For a course I need to develop a simple game using Three.js. I make the following array of spotlights:
let spotlights = [];
for (let i = 0; i < 5; i++) {
const obj = room[spot];
let sl = new THREE.SpotLight();
sl.intensity = obj.intensity;
sl.decay = obj.decay;
sl.distance = obj.distance;
sl.penumbra = obj.penumbra;
sl.castShadow = true;
sl.shadow.mapSize.width = 1024;
sl.shadow.mapSize.height = 1024;
sl.receiveShadow = true;
scene.add(sl);
spotlights.push(sl);
}
When i print the array “spotlights” in the console i get the following:
How do i access these objects? When i try spotlights[0]
it gives back undefined.