1. 程式人生 > >THREE.OrbitControls初始化設置位移/旋轉/滾輪

THREE.OrbitControls初始化設置位移/旋轉/滾輪

blog style spa set object 滾輪 matrix target obj

let oldController;//已知的一個controller

//初始化旋轉(鼠標左鍵的操作)

let position=oldController.object.position;

camera.position.set(position.x,position.y,position.z);

//初始化zoom(鼠標滾輪的操作)

camera.zoom=oldController.object.zoom;

camera.updateProjectionMatrix();//必須update

//初始化位移(鼠標右鍵的操作)

let newController=new THREE.OrbitControls(camera, canvas);

newController.target=oldController.target;

return newController;

THREE.OrbitControls初始化設置位移/旋轉/滾輪