Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
I've made a directional light that I want to change color over time. I'm reading
the documentation
, but still not getting it up and running.
Before init I declare variables:
var rmapped = 0;
var color;
var frontLight;
In my init I have:
color = "rgb(" + r + "," + g + "," + b + ")";
var frontLight = new THREE.DirectionalLight(color, 1);
frontLight.position.set(0, 0, 3000);
frontLight.castShadow = true;
frontLight.shadowDarkness = 1;
frontLight.shadowMapSoft = true;
scene.add(frontLight);
And in my update() I have:
rmapped = rmapped +.1;
color.add(rmapped,1,1)
I'm just as happy using HSL, or using addScalar(). I just need something up and running that can change the color every frame.
Thanks!
// h — hue value between 0.0 and 1.0
// s — saturation value between 0.0 and 1.0
// l — lightness value between 0.0 and 1.0
var h = rmapped * 0.01 % 1;
var s = 0.5;
var l = 0.5;
frontLight.color.setHSL ( h, s, l );
rmapped ++;
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.