@setupsworks/office 0.7.5 → 0.7.6
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/README.md +3 -3
- package/dist/assets/{CanvasPool-D8o5qooo.js → CanvasPool-DxzlD0_z.js} +1 -1
- package/dist/assets/{CanvasRenderer-6iBTvAyb.js → CanvasRenderer-n415agIi.js} +1 -1
- package/dist/assets/{RenderTargetSystem-R9NN3Lf_.js → RenderTargetSystem-CAgQLo6K.js} +1 -1
- package/dist/assets/{WebGLRenderer-BceHugHE.js → WebGLRenderer-tfepD2rr.js} +1 -1
- package/dist/assets/{WebGPURenderer-B-kl5Onz.js → WebGPURenderer-CMWrBDWU.js} +1 -1
- package/dist/assets/{browserAll-CXCccwgI.js → browserAll-CU-8rI48.js} +1 -1
- package/dist/assets/{canvasUtils-Cbq_vt2i.js → canvasUtils-LeZLwOlL.js} +1 -1
- package/dist/assets/{getTexelRangeRects-DY8vmJhl.js → getTexelRangeRects-DhWvqmbJ.js} +1 -1
- package/dist/assets/{index-ByCDDgCj.js → index-CMIifH9a.js} +23 -23
- package/dist/assets/index-DqjpxGKf.css +1 -0
- package/dist/assets/{webworkerAll-CkYM11AB.js → webworkerAll-B8F2O1DY.js} +1 -1
- package/dist/index.html +2 -2
- package/dist-server/main.mjs +31 -14
- package/package.json +6 -2
- package/dist/assets/index-CmC5xWQz.css +0 -1
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
[](LICENSE)
|
|
7
7
|
[](https://nodejs.org)
|
|
8
8
|
|
|
9
|
-

|
|
10
10
|
|
|
11
11
|
One **lead** agent plans the work and hands out tasks. Each **worker** gets its own desk, its own copy of your repo and its own Docker Sandbox, then opens a pull request. You see it all happen: the plan on the wall, agents at their desks, PRs moving through review.
|
|
12
12
|
|
|
@@ -72,7 +72,7 @@ You don't need to install these by hand first. HQ checks for each one and shows
|
|
|
72
72
|
|
|
73
73
|
## How it works
|
|
74
74
|
|
|
75
|
-

|
|
76
76
|
|
|
77
77
|
1. **You tell the lead what to build.** It creates a board of small tasks, each with the files it may touch, and assigns them.
|
|
78
78
|
2. **Workers build in their own sandboxes.** Each one pulls `main`, makes a branch, writes the code and opens a PR titled `[TASK-ID] …`.
|
|
@@ -99,7 +99,7 @@ More detail on workspaces, sandboxes, MCP servers, app variables and what HQ sav
|
|
|
99
99
|
| Windows: `listen EACCES` on start | Windows reserved that port. Use `--port 8420`. |
|
|
100
100
|
| `posix_spawnp failed` when opening a terminal | Run `npx clear-npx-cache`, then `npx @setupsworks/office@latest`. |
|
|
101
101
|
|
|
102
|
-
**Remove a project:** delete each agent in Settings → Team (this removes its sandbox and, if you choose, its folder), then delete `~/.
|
|
102
|
+
**Remove a project:** delete each agent in Settings → Team (this removes its sandbox and, if you choose, its folder), then delete `~/.swoffic/<project>`.
|
|
103
103
|
|
|
104
104
|
## Docs
|
|
105
105
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as _,a as S,G as m,b as w,c as C,d as u,v as g,D as x,w as F,n as p,i as b,e as k}from"./index-
|
|
1
|
+
import{S as _,a as S,G as m,b as w,c as C,d as u,v as g,D as x,w as F,n as p,i as b,e as k}from"./index-CMIifH9a.js";const v=class o extends _{constructor(e){e={...o.defaultOptions,...e},super(e),this.enabled=!0,this._state=S.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,s,t,n){e.applyFilter(this,s,t,n)}get blendMode(){return this._state.blendMode}set blendMode(e){this._state.blendMode=e}static from(e){const{gpu:s,gl:t,...n}=e;let i,a;return s&&(i=m.from(s)),t&&(a=w.from(t)),new o({gpuProgram:i,glProgram:a,...n})}};v.defaultOptions={blendMode:"normal",resolution:1,padding:0,antialias:"off",blendRequired:!1,clipToViewport:!0};let R=v;const c=32767;function f(h,e){return(h<<17)+(e<<2)}class M{constructor(e){this._buckets=new Map,this._screens=new C,this._enableFullScreen=!1,this.canvasOptions=e||{}}get enableFullScreen(){return u(g,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen}set enableFullScreen(e){u(g,"CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize."),this._enableFullScreen=e}_createCanvasAndContext(e,s){const t=x.get().createCanvas();t.width=e,t.height=s;const n=t.getContext("2d");return{canvas:t,context:n}}getOptimalCanvasAndContext(e,s,t=1){const{width:n,height:i}=this.getOptimalSize(e,s,t);(n>c||i>c)&&F(`CanvasPool: ${n}x${i} is larger than the ${c}px pool key limit, canvases of this size may be pooled together`);const a=f(n,i);let r=this._buckets.get(a);r||(r=[],this._buckets.set(a,r));let l=r.pop();return l||(l=this._createCanvasAndContext(n,i)),l}getOptimalSize(e,s,t=1){const n=Math.ceil(e*t-1e-6),i=Math.ceil(s*t-1e-6),a=p(n),r=this._screens.getFittingWidth(n),l=p(i),d=this._screens.getFittingHeight(i);return{width:r!==void 0?Math.min(r,a):a,height:d!==void 0?Math.min(d,l):l}}returnCanvasAndContext(e){const s=e.canvas,{width:t,height:n}=s,i=this._buckets.get(f(t,n));i&&(e.context.resetTransform(),e.context.clearRect(0,0,t,n),i.push(e))}setScreenSize(e,s,t){this._screens.set(e,s,t)&&this._pruneScreenCanvases()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(const[e]of this._buckets){const s=e>>>17,t=e>>>2&32767;(b(s)||this._screens.hasWidth(s))&&(b(t)||this._screens.hasHeight(t))||this._buckets.delete(e)}}}const y=new M;k.register(y);export{y as C,R as F};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{g as Se,l as Me,m as oe,M as G,o as S,p as Xe,w as we,s as Re,q as Ie,C as Ae,T as Be,r as ze,F as Je,t as Ke,x as Qe,D as He,A as Ze,R as et,y as ne}from"./index-ByCDDgCj.js";import{R as tt,S as st,B as nt,a as at,b as rt,c as ot,A as it,C as ct}from"./RenderTargetSystem-R9NN3Lf_.js";import{c as P,a as lt}from"./canvasUtils-Cbq_vt2i.js";import"./CanvasPool-D8o5qooo.js";const ge=class X{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 c,i,l,u;const s=t.elements;if(!s||!s.length)return;const n=e.renderer,r=n.canvasContext,o=r.activeContext;for(let x=0;x<s.length;x++){const E=s[x];if(!E.packAsQuad)continue;const v=E,f=v.texture,M=f?P.getCanvasSource(f):null;if(!M)continue;const y=f.source.style,A=r.smoothProperty,Y=y.scaleMode!=="nearest";o[A]!==Y&&(o[A]=Y),r.setBlendMode(t.blendMode);const U=((c=n.globalUniforms.globalUniformData)==null?void 0:c.worldColor)??4294967295,W=v.color,k=(U>>>24&255)/255,C=(W>>>24&255)/255,V=((i=n.filter)==null?void 0:i.alphaMultiplier)??1,Q=k*C*V;if(Q<=0)continue;o.globalAlpha=Q;const Z=U&16777215,z=W&16777215,_=Me(oe(z,Z)),w=f.frame,R=y.addressModeU??y.addressMode,ce=y.addressModeV??y.addressMode,ee=X._getPatternRepeat(R,ce),q=f.source._resolution??f.source.resolution??1,$=(u=(l=v.renderable)==null?void 0:l.renderGroup)==null?void 0:u.isCachedAsTexture,p=w.x*q,m=w.y*q,g=w.width*q,L=w.height*q,I=v.bounds,b=n.renderTarget.renderTarget.isRoot,D=I.minX,F=I.minY,B=I.maxX-I.minX,H=I.maxY-I.minY,N=f.rotate,h=f.uvs,O=Math.min(h.x0,h.x1,h.x2,h.x3,h.y0,h.y1,h.y2,h.y3),j=Math.max(h.x0,h.x1,h.x2,h.x3,h.y0,h.y1,h.y2,h.y3),T=ee!=="no-repeat"&&(O<0||j>1),ae=N&&!(!T&&(_!==16777215||N));ae?(X._tempPatternMatrix.copyFrom(v.transform),Se.matrixAppendRotationInv(X._tempPatternMatrix,N,D,F,B,H),r.setContextTransform(X._tempPatternMatrix,v.roundPixels===1,void 0,$&&b)):r.setContextTransform(v.transform,v.roundPixels===1,void 0,$&&b);const le=B,he=H;let te=ae?0:D,se=ae?0:F;if(!ae&&v.roundPixels===1&&(te|=0,se|=0),T){let de=M;const J=_!==16777215&&!N,K=w.width<=f.source.width&&w.height<=f.source.height;J&&K&&(de=P.getTintedCanvas({texture:f},_));const pe=o.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=(h.x1-h.x0)*Ce,ke=(h.y1-h.y0)*Ce,_e=(h.x3-h.x0)*Te,be=(h.y3-h.y0)*Te,Ve=h.x0-Pe*te-_e*se,$e=h.y0-ke*te-be*se,ue=f.source.pixelWidth,me=f.source.pixelHeight;X._tempPatternMatrix.set(Pe*ue,ke*me,_e*ue,be*me,Ve*ue,$e*me),P.applyPatternTransform(pe,X._tempPatternMatrix),o.fillStyle=pe,o.fillRect(te,se,le,he)}else{const J=_!==16777215||N?P.getTintedCanvas({texture:f},_):M,K=J!==M;o.drawImage(J,K?0:p,K?0:m,K?J.width:g,K?J.height:L,te,se,le,he)}}}};ge._tempPatternMatrix=new G;ge.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let ht=ge;class Ge{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 r=this._colorStack[this._colorStackIndex];r!==this._currentColor&&(this._currentColor=r,s.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const r=n[this._colorStackIndex-1];r!==this._currentColor&&(this._currentColor=r,s.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}Ge.extension={type:[S.CanvasPipes],name:"colorMask"};function dt(a,e,t,s,n,r){r=Math.max(0,Math.min(r,Math.min(s,n)/2)),a.moveTo(e+r,t),a.lineTo(e+s-r,t),a.quadraticCurveTo(e+s,t,e+s,t+r),a.lineTo(e+s,t+n-r),a.quadraticCurveTo(e+s,t+n,e+s-r,t+n),a.lineTo(e+r,t+n),a.quadraticCurveTo(e,t+n,e,t+n-r),a.lineTo(e,t+r),a.quadraticCurveTo(e,t,e+r,t)}function Ee(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;dt(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 pt(a,e,t){const s=[],n=[],r=[],o=Re[e.type];if(!(o!=null&&o.build(e,s)))return!1;const c=e.closePath??!0;Ie(s,t,!1,c,n,r);for(let i=0;i<r.length;i+=3){const l=r[i]*2,u=r[i+1]*2,x=r[i+2]*2;a.moveTo(n[l],n[l+1]),a.lineTo(n[u],n[u+1]),a.lineTo(n[x],n[x+1]),a.closePath()}return!0}function ut(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,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ee(a,s.shape),r&&a.restore()}return!0}class We{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 u,x,E;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 r=e.mask.mask;if(!(r instanceof Xe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const o=r,c=(u=o.context)==null?void 0:u.instructions;if(!(c!=null&&c.length)){this._canvasMaskStack.push(!1);return}n.save(),s.setContextTransform(o.groupTransform,(t._roundPixels|o._roundPixels)===1),n.beginPath();let i=!1,l=!1;for(let v=0;v<c.length;v++){const f=c[v],M=f.action;if(M!=="fill"&&M!=="stroke")continue;const y=f.data,A=(x=y==null?void 0:y.path)==null?void 0:x.shapePath;if(!((E=A==null?void 0:A.shapePrimitives)!=null&&E.length))continue;const Y=M==="stroke",U=A.shapePrimitives;for(let W=0;W<U.length;W++){const k=U[W];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&&y.style?i=pt(n,k.shape,y.style)||i:(Ee(n,k.shape),l=ut(n,k.holes)||l,i=!0),V&&n.restore()}}if(!i){n.restore(),this._canvasMaskStack.push(!1);return}l?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),we(t))}}We.extension={type:[S.CanvasPipes],name:"stencilMask"};const d="source-over";function mt(){const a=lt(),e=Object.create(null);return e.inherit=d,e.none=d,e.normal="source-over",e.add="lighter",e.multiply=a?"multiply":d,e.screen=a?"screen":d,e.overlay=a?"overlay":d,e.darken=a?"darken":d,e.lighten=a?"lighten":d,e["color-dodge"]=a?"color-dodge":d,e["color-burn"]=a?"color-burn":d,e["hard-light"]=a?"hard-light":d,e["soft-light"]=a?"soft-light":d,e.difference=a?"difference":d,e.exclusion=a?"exclusion":d,e.saturation=a?"saturation":d,e.color=a?"color":d,e.luminosity=a?"luminosity":d,e["linear-burn"]=a?"color-burn":d,e["linear-dodge"]=a?"color-dodge":d,e["linear-light"]=a?"hard-light":d,e["pin-light"]=a?"hard-light":d,e["vivid-light"]=a?"hard-light":d,e["hard-mix"]=d,e.negation=a?"difference":d,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=d,e.divide=d,e.min=d,e.max=d,e}const ft=new G;class De{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=mt(),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 l;const r=n?G.IDENTITY:((l=this._renderer.globalUniforms.globalUniformData)==null?void 0:l.worldTransformMatrix)||G.IDENTITY;let o=ft;o.copyFrom(r),o.append(e);const c=this._projTransform,i=this.activeResolution;if(s=s||i,c){const u=G.shared;u.copyFrom(o),u.prepend(c),o=u}t?this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*i|0,o.ty*i|0):this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*i,o.ty*i)}clear(e,t){const s=this.activeContext,n=this._renderer;if(s.clearRect(0,0,n.width,n.height),e){const r=Ae.shared.setValue(e);s.globalAlpha=t??r.alpha,s.fillStyle=r.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()}}De.extension={type:[S.CanvasSystem],name:"canvasContext"};class Fe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Fe.extension={type:[S.CanvasSystem],name:"limits"};const gt="#808080",re=new G,vt=new G,yt=new G,fe=new G,xt=new G;function Ct(a,e,t){a.beginPath();for(let s=0;s<t.length;s+=3){const n=t[s]*2,r=t[s+1]*2,o=t[s+2]*2;a.moveTo(e[n],e[n+1]),a.lineTo(e[r],e[r+1]),a.lineTo(e[o],e[o+1]),a.closePath()}a.fill()}function Tt(a){return`#${(a&16777215).toString(16).padStart(6,"0")}`}function Pt(a,e,t,s,n,r){r=Math.max(0,Math.min(r,Math.min(s,n)/2)),a.moveTo(e+r,t),a.lineTo(e+s-r,t),a.quadraticCurveTo(e+s,t,e+s,t+r),a.lineTo(e+s,t+n-r),a.quadraticCurveTo(e+s,t+n,e+s-r,t+n),a.lineTo(e+r,t+n),a.quadraticCurveTo(e,t+n,e,t+n-r),a.lineTo(e,t+r),a.quadraticCurveTo(e,t,e+r,t)}function ie(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;Pt(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 kt(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,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),ie(a,s.shape),r&&a.restore()}return!0}function _t(a,e,t,s){const n=a.fill;if(n instanceof Je){n.buildGradient();const o=n.texture;if(o){const c=P.getTintedPattern(o,e),i=t?fe.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):fe.copyFrom(n.transform);return s&&!a.textureSpace&&i.append(s),P.applyPatternTransform(c,i),c}}if(n instanceof Ke){const o=P.getTintedPattern(n.texture,e);return P.applyPatternTransform(o,n.transform,!1),o}const r=a.texture;if(r&&r!==Be.WHITE){if(!r.source.resource)return gt;const o=P.getTintedPattern(r,e);let c=a.matrix;if(t){const{resolution:i}=r.source;if(c=fe.copyFrom(t),r.rotate){const{uvs:l,orig:u}=r;c.prepend(xt.set(l.x1-l.x0,l.y1-l.y0,l.x3-l.x0,l.y3-l.y0,l.x0,l.y0).invert()).scale(u.width*i,u.height*i)}else c.scale(r.source.pixelWidth,r.source.pixelHeight).translate(-r.frame.x*i,-r.frame.y*i)}return P.applyPatternTransform(o,c),o}return Tt(e)}class Ue{constructor(){this.shader=null}contextChange(e){}execute(e,t){var Y,U,W,k,C,V,Q;const s=e.renderer,n=s.canvasContext,r=n.activeContext,o=t.groupTransform,c=((Y=s.globalUniforms.globalUniformData)==null?void 0:Y.worldColor)??4294967295,i=t.groupColorAlpha,l=(c>>>24&255)/255,u=(i>>>24&255)/255,x=((U=s.filter)==null?void 0:U.alphaMultiplier)??1,E=l*u*x;if(E<=0)return;const v=c&16777215,f=i&16777215,M=Me(oe(f,v)),y=s._roundPixels|t._roundPixels;r.save(),n.setContextTransform(o,y===1),n.setBlendMode(t.groupBlendMode);const A=t.context.instructions;for(let Z=0;Z<A.length;Z++){const z=A[Z];if(z.action==="texture"){const p=z.data,m=p.image,g=m?P.getCanvasSource(m):null;if(!g)continue;const L=p.alpha*E;if(L<=0)continue;const I=oe(p.style,M);r.globalAlpha=L;let b=g;I!==16777215&&(b=P.getTintedCanvas({texture:m},I));const D=m.frame,F=m.source._resolution??m.source.resolution??1;let B=D.x*F,H=D.y*F;const N=D.width*F,h=D.height*F;b!==g&&(B=0,H=0);const O=p.transform,j=O&&!O.isIdentity(),T=m.rotate;j||T?(re.copyFrom(o),j&&re.append(O),T&&Se.matrixAppendRotationInv(re,T,p.dx,p.dy,p.dw,p.dh),n.setContextTransform(re,y===1)):n.setContextTransform(o,y===1),r.drawImage(b,B,H,b===g?N:b.width,b===g?h:b.height,T?0:p.dx,T?0:p.dy,p.dw,p.dh),(j||T)&&n.setContextTransform(o,y===1);continue}const _=z.data,w=(W=_==null?void 0:_.path)==null?void 0:W.shapePath;if(!((k=w==null?void 0:w.shapePrimitives)!=null&&k.length))continue;const R=_.style,ce=oe(R.color,M),ee=R.alpha*E;if(ee<=0)continue;const q=z.action==="stroke";if(r.globalAlpha=ee,q){const p=R;r.lineWidth=p.width,r.lineCap=p.cap,r.lineJoin=p.join,r.miterLimit=p.miterLimit}const $=w.shapePrimitives;if(!q&&((Q=(V=(C=_.hole)==null?void 0:C.shapePath)==null?void 0:V.shapePrimitives)!=null&&Q.length)){const p=$[$.length-1];p.holes=_.hole.shapePath.shapePrimitives}for(let p=0;p<$.length;p++){const m=$[p];if(!(m!=null&&m.shape))continue;const g=m.transform,L=g&&!g.isIdentity(),I=R.texture&&R.texture!==Be.WHITE,b=R.textureSpace==="global"?g:null,D=I?ze(vt,R,m.shape,b):null,F=L?yt.copyFrom(o).append(g):o,B=_t(R,ce,D,F);if(L&&(r.save(),r.transform(g.a,g.b,g.c,g.d,g.tx,g.ty)),q){const H=R;if(H.alignment!==.5&&!H.pixelLine){const h=[],O=[],j=[],T=Re[m.shape.type];if(T!=null&&T.build(m.shape,h)){const ve=m.shape.closePath??!0;Ie(h,H,!1,ve,O,j),r.fillStyle=B,Ct(r,O,j)}else r.strokeStyle=B,r.beginPath(),ie(r,m.shape),r.stroke()}else r.strokeStyle=B,r.beginPath(),ie(r,m.shape),r.stroke()}else r.fillStyle=B,r.beginPath(),ie(r,m.shape),kt(r,m.holes)?r.fill("evenodd"):r.fill();L&&r.restore()}}r.restore()}destroy(){this.shader=null}}Ue.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class bt{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 r=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=r.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,s,n)}clear(e,t,s,n){const o=this._renderTargetSystem.getGpuRenderTarget(e).context,c=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(c.x,c.y,c.width,c.height),s){const i=Ae.shared.setValue(s);i.alpha>0&&(o.globalAlpha=i.alpha,o.fillStyle=i.toHex(),o.fillRect(c.x,c.y,c.width,c.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,s,n,r){const c=this._renderTargetSystem.getGpuRenderTarget(e).canvas,i=t.source,{context:l}=this._ensureCanvas(i),u=(r==null?void 0:r.x)??0,x=(r==null?void 0:r.y)??0;return l.drawImage(c,s.x,s.y,n.width,n.height,u,x,n.width,n.height),i.update(),t}copyDepthTexture(e,t,s,n,r){we("[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer")}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Qe.test(t))&&(t=He.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 tt{constructor(e){super(e),this.adaptor=new bt,this.adaptor.init(e,this)}}qe.extension={type:[S.CanvasSystem],name:"renderTarget"};class Le{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=He.get().createCanvas(),s=t.getContext("2d"),n=P.getCanvasSource(e);if(!n)return t;const r=e.frame,o=e.source._resolution??e.source.resolution??1,c=r.x*o,i=r.y*o,l=r.width*o,u=r.height*o;return t.width=Math.ceil(l),t.height=Math.ceil(u),s.drawImage(n,c,i,l,u,0,0,l,u),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(){}}Le.extension={type:[S.CanvasSystem],name:"texture"};const St=[...st,De,Fe,Le,qe],Mt=[nt,at,rt,ot,it,We,Ge,ct],wt=[ht,Ue],Ne=[],Oe=[],je=[],Ye=[];ne.handleByNamedList(S.CanvasSystem,Ne);ne.handleByNamedList(S.CanvasPipes,Oe);ne.handleByNamedList(S.CanvasPipesAdaptor,je);ne.handleByNamedList(S.CanvasLoader,Ye);ne.add(...St,...Mt,...wt);class Ht extends Ze{constructor(){const e={name:"canvas",type:et.CANVAS,systems:Ne,renderPipes:Oe,renderPipeAdaptors:je,loaders:Ye};super(e)}}export{Ht as CanvasRenderer};
|
|
1
|
+
import{g as Se,l as Me,m as oe,M as G,o as S,p as Xe,w as we,s as Re,q as Ie,C as Ae,T as Be,r as ze,F as Je,t as Ke,x as Qe,D as He,A as Ze,R as et,y as ne}from"./index-CMIifH9a.js";import{R as tt,S as st,B as nt,a as at,b as rt,c as ot,A as it,C as ct}from"./RenderTargetSystem-CAgQLo6K.js";import{c as P,a as lt}from"./canvasUtils-LeZLwOlL.js";import"./CanvasPool-DxzlD0_z.js";const ge=class X{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 c,i,l,u;const s=t.elements;if(!s||!s.length)return;const n=e.renderer,r=n.canvasContext,o=r.activeContext;for(let x=0;x<s.length;x++){const E=s[x];if(!E.packAsQuad)continue;const v=E,f=v.texture,M=f?P.getCanvasSource(f):null;if(!M)continue;const y=f.source.style,A=r.smoothProperty,Y=y.scaleMode!=="nearest";o[A]!==Y&&(o[A]=Y),r.setBlendMode(t.blendMode);const U=((c=n.globalUniforms.globalUniformData)==null?void 0:c.worldColor)??4294967295,W=v.color,k=(U>>>24&255)/255,C=(W>>>24&255)/255,V=((i=n.filter)==null?void 0:i.alphaMultiplier)??1,Q=k*C*V;if(Q<=0)continue;o.globalAlpha=Q;const Z=U&16777215,z=W&16777215,_=Me(oe(z,Z)),w=f.frame,R=y.addressModeU??y.addressMode,ce=y.addressModeV??y.addressMode,ee=X._getPatternRepeat(R,ce),q=f.source._resolution??f.source.resolution??1,$=(u=(l=v.renderable)==null?void 0:l.renderGroup)==null?void 0:u.isCachedAsTexture,p=w.x*q,m=w.y*q,g=w.width*q,L=w.height*q,I=v.bounds,b=n.renderTarget.renderTarget.isRoot,D=I.minX,F=I.minY,B=I.maxX-I.minX,H=I.maxY-I.minY,N=f.rotate,h=f.uvs,O=Math.min(h.x0,h.x1,h.x2,h.x3,h.y0,h.y1,h.y2,h.y3),j=Math.max(h.x0,h.x1,h.x2,h.x3,h.y0,h.y1,h.y2,h.y3),T=ee!=="no-repeat"&&(O<0||j>1),ae=N&&!(!T&&(_!==16777215||N));ae?(X._tempPatternMatrix.copyFrom(v.transform),Se.matrixAppendRotationInv(X._tempPatternMatrix,N,D,F,B,H),r.setContextTransform(X._tempPatternMatrix,v.roundPixels===1,void 0,$&&b)):r.setContextTransform(v.transform,v.roundPixels===1,void 0,$&&b);const le=B,he=H;let te=ae?0:D,se=ae?0:F;if(!ae&&v.roundPixels===1&&(te|=0,se|=0),T){let de=M;const J=_!==16777215&&!N,K=w.width<=f.source.width&&w.height<=f.source.height;J&&K&&(de=P.getTintedCanvas({texture:f},_));const pe=o.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=(h.x1-h.x0)*Ce,ke=(h.y1-h.y0)*Ce,_e=(h.x3-h.x0)*Te,be=(h.y3-h.y0)*Te,Ve=h.x0-Pe*te-_e*se,$e=h.y0-ke*te-be*se,ue=f.source.pixelWidth,me=f.source.pixelHeight;X._tempPatternMatrix.set(Pe*ue,ke*me,_e*ue,be*me,Ve*ue,$e*me),P.applyPatternTransform(pe,X._tempPatternMatrix),o.fillStyle=pe,o.fillRect(te,se,le,he)}else{const J=_!==16777215||N?P.getTintedCanvas({texture:f},_):M,K=J!==M;o.drawImage(J,K?0:p,K?0:m,K?J.width:g,K?J.height:L,te,se,le,he)}}}};ge._tempPatternMatrix=new G;ge.extension={type:[S.CanvasPipesAdaptor],name:"batch"};let ht=ge;class Ge{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 r=this._colorStack[this._colorStackIndex];r!==this._currentColor&&(this._currentColor=r,s.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1})),this._colorStackIndex++}pop(e,t,s){this._renderer.renderPipes.batch.break(s);const n=this._colorStack;this._colorStackIndex--;const r=n[this._colorStackIndex-1];r!==this._currentColor&&(this._currentColor=r,s.add({renderPipeId:"colorMask",colorMask:r,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}}Ge.extension={type:[S.CanvasPipes],name:"colorMask"};function dt(a,e,t,s,n,r){r=Math.max(0,Math.min(r,Math.min(s,n)/2)),a.moveTo(e+r,t),a.lineTo(e+s-r,t),a.quadraticCurveTo(e+s,t,e+s,t+r),a.lineTo(e+s,t+n-r),a.quadraticCurveTo(e+s,t+n,e+s-r,t+n),a.lineTo(e+r,t+n),a.quadraticCurveTo(e,t+n,e,t+n-r),a.lineTo(e,t+r),a.quadraticCurveTo(e,t,e+r,t)}function Ee(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;dt(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 pt(a,e,t){const s=[],n=[],r=[],o=Re[e.type];if(!(o!=null&&o.build(e,s)))return!1;const c=e.closePath??!0;Ie(s,t,!1,c,n,r);for(let i=0;i<r.length;i+=3){const l=r[i]*2,u=r[i+1]*2,x=r[i+2]*2;a.moveTo(n[l],n[l+1]),a.lineTo(n[u],n[u+1]),a.lineTo(n[x],n[x+1]),a.closePath()}return!0}function ut(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,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),Ee(a,s.shape),r&&a.restore()}return!0}class We{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 u,x,E;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 r=e.mask.mask;if(!(r instanceof Xe)){this._warnOnce("nonGraphics","CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask."),this._canvasMaskStack.push(!1);return}const o=r,c=(u=o.context)==null?void 0:u.instructions;if(!(c!=null&&c.length)){this._canvasMaskStack.push(!1);return}n.save(),s.setContextTransform(o.groupTransform,(t._roundPixels|o._roundPixels)===1),n.beginPath();let i=!1,l=!1;for(let v=0;v<c.length;v++){const f=c[v],M=f.action;if(M!=="fill"&&M!=="stroke")continue;const y=f.data,A=(x=y==null?void 0:y.path)==null?void 0:x.shapePath;if(!((E=A==null?void 0:A.shapePrimitives)!=null&&E.length))continue;const Y=M==="stroke",U=A.shapePrimitives;for(let W=0;W<U.length;W++){const k=U[W];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&&y.style?i=pt(n,k.shape,y.style)||i:(Ee(n,k.shape),l=ut(n,k.holes)||l,i=!0),V&&n.restore()}}if(!i){n.restore(),this._canvasMaskStack.push(!1);return}l?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),we(t))}}We.extension={type:[S.CanvasPipes],name:"stencilMask"};const d="source-over";function mt(){const a=lt(),e=Object.create(null);return e.inherit=d,e.none=d,e.normal="source-over",e.add="lighter",e.multiply=a?"multiply":d,e.screen=a?"screen":d,e.overlay=a?"overlay":d,e.darken=a?"darken":d,e.lighten=a?"lighten":d,e["color-dodge"]=a?"color-dodge":d,e["color-burn"]=a?"color-burn":d,e["hard-light"]=a?"hard-light":d,e["soft-light"]=a?"soft-light":d,e.difference=a?"difference":d,e.exclusion=a?"exclusion":d,e.saturation=a?"saturation":d,e.color=a?"color":d,e.luminosity=a?"luminosity":d,e["linear-burn"]=a?"color-burn":d,e["linear-dodge"]=a?"color-dodge":d,e["linear-light"]=a?"hard-light":d,e["pin-light"]=a?"hard-light":d,e["vivid-light"]=a?"hard-light":d,e["hard-mix"]=d,e.negation=a?"difference":d,e["normal-npm"]=e.normal,e["add-npm"]=e.add,e["screen-npm"]=e.screen,e.erase="destination-out",e.subtract=d,e.divide=d,e.min=d,e.max=d,e}const ft=new G;class De{constructor(e){this.activeResolution=1,this.smoothProperty="imageSmoothingEnabled",this.blendModes=mt(),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 l;const r=n?G.IDENTITY:((l=this._renderer.globalUniforms.globalUniformData)==null?void 0:l.worldTransformMatrix)||G.IDENTITY;let o=ft;o.copyFrom(r),o.append(e);const c=this._projTransform,i=this.activeResolution;if(s=s||i,c){const u=G.shared;u.copyFrom(o),u.prepend(c),o=u}t?this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*i|0,o.ty*i|0):this.activeContext.setTransform(o.a*s,o.b*s,o.c*s,o.d*s,o.tx*i,o.ty*i)}clear(e,t){const s=this.activeContext,n=this._renderer;if(s.clearRect(0,0,n.width,n.height),e){const r=Ae.shared.setValue(e);s.globalAlpha=t??r.alpha,s.fillStyle=r.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()}}De.extension={type:[S.CanvasSystem],name:"canvasContext"};class Fe{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0}init(){}}Fe.extension={type:[S.CanvasSystem],name:"limits"};const gt="#808080",re=new G,vt=new G,yt=new G,fe=new G,xt=new G;function Ct(a,e,t){a.beginPath();for(let s=0;s<t.length;s+=3){const n=t[s]*2,r=t[s+1]*2,o=t[s+2]*2;a.moveTo(e[n],e[n+1]),a.lineTo(e[r],e[r+1]),a.lineTo(e[o],e[o+1]),a.closePath()}a.fill()}function Tt(a){return`#${(a&16777215).toString(16).padStart(6,"0")}`}function Pt(a,e,t,s,n,r){r=Math.max(0,Math.min(r,Math.min(s,n)/2)),a.moveTo(e+r,t),a.lineTo(e+s-r,t),a.quadraticCurveTo(e+s,t,e+s,t+r),a.lineTo(e+s,t+n-r),a.quadraticCurveTo(e+s,t+n,e+s-r,t+n),a.lineTo(e+r,t+n),a.quadraticCurveTo(e,t+n,e,t+n-r),a.lineTo(e,t+r),a.quadraticCurveTo(e,t,e+r,t)}function ie(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;Pt(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 kt(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,r=n&&!n.isIdentity();r&&(a.save(),a.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),ie(a,s.shape),r&&a.restore()}return!0}function _t(a,e,t,s){const n=a.fill;if(n instanceof Je){n.buildGradient();const o=n.texture;if(o){const c=P.getTintedPattern(o,e),i=t?fe.copyFrom(t).scale(o.source.pixelWidth,o.source.pixelHeight):fe.copyFrom(n.transform);return s&&!a.textureSpace&&i.append(s),P.applyPatternTransform(c,i),c}}if(n instanceof Ke){const o=P.getTintedPattern(n.texture,e);return P.applyPatternTransform(o,n.transform,!1),o}const r=a.texture;if(r&&r!==Be.WHITE){if(!r.source.resource)return gt;const o=P.getTintedPattern(r,e);let c=a.matrix;if(t){const{resolution:i}=r.source;if(c=fe.copyFrom(t),r.rotate){const{uvs:l,orig:u}=r;c.prepend(xt.set(l.x1-l.x0,l.y1-l.y0,l.x3-l.x0,l.y3-l.y0,l.x0,l.y0).invert()).scale(u.width*i,u.height*i)}else c.scale(r.source.pixelWidth,r.source.pixelHeight).translate(-r.frame.x*i,-r.frame.y*i)}return P.applyPatternTransform(o,c),o}return Tt(e)}class Ue{constructor(){this.shader=null}contextChange(e){}execute(e,t){var Y,U,W,k,C,V,Q;const s=e.renderer,n=s.canvasContext,r=n.activeContext,o=t.groupTransform,c=((Y=s.globalUniforms.globalUniformData)==null?void 0:Y.worldColor)??4294967295,i=t.groupColorAlpha,l=(c>>>24&255)/255,u=(i>>>24&255)/255,x=((U=s.filter)==null?void 0:U.alphaMultiplier)??1,E=l*u*x;if(E<=0)return;const v=c&16777215,f=i&16777215,M=Me(oe(f,v)),y=s._roundPixels|t._roundPixels;r.save(),n.setContextTransform(o,y===1),n.setBlendMode(t.groupBlendMode);const A=t.context.instructions;for(let Z=0;Z<A.length;Z++){const z=A[Z];if(z.action==="texture"){const p=z.data,m=p.image,g=m?P.getCanvasSource(m):null;if(!g)continue;const L=p.alpha*E;if(L<=0)continue;const I=oe(p.style,M);r.globalAlpha=L;let b=g;I!==16777215&&(b=P.getTintedCanvas({texture:m},I));const D=m.frame,F=m.source._resolution??m.source.resolution??1;let B=D.x*F,H=D.y*F;const N=D.width*F,h=D.height*F;b!==g&&(B=0,H=0);const O=p.transform,j=O&&!O.isIdentity(),T=m.rotate;j||T?(re.copyFrom(o),j&&re.append(O),T&&Se.matrixAppendRotationInv(re,T,p.dx,p.dy,p.dw,p.dh),n.setContextTransform(re,y===1)):n.setContextTransform(o,y===1),r.drawImage(b,B,H,b===g?N:b.width,b===g?h:b.height,T?0:p.dx,T?0:p.dy,p.dw,p.dh),(j||T)&&n.setContextTransform(o,y===1);continue}const _=z.data,w=(W=_==null?void 0:_.path)==null?void 0:W.shapePath;if(!((k=w==null?void 0:w.shapePrimitives)!=null&&k.length))continue;const R=_.style,ce=oe(R.color,M),ee=R.alpha*E;if(ee<=0)continue;const q=z.action==="stroke";if(r.globalAlpha=ee,q){const p=R;r.lineWidth=p.width,r.lineCap=p.cap,r.lineJoin=p.join,r.miterLimit=p.miterLimit}const $=w.shapePrimitives;if(!q&&((Q=(V=(C=_.hole)==null?void 0:C.shapePath)==null?void 0:V.shapePrimitives)!=null&&Q.length)){const p=$[$.length-1];p.holes=_.hole.shapePath.shapePrimitives}for(let p=0;p<$.length;p++){const m=$[p];if(!(m!=null&&m.shape))continue;const g=m.transform,L=g&&!g.isIdentity(),I=R.texture&&R.texture!==Be.WHITE,b=R.textureSpace==="global"?g:null,D=I?ze(vt,R,m.shape,b):null,F=L?yt.copyFrom(o).append(g):o,B=_t(R,ce,D,F);if(L&&(r.save(),r.transform(g.a,g.b,g.c,g.d,g.tx,g.ty)),q){const H=R;if(H.alignment!==.5&&!H.pixelLine){const h=[],O=[],j=[],T=Re[m.shape.type];if(T!=null&&T.build(m.shape,h)){const ve=m.shape.closePath??!0;Ie(h,H,!1,ve,O,j),r.fillStyle=B,Ct(r,O,j)}else r.strokeStyle=B,r.beginPath(),ie(r,m.shape),r.stroke()}else r.strokeStyle=B,r.beginPath(),ie(r,m.shape),r.stroke()}else r.fillStyle=B,r.beginPath(),ie(r,m.shape),kt(r,m.holes)?r.fill("evenodd"):r.fill();L&&r.restore()}}r.restore()}destroy(){this.shader=null}}Ue.extension={type:[S.CanvasPipesAdaptor],name:"graphics"};class bt{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 r=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=r.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,s,n)}clear(e,t,s,n){const o=this._renderTargetSystem.getGpuRenderTarget(e).context,c=n||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(o.setTransform(1,0,0,1,0,0),o.clearRect(c.x,c.y,c.width,c.height),s){const i=Ae.shared.setValue(s);i.alpha>0&&(o.globalAlpha=i.alpha,o.fillStyle=i.toHex(),o.fillRect(c.x,c.y,c.width,c.height),o.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,s,n,r){const c=this._renderTargetSystem.getGpuRenderTarget(e).canvas,i=t.source,{context:l}=this._ensureCanvas(i),u=(r==null?void 0:r.x)??0,x=(r==null?void 0:r.y)??0;return l.drawImage(c,s.x,s.y,n.width,n.height,u,x,n.width,n.height),i.update(),t}copyDepthTexture(e,t,s,n,r){we("[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer")}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;(!t||!Qe.test(t))&&(t=He.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 tt{constructor(e){super(e),this.adaptor=new bt,this.adaptor.init(e,this)}}qe.extension={type:[S.CanvasSystem],name:"renderTarget"};class Le{constructor(e){}init(){}initSource(e){}generateCanvas(e){const t=He.get().createCanvas(),s=t.getContext("2d"),n=P.getCanvasSource(e);if(!n)return t;const r=e.frame,o=e.source._resolution??e.source.resolution??1,c=r.x*o,i=r.y*o,l=r.width*o,u=r.height*o;return t.width=Math.ceil(l),t.height=Math.ceil(u),s.drawImage(n,c,i,l,u,0,0,l,u),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(){}}Le.extension={type:[S.CanvasSystem],name:"texture"};const St=[...st,De,Fe,Le,qe],Mt=[nt,at,rt,ot,it,We,Ge,ct],wt=[ht,Ue],Ne=[],Oe=[],je=[],Ye=[];ne.handleByNamedList(S.CanvasSystem,Ne);ne.handleByNamedList(S.CanvasPipes,Oe);ne.handleByNamedList(S.CanvasPipesAdaptor,je);ne.handleByNamedList(S.CanvasLoader,Ye);ne.add(...St,...Mt,...wt);class Ht extends Ze{constructor(){const e={name:"canvas",type:et.CANVAS,systems:Ne,renderPipes:Oe,renderPipeAdaptors:je,loaders:Ye};super(e)}}export{Ht as CanvasRenderer};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a1 as Xe,Y as me,M as x,G as Je,b as Qe,w as R,T as _,a as Ze,a2 as ge,o as d,y as Y,a3 as E,a4 as et,a5 as $,a6 as v,R as L,a7 as _e,a8 as tt,h as T,W as U,a9 as oe,aa as xe,ab as be,ac as ye,ad as Te,I as O,C as W,D as q,V as w,X as P,ae as rt,P as st,af as nt,N as at,z as le,ag as de,d as f,E as it,k as ot,x as V,e as lt,ah as dt,ai as ht,aj as ct,v as ut}from"./index-
|
|
1
|
+
import{a1 as Xe,Y as me,M as x,G as Je,b as Qe,w as R,T as _,a as Ze,a2 as ge,o as d,y as Y,a3 as E,a4 as et,a5 as $,a6 as v,R as L,a7 as _e,a8 as tt,h as T,W as U,a9 as oe,aa as xe,ab as be,ac as ye,ad as Te,I as O,C as W,D as q,V as w,X as P,ae as rt,P as st,af as nt,N as at,z as le,ag as de,d as f,E as it,k as ot,x as V,e as lt,ah as dt,ai as ht,aj as ct,v as ut}from"./index-CMIifH9a.js";import{F as pt,C as he}from"./CanvasPool-DxzlD0_z.js";var ft=`in vec2 vMaskCoord;
|
|
2
2
|
in vec2 vTextureCoord;
|
|
3
3
|
|
|
4
4
|
uniform sampler2D uTexture;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{D as g,a as P,o as d,K as O,j as N,w as p,f as Q,b as Ue,S as L,T as R,ak as Fe,V as ee,al as Me,h as y,X as T,x as C,W as x,E as Pe,k as Oe,Y as w,am as Le,an as k,y as S,M as te,ao as re,ap as we,aq as ne,ar as He,as as Xe,A as Ve,R as ke}from"./index-ByCDDgCj.js";import{e as We,G as je,c as Ke,b as Ye,U as $e,B as se,d as I,g as ze,f as ie,h as qe}from"./getTexelRangeRects-DY8vmJhl.js";import{R as Ze,S as Je,d as Qe}from"./RenderTargetSystem-R9NN3Lf_.js";import"./CanvasPool-D8o5qooo.js";function et(){const{userAgent:r}=g.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}class ae{constructor(){this._tempState=P.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,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(t,n.glProgram)}execute(e,t){const n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);const s=t.textures.textures;for(let i=0;i<t.textures.count;i++)n.texture.bind(s[i],i);n.texture.unbindIntegerTextures(t.textures.count),n.geometry.draw(t.topology,t.size,t.start)}}ae.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var D=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(D||{});class tt{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class oe{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new O({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:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){const{_gl:n}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,n.bindBufferBase(n.UNIFORM_BUFFER,t,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 t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;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 t=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t)}getLastBindBaseLocation(e){const t=e._lastBindBaseLocation;return this._boundBufferBases[t]===e?t:-1}bindBufferRange(e,t,n,s){const{_gl:i}=this;n||(n=0),t||(t=0),this._boundBufferBases[t]=null,i.bindBufferRange(i.UNIFORM_BUFFER,t||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);const s=e.data,i=e.descriptor.usage&N.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?t.bufferSubData(n.type,e._updateOffset,s,e._updateOffset/s.BYTES_PER_ELEMENT,(e._updateSize||s.byteLength)/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,t.bufferData(n.type,s,i)):(n.byteLength=e.descriptor.size,t.bufferData(n.type,n.byteLength,i)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];n&&(t||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:t}=this;let n=D.ARRAY_BUFFER;e.descriptor.usage&N.INDEX?n=D.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&N.UNIFORM&&(n=D.UNIFORM_BUFFER);const s=new tt(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}oe.extension={type:[d.WebGLSystem],name:"buffer"};const H=class ce{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={...ce.defaultOptions,...e};let t=this.multiView=e.multiView;if(e.context&&t&&(p("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),t=!1),t?this.canvas=g.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:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof g.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const t=this._renderer.view.canvas;t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,t){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",t)),!n&&(n=s.getContext("webgl",t),!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,t={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={...t,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={...t,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 t;this.gl.isContextLost()&&((t=this.extensions.loseContext)==null||t.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const t=e.getContextAttributes();t&&!t.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")}};H.extension={type:[d.WebGLSystem],name:"context"};H.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let rt=H;var F=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(F||{}),v=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_3D=32879]="TEXTURE_3D",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(v||{}),f=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(f||{});const W={uint8x2:f.UNSIGNED_BYTE,uint8x4:f.UNSIGNED_BYTE,sint8x2:f.BYTE,sint8x4:f.BYTE,unorm8x2:f.UNSIGNED_BYTE,unorm8x4:f.UNSIGNED_BYTE,snorm8x2:f.BYTE,snorm8x4:f.BYTE,uint16x2:f.UNSIGNED_SHORT,uint16x4:f.UNSIGNED_SHORT,sint16x2:f.SHORT,sint16x4:f.SHORT,unorm16x2:f.UNSIGNED_SHORT,unorm16x4:f.UNSIGNED_SHORT,snorm16x2:f.SHORT,snorm16x4:f.SHORT,float16x2:f.HALF_FLOAT,float16x4:f.HALF_FLOAT,float32:f.FLOAT,float32x2:f.FLOAT,float32x3:f.FLOAT,float32x4:f.FLOAT,uint32:f.UNSIGNED_INT,uint32x2:f.UNSIGNED_INT,uint32x3:f.UNSIGNED_INT,uint32x4:f.UNSIGNED_INT,sint32:f.INT,sint32x2:f.INT,sint32x3:f.INT,sint32x4:f.INT};function nt(r){return W[r]??W.float32}const st={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class it{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ue{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new O({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 t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=s=>t.bindVertexArrayOES(s),e.deleteVertexArray=s=>t.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,c)=>{n.drawElementsInstancedANGLE(s,i,a,o,c)},e.vertexAttribDivisor=(s,i)=>n.vertexAttribDivisorANGLE(s,i)),this._activeGeometry=null,this._activeVao=null}bind(e,t){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,t);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];t.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){const n=e.attributes,s=t._attributeData;for(const i in s)if(!n[i])throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`)}getSignature(e,t){const n=e.attributes,s=t._attributeData,i=["g",e.uid];for(const a in n)s[a]&&i.push(a,s[a].location);return i.join("-")}getVao(e,t){var n;return((n=e._gpuData[this._renderer.uid])==null?void 0:n.vaoCache[t._key])||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);const a=this.getSignature(e,t);let o=e._gpuData[this._renderer.uid];o||(o=new it,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const c=o.vaoCache;let u=c[a];if(u)return c[t._key]=u,u;We(e,t._attributeData);const _=e.buffers;u=s.createVertexArray(),s.bindVertexArray(u);for(let h=0;h<_.length;h++){const l=_[h];i.bind(l)}return this.activateVao(e,t),c[t._key]=u,c[a]=u,s.bindVertexArray(null),u}onGeometryUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!t)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,t){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 c in i){const u=i[c],_=u.buffer,h=s.getGlBuffer(_),l=t._attributeData[c];if(l){a!==h&&(s.bind(_),a=h);const m=l.location;n.enableVertexAttribArray(m);const E=Q(u.format),b=nt(u.format);if(((o=l.format)==null?void 0:o.substring(1,4))==="int"?n.vertexAttribIPointer(m,E.size,b,u.stride,u.offset):n.vertexAttribPointer(m,E.size,b,E.normalised,u.stride,u.offset),u.instance)if(this.hasInstance){const Ge=u.divisor??1;n.vertexAttribDivisor(m,Ge)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,n,s){const{gl:i}=this._renderer,a=this._activeGeometry,o=st[e||a.topology];if(s??(s=a.instanceCount),a.indexBuffer){const c=a.indexBuffer.data.BYTES_PER_ELEMENT,u=c===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT,_=t||a.indexCount||a.indexBuffer.data.length,h=(n||0)*c;s!==1?i.drawElementsInstanced(o,_,u,h,s):i.drawElements(o,_,u,h)}else s!==1?i.drawArraysInstanced(o,n||0,t||a.vertexCount,s):i.drawArrays(o,n||0,t||a.vertexCount);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}}ue.extension={type:[d.WebGLSystem],name:"geometry"};const at=new Fe({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),X=class _e{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:t,antialias:n}={..._e.defaultOptions,...e};this.useBackBuffer=t,this._antialias=n,this._renderer.context.supports.msaa||(p("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=P.for2d();const s=new Ue({vertex:`
|
|
1
|
+
import{D as g,a as P,o as d,K as O,j as N,w as p,f as Q,b as Ue,S as L,T as R,ak as Fe,V as ee,al as Me,h as y,X as T,x as C,W as x,E as Pe,k as Oe,Y as w,am as Le,an as k,y as S,M as te,ao as re,ap as we,aq as ne,ar as He,as as Xe,A as Ve,R as ke}from"./index-CMIifH9a.js";import{e as We,G as je,c as Ke,b as Ye,U as $e,B as se,d as I,g as ze,f as ie,h as qe}from"./getTexelRangeRects-DhWvqmbJ.js";import{R as Ze,S as Je,d as Qe}from"./RenderTargetSystem-CAgQLo6K.js";import"./CanvasPool-DxzlD0_z.js";function et(){const{userAgent:r}=g.get().getNavigator();return/^((?!chrome|android).)*safari/i.test(r)}class ae{constructor(){this._tempState=P.for2d(),this._didUploadHash={}}init(e){e.renderer.runners.contextChange.add(this)}contextChange(){this._didUploadHash={}}start(e,t,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(t,n.glProgram)}execute(e,t){const n=e.renderer;this._tempState.blendMode=t.blendMode,n.state.set(this._tempState);const s=t.textures.textures;for(let i=0;i<t.textures.count;i++)n.texture.bind(s[i],i);n.texture.unbindIntegerTextures(t.textures.count),n.geometry.draw(t.topology,t.size,t.start)}}ae.extension={type:[d.WebGLPipesAdaptor],name:"batch"};var D=(r=>(r[r.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",r[r.ARRAY_BUFFER=34962]="ARRAY_BUFFER",r[r.UNIFORM_BUFFER=35345]="UNIFORM_BUFFER",r))(D||{});class tt{constructor(e,t){this._lastBindBaseLocation=-1,this._lastBindCallId=-1,this.buffer=e||null,this.updateID=-1,this.byteLength=-1,this.type=t}destroy(){this.buffer=null,this.updateID=-1,this.byteLength=-1,this.type=-1,this._lastBindBaseLocation=-1,this._lastBindCallId=-1}}class oe{constructor(e){this._boundBufferBases=Object.create(null),this._minBaseLocation=0,this._nextBindBaseIndex=this._minBaseLocation,this._bindCallId=0,this._renderer=e,this._managedBuffers=new O({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:t}=this,n=this.getGlBuffer(e);t.bindBuffer(n.type,n.buffer)}bindBufferBase(e,t){const{_gl:n}=this;this._boundBufferBases[t]!==e&&(this._boundBufferBases[t]=e,e._lastBindBaseLocation=t,n.bindBufferBase(n.UNIFORM_BUFFER,t,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 t=this.getLastBindBaseLocation(e);if(t>=this._minBaseLocation)return e._lastBindCallId=this._bindCallId,t;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 t=s,this._nextBindBaseIndex=s+1,n>=2?-1:(e._lastBindCallId=this._bindCallId,this._boundBufferBases[t]=null,t)}getLastBindBaseLocation(e){const t=e._lastBindBaseLocation;return this._boundBufferBases[t]===e?t:-1}bindBufferRange(e,t,n,s){const{_gl:i}=this;n||(n=0),t||(t=0),this._boundBufferBases[t]=null,i.bindBufferRange(i.UNIFORM_BUFFER,t||0,e.buffer,n*256,s||256)}updateBuffer(e){const{_gl:t}=this,n=this.getGlBuffer(e);if(e._updateID===n.updateID)return n;n.updateID=e._updateID,t.bindBuffer(n.type,n.buffer);const s=e.data,i=e.descriptor.usage&N.STATIC?t.STATIC_DRAW:t.DYNAMIC_DRAW;return s?n.byteLength>=s.byteLength?t.bufferSubData(n.type,e._updateOffset,s,e._updateOffset/s.BYTES_PER_ELEMENT,(e._updateSize||s.byteLength)/s.BYTES_PER_ELEMENT):(n.byteLength=s.byteLength,t.bufferData(n.type,s,i)):(n.byteLength=e.descriptor.size,t.bufferData(n.type,n.byteLength,i)),n}destroyAll(e=!1){this._managedBuffers.removeAll(e)}onBufferUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];n&&(t||this._gl.deleteBuffer(n.buffer))}createGLBuffer(e){const{_gl:t}=this;let n=D.ARRAY_BUFFER;e.descriptor.usage&N.INDEX?n=D.ELEMENT_ARRAY_BUFFER:e.descriptor.usage&N.UNIFORM&&(n=D.UNIFORM_BUFFER);const s=new tt(t.createBuffer(),n);return e._gpuData[this._renderer.uid]=s,this._managedBuffers.add(e),s}resetState(){this._boundBufferBases=Object.create(null)}}oe.extension={type:[d.WebGLSystem],name:"buffer"};const H=class ce{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={...ce.defaultOptions,...e};let t=this.multiView=e.multiView;if(e.context&&t&&(p("Renderer created with both a context and multiview enabled. Disabling multiView as both cannot work together."),t=!1),t?this.canvas=g.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:t}=this;(t.width<e.width||t.height<e.height)&&(t.width=Math.max(e.width,e.width),t.height=Math.max(e.height,e.height))}initFromContext(e){this.gl=e,this.webGLVersion=e instanceof g.get().getWebGLRenderingContext()?1:2,this.getExtensions(),this.validateContext(e),this._renderer.runners.contextChange.emit(e);const t=this._renderer.view.canvas;t.addEventListener("webglcontextlost",this.handleContextLost,!1),t.addEventListener("webglcontextrestored",this.handleContextRestored,!1)}createContext(e,t){let n;const s=this.canvas;if(e===2&&(n=s.getContext("webgl2",t)),!n&&(n=s.getContext("webgl",t),!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,t={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={...t,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={...t,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 t;this.gl.isContextLost()&&((t=this.extensions.loseContext)==null||t.restoreContext())},0))}handleContextRestored(){this.getExtensions(),this._renderer.runners.contextChange.emit(this.gl)}destroy(){var t;const e=this._renderer.view.canvas;this._renderer=null,e.removeEventListener("webglcontextlost",this.handleContextLost),e.removeEventListener("webglcontextrestored",this.handleContextRestored),this.gl.useProgram(null),(t=this.extensions.loseContext)==null||t.loseContext()}forceContextLoss(){var e;(e=this.extensions.loseContext)==null||e.loseContext(),this._contextLossForced=!0}validateContext(e){const t=e.getContextAttributes();t&&!t.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")}};H.extension={type:[d.WebGLSystem],name:"context"};H.defaultOptions={context:null,premultipliedAlpha:!0,preserveDrawingBuffer:!1,powerPreference:void 0,preferWebGLVersion:2,multiView:!1};let rt=H;var F=(r=>(r[r.RGBA=6408]="RGBA",r[r.RGB=6407]="RGB",r[r.RG=33319]="RG",r[r.RED=6403]="RED",r[r.RGBA_INTEGER=36249]="RGBA_INTEGER",r[r.RGB_INTEGER=36248]="RGB_INTEGER",r[r.RG_INTEGER=33320]="RG_INTEGER",r[r.RED_INTEGER=36244]="RED_INTEGER",r[r.ALPHA=6406]="ALPHA",r[r.LUMINANCE=6409]="LUMINANCE",r[r.LUMINANCE_ALPHA=6410]="LUMINANCE_ALPHA",r[r.DEPTH_COMPONENT=6402]="DEPTH_COMPONENT",r[r.DEPTH_STENCIL=34041]="DEPTH_STENCIL",r))(F||{}),v=(r=>(r[r.TEXTURE_2D=3553]="TEXTURE_2D",r[r.TEXTURE_CUBE_MAP=34067]="TEXTURE_CUBE_MAP",r[r.TEXTURE_2D_ARRAY=35866]="TEXTURE_2D_ARRAY",r[r.TEXTURE_3D=32879]="TEXTURE_3D",r[r.TEXTURE_CUBE_MAP_POSITIVE_X=34069]="TEXTURE_CUBE_MAP_POSITIVE_X",r[r.TEXTURE_CUBE_MAP_NEGATIVE_X=34070]="TEXTURE_CUBE_MAP_NEGATIVE_X",r[r.TEXTURE_CUBE_MAP_POSITIVE_Y=34071]="TEXTURE_CUBE_MAP_POSITIVE_Y",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Y=34072]="TEXTURE_CUBE_MAP_NEGATIVE_Y",r[r.TEXTURE_CUBE_MAP_POSITIVE_Z=34073]="TEXTURE_CUBE_MAP_POSITIVE_Z",r[r.TEXTURE_CUBE_MAP_NEGATIVE_Z=34074]="TEXTURE_CUBE_MAP_NEGATIVE_Z",r))(v||{}),f=(r=>(r[r.UNSIGNED_BYTE=5121]="UNSIGNED_BYTE",r[r.UNSIGNED_SHORT=5123]="UNSIGNED_SHORT",r[r.UNSIGNED_SHORT_5_6_5=33635]="UNSIGNED_SHORT_5_6_5",r[r.UNSIGNED_SHORT_4_4_4_4=32819]="UNSIGNED_SHORT_4_4_4_4",r[r.UNSIGNED_SHORT_5_5_5_1=32820]="UNSIGNED_SHORT_5_5_5_1",r[r.UNSIGNED_INT=5125]="UNSIGNED_INT",r[r.UNSIGNED_INT_10F_11F_11F_REV=35899]="UNSIGNED_INT_10F_11F_11F_REV",r[r.UNSIGNED_INT_2_10_10_10_REV=33640]="UNSIGNED_INT_2_10_10_10_REV",r[r.UNSIGNED_INT_24_8=34042]="UNSIGNED_INT_24_8",r[r.UNSIGNED_INT_5_9_9_9_REV=35902]="UNSIGNED_INT_5_9_9_9_REV",r[r.BYTE=5120]="BYTE",r[r.SHORT=5122]="SHORT",r[r.INT=5124]="INT",r[r.FLOAT=5126]="FLOAT",r[r.FLOAT_32_UNSIGNED_INT_24_8_REV=36269]="FLOAT_32_UNSIGNED_INT_24_8_REV",r[r.HALF_FLOAT=36193]="HALF_FLOAT",r))(f||{});const W={uint8x2:f.UNSIGNED_BYTE,uint8x4:f.UNSIGNED_BYTE,sint8x2:f.BYTE,sint8x4:f.BYTE,unorm8x2:f.UNSIGNED_BYTE,unorm8x4:f.UNSIGNED_BYTE,snorm8x2:f.BYTE,snorm8x4:f.BYTE,uint16x2:f.UNSIGNED_SHORT,uint16x4:f.UNSIGNED_SHORT,sint16x2:f.SHORT,sint16x4:f.SHORT,unorm16x2:f.UNSIGNED_SHORT,unorm16x4:f.UNSIGNED_SHORT,snorm16x2:f.SHORT,snorm16x4:f.SHORT,float16x2:f.HALF_FLOAT,float16x4:f.HALF_FLOAT,float32:f.FLOAT,float32x2:f.FLOAT,float32x3:f.FLOAT,float32x4:f.FLOAT,uint32:f.UNSIGNED_INT,uint32x2:f.UNSIGNED_INT,uint32x3:f.UNSIGNED_INT,uint32x4:f.UNSIGNED_INT,sint32:f.INT,sint32x2:f.INT,sint32x3:f.INT,sint32x4:f.INT};function nt(r){return W[r]??W.float32}const st={"point-list":0,"line-list":1,"line-strip":3,"triangle-list":4,"triangle-strip":5};class it{constructor(){this.vaoCache=Object.create(null)}destroy(){this.vaoCache=Object.create(null)}}class ue{constructor(e){this._renderer=e,this._activeGeometry=null,this._activeVao=null,this.hasVao=!0,this.hasInstance=!0,this._managedGeometries=new O({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 t=this._renderer.context.extensions.vertexArrayObject;t&&(e.createVertexArray=()=>t.createVertexArrayOES(),e.bindVertexArray=s=>t.bindVertexArrayOES(s),e.deleteVertexArray=s=>t.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,c)=>{n.drawElementsInstancedANGLE(s,i,a,o,c)},e.vertexAttribDivisor=(s,i)=>n.vertexAttribDivisorANGLE(s,i)),this._activeGeometry=null,this._activeVao=null}bind(e,t){const n=this.gl;this._activeGeometry=e;const s=this.getVao(e,t);this._activeVao!==s&&(this._activeVao=s,n.bindVertexArray(s)),this.updateBuffers()}resetState(){this.unbind()}updateBuffers(){const e=this._activeGeometry,t=this._renderer.buffer;for(let n=0;n<e.buffers.length;n++){const s=e.buffers[n];t.updateBuffer(s)}e._gcLastUsed=this._renderer.gc.now}checkCompatibility(e,t){const n=e.attributes,s=t._attributeData;for(const i in s)if(!n[i])throw new Error(`shader and geometry incompatible, geometry missing the "${i}" attribute`)}getSignature(e,t){const n=e.attributes,s=t._attributeData,i=["g",e.uid];for(const a in n)s[a]&&i.push(a,s[a].location);return i.join("-")}getVao(e,t){var n;return((n=e._gpuData[this._renderer.uid])==null?void 0:n.vaoCache[t._key])||this.initGeometryVao(e,t)}initGeometryVao(e,t,n=!0){const s=this._renderer.gl,i=this._renderer.buffer;this._renderer.shader._getProgramData(t),this.checkCompatibility(e,t);const a=this.getSignature(e,t);let o=e._gpuData[this._renderer.uid];o||(o=new it,e._gpuData[this._renderer.uid]=o,this._managedGeometries.add(e));const c=o.vaoCache;let u=c[a];if(u)return c[t._key]=u,u;We(e,t._attributeData);const _=e.buffers;u=s.createVertexArray(),s.bindVertexArray(u);for(let h=0;h<_.length;h++){const l=_[h];i.bind(l)}return this.activateVao(e,t),c[t._key]=u,c[a]=u,s.bindVertexArray(null),u}onGeometryUnload(e,t=!1){const n=e._gpuData[this._renderer.uid];if(!n)return;const s=n.vaoCache;if(!t)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,t){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 c in i){const u=i[c],_=u.buffer,h=s.getGlBuffer(_),l=t._attributeData[c];if(l){a!==h&&(s.bind(_),a=h);const m=l.location;n.enableVertexAttribArray(m);const E=Q(u.format),b=nt(u.format);if(((o=l.format)==null?void 0:o.substring(1,4))==="int"?n.vertexAttribIPointer(m,E.size,b,u.stride,u.offset):n.vertexAttribPointer(m,E.size,b,E.normalised,u.stride,u.offset),u.instance)if(this.hasInstance){const Ge=u.divisor??1;n.vertexAttribDivisor(m,Ge)}else throw new Error("geometry error, GPU Instancing is not supported on this device")}}}draw(e,t,n,s){const{gl:i}=this._renderer,a=this._activeGeometry,o=st[e||a.topology];if(s??(s=a.instanceCount),a.indexBuffer){const c=a.indexBuffer.data.BYTES_PER_ELEMENT,u=c===2?i.UNSIGNED_SHORT:i.UNSIGNED_INT,_=t||a.indexCount||a.indexBuffer.data.length,h=(n||0)*c;s!==1?i.drawElementsInstanced(o,_,u,h,s):i.drawElements(o,_,u,h)}else s!==1?i.drawArraysInstanced(o,n||0,t||a.vertexCount,s):i.drawArrays(o,n||0,t||a.vertexCount);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}}ue.extension={type:[d.WebGLSystem],name:"geometry"};const at=new Fe({attributes:{aPosition:[-1,-1,3,-1,-1,3]}}),X=class _e{constructor(e){this.useBackBuffer=!1,this._useBackBufferThisRender=!1,this._renderer=e}init(e={}){const{useBackBuffer:t,antialias:n}={..._e.defaultOptions,...e};this.useBackBuffer=t,this._antialias=n,this._renderer.context.supports.msaa||(p("antialiasing, is not supported on when using the back buffer"),this._antialias=!1),this._state=P.for2d();const s=new Ue({vertex:`
|
|
2
2
|
attribute vec2 aPosition;
|
|
3
3
|
out vec2 vUv;
|
|
4
4
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{J as te,a as re,o as g,K as se,L as Fe,w as B,D as E,j as A,B as De,N as ie,h as D,O as W,Q as ke,V as ne,W as S,x as L,X as F,Y as ae,y as T,M as oe,Z as ue,_ as Ie,$ as ce,a0 as ze,S as de,T as V,A as We,R as Ve}from"./index-ByCDDgCj.js";import{c as Ne,u as He,U as $e,B as Ke,G as je,e as N,g as qe,l as Ye,a as Xe,t as Ze}from"./getTexelRangeRects-DY8vmJhl.js";import{R as Je,S as Qe,d as et}from"./RenderTargetSystem-R9NN3Lf_.js";import{C as H}from"./CanvasPool-D8o5qooo.js";const M=re.for2d();class le{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),M.blendMode="normal",s.pipeline.getPipeline(t,n,M,void 0,r._overrides);const a=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,a,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const o=t.textures;t.bindGroup=te(o.textures,o.count,s.limits.maxBatchableTextures)}M.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),a=s.pipeline.getPipeline(this._geometry,r,M,t.topology,this._shader._overrides);t.bindGroup._touch(s.gc.now),i.setPipeline(a),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}le.extension={type:[g.WebGPUPipesAdaptor],name:"batch"};class tt{constructor(e,t){this.autoGarbageCollect=!0,this._gpuData=null,this.gpuBindGroup=e,this._gcLastUsed=t}unload(){this.gpuBindGroup=null}}class he{constructor(e){this._hash=Object.create(null),this._renderer=e,e.gc.addResourceHash(this,"_hash","resource"),e.gc.addCollection(this,"_hash","hash")}contextChange(e){this._gpu=e,this._hash=Object.create(null)}getBindGroup(e,t,r){const s=`${e._key}:${t._layoutKey<<4|r}`,i=this._hash[s];return i?(i._gcLastUsed=this._renderer.gc.now,i.gpuBindGroup):this._createBindGroup(s,e,t,r)}_createBindGroup(e,t,r,s){const i=this._gpu.device,n=r.layout[s],a=[],o=this._renderer;for(const h in n){const d=t.resources[h]??t.resources[n[h]];if(!d||d.destroyed)throw new Error(`[BindGroup] the resource bound as '${h}' was destroyed while a shader still uses it. Remove it from the shader before destroying it.`);let m;if(d._resourceType==="uniformGroup"){const p=d;o.ubo.updateUniformGroup(p);const f=p.buffer;m={buffer:o.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(d._resourceType==="buffer"){const p=d;m={buffer:o.buffer.getGPUBuffer(p),offset:0,size:p.descriptor.size}}else if(d._resourceType==="bufferResource"){const p=d;m={buffer:o.buffer.getGPUBuffer(p.buffer),offset:p.offset,size:p.size??p.buffer.descriptor.size}}else if(d._resourceType==="textureSampler"){const p=d;m=o.texture.getGpuSampler(p)}else if(d._resourceType==="textureSource"){const p=d;m=o.texture.getTextureView(p)}else if(d._resourceType==="textureView"){const p=d;m=o.texture.getTextureView(p.source,p.viewDescriptor)}a.push({binding:n[h],resource:m})}const c=o.shader.getProgramData(r).bindGroups[s],l=i.createBindGroup({layout:c,entries:a});return this._hash[e]=new tt(l,o.gc.now),l}destroy(){this._hash=null,this._renderer=null}}he.extension={type:[g.WebGPUSystem],name:"bindGroup"};class rt{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class pe{constructor(e){this._renderer=e,this._managedBuffers=new se({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e,this.destroyAll()}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,e._updateOffset,r.buffer,r.byteOffset+e._updateOffset,(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.data&&(Fe(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new rt(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}}pe.extension={type:[g.WebGPUSystem],name:"buffer"};class st{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 fe{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}}fe.extension={type:[g.WebGPUSystem],name:"colorMask"};const it=new Set(["apple","arm","qualcomm","img-tec"]);class k{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._options=e,this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>this._setGpu(t)),this._initPromise)}_setGpu(e){var t,r;this.gpu=e,this.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT=="number",tileBased:it.has((r=(t=e.adapter)==null?void 0:t.info)==null?void 0:r.vendor)},this._options.gpu||e.device.lost.then(()=>this._restoreDevice()).catch(s=>B("WebGPU device was lost and could not be restored",s)),this._renderer.runners.contextChange.emit(this.gpu)}async _restoreDevice(){if(!this._renderer)return;const e=await this._createDeviceAndAdaptor(this._options);if(!this._renderer){e.device.destroy();return}this._setGpu(e)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await E.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter});if(!t)throw new Error("WebGPU not supported. No GPU adapter was returned by navigator.gpu.requestAdapter().");const r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2","indirect-first-instance","bgra8unorm-storage","texture-formats-tier1"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r,requiredLimits:{maxSampledTexturesPerShaderStage:t.limits.maxSampledTexturesPerShaderStage,maxSamplersPerShaderStage:t.limits.maxSamplersPerShaderStage}});return{adapter:t,device:s}}destroy(){var e,t;(e=this._options)!=null&&e.gpu||(t=this.gpu)==null||t.device.destroy(),this.gpu=null,this.extensions=null,this._renderer=null}}k.extension={type:[g.WebGPUSystem],name:"device"};k.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class nt{constructor(e,t,r,s){this.gpuBundle=e,this.stateKey=t,this.device=r,this.label=s}}class me{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e;for(let t=0;t<16;t++)this._boundBindGroup[t]={bindGroup:null,program:null,key:null}}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){return this.endRenderPass(),this._clearCache(),this._passEncoder=this.commandEncoder.beginRenderPass(e.descriptor),this.renderPassEncoder=this._passEncoder,this._passEncoder}endRenderPass(){this._passEncoder&&this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null}beginBundle(e){if(this._passEncoder!==this.renderPassEncoder)throw new Error("Cannot begin a new render bundle while one is already being recorded.");this._clearCache();const t=this._renderer.pipeline,r=t.getBundleDescriptor();r.label=e,this._bundleStateKey=t.bundleStateKey,this._bundleLabel=e,this.renderPassEncoder=this._gpu.device.createRenderBundleEncoder(r)}endBundle(){const e=this.renderPassEncoder;if(!e||!("finish"in e))throw new Error("endBundle called without an active render bundle.");const t=e.finish({label:this._bundleLabel});return this.renderPassEncoder=this._passEncoder,this._clearCache(),new nt(t,this._bundleStateKey,this._gpu.device,this._bundleLabel)}isBundleValid(e){return(e==null?void 0:e.stateKey)===this._renderer.pipeline.bundleStateKey&&e.device===this._gpu.device}executeBundle(e){const t=[];if(Array.isArray(e))for(let r=0;r<e.length;r++)t[r]=this._getGpuBundle(e[r]);else t[0]=this._getGpuBundle(e);this._clearCache(),this._passEncoder.executeBundles(t)}_getGpuBundle(e){return this.isBundleValid(e)||B(`Render bundle ${(e==null?void 0:e.label)??"(unlabeled)"} was recorded against a different render target state or on a lost device. Re-record it — replaying it will either be rejected by WebGPU or draw with the wrong winding. Check encoder.isBundleValid(bundle) before executing.`),e.gpuBundle}setViewport(e){this._passEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setStencilReference(e){this._passEncoder.setStencilReference(e)}setPipelineFromGeometryProgramAndState(e,t,r,s,i){const n=this._renderer.pipeline.getPipeline(e,t,r,s,i);this.setPipeline(n)}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){const t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.key=null}setBindGroup(e,t,r){const s=this._boundBindGroup[e];if(s.bindGroup===t&&s.program===r&&s.key===t._key)return;s.bindGroup=t,s.program=r,s.key=t._key,t._touch(this._renderer.gc.now);const i=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,i)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(let s=0;s<r.length;s++)this._setVertexBuffer(s,e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){const r=e.gpuProgram,s=r.layout;for(let i=0;i<s.length;i++){const n=e.groups[i];!s[i]||!n||(t||this._syncBindGroup(n),this.setBindGroup(i,n,r))}}_syncBindGroup(e){const t=e.resources,r=e._resourceKeys;for(let s=0;s<r.length;s++){const i=t[r[s]];i&&i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:a,baseVertex:o,instanceCount:c,skipSync:l,firstInstance:h}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i,r._overrides),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,l),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexCount||t.indexBuffer.data.length,c??t.instanceCount,a||0,o||0,h||0):this.renderPassEncoder.draw(n||t.vertexCount,c??t.instanceCount,a||0,h||0)}drawIndirect(e){const{geometry:t,shader:r,state:s,topology:i,skipSync:n,indirectBuffer:a,indirectOffset:o}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i,r._overrides),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,n),t.indexBuffer?this.renderPassEncoder.drawIndexedIndirect(a,o):this.renderPassEncoder.drawIndirect(a,o)}finishRenderPass(){this._passEncoder&&(this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}_clearCache(){for(let e=0;e<16;e++){const t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.key=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,this.renderPassEncoder=null,this._passEncoder=null}contextChange(e){this._gpu=e}}me.extension={type:[g.WebGPUSystem],name:"encoder",priority:1};class ge{constructor(e){this.supportsOverrideConstants=!1,this._renderer=e}contextChange(){const e=this._renderer.device.gpu.device;this.maxTextures=Math.min(e.limits.maxSampledTexturesPerShaderStage,e.limits.maxSamplersPerShaderStage),this.maxBatchableTextures=this.maxTextures,this._detectOverrideConstantsSupport(e)}_detectOverrideConstantsSupport(e){e.pushErrorScope("validation");const t=e.createShaderModule({code:`override TEST_VALUE: f32 = 0.0;
|
|
1
|
+
import{J as te,a as re,o as g,K as se,L as Fe,w as B,D as E,j as A,B as De,N as ie,h as D,O as W,Q as ke,V as ne,W as S,x as L,X as F,Y as ae,y as T,M as oe,Z as ue,_ as Ie,$ as ce,a0 as ze,S as de,T as V,A as We,R as Ve}from"./index-CMIifH9a.js";import{c as Ne,u as He,U as $e,B as Ke,G as je,e as N,g as qe,l as Ye,a as Xe,t as Ze}from"./getTexelRangeRects-DhWvqmbJ.js";import{R as Je,S as Qe,d as et}from"./RenderTargetSystem-CAgQLo6K.js";import{C as H}from"./CanvasPool-DxzlD0_z.js";const M=re.for2d();class le{start(e,t,r){const s=e.renderer,i=s.encoder,n=r.gpuProgram;this._shader=r,this._geometry=t,i.setGeometry(t,n),M.blendMode="normal",s.pipeline.getPipeline(t,n,M,void 0,r._overrides);const a=s.globalUniforms.bindGroup;i.resetBindGroup(1),i.setBindGroup(0,a,n)}execute(e,t){const r=this._shader.gpuProgram,s=e.renderer,i=s.encoder;if(!t.bindGroup){const o=t.textures;t.bindGroup=te(o.textures,o.count,s.limits.maxBatchableTextures)}M.blendMode=t.blendMode;const n=s.bindGroup.getBindGroup(t.bindGroup,r,1),a=s.pipeline.getPipeline(this._geometry,r,M,t.topology,this._shader._overrides);t.bindGroup._touch(s.gc.now),i.setPipeline(a),i.renderPassEncoder.setBindGroup(1,n),i.renderPassEncoder.drawIndexed(t.size,1,t.start)}}le.extension={type:[g.WebGPUPipesAdaptor],name:"batch"};class tt{constructor(e,t){this.autoGarbageCollect=!0,this._gpuData=null,this.gpuBindGroup=e,this._gcLastUsed=t}unload(){this.gpuBindGroup=null}}class he{constructor(e){this._hash=Object.create(null),this._renderer=e,e.gc.addResourceHash(this,"_hash","resource"),e.gc.addCollection(this,"_hash","hash")}contextChange(e){this._gpu=e,this._hash=Object.create(null)}getBindGroup(e,t,r){const s=`${e._key}:${t._layoutKey<<4|r}`,i=this._hash[s];return i?(i._gcLastUsed=this._renderer.gc.now,i.gpuBindGroup):this._createBindGroup(s,e,t,r)}_createBindGroup(e,t,r,s){const i=this._gpu.device,n=r.layout[s],a=[],o=this._renderer;for(const h in n){const d=t.resources[h]??t.resources[n[h]];if(!d||d.destroyed)throw new Error(`[BindGroup] the resource bound as '${h}' was destroyed while a shader still uses it. Remove it from the shader before destroying it.`);let m;if(d._resourceType==="uniformGroup"){const p=d;o.ubo.updateUniformGroup(p);const f=p.buffer;m={buffer:o.buffer.getGPUBuffer(f),offset:0,size:f.descriptor.size}}else if(d._resourceType==="buffer"){const p=d;m={buffer:o.buffer.getGPUBuffer(p),offset:0,size:p.descriptor.size}}else if(d._resourceType==="bufferResource"){const p=d;m={buffer:o.buffer.getGPUBuffer(p.buffer),offset:p.offset,size:p.size??p.buffer.descriptor.size}}else if(d._resourceType==="textureSampler"){const p=d;m=o.texture.getGpuSampler(p)}else if(d._resourceType==="textureSource"){const p=d;m=o.texture.getTextureView(p)}else if(d._resourceType==="textureView"){const p=d;m=o.texture.getTextureView(p.source,p.viewDescriptor)}a.push({binding:n[h],resource:m})}const c=o.shader.getProgramData(r).bindGroups[s],l=i.createBindGroup({layout:c,entries:a});return this._hash[e]=new tt(l,o.gc.now),l}destroy(){this._hash=null,this._renderer=null}}he.extension={type:[g.WebGPUSystem],name:"bindGroup"};class rt{constructor(e){this.gpuBuffer=e}destroy(){this.gpuBuffer.destroy(),this.gpuBuffer=null}}class pe{constructor(e){this._renderer=e,this._managedBuffers=new se({renderer:e,type:"resource",onUnload:this.onBufferUnload.bind(this),name:"gpuBuffer"})}contextChange(e){this._gpu=e,this.destroyAll()}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,e._updateOffset,r.buffer,r.byteOffset+e._updateOffset,(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.data&&(Fe(e.data.buffer,t.getMappedRange(),e.data.byteOffset,e.data.byteLength),t.unmap()),e._gpuData[this._renderer.uid]=new rt(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}}pe.extension={type:[g.WebGPUSystem],name:"buffer"};class st{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 fe{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}}fe.extension={type:[g.WebGPUSystem],name:"colorMask"};const it=new Set(["apple","arm","qualcomm","img-tec"]);class k{constructor(e){this._renderer=e}async init(e){return this._initPromise?this._initPromise:(this._options=e,this._initPromise=(e.gpu?Promise.resolve(e.gpu):this._createDeviceAndAdaptor(e)).then(t=>this._setGpu(t)),this._initPromise)}_setGpu(e){var t,r;this.gpu=e,this.extensions={transientAttachment:typeof GPUTextureUsage.TRANSIENT_ATTACHMENT=="number",tileBased:it.has((r=(t=e.adapter)==null?void 0:t.info)==null?void 0:r.vendor)},this._options.gpu||e.device.lost.then(()=>this._restoreDevice()).catch(s=>B("WebGPU device was lost and could not be restored",s)),this._renderer.runners.contextChange.emit(this.gpu)}async _restoreDevice(){if(!this._renderer)return;const e=await this._createDeviceAndAdaptor(this._options);if(!this._renderer){e.device.destroy();return}this._setGpu(e)}contextChange(e){this._renderer.gpu=e}async _createDeviceAndAdaptor(e){const t=await E.get().getNavigator().gpu.requestAdapter({powerPreference:e.powerPreference,forceFallbackAdapter:e.forceFallbackAdapter});if(!t)throw new Error("WebGPU not supported. No GPU adapter was returned by navigator.gpu.requestAdapter().");const r=["texture-compression-bc","texture-compression-astc","texture-compression-etc2","indirect-first-instance","bgra8unorm-storage","texture-formats-tier1"].filter(i=>t.features.has(i)),s=await t.requestDevice({requiredFeatures:r,requiredLimits:{maxSampledTexturesPerShaderStage:t.limits.maxSampledTexturesPerShaderStage,maxSamplersPerShaderStage:t.limits.maxSamplersPerShaderStage}});return{adapter:t,device:s}}destroy(){var e,t;(e=this._options)!=null&&e.gpu||(t=this.gpu)==null||t.device.destroy(),this.gpu=null,this.extensions=null,this._renderer=null}}k.extension={type:[g.WebGPUSystem],name:"device"};k.defaultOptions={powerPreference:void 0,forceFallbackAdapter:!1};class nt{constructor(e,t,r,s){this.gpuBundle=e,this.stateKey=t,this.device=r,this.label=s}}class me{constructor(e){this._boundBindGroup=Object.create(null),this._boundVertexBuffer=Object.create(null),this._renderer=e;for(let t=0;t<16;t++)this._boundBindGroup[t]={bindGroup:null,program:null,key:null}}renderStart(){this.commandFinished=new Promise(e=>{this._resolveCommandFinished=e}),this.commandEncoder=this._renderer.gpu.device.createCommandEncoder()}beginRenderPass(e){return this.endRenderPass(),this._clearCache(),this._passEncoder=this.commandEncoder.beginRenderPass(e.descriptor),this.renderPassEncoder=this._passEncoder,this._passEncoder}endRenderPass(){this._passEncoder&&this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null}beginBundle(e){if(this._passEncoder!==this.renderPassEncoder)throw new Error("Cannot begin a new render bundle while one is already being recorded.");this._clearCache();const t=this._renderer.pipeline,r=t.getBundleDescriptor();r.label=e,this._bundleStateKey=t.bundleStateKey,this._bundleLabel=e,this.renderPassEncoder=this._gpu.device.createRenderBundleEncoder(r)}endBundle(){const e=this.renderPassEncoder;if(!e||!("finish"in e))throw new Error("endBundle called without an active render bundle.");const t=e.finish({label:this._bundleLabel});return this.renderPassEncoder=this._passEncoder,this._clearCache(),new nt(t,this._bundleStateKey,this._gpu.device,this._bundleLabel)}isBundleValid(e){return(e==null?void 0:e.stateKey)===this._renderer.pipeline.bundleStateKey&&e.device===this._gpu.device}executeBundle(e){const t=[];if(Array.isArray(e))for(let r=0;r<e.length;r++)t[r]=this._getGpuBundle(e[r]);else t[0]=this._getGpuBundle(e);this._clearCache(),this._passEncoder.executeBundles(t)}_getGpuBundle(e){return this.isBundleValid(e)||B(`Render bundle ${(e==null?void 0:e.label)??"(unlabeled)"} was recorded against a different render target state or on a lost device. Re-record it — replaying it will either be rejected by WebGPU or draw with the wrong winding. Check encoder.isBundleValid(bundle) before executing.`),e.gpuBundle}setViewport(e){this._passEncoder.setViewport(e.x,e.y,e.width,e.height,0,1)}setStencilReference(e){this._passEncoder.setStencilReference(e)}setPipelineFromGeometryProgramAndState(e,t,r,s,i){const n=this._renderer.pipeline.getPipeline(e,t,r,s,i);this.setPipeline(n)}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){const t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.key=null}setBindGroup(e,t,r){const s=this._boundBindGroup[e];if(s.bindGroup===t&&s.program===r&&s.key===t._key)return;s.bindGroup=t,s.program=r,s.key=t._key,t._touch(this._renderer.gc.now);const i=this._renderer.bindGroup.getBindGroup(t,r,e);this.renderPassEncoder.setBindGroup(e,i)}setGeometry(e,t){const r=this._renderer.pipeline.getBufferNamesToBind(e,t);for(let s=0;s<r.length;s++)this._setVertexBuffer(s,e.attributes[r[s]].buffer);e.indexBuffer&&this._setIndexBuffer(e.indexBuffer)}_setShaderBindGroups(e,t){const r=e.gpuProgram,s=r.layout;for(let i=0;i<s.length;i++){const n=e.groups[i];!s[i]||!n||(t||this._syncBindGroup(n),this.setBindGroup(i,n,r))}}_syncBindGroup(e){const t=e.resources,r=e._resourceKeys;for(let s=0;s<r.length;s++){const i=t[r[s]];i&&i.isUniformGroup&&this._renderer.ubo.updateUniformGroup(i)}}draw(e){const{geometry:t,shader:r,state:s,topology:i,size:n,start:a,baseVertex:o,instanceCount:c,skipSync:l,firstInstance:h}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i,r._overrides),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,l),t.indexBuffer?this.renderPassEncoder.drawIndexed(n||t.indexCount||t.indexBuffer.data.length,c??t.instanceCount,a||0,o||0,h||0):this.renderPassEncoder.draw(n||t.vertexCount,c??t.instanceCount,a||0,h||0)}drawIndirect(e){const{geometry:t,shader:r,state:s,topology:i,skipSync:n,indirectBuffer:a,indirectOffset:o}=e;this.setPipelineFromGeometryProgramAndState(t,r.gpuProgram,s,i,r._overrides),this.setGeometry(t,r.gpuProgram),this._setShaderBindGroups(r,n),t.indexBuffer?this.renderPassEncoder.drawIndexedIndirect(a,o):this.renderPassEncoder.drawIndirect(a,o)}finishRenderPass(){this._passEncoder&&(this._passEncoder.end(),this.renderPassEncoder=null,this._passEncoder=null)}postrender(){this.finishRenderPass(),this._gpu.device.queue.submit([this.commandEncoder.finish()]),this._resolveCommandFinished(),this.commandEncoder=null}_clearCache(){for(let e=0;e<16;e++){const t=this._boundBindGroup[e];t.bindGroup=null,t.program=null,t.key=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,this.renderPassEncoder=null,this._passEncoder=null}contextChange(e){this._gpu=e}}me.extension={type:[g.WebGPUSystem],name:"encoder",priority:1};class ge{constructor(e){this.supportsOverrideConstants=!1,this._renderer=e}contextChange(){const e=this._renderer.device.gpu.device;this.maxTextures=Math.min(e.limits.maxSampledTexturesPerShaderStage,e.limits.maxSamplersPerShaderStage),this.maxBatchableTextures=this.maxTextures,this._detectOverrideConstantsSupport(e)}_detectOverrideConstantsSupport(e){e.pushErrorScope("validation");const t=e.createShaderModule({code:`override TEST_VALUE: f32 = 0.0;
|
|
2
2
|
@compute @workgroup_size(1) fn main() {}`});e.createComputePipeline({layout:"auto",compute:{module:t,entryPoint:"main",constants:{TEST_VALUE:1}}}),e.popErrorScope().then(r=>{this.supportsOverrideConstants=!r})}destroy(){}}ge.extension={type:[g.WebGPUSystem],name:"limits"};class _e{constructor(e){this._renderer=e,e.renderTarget.onRenderTargetChange.add(this)}contextChange(){this._activeGpuRenderTarget=null}onRenderTargetChange(e){const t=this._renderer.renderTarget.getGpuRenderTarget(e);this._activeRenderTarget=e,this._activeGpuRenderTarget=t,this.setStencilMode(t.stencilMode,t.stencilReference)}setStencilMode(e,t){const r=this._activeGpuRenderTarget??(this._activeGpuRenderTarget=this._renderer.renderTarget.getGpuRenderTarget(this._activeRenderTarget));r.stencilMode=e,r.stencilReference=t;const s=this._renderer;s.pipeline.setStencilMode(e),s.encoder.setStencilReference(t)}destroy(){this._renderer.renderTarget.onRenderTargetChange.remove(this),this._renderer=null,this._activeRenderTarget=null,this._activeGpuRenderTarget=null}}_e.extension={type:[g.WebGPUSystem],name:"stencil"};const U={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 at(u){const e=u.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=U[s.data.type].size;const n=U[s.data.type].align;if(!U[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 ot(u,e){const{size:t,align:r}=U[u.data.type],s=(Math.max(t,r)-t)/4,i=u.data.type.indexOf("i32")>=0?"dataInt32":"data";return`
|
|
3
3
|
v = uv.${u.data.name};
|
|
4
4
|
${e!==0?`offset += ${e};`:""}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{z as A,U as Z,P as y,H as te,o as b,E as ie,w as f,y as w,I as V}from"./index-ByCDDgCj.js";import"./webworkerAll-CkYM11AB.js";import"./canvasUtils-Cbq_vt2i.js";import"./CanvasPool-D8o5qooo.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,n=this._canvas.height,s=t.width/i*this._renderer.resolution,o=t.height/n*this._renderer.resolution,r=t.left,l=t.top,d=`translate(${r}px, ${l}px) scale(${s}, ${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,n=this.canvas.height,s=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=s,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 M{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=M.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new y,this.page=new y,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,n,s){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,L=/iPod/i,S=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,x=/\bAndroid(?:.+)Mobile\b/i,R=/Android/i,E=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,O=/Silk/i,_=/Windows Phone/i,X=/\bWindows(?:.+)ARM\b/i,K=/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 ne(a){return function(e){return e.test(a)}}function j(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 n=ne(t),s={apple:{phone:n(I)&&!n(_),ipod:n(L),tablet:!n(I)&&(n(S)||$(e))&&!n(_),universal:n(U),device:(n(I)||n(L)||n(S)||n(U)||$(e))&&!n(_)},amazon:{phone:n(E),tablet:!n(E)&&n(O),device:n(E)||n(O)},android:{phone:!n(_)&&n(E)||!n(_)&&n(x),tablet:!n(_)&&!n(E)&&!n(x)&&(n(O)||n(R)),device:!n(_)&&(n(E)||n(O)||n(x)||n(R))||n(/\bokhttp\b/i)},windows:{phone:n(_),tablet:n(X),device:n(_)||n(X)},other:{blackberry:n(K),blackberry10:n(Y),opera:n(H),firefox:n(N),chrome:n(F),device:n(K)||n(Y)||n(H)||n(N)||n(F)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const se=j.default??j,oe=se(globalThis.navigator),re=9,G=100,ae=0,he=0,W=2,z=1,le=-1e3,ce=-1e3,de=2,C=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=`${le}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=`${he}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=W.toString(),this._canvasObserver=new q({domElement:this._div,renderer:this._renderer})),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._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(s=>{s.parentNode&&s.parentNode.removeChild(s)}),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,this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),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 n=this._children[i];t.has(i)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,te(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const n=this._children[i];if(!n._accessibleActive||!n._accessibleDiv)continue;const s=n._accessibleDiv,o=n.hitArea||n.getBounds().rectangle;if(n.hitArea){const r=n.worldTransform;s.style.left=`${r.tx+o.x*r.a}px`,s.style.top=`${r.ty+o.y*r.d}px`,s.style.width=`${o.width*r.a}px`,s.style.height=`${o.height*r.d}px`}else this._capHitArea(o),s.style.left=`${o.x}px`,s.style.top=`${o.y}px`,s.style.width=`${o.width}px`,s.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"),this.debug||(i.style.color="transparent")):(i=document.createElement(e.accessibleType),i.style.cssText=`
|
|
1
|
+
import{z as A,U as Z,P as y,H as te,o as b,E as ie,w as f,y as w,I as V}from"./index-CMIifH9a.js";import"./webworkerAll-B8F2O1DY.js";import"./canvasUtils-LeZLwOlL.js";import"./CanvasPool-DxzlD0_z.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,n=this._canvas.height,s=t.width/i*this._renderer.resolution,o=t.height/n*this._renderer.resolution,r=t.left,l=t.top,d=`translate(${r}px, ${l}px) scale(${s}, ${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,n=this.canvas.height,s=t.contentRect.width/i*this._renderer.resolution,o=t.contentRect.height/n*this._renderer.resolution;(this._lastScaleX!==s||this._lastScaleY!==o)&&(this.updateTranslation(),this._lastScaleX=s,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 M{constructor(e){this.bubbles=!0,this.cancelBubble=!0,this.cancelable=!1,this.composed=!1,this.defaultPrevented=!1,this.eventPhase=M.prototype.NONE,this.propagationStopped=!1,this.propagationImmediatelyStopped=!1,this.layer=new y,this.page=new y,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,n,s){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,L=/iPod/i,S=/iPad/i,U=/\biOS-universal(?:.+)Mac\b/i,x=/\bAndroid(?:.+)Mobile\b/i,R=/Android/i,E=/(?:SD4930UR|\bSilk(?:.+)Mobile\b)/i,O=/Silk/i,_=/Windows Phone/i,X=/\bWindows(?:.+)ARM\b/i,K=/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 ne(a){return function(e){return e.test(a)}}function j(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 n=ne(t),s={apple:{phone:n(I)&&!n(_),ipod:n(L),tablet:!n(I)&&(n(S)||$(e))&&!n(_),universal:n(U),device:(n(I)||n(L)||n(S)||n(U)||$(e))&&!n(_)},amazon:{phone:n(E),tablet:!n(E)&&n(O),device:n(E)||n(O)},android:{phone:!n(_)&&n(E)||!n(_)&&n(x),tablet:!n(_)&&!n(E)&&!n(x)&&(n(O)||n(R)),device:!n(_)&&(n(E)||n(O)||n(x)||n(R))||n(/\bokhttp\b/i)},windows:{phone:n(_),tablet:n(X),device:n(_)||n(X)},other:{blackberry:n(K),blackberry10:n(Y),opera:n(H),firefox:n(N),chrome:n(F),device:n(K)||n(Y)||n(H)||n(N)||n(F)},any:!1,phone:!1,tablet:!1};return s.any=s.apple.device||s.android.device||s.windows.device||s.other.device,s.phone=s.apple.phone||s.android.phone||s.windows.phone,s.tablet=s.apple.tablet||s.android.tablet||s.windows.tablet,s}const se=j.default??j,oe=se(globalThis.navigator),re=9,G=100,ae=0,he=0,W=2,z=1,le=-1e3,ce=-1e3,de=2,C=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=`${le}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=`${he}px`,this._div.style.pointerEvents="none",this._div.style.zIndex=W.toString(),this._canvasObserver=new q({domElement:this._div,renderer:this._renderer})),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._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(s=>{s.parentNode&&s.parentNode.removeChild(s)}),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,this._activateOnTab&&globalThis.addEventListener("keydown",this._boundOnKeyDown,!1),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 n=this._children[i];t.has(i)||(n._accessibleDiv&&n._accessibleDiv.parentNode&&(n._accessibleDiv.parentNode.removeChild(n._accessibleDiv),this._getPool(n.accessibleType).push(n._accessibleDiv),n._accessibleDiv=null),n._accessibleActive=!1,te(this._children,i,1))}this._renderer.renderingToScreen&&this._canvasObserver.ensureAttached();for(let i=0;i<this._children.length;i++){const n=this._children[i];if(!n._accessibleActive||!n._accessibleDiv)continue;const s=n._accessibleDiv,o=n.hitArea||n.getBounds().rectangle;if(n.hitArea){const r=n.worldTransform;s.style.left=`${r.tx+o.x*r.a}px`,s.style.top=`${r.ty+o.y*r.d}px`,s.style.width=`${o.width*r.a}px`,s.style.height=`${o.height*r.d}px`}else this._capHitArea(o),s.style.left=`${o.x}px`,s.style.top=`${o.y}px`,s.style.width=`${o.width}px`,s.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"),this.debug||(i.style.color="transparent")):(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,C as I,g as C}from"./index-
|
|
1
|
+
import{D as y,C as I,g as C}from"./index-CMIifH9a.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(),e!==16777215&&(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),e!==16777215&&(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{M as a,h as c};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{w as _,f as g,h as d,u as U,B as y,j as h,E as I,k as p}from"./index-
|
|
1
|
+
import{w as _,f as g,h as d,u as U,B as y,j as h,E as I,k as p}from"./index-CMIifH9a.js";const x={name:"local-uniform-bit",vertex:{header:`
|
|
2
2
|
|
|
3
3
|
struct LocalUniforms {
|
|
4
4
|
uTransformMatrix:mat3x3<f32>,
|