Change light intensity dynamically three times

Is there a way that I have not seen to change the light intensity of directional light on the fly? Or even the surrounding light?

ambientLight = new THREE.AmbientLight(0xffffff); scene.add(ambientLight); directionalLightL = new THREE.DirectionalLight(0xffffff, dLight, 0); directionalLightL.position.set(dlpX, dlpY, dlpZ); scene.add(directionalLightL); 

So this is done initially for rendering, but how can I change only one intensity intensity after that? Remove / re-add light? Find him in the house and change him? Something in the API I did not notice?

+6
source share
1 answer

To change the intensity for DirectionalLight , SpotLight , PointLight or AmbientLight , you simply set it:

 light.intensity = 0.5; 

You can change the background color as follows:

 light.color.setHex( 0xff0000 ); 

See Color.js for other ways to set colors.

three.js r.74

+10
source

Source: https://habr.com/ru/post/944049/


All Articles