@@ -165,11 +165,11 @@ define([
165
165
var baseUrl = tileset . url ;
166
166
var rootTile = new Cesium3DTile ( tileset , baseUrl , tree . root , parentTile ) ;
167
167
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
170
171
if ( defined ( parentTile ) ) {
171
172
parentTile . children . push ( rootTile ) ;
172
- // TODO: Is this right?
173
173
parentTile . numberOfChildrenWithoutContent += 1 ;
174
174
}
175
175
@@ -337,20 +337,30 @@ define([
337
337
// 2) If its children are already loaded, select its (root) child since the geometric error of it is
338
338
// same as this tile's
339
339
var contentUrl = tile . _header . content . url ;
340
+ var root ;
340
341
341
342
// 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 ( ) ) &&
344
345
( 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
+ }
347
357
return ;
348
358
} else if ( replace ) {
349
359
// 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
+ }
354
364
}
355
365
356
366
// Request the tile's tileset if it's unloaded.
@@ -395,7 +405,9 @@ define([
395
405
}
396
406
397
407
if ( root . isContentUnloaded ( ) ) {
398
- if ( outOfCore ) {
408
+ if ( root . hasTilesetContent ) {
409
+ selectTileWithTilesetContent ( tiles3D , selectedTiles , root , fullyVisible , frameState , true ) ;
410
+ } else if ( outOfCore ) {
399
411
requestContent ( tiles3D , root ) ;
400
412
}
401
413
return ;
@@ -485,6 +497,13 @@ define([
485
497
// is not sufficient, its children (or ancestors) are
486
498
// rendered instead
487
499
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)
488
507
if ( ( sse <= maximumScreenSpaceError ) || ( childrenLength === 0 ) ) {
489
508
// This tile meets the SSE so add its commands.
490
509
//
0 commit comments