Skip to content
Advertisement

(Three.JS) How to loop/lerp through more than two colors (three colors)?

I’m working on a project in the Three.JS Online Editor. I’m trying to make a Day / Night Cycle. It should loop through colors, setting the scene background colors, like this:

  1. Day
  2. Sunrise/Sunset
  3. Night
  4. Sunrise/Sunset
  5. Day … Etc., etc.,

And it should loop through these, forever.

I’ve gotten it to loop through two colors, but I can’t seem to get it to loop through all three.

Is there a way to do this? Here’s my code so far:

JavaScript

Any help would be appreciated.

If anyone needs any more information, please, let me know!

Thanks!

Advertisement

Answer

Try it like so:

JavaScript
JavaScript
JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement