Help Me With Spotlight Direction And Angle

Hello,

I am trying to create 3 spotlights for the object at 0,0,0. My object has Y height about 10 unit.

  • The first spotlight should be placed at the camera position and should be following the camera position when rotating the scene.
  • The second spotlight should be placed 120 deg from the camera with 0,0,0 rotation anchor. So it should be behind the object.
  • The third spotlight should be place -120 deg from the camera with 0,0,0 rotation anchor. So it should be behind the object.

Here is my https://playground.babylonjs.com/#45FDGY#1.

In my playground I use PointLight, I want to change into SpotLight. I do not know how to set the direction and angle. Please help.

Hello @Alvin_Stefanus , how are you doing?

I took you playground and modified it to use SpotLights, the trick is to also set the directions appropriately when moving the light around, since your object is in the center you can do that by always setting the direction to be the inverse of the light position. Otherwise, you would have to subtract the light position from the target mesh position.

Babylon.js Playground (babylonjs-playground.com)