我正試圖創建一個相機,跟隨一個圍繞球體的軌道上旋轉的對象。但每當攝像機到達軌道的極座標時,方向都會改變。如何設置遵循圓形路徑的攝像機?
function render() {
rotation += 0.002;
// set the marker position
pt = path.getPoint(t);
// set the marker position
marker.position.set(pt.x, pt.y, pt.z);
marker.lookAt(new THREE.Vector3(0,0,0));
// rotate the mesh that illustrates the orbit
mesh.rotation.y = rotation
// set the camera position
var cameraPt = cameraPath.getPoint(t);
camera.position.set(cameraPt.x, cameraPt.y, cameraPt.z);
camera.lookAt(marker.position);
t = (t >= 1) ? 0 : t += 0.002;
renderer.render(scene, camera);
}
下面是一個完整的小提琴:我只是根據所必須遵循的對象並調用lookAt
事後設置攝像機的位置http://jsfiddle.net/krw8nwLn/69/
我創建了第二個立方體另一小提琴其中代表所需的相機行爲:http://jsfiddle.net/krw8nwLn/70/
你的兩個鏈接指向相同的網址 –
哦,對不起!我已經更新了這個問題:) – Slevin