diff --git a/src/index.d.ts b/src/index.d.ts index d95032ba..7ed8900b 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -5,7 +5,6 @@ export { B3DMLoader, B3DMScene } from './three/loaders/B3DMLoader'; export { I3DMLoader, I3DMScene } from './three/loaders/I3DMLoader'; export { PNTSLoader, PNTSScene } from './three/loaders/PNTSLoader'; export { CMPTLoader } from './three/loaders/CMPTLoader'; -export { GLTFExtensionLoader } from './three/loaders/GLTFExtensionLoader'; export { Ellipsoid } from './three/math/Ellipsoid'; export { EllipsoidRegion } from './three/math/EllipsoidRegion'; export * as GeoUtils from './three/math/GeoUtils'; diff --git a/src/index.js b/src/index.js index a9653831..cc716859 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,6 @@ export { B3DMLoader } from './three/loaders/B3DMLoader.js'; export { PNTSLoader } from './three/loaders/PNTSLoader.js'; export { I3DMLoader } from './three/loaders/I3DMLoader.js'; export { CMPTLoader } from './three/loaders/CMPTLoader.js'; -export { GLTFExtensionLoader } from './three/loaders/GLTFExtensionLoader.js'; export * from './three/math/Ellipsoid.js'; export * from './three/math/EllipsoidRegion.js'; diff --git a/src/three/TilesRenderer.js b/src/three/TilesRenderer.js index 4e1e0397..97f94e5a 100644 --- a/src/three/TilesRenderer.js +++ b/src/three/TilesRenderer.js @@ -3,7 +3,6 @@ import { B3DMLoader } from './loaders/B3DMLoader.js'; import { PNTSLoader } from './loaders/PNTSLoader.js'; import { I3DMLoader } from './loaders/I3DMLoader.js'; import { CMPTLoader } from './loaders/CMPTLoader.js'; -import { GLTFExtensionLoader } from './loaders/GLTFExtensionLoader.js'; import { TilesGroup } from './TilesGroup.js'; import { Matrix4, @@ -19,6 +18,7 @@ import { TileBoundingVolume } from './math/TileBoundingVolume.js'; import { ExtendedFrustum } from './math/ExtendedFrustum.js'; import { estimateBytesUsed } from './utilities.js'; import { WGS84_ELLIPSOID } from './math/GeoConstants.js'; +import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; const _mat = new Matrix4(); const _euler = new Euler(); @@ -643,10 +643,25 @@ export class TilesRenderer extends TilesRendererBase { case 'gltf': case 'glb': { - const loader = new GLTFExtensionLoader( manager ); - loader.workingPath = workingPath; - loader.fetchOptions = fetchOptions; - promise = loader.parse( buffer ).then( result => { + const loader = manager.getHandler( 'path.gltf' ) || manager.getHandler( 'path.glb' ) || new GLTFLoader( manager ); + loader.setWithCredentials( fetchOptions.credentials === 'include' ); + loader.setRequestHeader( fetchOptions.headers || {} ); + if ( fetchOptions.credentials === 'include' && fetchOptions.mode === 'cors' ) { + + loader.setCrossOrigin( 'use-credentials' ); + + } + + // assume any pre-registered loader has paths configured as the user desires, but if we're making + // a new loader, use the working path during parse to support relative uris on other hosts + let resourcePath = loader.resourcePath || loader.path || workingPath; + if ( ! /[\\/]$/.test( resourcePath ) && resourcePath.length ) { + + resourcePath += '/'; + + } + + promise = loader.parseAsync( buffer, resourcePath ).then( result => { // apply the local up-axis correction rotation // GLTFLoader seems to never set a transformation on the root scene object so diff --git a/src/three/loaders/GLTFExtensionLoader.d.ts b/src/three/loaders/GLTFExtensionLoader.d.ts deleted file mode 100644 index 724f8f8f..00000000 --- a/src/three/loaders/GLTFExtensionLoader.d.ts +++ /dev/null @@ -1,11 +0,0 @@ - -import { GLTF } from 'three/examples/jsm/loaders/GLTFLoader'; -import { LoaderBase } from '../../base/loaders/LoaderBase'; -import { LoadingManager } from 'three'; - -export class GLTFExtensionLoader extends LoaderBase { - - constructor( manager : LoadingManager ); - parse( buffer : ArrayBuffer ) : Promise< GLTF >; - -} diff --git a/src/three/loaders/GLTFExtensionLoader.js b/src/three/loaders/GLTFExtensionLoader.js deleted file mode 100644 index 34366360..00000000 --- a/src/three/loaders/GLTFExtensionLoader.js +++ /dev/null @@ -1,65 +0,0 @@ -import { DefaultLoadingManager } from 'three'; -import { GLTFLoader } from 'three/examples/jsm/loaders/GLTFLoader.js'; -import { LoaderBase } from '../../base/loaders/LoaderBase.js'; - -export class GLTFExtensionLoader extends LoaderBase { - - constructor( manager = DefaultLoadingManager ) { - - super(); - this.manager = manager; - - } - - parse( buffer ) { - - return new Promise( ( resolve, reject ) => { - - const manager = this.manager; - const fetchOptions = this.fetchOptions; - let loader = manager.getHandler( 'path.gltf' ) || manager.getHandler( 'path.glb' ); - - if ( ! loader ) { - - loader = new GLTFLoader( manager ); - - } - - if ( fetchOptions.credentials === 'include' && fetchOptions.mode === 'cors' ) { - - loader.setCrossOrigin( 'use-credentials' ); - - } - - if ( 'credentials' in fetchOptions ) { - - loader.setWithCredentials( fetchOptions.credentials === 'include' ); - - } - - if ( fetchOptions.headers ) { - - loader.setRequestHeader( fetchOptions.headers ); - - } - - // assume any pre-registered loader has paths configured as the user desires, but if we're making - // a new loader, use the working path during parse to support relative uris on other hosts - let resourcePath = loader.resourcePath || loader.path || this.workingPath; - if ( ! /[\\/]$/.test( resourcePath ) && resourcePath.length ) { - - resourcePath += '/'; - - } - - loader.parse( buffer, resourcePath, model => { - - resolve( model ); - - }, reject ); - - } ); - - } - -}