Skip to content

Commit

Permalink
refactor(Label): optimize elevation update.
Browse files Browse the repository at this point in the history
  • Loading branch information
gchoqueux committed Mar 15, 2023
1 parent 90ada88 commit 7492c8e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/Core/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ class Label extends THREE.Object3D {
this.updateMatrixWorld();
}

updateElevationFromLayer(layer) {
const elevation = Math.max(0, DEMUtils.getElevationValueAt(layer, this.coordinates, DEMUtils.FAST_READ_Z));
updateElevationFromLayer(layer, nodes) {
const elevation = Math.max(0, DEMUtils.getElevationValueAt(layer, this.coordinates, DEMUtils.FAST_READ_Z, nodes));
if (elevation && elevation != this.coordinates.z) {
this.coordinates.z = elevation;
this.updateHorizonCullingPoint();
Expand Down
4 changes: 2 additions & 2 deletions src/Layer/LabelLayer.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ class LabelLayer extends Layer {
const elevationLayer = node.material.getElevationLayer();
if (elevationLayer && node.layerUpdateState[elevationLayer.id].canTryUpdate()) {
node.children.forEach((c) => {
if (c.isLabel && c.needsAltitude && c.updateElevationFromLayer(this.parent)) {
if (c.isLabel && c.needsAltitude && c.updateElevationFromLayer(this.parent, [node])) {
c.update3dPosition(context.view.referenceCrs);
}
});
Expand Down Expand Up @@ -214,7 +214,7 @@ class LabelLayer extends Layer {

labels.forEach((label) => {
if (label.needsAltitude) {
label.updateElevationFromLayer(this.parent);
label.updateElevationFromLayer(this.parent, [node]);
}

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

0 comments on commit 7492c8e

Please sign in to comment.