\$\begingroup\$
\$\endgroup\$
which part of the code is responsible for the rotation in this example? Is it the camera or the scene itself?
expiredninjaexpiredninja
asked Apr 28, 2014 at 18:06
2 Answers 2
\$\begingroup\$
\$\endgroup\$
4
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
-
\$\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\$expiredninja– expiredninja2014年06月07日 17:37:11 +00:00Commented 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– vals2014年06月09日 16:47:23 +00:00Commented 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\$Jake Wilson– Jake Wilson2016年07月21日 22:33:01 +00:00Commented 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– awright2016年08月05日 21:04:00 +00:00Commented Aug 5, 2016 at 21:04
\$\begingroup\$
\$\endgroup\$
1
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.
answered Apr 28, 2014 at 23:52
-
\$\begingroup\$ I was thinking the same thing, but could you be more specific about where that happens? \$\endgroup\$expiredninja– expiredninja2014年06月02日 04:43:45 +00:00Commented Jun 2, 2014 at 4:43
You must log in to answer this question.
lang-js