我正在製作這個程序,您可以點擊一個對象,放大它,然後通過按住鼠標右鍵並拖動來從各個角度查看它。我需要相機繞着物體轉動,而不是用相機看着它旋轉物體。我真的不知道如何去算出它!如何旋轉對象上的THREE.PerspectiveCamera
爲了測試已經有與XYZ一個遊戲對象,我們選擇了和正在尋找
var g = new GameObject(500, 0, 0);//The game object with xyz
this.selected = g;//set selected to g
//Create and set the camera
this.camera = new THREE.PerspectiveCamera(45, w/h, 1, 10000);
this.camera.position.x = 0;
this.camera.position.y = 0;
this.camera.position.z = 0;
//set camera to look at the object which is 500 away in the x direction
this.camera.lookAt(new THREE.Vector3(this.selected.x, this.selected.y, this.selected.z));
所以相機和物體之間的半徑是500,而選擇和旋轉,該相機應該始終離開500。
我在這裏更新的情景:
Main.prototype.update = function(){
this.renderer.render(this.scene, this.camera);//scene is just some ambient lighting
//what to do when mouse right is held down
if(this.rightMouseDown){
//placeholder functionality, needs to rotate around object based on mouse movements
this.camera.position.x -= 5;
}
}
如何旋轉此相機周圍克,具有500半徑?!?!
爲什麼不使用軌跡球控件? http://threejs.org/examples/misc_controls_trackball.html – gaitat 2014-11-23 23:40:31