Skip to content

Instantly share code, notes, and snippets.

@nbriz
Last active December 18, 2015 05:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nbriz/f6187463e7c0bb9166ac to your computer and use it in GitHub Desktop.
Save nbriz/f6187463e7c0bb9166ac to your computer and use it in GitHub Desktop.
oscillate mesh's hue, for threejs_playGnd
/* ------------------- INSTRUCTIONS -----
to oscillate hue
add the code below to your draw() fucntion
-------------------------------------- */
var time = Date.now() * 0.0005;
h = ( 360 * ( 1.0 + time ) % 360 ) / 360;
mesh.material.color.setHSL(h, 0.5, 0.5 );
// ** NOTE ** only 'Basic', 'Lambert' and 'Phong'
// material have a color property, the
// 'Normal' material has no color property
/* --------------------------------------
try also, moving and/or spinning your mesh
add the code below to your draw() function
-------------------------------------- */
mesh.position.x = Math.sin( Date.now() * 0.001 ) * 50;
mesh.rotation.z = Date.now() * 0.0005;
/* --------------------------------------
try also leaving trails
replace the 'renderer = new ...' on line 27
in the setup() function, with the code below
-------------------------------------- */
renderer = new THREE.WebGLRenderer( { preserveDrawingBuffer: true } );
renderer.autoClearColor = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment