Three.js -相机旋转&TransformControls
Three.js - Camera rotation & TransformControls
在我的three.js场景中我可以添加和编辑对象。我最近添加了一个"旋转相机"复选框,效果很好。但问题是,附加到对象上的transformControls似乎以不同的方式旋转:当我停止旋转时,控件与对象相比发生了位移。下面是我的函数:
function optionCameraRotation() {
"use strict";
return {
ROTATION_Y_AXIS : false
};
}
var rotationOption = optionCameraRotation();
我的GUI.DAT按钮:
guiCamera.add(rotationOption, 'ROTATION_Y_AXIS').name('Rotation Active');
我的animate()函数:
function animate() {
requestAnimationFrame( animate );
THREE.AnimationHandler.update( 0.05 );
if (rotationOption.ROTATION_Y_AXIS) {
scene.rotation.y = (scene.rotation.y + 0.005 * 4) % (Math.PI * 2);
}
renderer.render( scene, camera );
update();
}
问题在哪里
我只需要纠正我的if语句在我的animate()函数像这样:
if (rotationOption.ROTATION_Y_AXIS) {
var timer = Date.now() * 0.0001;
camera.position.x = Math.cos( timer ) * 200;
camera.position.z = Math.sin( timer ) * 200;
camera.lookAt( scene.position );
renderer.render( scene, camera );
}
相关文章:
- 没有找到相关文章