Orillusion / orillusion

Orillusion is a pure Web3D rendering engine which is fully developed based on the WebGPU standard.
https://www.orillusion.com
MIT License
4.7k stars 614 forks source link

Light switch bug #10

Closed tunghsingw closed 1 year ago

tunghsingw commented 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: image

DirectLight disable, SpotLight is enable image

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);
X-OldGentleMan commented 1 year ago

Thank you. Let's investigate this issue ourselves

X-OldGentleMan commented 1 year ago

This bug is already being fixed #82