MeT*_*-30 8 3d rotation three.js
我有一个Object3d在Three.JS这是一组有些网格对象.
我想围绕Y轴旋转这个组,在它的中心,远离世界中心(0,0,0).
我只知道Group.rotate.y += deg代码,但是对于每个轴方向,它总是围绕(0,0,0)旋转对象,而不是我的组中心!
我怎样才能解决这个问题?
阅读评论
看看Object3D的rotateOnAxis(axis, angle)功能.它应该是这样的:
//declared once at the top of your code
var axis = new THREE.Vector3(0.5,0.5,0);//tilted a bit on x and y - feel free to plug your different axis here
//in your update/draw function
rad += radIncrement;
object.rotateOnAxis(axis,rad);
Run Code Online (Sandbox Code Playgroud)
HTH
这个答案对我有帮助,但代码不太正确。轴必须是单位向量,并且object.rotateOnAxis()是增量的。
这是一个工作示例:
var axis = new THREE.Vector3(4, 0, 7).normalize();
var speed = 0.01;
// set up scene, etc.
function animate () {
// other code
if (object) {
object.rotateOnAxis(axis, speed);
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
25617 次 |
| 最近记录: |