Skip to content Skip to sidebar Skip to footer

Three Js Rotation Of Objects Around A Sphere

I am using a particle system to evenly distribute points on a sphere. That works great. I then place instances of a given geometry on those points. This part also works. I would no

Solution 1:

If you want you cubes to be rotated so they are tangent to the sphere, then think of each cube as being on the end of a stick.

The stick is an Object3D located at the origin. The cube is a child of the stick located at ( 0, 0, r ). Now rotate the stick to where you want. ( But avoid the north and south poles. )

var parent = new THREE.Object3D();
scene.add( parent );

var stick = new THREE.Object3D();
var point = new THREE.Vector3( x, y, z );
stick.lookAt( point );
parent.add( stick );

var geometry = new THREE.CubeGeometry( 25, 25, 25, 1, 1, 1 );
var mesh = new THREE.Mesh( geometry, material );
mesh.position.set( 0, 0, r );
stick.add( mesh );

three.js r.64

Post a Comment for "Three Js Rotation Of Objects Around A Sphere"