{"record":{"id":"d0dcd06403affe0a","repo":"BabylonJS/Babylon.js","slug":"framegraphlightingvolumetask-this-name-light-m","errorCode":null,"errorMessage":"FrameGraphLightingVolumeTask ${this.name}: light must be a directional light","messagePattern":"FrameGraphLightingVolumeTask (.+?): light must be a directional light","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/FrameGraph/Tasks/Misc/lightingVolumeTask.ts","lineNumber":73,"sourceCode":"        if (isReady) {\r\n            this.lightingVolume._setComputeShaderFastMode(true);\r\n        }\r\n        return isReady;\r\n    }\r\n\r\n    public override getClassName(): string {\r\n        return \"FrameGraphLightingVolumeTask\";\r\n    }\r\n\r\n    public record() {\r\n        if (this.shadowGenerator === undefined) {\r\n            throw new Error(`FrameGraphLightingVolumeTask ${this.name}: shadowGenerator is required`);\r\n        }\r\n\r\n        const light = this.shadowGenerator.light;\r\n\r\n        if (!(light instanceof DirectionalLight)) {\r\n            throw new Error(`FrameGraphLightingVolumeTask ${this.name}: light must be a directional light`);\r\n        }\r\n\r\n        this.lightingVolume.shadowGenerator = this.shadowGenerator.shadowGenerator;\r\n\r\n        const pass = this._frameGraph.addObjectListPass(this.name);\r\n\r\n        pass.setObjectList(this.outputMeshLightingVolume);\r\n        pass.setExecuteFunc(() => {\r\n            this.lightingVolume.update();\r\n        });\r\n\r\n        const passDisabled = this._frameGraph.addObjectListPass(this.name + \"_disabled\", true);\r\n\r\n        passDisabled.setObjectList(this.outputMeshLightingVolume);\r\n        passDisabled.setExecuteFunc(() => {});\r\n    }\r\n\r\n    public override dispose() {\r","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/FrameGraph/Tasks/Misc/lightingVolumeTask.ts#L55-L91","documentation":"After requiring a shadow generator, FrameGraphLightingVolumeTask validates that shadowGenerator.light is an instance of DirectionalLight. Lighting volumes are only implemented for directional lights, so any other light type (point, spot, etc.) makes the task throw during record().","triggerScenarios":"lightingVolumeTask.record() where task.shadowGenerator is set, but the underlying shadowGenerator.light is a PointLight, SpotLight, or other non-directional light.","commonSituations":"Attaching a lighting volume to a scene lit by spot or point light shadow generators; changing the scene's light type from directional to spot after the task was configured.","solutions":["Use a DirectionalLight with a directional shadow generator for the lighting volume.","Remove or disable the lighting volume task for non-directional lights.","Check light instanceof DirectionalLight in scene setup code before wiring the task."],"exampleFix":"// before\nconst light = new BABYLON.SpotLight(\"spot\", pos, dir, 1.2, 8, scene);\n// after\nconst light = new BABYLON.DirectionalLight(\"dir\", dir, scene);\nlvTask.shadowGenerator = shadowGenTask.output;","handlingStrategy":"validation","validationCode":"if (!(lightingVolumeTask.shadowGenerator?.light instanceof BABYLON.DirectionalLight)) {\n  throw new Error(\"LightingVolumeTask only supports directional lights\");\n}","typeGuard":"function isDirectionalLight(light: unknown): light is BABYLON.DirectionalLight {\n  return light instanceof BABYLON.DirectionalLight;\n}","tryCatchPattern":"try {\n  lightingVolumeTask.record();\n} catch (e) {\n  if (String(e).includes(\"directional light\")) {\n    console.error(\"Replace the scene light with a DirectionalLight or remove the lighting volume task\");\n  } else throw e;\n}","preventionTips":["Check the light type at scene setup when you plan to use lighting volumes.","Document that lighting volumes require directional lights.","Guard the lighting-volume graph branch behind a light-type check."],"tags":["frame-graph","lighting","type-mismatch","validation"],"backgroundTag":"unsupported-light-type","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}