|
2 | 2 | /** @import { WMTSTileMatrix } from './WMTSImageSource.js' */ |
3 | 3 | /** @import { VectorTileStyle } from './utils/VectorShapeCanvasRenderer.js' */ |
4 | 4 | import { Color, BufferAttribute, Matrix4, Vector3, Box3, Triangle, CanvasTexture } from 'three'; |
5 | | -import { PriorityQueue, PriorityQueueItemRemovedError, unifiedPriorityCallback } from '3d-tiles-renderer/core'; |
| 5 | +import { PriorityQueue, PriorityQueueItemRemovedError, unifiedPriorityCallback, DEFAULT_DOWNLOAD_QUEUE } from '3d-tiles-renderer/core'; |
6 | 6 | import { CesiumIonAuth, GoogleCloudAuth } from '3d-tiles-renderer/core/plugins'; |
7 | 7 | import { XYZImageSource } from './sources/XYZImageSource.js'; |
8 | 8 | import { QuadKeyImageSource } from './sources/QuadKeyImageSource.js'; |
@@ -928,24 +928,13 @@ export class ImageOverlayPlugin { |
928 | 928 | // initialize the overlay to use the right fetch options, load all data for existing tiles |
929 | 929 | _initOverlay( overlay ) { |
930 | 930 |
|
931 | | - const { tiles, processedTiles } = this; |
| 931 | + const { processedTiles } = this; |
932 | 932 |
|
933 | 933 | overlay.init().then( () => { |
934 | 934 |
|
935 | 935 | // Set resolution on the overlay |
936 | 936 | overlay.setResolution( this.resolution ); |
937 | 937 |
|
938 | | - // TODO: we should move away from reaching into specific "tiles renderer" download queue. |
939 | | - // We should prefer an overarching, common download system. |
940 | | - const overlayFetch = overlay.fetch.bind( overlay ); |
941 | | - overlay.fetch = ( ...args ) => tiles |
942 | | - .downloadQueue |
943 | | - .add( { priority: - performance.now() }, () => { |
944 | | - |
945 | | - return overlayFetch( ...args ); |
946 | | - |
947 | | - } ); |
948 | | - |
949 | 938 | } ); |
950 | 939 |
|
951 | 940 | const promises = []; |
@@ -1396,6 +1385,7 @@ export class ImageOverlay { |
1396 | 1385 | this.frame = frame !== null ? frame.clone() : null; |
1397 | 1386 | this.alphaMask = alphaMask; |
1398 | 1387 | this.alphaInvert = alphaInvert; |
| 1388 | + this.downloadQueue = DEFAULT_DOWNLOAD_QUEUE; |
1399 | 1389 |
|
1400 | 1390 | this._whenReady = null; |
1401 | 1391 | this.isReady = false; |
@@ -1438,7 +1428,7 @@ export class ImageOverlay { |
1438 | 1428 |
|
1439 | 1429 | } |
1440 | 1430 |
|
1441 | | - return fetch( url, options ); |
| 1431 | + return this.downloadQueue.add( { priority: - performance.now() }, () => fetch( url, options ) ); |
1442 | 1432 |
|
1443 | 1433 | } |
1444 | 1434 |
|
@@ -2097,10 +2087,22 @@ export class CesiumIonOverlay extends TiledImageOverlay { |
2097 | 2087 |
|
2098 | 2088 | } |
2099 | 2089 |
|
2100 | | - fetch( ...args ) { |
| 2090 | + fetch( url, options = {} ) { |
2101 | 2091 |
|
2102 | 2092 | // bypass auth fetch if asset is external type to prevent CORS error due to wrong bearer token |
2103 | | - return this.externalType ? super.fetch( ...args ) : this.auth.fetch( ...args ); |
| 2093 | + if ( this.externalType ) { |
| 2094 | + |
| 2095 | + return super.fetch( url, options ); |
| 2096 | + |
| 2097 | + } |
| 2098 | + |
| 2099 | + if ( this.preprocessURL ) { |
| 2100 | + |
| 2101 | + url = this.preprocessURL( url ); |
| 2102 | + |
| 2103 | + } |
| 2104 | + |
| 2105 | + return this.downloadQueue.add( { priority: - performance.now() }, () => this.auth.fetch( url, options ) ); |
2104 | 2106 |
|
2105 | 2107 | } |
2106 | 2108 |
|
@@ -2166,9 +2168,15 @@ export class GoogleMapsOverlay extends TiledImageOverlay { |
2166 | 2168 |
|
2167 | 2169 | } |
2168 | 2170 |
|
2169 | | - fetch( ...args ) { |
| 2171 | + fetch( url, options = {} ) { |
| 2172 | + |
| 2173 | + if ( this.preprocessURL ) { |
| 2174 | + |
| 2175 | + url = this.preprocessURL( url ); |
| 2176 | + |
| 2177 | + } |
2170 | 2178 |
|
2171 | | - return this.auth.fetch( ...args ); |
| 2179 | + return this.downloadQueue.add( { priority: - performance.now() }, () => this.auth.fetch( url, options ) ); |
2172 | 2180 |
|
2173 | 2181 | } |
2174 | 2182 |
|
|
0 commit comments