diff --git a/src/three/plugins/images/ImageOverlayPlugin.d.ts b/src/three/plugins/images/ImageOverlayPlugin.d.ts index 1b1a0a6a4..858233322 100644 --- a/src/three/plugins/images/ImageOverlayPlugin.d.ts +++ b/src/three/plugins/images/ImageOverlayPlugin.d.ts @@ -21,6 +21,8 @@ export class ImageOverlay { color: number | Color; opacity: number; frame?: Matrix4 | null; + proxyUrl?: string; + fetchOptions?: any; } @@ -72,7 +74,6 @@ export class WMSTilesOverlay extends ImageOverlay { levels?: number, transparent?: boolean, contentBoundingBox?: [ number, number, number, number ], - color: number | Color, opacity: number, frame?: Matrix4 | null, diff --git a/src/three/plugins/images/ImageOverlayPlugin.js b/src/three/plugins/images/ImageOverlayPlugin.js index 2cff0d778..d20485519 100644 --- a/src/three/plugins/images/ImageOverlayPlugin.js +++ b/src/three/plugins/images/ImageOverlayPlugin.js @@ -961,7 +961,7 @@ export class ImageOverlayPlugin { _initOverlay( overlay ) { const { tiles } = this; - overlay.imageSource.fetchOptions = tiles.fetchOptions; + if ( ! overlay.isInitialized ) { overlay.imageSource.fetchData = ( ...args ) => tiles @@ -1401,14 +1401,29 @@ class ImageOverlay { } + get fetchOptions() { + + return this.imageSource.fetchOptions; + + } + + set fetchOptions( v ) { + + this.imageSource.fetchOptions = v; + + } + constructor( options = {} ) { const { opacity = 1, color = 0xffffff, frame = null, + preprocessURL = null, } = options; this.imageSource = null; + + this.preprocessURL = preprocessURL; this.opacity = opacity; this.color = new Color( color ); this.frame = frame !== null ? frame.clone() : null; @@ -1428,9 +1443,16 @@ class ImageOverlay { } - fetch( ...args ) { + // Apply proxy prefix and merge options + fetch( url, options = {} ) { + + if ( this.preprocessURL ) { + + url = this.preprocessURL( url ); + + } - return fetch( ...args ); + return fetch( url, options ); } @@ -1507,6 +1529,13 @@ export class WMSTilesOverlay extends ImageOverlay { super( options ); this.imageSource = new WMSImageSource( options ); + + if ( options.fetchOptions ) { + + this.imageSource.fetchOptions = options.fetchOptions; + + } + this.imageSource.fetchData = ( ...args ) => this.fetch( ...args ); } diff --git a/src/three/plugins/images/sources/WMSImageSource.js b/src/three/plugins/images/sources/WMSImageSource.js index 0e4170072..39994134f 100644 --- a/src/three/plugins/images/sources/WMSImageSource.js +++ b/src/three/plugins/images/sources/WMSImageSource.js @@ -140,7 +140,6 @@ export class WMSImageSource extends TiledImageSource { REQUEST: 'GetMap', VERSION: version, LAYERS: layer, - STYLES: styles, [ crsParam ]: crs, BBOX: bboxParam.join( ',' ), WIDTH: tileDimension, @@ -149,6 +148,14 @@ export class WMSImageSource extends TiledImageSource { TRANSPARENT: transparent ? 'TRUE' : 'FALSE', } ); + // Only add STYLES if it's defined (not null or undefined) + // This is a WMS-specific parameter, and giving it an unexpected value can lead to errors + if ( styles !== null && styles !== undefined ) { + + params.set( 'STYLES', styles ); + + } + return new URL( '?' + params.toString(), this.url ).toString(); }