Three.js beginner here, I'm trying to create a 3d-ring like structure composed of separate meshes that I union together using CSG. I managed to place each of the separate meshes along a circle. How do I now rotate them so that the long side of each one is facing the center of the circle (I believe this is rotating about the object's y-axis)? The meshes are currently all facing the same direction, and what I have so far.
However, when I tried rotating one of them about the y-axis, it did not rotate inwards towards the circle as I expected. Instead, it rotated like this. It does not seem like it rotated from the center of the position it was previously at.
I tried the following code to get this result:
mesh.position.x = 0;
mesh.position.y = 0;
mesh.position.z = 0;
mesh.updateMatrixWorld( true );
// Also tried "mesh.rotation.y = ((2 * Math.PI) / 10) * k;" instead of the following line:
mesh.rotateY(((2 * Math.PI) / 10) * k);
mesh.position.x = 25 * Math.cos((2 * k * Math.PI) / 10);
mesh.position.y = 0;
mesh.position.z = 25 * Math.sin((2 * k * Math.PI) / 10);
mesh.updateMatrixWorld( true );
Thanks in advance! (Also side note, if anyone understands why some parts of the meshes are randomly becoming non-existent/transparent, would be super helpful).
EDIT: JSFiddle Link
https://raw.githubusercontent.comare being blocked (you can see all the errors by opening the dev console). Try replacing your external resources with assets from here gitcdn.link and you'll see the errors correcting themselves as you replace the URLS.