@@ -300,7 +300,12 @@ define([
300
300
} ;
301
301
302
302
BaseTraversal . prototype . getChildren = function ( tile ) {
303
- if ( hasVisibleChildren ( this , tile , this . baseScreenSpaceError ) ) {
303
+ if ( this . updateAndCheckChildren ( tile ) ) {
304
+ if ( ! childrenAreVisible ( tile ) ) {
305
+ ++ this . tileset . _statistics . numberOfTilesCulledWithChildrenUnion ;
306
+ return emptyArray ;
307
+ }
308
+
304
309
var children = tile . children ;
305
310
var childrenLength = children . length ;
306
311
var allReady = true ;
@@ -326,13 +331,13 @@ define([
326
331
return emptyArray ;
327
332
} ;
328
333
329
- function hasVisibleChildren ( traversal , tile , screenSpaceError ) {
330
- var tileset = traversal . tileset ;
334
+ BaseTraversal . prototype . updateAndCheckChildren = function ( tile ) {
335
+ var tileset = this . tileset ;
331
336
332
337
if ( tile . hasTilesetContent ) {
333
338
// load any tilesets of tilesets now because at this point we still have not achieved a base level of content
334
339
if ( ! defined ( tile . _ancestorWithContent ) ) {
335
- loadTile ( tile , traversal . frameState ) ;
340
+ loadTile ( tile , this . frameState ) ;
336
341
}
337
342
}
338
343
@@ -341,11 +346,11 @@ define([
341
346
}
342
347
343
348
// stop traversal when we've attained the desired level of error
344
- if ( tile . _screenSpaceError <= screenSpaceError && tile . hasRenderableContent ) {
349
+ if ( tile . _screenSpaceError <= this . baseScreenSpaceError && tile . hasRenderableContent ) {
345
350
return false ;
346
351
}
347
352
348
- var childrenVisibility = updateChildren ( tileset , tile , traversal . frameState ) ;
353
+ var childrenVisibility = updateChildren ( tileset , tile , this . frameState ) ;
349
354
var showAdditive = tile . refine === Cesium3DTileRefine . ADD ;
350
355
var showReplacement = tile . refine === Cesium3DTileRefine . REPLACE && ( childrenVisibility & Cesium3DTileChildrenVisibility . VISIBLE_IN_REQUEST_VOLUME ) !== 0 ;
351
356
@@ -386,11 +391,16 @@ define([
386
391
387
392
// Continue traversing until we have renderable content. We want the first descendants with content of the root to load
388
393
InternalBaseTraversal . prototype . shouldVisit = function ( tile ) {
389
- return ! tile . hasRenderableContent && isVisible ( tile . visibilityPlaneMask ) ;
394
+ return ! tile . hasRenderableContent && isVisible ( tile . visibilityPlaneMask ) ;
390
395
} ;
391
396
392
397
InternalBaseTraversal . prototype . getChildren = function ( tile ) {
393
- if ( hasVisibleChildren ( this , tile , this . baseScreenSpaceError ) ) {
398
+ if ( this . updateAndCheckChildren ( tile , this . baseScreenSpaceError ) ) {
399
+ if ( ! childrenAreVisible ( tile ) ) {
400
+ ++ this . tileset . _statistics . numberOfTilesCulledWithChildrenUnion ;
401
+ return emptyArray ;
402
+ }
403
+
394
404
var children = tile . children ;
395
405
var childrenLength = children . length ;
396
406
for ( var i = 0 ; i < childrenLength ; ++ i ) {
@@ -403,6 +413,8 @@ define([
403
413
return emptyArray ;
404
414
} ;
405
415
416
+ InternalBaseTraversal . prototype . updateAndCheckChildren = BaseTraversal . prototype . updateAndCheckChildren ;
417
+
406
418
function SkipTraversal ( options ) {
407
419
this . tileset = undefined ;
408
420
this . frameState = undefined ;
@@ -497,6 +509,11 @@ define([
497
509
}
498
510
499
511
if ( showAdditive || showReplacement || tile . hasTilesetContent ) {
512
+ if ( ! childrenAreVisible ( tile ) ) {
513
+ ++ this . tileset . _statistics . numberOfTilesCulledWithChildrenUnion ;
514
+ return emptyArray ;
515
+ }
516
+
500
517
var children = tile . children ;
501
518
var childrenLength = children . length ;
502
519
for ( var i = 0 ; i < childrenLength ; ++ i ) {
@@ -546,7 +563,7 @@ define([
546
563
updateTransforms ( children , tile . computedTransform ) ;
547
564
computeDistanceToCamera ( children , frameState ) ;
548
565
549
- return computeChildrenVisibility ( tile , frameState , true ) ;
566
+ return computeChildrenVisibility ( tile , frameState ) ;
550
567
}
551
568
552
569
function visitTile ( tileset , tile , frameState , outOfCore ) {
@@ -595,7 +612,7 @@ define([
595
612
}
596
613
}
597
614
598
- function computeChildrenVisibility ( tile , frameState , checkViewerRequestVolume ) {
615
+ function computeChildrenVisibility ( tile , frameState ) {
599
616
var flag = Cesium3DTileChildrenVisibility . NONE ;
600
617
var children = tile . children ;
601
618
var childrenLength = children . length ;
@@ -609,17 +626,15 @@ define([
609
626
flag |= Cesium3DTileChildrenVisibility . VISIBLE ;
610
627
}
611
628
612
- if ( checkViewerRequestVolume ) {
613
- if ( ! child . insideViewerRequestVolume ( frameState ) ) {
614
- if ( isVisible ( visibilityMask ) ) {
615
- flag |= Cesium3DTileChildrenVisibility . VISIBLE_NOT_IN_REQUEST_VOLUME ;
616
- }
617
- visibilityMask = CullingVolume . MASK_OUTSIDE ;
618
- } else {
619
- flag |= Cesium3DTileChildrenVisibility . IN_REQUEST_VOLUME ;
620
- if ( isVisible ( visibilityMask ) ) {
621
- flag |= Cesium3DTileChildrenVisibility . VISIBLE_IN_REQUEST_VOLUME ;
622
- }
629
+ if ( ! child . insideViewerRequestVolume ( frameState ) ) {
630
+ if ( isVisible ( visibilityMask ) ) {
631
+ flag |= Cesium3DTileChildrenVisibility . VISIBLE_NOT_IN_REQUEST_VOLUME ;
632
+ }
633
+ visibilityMask = CullingVolume . MASK_OUTSIDE ;
634
+ } else {
635
+ flag |= Cesium3DTileChildrenVisibility . IN_REQUEST_VOLUME ;
636
+ if ( isVisible ( visibilityMask ) ) {
637
+ flag |= Cesium3DTileChildrenVisibility . VISIBLE_IN_REQUEST_VOLUME ;
623
638
}
624
639
}
625
640
@@ -688,6 +703,11 @@ define([
688
703
return visibilityPlaneMask !== CullingVolume . MASK_OUTSIDE ;
689
704
}
690
705
706
+ function childrenAreVisible ( tile ) {
707
+ // optimization does not apply for additive refinement
708
+ return tile . refine === Cesium3DTileRefine . ADD || tile . children . length === 0 || tile . childrenVisibility & Cesium3DTileChildrenVisibility . VISIBLE !== 0 ;
709
+ }
710
+
691
711
function DFS ( root , options ) {
692
712
var stack = options . stack ;
693
713
0 commit comments