我使用原始编辑器示例,其中包含 R69版本的Three.js 。我使用以下代码将OrbitControls添加到Viewport.js文件中(声明轨道控件并与渲染例程集成到场景中)然后场景开始以恒定速度旋转但是如果我以任何方式与场景添加对象进行交互,则单击鼠标,点击+拖动整个场景消失。
var camera = editor.camera;
camera.position.fromArray( editor.config.getKey( 'camera/position' ) );
//camera.lookAt( new THREE.Vector3().fromArray( editor.config.getKey( 'camera/target' ) ) );
// ANIMATION ORBIT CONTROLS
var orbitControls = new THREE.OrbitControls(camera);
orbitControls.autoRotate = true;
var clock = new THREE.Clock();
//
function render() {
sceneHelpers.updateMatrixWorld();
scene.updateMatrixWorld();
// ADDITIONAL CODE
var delta = clock.getDelta();
orbitControls.update(delta/10);
requestAnimationFrame(render);
// ADDITIONAL CODE END
renderer.clear();
renderer.render( scene, camera );
if ( renderer instanceof THREE.RaytracingRenderer === false ) {
renderer.render( sceneHelpers, camera );
}
}