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);
controls.target.copy(dodecahedron.position);
const ambientLight = new THREE.AmbientLight(0x404040); // soft white light
scene.add(ambientLight);
const directionalLight = new THREE.DirectionalLight(0xffffff, 2);
directionalLight.position.set(0, 0, 3); // Shine from behind the camera
camera.add(directionalLight);
const light = new THREE.PointLight(0xffffff, 5);
light.position.set(0, 0, -3); // Position in front of the camera
camera.add(light);
const helper = new THREE.PointLightHelper(light);
scene.add(helper);
const cameraHelper = new CameraHelper(camera);
scene.add(cameraHelper);
function animate() {
requestAnimationFrame(animate);
renderer.render(scene, camera);
controls.update();
}
animate();
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