Skip to content

Commit

Permalink
Merge pull request #200 from NASA-AMMOS/priority-update
Browse files Browse the repository at this point in the history
TilesRendererBase: Improve default priority behavior
  • Loading branch information
gkjohnson authored Jul 28, 2021
2 parents 45b6d8b + 8b4a5c9 commit 2575b17
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 9 deletions.
16 changes: 11 additions & 5 deletions src/base/TilesRendererBase.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export interface Tile {
* How far is this tiles bounds from the nearest active Camera.
* Expected to be filled in during calculateError implementations.
*/
__distanceFromCamera : Number;
__distanceFromCamera : Number;
/**
* This tile is currently active if:
* 1: Tile content is loaded and ready to be made visible if needed
Expand All @@ -58,14 +58,20 @@ export interface Tile {
* 2: Tile is within a camera frustum
* 3: Tile meets the SSE requirements
*/
__visible : Boolean;
__visible : Boolean;
/**
* Frame number that this tile was last used: active+visible
* Whether or not the tile was visited during the last update run.
*/
__lastFrameVisited : Number;
__used : Boolean;

/**
* Whether or not the tile was within the frustum on the last update run.
*/
__inFrustum : Boolean;

/**
* TODO: Document this if it is useful enough to be the default property in the LRU sorting.
*/
__depthFromRenderedParent : Number;
__depthFromRenderedParent : Number;

}
13 changes: 9 additions & 4 deletions src/base/TilesRendererBase.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,17 @@ import { UNLOADED, LOADING, PARSING, LOADED, FAILED } from './constants.js';
*/
const priorityCallback = ( a, b ) => {

if ( a.__lastFrameVisited !== b.__lastFrameVisited ) {
if ( a.__inFrustum !== b.__inFrustum ) {

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

} else if ( a.__error !== b.__error ) {
} else if ( a.__used !== b.__used ) {

// prioritize tiles that were used most recently
return a.__used ? 1 : - 1;

} if ( a.__error !== b.__error ) {

// tiles which have greater error next
return a.__error - b.__error;
Expand Down
19 changes: 19 additions & 0 deletions src/three/TilesRenderer.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,6 +452,25 @@ export class TilesRenderer extends TilesRendererBase {
vecY.normalize();
vecZ.normalize();

// handle the case where the box has a dimension of 0 in one axis
if ( scaleX === 0 ) {

vecX.crossVectors( vecY, vecZ );

}

if ( scaleY === 0 ) {

vecY.crossVectors( vecX, vecZ );

}

if ( scaleZ === 0 ) {

vecZ.crossVectors( vecX, vecY );

}

// create the oriented frame that the box exists in
boxTransform.set(
vecX.x, vecY.x, vecZ.x, data[ 0 ],
Expand Down

0 comments on commit 2575b17

Please sign in to comment.