0
\$\begingroup\$

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

\$\endgroup\$

2 Answers 2

2
\$\begingroup\$

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

\$\endgroup\$
4
  • \$\begingroup\$ 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; \$\endgroup\$ Jun 7, 2014 at 17:37
  • 1
    \$\begingroup\$ Yes, it would have been more clean in a function. May be the apropiate name would be updateCameraPosition \$\endgroup\$
    – vals
    Jun 9, 2014 at 16:47
  • \$\begingroup\$ Why not rotate the object at the center of the scene instead of rotating the camera? I'm just wondering because when you rotate the camera you loose lighting positions, etc since they are not constrained to the camera position. \$\endgroup\$ Jul 21, 2016 at 22:33
  • \$\begingroup\$ How would I adjust this to make a quick succession of short rotations, just to give the object the appearance of a short "wiggle". We want to catch the user's eye. I'm thinking we would issue a series of positions and lookAt commands with a timeout in between, but I haven't been able to make it work. \$\endgroup\$
    – awright
    Aug 5, 2016 at 21:04
1
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\begingroup\$ I was thinking the same thing, but could you be more specific about where that happens? \$\endgroup\$ Jun 2, 2014 at 4:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .