Having just started working with threejs, I decided to use a for loop to create 400 cylinders. The rendering of the objects in the scene works perfectly. However, when it comes to animating the cylinders, only one out of the 400 seems to rotate. How can I make all of the cylinders rotate?
Below is the code I used:
for( var j = 0; j < 400; j++){
abgeometry2 = new THREE.CylinderGeometry (1, 5, 8, 4);
abmesh2 = new THREE.MeshPhongMaterial({color: 0x3B170B, wireframe: false });
mesh2 = new THREE.Mesh(abgeometry2, abmesh2);
mesh2.position.x = Math.random() * 400 - 200;
mesh2.position.y = Math.random() * 400 - 200;
mesh2.position.z = Math.random() * 400 - 200;
scene.add( mesh2 );
}
In the animate function, I added the following line of code: mesh2.rotation.z += 0.06;
. I understand that I might be missing something obvious, as I am still learning the ins and outs of threejs.