Three js rotation of objects around a sphere

前端 未结 1 1974
爱一瞬间的悲伤
爱一瞬间的悲伤 2021-01-21 12:28

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

相关标签:
1条回答
  • 2021-01-21 13:19

    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

    0 讨论(0)
提交回复
热议问题