Skip to content

Commit 6069ecf

Browse files
authored
TilesRenderer: Move "traversal" fields into a dedicated subobject (#1431)
* Change to use a "traversal" sub object * Clean up * Create an "internal" subfield * Fix tests * Fix priority sort * Remove types * Convert fields * Small fixes * Fixes * More updates
1 parent affdcfe commit 6069ecf

16 files changed

Lines changed: 334 additions & 319 deletions

example/three/cesiumCompare.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ function render() {
135135
shallowTilesLoaded = 0;
136136
traverse( threeViewer.root, t => {
137137

138-
if ( t.__hasRenderableContent && t.__loadingState !== 0 ) {
138+
if ( t.internal && t.internal.hasRenderableContent && t.internal.loadingState !== 0 ) {
139139

140140
shallowTilesLoaded ++;
141141
return true;
@@ -147,7 +147,7 @@ function render() {
147147
allLoadedTiles = 0;
148148
traverse( threeViewer.root, ( t, d ) => {
149149

150-
if ( t.__hasContent && t.__loadingState !== 0 ) {
150+
if ( t.internal && t.internal.hasContent && t.internal.loadingState !== 0 ) {
151151

152152
allLoadedTiles ++;
153153

example/three/index.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ function reinstantiateTiles() {
9797
ktx2loader.detectSupport( renderer );
9898

9999
tiles = new TilesRenderer( url );
100-
tiles.registerPlugin( new DebugTilesPlugin() );
101100
tiles.registerPlugin( new ImplicitTilingPlugin() );
102101
tiles.registerPlugin( new GLTFExtensionsPlugin( {
103102
rtc: true,
@@ -109,9 +108,11 @@ function reinstantiateTiles() {
109108
geospatialRotationParent.add( tiles.group );
110109

111110
// Used with CUSTOM_COLOR
112-
tiles.customColorCallback = ( tile, object ) => {
111+
const debugPlugin = new DebugTilesPlugin();
112+
tiles.registerPlugin( debugPlugin );
113+
debugPlugin.customColorCallback = ( tile, object ) => {
113114

114-
const depthIsEven = tile.__depth % 2 === 0;
115+
const depthIsEven = tile.internal.depth % 2 === 0;
115116
const hex = depthIsEven ? 0xff0000 : 0xffffff;
116117
object.traverse( c => {
117118

example/three/src/plugins/overlays/TextureOverlayPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ export class TextureOverlayPlugin {
283283
// public functions
284284
getTileKey( tile ) {
285285

286-
return new URL( tile.content.uri, tile.__basePath + '/' ).toString();
286+
return new URL( tile.content.uri, tile.internal.basePath + '/' ).toString();
287287

288288
}
289289

src/core/plugins/ImplicitTilingPlugin.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ export class ImplicitTilingPlugin {
1818

1919
if ( tile.implicitTiling ) {
2020

21-
tile.__hasUnrenderableContent = true;
22-
tile.__hasRenderableContent = false;
21+
tile.internal.hasUnrenderableContent = true;
22+
tile.internal.hasRenderableContent = false;
2323

2424
// Declare some properties
2525
tile.__subtreeIdx = 0; // Idx of the tile in its subtree
@@ -34,8 +34,8 @@ export class ImplicitTilingPlugin {
3434
} else if ( /.subtree$/i.test( tile.content?.uri ) ) {
3535

3636
// Handling content uri pointing to a subtree file
37-
tile.__hasUnrenderableContent = true;
38-
tile.__hasRenderableContent = false;
37+
tile.internal.hasUnrenderableContent = true;
38+
tile.internal.hasRenderableContent = false;
3939

4040
}
4141

@@ -46,7 +46,7 @@ export class ImplicitTilingPlugin {
4646
if ( /^subtree$/i.test( extension ) ) {
4747

4848
const loader = new SUBTREELoader( tile );
49-
loader.workingPath = tile.__basePath;
49+
loader.workingPath = tile.internal.basePath;
5050
loader.fetchOptions = this.tiles.fetchOptions;
5151
return loader.parse( buffer );
5252

@@ -64,7 +64,7 @@ export class ImplicitTilingPlugin {
6464
.replace( '{y}', tile.__y )
6565
.replace( '{z}', tile.__z );
6666

67-
return new URL( implicitUri, tile.__basePath + '/' ).toString();
67+
return new URL( implicitUri, tile.internal.basePath + '/' ).toString();
6868

6969
}
7070

@@ -84,7 +84,7 @@ export class ImplicitTilingPlugin {
8484

8585
} );
8686
tile.children.length = 0;
87-
tile.__childrenProcessed = 0;
87+
tile.internal.childrenProcessed = 0;
8888

8989
}
9090

src/core/renderer/tiles/Tile.d.ts

Lines changed: 44 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,68 @@
11
import { TileBase } from './TileBase.js';
22

33
/**
4-
* Documented 3d-tile state managed by the TilesRenderer* / used/usable in priority / traverseFunctions!
4+
* Internal implementation details for tile management
55
*/
6-
export interface Tile extends TileBase {
7-
8-
parent: Tile;
6+
export interface TileInternalData {
7+
hasContent: boolean;
8+
hasRenderableContent: boolean;
9+
hasUnrenderableContent: boolean;
10+
loadingState: number;
11+
basePath: string;
12+
childrenProcessed: number;
13+
depth: number;
14+
depthFromRenderedParent: number;
15+
}
916

17+
/**
18+
* Traversal state data updated during each frame's tile traversal
19+
*/
20+
export interface TileTraversalData {
1021
/**
11-
* Hierarchy Depth from the TileGroup
22+
* How far this tile's bounds are from the nearest active camera.
23+
* Expected to be filled in during calculateError implementations.
1224
*/
13-
__depth : number;
25+
distanceFromCamera: number;
1426
/**
1527
* The screen space error for this tile
1628
*/
17-
__error : number;
29+
error: number;
1830
/**
19-
* How far is this tiles bounds from the nearest active Camera.
20-
* Expected to be filled in during calculateError implementations.
31+
* Whether or not the tile was within the frustum on the last update run
32+
*/
33+
inFrustum: boolean;
34+
/**
35+
* Whether this tile is a leaf node in the used tree
2136
*/
22-
__distanceFromCamera : number;
37+
isLeaf: boolean;
2338
/**
24-
* This tile is currently active if:
25-
* 1: Tile content is loaded and ready to be made visible if needed
39+
* Whether or not the tile was visited during the last update run
2640
*/
27-
__active : boolean;
41+
used: boolean;
42+
/**
43+
* Whether or not the tile was used in the previous frame
44+
*/
45+
usedLastFrame: boolean;
2846
/**
2947
* This tile is currently visible if:
3048
* 1: Tile content is loaded
3149
* 2: Tile is within a camera frustum
3250
* 3: Tile meets the SSE requirements
3351
*/
34-
__visible : boolean;
35-
/**
36-
* Whether or not the tile was visited during the last update run.
37-
*/
38-
__used : boolean;
52+
visible: boolean;
53+
}
3954

40-
/**
41-
* Whether or not the tile was within the frustum on the last update run.
42-
*/
43-
__inFrustum : boolean;
55+
/**
56+
* Documented 3d-tile state managed by the TilesRenderer* / used/usable in priority / traverseFunctions!
57+
*/
58+
export interface Tile extends TileBase {
4459

45-
/**
46-
* The depth of the tiles that increments only when a child with geometry content is encountered
47-
*/
48-
__depthFromRenderedParent : number;
60+
parent: Tile;
61+
62+
// Internal implementation details for tile management
63+
internal: TileInternalData;
64+
65+
// Traversal state data updated during each frame's tile traversal
66+
traversal: TileTraversalData;
4967

5068
}

src/core/renderer/tiles/TileInternal.d.ts

Lines changed: 0 additions & 35 deletions
This file was deleted.

0 commit comments

Comments
 (0)