From f5ed28e65f266fd66f496b1188e6a666c85908a9 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 21 May 2026 11:40:27 +0900 Subject: [PATCH 1/3] Add "applyOverlayTexture" option --- src/three/plugins/API.md | 8 +++++++- src/three/plugins/images/GeneratedSurfacePlugin.js | 9 ++++++--- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/three/plugins/API.md b/src/three/plugins/API.md index efefe96cc..6e38a648c 100644 --- a/src/three/plugins/API.md +++ b/src/three/plugins/API.md @@ -1019,7 +1019,9 @@ both planar and ellipsoidal geometry via the `shape` option. ```js constructor( { - // Overlay instance to derive the tiling scheme from. + // Overlay instance to derive the tiling scheme from. When + // `applyOverlayTexture` is enabled, also used to texture the + // generated tile meshes. overlay = null: ImageOverlay, // Geometry shape: `'planar'` or `'ellipsoid'`. Only @@ -1034,6 +1036,10 @@ constructor( // Apply recommended TilesRenderer settings. useRecommendedSettings = true: boolean, + + // Whether to apply the overlay's texture to the generated tile + // meshes. + applyOverlayTexture = false: boolean, } ) ``` diff --git a/src/three/plugins/images/GeneratedSurfacePlugin.js b/src/three/plugins/images/GeneratedSurfacePlugin.js index ab41ef5cb..4d85e25f1 100644 --- a/src/three/plugins/images/GeneratedSurfacePlugin.js +++ b/src/three/plugins/images/GeneratedSurfacePlugin.js @@ -22,12 +22,13 @@ const _sphere = /* @__PURE__ */ new Sphere(); * both planar and ellipsoidal geometry via the `shape` option. * * @param {Object} [options] - * @param {ImageOverlay} [options.overlay=null] Overlay instance to derive the tiling scheme from and used to define surface imagery. + * @param {ImageOverlay} [options.overlay=null] Overlay instance to derive the tiling scheme from. When `applyOverlayTexture` is enabled, also used to texture the generated tile meshes. * @param {string} [options.shape='ellipsoid'] Geometry shape: `'planar'` or `'ellipsoid'`. Only * meaningful for cartographic sources. * @param {boolean} [options.endCaps=true] For Mercator ellipsoid mode, snap poles to ±90° lat. * @param {boolean} [options.center=true] Shift planar tiles so the image is centered at origin. * @param {boolean} [options.useRecommendedSettings=true] Apply recommended TilesRenderer settings. + * @param {boolean} [options.applyOverlayTexture=false] Whether to apply the overlay's texture to the generated tile meshes. */ export class GeneratedSurfacePlugin { @@ -39,6 +40,7 @@ export class GeneratedSurfacePlugin { endCaps = true, center = true, useRecommendedSettings = true, + applyOverlayTexture = false, } = options; this.priority = - 10; @@ -49,6 +51,7 @@ export class GeneratedSurfacePlugin { this.endCaps = endCaps; this.center = center; this.useRecommendedSettings = useRecommendedSettings; + this.applyOverlayTexture = applyOverlayTexture; this._tiling = null; @@ -93,7 +96,6 @@ export class GeneratedSurfacePlugin { } - const { overlay } = this; let res; if ( this._useEllipsoid() ) { @@ -105,7 +107,8 @@ export class GeneratedSurfacePlugin { } - if ( overlay ) { + const { overlay, applyOverlayTexture } = this; + if ( overlay && applyOverlayTexture ) { const x = tile[ TILE_X ]; const y = tile[ TILE_Y ]; From 57ddee52fcfe5e8f04b1859a2a9bba80f988e5f4 Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 21 May 2026 11:46:59 +0900 Subject: [PATCH 2/3] Dispose correctly --- .../plugins/images/GeneratedSurfacePlugin.js | 31 +++++++++++++------ 1 file changed, 22 insertions(+), 9 deletions(-) diff --git a/src/three/plugins/images/GeneratedSurfacePlugin.js b/src/three/plugins/images/GeneratedSurfacePlugin.js index 4d85e25f1..92c88bd5b 100644 --- a/src/three/plugins/images/GeneratedSurfacePlugin.js +++ b/src/three/plugins/images/GeneratedSurfacePlugin.js @@ -9,6 +9,9 @@ const MIN_LON_VERTS = 30; const MIN_LAT_VERTS = 15; const DEFAULT_LEVELS = 20; +const OVERLAY_RANGE = Symbol( 'OVERLAY_RANGE' ); +const OVERLAY_LEVEL = Symbol( 'OVERLAY_LEVEL' ); + const _pos = /* @__PURE__ */ new Vector3(); const _norm = /* @__PURE__ */ new Vector3(); const _sphere = /* @__PURE__ */ new Sphere(); @@ -120,14 +123,14 @@ export class GeneratedSurfacePlugin { await overlay.lockTexture( range, level ); const texture = overlay.getTexture( range, level ); - tile.overlayRange = range; - tile.overlayLevel = level; + tile[ OVERLAY_RANGE ] = range; + tile[ OVERLAY_LEVEL ] = level; if ( abortSignal.aborted ) { overlay.releaseTexture( range, level ); - tile.overlayRange = null; - tile.overlayLevel = null; + delete tile[ OVERLAY_RANGE ]; + delete tile[ OVERLAY_LEVEL ]; return null; } @@ -158,17 +161,27 @@ export class GeneratedSurfacePlugin { disposeTile( tile ) { - const { overlayRange, overlayLevel } = tile; - if ( this.overlay && overlayRange ) { + const range = tile[ OVERLAY_RANGE ]; + if ( this.overlay && range ) { - this.overlay.releaseTexture( overlayRange, overlayLevel ); - tile.overlayRange = null; - tile.overlayLevel = null; + this.overlay.releaseTexture( range, tile[ OVERLAY_LEVEL ] ); + delete tile[ OVERLAY_RANGE ]; + delete tile[ OVERLAY_LEVEL ]; } } + dispose() { + + this.tiles.forEachLoadedModel( ( scene, tile ) => { + + this.disposeTile( tile ); + + } ); + + } + /** * Returns the cartographic coordinates for a given world-space position. "lat" and "lon" are assigned * to the target object. From fe1747bc77af9c7d702ca89e2ef556c6b2f218ef Mon Sep 17 00:00:00 2001 From: Garrett Johnson Date: Thu, 21 May 2026 11:47:14 +0900 Subject: [PATCH 3/3] Adjust examples --- example/three/deepZoom.js | 1 + example/three/geojson.js | 1 + example/three/mapTiles.js | 1 + example/three/wmsTiles.js | 1 + example/three/wmtsTiles.js | 1 + 5 files changed, 5 insertions(+) diff --git a/example/three/deepZoom.js b/example/three/deepZoom.js index 8e028826a..7eba951b5 100644 --- a/example/three/deepZoom.js +++ b/example/three/deepZoom.js @@ -56,6 +56,7 @@ function init() { overlay: new DeepZoomOverlay( { url: 'https://openseadragon.github.io/example-images/duomo/duomo.dzi', } ), + applyOverlayTexture: true, } ) ); tiles.registerPlugin( new UpdateOnChangePlugin() ); tiles.fetchOptions.mode = 'cors'; diff --git a/example/three/geojson.js b/example/three/geojson.js index 164168963..fe50bf7fc 100644 --- a/example/three/geojson.js +++ b/example/three/geojson.js @@ -106,6 +106,7 @@ function init() { } ), center: true, shape: 'ellipsoid', + applyOverlayTexture: true, } ), ); diff --git a/example/three/mapTiles.js b/example/three/mapTiles.js index 1b0c996a5..89fdcd250 100644 --- a/example/three/mapTiles.js +++ b/example/three/mapTiles.js @@ -96,6 +96,7 @@ function initTiles() { surfacePlugin = new GeneratedSurfacePlugin( { overlay, shape: params.planar ? 'planar' : 'ellipsoid', + applyOverlayTexture: true, } ); tiles.registerPlugin( surfacePlugin ); diff --git a/example/three/wmsTiles.js b/example/three/wmsTiles.js index 3f41673ae..0e6530aa6 100644 --- a/example/three/wmsTiles.js +++ b/example/three/wmsTiles.js @@ -122,6 +122,7 @@ function rebuildTiles() { version: capabilities.version, } ), shape: 'ellipsoid', + applyOverlayTexture: true, } ) ); tiles.group.rotation.x = - Math.PI / 2; diff --git a/example/three/wmtsTiles.js b/example/three/wmtsTiles.js index 180c8b7d5..49daccf91 100644 --- a/example/three/wmtsTiles.js +++ b/example/three/wmtsTiles.js @@ -182,6 +182,7 @@ function rebuildTiles() { } ), shape: params.planar ? 'planar' : 'ellipsoid', center: true, + applyOverlayTexture: true, } ) ); tiles.setCamera( camera );