webwallgl 1.0.0-beta1 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +86 -8
- package/README.md +85 -8
- package/package.json +7 -1
- package/types.d.ts +9 -1
- package/webwallgl.d.ts +2 -2
- package/webwallgl.global.js +2492 -251
- package/webwallgl.global.js.map +1 -1
- package/webwallgl.global.min.js +1253 -33
- package/webwallgl.global.min.js.map +1 -1
- package/webwallgl.min.mjs +1253 -33
- package/webwallgl.min.mjs.map +1 -1
- package/webwallgl.mjs +2492 -251
- package/webwallgl.mjs.map +1 -1
package/webwallgl.global.min.js
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
|
-
(()=>{var cl=(et,Ye)=>()=>{try{return Ye||et((Ye={exports:{}}).exports,Ye),Ye.exports}catch(qt){throw Ye=0,qt}};var ll=cl((wr,Wi)=>{(function(et,Ye){typeof wr=="object"&&typeof Wi<"u"?Ye(wr):typeof define=="function"&&define.amd?define(["exports"],Ye):(et=typeof globalThis<"u"?globalThis:et||self,Ye(et.WebWallGL={}))})(wr,function(et){"use strict";function Ye(e,n){const t=n?.renderDpr??e.cfg?.renderDpr??1;return Math.min(window.devicePixelRatio||1,t)}function qt(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function ro(e){const n=qt(e);return n==="contain"?{objectFit:"contain",background:"rgba(10,12,16,0.85)"}:n==="stretch"?{objectFit:"fill",background:"transparent"}:{objectFit:"cover",background:"transparent"}}function Vi(e){return{cfg:{type:"canvas"},coverAlign:{x:.5,y:.5,tx:.5,ty:.5},frameMeter:{stamps:[],last:0,fps:0},disposers:[]}}(()=>{const e=n=>n.preventDefault();window.addEventListener("contextmenu",e,!0),document.addEventListener("contextmenu",e,!0),window.__blockContextMenu=n=>n.addEventListener("contextmenu",e,!0)})();function tn(e){e.wrap&&(e.wrap.innerHTML=""),e.raf!==void 0&&cancelAnimationFrame(e.raf),e.raf=void 0;for(const n of e.videoPairs??[])n.destroy();e.videoPairs=void 0,e.sceneCleanup&&e.sceneCleanup(),e.sceneCleanup=void 0,e.sceneCtl=void 0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0);for(const n of e.videoTextures??[])n.pause(),n.removeAttribute("src"),n.load(),n.remove();e.videoTextures=void 0;for(const n of e.objectUrls??[])try{URL.revokeObjectURL(n)}catch{}if(e.objectUrls=void 0,e.sceneAudio){for(const n of e.sceneAudio.audios)n.pause(),n.removeAttribute("src"),n.load();e.sceneAudio=void 0}if(e.video){e.video.pause(),e.video.removeAttribute("src");try{e.video.load()}catch{}e.video.remove()}e.video=void 0,e.img=void 0,e.iframe=void 0,e.canvas=void 0,e.ctx=void 0,e.info=void 0,so(e)}function Xi(e){tn(e);for(const n of e.disposers.splice(0))try{n()}catch{}e.wrap?.remove(),e.wrap=void 0}const Hi=new TextDecoder,st=e=>Hi.decode(e).replace(/^\uFEFF/,""),oo=500;function io(e,n){const t=e.frameMeter.stamps;t.push(n),e.frameMeter.last=n;const r=n-oo;for(;t.length&&t[0]<r;)t.shift();const o=t.length>=2?t[t.length-1]-t[0]:0;e.frameMeter.fps=o>0?(t.length-1)*1e3/o:0}function so(e){e.frameMeter.stamps.length=0,e.frameMeter.last=0,e.frameMeter.fps=0}function Gi(e){return!e.frameMeter.last||e.paused?{fps:0,running:!1}:performance.now()-e.frameMeter.last>Math.max(oo,400)?{fps:0,running:!1}:{fps:e.frameMeter.fps,running:!0}}function ae(e,n,t){try{e.onDiagnostic?.(t,/fail|error|失败|ERROR/.test(t)?"error":"info")}catch{}try{const r=n.mediaBase?new URL(n.mediaBase).origin:"";if(r){const o=new Image;o.src=`${r}/diag?msg=${encodeURIComponent(`scene ${n.src??"?"}: ${t.slice(0,500)}`)}`}}catch{}}function Mr(e){e.coverAlign.x=e.coverAlign.y=e.coverAlign.tx=e.coverAlign.ty=.5,Yi(e)}function Yi(e){const n=`${(e.coverAlign.x*100).toFixed(2)}% ${(e.coverAlign.y*100).toFixed(2)}%`,t=e.video??e.img;t&&t.isConnected&&(t.style.objectPosition=n)}function ao(e,n,t){const r=Ye(e,t),o=Math.max(1,Math.round((n.clientWidth||window.innerWidth||1)*r)),i=Math.max(1,Math.round((n.clientHeight||window.innerHeight||1)*r));return n.width===o&&n.height===i?!1:(n.width=o,n.height=i,!0)}function qi(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<16)throw new Error("\u6587\u4EF6\u592A\u5C0F\uFF0C\u4E0D\u662F scene.pkg");const t=n.getUint32(0,!0);if(t<4||t>16)throw new Error("\u9B54\u6570\u957F\u5EA6\u5F02\u5E38: "+t);const r=co(e,4,t);if(!r.startsWith("PKGV"))throw new Error("\u4E0D\u662F scene.pkg\uFF0C\u9B54\u6570: "+r);const o=n.getUint32(4+t,!0);let i=4+t+4;const s=[];for(let a=0;a<o;a++){if(i+8>e.length)throw new Error("\u5165\u53E3\u8868\u8D8A\u754C @"+a);const u=n.getUint32(i,!0);if(i+=4,i+u+8>e.length)throw new Error("\u5165\u53E3 "+a+" \u8D8A\u754C");const l=Ki(e,i,u);i+=u;const d=n.getUint32(i,!0);i+=4;const h=n.getUint32(i,!0);i+=4,s.push({name:l,offset:d,size:h})}const c=i;return{magic:r,version:r.slice(4),count:o,entries:s,dataStart:c,fileSize:e.length,buf:e}}function _r(e,n){const t=e.entries.find(i=>i.name===n);if(t===void 0)return null;const r=e.dataStart+t.offset,o=r+t.size;if(r<0||o>e.fileSize)throw new Error("\u5165\u53E3 "+n+" \u8D8A\u754C");return e.buf.subarray(r,o)}function Zi(e){let n=0;for(const t of e.entries)n=Math.max(n,t.offset+t.size);return{dataEnd:e.dataStart+n,fileSize:e.fileSize,ok:e.dataStart+n<=e.fileSize}}function co(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}function Ki(e,n,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(n,n+t))}catch{return co(e,n,t)}}const Qi=Object.freeze(Object.defineProperty({__proto__:null,getEntry:_r,parsePkg:qi,verifyLayout:Zi},Symbol.toStringTag,{value:"Module"})),Ar={0:"ARGB8888",1:"RGB888",2:"RGB565",4:"DXT5",6:"DXT3",7:"DXT1",8:"RG88",9:"R8",10:"RG1616f",11:"R16f",12:"BC7",13:"RGBa1010102",14:"RGBA16161616f",15:"RGB161616f"},Nt={UNKNOWN:-1,JPEG:2,PNG:13,GIF:25,WEBP:35,MP4:35};function Ji(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=n[0];if(e.isVideo)return{width:t.width,height:t.height,video:t.data};if(e.freeImageFormat===Nt.PNG)return{width:t.width,height:t.height,png:t.data};if(e.freeImageFormat!==Nt.UNKNOWN)return{width:t.width,height:t.height,image:t.data,fif:e.freeImageFormat};const r=Tr(e.format,t.data,t.width,t.height);return!e.frames?.list?.length&&(t.width!==e.width||t.height!==e.height)?{width:e.width,height:e.height,rgba:lo(r,t.width,t.height,e.width,e.height)}:{width:t.width,height:t.height,rgba:r}}function es(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=[];for(const r of n){if(e.freeImageFormat!==Nt.UNKNOWN){t.push({width:r.width,height:r.height,image:r.data,fif:e.freeImageFormat});continue}const o=Tr(e.format,r.data,r.width,r.height);t.push({width:r.width,height:r.height,rgba:o})}return!e.frames?.list?.length&&t.length>0&&(t[0].width!==e.width||t[0].height!==e.height)&&t[0].rgba&&(t[0]={width:e.width,height:e.height,rgba:lo(t[0].rgba,t[0].width,t[0].height,e.width,e.height)}),t}function lo(e,n,t,r,o){const i=new Uint8Array(r*o*4);for(let s=0;s<o;s++)i.set(e.subarray(s*n*4,s*n*4+r*4),s*r*4);return i}function Tr(e,n,t,r){switch(e){case 0:return ts(n,t,r);case 1:return ns(n,t,r);case 2:return rs(n,t,r);case 4:return cs(n,t,r);case 6:return as(n,t,r);case 7:return ss(n,t,r);case 8:return os(n,t,r);case 9:return is(n,t,r);case 12:throw new Error("BC7 \u89E3\u7801\u6682\u672A\u5B9E\u73B0\uFF08format=12\uFF09");default:throw new Error("\u672A\u652F\u6301\u7684\u7EB9\u7406\u683C\u5F0F: "+(Ar[e]||e))}}function ts(e,n,t){return new Uint8Array(e.buffer,e.byteOffset,n*t*4).slice()}function ns(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*3],r[o*4+1]=e[o*3+1],r[o*4+2]=e[o*3+2],r[o*4+3]=255;return r}function rs(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++){const i=e[o*2]|e[o*2+1]<<8,s=i>>11&31,c=i>>5&63,a=i&31;r[o*4]=s<<3|s>>2,r[o*4+1]=c<<2|c>>4,r[o*4+2]=a<<3|a>>2,r[o*4+3]=255}return r}function os(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*2+1],r[o*4+1]=e[o*2+1],r[o*4+2]=e[o*2+1],r[o*4+3]=e[o*2];return r}function is(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o],r[o*4+1]=e[o],r[o*4+2]=e[o],r[o*4+3]=255;return r}function ss(e,n,t){return Sr(e,n,t,!0,0)}function as(e,n,t){return Sr(e,n,t,!1,3)}function cs(e,n,t){return Sr(e,n,t,!1,5)}function Sr(e,n,t,r,o){const i=new Uint8Array(n*t*4),s=r?8:16,c=new Uint8Array(16);let a=0;for(let u=0;u<t;u+=4)for(let l=0;l<n;l+=4){if(a+s>e.length)return i;c.set(e.subarray(a,a+s)),a+=s;const d=ls(c,r),h=us(c,r),p=o===3?fs(c):o===5?ds(c):null;for(let w=0;w<4;w++)for(let m=0;m<4;m++){const g=l+m,v=u+w;if(g>=n||v>=t)continue;const b=w*4+m,y=(v*n+g)*4;i[y]=d[h[b]*4],i[y+1]=d[h[b]*4+1],i[y+2]=d[h[b]*4+2],i[y+3]=p!==null?p[b]:d[h[b]*4+3]}}return i}function uo(e,n){const t=e[n]|e[n+1]<<8,r=t>>11&31,o=t>>5&63,i=t&31;return[t,r<<3|r>>2,o<<2|o>>4,i<<3|i>>2]}function ls(e,n){const t=n?0:8,r=uo(e,t),o=uo(e,t+2),i=new Uint8Array(16);return i[0]=r[1],i[1]=r[2],i[2]=r[3],i[3]=255,i[4]=o[1],i[5]=o[2],i[6]=o[3],i[7]=255,n&&r[0]<=o[0]?(i[8]=r[1]+o[1]>>1,i[9]=r[2]+o[2]>>1,i[10]=r[3]+o[3]>>1,i[11]=255,i[12]=0,i[13]=0,i[14]=0,i[15]=0):(i[8]=Math.floor((2*r[1]+o[1])/3),i[9]=Math.floor((2*r[2]+o[2])/3),i[10]=Math.floor((2*r[3]+o[3])/3),i[11]=255,i[12]=Math.floor((r[1]+2*o[1])/3),i[13]=Math.floor((r[2]+2*o[2])/3),i[14]=Math.floor((r[3]+2*o[3])/3),i[15]=255),i}function us(e,n){const t=n?4:12,r=new Uint8Array(16);for(let o=0;o<4;o++){const i=e[t+o];r[o*4]=i&3,r[o*4+1]=i>>2&3,r[o*4+2]=i>>4&3,r[o*4+3]=i>>6&3}return r}function fs(e){const n=new Uint8Array(16);for(let t=0;t<8;t++){const r=e[t],o=r&15,i=r&240;n[2*t]=o|o<<4,n[2*t+1]=i|i>>4}return n}function ds(e){const n=e[0],t=e[1],r=new Uint8Array(8);if(r[0]=n,r[1]=t,n<=t){for(let c=1;c<5;c++)r[1+c]=Math.floor(((5-c)*n+c*t)/5);r[6]=0,r[7]=255}else for(let c=1;c<7;c++)r[c+1]=Math.floor(((7-c)*n+c*t)/7);const o=new Uint8Array(16);let i=0;for(let c=0;c<2;c++){let a=0;for(let u=0;u<3;u++)a|=e[2+c*3+u]<<8*u;for(let u=0;u<8;u++)o[i++]=a>>3*u&7}const s=new Uint8Array(16);for(let c=0;c<16;c++)s[c]=r[o[c]];return s}function fo(e,n){const t=new Uint8Array(n);let r=0,o=0;for(;r<e.length;){const i=e[r++];let s=i>>4;if(s===15){let l;do l=e[r++],s+=l;while(l===255)}for(let l=0;l<s;l++)t[o++]=e[r++];if(r>=e.length)break;const c=e[r]|e[r+1]<<8;r+=2;let a=4+(i&15);if((i&15)===15){let l;do l=e[r++],a+=l;while(l===255)}const u=o-c;for(let l=0;l<a;l++)t[o++]=t[u+l]}return t}function Ue(e,n){return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function ho(e,n){return Ue(e,n)|0}const bn=new DataView(new ArrayBuffer(4));function Ut(e,n){return bn.setUint8(0,e[n]),bn.setUint8(1,e[n+1]),bn.setUint8(2,e[n+2]),bn.setUint8(3,e[n+3]),bn.getFloat32(0,!0)}function hs(e){let n=0;const t=Yn(e,n,9);if(n+=9,t!=="TEXV0005\0")throw new Error("\u4E0D\u662F .tex \u6587\u4EF6: "+t);const r=Yn(e,n,9);if(n+=9,r!=="TEXI0001\0")throw new Error("\u672A\u77E5 TEXI \u5B50\u5BB9\u5668: "+r);const o=Ue(e,n);n+=4;const i=Ue(e,n);n+=4;const s=Ue(e,n);n+=4;const c=Ue(e,n);n+=4;const a=Ue(e,n);n+=4;const u=Ue(e,n);n+=4,n+=4;const l=Yn(e,n,9);n+=9;const d=Ue(e,n);n+=4;let h=Nt.UNKNOWN,p=0;if(l==="TEXB0004\0"){h=Ue(e,n)|0,n+=4;const S=Ue(e,n);n+=4,h===Nt.UNKNOWN&&S===1&&(h=Nt.MP4),p=S===1?4:3}else if(l==="TEXB0003\0")h=Ue(e,n)|0,n+=4,p=3;else if(l==="TEXB0002\0")p=2;else if(l==="TEXB0001\0")p=1;else throw new Error("\u672A\u77E5 TEXB \u5BB9\u5668: "+l);const w=(i&32)!==0||h===Nt.MP4,m=[];for(let S=0;S<d;S++){const _=Ue(e,n);n+=4;const C=[];for(let N=0;N<_;N++){if(p===4){for(n+=8;n<e.length&&e[n]!==0;)n++;n+=1,n+=4}const D=Ue(e,n);n+=4;const k=Ue(e,n);n+=4;let O=0,j=0;p>=2&&(O=Ue(e,n),n+=4,j=ho(e,n),n+=4);const W=ho(e,n);if(n+=4,w){C.push({width:D,height:k,compression:0,data:e.subarray(n)}),n=e.length;continue}O===0&&(j=W);const K=e.subarray(n,n+W);n+=W;let V=K;O===1&&(V=fo(K,j)),C.push({width:D,height:k,compression:O,data:V})}m.push(C)}const g=m[0]&&m[0][0],v=g?g.width:s,b=g?g.height:c;let y=null;if(n+13<=e.length){const S=Yn(e,n,9);if(S.indexOf("TEXS")===0){let _=n+9;const C=Ue(e,_);_+=4;let N=0,D=0;S==="TEXS0003\0"&&(N=Ue(e,_),_+=4,D=Ue(e,_),_+=4);const k=e.length-_,O=C>0&&k>0&&k%C===0?k/C:0;if(C>0&&C<=4096&&O>=32){const j=[];for(let K=0;K<C;K++){const V=_+K*O;if(V+32>e.length)break;const G=Ut(e,V+8),Q=Ut(e,V+12),q=Ut(e,V+16),te=Ut(e,V+20),me=Ut(e,V+24),xe=Ut(e,V+28);j.push({imageId:Ut(e,V)|0,duration:Ut(e,V+4),x:G,y:Q,width:Math.hypot(q,te)||N,height:Math.hypot(me,xe)||D,uDir:[q,te],vDir:[me,xe],rotated:Math.abs(te)>.5||Math.abs(me)>.5})}j.length===C&&j.every(K=>{if(!(K.width>0&&K.height>0))return!1;const V=[K.x,K.x+K.uDir[0],K.x+K.vDir[0],K.x+K.uDir[0]+K.vDir[0]],G=[K.y,K.y+K.uDir[1],K.y+K.vDir[1],K.y+K.uDir[1]+K.vDir[1]];return Math.min(...V)>=-1&&Math.max(...V)<=v+1&&Math.min(...G)>=-1&&Math.max(...G)<=b+1})&&(y={magic:S,frameWidth:N,frameHeight:D,atlasWidth:v,atlasHeight:b,list:j})}}}return{format:o,formatName:Ar[o]||String(o),flags:i,textureWidth:s,textureHeight:c,width:a,height:u,freeImageFormat:h,containerMagic:l,containerVersion:p,isVideo:w,images:m,frames:y}}function Yn(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}const ms=Object.freeze(Object.defineProperty({__proto__:null,FIF:Nt,TEXTURE_FORMATS:Ar,decodeMip0:Ji,decodeMips:es,decodePixels:Tr,lz4Decompress:fo,parseTex:hs},Symbol.toStringTag,{value:"Module"}));function mo(e,n){if(!e||typeof n!="string")return null;const t=e[n];return t&&typeof t=="object"?t:null}function Er(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.name=="string"?e.name:null}function ps(e,n){return qn(e)&&qn(n)?Number(e)===Number(n):String(e)===String(n)}function Pr(e){if(typeof e=="boolean")return"bool";if(typeof e=="number")return Number.isFinite(e)?"num":"other";if(typeof e=="string"){const n=e.trim().split(/\s+/);return n.length>0&&n[0]!==""&&n.every(t=>Number.isFinite(Number(t)))?"num":"text"}return"other"}function gs(e){switch(e.type){case"bool":return"bool";case"slider":return"num";case"color":return"num";case"textinput":return"text";default:return Pr(e.value)}}function po(e,n){if(e===null||typeof e!="object")return e;if(e.user&&typeof e.user=="object"&&typeof e.user.name=="string"){const r=mo(n,e.user.name);if(!r||r.value===void 0||r.value===null)return e.value;const o=r.type==="combo"?Cr(r.value,r.options):r.value;return ps(o,e.user.condition)}if(typeof e.user!="string")return e;const t=mo(n,e.user);if(!t||t.value===void 0||t.value===null)return e.value;if(t.userOverridden)return t.value;if(e.value!==null&&typeof e.value=="object")return e.value;if(e.value===void 0)return t.value;if(Pr(e.value)==="bool"&&t.type==="slider"){const r=Number(t.value);return Number.isFinite(r)?r!==0:e.value}return Pr(e.value)===gs(t)?t.value:e.value}function nn(e,n,t){if(t>32||e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let r=0;r<e.length;r++)e[r]=nn(e[r],n,t+1);return e}if(Er(e.user)){let r=po(e,n);for(let o=0;o<8&&r!==null&&typeof r=="object"&&Er(r.user);o++)r=po(r,n);return e.value=nn(r,n,t+1),e}for(const r of Object.keys(e))e[r]=nn(e[r],n,t+1);return e}function bs(e){return e?Array.isArray(e)?e.map(n=>n&&typeof n=="object"&&"value"in n?n.value:n):typeof e=="object"?Object.values(e):[]:[]}function qn(e){return typeof e=="number"?Number.isInteger(e):typeof e=="string"&&/^-?\d+$/.test(e.trim())}function Cr(e,n){const t=bs(n);return!(t.length>0?t.every(qn):qn(e))||typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):e}function vs(e){const n={};if(!e||typeof e!="object")return n;for(const[t,r]of Object.entries(e))!r||typeof r!="object"||!("value"in r)||(n[t]=r.type==="combo"?Cr(r.value,r.options):r.value);return n}function pt(e){return e&&typeof e=="object"?Er(e.user):null}function ys(e,n,t){const r={};if(!t||typeof t!="object")return r;const o=e&&typeof e=="object"?e:{},i=n&&typeof n=="object"?n:{};for(const[s,c]of Object.entries(t)){const a=c&&typeof c=="object"&&"value"in c?c.value:c,u=o[s];if(u&&typeof u=="object"){u.value=a,u.userOverridden=!0;const l=u.type==="combo"?Cr(u.value,u.options):u.value;i[s]=l,r[s]=l}else i[s]=a,r[s]=a}return r}function rn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0,n[0]||0]:[n[0]||0,n[1]||0,n[2]||0]}function vn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0]:[n[0]||0,n[1]||0]}function Zn(e){return e==null?[1,1,1]:typeof e=="string"?rn(e):typeof e=="object"&&e!==null?rn(e.value):[1,1,1]}function Ke(e,n=!1){if(e==null)return n;if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="object"&&e!==null){const t=e.value;return typeof t=="number"?t!==0:!!t}return n}function tt(e,n){if(typeof e=="number")return e;if(e!==null&&typeof e=="object"){const t=Number(e.value);return Number.isFinite(t)?t:n}return n}function xs(e,n){const t=n&&n.general&&n.general.properties||{},r=e.objects||[];nn(r,t,0),nn(e.general||{},t,0);const o=new Map;for(const m of r)m.id!==void 0&&o.set(m.id,m);const i=r.map(m=>({id:m.id,parent:m.parent,origin:rn(m.origin||"0 0 0"),scale:rn(m.scale||"1 1 1"),angles:rn(m.angles||"0 0 0")}));for(let m=0;m<8;m++){let g=!1;for(const v of i){if(v.parent===void 0||v.parent===null||!o.get(v.parent))continue;const y=i.findIndex(G=>G.id===v.parent);if(y<0)continue;const S=i[y];if(S.parent!==void 0&&S.parent!==null)continue;const _=r[y],C=_.scale,N=C!==null&&typeof C=="object"&&(typeof C.script=="string"||C.user!==void 0),D=!_.image&&!_.model&&!_.particle&&_.text==null&&!_.size,k=N&&D?[1,1,1]:S.scale,O=S.angles[2]*Math.PI/180,j=Math.cos(O),W=Math.sin(O),K=v.origin[0]*k[0],V=v.origin[1]*k[1];v.origin[0]=S.origin[0]+K*j-V*W,v.origin[1]=S.origin[1]+K*W+V*j,v.origin[2]=S.origin[2]+v.origin[2],v.angles[2]=S.angles[2]+v.angles[2],v.scale[0]=k[0]*v.scale[0],v.scale[1]=k[1]*v.scale[1],v.scale[2]=k[2]*v.scale[2],v.parent=null,g=!0}if(!g)break}const s=r.map(m=>Ke(m.visible,!0)),c=new Map;r.forEach((m,g)=>{m.id!==void 0&&c.set(m.id,g)});const a=new Map,u=new Map;for(const m of r)if(m.parent!==void 0&&m.parent!==null){a.set(m.parent,(a.get(m.parent)||0)+1);const g=m.id!==void 0?m.id:null;if(g!==null){const v=u.get(m.parent);v?v.push(g):u.set(m.parent,[g])}}const l=r.map(()=>!0);for(let m=0;m<r.length;m++){let g=s[m],v=r[m].parent;for(let b=0;g&&v!==void 0&&v!==null&&b<64;b++){const y=c.get(v);if(y===void 0)break;s[y]||(g=!1),v=r[y].parent}l[m]=g}const d=r.map((m,g)=>{const v=i[g],b=typeof m.image=="string"&&(m.image.indexOf("models/util/projectlayer")===0||m.image.indexOf("models/util/fullscreenlayer")===0);let y=vn(m.size||"0 0"),S=v.origin;if(b){const _=(e.general||{}).orthogonalprojection,C=_&&Number(_.width),N=_&&Number(_.height);C>0&&N>0&&(y=[C,N],S=[C/2,N/2,v.origin[2]||0])}return{id:m.id!==void 0?m.id:g,name:m.name||"",visible:l[g],visibleSelf:s[g],srcObject:m,image:typeof m.image=="string"?m.image:null,model:typeof m.model=="string"?m.model:null,isSkybox:typeof m.name=="string"&&m.name.indexOf("\u5929\u7A7A\u76D2")>=0,particle:typeof m.particle=="string"?m.particle:null,instanceoverride:m.instanceoverride||null,sound:Array.isArray(m.sound)?m.sound.filter(_=>typeof _=="string"):[],soundprops:{volume:tt(m.volume,1),playbackmode:m.playbackmode||"single",startsilent:Ke(m.startsilent,!1),maxtime:tt(m.maxtime,0),mintime:tt(m.mintime,0),spatialization:Ke(m.spatialization,!1),muteineditor:Ke(m.muteineditor,!1)},text:typeof m.text=="string"?m.text:m.text&&typeof m.text=="object"?m.text.value:null,textScript:m.text&&typeof m.text=="object"&&m.text.script||null,textScriptProps:m.text&&typeof m.text=="object"&&m.text.scriptproperties||null,component:typeof m.component=="string"?m.component:null,isText:m.text!==void 0&&m.text!==null,textFont:typeof m.font=="string"?m.font:null,textPointsize:tt(m.pointsize,24)||24,textColor:Zn(m.color),textAnchor:typeof m.anchor=="string"&&m.anchor!=="none"?m.anchor:"center",textMaxwidth:tt(m.maxwidth,0),textMaxrows:tt(m.maxrows,0),textLimitwidth:Ke(m.limitwidth,!1),textLimitrows:Ke(m.limitrows,!1),textLimituseellipsis:Ke(m.limituseellipsis,!1),textHAlign:m.horizontalalign||"center",textVAlign:m.verticalalign||"center",textSpacing:m.spacing?vn(m.spacing):[0,0],textPadding:(()=>{const _=m.padding;if(typeof _=="number")return _;const C=String(_??"").trim().split(/\s+/).map(Number).filter(N=>Number.isFinite(N));return C.length?C.reduce((N,D)=>N+D,0)/C.length:0})(),textOpaquebackground:Ke(m.opaquebackground,!1),textBackgroundcolor:Zn(m.backgroundcolor),textBackgroundbrightness:tt(m.backgroundbrightness,1),textCastshadow:Ke(m.castshadow,!1),isSound:!!(m.sound&&m.sound.length),isComponent:!!m.component,objectScripts:(()=>{const _={};for(const C of["scale","origin","color","alpha","brightness","angles","visible"]){const N=m[C];N&&typeof N=="object"&&typeof N.script=="string"&&N.script&&(_[C]={script:N.script,scriptproperties:N.scriptproperties||null,value:N.value})}return Object.keys(_).length?_:null})(),objectAnimations:(()=>{const _={};for(const C of["scale","origin","color","alpha","brightness","angles","visible","volume","maxwidth","zoom"]){const N=m[C];N&&typeof N=="object"&&N.animation&&typeof N.animation=="object"&&N.animation.options&&(_[C]={animation:N.animation,value:N.value})}return Object.keys(_).length?_:null})(),animationLayers:(m.animationlayers||[]).filter(_=>_&&typeof _.animation=="number").map(_=>({animation:_.animation,visible:Ke(_.visible,!0),additive:Ke(_.additive,!1),blend:tt(_.blend,1),rate:tt(_.rate,1)})),solid:(()=>{if(typeof m.particle=="string")return!1;const _=typeof m.image=="string"?m.image:"";return _.indexOf("models/util/composelayer")===0?!1:_.indexOf("models/util/solidlayer")===0?!0:m.solid?!_||_.indexOf("models/util/")===0:!1})(),isContainer:typeof m.image=="string"&&m.image.indexOf("models/util/composelayer")===0,hasChildren:(a.get(m.id!==void 0?m.id:g)||0)>0,childIds:u.get(m.id!==void 0?m.id:g)||null,parentId:m.parent!==void 0&&m.parent!==null?m.parent:null,attachment:typeof m.attachment=="string"&&m.attachment!==""?m.attachment:null,passthrough:!!(m.config&&m.config.passthrough===!0),isPostProcess:b,origin:S,scale:v.scale,angles:v.angles,size:y,alignment:m.alignment||"center",color:Zn(m.color),alpha:tt(m.alpha,1),brightness:tt(m.brightness,1),copybackground:!!m.copybackground,colorBlendMode:m.colorBlendMode||0,parallaxDepth:m.parallaxDepth!==void 0?vn(m.parallaxDepth):null,effects:(m.effects||[]).map(_=>({file:_.file||"",name:typeof _.name=="string"?_.name:"",visible:Ke(_.visible,!0),visibleScript:_.visible&&typeof _.visible=="object"&&typeof _.visible.script=="string"&&_.visible.script?{script:_.visible.script,scriptproperties:_.visible.scriptproperties||null,value:!!_.visible.value}:null,passes:(_.passes||[]).map(C=>({combos:C.combos||{},constantshadervalues:C.constantshadervalues||{},textures:C.textures||[]}))}))}}),h=e.general||{},p=(()=>{const m={};for(const[g,v]of Object.entries(h))v&&typeof v=="object"&&typeof v.script=="string"&&v.script&&(m[g]={script:v.script,scriptproperties:v.scriptproperties||null,value:v.value});return Object.keys(m).length?m:null})(),w=(()=>{const m={};for(const[g,v]of Object.entries(h))v&&typeof v=="object"&&v.animation&&typeof v.animation=="object"&&v.animation.options&&(m[g]={animation:v.animation,value:v.value});return Object.keys(m).length?m:null})();{const m=new Map;for(const g of d)g.id!==void 0&&m.set(g.id,g);for(let g=0;g<8;g++){let v=!1;for(const b of d){if(b.parallaxDepth||b.parentId==null)continue;const y=m.get(b.parentId);!y||!y.parallaxDepth||y.image||y.particle||y.model||(b.parallaxDepth=y.parallaxDepth.slice(),v=!0)}if(!v)break}}return{camera:e.camera||null,general:h,generalScripts:p,generalAnimations:w,layers:d,properties:t}}function ws(e){if(!Array.isArray(e))return;const n=new Map;for(const t of e)t&&t.id!==void 0&&t.id!==null&&n.set(t.id,t);for(const t of e){if(!t)continue;if(t.destroyed){t.visible=!1;continue}let r=t.visibleSelf!==!1,o=t.parentId;for(let i=0;r&&o!=null&&i<64;i++){const s=n.get(o);if(!s)break;(s.visibleSelf===!1||s.destroyed)&&(r=!1),o=s.parentId}t.visible=r}}function Ms(e,n){!e||!n||typeof n!="object"||e.isContainer||n.solidlayer===!0&&(e.solid=!0)}function _s(e){return!e||typeof e.material!="string"?null:{materialPath:e.material,autosize:!!e.autosize,cropoffset:e.cropoffset?vn(e.cropoffset):null}}const As=Object.freeze(Object.defineProperty({__proto__:null,applySolidFromModel:Ms,parseBool:Ke,parseColor:Zn,parseNum:tt,parseScene:xs,parseVec2:vn,parseVec3:rn,recomputeLayerVisibility:ws,resolveMaterial:_s},Symbol.toStringTag,{value:"Module"}));function Ts(e,n,t){const r=_r(e,n.file);if(r===null)return;let o;try{o=JSON.parse(t(r))}catch{return}n.fbos=o.fbos||[],n.materialPasses=(o.passes||[]).map(i=>{if(!i.material)return{shader:null,copyCommand:!0,target:i.target||null,source:i.source||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const s=_r(e,i.material);if(s===null)return{shader:null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const c=JSON.parse(t(s)),a=c.passes&&c.passes[0]||{};return{shader:a.shader||null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:a.blending||"normal",textures:a.textures||[],combos:a.combos||{},constants:a.constantshadervalues||{}}})}const Ss={"models/util/solidlayer.json":{material:"materials/util/solidlayer.json"},"models/util/composelayer.json":{material:"materials/util/solidlayer.json"},"models/util/fullscreenlayer.json":{material:"materials/util/solidlayer.json"},"models/util/projectlayer.json":{material:"materials/util/solidlayer.json"}};function go(e){if(!e||typeof e!="string")return!0;const n=e.toLowerCase();return n==="generic"||n==="sprite"||n==="flat"||n.startsWith("genericimage")}function Es(e,n){return!e||!n||!n.shader||go(n.shader)||(e.effects=e.effects||[],e.effects.some(t=>t.layerMaterial))?!1:(e.effects.unshift({file:"",name:"_layerMaterial",visible:!0,layerMaterial:!0,passes:[{combos:n.combos||{},constantshadervalues:n.constantshadervalues||{},textures:n.textures||[]}],materialPasses:[{shader:n.shader,copyCommand:!1,target:null,binds:[],blending:n.blending||"normal",textures:n.textures||[],combos:n.combos||{},constants:n.constantshadervalues||{}}],fbos:[]}),!0)}const Ps=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_MATERIALS:{"materials/util/solidlayer.json":{passes:[{shader:"flat",blending:"translucent",cullmode:"nocull",depthtest:"disabled",depthwrite:"disabled",textures:[],combos:{}}]}},BUILTIN_MODELS:Ss,attachLayerMaterialEffect:Es,isBuiltinAlbedoShader:go,resolveEffectChain:Ts},Symbol.toStringTag,{value:"Module"}));function on(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function gt(e,n){const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++){let i=0;for(let s=0;s<4;s++)i+=e[s*4+o]*n[r*4+s];t[r*4+o]=i}return t}function yn(e,n,t,r,o,i){const s=on();return s[0]=2/(n-e),s[5]=2/(r-t),s[10]=-2/(i-o),s[12]=-(n+e)/(n-e),s[13]=-(r+t)/(r-t),s[14]=-0/(i-o),s}function sn(e,n,t,r){return gt(e,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,n,t,r,1]))}function Cs(e){const n=new Float32Array(16);for(let t=0;t<4;t++)for(let r=0;r<4;r++)n[r*4+t]=e[t*4+r];return n}function xn(e,n,t,r){return gt(e,new Float32Array([n,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1]))}function bo(e,n){const t=Math.cos(n),r=Math.sin(n);return gt(e,new Float32Array([t,r,0,0,-r,t,0,0,0,0,1,0,0,0,0,1]))}function Rs(e,n){const t=Math.cos(n),r=Math.sin(n);return gt(e,new Float32Array([1,0,0,0,0,t,r,0,0,-r,t,0,0,0,0,1]))}function Ls(e,n){const t=Math.cos(n),r=Math.sin(n);return gt(e,new Float32Array([t,0,-r,0,0,1,0,0,r,0,t,0,0,0,0,1]))}function Fs(e,n,t,r){const o=1/Math.tan(e*Math.PI/180/2),i=new Float32Array(16);return i[0]=o/(n||1),i[5]=o,i[10]=(r+t)/(t-r),i[11]=-1,i[14]=2*r*t/(t-r),i}function Kn(e,n){const t=e&&typeof e=="object"?e.value:e;return typeof t=="number"&&Number.isFinite(t)?t:n}function Ns(e){const n=e&&e.general;return!n||n.orthogonalprojection?!1:Kn(n.fov,0)>0}function Us(e,n){return n&&n.perspective&&e&&e.isSkybox&&n.eye?n.eye:e.origin}function ks(e,n,t){const r=yo([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),o=yo(xo(t,r)),i=xo(r,o),s=new Float32Array([o[0],i[0],r[0],0,o[1],i[1],r[1],0,o[2],i[2],r[2],0,0,0,0,1]);return s[12]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),s[13]=-(i[0]*e[0]+i[1]*e[1]+i[2]*e[2]),s[14]=-(r[0]*e[0]+r[1]*e[1]+r[2]*e[2]),s}function Bs(e,n,t,r){const o=e[3]*n+e[7]*t+e[11]*r+e[15];return[(e[0]*n+e[4]*t+e[8]*r+e[12])/o,(e[1]*n+e[5]*t+e[9]*r+e[13])/o,(e[2]*n+e[6]*t+e[10]*r+e[14])/o]}const Is=[[16,9],[16,10],[21,9],[32,9]];function Os(e,n,t,r,o){const i=e/n;if(!Number.isFinite(i)||i<=0||!(t>0)||!(r>0))return null;const s=.02,c=t/r;if(Math.abs(i-c)<=s*c)return{viewW:t,viewH:r};for(const[a,u]of Is){const l=a/u;if(Math.abs(i-l)>s*l)continue;const d=r,h=r*l;return h>t+1e-6?{viewW:t,viewH:t/l}:{viewW:h,viewH:d}}return null}function Rr(e,n,t,r,o,i,s){const c=vo(i),a=vo(s);if(e==="cover"){const u=Os(r,o,n,t);if(u)return{offX:(n-u.viewW)*c,offY:(t-u.viewH)*a,viewW:u.viewW,viewH:u.viewH};const l=Math.max(r/n,o/t),d=r/l,h=o/l;return{offX:(n-d)*c,offY:(t-h)*a,viewW:d,viewH:h}}if(e==="contain"){const u=r/o;if(n/t>u){const p=n,w=n/u;return{offX:0,offY:(t-w)/2,viewW:p,viewH:w}}const d=t,h=t*u;return{offY:0,offX:(n-h)/2,viewW:h,viewH:d}}return{offX:0,offY:0,viewW:n,viewH:t}}function Ds(e,n,t,r,o,i){const s=e.general,c=e.camera,a=c&&c.eye?Lr(c.eye):[0,0,0],u=c&&c.center?Lr(c.center):[0,0,-1],l=c&&c.up?Lr(c.up):[0,1,0];if(Ns(e)){const y=t>0?n/t:1.7777777777777777,S=Kn(s.fov,50),_=Math.max(Kn(s.nearz,.01),1e-4),C=Math.max(Kn(s.farz,1e4),_+1),N=ks(a,u,l),D=Fs(S,y,_,C);return{view:N,projection:D,eye:a,center:u,projW:y,projH:1,offX:0,offY:0,viewW:y,viewH:1,perspective:!0}}const d=on(),h=s&&s.orthogonalprojection&&s.orthogonalprojection.width||n,p=s&&s.orthogonalprojection&&s.orthogonalprojection.height||t,w=Rr(r,h,p,n,t,o,i),m=e&&e.cameraTransforms?e.cameraTransforms.zoom:s&&s.zoom,g=m&&typeof m=="object"?m.value:m,v=Number(g);if(Number.isFinite(v)&&v>0&&Math.abs(v-1)>1e-6){const y=w.offX+w.viewW/2,S=w.offY+w.viewH/2,_=w.viewW/v,C=w.viewH/v;w.offX=y-_/2,w.offY=S-C/2,w.viewW=_,w.viewH=C}const b=yn(w.offX,w.offX+w.viewW,w.offY+w.viewH,w.offY,-1e4,1e4);return{view:d,projection:b,eye:a,projW:h,projH:p,offX:w.offX,offY:w.offY,viewW:w.viewW,viewH:w.viewH,perspective:!1}}function vo(e){const n=Number(e);return Number.isFinite(n)?n<0?0:n>1?1:n:.5}function Lr(e){return String(e).trim().split(/\s+/).map(Number)}function yo(e){const n=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/n,e[1]/n,e[2]/n]}function xo(e,n){return[e[1]*n[2]-e[2]*n[1],e[2]*n[0]-e[0]*n[2],e[0]*n[1]-e[1]*n[0]]}function an(e){const n=Number(e);return Number.isFinite(n)?n*.5:0}function zs(e){const n=new Map,t=new Map,r=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]*)\))?[ \t]*(.*)$/gm;let o;for(;(o=r.exec(e))!==null;){const i=s=>s.replace(/\/\/.*$/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim();o[2]!==void 0?t.set(o[1],{args:o[2].split(",").map(s=>s.trim()).filter(Boolean),body:i(o[3])}):n.set(o[1],i(o[3]))}return{defs:n,fns:t}}function $s(e,n,t,r){const o=[];let i=0;for(;i<e.length;){const s=e.indexOf(n,i);if(s===-1){o.push(e.slice(i));break}o.push(e.slice(i,s));let a=s+n.length;for(;a<e.length&&/\s/.test(e[a]);)a++;if(e[a]!=="("){o.push(e.slice(s,a)),i=a;continue}let u=0,l=a;for(;l<e.length;l++)if(e[l]==="(")u++;else if(e[l]===")"&&(u--,u===0))break;if(l>=e.length){o.push(e.slice(s));break}const d=e.slice(a+1,l),h=kt(d);let p=t.body;t.args.forEach((w,m)=>{const g=h[m]!==void 0?h[m].trim():"";p=wn(p,w,g)}),r>0&&(p=wo(p,r-1)),o.push("("+p+")"),i=l+1}return o.join("")}function wn(e,n,t){return e.replace(new RegExp("\\b"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","g"),t)}function kt(e){const n=[];let t=0,r="";for(let o=0;o<e.length;o++){const i=e[o];i==="("?t++:i===")"&&t--,i===","&&t===0?(n.push(r),r=""):r+=i}return r.trim()!==""&&n.push(r),n}function wo(e,n){for(let t=0;t<12;t++){const{defs:r,fns:o}=zs(e);if(r.size===0&&o.size===0)break;const i=e.split(`
|
|
2
|
-
`);let s=!1;for(let
|
|
3
|
-
`),!
|
|
1
|
+
(function(yt,Ut){typeof exports=="object"&&typeof module<"u"?Ut(exports):typeof define=="function"&&define.amd?define(["exports"],Ut):(yt=typeof globalThis<"u"?globalThis:yt||self,Ut(yt.WebWallGL={}))})(this,function(yt){"use strict";function Ut(e,n){const t=n?.renderDpr??e.cfg?.renderDpr??1;return Math.min(window.devicePixelRatio||1,t)}function un(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function bo(e){const n=un(e);return n==="contain"?{objectFit:"contain",background:"rgba(10,12,16,0.85)"}:n==="stretch"?{objectFit:"fill",background:"transparent"}:{objectFit:"cover",background:"transparent"}}function hs(e){return{cfg:{type:"canvas"},coverAlign:{x:.5,y:.5,tx:.5,ty:.5},frameMeter:{stamps:[],last:0,fps:0},disposers:[]}}(()=>{const e=n=>n.preventDefault();window.addEventListener("contextmenu",e,!0),document.addEventListener("contextmenu",e,!0),window.__blockContextMenu=n=>n.addEventListener("contextmenu",e,!0)})();function Zt(e){if(e.iframe)try{e.iframe.contentWindow?.location.replace("about:blank")}catch{}if(e.wrap)e.wrap.innerHTML="";else if(e.iframe?.isConnected)try{e.iframe.remove()}catch{}e.raf!==void 0&&cancelAnimationFrame(e.raf),e.raf=void 0;for(const n of e.videoPairs??[])n.destroy();e.videoPairs=void 0,e.sceneCleanup&&e.sceneCleanup(),e.sceneCleanup=void 0,e.sceneCtl=void 0,e.pointerCtl=void 0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0);for(const n of e.videoTextures??[])n.pause(),n.removeAttribute("src"),n.load(),n.remove();e.videoTextures=void 0;for(const n of e.objectUrls??[])try{URL.revokeObjectURL(n)}catch{}if(e.objectUrls=void 0,e.sceneAudio){for(const n of e.sceneAudio.audios)n.pause(),n.removeAttribute("src"),n.load();e.sceneAudio=void 0}if(e.video){e.video.pause(),e.video.removeAttribute("src");try{e.video.load()}catch{}e.video.remove()}e.video=void 0,e.img=void 0,e.iframe=void 0,e.canvas=void 0,e.ctx=void 0,e.info=void 0,vo(e)}function ms(e){Zt(e);for(const n of e.disposers.splice(0))try{n()}catch{}e.wrap?.remove(),e.wrap=void 0}const gs=new TextDecoder,ft=e=>gs.decode(e).replace(/^\uFEFF/,""),yo=500;function qn(e,n){const t=e.frameMeter.stamps;t.push(n),e.frameMeter.last=n;const r=n-yo;for(;t.length&&t[0]<r;)t.shift();const o=t.length>=2?t[t.length-1]-t[0]:0;e.frameMeter.fps=o>0?(t.length-1)*1e3/o:0}function vo(e){e.frameMeter.stamps.length=0,e.frameMeter.last=0,e.frameMeter.fps=0}function bs(e){return!e.frameMeter.last||e.paused?{fps:0,running:!1}:performance.now()-e.frameMeter.last>Math.max(yo,400)?{fps:0,running:!1}:{fps:e.frameMeter.fps,running:!0}}function se(e,n,t){try{e.onDiagnostic?.(t,/fail|error|失败|ERROR/.test(t)?"error":"info")}catch{}try{const r=n.mediaBase?new URL(n.mediaBase,window.location.href).origin:"";if(r){const o=new Image;o.src=`${r}/diag?msg=${encodeURIComponent(`scene ${n.src??"?"}: ${t.slice(0,500)}`)}`}}catch{}}function Pr(e){e.coverAlign.x=e.coverAlign.y=e.coverAlign.tx=e.coverAlign.ty=.5,ys(e)}function ys(e){const n=`${(e.coverAlign.x*100).toFixed(2)}% ${(e.coverAlign.y*100).toFixed(2)}%`,t=e.video??e.img;t&&t.isConnected&&(t.style.objectPosition=n)}function xo(e,n,t){const r=Ut(e,t),o=Math.max(1,Math.round((n.clientWidth||window.innerWidth||1)*r)),i=Math.max(1,Math.round((n.clientHeight||window.innerHeight||1)*r));return n.width===o&&n.height===i?!1:(n.width=o,n.height=i,!0)}function vs(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength);if(e.length<16)throw new Error("\u6587\u4EF6\u592A\u5C0F\uFF0C\u4E0D\u662F scene.pkg");const t=n.getUint32(0,!0);if(t<4||t>16)throw new Error("\u9B54\u6570\u957F\u5EA6\u5F02\u5E38: "+t);const r=wo(e,4,t);if(!r.startsWith("PKGV"))throw new Error("\u4E0D\u662F scene.pkg\uFF0C\u9B54\u6570: "+r);const o=n.getUint32(4+t,!0);let i=4+t+4;const s=[];for(let c=0;c<o;c++){if(i+8>e.length)throw new Error("\u5165\u53E3\u8868\u8D8A\u754C @"+c);const u=n.getUint32(i,!0);if(i+=4,i+u+8>e.length)throw new Error("\u5165\u53E3 "+c+" \u8D8A\u754C");const l=ws(e,i,u);i+=u;const p=n.getUint32(i,!0);i+=4;const f=n.getUint32(i,!0);i+=4,s.push({name:l,offset:p,size:f})}const a=i;return{magic:r,version:r.slice(4),count:o,entries:s,dataStart:a,fileSize:e.length,buf:e}}function Cr(e,n){const t=e.entries.find(i=>i.name===n);if(t===void 0)return null;const r=e.dataStart+t.offset,o=r+t.size;if(r<0||o>e.fileSize)throw new Error("\u5165\u53E3 "+n+" \u8D8A\u754C");return e.buf.subarray(r,o)}function xs(e){let n=0;for(const t of e.entries)n=Math.max(n,t.offset+t.size);return{dataEnd:e.dataStart+n,fileSize:e.fileSize,ok:e.dataStart+n<=e.fileSize}}function wo(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}function ws(e,n,t){try{return new TextDecoder("utf-8",{fatal:!0}).decode(e.subarray(n,n+t))}catch{return wo(e,n,t)}}const Ms=Object.freeze(Object.defineProperty({__proto__:null,getEntry:Cr,parsePkg:vs,verifyLayout:xs},Symbol.toStringTag,{value:"Module"})),Lr={0:"ARGB8888",1:"RGB888",2:"RGB565",4:"DXT5",6:"DXT3",7:"DXT1",8:"RG88",9:"R8",10:"RG1616f",11:"R16f",12:"BC7",13:"RGBa1010102",14:"RGBA16161616f",15:"RGB161616f"},Bt={UNKNOWN:-1,JPEG:2,PNG:13,GIF:25,WEBP:35,MP4:35};function _s(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=n[0];if(e.isVideo)return{width:t.width,height:t.height,video:t.data};if(e.freeImageFormat===Bt.PNG)return{width:t.width,height:t.height,png:t.data};if(e.freeImageFormat!==Bt.UNKNOWN)return{width:t.width,height:t.height,image:t.data,fif:e.freeImageFormat};const r=Rr(e.format,t.data,t.width,t.height);return!e.frames?.list?.length&&(t.width!==e.width||t.height!==e.height)?{width:e.width,height:e.height,rgba:Mo(r,t.width,t.height,e.width,e.height)}:{width:t.width,height:t.height,rgba:r}}function As(e){const n=e.images[0];if(!n||n.length===0)throw new Error("\u65E0\u56FE\u50CF\u6570\u636E");const t=[];for(const r of n){if(e.freeImageFormat!==Bt.UNKNOWN){t.push({width:r.width,height:r.height,image:r.data,fif:e.freeImageFormat});continue}const o=Rr(e.format,r.data,r.width,r.height);t.push({width:r.width,height:r.height,rgba:o})}return!e.frames?.list?.length&&t.length>0&&(t[0].width!==e.width||t[0].height!==e.height)&&t[0].rgba&&(t[0]={width:e.width,height:e.height,rgba:Mo(t[0].rgba,t[0].width,t[0].height,e.width,e.height)}),t}function Mo(e,n,t,r,o){const i=new Uint8Array(r*o*4);for(let s=0;s<o;s++)i.set(e.subarray(s*n*4,s*n*4+r*4),s*r*4);return i}function Rr(e,n,t,r){switch(e){case 0:return Ts(n,t,r);case 1:return Ss(n,t,r);case 2:return Es(n,t,r);case 4:return Fs(n,t,r);case 6:return Rs(n,t,r);case 7:return Ls(n,t,r);case 8:return Ps(n,t,r);case 9:return Cs(n,t,r);case 12:throw new Error("BC7 \u89E3\u7801\u6682\u672A\u5B9E\u73B0\uFF08format=12\uFF09");default:throw new Error("\u672A\u652F\u6301\u7684\u7EB9\u7406\u683C\u5F0F: "+(Lr[e]||e))}}function Ts(e,n,t){return new Uint8Array(e.buffer,e.byteOffset,n*t*4).slice()}function Ss(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*3],r[o*4+1]=e[o*3+1],r[o*4+2]=e[o*3+2],r[o*4+3]=255;return r}function Es(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++){const i=e[o*2]|e[o*2+1]<<8,s=i>>11&31,a=i>>5&63,c=i&31;r[o*4]=s<<3|s>>2,r[o*4+1]=a<<2|a>>4,r[o*4+2]=c<<3|c>>2,r[o*4+3]=255}return r}function Ps(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o*2+1],r[o*4+1]=e[o*2+1],r[o*4+2]=e[o*2+1],r[o*4+3]=e[o*2];return r}function Cs(e,n,t){const r=new Uint8Array(n*t*4);for(let o=0;o<n*t;o++)r[o*4]=e[o],r[o*4+1]=e[o],r[o*4+2]=e[o],r[o*4+3]=255;return r}function Ls(e,n,t){return Fr(e,n,t,!0,0)}function Rs(e,n,t){return Fr(e,n,t,!1,3)}function Fs(e,n,t){return Fr(e,n,t,!1,5)}function Fr(e,n,t,r,o){const i=new Uint8Array(n*t*4),s=r?8:16,a=new Uint8Array(16);let c=0;for(let u=0;u<t;u+=4)for(let l=0;l<n;l+=4){if(c+s>e.length)return i;a.set(e.subarray(c,c+s)),c+=s;const p=ks(a,r),f=Ns(a,r),d=o===3?Us(a):o===5?Bs(a):null;for(let w=0;w<4;w++)for(let M=0;M<4;M++){const m=l+M,A=u+w;if(m>=n||A>=t)continue;const h=w*4+M,b=(A*n+m)*4;i[b]=p[f[h]*4],i[b+1]=p[f[h]*4+1],i[b+2]=p[f[h]*4+2],i[b+3]=d!==null?d[h]:p[f[h]*4+3]}}return i}function _o(e,n){const t=e[n]|e[n+1]<<8,r=t>>11&31,o=t>>5&63,i=t&31;return[t,r<<3|r>>2,o<<2|o>>4,i<<3|i>>2]}function ks(e,n){const t=n?0:8,r=_o(e,t),o=_o(e,t+2),i=new Uint8Array(16);return i[0]=r[1],i[1]=r[2],i[2]=r[3],i[3]=255,i[4]=o[1],i[5]=o[2],i[6]=o[3],i[7]=255,n&&r[0]<=o[0]?(i[8]=r[1]+o[1]>>1,i[9]=r[2]+o[2]>>1,i[10]=r[3]+o[3]>>1,i[11]=255,i[12]=0,i[13]=0,i[14]=0,i[15]=0):(i[8]=Math.floor((2*r[1]+o[1])/3),i[9]=Math.floor((2*r[2]+o[2])/3),i[10]=Math.floor((2*r[3]+o[3])/3),i[11]=255,i[12]=Math.floor((r[1]+2*o[1])/3),i[13]=Math.floor((r[2]+2*o[2])/3),i[14]=Math.floor((r[3]+2*o[3])/3),i[15]=255),i}function Ns(e,n){const t=n?4:12,r=new Uint8Array(16);for(let o=0;o<4;o++){const i=e[t+o];r[o*4]=i&3,r[o*4+1]=i>>2&3,r[o*4+2]=i>>4&3,r[o*4+3]=i>>6&3}return r}function Us(e){const n=new Uint8Array(16);for(let t=0;t<8;t++){const r=e[t],o=r&15,i=r&240;n[2*t]=o|o<<4,n[2*t+1]=i|i>>4}return n}function Bs(e){const n=e[0],t=e[1],r=new Uint8Array(8);if(r[0]=n,r[1]=t,n<=t){for(let a=1;a<5;a++)r[1+a]=Math.floor(((5-a)*n+a*t)/5);r[6]=0,r[7]=255}else for(let a=1;a<7;a++)r[a+1]=Math.floor(((7-a)*n+a*t)/7);const o=new Uint8Array(16);let i=0;for(let a=0;a<2;a++){let c=0;for(let u=0;u<3;u++)c|=e[2+a*3+u]<<8*u;for(let u=0;u<8;u++)o[i++]=c>>3*u&7}const s=new Uint8Array(16);for(let a=0;a<16;a++)s[a]=r[o[a]];return s}function Ao(e,n){const t=new Uint8Array(n);let r=0,o=0;for(;r<e.length;){const i=e[r++];let s=i>>4;if(s===15){let l;do l=e[r++],s+=l;while(l===255)}for(let l=0;l<s;l++)t[o++]=e[r++];if(r>=e.length)break;const a=e[r]|e[r+1]<<8;r+=2;let c=4+(i&15);if((i&15)===15){let l;do l=e[r++],c+=l;while(l===255)}const u=o-a;for(let l=0;l<c;l++)t[o++]=t[u+l]}return t}function Be(e,n){return(e[n]|e[n+1]<<8|e[n+2]<<16|e[n+3]<<24)>>>0}function To(e,n){return Be(e,n)|0}const Tn=new DataView(new ArrayBuffer(4));function Dt(e,n){return Tn.setUint8(0,e[n]),Tn.setUint8(1,e[n+1]),Tn.setUint8(2,e[n+2]),Tn.setUint8(3,e[n+3]),Tn.getFloat32(0,!0)}function Ds(e){let n=0;const t=Yn(e,n,9);if(n+=9,t!=="TEXV0005\0")throw new Error("\u4E0D\u662F .tex \u6587\u4EF6: "+t);const r=Yn(e,n,9);if(n+=9,r!=="TEXI0001\0")throw new Error("\u672A\u77E5 TEXI \u5B50\u5BB9\u5668: "+r);const o=Be(e,n);n+=4;const i=Be(e,n);n+=4;const s=Be(e,n);n+=4;const a=Be(e,n);n+=4;const c=Be(e,n);n+=4;const u=Be(e,n);n+=4,n+=4;const l=Yn(e,n,9);n+=9;const p=Be(e,n);n+=4;let f=Bt.UNKNOWN,d=0;if(l==="TEXB0004\0"){f=Be(e,n)|0,n+=4;const v=Be(e,n);n+=4,f===Bt.UNKNOWN&&v===1&&(f=Bt.MP4),d=v===1?4:3}else if(l==="TEXB0003\0")f=Be(e,n)|0,n+=4,d=3;else if(l==="TEXB0002\0")d=2;else if(l==="TEXB0001\0")d=1;else throw new Error("\u672A\u77E5 TEXB \u5BB9\u5668: "+l);const w=(i&32)!==0||f===Bt.MP4,M=[];for(let v=0;v<p;v++){const T=Be(e,n);n+=4;const _=[];for(let F=0;F<T;F++){if(d===4){for(n+=8;n<e.length&&e[n]!==0;)n++;n+=1,n+=4}const R=Be(e,n);n+=4;const k=Be(e,n);n+=4;let U=0,V=0;d>=2&&(U=Be(e,n),n+=4,V=To(e,n),n+=4);const q=To(e,n);if(n+=4,w){_.push({width:R,height:k,compression:0,data:e.subarray(n)}),n=e.length;continue}U===0&&(V=q);const W=e.subarray(n,n+q);n+=q;let Z=W;U===1&&(Z=Ao(W,V)),_.push({width:R,height:k,compression:U,data:Z})}M.push(_)}const m=M[0]&&M[0][0],A=m?m.width:s,h=m?m.height:a;let b=null;if(n+13<=e.length){const v=Yn(e,n,9);if(v.indexOf("TEXS")===0){let T=n+9;const _=Be(e,T);T+=4;let F=0,R=0;v==="TEXS0003\0"&&(F=Be(e,T),T+=4,R=Be(e,T),T+=4);const k=e.length-T,U=_>0&&k>0&&k%_===0?k/_:0;if(_>0&&_<=4096&&U>=32){const V=[];for(let W=0;W<_;W++){const Z=T+W*U;if(Z+32>e.length)break;const K=Dt(e,Z+8),re=Dt(e,Z+12),te=Dt(e,Z+16),X=Dt(e,Z+20),J=Dt(e,Z+24),de=Dt(e,Z+28);V.push({imageId:Dt(e,Z)|0,duration:Dt(e,Z+4),x:K,y:re,width:Math.hypot(te,X)||F,height:Math.hypot(J,de)||R,uDir:[te,X],vDir:[J,de],rotated:Math.abs(X)>.5||Math.abs(J)>.5})}V.length===_&&V.every(W=>{if(!(W.width>0&&W.height>0))return!1;const Z=[W.x,W.x+W.uDir[0],W.x+W.vDir[0],W.x+W.uDir[0]+W.vDir[0]],K=[W.y,W.y+W.uDir[1],W.y+W.vDir[1],W.y+W.uDir[1]+W.vDir[1]];return Math.min(...Z)>=-1&&Math.max(...Z)<=A+1&&Math.min(...K)>=-1&&Math.max(...K)<=h+1})&&(b={magic:v,frameWidth:F,frameHeight:R,atlasWidth:A,atlasHeight:h,list:V})}}}return{format:o,formatName:Lr[o]||String(o),flags:i,textureWidth:s,textureHeight:a,width:c,height:u,freeImageFormat:f,containerMagic:l,containerVersion:d,isVideo:w,images:M,frames:b}}function Yn(e,n,t){let r="";for(let o=n;o<n+t;o++)r+=String.fromCharCode(e[o]);return r}const Is=Object.freeze(Object.defineProperty({__proto__:null,FIF:Bt,TEXTURE_FORMATS:Lr,decodeMip0:_s,decodeMips:As,decodePixels:Rr,lz4Decompress:Ao,parseTex:Ds},Symbol.toStringTag,{value:"Module"}));function So(e,n){if(!e||typeof n!="string")return null;const t=e[n];return t&&typeof t=="object"?t:null}function kr(e){return typeof e=="string"?e:e&&typeof e=="object"&&typeof e.name=="string"?e.name:null}function Os(e,n){return Zn(e)&&Zn(n)?Number(e)===Number(n):String(e)===String(n)}function Nr(e){if(typeof e=="boolean")return"bool";if(typeof e=="number")return Number.isFinite(e)?"num":"other";if(typeof e=="string"){const n=e.trim().split(/\s+/);return n.length>0&&n[0]!==""&&n.every(t=>Number.isFinite(Number(t)))?"num":"text"}return"other"}function $s(e){switch(e.type){case"bool":return"bool";case"slider":return"num";case"color":return"num";case"textinput":return"text";default:return Nr(e.value)}}function Eo(e,n){if(e===null||typeof e!="object")return e;if(e.user&&typeof e.user=="object"&&typeof e.user.name=="string"){const r=So(n,e.user.name);if(!r||r.value===void 0||r.value===null)return e.value;const o=r.type==="combo"?Ur(r.value,r.options):r.value;return Os(o,e.user.condition)}if(typeof e.user!="string")return e;const t=So(n,e.user);if(!t||t.value===void 0||t.value===null)return e.value;if(t.userOverridden)return t.value;if(e.value!==null&&typeof e.value=="object")return e.value;if(e.value===void 0)return t.value;if(Nr(e.value)==="bool"&&t.type==="slider"){const r=Number(t.value);return Number.isFinite(r)?r!==0:e.value}return Nr(e.value)===$s(t)?t.value:e.value}function fn(e,n,t){if(t>32||e===null||typeof e!="object")return e;if(Array.isArray(e)){for(let r=0;r<e.length;r++)e[r]=fn(e[r],n,t+1);return e}if(kr(e.user)){let r=Eo(e,n);for(let o=0;o<8&&r!==null&&typeof r=="object"&&kr(r.user);o++)r=Eo(r,n);return e.value=fn(r,n,t+1),e}for(const r of Object.keys(e))e[r]=fn(e[r],n,t+1);return e}function js(e){return e?Array.isArray(e)?e.map(n=>n&&typeof n=="object"&&"value"in n?n.value:n):typeof e=="object"?Object.values(e):[]:[]}function Zn(e){return typeof e=="number"?Number.isInteger(e):typeof e=="string"&&/^-?\d+$/.test(e.trim())}function Ur(e,n){const t=js(n);return!(t.length>0?t.every(Zn):Zn(e))||typeof e=="number"&&Number.isFinite(e)?e:typeof e=="string"&&/^-?\d+$/.test(e.trim())?Number(e):e}function zs(e){const n={};if(!e||typeof e!="object")return n;for(const[t,r]of Object.entries(e))!r||typeof r!="object"||!("value"in r)||(n[t]=r.type==="combo"?Ur(r.value,r.options):r.value);return n}function vt(e){return e&&typeof e=="object"?kr(e.user):null}function Vs(e,n,t){const r={};if(!t||typeof t!="object")return r;const o=e&&typeof e=="object"?e:{},i=n&&typeof n=="object"?n:{};for(const[s,a]of Object.entries(t)){const c=a&&typeof a=="object"&&"value"in a?a.value:a,u=o[s];if(u&&typeof u=="object"){u.value=c,u.userOverridden=!0;const l=u.type==="combo"?Ur(u.value,u.options):u.value;i[s]=l,r[s]=l}else i[s]=c,r[s]=c}return r}function dn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0,n[0]||0]:[n[0]||0,n[1]||0,n[2]||0]}function Sn(e){typeof e=="object"&&e!==null&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return n.length===1?[n[0]||0,n[0]||0]:[n[0]||0,n[1]||0]}function Kn(e){return e==null?[1,1,1]:typeof e=="string"?dn(e):typeof e=="object"&&e!==null?dn(e.value):[1,1,1]}function nt(e,n=!1){if(e==null)return n;if(typeof e=="boolean")return e;if(typeof e=="number")return e!==0;if(typeof e=="object"&&e!==null){const t=e.value;return typeof t=="number"?t!==0:!!t}return n}function st(e,n){if(typeof e=="number")return e;if(e!==null&&typeof e=="object"){const t=Number(e.value);return Number.isFinite(t)?t:n}return n}function Br(e){return e?!e.image&&!e.model&&!e.particle&&e.text==null&&!e.size:!1}function Dr(e,n,t){const r=t?e.scale:[1,1,1],o=(e.angles[2]||0)*Math.PI/180,i=Math.cos(o),s=Math.sin(o),a=n.origin[0]*r[0],c=n.origin[1]*r[1];return{origin:[e.origin[0]+a*i-c*s,e.origin[1]+a*s+c*i,e.origin[2]+(n.origin[2]||0)],scale:[r[0]*n.scale[0],r[1]*n.scale[1],r[2]*n.scale[2]],angles:[n.angles[0],n.angles[1],(e.angles[2]||0)+n.angles[2]]}}function Ws(e,n){const t=n&&n.general&&n.general.properties||{},r=e.objects||[];fn(r,t,0),fn(e.general||{},t,0);const o=new Map;for(const m of r)m.id!==void 0&&o.set(m.id,m);const i=r.map(m=>({id:m.id,parent:m.parent,origin:dn(m.origin||"0 0 0"),scale:dn(m.scale||"1 1 1"),angles:dn(m.angles||"0 0 0")})),s=i.map(m=>({origin:m.origin.slice(),scale:m.scale.slice(),angles:m.angles.slice()}));for(let m=0;m<8;m++){let A=!1;for(const h of i){if(h.parent===void 0||h.parent===null||!o.get(h.parent))continue;const v=i.findIndex(V=>V.id===h.parent);if(v<0)continue;const T=i[v];if(T.parent!==void 0&&T.parent!==null)continue;const _=r[v],F=_.scale,k=!(F!==null&&typeof F=="object"&&(typeof F.script=="string"||F.user!==void 0)&&Br(_)),U=Dr(T,h,k);h.origin=U.origin,h.scale=U.scale,h.angles=U.angles,h.parent=null,A=!0}if(!A)break}const a=r.map(m=>nt(m.visible,!0)),c=new Map;r.forEach((m,A)=>{m.id!==void 0&&c.set(m.id,A)});const u=new Map,l=new Map;for(const m of r)if(m.parent!==void 0&&m.parent!==null){u.set(m.parent,(u.get(m.parent)||0)+1);const A=m.id!==void 0?m.id:null;if(A!==null){const h=l.get(m.parent);h?h.push(A):l.set(m.parent,[A])}}const p=r.map(()=>!0);for(let m=0;m<r.length;m++){let A=a[m],h=r[m].parent;for(let b=0;A&&h!==void 0&&h!==null&&b<64;b++){const v=c.get(h);if(v===void 0)break;a[v]||(A=!1),h=r[v].parent}p[m]=A}const f=r.map((m,A)=>{const h=i[A],b=typeof m.image=="string"&&(m.image.indexOf("models/util/projectlayer")===0||m.image.indexOf("models/util/fullscreenlayer")===0);let v=Sn(m.size||"0 0"),T=h.origin;if(b){const _=(e.general||{}).orthogonalprojection,F=_&&Number(_.width),R=_&&Number(_.height);F>0&&R>0&&(v=[F,R],T=[F/2,R/2,h.origin[2]||0])}return{id:m.id!==void 0?m.id:A,name:m.name||"",visible:p[A],visibleSelf:a[A],srcObject:m,image:typeof m.image=="string"?m.image:null,model:typeof m.model=="string"?m.model:null,isSkybox:typeof m.name=="string"&&m.name.indexOf("\u5929\u7A7A\u76D2")>=0,particle:typeof m.particle=="string"?m.particle:null,instanceoverride:m.instanceoverride||null,sound:Array.isArray(m.sound)?m.sound.filter(_=>typeof _=="string"):[],soundprops:{volume:st(m.volume,1),playbackmode:m.playbackmode||"single",startsilent:nt(m.startsilent,!1),maxtime:st(m.maxtime,0),mintime:st(m.mintime,0),spatialization:nt(m.spatialization,!1),muteineditor:nt(m.muteineditor,!1)},text:typeof m.text=="string"?m.text:m.text&&typeof m.text=="object"?m.text.value:null,textScript:m.text&&typeof m.text=="object"&&m.text.script||null,textScriptProps:m.text&&typeof m.text=="object"&&m.text.scriptproperties||null,component:typeof m.component=="string"?m.component:null,isText:m.text!==void 0&&m.text!==null,textFont:typeof m.font=="string"?m.font:null,textPointsize:st(m.pointsize,24)||24,textColor:Kn(m.color),textAnchor:typeof m.anchor=="string"&&m.anchor!=="none"?m.anchor:"center",textMaxwidth:st(m.maxwidth,0),textMaxrows:st(m.maxrows,0),textLimitwidth:nt(m.limitwidth,!1),textLimitrows:nt(m.limitrows,!1),textLimituseellipsis:nt(m.limituseellipsis,!1),textHAlign:m.horizontalalign||"center",textVAlign:m.verticalalign||"center",textSpacing:m.spacing?Sn(m.spacing):[0,0],textPadding:(()=>{const _=m.padding;if(typeof _=="number")return _;const F=String(_??"").trim().split(/\s+/).map(Number).filter(R=>Number.isFinite(R));return F.length?F.reduce((R,k)=>R+k,0)/F.length:0})(),textOpaquebackground:nt(m.opaquebackground,!1),textBackgroundcolor:Kn(m.backgroundcolor),textBackgroundbrightness:st(m.backgroundbrightness,1),textCastshadow:nt(m.castshadow,!1),isSound:!!(m.sound&&m.sound.length),isComponent:!!m.component,objectScripts:(()=>{const _={};for(const F of["scale","origin","color","alpha","brightness","angles","visible"]){const R=m[F];R&&typeof R=="object"&&typeof R.script=="string"&&R.script&&(_[F]={script:R.script,scriptproperties:R.scriptproperties||null,value:R.value})}return Object.keys(_).length?_:null})(),objectAnimations:(()=>{const _={};for(const F of["scale","origin","color","alpha","brightness","angles","visible","volume","maxwidth","zoom"]){const R=m[F];R&&typeof R=="object"&&R.animation&&typeof R.animation=="object"&&R.animation.options&&(_[F]={animation:R.animation,value:R.value})}return Object.keys(_).length?_:null})(),animationLayers:(m.animationlayers||[]).filter(_=>_&&typeof _.animation=="number").map(_=>({animation:_.animation,visible:nt(_.visible,!0),additive:nt(_.additive,!1),blend:st(_.blend,1),rate:st(_.rate,1)})),solid:(()=>{if(typeof m.particle=="string")return!1;const _=typeof m.image=="string"?m.image:"";return _.indexOf("models/util/composelayer")===0?!1:_.indexOf("models/util/solidlayer")===0?!0:m.solid?!_||_.indexOf("models/util/")===0:!1})(),isContainer:typeof m.image=="string"&&m.image.indexOf("models/util/composelayer")===0,hasChildren:(u.get(m.id!==void 0?m.id:A)||0)>0,childIds:l.get(m.id!==void 0?m.id:A)||null,parentId:m.parent!==void 0&&m.parent!==null?m.parent:null,attachment:typeof m.attachment=="string"&&m.attachment!==""?m.attachment:null,passthrough:!!(m.config&&m.config.passthrough===!0),isPostProcess:b,origin:T,scale:h.scale,angles:h.angles,localOrigin:s[A].origin,localScale:s[A].scale,localAngles:s[A].angles,renderInert:Br(m),scaleRuntimeBound:m.scale!==null&&typeof m.scale=="object"&&(typeof m.scale.script=="string"||m.scale.user!==void 0),size:v,alignment:m.alignment||"center",color:Kn(m.color),alpha:st(m.alpha,1),brightness:st(m.brightness,1),copybackground:!!m.copybackground,colorBlendMode:m.colorBlendMode||0,parallaxDepth:m.parallaxDepth!==void 0?Sn(m.parallaxDepth):null,effects:(m.effects||[]).map(_=>({file:_.file||"",name:typeof _.name=="string"?_.name:"",visible:nt(_.visible,!0),visibleScript:_.visible&&typeof _.visible=="object"&&typeof _.visible.script=="string"&&_.visible.script?{script:_.visible.script,scriptproperties:_.visible.scriptproperties||null,value:!!_.visible.value}:null,passes:(_.passes||[]).map(F=>({combos:F.combos||{},constantshadervalues:F.constantshadervalues||{},textures:F.textures||[]}))}))}}),d=e.general||{},w=(()=>{const m={};for(const[A,h]of Object.entries(d))h&&typeof h=="object"&&typeof h.script=="string"&&h.script&&(m[A]={script:h.script,scriptproperties:h.scriptproperties||null,value:h.value});return Object.keys(m).length?m:null})(),M=(()=>{const m={};for(const[A,h]of Object.entries(d))h&&typeof h=="object"&&h.animation&&typeof h.animation=="object"&&h.animation.options&&(m[A]={animation:h.animation,value:h.value});return Object.keys(m).length?m:null})();{const m=new Map;for(const A of f)A.id!==void 0&&m.set(A.id,A);for(let A=0;A<8;A++){let h=!1;for(const b of f){if(b.parallaxDepth||b.parentId==null)continue;const v=m.get(b.parentId);!v||!v.parallaxDepth||v.image||v.particle||v.model||(b.parallaxDepth=v.parallaxDepth.slice(),h=!0)}if(!h)break}}return{camera:e.camera||null,general:d,generalScripts:w,generalAnimations:M,layers:f,properties:t}}function Hs(e){if(!Array.isArray(e))return;const n=new Map;for(const t of e)t&&t.id!==void 0&&t.id!==null&&n.set(t.id,t);for(const t of e){if(!t)continue;if(t.destroyed){t.visible=!1;continue}let r=t.visibleSelf!==!1,o=t.parentId;for(let i=0;r&&o!=null&&i<64;i++){const s=n.get(o);if(!s)break;(s.visibleSelf===!1||s.destroyed)&&(r=!1),o=s.parentId}t.visible=r}}function Xs(e,n){!e||!n||typeof n!="object"||e.isContainer||n.solidlayer===!0&&(e.solid=!0)}function Gs(e){return!e||typeof e.material!="string"?null:{materialPath:e.material,autosize:!!e.autosize,cropoffset:e.cropoffset?Sn(e.cropoffset):null}}function qs(e,n){if(!e||e.length===0)return;const t=new Map;for(const i of e)i&&i.id!==void 0&&i.id!==null&&t.set(i.id,i);const r=i=>{let s=0,a=i.parentId;for(let c=0;a!=null&&c<64;c++){const u=t.get(a);if(!u)break;s++,a=u.parentId}return s},o=[];for(const i of e)!i||!i.localOrigin||i.isPostProcess||n&&!n.has(i.id)||o.push(i);o.sort((i,s)=>r(i)-r(s));for(const i of o){const s=i.parentId!==void 0&&i.parentId!==null?t.get(i.parentId):null;let a;if(!s)a={origin:i.localOrigin.slice(),scale:i.localScale.slice(),angles:i.localAngles.slice()};else{const u=!(s.scaleRuntimeBound&&s.renderInert);a=Dr({origin:s.origin,scale:s.scale,angles:s.angles},{origin:i.localOrigin,scale:i.localScale,angles:i.localAngles},u)}const c=i.attachBindDelta;c&&(a.origin[0]+=c[0],a.origin[1]+=c[1]),i.origin[0]=a.origin[0],i.origin[1]=a.origin[1],i.origin[2]=a.origin[2],i.scale[0]=a.scale[0],i.scale[1]=a.scale[1],i.scale[2]=a.scale[2],i.angles[0]=a.angles[0],i.angles[1]=a.angles[1],i.angles[2]=a.angles[2],i.attachBase&&(i.attachBase[0]=a.origin[0],i.attachBase[1]=a.origin[1])}}function Ys(e,n){const t=new Set;if(!e||e.length===0)return t;const r=new Map;for(const a of e){if(!a||a.parentId===void 0||a.parentId===null)continue;const c=r.get(a.parentId);c?c.push(a):r.set(a.parentId,[a])}const o=["origin","scale","angles"],i=[];for(const a of e){if(!a||a.id===void 0||a.id===null)continue;const c=a.objectScripts||null,u=a.objectAnimations||null;o.some(p=>c&&c[p]||u&&u[p])&&i.push(a)}if(n)for(const a of n)a&&a.id!==void 0&&a.id!==null&&i.push(a);const s=i.slice();for(let a=0;s.length>0&&a<1e5;a++){const c=s.pop();if(!c||c.id===void 0||c.id===null||t.has(c.id))continue;t.add(c.id);const u=r.get(c.id);if(u)for(const l of u)s.push(l)}return t}const Zs=Object.freeze(Object.defineProperty({__proto__:null,applySolidFromModel:Xs,collectTransformDirty:Ys,composeChildTransform:Dr,isRenderInert:Br,parseBool:nt,parseColor:Kn,parseNum:st,parseScene:Ws,parseVec2:Sn,parseVec3:dn,recomposeWorld:qs,recomputeLayerVisibility:Hs,resolveMaterial:Gs},Symbol.toStringTag,{value:"Module"}));function Ks(e,n,t){const r=Cr(e,n.file);if(r===null)return;let o;try{o=JSON.parse(t(r))}catch{return}n.fbos=o.fbos||[],n.materialPasses=(o.passes||[]).map(i=>{if(!i.material)return{shader:null,copyCommand:!0,target:i.target||null,source:i.source||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const s=Cr(e,i.material);if(s===null)return{shader:null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:"normal",textures:[],combos:{},constants:{}};const a=JSON.parse(t(s)),c=a.passes&&a.passes[0]||{};return{shader:c.shader||null,copyCommand:!1,target:i.target||null,binds:i.bind||[],blending:c.blending||"normal",textures:c.textures||[],combos:c.combos||{},constants:c.constantshadervalues||{}}})}const Qs={"models/util/solidlayer.json":{material:"materials/util/solidlayer.json"},"models/util/composelayer.json":{material:"materials/util/solidlayer.json"},"models/util/fullscreenlayer.json":{material:"materials/util/solidlayer.json"},"models/util/projectlayer.json":{material:"materials/util/solidlayer.json"}};function Po(e){if(!e||typeof e!="string")return!0;const n=e.toLowerCase();return n==="generic"||n==="sprite"||n==="flat"||n.startsWith("genericimage")}function Js(e,n){return!e||!n||!n.shader||Po(n.shader)||(e.effects=e.effects||[],e.effects.some(t=>t.layerMaterial))?!1:(e.effects.unshift({file:"",name:"_layerMaterial",visible:!0,layerMaterial:!0,passes:[{combos:n.combos||{},constantshadervalues:n.constantshadervalues||{},textures:n.textures||[]}],materialPasses:[{shader:n.shader,copyCommand:!1,target:null,binds:[],blending:n.blending||"normal",textures:n.textures||[],combos:n.combos||{},constants:n.constantshadervalues||{}}],fbos:[]}),!0)}const ea=Object.freeze(Object.defineProperty({__proto__:null,BUILTIN_MATERIALS:{"materials/util/solidlayer.json":{passes:[{shader:"flat",blending:"translucent",cullmode:"nocull",depthtest:"disabled",depthwrite:"disabled",textures:[],combos:{}}]}},BUILTIN_MODELS:Qs,attachLayerMaterialEffect:Js,isBuiltinAlbedoShader:Po,resolveEffectChain:Ks},Symbol.toStringTag,{value:"Module"}));function pn(){return new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1])}function xt(e,n){const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++){let i=0;for(let s=0;s<4;s++)i+=e[s*4+o]*n[r*4+s];t[r*4+o]=i}return t}function hn(e,n,t,r,o,i){const s=pn();return s[0]=2/(n-e),s[5]=2/(r-t),s[10]=-2/(i-o),s[12]=-(n+e)/(n-e),s[13]=-(r+t)/(r-t),s[14]=-0/(i-o),s}function mn(e,n,t,r){return xt(e,new Float32Array([1,0,0,0,0,1,0,0,0,0,1,0,n,t,r,1]))}function Co(e){const n=new Float32Array(16);for(let t=0;t<4;t++)for(let r=0;r<4;r++)n[r*4+t]=e[t*4+r];return n}function En(e,n,t,r){return xt(e,new Float32Array([n,0,0,0,0,t,0,0,0,0,r,0,0,0,0,1]))}function Lo(e,n){const t=Math.cos(n),r=Math.sin(n);return xt(e,new Float32Array([t,r,0,0,-r,t,0,0,0,0,1,0,0,0,0,1]))}function ta(e,n){const t=Math.cos(n),r=Math.sin(n);return xt(e,new Float32Array([1,0,0,0,0,t,r,0,0,-r,t,0,0,0,0,1]))}function na(e,n){const t=Math.cos(n),r=Math.sin(n);return xt(e,new Float32Array([t,0,-r,0,0,1,0,0,r,0,t,0,0,0,0,1]))}function ra(e,n,t,r){const o=1/Math.tan(e*Math.PI/180/2),i=new Float32Array(16);return i[0]=o/(n||1),i[5]=o,i[10]=(r+t)/(t-r),i[11]=-1,i[14]=2*r*t/(t-r),i}function Qn(e,n){const t=e&&typeof e=="object"?e.value:e;return typeof t=="number"&&Number.isFinite(t)?t:n}function oa(e){const n=e&&e.general;return!n||n.orthogonalprojection?!1:Qn(n.fov,0)>0}function ia(e,n){return n&&n.perspective&&e&&e.isSkybox&&n.eye?n.eye:e.origin}function sa(e,n,t){const r=Fo([e[0]-n[0],e[1]-n[1],e[2]-n[2]]),o=Fo(ko(t,r)),i=ko(r,o),s=new Float32Array([o[0],i[0],r[0],0,o[1],i[1],r[1],0,o[2],i[2],r[2],0,0,0,0,1]);return s[12]=-(o[0]*e[0]+o[1]*e[1]+o[2]*e[2]),s[13]=-(i[0]*e[0]+i[1]*e[1]+i[2]*e[2]),s[14]=-(r[0]*e[0]+r[1]*e[1]+r[2]*e[2]),s}function aa(e,n,t,r){const o=e[3]*n+e[7]*t+e[11]*r+e[15];return[(e[0]*n+e[4]*t+e[8]*r+e[12])/o,(e[1]*n+e[5]*t+e[9]*r+e[13])/o,(e[2]*n+e[6]*t+e[10]*r+e[14])/o]}const ca=[[16,9],[16,10],[21,9],[32,9]];function la(e,n,t,r,o){const i=e/n;if(!Number.isFinite(i)||i<=0||!(t>0)||!(r>0))return null;const s=.02,a=t/r;if(Math.abs(i-a)<=s*a)return{viewW:t,viewH:r};for(const[c,u]of ca){const l=c/u;if(Math.abs(i-l)>s*l)continue;const p=r,f=r*l;return f>t+1e-6?{viewW:t,viewH:t/l}:{viewW:f,viewH:p}}return null}function Ir(e,n,t,r,o,i,s){const a=Ro(i),c=Ro(s);if(e==="cover"){const u=la(r,o,n,t);if(u)return{offX:(n-u.viewW)*a,offY:(t-u.viewH)*c,viewW:u.viewW,viewH:u.viewH};const l=Math.max(r/n,o/t),p=r/l,f=o/l;return{offX:(n-p)*a,offY:(t-f)*c,viewW:p,viewH:f}}if(e==="contain"){const u=r/o;if(n/t>u){const d=n,w=n/u;return{offX:0,offY:(t-w)/2,viewW:d,viewH:w}}const p=t,f=t*u;return{offY:0,offX:(n-f)/2,viewW:f,viewH:p}}return{offX:0,offY:0,viewW:n,viewH:t}}function ua(e,n,t,r,o,i){const s=e.general,a=e.camera,c=a&&a.eye?Or(a.eye):[0,0,0],u=a&&a.center?Or(a.center):[0,0,-1],l=a&&a.up?Or(a.up):[0,1,0];if(oa(e)){const b=t>0?n/t:1.7777777777777777,v=Qn(s.fov,50),T=Math.max(Qn(s.nearz,.01),1e-4),_=Math.max(Qn(s.farz,1e4),T+1),F=sa(c,u,l),R=ra(v,b,T,_);return{view:F,projection:R,eye:c,center:u,projW:b,projH:1,offX:0,offY:0,viewW:b,viewH:1,perspective:!0}}const p=pn(),f=s&&s.orthogonalprojection&&s.orthogonalprojection.width||n,d=s&&s.orthogonalprojection&&s.orthogonalprojection.height||t,w=Ir(r,f,d,n,t,o,i),M=e&&e.cameraTransforms?e.cameraTransforms.zoom:s&&s.zoom,m=M&&typeof M=="object"?M.value:M,A=Number(m);if(Number.isFinite(A)&&A>0&&Math.abs(A-1)>1e-6){const b=w.offX+w.viewW/2,v=w.offY+w.viewH/2,T=w.viewW/A,_=w.viewH/A;w.offX=b-T/2,w.offY=v-_/2,w.viewW=T,w.viewH=_}const h=hn(w.offX,w.offX+w.viewW,w.offY+w.viewH,w.offY,-1e4,1e4);return{view:p,projection:h,eye:c,projW:f,projH:d,offX:w.offX,offY:w.offY,viewW:w.viewW,viewH:w.viewH,perspective:!1}}function Ro(e){const n=Number(e);return Number.isFinite(n)?n<0?0:n>1?1:n:.5}function Or(e){return String(e).trim().split(/\s+/).map(Number)}function Fo(e){const n=Math.hypot(e[0],e[1],e[2])||1;return[e[0]/n,e[1]/n,e[2]/n]}function ko(e,n){return[e[1]*n[2]-e[2]*n[1],e[2]*n[0]-e[0]*n[2],e[0]*n[1]-e[1]*n[0]]}function gn(e){const n=Number(e);return Number.isFinite(n)?n*.5:0}function fa(e){const n=new Map,t=new Map,r=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\(([^)]*)\))?[ \t]*(.*)$/gm;let o;for(;(o=r.exec(e))!==null;){const i=s=>s.replace(/\/\/.*$/,"").replace(/\/\*[\s\S]*?\*\//g,"").trim();o[2]!==void 0?t.set(o[1],{args:o[2].split(",").map(s=>s.trim()).filter(Boolean),body:i(o[3])}):n.set(o[1],i(o[3]))}return{defs:n,fns:t}}function da(e,n,t,r){const o=[];let i=0;for(;i<e.length;){const s=e.indexOf(n,i);if(s===-1){o.push(e.slice(i));break}o.push(e.slice(i,s));let c=s+n.length;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]!=="("){o.push(e.slice(s,c)),i=c;continue}let u=0,l=c;for(;l<e.length;l++)if(e[l]==="(")u++;else if(e[l]===")"&&(u--,u===0))break;if(l>=e.length){o.push(e.slice(s));break}const p=e.slice(c+1,l),f=St(p);let d=t.body;t.args.forEach((w,M)=>{const m=f[M]!==void 0?f[M].trim():"";d=Pn(d,w,m)}),r>0&&(d=No(d,r-1)),o.push("("+d+")"),i=l+1}return o.join("")}function Pn(e,n,t){return e.replace(new RegExp("\\b"+n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b","g"),t)}function St(e){const n=[];let t=0,r="";for(let o=0;o<e.length;o++){const i=e[o];i==="("?t++:i===")"&&t--,i===","&&t===0?(n.push(r),r=""):r+=i}return r.trim()!==""&&n.push(r),n}function No(e,n){for(let t=0;t<12;t++){const{defs:r,fns:o}=fa(e);if(r.size===0&&o.size===0)break;const i=e.split(`
|
|
2
|
+
`),s=new Map;for(let u=0;u<i.length;u++){const l=/^[ \t]*#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)/.exec(i[u]);l&&!s.has(l[1])&&s.set(l[1],u)}const a=new Map;{const u="(?:float|int|bool|vec[234]|ivec[234]|bvec[234]|mat[234])";for(const l of r.keys()){const p=l.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),f=new RegExp("^\\s*(?:const\\s+|uniform\\s+|varying\\s+|in\\s+|out\\s+|attribute\\s+)*"+u+"\\s+"+p+"\\s*[=;]");for(let d=0;d<i.length;d++)if(f.test(i[d])){a.set(l,d);break}}}let c=!1;for(let u=0;u<i.length;u++){const l=i[u];if(/^[ \t]*#/.test(l))continue;let p=l;for(const[f,d]of r){const w=s.get(f);if(w!==void 0&&u<w||a.get(f)===u)continue;new RegExp("\\b"+f.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b").test(p)&&(p=Pn(p,f,d),c=!0)}for(const[f,d]of o){const w=s.get(f);w!==void 0&&u<w||p.includes(f)&&(p=da(p,f,d,n),c=!0)}i[u]=p}if(e=i.join(`
|
|
3
|
+
`),!c)break}return e}function Uo(e,n,t){const r=d=>n[d]!==void 0?String(n[d]):t.has(d)?"("+t.get(d)+")":"0";let o=e.replace(/\b[A-Za-z_][A-Za-z0-9_]*\b/g,d=>r(d)),i=0;function s(){for(;i<o.length&&/\s/.test(o[i]);)i++}function a(){let d=c();for(s();o.startsWith("||",i);){i+=2;const w=c();d=d||w,s()}return d}function c(){let d=u();for(s();o.startsWith("&&",i);){i+=2;const w=u();d=d&&w,s()}return d}function u(){let d=l();for(s();o.startsWith("==",i)||o.startsWith("!=",i);){const w=o[i]==="="?"==":"!=";i+=2;const M=l();d=w==="=="?d===M:d!==M,s()}return d}function l(){let d=p();for(s();/^[<>]/.test(o[i]||"");){let w=o[i];o[i+1]==="="&&(w+="=",i++),i++;const M=p();w==="<"?d=d<M:w===">"?d=d>M:w==="<="?d=d<=M:d=d>=M,s()}return d}function p(){return s(),o[i]==="!"?(i++,!p()):f()}function f(){if(s(),o[i]==="("){i++;const w=a();return s(),i++,w}const d=/^-?\d+(\.\d+)?/.exec(o.slice(i));return d?(i+=d[0].length,Number(d[0])):!1}return a()}function Bo(e){let n="",t=0;const r=e.length;for(;t<r;){const o=e[t],i=e[t+1];if(o==="/"&&i==="*"){for(t+=2;t<r&&!(e[t]==="*"&&e[t+1]==="/");)e[t]===`
|
|
4
4
|
`&&(n+=`
|
|
5
5
|
`),t++;t+=2;continue}if(o==="/"&&i==="/"){for(;t<r&&e[t]!==`
|
|
6
|
-
`;)t++;continue}n+=o,t++}return n}function
|
|
7
|
-
`),i=[],s=[],
|
|
8
|
-
`)}function Mn(e){return e.every(n=>n.parent&&n.hit)}function Qn(e,n,t,r){let o=0;for(let i=n;i<e.length;i++)if(e[i]===t)o++;else if(e[i]===r&&(o--,o===0))return i;return-1}function To(e,n){return Qn(e,n,"(",")")}const js=new Set(["void","bool","int","uint","float","double","vec2","vec3","vec4","bvec2","bvec3","bvec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","mat2","mat3","mat4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4"]);function Ws(e,n){let t=n-1;for(;t>=0&&/[ \t]/.test(e[t]);)t--;if(t<0||t===n-1)return!1;let r=t+1;for(;t>=0&&/[A-Za-z0-9_]/.test(e[t]);)t--;const o=e.slice(t+1,r);return js.has(o)}function Be(e,n,t){let r="",o=0;for(;o<e.length;){const i=e.indexOf(n,o);if(i===-1){r+=e.slice(o);break}if(i>0&&/[A-Za-z0-9_]/.test(e[i-1])){r+=e.slice(o,i+1),o=i+1;continue}const s=i+n.length;if(s<e.length&&/[A-Za-z0-9_]/.test(e[s])){r+=e.slice(o,s),o=s;continue}if(Ws(e,i)){r+=e.slice(o,s),o=s;continue}r+=e.slice(o,i);let c=i+n.length;for(;c<e.length&&/\s/.test(e[c]);)c++;if(e[c]!=="("){r+=e.slice(i,c),o=c;continue}const a=To(e,c);if(a===-1){r+=e.slice(i);break}const u=e.slice(c+1,a);r+=t(u,i),o=a+1}return r}function So(e,n,t,r,o){const i=e;e=_o(e);const s={},c=/\[COMBO\][^\n]*?"combo"\s*:\s*"([^"]+)"[^\n]*?"default"\s*:\s*(-?\d+)/g;let a;if(typeof o=="string"&&o){const g=new RegExp(c.source,"g");let v;for(;(v=g.exec(o))!==null;)s[v[1]]=Number(v[2])}for(;(a=c.exec(i))!==null;)s[a[1]]=Number(a[2]);const u={GLSL:1,...s,...t||{}};let l=Ao(e,u,r);l=wo(l,20),l=l.replace(/^[ \t]*#define[^\n]*\n?/gm,"");{const g=new Set,v=/\[COMBO\][^\n]*"combo"\s*:\s*"([^"]+)"/g;let b;for(;(b=v.exec(i))!==null;)g.add(b[1]);for(const y of Object.keys(u))g.add(y);g.delete("GLSL");for(const y of g){const S=u[y]!==void 0?u[y]:0;l=wn(l,y,String(S))}}l=wn(l,"sample","smp"),l=l.replace(/(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[fh]\b/g,"$1"),l=l.replace(/\bfloat4x4\b/g,"mat4").replace(/\bfloat3x3\b/g,"mat3").replace(/\bfloat2x2\b/g,"mat2").replace(/\bfloat4\b/g,"vec4").replace(/\bfloat3\b/g,"vec3").replace(/\bfloat2\b/g,"vec2").replace(/\bhalf4\b/g,"vec4").replace(/\bhalf3\b/g,"vec3").replace(/\bhalf2\b/g,"vec2").replace(/\bhalf\b/g,"float"),l=l.replace(/\btexSample2DLod\b/g,"textureLod").replace(/\btexSample2D\b/g,"texture"),l=Be(l,"saturate",g=>"clamp("+g+", 0.0, 1.0)"),l=Be(l,"CAST4",g=>"vec4("+g+")"),l=Be(l,"CAST3",g=>"vec3("+g+")"),l=Be(l,"CAST2",g=>"vec2("+g+")"),l=l.replace(/\b(max|min)\(\s*(-?\d+(?:\.\d+)?)\s*,\s*([A-Za-z_]\w*\.(rgb|xyz|rg|xy|r|x))\s*\)/g,(g,v,b,y,S)=>{const _=S.length;return v+"(vec"+_+"("+b+"), "+y+")"}),l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*([A-Za-z_][A-Za-z0-9_]*)/g,"$1$2.0 $3 $4"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(\d+\.\d+)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))/g,"$1$2.0 $3 $4");{const g=new Set,v=/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?(?:float|vec2|vec3|vec4|mat2|mat3|mat4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);if(g.size>0){const y=Array.from(g).sort((S,_)=>_.length-S.length).join("|");l=l.replace(new RegExp("(^|[^\\w.])(\\d+)\\s*([+-])\\s*("+y+")(?![A-Za-z0-9_])","g"),"$1$2.0 $3 $4")}}{const g=["smoothstep","step","mix","clamp","max","min","pow","mod","atan","sqrt","inversesqrt","exp","log","exp2","log2","abs","sign","floor","ceil","fract","length","distance","dot","reflect","refract","faceforward","normalize","cross"],v=/\b(ApplyBlending|ApplyComposite|BlendTransparency)\s*\(/;for(const b of g)l=Be(l,b,y=>{const _=kt(y).map(C=>{if(v.test(C))return C;const N=[];let D=C.replace(/\[[^\]]*\]/g,k=>(N.push(k),"\0"+(N.length-1)+"\0")).replace(/\b(?:ivec[234]|uvec[234]|int|uint)\s*\([^()]*\)/g,k=>(N.push(k),"\0"+(N.length-1)+"\0"));return D=D.replace(/(?<![A-Za-z0-9_.\u0000])(\d+)(?![.\d])(?![A-Za-z_])/g,"$1.0"),D.replace(/\u0000(\d+)\u0000/g,(k,O)=>N[Number(O)])});return b+"("+_.join(",")+")"});l=Be(l,"pow",b=>{const y=kt(b);if(y.length!==2)return"pow("+b+")";const S=y[0].trim(),_=y[1].trim(),C=/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\s*$/.exec(S),D=C?{xyzw:4,rgba:4,xyz:3,rgb:3,xy:2,rg:2,zw:2}[C[1]]:0,k=/\bvec[234]\s*\(/.test(_)||/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\b/.test(_);return D>=2&&!k?"pow("+S+", vec"+D+"("+_+"))":"pow("+S+", "+_+")"})}l=l.replace(/([)\]])\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/\)\s*([+-])\s*(\d+)(?![\d.])/g,") $1 $2.0"),l=l.replace(/(^|[^\w.])(\d+)(?![.\d])\s*([+-])\s*((?:step|smoothstep|mix|mod|fract|abs|sin|cos|tan|atan|sqrt|pow|inversesqrt|floor|ceil|sign|length|normalize|distance|dot|cross|exp|log|exp2|log2|clamp|min|max)\s*\()/g,"$1$2.0 $3 $4");{const g=new Set,v=/\b(?:vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);if(g.size>0){const y=Array.from(g).sort((S,_)=>_.length-S.length).join("|");l=l.replace(new RegExp("\\b("+y+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}{const g=new Set,v=/\b(?:int|uint)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);l=l.replace(/\buint\b/g,"int"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*%\s*(\d+)(?![\d.])/g,(y,S,_)=>g.has(S)?y:"mod("+S+", "+_+".0)"),l=l.replace(/\bint\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*mod\(([^;]*)\);/g,"int $1 = int(mod($2));")}l=l.replace(/\b(vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([^;()\n,]+);/g,(g,v,b,y)=>{const S=y.trim();return/^(vec[234]|mat[234]|int\b|float\b)/.test(S)?g:v+" "+b+" = "+v+"("+S+");"});for(const g of["mix","clamp","step","smoothstep","min","max","mod","pow"])l=Be(l,g,v=>g+"("+v.replace(/(?<![A-Za-z0-9_.])(\d+)(?![.\d])/g,"$1.0")+")");l=Be(l,"clamp",g=>{const v=kt(g);if(v.length!==3)return"clamp("+g+")";const b=v[0].trim(),y=v[1].trim(),S=_=>/^-?\d+\.?\d*$/.test(_);return S(b)&&S(y)&&Number(b)===0&&Number(y)===1?"clamp("+v[2].trim()+", "+b+", "+y+")":"clamp("+g+")"}),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([)\]])\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=Be(l,"smoothstep",g=>{const v=kt(g);return v.length===3&&v[1].trim()==="0.0"&&v[0].trim()!=="0.0"?"(1.0 - smoothstep(0.0, "+v[0].trim()+", "+v[2].trim()+"))":"smoothstep("+g+")"});{const g=new Map,v=/\b(?:uniform|varying|attribute|in|out)?\s*\b(vec([234]))\s+([A-Za-z_]\w*)/g;let b;for(;(b=v.exec(l))!==null;)g.set(b[3],Number(b[2]));if(g.size>0){const y={2:"xy",3:"xyz",4:"xyzw"};l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)\s*;/g,(S,_,C,N)=>{const D=g.get(C),k=g.get(N);return!D||!k||D>=k?S:_+C+" = "+N+"."+y[D]+";"})}if(g.size>0){const y=new Set,S=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let _;for(;(_=S.exec(l))!==null;)y.add(_[1]);const C="pow|saturate|clamp|smoothstep|step|abs|floor|ceil|fract|frac|sin|cos|tan|asin|acos|atan|sqrt|length|distance|dot|exp|log|sign|fmod|mod|min|max|mix|lerp",N=/^(?:length|distance|dot)$/,D=O=>{const j=O.match(new RegExp("^(?:"+C+")\\s*\\("));if(!j)return!1;let W=0;const K=j[0].length-1;let V=-1;for(let q=K;q<O.length;q++)if(O[q]==="(")W++;else if(O[q]===")"&&(W--,W===0)){V=q;break}if(V!==O.length-1)return!1;const G=j[0].replace(/\s*\($/,"");if(N.test(G))return!0;const Q=O.slice(K+1,V);if(/\bvec[234]\s*\(/.test(Q)||/\.[xyzwrgba]{2,4}\b/.test(Q))return!1;for(const q of g.keys()){const te=q.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp("(?<!\\.)\\b"+te+"\\b(?!\\s*\\.[xyzwrgba]\\b)").test(Q))return!1}return!0},k=new Set;if(l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(O,j,W,K)=>{const V=g.get(W);if(!V)return O;const G=K.trim();if(new RegExp("^vec"+V+"\\s*\\(").test(G)||g.has(G))return O;const Q=/^-?\d+(?:\.\d+)?(?:e[-+]?\d+)?$/i.test(G),q=y.has(G);return!Q&&!q&&!D(G)?O:(k.add(W),j+W+" = vec"+V+"("+G+");")}),k.size>0){const O=[...k].sort((j,W)=>W.length-j.length).join("|");l=l.replace(new RegExp(`\\b([A-Za-z_]\\w*)\\s*([*/])\\s*(${O})\\b`,"g"),(j,W,K,V)=>g.has(W)?j:`${W} ${K} ${V}.x`),l=l.replace(new RegExp(`\\b(${O})\\s*([*/])\\s*([A-Za-z_]\\w*)\\b`,"g"),(j,W,K,V)=>g.has(V)?j:`${W}.x ${K} ${V}`)}}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*=\s*)(-?\d+)\s*;/g,"$1$2.0;"),l=l.replace(/\b(float|vec2|vec3|vec4)\s+([A-Za-z_]\w*)\s*=\s*(-?\d+)\s*;/g,(g,v,b,y)=>v==="float"?`${v} ${b} = ${y}.0;`:`${v} ${b} = ${v}(${y}.0);`);{const g=new Set,v=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);if(g.size>0){const y=[...g].sort((S,_)=>_.length-S.length).join("|");l=l.replace(new RegExp(`\\b(${y})\\s*=\\s*(-?\\d+)\\s*;`,"g"),"$1 = $2.0;"),l=l.replace(new RegExp(`\\b(${y})\\s*([-+*/]=)\\s*(-?\\d+)\\s*;`,"g"),"$1 $2 $3.0;")}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*[-+*/]=\s*)(-?\d+)\s*;/g,"$1$2.0;");const d="step|smoothstep|saturate|clamp|mix|lerp|frac|fract|abs|floor|ceil|min|max|pow|sqrt|length|dot|distance";l=l.replace(new RegExp(`\\bint\\s+([A-Za-z_]\\w*)\\s*=\\s*((?:${d})\\s*\\()`,"g"),"float $1 = $2");{const g=new Set,v=/\bbool\s+([A-Za-z_]\w*)\s*=/g;let b;for(;(b=v.exec(l))!==null;)g.add(b[1]);if(g.size>0){const y=[...g].join("|");l=l.replace(new RegExp(`([-+*/]=\\s*)(${y})\\b`,"g"),(S,_,C)=>`${_}float(${C})`)}}{const g=new Set;for(const v of l.matchAll(/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?float\s+([A-Za-z_]\w*)\s*\[/g))g.add(v[1]);if(g.size){const v=[...g].sort((C,N)=>N.length-C.length).join("|"),b=new RegExp("\\b("+v+")\\s*\\[","g");let y="",S=0,_;for(;_=b.exec(l);){const C=_.index+_[0].length-1,N=Qn(l,C,"[","]");if(N<0)break;let D=N+1;for(;D<l.length&&/[ \t]/.test(l[D]);)D++;if(l[D]!=="["){b.lastIndex=N+1;continue}const k=Qn(l,D,"[","]");if(k<0)break;const O=l.slice(C+1,N),j=l.slice(D+1,k);y+=l.slice(S,_.index),y+=_[1]+"[int(("+O+")) * 4 + int(("+j+"))]",S=k+1,b.lastIndex=S}l=y+l.slice(S)}}l=Be(l,"mix",(g,v)=>{const b=kt(g);if(b.length!==3)return"mix("+g+")";const y=D=>{const k=D.trim(),O=/\.([xyzwrgba]{1,4})\s*$/.exec(k);if(O)return O[1].length;const j=/^vec([234])\s*\(/.exec(k);if(j)return Number(j[1]);if(!/^[A-Za-z_]\w*$/.test(k))return 0;const W=new RegExp("\\b(vec([234])|float)\\s+"+k+"\\b","g");let K=0,V;for(;(V=W.exec(l))!==null&&V.index<v;)K=V[1].startsWith("vec")?Number(V[2]):1;return K},S=b[0].trim(),_=b[1].trim(),C=y(S),N=y(_);if(C>=2&&N>=2&&C!==N){const D=Math.min(C,N),k=D===2?".xy":D===3?".xyz":"";return k?"mix("+(C>D?S+k:S)+", "+(N>D?_+k:_)+", "+b[2].trim()+")":"mix("+g+")"}return"mix("+g+")"});{const g=/\b(vec([234]))\s+([A-Za-z_]\w*)\s*\(/g;let v="",b=0,y;for(;y=g.exec(l);){const S=To(l,y.index+y[0].length-1);if(S<0)break;let _=S+1;for(;_<l.length&&/\s/.test(l[_]);)_++;if(l[_]!=="{")continue;const C=Qn(l,_,"{","}");if(C<0)break;const N=Number(y[2]);if(N>=4){g.lastIndex=C;continue}let D=l.slice(_+1,C);const k=new Map;for(const j of l.slice(0,y.index).matchAll(/\buniform\s+(?:highp|mediump|lowp\s+)?(vec([234]))\s+([A-Za-z_]\w*)/g))k.set(j[3],Number(j[2]));for(const j of D.matchAll(/\b(vec([234]))\s+([A-Za-z_]\w*)/g))k.set(j[3],Number(j[2]));const O=N===2?"xy":"xyz";D=D.replace(/\breturn\s+([A-Za-z_]\w*)\s*;/g,(j,W)=>{const K=k.get(W);return K&&K>N?"return "+W+"."+O+";":j}),v+=l.slice(b,_+1)+D,b=C,g.lastIndex=C}l=v+l.slice(b)}const h=new Set,p=/\b(?:uniform\s+)?(?:mat4|mat3|mat2|float4x4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let w;for(;(w=p.exec(l))!==null;)h.add(w[1]);if(l=Be(l,"mul",g=>{const v=kt(g);if(v.length!==2)return"mul("+g+")";const b=v[0].trim(),y=v[1].trim(),S=_=>h.has(_.split(/[\[.\s]/)[0])||/^mat[234]\(/.test(_);return S(b)&&S(y)?"(transpose("+y+") * transpose("+b+"))":S(y)?"(transpose("+y+") * "+b+")":"("+b+" * "+y+")"}),l=l.replace(/\blerp\b/g,"mix").replace(/\bfrac\b/g,"fract"),l=Be(l,"atan2",g=>"atan("+g+")"),l=Be(l,"fmod",g=>{const v=kt(g);if(v.length!==2)return"mod("+g+")";const b=v[0].trim(),y=v[1].trim();return"(("+b+") - ("+y+") * trunc(("+b+") / ("+y+")))"}),l=Be(l,"ddx",g=>"dFdx("+g+")"),l=Be(l,"ddy",g=>"dFdy("+g+")"),l=Be(l,"CAST3X3",g=>"mat3("+g+")"),n==="vert")l=l.replace(/\battribute\b/g,"in").replace(/\bvarying\b/g,"out");else{if(l=l.replace(/\bvarying\b/g,"in").replace(/\battribute\b/g,"in"),typeof o=="string"&&o){const b=new Map,y=/^\s*(?:varying|out)\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let S;for(;(S=y.exec(o))!==null;)b.set(S[2],S[1]);const _={float:1,vec2:2,vec3:3,vec4:4},C=new Map;if(l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(N,D,k,O,j,W)=>{const K=b.get(j);return!K||_[K]<=_[k]?N:(C.set(j,_[k]),D+K+O+j+W)}),C.size>0){const N={1:"x",2:"xy",3:"xyz"};for(const[D,k]of C){const O=N[k];O&&(l=l.split(`
|
|
9
|
-
`).
|
|
10
|
-
`))}}}const g=new Set,v=new Set;{const b=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let y;for(;(y=b.exec(l))!==null;)v.add(y[2])}for(const b of v)new RegExp("\\b"+b+"\\b\\s*(?:\\.[xyzwrgba]{1,4})?\\s*(?:[-+*/]?=(?!=)|\\+\\+|--)").test(l)&&g.add(b);if(g.size>0){const b=l.search(/\bvoid\s+main\s*\([^)]*\)\s*\{/);if(b!==-1){const y=l.indexOf("{",b),S=l.slice(0,y+1);let _=l.slice(y+1);const C=[];for(const N of g){const D=new RegExp("^\\s*in\\s+(?:highp|mediump|lowp\\s+)?(vec[234]|float)\\s+"+N+"\\s*;","m").exec(l),k=D?D[1]:"vec4";C.push(" "+k+" "+N+"_rw = "+N+";"),_=wn(_,N,N+"_rw")}_=`
|
|
11
|
-
|
|
6
|
+
`;)t++;continue}n+=o,t++}return n}function Do(e,n,t,r){const o=e.split(`
|
|
7
|
+
`),i=[],s=[],a=new Map;for(let c=0;c<o.length;c++){const u=o[c],l=u.trim();if(l.startsWith("#include")){if(Cn(s)){const p=/^#include[ \t]+"([^"]+)"|^#include[ \t]+<([^>]+)>/.exec(l),f=p&&(p[1]||p[2]),d=f&&t?t(f):null;d!=null?i.push(Do(Bo(d),n,t)):i.push("// [include \u7F3A\u5931: "+f+"]")}continue}if(l.startsWith("#define")){if(Cn(s)){i.push(u);const p=/^#define[ \t]+([A-Za-z_][A-Za-z0-9_]*)(?:\([^)]*\))?[ \t]*(.*)$/.exec(l);p&&a.set(p[1],p[2].trim())}continue}if(l.startsWith("#undef")){Cn(s)&&i.push(u);continue}if(l.startsWith("#ifdef")||l.startsWith("#ifndef")||l.startsWith("#if")){const p=Cn(s);let f=!1;if(l.startsWith("#ifdef")){const d=l.slice(6).trim().split(/\s+/)[0];f=n[d]!==void 0||a.has(d)}else if(l.startsWith("#ifndef")){const d=l.slice(7).trim().split(/\s+/)[0];f=!(n[d]!==void 0||a.has(d))}else try{f=!!Uo(l.slice(3).trim(),n,a)}catch{f=!1}s.push({parent:p,hit:f,done:f});continue}if(l.startsWith("#else")){if(s.length>0){const p=s[s.length-1];p.hit=!p.done,p.done=!0}continue}if(l.startsWith("#elif")){if(s.length>0){const p=s[s.length-1];if(p.done)p.hit=!1;else{let f=!1;try{f=!!Uo(l.slice(5).trim(),n,a)}catch{f=!1}p.hit=f,p.done=f}}continue}if(l.startsWith("#endif")){s.length>0&&s.pop();continue}l.startsWith("#")||Cn(s)&&i.push(u)}return i.join(`
|
|
8
|
+
`)}function Cn(e){return e.every(n=>n.parent&&n.hit)}function Jn(e,n,t,r){let o=0;for(let i=n;i<e.length;i++)if(e[i]===t)o++;else if(e[i]===r&&(o--,o===0))return i;return-1}function Io(e,n){return Jn(e,n,"(",")")}const pa=new Set(["void","bool","int","uint","float","double","vec2","vec3","vec4","bvec2","bvec3","bvec4","ivec2","ivec3","ivec4","uvec2","uvec3","uvec4","mat2","mat3","mat4","mat2x2","mat2x3","mat2x4","mat3x2","mat3x3","mat3x4","mat4x2","mat4x3","mat4x4"]);function ha(e,n){let t=n-1;for(;t>=0&&/[ \t]/.test(e[t]);)t--;if(t<0||t===n-1)return!1;let r=t+1;for(;t>=0&&/[A-Za-z0-9_]/.test(e[t]);)t--;const o=e.slice(t+1,r);return pa.has(o)}function Oo(e){const n=new Set;let t;const r=/\b(?:const\s+)?int\s+([A-Za-z_]\w*)\s*[=;)\u0003]/g;for(;(t=r.exec(e))!==null;)n.add(t[1]);return n}function ze(e,n,t){let r="",o=0;for(;o<e.length;){const i=e.indexOf(n,o);if(i===-1){r+=e.slice(o);break}if(i>0&&/[A-Za-z0-9_]/.test(e[i-1])){r+=e.slice(o,i+1),o=i+1;continue}const s=i+n.length;if(s<e.length&&/[A-Za-z0-9_]/.test(e[s])){r+=e.slice(o,s),o=s;continue}if(ha(e,i)){r+=e.slice(o,s),o=s;continue}r+=e.slice(o,i);let a=i+n.length;for(;a<e.length&&/\s/.test(e[a]);)a++;if(e[a]!=="("){r+=e.slice(i,a),o=a;continue}const c=Io(e,a);if(c===-1){r+=e.slice(i);break}const u=e.slice(a+1,c);r+=t(u,i),o=c+1}return r}function $o(e,n,t,r,o){const i=e;e=Bo(e);const s={},a=/\[COMBO\][^\n]*?"combo"\s*:\s*"([^"]+)"[^\n]*?"default"\s*:\s*(-?\d+)/g;let c;if(typeof o=="string"&&o){const h=new RegExp(a.source,"g");let b;for(;(b=h.exec(o))!==null;)s[b[1]]=Number(b[2])}for(;(c=a.exec(i))!==null;)s[c[1]]=Number(c[2]);const u={GLSL:1,...s,...t||{}};let l=Do(e,u,r);l=No(l,20),l=l.replace(/^[ \t]*#define[^\n]*\n?/gm,"");{const h=new Set,b=/\[COMBO\][^\n]*"combo"\s*:\s*"([^"]+)"/g;let v;for(;(v=b.exec(i))!==null;)h.add(v[1]);for(const T of Object.keys(u))h.add(T);h.delete("GLSL");for(const T of h){const _=u[T]!==void 0?u[T]:0;l=Pn(l,T,String(_))}}l=Pn(l,"sample","smp"),l=l.replace(/(\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)[fh]\b/g,"$1"),l=l.replace(/\bfloat4x4\b/g,"mat4").replace(/\bfloat3x3\b/g,"mat3").replace(/\bfloat2x2\b/g,"mat2").replace(/\bfloat4\b/g,"vec4").replace(/\bfloat3\b/g,"vec3").replace(/\bfloat2\b/g,"vec2").replace(/\bhalf4\b/g,"vec4").replace(/\bhalf3\b/g,"vec3").replace(/\bhalf2\b/g,"vec2").replace(/\bhalf\b/g,"float"),l=l.replace(/\btexSample2DLod\b/g,"textureLod").replace(/\btexSample2D\b/g,"texture"),l=ze(l,"saturate",h=>"clamp("+h+", 0.0, 1.0)"),l=ze(l,"CAST4",h=>"vec4("+h+")"),l=ze(l,"CAST3",h=>"vec3("+h+")"),l=ze(l,"CAST2",h=>"vec2("+h+")"),l=l.replace(/\b(max|min)\(\s*(-?\d+(?:\.\d+)?)\s*,\s*([A-Za-z_]\w*\.(rgb|xyz|rg|xy|r|x))\s*\)/g,(h,b,v,T,_)=>{const F=_.length;return b+"(vec"+F+"("+v+"), "+T+")"}),l=l.replace(/(\.([xyzwrgba]{2,4})\s*=\s*)(max|min)\(\s*(-?\d+(?:\.\d+)?(?:[eE][+-]?\d+)?)\s*,\s*([^;]+?)\s*\)\s*;/g,(h,b,v,T,_,F)=>/\.[xyzwrgba]{2,4}\b|\bvec[234]\s*\(/.test(F)?`${b}${T}(vec${v.length}(${_}), ${F});`:h),l=l.replace(/(^|[^\w)\]])([+-])([+-])(?=[\d.])/g,(h,b,v,T)=>b+(v===T?"+":"-"));const p=[];l=l.replace(/\b\d+(?:\.\d+)?[eE][+-]?\d+\b/g,h=>(p.push(h),""+"".repeat(p.length)+""));const f=[];l=l.replace(/\bfor\s*\(\s*int\s+([A-Za-z_]\w*)([^)]*)\)/g,(h,b,v)=>(f.push(v+")"),`for (int ${b}${"".repeat(f.length)}`));for(let h=0;h<8;h++){const b=l;l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*([A-Za-z_][A-Za-z0-9_]*)/g,"$1$2.0 $3 $4"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(\d+\.\d+)\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([*/])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*(\d+\.\d+)/g,"$1$2.0 $3 $4"),l=l.replace(/(^|[^\w.])(\d+)\s*([+-])\s*([A-Za-z_]\w*\.(?:xyzw|xyz|xy|zw|rgba|rgb|rg|x|y|z|w|r|g|b|a))/g,"$1$2.0 $3 $4"),l=l.replace(/(^|[^\w.])(\d+)\s*([*/+-])\s*(\()/g,(v,T,_,F,R,k,U)=>{let V=0,q=k+v.length-1;for(;q<U.length;q++){const Z=U[q];if(Z==="(")V++;else if(Z===")"){if(V--,V===0){q++;break}}else if(V===0&&(Z===";"||Z===","||Z===`
|
|
9
|
+
`))break}for(;q<U.length;q++){const Z=U[q];if(Z===";"||Z===","||Z===`
|
|
10
|
+
`||Z===")")break}const W=U.slice(k,q);return/\d\.\d/.test(W)?`${T}${_}.0 ${F} ${R}`:v});{const v=new Set,T=/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?(?:float|vec2|vec3|vec4|mat2|mat3|mat4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let _;for(;(_=T.exec(l))!==null;)v.add(_[1]);if(v.size>0){const F=Array.from(v).sort((R,k)=>k.length-R.length).join("|");l=l.replace(new RegExp("(^|[^\\w.])(\\d+)\\s*([+-])\\s*("+F+")(?![A-Za-z0-9_])","g"),"$1$2.0 $3 $4"),l=l.replace(new RegExp("\\b("+F+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}if(l===b)break}{const h=["smoothstep","step","mix","clamp","max","min","pow","mod","atan","sqrt","inversesqrt","exp","log","exp2","log2","abs","sign","floor","ceil","fract","length","distance","dot","reflect","refract","faceforward","normalize","cross"],b=/\b(ApplyBlending|ApplyComposite|BlendTransparency)\s*\(/;for(const v of h)l=ze(l,v,T=>{const F=St(T).map(R=>{if(b.test(R))return R;const k=[];let U=R.replace(/\[[^\]]*\]/g,V=>(k.push(V),"\0"+(k.length-1)+"\0")).replace(/\b(?:ivec[234]|uvec[234]|int|uint)\s*\([^()]*\)/g,V=>(k.push(V),"\0"+(k.length-1)+"\0"));return U=U.replace(/(?<![A-Za-z0-9_.\u0000])(\d+)(?![.\d])(?![A-Za-z_])/g,"$1.0"),U.replace(/\u0000(\d+)\u0000/g,(V,q)=>k[Number(q)])});return v+"("+F.join(",")+")"});l=ze(l,"pow",v=>{const T=St(v);if(T.length!==2)return"pow("+v+")";const _=T[0].trim(),F=T[1].trim(),R=/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\s*$/.exec(_),U=R?{xyzw:4,rgba:4,xyz:3,rgb:3,xy:2,rg:2,zw:2}[R[1]]:0,V=/\bvec[234]\s*\(/.test(F)||/\.(xyzw|rgba|xyz|rgb|xy|rg|zw)\b/.test(F);return U>=2&&!V?"pow("+_+", vec"+U+"("+F+"))":"pow("+_+", "+F+")"})}l=l.replace(/([)\]])\s*([*/])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/\)\s*([+-])\s*(\d+)(?![\d.])/g,") $1 $2.0"),l=l.replace(/(^|[^\w.])(\d+)(?![.\d])\s*([+-])\s*((?:step|smoothstep|mix|mod|fract|abs|sin|cos|tan|atan|sqrt|pow|inversesqrt|floor|ceil|sign|length|normalize|distance|dot|cross|exp|log|exp2|log2|clamp|min|max)\s*\()/g,"$1$2.0 $3 $4");{const h=new Set,b=/\b(?:vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)/g;let v;for(;(v=b.exec(l))!==null;)h.add(v[1]);if(h.size>0){const T=Array.from(h).sort((_,F)=>F.length-_.length).join("|");l=l.replace(new RegExp("\\b("+T+")\\s*([+-])\\s*(\\d+)(?![\\d.])","g"),"$1 $2 $3.0")}}{const h=new Set,b=/\b(?:int|uint)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let v;for(;(v=b.exec(l))!==null;)h.add(v[1]);l=l.replace(/\buint\b/g,"int"),l=l.replace(/\b([A-Za-z_][A-Za-z0-9_]*)\s*%\s*(\d+)(?![\d.])/g,(T,_,F)=>h.has(_)?T:"mod("+_+", "+F+".0)"),l=l.replace(/\bint\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*mod\(([^;]*)\);/g,"int $1 = int(mod($2));")}l=l.replace(/\b(vec[234])\s+([A-Za-z_][A-Za-z0-9_]*)\s*=\s*([^;()\n,]+);/g,(h,b,v,T)=>{const _=T.trim();return/^(vec[234]|mat[234]|int\b|float\b)/.test(_)?h:b+" "+v+" = "+b+"("+_+");"});for(const h of["mix","clamp","step","smoothstep","min","max","mod","pow"])l=ze(l,h,b=>h+"("+b.replace(/(?<![A-Za-z0-9_.])(\d+)(?![.\d])/g,"$1.0")+")");l=ze(l,"clamp",h=>{const b=St(h);if(b.length!==3)return"clamp("+h+")";const v=b[0].trim(),T=b[1].trim(),_=F=>/^-?\d+\.?\d*$/.test(F);return _(v)&&_(T)&&Number(v)===0&&Number(T)===1?"clamp("+b[2].trim()+", "+v+", "+T+")":"clamp("+h+")"}),l=l.replace(/(\.\d+)\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=l.replace(/([)\]])\s*([+-])\s*(\d+)(?![\d.])/g,"$1 $2 $3.0"),l=ze(l,"smoothstep",h=>{const b=St(h);return b.length===3&&b[1].trim()==="0.0"&&b[0].trim()!=="0.0"?"(1.0 - smoothstep(0.0, "+b[0].trim()+", "+b[2].trim()+"))":"smoothstep("+h+")"});{const h=new Map,b=/\b(?:uniform|varying|attribute|in|out)?\s*\b(vec([234]))\s+([A-Za-z_]\w*)/g;let v;for(;(v=b.exec(l))!==null;)h.set(v[3],Number(v[2]));if(h.size>0){const T={2:"xy",3:"xyz",4:"xyzw"};l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([A-Za-z_]\w*)\s*;/g,(_,F,R,k)=>{const U=h.get(R),V=h.get(k);return!U||!V||U>=V?_:F+R+" = "+k+"."+T[U]+";"})}{const T=new Set;{const R=/\b(?:uniform|varying|attribute|in|out|const)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let k;for(;(k=R.exec(l))!==null;)T.add(k[1])}const _=R=>{const k=R.trim();{const q=/^vec([234])\s*\(/.exec(k);if(q){let W=0;for(let Z=k.indexOf("(");Z<k.length;Z++)if(k[Z]==="(")W++;else if(k[Z]===")"&&(W--,W===0))return Z===k.length-1?Number(q[1]):0;return 0}}if(/^texture(?:Lod)?\s*\(/.test(k)){let q=0;for(let W=k.indexOf("(");W<k.length;W++)if(k[W]==="(")q++;else if(k[W]===")"&&(q--,q===0))return W===k.length-1?4:0;return 0}const U=/^([A-Za-z_]\w*)(?:\.([xyzwrgba]{2,4}))?\s*[*/]\s*([^*/]+)$/.exec(k);if(!U)return 0;const V=U[3];return/\bvec[234]\s*\(|\.[xyzwrgba]{2,4}\b/.test(V)?0:U[2]?U[2].length:T.has(U[1])?0:h.get(U[1])||0};l=l.replace(/(^|[;{}\n]\s*)float\s+([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(R,k,U,V)=>_(V)<2?R:`${k}float ${U} = (${V.trim()}).x;`);const F={2:"xy",3:"xyz"};l=l.replace(/(^|[;{}\n]\s*)vec([23])\s+([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(R,k,U,V,q)=>{const W=Number(U);return _(q)<=W?R:`${k}vec${U} ${V} = (${q.trim()}).${F[W]};`})}if(h.size>0){const T=new Set,_=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let F;for(;(F=_.exec(l))!==null;)T.add(F[1]);const R="pow|saturate|clamp|smoothstep|step|abs|floor|ceil|fract|frac|sin|cos|tan|asin|acos|atan|sqrt|length|distance|dot|exp|log|sign|fmod|mod|min|max|mix|lerp",k=/^(?:length|distance|dot)$/,U=q=>{const W=q.match(new RegExp("^(?:"+R+")\\s*\\("));if(!W)return!1;let Z=0;const K=W[0].length-1;let re=-1;for(let J=K;J<q.length;J++)if(q[J]==="(")Z++;else if(q[J]===")"&&(Z--,Z===0)){re=J;break}if(re!==q.length-1)return!1;const te=W[0].replace(/\s*\($/,"");if(k.test(te))return!0;const X=q.slice(K+1,re);if(/\bvec[234]\s*\(/.test(X)||/\.[xyzwrgba]{2,4}\b/.test(X))return!1;for(const J of h.keys()){const de=J.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");if(new RegExp("(?<!\\.)\\b"+de+"\\b(?!\\s*\\.[xyzwrgba]\\b)").test(X))return!1}return!0},V=new Set;if(l=l.replace(/(^|[;{}\n]\s*)([A-Za-z_]\w*)\s*=\s*([^;]+);/g,(q,W,Z,K)=>{const re=h.get(Z);if(!re||T.has(Z))return q;const te=K.trim();if(new RegExp("^vec"+re+"\\s*\\(").test(te)||h.has(te))return q;const X=/^-?\d+(?:\.\d+)?(?:e[-+]?\d+)?$/i.test(te),J=T.has(te);return!X&&!J&&!U(te)?q:(V.add(Z),W+Z+" = vec"+re+"("+te+");")}),V.size>0){const q=[...V].sort((W,Z)=>Z.length-W.length).join("|");l=l.replace(new RegExp(`\\b([A-Za-z_]\\w*)\\s*([*/])\\s*(${q})\\b`,"g"),(W,Z,K,re)=>h.has(Z)?W:`${Z} ${K} ${re}.x`),l=l.replace(new RegExp(`\\b(${q})\\s*([*/])\\s*([A-Za-z_]\\w*)\\b`,"g"),(W,Z,K,re)=>h.has(re)?W:`${Z}.x ${K} ${re}`)}}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*=\s*)(-?\d+)\s*;/g,"$1$2.0;"),l=l.replace(/\b(float|vec2|vec3|vec4)\s+([A-Za-z_]\w*)\s*=\s*(-?\d+)\s*;/g,(h,b,v,T)=>b==="float"?`${b} ${v} = ${T}.0;`:`${b} ${v} = ${b}(${T}.0);`);{const h=new Set,b=/\b(?:uniform|varying|attribute|in|out)?\s*\bfloat\s+([A-Za-z_]\w*)/g;let v;for(;(v=b.exec(l))!==null;)h.add(v[1]);if(h.size>0){const T=[...h].sort((_,F)=>F.length-_.length).join("|");l=l.replace(new RegExp(`\\b(${T})\\s*=\\s*(-?\\d+)\\s*;`,"g"),"$1 = $2.0;"),l=l.replace(new RegExp(`\\b(${T})\\s*([-+*/]=)\\s*(-?\\d+)\\s*;`,"g"),"$1 $2 $3.0;")}}l=l.replace(/(\.[xyzwrgba]{1,4}\s*[-+*/]=\s*)(-?\d+)\s*;/g,"$1$2.0;");const d="step|smoothstep|saturate|clamp|mix|lerp|frac|fract|abs|floor|ceil|min|max|pow|sqrt|length|dot|distance";l=l.replace(new RegExp(`\\bint\\s+([A-Za-z_]\\w*)\\s*=\\s*((?:${d})\\s*\\()`,"g"),"float $1 = $2"),l=l.replace(/\bfloat\s+([A-Za-z_]\w*)\s*=\s*(int\s*\([^;]*\))\s*;/g,"float $1 = float($2);");{const h=Oo(l);h.size>0&&(l=l.replace(/\b(const\s+)?float\s+([A-Za-z_]\w*)\s*=\s*([^;{}]+);/g,(b,v,T,_)=>{const F=_.trim();if(/\./.test(F)||/[A-Za-z_]\w*\s*\(/.test(F))return b;const R=F.match(/[A-Za-z_]\w*/g);return!R||!R.length||!R.every(k=>h.has(k))?b:`${v||""}float ${T} = float(${F});`}))}{const h=Oo(l),b=new Set;let v;const T=/\b(?:const\s+|uniform\s+|varying\s+|in\s+|out\s+)*float\s+([A-Za-z_]\w*)/g;for(;(v=T.exec(l))!==null;)b.add(v[1]);for(const _ of[...h])b.has(_)&&(h.delete(_),b.delete(_));if(h.size>0&&b.size>0){const _=[...h].sort((R,k)=>k.length-R.length).join("|"),F=[...b].sort((R,k)=>k.length-R.length).join("|");l=l.replace(new RegExp(`\\b(${_})\\s*([*/+-])\\s*(${F})\\b`,"g"),(R,k,U,V)=>`float(${k}) ${U} ${V}`),l=l.replace(new RegExp(`\\b(${F})\\s*([*/+-])\\s*(${_})\\b`,"g"),(R,k,U,V)=>`${k} ${U} float(${V})`)}}{const h=new Set,b=/\bbool\s+([A-Za-z_]\w*)\s*=/g;let v;for(;(v=b.exec(l))!==null;)h.add(v[1]);if(h.size>0){const T=[...h].join("|");l=l.replace(new RegExp(`([-+*/]=\\s*)(${T})\\b`,"g"),(_,F,R)=>`${F}float(${R})`)}}{const h=/\(\s*([^()&|]+?)\s*(<=|>=|<|>|==|!=)\s*([^()&|]+?)\s*\)/g;l=l.replace(new RegExp(h.source+"\\s*([*/])","g"),(b,v,T,_,F)=>`float(${v.trim()} ${T} ${_.trim()}) ${F}`),l=l.replace(new RegExp("([-+*/]=\\s*)"+h.source,"g"),(b,v,T,_,F)=>`${v}float(${T.trim()} ${_} ${F.trim()})`)}{const h=new Set;for(const b of l.matchAll(/\b(?:uniform\s+)?(?:highp|mediump|lowp\s+)?float\s+([A-Za-z_]\w*)\s*\[/g))h.add(b[1]);if(h.size){const b=[...h].sort((R,k)=>k.length-R.length).join("|"),v=new RegExp("\\b("+b+")\\s*\\[","g");let T="",_=0,F;for(;F=v.exec(l);){const R=F.index+F[0].length-1,k=Jn(l,R,"[","]");if(k<0)break;let U=k+1;for(;U<l.length&&/[ \t]/.test(l[U]);)U++;if(l[U]!=="["){const K=l.slice(R+1,k).trim(),re=/\d\.\d/.test(K)||/^[A-Za-z_]\w*$/.test(K)&&new RegExp("\\bfloat\\s+"+K.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")+"\\b").test(l),te=/^\s*int\s*\(/.test(K)||/^-?\d+$/.test(K);if(re&&!te){T+=l.slice(_,F.index),T+=F[1]+"[int("+K+")]",_=k+1,v.lastIndex=_;continue}v.lastIndex=k+1;continue}const V=Jn(l,U,"[","]");if(V<0)break;const q=l.slice(R+1,k),W=l.slice(U+1,V);T+=l.slice(_,F.index),T+=F[1]+"[int(("+q+")) * 4 + int(("+W+"))]",_=V+1,v.lastIndex=_}l=T+l.slice(_)}}l=ze(l,"mix",(h,b)=>{const v=St(h);if(v.length!==3)return"mix("+h+")";const T=U=>{const V=U.trim(),q=/\.([xyzwrgba]{1,4})\s*$/.exec(V);if(q)return q[1].length;const W=/^vec([234])\s*\(/.exec(V);if(W)return Number(W[1]);if(!/^[A-Za-z_]\w*$/.test(V))return 0;const Z=new RegExp("\\b(vec([234])|float)\\s+"+V+"\\b","g");let K=0,re;for(;(re=Z.exec(l))!==null&&re.index<b;)K=re[1].startsWith("vec")?Number(re[2]):1;return K},_=v[0].trim(),F=v[1].trim(),R=T(_),k=T(F);if(R>=2&&k>=2&&R!==k){const U=Math.min(R,k),V=U===2?".xy":U===3?".xyz":"";return V?"mix("+(R>U?_+V:_)+", "+(k>U?F+V:F)+", "+v[2].trim()+")":"mix("+h+")"}return"mix("+h+")"});{const h=/\b(vec([234]))\s+([A-Za-z_]\w*)\s*\(/g;let b="",v=0,T;for(;T=h.exec(l);){const _=Io(l,T.index+T[0].length-1);if(_<0)break;let F=_+1;for(;F<l.length&&/\s/.test(l[F]);)F++;if(l[F]!=="{")continue;const R=Jn(l,F,"{","}");if(R<0)break;const k=Number(T[2]);if(k>=4){h.lastIndex=R;continue}let U=l.slice(F+1,R);const V=new Map;for(const W of l.slice(0,T.index).matchAll(/\buniform\s+(?:highp|mediump|lowp\s+)?(vec([234]))\s+([A-Za-z_]\w*)/g))V.set(W[3],Number(W[2]));for(const W of U.matchAll(/\b(vec([234]))\s+([A-Za-z_]\w*)/g))V.set(W[3],Number(W[2]));const q=k===2?"xy":"xyz";U=U.replace(/\breturn\s+([A-Za-z_]\w*)\s*;/g,(W,Z)=>{const K=V.get(Z);return K&&K>k?"return "+Z+"."+q+";":W}),b+=l.slice(v,F+1)+U,v=R,h.lastIndex=R}l=b+l.slice(v)}const w=new Set,M=/\b(?:uniform\s+)?(?:mat4|mat3|mat2|float4x4)\s+([A-Za-z_][A-Za-z0-9_]*)/g;let m;for(;(m=M.exec(l))!==null;)w.add(m[1]);if(l=ze(l,"mul",h=>{const b=St(h);if(b.length!==2)return"mul("+h+")";const v=b[0].trim(),T=b[1].trim(),_=F=>w.has(F.split(/[\[.\s]/)[0])||/^mat[234]\(/.test(F);return _(v)&&_(T)?"(transpose("+T+") * transpose("+v+"))":_(T)?"(transpose("+T+") * "+v+")":"("+v+" * "+T+")"}),l=l.replace(/\blerp\b/g,"mix").replace(/\bfrac\b/g,"fract"),l=ze(l,"atan2",h=>"atan("+h+")"),l=ze(l,"fmod",h=>{const b=St(h);if(b.length!==2)return"mod("+h+")";const v=b[0].trim(),T=b[1].trim();return"(("+v+") - ("+T+") * trunc(("+v+") / ("+T+")))"}),l=ze(l,"ddx",h=>"dFdx("+h+")"),l=ze(l,"ddy",h=>"dFdy("+h+")"),l=ze(l,"CAST3X3",h=>"mat3("+h+")"),n==="vert")l=l.replace(/\battribute\b/g,"in").replace(/\bvarying\b/g,"out");else{if(l=l.replace(/\bvarying\b/g,"in").replace(/\battribute\b/g,"in"),typeof o=="string"&&o){const v=new Map,T=/^\s*(?:varying|out)\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=T.exec(o))!==null;)v.set(_[2],_[1]);const F={float:1,vec2:2,vec3:3,vec4:4},R=new Map;if(l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(k,U,V,q,W,Z)=>{const K=v.get(W);return!K||F[K]<=F[V]?k:(R.set(W,F[V]),U+K+q+W+Z)}),R.size>0){const k={1:"x",2:"xy",3:"xyz"};for(const[U,V]of R){const q=k[V];q&&(l=l.split(`
|
|
11
|
+
`).map(W=>/^\s*in\s/.test(W)?W:W.replace(new RegExp("\\b"+U+"\\b(?!\\s*[.\\w])","g"),U+"."+q)).join(`
|
|
12
|
+
`))}}l=l.replace(/^(\s*in\s+(?:highp|mediump|lowp\s+)?)(vec[234]|float)(\s+)([A-Za-z_]\w*)(\s*;)/gm,(k,U,V,q,W,Z)=>{const K=v.get(W);if(!K||F[K]>=F[V])return k;const re="xyzw",te="rgba";return new RegExp("\\b"+W+"\\s*\\.\\s*["+re+te+"]*["+re.slice(F[K])+te.slice(F[K])+"]").test(l)?k:U+K+q+W+Z})}{const v=new Map,T=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[34])\s+([A-Za-z_]\w*)\s*;/gm;let _;for(;(_=T.exec(l))!==null;)v.set(_[2],Number(_[1].slice(3)));const F=new Map(v),R=/\b(vec[34])\s+([A-Za-z_]\w*)\s*[=;]/g;for(;(_=R.exec(l))!==null;)F.has(_[2])||F.set(_[2],Number(_[1].slice(3)));if(F.size>0){const k=U=>{const V=U.trim();if(!V)return U;const q=/^([A-Za-z_]\w*)$/.exec(V);if(q&&F.has(q[1]))return q[1]+".xy";const W=/^([A-Za-z_]\w*)(\s*[+\-].+)$/.exec(V);return W&&F.has(W[1])?"("+W[1]+".xy"+W[2]+")":U};for(const U of["textureLod","texture"])l=ze(l,U,V=>{const q=St(V);return q.length>=2&&(q[1]=k(q[1])),U+"("+q.join(", ")+")"})}v.size>0&&(l=l.split(`
|
|
13
|
+
`).map(k=>{if(!/\bvec2\s+[A-Za-z_]\w*\s*=/.test(k))return k;let U=k;for(const V of v.keys())U=U.replace(new RegExp("\\b"+V+"\\b(?!\\s*[.\\w])","g"),V+".xy");return U}).join(`
|
|
14
|
+
`))}const h=new Set,b=new Set;{const v=/^\s*in\s+(?:highp|mediump|lowp\s+)?(vec[234]|float)\s+([A-Za-z_]\w*)\s*;/gm;let T;for(;(T=v.exec(l))!==null;)b.add(T[2])}for(const v of b)new RegExp("\\b"+v+"\\b\\s*(?:\\.[xyzwrgba]{1,4})?\\s*(?:[-+*/]?=(?!=)|\\+\\+|--)").test(l)&&h.add(v);if(h.size>0){const v=l.search(/\bvoid\s+main\s*\([^)]*\)\s*\{/);if(v!==-1){const T=l.indexOf("{",v),_=l.slice(0,T+1);let F=l.slice(T+1);const R=[];for(const k of h){if(new RegExp("(?:^|[;{}\\n])\\s*(?:highp|mediump|lowp\\s+)?(?:vec[234]|float|int|bool)\\s+"+k+"\\s*[=;]").test(F))continue;const V=new RegExp("^\\s*in\\s+(?:highp|mediump|lowp\\s+)?(vec[234]|float)\\s+"+k+"\\s*;","m").exec(l),q=V?V[1]:"vec4";R.push(" "+q+" "+k+"_rw = "+k+";"),F=Pn(F,k,k+"_rw")}R.length>0&&(F=`
|
|
15
|
+
`+R.map(k=>k.replace(/= (\w+)_rw;/,"= $1;")).join(`
|
|
12
16
|
`)+`
|
|
13
|
-
`+
|
|
14
|
-
`).map(
|
|
15
|
-
`)}let
|
|
16
|
-
`;return n==="vert"&&(
|
|
17
|
-
`),n==="frag"&&(
|
|
18
|
-
`,/\bgl_FragColor\b/.test(l)&&(
|
|
19
|
-
`,l=l.replace(/\bgl_FragColor\b/g,"fragColor"))),
|
|
17
|
+
`+F),l=_+F}}}l=l.replace(/\[(?:unroll|loop|branch|flatten)\]\s*/g,""),l=l.replace(/\bstatic\s+/g,""),f.length>0&&(l=l.replace(/\u0003(\u0004+)\u0003/g,(h,b)=>f[b.length-1]));{const h=new Set;for(const b of l.matchAll(/\b(?:uniform[ \t]+)?(?:highp|mediump|lowp)?[ \t]*float[ \t]+([A-Za-z_]\w*)[ \t]*[;=]/g))h.add(b[1]);if(h.size){const b=v=>{const T=v.trim().startsWith("-"),_=v.replace(/^-\s*/,"").trim();return h.has(_)?(T?"-":"")+"int("+_+")":v};l=l.replace(/(for\s*\(\s*(?:int|uint)\s+(\w+)\s*=\s*)(-?\s*[A-Za-z_]\w*|-?\s*\d+)(\s*;\s*\2\s*[<>]=?\s*)(-?\s*[A-Za-z_]\w*|-?\s*\d+)(\s*;)/g,(v,T,_,F,R,k,U)=>T+b(F)+R+b(k)+U)}}{const h=new Set;l=l.split(`
|
|
18
|
+
`).map(b=>{const v=/^[ \t]*uniform[ \t]+(?:highp|mediump|lowp[ \t]+)?[A-Za-z0-9_]+[ \t]+([A-Za-z_][A-Za-z0-9_]*)/.exec(b);if(!v)return b;const T=v[1];return h.has(T)?"":(h.add(T),b)}).join(`
|
|
19
|
+
`)}p.length>0&&(l=l.replace(/\u0001(\u0002+)\u0001/g,(h,b)=>p[b.length-1]));let A=`#version 300 es
|
|
20
|
+
`;return n==="vert"&&(A+=`precision highp float;
|
|
21
|
+
`),n==="frag"&&(A+=`precision highp float;
|
|
22
|
+
`,/\bgl_FragColor\b/.test(l)&&(A+=`out vec4 fragColor;
|
|
23
|
+
`,l=l.replace(/\bgl_FragColor\b/g,"fragColor"))),A+l}const jo={center:[.5,.5],centre:[.5,.5],left:[0,.5],right:[1,.5],top:[.5,0],bottom:[.5,1],topleft:[0,0],topright:[1,0],bottomleft:[0,1],bottomright:[1,1]},ma={2:"multiply",6:"additive",7:"screen",9:"additive",31:"additive"},ga={screen:1,multiply:2},$r=`#version 300 es
|
|
20
24
|
in vec3 a_Position;
|
|
21
25
|
in vec2 a_TexCoord;
|
|
22
26
|
uniform mat4 u_MVP;
|
|
@@ -24,7 +28,7 @@ out vec2 v_UV;
|
|
|
24
28
|
void main() {
|
|
25
29
|
gl_Position = u_MVP * vec4(a_Position, 1.0);
|
|
26
30
|
v_UV = a_TexCoord;
|
|
27
|
-
}`,
|
|
31
|
+
}`,ba=`#version 300 es
|
|
28
32
|
precision mediump float;
|
|
29
33
|
in vec2 v_UV;
|
|
30
34
|
uniform sampler2D u_Tex;
|
|
@@ -40,7 +44,7 @@ void main() {
|
|
|
40
44
|
if (u_BlendPrep == 1) c.rgb *= c.a;
|
|
41
45
|
else if (u_BlendPrep == 2) c.rgb = mix(vec3(1.0), c.rgb, c.a);
|
|
42
46
|
fragColor = c;
|
|
43
|
-
}`,
|
|
47
|
+
}`,ya=`#version 300 es
|
|
44
48
|
precision mediump float;
|
|
45
49
|
in vec2 v_UV;
|
|
46
50
|
uniform sampler2D u_Tex;
|
|
@@ -51,21 +55,22 @@ void main() {
|
|
|
51
55
|
if (u_BlendPrep == 1) c.rgb *= c.a;
|
|
52
56
|
else if (u_BlendPrep == 2) c.rgb = mix(vec3(1.0), c.rgb, c.a);
|
|
53
57
|
fragColor = c;
|
|
54
|
-
}`,
|
|
58
|
+
}`,va=`#version 300 es
|
|
55
59
|
precision mediump float;
|
|
56
60
|
in vec2 v_UV;
|
|
57
61
|
uniform sampler2D u_Tex;
|
|
58
62
|
out vec4 fragColor;
|
|
59
63
|
void main() {
|
|
60
64
|
fragColor = vec4(texture(u_Tex, v_UV).rgb, 1.0);
|
|
61
|
-
}`;function
|
|
62
|
-
void main(`));const o=n?/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/:/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/;return r.replace(o,"unprojectedUVs *= "+sa+" *")}function aa(e,n={}){const t=e.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0});if(!t)throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 WebGL2");const r=n.shaderResolver||(async()=>null),o=n.diag||(()=>{}),i=typeof document<"u"?document.createElement("canvas"):null;i&&(i.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0");let s=!1,c=n.fboCapFactor===void 0?0:n.fboCapFactor,a=null,u=null,l=null;const d=[["g_AudioSpectrum16Left","left16"],["g_AudioSpectrum16Right","right16"],["g_AudioSpectrum32Left","left32"],["g_AudioSpectrum32Right","right32"],["g_AudioSpectrum64Left","left64"],["g_AudioSpectrum64Right","right64"]];function h(f){l=f||null}let p=null,w=null,m=null,g=null,v=null,b=null,y=null;const S=new Map,_=new Map,C={total:0,ok:0,failed:0};function N(f,T){p=typeof f=="function"?f:null,w=T&&T.userProperties||null,m=T&&T.audioViews||null,g=T&&T.shared||null,v=T&&T.inputView||null,b=T&&T.timers||null,y=T&&typeof T.onSandbox=="function"?T.onSandbox:null,S.clear(),_.clear()}let D=!1;const k=Jn(t,Fr,Hs),O=Jn(t,Fr,Gs),j=Jn(t,Fr,Ys),W=t.createVertexArray();t.bindVertexArray(W);const K=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,K),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(1),t.vertexAttribPointer(1,2,t.FLOAT,!1,20,12),t.bindVertexArray(null);const V=new Map;let G=1;function Q(f,T,x){const M=(x||"")+"|"+f+"x"+T;if(V.has(M)){const B=V.get(M);return B.stamp=G,B}const E=t.createFramebuffer(),P=t.createTexture();t.bindTexture(t.TEXTURE_2D,P),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,f,T,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,E),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,P,0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindFramebuffer(t.FRAMEBUFFER,null);const R={fbo:E,tex:P,width:f,height:T,stamp:G};return V.set(M,R),R}function q(){for(const[f,T]of V)T.stamp!==G&&(T.fbo&&t.deleteFramebuffer(T.fbo),T.tex&&t.deleteTexture(T.tex),V.delete(f))}const te=new Map,me=new Map,xe=new Map;function We(f){const T={},x=/uniform\s+[A-Za-z0-9_]+\s+([A-Za-z_][A-Za-z0-9_]*)[^;]*;\s*\/\/([^\n]*)/g;let M;for(;(M=x.exec(f))!==null;){const E=M[1],P=M[2],R=/"material"\s*:\s*"([^"]+)"/.exec(P);if(!R)continue;const B=/"default"\s*:\s*("(?:[^"]*)"|-?\d+(?:\.\d+)?)/.exec(P);T[R[1]]={uniform:E,default:B?rt(B[1]):void 0}}return T}function Ve(f){const T=new Map,x=/uniform\s+sampler2D\s+g_Texture(\d+)\s*;\s*\/\/([^\n]*)/g;let M;for(;(M=x.exec(f))!==null;){const E=Number(M[1]),P=/"default"\s*:\s*"([^"]+)"/.exec(M[2]);P&&P[1]&&T.set(E,P[1])}return T}function Ee(f){const T=[],x=/uniform\s+sampler2D\s+(g_Texture(\d+))[^;]*;\s*\/\/([^\n]*)/g;let M;for(;(M=x.exec(f))!==null;){const E=/"combo"\s*:\s*"([^"]+)"/.exec(M[3]);E&&T.push({slot:Number(M[2]),name:M[1],combo:E[1]})}return T}function rt(f){if(f.startsWith('"'))return f.slice(1,-1);const T=Number(f);return Number.isFinite(T)?T:void 0}async function Xe(f,T,x){let M=xe.get(f);if(M===void 0){const R=await r("shaders/"+f+".frag")||"",B=await r("shaders/"+f+".vert")||"";M={frag:R,vert:B,texCombos:Ee(R)},xe.set(f,M)}const E={...T};for(const R of M.texCombos)x&&x[R.slot]&&E[R.combo]===void 0&&(E[R.combo]=1);const P=f+"|"+JSON.stringify(E);if(te.has(P))return te.get(P);for(let R=0;R<4;R++){const B=new Set,z=re=>me.has(re)?me.get(re):(B.add(re),null),$=ko(So(M.frag,"frag",E,z,M.vert)),J=So(M.vert,"vert",E,z,M.frag);if(B.size===0){let re;try{re=Jn(t,J,$)}catch(F){throw new Error("shader="+f+" "+(F&&F.message))}const Z=new Map,ce=t.getProgramParameter(re,t.ACTIVE_UNIFORMS);for(let F=0;F<ce;F++){const ee=t.getActiveUniform(re,F),ue=ee.name.replace(/\[0\]$/,"");Z.set(ue,{loc:t.getUniformLocation(re,ee.name),type:Qs[ee.type]||"unknown",size:ee.size})}const le={...We(M.vert),...We(M.frag)},se=new Map([...Ve(M.vert),...Ve(M.frag)]),ie={prog:re,uni:Z,matMeta:le,samplerDefaults:se,fragGlsl:$,vertGlsl:J};return te.set(P,ie),ie}await Promise.all(Array.from(B).map(async re=>{me.set(re,await r("shaders/"+re)||"")}))}throw new Error("include \u89E3\u6790\u5931\u8D25: "+f)}const Pe=Nr(t,new Uint8Array([255,255,255,255]),1,1),Ae=Nr(t,new Uint8Array([0,0,0,0]),1,1);let Ze=null;function to(f){Ze=f||null}function lt(){if(!Ze)return null;const f=typeof Ze=="function"?Ze():Ze;return f&&f.state?f.state:f}const He={x:0,y:0,sx:0,sy:0};let hr=0,$t=0,ot=0,ze=1/60,Et=-1;const kn=typeof n.fadeDuration=="number"&&n.fadeDuration>=0?n.fadeDuration:1,Bn=(f,T)=>{const x=f!==null&&typeof f=="object"?f.value:f;return x===!0||x===1?!0:x===!1||x===0?!1:T},In=(f,T)=>{const x=f!==null&&typeof f=="object"?f.value:f;return typeof x=="number"&&Number.isFinite(x)?x:T},mr=f=>n.fade!==!1&&Bn(f.camerafade,!1);function fn(f,T){if(!Bn(f.camerashake,!1))return null;const x=In(f.camerashakeamplitude,0);if(x===0)return null;const M=Math.max(0,Math.min(1,In(f.camerashakeroughness,0))),E=In(f.camerashakespeed,1),P=T*E,R=Math.sin(P*2.1)*Math.cos(P*.7),B=Math.cos(P*1.7)*Math.sin(P*.9),z=Math.sin(P*11.3)*Math.cos(P*7.1),$=Math.cos(P*9.7)*Math.sin(P*13.1);return{x:(R*(1-M)+z*M)*x,y:(B*(1-M)+$*M)*x}}function pr(){const f=new Date;return(f.getHours()*3600+f.getMinutes()*60+f.getSeconds())/86400}function we(f,T,x){const M=f.get(T);M&&M.loc!==null&&x(M.loc,M.type,M.size)}function Kt(f){if(typeof f=="number")return[f,f,f,f];const T=String(f).trim().split(/[\s,]+/).map(Number);return[T[0]||0,T[1]||0,T[2]||0,T[3]||0]}function vt(f,T,x){const M=f.get(T);if(!M||M.loc===null)return;const E=x&&x.value!==void 0?x.value:x,P=Kt(E);switch(M.type){case"float":t.uniform1f(M.loc,P[0]);break;case"int":case"bool":t.uniform1i(M.loc,E===!0||E===1?1:Math.round(P[0]));break;case"vec2":t.uniform2f(M.loc,P[0],P[1]);break;case"vec3":t.uniform3f(M.loc,P[0],P[1],P[2]);break;case"vec4":t.uniform4f(M.loc,P[0],P[1],P[2],P[3]);break;case"mat4":t.uniformMatrix4fv(M.loc,!1,Je);break;case"mat3":t.uniformMatrix3fv(M.loc,!1,br);break}}const On=()=>new Float32Array([1,0,0,0,1,0,0,0,1]);function gr(f,T,x,M,E,P,R,B,z,$,J){if(we(f,"g_Time",F=>t.uniform1f(F,x)),we(f,"g_Daytime",F=>t.uniform1f(F,pr())),we(f,"g_ModelViewProjectionMatrix",F=>t.uniformMatrix4fv(F,!1,P)),we(f,"g_ModelMatrix",F=>t.uniformMatrix4fv(F,!1,R)),we(f,"g_ViewProjectionMatrix",F=>t.uniformMatrix4fv(F,!1,B)),f.get("g_ModelViewProjectionMatrixInverse")){let F=null;for(const[ue,ve]of z)ue===0&&(F=ve);const ee=F&&F[0]>0&&F[1]>0?Cs(xn(on(),F[0]/2,F[1]/2,1)):Je;we(f,"g_ModelViewProjectionMatrixInverse",ue=>t.uniformMatrix4fv(ue,!1,ee))}we(f,"g_Brightness",F=>t.uniform1f(F,T.brightness)),we(f,"g_UserAlpha",F=>t.uniform1f(F,T.alpha)),we(f,"g_Alpha",F=>t.uniform1f(F,T.alpha)),we(f,"g_Color",F=>t.uniform3f(F,T.color[0],T.color[1],T.color[2])),we(f,"g_Color4",F=>t.uniform4f(F,T.color[0],T.color[1],T.color[2],1)),we(f,"g_CompositeColor",F=>t.uniform3f(F,T.color[0],T.color[1],T.color[2])),we(f,"g_TexelSize",F=>t.uniform2f(F,1/M,1/E)),we(f,"g_TexelSizeHalf",F=>t.uniform2f(F,.5/M,.5/E)),we(f,"g_TextureReductionScale",F=>t.uniform1f(F,1));const re=lt(),Z=Br(!!(re&&re.has),!!f.get("g_PointerScale"));let ce=Z?_n:re?re.u:.5,le=Z?_n:re?re.v:.5,se=Z?_n:re?re.lastU:.5,ie=Z?_n:re?re.lastV:.5;if(J&&T&&T.size&&T.size[0]>0&&T.size[1]>0){const F=Math.abs(T.size[0]*T.scale[0]),ee=Math.abs(T.size[1]*T.scale[1]);if(F>0&&ee>0){const ue=T.origin[0]-F/2,ve=J.projH-T.origin[1]-ee/2,Me=Re=>(J.offX+Re*J.viewW-ue)/F,he=Re=>(J.offY+Re*J.viewH-ve)/ee;ce=Me(ce),le=he(le),se=Me(se),ie=he(ie)}}we(f,"g_PointerPosition",F=>t.uniform2f(F,ce,le)),we(f,"g_PointerPositionLast",F=>t.uniform2f(F,se,ie)),we(f,"g_PointerState",F=>t.uniform4f(F,ce,le,re&&re.leftDown?1:0,0)),we(f,"g_ParallaxPosition",F=>t.uniform2f(F,He.sx*.5+.5,He.sy*.5+.5)),we(f,"g_Frametime",F=>t.uniform1f(F,ze)),f.get("g_EffectTextureProjectionMatrixInverse")&&we(f,"g_EffectTextureProjectionMatrixInverse",F=>t.uniformMatrix4fv(F,!1,Je));for(let F=0;F<8;F++)we(f,"g_Texture"+F,ee=>t.uniform1i(ee,F));for(const[F,ee]of z)we(f,"g_Texture"+F+"Resolution",ue=>t.uniform4f(ue,ee[0],ee[1],ee[2],ee[3]));if(l){const F=typeof l=="function"?l():l;if(F)for(const[ee,ue]of d){const ve=F[ue];ve&&we(f,ee,Me=>t.uniform1fv(Me,ve))}}}function dn(f,T,x){for(const[M,E]of Object.entries(T||{})){const P=x&&x[M];P&&vt(f,P.uniform,E)}for(const[M,E]of Object.entries(x||{}))(!T||!(M in T))&&E.default!==void 0&&vt(f,E.uniform,E.default)}function hn(f){const T=lt();Br(!!(T&&T.has),!!f.get("g_PointerScale"))&&we(f,"g_PointerScale",x=>t.uniform1f(x,0))}function ut(f,T,x,M){if(!f)return f;let E=!1;for(const R of Object.values(f))if(R!==null&&typeof R=="object"&&typeof R.script=="string"){E=!0;break}if(!E||!p)return f;const P={...f};for(const[R,B]of Object.entries(f)){if(B===null||typeof B!="object"||typeof B.script!="string")continue;const z=T+"|"+R;let $=S.get(z);if($===void 0){C.total++;try{$=p(B.script,B.scriptproperties||B.scriptProperties||null,{userProperties:w||{},audioViews:m||void 0,layer:M||null,shared:g||{},inputView:v||void 0,setTimeout:b?b.setTimeout:void 0,clearTimeout:b?b.clearTimeout:void 0,setInterval:b?b.setInterval:void 0,clearInterval:b?b.clearInterval:void 0})}catch{$=null}if($?C.ok++:C.failed++,S.set(z,$),$){const se=B.value!==void 0?B.value:B,ie=Kt(se),ee=typeof se=="number"?ie[0]:{x:ie[0],y:ie[1],z:ie[2]};$.init&&$.init(ee)}if($&&typeof $.applyUserProperties=="function")try{$.applyUserProperties(w||{})}catch{}if($&&$.hasMediaHook&&y)try{y($)}catch{}}if(!$||$.disabled||!$.hasUpdate)continue;if($.engine){$.engine.runtime=x,$.engine.frametime=ze,$.engine.timeOfDay=pr();const se=lt();se&&se.screenW&&se.screenH&&($.engine.screenResolution={x:se.screenW,y:se.screenH})}const J=Kt(B.value!==void 0?B.value:B),Z=typeof(B.value!==void 0?B.value:B)=="number"?J[0]:{x:J[0],y:J[1],z:J[2]};let ce;try{ce=$.callUpdate(Z)}catch{ce=void 0}const le=ce??Z;if(typeof le=="number"&&Number.isFinite(le))P[R]=le;else if(le&&typeof le=="object"){const se=Number(le.x),ie=Number(le.y),F=Number(le.z);Number.isFinite(se)&&Number.isFinite(ie)&&(P[R]=Number.isFinite(F)?`${se} ${ie} ${F}`:`${se} ${ie} 0`)}}return P}function Dn(f,T,x){if(!f)return f;let M=!1;for(const P of Object.values(f))if(P&&typeof P=="object"&&P.animation&&P.animation.options){M=!0;break}if(!M)return f;const E={...f};for(const[P,R]of Object.entries(f)){if(!R||typeof R!="object"||!R.animation||!R.animation.options)continue;const B=T+"|anim|"+P;let z=_.get(B);if(!z){const $=Lo(R.animation),J=R.value!==void 0?R.value:0;$.baseNumeric=Array.isArray(J)?J.slice():J,z={ctrl:$},_.set(B,z)}z.ctrl.playing&&z.ctrl.setFrame(x*z.ctrl.fps*z.ctrl.rate),E[P]=z.ctrl.applyTo(z.ctrl.baseNumeric)}return E}function Qt(f,T,x,M){return f==null||f===""?null:f.startsWith("_rt_")?f.startsWith("_rt_imageLayerComposite")?gn&&dt.has(f)?dt.get(f):T:x.has(f)?x.get(f):null:x.has(f)?x.get(f):M.get(f)||null}const it=Zs(),zn=Ks(),$n=new Map;function jt(f,T){const x=f+"x"+T;let M=$n.get(x);return M===void 0&&(M=qs(f,T),$n.set(x,M)),M}let Wt=null;function ft(f,T){Wt!==f&&(t.bindBuffer(t.ARRAY_BUFFER,K),t.bufferData(t.ARRAY_BUFFER,T,t.DYNAMIC_DRAW),Wt=f)}const _e={mvp:t.getUniformLocation(k,"u_MVP"),tex:t.getUniformLocation(k,"u_Tex"),color:t.getUniformLocation(k,"u_Color4"),frameOrigin:t.getUniformLocation(k,"u_FrameOrigin"),frameU:t.getUniformLocation(k,"u_FrameU"),frameV:t.getUniformLocation(k,"u_FrameV"),blendPrep:t.getUniformLocation(k,"u_BlendPrep")},Pt={mvp:t.getUniformLocation(O,"u_MVP"),tex:t.getUniformLocation(O,"u_Tex"),blendPrep:t.getUniformLocation(O,"u_BlendPrep")},Jt={mvp:t.getUniformLocation(j,"u_MVP"),tex:t.getUniformLocation(j,"u_Tex")},Je=on(),br=On();function yt(f){f==="translucent"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):f==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):t.disable(t.BLEND)}let Vt=0;function Xt(f){const{mode:T,prep:x}=kr(f);Vt=x,T==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):T==="multiply"?(t.enable(t.BLEND),t.blendFuncSeparate(t.DST_COLOR,t.ZERO,t.ONE,t.ONE_MINUS_SRC_ALPHA)):T==="screen"?(t.enable(t.BLEND),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA)):yt("translucent")}function jn(f,T){if(T&&T.perspective)return!1;const x=f.size[0]*f.scale[0],M=f.size[1]*f.scale[1];if(x===0||M===0)return!1;let E=Math.abs(x)/2,P=Math.abs(M)/2;const R=f.angles[2];if(R!==0){const ce=Math.abs(Math.cos(R)),le=Math.abs(Math.sin(R)),se=E*ce+P*le,ie=E*le+P*ce;E=se,P=ie}const B=f.origin[0],z=T.projH-f.origin[1];let $=64;f.parallaxDepth&&($+=Math.abs(an(f.parallaxDepth[0])*$t),$+=Math.abs(an(f.parallaxDepth[1])*ot));const J=Fo(f),re=$+J[0],Z=$+J[1];return B+E+re<T.offX||B-E-re>T.offX+T.viewW||z+P+Z<T.offY||z-P-Z>T.offY+T.viewH}function vr(f,T,x){if(!f.spriteSheet)return null;const M=T&&T.frames,E=Array.isArray(M)?M:M&&M.list;if(!E||E.length===0)return null;const P=M&&M.atlasWidth||T.width||0,R=M&&M.atlasHeight||T.height||0;if(P<=0||R<=0)return null;f.spriteFrameCount=E.length;let B=0;const z=f.textureAnimation;if(z&&z.frame!==null&&z.frame!==void 0)B=Math.floor(Number(z.frame))||0,B>=0||(B=0),B>=E.length&&(B=E.length-1);else if(E.length>1){const le=z&&z.playing===!1;let se=0;for(const ie of E)se+=ie.duration>0?ie.duration:1/30;if(!le&&se>0){let ie=x%se;ie<0&&(ie+=se);for(let F=0;F<E.length;F++){const ee=E[F].duration>0?E[F].duration:.03333333333333333;if(ie<ee){B=F;break}ie-=ee,B=F}}}const $=E[B],J=$.uDir?$.uDir[0]:$.width,re=$.uDir?$.uDir[1]:0,Z=$.vDir?$.vDir[0]:0,ce=$.vDir?$.vDir[1]:$.height;return[$.x/P,$.y/R,J/P,re/R,Z/P,ce/R]}function xt(f,T){const x=f.size[0]*f.scale[0],M=f.size[1]*f.scale[1];let E=on();if(T&&T.perspective){const R=Us(f,T);E=sn(E,R[0],R[1],R[2]);const B=f.angles[0]||0,z=f.angles[1]||0;z&&(E=Ls(E,z)),B&&(E=Rs(E,B)),E=bo(E,-f.angles[2])}else{if(E=sn(E,f.origin[0],T.projH-f.origin[1],f.origin[2]),f.parallaxDepth&&($t!==0||ot!==0)){const R=an(f.parallaxDepth[0]),B=an(f.parallaxDepth[1]);E=sn(E,R*$t,B*ot,0)}E=bo(E,-f.angles[2])}const P=Eo[f.alignment]||[.5,.5];return(P[0]!==.5||P[1]!==.5)&&(E=sn(E,(.5-P[0])*x,(.5-P[1])*M,0)),{m:E,w:x,h:M}}function yr(f,T,x,M,E,P,R,B,z=!1,$=null,J=null){const re=xt(M,E);let Z=re.m;if(J){const se=(J[0]+J[2]/2)*M.scale[0],ie=(J[1]+J[3]/2)*M.scale[1];Z=sn(Z,se,-ie,0),Z=xn(Z,J[2]*M.scale[0],J[3]*M.scale[1],1)}else Z=xn(Z,re.w,re.h,1);const ce=gt(P,Z),le=f===O?Pt:_e;t.useProgram(f),z?(Vt=0,t.enable(t.BLEND),M.containerAlphaMeaningful?t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA):t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):Xt(M.colorBlendMode),le.blendPrep!==null&&le.blendPrep!==void 0&&t.uniform1i(le.blendPrep,Vt),Ce?(t.bindFramebuffer(t.FRAMEBUFFER,Ce.fbo.fbo),t.viewport(0,0,Ce.w,Ce.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,R,B)),t.bindVertexArray(W),ft("local",zn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,T),t.uniform1i(le.tex,0),t.uniformMatrix4fv(le.mvp,!1,ce),le.color!==null&&le.color!==void 0&&t.uniform4f(le.color,x[0],x[1],x[2],x[3]),mn(le,$),t.drawArrays(t.TRIANGLES,0,6)}function mn(f,T){!f||f.frameOrigin===null||f.frameOrigin===void 0||(T?(t.uniform2f(f.frameOrigin,T[0],T[1]),t.uniform2f(f.frameU,T[2],T[3]),t.uniform2f(f.frameV,T[4],T[5])):(t.uniform2f(f.frameOrigin,0,0),t.uniform2f(f.frameU,1,0),t.uniform2f(f.frameV,0,1)))}let pn=null,Ce=null;const dt=new Map,Ct=new Map;let gn=!0;function Wn(f,T){const x=xt(f,T),M=T&&T.perspective?f.scale[1]:-f.scale[1],E=T&&T.perspective&&f.scale[2]||1;return xn(x.m,f.scale[0],M,E)}function Vn(f,T,x,M,E,P,R){Ce?(t.bindFramebuffer(t.FRAMEBUFFER,Ce.fbo.fbo),t.viewport(0,0,Ce.w,Ce.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,M,E));const B=gt(x,Wn(f,T));pn(f,B,{time:P,overrideTex:R||null}),Wt=null}let Ht=null;function A(f,T){return Ht===null&&(Ht=t.createTexture(),t.bindTexture(t.TEXTURE_2D,Ht),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,Ht),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB8,0,0,f,T,0),Ht}function L(f,T,x,M,E,P,R,B){const z=A(R,B),$=xt(f,E);let J=$.m;J=xn(J,$.w,$.h,1);const re=gt(P,J),Z=[[-.5,.5],[.5,.5],[-.5,-.5],[.5,-.5]].map(([ee,ue])=>{const ve=Bs(re,ee,ue,0);return[ve[0]*.5+.5,ve[1]*.5+.5]}),[ce,le,se,ie]=Z,F=new Float32Array([0,M,0,ce[0],ce[1],0,0,0,se[0],se[1],x,M,0,le[0],le[1],x,M,0,le[0],le[1],0,0,0,se[0],se[1],x,0,0,ie[0],ie[1]]);t.useProgram(j),yt("normal"),t.disable(t.BLEND),t.bindFramebuffer(t.FRAMEBUFFER,T.fbo),t.viewport(0,0,x,M),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(W),t.bindBuffer(t.ARRAY_BUFFER,K),t.bufferData(t.ARRAY_BUFFER,F,t.DYNAMIC_DRAW),Wt=null,t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,z),t.uniform1i(Jt.tex,0),t.uniformMatrix4fv(Jt.mvp,!1,yn(0,x,0,M,-1e4,1e4)),t.drawArrays(t.TRIANGLES,0,6),t.enable(t.BLEND)}function I(f,T,x,M,E){if(!gn||Ce)return;const P=Ct.get(f.id);if(!P||P.size===0)return;const R=Math.max(1,Math.round(Math.abs(f.size[0]*(f.scale[0]||1)))),B=Math.max(1,Math.round(Math.abs(f.size[1]*(f.scale[1]||1))));if(R<=1&&B<=1)return;const z=Q(R,B,"lc:"+f.id);L(f,z,R,B,T,x,M,E);for(const $ of P)dt.set($,z);Ct.delete(f.id),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,M,E)}async function U(f,T,x,M,E,P,R,B){G++,t.viewport(0,0,x,M);const z=f.general||{};if(z.clearenabled!==!1){const F=Co(z.clearcolor||"0 0 0");t.clearColor(F[0],F[1],F[2],1)}else t.clearColor(0,0,0,1);if(t.clear(t.COLOR_BUFFER_BIT),Et>=0){const F=E-Et;ze=F>0&&F<1?F:Math.min(.1,Math.max(.001,F||1/60))}Et=E;const $=Ds(f,x,M,P,R,B);let J=gt($.projection,$.view);const re=z.cameraparallax,Z=re===!0||re!==null&&typeof re=="object"&&re.value===!0;$t=0,ot=0;const ce=lt();if(ce&&(He.x=ce.u*2-1,He.y=ce.v*2-1),!$.perspective&&n.parallax!==!1&&Z){const F=(Lt,fe)=>{const ge=Lt!==null&&typeof Lt=="object"?Lt.value:Lt;return typeof ge=="number"&&Number.isFinite(ge)?ge:fe},ee=F(z.cameraparallaxamount,0),ue=F(z.cameraparallaxmouseinfluence,1),ve=F(z.cameraparallaxdelay,1),Me=E-hr;hr=E;const he=Me>0?1-Math.exp(-Me/Math.max(.05,ve)):1;He.sx+=(He.x-He.sx)*he,He.sy+=(He.y-He.sy)*he;const Re=ee*ue,Te=60,Ge=He.sx*Re*$.viewW,wt=He.sy*Re*$.viewH,Rt=Math.max(Math.abs(Ge),Math.abs(wt))/Te,en=Rt>1?1/Rt:1;$t=-(Ge*en),ot=-(wt*en)}if(!$.perspective&&n.shake!==!1){const F=fn(z,E);if(F){const ee=F.x*$.viewW*.02,ue=F.y*$.viewH*.02;(ee!==0||ue!==0)&&(J=gt(J,sn(on(),ee,ue,0)))}}if(Ze){const F=typeof Ze=="function"?Ze():Ze;F&&typeof F.syncWorld=="function"&&F.syncWorld($,0,0)}if(!D){D=!0;const F=(f.layers||[]).filter(ve=>ve.isContainer),ee=F.filter(ve=>(ve.effects||[]).some(Me=>Me.visible)&&!ve.hasChildren),ue=ee.filter(ve=>(ve.effects||[]).some(Me=>(Me.materialPasses||[]).length>0));o(`containers total=${F.length} canvasCandidates=${ee.length} passesResolved=${ue.length} names=${ee.slice(0,4).map(ve=>ve.name||"?").join("/")}`)}await X(f,T,$,x,M,E);const le=new Map;for(const F of f.layers)F.id!==void 0&&le.set(F.id,F);const se=new Set;for(const F of f.layers)!F.visible||F.destroyed||!F.isContainer||!F.hasChildren||!(F.effects||[]).some(ue=>ue.visible)||(F.childIds||[]).length===0||tr(F,le,se);if(a)try{a()}catch(F){o("particle advance error: "+(F&&F.message))}const ie=$.perspective?f.layers.slice().sort((F,ee)=>+!!ee.isSkybox-+!!F.isSkybox):f.layers;for(const F of ie)if(!(!F.visible||F.destroyed)&&!(F.isPostProcess&&!(F.effects||[]).some(ee=>ee.visible))&&!se.has(F.id)){if(F.isContainer){if(!(F.effects||[]).some(ue=>ue.visible)){I(F,$,J,x,M);continue}if(F.hasChildren){(F.childIds||[]).length>0&&await ne(F,f,T,$,J,x,M,E);continue}}if(F.particle){if(u)try{await u(F.id,$,J,x,M)}catch(ee){o("particle render error: "+(ee&&ee.message))}continue}jn(F,$)||await Y(F,T,$,J,x,M,E)}if(mr(z)&&E<kn){const F=Math.max(0,Math.min(1,E/kn)),ee=1-F*F*(3-2*F);if(ee>.002){const ue=Co(z.clearcolor||"0 0 0");t.useProgram(k),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,x,M),t.bindVertexArray(W),ft("pass",it),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,Pe),t.uniform1i(_e.tex,0),t.uniform4f(_e.color,ue[0],ue[1],ue[2],ee),mn(_e,null),_e.blendPrep!==null&&_e.blendPrep!==void 0&&t.uniform1i(_e.blendPrep,0),t.uniformMatrix4fv(_e.mvp,!1,Je),t.drawArrays(t.TRIANGLES,0,6)}}t.bindVertexArray(null),q()}async function X(f,T,x,M,E,P){dt.clear(),Ct.clear();const R=new Map,B=new Set;let z=null;const $=J=>{if(typeof J!="string")return;const re=/^_rt_imageLayerComposite_(\d+)_[a-z]$/.exec(J);if(!re)return;const Z=Number(re[1]);z!==null&&Z===z&&B.add(Z);let ce=R.get(Z);ce||(ce=new Set,R.set(Z,ce)),ce.add(J)};for(const J of f.layers||[]){z=J.id;for(const re of J.effects||[])if(re.visible){for(const Z of re.passes||[])for(const ce of Z.textures||[])$(ce);for(const Z of re.materialPasses||[]){for(const ce of Z.binds||[])$(ce&&ce.name);for(const ce of Z.textures||[])$(ce)}}}if(R.size!==0){for(const[J,re]of R){const Z=(f.layers||[]).find(Te=>Te.id===J);if(!Z||Z.particle||Z.isPostProcess||B.has(J))continue;const ce=typeof Z.image=="string"?Z.image:"";if(Z.isContainer&&!Z.hasChildren&&ce.indexOf("models/util/composelayer")===0&&!(Z.effects||[]).some(Te=>Te.visible)){Ct.set(J,re);continue}const se=Math.max(1,Math.round(Math.abs(Z.size[0]*(Z.scale[0]||1)))),ie=Math.max(1,Math.round(Math.abs(Z.size[1]*(Z.scale[1]||1))));if(se<=1&&ie<=1)continue;const F=Q(se,ie,"lc:"+J);t.bindFramebuffer(t.FRAMEBUFFER,F.fbo),t.viewport(0,0,se,ie),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const ee={view:x.view,projection:yn(0,se,0,ie,-1e4,1e4),eye:x.eye,projW:se,projH:ie,offX:0,offY:0,viewW:se,viewH:ie},ue=Ce,ve=Z.origin,Me=Z.scale,he=Z.angles,Re=Z.visible;Ce={fbo:F,w:se,h:ie},Z.origin=[se/2,ee.projH-ie/2,ve[2]],Z.scale=[Math.sign(Me[0])||1,Math.sign(Me[1])||1,Me[2]],Z.angles=[0,0,0],Z.visible=!0;try{await Y(Z,T,ee,ee.projection,se,ie,P);for(const Te of re)dt.set(Te,F)}catch(Te){o(`composite \u6E90\u5C42 ${J} \u6E32\u67D3\u5931\u8D25: ${Te&&Te.message}`)}finally{Ce=ue,Z.origin=ve,Z.scale=Me,Z.angles=he,Z.visible=Re}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,M,E)}}async function ne(f,T,x,M,E,P,R,B){const z=Math.max(1,Math.round(Math.abs(f.size[0]))),$=Math.max(1,Math.round(Math.abs(f.size[1])));if((f.childIds||[]).length===0)return;const re=new Map;for(const he of T.layers)he.id!==void 0&&re.set(he.id,he);const Z=tr(f,re),ce=T.layers.filter(he=>Z.has(he.id)&&he.visible);if(ce.length===0)return;const le=Q(z,$,"group");t.bindFramebuffer(t.FRAMEBUFFER,le.fbo),t.viewport(0,0,z,$),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const se={view:M.view,projection:yn(0,z,0,$,-1e4,1e4),eye:M.eye,projW:z,projH:$,offX:0,offY:0,viewW:z,viewH:$},ie=se.projection,F=f.scale[0]||1,ee=f.scale[1]||1,ue=f.angles[2]||0,ve=Math.cos(-ue),Me=Math.sin(-ue);Ce={fbo:le,w:z,h:$};try{for(const he of ce){if(he.isPostProcess||he.particle||he.isContainer&&(he.childIds||[]).length>0)continue;const Re=he.origin,Te=he.scale,Ge=he.angles,wt=Re[0]-f.origin[0],Rt=Re[1]-f.origin[1],en=(wt*ve-Rt*Me)/F,Lt=(wt*Me+Rt*ve)/ee;he.origin=[z/2+en,$/2+Lt,Re[2]],he.scale=[Te[0]/F,Te[1]/ee,Te[2]],he.angles=[Ge[0],Ge[1],Ge[2]-ue];try{await Y(he,x,se,ie,z,$,B)}finally{he.origin=Re,he.scale=Te,he.angles=Ge}}}finally{Ce=null}f.groupTex=le.tex,f.groupW=z,f.groupH=$;try{await Y(f,x,M,E,P,R,B)}finally{f.groupTex=null}}async function Y(f,T,x,M,E,P,R){const B=!!(f.puppet&&pn),z=!f.solid&&f.textureName?T.get(f.textureName):null;if(z&&z.video){const fe=z.video;if(fe.readyState>=2&&fe.currentTime!==z.lastUploaded){t.bindTexture(t.TEXTURE_2D,z.glTex);try{let ge=fe.videoWidth||z.width,de=fe.videoHeight||z.height;const Ne=2048,Mt=t.getParameter(t.MAX_TEXTURE_SIZE),ht=Mt>0&&Mt<4096?Math.min(Ne,Mt):Ne;let Gt=1;Math.max(ge,de)>ht&&(Gt=ht/Math.max(ge,de));const mt=Math.max(1,Math.round(ge*Gt)),$e=Math.max(1,Math.round(de*Gt));let xr=fe;if(i&&mt>0&&$e>0){(i.width!==mt||i.height!==$e)&&(i.width=mt,i.height=$e);const Ft=i.getContext("2d");Ft&&(Ft.clearRect(0,0,mt,$e),Ft.drawImage(fe,0,0,mt,$e),xr=i)}if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,xr),t.getError()!==t.NO_ERROR&&i)try{const Yt=i.getContext("2d").getImageData(0,0,i.width,i.height);for(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,i.width,i.height,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(Yt.data.buffer));t.getError()!==t.NO_ERROR;);}catch{}z.width=mt,z.height=$e,z.lastUploaded=fe.currentTime,s||(s=!0,o("video tex ready "+mt+"x"+$e+" (src "+ge+"x"+de+")"))}catch(ge){s||(s=!0,o("video upload FAIL: "+(ge&&ge.message||ge))),console.warn("[we-scene] \u89C6\u9891\u5E27\u4E0A\u4F20\u5931\u8D25:",ge&&ge.message,"readyState=",fe.readyState,"cur=",fe.currentTime)}}}const $=f.groupTex?f.groupTex:z&&z.glTex?z.glTex:f.solid?Pe:Ae,J=(!!f.passthrough||!!f.isPostProcess||No(f))&&!f.groupTex&&!z&&!B;let re,Z;if(f.groupTex?(re=f.groupW||f.size[0],Z=f.groupH||f.size[1]):B||!z?(re=f.size[0],Z=f.size[1]):(re=z.width,Z=z.height),!B&&z&&f.spriteSheet){const fe=z.frames,ge=Array.isArray(fe)?fe:fe&&fe.list;ge&&ge.length&&(re=ge[0].width||re,Z=ge[0].height||Z)}const ce=Math.max(1,Math.round(re)),le=Math.max(1,Math.round(Z)),se=[f.color[0]*f.brightness,f.color[1]*f.brightness,f.color[2]*f.brightness,f.alpha],ie=(f.effects||[]).filter(fe=>fe.visible);let F=ce,ee=le;if(c>0&&x.projW>0&&x.projH>0){const fe=Math.min(Math.abs(f.size[0]*f.scale[0]),x.viewW),ge=Math.min(Math.abs(f.size[1]*f.scale[1]),x.viewH),de=fe*(E/x.projW),Ne=ge*(P/x.projH);if(de>0&&Ne>0){const Mt=Math.max(64,Math.round(de*c)),ht=Math.max(64,Math.round(Ne*c));Mt<ce&&(F=Mt),ht<le&&(ee=ht)}}if(ie.length===0){B?Vn(f,x,M,E,P,R):yr(k,$,se,f,x,M,E,P,!1,vr(f,z,R));return}const ue=Q(F,ee,"ping"),ve=Q(F,ee,"pong"),Me=yn(0,F,0,ee,-1e4,1e4);if(B)t.useProgram(k),yt("normal"),t.bindFramebuffer(t.FRAMEBUFFER,ue.fbo),t.viewport(0,0,F,ee),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(W),Wt=null,ft("layer"+F+"x"+ee,jt(F,ee)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,$),t.uniform1i(_e.tex,0),t.uniform4f(_e.color,1,1,1,1),mn(_e,null),_e.blendPrep!==null&&_e.blendPrep!==void 0&&t.uniform1i(_e.blendPrep,0),t.uniformMatrix4fv(_e.mvp,!1,Me),t.drawArrays(t.TRIANGLES,0,6);else if(J)L(f,ue,F,ee,x,M,E,P);else{t.useProgram(k),yt("normal"),t.bindFramebuffer(t.FRAMEBUFFER,ue.fbo),t.viewport(0,0,F,ee),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(W),ft("layer"+F+"x"+ee,jt(F,ee)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,$),t.uniform1i(_e.tex,0);const fe=ie.some(ge=>ge&&ge.layerMaterial)?[1,1,1,se[3]]:se;t.uniform4f(_e.color,fe[0],fe[1],fe[2],fe[3]),mn(_e,vr(f,z,R)),_e.blendPrep!==null&&_e.blendPrep!==void 0&&t.uniform1i(_e.blendPrep,0),t.uniformMatrix4fv(_e.mvp,!1,Me),t.drawArrays(t.TRIANGLES,0,6)}let he=ue,Re=ve;const Te=new Map;let Ge=!1,wt=ue;const Rt=[],en=new Set;for(const fe of ie){for(const de of fe.fbos||[])if(!Te.has(de.name)){const[Ne,Mt]=Uo(de,F,ee),ht=de.unique?f.id+":"+de.name:de.name;Te.set(de.name,Q(Ne,Mt,ht))}const ge=fe.materialPasses||[];for(let de=0;de<ge.length;de++)Rt.push({eff:fe,mp:ge[de],ov:fe.passes&&fe.passes[de]})}const Lt=[];for(let fe=0;fe<Rt.length;fe++){const{eff:ge,mp:de,ov:Ne}=Rt[fe];if(en.has(ge))continue;const Mt={...de.combos||{},...Ne&&Ne.combos||{}},ht=de.textures||[],Gt=Ne&&Ne.textures||[],mt=[];for(let ye=0;ye<Math.max(ht.length,Gt.length);ye++)Gt[ye]!==void 0&&Gt[ye]!==null?mt[ye]=Gt[ye]:mt[ye]=ht[ye]!==void 0?ht[ye]:null;if(de.copyCommand){const ye=de.source?Te.get(de.source):null,je=de.target?Te.get(de.target):null;ye&&je&&(t.useProgram(O),yt("normal"),t.bindFramebuffer(t.FRAMEBUFFER,je.fbo),t.viewport(0,0,je.width,je.height),t.bindVertexArray(W),ft("pass",it),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,ye.tex),t.uniform1i(Pt.tex,0),Pt.blendPrep!==null&&Pt.blendPrep!==void 0&&t.uniform1i(Pt.blendPrep,0),t.uniformMatrix4fv(Pt.mvp,!1,Je),t.drawArrays(t.TRIANGLES,0,6),t.bindFramebuffer(t.FRAMEBUFFER,null));continue}let $e;try{$e=await Xe(de.shader,Mt,mt)}catch(ye){console.warn("[we-scene] \u8DF3\u8FC7\u6548\u679C\uFF08pass \u7F16\u8BD1\u5931\u8D25\uFF09:",de.shader,ye&&ye.message||ye),en.add(ge);continue}const xr=$e.prog,Ft=$e.uni;$e.fragGlsl&&Lt.push($e.fragGlsl);let Yt,Xn;de.target?(Ge||(wt=he,Ge=!0),Yt=Te.get(de.target)||he,Xn=wt):(Ge=!1,Yt=Re,Xn=he),t.useProgram(xr),yt(de.blending||"normal"),t.bindFramebuffer(t.FRAMEBUFFER,Yt.fbo),t.viewport(0,0,Yt.width,Yt.height),t.bindVertexArray(W),ft("pass",it);const no=de.textures||[],sl=Math.max(no.length,8),ji=new Map,al=new Set;for(let ye=0;ye<sl;ye++){let je=ye<no.length?no[ye]:null;Ne&&Ne.textures&&Ne.textures[ye]!==void 0&&Ne.textures[ye]!==null&&(je=Ne.textures[ye]);for(const Gn of de.binds||[])Gn.index===ye&&(je=Gn.name);let _t;if(ye===0&&(je==null||je===""))_t=Xn;else{if((je==null||je==="")&&$e.samplerDefaults){const Gn=$e.samplerDefaults.get(ye);Gn&&(je=Gn)}_t=Qt(je,Xn,Te,T)}je==="previous"&&(_t=Xn),_t===null&&(_t={glTex:Pe,width:1,height:1,tex:Pe});const Hn=_t.fbo?_t:{tex:_t.glTex||Pe,width:_t.width||1,height:_t.height||1};t.activeTexture(t.TEXTURE0+ye),t.bindTexture(t.TEXTURE_2D,Hn.tex),al.add(ye),ji.set(ye,[Hn.width,Hn.height,Hn.width,Hn.height])}gr(Ft,f,R,x.projW,x.projH,Je,Me,Je,ji,Me,x),dn(Ft,Dn(ut({...de.constants||{},...Ne&&Ne.constantshadervalues||{}},(f.id||f.name||"?")+"|"+(de.shader||"?")+"|"+fe,R,f),(f.id||f.name||"?")+"|"+(de.shader||"?")+"|"+fe,R),$e.matMeta),hn(Ft),t.drawArrays(t.TRIANGLES,0,6),de.target||(Re=he,he=Yt)}if(f.isContainer&&!f.groupTex&&!J&&f.containerAlphaMeaningful===void 0){let fe=!1;for(const ge of Lt){if(typeof ge!="string")continue;const de=ge.match(/\bfloat\s+alpha\s*=\s*([^;]+);/);if(de&&!/^\s*scene\s*\.\s*a\s*$/.test(de[1])){fe=!0;break}}f.containerAlphaMeaningful=fe,o(`container "${f.name||"?"}" alpha ${fe?"\u643A\u5E26\u5F62\u72B6 \u2192 SRC_ALPHA":"\u65E0\u4FE1\u606F \u2192 \u52A0\u6CD5"}`)}if(B){Vn(f,x,M,E,P,R,he.tex);return}yr(O,he.tex,[1,1,1,1],f,x,M,E,P,!!f.isContainer&&!f.groupTex&&!J,null,null)}return{gl:t,render:U,getFBO:Q,getEffectProgram:Xe,progCache:te,shaderResolver:r,whiteTex:Pe,resetShaderCaches:function(){te.clear(),me.clear(),xe&&xe.clear()},setFboCapFactor:function(f){c=f},setParticleRenderer:function(f,T){a=typeof f=="function"?f:null,u=typeof T=="function"?T:null},setConstantScriptRuntime:N,applyConstUserProperties:function(f){if(f){for(const T of S.values())if(T&&typeof T.applyUserProperties=="function")try{T.applyUserProperties(f)}catch{}}},constantScriptStats:function(){return{...C,cached:S.size}},setCompositeEnabled:function(f){gn=!!f},compositeStats:function(){const f=[],T=new Uint8Array(4);for(const[x,M]of dt){let E=null;try{t.bindFramebuffer(t.FRAMEBUFFER,M.fbo),t.readPixels(M.w>>1,M.h>>1,1,1,t.RGBA,t.UNSIGNED_BYTE,T),E=[T[0],T[1],T[2],T[3]]}catch{}f.push({name:x,w:M.w,h:M.h,center:E})}return t.bindFramebuffer(t.FRAMEBUFFER,null),f},setPuppetRenderer:function(f){pn=f},setAudioProvider:h,setPointerProvider:to,getParallaxOffset:function(){return{x:$t,y:ot}},dispose:function(){try{const f=t.getExtension("WEBGL_lose_context");f&&f.loseContext()}catch{}}}}const ca=Object.freeze(Object.defineProperty({__proto__:null,ALIGN:Eo,XRAY_IDLE_SCREEN_UV:_n,applyColorBlendCPU:oa,collectGroupDescendantIds:tr,colorBlendPlan:kr,createRenderer:aa,effectFboSize:Uo,layerWantsPreserveBackdrop:No,makeTexture:Nr,makeTextureMip:Js,puppetAnimMargin:Fo,rewriteXrayFragScale:ko,xrayShouldParkPointer:Br,xrayUvScale:ia},Symbol.toStringTag,{value:"Module"}));function la(e=256,n=8){const t=e/n,r=Bo(1337),o=Bo(4242),i=new Float32Array(t*t),s=new Float32Array(t*t);for(let u=0;u<t*t;u++)i[u]=r(),s[u]=o();const c=new Uint8Array(e*e*4),a=n;for(let u=0;u<e;u++){const l=Math.floor(u/a),d=u%a/a,h=d*d*(3-2*d);for(let p=0;p<e;p++){const w=Math.floor(p/a),m=p%a/a,g=m*m*(3-2*m),v=w%t,b=(w+1)%t,y=l%t,S=(l+1)%t,_=i[y*t+v],C=i[y*t+b],N=i[S*t+v],D=i[S*t+b],k=s[y*t+v],O=s[y*t+b],j=s[S*t+v],W=s[S*t+b],K=_+(C-_)*g+(N-_)*h+(_-C-N+D)*g*h,V=k+(O-k)*g+(j-k)*h+(k-O-j+W)*g*h,G=(u*e+p)*4;c[G]=Math.round(K*255),c[G+1]=Math.round(V*255),c[G+2]=0,c[G+3]=255}}return c}function Bo(e){let n=e>>>0;return()=>{n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const ua=Object.freeze(Object.defineProperty({__proto__:null,generateNoiseTexture:la},Symbol.toStringTag,{value:"Module"})),at=Math.PI*2;function Le(e,n){return e==null?Math.random():n==null?e:e+Math.random()*(n-e)}function Io(e,n,t){if(e==null)return Math.random();if(n==null)return e;const r=t&&t!==1?Math.pow(Math.random(),t):Math.random();return e+r*(n-e)}function be(e,n){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e==null)return n?n.slice():[0,0,0];if(typeof e=="object")return be(e.value,n);if(typeof e=="number")return[e,e,e];const t=String(e).trim().split(/\s+/).map(Number);return[t[0]||0,t[1]||0,t[2]||0]}function Oo(e){return e==null?null:typeof e=="number"?[e,e,e]:be(e)}function H(e,n){if(e==null)return n;if(typeof e=="object")return H(e.value,n);const t=Number(e);return Number.isFinite(t)?t:n}function Ir(e,n){const t=e[0],r=e[1]>t?e[1]:t+1e-6,o=Math.min(1,Math.max(0,(n-t)/(r-t)));return o*o*(3-2*o)}function Bt(e,n,t){const r=Math.sin(e*127.1+n*311.7+t*74.7)*43758.5453;return r-Math.floor(r)}function fa(e,n,t){const r=Math.floor(e),o=Math.floor(n),i=Math.floor(t),s=e-r,c=n-o,a=t-i,u=s*s*(3-2*s),l=c*c*(3-2*c),d=a*a*(3-2*a),h=(v,b,y)=>v+(b-v)*y,p=h(Bt(r,o,i),Bt(r+1,o,i),u),w=h(Bt(r,o+1,i),Bt(r+1,o+1,i),u),m=h(Bt(r,o,i+1),Bt(r+1,o,i+1),u),g=h(Bt(r,o+1,i+1),Bt(r+1,o+1,i+1),u);return h(h(p,w,l),h(m,g,l),d)}function Or(e,n,t,r){let o=0,i=.5,s=1,c=0;for(let a=0;a<r;a++)o+=i*fa(e*s,n*s,t*s),c+=i,i*=.5,s*=2;return o/(c||1)}function Dr(e,n,t,r){return[Or(e,n,t,r)*2-1,Or(e+31.7,n+11.3,t+57.1,r)*2-1,Or(e+73.9,n+92.1,t+13.7,r)*2-1]}function da(e){const n=`#version 300 es
|
|
65
|
+
}`;function xa(e,n){return new Float32Array([0,n,0,0,1,0,0,0,0,0,e,n,0,1,1,e,n,0,1,1,0,0,0,0,0,e,0,0,1,0])}function wa(){return new Float32Array([-1,1,0,0,1,-1,-1,0,0,0,1,1,0,1,1,1,1,0,1,1,-1,-1,0,0,0,1,-1,0,1,0])}function Ma(){return new Float32Array([-.5,.5,0,0,1,-.5,-.5,0,0,0,.5,.5,0,1,1,.5,.5,0,1,1,-.5,-.5,0,0,0,.5,-.5,0,1,0])}const _a={5126:"float",35664:"vec2",35665:"vec3",35666:"vec4",5124:"int",35667:"ivec2",35668:"ivec3",35669:"ivec4",35670:"bool",35676:"mat4",35675:"mat3"};function er(e,n,t){const r=zo(e,e.VERTEX_SHADER,n),o=zo(e,e.FRAGMENT_SHADER,t),i=e.createProgram();if(e.attachShader(i,r),e.attachShader(i,o),e.bindAttribLocation(i,0,"a_Position"),e.bindAttribLocation(i,1,"a_TexCoord"),e.linkProgram(i),!e.getProgramParameter(i,e.LINK_STATUS))throw new Error("\u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(i));return i}function zo(e,n,t){const r=e.createShader(n);if(e.shaderSource(r,t),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS))throw new Error("\u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(r));return r}function Vo(e){e!==null&&typeof e=="object"&&"value"in e&&(e=e.value);const n=String(e??"").trim().split(/\s+/).map(Number);return[n[0]||0,n[1]||0,n[2]||0]}function jr(e,n,t,r,o=null){const i=e.createTexture();return e.bindTexture(e.TEXTURE_2D,i),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),o?e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o):e.texImage2D(e.TEXTURE_2D,0,e.RGBA,t,r,0,e.RGBA,e.UNSIGNED_BYTE,n),i}function Aa(e,n,t=!1){const r=e.createTexture();e.bindTexture(e.TEXTURE_2D,r),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR_MIPMAP_LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR);const o=n[0];if(o.bitmap)e.texImage2D(e.TEXTURE_2D,0,e.RGBA,e.RGBA,e.UNSIGNED_BYTE,o.bitmap);else if(t&&o.rgba){const i=o.width*o.height,s=new Uint8Array(i*2);for(let c=0;c<i;c++)s[c*2]=o.rgba[c*4+3],s[c*2+1]=o.rgba[c*4];const a=e.getParameter(e.UNPACK_ALIGNMENT);e.pixelStorei(e.UNPACK_ALIGNMENT,1),e.texImage2D(e.TEXTURE_2D,0,e.RG8,o.width,o.height,0,e.RG,e.UNSIGNED_BYTE,s),e.pixelStorei(e.UNPACK_ALIGNMENT,a)}else e.texImage2D(e.TEXTURE_2D,0,e.RGBA,o.width,o.height,0,e.RGBA,e.UNSIGNED_BYTE,o.rgba);return e.generateMipmap(e.TEXTURE_2D),r}function zr(e,n,t,r,o){const i=1-o;return i*i*i*e+3*i*i*o*n+3*i*o*o*t+o*o*o*r}function Ta(e,n,t,r,o){if(o<=e)return 0;if(o>=r)return 1;let i=r-e>1e-9?(o-e)/(r-e):.5;for(let c=0;c<8;c++){const u=zr(e,n,t,r,i)-o;if(Math.abs(u)<1e-6)return i;const l=1-i,p=3*l*l*(n-e)+6*l*i*(t-n)+3*i*i*(r-t);if(Math.abs(p)<1e-9)break;const f=i-u/p;if(f<0||f>1||!Number.isFinite(f))break;i=f}let s=0,a=1;for(let c=0;c<40;c++)i=(s+a)/2,zr(e,n,t,r,i)<o?s=i:a=i;return i}function tr(e,n,t){if(!e||e.length===0)return 0;if(e.length===1)return Number(e[0].value)||0;if(t&&t.length>0){const k=e[0],U=e[e.length-1],V=t.length-U.frame;if(V>1e-9&&n>U.frame&&n<=t.length)return tr([{frame:0,value:U.value,front:U.front,back:U.back},{frame:V,value:k.value,front:k.front,back:k.back}],n-U.frame)}if(n<=e[0].frame)return Number(e[0].value)||0;const r=e[e.length-1];if(n>=r.frame)return Number(r.value)||0;let o=0,i=e.length-1;for(;i-o>1;){const k=o+i>>1;e[k].frame<=n?o=k:i=k}const s=e[o],a=e[i],c=s.frame,u=a.frame,l=Number(s.value)||0,p=Number(a.value)||0,f=u-c;if(f<=0)return p;const d=s.front,w=a.back,M=f/3,m=!!(d&&d.enabled),A=!!(w&&w.enabled),h=m?Math.abs(Number(d.x)||0):1,b=A?Math.abs(Number(w.x)||0):1,v=c+Math.min(h,1.5)*M,T=u-Math.min(b,1.5)*M,_=m?l+(Number(d.y)||0):l+(p-l)/3,F=A?p+(Number(w.y)||0):p-(p-l)/3,R=Ta(c,v,T,u,n);return zr(l,_,F,p,R)}function Wo(e,n,t){const r=n>0?n:1;if(t==="loop"){let o=e%r;return o<0&&(o+=r),o}if(t==="mirror"){const o=r*2;let i=e%o;return i<0&&(i+=o),i<=r?i:o-i}return Math.max(0,Math.min(r,e))}function Sa(e){return Array.isArray(e)?e:typeof e=="string"?e.trim().split(/\s+/).map(Number):Number.isFinite(e)?[e]:[]}function Ho(e){const n=e&&e.options||{},t=Number(n.fps)>0?Number(n.fps):30,r=Number(n.length)>0?Number(n.length):0,o=n.mode==="loop"||n.mode==="mirror"?n.mode:"single",i=typeof n.name=="string"?n.name:"",s=!!(e&&e.relative),a=n.wraploop===!0&&o==="loop",c=[];for(let f=0;;f++){const d=e&&e["c"+f];if(!Array.isArray(d))break;c.push(d)}const u=n.startpaused!==!0,l=[],p={name:i,mode:o,fps:t,relative:s,channelCount:c.length,frame:0,rate:1,playing:u,ended:!1,get frameCount(){return r},play(){return p.playing=!0,p.ended=!1,p},pause(){return p.playing=!1,p},stop(){return p.playing=!1,p.frame=0,p.ended=!1,p},setFrame(f){const d=Number(f);return Number.isFinite(d)&&(p.frame=d),p},getFrame(){return p.frame},setRate(f){const d=Number(f);return Number.isFinite(d)&&(p.rate=d),p},addEndedCallback(f){return typeof f=="function"&&l.push(f),p},setBlend(){return p},setVisible(){return p},advance(f){if(p.playing&&(p.frame+=(Number(f)||0)*t*p.rate,o==="single"))if(p.frame>=r){if(p.frame=r,p.playing=!1,!p.ended){p.ended=!0;for(const d of l)try{d()}catch{}}}else p.frame<0&&(p.frame=0,p.playing=!1)},value(){const f=Wo(p.frame,r,o),d=a?{length:r}:void 0;if(c.length===1)return tr(c[0],f,d);const w=[];for(const M of c)w.push(tr(M,f,d));return w},applyTo(f){const d=p.value();if(!s)return d;const w=Sa(f);return Array.isArray(d)?d.map((M,m)=>M+(Number(w[m])||0)):d+(Number(w[0])||0)}};return p}function Ea(){const e={name:"",mode:"single",fps:30,relative:!1,channelCount:0,frame:0,rate:1,playing:!1,ended:!1,get frameCount(){return 0},play(){return e},pause(){return e},stop(){return e},setFrame(){return e},getFrame(){return 0},setRate(){return e},addEndedCallback(){return e},setBlend(){return e},setVisible(){return e},advance(){},value(){return 0},applyTo(n){return n}};return e}const Pa=Object.freeze(Object.defineProperty({__proto__:null,createAnimation:Ho,createNeutralAnimation:Ea,sampleChannel:tr,wrapFrame:Wo},Symbol.toStringTag,{value:"Module"}));function Xo(e){const n=e&&e.puppet&&e.puppet.animBound;return n?[n.x*Math.abs(e.scale[0]),n.y*Math.abs(e.scale[1])]:[0,0]}function Go(e){for(const n of e&&e.effects||[]){if(n.visible===!1)continue;const t=Math.max((n.passes||[]).length,(n.materialPasses||[]).length);for(let r=0;r<t;r++){const o=n.passes&&n.passes[r]&&n.passes[r].combos||{},i=n.materialPasses&&n.materialPasses[r]&&n.materialPasses[r].combos||{},s=o.TRANSPARENCY!==void 0?o.TRANSPARENCY:i.TRANSPARENCY;if(Number(s)===0)return!0}}return!1}function nr(e,n,t){if(t||(t=new Set),!n)return t;for(const r of e.childIds||[]){const o=n.get(r);!o||o.particle||o.isPostProcess||(t.add(r),nr(o,n,t))}return t}function Vr(e){const n=ma[e]||"translucent";return{mode:n,prep:ga[n]||0}}function Ca(e,n,t,r){const{mode:o,prep:i}=Vr(e);let s=t;return i===1?s=t*r:i===2&&(s=1-r+t*r),o==="screen"?s+n*(1-s):o==="multiply"?n*s:o==="additive"?n+t*r:n*(1-r)+t*r}function qo(e,n,t){const r=e&&Number(e.scale)||1;let o=Math.max(1,Math.round(n/r)),i=Math.max(1,Math.round(t/r));const s=e&&Number(e.fit);if(Number.isFinite(s)&&s>0){const a=Math.max(o,i);if(a>s){const c=s/a;o=Math.max(1,Math.round(o*c)),i=Math.max(1,Math.round(i*c))}}return[o,i]}function La(e){const n=Number(e);return!Number.isFinite(n)||n<.001?999:1/n}const Ln=-1;function Wr(e,n){return!!n&&!e}const Ra="mix(999.0, 1.0 / max(g_PointerScale, 0.001), step(0.001, g_PointerScale))";function Yo(e){if(typeof e!="string"||/unprojectedUVs\s*\*=\s*mix\(999\.0,\s*1\.0\s*\/\s*max\(\s*g_PointerScale/.test(e))return e;const n=/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/.test(e),t=/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/.test(e);if(!n&&!t)return e;let r=e;/uniform\s+float\s+g_PointerScale\b/.test(r)||(r=r.replace(/void\s+main\s*\(/,`uniform float g_PointerScale;
|
|
66
|
+
void main(`));const o=n?/unprojectedUVs\s*\*=\s*v_PointerScale\s*\*/:/unprojectedUVs\s*\*=\s*g_PointerScale\s*\*/;return r.replace(o,"unprojectedUVs *= "+Ra+" *")}function Fa(e,n={}){const t=e.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0});if(!t)throw new Error("\u5F53\u524D\u6D4F\u89C8\u5668\u4E0D\u652F\u6301 WebGL2");const r=n.shaderResolver||(async()=>null),o=n.diag||(()=>{}),i=typeof document<"u"?document.createElement("canvas"):null;i&&(i.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0");let s=!1,a=n.fboCapFactor===void 0?0:n.fboCapFactor,c=null,u=null,l=null;const p=[["g_AudioSpectrum16Left","left16"],["g_AudioSpectrum16Right","right16"],["g_AudioSpectrum32Left","left32"],["g_AudioSpectrum32Right","right32"],["g_AudioSpectrum64Left","left64"],["g_AudioSpectrum64Right","right64"]];function f(x){l=x||null}let d=null,w=null,M=null,m=null,A=null,h=null,b=null;const v=new Map,T=new Map,_={total:0,ok:0,failed:0};function F(x,B){d=typeof x=="function"?x:null,w=B&&B.userProperties||null,M=B&&B.audioViews||null,m=B&&B.shared||null,A=B&&B.inputView||null,h=B&&B.timers||null,b=B&&typeof B.onSandbox=="function"?B.onSandbox:null,v.clear(),T.clear()}let R=!1;const k=er(t,$r,ba),U=er(t,$r,ya),V=er(t,$r,va),q=t.createVertexArray();t.bindVertexArray(q);const W=t.createBuffer();t.bindBuffer(t.ARRAY_BUFFER,W),t.enableVertexAttribArray(0),t.vertexAttribPointer(0,3,t.FLOAT,!1,20,0),t.enableVertexAttribArray(1),t.vertexAttribPointer(1,2,t.FLOAT,!1,20,12),t.bindVertexArray(null);const Z=new Map;let K=1;function re(x,B,H){const z=(H||"")+"|"+x+"x"+B;if(Z.has(z)){const L=Z.get(z);return L.stamp=K,L}const G=t.createFramebuffer(),g=t.createTexture();t.bindTexture(t.TEXTURE_2D,g),t.texImage2D(t.TEXTURE_2D,0,t.RGBA,x,B,0,t.RGBA,t.UNSIGNED_BYTE,null),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.bindFramebuffer(t.FRAMEBUFFER,G),t.framebufferTexture2D(t.FRAMEBUFFER,t.COLOR_ATTACHMENT0,t.TEXTURE_2D,g,0),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindFramebuffer(t.FRAMEBUFFER,null);const S={fbo:G,tex:g,width:x,height:B,stamp:K};return Z.set(z,S),S}function te(){for(const[x,B]of Z)B.stamp!==K&&(B.fbo&&t.deleteFramebuffer(B.fbo),B.tex&&t.deleteTexture(B.tex),Z.delete(x))}const X=new Map,J=new Map,de=new Map;function Se(x){const B={},H=/uniform\s+[A-Za-z0-9_]+\s+([A-Za-z_][A-Za-z0-9_]*)[^;]*;\s*\/\/([^\n]*)/g;let z;for(;(z=H.exec(x))!==null;){const G=z[1],g=z[2],S=/"material"\s*:\s*"([^"]+)"/.exec(g);if(!S)continue;const L=/"default"\s*:\s*("(?:[^"]*)"|-?\d+(?:\.\d+)?)/.exec(g);B[S[1]]={uniform:G,default:L?Je(L[1]):void 0}}return B}function Ae(x){const B=new Map,H=/uniform\s+sampler2D\s+g_Texture(\d+)\s*;\s*\/\/([^\n]*)/g;let z;for(;(z=H.exec(x))!==null;){const G=Number(z[1]),g=/"default"\s*:\s*"([^"]+)"/.exec(z[2]);g&&g[1]&&B.set(G,g[1])}return B}function Ie(x){const B=[],H=/uniform\s+sampler2D\s+(g_Texture(\d+))[^;]*;\s*\/\/([^\n]*)/g;let z;for(;(z=H.exec(x))!==null;){const G=/"combo"\s*:\s*"([^"]+)"/.exec(z[3]);G&&B.push({slot:Number(z[2]),name:z[1],combo:G[1]})}return B}function Je(x){if(x.startsWith('"'))return x.slice(1,-1);const B=Number(x);return Number.isFinite(B)?B:void 0}async function Xe(x,B,H){let z=de.get(x);if(z===void 0){const S=await r("shaders/"+x+".frag")||"",L=await r("shaders/"+x+".vert")||"";z={frag:S,vert:L,texCombos:Ie(S)},de.set(x,z)}const G={...B};for(const S of z.texCombos)H&&H[S.slot]&&G[S.combo]===void 0&&(G[S.combo]=1);const g=x+"|"+JSON.stringify(G);if(X.has(g)){const S=X.get(g);if(S===null)throw new Error("shader="+x+" \u7F16\u8BD1\u5931\u8D25\uFF08\u5DF2\u7F13\u5B58\uFF09");return S}for(let S=0;S<4;S++){const L=new Set,E=I=>J.has(I)?J.get(I):(L.add(I),null),N=Yo($o(z.frag,"frag",G,E,z.vert)),j=$o(z.vert,"vert",G,E,z.frag);if(L.size===0){let I;try{I=er(t,j,N)}catch(C){throw X.set(g,null),new Error("shader="+x+" "+(C&&C.message))}const D=new Map,O=t.getProgramParameter(I,t.ACTIVE_UNIFORMS);for(let C=0;C<O;C++){const Q=t.getActiveUniform(I,C),ee=Q.name.replace(/\[0\]$/,"");D.set(ee,{loc:t.getUniformLocation(I,Q.name),type:_a[Q.type]||"unknown",size:Q.size})}const Y={...Se(z.vert),...Se(z.frag)},$=/gl_Position\s*=\s*vec4\s*\(\s*a_Position/.test(z.vert)&&!/[aA]_Position[\s\S]{0,40}mul\s*\(/.test(z.vert),P=new Map([...Ae(z.vert),...Ae(z.frag)]),y={prog:I,uni:D,matMeta:Y,samplerDefaults:P,fragGlsl:N,vertGlsl:j,ndcDirect:$};return X.set(g,y),y}await Promise.all(Array.from(L).map(async I=>{J.set(I,await r("shaders/"+I)||"")}))}throw new Error("include \u89E3\u6790\u5931\u8D25: "+x)}const Ee=jr(t,new Uint8Array([255,255,255,255]),1,1),Re=jr(t,new Uint8Array([0,0,0,0]),1,1);let le=null;function Pe(x){le=x||null}function Oe(){if(!le)return null;const x=typeof le=="function"?le():le;return x&&x.state?x.state:x}const Me={x:0,y:0,sx:0,sy:0};let _e=0,$e=0,Ge=0,ht=1/60,me=-1;const Ct=typeof n.fadeDuration=="number"&&n.fadeDuration>=0?n.fadeDuration:1,yr=(x,B)=>{const H=x!==null&&typeof x=="object"?x.value:x;return H===!0||H===1?!0:H===!1||H===0?!1:B},_t=(x,B)=>{const H=x!==null&&typeof x=="object"?x.value:x;return typeof H=="number"&&Number.isFinite(H)?H:B},vr=x=>n.fade!==!1&&yr(x.camerafade,!1);function po(x,B){if(!yr(x.camerashake,!1))return null;const H=_t(x.camerashakeamplitude,0);if(H===0)return null;const z=Math.max(0,Math.min(1,_t(x.camerashakeroughness,0))),G=_t(x.camerashakespeed,1),g=B*G,S=Math.sin(g*2.1)*Math.cos(g*.7),L=Math.cos(g*1.7)*Math.sin(g*.9),E=Math.sin(g*11.3)*Math.cos(g*7.1),N=Math.cos(g*9.7)*Math.sin(g*13.1);return{x:(S*(1-z)+E*z)*H,y:(L*(1-z)+N*z)*H}}function xr(){const x=new Date;return(x.getHours()*3600+x.getMinutes()*60+x.getSeconds())/86400}function ye(x,B,H){const z=x.get(B);z&&z.loc!==null&&H(z.loc,z.type,z.size)}function qe(x){if(typeof x=="number")return[x,x,x,x];const B=String(x).trim().split(/[\s,]+/).map(Number);return[B[0]||0,B[1]||0,B[2]||0,B[3]||0]}function vn(x,B,H){const z=x.get(B);if(!z||z.loc===null)return;const G=H&&H.value!==void 0?H.value:H,g=qe(G);switch(z.type){case"float":t.uniform1f(z.loc,g[0]);break;case"int":case"bool":t.uniform1i(z.loc,G===!0||G===1?1:Math.round(g[0]));break;case"vec2":t.uniform2f(z.loc,g[0],g[1]);break;case"vec3":t.uniform3f(z.loc,g[0],g[1],g[2]);break;case"vec4":t.uniform4f(z.loc,g[0],g[1],g[2],g[3]);break;case"mat4":t.uniformMatrix4fv(z.loc,!1,mt);break;case"mat3":t.uniformMatrix3fv(z.loc,!1,rn);break}}const Vt=()=>new Float32Array([1,0,0,0,1,0,0,0,1]);function wr(x,B,H,z,G,g,S,L,E,N,j){if(ye(x,"g_Time",y=>t.uniform1f(y,H)),ye(x,"g_Daytime",y=>t.uniform1f(y,xr())),ye(x,"g_ModelViewProjectionMatrix",y=>t.uniformMatrix4fv(y,!1,g)),ye(x,"g_ModelMatrix",y=>t.uniformMatrix4fv(y,!1,S)),ye(x,"g_ViewProjectionMatrix",y=>t.uniformMatrix4fv(y,!1,L)),x.get("g_ModelViewProjectionMatrixInverse")){let y=null;for(const[Q,ee]of E)Q===0&&(y=ee);const C=y&&y[0]>0&&y[1]>0?Co(En(pn(),y[0]/2,y[1]/2,1)):mt;ye(x,"g_ModelViewProjectionMatrixInverse",Q=>t.uniformMatrix4fv(Q,!1,C))}ye(x,"g_Brightness",y=>t.uniform1f(y,B.brightness)),ye(x,"g_UserAlpha",y=>t.uniform1f(y,B.alpha)),ye(x,"g_Alpha",y=>t.uniform1f(y,B.alpha)),ye(x,"g_Color",y=>t.uniform3f(y,B.color[0],B.color[1],B.color[2])),ye(x,"g_Color4",y=>t.uniform4f(y,B.color[0],B.color[1],B.color[2],1)),ye(x,"g_CompositeColor",y=>t.uniform3f(y,B.color[0],B.color[1],B.color[2])),ye(x,"g_TexelSize",y=>t.uniform2f(y,1/z,1/G)),ye(x,"g_TexelSizeHalf",y=>t.uniform2f(y,.5/z,.5/G)),ye(x,"g_TextureReductionScale",y=>t.uniform1f(y,1));const I=Oe(),D=Wr(!!(I&&I.has),!!x.get("g_PointerScale"));let O=D?Ln:I?I.u:.5,Y=D?Ln:I?I.v:.5,$=D?Ln:I?I.lastU:.5,P=D?Ln:I?I.lastV:.5;if(j&&B&&B.size&&B.size[0]>0&&B.size[1]>0){const y=Math.abs(B.size[0]*B.scale[0]),C=Math.abs(B.size[1]*B.scale[1]);if(y>0&&C>0){const Q=B.origin[0]-y/2,ee=j.projH-B.origin[1]-C/2,ie=fe=>(j.offX+fe*j.viewW-Q)/y,oe=fe=>(j.offY+fe*j.viewH-ee)/C;O=ie(O),Y=oe(Y),$=ie($),P=oe(P)}}ye(x,"g_PointerPosition",y=>t.uniform2f(y,O,Y)),ye(x,"g_PointerPositionLast",y=>t.uniform2f(y,$,P)),ye(x,"g_PointerState",y=>t.uniform4f(y,O,Y,I&&I.leftDown?1:0,0)),ye(x,"g_ParallaxPosition",y=>t.uniform2f(y,Me.sx*.5+.5,Me.sy*.5+.5)),ye(x,"g_Frametime",y=>t.uniform1f(y,ht)),x.get("g_EffectTextureProjectionMatrixInverse")&&ye(x,"g_EffectTextureProjectionMatrixInverse",y=>t.uniformMatrix4fv(y,!1,mt));for(let y=0;y<8;y++)ye(x,"g_Texture"+y,C=>t.uniform1i(C,y));for(const[y,C]of E)ye(x,"g_Texture"+y+"Resolution",Q=>t.uniform4f(Q,C[0],C[1],C[2],C[3]));if(l){const y=typeof l=="function"?l():l;if(y)for(const[C,Q]of p){const ee=y[Q];ee&&ye(x,C,ie=>t.uniform1fv(ie,ee))}}}function Mr(x,B,H){for(const[z,G]of Object.entries(B||{})){const g=H&&H[z];g&&vn(x,g.uniform,G)}for(const[z,G]of Object.entries(H||{}))(!B||!(z in B))&&G.default!==void 0&&vn(x,G.uniform,G.default)}function ho(x){const B=Oe();Wr(!!(B&&B.has),!!x.get("g_PointerScale"))&&ye(x,"g_PointerScale",H=>t.uniform1f(H,0))}function _r(x,B,H,z){if(!x)return x;let G=!1;for(const S of Object.values(x))if(S!==null&&typeof S=="object"&&typeof S.script=="string"){G=!0;break}if(!G||!d)return x;const g={...x};for(const[S,L]of Object.entries(x)){if(L===null||typeof L!="object"||typeof L.script!="string")continue;const E=B+"|"+S;let N=v.get(E);if(N===void 0){_.total++;try{N=d(L.script,L.scriptproperties||L.scriptProperties||null,{userProperties:w||{},audioViews:M||void 0,layer:z||null,shared:m||{},inputView:A||void 0,setTimeout:h?h.setTimeout:void 0,clearTimeout:h?h.clearTimeout:void 0,setInterval:h?h.setInterval:void 0,clearInterval:h?h.clearInterval:void 0})}catch{N=null}if(N?_.ok++:_.failed++,v.set(E,N),N){const $=L.value!==void 0?L.value:L,P=qe($),C=typeof $=="number"?P[0]:{x:P[0],y:P[1],z:P[2]};N.init&&N.init(C)}if(N&&typeof N.applyUserProperties=="function")try{N.applyUserProperties(w||{})}catch{}if(N&&N.hasMediaHook&&b)try{b(N)}catch{}}if(!N||N.disabled||!N.hasUpdate)continue;if(N.engine){N.engine.runtime=H,N.engine.frametime=ht,N.engine.timeOfDay=xr();const $=Oe();$&&$.screenW&&$.screenH&&(N.engine.screenResolution={x:$.screenW,y:$.screenH})}const j=qe(L.value!==void 0?L.value:L),D=typeof(L.value!==void 0?L.value:L)=="number"?j[0]:{x:j[0],y:j[1],z:j[2]};let O;try{O=N.callUpdate(D)}catch{O=void 0}const Y=O??D;if(typeof Y=="number"&&Number.isFinite(Y))g[S]=Y;else if(Y&&typeof Y=="object"){const $=Number(Y.x),P=Number(Y.y),y=Number(Y.z);Number.isFinite($)&&Number.isFinite(P)&&(g[S]=Number.isFinite(y)?`${$} ${P} ${y}`:`${$} ${P} 0`)}}return g}function xn(x,B,H){if(!x)return x;let z=!1;for(const g of Object.values(x))if(g&&typeof g=="object"&&g.animation&&g.animation.options){z=!0;break}if(!z)return x;const G={...x};for(const[g,S]of Object.entries(x)){if(!S||typeof S!="object"||!S.animation||!S.animation.options)continue;const L=B+"|anim|"+g;let E=T.get(L);if(!E){const N=Ho(S.animation),j=S.value!==void 0?S.value:0;N.baseNumeric=Array.isArray(j)?j.slice():j,E={ctrl:N},T.set(L,E)}E.ctrl.playing&&E.ctrl.setFrame(H*E.ctrl.fps*E.ctrl.rate),G[g]=E.ctrl.applyTo(E.ctrl.baseNumeric)}return G}function mo(x,B,H,z){return x==null||x===""?null:x.startsWith("_rt_")?x.startsWith("_rt_imageLayerComposite")?Gt&&Lt.has(x)?Lt.get(x):B:H.has(x)?H.get(x):null:H.has(x)?H.get(x):z.get(x)||null}const tn=wa(),Vn=Ma(),At=new Map;function nn(x,B){const H=x+"x"+B;let z=At.get(H);return z===void 0&&(z=xa(x,B),At.set(H,z)),z}let Wt=null;function at(x,B){Wt!==x&&(t.bindBuffer(t.ARRAY_BUFFER,W),t.bufferData(t.ARRAY_BUFFER,B,t.DYNAMIC_DRAW),Wt=x)}const we={mvp:t.getUniformLocation(k,"u_MVP"),tex:t.getUniformLocation(k,"u_Tex"),color:t.getUniformLocation(k,"u_Color4"),frameOrigin:t.getUniformLocation(k,"u_FrameOrigin"),frameU:t.getUniformLocation(k,"u_FrameU"),frameV:t.getUniformLocation(k,"u_FrameV"),blendPrep:t.getUniformLocation(k,"u_BlendPrep")},ct={mvp:t.getUniformLocation(U,"u_MVP"),tex:t.getUniformLocation(U,"u_Tex"),blendPrep:t.getUniformLocation(U,"u_BlendPrep")},lt={mvp:t.getUniformLocation(V,"u_MVP"),tex:t.getUniformLocation(V,"u_Tex")},mt=pn(),rn=Vt();function Ke(x){x==="translucent"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):x==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):t.disable(t.BLEND)}let on=0;function Ar(x){const{mode:B,prep:H}=Vr(x);on=H,B==="additive"?(t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE,t.ONE,t.ONE)):B==="multiply"?(t.enable(t.BLEND),t.blendFuncSeparate(t.DST_COLOR,t.ZERO,t.ONE,t.ONE_MINUS_SRC_ALPHA)):B==="screen"?(t.enable(t.BLEND),t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_COLOR,t.ONE,t.ONE_MINUS_SRC_ALPHA)):Ke("translucent")}function sn(x,B){if(B&&B.perspective)return!1;const H=x.size[0]*x.scale[0],z=x.size[1]*x.scale[1];if(H===0||z===0)return!1;let G=Math.abs(H)/2,g=Math.abs(z)/2;const S=x.angles[2];if(S!==0){const O=Math.abs(Math.cos(S)),Y=Math.abs(Math.sin(S)),$=G*O+g*Y,P=G*Y+g*O;G=$,g=P}const L=x.origin[0],E=B.projH-x.origin[1];let N=64;x.parallaxDepth&&(N+=Math.abs(gn(x.parallaxDepth[0])*$e),N+=Math.abs(gn(x.parallaxDepth[1])*Ge));const j=Xo(x),I=N+j[0],D=N+j[1];return L+G+I<B.offX||L-G-I>B.offX+B.viewW||E+g+D<B.offY||E-g-D>B.offY+B.viewH}function Wn(x,B,H){if(!x.spriteSheet)return null;const z=B&&B.frames,G=Array.isArray(z)?z:z&&z.list;if(!G||G.length===0)return null;const g=z&&z.atlasWidth||B.width||0,S=z&&z.atlasHeight||B.height||0;if(g<=0||S<=0)return null;x.spriteFrameCount=G.length;let L=0;const E=x.textureAnimation;if(E&&E.frame!==null&&E.frame!==void 0)L=Math.floor(Number(E.frame))||0,L>=0||(L=0),L>=G.length&&(L=G.length-1);else if(G.length>1){const Y=E&&E.playing===!1;let $=0;for(const P of G)$+=P.duration>0?P.duration:1/30;if(!Y&&$>0){let P=H%$;P<0&&(P+=$);for(let y=0;y<G.length;y++){const C=G[y].duration>0?G[y].duration:.03333333333333333;if(P<C){L=y;break}P-=C,L=y}}}const N=G[L],j=N.uDir?N.uDir[0]:N.width,I=N.uDir?N.uDir[1]:0,D=N.vDir?N.vDir[0]:0,O=N.vDir?N.vDir[1]:N.height;return[N.x/g,N.y/S,j/g,I/S,D/g,O/S]}function Ht(x,B){const H=x.size[0]*x.scale[0],z=x.size[1]*x.scale[1];let G=pn();if(B&&B.perspective){const S=ia(x,B);G=mn(G,S[0],S[1],S[2]);const L=x.angles[0]||0,E=x.angles[1]||0;E&&(G=na(G,E)),L&&(G=ta(G,L)),G=Lo(G,-x.angles[2])}else{if(G=mn(G,x.origin[0],B.projH-x.origin[1],x.origin[2]),x.parallaxDepth&&($e!==0||Ge!==0)){const S=gn(x.parallaxDepth[0]),L=gn(x.parallaxDepth[1]);G=mn(G,S*$e,L*Ge,0)}G=Lo(G,-x.angles[2])}const g=jo[x.alignment]||[.5,.5];return(g[0]!==.5||g[1]!==.5)&&(G=mn(G,(.5-g[0])*H,(.5-g[1])*z,0)),{m:G,w:H,h:z}}function wn(x,B,H,z,G,g,S,L,E=!1,N=null,j=null){const I=Ht(z,G);let D=I.m;if(j){const $=(j[0]+j[2]/2)*z.scale[0],P=(j[1]+j[3]/2)*z.scale[1];D=mn(D,$,-P,0),D=En(D,j[2]*z.scale[0],j[3]*z.scale[1],1)}else D=En(D,I.w,I.h,1);const O=xt(g,D),Y=x===U?ct:we;t.useProgram(x),E?(on=0,t.enable(t.BLEND),z.containerAlphaMeaningful?t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA):t.blendFuncSeparate(t.ONE,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA)):Ar(z.colorBlendMode),Y.blendPrep!==null&&Y.blendPrep!==void 0&&t.uniform1i(Y.blendPrep,on),Fe?(t.bindFramebuffer(t.FRAMEBUFFER,Fe.fbo.fbo),t.viewport(0,0,Fe.w,Fe.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,S,L)),t.bindVertexArray(q),at("local",Vn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,B),t.uniform1i(Y.tex,0),t.uniformMatrix4fv(Y.mvp,!1,O),Y.color!==null&&Y.color!==void 0&&t.uniform4f(Y.color,H[0],H[1],H[2],H[3]),an(Y,N),t.drawArrays(t.TRIANGLES,0,6)}function an(x,B){!x||x.frameOrigin===null||x.frameOrigin===void 0||(B?(t.uniform2f(x.frameOrigin,B[0],B[1]),t.uniform2f(x.frameU,B[2],B[3]),t.uniform2f(x.frameV,B[4],B[5])):(t.uniform2f(x.frameOrigin,0,0),t.uniform2f(x.frameU,1,0),t.uniform2f(x.frameV,0,1)))}let Xt=null,Fe=null;const Lt=new Map,Rt=new Map;let Gt=!0;function qt(x,B){const H=Ht(x,B),z=B&&B.perspective?x.scale[1]:-x.scale[1],G=B&&B.perspective&&x.scale[2]||1;return En(H.m,x.scale[0],z,G)}function Mn(x,B,H,z,G,g,S){Fe?(t.bindFramebuffer(t.FRAMEBUFFER,Fe.fbo.fbo),t.viewport(0,0,Fe.w,Fe.h)):(t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,z,G));const L=xt(H,qt(x,B));Xt(x,L,{time:g,overrideTex:S||null}),Wt=null}let cn=null;function Yt(x,B){return cn===null&&(cn=t.createTexture(),t.bindTexture(t.TEXTURE_2D,cn),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE)),t.bindFramebuffer(t.FRAMEBUFFER,null),t.bindTexture(t.TEXTURE_2D,cn),t.copyTexImage2D(t.TEXTURE_2D,0,t.RGB8,0,0,x,B,0),cn}function Tr(x,B,H,z,G,g,S,L){const E=Yt(S,L),N=Ht(x,G);let j=N.m;j=En(j,N.w,N.h,1);const I=xt(g,j),D=[[-.5,.5],[.5,.5],[-.5,-.5],[.5,-.5]].map(([C,Q])=>{const ee=aa(I,C,Q,0);return[ee[0]*.5+.5,ee[1]*.5+.5]}),[O,Y,$,P]=D,y=new Float32Array([0,z,0,O[0],O[1],0,0,0,$[0],$[1],H,z,0,Y[0],Y[1],H,z,0,Y[0],Y[1],0,0,0,$[0],$[1],H,0,0,P[0],P[1]]);t.useProgram(V),Ke("normal"),t.disable(t.BLEND),t.bindFramebuffer(t.FRAMEBUFFER,B.fbo),t.viewport(0,0,H,z),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(q),t.bindBuffer(t.ARRAY_BUFFER,W),t.bufferData(t.ARRAY_BUFFER,y,t.DYNAMIC_DRAW),Wt=null,t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,E),t.uniform1i(lt.tex,0),t.uniformMatrix4fv(lt.mvp,!1,hn(0,H,0,z,-1e4,1e4)),t.drawArrays(t.TRIANGLES,0,6),t.enable(t.BLEND)}function Sr(x,B,H,z,G){if(!Gt||Fe)return;const g=Rt.get(x.id);if(!g||g.size===0)return;const S=Math.max(1,Math.round(Math.abs(x.size[0]*(x.scale[0]||1)))),L=Math.max(1,Math.round(Math.abs(x.size[1]*(x.scale[1]||1))));if(S<=1&&L<=1)return;const E=re(S,L,"lc:"+x.id);Tr(x,E,S,L,B,H,z,G);for(const N of g)Lt.set(N,E);Rt.delete(x.id),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,z,G)}async function Er(x,B,H,z,G,g,S,L){K++,t.viewport(0,0,H,z);const E=x.general||{};if(E.clearenabled!==!1){const y=Vo(E.clearcolor||"0 0 0");t.clearColor(y[0],y[1],y[2],1)}else t.clearColor(0,0,0,1);if(t.clear(t.COLOR_BUFFER_BIT),me>=0){const y=G-me;ht=y>0&&y<1?y:Math.min(.1,Math.max(.001,y||1/60))}me=G;const N=ua(x,H,z,g,S,L);let j=xt(N.projection,N.view);const I=E.cameraparallax,D=I===!0||I!==null&&typeof I=="object"&&I.value===!0;$e=0,Ge=0;const O=Oe();if(O&&(Me.x=O.u*2-1,Me.y=O.v*2-1),!N.perspective&&n.parallax!==!1&&D){const y=(je,ce)=>{const pe=je!==null&&typeof je=="object"?je.value:je;return typeof pe=="number"&&Number.isFinite(pe)?pe:ce},C=y(E.cameraparallaxamount,0),Q=y(E.cameraparallaxmouseinfluence,1),ee=y(E.cameraparallaxdelay,1),ie=G-_e;_e=G;const oe=ie>0?1-Math.exp(-ie/Math.max(.05,ee)):1;Me.sx+=(Me.x-Me.sx)*oe,Me.sy+=(Me.y-Me.sy)*oe;const fe=C*Q,be=60,rt=Me.sx*fe*N.viewW,gt=Me.sy*fe*N.viewH,bt=Math.max(Math.abs(rt),Math.abs(gt))/be,kt=bt>1?1/bt:1;$e=-(rt*kt),Ge=-(gt*kt)}if(!N.perspective&&n.shake!==!1){const y=po(E,G);if(y){const C=y.x*N.viewW*.02,Q=y.y*N.viewH*.02;(C!==0||Q!==0)&&(j=xt(j,mn(pn(),C,Q,0)))}}if(le){const y=typeof le=="function"?le():le;y&&typeof y.syncWorld=="function"&&y.syncWorld(N,0,0)}if(!R){R=!0;const y=(x.layers||[]).filter(ee=>ee.isContainer),C=y.filter(ee=>(ee.effects||[]).some(ie=>ie.visible)&&!ee.hasChildren),Q=C.filter(ee=>(ee.effects||[]).some(ie=>(ie.materialPasses||[]).length>0));o(`containers total=${y.length} canvasCandidates=${C.length} passesResolved=${Q.length} names=${C.slice(0,4).map(ee=>ee.name||"?").join("/")}`)}await ln(x,B,N,H,z,G);const Y=new Map;for(const y of x.layers)y.id!==void 0&&Y.set(y.id,y);const $=new Set;for(const y of x.layers)!y.visible||y.destroyed||!y.isContainer||!y.hasChildren||!(y.effects||[]).some(Q=>Q.visible)||(y.childIds||[]).length===0||nr(y,Y,$);if(c)try{c()}catch(y){o("particle advance error: "+(y&&y.message))}const P=N.perspective?x.layers.slice().sort((y,C)=>+!!C.isSkybox-+!!y.isSkybox):x.layers;for(const y of P)if(!y.destroyed){if(!y.visible){Rt.has(y.id)&&Sr(y,N,j,H,z);continue}if(!(y.isPostProcess&&!(y.effects||[]).some(C=>C.visible))&&!$.has(y.id)){if(y.isContainer){if(!(y.effects||[]).some(Q=>Q.visible)){Sr(y,N,j,H,z);continue}if(y.hasChildren){(y.childIds||[]).length>0&&await _n(y,x,B,N,j,H,z,G);continue}}if(y.particle){if(u)try{await u(y.id,N,j,H,z)}catch(C){o("particle render error: "+(C&&C.message))}continue}sn(y,N)||await Ft(y,B,N,j,H,z,G)}}if(vr(E)&&G<Ct){const y=Math.max(0,Math.min(1,G/Ct)),C=1-y*y*(3-2*y);if(C>.002){const Q=Vo(E.clearcolor||"0 0 0");t.useProgram(k),t.enable(t.BLEND),t.blendFuncSeparate(t.SRC_ALPHA,t.ONE_MINUS_SRC_ALPHA,t.ONE,t.ONE_MINUS_SRC_ALPHA),t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,H,z),t.bindVertexArray(q),at("pass",tn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,Ee),t.uniform1i(we.tex,0),t.uniform4f(we.color,Q[0],Q[1],Q[2],C),an(we,null),we.blendPrep!==null&&we.blendPrep!==void 0&&t.uniform1i(we.blendPrep,0),t.uniformMatrix4fv(we.mvp,!1,mt),t.drawArrays(t.TRIANGLES,0,6)}}t.bindVertexArray(null),te()}async function ln(x,B,H,z,G,g){Lt.clear(),Rt.clear();const S=new Map,L=new Set;let E=null;const N=j=>{if(typeof j!="string")return;const I=/^_rt_imageLayerComposite_(\d+)_[a-z]$/.exec(j);if(!I)return;const D=Number(I[1]);E!==null&&D===E&&L.add(D);let O=S.get(D);O||(O=new Set,S.set(D,O)),O.add(j)};for(const j of x.layers||[]){E=j.id;for(const I of j.effects||[])if(I.visible){for(const D of I.passes||[])for(const O of D.textures||[])N(O);for(const D of I.materialPasses||[]){for(const O of D.binds||[])N(O&&O.name);for(const O of D.textures||[])N(O)}}}if(S.size!==0){for(const[j,I]of S){const D=(x.layers||[]).find(be=>be.id===j);if(!D||D.particle||D.isPostProcess||L.has(j))continue;const O=typeof D.image=="string"?D.image:"";if(D.isContainer&&!D.hasChildren&&O.indexOf("models/util/composelayer")===0&&!(D.effects||[]).some(be=>be.visible)){Rt.set(j,I);continue}const $=Math.max(1,Math.round(Math.abs(D.size[0]*(D.scale[0]||1)))),P=Math.max(1,Math.round(Math.abs(D.size[1]*(D.scale[1]||1))));if($<=1&&P<=1)continue;const y=re($,P,"lc:"+j);t.bindFramebuffer(t.FRAMEBUFFER,y.fbo),t.viewport(0,0,$,P),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const C={view:H.view,projection:hn(0,$,0,P,-1e4,1e4),eye:H.eye,projW:$,projH:P,offX:0,offY:0,viewW:$,viewH:P},Q=Fe,ee=D.origin,ie=D.scale,oe=D.angles,fe=D.visible;Fe={fbo:y,w:$,h:P},D.origin=[$/2,C.projH-P/2,ee[2]],D.scale=[Math.sign(ie[0])||1,Math.sign(ie[1])||1,ie[2]],D.angles=[0,0,0],D.visible=!0;try{await Ft(D,B,C,C.projection,$,P,g);for(const be of I)Lt.set(be,y)}catch(be){o(`composite \u6E90\u5C42 ${j} \u6E32\u67D3\u5931\u8D25: ${be&&be.message}`)}finally{Fe=Q,D.origin=ee,D.scale=ie,D.angles=oe,D.visible=fe}}t.bindFramebuffer(t.FRAMEBUFFER,null),t.viewport(0,0,z,G)}}async function _n(x,B,H,z,G,g,S,L){const E=Math.max(1,Math.round(Math.abs(x.size[0]))),N=Math.max(1,Math.round(Math.abs(x.size[1])));if((x.childIds||[]).length===0)return;const I=new Map;for(const oe of B.layers)oe.id!==void 0&&I.set(oe.id,oe);const D=nr(x,I),O=B.layers.filter(oe=>D.has(oe.id)&&oe.visible);if(O.length===0)return;const Y=re(E,N,"group");t.bindFramebuffer(t.FRAMEBUFFER,Y.fbo),t.viewport(0,0,E,N),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT);const $={view:z.view,projection:hn(0,E,0,N,-1e4,1e4),eye:z.eye,projW:E,projH:N,offX:0,offY:0,viewW:E,viewH:N},P=$.projection,y=x.scale[0]||1,C=x.scale[1]||1,Q=x.angles[2]||0,ee=Math.cos(-Q),ie=Math.sin(-Q);Fe={fbo:Y,w:E,h:N};try{for(const oe of O){if(oe.isPostProcess||oe.particle||oe.isContainer&&(oe.childIds||[]).length>0)continue;const fe=oe.origin,be=oe.scale,rt=oe.angles,gt=fe[0]-x.origin[0],bt=fe[1]-x.origin[1],kt=(gt*ee-bt*ie)/y,je=(gt*ie+bt*ee)/C;oe.origin=[E/2+kt,N/2+je,fe[2]],oe.scale=[be[0]/y,be[1]/C,be[2]],oe.angles=[rt[0],rt[1],rt[2]-Q];try{await Ft(oe,H,$,P,E,N,L)}finally{oe.origin=fe,oe.scale=be,oe.angles=rt}}}finally{Fe=null}x.groupTex=Y.tex,x.groupW=E,x.groupH=N;try{await Ft(x,H,z,G,g,S,L)}finally{x.groupTex=null}}async function Ft(x,B,H,z,G,g,S){const L=!!(x.puppet&&Xt),E=!x.solid&&x.textureName?B.get(x.textureName):null;if(E&&E.video){const ce=E.video;if(ce.readyState>=2&&ce.currentTime!==E.lastUploaded){t.bindTexture(t.TEXTURE_2D,E.glTex);try{let pe=ce.videoWidth||E.width,ue=ce.videoHeight||E.height;const Ce=2048,ot=t.getParameter(t.MAX_TEXTURE_SIZE),et=ot>0&&ot<4096?Math.min(Ce,ot):Ce;let ut=1;Math.max(pe,ue)>et&&(ut=et/Math.max(pe,ue));const it=Math.max(1,Math.round(pe*ut)),Le=Math.max(1,Math.round(ue*ut));let An=ce;if(i&&it>0&&Le>0){(i.width!==it||i.height!==Le)&&(i.width=it,i.height=Le);const Nt=i.getContext("2d");Nt&&(Nt.clearRect(0,0,it,Le),Nt.drawImage(ce,0,0,it,Le),An=i)}if(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,t.RGBA,t.UNSIGNED_BYTE,An),t.getError()!==t.NO_ERROR&&i)try{const tt=i.getContext("2d").getImageData(0,0,i.width,i.height);for(t.texImage2D(t.TEXTURE_2D,0,t.RGBA,i.width,i.height,0,t.RGBA,t.UNSIGNED_BYTE,new Uint8Array(tt.data.buffer));t.getError()!==t.NO_ERROR;);}catch{}E.width=it,E.height=Le,E.lastUploaded=ce.currentTime,s||(s=!0,o("video tex ready "+it+"x"+Le+" (src "+pe+"x"+ue+")"))}catch(pe){s||(s=!0,o("video upload FAIL: "+(pe&&pe.message||pe))),console.warn("[we-scene] \u89C6\u9891\u5E27\u4E0A\u4F20\u5931\u8D25:",pe&&pe.message,"readyState=",ce.readyState,"cur=",ce.currentTime)}}}const N=x.groupTex?x.groupTex:E&&E.glTex?E.glTex:x.solid?Ee:Re,j=(!!x.passthrough||!!x.isPostProcess||Go(x))&&!x.groupTex&&!E&&!L;let I,D;if(x.groupTex?(I=x.groupW||x.size[0],D=x.groupH||x.size[1]):L||!E?(I=x.size[0],D=x.size[1]):(I=E.width,D=E.height),!L&&E&&x.spriteSheet){const ce=E.frames,pe=Array.isArray(ce)?ce:ce&&ce.list;pe&&pe.length&&(I=pe[0].width||I,D=pe[0].height||D)}const O=Math.max(1,Math.round(I)),Y=Math.max(1,Math.round(D)),$=[x.color[0]*x.brightness,x.color[1]*x.brightness,x.color[2]*x.brightness,x.alpha],P=(x.effects||[]).filter(ce=>ce.visible);let y=O,C=Y;if(a>0&&H.projW>0&&H.projH>0){const ce=Math.min(Math.abs(x.size[0]*x.scale[0]),H.viewW),pe=Math.min(Math.abs(x.size[1]*x.scale[1]),H.viewH),ue=ce*(G/H.projW),Ce=pe*(g/H.projH);if(ue>0&&Ce>0){const ot=Math.max(64,Math.round(ue*a)),et=Math.max(64,Math.round(Ce*a));ot<O&&(y=ot),et<Y&&(C=et)}}if(P.length===0){L?Mn(x,H,z,G,g,S):wn(k,N,$,x,H,z,G,g,!1,Wn(x,E,S));return}const Q=re(y,C,"ping"),ee=re(y,C,"pong"),ie=hn(0,y,0,C,-1e4,1e4);if(L)t.useProgram(k),Ke("normal"),t.bindFramebuffer(t.FRAMEBUFFER,Q.fbo),t.viewport(0,0,y,C),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(q),Wt=null,at("layer"+y+"x"+C,nn(y,C)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,N),t.uniform1i(we.tex,0),t.uniform4f(we.color,1,1,1,1),an(we,null),we.blendPrep!==null&&we.blendPrep!==void 0&&t.uniform1i(we.blendPrep,0),t.uniformMatrix4fv(we.mvp,!1,ie),t.drawArrays(t.TRIANGLES,0,6);else if(j)Tr(x,Q,y,C,H,z,G,g);else{t.useProgram(k),Ke("normal"),t.bindFramebuffer(t.FRAMEBUFFER,Q.fbo),t.viewport(0,0,y,C),t.clearColor(0,0,0,0),t.clear(t.COLOR_BUFFER_BIT),t.bindVertexArray(q),at("layer"+y+"x"+C,nn(y,C)),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,N),t.uniform1i(we.tex,0);const ce=P.some(pe=>pe&&pe.layerMaterial)?[1,1,1,$[3]]:$;t.uniform4f(we.color,ce[0],ce[1],ce[2],ce[3]),an(we,Wn(x,E,S)),we.blendPrep!==null&&we.blendPrep!==void 0&&t.uniform1i(we.blendPrep,0),t.uniformMatrix4fv(we.mvp,!1,ie),t.drawArrays(t.TRIANGLES,0,6)}let oe=Q,fe=ee;const be=new Map;let rt=!1,gt=Q;const bt=[],kt=new Set;for(const ce of P){for(const ue of ce.fbos||[])if(!be.has(ue.name)){const[Ce,ot]=qo(ue,y,C),et=ue.unique?x.id+":"+ue.name:ue.name;be.set(ue.name,re(Ce,ot,et))}const pe=ce.materialPasses||[];for(let ue=0;ue<pe.length;ue++)bt.push({eff:ce,mp:pe[ue],ov:ce.passes&&ce.passes[ue]})}const je=[];for(let ce=0;ce<bt.length;ce++){const{eff:pe,mp:ue,ov:Ce}=bt[ce];if(kt.has(pe))continue;const ot={...ue.combos||{},...Ce&&Ce.combos||{}},et=ue.textures||[],ut=Ce&&Ce.textures||[],it=[];for(let ve=0;ve<Math.max(et.length,ut.length);ve++)ut[ve]!==void 0&&ut[ve]!==null?it[ve]=ut[ve]:it[ve]=et[ve]!==void 0?et[ve]:null;if(ue.copyCommand){const ve=ue.source?be.get(ue.source):null,Ue=ue.target?be.get(ue.target):null;ve&&Ue&&(t.useProgram(U),Ke("normal"),t.bindFramebuffer(t.FRAMEBUFFER,Ue.fbo),t.viewport(0,0,Ue.width,Ue.height),t.bindVertexArray(q),at("pass",tn),t.activeTexture(t.TEXTURE0),t.bindTexture(t.TEXTURE_2D,ve.tex),t.uniform1i(ct.tex,0),ct.blendPrep!==null&&ct.blendPrep!==void 0&&t.uniform1i(ct.blendPrep,0),t.uniformMatrix4fv(ct.mvp,!1,mt),t.drawArrays(t.TRIANGLES,0,6),t.bindFramebuffer(t.FRAMEBUFFER,null));continue}let Le;try{Le=await Xe(ue.shader,ot,it)}catch(ve){const Ue=ve&&ve.message||String(ve);/已缓存/.test(Ue)||console.warn("[we-scene] \u8DF3\u8FC7\u6548\u679C\uFF08pass \u7F16\u8BD1\u5931\u8D25\uFF09:",ue.shader,Ue),kt.add(pe);continue}const An=Le.prog,Nt=Le.uni;Le.fragGlsl&&je.push(Le.fragGlsl);let tt,Hn;ue.target?(rt||(gt=oe,rt=!0),tt=be.get(ue.target)||oe,Hn=gt):(rt=!1,tt=fe,Hn=oe),t.useProgram(An),Ke(ue.blending||"normal"),t.bindFramebuffer(t.FRAMEBUFFER,tt.fbo),t.viewport(0,0,tt.width,tt.height),t.bindVertexArray(q);const ds=!Le.ndcDirect;ds?at("passPx"+tt.width+"x"+tt.height,nn(tt.width,tt.height)):at("pass",tn);const Au=ds?Co(hn(0,tt.width,0,tt.height,-1e4,1e4)):mt,go=ue.textures||[],Tu=Math.max(go.length,8),ps=new Map,Su=new Set;for(let ve=0;ve<Tu;ve++){let Ue=ve<go.length?go[ve]:null;Ce&&Ce.textures&&Ce.textures[ve]!==void 0&&Ce.textures[ve]!==null&&(Ue=Ce.textures[ve]);for(const Gn of ue.binds||[])Gn.index===ve&&(Ue=Gn.name);let Tt;if(ve===0&&(Ue==null||Ue===""))Tt=Hn;else{if((Ue==null||Ue==="")&&Le.samplerDefaults){const Gn=Le.samplerDefaults.get(ve);Gn&&(Ue=Gn)}Tt=mo(Ue,Hn,be,B)}Ue==="previous"&&(Tt=Hn),Tt===null&&(Tt={glTex:Ee,width:1,height:1,tex:Ee});const Xn=Tt.fbo?Tt:{tex:Tt.glTex||Ee,width:Tt.width||1,height:Tt.height||1};t.activeTexture(t.TEXTURE0+ve),t.bindTexture(t.TEXTURE_2D,Xn.tex),Su.add(ve),ps.set(ve,[Xn.width,Xn.height,Xn.width,Xn.height])}wr(Nt,x,S,H.projW,H.projH,Au,ie,mt,ps,ie,H),Mr(Nt,xn(_r({...ue.constants||{},...Ce&&Ce.constantshadervalues||{}},(x.id||x.name||"?")+"|"+(ue.shader||"?")+"|"+ce,S,x),(x.id||x.name||"?")+"|"+(ue.shader||"?")+"|"+ce,S),Le.matMeta),ho(Nt),t.drawArrays(t.TRIANGLES,0,6),ue.target||(fe=oe,oe=tt)}if(x.isContainer&&!x.groupTex&&!j&&x.containerAlphaMeaningful===void 0){let ce=!1;for(const pe of je){if(typeof pe!="string")continue;const ue=pe.match(/\bfloat\s+alpha\s*=\s*([^;]+);/);if(ue&&!/^\s*scene\s*\.\s*a\s*$/.test(ue[1])){ce=!0;break}}x.containerAlphaMeaningful=ce,o(`container "${x.name||"?"}" alpha ${ce?"\u643A\u5E26\u5F62\u72B6 \u2192 SRC_ALPHA":"\u65E0\u4FE1\u606F \u2192 \u52A0\u6CD5"}`)}if(L){Mn(x,H,z,G,g,S,oe.tex);return}wn(U,oe.tex,[1,1,1,1],x,H,z,G,g,!!x.isContainer&&!x.groupTex&&!j,null,null)}return{gl:t,render:Er,getFBO:re,getEffectProgram:Xe,progCache:X,shaderResolver:r,whiteTex:Ee,resetShaderCaches:function(){X.clear(),J.clear(),de&&de.clear()},setFboCapFactor:function(x){a=x},setParticleRenderer:function(x,B){c=typeof x=="function"?x:null,u=typeof B=="function"?B:null},setConstantScriptRuntime:F,applyConstUserProperties:function(x){if(x){for(const B of v.values())if(B&&typeof B.applyUserProperties=="function")try{B.applyUserProperties(x)}catch{}}},constantScriptStats:function(){return{..._,cached:v.size}},setCompositeEnabled:function(x){Gt=!!x},compositeStats:function(){const x=[],B=new Uint8Array(4);for(const[H,z]of Lt){let G=null;try{t.bindFramebuffer(t.FRAMEBUFFER,z.fbo),t.readPixels(z.w>>1,z.h>>1,1,1,t.RGBA,t.UNSIGNED_BYTE,B),G=[B[0],B[1],B[2],B[3]]}catch{}x.push({name:H,w:z.w,h:z.h,center:G})}return t.bindFramebuffer(t.FRAMEBUFFER,null),x},setPuppetRenderer:function(x){Xt=x},setAudioProvider:f,setPointerProvider:Pe,getParallaxOffset:function(){return{x:$e,y:Ge}},dispose:function(){try{const x=t.getExtension("WEBGL_lose_context");x&&x.loseContext()}catch{}}}}const ka=Object.freeze(Object.defineProperty({__proto__:null,ALIGN:jo,XRAY_IDLE_SCREEN_UV:Ln,applyColorBlendCPU:Ca,collectGroupDescendantIds:nr,colorBlendPlan:Vr,createRenderer:Fa,effectFboSize:qo,layerWantsPreserveBackdrop:Go,makeTexture:jr,makeTextureMip:Aa,puppetAnimMargin:Xo,rewriteXrayFragScale:Yo,xrayShouldParkPointer:Wr,xrayUvScale:La},Symbol.toStringTag,{value:"Module"}));function Na(e=256,n=8){const t=e/n,r=Zo(1337),o=Zo(4242),i=new Float32Array(t*t),s=new Float32Array(t*t);for(let u=0;u<t*t;u++)i[u]=r(),s[u]=o();const a=new Uint8Array(e*e*4),c=n;for(let u=0;u<e;u++){const l=Math.floor(u/c),p=u%c/c,f=p*p*(3-2*p);for(let d=0;d<e;d++){const w=Math.floor(d/c),M=d%c/c,m=M*M*(3-2*M),A=w%t,h=(w+1)%t,b=l%t,v=(l+1)%t,T=i[b*t+A],_=i[b*t+h],F=i[v*t+A],R=i[v*t+h],k=s[b*t+A],U=s[b*t+h],V=s[v*t+A],q=s[v*t+h],W=T+(_-T)*m+(F-T)*f+(T-_-F+R)*m*f,Z=k+(U-k)*m+(V-k)*f+(k-U-V+q)*m*f,K=(u*e+d)*4;a[K]=Math.round(W*255),a[K+1]=Math.round(Z*255),a[K+2]=0,a[K+3]=255}}return a}function Zo(e){let n=e>>>0;return()=>{n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const Ua=Object.freeze(Object.defineProperty({__proto__:null,generateNoiseTexture:Na},Symbol.toStringTag,{value:"Module"})),dt=Math.PI*2;function ke(e,n){return e==null?Math.random():n==null?e:e+Math.random()*(n-e)}function Ko(e,n,t){if(e==null)return Math.random();if(n==null)return e;const r=t&&t!==1?Math.pow(Math.random(),t):Math.random();return e+r*(n-e)}function ge(e,n){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e==null)return n?n.slice():[0,0,0];if(typeof e=="object")return ge(e.value,n);if(typeof e=="number")return[e,e,e];const t=String(e).trim().split(/\s+/).map(Number);return[t[0]||0,t[1]||0,t[2]||0]}function Qo(e){return e==null?null:typeof e=="number"?[e,e,e]:ge(e)}function ne(e,n){if(e==null)return n;if(typeof e=="object")return ne(e.value,n);const t=Number(e);return Number.isFinite(t)?t:n}function Hr(e,n){const t=e[0],r=e[1]>t?e[1]:t+1e-6,o=Math.min(1,Math.max(0,(n-t)/(r-t)));return o*o*(3-2*o)}function It(e,n,t){const r=Math.sin(e*127.1+n*311.7+t*74.7)*43758.5453;return r-Math.floor(r)}function Ba(e,n,t){const r=Math.floor(e),o=Math.floor(n),i=Math.floor(t),s=e-r,a=n-o,c=t-i,u=s*s*(3-2*s),l=a*a*(3-2*a),p=c*c*(3-2*c),f=(A,h,b)=>A+(h-A)*b,d=f(It(r,o,i),It(r+1,o,i),u),w=f(It(r,o+1,i),It(r+1,o+1,i),u),M=f(It(r,o,i+1),It(r+1,o,i+1),u),m=f(It(r,o+1,i+1),It(r+1,o+1,i+1),u);return f(f(d,w,l),f(M,m,l),p)}function Xr(e,n,t,r){let o=0,i=.5,s=1,a=0;for(let c=0;c<r;c++)o+=i*Ba(e*s,n*s,t*s),a+=i,i*=.5,s*=2;return o/(a||1)}function Gr(e,n,t,r){return[Xr(e,n,t,r)*2-1,Xr(e+31.7,n+11.3,t+57.1,r)*2-1,Xr(e+73.9,n+92.1,t+13.7,r)*2-1]}function Da(e){const n=`#version 300 es
|
|
63
67
|
// \u5355\u4F4D quad\uFF08TRIANGLE_STRIP 4 \u9876\u70B9\uFF09\uFF0C\u6309\u5B9E\u4F8B\u7684 size/rot \u5C55\u5F00\u4E3A\u671D\u5C4F\u5E55\u7684\u7CBE\u7075
|
|
64
68
|
layout(location=0) in vec2 a_corner; // -0.5..0.5
|
|
65
69
|
layout(location=1) in vec3 a_pos; // \u5B9E\u4F8B\u4E2D\u5FC3\uFF08\u6295\u5F71\u7A7A\u95F4\u4E16\u754C\u5750\u6807\uFF09
|
|
66
70
|
layout(location=2) in vec2 a_sizeRot; // x=size(\u50CF\u7D20) y=rot(\u5F27\u5EA6)
|
|
67
71
|
layout(location=3) in vec4 a_color; // rgb + alpha
|
|
68
72
|
layout(location=4) in vec3 a_stretchFrame; // xy=\u975E\u7B49\u6BD4\u62C9\u4F38 z=\u5E27\u5E8F\u53F7
|
|
73
|
+
layout(location=5) in vec2 a_vrange; // \u6BB5\u4E24\u7AEF\u6CBF\u8D34\u56FE v \u7684\u53D6\u503C\uFF08rope \u8FDE\u7EBF\u7528\uFF1B\u666E\u901A\u7CBE\u7075 0..1\uFF09
|
|
69
74
|
uniform mat4 u_mvp;
|
|
70
75
|
// \u5E8F\u5217\u5E27 uv \u53D8\u6362\u8868\uFF08TEXS \u5E27\u77E9\u5F62\u5F52\u4E00\u5316\u540E\u7684 offset/scale\uFF09\uFF0C\u6700\u591A 128 \u5E27
|
|
71
76
|
// \uFF08matrix spritesheet 72 \u6709 71 \u5E27\uFF0C\u65E7\u4E0A\u9650 64 \u4F1A\u4E22\u672B\u5C3E\u5B57\u7B26\uFF09
|
|
@@ -83,7 +88,8 @@ void main(){
|
|
|
83
88
|
gl_Position = u_mvp * vec4(a_pos.xy + rotated, a_pos.z, 1.0);
|
|
84
89
|
// quad \u89D2 \u2192 \u8D34\u56FE uv\u3002\u4E16\u754C y \u5DF2\u7FFB\u8F6C\u5230\u6295\u5F71\u7A7A\u95F4\uFF08y \u5411\u4E0B\uFF09\uFF0C\u6545 quad \u7684 +y \u89D2
|
|
85
90
|
// \u5BF9\u5E94\u5C4F\u5E55\u4E0A\u65B9\uFF0C\u5E94\u91C7\u6837\u7EB9\u7406\u9876\u884C v=1\uFF08\u4E0E renderer.js \u7684 layerQuadVerts \u540C\u7EA6\u5B9A\uFF09\u3002
|
|
86
|
-
|
|
91
|
+
// a_vrange \u8BA9 rope \u6BB5\u4E24\u7AEF\u5404\u53D6\u81EA\u5DF1\u7684 v\uFF08\u6CBF\u7EF3\u8FDE\u7EED\u6E10\u53D8\uFF09\uFF1B\u666E\u901A\u7CBE\u7075\u662F (0,1) \u6052\u7B49\u3002
|
|
92
|
+
vec2 uv = vec2(a_corner.x + 0.5, mix(a_vrange.x, a_vrange.y, a_corner.y + 0.5));
|
|
87
93
|
if (u_frameCount > 0) {
|
|
88
94
|
// \u5E27\u77E9\u5F62\u4EE5\u5DE6\u4E0A\u4E3A\u539F\u70B9\uFF08TEXS \u662F top-down \u50CF\u7D20\u5750\u6807\uFF09\uFF0C\u6545\u5148\u628A v \u7FFB\u6210 top-down
|
|
89
95
|
int fi = int(a_stretchFrame.z);
|
|
@@ -132,7 +138,7 @@ void main(){
|
|
|
132
138
|
if (col.a < 0.004) discard;
|
|
133
139
|
}
|
|
134
140
|
fragColor = col;
|
|
135
|
-
}`,r=(u,l)=>{const d=e.createShader(u);if(e.shaderSource(d,l),e.compileShader(d),!e.getShaderParameter(d,e.COMPILE_STATUS))throw new Error("\u7C92\u5B50 shader: "+e.getShaderInfoLog(d));return d},o=e.createProgram();if(e.attachShader(o,r(e.VERTEX_SHADER,n)),e.attachShader(o,r(e.FRAGMENT_SHADER,t)),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new Error("\u7C92\u5B50 shader \u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(o));const i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-.5,-.5,.5,-.5,-.5,.5,.5,.5]),e.STATIC_DRAW);const s=e.createBuffer(),c=e.createVertexArray();e.bindVertexArray(c),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,8,0),e.vertexAttribDivisor(0,0),e.bindBuffer(e.ARRAY_BUFFER,s);const a=48;return e.enableVertexAttribArray(1),e.vertexAttribPointer(1,3,e.FLOAT,!1,a,0),e.vertexAttribDivisor(1,1),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,!1,a,12),e.vertexAttribDivisor(2,1),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,a,20),e.vertexAttribDivisor(3,1),e.enableVertexAttribArray(4),e.vertexAttribPointer(4,3,e.FLOAT,!1,a,36),e.vertexAttribDivisor(4,1),e.bindVertexArray(null),{prog:{prog:o,uniTex:e.getUniformLocation(o,"u_tex"),uniNormal:e.getUniformLocation(o,"u_normal"),uniScene:e.getUniformLocation(o,"u_scene"),uniRefract:e.getUniformLocation(o,"u_refract"),uniSampleScene:e.getUniformLocation(o,"u_sampleScene"),uniResolution:e.getUniformLocation(o,"u_resolution"),uniRefractScale:e.getUniformLocation(o,"u_refractScale"),uniMvp:e.getUniformLocation(o,"u_mvp"),uniFrameCount:e.getUniformLocation(o,"u_frameCount"),uniFrames:e.getUniformLocation(o,"u_frames")},quadBuf:i,vbuf:s,vao:c}}function Do(e){const n=e&&e.passes&&e.passes[0]&&e.passes[0].combos;return!!(n&&Number(n.REFRACT)===1)}function ha(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/64|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<250||e[i+1]<250||e[i+2]<250||e[i+3]<250)return!1;r++}return r>0}function zo(e,n,t,r){let o=Math.abs(Number(e)||0)*(Number(n)||0);const i=Number(t)||0,s=Number(r)||0;return i>0&&(o=Math.max(i,o)),s>0&&(o=Math.min(s,o)),o}function $o(e,n){return e||n?Math.atan2(n,e)-Math.PI/2:0}function jo(e,n){return e&&e.kind==="ropetrail"?Math.max(1,n||1):1}class ma{constructor(){this.alive=!1,this.x=this.y=this.z=0,this.vx=this.vy=this.vz=0,this.bx=this.by=this.bz=0,this.age=0,this.life=1,this.size=1,this.baseSize=1,this.rot=0,this.rotVel=0,this.r=this.g=this.b=1,this.baseR=this.baseG=this.baseB=1,this.alpha=1,this.baseAlpha=1,this.seed=0,this.frame=0,this.oscPhase=0,this.oscFreq=0,this.oscAmp=0,this.oscAPhase=0,this.oscAFreq=0,this.oscSPhase=0,this.oscSFreq=0,this.turbSpeed=0,this.turbPhase=0,this.trail=null}}class pa{constructor(n,t,r,o){this.gl=n,this.model=t||{},this.override=r||{},this.layer=o||null;const i=o&&o.origin?o.origin:[0,0,0],s=o&&o.scale?o.scale:[1,1,1],c=o&&o.angles?o.angles:[0,0,0];this.originX=i[0]||0,this.originY=i[1]||0,this.originZ=i[2]||0,this.scaleX=s[0]===0?1:s[0],this.scaleY=s[1]===0?1:s[1],this.angleZ=(c[2]||0)*Math.PI/180;const a=Math.abs(this.scaleX),u=Math.abs(this.scaleY);this.sysScale=Math.min(a,u)||1,this.spriteStretchX=a/this.sysScale,this.spriteStretchY=u/this.sysScale,this.maxCount=Math.max(1,Math.min(2e4,H(this.model.maxcount,100))),this.simTime=0,this.paused=!1,this.texture=null,this.normalTex=null,this.material=null,this.blend="translucent",this.refract=!1,this.refractAmount=.04,this.opacityMul=1,this.lifetimeMul=1,this.visible=!0,this._ready=!1,this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null,this.sequenceMul=Math.max(1,Math.round(H(this.model.sequencemultiplier,1))),this.animationMode=this.model.animationmode||null,this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul,this.texAspectX=1,this.texAspectY=1,this.controlPoints=(this.model.controlpoint||[]).filter(Boolean).map(l=>({id:H(l.id,0),lockToPointer:!!l.locktopointer||(H(l.flags,0)&1)!==0,offset:be(l.offset),x:0,y:0,z:0})),this.pointer=null,this._followParent=null,this._followMode=null,this._followOffset=[0,0,0],this._ov={},this._applyOverride(),this.startTime=Math.max(0,Math.min(30,H(this.model.starttime,0))),this._warmed=!1,this._compile()}reapplyOverride(){this._applyOverride()}_applyOverride(){this._ov={},this.opacityMul=1,this.lifetimeMul=1,this.maxCount=Math.max(1,Math.min(2e4,H(this.model.maxcount,100)));const n=this.override||{};for(const t of Object.keys(n)){if(t==="id")continue;const r=n[t],o=r&&typeof r=="object"&&"value"in r?r.value:r;if(t==="count"){const i=H(this.model.maxcount,100),s=Number(o),c=Number.isFinite(s)?s:1;this.maxCount=Math.max(1,Math.min(2e4,Math.round(i*c))),this._ov.countMul=c}else if(t==="alpha")this.opacityMul=Number(o),Number.isFinite(this.opacityMul)||(this.opacityMul=1);else if(t==="color"||t==="colorn"){const i=be(o);this._ov.color=t==="colorn"?i:[i[0]/255,i[1]/255,i[2]/255]}else t==="size"?this._ov.size=Number(o)||1:t==="rate"?(this._ov.rateMul=Number(o),Number.isFinite(this._ov.rateMul)||(this._ov.rateMul=1)):t==="speed"?this._ov.speed=Number(o)||1:t==="lifetime"?this.lifetimeMul=Number(o)||1:t==="brightness"?this._ov.brightness=Number(o)||1:this._ov[t]=o}this.pool=[];for(let t=0;t<this.maxCount;t++)this.pool.push(new ma)}_compile(){const n=this.model;this.emitters=(n.emitter||[]).map(a=>({kind:a.name==="boxrandom"?"box":"sphere",origin:be(a.origin),directions:be(a.directions,[1,1,1]),distanceMin:Oo(a.distancemin),distanceMax:Oo(a.distancemax),sign:a.sign?be(a.sign):null,rate:H(a.rate,0),audioDriven:a.audioprocessingmode!==void 0,audioBounds:be(a.audioprocessingbounds,[0,1]),fill:a.rate===void 0&&a.instantaneous===void 0&&a.audioprocessingmode===void 0,instantaneous:H(a.instantaneous,0),speedMin:H(a.speedmin,0),speedMax:H(a.speedmax,0),controlPoint:a.controlpoint!==void 0&&a.controlpoint!==null?H(a.controlpoint,0):0,_burst:!1}));const t=n.initializer||[];this.init={life:null,size:null,color:null,alpha:null,velocity:null,rotation:null,angularVelocity:null,turbulentVelocity:null,mapAround:null};for(const a of t)switch(a.name){case"lifetimerandom":this.init.life={min:H(a.min,1),max:H(a.max,1),exp:H(a.exponent,1)};break;case"sizerandom":this.init.size={min:H(a.min,1),max:H(a.max,1),exp:H(a.exponent,1)};break;case"colorrandom":this.init.color={min:be(a.min,[255,255,255]),max:be(a.max,[255,255,255])};break;case"alpharandom":this.init.alpha={min:H(a.min,1),max:H(a.max,1)};break;case"velocityrandom":this.init.velocity={min:be(a.min),max:be(a.max)};break;case"rotationrandom":this.init.rotation={min:be(a.min),max:be(a.max,[0,0,0]),exp:H(a.exponent,1)};break;case"angularvelocityrandom":this.init.angularVelocity={min:be(a.min),max:be(a.max),exp:H(a.exponent,1)};break;case"mapsequencearoundcontrolpoint":this.init.mapAround={count:Math.max(1,H(a.count,1)),bounds:be(a.bounds,[0,1]),speedMin:be(a.speedmin),speedMax:be(a.speedmax,[0,0,0]),cp:H(a.controlpoint,0)},this._mapAroundSeq=0;break;case"turbulentvelocityrandom":this.init.turbulentVelocity={scale:H(a.scale,.1),offset:H(a.offset,0),speedMin:H(a.speedmin,0),speedMax:H(a.speedmax,0),phaseMax:H(a.phasemax,0),timeScale:H(a.timescale,0),audioMode:H(a.audioprocessingmode,0),audioBounds:be(a.audioprocessingbounds,[0,1])};break}const r=n.operator||[];this.ops={movement:null,angularMovement:null,alphaFade:null,alphaChange:null,sizeChange:null,colorChange:null,turbulence:[],oscAlpha:null,oscSize:null,oscPos:null,attract:[],vortex:[],remap:[]};for(const a of r)switch(a.name){case"movement":this.ops.movement={gravity:be(a.gravity),drag:H(a.drag,0)};break;case"angularmovement":this.ops.angularMovement={force:be(a.force),drag:H(a.drag,0)};break;case"alphafade":this.ops.alphaFade={fadeIn:H(a.fadeintime,.1),fadeOut:H(a.fadeouttime,.9)};break;case"alphachange":this.ops.alphaChange={startTime:H(a.starttime,0),endTime:H(a.endtime,1),startValue:H(a.startvalue,1),endValue:H(a.endvalue,0)};break;case"sizechange":this.ops.sizeChange={startTime:H(a.starttime,0),endTime:H(a.endtime,1),startValue:H(a.startvalue,1),endValue:H(a.endvalue,1)};break;case"colorchange":this.ops.colorChange={startTime:H(a.starttime,0),endTime:H(a.endtime,1),startValue:a.startvalue!==void 0?be(a.startvalue):null,endValue:be(a.endvalue,[1,1,1])};break;case"turbulence":this.ops.turbulence.push({scale:H(a.scale,.01),speedMin:H(a.speedmin,0),speedMax:H(a.speedmax,0),timeScale:H(a.timescale,1),phaseMin:H(a.phasemin,0),phaseMax:H(a.phasemax,0),mask:a.mask!==void 0?be(a.mask,[1,1,1]):[1,1,1]});break;case"oscillatealpha":this.ops.oscAlpha={freqMin:H(a.frequencymin,H(a.frequencymax,1)),freqMax:H(a.frequencymax,1),scaleMin:H(a.scalemin,0),scaleMax:H(a.scalemax,1),phaseMax:H(a.phasemax,at)};break;case"oscillatesize":this.ops.oscSize={freqMin:H(a.frequencymin,H(a.frequencymax,1)),freqMax:H(a.frequencymax,H(a.frequencymin,1)),scaleMin:H(a.scalemin,1),scaleMax:H(a.scalemax,1),phaseMax:H(a.phasemax,at)};break;case"oscillateposition":this.ops.oscPos={freqMin:H(a.frequencymin,H(a.frequencymax,.5)),freqMax:H(a.frequencymax,.5),scaleMin:H(a.scalemin,0),scaleMax:H(a.scalemax,1),phaseMin:H(a.phasemin,0),phaseMax:H(a.phasemax,at),mask:a.mask!==void 0?be(a.mask,[1,1,0]):[1,1,0]};break;case"controlpointattract":this.ops.attract.push({cp:H(a.controlpoint,0),origin:be(a.origin),scale:H(a.scale,0),threshold:H(a.threshold,0)});break;case"vortex":this.ops.vortex.push({axis:be(a.axis,[0,0,1]),offset:be(a.offset),distanceInner:H(a.distanceinner,0),distanceOuter:H(a.distanceouter,0),speedInner:H(a.speedinner,0),speedOuter:H(a.speedouter,0),cp:a.controlpoint!==void 0&&a.controlpoint!==null?H(a.controlpoint,0):0,audioMode:H(a.audioprocessingmode,0),audioBounds:be(a.audioprocessingbounds,[0,1])});break;case"remapvalue":this.ops.remap.push({output:a.output||"velocity",rangeMin:be(a.outputrangemin),rangeMax:be(a.outputrangemax),fn:a.transformfunction||"simplexnoise",inputScale:H(a.transforminputscale,1)});break}const o=this.model.renderer,i=o==null,s=Array.isArray(o)?o:o?[o]:[];this.renderers=s.map(a=>{const u=a&&a.name||"sprite";return{kind:u,length:H(a&&a.length,u==="spritetrail"?.1:0),maxLength:H(a&&a.maxlength,0),minLength:H(a&&a.minlength,0),subdivision:H(a&&a.subdivision,1),orientation:a&&a.orientation||null}}),i&&!this.renderers.length&&(this.renderers=[{kind:"sprite",length:0,maxLength:0,minLength:0,subdivision:1,orientation:null}]);const c=this.renderers.find(a=>a.kind==="spritetrail"||a.kind==="ropetrail");if(this.trailCfg=c||null,this.trailSegments=1,c&&c.kind==="ropetrail"){const a=Math.max(2,Math.min(16,Math.round(c.maxLength||c.subdivision||6)));this.trailSegments=a;for(const u of this.pool)u.trail=new Float32Array(a*3)}}setModel(n){this.model=n,this._compile()}setMaterial(n){this.material=n;const t=n&&n.passes&&n.passes[0];this.blend=t&&t.blending||"translucent",this.refract=Do(n);const r=t&&t.constantshadervalues,o=r&&r.ui_editor_properties_refract_amount,i=Number(o);this.refractAmount=Number.isFinite(i)?Math.min(.35,Math.max(0,i)):.04}setNormalTexture(n){this.normalTex=n||null}setTexture(n){this.texture=n,this._ready=!!n;const t=n&&n.frames,r=Array.isArray(t)?t:t&&t.list&&t.list.length?t.list:null,o=n&&n.width||r&&(t&&t.atlasWidth||r.atlasWidth)||0,i=n&&n.height||r&&(t&&t.atlasHeight||r.atlasHeight)||0;r&&o>0&&i>0?(this.texFrames=r.map(u=>({ou:u.x/o,ov:u.y/i,su:u.width/o,sv:u.height/i})),this.frameCount=this.texFrames.length):(this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul);let s=1,c=1;this.texFrames&&r?(s=r[0].width||1,c=r[0].height||1):n&&n.width>0&&n.height>0&&(s=n.width,c=n.height);const a=Math.max(s,c)||1;this.texAspectX=s/a,this.texAspectY=c/a,this._frameData=void 0}setVisible(n){this.visible=n}setPointer(n,t){const r=n-this.originX,o=t-this.originY,i=Math.cos(-this.angleZ),s=Math.sin(-this.angleZ);this.pointer={x:(r*i-o*s)/(this.scaleX||1),y:(r*s+o*i)/(this.scaleY||1)}}attachFollow(n,t,r){this._followParent=n||null,this._followMode=t==="particle"||t==="origin"?t:null;const o=r||[0,0,0];this._followOffset=[o[0]||0,o[1]||0,o[2]||0],this._syncFollow()}leaderParticle(){const n=this.pool;for(let t=0;t<n.length;t++)if(n[t].alive)return n[t];return null}localToWorld(n,t){const r=n*this.scaleX,o=t*this.scaleY,i=Math.cos(this.angleZ),s=Math.sin(this.angleZ);return[this.originX+r*i-o*s,this.originY+r*s+o*i]}_syncFollow(){const n=this._followParent,t=this._followMode;if(!n||!t)return;const r=this._followOffset;if(t==="particle"){const o=n.leaderParticle();if(!o)return;const i=n.localToWorld(o.x+r[0],o.y+r[1]);this.originX=i[0],this.originY=i[1]}else{const o=n.localToWorld(r[0],r[1]);this.originX=o[0],this.originY=o[1]}}spawn(n){const t=this.pool,r=t.length;let o=null,i=this._cursor||0;for(let d=0;d<r;d++){const h=t[(i+d)%r];if(!h.alive){o=h,this._cursor=(i+d+1)%r;break}}if(!o)return;o.alive=!0,o.age=0,o.seed=Math.random(),o.rot=0,o.rotVel=0,o.vx=o.vy=o.vz=0,o.frame=0;const s=n.origin;if(n.kind==="box"){const d=n.distanceMax||[0,0,0],h=n.distanceMin;o.x=s[0]+Le(-d[0],d[0])+(h?h[0]:0),o.y=s[1]+Le(-d[1],d[1])+(h?h[1]:0),o.z=s[2]+Le(-d[2],d[2])+(h?h[2]:0)}else{const d=n.directions,h=n.distanceMin?n.distanceMin[0]:0,p=n.distanceMax?n.distanceMax[0]:0,w=Math.random()*2-1,m=Math.random()*at,g=Math.sqrt(Math.max(0,1-w*w));let v=g*Math.cos(m),b=g*Math.sin(m),y=w;n.sign&&(n.sign[0]&&(v=Math.abs(v)*Math.sign(n.sign[0])),n.sign[1]&&(b=Math.abs(b)*Math.sign(n.sign[1])),n.sign[2]&&(y=Math.abs(y)*Math.sign(n.sign[2])));const S=Le(h,p);if(o.x=s[0]+v*S*d[0],o.y=s[1]+b*S*d[1],o.z=s[2]+y*S*d[2],n.speedMax||n.speedMin){const _=Le(n.speedMin,n.speedMax);o.vx+=v*_,o.vy+=b*_,o.vz+=y*_}}{const d=this._cpPos(n.controlPoint);if(d)o.x+=d[0],o.y+=d[1],o.z+=d[2];else{const h=this.controlPoints.find(p=>p.id===n.controlPoint);if(h&&h.lockToPointer){o.alive=!1;return}}}if(this.init.mapAround){const d=this.init.mapAround,h=this._cpPos(d.cp);if(h){const p=d.count,w=this._mapAroundSeq++,m=p>0?w%p/p:0,v=(d.bounds[0]+(d.bounds[1]-d.bounds[0])*m)*at,b=n.distanceMin?n.distanceMin[0]:0,y=n.distanceMax?n.distanceMax[0]:0,S=y>0?y:b;o.x=h[0]+Math.cos(v)*S,o.y=h[1]+Math.sin(v)*S,o.z=h[2];const _=Math.random();o.vx+=d.speedMin[0]+(d.speedMax[0]-d.speedMin[0])*_,o.vy+=d.speedMin[1]+(d.speedMax[1]-d.speedMin[1])*_,o.vz+=d.speedMin[2]+(d.speedMax[2]-d.speedMin[2])*_}}const c=this.init,a=this._ov.speed||1,u=this._ov.size||1;if(o.life=c.life?Math.max(.001,Io(c.life.min,c.life.max,c.life.exp)*this.lifetimeMul):1,o.baseSize=c.size?Io(c.size.min,c.size.max,c.size.exp)*u:u,o.size=o.baseSize,c.color){const d=c.color.min,h=c.color.max,p=Math.random();o.baseR=(d[0]+(h[0]-d[0])*p)/255,o.baseG=(d[1]+(h[1]-d[1])*p)/255,o.baseB=(d[2]+(h[2]-d[2])*p)/255}else o.baseR=o.baseG=o.baseB=1;if(this._ov.color&&(o.baseR=this._ov.color[0],o.baseG=this._ov.color[1],o.baseB=this._ov.color[2]),o.r=o.baseR,o.g=o.baseG,o.b=o.baseB,o.baseAlpha=(c.alpha?Le(c.alpha.min,c.alpha.max):1)*this.opacityMul,o.alpha=o.baseAlpha,c.velocity&&(o.vx+=Le(c.velocity.min[0],c.velocity.max[0])*a,o.vy+=Le(c.velocity.min[1],c.velocity.max[1])*a,o.vz+=Le(c.velocity.min[2],c.velocity.max[2])*a),c.turbulentVelocity){const d=c.turbulentVelocity,h=d.audioMode?Ir(d.audioBounds,this._audioLevel||0):1,p=Le(d.speedMin,d.speedMax)*a*h,w=this.simTime*(d.timeScale||0),m=Dr(o.x*d.scale+d.offset,o.y*d.scale+d.offset,w+o.seed*(d.phaseMax||0),3);o.vx+=m[0]*p,o.vy+=m[1]*p,o.vz+=m[2]*p}c.rotation&&(o.rot=Le(c.rotation.min[2],c.rotation.max[2])),c.angularVelocity&&(o.rotVel=Le(c.angularVelocity.min[2],c.angularVelocity.max[2]));const l=this.ops;if(l.oscPos&&(o.oscFreq=Le(l.oscPos.freqMin,l.oscPos.freqMax),o.oscAmp=Le(l.oscPos.scaleMin,l.oscPos.scaleMax),o.oscPhase=Le(l.oscPos.phaseMin,l.oscPos.phaseMax)+o.seed*at),l.oscAlpha&&(o.oscAFreq=Le(l.oscAlpha.freqMin,l.oscAlpha.freqMax),o.oscAPhase=Math.random()*(l.oscAlpha.phaseMax||at)),l.oscSize&&(o.oscSFreq=Le(l.oscSize.freqMin,l.oscSize.freqMax),o.oscSPhase=Math.random()*(l.oscSize.phaseMax||at)),l.turbulence.length){const d=l.turbulence[0];o.turbSpeed=Le(d.speedMin,d.speedMax),o.turbPhase=Le(d.phaseMin,d.phaseMax)}if(this.frameCount>1&&(o.frame=this.animationMode==="randomframe"?Math.floor(Math.random()*this.frameCount):0),o.bx=o.x,o.by=o.y,o.bz=o.z,o.trail)for(let d=0;d<o.trail.length;d+=3)o.trail[d]=o.x,o.trail[d+1]=o.y,o.trail[d+2]=o.z}updateParticle(n,t){if(n.age+=t,n.age>=n.life){n.alive=!1;return}const r=n.age/n.life,o=this.ops;if(o.movement&&(n.vx+=o.movement.gravity[0]*t,n.vy+=o.movement.gravity[1]*t,n.vz+=o.movement.gravity[2]*t,o.movement.drag>0)){const c=Math.exp(-o.movement.drag*t);n.vx*=c,n.vy*=c,n.vz*=c}o.angularMovement&&(n.rotVel+=(o.angularMovement.force[2]||0)*t,o.angularMovement.drag>0&&(n.rotVel*=Math.exp(-o.angularMovement.drag*t)));for(const c of o.turbulence){const a=c.timeScale||1,u=Dr(n.bx*c.scale,n.by*c.scale,this.simTime*c.scale*a+n.turbPhase,3);n.vx+=u[0]*n.turbSpeed*c.mask[0]*t,n.vy+=u[1]*n.turbSpeed*c.mask[1]*t,n.vz+=u[2]*n.turbSpeed*c.mask[2]*t}for(const c of o.attract){const a=this._cpPos(c.cp);if(!a)continue;const u=a[0]+c.origin[0]-n.x,l=a[1]+c.origin[1]-n.y,d=Math.hypot(u,l);if(d<.001||c.threshold>0&&d>c.threshold)continue;const h=c.threshold>0?1-d/c.threshold:1,p=c.scale*h*t/Math.max(1,d);n.vx+=u*p,n.vy+=l*p}for(const c of o.vortex){const a=this._cpPos(c.cp)||[0,0,0],u=n.x-(a[0]+c.offset[0]),l=n.y-(a[1]+c.offset[1]),d=Math.hypot(u,l);if(d<.001)continue;const h=c.distanceOuter-c.distanceInner,p=h>0?Math.min(1,Math.max(0,(d-c.distanceInner)/h)):0,w=c.audioMode?Ir(c.audioBounds,this._audioLevel||0):1,m=c.speedInner+(c.speedOuter-c.speedInner)*p;n.vx+=-l/d*m*t*w,n.vy+=u/d*m*t*w}for(const c of o.remap){const a=c.inputScale||1,u=Dr(n.bx*.01*a,n.by*.01*a,this.simTime*.1,c.fn==="fbmnoise"?4:2);if(c.output==="velocity")for(let l=0;l<3;l++){const d=(u[l]+1)/2,h=c.rangeMin[l]+(c.rangeMax[l]-c.rangeMin[l])*d;l===0?n.vx=h:l===1?n.vy=h:n.vz=h}else if(c.output==="speed"){const l=(u[0]+1)/2,d=c.rangeMin[0]+(c.rangeMax[0]-c.rangeMin[0])*l,h=Math.hypot(n.vx,n.vy)||1;n.vx=n.vx/h*d,n.vy=n.vy/h*d}}if(n.bx+=n.vx*t,n.by+=n.vy*t,n.bz+=n.vz*t,n.rot+=n.rotVel*t,n.x=n.bx,n.y=n.by,n.z=n.bz,o.oscPos){const c=this.simTime*n.oscFreq*at+n.oscPhase,a=o.oscPos.mask;n.x+=Math.sin(c)*n.oscAmp*a[0],n.y+=Math.cos(c)*n.oscAmp*a[1],n.z+=Math.sin(c*.7)*n.oscAmp*a[2]}let i=n.baseSize;if(o.sizeChange){const c=o.sizeChange,a=c.endTime-c.startTime,u=a>0?Math.min(1,Math.max(0,(r-c.startTime)/a)):r>=c.startTime?1:0;i*=c.startValue+(c.endValue-c.startValue)*u}if(o.oscSize){const c=this.simTime*n.oscSFreq*at+n.oscSPhase,a=o.oscSize,u=(a.scaleMin+a.scaleMax)/2,l=(a.scaleMax-a.scaleMin)/2;i*=u+Math.sin(c)*l}if(n.size=i,o.colorChange){const c=o.colorChange,a=c.endTime-c.startTime,u=a>0?Math.min(1,Math.max(0,(r-c.startTime)/a)):r>=c.startTime?1:0,l=c.startValue||[n.baseR,n.baseG,n.baseB];n.r=l[0]+(c.endValue[0]-l[0])*u,n.g=l[1]+(c.endValue[1]-l[1])*u,n.b=l[2]+(c.endValue[2]-l[2])*u}let s=n.baseAlpha;if(o.alphaFade){const c=o.alphaFade.fadeIn,a=o.alphaFade.fadeOut;c>0&&r<c&&(s*=r/c),a<1&&r>a&&(s*=Math.max(0,(1-r)/(1-a)))}else o.alphaChange||(r<.1?s*=r/.1:r>.85&&(s*=(1-r)/.15));if(o.alphaChange){const c=o.alphaChange,a=c.endTime-c.startTime,u=a>0?Math.min(1,Math.max(0,(r-c.startTime)/a)):r>=c.startTime?1:0;s*=c.startValue+(c.endValue-c.startValue)*u}if(o.oscAlpha){const c=this.simTime*n.oscAFreq*at+n.oscAPhase,a=o.oscAlpha,u=(a.scaleMin+a.scaleMax)/2,l=(a.scaleMax-a.scaleMin)/2;s*=u+Math.sin(c)*l}if(n.alpha=Math.max(0,s),this.frameCount>1&&this.animationMode!=="randomframe"&&(n.frame=Math.min(this.frameCount-1,Math.floor(r*this.frameCount))),n.trail){const c=n.trail;for(let a=c.length-3;a>=3;a-=3)c[a]=c[a-3],c[a+1]=c[a-2],c[a+2]=c[a-1];c[0]=n.x,c[1]=n.y,c[2]=n.z}}_cpPos(n){const t=this.controlPoints.find(r=>r.id===n);return t?t.lockToPointer?this.pointer?[this.pointer.x+t.offset[0],this.pointer.y+t.offset[1],t.offset[2]]:null:t.offset:null}advance(n,t){if(!(this.paused||!this.visible)){if(this._syncFollow(),!this._warmed&&(this._warmed=!0,this.startTime>0)){const r=.03333333333333333,o=Math.min(900,Math.round(this.startTime/r));for(let i=0;i<o;i++)this._step(r)}this._step(n,t)}}_step(n,t){this.simTime+=n;const r=t&&Number.isFinite(t.level)?Math.max(0,Math.min(1,t.level)):0;this._audioLevel=r;for(const i of this.emitters){if(i.instantaneous>0&&!i._burst){i._burst=!0;for(let a=0;a<Math.min(i.instantaneous,this.maxCount);a++)this.spawn(i)}if(i.fill){const u=Math.min(this.maxCount,2048);let l=0;for(let h=0;h<this.pool.length;h++)this.pool[h].alive&&l++;let d=Math.min(u-l,512);for(;d-- >0;)this.spawn(i);continue}if(i.audioDriven){const a=Ir(i.audioBounds,r);if(i.rate>0){const u=i.rate*a*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(u>0))continue;i._accum=(i._accum||0)+u*n;let l=Math.floor(i._accum);if(l>0){i._accum-=l,l>this.maxCount&&(l=this.maxCount);for(let d=0;d<l;d++)this.spawn(i)}}else{const l=Math.round(Math.min(this.maxCount,2048)*a);let d=0;for(let p=0;p<this.pool.length;p++)this.pool[p].alive&&d++;let h=Math.min(l-d,256);for(;h-- >0;)this.spawn(i)}continue}const s=i.rate*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(s>0))continue;i._accum=(i._accum||0)+s*n;let c=Math.floor(i._accum);if(c>0){i._accum-=c,c>this.maxCount&&(c=this.maxCount);for(let a=0;a<c;a++)this.spawn(i)}}const o=this.pool;for(let i=0;i<o.length;i++)o[i].alive&&this.updateParticle(o[i],n)}render(n,t,r,o,i){if(!this._ready||!this.visible||!this.renderers.length)return;const s=this.gl;this._prog||this._buildProgram(s);const c=this.trailCfg&&this.trailCfg.kind==="ropetrail"?this.trailCfg:null,a=this.trailCfg&&this.trailCfg.kind==="spritetrail"?this.trailCfg:null,u=jo(this.trailCfg,this.trailSegments),l=12,d=this.pool;let h=0;for(let G=0;G<d.length;G++)d[G].alive&&h++;if(h===0)return;const p=h*u,w=p*l;(!this._data||this._data.length<w)&&(this._data=new Float32Array(Math.max(w,1024)));const m=this._data;let g=0;const v=this._ov.brightness||1,b=this.sysScale,y=this.spriteStretchX*(this.texAspectX||1),S=this.spriteStretchY*(this.texAspectY||1),_=Math.cos(this.angleZ),C=Math.sin(this.angleZ),N=this.originX,D=this.originY,k=this.scaleX,O=this.scaleY,j=(G,Q)=>{const q=G*k,te=Q*O;return[N+q*_-te*C,i-(D+q*C+te*_)]};for(let G=0;G<d.length;G++){const Q=d[G];if(Q.alive)for(let q=0;q<u;q++){let te=Q.x,me=Q.y,xe=1,We=1;if(c&&Q.trail){te=Q.trail[q*3],me=Q.trail[q*3+1];const Pe=u>1?q/(u-1):0;xe=1-Pe,We=1-Pe*.55}const Ve=j(te,me);let Ee=Q.rot,rt=y,Xe=S;if(a){const Pe=j(Q.x+Q.vx,Q.y+Q.vy);Ee=$o(Pe[0]-Ve[0],Pe[1]-Ve[1]);const Ae=zo(Math.hypot(Q.vx,Q.vy),a.length,a.minLength,a.maxLength);Xe=S*Ae}m[g++]=Ve[0],m[g++]=Ve[1],m[g++]=0,m[g++]=Math.abs(Q.size)*b*We,m[g++]=Ee,m[g++]=Q.r*v,m[g++]=Q.g*v,m[g++]=Q.b*v,m[g++]=Q.alpha*xe,m[g++]=rt,m[g++]=Xe,m[g++]=Q.frame}}const W=this._prog;s.useProgram(W.prog),s.bindVertexArray(this._vao),s.bindBuffer(s.ARRAY_BUFFER,this._vbuf),s.bufferData(s.ARRAY_BUFFER,m.subarray(0,g),s.DYNAMIC_DRAW),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(W.uniTex,0),s.uniformMatrix4fv(W.uniMvp,!1,n);const K=this.refract&&this.normalTex&&this.normalTex.glTex;if(W.uniRefract&&s.uniform1i(W.uniRefract,K?1:0),K){s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.normalTex.glTex),W.uniNormal&&s.uniform1i(W.uniNormal,1);const G=this.blend!=="additive";if(W.uniSampleScene&&s.uniform1i(W.uniSampleScene,G?1:0),G){const Q=s.drawingBufferWidth||t,q=s.drawingBufferHeight||r;s.bindFramebuffer(s.FRAMEBUFFER,null),s.activeTexture(s.TEXTURE2),this._sceneTex?s.bindTexture(s.TEXTURE_2D,this._sceneTex):(this._sceneTex=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._sceneTex),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGB8,0,0,Q,q,0),W.uniScene&&s.uniform1i(W.uniScene,2),W.uniResolution&&s.uniform2f(W.uniResolution,Q,q),W.uniRefractScale&&s.uniform1f(W.uniRefractScale,this.refractAmount||.04)}else s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),W.uniScene&&s.uniform1i(W.uniScene,2)}else W.uniNormal&&(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(W.uniNormal,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),W.uniScene&&s.uniform1i(W.uniScene,2),W.uniSampleScene&&s.uniform1i(W.uniSampleScene,0));const V=this._frameUniformData();V?(s.uniform1i(W.uniFrameCount,V.count),s.uniform4fv(W.uniFrames,V.arr)):s.uniform1i(W.uniFrameCount,0),s.enable(s.BLEND),this.blend==="additive"?s.blendFunc(s.SRC_ALPHA,s.ONE):s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.depthMask(!1),s.drawArraysInstanced(s.TRIANGLE_STRIP,0,4,p),s.depthMask(!0),s.disable(s.BLEND),s.bindVertexArray(null)}_buildProgram(n){const t=da(n);this._quadBuf=t.quadBuf,this._vbuf=t.vbuf,this._vao=t.vao,this._prog=t.prog}_frameUniformData(){if(this._frameData!==void 0)return this._frameData;let n=this.texFrames;if(!n&&this.sequenceMul>1){const o=this.sequenceMul;n=[];for(let i=0;i<o;i++)for(let s=0;s<o;s++)n.push({ou:s/o,ov:i/o,su:1/o,sv:1/o})}if(!n||n.length===0)return this._frameData=null,null;const t=Math.min(n.length,128),r=new Float32Array(t*4);for(let o=0;o<t;o++)r[o*4]=n[o].ou,r[o*4+1]=n[o].ov,r[o*4+2]=n[o].su,r[o*4+3]=n[o].sv;return this._frameData={count:t,arr:r},this._frameData}liveCount(){let n=0;for(const t of this.pool)t.alive&&n++;return n}dispose(){this.paused=!0;const n=this.gl;if(n){try{this._vbuf&&n.deleteBuffer(this._vbuf),this._quadBuf&&n.deleteBuffer(this._quadBuf),this._vao&&n.deleteVertexArray(this._vao),this._prog&&this._prog.prog&&n.deleteProgram(this._prog.prog),this._sceneTex&&n.deleteTexture(this._sceneTex)}catch{}this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null}}}const ga=Object.freeze(Object.defineProperty({__proto__:null,ParticleSystem:pa,particleInstanceSegs:jo,particlePassRefract:Do,rgbaIsBlankWhite:ha,spriteTrailLengthFactor:zo,spriteTrailRotation:$o},Symbol.toStringTag,{value:"Module"})),An=new Map,zr=new Map;let nr=null;function ba(e,n){const t=String(e);zr.set(t,n),An.delete(t)}function va(e){nr=typeof e=="function"?e:null}function ya(){zr.clear(),nr=null,An.clear()}function xa(){return Object.keys(Pn)}function Se(e,n,t){e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=Math.round(Math.min(1,Math.max(0,t))*255)}function Tn(e,n){const{width:t,height:r,rgba:o}=e,i=Math.max(2,Math.round(Math.min(t,r)*.04));for(let s=0;s<r;s++)for(let c=0;c<t;c++){const a=Math.min(c,s,t-1-c,r-1-s);if(a>=i)continue;const u=a/i,l=(s*t+c)*4+3;o[l]=Math.round(o[l]*u)}if(n>0){let s=0;const c=t*r;for(let u=0;u<c;u++)s+=o[u*4+3];const a=s/c/255;if(a>n&&a>0){const u=n/a;for(let l=0;l<c;l++)o[l*4+3]=Math.round(o[l*4+3]*u)}}return e}function $r(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const cn=e=>e*e*(3-2*e),Wo=e=>e*e*e*(e*(e*6-15)+10),jr=(e,n,t)=>e+(n-e)*t,oe=(e,n)=>Math.exp(-(e*e)/(n*n));function Zt(e,n,t,r){const o=Math.min(e,n,t-1-e,t-1-n);return o>=r?1:o/r}function Sn(e,n){const t=new Uint8Array(e*e*4),r=e/2;for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=Math.hypot((i+.5-r)/r,(o+.5-r)/r);let c=0;for(let a=0;a<n.length;a++)c+=n[a].w*oe(s,n[a].r);Se(t,(o*e+i)*4,c)}return{width:e,height:e,rgba:t}}function At(e,n,t){return Sn(e,[n,t])}function Tt(e,n,t,r,o){const i=new Uint8Array(e*e*4),s=e/2,c=Math.max(2,Math.round(e*.03));for(let a=0;a<e;a++)for(let u=0;u<e;u++){const l=(u+.5-s)/s,d=(a+.5-s)/s,h=Math.hypot(l,d),p=Math.atan2(d,l),w=Math.pow(.5+.5*Math.cos(n*p),r);let m=oe(h,o)+w*oe(h,t);m*=Zt(u,a,e,c),Se(i,(a*e+u)*4,m)}return{width:e,height:e,rgba:i}}function nt(e,n,t,r,o){const i=o===void 0?.55:o,s=new Uint8Array(e*n*4);for(let c=0;c<n;c++){const a=c/(n-1),u=r?oe(a-.5,.27):cn(Math.min(1,a/.06))*Math.pow(1-a,1.35);for(let l=0;l<e;l++){const d=l/(e-1)*2-1,h=oe(d,t);Se(s,(c*e+l)*4,h*h*h*u*i)}}return{width:e,height:n,rgba:s}}function Wr(e,n,t){const r=new Uint8Array(e*e*4),o=e/2;for(let i=0;i<e;i++)for(let s=0;s<e;s++){const c=Math.hypot((s-o)/o,(i-o)/o);Se(r,(i*e+s)*4,oe(c-n,t*.6)*Math.max(0,1-c))}return{width:e,height:e,rgba:r}}function Vo(e,n){const t={1:{r:.78,t:.048,inner:.06,hi:[[-.28,-.32,.22,.9],[.32,.36,.12,.28]]},2:{r:.7,t:.07,inner:.14,hi:[[-.2,-.28,.3,.72],[.38,.2,.14,.4]]},3:{r:.84,t:.036,inner:.04,hi:[[-.34,-.18,.16,.95],[.2,.42,.1,.22],[.04,-.08,.07,.18]]}},r=t[n]||t[1],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-i)/i,u=(s+.5-i)/i,l=Math.hypot(a,u);let d=oe(l-r.r,r.t*.85)*Math.max(0,1.05-l);l<r.r&&(d+=r.inner*oe(l,.5));for(let h=0;h<r.hi.length;h++){const p=r.hi[h];d+=p[3]*oe(Math.hypot(a-p[0],u-p[1]),p[2])}Se(o,(s*e+c)*4,d)}return Tn({width:e,height:e,rgba:o},.05)}function En(e,n){const t=e>>1,r=new Uint8Array(e*e*4),o=n===1?[1,2,1,3]:n===2?[2,1,2,3]:[3,1,2,3];for(let i=0;i<2;i++)for(let s=0;s<2;s++){const c=Vo(t,o[i*2+s]);for(let a=0;a<t;a++){const u=(i*t+a)*e,l=a*t;for(let d=0;d<t;d++){const h=(u+s*t+d)*4,p=(l+d)*4;r[h]=c.rgba[p],r[h+1]=c.rgba[p+1],r[h+2]=c.rgba[p+2],r[h+3]=c.rgba[p+3]}}}return{width:e,height:e,rgba:r}}function Xo(e){const n=new Uint8Array(e*e*4),t=e/2,r=[[.32,0],[1.1,.35],[2.2,-.3],[-.7,.2]];for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=i>=t?1:0,c=o>=t?1:0,a=c*2+s,u=s*t+t/2,l=c*t+t/2,d=r[a][0],h=r[a][1],p=(i+.5-u)/(t*.4),w=(o+.5-l)/(t*.4),m=Math.cos(d),g=Math.sin(d);let v=p*m+w*g;const b=-p*g+w*m;v+=h*b*.18;const y=1-Math.max(0,b)*.42,S=Math.hypot(v/(.52*y),b/.92);let _=S>=1.12?0:oe(S,.48);_=Math.min(1,_+oe(v,.07)*oe(b,.65)*_*.4),Se(n,(o*e+i)*4,_)}return Tn({width:e,height:e,rgba:n},.11)}function Ie(e,n){const t={0:{rx:.36,ry:.92,wave:0,folds:0},1:{rx:.48,ry:.86,wave:.05,folds:7},2:{rx:.4,ry:.88,wave:.08,folds:5},3:{rx:.58,ry:.72,wave:0,folds:0},5:{rx:.44,ry:.8,wave:.12,folds:9},6:{rx:.52,ry:.78,wave:.07,folds:4},7:{rx:.5,ry:.9,wave:.16,folds:3},8:{rx:.38,ry:.94,wave:.2,folds:2}},r=t[n]||t[0],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-i)/i,u=(s+.5-i)/i,l=Math.atan2(a,u),d=r.wave?1+r.wave*Math.sin(l*r.folds):1,h=Math.hypot(a/(r.rx*d),u/r.ry);let p=h>=1.12?0:oe(h,.5);p>0&&(p=Math.min(1,p+oe(a,.028)*oe(u,.72)*.28)),Se(o,(s*e+c)*4,p)}return Tn({width:e,height:e,rgba:o},.11)}function ct(e,n){const t=e.width,r=e.height,o=e.rgba,i=n??2.8,s=new Uint8Array(t*r*4),c=(a,u)=>{const l=a<0?0:a>=t?t-1:a,d=u<0?0:u>=r?r-1:u;return o[(d*t+l)*4+3]/255};for(let a=0;a<r;a++)for(let u=0;u<t;u++){const l=(c(u-1,a)-c(u+1,a))*i,d=(c(u,a-1)-c(u,a+1))*i,h=1/Math.hypot(l,d,1),p=(a*t+u)*4;s[p]=Math.round((l*h*.5+.5)*255),s[p+1]=Math.round((d*h*.5+.5)*255),s[p+2]=Math.round((h*.5+.5)*255),s[p+3]=255}return{width:t,height:r,rgba:s}}function Ho(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,c=Math.hypot(i,s),a=c>=1?0:Math.sqrt(Math.max(0,1-c*c)),u=oe(c-.62,.11)*.55;Se(n,(r*e+o)*4,Math.min(1,a*.85+u))}return{width:e,height:e,rgba:n}}function wa(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,c=Math.hypot(i,s),a=Math.atan2(s,i),u=oe(c,.38)*(.55+.45*Math.cos(a*3+c*6));Se(n,(r*e+o)*4,u)}return{width:e,height:e,rgba:n}}function Go(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(o+.5-t)/t,a=Math.hypot(s,c),u=Math.atan2(c,s),l=cn(Math.max(0,Math.cos(u)*.55+.45)),d=oe(a-.68,.07)*l+.35*oe(a-.78,.12)*oe(u-.9,.55);Se(n,(o*e+i)*4,Math.min(1,d)*Zt(i,o,e,r))}return{width:e,height:e,rgba:n}}function Ma(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/48|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<240||e[i+1]<240||e[i+2]<240)return!1;r++}return r>0}function _a(e){return!e||!e.rgba?e:Ma(e.rgba)?ct(e,2.8):e}const Aa={"particle/drop":"particle/drop_normal","particle/water/rain_drops_sheet":"particle/water/rain_drops_sheet_normal","particle/bubbles/bubble1":"particle/bubbles/bubble1normal","particle/bubbles/bubble2":"particle/bubbles/bubble2_normal","particle/sharp_halo":"particle/sharp_halo_normal","particle/misc/wave":"particle/normal_splash","particle/halo":"particle/sharp_halo_normal"};function Ta(e){if(!e)return null;const n=String(e);return/normal/i.test(n)?n:Aa[n]||n+"_normal"}function Sa(e){const n=String(e);return/(^|\/)normal_/.test(n)?null:/_normal$/i.test(n)?n.replace(/_normal$/i,""):/normal$/i.test(n)?n.replace(/normal$/i,""):null}function Ea(e){if(Pn[e])return Pn[e]();const n=String(e).toLowerCase();return/normal/.test(n)?At(64,{r:.18,w:1},{r:.4,w:.2}):ti(e)()}function Yo(e,n,t){const r=$r(t*7919+17);let o=e;const i=[];for(let a=0;a<n;a++){const u=o*o,l=new Float32Array(u*2);for(let d=0;d<u;d++){const h=r()*Math.PI*2;l[d*2]=Math.cos(h),l[d*2+1]=Math.sin(h)}i.push({f:o,g:l,ox:a*7.31,oy:a*3.17}),o*=2}const s=(a,u,l,d,h)=>{const p=a.f,w=(u%p+p)%p,g=((l%p+p)%p*p+w)*2;return a.g[g]*d+a.g[g+1]*h},c=(a,u,l)=>{const d=(u+a.ox)*a.f,h=(l+a.oy)*a.f,p=Math.floor(d),w=Math.floor(h),m=d-p,g=h-w,v=Wo(m),b=Wo(g);return jr(jr(s(a,p,w,m,g),s(a,p+1,w,m-1,g),v),jr(s(a,p,w+1,m,g-1),s(a,p+1,w+1,m-1,g-1),v),b)};return function(u,l,d){const h=d==null?i.length:Math.min(d,i.length);let p=1,w=0,m=0;for(let g=0;g<h;g++)w+=(c(i[g],u,l)*.5+.5)*p,m+=p,p*=.55;return w/m}}function qo(e,n,t){const{width:r,height:o,rgba:i}=e;if(r===n&&o===t)return e;const s=new Uint8Array(n*t*4);for(let c=0;c<t;c++){const a=(c+.5)/t*o-.5,u=Math.max(0,Math.min(o-1,Math.floor(a))),l=Math.max(0,Math.min(o-1,u+1)),d=a-Math.floor(a);for(let h=0;h<n;h++){const p=(h+.5)/n*r-.5,w=Math.max(0,Math.min(r-1,Math.floor(p))),m=Math.max(0,Math.min(r-1,w+1)),g=p-Math.floor(p),v=i[(u*r+w)*4+3],b=i[(u*r+m)*4+3],y=i[(l*r+w)*4+3],S=i[(l*r+m)*4+3],_=(v*(1-g)+b*g)*(1-d)+(y*(1-g)+S*g)*d;Se(s,(c*n+h)*4,_/255)}}return{width:n,height:t,rgba:s}}function It(e,n,t,r,o,i,s){const c=i===void 0?1:i,a=s===void 0?200:s,u=256,l=Yo(n,t,r),d=new Uint8Array(u*u*4),h=u/2,p=u*u,w=new Float32Array(p);let m=1,g=0;for(let S=0;S<p;S++){const _=S%u,C=S/u|0,N=(_+.5)/u,D=(C+.5)/u,k=l(N+5.2,D+1.3,2)-.5,O=l(N+9.7,D+8.1,2)-.5,j=w[S]=l(N+k*.45,D+O*.45);j<m&&(m=j),j>g&&(g=j)}const v=g-m||1;for(let S=0;S<u;S++)for(let _=0;_<u;_++){const C=(w[S*u+_]-m)/v,N=Math.hypot((_+.5-h)/h,(S+.5-h)/h),D=Math.pow(Math.max(0,1-N),c);let k=Math.max(0,(C-(1-o))/(o||1));k=cn(Math.min(1,k))*D,Se(d,(S*u+_)*4,k)}let b=0;for(let S=0;S<p;S++)b=Math.max(b,d[S*4+3]);if(b>0&&b<a){const S=a/b;for(let _=0;_<p;_++)d[_*4+3]=Math.round(Math.min(255,d[_*4+3]*S))}const y={width:u,height:u,rgba:d};return u===e?y:qo(y,e,e)}function Vr(e,n){const t=e,r=Yo(3,5,n??23),o=new Uint8Array(t*t*4),i=t*t,s=new Float32Array(i);let c=1,a=0;for(let h=0;h<i;h++){const p=h%t,w=h/t|0,m=(p+.5)/t,g=(w+.5)/t,v=r(m+2.1,g+4.7,2)-.5,b=r(m+6.3,g+1.9,2)-.5,y=s[h]=r(m+v*.28,g+b*.55);y<c&&(c=y),y>a&&(a=y)}const u=a-c||1;for(let h=0;h<t;h++)for(let p=0;p<t;p++){const w=(h+.5)/t,m=(p+.5)/t*2-1,g=.1+.52*Math.pow(w,1.25),v=(s[h*t+p]-c)/u,b=oe(m/(g||.01),.55)*oe(w-.58,.42);let y=cn(Math.min(1,Math.max(0,(v-.18)/.72)))*b;y*=w<.06?w/.06:1,Se(o,(h*t+p)*4,y)}let l=0;for(let h=0;h<i;h++)l=Math.max(l,o[h*4+3]);if(l>0&&l<220){const h=220/l;for(let p=0;p<i;p++)o[p*4+3]=Math.round(Math.min(255,o[p*4+3]*h))}const d=Tn({width:t,height:t,rgba:o},.08);return t===e?d:qo(d,e,e)}function Xr(e,n,t,r){const o=new Uint8Array(e*n*4),i=e/t,s=n/r;for(let c=0;c<n;c++)for(let a=0;a<e;a++){const u=Math.floor(a/i),l=Math.floor(c/s),d=(a+.5-u*i)/i*2-1,h=(c+.5-l*s)/s*2-1,p=1-Math.max(0,h)*.45,w=Math.hypot(d/(.52*p),h/.8),m=w>=1.12?0:oe(w,.48);Se(o,(c*e+a)*4,m)}return{width:e,height:n,rgba:o}}function Zo(e){const n=new Uint8Array(e*e*4),t=$r(7),r=[];for(let o=0;o<11;o++)r.push({x:.14+t()*.72,y:.14+t()*.72,rx:.025+t()*.03,ry:.018+t()*.024,rot:t()*Math.PI});for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5)/e,c=(o+.5)/e;let a=0;for(const u of r){const l=s-u.x,d=c-u.y,h=Math.cos(u.rot),p=Math.sin(u.rot),w=(l*h+d*p)/u.rx,m=(-l*p+d*h)/u.ry,g=oe(Math.hypot(w,m),.55);g>a&&(a=g)}Se(n,(o*e+i)*4,a)}return{width:e,height:e,rgba:n}}function rr(e,n){const t=n??19,r=$r(t),o=h=>Math.min(.86,Math.max(.14,h)),i=5+t%4,s=[];let c=o(.5+(r()-.5)*.16);for(let h=0;h<=i;h++){const p=.06+h/i*.86;h>0&&(c=o(c+(r()-.5)*.32)),s.push([c,p])}const a=[];for(let h=0;h<s.length-1;h++)a.push([s[h],s[h+1],1]);const u=1+t%2;for(let h=0;h<u;h++){const p=1+(t+h*3)%Math.max(1,s.length-2),w=s[p],m=[w];let g=w[0],v=w[1];const b=2+t%2;for(let y=0;y<b;y++)g=o(g+(r()-.5)*.36),v=Math.min(.92,v+.1+r()*.08),m.push([g,v]);for(let y=0;y<m.length-1;y++)a.push([m[y],m[y+1],.45+h*.1])}const l=new Uint8Array(e*e*4),d=Math.max(2,Math.round(e*.04));for(let h=0;h<e;h++)for(let p=0;p<e;p++){const w=(p+.5)/e,m=(h+.5)/e;let g=9,v=0;for(const[y,S,_]of a){const C=S[0]-y[0],N=S[1]-y[1],D=C*C+N*N||1e-8,k=Math.max(0,Math.min(1,((w-y[0])*C+(m-y[1])*N)/D)),O=Math.hypot(w-(y[0]+C*k),m-(y[1]+N*k));O/_<g&&(g=O/_,v=_)}const b=.95*oe(g,.012)+.3*oe(g,.05)*v;Se(l,(h*e+p)*4,Math.min(1,b)*Zt(p,h,e,d))}return{width:e,height:e,rgba:l}}function Hr(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++)for(let o=0;o<e;o++){const i=(o+.5-e/2)/(e/2),s=(r+.5-n/2)/(n/2),c=oe(i,.34)*Math.exp(-Math.max(0,-s-.05)*4.2)*(s<.1?1:Math.max(0,1-s*4)),a=Math.hypot(i/.34,(s-.42)/.3),u=a>=1?0:oe(a,.5);Se(t,(r*e+o)*4,Math.max(c,u))}return{width:e,height:n,rgba:t}}function Pa(e){return At(e,{r:.1,w:1},{r:.3,w:.16})}function Gr(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++){const o=(r+.5)/n,i=cn(Math.min(1,Math.min(o/.08,(1-o)/.08))),s=oe(o-.46,.24)*i,c=.5*(1-cn(Math.min(1,Math.max(0,(o-.42)/.5)))*.6);for(let a=0;a<e;a++){const u=(a+.5-e/2)/(e/2);Se(t,(r*e+a)*4,oe(Math.abs(u)/(c||.01),.5)*s)}}return{width:e,height:n,rgba:t}}function Ko(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(o+.5-t)/t,a=oe(Math.hypot(s,c),.42),u=oe(Math.hypot(s-.34,c),.36),l=Math.max(0,a-u*1.08)*Zt(i,o,e,r);Se(n,(o*e+i)*4,l)}return{width:e,height:e,rgba:n}}function Qo(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(o+.5-t)/t;let a=oe(Math.hypot(s,c),.08);for(let u=0;u<6;u++){const l=u*Math.PI/3,d=Math.cos(l),h=Math.sin(l),p=s*d+c*h,w=-s*h+c*d;if(p<0)continue;const m=Math.max(0,1.02-p/.72);a+=oe(w,.028)*oe(p,.5)*m,a+=.55*oe(w-(p-.28)*.65,.02)*oe(p-.28,.12)*m,a+=.55*oe(w+(p-.28)*.65,.02)*oe(p-.28,.12)*m,a+=.4*oe(w-(p-.48)*.7,.016)*oe(p-.48,.08)*m,a+=.4*oe(w+(p-.48)*.7,.016)*oe(p-.48,.08)*m}Se(n,(o*e+i)*4,Math.min(1,a)*Zt(i,o,e,r))}return{width:e,height:e,rgba:n}}function Jo(e,n){const t=new Uint8Array(e*e*4),r=e/2,o=Math.max(2,Math.round(e*.04)),i=Math.abs(n|0)%3;for(let s=0;s<e;s++)for(let c=0;c<e;c++){const a=(c+.5-r)/r*1.55,u=(s+.5-r)/r*1.55,l=Math.abs(Math.abs(a)+Math.abs(u)-.55);let d=oe(l,.016);i===0?(d+=oe(a,.012)*oe(u,.38),d+=oe(u,.012)*oe(a,.38)):i===1?(d+=oe(a-u,.012)*oe(a+u,.36),d+=oe(a+u,.012)*oe(a-u,.36)):(d+=oe(Math.hypot(a,u)-.26,.014),d+=oe(a,.012)*oe(u,.22)),Se(t,(s*e+c)*4,Math.min(1,d)*Zt(c,s,e,o))}return Tn({width:e,height:e,rgba:t},.03)}function Yr(e){let n=0;const t=String(e);for(let r=0;r<t.length;r++)n=n*31+t.charCodeAt(r)|0;return n}function ei(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.03));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,c=(o+.5-t)/t,a=Math.hypot(s,c),u=oe(a,.07)+.85*oe(s,.62)*oe(c,.045)+.22*oe(s,.92)*oe(c,.018);Se(n,(o*e+i)*4,Math.min(1,u)*Zt(i,o,e,r))}return{width:e,height:e,rgba:n}}const Pn={"particle/halo_6":()=>At(256,{r:.14,w:1},{r:.4,w:.17}),"particle/normal_splash":()=>ct(Ho(256),3.2),"particle/drop_normal":()=>ct(Gr(128,512),3.4),"particle/normal_ring_smooth":()=>ct(Wr(256,.55,.12),3.1),"particle/normal_pinch_rotate":()=>ct(wa(256),2.8),"particle/water/rain_drops_sheet_normal":()=>ct(Xr(256,512,2,4),3.6),"particle/bubbles/bubble1normal":()=>ct(En(256,1),3.2),"particle/bubbles/bubble2_normal":()=>ct(En(256,2),3.2),"particle/sharp_halo_normal":()=>ct(Sn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),3.4),"particle/beam/beam_0":()=>nt(128,512,.46,!0),"particle/beam/beam_1":()=>nt(128,512,.34,!0),"particle/beam/beam_2":()=>nt(128,512,.22,!0),"particle/beam/beam_2_fade":()=>nt(128,512,.24,!1),"particle/light/light_shafts_0":()=>nt(128,512,.42,!0),"particle/light/light_shafts_1":()=>nt(128,512,.3,!0),"particle/light/light_shafts_3":()=>nt(128,512,.26,!0),"particle/light/light_shafts_5":()=>nt(128,512,.23,!0),"particle/light/light_shafts_6":()=>nt(128,512,.2,!0),"particle/nature/rosepetals":()=>Xo(256),"particle/nature/leaves":()=>Ie(256,0),"particle/nature/leaves1":()=>Ie(256,1),"particle/nature/leaves2":()=>Ie(256,2),"particle/nature/leaves3":()=>Ie(256,3),"particle/nature/leaves5":()=>Ie(256,5),"particle/nature/leaves6":()=>Ie(256,6),"particle/nature/leaves7":()=>Ie(256,7),"particle/nature/leaves8":()=>Ie(256,8),"particle/nature/snow":()=>Qo(256),"particle/halo":()=>At(256,{r:.12,w:1},{r:.3,w:.15}),"particle/halo_1":()=>At(256,{r:.1,w:1},{r:.3,w:.13}),"particle/halo_2":()=>At(256,{r:.2,w:.9},{r:.44,w:.2}),"particle/halo_3":()=>Sn(256,[{r:.045,w:1},{r:.13,w:.85},{r:.36,w:.15}]),"particle/halo_4":()=>At(256,{r:.085,w:1},{r:.28,w:.12}),"particle/halo_5":()=>Sn(256,[{r:.04,w:1},{r:.11,w:.8},{r:.34,w:.17}]),"particle/sharp_halo":()=>Sn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),"particle/chromaticdot":()=>Pa(128),"particle/light/flare_0":()=>Tt(256,6,.58,10,.08),"particle/light/flare_1":()=>Tt(512,4,.62,14,.07),"particle/light/flare_2":()=>ei(256),"particle/drop":()=>Gr(128,512),"particle/nature/rain1":()=>nt(128,512,.16,!0,.6),"particle/nature/rain2":()=>nt(128,512,.24,!0,.55),"particle/water/rain_drops_sheet":()=>Xr(256,512,2,4),"particle/fog/fog1":()=>It(512,4,5,1,.4,.9,150),"particle/fog/fog2":()=>It(512,3,5,2,.45,.8,140),"particle/fog/fog3":()=>It(512,6,4,3,.36,1,150),"particle/smoke/smoke1":()=>It(512,3,5,7,.55,1.5,130),"particle/smoke/smoke2":()=>It(512,2,5,11,.6,1.7,120),"particle/smoke/smoke2light":()=>It(512,2,5,13,.4,1.7,110),"particle/misc/wave":()=>Wr(512,.72,.085),"particle/misc/star_0":()=>Tt(256,5,.62,8,.1),"particle/bubbles/bubble1":()=>En(256,1),"particle/bubbles/bubble2":()=>En(256,2),"particle/bubbles/bubble3":()=>En(256,3),"particle/debris/debris1":()=>Zo(128),"particle/lightning/lightning1":()=>rr(256,3),"particle/lightning/lightning2":()=>rr(256,11),"particle/lightning/lightning3":()=>rr(256,19),"particle/fire/fire1":()=>Vr(256,23),"particle/fire/fire2":()=>Vr(256,41),"particle/star":()=>Tt(256,4,.58,12,.09),"particle/shape/circle_wind":()=>Go(256),"particle/sickle":()=>Ko(256),"particle/magic/glyph_4":()=>Jo(256,4),"@sparkle":()=>Tt(256,4,.6,16,.08),"@star":()=>Tt(256,5,.62,8,.1),"@trail":()=>Hr(128,256)};function ti(e){const n=String(e).toLowerCase();if(/normal/.test(n)){const t=Sa(e);return t?()=>ct(Ea(t),2.8):()=>ct(Ho(128),2.6)}return/rosepetal|petal|sakura|blossom/.test(n)?()=>Xo(256):/leaf|leaves|foliage/.test(n)?/leaves8/.test(n)?()=>Ie(256,8):/leaves7/.test(n)?()=>Ie(256,7):/leaves6/.test(n)?()=>Ie(256,6):/leaves5/.test(n)?()=>Ie(256,5):/leaves3/.test(n)?()=>Ie(256,3):/leaves2/.test(n)?()=>Ie(256,2):/leaves1/.test(n)?()=>Ie(256,1):()=>Ie(256,0):/circle_wind|windcircle/.test(n)?()=>Go(256):/fog|cloud|mist|vapor/.test(n)?()=>It(512,4,5,5,.4,.9,150):/smoke/.test(n)?()=>It(512,3,5,8,.55,1.5,130):/beam|shaft|ray|godray/.test(n)?()=>nt(128,512,.3,!0):/flare/.test(n)?()=>ei(256):/bubble/.test(n)?()=>Vo(256,1):/ring|wave/.test(n)?()=>Wr(512,.72,.085):/fire|flame|ember|ash/.test(n)?()=>Vr(256,Yr(n)):/sickle|crescent|moon/.test(n)?()=>Ko(256):/glyph|magic|rune/.test(n)?()=>Jo(256,Yr(n)):/snowflake|雪花|snow/.test(n)?()=>Qo(256):/流星|meteor|shooting/.test(n)?()=>Hr(128,256):/star|星/.test(n)?()=>Tt(256,5,.62,8,.1):/sparkle|glint|twinkle/.test(n)?()=>Tt(256,4,.6,16,.08):/rain_drops_sheet|drops_sheet/.test(n)?()=>Xr(256,512,2,4):/drop|rain/.test(n)?()=>Gr(128,512):/debris|dirt|rock/.test(n)?()=>Zo(128):/lightning|bolt|arc/.test(n)?()=>rr(256,Yr(n)):/note|music/.test(n)?()=>Tt(256,4,.55,8,.12):/trail|streak/.test(n)?()=>Hr(128,256):()=>At(256,{r:.12,w:1},{r:.3,w:.15})}function Ca(e){if(An.has(e))return An.get(e);let n=null;const t=zr.get(e);if(t)try{n=t()}catch{n=null}if(!n&&nr)try{n=nr(e)}catch{n=null}if(!n&&Pn[e])try{n=Pn[e]()}catch{n=null}if(!n)try{n=ti(e)()}catch{n=null}return n||(n=At(256,{r:.12,w:1},{r:.3,w:.15})),An.set(e,n),n}function Ra(e){return typeof e=="string"&&e.indexOf("particle/")===0}const La=Object.freeze(Object.defineProperty({__proto__:null,buildBuiltinParticleTexture:Ca,isBuiltinParticleTextureName:Ra,listBuiltinParticleTextureNames:xa,particleNormalNameForAlbedo:Ta,prepareParticleNormalTexture:_a,resetParticleTextureFactories:ya,setParticleTextureFactory:ba,setParticleTextureProvider:va},Symbol.toStringTag,{value:"Module"})),ni=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function Ot(e,n,t){const r=t||new Float32Array(16);for(let o=0;o<4;o++)for(let i=0;i<4;i++)r[o*4+i]=e[i]*n[o*4]+e[4+i]*n[o*4+1]+e[8+i]*n[o*4+2]+e[12+i]*n[o*4+3];return r}function ri(e){const n=[];for(let r=0;r<4;r++)n.push([e[r],e[4+r],e[8+r],e[12+r],0,0,0,0]),n[r][4+r]=1;for(let r=0;r<4;r++){let o=r;for(let c=r+1;c<4;c++)Math.abs(n[c][r])>Math.abs(n[o][r])&&(o=c);const i=n[r];n[r]=n[o],n[o]=i;const s=n[r][r];if(Math.abs(s)<1e-12)return Float32Array.from(ni);for(let c=0;c<8;c++)n[r][c]/=s;for(let c=0;c<4;c++){if(c===r)continue;const a=n[c][r];if(a!==0)for(let u=0;u<8;u++)n[c][u]-=a*n[r][u]}}const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++)t[r*4+o]=n[o][4+r];return t}function qr(e,n,t,r,o,i,s,c,a,u){const l=u||new Float32Array(16),d=Math.cos(r),h=Math.sin(r),p=Math.cos(o),w=Math.sin(o),m=Math.cos(i),g=Math.sin(i);return l[0]=m*p*s,l[1]=g*p*s,l[2]=-w*s,l[3]=0,l[4]=(m*w*h-g*d)*c,l[5]=(g*w*h+m*d)*c,l[6]=p*h*c,l[7]=0,l[8]=(m*w*d+g*h)*a,l[9]=(g*w*d-m*h)*a,l[10]=p*d*a,l[11]=0,l[12]=e,l[13]=n,l[14]=t,l[15]=1,l}function Cn(e,n){const t=[];for(;n<e.byteLength;){const o=e.getUint8(n++);if(o===0)break;t.push(o)}let r="";try{r=new TextDecoder("utf-8").decode(new Uint8Array(t))}catch{r=String.fromCharCode.apply(null,t)}return{value:r,next:n}}function or(e,n,t=0){const r=[];for(let o=0;o<n.length;o++)r.push(n.charCodeAt(o));e:for(let o=t;o<=e.length-r.length;o++){for(let i=0;i<r.length;i++)if(e[o+i]!==r[i])continue e;return o}return-1}function Fa(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=String.fromCharCode.apply(null,Array.from(e.subarray(0,8)));if(!t.startsWith("MDLV"))throw new Error("\u4E0D\u662F MDL: "+t);const r=Cn(n,21),i=parseInt(t.slice(4),10)>=23?[{lenOff:32,stride:80,uv:72,bone:40,weight:56},{lenOff:32,stride:48,uv:40,bone:-1,weight:-1}]:[{lenOff:8,stride:52,uv:44,bone:12,weight:28},{lenOff:4,stride:52,uv:44,bone:12,weight:28},{lenOff:32,stride:80,uv:72,bone:40,weight:56}];let s=null,c=0,a=0;for(const G of i){const Q=r.next+G.lenOff;if(Q+4>e.byteLength)continue;const q=n.getUint32(Q,!0);if(q>0&&q%G.stride===0&&Q+4+q<=e.byteLength){s=G,c=q,a=Q;break}}if(!s)throw new Error("\u9876\u70B9\u533A\u957F\u5EA6\u5F02\u5E38\uFF08"+t+"\uFF0C\u5DF2\u8BD5 stride "+i.map(G=>G.stride).join("/")+"\uFF09");const u=a+4,l=c/s.stride,d=new Float32Array(l*3),h=new Float32Array(l*2),p=new Float32Array(l*4),w=new Float32Array(l*4);for(let G=0;G<l;G++){const Q=u+G*s.stride;if(d[G*3]=n.getFloat32(Q,!0),d[G*3+1]=n.getFloat32(Q+4,!0),d[G*3+2]=n.getFloat32(Q+8,!0),h[G*2]=n.getFloat32(Q+s.uv,!0),h[G*2+1]=n.getFloat32(Q+s.uv+4,!0),s.bone>=0&&s.weight>=0)for(let q=0;q<4;q++)p[G*4+q]=n.getUint32(Q+s.bone+q*4,!0),w[G*4+q]=n.getFloat32(Q+s.weight+q*4,!0);else p[G*4]=0,w[G*4]=1}const m=n.getUint32(u+c,!0),g=u+c+4,v=l>65535&&m%4===0,b=v?m/4:m/2,y=v?new Uint32Array(b):new Uint16Array(b);if(v)for(let G=0;G<b;G++)y[G]=n.getUint32(g+G*4,!0);else for(let G=0;G<b;G++)y[G]=n.getUint16(g+G*2,!0);const S=Ua(e,n),_=ka(e,n,S.length),C=Ia(e,n,S),N=Na(e,n,S.length),D=[],k=[],O=[];if(S.length>0){const G=S.map((q,te)=>{const me=q.matrix,xe=Math.hypot(me[0],me[1]),We=Math.hypot(me[4],me[5]);return O[te]=Float32Array.from([me[12],me[13],me[14],0,0,Math.atan2(me[1],me[0]),xe||1,We||1,me[10]||1]),Float32Array.from(me)});for(let q=0;q<S.length;q++){const te=O[q],me=S[q].matrix;Math.hypot(te[0]-me[12],te[1]-me[13])>.001&&(G[q]=qr(te[0],te[1],te[2],te[3],te[4],te[5],te[6],te[7],te[8],new Float32Array(16)))}const Q=[];for(let q=0;q<S.length;q++){const te=S[q].parent;Q[q]=te>=0&&te<q?Ot(Q[te],G[q]):Float32Array.from(G[q])}for(let q=0;q<S.length;q++)D[q]=ri(Q[q]);if(C){const q=[];for(let te=0;te<S.length;te++){const me=S[te].parent;q[te]=me>=0&&me<te?Ot(q[me],C[te]):Float32Array.from(C[te])}for(let te=0;te<S.length;te++)k[te]=Ot(q[te],D[te])}}let j=1/0,W=-1/0,K=1/0,V=-1/0;for(let G=0;G<l;G++){const Q=d[G*3],q=d[G*3+1];Q<j&&(j=Q),Q>W&&(W=Q),q<K&&(K=q),q>V&&(V=q)}return{magic:t,materialPath:r.value,vertexCount:l,positions:d,uvs:h,boneIdx:p,weights:w,indexCount:b,indexType:v?"u32":"u16",indices:y,bones:S,animations:_,animBound:Ba(_,S),invBindWorld:D,bindTRS:O.length>0?O:null,attachments:N.length>0?N:null,restCorrection:k.length>0?k:null,bounds:{minX:j,maxX:W,minY:K,maxY:V}}}function Na(e,n,t){const r=or(e,"MDAT");if(r<0)return[];const o=n.getUint16(r+13,!0);if(o<=0||o>256)return[];const i=[];let s=r+15;for(let c=0;c<o&&!(s+2>e.length);c++){const a=n.getUint16(s,!0),u=Cn(n,s+2);if(u.next+64>e.length)break;const l=new Float32Array(16);for(let d=0;d<16;d++)l[d]=n.getFloat32(u.next+d*4,!0);a<t&&i.push({bone:a,name:u.value,matrix:l}),s=u.next+64}return i}function Ua(e,n){const t=or(e,"MDLS");if(t<0)return[];const r=n.getUint32(t+13,!0);if(r<=0||r>1024)return[];const o=[];let i=t+17;for(let s=0;s<r;s++){if(i+77>n.byteLength)return o;const c=n.getUint32(i+1,!0),a=n.getInt32(i+5,!0),u=new Float32Array(16);for(let d=0;d<16;d++)u[d]=n.getFloat32(i+13+d*4,!0);const l=Cn(n,i+13+64);o.push({id:c,parent:a>=0&&a<r?a:-1,matrix:u}),i=l.next}return o}function ka(e,n,t){const r=or(e,"MDLA");if(r<0)return[];let o=r+9;const i=n.getUint32(o,!0);o+=4;const s=n.getUint32(o,!0);if(o+=4,s<=0||s>256)return[];const c=[];for(let a=0;a<s&&!(o+16>n.byteLength);a++){const u=n.getUint32(o,!0);o+=8;const l=Cn(n,o);o=l.next;const d=Cn(n,o);if(o=d.next,o+16>n.byteLength)break;const h=n.getFloat32(o,!0);o+=4;const p=n.getUint32(o,!0);o+=8;const w=n.getUint32(o,!0);if(o+=4,w>1024)break;const m=[];for(let g=0;g<w&&!(o+8>n.byteLength);g++){o+=4;const v=n.getUint32(o,!0);o+=4;const b=Math.floor(v/36);if(o+v>n.byteLength)break;const y=new Float32Array(b*9);for(let S=0;S<b;S++){const _=o+S*36;for(let C=0;C<9;C++)y[S*9+C]=n.getFloat32(_+C*4,!0)}o+=v,m.push({frameCount:b,keyframes:y})}if(o+=35,m.length>0&&p>0&&h>0&&c.push({id:u,name:l.value,mode:d.value,fps:h,frameCount:p,duration:p/h,tracks:m}),o>=i)break}return c}function Ba(e,n){let t=0,r=0;for(const o of e)for(let i=0;i<o.tracks.length;i++){const s=o.tracks[i];if(!s)continue;const c=n[i],a=c?c.matrix[12]:0,u=c?c.matrix[13]:0,l=s.keyframes;for(let d=0;d<s.frameCount;d++){const h=Math.abs(l[d*9]-a),p=Math.abs(l[d*9+1]-u);h>t&&(t=h),p>r&&(r=p)}}return{x:t,y:r}}function Ia(e,n,t){if(t.length===0)return null;const r=or(e,"MDLE");if(r<0)return null;const o=r+8+1+4+4;if(o+t.length*64>n.byteLength)return null;const i=[];for(let s=0;s<t.length;s++){const c=new Float32Array(16);for(let a=0;a<16;a++)c[a]=n.getFloat32(o+s*64+a*4,!0);i.push(c)}return i}function Oa(e,n,t,r){const o=e.frameCount;if(o===0)return r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=0,r[6]=1,r[7]=1,r[8]=1,r;const i=t*n.fps;let s,c,a;if(n.mode==="loop"){const p=Math.max(1,o-1),w=(i%p+p)%p;s=Math.floor(w),c=(s+1)%o,a=w-s}else if(n.mode==="mirror"){const p=Math.max(1,o-1),w=p*2;let m=(i%w+w)%w;m>p&&(m=w-m),s=Math.floor(m),c=Math.min(s+1,o-1),a=m-s}else{const p=Math.min(Math.max(i,0),o-1);s=Math.floor(p),c=Math.min(s+1,o-1),a=p-s}const u=e.keyframes,l=s*9,d=c*9,h=1-a;for(let p=0;p<9;p++)if(p>=3&&p<=5){let w=u[d+p]-u[l+p];w>Math.PI?w-=2*Math.PI:w<-Math.PI&&(w+=2*Math.PI),r[p]=u[l+p]+w*a}else r[p]=u[l+p]*h+u[d+p]*a;return r}function Da(e,n,t){const r=e.bindTRS&&e.bindTRS[n];if(r)return t.set(r),t;const o=e.bones[n].matrix;return t[0]=o[12],t[1]=o[13],t[2]=o[14],t[3]=0,t[4]=0,t[5]=Math.atan2(o[1],o[0]),t[6]=Math.hypot(o[0],o[1])||1,t[7]=Math.hypot(o[4],o[5])||1,t[8]=o[10]||1,t}function Zr(e,n,t,r){const o=e.bones,i=o.length;if(i===0)return null;const s=!!(r&&r.size>0);if(!e._skin||e._skin.length!==i*16){e._skin=new Float32Array(i*16),e._local=[],e._world=[],e._tmp=new Float32Array(16),e._tmp2=new Float32Array(16);for(let h=0;h<i;h++)e._local.push(new Float32Array(16)),e._world.push(new Float32Array(16))}const c=Array.isArray(t)&&t.length>0,a=[];if(c)for(const h of t){if(h.visible===!1||h.visible===0)continue;const p=e.animations.find(w=>w.id===h.animation);p&&a.push({anim:p,additive:!!h.additive,blend:typeof h.blend=="number"?h.blend:1,rate:typeof h.rate=="number"?h.rate:1})}if(a.length===0&&!c){const h=e.animations[0];if(h)a.push({anim:h,additive:!1,blend:1,rate:1});else if(!s)return null}const u=e._trsBase||(e._trsBase=new Float32Array(9)),l=e._trsAcc||(e._trsAcc=new Float32Array(9)),d=e._trsSmp||(e._trsSmp=new Float32Array(9));for(let h=0;h<i;h++){Da(e,h,u),l.set(u);let p=!1,w=0;for(const g of a){const v=g.anim.tracks[h];if(!v)continue;Oa(v,g.anim,n*g.rate,d);const b=g.blend;if(g.additive){for(let y=0;y<9;y++){let S=d[y]-u[y];y>=3&&y<=5&&(S>Math.PI?S-=2*Math.PI:S<-Math.PI&&(S+=2*Math.PI)),l[y]+=S*b}w+=b}else for(let y=0;y<9;y++)l[y]=l[y]*(1-b)+d[y]*b;p=!0}if(w>1)for(let g=0;g<9;g++)l[g]=u[g]+(l[g]-u[g])/w;const m=s?r.get(h):void 0;m&&(l[0]=m[0],l[1]=m[1],l[2]=m[2],p=!0),p?qr(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],e._local[h]):qr(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],e._local[h])}for(let h=0;h<i;h++){const p=o[h].parent;p>=0&&p<h?Ot(e._world[p],e._local[h],e._world[h]):e._world[h].set(e._local[h])}for(let h=0;h<i;h++)Ot(e._world[h],e.invBindWorld[h],e._tmp),e._skin.set(e._tmp,h*16);return e._skin}function oi(e,n){return!e||!e.invBindWorld||!(n>=0&&n<e.invBindWorld.length)?null:ri(e.invBindWorld[n])}function za(e,n){return Ot(e,n)}function ii(e,n){if(!e||!e.attachments||typeof n!="string"||n===""||!e._world)return null;for(const t of e.attachments)if(t.name===n)return t.bone<0||t.bone>=e._world.length?null:Ot(e._world[t.bone],t.matrix);return null}function si(e,n){if(!e||!e.attachments||typeof n!="string"||n==="")return null;for(const t of e.attachments){if(t.name!==n)continue;const r=oi(e,t.bone);return r?Ot(r,t.matrix):null}return null}function Kr(e,n,t){const r=e&&e.angles&&e.angles[2]||0,o=e&&e.scale?e.scale[0]:1,i=e&&e.scale?e.scale[1]:1,s=r*Math.PI/180,c=Math.cos(s),a=Math.sin(s),u=n*o,l=t*i;return[u*c-l*a,u*a+l*c]}function $a(e){const n=new Map,t=new Map;for(const i of e){if(!i||i.id===void 0||i.id===null||(n.set(i.id,i),i.parentId===void 0||i.parentId===null))continue;const s=t.get(i.parentId);s?s.push(i):t.set(i.parentId,[i])}const r=(i,s)=>{const c=t.get(i.id);if(c)for(const a of c)s.push(a),r(a,s)},o=[];for(const i of e){const s=i&&i.attachment;if(typeof s!="string"||s==="")continue;const c=n.get(i.parentId);if(!c||!c.puppet)continue;const a=si(c.puppet,s);if(!a)continue;const u=a[12],l=a[13],d=Kr(c,u,l),h=[];r(i,h),i.origin[0]+=d[0],i.origin[1]+=d[1];for(const p of h)p.origin[0]+=d[0],p.origin[1]+=d[1];o.push({layer:i,parent:c,name:s,bindX:u,bindY:l,desc:h})}for(const i of o){i.baseX=i.layer.origin[0],i.baseY=i.layer.origin[1],i.subtree=[{layer:i.layer,x:i.layer.origin[0],y:i.layer.origin[1]}];for(const s of i.desc)i.subtree.push({layer:s,x:s.origin[0],y:s.origin[1]})}return o}function ja(e,n,t){if(!e||e.length===0)return;const r=new Set,o=[];for(const s of e){const c=s.parent&&s.parent.puppet;if(!c){o.push(null);continue}if(!r.has(c)){r.add(c);const u=typeof t=="function"?t(s.parent):null;Zr(c,n,s.parent.animationLayers,u)}const a=ii(c,s.name);if(!a){o.push(null);continue}o.push(Kr(s.parent,a[12]-s.bindX,a[13]-s.bindY))}const i=new Set;for(const s of e){const c=s.subtree||[{layer:s.layer,x:s.baseX,y:s.baseY}];for(const a of c)i.has(a.layer)||(i.add(a.layer),a.layer.origin[0]=a.x,a.layer.origin[1]=a.y)}for(let s=0;s<e.length;s++){const c=e[s],a=o[s],u=c.subtree||[{layer:c.layer,x:c.baseX,y:c.baseY}];if(a)for(const l of u)l.layer.origin[0]+=a[0],l.layer.origin[1]+=a[1]}}const Wa=128,ir=24;function Va(e){const n=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)||256,t=Math.floor((n-32)/4);return Math.max(ir,Math.min(Wa,t))}const Xa=e=>`#version 300 es
|
|
141
|
+
}`,r=(u,l)=>{const p=e.createShader(u);if(e.shaderSource(p,l),e.compileShader(p),!e.getShaderParameter(p,e.COMPILE_STATUS))throw new Error("\u7C92\u5B50 shader: "+e.getShaderInfoLog(p));return p},o=e.createProgram();if(e.attachShader(o,r(e.VERTEX_SHADER,n)),e.attachShader(o,r(e.FRAGMENT_SHADER,t)),e.linkProgram(o),!e.getProgramParameter(o,e.LINK_STATUS))throw new Error("\u7C92\u5B50 shader \u94FE\u63A5\u5931\u8D25: "+e.getProgramInfoLog(o));const i=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,i),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-.5,-.5,.5,-.5,-.5,.5,.5,.5]),e.STATIC_DRAW);const s=e.createBuffer(),a=e.createVertexArray();e.bindVertexArray(a),e.bindBuffer(e.ARRAY_BUFFER,i),e.enableVertexAttribArray(0),e.vertexAttribPointer(0,2,e.FLOAT,!1,8,0),e.vertexAttribDivisor(0,0),e.bindBuffer(e.ARRAY_BUFFER,s);const c=56;return e.enableVertexAttribArray(1),e.vertexAttribPointer(1,3,e.FLOAT,!1,c,0),e.vertexAttribDivisor(1,1),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,2,e.FLOAT,!1,c,12),e.vertexAttribDivisor(2,1),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,c,20),e.vertexAttribDivisor(3,1),e.enableVertexAttribArray(4),e.vertexAttribPointer(4,3,e.FLOAT,!1,c,36),e.vertexAttribDivisor(4,1),e.enableVertexAttribArray(5),e.vertexAttribPointer(5,2,e.FLOAT,!1,c,48),e.vertexAttribDivisor(5,1),e.bindVertexArray(null),{prog:{prog:o,uniTex:e.getUniformLocation(o,"u_tex"),uniNormal:e.getUniformLocation(o,"u_normal"),uniScene:e.getUniformLocation(o,"u_scene"),uniRefract:e.getUniformLocation(o,"u_refract"),uniSampleScene:e.getUniformLocation(o,"u_sampleScene"),uniResolution:e.getUniformLocation(o,"u_resolution"),uniRefractScale:e.getUniformLocation(o,"u_refractScale"),uniMvp:e.getUniformLocation(o,"u_mvp"),uniFrameCount:e.getUniformLocation(o,"u_frameCount"),uniFrames:e.getUniformLocation(o,"u_frames")},quadBuf:i,vbuf:s,vao:a}}function Jo(e){const n=e&&e.passes&&e.passes[0]&&e.passes[0].combos;return!!(n&&Number(n.REFRACT)===1)}function Ia(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/64|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<250||e[i+1]<250||e[i+2]<250||e[i+3]<250)return!1;r++}return r>0}function ei(e,n,t,r){let o=Math.abs(Number(e)||0)*(Number(n)||0);const i=Number(t)||0,s=Number(r)||0;return i>0&&(o=Math.max(i,o)),s>0&&(o=Math.min(s,o)),o}function qr(e,n){return e||n?Math.atan2(n,e)-Math.PI/2:0}function ti(e,n){return e&&e.kind==="ropetrail"?Math.max(1,n||1):1}function ni(e){if(!e||e.kind!=="ropetrail")return 1;const n=Math.round(Number(e.segments)||0);return n>=2?Math.min(32,n):8}function ri(e){if(!e||e.kind!=="ropetrail")return 0;const n=Number(e.length);return Number.isFinite(n)&&n>0?n:.2}function Yr(e){return e.life>0?e.age/e.life:0}class Oa{constructor(){this.alive=!1,this.x=this.y=this.z=0,this.vx=this.vy=this.vz=0,this.bx=this.by=this.bz=0,this.age=0,this.life=1,this.size=1,this.baseSize=1,this.rot=0,this.rotVel=0,this.r=this.g=this.b=1,this.baseR=this.baseG=this.baseB=1,this.alpha=1,this.baseAlpha=1,this.seed=0,this.frame=0,this.oscPhase=0,this.oscFreq=0,this.oscAmp=0,this.oscAPhase=0,this.oscAFreq=0,this.oscSPhase=0,this.oscSFreq=0,this.turbSpeed=0,this.turbPhase=0,this.trail=null,this.trailClock=0,this.seq=0}}class $a{constructor(n,t,r,o){this.gl=n,this.model=t||{},this.override=r||{},this.layer=o||null,this.syncLayerTransform(),this.maxCount=Math.max(1,Math.min(2e4,ne(this.model.maxcount,100))),this.simTime=0,this.paused=!1,this.texture=null,this.normalTex=null,this.material=null,this.blend="translucent",this.refract=!1,this.refractAmount=.04,this.opacityMul=1,this.lifetimeMul=1,this.visible=!0,this._ready=!1,this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null,this.sequenceMul=Math.max(1,Math.round(ne(this.model.sequencemultiplier,1))),this.animationMode=this.model.animationmode||null,this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul,this.texAspectX=1,this.texAspectY=1,this.controlPoints=(this.model.controlpoint||[]).filter(Boolean).map(i=>({id:ne(i.id,0),lockToPointer:!!i.locktopointer||(ne(i.flags,0)&1)!==0,offset:ge(i.offset),x:0,y:0,z:0})),this.pointer=null,this._followParent=null,this._followMode=null,this._followOffset=[0,0,0],this.ropeRenderer=null,this._seq=0,this._ropeOrder=[],this._ov={},this._applyOverride(),this.startTime=Math.max(0,Math.min(30,ne(this.model.starttime,0))),this._warmed=!1,this._compile()}reapplyOverride(){this._applyOverride()}_applyOverride(){this._ov={},this.opacityMul=1,this.lifetimeMul=1,this.maxCount=Math.max(1,Math.min(2e4,ne(this.model.maxcount,100)));const n=this.override||{};for(const t of Object.keys(n)){if(t==="id")continue;const r=n[t],o=r&&typeof r=="object"&&"value"in r?r.value:r;if(t==="count"){const i=ne(this.model.maxcount,100),s=Number(o),a=Number.isFinite(s)?s:1;this.maxCount=Math.max(1,Math.min(2e4,Math.round(i*a))),this._ov.countMul=a}else if(t==="alpha")this.opacityMul=Number(o),Number.isFinite(this.opacityMul)||(this.opacityMul=1);else if(t==="color"||t==="colorn"){const i=ge(o);this._ov.color=t==="colorn"?i:[i[0]/255,i[1]/255,i[2]/255]}else t==="size"?this._ov.size=Number(o)||1:t==="rate"?(this._ov.rateMul=Number(o),Number.isFinite(this._ov.rateMul)||(this._ov.rateMul=1)):t==="speed"?this._ov.speed=Number(o)||1:t==="lifetime"?this.lifetimeMul=Number(o)||1:t==="brightness"?this._ov.brightness=Number(o)||1:this._ov[t]=o}this.pool=[];for(let t=0;t<this.maxCount;t++)this.pool.push(new Oa)}_compile(){const n=this.model;this.emitters=(n.emitter||[]).map(c=>({kind:c.name==="boxrandom"?"box":"sphere",origin:ge(c.origin),directions:ge(c.directions,[1,1,1]),distanceMin:Qo(c.distancemin),distanceMax:Qo(c.distancemax),sign:c.sign?ge(c.sign):null,rate:ne(c.rate,0),audioDriven:c.audioprocessingmode!==void 0,audioBounds:ge(c.audioprocessingbounds,[0,1]),fill:c.rate===void 0&&c.instantaneous===void 0&&c.audioprocessingmode===void 0,instantaneous:ne(c.instantaneous,0),speedMin:ne(c.speedmin,0),speedMax:ne(c.speedmax,0),controlPoint:c.controlpoint!==void 0&&c.controlpoint!==null?ne(c.controlpoint,0):0,_burst:!1}));const t=n.initializer||[];this.init={life:null,size:null,color:null,alpha:null,velocity:null,rotation:null,angularVelocity:null,turbulentVelocity:null,mapAround:null};for(const c of t)switch(c.name){case"lifetimerandom":this.init.life={min:ne(c.min,1),max:ne(c.max,1),exp:ne(c.exponent,1)};break;case"sizerandom":this.init.size={min:ne(c.min,1),max:ne(c.max,1),exp:ne(c.exponent,1)};break;case"colorrandom":this.init.color={min:ge(c.min,[255,255,255]),max:ge(c.max,[255,255,255])};break;case"alpharandom":this.init.alpha={min:ne(c.min,1),max:ne(c.max,1)};break;case"velocityrandom":this.init.velocity={min:ge(c.min),max:ge(c.max)};break;case"rotationrandom":this.init.rotation={min:ge(c.min),max:ge(c.max,[0,0,0]),exp:ne(c.exponent,1)};break;case"angularvelocityrandom":this.init.angularVelocity={min:ge(c.min),max:ge(c.max),exp:ne(c.exponent,1)};break;case"mapsequencearoundcontrolpoint":this.init.mapAround={count:Math.max(1,ne(c.count,1)),bounds:ge(c.bounds,[0,1]),speedMin:ge(c.speedmin),speedMax:ge(c.speedmax,[0,0,0]),cp:ne(c.controlpoint,0)},this._mapAroundSeq=0;break;case"turbulentvelocityrandom":this.init.turbulentVelocity={scale:ne(c.scale,.1),offset:ne(c.offset,0),speedMin:ne(c.speedmin,0),speedMax:ne(c.speedmax,0),phaseMax:ne(c.phasemax,0),timeScale:ne(c.timescale,0),audioMode:ne(c.audioprocessingmode,0),audioBounds:ge(c.audioprocessingbounds,[0,1])};break}const r=n.operator||[];this.ops={movement:null,angularMovement:null,alphaFade:null,alphaChange:null,sizeChange:null,colorChange:null,turbulence:[],oscAlpha:null,oscSize:null,oscPos:null,attract:[],vortex:[],remap:[]};for(const c of r)switch(c.name){case"movement":this.ops.movement={gravity:ge(c.gravity),drag:ne(c.drag,0)};break;case"angularmovement":this.ops.angularMovement={force:ge(c.force),drag:ne(c.drag,0)};break;case"alphafade":this.ops.alphaFade={fadeIn:ne(c.fadeintime,.1),fadeOut:ne(c.fadeouttime,.9)};break;case"alphachange":this.ops.alphaChange={startTime:ne(c.starttime,0),endTime:ne(c.endtime,1),startValue:ne(c.startvalue,1),endValue:ne(c.endvalue,0)};break;case"sizechange":this.ops.sizeChange={startTime:ne(c.starttime,0),endTime:ne(c.endtime,1),startValue:ne(c.startvalue,1),endValue:ne(c.endvalue,1)};break;case"colorchange":this.ops.colorChange={startTime:ne(c.starttime,0),endTime:ne(c.endtime,1),startValue:c.startvalue!==void 0?ge(c.startvalue):null,endValue:ge(c.endvalue,[1,1,1])};break;case"turbulence":this.ops.turbulence.push({scale:ne(c.scale,.01),speedMin:ne(c.speedmin,0),speedMax:ne(c.speedmax,0),timeScale:ne(c.timescale,1),phaseMin:ne(c.phasemin,0),phaseMax:ne(c.phasemax,0),mask:c.mask!==void 0?ge(c.mask,[1,1,1]):[1,1,1]});break;case"oscillatealpha":this.ops.oscAlpha={freqMin:ne(c.frequencymin,ne(c.frequencymax,1)),freqMax:ne(c.frequencymax,1),scaleMin:ne(c.scalemin,0),scaleMax:ne(c.scalemax,1),phaseMax:ne(c.phasemax,dt)};break;case"oscillatesize":this.ops.oscSize={freqMin:ne(c.frequencymin,ne(c.frequencymax,1)),freqMax:ne(c.frequencymax,ne(c.frequencymin,1)),scaleMin:ne(c.scalemin,1),scaleMax:ne(c.scalemax,1),phaseMax:ne(c.phasemax,dt)};break;case"oscillateposition":this.ops.oscPos={freqMin:ne(c.frequencymin,ne(c.frequencymax,.5)),freqMax:ne(c.frequencymax,.5),scaleMin:ne(c.scalemin,0),scaleMax:ne(c.scalemax,1),phaseMin:ne(c.phasemin,0),phaseMax:ne(c.phasemax,dt),mask:c.mask!==void 0?ge(c.mask,[1,1,0]):[1,1,0]};break;case"controlpointattract":this.ops.attract.push({cp:ne(c.controlpoint,0),origin:ge(c.origin),scale:ne(c.scale,0),threshold:ne(c.threshold,0)});break;case"vortex":this.ops.vortex.push({axis:ge(c.axis,[0,0,1]),offset:ge(c.offset),distanceInner:ne(c.distanceinner,0),distanceOuter:ne(c.distanceouter,0),speedInner:ne(c.speedinner,0),speedOuter:ne(c.speedouter,0),cp:c.controlpoint!==void 0&&c.controlpoint!==null?ne(c.controlpoint,0):0,audioMode:ne(c.audioprocessingmode,0),audioBounds:ge(c.audioprocessingbounds,[0,1])});break;case"remapvalue":this.ops.remap.push({output:c.output||"velocity",rangeMin:ge(c.outputrangemin),rangeMax:ge(c.outputrangemax),fn:c.transformfunction||"simplexnoise",inputScale:ne(c.transforminputscale,1)});break}const o=this.model.renderer,i=o==null,s=Array.isArray(o)?o:o?[o]:[];this.renderers=s.map(c=>{const u=c&&c.name||"sprite";return{kind:u,length:ne(c&&c.length,u==="spritetrail"?.1:u==="ropetrail"?.2:0),maxLength:ne(c&&c.maxlength,0),minLength:ne(c&&c.minlength,0),subdivision:ne(c&&c.subdivision,1),segments:ne(c&&c.segments,0),orientation:c&&c.orientation||null}}),i&&!this.renderers.length&&(this.renderers=[{kind:"sprite",length:0,maxLength:0,minLength:0,subdivision:1,segments:0,orientation:null}]);const a=this.renderers.find(c=>c.kind==="spritetrail"||c.kind==="ropetrail");if(this.trailCfg=a||null,this.trailSegments=1,this.trailDuration=0,this.trailSampleDt=0,a&&a.kind==="ropetrail"){const c=ni(a);this.trailSegments=c,this.trailDuration=ri(a),this.trailSampleDt=this.trailDuration/Math.max(1,c-1);for(const u of this.pool)u.trail=new Float32Array(c*3),u.trailClock=0}this.ropeRenderer=this.renderers.find(c=>c.kind==="rope")||null}setModel(n){this.model=n,this._compile()}setMaterial(n){this.material=n;const t=n&&n.passes&&n.passes[0];this.blend=t&&t.blending||"translucent",this.refract=Jo(n);const r=t&&t.constantshadervalues,o=r&&r.ui_editor_properties_refract_amount,i=Number(o);this.refractAmount=Number.isFinite(i)?Math.min(.35,Math.max(0,i)):.04}setNormalTexture(n){this.normalTex=n||null}setTexture(n){this.texture=n,this._ready=!!n;const t=n&&n.frames,r=Array.isArray(t)?t:t&&t.list&&t.list.length?t.list:null,o=n&&n.width||r&&(t&&t.atlasWidth||r.atlasWidth)||0,i=n&&n.height||r&&(t&&t.atlasHeight||r.atlasHeight)||0;r&&o>0&&i>0?(this.texFrames=r.map(u=>({ou:u.x/o,ov:u.y/i,su:u.width/o,sv:u.height/i})),this.frameCount=this.texFrames.length):(this.texFrames=null,this.frameCount=this.sequenceMul*this.sequenceMul);let s=1,a=1;this.texFrames&&r?(s=r[0].width||1,a=r[0].height||1):n&&n.width>0&&n.height>0&&(s=n.width,a=n.height);const c=Math.max(s,a)||1;this.texAspectX=s/c,this.texAspectY=a/c,this._frameData=void 0}setVisible(n){this.visible=n}syncLayerTransform(){const n=this.layer,t=n&&n.origin?n.origin:[0,0,0],r=n&&n.scale?n.scale:[1,1,1],o=n&&n.angles?n.angles:[0,0,0];this.originX=t[0]||0,this.originY=t[1]||0,this.originZ=t[2]||0,this.scaleX=r[0]===0?1:r[0],this.scaleY=r[1]===0?1:r[1],this.angleZ=(o[2]||0)*Math.PI/180;const i=Math.abs(this.scaleX),s=Math.abs(this.scaleY);this.sysScale=Math.min(i,s)||1,this.spriteStretchX=i/this.sysScale,this.spriteStretchY=s/this.sysScale}setPointer(n,t){const r=n-this.originX,o=t-this.originY,i=Math.cos(-this.angleZ),s=Math.sin(-this.angleZ);this.pointer={x:(r*i-o*s)/(this.scaleX||1),y:(r*s+o*i)/(this.scaleY||1)}}attachFollow(n,t,r){this._followParent=n||null,this._followMode=t==="particle"||t==="origin"?t:null;const o=r||[0,0,0];this._followOffset=[o[0]||0,o[1]||0,o[2]||0],this._syncFollow()}leaderParticle(){const n=this.pool;for(let t=0;t<n.length;t++)if(n[t].alive)return n[t];return null}localToWorld(n,t){const r=n*this.scaleX,o=t*this.scaleY,i=Math.cos(this.angleZ),s=Math.sin(this.angleZ);return[this.originX+r*i-o*s,this.originY+r*s+o*i]}_syncFollow(){const n=this._followParent,t=this._followMode;if(!n||!t)return;const r=this._followOffset;if(t==="particle"){const o=n.leaderParticle();if(!o)return;const i=n.localToWorld(o.x+r[0],o.y+r[1]);this.originX=i[0],this.originY=i[1]}else{const o=n.localToWorld(r[0],r[1]);this.originX=o[0],this.originY=o[1]}}spawn(n){const t=this.pool,r=t.length;let o=null,i=this._cursor||0;for(let p=0;p<r;p++){const f=t[(i+p)%r];if(!f.alive){o=f,this._cursor=(i+p+1)%r;break}}if(!o)return;o.alive=!0,o.age=0,o.seed=Math.random(),o.rot=0,o.rotVel=0,o.vx=o.vy=o.vz=0,o.frame=0,o.seq=this._seq++;const s=n.origin;if(n.kind==="box"){const p=n.distanceMax||[0,0,0],f=n.distanceMin;o.x=s[0]+ke(-p[0],p[0])+(f?f[0]:0),o.y=s[1]+ke(-p[1],p[1])+(f?f[1]:0),o.z=s[2]+ke(-p[2],p[2])+(f?f[2]:0)}else{const p=n.directions,f=n.distanceMin?n.distanceMin[0]:0,d=n.distanceMax?n.distanceMax[0]:0,w=Math.random()*2-1,M=Math.random()*dt,m=Math.sqrt(Math.max(0,1-w*w));let A=m*Math.cos(M),h=m*Math.sin(M),b=w;n.sign&&(n.sign[0]&&(A=Math.abs(A)*Math.sign(n.sign[0])),n.sign[1]&&(h=Math.abs(h)*Math.sign(n.sign[1])),n.sign[2]&&(b=Math.abs(b)*Math.sign(n.sign[2])));const v=ke(f,d);if(o.x=s[0]+A*v*p[0],o.y=s[1]+h*v*p[1],o.z=s[2]+b*v*p[2],n.speedMax||n.speedMin){const T=ke(n.speedMin,n.speedMax);o.vx+=A*T,o.vy+=h*T,o.vz+=b*T}}{const p=this._cpPos(n.controlPoint);if(p)o.x+=p[0],o.y+=p[1],o.z+=p[2];else{const f=this.controlPoints.find(d=>d.id===n.controlPoint);if(f&&f.lockToPointer){o.alive=!1;return}}}if(this.init.mapAround){const p=this.init.mapAround,f=this._cpPos(p.cp);if(f){const d=p.count,w=this._mapAroundSeq++,M=d>0?w%d/d:0,A=(p.bounds[0]+(p.bounds[1]-p.bounds[0])*M)*dt,h=n.distanceMin?n.distanceMin[0]:0,b=n.distanceMax?n.distanceMax[0]:0,v=b>0?b:h;o.x=f[0]+Math.cos(A)*v,o.y=f[1]+Math.sin(A)*v,o.z=f[2];const T=Math.random();o.vx+=p.speedMin[0]+(p.speedMax[0]-p.speedMin[0])*T,o.vy+=p.speedMin[1]+(p.speedMax[1]-p.speedMin[1])*T,o.vz+=p.speedMin[2]+(p.speedMax[2]-p.speedMin[2])*T}}const a=this.init,c=this._ov.speed||1,u=this._ov.size||1;if(o.life=a.life?Math.max(.001,Ko(a.life.min,a.life.max,a.life.exp)*this.lifetimeMul):1,o.baseSize=a.size?Ko(a.size.min,a.size.max,a.size.exp)*u:u,o.size=o.baseSize,a.color){const p=a.color.min,f=a.color.max,d=Math.random();o.baseR=(p[0]+(f[0]-p[0])*d)/255,o.baseG=(p[1]+(f[1]-p[1])*d)/255,o.baseB=(p[2]+(f[2]-p[2])*d)/255}else o.baseR=o.baseG=o.baseB=1;if(this._ov.color&&(o.baseR=this._ov.color[0],o.baseG=this._ov.color[1],o.baseB=this._ov.color[2]),o.r=o.baseR,o.g=o.baseG,o.b=o.baseB,o.baseAlpha=(a.alpha?ke(a.alpha.min,a.alpha.max):1)*this.opacityMul,o.alpha=o.baseAlpha,a.velocity&&(o.vx+=ke(a.velocity.min[0],a.velocity.max[0])*c,o.vy+=ke(a.velocity.min[1],a.velocity.max[1])*c,o.vz+=ke(a.velocity.min[2],a.velocity.max[2])*c),a.turbulentVelocity){const p=a.turbulentVelocity,f=p.audioMode?Hr(p.audioBounds,this._audioLevel||0):1,d=ke(p.speedMin,p.speedMax)*c*f,w=this.simTime*(p.timeScale||0),M=Gr(o.x*p.scale+p.offset,o.y*p.scale+p.offset,w+o.seed*(p.phaseMax||0),3);o.vx+=M[0]*d,o.vy+=M[1]*d,o.vz+=M[2]*d}a.rotation&&(o.rot=ke(a.rotation.min[2],a.rotation.max[2])),a.angularVelocity&&(o.rotVel=ke(a.angularVelocity.min[2],a.angularVelocity.max[2]));const l=this.ops;if(l.oscPos&&(o.oscFreq=ke(l.oscPos.freqMin,l.oscPos.freqMax),o.oscAmp=ke(l.oscPos.scaleMin,l.oscPos.scaleMax),o.oscPhase=ke(l.oscPos.phaseMin,l.oscPos.phaseMax)+o.seed*dt),l.oscAlpha&&(o.oscAFreq=ke(l.oscAlpha.freqMin,l.oscAlpha.freqMax),o.oscAPhase=Math.random()*(l.oscAlpha.phaseMax||dt)),l.oscSize&&(o.oscSFreq=ke(l.oscSize.freqMin,l.oscSize.freqMax),o.oscSPhase=Math.random()*(l.oscSize.phaseMax||dt)),l.turbulence.length){const p=l.turbulence[0];o.turbSpeed=ke(p.speedMin,p.speedMax),o.turbPhase=ke(p.phaseMin,p.phaseMax)}if(this.frameCount>1&&(o.frame=this.animationMode==="randomframe"?Math.floor(Math.random()*this.frameCount):0),o.bx=o.x,o.by=o.y,o.bz=o.z,o.trail){for(let p=0;p<o.trail.length;p+=3)o.trail[p]=o.x,o.trail[p+1]=o.y,o.trail[p+2]=o.z;o.trailClock=0}}updateParticle(n,t){if(n.age+=t,n.age>=n.life){n.alive=!1;return}const r=n.age/n.life,o=this.ops;if(o.movement&&(n.vx+=o.movement.gravity[0]*t,n.vy+=o.movement.gravity[1]*t,n.vz+=o.movement.gravity[2]*t,o.movement.drag>0)){const a=Math.exp(-o.movement.drag*t);n.vx*=a,n.vy*=a,n.vz*=a}o.angularMovement&&(n.rotVel+=(o.angularMovement.force[2]||0)*t,o.angularMovement.drag>0&&(n.rotVel*=Math.exp(-o.angularMovement.drag*t)));for(const a of o.turbulence){const c=a.timeScale||1,u=Gr(n.bx*a.scale,n.by*a.scale,this.simTime*a.scale*c+n.turbPhase,3);n.vx+=u[0]*n.turbSpeed*a.mask[0]*t,n.vy+=u[1]*n.turbSpeed*a.mask[1]*t,n.vz+=u[2]*n.turbSpeed*a.mask[2]*t}for(const a of o.attract){const c=this._cpPos(a.cp);if(!c)continue;const u=c[0]+a.origin[0]-n.x,l=c[1]+a.origin[1]-n.y,p=Math.hypot(u,l);if(p<.001||a.threshold>0&&p>a.threshold)continue;const f=a.threshold>0?1-p/a.threshold:1,d=a.scale*f*t/Math.max(1,p);n.vx+=u*d,n.vy+=l*d}for(const a of o.vortex){const c=this._cpPos(a.cp)||[0,0,0],u=n.x-(c[0]+a.offset[0]),l=n.y-(c[1]+a.offset[1]),p=Math.hypot(u,l);if(p<.001)continue;const f=a.distanceOuter-a.distanceInner,d=f>0?Math.min(1,Math.max(0,(p-a.distanceInner)/f)):0,w=a.audioMode?Hr(a.audioBounds,this._audioLevel||0):1,M=a.speedInner+(a.speedOuter-a.speedInner)*d;n.vx+=-l/p*M*t*w,n.vy+=u/p*M*t*w}for(const a of o.remap){const c=a.inputScale||1,u=Gr(n.bx*.01*c,n.by*.01*c,this.simTime*.1,a.fn==="fbmnoise"?4:2);if(a.output==="velocity")for(let l=0;l<3;l++){const p=(u[l]+1)/2,f=a.rangeMin[l]+(a.rangeMax[l]-a.rangeMin[l])*p;l===0?n.vx=f:l===1?n.vy=f:n.vz=f}else if(a.output==="speed"){const l=(u[0]+1)/2,p=a.rangeMin[0]+(a.rangeMax[0]-a.rangeMin[0])*l,f=Math.hypot(n.vx,n.vy)||1;n.vx=n.vx/f*p,n.vy=n.vy/f*p}}if(n.bx+=n.vx*t,n.by+=n.vy*t,n.bz+=n.vz*t,n.rot+=n.rotVel*t,n.x=n.bx,n.y=n.by,n.z=n.bz,o.oscPos){const a=this.simTime*n.oscFreq*dt+n.oscPhase,c=o.oscPos.mask;n.x+=Math.sin(a)*n.oscAmp*c[0],n.y+=Math.cos(a)*n.oscAmp*c[1],n.z+=Math.sin(a*.7)*n.oscAmp*c[2]}let i=n.baseSize;if(o.sizeChange){const a=o.sizeChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0;i*=a.startValue+(a.endValue-a.startValue)*u}if(o.oscSize){const a=this.simTime*n.oscSFreq*dt+n.oscSPhase,c=o.oscSize,u=(c.scaleMin+c.scaleMax)/2,l=(c.scaleMax-c.scaleMin)/2;i*=u+Math.sin(a)*l}if(n.size=i,o.colorChange){const a=o.colorChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0,l=a.startValue||[n.baseR,n.baseG,n.baseB];n.r=l[0]+(a.endValue[0]-l[0])*u,n.g=l[1]+(a.endValue[1]-l[1])*u,n.b=l[2]+(a.endValue[2]-l[2])*u}let s=n.baseAlpha;if(o.alphaFade){const a=o.alphaFade.fadeIn,c=o.alphaFade.fadeOut;a>0&&r<a&&(s*=r/a),c<1&&r>c&&(s*=Math.max(0,(1-r)/(1-c)))}else o.alphaChange||(r<.1?s*=r/.1:r>.85&&(s*=(1-r)/.15));if(o.alphaChange){const a=o.alphaChange,c=a.endTime-a.startTime,u=c>0?Math.min(1,Math.max(0,(r-a.startTime)/c)):r>=a.startTime?1:0;s*=a.startValue+(a.endValue-a.startValue)*u}if(o.oscAlpha){const a=this.simTime*n.oscAFreq*dt+n.oscAPhase,c=o.oscAlpha,u=(c.scaleMin+c.scaleMax)/2,l=(c.scaleMax-c.scaleMin)/2;s*=u+Math.sin(a)*l}if(n.alpha=Math.max(0,s),this.frameCount>1&&this.animationMode!=="randomframe"&&(n.frame=Math.min(this.frameCount-1,Math.floor(r*this.frameCount))),n.trail){const a=n.trail,c=this.trailSampleDt;if(c>0){n.trailClock=(n.trailClock||0)+t;let u=0;const l=this.trailSegments||8;for(;n.trailClock>=c&&u<l;){n.trailClock-=c,u++;for(let p=a.length-3;p>=3;p-=3)a[p]=a[p-3],a[p+1]=a[p-2],a[p+2]=a[p-1]}}a[0]=n.x,a[1]=n.y,a[2]=n.z}}_cpPos(n){const t=this.controlPoints.find(r=>r.id===n);return t?t.lockToPointer?this.pointer?[this.pointer.x+t.offset[0],this.pointer.y+t.offset[1],t.offset[2]]:null:t.offset:null}advance(n,t){if(!(this.paused||!this.visible)){if(this._syncFollow(),!this._warmed&&(this._warmed=!0,this.startTime>0)){const r=.03333333333333333,o=Math.min(900,Math.round(this.startTime/r));for(let i=0;i<o;i++)this._step(r)}this._step(n,t)}}_step(n,t){this.simTime+=n;const r=t&&Number.isFinite(t.level)?Math.max(0,Math.min(1,t.level)):0;this._audioLevel=r;for(const i of this.emitters){if(i.instantaneous>0&&!i._burst){i._burst=!0;for(let c=0;c<Math.min(i.instantaneous,this.maxCount);c++)this.spawn(i)}if(i.fill){const u=Math.min(this.maxCount,2048);let l=0;for(let f=0;f<this.pool.length;f++)this.pool[f].alive&&l++;let p=Math.min(u-l,512);for(;p-- >0;)this.spawn(i);continue}if(i.audioDriven){const c=Hr(i.audioBounds,r);if(i.rate>0){const u=i.rate*c*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(u>0))continue;i._accum=(i._accum||0)+u*n;let l=Math.floor(i._accum);if(l>0){i._accum-=l,l>this.maxCount&&(l=this.maxCount);for(let p=0;p<l;p++)this.spawn(i)}}else{const l=Math.round(Math.min(this.maxCount,2048)*c);let p=0;for(let d=0;d<this.pool.length;d++)this.pool[d].alive&&p++;let f=Math.min(l-p,256);for(;f-- >0;)this.spawn(i)}continue}const s=i.rate*(this._ov.rateMul!==void 0?this._ov.rateMul:1)*(this._ov.countMul!==void 0?this._ov.countMul:1);if(!(s>0))continue;i._accum=(i._accum||0)+s*n;let a=Math.floor(i._accum);if(a>0){i._accum-=a,a>this.maxCount&&(a=this.maxCount);for(let c=0;c<a;c++)this.spawn(i)}}const o=this.pool;for(let i=0;i<o.length;i++)o[i].alive&&this.updateParticle(o[i],n)}render(n,t,r,o,i){if(!this._ready||!this.visible||!this.renderers.length)return;const s=this.gl;this._prog||this._buildProgram(s);const a=this.trailCfg&&this.trailCfg.kind==="ropetrail"?this.trailCfg:null,c=this.trailCfg&&this.trailCfg.kind==="spritetrail"?this.trailCfg:null,u=this.ropeRenderer,l=ti(this.trailCfg,this.trailSegments),p=14,f=this.pool;let d=null;if(u){d=this._ropeOrder,d.length=0;for(let te=0;te<f.length;te++)f[te].alive&&d.push(f[te]);d.sort((te,X)=>te.seq-X.seq)}let w=0;if(d)w=d.length;else for(let te=0;te<f.length;te++)f[te].alive&&w++;if(w===0||u&&w<2)return;const M=u?w-1:w*l,m=M*p;(!this._data||this._data.length<m)&&(this._data=new Float32Array(Math.max(m,1024)));const A=this._data;let h=0;const b=this._ov.brightness||1,v=this.sysScale,T=this.spriteStretchX*(this.texAspectX||1),_=this.spriteStretchY*(this.texAspectY||1),F=Math.cos(this.angleZ),R=Math.sin(this.angleZ),k=this.originX,U=this.originY,V=this.scaleX,q=this.scaleY,W=(te,X)=>{const J=te*V,de=X*q;return[k+J*F-de*R,i-(U+J*R+de*F)]};if(u)for(let te=0;te+1<w;te++){const X=d[te],J=d[te+1],de=W(X.x,X.y),Se=W(J.x,J.y),Ae=Se[0]-de[0],Ie=Se[1]-de[1],Je=Math.hypot(Ae,Ie),Xe=(Math.abs(X.size)+Math.abs(J.size))*.5*v;Xe>0&&(A[h++]=(de[0]+Se[0])*.5,A[h++]=(de[1]+Se[1])*.5,A[h++]=0,A[h++]=Xe,A[h++]=Math.atan2(-Ae,Ie),A[h++]=(X.r+J.r)*.5*b,A[h++]=(X.g+J.g)*.5*b,A[h++]=(X.b+J.b)*.5*b,A[h++]=(X.alpha+J.alpha)*.5,A[h++]=1,A[h++]=Je/Xe,A[h++]=0,A[h++]=Yr(X),A[h++]=Yr(J))}for(let te=0;te<f.length&&!u;te++){const X=f[te];if(X.alive)for(let J=0;J<l;J++){let de=X.x,Se=X.y,Ae=1,Ie=1,Je=X.rot,Xe=T,Ee=_,Re,le;if(a&&X.trail){de=X.trail[J*3],Se=X.trail[J*3+1];const Pe=l>1?J/(l-1):0;Ae=1-Pe,Ie=1-Pe*.55;let Oe=0,Me=0;J+1<l?(Oe=X.trail[J*3]-X.trail[(J+1)*3],Me=X.trail[J*3+1]-X.trail[(J+1)*3+1]):J>0?(Oe=X.trail[(J-1)*3]-X.trail[J*3],Me=X.trail[(J-1)*3+1]-X.trail[J*3+1]):(Oe=X.vx,Me=X.vy);const _e=W(de,Se),$e=W(de-Oe,Se-Me),Ge=_e[0]-$e[0],ht=_e[1]-$e[1],me=Math.hypot(Ge,ht),Ct=Math.max(.001,Math.abs(X.size)*v*Ie);me>.001?(Je=qr(Ge,ht),Re=(_e[0]+$e[0])*.5,le=(_e[1]+$e[1])*.5,Ee=Math.max(_,me/Ct)):(Re=_e[0],le=_e[1])}else{const Pe=W(de,Se);Re=Pe[0],le=Pe[1]}if(c){const Pe=W(X.x,X.y);Re=Pe[0],le=Pe[1];const Oe=W(X.x+X.vx,X.y+X.vy);Je=qr(Oe[0]-Pe[0],Oe[1]-Pe[1]);const Me=ei(Math.hypot(X.vx,X.vy),c.length,c.minLength,c.maxLength);Ee=_*Me}A[h++]=Re,A[h++]=le,A[h++]=0,A[h++]=Math.abs(X.size)*v*Ie,A[h++]=Je,A[h++]=X.r*b,A[h++]=X.g*b,A[h++]=X.b*b,A[h++]=X.alpha*Ae,A[h++]=Xe,A[h++]=Ee,A[h++]=X.frame,A[h++]=0,A[h++]=1}}const Z=this._prog;s.useProgram(Z.prog),s.bindVertexArray(this._vao),s.bindBuffer(s.ARRAY_BUFFER,this._vbuf),s.bufferData(s.ARRAY_BUFFER,A.subarray(0,h),s.DYNAMIC_DRAW),s.activeTexture(s.TEXTURE0),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(Z.uniTex,0),s.uniformMatrix4fv(Z.uniMvp,!1,n);const K=this.refract&&this.normalTex&&this.normalTex.glTex;if(Z.uniRefract&&s.uniform1i(Z.uniRefract,K?1:0),K){s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.normalTex.glTex),Z.uniNormal&&s.uniform1i(Z.uniNormal,1);const te=this.blend!=="additive";if(Z.uniSampleScene&&s.uniform1i(Z.uniSampleScene,te?1:0),te){const X=s.drawingBufferWidth||t,J=s.drawingBufferHeight||r;s.bindFramebuffer(s.FRAMEBUFFER,null),s.activeTexture(s.TEXTURE2),this._sceneTex?s.bindTexture(s.TEXTURE_2D,this._sceneTex):(this._sceneTex=s.createTexture(),s.bindTexture(s.TEXTURE_2D,this._sceneTex),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE)),s.copyTexImage2D(s.TEXTURE_2D,0,s.RGB8,0,0,X,J,0),Z.uniScene&&s.uniform1i(Z.uniScene,2),Z.uniResolution&&s.uniform2f(Z.uniResolution,X,J),Z.uniRefractScale&&s.uniform1f(Z.uniRefractScale,this.refractAmount||.04)}else s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),Z.uniScene&&s.uniform1i(Z.uniScene,2)}else Z.uniNormal&&(s.activeTexture(s.TEXTURE1),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),s.uniform1i(Z.uniNormal,1),s.activeTexture(s.TEXTURE2),s.bindTexture(s.TEXTURE_2D,this.texture.glTex),Z.uniScene&&s.uniform1i(Z.uniScene,2),Z.uniSampleScene&&s.uniform1i(Z.uniSampleScene,0));const re=this._frameUniformData();re?(s.uniform1i(Z.uniFrameCount,re.count),s.uniform4fv(Z.uniFrames,re.arr)):s.uniform1i(Z.uniFrameCount,0),s.enable(s.BLEND),this.blend==="additive"?s.blendFunc(s.SRC_ALPHA,s.ONE):s.blendFunc(s.SRC_ALPHA,s.ONE_MINUS_SRC_ALPHA),s.depthMask(!1),s.drawArraysInstanced(s.TRIANGLE_STRIP,0,4,M),s.depthMask(!0),s.disable(s.BLEND),s.bindVertexArray(null)}_buildProgram(n){const t=Da(n);this._quadBuf=t.quadBuf,this._vbuf=t.vbuf,this._vao=t.vao,this._prog=t.prog}_frameUniformData(){if(this._frameData!==void 0)return this._frameData;let n=this.texFrames;if(!n&&this.sequenceMul>1){const o=this.sequenceMul;n=[];for(let i=0;i<o;i++)for(let s=0;s<o;s++)n.push({ou:s/o,ov:i/o,su:1/o,sv:1/o})}if(!n||n.length===0)return this._frameData=null,null;const t=Math.min(n.length,128),r=new Float32Array(t*4);for(let o=0;o<t;o++)r[o*4]=n[o].ou,r[o*4+1]=n[o].ov,r[o*4+2]=n[o].su,r[o*4+3]=n[o].sv;return this._frameData={count:t,arr:r},this._frameData}liveCount(){let n=0;for(const t of this.pool)t.alive&&n++;return n}dispose(){this.paused=!0;const n=this.gl;if(n){try{this._vbuf&&n.deleteBuffer(this._vbuf),this._quadBuf&&n.deleteBuffer(this._quadBuf),this._vao&&n.deleteVertexArray(this._vao),this._prog&&this._prog.prog&&n.deleteProgram(this._prog.prog),this._sceneTex&&n.deleteTexture(this._sceneTex)}catch{}this._prog=null,this._vbuf=null,this._quadBuf=null,this._vao=null,this._data=null,this._sceneTex=null}}}const ja=Object.freeze(Object.defineProperty({__proto__:null,ParticleSystem:$a,particleInstanceSegs:ti,particlePassRefract:Jo,rgbaIsBlankWhite:Ia,ropeParticleV:Yr,ropeTrailDuration:ri,ropeTrailHistoryCount:ni,spriteTrailLengthFactor:ei,spriteTrailRotation:qr},Symbol.toStringTag,{value:"Module"})),Rn=new Map,Zr=new Map;let rr=null;function za(e,n){const t=String(e);Zr.set(t,n),Rn.delete(t)}function Va(e){rr=typeof e=="function"?e:null}function Wa(){Zr.clear(),rr=null,Rn.clear()}function Ha(){return Object.keys(Bn)}function Te(e,n,t){e[n]=255,e[n+1]=255,e[n+2]=255,e[n+3]=Math.round(Math.min(1,Math.max(0,t))*255)}function Fn(e,n){const{width:t,height:r,rgba:o}=e,i=Math.max(2,Math.round(Math.min(t,r)*.04));for(let s=0;s<r;s++)for(let a=0;a<t;a++){const c=Math.min(a,s,t-1-a,r-1-s);if(c>=i)continue;const u=c/i,l=(s*t+a)*4+3;o[l]=Math.round(o[l]*u)}if(n>0){let s=0;const a=t*r;for(let u=0;u<a;u++)s+=o[u*4+3];const c=s/a/255;if(c>n&&c>0){const u=n/c;for(let l=0;l<a;l++)o[l*4+3]=Math.round(o[l*4+3]*u)}}return e}function or(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}const bn=e=>e*e*(3-2*e),oi=e=>e*e*e*(e*(e*6-15)+10),Kr=(e,n,t)=>e+(n-e)*t,ae=(e,n)=>Math.exp(-(e*e)/(n*n));function Kt(e,n,t,r){const o=Math.min(e,n,t-1-e,t-1-n);return o>=r?1:o/r}function kn(e,n){const t=new Uint8Array(e*e*4),r=e/2;for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=Math.hypot((i+.5-r)/r,(o+.5-r)/r);let a=0;for(let c=0;c<n.length;c++)a+=n[c].w*ae(s,n[c].r);Te(t,(o*e+i)*4,a)}return{width:e,height:e,rgba:t}}function Et(e,n,t){return kn(e,[n,t])}function Pt(e,n,t,r,o){const i=new Uint8Array(e*e*4),s=e/2,a=Math.max(2,Math.round(e*.03));for(let c=0;c<e;c++)for(let u=0;u<e;u++){const l=(u+.5-s)/s,p=(c+.5-s)/s,f=Math.hypot(l,p),d=Math.atan2(p,l),w=Math.pow(.5+.5*Math.cos(n*d),r);let M=ae(f,o)+w*ae(f,t);M*=Kt(u,c,e,a),Te(i,(c*e+u)*4,M)}return{width:e,height:e,rgba:i}}function wt(e,n,t,r,o){const s=new Uint8Array(e*n*4);for(let a=0;a<n;a++){const c=a/(n-1),u=r?ae(c-.5,.27):bn(Math.min(1,c/.06))*Math.pow(1-c,1.35);for(let l=0;l<e;l++){const p=l/(e-1)*2-1,f=ae(p,t);Te(s,(a*e+l)*4,f*f*f*u*.55)}}return{width:e,height:n,rgba:s}}const Nn=4;function ii(e,n,t,r,o){const i=o===void 0?.85:o,s=new Uint8Array(e*n*4),a=n/Nn,c=or(335009),u=Math.tan(t*Math.PI/180),l=e/2;for(let p=0;p<Nn;p++){const f=i*(.8+c()*.35),d=r*(.85+c()*.5),w=(c()-.5)*e*.12;for(let M=0;M<a;M++){const m=M/(a-1),A=l+w+(a-1)*u/2-(a-1)*u*m,h=ae(m-.5,.27);for(let b=0;b<e;b++){const v=Math.abs(b+.5-A),_=Math.exp(-(v*v)/(d*d))*h*f;_<.004||Te(s,((p*a+M)*e+b)*4,_)}}}return{width:e,height:n,rgba:s}}function Xa(e){if(e==="particle/nature/rain1"||e==="particle/nature/rain2"){const n=[];for(let t=0;t<Nn;t++)n.push({ou:0,ov:t/Nn,su:1,sv:1/Nn});return n}return null}function Qr(e,n,t){const r=new Uint8Array(e*e*4),o=e/2;for(let i=0;i<e;i++)for(let s=0;s<e;s++){const a=Math.hypot((s-o)/o,(i-o)/o);Te(r,(i*e+s)*4,ae(a-n,t*.6)*Math.max(0,1-a))}return{width:e,height:e,rgba:r}}function si(e,n){const t={1:{r:.78,t:.048,inner:.06,hi:[[-.28,-.32,.22,.9],[.32,.36,.12,.28]]},2:{r:.7,t:.07,inner:.14,hi:[[-.2,-.28,.3,.72],[.38,.2,.14,.4]]},3:{r:.84,t:.036,inner:.04,hi:[[-.34,-.18,.16,.95],[.2,.42,.1,.22],[.04,-.08,.07,.18]]}},r=t[n]||t[1],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-i)/i,u=(s+.5-i)/i,l=Math.hypot(c,u);let p=ae(l-r.r,r.t*.85)*Math.max(0,1.05-l);l<r.r&&(p+=r.inner*ae(l,.5));for(let f=0;f<r.hi.length;f++){const d=r.hi[f];p+=d[3]*ae(Math.hypot(c-d[0],u-d[1]),d[2])}Te(o,(s*e+a)*4,p)}return Fn({width:e,height:e,rgba:o},.05)}function Un(e,n){const t=e>>1,r=new Uint8Array(e*e*4),o=n===1?[1,2,1,3]:n===2?[2,1,2,3]:[3,1,2,3];for(let i=0;i<2;i++)for(let s=0;s<2;s++){const a=si(t,o[i*2+s]);for(let c=0;c<t;c++){const u=(i*t+c)*e,l=c*t;for(let p=0;p<t;p++){const f=(u+s*t+p)*4,d=(l+p)*4;r[f]=a.rgba[d],r[f+1]=a.rgba[d+1],r[f+2]=a.rgba[d+2],r[f+3]=a.rgba[d+3]}}}return{width:e,height:e,rgba:r}}function ai(e){const n=new Uint8Array(e*e*4),t=e/2,r=[[.32,0],[1.1,.35],[2.2,-.3],[-.7,.2]];for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=i>=t?1:0,a=o>=t?1:0,c=a*2+s,u=s*t+t/2,l=a*t+t/2,p=r[c][0],f=r[c][1],d=(i+.5-u)/(t*.4),w=(o+.5-l)/(t*.4),M=Math.cos(p),m=Math.sin(p);let A=d*M+w*m;const h=-d*m+w*M;A+=f*h*.18;const b=1-Math.max(0,h)*.42,v=Math.hypot(A/(.52*b),h/.92);let T=v>=1.12?0:ae(v,.48);T=Math.min(1,T+ae(A,.07)*ae(h,.65)*T*.4),Te(n,(o*e+i)*4,T)}return Fn({width:e,height:e,rgba:n},.11)}function Ve(e,n){const t={0:{rx:.36,ry:.92,wave:0,folds:0},1:{rx:.48,ry:.86,wave:.05,folds:7},2:{rx:.4,ry:.88,wave:.08,folds:5},3:{rx:.58,ry:.72,wave:0,folds:0},5:{rx:.44,ry:.8,wave:.12,folds:9},6:{rx:.52,ry:.78,wave:.07,folds:4},7:{rx:.5,ry:.9,wave:.16,folds:3},8:{rx:.38,ry:.94,wave:.2,folds:2}},r=t[n]||t[0],o=new Uint8Array(e*e*4),i=e/2;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-i)/i,u=(s+.5-i)/i,l=Math.atan2(c,u),p=r.wave?1+r.wave*Math.sin(l*r.folds):1,f=Math.hypot(c/(r.rx*p),u/r.ry);let d=f>=1.12?0:ae(f,.5);d>0&&(d=Math.min(1,d+ae(c,.028)*ae(u,.72)*.28)),Te(o,(s*e+a)*4,d)}return Fn({width:e,height:e,rgba:o},.11)}function pt(e,n){const t=e.width,r=e.height,o=e.rgba,i=n??2.8,s=new Uint8Array(t*r*4),a=(c,u)=>{const l=c<0?0:c>=t?t-1:c,p=u<0?0:u>=r?r-1:u;return o[(p*t+l)*4+3]/255};for(let c=0;c<r;c++)for(let u=0;u<t;u++){const l=(a(u-1,c)-a(u+1,c))*i,p=(a(u,c-1)-a(u,c+1))*i,f=1/Math.hypot(l,p,1),d=(c*t+u)*4;s[d]=Math.round((l*f*.5+.5)*255),s[d+1]=Math.round((p*f*.5+.5)*255),s[d+2]=Math.round((f*.5+.5)*255),s[d+3]=255}return{width:t,height:r,rgba:s}}function ci(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,a=Math.hypot(i,s),c=a>=1?0:Math.sqrt(Math.max(0,1-a*a)),u=ae(a-.62,.11)*.55;Te(n,(r*e+o)*4,Math.min(1,c*.85+u))}return{width:e,height:e,rgba:n}}function Ga(e){const n=new Uint8Array(e*e*4),t=e/2;for(let r=0;r<e;r++)for(let o=0;o<e;o++){const i=(o+.5-t)/t,s=(r+.5-t)/t,a=Math.hypot(i,s),c=Math.atan2(s,i),u=ae(a,.38)*(.55+.45*Math.cos(c*3+a*6));Te(n,(r*e+o)*4,u)}return{width:e,height:e,rgba:n}}function li(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=Math.hypot(s,a),u=Math.atan2(a,s),l=bn(Math.max(0,Math.cos(u)*.55+.45)),p=ae(c-.68,.07)*l+.35*ae(c-.78,.12)*ae(u-.9,.55);Te(n,(o*e+i)*4,Math.min(1,p)*Kt(i,o,e,r))}return{width:e,height:e,rgba:n}}function qa(e){if(!e||e.length<16)return!1;const n=e.length/4,t=Math.max(1,n/48|0);let r=0;for(let o=0;o<n;o+=t){const i=o*4;if(e[i]<240||e[i+1]<240||e[i+2]<240)return!1;r++}return r>0}function Ya(e){return!e||!e.rgba?e:qa(e.rgba)?pt(e,2.8):e}const Za={"particle/drop":"particle/drop_normal","particle/water/rain_drops_sheet":"particle/water/rain_drops_sheet_normal","particle/bubbles/bubble1":"particle/bubbles/bubble1normal","particle/bubbles/bubble2":"particle/bubbles/bubble2_normal","particle/sharp_halo":"particle/sharp_halo_normal","particle/misc/wave":"particle/normal_splash","particle/halo":"particle/sharp_halo_normal"};function Ka(e){if(!e)return null;const n=String(e);return/normal/i.test(n)?n:Za[n]||n+"_normal"}function Qa(e){const n=String(e);return/(^|\/)normal_/.test(n)?null:/_normal$/i.test(n)?n.replace(/_normal$/i,""):/normal$/i.test(n)?n.replace(/normal$/i,""):null}function Ja(e){if(Bn[e])return Bn[e]();const n=String(e).toLowerCase();return/normal/.test(n)?Et(64,{r:.18,w:1},{r:.4,w:.2}):bi(e)()}function ui(e,n,t){const r=or(t*7919+17);let o=e;const i=[];for(let c=0;c<n;c++){const u=o*o,l=new Float32Array(u*2);for(let p=0;p<u;p++){const f=r()*Math.PI*2;l[p*2]=Math.cos(f),l[p*2+1]=Math.sin(f)}i.push({f:o,g:l,ox:c*7.31,oy:c*3.17}),o*=2}const s=(c,u,l,p,f)=>{const d=c.f,w=(u%d+d)%d,m=((l%d+d)%d*d+w)*2;return c.g[m]*p+c.g[m+1]*f},a=(c,u,l)=>{const p=(u+c.ox)*c.f,f=(l+c.oy)*c.f,d=Math.floor(p),w=Math.floor(f),M=p-d,m=f-w,A=oi(M),h=oi(m);return Kr(Kr(s(c,d,w,M,m),s(c,d+1,w,M-1,m),A),Kr(s(c,d,w+1,M,m-1),s(c,d+1,w+1,M-1,m-1),A),h)};return function(u,l,p){const f=p==null?i.length:Math.min(p,i.length);let d=1,w=0,M=0;for(let m=0;m<f;m++)w+=(a(i[m],u,l)*.5+.5)*d,M+=d,d*=.55;return w/M}}function fi(e,n,t){const{width:r,height:o,rgba:i}=e;if(r===n&&o===t)return e;const s=new Uint8Array(n*t*4);for(let a=0;a<t;a++){const c=(a+.5)/t*o-.5,u=Math.max(0,Math.min(o-1,Math.floor(c))),l=Math.max(0,Math.min(o-1,u+1)),p=c-Math.floor(c);for(let f=0;f<n;f++){const d=(f+.5)/n*r-.5,w=Math.max(0,Math.min(r-1,Math.floor(d))),M=Math.max(0,Math.min(r-1,w+1)),m=d-Math.floor(d),A=i[(u*r+w)*4+3],h=i[(u*r+M)*4+3],b=i[(l*r+w)*4+3],v=i[(l*r+M)*4+3],T=(A*(1-m)+h*m)*(1-p)+(b*(1-m)+v*m)*p;Te(s,(a*n+f)*4,T/255)}}return{width:n,height:t,rgba:s}}function Ot(e,n,t,r,o,i,s){const a=i===void 0?1:i,c=s===void 0?200:s,u=256,l=ui(n,t,r),p=new Uint8Array(u*u*4),f=u/2,d=u*u,w=new Float32Array(d);let M=1,m=0;for(let v=0;v<d;v++){const T=v%u,_=v/u|0,F=(T+.5)/u,R=(_+.5)/u,k=l(F+5.2,R+1.3,2)-.5,U=l(F+9.7,R+8.1,2)-.5,V=w[v]=l(F+k*.45,R+U*.45);V<M&&(M=V),V>m&&(m=V)}const A=m-M||1;for(let v=0;v<u;v++)for(let T=0;T<u;T++){const _=(w[v*u+T]-M)/A,F=Math.hypot((T+.5-f)/f,(v+.5-f)/f),R=Math.pow(Math.max(0,1-F),a);let k=Math.max(0,(_-(1-o))/(o||1));k=bn(Math.min(1,k))*R,Te(p,(v*u+T)*4,k)}let h=0;for(let v=0;v<d;v++)h=Math.max(h,p[v*4+3]);if(h>0&&h<c){const v=c/h;for(let T=0;T<d;T++)p[T*4+3]=Math.round(Math.min(255,p[T*4+3]*v))}const b={width:u,height:u,rgba:p};return u===e?b:fi(b,e,e)}function Jr(e,n){const t=e,r=ui(3,5,n??23),o=new Uint8Array(t*t*4),i=t*t,s=new Float32Array(i);let a=1,c=0;for(let f=0;f<i;f++){const d=f%t,w=f/t|0,M=(d+.5)/t,m=(w+.5)/t,A=r(M+2.1,m+4.7,2)-.5,h=r(M+6.3,m+1.9,2)-.5,b=s[f]=r(M+A*.28,m+h*.55);b<a&&(a=b),b>c&&(c=b)}const u=c-a||1;for(let f=0;f<t;f++)for(let d=0;d<t;d++){const w=(f+.5)/t,M=(d+.5)/t*2-1,m=.1+.52*Math.pow(w,1.25),A=(s[f*t+d]-a)/u,h=ae(M/(m||.01),.55)*ae(w-.58,.42);let b=bn(Math.min(1,Math.max(0,(A-.18)/.72)))*h;b*=w<.06?w/.06:1,Te(o,(f*t+d)*4,b)}let l=0;for(let f=0;f<i;f++)l=Math.max(l,o[f*4+3]);if(l>0&&l<220){const f=220/l;for(let d=0;d<i;d++)o[d*4+3]=Math.round(Math.min(255,o[d*4+3]*f))}const p=Fn({width:t,height:t,rgba:o},.08);return t===e?p:fi(p,e,e)}function eo(e,n,t,r){const o=new Uint8Array(e*n*4),i=e/t,s=n/r;for(let a=0;a<n;a++)for(let c=0;c<e;c++){const u=Math.floor(c/i),l=Math.floor(a/s),p=(c+.5-u*i)/i*2-1,f=(a+.5-l*s)/s*2-1,d=1-Math.max(0,f)*.45,w=Math.hypot(p/(.52*d),f/.8),M=w>=1.12?0:ae(w,.48);Te(o,(a*e+c)*4,M)}return{width:e,height:n,rgba:o}}function di(e){const n=new Uint8Array(e*e*4),t=or(7),r=[];for(let o=0;o<11;o++)r.push({x:.14+t()*.72,y:.14+t()*.72,rx:.025+t()*.03,ry:.018+t()*.024,rot:t()*Math.PI});for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5)/e,a=(o+.5)/e;let c=0;for(const u of r){const l=s-u.x,p=a-u.y,f=Math.cos(u.rot),d=Math.sin(u.rot),w=(l*f+p*d)/u.rx,M=(-l*d+p*f)/u.ry,m=ae(Math.hypot(w,M),.55);m>c&&(c=m)}Te(n,(o*e+i)*4,c)}return{width:e,height:e,rgba:n}}function ir(e,n){const t=n??19,r=or(t),o=f=>Math.min(.86,Math.max(.14,f)),i=5+t%4,s=[];let a=o(.5+(r()-.5)*.16);for(let f=0;f<=i;f++){const d=.06+f/i*.86;f>0&&(a=o(a+(r()-.5)*.32)),s.push([a,d])}const c=[];for(let f=0;f<s.length-1;f++)c.push([s[f],s[f+1],1]);const u=1+t%2;for(let f=0;f<u;f++){const d=1+(t+f*3)%Math.max(1,s.length-2),w=s[d],M=[w];let m=w[0],A=w[1];const h=2+t%2;for(let b=0;b<h;b++)m=o(m+(r()-.5)*.36),A=Math.min(.92,A+.1+r()*.08),M.push([m,A]);for(let b=0;b<M.length-1;b++)c.push([M[b],M[b+1],.45+f*.1])}const l=new Uint8Array(e*e*4),p=Math.max(2,Math.round(e*.04));for(let f=0;f<e;f++)for(let d=0;d<e;d++){const w=(d+.5)/e,M=(f+.5)/e;let m=9,A=0;for(const[b,v,T]of c){const _=v[0]-b[0],F=v[1]-b[1],R=_*_+F*F||1e-8,k=Math.max(0,Math.min(1,((w-b[0])*_+(M-b[1])*F)/R)),U=Math.hypot(w-(b[0]+_*k),M-(b[1]+F*k));U/T<m&&(m=U/T,A=T)}const h=.95*ae(m,.012)+.3*ae(m,.05)*A;Te(l,(f*e+d)*4,Math.min(1,h)*Kt(d,f,e,p))}return{width:e,height:e,rgba:l}}function to(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++)for(let o=0;o<e;o++){const i=(o+.5-e/2)/(e/2),s=(r+.5-n/2)/(n/2),a=ae(i,.34)*Math.exp(-Math.max(0,-s-.05)*4.2)*(s<.1?1:Math.max(0,1-s*4)),c=Math.hypot(i/.34,(s-.42)/.3),u=c>=1?0:ae(c,.5);Te(t,(r*e+o)*4,Math.max(a,u))}return{width:e,height:n,rgba:t}}function ec(e){return Et(e,{r:.1,w:1},{r:.3,w:.16})}function no(e,n){const t=new Uint8Array(e*n*4);for(let r=0;r<n;r++){const o=(r+.5)/n,i=bn(Math.min(1,Math.min(o/.08,(1-o)/.08))),s=ae(o-.46,.24)*i,a=.5*(1-bn(Math.min(1,Math.max(0,(o-.42)/.5)))*.6);for(let c=0;c<e;c++){const u=(c+.5-e/2)/(e/2);Te(t,(r*e+c)*4,ae(Math.abs(u)/(a||.01),.5)*s)}}return{width:e,height:n,rgba:t}}function pi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=ae(Math.hypot(s,a),.42),u=ae(Math.hypot(s-.34,a),.36),l=Math.max(0,c-u*1.08)*Kt(i,o,e,r);Te(n,(o*e+i)*4,l)}return{width:e,height:e,rgba:n}}function hi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.04));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t;let c=ae(Math.hypot(s,a),.08);for(let u=0;u<6;u++){const l=u*Math.PI/3,p=Math.cos(l),f=Math.sin(l),d=s*p+a*f,w=-s*f+a*p;if(d<0)continue;const M=Math.max(0,1.02-d/.72);c+=ae(w,.028)*ae(d,.5)*M,c+=.55*ae(w-(d-.28)*.65,.02)*ae(d-.28,.12)*M,c+=.55*ae(w+(d-.28)*.65,.02)*ae(d-.28,.12)*M,c+=.4*ae(w-(d-.48)*.7,.016)*ae(d-.48,.08)*M,c+=.4*ae(w+(d-.48)*.7,.016)*ae(d-.48,.08)*M}Te(n,(o*e+i)*4,Math.min(1,c)*Kt(i,o,e,r))}return{width:e,height:e,rgba:n}}function mi(e,n){const t=new Uint8Array(e*e*4),r=e/2,o=Math.max(2,Math.round(e*.04)),i=Math.abs(n|0)%3;for(let s=0;s<e;s++)for(let a=0;a<e;a++){const c=(a+.5-r)/r*1.55,u=(s+.5-r)/r*1.55,l=Math.abs(Math.abs(c)+Math.abs(u)-.55);let p=ae(l,.016);i===0?(p+=ae(c,.012)*ae(u,.38),p+=ae(u,.012)*ae(c,.38)):i===1?(p+=ae(c-u,.012)*ae(c+u,.36),p+=ae(c+u,.012)*ae(c-u,.36)):(p+=ae(Math.hypot(c,u)-.26,.014),p+=ae(c,.012)*ae(u,.22)),Te(t,(s*e+a)*4,Math.min(1,p)*Kt(a,s,e,o))}return Fn({width:e,height:e,rgba:t},.03)}function ro(e){let n=0;const t=String(e);for(let r=0;r<t.length;r++)n=n*31+t.charCodeAt(r)|0;return n}function gi(e){const n=new Uint8Array(e*e*4),t=e/2,r=Math.max(2,Math.round(e*.03));for(let o=0;o<e;o++)for(let i=0;i<e;i++){const s=(i+.5-t)/t,a=(o+.5-t)/t,c=Math.hypot(s,a),u=ae(c,.07)+.85*ae(s,.62)*ae(a,.045)+.22*ae(s,.92)*ae(a,.018);Te(n,(o*e+i)*4,Math.min(1,u)*Kt(i,o,e,r))}return{width:e,height:e,rgba:n}}const Bn={"particle/halo_6":()=>Et(256,{r:.14,w:1},{r:.4,w:.17}),"particle/normal_splash":()=>pt(ci(256),3.2),"particle/drop_normal":()=>pt(no(128,512),3.4),"particle/normal_ring_smooth":()=>pt(Qr(256,.55,.12),3.1),"particle/normal_pinch_rotate":()=>pt(Ga(256),2.8),"particle/water/rain_drops_sheet_normal":()=>pt(eo(256,512,2,4),3.6),"particle/bubbles/bubble1normal":()=>pt(Un(256,1),3.2),"particle/bubbles/bubble2_normal":()=>pt(Un(256,2),3.2),"particle/sharp_halo_normal":()=>pt(kn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),3.4),"particle/beam/beam_0":()=>wt(128,512,.46,!0),"particle/beam/beam_1":()=>wt(128,512,.34,!0),"particle/beam/beam_2":()=>wt(128,512,.22,!0),"particle/beam/beam_2_fade":()=>wt(128,512,.24,!1),"particle/light/light_shafts_0":()=>wt(128,512,.42,!0),"particle/light/light_shafts_1":()=>wt(128,512,.3,!0),"particle/light/light_shafts_3":()=>wt(128,512,.26,!0),"particle/light/light_shafts_5":()=>wt(128,512,.23,!0),"particle/light/light_shafts_6":()=>wt(128,512,.2,!0),"particle/nature/rosepetals":()=>ai(256),"particle/nature/leaves":()=>Ve(256,0),"particle/nature/leaves1":()=>Ve(256,1),"particle/nature/leaves2":()=>Ve(256,2),"particle/nature/leaves3":()=>Ve(256,3),"particle/nature/leaves5":()=>Ve(256,5),"particle/nature/leaves6":()=>Ve(256,6),"particle/nature/leaves7":()=>Ve(256,7),"particle/nature/leaves8":()=>Ve(256,8),"particle/nature/snow":()=>hi(256),"particle/halo":()=>Et(256,{r:.12,w:1},{r:.3,w:.15}),"particle/halo_1":()=>Et(256,{r:.1,w:1},{r:.3,w:.13}),"particle/halo_2":()=>Et(256,{r:.2,w:.9},{r:.44,w:.2}),"particle/halo_3":()=>kn(256,[{r:.045,w:1},{r:.13,w:.85},{r:.36,w:.15}]),"particle/halo_4":()=>Et(256,{r:.085,w:1},{r:.28,w:.12}),"particle/halo_5":()=>kn(256,[{r:.04,w:1},{r:.11,w:.8},{r:.34,w:.17}]),"particle/sharp_halo":()=>kn(256,[{r:.035,w:1},{r:.09,w:.45},{r:.22,w:.08}]),"particle/chromaticdot":()=>ec(128),"particle/light/flare_0":()=>Pt(256,6,.58,10,.08),"particle/light/flare_1":()=>Pt(512,4,.62,14,.07),"particle/light/flare_2":()=>gi(256),"particle/drop":()=>no(128,512),"particle/nature/rain1":()=>ii(128,512,10,1,.78),"particle/nature/rain2":()=>ii(128,512,10,1.6,.66),"particle/water/rain_drops_sheet":()=>eo(256,512,2,4),"particle/fog/fog1":()=>Ot(512,4,5,1,.4,.9,150),"particle/fog/fog2":()=>Ot(512,3,5,2,.45,.8,140),"particle/fog/fog3":()=>Ot(512,6,4,3,.36,1,150),"particle/smoke/smoke1":()=>Ot(512,3,5,7,.55,1.5,130),"particle/smoke/smoke2":()=>Ot(512,2,5,11,.6,1.7,120),"particle/smoke/smoke2light":()=>Ot(512,2,5,13,.4,1.7,110),"particle/misc/wave":()=>Qr(512,.72,.085),"particle/misc/star_0":()=>Pt(256,5,.62,8,.1),"particle/bubbles/bubble1":()=>Un(256,1),"particle/bubbles/bubble2":()=>Un(256,2),"particle/bubbles/bubble3":()=>Un(256,3),"particle/debris/debris1":()=>di(128),"particle/lightning/lightning1":()=>ir(256,3),"particle/lightning/lightning2":()=>ir(256,11),"particle/lightning/lightning3":()=>ir(256,19),"particle/fire/fire1":()=>Jr(256,23),"particle/fire/fire2":()=>Jr(256,41),"particle/star":()=>Pt(256,4,.58,12,.09),"particle/shape/circle_wind":()=>li(256),"particle/sickle":()=>pi(256),"particle/magic/glyph_4":()=>mi(256,4),"@sparkle":()=>Pt(256,4,.6,16,.08),"@star":()=>Pt(256,5,.62,8,.1),"@trail":()=>to(128,256)};function bi(e){const n=String(e).toLowerCase();if(/normal/.test(n)){const t=Qa(e);return t?()=>pt(Ja(t),2.8):()=>pt(ci(128),2.6)}return/rosepetal|petal|sakura|blossom/.test(n)?()=>ai(256):/leaf|leaves|foliage/.test(n)?/leaves8/.test(n)?()=>Ve(256,8):/leaves7/.test(n)?()=>Ve(256,7):/leaves6/.test(n)?()=>Ve(256,6):/leaves5/.test(n)?()=>Ve(256,5):/leaves3/.test(n)?()=>Ve(256,3):/leaves2/.test(n)?()=>Ve(256,2):/leaves1/.test(n)?()=>Ve(256,1):()=>Ve(256,0):/circle_wind|windcircle/.test(n)?()=>li(256):/fog|cloud|mist|vapor/.test(n)?()=>Ot(512,4,5,5,.4,.9,150):/smoke/.test(n)?()=>Ot(512,3,5,8,.55,1.5,130):/beam|shaft|ray|godray/.test(n)?()=>wt(128,512,.3,!0):/flare/.test(n)?()=>gi(256):/bubble/.test(n)?()=>si(256,1):/ring|wave/.test(n)?()=>Qr(512,.72,.085):/fire|flame|ember|ash/.test(n)?()=>Jr(256,ro(n)):/sickle|crescent|moon/.test(n)?()=>pi(256):/glyph|magic|rune/.test(n)?()=>mi(256,ro(n)):/snowflake|雪花|snow/.test(n)?()=>hi(256):/流星|meteor|shooting/.test(n)?()=>to(128,256):/star|星/.test(n)?()=>Pt(256,5,.62,8,.1):/sparkle|glint|twinkle/.test(n)?()=>Pt(256,4,.6,16,.08):/rain_drops_sheet|drops_sheet/.test(n)?()=>eo(256,512,2,4):/drop|rain/.test(n)?()=>no(128,512):/debris|dirt|rock/.test(n)?()=>di(128):/lightning|bolt|arc/.test(n)?()=>ir(256,ro(n)):/note|music/.test(n)?()=>Pt(256,4,.55,8,.12):/trail|streak/.test(n)?()=>to(128,256):()=>Et(256,{r:.12,w:1},{r:.3,w:.15})}function tc(e){if(Rn.has(e))return Rn.get(e);let n=null;const t=Zr.get(e);if(t)try{n=t()}catch{n=null}if(!n&&rr)try{n=rr(e)}catch{n=null}if(!n&&Bn[e])try{n=Bn[e]()}catch{n=null}if(!n)try{n=bi(e)()}catch{n=null}return n||(n=Et(256,{r:.12,w:1},{r:.3,w:.15})),Rn.set(e,n),n}function nc(e){return typeof e=="string"&&e.indexOf("particle/")===0}const rc=Object.freeze(Object.defineProperty({__proto__:null,buildBuiltinParticleTexture:tc,builtinParticleFrames:Xa,isBuiltinParticleTextureName:nc,listBuiltinParticleTextureNames:Ha,particleNormalNameForAlbedo:Ka,prepareParticleNormalTexture:Ya,resetParticleTextureFactories:Wa,setParticleTextureFactory:za,setParticleTextureProvider:Va},Symbol.toStringTag,{value:"Module"})),yi=Object.freeze([1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1]);function $t(e,n,t){const r=t||new Float32Array(16);for(let o=0;o<4;o++)for(let i=0;i<4;i++)r[o*4+i]=e[i]*n[o*4]+e[4+i]*n[o*4+1]+e[8+i]*n[o*4+2]+e[12+i]*n[o*4+3];return r}function vi(e){const n=[];for(let r=0;r<4;r++)n.push([e[r],e[4+r],e[8+r],e[12+r],0,0,0,0]),n[r][4+r]=1;for(let r=0;r<4;r++){let o=r;for(let a=r+1;a<4;a++)Math.abs(n[a][r])>Math.abs(n[o][r])&&(o=a);const i=n[r];n[r]=n[o],n[o]=i;const s=n[r][r];if(Math.abs(s)<1e-12)return Float32Array.from(yi);for(let a=0;a<8;a++)n[r][a]/=s;for(let a=0;a<4;a++){if(a===r)continue;const c=n[a][r];if(c!==0)for(let u=0;u<8;u++)n[a][u]-=c*n[r][u]}}const t=new Float32Array(16);for(let r=0;r<4;r++)for(let o=0;o<4;o++)t[r*4+o]=n[o][4+r];return t}function oo(e,n,t,r,o,i,s,a,c,u){const l=u||new Float32Array(16),p=Math.cos(r),f=Math.sin(r),d=Math.cos(o),w=Math.sin(o),M=Math.cos(i),m=Math.sin(i);return l[0]=M*d*s,l[1]=m*d*s,l[2]=-w*s,l[3]=0,l[4]=(M*w*f-m*p)*a,l[5]=(m*w*f+M*p)*a,l[6]=d*f*a,l[7]=0,l[8]=(M*w*p+m*f)*c,l[9]=(m*w*p-M*f)*c,l[10]=d*p*c,l[11]=0,l[12]=e,l[13]=n,l[14]=t,l[15]=1,l}function Dn(e,n){const t=[];for(;n<e.byteLength;){const o=e.getUint8(n++);if(o===0)break;t.push(o)}let r="";try{r=new TextDecoder("utf-8").decode(new Uint8Array(t))}catch{r=String.fromCharCode.apply(null,t)}return{value:r,next:n}}function sr(e,n,t=0){const r=[];for(let o=0;o<n.length;o++)r.push(n.charCodeAt(o));e:for(let o=t;o<=e.length-r.length;o++){for(let i=0;i<r.length;i++)if(e[o+i]!==r[i])continue e;return o}return-1}function oc(e){const n=new DataView(e.buffer,e.byteOffset,e.byteLength),t=String.fromCharCode.apply(null,Array.from(e.subarray(0,8)));if(!t.startsWith("MDLV"))throw new Error("\u4E0D\u662F MDL: "+t);const r=Dn(n,21),i=parseInt(t.slice(4),10)>=23?[{lenOff:32,stride:80,uv:72,bone:40,weight:56},{lenOff:32,stride:48,uv:40,bone:-1,weight:-1}]:[{lenOff:8,stride:52,uv:44,bone:12,weight:28},{lenOff:4,stride:52,uv:44,bone:12,weight:28},{lenOff:32,stride:80,uv:72,bone:40,weight:56}];let s=null,a=0,c=0;for(const K of i){const re=r.next+K.lenOff;if(re+4>e.byteLength)continue;const te=n.getUint32(re,!0);if(te>0&&te%K.stride===0&&re+4+te<=e.byteLength){s=K,a=te,c=re;break}}if(!s)throw new Error("\u9876\u70B9\u533A\u957F\u5EA6\u5F02\u5E38\uFF08"+t+"\uFF0C\u5DF2\u8BD5 stride "+i.map(K=>K.stride).join("/")+"\uFF09");const u=c+4,l=a/s.stride,p=new Float32Array(l*3),f=new Float32Array(l*2),d=new Float32Array(l*4),w=new Float32Array(l*4);for(let K=0;K<l;K++){const re=u+K*s.stride;if(p[K*3]=n.getFloat32(re,!0),p[K*3+1]=n.getFloat32(re+4,!0),p[K*3+2]=n.getFloat32(re+8,!0),f[K*2]=n.getFloat32(re+s.uv,!0),f[K*2+1]=n.getFloat32(re+s.uv+4,!0),s.bone>=0&&s.weight>=0)for(let te=0;te<4;te++)d[K*4+te]=n.getUint32(re+s.bone+te*4,!0),w[K*4+te]=n.getFloat32(re+s.weight+te*4,!0);else d[K*4]=0,w[K*4]=1}const M=n.getUint32(u+a,!0),m=u+a+4,A=l>65535&&M%4===0,h=A?M/4:M/2,b=A?new Uint32Array(h):new Uint16Array(h);if(A)for(let K=0;K<h;K++)b[K]=n.getUint32(m+K*4,!0);else for(let K=0;K<h;K++)b[K]=n.getUint16(m+K*2,!0);const v=sc(e,n),T=ac(e,n,v.length),_=lc(e,n,v),F=ic(e,n,v.length),R=[],k=[],U=[];if(v.length>0){const K=v.map((te,X)=>{const J=te.matrix,de=Math.hypot(J[0],J[1]),Se=Math.hypot(J[4],J[5]);return U[X]=Float32Array.from([J[12],J[13],J[14],0,0,Math.atan2(J[1],J[0]),de||1,Se||1,J[10]||1]),Float32Array.from(J)});for(let te=0;te<v.length;te++){const X=U[te],J=v[te].matrix;Math.hypot(X[0]-J[12],X[1]-J[13])>.001&&(K[te]=oo(X[0],X[1],X[2],X[3],X[4],X[5],X[6],X[7],X[8],new Float32Array(16)))}const re=[];for(let te=0;te<v.length;te++){const X=v[te].parent;re[te]=X>=0&&X<te?$t(re[X],K[te]):Float32Array.from(K[te])}for(let te=0;te<v.length;te++)R[te]=vi(re[te]);if(_){const te=[];for(let X=0;X<v.length;X++){const J=v[X].parent;te[X]=J>=0&&J<X?$t(te[J],_[X]):Float32Array.from(_[X])}for(let X=0;X<v.length;X++)k[X]=$t(te[X],R[X])}}let V=1/0,q=-1/0,W=1/0,Z=-1/0;for(let K=0;K<l;K++){const re=p[K*3],te=p[K*3+1];re<V&&(V=re),re>q&&(q=re),te<W&&(W=te),te>Z&&(Z=te)}return{magic:t,materialPath:r.value,vertexCount:l,positions:p,uvs:f,boneIdx:d,weights:w,indexCount:h,indexType:A?"u32":"u16",indices:b,bones:v,animations:T,animBound:cc(T,v),invBindWorld:R,bindTRS:U.length>0?U:null,attachments:F.length>0?F:null,restCorrection:k.length>0?k:null,bounds:{minX:V,maxX:q,minY:W,maxY:Z}}}function ic(e,n,t){const r=sr(e,"MDAT");if(r<0)return[];const o=n.getUint16(r+13,!0);if(o<=0||o>256)return[];const i=[];let s=r+15;for(let a=0;a<o&&!(s+2>e.length);a++){const c=n.getUint16(s,!0),u=Dn(n,s+2);if(u.next+64>e.length)break;const l=new Float32Array(16);for(let p=0;p<16;p++)l[p]=n.getFloat32(u.next+p*4,!0);c<t&&i.push({bone:c,name:u.value,matrix:l}),s=u.next+64}return i}function sc(e,n){const t=sr(e,"MDLS");if(t<0)return[];const r=n.getUint32(t+13,!0);if(r<=0||r>1024)return[];const o=[];let i=t+17;for(let s=0;s<r;s++){if(i+77>n.byteLength)return o;const a=n.getUint32(i+1,!0),c=n.getInt32(i+5,!0),u=new Float32Array(16);for(let p=0;p<16;p++)u[p]=n.getFloat32(i+13+p*4,!0);const l=Dn(n,i+13+64);o.push({id:a,parent:c>=0&&c<r?c:-1,matrix:u}),i=l.next}return o}function ac(e,n,t){const r=sr(e,"MDLA");if(r<0)return[];let o=r+9;const i=n.getUint32(o,!0);o+=4;const s=n.getUint32(o,!0);if(o+=4,s<=0||s>256)return[];const a=[];for(let c=0;c<s&&!(o+16>n.byteLength);c++){const u=n.getUint32(o,!0);o+=8;const l=Dn(n,o);o=l.next;const p=Dn(n,o);if(o=p.next,o+16>n.byteLength)break;const f=n.getFloat32(o,!0);o+=4;const d=n.getUint32(o,!0);o+=8;const w=n.getUint32(o,!0);if(o+=4,w>1024)break;const M=[];for(let m=0;m<w&&!(o+8>n.byteLength);m++){o+=4;const A=n.getUint32(o,!0);o+=4;const h=Math.floor(A/36);if(o+A>n.byteLength)break;const b=new Float32Array(h*9);for(let v=0;v<h;v++){const T=o+v*36;for(let _=0;_<9;_++)b[v*9+_]=n.getFloat32(T+_*4,!0)}o+=A,M.push({frameCount:h,keyframes:b})}if(o+=35,M.length>0&&d>0&&f>0&&a.push({id:u,name:l.value,mode:p.value,fps:f,frameCount:d,duration:d/f,tracks:M}),o>=i)break}return a}function cc(e,n){let t=0,r=0;for(const o of e)for(let i=0;i<o.tracks.length;i++){const s=o.tracks[i];if(!s)continue;const a=n[i],c=a?a.matrix[12]:0,u=a?a.matrix[13]:0,l=s.keyframes;for(let p=0;p<s.frameCount;p++){const f=Math.abs(l[p*9]-c),d=Math.abs(l[p*9+1]-u);f>t&&(t=f),d>r&&(r=d)}}return{x:t,y:r}}function lc(e,n,t){if(t.length===0)return null;const r=sr(e,"MDLE");if(r<0)return null;const o=r+8+1+4+4;if(o+t.length*64>n.byteLength)return null;const i=[];for(let s=0;s<t.length;s++){const a=new Float32Array(16);for(let c=0;c<16;c++)a[c]=n.getFloat32(o+s*64+c*4,!0);i.push(a)}return i}function uc(e,n,t,r){const o=e.frameCount;if(o===0)return r[0]=0,r[1]=0,r[2]=0,r[3]=0,r[4]=0,r[5]=0,r[6]=1,r[7]=1,r[8]=1,r;const i=t*n.fps;let s,a,c;if(n.mode==="loop"){const d=Math.max(1,o-1),w=(i%d+d)%d;s=Math.floor(w),a=(s+1)%o,c=w-s}else if(n.mode==="mirror"){const d=Math.max(1,o-1),w=d*2;let M=(i%w+w)%w;M>d&&(M=w-M),s=Math.floor(M),a=Math.min(s+1,o-1),c=M-s}else{const d=Math.min(Math.max(i,0),o-1);s=Math.floor(d),a=Math.min(s+1,o-1),c=d-s}const u=e.keyframes,l=s*9,p=a*9,f=1-c;for(let d=0;d<9;d++)if(d>=3&&d<=5){let w=u[p+d]-u[l+d];w>Math.PI?w-=2*Math.PI:w<-Math.PI&&(w+=2*Math.PI),r[d]=u[l+d]+w*c}else r[d]=u[l+d]*f+u[p+d]*c;return r}function fc(e,n,t){const r=e.bindTRS&&e.bindTRS[n];if(r)return t.set(r),t;const o=e.bones[n].matrix;return t[0]=o[12],t[1]=o[13],t[2]=o[14],t[3]=0,t[4]=0,t[5]=Math.atan2(o[1],o[0]),t[6]=Math.hypot(o[0],o[1])||1,t[7]=Math.hypot(o[4],o[5])||1,t[8]=o[10]||1,t}function io(e,n,t,r){const o=e.bones,i=o.length;if(i===0)return null;const s=!!(r&&r.size>0);if(!e._skin||e._skin.length!==i*16){e._skin=new Float32Array(i*16),e._local=[],e._world=[],e._tmp=new Float32Array(16),e._tmp2=new Float32Array(16);for(let f=0;f<i;f++)e._local.push(new Float32Array(16)),e._world.push(new Float32Array(16))}const a=Array.isArray(t)&&t.length>0,c=[];if(a)for(const f of t){if(f.visible===!1||f.visible===0)continue;const d=e.animations.find(w=>w.id===f.animation);d&&c.push({anim:d,additive:!!f.additive,blend:typeof f.blend=="number"?f.blend:1,rate:typeof f.rate=="number"?f.rate:1})}if(c.length===0&&!a){const f=e.animations[0];if(f)c.push({anim:f,additive:!1,blend:1,rate:1});else if(!s)return null}const u=e._trsBase||(e._trsBase=new Float32Array(9)),l=e._trsAcc||(e._trsAcc=new Float32Array(9)),p=e._trsSmp||(e._trsSmp=new Float32Array(9));for(let f=0;f<i;f++){fc(e,f,u),l.set(u);let d=!1,w=0;for(const m of c){const A=m.anim.tracks[f];if(!A)continue;uc(A,m.anim,n*m.rate,p);const h=m.blend;if(m.additive){for(let b=0;b<9;b++){let v=p[b]-u[b];b>=3&&b<=5&&(v>Math.PI?v-=2*Math.PI:v<-Math.PI&&(v+=2*Math.PI)),l[b]+=v*h}w+=h}else for(let b=0;b<9;b++)l[b]=l[b]*(1-h)+p[b]*h;d=!0}if(w>1)for(let m=0;m<9;m++)l[m]=u[m]+(l[m]-u[m])/w;const M=s?r.get(f):void 0;M&&(l[0]=M[0],l[1]=M[1],l[2]=M[2],d=!0),d?oo(l[0],l[1],l[2],l[3],l[4],l[5],l[6],l[7],l[8],e._local[f]):oo(u[0],u[1],u[2],u[3],u[4],u[5],u[6],u[7],u[8],e._local[f])}for(let f=0;f<i;f++){const d=o[f].parent;d>=0&&d<f?$t(e._world[d],e._local[f],e._world[f]):e._world[f].set(e._local[f])}for(let f=0;f<i;f++)$t(e._world[f],e.invBindWorld[f],e._tmp),e._skin.set(e._tmp,f*16);return e._skin}function xi(e,n){return!e||!e.invBindWorld||!(n>=0&&n<e.invBindWorld.length)?null:vi(e.invBindWorld[n])}function dc(e,n){return $t(e,n)}function wi(e,n){if(!e||!e.attachments||typeof n!="string"||n===""||!e._world)return null;for(const t of e.attachments)if(t.name===n)return t.bone<0||t.bone>=e._world.length?null:$t(e._world[t.bone],t.matrix);return null}function Mi(e,n){if(!e||!e.attachments||typeof n!="string"||n==="")return null;for(const t of e.attachments){if(t.name!==n)continue;const r=xi(e,t.bone);return r?$t(r,t.matrix):null}return null}function so(e,n,t){const r=e&&e.angles&&e.angles[2]||0,o=e&&e.scale?e.scale[0]:1,i=e&&e.scale?e.scale[1]:1,s=r*Math.PI/180,a=Math.cos(s),c=Math.sin(s),u=n*o,l=t*i;return[u*a-l*c,u*c+l*a]}function pc(e){const n=new Map,t=new Map;for(const i of e){if(!i||i.id===void 0||i.id===null||(n.set(i.id,i),i.parentId===void 0||i.parentId===null))continue;const s=t.get(i.parentId);s?s.push(i):t.set(i.parentId,[i])}const r=(i,s)=>{const a=t.get(i.id);if(a)for(const c of a)s.push(c),r(c,s)},o=[];for(const i of e){const s=i&&i.attachment;if(typeof s!="string"||s==="")continue;const a=n.get(i.parentId);if(!a||!a.puppet)continue;const c=Mi(a.puppet,s);if(!c)continue;const u=c[12],l=c[13],p=so(a,u,l),f=[];r(i,f),i.origin[0]+=p[0],i.origin[1]+=p[1];for(const d of f)d.origin[0]+=p[0],d.origin[1]+=p[1];i.parallaxDepth=a.parallaxDepth?a.parallaxDepth.slice():null;for(const d of f)d.parallaxDepth=i.parallaxDepth?i.parallaxDepth.slice():null;i.attachBindDelta=[p[0],p[1]],o.push({layer:i,parent:a,name:s,bindX:u,bindY:l,desc:f})}for(const i of o){i.baseX=i.layer.origin[0],i.baseY=i.layer.origin[1],i.subtree=[{layer:i.layer,x:i.layer.origin[0],y:i.layer.origin[1]}];for(const s of i.desc)i.subtree.push({layer:s,x:s.origin[0],y:s.origin[1]});for(const s of i.subtree)s.layer.attachBase||(s.layer.attachBase=[s.x,s.y])}return o}function hc(e,n,t){if(!e||e.length===0)return;const r=new Set,o=[];for(const a of e){const c=a.parent&&a.parent.puppet;if(!c){o.push(null);continue}if(!r.has(c)){r.add(c);const l=typeof t=="function"?t(a.parent):null;io(c,n,a.parent.animationLayers,l)}const u=wi(c,a.name);if(!u){o.push(null);continue}o.push(so(a.parent,u[12]-a.bindX,u[13]-a.bindY))}const i=a=>{const c=a.layer.attachBase;return c||[a.x,a.y]},s=new Set;for(const a of e){const c=a.subtree||[{layer:a.layer,x:a.baseX,y:a.baseY}];for(const u of c){if(s.has(u.layer))continue;s.add(u.layer);const l=i(u);u.layer.origin[0]=l[0],u.layer.origin[1]=l[1]}}for(let a=0;a<e.length;a++){const c=e[a],u=o[a],l=c.subtree||[{layer:c.layer,x:c.baseX,y:c.baseY}];if(u)for(const p of l)p.layer.origin[0]+=u[0],p.layer.origin[1]+=u[1]}}const mc=128,ar=24;function gc(e){const n=e.getParameter(e.MAX_VERTEX_UNIFORM_VECTORS)||256,t=Math.floor((n-32)/4);return Math.max(ar,Math.min(mc,t))}const bc=e=>`#version 300 es
|
|
136
142
|
in vec3 a_pos;
|
|
137
143
|
in vec2 a_uv;
|
|
138
144
|
in vec4 a_bone;
|
|
@@ -158,7 +164,7 @@ void main() {
|
|
|
158
164
|
vec4 local = total > 0.0 ? skinned / total : p;
|
|
159
165
|
gl_Position = u_mvp * vec4(local.xy, 0.0, 1.0);
|
|
160
166
|
v_uv = a_uv;
|
|
161
|
-
}`,
|
|
167
|
+
}`,yc=`#version 300 es
|
|
162
168
|
precision mediump float;
|
|
163
169
|
in vec2 v_uv;
|
|
164
170
|
uniform sampler2D u_tex;
|
|
@@ -167,12 +173,12 @@ out vec4 fragColor;
|
|
|
167
173
|
void main() {
|
|
168
174
|
vec4 t = texture(u_tex, v_uv);
|
|
169
175
|
fragColor = t * u_color;
|
|
170
|
-
}`;function
|
|
171
|
-
`);for(const S of h)d.push(...l(S));let p=!1;if(n.limitrows&&n.maxrows>0&&d.length>n.maxrows&&(d=d.slice(0,n.maxrows),p=!0,n.limituseellipsis)){let S=d[n.maxrows-1];for(;S.length>0&&t(S+"\u2026")>u;)S=S.slice(0,-1);d[n.maxrows-1]=S+"\u2026"}const w=d.map(S=>t(S)),m=d.length*c,g=n.halign||"center",v=n.valign||"center",b=v==="top"?i:v==="bottom"?Math.max(i,o-i-m):(o-m)/2;return{lines:d.map((S,_)=>{const C=w[_],N=g==="left"?i:g==="right"?Math.max(i,r-i-C):(r-C)/2;return{text:S,width:C,x:N,y:b+_*c}}),lineHeight:c,totalH:m,truncated:p,boxW:r,boxH:o}}function Za(e,n,t){const r=n.boxW,o=n.boxH,i=t.color||[1,1,1],s=t.alpha!==void 0?t.alpha:1,c=t.brightness!==void 0?t.brightness:1;e.font=t.font;try{e.letterSpacing=(t.spacing&&t.spacing[0]?t.spacing[0]:0)+"px"}catch{}if(e.textBaseline="middle",t.opaquebackground){const u=t.backgroundcolor||[0,0,0],l=t.backgroundbrightness!==void 0?t.backgroundbrightness:1;e.fillStyle=`rgba(${Math.round(u[0]*255*l)},${Math.round(u[1]*255*l)},${Math.round(u[2]*255*l)},${s})`,e.fillRect(0,0,r,o)}const a=(u,l,d)=>{e.fillStyle=d;for(const h of n.lines)e.fillText(h.text,h.x+u,h.y+n.lineHeight/2+l)};if(t.castshadow){const u=Math.max(1,(t.pointsize||24)/10);a(u,u,`rgba(0,0,0,${s*.75})`)}a(0,0,`rgba(${Math.round(i[0]*255*c)},${Math.round(i[1]*255*c)},${Math.round(i[2]*255*c)},${s})`)}const ci=/^add[A-Z]/;function li(){return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{},debug:()=>{}}}function ui(e){return new Proxy(e,{get(n,t,r){const o=Reflect.get(n,t,r);if(o==null&&typeof t=="string"&&t!=="then"){const i=()=>{};return n[t]=i,i}return o}})}function ln(e,n){return()=>{}}function fi(e,n){e.isScreensaver=!!n.isScreensaver,typeof n.isRunningInEditor=="boolean"&&(e.isRunningInEditor=n.isRunningInEditor),e.setInterval||(e.setInterval=n.setInterval||ln),e.setTimeout||(e.setTimeout=n.setTimeout||ln),e.clearTimeout||(e.clearTimeout=n.clearTimeout||(()=>{})),e.clearInterval||(e.clearInterval=n.clearInterval||(()=>{})),typeof n.openUserShortcut=="function"&&(e.openUserShortcut=n.openUserShortcut);const t=n.mediaControl||null;e.media={skipNext:()=>{if(t&&t.skipNext)return t.skipNext()},skipPrevious:()=>{if(t&&t.skipPrevious)return t.skipPrevious()},play:()=>{if(t&&t.play)return t.play()},pause:()=>{if(t&&t.pause)return t.pause()},playPause:()=>{if(t&&t.playPause)return t.playPause()},get snapshot(){return t&&t.snapshot?t.snapshot:null}};const r=n.windowTitle;Object.defineProperty(e,"windowTitle",{configurable:!0,enumerable:!0,get(){return r&&r.title?String(r.title):""}}),Object.defineProperty(e,"windowApp",{configurable:!0,enumerable:!0,get(){return r&&r.app?String(r.app):""}})}class pe{constructor(n,t,r){if(n!==null&&typeof n=="object")this.x=n.x!==void 0?n.x:n.width||0,this.y=t!==void 0?t:n.y!==void 0?n.y:n.height||0,this.z=r!==void 0?r:n.z||0;else if(t===void 0&&r===void 0){const o=Number(n)||0;this.x=o,this.y=o,this.z=o}else this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){const t=new pe(n);return new pe(this.x+t.x,this.y+t.y,this.z+t.z)}subtract(n){const t=new pe(n);return new pe(this.x-t.x,this.y-t.y,this.z-t.z)}multiply(n){return n&&typeof n=="object"?new pe(this.x*n.x,this.y*n.y,this.z*n.z):new pe(this.x*n,this.y*n,this.z*n)}divide(n){const t=(r,o)=>o===0?0:r/o;return n&&typeof n=="object"?new pe(t(this.x,n.x),t(this.y,n.y),t(this.z,n.z)):new pe(t(this.x,n),t(this.y,n),t(this.z,n))}copy(){return new pe(this.x,this.y,this.z)}mix(n,t){const r=new pe(n),o=Number(t),i=Number.isFinite(o)?o:0;return new pe(this.x+(r.x-this.x)*i,this.y+(r.y-this.y)*i,this.z+(r.z-this.z)*i)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){const n=this.length();return n===0?new pe(0,0,0):new pe(this.x/n,this.y/n,this.z/n)}dot(n){const t=new pe(n);return this.x*t.x+this.y*t.y+this.z*t.z}toString(){return this.x+" "+this.y+" "+this.z}}const di=pe;function hi(e){if(e instanceof pe||!e||typeof e!="object"||Array.isArray(e)||!("x"in e)&&!("y"in e)&&!("z"in e)||Object.getPrototypeOf(e)===pe.prototype)return e;try{Object.setPrototypeOf(e,pe.prototype)}catch{}return e}function mi(e){return e&&e.cursorWorldPosition?e:{cursorWorldPosition:new pe(0,0,0),cursorScreenPosition:new pe(0,0,0),cursorPosition:new pe(0,0,0),cursorPositionLast:new pe(0,0,0),cursorLeftDown:!1}}function Ka(e,n,t){return new pe(e||0,n||0,t||0)}function Qa(){const e={cursorWorldPosition:new pe(0,0,0),cursorScreenPosition:new pe(0,0,0),cursorPosition:new pe(0,0,0),cursorPositionLast:new pe(0,0,0),cursorLeftDown:!1};return e.update=function(n){return n&&(e.cursorWorldPosition.x=n.wx,e.cursorWorldPosition.y=n.originY!=null?n.originY:n.wy,e.cursorWorldPosition.z=0,e.cursorScreenPosition.x=n.screenX,e.cursorScreenPosition.y=n.screenY,e.cursorScreenPosition.z=0,e.cursorPosition.x=n.u,e.cursorPosition.y=n.v,e.cursorPosition.z=0,e.cursorPositionLast.x=n.lastU,e.cursorPositionLast.y=n.lastV,e.cursorPositionLast.z=0,e.cursorLeftDown=!!n.leftDown),e},e}const pi={mix:(e,n,t)=>e+(n-e)*t,lerp:(e,n,t)=>e+(n-e)*t,clamp:(e,n,t)=>Math.min(t,Math.max(n,e)),saturate:e=>Math.min(1,Math.max(0,e)),smoothstep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},smoothStep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},random:(e,n)=>e===void 0?Math.random():e+Math.random()*((n===void 0?1:n)-e),randomInt:(e,n)=>Math.floor((e||0)+Math.random()*((n===void 0?1:n)+1-(e||0))),degrees:e=>e*180/Math.PI,radians:e=>e*Math.PI/180},gi={hsv2rgb:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=((Number(n.x)||0)%1+1)%1,r=Math.min(1,Math.max(0,Number(n.y)||0)),o=Math.min(1,Math.max(0,Number(n.z)||0)),i=Math.floor(t*6),s=t*6-i,c=o*(1-r),a=o*(1-s*r),u=o*(1-(1-s)*r),d=[[o,u,c],[a,o,c],[c,o,u],[c,a,o],[u,c,o],[o,c,a]][i%6];return{x:d[0],y:d[1],z:d[2]}},rgb2hsv:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=Number(n.x)||0,r=Number(n.y)||0,o=Number(n.z)||0,i=Math.max(t,r,o),s=Math.min(t,r,o),c=i-s;let a=0;return c>0&&(i===t?a=(r-o)/c/6:i===r?a=(2+(o-t)/c)/6:a=(4+(t-r)/c)/6,a<0&&(a+=1)),{x:a,y:i===0?0:c/i,z:i}}},bi={add:(e,n)=>({x:(e.x||0)+(n.x||0),y:(e.y||0)+(n.y||0),z:(e.z||0)+(n.z||0)}),subtract:(e,n)=>({x:(e.x||0)-(n.x||0),y:(e.y||0)-(n.y||0),z:(e.z||0)-(n.z||0)}),scale:(e,n)=>({x:(e.x||0)*n,y:(e.y||0)*n,z:(e.z||0)*n}),length:e=>Math.hypot(e.x||0,e.y||0,e.z||0),dot:(e,n)=>(e.x||0)*(n.x||0)+(e.y||0)*(n.y||0)+(e.z||0)*(n.z||0),normalize:e=>{const n=Math.hypot(e.x||0,e.y||0,e.z||0)||1;return{x:(e.x||0)/n,y:(e.y||0)/n,z:(e.z||0)/n}},mix:(e,n,t)=>({x:(e.x||0)+((n.x||0)-(e.x||0))*t,y:(e.y||0)+((n.y||0)-(e.y||0))*t,z:(e.z||0)+((n.z||0)-(e.z||0))*t})},vi=Object.freeze({PLAYBACK_STOPPED:0,PLAYBACK_PLAYING:1,PLAYBACK_PAUSED:2}),sr=["mediaPropertiesChanged","mediaThumbnailChanged","mediaPlaybackChanged","mediaTimelineChanged","mediaStatusChanged","mediaLyricsChanged"],Ja=["scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent"],ec=new RegExp(`(^[ \\t]*|;|\\})[ \\t]*(?:var|let|const)[ \\t]+(?=(?:${Ja.join("|")})\\b)`,"gm"),tc={WEMath:!0,WEColor:!0,WEVector:!0};function yi(e){return typeof e!="string"?e:e.replace(/([!=])==(\s*)(['"])(-?\d+)\3/g,"$1=$2$3$4$3")}function xi(e){return yi(e).replace(/\bimport\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]\s*;?/g,(n,t,r)=>{const o=String(r);return tc[o]?t===o?"":`var ${t} = ${o};`:`var ${t} = {};`}).replace(/(^[ \t]*|;|\})[ \t]*import\s+(?:[^;'"]+\s+from\s+)?['"][^'"]*['"];?[ \t]*/gm,"$1").replace(/(^[ \t]*|;|\})[ \t]*export[ \t]+(?=(?:async[ \t]+)?function\b|(?:var|let|const)\b)/gm,"$1").replace(ec,"$1")}function Rn(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function nc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=xi(e);if(r===e&&e.indexOf("update")<0)return null;const o={};if(n&&typeof n=="object")for(const[v,b]of Object.entries(n))o[v]=Rn(b);const i=new Proxy(()=>i,{apply(){return i},get(v,b){if(b==="finish")return()=>o;if(typeof b=="string"&&ci.test(b))return y=>(y&&typeof y=="object"&&typeof y.name=="string"&&!(y.name in o)&&(o[y.name]=Rn(y.value)),i)}}),s={text:t.text!==void 0&&t.text!==null?String(t.text):"",font:t.font||"",pointsize:t.pointsize||24,color:(t.color||[1,1,1]).slice(),angles:(t.angles||[0,0,0]).slice(),scale:(t.scale||[1,1,1]).slice(),visible:t.visible!==!1,origin:Jr(t.origin||[0,0,0])},c={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:t.canvasSize||{width:1920,height:1080},screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||ln,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||ln,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};fi(c,t);const a=t.audioViews;c.registerAudioBuffers=v=>{const b=Math.max(1,Math.min(64,Math.floor(Number(v)||0)));let y=a?a.get(b):void 0;return y||(y={left:new Float32Array(b),right:new Float32Array(b),average:new Float32Array(b)},a&&a.set(b,y)),y};const u={getLayer(v){const b=t.getLayerText?t.getLayerText(String(v)):void 0;return{text:b!=null?String(b):""}},createLayer(v){return{text:"",visible:!1,color:[0,0,0],alpha:1,pointsize:t.pointsize||24,font:t.font||"",origin:Jr(t.origin||[0,0,0]),angles:[0,0,0],scale:[1,1,1]}},sortLayer:()=>{},getLayerIndex:()=>0},l=t.shared||{},d={console:li()},h=mi(t.inputView);let p;try{p=new Function("scriptProperties","engine","thisLayer","thisScene","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","MediaPlaybackEvent",`"use strict";
|
|
176
|
+
}`;function vc(e){const n=(u,l)=>{const p=e.createShader(u);if(e.shaderSource(p,l),e.compileShader(p),!e.getShaderParameter(p,e.COMPILE_STATUS))throw new Error("MDL \u7740\u8272\u5668\u7F16\u8BD1\u5931\u8D25: "+e.getShaderInfoLog(p));return p};let t=gc(e),r=null;for(;;){const u=e.createProgram();let l=!1;try{e.attachShader(u,n(e.VERTEX_SHADER,bc(t))),e.attachShader(u,n(e.FRAGMENT_SHADER,yc)),e.bindAttribLocation(u,0,"a_pos"),e.bindAttribLocation(u,1,"a_uv"),e.bindAttribLocation(u,2,"a_bone"),e.bindAttribLocation(u,3,"a_weight"),e.linkProgram(u),l=!!e.getProgramParameter(u,e.LINK_STATUS)}catch{l=!1}if(l){r=u;break}if(e.deleteProgram(u),t<=ar)throw new Error("MDL \u7740\u8272\u5668\u94FE\u63A5\u5931\u8D25\uFF08\u9AA8\u6570\u5DF2\u964D\u5230 "+ar+"\uFF09");t=Math.max(ar,t>>1)}const o=t,i={mvp:e.getUniformLocation(r,"u_mvp"),tex:e.getUniformLocation(r,"u_tex"),skin:e.getUniformLocation(r,"u_skin"),boneCount:e.getUniformLocation(r,"u_boneCount"),color:e.getUniformLocation(r,"u_color")},s=new Float32Array(o*16);for(let u=0;u<o;u++)s.set(yi,u*16);const a=new WeakMap;function c(u){let l=a.get(u);if(l)return l;const p=e.createVertexArray();e.bindVertexArray(p);const f=u.vertexCount,d=new Float32Array(f*13);for(let A=0;A<f;A++){const h=A*13;d[h]=u.positions[A*3],d[h+1]=u.positions[A*3+1],d[h+2]=u.positions[A*3+2],d[h+3]=u.uvs[A*2],d[h+4]=u.uvs[A*2+1];for(let b=0;b<4;b++)d[h+5+b]=u.boneIdx[A*4+b],d[h+9+b]=u.weights[A*4+b]}const w=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,w),e.bufferData(e.ARRAY_BUFFER,d,e.STATIC_DRAW);const M=52;e.enableVertexAttribArray(0),e.vertexAttribPointer(0,3,e.FLOAT,!1,M,0),e.enableVertexAttribArray(1),e.vertexAttribPointer(1,2,e.FLOAT,!1,M,12),e.enableVertexAttribArray(2),e.vertexAttribPointer(2,4,e.FLOAT,!1,M,20),e.enableVertexAttribArray(3),e.vertexAttribPointer(3,4,e.FLOAT,!1,M,36);const m=e.createBuffer();return e.bindBuffer(e.ELEMENT_ARRAY_BUFFER,m),e.bufferData(e.ELEMENT_ARRAY_BUFFER,u.indices,e.STATIC_DRAW),e.bindVertexArray(null),l={vao:p,vbuf:w,ibuf:m},a.set(u,l),l}return{gl:e,prog:r,maxBones:o,upload(u){c(u)},draw(u,l,p,f){const d=c(l);e.useProgram(r),e.bindVertexArray(d.vao),e.activeTexture(e.TEXTURE0);const w=p.overrideTex||(f&&f.glTex?f.glTex:f);e.bindTexture(e.TEXTURE_2D,w),e.uniform1i(i.tex,0),e.uniformMatrix4fv(i.mvp,!1,u);const M=p.color||[1,1,1,1];e.uniform4f(i.color,M[0],M[1],M[2],M[3]);const m=io(l,p.time||0,p.animLayers,p.boneOverrides),A=Math.min(l.bones.length,o);m&&A>0?(e.uniformMatrix4fv(i.skin,!1,m.subarray(0,A*16)),e.uniform1i(i.boneCount,A)):(e.uniformMatrix4fv(i.skin,!1,s),e.uniform1i(i.boneCount,0)),p.blending==="additive"?(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE,e.ONE,e.ONE)):p.blending==="normal"?e.disable(e.BLEND):(e.enable(e.BLEND),e.blendFuncSeparate(e.SRC_ALPHA,e.ONE_MINUS_SRC_ALPHA,e.ONE,e.ONE_MINUS_SRC_ALPHA));const h=l.indexType==="u32"?e.UNSIGNED_INT:e.UNSIGNED_SHORT;e.drawElements(e.TRIANGLES,l.indexCount,h,0),e.bindVertexArray(null)}}}const xc=Object.freeze(Object.defineProperty({__proto__:null,applyAttachmentBindOrigins:pc,attachmentBind:Mi,attachmentWorld:wi,bindWorldOf:xi,computeSkinMatrices:io,createMDLRenderer:vc,followAttachments:hc,mat4MulOut:dc,parentMeshToWorldDelta:so,parseMDL:oc},Symbol.toStringTag,{value:"Module"}));function _i(e,n,t){const r=Math.max(0,Number(t)||0),o=Math.max(1,Number(e)||1),i=Math.max(1,Number(n)||1);return r*2>=Math.min(o,i)?0:r}function wc(e,n,t){const r=Math.max(1,n.boxW),o=Math.max(1,n.boxH),i=_i(r,o,n.padding||0),s=n.spacing||[0,0],a=Math.max(1,n.lineHeight||(n.pointsize||24)*1.25+s[1]),c=Math.max(1,r-i*2),u=n.limitwidth&&n.maxwidth>0?Math.min(n.maxwidth,c):1/0;function l(_){if(t(_)<=u)return[_];const F=[];let R="",k=-1;for(const U of _)if(R+=U,(U===" "||U===" ")&&(k=R.length),t(R)>u&&R.length>1)for(k>0?(F.push(R.slice(0,k-1)),R=R.slice(k)):(F.push(R.slice(0,-1)),R=U),k=-1;t(R)>u&&R.length>1;)F.push(R.slice(0,-1)),R=R.slice(-1);return R!==""&&F.push(R),F.length?F:[""]}let p=[];const f=String(e??"").split(`
|
|
177
|
+
`);for(const _ of f)p.push(...l(_));let d=!1;if(n.limitrows&&n.maxrows>0&&p.length>n.maxrows&&(p=p.slice(0,n.maxrows),d=!0,n.limituseellipsis)){let _=p[n.maxrows-1];for(;_.length>0&&t(_+"\u2026")>u;)_=_.slice(0,-1);p[n.maxrows-1]=_+"\u2026"}const w=p.map(_=>t(_)),M=p.length*a,m=n.halign||"center",A=n.valign||"center",h=r/2,b=o/2,v=A==="top"?b:A==="bottom"?b-M:(o-M)/2;return{lines:p.map((_,F)=>{const R=w[F],k=m==="left"?h:m==="right"?h-R:(r-R)/2;return{text:_,width:R,x:k,y:v+F*a}}),lineHeight:a,totalH:M,truncated:d,boxW:r,boxH:o}}function Mc(e,n,t){const r=n.boxW,o=n.boxH,i=t.color||[1,1,1],s=t.alpha!==void 0?t.alpha:1,a=t.brightness!==void 0?t.brightness:1;e.font=t.font;try{e.letterSpacing=(t.spacing&&t.spacing[0]?t.spacing[0]:0)+"px"}catch{}if(e.textBaseline="middle",t.opaquebackground){const u=t.backgroundcolor||[0,0,0],l=t.backgroundbrightness!==void 0?t.backgroundbrightness:1;e.fillStyle=`rgba(${Math.round(u[0]*255*l)},${Math.round(u[1]*255*l)},${Math.round(u[2]*255*l)},${s})`,e.fillRect(0,0,r,o)}const c=(u,l,p)=>{e.fillStyle=p;for(const f of n.lines)e.fillText(f.text,f.x+u,f.y+n.lineHeight/2+l)};if(t.castshadow){const u=Math.max(1,(t.pointsize||24)/10);c(u,u,`rgba(0,0,0,${s*.75})`)}c(0,0,`rgba(${Math.round(i[0]*255*a)},${Math.round(i[1]*255*a)},${Math.round(i[2]*255*a)},${s})`)}const Ai=/^add[A-Z]/;function Ti(){return{log:()=>{},warn:()=>{},error:()=>{},info:()=>{},debug:()=>{}}}function Si(e){return new Proxy(e,{get(n,t,r){const o=Reflect.get(n,t,r);if(o==null&&typeof t=="string"&&t!=="then"){const i=()=>{};return n[t]=i,i}return o}})}function yn(e,n){return()=>{}}function Ei(e,n){e.isScreensaver=!!n.isScreensaver,typeof n.isRunningInEditor=="boolean"&&(e.isRunningInEditor=n.isRunningInEditor),e.setInterval||(e.setInterval=n.setInterval||yn),e.setTimeout||(e.setTimeout=n.setTimeout||yn),e.clearTimeout||(e.clearTimeout=n.clearTimeout||(()=>{})),e.clearInterval||(e.clearInterval=n.clearInterval||(()=>{})),typeof n.openUserShortcut=="function"&&(e.openUserShortcut=n.openUserShortcut);const t=n.mediaControl||null;e.media={skipNext:()=>{if(t&&t.skipNext)return t.skipNext()},skipPrevious:()=>{if(t&&t.skipPrevious)return t.skipPrevious()},play:()=>{if(t&&t.play)return t.play()},pause:()=>{if(t&&t.pause)return t.pause()},playPause:()=>{if(t&&t.playPause)return t.playPause()},get snapshot(){return t&&t.snapshot?t.snapshot:null}};const r=n.windowTitle;Object.defineProperty(e,"windowTitle",{configurable:!0,enumerable:!0,get(){return r&&r.title?String(r.title):""}}),Object.defineProperty(e,"windowApp",{configurable:!0,enumerable:!0,get(){return r&&r.app?String(r.app):""}})}class he{constructor(n,t,r){if(n!==null&&typeof n=="object")this.x=n.x!==void 0?n.x:n.width||0,this.y=t!==void 0?t:n.y!==void 0?n.y:n.height||0,this.z=r!==void 0?r:n.z||0;else if(t===void 0&&r===void 0){const o=Number(n)||0;this.x=o,this.y=o,this.z=o}else this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){const t=new he(n);return new he(this.x+t.x,this.y+t.y,this.z+t.z)}subtract(n){const t=new he(n);return new he(this.x-t.x,this.y-t.y,this.z-t.z)}multiply(n){return n&&typeof n=="object"?new he(this.x*n.x,this.y*n.y,this.z*n.z):new he(this.x*n,this.y*n,this.z*n)}divide(n){const t=(r,o)=>o===0?0:r/o;return n&&typeof n=="object"?new he(t(this.x,n.x),t(this.y,n.y),t(this.z,n.z)):new he(t(this.x,n),t(this.y,n),t(this.z,n))}copy(){return new he(this.x,this.y,this.z)}mix(n,t){const r=new he(n),o=Number(t),i=Number.isFinite(o)?o:0;return new he(this.x+(r.x-this.x)*i,this.y+(r.y-this.y)*i,this.z+(r.z-this.z)*i)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}normalize(){const n=this.length();return n===0?new he(0,0,0):new he(this.x/n,this.y/n,this.z/n)}dot(n){const t=new he(n);return this.x*t.x+this.y*t.y+this.z*t.z}toString(){return this.x+" "+this.y+" "+this.z}}const Pi=he;function Ci(e){if(e instanceof he||!e||typeof e!="object"||Array.isArray(e)||!("x"in e)&&!("y"in e)&&!("z"in e)||Object.getPrototypeOf(e)===he.prototype)return e;try{Object.setPrototypeOf(e,he.prototype)}catch{}return e}function Li(e){return e&&e.cursorWorldPosition?e:{cursorWorldPosition:new he(0,0,0),cursorScreenPosition:new he(0,0,0),cursorPosition:new he(0,0,0),cursorPositionLast:new he(0,0,0),cursorLeftDown:!1}}function _c(e,n,t){return new he(e||0,n||0,t||0)}function Ac(){const e={cursorWorldPosition:new he(0,0,0),cursorScreenPosition:new he(0,0,0),cursorPosition:new he(0,0,0),cursorPositionLast:new he(0,0,0),cursorLeftDown:!1};return e.update=function(n){return n&&(e.cursorWorldPosition.x=n.wx,e.cursorWorldPosition.y=n.originY!=null?n.originY:n.wy,e.cursorWorldPosition.z=0,e.cursorScreenPosition.x=n.screenX,e.cursorScreenPosition.y=n.screenY,e.cursorScreenPosition.z=0,e.cursorPosition.x=n.u,e.cursorPosition.y=n.v,e.cursorPosition.z=0,e.cursorPositionLast.x=n.lastU,e.cursorPositionLast.y=n.lastV,e.cursorPositionLast.z=0,e.cursorLeftDown=!!n.leftDown),e},e}const Ri={mix:(e,n,t)=>e+(n-e)*t,lerp:(e,n,t)=>e+(n-e)*t,clamp:(e,n,t)=>Math.min(t,Math.max(n,e)),saturate:e=>Math.min(1,Math.max(0,e)),smoothstep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},smoothStep:(e,n,t)=>{const r=Math.min(1,Math.max(0,(t-e)/(n-e||1)));return r*r*(3-2*r)},random:(e,n)=>e===void 0?Math.random():e+Math.random()*((n===void 0?1:n)-e),randomInt:(e,n)=>Math.floor((e||0)+Math.random()*((n===void 0?1:n)+1-(e||0))),degrees:e=>e*180/Math.PI,radians:e=>e*Math.PI/180},Fi={hsv2rgb:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=((Number(n.x)||0)%1+1)%1,r=Math.min(1,Math.max(0,Number(n.y)||0)),o=Math.min(1,Math.max(0,Number(n.z)||0)),i=Math.floor(t*6),s=t*6-i,a=o*(1-r),c=o*(1-s*r),u=o*(1-(1-s)*r),p=[[o,u,a],[c,o,a],[a,o,u],[a,c,o],[u,a,o],[o,a,c]][i%6];return{x:p[0],y:p[1],z:p[2]}},rgb2hsv:e=>{const n=e&&typeof e=="object"?e:{x:0,y:0,z:0},t=Number(n.x)||0,r=Number(n.y)||0,o=Number(n.z)||0,i=Math.max(t,r,o),s=Math.min(t,r,o),a=i-s;let c=0;return a>0&&(i===t?c=(r-o)/a/6:i===r?c=(2+(o-t)/a)/6:c=(4+(t-r)/a)/6,c<0&&(c+=1)),{x:c,y:i===0?0:a/i,z:i}}},ki={add:(e,n)=>({x:(e.x||0)+(n.x||0),y:(e.y||0)+(n.y||0),z:(e.z||0)+(n.z||0)}),subtract:(e,n)=>({x:(e.x||0)-(n.x||0),y:(e.y||0)-(n.y||0),z:(e.z||0)-(n.z||0)}),scale:(e,n)=>({x:(e.x||0)*n,y:(e.y||0)*n,z:(e.z||0)*n}),length:e=>Math.hypot(e.x||0,e.y||0,e.z||0),dot:(e,n)=>(e.x||0)*(n.x||0)+(e.y||0)*(n.y||0)+(e.z||0)*(n.z||0),normalize:e=>{const n=Math.hypot(e.x||0,e.y||0,e.z||0)||1;return{x:(e.x||0)/n,y:(e.y||0)/n,z:(e.z||0)/n}},mix:(e,n,t)=>({x:(e.x||0)+((n.x||0)-(e.x||0))*t,y:(e.y||0)+((n.y||0)-(e.y||0))*t,z:(e.z||0)+((n.z||0)-(e.z||0))*t})},Ni=Object.freeze({PLAYBACK_STOPPED:0,PLAYBACK_PLAYING:1,PLAYBACK_PAUSED:2}),cr=["mediaPropertiesChanged","mediaThumbnailChanged","mediaPlaybackChanged","mediaTimelineChanged","mediaStatusChanged","mediaLyricsChanged"],Tc=["scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent"],Sc=new RegExp(`(^[ \\t]*|;|\\})[ \\t]*(?:var|let|const)[ \\t]+(?=(?:${Tc.join("|")})\\b)`,"gm"),Ec={WEMath:!0,WEColor:!0,WEVector:!0};function Ui(e){return typeof e!="string"?e:e.replace(/([!=])==(\s*)(['"])(-?\d+)\3/g,"$1=$2$3$4$3")}function Bi(e){return Ui(e).replace(/\bimport\s*\*\s*as\s+(\w+)\s+from\s*['"]([^'"]+)['"]\s*;?/g,(n,t,r)=>{const o=String(r);return Ec[o]?t===o?"":`var ${t} = ${o};`:`var ${t} = {};`}).replace(/(^[ \t]*|;|\})[ \t]*import\s+(?:[^;'"]+\s+from\s+)?['"][^'"]*['"];?[ \t]*/gm,"$1").replace(/(^[ \t]*|;|\})[ \t]*export[ \t]+(?=(?:async[ \t]+)?function\b|(?:var|let|const)\b)/gm,"$1").replace(Sc,"$1")}function In(e){return e!==null&&typeof e=="object"&&"value"in e?e.value:e}function Di(e){const n=e||{width:1920,height:1080};return n.x!==void 0&&n.y!==void 0?n:{x:n.width,y:n.height,width:n.width,height:n.height}}function Pc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=Bi(e);if(r===e&&e.indexOf("update")<0)return null;const o={};if(n&&typeof n=="object")for(const[A,h]of Object.entries(n))o[A]=In(h);const i=new Proxy(()=>i,{apply(){return i},get(A,h){if(h==="finish")return()=>o;if(typeof h=="string"&&Ai.test(h))return b=>(b&&typeof b=="object"&&typeof b.name=="string"&&!(b.name in o)&&(o[b.name]=In(b.value)),i)}}),s={text:t.text!==void 0&&t.text!==null?String(t.text):"",font:t.font||"",pointsize:t.pointsize||24,color:(t.color||[1,1,1]).slice(),angles:(t.angles||[0,0,0]).slice(),scale:(t.scale||[1,1,1]).slice(),visible:t.visible!==!1,origin:ur(t.origin||[0,0,0])},a={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Di(t.canvasSize),screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||yn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||yn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};Ei(a,t);const c=t.audioViews;a.registerAudioBuffers=A=>{const h=Math.max(1,Math.min(64,Math.floor(Number(A)||0)));let b=c?c.get(h):void 0;return b||(b={left:new Float32Array(h),right:new Float32Array(h),average:new Float32Array(h)},c&&c.set(h,b)),b};const u={getLayer(A){const h=t.getLayerText?t.getLayerText(String(A)):void 0;return{text:h!=null?String(h):""}},createLayer(A){return{text:"",visible:!1,color:[0,0,0],alpha:1,pointsize:t.pointsize||24,font:t.font||"",origin:ur(t.origin||[0,0,0]),angles:[0,0,0],scale:[1,1,1]}},sortLayer:()=>{},getLayerIndex:()=>0},l=t.shared||{},p={console:Ti()},f=Li(t.inputView);let d;try{d=new Function("scriptProperties","engine","thisLayer","thisScene","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","MediaPlaybackEvent",`"use strict";
|
|
172
178
|
`+r+`
|
|
173
|
-
;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+sr.map(b=>`${b}: typeof ${b} === "function" ? ${b} : null,`).join("")+"dummy_: 0};")(o,ui(c),s,u,pi,gi,bi,i,l,d.console,void 0,d,d,d,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,pe,di,h,vi)}catch(v){return t.onError&&t.onError(v,"parse"),null}const w=!!(p&&sr.some(v=>p[v])),m=!!(p&&typeof p.applyUserProperties=="function");if(!p||!p.update&&!w&&!m)return null;const g={engine:c,thisLayer:s,scriptProperties:o,hasUpdate:!!p.update,hasCursorHook:!!(p.cursorClick||p.cursorEnter||p.cursorLeave||p.cursorDown||p.cursorUp||p.cursorMove),hasMediaHook:w,hasApplyHook:m,errCount:0,disabled:!1,init(v){if(p.init)try{p.init(v)}catch(b){g.errCount++,t.onError&&t.onError(b,"init")}},applyUserProperties(v){if(p.applyUserProperties)try{p.applyUserProperties(v||{})}catch(b){g.errCount++,t.onError&&t.onError(b,"applyUserProperties")}},callUpdate(v){if(!p.update||g.disabled)return null;const b=s.text;let y;try{y=p.update(b!==""?b:v!==void 0?v:"")}catch(S){return g.errCount++,t.onError&&t.onError(S,"update"),g.errCount>=3&&(g.disabled=!0),null}return typeof y=="string"?(s.text=y,y):typeof y=="boolean"?null:y!=null?(s.text=String(y),s.text):s.text!==b?s.text:null},callCursor(v,b){if(g.disabled)return;const y=p[v];if(typeof y=="function")try{return y(b)}catch(S){g.errCount++,t.onError&&t.onError(S,v),g.errCount>=3&&(g.disabled=!0);return}},callMedia(v,b){if(g.disabled)return;const y=p[v];if(typeof y=="function")try{return y(b)}catch(S){g.errCount++,t.onError&&t.onError(S,v),g.errCount>=3&&(g.disabled=!0);return}}};return g}function Ln(){const e={play:()=>e,pause:()=>e,stop:()=>e,setFrame:()=>e,setRate:()=>e,setBlend:()=>e,setVisible:()=>e,isPlaying:Object.assign(()=>!1,{valueOf:()=>!1,toString:()=>"false"}),get frame(){return 0},get frameCount(){return 0},get rate(){return 1}};return e}function rc(e){if(!e)return Ln();if(e.textureAnimation)return e.textureAnimation.api;const n={frame:null,playing:!0,rate:1},t={play:()=>(n.playing=!0,t),pause:()=>(n.playing=!1,t),stop:()=>(n.playing=!1,t),setFrame:r=>{const o=Number(r);return n.frame=Number.isFinite(o)?o:0,t},setRate:r=>{const o=Number(r);return Number.isFinite(o)&&(n.rate=o),t},setBlend:()=>t,setVisible:r=>(e.visible=!!r,t),isPlaying:Object.assign(()=>n.playing,{valueOf:()=>n.playing,toString:()=>String(n.playing)}),get frame(){return n.frame===null?0:n.frame},get frameCount(){return e.spriteFrameCount||0},get rate(){return n.rate}};return n.api=t,e.textureAnimation=n,t}function oc(e){if(e&&e.videoTextureApi)return e.videoTextureApi;const n=()=>e&&e.videoCtl||null,t={get duration(){const r=n(),o=r&&typeof r.duration=="function"?r.duration():0;return Number.isFinite(o)?o:0},get rate(){const r=n(),o=r&&typeof r.getRate=="function"?r.getRate():1;return Number.isFinite(o)&&o>0?o:1},set rate(r){const o=n(),i=Number(r);o&&typeof o.setRate=="function"&&Number.isFinite(i)&&o.setRate(i)},get loop(){const r=n();return r&&typeof r.getLoop=="function"?!!r.getLoop():!0},set loop(r){const o=n();o&&typeof o.setLoop=="function"&&o.setLoop(!!r)},play:()=>{const r=n();r&&r.play&&r.play()},pause:()=>{const r=n();r&&r.pause&&r.pause()},stop:()=>{const r=n();r&&r.stop&&r.stop()},isPlaying:Object.assign(()=>{const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},{valueOf(){const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},toString(){const r=n();return String(!!(r&&typeof r.isPlaying=="function"&&r.isPlaying()))}}),getCurrentTime:()=>{const r=n(),o=r&&typeof r.getCurrentTime=="function"?r.getCurrentTime():0;return Number.isFinite(o)?o:0},setCurrentTime:r=>{const o=n(),i=Number(r);o&&typeof o.setCurrentTime=="function"&&Number.isFinite(i)&&o.setCurrentTime(i)},addEndedCallback:r=>{const o=n();typeof r=="function"&&o&&typeof o.addEndedCallback=="function"&&o.addEndedCallback(r)}};return e&&(e.videoTextureApi=t),t}function ic(){const e=new Map,n=r=>e.has(String(r))?e.get(String(r)):null,t=(r,o)=>{e.set(String(r),String(o))};return{getItem:n,setItem:t,get:n,set:t,removeItem:r=>{e.delete(String(r))},remove:r=>{e.delete(String(r))},clear:()=>{e.clear()},key:r=>Array.from(e.keys())[r]??null,get length(){return e.size}}}function sc(e,n){const t=e&&e.puppet,r=t&&t.bones||null,o=r?r.length:0,i=e&&e.origin||[0,0,0],s=e&&e.scale||[1,1,1],c=s[0]||1,a=s[1]||1,u=(w,m)=>[i[0]+w*c,i[1]-m*a],l=(w,m)=>[(w-i[0])/c,-(m-i[1])/a],d=w=>{const m=n.get(w);if(m)return[m[0],m[1],m[2]];const g=r[w].matrix;return[g[12],g[13],g[14]]},h=w=>{let m=0,g=0,v=w;for(let b=0;v>=0&&v<o&&b<64;b++){const y=d(v);m+=y[0],g+=y[1],v=r[v].parent}return u(m,g)},p=w=>{const m={translation(g){if(g===void 0){const _=h(w);return new pe(_[0],_[1],0)}const v=Dt(g);let b=0,y=0;if(r[w].parent>=0){const _=h(r[w].parent),C=l(_[0],_[1]);b=C[0],y=C[1]}const S=l(v[0],v[1]);return n.set(w,[S[0]-b,S[1]-y,0]),m},rotation(){return m},scale(){return m}};return m};return{getBoneCount:()=>o,getBoneTransform:w=>{const m=Math.floor(Number(w));if(!r||!(m>=0)||m>=o){const g={translation(v){return v===void 0?new pe(0,0,0):g},rotation(){return g},scale(){return g}};return g}return p(m)},setBoneTransform:(w,m)=>{const g=Math.floor(Number(w));!r||!(g>=0)||g>=o},applyBonePhysicsImpulse:()=>{}}}function Qr(e){return{get visible(){return e?!!e.visible:!1},set visible(n){e&&(e.visible=!!n)},get name(){return e&&e.name||""},getMaterial:()=>null}}function wi(e,n){if(e==null)return null;const t=r=>{if(!r)return null;if(n&&typeof n.getSceneLayer=="function"){const o=n.getSceneLayer(String(r));if(o)return o}return n&&n.layer&&n.layer.name===r?n.layer:null};return t(typeof e=="object"?e.name:String(e))}function ac(e,n){e&&(e.visibleSelf=!1,e.visible=!1,e.destroyed=!0,n&&typeof n.recomputeVisibility=="function"&&n.recomputeVisibility())}function Mi(e,n){if(typeof e!="string"||!e||/\/workshop\//.test(e))return e;const t=n!=null&&n!==""?String(n):"";if(!t)return e;const r=e.match(/^(models|materials|shaders|particles|effects)\/(.+)$/);return r?`${r[1]}/workshop/${t}/${r[2]}`:e}function cc(e){if(typeof e!="string")return null;const n=e.match(/export\s+let\s+__workshopId\s*=\s*['"](\d+)['"]/);return n?n[1]:null}function lc(e){const n=t=>ar(t||null,e);return{getLayer(t){if(e.getSceneLayer){const r=e.getSceneLayer(String(t));if(r&&!r.destroyed)return n(r)}return n(null)},createLayer(t){if(typeof e.createSceneLayer!="function")return n(null);let r=t;if(typeof t=="string"){const i=typeof e.getWorkshopId=="function"?e.getWorkshopId():e.workshopId;r=Mi(t,i)}const o=e.createSceneLayer(r);return n(o||null)},destroyLayer(t){ac(wi(t,e),e)},sortLayer:()=>{},getLayerIndex(t){const r=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],o=t&&typeof t=="object"?t.name:String(t||""),i=r.findIndex(s=>s&&s.name===o);return i<0?0:i},enumerateLayers(){const t=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],r=[];for(const o of t)o&&!o.destroyed&&r.push(n(o));return r},getAnimation(t){if(typeof e.getSceneAnimation=="function"){const r=e.getSceneAnimation(t);if(r)return r}return Ln()},getCameraTransforms(){const t=e.cameraTransforms||{zoom:1};return{zoom:typeof t.zoom=="number"?t.zoom:1,center:t.center||null,eye:t.eye||null,parallaxAmount:typeof t.parallaxAmount=="number"?t.parallaxAmount:0}},setCameraTransforms(t){const r=e.cameraTransforms;!r||!t||typeof t!="object"||(typeof t.zoom=="number"&&Number.isFinite(t.zoom)&&t.zoom>0&&(r.zoom=t.zoom),t.center!==void 0&&(r.center=t.center),t.eye!==void 0&&(r.eye=t.eye),typeof t.parallaxAmount=="number"&&(r.parallaxAmount=t.parallaxAmount))},getInitialLayerConfig(t){return typeof e.getInitialLayerConfig=="function"?e.getInitialLayerConfig(t):wi(t,e)||null}}}function ar(e,n){const t=s=>Jr(Array.isArray(s)?s:[0,0,0]),r=n&&typeof n.getBoneOverrides=="function"&&e?n.getBoneOverrides(e):null,o={origin:t(e?e.origin:[0,0,0]),scale:t(e?e.scale:[1,1,1]),angles:dc(e),size:t(e?e.size:[0,0,0]),color:t(e?e.color:[1,1,1])},i={get name(){return e&&e.name||""},get id(){return e&&e.id||0},get visible(){const s=n&&n.targetEffect;return s?!!s.visible:e?e.visibleSelf!==void 0?!!e.visibleSelf:!!e.visible:!1},set visible(s){const c=n&&n.targetEffect;if(c){c.visible=!!s;return}e&&(e.visibleSelf=!!s,typeof n.recomputeVisibility=="function"?n.recomputeVisibility():e.visible=!!s)},get alpha(){return e&&typeof e.alpha=="number"?e.alpha:1},set alpha(s){e&&(e.alpha=Number(s)||0)},get brightness(){return e&&typeof e.brightness=="number"?e.brightness:1},set brightness(s){e&&(e.brightness=Number(s)||0)},get text(){return e&&e.text!==void 0?String(e.text):""},set text(s){e&&typeof s!="boolean"&&(e.text=s==null?"":String(s))},get pointsize(){return e&&e.textPointsize||24},set pointsize(s){e&&(e.textPointsize=Number(s)||24)},get font(){return e&&e.textFont||""},set font(s){e&&(e.textFont=String(s||""))},get alignment(){return e&&e.alignment||"center"},set alignment(s){if(!e)return;const c=String(s||"center").toLowerCase();e.alignment=c==="centre"?"center":c},...e&&e.puppet&&r?sc(e,r):{getBoneCount:()=>0,getBoneTransform:()=>{const s={translation(c){return c===void 0?new pe(0,0,0):s},rotation(){return s},scale(){return s}};return s},setBoneTransform:()=>{},applyBonePhysicsImpulse:()=>{}},getParent:()=>{if(!e||e.parentId==null)return null;const s=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById(e.parentId):null;return!s||s.destroyed?null:ar(s,n)},getChildren:()=>{const s=e&&e.childIds||[];if(!s.length)return[];const c=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById:null;if(!c)return[];const a=[];for(const u of s){const l=c(u);l&&!l.destroyed&&a.push(ar(l,n))}return a},getAnimation:s=>{const c=e&&e.animations,a=e&&e.animationList||[];return s==null||s===""?a[0]||Ln():c&&c[s]?c[s]:typeof s=="number"&&a[s]?a[s]:typeof s=="string"&&/^\d+$/.test(s)&&a[Number(s)]?a[Number(s)]:Ln()},getAnimationLayer:s=>{const c=e&&e.animations,a=e&&e.animationList||[];return c&&c[s]?c[s]:typeof s=="number"&&a[s]?a[s]:typeof s=="string"&&/^\d+$/.test(s)&&a[Number(s)]?a[Number(s)]:Ln()},getAnimationLayerCount:()=>(e&&e.animationList||[]).length,getTextureAnimation:()=>rc(e),play:()=>{e&&e.soundCtl&&e.soundCtl.play&&e.soundCtl.play(),e&&e.videoCtl&&e.videoCtl.play&&e.videoCtl.play()},pause:()=>{e&&e.soundCtl&&e.soundCtl.pause&&e.soundCtl.pause(),e&&e.videoCtl&&e.videoCtl.pause&&e.videoCtl.pause()},stop:()=>{e&&e.soundCtl&&e.soundCtl.stop&&e.soundCtl.stop(),e&&e.videoCtl&&e.videoCtl.stop&&e.videoCtl.stop()},isPlaying:Object.assign(()=>{const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||c)},{valueOf(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||c)},toString(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),c=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return String(!!(s||c))}}),get volume(){if(e&&e.soundCtl&&typeof e.soundCtl.getVolume=="function")return e.soundCtl.getVolume();const s=e&&e.soundprops&&e.soundprops.volume;return typeof s=="number"?s:1},set volume(s){const c=Number(s);if(!Number.isFinite(c)||!e)return;const a=Math.max(0,Math.min(1,c));e.soundprops&&(e.soundprops.volume=a),e.soundCtl&&typeof e.soundCtl.setVolume=="function"&&e.soundCtl.setVolume(a)},getVideoTexture:()=>oc(e),getTransformMatrix:()=>{const s=e&&e.origin||[0,0,0],c=new Float32Array(16);return c[0]=1,c[5]=1,c[10]=1,c[15]=1,c[12]=s[0]||0,c[13]=s[1]||0,c[14]=s[2]||0,{m:c}},getEffect:s=>{const c=e&&e.effects||null;if(!c||c.length===0)return Qr(null);if(typeof s=="number"||typeof s=="string"&&/^\d+$/.test(s))return Qr(c[Number(s)]||null);const a=String(s);return Qr(c.find(u=>u&&u.name===a)||null)}};Object.defineProperty(i,"angles",{enumerable:!0,get(){return o.angles},set(s){if(e&&Array.isArray(e.angles)){const c=_i(s);e.angles[0]=c[0],e.angles[1]=c[1],e.angles[2]=c[2]}}});for(const s of["origin","scale","size","color"])Object.defineProperty(i,s,{enumerable:!0,get(){if(e&&Array.isArray(e[s])){const c=e[s];o[s].x=c[0]||0,o[s].y=c[1]||0,o[s].z=c[2]||0}return o[s]},set(c){const a=Dt(c);o[s].x=a[0],o[s].y=a[1],o[s].z=a[2],e&&Array.isArray(e[s])&&s!=="size"&&(e[s][0]=a[0],e[s][1]=a[1],e[s][2]=a[2])}});return i}function uc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=xi(e),o={};if(n&&typeof n=="object")for(const[S,_]of Object.entries(n))if(_!==null&&typeof _=="object"&&typeof _.user=="string"){const C=t.userProperties?t.userProperties[_.user]:void 0;o[S]=C!==void 0?C:Rn(_)}else o[S]=Rn(_);const i=new Proxy(()=>i,{apply(){return i},get(S,_){if(_==="finish")return()=>o;if(typeof _=="string"&&ci.test(_))return C=>(C&&typeof C=="object"&&typeof C.name=="string"&&!(C.name in o)&&(o[C.name]=Rn(C.value)),i)}}),s={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:t.canvasSize||{width:1920,height:1080},screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||ln,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||ln,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};fi(s,t);const c=t.audioViews;s.registerAudioBuffers=S=>{const _=Math.max(1,Math.min(64,Math.floor(Number(S)||0)));let C=c?c.get(_):void 0;return C||(C={left:new Float32Array(_),right:new Float32Array(_),average:new Float32Array(_)},c&&c.set(_,C)),C};const a=t.shared||{},u={console:li()},l=mi(t.inputView),d=t.layer||null,h=t.workshopId!=null?t.workshopId:cc(e),p=ar(d,t),w=lc({...t,workshopId:h,getWorkshopId:()=>h});let m;try{m=new Function("scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent",`"use strict";
|
|
179
|
+
;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+cr.map(h=>`${h}: typeof ${h} === "function" ? ${h} : null,`).join("")+"dummy_: 0};")(o,Si(a),s,u,Ri,Fi,ki,i,l,p.console,void 0,p,p,p,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,he,Pi,f,Ni)}catch(A){return t.onError&&t.onError(A,"parse"),null}const w=!!(d&&cr.some(A=>d[A])),M=!!(d&&typeof d.applyUserProperties=="function");if(!d||!d.update&&!w&&!M)return null;const m={engine:a,thisLayer:s,scriptProperties:o,hasUpdate:!!d.update,hasCursorHook:!!(d.cursorClick||d.cursorEnter||d.cursorLeave||d.cursorDown||d.cursorUp||d.cursorMove),hasMediaHook:w,hasApplyHook:M,errCount:0,disabled:!1,init(A){if(d.init)try{d.init(A)}catch(h){m.errCount++,t.onError&&t.onError(h,"init")}},applyUserProperties(A){if(d.applyUserProperties)try{d.applyUserProperties(A||{})}catch(h){m.errCount++,t.onError&&t.onError(h,"applyUserProperties")}},callUpdateRaw(A){if(!(!d.update||m.disabled))try{return d.update(A)}catch(h){m.errCount++,t.onError&&t.onError(h,"update"),m.errCount>=3&&(m.disabled=!0);return}},callUpdate(A){if(!d.update||m.disabled)return null;const h=s.text;let b;try{b=d.update(h!==""?h:A!==void 0?A:"")}catch(v){return m.errCount++,t.onError&&t.onError(v,"update"),m.errCount>=3&&(m.disabled=!0),null}return typeof b=="string"?(s.text=b,b):typeof b=="boolean"?null:b!=null?(s.text=String(b),s.text):s.text!==h?s.text:null},callCursor(A,h){if(m.disabled)return;const b=d[A];if(typeof b=="function")try{return b(h)}catch(v){m.errCount++,t.onError&&t.onError(v,A),m.errCount>=3&&(m.disabled=!0);return}},callMedia(A,h){if(m.disabled)return;const b=d[A];if(typeof b=="function")try{return b(h)}catch(v){m.errCount++,t.onError&&t.onError(v,A),m.errCount>=3&&(m.disabled=!0);return}}};return m}function On(){const e={play:()=>e,pause:()=>e,stop:()=>e,setFrame:()=>e,setRate:()=>e,setBlend:()=>e,setVisible:()=>e,isPlaying:Object.assign(()=>!1,{valueOf:()=>!1,toString:()=>"false"}),get frame(){return 0},get frameCount(){return 0},get rate(){return 1}};return e}function Cc(e){if(!e)return On();if(e.textureAnimation)return e.textureAnimation.api;const n={frame:null,playing:!0,rate:1},t={play:()=>(n.playing=!0,t),pause:()=>(n.playing=!1,t),stop:()=>(n.playing=!1,t),setFrame:r=>{const o=Number(r);return n.frame=Number.isFinite(o)?o:0,t},setRate:r=>{const o=Number(r);return Number.isFinite(o)&&(n.rate=o),t},setBlend:()=>t,setVisible:r=>(e.visible=!!r,t),isPlaying:Object.assign(()=>n.playing,{valueOf:()=>n.playing,toString:()=>String(n.playing)}),get frame(){return n.frame===null?0:n.frame},get frameCount(){return e.spriteFrameCount||0},get rate(){return n.rate}};return n.api=t,e.textureAnimation=n,t}function Lc(e){if(e&&e.videoTextureApi)return e.videoTextureApi;const n=()=>e&&e.videoCtl||null,t={get duration(){const r=n(),o=r&&typeof r.duration=="function"?r.duration():0;return Number.isFinite(o)?o:0},get rate(){const r=n(),o=r&&typeof r.getRate=="function"?r.getRate():1;return Number.isFinite(o)&&o>0?o:1},set rate(r){const o=n(),i=Number(r);o&&typeof o.setRate=="function"&&Number.isFinite(i)&&o.setRate(i)},get loop(){const r=n();return r&&typeof r.getLoop=="function"?!!r.getLoop():!0},set loop(r){const o=n();o&&typeof o.setLoop=="function"&&o.setLoop(!!r)},play:()=>{const r=n();r&&r.play&&r.play()},pause:()=>{const r=n();r&&r.pause&&r.pause()},stop:()=>{const r=n();r&&r.stop&&r.stop()},isPlaying:Object.assign(()=>{const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},{valueOf(){const r=n();return!!(r&&typeof r.isPlaying=="function"&&r.isPlaying())},toString(){const r=n();return String(!!(r&&typeof r.isPlaying=="function"&&r.isPlaying()))}}),getCurrentTime:()=>{const r=n(),o=r&&typeof r.getCurrentTime=="function"?r.getCurrentTime():0;return Number.isFinite(o)?o:0},setCurrentTime:r=>{const o=n(),i=Number(r);o&&typeof o.setCurrentTime=="function"&&Number.isFinite(i)&&o.setCurrentTime(i)},addEndedCallback:r=>{const o=n();typeof r=="function"&&o&&typeof o.addEndedCallback=="function"&&o.addEndedCallback(r)}};return e&&(e.videoTextureApi=t),t}function Rc(){const e=new Map,n=r=>e.has(String(r))?e.get(String(r)):null,t=(r,o)=>{e.set(String(r),String(o))};return{getItem:n,setItem:t,get:n,set:t,removeItem:r=>{e.delete(String(r))},remove:r=>{e.delete(String(r))},clear:()=>{e.clear()},key:r=>Array.from(e.keys())[r]??null,get length(){return e.size}}}function Fc(e,n){const t=e&&e.puppet,r=t&&t.bones||null,o=r?r.length:0,i=e&&e.origin||[0,0,0],s=e&&e.scale||[1,1,1],a=s[0]||1,c=s[1]||1,u=(w,M)=>[i[0]+w*a,i[1]-M*c],l=(w,M)=>[(w-i[0])/a,-(M-i[1])/c],p=w=>{const M=n.get(w);if(M)return[M[0],M[1],M[2]];const m=r[w].matrix;return[m[12],m[13],m[14]]},f=w=>{let M=0,m=0,A=w;for(let h=0;A>=0&&A<o&&h<64;h++){const b=p(A);M+=b[0],m+=b[1],A=r[A].parent}return u(M,m)},d=w=>{const M={translation(m){if(m===void 0){const T=f(w);return new he(T[0],T[1],0)}const A=jt(m);let h=0,b=0;if(r[w].parent>=0){const T=f(r[w].parent),_=l(T[0],T[1]);h=_[0],b=_[1]}const v=l(A[0],A[1]);return n.set(w,[v[0]-h,v[1]-b,0]),M},rotation(){return M},scale(){return M}};return M};return{getBoneCount:()=>o,getBoneTransform:w=>{const M=Math.floor(Number(w));if(!r||!(M>=0)||M>=o){const m={translation(A){return A===void 0?new he(0,0,0):m},rotation(){return m},scale(){return m}};return m}return d(M)},setBoneTransform:(w,M)=>{const m=Math.floor(Number(w));!r||!(m>=0)||m>=o},applyBonePhysicsImpulse:()=>{}}}function ao(e){return{get visible(){return e?!!e.visible:!1},set visible(n){e&&(e.visible=!!n)},get name(){return e&&e.name||""},getMaterial:()=>null}}function Ii(e,n){if(e==null)return null;const t=r=>{if(!r)return null;if(n&&typeof n.getSceneLayer=="function"){const o=n.getSceneLayer(String(r));if(o)return o}return n&&n.layer&&n.layer.name===r?n.layer:null};return t(typeof e=="object"?e.name:String(e))}function kc(e,n){e&&(e.visibleSelf=!1,e.visible=!1,e.destroyed=!0,n&&typeof n.recomputeVisibility=="function"&&n.recomputeVisibility())}function Oi(e,n){if(typeof e!="string"||!e||/\/workshop\//.test(e))return e;const t=n!=null&&n!==""?String(n):"";if(!t)return e;const r=e.match(/^(models|materials|shaders|particles|effects)\/(.+)$/);return r?`${r[1]}/workshop/${t}/${r[2]}`:e}function Nc(e){if(typeof e!="string")return null;const n=e.match(/export\s+let\s+__workshopId\s*=\s*['"](\d+)['"]/);return n?n[1]:null}function Uc(e){const n=t=>lr(t||null,e);return{getLayer(t){if(e.getSceneLayer){const r=e.getSceneLayer(String(t));if(r&&!r.destroyed)return n(r)}return n(null)},createLayer(t){if(typeof e.createSceneLayer!="function")return n(null);let r=t;if(typeof t=="string"){const i=typeof e.getWorkshopId=="function"?e.getWorkshopId():e.workshopId;r=Oi(t,i)}const o=e.createSceneLayer(r);return n(o||null)},destroyLayer(t){kc(Ii(t,e),e)},sortLayer:()=>{},getLayerIndex(t){const r=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],o=t&&typeof t=="object"?t.name:String(t||""),i=r.findIndex(s=>s&&s.name===o);return i<0?0:i},enumerateLayers(){const t=typeof e.enumerateSceneLayers=="function"?e.enumerateSceneLayers():[],r=[];for(const o of t)o&&!o.destroyed&&r.push(n(o));return r},getAnimation(t){if(typeof e.getSceneAnimation=="function"){const r=e.getSceneAnimation(t);if(r)return r}return On()},getCameraTransforms(){const t=e.cameraTransforms||{zoom:1};return{zoom:typeof t.zoom=="number"?t.zoom:1,center:t.center||null,eye:t.eye||null,parallaxAmount:typeof t.parallaxAmount=="number"?t.parallaxAmount:0}},setCameraTransforms(t){const r=e.cameraTransforms;!r||!t||typeof t!="object"||(typeof t.zoom=="number"&&Number.isFinite(t.zoom)&&t.zoom>0&&(r.zoom=t.zoom),t.center!==void 0&&(r.center=t.center),t.eye!==void 0&&(r.eye=t.eye),typeof t.parallaxAmount=="number"&&(r.parallaxAmount=t.parallaxAmount))},getInitialLayerConfig(t){return typeof e.getInitialLayerConfig=="function"?e.getInitialLayerConfig(t):Ii(t,e)||null}}}function lr(e,n){const t=s=>ur(Array.isArray(s)?s:[0,0,0]),r=n&&typeof n.getBoneOverrides=="function"&&e?n.getBoneOverrides(e):null,o={origin:t(e?e.origin:[0,0,0]),scale:t(e?e.scale:[1,1,1]),angles:Ic(e),size:t(e?e.size:[0,0,0]),color:t(e?e.color:[1,1,1])},i={get name(){return e&&e.name||""},get id(){return e&&e.id||0},get visible(){const s=n&&n.targetEffect;return s?!!s.visible:e?e.visibleSelf!==void 0?!!e.visibleSelf:!!e.visible:!1},set visible(s){const a=n&&n.targetEffect;if(a){a.visible=!!s;return}e&&(e.visibleSelf=!!s,typeof n.recomputeVisibility=="function"?n.recomputeVisibility():e.visible=!!s)},get alpha(){return e&&typeof e.alpha=="number"?e.alpha:1},set alpha(s){e&&(e.alpha=Number(s)||0)},get brightness(){return e&&typeof e.brightness=="number"?e.brightness:1},set brightness(s){e&&(e.brightness=Number(s)||0)},get text(){return e&&e.text!==void 0?String(e.text):""},set text(s){e&&typeof s!="boolean"&&(e.text=s==null?"":String(s))},get pointsize(){return e&&e.textPointsize||24},set pointsize(s){e&&(e.textPointsize=Number(s)||24)},get font(){return e&&e.textFont||""},set font(s){e&&(e.textFont=String(s||""))},get alignment(){return e&&e.alignment||"center"},set alignment(s){if(!e)return;const a=String(s||"center").toLowerCase();e.alignment=a==="centre"?"center":a},...e&&e.puppet&&r?Fc(e,r):{getBoneCount:()=>0,getBoneTransform:()=>{const s={translation(a){return a===void 0?new he(0,0,0):s},rotation(){return s},scale(){return s}};return s},setBoneTransform:()=>{},applyBonePhysicsImpulse:()=>{}},getParent:()=>{if(!e||e.parentId==null)return null;const s=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById(e.parentId):null;return!s||s.destroyed?null:lr(s,n)},getChildren:()=>{const s=e&&e.childIds||[];if(!s.length)return[];const a=n&&typeof n.getSceneLayerById=="function"?n.getSceneLayerById:null;if(!a)return[];const c=[];for(const u of s){const l=a(u);l&&!l.destroyed&&c.push(lr(l,n))}return c},getAnimation:s=>{const a=e&&e.animations,c=e&&e.animationList||[];return s==null||s===""?c[0]||On():a&&a[s]?a[s]:typeof s=="number"&&c[s]?c[s]:typeof s=="string"&&/^\d+$/.test(s)&&c[Number(s)]?c[Number(s)]:On()},getAnimationLayer:s=>{const a=e&&e.animations,c=e&&e.animationList||[];return a&&a[s]?a[s]:typeof s=="number"&&c[s]?c[s]:typeof s=="string"&&/^\d+$/.test(s)&&c[Number(s)]?c[Number(s)]:On()},getAnimationLayerCount:()=>(e&&e.animationList||[]).length,getTextureAnimation:()=>Cc(e),play:()=>{e&&e.soundCtl&&e.soundCtl.play&&e.soundCtl.play(),e&&e.videoCtl&&e.videoCtl.play&&e.videoCtl.play()},pause:()=>{e&&e.soundCtl&&e.soundCtl.pause&&e.soundCtl.pause(),e&&e.videoCtl&&e.videoCtl.pause&&e.videoCtl.pause()},stop:()=>{e&&e.soundCtl&&e.soundCtl.stop&&e.soundCtl.stop(),e&&e.videoCtl&&e.videoCtl.stop&&e.videoCtl.stop()},isPlaying:Object.assign(()=>{const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||a)},{valueOf(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return!!(s||a)},toString(){const s=e&&e.soundCtl&&typeof e.soundCtl.isPlaying=="function"&&e.soundCtl.isPlaying(),a=e&&e.videoCtl&&typeof e.videoCtl.isPlaying=="function"&&e.videoCtl.isPlaying();return String(!!(s||a))}}),get volume(){if(e&&e.soundCtl&&typeof e.soundCtl.getVolume=="function")return e.soundCtl.getVolume();const s=e&&e.soundprops&&e.soundprops.volume;return typeof s=="number"?s:1},set volume(s){const a=Number(s);if(!Number.isFinite(a)||!e)return;const c=Math.max(0,Math.min(1,a));e.soundprops&&(e.soundprops.volume=c),e.soundCtl&&typeof e.soundCtl.setVolume=="function"&&e.soundCtl.setVolume(c)},getVideoTexture:()=>Lc(e),getTransformMatrix:()=>{const s=e&&e.origin||[0,0,0],a=new Float32Array(16);return a[0]=1,a[5]=1,a[10]=1,a[15]=1,a[12]=s[0]||0,a[13]=s[1]||0,a[14]=s[2]||0,{m:a}},getEffect:s=>{const a=e&&e.effects||null;if(!a||a.length===0)return ao(null);if(typeof s=="number"||typeof s=="string"&&/^\d+$/.test(s))return ao(a[Number(s)]||null);const c=String(s);return ao(a.find(u=>u&&u.name===c)||null)}};Object.defineProperty(i,"angles",{enumerable:!0,get(){return o.angles},set(s){if(e&&Array.isArray(e.angles)){const a=$i(s);e.angles[0]=a[0],e.angles[1]=a[1],e.angles[2]=a[2]}}});for(const s of["origin","scale","size","color"])Object.defineProperty(i,s,{enumerable:!0,get(){const a=e&&Array.isArray(e[s])?e[s]:null;return ur(a||[0,0,0])},set(a){const c=jt(a);o[s].x=c[0],o[s].y=c[1],o[s].z=c[2],e&&Array.isArray(e[s])&&s!=="size"&&(e[s][0]=c[0],e[s][1]=c[1],e[s][2]=c[2])}});return i}function Bc(e,n,t={}){if(typeof e!="string"||e.length===0)return null;const r=Bi(e),o={};if(n&&typeof n=="object")for(const[T,_]of Object.entries(n))if(_!==null&&typeof _=="object"&&typeof _.user=="string"){const F=t.userProperties?t.userProperties[_.user]:void 0;o[T]=F!==void 0?F:In(_)}else o[T]=In(_);const i=new Proxy(()=>i,{apply(){return i},get(T,_){if(_==="finish")return()=>o;if(typeof _=="string"&&Ai.test(_))return F=>(F&&typeof F=="object"&&typeof F.name=="string"&&!(F.name in o)&&(o[F.name]=In(F.value)),i)}}),s={registerAsset:()=>{},frametime:1/60,runtime:0,canvasSize:Di(t.canvasSize),screenResolution:t.screenResolution||{x:1920,y:1080},timeOfDay:typeof t.timeOfDay=="number"?t.timeOfDay:0,userProperties:t.userProperties||{},AUDIO_RESOLUTION_16:16,AUDIO_RESOLUTION_32:32,AUDIO_RESOLUTION_64:64,setTimeout:t.setTimeout||yn,clearTimeout:t.clearTimeout||(()=>{}),setInterval:t.setInterval||yn,clearInterval:t.clearInterval||(()=>{}),openUserShortcut:t.openUserShortcut||(()=>{}),isRunningInEditor:!!t.isRunningInEditor,isScreensaver:!!t.isScreensaver};Ei(s,t);const a=t.audioViews;s.registerAudioBuffers=T=>{const _=Math.max(1,Math.min(64,Math.floor(Number(T)||0)));let F=a?a.get(_):void 0;return F||(F={left:new Float32Array(_),right:new Float32Array(_),average:new Float32Array(_)},a&&a.set(_,F)),F};const c=t.shared||{},u={console:Ti()},l=Li(t.inputView),p=t.layer||null,f=t.workshopId!=null?t.workshopId:Nc(e),d=lr(p,t),w=Uc({...t,workshopId:f,getWorkshopId:()=>f});let M;try{M=new Function("scriptProperties","engine","WEMath","WEColor","WEVector","createScriptProperties","shared","console","process","globalThis","self","window","document","require","module","exports","fetch","XMLHttpRequest","Worker","importScripts","location","navigator","alert","confirm","prompt","setTimeout","setInterval","clearTimeout","clearInterval","requestAnimationFrame","cancelAnimationFrame","performance","Function","Vec3","Vec2","input","thisLayer","thisScene","thisObject","localStorage","MediaPlaybackEvent",`"use strict";
|
|
174
180
|
`+r+`
|
|
175
|
-
;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+sr.map(_=>`${_}: typeof ${_} === "function" ? ${_} : null,`).join("")+"dummy_: 0};")(o,ui(s),pi,gi,bi,i,a,u.console,void 0,u,u,u,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,pe,di,l,p,w,p,ic(),vi)}catch(S){return t.onError&&t.onError(S,"parse"),null}const g=!!(m&&(m.cursorClick||m.cursorEnter||m.cursorLeave||m.cursorDown||m.cursorUp||m.cursorMove)),v=!!(m&&sr.some(S=>m[S])),b=!!(m&&typeof m.applyUserProperties=="function");if(!m||!m.update&&!g&&!v&&!b)return null;const y={engine:s,scriptProperties:o,hasUpdate:!!m.update,hasCursorHook:g,hasApplyHook:b,errCount:0,disabled:!1,init(S){if(m.init)try{m.init(hi(S))}catch(_){y.errCount++,t.onError&&t.onError(_,"init")}},applyUserProperties(S){if(m.applyUserProperties)try{m.applyUserProperties(S||{})}catch(_){y.errCount++,t.onError&&t.onError(_,"applyUserProperties")}},callUpdate(S){if(y.disabled||!m.update)return;let _;try{_=m.update(hi(S))}catch(C){y.errCount++,t.onError&&t.onError(C,"update"),y.errCount>=3&&(y.disabled=!0);return}return _},hasCursorHook:g,callCursor(S,_){if(y.disabled)return;const C=m[S];if(typeof C=="function")try{return C(_)}catch(N){y.errCount++,t.onError&&t.onError(N,S),y.errCount>=3&&(y.disabled=!0);return}},hasMediaHook:v,callMedia(S,_){if(y.disabled)return;const C=m[S];if(typeof C=="function")try{return C(_)}catch(N){y.errCount++,t.onError&&t.onError(N,S),y.errCount>=3&&(y.disabled=!0);return}}};return y}function Jr(e){const n=Array.isArray(e)?e:[0,0,0],t={x:n[0]||0,y:n[1]||0,z:n[2]||0},r={get x(){return t.x},set x(o){t.x=Number(o)||0},get y(){return t.y},set y(o){t.y=Number(o)||0},get z(){return t.z},set z(o){t.z=Number(o)||0},add(o){const i=Dt(o);return t.x+=i[0],t.y+=i[1],t.z+=i[2],r},subtract(o){const i=Dt(o);return t.x-=i[0],t.y-=i[1],t.z-=i[2],r},multiply(o){if(o&&typeof o=="object"){const i=Dt(o);t.x*=i[0],t.y*=i[1],t.z*=i[2]}else{const i=Number(o)||0;t.x*=i,t.y*=i,t.z*=i}return r},copy(){return new pe(t.x,t.y,t.z)},length(){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)},toArray(){return[t.x,t.y,t.z]}};return r}function Dt(e){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e&&typeof e=="object")return[e.x||0,e.y||0,e.z||0];const n=Number(e)||0;return[n,n,n]}const cr=Math.PI/180,lr=180/Math.PI;function fc(e){const n=Array.isArray(e)?e:[0,0,0];return{x:(n[0]||0)*lr,y:(n[1]||0)*lr,z:(n[2]||0)*lr}}function _i(e){const n=Dt(e);return[n[0]*cr,n[1]*cr,n[2]*cr]}function dc(e){const n={x:0,y:1,z:2},t={add(r){const o=Dt(r);return t.x+=o[0],t.y+=o[1],t.z+=o[2],t},subtract(r){const o=Dt(r);return t.x-=o[0],t.y-=o[1],t.z-=o[2],t},multiply(r){return t.x*=r,t.y*=r,t.z*=r,t},toArray(){return[t.x,t.y,t.z]}};for(const r of["x","y","z"])Object.defineProperty(t,r,{enumerable:!0,get(){return!e||!Array.isArray(e.angles)?0:(e.angles[n[r]]||0)*lr},set(o){!e||!Array.isArray(e.angles)||(e.angles[n[r]]=(Number(o)||0)*cr)}});return t}function hc(e,n){return Math.min(256,Math.ceil(Math.max(1,Number(e)||1)*2+8))}function mc(e){for(const n of e&&e.effects?e.effects:[]){if(n&&n.visible===!1)continue;if(String(n&&(n.file||n.name)||"").includes("tint"))return!0;for(const r of n&&n.passes||[])for(const o of r&&r.textures||[])if(o&&String(o).toLowerCase().includes("mask"))return!0}return!1}const pc=Object.freeze(Object.defineProperty({__proto__:null,createInputView:Qa,drawTextLayer:Za,effectiveTextPadding:ai,evalObjectScript:uc,evalTextScript:nc,layoutText:qa,makeCursorEventVec:Ka,radToScriptAngles:fc,resolveWorkshopAssetPath:Mi,rewriteComboStringEq:yi,scriptAnglesToRad:_i,textCanvasMargin:hc,textLayerHasTintMask:mc},Symbol.toStringTag,{value:"Module"}));function gc(e={},n={}){const t=typeof e.setTimeout=="function"?e.setTimeout:null,r=typeof e.clearTimeout=="function"?e.clearTimeout:null,o=typeof e.setInterval=="function"?e.setInterval:null,i=typeof e.clearInterval=="function"?e.clearInterval:null,s=typeof n.onError=="function"?n.onError:null,c=new Set,a=g=>{const v=Number(g);return Number.isFinite(v)&&v>0?v:0},u=g=>()=>{try{g()}catch(v){s&&s(v,"timer")}},l=(g,v)=>{const b=()=>{g.fired||(g.fired=!0,c.delete(b),v&&g.handle!=null&&v(g.handle))};return b.handle=null,b.valueOf=()=>typeof g.handle=="number"?g.handle:0,b};function d(g,v){if(typeof g!="function")return l({fired:!0,handle:null},null);const b={fired:!1,handle:null},y=l(b,r);return c.add(y),b.handle=t?t(u(()=>{b.fired=!0,c.delete(y),g()}),a(v)):null,y.handle=b.handle,y}function h(g,v){if(typeof g!="function")return l({fired:!0,handle:null},null);const b={fired:!1,handle:null},y=l(b,i);return c.add(y),b.handle=o?o(u(g),a(v)):null,y.handle=b.handle,y}function p(g){if(typeof g=="function"){g();return}r&&g!=null&&r(g)}function w(g){if(typeof g=="function"){g();return}i&&g!=null&&i(g)}function m(){for(const g of[...c])g();c.clear()}return{setTimeout:d,setInterval:h,clearTimeout:p,clearInterval:w,dispose:m,pendingCount:()=>c.size}}const bc=Object.freeze(Object.defineProperty({__proto__:null,createEngineTimers:gc},Symbol.toStringTag,{value:"Module"}));function vc(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function eo(e,n){const t=Math.floor(e),r=e-t,o=s=>{const c=Math.sin((s*127.1+n*311.7)*43758.5453)*43758.5453;return(c-Math.floor(c))*2-1},i=r*r*(3-2*r);return o(t)*(1-i)+o(t+1)*i}const yc=32,Ai=60/112,xc=3.2;function wc(e){const n=new Float32Array(16),t=new Float32Array(16),r=new Float32Array(16);for(let o=0;o<16;o++)n[o]=o%4===0?1:o%4===2?.38+e()*.15:e()<.08?.5:0,t[o]=o%8===4?1:e()<.06?.6:0,r[o]=o%2===1?.5+e()*.4:o%4===0?.25:e()<.3?.3:0;return{kick:n,snare:t,hat:r}}function Mc(e=20260830){const n=vc(e),t=wc(n),r=new Float32Array(64);for(let g=0;g<64;g++)r[g]=n()*64;const o=64,i=new Float32Array(o),s=new Float32Array(o),c=new Float32Array(o),a=new Float32Array(o),u=new Float32Array(32),l=new Float32Array(32),d=new Float32Array(16),h=new Float32Array(16),p={left64:c,right64:a,left32:u,right32:l,left16:d,right16:h,level:0,silent:!1};function w(g,v){const b=v.length/g.length;for(let y=0;y<g.length;y++){let S=0;const _=Math.floor(y*b),C=Math.floor((y+1)*b);for(let N=_;N<Math.max(_+1,C);N++)S+=v[N];g[y]=S/Math.max(1,C-_)}}function m(g){const v=g/Ai,b=v*4,y=Math.floor(b)%16,S=b-Math.floor(b),_=Math.exp(-S*Ai*14),C=g%yc,N=C>=27&&C<29,D=C>=29?(C-29)/3:0,k=C>=24&&C<27?1-(C-24)/3:0,O=N?0:D>0?D*D:k>0?0:1,j=N?0:k>0?.35:1,W=t.kick[y]*_*O,K=(t.snare[y]*_+t.hat[y]*_*.7)*O,V=t.hat[y]*_*O,G=D>0?Math.pow(D,3)*(.4+.6*Math.abs(eo(b*2,7))):0;let Q=0;for(let q=0;q<o;q++){const te=q/o,me=Math.pow(1-te*.85,1.6);let xe=j*(.5+.3*eo(v*.5+r[q]*.05,q%8));if(xe*=.35+.65*te,te<.2&&(xe+=W*(1-te/.2)),te>=.12&&te<.62){const Pe=1-Math.abs(te-.34)/.28;Pe>0&&(xe+=K*.55*Pe)}te>=.45&&(xe+=V*.5*((te-.45)/.55)),xe+=G*.5,xe*=me,xe=Math.min(1,xe*xc);const We=.06+te*.2,Ve=eo(v*.13+q*.35,11)*We;let Ee=Math.min(1,Math.max(0,xe*(1-Ve))),rt=Math.min(1,Math.max(0,xe*(1+Ve)));const Xe=N?.012:0;i[q]=Math.max(Xe,Ee),s[q]=Math.max(Xe,rt),q<48&&(Q+=(i[q]+s[q])*.5)}return c.set(i),a.set(s),w(u,i),w(l,s),w(d,i),w(h,s),p.level=Math.min(1,Q/(48*1.2)),p.silent=N,p}return{update:m,snapshot:p,bands:o}}function _c(e,n){for(const t of e.values()){Ti(t.left,n.left64),Ti(t.right,n.right64);for(let r=0;r<t.average.length;r++)t.average[r]=(t.left[r]+t.right[r])*.5}}function Ti(e,n){const t=n.length/e.length;for(let r=0;r<e.length;r++){let o=0;const i=Math.floor(r*t),s=Math.max(i+1,Math.floor((r+1)*t));for(let c=i;c<s;c++)o+=n[c];e[r]=o/(s-i)}}const zt={STOPPED:0,PLAYING:1,PAUSED:2};class Fe{constructor(n,t,r){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){return new Fe(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new Fe(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){if(n!==null&&typeof n=="object")return new Fe(this.x*n.x,this.y*n.y,this.z*n.z);const t=Number(n)||0;return new Fe(this.x*t,this.y*t,this.z*t)}divide(n){const t=Number(n)||1;return new Fe(this.x/t,this.y/t,this.z/t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}copy(){return new Fe(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}}function Ac(e,n,t){return new Fe(e,n,t)}const Tc=[{title:"\u591C\u822A\u661F",artist:"\u76F8\u4F4D\u8FC1\u79FB",album:"\u6DF1\u7A7A\u56DE\u58F0",albumArtist:"\u76F8\u4F4D\u8FC1\u79FB",duration:212,colors:{primary:[.24,.42,.86],secondary:[.12,.18,.42],tertiary:[.62,.74,.98],text:[.95,.97,1]},lyrics:[[0,"\u5728\u65E0\u5149\u7684\u822A\u9053\u4E0A"],[12,"\u6211\u4EEC\u53EA\u5E26\u8D70\u5F7C\u6B64\u7684\u540D\u5B57"],[26,"\u5F15\u64CE\u4F4E\u9E23\u50CF\u4E00\u53E5\u65E7\u8BFA\u8A00"],[41,"\u628A\u9ED1\u6697\u6298\u6210\u4E24\u534A"],[58,"\u591C\u822A\u661F\u554A"],[72,"\u522B\u5728\u4E2D\u9014\u7184\u706D"],[95,"\uFF08\u95F4\u594F\uFF09"],[126,"\u5982\u679C\u5750\u6807\u7EC8\u5C06\u5931\u6548"],[140,"\u5C31\u8BA9\u8F68\u8FF9\u81EA\u5DF1\u8BF4\u8BDD"],[158,"\u6211\u4EEC\u4E0D\u8FD4\u822A"],[176,"\u4E5F\u4E0D\u9057\u61BE"],[198,"\u2026\u2026"]]},{title:"Amber Lantern",artist:"Hollow Coast",album:"Tidewater",albumArtist:"Hollow Coast",duration:187,colors:{primary:[.93,.62,.24],secondary:[.44,.24,.1],tertiary:[.99,.82,.56],text:[1,.98,.93]},lyrics:[[0,"Salt on the window frame"],[14,"a lantern swinging slow"],[30,"you said the tide forgets"],[46,"but the harbour never does"],[63,"Amber lantern, burn a little longer"],[88,"(instrumental)"],[118,"Every rope remembers the knot"],[134,"every shore remembers the leaving"],[152,"burn a little longer"],[170,"for me"]]},{title:"\u82D4\u75D5",artist:"\u6797\u95F4\u7535\u53F0",album:"\u534A\u5C71\u96E8",albumArtist:"\u6797\u95F4\u7535\u53F0",duration:241,colors:{primary:[.3,.68,.44],secondary:[.1,.28,.2],tertiary:[.72,.92,.78],text:[.96,1,.97]},lyrics:[[0,"\u96E8\u505C\u5728\u7B2C\u4E09\u7EA7\u53F0\u9636"],[16,"\u82D4\u75D5\u722C\u6EE1\u4E86\u65E7\u95E8\u724C"],[33,"\u4F60\u8BF4\u6162\u4E00\u70B9\u4E5F\u6CA1\u5173\u7CFB"],[52,"\u5C71\u4E0D\u4F1A\u8D70"],[70,"\u800C\u6211\u4EEC\u6709\u7684\u662F\u65F6\u95F4"],[92,"\uFF08\u95F4\u594F\uFF09"],[130,"\u628A\u4F1E\u6536\u8D77\u6765\u5427"],[148,"\u8BA9\u6F6E\u6C14\u8BB0\u4F4F\u8FD9\u4E00\u523B"],[172,"\u6162\u4E00\u70B9"],[200,"\u771F\u7684\u6CA1\u5173\u7CFB"],[226,"\u2026\u2026"]]},{title:"Neon Ashes",artist:"VELVET//NULL",album:"Afterimage",albumArtist:"VELVET//NULL",duration:168,colors:{primary:[.86,.22,.58],secondary:[.3,.06,.22],tertiary:[.99,.64,.86],text:[1,.94,.98]},lyrics:[[0,"city bleeds into the lens"],[11,"we were only afterimage"],[24,"neon ashes on your coat"],[38,"nothing here stays lit"],[55,"burn out with me"],[76,"(drop)"],[104,"nothing here stays lit"],[122,"burn out with me"],[146,"\u2026"]]}],ur=3;function Si(e=20260901){const n=Tc,t=n.reduce((v,b)=>v+b.duration+ur,0),r={hasMedia:!1,state:zt.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:new Fe(0,0,0),secondaryColor:new Fe(0,0,0),tertiaryColor:new Fe(0,0,0),textColor:new Fe(1,1,1),highContrastColor:new Fe(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1};let o=0,i=!1,s=0,c=0;function a(v){let b=0;const y=(v%n.length+n.length)%n.length;for(let S=0;S<y;S++)b+=n[S].duration+ur;return b}function u(v){let b=t>0?v%t:0;b<0&&(b+=t);let y=-1,S=0,_=!1;for(let j=0;j<n.length;j++){const W=n[j].duration;if(b<W){y=j,S=b;break}if(b-=W,b<ur){y=j,S=W,_=!0;break}b-=ur}y<0&&(y=n.length-1,S=n[y].duration,_=!0);const C=n[y];r.hasMedia=!0,r.trackIndex=y,r.title=C.title,r.artist=C.artist,r.album=C.album,r.albumArtist=C.albumArtist,r.duration=C.duration,r.position=S;const N=C.duration>0?S/C.duration:0;i?r.state=zt.PAUSED:_?r.state=zt.STOPPED:N>.7&&N<.76?r.state=zt.PAUSED:r.state=zt.PLAYING,r.hasThumbnail=!_;const D=C.colors;r.primaryColor=new Fe(D.primary[0],D.primary[1],D.primary[2]),r.secondaryColor=new Fe(D.secondary[0],D.secondary[1],D.secondary[2]),r.tertiaryColor=new Fe(D.tertiary[0],D.tertiary[1],D.tertiary[2]),r.textColor=new Fe(D.text[0],D.text[1],D.text[2]);const k=.2126*D.primary[0]+.7152*D.primary[1]+.0722*D.primary[2];r.highContrastColor=k>.5?new Fe(0,0,0):new Fe(1,1,1),r.lyrics=C.lyrics;let O=-1;for(let j=0;j<C.lyrics.length;j++)S>=C.lyrics[j][0]&&(O=j);return r.lyricIndex=O,r.lyricLine=O>=0?C.lyrics[O][1]:"",r}function l(v){c=Number(v)||0;const b=i?s:c+o;return u(b)}function d(v){i=!1;const b=a(v);return o=b-c,u(b)}function h(){const v=r.trackIndex<0?0:r.trackIndex+1;return d(v)}function p(){const v=r.trackIndex<0?n.length-1:r.trackIndex-1;return d(v)}function w(){return i||(s=c+o,i=!0,r.state=zt.PAUSED),r}function m(){return i?(i=!1,o=s-c,u(s)):r}function g(){return i?m():w()}return{update:l,snapshot:r,tracks:n,cycle:t,MEDIA_PLAYBACK:zt,skipNext:h,skipPrevious:p,play:m,pause:w,playPause:g}}function Sc(e,n=512){const t=Math.max(8,n|0),r=new Uint8Array(t*t*4),o=e&&e.colors?e.colors:{primary:[.5,.5,.5],secondary:[.1,.1,.1],tertiary:[.8,.8,.8]},[i,s,c]=o.primary,[a,u,l]=o.secondary,[d,h,p]=o.tertiary;for(let w=0;w<t;w++)for(let m=0;m<t;m++){const g=m/(t-1),v=w/(t-1),b=g-.5,y=v-.5,S=Math.sqrt(b*b+y*y)*2,_=.5+.5*Math.sin(S*18-1.2),C=.5+.5*Math.sin((g+v)*6),N=Math.min(1,Math.max(0,S));let D=i*(1-N)+a*N,k=s*(1-N)+u*N,O=c*(1-N)+l*N;D=D*(.72+.28*_)+d*.18*C,k=k*(.72+.28*_)+h*.18*C,O=O*(.72+.28*_)+p*.18*C;const j=1-.35*Math.min(1,S*S),W=(w*t+m)*4;r[W]=Math.max(0,Math.min(255,Math.round(D*j*255))),r[W+1]=Math.max(0,Math.min(255,Math.round(k*j*255))),r[W+2]=Math.max(0,Math.min(255,Math.round(O*j*255))),r[W+3]=255}return{width:t,height:t,rgba:r}}function Ec(e,n){const t=[];if(!n)return t;const r=!e;return(r||e.hasMedia!==n.hasMedia)&&t.push({name:"mediaStatusChanged",event:{enabled:n.hasMedia}}),(r||e.title!==n.title||e.artist!==n.artist||e.album!==n.album||e.albumArtist!==n.albumArtist)&&t.push({name:"mediaPropertiesChanged",event:{title:n.title,artist:n.artist,album:n.album,albumArtist:n.albumArtist,albumTitle:n.album,subTitle:"",trackType:"music"}}),(r||e.hasThumbnail!==n.hasThumbnail||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaThumbnailChanged",event:{hasThumbnail:n.hasThumbnail,primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,tertiaryColor:n.tertiaryColor,textColor:n.textColor,highContrastColor:n.highContrastColor}}),(r||e.state!==n.state)&&t.push({name:"mediaPlaybackChanged",event:{state:n.state}}),(r||Math.floor(e.position)!==Math.floor(n.position)||e.duration!==n.duration)&&t.push({name:"mediaTimelineChanged",event:{position:n.position,duration:n.duration}}),(r||e.lyricIndex!==n.lyricIndex||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaLyricsChanged",event:{line:n.lyricLine,index:n.lyricIndex,lines:n.lyrics}}),t}function Pc(e){return e?{hasMedia:e.hasMedia,state:e.state,title:e.title,artist:e.artist,album:e.album,albumArtist:e.albumArtist,position:e.position,duration:e.duration,hasThumbnail:e.hasThumbnail,trackIndex:e.trackIndex,lyricIndex:e.lyricIndex,lyricLine:e.lyricLine}:null}const Cc=Object.freeze(Object.defineProperty({__proto__:null,MEDIA_PLAYBACK:zt,cloneMediaSnapshot:Pc,createSimulatedMedia:Si,diffMediaEvents:Ec,mediaVec3:Ac,renderThumbnail:Sc},Symbol.toStringTag,{value:"Module"})),Ei=14,Fn=[{app:"Safari",title:"GitHub \xB7 we-scene-renderer",url:"https://github.com/oneincase/we-scene-renderer"},{app:"Google Chrome",title:"YouTube",url:"https://www.youtube.com/watch?v=dQw4w9WgXcQ"},{app:"Google Chrome",title:"Wallpaper Engine - Workshop",url:"https://steamcommunity.com/app/431960/workshop/"},{app:"Safari",title:"MDN Web Docs",url:"https://developer.mozilla.org/en-US/docs/Web/API"},{app:"Music",title:"\u591C\u822A\u661F \u2014 \u76F8\u4F4D\u8FC1\u79FB",url:""},{app:"Code",title:"we-scene-renderer \u2014 text.js",url:""}];function Pi(){const e={app:"",title:"",url:"",index:-1};function n(t){const r=Number(t)||0,o=Fn.length?Math.floor(r/Ei)%Fn.length:0,i=Fn[o]||Fn[0];return e.app=i.app,e.title=i.title,e.url=i.url,e.index=o,e}return n(0),{update:n,snapshot:e,tabs:Fn,hold:Ei}}function Ci(e){const n={name:"",at:0};function t(r){return n.name=String(r||""),n.at=Date.now(),typeof e=="function"&&e(n.name),n.name}return{openUserShortcut:t,last:n}}function Rc(e){const n=Si(e),t=Pi(),r=Ci(null);return{media:n,windowTitle:t,shortcuts:r}}const Lc=Object.freeze(Object.defineProperty({__proto__:null,createShortcutHandler:Ci,createSimulatedSystem:Rc,createSimulatedWindowTitle:Pi},Symbol.toStringTag,{value:"Module"}));function Fc(e={}){const n=e.target||(typeof window<"u"?window:null),t=e.viewport||(typeof window<"u"?()=>({w:window.innerWidth||1,h:window.innerHeight||1}):null),r={u:.5,v:.5,screenX:0,screenY:0,wx:0,wy:0,originY:null,lastU:.5,lastV:.5,lastScreenX:0,lastScreenY:0,lastWx:0,lastWy:0,lastOriginY:null,leftDown:!1,has:!1,moveCount:0,downCount:0,upCount:0,lastEventTime:0,screenW:1,screenH:1};function o(){if(!t)return;const l=t();r.screenW=l.w||1,r.screenH=l.h||1}o();function i(l){o();let d=l.clientX,h=l.clientY;if(n&&typeof n.getBoundingClientRect=="function"){const m=n.getBoundingClientRect();d-=m.left,h-=m.top}const p=d/r.screenW,w=h/r.screenH;r.has||(r.lastU=p,r.lastV=w,r.lastScreenX=d,r.lastScreenY=h),r.screenX=d,r.screenY=h,r.u=p,r.v=w,r.has=!0,r.moveCount++,r.lastEventTime=Date.now()}function s(l){l.button!==void 0&&l.button!==0||(r.leftDown=!0,r.downCount++)}function c(l){l.button!==void 0&&l.button!==0||(r.leftDown=!1,r.upCount++)}function a(){r.leftDown=!1}let u=!1;return n&&n.addEventListener&&(u=!0,n.addEventListener("mousemove",i,{passive:!0}),n.addEventListener("mousedown",s,{passive:!0}),n.addEventListener("mouseup",c,{passive:!0}),n.addEventListener("blur",a,{passive:!0}),typeof document<"u"&&document.addEventListener&&document.addEventListener("mouseleave",a,{passive:!0})),{state:r,beginFrame(){o(),r.lastU=r.u,r.lastV=r.v,r.lastScreenX=r.screenX,r.lastScreenY=r.screenY,r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY},syncWorld(l,d=0,h=0){if(!l)return;r.wx=l.offX+r.u*l.viewW-d,r.wy=l.offY+r.v*l.viewH-h;const p=Number(l.projH);r.originY=Number.isFinite(p)?p-r.wy:r.wy,r.lastWx===0&&r.lastWy===0&&(r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY)},normalizedDelta(){const l=r.u-r.lastU,d=r.v-r.lastV;return Math.hypot(l,d)},dispose(){!u||!n||!n.removeEventListener||(u=!1,n.removeEventListener("mousemove",i),n.removeEventListener("mousedown",s),n.removeEventListener("mouseup",c),n.removeEventListener("blur",a),typeof document<"u"&&document.removeEventListener&&document.removeEventListener("mouseleave",a))}}}const Nc=Object.freeze(Object.defineProperty({__proto__:null,createPointerSource:Fc},Symbol.toStringTag,{value:"Module"}));function Ri(e,n,t,r,o,i,s){const c=e.size||[0,0],a=e.scale||[1,1,1],u=c[0]*a[0],l=c[1]*a[1];if(!(u>0)||!(l>0))return null;const d=e.origin||[0,0,0];let h=d[0],p=r-d[1];if(e.parallaxDepth&&(o!==0||i!==0)){const b=e.parallaxDepth,y=an(b[0]),S=an(b[1]);h+=y*o,p+=S*i}let w=n-h,m=t-p;const g=e.angles?e.angles[2]:0;if(g){const b=Math.cos(-g),y=Math.sin(-g),S=w*b+m*y,_=-w*y+m*b;w=S,m=_}const v=s&&s[e.alignment]||[.5,.5];return(v[0]!==.5||v[1]!==.5)&&(w-=(.5-v[0])*u,m-=(.5-v[1])*l),{lx:w/u,ly:m/l,w:u,h:l}}function Uc(e,n,t,r,o={}){if(!e||e.length===0)return null;const i=o.parOffX||0,s=o.parOffY||0,c=o.alignTable,a=o.filter;for(let u=e.length-1;u>=0;u--){const l=e[u];if(!l||!l.visible||l.destroyed||a&&!a(l))continue;const d=Ri(l,n,t,r,i,s,c);if(d&&Math.abs(d.lx)<=.5&&Math.abs(d.ly)<=.5)return l}return null}const kc=Object.freeze(Object.defineProperty({__proto__:null,hitTestLayers:Uc,worldToLayerLocal:Ri},Symbol.toStringTag,{value:"Module"})),Oe=e=>e,De=Oe(Qi),fr=Oe(ms),Qe=Oe(As),bt=Oe(Ps),ke=Oe(ca),Bc=Oe(ua),Ic=Oe(ga),un=Oe(La),Nn=Oe(Ya),qe=Oe(pc),Oc=Oe(bc),St=Oe(Cc),Li=Oe(Lc),Fi=Oe(ra),Dc=Oe(Nc),zc=Oe(kc);function $c(e,n,t){return{camera:null,general:{orthogonalprojection:{width:e,height:n},clearenabled:!0,clearcolor:"0 0 0"},layers:[{id:0,name:"media",visible:!0,image:t,textureName:t,particle:null,puppet:null,solid:!1,isContainer:!1,isPostProcess:!1,isText:!1,isSound:!1,isComponent:!1,sound:[],origin:[e/2,n/2,0],scale:[1,1,1],angles:[0,0,0],size:[e,n],alignment:"center",color:[1,1,1],alpha:1,brightness:1,colorBlendMode:0,copybackground:!1,parallaxDepth:null,animationLayers:[],effects:[]}],properties:{}}}async function jc(e){const n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}`);const t=new window.ImageDecoder({data:await n.arrayBuffer(),type:"image/gif"});await t.tracks.ready,await t.completed;const r=t.tracks.selectedTrack;if(!r||!r.frameCount)return null;const o=Math.min(r.frameCount,300),i=[];let s=0,c=0;for(let a=0;a<o;a++){const{image:u}=await t.decode({frameIndex:a});s=u.displayWidth,c=u.displayHeight,i.push({bitmap:await createImageBitmap(u),durationMs:u.duration?u.duration/1e3:100}),u.close()}return t.close?.(),{width:s,height:c,frames:i}}function Wc(e,n){if(tn(e),!n.src){e.fallbackPage?.();return}const t=n.type==="video",r=n.type==="gif",o=document.createElement("canvas"),i=Ye(e,n);if(o.width=Math.max(1,Math.round(innerWidth*i)),o.height=Math.max(1,Math.round(innerHeight*i)),o.style.cssText="position:absolute;inset:0;width:100%;height:100%;",!o.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0})){ae(e,n,`media ${n.type}: WEBGL2_UNAVAILABLE\uFF0C\u56DE\u9000 DOM \u6E32\u67D3`),t?Vc(e,n):Xc(e,n);return}e.wrap?.appendChild(o),e.canvas=o;let c=!1;e.sceneCleanup=()=>{c=!0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let a,u,l=!1;e.sceneCtl={pause(){a?.()},resume(){u?.()},applyUserProperties(){}};const d=h=>{c||(c=!0,ae(e,n,`media ${n.type} \u5931\u8D25: ${h}`),e.fallbackPage?.())};(async()=>{try{const h=ke.createRenderer(o,{diag:k=>ae(e,n,`renderer: ${k}`),fboCapFactor:0});if(e.renderer=h,c)return;const p="__media",w=new Map;let m,g=0,v=0;if(t){const k=document.createElement("video");if(k.autoplay=!0,k.loop=n.loop!==!1,k.muted=n.muted!==!1,k.playsInline=!0,k.preload="metadata",k.width=o.width,k.height=o.height,k.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",k.src=n.src,document.body.appendChild(k),e.video=k,(e.videoTextures??=[]).push(k),await new Promise((O,j)=>{k.addEventListener("loadedmetadata",()=>O(),{once:!0}),k.addEventListener("error",()=>j(new Error(`video error ${k.error?.code??"?"}`)),{once:!0})}),c)return;g=k.videoWidth||o.width,v=k.videoHeight||o.height,w.set(p,{video:k,glTex:ke.makeTexture(h.gl,new Uint8Array([0,0,0,255]),1,1),width:g,height:v,rg88:!1,lastUploaded:-1}),e.paused||k.play().catch(()=>{}),ae(e,n,`media video ${g}x${v} \u2192 scene \u6E32\u67D3`)}else{let k=!1;if(r&&typeof window.ImageDecoder=="function")try{const O=await jc(n.src);if(O&&O.frames.length>1){g=O.width,v=O.height;const j=h.gl,W={glTex:ke.makeTexture(j,null,0,0,O.frames[0].bitmap),width:g,height:v,rg88:!1};w.set(p,W);let K=0,V=performance.now()+O.frames[0].durationMs;m=()=>{const Q=performance.now();if(!(Q<V)){K=(K+1)%O.frames.length,V=Q+O.frames[K].durationMs,j.bindTexture(j.TEXTURE_2D,W.glTex);try{j.texImage2D(j.TEXTURE_2D,0,j.RGBA,j.RGBA,j.UNSIGNED_BYTE,O.frames[K].bitmap)}catch{}}};const G=e.sceneCleanup;e.sceneCleanup=()=>{G?.();for(const Q of O.frames)Q.bitmap.close()},k=!0,ae(e,n,`media gif ${g}x${v} ${O.frames.length} \u5E27 \u2192 scene \u6E32\u67D3`)}}catch(O){ae(e,n,`gif \u89E3\u7801\u5931\u8D25\uFF0C\u56DE\u9000\u9759\u6001\u9996\u5E27: ${String(O.message).slice(0,80)}`)}if(!k){const O=new Image;if(O.crossOrigin="anonymous",O.src=n.src,await new Promise((j,W)=>{O.addEventListener("load",()=>j(),{once:!0}),O.addEventListener("error",()=>W(new Error("image load error")),{once:!0})}),c)return;g=O.naturalWidth||1,v=O.naturalHeight||1,e.img=O,w.set(p,{glTex:ke.makeTexture(h.gl,null,0,0,O),width:g,height:v,rg88:!1}),ae(e,n,`media ${n.type} ${g}x${v} \u2192 scene \u6E32\u67D3`)}}if(c)return;const b=$c(g,v,p),y=performance.now();let S=0,_=0,C=-1/0;const N=k=>{if(c||e.paused)return;const O=e.cfg.sceneFps||60;if(k-C>=1e3/O){C=k,io(e,k),ao(e,o,e.cfg),m?.();const j=e.coverAlign;h.render(b,w,o.width,o.height,(k-y-S)/1e3,qt(e.cfg.fit),j.x,j.y).then(()=>{c||e.paused||(e.raf=requestAnimationFrame(N))}).catch(W=>d(String(W.message||W).slice(0,200)))}else e.paused||(e.raf=requestAnimationFrame(N))},D=()=>{c||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(N))};a=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),_||(_=performance.now());const k=e.video;l=!!(k&&!k.paused&&!k.ended),k?.pause()},u=()=>{_&&(S+=performance.now()-_,_=0),l&&e.video?.play().catch(()=>{}),l=!1,D()},D()}catch(h){d(String(h.message||h).slice(0,200))}})()}function Vc(e,n){if(tn(e),!n.src){e.fallbackPage?.();return}const t=ro(n.fit),r=`position:absolute;inset:0;width:100%;height:100%;object-fit:${t.objectFit};object-position:50% 50%;background:${t.background};`;let o=!1;const i=()=>{o||(o=!0,console.warn("video error, fallback to default wallpaper"),e.fallbackPage?.())},s=document.createElement("video");s.autoplay=!0,s.loop=n.loop!==!1,s.muted=n.muted!==!1,s.playsInline=!0,s.preload="metadata";const c=Math.min(window.devicePixelRatio||1,e.cfg.renderDpr||1);s.width=Math.max(1,Math.round(innerWidth*c)),s.height=Math.max(1,Math.round(innerHeight*c)),s.style.cssText=r,s.src=n.src,s.addEventListener("error",i),e.wrap?.appendChild(s),e.video=s,s.addEventListener("canplay",()=>s.play().catch(()=>{}),{once:!0}),ae(e,n,"video mounted (single + native loop)")}function Xc(e,n){tn(e);const t=document.createElement("img"),r=ro(n.fit);t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;object-fit:${r.objectFit};object-position:50% 50%;background:${r.background};`,t.src=n.src??"",t.addEventListener("error",()=>e.fallbackPage?.()),e.wrap?.appendChild(t),e.img=t}const Hc=["scene.pkg","scenes/scene.pkg","gifscene.pkg"];function Ni(e,n){const t=e.replace(/\/+$/,"");return{key:t,async scenePkg(r){let o=null,i=null;for(const c of Hc){let a;try{a=await fetch(`${t}/${c}`,{...n,signal:r})}catch(u){if(r?.aborted)throw u;i=u;continue}if(!a.ok){o=a.status;continue}try{return await a.arrayBuffer()}catch(u){if(r?.aborted)throw u;const l=u instanceof Error?u.message:String(u);throw new Error(`\u8BFB\u53D6 scene.pkg \u4F53\u5931\u8D25\uFF08${l}\uFF09`)}}if(o!=null)throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08HTTP ${o}\uFF09`);const s=i instanceof Error?i.message:"Failed to fetch";throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08${s}\uFF09`)},async project(r){try{const o=await fetch(`${t}/project.json`,{...n,signal:r});return o.ok?await o.json():null}catch{return null}}}}function Gc(e,n){const t=e;return{key:typeof t.name=="string"?`file:${t.name}:${t.size}:${t.lastModified??0}`:void 0,scenePkg:()=>e.arrayBuffer(),project:async()=>n??null}}function Yc(e,n,t){return{key:t,scenePkg:async()=>e,project:async()=>n??null}}const Ui=.5,qc=.04,ki=.08;function Zc(e,n){const t=b=>{const y=document.createElement("video");b&&(y.src=e),y.muted=n.muted,y.playsInline=!0,y.preload="metadata";const S=Math.min(window.devicePixelRatio||1,n.renderDpr||1),_=Math.max(1,Math.round(n.maxW*S)),C=Math.max(1,Math.round(n.maxH*S));return y.width=_,y.height=C,y.loop=!0,y};let r=t(!0),o=t(!1),i=!1,s=1,c=n.muted;o.muted=!0;const a=()=>{i||(o.src=e,i=!0)};let u=!1,l=!1,d=-1,h=0,p=!1;const w=()=>{if(u=!1,l=!1,!o.paused){o.pause();try{o.currentTime=0}catch{}}},m=()=>{const b=r;r=o,o=b,u=!1,l=!1,r.play().catch(()=>{}),r.muted=c,r.volume=s,b.pause();try{b.currentTime=0}catch{}b.muted=!0,d=-1,i=!0,v.onSwap?.(r)},g=()=>{if(p)return;h=requestAnimationFrame(g);const b=r.duration;if(!isFinite(b)||b<=0)return;const y=r.currentTime;if(d>=0&&y<d-.05){const _=l;w(),d=y,_||v.onFallback?.();return}d=y;const S=b-y;if(S>Ui+.5){(u||l)&&w();return}if(l){(S<=ki||y<=ki)&&m();return}if(u){o.paused?o.play().catch(()=>{}):o.currentTime>=qc*.5&&(o.pause(),u=!1,l=!0);return}if(S<=Ui&&(a(),o.readyState>=2)){try{o.currentTime=0}catch{}o.play().catch(()=>{}),u=!0}};h=requestAnimationFrame(g);const v={get active(){return r},get standby(){return o},onSwap:void 0,onFallback:void 0,setVolume(b){s=Math.max(0,Math.min(1,b)),c=b<=0,r.muted=c,r.volume=s,o.muted=!0,o.volume=s},pause(){w(),r.pause(),h&&cancelAnimationFrame(h),h=0},resume(){p||(r.play().catch(b=>{b&&b.name}),h||(h=requestAnimationFrame(g)))},destroy(){p=!0,h&&cancelAnimationFrame(h),h=0;for(const b of[r,o]){b.pause(),b.removeAttribute("src");try{b.load()}catch{}b.remove()}}};return v}const Bi=!1,Ii=!0,Oi=!1,Kc=!1,Qc=!1,Di=4,Jc={"common.h":`// WE common.h\uFF08\u91CD\u5EFA\u5B50\u96C6\uFF0C\u4F9B we-scene \u6D4F\u89C8\u5668\u6E32\u67D3\uFF09
|
|
181
|
+
;return {update: typeof update === "function" ? update : null,init: typeof init === "function" ? init : null,applyUserProperties: typeof applyUserProperties === "function" ? applyUserProperties : null,cursorClick: typeof cursorClick === "function" ? cursorClick : null,cursorEnter: typeof cursorEnter === "function" ? cursorEnter : null,cursorLeave: typeof cursorLeave === "function" ? cursorLeave : null,cursorDown: typeof cursorDown === "function" ? cursorDown : null,cursorUp: typeof cursorUp === "function" ? cursorUp : null,cursorMove: typeof cursorMove === "function" ? cursorMove : null,`+cr.map(_=>`${_}: typeof ${_} === "function" ? ${_} : null,`).join("")+"dummy_: 0};")(o,Si(s),Ri,Fi,ki,i,c,u.console,void 0,u,u,u,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,void 0,he,Pi,l,d,w,d,Rc(),Ni)}catch(T){return t.onError&&t.onError(T,"parse"),null}const m=!!(M&&(M.cursorClick||M.cursorEnter||M.cursorLeave||M.cursorDown||M.cursorUp||M.cursorMove)),A=!!(M&&cr.some(T=>M[T])),h=!!(M&&typeof M.applyUserProperties=="function"),b=/\bengine\s*\.\s*(runtime|frametime)\b/.test(r);if(!M||!M.update&&!m&&!A&&!h&&!b)return null;const v={engine:s,scriptProperties:o,hasUpdate:!!M.update,hasCursorHook:m,hasApplyHook:h,errCount:0,disabled:!1,init(T){if(M.init)try{M.init(Ci(T))}catch(_){v.errCount++,t.onError&&t.onError(_,"init")}},applyUserProperties(T){if(M.applyUserProperties)try{M.applyUserProperties(T||{})}catch(_){v.errCount++,t.onError&&t.onError(_,"applyUserProperties")}},callUpdate(T){if(v.disabled||!M.update)return;let _;try{_=M.update(Ci(T))}catch(F){v.errCount++,t.onError&&t.onError(F,"update"),v.errCount>=3&&(v.disabled=!0);return}return _},hasCursorHook:m,callCursor(T,_){if(v.disabled)return;const F=M[T];if(typeof F=="function")try{return F(_)}catch(R){v.errCount++,t.onError&&t.onError(R,T),v.errCount>=3&&(v.disabled=!0);return}},hasMediaHook:A,callMedia(T,_){if(v.disabled)return;const F=M[T];if(typeof F=="function")try{return F(_)}catch(R){v.errCount++,t.onError&&t.onError(R,T),v.errCount>=3&&(v.disabled=!0);return}}};return v}function ur(e){const n=Array.isArray(e)?e:[0,0,0],t={x:n[0]||0,y:n[1]||0,z:n[2]||0},r={get x(){return t.x},set x(o){t.x=Number(o)||0},get y(){return t.y},set y(o){t.y=Number(o)||0},get z(){return t.z},set z(o){t.z=Number(o)||0},add(o){const i=jt(o);return t.x+=i[0],t.y+=i[1],t.z+=i[2],r},subtract(o){const i=jt(o);return t.x-=i[0],t.y-=i[1],t.z-=i[2],r},multiply(o){if(o&&typeof o=="object"){const i=jt(o);t.x*=i[0],t.y*=i[1],t.z*=i[2]}else{const i=Number(o)||0;t.x*=i,t.y*=i,t.z*=i}return r},copy(){return new he(t.x,t.y,t.z)},length(){return Math.sqrt(t.x*t.x+t.y*t.y+t.z*t.z)},toArray(){return[t.x,t.y,t.z]}};return r}function jt(e){if(Array.isArray(e))return[e[0]||0,e[1]||0,e[2]||0];if(e&&typeof e=="object")return[e.x||0,e.y||0,e.z||0];const n=Number(e)||0;return[n,n,n]}const fr=Math.PI/180,dr=180/Math.PI;function Dc(e){const n=Array.isArray(e)?e:[0,0,0];return{x:(n[0]||0)*dr,y:(n[1]||0)*dr,z:(n[2]||0)*dr}}function $i(e){const n=jt(e);return[n[0]*fr,n[1]*fr,n[2]*fr]}function Ic(e){const n={x:0,y:1,z:2},t={add(r){const o=jt(r);return t.x+=o[0],t.y+=o[1],t.z+=o[2],t},subtract(r){const o=jt(r);return t.x-=o[0],t.y-=o[1],t.z-=o[2],t},multiply(r){return t.x*=r,t.y*=r,t.z*=r,t},toArray(){return[t.x,t.y,t.z]}};for(const r of["x","y","z"])Object.defineProperty(t,r,{enumerable:!0,get(){return!e||!Array.isArray(e.angles)?0:(e.angles[n[r]]||0)*dr},set(o){!e||!Array.isArray(e.angles)||(e.angles[n[r]]=(Number(o)||0)*fr)}});return t}function Oc(e,n){return Math.min(256,Math.ceil(Math.max(1,Number(e)||1)*2+8))}function $c(e){for(const n of e&&e.effects?e.effects:[]){if(n&&n.visible===!1)continue;if(String(n&&(n.file||n.name)||"").includes("tint"))return!0;for(const r of n&&n.passes||[])for(const o of r&&r.textures||[])if(o&&String(o).toLowerCase().includes("mask"))return!0}return!1}const jc=Object.freeze(Object.defineProperty({__proto__:null,createInputView:Ac,drawTextLayer:Mc,effectiveTextPadding:_i,evalObjectScript:Bc,evalTextScript:Pc,layoutText:wc,makeCursorEventVec:_c,radToScriptAngles:Dc,resolveWorkshopAssetPath:Oi,rewriteComboStringEq:Ui,scriptAnglesToRad:$i,textCanvasMargin:Oc,textLayerHasTintMask:$c},Symbol.toStringTag,{value:"Module"}));function zc(e={},n={}){const t=typeof e.setTimeout=="function"?e.setTimeout:null,r=typeof e.clearTimeout=="function"?e.clearTimeout:null,o=typeof e.setInterval=="function"?e.setInterval:null,i=typeof e.clearInterval=="function"?e.clearInterval:null,s=typeof n.onError=="function"?n.onError:null,a=new Set,c=m=>{const A=Number(m);return Number.isFinite(A)&&A>0?A:0},u=m=>()=>{try{m()}catch(A){s&&s(A,"timer")}},l=(m,A)=>{const h=()=>{m.fired||(m.fired=!0,a.delete(h),A&&m.handle!=null&&A(m.handle))};return h.handle=null,h.valueOf=()=>typeof m.handle=="number"?m.handle:0,h};function p(m,A){if(typeof m!="function")return l({fired:!0,handle:null},null);const h={fired:!1,handle:null},b=l(h,r);return a.add(b),h.handle=t?t(u(()=>{h.fired=!0,a.delete(b),m()}),c(A)):null,b.handle=h.handle,b}function f(m,A){if(typeof m!="function")return l({fired:!0,handle:null},null);const h={fired:!1,handle:null},b=l(h,i);return a.add(b),h.handle=o?o(u(m),c(A)):null,b.handle=h.handle,b}function d(m){if(typeof m=="function"){m();return}r&&m!=null&&r(m)}function w(m){if(typeof m=="function"){m();return}i&&m!=null&&i(m)}function M(){for(const m of[...a])m();a.clear()}return{setTimeout:p,setInterval:f,clearTimeout:d,clearInterval:w,dispose:M,pendingCount:()=>a.size}}const Vc=Object.freeze(Object.defineProperty({__proto__:null,createEngineTimers:zc},Symbol.toStringTag,{value:"Module"}));function Wc(e){let n=e>>>0;return function(){n|=0,n=n+1831565813|0;let t=Math.imul(n^n>>>15,1|n);return t=t+Math.imul(t^t>>>7,61|t)^t,((t^t>>>14)>>>0)/4294967296}}function co(e,n){const t=Math.floor(e),r=e-t,o=s=>{const a=Math.sin((s*127.1+n*311.7)*43758.5453)*43758.5453;return(a-Math.floor(a))*2-1},i=r*r*(3-2*r);return o(t)*(1-i)+o(t+1)*i}const Hc=32,ji=60/112,Xc=3.2;function Gc(e){const n=new Float32Array(16),t=new Float32Array(16),r=new Float32Array(16);for(let o=0;o<16;o++)n[o]=o%4===0?1:o%4===2?.38+e()*.15:e()<.08?.5:0,t[o]=o%8===4?1:e()<.06?.6:0,r[o]=o%2===1?.5+e()*.4:o%4===0?.25:e()<.3?.3:0;return{kick:n,snare:t,hat:r}}function zi(e=20260830){const n=Wc(e),t=Gc(n),r=new Float32Array(64);for(let h=0;h<64;h++)r[h]=n()*64;const o=64,i=new Float32Array(o),s=new Float32Array(o),a=new Float32Array(o),c=new Float32Array(o),u=new Float32Array(o),l=new Float32Array(o),p=new Float32Array(32),f=new Float32Array(32),d=new Float32Array(16),w=new Float32Array(16),M={left64:u,right64:l,left32:p,right32:f,left16:d,right16:w,preL64:a,preR64:c,level:0,silent:!1};function m(h,b){const v=b.length/h.length;for(let T=0;T<h.length;T++){let _=0;const F=Math.floor(T*v),R=Math.floor((T+1)*v);for(let k=F;k<Math.max(F+1,R);k++)_+=b[k];h[T]=_/Math.max(1,R-F)}}function A(h){const b=h/ji,v=b*4,T=Math.floor(v)%16,_=v-Math.floor(v),F=Math.exp(-_*ji*14),R=h%Hc,k=R>=27&&R<29,U=R>=29?(R-29)/3:0,V=R>=24&&R<27?1-(R-24)/3:0,q=k?0:U>0?U*U:V>0?0:1,W=k?0:V>0?.35:1,Z=t.kick[T]*F*q,K=(t.snare[T]*F+t.hat[T]*F*.7)*q,re=t.hat[T]*F*q,te=U>0?Math.pow(U,3)*(.4+.6*Math.abs(co(v*2,7))):0;let X=0;for(let J=0;J<o;J++){const de=J/o,Se=Math.pow(1-de*.85,1.6);let Ae=W*(.5+.3*co(b*.5+r[J]*.05,J%8));if(Ae*=.35+.65*de,de<.2&&(Ae+=Z*(1-de/.2)),de>=.12&&de<.62){const Pe=1-Math.abs(de-.34)/.28;Pe>0&&(Ae+=K*.55*Pe)}de>=.45&&(Ae+=re*.5*((de-.45)/.55)),Ae+=te*.5,Ae*=Se;const Ie=Ae;Ae=Math.min(1,Ae*Xc);const Je=.06+de*.2,Xe=co(b*.13+J*.35,11)*Je;let Ee=Math.min(1,Math.max(0,Ae*(1-Xe))),Re=Math.min(1,Math.max(0,Ae*(1+Xe)));const le=k?.012:0;i[J]=Math.max(le,Ee),s[J]=Math.max(le,Re),a[J]=Math.max(le,Math.max(0,Ie*(1-Xe))),c[J]=Math.max(le,Math.max(0,Ie*(1+Xe))),J<48&&(X+=(i[J]+s[J])*.5)}return u.set(i),l.set(s),m(p,i),m(f,s),m(d,i),m(w,s),M.level=Math.min(1,X/(48*1.2)),M.silent=k,M}return{update:A,snapshot:M,bands:o}}function qc(e,n){for(const t of e.values()){Vi(t.left,n.left64),Vi(t.right,n.right64);for(let r=0;r<t.average.length;r++)t.average[r]=(t.left[r]+t.right[r])*.5}}function Vi(e,n){const t=n.length/e.length;for(let r=0;r<e.length;r++){let o=0;const i=Math.floor(r*t),s=Math.max(i+1,Math.floor((r+1)*t));for(let a=i;a<s;a++)o+=n[a];e[r]=o/(s-i)}}const zt={STOPPED:0,PLAYING:1,PAUSED:2};class Ne{constructor(n,t,r){this.x=Number(n)||0,this.y=Number(t)||0,this.z=Number(r)||0}add(n){return new Ne(this.x+n.x,this.y+n.y,this.z+n.z)}subtract(n){return new Ne(this.x-n.x,this.y-n.y,this.z-n.z)}multiply(n){if(n!==null&&typeof n=="object")return new Ne(this.x*n.x,this.y*n.y,this.z*n.z);const t=Number(n)||0;return new Ne(this.x*t,this.y*t,this.z*t)}divide(n){const t=Number(n)||1;return new Ne(this.x/t,this.y/t,this.z/t)}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}copy(){return new Ne(this.x,this.y,this.z)}toArray(){return[this.x,this.y,this.z]}}function Yc(e,n,t){return new Ne(e,n,t)}const Zc=[{title:"\u591C\u822A\u661F",artist:"\u76F8\u4F4D\u8FC1\u79FB",album:"\u6DF1\u7A7A\u56DE\u58F0",albumArtist:"\u76F8\u4F4D\u8FC1\u79FB",duration:212,colors:{primary:[.24,.42,.86],secondary:[.12,.18,.42],tertiary:[.62,.74,.98],text:[.95,.97,1]},lyrics:[[0,"\u5728\u65E0\u5149\u7684\u822A\u9053\u4E0A"],[12,"\u6211\u4EEC\u53EA\u5E26\u8D70\u5F7C\u6B64\u7684\u540D\u5B57"],[26,"\u5F15\u64CE\u4F4E\u9E23\u50CF\u4E00\u53E5\u65E7\u8BFA\u8A00"],[41,"\u628A\u9ED1\u6697\u6298\u6210\u4E24\u534A"],[58,"\u591C\u822A\u661F\u554A"],[72,"\u522B\u5728\u4E2D\u9014\u7184\u706D"],[95,"\uFF08\u95F4\u594F\uFF09"],[126,"\u5982\u679C\u5750\u6807\u7EC8\u5C06\u5931\u6548"],[140,"\u5C31\u8BA9\u8F68\u8FF9\u81EA\u5DF1\u8BF4\u8BDD"],[158,"\u6211\u4EEC\u4E0D\u8FD4\u822A"],[176,"\u4E5F\u4E0D\u9057\u61BE"],[198,"\u2026\u2026"]]},{title:"Amber Lantern",artist:"Hollow Coast",album:"Tidewater",albumArtist:"Hollow Coast",duration:187,colors:{primary:[.93,.62,.24],secondary:[.44,.24,.1],tertiary:[.99,.82,.56],text:[1,.98,.93]},lyrics:[[0,"Salt on the window frame"],[14,"a lantern swinging slow"],[30,"you said the tide forgets"],[46,"but the harbour never does"],[63,"Amber lantern, burn a little longer"],[88,"(instrumental)"],[118,"Every rope remembers the knot"],[134,"every shore remembers the leaving"],[152,"burn a little longer"],[170,"for me"]]},{title:"\u82D4\u75D5",artist:"\u6797\u95F4\u7535\u53F0",album:"\u534A\u5C71\u96E8",albumArtist:"\u6797\u95F4\u7535\u53F0",duration:241,colors:{primary:[.3,.68,.44],secondary:[.1,.28,.2],tertiary:[.72,.92,.78],text:[.96,1,.97]},lyrics:[[0,"\u96E8\u505C\u5728\u7B2C\u4E09\u7EA7\u53F0\u9636"],[16,"\u82D4\u75D5\u722C\u6EE1\u4E86\u65E7\u95E8\u724C"],[33,"\u4F60\u8BF4\u6162\u4E00\u70B9\u4E5F\u6CA1\u5173\u7CFB"],[52,"\u5C71\u4E0D\u4F1A\u8D70"],[70,"\u800C\u6211\u4EEC\u6709\u7684\u662F\u65F6\u95F4"],[92,"\uFF08\u95F4\u594F\uFF09"],[130,"\u628A\u4F1E\u6536\u8D77\u6765\u5427"],[148,"\u8BA9\u6F6E\u6C14\u8BB0\u4F4F\u8FD9\u4E00\u523B"],[172,"\u6162\u4E00\u70B9"],[200,"\u771F\u7684\u6CA1\u5173\u7CFB"],[226,"\u2026\u2026"]]},{title:"Neon Ashes",artist:"VELVET//NULL",album:"Afterimage",albumArtist:"VELVET//NULL",duration:168,colors:{primary:[.86,.22,.58],secondary:[.3,.06,.22],tertiary:[.99,.64,.86],text:[1,.94,.98]},lyrics:[[0,"city bleeds into the lens"],[11,"we were only afterimage"],[24,"neon ashes on your coat"],[38,"nothing here stays lit"],[55,"burn out with me"],[76,"(drop)"],[104,"nothing here stays lit"],[122,"burn out with me"],[146,"\u2026"]]}],pr=3;function Wi(e=20260901){const n=Zc,t=n.reduce((A,h)=>A+h.duration+pr,0),r={hasMedia:!1,state:zt.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:new Ne(0,0,0),secondaryColor:new Ne(0,0,0),tertiaryColor:new Ne(0,0,0),textColor:new Ne(1,1,1),highContrastColor:new Ne(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1};let o=0,i=!1,s=0,a=0;function c(A){let h=0;const b=(A%n.length+n.length)%n.length;for(let v=0;v<b;v++)h+=n[v].duration+pr;return h}function u(A){let h=t>0?A%t:0;h<0&&(h+=t);let b=-1,v=0,T=!1;for(let V=0;V<n.length;V++){const q=n[V].duration;if(h<q){b=V,v=h;break}if(h-=q,h<pr){b=V,v=q,T=!0;break}h-=pr}b<0&&(b=n.length-1,v=n[b].duration,T=!0);const _=n[b];r.hasMedia=!0,r.trackIndex=b,r.title=_.title,r.artist=_.artist,r.album=_.album,r.albumArtist=_.albumArtist,r.duration=_.duration,r.position=v;const F=_.duration>0?v/_.duration:0;i?r.state=zt.PAUSED:T?r.state=zt.STOPPED:F>.7&&F<.76?r.state=zt.PAUSED:r.state=zt.PLAYING,r.hasThumbnail=!T;const R=_.colors;r.primaryColor=new Ne(R.primary[0],R.primary[1],R.primary[2]),r.secondaryColor=new Ne(R.secondary[0],R.secondary[1],R.secondary[2]),r.tertiaryColor=new Ne(R.tertiary[0],R.tertiary[1],R.tertiary[2]),r.textColor=new Ne(R.text[0],R.text[1],R.text[2]);const k=.2126*R.primary[0]+.7152*R.primary[1]+.0722*R.primary[2];r.highContrastColor=k>.5?new Ne(0,0,0):new Ne(1,1,1),r.lyrics=_.lyrics;let U=-1;for(let V=0;V<_.lyrics.length;V++)v>=_.lyrics[V][0]&&(U=V);return r.lyricIndex=U,r.lyricLine=U>=0?_.lyrics[U][1]:"",r}function l(A){a=Number(A)||0;const h=i?s:a+o;return u(h)}function p(A){i=!1;const h=c(A);return o=h-a,u(h)}function f(){const A=r.trackIndex<0?0:r.trackIndex+1;return p(A)}function d(){const A=r.trackIndex<0?n.length-1:r.trackIndex-1;return p(A)}function w(){return i||(s=a+o,i=!0,r.state=zt.PAUSED),r}function M(){return i?(i=!1,o=s-a,u(s)):r}function m(){return i?M():w()}return{update:l,snapshot:r,tracks:n,cycle:t,MEDIA_PLAYBACK:zt,skipNext:f,skipPrevious:d,play:M,pause:w,playPause:m}}function Kc(e,n=512){const t=Math.max(8,n|0),r=new Uint8Array(t*t*4),o=e&&e.colors?e.colors:{primary:[.5,.5,.5],secondary:[.1,.1,.1],tertiary:[.8,.8,.8]},[i,s,a]=o.primary,[c,u,l]=o.secondary,[p,f,d]=o.tertiary;for(let w=0;w<t;w++)for(let M=0;M<t;M++){const m=M/(t-1),A=w/(t-1),h=m-.5,b=A-.5,v=Math.sqrt(h*h+b*b)*2,T=.5+.5*Math.sin(v*18-1.2),_=.5+.5*Math.sin((m+A)*6),F=Math.min(1,Math.max(0,v));let R=i*(1-F)+c*F,k=s*(1-F)+u*F,U=a*(1-F)+l*F;R=R*(.72+.28*T)+p*.18*_,k=k*(.72+.28*T)+f*.18*_,U=U*(.72+.28*T)+d*.18*_;const V=1-.35*Math.min(1,v*v),q=(w*t+M)*4;r[q]=Math.max(0,Math.min(255,Math.round(R*V*255))),r[q+1]=Math.max(0,Math.min(255,Math.round(k*V*255))),r[q+2]=Math.max(0,Math.min(255,Math.round(U*V*255))),r[q+3]=255}return{width:t,height:t,rgba:r}}function Qc(e,n){const t=[];if(!n)return t;const r=!e;return(r||e.hasMedia!==n.hasMedia)&&t.push({name:"mediaStatusChanged",event:{enabled:n.hasMedia}}),(r||e.title!==n.title||e.artist!==n.artist||e.album!==n.album||e.albumArtist!==n.albumArtist)&&t.push({name:"mediaPropertiesChanged",event:{title:n.title,artist:n.artist,album:n.album,albumArtist:n.albumArtist,albumTitle:n.album,subTitle:"",trackType:"music"}}),(r||e.hasThumbnail!==n.hasThumbnail||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaThumbnailChanged",event:{hasThumbnail:n.hasThumbnail,primaryColor:n.primaryColor,secondaryColor:n.secondaryColor,tertiaryColor:n.tertiaryColor,textColor:n.textColor,highContrastColor:n.highContrastColor}}),(r||e.state!==n.state)&&t.push({name:"mediaPlaybackChanged",event:{state:n.state}}),(r||Math.floor(e.position)!==Math.floor(n.position)||e.duration!==n.duration)&&t.push({name:"mediaTimelineChanged",event:{position:n.position,duration:n.duration}}),(r||e.lyricIndex!==n.lyricIndex||e.trackIndex!==n.trackIndex)&&t.push({name:"mediaLyricsChanged",event:{line:n.lyricLine,index:n.lyricIndex,lines:n.lyrics}}),t}function Jc(e){return e?{hasMedia:e.hasMedia,state:e.state,title:e.title,artist:e.artist,album:e.album,albumArtist:e.albumArtist,position:e.position,duration:e.duration,hasThumbnail:e.hasThumbnail,trackIndex:e.trackIndex,lyricIndex:e.lyricIndex,lyricLine:e.lyricLine}:null}const el=Object.freeze(Object.defineProperty({__proto__:null,MEDIA_PLAYBACK:zt,cloneMediaSnapshot:Jc,createSimulatedMedia:Wi,diffMediaEvents:Qc,mediaVec3:Yc,renderThumbnail:Kc},Symbol.toStringTag,{value:"Module"})),Hi=14,$n=[{app:"Safari",title:"GitHub \xB7 we-scene-renderer",url:"https://github.com/oneincase/we-scene-renderer"},{app:"Google Chrome",title:"YouTube",url:"https://www.youtube.com/watch?v=dQw4w9WgXcQ"},{app:"Google Chrome",title:"Wallpaper Engine - Workshop",url:"https://steamcommunity.com/app/431960/workshop/"},{app:"Safari",title:"MDN Web Docs",url:"https://developer.mozilla.org/en-US/docs/Web/API"},{app:"Music",title:"\u591C\u822A\u661F \u2014 \u76F8\u4F4D\u8FC1\u79FB",url:""},{app:"Code",title:"we-scene-renderer \u2014 text.js",url:""}];function Xi(){const e={app:"",title:"",url:"",index:-1};function n(t){const r=Number(t)||0,o=$n.length?Math.floor(r/Hi)%$n.length:0,i=$n[o]||$n[0];return e.app=i.app,e.title=i.title,e.url=i.url,e.index=o,e}return n(0),{update:n,snapshot:e,tabs:$n,hold:Hi}}function Gi(e){const n={name:"",at:0};function t(r){return n.name=String(r||""),n.at=Date.now(),typeof e=="function"&&e(n.name),n.name}return{openUserShortcut:t,last:n}}function tl(e){const n=Wi(e),t=Xi(),r=Gi(null);return{media:n,windowTitle:t,shortcuts:r}}const nl=Object.freeze(Object.defineProperty({__proto__:null,createShortcutHandler:Gi,createSimulatedSystem:tl,createSimulatedWindowTitle:Xi},Symbol.toStringTag,{value:"Module"}));function rl(e={}){const n=e.target||(typeof window<"u"?window:null),t=e.viewport||(typeof window<"u"?()=>({w:window.innerWidth||1,h:window.innerHeight||1}):null),r={u:.5,v:.5,screenX:0,screenY:0,wx:0,wy:0,originY:null,lastU:.5,lastV:.5,lastScreenX:0,lastScreenY:0,lastWx:0,lastWy:0,lastOriginY:null,leftDown:!1,has:!1,moveCount:0,downCount:0,upCount:0,lastEventTime:0,screenW:1,screenH:1};function o(){if(!t)return;const f=t();r.screenW=f.w||1,r.screenH=f.h||1}o();function i(f,d){const w=f/r.screenW,M=d/r.screenH;r.has||(r.lastU=w,r.lastV=M,r.lastScreenX=f,r.lastScreenY=d),r.screenX=f,r.screenY=d,r.u=w,r.v=M,r.has=!0,r.moveCount++,r.lastEventTime=Date.now()}function s(f){const d=(f&1)!==0;d!==r.leftDown&&(r.leftDown=d,d?r.downCount++:r.upCount++,r.lastEventTime=Date.now())}function a(f){o();let d=f.clientX,w=f.clientY;if(n&&typeof n.getBoundingClientRect=="function"){const M=n.getBoundingClientRect();d-=M.left,w-=M.top}i(d,w)}function c(f){f.button!==void 0&&f.button!==0||s(1)}function u(f){f.button!==void 0&&f.button!==0||s(0)}function l(){s(0)}let p=!1;return n&&n.addEventListener&&(p=!0,n.addEventListener("mousemove",a,{passive:!0}),n.addEventListener("mousedown",c,{passive:!0}),n.addEventListener("mouseup",u,{passive:!0}),n.addEventListener("blur",l,{passive:!0}),typeof document<"u"&&document.addEventListener&&document.addEventListener("mouseleave",l,{passive:!0})),{state:r,pushExternal(f){if(!f)return;o();const d=Number(f.u),w=Number(f.v);Number.isFinite(d)&&Number.isFinite(w)&&i(d*r.screenW,w*r.screenH),s(Number(f.buttons)||0)},pushExternalLeave(){s(0)},beginFrame(){o(),r.lastU=r.u,r.lastV=r.v,r.lastScreenX=r.screenX,r.lastScreenY=r.screenY,r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY},syncWorld(f,d=0,w=0){if(!f)return;r.wx=f.offX+r.u*f.viewW-d,r.wy=f.offY+r.v*f.viewH-w;const M=Number(f.projH);r.originY=Number.isFinite(M)?M-r.wy:r.wy,r.lastWx===0&&r.lastWy===0&&(r.lastWx=r.wx,r.lastWy=r.wy,r.lastOriginY=r.originY)},normalizedDelta(){const f=r.u-r.lastU,d=r.v-r.lastV;return Math.hypot(f,d)},dispose(){!p||!n||!n.removeEventListener||(p=!1,n.removeEventListener("mousemove",a),n.removeEventListener("mousedown",c),n.removeEventListener("mouseup",u),n.removeEventListener("blur",l),typeof document<"u"&&document.removeEventListener&&document.removeEventListener("mouseleave",l))}}}const ol=Object.freeze(Object.defineProperty({__proto__:null,createPointerSource:rl},Symbol.toStringTag,{value:"Module"}));function qi(e,n,t,r,o,i,s){const a=e.size||[0,0],c=e.scale||[1,1,1],u=a[0]*c[0],l=a[1]*c[1];if(!(u>0)||!(l>0))return null;const p=e.origin||[0,0,0];let f=p[0],d=r-p[1];if(e.parallaxDepth&&(o!==0||i!==0)){const h=e.parallaxDepth,b=gn(h[0]),v=gn(h[1]);f+=b*o,d+=v*i}let w=n-f,M=t-d;const m=e.angles?e.angles[2]:0;if(m){const h=Math.cos(-m),b=Math.sin(-m),v=w*h+M*b,T=-w*b+M*h;w=v,M=T}const A=s&&s[e.alignment]||[.5,.5];return(A[0]!==.5||A[1]!==.5)&&(w-=(.5-A[0])*u,M-=(.5-A[1])*l),{lx:w/u,ly:M/l,w:u,h:l}}function il(e,n,t,r,o={}){if(!e||e.length===0)return null;const i=o.parOffX||0,s=o.parOffY||0,a=o.alignTable,c=o.filter;for(let u=e.length-1;u>=0;u--){const l=e[u];if(!l||!l.visible||l.destroyed||c&&!c(l))continue;const p=qi(l,n,t,r,i,s,a);if(p&&Math.abs(p.lx)<=.5&&Math.abs(p.ly)<=.5)return l}return null}const sl=Object.freeze(Object.defineProperty({__proto__:null,hitTestLayers:il,worldToLayerLocal:qi},Symbol.toStringTag,{value:"Module"})),We=e=>e,He=We(Ms),hr=We(Is),Ye=We(Zs),Mt=We(ea),De=We(ka),al=We(Ua),cl=We(ja),Qt=We(rc),jn=We(xc),Qe=We(jc),ll=We(Vc),xe=We(el),Yi=We(nl),Zi=We(Pa),ul=We(ol),fl=We(sl);function dl(e,n,t){return{camera:null,general:{orthogonalprojection:{width:e,height:n},clearenabled:!0,clearcolor:"0 0 0"},layers:[{id:0,name:"media",visible:!0,image:t,textureName:t,particle:null,puppet:null,solid:!1,isContainer:!1,isPostProcess:!1,isText:!1,isSound:!1,isComponent:!1,sound:[],origin:[e/2,n/2,0],scale:[1,1,1],angles:[0,0,0],size:[e,n],alignment:"center",color:[1,1,1],alpha:1,brightness:1,colorBlendMode:0,copybackground:!1,parallaxDepth:null,animationLayers:[],effects:[]}],properties:{}}}async function pl(e){const n=await fetch(e);if(!n.ok)throw new Error(`HTTP ${n.status}`);const t=new window.ImageDecoder({data:await n.arrayBuffer(),type:"image/gif"});await t.tracks.ready,await t.completed;const r=t.tracks.selectedTrack;if(!r||!r.frameCount)return null;const o=Math.min(r.frameCount,300),i=[];let s=0,a=0;for(let c=0;c<o;c++){const{image:u}=await t.decode({frameIndex:c});s=u.displayWidth,a=u.displayHeight,i.push({bitmap:await createImageBitmap(u),durationMs:u.duration?u.duration/1e3:100}),u.close()}return t.close?.(),{width:s,height:a,frames:i}}function hl(e,n){if(Zt(e),!n.src){e.fallbackPage?.();return}const t=n.type==="video",r=n.type==="gif",o=document.createElement("canvas"),i=Ut(e,n);if(o.width=Math.max(1,Math.round(innerWidth*i)),o.height=Math.max(1,Math.round(innerHeight*i)),o.style.cssText="position:absolute;inset:0;width:100%;height:100%;",!o.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0})){se(e,n,`media ${n.type}: WEBGL2_UNAVAILABLE\uFF0C\u56DE\u9000 DOM \u6E32\u67D3`),t?ml(e,n):gl(e,n);return}e.wrap?.appendChild(o),e.canvas=o;let a=!1;e.sceneCleanup=()=>{a=!0,e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let c,u,l=!1;e.sceneCtl={pause(){c?.()},resume(){u?.()},applyUserProperties(){}};const p=f=>{a||(a=!0,se(e,n,`media ${n.type} \u5931\u8D25: ${f}`),e.fallbackPage?.())};(async()=>{try{const f=De.createRenderer(o,{diag:k=>se(e,n,`renderer: ${k}`),fboCapFactor:0});if(e.renderer=f,a)return;const d="__media",w=new Map;let M,m=0,A=0;if(t){const k=document.createElement("video");if(k.autoplay=!0,k.loop=n.loop!==!1,k.muted=n.muted!==!1,k.playsInline=!0,k.preload="metadata",k.width=o.width,k.height=o.height,k.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",k.src=n.src,document.body.appendChild(k),e.video=k,(e.videoTextures??=[]).push(k),await new Promise((U,V)=>{k.addEventListener("loadedmetadata",()=>U(),{once:!0}),k.addEventListener("error",()=>V(new Error(`video error ${k.error?.code??"?"}`)),{once:!0})}),a)return;m=k.videoWidth||o.width,A=k.videoHeight||o.height,w.set(d,{video:k,glTex:De.makeTexture(f.gl,new Uint8Array([0,0,0,255]),1,1),width:m,height:A,rg88:!1,lastUploaded:-1}),e.paused||k.play().catch(()=>{}),se(e,n,`media video ${m}x${A} \u2192 scene \u6E32\u67D3`)}else{let k=!1;if(r&&typeof window.ImageDecoder=="function")try{const U=await pl(n.src);if(U&&U.frames.length>1){m=U.width,A=U.height;const V=f.gl,q={glTex:De.makeTexture(V,null,0,0,U.frames[0].bitmap),width:m,height:A,rg88:!1};w.set(d,q);let W=0,Z=performance.now()+U.frames[0].durationMs;M=()=>{const re=performance.now();if(!(re<Z)){W=(W+1)%U.frames.length,Z=re+U.frames[W].durationMs,V.bindTexture(V.TEXTURE_2D,q.glTex);try{V.texImage2D(V.TEXTURE_2D,0,V.RGBA,V.RGBA,V.UNSIGNED_BYTE,U.frames[W].bitmap)}catch{}}};const K=e.sceneCleanup;e.sceneCleanup=()=>{K?.();for(const re of U.frames)re.bitmap.close()},k=!0,se(e,n,`media gif ${m}x${A} ${U.frames.length} \u5E27 \u2192 scene \u6E32\u67D3`)}}catch(U){se(e,n,`gif \u89E3\u7801\u5931\u8D25\uFF0C\u56DE\u9000\u9759\u6001\u9996\u5E27: ${String(U.message).slice(0,80)}`)}if(!k){const U=new Image;if(U.crossOrigin="anonymous",U.src=n.src,await new Promise((V,q)=>{U.addEventListener("load",()=>V(),{once:!0}),U.addEventListener("error",()=>q(new Error("image load error")),{once:!0})}),a)return;m=U.naturalWidth||1,A=U.naturalHeight||1,e.img=U,w.set(d,{glTex:De.makeTexture(f.gl,null,0,0,U),width:m,height:A,rg88:!1}),se(e,n,`media ${n.type} ${m}x${A} \u2192 scene \u6E32\u67D3`)}}if(a)return;const h=dl(m,A,d),b=performance.now();let v=0,T=0,_=-1/0;const F=k=>{if(a||e.paused)return;const U=e.cfg.sceneFps||60;if(k-_>=1e3/U){_=k,qn(e,k),xo(e,o,e.cfg),M?.();const V=e.coverAlign;f.render(h,w,o.width,o.height,(k-b-v)/1e3,un(e.cfg.fit),V.x,V.y).then(()=>{a||e.paused||(e.raf=requestAnimationFrame(F))}).catch(q=>p(String(q.message||q).slice(0,200)))}else e.paused||(e.raf=requestAnimationFrame(F))},R=()=>{a||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(F))};c=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),T||(T=performance.now());const k=e.video;l=!!(k&&!k.paused&&!k.ended),k?.pause()},u=()=>{T&&(v+=performance.now()-T,T=0),l&&e.video?.play().catch(()=>{}),l=!1,R()},R()}catch(f){p(String(f.message||f).slice(0,200))}})()}function ml(e,n){if(Zt(e),!n.src){e.fallbackPage?.();return}const t=bo(n.fit),r=`position:absolute;inset:0;width:100%;height:100%;object-fit:${t.objectFit};object-position:50% 50%;background:${t.background};`;let o=!1;const i=()=>{o||(o=!0,console.warn("video error, fallback to default wallpaper"),e.fallbackPage?.())},s=document.createElement("video");s.autoplay=!0,s.loop=n.loop!==!1,s.muted=n.muted!==!1,s.playsInline=!0,s.preload="metadata";const a=Math.min(window.devicePixelRatio||1,e.cfg.renderDpr||1);s.width=Math.max(1,Math.round(innerWidth*a)),s.height=Math.max(1,Math.round(innerHeight*a)),s.style.cssText=r,s.src=n.src,s.addEventListener("error",i),e.wrap?.appendChild(s),e.video=s,s.addEventListener("canplay",()=>s.play().catch(()=>{}),{once:!0}),se(e,n,"video mounted (single + native loop)")}function gl(e,n){Zt(e);const t=document.createElement("img"),r=bo(n.fit);t.style.cssText=`position:absolute;inset:0;width:100%;height:100%;object-fit:${r.objectFit};object-position:50% 50%;background:${r.background};`,t.src=n.src??"",t.addEventListener("error",()=>e.fallbackPage?.()),e.wrap?.appendChild(t),e.img=t}const bl=["scene.pkg","scenes/scene.pkg","gifscene.pkg"];function Ki(e,n){const t=e.replace(/\/+$/,"");return{key:t,async scenePkg(r){let o=null,i=null;for(const a of bl){let c;try{c=await fetch(`${t}/${a}`,{...n,signal:r})}catch(u){if(r?.aborted)throw u;i=u;continue}if(!c.ok){o=c.status;continue}try{return await c.arrayBuffer()}catch(u){if(r?.aborted)throw u;const l=u instanceof Error?u.message:String(u);throw new Error(`\u8BFB\u53D6 scene.pkg \u4F53\u5931\u8D25\uFF08${l}\uFF09`)}}if(o!=null)throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08HTTP ${o}\uFF09`);const s=i instanceof Error?i.message:"Failed to fetch";throw new Error(`scene.pkg \u52A0\u8F7D\u5931\u8D25\uFF08${s}\uFF09`)},async project(r){try{const o=await fetch(`${t}/project.json`,{...n,signal:r});return o.ok?await o.json():null}catch{return null}},async webEntry(r){let o="index.html";try{const i=await fetch(`${t}/project.json`,{...n,signal:r});if(i.ok){const s=await i.json();s&&typeof s.file=="string"&&s.file.trim()&&(o=s.file.trim().replace(/^\/+/,""))}}catch{if(r?.aborted)throw new Error("aborted")}return{url:`${t}/${o}`}}}}function yl(e,n){const t=e;return{key:typeof t.name=="string"?`file:${t.name}:${t.size}:${t.lastModified??0}`:void 0,scenePkg:()=>e.arrayBuffer(),project:async()=>n??null}}function vl(e,n,t){return{key:t,scenePkg:async()=>e,project:async()=>n??null}}const Qi=.5,xl=.04,Ji=.08;function wl(e,n){const t=h=>{const b=document.createElement("video");h&&(b.src=e),b.muted=n.muted,b.playsInline=!0,b.preload="metadata";const v=Math.min(window.devicePixelRatio||1,n.renderDpr||1),T=Math.max(1,Math.round(n.maxW*v)),_=Math.max(1,Math.round(n.maxH*v));return b.width=T,b.height=_,b.loop=!0,b};let r=t(!0),o=t(!1),i=!1,s=1,a=n.muted;o.muted=!0;const c=()=>{i||(o.src=e,i=!0)};let u=!1,l=!1,p=-1,f=0,d=!1;const w=()=>{if(u=!1,l=!1,!o.paused){o.pause();try{o.currentTime=0}catch{}}},M=()=>{const h=r;r=o,o=h,u=!1,l=!1,r.play().catch(()=>{}),r.muted=a,r.volume=s,h.pause();try{h.currentTime=0}catch{}h.muted=!0,p=-1,i=!0,A.onSwap?.(r)},m=()=>{if(d)return;f=requestAnimationFrame(m);const h=r.duration;if(!isFinite(h)||h<=0)return;const b=r.currentTime;if(p>=0&&b<p-.05){const T=l;w(),p=b,T||A.onFallback?.();return}p=b;const v=h-b;if(v>Qi+.5){(u||l)&&w();return}if(l){(v<=Ji||b<=Ji)&&M();return}if(u){o.paused?o.play().catch(()=>{}):o.currentTime>=xl*.5&&(o.pause(),u=!1,l=!0);return}if(v<=Qi&&(c(),o.readyState>=2)){try{o.currentTime=0}catch{}o.play().catch(()=>{}),u=!0}};f=requestAnimationFrame(m);const A={get active(){return r},get standby(){return o},onSwap:void 0,onFallback:void 0,setVolume(h){s=Math.max(0,Math.min(1,h)),a=h<=0,r.muted=a,r.volume=s,o.muted=!0,o.volume=s},pause(){w(),r.pause(),f&&cancelAnimationFrame(f),f=0},resume(){d||(r.play().catch(h=>{h&&h.name}),f||(f=requestAnimationFrame(m)))},destroy(){d=!0,f&&cancelAnimationFrame(f),f=0;for(const h of[r,o]){h.pause(),h.removeAttribute("src");try{h.load()}catch{}h.remove()}}};return A}const es=!1,ts=!0,ns=!1,Ml=!1,_l=!1,rs=4,zn=64,os={STOPPED:0};function Al(){return{left64:new Float32Array(zn),right64:new Float32Array(zn),left32:new Float32Array(32),right32:new Float32Array(32),left16:new Float32Array(16),right16:new Float32Array(16),level:0,silent:!0}}function mr(e,n){const t=n.length/e.length;for(let r=0;r<e.length;r++){let o=0;const i=Math.floor(r*t),s=Math.max(i+1,Math.floor((r+1)*t));for(let a=i;a<s;a++)o+=n[a];e[r]=o/(s-i)}}function Tl(e,n,t){const r=n.length,o=t*.5,i=20,s=Math.min(2e4,o);let a=0;for(let c=0;c<zn;c++){const u=c/zn,l=(c+1)/zn,p=i*Math.pow(s/i,u),f=i*Math.pow(s/i,l),d=Math.max(0,Math.floor(p/o*r)),w=Math.min(r,Math.max(d+1,Math.ceil(f/o*r)));let M=0;for(let A=d;A<w;A++)M+=n[A]/255;const m=Math.min(1,M/(w-d)*1.35);e.left64[c]=m,e.right64[c]=m,c<48&&(a+=m)}mr(e.left32,e.left64),mr(e.right32,e.right64),mr(e.left16,e.left64),mr(e.right16,e.right64),e.level=Math.min(1,a/(48*1.2)),e.silent=e.level<.02}function Sl(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619);return(n>>>0)%360}function lo(e,n,t){const r=n/100,o=t/100,i=(1-Math.abs(2*o-1))*r,s=e/60,a=i*(1-Math.abs(s%2-1));let c=0,u=0,l=0;s<1?[c,u,l]=[i,a,0]:s<2?[c,u,l]=[a,i,0]:s<3?[c,u,l]=[0,i,a]:s<4?[c,u,l]=[0,a,i]:s<5?[c,u,l]=[a,0,i]:[c,u,l]=[i,0,a];const p=o-i/2;return[c+p,u+p,l+p]}function El(e,n){const t=Sl(n||"empty"),[r,o,i]=lo(t,72,48),[s,a,c]=lo((t+40)%360,55,28),[u,l,p]=lo((t+20)%360,70,72);e.primaryColor=xe.mediaVec3(r,o,i),e.secondaryColor=xe.mediaVec3(s,a,c),e.tertiaryColor=xe.mediaVec3(u,l,p),e.textColor=xe.mediaVec3(.98,.98,1),e.highContrastColor=xe.mediaVec3(1,1,1),e.hasThumbnail=!!n}function Pl(e,n,t){const r=document.createElement("canvas");r.width=32,r.height=32;const o=r.getContext("2d",{willReadFrequently:!0});if(!o)return null;o.drawImage(e,0,0,n,t,0,0,32,32);const i=o.getImageData(0,0,32,32).data;let s=0,a=0,c=0,u=0,l=0,p=0,f=0,d=-1;for(let A=0;A<i.length;A+=4){const h=i[A]/255,b=i[A+1]/255,v=i[A+2]/255;s+=h,a+=b,c+=v,u++;const T=Math.max(h,b,v),_=Math.min(h,b,v),F=T-_,R=.2126*h+.7152*b+.0722*v,k=F*1.4+(R>.15&&R<.85?.3:0);k>d&&(d=k,l=h,p=b,f=v)}if(!u)return null;const w=[l,p,f],M=[s/u*.55,a/u*.55,c/u*.55],m=[Math.min(1,w[0]*.45+.55),Math.min(1,w[1]*.45+.55),Math.min(1,w[2]*.45+.55)];return{primary:w,secondary:M,tertiary:m}}function Cl(e,n,t,r=512){const o=document.createElement("canvas");o.width=r,o.height=r;const i=o.getContext("2d"),s=Math.max(r/Math.max(1,n),r/Math.max(1,t)),a=n*s,c=t*s;i.fillStyle="#000",i.fillRect(0,0,r,r),i.drawImage(e,(r-a)/2,(r-c)/2,a,c);const u=i.getImageData(0,0,r,r);return{width:r,height:r,rgba:new Uint8Array(u.data)}}function Ll(){return{hasMedia:!1,state:os.STOPPED,title:"",artist:"",album:"",albumArtist:"",position:0,duration:0,hasThumbnail:!1,primaryColor:xe.mediaVec3(0,0,0),secondaryColor:xe.mediaVec3(0,0,0),tertiaryColor:xe.mediaVec3(0,0,0),textColor:xe.mediaVec3(1,1,1),highContrastColor:xe.mediaVec3(1,1,1),trackIndex:-1,lyrics:[],lyricLine:"",lyricIndex:-1}}async function Rl(){if(!navigator.mediaDevices?.getUserMedia)return null;try{const e=await navigator.mediaDevices.getUserMedia({audio:{echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1},video:!1}),n=new AudioContext,t=n.createMediaStreamSource(e),r=n.createAnalyser();return r.fftSize=2048,r.smoothingTimeConstant=.8,t.connect(r),n.state==="suspended"&&await n.resume().catch(()=>{}),{ctx:n,stream:e,analyser:r,buf:new Uint8Array(r.frequencyBinCount)}}catch{return null}}async function Fl(e){const n=e?.origin??(typeof location<"u"?location.origin:""),t=e?.onArtwork,r=Al(),o=Ll(),i={app:"",title:"",url:"",index:0};let s="off",a="offline",c="offline",u="",l=!1,p="";const f=await Rl();f?s="mic":navigator.mediaDevices?.getUserMedia?s="denied":s="unavailable";let d=null,w=null,M=!1;const m=(T,_,F)=>{!n||!t||!l||p!==T&&(p=T,t({url:`${n}/api/system/artwork?k=${encodeURIComponent(T)}&_=${Date.now()}`,trackKey:T,title:_,artist:F}))},A=T=>{if(!T||!T.hasMedia){o.hasMedia=!1,o.state=os.STOPPED,o.title="",o.artist="",o.album="",o.albumArtist="",o.position=0,o.duration=0,o.hasThumbnail=!1,o.trackIndex=-1,a=T?"empty":"offline",u="",l=!1,p="";return}a="live",o.hasMedia=!0,o.state=Number(T.state)===2?2:Number(T.state)===1?1:0,o.title=String(T.title??""),o.artist=String(T.artist??""),o.album=String(T.album??""),o.albumArtist=String(T.albumArtist??T.artist??""),o.position=Number(T.position)||0,o.duration=Number(T.duration)||0,l=T.hasArtwork===!0;const _=`${o.title}|${o.artist}|${o.album}`;_!==u&&(u=_,p="",o.trackIndex=o.trackIndex+1|0,El(o,_)),m(_,o.title,o.artist)},h=T=>{if(!T){c="offline";return}i.app=String(T.app??""),i.title=String(T.title??""),i.url=String(T.url??""),c=i.app||i.title?"live":"empty"},b=async()=>{if(!(!n||M))try{const[T,_]=await Promise.all([fetch(`${n}/api/system/media`,{cache:"no-store"}),fetch(`${n}/api/system/window`,{cache:"no-store"})]);if(T.ok){const F=await T.json();A(F)}else a="offline";_.ok&&h(await _.json())}catch{a=a==="live"?"live":"offline",c=c==="live"?"live":"offline"}};if(n){await b(),w=setInterval(()=>{b()},1e3);try{d=new EventSource(`${n}/api/system/stream`),d.onmessage=T=>{if(!M)try{const _=JSON.parse(T.data);A(_.media),h(_.window)}catch{}}}catch{}}const v=T=>{!n||M||fetch(`${n}/api/system/media-control`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:T})}).then(async _=>_.ok?_.json():null).then(_=>{_&&typeof _=="object"&&A(_),b()}).catch(()=>{b()})};return{audio:{snapshot:r,pump:()=>{if(!f||M){r.level=0,r.silent=!0;return}f.analyser.getByteFrequencyData(f.buf),Tl(r,f.buf,f.ctx.sampleRate||48e3)}},media:{snapshot:o,pump:()=>{},skipNext:()=>v("skipNext"),skipPrevious:()=>v("skipPrevious"),play:()=>v("play"),pause:()=>v("pause"),playPause:()=>v("playPause")},windowTitle:{snapshot:i,pump:()=>{}},status:()=>({audio:s,media:a,window:c,title:o.title,artist:o.artist,app:i.app,windowTitle:i.title,hasArtwork:l}),dispose:()=>{M=!0,w&&(clearInterval(w),w=null);try{d?.close()}catch{}if(d=null,f)try{f.stream.getTracks().forEach(T=>T.stop()),f.ctx.close()}catch{}}}}const kl={"common.h":`// WE common.h\uFF08\u91CD\u5EFA\u5B50\u96C6\uFF0C\u4F9B we-scene \u6D4F\u89C8\u5668\u6E32\u67D3\uFF09
|
|
176
182
|
#define M_PI 3.14159265359
|
|
177
183
|
// M_PI_2 \u662F\u300CPI \xD7 2\u300D\u800C\u4E0D\u662F\u300CPI \xF7 2\u300D\u2014\u2014 \u540D\u5B57\u6781\u6613\u8BFB\u53CD\uFF0C\u6B64\u524D\u8BEF\u5199\u6210 1.5708\uFF0C
|
|
178
184
|
// \u5F71\u54CD\u5168\u5E93 142 \u4E2A\u6587\u4EF6\uFF0864 \u4E2A\u58C1\u7EB8\uFF09\u3002\u4E09\u6761\u72EC\u7ACB\u8BC1\u636E\uFF1A
|
|
@@ -419,10 +425,18 @@ mat3 squareToQuad(vec2 p0, vec2 p1, vec2 p2, vec2 p3) {
|
|
|
419
425
|
float d = p1.y - p0.y + g * p1.y;
|
|
420
426
|
float e = p3.y - p0.y + h * p3.y;
|
|
421
427
|
float f = p0.y;
|
|
422
|
-
// \
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
428
|
+
// \u8C03\u7528\u70B9\u4E00\u5F8B\u662F mul(vec3(uv,1), inverse(\u672C\u51FD\u6570\u7ED3\u679C))\uFF0Chlsl2glsl \u628A\u5B83\u8F6C\u5199\u6210
|
|
429
|
+
// transpose(xform) * vec3(uv,1)\u3002\u8981\u8BA9\u5C4F\u5E55\u70B9 s \u5F97\u5230 texCoord = S\u207B\xB9\xB7s\uFF08S \u4E3A
|
|
430
|
+
// Heckbert \u6B63\u5411\u77E9\u9635 [[a,b,c],[d,e,f],[g,h,1]]\uFF0C\u5355\u4F4D\u65B9\u2192\u56DB\u8FB9\u5F62\uFF09\uFF0C\u5FC5\u987B
|
|
431
|
+
// xform = inverse(\u672C\u51FD\u6570\u7ED3\u679C) \u6EE1\u8DB3 transpose(xform)\xB7s = S\u207B\xB9\xB7s\uFF0C
|
|
432
|
+
// \u5373\u672C\u51FD\u6570\u8FD4\u56DE S \u7684**\u8F6C\u7F6E**\uFF1Amat3 \u5217\u4E3B\u5E8F\u6784\u9020\u4E3A (a,d,g)(b,e,h)(c,f,1) \u7684\u8F6C\u7F6E
|
|
433
|
+
// = (a,b,c)(d,e,f)(g,h,1)\u3002\u6392\u5E03\u5DEE\u4E00\u4E2A\u8F6C\u7F6E\uFF0Cperspective/\u6C34\u6CE2\u7B49\u5168\u90E8\u9519\u4F4D\u2014\u2014
|
|
434
|
+
// 3174556087 \u7684\u97F3\u8C31\u67F1\u88AB\u8D34\u5230\u7A97\u6237\u4FA7\u8FB9\u7AD6\u6392\uFF08\u5E94\u4E3A\u8D34\u4E0B\u7A97\u6CBF\u6A2A\u6392\uFF09\u5B9E\u6D4B\u786E\u8BA4\u3002
|
|
435
|
+
// 2026-09-05 \u6570\u503C\u6A21\u62DF\uFF1A\u65E7\u6392\u5E03 transpose(S\u207B\xB9)\xB7corner \u4E0E\u6B63\u786E S\u207B\xB9\xB7corner \u9010\u9879\u4E0D\u540C\uFF0C
|
|
436
|
+
// \u53EF\u89C1\u533A\u584C\u7F29\u6210\u4E00\u6761\u659C\u5E26\uFF1B\u65B0\u6392\u5E03\u540E\u4E2D\u5FC3 (0.5,0.5) \u2192 (0.478,0.511) \u2208 [0,1]\xB2\u3002
|
|
437
|
+
return mat3(a, b, c,
|
|
438
|
+
d, e, f,
|
|
439
|
+
g, h, 1.0);
|
|
426
440
|
}
|
|
427
441
|
`,"common_blur.h":`// WE common_blur.h\uFF08\u91CD\u5EFA\uFF09
|
|
428
442
|
uniform sampler2D g_Texture0;
|
|
@@ -495,6 +509,1212 @@ vec3 DecompressNormal(vec4 tex) {
|
|
|
495
509
|
return vec3(xy, sqrt(clamp(1.0 - dot(xy, xy), 0.0, 1.0)));
|
|
496
510
|
}
|
|
497
511
|
`,"common_vertex.h":`// WE common_vertex.h\uFF08\u91CD\u5EFA\uFF1A\u7A7A\u5360\u4F4D\uFF0C\u89C1 headers.ts \u6CE8\u91CA\uFF09
|
|
498
|
-
`},el={systemfont_segoe:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",systemfont_arial:"Arial, 'Helvetica Neue', sans-serif",systemfont_verdana:"Verdana, Geneva, sans-serif",systemfont_tahoma:"Tahoma, Geneva, sans-serif",systemfont_timesnewroman:"'Times New Roman', Times, serif",systemfont_georgia:"Georgia, 'Times New Roman', serif",systemfont_couriernew:"'Courier New', Courier, monospace",systemfont_trebuchetms:"'Trebuchet MS', 'Helvetica Neue', sans-serif",systemfont_impact:"Impact, 'Arial Black', sans-serif",systemfont_comicsansms:"'Comic Sans MS', 'Comic Sans', cursive",systemfont_sylfaen:"Palatino, 'Times New Roman', serif",systemfont_calibri:"Calibri, Carlito, 'Helvetica Neue', sans-serif",systemfont_cambria:"Cambria, Georgia, serif",systemfont_consolas:"Consolas, 'Courier New', monospace",systemfont_microsoftyahei:"'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif",systemfont_simsun:"SimSun, 'Songti SC', serif",systemfont_simhei:"SimHei, 'Heiti SC', sans-serif"},zi=new Map,Un=new Map;async function tl(e,n,t,r){const o=t.key;if(o){const a=Un.get(o);if(a)return a.at=Date.now(),ae(e,n,`pkg cache hit: ${a.parsed.fileSize} bytes`),a.parsed}let i;try{i=await t.scenePkg(r)}catch(a){throw r.aborted||a instanceof Error?a:new Error(String(a))}ae(e,n,`pkg body: ${i.byteLength} bytes`);const s=i instanceof Uint8Array?i:new Uint8Array(i),c=De.parsePkg(s);if(!o)return c;if(Un.set(o,{parsed:c,at:Date.now()}),Un.size>2){let a=null,u=1/0;for(const[l,d]of Un)l!==o&&d.at<u&&(u=d.at,a=l);a&&Un.delete(a)}return c}function nl(e,n){tn(e);const t=n.canvas??document.createElement("canvas"),r=Ye(e,n),o=t.clientWidth||window.innerWidth||1,i=t.clientHeight||window.innerHeight||1;t.width=Math.max(1,Math.round(o*r)),t.height=Math.max(1,Math.round(i*r)),n.canvas||(t.style.cssText="position:absolute;inset:0;width:100%;height:100%;",e.wrap?.appendChild(t)),e.canvas=t;let s=!1;const c=new AbortController;let a;e.sceneCleanup=()=>{s=!0,c.abort(),e.sceneTextUpdate=void 0,a&&(a(),a=void 0),e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let u=null,l,d,h;e.sceneCtl={pause(){d?.()},resume(){h?.()},applyUserProperties(p){l?l(p):u={...u||{},...p}}},(async()=>{try{const p=n.source??Ni(`${n.mediaBase}/${n.src}`);if(!n.source&&(!n.mediaBase||!n.src))throw new Error("\u573A\u666F\u58C1\u7EB8\u7F3A\u5C11 mediaBase/src");ae(e,n,"mountScene start");const w=await tl(e,n,p,c.signal);if(s)return;let m=null;try{m=await p.project?.(c.signal)??null}catch{}if(!t.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0}))throw new Error("WEBGL2_UNAVAILABLE");const v=De.getEntry(w,"scene.json");if(!v)throw new Error("pkg \u4E2D\u6CA1\u6709 scene.json\uFF08\u4E0D\u662F\u573A\u666F\u58C1\u7EB8\uFF1F\uFF09");const b=Qe.parseScene(JSON.parse(st(v)),m);{const A=b.general?.zoom,L=Number(A&&typeof A=="object"?A.value:A);b.cameraTransforms={zoom:Number.isFinite(L)&&L>0?L:1}}const y=vs(b.properties||{});e.liveUserProps=y;const S=()=>Qe.recomputeLayerVisibility(b.layers);if(e.onSceneInfo){const A=b.general?.orthogonalprojection||{},L=Number(A.width)>0?Number(A.width):t.width,I=Number(A.height)>0?Number(A.height):t.height,U=b.layers||[],X={width:L,height:I,layerCount:U.length,hasModels:U.some(Y=>!!Y.model),hasParticles:U.some(Y=>!!Y.particle),hasText:U.some(Y=>!!Y.text)},ne=e.onSceneInfo;e.onSceneInfo=void 0,ne(X)}const _=[];Ii&&(b.layers=b.layers.filter(A=>!(Ii&&A.isComponent)));const C=A=>{const L=A.startsWith("shaders/")?A:"shaders/"+A,I=A.startsWith("shaders/")?A.slice(8):A,U=De.getEntry(w,L);let X=U?st(U):Jc[I]??null;const ne=window.__shaderPatch;if(X&&ne){const Y=I.replace(/\.(frag|vert|h)$/,""),f=ne[Y]||ne[I];if(typeof f=="function")try{const T=f(X,I);typeof T=="string"&&(X=T)}catch{}}return Promise.resolve(X)},N=ke.createRenderer(t,{shaderResolver:C,diag:A=>ae(e,n,`renderer: ${A}`),fboCapFactor:0});if(e.renderer=N,s)return;const D=m?.general?.supportsaudioprocessing!==!1,k=Mc(),O={enabled:D},j=A=>new Float32Array(A),W={left16:j(16),right16:j(16),left32:j(32),right32:j(32),left64:j(64),right64:j(64),level:0,silent:!0};N.setAudioProvider(()=>O.enabled?k.snapshot:W);const K=new Map;window.__audioStats=()=>({enabled:O.enabled,level:O.enabled?Math.round(k.snapshot.level*1e3)/1e3:0,silent:O.enabled?k.snapshot.silent:!0,bass:O.enabled?Math.round(k.snapshot.left64[2]*1e3)/1e3:0}),window.__audioMute=A=>(O.enabled=!A,O.enabled),ae(e,n,`audio: simulated stream, supportsaudioprocessing=${D}`);const V=St.createSimulatedMedia(),G=Li.createSimulatedWindowTitle(),Q=Li.createShortcutHandler(A=>{ae(e,n,`openUserShortcut: ${A}`)}),q={enabled:!0,override:null},te=[];let me=null;const xe=A=>{if(!(!A||!A.hasMediaHook||te.includes(A))&&(te.push(A),!!V.snapshot.hasMedia))for(const{name:L,event:I}of St.diffMediaEvents(null,V.snapshot))try{A.callMedia(L,I)}catch{}};window.__mediaStats=()=>({enabled:q.enabled,hooks:te.length,title:V.snapshot.title,artist:V.snapshot.artist,album:V.snapshot.album,state:V.snapshot.state,position:Math.round(V.snapshot.position),duration:V.snapshot.duration,hasThumbnail:V.snapshot.hasThumbnail,lyric:V.snapshot.lyricLine,primaryColor:V.snapshot.primaryColor?[V.snapshot.primaryColor.x,V.snapshot.primaryColor.y,V.snapshot.primaryColor.z]:null}),window.__mediaSet=A=>{Object.assign(V.snapshot,A||{});const L=St.diffMediaEvents(me,V.snapshot);for(const{name:I,event:U}of L)for(const X of te)X.callMedia(I,U);return me=St.cloneMediaSnapshot(V.snapshot),window.__mediaStats()};const We=()=>{const A=St.diffMediaEvents(me,V.snapshot);for(const{name:L,event:I}of A)for(const U of te)try{U.callMedia(L,I)}catch{}me=St.cloneMediaSnapshot(V.snapshot)},Ve={snapshot:V.snapshot,skipNext:()=>(V.skipNext(),We(),V.snapshot),skipPrevious:()=>(V.skipPrevious(),We(),V.snapshot),play:()=>(V.play(),We(),V.snapshot),pause:()=>(V.pause(),We(),V.snapshot),playPause:()=>(V.playPause(),We(),V.snapshot)};window.__mediaControl=Ve,window.__system={media:Ve,windowTitle:G.snapshot,shortcuts:Q.last};const Ee=Dc.createPointerSource(n.canvas?{target:n.canvas,viewport:()=>({w:n.canvas.clientWidth||window.innerWidth||1,h:n.canvas.clientHeight||window.innerHeight||1})}:{});N.setPointerProvider(()=>Ee);{const A=a;a=()=>{A?.(),Ee.dispose()}}const rt=qe.createInputView(),Xe=Oc.createEngineTimers({setTimeout:(A,L)=>window.setTimeout(A,L),clearTimeout:A=>window.clearTimeout(A),setInterval:(A,L)=>window.setInterval(A,L),clearInterval:A=>window.clearInterval(A)},{onError:(()=>{let A=!1;return L=>{A||(A=!0,ae(e,n,`engine \u5B9A\u65F6\u5668\u56DE\u8C03\u629B\u9519\uFF08\u6B64\u540E\u540C\u7C7B\u9759\u9ED8\uFF09: ${String(L?.message||L).slice(0,90)}`))}})()}),Pe={setTimeout:Xe.setTimeout,clearTimeout:Xe.clearTimeout,setInterval:Xe.setInterval,clearInterval:Xe.clearInterval};{const A=a;a=()=>{A?.(),Xe.dispose()}}window.__pointerStats=()=>{const A=Ee.state,L=I=>Math.round(I*1e3)/1e3;return{normalized:{u:L(A.u),v:L(A.v)},last:{u:L(A.lastU),v:L(A.lastV)},world:{x:Math.round(A.wx),y:Math.round(A.wy)},originY:A.originY!=null?Math.round(A.originY):null,screen:{x:A.screenX,y:A.screenY,w:A.screenW,h:A.screenH},leftDown:A.leftDown,has:A.has,delta:L(Ee.normalizedDelta()),counts:{move:A.moveCount,down:A.downCount,up:A.upCount}}};const Ae=new Map;Ae.set("util/white",{glTex:ke.makeTexture(N.gl,new Uint8Array([255,255,255,255]),1,1),width:1,height:1,rg88:!1}),Ae.set("util/noflow",{glTex:ke.makeTexture(N.gl,new Uint8Array([127,127,127,255]),1,1),width:1,height:1,rg88:!1}),Ae.set("util/noise",{glTex:ke.makeTexture(N.gl,Bc.generateNoiseTexture(),256,256),width:256,height:256,rg88:!1,mips:null});{const A=I=>{const U=St.renderThumbnail(I,512);return{glTex:ke.makeTextureMip(N.gl,[U],!1),width:U.width,height:U.height,rg88:!1,mips:[U],generated:!0}},L=V.tracks||[];L.length&&(Ae.set("$mediaThumbnail",A(L[0])),Ae.set("$mediaPreviousThumbnail",A(L[L.length-1])))}const Ze=new Map,to=async A=>{if(Ae.has(A))return Ae.get(A);const L=De.getEntry(w,`materials/${A}.tex`);if(!L){if(un.isBuiltinParticleTextureName(A)){const Y=un.buildBuiltinParticleTexture(A);if(Y){const f={glTex:ke.makeTextureMip(N.gl,[Y],!1),width:Y.width,height:Y.height,rg88:!1,mips:[Y],generated:!0};return Ae.set(A,f),f}}return null}const I=fr.parseTex(L),U=fr.decodeMip0(I),X=I.format===8;let ne=null;if(U.video!==void 0){const Y=URL.createObjectURL(new Blob([U.video],{type:"video/mp4"})),f=Zc(Y,{muted:!0,renderDpr:Ye(e,n),maxW:t.clientWidth||window.innerWidth||1,maxH:t.clientHeight||window.innerHeight||1});for(const R of[f.active,f.standby])R.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",document.body.appendChild(R),(e.videoTextures??=[]).push(R);(e.objectUrls??=[]).push(Y),(e.videoPairs??=[]).push(f),f.active.addEventListener("loadedmetadata",()=>{ae(e,n,`video tex '${A}': ${f.active.videoWidth}x${f.active.videoHeight}`)}),f.active.addEventListener("error",()=>{ae(e,n,`video tex '${A}' ERROR: ${f.active.error?.code}`)});const T=[],x=R=>{for(const B of T)R.addEventListener("ended",B)},M={play:()=>{s||f.resume()},pause:()=>f.pause(),stop:()=>{f.pause();try{f.active.currentTime=0}catch{}},isPlaying:()=>!f.active.paused&&!f.active.ended,duration:()=>Number.isFinite(f.active.duration)?f.active.duration:0,getCurrentTime:()=>f.active.currentTime||0,setCurrentTime:R=>{try{f.active.currentTime=R}catch{}},getRate:()=>f.active.playbackRate||1,setRate:R=>{f.active.playbackRate=R,f.standby.playbackRate=R},getLoop:()=>f.active.loop,setLoop:R=>{f.active.loop=R,f.standby.loop=R},addEndedCallback:R=>{T.push(R),f.active.addEventListener("ended",R)}},E={get video(){return f.active},glTex:ke.makeTexture(N.gl,new Uint8Array([0,0,0,0]),1,1),width:U.width,height:U.height,rg88:!1,lastUploaded:-1,videoCtl:M};let P=0;return f.onSwap=R=>{E.lastUploaded=-1,x(R),P++,(P===1||P===10||P===100)&&ae(e,n,`video tex '${A}' loop swap ok x${P}`)},f.onFallback=()=>{ae(e,n,`video tex '${A}' loop fallback (native loop used)`)},Ae.set(A,E),E}else if(U.png!==void 0||U.image!==void 0&&U.fif===fr.FIF.JPEG){const Y=new Blob([U.png||U.image],{type:U.png?"image/png":"image/jpeg"}),f=await createImageBitmap(Y);ne={glTex:ke.makeTexture(N.gl,null,0,0,f),width:f.width,height:f.height,rg88:X}}else{if(U.image!==void 0)return null;{const Y=fr.decodeMip0(I);ne={glTex:ke.makeTextureMip(N.gl,[Y],X),width:Y.width,height:Y.height,rg88:X,mips:[Y]}}}if(!ne)return null;if(I.frames?.list?.length){const Y=I.frames.list;Y.atlasWidth=ne.width,Y.atlasHeight=ne.height,ne.frames=Y}return Ae.set(A,ne),ne},lt=A=>{if(Ae.has(A))return Promise.resolve(Ae.get(A));const L=Ze.get(A);if(L)return L;const I=to(A);return Ze.set(A,I),I.finally(()=>{Ze.get(A)===I&&Ze.delete(A)}),I},He=/uniform\s+sampler2D\s+g_Texture\d+\s*;\s*\/\/[^\n]*"default"\s*:\s*"([^"]+)"/g,hr=async A=>{for(const L of A.materialPasses||[])if(L.shader)for(const I of["frag","vert"]){const U=De.getEntry(w,`shaders/${L.shader}.${I}`);if(!U)continue;const X=st(U);He.lastIndex=0;let ne;for(;(ne=He.exec(X))!==null;){const Y=ne[1];!Y||Y.startsWith("util/")||Y.startsWith("_rt_")||Ae.has(Y)||await lt(Y)}}};let $t=0;const ot=[];for(let A=0;A<b.layers.length;A++){const L=b.layers[A];if(L.image)try{let I;if(bt.BUILTIN_MODELS[L.image])I=bt.BUILTIN_MODELS[L.image];else{const T=De.getEntry(w,L.image);if(!T)continue;I=JSON.parse(st(T))}if(Qe.applySolidFromModel(L,I),I&&typeof I=="object"&&"width"in I&&"height"in I){const T=I;(L.size?.[0]||0)===0&&(L.size?.[1]||0)===0&&T.width>0&&T.height>0&&(L.size=[T.width,T.height])}const U=Qe.resolveMaterial(I);if(!U)continue;let X;if(bt.BUILTIN_MATERIALS[U.materialPath])X=bt.BUILTIN_MATERIALS[U.materialPath];else{const T=De.getEntry(w,U.materialPath);if(T)X=JSON.parse(st(T));else if(L.solid&&bt.BUILTIN_MATERIALS["materials/util/solidlayer.json"])X=bt.BUILTIN_MATERIALS["materials/util/solidlayer.json"];else continue}const ne=X.passes?.[0],Y=ne?.textures||[],f=Y[0];if(ne?.combos){for(const T of Object.keys(ne.combos))if(T.toLowerCase()==="spritesheet"&&Number(ne.combos[T])===1){L.spriteSheet=!0;break}}for(let T=0;T<Y.length;T++){const x=Y[T];typeof x!="string"||!x||x.startsWith("util/")||x.startsWith("_rt_")||ot.push(lt(x).then(M=>{M&&T===0&&(L.textureName=x,$t++,M.videoCtl&&(L.videoCtl=M.videoCtl))}))}ne?.shader&&De.getEntry(w,`shaders/${ne.shader}.frag`)&&bt.attachLayerMaterialEffect(L,ne);for(const T of L.effects||[])bt.resolveEffectChain(w,T,st);for(const T of L.effects||[]){for(const x of T.passes||[])for(const M of x.textures||[])typeof M=="string"&&M!==""&&!M.startsWith("util/")&&!M.startsWith("_rt_")&&ot.push(lt(M));ot.push(hr(T))}}catch(I){console.warn(`\u56FE\u5C42 ${L.name||A} \u52A0\u8F7D\u5931\u8D25: ${I.message}`)}}if(!Oi){for(const A of b.layers)if(!(!A.isText||!(A.effects||[]).length))try{for(const L of A.effects||[])bt.resolveEffectChain(w,L,st);for(const L of A.effects||[])for(const I of L.passes||[])for(const U of I.textures||[])typeof U=="string"&&U!==""&&!U.startsWith("util/")&&!U.startsWith("_rt_")&&ot.push(lt(U))}catch(L){console.warn(`\u6587\u5B57\u5C42\u6548\u679C ${A.name} \u89E3\u6790\u5931\u8D25: ${L.message}`)}}await Promise.all(ot);for(const[A,L]of Ae){if(!L?.videoCtl)continue;b.layers.some(U=>U.textureName===A&&U.visible&&!U.destroyed)&&!e.paused&&L.videoCtl.play()}const ze=[],Et=new Map;let kn=0;const Bn=async A=>{const L=await lt(A);if(L)return L;const I=un.buildBuiltinParticleTexture(A);if(!I)return null;const U={glTex:ke.makeTextureMip(N.gl,[I],!1),width:I.width,height:I.height,rg88:!1,mips:[I],generated:!0};return Ae.set(A,U),kn++,U},In=A=>{if(!A)return null;const L=A.mips&&A.mips[0];if(L?.rgba&&typeof un.prepareParticleNormalTexture=="function"){const I=un.prepareParticleNormalTexture(L);if(I&&I!==L)return{glTex:ke.makeTextureMip(N.gl,[I],!1),width:I.width,height:I.height,rg88:!1,mips:[I],generated:!0}}return A},mr=async(A,L,I,U)=>{if(U>3)return null;const X=De.getEntry(w,A);if(!X)return ae(e,n,`particle '${A}' \u4E0D\u5728 pkg\uFF0C\u8DF3\u8FC7`),null;const ne=JSON.parse(st(X)),Y=new Ic.ParticleSystem(N.gl,ne,I,L);let f=null,T=null;if(ne.material){const P=De.getEntry(w,ne.material);if(P){const R=JSON.parse(st(P));Y.setMaterial(R);const B=R?.passes?.[0]?.textures||[];f=B[0]||null,T=B[1]||null}}const x=await Bn(f||"particle/halo");if(!x)return ae(e,n,`particle '${A}' \u65E0\u8D34\u56FE\u53EF\u7528\uFF0C\u8DF3\u8FC7`),null;Y.setTexture({glTex:x.glTex,width:x.width,height:x.height,frames:x.frames});const M=T||(Y.refract?un.particleNormalNameForAlbedo(f||"particle/halo"):null);if(M){const P=In(await Bn(M));P&&Y.setNormalTexture({glTex:P.glTex,width:P.width,height:P.height})}Y.setVisible(!!L.visible),ze.push(Y);const E=L.id;if(E!==void 0){let P=Et.get(E);P||(P=[],Et.set(E,P)),P.push(Y)}for(const P of ne.children||[]){if(!P||typeof P.name!="string")continue;const R=String(P.origin??"0 0 0").trim().split(/\s+/).map(Number),B=String(P.scale??"1 1 1").trim().split(/\s+/).map(Number),z=String(P.angles??"0 0 0").trim().split(/\s+/).map(Number),$=P.type==="eventfollow"?"particle":!P.type||P.type==="static"?"origin":null,J=Y.localToWorld(R[0]||0,R[1]||0),re={...L,origin:[J[0],J[1],(L.origin?.[2]||0)+(R[2]||0)],scale:[(L.scale?.[0]??1)*(B[0]||1),(L.scale?.[1]??1)*(B[1]||1),(L.scale?.[2]??1)*(B[2]||1)],angles:[(L.angles?.[0]||0)+(z[0]||0),(L.angles?.[1]||0)+(z[1]||0),(L.angles?.[2]||0)+(z[2]||0)]},Z=await mr(P.name,re,P.instanceoverride||I,U+1);Z&&$&&Z.attachFollow(Y,$,[R[0]||0,R[1]||0,R[2]||0])}return Y};if(!Kc){for(const A of b.layers)if(A.particle)try{await mr(A.particle,A,A.instanceoverride,0)}catch(L){console.warn(`\u7C92\u5B50\u56FE\u5C42 ${A.name} \u52A0\u8F7D\u5931\u8D25: ${L.message}`),ae(e,n,`particle '${A.name}' FAIL: ${L.message.slice(0,80)}`)}}if(ze.length>0){const A=a;a=()=>{A?.();for(const L of ze)L.dispose()}}const fn=[];for(const A of b.layers)if(!(!A.sound||!A.sound.length))try{for(const L of A.sound){const I=De.getEntry(w,L);if(!I)continue;const U=(L.split(".").pop()||"").toLowerCase(),X=U==="mp3"?"audio/mpeg":U==="ogg"?"audio/ogg":U==="flac"?"audio/flac":"audio/wav",ne=new Blob([I],{type:X}),Y=URL.createObjectURL(ne);(e.objectUrls??=[]).push(Y);const f=document.createElement("audio");f.src=Y,f.loop=A.soundprops?.playbackmode==="loop",f.volume=Math.max(0,Math.min(1,A.soundprops?.volume??1)),f.muted=n.muted!==!1,A.soundCtl={play(){if(f.ended)try{f.currentTime=0}catch{}f.play().catch(()=>{})},pause(){f.pause()},stop(){f.pause();try{f.currentTime=0}catch{}},isPlaying:()=>!f.paused&&!f.ended,getVolume:()=>f.volume,setVolume:T=>{f.volume=Math.max(0,Math.min(1,T))}},!A.soundprops?.startsilent&&!e.paused&&f.play().catch(()=>{}),fn.push(f);break}}catch(L){console.warn(`\u58F0\u97F3\u56FE\u5C42 ${A.name} \u52A0\u8F7D\u5931\u8D25: ${L.message}`)}const pr=A=>{for(const L of fn)L.volume=Math.max(0,Math.min(1,A)),L.muted=A<=0};if(e.sceneAudio={setVolume:pr,audios:fn},s)return;let we=performance.now(),Kt=0;N.setParticleRenderer(()=>{const A=performance.now(),L=Math.min(.05,(A-we)/1e3);if(we=A,Ee.state.has){const{wx:I,wy:U,originY:X}=Ee.state,ne=X??U;for(const Y of ze)Y.setPointer(I,ne)}for(const I of ze)I.advance(L,O.enabled?k.snapshot:null);if(Kt<2&&(Kt++,Kt===2)){const I=ze.reduce((U,X)=>U+X.liveCount(),0);ae(e,n,`particles live: ${I} across ${ze.length} systems`)}},(A,L,I,U,X)=>{if(A===void 0)return;const ne=Et.get(A);if(ne)for(const Y of ne)Y.render(I,U,X,L.projW,L.projH)}),ae(e,n,`particles: ${ze.length} systems, ${kn} builtin tex generated`),window.__particleStats=()=>ze.map(A=>{let L=0,I=1/0,U=-1/0,X=1/0,ne=-1/0,Y=1/0,f=-1/0;for(const T of A.pool){if(!T.alive)continue;L++;const x=A.originX+T.x*A.scaleX,M=A.originY+T.y*A.scaleY;x<I&&(I=x),x>U&&(U=x),M<X&&(X=M),M>ne&&(ne=M);const E=Math.abs(T.size)*A.sysScale;E<Y&&(Y=E),E>f&&(f=E)}return{live:L,max:A.maxCount,blend:A.blend,renderer:A.renderers.map(T=>T.kind).join("+"),origin:[Math.round(A.originX),Math.round(A.originY)],bbox:L?[Math.round(I),Math.round(X),Math.round(U),Math.round(ne)]:null,size:L?[Math.round(Y),Math.round(f)]:null}}),window.__particleToggle=(A,L)=>{for(let I=0;I<ze.length;I++)ze[I].setVisible(L===void 0?A:I===L);return ze.length};const vt=[],On=new Map,gr=A=>{if(!A||!A.puppet)return null;let L=On.get(A);return L||(L=new Map,On.set(A,L)),L};for(const A of b.layers)if(A.image)try{if(bt.BUILTIN_MODELS[A.image])continue;const L=De.getEntry(w,A.image);if(!L)continue;const I=JSON.parse(st(L));if(!I.puppet)continue;const U=De.getEntry(w,I.puppet);if(!U)continue;const X=Nn.parseMDL(new Uint8Array(U)),ne=A.textureName?Ae.get(A.textureName):null;if(!ne){ae(e,n,`puppet '${A.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}A.puppet=X,vt.push({mdl:X,tex:ne,layer:A});const Y=X.animations[0];ae(e,n,`puppet '${A.name}' v=${X.vertexCount} bones=${X.bones.length}`+(Y?` anim='${Y.name}' ${Y.fps}fps\xD7${Y.frameCount}`:" \u65E0\u52A8\u753B"))}catch(L){console.warn(`puppet \u56FE\u5C42 ${A.name} \u52A0\u8F7D\u5931\u8D25: ${L.message}`),ae(e,n,`puppet '${A.name}' \u5931\u8D25: ${L.message}`)}for(const A of b.layers)if(A.model&&!A.puppet)try{const L=De.getEntry(w,A.model);if(!L)continue;const I=Nn.parseMDL(new Uint8Array(L));let U=null;if(I.materialPath){const ne=De.getEntry(w,I.materialPath);if(ne){const f=JSON.parse(st(ne))?.passes?.[0]?.textures?.[0];typeof f=="string"&&f&&(U=f)}}U&&(await lt(U),A.textureName=U);const X=U?Ae.get(U):null;if(!X){ae(e,n,`model '${A.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}A.puppet=I,vt.push({mdl:I,tex:X,layer:A}),ae(e,n,`model '${A.name}' v=${I.vertexCount} static ${I.materialPath||""}`)}catch(L){console.warn(`model \u56FE\u5C42 ${A.name} \u52A0\u8F7D\u5931\u8D25: ${L.message}`),ae(e,n,`model '${A.name}' \u5931\u8D25: ${L.message}`)}let dn=null;if(vt.length>0)try{dn=Nn.createMDLRenderer(N.gl);for(const L of vt)dn.upload(L.mdl);const A=new Map;for(const L of vt)A.set(L.layer,L);N.setPuppetRenderer((L,I,U)=>{const X=A.get(L);X&&dn.draw(I,X.mdl,{time:U.time,animLayers:L.animationLayers,boneOverrides:On.get(L),overrideTex:U.overrideTex||null,color:[L.color[0]*L.brightness,L.color[1]*L.brightness,L.color[2]*L.brightness,L.alpha]},X.tex)})}catch(A){console.warn(`puppet \u6E32\u67D3\u5668\u521D\u59CB\u5316\u5931\u8D25: ${A.message}`),ae(e,n,`puppet renderer \u5931\u8D25: ${A.message}`),dn=null;for(const L of vt)L.layer.puppet=null}if(s)return;ae(e,n,`puppet: ${vt.length} meshes`);const hn=Nn.applyAttachmentBindOrigins(b.layers);hn.length&&ae(e,n,`attachments: ${hn.length} hanging layers`);const ut=[],Dn=new Map,Qt={};let it=null,zn=null,$n=0;if(!Oi&&b.layers.some(A=>A.isText)){const A=b.general?.orthogonalprojection,L=A?.width||t.width,I=A?.height||t.height,U=Rr(qt(e.cfg.fit),L,I,t.width,t.height),X=Math.min(3,Math.max(.5,t.width/Math.max(1,U.viewW))),ne=new Map,Y=new Set;for(const x of b.layers)x.isText&&x.textFont&&Y.add(x.textFont);for(const x of w.entries||[])typeof x.name=="string"&&/^fonts\/.+\.(ttf|otf|woff2?)$/i.test(x.name)&&Y.add(x.name);for(const x of Y){const M=zi.get(`${n.src}|${x}`);if(M){ne.set(x,M);continue}const E=el[x.toLowerCase()];if(E){ne.set(x,E);continue}try{const P=De.getEntry(w,x);if(!P)continue;const R="wefont_"+x.split("/").pop().replace(/[^a-zA-Z0-9]/g,"_"),B=URL.createObjectURL(new Blob([P])),z=new FontFace(R,`url(${B})`);await z.load(),document.fonts.add(z),(e.objectUrls??=[]).push(B),ne.set(x,R),zi.set(`${n.src}|${x}`,R)}catch(P){console.warn(`\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25 ${x}: ${P.message}`)}}it=document.createElement("canvas"),zn=it.getContext("2d");const f=2048;for(const x of b.layers)if(x.isText)try{const M={layer:x,sandbox:null,texName:"__wstext_"+x.id,entry:null,lastKey:null,quality:X};if(x.textScript&&(M.sandbox=qe.evalTextScript(x.textScript,x.textScriptProps,{text:x.text??"",font:x.textFont||"",pointsize:x.textPointsize,color:x.textColor,angles:x.angles,origin:x.origin,scale:x.scale,visible:x.visible,canvasSize:{width:L,height:I},userProperties:y,shared:Qt,audioViews:K,inputView:rt,...Pe,mediaControl:Ve,windowTitle:G.snapshot,openUserShortcut:Q.openUserShortcut,getLayerText:B=>Dn.get(B),onError:B=>{ae(e,n,`text script '${x.name}' \u5931\u8D25: ${String(B.message||B).slice(0,120)}`)}}),M.sandbox&&(_.push(M.sandbox),M.sandbox.init(),M.sandbox.applyUserProperties(y),M.sandbox.hasMediaHook&&xe(M.sandbox))),Dn.set(x.name||"",String(x.text??"")),x.textAnchor!=="center"&&x.size[0]>0&&x.size[1]>0){const B=x.size[0]*(x.scale[0]||1)/2,z=x.size[1]*(x.scale[1]||1)/2,$=x.textAnchor;$.includes("left")&&(x.origin[0]+=B),$.includes("right")&&(x.origin[0]-=B),$.includes("top")&&(x.origin[1]-=z),$.includes("bottom")&&(x.origin[1]+=z)}const E=Di*Math.max(1,x.textPointsize),P=qe.textLayerHasTintMask(x)?8:256,R=Math.min(P,qe.textCanvasMargin(E,0));M.boxW=x.size[0]>0?x.size[0]:E*4,M.boxH=x.size[1]>0?x.size[1]:E*1.6,M.margin=R,x.size=[M.boxW+R*2,M.boxH+R*2],M.entry={glTex:ke.makeTexture(N.gl,new Uint8Array([0,0,0,0]),1,1),width:1,height:1,rg88:!1},Ae.set(M.texName,M.entry),x.textureName=M.texName,x.solid=!1,ut.push(M)}catch(M){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${x.name} \u521D\u59CB\u5316\u5931\u8D25: ${M.message}`)}if(ut.length>0){const x=a;a=()=>{x?.();for(const M of ut)N.gl.deleteTexture(M.entry.glTex)}}const T=x=>{if(!zn||!it)return;const M=zn;for(const E of ut){const P=E.layer;let R=String(P.text??"");if(E.sandbox&&E.sandbox.hasUpdate){E.sandbox.engine.runtime=x;const J=E.sandbox.callUpdate(R);J!=null?R=String(J):E.sandbox.thisLayer.text&&(R=String(E.sandbox.thisLayer.text))}else E.sandbox&&typeof E.sandbox.thisLayer?.text=="string"&&(R=String(E.sandbox.thisLayer.text));if(Dn.set(P.name||"",R),!P.visible)continue;const B=Math.max(1,E.sandbox?E.sandbox.thisLayer.pointsize:P.textPointsize),z=E.sandbox&&E.sandbox.thisLayer.font||P.textFont||"",$=`${R}\0${B}\0${z}\0${P.alpha}\0${P.textCastshadow}`;if(E.lastKey!==$){E.lastKey=$;try{const J=Di*B,re=E.boxW,Z=E.boxH,ce=E.margin,le=Math.abs(P.scale[0]||1),se=Math.abs(P.scale[1]||1);let ie=Math.max(1,Math.round(P.size[0]*le*E.quality)),F=Math.max(1,Math.round(P.size[1]*se*E.quality));const ee=Math.min(1,f/Math.max(ie,F));ie=Math.max(1,Math.round(ie*ee)),F=Math.max(1,Math.round(F*ee)),it.width!==ie||it.height!==F?(it.width=ie,it.height=F):(M.setTransform(1,0,0,1,0,0),M.clearRect(0,0,ie,F));const ue=Math.min(ie/P.size[0],F/P.size[1]);M.setTransform(ue,0,0,ue,0,0),M.translate(ce,ce);const ve=z&&ne.get(z)||"sans-serif";M.font=`${J}px "${ve}", sans-serif`;const Me=M.measureText(""),he=(Me.fontBoundingBoxAscent||0)+(Me.fontBoundingBoxDescent||0),Re=P.textSpacing||[0,0],Te=qe.layoutText(R,{boxW:re,boxH:Z,pointsize:J,lineHeight:(he>0?he:J*1.25)+Re[1],spacing:Re,padding:P.textPadding||0,maxwidth:P.textMaxwidth||0,limitwidth:!!P.textLimitwidth,maxrows:P.textMaxrows||0,limitrows:!!P.textLimitrows,limituseellipsis:!!P.textLimituseellipsis,halign:P.textHAlign,valign:P.textVAlign},wt=>M.measureText(wt).width);qe.drawTextLayer(M,Te,{font:M.font,color:P.textColor,alpha:P.alpha,brightness:P.brightness,spacing:Re,pointsize:J,opaquebackground:!!P.textOpaquebackground,backgroundcolor:P.textBackgroundcolor,backgroundbrightness:P.textBackgroundbrightness,castshadow:!!P.textCastshadow});const Ge=E.entry;N.gl.bindTexture(N.gl.TEXTURE_2D,Ge.glTex),N.gl.texImage2D(N.gl.TEXTURE_2D,0,N.gl.RGBA,N.gl.RGBA,N.gl.UNSIGNED_BYTE,it),Ge.width=ie,Ge.height=F}catch(J){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${P.name} \u7ED8\u5236\u5931\u8D25: ${J.message}`),E.lastKey=null}}}};e.sceneTextUpdate=T,window.__textWidgets=ut,ae(e,n,`text widgets: ${ut.length} (scripts ${ut.filter(x=>x.sandbox).length}, fonts ${ne.size}, quality ${X.toFixed(2)})`)}if(s)return;const jt=[],Wt=[],ft=[],_e={},Pt=[],Jt=[],Je=new Map,br=(A,L)=>{if(!L||typeof L.callCursor!="function"||!L.hasCursorHook)return;const I=Je.get(A);I?I.push(L):Je.set(A,[L])};for(const A of ut)A.sandbox&&br(A.layer,A.sandbox);{const A=b.general?.orthogonalprojection,L=A?.width||t.width,I=A?.height||t.height,U=y,X=(x,M)=>{const E=b.general||{};if(x==="zoom"&&typeof M=="number"&&Number.isFinite(M)&&M>0){b.cameraTransforms.zoom=M,E.zoom&&typeof E.zoom=="object"?E.zoom.value=M:E.zoom=M;return}E[x]&&typeof E[x]=="object"&&"value"in E[x]?E[x].value=M:E[x]=M};let ne=1+Math.max(0,...b.layers.map(x=>Number(x.id)||0));const Y={recomputeVisibility:S,getSceneLayer:x=>b.layers.find(M=>M.name===x&&!M.destroyed)||null,getSceneLayerById:x=>b.layers.find(M=>M.id===x&&!M.destroyed)||null,enumerateSceneLayers:()=>b.layers.filter(x=>!x.destroyed),getSceneAnimation:x=>{if(x==null||x==="")return null;if(_e[x])return _e[x];for(const M of b.layers)if(M.animations&&M.animations[x])return M.animations[x];return null},cameraTransforms:b.cameraTransforms,getInitialLayerConfig:x=>{const M=x&&typeof x=="object"?x.name:String(x||"");return b.layers.find(E=>E.name===M)||null},createSceneLayer:x=>{let M=x&&typeof x=="object"?x:null;if(typeof x=="string"){const P=x;if(M=b.layers.find(R=>R&&!R.destroyed&&R.image===P&&R.textureName)||b.layers.find(R=>R&&!R.destroyed&&R.image===P)||null,!M)return ae(e,n,`createLayer('${P}') \u627E\u4E0D\u5230\u5DF2\u52A0\u8F7D\u7684\u540C\u6A21\u578B\u5C42`),null}M||(M={});const E={...M,id:ne++,origin:Array.isArray(M.origin)?M.origin.slice():[0,0,0],scale:Array.isArray(M.scale)?M.scale.slice():[1,1,1],angles:Array.isArray(M.angles)?M.angles.slice():[0,0,0],size:Array.isArray(M.size)?M.size.slice():[0,0],color:Array.isArray(M.color)?M.color.slice():[1,1,1],childIds:null,hasChildren:!1,destroyed:!1,animations:{},animationList:[],objectScripts:null};return delete E.textureAnimation,delete E.videoTextureApi,delete E.soundCtl,delete E.videoCtl,Array.isArray(M.effects)&&(E.effects=M.effects.map(P=>({...P,passes:Array.isArray(P.passes)?P.passes.map(R=>({...R})):P.passes}))),b.layers.push(E),E},mediaControl:Ve,windowTitle:G.snapshot,openUserShortcut:Q.openUserShortcut,isScreensaver:!1};N.setConstantScriptRuntime?.(qe.evalObjectScript,{userProperties:U,audioViews:K,shared:Qt,inputView:rt,timers:Xe,...Y,onSandbox:x=>{x&&x.hasMediaHook&&xe(x)}});for(const x of b.layers){const M=x.objectAnimations;if(M){x.animations=x.animations||{},x.animationList=x.animationList||[];for(const[E,P]of Object.entries(M))try{const R=Fi.createAnimation(P.animation);R.field=E,R.baseValue=P.value;const B=x[E];R.baseNumeric=Array.isArray(B)?B.slice():B,x.animationList.push(R),R.name&&(x.animations[R.name]=R),Wt.push({layer:x,field:E,ctrl:R})}catch(R){ae(e,n,`animation '${x.name}.${E}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(R.message).slice(0,80)}`)}}}for(const x of b.layers){for(const[E,P]of(x.effects||[]).entries()){const R=P.visibleScript;if(R)try{const B=qe.evalObjectScript(R.script,R.scriptproperties,{canvasSize:{width:L,height:I},userProperties:U,audioViews:K,inputView:rt,...Pe,layer:x,targetEffect:P,...Y,shared:Qt,onError:z=>ae(e,n,`effect visible script '${x.name}#${E}' \u5931\u8D25: ${String(z.message||z).slice(0,80)}`)});if(!B)continue;_.push(B),B.init(P.visible),B.applyUserProperties(U),B.hasMediaHook&&xe(B),B.hasUpdate&&Pt.push({effect:P,sandbox:B})}catch(B){console.warn(`\u6548\u679C\u5F00\u5173\u811A\u672C ${x.name}#${E} \u6C42\u503C\u5931\u8D25: ${B.message}`)}}const M=x.objectScripts;if(M)for(const[E,P]of Object.entries(M))try{const R=qe.evalObjectScript(P.script,P.scriptproperties,{canvasSize:{width:L,height:I},screenResolution:{x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1},timeOfDay:(()=>{const B=new Date;return(B.getHours()*3600+B.getMinutes()*60+B.getSeconds())/86400})(),userProperties:U,audioViews:K,inputView:rt,layer:x,...Y,getBoneOverrides:gr,shared:Qt,...Pe,onError:B=>ae(e,n,`object script '${x.name}.${E}' \u5931\u8D25: ${String(B.message||B).slice(0,90)}`)});if(R){_.push(R);const B=x[E],z=E==="angles"&&Array.isArray(B)?qe.radToScriptAngles(B):Array.isArray(B)?{x:B[0]??0,y:B[1]??0,z:B[2]??0}:B;R.init(z),R.applyUserProperties(U),br(x,R),R.hasMediaHook&&xe(R),R.hasUpdate&&jt.push({layer:x,field:E,kind:E==="visible"?"bool":E==="alpha"||E==="brightness"?"scalar":"vec3",sandbox:R})}}catch(R){console.warn(`\u5BF9\u8C61\u811A\u672C ${x.name}.${E} \u6C42\u503C\u5931\u8D25: ${R.message}`)}}const f=b.generalScripts;if(f){for(const[x,M]of Object.entries(f))try{const E=qe.evalObjectScript(M.script,M.scriptproperties,{canvasSize:{width:L,height:I},userProperties:U,audioViews:K,inputView:rt,...Pe,...Y,shared:Qt,onError:R=>ae(e,n,`general script '${x}' \u5931\u8D25: ${String(R.message||R).slice(0,80)}`)});if(!E)continue;_.push(E),E.init(M.value),E.applyUserProperties(U),E.hasMediaHook&&xe(E);const P=R=>X(x,R);E.hasUpdate&&Jt.push({field:x,sandbox:E,write:P})}catch(E){console.warn(`general \u811A\u672C ${x} \u6C42\u503C\u5931\u8D25: ${E.message}`)}Jt.length&&ae(e,n,`general scripts: ${Jt.map(x=>x.field).join(",")}`)}const T=b.generalAnimations;if(T){for(const[x,M]of Object.entries(T))try{const E=Fi.createAnimation(M.animation);E.field=x,E.baseValue=M.value,E.baseNumeric=M.value,E.name&&(_e[E.name]=E),ft.push({field:x,ctrl:E,write:P=>X(x,P)})}catch(E){ae(e,n,`general animation '${x}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(E.message).slice(0,80)}`)}ft.length&&ae(e,n,`general animations: ${ft.map(x=>x.field).join(",")}`)}}jt.length&&(ae(e,n,`object scripts: ${jt.length}`),window.__objScripts=jt),window.__mediaHooks=te,window.__compositeStats=()=>N.compositeStats?.()??null,window.__compositeEnable=A=>N.setCompositeEnabled?.(A),window.__scene=b,window.__textures=Ae;const yt=Array.from(Je.keys());yt.length&&ae(e,n,`cursor hooks: ${yt.length} layers`);let Vt=null,Xt=null,jn=!1;const vr=()=>({worldPosition:qe.makeCursorEventVec(Ee.state.wx,Ee.state.originY!=null?Ee.state.originY:Ee.state.wy,0)}),xt=(A,L,I)=>{const U=Je.get(A);if(U)for(const X of U)X.callCursor(L,I)},yr=()=>{if(yt.length===0)return;const A=Ee.state;if(!A.has)return;const L=N.getParallaxOffset?N.getParallaxOffset():{x:0,y:0},I=b.general?.orthogonalprojection?.height||t.height,U=zc.hitTestLayers(b.layers,A.wx,A.wy,I,{parOffX:L.x,parOffY:L.y,alignTable:ke.ALIGN,filter:ne=>Je.has(ne)}),X=vr();U!==Vt&&(Vt&&xt(Vt,"cursorLeave",X),Vt=U,U&&xt(U,"cursorEnter",X)),U&&xt(U,"cursorMove",X),A.leftDown&&!jn?(Xt=U,U&&xt(U,"cursorDown",X)):!A.leftDown&&jn&&(Xt&&xt(Xt,"cursorUp",X),Xt&&Xt===U&&xt(U,"cursorClick",X),Xt=null),jn=A.leftDown},mn=performance.now();let pn=0,Ce=0;const dt=[],Ct=[];let gn=-1/0;const Wn=A=>{if(s||e.paused)return;const I=1e3/(e.cfg.sceneFps||60);if(A-gn>=I){if(gn=A,io(e,A),e.onFirstFrame){const f=e.onFirstFrame;e.onFirstFrame=void 0,f()}ao(e,t,e.cfg);const U=(A-mn-pn)/1e3;if(rt.update(Ee.state),q.enabled){V.update(U);const f=St.diffMediaEvents(me,V.snapshot);if(f.length){for(const{name:T,event:x}of f)for(const M of te)M.disabled||M.callMedia(T,x);me=St.cloneMediaSnapshot(V.snapshot)}}G.update(U);for(const f of Wt){f.ctrl.advance(I/1e3);const T=f.field,x=f.ctrl.applyTo(f.ctrl.baseNumeric);if(Array.isArray(x)){const M=f.layer[T];if(Array.isArray(M))for(let E=0;E<x.length&&E<M.length;E++)M[E]=x[E]}else Number.isFinite(x)&&(T==="visible"?f.layer[T]=!!x:f.layer[T]=x)}for(const f of ft){f.ctrl.advance(I/1e3);const T=f.ctrl.applyTo(f.ctrl.baseNumeric);typeof T=="number"&&Number.isFinite(T)?f.write(T):Array.isArray(T)&&Number.isFinite(T[0])&&f.write(T[0])}for(const f of Pt){if(f.sandbox.disabled)continue;f.sandbox.engine.frametime=I/1e3,f.sandbox.engine.runtime=U;const T=f.sandbox.callUpdate(!!f.effect.visible);typeof T=="boolean"&&(f.effect.visible=T)}for(const f of Jt){if(f.sandbox.disabled)continue;f.sandbox.engine.frametime=I/1e3,f.sandbox.engine.runtime=U;const T=b.general||{},x=T[f.field]&&typeof T[f.field]=="object"&&"value"in T[f.field]?T[f.field].value:T[f.field],M=f.sandbox.callUpdate(x);M!==void 0&&f.write(M)}const X={x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1};let ne=!1;for(const f of jt){if(f.sandbox.disabled)continue;f.sandbox.engine.frametime=I/1e3,f.sandbox.engine.runtime=U,f.sandbox.engine.screenResolution=X;const T=f.layer[f.field];if(f.kind==="bool"){const x=f.sandbox.callUpdate(!!T);typeof x=="boolean"&&(f.field==="visible"?f.layer.visibleSelf!==x&&(f.layer.visibleSelf=x,ne=!0):f.layer[f.field]=x)}else if(f.kind==="scalar"){const x=f.sandbox.callUpdate(Number(T)||0),M=Number(x);Number.isFinite(M)&&(f.layer[f.field]=M)}else{const x=f.field==="angles"?qe.radToScriptAngles(T):{x:T[0]||0,y:T[1]||0,z:T[2]||0},M=f.sandbox.callUpdate(x),E=M&&typeof M=="object"&&"x"in M?M:x;f.layer[f.field]=f.field==="angles"?qe.scriptAnglesToRad(E):[E.x||0,E.y||0,E.z||0]}}ne&&S(),O.enabled&&(k.update(U),_c(K,k.snapshot)),hn.length&&Nn.followAttachments(hn,U,gr);const Y=e.coverAlign;N.render(b,Ae,t.width,t.height,U,qt(e.cfg.fit),Y.x,Y.y).then(()=>{if(!(s||e.paused)){try{yr()}catch{}Ee.beginFrame();try{e.sceneTextUpdate&&A>=$n&&($n=A+100,e.sceneTextUpdate(U))}catch{}e.raf=requestAnimationFrame(Wn)}}).catch(f=>{console.warn("scene render error:",f),ae(e,n,`render: ${String(f.message||f).slice(0,200)}`),s=!0})}else e.paused||(e.raf=requestAnimationFrame(Wn))},Vn=()=>{s||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(Wn))},Ht=A=>{if(s)return;const L=b.properties||{},I=ys(L,y,A);if(Object.keys(I).length){for(const U of b.layers){const X=U.srcObject;if(!X)continue;nn(X,L,0);const ne=pt(X.visible);ne&&ne in I&&(U.visibleSelf=Qe.parseBool(X.visible,!0));const Y=pt(X.color);Y&&Y in I&&(U.color=Qe.parseColor(X.color),U.isText&&(U.textColor=U.color));const f=pt(X.alpha);f&&f in I&&(U.alpha=Qe.parseNum(X.alpha,1));const T=pt(X.brightness);T&&T in I&&(U.brightness=Qe.parseNum(X.brightness,1));const x=pt(X.volume);if(x&&x in I){const E=Qe.parseNum(X.volume,1);U.soundprops&&(U.soundprops.volume=E),U.soundCtl?.setVolume?.(E)}for(let E=0;E<(X.animationlayers||[]).length;E++){const P=X.animationlayers[E],R=U.animationLayers?.[E];if(!P||!R)continue;const B=pt(P.visible);B&&B in I&&(R.visible=Qe.parseBool(P.visible,!0));const z=pt(P.rate);z&&z in I&&(R.rate=Qe.parseNum(P.rate,1));const $=pt(P.blend);$&&$ in I&&(R.blend=Qe.parseNum(P.blend,1))}for(let E=0;E<(X.effects||[]).length;E++){const P=X.effects[E],R=U.effects?.[E];if(!P||!R)continue;const B=pt(P.visible);B&&B in I&&!R.visibleScript&&(R.visible=Qe.parseBool(P.visible,!0))}const M=X.instanceoverride;if(M&&typeof M=="object"&&U.particle){let E=!1;for(const P of Object.keys(M)){if(P==="id")continue;const R=pt(M[P]);if(R&&R in I){E=!0;break}}if(E){const P=Et.get(U.id);if(P)for(const R of P)R.reapplyOverride?.()}}}for(const U of _)if(!(!U||U.disabled))try{U.applyUserProperties(I)}catch{}S();for(const U of b.layers){if(!U.particle)continue;const X=Et.get(U.id);if(X)for(const ne of X)ne.setVisible(!!U.visible)}N.applyConstUserProperties?.(I);for(const U of ut)U.lastKey=null;ae(e,n,`props hot: ${Object.keys(I).join(",")}`)}};d=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),Ce||(Ce=performance.now()),dt.length=0;for(const A of Ae.values())A?.videoCtl?.isPlaying?.()&&(dt.push(A.videoCtl),A.videoCtl.pause());Ct.length=0;for(const A of fn)!A.paused&&!A.ended&&(Ct.push(A),A.pause())},h=()=>{Ce&&(pn+=performance.now()-Ce,Ce=0),we=performance.now();for(const A of dt)try{A.play()}catch{}dt.length=0;for(const A of Ct)A.play().catch(()=>{});Ct.length=0,Vn()},l=Ht,u&&(Ht(u),u=null),Vn();{const A=b.general?.orthogonalprojection,L=A?.width||t.width,I=A?.height||t.height,U=qt(e.cfg.fit),X=Rr(U,L,I,t.width,t.height);ae(e,n,`fit ${U}: view ${Math.round(X.viewW)}x${Math.round(X.viewH)} scene ${L}x${I} canvas ${t.width}x${t.height}`)}ae(e,n,`renderer started: ${b.layers.length} layers`)}catch(p){if(s||p&&p.name==="AbortError")return;console.warn("scene render failed:",p);const w=p instanceof Error?p:new Error(String(p));ae(e,n,`failed: ${String(w.message||w).slice(0,200)}`),e.onError?e.onError(w):e.fallbackPage?.()}})()}function dr(e,n){(n.type==="video"||n.type==="gif"||n.type==="image")&&n.src?Wc(e,n):n.type==="scene"&&(n.source||n.src)?nl(e,n):e.onUnhandledType?.(n)}function rl(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function ol(e,n){return{type:"scene",canvas:e,source:n.source,fit:rl(n.fit),renderDpr:n.renderDpr??1,sceneFps:n.fps??60,muted:(n.volume??0)<=0,loop:!0}}function $i(e,n){const t=Vi(),r={ready:[],error:[],diagnostic:[]};let o={...n??{},source:null};const i=d=>{for(const h of r.error)try{h(d)}catch{}},s=d=>{t.onDiagnostic=(h,p)=>{try{d.onDiagnostic?.(h,p)}catch{}for(const w of r.diagnostic)try{w(h,p)}catch{}},t.onError=h=>{try{d.onError?.(h)}catch{}i(h)},t.onSceneInfo=h=>{t.info=h}},c=()=>new Promise(d=>{const h=t.onFirstFrame;t.onFirstFrame=()=>{t.onFirstFrame=void 0,h?.(),d()}}),a=()=>{let d=()=>{};return{promise:new Promise((p,w)=>{d=u.on("error",m=>w(m))}),off:d}},u={canvas:e,pause(){t.paused=!0,t.sceneCtl?.pause()},resume(){t.paused=!1,so(t),t.sceneCtl?.resume()},get paused(){return!!t.paused},setFit(d){t.cfg.fit=d,Mr(t)},setFps(d){t.cfg.sceneFps=d},setVolume(d){const h=Math.max(0,Math.min(1,d));t.cfg.muted=h<=0,t.sceneAudio?.setVolume(h)},setRenderDpr(d){t.cfg.renderDpr=d,dr(t,t.cfg)},setProperties(d){const h={};for(const[p,w]of Object.entries(d))h[p]={value:w};t.sceneCtl?.applyUserProperties(h)},getProperties(){return{...t.liveUserProps??{}}},async load(d){o={...o,source:d},s(o);const h={...t.cfg,type:"scene",source:d,src:void 0,mediaBase:void 0};t.cfg=h,t.paused=!1,t.info=void 0,Mr(t);const p=c(),w=a();dr(t,h);try{await Promise.race([p,w.promise])}finally{w.off()}},release(){tn(t)},restore(){dr(t,t.cfg)},destroy(){Xi(t),t.onDiagnostic=void 0,t.onError=void 0,t.onFirstFrame=void 0,t.onSceneInfo=void 0,r.ready.length=0,r.error.length=0,r.diagnostic.length=0},get stats(){return Gi(t)},get info(){return t.info??null},on(d,h){const p=r[d];return p.push(h),()=>{const w=p.indexOf(h);w>=0&&p.splice(w,1)}}},l=async d=>{o=d,s(d),t.cfg=ol(e,d),t.paused=d.autoplay===!1,t.info=void 0,Mr(t);const h=c(),p=a();dr(t,t.cfg);try{await Promise.race([h,p.promise])}finally{p.off()}(d.volume??0)>0&&u.setVolume(d.volume),d.properties&&Object.keys(d.properties).length&&u.setProperties(d.properties)};return u.__applyOptions=l,u}async function il(e,n){const t=$i(e,n);return await t.__applyOptions(n),t}et.bytesSource=Yc,et.createScene=$i,et.fileSource=Gc,et.httpSource=Ni,et.mount=il,Object.defineProperty(et,Symbol.toStringTag,{value:"Module"})})});ll();})();
|
|
512
|
+
`};function Nl(e){if(!e||e.length<12)return e;const n=e[0],t=e[1],r=e[2],o=e[3];if(!(n===0&&t===1&&r===0&&o===0)&&!(n===79&&t===84&&r===84&&o===79))return e;const a=Uint8Array.from(e),c=new DataView(a.buffer,a.byteOffset,a.byteLength),u=c.getUint16(4);if(u<=0||12+u*16>a.length)return e;let l=-1,p=0,f=0;for(let A=0;A<u;A++){const h=12+A*16;if(String.fromCharCode(a[h],a[h+1],a[h+2],a[h+3])==="cmap"){l=h,p=c.getUint32(h+8),f=c.getUint32(h+12);break}}if(l<0||p+f>a.length)return e;let d=!1;const w=c.getUint16(p+2);for(let A=0;A<w;A++){const h=p+4+A*8,b=c.getUint32(h+4),v=p+b;if(v+14>a.length||c.getUint16(v)!==4)continue;const T=c.getUint16(v+6),_=T>>>1;if(_<1)continue;const F=2*Math.pow(2,Math.floor(Math.log2(_))),R=Math.floor(Math.log2(_)),k=T-F,U=c.getUint16(v+8),V=c.getUint16(v+10),q=c.getUint16(v+12);U===F&&V===R&&q===k||(c.setUint16(v+8,F),c.setUint16(v+10,R),c.setUint16(v+12,k),d=!0)}if(!d)return e;let M=0;const m=p+f;for(let A=p;A<m;A+=4){const h=a[A]||0,b=A+1<m?a[A+1]:0,v=A+2<m?a[A+2]:0,T=A+3<m?a[A+3]:0;M=M+(h<<24|b<<16|v<<8|T)>>>0}return c.setUint32(l+4,M),a}const Ul={systemfont_segoe:"'Segoe UI', 'Helvetica Neue', Arial, sans-serif",systemfont_arial:"Arial, 'Helvetica Neue', sans-serif",systemfont_verdana:"Verdana, Geneva, sans-serif",systemfont_tahoma:"Tahoma, Geneva, sans-serif",systemfont_timesnewroman:"'Times New Roman', Times, serif",systemfont_georgia:"Georgia, 'Times New Roman', serif",systemfont_couriernew:"'Courier New', Courier, monospace",systemfont_trebuchetms:"'Trebuchet MS', 'Helvetica Neue', sans-serif",systemfont_impact:"Impact, 'Arial Black', sans-serif",systemfont_comicsansms:"'Comic Sans MS', 'Comic Sans', cursive",systemfont_sylfaen:"Palatino, 'Times New Roman', serif",systemfont_calibri:"Calibri, Carlito, 'Helvetica Neue', sans-serif",systemfont_cambria:"Cambria, Georgia, serif",systemfont_consolas:"Consolas, 'Courier New', monospace",systemfont_microsoftyahei:"'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif",systemfont_simsun:"SimSun, 'Songti SC', serif",systemfont_simhei:"SimHei, 'Heiti SC', sans-serif"},gr=new Map;function Bl(e){let n=5381;for(let t=0;t<e.length;t++)n=(n<<5)+n+e.charCodeAt(t)|0;return(n>>>0).toString(36)}function Dl(e){for(const n of e){const t=gr.get(n);if(t&&(t.refs--,!(t.refs>0))){gr.delete(n);try{const r=[];document.fonts.forEach(o=>{o.family===t.family&&r.push(o)});for(const o of r)document.fonts.delete(o)}catch{}}}}const Jt=new Map,Il=512*1024*1024;let uo=0;function Ol(e){for(;Jt.size>0&&(Jt.size>2||uo>Il);){let n=null,t=1/0;for(const[o,i]of Jt)o!==e&&i.at<t&&(t=i.at,n=o);if(!n)break;const r=Jt.get(n);uo-=r.parsed.fileSize||0,Jt.delete(n)}}async function $l(e,n,t,r){const o=t.key;if(o){const c=Jt.get(o);if(c)return c.at=Date.now(),se(e,n,`pkg cache hit: ${c.parsed.fileSize} bytes`),c.parsed}let i;try{i=await t.scenePkg(r)}catch(c){throw r.aborted||c instanceof Error?c:new Error(String(c))}se(e,n,`pkg body: ${i.byteLength} bytes`);const s=i instanceof Uint8Array?i:new Uint8Array(i),a=He.parsePkg(s);return o&&(Jt.set(o,{parsed:a,at:Date.now()}),uo+=a.fileSize||0,Ol(o)),a}function jl(e,n){Zt(e);const t=(n.canvas instanceof HTMLCanvasElement?n.canvas:null)??document.createElement("canvas"),r=Ut(e,n),o=t.clientWidth||window.innerWidth||1,i=t.clientHeight||window.innerHeight||1;t.width=Math.max(1,Math.round(o*r)),t.height=Math.max(1,Math.round(i*r)),n.canvas instanceof HTMLCanvasElement||(t.style.cssText="position:absolute;inset:0;width:100%;height:100%;",e.wrap?.appendChild(t)),e.canvas=t;let s=!1;const a=console.warn.bind(console);console.warn=(...w)=>{const M=w.map(m=>typeof m=="string"?m:String(m?.message??m)).join(" ");if(M.includes("[we-scene]"))try{se(e,n,M.slice(0,300))}catch{}a(...w)};const c=new AbortController;let u;e.sceneCleanup=()=>{s=!0,console.warn=a,c.abort(),e.sceneTextUpdate=void 0,u&&(u(),u=void 0),e.renderer&&(e.renderer.dispose?.(),e.renderer=void 0)};let l=null,p,f,d;e.sceneCtl={pause(){f?.()},resume(){d?.()},applyUserProperties(w){p?p(w):l={...l||{},...w}}},(async()=>{try{const w=n.source??Ki(`${n.mediaBase}/${n.src}`);if(!n.source&&(!n.mediaBase||!n.src))throw new Error("\u573A\u666F\u58C1\u7EB8\u7F3A\u5C11 mediaBase/src");se(e,n,"mountScene start");const M=await $l(e,n,w,c.signal);if(s)return;let m=null;try{m=await w.project?.(c.signal)??null}catch{}if(!t.getContext("webgl2",{premultipliedAlpha:!1,antialias:!1,alpha:!1,preserveDrawingBuffer:!0}))throw new Error("WEBGL2_UNAVAILABLE");const h=He.getEntry(M,"scene.json");if(!h)throw new Error("pkg \u4E2D\u6CA1\u6709 scene.json\uFF08\u4E0D\u662F\u573A\u666F\u58C1\u7EB8\uFF1F\uFF09");const b=Ye.parseScene(JSON.parse(ft(h)),m);if(n.clearColor){const g=b.general??={};g.clearcolor=n.clearColor,g.clearenabled=!0}{const g=b.general?.zoom,S=Number(g&&typeof g=="object"?g.value:g);b.cameraTransforms={zoom:Number.isFinite(S)&&S>0?S:1}}const v=zs(b.properties||{});e.liveUserProps=v;const T=()=>Ye.recomputeLayerVisibility(b.layers);if(e.onSceneInfo){const g=b.general?.orthogonalprojection||{},S=Number(g.width)>0?Number(g.width):t.width,L=Number(g.height)>0?Number(g.height):t.height,E=b.layers||[],N={width:S,height:L,layerCount:E.length,hasModels:E.some(I=>!!I.model),hasParticles:E.some(I=>!!I.particle),hasText:E.some(I=>!!I.text)},j=e.onSceneInfo;e.onSceneInfo=void 0,j(N)}const _=[];ts&&(b.layers=b.layers.filter(g=>!(ts&&g.isComponent)));const F=g=>{const S=g.startsWith("shaders/")?g:"shaders/"+g,L=g.startsWith("shaders/")?g.slice(8):g,E=He.getEntry(M,S);let N=E?ft(E):kl[L]??null;const j=window.__shaderPatch;if(N&&j){const I=L.replace(/\.(frag|vert|h)$/,""),D=j[I]||j[L];if(typeof D=="function")try{const O=D(N,L);typeof O=="string"&&(N=O)}catch{}}return Promise.resolve(N)},R=De.createRenderer(t,{shaderResolver:F,diag:g=>se(e,n,`renderer: ${g}`),fboCapFactor:0});if(e.renderer=R,s)return;const k=m?.general?.supportsaudioprocessing!==!1,U=zi(),V=xe.createSimulatedMedia(),q=Yi.createSimulatedWindowTitle();let W=null;const Z={mediaDriver:null,lastSnap:{get:()=>null,setHasThumbnail:()=>{}}},K={current:null};let re=V,te=q;const X={enabled:k},J=g=>new Float32Array(g),de={left16:J(16),right16:J(16),left32:J(32),right32:J(32),left64:J(64),right64:J(64),level:0,silent:!0},Se=(()=>{const g={left64:J(64),right64:J(64),left32:J(32),right32:J(32),left16:J(16),right16:J(16),preL64:J(64),preR64:J(64),level:0,silent:!0},S=(L,E)=>{const N=E.length/L.length;for(let j=0;j<L.length;j++){let I=0;const D=Math.floor(j*N),O=Math.max(D+1,Math.floor((j+1)*N));for(let Y=D;Y<O;Y++)I+=E[Y];L[j]=I/(O-D)}};return{active:!1,snapshot:g,pump(){const L=e.audioBridge?.();if(!L||!L.left||!L.right){this.active=!1;return}const E=Math.min(64,L.left.length,L.right.length);let N=0;for(let j=0;j<E;j++){const I=L.left[j]||0,D=L.right[j]||0;g.left64[j]=I,g.right64[j]=D,g.preL64[j]=I,g.preR64[j]=D,j<48&&(N+=I)}for(let j=E;j<64;j++)g.left64[j]=0,g.right64[j]=0,g.preL64[j]=0,g.preR64[j]=0;S(g.left32,g.left64),S(g.right32,g.right64),S(g.left16,g.left64),S(g.right16,g.right64),g.level=Math.min(1,N/48),g.silent=g.level<.02,this.active=!0}}})(),Ae=()=>Se.active?Se.snapshot:K.current?K.current.snapshot:U.snapshot;R.setAudioProvider(()=>X.enabled?Ae():de);const Ie=new Map;window.__audioStats=()=>({enabled:X.enabled,live:!!K.current,level:X.enabled?Math.round((K.current?K.current.snapshot:U.snapshot).level*1e3)/1e3:0,silent:X.enabled?(K.current?K.current.snapshot:U.snapshot).silent:!0,bass:X.enabled?Math.round((K.current?K.current.snapshot:U.snapshot).left64[2]*1e3)/1e3:0}),window.__audioMute=g=>(X.enabled=!g,X.enabled),se(e,n,`audio: ${K.current?"live mic":"simulated"} stream, supportsaudioprocessing=${k}`);const Je=Yi.createShortcutHandler(g=>{se(e,n,`openUserShortcut: ${g}`)}),Xe={enabled:!0,override:null},Ee=[];let Re=null;Z.lastSnap={get:()=>Re,setHasThumbnail:g=>{Re&&(Re.hasThumbnail=g)}};const le=()=>re.snapshot,Pe=g=>{if(!(!g||!g.hasMediaHook||Ee.includes(g))&&(Ee.push(g),!!le().hasMedia))for(const{name:S,event:L}of xe.diffMediaEvents(null,le()))try{g.callMedia(S,L)}catch{}};window.__mediaStats=()=>({enabled:Xe.enabled,live:!!W,hooks:Ee.length,title:le().title,artist:le().artist,album:le().album,state:le().state,position:Math.round(le().position),duration:le().duration,hasThumbnail:le().hasThumbnail,lyric:le().lyricLine,primaryColor:le().primaryColor?[le().primaryColor.x,le().primaryColor.y,le().primaryColor.z]:null}),window.__mediaSet=g=>{Object.assign(le(),g||{});const S=xe.diffMediaEvents(Re,le());for(const{name:L,event:E}of S)for(const N of Ee)N.callMedia(L,E);return Re=xe.cloneMediaSnapshot(le()),window.__mediaStats()};const Oe=()=>{const g=xe.diffMediaEvents(Re,le());for(const{name:S,event:L}of g)for(const E of Ee)try{E.callMedia(S,L)}catch{}Re=xe.cloneMediaSnapshot(le())},Me={get snapshot(){return le()},skipNext:()=>(re.skipNext(),Oe(),le()),skipPrevious:()=>(re.skipPrevious(),Oe(),le()),play:()=>(re.play(),Oe(),le()),pause:()=>(re.pause(),Oe(),le()),playPause:()=>(re.playPause(),Oe(),le())};window.__mediaControl=Me,window.__system={media:Me,windowTitle:te.snapshot,shortcuts:Je.last,live:null},window.__liveSystem=()=>({audio:"off",media:"offline",window:"offline"});const _e=ul.createPointerSource(n.canvas?{target:n.canvas,viewport:()=>({w:n.canvas.clientWidth||window.innerWidth||1,h:n.canvas.clientHeight||window.innerHeight||1})}:{});R.setPointerProvider(()=>_e),e.pointerCtl={push:g=>_e.pushExternal(g),leave:()=>_e.pushExternalLeave()};{const g=u;u=()=>{g?.(),_e.dispose()}}const $e=Qe.createInputView(),Ge=ll.createEngineTimers({setTimeout:(g,S)=>window.setTimeout(g,S),clearTimeout:g=>window.clearTimeout(g),setInterval:(g,S)=>window.setInterval(g,S),clearInterval:g=>window.clearInterval(g)},{onError:(()=>{let g=!1;return S=>{g||(g=!0,se(e,n,`engine \u5B9A\u65F6\u5668\u56DE\u8C03\u629B\u9519\uFF08\u6B64\u540E\u540C\u7C7B\u9759\u9ED8\uFF09: ${String(S?.message||S).slice(0,90)}`))}})()}),ht={setTimeout:Ge.setTimeout,clearTimeout:Ge.clearTimeout,setInterval:Ge.setInterval,clearInterval:Ge.clearInterval};{const g=u;u=()=>{g?.(),Ge.dispose()}}window.__pointerStats=()=>{const g=_e.state,S=L=>Math.round(L*1e3)/1e3;return{normalized:{u:S(g.u),v:S(g.v)},last:{u:S(g.lastU),v:S(g.lastV)},world:{x:Math.round(g.wx),y:Math.round(g.wy)},originY:g.originY!=null?Math.round(g.originY):null,screen:{x:g.screenX,y:g.screenY,w:g.screenW,h:g.screenH},leftDown:g.leftDown,has:g.has,delta:S(_e.normalizedDelta()),counts:{move:g.moveCount,down:g.downCount,up:g.upCount}}};const me=new Map;me.set("util/white",{glTex:De.makeTexture(R.gl,new Uint8Array([255,255,255,255]),1,1),width:1,height:1,rg88:!1}),me.set("util/noflow",{glTex:De.makeTexture(R.gl,new Uint8Array([127,127,127,255]),1,1),width:1,height:1,rg88:!1}),me.set("util/noise",{glTex:De.makeTexture(R.gl,al.generateNoiseTexture(),256,256),width:256,height:256,rg88:!1,mips:null});{const g=L=>{const E=xe.renderThumbnail(L,512);return{glTex:De.makeTextureMip(R.gl,[E],!1),width:E.width,height:E.height,rg88:!1,mips:[E],generated:!0}},S=V.tracks||[];S.length&&(me.set("$mediaThumbnail",g(S[0])),me.set("$mediaPreviousThumbnail",g(S[S.length-1])))}if(n.liveSystem)try{const g=async L=>{try{const E=await fetch(L.url,{cache:"no-store"});if(!E.ok)return;const N=await E.blob(),j=await createImageBitmap(N),I=Cl(j,j.width,j.height,512),D=Pl(j,j.width,j.height);j.close?.();const O=me.get("$mediaThumbnail");O&&me.set("$mediaPreviousThumbnail",O);const Y=R.gl,$=me.get("$mediaThumbnail");$?.glTex?(Y.bindTexture(Y.TEXTURE_2D,$.glTex),Y.texImage2D(Y.TEXTURE_2D,0,Y.RGBA,I.width,I.height,0,Y.RGBA,Y.UNSIGNED_BYTE,I.rgba),$.width=I.width,$.height=I.height,$.mips=[I]):me.set("$mediaThumbnail",{glTex:De.makeTextureMip(Y,[I],!1),width:I.width,height:I.height,rg88:!1,mips:[I],generated:!0});const P=re.snapshot;D&&(P.primaryColor=xe.mediaVec3(...D.primary),P.secondaryColor=xe.mediaVec3(...D.secondary),P.tertiaryColor=xe.mediaVec3(...D.tertiary),P.textColor=xe.mediaVec3(.98,.98,1),P.highContrastColor=xe.mediaVec3(1,1,1)),P.hasThumbnail=!0,Z.lastSnap.setHasThumbnail(!1),se(e,n,`liveSystem: artwork ${L.title||L.trackKey}`)}catch(E){se(e,n,`liveSystem: artwork \u5931\u8D25 (${E instanceof Error?E.message:E})`)}};if(W=await Fl({origin:location.origin,onArtwork:L=>{g(L)}}),re=W.media,te=W.windowTitle,Z.mediaDriver=W.media,W.status().audio==="mic"&&(K.current=W.audio),re.snapshot.hasMedia){for(const{name:L,event:E}of xe.diffMediaEvents(null,re.snapshot))for(const N of Ee)try{N.callMedia(L,E)}catch{}Re=xe.cloneMediaSnapshot(re.snapshot)}const S=W.status();se(e,n,`liveSystem: audio=${S.audio} media=${S.media} window=${S.window}`+(S.title?` title="${S.title}"`:"")+(S.hasArtwork?" artwork=1":"")),se(e,n,`audio: ${K.current?"live mic":"simulated"} stream, supportsaudioprocessing=${k}`),window.__system={media:Me,windowTitle:te.snapshot,shortcuts:Je.last,live:()=>W.status()},window.__liveSystem=()=>W.status()}catch(g){se(e,n,`liveSystem: \u542F\u52A8\u5931\u8D25\uFF0C\u56DE\u9000\u6A21\u62DF\u6E90 (${g instanceof Error?g.message:g})`),W=null}{const g=u;u=()=>{g?.(),W?.dispose(),W=null}}const Ct=new Map,yr=async g=>{if(me.has(g))return me.get(g);const S=He.getEntry(M,`materials/${g}.tex`);if(!S){if(Qt.isBuiltinParticleTextureName(g)){const I=Qt.buildBuiltinParticleTexture(g);if(I){const D={glTex:De.makeTextureMip(R.gl,[I],!1),width:I.width,height:I.height,rg88:!1,mips:[I],generated:!0};return me.set(g,D),D}}return null}const L=hr.parseTex(S),E=hr.decodeMip0(L),N=L.format===8;let j=null;if(E.video!==void 0){const I=URL.createObjectURL(new Blob([E.video],{type:"video/mp4"})),D=wl(I,{muted:!0,renderDpr:Ut(e,n),maxW:t.clientWidth||window.innerWidth||1,maxH:t.clientHeight||window.innerHeight||1});for(const C of[D.active,D.standby])C.style.cssText="position:fixed;left:-9999px;top:-9999px;width:2px;height:2px;opacity:0;pointer-events:none",document.body.appendChild(C),(e.videoTextures??=[]).push(C);(e.objectUrls??=[]).push(I),(e.videoPairs??=[]).push(D),D.active.addEventListener("loadedmetadata",()=>{se(e,n,`video tex '${g}': ${D.active.videoWidth}x${D.active.videoHeight}`)}),D.active.addEventListener("error",()=>{se(e,n,`video tex '${g}' ERROR: ${D.active.error?.code}`)});const O=[],Y=C=>{for(const Q of O)C.addEventListener("ended",Q)},$={play:()=>{s||D.resume()},pause:()=>D.pause(),stop:()=>{D.pause();try{D.active.currentTime=0}catch{}},isPlaying:()=>!D.active.paused&&!D.active.ended,duration:()=>Number.isFinite(D.active.duration)?D.active.duration:0,getCurrentTime:()=>D.active.currentTime||0,setCurrentTime:C=>{try{D.active.currentTime=C}catch{}},getRate:()=>D.active.playbackRate||1,setRate:C=>{D.active.playbackRate=C,D.standby.playbackRate=C},getLoop:()=>D.active.loop,setLoop:C=>{D.active.loop=C,D.standby.loop=C},addEndedCallback:C=>{O.push(C),D.active.addEventListener("ended",C)}},P={get video(){return D.active},glTex:De.makeTexture(R.gl,new Uint8Array([0,0,0,0]),1,1),width:E.width,height:E.height,rg88:!1,lastUploaded:-1,videoCtl:$};let y=0;return D.onSwap=C=>{P.lastUploaded=-1,Y(C),y++,(y===1||y===10||y===100)&&se(e,n,`video tex '${g}' loop swap ok x${y}`)},D.onFallback=()=>{se(e,n,`video tex '${g}' loop fallback (native loop used)`)},me.set(g,P),P}else if(E.png!==void 0||E.image!==void 0&&E.fif===hr.FIF.JPEG){const I=new Blob([E.png||E.image],{type:E.png?"image/png":"image/jpeg"}),D=await createImageBitmap(I);j={glTex:De.makeTexture(R.gl,null,0,0,D),width:D.width,height:D.height,rg88:N}}else{if(E.image!==void 0)return null;{const I=hr.decodeMip0(L);j={glTex:De.makeTextureMip(R.gl,[I],N),width:I.width,height:I.height,rg88:N,mips:[I]}}}if(!j)return null;if(L.frames?.list?.length){const I=L.frames.list;I.atlasWidth=j.width,I.atlasHeight=j.height,j.frames=I}return me.set(g,j),j},_t=g=>{if(me.has(g))return Promise.resolve(me.get(g));const S=Ct.get(g);if(S)return S;const L=yr(g);return Ct.set(g,L),L.finally(()=>{Ct.get(g)===L&&Ct.delete(g)}),L},vr=/uniform\s+sampler2D\s+g_Texture\d+\s*;\s*\/\/[^\n]*"default"\s*:\s*"([^"]+)"/g,po=async g=>{for(const S of g.materialPasses||[])if(S.shader)for(const L of["frag","vert"]){const E=He.getEntry(M,`shaders/${S.shader}.${L}`);if(!E)continue;const N=ft(E);vr.lastIndex=0;let j;for(;(j=vr.exec(N))!==null;){const I=j[1];!I||I.startsWith("util/")||I.startsWith("_rt_")||me.has(I)||await _t(I)}}};let xr=0;const ye=[];for(let g=0;g<b.layers.length;g++){const S=b.layers[g];if(S.image)try{let L;if(Mt.BUILTIN_MODELS[S.image])L=Mt.BUILTIN_MODELS[S.image];else{const P=He.getEntry(M,S.image);if(!P)continue;L=JSON.parse(ft(P))}Ye.applySolidFromModel(S,L);const E=S.srcObject?.instance?.usertextures,N=E?.[0]&&typeof E[0].name=="string"&&E[0].name.startsWith("$")?E[0].name:null,j=N&&me.has(N)?N:null;if(j&&(S.textureName=j,S.solid=!1),L&&typeof L=="object"&&"width"in L&&"height"in L){const P=L;(S.size?.[0]||0)===0&&(S.size?.[1]||0)===0&&P.width>0&&P.height>0&&(S.size=[P.width,P.height])}const I=Ye.resolveMaterial(L);if(!I)continue;let D;if(Mt.BUILTIN_MATERIALS[I.materialPath])D=Mt.BUILTIN_MATERIALS[I.materialPath];else{const P=He.getEntry(M,I.materialPath);if(P)D=JSON.parse(ft(P));else if(S.solid&&Mt.BUILTIN_MATERIALS["materials/util/solidlayer.json"])D=Mt.BUILTIN_MATERIALS["materials/util/solidlayer.json"];else continue}const O=D.passes?.[0],Y=O?.textures||[],$=Y[0];if(O?.combos){for(const P of Object.keys(O.combos))if(P.toLowerCase()==="spritesheet"&&Number(O.combos[P])===1){S.spriteSheet=!0;break}}for(let P=0;P<Y.length;P++){const y=Y[P];typeof y!="string"||!y||y.startsWith("util/")||y.startsWith("_rt_")||ye.push(_t(y).then(C=>{C&&P===0&&!j&&(S.textureName=y,xr++,C.videoCtl&&(S.videoCtl=C.videoCtl))}))}O?.shader&&He.getEntry(M,`shaders/${O.shader}.frag`)&&Mt.attachLayerMaterialEffect(S,O);for(const P of S.effects||[])Mt.resolveEffectChain(M,P,ft);for(const P of S.effects||[]){for(const y of P.passes||[])for(const C of y.textures||[])typeof C=="string"&&C!==""&&!C.startsWith("util/")&&!C.startsWith("_rt_")&&ye.push(_t(C));ye.push(po(P))}}catch(L){console.warn(`\u56FE\u5C42 ${S.name||g} \u52A0\u8F7D\u5931\u8D25: ${L.message}`)}}if(!ns){for(const g of b.layers)if(!(!g.isText||!(g.effects||[]).length))try{for(const S of g.effects||[])Mt.resolveEffectChain(M,S,ft);for(const S of g.effects||[])for(const L of S.passes||[])for(const E of L.textures||[])typeof E=="string"&&E!==""&&!E.startsWith("util/")&&!E.startsWith("_rt_")&&ye.push(_t(E))}catch(S){console.warn(`\u6587\u5B57\u5C42\u6548\u679C ${g.name} \u89E3\u6790\u5931\u8D25: ${S.message}`)}}await Promise.all(ye);for(const[g,S]of me){if(!S?.videoCtl)continue;b.layers.some(E=>E.textureName===g&&E.visible&&!E.destroyed)&&!e.paused&&S.videoCtl.play()}const qe=[],vn=[],Vt=new Map;let wr=0;const Mr=async g=>{const S=await _t(g);if(S)return S;const L=Qt.buildBuiltinParticleTexture(g);if(!L)return null;const E={glTex:De.makeTextureMip(R.gl,[L],!1),width:L.width,height:L.height,rg88:!1,mips:[L],generated:!0,frames:Qt.builtinParticleFrames(g)??void 0};return me.set(g,E),wr++,E},ho=g=>{if(!g)return null;const S=g.mips&&g.mips[0];if(S?.rgba&&typeof Qt.prepareParticleNormalTexture=="function"){const L=Qt.prepareParticleNormalTexture(S);if(L&&L!==S)return{glTex:De.makeTextureMip(R.gl,[L],!1),width:L.width,height:L.height,rg88:!1,mips:[L],generated:!0}}return g},_r=async(g,S,L,E)=>{if(E>3)return null;const N=He.getEntry(M,g);if(!N)return se(e,n,`particle '${g}' \u4E0D\u5728 pkg\uFF0C\u8DF3\u8FC7`),null;const j=JSON.parse(ft(N)),I=new cl.ParticleSystem(R.gl,j,L,S);let D=null,O=null;if(j.material){const y=He.getEntry(M,j.material);if(y){const C=JSON.parse(ft(y));I.setMaterial(C);const Q=C?.passes?.[0]?.textures||[];D=Q[0]||null,O=Q[1]||null}}const Y=await Mr(D||"particle/halo");if(!Y)return se(e,n,`particle '${g}' \u65E0\u8D34\u56FE\u53EF\u7528\uFF0C\u8DF3\u8FC7`),null;I.setTexture({glTex:Y.glTex,width:Y.width,height:Y.height,frames:Y.frames});const $=O||(I.refract?Qt.particleNormalNameForAlbedo(D||"particle/halo"):null);if($){const y=ho(await Mr($));y&&I.setNormalTexture({glTex:y.glTex,width:y.width,height:y.height})}I.setVisible(!!S.visible),qe.push(I);const P=S.id;if(P!==void 0){let y=Vt.get(P);y||(y=[],Vt.set(P,y)),y.push(I)}for(const y of j.children||[]){if(!y||typeof y.name!="string")continue;const C=String(y.origin??"0 0 0").trim().split(/\s+/).map(Number),Q=String(y.scale??"1 1 1").trim().split(/\s+/).map(Number),ee=String(y.angles??"0 0 0").trim().split(/\s+/).map(Number),ie=y.type==="eventfollow"?"particle":!y.type||y.type==="static"?"origin":null,oe=I.localToWorld(C[0]||0,C[1]||0),fe={...S,origin:[oe[0],oe[1],(S.origin?.[2]||0)+(C[2]||0)],scale:[(S.scale?.[0]??1)*(Q[0]||1),(S.scale?.[1]??1)*(Q[1]||1),(S.scale?.[2]??1)*(Q[2]||1)],angles:[(S.angles?.[0]||0)+(ee[0]||0),(S.angles?.[1]||0)+(ee[1]||0),(S.angles?.[2]||0)+(ee[2]||0)]},be=await _r(y.name,fe,y.instanceoverride||L,E+1);be&&ie&&be.attachFollow(I,ie,[C[0]||0,C[1]||0,C[2]||0])}return I};if(!Ml){for(const g of b.layers)if(g.particle)try{await _r(g.particle,g,g.instanceoverride,0)}catch(S){console.warn(`\u7C92\u5B50\u56FE\u5C42 ${g.name} \u52A0\u8F7D\u5931\u8D25: ${S.message}`),se(e,n,`particle '${g.name}' FAIL: ${S.message.slice(0,80)}`)}}if(qe.length>0){const g=u;u=()=>{g?.();for(const S of qe)S.dispose()}}const xn=[];for(const g of b.layers)if(!(!g.sound||!g.sound.length))try{for(const S of g.sound){const L=He.getEntry(M,S);if(!L)continue;const E=(S.split(".").pop()||"").toLowerCase(),N=E==="mp3"?"audio/mpeg":E==="ogg"?"audio/ogg":E==="flac"?"audio/flac":"audio/wav",j=new Blob([L],{type:N}),I=URL.createObjectURL(j);(e.objectUrls??=[]).push(I);const D=document.createElement("audio");D.src=I,D.loop=g.soundprops?.playbackmode==="loop",D.volume=Math.max(0,Math.min(1,g.soundprops?.volume??1)),D.muted=n.muted!==!1,g.soundCtl={play(){if(D.ended)try{D.currentTime=0}catch{}D.play().catch(()=>{})},pause(){D.pause()},stop(){D.pause();try{D.currentTime=0}catch{}},isPlaying:()=>!D.paused&&!D.ended,getVolume:()=>D.volume,setVolume:O=>{D.volume=Math.max(0,Math.min(1,O))}},!g.soundprops?.startsilent&&!e.paused&&D.play().catch(()=>{}),xn.push(D);break}}catch(S){console.warn(`\u58F0\u97F3\u56FE\u5C42 ${g.name} \u52A0\u8F7D\u5931\u8D25: ${S.message}`)}const mo=g=>{for(const S of xn)S.volume=Math.max(0,Math.min(1,g)),S.muted=g<=0};if(e.sceneAudio={setVolume:mo,audios:xn},s)return;let tn=performance.now(),Vn=0;R.setParticleRenderer(()=>{const g=performance.now(),S=Math.min(.05,(g-tn)/1e3);if(tn=g,_e.state.has){const{wx:L,wy:E,originY:N}=_e.state,j=N??E;for(const I of qe)I.setPointer(L,j)}if(vn.length)for(const L of vn)L.syncLayerTransform();for(const L of qe)L.advance(S,X.enabled?Ae():null);if(Vn<2&&(Vn++,Vn===2)){const L=qe.reduce((E,N)=>E+N.liveCount(),0);se(e,n,`particles live: ${L} across ${qe.length} systems`)}},(g,S,L,E,N)=>{if(g===void 0)return;const j=Vt.get(g);if(j)for(const I of j)I.render(L,E,N,S.projW,S.projH)}),se(e,n,`particles: ${qe.length} systems, ${wr} builtin tex generated`),window.__particleStats=()=>qe.map(g=>{let S=0,L=1/0,E=-1/0,N=1/0,j=-1/0,I=1/0,D=-1/0;for(const O of g.pool){if(!O.alive)continue;S++;const Y=g.originX+O.x*g.scaleX,$=g.originY+O.y*g.scaleY;Y<L&&(L=Y),Y>E&&(E=Y),$<N&&(N=$),$>j&&(j=$);const P=Math.abs(O.size)*g.sysScale;P<I&&(I=P),P>D&&(D=P)}return{live:S,max:g.maxCount,blend:g.blend,renderer:g.renderers.map(O=>O.kind).join("+"),origin:[Math.round(g.originX),Math.round(g.originY)],bbox:S?[Math.round(L),Math.round(N),Math.round(E),Math.round(j)]:null,size:S?[Math.round(I),Math.round(D)]:null}}),window.__particleToggle=(g,S)=>{for(let L=0;L<qe.length;L++)qe[L].setVisible(S===void 0?g:L===S);return qe.length};const At=[],nn=new Map,Wt=g=>{if(!g||!g.puppet)return null;let S=nn.get(g);return S||(S=new Map,nn.set(g,S)),S};for(const g of b.layers)if(g.image)try{if(Mt.BUILTIN_MODELS[g.image])continue;const S=He.getEntry(M,g.image);if(!S)continue;const L=JSON.parse(ft(S));if(!L.puppet)continue;const E=He.getEntry(M,L.puppet);if(!E)continue;const N=jn.parseMDL(new Uint8Array(E)),j=g.textureName?me.get(g.textureName):null;if(!j){se(e,n,`puppet '${g.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}g.puppet=N,At.push({mdl:N,tex:j,layer:g});const I=N.animations[0];se(e,n,`puppet '${g.name}' v=${N.vertexCount} bones=${N.bones.length}`+(I?` anim='${I.name}' ${I.fps}fps\xD7${I.frameCount}`:" \u65E0\u52A8\u753B"))}catch(S){console.warn(`puppet \u56FE\u5C42 ${g.name} \u52A0\u8F7D\u5931\u8D25: ${S.message}`),se(e,n,`puppet '${g.name}' \u5931\u8D25: ${S.message}`)}for(const g of b.layers)if(g.model&&!g.puppet)try{const S=He.getEntry(M,g.model);if(!S)continue;const L=jn.parseMDL(new Uint8Array(S));let E=null;if(L.materialPath){const j=He.getEntry(M,L.materialPath);if(j){const D=JSON.parse(ft(j))?.passes?.[0]?.textures?.[0];typeof D=="string"&&D&&(E=D)}}E&&(await _t(E),g.textureName=E);const N=E?me.get(E):null;if(!N){se(e,n,`model '${g.name}' \u65E0\u8D34\u56FE\uFF0C\u8DF3\u8FC7`);continue}g.puppet=L,At.push({mdl:L,tex:N,layer:g}),se(e,n,`model '${g.name}' v=${L.vertexCount} static ${L.materialPath||""}`)}catch(S){console.warn(`model \u56FE\u5C42 ${g.name} \u52A0\u8F7D\u5931\u8D25: ${S.message}`),se(e,n,`model '${g.name}' \u5931\u8D25: ${S.message}`)}let at=null;if(At.length>0)try{at=jn.createMDLRenderer(R.gl);for(const S of At)at.upload(S.mdl);const g=new Map;for(const S of At)g.set(S.layer,S);R.setPuppetRenderer((S,L,E)=>{const N=g.get(S);N&&at.draw(L,N.mdl,{time:E.time,animLayers:S.animationLayers,boneOverrides:nn.get(S),overrideTex:E.overrideTex||null,color:[S.color[0]*S.brightness,S.color[1]*S.brightness,S.color[2]*S.brightness,S.alpha]},N.tex)})}catch(g){console.warn(`puppet \u6E32\u67D3\u5668\u521D\u59CB\u5316\u5931\u8D25: ${g.message}`),se(e,n,`puppet renderer \u5931\u8D25: ${g.message}`),at=null;for(const S of At)S.layer.puppet=null}if(s)return;se(e,n,`puppet: ${At.length} meshes`);const we=jn.applyAttachmentBindOrigins(b.layers);we.length&&se(e,n,`attachments: ${we.length} hanging layers`);const ct=Ye.collectTransformDirty(b.layers,we.map(g=>g.layer));if(ct.size){se(e,n,`transform graph: ${ct.size} live layers`);for(const[g,S]of Vt)if(ct.has(g))for(const L of S)vn.push(L)}const lt=[],mt=new Map,rn={};let Ke=null,on=null,Ar=0;if(!ns&&b.layers.some(g=>g.isText)){const g=b.general?.orthogonalprojection,S=g?.width||t.width,L=g?.height||t.height,E=Ir(un(e.cfg.fit),S,L,t.width,t.height),N=Math.min(3,Math.max(.5,t.width/Math.max(1,E.viewW))),j=new Map,I=[],D=new Set;for(const $ of b.layers)$.isText&&$.textFont&&D.add($.textFont);for(const $ of M.entries||[])typeof $.name=="string"&&/^fonts\/.+\.(ttf|otf|woff2?)$/i.test($.name)&&D.add($.name);for(const $ of D){const P=`${n.src}|${$}`,y=gr.get(P);if(y){y.refs++,I.push(P),j.set($,y.family);continue}const C=Ul[$.toLowerCase()];if(C){j.set($,C);continue}try{const Q=He.getEntry(M,$);if(!Q)continue;const ee=Nl(Q instanceof Uint8Array?Q:new Uint8Array(Q)),ie="wefont_"+Bl(P)+"_"+$.split("/").pop().replace(/[^a-zA-Z0-9]/g,"_"),oe=URL.createObjectURL(new Blob([ee])),fe=new FontFace(ie,`url(${oe})`);if(await fe.load(),s){URL.revokeObjectURL(oe);break}document.fonts.add(fe),(e.objectUrls??=[]).push(oe),j.set($,ie),gr.set(P,{family:ie,refs:1}),I.push(P)}catch(Q){console.warn(`\u5B57\u4F53\u52A0\u8F7D\u5931\u8D25 ${$}: ${Q.message}`)}}if(I.length){const $=e.sceneCleanup;e.sceneCleanup=()=>{Dl(I),$?.()}}Ke=document.createElement("canvas"),on=Ke.getContext("2d");const O=2048;for(const $ of b.layers)if($.isText)try{const P={layer:$,sandbox:null,texName:"__wstext_"+$.id,entry:null,lastKey:null,quality:N};if($.textScript&&(P.sandbox=Qe.evalTextScript($.textScript,$.textScriptProps,{text:$.text??"",font:$.textFont||"",pointsize:$.textPointsize,color:$.textColor,angles:$.angles,origin:$.origin,scale:$.scale,visible:$.visible,canvasSize:{width:S,height:L},userProperties:v,shared:rn,audioViews:Ie,inputView:$e,...ht,mediaControl:Me,windowTitle:te.snapshot,openUserShortcut:Je.openUserShortcut,getLayerText:ee=>mt.get(ee),onError:ee=>{se(e,n,`text script '${$.name}' \u5931\u8D25: ${String(ee.message||ee).slice(0,120)}`)}}),P.sandbox&&(_.push(P.sandbox),P.sandbox.init(),P.sandbox.applyUserProperties(v),P.sandbox.hasMediaHook&&Pe(P.sandbox))),mt.set($.name||"",String($.text??"")),$.textAnchor!=="center"&&$.size[0]>0&&$.size[1]>0){const ee=$.size[0]*($.scale[0]||1)/2,ie=$.size[1]*($.scale[1]||1)/2,oe=$.textAnchor;let fe=0,be=0;oe.includes("left")&&(fe+=ee),oe.includes("right")&&(fe-=ee),oe.includes("top")&&(be-=ie),oe.includes("bottom")&&(be+=ie),$.origin[0]+=fe,$.origin[1]+=be,$.localOrigin&&($.localOrigin[0]+=fe,$.localOrigin[1]+=be)}const y=rs*Math.max(1,$.textPointsize),C=Qe.textLayerHasTintMask($)?8:256,Q=Math.min(C,Qe.textCanvasMargin(y,0));P.boxW=$.size[0]>0?$.size[0]:y*4,P.boxH=$.size[1]>0?$.size[1]:y*1.6,P.margin=Q,$.size=[P.boxW+Q*2,P.boxH+Q*2],P.entry={glTex:De.makeTexture(R.gl,new Uint8Array([0,0,0,0]),1,1),width:1,height:1,rg88:!1},me.set(P.texName,P.entry),$.textureName=P.texName,$.solid=!1,lt.push(P)}catch(P){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${$.name} \u521D\u59CB\u5316\u5931\u8D25: ${P.message}`)}if(lt.length>0){const $=u;u=()=>{$?.();for(const P of lt)R.gl.deleteTexture(P.entry.glTex)}}const Y=$=>{if(!on||!Ke)return;const P=on;for(const y of lt){const C=y.layer;let Q=String(C.text??"");if(y.sandbox&&y.sandbox.hasUpdate){y.sandbox.engine.runtime=$;const fe=y.sandbox.callUpdate(Q);fe!=null?Q=String(fe):y.sandbox.thisLayer.text&&(Q=String(y.sandbox.thisLayer.text))}else y.sandbox&&typeof y.sandbox.thisLayer?.text=="string"&&(Q=String(y.sandbox.thisLayer.text));if(mt.set(C.name||"",Q),!C.visible)continue;const ee=Math.max(1,y.sandbox?y.sandbox.thisLayer.pointsize:C.textPointsize),ie=y.sandbox&&y.sandbox.thisLayer.font||C.textFont||"",oe=`${Q}\0${ee}\0${ie}\0${C.alpha}\0${C.textCastshadow}`;if(y.lastKey!==oe){y.lastKey=oe;try{const fe=rs*ee,be=y.boxW,rt=y.boxH,gt=y.margin,bt=Math.abs(C.scale[0]||1),kt=Math.abs(C.scale[1]||1);let je=Math.max(1,Math.round(C.size[0]*bt*y.quality)),ce=Math.max(1,Math.round(C.size[1]*kt*y.quality));const pe=Math.min(1,O/Math.max(je,ce));je=Math.max(1,Math.round(je*pe)),ce=Math.max(1,Math.round(ce*pe)),Ke.width!==je||Ke.height!==ce?(Ke.width=je,Ke.height=ce):(P.setTransform(1,0,0,1,0,0),P.clearRect(0,0,je,ce));const ue=Math.min(je/C.size[0],ce/C.size[1]);P.setTransform(ue,0,0,ue,0,0),P.translate(gt,gt);const Ce=ie&&j.get(ie)||"sans-serif";P.font=`${fe}px "${Ce}", sans-serif`;const ot=P.measureText(""),et=(ot.fontBoundingBoxAscent||0)+(ot.fontBoundingBoxDescent||0),ut=C.textSpacing||[0,0],it=Qe.layoutText(Q,{boxW:be,boxH:rt,pointsize:fe,lineHeight:(et>0?et:fe*1.25)+ut[1],spacing:ut,padding:C.textPadding||0,maxwidth:C.textMaxwidth||0,limitwidth:!!C.textLimitwidth,maxrows:C.textMaxrows||0,limitrows:!!C.textLimitrows,limituseellipsis:!!C.textLimituseellipsis,halign:C.textHAlign,valign:C.textVAlign},An=>P.measureText(An).width);Qe.drawTextLayer(P,it,{font:P.font,color:C.textColor,alpha:C.alpha,brightness:C.brightness,spacing:ut,pointsize:fe,opaquebackground:!!C.textOpaquebackground,backgroundcolor:C.textBackgroundcolor,backgroundbrightness:C.textBackgroundbrightness,castshadow:!!C.textCastshadow});const Le=y.entry;R.gl.bindTexture(R.gl.TEXTURE_2D,Le.glTex),R.gl.texImage2D(R.gl.TEXTURE_2D,0,R.gl.RGBA,R.gl.RGBA,R.gl.UNSIGNED_BYTE,Ke),Le.width=je,Le.height=ce}catch(fe){console.warn(`\u6587\u5B57\u5BF9\u8C61 ${C.name} \u7ED8\u5236\u5931\u8D25: ${fe.message}`),y.lastKey=null}}}};e.sceneTextUpdate=Y,window.__textWidgets=lt,se(e,n,`text widgets: ${lt.length} (scripts ${lt.filter($=>$.sandbox).length}, fonts ${j.size}, quality ${N.toFixed(2)})`)}if(s)return;const sn=[],Wn=[],Ht=[],wn={},an=[],Xt=[],Fe=new Map,Lt=(g,S)=>{if(!S||typeof S.callCursor!="function"||!S.hasCursorHook)return;const L=Fe.get(g);L?L.push(S):Fe.set(g,[S])};for(const g of lt)g.sandbox&&Lt(g.layer,g.sandbox);{const g=b.general?.orthogonalprojection,S=g?.width||t.width,L=g?.height||t.height,E=v,N=(P,y)=>{const C=b.general||{};if(P==="zoom"&&typeof y=="number"&&Number.isFinite(y)&&y>0){b.cameraTransforms.zoom=y,C.zoom&&typeof C.zoom=="object"?C.zoom.value=y:C.zoom=y;return}C[P]&&typeof C[P]=="object"&&"value"in C[P]?C[P].value=y:C[P]=y};let j=1+Math.max(0,...b.layers.map(P=>Number(P.id)||0));const I={recomputeVisibility:T,getSceneLayer:P=>b.layers.find(y=>y.name===P&&!y.destroyed)||null,getSceneLayerById:P=>b.layers.find(y=>y.id===P&&!y.destroyed)||null,enumerateSceneLayers:()=>b.layers.filter(P=>!P.destroyed),getSceneAnimation:P=>{if(P==null||P==="")return null;if(wn[P])return wn[P];for(const y of b.layers)if(y.animations&&y.animations[P])return y.animations[P];return null},cameraTransforms:b.cameraTransforms,getInitialLayerConfig:P=>{const y=P&&typeof P=="object"?P.name:String(P||"");return b.layers.find(C=>C.name===y)||null},createSceneLayer:P=>{let y=P&&typeof P=="object"?P:null;if(typeof P=="string"){const Q=P;if(y=b.layers.find(ee=>ee&&!ee.destroyed&&ee.image===Q&&ee.textureName)||b.layers.find(ee=>ee&&!ee.destroyed&&ee.image===Q)||null,!y)return se(e,n,`createLayer('${Q}') \u627E\u4E0D\u5230\u5DF2\u52A0\u8F7D\u7684\u540C\u6A21\u578B\u5C42`),null}y||(y={});const C={...y,id:j++,origin:Array.isArray(y.origin)?y.origin.slice():[0,0,0],scale:Array.isArray(y.scale)?y.scale.slice():[1,1,1],angles:Array.isArray(y.angles)?y.angles.slice():[0,0,0],size:Array.isArray(y.size)?y.size.slice():[0,0],color:Array.isArray(y.color)?y.color.slice():[1,1,1],childIds:null,hasChildren:!1,destroyed:!1,animations:{},animationList:[],objectScripts:null};return delete C.textureAnimation,delete C.videoTextureApi,delete C.soundCtl,delete C.videoCtl,Array.isArray(y.effects)&&(C.effects=y.effects.map(Q=>({...Q,passes:Array.isArray(Q.passes)?Q.passes.map(ee=>({...ee})):Q.passes}))),b.layers.push(C),C},mediaControl:Me,windowTitle:te.snapshot,openUserShortcut:Je.openUserShortcut,isScreensaver:!1};R.setConstantScriptRuntime?.(Qe.evalObjectScript,{userProperties:E,audioViews:Ie,shared:rn,inputView:$e,timers:Ge,...I,onSandbox:P=>{P&&P.hasMediaHook&&Pe(P)}});const D={origin:"localOrigin",scale:"localScale",angles:"localAngles"},O=(P,y)=>{const C=D[y];return C&&P&&Array.isArray(P[C])?C:y};for(const P of b.layers){const y=P.objectAnimations;if(y){P.animations=P.animations||{},P.animationList=P.animationList||[];for(const[C,Q]of Object.entries(y))try{const ee=Zi.createAnimation(Q.animation);ee.field=C,ee.baseValue=Q.value;const ie=O(P,C),oe=P[ie];ee.baseNumeric=Array.isArray(oe)?oe.slice():oe,ee.slot=ie,P.animationList.push(ee),ee.name&&(P.animations[ee.name]=ee),Wn.push({layer:P,field:C,slot:ie,ctrl:ee})}catch(ee){se(e,n,`animation '${P.name}.${C}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(ee.message).slice(0,80)}`)}}}for(const P of b.layers){for(const[C,Q]of(P.effects||[]).entries()){const ee=Q.visibleScript;if(ee)try{const ie=Qe.evalObjectScript(ee.script,ee.scriptproperties,{canvasSize:{width:S,height:L},userProperties:E,audioViews:Ie,inputView:$e,...ht,layer:P,targetEffect:Q,...I,shared:rn,onError:oe=>se(e,n,`effect visible script '${P.name}#${C}' \u5931\u8D25: ${String(oe.message||oe).slice(0,80)}`)});if(!ie)continue;_.push(ie),ie.init(Q.visible),ie.applyUserProperties(E),ie.hasMediaHook&&Pe(ie),ie.hasUpdate&&an.push({effect:Q,sandbox:ie})}catch(ie){console.warn(`\u6548\u679C\u5F00\u5173\u811A\u672C ${P.name}#${C} \u6C42\u503C\u5931\u8D25: ${ie.message}`)}}const y=P.objectScripts;if(y)for(const[C,Q]of Object.entries(y))try{const ee=Qe.evalObjectScript(Q.script,Q.scriptproperties,{canvasSize:{width:S,height:L},screenResolution:{x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1},timeOfDay:(()=>{const ie=new Date;return(ie.getHours()*3600+ie.getMinutes()*60+ie.getSeconds())/86400})(),userProperties:E,audioViews:Ie,inputView:$e,layer:P,...I,getBoneOverrides:Wt,shared:rn,...ht,onError:ie=>se(e,n,`object script '${P.name}.${C}' \u5931\u8D25: ${String(ie.message||ie).slice(0,90)}`)});if(ee){_.push(ee);const ie=O(P,C),oe=P[ie],fe=C==="angles"&&Array.isArray(oe)?Qe.radToScriptAngles(oe):Array.isArray(oe)?{x:oe[0]??0,y:oe[1]??0,z:oe[2]??0}:oe;ee.init(fe),ee.applyUserProperties(E),Lt(P,ee),ee.hasMediaHook&&Pe(ee),ee.hasUpdate&&sn.push({layer:P,field:C,slot:ie,kind:C==="visible"?"bool":C==="alpha"||C==="brightness"?"scalar":"vec3",sandbox:ee})}}catch(ee){console.warn(`\u5BF9\u8C61\u811A\u672C ${P.name}.${C} \u6C42\u503C\u5931\u8D25: ${ee.message}`)}}const Y=b.generalScripts;if(Y){for(const[P,y]of Object.entries(Y))try{const C=Qe.evalObjectScript(y.script,y.scriptproperties,{canvasSize:{width:S,height:L},userProperties:E,audioViews:Ie,inputView:$e,...ht,...I,shared:rn,onError:ee=>se(e,n,`general script '${P}' \u5931\u8D25: ${String(ee.message||ee).slice(0,80)}`)});if(!C)continue;_.push(C),C.init(y.value),C.applyUserProperties(E),C.hasMediaHook&&Pe(C);const Q=ee=>N(P,ee);C.hasUpdate&&Xt.push({field:P,sandbox:C,write:Q})}catch(C){console.warn(`general \u811A\u672C ${P} \u6C42\u503C\u5931\u8D25: ${C.message}`)}Xt.length&&se(e,n,`general scripts: ${Xt.map(P=>P.field).join(",")}`)}const $=b.generalAnimations;if($){for(const[P,y]of Object.entries($))try{const C=Zi.createAnimation(y.animation);C.field=P,C.baseValue=y.value,C.baseNumeric=y.value,C.name&&(wn[C.name]=C),Ht.push({field:P,ctrl:C,write:Q=>N(P,Q)})}catch(C){se(e,n,`general animation '${P}' \u5EFA\u63A7\u5236\u5668\u5931\u8D25: ${String(C.message).slice(0,80)}`)}Ht.length&&se(e,n,`general animations: ${Ht.map(P=>P.field).join(",")}`)}}sn.length&&(se(e,n,`object scripts: ${sn.length}`),window.__objScripts=sn),window.__mediaHooks=Ee,window.__sceneLayers=b.layers,window.__compositeStats=()=>R.compositeStats?.()??null,window.__compositeEnable=g=>R.setCompositeEnabled?.(g),window.__scene=b,window.__textures=me;const Rt=Array.from(Fe.keys());Rt.length&&se(e,n,`cursor hooks: ${Rt.length} layers`);let Gt=null,qt=null,Mn=!1;const cn=()=>({worldPosition:Qe.makeCursorEventVec(_e.state.wx,_e.state.originY!=null?_e.state.originY:_e.state.wy,0)}),Yt=(g,S,L)=>{const E=Fe.get(g);if(E)for(const N of E)N.callCursor(S,L)},Tr=()=>{if(Rt.length===0)return;const g=_e.state;if(!g.has)return;const S=R.getParallaxOffset?R.getParallaxOffset():{x:0,y:0},L=b.general?.orthogonalprojection?.height||t.height,E=fl.hitTestLayers(b.layers,g.wx,g.wy,L,{parOffX:S.x,parOffY:S.y,alignTable:De.ALIGN,filter:j=>Fe.has(j)}),N=cn();E!==Gt&&(Gt&&Yt(Gt,"cursorLeave",N),Gt=E,E&&Yt(E,"cursorEnter",N)),E&&Yt(E,"cursorMove",N),g.leftDown&&!Mn?(qt=E,E&&Yt(E,"cursorDown",N)):!g.leftDown&&Mn&&(qt&&Yt(qt,"cursorUp",N),qt&&qt===E&&Yt(E,"cursorClick",N),qt=null),Mn=g.leftDown},Sr=performance.now();let Er=0,ln=0;const _n=[],Ft=[];let x=-1/0,B=0;const H=g=>{if(s||e.paused)return;const L=1e3/(e.cfg.sceneFps||60);if(g-x>=L){if(x=g,qn(e,g),e.onFirstFrame){const O=e.onFirstFrame;e.onFirstFrame=void 0,O()}xo(e,t,e.cfg);const E=(g-Sr-Er)/1e3;if($e.update(_e.state),Xe.enabled){W?.media?W.media.pump():V.update(E);const O=le(),Y=xe.diffMediaEvents(Re,O);if(Y.length){for(const{name:$,event:P}of Y)for(const y of Ee)y.disabled||y.callMedia($,P);Re=xe.cloneMediaSnapshot(O)}}W?.windowTitle?W.windowTitle.pump():q.update(E);const N=Math.max(0,E-B);B=E;for(const O of Wn){O.ctrl.advance(N);const Y=O.field,$=O.slot||Y,P=O.ctrl.applyTo(O.ctrl.baseNumeric);if(Array.isArray(P)){const y=O.layer[$];if(Array.isArray(y))for(let C=0;C<P.length&&C<y.length;C++)y[C]=P[C]}else Number.isFinite(P)&&(Y==="visible"?O.layer[Y]=!!P:O.layer[$]=P)}for(const O of Ht){O.ctrl.advance(N);const Y=O.ctrl.applyTo(O.ctrl.baseNumeric);typeof Y=="number"&&Number.isFinite(Y)?O.write(Y):Array.isArray(Y)&&Number.isFinite(Y[0])&&O.write(Y[0])}for(const O of an){if(O.sandbox.disabled)continue;O.sandbox.engine.frametime=N,O.sandbox.engine.runtime=E;const Y=O.sandbox.callUpdate(!!O.effect.visible);typeof Y=="boolean"&&(O.effect.visible=Y)}for(const O of Xt){if(O.sandbox.disabled)continue;O.sandbox.engine.frametime=N,O.sandbox.engine.runtime=E;const Y=b.general||{},$=Y[O.field]&&typeof Y[O.field]=="object"&&"value"in Y[O.field]?Y[O.field].value:Y[O.field],P=O.sandbox.callUpdate($);P!==void 0&&O.write(P)}const j={x:t.clientWidth||window.innerWidth||1,y:t.clientHeight||window.innerHeight||1};for(const O of _)!O||O.disabled||(O.engine.frametime=N,O.engine.runtime=E,O.engine.screenResolution=j);let I=!1;for(const O of sn){if(O.sandbox.disabled)continue;O.sandbox.engine.frametime=N,O.sandbox.engine.runtime=E,O.sandbox.engine.screenResolution=j;const Y=O.layer[O.field];if(O.kind==="bool"){const $=O.sandbox.callUpdate(!!Y);typeof $=="boolean"&&(O.field==="visible"?O.layer.visibleSelf!==$&&(O.layer.visibleSelf=$,I=!0):O.layer[O.field]=$)}else if(O.kind==="scalar"){const $=O.sandbox.callUpdate(Number(Y)||0),P=Number($);Number.isFinite(P)&&(O.layer[O.field]=P)}else{const $=O.slot||O.field,P=O.layer[$],y=O.field==="angles"?Qe.radToScriptAngles(P):{x:P[0]||0,y:P[1]||0,z:P[2]||0},C=O.sandbox.callUpdate(y),Q=C&&typeof C=="object"&&"x"in C?C:y;O.layer[$]=O.field==="angles"?Qe.scriptAnglesToRad(Q):[Q.x||0,Q.y||0,Q.z||0]}}I&&T(),ct.size&&Ye.recomposeWorld(b.layers,ct),X.enabled&&(Se.pump(),Se.active||(K.current?K.current.pump():U.update(E)),qc(Ie,Ae())),we.length&&jn.followAttachments(we,E,Wt);const D=e.coverAlign;R.render(b,me,t.width,t.height,E,un(e.cfg.fit),D.x,D.y).then(()=>{if(!(s||e.paused)){try{Tr()}catch{}_e.beginFrame();try{e.sceneTextUpdate&&g>=Ar&&(Ar=g+100,e.sceneTextUpdate(E))}catch{}e.raf=requestAnimationFrame(H)}}).catch(O=>{console.warn("scene render error:",O),se(e,n,`render: ${String(O.message||O).slice(0,200)}`),s=!0})}else e.paused||(e.raf=requestAnimationFrame(H))},z=()=>{s||e.paused||e.raf===void 0&&(e.raf=requestAnimationFrame(H))},G=g=>{if(s)return;const S=b.properties||{},L=Vs(S,v,g);if(Object.keys(L).length){for(const E of b.layers){const N=E.srcObject;if(!N)continue;fn(N,S,0);const j=vt(N.visible);j&&j in L&&(E.visibleSelf=Ye.parseBool(N.visible,!0));const I=vt(N.color);I&&I in L&&(E.color=Ye.parseColor(N.color),E.isText&&(E.textColor=E.color));const D=vt(N.alpha);D&&D in L&&(E.alpha=Ye.parseNum(N.alpha,1));const O=vt(N.brightness);O&&O in L&&(E.brightness=Ye.parseNum(N.brightness,1));const Y=vt(N.volume);if(Y&&Y in L){const P=Ye.parseNum(N.volume,1);E.soundprops&&(E.soundprops.volume=P),E.soundCtl?.setVolume?.(P)}for(let P=0;P<(N.animationlayers||[]).length;P++){const y=N.animationlayers[P],C=E.animationLayers?.[P];if(!y||!C)continue;const Q=vt(y.visible);Q&&Q in L&&(C.visible=Ye.parseBool(y.visible,!0));const ee=vt(y.rate);ee&&ee in L&&(C.rate=Ye.parseNum(y.rate,1));const ie=vt(y.blend);ie&&ie in L&&(C.blend=Ye.parseNum(y.blend,1))}for(let P=0;P<(N.effects||[]).length;P++){const y=N.effects[P],C=E.effects?.[P];if(!y||!C)continue;const Q=vt(y.visible);Q&&Q in L&&!C.visibleScript&&(C.visible=Ye.parseBool(y.visible,!0))}const $=N.instanceoverride;if($&&typeof $=="object"&&E.particle){let P=!1;for(const y of Object.keys($)){if(y==="id")continue;const C=vt($[y]);if(C&&C in L){P=!0;break}}if(P){const y=Vt.get(E.id);if(y)for(const C of y)C.reapplyOverride?.()}}}for(const E of _)if(!(!E||E.disabled))try{E.applyUserProperties(L)}catch{}T();for(const E of b.layers){if(!E.particle)continue;const N=Vt.get(E.id);if(N)for(const j of N)j.setVisible(!!E.visible)}R.applyConstUserProperties?.(L);for(const E of lt)E.lastKey=null;se(e,n,`props hot: ${Object.keys(L).join(",")}`)}};f=()=>{e.raf!==void 0&&(cancelAnimationFrame(e.raf),e.raf=void 0),ln||(ln=performance.now()),_n.length=0;for(const g of me.values())g?.videoCtl?.isPlaying?.()&&(_n.push(g.videoCtl),g.videoCtl.pause());Ft.length=0;for(const g of xn)!g.paused&&!g.ended&&(Ft.push(g),g.pause())},d=()=>{ln&&(Er+=performance.now()-ln,ln=0),tn=performance.now();for(const g of _n)try{g.play()}catch{}_n.length=0;for(const g of Ft)g.play().catch(()=>{});Ft.length=0,z()},p=G,l&&(G(l),l=null),z();{const g=b.general?.orthogonalprojection,S=g?.width||t.width,L=g?.height||t.height,E=un(e.cfg.fit),N=Ir(E,S,L,t.width,t.height);se(e,n,`fit ${E}: view ${Math.round(N.viewW)}x${Math.round(N.viewH)} scene ${S}x${L} canvas ${t.width}x${t.height}`)}se(e,n,`renderer started: ${b.layers.length} layers`)}catch(w){if(s||w&&w.name==="AbortError")return;console.warn("scene render failed:",w);const M=w instanceof Error?w:new Error(String(w));se(e,n,`failed: ${String(M.message||M).slice(0,200)}`),e.onError?e.onError(M):e.fallbackPage?.()}})()}const zl='data-we-shim="1"',is="data-we-shim-src";function Vl(e){try{const n=new URL(e),t=n.pathname,r=t.lastIndexOf("/");return n.pathname=r<0?"/":t.slice(0,r+1),n.hash="",n.search="",n.href}catch{const n=e.replace(/[#?].*$/,""),t=n.lastIndexOf("/");return t<0?n:n.slice(0,t+1)}}function Wl(e){const n=/<meta[^>]+http-equiv\s*=\s*["']?Content-Security-Policy["']?[^>]*>/gi;let t;for(;t=n.exec(e);){const r=t[0],o=/content\s*=\s*"([^"]*)"/i.exec(r)?.[1]??/content\s*=\s*'([^']*)'/i.exec(r)?.[1]??"";if(/script-src/i.test(o)&&!/script-src[^;]*'unsafe-inline'/i.test(o)&&!/script-src[^;]*\*/i.test(o))return!0}return!1}function ss(e){return e.replace(/<\/script/gi,"<\\/script")}function Hl(e,n,t){if(e||(e=""),e.includes(zl)||e.includes(is))return e;const r=t.baseHref&&!/<base\b/i.test(e)?`<base href="${t.baseHref.replace(/"/g,""")}">`:"",o=`<script ${is}="1">
|
|
513
|
+
${ss(n)}
|
|
514
|
+
<\/script>`,i=t.seedScript&&t.seedScript.trim()?`<script>
|
|
515
|
+
${ss(t.seedScript)}
|
|
516
|
+
<\/script>`:"",s=`${r}${o}${i}`,a=/<head(\s[^>]*)?>/i.exec(e);if(a){const u=a.index+a[0].length;return e.slice(0,u)+s+e.slice(u)}const c=/<html(\s[^>]*)?>/i.exec(e);if(c){const u=c.index+c[0].length;return e.slice(0,u)+`<head>${s}</head>`+e.slice(u)}return`<!DOCTYPE html><html><head>${s}</head><body>${e}</body></html>`}const Xl=`/**
|
|
517
|
+
* WE \u7F51\u9875\u58C1\u7EB8\u517C\u5BB9 shim\uFF08\u6CE8\u5165\u5230 iframe\uFF0C\u5FC5\u987B\u5728\u4F5C\u8005\u811A\u672C\u4E4B\u524D\u6267\u884C\uFF09\u3002
|
|
518
|
+
*
|
|
519
|
+
* \u8BED\u6599\uFF1A\u672C\u673A\u5E93 42 \u5F20 web \u58C1\u7EB8\u626B\u63CF\uFF082026-09\uFF09\u2014\u2014
|
|
520
|
+
* wallpaperPropertyListener 29 / RegisterAudioListener 22 /
|
|
521
|
+
* RequestRandomFileForProperty 8 / userDirectoryFiles* 9 /
|
|
522
|
+
* Media*Listener 2 / PluginListener 2
|
|
523
|
+
*
|
|
524
|
+
* \u5B98\u65B9 CEF \u5728\u4EFB\u4F55\u58C1\u7EB8\u811A\u672C\u524D\u5C31\u628A\u8FD9\u4E9B\u505A\u6210\u539F\u751F\u51FD\u6570\uFF1B\u5DE5\u574A\u9876\u5C42\u76F4\u63A5\u6CE8\u518C\u3002
|
|
525
|
+
* \u672C\u6587\u4EF6\u4F5C\u4E3A <head> \u9996\u4E2A classic script \u63D2\u5165\u3002
|
|
526
|
+
*
|
|
527
|
+
* \u7236\u9875\u63A7\u5236\u9762 __we*\uFF08main.ts weShimCall / web.ts \u6CF5\uFF09\uFF1A
|
|
528
|
+
* __weSetPaused / __weSetFps / __weSetVolume / __weApplyProps / __weSeedProps
|
|
529
|
+
* __wePushAudio(arr128)
|
|
530
|
+
* __wePushMedia(event) \u2014 {op, payload} \u89C1\u4E0B
|
|
531
|
+
* __wePushDirectoryFiles(prop, files) / __weRemoveDirectoryFiles(prop, files)
|
|
532
|
+
* __weRewriteFileUrl(s) \u2014 file:/// \u2192 \u540C\u6E90\u76F8\u5BF9\uFF08HTTP \u9875\uFF09\uFF1B\u7A7A file:/// \u2192 ""
|
|
533
|
+
* __wePushPointer(x, y, buttons) / __wePointerLeave() \u2014 \u5916\u90E8\u6307\u9488\u6CE8\u5165\uFF08\u89C1\u6587\u672B\uFF09
|
|
534
|
+
*/
|
|
535
|
+
(function (w) {
|
|
536
|
+
"use strict";
|
|
537
|
+
try {
|
|
538
|
+
if (w.document && w.document.documentElement) {
|
|
539
|
+
w.document.documentElement.setAttribute("data-we-shim", "1");
|
|
540
|
+
}
|
|
541
|
+
} catch (_) {
|
|
542
|
+
/* \u5FFD\u7565 */
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
var audioListener = null;
|
|
546
|
+
var propertyListener = null;
|
|
547
|
+
var paused = false;
|
|
548
|
+
var fps = 60;
|
|
549
|
+
var volume = 0;
|
|
550
|
+
var pendingProps = null;
|
|
551
|
+
var pendingGeneral = null;
|
|
552
|
+
var rafMap = Object.create(null);
|
|
553
|
+
var rafCounter = 0;
|
|
554
|
+
var origRaf = w.requestAnimationFrame.bind(w);
|
|
555
|
+
var origCaf = w.cancelAnimationFrame.bind(w);
|
|
556
|
+
|
|
557
|
+
// \u5B98\u65B9 CEF \u4EE5\u6587\u4EF6\u7CFB\u7EDF\u4E3A\u6E90\uFF0C\u4F5C\u8005\u666E\u904D \`'file:///' + value\`\u3002HTTP \u540C\u6E90\u9875\u91CC
|
|
558
|
+
// file:///files/x.webm \u52A0\u8F7D\u5931\u8D25\uFF1B\u7A7A value \u53D8\u6210 file:///\uFF081748506393\uFF09\u3002
|
|
559
|
+
// file: \u534F\u8BAE\u9875\u4FDD\u6301\u539F\u6837\uFF08\u771F\u672C\u5730\u5D4C\u5165\uFF09\u3002
|
|
560
|
+
function rewriteBareFileUrl(url) {
|
|
561
|
+
if (typeof url !== "string") return url;
|
|
562
|
+
var s = url.trim();
|
|
563
|
+
if (!/^file:/i.test(s)) return s;
|
|
564
|
+
try {
|
|
565
|
+
var loc = w.location;
|
|
566
|
+
if (loc && loc.protocol === "file:") return s;
|
|
567
|
+
} catch (_) {
|
|
568
|
+
/* \u5FFD\u7565 */
|
|
569
|
+
}
|
|
570
|
+
var rest = s.replace(/^file:\\/\\//i, "").replace(/^\\/+/, "");
|
|
571
|
+
if (!rest) return "";
|
|
572
|
+
if (/^[a-zA-Z][:|]/.test(rest)) return "";
|
|
573
|
+
if (/^(Users|home|tmp|var|etc|private|Volumes)\\//.test(rest)) return "";
|
|
574
|
+
try {
|
|
575
|
+
var href = w.location && w.location.href;
|
|
576
|
+
if (href) return new URL(rest, href).href;
|
|
577
|
+
} catch (_) {
|
|
578
|
+
/* \u5FFD\u7565 */
|
|
579
|
+
}
|
|
580
|
+
return rest;
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function rewriteWeFileUrl(input) {
|
|
584
|
+
if (typeof input !== "string") return input;
|
|
585
|
+
if (/url\\(/i.test(input)) {
|
|
586
|
+
return input.replace(/url\\(\\s*(['"]?)([^)'"]*?)\\1\\s*\\)/gi, function (_m, q, inner) {
|
|
587
|
+
var next = rewriteBareFileUrl(inner);
|
|
588
|
+
if (!next) return "none";
|
|
589
|
+
var quote = q || '"';
|
|
590
|
+
return "url(" + quote + next + quote + ")";
|
|
591
|
+
});
|
|
592
|
+
}
|
|
593
|
+
return rewriteBareFileUrl(input);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
w.__weRewriteFileUrl = rewriteWeFileUrl;
|
|
597
|
+
|
|
598
|
+
function installFileUrlHooks() {
|
|
599
|
+
try {
|
|
600
|
+
if (w.Element && w.Element.prototype && typeof w.Element.prototype.setAttribute === "function") {
|
|
601
|
+
var origSetAttr = w.Element.prototype.setAttribute;
|
|
602
|
+
w.Element.prototype.setAttribute = function (name, value) {
|
|
603
|
+
var n = String(name || "").toLowerCase();
|
|
604
|
+
if (n === "src" || n === "href" || n === "poster") value = rewriteWeFileUrl(value);
|
|
605
|
+
return origSetAttr.call(this, name, value);
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
} catch (_) {
|
|
609
|
+
/* \u65E0 DOM \u7684 verifier \u8DF3\u8FC7 */
|
|
610
|
+
}
|
|
611
|
+
var ctorNames = ["HTMLImageElement", "HTMLMediaElement", "HTMLSourceElement", "HTMLScriptElement"];
|
|
612
|
+
for (var i = 0; i < ctorNames.length; i++) {
|
|
613
|
+
try {
|
|
614
|
+
var Ctor = w[ctorNames[i]];
|
|
615
|
+
if (!Ctor || !Ctor.prototype) continue;
|
|
616
|
+
var desc = Object.getOwnPropertyDescriptor(Ctor.prototype, "src");
|
|
617
|
+
if (!desc || typeof desc.set !== "function") continue;
|
|
618
|
+
(function (d) {
|
|
619
|
+
Object.defineProperty(Ctor.prototype, "src", {
|
|
620
|
+
configurable: true,
|
|
621
|
+
enumerable: d.enumerable,
|
|
622
|
+
get: d.get,
|
|
623
|
+
set: function (v) {
|
|
624
|
+
d.set.call(this, rewriteWeFileUrl(v));
|
|
625
|
+
},
|
|
626
|
+
});
|
|
627
|
+
})(desc);
|
|
628
|
+
} catch (_) {
|
|
629
|
+
/* \u5FFD\u7565\u5355\u4E2A\u539F\u578B */
|
|
630
|
+
}
|
|
631
|
+
}
|
|
632
|
+
try {
|
|
633
|
+
var styleDesc =
|
|
634
|
+
w.HTMLElement && Object.getOwnPropertyDescriptor(w.HTMLElement.prototype, "style");
|
|
635
|
+
// Chromium \u7684 backgroundImage \u4E0D\u662F\u539F\u578B\u81EA\u6709\u63CF\u8FF0\u7B26\uFF0C\u53EA\u80FD\u5305 HTMLElement.style \u7684 Proxy\u3002
|
|
636
|
+
if (styleDesc && typeof styleDesc.get === "function" && w.Proxy && w.WeakMap) {
|
|
637
|
+
var styleCache = new w.WeakMap();
|
|
638
|
+
Object.defineProperty(w.HTMLElement.prototype, "style", {
|
|
639
|
+
configurable: true,
|
|
640
|
+
enumerable: styleDesc.enumerable,
|
|
641
|
+
get: function () {
|
|
642
|
+
var raw = styleDesc.get.call(this);
|
|
643
|
+
if (!raw) return raw;
|
|
644
|
+
var cached = styleCache.get(raw);
|
|
645
|
+
if (cached) return cached;
|
|
646
|
+
var proxy = new w.Proxy(raw, {
|
|
647
|
+
set: function (target, prop, value) {
|
|
648
|
+
if (typeof value === "string" && typeof prop === "string" && /background/i.test(prop)) {
|
|
649
|
+
value = rewriteWeFileUrl(value);
|
|
650
|
+
}
|
|
651
|
+
target[prop] = value;
|
|
652
|
+
return true;
|
|
653
|
+
},
|
|
654
|
+
get: function (target, prop) {
|
|
655
|
+
var v = target[prop];
|
|
656
|
+
if (typeof v === "function") return v.bind(target);
|
|
657
|
+
return v;
|
|
658
|
+
},
|
|
659
|
+
});
|
|
660
|
+
styleCache.set(raw, proxy);
|
|
661
|
+
return proxy;
|
|
662
|
+
},
|
|
663
|
+
set: styleDesc.set,
|
|
664
|
+
});
|
|
665
|
+
}
|
|
666
|
+
var styleProto = w.CSSStyleDeclaration && w.CSSStyleDeclaration.prototype;
|
|
667
|
+
if (styleProto && typeof styleProto.setProperty === "function") {
|
|
668
|
+
var origSetProp = styleProto.setProperty;
|
|
669
|
+
styleProto.setProperty = function (name, value, priority) {
|
|
670
|
+
if (typeof value === "string" && /background/i.test(String(name || ""))) {
|
|
671
|
+
value = rewriteWeFileUrl(value);
|
|
672
|
+
}
|
|
673
|
+
return origSetProp.call(this, name, value, priority);
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
} catch (_) {
|
|
677
|
+
/* \u5FFD\u7565 */
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
installFileUrlHooks();
|
|
681
|
+
|
|
682
|
+
// propertyName \u2192 string[]\uFF08\u7EDD\u5BF9/\u76F8\u5BF9\u8DEF\u5F84\uFF1B\u968F\u673A\u6587\u4EF6\u4ECE\u6B64\u62BD\uFF09
|
|
683
|
+
var directoryFiles = Object.create(null);
|
|
684
|
+
|
|
685
|
+
var mediaListeners = {
|
|
686
|
+
properties: null,
|
|
687
|
+
thumbnail: null,
|
|
688
|
+
playback: null,
|
|
689
|
+
timeline: null,
|
|
690
|
+
status: null,
|
|
691
|
+
};
|
|
692
|
+
// \u665A\u6CE8\u518C\u65F6\u56DE\u653E\u6700\u8FD1\u4E00\u5E27\uFF08\u4F5C\u8005\u811A\u672C\u5E38\u5728 DOMContentLoaded \u540E\u624D Register\uFF09
|
|
693
|
+
var lastMedia = {
|
|
694
|
+
properties: null,
|
|
695
|
+
thumbnail: null,
|
|
696
|
+
playback: null,
|
|
697
|
+
timeline: null,
|
|
698
|
+
status: null,
|
|
699
|
+
};
|
|
700
|
+
|
|
701
|
+
function callApplyUserProperties(props) {
|
|
702
|
+
if (!propertyListener || typeof propertyListener.applyUserProperties !== "function") return;
|
|
703
|
+
try {
|
|
704
|
+
propertyListener.applyUserProperties(props || {});
|
|
705
|
+
} catch (_) {
|
|
706
|
+
/* \u58C1\u7EB8\u811A\u672C\u629B\u9519\u4E0D\u6253\u65AD\u5BBF\u4E3B */
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
|
|
710
|
+
function callApplyGeneralProperties(props) {
|
|
711
|
+
if (!propertyListener || typeof propertyListener.applyGeneralProperties !== "function") return;
|
|
712
|
+
try {
|
|
713
|
+
propertyListener.applyGeneralProperties(props || {});
|
|
714
|
+
} catch (_) {
|
|
715
|
+
/* \u5FFD\u7565 */
|
|
716
|
+
}
|
|
717
|
+
}
|
|
718
|
+
|
|
719
|
+
function callSetPaused(v) {
|
|
720
|
+
if (!propertyListener || typeof propertyListener.setPaused !== "function") return;
|
|
721
|
+
try {
|
|
722
|
+
propertyListener.setPaused(!!v);
|
|
723
|
+
} catch (_) {
|
|
724
|
+
/* \u5FFD\u7565 */
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
function callDirectoryAdded(prop, files) {
|
|
729
|
+
if (!propertyListener || typeof propertyListener.userDirectoryFilesAddedOrChanged !== "function")
|
|
730
|
+
return;
|
|
731
|
+
try {
|
|
732
|
+
propertyListener.userDirectoryFilesAddedOrChanged(prop, files);
|
|
733
|
+
} catch (_) {
|
|
734
|
+
/* \u5FFD\u7565 */
|
|
735
|
+
}
|
|
736
|
+
}
|
|
737
|
+
|
|
738
|
+
function callDirectoryRemoved(prop, files) {
|
|
739
|
+
if (!propertyListener || typeof propertyListener.userDirectoryFilesRemoved !== "function") return;
|
|
740
|
+
try {
|
|
741
|
+
propertyListener.userDirectoryFilesRemoved(prop, files);
|
|
742
|
+
} catch (_) {
|
|
743
|
+
/* \u5FFD\u7565 */
|
|
744
|
+
}
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
function flushPending() {
|
|
748
|
+
if (pendingProps) {
|
|
749
|
+
var p = pendingProps;
|
|
750
|
+
pendingProps = null;
|
|
751
|
+
callApplyUserProperties(p);
|
|
752
|
+
}
|
|
753
|
+
if (pendingGeneral) {
|
|
754
|
+
var g = pendingGeneral;
|
|
755
|
+
pendingGeneral = null;
|
|
756
|
+
callApplyGeneralProperties(g);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
|
|
760
|
+
/**
|
|
761
|
+
* \u5DE5\u574A\u5E38\u5728 React render \u91CC\u5199 \`window.wallpaperPropertyListener = {\u2026}\`\uFF082905017768\uFF09\u3002
|
|
762
|
+
* \u5B98\u65B9 CEF \u4E0D\u4F1A\u5728\u8D4B\u503C\u5F53\u4E0B\u540C\u6B65\u56DE\u8C03 setPaused/apply*\uFF1B\u82E5\u6211\u4EEC\u540C\u6B65 flush\uFF0C
|
|
763
|
+
* \u7B49\u4E8E render \u4E2D setState \u2192 React \u7194\u65AD \u2192 #root \u7A7A\uFF08\u4E00\u7247\u9ED1\uFF09\u3002
|
|
764
|
+
*/
|
|
765
|
+
function afterAssign(fn) {
|
|
766
|
+
try {
|
|
767
|
+
if (typeof w.queueMicrotask === "function") w.queueMicrotask(fn);
|
|
768
|
+
else w.setTimeout(fn, 0);
|
|
769
|
+
} catch (_) {
|
|
770
|
+
try {
|
|
771
|
+
fn();
|
|
772
|
+
} catch (_) {
|
|
773
|
+
/* \u5FFD\u7565 */
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
function safeCall(fn, arg) {
|
|
779
|
+
if (typeof fn !== "function") return;
|
|
780
|
+
try {
|
|
781
|
+
fn(arg);
|
|
782
|
+
} catch (_) {
|
|
783
|
+
/* \u5FFD\u7565 */
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
// \u2014\u2014 \u5A92\u4F53\u96C6\u6210\u679A\u4E3E\uFF083747222633\uFF1A\u7F3A\u7701\u65F6 PLAYBACK_PLAYING||0 \u4F1A\u628A\u300C\u64AD\u653E\u300D\u5F53\u6210 0\uFF09\u2014\u2014
|
|
788
|
+
w.wallpaperMediaIntegration = {
|
|
789
|
+
PLAYBACK_STOPPED: 0,
|
|
790
|
+
PLAYBACK_PLAYING: 1,
|
|
791
|
+
PLAYBACK_PAUSED: 2,
|
|
792
|
+
};
|
|
793
|
+
|
|
794
|
+
// \u2014\u2014 \u5B98\u65B9 API\uFF1A\u97F3\u9891 \u2014\u2014
|
|
795
|
+
w.wallpaperRegisterAudioListener = function (cb) {
|
|
796
|
+
audioListener = typeof cb === "function" ? cb : null;
|
|
797
|
+
};
|
|
798
|
+
|
|
799
|
+
// \u2014\u2014 \u5B98\u65B9 API\uFF1A\u5A92\u4F53 \u2014\u2014
|
|
800
|
+
w.wallpaperRegisterMediaPropertiesListener = function (cb) {
|
|
801
|
+
mediaListeners.properties = typeof cb === "function" ? cb : null;
|
|
802
|
+
if (mediaListeners.properties && lastMedia.properties) {
|
|
803
|
+
safeCall(mediaListeners.properties, lastMedia.properties);
|
|
804
|
+
}
|
|
805
|
+
};
|
|
806
|
+
w.wallpaperRegisterMediaThumbnailListener = function (cb) {
|
|
807
|
+
mediaListeners.thumbnail = typeof cb === "function" ? cb : null;
|
|
808
|
+
if (mediaListeners.thumbnail && lastMedia.thumbnail) {
|
|
809
|
+
safeCall(mediaListeners.thumbnail, lastMedia.thumbnail);
|
|
810
|
+
}
|
|
811
|
+
};
|
|
812
|
+
w.wallpaperRegisterMediaPlaybackListener = function (cb) {
|
|
813
|
+
mediaListeners.playback = typeof cb === "function" ? cb : null;
|
|
814
|
+
if (mediaListeners.playback && lastMedia.playback) {
|
|
815
|
+
safeCall(mediaListeners.playback, lastMedia.playback);
|
|
816
|
+
}
|
|
817
|
+
};
|
|
818
|
+
w.wallpaperRegisterMediaTimelineListener = function (cb) {
|
|
819
|
+
mediaListeners.timeline = typeof cb === "function" ? cb : null;
|
|
820
|
+
if (mediaListeners.timeline && lastMedia.timeline) {
|
|
821
|
+
safeCall(mediaListeners.timeline, lastMedia.timeline);
|
|
822
|
+
}
|
|
823
|
+
};
|
|
824
|
+
w.wallpaperRegisterMediaStatusListener = function (cb) {
|
|
825
|
+
mediaListeners.status = typeof cb === "function" ? cb : null;
|
|
826
|
+
if (mediaListeners.status && lastMedia.status) {
|
|
827
|
+
safeCall(mediaListeners.status, lastMedia.status);
|
|
828
|
+
}
|
|
829
|
+
};
|
|
830
|
+
|
|
831
|
+
// \u2014\u2014 \u5B98\u65B9 API\uFF1A\u968F\u673A\u6587\u4EF6\uFF08slideshow\uFF09\u2014\u2014
|
|
832
|
+
// \u56DE\u8C03\u7B7E\u540D\uFF1Afunction(propertyName, filePath)\u3002\u65E0\u5E93\u5B58\u6587\u4EF6\u65F6 filePath \u4E3A\u7A7A\u4E32\uFF08\u8BED\u6599 if(i) \u5B88\u536B\uFF09\u3002
|
|
833
|
+
w.wallpaperRequestRandomFileForProperty = function (propertyName, callback) {
|
|
834
|
+
if (typeof callback !== "function") return;
|
|
835
|
+
var prop = String(propertyName || "");
|
|
836
|
+
var list = directoryFiles[prop];
|
|
837
|
+
var path = "";
|
|
838
|
+
if (list && list.length) {
|
|
839
|
+
path = String(list[(Math.random() * list.length) | 0] || "");
|
|
840
|
+
}
|
|
841
|
+
try {
|
|
842
|
+
callback(prop, path);
|
|
843
|
+
} catch (_) {
|
|
844
|
+
/* \u5FFD\u7565 */
|
|
845
|
+
}
|
|
846
|
+
};
|
|
847
|
+
|
|
848
|
+
// \u2014\u2014 PropertyListener\uFF08getter/setter\uFF1B\u56DE\u8C03\u5EF6\u540E\u5230\u5FAE\u4EFB\u52A1\uFF0C\u89C1 afterAssign\uFF09\u2014\u2014
|
|
849
|
+
// \u5B98\u65B9\u5728\u9875\u9762\u52A0\u8F7D\u5B8C\u6210\u540E\u624D\u53D1\u5168\u91CF\u5C5E\u6027/\u6682\u505C\u72B6\u6001\uFF1B\u9996\u5C4F\u811A\u672C\uFF08body onLoad=init \u7B49\uFF09\u5E38
|
|
850
|
+
// \u5047\u8BBE\u5C5E\u6027\u5230\u8FBE\u65F6 DOM/\u573A\u666F\u5DF2\u521D\u59CB\u5316\uFF08827982449\uFF1AapplyUserProperties\u2192cl() \u5728 load \u524D
|
|
851
|
+
// \u8DD1\u4F1A\u649E\u4E0A\u672A\u521B\u5EFA\u7684 scene/material\uFF09\u3002\u672A\u52A0\u8F7D\u5B8C\u6210\u65F6\u7B49 window load + \u4E00\u4E2A\u5B8F\u4EFB\u52A1
|
|
852
|
+
// \uFF08\u4FDD\u8BC1\u6392\u5728 onLoad \u5C5E\u6027\u5904\u7406\u5668\u4E4B\u540E\uFF09\uFF0C\u5DF2\u52A0\u8F7D\u5B8C\u6210\u5219\u5FAE\u4EFB\u52A1\u5373\u53D1\u3002
|
|
853
|
+
function whenPageReady(fn) {
|
|
854
|
+
var ready = "complete";
|
|
855
|
+
try {
|
|
856
|
+
ready = w.document.readyState;
|
|
857
|
+
} catch (_) {
|
|
858
|
+
/* \u5FFD\u7565 */
|
|
859
|
+
}
|
|
860
|
+
if (ready === "complete") {
|
|
861
|
+
afterAssign(fn);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
try {
|
|
865
|
+
w.addEventListener("load", function () {
|
|
866
|
+
// setTimeout \u4FDD\u8BC1\u6392\u5728 load \u540C\u6B65\u94FE\uFF08onLoad \u5904\u7406\u5668\uFF09\u4E4B\u540E
|
|
867
|
+
w.setTimeout(fn, 0);
|
|
868
|
+
}, { once: true });
|
|
869
|
+
} catch (_) {
|
|
870
|
+
afterAssign(fn);
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
Object.defineProperty(w, "wallpaperPropertyListener", {
|
|
874
|
+
configurable: true,
|
|
875
|
+
enumerable: true,
|
|
876
|
+
get: function () {
|
|
877
|
+
return propertyListener;
|
|
878
|
+
},
|
|
879
|
+
set: function (v) {
|
|
880
|
+
var next = v && typeof v === "object" ? v : null;
|
|
881
|
+
var prev = propertyListener;
|
|
882
|
+
propertyListener = next;
|
|
883
|
+
if (!next) return;
|
|
884
|
+
// \u4EC5\u9996\u6B21\u6CE8\u518C\u8865\u53D1\u6302\u8F7D\u72B6\u6001\u3002\u5B98\u65B9 CEF \u4ECE\u4E0D\u5728\u8D4B\u503C\u5F53\u4E0B\u56DE\u8C03\uFF1B2905017768 \u7B49 React \u58C1\u7EB8\u5728
|
|
885
|
+
// \u6E32\u67D3\u4F53\u91CC\u91CD\u65B0\u8D4B\u503C\uFF08\u65B0\u5BF9\u8C61\u5B57\u9762\u91CF\uFF09\uFF0C\u82E5\u6BCF\u6B21\u90FD\u8865 setPaused \u4F1A\u5F62\u6210
|
|
886
|
+
// \u6E32\u67D3 \u2192 \u8D4B\u503C \u2192 \u8865\u53D1 setState \u2192 \u518D\u6E32\u67D3 \u7684\u5FAE\u4EFB\u52A1\u6B7B\u5FAA\u73AF\uFF08\u70B9\u4E0B\u4E00\u66F2\u6574\u9875\u5361\u6B7B\uFF09\u3002
|
|
887
|
+
if (prev) return;
|
|
888
|
+
whenPageReady(function () {
|
|
889
|
+
flushPending();
|
|
890
|
+
callApplyGeneralProperties({ fps: fps });
|
|
891
|
+
callSetPaused(paused);
|
|
892
|
+
// \u5DF2\u7F13\u5B58\u7684\u76EE\u5F55\u6587\u4EF6\u8865\u63A8\u4E00\u6B21\uFF08\u4F5C\u8005\u53EF\u80FD\u540E\u6302 userDirectoryFilesAddedOrChanged\uFF09
|
|
893
|
+
for (var prop in directoryFiles) {
|
|
894
|
+
if (Object.prototype.hasOwnProperty.call(directoryFiles, prop) && directoryFiles[prop].length) {
|
|
895
|
+
callDirectoryAdded(prop, directoryFiles[prop].slice());
|
|
896
|
+
}
|
|
897
|
+
}
|
|
898
|
+
});
|
|
899
|
+
},
|
|
900
|
+
});
|
|
901
|
+
|
|
902
|
+
// \u2014\u2014 Plugin\uFF08iCUE \u7B49\uFF1B\u65E0\u786C\u4EF6\u65F6\u7A7A\u5B9E\u73B0\uFF0C\u907F\u514D if \u5224\u65AD\u5931\u8D25\uFF09\u2014\u2014
|
|
903
|
+
if (!w.wallpaperPluginListener) {
|
|
904
|
+
w.wallpaperPluginListener = {
|
|
905
|
+
onPluginLoaded: function () {},
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
|
|
909
|
+
// \u2014\u2014 \u5B9A\u65F6\u5668\u51BB\u7ED3\uFF1A\u5B98\u65B9\u6682\u505C = "fully freeze the process that renders the wallpaper"\uFF0C
|
|
910
|
+
// rAF \u5DF2\u5728\u8282\u6D41\u5C42\u6302\u8D77\uFF0C\u8FD9\u91CC\u51BB\u7ED3\u5B9A\u65F6\u5668\uFF1A\u6682\u505C\u671F\u95F4\u65B0\u5EFA\u7684\u6302\u8D77\u767B\u8BB0\u3001\u6062\u590D\u65F6\u6309\u539F\u5EF6\u8FDF/\u95F4\u9694
|
|
911
|
+
// \u91CD\u65B0\u542F\u52A8\uFF1B**\u5DF2\u542F\u52A8**\u7684\u771F\u5B9A\u65F6\u5668\u5230\u671F\u7531\u5305\u88C5\u56DE\u8C03\u62E6\u4E0B\u2014\u2014timeout \u8F6C\u6302\u8D77\uFF08\u6062\u590D\u540E\u7ACB\u5373\u8865\u8DD1\uFF0C
|
|
912
|
+
// \u8FD1\u4F3C\u5B98\u65B9\u7684\u5269\u4F59\u7B49\u5F85\uFF09\uFF0Cinterval \u76F4\u63A5\u8DF3\u8FC7\u8BE5\u5468\u671F\uFF08\u6062\u590D\u540E\u4ECE\u4E0B\u4E2A\u5468\u671F\u7EE7\u7EED\uFF09\u3002
|
|
913
|
+
var pendTimers = [];
|
|
914
|
+
var tmSeq = 0;
|
|
915
|
+
var TM_BASE = 0x40000000; // \u5047 id \u6BB5\uFF0C\u907F\u514D\u4E0E\u771F\u5B9E timer id \u6DF7\u6DC6
|
|
916
|
+
var origST = w.setTimeout;
|
|
917
|
+
var origSI = w.setInterval;
|
|
918
|
+
var origCTO = w.clearTimeout;
|
|
919
|
+
var origCIT = w.clearInterval;
|
|
920
|
+
function guardTimeout(fn) {
|
|
921
|
+
if (typeof fn !== "function") return fn;
|
|
922
|
+
return function () {
|
|
923
|
+
if (paused) {
|
|
924
|
+
pendTimers.push({ id: 0, kind: "t", fn: fn, ms: 1, extra: [] });
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
return fn.apply(this, arguments);
|
|
928
|
+
};
|
|
929
|
+
}
|
|
930
|
+
function guardInterval(fn) {
|
|
931
|
+
if (typeof fn !== "function") return fn;
|
|
932
|
+
return function () {
|
|
933
|
+
if (paused) return;
|
|
934
|
+
return fn.apply(this, arguments);
|
|
935
|
+
};
|
|
936
|
+
}
|
|
937
|
+
function startTimer(kind, fn, ms, extra) {
|
|
938
|
+
if (paused) {
|
|
939
|
+
var id = TM_BASE + ++tmSeq;
|
|
940
|
+
pendTimers.push({ id: id, kind: kind, fn: fn, ms: ms, extra: extra });
|
|
941
|
+
return id;
|
|
942
|
+
}
|
|
943
|
+
var args = [kind === "t" ? guardTimeout(fn) : guardInterval(fn), ms].concat(extra);
|
|
944
|
+
return (kind === "t" ? origST : origSI).apply(w, args);
|
|
945
|
+
}
|
|
946
|
+
w.setTimeout = function (fn, ms) {
|
|
947
|
+
return startTimer("t", fn, ms, Array.prototype.slice.call(arguments, 2));
|
|
948
|
+
};
|
|
949
|
+
w.setInterval = function (fn, ms) {
|
|
950
|
+
return startTimer("i", fn, ms, Array.prototype.slice.call(arguments, 2));
|
|
951
|
+
};
|
|
952
|
+
function unpend(id) {
|
|
953
|
+
for (var i = 0; i < pendTimers.length; i++) {
|
|
954
|
+
if (pendTimers[i].id === id) {
|
|
955
|
+
pendTimers.splice(i, 1);
|
|
956
|
+
return true;
|
|
957
|
+
}
|
|
958
|
+
}
|
|
959
|
+
return false;
|
|
960
|
+
}
|
|
961
|
+
w.clearTimeout = function (id) {
|
|
962
|
+
if (unpend(id)) return;
|
|
963
|
+
origCTO.call(w, id);
|
|
964
|
+
};
|
|
965
|
+
w.clearInterval = function (id) {
|
|
966
|
+
if (unpend(id)) return;
|
|
967
|
+
origCIT.call(w, id);
|
|
968
|
+
};
|
|
969
|
+
function resumeTimers() {
|
|
970
|
+
var list = pendTimers;
|
|
971
|
+
pendTimers = [];
|
|
972
|
+
for (var i = 0; i < list.length; i++) {
|
|
973
|
+
var t = list[i];
|
|
974
|
+
(t.kind === "t" ? origST : origSI).call(w, t.fn, t.ms, t.extra);
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* \u6062\u590D\u6682\u505C\u671F\u95F4\u88AB\u6302\u8D77\u7684 rAF \u8BF7\u6C42\u3002
|
|
980
|
+
*
|
|
981
|
+
* **\u4E0D\u8865\u8DD1\u8FD9\u4E9B\u56DE\u8C03\uFF0C\u4E3B\u5FAA\u73AF\u5C31\u6C38\u4E45\u65AD\u6389**\uFF081278092907 Monstercat\uFF1A\`draw()\` \u5728\u51FD\u6570\u4F53
|
|
982
|
+
* \u5F00\u5934\u5C31 \`requestAnimationFrame(draw)\` \u518D\u753B\uFF0C\u6682\u505C\u671F\u95F4\u90A3\u6B21\u8BF7\u6C42\u88AB\u767B\u8BB0\u6210 hold\uFF0C
|
|
983
|
+
* \u6062\u590D\u540E\u6CA1\u4EBA\u8DD1\u5B83 \u2192 \u6574\u6761\u94FE\u6CA1\u6709\u4E0B\u4E00\u5E27\uFF0C\u753B\u9762\u6C38\u4E45\u5B9A\u683C\uFF0C\u4E14\u6CA1\u6709\u4EFB\u4F55\u62A5\u9519\uFF09\u3002
|
|
984
|
+
* \u8FD9\u662F rAF \u81EA\u9012\u5F52\u7684\u901A\u7528\u5F62\u6001\uFF0C\u4E0D\u662F\u8FD9\u4E00\u5F20\u7684\u7279\u4F8B\u3002
|
|
985
|
+
*
|
|
986
|
+
* \u8D70 \`w.requestAnimationFrame\` \u800C\u4E0D\u662F \`origRaf\`\uFF1A\u6B64\u65F6\u5DF2 unpaused\uFF0C\u8981\u8BA9\u5B83\u91CD\u65B0\u7ECF\u8FC7
|
|
987
|
+
* \u8282\u6D41\u5C42\uFF08\u4F4E fps \u65F6\u8BE5\u8D70 setTimeout \u8DEF\u5F84\uFF09\uFF0C\u5E76\u7167\u5E38\u53D1 we-frame \u6253\u70B9\u3002
|
|
988
|
+
*/
|
|
989
|
+
function resumeRafHolds() {
|
|
990
|
+
var holds = [];
|
|
991
|
+
for (var id in rafMap) {
|
|
992
|
+
if (!Object.prototype.hasOwnProperty.call(rafMap, id)) continue;
|
|
993
|
+
if (rafMap[id] && rafMap[id].kind === "hold") {
|
|
994
|
+
holds.push(rafMap[id].cb);
|
|
995
|
+
delete rafMap[id];
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
for (var i = 0; i < holds.length; i++) {
|
|
999
|
+
try {
|
|
1000
|
+
w.requestAnimationFrame(holds[i]);
|
|
1001
|
+
} catch (_) {
|
|
1002
|
+
/* \u5355\u4E2A\u56DE\u8C03\u91CD\u6302\u5931\u8D25\u4E0D\u5F71\u54CD\u5176\u5B83 */
|
|
1003
|
+
}
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
// \u2014\u2014 \u5A92\u4F53\u97F3\u91CF\uFF1A\u5BF9\u9F50\u5B98\u65B9 CEF \u8BED\u4E49\uFF08\u6D4F\u89C8\u5668\u7EA7\u4E3B\u97F3\u91CF\u4E0E\u4F5C\u8005\u9875\u9762\u5185\u97F3\u91CF\u72EC\u7ACB\u76F8\u4E58\uFF09\u2014\u2014
|
|
1008
|
+
// \u4F5C\u8005\u5E38\u5728\u64AD\u653E\u524D\u91CD\u8BBE a.volume = uiVolume\uFF08Bocchi\uFF09\uFF0C\u4E14\u97F3\u9891\u591A\u4E3A \`new Audio()\` \u4E0D\u8FDB
|
|
1009
|
+
// DOM\u2014\u2014querySelectorAll \u627E\u4E0D\u5230\u3001\u76F4\u63A5\u8986\u76D6 volume \u53C8\u4F1A\u88AB\u4F5C\u8005\u56DE\u5199\u3002\u56E0\u6B64 hook \u539F\u578B\uFF1A
|
|
1010
|
+
// setter \u8BB0\u4F5C\u8005\u503C\uFF0C\u5143\u7D20\u5B9E\u9645\u97F3\u91CF = \u4F5C\u8005\u503C \xD7 \u4E3B\u97F3\u91CF\uFF1B\`__weSetVolume\` \u6539\u7CFB\u6570\u5E76\u5237\u65B0
|
|
1011
|
+
// \u5168\u90E8\u6D3B\u5B9E\u4F8B\uFF08DOM \u5185 + Audio \u6784\u9020\u5668\u767B\u8BB0\u7684 WeakRef\uFF09\u3002
|
|
1012
|
+
var hostVolume = 1;
|
|
1013
|
+
var liveMedia = []; // WeakRef<HTMLMediaElement>
|
|
1014
|
+
function trackMedia(el) {
|
|
1015
|
+
if (!w.WeakRef) return;
|
|
1016
|
+
liveMedia.push(new w.WeakRef(el));
|
|
1017
|
+
}
|
|
1018
|
+
function applyMediaVolume(el) {
|
|
1019
|
+
if (el.__weBaseVol != null) {
|
|
1020
|
+
mediaVolDesc.set.call(el, el.__weBaseVol * hostVolume);
|
|
1021
|
+
} else {
|
|
1022
|
+
mediaVolDesc.set.call(el, hostVolume);
|
|
1023
|
+
}
|
|
1024
|
+
var baseMuted = !!el.__weBaseMuted;
|
|
1025
|
+
mediaMutedDesc.set.call(el, baseMuted || hostVolume <= 0);
|
|
1026
|
+
}
|
|
1027
|
+
function refreshAllMediaVolume() {
|
|
1028
|
+
try {
|
|
1029
|
+
var nodes = w.document.querySelectorAll("audio,video");
|
|
1030
|
+
for (var i = 0; i < nodes.length; i++) applyMediaVolume(nodes[i]);
|
|
1031
|
+
} catch (_) {
|
|
1032
|
+
/* \u5FFD\u7565 */
|
|
1033
|
+
}
|
|
1034
|
+
for (var j = liveMedia.length - 1; j >= 0; j--) {
|
|
1035
|
+
var el = liveMedia[j].deref();
|
|
1036
|
+
if (!el) {
|
|
1037
|
+
liveMedia.splice(j, 1);
|
|
1038
|
+
continue;
|
|
1039
|
+
}
|
|
1040
|
+
applyMediaVolume(el);
|
|
1041
|
+
}
|
|
1042
|
+
}
|
|
1043
|
+
var mediaVolDesc = null;
|
|
1044
|
+
var mediaMutedDesc = null;
|
|
1045
|
+
function installMediaVolumeHooks() {
|
|
1046
|
+
try {
|
|
1047
|
+
if (!w.HTMLMediaElement || !w.HTMLMediaElement.prototype) return;
|
|
1048
|
+
var proto = w.HTMLMediaElement.prototype;
|
|
1049
|
+
mediaVolDesc = Object.getOwnPropertyDescriptor(proto, "volume");
|
|
1050
|
+
mediaMutedDesc = Object.getOwnPropertyDescriptor(proto, "muted");
|
|
1051
|
+
if (mediaVolDesc && typeof mediaVolDesc.set === "function") {
|
|
1052
|
+
Object.defineProperty(proto, "volume", {
|
|
1053
|
+
configurable: true,
|
|
1054
|
+
enumerable: mediaVolDesc.enumerable,
|
|
1055
|
+
get: function () {
|
|
1056
|
+
return this.__weBaseVol != null ? this.__weBaseVol : mediaVolDesc.get.call(this);
|
|
1057
|
+
},
|
|
1058
|
+
set: function (v) {
|
|
1059
|
+
this.__weBaseVol = Math.max(0, Math.min(1, Number(v) || 0));
|
|
1060
|
+
mediaVolDesc.set.call(this, this.__weBaseVol * hostVolume);
|
|
1061
|
+
},
|
|
1062
|
+
});
|
|
1063
|
+
}
|
|
1064
|
+
if (mediaMutedDesc && typeof mediaMutedDesc.set === "function") {
|
|
1065
|
+
Object.defineProperty(proto, "muted", {
|
|
1066
|
+
configurable: true,
|
|
1067
|
+
enumerable: mediaMutedDesc.enumerable,
|
|
1068
|
+
get: function () {
|
|
1069
|
+
return this.__weBaseMuted != null
|
|
1070
|
+
? this.__weBaseMuted || hostVolume <= 0
|
|
1071
|
+
: mediaMutedDesc.get.call(this);
|
|
1072
|
+
},
|
|
1073
|
+
set: function (v) {
|
|
1074
|
+
this.__weBaseMuted = !!v;
|
|
1075
|
+
mediaMutedDesc.set.call(this, !!v || hostVolume <= 0);
|
|
1076
|
+
},
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
// \`new Audio()\` \u4E0D\u8FDB DOM\uFF1A\u6784\u9020\u5668\u767B\u8BB0 WeakRef \u4EE5\u4FBF\u4E3B\u97F3\u91CF\u53D8\u5316\u65F6\u5237\u65B0
|
|
1080
|
+
if (typeof w.Audio === "function" && w.WeakRef) {
|
|
1081
|
+
var OrigAudio = w.Audio;
|
|
1082
|
+
function WrappedAudio(src) {
|
|
1083
|
+
var a = new OrigAudio(src);
|
|
1084
|
+
trackMedia(a);
|
|
1085
|
+
applyMediaVolume(a);
|
|
1086
|
+
return a;
|
|
1087
|
+
}
|
|
1088
|
+
WrappedAudio.prototype = OrigAudio.prototype;
|
|
1089
|
+
w.Audio = WrappedAudio;
|
|
1090
|
+
}
|
|
1091
|
+
} catch (_) {
|
|
1092
|
+
/* \u65E0\u5A92\u4F53\u73AF\u5883\u7684 verifier \u8DF3\u8FC7 */
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
installMediaVolumeHooks();
|
|
1096
|
+
|
|
1097
|
+
// \u2014\u2014 \u7236\u9875\u63A7\u5236\u9762 \u2014\u2014
|
|
1098
|
+
// \u5B98\u65B9 setPaused \u53EA\u5728\u6682\u505C\u72B6\u6001\u5B9E\u9645\u53D8\u5316\u65F6\u8C03\u7528\u4E00\u6B21\uFF1B\u91CD\u590D\u8C03\u7528\u53BB\u91CD\u3002
|
|
1099
|
+
// \u6682\u505C\u8FD8\u8981\u51BB\u7ED3\u9875\u5185\u5A92\u4F53\uFF1A\u5B98\u65B9\u662F\u8FDB\u7A0B\u7EA7\u51BB\u7ED3\uFF08\u65E0\u58F0\u3001\u89E3\u7801\u5668\u53EF\u56DE\u6536\uFF09\uFF0C\u4F5C\u8005\u7684
|
|
1100
|
+
// setPaused \u5E38\u53EA\u7BA1\u81EA\u5DF1\u7684\u903B\u8F91\u3002\u53EA\u8BB0\u5F55\u300C\u6211\u4EEC\u4EE3\u4E3A\u6682\u505C\u300D\u7684\u5143\u7D20\uFF0C\u6062\u590D\u65F6\u4EC5\u8FD8\u539F\u8FD9\u90E8\u5206\uFF0C
|
|
1101
|
+
// \u4E0D\u78B0\u4F5C\u8005\u81EA\u5DF1\u6682\u505C\u7684\u3002
|
|
1102
|
+
var weFrozenMedia = [];
|
|
1103
|
+
function freezePageMedia() {
|
|
1104
|
+
weFrozenMedia.length = 0;
|
|
1105
|
+
try {
|
|
1106
|
+
var nodes = w.document.querySelectorAll("audio,video");
|
|
1107
|
+
for (var i = 0; i < nodes.length; i++) {
|
|
1108
|
+
if (!nodes[i].paused) {
|
|
1109
|
+
weFrozenMedia.push(nodes[i]);
|
|
1110
|
+
try {
|
|
1111
|
+
nodes[i].pause();
|
|
1112
|
+
} catch (_) {
|
|
1113
|
+
/* \u5FFD\u7565 */
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
}
|
|
1117
|
+
} catch (_) {
|
|
1118
|
+
/* \u5FFD\u7565 */
|
|
1119
|
+
}
|
|
1120
|
+
}
|
|
1121
|
+
function thawPageMedia() {
|
|
1122
|
+
for (var i = 0; i < weFrozenMedia.length; i++) {
|
|
1123
|
+
try {
|
|
1124
|
+
var p = weFrozenMedia[i].play();
|
|
1125
|
+
if (p && p.catch) p.catch(function () {});
|
|
1126
|
+
} catch (_) {
|
|
1127
|
+
/* \u5FFD\u7565 */
|
|
1128
|
+
}
|
|
1129
|
+
}
|
|
1130
|
+
weFrozenMedia.length = 0;
|
|
1131
|
+
}
|
|
1132
|
+
|
|
1133
|
+
/**
|
|
1134
|
+
* \u6682\u505C\u8FD8\u8981\u51BB\u7ED3 **CSS \u52A8\u753B / \u8FC7\u6E21**\uFF08Web Animations \u65F6\u95F4\u8F74\uFF09\u3002
|
|
1135
|
+
*
|
|
1136
|
+
* rAF \u4E0E\u5B9A\u65F6\u5668\u51BB\u7ED3\u7BA1\u4E0D\u5230\u5B83\u4EEC\uFF1ACSS \`animation\` \u7531\u6D4F\u89C8\u5668**\u5408\u6210\u5668**\u72EC\u7ACB\u9A71\u52A8\uFF0C
|
|
1137
|
+
* \u4E0E JS \u4E3B\u7EBF\u7A0B\u65E0\u5173\u30021444432396 Glitch Clock \u7684\u6574\u4E2A\u89C6\u89C9\uFF08\u80CC\u666F\u79FB\u52A8\u3001\u6296\u52A8\u3001\u6545\u969C
|
|
1138
|
+
* \u95EA\u70C1\uFF09\u662F 10 \u5904 \`animation: \u2026 infinite\`\uFF0C\u53EA\u6709\u65F6\u949F\u6587\u5B57\u8D70 \`setInterval\` \u2014\u2014
|
|
1139
|
+
* \u6682\u505C\u540E\u753B\u9762\u7167\u65E7\u52A8\u4E2A\u4E0D\u505C\uFF0C\u7528\u6237\u770B\u5230\u7684\u5C31\u662F\u300C\u65E0\u6CD5\u6682\u505C\u300D\uFF08\u5B9E\u6D4B\u6682\u505C\u671F\u95F4 6 \u4E2A\u52A8\u753B
|
|
1140
|
+
* \u5168\u4E3A \`playState:"running"\`\uFF0C\`currentTime\` 700ms \u63A8\u8FDB\u6574 700ms\uFF09\u3002
|
|
1141
|
+
*
|
|
1142
|
+
* \u5B98\u65B9\u6682\u505C\u8BED\u4E49\u662F\u300Cfully freeze the process that renders the wallpaper\u300D\uFF0C
|
|
1143
|
+
* \u5408\u6210\u5668\u52A8\u753B\u81EA\u7136\u4E5F\u5728\u51BB\u7ED3\u8303\u56F4\u5185\u3002
|
|
1144
|
+
*
|
|
1145
|
+
* \u4E0E\u5A92\u4F53\u51BB\u7ED3\u540C\u4E00\u6761\u7EAA\u5F8B\uFF1A**\u53EA\u8BB0\u5F55\u6211\u4EEC\u4EE3\u4E3A\u6682\u505C\u7684**\uFF0C\u6062\u590D\u65F6\u4EC5\u8FD8\u539F\u8FD9\u90E8\u5206\u2014\u2014
|
|
1146
|
+
* \u4F5C\u8005\u81EA\u5DF1\u7528 \`animation-play-state: paused\` \u505C\u4E0B\u7684\uFF08\u5E38\u89C1\u4E8E hover \u624D\u64AD\u7684\u88C5\u9970\uFF09
|
|
1147
|
+
* \u4E0D\u80FD\u88AB\u6211\u4EEC\u5524\u9192\u3002\`getAnimations()\` \u62FF\u7684\u662F\u6D3B\u52A8\u52A8\u753B\u5BF9\u8C61\uFF0C\`pause()\`/\`play()\`
|
|
1148
|
+
* \u76F4\u63A5\u4F5C\u7528\u5728\u65F6\u95F4\u8F74\u4E0A\uFF0C\u6BD4\u6539 \`style.animationPlayState\` \u5E72\u51C0\uFF08\u540E\u8005\u4F1A\u6C61\u67D3\u4F5C\u8005\u7684
|
|
1149
|
+
* \u5185\u8054\u6837\u5F0F\uFF0C\u4E14\u88AB\u4F5C\u8005\u4E0B\u4E00\u6B21\u6837\u5F0F\u5199\u5165\u8986\u76D6\uFF09\u3002
|
|
1150
|
+
*/
|
|
1151
|
+
var weFrozenAnims = [];
|
|
1152
|
+
function freezePageAnimations() {
|
|
1153
|
+
weFrozenAnims.length = 0;
|
|
1154
|
+
try {
|
|
1155
|
+
if (typeof w.document.getAnimations !== "function") return;
|
|
1156
|
+
var anims = w.document.getAnimations();
|
|
1157
|
+
for (var i = 0; i < anims.length; i++) {
|
|
1158
|
+
var a = anims[i];
|
|
1159
|
+
if (a && a.playState === "running") {
|
|
1160
|
+
weFrozenAnims.push(a);
|
|
1161
|
+
try {
|
|
1162
|
+
a.pause();
|
|
1163
|
+
} catch (_) {
|
|
1164
|
+
/* \u4E2A\u522B\u52A8\u753B\u4E0D\u53EF\u6682\u505C\u65F6\u8DF3\u8FC7 */
|
|
1165
|
+
}
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
} catch (_) {
|
|
1169
|
+
/* \u65E7\u5F15\u64CE\u65E0 getAnimations\uFF1A\u9000\u5316\u4E3A\u4E0D\u51BB\u7ED3\uFF0C\u4E0D\u62A5\u9519 */
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
function thawPageAnimations() {
|
|
1173
|
+
for (var i = 0; i < weFrozenAnims.length; i++) {
|
|
1174
|
+
try {
|
|
1175
|
+
weFrozenAnims[i].play();
|
|
1176
|
+
} catch (_) {
|
|
1177
|
+
/* \u5DF2\u88AB\u4F5C\u8005\u79FB\u9664\u7684\u52A8\u753B\u5FFD\u7565 */
|
|
1178
|
+
}
|
|
1179
|
+
}
|
|
1180
|
+
weFrozenAnims.length = 0;
|
|
1181
|
+
}
|
|
1182
|
+
w.__weSetPaused = function (v) {
|
|
1183
|
+
var next = !!v;
|
|
1184
|
+
if (next === paused) return;
|
|
1185
|
+
paused = next;
|
|
1186
|
+
if (paused) {
|
|
1187
|
+
callSetPaused(true);
|
|
1188
|
+
freezePageMedia();
|
|
1189
|
+
freezePageAnimations();
|
|
1190
|
+
} else {
|
|
1191
|
+
callSetPaused(false);
|
|
1192
|
+
thawPageMedia();
|
|
1193
|
+
thawPageAnimations();
|
|
1194
|
+
resumeTimers();
|
|
1195
|
+
// rAF \u6302\u8D77\u9879\u5FC5\u987B\u8865\u8DD1\uFF0C\u5426\u5219\u81EA\u9012\u5F52\u7684\u4E3B\u5FAA\u73AF\u6C38\u4E45\u65AD\u94FE\uFF081278092907\uFF09
|
|
1196
|
+
resumeRafHolds();
|
|
1197
|
+
}
|
|
1198
|
+
};
|
|
1199
|
+
|
|
1200
|
+
w.__weSetFps = function (n) {
|
|
1201
|
+
var next = Number(n);
|
|
1202
|
+
if (!Number.isFinite(next) || next <= 0) return;
|
|
1203
|
+
fps = next;
|
|
1204
|
+
callApplyGeneralProperties({ fps: fps });
|
|
1205
|
+
};
|
|
1206
|
+
|
|
1207
|
+
w.__weSetVolume = function (v) {
|
|
1208
|
+
var next = Math.max(0, Math.min(1, Number(v) || 0));
|
|
1209
|
+
volume = next;
|
|
1210
|
+
hostVolume = next;
|
|
1211
|
+
refreshAllMediaVolume();
|
|
1212
|
+
};
|
|
1213
|
+
|
|
1214
|
+
w.__weApplyProps = function (props) {
|
|
1215
|
+
if (!props || typeof props !== "object") return;
|
|
1216
|
+
// file \u5C5E\u6027\uFF1A\u503C\u662F\u8DEF\u5F84\u65F6\u767B\u8BB0\u8FDB\u968F\u673A\u6C60\uFF08\u5355\u6587\u4EF6 slideshow\uFF09
|
|
1217
|
+
try {
|
|
1218
|
+
for (var key in props) {
|
|
1219
|
+
if (!Object.prototype.hasOwnProperty.call(props, key)) continue;
|
|
1220
|
+
var ent = props[key];
|
|
1221
|
+
var val = ent && typeof ent === "object" && "value" in ent ? ent.value : ent;
|
|
1222
|
+
if (typeof val === "string" && val !== "" && /\\.(png|jpe?g|gif|webp|webm|mp4|bmp)$/i.test(val)) {
|
|
1223
|
+
directoryFiles[key] = [val];
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1226
|
+
} catch (_) {
|
|
1227
|
+
/* \u5FFD\u7565 */
|
|
1228
|
+
}
|
|
1229
|
+
if (!propertyListener || typeof propertyListener.applyUserProperties !== "function") {
|
|
1230
|
+
pendingProps = props;
|
|
1231
|
+
return;
|
|
1232
|
+
}
|
|
1233
|
+
callApplyUserProperties(props);
|
|
1234
|
+
};
|
|
1235
|
+
|
|
1236
|
+
w.__weSeedProps = function (props) {
|
|
1237
|
+
if (!props || typeof props !== "object") return;
|
|
1238
|
+
if (propertyListener && typeof propertyListener.applyUserProperties === "function") {
|
|
1239
|
+
w.__weApplyProps(props);
|
|
1240
|
+
} else {
|
|
1241
|
+
pendingProps = props;
|
|
1242
|
+
}
|
|
1243
|
+
};
|
|
1244
|
+
|
|
1245
|
+
w.__wePushAudio = function (arr) {
|
|
1246
|
+
if (paused || !audioListener) return;
|
|
1247
|
+
try {
|
|
1248
|
+
audioListener(arr);
|
|
1249
|
+
} catch (_) {
|
|
1250
|
+
/* \u5FFD\u7565 */
|
|
1251
|
+
}
|
|
1252
|
+
};
|
|
1253
|
+
|
|
1254
|
+
/**
|
|
1255
|
+
* \u5A92\u4F53\u4E8B\u4EF6\u6CF5\u3002payload \u5F62\u6001\u5BF9\u9F50\u5B98\u65B9\uFF1A
|
|
1256
|
+
* { op:"properties", title, artist, album, albumArtist }
|
|
1257
|
+
* { op:"thumbnail", thumbnail, primaryColor, textColor, ... }
|
|
1258
|
+
* { op:"playback", state } // 0/1/2
|
|
1259
|
+
* { op:"timeline", position, duration }
|
|
1260
|
+
* { op:"status", enabled }
|
|
1261
|
+
*/
|
|
1262
|
+
w.__wePushMedia = function (payload) {
|
|
1263
|
+
if (!payload || typeof payload !== "object") return;
|
|
1264
|
+
var op = payload.op;
|
|
1265
|
+
if (op === "properties") {
|
|
1266
|
+
lastMedia.properties = payload;
|
|
1267
|
+
safeCall(mediaListeners.properties, payload);
|
|
1268
|
+
} else if (op === "thumbnail") {
|
|
1269
|
+
lastMedia.thumbnail = payload;
|
|
1270
|
+
safeCall(mediaListeners.thumbnail, payload);
|
|
1271
|
+
} else if (op === "playback") {
|
|
1272
|
+
lastMedia.playback = payload;
|
|
1273
|
+
safeCall(mediaListeners.playback, payload);
|
|
1274
|
+
} else if (op === "timeline") {
|
|
1275
|
+
lastMedia.timeline = payload;
|
|
1276
|
+
safeCall(mediaListeners.timeline, payload);
|
|
1277
|
+
} else if (op === "status") {
|
|
1278
|
+
lastMedia.status = payload;
|
|
1279
|
+
safeCall(mediaListeners.status, payload);
|
|
1280
|
+
}
|
|
1281
|
+
};
|
|
1282
|
+
|
|
1283
|
+
/** \u76EE\u5F55\u6587\u4EF6\u5217\u8868\uFF08\u9996\u6B21\u6216\u8FFD\u52A0\uFF09\u3002files: string[] */
|
|
1284
|
+
w.__wePushDirectoryFiles = function (propertyName, files) {
|
|
1285
|
+
var prop = String(propertyName || "");
|
|
1286
|
+
if (!prop || !Array.isArray(files)) return;
|
|
1287
|
+
var cleaned = [];
|
|
1288
|
+
for (var i = 0; i < files.length; i++) {
|
|
1289
|
+
if (files[i] != null && String(files[i]) !== "") cleaned.push(String(files[i]));
|
|
1290
|
+
}
|
|
1291
|
+
if (!directoryFiles[prop]) directoryFiles[prop] = [];
|
|
1292
|
+
// \u9996\u6B21\u5168\u91CF\u66FF\u6362\u8BED\u4E49\u7531\u8C03\u7528\u65B9\u51B3\u5B9A\uFF1B\u8FD9\u91CC concat \u53BB\u91CD
|
|
1293
|
+
var seen = Object.create(null);
|
|
1294
|
+
for (var j = 0; j < directoryFiles[prop].length; j++) seen[directoryFiles[prop][j]] = 1;
|
|
1295
|
+
var added = [];
|
|
1296
|
+
for (var k = 0; k < cleaned.length; k++) {
|
|
1297
|
+
if (!seen[cleaned[k]]) {
|
|
1298
|
+
seen[cleaned[k]] = 1;
|
|
1299
|
+
directoryFiles[prop].push(cleaned[k]);
|
|
1300
|
+
added.push(cleaned[k]);
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
if (added.length) callDirectoryAdded(prop, added);
|
|
1304
|
+
};
|
|
1305
|
+
|
|
1306
|
+
w.__weRemoveDirectoryFiles = function (propertyName, files) {
|
|
1307
|
+
var prop = String(propertyName || "");
|
|
1308
|
+
if (!prop || !Array.isArray(files) || !directoryFiles[prop]) return;
|
|
1309
|
+
var removeSet = Object.create(null);
|
|
1310
|
+
for (var i = 0; i < files.length; i++) removeSet[String(files[i])] = 1;
|
|
1311
|
+
var kept = [];
|
|
1312
|
+
var removed = [];
|
|
1313
|
+
for (var j = 0; j < directoryFiles[prop].length; j++) {
|
|
1314
|
+
var f = directoryFiles[prop][j];
|
|
1315
|
+
if (removeSet[f]) removed.push(f);
|
|
1316
|
+
else kept.push(f);
|
|
1317
|
+
}
|
|
1318
|
+
directoryFiles[prop] = kept;
|
|
1319
|
+
if (removed.length) callDirectoryRemoved(prop, removed);
|
|
1320
|
+
};
|
|
1321
|
+
|
|
1322
|
+
// \u2014\u2014 \u5916\u90E8\u6307\u9488\u6CE8\u5165\uFF08\u684C\u9762 underlay \u5C42\u6536\u4E0D\u5230\u9F20\u6807\u4E8B\u4EF6\uFF0C\u7236\u9875\u7ECF __wp.pushPointer \u63A8\u5165\uFF09\u2014\u2014
|
|
1323
|
+
//
|
|
1324
|
+
// \u573A\u666F\u58C1\u7EB8\u90A3\u6761\u901A\u9053\u662F\u300C\u5199\u4E00\u4E2A\u72B6\u6001\u5BF9\u8C61\u3001\u6E32\u67D3\u5668\u6BCF\u5E27\u8BFB\u300D\uFF08render/pointer.js\uFF09\uFF1B\u7F51\u9875\u58C1\u7EB8
|
|
1325
|
+
// \u6CA1\u6709\u8FD9\u6837\u7684\u5355\u4E00\u6D88\u8D39\u70B9 \u2014\u2014 \u4F5C\u8005\u4EE3\u7801\u5C31\u662F**\u76D1\u542C DOM \u4E8B\u4EF6**\u7684\uFF0C\u6240\u4EE5\u8FD9\u91CC\u5FC5\u987B\u628A\u63A8\u9001
|
|
1326
|
+
// \u8FD8\u539F\u6210\u4E00\u4E32\u5408\u6210\u4E8B\u4EF6\u3002\u8BED\u6599\uFF08\u672C\u673A 49 \u5F20 web\uFF09\uFF1Amousemove 24 \u5F20\u3001click 29 \u5F20\u3001
|
|
1327
|
+
// mouseover/out 17 \u5F20\u3001mouseenter/leave 8 \u5F20\u3001pointer* 16 \u5F20\uFF08createjs \u7CFB\u4E00\u5F8B\u8D70
|
|
1328
|
+
// pointerdown/move/up\uFF09\u3001.button 18 \u5F20\u3001.which 17 \u5F20\u3001pointerId/relatedTarget 15 \u5F20\u3002
|
|
1329
|
+
//
|
|
1330
|
+
// \u4E09\u6761\u8981\u70B9\uFF08\u90FD\u6709\u8BED\u6599\u4F9D\u636E\uFF0C\u6539\u9519\u4E86\u4F1A\u9759\u9ED8\u5931\u6548\uFF09\uFF1A
|
|
1331
|
+
//
|
|
1332
|
+
// 1. **\u5FC5\u987B elementFromPoint \u6309\u547D\u4E2D\u5143\u7D20\u6D3E\u53D1**\uFF0C\u4E0D\u80FD\u4E00\u5F8B\u6253 document\u3002\u4F5C\u8005\u65E2\u6709\u6302
|
|
1333
|
+
// document/window \u7684\uFF0815 \u5F20\uFF0C\u9760\u5192\u6CE1\u6536\u5230\uFF09\uFF0C\u4E5F\u6709\u6302 canvas \u4E0A\u8BFB \`event.offsetX\`
|
|
1334
|
+
// \u7684\uFF081748506393 \u6D41\u4F53 \`pointers[0].dx = (e.offsetX - \u2026)\`\uFF09\u3002offsetX/offsetY \u7531
|
|
1335
|
+
// \u6D4F\u89C8\u5668\u6309 target \u7684 padding box \u73B0\u7B97 \u2014\u2014 target \u6253\u9519\u5C31\u662F\u9519\u7684\u504F\u79FB\uFF0C\u4E14\u65E0\u4EFB\u4F55\u62A5\u9519\u3002
|
|
1336
|
+
// pageX/pageY \u540C\u7406\u7531 clientX + \u6EDA\u52A8\u91CF\u73B0\u7B97\uFF0C\u4E0D\u7528\u6211\u4EEC\u586B\u3002
|
|
1337
|
+
//
|
|
1338
|
+
// 2. **over/out/enter/leave \u94FE\u8981\u6309 W3C \u8BED\u4E49\u8865\u5168**\u30021748506393 \u9760 canvas \u7684
|
|
1339
|
+
// \`mouseenter\` \u628A \`pointers[0].down\` \u7F6E true\uFF08\u4E0D\u8FDB\u8FD9\u4E2A\u5206\u652F\u5219\u9F20\u6807\u600E\u4E48\u52A8\u90FD\u4E0D\u51FA\u67D3\u6599\uFF09\u3001
|
|
1340
|
+
// \u9760 window \u7684 \`mouseleave\` \u590D\u4F4D\uFF1B1081733658 animatedGrid \u9760 \`document.body\` \u7684
|
|
1341
|
+
// mouseover/mouseleave \u8D77\u505C\u6574\u4E2A\u7F51\u683C\u52A8\u753B\u3002leave/enter \u4E0D\u5192\u6CE1\uFF0C\u5FC5\u987B\u81EA\u5DF1\u6CBF\u7956\u5148\u94FE\u8D70\u5230
|
|
1342
|
+
// \u6700\u8FD1\u516C\u5171\u7956\u5148\uFF0C\u53EA\u53D1\u751F\u53D8\u5316\u7684\u90A3\u4E00\u6BB5\u3002
|
|
1343
|
+
//
|
|
1344
|
+
// 3. **click \u8981\u9760 down/up \u8FB9\u7F18\u5408\u6210**\uFF0C\u4E14 down \u4E0E up \u7684 target \u4E0D\u540C\uFF08\u62D6\u62FD\uFF09\u65F6\u4E0D\u53D1\u3002
|
|
1345
|
+
// 29 \u5F20\u542C click \u662F\u6700\u5927\u7684\u6D88\u8D39\u65B9\uFF1B\u8F6E\u8BE2\u63A8\u9001\u91CC\u6CA1\u6709\u300C\u70B9\u51FB\u300D\u8FD9\u4E2A\u4E8B\u4EF6\uFF0C\u53EA\u6709\u6309\u952E\u63A9\u7801\u7684
|
|
1346
|
+
// \u8DF3\u53D8\uFF0C\u8FB9\u7F18\u4E22\u4E86\u5C31\u7B49\u4E8E\u6574\u7C7B\u4EA4\u4E92\u6D88\u5931\u3002
|
|
1347
|
+
//
|
|
1348
|
+
// \u786C\u9650\u5236\uFF08\u5199\u5728\u8FD9\u91CC\u907F\u514D\u53CD\u590D\u8BD5\uFF09\uFF1ACSS \`:hover\` \u7531\u6D4F\u89C8\u5668\u81EA\u5DF1\u7684 hit-test \u9A71\u52A8\uFF0C\u5408\u6210\u4E8B\u4EF6
|
|
1349
|
+
// \u6C38\u8FDC\u70B9\u4E0D\u4EAE\u5B83\uFF0818 \u5F20\u542B \`:hover\`\uFF09\u2014\u2014 \u7EAF CSS hover \u52A8\u753B\u7684\u58C1\u7EB8\u65E0\u6CD5\u7528\u6CE8\u5165\u901A\u9053\u54CD\u5E94\uFF0C
|
|
1350
|
+
// \u8FD9\u4E0D\u662F\u5B9E\u73B0\u7F3A\u9677\uFF0C\u662F\u5408\u6210\u4E8B\u4EF6\u7684\u56FA\u6709\u8FB9\u754C\u3002
|
|
1351
|
+
var ptrHas = false; // \u662F\u5426\u6536\u5230\u8FC7\u63A8\u9001\uFF08\u9996\u5E27 movement \u5F52\u96F6\u7528\uFF09
|
|
1352
|
+
var ptrX = 0;
|
|
1353
|
+
var ptrY = 0;
|
|
1354
|
+
var ptrButtons = 0;
|
|
1355
|
+
var ptrTarget = null; // \u4E0A\u6B21\u547D\u4E2D\u5143\u7D20\uFF08over/out \u94FE\u7684\u65E7\u7AEF\uFF09
|
|
1356
|
+
var ptrDownTarget = null; // \u6309\u4E0B\u65F6\u7684\u547D\u4E2D\u5143\u7D20\uFF08click \u5224\u5B9A\uFF09
|
|
1357
|
+
var ptrLastClickTime = 0;
|
|
1358
|
+
var ptrLastClickTarget = null;
|
|
1359
|
+
/** \u53CC\u51FB\u5224\u5B9A\u7A97\u53E3\uFF08ms\uFF09\u3002\u4E0E\u4E3B\u6D41\u6D4F\u89C8\u5668\u4E00\u81F4\uFF0C\u8BED\u6599\u91CC 5 \u5F20\u542C dblclick\u3002 */
|
|
1360
|
+
var PTR_DBLCLICK_MS = 500;
|
|
1361
|
+
|
|
1362
|
+
function ptrRoot() {
|
|
1363
|
+
try {
|
|
1364
|
+
return w.document.body || w.document.documentElement || null;
|
|
1365
|
+
} catch (_) {
|
|
1366
|
+
return null;
|
|
1367
|
+
}
|
|
1368
|
+
}
|
|
1369
|
+
|
|
1370
|
+
function ptrHitTest(x, y) {
|
|
1371
|
+
try {
|
|
1372
|
+
if (typeof w.document.elementFromPoint === "function") {
|
|
1373
|
+
var el = w.document.elementFromPoint(x, y);
|
|
1374
|
+
if (el) return el;
|
|
1375
|
+
}
|
|
1376
|
+
} catch (_) {
|
|
1377
|
+
/* \u5FFD\u7565 */
|
|
1378
|
+
}
|
|
1379
|
+
return ptrRoot();
|
|
1380
|
+
}
|
|
1381
|
+
|
|
1382
|
+
/** node \u2192 [node, parent, \u2026, root]\uFF1B\u7528 parentNode \u800C\u975E parentElement\uFF0C
|
|
1383
|
+
* \u8FD9\u6837 document / documentElement \u4E5F\u5728\u94FE\u91CC\uFF08\u4F5C\u8005\u6302 document \u7684 leave \u8981\u6536\u5230\uFF09\u3002 */
|
|
1384
|
+
function ptrChain(node) {
|
|
1385
|
+
var out = [];
|
|
1386
|
+
var n = node;
|
|
1387
|
+
while (n) {
|
|
1388
|
+
out.push(n);
|
|
1389
|
+
try {
|
|
1390
|
+
n = n.parentNode || null;
|
|
1391
|
+
} catch (_) {
|
|
1392
|
+
n = null;
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
return out;
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
function ptrCommonAncestor(a, b) {
|
|
1399
|
+
if (!a || !b) return null;
|
|
1400
|
+
var ca = ptrChain(a);
|
|
1401
|
+
var seen = [];
|
|
1402
|
+
for (var i = 0; i < ca.length; i++) seen.push(ca[i]);
|
|
1403
|
+
var cb = ptrChain(b);
|
|
1404
|
+
for (var j = 0; j < cb.length; j++) {
|
|
1405
|
+
for (var k = 0; k < seen.length; k++) {
|
|
1406
|
+
if (seen[k] === cb[j]) return cb[j];
|
|
1407
|
+
}
|
|
1408
|
+
}
|
|
1409
|
+
return null;
|
|
1410
|
+
}
|
|
1411
|
+
|
|
1412
|
+
/**
|
|
1413
|
+
* \u9020\u4E00\u4E2A\u5408\u6210\u9F20\u6807/\u6307\u9488\u4E8B\u4EF6\u3002
|
|
1414
|
+
*
|
|
1415
|
+
* \`PointerEvent\` \u4F18\u5148\uFF1Acreatejs \u4E00\u65CF\uFF08\u8BED\u6599 7 \u5F20\uFF09\u53EA\u6302 pointerdown/move/up\uFF0C
|
|
1416
|
+
* \u4E14\u4F1A\u8BFB \`pointerId\` / \`pointerType\` / \`isPrimary\`\u3002\u73AF\u5883\u6CA1\u6709 PointerEvent \u65F6
|
|
1417
|
+
* \u9000\u56DE MouseEvent\uFF08\u4E8B\u4EF6\u540D\u7167\u65E7\uFF0C\u4F5C\u8005\u7684 addEventListener('pointermove') \u4ECD\u80FD\u6536\u5230\uFF09\u3002
|
|
1418
|
+
*/
|
|
1419
|
+
function ptrMakeEvent(type, x, y, opts) {
|
|
1420
|
+
var o = opts || {};
|
|
1421
|
+
var isPointer = type.indexOf("pointer") === 0;
|
|
1422
|
+
var init = {
|
|
1423
|
+
bubbles: o.bubbles !== false,
|
|
1424
|
+
cancelable: o.cancelable !== false,
|
|
1425
|
+
// composed\uFF1A\u4F5C\u8005\u628A canvas \u653E\u8FDB shadow DOM \u65F6\u4E8B\u4EF6\u8981\u80FD\u7A7F\u51FA\u6765
|
|
1426
|
+
composed: true,
|
|
1427
|
+
view: w,
|
|
1428
|
+
detail: o.detail || 0,
|
|
1429
|
+
clientX: x,
|
|
1430
|
+
clientY: y,
|
|
1431
|
+
// screenX/screenY \u662F init \u5B57\u6BB5\uFF08\u4E0D\u50CF pageX/offsetX \u90A3\u6837\u73B0\u7B97\uFF09\u3002iframe \u91CC
|
|
1432
|
+
// \u53EA\u80FD\u6309\u5916\u5C42\u7A97\u53E3\u539F\u70B9\u8FD1\u4F3C\uFF1B16 \u5F20\u8BFB screenX\uFF0C\u591A\u7528\u4E8E\u7B97\u76F8\u5BF9\u4F4D\u79FB\u800C\u975E\u7EDD\u5BF9\u5B9A\u4F4D\u3002
|
|
1433
|
+
screenX: x + (Number(w.screenX) || 0),
|
|
1434
|
+
screenY: y + (Number(w.screenY) || 0),
|
|
1435
|
+
// button\uFF1A**\u79FB\u52A8/\u60AC\u505C\u7C7B\u4E8B\u4EF6\u5FC5\u987B\u662F -1**\uFF0C\u53EA\u6709 down/up/click \u624D\u662F 0\uFF08\u5DE6\uFF09/1\uFF08\u4E2D\uFF09/2\uFF08\u53F3\uFF09\u3002
|
|
1436
|
+
// \u8FD9\u6761\u662F W3C \u89C4\u5B9A\u7684\u300C\u6CA1\u6709\u6309\u952E\u72B6\u6001\u53D8\u5316\u300D\u54E8\u5175\u503C\uFF0C\u4E0D\u662F\u53EF\u7701\u7684\u7EC6\u8282\uFF1AGameMaker HTML5
|
|
1437
|
+
// \u5BFC\u51FA\u7684\u8FD0\u884C\u65F6\uFF082517518192 FNAF\uFF09\u5728 pointermove \u5206\u652F\u91CC\u7167\u6284 \`_tq = e.button\` \u518D
|
|
1438
|
+
// \`_mq |= (1 << _tq)\`\uFF0C\u800C _mq \u53EA\u5728 pointerup/out \u624D\u6E05\u96F6 \u2014\u2014 \u586B 0 \u7B49\u4E8E\u544A\u8BC9\u6E38\u620F
|
|
1439
|
+
// \u300C\u5DE6\u952E\u4E00\u76F4\u6309\u7740\u300D\uFF0C\u9F20\u6807\u53EA\u662F\u79FB\u8FC7\u53BB\u5C31\u6C38\u4E45\u5361\u5728\u6309\u4E0B\u6001\uFF08\u4E14\u6CA1\u6709\u4EFB\u4F55\u62A5\u9519\uFF09\u3002
|
|
1440
|
+
button: o.button != null ? o.button : -1,
|
|
1441
|
+
buttons: o.buttons != null ? o.buttons : ptrButtons,
|
|
1442
|
+
movementX: o.movementX || 0,
|
|
1443
|
+
movementY: o.movementY || 0,
|
|
1444
|
+
ctrlKey: false,
|
|
1445
|
+
shiftKey: false,
|
|
1446
|
+
altKey: false,
|
|
1447
|
+
metaKey: false,
|
|
1448
|
+
};
|
|
1449
|
+
if ("relatedTarget" in o) init.relatedTarget = o.relatedTarget || null;
|
|
1450
|
+
// \`button: -1\` \u65E0\u6CD5\u7ECF MouseEvent \u6784\u9020\u5668\u8868\u8FBE\uFF1AChromium \u628A -1 \u89C4\u8303\u5316\u6210 0
|
|
1451
|
+
// \uFF08\u5B9E\u6D4B \`new MouseEvent("x", {button:-1}).button === 0\`\uFF0C\u800C -2 \u80FD\u539F\u6837\u901A\u8FC7 \u2014\u2014
|
|
1452
|
+
// \u4E0D\u662F\u94B3\u4F4D\uFF0C\u662F\u5BF9 -1 \u7684\u7279\u6B8A\u5904\u7406\uFF09\u3002PointerEvent \u6784\u9020\u5668\u5219\u4FDD\u7559 -1\u3002
|
|
1453
|
+
// \u6240\u4EE5 mouse \u7C7B\u4E8B\u4EF6\u5FC5\u987B\u5728\u6784\u9020\u540E\u628A -1 \u76D6\u56DE\u53BB\uFF0C\u5426\u5219\u300C\u79FB\u52A8=\u5DE6\u952E\u6309\u4E0B\u300D\u7684\u5751
|
|
1454
|
+
// \u53EA\u5728 pointer \u8DEF\u5F84\u4FEE\u597D\u3001mouse \u8DEF\u5F84\u4F9D\u65E7\uFF082517518192 \u6070\u597D\u8D70 pointer\uFF0C
|
|
1455
|
+
// \u5149\u770B\u5B83\u4F1A\u8BEF\u4EE5\u4E3A\u5DF2\u7ECF\u4FEE\u5B8C\uFF09\u3002
|
|
1456
|
+
var needsButtonPatch = init.button < 0;
|
|
1457
|
+
var ev = null;
|
|
1458
|
+
if (isPointer) {
|
|
1459
|
+
init.pointerId = 1;
|
|
1460
|
+
init.pointerType = "mouse";
|
|
1461
|
+
init.isPrimary = true;
|
|
1462
|
+
init.width = 1;
|
|
1463
|
+
init.height = 1;
|
|
1464
|
+
init.pressure = init.buttons ? 0.5 : 0;
|
|
1465
|
+
try {
|
|
1466
|
+
if (typeof w.PointerEvent === "function") ev = new w.PointerEvent(type, init);
|
|
1467
|
+
} catch (_) {
|
|
1468
|
+
/* \u9000\u56DE MouseEvent */
|
|
1469
|
+
}
|
|
1470
|
+
}
|
|
1471
|
+
if (!ev) {
|
|
1472
|
+
try {
|
|
1473
|
+
if (typeof w.MouseEvent === "function") ev = new w.MouseEvent(type, init);
|
|
1474
|
+
} catch (_) {
|
|
1475
|
+
/* \u5FFD\u7565 */
|
|
1476
|
+
}
|
|
1477
|
+
}
|
|
1478
|
+
if (ev && needsButtonPatch && ev.button !== init.button) {
|
|
1479
|
+
try {
|
|
1480
|
+
Object.defineProperty(ev, "button", { configurable: true, get: function () {
|
|
1481
|
+
return init.button;
|
|
1482
|
+
} });
|
|
1483
|
+
} catch (_) {
|
|
1484
|
+
/* \u53EA\u8BFB\u4E14\u4E0D\u53EF\u91CD\u5B9A\u4E49\u65F6\u4FDD\u6301\u6784\u9020\u503C */
|
|
1485
|
+
}
|
|
1486
|
+
}
|
|
1487
|
+
return ev;
|
|
1488
|
+
}
|
|
1489
|
+
|
|
1490
|
+
function ptrDispatch(node, type, x, y, opts) {
|
|
1491
|
+
if (!node || typeof node.dispatchEvent !== "function") return;
|
|
1492
|
+
var ev = ptrMakeEvent(type, x, y, opts);
|
|
1493
|
+
if (!ev) return;
|
|
1494
|
+
try {
|
|
1495
|
+
node.dispatchEvent(ev);
|
|
1496
|
+
} catch (_) {
|
|
1497
|
+
/* \u4F5C\u8005\u5904\u7406\u5668\u629B\u9519\u4E0D\u6253\u65AD\u540E\u7EED\u4E8B\u4EF6\uFF08\u4E0E\u5B98\u65B9 CEF \u4E00\u81F4\uFF1A\u4E00\u4E2A\u574F listener \u4E0D\u8BE5
|
|
1498
|
+
\u8BA9\u6574\u6761\u94FE\u65AD\u6389\uFF0C\u5426\u5219 leave \u53D1\u4E0D\u51FA\u53BB\u4F1A\u7559\u4E0B\u6C38\u4E45 hover/\u6309\u4E0B\u6001\uFF09 */
|
|
1499
|
+
}
|
|
1500
|
+
}
|
|
1501
|
+
|
|
1502
|
+
/** \u547D\u4E2D\u5143\u7D20\u53D8\u5316\u65F6\u8865 out/leave + over/enter \u56DB\u6BB5\uFF0C\u987A\u5E8F\u4E0E\u6D4F\u89C8\u5668\u4E00\u81F4\u3002 */
|
|
1503
|
+
function ptrCrossBoundary(prev, next, x, y) {
|
|
1504
|
+
if (prev === next) return;
|
|
1505
|
+
var ancestor = ptrCommonAncestor(prev, next);
|
|
1506
|
+
if (prev) {
|
|
1507
|
+
ptrDispatch(prev, "pointerout", x, y, { relatedTarget: next });
|
|
1508
|
+
ptrDispatch(prev, "mouseout", x, y, { relatedTarget: next });
|
|
1509
|
+
var leaving = ptrChain(prev);
|
|
1510
|
+
for (var i = 0; i < leaving.length; i++) {
|
|
1511
|
+
if (leaving[i] === ancestor) break;
|
|
1512
|
+
// leave \u4E0D\u5192\u6CE1\uFF1A\u5FC5\u987B\u9010\u4E2A\u53D1\uFF0C\u4E14 target \u5C31\u662F\u5B83\u81EA\u5DF1
|
|
1513
|
+
ptrDispatch(leaving[i], "pointerleave", x, y, {
|
|
1514
|
+
bubbles: false,
|
|
1515
|
+
cancelable: false,
|
|
1516
|
+
relatedTarget: next,
|
|
1517
|
+
});
|
|
1518
|
+
ptrDispatch(leaving[i], "mouseleave", x, y, {
|
|
1519
|
+
bubbles: false,
|
|
1520
|
+
cancelable: false,
|
|
1521
|
+
relatedTarget: next,
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
}
|
|
1525
|
+
if (next) {
|
|
1526
|
+
ptrDispatch(next, "pointerover", x, y, { relatedTarget: prev });
|
|
1527
|
+
ptrDispatch(next, "mouseover", x, y, { relatedTarget: prev });
|
|
1528
|
+
var entering = [];
|
|
1529
|
+
var chain = ptrChain(next);
|
|
1530
|
+
for (var j = 0; j < chain.length; j++) {
|
|
1531
|
+
if (chain[j] === ancestor) break;
|
|
1532
|
+
entering.push(chain[j]);
|
|
1533
|
+
}
|
|
1534
|
+
// enter \u7531\u5916\u5411\u5185\uFF08\u7956\u5148\u5148\u6536\u5230\uFF09\uFF0C\u4E0E\u6D4F\u89C8\u5668\u4E00\u81F4
|
|
1535
|
+
for (var k = entering.length - 1; k >= 0; k--) {
|
|
1536
|
+
ptrDispatch(entering[k], "pointerenter", x, y, {
|
|
1537
|
+
bubbles: false,
|
|
1538
|
+
cancelable: false,
|
|
1539
|
+
relatedTarget: prev,
|
|
1540
|
+
});
|
|
1541
|
+
ptrDispatch(entering[k], "mouseenter", x, y, {
|
|
1542
|
+
bubbles: false,
|
|
1543
|
+
cancelable: false,
|
|
1544
|
+
relatedTarget: prev,
|
|
1545
|
+
});
|
|
1546
|
+
}
|
|
1547
|
+
}
|
|
1548
|
+
}
|
|
1549
|
+
|
|
1550
|
+
/**
|
|
1551
|
+
* \u5916\u90E8\u6307\u9488\u6CE8\u5165\u5165\u53E3\u3002
|
|
1552
|
+
*
|
|
1553
|
+
* @param {number} x \u76F8\u5BF9 iframe \u89C6\u53E3\u5DE6\u8FB9\u7684 **CSS \u50CF\u7D20**\uFF08= clientX \u7A7A\u95F4\uFF09
|
|
1554
|
+
* @param {number} y \u540C\u4E0A\uFF0C\u76F8\u5BF9\u4E0A\u8FB9\uFF0CY \u671D\u4E0B
|
|
1555
|
+
* @param {number} [buttons] \u6309\u952E\u4F4D\u63A9\u7801\uFF0Cbit0 \u5DE6\u952E\u3002\u4E0E\u573A\u666F\u901A\u9053\u540C\u4E00\u7EA6\u5B9A\uFF0C
|
|
1556
|
+
* \u5F53\u524D\u53EA\u6D88\u8D39 bit0\uFF08\u53F3/\u4E2D\u952E\u4F4D\u4FDD\u7559\uFF1B\u684C\u9762\u53F3\u952E\u5C5E\u4E8E Finder\uFF0C\u4E0D\u8BE5\u88AB\u58C1\u7EB8\u52AB\u6301\uFF09
|
|
1557
|
+
*
|
|
1558
|
+
* \u63A5**\u50CF\u7D20**\u800C\u4E0D\u662F\u5F52\u4E00\u5316\u5750\u6807\uFF1A\u7F51\u9875\u58C1\u7EB8\u7684 iframe \u5728 cover \u9732\u5E95\u81EA\u9002\u914D\u4E0B\u53EF\u80FD\u6BD4\u821E\u53F0\u5927
|
|
1559
|
+
* \u5E76\u5E26\u5C45\u4E2D\u504F\u79FB\uFF08\u89C1 web.ts installLetterboxFix\uFF09\uFF0C\u6362\u7B97\u9700\u8981 iframe \u7684\u51E0\u4F55 \u2014\u2014 \u90A3\u662F\u7236\u9875
|
|
1560
|
+
* \u624D\u77E5\u9053\u7684\u4FE1\u606F\uFF0C\u7236\u9875\u6362\u7B97\u5B8C\u518D\u63A8\u8FDB\u6765\uFF0Cshim \u4E0D\u505A\u4E8C\u6B21\u9664\u6CD5\u3002
|
|
1561
|
+
*
|
|
1562
|
+
* \u6682\u505C\u671F\u95F4\u4E22\u5F03\uFF1A\u5B98\u65B9\u6682\u505C\u8BED\u4E49\u662F\u300C\u51BB\u7ED3\u6E32\u67D3\u8FDB\u7A0B\u300D\uFF0C\u6B64\u65F6\u6D3E\u53D1\u4E8B\u4EF6\u4F1A\u8BA9\u4F5C\u8005\u7684\u52A8\u753B\u72B6\u6001
|
|
1563
|
+
* \u5728\u51BB\u7ED3\u4E2D\u7EE7\u7EED\u63A8\u8FDB\uFF0C\u6062\u590D\u65F6\u753B\u9762\u8DF3\u4E00\u4E0B\u3002
|
|
1564
|
+
*/
|
|
1565
|
+
w.__wePushPointer = function (x, y, buttons) {
|
|
1566
|
+
if (paused) return;
|
|
1567
|
+
var nx = Number(x);
|
|
1568
|
+
var ny = Number(y);
|
|
1569
|
+
// \u975E\u6709\u9650\u503C\u76F4\u63A5\u4E22\u5F03\uFF08\u4E0E\u573A\u666F\u901A\u9053\u540C\u4E00\u7EA6\u5B9A\uFF09\uFF1ANaN \u4F20\u8FDB clientX \u4F1A\u8BA9 elementFromPoint
|
|
1570
|
+
// \u8FD4\u56DE null\u3001\u540E\u7EED offsetX \u5168\u6210 NaN\uFF0C\u4F5C\u8005\u7684\u4F4D\u79FB\u79EF\u5206\u4F1A\u4E00\u6B21\u6027\u6C61\u67D3\u6210 NaN \u4E14\u4E0D\u62A5\u9519\u3002
|
|
1571
|
+
if (!isFinite(nx) || !isFinite(ny)) return;
|
|
1572
|
+
var mask = Number(buttons) || 0;
|
|
1573
|
+
var moved = !ptrHas || nx !== ptrX || ny !== ptrY;
|
|
1574
|
+
var maskChanged = mask !== ptrButtons;
|
|
1575
|
+
// \u4F4D\u7F6E\u4E0E\u6309\u952E\u90FD\u6CA1\u53D8\u5C31\u4EC0\u4E48\u90FD\u4E0D\u53D1\uFF1A\u5BBF\u4E3B\u6309 ~90Hz \u63A8\u9001\uFF0C\u9759\u6B62\u65F6\u91CD\u590D\u6D3E\u53D1
|
|
1576
|
+
// mousemove \u4F1A\u8BA9\u4F5C\u8005\u7684\u300C\u6709\u6CA1\u6709\u5728\u52A8\u300D\u5224\u5B9A\uFF081081733658 \u7F51\u683C\uFF09\u6C38\u8FDC\u8BA4\u4E3A\u5728\u52A8\u3002
|
|
1577
|
+
if (!moved && !maskChanged) return;
|
|
1578
|
+
|
|
1579
|
+
var dx = ptrHas ? nx - ptrX : 0;
|
|
1580
|
+
var dy = ptrHas ? ny - ptrY : 0;
|
|
1581
|
+
ptrX = nx;
|
|
1582
|
+
ptrY = ny;
|
|
1583
|
+
ptrHas = true;
|
|
1584
|
+
|
|
1585
|
+
var target = ptrHitTest(nx, ny);
|
|
1586
|
+
if (moved) {
|
|
1587
|
+
ptrCrossBoundary(ptrTarget, target, nx, ny);
|
|
1588
|
+
ptrTarget = target;
|
|
1589
|
+
ptrDispatch(target, "pointermove", nx, ny, { movementX: dx, movementY: dy });
|
|
1590
|
+
ptrDispatch(target, "mousemove", nx, ny, { movementX: dx, movementY: dy });
|
|
1591
|
+
} else {
|
|
1592
|
+
ptrTarget = target;
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
if (!maskChanged) return;
|
|
1596
|
+
var wasDown = (ptrButtons & 1) !== 0;
|
|
1597
|
+
var isDown = (mask & 1) !== 0;
|
|
1598
|
+
ptrButtons = mask;
|
|
1599
|
+
if (isDown === wasDown) return; // \u53EA\u6709\u9AD8\u4F4D\u53D8\u5316\uFF1A\u5F53\u524D\u4E0D\u6D88\u8D39
|
|
1600
|
+
if (isDown) {
|
|
1601
|
+
ptrDownTarget = target;
|
|
1602
|
+
ptrDispatch(target, "pointerdown", nx, ny, { button: 0, detail: 1 });
|
|
1603
|
+
ptrDispatch(target, "mousedown", nx, ny, { button: 0, detail: 1 });
|
|
1604
|
+
return;
|
|
1605
|
+
}
|
|
1606
|
+
ptrDispatch(target, "pointerup", nx, ny, { button: 0, detail: 1 });
|
|
1607
|
+
ptrDispatch(target, "mouseup", nx, ny, { button: 0, detail: 1 });
|
|
1608
|
+
// click \u53EA\u5728 down/up \u843D\u5728\u540C\u4E00\u5143\u7D20\u4E0A\u65F6\u53D1\uFF08\u5426\u5219\u662F\u62D6\u62FD\uFF0C\u6D4F\u89C8\u5668\u4E5F\u4E0D\u53D1\uFF09
|
|
1609
|
+
if (ptrDownTarget && ptrDownTarget === target) {
|
|
1610
|
+
var now = Date.now();
|
|
1611
|
+
var isDouble =
|
|
1612
|
+
ptrLastClickTarget === target && now - ptrLastClickTime <= PTR_DBLCLICK_MS;
|
|
1613
|
+
ptrDispatch(target, "click", nx, ny, { button: 0, detail: isDouble ? 2 : 1 });
|
|
1614
|
+
if (isDouble) {
|
|
1615
|
+
ptrDispatch(target, "dblclick", nx, ny, { button: 0, detail: 2 });
|
|
1616
|
+
ptrLastClickTarget = null;
|
|
1617
|
+
ptrLastClickTime = 0;
|
|
1618
|
+
} else {
|
|
1619
|
+
ptrLastClickTarget = target;
|
|
1620
|
+
ptrLastClickTime = now;
|
|
1621
|
+
}
|
|
1622
|
+
}
|
|
1623
|
+
ptrDownTarget = null;
|
|
1624
|
+
};
|
|
1625
|
+
|
|
1626
|
+
/**
|
|
1627
|
+
* \u6307\u9488\u79BB\u5F00\u672C\u7A97\u53E3\uFF08\u9F20\u6807\u53BB\u4E86\u522B\u7684\u663E\u793A\u5668\uFF09\u3002
|
|
1628
|
+
*
|
|
1629
|
+
* \u4E0E\u573A\u666F\u901A\u9053\u4E0D\u540C\uFF0C\u8FD9\u91CC**\u5FC5\u987B\u628A out/leave \u94FE\u53D1\u51FA\u53BB**\uFF1A\u573A\u666F\u4FA7\u53EA\u662F\u6E05\u4E00\u4E2A\u72B6\u6001\u4F4D\uFF0C
|
|
1630
|
+
* \u800C\u7F51\u9875\u4F5C\u8005\u7684 hover \u6001\u662F\u81EA\u5DF1\u8BB0\u7684\uFF0C\u4E0D\u53D1 leave \u5C31\u6C38\u4E45\u5361\u5728\u300C\u9F20\u6807\u8FD8\u5728\u4E0A\u9762\u300D
|
|
1631
|
+
* \uFF081081733658 \u7F51\u683C\u4F1A\u4E00\u76F4\u8DD1\u30011748506393 \u7684 \`pointers[0].down\` \u4E00\u76F4\u4E3A true\uFF09\u3002
|
|
1632
|
+
* \u6309\u4E0B\u6001\u4E5F\u8981\u8865\u4E00\u6B21 up\uFF0C\u5426\u5219\u62D6\u62FD\u903B\u8F91\u6C38\u8FDC\u4E0D\u7ED3\u675F\u3002
|
|
1633
|
+
*/
|
|
1634
|
+
w.__wePointerLeave = function () {
|
|
1635
|
+
if ((ptrButtons & 1) !== 0 && ptrTarget) {
|
|
1636
|
+
ptrDispatch(ptrTarget, "pointerup", ptrX, ptrY, { button: 0, buttons: 0, detail: 1 });
|
|
1637
|
+
ptrDispatch(ptrTarget, "mouseup", ptrX, ptrY, { button: 0, buttons: 0, detail: 1 });
|
|
1638
|
+
}
|
|
1639
|
+
ptrButtons = 0;
|
|
1640
|
+
ptrDownTarget = null;
|
|
1641
|
+
if (ptrTarget) {
|
|
1642
|
+
ptrCrossBoundary(ptrTarget, null, ptrX, ptrY);
|
|
1643
|
+
ptrTarget = null;
|
|
1644
|
+
}
|
|
1645
|
+
// \u4F4D\u7F6E\uFF08ptrX/ptrY\uFF09\u4E0E ptrHas \u4FDD\u7559\uFF1A\u4E0B\u6B21\u8FDB\u6765\u65F6 movement \u624D\u662F\u771F\u5B9E\u4F4D\u79FB\uFF0C
|
|
1646
|
+
// \u800C\u4E0D\u662F\u4ECE (0,0) \u8DF3\u8FC7\u6765\u7684\u4E00\u4E2A\u5DE8\u5927\u5047 delta\u3002
|
|
1647
|
+
};
|
|
1648
|
+
|
|
1649
|
+
// \u2014\u2014 rAF \u8282\u6D41\uFF08\u5E26 __weThrottled\uFF0C\u907F\u514D\u7236\u9875 injectGpuThrottle \u53CC\u5C42\u51CF\u534A\uFF09\u2014\u2014
|
|
1650
|
+
|
|
1651
|
+
function installRafThrottle() {
|
|
1652
|
+
var throttled = function (cb) {
|
|
1653
|
+
if (typeof cb !== "function") return 0;
|
|
1654
|
+
if (paused) {
|
|
1655
|
+
var idHold = ++rafCounter;
|
|
1656
|
+
rafMap[idHold] = { kind: "hold", cb: cb };
|
|
1657
|
+
return idHold;
|
|
1658
|
+
}
|
|
1659
|
+
var limit = fps >= 60 ? 0 : 1000 / fps;
|
|
1660
|
+
if (limit <= 0) {
|
|
1661
|
+
var idNative = origRaf(function (now) {
|
|
1662
|
+
delete rafMap[idNative];
|
|
1663
|
+
try {
|
|
1664
|
+
cb(now);
|
|
1665
|
+
} catch (_) {
|
|
1666
|
+
/* \u5FFD\u7565 */
|
|
1667
|
+
}
|
|
1668
|
+
try {
|
|
1669
|
+
w.parent.postMessage({ op: "we-frame", t: now }, "*");
|
|
1670
|
+
} catch (_) {
|
|
1671
|
+
/* \u5FFD\u7565 */
|
|
1672
|
+
}
|
|
1673
|
+
});
|
|
1674
|
+
rafMap[idNative] = { kind: "native", id: idNative };
|
|
1675
|
+
return idNative;
|
|
1676
|
+
}
|
|
1677
|
+
var id = ++rafCounter;
|
|
1678
|
+
var to = w.setTimeout(function () {
|
|
1679
|
+
delete rafMap[id];
|
|
1680
|
+
origRaf(function (now) {
|
|
1681
|
+
try {
|
|
1682
|
+
cb(now);
|
|
1683
|
+
} catch (_) {
|
|
1684
|
+
/* \u5FFD\u7565 */
|
|
1685
|
+
}
|
|
1686
|
+
try {
|
|
1687
|
+
w.parent.postMessage({ op: "we-frame", t: now }, "*");
|
|
1688
|
+
} catch (_) {
|
|
1689
|
+
/* \u5FFD\u7565 */
|
|
1690
|
+
}
|
|
1691
|
+
});
|
|
1692
|
+
}, limit);
|
|
1693
|
+
rafMap[id] = { kind: "timeout", to: to };
|
|
1694
|
+
return id;
|
|
1695
|
+
};
|
|
1696
|
+
throttled.__weThrottled = true;
|
|
1697
|
+
w.requestAnimationFrame = throttled;
|
|
1698
|
+
w.cancelAnimationFrame = function (id) {
|
|
1699
|
+
var ent = rafMap[id];
|
|
1700
|
+
if (!ent) {
|
|
1701
|
+
try {
|
|
1702
|
+
origCaf(id);
|
|
1703
|
+
} catch (_) {
|
|
1704
|
+
/* \u5FFD\u7565 */
|
|
1705
|
+
}
|
|
1706
|
+
return;
|
|
1707
|
+
}
|
|
1708
|
+
delete rafMap[id];
|
|
1709
|
+
if (ent.kind === "timeout") w.clearTimeout(ent.to);
|
|
1710
|
+
else if (ent.kind === "native") origCaf(ent.id);
|
|
1711
|
+
};
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
installRafThrottle();
|
|
1715
|
+
})(window);
|
|
1716
|
+
|
|
1717
|
+
`;function Ze(e,n){try{const t=e.iframe?.contentWindow;t&&n(t)}catch{}}function Gl(e,n,t){const r=n.contentWindow;if(!r||r.requestAnimationFrame?.__weThrottled)return;const o=e.cfg.sceneFps||30;if(o>=60)return;const i=1e3/o;try{const s=r.requestAnimationFrame.bind(r),a=new Map;let c=0;r.requestAnimationFrame=u=>{const l=++c,p=r.setTimeout(()=>{a.delete(l),s(f=>{try{u(f)}catch{}})},i);return a.set(l,p),l},r.cancelAnimationFrame=u=>{const l=a.get(u);l!==void 0&&(r.clearTimeout(l),a.delete(u))}}catch{}}const ql=new Float32Array(128);function Yl(e,n,t){const r=Math.min(64,n.length),o=Math.min(64,t.length);for(let i=0;i<r;i++)e[i]=Number(n[i])||0;for(let i=0;i<o;i++)e[64+i]=Number(t[i])||0;return e}const Zl=1.8,Kl=1.8,Ql=30;function as(e){const n=Number(e)||0;return n<=0?0:Math.min(1,Math.pow(n,Kl)*Zl)}function Jl(){const e=zi(),n=new Float32Array(64),t=new Float32Array(64);return{tick(r){e.update(r/1e3)},snapshot(){const r=e.snapshot,o=r.preL64,i=r.preR64;for(let s=0;s<64;s++)o&&i?(n[s]=as(o[s]),t[s]=as(i[s])):(n[s]=(Number(r.left64[s])||0)*.2,t[s]=(Number(r.right64[s])||0)*.2);return{left:n,right:t}}}}function eu(e,n){if(e.wrap)return e.wrap;const t=n.canvas;if(!t)return null;if(t instanceof HTMLCanvasElement){const r=t.parentElement;return r?(se(e,n,"\u7F51\u9875\u58C1\u7EB8\u6302\u5728 canvas \u7236\u5BB9\u5668\u4E0A\uFF08canvas \u4E0D\u80FD\u6709\u5B50\u8282\u70B9\uFF1B\u66F4\u9002\u5408\u7A7A div\uFF09"),r):null}return t}function tu(e,n,t){const r=[];return n!=null&&Number.isFinite(n)&&r.push(`window.__weSetFps(${Number(n)});`),t!=null&&Number.isFinite(t)&&r.push(`window.__weSetVolume(${Math.max(0,Math.min(1,Number(t)))});`),e&&Object.keys(e).length&&r.push(`window.__weSeedProps(${JSON.stringify(e)});`),r.join(`
|
|
1718
|
+
`)}function nu(e,n,t){const r="position:absolute;border:none;background:transparent;",o=()=>{n.style.cssText=r+"inset:0;width:100%;height:100%;"};o();let i="";const s=()=>{if(!n.isConnected)return;let f=null;try{f=n.contentDocument}catch{return}if(!f)return;const d=t.clientWidth||window.innerWidth||0,w=t.clientHeight||window.innerHeight||0,M=un(e.cfg.fit)==="cover";o();const m=M&&d>0&&w>0?uu(f):null,A=m?lu(d,w,m.contentAspect):null,h=A?`${Math.round(A.width)}x${Math.round(A.height)}`:"full";if(!A){i="full";return}n.style.cssText=r+`left:${A.left}px;top:${A.top}px;width:${A.width}px;height:${A.height}px;`,h!==i&&(i=h,se(e,e.cfg,`\u7F51\u9875\u58C1\u7EB8\u9732\u5E95\u81EA\u9002\u914D\uFF1A\u89C6\u53E3\u6309\u5185\u5BB9\u6BD4\u4F8B\u6539\u4E3A ${Math.round(A.width)}\xD7${Math.round(A.height)}\uFF08cover \u5C45\u4E2D\u88C1\u5207\uFF09`))},a=()=>s();window.addEventListener("resize",a);let c;typeof ResizeObserver<"u"&&(c=new ResizeObserver(()=>s()),c.observe(t));const u=[],l=()=>{s();for(const f of[120,400,1200])u.push(window.setTimeout(s,f));try{const f=n.contentDocument;if(f)for(const d of f.querySelectorAll("video,img"))d.addEventListener("loadedmetadata",s,{once:!0}),d.addEventListener("load",s,{once:!0})}catch{}};n.addEventListener("load",l),e.webRelayout=s;const p=e.sceneCleanup;e.sceneCleanup=()=>{window.removeEventListener("resize",a),c?.disconnect();for(const f of u)clearTimeout(f);n.removeEventListener("load",l),e.webRelayout===s&&(e.webRelayout=void 0);try{p?.()}catch{}}}function ru(e,n,t,r,o){if(!Number.isFinite(e)||!Number.isFinite(n)||!(t.width>0)||!(t.height>0))return null;const i=r.width>0&&o.width>0?r.width/o.width:1,s=r.height>0&&o.height>0?r.height/o.height:1;return{x:(e*t.width-(r.left-t.left))/(i||1),y:(n*t.height-(r.top-t.top))/(s||1)}}function ou(e,n,t){e.pointerCtl={push(r){if(!n.isConnected)return;const o=t.getBoundingClientRect(),i=n.getBoundingClientRect(),s=ru(Number(r?.u),Number(r?.v),{left:o.left,top:o.top,width:o.width||t.clientWidth||window.innerWidth||0,height:o.height||t.clientHeight||window.innerHeight||0},{left:i.left,top:i.top,width:i.width,height:i.height},{width:n.clientWidth,height:n.clientHeight});s&&Ze(e,a=>a.__wePushPointer?.(s.x,s.y,Number(r.buttons)||0))},leave(){Ze(e,r=>r.__wePointerLeave?.())}}}function fo(e,n,t,r,o){const i=document.createElement("iframe");i.setAttribute("sandbox","allow-scripts allow-same-origin"),i.style.cssText="position:absolute;inset:0;width:100%;height:100%;border:none;background:transparent;",!e.wrap&&getComputedStyle(t).position==="static"&&(t.style.position="relative"),i.src=r,t.appendChild(i),e.iframe=i,o.blobUrl&&(e.objectUrls??=[]).push(o.blobUrl),nu(e,i,t),o.injected&&ou(e,i,t);const s=c=>{if(c.source!==i.contentWindow)return;const u=c.data;if(!u||u.op!=="we-frame"||e.paused)return;const l=typeof u.t=="number"?u.t:performance.now();o.frameClock&&(o.frameClock.last=l),qn(e,l)};window.addEventListener("message",s);const a=e.sceneCleanup;e.sceneCleanup=()=>{window.removeEventListener("message",s);try{a?.()}catch{}},i.addEventListener("load",()=>{try{const l=i.contentDocument;l&&window.__blockContextMenu?.(l),o.injected||Gl(e,i,l)}catch{}Ze(e,l=>{const p={};for(const[f,d]of Object.entries(e.liveUserProps??{}))p[f]={value:d};l.__weApplyProps?.(p),l.__weSetFps?.(e.cfg.sceneFps??60),l.__weSetVolume?.(e.cfg.muted===!1?1:0),e.paused&&l.__weSetPaused?.(!0)});try{e.onFirstFrame?.(),e.onFirstFrame=void 0}catch{}const c=t.clientWidth||window.innerWidth||1,u=t.clientHeight||window.innerHeight||1;try{e.onSceneInfo?.({width:c,height:u,layerCount:0,hasModels:!1,hasParticles:!1,hasText:!1})}catch{}})}const iu=.005,su=.01,au=.2,cu=6;function lu(e,n,t){if(!(e>0)||!(n>0)||!(t>0))return null;const r=e/n;if(Math.abs(r-t)<=iu)return null;if(r<t){const i=n*t;return{width:i,height:n,left:(e-i)/2,top:0}}const o=e/t;return{width:e,height:o,left:0,top:(n-o)/2}}function uu(e){const n=e.defaultView;if(!n)return null;const t=n.innerWidth,r=n.innerHeight;if(!(t>0)||!(r>0))return null;const o=[...e.querySelectorAll("video,img")];for(const i of o){const s=i.getBoundingClientRect();if(s.width<=0||s.height<=0||s.width<t*.98||Math.abs(s.left)>t*.02||s.top>r*.02||r-s.height<r*su)continue;const a=i.videoWidth||i.naturalWidth||0,c=i.videoHeight||i.naturalHeight||0;if(!(a>0)||!(c>0))continue;const u=a/c;if(!(!Number.isFinite(u)||u<au||u>cu))return{contentAspect:u}}return null}function en(e){if(!e)return"rgb(128,128,128)";const n=Math.round(Math.max(0,Math.min(1,Number(e.x)||0))*255),t=Math.round(Math.max(0,Math.min(1,Number(e.y)||0))*255),r=Math.round(Math.max(0,Math.min(1,Number(e.z)||0))*255);return`rgb(${n},${t},${r})`}function fu(e){try{const n=document.createElement("canvas");n.width=n.height=64;const t=n.getContext("2d");if(!t)return"";const r=e.primaryColor,o=e.secondaryColor,i=t.createLinearGradient(0,0,64,64);return i.addColorStop(0,en(r)),i.addColorStop(1,en(o)),t.fillStyle=i,t.fillRect(0,0,64,64),n.toDataURL("image/jpeg",.85)}catch{return""}}function du(){return xe.createSimulatedMedia()}function pu(e,n,t){const r=xe.diffMediaEvents(n,t);for(const{name:o,event:i}of r)if(o==="mediaStatusChanged")Ze(e,s=>s.__wePushMedia?.({op:"status",enabled:!!i.enabled}));else if(o==="mediaPropertiesChanged")Ze(e,s=>s.__wePushMedia?.({op:"properties",title:i.title??"",artist:i.artist??"",album:i.album??"",albumArtist:i.albumArtist??""}));else if(o==="mediaThumbnailChanged"){const s=fu(t);Ze(e,a=>a.__wePushMedia?.({op:"thumbnail",thumbnail:s,hasThumbnail:!!i.hasThumbnail||!!s,primaryColor:en(i.primaryColor),secondaryColor:en(i.secondaryColor),tertiaryColor:en(i.tertiaryColor),textColor:en(i.textColor),highContrastColor:en(i.highContrastColor)}))}else o==="mediaPlaybackChanged"?Ze(e,s=>s.__wePushMedia?.({op:"playback",state:Number(i.state)||0})):o==="mediaTimelineChanged"&&Ze(e,s=>s.__wePushMedia?.({op:"timeline",position:Number(i.position)||0,duration:Number(i.duration)||0}));return xe.cloneMediaSnapshot(t)}function cs(e,n,t){if(!n)return;let r=0,o=0;const i=a=>{if(r=requestAnimationFrame(i),e.paused||!e.iframe)return;const c=e.cfg.sceneFps||60,l=1e3/Math.min(Math.max(1,c),Ql);if(!(a-o<l*.85)){o=a;try{n.tick?.(a);const p=n.snapshot(),f=Yl(ql,p.left,p.right);Ze(e,d=>d.__wePushAudio?.(f)),t&&a-t.last>200&&qn(e,a)}catch{}}};r=requestAnimationFrame(i);const s=e.sceneCleanup;e.sceneCleanup=()=>{cancelAnimationFrame(r);try{s?.()}catch{}}}function ls(e,n){if(!n)return;let t=0,r=null,o=0;const i=a=>{if(t=requestAnimationFrame(i),!(e.paused||!e.iframe)&&!(a-o<200)){o=a;try{n.update(a/1e3),r=pu(e,r,n.snapshot)}catch{}}};t=requestAnimationFrame(i);const s=e.sceneCleanup;e.sceneCleanup=()=>{cancelAnimationFrame(t);try{s?.()}catch{}}}function hu(e){e.sceneCtl={pause(){e.paused=!0,Ze(e,n=>n.__weSetPaused?.(!0))},resume(){e.paused=!1,Ze(e,n=>n.__weSetPaused?.(!1))},applyUserProperties(n){const t={...e.liveUserProps??{}};for(const[r,o]of Object.entries(n??{})){const i=o&&typeof o=="object"&&"value"in o?o.value:o;t[r]=i}e.liveUserProps=t,Ze(e,r=>r.__weApplyProps?.(n))}}}function mu(e){try{return new URL(e,location.href).origin===location.origin}catch{return!1}}function gu(e){const n=e?.general?.properties;if(!n||typeof n!="object")return{};const t={};for(const[r,o]of Object.entries(n)){if(!o||typeof o!="object"||typeof o.type!="string")continue;const i=o.value,s=o.type.toLowerCase();if(i==null){if(s==="file"||s==="directory"){t[r]={value:""};continue}if(!("value"in o))continue}t[r]={value:i}}return t}async function bu(e){try{const n=new URL("project.json",new URL(e,location.href)),t=await fetch(n.href,{credentials:"same-origin"});return t.ok?gu(await t.json()):{}}catch{return{}}}function yu(e,n){const t={...e};if(n)for(const[r,o]of Object.entries(n))t[r]={value:o};return t}function vu(e,n){Zt(e),e.cfg=n;const t=eu(e,n);if(!t){se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u53EF\u7528\u5BB9\u5668"),e.onError?.(new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u53EF\u7528\u5BB9\u5668"));return}const r=n.src??"";if(!r){se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u7F3A\u5C11 src"),e.onError?.(new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u7F3A\u5C11 src"));return}hu(e);const o=n,i=o._webAudio===null?null:o._webAudio??Jl(),s=o._webMedia===null?null:o._webMedia??du(),a=l=>{se(e,n,`\u7F51\u9875\u58C1\u7EB8 shim \u6CE8\u5165\u5931\u8D25\uFF08${l}\uFF09\uFF0C\u9000\u56DE\u88F8 iframe`),fo(e,n,t,r,{injected:!1}),cs(e,null),ls(e,null)},c={last:0},u=()=>{cs(e,i,c),ls(e,s)};(async()=>{const l=await bu(r),p=yu(l,e.liveUserProps);if(e.liveUserProps=Object.fromEntries(Object.entries(p).map(([f,d])=>[f,d.value])),mu(r)){fo(e,n,t,r,{injected:!0,frameClock:c}),u(),e.iframe?.addEventListener("load",()=>{let d=!1;Ze(e,w=>{d=typeof w.__weSetPaused=="function"}),d||se(e,n,"\u7F51\u9875\u58C1\u7EB8\uFF1A\u540C\u6E90\u5165\u53E3\u672A\u68C0\u6D4B\u5230 WE shim\uFF08host \u672A\u6CE8\u5165\uFF1F\uFF09\uFF1BSpine \u7C7B\u58C1\u7EB8\u8BF7\u786E\u8BA4 /web/ HTML \u6539\u5199")},{once:!0});return}try{const f=await fetch(r,{credentials:"same-origin"});if(!f.ok){a(`HTTP ${f.status}`);return}const d=await f.text();if(Wl(d)){a("CSP \u963B\u6B62 inline script");return}const w=Hl(d,Xl,{baseHref:Vl(r),seedScript:tu(p,n.sceneFps,n.muted===!1?1:0)}),M=new Blob([w],{type:"text/html;charset=utf-8"}),m=URL.createObjectURL(M);fo(e,n,t,m,{blobUrl:m,injected:!0,frameClock:c}),u()}catch(f){a(f instanceof Error?f.message:String(f))}})()}function br(e,n){const t=String(n.type??"").toLowerCase();n={...n,type:t},e.cfg=n,(t==="video"||t==="gif"||t==="image")&&n.src?hl(e,n):t==="scene"&&(n.source||n.src)?jl(e,n):t==="web"&&n.src?vu(e,n):e.onUnhandledType?.(n)}function xu(e){return e==="fit"?"contain":e==="fill"?"cover":e==="contain"||e==="stretch"?e:"cover"}function wu(e){const n=e?.type;return typeof n=="string"&&n.toLowerCase()==="web"}function Mu(e){if(e instanceof HTMLCanvasElement)return e;const n=e.querySelector(":scope > canvas[data-webwallgl]");if(n instanceof HTMLCanvasElement)return n;const t=document.createElement("canvas");return t.setAttribute("data-webwallgl","1"),t.style.cssText="position:absolute;inset:0;width:100%;height:100%;display:block;",getComputedStyle(e).position==="static"&&(e.style.position="relative"),e.appendChild(t),t}async function us(e,n){const t={fit:xu(n.fit),renderDpr:n.renderDpr??1,sceneFps:n.fps??60,muted:(n.volume??0)<=0,loop:!0,canvas:e,source:n.source};let r=null;try{r=await n.source.project?.()??null}catch{r=null}if(wu(r)){let i;try{i=(await n.source.webEntry?.())?.url}catch{i=void 0}if(!i&&n.source.key){const s=r&&typeof r.file=="string"&&String(r.file).trim().replace(/^\/+/,"")||"index.html";i=`${n.source.key.replace(/\/+$/,"")}/${s}`}if(!i)throw new Error("\u7F51\u9875\u58C1\u7EB8\uFF1A\u65E0\u6CD5\u89E3\u6790\u5165\u53E3 URL\uFF08\u9700\u8981 Source.webEntry \u6216 httpSource\uFF09");return{...t,type:"web",src:i,source:n.source}}const o=Mu(e);return{...t,type:"scene",canvas:o,source:n.source}}function fs(e,n){const t=hs(),r={ready:[],error:[],diagnostic:[]};let o={...n??{},source:null},i=e;const s=f=>{for(const d of r.error)try{d(f)}catch{}},a=f=>{t.onDiagnostic=(d,w)=>{try{f.onDiagnostic?.(d,w)}catch{}for(const M of r.diagnostic)try{M(d,w)}catch{}},t.onError=d=>{try{f.onError?.(d)}catch{}s(d)},t.onSceneInfo=d=>{t.info=d}},c=()=>new Promise(f=>{const d=t.onFirstFrame;t.onFirstFrame=()=>{t.onFirstFrame=void 0,d?.();const w=t.info??{width:0,height:0,layerCount:0,hasModels:!1,hasParticles:!1,hasText:!1};try{o.onReady?.(w)}catch{}for(const M of r.ready)try{M(w)}catch{}f()}}),u=()=>{let f=()=>{};return{promise:new Promise((w,M)=>{f=l.on("error",m=>M(m))}),off:f}},l={get canvas(){return i},pause(){t.paused=!0,t.sceneCtl?.pause()},resume(){t.paused=!1,vo(t),t.sceneCtl?.resume()},get paused(){return!!t.paused},setFit(f){t.cfg.fit=f,Pr(t)},setFps(f){t.cfg.sceneFps=f,Ze(t,d=>d.__weSetFps?.(f))},setVolume(f){const d=Math.max(0,Math.min(1,f));t.cfg.muted=d<=0,t.sceneAudio?.setVolume(d),Ze(t,w=>w.__weSetVolume?.(d))},setRenderDpr(f){t.cfg.renderDpr=f,br(t,t.cfg)},setProperties(f){const d={};for(const[w,M]of Object.entries(f))d[w]={value:M};t.sceneCtl?.applyUserProperties(d)},getProperties(){return{...t.liveUserProps??{}}},async load(f){o={...o,source:f},a(o);const d=await us(i,o);d.type==="scene"&&d.canvas instanceof HTMLCanvasElement&&(i=d.canvas),t.cfg=d,t.paused=!1,t.info=void 0,Pr(t),o.properties&&(t.liveUserProps={...o.properties});const w=c(),M=u();br(t,d);try{await Promise.race([w,M.promise])}finally{M.off()}},release(){Zt(t)},restore(){br(t,t.cfg)},destroy(){ms(t),t.onDiagnostic=void 0,t.onError=void 0,t.onFirstFrame=void 0,t.onSceneInfo=void 0,r.ready.length=0,r.error.length=0,r.diagnostic.length=0},get stats(){return bs(t)},get info(){return t.info??null},on(f,d){const w=r[f];return w.push(d),()=>{const M=w.indexOf(d);M>=0&&w.splice(M,1)}}},p=async f=>{o=f,a(f);const d=await us(e,f);d.type==="scene"&&d.canvas instanceof HTMLCanvasElement&&(i=d.canvas),t.cfg=d,t.paused=f.autoplay===!1,t.info=void 0,Pr(t),f.properties&&Object.keys(f.properties).length&&(t.liveUserProps={...f.properties});const w=c(),M=u();br(t,t.cfg);try{await Promise.race([w,M.promise])}finally{M.off()}(f.volume??0)>0&&l.setVolume(f.volume),f.properties&&Object.keys(f.properties).length&&l.setProperties(f.properties)};return l.__applyOptions=p,l}async function _u(e,n){const t=fs(e,n);return await t.__applyOptions(n),t}yt.bytesSource=vl,yt.createScene=fs,yt.fileSource=yl,yt.httpSource=Ki,yt.mount=_u,Object.defineProperty(yt,Symbol.toStringTag,{value:"Module"})});
|
|
499
1719
|
|
|
500
1720
|
//# sourceMappingURL=webwallgl.global.min.js.map
|