there is my code http://codepen.io/usf/pen/pGscf
in this part
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);
};
i want to look on earth from sun (lol), but i see nothing. how can i fix that? I think there is some little mistake, but can't find it out
There is something wrong here: camera.position.set(sun.position);
The set method should be used like this :
set: function ( x, y, z ) {
this.x = x;
this.y = y;
this.z = z;
return this;
}
Use camera.position.copy(sun.position)
instead.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.