Skip to content

Commit 70162ae

Browse files
authored
fix: fix outdated tile cache of vt layer, close maptalks/issues#937 (#2816)
1 parent 6f30ef8 commit 70162ae

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

packages/vt/src/layer/plugins/PainterPlugin.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,19 @@ function createPainterPlugin(type, Painter) {
135135
}
136136
}
137137

138-
let meshes = this._getMesh(key);
138+
let meshes = tileCache.meshes;
139139
if (!meshes) {
140140
const { meshes: newMeshes, retire: isRetire } = this._createMeshes(geometries, context);
141141
if (!retire) {
142142
retire = isRetire;
143143
}
144144
meshes = newMeshes;
145+
const oldMeshes = this._getMesh(key);
146+
if (oldMeshes) {
147+
painter.deleteMesh(oldMeshes, true);
148+
}
149+
tileCache.meshes = meshes;
150+
this._meshCache[key] = meshes;
145151
}
146152
return { retire };
147153
},
@@ -170,8 +176,6 @@ function createPainterPlugin(type, Painter) {
170176
if (sceneConfig.animation) {
171177
meshes._animationTime = context.timestamp;
172178
}
173-
const key = this._getMeshKey(context);
174-
this._meshCache[key] = meshes;
175179
}
176180
return { meshes, retire };
177181
},

packages/vt/src/layer/renderer/VectorTileLayerRenderer.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1403,6 +1403,7 @@ class VectorTileLayerRenderer extends CanvasCompatible(TileLayerRendererable(Lay
14031403
const skinImage = skinImages[i];
14041404
const texture = skinImage.texture;
14051405
this._parentContext = {
1406+
tile: skinImage.tile,
14061407
terrainMaskFBO: skinImage.terrainMaskFBO,
14071408
renderTarget: {
14081409
fbo: texture

packages/vt/src/worker/layer/GeojsonLayerWorker.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export default class GeoJSONLayerWorker extends BaseLayerWorker {
4747
cb();
4848
return;
4949
}
50+
this.empty = false;
5051
const options = {
5152
maxZoom: 24, // max zoom to preserve detail on; can't be higher than 24
5253
tolerance: this.options.simplifyTolerance, // simplification tolerance (higher means simpler)

0 commit comments

Comments
 (0)