Flashlight Follow Camera

Hi, I’d like to build some kind of flashlight or Torch effect where the ground is only lit where to camera’s looking at.

Here is my PG so far - I don’t know how to make to make the camera follow my mousemove

https://playground.babylonjs.com/#CQNGRK#547

scene.onBeforeRenderObservable.add(()=>{
        spotLight.position = camera.position;
		spotLight.setDirectionToTarget(camera.getFrontPosition(1))
    })
1 Like

Another approach is you could parent the spotLight to the camera, then you don’t need to use onBeforeRenderObservable

You probably need something other than ArcRotateCamera also, because torch light for that is still going to point at the one place.

https://playground.babylonjs.com/#CQNGRK#549

1 Like