So I have a cube mesh placed at a random location:
mesh.position.set(target.x, target.y, target.z);
scene.add(mesh);
I want to draw its edge lines in that location. I tried using EdgeGeometry as suggest. However, it only works when the mesh is set at the origin but the efforts for updating its buffer geometry doesn’t make it work!
const newBox = mesh.geometry.clone();
newBox.applyQuaternion(mesh.quaternion);
newBox.attributes.position =
newBox.attributes.position.applyMatrix4(mesh.matrixWorld);
newBox.attributes.position.needsUpdate = true;
const edges = new THREE.EdgesGeometry(newBox);
const lines = new THREE.LineSegments(
edges,
new THREE.LineBasicMaterial({ color: "red" })
);
scene.add(lines);
mesh
the outline edges are placed at the same location for all meshes. I’ve also rotated the original mesh so the outline should be rotated.
As mentioned before that’s what I tried
New contributor
Voy Hexag is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.