Dynamic camera position

Hello, I have a question, how do I make the light come from the camera? Everywhere in the documentation there are examples with dynamic changes in the intensity, color, and position of light, but nowhere is it specified how to fix the light at the camera’s anchor point, so that when the camera’s position changes, the light source also changes its position following the camera. Can you tell me how this can be implemented, or from which function or paragraphs in the documentation you need to build on.

Hi, viktor. If you need a quick solution, you can use a TransformNode and move it, then attach the light source and camera to the TransformNode, making it their parent.
BABYLON.Node

This is my quick answer, but if you’d like, we can go into more detail about what kind of light source you need. Is it a standard Environmental Omni Light or a SpotLight? If it’s a SpotLight, you can attach the camera’s target to the light source’s target also.

In render loop I update every frame the light.position and light.direction (where light is instance of object of Light).

1 Like