UNPKG

playcanvas

Version:

Open-source WebGL/WebGPU 3D engine for the web

36 lines (35 loc) 1.13 kB
import { RenderPass } from "../../platform/graphics/render-pass.js"; import { SHADER_FORWARD } from "../../scene/constants.js"; class RenderPassLightmapper extends RenderPass { viewBindGroups = []; constructor(device, renderer, camera, worldClusters, receivers, lightArray) { super(device); this.renderer = renderer; this.camera = camera; this.worldClusters = worldClusters; this.receivers = receivers; this.lightArray = lightArray; } destroy() { this.viewBindGroups.forEach((bg) => { bg.defaultUniformBuffer.destroy(); bg.destroy(); }); this.viewBindGroups.length = 0; } execute() { const device = this.device; const { renderer, camera, receivers, renderTarget, worldClusters, lightArray } = this; if (device.supportsUniformBuffers && !renderer.viewUniformFormat) { renderer.initViewBindGroupFormat(renderer.scene.clusteredLightingEnabled); } renderer.renderForwardLayer(camera, renderTarget, null, void 0, SHADER_FORWARD, this.viewBindGroups, { meshInstances: receivers, splitLights: lightArray, lightClusters: worldClusters }); } } export { RenderPassLightmapper };