@@ -58,7 +58,7 @@ function markOverlayImages( range, level, overlay, doRelease ) {
5858
5959 const promises = [ ] ;
6060 const { imageSource, tiling } = overlay ;
61- forEachTileInBounds ( range , level , tiling , overlay . isPlanarProjection , ( tx , ty , tl ) => {
61+ forEachTileInBounds ( range , level , tiling , ( tx , ty , tl ) => {
6262
6363 if ( doRelease ) {
6464
@@ -91,7 +91,7 @@ function markOverlayImages( range, level, overlay, doRelease ) {
9191function countTilesInRange ( range , level , overlay ) {
9292
9393 let total = 0 ;
94- forEachTileInBounds ( range , level , overlay . tiling , overlay . isPlanarProjection , ( x , y , l ) => {
94+ forEachTileInBounds ( range , level , overlay . tiling , ( x , y , l ) => {
9595
9696 total ++ ;
9797
@@ -973,15 +973,14 @@ export class ImageOverlayPlugin {
973973 }
974974
975975 // internal
976- _calculateLevelFromOverlay ( overlay , range , tile , normalized = false ) {
976+ _calculateLevelFromOverlay ( overlay , range , tile ) {
977977
978978 if ( overlay . isPlanarProjection ) {
979979
980980 const { resolution } = this ;
981981 const { tiling } = overlay ;
982982
983- const normalizedRange = normalized ? range : tiling . toNormalizedRange ( range ) ;
984- const [ minX , minY , maxX , maxY ] = normalizedRange ;
983+ const [ minX , minY , maxX , maxY ] = range ;
985984 const w = maxX - minX ;
986985 const h = maxY - minY ;
987986
@@ -1117,17 +1116,18 @@ export class ImageOverlayPlugin {
11171116 . tileInfo
11181117 . set ( tile , info ) ;
11191118
1120- if ( overlay . isPlanarProjection ) {
1119+ // if the overlay isn't ready then we can't convert the range correctly, yet
1120+ if ( overlay . isReady ) {
11211121
1122- // TODO: we could project the shape into the frame, compute 2d bounds, and then mark tiles
1122+ if ( overlay . isPlanarProjection ) {
11231123
1124- } else {
1124+ // TODO: we could project the shape into the frame, compute 2d bounds, and then mark tiles
11251125
1126- // If the tile has a region bounding volume then mark the tiles to preload
1127- if ( tile . boundingVolume . region ) {
1126+ } else if ( tile . boundingVolume . region ) {
11281127
1128+ // If the tile has a region bounding volume then mark the tiles to preload
11291129 const [ minLon , minLat , maxLon , maxLat ] = tile . boundingVolume . region ;
1130- const range = [ minLon , minLat , maxLon , maxLat ] ;
1130+ const range = overlay . tiling . toNormalizedRange ( [ minLon , minLat , maxLon , maxLat ] ) ;
11311131 info . range = range ;
11321132 info . level = this . _calculateLevelFromOverlay ( overlay , range , tile ) ;
11331133
@@ -1224,25 +1224,15 @@ export class ImageOverlayPlugin {
12241224 }
12251225
12261226 ( { range, uvs } = getMeshesCartographicRange ( meshes , ellipsoid , _matrix , tiling ) ) ;
1227+ range = tiling . toNormalizedRange ( range ) ;
12271228 heightInRange = true ;
12281229
12291230 }
12301231
1231- let normalizedRange ;
1232- if ( ! overlay . isPlanarProjection ) {
1233-
1234- normalizedRange = tiling . toNormalizedRange ( range ) ;
1235-
1236- } else {
1237-
1238- normalizedRange = range ;
1239-
1240- }
1241-
12421232 // calculate the tiling level here if not already created
12431233 if ( info . level === null ) {
12441234
1245- info . level = this . _calculateLevelFromOverlay ( overlay , normalizedRange , tile , true ) ;
1235+ info . level = this . _calculateLevelFromOverlay ( overlay , range , tile ) ;
12461236
12471237 }
12481238
@@ -1283,10 +1273,10 @@ export class ImageOverlayPlugin {
12831273
12841274 // if the previous layer is present then draw it as an overlay to fill in any gaps while we wait for
12851275 // the next set of textures
1286- tileComposer . setRenderTarget ( target , normalizedRange ) ;
1276+ tileComposer . setRenderTarget ( target , range ) ;
12871277 tileComposer . clear ( 0xffffff , 0 ) ;
12881278
1289- forEachTileInBounds ( range , info . level - 1 , tiling , overlay . isPlanarProjection , ( tx , ty , tl ) => {
1279+ forEachTileInBounds ( range , info . level - 1 , tiling , ( tx , ty , tl ) => {
12901280
12911281 // draw using normalized bounds since the mercator bounds are non-linear
12921282 const span = tiling . getTileBounds ( tx , ty , tl , true , false ) ;
@@ -1322,10 +1312,10 @@ export class ImageOverlayPlugin {
13221312 }
13231313
13241314 // draw the textures
1325- tileComposer . setRenderTarget ( target , normalizedRange ) ;
1315+ tileComposer . setRenderTarget ( target , range ) ;
13261316 tileComposer . clear ( 0xffffff , 0 ) ;
13271317
1328- forEachTileInBounds ( range , info . level , tiling , overlay . isPlanarProjection , ( tx , ty , tl ) => {
1318+ forEachTileInBounds ( range , info . level , tiling , ( tx , ty , tl ) => {
13291319
13301320 // draw using normalized bounds since the mercator bounds are non-linear
13311321 const span = tiling . getTileBounds ( tx , ty , tl , true , false ) ;
0 commit comments