UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

63 lines 2.31 kB
import { LightingVolume } from "../../../Lights/lightingVolume.js"; import { DirectionalLight } from "../../../Lights/directionalLight.js"; import { FrameGraphTask } from "../../frameGraphTask.js"; /** * Task used to create a lighting volume from a directional light's shadow generator. */ export class FrameGraphLightingVolumeTask extends FrameGraphTask { get name() { return this._name; } set name(name) { this._name = name; if (this.lightingVolume) { this.lightingVolume.name = name; } } /** * Creates a new FrameGraphLightingVolumeTask. * @param name Name of the task. * @param frameGraph The frame graph instance. */ constructor(name, frameGraph) { super(name, frameGraph); this.lightingVolume = new LightingVolume(name, frameGraph.scene); this.outputMeshLightingVolume = { meshes: [this.lightingVolume.mesh], particleSystems: [], }; } isReady() { const isReady = this.lightingVolume.isReady(); if (isReady) { this.lightingVolume._setComputeShaderFastMode(true); } return isReady; } getClassName() { return "FrameGraphLightingVolumeTask"; } record() { if (this.shadowGenerator === undefined) { throw new Error(`FrameGraphLightingVolumeTask ${this.name}: shadowGenerator is required`); } const light = this.shadowGenerator.light; if (!(light instanceof DirectionalLight)) { throw new Error(`FrameGraphLightingVolumeTask ${this.name}: light must be a directional light`); } this.lightingVolume.shadowGenerator = this.shadowGenerator.shadowGenerator; const pass = this._frameGraph.addObjectListPass(this.name); pass.setObjectList(this.outputMeshLightingVolume); pass.setExecuteFunc(() => { this.lightingVolume.update(); }); const passDisabled = this._frameGraph.addObjectListPass(this.name + "_disabled", true); passDisabled.setObjectList(this.outputMeshLightingVolume); passDisabled.setExecuteFunc(() => { }); } dispose() { super.dispose(); this.lightingVolume.dispose(); } } //# sourceMappingURL=lightingVolumeTask.js.map