@@ -14,26 +14,31 @@ import { UNLOADED, LOADING, PARSING, LOADED, FAILED } from './constants.js';
1414 */
1515const 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