0

I'm trying to add a spotlight effect on different parts of my scene but for some reason I'm unable to accomplish it. I tried using PointLight and SpotLight but they both didn't work.

Example of the code

 var pointLight = new THREE.PointLight( 0xffffff, 1, 10 );
 pointLight.position.set(obj.position);
 scene.add( pointLight );

The light effect doesn't need to follow the mouse movement. It just needs to appear after specific event trigger.

I'm not sure if the spotLight or the pointLight is the right way to do this. I appreciate any feedback on what approach I should take and what is the best way to accomplish this animation.

Attempted adding SpotLight like so

var spotLight = new THREE.SpotLight(  0xffffff );
spotLight.position.set( 0, 0, 0 );

spotLight.shadow.mapSize.width = 512;
spotLight.shadow.mapSize.height = 512;
spotLight.target = obj;
spotLight.intensity = 2;
scene.add( spotLight );

var spotLightHelper = new THREE.SpotLightHelper( spotLight );
scene.add( spotLightHelper );

Animation example

Jir
  • 113
  • 1
  • 1
  • 8
  • Are you searching for [`SpotLight`](https://threejs.org/docs/#api/en/lights/SpotLight)? – Rabbid76 Feb 29 '20 at 11:23
  • I'm looking for something that would accomplish the animation in the gif. My first thought was to use `SpotLight` or `PointLight` but they both didn't work. – Jir Mar 01 '20 at 21:40
  • What have you tired so far. Of course you can't just switch on a spot light. You have to animate the light intensity and the light cone. – Rabbid76 Mar 01 '20 at 21:56
  • I started by just adding the `SpotLight` to the scene and that didn't work. I added the code to the original post. – Jir Mar 02 '20 at 04:11
  • The SpotLight code I added to the question portion. – Jir Mar 02 '20 at 05:47
  • I've seen that. But what "did not work"? "Did not work" is not a technical description of an issue. – Rabbid76 Mar 02 '20 at 05:48
  • I mean that the SpotLight didn't even show up on my scene. – Jir Mar 02 '20 at 05:50

0 Answers0