three.js鼠标控制插件
代码:
<script src="js/controls/OrbitControls.js"></script>//导入鼠标控制js文件
var clock=new THREE.Clock();
animate();//开始每秒最大60帧的渲染
////////////////////////////////////////////////////////////////
controls = new THREE.OrbitControls(camera, render.domElement);//鼠标控制 鼠标左击旋转 右击平移 滚轮远近
////////////////////////////////////////////////////////////////
function animate() {
//更新性能插件
let delta = clock.getDelta();
controls.update(delta);
requestAnimationFrame( animate );
stats.begin();
render();
stats.end();
}
function render() {
//camera.position.x+=(mousex-camera.position.x)*1;
//camera.position.y+=-(mousey-camera.position.x)*1;//
//camera.lookAt( scene.position );
//以上三句,固定原点,只能滚轮缩放,左键无法拖拽旋转,右键无法平移
renderer.render( scene, camera );
}