Reputation: 1
I have created a geometry using some x,y,z positions. Now I have to rotate this geometry to its self axis i.e. it should rotate like earth is rotating. I don't want camera to be moved but I want geometry to be moved. Can Someone help? The code right now is something like: var myGeometry = new THREE.Geometry();
for(i=0;i<n;i++)
{
vertex.x = green_arr[i];
vertex.y = green_arr[i+1];
vertex.z = green_arr[i+2];
myGeometry.vertices.push( vertex );
}
var particleCube = new THREE.PointCloud( myGeometry, shaderMaterial );
particleCube.dynamic = true;
particleCube.sortParticles = true;
scene.add( particleCube );
I have for rotation
var time = Date.now() * 0.0004;
scene.children[0].rotation.y = time;
scene.children[0].rotation.z = time * 0.7;
But this is rotating my points all over the screen which I don't want. I want to rotate them around its own axis
Upvotes: 0
Views: 1303
Reputation: 1
Are you trying to rotate each vertex around it's own local position? Or around the PointCloud's position?
It looks like your current code rotates the whole system around its origin. If you want each point rotating around it's own local axis you might try adding them to their own separate array and looping through that in the render function:
for(var p=0; p<particleCube.geometry.length; p++){
particleCube.geometry.vertices[p].rotation.y=time;
particleCube.geometry.vertices[p].rotation.z=time*0.7;
}
Otherwise you might try
particleCube.rotation.y=time;
particleCube.rotation.z=time*0.7;
Upvotes: 0