modern-canvas 0.2.4 → 0.2.5
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/dist/index.cjs +0 -2
- package/dist/index.d.cts +3 -3
- package/dist/index.d.mts +3 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +0 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -6568,8 +6568,6 @@ var __decorateClass$B = (decorators, target, key, kind) => {
|
|
|
6568
6568
|
return result;
|
|
6569
6569
|
};
|
|
6570
6570
|
exports.Effect = class Effect extends exports.TimelineNode {
|
|
6571
|
-
material;
|
|
6572
|
-
effectMode;
|
|
6573
6571
|
get _effectMode() {
|
|
6574
6572
|
return this.effectMode ?? "parent";
|
|
6575
6573
|
}
|
package/dist/index.d.cts
CHANGED
|
@@ -2669,9 +2669,9 @@ declare class Scaler extends Node {
|
|
|
2669
2669
|
}
|
|
2670
2670
|
|
|
2671
2671
|
declare class KawaseTransition extends Transition {
|
|
2672
|
-
static material: Material;
|
|
2673
2672
|
blur: number;
|
|
2674
2673
|
quality: number;
|
|
2674
|
+
static material: Material;
|
|
2675
2675
|
apply(renderer: WebGLRenderer, target: Viewport): void;
|
|
2676
2676
|
}
|
|
2677
2677
|
|
|
@@ -2681,18 +2681,18 @@ declare class LeftEraseTransition extends Transition {
|
|
|
2681
2681
|
}
|
|
2682
2682
|
|
|
2683
2683
|
declare class TiltShiftTransition extends Transition {
|
|
2684
|
-
static material: Material;
|
|
2685
2684
|
blur: number;
|
|
2686
2685
|
gradientBlur: number;
|
|
2686
|
+
static material: Material;
|
|
2687
2687
|
apply(renderer: WebGLRenderer, target: Viewport): void;
|
|
2688
2688
|
}
|
|
2689
2689
|
|
|
2690
2690
|
declare class TwistTransition extends Transition {
|
|
2691
|
-
static material: Material;
|
|
2692
2691
|
radius?: number;
|
|
2693
2692
|
angle: number;
|
|
2694
2693
|
padding: number;
|
|
2695
2694
|
offset?: number;
|
|
2695
|
+
static material: Material;
|
|
2696
2696
|
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2697
2697
|
}
|
|
2698
2698
|
|
package/dist/index.d.mts
CHANGED
|
@@ -2669,9 +2669,9 @@ declare class Scaler extends Node {
|
|
|
2669
2669
|
}
|
|
2670
2670
|
|
|
2671
2671
|
declare class KawaseTransition extends Transition {
|
|
2672
|
-
static material: Material;
|
|
2673
2672
|
blur: number;
|
|
2674
2673
|
quality: number;
|
|
2674
|
+
static material: Material;
|
|
2675
2675
|
apply(renderer: WebGLRenderer, target: Viewport): void;
|
|
2676
2676
|
}
|
|
2677
2677
|
|
|
@@ -2681,18 +2681,18 @@ declare class LeftEraseTransition extends Transition {
|
|
|
2681
2681
|
}
|
|
2682
2682
|
|
|
2683
2683
|
declare class TiltShiftTransition extends Transition {
|
|
2684
|
-
static material: Material;
|
|
2685
2684
|
blur: number;
|
|
2686
2685
|
gradientBlur: number;
|
|
2686
|
+
static material: Material;
|
|
2687
2687
|
apply(renderer: WebGLRenderer, target: Viewport): void;
|
|
2688
2688
|
}
|
|
2689
2689
|
|
|
2690
2690
|
declare class TwistTransition extends Transition {
|
|
2691
|
-
static material: Material;
|
|
2692
2691
|
radius?: number;
|
|
2693
2692
|
angle: number;
|
|
2694
2693
|
padding: number;
|
|
2695
2694
|
offset?: number;
|
|
2695
|
+
static material: Material;
|
|
2696
2696
|
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2697
2697
|
}
|
|
2698
2698
|
|
package/dist/index.d.ts
CHANGED
|
@@ -2669,9 +2669,9 @@ declare class Scaler extends Node {
|
|
|
2669
2669
|
}
|
|
2670
2670
|
|
|
2671
2671
|
declare class KawaseTransition extends Transition {
|
|
2672
|
-
static material: Material;
|
|
2673
2672
|
blur: number;
|
|
2674
2673
|
quality: number;
|
|
2674
|
+
static material: Material;
|
|
2675
2675
|
apply(renderer: WebGLRenderer, target: Viewport): void;
|
|
2676
2676
|
}
|
|
2677
2677
|
|
|
@@ -2681,18 +2681,18 @@ declare class LeftEraseTransition extends Transition {
|
|
|
2681
2681
|
}
|
|
2682
2682
|
|
|
2683
2683
|
declare class TiltShiftTransition extends Transition {
|
|
2684
|
-
static material: Material;
|
|
2685
2684
|
blur: number;
|
|
2686
2685
|
gradientBlur: number;
|
|
2686
|
+
static material: Material;
|
|
2687
2687
|
apply(renderer: WebGLRenderer, target: Viewport): void;
|
|
2688
2688
|
}
|
|
2689
2689
|
|
|
2690
2690
|
declare class TwistTransition extends Transition {
|
|
2691
|
-
static material: Material;
|
|
2692
2691
|
radius?: number;
|
|
2693
2692
|
angle: number;
|
|
2694
2693
|
padding: number;
|
|
2695
2694
|
offset?: number;
|
|
2695
|
+
static material: Material;
|
|
2696
2696
|
apply(renderer: WebGLRenderer, source: Viewport): void;
|
|
2697
2697
|
}
|
|
2698
2698
|
|
package/dist/index.js
CHANGED
|
@@ -102,7 +102,7 @@ uniform sampler2D sampler;
|
|
|
102
102
|
uniform vec4 tint;
|
|
103
103
|
void main(void) {
|
|
104
104
|
gl_FragColor = texture2D(sampler, vUv) * tint;
|
|
105
|
-
}`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}u(ir,"_instance");class J extends fi{static get instance(){return this._instance??(this._instance=new this)}static draw(r,e=ir.instance,t){this.instance.draw(r,e,t)}constructor(){super({vertexAttributes:{position:new je({buffer:new vt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new je({buffer:new vt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new rr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(J,"_instance");class lc extends fi{constructor(){const e=new vt({data:new Float32Array,dynamic:!0}),t=new vt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new je({buffer:e,size:2,normalized:!1,type:"float"}),uv:new je({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new rr({data:new Uint16Array,dynamic:!0})});u(this,"positionBuffer");u(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}update(e,t,i){return this.positionBuffer.data=e,this.uvBuffer.data=t,this.indexBuffer.data=i,this}}function hc(){return{shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0}}function $o(){return{left:0,top:0,width:0,height:0,rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function cc(){return{overflow:"visible",visibility:"visible",filter:"none",opacity:1,marginLeft:0,marginTop:0,marginRight:0,marginBottom:0,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,...$o(),backgroundImage:"none",backgroundColor:"transparent",...hc(),borderRadius:0,borderColor:"transparent",borderWidth:1}}function zo(){return{writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"black",color:"black",listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside",highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function uc(){return{...cc(),...zo()}}var fc=Object.defineProperty,_e=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&fc(r,e,i),i};const Vo={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};class ne extends yt{constructor(e){super();u(this,"_backgroundColor",new Ct);this.setProperties(e)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"backgroundColor":this._backgroundColor.value=this.backgroundColor==="none"?void 0:this.backgroundColor;break}}canPointeEvents(){return this.pointerEvents!=="none"}getComputedOpacity(){return at(0,this.opacity,1)}getComputedBackgroundColor(){return this._backgroundColor}async loadBackgroundImage(){if(this.backgroundImage!=="none")return await Pt.texture.load(this.backgroundImage)}getComputedTransform(){const{scaleX:e,scaleY:t,left:i,top:s,width:o,height:a,rotate:l}=this,h=new et,c=new et(!1),f=new et(!1).scale(e,t).translate(i,s).rotate(l*qn);let p=this.transform;(!p||p==="none")&&(p=""),yr(p,{width:o,height:a}).forEach(({name:S,args:w})=>{const v=w.map(x=>x.normalizedIntValue);switch(h.identity(),S){case"translate":h.translate(v[0]*o,(v[1]??v[0])*this.height);break;case"translateX":h.translateX(v[0]*o);break;case"translateY":h.translateY(v[0]*a);break;case"translateZ":h.translateZ(v[0]);break;case"translate3d":h.translate3d(v[0]*o,(v[1]??v[0])*a,v[2]??v[1]??v[0]);break;case"scale":h.scale(v[0],v[1]??v[0]);break;case"scaleX":h.scaleX(v[0]);break;case"scaleY":h.scaleY(v[0]);break;case"scale3d":h.scale3d(v[0],v[1]??v[0],v[2]??v[1]??v[0]);break;case"rotate":h.rotate(v[0]*le);break;case"rotateX":h.rotateX(v[0]*le);break;case"rotateY":h.rotateY(v[0]*le);break;case"rotateZ":h.rotateZ(v[0]*le);break;case"rotate3d":h.rotate3d(v[0]*le,(v[1]??v[0])*le,(v[2]??v[1]??v[0])*le,(v[3]??v[2]??v[1]??v[0])*le);break;case"skew":h.skew(v[0],v[0]??v[1]);break;case"skewX":h.skewX(v[0]);break;case"skewY":h.skewY(v[0]);break;case"matrix":h.set(v);break}c.multiply(h)}),f.update(),c.update();const m=f.toArray(),g=c.toArray(),_=[g[0]*m[0]+g[3]*m[1],g[1]*m[0]+g[4]*m[1],g[2]*m[0]+g[5]*m[1]+m[2],g[0]*m[3]+g[3]*m[4],g[1]*m[3]+g[4]*m[4],g[2]*m[3]+g[5]*m[4]+m[5],0,0,1],[y,E]=this.getComputedTransformOrigin(),T=y*o,P=E*a;return _[2]+=_[0]*-T+_[1]*-P+T,_[5]+=_[3]*-T+_[4]*-P+P,new et().set(_)}getComputedTransformOrigin(){const[e,t=e]=this.transformOrigin.split(" ");return[e,t].map(i=>{switch(i=i.trim(),i){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(i)}})}getComputedFilter(){let e={};return this.filter==="none"||(e=yr(this.filter).reduce((t,{name:i,args:s})=>(t[i]=s[0].normalizedIntValue,t),e),Object.keys(Vo).forEach(t=>{e[t]=e[t]??Vo[t]})),e}getComputedFilterColorMatrix(){const e=new us,t=this.getComputedFilter();for(const i in t){const s=t[i];switch(i){case"hue-rotate":e.hueRotate(s*le);break;case"saturate":e.saturate(s);break;case"brightness":e.brightness(s);break;case"contrast":e.contrast(s);break;case"invert":e.invert(s);break;case"sepia":e.sepia(s);break;case"opacity":e.opacity(s);break;case"grayscale":e.grayscale(s);break}}return e}}_e([M({default:"none"})],ne.prototype,"backgroundColor"),_e([M({default:"none"})],ne.prototype,"backgroundImage"),_e([M({default:"none"})],ne.prototype,"filter"),_e([M({default:"inherit"})],ne.prototype,"direction"),_e([M({default:"none"})],ne.prototype,"boxShadow"),_e([M({default:"none"})],ne.prototype,"maskImage"),_e([M({default:1})],ne.prototype,"opacity"),_e([M({default:0})],ne.prototype,"borderWidth"),_e([M({default:0})],ne.prototype,"borderRadius"),_e([M({default:"#000000"})],ne.prototype,"borderColor"),_e([M({default:"none"})],ne.prototype,"borderStyle"),_e([M({default:0})],ne.prototype,"outlineWidth"),_e([M({default:0})],ne.prototype,"outlineOffset"),_e([M({default:"#000000"})],ne.prototype,"outlineColor"),_e([M({default:"none"})],ne.prototype,"outlineStyle"),_e([M({default:"visible"})],ne.prototype,"visibility"),_e([M({default:"visible"})],ne.prototype,"overflow"),_e([M({default:"auto"})],ne.prototype,"pointerEvents");const jo=$o();for(const n in jo)vr(ne,n,{default:jo[n]});const Go=zo();for(const n in Go)vr(ne,n,{default:Go[n]});var dc=Object.defineProperty,sr=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&dc(r,e,i),i};class ge extends yt{constructor(e){super();u(this,"_isPowerOfTwo",!1);u(this,"_needsUpload",!1);this.source=e,this._updateSize()}static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}_glTextureOptions(e,t){let i=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(i="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:i,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=Zi(this.realWidth)&&Zi(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.valid?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.valid?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){_n&&this.source instanceof ImageBitmap&&this.source.close()}}sr([ue()],ge.prototype,"source"),sr([M({default:0})],ge.prototype,"width"),sr([M({default:0})],ge.prototype,"height"),sr([M({default:"linear"})],ge.prototype,"filterMode"),sr([M({default:"clamp_to_edge"})],ge.prototype,"wrapMode"),sr([M({default:1})],ge.prototype,"pixelRatio");var pc=Object.defineProperty,gc=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&pc(r,e,i),i};class Er extends ge{constructor(r=document.createElement("canvas")){super(r)}_updateProperty(r,e,t,i){switch(r){case"width":this.source.width=Math.max(1,Math.ceil(e*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(e*this.pixelRatio));break}super._updateProperty(r,e,t,i)}}gc([M({default:2})],Er.prototype,"pixelRatio");class Ss extends ge{constructor(r){const e=new Ct(r);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function mc(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),useBitmap:!!((n==null?void 0:n.useBitmap)??!0)&&Ji,crossorigin:(n==null?void 0:n.crossorigin)??null}}class yc extends ge{constructor(e,t){const i=mc(t);super(e);u(this,"bitmap");u(this,"useBitmap");u(this,"preserveBitmap",!1);u(this,"_loadSource");u(this,"_loadBitmap");const s=e.src,o=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!o,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,i=()=>{t.onload=null,t.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},o=a=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,a),this.emit("error",a),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=o)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Ji)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(_r&&i instanceof HTMLImageElement&&(!i.complete||i.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Es extends ge{constructor(r,e=1,t=1){const i={width:e,height:t,pixels:null};r&&(ArrayBuffer.isView(r)?i.pixels=new Uint8Array(r.buffer):i.pixels=new Uint8Array(r)),super(i)}_updateProperty(r,e,t,i){switch(r){case"width":this.source.width=Math.round(e*this.pixelRatio);break;case"height":this.source.height=Math.round(e*this.pixelRatio);break}super._updateProperty(r,e,t,i)}}var _c=Object.defineProperty,qo=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&_c(r,e,i),i};function vc(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),autoPlay:!!((n==null?void 0:n.autoPlay)??!1),fps:Number((n==null?void 0:n.fps)??0),crossorigin:(n==null?void 0:n.crossorigin)??null,loop:!!((n==null?void 0:n.loop)??!1),muted:!!((n==null?void 0:n.muted)??!1),playsinline:!!((n==null?void 0:n.playsinline)??!0)}}const Ms=(Xt=class extends ge{constructor(e,t){const i=vc(t);if(!Cn(e)){typeof e=="string"&&(e=[e]);const s=e[0].src||e[0],o=document.createElement("video");i.autoLoad&&o.setAttribute("preload","auto"),i.playsinline&&(o.setAttribute("webkit-playsinline",""),o.setAttribute("playsinline","")),i.muted&&(o.setAttribute("muted",""),o.muted=!0),i.loop&&o.setAttribute("loop",""),i.autoPlay&&o.setAttribute("autoplay",""),An(o,s,i.crossorigin);for(let a=0;a<e.length;++a){let{src:l,mime:h}=e[a];if(l=l||e[a],l.startsWith("data:"))h=l.slice(5,l.indexOf(";"));else if(!l.startsWith("blob:")){const f=l.split("?").shift().toLowerCase(),p=f.slice(f.lastIndexOf(".")+1);h=h||Xt.mimeTypes.get(p)||`video/${p}`}const c=document.createElement("source");c.src=l,h&&(c.type=h),o.appendChild(c)}e=o}super(e);u(this,"_spf",0);u(this,"_autoPlay",!1);u(this,"_sourceLoad");u(this,"_nextTime",0);u(this,"_connected",!1);u(this,"_requestId");u(this,"_resolve");u(this,"_reject");u(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});u(this,"_onPlayStop",()=>{this._setupAutoUpdate()});u(this,"_onCanPlay",()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()});u(this,"_onError",e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)});u(this,"_onSeeked",()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)});u(this,"_videoFrameRequestCallback",()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)});u(this,"requestUpload",()=>{const e=Math.floor(fe.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)});this.fps=i.fps,this._autoPlay=i.autoPlay,i.autoPlay&&this.load(),this._setupAutoUpdate()}get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(e){this.source.currentTime=e}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(fe.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(fe.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(fe.off(this.requestUpload),this._connected=!1,this._nextTime=0))}async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,i)=>{this.valid?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=i,e.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}},u(Xt,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),Xt);qo([ue({default:!0})],Ms.prototype,"autoUpdate"),qo([ue({default:0})],Ms.prototype,"fps");let Wo=Ms;class As extends Es{}class Xo extends Pe{constructor(){super(...arguments);u(this,"textureTransform");u(this,"fillStyle");u(this,"strokeStyle");u(this,"lineCap");u(this,"lineJoin");u(this,"lineWidth");u(this,"miterLimit");u(this,"_defaultStyle",ge.EMPTY);u(this,"_stroke",[]);u(this,"_fille",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof ge?e=this.strokeStyle:e=new Ss(this.strokeStyle)),this.curves.length&&(this._stroke.push({path:new Pe(this),texture:e,textureTransform:this.textureTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this.currentCurve=new tr,this.curves=[this.currentCurve])}fillRect(e,t,i,s){this.rect(e,t,i,s).fill()}strokeRect(e,t,i,s){this.rect(e,t,i,s).stroke()}fill(){let e=this._defaultStyle;this.fillStyle&&(this.fillStyle instanceof ge?e=this.fillStyle:e=new Ss(this.fillStyle)),this._fille.push({path:new Pe(this),texture:e,textureTransform:this.textureTransform}),this.currentCurve=new tr,this.curves=[this.currentCurve]}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.textureTransform=e.textureTransform,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._stroke=e._stroke.slice(),this._fille=e._fille.slice(),this}reset(){return super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.textureTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this._stroke.length=0,this._fille.length=0,this}buildUvs(e,t,i,s,o){if(s){let a=s.width,l=s.height;o&&([a,l]=o.applyToPoint(a,l));for(let h=t.length,c=e;c<h;c+=2)i.push(t[c]/a,t[c+1]/l)}else for(let a=t.length,l=e;l<a;l+=2)i.push(0,0)}toBatchables(){const e=[];let t=[],i=[],s=[],o=0,a;const l=c=>{e.push({type:c,vertices:t,indices:i,uvs:s,texture:a}),t=[],i=[],s=[],a=void 0};let h=t.length;for(let c=this._fille.length,f=0;f<c;f++){const p=this._fille[f];a??(a=p.texture),a!==p.texture&&l("fill"),o=t.length,p.path.fillTriangulate({vertices:t,indices:i}),this.buildUvs(o,t,s,p.texture,p.textureTransform)}t.length-h>0&&l("fill"),h=t.length;for(let c=this._stroke.length,f=0;f<c;f++){o=t.length;const p=this._stroke[f];a??(a=p.texture),p.path.strokeTriangulate({vertices:t,indices:i,lineStyle:p.style,flipAlignment:!1,closed:!0}),this.buildUvs(o,t,s,p.texture,p.textureTransform),l("stroke")}return t.length-h>0&&l("stroke"),e}}var bc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,nr=(n,r,e,t)=>{for(var i=t>1?void 0:t?wc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&bc(r,e,i),i};d.Node=class extends ti{constructor(e,t=[]){super();u(this,"name",`${this.tag}:${String(this.instanceId)}`);u(this,"mask");u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",[]);u(this,"_meta",new Map);this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties(e).append(t).on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}getName(){return this.name}setName(e){return this.name=e,this}get tree(){return this.getTree()}set tree(e){this.setTree(e)}getTree(){return this._tree}getViewport(){var e;return(e=this._tree)==null?void 0:e.getCurrentViewport()}getWindow(){var e;return(e=this._tree)==null?void 0:e.root}isInsideTree(){return!!this._tree}setTree(e){const t=this._tree;if(e!==t){e?(this._tree=e,this.emit("treeEnter",e)):t&&(this.emit("treeExit",t),this._tree=e);for(let i=this._children.length,s=0;s<i;s++){const o=this._children[s];!e&&this.emit("childExitingTree",o),o.setTree(e),e&&this.emit("childEnteredTree",o)}e&&(this.emit("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){var t;if(!((t=this._parent)!=null&&t.is(e))){const i=this._parent;this._parent=e,this.setTree(e==null?void 0:e._tree),e?this.emit("parented",e):i&&this.emit("unparented",i)}return this}get siblingIndex(){return this.getIndex()}set siblingIndex(e){var t;(t=this._parent)==null||t.moveChild(this,e)}get previousSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.getChildren();return e?e[e.length-1]:void 0}hasMeta(e){return this._meta.has(e)}getMeta(e,t){return this._meta.get(e)??t}setMeta(e,t){this._meta.set(e,t)}deleteMeta(e){this._meta.delete(e)}clearMeta(){this._meta.clear()}canProcess(){var e;if(!this._tree)return!1;switch(this.processMode){case"inherit":return((e=this._parent)==null?void 0:e.canProcess())??!0;case"pausable":return!this._tree.paused;case"when_paused":return this._tree.paused;case"always":return!0;case"disabled":default:return!1}}canRender(){var e;if(!this._tree)return!1;switch(this.renderMode){case"inherit":return((e=this._parent)==null?void 0:e.canRender())??!0;case"always":return!0;case"disabled":default:return!1}}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,i=this.canRender(),s=this.canProcess();s&&(t==null||t.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let o;if(i){const a=t.renderStack.push(this);o=t.renderStack.currentCall,t.renderStack.currentCall=a}if(this.mask instanceof d.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.addChild(this.mask,"front"));else{const a=this.getNode("__$mask");a&&this.removeChild(a)}for(let a=this._children.length,l=0;l<a;l++)this._children[l].emit("process",e);i&&(t.renderStack.currentCall=o),s&&(this.emit("processed",e),t==null||t.emit("nodeProcessed",this))}render(e,t){const i=this.mask;i&&(e.flush(),e.mask.push(this,i)),this._render(e),t==null||t(),i&&(e.flush(),e.mask.pop(this))}input(e,t){for(let i=this._children.length-1;i>=0;i--)this._children[i].input(e,t);this._input(e,t)}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t.internalMode==="default");default:return this._children.filter(t=>t.internalMode===e)}}getIndex(e=!1){var t;return((t=this._parent)==null?void 0:t.getChildren(e).indexOf(this))??0}getNode(e){return this._children.find(t=>t.name===e)}removeNode(e){var t;(t=this.getNode(e))==null||t.remove()}addSibling(e){return this.is(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex(!0)+1),this)}append(...e){let t;return Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.addChild(i)}),this}addChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return this;switch(t){case"default":case"front":{const i=t==="default"?"back":"front",s=this._children.findIndex(o=>o.internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case"back":this._children.push(e);break}return e.internalMode=t,e.setParent(this),this.emit("addChild",e),this}moveChild(e,t,i=e.internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;e.internalMode=i;const s=this._children.indexOf(e);let o=this._children.findIndex(h=>{switch(i){case"default":return h.internalMode!=="front";case"back":return h.internalMode==="back";case"front":default:return!0}});o=o>-1?o:Math.max(0,this._children.length-1);let a=this._children.slice(o).findIndex(h=>{switch(i){case"front":return h.internalMode!=="front";case"default":return h.internalMode==="back";case"back":default:return!1}});a=a>-1?o+a:Math.max(0,this._children.length-1);const l=at(o,t>-1?t:a,a);return l!==s&&(s>-1&&this._children.splice(s,1),e.setParent(this),l>-1&&l<this._children.length?this._children.splice(l,0,e):this._children.push(e),s>-1?this.emit("moveChild",e,l,s):this.emit("addChild",e)),this}removeChild(e){const t=e.getIndex(!0);return this.is(e.parent)&&t>-1&&(this._children.splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),this}removeChildren(){this.getChildren().forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEach(e){return this.getChildren().forEach(e),this}deepForEach(e){return this.getChildren().forEach(t=>{e(t),t.deepForEach(e)}),this}is(e){return!!(e&&this.instanceId===e.instanceId)}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}toJSON(){return{tag:this.tag,props:super.toJSON(),children:this.getChildren().map(e=>e.toJSON())}}static parse(e){if(Array.isArray(e))return e.map(l=>this.parse(l));const{tag:t,props:i,children:s}=e,o=ei.get(t)??d.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},nr([M()],d.Node.prototype,"name",2),nr([M()],d.Node.prototype,"mask",2),nr([M({default:"inherit"})],d.Node.prototype,"processMode",2),nr([M({default:"inherit"})],d.Node.prototype,"renderMode",2),nr([M({default:"default"})],d.Node.prototype,"internalMode",2),d.Node=nr([j("Node")],d.Node);var xc=Object.defineProperty,Pc=Object.getOwnPropertyDescriptor,pi=(n,r,e,t)=>{for(var i=t>1?void 0:t?Pc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&xc(r,e,i),i};d.TimelineNode=class extends d.Node{constructor(e,t=[]){super();u(this,"computedDuration",0);u(this,"_currentTime",0);u(this,"_startTime",0);this.setProperties(e).append(t)}get timeline(){var e;return(e=this._tree)==null?void 0:e.timeline}get timelineCurrentTime(){var e;return((e=this.timeline)==null?void 0:e.currentTime)??0}get parentStartTime(){var e;return((e=this._parent)==null?void 0:e.startTime)??0}get currentTime(){return at(0,this._currentTime,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?at(0,this._currentTime/this.computedDuration,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=t!=null&&t.computedDuration?Math.min(this._startTime+this.duration,t.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime)}}_process(e){this._updateCurrentTime(),super._process(e)}},pi([M({default:0})],d.TimelineNode.prototype,"delay",2),pi([M({default:0})],d.TimelineNode.prototype,"duration",2),pi([M({default:!1})],d.TimelineNode.prototype,"paused",2),d.TimelineNode=pi([j("TimelineNode")],d.TimelineNode);var Cc=Object.defineProperty,Tc=Object.getOwnPropertyDescriptor,Mr=(n,r,e,t)=>{for(var i=t>1?void 0:t?Tc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Cc(r,e,i),i};d.Viewport=class extends d.Node{constructor(e=!1){super();u(this,"_projection",new Xn);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new As,needsUpload:!1},{texture:new As,needsUpload:!1}]);this.flipY=e,this._projection.flipY(e)}get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(e){const{width:t,height:i}=this,{pixelRatio:s}=e;return this._framebuffers.forEach(o=>{const a=o.texture;a.pixelRatio=s,a.width=t,a.height=i,a.upload(e)}),{width:t,height:i,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height),this.emit("updateRect");break}}requestUpload(){this._framebuffers.forEach(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){var t;return this.valid?(e.flush(),(t=this._tree)==null||t.setCurrentViewport(this),e.framebuffer.bind(this._glFramebuffer(e)),this.upload(e),!0):!1}redraw(e,t){if(this.valid){e.flush();const i=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),i.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),J.draw(e,ir.instance,{sampler:0}))}render(e,t){var s,o;const i=(s=this._tree)==null?void 0:s.getCurrentViewport();this.activate(e),e.clear(),super.render(e,t),e.flush(),i?i.activate(e):(e.framebuffer.bind(null),(o=this._tree)==null||o.setCurrentViewport(void 0))}getRect(){return new ni(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},Mr([M({default:0})],d.Viewport.prototype,"x",2),Mr([M({default:0})],d.Viewport.prototype,"y",2),Mr([M({default:0})],d.Viewport.prototype,"width",2),Mr([M({default:0})],d.Viewport.prototype,"height",2),d.Viewport=Mr([j("Viewport")],d.Viewport);var Sc=Object.defineProperty,Ec=Object.getOwnPropertyDescriptor,Ar=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ec(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Sc(r,e,i),i};d.Effect=class extends d.TimelineNode{constructor(e,t=[]){super();u(this,"material");u(this,"effectMode");u(this,"viewport1",new d.Viewport);u(this,"viewport2",new d.Viewport);u(this,"_renderId",0);u(this,"_renderViewport");u(this,"_previousSibling");u(this,"_nextSibling");this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}get _effectMode(){return this.effectMode??"parent"}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"glsl":{const o=new di(t);!this.effectMode&&o.has.transition&&(this.effectMode="transition"),this.material=o;break}case"glslSrc":{t?Pt.text.load(t).then(o=>this.glsl=o):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(e){var i;if(!this.isInsideTimeRange())return;const t=(i=this._tree)==null?void 0:i.renderStack;if(t)switch(this._effectMode){case"transition":e.is(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.is(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}}_processParent(){var a,l;const e=(a=this._tree)==null?void 0:a.renderStack;if(!e)return;const t=(l=e.currentCall)==null?void 0:l.parentCall;if(!t)return;const i=t.calls;let s,o;i.forEach((h,c)=>{var f;(h.renderable.is(this._parent)||(f=h.renderable.parent)!=null&&f.is(this._parent))&&(s=s??c,o=c)}),!(s===void 0||o===void 0)&&(i.splice(o+1,0,e.createCall(this)),i.splice(s,0,e.createCall(this)))}_processChildren(){var e;this._children.length&&(super.emit("process"),(e=this._tree)==null||e.renderStack.push(this))}_onProcess(e=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){var i;const t=(i=this._tree)==null?void 0:i.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(i.activate(e),e.clear(),this.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,i,{from:this.viewport1,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),i.activate(e),this.viewport1.texture.activate(e,0),J.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,i){this.material&&(i!=null&&i.redraw?t.redraw(e,()=>{J.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):J.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},Ar([ue()],d.Effect.prototype,"material",2),Ar([M()],d.Effect.prototype,"effectMode",2),Ar([M({default:""})],d.Effect.prototype,"glsl",2),Ar([M({default:""})],d.Effect.prototype,"glslSrc",2),d.Effect=Ar([j("Effect")],d.Effect);var Ho=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,Ac=(n,r,e)=>r in n?Ho(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Os=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ho(r,e,i),i},Yo=(n,r,e)=>Ac(n,typeof r!="symbol"?r+"":r,e);const Oc=`attribute vec2 position;
|
|
105
|
+
}`,uniforms:{sampler:0,projectionMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),modelViewMatrix:new Float32Array([1,0,0,0,1,0,0,0,1]),tint:new Float32Array([1,1,1,1])}})}}u(ir,"_instance");class J extends fi{static get instance(){return this._instance??(this._instance=new this)}static draw(r,e=ir.instance,t){this.instance.draw(r,e,t)}constructor(){super({vertexAttributes:{position:new je({buffer:new vt({data:new Float32Array([-1,-1,1,-1,1,1,-1,1]),dynamic:!1}),size:2,normalized:!1,type:"float"}),uv:new je({buffer:new vt({data:new Float32Array([0,0,1,0,1,1,0,1]),dynamic:!1}),size:2,normalized:!1,type:"float"})},indexBuffer:new rr({data:new Uint16Array([0,1,2,0,2,3]),dynamic:!1})})}}u(J,"_instance");class lc extends fi{constructor(){const e=new vt({data:new Float32Array,dynamic:!0}),t=new vt({data:new Float32Array,dynamic:!0});super({vertexAttributes:{position:new je({buffer:e,size:2,normalized:!1,type:"float"}),uv:new je({buffer:t,size:2,normalized:!1,type:"float"})},indexBuffer:new rr({data:new Uint16Array,dynamic:!0})});u(this,"positionBuffer");u(this,"uvBuffer");this.positionBuffer=e,this.uvBuffer=t}update(e,t,i){return this.positionBuffer.data=e,this.uvBuffer.data=t,this.indexBuffer.data=i,this}}function hc(){return{shadowColor:"transparent",shadowOffsetX:0,shadowOffsetY:0,shadowBlur:0}}function $o(){return{left:0,top:0,width:0,height:0,rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function cc(){return{overflow:"visible",visibility:"visible",filter:"none",opacity:1,marginLeft:0,marginTop:0,marginRight:0,marginBottom:0,paddingLeft:0,paddingTop:0,paddingRight:0,paddingBottom:0,...$o(),backgroundImage:"none",backgroundColor:"transparent",...hc(),borderRadius:0,borderColor:"transparent",borderWidth:1}}function zo(){return{writingMode:"horizontal-tb",verticalAlign:"baseline",lineHeight:1.2,letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textWrap:"wrap",textAlign:"start",textIndent:0,textTransform:"none",textOrientation:"mixed",textDecoration:"none",textStrokeWidth:0,textStrokeColor:"black",color:"black",listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside",highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function uc(){return{...cc(),...zo()}}var fc=Object.defineProperty,_e=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&fc(r,e,i),i};const Vo={brightness:1,contrast:1,grayscale:0,"hue-rotate":0,invert:0,opacity:1,saturate:1,sepia:0};class ne extends yt{constructor(e){super();u(this,"_backgroundColor",new Ct);this.setProperties(e)}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"backgroundColor":this._backgroundColor.value=this.backgroundColor==="none"?void 0:this.backgroundColor;break}}canPointeEvents(){return this.pointerEvents!=="none"}getComputedOpacity(){return at(0,this.opacity,1)}getComputedBackgroundColor(){return this._backgroundColor}async loadBackgroundImage(){if(this.backgroundImage!=="none")return await Pt.texture.load(this.backgroundImage)}getComputedTransform(){const{scaleX:e,scaleY:t,left:i,top:s,width:o,height:a,rotate:l}=this,h=new et,c=new et(!1),f=new et(!1).scale(e,t).translate(i,s).rotate(l*qn);let p=this.transform;(!p||p==="none")&&(p=""),yr(p,{width:o,height:a}).forEach(({name:S,args:w})=>{const v=w.map(x=>x.normalizedIntValue);switch(h.identity(),S){case"translate":h.translate(v[0]*o,(v[1]??v[0])*this.height);break;case"translateX":h.translateX(v[0]*o);break;case"translateY":h.translateY(v[0]*a);break;case"translateZ":h.translateZ(v[0]);break;case"translate3d":h.translate3d(v[0]*o,(v[1]??v[0])*a,v[2]??v[1]??v[0]);break;case"scale":h.scale(v[0],v[1]??v[0]);break;case"scaleX":h.scaleX(v[0]);break;case"scaleY":h.scaleY(v[0]);break;case"scale3d":h.scale3d(v[0],v[1]??v[0],v[2]??v[1]??v[0]);break;case"rotate":h.rotate(v[0]*le);break;case"rotateX":h.rotateX(v[0]*le);break;case"rotateY":h.rotateY(v[0]*le);break;case"rotateZ":h.rotateZ(v[0]*le);break;case"rotate3d":h.rotate3d(v[0]*le,(v[1]??v[0])*le,(v[2]??v[1]??v[0])*le,(v[3]??v[2]??v[1]??v[0])*le);break;case"skew":h.skew(v[0],v[0]??v[1]);break;case"skewX":h.skewX(v[0]);break;case"skewY":h.skewY(v[0]);break;case"matrix":h.set(v);break}c.multiply(h)}),f.update(),c.update();const m=f.toArray(),g=c.toArray(),_=[g[0]*m[0]+g[3]*m[1],g[1]*m[0]+g[4]*m[1],g[2]*m[0]+g[5]*m[1]+m[2],g[0]*m[3]+g[3]*m[4],g[1]*m[3]+g[4]*m[4],g[2]*m[3]+g[5]*m[4]+m[5],0,0,1],[y,E]=this.getComputedTransformOrigin(),T=y*o,P=E*a;return _[2]+=_[0]*-T+_[1]*-P+T,_[5]+=_[3]*-T+_[4]*-P+P,new et().set(_)}getComputedTransformOrigin(){const[e,t=e]=this.transformOrigin.split(" ");return[e,t].map(i=>{switch(i=i.trim(),i){case"left":case"top":return 0;case"center":return .5;case"right":case"bottom":return 1;default:return Number(i)}})}getComputedFilter(){let e={};return this.filter==="none"||(e=yr(this.filter).reduce((t,{name:i,args:s})=>(t[i]=s[0].normalizedIntValue,t),e),Object.keys(Vo).forEach(t=>{e[t]=e[t]??Vo[t]})),e}getComputedFilterColorMatrix(){const e=new us,t=this.getComputedFilter();for(const i in t){const s=t[i];switch(i){case"hue-rotate":e.hueRotate(s*le);break;case"saturate":e.saturate(s);break;case"brightness":e.brightness(s);break;case"contrast":e.contrast(s);break;case"invert":e.invert(s);break;case"sepia":e.sepia(s);break;case"opacity":e.opacity(s);break;case"grayscale":e.grayscale(s);break}}return e}}_e([M({default:"none"})],ne.prototype,"backgroundColor"),_e([M({default:"none"})],ne.prototype,"backgroundImage"),_e([M({default:"none"})],ne.prototype,"filter"),_e([M({default:"inherit"})],ne.prototype,"direction"),_e([M({default:"none"})],ne.prototype,"boxShadow"),_e([M({default:"none"})],ne.prototype,"maskImage"),_e([M({default:1})],ne.prototype,"opacity"),_e([M({default:0})],ne.prototype,"borderWidth"),_e([M({default:0})],ne.prototype,"borderRadius"),_e([M({default:"#000000"})],ne.prototype,"borderColor"),_e([M({default:"none"})],ne.prototype,"borderStyle"),_e([M({default:0})],ne.prototype,"outlineWidth"),_e([M({default:0})],ne.prototype,"outlineOffset"),_e([M({default:"#000000"})],ne.prototype,"outlineColor"),_e([M({default:"none"})],ne.prototype,"outlineStyle"),_e([M({default:"visible"})],ne.prototype,"visibility"),_e([M({default:"visible"})],ne.prototype,"overflow"),_e([M({default:"auto"})],ne.prototype,"pointerEvents");const jo=$o();for(const n in jo)vr(ne,n,{default:jo[n]});const Go=zo();for(const n in Go)vr(ne,n,{default:Go[n]});var dc=Object.defineProperty,sr=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&dc(r,e,i),i};class ge extends yt{constructor(e){super();u(this,"_isPowerOfTwo",!1);u(this,"_needsUpload",!1);this.source=e,this._updateSize()}static get EMPTY(){return new this({width:1,height:1,pixels:null})}static get WHITE(){return new this({width:1,height:1,pixels:new Uint8Array([255,255,255,255])})}static get BLACK(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,0,255])})}static get RED(){return new this({width:1,height:1,pixels:new Uint8Array([255,0,0,255])})}static get GREEN(){return new this({width:1,height:1,pixels:new Uint8Array([0,255,0,255])})}static get BLUE(){return new this({width:1,height:1,pixels:new Uint8Array([0,0,255,255])})}get valid(){return!!(this.width&&this.height)}get realWidth(){return Math.round(this.width*this.pixelRatio)}get realHeight(){return Math.round(this.height*this.pixelRatio)}_glTextureOptions(e,t){let i=this.wrapMode;return e.version===1&&!this._isPowerOfTwo&&(i="clamp_to_edge"),{value:this.source,target:"texture_2d",location:0,filterMode:this.filterMode,wrapMode:i,...t}}_glTexture(e,t){return e.getRelated(this,()=>e.texture.create(this._glTextureOptions(e,t)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"width":case"height":this._updatePOT();break;case"source":this._updateSize();break;case"filterMode":case"wrapMode":case"pixelRatio":this.requestUpload();break}}_updatePOT(){this._isPowerOfTwo=Zi(this.realWidth)&&Zi(this.realHeight),this.requestUpload()}_updateSize(){const e=this.source;"pixels"in e?(this.width=e.width/this.pixelRatio,this.height=e.height/this.pixelRatio):(this.width=Number(e.naturalWidth||e.videoWidth||e.width||0)/this.pixelRatio,this.height=Number(e.naturalHeight||e.videoHeight||e.height||0)/this.pixelRatio),this.requestUpload()}requestUpload(){this._needsUpload=!0}upload(e,t){return this._needsUpload&&this.valid?(this._needsUpload=!1,e.texture.update(this._glTexture(e,t),this._glTextureOptions(e,t)),!0):!1}activate(e,t=0){return this.valid?(e.texture.bind({target:"texture_2d",value:this._glTexture(e,{location:t}),location:t}),this.upload(e,{location:t}),!0):!1}inactivate(e){e.texture.unbind(this._glTexture(e))}destroy(){_n&&this.source instanceof ImageBitmap&&this.source.close()}}sr([ue()],ge.prototype,"source"),sr([M({default:0})],ge.prototype,"width"),sr([M({default:0})],ge.prototype,"height"),sr([M({default:"linear"})],ge.prototype,"filterMode"),sr([M({default:"clamp_to_edge"})],ge.prototype,"wrapMode"),sr([M({default:1})],ge.prototype,"pixelRatio");var pc=Object.defineProperty,gc=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&pc(r,e,i),i};class Er extends ge{constructor(r=document.createElement("canvas")){super(r)}_updateProperty(r,e,t,i){switch(r){case"width":this.source.width=Math.max(1,Math.ceil(e*this.pixelRatio));break;case"height":this.source.height=Math.max(1,Math.ceil(e*this.pixelRatio));break}super._updateProperty(r,e,t,i)}}gc([M({default:2})],Er.prototype,"pixelRatio");class Ss extends ge{constructor(r){const e=new Ct(r);super({width:1,height:1,pixels:new Uint8Array([e.r8,e.g8,e.b8,e.a8])})}}function mc(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),useBitmap:!!((n==null?void 0:n.useBitmap)??!0)&&Ji,crossorigin:(n==null?void 0:n.crossorigin)??null}}class yc extends ge{constructor(e,t){const i=mc(t);super(e);u(this,"bitmap");u(this,"useBitmap");u(this,"preserveBitmap",!1);u(this,"_loadSource");u(this,"_loadBitmap");const s=e.src,o=s.includes(".svg")||s.startsWith("data:image/svg+xml");this.useBitmap=i.useBitmap&&!o,i.autoLoad&&this.load()}async load(){return this._loadSource||(this._loadSource=new Promise(e=>{this._loadSource=void 0;const t=this.source,i=()=>{t.onload=null,t.onerror=null},s=()=>{i(),this.requestUpload(),this.useBitmap?this.genBitmap().finally(()=>e(this)):e(this)},o=a=>{i(),console.warn(`Failed to load ImageTexture, src: ${t.src}`,a),this.emit("error",a),e(this)};t.complete&&t.src?s():(t.onload=s,t.onerror=o)})),this._loadSource}genBitmap(){if(this._loadBitmap)return this._loadBitmap;if(this.bitmap||!Ji)return Promise.resolve(this);const e=this.source,t=!e.crossOrigin||e.crossOrigin==="anonymous";return this._loadBitmap=fetch(e.src,{mode:t?"cors":"no-cors"}).then(i=>i.blob()).then(i=>createImageBitmap(i,0,0,e.width,e.height,{premultiplyAlpha:"premultiply"})).then(i=>(this.bitmap=i,this.requestUpload(),this._loadBitmap=void 0,this)).catch(i=>(console.warn("Failed to genBitmap",i),this)),this._loadBitmap}_glTextureOptions(e){return{...super._glTextureOptions(e),value:this.bitmap??this.source}}upload(e){if(this.useBitmap){if(!this.bitmap)return this.genBitmap(),!1}else{const i=this.source;if(_r&&i instanceof HTMLImageElement&&(!i.complete||i.naturalWidth===0))return!1}const t=super.upload(e);return this.preserveBitmap&&this.bitmap&&(this.bitmap.close(),this.bitmap=void 0),t}}class Es extends ge{constructor(r,e=1,t=1){const i={width:e,height:t,pixels:null};r&&(ArrayBuffer.isView(r)?i.pixels=new Uint8Array(r.buffer):i.pixels=new Uint8Array(r)),super(i)}_updateProperty(r,e,t,i){switch(r){case"width":this.source.width=Math.round(e*this.pixelRatio);break;case"height":this.source.height=Math.round(e*this.pixelRatio);break}super._updateProperty(r,e,t,i)}}var _c=Object.defineProperty,qo=(n,r,e,t)=>{for(var i=void 0,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=o(r,e,i)||i);return i&&_c(r,e,i),i};function vc(n){return{autoLoad:!!((n==null?void 0:n.autoLoad)??!0),autoPlay:!!((n==null?void 0:n.autoPlay)??!1),fps:Number((n==null?void 0:n.fps)??0),crossorigin:(n==null?void 0:n.crossorigin)??null,loop:!!((n==null?void 0:n.loop)??!1),muted:!!((n==null?void 0:n.muted)??!1),playsinline:!!((n==null?void 0:n.playsinline)??!0)}}const Ms=(Xt=class extends ge{constructor(e,t){const i=vc(t);if(!Cn(e)){typeof e=="string"&&(e=[e]);const s=e[0].src||e[0],o=document.createElement("video");i.autoLoad&&o.setAttribute("preload","auto"),i.playsinline&&(o.setAttribute("webkit-playsinline",""),o.setAttribute("playsinline","")),i.muted&&(o.setAttribute("muted",""),o.muted=!0),i.loop&&o.setAttribute("loop",""),i.autoPlay&&o.setAttribute("autoplay",""),An(o,s,i.crossorigin);for(let a=0;a<e.length;++a){let{src:l,mime:h}=e[a];if(l=l||e[a],l.startsWith("data:"))h=l.slice(5,l.indexOf(";"));else if(!l.startsWith("blob:")){const f=l.split("?").shift().toLowerCase(),p=f.slice(f.lastIndexOf(".")+1);h=h||Xt.mimeTypes.get(p)||`video/${p}`}const c=document.createElement("source");c.src=l,h&&(c.type=h),o.appendChild(c)}e=o}super(e);u(this,"_spf",0);u(this,"_autoPlay",!1);u(this,"_sourceLoad");u(this,"_nextTime",0);u(this,"_connected",!1);u(this,"_requestId");u(this,"_resolve");u(this,"_reject");u(this,"_onPlayStart",()=>{this.valid||this._onCanPlay(),this._setupAutoUpdate()});u(this,"_onPlayStop",()=>{this._setupAutoUpdate()});u(this,"_onCanPlay",()=>{const e=this.source;e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay);const t=this.valid;this._nextTime=0,this._updateSize(),this.requestUpload(),this._nextTime=0,!t&&this._resolve&&(this._resolve(this),this._sourceLoad=void 0,this._resolve=void 0,this._reject=void 0),this.isPlaying?this._onPlayStart():this._autoPlay&&e.play()});u(this,"_onError",e=>{this.source.removeEventListener("error",this._onError,!0),this.emit("error",e),this._reject&&(this._reject(e),this._reject=void 0,this._resolve=void 0)});u(this,"_onSeeked",()=>{this.autoUpdate&&!this.isPlaying&&(this._nextTime=0,this.requestUpload(),this._nextTime=0)});u(this,"_videoFrameRequestCallback",()=>{this.requestUpload(),this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback)});u(this,"requestUpload",()=>{const e=Math.floor(fe.elapsed*this.source.playbackRate);this._nextTime-=e,(!this._spf||this._nextTime<=0)&&(super.requestUpload(),this._nextTime=this._spf||0)});this.fps=i.fps,this._autoPlay=i.autoPlay,i.autoPlay&&this.load(),this._setupAutoUpdate()}get isReady(){return this.source.readyState>2}get isPlaying(){return!this.source.paused&&!this.source.ended&&this.isReady}get duration(){return this.source.duration}get seeking(){return this.source.seeking}get currentTime(){return this.source.currentTime}set currentTime(e){this.source.currentTime=e}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"fps":this._spf=t?Math.floor(1e3/t):0,this._setupAutoUpdate();break;case"autoUpdate":this._setupAutoUpdate();break}}_setupAutoUpdate(){this.autoUpdate&&this.isPlaying?!this.fps&&this.source.requestVideoFrameCallback?(this._connected&&(fe.off(this.requestUpload),this._connected=!1,this._nextTime=0),this._requestId===void 0&&(this._requestId=this.source.requestVideoFrameCallback(this._videoFrameRequestCallback))):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected||(fe.on(this.requestUpload),this._connected=!0,this._nextTime=0)):(this._requestId!==void 0&&(this.source.cancelVideoFrameCallback(this._requestId),this._requestId=void 0),this._connected&&(fe.off(this.requestUpload),this._connected=!1,this._nextTime=0))}async load(){if(!this._sourceLoad){const e=this.source;(e.readyState===e.HAVE_ENOUGH_DATA||e.readyState===e.HAVE_FUTURE_DATA)&&e.width&&e.height&&(e.complete=!0),e.addEventListener("play",this._onPlayStart),e.addEventListener("pause",this._onPlayStop),e.addEventListener("seeked",this._onSeeked),this.isReady?this._onCanPlay():(e.addEventListener("canplay",this._onCanPlay),e.addEventListener("canplaythrough",this._onCanPlay),e.addEventListener("error",this._onError,!0)),this._sourceLoad=new Promise((t,i)=>{this.valid?(this._sourceLoad=void 0,t(this)):(this._resolve=t,this._reject=i,e.load())})}return this._sourceLoad}destroy(){this._setupAutoUpdate();const e=this.source;e&&(e.removeEventListener("play",this._onPlayStart),e.removeEventListener("pause",this._onPlayStop),e.removeEventListener("seeked",this._onSeeked),e.removeEventListener("canplay",this._onCanPlay),e.removeEventListener("canplaythrough",this._onCanPlay),e.removeEventListener("error",this._onError,!0),e.pause(),e.src="",e.load())}},u(Xt,"mimeTypes",new Map(Object.entries({ogv:"video/ogg",mov:"video/quicktime",m4v:"video/mp4"}))),Xt);qo([ue({default:!0})],Ms.prototype,"autoUpdate"),qo([ue({default:0})],Ms.prototype,"fps");let Wo=Ms;class As extends Es{}class Xo extends Pe{constructor(){super(...arguments);u(this,"textureTransform");u(this,"fillStyle");u(this,"strokeStyle");u(this,"lineCap");u(this,"lineJoin");u(this,"lineWidth");u(this,"miterLimit");u(this,"_defaultStyle",ge.EMPTY);u(this,"_stroke",[]);u(this,"_fille",[])}stroke(){let e=this._defaultStyle;this.strokeStyle&&(this.strokeStyle instanceof ge?e=this.strokeStyle:e=new Ss(this.strokeStyle)),this.curves.length&&(this._stroke.push({path:new Pe(this),texture:e,textureTransform:this.textureTransform,style:{alignment:.5,cap:this.lineCap??"butt",join:this.lineJoin??"miter",width:this.lineWidth??1,miterLimit:this.miterLimit??10}}),this.currentCurve=new tr,this.curves=[this.currentCurve])}fillRect(e,t,i,s){this.rect(e,t,i,s).fill()}strokeRect(e,t,i,s){this.rect(e,t,i,s).stroke()}fill(){let e=this._defaultStyle;this.fillStyle&&(this.fillStyle instanceof ge?e=this.fillStyle:e=new Ss(this.fillStyle)),this._fille.push({path:new Pe(this),texture:e,textureTransform:this.textureTransform}),this.currentCurve=new tr,this.curves=[this.currentCurve]}copy(e){return super.copy(e),this.strokeStyle=e.strokeStyle,this.fillStyle=e.fillStyle,this.textureTransform=e.textureTransform,this.lineCap=e.lineCap,this.lineJoin=e.lineJoin,this.lineWidth=e.lineWidth,this.miterLimit=e.miterLimit,this._stroke=e._stroke.slice(),this._fille=e._fille.slice(),this}reset(){return super.reset(),this.strokeStyle=void 0,this.fillStyle=void 0,this.textureTransform=void 0,this.lineCap=void 0,this.lineJoin=void 0,this.lineWidth=void 0,this.miterLimit=void 0,this._stroke.length=0,this._fille.length=0,this}buildUvs(e,t,i,s,o){if(s){let a=s.width,l=s.height;o&&([a,l]=o.applyToPoint(a,l));for(let h=t.length,c=e;c<h;c+=2)i.push(t[c]/a,t[c+1]/l)}else for(let a=t.length,l=e;l<a;l+=2)i.push(0,0)}toBatchables(){const e=[];let t=[],i=[],s=[],o=0,a;const l=c=>{e.push({type:c,vertices:t,indices:i,uvs:s,texture:a}),t=[],i=[],s=[],a=void 0};let h=t.length;for(let c=this._fille.length,f=0;f<c;f++){const p=this._fille[f];a??(a=p.texture),a!==p.texture&&l("fill"),o=t.length,p.path.fillTriangulate({vertices:t,indices:i}),this.buildUvs(o,t,s,p.texture,p.textureTransform)}t.length-h>0&&l("fill"),h=t.length;for(let c=this._stroke.length,f=0;f<c;f++){o=t.length;const p=this._stroke[f];a??(a=p.texture),p.path.strokeTriangulate({vertices:t,indices:i,lineStyle:p.style,flipAlignment:!1,closed:!0}),this.buildUvs(o,t,s,p.texture,p.textureTransform),l("stroke")}return t.length-h>0&&l("stroke"),e}}var bc=Object.defineProperty,wc=Object.getOwnPropertyDescriptor,nr=(n,r,e,t)=>{for(var i=t>1?void 0:t?wc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&bc(r,e,i),i};d.Node=class extends ti{constructor(e,t=[]){super();u(this,"name",`${this.tag}:${String(this.instanceId)}`);u(this,"mask");u(this,"_readyed",!1);u(this,"_tree");u(this,"_parent");u(this,"_children",[]);u(this,"_meta",new Map);this._onTreeEnter=this._onTreeEnter.bind(this),this._onTreeExit=this._onTreeExit.bind(this),this._onParented=this._onParented.bind(this),this._onUnparented=this._onUnparented.bind(this),this._onReady=this._onReady.bind(this),this._onProcess=this._onProcess.bind(this),this.setProperties(e).append(t).on("treeEnter",this._onTreeEnter).on("treeExit",this._onTreeExit).on("parented",this._onParented).on("unparented",this._onUnparented).on("ready",this._onReady).on("process",this._onProcess)}getName(){return this.name}setName(e){return this.name=e,this}get tree(){return this.getTree()}set tree(e){this.setTree(e)}getTree(){return this._tree}getViewport(){var e;return(e=this._tree)==null?void 0:e.getCurrentViewport()}getWindow(){var e;return(e=this._tree)==null?void 0:e.root}isInsideTree(){return!!this._tree}setTree(e){const t=this._tree;if(e!==t){e?(this._tree=e,this.emit("treeEnter",e)):t&&(this.emit("treeExit",t),this._tree=e);for(let i=this._children.length,s=0;s<i;s++){const o=this._children[s];!e&&this.emit("childExitingTree",o),o.setTree(e),e&&this.emit("childEnteredTree",o)}e&&(this.emit("treePostEnter",e),this._readyed||(this._readyed=!0,this.emit("ready")))}return this}get parent(){return this._parent}set parent(e){this.setParent(e)}hasParent(){return!!this._parent}getParent(){return this._parent}setParent(e){var t;if(!((t=this._parent)!=null&&t.is(e))){const i=this._parent;this._parent=e,this.setTree(e==null?void 0:e._tree),e?this.emit("parented",e):i&&this.emit("unparented",i)}return this}get siblingIndex(){return this.getIndex()}set siblingIndex(e){var t;(t=this._parent)==null||t.moveChild(this,e)}get previousSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()-1]}get nextSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[this.getIndex()+1]}get firstSibling(){var e;return(e=this._parent)==null?void 0:e.getChildren()[0]}get lastSibling(){var t;const e=(t=this._parent)==null?void 0:t.getChildren();return e?e[e.length-1]:void 0}hasMeta(e){return this._meta.has(e)}getMeta(e,t){return this._meta.get(e)??t}setMeta(e,t){this._meta.set(e,t)}deleteMeta(e){this._meta.delete(e)}clearMeta(){this._meta.clear()}canProcess(){var e;if(!this._tree)return!1;switch(this.processMode){case"inherit":return((e=this._parent)==null?void 0:e.canProcess())??!0;case"pausable":return!this._tree.paused;case"when_paused":return this._tree.paused;case"always":return!0;case"disabled":default:return!1}}canRender(){var e;if(!this._tree)return!1;switch(this.renderMode){case"inherit":return((e=this._parent)==null?void 0:e.canRender())??!0;case"always":return!0;case"disabled":default:return!1}}_onTreeEnter(e){this._treeEnter(e),this.emit("treeEntered",e)}_onTreeExit(e){this.emit("treeExiting",e),this._treeExit(e),this.emit("treeExited",e)}_onParented(e){this._parented(e)}_onUnparented(e){this._unparented(e)}_onReady(){this._ready()}_onProcess(e=0){const t=this._tree,i=this.canRender(),s=this.canProcess();s&&(t==null||t.emit("nodeProcessing",this),this.emit("processing",e),this._process(e));let o;if(i){const a=t.renderStack.push(this);o=t.renderStack.currentCall,t.renderStack.currentCall=a}if(this.mask instanceof d.Node)this.getNode("__$mask")||(this.mask.processMode="disabled",this.addChild(this.mask,"front"));else{const a=this.getNode("__$mask");a&&this.removeChild(a)}for(let a=this._children.length,l=0;l<a;l++)this._children[l].emit("process",e);i&&(t.renderStack.currentCall=o),s&&(this.emit("processed",e),t==null||t.emit("nodeProcessed",this))}render(e,t){const i=this.mask;i&&(e.flush(),e.mask.push(this,i)),this._render(e),t==null||t(),i&&(e.flush(),e.mask.pop(this))}input(e,t){for(let i=this._children.length-1;i>=0;i--)this._children[i].input(e,t);this._input(e,t)}getChildren(e=!1){switch(e){case!0:return this._children;case!1:return this._children.filter(t=>t.internalMode==="default");default:return this._children.filter(t=>t.internalMode===e)}}getIndex(e=!1){var t;return((t=this._parent)==null?void 0:t.getChildren(e).indexOf(this))??0}getNode(e){return this._children.find(t=>t.name===e)}removeNode(e){var t;(t=this.getNode(e))==null||t.remove()}addSibling(e){return this.is(e)||!this.hasParent()||e.hasParent()?this:(e.internalMode=this.internalMode,this._parent.moveChild(e,this.getIndex(!0)+1),this)}append(...e){let t;return Array.isArray(e[0])?t=e[0]:t=e,t.forEach(i=>{this.addChild(i)}),this}addChild(e,t=e.internalMode){if(this.is(e)||e.hasParent())return this;switch(t){case"default":case"front":{const i=t==="default"?"back":"front",s=this._children.findIndex(o=>o.internalMode===i);s>-1?this._children.splice(s,0,e):this._children.push(e);break}case"back":this._children.push(e);break}return e.internalMode=t,e.setParent(this),this.emit("addChild",e),this}moveChild(e,t,i=e.internalMode){if(this.is(e)||e.hasParent()&&!this.is(e.parent))return this;e.internalMode=i;const s=this._children.indexOf(e);let o=this._children.findIndex(h=>{switch(i){case"default":return h.internalMode!=="front";case"back":return h.internalMode==="back";case"front":default:return!0}});o=o>-1?o:Math.max(0,this._children.length-1);let a=this._children.slice(o).findIndex(h=>{switch(i){case"front":return h.internalMode!=="front";case"default":return h.internalMode==="back";case"back":default:return!1}});a=a>-1?o+a:Math.max(0,this._children.length-1);const l=at(o,t>-1?t:a,a);return l!==s&&(s>-1&&this._children.splice(s,1),e.setParent(this),l>-1&&l<this._children.length?this._children.splice(l,0,e):this._children.push(e),s>-1?this.emit("moveChild",e,l,s):this.emit("addChild",e)),this}removeChild(e){const t=e.getIndex(!0);return this.is(e.parent)&&t>-1&&(this._children.splice(t,1),e.setParent(void 0),this.emit("removeChild",e,t)),this}removeChildren(){this.getChildren().forEach(e=>this.removeChild(e))}remove(){var e;(e=this._parent)==null||e.removeChild(this)}forEach(e){return this.getChildren().forEach(e),this}deepForEach(e){return this.getChildren().forEach(t=>{e(t),t.deepForEach(e)}),this}is(e){return!!(e&&this.instanceId===e.instanceId)}_ready(){}_treeEnter(e){}_treeExit(e){}_parented(e){}_unparented(e){}_process(e){}_input(e,t){}_render(e){}toJSON(){return{tag:this.tag,props:super.toJSON(),children:this.getChildren().map(e=>e.toJSON())}}static parse(e){if(Array.isArray(e))return e.map(l=>this.parse(l));const{tag:t,props:i,children:s}=e,o=ei.get(t)??d.Node,a=new o(i);return s==null||s.forEach(l=>a.addChild(this.parse(l))),a}},nr([M()],d.Node.prototype,"name",2),nr([M()],d.Node.prototype,"mask",2),nr([M({default:"inherit"})],d.Node.prototype,"processMode",2),nr([M({default:"inherit"})],d.Node.prototype,"renderMode",2),nr([M({default:"default"})],d.Node.prototype,"internalMode",2),d.Node=nr([j("Node")],d.Node);var xc=Object.defineProperty,Pc=Object.getOwnPropertyDescriptor,pi=(n,r,e,t)=>{for(var i=t>1?void 0:t?Pc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&xc(r,e,i),i};d.TimelineNode=class extends d.Node{constructor(e,t=[]){super();u(this,"computedDuration",0);u(this,"_currentTime",0);u(this,"_startTime",0);this.setProperties(e).append(t)}get timeline(){var e;return(e=this._tree)==null?void 0:e.timeline}get timelineCurrentTime(){var e;return((e=this.timeline)==null?void 0:e.currentTime)??0}get parentStartTime(){var e;return((e=this._parent)==null?void 0:e.startTime)??0}get currentTime(){return at(0,this._currentTime,this.computedDuration)}get startTime(){return this._startTime}set startTime(e){this.delay=e-this.parentStartTime,this._updateCurrentTime(!0)}get endTime(){return this._startTime+this.computedDuration}get currentTimeProgress(){return this.computedDuration?at(0,this._currentTime/this.computedDuration,1):0}isInsideTimeRange(){const e=this._currentTime;return this.computedDuration?e>=0&&e<=this.computedDuration:e>=0}_updateCurrentTime(e=!1){if(e||!this.paused){const t=this._parent;this._startTime=this.delay+this.parentStartTime,this.computedDuration=t!=null&&t.computedDuration?Math.min(this._startTime+this.duration,t.endTime)-this._startTime:this.duration,this._currentTime=this.timelineCurrentTime-this._startTime,this.emit("updateCurrentTime",this._currentTime)}}_process(e){this._updateCurrentTime(),super._process(e)}},pi([M({default:0})],d.TimelineNode.prototype,"delay",2),pi([M({default:0})],d.TimelineNode.prototype,"duration",2),pi([M({default:!1})],d.TimelineNode.prototype,"paused",2),d.TimelineNode=pi([j("TimelineNode")],d.TimelineNode);var Cc=Object.defineProperty,Tc=Object.getOwnPropertyDescriptor,Mr=(n,r,e,t)=>{for(var i=t>1?void 0:t?Tc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Cc(r,e,i),i};d.Viewport=class extends d.Node{constructor(e=!1){super();u(this,"_projection",new Xn);u(this,"_framebufferIndex",0);u(this,"_framebuffers",[{texture:new As,needsUpload:!1},{texture:new As,needsUpload:!1}]);this.flipY=e,this._projection.flipY(e)}get valid(){return!!(this.width&&this.height)}get framebuffer(){return this._framebuffers[this._framebufferIndex]}get texture(){return this.framebuffer.texture}_glFramebufferOptions(e){const{width:t,height:i}=this,{pixelRatio:s}=e;return this._framebuffers.forEach(o=>{const a=o.texture;a.pixelRatio=s,a.width=t,a.height=i,a.upload(e)}),{width:t,height:i,colorTextures:[this.texture._glTexture(e)]}}_glFramebuffer(e){return e.getRelated(this.framebuffer,()=>e.framebuffer.create(this._glFramebufferOptions(e)))}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"x":case"y":this.requestUpload(),this._projection.translate(this.x,this.y),this.emit("updateRect");break;case"width":case"height":this.requestUpload(),this._projection.resize(this.width,this.height),this.emit("updateRect");break}}requestUpload(){this._framebuffers.forEach(e=>e.needsUpload=!0)}resize(e,t){this.width=e,this.height=t}upload(e){const t=this.framebuffer;return t.needsUpload&&this.valid?(t.needsUpload=!1,e.framebuffer.update(this._glFramebuffer(e),this._glFramebufferOptions(e)),!0):!1}activate(e){var t;return this.valid?(e.flush(),(t=this._tree)==null||t.setCurrentViewport(this),e.framebuffer.bind(this._glFramebuffer(e)),this.upload(e),!0):!1}redraw(e,t){if(this.valid){e.flush();const i=this.framebuffer.texture;return this._framebufferIndex=(this._framebufferIndex+1)%this._framebuffers.length,this.activate(e),e.clear(),i.activate(e,0),t(),!0}return!1}activateWithCopy(e,t){this.resize(t.width,t.height),this.activate(e)&&(e.clear(),t.texture.activate(e,0),J.draw(e,ir.instance,{sampler:0}))}render(e,t){var s,o;const i=(s=this._tree)==null?void 0:s.getCurrentViewport();this.activate(e),e.clear(),super.render(e,t),e.flush(),i?i.activate(e):(e.framebuffer.bind(null),(o=this._tree)==null||o.setCurrentViewport(void 0))}getRect(){return new ni(this.x,this.y,this.width,this.height)}toProjectionArray(e=!1){return this._projection.toArray(e)}},Mr([M({default:0})],d.Viewport.prototype,"x",2),Mr([M({default:0})],d.Viewport.prototype,"y",2),Mr([M({default:0})],d.Viewport.prototype,"width",2),Mr([M({default:0})],d.Viewport.prototype,"height",2),d.Viewport=Mr([j("Viewport")],d.Viewport);var Sc=Object.defineProperty,Ec=Object.getOwnPropertyDescriptor,Ar=(n,r,e,t)=>{for(var i=t>1?void 0:t?Ec(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Sc(r,e,i),i};d.Effect=class extends d.TimelineNode{constructor(e,t=[]){super();u(this,"viewport1",new d.Viewport);u(this,"viewport2",new d.Viewport);u(this,"_renderId",0);u(this,"_renderViewport");u(this,"_previousSibling");u(this,"_nextSibling");this._onProcessing=this._onProcessing.bind(this),this._onNodeProcessed=this._onNodeProcessed.bind(this),this.setProperties(e).append(t)}get _effectMode(){return this.effectMode??"parent"}_updateProperty(e,t,i,s){switch(super._updateProperty(e,t,i,s),e){case"glsl":{const o=new di(t);!this.effectMode&&o.has.transition&&(this.effectMode="transition"),this.material=o;break}case"glslSrc":{t?Pt.text.load(t).then(o=>this.glsl=o):this.glsl="";break}}}_treeEnter(e){e.on("processing",this._onProcessing),e.on("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(e),this.viewport2.setTree(e)}_treeExit(e){e.off("processing",this._onProcessing),e.off("nodeProcessed",this._onNodeProcessed),this.viewport1.setTree(void 0),this.viewport2.setTree(void 0)}_onProcessing(){switch(this._updateCurrentTime(),this._effectMode){case"transition":this._previousSibling=this.previousSibling,this._nextSibling=this.nextSibling;break;default:this._previousSibling=void 0,this._nextSibling=void 0;break}}_onNodeProcessed(e){var i;if(!this.isInsideTimeRange())return;const t=(i=this._tree)==null?void 0:i.renderStack;if(t)switch(this._effectMode){case"transition":e.is(this._previousSibling)?(this._previousSibling=void 0,t.push(this)):e.is(this._nextSibling)&&(this._nextSibling=void 0,t.push(this));break}}_processParent(){var a,l;const e=(a=this._tree)==null?void 0:a.renderStack;if(!e)return;const t=(l=e.currentCall)==null?void 0:l.parentCall;if(!t)return;const i=t.calls;let s,o;i.forEach((h,c)=>{var f;(h.renderable.is(this._parent)||(f=h.renderable.parent)!=null&&f.is(this._parent))&&(s=s??c,o=c)}),!(s===void 0||o===void 0)&&(i.splice(o+1,0,e.createCall(this)),i.splice(s,0,e.createCall(this)))}_processChildren(){var e;this._children.length&&(super.emit("process"),(e=this._tree)==null||e.renderStack.push(this))}_onProcess(e=0){if(this.canProcess())switch(this._renderId=0,this._effectMode){case"before":super._onProcess(e);break;case"parent":this._processParent();break;case"children":this._processChildren();break}}_renderBefore(e){var i;const t=(i=this._tree)==null?void 0:i.getCurrentViewport();t&&this.apply(e,t,{redraw:!0})}_renderTransition(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&(this.viewport1.activateWithCopy(e,this._renderViewport),this.viewport2.resize(this._renderViewport.width,this._renderViewport.height)),this.viewport2.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(i.activate(e),e.clear(),this.viewport1.texture.activate(e,0),this.viewport2.texture.activate(e,1),this.apply(e,i,{from:this.viewport1,to:this.viewport2}),e.texture.unbind(0),e.texture.unbind(1))}}_renderParentOrChildren(e){var t;if(this._renderId%2===0)this._renderViewport=(t=this._tree)==null?void 0:t.getCurrentViewport(),this._renderViewport&&this.viewport1.resize(this._renderViewport.width,this._renderViewport.height),this.viewport1.activate(e),e.clear();else{const i=this._renderViewport;this._renderViewport=void 0,i&&(this.viewport1.activate(e),this.apply(e,this.viewport1,{redraw:!0,target:this._effectMode==="parent"?this._parent??void 0:void 0,targetArea:this._parseTargetArea()}),i.activate(e),this.viewport1.texture.activate(e,0),J.draw(e))}}_parseTargetArea(){if(this._effectMode==="parent"&&this._parent&&"getRect"in this._parent){const e=this._parent.getRect();if(e)return[e.left/this.viewport1.width,e.top/this.viewport1.height,e.width/this.viewport1.width,e.height/this.viewport1.height]}}_render(e){switch(this._effectMode){case"before":this._renderBefore(e);break;case"transition":this._renderTransition(e);break;case"parent":case"children":default:this._renderParentOrChildren(e);break}this._renderId++}apply(e,t,i){this.material&&(i!=null&&i.redraw?t.redraw(e,()=>{J.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:t.width/t.height})}):J.draw(e,this.material,{from:0,to:1,progress:this.currentTimeProgress,ratio:i!=null&&i.from?i.from.width/i.from.height:0}))}},Ar([ue()],d.Effect.prototype,"material",2),Ar([M()],d.Effect.prototype,"effectMode",2),Ar([M({default:""})],d.Effect.prototype,"glsl",2),Ar([M({default:""})],d.Effect.prototype,"glslSrc",2),d.Effect=Ar([j("Effect")],d.Effect);var Ho=Object.defineProperty,Mc=Object.getOwnPropertyDescriptor,Ac=(n,r,e)=>r in n?Ho(n,r,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[r]=e,Os=(n,r,e,t)=>{for(var i=t>1?void 0:t?Mc(r,e):r,s=n.length-1,o;s>=0;s--)(o=n[s])&&(i=(t?o(r,e,i):o(i))||i);return t&&i&&Ho(r,e,i),i},Yo=(n,r,e)=>Ac(n,typeof r!="symbol"?r+"":r,e);const Oc=`attribute vec2 position;
|
|
106
106
|
attribute vec2 uv;
|
|
107
107
|
varying vec2 vUv[9];
|
|
108
108
|
uniform float strength;
|
package/dist/index.mjs
CHANGED