Skip to content

Commit 345ed2d

Browse files
committed
relaxed limitations on subtrees specified by tiles.json files. Roots can now themselves be tiles.json pointers.
1 parent e5eb7a0 commit 345ed2d

File tree

1 file changed

+31
-12
lines changed

1 file changed

+31
-12
lines changed

Source/Scene/Cesium3DTileset.js

+31-12
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,11 @@ define([
165165
var baseUrl = tileset.url;
166166
var rootTile = new Cesium3DTile(tileset, baseUrl, tree.root, parentTile);
167167

168-
// Parent is a tileset, it had no children at time of inception, but after
169-
// loading its content, the root tile of the subtree will be its child
168+
// If there is a parentTile, add the root of the currently loading
169+
// tileset to parentTile's children, and increment its numberOfChildrenWithoutContent
170+
// with 1
170171
if (defined(parentTile)) {
171172
parentTile.children.push(rootTile);
172-
// TODO: Is this right?
173173
parentTile.numberOfChildrenWithoutContent += 1;
174174
}
175175

@@ -337,20 +337,30 @@ define([
337337
// 2) If its children are already loaded, select its (root) child since the geometric error of it is
338338
// same as this tile's
339339
var contentUrl = tile._header.content.url;
340+
var root;
340341

341342
// If the subtree has already been added and child
342-
// content requested, select the child and continue
343-
if ((tile.content.state === Cesium3DTileContentState.Ready) &&
343+
// content requested, select the child (= the root) and continue
344+
if ((tile.isReady()) &&
344345
(tile.numberOfChildrenWithoutContent === 0)) {
345-
// TODO: select which tiles? All children tiles?
346-
selectTile(selectedTiles, tile.children[0], fullyVisible, frameState);
346+
// A tiles.json must specify at least one tile, ie a root
347+
root = tile.children[0];
348+
if (root.hasTilesetContent) {
349+
selectTileWithTilesetContent(tiles3D, selectedTiles, root, fullyVisible, frameState, replace);
350+
} else {
351+
if (root.isContentUnloaded()) {
352+
requestContent(tiles3D, root);
353+
} else if (root.isReady()){
354+
selectTile(selectedTiles, root, fullyVisible, frameState);
355+
}
356+
}
347357
return;
348358
} else if (replace) {
349359
// Otherwise, select the parent tile, to avoid showing an empty space
350-
// Note that tile.parent must always be defined here --
351-
// tile should never be the root of the tileset AND
352-
// contain another tileset
353-
selectTile(selectedTiles, tile.parent, fullyVisible, frameState);
360+
// while waiting for tile to load
361+
if (defined(tile.parent)) {
362+
selectTile(selectedTiles, tile.parent, fullyVisible, frameState);
363+
}
354364
}
355365

356366
// Request the tile's tileset if it's unloaded.
@@ -395,7 +405,9 @@ define([
395405
}
396406

397407
if (root.isContentUnloaded()) {
398-
if (outOfCore) {
408+
if (root.hasTilesetContent) {
409+
selectTileWithTilesetContent(tiles3D, selectedTiles, root, fullyVisible, frameState, true);
410+
} else if (outOfCore) {
399411
requestContent(tiles3D, root);
400412
}
401413
return;
@@ -485,6 +497,13 @@ define([
485497
// is not sufficient, its children (or ancestors) are
486498
// rendered instead
487499

500+
// TODO: Can we change childrenLength check here to
501+
// checking hasTilesetContent?
502+
// Also, it seems the t.hasTilesetContent checks further down
503+
// will never be reached because in all cases (?) where
504+
// the tile has tilesetContent the first condition should be true
505+
// (Needs to be adjusted, since such a tile actually can have
506+
// children)
488507
if ((sse <= maximumScreenSpaceError) || (childrenLength === 0)) {
489508
// This tile meets the SSE so add its commands.
490509
//

0 commit comments

Comments
 (0)