-
Notifications
You must be signed in to change notification settings - Fork 301
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use gltf extension plugin in demos (#886)
* Update demos * README update
- Loading branch information
Showing
6 changed files
with
36 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
import { GeoUtils, WGS84_ELLIPSOID, TilesRenderer } from '3d-tiles-renderer'; | ||
import { GoogleCloudAuthPlugin, TilesFadePlugin, TileCompressionPlugin } from '3d-tiles-renderer/plugins'; | ||
import { GoogleCloudAuthPlugin, TilesFadePlugin, TileCompressionPlugin, GLTFExtensionsPlugin } from '3d-tiles-renderer/plugins'; | ||
import { | ||
Scene, | ||
WebGLRenderer, | ||
PerspectiveCamera, | ||
Raycaster, | ||
MathUtils, | ||
} from 'three'; | ||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; | ||
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js'; | ||
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js'; | ||
import { OrbitControls } from 'three/examples/jsm/controls/OrbitControls.js'; | ||
|
@@ -45,6 +44,12 @@ function reinstantiateTiles() { | |
tiles.registerPlugin( new GoogleCloudAuthPlugin( { apiToken: params.apiKey } ) ); | ||
tiles.registerPlugin( new TileCompressionPlugin() ); | ||
tiles.registerPlugin( new TilesFadePlugin() ); | ||
tiles.registerPlugin( new GLTFExtensionsPlugin( { | ||
// Note the DRACO compression files need to be supplied via an explicit source. | ||
// We use unpkg here but in practice should be provided by the application. | ||
dracoLoader: new DRACOLoader().setDecoderPath( 'https://unpkg.com/[email protected]/examples/jsm/libs/draco/gltf/' ) | ||
} ) ); | ||
|
||
// tiles.setLatLonToYUp( 35.3606 * MathUtils.DEG2RAD, 138.7274 * MathUtils.DEG2RAD ); // Mt Fuji | ||
// tiles.setLatLonToYUp( 48.8584 * MathUtils.DEG2RAD, 2.2945 * MathUtils.DEG2RAD ); // Eiffel Tower | ||
// tiles.setLatLonToYUp( 41.8902 * MathUtils.DEG2RAD, 12.4922 * MathUtils.DEG2RAD ); // Colosseum | ||
|
@@ -54,15 +59,6 @@ function reinstantiateTiles() { | |
// tiles.setLatLonToYUp( 34.9947 * MathUtils.DEG2RAD, 135.7847 * MathUtils.DEG2RAD ); // Kiyomizu-dera | ||
tiles.setLatLonToYUp( 35.6586 * MathUtils.DEG2RAD, 139.7454 * MathUtils.DEG2RAD ); // Tokyo Tower | ||
|
||
// Note the DRACO compression files need to be supplied via an explicit source. | ||
// We use unpkg here but in practice should be provided by the application. | ||
const dracoLoader = new DRACOLoader(); | ||
dracoLoader.setDecoderPath( 'https://unpkg.com/[email protected]/examples/jsm/libs/draco/gltf/' ); | ||
|
||
const loader = new GLTFLoader( tiles.manager ); | ||
loader.setDRACOLoader( dracoLoader ); | ||
|
||
tiles.manager.addHandler( /\.gltf$/, loader ); | ||
scene.add( tiles.group ); | ||
|
||
tiles.setResolutionFromRenderer( camera, renderer ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,7 @@ import { | |
UpdateOnChangePlugin, | ||
TileCompressionPlugin, | ||
UnloadTilesPlugin, | ||
GLTFExtensionsPlugin, | ||
} from '3d-tiles-renderer/plugins'; | ||
import { | ||
Scene, | ||
|
@@ -20,7 +21,6 @@ import { | |
MathUtils, | ||
OrthographicCamera, | ||
} from 'three'; | ||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; | ||
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js'; | ||
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js'; | ||
import Stats from 'three/examples/jsm/libs/stats.module.js'; | ||
|
@@ -65,6 +65,12 @@ function reinstantiateTiles() { | |
tiles.registerPlugin( new TileCompressionPlugin() ); | ||
tiles.registerPlugin( new UpdateOnChangePlugin() ); | ||
tiles.registerPlugin( new UnloadTilesPlugin() ); | ||
tiles.registerPlugin( new GLTFExtensionsPlugin( { | ||
// Note the DRACO compression files need to be supplied via an explicit source. | ||
// We use unpkg here but in practice should be provided by the application. | ||
dracoLoader: new DRACOLoader().setDecoderPath( 'https://unpkg.com/[email protected]/examples/jsm/libs/draco/gltf/' ) | ||
} ) ); | ||
|
||
|
||
if ( params.useBatchedMesh ) { | ||
|
||
|
@@ -77,16 +83,6 @@ function reinstantiateTiles() { | |
} | ||
|
||
tiles.group.rotation.x = - Math.PI / 2; | ||
|
||
// Note the DRACO compression files need to be supplied via an explicit source. | ||
// We use unpkg here but in practice should be provided by the application. | ||
const dracoLoader = new DRACOLoader(); | ||
dracoLoader.setDecoderPath( 'https://unpkg.com/[email protected]/examples/jsm/libs/draco/gltf/' ); | ||
|
||
const loader = new GLTFLoader( tiles.manager ); | ||
loader.setDRACOLoader( dracoLoader ); | ||
|
||
tiles.manager.addHandler( /\.gltf$/, loader ); | ||
scene.add( tiles.group ); | ||
|
||
tiles.setResolutionFromRenderer( transition.camera, renderer ); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ import { | |
import { | ||
DebugTilesPlugin, | ||
ImplicitTilingPlugin, | ||
GLTFCesiumRTCExtension, | ||
GLTFExtensionsPlugin, | ||
} from '3d-tiles-renderer/plugins'; | ||
import { | ||
Scene, | ||
|
@@ -37,7 +37,6 @@ import { | |
} from 'three'; | ||
import { FlyOrbitControls } from './src/controls/FlyOrbitControls.js'; | ||
import * as BufferGeometryUtils from 'three/examples/jsm/utils/BufferGeometryUtils.js'; | ||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; | ||
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js'; | ||
import { KTX2Loader } from 'three/examples/jsm/loaders/KTX2Loader.js'; | ||
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js'; | ||
|
@@ -96,10 +95,6 @@ function reinstantiateTiles() { | |
|
||
} | ||
|
||
tiles = new TilesRenderer( url ); | ||
tiles.registerPlugin( new DebugTilesPlugin() ); | ||
tiles.registerPlugin( new ImplicitTilingPlugin() ); | ||
|
||
// Note the DRACO compression files need to be supplied via an explicit source. | ||
// We use unpkg here but in practice should be provided by the application. | ||
const dracoLoader = new DRACOLoader(); | ||
|
@@ -109,13 +104,16 @@ function reinstantiateTiles() { | |
ktx2loader.setTranscoderPath( 'https://unpkg.com/[email protected]/examples/jsm/libs/basis/' ); | ||
ktx2loader.detectSupport( renderer ); | ||
|
||
const loader = new GLTFLoader( tiles.manager ); | ||
loader.setDRACOLoader( dracoLoader ); | ||
loader.setKTX2Loader( ktx2loader ); | ||
loader.register( () => new GLTFCesiumRTCExtension() ); | ||
tiles = new TilesRenderer( url ); | ||
tiles.registerPlugin( new DebugTilesPlugin() ); | ||
tiles.registerPlugin( new ImplicitTilingPlugin() ); | ||
tiles.registerPlugin( new GLTFExtensionsPlugin( { | ||
rtc: true, | ||
dracoLoader: dracoLoader, | ||
ktxLoader: ktx2loader, | ||
} ) ); | ||
|
||
tiles.fetchOptions.mode = 'cors'; | ||
tiles.manager.addHandler( /\.gltf$/, loader ); | ||
geospatialRotationParent.add( tiles.group ); | ||
|
||
// Used with CUSTOM_COLOR | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import { EnvironmentControls, TilesRenderer } from '3d-tiles-renderer'; | ||
import { CesiumIonAuthPlugin } from '3d-tiles-renderer/plugins'; | ||
import { CesiumIonAuthPlugin, GLTFExtensionsPlugin } from '3d-tiles-renderer/plugins'; | ||
import { | ||
Scene, | ||
WebGLRenderer, | ||
|
@@ -10,7 +10,6 @@ import { | |
DataTexture, | ||
EquirectangularReflectionMapping | ||
} from 'three'; | ||
import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; | ||
import { DRACOLoader } from 'three/examples/jsm/loaders/DRACOLoader.js'; | ||
import { GUI } from 'three/examples/jsm/libs/lil-gui.module.min.js'; | ||
|
||
|
@@ -46,16 +45,12 @@ function rotationBetweenDirections( dir1, dir2 ) { | |
function setupTiles() { | ||
|
||
tiles.fetchOptions.mode = 'cors'; | ||
tiles.registerPlugin( new GLTFExtensionsPlugin( { | ||
// Note the DRACO compression files need to be supplied via an explicit source. | ||
// We use unpkg here but in practice should be provided by the application. | ||
dracoLoader: new DRACOLoader().setDecoderPath( 'https://unpkg.com/[email protected]/examples/jsm/libs/draco/gltf/' ) | ||
} ) ); | ||
|
||
// Note the DRACO compression files need to be supplied via an explicit source. | ||
// We use unpkg here but in practice should be provided by the application. | ||
const dracoLoader = new DRACOLoader(); | ||
dracoLoader.setDecoderPath( 'https://unpkg.com/[email protected]/examples/jsm/libs/draco/gltf/' ); | ||
|
||
const loader = new GLTFLoader( tiles.manager ); | ||
loader.setDRACOLoader( dracoLoader ); | ||
|
||
tiles.manager.addHandler( /\.gltf$/, loader ); | ||
scene.add( tiles.group ); | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters