UNPKG

playcanvas

Version:

PlayCanvas WebGL game engine

33 lines (30 loc) 1.16 kB
import { QuadRender } from './quad-render.js'; import { BlendState } from '../../platform/graphics/blend-state.js'; import { CULLFACE_NONE } from '../../platform/graphics/constants.js'; import { DepthState } from '../../platform/graphics/depth-state.js'; import { RenderPass } from '../../platform/graphics/render-pass.js'; class RenderPassShaderQuad extends RenderPass { set shader(shader) { this.quadRender?.destroy(); this.quadRender = null; this._shader = shader; if (shader) { this.quadRender = new QuadRender(shader); } } get shader() { return this._shader; } execute() { const device = this.device; device.setBlendState(this.blendState); device.setCullMode(this.cullMode); device.setDepthState(this.depthState); device.setStencilState(this.stencilFront, this.stencilBack); this.quadRender.render(); } constructor(...args){ super(...args), this._shader = null, this.quadRender = null, this.cullMode = CULLFACE_NONE, this.blendState = BlendState.NOBLEND, this.depthState = DepthState.NODEPTH, this.stencilFront = null, this.stencilBack = null; } } export { RenderPassShaderQuad };