Skip to content

Commit 86c69c4

Browse files
authored
Merge pull request #204 from NASA-AMMOS/priority-func-update
Update the priority function (again)
2 parents 533b2df + cd90e21 commit 86c69c4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/base/TilesRendererBase.js

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

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

19-
// prioritize loading whatever is in the frame
19+
// load shallower tiles first
20+
return a.__depth > b.__depth ? - 1 : 1;
21+
22+
} else if ( a.__inFrustum !== b.__inFrustum ) {
23+
24+
// load tiles that are in the frustum at the current depth
2025
return a.__inFrustum ? 1 : - 1;
2126

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

24-
// prioritize tiles that were used most recently
29+
// load tiles that have been used
2530
return a.__used ? 1 : - 1;
2631

27-
} if ( a.__error !== b.__error ) {
32+
} else if ( a.__error !== b.__error ) {
2833

29-
// tiles which have greater error next
30-
return a.__error - b.__error;
34+
// load the tile with the higher error
35+
return a.__error > b.__error ? 1 : - 1;
3136

3237
} else if ( a.__distanceFromCamera !== b.__distanceFromCamera ) {
3338

3439
// and finally visible tiles which have equal error (ex: if geometricError === 0)
3540
// should prioritize based on distance.
36-
return a.__distanceFromCamera - b.__distanceFromCamera;
41+
return a.__distanceFromCamera > b.__distanceFromCamera ? - 1 : 1;
3742

3843
}
3944

0 commit comments

Comments
 (0)