Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

three.js directional light following camera

I having a problem with Three.js and lighting following a camera.

I am using orbit control for the mouse movement/

In release number 66 the following use to work

    light = new THREE.DirectionalLight( 0xffffff, 1 );
    light.position = camera.position;
    scene.add(light);

However in release number 67 and 68 the lighting doesn't follow the camera. The light is only show on one face.

like image 681
Thomas Turner Avatar asked Nov 16 '25 23:11

Thomas Turner


1 Answers

I got it to work with the help of above

controls = new THREE.OrbitControls(camera);
controls.addEventListener( 'change', light_update );

function light_update()
{
    light.position.copy( camera.position );
}

Thanks

like image 158
Thomas Turner Avatar answered Nov 18 '25 14:11

Thomas Turner



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!