Hi, I’m trying to set up the spotlights, but target always directs to (0,0,0).
- spotLight.target = object;
- spotLight.lookAt( object.position ); ← this direct to weired point(not expected direction)
and also I’ve tried
scene.add( spotLight );
scene.add( spotLight.target );
but it didn’t work…
I would appreciate if anyone had any solution.
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( spotLight.target ); // add target to the scene
// Add this to add a SpotLightHelper
spotLightHelper = new THREE.SpotLightHelper(spotLight, 0XFF00FF)
spotLight.target.position.z = Math.cos( time );
// Add this in animate() to make sure it animates.
if (spotLightHelper) spotLightHelper.update();