directionalLight and PointLight when moving scene

Hello, I’m trying to attach lighting to the camera so that when the scene moves, face of object facing to camera to be lit
i use this code

const controls = new OrbitControls(camera, renderer.domElement);;

  const ambientLight = new THREE.AmbientLight(0x404040); // soft white light

  const directionalLight = new THREE.DirectionalLight(0xffffff, 2);
  directionalLight.position.set(0, 0, 3); // Shine from behind the camera

  const light = new THREE.PointLight(0xffffff, 5);
  light.position.set(0, 0, -3);  // Position in front of the camera

  const helper = new THREE.PointLightHelper(light);

  const cameraHelper = new CameraHelper(camera);

  function animate() {

    renderer.render(scene, camera);


i try directionalLight and light attach to camera but when i do this any light stoped work like in screen but if i change camera.add(directionalLight) to scene.add(directionalLight) light will appear but it is not gonna change when i move camera (screen ) . How to decide this problem? Thanks :slight_smile:

You have to add the camera to the scene as well. Putting it in the scene makes it’s matrices get updated on render.

1 Like