S
S
Sergey Shilov2019-08-13 14:44:24
WebGL
Sergey Shilov, 2019-08-13 14:44:24

How to make smooth background change in three.js?

Good afternoon! I'm trying to change the background under different conditions. Everything works, but the background needs to change smoothly, similar to the css transition property. It is not possible to google this question correctly.
Here is the code:

function menuCurrent(dist) {
         if (dist > -680 && dist < planesLength + 300) {
             currentMenu('tattoo');
             scene.background = new THREE.Color(0xff0000);
         } else if (dist >= planesLength + 300 && dist < planesLength + picturesLength + 550) {
             currentMenu('picture');
         } else if (dist >= planesLength + picturesLength + 550) {
             currentMenu('about');
         } else if (isFrontPage) {
             $('#header-menu .active').removeClass('active');
             scene.background = new THREE.Color(0x0D0D45);
         }
     }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikolai Chuprik, 2019-10-27
@choupa

It just won't work. You need to write an animation function. On each each frame, step by step change the color along the way from the initial to the final.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question