diff --git a/src/babylonjs/renderer/loaders/B3DMLoader.js b/src/babylonjs/renderer/loaders/B3DMLoader.js index 8eb64c755..836c240dd 100644 --- a/src/babylonjs/renderer/loaders/B3DMLoader.js +++ b/src/babylonjs/renderer/loaders/B3DMLoader.js @@ -31,10 +31,10 @@ export class B3DMLoader extends B3DMLoaderBase { /** * @param {ArrayBuffer} buffer - The raw B3DM file data. - * @param {string} uri - URI used for resolving relative resources. + * @param {string} url - URL used for resolving relative resources. * @returns {Promise} */ - async parse( buffer, uri ) { + async parse( buffer, url ) { const b3dm = super.parse( buffer ); @@ -51,7 +51,7 @@ export class B3DMLoader extends B3DMLoaderBase { } // parse the file - const result = await gltfLoader.parse( b3dm.glbBytes, uri, 'glb' ); + const result = await gltfLoader.parse( b3dm.glbBytes, url, 'glb' ); const gltfScene = result.scene; return { ...b3dm, diff --git a/src/babylonjs/renderer/loaders/GLTFLoader.js b/src/babylonjs/renderer/loaders/GLTFLoader.js index 15179d7a4..4dc0e2f0b 100644 --- a/src/babylonjs/renderer/loaders/GLTFLoader.js +++ b/src/babylonjs/renderer/loaders/GLTFLoader.js @@ -36,11 +36,11 @@ export class GLTFLoader extends LoaderBase { /** * @param {ArrayBuffer} buffer - The raw GLTF or GLB file data. - * @param {string} uri - URI used for resolving relative resources. + * @param {string} url - URL used for resolving relative resources. * @param {string} extension - File extension, either `'gltf'` or `'glb'`. * @returns {Promise<{scene: TransformNode, container: AssetContainer, metadata: Object|null}>} */ - async parse( buffer, uri, extension ) { + async parse( buffer, url, extension ) { const { scene, workingPath, adjustmentTransform } = this; @@ -56,7 +56,7 @@ export class GLTFLoader extends LoaderBase { const pluginExtension = extension === 'gltf' ? '.gltf' : '.glb'; let metadata = null; const container = await LoadAssetContainerAsync( - new File( [ buffer ], uri ), + new File( [ buffer ], url ), scene, { pluginExtension, diff --git a/src/babylonjs/renderer/tiles/TilesRenderer.js b/src/babylonjs/renderer/tiles/TilesRenderer.js index 15e6c111f..beb9adfd4 100644 --- a/src/babylonjs/renderer/tiles/TilesRenderer.js +++ b/src/babylonjs/renderer/tiles/TilesRenderer.js @@ -161,11 +161,11 @@ export class TilesRenderer extends TilesRendererBase { } - async parseTile( buffer, tile, extension, uri, abortSignal ) { + async parseTile( buffer, tile, extension, url, abortSignal ) { const engineData = tile.engineData; const rootScene = this.scene; - const workingPath = LoaderUtils.getWorkingPath( uri ); + const workingPath = LoaderUtils.getWorkingPath( url ); const fetchOptions = this.fetchOptions; const tileTransform = engineData.transform; @@ -183,7 +183,7 @@ export class TilesRenderer extends TilesRendererBase { loader.fetchOptions = fetchOptions; loader.adjustmentTransform.copyFrom( upRotationMatrix ); - result = await loader.parse( buffer, uri ); + result = await loader.parse( buffer, url ); break; } @@ -196,7 +196,7 @@ export class TilesRenderer extends TilesRendererBase { loader.fetchOptions = fetchOptions; loader.adjustmentTransform.copyFrom( upRotationMatrix ); - result = await loader.parse( buffer, uri, extension ); + result = await loader.parse( buffer, url, extension ); break; } diff --git a/src/core/plugins/CesiumIonAuthPlugin.js b/src/core/plugins/CesiumIonAuthPlugin.js index ed70a3693..4af0dcdea 100644 --- a/src/core/plugins/CesiumIonAuthPlugin.js +++ b/src/core/plugins/CesiumIonAuthPlugin.js @@ -138,20 +138,20 @@ export class CesiumIonAuthPlugin { } - preprocessURL( uri ) { + preprocessURL( url ) { - uri = new URL( uri ); - if ( /^http/.test( uri.protocol ) && this._tileSetVersion != - 1 ) { + url = new URL( url ); + if ( /^http/.test( url.protocol ) && this._tileSetVersion != - 1 ) { - uri.searchParams.set( 'v', this._tileSetVersion ); + url.searchParams.set( 'v', this._tileSetVersion ); } - return uri.toString(); + return url.toString(); } - fetchData( uri, options ) { + fetchData( url, options ) { const tiles = this.tiles; if ( tiles.getPluginByName( 'GOOGLE_CLOUD_AUTH_PLUGIN' ) !== null ) { @@ -160,7 +160,7 @@ export class CesiumIonAuthPlugin { } else { - return this.auth.fetch( uri, options ); + return this.auth.fetch( url, options ); } diff --git a/src/core/plugins/GoogleCloudAuthPlugin.js b/src/core/plugins/GoogleCloudAuthPlugin.js index b8682b88f..5d3eca5f2 100644 --- a/src/core/plugins/GoogleCloudAuthPlugin.js +++ b/src/core/plugins/GoogleCloudAuthPlugin.js @@ -137,9 +137,9 @@ export class GoogleCloudAuthPlugin { } - async fetchData( uri, options ) { + async fetchData( url, options ) { - return this.auth.fetch( uri, options ); + return this.auth.fetch( url, options ); } diff --git a/src/core/renderer/loaders/I3DMLoaderBase.js b/src/core/renderer/loaders/I3DMLoaderBase.js index 44348f3c5..95c258e21 100644 --- a/src/core/renderer/loaders/I3DMLoaderBase.js +++ b/src/core/renderer/loaders/I3DMLoaderBase.js @@ -97,17 +97,17 @@ export class I3DMLoaderBase extends LoaderBase { } else { - const externalUri = this.resolveExternalURL( arrayToString( bodyBytes ) ); + const externalUrl = this.resolveExternalURL( arrayToString( bodyBytes ) ); //Store the gltf working path - gltfWorkingPath = getWorkingPath( externalUri ); + gltfWorkingPath = getWorkingPath( externalUrl ); - promise = fetch( externalUri, this.fetchOptions ) + promise = fetch( externalUrl, this.fetchOptions ) .then( res => { if ( ! res.ok ) { - throw new Error( `I3DMLoaderBase : Failed to load file "${ externalUri }" with status ${ res.status } : ${ res.statusText }` ); + throw new Error( `I3DMLoaderBase : Failed to load file "${ externalUrl }" with status ${ res.status } : ${ res.statusText }` ); } diff --git a/src/core/renderer/tiles/TilesRendererBase.d.ts b/src/core/renderer/tiles/TilesRendererBase.d.ts index e0bf637b9..c64c47789 100644 --- a/src/core/renderer/tiles/TilesRendererBase.d.ts +++ b/src/core/renderer/tiles/TilesRendererBase.d.ts @@ -13,7 +13,7 @@ export interface TilesRendererBaseEventMap { 'load-root-tileset': { tileset : Tileset, url : string }; 'tiles-load-start': {}; 'tiles-load-end': {}; - 'tile-download-start': { tile : Tile, uri : string }; + 'tile-download-start': { tile : Tile, url : string, /** @deprecated Use url instead. */ uri : string }; 'load-model': { scene : TScene, tile : Tile, url : string }; 'dispose-model': { scene : TScene, tile : Tile }; 'tile-visibility-change': { scene : TScene, tile : Tile, visible : boolean }; diff --git a/src/core/renderer/tiles/TilesRendererBase.js b/src/core/renderer/tiles/TilesRendererBase.js index 7b00a89ac..9adf05aab 100644 --- a/src/core/renderer/tiles/TilesRendererBase.js +++ b/src/core/renderer/tiles/TilesRendererBase.js @@ -284,7 +284,7 @@ const unifiedPriorityCallback = ( a, b ) => { * Fired when a tile content download begins. * @event TilesRendererBase#tile-download-start * @property {Tile} tile - The tile being downloaded. - * @property {string} uri - The URI being fetched. + * @property {string} url - The URL being fetched. */ /** @@ -1586,15 +1586,15 @@ export class TilesRendererBase { let isExternalTileset = false; let externalTileset = null; - let uri = new URL( tile.content.uri, tile.internal.basePath + '/' ).toString(); - this.invokeAllPlugins( plugin => uri = plugin.preprocessURL ? plugin.preprocessURL( uri, tile ) : uri ); + let url = new URL( tile.content.uri, tile.internal.basePath + '/' ).toString(); + this.invokeAllPlugins( plugin => url = plugin.preprocessURL ? plugin.preprocessURL( url, tile ) : url ); const stats = this.stats; const lruCache = this.lruCache; const downloadQueue = this.downloadQueue; const parseQueue = this.parseQueue; const loadingTiles = this.loadingTiles; - const extension = getUrlExtension( uri ); + const extension = getUrlExtension( url ); // track an abort controller and pass-through the below conditions if aborted const controller = new AbortController(); @@ -1690,8 +1690,18 @@ export class TilesRendererBase { stats.downloading ++; stats.queued --; - const res = this.invokeOnePlugin( plugin => plugin.fetchData && plugin.fetchData( uri, { ...this.fetchOptions, signal } ) ); - this.dispatchEvent( { type: 'tile-download-start', tile, uri } ); + const res = this.invokeOnePlugin( plugin => plugin.fetchData && plugin.fetchData( url, { ...this.fetchOptions, signal } ) ); + this.dispatchEvent( { + type: 'tile-download-start', + tile, + url, + get uri() { + + console.warn( 'tile-download-start event: "uri" has been renamed to "url".' ); + return this.url; + + }, + } ); return res; } ) @@ -1742,7 +1752,7 @@ export class TilesRendererBase { if ( extension === 'json' && content.root ) { - this.preprocessTileset( content, uri, tile ); + this.preprocessTileset( content, url, tile ); tile.children.push( content.root ); externalTileset = content; isExternalTileset = true; @@ -1750,7 +1760,7 @@ export class TilesRendererBase { } else { - return this.invokeOnePlugin( plugin => plugin.parseTile && plugin.parseTile( content, parseTile, extension, uri, signal ) ); + return this.invokeOnePlugin( plugin => plugin.parseTile && plugin.parseTile( content, parseTile, extension, url, signal ) ); } @@ -1796,7 +1806,7 @@ export class TilesRendererBase { this.dispatchEvent( { type: 'load-tileset', tileset: externalTileset, - url: uri, + url, } ); } @@ -1807,7 +1817,7 @@ export class TilesRendererBase { type: 'load-model', scene: tile.engineData.scene, tile, - url: uri, + url, } ); } @@ -1857,7 +1867,7 @@ export class TilesRendererBase { type: 'load-error', tile, error, - url: uri, + url, } ); } else { diff --git a/src/three/plugins/QuantizedMeshPlugin.js b/src/three/plugins/QuantizedMeshPlugin.js index 962142088..a3c8cc6f1 100644 --- a/src/three/plugins/QuantizedMeshPlugin.js +++ b/src/three/plugins/QuantizedMeshPlugin.js @@ -230,7 +230,7 @@ export class QuantizedMeshPlugin { } - parseToMesh( buffer, tile, extension, uri ) { + parseToMesh( buffer, tile, extension, url ) { const { skirtLength, @@ -248,7 +248,7 @@ export class QuantizedMeshPlugin { if ( extension === 'quantized_tile_split' ) { // split the parent tile - const searchParams = new URL( uri ).searchParams; + const searchParams = new URL( url ).searchParams; const left = searchParams.get( 'left' ) === 'true'; const bottom = searchParams.get( 'bottom' ) === 'true'; @@ -443,10 +443,10 @@ export class QuantizedMeshPlugin { } - fetchData( uri, options ) { + fetchData( url, options ) { // if this is our custom url indicating a tile split then return fake response - if ( /quantized_tile_split/.test( uri ) ) { + if ( /quantized_tile_split/.test( url ) ) { return new ArrayBuffer(); diff --git a/src/three/plugins/gltf/GLTFStructuralMetadataExtension.js b/src/three/plugins/gltf/GLTFStructuralMetadataExtension.js index 8e3d2eefd..67f5e2c34 100644 --- a/src/three/plugins/gltf/GLTFStructuralMetadataExtension.js +++ b/src/three/plugins/gltf/GLTFStructuralMetadataExtension.js @@ -100,13 +100,13 @@ export class GLTFStructuralMetadataExtension { // TODO: cache the loaded schema so we can share it and dispose of it when the // extension is no longer available const { manager, path, requestHeader, crossOrigin } = parser.options; - const finalUri = new URL( rootExtension.schemaUri, path ).toString(); + const finalUrl = new URL( rootExtension.schemaUri, path ).toString(); const fileLoader = new FileLoader( manager ); fileLoader.setCrossOrigin( crossOrigin ); fileLoader.setResponseType( 'json' ); fileLoader.setRequestHeader( requestHeader ); - schemaPromise = fileLoader.loadAsync( finalUri ) + schemaPromise = fileLoader.loadAsync( finalUrl ) .then( schema => { rootExtension = { ...rootExtension, schema }; diff --git a/src/three/plugins/images/GeneratedSurfacePlugin.js b/src/three/plugins/images/GeneratedSurfacePlugin.js index 92c88bd5b..762f519f3 100644 --- a/src/three/plugins/images/GeneratedSurfacePlugin.js +++ b/src/three/plugins/images/GeneratedSurfacePlugin.js @@ -91,7 +91,7 @@ export class GeneratedSurfacePlugin { } - async parseToMesh( buffer, tile, extension, uri, abortSignal ) { + async parseToMesh( buffer, tile, extension, url, abortSignal ) { if ( extension !== 'generated_surface' ) { @@ -452,9 +452,9 @@ export class GeneratedSurfacePlugin { } - fetchData( uri ) { + fetchData( url ) { - if ( /generated_surface/.test( uri ) ) { + if ( /generated_surface/.test( url ) ) { return new ArrayBuffer(); diff --git a/src/three/plugins/images/ImageOverlayPlugin.js b/src/three/plugins/images/ImageOverlayPlugin.js index fbf6f442e..0b82eea47 100644 --- a/src/three/plugins/images/ImageOverlayPlugin.js +++ b/src/three/plugins/images/ImageOverlayPlugin.js @@ -437,7 +437,7 @@ export class ImageOverlayPlugin { } - parseToMesh( buffer, tile, extension, uri ) { + parseToMesh( buffer, tile, extension, url ) { if ( extension === 'image_overlay_tile_split' ) { @@ -780,10 +780,10 @@ export class ImageOverlayPlugin { } - fetchData( uri, options ) { + fetchData( url, options ) { // if this is our custom url indicating a tile split then return fake response - if ( /image_overlay_tile_split/.test( uri ) ) { + if ( /image_overlay_tile_split/.test( url ) ) { return new ArrayBuffer(); diff --git a/src/three/renderer/tiles/TilesRenderer.js b/src/three/renderer/tiles/TilesRenderer.js index e43eea0aa..af8e722d9 100644 --- a/src/three/renderer/tiles/TilesRenderer.js +++ b/src/three/renderer/tiles/TilesRenderer.js @@ -644,10 +644,10 @@ export class TilesRenderer extends TilesRendererBase { } - async parseTile( buffer, tile, extension, uri, abortSignal ) { + async parseTile( buffer, tile, extension, url, abortSignal ) { const engineData = tile.engineData; - const workingPath = LoaderUtils.getWorkingPath( uri ); + const workingPath = LoaderUtils.getWorkingPath( url ); const fetchOptions = this.fetchOptions; const manager = this.manager; @@ -758,7 +758,7 @@ export class TilesRenderer extends TilesRendererBase { default: { - promise = this.invokeOnePlugin( plugin => plugin.parseToMesh && plugin.parseToMesh( buffer, tile, extension, uri, abortSignal ) ); + promise = this.invokeOnePlugin( plugin => plugin.parseToMesh && plugin.parseToMesh( buffer, tile, extension, url, abortSignal ) ); break; }