Skip to content

Commit

Permalink
Move common "visibleTiles", "activeTiles" logic to the base class (#929)
Browse files Browse the repository at this point in the history
  • Loading branch information
gkjohnson authored Jan 17, 2025
1 parent abbbb1a commit 040263c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 25 deletions.
10 changes: 8 additions & 2 deletions src/base/TilesRendererBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ export class TilesRendererBase {
parseQueue.maxJobs = 1;
parseQueue.priorityCallback = priorityCallback;

this.visibleTiles = new Set();
this.activeTiles = new Set();
this.usedSet = new Set();
this.lruCache = lruCache;
this.downloadQueue = downloadQueue;
Expand Down Expand Up @@ -494,11 +496,15 @@ export class TilesRendererBase {

}

setTileActive( tile, state ) {
setTileActive( tile, active ) {

active ? this.activeTiles.add( tile ) : this.activeTiles.delete( tile );

}

setTileVisible( tile, state ) {
setTileVisible( tile, visible ) {

visible ? this.visibleTiles.add( tile ) : this.visibleTiles.delete( tile );

}

Expand Down
25 changes: 2 additions & 23 deletions src/three/TilesRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,6 @@ export class TilesRenderer extends TilesRendererBase {
this.cameras = [];
this.cameraMap = new Map();
this.cameraInfo = [];
this.activeTiles = new Set();
this.visibleTiles = new Set();
this.optimizeRaycast = true;
this._upRotationMatrix = new Matrix4();

Expand Down Expand Up @@ -896,10 +894,8 @@ export class TilesRenderer extends TilesRendererBase {
setTileVisible( tile, visible ) {

const scene = tile.cached.scene;
const visibleTiles = this.visibleTiles;
const group = this.group;

// TODO: move "visibleTiles" to TilesRendererBase
if ( visible ) {

if ( scene ) {
Expand All @@ -909,8 +905,6 @@ export class TilesRenderer extends TilesRendererBase {

}

visibleTiles.add( tile );

} else {

if ( scene ) {
Expand All @@ -919,10 +913,10 @@ export class TilesRenderer extends TilesRendererBase {

}

visibleTiles.delete( tile );

}

super.setTileVisible( tile, visible );

this.dispatchEvent( {
type: 'tile-visibility-change',
scene,
Expand All @@ -932,21 +926,6 @@ export class TilesRenderer extends TilesRendererBase {

}

setTileActive( tile, active ) {

const activeTiles = this.activeTiles;
if ( active ) {

activeTiles.add( tile );

} else {

activeTiles.delete( tile );

}

}

calculateError( tile ) {

const cached = tile.cached;
Expand Down

0 comments on commit 040263c

Please sign in to comment.