Skip to content

Commit 5d0ca6f

Browse files
mgermeriegchoqueux
authored andcommittedJul 8, 2021
fix(Label): rounds the projected coordinates of labels
1 parent 26b970b commit 5d0ca6f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed
 

‎src/Core/Label.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,11 @@ class Label extends THREE.Object3D {
134134
}
135135

136136
updateCSSPosition() {
137-
this.content.style[STYLE_TRANSFORM] = `translate(${this.boundaries.left + this.padding}px, ${this.boundaries.top + this.padding}px)`;
137+
this.content.style[STYLE_TRANSFORM] = `translate(${
138+
this.projectedPosition.x + this.offset.left
139+
}px, ${
140+
this.projectedPosition.y + this.offset.top
141+
}px)`;
138142
}
139143

140144
/**

‎test/unit/label.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ describe('Label', function () {
148148

149149
label.updateProjectedPosition(10.4, 10.6);
150150
label.updateCSSPosition();
151-
assert.equal(label.content.style.transform, 'translate(15.4px, 15.6px)');
151+
assert.equal(label.content.style.transform, 'translate(15px, 16px)');
152152
});
153153

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

0 commit comments

Comments
 (0)
Please sign in to comment.