UNPKG

@animech-public/playcanvas

Version:
2 lines (1 loc) 1.45 kB
import{QuadRender as t}from"./quad-render.js";import{BlendState as e}from"../../platform/graphics/blend-state.js";import{CULLFACE_NONE as s,SEMANTIC_POSITION as r}from"../../platform/graphics/constants.js";import{DepthState as i}from"../../platform/graphics/depth-state.js";import{RenderPass as a}from"../../platform/graphics/render-pass.js";import{createShaderFromCode as n}from"../shader-lib/utils.js";class d extends a{constructor(...t){super(...t),this._shader=null,this.quadRender=null,this.cullMode=s,this.blendState=e.NOBLEND,this.depthState=i.NODEPTH,this.stencilFront=null,this.stencilBack=null}set shader(e){var s,r;null==(s=this.quadRender)||s.destroy(),this.quadRender=null,null==(r=this._shader)||r.destroy(),this._shader=e,e&&(this.quadRender=new t(e))}get shader(){return this._shader}createQuadShader(t,e,s={}){return n(this.device,d.quadVertexShader,e,t,{aPosition:r},s)}destroy(){var t;null==(t=this.shader)||t.destroy(),this.shader=null}execute(){const t=this.device;t.setBlendState(this.blendState),t.setCullMode(this.cullMode),t.setDepthState(this.depthState),t.setStencilState(this.stencilFront,this.stencilBack),this.quadRender.render()}}d.quadVertexShader="\n\t\t\t\tattribute vec2 aPosition;\n\t\t\t\tvarying vec2 uv0;\n\t\t\t\tvoid main(void)\n\t\t\t\t{\n\t\t\t\t\t\tgl_Position = vec4(aPosition, 0.0, 1.0);\n\t\t\t\t\t\tuv0 = getImageEffectUV((aPosition.xy + 1.0) * 0.5);\n\t\t\t\t}\n\t\t";export{d as RenderPassShaderQuad};