I was running into a problem when I was setting my light objects name light.name = 'globalLight'
and im making variable that is lightGlobal = scene.getObjectByName('globalLight');
but when i tried to hide using lightGlobal.visible = false;
it was just let the other light wasn’t hide the green one Is light0
and the blue one is light1
render example
The problem screenshot
As you can see the blue light is gone but the green one won’t hide
My code :
ambient = new THREE.AmbientLight( 0x404040 );
scene.add( ambient );
lightCam = new THREE.DirectionalLight( 0xffffff, 1.0 );
light0 = new THREE.PointLight( 0x0000ff, 1.0 );
light0.position.set( 4.0, 4.0, 4.0 );
light0.castShadow = true;
light0.name = "globalLight";
light1 = new THREE.PointLight( 0x00ff00, 1.0 );
light1.position.set( 4.0, 4.0, -4.0 );
light1.castShadow = true;
light1.name = "globalLight";
scene.add( light0, light1 );
globalLight = scene.getObjectByName( "globalLight", true );
globalLight.visible = false;