Skip to content

Commit e56e042

Browse files
ibesoragithub-actions[bot]
authored andcommitted
Preserve models on tile reload
GitOrigin-RevId: 257e591ea224d07bcec55c554dbfa692730d6e7e
1 parent c56425e commit e56e042

File tree

7 files changed

+10
-10
lines changed

7 files changed

+10
-10
lines changed

3d-style/data/bucket/model_bucket.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ class ModelBucket implements Bucket {
422422
this.uploaded = true;
423423
}
424424

425-
destroy() {
425+
destroy(reload?: boolean) {
426426
for (const modelId in this.instancesPerModel) {
427427
const perModelAttributes: PerModelAttributes = this.instancesPerModel[modelId];
428428
if (perModelAttributes.instancedDataArray.length === 0) continue;
@@ -431,7 +431,7 @@ class ModelBucket implements Bucket {
431431
}
432432
}
433433
const modelManager = this.layers[0].modelManager;
434-
if (modelManager && this.modelUris && this.modelsRequested) {
434+
if (reload && modelManager && this.modelUris && this.modelsRequested) {
435435
for (const modelUri of this.modelUris) {
436436
modelManager.removeModel(modelUri, "", true);
437437
}

src/data/bucket.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export interface Bucket {
135135
*
136136
* @private
137137
*/
138-
destroy: () => void;
138+
destroy: (reload?: boolean) => void;
139139
updateFootprints: (id: UnwrappedTileID, footprints: Array<TileFootprint>) => void;
140140
updateAppearances: (canonical?: CanonicalTileID, featureState?: FeatureStates, availableImages?: Array<ImageId>, globalProperties?: GlobalProperties) => void;
141141
}

src/source/custom_source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ class CustomSource<T> extends Evented<SourceEvents> implements ISource {
335335
if (tile.texture && tile.texture instanceof Texture) {
336336
// Clean everything else up owned by the tile, but preserve the texture.
337337
// Destroy first to prevent racing with the texture cache being popped.
338-
tile.destroy(true);
338+
tile.destroy(false);
339339

340340
// Save the texture to the cache
341341
if (tile.texture && tile.texture instanceof Texture) {

src/source/geojson_source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -476,7 +476,7 @@ class GeoJSONSource extends Evented<SourceEvents> implements ISource {
476476
}
477477

478478
delete tile.request;
479-
tile.destroy();
479+
tile.destroy(false);
480480

481481
if (tile.aborted) {
482482
return callback(null);

src/source/raster_array_tile_source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ class RasterArrayTileSource extends RasterTileSource<'raster-array'> {
168168
if (textures.size) {
169169
// Clean everything else up owned by the tile, but preserve the texture.
170170
// Destroy first to prevent racing with the texture cache being popped.
171-
tile.destroy(true);
171+
tile.destroy(false);
172172
// Preserve the textures in the cache
173173
for (const texture of textures.values()) {
174174
// Save the texture to the cache

src/source/raster_tile_source.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ class RasterTileSource<T = 'raster'> extends Evented<SourceEvents> implements IS
245245
if (tile.texture && tile.texture instanceof Texture) {
246246
// Clean everything else up owned by the tile, but preserve the texture.
247247
// Destroy first to prevent racing with the texture cache being popped.
248-
tile.destroy(true);
248+
tile.destroy(false);
249249

250250
// Save the texture to the cache
251251
if (tile.texture && tile.texture instanceof Texture) {

src/source/tile.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,9 +1018,9 @@ class Tile {
10181018
* @returns {undefined}
10191019
* @private
10201020
*/
1021-
destroy(preserveTexture: boolean = false) {
1021+
destroy(reload: boolean = true) {
10221022
for (const id in this.buckets) {
1023-
this.buckets[id].destroy();
1023+
this.buckets[id].destroy(reload);
10241024
}
10251025

10261026
this.buckets = {};
@@ -1083,7 +1083,7 @@ class Tile {
10831083
this._globeTileDebugTextBuffer = null;
10841084
}
10851085

1086-
if (!preserveTexture && this.texture && this.texture instanceof Texture) {
1086+
if (reload && this.texture && this.texture instanceof Texture) {
10871087
this.texture.destroy();
10881088
delete this.texture;
10891089
}

0 commit comments

Comments
 (0)