Skip to content

Commit

Permalink
EnvironmentControls, GlobeControls: move to core (#477)
Browse files Browse the repository at this point in the history
* Move controls files

* Remove hard corded ellipsoid reference

* Export the controls

* Update example
  • Loading branch information
gkjohnson committed Feb 9, 2024
1 parent d898b86 commit adf6238
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 4 deletions.
8 changes: 6 additions & 2 deletions example/googleMapsExample.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { GeoUtils, WGS84_ELLIPSOID, DebugGoogleTilesRenderer as GoogleTilesRenderer } from '../src/index.js';
import {
WGS84_ELLIPSOID,
GeoUtils,
GlobeControls,
DebugGoogleTilesRenderer as GoogleTilesRenderer,
} from '../src/index.js';
import {
Scene,
WebGLRenderer,
Expand All @@ -10,7 +15,6 @@ import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js';
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js';
import { estimateBytesUsed } from 'three/examples/jsm/utils/BufferGeometryUtils.js';
import Stats from 'three/examples/jsm/libs/stats.module.js';
import { GlobeControls } from './src/controls/GlobeControls.js';

let camera, controls, scene, renderer, tiles;
let statsContainer, stats;
Expand Down
7 changes: 7 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export * from './three/DebugTilesRenderer.js';

// three.js
export { TilesRenderer } from './three/TilesRenderer.js';
export { B3DMLoader } from './three/B3DMLoader.js';
export { PNTSLoader } from './three/PNTSLoader.js';
Expand All @@ -16,6 +17,11 @@ export * from './three/math/GeoConstants.js';
export * from './three/renderers/GoogleTilesRenderer.js';
export * from './three/renderers/CesiumIonTilesRenderer.js';

// three.js controls
export { GlobeControls } from './three/controls/GlobeControls.js';
export { EnvironmentControls } from './three/controls/EnvironmentControls.js';

// common
export { TilesRendererBase } from './base/TilesRendererBase.js';
export { LoaderBase } from './base/LoaderBase.js';
export { B3DMLoaderBase } from './base/B3DMLoaderBase.js';
Expand All @@ -26,3 +32,4 @@ export * from './base/constants.js';

export { LRUCache } from './utilities/LRUCache.js';
export { PriorityQueue } from './utilities/PriorityQueue.js';

File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
} from 'three';
import { EnvironmentControls, NONE } from './EnvironmentControls.js';
import { makeRotateAroundPoint } from './utils.js';
import { WGS84_ELLIPSOID } from '../../../src/index.js';

const _invMatrix = new Matrix4();
const _rotMatrix = new Matrix4();
Expand Down Expand Up @@ -116,6 +115,7 @@ export class GlobeControls extends EnvironmentControls {
camera,
tilesGroup,
pivotMesh,
ellipsoid,
} = this;

// clamp the camera distance
Expand Down Expand Up @@ -150,7 +150,7 @@ export class GlobeControls extends EnvironmentControls {
}

// update the projection matrix
const largestDistance = Math.max( ...WGS84_ELLIPSOID.radius );
const largestDistance = Math.max( ...ellipsoid.radius );
camera.near = Math.max( 1, distanceToCenter - largestDistance * 1.25 );
camera.far = distanceToCenter + largestDistance + 0.1;
camera.updateProjectionMatrix();
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit adf6238

Please sign in to comment.