Initialization code:
var lightTrig = false;
var pointLight = new THREE.PointLight(0xffffff, 1, 10);
pointLight.position.copy(initialPos);
pointLight.visible = false; // THIS LINE
scene.add(pointLight);
and in my event handler, I toggle the visible attribute
function keyDown(e) {
switch(e.keyCode) {
// some code...
case 76: // l
lightTrig = !lightTrig;
pointLight.visible = lightTrig;
break;
// some other code...
}
}
If I comment “THIS LINE” everything goes as expected (in fact, I need to tap L key on keyboard twice to synchronize pointLight.visible with lightTrig since the lightTrig is initialized to false. )
But if “THIS LINE” is not commented i.e. pointLight.visible is initialized to false, pointLight will never illuminate the scene no matter how many times I tap the L key.
I assume that other part of my code is correct because it will work as long as “THIS LINE” is commented. However, I need the pointLight.visible to be false in the begining state so the user can turn on the light (by tapping L key). Is there anybody who knows what happened when I set visible attribute of pointLight to false before rendering ?
PS: same thing happens when I use SpotLight.
PPS: Sorry for my bad English!
@zwcloud The issue was addressed by 1cdc095, so apparently, it has.