Create a gist now

Instantly share code, notes, and snippets.

@nbriz /swingCamera.js Secret
Last active Dec 18, 2015

What would you like to do?
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