Spotlight can't set target correctly

Hi, I’m trying to set up the spotlights, but target always directs to (0,0,0).
I’ve tried

  • = object;
  • spotLight.lookAt( object.position ); ← this direct to weired point(not expected direction)

and also I’ve tried

scene.add( spotLight );
scene.add( );

but it didn’t work…
I would appreciate if anyone had any solution.

1 Like

Try it with this basic template:

Also see:


It works!!! Thank you sooooo much Mugen87 !!!

If anyone wants to see the spotlight animate with the spotlight helper, you can make the following changes to @Mugen87 's jsfiddle.

// Add this at the end to declare `spotLightHelper`
let camera, scene, renderer, clock, spotLight, spotLightHelper;



	scene.add( ); // add target to the scene

// Add this to add a SpotLightHelper
	spotLightHelper = new THREE.SpotLightHelper(spotLight, 0XFF00FF)

... = Math.cos( time );
// Add this in animate() to make sure it animates.
    if (spotLightHelper) spotLightHelper.update();