Change the way the label faces the camera

This commit is contained in:
Rayzeq 2021-06-21 22:55:08 +02:00
parent 6ceb9497ae
commit 280c71bbf2

View file

@ -275,7 +275,7 @@ async function createMesh(width, height, segmentsX, segmentsY) {
const [x, y, z] = get3dCoords(label.x.baseVal[0].value, label.y.baseVal[0].value)
text_mesh.position.set(x, y + 15, z);
text_mesh.animate = function () {
this.lookAt(camera.position);
this.rotation.copy(camera.rotation);
}
textMeshs.push(text_mesh)
@ -290,11 +290,11 @@ async function createMesh(width, height, segmentsX, segmentsY) {
const [x, y, z] = get3dCoords(label.x.baseVal[0].value, label.y.baseVal[0].value)
text_mesh.position.set(x, y + 5, z);
text_mesh.animate = function () {
this.lookAt(camera.position);
if(this.position.distanceTo(camera.position) > 200) {
this.visible = false;
} else {
this.visible = true;
this.rotation.copy(camera.rotation);
}
}