Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/core/plugins/GoogleCloudAuthPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export class GoogleCloudAuthPlugin {

this._visibilityChangeCallback = ( { tile, visible } ) => {

const copyright = tile.cached.metadata?.asset?.copyright || '';
const copyright = tile.engineData.metadata?.asset?.copyright || '';
if ( visible ) {

this._attributionsManager.addAttributions( copyright );
Expand Down
24 changes: 21 additions & 3 deletions src/core/renderer/tiles/TilesRendererBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -649,6 +649,24 @@ export class TilesRendererBase {

tile.__lastFrameVisited = - 1;

// Initialize engineData data structure with engine-agnostic fields
tile.engineData = {
scene: null,
metadata: null,
boundingVolume: null,
};

// Backwards compatibility: cached is an alias for engineData
Object.defineProperty( tile, 'cached', {
get() {

return this.engineData;

},
enumerable: false,
configurable: true,
} );

this.invokeAllPlugins( plugin => {

plugin !== this && plugin.preprocessNode && plugin.preprocessNode( tile, tilesetDir, parentTile );
Expand Down Expand Up @@ -775,7 +793,7 @@ export class TilesRendererBase {

if ( plugin.calculateBytesUsed ) {

bytes += plugin.calculateBytesUsed( tile, tile.cached.scene ) || 0;
bytes += plugin.calculateBytesUsed( tile, tile.engineData.scene ) || 0;

}

Expand Down Expand Up @@ -1121,11 +1139,11 @@ export class TilesRendererBase {

}

if ( tile.cached.scene ) {
if ( tile.engineData.scene ) {

this.dispatchEvent( {
type: 'load-model',
scene: tile.cached.scene,
scene: tile.engineData.scene,
tile,
url: uri,
} );
Expand Down
14 changes: 7 additions & 7 deletions src/three/plugins/DebugTilesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -282,9 +282,9 @@ export class DebugTilesPlugin {
// initialize an already-loaded tiles
tiles.traverse( tile => {

if ( tile.cached.scene ) {
if ( tile.engineData.scene ) {

this._onLoadModel( tile.cached.scene, tile );
this._onLoadModel( tile.engineData.scene, tile );

}

Expand Down Expand Up @@ -312,7 +312,7 @@ export class DebugTilesPlugin {

}

const scene = tile.cached.scene;
const scene = tile.engineData.scene;
if ( scene ) {

scene.traverse( c => {
Expand Down Expand Up @@ -451,7 +451,7 @@ export class DebugTilesPlugin {
// update plugins
visibleTiles.forEach( tile => {

const scene = tile.cached.scene;
const scene = tile.engineData.scene;

// create a random color per-tile
let h, s, l;
Expand Down Expand Up @@ -656,7 +656,7 @@ export class DebugTilesPlugin {
_createBoundHelper( tile ) {

const tiles = this.tiles;
const cached = tile.cached;
const cached = tile.engineData;
const { sphere, obb, region } = cached.boundingVolume;
if ( obb ) {

Expand Down Expand Up @@ -750,7 +750,7 @@ export class DebugTilesPlugin {

_updateBoundHelper( tile, visible ) {

const cached = tile.cached;
const cached = tile.engineData;

if ( ! cached ) {

Expand Down Expand Up @@ -910,7 +910,7 @@ export class DebugTilesPlugin {

_onDisposeModel( tile ) {

const cached = tile.cached;
const cached = tile.engineData;
if ( cached.boxHelperGroup ) {

cached.boxHelperGroup.children[ 0 ].geometry.dispose();
Expand Down
2 changes: 1 addition & 1 deletion src/three/plugins/LoadRegionPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export class LoadRegionPlugin {
// tiles are only loaded if they are within those shapes.
calculateTileViewError( tile, target ) {

const boundingVolume = tile.cached.boundingVolume;
const boundingVolume = tile.engineData.boundingVolume;
const { regions, tiles } = this;

let inShape = false;
Expand Down
4 changes: 2 additions & 2 deletions src/three/plugins/QuantizedMeshPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ export class QuantizedMeshPlugin {
clipper.minLon = west;
clipper.maxLon = east;

result = clipper.clipToQuadrant( tile.parent.cached.scene, left, bottom );
result = clipper.clipToQuadrant( tile.parent.engineData.scene, left, bottom );

} else if ( extension === 'terrain' ) {

Expand Down Expand Up @@ -284,7 +284,7 @@ export class QuantizedMeshPlugin {
const { minHeight, maxHeight, metadata } = result.userData;
tile.boundingVolume.region[ 4 ] = minHeight;
tile.boundingVolume.region[ 5 ] = maxHeight;
tile.cached.boundingVolume.setRegionData( ellipsoid, ...tile.boundingVolume.region );
tile.engineData.boundingVolume.setRegionData( ellipsoid, ...tile.boundingVolume.region );

// use the geometric error value if it's present
if ( metadata ) {
Expand Down
2 changes: 1 addition & 1 deletion src/three/plugins/TileFlatteningPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export class TileFlatteningPlugin {
const { positionsUpdated, positionsMap, shapes, tiles } = this;
positionsUpdated.add( tile );

const scene = tile.cached.scene;
const scene = tile.engineData.scene;
if ( ! positionsMap.has( tile ) ) {

// save the geometry positions for resetting after
Expand Down
2 changes: 1 addition & 1 deletion src/three/plugins/UnloadTilesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export class UnloadTilesPlugin {

const unloadCallback = tile => {

const scene = tile.cached.scene;
const scene = tile.engineData.scene;
const visible = tiles.visibleTiles.has( tile );

if ( ! visible ) {
Expand Down
12 changes: 6 additions & 6 deletions src/three/plugins/batched/BatchedTilesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ export class BatchedTilesPlugin {

setTileVisible( tile, visible ) {

const scene = tile.cached.scene;
const scene = tile.engineData.scene;
if ( visible ) {

// Add tileset to the batched mesh if it hasn't been added already
Expand Down Expand Up @@ -374,7 +374,7 @@ export class BatchedTilesPlugin {
// TODO: this would be best done in a more general way
if ( this.discardOriginalContent ) {

tile.cached.textures.forEach( tex => {
tile.engineData.textures.forEach( tex => {

if ( tex.image instanceof ImageBitmap ) {

Expand All @@ -384,10 +384,10 @@ export class BatchedTilesPlugin {

} );

tile.cached.scene = null;
tile.cached.materials = [];
tile.cached.geometries = [];
tile.cached.textures = [];
tile.engineData.scene = null;
tile.engineData.materials = [];
tile.engineData.geometries = [];
tile.engineData.textures = [];

}

Expand Down
8 changes: 4 additions & 4 deletions src/three/plugins/fade/TilesFadePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ function onUpdateAfter() {

// if a tile is fading out then it may not be traversed and thus will not have
// the frustum flag set correctly.
const scene = t.cached.scene;
const scene = t.engineData.scene;
if ( scene ) {

scene.visible = t.__inFrustum;
Expand Down Expand Up @@ -124,7 +124,7 @@ function onUpdateAfter() {
fadeManager.forEachObject( ( tile, { fadeIn, fadeOut } ) => {

// prevent faded tiles from being unloaded
const scene = tile.cached.scene;
const scene = tile.engineData.scene;
const isFadingOut = fadeManager.isFadingOut( tile );
tiles.markTileUsed( tile );
if ( scene ) {
Expand Down Expand Up @@ -252,7 +252,7 @@ export class TilesFadePlugin {
// this function gets fired _after_ all set visible callbacks including the batched meshes

// revert the scene and fade to the initial state when toggling
const scene = tile.cached.scene;
const scene = tile.engineData.scene;
if ( scene ) {

scene.visible = true;
Expand Down Expand Up @@ -308,7 +308,7 @@ export class TilesFadePlugin {
fadeManager.onFadeComplete = ( tile, visible ) => {

// mark the fade as finished and reset the fade parameters
this._fadeMaterialManager.setFade( tile.cached.scene, 0, 0 );
this._fadeMaterialManager.setFade( tile.engineData.scene, 0, 0 );

this.forEachBatchIds( tile, ( id, batchedMesh, plugin ) => {

Expand Down
2 changes: 1 addition & 1 deletion src/three/plugins/images/EllipsoidProjectionTilesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class EllipsoidProjectionTilesPlugin extends ImageFormatPlugin {
// adjust the geometry to position it at the region
const { position, normal, uv } = geometry.attributes;
const vertCount = position.count;
tile.cached.boundingVolume.getSphere( _sphere );
tile.engineData.boundingVolume.getSphere( _sphere );
for ( let i = 0; i < vertCount; i ++ ) {

// retrieve attributes
Expand Down
4 changes: 2 additions & 2 deletions src/three/plugins/images/ImageOverlayPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ export class ImageOverlayPlugin {

}

const clone = parent.cached.scene.clone();
const clone = parent.engineData.scene.clone();
clone.updateMatrixWorld();

if ( fullDispose || parent[ SPLIT_HASH ] !== this._getSplitVectors( clone, parent ).hash ) {
Expand Down Expand Up @@ -613,7 +613,7 @@ export class ImageOverlayPlugin {

// remove the parent transform because it will be multiplied back in after the fact
result.matrix
.premultiply( tile.cached.transformInverse )
.premultiply( tile.engineData.transformInverse )
.decompose( result.position, result.quaternion, result.scale );

// collect the meshes
Expand Down
Loading
Loading