Skip to content

Commit 2575b17

Browse files
authored
Merge pull request #200 from NASA-AMMOS/priority-update
TilesRendererBase: Improve default priority behavior
2 parents 45b6d8b + 8b4a5c9 commit 2575b17

File tree

3 files changed

+39
-9
lines changed

3 files changed

+39
-9
lines changed

src/base/TilesRendererBase.d.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface Tile {
4646
* How far is this tiles bounds from the nearest active Camera.
4747
* Expected to be filled in during calculateError implementations.
4848
*/
49-
__distanceFromCamera : Number;
49+
__distanceFromCamera : Number;
5050
/**
5151
* This tile is currently active if:
5252
* 1: Tile content is loaded and ready to be made visible if needed
@@ -58,14 +58,20 @@ export interface Tile {
5858
* 2: Tile is within a camera frustum
5959
* 3: Tile meets the SSE requirements
6060
*/
61-
__visible : Boolean;
61+
__visible : Boolean;
6262
/**
63-
* Frame number that this tile was last used: active+visible
63+
* Whether or not the tile was visited during the last update run.
6464
*/
65-
__lastFrameVisited : Number;
65+
__used : Boolean;
66+
67+
/**
68+
* Whether or not the tile was within the frustum on the last update run.
69+
*/
70+
__inFrustum : Boolean;
71+
6672
/**
6773
* TODO: Document this if it is useful enough to be the default property in the LRU sorting.
6874
*/
69-
__depthFromRenderedParent : Number;
75+
__depthFromRenderedParent : Number;
7076

7177
}

src/base/TilesRendererBase.js

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,17 @@ import { UNLOADED, LOADING, PARSING, LOADED, FAILED } from './constants.js';
1414
*/
1515
const priorityCallback = ( a, b ) => {
1616

17-
if ( a.__lastFrameVisited !== b.__lastFrameVisited ) {
17+
if ( a.__inFrustum !== b.__inFrustum ) {
1818

19-
// the lastFrameVisited tracks the last frame where a tile was used
20-
return a.__lastFrameVisited - b.__lastFrameVisited;
19+
// prioritize loading whatever is in the frame
20+
return a.__inFrustum ? 1 : - 1;
2121

22-
} else if ( a.__error !== b.__error ) {
22+
} else if ( a.__used !== b.__used ) {
23+
24+
// prioritize tiles that were used most recently
25+
return a.__used ? 1 : - 1;
26+
27+
} if ( a.__error !== b.__error ) {
2328

2429
// tiles which have greater error next
2530
return a.__error - b.__error;

src/three/TilesRenderer.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -452,6 +452,25 @@ export class TilesRenderer extends TilesRendererBase {
452452
vecY.normalize();
453453
vecZ.normalize();
454454

455+
// handle the case where the box has a dimension of 0 in one axis
456+
if ( scaleX === 0 ) {
457+
458+
vecX.crossVectors( vecY, vecZ );
459+
460+
}
461+
462+
if ( scaleY === 0 ) {
463+
464+
vecY.crossVectors( vecX, vecZ );
465+
466+
}
467+
468+
if ( scaleZ === 0 ) {
469+
470+
vecZ.crossVectors( vecX, vecY );
471+
472+
}
473+
455474
// create the oriented frame that the box exists in
456475
boxTransform.set(
457476
vecX.x, vecY.x, vecZ.x, data[ 0 ],

0 commit comments

Comments
 (0)