playcanvas
Version:
Open-source WebGL/WebGPU 3D engine for the web
29 lines (26 loc) • 1.15 kB
JavaScript
import { QuadRender } from './quad-render.js';
import { BlendState } from '../../platform/graphics/blend-state.js';
import { CULLFACE_NONE, FRONTFACE_CCW } 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() {
this.device.setDrawStates(this.blendState, this.depthState, this.cullMode, this.frontFace, this.stencilFront, this.stencilBack);
this.quadRender?.render(this.viewport, this.scissor);
}
constructor(...args){
super(...args), this._shader = null, this.quadRender = null, this.cullMode = CULLFACE_NONE, this.frontFace = FRONTFACE_CCW, this.blendState = BlendState.NOBLEND, this.depthState = DepthState.NODEPTH, this.stencilFront = null, this.stencilBack = null;
}
}
export { RenderPassShaderQuad };