Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

which part of the code is responsible for the rotation in this example? Is it the camera or the scene itself?

http://threejs.org/examples/#canvas_camera_orthographic

share|improve this question
add comment

2 Answers 2

up vote 1 down vote accepted

in the render function, you have

function render() {

    var timer = Date.now() * 0.0001;

    camera.position.x = Math.cos( timer ) * 200;
    camera.position.z = Math.sin( timer ) * 200;
    camera.lookAt( scene.position );

renderer.render( scene, camera );

}

That makes the camera take a circular path of radius 200 , always looking at the center of the scene

share|improve this answer
    
all this should be in a rotate function or something.. var timer = Date.now() * 0.0001; camera.position.x = Math.cos( timer ) * 200; camera.position.z = Math.sin( timer ) * 200; –  expiredninja Jun 7 at 17:37
1  
Yes, it would have been more clean in a function. May be the apropiate name would be updateCameraPosition –  vals Jun 9 at 16:47
add comment

According to the source they call the render method and it simply updates the camera position and uses camera.lookAt() to calculate the matrix to look at the center.

share|improve this answer
    
I was thinking the same thing, but could you be more specific about where that happens? –  expiredninja Jun 2 at 4:43
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.