Skip to content

Commit

Permalink
fix(Label): rounds the projected coordinates of labels
Browse files Browse the repository at this point in the history
  • Loading branch information
mgermerie authored and gchoqueux committed Jul 8, 2021
1 parent 26b970b commit 5d0ca6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/Core/Label.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,11 @@ class Label extends THREE.Object3D {
}

updateCSSPosition() {
this.content.style[STYLE_TRANSFORM] = `translate(${this.boundaries.left + this.padding}px, ${this.boundaries.top + this.padding}px)`;
this.content.style[STYLE_TRANSFORM] = `translate(${
this.projectedPosition.x + this.offset.left
}px, ${
this.projectedPosition.y + this.offset.top
}px)`;
}

/**
Expand Down
2 changes: 1 addition & 1 deletion test/unit/label.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ describe('Label', function () {

label.updateProjectedPosition(10.4, 10.6);
label.updateCSSPosition();
assert.equal(label.content.style.transform, 'translate(15.4px, 15.6px)');
assert.equal(label.content.style.transform, 'translate(15px, 16px)');
});

it('updates the horizon culling point', function () {
Expand Down

0 comments on commit 5d0ca6f

Please sign in to comment.