I have a merged threejs model of text and plane. I want to create a function so that this model is always facing us. But what happens is the direction is not appropriate. I’m here using Autodesk Forge, but I think operating it will be the same. This is my code.
const box = new THREE.PlaneGeometry(2, 2);
const texture = THREE.ImageUtils.loadTexture(
"https://threejsfundamentals.org/threejs/resources/images/wall.jpg"
);
const globalMaterial = new THREE.MeshBasicMaterial({
map: texture,
side: THREE.DoubleSide,
});
const textGeometry = new THREE.TextGeometry(`Id : ${dbId}`, {
font: "monaco",
size: 1,
height: 0,
curveSegments: 3,
});
let restricted = new THREE.Geometry();
const boxMesh = new THREE.Mesh(box, globalMaterial);
const textMesh = new THREE.Mesh(textGeometry, globalMaterial);
// boxMesh.matrix.makeRotationX(-4.7);
// textMesh.matrix.makeRotationX(-4.7);
textMesh.matrix.setPosition(new THREE.Vector3(-3, 0, 5));
restricted.merge(boxMesh.geometry, boxMesh.matrix);
restricted.merge(textMesh.geometry, textMesh.matrix);
restricted.computeVertexNormals();
const restrictedGeo = new THREE.BufferGeometry().fromGeometry(restricted);
this.restrictedArea = new THREE.Mesh(restrictedGeo, globalMaterial);
this.restrictedArea.matrix.setPosition(new THREE.Vector3(x, y, z));
this.restrictedArea.dbId = dbId;
modelBuilder.addMesh(this.restrictedArea);
lookAtMe(modelBuilder, mesh) {
mesh.matrix.makeRotationFromQuaternion(
this.viewer.getCamera().clone().quaternion
);
modelBuilder.updateMesh(mesh);
}