In my project, I am working with an interactive icosahedron mesh that undergoes rotation. As part of the animation loop, circle geometries are dynamically added, and their locations are set to each vertex of the mesh at every frame.
geometry = new THREE.IcosahedronGeometry(isoRadius, 1);
var material = new THREE.MeshBasicMaterial({
color: wireframeColor,
wireframe: true
});
isoMesh = new THREE.Mesh(geometry, material);
scene.add(isoMesh);
The circle geometries' positions are updated as the icosahedron rotates:
function animate() {
isoMesh.rotation.x += 0.005;
isoMesh.rotation.y += 0.002;
// update vertices
isoMesh.updateMatrix();
isoMesh.geometry.applyMatrix(isoMesh.matrix);
isoMesh.rotation.set(0, 0, 0);
for (var i = 0; i < geometry.vertices.length; i++) {
nodes[i].position.copy(geometry.vertices[i]);
nodes[i].lookAt(camera.position);
}
I've noticed a peculiar behavior where if I remove the line "isoMesh.rotation.set(0, 0, 0);", the icosahedron rotates correctly but the nodes rotate too quickly. However, when I add that line back in, the nodes rotate correctly but the icosahedron doesn't move. This discrepancy between the rotations of the nodes and the mesh has me puzzled.
My understanding of three.js is still limited, so I'm unsure why this difference in rotation behavior occurs. It seems there may be a distinction between the mesh and the geometry, leading to this issue. Can anyone shed light on what might be causing this unexpected outcome?