[英]three.js lookat() function not works as i need
有我的代碼http://codepen.io/usf/pen/pGscf
在這一部分
function animate() {
//sun.rotation.x = t/1000;
sun.rotation.y += 0.01;
t += 0.1;
earth.position.x = Math.sin((2*Math.PI/24*60*60)*timeScale*t)*300;
earth.position.z = Math.cos((2*Math.PI/24*60*60)*timeScale*t)*200;
camera.position.set(sun.position);
camera.lookAt(earth.position);
//sun.lookAt(earth.position);
renderer.clear();
renderer.render(scene, camera);
window.requestAnimationFrame(animate, renderer.domElement);
};
我想從太陽(lol)看地球,但我什么也看不見。 我怎么能解決這個問題? 我認為有一些小錯誤,但無法找到它
這里有一些問題: camera.position.set(sun.position);
set方法應該像這樣使用:
set: function ( x, y, z ) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
請改用camera.position.copy(sun.position)
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.