Closed tunghsingw closed 1 year ago
Add a DirectLight and a SpotLight to scene. when DirectLight is disabled, the SpotLight will disabled too。 (DirectLight is red color,SpotLight is blue color。)
all light enable:
DirectLight disable, SpotLight is enable
engine version 0.5.0
chrome 114.0.5696.0 (Official Build) canary (64-bit)
this is all code:
Engine3D.setting.shadow.enable = true; await Engine3D.init({}); GUIHelp.init(); let scene = new Scene3D(); let cameraObj = new Object3D(); cameraObj.name = `cameraObj`; let mainCamera = cameraObj.addComponent(Camera3D); mainCamera.perspective(60, webGPUContext.aspect, 1, 5000.0); let hoverCameraController = mainCamera.object3D.addComponent(HoverCameraController); scene.addChild(cameraObj); //set camera data hoverCameraController.setCamera(0, -45, 1000, new Vector3(0, 50, 0)); { let obj = new Object3D(); obj.localPosition = new Vector3(0, 0, 0); obj.localRotation = new Vector3(135, 45, 0); let lt: DirectLight = obj.addComponent(DirectLight); lt.castShadow = true; lt.intensity = 50; lt.lightColor = Color.COLOR_RED; let mr = obj.addComponent(MeshRenderer); mr.castShadow = true; mr.geometry = new SphereGeometry(30, 30, 30); let mat = new UnLitMaterial(); mat.baseColor = Color.COLOR_RED; mr.material = mat; scene.addChild(obj); lt.debug(); GUIHelp.addButton("direct enable switch", () => lt.enable = !lt.enable) } { let obj = new Object3D(); obj.localPosition = new Vector3(100, 130, 100); obj.localRotation = new Vector3(135, 100, 0); let lt: SpotLight = obj.addComponent(SpotLight); lt.castShadow = true; lt.intensity = 100; lt.at = 4; lt.radius = 10; lt.range = 500; lt.lightColor = Color.COLOR_BLUE; let mr = obj.addComponent(MeshRenderer); mr.castShadow = true; mr.geometry = new SphereGeometry(30, 30, 30); let mat = new UnLitMaterial(); mat.baseColor = Color.COLOR_BLUE; mr.material = mat; scene.addChild(obj); lt.debug(); GUIHelp.addButton("spot enable switch", () => lt.enable = !lt.enable) } // floor { let mat = new LitMaterial(); mat.baseMap = defaultTexture.grayTexture; let floor = new Object3D(); let mr = floor.addComponent(MeshRenderer); mr.geometry = new BoxGeometry(2000, 1, 2000); mr.material = mat; scene.addChild(floor); } let renderJob = new ForwardRenderJob(scene); Engine3D.startRender(renderJob);
Thank you. Let's investigate this issue ourselves
This bug is already being fixed #82
Add a DirectLight and a SpotLight to scene. when DirectLight is disabled, the SpotLight will disabled too。 (DirectLight is red color,SpotLight is blue color。)
all light enable:![image](https://user-images.githubusercontent.com/22024979/230306736-b53aa3aa-cf20-4893-992d-6727e5f4e8fd.png)
DirectLight disable, SpotLight is enable![image](https://user-images.githubusercontent.com/22024979/230306642-a8248d62-951e-4e62-bd3d-eea362f7d71b.png)
engine version 0.5.0
chrome 114.0.5696.0 (Official Build) canary (64-bit)
this is all code: