Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Three.js change light intensity dynamically

Is there a way that i have not seen to change the light intensity of directional lights on the fly? Or even ambient 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 that is done initially to render, but how can i change just one specific lights intensity afterwards? Remove/re-add the light? Find it in the dom and change it? Something in the API i have not noticed?

like image 745
Austin Best Avatar asked May 01 '13 13:05

Austin Best


1 Answers

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

light.intensity = 0.5;

You can change the light color like so:

light.color.setHex( 0xff0000 );

See Color.js for other ways to set a color.

three.js r.74

like image 87
WestLangley Avatar answered Nov 15 '22 18:11

WestLangley