Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/babylonjs/renderer/loaders/B3DMLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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<Object>}
*/
async parse( buffer, uri ) {
async parse( buffer, url ) {

const b3dm = super.parse( buffer );

Expand All @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions src/babylonjs/renderer/loaders/GLTFLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions src/babylonjs/renderer/tiles/TilesRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

}
Expand All @@ -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;

}
Expand Down
14 changes: 7 additions & 7 deletions src/core/plugins/CesiumIonAuthPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) {
Expand All @@ -160,7 +160,7 @@ export class CesiumIonAuthPlugin {

} else {

return this.auth.fetch( uri, options );
return this.auth.fetch( url, options );

}

Expand Down
4 changes: 2 additions & 2 deletions src/core/plugins/GoogleCloudAuthPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

}

Expand Down
8 changes: 4 additions & 4 deletions src/core/renderer/loaders/I3DMLoaderBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 }` );

}

Expand Down
2 changes: 1 addition & 1 deletion src/core/renderer/tiles/TilesRendererBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export interface TilesRendererBaseEventMap<TScene = unknown> {
'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 };
Expand Down
32 changes: 21 additions & 11 deletions src/core/renderer/tiles/TilesRendererBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/

/**
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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;

} )
Expand Down Expand Up @@ -1742,15 +1752,15 @@ 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;
return Promise.resolve();

} 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 ) );

}

Expand Down Expand Up @@ -1796,7 +1806,7 @@ export class TilesRendererBase {
this.dispatchEvent( {
type: 'load-tileset',
tileset: externalTileset,
url: uri,
url,
} );

}
Expand All @@ -1807,7 +1817,7 @@ export class TilesRendererBase {
type: 'load-model',
scene: tile.engineData.scene,
tile,
url: uri,
url,
} );

}
Expand Down Expand Up @@ -1857,7 +1867,7 @@ export class TilesRendererBase {
type: 'load-error',
tile,
error,
url: uri,
url,
} );

} else {
Expand Down
8 changes: 4 additions & 4 deletions src/three/plugins/QuantizedMeshPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export class QuantizedMeshPlugin {

}

parseToMesh( buffer, tile, extension, uri ) {
parseToMesh( buffer, tile, extension, url ) {

const {
skirtLength,
Expand All @@ -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';

Expand Down Expand Up @@ -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();

Expand Down
4 changes: 2 additions & 2 deletions src/three/plugins/gltf/GLTFStructuralMetadataExtension.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
Expand Down
6 changes: 3 additions & 3 deletions src/three/plugins/images/GeneratedSurfacePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' ) {

Expand Down Expand Up @@ -452,9 +452,9 @@ export class GeneratedSurfacePlugin {

}

fetchData( uri ) {
fetchData( url ) {

if ( /generated_surface/.test( uri ) ) {
if ( /generated_surface/.test( url ) ) {

return new ArrayBuffer();

Expand Down
6 changes: 3 additions & 3 deletions src/three/plugins/images/ImageOverlayPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export class ImageOverlayPlugin {

}

parseToMesh( buffer, tile, extension, uri ) {
parseToMesh( buffer, tile, extension, url ) {

if ( extension === 'image_overlay_tile_split' ) {

Expand Down Expand Up @@ -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();

Expand Down
6 changes: 3 additions & 3 deletions src/three/renderer/tiles/TilesRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;

}
Expand Down
Loading