Skip to content

Commit 7492c8e

Browse files
committed
refactor(Label): optimize elevation update.
1 parent 90ada88 commit 7492c8e

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

src/Core/Label.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,8 +205,8 @@ class Label extends THREE.Object3D {
205205
this.updateMatrixWorld();
206206
}
207207

208-
updateElevationFromLayer(layer) {
209-
const elevation = Math.max(0, DEMUtils.getElevationValueAt(layer, this.coordinates, DEMUtils.FAST_READ_Z));
208+
updateElevationFromLayer(layer, nodes) {
209+
const elevation = Math.max(0, DEMUtils.getElevationValueAt(layer, this.coordinates, DEMUtils.FAST_READ_Z, nodes));
210210
if (elevation && elevation != this.coordinates.z) {
211211
this.coordinates.z = elevation;
212212
this.updateHorizonCullingPoint();

src/Layer/LabelLayer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class LabelLayer extends Layer {
175175
const elevationLayer = node.material.getElevationLayer();
176176
if (elevationLayer && node.layerUpdateState[elevationLayer.id].canTryUpdate()) {
177177
node.children.forEach((c) => {
178-
if (c.isLabel && c.needsAltitude && c.updateElevationFromLayer(this.parent)) {
178+
if (c.isLabel && c.needsAltitude && c.updateElevationFromLayer(this.parent, [node])) {
179179
c.update3dPosition(context.view.referenceCrs);
180180
}
181181
});
@@ -214,7 +214,7 @@ class LabelLayer extends Layer {
214214

215215
labels.forEach((label) => {
216216
if (label.needsAltitude) {
217-
label.updateElevationFromLayer(this.parent);
217+
label.updateElevationFromLayer(this.parent, [node]);
218218
}
219219

220220
const present = node.children.find(l => l.isLabel && l.baseContent == label.baseContent);

0 commit comments

Comments
 (0)