@phil65/demoreel 0.3.1 → 0.4.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.
Files changed (37) hide show
  1. package/THIRD_PARTY_NOTICES.md +1 -1
  2. package/dist/args.js +12 -0
  3. package/dist/cli.js +31 -2
  4. package/dist/compose.d.ts +4 -0
  5. package/dist/compose.js +4 -0
  6. package/dist/gif.d.ts +16 -0
  7. package/dist/gif.js +19 -0
  8. package/dist/index.d.ts +3 -2
  9. package/dist/index.js +2 -1
  10. package/dist/openscreen/project.js +3 -3
  11. package/dist/project.d.ts +51 -1
  12. package/dist/project.js +89 -1
  13. package/dist/record.d.ts +6 -1
  14. package/dist/record.js +2 -1
  15. package/dist/renderer/assets/CanvasPool-PBu3bHFZ.js +1 -0
  16. package/dist/renderer/assets/CanvasRenderer-HmF-4gyW.js +1 -0
  17. package/dist/renderer/assets/RenderTargetSystem-Dk1U4wDJ.js +184 -0
  18. package/dist/renderer/assets/WebGLRenderer-C0v9HBel.js +149 -0
  19. package/dist/renderer/assets/WebGPURenderer-Ce0-U9Q1.js +95 -0
  20. package/dist/renderer/assets/{browserAll-aHn2isHo.js → browserAll-DhvWQ7nM.js} +2 -2
  21. package/dist/renderer/assets/canvasUtils-KRroregW.js +1 -0
  22. package/dist/renderer/assets/{getTexelRangeRects-yD6MQ0xy.js → getTexelRangeRects-D3pwCyRt.js} +3 -3
  23. package/dist/renderer/assets/index-CE-lli1m.js +556 -0
  24. package/dist/renderer/assets/init-DfmWKarH.js +83 -0
  25. package/dist/renderer/assets/webworkerAll-B41hok0-.js +1 -0
  26. package/dist/renderer/index.html +1 -6
  27. package/dist/scene.d.ts +24 -4
  28. package/dist/scene.js +74 -5
  29. package/dist/types.d.ts +4 -0
  30. package/package.json +1 -1
  31. package/dist/renderer/assets/CanvasPool-CHSHS1-v.js +0 -23
  32. package/dist/renderer/assets/RenderTargetSystem-EAUH9iQk.js +0 -404
  33. package/dist/renderer/assets/canvasUtils-n5g2f3_X.js +0 -1
  34. package/dist/renderer/assets/getTextureBatchBindGroup-Bwvgbco6.js +0 -1
  35. package/dist/renderer/assets/index-BwP6rH7I.js +0 -556
  36. package/dist/renderer/assets/init-C2Za5NQh.js +0 -83
  37. package/dist/renderer/assets/webworkerAll-JSSmbaR2.js +0 -1
@@ -1,404 +0,0 @@
1
- import{$ as e,A as t,B as n,E as r,F as i,G as a,H as o,J as s,L as c,M as l,O as u,Q as d,R as f,S as p,T as m,U as h,V as g,X as _,Y as v,a as y,at as b,b as x,c as ee,d as te,f as S,g as ne,h as re,i as C,n as ie,nt as ae,ot as w,p as oe,q as se,r as ce,rt as le,s as ue,t as de,tt as T,u as E,v as fe,w as D,x as O,z as k}from"./CanvasPool-CHSHS1-v.js";var A=[];w.handleByNamedList(b.Environment,A);async function pe(e){if(!e)for(let e=0;e<A.length;e++){let t=A[e];if(t.value.test()){await t.value.load();return}}}var j;function me(){if(typeof j==`boolean`)return j;try{j=Function(`param1`,`param2`,`param3`,`return param1[param2] === param3;`)({a:`b`},`a`,`b`)===!0}catch{j=!1}return j}var M=(e=>(e[e.NONE=0]=`NONE`,e[e.COLOR=16384]=`COLOR`,e[e.STENCIL=1024]=`STENCIL`,e[e.DEPTH=256]=`DEPTH`,e[e.COLOR_DEPTH=16640]=`COLOR_DEPTH`,e[e.COLOR_STENCIL=17408]=`COLOR_STENCIL`,e[e.DEPTH_STENCIL=1280]=`DEPTH_STENCIL`,e[e.ALL=17664]=`ALL`,e))(M||{}),he=class{constructor(e){this.items=[],this._name=e}emit(e,t,n,r,i,a,o,s){let{name:c,items:l}=this;for(let u=0,d=l.length;u<d;u++)l[u][c](e,t,n,r,i,a,o,s);return this}add(e){return e[this._name]&&(this.remove(e),this.items.push(e)),this}remove(e){let t=this.items.indexOf(e);return t!==-1&&this.items.splice(t,1),this}contains(e){return this.items.indexOf(e)!==-1}removeAll(){return this.items.length=0,this}destroy(){this.removeAll(),this.items=null,this._name=null}get empty(){return this.items.length===0}get name(){return this._name}},ge=[`init`,`destroy`,`contextChange`,`resolutionChange`,`resetState`,`renderEnd`,`renderStart`,`render`,`update`,`postrender`,`prerender`],_e=class e extends le{constructor(e){super(),this.tick=0,this.uid=d(`renderer`),this.runners=Object.create(null),this.renderPipes=Object.create(null),this._initOptions={},this._systemsHash=Object.create(null),this.type=e.type,this.name=e.name,this.config=e;let t=[...ge,...this.config.runners??[]];this._addRunners(...t),this._unsafeEvalCheck()}async init(t={}){let n=t.skipExtensionImports===!0||t.manageImports===!1;await pe(n),!n&&this.config.loaders&&await Promise.all(this.config.loaders.map(e=>e.value.load())),this._addSystems(this.config.systems),this._addPipes(this.config.renderPipes,this.config.renderPipeAdaptors);for(let e in this._systemsHash)t={...this._systemsHash[e].constructor.defaultOptions,...t};t={...e.defaultOptions,...t},this._roundPixels=+!!t.roundPixels;for(let e=0;e<this.runners.init.items.length;e++)await this.runners.init.items[e].init(t);this._initOptions=t}render(e,t){this.tick++;let r=e;if(r instanceof D&&(r={container:r},t&&(s(v,`passing a second argument is deprecated, please use render options instead`),r.target=t.renderTexture)),r.target||(r.target=this.view.renderTarget),r.target===this.view.renderTarget&&(this._lastObjectRendered=r.container,r.clearColor??(r.clearColor=this.background.colorRgba),r.clear??(r.clear=this.background.clearBeforeRender)),r.clearColor){let e=Array.isArray(r.clearColor)&&r.clearColor.length===4;r.clearColor=e?r.clearColor:n.shared.setValue(r.clearColor).toArray()}r.transform||(r.container.updateLocalTransform(),r.transform=r.container.localTransform),r.container.visible&&(r.container.enableRenderGroup(),this.runners.prerender.emit(r),this.runners.renderStart.emit(r),this.runners.render.emit(r),this.runners.renderEnd.emit(r),this.runners.postrender.emit(r))}resize(e,t,n){let r=this.view.resolution;this.view.resize(e,t,n),this.emit(`resize`,this.view.screen.width,this.view.screen.height,this.view.resolution),n!==void 0&&n!==r&&this.runners.resolutionChange.emit(n)}clear(e={}){let t=this;e.target||=t.renderTarget.renderTarget,e.clearColor||=this.background.colorRgba,e.clear??=M.ALL;let{clear:r,clearColor:i,target:a,mipLevel:o,layer:s}=e;n.shared.setValue(i??this.background.colorRgba),t.renderTarget.clear(a,r,n.shared.toArray(),o??0,s??0)}get resolution(){return this.view.resolution}set resolution(e){this.view.resolution=e,this.runners.resolutionChange.emit(e)}get width(){return this.view.texture.frame.width}get height(){return this.view.texture.frame.height}get canvas(){return this.view.canvas}get lastObjectRendered(){return this._lastObjectRendered}get renderingToScreen(){return this.renderTarget.renderingToScreen}get screen(){return this.view.screen}_addRunners(...e){e.forEach(e=>{this.runners[e]=new he(e)})}_addSystems(e){let t;for(t in e){let n=e[t];this._addSystem(n.value,n.name)}}_addSystem(e,t){let n=new e(this);if(this[t])throw Error(`Whoops! The name "${t}" is already in use`);this[t]=n,this._systemsHash[t]=n;for(let e in this.runners)this.runners[e].add(n);return this}_addPipes(e,t){let n=t.reduce((e,t)=>(e[t.name]=t.value,e),{});e.forEach(e=>{let t=e.value,r=e.name,i=n[r];this.renderPipes[r]=new t(this,i?new i:null),this.runners.destroy.add(this.renderPipes[r])})}destroy(e=!1){this.runners.destroy.items.reverse(),this.runners.destroy.emit(e),(e===!0||typeof e==`object`&&e.releaseGlobalResources)&&f.release(),Object.values(this.runners).forEach(e=>{e.destroy()}),this._systemsHash=null,this.renderPipes=null,this.removeAllListeners()}generateTexture(e){return this.textureGenerator.generateTexture(e)}get roundPixels(){return!!this._roundPixels}_unsafeEvalCheck(){if(!me())throw Error(`Current environment does not allow unsafe-eval, please use pixi.js/unsafe-eval module to enable support.`)}resetState(){this.runners.resetState.emit()}};_e.defaultOptions={resolution:1,failIfMajorPerformanceCaveat:!1,roundPixels:!1};var ve=_e,N=`8.23.0`,ye=class{static init(){globalThis.__PIXI_APP_INIT__?.(this,N)}static destroy(){}};ye.extension=b.Application;var be=class{constructor(e){this._renderer=e}init(){globalThis.__PIXI_RENDERER_INIT__?.(this._renderer,N)}destroy(){this._renderer=null}};be.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:`initHook`,priority:-10};var xe=class{constructor(e){this.rawBinaryData=typeof e==`number`?new ArrayBuffer(e):e instanceof Uint8Array?e.buffer:e,this.uint32View=new Uint32Array(this.rawBinaryData),this.float32View=new Float32Array(this.rawBinaryData),this.size=this.rawBinaryData.byteLength}get int8View(){return this._int8View||=new Int8Array(this.rawBinaryData),this._int8View}get uint8View(){return this._uint8View||=new Uint8Array(this.rawBinaryData),this._uint8View}get int16View(){return this._int16View||=new Int16Array(this.rawBinaryData),this._int16View}get int32View(){return this._int32View||=new Int32Array(this.rawBinaryData),this._int32View}get float64View(){return this._float64Array||=new Float64Array(this.rawBinaryData),this._float64Array}get bigUint64View(){return this._bigUint64Array||=new BigUint64Array(this.rawBinaryData),this._bigUint64Array}view(e){return this[`${e}View`]}destroy(){this.rawBinaryData=null,this.uint32View=null,this.float32View=null,this.uint16View=null,this._int8View=null,this._uint8View=null,this._int16View=null,this._int32View=null,this._float64Array=null,this._bigUint64Array=null}static sizeOf(e){switch(e){case`int8`:case`uint8`:return 1;case`int16`:case`uint16`:return 2;case`int32`:case`uint32`:case`float32`:return 4;default:throw Error(`${e} isn't a valid view type`)}}};function P(e,t,n,r){if(n??=0,r??=Math.min(e.byteLength-n,t.byteLength),!(n&7)&&!(r&7)){let i=r/8;new Float64Array(t,0,i).set(new Float64Array(e,n,i))}else if(!(n&3)&&!(r&3)){let i=r/4;new Float32Array(t,0,i).set(new Float32Array(e,n,i))}else new Uint8Array(t).set(new Uint8Array(e,n,r))}var Se={normal:`normal-npm`,add:`add-npm`,screen:`screen-npm`},F=(e=>(e[e.DISABLED=0]=`DISABLED`,e[e.RENDERING_MASK_ADD=1]=`RENDERING_MASK_ADD`,e[e.MASK_ACTIVE=2]=`MASK_ACTIVE`,e[e.INVERSE_MASK_ACTIVE=3]=`INVERSE_MASK_ACTIVE`,e[e.RENDERING_MASK_REMOVE=4]=`RENDERING_MASK_REMOVE`,e[e.NONE=5]=`NONE`,e))(F||{});function Ce(e,t){return t.alphaMode===`no-premultiply-alpha`&&Se[e]||e}var we=`precision mediump float;
2
- void main(void){
3
- float test = 0.1;
4
- %forloop%
5
- gl_FragColor = vec4(0.0);
6
- }`;function Te(e){let t=``;for(let n=0;n<e;++n)n>0&&(t+=`
7
- else `),n<e-1&&(t+=`if(test == ${n}.0){}`);return t}function Ee(e,t){if(e===0)throw Error("Invalid value of `0` passed to `checkMaxIfStatementsInShader`");let n=t.createShader(t.FRAGMENT_SHADER);try{for(;;){let r=we.replace(/%forloop%/gi,Te(e));if(t.shaderSource(n,r),t.compileShader(n),!t.getShaderParameter(n,t.COMPILE_STATUS))e=e/2|0;else break}}finally{t.deleteShader(n)}return e}var I=null;function De(){if(I)return I;let e=ne();return I=e.getParameter(e.MAX_TEXTURE_IMAGE_UNITS),I=Ee(I,e),e.getExtension(`WEBGL_lose_context`)?.loseContext(),I}var Oe=class{constructor(){this.ids=Object.create(null),this.textures=[],this.count=0}clear(){for(let e=0;e<this.count;e++){let t=this.textures[e];this.textures[e]=null,this.ids[t.uid]=null}this.count=0}},ke=class{constructor(){this.renderPipeId=`batch`,this.action=`startBatch`,this.start=0,this.size=0,this.textures=new Oe,this.blendMode=`normal`,this.topology=`triangle-strip`,this.canBundle=!0}destroy(){this.textures=null,this.gpuBindGroup=null,this.bindGroup=null,this.batcher=null,this.elements=null}},L=[],R=0;f.register({clear:()=>{if(L.length>0)for(let e of L)e&&e.destroy();L.length=0,R=0}});function Ae(){return R>0?L[--R]:new ke}function je(e){e.elements=null,L[R++]=e}var z=0,Me=class e{constructor(t){this.uid=d(`batcher`),this.dirty=!0,this.batchIndex=0,this.batches=[],this._elements=[],t={...e.defaultOptions,...t},t.maxTextures||(s(`v8.8.0`,`maxTextures is a required option for Batcher now, please pass it in the options`),t.maxTextures=De());let{maxTextures:n,attributesInitialSize:r,indicesInitialSize:i}=t;this.attributeBuffer=new xe(r*4),this.indexBuffer=new Uint16Array(i),this.maxTextures=n}begin(){this.elementSize=0,this.elementStart=0,this.indexSize=0,this.attributeSize=0;for(let e=0;e<this.batchIndex;e++)je(this.batches[e]);this.batchIndex=0,this._batchIndexStart=0,this._batchIndexSize=0,this.dirty=!0}add(e){this._elements[this.elementSize++]=e,e._indexStart=this.indexSize,e._attributeStart=this.attributeSize,e._batcher=this,this.indexSize+=e.indexSize,this.attributeSize+=e.attributeSize*this.vertexSize}checkAndUpdateTexture(e,t){let n=e._batch.textures.ids[t._source.uid];return!n&&n!==0?!1:(e._textureId=n,e.texture=t,!0)}updateElement(e){this.dirty=!0;let t=this.attributeBuffer;e.packAsQuad?this.packQuadAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId):this.packAttributes(e,t.float32View,t.uint32View,e._attributeStart,e._textureId)}break(e){let t=this._elements;if(!t[this.elementStart])return;let n=Ae(),r=n.textures;r.clear();let i=t[this.elementStart],a=Ce(i.blendMode,i.texture._source),o=i.topology;this.attributeSize*4>this.attributeBuffer.size&&this._resizeAttributeBuffer(this.attributeSize*4),this.indexSize>this.indexBuffer.length&&this._resizeIndexBuffer(this.indexSize);let s=this.attributeBuffer.float32View,c=this.attributeBuffer.uint32View,l=this.indexBuffer,u=this._batchIndexSize,d=this._batchIndexStart,f=`startBatch`,p=[],m=this.maxTextures;for(let i=this.elementStart;i<this.elementSize;++i){let h=t[i];t[i]=null;let g=h.texture._source,_=Ce(h.blendMode,g),v=a!==_||o!==h.topology;g._batchTick===z&&!v?(h._textureId=g._textureBindLocation,u+=h.indexSize,h.packAsQuad?(this.packQuadAttributes(h,s,c,h._attributeStart,h._textureId),this.packQuadIndex(l,h._indexStart,h._attributeStart/this.vertexSize)):(this.packAttributes(h,s,c,h._attributeStart,h._textureId),this.packIndex(h,l,h._indexStart,h._attributeStart/this.vertexSize)),h._batch=n,p.push(h)):((r.count>=m||v)&&(this._finishBatch(n,d,u-d,r,a,o,e,f,p),f=`renderBatch`,d=u,a=_,o=h.topology,n=Ae(),r=n.textures,r.clear(),p=[],++z),g._batchTick=z,h._textureId=g._textureBindLocation=r.count,r.ids[g.uid]=r.count,r.textures[r.count++]=g,h._batch=n,p.push(h),u+=h.indexSize,h.packAsQuad?(this.packQuadAttributes(h,s,c,h._attributeStart,h._textureId),this.packQuadIndex(l,h._indexStart,h._attributeStart/this.vertexSize)):(this.packAttributes(h,s,c,h._attributeStart,h._textureId),this.packIndex(h,l,h._indexStart,h._attributeStart/this.vertexSize)))}r.count>0&&(this._finishBatch(n,d,u-d,r,a,o,e,f,p),d=u,++z),this.elementStart=this.elementSize,this._batchIndexStart=d,this._batchIndexSize=u}_finishBatch(e,t,n,r,i,a,o,s,c){e.gpuBindGroup=null,e.bindGroup=null,e.action=s,e.batcher=this,e.textures=r,e.blendMode=i,e.topology=a,e.start=t,e.size=n,e.elements=c,++z,this.batches[this.batchIndex++]=e,o.add(e)}finish(e){this.break(e)}ensureAttributeBuffer(e){e*4<=this.attributeBuffer.size||this._resizeAttributeBuffer(e*4)}ensureIndexBuffer(e){e<=this.indexBuffer.length||this._resizeIndexBuffer(e)}_resizeAttributeBuffer(e){let t=new xe(Math.max(e,this.attributeBuffer.size*2));P(this.attributeBuffer.rawBinaryData,t.rawBinaryData),this.attributeBuffer=t}_resizeIndexBuffer(e){let t=this.indexBuffer,n=Math.max(e,t.length*1.5);n+=n%2;let r=n>65535?new Uint32Array(n):new Uint16Array(n);if(r.BYTES_PER_ELEMENT!==t.BYTES_PER_ELEMENT)for(let e=0;e<t.length;e++)r[e]=t[e];else P(t.buffer,r.buffer);this.indexBuffer=r}packQuadIndex(e,t,n){e[t]=n+0,e[t+1]=n+1,e[t+2]=n+2,e[t+3]=n+0,e[t+4]=n+2,e[t+5]=n+3}packIndex(e,t,n,r){let i=e.indices,a=e.indexSize,o=e.indexOffset,s=e.attributeOffset;for(let e=0;e<a;e++)t[n++]=r+i[e+o]-s}destroy(e={}){if(this.batches!==null){for(let e=0;e<this.batchIndex;e++)je(this.batches[e]);this.batches=null,this.geometry.destroy(!0),this.geometry=null,e.shader&&(this.shader?.destroy(),this.shader=null);for(let e=0;e<this._elements.length;e++)this._elements[e]&&(this._elements[e]._batch=null);this._elements=null,this.indexBuffer=null,this.attributeBuffer.destroy(),this.attributeBuffer=null}}};Me.defaultOptions={maxTextures:null,attributesInitialSize:4,indicesInitialSize:6};var Ne=Me,Pe=new Float32Array(1),Fe=new Uint32Array(1),Ie=class extends ie{constructor(){let e=new ce({data:Pe,label:`attribute-batch-buffer`,usage:C.VERTEX|C.COPY_DST,shrinkToFit:!1}),t=new ce({data:Fe,label:`index-batch-buffer`,usage:C.INDEX|C.COPY_DST,shrinkToFit:!1});super({attributes:{aPosition:{buffer:e,format:`float32x2`,stride:24,offset:0},aUV:{buffer:e,format:`float32x2`,stride:24,offset:8},aColor:{buffer:e,format:`unorm8x4`,stride:24,offset:16},aTextureIdAndRound:{buffer:e,format:`uint16x2`,stride:24,offset:20}},indexBuffer:t})}};function Le(e,t,n){if(e)for(let r in e){let i=t[r.toLocaleLowerCase()];if(i){let t=e[r];r===`header`&&(t=t.replace(/@in\s+[^;]+;\s*/g,``).replace(/@out\s+[^;]+;\s*/g,``)),n&&i.push(`//----${n}----//`),i.push(t)}else k(`${r} placement hook does not exist in shader`)}}var Re=/\{\{(.*?)\}\}/g;function ze(e){let t={};return(e.match(Re)?.map(e=>e.replace(/[{()}]/g,``))??[]).forEach(e=>{t[e]=[]}),t}function Be(e,t){let n,r=/@in\s+([^;]+);/g;for(;(n=r.exec(e))!==null;)t.push(n[1])}function Ve(e,t,n=!1){let r=[];Be(t,r),e.forEach(e=>{e.header&&Be(e.header,r)});let i=r;n&&i.sort();let a=i.map((e,t)=>` @location(${t}) ${e},`).join(`
8
- `),o=t.replace(/@in\s+[^;]+;\s*/g,``);return o=o.replace(`{{in}}`,`
9
- ${a}
10
- `),o}function He(e,t){let n,r=/@out\s+([^;]+);/g;for(;(n=r.exec(e))!==null;)t.push(n[1])}function Ue(e){let t=/\b(\w+)\s*:/g.exec(e);return t?t[1]:``}function We(e){return e.replace(/@.*?\s+/g,``)}function Ge(e,t){let n=[];He(t,n),e.forEach(e=>{e.header&&He(e.header,n)});let r=0,i=n.sort().map(e=>e.indexOf(`builtin`)>-1?e:`@location(${r++}) ${e}`).join(`,
11
- `),a=n.sort().map(e=>` var ${We(e)};`).join(`
12
- `),o=`return VSOutput(
13
- ${n.sort().map(e=>` ${Ue(e)}`).join(`,
14
- `)});`,s=t.replace(/@out\s+[^;]+;\s*/g,``);return s=s.replace(`{{struct}}`,`
15
- ${i}
16
- `),s=s.replace(`{{start}}`,`
17
- ${a}
18
- `),s=s.replace(`{{return}}`,`
19
- ${o}
20
- `),s}function Ke(e,t){let n=e;for(let e in t){let r=t[e];n=r.join(`
21
- `).length?n.replace(`{{${e}}}`,`//-----${e} START-----//
22
- ${r.join(`
23
- `)}
24
- //----${e} FINISH----//`):n.replace(`{{${e}}}`,``)}return n}var B=Object.create(null),V=new Map,qe=0;function Je({template:e,bits:t}){let n=Ze(e,t);if(B[n])return B[n];let{vertex:r,fragment:i}=Xe(e,t);return B[n]=Qe(r,i,t),B[n]}function Ye({template:e,bits:t}){let n=Ze(e,t);return B[n]||(B[n]=Qe(e.vertex,e.fragment,t)),B[n]}function Xe(e,t){let n=t.map(e=>e.vertex).filter(e=>!!e),r=t.map(e=>e.fragment).filter(e=>!!e),i=Ve(n,e.vertex,!0);i=Ge(n,i);let a=Ve(r,e.fragment,!0);return{vertex:i,fragment:a}}function Ze(e,t){return t.map(e=>(V.has(e)||V.set(e,qe++),V.get(e))).sort((e,t)=>e-t).join(`-`)+e.vertex+e.fragment}function Qe(e,t,n){let r=ze(e),i=ze(t);return n.forEach(e=>{Le(e.vertex,r,e.name),Le(e.fragment,i,e.name)}),{vertex:Ke(e,r),fragment:Ke(t,i)}}var $e=`
25
- @in aPosition: vec2<f32>;
26
- @in aUV: vec2<f32>;
27
-
28
- @out @builtin(position) vPosition: vec4<f32>;
29
- @out vUV : vec2<f32>;
30
- @out vColor : vec4<f32>;
31
-
32
- {{header}}
33
-
34
- struct VSOutput {
35
- {{struct}}
36
- };
37
-
38
- @vertex
39
- fn main( {{in}} ) -> VSOutput {
40
-
41
- var worldTransformMatrix = globalUniforms.uWorldTransformMatrix;
42
- var modelMatrix = mat3x3<f32>(
43
- 1.0, 0.0, 0.0,
44
- 0.0, 1.0, 0.0,
45
- 0.0, 0.0, 1.0
46
- );
47
- var position = aPosition;
48
- var uv = aUV;
49
-
50
- {{start}}
51
-
52
- vColor = vec4<f32>(1., 1., 1., 1.);
53
-
54
- {{main}}
55
-
56
- vUV = uv;
57
-
58
- var modelViewProjectionMatrix = globalUniforms.uProjectionMatrix * worldTransformMatrix * modelMatrix;
59
-
60
- vPosition = vec4<f32>((modelViewProjectionMatrix * vec3<f32>(position, 1.0)).xy, 0.0, 1.0);
61
-
62
- vColor *= globalUniforms.uWorldColorAlpha;
63
-
64
- {{end}}
65
-
66
- {{return}}
67
- };
68
- `,et=`
69
- @in vUV : vec2<f32>;
70
- @in vColor : vec4<f32>;
71
-
72
- {{header}}
73
-
74
- @fragment
75
- fn main(
76
- {{in}}
77
- ) -> @location(0) vec4<f32> {
78
-
79
- {{start}}
80
-
81
- var outColor:vec4<f32>;
82
-
83
- {{main}}
84
-
85
- var finalColor:vec4<f32> = outColor * vColor;
86
-
87
- {{end}}
88
-
89
- return finalColor;
90
- };
91
- `,tt=`
92
- in vec2 aPosition;
93
- in vec2 aUV;
94
-
95
- out vec4 vColor;
96
- out vec2 vUV;
97
-
98
- {{header}}
99
-
100
- void main(void){
101
-
102
- mat3 worldTransformMatrix = uWorldTransformMatrix;
103
- mat3 modelMatrix = mat3(
104
- 1.0, 0.0, 0.0,
105
- 0.0, 1.0, 0.0,
106
- 0.0, 0.0, 1.0
107
- );
108
- vec2 position = aPosition;
109
- vec2 uv = aUV;
110
-
111
- {{start}}
112
-
113
- vColor = vec4(1.);
114
-
115
- {{main}}
116
-
117
- vUV = uv;
118
-
119
- mat3 modelViewProjectionMatrix = uProjectionMatrix * worldTransformMatrix * modelMatrix;
120
-
121
- gl_Position = vec4((modelViewProjectionMatrix * vec3(position, 1.0)).xy, 0.0, 1.0);
122
-
123
- vColor *= uWorldColorAlpha;
124
-
125
- {{end}}
126
- }
127
- `,nt=`
128
-
129
- in vec4 vColor;
130
- in vec2 vUV;
131
-
132
- out vec4 finalColor;
133
-
134
- {{header}}
135
-
136
- void main(void) {
137
-
138
- {{start}}
139
-
140
- vec4 outColor;
141
-
142
- {{main}}
143
-
144
- finalColor = outColor * vColor;
145
-
146
- {{end}}
147
- }
148
- `,rt={name:`global-uniforms-bit`,vertex:{header:`
149
- struct GlobalUniforms {
150
- uProjectionMatrix:mat3x3<f32>,
151
- uWorldTransformMatrix:mat3x3<f32>,
152
- uWorldColorAlpha: vec4<f32>,
153
- uResolution: vec2<f32>,
154
- }
155
-
156
- @group(0) @binding(0) var<uniform> globalUniforms : GlobalUniforms;
157
- `}},it={name:`global-uniforms-bit`,vertex:{header:`
158
- uniform mat3 uProjectionMatrix;
159
- uniform mat3 uWorldTransformMatrix;
160
- uniform vec4 uWorldColorAlpha;
161
- uniform vec2 uResolution;
162
- `}};function at({bits:e,name:t}){let n=Je({template:{fragment:et,vertex:$e},bits:[rt,...e]});return oe.from({name:t,vertex:{source:n.vertex,entryPoint:`main`},fragment:{source:n.fragment,entryPoint:`main`}})}function ot({bits:e,name:t}){return new re({name:t,...Ye({template:{vertex:tt,fragment:nt},bits:[it,...e]})})}var st={name:`color-bit`,vertex:{header:`
163
- @in aColor: vec4<f32>;
164
- `,main:`
165
- vColor *= vec4<f32>(aColor.rgb * aColor.a, aColor.a);
166
- `}},ct={name:`color-bit`,vertex:{header:`
167
- in vec4 aColor;
168
- `,main:`
169
- vColor *= vec4(aColor.rgb * aColor.a, aColor.a);
170
- `}},H={};function lt(e){let t=[];if(e===1)t.push(`@group(1) @binding(0) var textureSource1: texture_2d<f32>;`),t.push(`@group(1) @binding(1) var textureSampler1: sampler;`);else{let n=0;for(let r=0;r<e;r++)t.push(`@group(1) @binding(${n++}) var textureSource${r+1}: texture_2d<f32>;`),t.push(`@group(1) @binding(${n++}) var textureSampler${r+1}: sampler;`)}return t.join(`
171
- `)}function ut(e){let t=[];if(e===1)t.push(`outColor = textureSampleGrad(textureSource1, textureSampler1, vUV, uvDx, uvDy);`);else{t.push(`switch vTextureId {`);for(let n=0;n<e;n++)n===e-1?t.push(` default:{`):t.push(` case ${n}:{`),t.push(` outColor = textureSampleGrad(textureSource${n+1}, textureSampler${n+1}, vUV, uvDx, uvDy);`),t.push(` break;}`);t.push(`}`)}return t.join(`
172
- `)}function dt(e){return H[e]||(H[e]={name:`texture-batch-bit`,vertex:{header:`
173
- @in aTextureIdAndRound: vec2<u32>;
174
- @out @interpolate(flat) vTextureId : u32;
175
- `,main:`
176
- vTextureId = aTextureIdAndRound.y;
177
- `,end:`
178
- if(aTextureIdAndRound.x == 1)
179
- {
180
- vPosition = vec4<f32>(roundPixels(vPosition.xy, globalUniforms.uResolution), vPosition.zw);
181
- }
182
- `},fragment:{header:`
183
- @in @interpolate(flat) vTextureId: u32;
184
-
185
- ${lt(e)}
186
- `,main:`
187
- var uvDx = dpdx(vUV);
188
- var uvDy = dpdy(vUV);
189
-
190
- ${ut(e)}
191
- `}}),H[e]}var U={};function ft(e){let t=[];for(let n=0;n<e;n++)n>0&&t.push(`else`),n<e-1&&t.push(`if(vTextureId < ${n}.5)`),t.push(`{`),t.push(` outColor = texture(uTextures[${n}], vUV);`),t.push(`}`);return t.join(`
192
- `)}function pt(e){return U[e]||(U[e]={name:`texture-batch-bit`,vertex:{header:`
193
- in vec2 aTextureIdAndRound;
194
- out float vTextureId;
195
-
196
- `,main:`
197
- vTextureId = aTextureIdAndRound.y;
198
- `,end:`
199
- if(aTextureIdAndRound.x == 1.)
200
- {
201
- gl_Position.xy = roundPixels(gl_Position.xy, uResolution);
202
- }
203
- `},fragment:{header:`
204
- in float vTextureId;
205
-
206
- uniform sampler2D uTextures[${e}];
207
-
208
- `,main:`
209
-
210
- ${ft(e)}
211
- `}}),U[e]}var mt={name:`round-pixels-bit`,vertex:{header:`
212
- fn roundPixels(position: vec2<f32>, targetSize: vec2<f32>) -> vec2<f32>
213
- {
214
- return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
215
- }
216
- `}},ht={name:`round-pixels-bit`,vertex:{header:`
217
- vec2 roundPixels(vec2 position, vec2 targetSize)
218
- {
219
- return (floor(((position * 0.5 + 0.5) * targetSize) + 0.5) / targetSize) * 2.0 - 1.0;
220
- }
221
- `}},gt={};function _t(e){let t=gt[e];if(t)return t;let n=new Int32Array(e);for(let t=0;t<e;t++)n[t]=t;return t=gt[e]=new S({uTextures:{value:n,type:`i32`,size:e}},{isStatic:!0}),t}var vt=class extends ee{constructor(e){let t=ot({name:`batch`,bits:[ct,pt(e),ht]}),n=at({name:`batch`,bits:[st,dt(e),mt]});super({glProgram:t,gpuProgram:n,resources:{batchSamplers:_t(e)}}),this.maxTextures=e}},W=null,yt=class e extends Ne{constructor(t){super(t),this.geometry=new Ie,this.name=e.extension.name,this.vertexSize=6,W??=new vt(t.maxTextures),this.shader=W}packAttributes(e,t,n,r,i){let a=i<<16|e.roundPixels&65535,o=e.transform,s=o.a,c=o.b,l=o.c,u=o.d,d=o.tx,f=o.ty,{positions:p,uvs:m}=e,h=e.color,g=e.attributeOffset,_=g+e.attributeSize;for(let e=g;e<_;e++){let i=e*2,o=p[i],g=p[i+1];t[r++]=s*o+l*g+d,t[r++]=u*g+c*o+f,t[r++]=m[i],t[r++]=m[i+1],n[r++]=h,n[r++]=a}}packQuadAttributes(e,t,n,r,i){let a=e.texture,o=e.transform,s=o.a,c=o.b,l=o.c,u=o.d,d=o.tx,f=o.ty,p=e.bounds,m=p.maxX,h=p.minX,g=p.maxY,_=p.minY,v=a.uvs,y=e.color,b=i<<16|e.roundPixels&65535;t[r+0]=s*h+l*_+d,t[r+1]=u*_+c*h+f,t[r+2]=v.x0,t[r+3]=v.y0,n[r+4]=y,n[r+5]=b,t[r+6]=s*m+l*_+d,t[r+7]=u*_+c*m+f,t[r+8]=v.x1,t[r+9]=v.y1,n[r+10]=y,n[r+11]=b,t[r+12]=s*m+l*g+d,t[r+13]=u*g+c*m+f,t[r+14]=v.x2,t[r+15]=v.y2,n[r+16]=y,n[r+17]=b,t[r+18]=s*h+l*g+d,t[r+19]=u*g+c*h+f,t[r+20]=v.x3,t[r+21]=v.y3,n[r+22]=y,n[r+23]=b}_updateMaxTextures(e){this.shader.maxTextures!==e&&(W=new vt(e),this.shader=W)}destroy(){this.shader=null,super.destroy()}};yt.extension={type:[b.Batcher],name:`default`};var G=yt,bt=class{constructor(e){this.items=Object.create(null);let{renderer:t,type:n,onUnload:r,priority:i,name:a}=e;this._renderer=t,t.gc.addResourceHash(this,`items`,n,i??0),this._onUnload=r,this.name=a}add(e){return!this.items[e.uid]&&(this.items[e.uid]=e,e.once(`unload`,this.remove,this),e._gcLastUsed=this._renderer.gc.now,!0)}remove(e,...t){if(!this.items[e.uid])return;let n=e._gpuData[this._renderer.uid];n&&(this._onUnload?.(e,...t),e.off(`unload`,this.remove,this),n.destroy(),e._gpuData[this._renderer.uid]=null,this.items[e.uid]=null)}removeAll(...e){Object.values(this.items).forEach(t=>t&&this.remove(t,...e))}destroy(...e){this.removeAll(...e),this.items=Object.create(null),this._renderer=null,this._onUnload=null}},xt=`in vec2 vMaskCoord;
222
- in vec2 vTextureCoord;
223
-
224
- uniform sampler2D uTexture;
225
- uniform sampler2D uMaskTexture;
226
-
227
- uniform float uAlpha;
228
- uniform vec4 uMaskClamp;
229
- uniform float uInverse;
230
- uniform float uChannel;
231
-
232
- out vec4 finalColor;
233
-
234
- void main(void)
235
- {
236
- float clip = step(3.5,
237
- step(uMaskClamp.x, vMaskCoord.x) +
238
- step(uMaskClamp.y, vMaskCoord.y) +
239
- step(vMaskCoord.x, uMaskClamp.z) +
240
- step(vMaskCoord.y, uMaskClamp.w));
241
-
242
- // TODO look into why this is needed
243
- float npmAlpha = uAlpha;
244
- vec4 original = texture(uTexture, vTextureCoord);
245
- vec4 masky = texture(uMaskTexture, vMaskCoord);
246
-
247
- float a;
248
- if (uChannel == 1.0) {
249
- a = masky.a * npmAlpha * clip;
250
- } else {
251
- float alphaMul = 1.0 - npmAlpha * (1.0 - masky.a);
252
- a = alphaMul * masky.r * npmAlpha * clip;
253
- }
254
-
255
- if (uInverse == 1.0) {
256
- a = 1.0 - a;
257
- }
258
-
259
- finalColor = original * a;
260
- }
261
- `,St=`in vec2 aPosition;
262
-
263
- out vec2 vTextureCoord;
264
- out vec2 vMaskCoord;
265
-
266
-
267
- uniform vec4 uInputSize;
268
- uniform vec4 uOutputFrame;
269
- uniform vec4 uOutputTexture;
270
- uniform mat3 uFilterMatrix;
271
-
272
- vec4 filterVertexPosition( vec2 aPosition )
273
- {
274
- vec2 position = aPosition * uOutputFrame.zw + uOutputFrame.xy;
275
-
276
- position.x = position.x * (2.0 / uOutputTexture.x) - 1.0;
277
- position.y = position.y * (2.0*uOutputTexture.z / uOutputTexture.y) - uOutputTexture.z;
278
-
279
- return vec4(position, 0.0, 1.0);
280
- }
281
-
282
- vec2 filterTextureCoord( vec2 aPosition )
283
- {
284
- return aPosition * (uOutputFrame.zw * uInputSize.zw);
285
- }
286
-
287
- vec2 getFilterCoord( vec2 aPosition )
288
- {
289
- return ( uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
290
- }
291
-
292
- void main(void)
293
- {
294
- gl_Position = filterVertexPosition(aPosition);
295
- vTextureCoord = filterTextureCoord(aPosition);
296
- vMaskCoord = getFilterCoord(aPosition);
297
- }
298
- `,Ct=`struct GlobalFilterUniforms {
299
- uInputSize:vec4<f32>,
300
- uInputPixel:vec4<f32>,
301
- uInputClamp:vec4<f32>,
302
- uOutputFrame:vec4<f32>,
303
- uGlobalFrame:vec4<f32>,
304
- uOutputTexture:vec4<f32>,
305
- };
306
-
307
- struct MaskUniforms {
308
- uFilterMatrix:mat3x3<f32>,
309
- uMaskClamp:vec4<f32>,
310
- uAlpha:f32,
311
- uInverse:f32,
312
- uChannel:f32,
313
- };
314
-
315
- @group(0) @binding(0) var<uniform> gfu: GlobalFilterUniforms;
316
- @group(0) @binding(1) var uTexture: texture_2d<f32>;
317
- @group(0) @binding(2) var uSampler : sampler;
318
-
319
- @group(1) @binding(0) var<uniform> filterUniforms : MaskUniforms;
320
- @group(1) @binding(1) var uMaskTexture: texture_2d<f32>;
321
-
322
- struct VSOutput {
323
- @builtin(position) position: vec4<f32>,
324
- @location(0) uv : vec2<f32>,
325
- @location(1) filterUv : vec2<f32>,
326
- };
327
-
328
- fn filterVertexPosition(aPosition:vec2<f32>) -> vec4<f32>
329
- {
330
- var position = aPosition * gfu.uOutputFrame.zw + gfu.uOutputFrame.xy;
331
-
332
- position.x = position.x * (2.0 / gfu.uOutputTexture.x) - 1.0;
333
- position.y = position.y * (2.0*gfu.uOutputTexture.z / gfu.uOutputTexture.y) - gfu.uOutputTexture.z;
334
-
335
- return vec4(position, 0.0, 1.0);
336
- }
337
-
338
- fn filterTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
339
- {
340
- return aPosition * (gfu.uOutputFrame.zw * gfu.uInputSize.zw);
341
- }
342
-
343
- fn globalTextureCoord( aPosition:vec2<f32> ) -> vec2<f32>
344
- {
345
- return (aPosition.xy / gfu.uGlobalFrame.zw) + (gfu.uGlobalFrame.xy / gfu.uGlobalFrame.zw);
346
- }
347
-
348
- fn getFilterCoord(aPosition:vec2<f32> ) -> vec2<f32>
349
- {
350
- return ( filterUniforms.uFilterMatrix * vec3( filterTextureCoord(aPosition), 1.0) ).xy;
351
- }
352
-
353
- fn getSize() -> vec2<f32>
354
- {
355
- return gfu.uGlobalFrame.zw;
356
- }
357
-
358
- @vertex
359
- fn mainVertex(
360
- @location(0) aPosition : vec2<f32>,
361
- ) -> VSOutput {
362
- return VSOutput(
363
- filterVertexPosition(aPosition),
364
- filterTextureCoord(aPosition),
365
- getFilterCoord(aPosition)
366
- );
367
- }
368
-
369
- @fragment
370
- fn mainFragment(
371
- @location(0) uv: vec2<f32>,
372
- @location(1) filterUv: vec2<f32>,
373
- @builtin(position) position: vec4<f32>
374
- ) -> @location(0) vec4<f32> {
375
-
376
- var maskClamp = filterUniforms.uMaskClamp;
377
- var uAlpha = filterUniforms.uAlpha;
378
-
379
- var clip = step(3.5,
380
- step(maskClamp.x, filterUv.x) +
381
- step(maskClamp.y, filterUv.y) +
382
- step(filterUv.x, maskClamp.z) +
383
- step(filterUv.y, maskClamp.w));
384
-
385
- var mask = textureSample(uMaskTexture, uSampler, filterUv);
386
- var source = textureSample(uTexture, uSampler, uv);
387
-
388
- var a: f32;
389
- if (filterUniforms.uChannel == 1.0) {
390
- a = mask.a * uAlpha * clip;
391
- } else {
392
- var alphaMul = 1.0 - uAlpha * (1.0 - mask.a);
393
- a = alphaMul * mask.r * uAlpha * clip;
394
- }
395
-
396
- if (filterUniforms.uInverse == 1.0) {
397
- a = 1.0 - a;
398
- }
399
-
400
- return source * a;
401
- }
402
- `,wt=class extends y{constructor(e){let{sprite:t,...n}=e,r=new h(t.texture),i=new S({uFilterMatrix:{value:new T,type:`mat3x3<f32>`},uMaskClamp:{value:r.uClampFrame,type:`vec4<f32>`},uAlpha:{value:1,type:`f32`},uInverse:{value:+!!e.inverse,type:`f32`},uChannel:{value:+(e.channel===`alpha`),type:`f32`}}),a=oe.from({vertex:{source:Ct,entryPoint:`mainVertex`},fragment:{source:Ct,entryPoint:`mainFragment`}}),o=re.from({vertex:St,fragment:xt,name:`mask-filter`});super({...n,gpuProgram:a,glProgram:o,clipToViewport:!1,resources:{filterUniforms:i,uMaskTexture:t.texture.source}}),this.sprite=t,this._textureMatrix=r}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?(k(`[MaskFilter] The mask texture was destroyed while the mask is still in use. Remove the mask before destroying its texture.`),o.EMPTY):e}destroy(e=!1){this._textureMatrix.destroy(),super.destroy(e)}};function Tt(e,t,n){let r=(e>>24&255)/255;t[n++]=(e&255)/255*r,t[n++]=(e>>8&255)/255*r,t[n++]=(e>>16&255)/255*r,t[n++]=r}var Et=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()}},K=class e{constructor(e,t){this.state=ue.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 G({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}};K.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:`batch`},K._availableBatchers=Object.create(null);var q=K;w.handleByMap(b.Batcher,q._availableBatchers),w.add(G);var Dt=new g,Ot=class extends i{constructor(){super(),this._placeholderSprite=new p(o.EMPTY),this.filters=[new wt({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=o.EMPTY,this.sprite=this._placeholderSprite}},J=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 i=c.get(Ot);if(i.inverse=e.inverse,i.channel=e.mask.channel,n){e.mask.mask.measurable=!0;let n=l(e.mask.mask,!0,Dt);e.mask.mask.measurable=!1,n.ceil();let a=t.renderTarget.renderTarget.colorTexture.source,o=r.getOptimalTexture({width:n.width,height:n.height,resolution:a._resolution,antialias:a.antialias});t.renderTarget.push({target:o,clear:!0}),t.globalUniforms.push({offset:n,worldColor:4294967295});let s=i.sprite;s.texture=o,s.worldTransform.tx=n.minX,s.worldTransform.ty=n.minY,this._activeMaskStage.push({filterEffect:i,maskedContainer:e.maskedContainer,filterTexture:o})}else i.sprite=e.mask.mask,this._activeMaskStage.push({filterEffect:i,maskedContainer:e.maskedContainer})}else if(e.action===`pushMaskEnd`){let e=this._activeMaskStage[this._activeMaskStage.length-1];n&&(t.type===E.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&&r.returnTexture(e.filterTexture),this._usedEffects.push(e.filterEffect)}}postrender(){let e=this._usedEffects;for(let t=0;t<e.length;t++)c.return(e[t]);e.length=0}destroy(){this.postrender(),this._renderer.runners.postrender.remove(this),this._renderer=null,this._activeMaskStage=null,this._usedEffects=null}};J.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:`alphaMask`};var kt=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}};kt.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:`colorMask`};var At=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 t=this._renderer,n=t.renderTarget.getGpuRenderTarget(t.renderTarget.renderTarget),r=n.maskStackIndex;e.action===`pushMaskBegin`?(t.renderTarget.ensureDepthStencil(),t.stencil.setStencilMode(F.RENDERING_MASK_ADD,r),r++,t.colorMask.setMask(0)):e.action===`pushMaskEnd`?(e.inverse?t.stencil.setStencilMode(F.INVERSE_MASK_ACTIVE,r):t.stencil.setStencilMode(F.MASK_ACTIVE,r),t.colorMask.setMask(15)):e.action===`popMaskBegin`?(t.colorMask.setMask(0),r===0?(t.renderTarget.clear(null,M.STENCIL),t.stencil.setStencilMode(F.DISABLED,r)):t.stencil.setStencilMode(F.RENDERING_MASK_REMOVE,r),r--):e.action===`popMaskEnd`&&(e.inverse?t.stencil.setStencilMode(F.INVERSE_MASK_ACTIVE,r):t.stencil.setStencilMode(F.MASK_ACTIVE,r),t.colorMask.setMask(15)),n.maskStackIndex=r}destroy(){this._renderer=null,this._maskHash=null}};At.extension={type:[b.WebGLPipes,b.WebGPUPipes],name:`stencilMask`};var jt=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}};jt.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:`customRender`};function Mt(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 Nt=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&&=(c.return(e._batchableRenderGroup),null),t.add(e)}_addRenderableCacheAsTexture(e,t){let n=e._batchableRenderGroup??=c.get(Et);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 T().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:4294967295,offset:{x:0,y:0}}),Mt(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}),Mt(e,this._renderer.renderPipes),this._renderer.globalUniforms.pop()}};Nt.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:`renderGroup`};var Pt=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 Et;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}};Pt.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:`sprite`};var Y={};w.handle(b.BlendMode,e=>{if(!e.name)throw Error(`BlendMode extension must have a name property`);Y[e.name]=e.ref},e=>{delete Y[e.name]});var Ft=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 m;this._activeBlendMode===t?this._isAdvanced&&e&&!r&&this._renderableList?.push(e):(this._isAdvanced&&this._endAdvancedBlendMode(n),this._activeBlendMode=t,e&&(this._isAdvanced=!!Y[t],this._isAdvanced&&this._beginAdvancedBlendMode(e,n)))}_beginAdvancedBlendMode(e,t){this._renderer.renderPipes.batch.break(t);let n=this._activeBlendMode;if(!Y[n]){k(`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 m,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 i,t.filters=[new Y[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}};Ft.extension={type:[b.WebGLPipes,b.WebGPUPipes,b.CanvasPipes],name:`blendMode`};function It(e,t){t||=0;for(let n=t;n<e.length&&e[n];n++)e[n]=null}var Lt=new D,Rt=7;function zt(e,t=!1){Bt(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&&Vt(n,r,0)}It(o,s),a.index=0}if(t)for(let n=0;n<e.renderGroupChildren.length;n++)zt(e.renderGroupChildren[n],t)}function Bt(e){let n=e.root,r;if(e.renderGroupParent){let i=e.renderGroupParent;e.worldTransform.appendFrom(n.relativeGroupTransform,i.worldTransform),e.worldColor=t(n.groupColor,i.worldColor),r=n.groupAlpha*i.worldAlpha}else e.worldTransform.copyFrom(n.localTransform),e.worldColor=n.localColor,r=n.localAlpha;r=r<0?0:r>1?1:r,e.worldAlpha=r,e.worldColorAlpha=e.worldColor+((r*255|0)<<24)}function Vt(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&Rt&&Ht(e,i,n)):(n=e._updateFlags,e.relativeGroupTransform.copyFrom(r),n&Rt&&Ht(e,Lt,n)),!e.renderGroup){let r=e.children,i=r.length;for(let e=0;e<i;e++)Vt(r[e],t,n);let a=e.parentRenderGroup,o=e;o.renderPipeId&&!a.structureDidChange&&a.updateRenderable(o)}}function Ht(e,n,r){if(r&1){e.groupColor=t(e.localColor,n.groupColor);let r=e.localAlpha*n.groupAlpha;r=r<0?0:r>1?1:r,e.groupAlpha=r,e.groupColorAlpha=e.groupColor+((r*255|0)<<24)}r&2&&(e.groupBlendMode=e.localBlendMode===`inherit`?n.groupBlendMode:e.localBlendMode),r&4&&(e.globalDisplayStatus=e.localDisplayStatus&n.globalDisplayStatus),e._updateFlags=0}function Ut(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 Wt=new T,Gt=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=Wt;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}),Mt(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,i=e.textureOptions.resolution||n.view.resolution,a=e.textureOptions.antialias??n.view.antialias,o=e.textureOptions.scaleMode??`linear`,s=e.texture;t.ceil(),e.texture&&r.returnTexture(e.texture),e.texture=r.getOptimalTexture({width:t.width,height:t.height,resolution:i,antialias:a,scaleMode:o}),e._textureBounds||=new g,e._textureBounds.copyFrom(t),s!==e.texture&&e.renderGroupParent&&(e.renderGroupParent.structureDidChange=!0)}}else e.texture&&=(r.returnTexture(e.texture),null)}_updateRenderGroups(e){let t=this._renderer,n=t.renderPipes;if(e.runOnRender(t),e.instructionSet.renderPipes=n,e.structureDidChange?It(e.childrenRenderablesToUpdate.list,0):Ut(e,n),zt(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)}It(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)}};Gt.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`renderGroup`};var Kt=class e{constructor(){this.clearBeforeRender=!0,this._backgroundColor=new n(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){n.shared.setValue(e).alpha<1&&this._backgroundColor.alpha===1&&k(`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(){}};Kt.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`background`,priority:0},Kt.defaultOptions={backgroundAlpha:1,backgroundColor:0,clearBeforeRender:!0};var qt=Kt;function Jt(e,t=!1){let n=e.source.format;if(n.endsWith(`float`)||se(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 X={png:`image/png`,jpg:`image/jpeg`,webp:`image/webp`},Yt=class e{constructor(e){this._renderer=e}_normalizeOptions(e,t={}){return e instanceof D||e instanceof o?{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)},X[n],r)});if(i.toDataURL!==void 0)return i.toDataURL(X[n],r);if(i.convertToBlob!==void 0){let e=await i.convertToBlob({type:X[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 o)return Jt(t),n.texture.generateCanvas(t);let r=n.textureGenerator.generateTexture(e);Jt(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 o?t:n.textureGenerator.generateTexture(e);Jt(r,!(t instanceof o));let i=n.texture.getPixels(r);return t instanceof D&&r.destroy(!0),i}texture(e){return e=this._normalizeOptions(e),e.target instanceof o?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}};Yt.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`extract`},Yt.defaultImageOptions={format:`png`,quality:1};var Xt=Yt,Zt=class e extends o{static create(t){let{dynamic:n,textureOptions:r,...i}=t;return new e({...r,source:new a(i),dynamic:n??!1})}resize(e,t,n){return this.source.resize(e,t,n),this}},Qt=new e,$t=new g,en=[0,0,0,0],tn=class{constructor(e){this._renderer=e}generateTexture(e){e instanceof D&&(e={target:e,frame:void 0,textureSourceOptions:{},resolution:void 0});let t=e.resolution||this._renderer.resolution,r=e.antialias||this._renderer.view.antialias,i=e.target,a=e.clearColor;a=a?Array.isArray(a)&&a.length===4?a:n.shared.setValue(a).toArray():en;let o=e.frame?.copyTo(Qt)||u(i,$t).rectangle,s=e.defaultAnchor&&{defaultAnchor:e.defaultAnchor};o.width=Math.max(o.width,1/t)|0,o.height=Math.max(o.height,1/t)|0;let c=Zt.create({...e.textureSourceOptions,width:o.width,height:o.height,resolution:t,antialias:r,textureOptions:s}),l=T.shared.translate(-o.x,-o.y);return this._renderer.render({container:i,transform:l,target:c,clearColor:a}),c.source.updateMipmaps(),c}destroy(){this._renderer=null}};tn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`textureGenerator`};function nn(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 rn(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 an=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`?nn(t[n]):rn(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}};an.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`gc`,priority:0},an.defaultOptions={gcActive:!0,gcMaxUnusedTime:6e4,gcFrequency:3e4};var on=an,sn=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:r,offset:i}){let a=this._renderer.renderTarget.renderTarget,o=this._stackIndex?this._globalUniformDataStack[this._stackIndex-1]:{projectionData:a,worldTransformMatrix:new T,worldColor:4294967295,offset:new ae},s={projectionMatrix:t||this._renderer.renderTarget.projectionMatrix,resolution:e||a.size,worldTransformMatrix:n||o.worldTransformMatrix,worldColor:r||o.worldColor,offset:i||o.offset,bindGroup:null},c=this._uniformsPool.pop()||this._createUniforms();this._activeUniforms.push(c);let l=c.uniforms;l.uProjectionMatrix=s.projectionMatrix,l.uResolution=s.resolution,l.uWorldTransformMatrix.copyFrom(s.worldTransformMatrix),l.uWorldTransformMatrix.tx-=s.offset.x,l.uWorldTransformMatrix.ty-=s.offset.y,Tt(s.worldColor,l.uWorldColorAlpha,0),c.update();let u;this._renderer.renderPipes.uniformBatch?u=this._renderer.renderPipes.uniformBatch.getUniformBindGroup(c,!1):(u=this._bindGroupPool.pop()||new te,this._activeBindGroups.push(u),u.setResource(c,0)),s.bindGroup=u,this._currentGlobalUniformData=s}push(e){this.bind(e),this._globalUniformDataStack[this._stackIndex++]=this._currentGlobalUniformData}pop(){this._currentGlobalUniformData=this._globalUniformDataStack[--this._stackIndex-1],this._renderer.type===E.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 S({uProjectionMatrix:{value:new T,type:`mat3x3<f32>`},uWorldTransformMatrix:{value:new T,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}};sn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`globalUniforms`};var cn=1,ln=class{constructor(){this._tasks=[],this._offset=0}init(){fe.system.add(this._update,this)}repeat(e,t,n=!0){let r=cn++,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(){fe.system.remove(this._update,this),this._tasks.length=0}};ln.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`scheduler`,priority:0};var un=!1;function dn(e){if(!un){if(O.get().getNavigator().userAgent.toLowerCase().indexOf(`chrome`)>-1){let t=[`%c %c %c %c %c PixiJS %c v${N} (${e}) http://www.pixijs.com/
403
-
404
- `,`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 ${N} - ${e} - http://www.pixijs.com/`);un=!0}}var fn=class{constructor(e){this._renderer=e}init(e){if(e.hello){let e=this._renderer.name;this._renderer.type===E.WEBGL&&(e+=` ${this._renderer.context.webGLVersion}`),dn(e)}}};fn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`hello`,priority:-2},fn.defaultOptions={hello:!1};var pn=class e{constructor(e){this._renderer=e}init(t){t={...e.defaultOptions,...t},this.maxUnusedTime=t.renderableGCMaxUnusedTime}get enabled(){return s(`8.15.0`,`RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead.`),this._renderer.gc.enabled}set enabled(e){s(`8.15.0`,`RenderableGCSystem.enabled is deprecated, please use the GCSystem.enabled instead.`),this._renderer.gc.enabled=e}addManagedHash(e,t){s(`8.15.0`,`RenderableGCSystem.addManagedHash is deprecated, please use the GCSystem.addCollection instead.`),this._renderer.gc.addCollection(e,t,`hash`)}addManagedArray(e,t){s(`8.15.0`,`RenderableGCSystem.addManagedArray is deprecated, please use the GCSystem.addCollection instead.`),this._renderer.gc.addCollection(e,t,`array`)}addRenderable(e){s(`8.15.0`,`RenderableGCSystem.addRenderable is deprecated, please use the GCSystem instead.`),this._renderer.gc.addResource(e,`renderable`)}run(){s(`8.15.0`,`RenderableGCSystem.run is deprecated, please use the GCSystem instead.`),this._renderer.gc.run()}destroy(){this._renderer=null}};pn.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`renderableGC`,priority:0},pn.defaultOptions={renderableGCActive:!0,renderableGCMaxUnusedTime:6e4,renderableGCFrequency:3e4};var mn=pn,hn=class e{get count(){return this._renderer.tick}get checkCount(){return this._checkCount}set checkCount(e){s(`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){s(`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){s(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`)}get active(){return this._renderer.gc.enabled}set active(e){s(`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(){s(`8.15.0`,`TextureGCSystem.run is deprecated, please use the GCSystem instead.`),this._renderer.gc.run()}destroy(){this._renderer=null}};hn.extension={type:[b.WebGLSystem,b.WebGPUSystem],name:`textureGC`},hn.defaultOptions={textureGCActive:!0,textureGCAMaxIdle:null,textureGCMaxIdle:3600,textureGCCheckCountMax:600};var gn=hn,_n=class e extends le{constructor(e={}){super(),this.uid=d(`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 a({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 s=n.depthStencilTexture===!0;if(this._depth=!!(n.depth||s),this._stencil=!!(n.stencil||s),n.depthStencilTexture instanceof o||n.depthStencilTexture instanceof a){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(s&&!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 a({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}};_n.defaultOptions={width:0,height:0,resolution:1,colorTextures:1,stencil:!1,depth:!1,antialias:!1,isRoot:!1};var Z=_n,Q=new Map;f.register(Q);function vn(e,t){if(!Q.has(e)){let n=new o({source:new x({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 t{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(n){n={...t.defaultOptions,...n},n.view&&(s(v,`ViewSystem.view has been renamed to ViewSystem.canvas`),n.canvas=n.view),this.screen=new e(0,0,n.width,n.height),this.canvas=n.canvas||O.get().createCanvas(),this.antialias=!!n.antialias;let{depth:r,...i}=n;!i.format&&this._renderer.type===E.WEBGPU&&(i.format=O.get().getNavigator().gpu.getPreferredCanvasFormat()),this.texture=vn(this.canvas,i),this.renderTarget=new Z({colorTextures:[this.texture],depth:!!r,isRoot:!0}),this.texture.source.transparent=n.backgroundAlpha<1,this.texture.source.on(`resize`,this._updateScreenSize,this),this.resolution=n.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),r.removeScreen(this._renderer.uid),de.removeScreen(this._renderer.uid),this.texture.destroy()}_updateScreenSize(){let{pixelWidth:e,pixelHeight:t}=this.texture.source,n=this._renderer.uid;r.setScreenSize(n,e,t,this.resolution),de.setScreenSize(n,e,t)}};$.extension={type:[b.WebGLSystem,b.WebGPUSystem,b.CanvasSystem],name:`view`,priority:0},$.defaultOptions={width:800,height:600,autoDensity:!1,antialias:!1};var yn=[qt,sn,fn,$,Gt,on,gn,tn,Xt,be,mn,ln],bn=[Ft,q,Pt,Nt,J,At,kt,jt];function xn(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 Sn(e){if(e.colorAttachments.length===0)return!1;let t=e.colorTexture.resource;return globalThis.HTMLCanvasElement&&t instanceof HTMLCanvasElement&&document.body.contains(t)}var Cn=class{constructor(t){this.rootViewPort=new e,this.viewport=new e,this.onRenderTargetChange=new he(`onRenderTargetChange`),this.projectionMatrix=new T,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 e,this._renderer=t,t.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=Sn(this.rootRenderTarget),this.adaptor.prerender?.(this.rootRenderTarget)}postrender(){this.adaptor.postrender?.(this.rootRenderTarget)}bind(e,t=!0,n,r,i=0,a=0,c){let l;`target`in e?l=e:(s(`8.20.0`,`RenderTargetSystem.bind: positional arguments are deprecated, please use an options object instead: bind({ target, clear, clearColor, frame, mipLevel, layer, flipY })`),l={target:e,clear:t,clearColor:n,frame:r,mipLevel:i,layer:a,flipY:c});let u=l.target;t=l.clear??!0,n=l.clearColor,i=(l.mipLevel??0)|0,a=(l.layer??0)|0,c=l.flipY,r=l.frame;let d=this.getRenderTarget(u),f=this.renderTarget!==d||!!d.flipY!=!!c;this.renderTarget=d;let p=this.getGpuRenderTarget(d);(d.pixelWidth!==p.width||d.pixelHeight!==p.height)&&(this.adaptor.resizeGpuRenderTarget(d),p.width=d.pixelWidth,p.height=d.pixelHeight);let m=d.colorAttachments[0]?.texture||d.depthStencilAttachment?.texture,h=this.viewport,g=m.dimension===`3d`?Math.max(m.depth>>i,1):m.depthOrArrayLayers;if(a<0||a>=g)throw Error(`[RenderTargetSystem] layer ${a} is out of bounds (layer count=${g}).`);let _=this._bindState;_.target=u,_.frame=r?this._bindFrame.copyFrom(r):void 0,_.mipLevel=i,_.layer=a,_.flipY=c;let v=Math.max(m.pixelWidth>>i,1),y=Math.max(m.pixelHeight>>i,1);if(!r&&u instanceof o&&(r=u.frame),r){let e=m._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,v-1),l=Math.min(l,y-1),u=Math.min(u,v-c),d=Math.min(d,y-l),u=Math.max(u,1),d=Math.max(d,1),h.x=c,h.y=l,h.width=u,h.height=d}else h.x=0,h.y=0,h.width=v,h.height=y;return d.flipY=c,xn(this.projectionMatrix,0,0,h.width/m.resolution,h.height/m.resolution,!d.isRoot!=!!d.flipY),this.adaptor.startRenderPass(d,t,n,h,i,a),f&&this.onRenderTargetChange.emit(d),d}getBindState(e){if(!this.renderTarget)throw Error(`[RenderTargetSystem] getBindState is only valid while a render surface is bound`);let t=this._bindState;return e??={},e.target=t.target,e.clear=M.NONE,e.clearColor=void 0,t.frame?e.frame?e.frame.copyFrom(t.frame):e.frame=t.frame.clone():e.frame=void 0,e.mipLevel=t.mipLevel,e.layer=t.layer,e.flipY=!!t.flipY,e}isFrontFaceInverted(e,t){if(!e){if(e=this.renderTarget,!e)return!1;t=e.flipY}return!!t!=(this._renderer.type===E.WEBGL&&!e.isRoot)}get frontFaceInverted(){return s(_,`RenderTargetSystem.frontFaceInverted is deprecated, use isFrontFaceInverted() instead`),this.isFrontFaceInverted()}clear(e,t=M.ALL,n,r=this.mipLevel,i=this.layer){t&&(e&&=this.getRenderTarget(e),this.adaptor.clear(e||this.renderTarget,t,n,this.viewport,r,i))}contextChange(){this._gpuRenderTargetHash=Object.create(null)}push(e,t=M.ALL,n,r,i=0,a=0,o){let c;`target`in e?c=e:(s(`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:t,clearColor:n,frame:r,mipLevel:i,layer:a,flipY:o});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){k(`[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`)){k(`[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){k(`[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(x.test(e)&&(e=vn(e).source),e instanceof Z)t=e,e.once(`destroy`,this._onRenderTargetDestroy,this);else if(e instanceof a){let n=e.format;t=n.includes(`depth`)||n.includes(`stencil`)?new Z({colorTextures:0,depthStencilTexture:e}):new Z({colorTextures:[e]}),e.source instanceof x&&(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=>se(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{F as C,M as D,ve as E,me as O,Ee as S,ye as T,pt as _,Pt as a,ot as b,J as c,bt as d,G as f,dt as g,ht as h,Ft as i,q as l,mt as m,bn as n,Nt as o,_t as p,yn as r,jt as s,Cn as t,Tt as u,st as v,P as w,at as x,ct as y};
@@ -1 +0,0 @@
1
- import{B as e,G as t,at as n,et as r,x as i}from"./CanvasPool-CHSHS1-v.js";var a=class extends t{constructor(e){super(e),this.uploadMethodId=`image`,this.autoGarbageCollect=!0}static test(e){return globalThis.HTMLImageElement&&e instanceof HTMLImageElement||typeof ImageBitmap<`u`&&e instanceof ImageBitmap||globalThis.VideoFrame&&e instanceof VideoFrame}};a.extension=n.TextureSource;var o;function s(e){let t=i.get().createCanvas(6,1),n=t.getContext(`2d`);return n.fillStyle=e,n.fillRect(0,0,6,1),t}function c(){if(o!==void 0)return o;try{let e=s(`#ff00ff`),t=s(`#ffff00`),n=i.get().createCanvas(6,1).getContext(`2d`);n.globalCompositeOperation=`multiply`,n.drawImage(e,0,0),n.drawImage(t,2,0);let r=n.getImageData(2,0,1,1);if(!r)o=!1;else{let e=r.data;o=e[0]===255&&e[1]===0&&e[2]===0}}catch{o=!1}return o}var l={canvas:null,convertTintToImage:!1,cacheStepsPerColorChannel:8,_canUseMultiply:void 0,get canUseMultiply(){return this._canUseMultiply??=c()},set canUseMultiply(e){this._canUseMultiply=e},_tintMethod:null,get tintMethod(){return this._tintMethod??=this.canUseMultiply?this.tintWithMultiply:this.tintWithPerPixel},set tintMethod(e){this._tintMethod=e},_canvasSourceCache:new WeakMap,_unpremultipliedCache:new WeakMap,getCanvasSource:e=>{let t=e.source,n=t?.resource;if(!n)return null;let r=t.alphaMode===`premultiplied-alpha`,a=t.resourceWidth??t.pixelWidth,o=t.resourceHeight??t.pixelHeight,s=a!==t.pixelWidth||o!==t.pixelHeight;if(r){if((n instanceof HTMLCanvasElement||typeof OffscreenCanvas<`u`&&n instanceof OffscreenCanvas)&&!s)return n;let e=l._unpremultipliedCache.get(t);if(e?.resourceId===t._resourceId)return e.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){let e=l._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;let r=i.get().createCanvas(t.pixelWidth,t.pixelHeight),a=r.getContext(`2d`),o=a.createImageData(t.pixelWidth,t.pixelHeight),s=o.data,c=n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength);if(t.format===`bgra8unorm`)for(let e=0;e<s.length&&e+3<c.length;e+=4)s[e]=c[e+2],s[e+1]=c[e+1],s[e+2]=c[e],s[e+3]=c[e+3];else s.set(c.subarray(0,s.length));return a.putImageData(o,0,0),l._canvasSourceCache.set(t,{canvas:r,resourceId:t._resourceId}),r}if(r){let e=i.get().createCanvas(t.pixelWidth,t.pixelHeight),r=e.getContext(`2d`,{willReadFrequently:!0});e.width=t.pixelWidth,e.height=t.pixelHeight,r.drawImage(n,0,0);let a=r.getImageData(0,0,e.width,e.height),o=a.data;for(let e=0;e<o.length;e+=4){let t=o[e+3];if(t>0){let n=255/t;o[e]=Math.min(255,o[e]*n+.5),o[e+1]=Math.min(255,o[e+1]*n+.5),o[e+2]=Math.min(255,o[e+2]*n+.5)}}return r.putImageData(a,0,0),l._unpremultipliedCache.set(t,{canvas:e,resourceId:t._resourceId}),e}if(s){let e=l._canvasSourceCache.get(t);if(e?.resourceId===t._resourceId)return e.canvas;let r=i.get().createCanvas(t.pixelWidth,t.pixelHeight),a=r.getContext(`2d`);return r.width=t.pixelWidth,r.height=t.pixelHeight,a.drawImage(n,0,0),l._canvasSourceCache.set(t,{canvas:r,resourceId:t._resourceId}),r}return n},getTintedCanvas:(t,n)=>{let r=t.texture,a=e.shared.setValue(n).toHex(),o=r.tintCache||={},s=o[a],c=r.source._resourceId;if(s?.tintId===c)return s;let u=s&&`getContext`in s?s:i.get().createCanvas();if(l.tintMethod(r,n,u),u.tintId=c,l.convertTintToImage&&u.toDataURL!==void 0){let e=i.get().createImage();e.src=u.toDataURL(),e.tintId=c,o[a]=e}else o[a]=u;return o[a]},getTintedPattern:(t,n)=>{let r=e.shared.setValue(n).toHex(),a=t.patternCache||={},o=t.source._resourceId,s=a[r];return s?.tintId===o||(l.canvas||=i.get().createCanvas(),l.tintMethod(t,n,l.canvas),s=l.canvas.getContext(`2d`).createPattern(l.canvas,`repeat`),s.tintId=o,a[r]=s),s},applyPatternTransform:(e,t,n=!0)=>{if(!t)return;let r=e;if(!r.setTransform)return;let i=globalThis.DOMMatrix;if(!i)return;let a=new i([t.a,t.b,t.c,t.d,t.tx,t.ty]);r.setTransform(n?a.inverse():a)},tintWithMultiply:(t,n,i)=>{let a=i.getContext(`2d`),o=t.frame.clone(),s=t.source._resolution??t.source.resolution??1,c=t.rotate;o.x*=s,o.y*=s,o.width*=s,o.height*=s;let u=r.isVertical(c),d=u?o.height:o.width,f=u?o.width:o.height;i.width=Math.ceil(d),i.height=Math.ceil(f),a.save(),n!==16777215&&(a.fillStyle=e.shared.setValue(n).toHex(),a.fillRect(0,0,d,f),a.globalCompositeOperation=`multiply`);let p=l.getCanvasSource(t);p&&(c&&l._applyInverseRotation(a,c,o.width,o.height),a.drawImage(p,o.x,o.y,o.width,o.height,0,0,o.width,o.height),n!==16777215&&(a.globalCompositeOperation=`destination-atop`,a.drawImage(p,o.x,o.y,o.width,o.height,0,0,o.width,o.height))),a.restore()},tintWithOverlay:(t,n,i)=>{let a=i.getContext(`2d`),o=t.frame.clone(),s=t.source._resolution??t.source.resolution??1,c=t.rotate;o.x*=s,o.y*=s,o.width*=s,o.height*=s;let u=r.isVertical(c),d=u?o.height:o.width,f=u?o.width:o.height;i.width=Math.ceil(d),i.height=Math.ceil(f),a.save(),a.globalCompositeOperation=`copy`,a.fillStyle=e.shared.setValue(n).toHex(),a.fillRect(0,0,d,f),a.globalCompositeOperation=`destination-atop`;let p=l.getCanvasSource(t);p&&(c&&l._applyInverseRotation(a,c,o.width,o.height),a.drawImage(p,o.x,o.y,o.width,o.height,0,0,o.width,o.height)),a.restore()},tintWithPerPixel:(e,t,n)=>{let i=n.getContext(`2d`),a=e.frame.clone(),o=e.source._resolution??e.source.resolution??1,s=e.rotate;a.x*=o,a.y*=o,a.width*=o,a.height*=o;let c=r.isVertical(s),u=c?a.height:a.width,d=c?a.width:a.height;n.width=Math.ceil(u),n.height=Math.ceil(d),i.save(),i.globalCompositeOperation=`copy`;let f=l.getCanvasSource(e);if(!f){i.restore();return}s&&l._applyInverseRotation(i,s,a.width,a.height),i.drawImage(f,a.x,a.y,a.width,a.height,0,0,a.width,a.height),i.restore();let p=t>>16&255,m=t>>8&255,h=t&255,g=i.getImageData(0,0,u,d),_=g.data;for(let e=0;e<_.length;e+=4)_[e]=_[e]*p/255,_[e+1]=_[e+1]*m/255,_[e+2]=_[e+2]*h/255;i.putImageData(g,0,0)},_applyInverseRotation:(e,t,n,i)=>{let a=r.inv(t),o=r.uX(a),s=r.uY(a),c=r.vX(a),l=r.vY(a),u=-Math.min(0,o*n,c*i,o*n+c*i),d=-Math.min(0,s*n,l*i,s*n+l*i);e.transform(o,s,c,l,u,d)}};export{c as n,a as r,l as t};
@@ -1 +0,0 @@
1
- import{H as e,d as t}from"./CanvasPool-CHSHS1-v.js";var n={};function r(e,t,r){let a=2166136261;for(let n=0;n<t;n++)a^=e[n].uid,a=Math.imul(a,16777619),a>>>=0;return n[a]||i(e,t,a,r)}function i(r,i,a,o){let s={},c=0;for(let t=0;t<o;t++){let n=t<i?r[t]:e.EMPTY.source;s[c++]=n.source,s[c++]=n.style}let l=new t(s);return n[a]=l,l}export{r as t};