-
-
Save nbriz/41ba4223df04c3fa4abd to your computer and use it in GitHub Desktop.
swinging camera motion for threejs_playGnd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ------------------- 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