kopia lustrzana https://github.com/robhawkes/vizicities
Merge pull request #192 from UDST/bug/destroy-workers
Fix an issue with worker layers erroring after destructionfeature/threejs-update
commit
77b72df352
|
@ -146,7 +146,7 @@ class GeoJSONWorkerLayer extends Layer {
|
||||||
if (processPromises.length > 0) {
|
if (processPromises.length > 0) {
|
||||||
Promise.all(processPromises).then(() => {
|
Promise.all(processPromises).then(() => {
|
||||||
resolve();
|
resolve();
|
||||||
});
|
}).catch(reject);
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
@ -333,7 +333,7 @@ class GeoJSONWorkerLayer extends Layer {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
}).catch(reject);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +439,7 @@ class GeoJSONWorkerLayer extends Layer {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
}).catch(reject);
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
@ -550,7 +550,7 @@ class GeoJSONWorkerLayer extends Layer {
|
||||||
}
|
}
|
||||||
|
|
||||||
resolve();
|
resolve();
|
||||||
});
|
}).catch(reject);
|
||||||
} else {
|
} else {
|
||||||
resolve();
|
resolve();
|
||||||
}
|
}
|
||||||
|
@ -1079,14 +1079,26 @@ class GeoJSONWorkerLayer extends Layer {
|
||||||
//
|
//
|
||||||
// Could make this an abstract method for each geometry layer
|
// Could make this an abstract method for each geometry layer
|
||||||
_setPolygonMesh(attributes, attributeLengths, style, flat) {
|
_setPolygonMesh(attributes, attributeLengths, style, flat) {
|
||||||
|
if (!this._world) {
|
||||||
|
return Promise.reject();
|
||||||
|
}
|
||||||
|
|
||||||
return PolygonLayer.SetMesh(attributes, attributeLengths, flat, style, this._options, this._world._environment._skybox);
|
return PolygonLayer.SetMesh(attributes, attributeLengths, flat, style, this._options, this._world._environment._skybox);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setPolylineMesh(attributes, attributeLengths, style, flat) {
|
_setPolylineMesh(attributes, attributeLengths, style, flat) {
|
||||||
|
if (!this._world) {
|
||||||
|
return Promise.reject();
|
||||||
|
}
|
||||||
|
|
||||||
return PolylineLayer.SetMesh(attributes, attributeLengths, flat, style, this._options);
|
return PolylineLayer.SetMesh(attributes, attributeLengths, flat, style, this._options);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setPointMesh(attributes, attributeLengths, style, flat) {
|
_setPointMesh(attributes, attributeLengths, style, flat) {
|
||||||
|
if (!this._world) {
|
||||||
|
return Promise.reject();
|
||||||
|
}
|
||||||
|
|
||||||
return PointLayer.SetMesh(attributes, attributeLengths, flat, style, this._options, this._world._environment._skybox);
|
return PointLayer.SetMesh(attributes, attributeLengths, flat, style, this._options, this._world._environment._skybox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -349,7 +349,7 @@ class GeoJSONTile extends Tile {
|
||||||
|
|
||||||
this._ready = true;
|
this._ready = true;
|
||||||
// console.timeEnd(this._tile);
|
// console.timeEnd(this._tile);
|
||||||
});
|
}).catch(() => {});
|
||||||
}
|
}
|
||||||
|
|
||||||
_abortRequest() {
|
_abortRequest() {
|
||||||
|
|
|
@ -63,6 +63,8 @@ class TileLayer extends Layer {
|
||||||
|
|
||||||
super(_options);
|
super(_options);
|
||||||
|
|
||||||
|
this._destroy = false;
|
||||||
|
|
||||||
this._tileCache = new TileCache(this._options.maxCache, tile => {
|
this._tileCache = new TileCache(this._options.maxCache, tile => {
|
||||||
this._destroyTile(tile);
|
this._destroyTile(tile);
|
||||||
});
|
});
|
||||||
|
@ -102,7 +104,7 @@ class TileLayer extends Layer {
|
||||||
|
|
||||||
// Update and output tiles from the previous LOD checklist
|
// Update and output tiles from the previous LOD checklist
|
||||||
_outputTiles() {
|
_outputTiles() {
|
||||||
if (!this._tiles) {
|
if (!this._tiles || this._destroy) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -135,7 +137,7 @@ class TileLayer extends Layer {
|
||||||
//
|
//
|
||||||
// Does not output the tiles, deferring this to _outputTiles()
|
// Does not output the tiles, deferring this to _outputTiles()
|
||||||
_calculateLOD() {
|
_calculateLOD() {
|
||||||
if (this._stop || !this._world) {
|
if (this._stop || !this._world || this._destroy) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,6 +372,8 @@ class TileLayer extends Layer {
|
||||||
|
|
||||||
// Destroys the layer and removes it from the scene and memory
|
// Destroys the layer and removes it from the scene and memory
|
||||||
destroy() {
|
destroy() {
|
||||||
|
this._destroy = true;
|
||||||
|
|
||||||
if (this._tiles.children) {
|
if (this._tiles.children) {
|
||||||
// Remove all tiles
|
// Remove all tiles
|
||||||
for (var i = this._tiles.children.length - 1; i >= 0; i--) {
|
for (var i = this._tiles.children.length - 1; i >= 0; i--) {
|
||||||
|
|
Ładowanie…
Reference in New Issue