개체를 클릭하고 확대/축소 한 다음 마우스 오른쪽 단추를 누른 채 드래그하여 모든 각도에서 볼 수있는이 프로그램을 만들고 있습니다. 나는 카메라가 물체를 돌아 다닐 필요가있다. 물체를 바라 보는 카메라로 물체를 회전시키지 말아야한다. 나는 정직하게 그것을 어떻게 계산하는지 전혀 모른다! 테스트를 위해THREE.PerspectiveCamera를 개체 주위로 회전시키는 방법
그래서 카메라와 피사체 사이의 반경이 500이며, 선택 및 회전하는 동안, 카메라가 항상해야 이미 우리가 선택하고
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));
보고있다 XYZ와 게임 오브젝트가 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)의 반경 g 주위에 카메라를 회전합니까?!?!
왜 트랙볼 컨트롤을 사용하지 않습니까? http://threejs.org/examples/misc_controls_trackball.html – gaitat