@phil65/demoreel 0.3.1 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +47 -12
- package/THIRD_PARTY_NOTICES.md +1 -1
- package/dist/args.js +26 -0
- package/dist/cli.js +53 -3
- package/dist/compose.d.ts +4 -0
- package/dist/compose.js +4 -0
- package/dist/gif.d.ts +16 -0
- package/dist/gif.js +19 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +4 -2
- package/dist/mcp.d.ts +5 -0
- package/dist/mcp.js +441 -0
- package/dist/openscreen/project.js +3 -3
- package/dist/project.d.ts +51 -1
- package/dist/project.js +89 -1
- package/dist/record.d.ts +6 -1
- package/dist/record.js +2 -1
- package/dist/renderer/assets/CanvasPool-PBu3bHFZ.js +1 -0
- package/dist/renderer/assets/CanvasRenderer-HmF-4gyW.js +1 -0
- package/dist/renderer/assets/RenderTargetSystem-Dk1U4wDJ.js +184 -0
- package/dist/renderer/assets/WebGLRenderer-C0v9HBel.js +149 -0
- package/dist/renderer/assets/WebGPURenderer-Ce0-U9Q1.js +95 -0
- package/dist/renderer/assets/{browserAll-aHn2isHo.js → browserAll-DhvWQ7nM.js} +2 -2
- package/dist/renderer/assets/canvasUtils-KRroregW.js +1 -0
- package/dist/renderer/assets/{getTexelRangeRects-yD6MQ0xy.js → getTexelRangeRects-D3pwCyRt.js} +3 -3
- package/dist/renderer/assets/index-CE-lli1m.js +556 -0
- package/dist/renderer/assets/init-DfmWKarH.js +83 -0
- package/dist/renderer/assets/webworkerAll-B41hok0-.js +1 -0
- package/dist/renderer/index.html +1 -6
- package/dist/scene.d.ts +24 -4
- package/dist/scene.js +74 -5
- package/dist/sheet.d.ts +6 -0
- package/dist/sheet.js +10 -0
- package/dist/types.d.ts +4 -0
- package/package.json +7 -1
- package/skills/demoreel/SKILL.md +161 -0
- package/dist/renderer/assets/CanvasPool-CHSHS1-v.js +0 -23
- package/dist/renderer/assets/RenderTargetSystem-EAUH9iQk.js +0 -404
- package/dist/renderer/assets/canvasUtils-n5g2f3_X.js +0 -1
- package/dist/renderer/assets/getTextureBatchBindGroup-Bwvgbco6.js +0 -1
- package/dist/renderer/assets/index-BwP6rH7I.js +0 -556
- package/dist/renderer/assets/init-C2Za5NQh.js +0 -83
- package/dist/renderer/assets/webworkerAll-JSSmbaR2.js +0 -1
package/dist/record.js
CHANGED
|
@@ -92,7 +92,7 @@ export async function recordScenario(input, opts = {}) {
|
|
|
92
92
|
});
|
|
93
93
|
await recorder.start();
|
|
94
94
|
return recorder;
|
|
95
|
-
}, { seed: session.scenario.seed, pacing: session.scenario.pacing });
|
|
95
|
+
}, { seed: session.scenario.seed, pacing: session.scenario.pacing, clickRipple: session.scenario.clickRipple });
|
|
96
96
|
const tRun = Date.now();
|
|
97
97
|
await session.scenario.run(scene, { baseUrl: session.baseUrl });
|
|
98
98
|
// Hold the last frame so the final zoom-out and captions finish.
|
|
@@ -134,6 +134,7 @@ export async function recordScenario(input, opts = {}) {
|
|
|
134
134
|
zoom: session.scenario.zoom,
|
|
135
135
|
look: session.scenario.look,
|
|
136
136
|
trimIdle: session.scenario.trimIdle,
|
|
137
|
+
cursor: session.scenario.cursor,
|
|
137
138
|
});
|
|
138
139
|
const result = {
|
|
139
140
|
videoPath,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Q as e,_t as t,ct as n,ht as r,mt as i,q as a,st as o,yt as s}from"./index-CE-lli1m.js";var c=32767;function l(e,t){return(e<<17)+(t<<2)}var u=new class{constructor(t){this._buckets=new Map,this._screens=new e,this._enableFullScreen=!1,this.canvasOptions=t||{}}get enableFullScreen(){return t(s,`CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize.`),this._enableFullScreen}set enableFullScreen(e){t(s,`CanvasPool.enableFullScreen is no longer used, the pool sizes canvases to the screens registered with setScreenSize.`),this._enableFullScreen=e}_createCanvasAndContext(e,t){let n=a.get().createCanvas();return n.width=e,n.height=t,{canvas:n,context:n.getContext(`2d`)}}getOptimalCanvasAndContext(e,t,r=1){let{width:i,height:a}=this.getOptimalSize(e,t,r);(i>c||a>c)&&n(`CanvasPool: ${i}x${a} is larger than the ${c}px pool key limit, canvases of this size may be pooled together`);let o=l(i,a),s=this._buckets.get(o);s||(s=[],this._buckets.set(o,s));let u=s.pop();return u||=this._createCanvasAndContext(i,a),u}getOptimalSize(e,t,n=1){let i=Math.ceil(e*n-1e-6),a=Math.ceil(t*n-1e-6),o=r(i),s=this._screens.getFittingWidth(i),c=r(a),l=this._screens.getFittingHeight(a);return{width:s===void 0?o:Math.min(s,o),height:l===void 0?c:Math.min(l,c)}}returnCanvasAndContext(e){let{width:t,height:n}=e.canvas,r=this._buckets.get(l(t,n));r&&(e.context.resetTransform(),e.context.clearRect(0,0,t,n),r.push(e))}setScreenSize(e,t,n){this._screens.set(e,t,n)&&this._pruneScreenCanvases()}removeScreen(e){this._screens.remove(e)&&this._pruneScreenCanvases()}clear(){this._buckets.clear()}_pruneScreenCanvases(){for(let[e]of this._buckets){let t=e>>>17,n=e>>>2&32767;(!i(t)&&!this._screens.hasWidth(t)||!i(n)&&!this._screens.hasHeight(n))&&this._buckets.delete(e)}}};o.register(u);export{u as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ct as e,Dt as t,Et as n,K as r,L as i,O as a,St as o,a as s,ct as c,dt as l,et as u,i as d,lt as f,nt as p,o as m,q as h,r as g,s as _,t as v}from"./index-CE-lli1m.js";import{a as y,c as b,i as x,l as S,o as C,r as w,s as T,t as E}from"./RenderTargetSystem-Dk1U4wDJ.js";import{n as D,t as O}from"./canvasUtils-KRroregW.js";var k=class e{static _getPatternRepeat(e,t){let n=e&&e!==`clamp-to-edge`,r=t&&t!==`clamp-to-edge`;return n&&r?`repeat`:n?`repeat-x`:r?`repeat-y`:`no-repeat`}start(e,t,n){}execute(t,n){let r=n.elements;if(!r||!r.length)return;let i=t.renderer,a=i.canvasContext,s=a.activeContext;for(let t=0;t<r.length;t++){let c=r[t];if(!c.packAsQuad)continue;let l=c,d=l.texture,f=d?O.getCanvasSource(d):null;if(!f)continue;let m=d.source.style,h=a.smoothProperty,g=m.scaleMode!==`nearest`;s[h]!==g&&(s[h]=g),a.setBlendMode(n.blendMode);let _=i.globalUniforms.globalUniformData?.worldColor??0xffffffff,v=l.color,y=(_>>>24&255)/255,b=(v>>>24&255)/255,x=i.filter?.alphaMultiplier??1,S=y*b*x;if(S<=0)continue;s.globalAlpha=S;let C=_&0xffffff,w=v&0xffffff,T=u(p(w,C)),E=d.frame,D=m.addressModeU??m.addressMode,k=m.addressModeV??m.addressMode,A=e._getPatternRepeat(D,k),j=d.source._resolution??d.source.resolution??1,M=l.renderable?.renderGroup?.isCachedAsTexture,N=E.x*j,P=E.y*j,F=E.width*j,I=E.height*j,L=l.bounds,R=i.renderTarget.renderTarget.isRoot,z=L.minX,B=L.minY,V=L.maxX-L.minX,H=L.maxY-L.minY,U=d.rotate,W=d.uvs,G=Math.min(W.x0,W.x1,W.x2,W.x3,W.y0,W.y1,W.y2,W.y3),K=Math.max(W.x0,W.x1,W.x2,W.x3,W.y0,W.y1,W.y2,W.y3),q=A!==`no-repeat`&&(G<0||K>1),J=U&&(!!q||T===0xffffff&&!U);J?(e._tempPatternMatrix.copyFrom(l.transform),o.matrixAppendRotationInv(e._tempPatternMatrix,U,z,B,V,H),a.setContextTransform(e._tempPatternMatrix,l.roundPixels===1,void 0,M&&R)):a.setContextTransform(l.transform,l.roundPixels===1,void 0,M&&R);let Y=V,X=H,Z=J?0:z,Q=J?0:B;if(!J&&l.roundPixels===1&&(Z|=0,Q|=0),q){let t=f,n=T!==0xffffff&&!U,r=E.width<=d.source.width&&E.height<=d.source.height;n&&r&&(t=O.getTintedCanvas({texture:d},T));let i=s.createPattern(t,A);if(!i)continue;let a=Y,o=X;if(a===0||o===0)continue;let c=1/a,l=1/o,u=(W.x1-W.x0)*c,p=(W.y1-W.y0)*c,m=(W.x3-W.x0)*l,h=(W.y3-W.y0)*l,g=W.x0-u*Z-m*Q,_=W.y0-p*Z-h*Q,v=d.source.pixelWidth,y=d.source.pixelHeight;e._tempPatternMatrix.set(u*v,p*y,m*v,h*y,g*v,_*y),O.applyPatternTransform(i,e._tempPatternMatrix),s.fillStyle=i,s.fillRect(Z,Q,Y,X)}else{let e=T!==0xffffff||U?O.getTintedCanvas({texture:d},T):f,t=e!==f;s.drawImage(e,t?0:N,t?0:P,t?e.width:F,t?e.height:I,Z,Q,Y,X)}}}};k._tempPatternMatrix=new e,k.extension={type:[n.CanvasPipesAdaptor],name:`batch`};var A=k,j=class{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,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;this._colorStackIndex--;let i=r[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1}))}execute(e){}destroy(){this._renderer=null,this._colorStack=null}};j.extension={type:[n.CanvasPipes],name:`colorMask`};function M(e,t,n,r,i,a){a=Math.max(0,Math.min(a,Math.min(r,i)/2)),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n)}function N(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`roundedRectangle`:{let n=t;M(e,n.x,n.y,n.width,n.height,n.radius);break}case`circle`:{let n=t;e.moveTo(n.x+n.radius,n.y),e.arc(n.x,n.y,n.radius,0,Math.PI*2);break}case`ellipse`:{let n=t;e.ellipse?(e.moveTo(n.x+n.halfWidth,n.y),e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,Math.PI*2)):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.moveTo(1,0),e.arc(0,0,1,0,Math.PI*2),e.restore());break}case`triangle`:{let n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{let n=t,r=n.points;if(!r?.length)break;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}function P(e,t,n){let r=[],i=[],a=[];if(!d[t.type]?.build(t,r))return!1;let o=t.closePath??!0;_(r,n,!1,o,i,a);for(let t=0;t<a.length;t+=3){let n=a[t]*2,r=a[t+1]*2,o=a[t+2]*2;e.moveTo(i[n],i[n+1]),e.lineTo(i[r],i[r+1]),e.lineTo(i[o],i[o+1]),e.closePath()}return!0}function F(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){let r=t[n];if(!r?.shape)continue;let i=r.transform,a=i&&!i.isIdentity();a&&(e.save(),e.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),N(e,r.shape),a&&e.restore()}return!0}var I=class{constructor(e){this._warnedMaskTypes=new Set,this._canvasMaskStack=[],this._renderer=e}push(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`stencilMask`,action:`pushMaskBegin`,mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`stencilMask`,action:`popMaskEnd`,mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){if(e.action!==`pushMaskBegin`&&e.action!==`popMaskEnd`)return;let t=this._renderer,n=t.canvasContext,r=n?.activeContext;if(!r)return;if(e.action===`popMaskEnd`){this._canvasMaskStack.pop()&&r.restore();return}e.inverse&&this._warnOnce(`inverse`,`CanvasRenderer: inverse masks are not supported on Canvas2D; ignoring inverse flag.`);let i=e.mask.mask;if(!(i instanceof v)){this._warnOnce(`nonGraphics`,`CanvasRenderer: only Graphics masks are supported in Canvas2D; skipping mask.`),this._canvasMaskStack.push(!1);return}let a=i,o=a.context?.instructions;if(!o?.length){this._canvasMaskStack.push(!1);return}r.save(),n.setContextTransform(a.groupTransform,(t._roundPixels|a._roundPixels)===1),r.beginPath();let s=!1,c=!1;for(let e=0;e<o.length;e++){let t=o[e],n=t.action;if(n!==`fill`&&n!==`stroke`)continue;let i=t.data,a=i?.path?.shapePath;if(!a?.shapePrimitives?.length)continue;let l=n===`stroke`,u=a.shapePrimitives;for(let e=0;e<u.length;e++){let t=u[e];if(!t?.shape)continue;let n=t.transform,a=n&&!n.isIdentity();a&&(r.save(),r.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),l&&i.style?s=P(r,t.shape,i.style)||s:(N(r,t.shape),c=F(r,t.holes)||c,s=!0),a&&r.restore()}}s?(c?r.clip(`evenodd`):r.clip(),this._canvasMaskStack.push(!0)):(r.restore(),this._canvasMaskStack.push(!1))}destroy(){this._renderer=null,this._warnedMaskTypes=null,this._canvasMaskStack=null}_warnOnce(e,t){this._warnedMaskTypes.has(e)||(this._warnedMaskTypes.add(e),c(t))}};I.extension={type:[n.CanvasPipes],name:`stencilMask`};var L=`source-over`;function R(){let e=D(),t=Object.create(null);return t.inherit=L,t.none=L,t.normal=`source-over`,t.add=`lighter`,t.multiply=e?`multiply`:L,t.screen=e?`screen`:L,t.overlay=e?`overlay`:L,t.darken=e?`darken`:L,t.lighten=e?`lighten`:L,t[`color-dodge`]=e?`color-dodge`:L,t[`color-burn`]=e?`color-burn`:L,t[`hard-light`]=e?`hard-light`:L,t[`soft-light`]=e?`soft-light`:L,t.difference=e?`difference`:L,t.exclusion=e?`exclusion`:L,t.saturation=e?`saturation`:L,t.color=e?`color`:L,t.luminosity=e?`luminosity`:L,t[`linear-burn`]=e?`color-burn`:L,t[`linear-dodge`]=e?`color-dodge`:L,t[`linear-light`]=e?`hard-light`:L,t[`pin-light`]=e?`hard-light`:L,t[`vivid-light`]=e?`hard-light`:L,t[`hard-mix`]=L,t.negation=e?`difference`:L,t[`normal-npm`]=t.normal,t[`add-npm`]=t.add,t[`screen-npm`]=t.screen,t.erase=`destination-out`,t.subtract=L,t.divide=L,t.min=L,t.max=L,t}var z=new e,B=class{constructor(e){this.activeResolution=1,this.smoothProperty=`imageSmoothingEnabled`,this.blendModes=R(),this._activeBlendMode=`normal`,this._projTransform=null,this._outerBlend=!1,this._warnedBlendModes=new Set,this._renderer=e}resolutionChange(e){this.activeResolution=e}init(){let 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){let e=this.rootContext;e.webkitImageSmoothingEnabled?this.smoothProperty=`webkitImageSmoothingEnabled`:e.mozImageSmoothingEnabled?this.smoothProperty=`mozImageSmoothingEnabled`:e.oImageSmoothingEnabled?this.smoothProperty=`oImageSmoothingEnabled`:e.msImageSmoothingEnabled&&(this.smoothProperty=`msImageSmoothingEnabled`)}}setContextTransform(t,n,r,i){let a=i?e.IDENTITY:this._renderer.globalUniforms.globalUniformData?.worldTransformMatrix||e.IDENTITY,o=z;o.copyFrom(a),o.append(t);let s=this._projTransform,c=this.activeResolution;if(r||=c,s){let t=e.shared;t.copyFrom(o),t.prepend(s),o=t}n?this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*c|0,o.ty*c|0):this.activeContext.setTransform(o.a*r,o.b*r,o.c*r,o.d*r,o.tx*c,o.ty*c)}clear(e,t){let n=this.activeContext,r=this._renderer;if(n.clearRect(0,0,r.width,r.height),e){let i=f.shared.setValue(e);n.globalAlpha=t??i.alpha,n.fillStyle=i.toHex(),n.fillRect(0,0,r.width,r.height),n.globalAlpha=1}}setBlendMode(e){if(this._activeBlendMode===e)return;this._activeBlendMode=e,this._outerBlend=!1;let t=this.blendModes[e];t?this.activeContext.globalCompositeOperation=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`)}destroy(){this.rootContext=null,this.activeContext=null,this._warnedBlendModes.clear()}};B.extension={type:[n.CanvasSystem],name:`canvasContext`};var V=class{constructor(){this.maxTextures=16,this.maxBatchableTextures=16,this.maxUniformBindings=0,this.minUniformBufferOffsetAlignment=0}init(){}};V.extension={type:[n.CanvasSystem],name:`limits`};var H=`#808080`,U=new e,W=new e,G=new e,K=new e,q=new e;function J(e,t,n){e.beginPath();for(let r=0;r<n.length;r+=3){let i=n[r]*2,a=n[r+1]*2,o=n[r+2]*2;e.moveTo(t[i],t[i+1]),e.lineTo(t[a],t[a+1]),e.lineTo(t[o],t[o+1]),e.closePath()}e.fill()}function Y(e){return`#${(e&0xffffff).toString(16).padStart(6,`0`)}`}function X(e,t,n,r,i,a){a=Math.max(0,Math.min(a,Math.min(r,i)/2)),e.moveTo(t+a,n),e.lineTo(t+r-a,n),e.quadraticCurveTo(t+r,n,t+r,n+a),e.lineTo(t+r,n+i-a),e.quadraticCurveTo(t+r,n+i,t+r-a,n+i),e.lineTo(t+a,n+i),e.quadraticCurveTo(t,n+i,t,n+i-a),e.lineTo(t,n+a),e.quadraticCurveTo(t,n,t+a,n)}function Z(e,t){switch(t.type){case`rectangle`:{let n=t;e.rect(n.x,n.y,n.width,n.height);break}case`roundedRectangle`:{let n=t;X(e,n.x,n.y,n.width,n.height,n.radius);break}case`circle`:{let n=t;e.arc(n.x,n.y,n.radius,0,Math.PI*2);break}case`ellipse`:{let n=t;e.ellipse?e.ellipse(n.x,n.y,n.halfWidth,n.halfHeight,0,0,Math.PI*2):(e.save(),e.translate(n.x,n.y),e.scale(n.halfWidth,n.halfHeight),e.arc(0,0,1,0,Math.PI*2),e.restore());break}case`triangle`:{let n=t;e.moveTo(n.x,n.y),e.lineTo(n.x2,n.y2),e.lineTo(n.x3,n.y3),e.closePath();break}default:{let n=t,r=n.points;if(!r?.length)break;e.moveTo(r[0],r[1]);for(let t=2;t<r.length;t+=2)e.lineTo(r[t],r[t+1]);n.closePath&&e.closePath();break}}}function Q(e,t){if(!t?.length)return!1;for(let n=0;n<t.length;n++){let r=t[n];if(!r?.shape)continue;let i=r.transform,a=i&&!i.isIdentity();a&&(e.save(),e.transform(i.a,i.b,i.c,i.d,i.tx,i.ty)),Z(e,r.shape),a&&e.restore()}return!0}function ee(e,t,n,r){let i=e.fill;if(i instanceof m){i.buildGradient();let a=i.texture;if(a){let o=O.getTintedPattern(a,t),s=n?K.copyFrom(n).scale(a.source.pixelWidth,a.source.pixelHeight):K.copyFrom(i.transform);return r&&!e.textureSpace&&s.append(r),O.applyPatternTransform(o,s),o}}if(i instanceof g){let e=O.getTintedPattern(i.texture,t);return O.applyPatternTransform(e,i.transform,!1),e}let a=e.texture;if(a&&a!==l.WHITE){if(!a.source.resource)return H;let r=O.getTintedPattern(a,t),i=e.matrix;if(n){let{resolution:e}=a.source;if(i=K.copyFrom(n),a.rotate){let{uvs:t,orig:n}=a;i.prepend(q.set(t.x1-t.x0,t.y1-t.y0,t.x3-t.x0,t.y3-t.y0,t.x0,t.y0).invert()).scale(n.width*e,n.height*e)}else i.scale(a.source.pixelWidth,a.source.pixelHeight).translate(-a.frame.x*e,-a.frame.y*e)}return O.applyPatternTransform(r,i),r}return Y(t)}var $=class{constructor(){this.shader=null}contextChange(e){}execute(e,t){let n=e.renderer,r=n.canvasContext,i=r.activeContext,a=t.groupTransform,c=n.globalUniforms.globalUniformData?.worldColor??0xffffffff,f=t.groupColorAlpha,m=(c>>>24&255)/255,h=(f>>>24&255)/255,g=n.filter?.alphaMultiplier??1,v=m*h*g;if(v<=0)return;let y=c&0xffffff,b=f&0xffffff,x=u(p(b,y)),S=n._roundPixels|t._roundPixels;i.save(),r.setContextTransform(a,S===1),r.setBlendMode(t.groupBlendMode);let C=t.context.instructions;for(let e=0;e<C.length;e++){let t=C[e];if(t.action===`texture`){let e=t.data,n=e.image,s=n?O.getCanvasSource(n):null;if(!s)continue;let c=e.alpha*v;if(c<=0)continue;let l=p(e.style,x);i.globalAlpha=c;let u=s;l!==0xffffff&&(u=O.getTintedCanvas({texture:n},l));let d=n.frame,f=n.source._resolution??n.source.resolution??1,m=d.x*f,h=d.y*f,g=d.width*f,_=d.height*f;u!==s&&(m=0,h=0);let y=e.transform,b=y&&!y.isIdentity(),C=n.rotate;b||C?(U.copyFrom(a),b&&U.append(y),C&&o.matrixAppendRotationInv(U,C,e.dx,e.dy,e.dw,e.dh),r.setContextTransform(U,S===1)):r.setContextTransform(a,S===1),i.drawImage(u,m,h,u===s?g:u.width,u===s?_:u.height,C?0:e.dx,C?0:e.dy,e.dw,e.dh),(b||C)&&r.setContextTransform(a,S===1);continue}let n=t.data,c=n?.path?.shapePath;if(!c?.shapePrimitives?.length)continue;let u=n.style,f=p(u.color,x),m=u.alpha*v;if(m<=0)continue;let h=t.action===`stroke`;if(i.globalAlpha=m,h){let e=u;i.lineWidth=e.width,i.lineCap=e.cap,i.lineJoin=e.join,i.miterLimit=e.miterLimit}let g=c.shapePrimitives;if(!h&&n.hole?.shapePath?.shapePrimitives?.length){let e=g[g.length-1];e.holes=n.hole.shapePath.shapePrimitives}for(let e=0;e<g.length;e++){let t=g[e];if(!t?.shape)continue;let n=t.transform,r=n&&!n.isIdentity(),o=u.texture&&u.texture!==l.WHITE,c=u.textureSpace===`global`?n:null,p=ee(u,f,o?s(W,u,t.shape,c):null,r?G.copyFrom(a).append(n):a);if(r&&(i.save(),i.transform(n.a,n.b,n.c,n.d,n.tx,n.ty)),h){let e=u;if(e.alignment!==.5&&!e.pixelLine){let n=[],r=[],a=[];if(d[t.shape.type]?.build(t.shape,n)){let o=t.shape.closePath??!0;_(n,e,!1,o,r,a),i.fillStyle=p,J(i,r,a)}else i.strokeStyle=p,i.beginPath(),Z(i,t.shape),i.stroke()}else i.strokeStyle=p,i.beginPath(),Z(i,t.shape),i.stroke()}else i.fillStyle=p,i.beginPath(),Z(i,t.shape),Q(i,t.holes)?i.fill(`evenodd`):i.fill();r&&i.restore()}}i.restore()}destroy(){this.shader=null}};$.extension={type:[n.CanvasPipesAdaptor],name:`graphics`};var te=class{init(e,t){this._renderer=e,this._renderTargetSystem=t}initGpuRenderTarget(e){let t=e.colorTexture,{canvas:n,context:r}=this._ensureCanvas(t);return{canvas:n,context:r,width:n.width,height:n.height}}resizeGpuRenderTarget(e){let t=e.colorTexture,{canvas:n}=this._ensureCanvas(t);n.width=e.pixelWidth,n.height=e.pixelHeight}startRenderPass(e,t,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e);this._renderer.canvasContext.activeContext=i.context,this._renderer.canvasContext.activeResolution=e.resolution,t&&this.clear(e,t,n,r)}clear(e,t,n,r){let i=this._renderTargetSystem.getGpuRenderTarget(e).context,a=r||{x:0,y:0,width:e.pixelWidth,height:e.pixelHeight};if(i.setTransform(1,0,0,1,0,0),i.clearRect(a.x,a.y,a.width,a.height),n){let e=f.shared.setValue(n);e.alpha>0&&(i.globalAlpha=e.alpha,i.fillStyle=e.toHex(),i.fillRect(a.x,a.y,a.width,a.height),i.globalAlpha=1)}}finishRenderPass(){}copyToTexture(e,t,n,r,i){let a=this._renderTargetSystem.getGpuRenderTarget(e).canvas,o=t.source,{context:s}=this._ensureCanvas(o),c=i?.x??0,l=i?.y??0;return s.drawImage(a,n.x,n.y,r.width,r.height,c,l,r.width,r.height),o.update(),t}copyDepthTexture(e,t,n,r,i){c(`[CanvasRenderTargetAdaptor] copyDepthTexture is not supported in the canvas renderer`)}destroyGpuRenderTarget(e){}_ensureCanvas(e){let t=e.resource;t&&r.test(t)||(t=h.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);let n=t.getContext(`2d`);return{canvas:t,context:n}}},ne=class extends E{constructor(e){super(e),this.adaptor=new te,this.adaptor.init(e,this)}};ne.extension={type:[n.CanvasSystem],name:`renderTarget`};var re=class{constructor(e){}init(){}initSource(e){}generateCanvas(e){let t=h.get().createCanvas(),n=t.getContext(`2d`),r=O.getCanvasSource(e);if(!r)return t;let i=e.frame,a=e.source._resolution??e.source.resolution??1,o=i.x*a,s=i.y*a,c=i.width*a,l=i.height*a;return t.width=Math.ceil(c),t.height=Math.ceil(l),n.drawImage(r,o,s,c,l,0,0,c,l),t}getPixels(e){let 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(){}};re.extension={type:[n.CanvasSystem],name:`texture`};var ie=[...w,B,V,re,ne],ae=[x,S,y,C,b,I,j,T],oe=[A,$],se=[],ce=[],le=[],ue=[];t.handleByNamedList(n.CanvasSystem,se),t.handleByNamedList(n.CanvasPipes,ce),t.handleByNamedList(n.CanvasPipesAdaptor,le),t.handleByNamedList(n.CanvasLoader,ue),t.add(...ie,...ae,...oe);var de=class extends a{constructor(){let e={name:`canvas`,type:i.CANVAS,systems:se,renderPipes:ce,renderPipeAdaptors:le,loaders:ue};super(e)}};export{de as CanvasRenderer};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import{$ as e,A as t,B as n,Ct as r,D as i,Dt as a,E as o,Et as s,H as c,J as l,K as u,L as d,M as f,P as p,R as m,Tt as h,W as g,X as _,Y as v,Z as y,_t as b,bt as ee,ct as x,dt as S,ft as te,gt as C,it as w,k as ne,lt as T,n as re,ot as E,pt as D,q as O,rt as ie,st as ae,tt as oe,u as se,ut as k,vt as ce,w as A,wt as le,xt as j,yt as ue,z as de}from"./index-CE-lli1m.js";import{t as fe}from"./CanvasPool-PBu3bHFZ.js";var pe=`in vec2 vMaskCoord;
|
|
2
|
+
in vec2 vTextureCoord;
|
|
3
|
+
|
|
4
|
+
uniform sampler2D uTexture;
|
|
5
|
+
uniform sampler2D uMaskTexture;
|
|
6
|
+
|
|
7
|
+
uniform float uAlpha;
|
|
8
|
+
uniform vec4 uMaskClamp;
|
|
9
|
+
uniform float uInverse;
|
|
10
|
+
uniform float uChannel;
|
|
11
|
+
|
|
12
|
+
out vec4 finalColor;
|
|
13
|
+
|
|
14
|
+
void main(void)
|
|
15
|
+
{
|
|
16
|
+
float clip = step(3.5,
|
|
17
|
+
step(uMaskClamp.x, vMaskCoord.x) +
|
|
18
|
+
step(uMaskClamp.y, vMaskCoord.y) +
|
|
19
|
+
step(vMaskCoord.x, uMaskClamp.z) +
|
|
20
|
+
step(vMaskCoord.y, uMaskClamp.w));
|
|
21
|
+
|
|
22
|
+
// TODO look into why this is needed
|
|
23
|
+
float npmAlpha = uAlpha;
|
|
24
|
+
vec4 original = texture(uTexture, vTextureCoord);
|
|
25
|
+
vec4 masky = texture(uMaskTexture, vMaskCoord);
|
|
26
|
+
|
|
27
|
+
float a;
|
|
28
|
+
if (uChannel == 1.0) {
|
|
29
|
+
a = masky.a * npmAlpha * clip;
|
|
30
|
+
} else {
|
|
31
|
+
float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
|
|
32
|
+
a = alphaMul * masky.r * npmAlpha * clip;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (uInverse == 1.0) {
|
|
36
|
+
a = 1.0 - a;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
finalColor = original * a;
|
|
40
|
+
}
|
|
41
|
+
`,me=`in vec2 aPosition;
|
|
42
|
+
|
|
43
|
+
out vec2 vTextureCoord;
|
|
44
|
+
out vec2 vMaskCoord;
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
uniform vec4 uInputSize;
|
|
48
|
+
uniform vec4 uOutputFrame;
|
|
49
|
+
uniform vec4 uOutputTexture;
|
|
50
|
+
uniform mat3 uFilterMatrix;
|
|
51
|
+
|
|
52
|
+
vec4 filterVertexPosition( vec2 aPosition )
|
|
53
|
+
{
|
|
54
|
+
vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
|
|
55
|
+
|
|
56
|
+
position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
|
|
57
|
+
position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
|
|
58
|
+
|
|
59
|
+
return vec4(position, 0.0, 1.0);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
vec2 filterTextureCoord( vec2 aPosition )
|
|
63
|
+
{
|
|
64
|
+
return aPosition * (uOutputFrame.zw * uInputSize.zw);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
vec2 getFilterCoord( vec2 aPosition )
|
|
68
|
+
{
|
|
69
|
+
return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
void main(void)
|
|
73
|
+
{
|
|
74
|
+
gl_Position = filterVertexPosition(aPosition);
|
|
75
|
+
vTextureCoord = filterTextureCoord(aPosition);
|
|
76
|
+
vMaskCoord = getFilterCoord(aPosition);
|
|
77
|
+
}
|
|
78
|
+
`,he=`struct GlobalFilterUniforms {
|
|
79
|
+
uInputSize:vec4<f32>,
|
|
80
|
+
uInputPixel:vec4<f32>,
|
|
81
|
+
uInputClamp:vec4<f32>,
|
|
82
|
+
uOutputFrame:vec4<f32>,
|
|
83
|
+
uGlobalFrame:vec4<f32>,
|
|
84
|
+
uOutputTexture:vec4<f32>,
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
struct MaskUniforms {
|
|
88
|
+
uFilterMatrix:mat3x3<f32>,
|
|
89
|
+
uMaskClamp:vec4<f32>,
|
|
90
|
+
uAlpha:f32,
|
|
91
|
+
uInverse:f32,
|
|
92
|
+
uChannel:f32,
|
|
93
|
+
};
|
|
94
|
+
|
|
95
|
+
@group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
|
|
96
|
+
@group(0) @binding(1) var uTexture: texture_2d<f32>;
|
|
97
|
+
@group(0) @binding(2) var uSampler : sampler;
|
|
98
|
+
|
|
99
|
+
@group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
|
|
100
|
+
@group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
|
|
101
|
+
|
|
102
|
+
struct VSOutput {
|
|
103
|
+
@builtin(position) position: vec4<f32>,
|
|
104
|
+
@location(0) uv : vec2<f32>,
|
|
105
|
+
@location(1) filterUv : vec2<f32>,
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
|
|
109
|
+
{
|
|
110
|
+
var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
|
|
111
|
+
|
|
112
|
+
position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
|
|
113
|
+
position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
|
|
114
|
+
|
|
115
|
+
return vec4(position, 0.0, 1.0);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
119
|
+
{
|
|
120
|
+
return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
|
|
124
|
+
{
|
|
125
|
+
return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
|
|
129
|
+
{
|
|
130
|
+
return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
fn getSize() -> vec2<f32>
|
|
134
|
+
{
|
|
135
|
+
return gfu.uGlobalFrame.zw;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
@vertex
|
|
139
|
+
fn mainVertex(
|
|
140
|
+
@location(0) aPosition : vec2<f32>,
|
|
141
|
+
) -> VSOutput {
|
|
142
|
+
return VSOutput(
|
|
143
|
+
filterVertexPosition(aPosition),
|
|
144
|
+
filterTextureCoord(aPosition),
|
|
145
|
+
getFilterCoord(aPosition)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
@fragment
|
|
150
|
+
fn mainFragment(
|
|
151
|
+
@location(0) uv: vec2<f32>,
|
|
152
|
+
@location(1) filterUv: vec2<f32>,
|
|
153
|
+
@builtin(position) position: vec4<f32>
|
|
154
|
+
) -> @location(0) vec4<f32> {
|
|
155
|
+
|
|
156
|
+
var maskClamp = filterUniforms.uMaskClamp;
|
|
157
|
+
var uAlpha = filterUniforms.uAlpha;
|
|
158
|
+
|
|
159
|
+
var clip = step(3.5,
|
|
160
|
+
step(maskClamp.x, filterUv.x) +
|
|
161
|
+
step(maskClamp.y, filterUv.y) +
|
|
162
|
+
step(filterUv.x, maskClamp.z) +
|
|
163
|
+
step(filterUv.y, maskClamp.w));
|
|
164
|
+
|
|
165
|
+
var mask = textureSample(uMaskTexture, uSampler, filterUv);
|
|
166
|
+
var source = textureSample(uTexture, uSampler, uv);
|
|
167
|
+
|
|
168
|
+
var a: f32;
|
|
169
|
+
if (filterUniforms.uChannel == 1.0) {
|
|
170
|
+
a = mask.a * uAlpha * clip;
|
|
171
|
+
} else {
|
|
172
|
+
var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
|
|
173
|
+
a = alphaMul * mask.r * uAlpha * clip;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
if (filterUniforms.uInverse == 1.0) {
|
|
177
|
+
a = 1.0 - a;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
return source * a;
|
|
181
|
+
}
|
|
182
|
+
`,ge=class extends f{constructor(e){let{sprite:t,...i}=e,a=new te(t.texture),o=new de({uFilterMatrix:{value:new r,type:`mat3x3<f32>`},uMaskClamp:{value:a.uClampFrame,type:`vec4<f32>`},uAlpha:{value:1,type:`f32`},uInverse:{value:+!!e.inverse,type:`f32`},uChannel:{value:+(e.channel===`alpha`),type:`f32`}}),s=n.from({vertex:{source:he,entryPoint:`mainVertex`},fragment:{source:he,entryPoint:`mainFragment`}}),l=c.from({vertex:me,fragment:pe,name:`mask-filter`});super({...i,gpuProgram:s,glProgram:l,clipToViewport:!1,resources:{filterUniforms:o,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=a}setSprite(e){this.sprite=e;let t=this._getSafeTexture();this._textureMatrix.texture=t,this.resources.uMaskTexture=t.source}set inverse(e){this.resources.filterUniforms.uniforms.uInverse=+!!e}get inverse(){return this.resources.filterUniforms.uniforms.uInverse===1}set channel(e){this.resources.filterUniforms.uniforms.uChannel=+(e===`alpha`)}get channel(){return this.resources.filterUniforms.uniforms.uChannel===1?`alpha`:`red`}apply(e,t,n,r){let i=this._getSafeTexture();this._textureMatrix.texture=i,e.calculateSpriteMatrix(this.resources.filterUniforms.uniforms.uFilterMatrix,this.sprite).prepend(this._textureMatrix.mapCoord),this.resources.uMaskTexture=i.source,e.applyFilter(this,t,n,r)}_getSafeTexture(){let e=this.sprite.texture;return e.destroyed||!e.source||e.source.destroyed?(x(`[MaskFilter] The mask texture was destroyed while the mask is still in use. Remove the mask before destroying its texture.`),S.EMPTY):e}destroy(e=!1){this._textureMatrix.destroy(),super.destroy(e)}},_e=class{constructor(){this.batcherName=`default`,this.topology=`triangle-list`,this.attributeSize=4,this.indexSize=6,this.packAsQuad=!0,this.roundPixels=0,this._attributeStart=0,this._batcher=null,this._batch=null}get blendMode(){return this.renderable.groupBlendMode}get color(){return this.renderable.groupColorAlpha}reset(){this.renderable=null,this.texture=null,this._batcher=null,this._batch=null,this.bounds=null}destroy(){this.reset()}},M=class e{constructor(e,t){this.state=p.for2d(),this._batchersByInstructionSet=Object.create(null),this._activeBatches=Object.create(null),this.renderer=e,this._adaptor=t,this._adaptor.init?.(this)}static getBatcher(e,t){return new this._availableBatchers[e]({maxTextures:t})}buildStart(e){let t=this._batchersByInstructionSet[e.uid];t||(t=this._batchersByInstructionSet[e.uid]=Object.create(null),t.default||(t.default=new se({maxTextures:this.renderer.limits.maxBatchableTextures}))),this._activeBatches=t,this._activeBatch=this._activeBatches.default;for(let e in this._activeBatches)this._activeBatches[e].begin()}addToBatch(t,n){if(this._activeBatch.name!==t.batcherName){this._activeBatch.break(n);let r=this._activeBatches[t.batcherName];r||(r=this._activeBatches[t.batcherName]=e.getBatcher(t.batcherName,this.renderer.limits.maxBatchableTextures),r.begin()),this._activeBatch=r}this._activeBatch.add(t)}break(e){this._activeBatch.break(e)}buildEnd(e){this._activeBatch.break(e);let t=this._activeBatches;for(let e in t){let n=t[e],r=n.geometry;r.indexBuffer.setDataWithSize(n.indexBuffer,n.indexSize,!0),r.buffers[0].setDataWithSize(n.attributeBuffer.float32View,n.attributeSize,!1)}}upload(e){let t=this._batchersByInstructionSet[e.uid];for(let e in t){let n=t[e],r=n.geometry;n.dirty&&(n.dirty=!1,r.buffers[0].update(n.attributeSize*4))}}execute(e){if(e.action===`startBatch`){let t=e.batcher,n=t.geometry,r=t.shader;this._adaptor.start(this,n,r)}this._adaptor.execute(this,e)}destroyInstructionSet(e){let t=this._batchersByInstructionSet[e.uid];if(t){for(let e in t)t[e].destroy();delete this._batchersByInstructionSet[e.uid],this._activeBatches===t&&(this._activeBatches=Object.create(null),this._activeBatch=null)}}destroy(){this.state=null,this.renderer=null,this._adaptor=null;for(let e in this._activeBatches)this._activeBatches[e].destroy();this._activeBatches=null}};M.extension={type:[s.WebGLPipes,s.WebGPUPipes,s.CanvasPipes],name:`batch`},M._availableBatchers=Object.create(null);var N=M;a.handleByMap(s.Batcher,N._availableBatchers),a.add(se);var ve=new k,ye=class extends w{constructor(){super(),this._placeholderSprite=new l(S.EMPTY),this.filters=[new ge({sprite:this._placeholderSprite,inverse:!1,resolution:`inherit`,antialias:`inherit`})]}get sprite(){return this.filters[0].sprite}set sprite(e){this.filters[0].setSprite(e)}get inverse(){return this.filters[0].inverse}set inverse(e){this.filters[0].inverse=e}get channel(){return this.filters[0].channel}set channel(e){this.filters[0].channel=e}reset(){this._placeholderSprite.texture=S.EMPTY,this.sprite=this._placeholderSprite}},P=class{constructor(e){this._activeMaskStage=[],this._usedEffects=[],this._renderer=e,e.runners.postrender.add(this)}push(e,t,n){let r=this._renderer;if(r.renderPipes.batch.break(n),n.add({renderPipeId:`alphaMask`,action:`pushMaskBegin`,mask:e,inverse:t._maskOptions.inverse,canBundle:!1,maskedContainer:t}),e.inverse=t._maskOptions.inverse,e.channel=t._maskOptions.channel??`red`,e.renderMaskToTexture){let t=e.mask;t.includeInBuild=!0,t.collectRenderables(n,r,null),t.includeInBuild=!1}r.renderPipes.batch.break(n),n.add({renderPipeId:`alphaMask`,action:`pushMaskEnd`,mask:e,maskedContainer:t,inverse:t._maskOptions.inverse,canBundle:!1})}pop(e,t,n){this._renderer.renderPipes.batch.break(n),n.add({renderPipeId:`alphaMask`,action:`popMaskEnd`,mask:e,inverse:t._maskOptions.inverse,canBundle:!1})}execute(e){let t=this._renderer,n=e.mask.renderMaskToTexture;if(e.action===`pushMaskBegin`){let r=E.get(ye);if(r.inverse=e.inverse,r.channel=e.mask.channel,n){e.mask.mask.measurable=!0;let n=ie(e.mask.mask,!0,ve);e.mask.mask.measurable=!1,n.ceil();let i=t.renderTarget.renderTarget.colorTexture.source,a=y.getOptimalTexture({width:n.width,height:n.height,resolution:i._resolution,antialias:i.antialias});t.renderTarget.push({target:a,clear:!0}),t.globalUniforms.push({offset:n,worldColor:0xffffffff});let o=r.sprite;o.texture=a,o.worldTransform.tx=n.minX,o.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer,filterTexture:a})}else r.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:r,maskedContainer:e.maskedContainer})}else if(e.action===`pushMaskEnd`){let e=this._activeMaskStage[this._activeMaskStage.length-1];n&&(t.type===d.WEBGL&&t.renderTarget.finishRenderPass(),t.renderTarget.pop(),t.globalUniforms.pop()),t.filter.push({renderPipeId:`filter`,action:`pushFilter`,container:e.maskedContainer,filterEffect:e.filterEffect,canBundle:!1})}else if(e.action===`popMaskEnd`){t.filter.pop();let e=this._activeMaskStage.pop();n&&y.returnTexture(e.filterTexture),this._usedEffects.push(e.filterEffect)}}postrender(){let e=this._usedEffects;for(let t=0;t<e.length;t++)E.return(e[t]);e.length=0}destroy(){this.postrender(),this._renderer.runners.postrender.remove(this),this._renderer=null,this._activeMaskStage=null,this._usedEffects=null}};P.extension={type:[s.WebGLPipes,s.WebGPUPipes,s.CanvasPipes],name:`alphaMask`};var be=class{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,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;r[this._colorStackIndex]=r[this._colorStackIndex-1]&e.mask;let i=this._colorStack[this._colorStackIndex];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1})),this._colorStackIndex++}pop(e,t,n){this._renderer.renderPipes.batch.break(n);let r=this._colorStack;this._colorStackIndex--;let i=r[this._colorStackIndex-1];i!==this._currentColor&&(this._currentColor=i,n.add({renderPipeId:`colorMask`,colorMask:i,canBundle:!1}))}execute(e){this._renderer.colorMask.setMask(e.colorMask)}destroy(){this._renderer=null,this._colorStack=null}};be.extension={type:[s.WebGLPipes,s.WebGPUPipes],name:`colorMask`};var xe=class{constructor(e){this._maskHash=new WeakMap,this._renderer=e}push(e,t,n){let r=e,i=this._renderer;i.renderPipes.batch.break(n),i.renderPipes.blendMode.setBlendMode(r.mask,`none`,n),n.add({renderPipeId:`stencilMask`,action:`pushMaskBegin`,mask:e,inverse:t._maskOptions.inverse,canBundle:!1});let a=r.mask;a.includeInBuild=!0,this._maskHash.has(r)||this._maskHash.set(r,{instructionsStart:0,instructionsLength:0});let o=this._maskHash.get(r);o.instructionsStart=n.instructionSize,a.collectRenderables(n,i,null),a.includeInBuild=!1,i.renderPipes.batch.break(n),n.add({renderPipeId:`stencilMask`,action:`pushMaskEnd`,mask:e,inverse:t._maskOptions.inverse,canBundle:!1}),o.instructionsLength=n.instructionSize-o.instructionsStart-1}pop(e,t,n){let r=e,i=this._renderer;i.renderPipes.batch.break(n),i.renderPipes.blendMode.setBlendMode(r.mask,`none`,n),n.add({renderPipeId:`stencilMask`,action:`popMaskBegin`,inverse:t._maskOptions.inverse,canBundle:!1});let a=this._maskHash.get(e);for(let e=0;e<a.instructionsLength;e++)n.instructions[n.instructionSize++]=n.instructions[a.instructionsStart++];n.add({renderPipeId:`stencilMask`,action:`popMaskEnd`,canBundle:!1})}execute(e){let n=this._renderer,r=n.renderTarget.getGpuRenderTarget(n.renderTarget.renderTarget),i=r.maskStackIndex;e.action===`pushMaskBegin`?(n.renderTarget.ensureDepthStencil(),n.stencil.setStencilMode(A.RENDERING_MASK_ADD,i),i++,n.colorMask.setMask(0)):e.action===`pushMaskEnd`?(e.inverse?n.stencil.setStencilMode(A.INVERSE_MASK_ACTIVE,i):n.stencil.setStencilMode(A.MASK_ACTIVE,i),n.colorMask.setMask(15)):e.action===`popMaskBegin`?(n.colorMask.setMask(0),i===0?(n.renderTarget.clear(null,t.STENCIL),n.stencil.setStencilMode(A.DISABLED,i)):n.stencil.setStencilMode(A.RENDERING_MASK_REMOVE,i),i--):e.action===`popMaskEnd`&&(e.inverse?n.stencil.setStencilMode(A.INVERSE_MASK_ACTIVE,i):n.stencil.setStencilMode(A.MASK_ACTIVE,i),n.colorMask.setMask(15)),r.maskStackIndex=i}destroy(){this._renderer=null,this._maskHash=null}};xe.extension={type:[s.WebGLPipes,s.WebGPUPipes],name:`stencilMask`};var F=class{constructor(e){this._renderer=e}updateRenderable(){}destroyRenderable(){}validateRenderable(){return!1}addRenderable(e,t){this._renderer.renderPipes.batch.break(t),t.add(e)}execute(e){e.isRenderable&&e.render(this._renderer)}destroy(){this._renderer=null}};F.extension={type:[s.WebGLPipes,s.WebGPUPipes,s.CanvasPipes],name:`customRender`};function I(e,t){let n=e.instructionSet,r=n.instructions;for(let e=0;e<n.instructionSize;e++){let n=r[e];t[n.renderPipeId].execute(n)}}var L=class{constructor(e){this._renderer=e}addRenderGroup(e,t){e.isCachedAsTexture?this._addRenderableCacheAsTexture(e,t):this._addRenderableDirect(e,t)}execute(e){e.isRenderable&&(e.isCachedAsTexture?this._executeCacheAsTexture(e):this._executeDirect(e))}destroy(){this._renderer=null}_addRenderableDirect(e,t){this._renderer.renderPipes.batch.break(t),e._batchableRenderGroup&&=(E.return(e._batchableRenderGroup),null),t.add(e)}_addRenderableCacheAsTexture(e,t){let n=e._batchableRenderGroup??=E.get(_e);n.renderable=e.root,n.transform=e.root.relativeGroupTransform,n.texture=e.texture,n.bounds=e._textureBounds,t.add(e),this._renderer.renderPipes.blendMode.pushBlendMode(e,e.root.groupBlendMode,t),this._renderer.renderPipes.batch.addToBatch(n,t),this._renderer.renderPipes.blendMode.popBlendMode(t)}_executeCacheAsTexture(e){if(e.textureNeedsUpdate){e.textureNeedsUpdate=!1;let t=new r().translate(-e._textureBounds.x,-e._textureBounds.y);this._renderer.renderTarget.push({target:e.texture,clear:!0,frame:e.texture.frame}),this._renderer.globalUniforms.push({worldTransformMatrix:t,worldColor:0xffffffff,offset:{x:0,y:0}}),I(e,this._renderer.renderPipes),this._renderer.renderTarget.finishRenderPass(),this._renderer.renderTarget.pop(),this._renderer.globalUniforms.pop()}let t=e._batchableRenderGroup,n=t._batcher;n.updateElement(t),n.geometry.buffers[0].update(t.attributeSize*n.vertexSize*4,t._attributeStart*4)}_executeDirect(e){this._renderer.globalUniforms.push({worldTransformMatrix:e.inverseParentTextureTransform,worldColor:e.worldColorAlpha}),I(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}};L.extension={type:[s.WebGLPipes,s.WebGPUPipes,s.CanvasPipes],name:`renderGroup`};var R=class{constructor(e){this._renderer=e}addRenderable(e,t){let n=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,n),this._renderer.renderPipes.batch.addToBatch(n,t)}updateRenderable(e){let t=this._getGpuSprite(e);e.didViewUpdate&&this._updateBatchableSprite(e,t),t._batcher.updateElement(t)}validateRenderable(e){let t=this._getGpuSprite(e);return!t._batcher.checkAndUpdateTexture(t,e._texture)}_updateBatchableSprite(e,t){t.bounds=e.visualBounds,t.texture=e._texture}_getGpuSprite(e){return e._gpuData[this._renderer.uid]||this._initGPUSprite(e)}_initGPUSprite(e){let t=new _e;return t.renderable=e,t.transform=e.groupTransform,t.texture=e._texture,t.bounds=e.visualBounds,t.roundPixels=this._renderer._roundPixels|e._roundPixels,e._gpuData[this._renderer.uid]=t,t}destroy(){this._renderer=null}};R.extension={type:[s.WebGLPipes,s.WebGPUPipes,s.CanvasPipes],name:`sprite`};var z={};a.handle(s.BlendMode,e=>{if(!e.name)throw Error(`BlendMode extension must have a name property`);z[e.name]=e.ref},e=>{delete z[e.name]});var B=class{constructor(e){this._blendModeStack=[],this._isAdvanced=!1,this._filterHash=Object.create(null),this._renderer=e,this._renderer.runners.prerender.add(this)}prerender(){this._activeBlendMode=`normal`,this._isAdvanced=!1}pushBlendMode(e,t,n){this._blendModeStack.push(t),this.setBlendMode(e,t,n)}popBlendMode(e){this._blendModeStack.pop();let t=this._blendModeStack[this._activeBlendMode.length-1]??`normal`;this.setBlendMode(null,t,e)}setBlendMode(e,t,n){let r=e instanceof _;this._activeBlendMode===t?this._isAdvanced&&e&&!r&&this._renderableList?.push(e):(this._isAdvanced&&this._endAdvancedBlendMode(n),this._activeBlendMode=t,e&&(this._isAdvanced=!!z[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,n)))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);let n=this._activeBlendMode;if(!z[n]){x(`Unable to assign BlendMode: '${n}'. You may want to include: import 'pixi.js/advanced-blend-modes'`);return}let r=this._ensureFilterEffect(n),i=e instanceof _,a={renderPipeId:`filter`,action:`pushFilter`,filterEffect:r,renderables:i?null:[e],container:i?e.root:null,canBundle:!1};this._renderableList=a.renderables,t.add(a)}_ensureFilterEffect(e){let t=this._filterHash[e];return t||(t=this._filterHash[e]=new w,t.filters=[new z[e]]),t}_endAdvancedBlendMode(e){this._isAdvanced=!1,this._renderableList=null,this._renderer.renderPipes.batch.break(e),e.add({renderPipeId:`filter`,action:`popFilter`,canBundle:!1})}buildStart(){this._isAdvanced=!1}buildEnd(e){this._isAdvanced&&this._endAdvancedBlendMode(e)}destroy(){this._renderer=null,this._renderableList=null;for(let e in this._filterHash)this._filterHash[e].destroy();this._filterHash=null}};B.extension={type:[s.WebGLPipes,s.WebGPUPipes,s.CanvasPipes],name:`blendMode`};function V(e,t){t||=0;for(let n=t;n<e.length&&e[n];n++)e[n]=null}var Se=new v,Ce=7;function we(e,t=!1){Te(e);let n=e.childrenToUpdate,r=e.updateTick++;for(let t in n){let i=Number(t),a=n[t],o=a.list,s=a.index;for(let t=0;t<s;t++){let n=o[t];n.parentRenderGroup===e&&n.relativeRenderGroupDepth===i&&Ee(n,r,0)}V(o,s),a.index=0}if(t)for(let n=0;n<e.renderGroupChildren.length;n++)we(e.renderGroupChildren[n],t)}function Te(e){let t=e.root,n;if(e.renderGroupParent){let r=e.renderGroupParent;e.worldTransform.appendFrom(t.relativeGroupTransform,r.worldTransform),e.worldColor=oe(t.groupColor,r.worldColor),n=t.groupAlpha*r.worldAlpha}else e.worldTransform.copyFrom(t.localTransform),e.worldColor=t.localColor,n=t.localAlpha;n=n<0?0:n>1?1:n,e.worldAlpha=n,e.worldColorAlpha=e.worldColor+(n*255<<24)}function Ee(e,t,n){if(t===e.updateTick)return;e.updateTick=t,e.didChange=!1;let r=e.localTransform;e.updateLocalTransform();let i=e.parent;if(i&&!i.renderGroup?(n|=e._updateFlags,e.relativeGroupTransform.appendFrom(r,i.relativeGroupTransform),n&Ce&&De(e,i,n)):(n=e._updateFlags,e.relativeGroupTransform.copyFrom(r),n&Ce&&De(e,Se,n)),!e.renderGroup){let r=e.children,i=r.length;for(let e=0;e<i;e++)Ee(r[e],t,n);let a=e.parentRenderGroup,o=e;o.renderPipeId&&!a.structureDidChange&&a.updateRenderable(o)}}function De(e,t,n){if(n&1){e.groupColor=oe(e.localColor,t.groupColor);let n=e.localAlpha*t.groupAlpha;n=n<0?0:n>1?1:n,e.groupAlpha=n,e.groupColorAlpha=e.groupColor+(n*255<<24)}n&2&&(e.groupBlendMode=e.localBlendMode===`inherit`?t.groupBlendMode:e.localBlendMode),n&4&&(e.globalDisplayStatus=e.localDisplayStatus&t.globalDisplayStatus),e._updateFlags=0}function Oe(e,t){let{list:n}=e.childrenRenderablesToUpdate,r=!1;for(let i=0;i<e.childrenRenderablesToUpdate.index;i++){let e=n[i];if(r=t[e.renderPipeId].validateRenderable(e),r)break}return e.structureDidChange=r,r}var ke=new r,Ae=class{constructor(e){this._renderer=e}render({container:e,transform:t}){let n=e.parent,r=e.renderGroup.renderGroupParent;e.parent=null,e.renderGroup.renderGroupParent=null;let i=this._renderer,a=ke;t&&(a.copyFrom(e.renderGroup.localTransform),e.renderGroup.localTransform.copyFrom(t));let o=i.renderPipes;this._updateCachedRenderGroups(e.renderGroup,null),this._updateRenderGroups(e.renderGroup),i.globalUniforms.start({worldTransformMatrix:t?e.renderGroup.localTransform:e.renderGroup.worldTransform,worldColor:e.renderGroup.worldColorAlpha}),I(e.renderGroup,o),o.uniformBatch&&o.uniformBatch.renderEnd(),t&&e.renderGroup.localTransform.copyFrom(a),e.parent=n,e.renderGroup.renderGroupParent=r}destroy(){this._renderer=null}_updateCachedRenderGroups(e,t){if(e._parentCacheAsTextureRenderGroup=t,e.isCachedAsTexture){if(!e.textureNeedsUpdate)return;t=e}for(let n=e.renderGroupChildren.length-1;n>=0;n--)this._updateCachedRenderGroups(e.renderGroupChildren[n],t);if(e.invalidateMatrices(),e.isCachedAsTexture){if(e.textureNeedsUpdate){let t=e.root.getLocalBounds(),n=this._renderer,r=e.textureOptions.resolution||n.view.resolution,i=e.textureOptions.antialias??n.view.antialias,a=e.textureOptions.scaleMode??`linear`,o=e.texture;t.ceil(),e.texture&&y.returnTexture(e.texture),e.texture=y.getOptimalTexture({width:t.width,height:t.height,resolution:r,antialias:i,scaleMode:a}),e._textureBounds||=new k,e._textureBounds.copyFrom(t),o!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&=(y.returnTexture(e.texture),null)}_updateRenderGroups(e){let t=this._renderer,n=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=n,e.structureDidChange?V(e.childrenRenderablesToUpdate.list,0):Oe(e,n),we(e),e.structureDidChange?(e.structureDidChange=!1,this._buildInstructions(e,t)):this._updateRenderables(e),e.childrenRenderablesToUpdate.index=0,t.renderPipes.batch.upload(e.instructionSet),!e.isCachedAsTexture||e.textureNeedsUpdate)for(let t=0;t<e.renderGroupChildren.length;t++)this._updateRenderGroups(e.renderGroupChildren[t])}_updateRenderables(e){let{list:t,index:n}=e.childrenRenderablesToUpdate;for(let r=0;r<n;r++){let n=t[r];n.didViewUpdate&&e.updateRenderable(n)}V(t,n)}_buildInstructions(e,t){let n=e.root,r=e.instructionSet;r.reset();let i=t.renderPipes?t:t.batch.renderer,a=i.renderPipes;a.batch.buildStart(r),a.blendMode.buildStart(),a.colorMask.buildStart(),n.sortableChildren&&n.sortChildren(),n.collectRenderablesWithEffects(r,i,null),a.batch.buildEnd(r),a.blendMode.buildEnd(r)}};Ae.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`renderGroup`};var H=class e{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new T(0),this.color=this._backgroundColor,this.alpha=1}init(t){t={...e.defaultOptions,...t},this.clearBeforeRender=t.clearBeforeRender,this.color=t.background||t.backgroundColor||this._backgroundColor,this.alpha=t.backgroundAlpha,this._backgroundColor.setAlpha(t.backgroundAlpha)}get color(){return this._backgroundColor}set color(e){T.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&x(`Cannot set a transparent background on an opaque canvas. To enable transparency, set backgroundAlpha < 1 when initializing your Application.`),this._backgroundColor.setValue(e)}get alpha(){return this._backgroundColor.alpha}set alpha(e){this._backgroundColor.setAlpha(e)}get colorRgba(){return this._backgroundColor.toArray()}destroy(){}};H.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`background`,priority:0},H.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};var je=H;function U(e,t=!1){let n=e.source.format;if(n.endsWith(`float`)||C(n)||n.startsWith(`depth`)||n===`stencil8`)throw t&&e.destroy(!0),Error(`[ExtractSystem] can't read ${n} textures: extract reads 8-bit color only. Extract a Mesh whose shader reads the texture and outputs color instead.`)}var W={png:`image/png`,jpg:`image/jpeg`,webp:`image/webp`},G=class e{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof v||e instanceof S?{target:e,...t}:{...t,...e}}async image(e){let t=O.get().createImage();return t.src=await this.base64(e),t}async base64(t){t=this._normalizeOptions(t,e.defaultImageOptions);let{format:n,quality:r}=t,i=this.canvas(t);if(i.toBlob!==void 0)return new Promise((e,t)=>{i.toBlob(n=>{if(!n){t(Error(`ICanvas.toBlob failed!`));return}let r=new FileReader;r.onload=()=>e(r.result),r.onerror=t,r.readAsDataURL(n)},W[n],r)});if(i.toDataURL!==void 0)return i.toDataURL(W[n],r);if(i.convertToBlob!==void 0){let e=await i.convertToBlob({type:W[n],quality:r});return new Promise((t,n)=>{let r=new FileReader;r.onload=()=>t(r.result),r.onerror=n,r.readAsDataURL(e)})}throw Error(`Extract.base64() requires ICanvas.toDataURL, ICanvas.toBlob, or ICanvas.convertToBlob to be implemented`)}canvas(e){e=this._normalizeOptions(e);let t=e.target,n=this._renderer;if(t instanceof S)return U(t),n.texture.generateCanvas(t);let r=n.textureGenerator.generateTexture(e);U(r,!0);let i=n.texture.generateCanvas(r);return r.destroy(!0),i}pixels(e){e=this._normalizeOptions(e);let t=e.target,n=this._renderer,r=t instanceof S?t:n.textureGenerator.generateTexture(e);U(r,!(t instanceof S));let i=n.texture.getPixels(r);return t instanceof v&&r.destroy(!0),i}texture(e){return e=this._normalizeOptions(e),e.target instanceof S?e.target:this._renderer.textureGenerator.generateTexture(e)}download(e){e=this._normalizeOptions(e);let t=this.canvas(e),n=document.createElement(`a`);n.download=e.filename??`image.png`,n.href=t.toDataURL(`image/png`),document.body.appendChild(n),n.click(),document.body.removeChild(n)}log(e){let t=e.width??200;e=this._normalizeOptions(e);let n=this.canvas(e),r=n.toDataURL();console.log(`[Pixi Texture] ${n.width}px ${n.height}px`);let i=[`font-size: 1px;`,`padding: ${t}px 300px;`,`background: url(${r}) no-repeat;`,`background-size: contain;`].join(` `);console.log(`%c `,i)}destroy(){this._renderer=null}};G.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`extract`},G.defaultImageOptions={format:`png`,quality:1};var Me=G,Ne=class e extends S{static create(t){let{dynamic:n,textureOptions:r,...i}=t;return new e({...r,source:new D(i),dynamic:n??!1})}resize(e,t,n){return this.source.resize(e,t,n),this}},Pe=new j,Fe=new k,Ie=[0,0,0,0],Le=class{constructor(e){this._renderer=e}generateTexture(t){t instanceof v&&(t={target:t,frame:void 0,textureSourceOptions:{},resolution:void 0});let n=t.resolution||this._renderer.resolution,i=t.antialias||this._renderer.view.antialias,a=t.target,o=t.clearColor;o=o?Array.isArray(o)&&o.length===4?o:T.shared.setValue(o).toArray():Ie;let s=t.frame?.copyTo(Pe)||e(a,Fe).rectangle,c=t.defaultAnchor&&{defaultAnchor:t.defaultAnchor};s.width=Math.max(s.width,1/n)|0,s.height=Math.max(s.height,1/n)|0;let l=Ne.create({...t.textureSourceOptions,width:s.width,height:s.height,resolution:n,antialias:i,textureOptions:c}),u=r.shared.translate(-s.x,-s.y);return this._renderer.render({container:a,transform:u,target:l,clearColor:o}),l.source.updateMipmaps(),l}destroy(){this._renderer=null}};Le.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`textureGenerator`};function Re(e){let t=!1;for(let n in e)if(e[n]==null){t=!0;break}if(!t)return e;let n=Object.create(null);for(let t in e){let r=e[t];r&&(n[t]=r)}return n}function ze(e){let t=0;for(let n=0;n<e.length;n++)e[n]==null?t++:e[n-t]=e[n];return e.length-=t,e}var K=class e{constructor(e){this._managedResources=[],this._managedResourceHashes=[],this._managedCollections=[],this._ready=!1,this._running=!1,this._renderer=e}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.gcMaxUnusedTime,this._frequency=t.gcFrequency,this.enabled=t.gcActive,this.now=performance.now()}get enabled(){return!!this._handler}set enabled(e){this.enabled!==e&&(e?(this._handler=this._renderer.scheduler.repeat(()=>{this._ready=!0},this._frequency,!1),this._collectionsHandler=this._renderer.scheduler.repeat(()=>{for(let e of this._managedCollections){let{context:t,collection:n,type:r}=e;t[n]=r===`hash`?Re(t[n]):ze(t[n])}},this._frequency)):(this._renderer.scheduler.cancel(this._handler),this._renderer.scheduler.cancel(this._collectionsHandler),this._handler=0,this._collectionsHandler=0))}prerender({container:e}){this.now=performance.now(),e.renderGroup.gcTick=this._renderer.tick++,this._updateInstructionGCTick(e.renderGroup,e.renderGroup.gcTick)}postrender(){this._ready&&this.enabled&&(this.run(),this._ready=!1)}_updateInstructionGCTick(e,t){e.instructionSet.gcTick=t,e.gcTick=t;for(let n of e.renderGroupChildren)this._updateInstructionGCTick(n,t)}addCollection(e,t,n){this._managedCollections.push({context:e,collection:t,type:n})}addResource(e,t){e._gcLastUsed===-1?(e._gcData={index:this._managedResources.length,type:t},e._gcLastUsed=this.now,e._onTouch?.(this.now),e.once(`unload`,this.removeResource,this),this._managedResources.push(e)):(e._gcLastUsed=this.now,e._onTouch?.(this.now))}removeResource(e){let t=e._gcData;if(!t)return;let n=t.index,r=this._managedResources.length-1;if(this._running)this._managedResources[n]=null;else{if(n!==r){let e=this._managedResources[r];this._managedResources[n]=e,e._gcData.index=n}this._managedResources.length--}e._gcData=null,e._gcLastUsed=-1}addResourceHash(e,t,n,r=0){this._managedResourceHashes.push({context:e,hash:t,type:n,priority:r}),this._managedResourceHashes.sort((e,t)=>e.priority-t.priority)}run(){if(this._running)return;let e=performance.now(),t=this._managedResourceHashes,n=this._managedResources;this._running=!0;try{for(let n of t)this.runOnHash(n,e);let r=n.length;for(let t=0;t<r;t++){let r=n[t];r&&this.runOnResource(r,e)}}finally{let e=0;for(let t=0;t<n.length;t++){let r=n[t];r&&(e!==t&&(n[e]=r,r._gcData.index=e),e++)}n.length=e,this._running=!1}}updateRenderableGCTick(e,t){let n=e.renderGroup??e.parentRenderGroup,r=n?.instructionSet?.gcTick??-1;(n?.gcTick??0)===r&&(e._gcLastUsed=t,e._onTouch?.(t))}runOnResource(e,t){e._gcData.type===`renderable`&&this.updateRenderableGCTick(e,t),t-e._gcLastUsed<this.maxUnusedTime||!e.autoGarbageCollect||(e.off(`unload`,this.removeResource,this),e.unload(),this.removeResource(e))}_createHashClone(e,t){let n=Object.create(null);for(let r in e){if(r===t)break;e[r]!==null&&(n[r]=e[r])}return n}runOnHash(e,t){let{context:n,hash:r,type:i}=e,a=n[r],o=null,s=0;for(let e in a){let n=a[e];if(n===null)s++,s===1e4&&!o&&(o=this._createHashClone(a,e));else if(n._gcLastUsed===-1)n._gcLastUsed=t,n._onTouch?.(t),o&&(o[e]=n);else if(i===`renderable`&&this.updateRenderableGCTick(n,t),!(t-n._gcLastUsed<this.maxUnusedTime)&&n.autoGarbageCollect){if(i===`renderable`){let e=n,t=e.renderGroup??e.parentRenderGroup;t&&(t.structureDidChange=!0)}n.unload(),n._gcData=null,n._gcLastUsed=-1,o||(s+1===1e4?o=this._createHashClone(a,e):(a[e]=null,s++))}else o&&(o[e]=n)}o&&(n[r]=o)}destroy(){this.enabled=!1,this._managedResources.forEach(e=>{e?.off(`unload`,this.removeResource,this)}),this._managedResources.length=0,this._managedResourceHashes.length=0,this._managedCollections.length=0,this._renderer=null}};K.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`gc`,priority:0},K.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};var Be=K,Ve=class{constructor(e){this._stackIndex=0,this._globalUniformDataStack=[],this._uniformsPool=[],this._activeUniforms=[],this._bindGroupPool=[],this._activeBindGroups=[],this._renderer=e}reset(){this._stackIndex=0;for(let e=0;e<this._activeUniforms.length;e++)this._uniformsPool.push(this._activeUniforms[e]);for(let e=0;e<this._activeBindGroups.length;e++)this._bindGroupPool.push(this._activeBindGroups[e]);this._activeUniforms.length=0,this._activeBindGroups.length=0}start(e){this.reset(),this.push(e)}bind({size:e,projectionMatrix:t,worldTransformMatrix:n,worldColor:i,offset:a}){let o=this._renderer.renderTarget.renderTarget,s=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:o,worldTransformMatrix:new r,worldColor:0xffffffff,offset:new le},c={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||o.size,worldTransformMatrix:n||s.worldTransformMatrix,worldColor:i||s.worldColor,offset:a||s.offset,bindGroup:null},l=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(l);let u=l.uniforms;u.uProjectionMatrix=c.projectionMatrix,u.uResolution=c.resolution,u.uWorldTransformMatrix.copyFrom(c.worldTransformMatrix),u.uWorldTransformMatrix.tx-=c.offset.x,u.uWorldTransformMatrix.ty-=c.offset.y,re(c.worldColor,u.uWorldColorAlpha,0),l.update();let d;this._renderer.renderPipes.uniformBatch?d=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(l,!1):(d=this._bindGroupPool.pop()||new m,this._activeBindGroups.push(d),d.setResource(l,0)),c.bindGroup=d,this._currentGlobalUniformData=c}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===d.WEBGL&&this._currentGlobalUniformData.bindGroup.resources[0].update()}get bindGroup(){return this._currentGlobalUniformData.bindGroup}get globalUniformData(){return this._currentGlobalUniformData}get uniformGroup(){return this._currentGlobalUniformData.bindGroup.resources[0]}_createUniforms(){return new de({uProjectionMatrix:{value:new r,type:`mat3x3<f32>`},uWorldTransformMatrix:{value:new r,type:`mat3x3<f32>`},uWorldColorAlpha:{value:new Float32Array(4),type:`vec4<f32>`},uResolution:{value:[0,0],type:`vec2<f32>`}},{isStatic:!0})}destroy(){this._renderer=null,this._globalUniformDataStack.length=0,this._uniformsPool.length=0,this._activeUniforms.length=0,this._bindGroupPool.length=0,this._activeBindGroups.length=0,this._currentGlobalUniformData=null}};Ve.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`globalUniforms`};var He=1,Ue=class{constructor(){this._tasks=[],this._offset=0}init(){g.system.add(this._update,this)}repeat(e,t,n=!0){let r=He++,i=0;return n&&(this._offset+=1e3,i=this._offset),this._tasks.push({func:e,duration:t,start:performance.now(),offset:i,last:performance.now(),repeat:!0,id:r}),r}cancel(e){for(let t=0;t<this._tasks.length;t++)if(this._tasks[t].id===e){this._tasks.splice(t,1);return}}_update(){let e=performance.now();for(let t=0;t<this._tasks.length;t++){let n=this._tasks[t];if(e-n.offset-n.last>=n.duration){let t=e-n.start;n.func(t),n.last=e}}}destroy(){g.system.remove(this._update,this),this._tasks.length=0}};Ue.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`scheduler`,priority:0};var q=!1;function We(e){if(!q){if(O.get().getNavigator().userAgent.toLowerCase().indexOf(`chrome`)>-1){let t=[`%c %c %c %c %c PixiJS %c v${i} (${e}) http://www.pixijs.com/
|
|
183
|
+
|
|
184
|
+
`,`background: #E72264; padding:5px 0;`,`background: #6CA2EA; padding:5px 0;`,`background: #B5D33D; padding:5px 0;`,`background: #FED23F; padding:5px 0;`,`color: #FFFFFF; background: #E72264; padding:5px 0;`,`color: #E72264; background: #FFFFFF; padding:5px 0;`];globalThis.console.log(...t)}else globalThis.console&&globalThis.console.log(`PixiJS ${i} - ${e} - http://www.pixijs.com/`);q=!0}}var J=class{constructor(e){this._renderer=e}init(e){if(e.hello){let e=this._renderer.name;this._renderer.type===d.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),We(e)}}};J.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`hello`,priority:-2},J.defaultOptions={hello:!1};var Y=class e{constructor(e){this._renderer=e}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return b(`8.15.0`,`RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead.`),this._renderer.gc.enabled}set enabled(e){b(`8.15.0`,`RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead.`),this._renderer.gc.enabled=e}addManagedHash(e,t){b(`8.15.0`,`RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead.`),this._renderer.gc.addCollection(e,t,`hash`)}addManagedArray(e,t){b(`8.15.0`,`RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead.`),this._renderer.gc.addCollection(e,t,`array`)}addRenderable(e){b(`8.15.0`,`RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead.`),this._renderer.gc.addResource(e,`renderable`)}run(){b(`8.15.0`,`RenderableGCSystem.run is deprecated, please use the GCSystem instead.`),this._renderer.gc.run()}destroy(){this._renderer=null}};Y.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`renderableGC`,priority:0},Y.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};var Ge=Y,X=class e{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){b(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`),this._checkCount=e}get maxIdle(){return this._renderer.gc.maxUnusedTime/1e3*60}set maxIdle(e){b(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`),this._renderer.gc.maxUnusedTime=e/60*1e3}get checkCountMax(){return Math.floor(this._renderer.gc._frequency/1e3)}set checkCountMax(e){b(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`)}get active(){return this._renderer.gc.enabled}set active(e){b(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`),this._renderer.gc.enabled=e}constructor(e){this._renderer=e,this._checkCount=0}init(t){t.textureGCActive!==e.defaultOptions.textureGCActive&&(this.active=t.textureGCActive),t.textureGCMaxIdle!==e.defaultOptions.textureGCMaxIdle&&(this.maxIdle=t.textureGCMaxIdle),t.textureGCCheckCountMax!==e.defaultOptions.textureGCCheckCountMax&&(this.checkCountMax=t.textureGCCheckCountMax)}run(){b(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`),this._renderer.gc.run()}destroy(){this._renderer=null}};X.extension={type:[s.WebGLSystem,s.WebGPUSystem],name:`textureGC`},X.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};var Ke=X,qe=class e extends h{constructor(e={}){super(),this.uid=ee(`renderTarget`),this.colorAttachments=[],this.dirtyId=0,this.isRoot=!1,this._size=new Float32Array(2),this._managedColorTextures=!1,this._managedDepthStencilTexture=!1,this._depth=!1,this._stencil=!1,this._colorTextures=null;let t=`colorAttachments`in e?e:this._normalizeOptions(e);if(this.isRoot=t.isRoot??!1,this.label=t.label,this.colorAttachments=t.colorAttachments,this.depthStencilAttachment=t.depthStencilAttachment,this.depthStencilAttachment){let e=this.depthStencilAttachment.texture.format;this._depth||=e.includes(`depth`),this._stencil||=e.includes(`stencil`)}if(this.colorAttachments.length===0&&!this.depthStencilAttachment)throw Error(`[RenderTarget] no color textures or depth textures were provided. Provide a depthStencilTexture or set depth/stencil to true when using colorTextures: 0.`);if(this.colorAttachments.length>0){let e=this.colorTexture;this.resize(e.width,e.height,e._resolution)}this.sizeSource&&this.sizeSource.on(`resize`,this.onSourceResize,this)}_normalizeOptions(t){let n={...e.defaultOptions,...t},r=[],i;if(typeof n.colorTextures==`number`){if(n.colorTextures>0){this._managedColorTextures=!0;for(let e=0;e<n.colorTextures;e++)r.push({texture:new D({width:n.width,height:n.height,resolution:n.resolution,antialias:n.antialias}),storeOp:`store`})}}else n.colorTextures.forEach(e=>{r.push({texture:e.source,storeOp:`store`})});let a=n.depthStencilTexture===!0;if(this._depth=!!(n.depth||a),this._stencil=!!(n.stencil||a),n.depthStencilTexture instanceof S||n.depthStencilTexture instanceof D){if(n.isRoot)throw Error(`[RenderTarget] cannot attach a depth-stencil texture to the screen — the canvas owns its own depth/stencil buffers. Render to a texture target instead.`);i={texture:n.depthStencilTexture.source}}else(a&&!n.isRoot||(n.stencil||n.depth)&&r.length===0)&&(i=this._createDepthStencilTexture(n.width,n.height,n.resolution));return{colorAttachments:r,depthStencilAttachment:i,isRoot:n.isRoot,label:n.label}}get size(){let e=this._size;return e[0]=this.pixelWidth,e[1]=this.pixelHeight,e}get width(){return this.sizeSource.width}get height(){return this.sizeSource.height}get pixelWidth(){return this.sizeSource.pixelWidth}get pixelHeight(){return this.sizeSource.pixelHeight}get resolution(){return this.sizeSource._resolution}get colorTextures(){return this._colorTextures||=this.colorAttachments.map(e=>e.texture),this._colorTextures}get depthStencilTexture(){return this.depthStencilAttachment?.texture??null}get depth(){return this._depth}get stencil(){return this._stencil}get colorTexture(){return this.colorAttachments[0]?.texture}get sizeSource(){return this.colorAttachments[0]?.texture??this.depthStencilAttachment?.texture}onSourceResize(e){this.resize(e.width,e.height,e._resolution,!0)}ensureDepthStencilTexture(){this._createDepthStencilTexture(this.sizeSource.width,this.sizeSource.height,this.sizeSource._resolution),this._depth=!0,this._stencil=!0}resize(e,t,n=this.resolution,r=!1){if(this.dirtyId++,this.colorAttachments.forEach((i,a)=>{r&&a===0||i.texture.resize(e,t,n)}),this.depthStencilAttachment){if(r&&this.colorAttachments.length===0)return;this.depthStencilAttachment.texture.resize(e,t,n)}}destroy(){(this.colorAttachments||this.depthStencilAttachment)&&(this.emit(`destroy`,this),this.sizeSource.off(`resize`,this.onSourceResize,this),this._managedColorTextures&&this.colorAttachments.forEach(e=>{e.texture.destroy()}),this.depthStencilAttachment&&(this._managedDepthStencilTexture&&this.depthStencilAttachment.texture.destroy(),delete this.depthStencilAttachment),this.colorAttachments=null,this._colorTextures=null,this.removeAllListeners())}_createDepthStencilTexture(e,t,n){if(this.depthStencilAttachment)return this.depthStencilAttachment;let r=new D({width:e,height:t,resolution:n,format:`depth24plus-stencil8`,autoGenerateMipmaps:!1,antialias:!1,mipLevelCount:1});return r.resize(e,t,n),this._managedDepthStencilTexture=!0,this.depthStencilAttachment={texture:r},this.depthStencilAttachment}};qe.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};var Z=qe,Q=new Map;ae.register(Q);function Je(e,t){if(!Q.has(e)){let n=new S({source:new u({resource:e,...t})}),r=()=>{Q.get(e)===n&&Q.delete(e)};n.once(`destroy`,r),n.source.once(`destroy`,r),Q.set(e,n)}return Q.get(e)}var $=class e{get autoDensity(){return this.texture.source.autoDensity}set autoDensity(e){this.texture.source.autoDensity=e}get resolution(){return this.texture.source._resolution}set resolution(e){this.texture.source.resize(this.texture.source.width,this.texture.source.height,e)}constructor(e){this._renderer=e}init(t){t={...e.defaultOptions,...t},t.view&&(b(ce,`ViewSystem.view has been renamed to ViewSystem.canvas`),t.canvas=t.view),this.screen=new j(0,0,t.width,t.height),this.canvas=t.canvas||O.get().createCanvas(),this.antialias=!!t.antialias;let{depth:n,...r}=t;!r.format&&this._renderer.type===d.WEBGPU&&(r.format=O.get().getNavigator().gpu.getPreferredCanvasFormat()),this.texture=Je(this.canvas,r),this.renderTarget=new Z({colorTextures:[this.texture],depth:!!n,isRoot:!0}),this.texture.source.transparent=t.backgroundAlpha<1,this.texture.source.on(`resize`,this._updateScreenSize,this),this.resolution=t.resolution,this._updateScreenSize()}resize(e,t,n){this.texture.source.resize(e,t,n),this._updateScreenSize(),this.screen.width=this.texture.frame.width,this.screen.height=this.texture.frame.height}destroy(e=!1){(typeof e==`boolean`?e:e?.removeView)&&this.canvas.parentNode&&this.canvas.parentNode.removeChild(this.canvas),this.texture.source.off(`resize`,this._updateScreenSize,this),y.removeScreen(this._renderer.uid),fe.removeScreen(this._renderer.uid),this.texture.destroy()}_updateScreenSize(){let{pixelWidth:e,pixelHeight:t}=this.texture.source,n=this._renderer.uid;y.setScreenSize(n,e,t,this.resolution),fe.setScreenSize(n,e,t)}};$.extension={type:[s.WebGLSystem,s.WebGPUSystem,s.CanvasSystem],name:`view`,priority:0},$.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};var Ye=[je,Ve,J,$,Ae,Be,Ke,Le,Me,o,Ge,Ue],Xe=[B,N,R,L,P,xe,be,F];function Ze(e,t,n,r,i,a){let o=a?1:-1;return e.identity(),e.a=1/r*2,e.d=o*(1/i*2),e.tx=-1-t*e.a,e.ty=-o-n*e.d,e}function Qe(e){if(e.colorAttachments.length===0)return!1;let t=e.colorTexture.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var $e=class{constructor(e){this.rootViewPort=new j,this.viewport=new j,this.onRenderTargetChange=new ne(`onRenderTargetChange`),this.projectionMatrix=new r,this.defaultClearColor=[0,0,0,0],this._renderSurfaceToRenderTargetHash=new Map,this._gpuRenderTargetHash=Object.create(null),this._renderTargetStack=[],this._bindState={target:null,frame:void 0,mipLevel:0,layer:0,flipY:!1},this._bindFrame=new j,this._renderer=e,e.gc.addCollection(this,`_gpuRenderTargetHash`,`hash`)}get renderSurface(){return this._bindState.target}get mipLevel(){return this._bindState.mipLevel}get layer(){return this._bindState.layer}finishRenderPass(){this.adaptor.finishRenderPass(this.renderTarget)}renderStart(e){this._renderTargetStack.length=0,this.push(e),this.rootViewPort.copyFrom(this.viewport),this.rootRenderTarget=this.renderTarget,this.renderingToScreen=Qe(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(e,t=!0,n,r,i=0,a=0,o){let s;`target`in e?s=e:(b(`8.20.0`,`RenderTargetSystem.bind: positional arguments are deprecated, please use an options object instead: bind({ target, clear, clearColor, frame, mipLevel, layer, flipY })`),s={target:e,clear:t,clearColor:n,frame:r,mipLevel:i,layer:a,flipY:o});let c=s.target;t=s.clear??!0,n=s.clearColor,i=(s.mipLevel??0)|0,a=(s.layer??0)|0,o=s.flipY,r=s.frame;let l=this.getRenderTarget(c),u=this.renderTarget!==l||!!l.flipY!=!!o;this.renderTarget=l;let d=this.getGpuRenderTarget(l);(l.pixelWidth!==d.width||l.pixelHeight!==d.height)&&(this.adaptor.resizeGpuRenderTarget(l),d.width=l.pixelWidth,d.height=l.pixelHeight);let f=l.colorAttachments[0]?.texture||l.depthStencilAttachment?.texture,p=this.viewport,m=f.dimension===`3d`?Math.max(f.depth>>i,1):f.depthOrArrayLayers;if(a<0||a>=m)throw Error(`[RenderTargetSystem] layer ${a} is out of bounds (layer count=${m}).`);let h=this._bindState;h.target=c,h.frame=r?this._bindFrame.copyFrom(r):void 0,h.mipLevel=i,h.layer=a,h.flipY=o;let g=Math.max(f.pixelWidth>>i,1),_=Math.max(f.pixelHeight>>i,1);if(!r&&c instanceof S&&(r=c.frame),r){let e=f._resolution,t=1<<Math.max(i,0),n=r.x*e+.5|0,a=r.y*e+.5|0,o=r.width*e+.5|0,s=r.height*e+.5|0,c=Math.floor(n/t),l=Math.floor(a/t),u=Math.ceil(o/t),d=Math.ceil(s/t);c<0&&(u+=c,c=0),l<0&&(d+=l,l=0),c=Math.min(c,g-1),l=Math.min(l,_-1),u=Math.min(u,g-c),d=Math.min(d,_-l),u=Math.max(u,1),d=Math.max(d,1),p.x=c,p.y=l,p.width=u,p.height=d}else p.x=0,p.y=0,p.width=g,p.height=_;return l.flipY=o,Ze(this.projectionMatrix,0,0,p.width/f.resolution,p.height/f.resolution,!l.isRoot!=!!l.flipY),this.adaptor.startRenderPass(l,t,n,p,i,a),u&&this.onRenderTargetChange.emit(l),l}getBindState(e){if(!this.renderTarget)throw Error(`[RenderTargetSystem] getBindState is only valid while a render surface is bound`);let n=this._bindState;return e??={},e.target=n.target,e.clear=t.NONE,e.clearColor=void 0,n.frame?e.frame?e.frame.copyFrom(n.frame):e.frame=n.frame.clone():e.frame=void 0,e.mipLevel=n.mipLevel,e.layer=n.layer,e.flipY=!!n.flipY,e}isFrontFaceInverted(e,t){if(!e){if(e=this.renderTarget,!e)return!1;t=e.flipY}return!!t!=(this._renderer.type===d.WEBGL&&!e.isRoot)}get frontFaceInverted(){return b(ue,`RenderTargetSystem.frontFaceInverted is deprecated, use isFrontFaceInverted() instead`),this.isFrontFaceInverted()}clear(e,n=t.ALL,r,i=this.mipLevel,a=this.layer){n&&(e&&=this.getRenderTarget(e),this.adaptor.clear(e||this.renderTarget,n,r,this.viewport,i,a))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,n=t.ALL,r,i,a=0,o=0,s){let c;`target`in e?c=e:(b(`8.20.0`,`RenderTargetSystem.push: positional arguments are deprecated, please use an options object instead: push({ target, clear, clearColor, frame, mipLevel, layer, flipY })`),c={target:e,clear:n,clearColor:r,frame:i,mipLevel:a,layer:o,flipY:s});let l=this.bind(c);return this._renderTargetStack.push({target:c.target,clear:!1,clearColor:void 0,frame:c.frame?c.frame.clone():void 0,mipLevel:c.mipLevel,layer:c.layer,flipY:c.flipY}),l}pop(){this._renderTargetStack.pop();let e=this._renderTargetStack[this._renderTargetStack.length-1];if(!e)throw Error(`[RenderTargetSystem] pop: no previous binding to restore (unbalanced pop)`);return this.bind(e)}getRenderTarget(e){return e.isTexture&&(e=e.source),this._renderSurfaceToRenderTargetHash.get(e)??this._initRenderTarget(e)}copyToTexture(e,t,n,r,i){let a=this.getRenderTarget(e);n.x<0&&(r.width+=n.x,i.x-=n.x,n.x=0),n.y<0&&(r.height+=n.y,i.y-=n.y,n.y=0);let{pixelWidth:o,pixelHeight:s}=a;return r.width=Math.min(r.width,o-n.x),r.height=Math.min(r.height,s-n.y),this.adaptor.copyToTexture(a,t,n,r,i)}copyDepthTexture(e,t,n,r,i={x:0,y:0}){let a=this.getRenderTarget(e);if(!a.depthStencilAttachment){x(`[RenderTargetSystem] copyDepthTexture: the source render target has no depth attachment to copy from`);return}let o=t.source;if(!o.format.includes(`depth`)&&!o.format.includes(`stencil`)){x(`[RenderTargetSystem] copyDepthTexture: the destination texture must have a depth/stencil format (got '${o.format}')`);return}let s=n.x,c=n.y,l=i.x,u=i.y,d=r.width,f=r.height;s<0&&(d+=s,l-=s,s=0),c<0&&(f+=c,u-=c,c=0),d=Math.min(d,a.pixelWidth-s),f=Math.min(f,a.pixelHeight-c),d=Math.min(d,o.pixelWidth-l),f=Math.min(f,o.pixelHeight-u),d<=0||f<=0||this.adaptor.copyDepthTexture(a,t,{x:s,y:c},{width:d,height:f},{x:l,y:u})}ensureDepthStencil(){if(!this.renderTarget.stencil){if(this.renderTarget.depthStencilTexture){x(`[RenderTargetSystem] a stencil mask is being used, but the render target's depthStencilTexture format '${this.renderTarget.depthStencilTexture.format}' has no stencil aspect, so masking cannot work here. Use a 'depth24plus-stencil8' texture instead.`);return}this.renderTarget._depth=!0,this.renderTarget._stencil=!0,this.adaptor.startRenderPass(this.renderTarget,!1,null,this.viewport,0,this.layer)}}destroy(){this._renderer=null,this._renderSurfaceToRenderTargetHash.forEach((e,t)=>{e===t?e.off(`destroy`,this._onRenderTargetDestroy,this):this._releaseRenderTarget(t,e)}),this._renderSurfaceToRenderTargetHash.clear();for(let e of Object.values(this._gpuRenderTargetHash))e&&this.adaptor.destroyGpuRenderTarget(e);this._gpuRenderTargetHash=Object.create(null)}_initRenderTarget(e){let t=null;if(u.test(e)&&(e=Je(e).source),e instanceof Z)t=e,e.once(`destroy`,this._onRenderTargetDestroy,this);else if(e instanceof D){let n=e.format;t=n.includes(`depth`)||n.includes(`stencil`)?new Z({colorTextures:0,depthStencilTexture:e}):new Z({colorTextures:[e]}),e.source instanceof u&&(t.isRoot=!0),e.once(`destroy`,this._onRenderSurfaceDestroy,this)}return this._renderSurfaceToRenderTargetHash.set(e,t),t}_onRenderSurfaceDestroy(e){let t=this._renderSurfaceToRenderTargetHash.get(e);t&&this._releaseRenderTarget(e,t)}_onRenderTargetDestroy(e){this._renderSurfaceToRenderTargetHash.delete(e),this._releaseGpuRenderTarget(e)}_releaseRenderTarget(e,t){t.destroy(),this._renderSurfaceToRenderTargetHash.delete(e),e.off(`destroy`,this._onRenderSurfaceDestroy,this),this._releaseGpuRenderTarget(t)}_releaseGpuRenderTarget(e){let t=this._gpuRenderTargetHash[e.uid];t&&(this._gpuRenderTargetHash[e.uid]=null,this.adaptor.destroyGpuRenderTarget(t))}getGpuRenderTarget(e){return this._gpuRenderTargetHash[e.uid]||(this._gpuRenderTargetHash[e.uid]=this._initGpuRenderTarget(e))}_initGpuRenderTarget(e){let t=e.colorAttachments;if(t.some(e=>e.texture.antialias)){let e=t.findIndex(e=>C(e.texture.format));if(e!==-1)throw Error(`[RenderTargetSystem] color attachment ${e} is ${t[e].texture.format}, an integer format, and integer formats can't be antialiased. Create the render target's textures without antialias.`)}return this.adaptor.initGpuRenderTarget(e)}resetState(){this.renderTarget=null,this._bindState.target=null}};export{R as a,P as c,B as i,N as l,Xe as n,L as o,Ye as r,F as s,$e as t};
|