Skip to content

Instantly share code, notes, and snippets.

@nbriz
Last active December 18, 2015 04:29
Show Gist options
  • Save nbriz/41ba4223df04c3fa4abd to your computer and use it in GitHub Desktop.
Save nbriz/41ba4223df04c3fa4abd to your computer and use it in GitHub Desktop.
swinging camera motion for threejs_playGnd
/* ------------------- INSTRUCTIONS -----
to swing the camera back and fourth
add the code below to your draw() function
to change the axis the camera swings on
change the 'x' after 'position' to 'y' or 'z'
-------------------------------------- */
camera.position.x = Math.sin( Date.now() * 0.002 ) * 50;
/* --------------------------------------
you can also swing a mesh this way
-------------------------------------- */
mesh.position.y = Math.sin( Date.now() * 0.002 ) * 300;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment