Three.js - Rotating a sphere around a certain axis

前端 未结 4 398
耶瑟儿~
耶瑟儿~ 2020-12-30 05:20

I have a problem. In Three.js, I want to rotate a sphere (Earth) around axis tilted by 23.5 degs. I found sphere.rotation.x, sphere.rotation.y and sphere.rotation.z, but whe

4条回答
  •  不思量自难忘°
    2020-12-30 06:11

    var quaternion = new THREE.Quaternion();
    var object = scene.getObjectByName('xxx');
    function render(){
        quaternion.setFromAxisAngle(new THREE.Vector3(0, 1, 0).normalize(), 0.005);
        object.position.applyQuaternion(quaternion);
    }
    

    three.js version is 86, see full example on codepen.

提交回复
热议问题