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
1 change: 1 addition & 0 deletions example/three/deepZoom.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions example/three/geojson.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions example/three/mapTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ function initTiles() {
surfacePlugin = new GeneratedSurfacePlugin( {
overlay,
shape: params.planar ? 'planar' : 'ellipsoid',
applyOverlayTexture: true,
} );
tiles.registerPlugin( surfacePlugin );

Expand Down
1 change: 1 addition & 0 deletions example/three/wmsTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ function rebuildTiles() {
version: capabilities.version,
} ),
shape: 'ellipsoid',
applyOverlayTexture: true,
} ) );

tiles.group.rotation.x = - Math.PI / 2;
Expand Down
1 change: 1 addition & 0 deletions example/three/wmtsTiles.js
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,7 @@ function rebuildTiles() {
} ),
shape: params.planar ? 'planar' : 'ellipsoid',
center: true,
applyOverlayTexture: true,
} ) );

tiles.setCamera( camera );
Expand Down
8 changes: 7 additions & 1 deletion src/three/plugins/API.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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,
}
)
```
Expand Down
40 changes: 28 additions & 12 deletions src/three/plugins/images/GeneratedSurfacePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -22,12 +25,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 {

Expand All @@ -39,6 +43,7 @@ export class GeneratedSurfacePlugin {
endCaps = true,
center = true,
useRecommendedSettings = true,
applyOverlayTexture = false,
} = options;

this.priority = - 10;
Expand All @@ -49,6 +54,7 @@ export class GeneratedSurfacePlugin {
this.endCaps = endCaps;
this.center = center;
this.useRecommendedSettings = useRecommendedSettings;
this.applyOverlayTexture = applyOverlayTexture;

this._tiling = null;

Expand Down Expand Up @@ -93,7 +99,6 @@ export class GeneratedSurfacePlugin {

}

const { overlay } = this;
let res;
if ( this._useEllipsoid() ) {

Expand All @@ -105,7 +110,8 @@ export class GeneratedSurfacePlugin {

}

if ( overlay ) {
const { overlay, applyOverlayTexture } = this;
if ( overlay && applyOverlayTexture ) {

const x = tile[ TILE_X ];
const y = tile[ TILE_Y ];
Expand All @@ -117,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;

}
Expand Down Expand Up @@ -155,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.
Expand Down
Loading