SpotLight - intensity parameter doesnt work

Hello,

I’m doing my first steps with three.js and I’m playing around with the following code:

   var scene = new THREE.Scene();
   var camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 1000);
   var renderer = new THREE.WebGLRenderer();
	
   renderer.setClearColor(0xEEEEEE);
   renderer.setSize(window.innerWidth, window.innerHeight);
   renderer.shadowMap.enabled=true;
   renderer.shadowMap.type=THREE.PCFSoftShadowMap;

   // Adding a plane (phong-material
   // Adding a cube (phong-material)
   // adding a sphere (phong material)

   var spotLight = new THREE.SpotLight({color: 0x800000, intensity:0.0} );
  
   spotLight.position.set( 40, 60, 10);
   spotLight.castShadow=true;      
   spotLight.shadow.mapSize.width=1024;
   spotLight.shadow.mapSize.height=1024;       
   scene.add( spotLight );

I get stuck with the intensity parameter. No matter what I try, it doesn’t have any effect on the scene.
I have tried with this parameter stand alone or together with the color parameter.

Maybe the intensity have some effect when used with other parameters. But I can’t read anything in the documentation…

Maybe someone can help ?
Thanks in advance!

Greetings,
Andy

The constructor of THREE.SpotLight() takes several separated parameters, not an object with several properties.
So, try

var spotLight = new THREE.SpotLight( 0x800000, 0.5 );

https://jsfiddle.net/prisoner849/7ybfhjap/

1 Like

Hi,

thank you, that helped.
Guess I have to study javascript “a bit” to get the basics right.

Greetings,
Andy

You’re welcome :slight_smile: