Skip to content

Commit 97ad7b1

Browse files
authored
Move update-before, update-after to superclass (#1457)
1 parent 382c864 commit 97ad7b1

2 files changed

Lines changed: 48 additions & 36 deletions

File tree

src/core/renderer/tiles/TilesRendererBase.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,7 @@ export class TilesRendererBase {
418418

419419
update() {
420420

421+
// load root
421422
const { lruCache, usedSet, stats, root, downloadQueue, parseQueue, processNodeQueue, optimizedLoadStrategy } = this;
422423
if ( this.rootLoadingState === UNLOADED ) {
423424

@@ -471,6 +472,40 @@ export class TilesRendererBase {
471472

472473
}
473474

475+
// check if the plugins that can block the tile updates require it
476+
let needsUpdate = null;
477+
this.invokeAllPlugins( plugin => {
478+
479+
if ( plugin.doTilesNeedUpdate ) {
480+
481+
const res = plugin.doTilesNeedUpdate();
482+
if ( needsUpdate === null ) {
483+
484+
needsUpdate = res;
485+
486+
} else {
487+
488+
needsUpdate = Boolean( needsUpdate || res );
489+
490+
}
491+
492+
}
493+
494+
} );
495+
496+
if ( needsUpdate === false ) {
497+
498+
this.dispatchEvent( { type: 'update-before' } );
499+
this.dispatchEvent( { type: 'update-after' } );
500+
return;
501+
502+
}
503+
504+
// follow through with the update
505+
this.dispatchEvent( { type: 'update-before' } );
506+
507+
//
508+
474509
stats.inFrustum = 0;
475510
stats.used = 0;
476511
stats.active = 0;
@@ -485,6 +520,9 @@ export class TilesRendererBase {
485520
downloadQueue.priorityCallback = priorityCallback;
486521
parseQueue.priorityCallback = priorityCallback;
487522

523+
// prepare for traversal
524+
this.prepareForTraversal();
525+
488526
// run traversal
489527
if ( optimizedLoadStrategy ) {
490528

@@ -527,6 +565,8 @@ export class TilesRendererBase {
527565

528566
}
529567

568+
this.dispatchEvent( { type: 'update-after' } );
569+
530570
}
531571

532572
resetFailedTiles() {
@@ -621,6 +661,8 @@ export class TilesRendererBase {
621661

622662
}
623663

664+
prepareForTraversal() {}
665+
624666
disposeTile( tile ) {
625667

626668
// TODO: are these necessary? Are we disposing tiles when they are currently visible?

src/three/renderer/tiles/TilesRenderer.js

Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -391,39 +391,7 @@ export class TilesRenderer extends TilesRendererBase {
391391

392392
}
393393

394-
update() {
395-
396-
// check if the plugins that can block the tile updates require it
397-
let needsUpdate = null;
398-
this.invokeAllPlugins( plugin => {
399-
400-
if ( plugin.doTilesNeedUpdate ) {
401-
402-
const res = plugin.doTilesNeedUpdate();
403-
if ( needsUpdate === null ) {
404-
405-
needsUpdate = res;
406-
407-
} else {
408-
409-
needsUpdate = Boolean( needsUpdate || res );
410-
411-
}
412-
413-
}
414-
415-
} );
416-
417-
if ( needsUpdate === false ) {
418-
419-
this.dispatchEvent( { type: 'update-before' } );
420-
this.dispatchEvent( { type: 'update-after' } );
421-
return;
422-
423-
}
424-
425-
// follow through with the update
426-
this.dispatchEvent( { type: 'update-before' } );
394+
prepareForTraversal() {
427395

428396
const group = this.group;
429397
const cameras = this.cameras;
@@ -511,12 +479,14 @@ export class TilesRenderer extends TilesRendererBase {
511479

512480
}
513481

514-
super.update();
482+
}
515483

516-
this.dispatchEvent( { type: 'update-after' } );
484+
update() {
485+
486+
super.update();
517487

518488
// check for cameras _after_ base update so we can enable pre-loading the root tileset
519-
if ( cameras.length === 0 && this.root ) {
489+
if ( this.cameras.length === 0 && this.root ) {
520490

521491
let found = false;
522492
this.invokeAllPlugins( plugin => found = found || Boolean( plugin !== this && plugin.calculateTileViewError ) );

0 commit comments

Comments
 (0)