xxscreeps-mod-client 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +15 -0
- package/dist/assets/{BufferResource-wp05kXJi.js → BufferResource-CE78HmbQ.js} +1 -1
- package/dist/assets/{CanvasRenderer-oAjr4VPy.js → CanvasRenderer-BH4PjMGX.js} +1 -1
- package/dist/assets/{Filter-DCFwFDCZ.js → Filter-ZZPoYeTC.js} +1 -1
- package/dist/assets/{RenderTargetSystem-BADEJjVe.js → RenderTargetSystem-EVgeaEAK.js} +1 -1
- package/dist/assets/{WebGLRenderer-CkUVdJjj.js → WebGLRenderer-DDvszQ53.js} +1 -1
- package/dist/assets/{WebGPURenderer-CDYm-Qve.js → WebGPURenderer-UUnYdUOg.js} +1 -1
- package/dist/assets/{browserAll-DRs0HlcT.js → browserAll-CppuWcbH.js} +1 -1
- package/dist/assets/{canvasUtils--etq-uaC.js → canvasUtils-Dmy9CrII.js} +1 -1
- package/dist/assets/{index-Cf0rVPz-.js → index-CINA8e_Z.js} +50 -50
- package/dist/assets/{webworkerAll-Bs2LlyVn.js → webworkerAll-D7azZfkM.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-2026 Bastian Hoyer
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
15
|
+
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ap as U,a9 as g,S as c,an as S,d as _,e as m,E as I,am as h}from"./index-
|
|
1
|
+
import{ap as U,a9 as g,S as c,an as S,d as _,e as m,E as I,am as h}from"./index-CINA8e_Z.js";const x={name:"local-uniform-bit",vertex:{header:`
|
|
2
2
|
|
|
3
3
|
struct LocalUniforms {
|
|
4
4
|
uTransformMatrix:mat3x3<f32>,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{af as Se,W as Me,ah as ae,M as U,k as R,r as Ve,ap as Xe,al as we,X as Ie,h as Re,T as Ae,a8 as $e,F as Je,l as Ke,g as Qe,D as Be,A as ze,u as Ze,a4 as re}from"./index-Cf0rVPz-.js";import{b as et,c as tt,a as st,B as nt,d as at,R as ot,A as rt,C as it}from"./RenderTargetSystem-BADEJjVe.js";import{a as P,c as ct}from"./canvasUtils--etq-uaC.js";import"./Filter-DCFwFDCZ.js";const ge=class ${static _getPatternRepeat(e,t){const s=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return s&&n?"repeat":s?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,s){}execute(e,t){var i,c,u,m;const s=t.elements;if(!s||!s.length)return;const n=e.renderer,o=n.canvasContext,r=o.activeContext;for(let x=0;x<s.length;x++){const G=s[x];if(!G.packAsQuad)continue;const y=G,f=y.texture,S=f?P.getCanvasSource(f):null;if(!S)continue;const v=f.source.style,A=o.smoothProperty,Y=v.scaleMode!=="nearest";r[A]!==Y&&(r[A]=Y),o.setBlendMode(t.blendMode);const q=((i=n.globalUniforms.globalUniformData)==null?void 0:i.worldColor)??4294967295,E=y.color,k=(q>>>24&255)/255,C=(E>>>24&255)/255,V=((c=n.filter)==null?void 0:c.alphaMultiplier)??1,z=k*C*V;if(z<=0)continue;r.globalAlpha=z;const Z=q&16777215,J=E&16777215,b=Me(ae(J,Z)),M=f.frame,w=v.addressModeU??v.addressMode,ie=v.addressModeV??v.addressMode,ee=$._getPatternRepeat(w,ie),D=f.source._resolution??f.source.resolution??1,X=(m=(u=y.renderable)==null?void 0:u.renderGroup)==null?void 0:m.isCachedAsTexture,d=M.x*D,p=M.y*D,g=M.width*D,L=M.height*D,I=y.bounds,_=n.renderTarget.renderTarget.isRoot,W=I.minX,F=I.minY,B=I.maxX-I.minX,H=I.maxY-I.minY,O=f.rotate,l=f.uvs,N=Math.min(l.x0,l.x1,l.x2,l.x3,l.y0,l.y1,l.y2,l.y3),j=Math.max(l.x0,l.x1,l.x2,l.x3,l.y0,l.y1,l.y2,l.y3),T=ee!=="no-repeat"&&(N<0||j>1),ce=O&&!(!T&&(b!==16777215||O));ce?($._tempPatternMatrix.copyFrom(y.transform),Se.matrixAppendRotationInv($._tempPatternMatrix,O,W,F,B,H),o.setContextTransform($._tempPatternMatrix,y.roundPixels===1,void 0,X&&_)):o.setContextTransform(y.transform,y.roundPixels===1,void 0,X&&_);const te=ce?0:W,se=ce?0:F,le=B,he=H;if(T){let de=S;const K=b!==16777215&&!O,Q=M.width<=f.source.width&&M.height<=f.source.height;K&&Q&&(de=P.getTintedCanvas({texture:f},b));const pe=r.createPattern(de,ee);if(!pe)continue;const ye=le,xe=he;if(ye===0||xe===0)continue;const Ce=1/ye,Te=1/xe,Pe=(l.x1-l.x0)*Ce,ke=(l.y1-l.y0)*Ce,be=(l.x3-l.x0)*Te,_e=(l.y3-l.y0)*Te,je=l.x0-Pe*te-be*se,Ye=l.y0-ke*te-_e*se,ue=f.source.pixelWidth,me=f.source.pixelHeight;$._tempPatternMatrix.set(Pe*ue,ke*me,be*ue,_e*me,je*ue,Ye*me),P.applyPatternTransform(pe,$._tempPatternMatrix),r.fillStyle=pe,r.fillRect(te,se,le,he)}else{const K=b!==16777215||O?P.getTintedCanvas({texture:f},b):S,Q=K!==S;r.drawImage(K,Q?0:d,Q?0:p,Q?K.width:g,Q?K.height:L,te,se,le,he)}}}};ge._tempPatternMatrix=new U;ge.extension={type:[R.CanvasPipesAdaptor],name:"batch"};let lt=ge;class He{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}He.extension={type:[R.CanvasPipes],name:"colorMask"};function ht(a,e,t,s,n,o){o=Math.max(0,Math.min(o,Math.min(s,n)/2)),a.moveTo(e+o,t),a.lineTo(e+s-o,t),a.quadraticCurveTo(e+s,t,e+s,t+o),a.lineTo(e+s,t+n-o),a.quadraticCurveTo(e+s,t+n,e+s-o,t+n),a.lineTo(e+o,t+n),a.quadraticCurveTo(e,t+n,e,t+n-o),a.lineTo(e,t+o),a.quadraticCurveTo(e,t,e+o,t)}function Ge(a,e){switch(e.type){case"rectangle":{const t=e;a.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;ht(a,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;a.moveTo(t.x+t.radius,t.y),a.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;a.ellipse?(a.moveTo(t.x+t.halfWidth,t.y),a.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(a.save(),a.translate(t.x,t.y),a.scale(t.halfWidth,t.halfHeight),a.moveTo(1,0),a.arc(0,0,1,0,Math.PI*2),a.restore());break}case"triangle":{const t=e;a.moveTo(t.x,t.y),a.lineTo(t.x2,t.y2),a.lineTo(t.x3,t.y3),a.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!(s!=null&&s.length))break;a.moveTo(s[0],s[1]);for(let n=2;n<s.length;n+=2)a.lineTo(s[n],s[n+1]);t.closePath&&a.closePath();break}}}function dt(a,e,t){const s=[],n=[],o=[],r=we[e.type];if(!(r!=null&&r.build(e,s)))return!1;const i=e.closePath??!0;Ie(s,t,!1,i,n,o);for(let c=0;c<o.length;c+=3){const u=o[c]*2,m=o[c+1]*2,x=o[c+2]*2;a.moveTo(n[u],n[u+1]),a.lineTo(n[m],n[m+1]),a.lineTo(n[x],n[x+1]),a.closePath()}return!0}function pt(a,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!(s!=null&&s.shape))continue;const n=s.transform,o=n&&!n.isIdentity();o&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ge(a,s.shape),o&&a.restore()}return!0}class Ee{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var m,x,G;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,s=t.canvasContext,n=s==null?void 0:s.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const o=e.mask.mask;if(!(o instanceof Ve)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=o,i=(m=r.context)==null?void 0:m.instructions;if(!(i!=null&&i.length)){this._canvasMaskStack.push(!1);return}n.save(),s.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,u=!1;for(let y=0;y<i.length;y++){const f=i[y],S=f.action;if(S!=="fill"&&S!=="stroke")continue;const v=f.data,A=(x=v==null?void 0:v.path)==null?void 0:x.shapePath;if(!((G=A==null?void 0:A.shapePrimitives)!=null&&G.length))continue;const Y=S==="stroke",q=A.shapePrimitives;for(let E=0;E<q.length;E++){const k=q[E];if(!(k!=null&&k.shape))continue;const C=k.transform,V=C&&!C.isIdentity();V&&(n.save(),n.transform(C.a,C.b,C.c,C.d,C.tx,C.ty)),Y&&v.style?c=dt(n,k.shape,v.style)||c:(Ge(n,k.shape),u=pt(n,k.holes)||u,c=!0),V&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}u?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),Xe(t))}}Ee.extension={type:[R.CanvasPipes],name:"stencilMask"};const h="source-over";function ut(){const a=ct(),e=Object.create(null);return e.inherit=h,e.none=h,e.normal="source-over",e.add="lighter",e.multiply=a?"multiply":h,e.screen=a?"screen":h,e.overlay=a?"overlay":h,e.darken=a?"darken":h,e.lighten=a?"lighten":h,e["color-dodge"]=a?"color-dodge":h,e["color-burn"]=a?"color-burn":h,e["hard-light"]=a?"hard-light":h,e["soft-light"]=a?"soft-light":h,e.difference=a?"difference":h,e.exclusion=a?"exclusion":h,e.saturation=a?"saturation":h,e.color=a?"color":h,e.luminosity=a?"luminosity":h,e["linear-burn"]=a?"color-burn":h,e["linear-dodge"]=a?"color-dodge":h,e["linear-light"]=a?"hard-light":h,e["pin-light"]=a?"hard-light":h,e["vivid-light"]=a?"hard-light":h,e["hard-mix"]=h,e.negation=a?"difference":h,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=h,e.divide=h,e.min=h,e.max=h,e}const mt=new U;class We{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=ut(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,s,n){var u;const o=n?U.IDENTITY:((u=this._renderer.globalUniforms.globalUniformData)==null?void 0:u.worldTransformMatrix)||U.IDENTITY;let r=mt;r.copyFrom(o),r.append(e);const i=this._projTransform,c=this.activeResolution;if(s=s||c,i){const m=U.shared;m.copyFrom(r),m.prepend(i),r=m}t?this.activeContext.setTransform(r.a*s,r.b*s,r.c*s,r.d*s,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*s,r.b*s,r.c*s,r.d*s,r.tx*c,r.ty*c)}clear(e,t){const s=this.activeContext,n=this._renderer;if(s.clearRect(0,0,n.width,n.height),e){const o=Re.shared.setValue(e);s.globalAlpha=t??o.alpha,s.fillStyle=o.toHex(),s.fillRect(0,0,n.width,n.height),s.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}We.extension={type:[R.CanvasSystem],name:"canvasContext"};class Fe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Fe.extension={type:[R.CanvasSystem],name:"limits"};const ft="#808080",ne=new U,gt=new U,vt=new U,fe=new U;function yt(a,e,t){a.beginPath();for(let s=0;s<t.length;s+=3){const n=t[s]*2,o=t[s+1]*2,r=t[s+2]*2;a.moveTo(e[n],e[n+1]),a.lineTo(e[o],e[o+1]),a.lineTo(e[r],e[r+1]),a.closePath()}a.fill()}function xt(a){return`#${(a&16777215).toString(16).padStart(6,"0")}`}function Ct(a,e,t,s,n,o){o=Math.max(0,Math.min(o,Math.min(s,n)/2)),a.moveTo(e+o,t),a.lineTo(e+s-o,t),a.quadraticCurveTo(e+s,t,e+s,t+o),a.lineTo(e+s,t+n-o),a.quadraticCurveTo(e+s,t+n,e+s-o,t+n),a.lineTo(e+o,t+n),a.quadraticCurveTo(e,t+n,e,t+n-o),a.lineTo(e,t+o),a.quadraticCurveTo(e,t,e+o,t)}function oe(a,e){switch(e.type){case"rectangle":{const t=e;a.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Ct(a,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;a.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;a.ellipse?a.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(a.save(),a.translate(t.x,t.y),a.scale(t.halfWidth,t.halfHeight),a.arc(0,0,1,0,Math.PI*2),a.restore());break}case"triangle":{const t=e;a.moveTo(t.x,t.y),a.lineTo(t.x2,t.y2),a.lineTo(t.x3,t.y3),a.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!(s!=null&&s.length))break;a.moveTo(s[0],s[1]);for(let n=2;n<s.length;n+=2)a.lineTo(s[n],s[n+1]);t.closePath&&a.closePath();break}}}function Tt(a,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!(s!=null&&s.shape))continue;const n=s.transform,o=n&&!n.isIdentity();o&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),oe(a,s.shape),o&&a.restore()}return!0}function Pt(a,e,t,s){const n=a.fill;if(n instanceof Je){n.buildGradient();const r=n.texture;if(r){const i=P.getTintedPattern(r,e),c=t?fe.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):fe.copyFrom(n.transform);return s&&!a.textureSpace&&c.append(s),P.applyPatternTransform(i,c),i}}if(n instanceof Ke){const r=P.getTintedPattern(n.texture,e);return P.applyPatternTransform(r,n.transform),r}const o=a.texture;if(o&&o!==Ae.WHITE){if(!o.source.resource)return ft;const r=P.getTintedPattern(o,e),i=t?fe.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):a.matrix;return P.applyPatternTransform(r,i),r}return xt(e)}class Ue{constructor(){this.shader=null}contextChange(e){}execute(e,t){var Y,q,E,k,C,V,z;const s=e.renderer,n=s.canvasContext,o=n.activeContext,r=t.groupTransform,i=((Y=s.globalUniforms.globalUniformData)==null?void 0:Y.worldColor)??4294967295,c=t.groupColorAlpha,u=(i>>>24&255)/255,m=(c>>>24&255)/255,x=((q=s.filter)==null?void 0:q.alphaMultiplier)??1,G=u*m*x;if(G<=0)return;const y=i&16777215,f=c&16777215,S=Me(ae(f,y)),v=s._roundPixels|t._roundPixels;o.save(),n.setContextTransform(r,v===1),n.setBlendMode(t.groupBlendMode);const A=t.context.instructions;for(let Z=0;Z<A.length;Z++){const J=A[Z];if(J.action==="texture"){const d=J.data,p=d.image,g=p?P.getCanvasSource(p):null;if(!g)continue;const L=d.alpha*G;if(L<=0)continue;const I=ae(d.style,S);o.globalAlpha=L;let _=g;I!==16777215&&(_=P.getTintedCanvas({texture:p},I));const W=p.frame,F=p.source._resolution??p.source.resolution??1;let B=W.x*F,H=W.y*F;const O=W.width*F,l=W.height*F;_!==g&&(B=0,H=0);const N=d.transform,j=N&&!N.isIdentity(),T=p.rotate;j||T?(ne.copyFrom(r),j&&ne.append(N),T&&Se.matrixAppendRotationInv(ne,T,d.dx,d.dy,d.dw,d.dh),n.setContextTransform(ne,v===1)):n.setContextTransform(r,v===1),o.drawImage(_,B,H,_===g?O:_.width,_===g?l:_.height,T?0:d.dx,T?0:d.dy,d.dw,d.dh),(j||T)&&n.setContextTransform(r,v===1);continue}const b=J.data,M=(E=b==null?void 0:b.path)==null?void 0:E.shapePath;if(!((k=M==null?void 0:M.shapePrimitives)!=null&&k.length))continue;const w=b.style,ie=ae(w.color,S),ee=w.alpha*G;if(ee<=0)continue;const D=J.action==="stroke";if(o.globalAlpha=ee,D){const d=w;o.lineWidth=d.width,o.lineCap=d.cap,o.lineJoin=d.join,o.miterLimit=d.miterLimit}const X=M.shapePrimitives;if(!D&&((z=(V=(C=b.hole)==null?void 0:C.shapePath)==null?void 0:V.shapePrimitives)!=null&&z.length)){const d=X[X.length-1];d.holes=b.hole.shapePath.shapePrimitives}for(let d=0;d<X.length;d++){const p=X[d];if(!(p!=null&&p.shape))continue;const g=p.transform,L=g&&!g.isIdentity(),I=w.texture&&w.texture!==Ae.WHITE,_=w.textureSpace==="global"?g:null,W=I?$e(gt,w,p.shape,_):null,F=L?vt.copyFrom(r).append(g):r,B=Pt(w,ie,W,F);if(L&&(o.save(),o.transform(g.a,g.b,g.c,g.d,g.tx,g.ty)),D){const H=w;if(H.alignment!==.5&&!H.pixelLine){const l=[],N=[],j=[],T=we[p.shape.type];if(T!=null&&T.build(p.shape,l)){const ve=p.shape.closePath??!0;Ie(l,H,!1,ve,N,j),o.fillStyle=B,yt(o,N,j)}else o.strokeStyle=B,o.beginPath(),oe(o,p.shape),o.stroke()}else o.strokeStyle=B,o.beginPath(),oe(o,p.shape),o.stroke()}else o.fillStyle=B,o.beginPath(),oe(o,p.shape),Tt(o,p.holes)?o.fill("evenodd"):o.fill();L&&o.restore()}}o.restore()}destroy(){this.shader=null}}Ue.extension={type:[R.CanvasPipesAdaptor],name:"graphics"};class kt{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:s,context:n}=this._ensureCanvas(t);return{canvas:s,context:n,width:s.width,height:s.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:s}=this._ensureCanvas(t);s.width=e.pixelWidth,s.height=e.pixelHeight}startRenderPass(e,t,s,n){const o=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=o.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,s,n)}clear(e,t,s,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),s){const c=Re.shared.setValue(s);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,s,n,o){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:u}=this._ensureCanvas(c),m=(o==null?void 0:o.x)??0,x=(o==null?void 0:o.y)??0;return u.drawImage(i,s.x,s.y,n.width,n.height,m,x,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Qe.test(t))&&(t=Be.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const s=t.getContext("2d");return{canvas:t,context:s}}}class qe extends et{constructor(e){super(e),this.adaptor=new kt,this.adaptor.init(e,this)}}qe.extension={type:[R.CanvasSystem],name:"renderTarget"};class De{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=Be.get().createCanvas(),s=t.getContext("2d"),n=P.getCanvasSource(e);if(!n)return t;const o=e.frame,r=e.source._resolution??e.source.resolution??1,i=o.x*r,c=o.y*r,u=o.width*r,m=o.height*r;return t.width=Math.ceil(u),t.height=Math.ceil(m),s.drawImage(n,i,c,u,m,0,0,u,m),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}De.extension={type:[R.CanvasSystem],name:"texture"};const bt=[...tt,We,Fe,De,qe],_t=[st,nt,at,ot,rt,Ee,He,it],St=[lt,Ue],Le=[],Oe=[],Ne=[];re.handleByNamedList(R.CanvasSystem,Le);re.handleByNamedList(R.CanvasPipes,Oe);re.handleByNamedList(R.CanvasPipesAdaptor,Ne);re.add(...bt,..._t,...St);class At extends ze{constructor(){const e={name:"canvas",type:Ze.CANVAS,systems:Le,renderPipes:Oe,renderPipeAdaptors:Ne};super(e)}}export{At as CanvasRenderer};
|
|
1
|
+
import{af as Se,W as Me,ah as ae,M as U,k as R,r as Ve,ap as Xe,al as we,X as Ie,h as Re,T as Ae,a8 as $e,F as Je,l as Ke,g as Qe,D as Be,A as ze,u as Ze,a4 as re}from"./index-CINA8e_Z.js";import{b as et,c as tt,a as st,B as nt,d as at,R as ot,A as rt,C as it}from"./RenderTargetSystem-EVgeaEAK.js";import{a as P,c as ct}from"./canvasUtils-Dmy9CrII.js";import"./Filter-ZZPoYeTC.js";const ge=class ${static _getPatternRepeat(e,t){const s=e&&e!=="clamp-to-edge",n=t&&t!=="clamp-to-edge";return s&&n?"repeat":s?"repeat-x":n?"repeat-y":"no-repeat"}start(e,t,s){}execute(e,t){var i,c,u,m;const s=t.elements;if(!s||!s.length)return;const n=e.renderer,o=n.canvasContext,r=o.activeContext;for(let x=0;x<s.length;x++){const G=s[x];if(!G.packAsQuad)continue;const y=G,f=y.texture,S=f?P.getCanvasSource(f):null;if(!S)continue;const v=f.source.style,A=o.smoothProperty,Y=v.scaleMode!=="nearest";r[A]!==Y&&(r[A]=Y),o.setBlendMode(t.blendMode);const q=((i=n.globalUniforms.globalUniformData)==null?void 0:i.worldColor)??4294967295,E=y.color,k=(q>>>24&255)/255,C=(E>>>24&255)/255,V=((c=n.filter)==null?void 0:c.alphaMultiplier)??1,z=k*C*V;if(z<=0)continue;r.globalAlpha=z;const Z=q&16777215,J=E&16777215,b=Me(ae(J,Z)),M=f.frame,w=v.addressModeU??v.addressMode,ie=v.addressModeV??v.addressMode,ee=$._getPatternRepeat(w,ie),D=f.source._resolution??f.source.resolution??1,X=(m=(u=y.renderable)==null?void 0:u.renderGroup)==null?void 0:m.isCachedAsTexture,d=M.x*D,p=M.y*D,g=M.width*D,L=M.height*D,I=y.bounds,_=n.renderTarget.renderTarget.isRoot,W=I.minX,F=I.minY,B=I.maxX-I.minX,H=I.maxY-I.minY,O=f.rotate,l=f.uvs,N=Math.min(l.x0,l.x1,l.x2,l.x3,l.y0,l.y1,l.y2,l.y3),j=Math.max(l.x0,l.x1,l.x2,l.x3,l.y0,l.y1,l.y2,l.y3),T=ee!=="no-repeat"&&(N<0||j>1),ce=O&&!(!T&&(b!==16777215||O));ce?($._tempPatternMatrix.copyFrom(y.transform),Se.matrixAppendRotationInv($._tempPatternMatrix,O,W,F,B,H),o.setContextTransform($._tempPatternMatrix,y.roundPixels===1,void 0,X&&_)):o.setContextTransform(y.transform,y.roundPixels===1,void 0,X&&_);const te=ce?0:W,se=ce?0:F,le=B,he=H;if(T){let de=S;const K=b!==16777215&&!O,Q=M.width<=f.source.width&&M.height<=f.source.height;K&&Q&&(de=P.getTintedCanvas({texture:f},b));const pe=r.createPattern(de,ee);if(!pe)continue;const ye=le,xe=he;if(ye===0||xe===0)continue;const Ce=1/ye,Te=1/xe,Pe=(l.x1-l.x0)*Ce,ke=(l.y1-l.y0)*Ce,be=(l.x3-l.x0)*Te,_e=(l.y3-l.y0)*Te,je=l.x0-Pe*te-be*se,Ye=l.y0-ke*te-_e*se,ue=f.source.pixelWidth,me=f.source.pixelHeight;$._tempPatternMatrix.set(Pe*ue,ke*me,be*ue,_e*me,je*ue,Ye*me),P.applyPatternTransform(pe,$._tempPatternMatrix),r.fillStyle=pe,r.fillRect(te,se,le,he)}else{const K=b!==16777215||O?P.getTintedCanvas({texture:f},b):S,Q=K!==S;r.drawImage(K,Q?0:d,Q?0:p,Q?K.width:g,Q?K.height:L,te,se,le,he)}}}};ge._tempPatternMatrix=new U;ge.extension={type:[R.CanvasPipesAdaptor],name:"batch"};let lt=ge;class He{constructor(e){this._colorStack=[],this._colorStackIndex=0,this._currentColor=0,this._renderer=e}buildStart(){this._colorStack[0]=15,this._colorStackIndex=1,this._currentColor=15}push(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;n[this._colorStackIndex]=n[this._colorStackIndex-1]&e.mask;const o=this._colorStack[this._colorStackIndex];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const o=n[this._colorStackIndex-1];o!==this._currentColor&&(this._currentColor=o,s.add({renderPipeId:"colorMask",colorMask:o,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}He.extension={type:[R.CanvasPipes],name:"colorMask"};function ht(a,e,t,s,n,o){o=Math.max(0,Math.min(o,Math.min(s,n)/2)),a.moveTo(e+o,t),a.lineTo(e+s-o,t),a.quadraticCurveTo(e+s,t,e+s,t+o),a.lineTo(e+s,t+n-o),a.quadraticCurveTo(e+s,t+n,e+s-o,t+n),a.lineTo(e+o,t+n),a.quadraticCurveTo(e,t+n,e,t+n-o),a.lineTo(e,t+o),a.quadraticCurveTo(e,t,e+o,t)}function Ge(a,e){switch(e.type){case"rectangle":{const t=e;a.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;ht(a,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;a.moveTo(t.x+t.radius,t.y),a.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;a.ellipse?(a.moveTo(t.x+t.halfWidth,t.y),a.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2)):(a.save(),a.translate(t.x,t.y),a.scale(t.halfWidth,t.halfHeight),a.moveTo(1,0),a.arc(0,0,1,0,Math.PI*2),a.restore());break}case"triangle":{const t=e;a.moveTo(t.x,t.y),a.lineTo(t.x2,t.y2),a.lineTo(t.x3,t.y3),a.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!(s!=null&&s.length))break;a.moveTo(s[0],s[1]);for(let n=2;n<s.length;n+=2)a.lineTo(s[n],s[n+1]);t.closePath&&a.closePath();break}}}function dt(a,e,t){const s=[],n=[],o=[],r=we[e.type];if(!(r!=null&&r.build(e,s)))return!1;const i=e.closePath??!0;Ie(s,t,!1,i,n,o);for(let c=0;c<o.length;c+=3){const u=o[c]*2,m=o[c+1]*2,x=o[c+2]*2;a.moveTo(n[u],n[u+1]),a.lineTo(n[m],n[m+1]),a.lineTo(n[x],n[x+1]),a.closePath()}return!0}function pt(a,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!(s!=null&&s.shape))continue;const n=s.transform,o=n&&!n.isIdentity();o&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ge(a,s.shape),o&&a.restore()}return!0}class Ee{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"pushMaskBegin",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,s){this._renderer.renderPipes.batch.break(s),s.add({renderPipeId:"stencilMask",action:"popMaskEnd",mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){var m,x,G;if(e.action!=="pushMaskBegin"&&e.action!=="popMaskEnd")return;const t=this._renderer,s=t.canvasContext,n=s==null?void 0:s.activeContext;if(!n)return;if(e.action==="popMaskEnd"){this._canvasMaskStack.pop()&&n.restore();return}e.inverse&&this._warnOnce("inverse","CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.");const o=e.mask.mask;if(!(o instanceof Ve)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const r=o,i=(m=r.context)==null?void 0:m.instructions;if(!(i!=null&&i.length)){this._canvasMaskStack.push(!1);return}n.save(),s.setContextTransform(r.groupTransform,(t._roundPixels|r._roundPixels)===1),n.beginPath();let c=!1,u=!1;for(let y=0;y<i.length;y++){const f=i[y],S=f.action;if(S!=="fill"&&S!=="stroke")continue;const v=f.data,A=(x=v==null?void 0:v.path)==null?void 0:x.shapePath;if(!((G=A==null?void 0:A.shapePrimitives)!=null&&G.length))continue;const Y=S==="stroke",q=A.shapePrimitives;for(let E=0;E<q.length;E++){const k=q[E];if(!(k!=null&&k.shape))continue;const C=k.transform,V=C&&!C.isIdentity();V&&(n.save(),n.transform(C.a,C.b,C.c,C.d,C.tx,C.ty)),Y&&v.style?c=dt(n,k.shape,v.style)||c:(Ge(n,k.shape),u=pt(n,k.holes)||u,c=!0),V&&n.restore()}}if(!c){n.restore(),this._canvasMaskStack.push(!1);return}u?n.clip("evenodd"):n.clip(),this._canvasMaskStack.push(!0)}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),Xe(t))}}Ee.extension={type:[R.CanvasPipes],name:"stencilMask"};const h="source-over";function ut(){const a=ct(),e=Object.create(null);return e.inherit=h,e.none=h,e.normal="source-over",e.add="lighter",e.multiply=a?"multiply":h,e.screen=a?"screen":h,e.overlay=a?"overlay":h,e.darken=a?"darken":h,e.lighten=a?"lighten":h,e["color-dodge"]=a?"color-dodge":h,e["color-burn"]=a?"color-burn":h,e["hard-light"]=a?"hard-light":h,e["soft-light"]=a?"soft-light":h,e.difference=a?"difference":h,e.exclusion=a?"exclusion":h,e.saturation=a?"saturation":h,e.color=a?"color":h,e.luminosity=a?"luminosity":h,e["linear-burn"]=a?"color-burn":h,e["linear-dodge"]=a?"color-dodge":h,e["linear-light"]=a?"hard-light":h,e["pin-light"]=a?"hard-light":h,e["vivid-light"]=a?"hard-light":h,e["hard-mix"]=h,e.negation=a?"difference":h,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=h,e.divide=h,e.min=h,e.max=h,e}const mt=new U;class We{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=ut(),this._activeBlendMode="normal",this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){const e=this._renderer.background.alpha<1;if(this.rootContext=this._renderer.canvas.getContext("2d",{alpha:e}),this.activeContext=this.rootContext,this.activeResolution=this._renderer.resolution,!this.rootContext.imageSmoothingEnabled){const t=this.rootContext;t.webkitImageSmoothingEnabled?this.smoothProperty="webkitImageSmoothingEnabled":t.mozImageSmoothingEnabled?this.smoothProperty="mozImageSmoothingEnabled":t.oImageSmoothingEnabled?this.smoothProperty="oImageSmoothingEnabled":t.msImageSmoothingEnabled&&(this.smoothProperty="msImageSmoothingEnabled")}}setContextTransform(e,t,s,n){var u;const o=n?U.IDENTITY:((u=this._renderer.globalUniforms.globalUniformData)==null?void 0:u.worldTransformMatrix)||U.IDENTITY;let r=mt;r.copyFrom(o),r.append(e);const i=this._projTransform,c=this.activeResolution;if(s=s||c,i){const m=U.shared;m.copyFrom(r),m.prepend(i),r=m}t?this.activeContext.setTransform(r.a*s,r.b*s,r.c*s,r.d*s,r.tx*c|0,r.ty*c|0):this.activeContext.setTransform(r.a*s,r.b*s,r.c*s,r.d*s,r.tx*c,r.ty*c)}clear(e,t){const s=this.activeContext,n=this._renderer;if(s.clearRect(0,0,n.width,n.height),e){const o=Re.shared.setValue(e);s.globalAlpha=t??o.alpha,s.fillStyle=o.toHex(),s.fillRect(0,0,n.width,n.height),s.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;const t=this.blendModes[e];if(!t){this._warnedBlendModes.has(e)||(console.warn(`CanvasRenderer: blend mode "${e}" is not supported in Canvas2D; falling back to "source-over".`),this._warnedBlendModes.add(e)),this.activeContext.globalCompositeOperation="source-over";return}this.activeContext.globalCompositeOperation=t}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}}We.extension={type:[R.CanvasSystem],name:"canvasContext"};class Fe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Fe.extension={type:[R.CanvasSystem],name:"limits"};const ft="#808080",ne=new U,gt=new U,vt=new U,fe=new U;function yt(a,e,t){a.beginPath();for(let s=0;s<t.length;s+=3){const n=t[s]*2,o=t[s+1]*2,r=t[s+2]*2;a.moveTo(e[n],e[n+1]),a.lineTo(e[o],e[o+1]),a.lineTo(e[r],e[r+1]),a.closePath()}a.fill()}function xt(a){return`#${(a&16777215).toString(16).padStart(6,"0")}`}function Ct(a,e,t,s,n,o){o=Math.max(0,Math.min(o,Math.min(s,n)/2)),a.moveTo(e+o,t),a.lineTo(e+s-o,t),a.quadraticCurveTo(e+s,t,e+s,t+o),a.lineTo(e+s,t+n-o),a.quadraticCurveTo(e+s,t+n,e+s-o,t+n),a.lineTo(e+o,t+n),a.quadraticCurveTo(e,t+n,e,t+n-o),a.lineTo(e,t+o),a.quadraticCurveTo(e,t,e+o,t)}function oe(a,e){switch(e.type){case"rectangle":{const t=e;a.rect(t.x,t.y,t.width,t.height);break}case"roundedRectangle":{const t=e;Ct(a,t.x,t.y,t.width,t.height,t.radius);break}case"circle":{const t=e;a.arc(t.x,t.y,t.radius,0,Math.PI*2);break}case"ellipse":{const t=e;a.ellipse?a.ellipse(t.x,t.y,t.halfWidth,t.halfHeight,0,0,Math.PI*2):(a.save(),a.translate(t.x,t.y),a.scale(t.halfWidth,t.halfHeight),a.arc(0,0,1,0,Math.PI*2),a.restore());break}case"triangle":{const t=e;a.moveTo(t.x,t.y),a.lineTo(t.x2,t.y2),a.lineTo(t.x3,t.y3),a.closePath();break}case"polygon":default:{const t=e,s=t.points;if(!(s!=null&&s.length))break;a.moveTo(s[0],s[1]);for(let n=2;n<s.length;n+=2)a.lineTo(s[n],s[n+1]);t.closePath&&a.closePath();break}}}function Tt(a,e){if(!(e!=null&&e.length))return!1;for(let t=0;t<e.length;t++){const s=e[t];if(!(s!=null&&s.shape))continue;const n=s.transform,o=n&&!n.isIdentity();o&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),oe(a,s.shape),o&&a.restore()}return!0}function Pt(a,e,t,s){const n=a.fill;if(n instanceof Je){n.buildGradient();const r=n.texture;if(r){const i=P.getTintedPattern(r,e),c=t?fe.copyFrom(t).scale(r.source.pixelWidth,r.source.pixelHeight):fe.copyFrom(n.transform);return s&&!a.textureSpace&&c.append(s),P.applyPatternTransform(i,c),i}}if(n instanceof Ke){const r=P.getTintedPattern(n.texture,e);return P.applyPatternTransform(r,n.transform),r}const o=a.texture;if(o&&o!==Ae.WHITE){if(!o.source.resource)return ft;const r=P.getTintedPattern(o,e),i=t?fe.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):a.matrix;return P.applyPatternTransform(r,i),r}return xt(e)}class Ue{constructor(){this.shader=null}contextChange(e){}execute(e,t){var Y,q,E,k,C,V,z;const s=e.renderer,n=s.canvasContext,o=n.activeContext,r=t.groupTransform,i=((Y=s.globalUniforms.globalUniformData)==null?void 0:Y.worldColor)??4294967295,c=t.groupColorAlpha,u=(i>>>24&255)/255,m=(c>>>24&255)/255,x=((q=s.filter)==null?void 0:q.alphaMultiplier)??1,G=u*m*x;if(G<=0)return;const y=i&16777215,f=c&16777215,S=Me(ae(f,y)),v=s._roundPixels|t._roundPixels;o.save(),n.setContextTransform(r,v===1),n.setBlendMode(t.groupBlendMode);const A=t.context.instructions;for(let Z=0;Z<A.length;Z++){const J=A[Z];if(J.action==="texture"){const d=J.data,p=d.image,g=p?P.getCanvasSource(p):null;if(!g)continue;const L=d.alpha*G;if(L<=0)continue;const I=ae(d.style,S);o.globalAlpha=L;let _=g;I!==16777215&&(_=P.getTintedCanvas({texture:p},I));const W=p.frame,F=p.source._resolution??p.source.resolution??1;let B=W.x*F,H=W.y*F;const O=W.width*F,l=W.height*F;_!==g&&(B=0,H=0);const N=d.transform,j=N&&!N.isIdentity(),T=p.rotate;j||T?(ne.copyFrom(r),j&&ne.append(N),T&&Se.matrixAppendRotationInv(ne,T,d.dx,d.dy,d.dw,d.dh),n.setContextTransform(ne,v===1)):n.setContextTransform(r,v===1),o.drawImage(_,B,H,_===g?O:_.width,_===g?l:_.height,T?0:d.dx,T?0:d.dy,d.dw,d.dh),(j||T)&&n.setContextTransform(r,v===1);continue}const b=J.data,M=(E=b==null?void 0:b.path)==null?void 0:E.shapePath;if(!((k=M==null?void 0:M.shapePrimitives)!=null&&k.length))continue;const w=b.style,ie=ae(w.color,S),ee=w.alpha*G;if(ee<=0)continue;const D=J.action==="stroke";if(o.globalAlpha=ee,D){const d=w;o.lineWidth=d.width,o.lineCap=d.cap,o.lineJoin=d.join,o.miterLimit=d.miterLimit}const X=M.shapePrimitives;if(!D&&((z=(V=(C=b.hole)==null?void 0:C.shapePath)==null?void 0:V.shapePrimitives)!=null&&z.length)){const d=X[X.length-1];d.holes=b.hole.shapePath.shapePrimitives}for(let d=0;d<X.length;d++){const p=X[d];if(!(p!=null&&p.shape))continue;const g=p.transform,L=g&&!g.isIdentity(),I=w.texture&&w.texture!==Ae.WHITE,_=w.textureSpace==="global"?g:null,W=I?$e(gt,w,p.shape,_):null,F=L?vt.copyFrom(r).append(g):r,B=Pt(w,ie,W,F);if(L&&(o.save(),o.transform(g.a,g.b,g.c,g.d,g.tx,g.ty)),D){const H=w;if(H.alignment!==.5&&!H.pixelLine){const l=[],N=[],j=[],T=we[p.shape.type];if(T!=null&&T.build(p.shape,l)){const ve=p.shape.closePath??!0;Ie(l,H,!1,ve,N,j),o.fillStyle=B,yt(o,N,j)}else o.strokeStyle=B,o.beginPath(),oe(o,p.shape),o.stroke()}else o.strokeStyle=B,o.beginPath(),oe(o,p.shape),o.stroke()}else o.fillStyle=B,o.beginPath(),oe(o,p.shape),Tt(o,p.holes)?o.fill("evenodd"):o.fill();L&&o.restore()}}o.restore()}destroy(){this.shader=null}}Ue.extension={type:[R.CanvasPipesAdaptor],name:"graphics"};class kt{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){const t=e.colorTexture,{canvas:s,context:n}=this._ensureCanvas(t);return{canvas:s,context:n,width:s.width,height:s.height}}resizeGpuRenderTarget(e){const t=e.colorTexture,{canvas:s}=this._ensureCanvas(t);s.width=e.pixelWidth,s.height=e.pixelHeight}startRenderPass(e,t,s,n){const o=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=o.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,s,n)}clear(e,t,s,n){const r=this._renderTargetSystem.getGpuRenderTarget(e).context,i=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(r.setTransform(1,0,0,1,0,0),r.clearRect(i.x,i.y,i.width,i.height),s){const c=Re.shared.setValue(s);c.alpha>0&&(r.globalAlpha=c.alpha,r.fillStyle=c.toHex(),r.fillRect(i.x,i.y,i.width,i.height),r.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,s,n,o){const i=this._renderTargetSystem.getGpuRenderTarget(e).canvas,c=t.source,{context:u}=this._ensureCanvas(c),m=(o==null?void 0:o.x)??0,x=(o==null?void 0:o.y)??0;return u.drawImage(i,s.x,s.y,n.width,n.height,m,x,n.width,n.height),c.update(),t}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Qe.test(t))&&(t=Be.get().createCanvas(e.pixelWidth,e.pixelHeight),e.resource=t),(t.width!==e.pixelWidth||t.height!==e.pixelHeight)&&(t.width=e.pixelWidth,t.height=e.pixelHeight);const s=t.getContext("2d");return{canvas:t,context:s}}}class qe extends et{constructor(e){super(e),this.adaptor=new kt,this.adaptor.init(e,this)}}qe.extension={type:[R.CanvasSystem],name:"renderTarget"};class De{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=Be.get().createCanvas(),s=t.getContext("2d"),n=P.getCanvasSource(e);if(!n)return t;const o=e.frame,r=e.source._resolution??e.source.resolution??1,i=o.x*r,c=o.y*r,u=o.width*r,m=o.height*r;return t.width=Math.ceil(u),t.height=Math.ceil(m),s.drawImage(n,i,c,u,m,0,0,u,m),t}getPixels(e){const t=this.generateCanvas(e);return{pixels:t.getContext("2d",{willReadFrequently:!0}).getImageData(0,0,t.width,t.height).data,width:t.width,height:t.height}}destroy(){}}De.extension={type:[R.CanvasSystem],name:"texture"};const bt=[...tt,We,Fe,De,qe],_t=[st,nt,at,ot,rt,Ee,He,it],St=[lt,Ue],Le=[],Oe=[],Ne=[];re.handleByNamedList(R.CanvasSystem,Le);re.handleByNamedList(R.CanvasPipes,Oe);re.handleByNamedList(R.CanvasPipesAdaptor,Ne);re.add(...bt,..._t,...St);class At extends ze{constructor(){const e={name:"canvas",type:Ze.CANVAS,systems:Le,renderPipes:Oe,renderPipeAdaptors:Ne};super(e)}}export{At as CanvasRenderer};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{v as n,x as o,q as u,o as f}from"./index-
|
|
1
|
+
import{v as n,x as o,q as u,o as f}from"./index-CINA8e_Z.js";const s=class i extends n{constructor(e){e={...i.defaultOptions,...e},super(e),this.enabled=!0,this._state=o.for2d(),this.blendMode=e.blendMode,this.padding=e.padding,typeof e.antialias=="boolean"?this.antialias=e.antialias?"on":"off":this.antialias=e.antialias,this.resolution=e.resolution,this.blendRequired=e.blendRequired,this.clipToViewport=e.clipToViewport,this.addResource("uTexture",0,1),e.blendRequired&&this.addResource("uBackTexture",0,3)}apply(e,t,a,r){e.applyFilter(this,t,a,r)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:t,gl:a,...r}=e;let l,d;return t&&(l=u.from(t)),a&&(d=f.from(a)),new i({gpuProgram:l,glProgram:d,...r})}};s.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let b=s;export{b as F};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as Ve,Q as oe,M as m,q as Ne,o as je,x as $e,j as le,k as l,a4 as W,a as w,ab as qe,c as z,H as T,u as V,m as de,w as Ke,T as p,S as g,C as D,B as ue,ap as ce,s as ee,ag as he,O as fe,L as pe,U as me,i as P,J as Ye,h as O,D as N,I as y,R as B,ac as Je,P as Xe,Z as Qe,b as Ze,K as te,V as re,a3 as f,am as et,g as E,p as tt,ao as rt,t as st,y as nt}from"./index-
|
|
1
|
+
import{z as Ve,Q as oe,M as m,q as Ne,o as je,x as $e,j as le,k as l,a4 as W,a as w,ab as qe,c as z,H as T,u as V,m as de,w as Ke,T as p,S as g,C as D,B as ue,ap as ce,s as ee,ag as he,O as fe,L as pe,U as me,i as P,J as Ye,h as O,D as N,I as y,R as B,ac as Je,P as Xe,Z as Qe,b as Ze,K as te,V as re,a3 as f,am as et,g as E,p as tt,ao as rt,t as st,y as nt}from"./index-CINA8e_Z.js";import{F as at}from"./Filter-ZZPoYeTC.js";var it=`in vec2 vMaskCoord;
|
|
2
2
|
in vec2 vTextureCoord;
|
|
3
3
|
|
|
4
4
|
uniform sampler2D uTexture;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as R,x as F,k as d,G as P,e as B,ap as p,a9 as z,o as ye,v as O,T as S,n as Ce,I as q,Y as Ne,S as g,R as V,g as y,C,Q as M,M as Z,a0 as Q,$ as De,ak as J,a7 as Ie,aa as Ge,A as Ue,u as Fe,a4 as A}from"./index-Cf0rVPz-.js";import{e as Pe,G as Oe,c as Me,u as Le,U as we,B as ee,g as N,a as te,d as He}from"./BufferResource-wp05kXJi.js";import{b as Ve,c as ke,S as Xe}from"./RenderTargetSystem-BADEJjVe.js";import"./Filter-DCFwFDCZ.js";function We(){const{userAgent:t}=R.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}class re{constructor(){this._tempState=F.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,r,n){const s=e.renderer,i=this._didUploadHash[n.uid];s.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(r,n.glProgram)}execute(e,r){const n=e.renderer;this._tempState.blendMode=r.blendMode,n.state.set(this._tempState);const s=r.textures.textures;for(let i=0;i<r.textures.count;i++)n.texture.bind(s[i],i);n.geometry.draw(r.topology,r.size,r.start)}}re.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var v=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(v||{});class je{constructor(e,r){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ne{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new P({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,n=this.getGlBuffer(e);r.bindBuffer(n.type,n.buffer)}bindBufferBase(e,r){const{_gl:n}=this;this._boundBufferBases[r]!==e&&(this._boundBufferBases[r]=e,e._lastBindBaseLocation=r,n.bindBufferBase(n.UNIFORM_BUFFER,r,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let r=this.getLastBindBaseLocation(e);if(r>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,r;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const i=this._boundBufferBases[s];if(i&&i._lastBindCallId===this._bindCallId){s++;continue}break}return r=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[r]=null,r)}getLastBindBaseLocation(e){const r=e._lastBindBaseLocation;return this._boundBufferBases[r]===e?r:-1}bindBufferRange(e,r,n,s){const{_gl:i}=this;n||(n=0),r||(r=0),this._boundBufferBases[r]=null,i.bindBufferRange(i.UNIFORM_BUFFER,r||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:r}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,r.bindBuffer(n.type,n.buffer);const s=e.data,i=e.descriptor.usage&B.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?r.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,r.bufferData(n.type,s,i)):(n.byteLength=e.descriptor.size,r.bufferData(n.type,n.byteLength,i)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];n&&(r||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:r}=this;let n=v.ARRAY_BUFFER;e.descriptor.usage&B.INDEX?n=v.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&B.UNIFORM&&(n=v.UNIFORM_BUFFER);const s=new je(r.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ne.extension={type:[d.WebGLSystem],name:"buffer"};const L=class se{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...se.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(p("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=R.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,i=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:i,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&p("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width<e.width||r.height<e.height)&&(r.width=Math.max(e.width,e.width),r.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof R.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const r=this._renderer.view.canvas;r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,r){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",r)),!n&&(n=s.getContext("webgl",r),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,r={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...r,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...r,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var r;this.gl.isContextLost()&&((r=this.extensions.loseContext)==null||r.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var r;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(r=this.extensions.loseContext)==null||r.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&p("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,i=this.extensions;n.uint32Indices=s||!!i.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!i.vertexArrayObject,n.srgbTextures=s||!!i.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||p("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};L.extension={type:[d.WebGLSystem],name:"context"};L.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let Ke=L;var G=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(G||{}),w=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(w||{}),l=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(l||{});const k={uint8x2:l.UNSIGNED_BYTE,uint8x4:l.UNSIGNED_BYTE,sint8x2:l.BYTE,sint8x4:l.BYTE,unorm8x2:l.UNSIGNED_BYTE,unorm8x4:l.UNSIGNED_BYTE,snorm8x2:l.BYTE,snorm8x4:l.BYTE,uint16x2:l.UNSIGNED_SHORT,uint16x4:l.UNSIGNED_SHORT,sint16x2:l.SHORT,sint16x4:l.SHORT,unorm16x2:l.UNSIGNED_SHORT,unorm16x4:l.UNSIGNED_SHORT,snorm16x2:l.SHORT,snorm16x4:l.SHORT,float16x2:l.HALF_FLOAT,float16x4:l.HALF_FLOAT,float32:l.FLOAT,float32x2:l.FLOAT,float32x3:l.FLOAT,float32x4:l.FLOAT,uint32:l.UNSIGNED_INT,uint32x2:l.UNSIGNED_INT,uint32x3:l.UNSIGNED_INT,uint32x4:l.UNSIGNED_INT,sint32:l.INT,sint32x2:l.INT,sint32x3:l.INT,sint32x4:l.INT};function $e(t){return k[t]??k.float32}const Ye={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ze{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ie{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new P({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=s=>r.bindVertexArrayOES(s),e.deleteVertexArray=s=>r.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,i,a,o)=>{n.drawArraysInstancedANGLE(s,i,a,o)},e.drawElementsInstanced=(s,i,a,o,u)=>{n.drawElementsInstancedANGLE(s,i,a,o,u)},e.vertexAttribDivisor=(s,i)=>n.vertexAttribDivisorANGLE(s,i)),this._activeGeometry=null,this._activeVao=null}bind(e,r){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,r);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];r.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,r){const n=e.attributes,s=r._attributeData;for(const i in s)if(!n[i])throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`)}getSignature(e,r){const n=e.attributes,s=r._attributeData,i=["g",e.uid];for(const a in n)s[a]&&i.push(a,s[a].location);return i.join("-")}getVao(e,r){var n;return((n=e._gpuData[this._renderer.uid])==null?void 0:n.vaoCache[r._key])||this.initGeometryVao(e,r)}initGeometryVao(e,r,n=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(r),this.checkCompatibility(e,r);const a=this.getSignature(e,r);let o=e._gpuData[this._renderer.uid];o||(o=new ze,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const u=o.vaoCache;let c=u[a];if(c)return u[r._key]=c,c;Pe(e,r._attributeData);const _=e.buffers;c=s.createVertexArray(),s.bindVertexArray(c);for(let f=0;f<_.length;f++){const h=_[f];i.bind(h)}return this.activateVao(e,r),u[r._key]=c,u[a]=c,s.bindVertexArray(null),c}onGeometryUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!r)for(const i in s)this._activeVao!==s[i]&&this.resetState(),this.gl.deleteVertexArray(s[i])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,r){var o;const n=this._renderer.gl,s=this._renderer.buffer,i=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let a=null;for(const u in i){const c=i[u],_=c.buffer,f=s.getGlBuffer(_),h=r._attributeData[u];if(h){a!==f&&(s.bind(_),a=f);const m=h.location;n.enableVertexAttribArray(m);const b=z(c.format),E=$e(c.format);if(((o=h.format)==null?void 0:o.substring(1,4))==="int"?n.vertexAttribIPointer(m,b.size,E,c.stride,c.offset):n.vertexAttribPointer(m,b.size,E,b.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const Be=c.divisor??1;n.vertexAttribDivisor(m,Be)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,r,n,s){const{gl:i}=this._renderer,a=this._activeGeometry,o=Ye[e||a.topology];if(s??(s=a.instanceCount),a.indexBuffer){const u=a.indexBuffer.data.BYTES_PER_ELEMENT,c=u===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;s!==1?i.drawElementsInstanced(o,r||a.indexBuffer.data.length,c,(n||0)*u,s):i.drawElements(o,r||a.indexBuffer.data.length,c,(n||0)*u)}else s!==1?i.drawArraysInstanced(o,n||0,r||a.getSize(),s):i.drawArrays(o,n||0,r||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ie.extension={type:[d.WebGLSystem],name:"geometry"};const qe=new Ce({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class ae{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:n}={...ae.defaultOptions,...e};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||(p("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=F.for2d();const s=new ye({vertex:`
|
|
1
|
+
import{D as R,x as F,k as d,G as P,e as B,ap as p,a9 as z,o as ye,v as O,T as S,n as Ce,I as q,Y as Ne,S as g,R as V,g as y,C,Q as M,M as Z,a0 as Q,$ as De,ak as J,a7 as Ie,aa as Ge,A as Ue,u as Fe,a4 as A}from"./index-CINA8e_Z.js";import{e as Pe,G as Oe,c as Me,u as Le,U as we,B as ee,g as N,a as te,d as He}from"./BufferResource-CE78HmbQ.js";import{b as Ve,c as ke,S as Xe}from"./RenderTargetSystem-EVgeaEAK.js";import"./Filter-ZZPoYeTC.js";function We(){const{userAgent:t}=R.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(t)}class re{constructor(){this._tempState=F.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,r,n){const s=e.renderer,i=this._didUploadHash[n.uid];s.shader.bind(n,i),i||(this._didUploadHash[n.uid]=!0),s.shader.updateUniformGroup(s.globalUniforms.uniformGroup),s.geometry.bind(r,n.glProgram)}execute(e,r){const n=e.renderer;this._tempState.blendMode=r.blendMode,n.state.set(this._tempState);const s=r.textures.textures;for(let i=0;i<r.textures.count;i++)n.texture.bind(s[i],i);n.geometry.draw(r.topology,r.size,r.start)}}re.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var v=(t=>(t[t.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",t[t.ARRAY_BUFFER=34962]="ARRAY_BUFFER",t[t.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",t))(v||{});class je{constructor(e,r){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=r}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class ne{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new P({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"glBuffer"})}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gl=null,this._boundBufferBases={}}contextChange(){this._gl=this._renderer.gl,this.destroyAll(!0),this._maxBindings=this._renderer.limits.maxUniformBindings}getGlBuffer(e){return e._gcLastUsed=this._renderer.gc.now,e._gpuData[this._renderer.uid]||this.createGLBuffer(e)}bind(e){const{_gl:r}=this,n=this.getGlBuffer(e);r.bindBuffer(n.type,n.buffer)}bindBufferBase(e,r){const{_gl:n}=this;this._boundBufferBases[r]!==e&&(this._boundBufferBases[r]=e,e._lastBindBaseLocation=r,n.bindBufferBase(n.UNIFORM_BUFFER,r,e.buffer))}nextBindBase(e){this._bindCallId++,this._minBaseLocation=0,e&&(this._boundBufferBases[0]=null,this._minBaseLocation=1,this._nextBindBaseIndex<1&&(this._nextBindBaseIndex=1))}freeLocationForBufferBase(e){let r=this.getLastBindBaseLocation(e);if(r>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,r;let n=0,s=this._nextBindBaseIndex;for(;n<2;){s>=this._maxBindings&&(s=this._minBaseLocation,n++);const i=this._boundBufferBases[s];if(i&&i._lastBindCallId===this._bindCallId){s++;continue}break}return r=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[r]=null,r)}getLastBindBaseLocation(e){const r=e._lastBindBaseLocation;return this._boundBufferBases[r]===e?r:-1}bindBufferRange(e,r,n,s){const{_gl:i}=this;n||(n=0),r||(r=0),this._boundBufferBases[r]=null,i.bindBufferRange(i.UNIFORM_BUFFER,r||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:r}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,r.bindBuffer(n.type,n.buffer);const s=e.data,i=e.descriptor.usage&B.STATIC?r.STATIC_DRAW:r.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?r.bufferSubData(n.type,0,s,0,e._updateSize/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,r.bufferData(n.type,s,i)):(n.byteLength=e.descriptor.size,r.bufferData(n.type,n.byteLength,i)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];n&&(r||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:r}=this;let n=v.ARRAY_BUFFER;e.descriptor.usage&B.INDEX?n=v.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&B.UNIFORM&&(n=v.UNIFORM_BUFFER);const s=new je(r.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}ne.extension={type:[d.WebGLSystem],name:"buffer"};const L=class se{constructor(e){this.supports={uint32Indices:!0,uniformBufferObject:!0,vertexArrayObject:!0,srgbTextures:!0,nonPowOf2wrapping:!0,msaa:!0,nonPowOf2mipmaps:!0},this._renderer=e,this.extensions=Object.create(null),this.handleContextLost=this.handleContextLost.bind(this),this.handleContextRestored=this.handleContextRestored.bind(this)}get isLost(){return!this.gl||this.gl.isContextLost()}contextChange(e){this.gl=e,this._renderer.gl=e}init(e){e={...se.defaultOptions,...e};let r=this.multiView=e.multiView;if(e.context&&r&&(p("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),r=!1),r?this.canvas=R.get().createCanvas(this._renderer.canvas.width,this._renderer.canvas.height):this.canvas=this._renderer.view.canvas,e.context)this.initFromContext(e.context);else{const n=this._renderer.background.alpha<1,s=e.premultipliedAlpha??!0,i=e.antialias&&!this._renderer.backBuffer.useBackBuffer;this.createContext(e.preferWebGLVersion,{alpha:n,premultipliedAlpha:s,antialias:i,stencil:!0,preserveDrawingBuffer:e.preserveDrawingBuffer,powerPreference:e.powerPreference??"default"})}}ensureCanvasSize(e){if(!this.multiView){e!==this.canvas&&p("multiView is disabled, but targetCanvas is not the main canvas");return}const{canvas:r}=this;(r.width<e.width||r.height<e.height)&&(r.width=Math.max(e.width,e.width),r.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof R.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const r=this._renderer.view.canvas;r.addEventListener("webglcontextlost",this.handleContextLost,!1),r.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,r){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",r)),!n&&(n=s.getContext("webgl",r),!n))throw new Error("This browser does not support WebGL. Try using the canvas renderer");this.gl=n,this.initFromContext(this.gl)}getExtensions(){const{gl:e}=this,r={anisotropicFiltering:e.getExtension("EXT_texture_filter_anisotropic"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),s3tc:e.getExtension("WEBGL_compressed_texture_s3tc"),s3tc_sRGB:e.getExtension("WEBGL_compressed_texture_s3tc_srgb"),etc:e.getExtension("WEBGL_compressed_texture_etc"),etc1:e.getExtension("WEBGL_compressed_texture_etc1"),pvrtc:e.getExtension("WEBGL_compressed_texture_pvrtc")||e.getExtension("WEBKIT_WEBGL_compressed_texture_pvrtc"),atc:e.getExtension("WEBGL_compressed_texture_atc"),astc:e.getExtension("WEBGL_compressed_texture_astc"),bptc:e.getExtension("EXT_texture_compression_bptc"),rgtc:e.getExtension("EXT_texture_compression_rgtc"),loseContext:e.getExtension("WEBGL_lose_context")};if(this.webGLVersion===1)this.extensions={...r,drawBuffers:e.getExtension("WEBGL_draw_buffers"),depthTexture:e.getExtension("WEBGL_depth_texture"),vertexArrayObject:e.getExtension("OES_vertex_array_object")||e.getExtension("MOZ_OES_vertex_array_object")||e.getExtension("WEBKIT_OES_vertex_array_object"),uint32ElementIndex:e.getExtension("OES_element_index_uint"),floatTexture:e.getExtension("OES_texture_float"),floatTextureLinear:e.getExtension("OES_texture_float_linear"),textureHalfFloat:e.getExtension("OES_texture_half_float"),textureHalfFloatLinear:e.getExtension("OES_texture_half_float_linear"),vertexAttribDivisorANGLE:e.getExtension("ANGLE_instanced_arrays"),srgb:e.getExtension("EXT_sRGB")};else{this.extensions={...r,colorBufferFloat:e.getExtension("EXT_color_buffer_float")};const n=e.getExtension("WEBGL_provoking_vertex");n&&n.provokingVertexWEBGL(n.FIRST_VERTEX_CONVENTION_WEBGL)}}handleContextLost(e){e.preventDefault(),this._contextLossForced&&(this._contextLossForced=!1,setTimeout(()=>{var r;this.gl.isContextLost()&&((r=this.extensions.loseContext)==null||r.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var r;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(r=this.extensions.loseContext)==null||r.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const r=e.getContextAttributes();r&&!r.stencil&&p("Provided WebGL context does not have a stencil buffer, masks may not render correctly");const n=this.supports,s=this.webGLVersion===2,i=this.extensions;n.uint32Indices=s||!!i.uint32ElementIndex,n.uniformBufferObject=s,n.vertexArrayObject=s||!!i.vertexArrayObject,n.srgbTextures=s||!!i.srgb,n.nonPowOf2wrapping=s,n.nonPowOf2mipmaps=s,n.msaa=s,n.uint32Indices||p("Provided WebGL context does not support 32 index buffer, large scenes may not render correctly")}};L.extension={type:[d.WebGLSystem],name:"context"};L.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let Ke=L;var G=(t=>(t[t.RGBA=6408]="RGBA",t[t.RGB=6407]="RGB",t[t.RG=33319]="RG",t[t.RED=6403]="RED",t[t.RGBA_INTEGER=36249]="RGBA_INTEGER",t[t.RGB_INTEGER=36248]="RGB_INTEGER",t[t.RG_INTEGER=33320]="RG_INTEGER",t[t.RED_INTEGER=36244]="RED_INTEGER",t[t.ALPHA=6406]="ALPHA",t[t.LUMINANCE=6409]="LUMINANCE",t[t.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",t[t.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",t[t.DEPTH_STENCIL=34041]="DEPTH_STENCIL",t))(G||{}),w=(t=>(t[t.TEXTURE_2D=3553]="TEXTURE_2D",t[t.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",t[t.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",t[t.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",t[t.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",t[t.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",t[t.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",t[t.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",t))(w||{}),l=(t=>(t[t.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",t[t.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",t[t.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",t[t.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",t[t.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",t[t.UNSIGNED_INT=5125]="UNSIGNED_INT",t[t.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",t[t.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",t[t.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",t[t.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",t[t.BYTE=5120]="BYTE",t[t.SHORT=5122]="SHORT",t[t.INT=5124]="INT",t[t.FLOAT=5126]="FLOAT",t[t.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",t[t.HALF_FLOAT=36193]="HALF_FLOAT",t))(l||{});const k={uint8x2:l.UNSIGNED_BYTE,uint8x4:l.UNSIGNED_BYTE,sint8x2:l.BYTE,sint8x4:l.BYTE,unorm8x2:l.UNSIGNED_BYTE,unorm8x4:l.UNSIGNED_BYTE,snorm8x2:l.BYTE,snorm8x4:l.BYTE,uint16x2:l.UNSIGNED_SHORT,uint16x4:l.UNSIGNED_SHORT,sint16x2:l.SHORT,sint16x4:l.SHORT,unorm16x2:l.UNSIGNED_SHORT,unorm16x4:l.UNSIGNED_SHORT,snorm16x2:l.SHORT,snorm16x4:l.SHORT,float16x2:l.HALF_FLOAT,float16x4:l.HALF_FLOAT,float32:l.FLOAT,float32x2:l.FLOAT,float32x3:l.FLOAT,float32x4:l.FLOAT,uint32:l.UNSIGNED_INT,uint32x2:l.UNSIGNED_INT,uint32x3:l.UNSIGNED_INT,uint32x4:l.UNSIGNED_INT,sint32:l.INT,sint32x2:l.INT,sint32x3:l.INT,sint32x4:l.INT};function $e(t){return k[t]??k.float32}const Ye={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class ze{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ie{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new P({renderer:e,type:"resource",onUnload:this.onGeometryUnload.bind(this),name:"glGeometry"})}contextChange(){const e=this.gl=this._renderer.gl;if(!this._renderer.context.supports.vertexArrayObject)throw new Error("[PixiJS] Vertex Array Objects are not supported on this device");this.destroyAll(!0);const r=this._renderer.context.extensions.vertexArrayObject;r&&(e.createVertexArray=()=>r.createVertexArrayOES(),e.bindVertexArray=s=>r.bindVertexArrayOES(s),e.deleteVertexArray=s=>r.deleteVertexArrayOES(s));const n=this._renderer.context.extensions.vertexAttribDivisorANGLE;n&&(e.drawArraysInstanced=(s,i,a,o)=>{n.drawArraysInstancedANGLE(s,i,a,o)},e.drawElementsInstanced=(s,i,a,o,u)=>{n.drawElementsInstancedANGLE(s,i,a,o,u)},e.vertexAttribDivisor=(s,i)=>n.vertexAttribDivisorANGLE(s,i)),this._activeGeometry=null,this._activeVao=null}bind(e,r){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,r);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,r=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];r.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,r){const n=e.attributes,s=r._attributeData;for(const i in s)if(!n[i])throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`)}getSignature(e,r){const n=e.attributes,s=r._attributeData,i=["g",e.uid];for(const a in n)s[a]&&i.push(a,s[a].location);return i.join("-")}getVao(e,r){var n;return((n=e._gpuData[this._renderer.uid])==null?void 0:n.vaoCache[r._key])||this.initGeometryVao(e,r)}initGeometryVao(e,r,n=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(r),this.checkCompatibility(e,r);const a=this.getSignature(e,r);let o=e._gpuData[this._renderer.uid];o||(o=new ze,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const u=o.vaoCache;let c=u[a];if(c)return u[r._key]=c,c;Pe(e,r._attributeData);const _=e.buffers;c=s.createVertexArray(),s.bindVertexArray(c);for(let f=0;f<_.length;f++){const h=_[f];i.bind(h)}return this.activateVao(e,r),u[r._key]=c,u[a]=c,s.bindVertexArray(null),c}onGeometryUnload(e,r=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!r)for(const i in s)this._activeVao!==s[i]&&this.resetState(),this.gl.deleteVertexArray(s[i])}destroyAll(e=!1){this._managedGeometries.removeAll(e)}activateVao(e,r){var o;const n=this._renderer.gl,s=this._renderer.buffer,i=e.attributes;e.indexBuffer&&s.bind(e.indexBuffer);let a=null;for(const u in i){const c=i[u],_=c.buffer,f=s.getGlBuffer(_),h=r._attributeData[u];if(h){a!==f&&(s.bind(_),a=f);const m=h.location;n.enableVertexAttribArray(m);const b=z(c.format),E=$e(c.format);if(((o=h.format)==null?void 0:o.substring(1,4))==="int"?n.vertexAttribIPointer(m,b.size,E,c.stride,c.offset):n.vertexAttribPointer(m,b.size,E,b.normalised,c.stride,c.offset),c.instance)if(this.hasInstance){const Be=c.divisor??1;n.vertexAttribDivisor(m,Be)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,r,n,s){const{gl:i}=this._renderer,a=this._activeGeometry,o=Ye[e||a.topology];if(s??(s=a.instanceCount),a.indexBuffer){const u=a.indexBuffer.data.BYTES_PER_ELEMENT,c=u===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT;s!==1?i.drawElementsInstanced(o,r||a.indexBuffer.data.length,c,(n||0)*u,s):i.drawElements(o,r||a.indexBuffer.data.length,c,(n||0)*u)}else s!==1?i.drawArraysInstanced(o,n||0,r||a.getSize(),s):i.drawArrays(o,n||0,r||a.getSize());return this}unbind(){this.gl.bindVertexArray(null),this._activeVao=null,this._activeGeometry=null}destroy(){this._managedGeometries.destroy(),this._renderer=null,this.gl=null,this._activeVao=null,this._activeGeometry=null}}ie.extension={type:[d.WebGLSystem],name:"geometry"};const qe=new Ce({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),H=class ae{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:r,antialias:n}={...ae.defaultOptions,...e};this.useBackBuffer=r,this._antialias=n,this._renderer.context.supports.msaa||(p("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=F.for2d();const s=new ye({vertex:`
|
|
2
2
|
attribute vec2 aPosition;
|
|
3
3
|
out vec2 vUv;
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{ae as L,x as A,k as l,G as D,am as ce,a5 as de,D as B,S as C,e as T,d as he,b as k,a2 as w,ap as v,C as y,g as pe,I as le,Q as z,f as M,M as F,a1 as O,_ as fe,aj as I,a6 as ge,v as W,T as R,A as me,u as _e,a4 as S}from"./index-Cf0rVPz-.js";import{c as be,f as ye,U as xe,B as Ge,G as Pe,e as Be,b as Se,l as Te,t as Ce}from"./BufferResource-wp05kXJi.js";import{b as ve,c as Ue,S as we}from"./RenderTargetSystem-BADEJjVe.js";import"./Filter-DCFwFDCZ.js";const G=A.for2d();class H{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),G.blendMode="normal",s.pipeline.getPipeline(t,n,G);const o=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const u=t.textures;t.bindGroup=L(u.textures,u.count,s.limits.maxBatchableTextures)}G.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),o=s.pipeline.getPipeline(this._geometry,r,G,t.topology);t.bindGroup._touch(s.gc.now,s.tick),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}H.extension={type:[l.WebGPUPipesAdaptor],name:"batch"};class V{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const s=this._gpu.device,i=t.layout[r],n=[],o=this._renderer;for(const f in i){const h=e.resources[f]??e.resources[i[f]];let p;if(h._resourceType==="uniformGroup"){const d=h;o.ubo.updateUniformGroup(d);const g=d.buffer;p={buffer:o.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(h._resourceType==="buffer"){const d=h;p={buffer:o.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(h._resourceType==="bufferResource"){const d=h;p={buffer:o.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(h._resourceType==="textureSampler"){const d=h;p=o.texture.getGpuSampler(d)}else if(h._resourceType==="textureSource"){const d=h;p=o.texture.getTextureView(d)}n.push({binding:i[f],resource:p})}const u=o.shader.getProgramData(t).bindGroups[r],c=s.createBindGroup({layout:u,entries:n});return this._hash[e._key]=c,c}destroy(){this._hash=null,this._renderer=null}}V.extension={type:[l.WebGPUSystem],name:"bindGroup"};class Me{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class N{constructor(e){this._renderer=e,this._managedBuffers=new D({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuBuffer)||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=ce("resource"),e.data&&(de(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new Me(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}N.extension={type:[l.WebGPUSystem],name:"buffer"};class Re{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}class j{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}j.extension={type:[l.WebGPUSystem],name:"colorMask"};class U{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await B.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}U.extension={type:[l.WebGPUSystem],name:"device"};U.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class K{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){const i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in r)this._setVertexBuffer(parseInt(s,10),e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:o,instanceCount:u,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,u??t.instanceCount,o||0):this.renderPassEncoder.draw(n||t.getSize(),u??t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t);for(const o in r)this._setVertexBuffer(o,r[o]);for(const o in i)this.setBindGroup(o,i[o],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}K.extension={type:[l.WebGPUSystem],name:"encoder",priority:1};class q{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}q.extension={type:[l.WebGPUSystem],name:"limits"};class Y{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:C.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Y.extension={type:[l.WebGPUSystem],name:"stencil"};const P={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function Ee(a){const e=a.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r<e.length;r++){const s=e[r];let i=P[s.data.type].size;const n=P[s.data.type].align;if(!P[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,n)*s.data.size),t=Math.ceil(t/n)*n,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function Le(a,e){const{size:t,align:r}=P[a.data.type],s=(r-t)/4,i=a.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
1
|
+
import{ae as L,x as A,k as l,G as D,am as ce,a5 as de,D as B,S as C,e as T,d as he,b as k,a2 as w,ap as v,C as y,g as pe,I as le,Q as z,f as M,M as F,a1 as O,_ as fe,aj as I,a6 as ge,v as W,T as R,A as me,u as _e,a4 as S}from"./index-CINA8e_Z.js";import{c as be,f as ye,U as xe,B as Ge,G as Pe,e as Be,b as Se,l as Te,t as Ce}from"./BufferResource-CE78HmbQ.js";import{b as ve,c as Ue,S as we}from"./RenderTargetSystem-EVgeaEAK.js";import"./Filter-ZZPoYeTC.js";const G=A.for2d();class H{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),G.blendMode="normal",s.pipeline.getPipeline(t,n,G);const o=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,o,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const u=t.textures;t.bindGroup=L(u.textures,u.count,s.limits.maxBatchableTextures)}G.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),o=s.pipeline.getPipeline(this._geometry,r,G,t.topology);t.bindGroup._touch(s.gc.now,s.tick),i.setPipeline(o),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}H.extension={type:[l.WebGPUPipesAdaptor],name:"batch"};class V{constructor(e){this._hash=Object.create(null),this._renderer=e}contextChange(e){this._gpu=e}getBindGroup(e,t,r){return e._updateKey(),this._hash[e._key]||this._createBindGroup(e,t,r)}_createBindGroup(e,t,r){const s=this._gpu.device,i=t.layout[r],n=[],o=this._renderer;for(const f in i){const h=e.resources[f]??e.resources[i[f]];let p;if(h._resourceType==="uniformGroup"){const d=h;o.ubo.updateUniformGroup(d);const g=d.buffer;p={buffer:o.buffer.getGPUBuffer(g),offset:0,size:g.descriptor.size}}else if(h._resourceType==="buffer"){const d=h;p={buffer:o.buffer.getGPUBuffer(d),offset:0,size:d.descriptor.size}}else if(h._resourceType==="bufferResource"){const d=h;p={buffer:o.buffer.getGPUBuffer(d.buffer),offset:d.offset,size:d.size}}else if(h._resourceType==="textureSampler"){const d=h;p=o.texture.getGpuSampler(d)}else if(h._resourceType==="textureSource"){const d=h;p=o.texture.getTextureView(d)}n.push({binding:i[f],resource:p})}const u=o.shader.getProgramData(t).bindGroups[r],c=s.createBindGroup({layout:u,entries:n});return this._hash[e._key]=c,c}destroy(){this._hash=null,this._renderer=null}}V.extension={type:[l.WebGPUSystem],name:"bindGroup"};class Me{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class N{constructor(e){this._renderer=e,this._managedBuffers=new D({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e}getGPUBuffer(e){var t;return e._gcLastUsed=this._renderer.gc.now,((t=e._gpuData[this._renderer.uid])==null?void 0:t.gpuBuffer)||this.createGPUBuffer(e)}updateBuffer(e){const t=this.getGPUBuffer(e),r=e.data;return e._updateID&&r&&(e._updateID=0,this._gpu.device.queue.writeBuffer(t,0,r.buffer,0,(e._updateSize||r.byteLength)+3&-4)),t}destroyAll(){this._managedBuffers.removeAll()}onBufferUnload(e){e.off("update",this.updateBuffer,this),e.off("change",this.onBufferChange,this)}createGPUBuffer(e){const t=this._gpu.device.createBuffer(e.descriptor);return e._updateID=0,e._resourceId=ce("resource"),e.data&&(de(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new Me(t),this._managedBuffers.add(e)&&(e.on("update",this.updateBuffer,this),e.on("change",this.onBufferChange,this)),t}onBufferChange(e){this._managedBuffers.remove(e),e._updateID=0,this.createGPUBuffer(e)}destroy(){this._managedBuffers.destroy(),this._renderer=null,this._gpu=null}}N.extension={type:[l.WebGPUSystem],name:"buffer"};class Re{constructor({minUniformOffsetAlignment:e}){this._minUniformOffsetAlignment=256,this.byteIndex=0,this._minUniformOffsetAlignment=e,this.data=new Float32Array(65535)}clear(){this.byteIndex=0}addEmptyGroup(e){if(e>this._minUniformOffsetAlignment/4)throw new Error(`UniformBufferBatch: array is too large: ${e*4}`);const t=this.byteIndex;let r=t+e*4;if(r=Math.ceil(r/this._minUniformOffsetAlignment)*this._minUniformOffsetAlignment,r>this.data.length*4)throw new Error("UniformBufferBatch: ubo batch got too big");return this.byteIndex=r,t}addGroup(e){const t=this.addEmptyGroup(e.length);for(let r=0;r<e.length;r++)this.data[t/4+r]=e[r];return t}destroy(){this.data=null}}class j{constructor(e){this._colorMaskCache=15,this._renderer=e}setMask(e){this._colorMaskCache!==e&&(this._colorMaskCache=e,this._renderer.pipeline.setColorMask(e))}destroy(){this._renderer=null,this._colorMaskCache=null}}j.extension={type:[l.WebGPUSystem],name:"colorMask"};class U{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>{this.gpu=t,this._renderer.runners.contextChange.emit(this.gpu)}),this._initPromise)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await B.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter}),r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r});return{adapter:t,device:s}}destroy(){this.gpu=null,this._renderer=null}}U.extension={type:[l.WebGPUSystem],name:"device"};U.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class K{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){this.endRenderPass(),this._clearCache(),this.renderPassEncoder=this.commandEncoder.beginRenderPass(e.descriptor)}endRenderPass(){this.renderPassEncoder&&this.renderPassEncoder.end(),this.renderPassEncoder=null}setViewport(e){this.renderPassEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setPipelineFromGeometryProgramAndState(e,t,r,s){const i=this._renderer.pipeline.getPipeline(e,t,r,s);this.setPipeline(i)}setPipeline(e){this._boundPipeline!==e&&(this._boundPipeline=e,this.renderPassEncoder.setPipeline(e))}_setVertexBuffer(e,t){this._boundVertexBuffer[e]!==t&&(this._boundVertexBuffer[e]=t,this.renderPassEncoder.setVertexBuffer(e,this._renderer.buffer.updateBuffer(t)))}_setIndexBuffer(e){if(this._boundIndexBuffer===e)return;this._boundIndexBuffer=e;const t=e.data.BYTES_PER_ELEMENT===2?"uint16":"uint32";this.renderPassEncoder.setIndexBuffer(this._renderer.buffer.updateBuffer(e),t)}resetBindGroup(e){this._boundBindGroup[e]=null}setBindGroup(e,t,r){if(this._boundBindGroup[e]===t)return;this._boundBindGroup[e]=t,t._touch(this._renderer.gc.now,this._renderer.tick);const s=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,s)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(const s in r)this._setVertexBuffer(parseInt(s,10),e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){for(const r in e.groups){const s=e.groups[r];t||this._syncBindGroup(s),this.setBindGroup(r,s,e.gpuProgram)}}_syncBindGroup(e){for(const t in e.resources){const r=e.resources[t];r.isUniformGroup&&this._renderer.ubo.updateUniformGroup(r)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:o,instanceCount:u,skipSync:c}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,c),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexBuffer.data.length,u??t.instanceCount,o||0):this.renderPassEncoder.draw(n||t.getSize(),u??t.instanceCount,o||0)}finishRenderPass(){this.renderPassEncoder&&(this.renderPassEncoder.end(),this.renderPassEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}restoreRenderPass(){const e=this._renderer.renderTarget.adaptor.getDescriptor(this._renderer.renderTarget.renderTarget,!1,[0,0,0,1],this._renderer.renderTarget.mipLevel,this._renderer.renderTarget.layer);this.renderPassEncoder=this.commandEncoder.beginRenderPass(e);const t=this._boundPipeline,r={...this._boundVertexBuffer},s=this._boundIndexBuffer,i={...this._boundBindGroup};this._clearCache();const n=this._renderer.renderTarget.viewport;this.renderPassEncoder.setViewport(n.x,n.y,n.width,n.height,0,1),this.setPipeline(t);for(const o in r)this._setVertexBuffer(o,r[o]);for(const o in i)this.setBindGroup(o,i[o],null);this._setIndexBuffer(s)}_clearCache(){for(let e=0;e<16;e++)this._boundBindGroup[e]=null,this._boundVertexBuffer[e]=null;this._boundIndexBuffer=null,this._boundPipeline=null}destroy(){this._renderer=null,this._gpu=null,this._boundBindGroup=null,this._boundVertexBuffer=null,this._boundIndexBuffer=null,this._boundPipeline=null}contextChange(e){this._gpu=e}}K.extension={type:[l.WebGPUSystem],name:"encoder",priority:1};class q{constructor(e){this._renderer=e}contextChange(){this.maxTextures=this._renderer.device.gpu.device.limits.maxSampledTexturesPerShaderStage,this.maxBatchableTextures=this.maxTextures}destroy(){}}q.extension={type:[l.WebGPUSystem],name:"limits"};class Y{constructor(e){this._renderTargetStencilState=Object.create(null),this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}onRenderTargetChange(e){let t=this._renderTargetStencilState[e.uid];t||(t=this._renderTargetStencilState[e.uid]={stencilMode:C.DISABLED,stencilReference:0}),this._activeRenderTarget=e,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._renderTargetStencilState[this._activeRenderTarget.uid];r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.renderPassEncoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._renderTargetStencilState=null}}Y.extension={type:[l.WebGPUSystem],name:"stencil"};const P={i32:{align:4,size:4},u32:{align:4,size:4},f32:{align:4,size:4},f16:{align:2,size:2},"vec2<i32>":{align:8,size:8},"vec2<u32>":{align:8,size:8},"vec2<f32>":{align:8,size:8},"vec2<f16>":{align:4,size:4},"vec3<i32>":{align:16,size:12},"vec3<u32>":{align:16,size:12},"vec3<f32>":{align:16,size:12},"vec3<f16>":{align:8,size:6},"vec4<i32>":{align:16,size:16},"vec4<u32>":{align:16,size:16},"vec4<f32>":{align:16,size:16},"vec4<f16>":{align:8,size:8},"mat2x2<f32>":{align:8,size:16},"mat2x2<f16>":{align:4,size:8},"mat3x2<f32>":{align:8,size:24},"mat3x2<f16>":{align:4,size:12},"mat4x2<f32>":{align:8,size:32},"mat4x2<f16>":{align:4,size:16},"mat2x3<f32>":{align:16,size:32},"mat2x3<f16>":{align:8,size:16},"mat3x3<f32>":{align:16,size:48},"mat3x3<f16>":{align:8,size:24},"mat4x3<f32>":{align:16,size:64},"mat4x3<f16>":{align:8,size:32},"mat2x4<f32>":{align:16,size:32},"mat2x4<f16>":{align:8,size:16},"mat3x4<f32>":{align:16,size:48},"mat3x4<f16>":{align:8,size:24},"mat4x4<f32>":{align:16,size:64},"mat4x4<f16>":{align:8,size:32}};function Ee(a){const e=a.map(r=>({data:r,offset:0,size:0}));let t=0;for(let r=0;r<e.length;r++){const s=e[r];let i=P[s.data.type].size;const n=P[s.data.type].align;if(!P[s.data.type])throw new Error(`[Pixi.js] WebGPU UniformBuffer: Unknown type ${s.data.type}`);s.data.size>1&&(i=Math.max(i,n)*s.data.size),t=Math.ceil(t/n)*n,s.size=i,s.offset=t,t+=i}return t=Math.ceil(t/16)*16,{uboElements:e,size:t}}function Le(a,e){const{size:t,align:r}=P[a.data.type],s=(r-t)/4,i=a.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
2
2
|
v = uv.${a.data.name};
|
|
3
3
|
${e!==0?`offset += ${e};`:""}
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{K as A,N as Z,P as g,ai as te,k as b,E as ie,ap as y,a4 as w,i as V}from"./index-Cf0rVPz-.js";import"./webworkerAll-Bs2LlyVn.js";import"./canvasUtils--etq-uaC.js";import"./Filter-DCFwFDCZ.js";class q{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=t.width/i*this._renderer.resolution,o=t.height/s*this._renderer.resolution,r=t.left,h=t.top,d=`translate(${r}px, ${h}px) scale(${n}, ${o})`;d!==this._lastTransform&&(this._domElement.style.transform=d,this._lastTransform=d)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const i=this.canvas.width,s=this.canvas.height,n=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||A.shared.add(this.updateTranslation,this,Z.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&A.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class O{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=O.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new g,this.page=new g,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var I=/iPhone/i,B=/iPod/i,C=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,k=/\bAndroid(?:.+)Mobile\b/i,R=/Android/i,E=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,M=/Silk/i,m=/Windows Phone/i,K=/\bWindows(?:.+)ARM\b/i,X=/BlackBerry/i,Y=/BB10/i,H=/Opera Mini/i,F=/\b(CriOS|Chrome)(?:.+)Mobile/i,N=/Mobile(?:.+)Firefox\b/i,$=function(a){return typeof a<"u"&&a.platform==="MacIntel"&&typeof a.maxTouchPoints=="number"&&a.maxTouchPoints>1&&typeof MSStream>"u"};function se(a){return function(e){return e.test(a)}}function G(a){var e={userAgent:"",platform:"",maxTouchPoints:0};!a&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof a=="string"?e.userAgent=a:a&&a.userAgent&&(e={userAgent:a.userAgent,platform:a.platform,maxTouchPoints:a.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var s=se(t),n={apple:{phone:s(I)&&!s(m),ipod:s(B),tablet:!s(I)&&(s(C)||$(e))&&!s(m),universal:s(U),device:(s(I)||s(B)||s(C)||s(U)||$(e))&&!s(m)},amazon:{phone:s(E),tablet:!s(E)&&s(M),device:s(E)||s(M)},android:{phone:!s(m)&&s(E)||!s(m)&&s(k),tablet:!s(m)&&!s(E)&&!s(k)&&(s(M)||s(R)),device:!s(m)&&(s(E)||s(M)||s(k)||s(R))||s(/\bokhttp\b/i)},windows:{phone:s(m),tablet:s(K),device:s(m)||s(K)},other:{blackberry:s(X),blackberry10:s(Y),opera:s(H),firefox:s(N),chrome:s(F),device:s(X)||s(Y)||s(H)||s(N)||s(F)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const ne=G.default??G,oe=ne(globalThis.navigator),re=9,W=100,ae=0,le=0,j=2,z=1,he=-1e3,ce=-1e3,de=2,L=class J{constructor(e,t=oe){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${z}px`,e.style.height=`${z}px`,e.style.position="absolute",e.style.top=`${he}px`,e.style.left=`${ce}px`,e.style.zIndex=de.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${ae}px`,this._div.style.left=`${le}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=j.toString(),this._canvasObserver=new q({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var e,t;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const i of this._children)(e=i._accessibleDiv)!=null&&e.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[i];(t=this._div)!=null&&t.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this._updateAccessibleObjects(t[i])}init(e){const i={accessibilityOptions:{...J.defaultOptions,...(e==null?void 0:e.accessibilityOptions)||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&t.add(this._children.indexOf(i))}for(let i=this._children.length-1;i>=0;i--){const s=this._children[i];t.has(i)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._getPool(s.accessibleType).push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,te(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const s=this._children[i];if(!s._accessibleActive||!s._accessibleDiv)continue;const n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){const r=s.worldTransform;n.style.left=`${r.tx+o.x*r.a}px`,n.style.top=`${r.ty+o.y*r.d}px`,n.style.width=`${o.width*r.a}px`,n.style.height=`${o.height*r.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let i=this._getPool(e.accessibleType).pop();i?(i.innerHTML="",i.removeAttribute("title"),i.removeAttribute("aria-label"),i.tabIndex=0):(e.accessibleType==="button"?i=document.createElement("button"):(i=document.createElement(e.accessibleType),i.style.cssText=`
|
|
1
|
+
import{K as A,N as Z,P as g,ai as te,k as b,E as ie,ap as y,a4 as w,i as V}from"./index-CINA8e_Z.js";import"./webworkerAll-D7azZfkM.js";import"./canvasUtils-Dmy9CrII.js";import"./Filter-ZZPoYeTC.js";class q{constructor(e){this._lastTransform="",this._observer=null,this._tickerAttached=!1,this.updateTranslation=()=>{if(!this._canvas)return;const t=this._canvas.getBoundingClientRect(),i=this._canvas.width,s=this._canvas.height,n=t.width/i*this._renderer.resolution,o=t.height/s*this._renderer.resolution,r=t.left,h=t.top,d=`translate(${r}px, ${h}px) scale(${n}, ${o})`;d!==this._lastTransform&&(this._domElement.style.transform=d,this._lastTransform=d)},this._domElement=e.domElement,this._renderer=e.renderer,!(globalThis.OffscreenCanvas&&this._renderer.canvas instanceof OffscreenCanvas)&&(this._canvas=this._renderer.canvas,this._attachObserver())}get canvas(){return this._canvas}ensureAttached(){!this._domElement.parentNode&&this._canvas.parentNode&&(this._canvas.parentNode.appendChild(this._domElement),this.updateTranslation())}_attachObserver(){"ResizeObserver"in globalThis?(this._observer&&(this._observer.disconnect(),this._observer=null),this._observer=new ResizeObserver(e=>{for(const t of e){if(t.target!==this._canvas)continue;const i=this.canvas.width,s=this.canvas.height,n=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/s*this._renderer.resolution;(this._lastScaleX!==n||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=n,this._lastScaleY=o)}}),this._observer.observe(this._canvas)):this._tickerAttached||A.shared.add(this.updateTranslation,this,Z.HIGH)}destroy(){this._observer?(this._observer.disconnect(),this._observer=null):this._tickerAttached&&A.shared.remove(this.updateTranslation),this._domElement=null,this._renderer=null,this._canvas=null,this._tickerAttached=!1,this._lastTransform="",this._lastScaleX=null,this._lastScaleY=null}}class O{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=O.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new g,this.page=new g,this.NONE=0,this.CAPTURING_PHASE=1,this.AT_TARGET=2,this.BUBBLING_PHASE=3,this.manager=e}get layerX(){return this.layer.x}get layerY(){return this.layer.y}get pageX(){return this.page.x}get pageY(){return this.page.y}get data(){return this}composedPath(){return this.manager&&(!this.path||this.path[this.path.length-1]!==this.target)&&(this.path=this.target?this.manager.propagationPath(this.target):[]),this.path}initEvent(e,t,i){throw new Error("initEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}initUIEvent(e,t,i,s,n){throw new Error("initUIEvent() is a legacy DOM API. It is not implemented in the Federated Events API.")}preventDefault(){this.nativeEvent instanceof Event&&this.nativeEvent.cancelable&&this.nativeEvent.preventDefault(),this.defaultPrevented=!0}stopImmediatePropagation(){this.propagationImmediatelyStopped=!0}stopPropagation(){this.propagationStopped=!0}}var I=/iPhone/i,B=/iPod/i,C=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,k=/\bAndroid(?:.+)Mobile\b/i,R=/Android/i,E=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,M=/Silk/i,m=/Windows Phone/i,K=/\bWindows(?:.+)ARM\b/i,X=/BlackBerry/i,Y=/BB10/i,H=/Opera Mini/i,F=/\b(CriOS|Chrome)(?:.+)Mobile/i,N=/Mobile(?:.+)Firefox\b/i,$=function(a){return typeof a<"u"&&a.platform==="MacIntel"&&typeof a.maxTouchPoints=="number"&&a.maxTouchPoints>1&&typeof MSStream>"u"};function se(a){return function(e){return e.test(a)}}function G(a){var e={userAgent:"",platform:"",maxTouchPoints:0};!a&&typeof navigator<"u"?e={userAgent:navigator.userAgent,platform:navigator.platform,maxTouchPoints:navigator.maxTouchPoints||0}:typeof a=="string"?e.userAgent=a:a&&a.userAgent&&(e={userAgent:a.userAgent,platform:a.platform,maxTouchPoints:a.maxTouchPoints||0});var t=e.userAgent,i=t.split("[FBAN");typeof i[1]<"u"&&(t=i[0]),i=t.split("Twitter"),typeof i[1]<"u"&&(t=i[0]);var s=se(t),n={apple:{phone:s(I)&&!s(m),ipod:s(B),tablet:!s(I)&&(s(C)||$(e))&&!s(m),universal:s(U),device:(s(I)||s(B)||s(C)||s(U)||$(e))&&!s(m)},amazon:{phone:s(E),tablet:!s(E)&&s(M),device:s(E)||s(M)},android:{phone:!s(m)&&s(E)||!s(m)&&s(k),tablet:!s(m)&&!s(E)&&!s(k)&&(s(M)||s(R)),device:!s(m)&&(s(E)||s(M)||s(k)||s(R))||s(/\bokhttp\b/i)},windows:{phone:s(m),tablet:s(K),device:s(m)||s(K)},other:{blackberry:s(X),blackberry10:s(Y),opera:s(H),firefox:s(N),chrome:s(F),device:s(X)||s(Y)||s(H)||s(N)||s(F)},any:!1,phone:!1,tablet:!1};return n.any=n.apple.device||n.android.device||n.windows.device||n.other.device,n.phone=n.apple.phone||n.android.phone||n.windows.phone,n.tablet=n.apple.tablet||n.android.tablet||n.windows.tablet,n}const ne=G.default??G,oe=ne(globalThis.navigator),re=9,W=100,ae=0,le=0,j=2,z=1,he=-1e3,ce=-1e3,de=2,L=class J{constructor(e,t=oe){this._mobileInfo=t,this.debug=!1,this._activateOnTab=!0,this._deactivateOnMouseMove=!0,this._isActive=!1,this._isMobileAccessibility=!1,this._div=null,this._pools={},this._renderId=0,this._children=[],this._androidUpdateCount=0,this._androidUpdateFrequency=500,this._isRunningTests=!1,this._boundOnKeyDown=this._onKeyDown.bind(this),this._boundOnMouseMove=this._onMouseMove.bind(this),this._hookDiv=null,(t.tablet||t.phone)&&this._createTouchHook(),this._renderer=e}get isActive(){return this._isActive}get isMobileAccessibility(){return this._isMobileAccessibility}get hookDiv(){return this._hookDiv}get div(){return this._div}_createTouchHook(){const e=document.createElement("button");e.style.width=`${z}px`,e.style.height=`${z}px`,e.style.position="absolute",e.style.top=`${he}px`,e.style.left=`${ce}px`,e.style.zIndex=de.toString(),e.style.backgroundColor="#FF0000",e.title="select to enable accessibility for this content",e.addEventListener("focus",()=>{this._isMobileAccessibility=!0,this._activate(),this._destroyTouchHook()}),document.body.appendChild(e),this._hookDiv=e}_destroyTouchHook(){this._hookDiv&&(document.body.removeChild(this._hookDiv),this._hookDiv=null)}_activate(){if(this._isActive)return;this._isActive=!0,this._div||(this._div=document.createElement("div"),this._div.style.position="absolute",this._div.style.top=`${ae}px`,this._div.style.left=`${le}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=j.toString(),this._canvasObserver=new q({domElement:this._div,renderer:this._renderer})),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._deactivateOnMouseMove&&globalThis.document.addEventListener("mousemove",this._boundOnMouseMove,!0);const e=this._renderer.view.canvas;if(e.parentNode)this._canvasObserver.ensureAttached(),this._initAccessibilitySetup();else{const t=new MutationObserver(()=>{e.parentNode&&(t.disconnect(),this._canvasObserver.ensureAttached(),this._initAccessibilitySetup())});t.observe(document.body,{childList:!0,subtree:!0})}}_initAccessibilitySetup(){this._renderer.runners.postrender.add(this),this._renderer.lastObjectRendered&&this._updateAccessibleObjects(this._renderer.lastObjectRendered)}_deactivate(){var e,t;if(!(!this._isActive||this._isMobileAccessibility)){this._isActive=!1,globalThis.document.removeEventListener("mousemove",this._boundOnMouseMove,!0),this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),this._renderer.runners.postrender.remove(this);for(const i of this._children)(e=i._accessibleDiv)!=null&&e.parentNode&&(i._accessibleDiv.parentNode.removeChild(i._accessibleDiv),i._accessibleDiv=null),i._accessibleActive=!1;for(const i in this._pools)this._pools[i].forEach(n=>{n.parentNode&&n.parentNode.removeChild(n)}),delete this._pools[i];(t=this._div)!=null&&t.parentNode&&this._div.parentNode.removeChild(this._div),this._pools={},this._children=[]}}_updateAccessibleObjects(e){if(!e.visible||!e.accessibleChildren)return;e.accessible&&(e._accessibleActive||this._addChild(e),e._renderId=this._renderId);const t=e.children;if(t)for(let i=0;i<t.length;i++)this._updateAccessibleObjects(t[i])}init(e){const i={accessibilityOptions:{...J.defaultOptions,...(e==null?void 0:e.accessibilityOptions)||{}}};this.debug=i.accessibilityOptions.debug,this._activateOnTab=i.accessibilityOptions.activateOnTab,this._deactivateOnMouseMove=i.accessibilityOptions.deactivateOnMouseMove,i.accessibilityOptions.enabledByDefault&&this._activate(),this._renderer.runners.postrender.remove(this)}postrender(){const e=performance.now();if(this._mobileInfo.android.device&&e<this._androidUpdateCount||(this._androidUpdateCount=e+this._androidUpdateFrequency,(!this._renderer.renderingToScreen||!this._renderer.view.canvas)&&!this._isRunningTests))return;const t=new Set;if(this._renderer.lastObjectRendered){this._updateAccessibleObjects(this._renderer.lastObjectRendered);for(const i of this._children)i._renderId===this._renderId&&t.add(this._children.indexOf(i))}for(let i=this._children.length-1;i>=0;i--){const s=this._children[i];t.has(i)||(s._accessibleDiv&&s._accessibleDiv.parentNode&&(s._accessibleDiv.parentNode.removeChild(s._accessibleDiv),this._getPool(s.accessibleType).push(s._accessibleDiv),s._accessibleDiv=null),s._accessibleActive=!1,te(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const s=this._children[i];if(!s._accessibleActive||!s._accessibleDiv)continue;const n=s._accessibleDiv,o=s.hitArea||s.getBounds().rectangle;if(s.hitArea){const r=s.worldTransform;n.style.left=`${r.tx+o.x*r.a}px`,n.style.top=`${r.ty+o.y*r.d}px`,n.style.width=`${o.width*r.a}px`,n.style.height=`${o.height*r.d}px`}else this._capHitArea(o),n.style.left=`${o.x}px`,n.style.top=`${o.y}px`,n.style.width=`${o.width}px`,n.style.height=`${o.height}px`}this._renderId++}_updateDebugHTML(e){e.innerHTML=`type: ${e.type}</br> title : ${e.title}</br> tabIndex: ${e.tabIndex}`}_capHitArea(e){e.x<0&&(e.width+=e.x,e.x=0),e.y<0&&(e.height+=e.y,e.y=0);const{width:t,height:i}=this._renderer;e.x+e.width>t&&(e.width=t-e.x),e.y+e.height>i&&(e.height=i-e.y)}_addChild(e){let i=this._getPool(e.accessibleType).pop();i?(i.innerHTML="",i.removeAttribute("title"),i.removeAttribute("aria-label"),i.tabIndex=0):(e.accessibleType==="button"?i=document.createElement("button"):(i=document.createElement(e.accessibleType),i.style.cssText=`
|
|
2
2
|
color: transparent;
|
|
3
3
|
pointer-events: none;
|
|
4
4
|
padding: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{D as y,h as I,af as C}from"./index-
|
|
1
|
+
import{D as y,h as I,af as C}from"./index-CINA8e_Z.js";let m;function x(s){const e=y.get().createCanvas(6,1),n=e.getContext("2d");return n.fillStyle=s,n.fillRect(0,0,6,1),e}function M(){if(m!==void 0)return m;try{const s=x("#ff00ff"),e=x("#ffff00"),a=y.get().createCanvas(6,1).getContext("2d");a.globalCompositeOperation="multiply",a.drawImage(s,0,0),a.drawImage(e,2,0);const t=a.getImageData(2,0,1,1);if(!t)m=!1;else{const o=t.data;m=o[0]===255&&o[1]===0&&o[2]===0}}catch{m=!1}return m}const h={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,canUseMultiply:M(),tintMethod:null,_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:s=>{const e=s.source,n=e==null?void 0:e.resource;if(!n)return null;const a=e.alphaMode==="premultiplied-alpha",t=e.resourceWidth??e.pixelWidth,o=e.resourceHeight??e.pixelHeight,l=t!==e.pixelWidth||o!==e.pixelHeight;if(a){if((n instanceof HTMLCanvasElement||typeof OffscreenCanvas<"u"&&n instanceof OffscreenCanvas)&&!l)return n;const i=h._unpremultipliedCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas}if(n instanceof Uint8Array||n instanceof Uint8ClampedArray||n instanceof Int8Array||n instanceof Uint16Array||n instanceof Int16Array||n instanceof Uint32Array||n instanceof Int32Array||n instanceof Float32Array||n instanceof ArrayBuffer){const i=h._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const r=y.get().createCanvas(e.pixelWidth,e.pixelHeight),g=r.getContext("2d"),c=g.createImageData(e.pixelWidth,e.pixelHeight),d=c.data,f=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(e.format==="bgra8unorm")for(let u=0;u<d.length&&u+3<f.length;u+=4)d[u]=f[u+2],d[u+1]=f[u+1],d[u+2]=f[u],d[u+3]=f[u+3];else d.set(f.subarray(0,d.length));return g.putImageData(c,0,0),h._canvasSourceCache.set(e,{canvas:r,resourceId:e._resourceId}),r}if(a){const i=y.get().createCanvas(e.pixelWidth,e.pixelHeight),r=i.getContext("2d",{willReadFrequently:!0});i.width=e.pixelWidth,i.height=e.pixelHeight,r.drawImage(n,0,0);const g=r.getImageData(0,0,i.width,i.height),c=g.data;for(let d=0;d<c.length;d+=4){const f=c[d+3];if(f>0){const u=255/f;c[d]=Math.min(255,c[d]*u+.5),c[d+1]=Math.min(255,c[d+1]*u+.5),c[d+2]=Math.min(255,c[d+2]*u+.5)}}return r.putImageData(g,0,0),h._unpremultipliedCache.set(e,{canvas:i,resourceId:e._resourceId}),i}if(l){const i=h._canvasSourceCache.get(e);if((i==null?void 0:i.resourceId)===e._resourceId)return i.canvas;const r=y.get().createCanvas(e.pixelWidth,e.pixelHeight),g=r.getContext("2d");return r.width=e.pixelWidth,r.height=e.pixelHeight,g.drawImage(n,0,0),h._canvasSourceCache.set(e,{canvas:r,resourceId:e._resourceId}),r}return n},getTintedCanvas:(s,e)=>{const n=s.texture,a=I.shared.setValue(e).toHex(),t=n.tintCache||(n.tintCache={}),o=t[a],l=n.source._resourceId;if((o==null?void 0:o.tintId)===l)return o;const i=o&&"getContext"in o?o:y.get().createCanvas();return h.tintMethod(n,e,i),i.tintId=l,t[a]=i,t[a]},getTintedPattern:(s,e)=>{const n=I.shared.setValue(e).toHex(),a=s.patternCache||(s.patternCache={}),t=s.source._resourceId;let o=a[n];return(o==null?void 0:o.tintId)===t||(h.canvas||(h.canvas=y.get().createCanvas()),h.tintMethod(s,e,h.canvas),o=h.canvas.getContext("2d").createPattern(h.canvas,"repeat"),o.tintId=t,a[n]=o),o},applyPatternTransform:(s,e,n=!0)=>{if(!e)return;const a=s;if(!a.setTransform)return;const t=globalThis.DOMMatrix;if(!t)return;const o=new t([e.a,e.b,e.c,e.d,e.tx,e.ty]);a.setTransform(n?o.inverse():o)},tintWithMultiply:(s,e,n)=>{const a=n.getContext("2d"),t=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,l=s.rotate;t.x*=o,t.y*=o,t.width*=o,t.height*=o;const i=C.isVertical(l),r=i?t.height:t.width,g=i?t.width:t.height;n.width=Math.ceil(r),n.height=Math.ceil(g),a.save(),a.fillStyle=I.shared.setValue(e).toHex(),a.fillRect(0,0,r,g),a.globalCompositeOperation="multiply";const c=h.getCanvasSource(s);if(!c){a.restore();return}l&&h._applyInverseRotation(a,l,t.width,t.height),a.drawImage(c,t.x,t.y,t.width,t.height,0,0,t.width,t.height),a.globalCompositeOperation="destination-atop",a.drawImage(c,t.x,t.y,t.width,t.height,0,0,t.width,t.height),a.restore()},tintWithOverlay:(s,e,n)=>{const a=n.getContext("2d"),t=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,l=s.rotate;t.x*=o,t.y*=o,t.width*=o,t.height*=o;const i=C.isVertical(l),r=i?t.height:t.width,g=i?t.width:t.height;n.width=Math.ceil(r),n.height=Math.ceil(g),a.save(),a.globalCompositeOperation="copy",a.fillStyle=I.shared.setValue(e).toHex(),a.fillRect(0,0,r,g),a.globalCompositeOperation="destination-atop";const c=h.getCanvasSource(s);if(!c){a.restore();return}l&&h._applyInverseRotation(a,l,t.width,t.height),a.drawImage(c,t.x,t.y,t.width,t.height,0,0,t.width,t.height),a.restore()},tintWithPerPixel:(s,e,n)=>{const a=n.getContext("2d"),t=s.frame.clone(),o=s.source._resolution??s.source.resolution??1,l=s.rotate;t.x*=o,t.y*=o,t.width*=o,t.height*=o;const i=C.isVertical(l),r=i?t.height:t.width,g=i?t.width:t.height;n.width=Math.ceil(r),n.height=Math.ceil(g),a.save(),a.globalCompositeOperation="copy";const c=h.getCanvasSource(s);if(!c){a.restore();return}l&&h._applyInverseRotation(a,l,t.width,t.height),a.drawImage(c,t.x,t.y,t.width,t.height,0,0,t.width,t.height),a.restore();const d=e>>16&255,f=e>>8&255,u=e&255,w=a.getImageData(0,0,r,g),v=w.data;for(let p=0;p<v.length;p+=4)v[p]=v[p]*d/255,v[p+1]=v[p+1]*f/255,v[p+2]=v[p+2]*u/255;a.putImageData(w,0,0)},_applyInverseRotation:(s,e,n,a)=>{const t=C.inv(e),o=C.uX(t),l=C.uY(t),i=C.vX(t),r=C.vY(t),g=-Math.min(0,o*n,i*a,o*n+i*a),c=-Math.min(0,l*n,r*a,l*n+r*a);s.transform(o,l,i,r,g,c)}};h.tintMethod=h.canUseMultiply?h.tintWithMultiply:h.tintWithPerPixel;export{h as a,M as c};
|