【发布时间】:2020-09-05 18:23:01
【问题描述】:
我在设置灯光对象名称 light.name = 'globalLight' 并制作变量 lightGlobal = scene.getObjectByName('globalLight'); 时遇到了问题,但是当我尝试使用 lightGlobal.visible = false; 隐藏时,只是让其他灯没有隐藏绿色的是light0,蓝色的是light1 渲染示例The rendered image example
问题screenshot
如您所见,蓝光消失了,但绿光不会隐藏
我的代码:
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;
【问题讨论】:
标签: javascript debugging three.js rendering