Three.js: add light to the camera

I want to move and rotate the camera, but keep PointLight in the same position relative to the camera. I read a bunch of threads saying that you can add a light object to the camera instead of the scene. For instance:

pointLight = new THREE.PointLight( 0xffffff );
pointLight.position.set(1,1,2);
camera.add(pointLight);

However, this does not seem to work for me. Instead, I now, when the camera changes the position of the light, applying the matrixWorld cameras to my desired relative light position. This works, but adding light to the camera seems like a clean solution.

Am I doing something wrong or is adding a light object to the camera, not recommended?

Thank!

+4
source share
1 answer

You need to add a camera to the scene if the camera has a child, for example, "PointLight".

scene.add( camera );

three.js r.68

+5

All Articles