dsh-plugin-beyond-simulator 2.0.0 → 2.0.2
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.
|
@@ -922,7 +922,7 @@ fn mainFragment(
|
|
|
922
922
|
`),e.unshift(`
|
|
923
923
|
var stride = ${r};
|
|
924
924
|
`);let s=e.join(`
|
|
925
|
-
`);return new Function("ps","f32v","u32v",s)}var Ja=class{constructor(t){this._size=0,this._generateParticleUpdateCache={};let e=this._size=t.size??1e3,r=t.properties,s=0,n=0;for(let h in r){let u=r[h],d=Wt(u.format);u.dynamic?n+=d.stride:s+=d.stride}this._dynamicStride=n/4,this._staticStride=s/4,this.staticAttributeBuffer=new Ge(e*4*s),this.dynamicAttributeBuffer=new Ge(e*4*n),this.indexBuffer=Xu(e);let o=new Be,a=0,l=0;this._staticBuffer=new Ft({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:it.VERTEX|it.COPY_DST}),this._dynamicBuffer=new Ft({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:it.VERTEX|it.COPY_DST});for(let h in r){let u=r[h],d=Wt(u.format);u.dynamic?(o.addAttribute(u.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:a*4,format:u.format}),a+=d.size):(o.addAttribute(u.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:l*4,format:u.format}),l+=d.size)}o.addIndex(this.indexBuffer);let c=this.getParticleUpdate(r);this._dynamicUpload=c.dynamicUpdate,this._staticUpload=c.staticUpdate,this.geometry=o}getParticleUpdate(t){let e=WE(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return j0(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new Ge(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Ge(this._size*this._dynamicStride*4*4),this.indexBuffer=Xu(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));let r=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,r.float32View,r.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){let s=this.staticAttributeBuffer;this._staticUpload(t,s.float32View,s.uint32View),this._staticBuffer.setDataWithSize(s.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}};function WE(i){let t=[];for(let e in i){let r=i[e];t.push(e,r.code,r.dynamic?"d":"s")}return t.join("_")}dt();et();rr();mt();rc();xe();Iu();fo();Za();Gt();H.add(ym,vm);function $0(i,t,e){if(i.fillType!=="Horizontal"&&i.fillType!=="Vertical")return null;let r=Number(i.fillAmount??1),s=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1;if(i.fillType==="Horizontal"){let o=t*s;return{x:i.fillHorizontalType==="Right"?t/2-o:-t/2,y:-e/2,width:o,height:e}}let n=e*s;return{x:-t/2,y:i.fillVerticalType==="Top"?-e/2:e/2-n,width:t,height:n}}Nh();jh();$h();Mh();ca();kr();sr();var K0={aVertex:(i,t,e,r,s)=>{let n=0,o=0,a=0,l=0;for(let c=0;c<i.length;++c){let h=i[c],u=h.texture,d=h.scaleX,f=h.scaleY,m=h.anchorX,g=h.anchorY,y=u.trim,x=u.orig;y?(o=y.x-m*x.width,n=o+y.width,l=y.y-g*x.height,a=l+y.height):(n=x.width*(1-m),o=x.width*-m,a=x.height*(1-g),l=x.height*-g),t[r]=o*d,t[r+1]=l*f,t[r+s]=n*d,t[r+s+1]=l*f,t[r+s*2]=n*d,t[r+s*2+1]=a*f,t[r+s*3]=o*d,t[r+s*3+1]=a*f,r+=s*4}},aPosition:(i,t,e,r,s)=>{for(let n=0;n<i.length;++n){let o=i[n],a=o.x,l=o.y;t[r]=a,t[r+1]=l,t[r+s]=a,t[r+s+1]=l,t[r+s*2]=a,t[r+s*2+1]=l,t[r+s*3]=a,t[r+s*3+1]=l,r+=s*4}},aRotation:(i,t,e,r,s)=>{for(let n=0;n<i.length;++n){let o=i[n].rotation;t[r]=o,t[r+s]=o,t[r+s*2]=o,t[r+s*3]=o,r+=s*4}},aUV:(i,t,e,r,s)=>{for(let n=0;n<i.length;++n){let o=i[n].texture.uvs;t[r]=o.x0,t[r+1]=o.y0,t[r+s]=o.x1,t[r+s+1]=o.y1,t[r+s*2]=o.x2,t[r+s*2+1]=o.y2,t[r+s*3]=o.x3,t[r+s*3+1]=o.y3,r+=s*4}},aColor:(i,t,e,r,s)=>{for(let n=0;n<i.length;++n){let o=i[n].color;e[r]=o,e[r+s]=o,e[r+s*2]=o,e[r+s*3]=o,r+=s*4}}};function Z0(i){let t=Object.values(i),e=t.filter(s=>s.dynamic),r=t.filter(s=>!s.dynamic);return{dynamicUpdate:q0(e),staticUpdate:q0(r)}}function q0(i){let t=0,e=[];for(let r=0;r<i.length;r++){let s=i[r],n=Wt(s.format).stride/4;t+=n,e.push({stride:n,updateFunction:s.updateFunction||K0[s.attributeName]})}return(r,s,n)=>{let o=0;for(let a=0;a<e.length;a++){let l=e[a];l.updateFunction(r,s,n,o,t),o+=l.stride}}}Js();ce();Ot();xr();Hh();function Q0(){return VE}function VE(i,t,e){let r=i.gl,s=i.shader,n=s._getProgramData(t.glProgram);for(let o in t.groups){let a=t.groups[o];for(let l in a.resources){let c=a.resources[l];if(c instanceof St)c.ubo?s.bindUniformBlock(c,t._uniformBindMap[o][l],e.blockIndex++):s.updateUniformGroup(c);else if(c instanceof ke)s.bindUniformBlock(c,t._uniformBindMap[o][l],e.blockIndex++);else if(c instanceof J||c instanceof Gi){i.texture.bind(c,e.textureCount);let h=t._uniformBindMap[o][l],u=n.uniformData[h];u&&(u.value!==e.textureCount&&r.uniform1i(u.location,e.textureCount),e.textureCount++)}else c instanceof Qt}}}va();ha();Qs();var J0=[(i,t,e,r,s)=>{let n=r[i].toArray(!0);t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+4]=n[3],t[e+5]=n[4],t[e+6]=n[5],t[e+8]=n[6],t[e+9]=n[7],t[e+10]=n[8]},(i,t,e,r,s)=>{s=r[i],t[e]=s.x,t[e+1]=s.y,t[e+2]=s.width,t[e+3]=s.height},(i,t,e,r,s)=>{s=r[i],t[e]=s.x,t[e+1]=s.y},(i,t,e,r,s)=>{s=r[i],t[e]=s.red,t[e+1]=s.green,t[e+2]=s.blue,t[e+3]=s.alpha},(i,t,e,r,s)=>{s=r[i],t[e]=s.red,t[e+1]=s.green,t[e+2]=s.blue}],tv={f32:(i,t,e,r,s)=>{t[e]=s},i32:(i,t,e,r,s)=>{t[e]=s},"vec2<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1]},"vec3<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2]},"vec4<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3]},"mat2x2<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3]},"mat3x3<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+4]=s[3],t[e+5]=s[4],t[e+6]=s[5],t[e+8]=s[6],t[e+9]=s[7],t[e+10]=s[8]},"mat4x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<16;n++)t[e+n]=s[n]},"mat3x2<f32>":(i,t,e,r,s)=>{for(let n=0;n<6;n++)t[e+(n/3|0)*4+n%3]=s[n]},"mat4x2<f32>":(i,t,e,r,s)=>{for(let n=0;n<8;n++)t[e+(n/4|0)*4+n%4]=s[n]},"mat2x3<f32>":(i,t,e,r,s)=>{for(let n=0;n<6;n++)t[e+(n/2|0)*4+n%2]=s[n]},"mat4x3<f32>":(i,t,e,r,s)=>{for(let n=0;n<12;n++)t[e+(n/4|0)*4+n%4]=s[n]},"mat2x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<8;n++)t[e+(n/2|0)*4+n%2]=s[n]},"mat3x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<12;n++)t[e+(n/3|0)*4+n%3]=s[n]}},ev={f32:(i,t,e,r,s)=>{t[e]=s},i32:(i,t,e,r,s)=>{t[e]=s},"vec2<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1]},"vec3<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2]},"vec4<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3]},"mat2x2<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+4]=s[2],t[e+5]=s[3]},"mat3x3<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+4]=s[3],t[e+5]=s[4],t[e+6]=s[5],t[e+8]=s[6],t[e+9]=s[7],t[e+10]=s[8]},"mat4x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<16;n++)t[e+n]=s[n]},"mat3x2<f32>":(i,t,e,r,s)=>{for(let n=0;n<6;n++)t[e+(n/3|0)*4+n%3]=s[n]},"mat4x2<f32>":(i,t,e,r,s)=>{for(let n=0;n<8;n++)t[e+(n/4|0)*4+n%4]=s[n]},"mat2x3<f32>":(i,t,e,r,s)=>{for(let n=0;n<6;n++)t[e+(n/2|0)*4+n%2]=s[n]},"mat4x3<f32>":(i,t,e,r,s)=>{for(let n=0;n<12;n++)t[e+(n/4|0)*4+n%4]=s[n]},"mat2x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<8;n++)t[e+(n/2|0)*4+n%2]=s[n]},"mat3x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<12;n++)t[e+(n/3|0)*4+n%3]=s[n]}};function rv(i){return sv(i,ev,t=>{let e=Math.max(_n[t.data.type]/16,1),r=t.data.value.length/t.data.size,s=(4-r%4)%4;return(n,o,a,l,c)=>{let h=0;for(let u=0;u<t.data.size*e;u++){for(let d=0;d<r;d++)o[a++]=c[h++];a+=s}}})}function iv(i){return sv(i,tv,t=>{let{size:e,align:r}=Nr[t.data.type],s=(e-r)/4;return(n,o,a,l,c)=>{let h=0;for(let u=0;u<t.data.size*(e/4);u++){for(let d=0;d<e/4;d++)o[a++]=c[h++];a+=s}}})}function sv(i,t,e){let r={};for(let s in i){let n=i[s],o=n.data,a=!1;r[o.name]={offset:n.offset/4,func:null};for(let l=0;l<Jt.length;l++){let c=Jt[l];if(o.type===c.type&&c.test(o)){r[o.name].func=J0[l],a=!0;break}}a||(o.size===1?r[o.name].func=t[o.type]:r[o.name].func=e(n))}return(s,n,o)=>{for(let a in r)r[a].func(a,n,o+r[a].offset,s,s[a])}}Qs();var nv={f32(i,t,e,r,s,n,o){e!==r&&(t.value=r,o.uniform1f(s[i].location,r))},"vec2<f32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1])&&(e[0]=r[0],e[1]=r[1],o.uniform2f(s[i].location,r[0],r[1]))},"vec3<f32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],o.uniform3f(s[i].location,r[0],r[1],r[2]))},"vec4<f32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],o.uniform4f(s[i].location,r[0],r[1],r[2],r[3]))},i32(i,t,e,r,s,n,o){e!==r&&(t.value=r,o.uniform1i(s[i].location,r))},"vec2<i32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1])&&(e[0]=r[0],e[1]=r[1],o.uniform2i(s[i].location,r[0],r[1]))},"vec3<i32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],o.uniform3i(s[i].location,r[0],r[1],r[2]))},"vec4<i32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],o.uniform4i(s[i].location,r[0],r[1],r[2],r[3]))},u32(i,t,e,r,s,n,o){e!==r&&(t.value=r,o.uniform1ui(s[i].location,r))},"vec2<u32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1])&&(e[0]=r[0],e[1]=r[1],o.uniform2ui(s[i].location,r[0],r[1]))},"vec3<u32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],o.uniform3ui(s[i].location,r[0],r[1],r[2]))},"vec4<u32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],o.uniform4ui(s[i].location,r[0],r[1],r[2],r[3]))},bool(i,t,e,r,s,n,o){e!==r&&(t.value=r,o.uniform1i(s[i].location,r))},"vec2<bool>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1])&&(e[0]=r[0],e[1]=r[1],o.uniform2i(s[i].location,r[0],r[1]))},"vec3<bool>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],o.uniform3i(s[i].location,r[0],r[1],r[2]))},"vec4<bool>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],o.uniform4i(s[i].location,r[0],r[1],r[2],r[3]))},"mat2x2<f32>"(i,t,e,r,s,n,o){o.uniformMatrix2fv(s[i].location,!1,r)},"mat3x3<f32>"(i,t,e,r,s,n,o){o.uniformMatrix3fv(s[i].location,!1,r)},"mat4x4<f32>"(i,t,e,r,s,n,o){o.uniformMatrix4fv(s[i].location,!1,r)}},ov={f32(i,t,e,r,s,n,o){o.uniform1fv(s[i].location,r)},"vec2<f32>"(i,t,e,r,s,n,o){o.uniform2fv(s[i].location,r)},"vec3<f32>"(i,t,e,r,s,n,o){o.uniform3fv(s[i].location,r)},"vec4<f32>"(i,t,e,r,s,n,o){o.uniform4fv(s[i].location,r)},"mat2x2<f32>"(i,t,e,r,s,n,o){o.uniformMatrix2fv(s[i].location,!1,r)},"mat3x3<f32>"(i,t,e,r,s,n,o){o.uniformMatrix3fv(s[i].location,!1,r)},"mat4x4<f32>"(i,t,e,r,s,n,o){o.uniformMatrix4fv(s[i].location,!1,r)},i32(i,t,e,r,s,n,o){o.uniform1iv(s[i].location,r)},"vec2<i32>"(i,t,e,r,s,n,o){o.uniform2iv(s[i].location,r)},"vec3<i32>"(i,t,e,r,s,n,o){o.uniform3iv(s[i].location,r)},"vec4<i32>"(i,t,e,r,s,n,o){o.uniform4iv(s[i].location,r)},u32(i,t,e,r,s,n,o){o.uniform1iv(s[i].location,r)},"vec2<u32>"(i,t,e,r,s,n,o){o.uniform2iv(s[i].location,r)},"vec3<u32>"(i,t,e,r,s,n,o){o.uniform3iv(s[i].location,r)},"vec4<u32>"(i,t,e,r,s,n,o){o.uniform4iv(s[i].location,r)},bool(i,t,e,r,s,n,o){o.uniform1iv(s[i].location,r)},"vec2<bool>"(i,t,e,r,s,n,o){o.uniform2iv(s[i].location,r)},"vec3<bool>"(i,t,e,r,s,n,o){o.uniform3iv(s[i].location,r)},"vec4<bool>"(i,t,e,r,s,n,o){o.uniform4iv(s[i].location,r)}},av=[(i,t,e,r,s,n,o)=>{o.uniformMatrix3fv(s[i].location,!1,n[i].toArray(!0))},(i,t,e,r,s,n,o)=>{e=s[i].value,r=n[i],(e[0]!==r.x||e[1]!==r.y||e[2]!==r.width||e[3]!==r.height)&&(e[0]=r.x,e[1]=r.y,e[2]=r.width,e[3]=r.height,o.uniform4f(s[i].location,r.x,r.y,r.width,r.height))},(i,t,e,r,s,n,o)=>{e=s[i].value,r=n[i],(e[0]!==r.x||e[1]!==r.y)&&(e[0]=r.x,e[1]=r.y,o.uniform2f(s[i].location,r.x,r.y))},(i,t,e,r,s,n,o)=>{e=s[i].value,r=n[i],(e[0]!==r.red||e[1]!==r.green||e[2]!==r.blue||e[3]!==r.alpha)&&(e[0]=r.red,e[1]=r.green,e[2]=r.blue,e[3]=r.alpha,o.uniform4f(s[i].location,r.red,r.green,r.blue,r.alpha))},(i,t,e,r,s,n,o)=>{e=s[i].value,r=n[i],(e[0]!==r.red||e[1]!==r.green||e[2]!==r.blue)&&(e[0]=r.red,e[1]=r.green,e[2]=r.blue,o.uniform3f(s[i].location,r.red,r.green,r.blue))}];function lv(i,t){let e={};for(let r in i.uniformStructures){if(!t[r])continue;let s=i.uniformStructures[r],n=!1;for(let o=0;o<Jt.length;o++){let a=Jt[o];if(s.type===a.type&&a.test(s)){e[r]=av[o],n=!0;break}}if(!n){let o=s.size===1?nv:ov;e[r]=o[s.type]}}return(r,s,n)=>{let o=n.gl;for(let a in e){let l=s[a],c=r[a],h=r[a].value;e[a](a,c,h,l,r,s,o)}}}function zE(){Object.assign(ue.prototype,{_unsafeEvalCheck(){}}),Object.assign(cr.prototype,{_systemCheck(){}}),Object.assign(zr.prototype,{_generateUniformsSync:lv}),Object.assign(Wr.prototype,{_generateUboSync:rv}),Object.assign(Hr.prototype,{_generateUboSync:iv}),Object.assign(Vr.prototype,{_generateShaderSync:Q0}),Object.assign(Ja.prototype,{generateParticleUpdate:Z0})}zE();var cv=33;function Yu(i,t){let e=i.code&&String(i.code).startsWith("Digit")?String(i.code).slice(5):"";return e&&Number(e)>=1&&Number(e)<=9?`KeyboardCraftspersonKey${e}${t}`:""}function hv(i,t,e,r){return{x:(i.clientX-t.left)*e/t.width,y:(t.bottom-i.clientY)*r/t.height}}function uv({renderer:i,api:t,onSnapshot:e,onStatus:r,onError:s,isActive:n}={}){let o=null,a=!1,l=!1,c=null,h=null,u=0,d=null,f=null,m=[];function g(F){s&&s(F)}async function y(F){o=F,a=F?.running!==!1,F?.scene&&F.scene.format==="tree-v1"?(F.scene.reset&&(u=0),await i.applyScene(F.scene,F.canvasWidth,F.canvasHeight),u=F.scene.revision||u):Array.isArray(F?.paint)&&await i.render(F.paint,F.canvasWidth,F.canvasHeight),e&&await e(F)}async function x(){if(!(!a||l)&&!(n&&!n())){l=!0;try{await y(await t("get",{view:!0,sceneRev:u,compact:!0}))}catch(F){a=!1,v(),g(F)}finally{l=!1}}}function b(){c||(c=setInterval(()=>{x()},33))}function v(){c&&clearInterval(c),c=null,h&&clearTimeout(h),h=null}function T(F=30){h||(h=setTimeout(()=>{h=null,x()},F))}function S(){a=!1,u=0,v()}async function E(F,A){if(n&&!n())return null;try{let k=await t(F,{light:!0,...A||{}});return k&&typeof k=="object"&&k.frame!==void 0&&r&&r(k),T(30),k}catch(k){return g(k),null}}async function w(F={}){u=0;let A=await t("start",{view:!0,compact:!0,...F});return await y({...A,running:!0}),a=!0,v(),b(),A}async function I(){u=0,v();let F=await t("get",{view:!0,compact:!0,sceneRev:0});return await y(F),a&&b(),F}async function G(F={}){u=0,v();let A=await t("device",{view:!0,compact:!0,...F});return await y({...A,running:!0}),a=!0,b(),A}async function M(F={}){u=0;let A=await t("view",{view:!0,compact:!0,...F});return await y({...A,running:!0}),A}async function C(){return S(),t("stop")}function R(F,A){return hv(F,A.getBoundingClientRect(),o.canvasWidth,o.canvasHeight)}function L(F,{keysOn:A}={}){let k=A||F,X=z=>{!o||!a||n&&!n()||(F.setPointerCapture?.(z.pointerId),E("pointer",{type:"down",...R(z,F)}))},D=z=>{!o||!a||n&&!n()||E("pointer",{type:"up",...R(z,F)})},Z=z=>{!o||!a||n&&!n()||(f=R(z,F),!d&&(d=setTimeout(()=>{d=null,f&&E("pointer",{type:"move",...f})},60)))},ht=()=>{o&&a&&(!n||n())&&E("pointer",{type:"move",x:-1,y:-1})},xt=z=>{if(!o||!a||n&&!n())return;let Dt=Yu(z,"Down");Dt&&(z.preventDefault(),E("key",{key:Dt}))},st=z=>{if(!o||!a||n&&!n())return;let Dt=Yu(z,"Up");Dt&&(z.preventDefault(),E("key",{key:Dt}))};F.addEventListener("pointerdown",X),F.addEventListener("pointerup",D),F.addEventListener("pointermove",Z),F.addEventListener("pointerleave",ht),k.addEventListener("keydown",xt),k.addEventListener("keyup",st);let at=()=>{F.removeEventListener("pointerdown",X),F.removeEventListener("pointerup",D),F.removeEventListener("pointermove",Z),F.removeEventListener("pointerleave",ht),k.removeEventListener("keydown",xt),k.removeEventListener("keyup",st),d&&clearTimeout(d),d=null};return m.push(at),at}function V(){for(S();m.length;)m.pop()();i?.destroy?.()}return{get snapshot(){return o},get running(){return a},get sceneRev(){return u},applyScene:y,poll:x,pollSoon:T,startPolling:b,stopPolling:v,reset:S,act:E,start:w,attach:I,device:G,view:M,stop:C,bindInput:L,destroy:V}}var XE=[0,-.5,.5,.5,-.5,.5],YE=[0,-.5,.12,-.12,.5,0,.12,.12,0,.5,-.12,.12,-.5,0,-.12,-.12],jE=[0,-.5,.11,-.15,.48,-.15,.18,.07,.29,.41,0,.2,-.29,.41,-.18,.07,-.48,-.15,-.11,-.15],$E=new Set(["image","textbox","textwindow","button"]);function Ln(i,t=4294967295){let e=Number(i??t)>>>0;return{color:e&16777215,alpha:(e>>>24&255)/255}}function Zt(i,t=0){let e=Number(i);return Number.isFinite(e)?e:t}function KE(i){let t=i?.matrix;if(!t||typeof t!="object")return null;let e=[t.a,t.b,t.c,t.d,t.tx,t.ty].map(Number);return e.every(Number.isFinite)?e:null}function qE(i){let t=i.horizontalAlignment==="Right"?1:i.horizontalAlignment==="Middle"?.5:0,e=i.verticalAlignment==="Bottom"?1:i.verticalAlignment==="Middle"?.5:0;return{x:t,y:e}}function ZE(i,t,e){let r=i.primitive==="triangle"?XE:i.primitive==="fourstar"?YE:jE,s=[];for(let n=0;n<r.length;n+=2)s.push(r[n]*t,r[n+1]*e);return s}function QE(i,t,e){return dv(i)?[i.kind,i.primitive,i.imageId,"sprite"].join(" "):[i.kind,i.primitive,t,e,i.imageColor,i.imageId,i.fillType,i.fillHorizontalType,i.fillVerticalType,i.fillAmount,i.text,i.fontSize,i.fontColor,i.bgColor,i.enableOutline,i.outlineColor,i.horizontalAlignment,i.verticalAlignment,i.pressed].join(" ")}function dv(i){return i.kind==="image"&&i.primitive==="circle"&&(!i.fillType||i.fillType==="Unused")}function JE(i){let t=W.get().createCanvas(i,i);t.width=t.height=i;let e=t.getContext("2d");return e.fillStyle="#ffffff",e.beginPath(),e.arc(i/2,i/2,i/2,0,Math.PI*2),e.fill(),new U({source:new vt({resource:t,width:i,height:i,resolution:1})})}var ju=class{constructor(t){this.canvas=t,this.app=null,this.nodes=new Map,this.circleTextures=new Map,this.canvasWidth=0,this.canvasHeight=0,this.scratch=new B,this.ready=this.initialize()}async initialize(){let t=new za;await t.init({canvas:this.canvas,width:1,height:1,autoStart:!1,autoDensity:!1,resolution:Math.min(2,window.devicePixelRatio||1),antialias:!0,backgroundAlpha:0,preference:"webgl",powerPreference:"high-performance"}),t.ticker.stop(),t.stage.eventMode="none",t.stage.sortableChildren=!0,this.app=t}resize(t,e){let r=Math.max(1,Math.round(Zt(t,1))),s=Math.max(1,Math.round(Zt(e,1)));r===this.canvasWidth&&s===this.canvasHeight||(this.canvasWidth=r,this.canvasHeight=s,this.app.renderer.resize(r,s))}createNode(t,{group:e=!1}={}){let r=new ut({isRenderGroup:!!e});return r.label=`runtime:${t.id}`,r.eventMode="none",r.sortableChildren=!0,r.__runtimeId=t.id,r.__group=!!e,this.nodes.set(t.id,r),this.app.stage.addChild(r),r}clearVisual(t){t.__visual&&(t.removeChild(t.__visual),t.__visual.destroy({children:!0,context:!0}),t.__visual=null,t.__visualKey="")}circleTexture(t){let e=this.app?.renderer.resolution||2,r=Math.min(4096,Math.max(256,2**Math.ceil(Math.log2(Math.max(1,t*e)))));this.circleTextures||=new Map;let s=this.circleTextures.get(r);return s||(s=JE(r),this.circleTextures.set(r,s)),s}replaceVisual(t,e,r,s){if(this.clearVisual(t),!$E.has(e.kind))return;let n=new ut;if(n.eventMode="none",n.label=`visual:${e.id}`,e.kind==="textbox"||e.kind==="textwindow"){let o=new Se,a=Ln(e.bgColor,16777215);o.rect(-r/2,-s/2,r,s).fill(a),n.addChild(o);let l=Math.max(8,Zt(e.fontSize,12)),c=qE(e),h=new On({text:String(e.text||""),style:new qe({fontFamily:'Inter, "Microsoft YaHei UI", "Microsoft YaHei", sans-serif',fontSize:l,fill:Ln(e.fontColor,4294967295),stroke:e.enableOutline?{color:Ln(e.outlineColor,4278190080).color,width:Math.max(2,l*.12),join:"round"}:void 0,wordWrap:!0,wordWrapWidth:Math.max(4,r-4),breakWords:!0,align:c.x===1?"right":c.x===.5?"center":"left",lineHeight:l*1.2})});h.anchor.set(c.x,c.y),h.x=c.x===0?-r/2+2:c.x===1?r/2-2:0,h.y=c.y===0?-s/2:c.y===1?s/2:0;let u=new Se().rect(-r/2,-s/2,r,s).fill({color:16777215,alpha:1});h.mask=u,n.addChild(u,h)}else if(e.kind==="button"){let o=new Se;o.roundRect(-r/2,-s/2,r,s,6).fill({color:3303631,alpha:1}),o.roundRect(-r/2,-s/2,r,s,6).stroke({color:7381247,alpha:.8,width:1}),e.pressed&&o.roundRect(-r/2,-s/2,r,s,6).fill({color:0,alpha:.28}),n.addChild(o)}else if(dv(e)){let o=new Me({texture:this.circleTexture(Math.min(r,s)),anchor:.5});n.__circle=o,n.addChild(o)}else{let o=new Se,a=Ln(e.imageColor,4294967295);e.primitive==="missing"?(o.rect(-r/2,-s/2,r,s).fill({color:4727336,alpha:.36}),o.rect(-r/2+.5,-s/2+.5,Math.max(0,r-1),Math.max(0,s-1)).stroke({color:16741505,alpha:1,width:1})):e.primitive==="circle"?o.circle(0,0,Math.min(r,s)/2).fill(a):e.primitive==="ring"?o.circle(0,0,Math.max(1,Math.min(r,s)/2-3.5)).stroke({...a,width:7}):e.primitive==="triangle"||e.primitive==="fourstar"||e.primitive==="fivestar"?o.poly(ZE(e,r,s)).fill(a):o.rect(-r/2,-s/2,r,s).fill(a);let l=$0(e,r,s);if(l&&(o.visible=l.width>0&&l.height>0,o.visible)){let c=new Se().rect(l.x,l.y,l.width,l.height).fill({color:16777215,alpha:1});o.mask=c,n.addChild(c)}n.addChild(o)}n.scale.set(e.pressed?.98:1),t.addChildAt(n,0),t.__visual=n}applyMatrix(t,e,r){let s=KE(e);if(!s){let u=Math.max(0,Zt(e.sourceWidth,Zt(e.width))),d=Math.max(0,Zt(e.sourceHeight,Zt(e.height)));t.x=Zt(e.left)+u/2,t.y=this.canvasHeight-Zt(e.bottom)-d/2,t.rotation=-Zt(e.rotationZ)*Math.PI/180,t.scale.set(1);return}let[n,o,a,l,c,h]=s;this.scratch.set(n,-o,-a,l,c,r?-h:this.canvasHeight-h),t.setFromMatrix(this.scratch)}updateNode(t,e,{nested:r=!1}={}){let s=Math.max(0,Zt(e.sourceWidth,Zt(e.width))),n=Math.max(0,Zt(e.sourceHeight,Zt(e.height))),o=QE(e,s,n);t.__visualKey!==o&&(this.replaceVisual(t,e,s,n),t.__visualKey=o),t.__visual&&t.__visual.scale.set(e.pressed?.98:1);let a=t.__visual?.__circle;if(a){let l=Math.min(s,n),c=Ln(e.imageColor,4294967295);a.texture=this.circleTexture(l),a.width=a.height=l,a.tint=c.color,a.alpha=c.alpha,a.visible=l>0}this.applyMatrix(t,e,r)}attachNode(t,e){let r=e.parent,n=(r==null?this.app.stage:this.nodes.get(r))||this.app.stage;t.parent!==n&&n.addChild(t),n.sortableChildren=!0,t.zIndex=-Zt(e.z)}upsertSceneNode(t){if(!t||t.id===void 0||t.id===null)return;let e=t.group===!0,r=this.nodes.get(t.id);r?r.__group!==e&&(e?r.enableRenderGroup?.():r.disableRenderGroup?.(),r.__group=e):r=this.createNode(t,{group:e}),this.updateNode(r,t,{nested:t.parent!=null}),this.attachNode(r,t)}removeNode(t){let e=this.nodes.get(t);if(e){for(let r of[...e.children])r.__runtimeId!=null&&e.removeChild(r);e.parent?.removeChild(e),this.clearVisual(e),e.destroy({children:!1}),this.nodes.delete(t)}}clearNodes(){for(let t of[...this.nodes.keys()])this.removeNode(t)}async applyScene(t,e,r){if(await this.ready,this.resize(e,r),!t||t.format!=="tree-v1"){this.app.render();return}t.reset&&this.clearNodes();for(let n of t.removed||[])this.removeNode(n);let s=t.reset?t.nodes:t.changed;for(let n=0;n<(s||[]).length;n+=1){let o=s[n];!o||o.id===void 0||o.id===null||this.nodes.has(o.id)||this.createNode(o,{group:o.group===!0})}for(let n=0;n<(s||[]).length;n+=1)this.upsertSceneNode(s[n]);this.app.render()}async render(t,e,r){await this.ready,this.resize(e,r);let s=new Set,n=Array.isArray(t)?t:[];for(let o=0;o<n.length;o+=1){let a=n[o];if(!a||a.id===void 0||a.id===null)continue;s.add(a.id);let l=this.nodes.get(a.id)||this.createNode(a);this.updateNode(l,a),l.zIndex=o,l.parent!==this.app.stage&&this.app.stage.addChild(l)}for(let[o]of this.nodes)s.has(o)||this.removeNode(o);this.app.render()}destroy(){this.clearNodes();for(let t of this.circleTextures.values())t.destroy(!0);this.circleTextures.clear(),this.app?.destroy({removeView:!1},{children:!0,texture:!0,textureSource:!0}),this.app=null}};export{cv as PLAY_POLL_INTERVAL_MS,ju as PixiPlayRenderer,uv as createPlaySession};
|
|
925
|
+
`);return new Function("ps","f32v","u32v",s)}var Ja=class{constructor(t){this._size=0,this._generateParticleUpdateCache={};let e=this._size=t.size??1e3,r=t.properties,s=0,n=0;for(let h in r){let u=r[h],d=Wt(u.format);u.dynamic?n+=d.stride:s+=d.stride}this._dynamicStride=n/4,this._staticStride=s/4,this.staticAttributeBuffer=new Ge(e*4*s),this.dynamicAttributeBuffer=new Ge(e*4*n),this.indexBuffer=Xu(e);let o=new Be,a=0,l=0;this._staticBuffer=new Ft({data:new Float32Array(1),label:"static-particle-buffer",shrinkToFit:!1,usage:it.VERTEX|it.COPY_DST}),this._dynamicBuffer=new Ft({data:new Float32Array(1),label:"dynamic-particle-buffer",shrinkToFit:!1,usage:it.VERTEX|it.COPY_DST});for(let h in r){let u=r[h],d=Wt(u.format);u.dynamic?(o.addAttribute(u.attributeName,{buffer:this._dynamicBuffer,stride:this._dynamicStride*4,offset:a*4,format:u.format}),a+=d.size):(o.addAttribute(u.attributeName,{buffer:this._staticBuffer,stride:this._staticStride*4,offset:l*4,format:u.format}),l+=d.size)}o.addIndex(this.indexBuffer);let c=this.getParticleUpdate(r);this._dynamicUpload=c.dynamicUpdate,this._staticUpload=c.staticUpdate,this.geometry=o}getParticleUpdate(t){let e=WE(t);return this._generateParticleUpdateCache[e]?this._generateParticleUpdateCache[e]:(this._generateParticleUpdateCache[e]=this.generateParticleUpdate(t),this._generateParticleUpdateCache[e])}generateParticleUpdate(t){return j0(t)}update(t,e){t.length>this._size&&(e=!0,this._size=Math.max(t.length,this._size*1.5|0),this.staticAttributeBuffer=new Ge(this._size*this._staticStride*4*4),this.dynamicAttributeBuffer=new Ge(this._size*this._dynamicStride*4*4),this.indexBuffer=Xu(this._size),this.geometry.indexBuffer.setDataWithSize(this.indexBuffer,this.indexBuffer.byteLength,!0));let r=this.dynamicAttributeBuffer;if(this._dynamicUpload(t,r.float32View,r.uint32View),this._dynamicBuffer.setDataWithSize(this.dynamicAttributeBuffer.float32View,t.length*this._dynamicStride*4,!0),e){let s=this.staticAttributeBuffer;this._staticUpload(t,s.float32View,s.uint32View),this._staticBuffer.setDataWithSize(s.float32View,t.length*this._staticStride*4,!0)}}destroy(){this._staticBuffer.destroy(),this._dynamicBuffer.destroy(),this.geometry.destroy()}};function WE(i){let t=[];for(let e in i){let r=i[e];t.push(e,r.code,r.dynamic?"d":"s")}return t.join("_")}dt();et();rr();mt();rc();xe();Iu();fo();Za();Gt();H.add(ym,vm);function $0(i,t,e){if(i.fillType!=="Horizontal"&&i.fillType!=="Vertical")return null;let r=Number(i.fillAmount??1),s=Number.isFinite(r)?Math.max(0,Math.min(1,r)):1;if(i.fillType==="Horizontal"){let o=t*s;return{x:i.fillHorizontalType==="Right"?t/2-o:-t/2,y:-e/2,width:o,height:e}}let n=e*s;return{x:-t/2,y:i.fillVerticalType==="Top"?-e/2:e/2-n,width:t,height:n}}Nh();jh();$h();Mh();ca();kr();sr();var K0={aVertex:(i,t,e,r,s)=>{let n=0,o=0,a=0,l=0;for(let c=0;c<i.length;++c){let h=i[c],u=h.texture,d=h.scaleX,f=h.scaleY,m=h.anchorX,g=h.anchorY,y=u.trim,x=u.orig;y?(o=y.x-m*x.width,n=o+y.width,l=y.y-g*x.height,a=l+y.height):(n=x.width*(1-m),o=x.width*-m,a=x.height*(1-g),l=x.height*-g),t[r]=o*d,t[r+1]=l*f,t[r+s]=n*d,t[r+s+1]=l*f,t[r+s*2]=n*d,t[r+s*2+1]=a*f,t[r+s*3]=o*d,t[r+s*3+1]=a*f,r+=s*4}},aPosition:(i,t,e,r,s)=>{for(let n=0;n<i.length;++n){let o=i[n],a=o.x,l=o.y;t[r]=a,t[r+1]=l,t[r+s]=a,t[r+s+1]=l,t[r+s*2]=a,t[r+s*2+1]=l,t[r+s*3]=a,t[r+s*3+1]=l,r+=s*4}},aRotation:(i,t,e,r,s)=>{for(let n=0;n<i.length;++n){let o=i[n].rotation;t[r]=o,t[r+s]=o,t[r+s*2]=o,t[r+s*3]=o,r+=s*4}},aUV:(i,t,e,r,s)=>{for(let n=0;n<i.length;++n){let o=i[n].texture.uvs;t[r]=o.x0,t[r+1]=o.y0,t[r+s]=o.x1,t[r+s+1]=o.y1,t[r+s*2]=o.x2,t[r+s*2+1]=o.y2,t[r+s*3]=o.x3,t[r+s*3+1]=o.y3,r+=s*4}},aColor:(i,t,e,r,s)=>{for(let n=0;n<i.length;++n){let o=i[n].color;e[r]=o,e[r+s]=o,e[r+s*2]=o,e[r+s*3]=o,r+=s*4}}};function Z0(i){let t=Object.values(i),e=t.filter(s=>s.dynamic),r=t.filter(s=>!s.dynamic);return{dynamicUpdate:q0(e),staticUpdate:q0(r)}}function q0(i){let t=0,e=[];for(let r=0;r<i.length;r++){let s=i[r],n=Wt(s.format).stride/4;t+=n,e.push({stride:n,updateFunction:s.updateFunction||K0[s.attributeName]})}return(r,s,n)=>{let o=0;for(let a=0;a<e.length;a++){let l=e[a];l.updateFunction(r,s,n,o,t),o+=l.stride}}}Js();ce();Ot();xr();Hh();function Q0(){return VE}function VE(i,t,e){let r=i.gl,s=i.shader,n=s._getProgramData(t.glProgram);for(let o in t.groups){let a=t.groups[o];for(let l in a.resources){let c=a.resources[l];if(c instanceof St)c.ubo?s.bindUniformBlock(c,t._uniformBindMap[o][l],e.blockIndex++):s.updateUniformGroup(c);else if(c instanceof ke)s.bindUniformBlock(c,t._uniformBindMap[o][l],e.blockIndex++);else if(c instanceof J||c instanceof Gi){i.texture.bind(c,e.textureCount);let h=t._uniformBindMap[o][l],u=n.uniformData[h];u&&(u.value!==e.textureCount&&r.uniform1i(u.location,e.textureCount),e.textureCount++)}else c instanceof Qt}}}va();ha();Qs();var J0=[(i,t,e,r,s)=>{let n=r[i].toArray(!0);t[e]=n[0],t[e+1]=n[1],t[e+2]=n[2],t[e+4]=n[3],t[e+5]=n[4],t[e+6]=n[5],t[e+8]=n[6],t[e+9]=n[7],t[e+10]=n[8]},(i,t,e,r,s)=>{s=r[i],t[e]=s.x,t[e+1]=s.y,t[e+2]=s.width,t[e+3]=s.height},(i,t,e,r,s)=>{s=r[i],t[e]=s.x,t[e+1]=s.y},(i,t,e,r,s)=>{s=r[i],t[e]=s.red,t[e+1]=s.green,t[e+2]=s.blue,t[e+3]=s.alpha},(i,t,e,r,s)=>{s=r[i],t[e]=s.red,t[e+1]=s.green,t[e+2]=s.blue}],tv={f32:(i,t,e,r,s)=>{t[e]=s},i32:(i,t,e,r,s)=>{t[e]=s},"vec2<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1]},"vec3<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2]},"vec4<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3]},"mat2x2<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3]},"mat3x3<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+4]=s[3],t[e+5]=s[4],t[e+6]=s[5],t[e+8]=s[6],t[e+9]=s[7],t[e+10]=s[8]},"mat4x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<16;n++)t[e+n]=s[n]},"mat3x2<f32>":(i,t,e,r,s)=>{for(let n=0;n<6;n++)t[e+(n/3|0)*4+n%3]=s[n]},"mat4x2<f32>":(i,t,e,r,s)=>{for(let n=0;n<8;n++)t[e+(n/4|0)*4+n%4]=s[n]},"mat2x3<f32>":(i,t,e,r,s)=>{for(let n=0;n<6;n++)t[e+(n/2|0)*4+n%2]=s[n]},"mat4x3<f32>":(i,t,e,r,s)=>{for(let n=0;n<12;n++)t[e+(n/4|0)*4+n%4]=s[n]},"mat2x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<8;n++)t[e+(n/2|0)*4+n%2]=s[n]},"mat3x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<12;n++)t[e+(n/3|0)*4+n%3]=s[n]}},ev={f32:(i,t,e,r,s)=>{t[e]=s},i32:(i,t,e,r,s)=>{t[e]=s},"vec2<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1]},"vec3<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2]},"vec4<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+3]=s[3]},"mat2x2<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+4]=s[2],t[e+5]=s[3]},"mat3x3<f32>":(i,t,e,r,s)=>{t[e]=s[0],t[e+1]=s[1],t[e+2]=s[2],t[e+4]=s[3],t[e+5]=s[4],t[e+6]=s[5],t[e+8]=s[6],t[e+9]=s[7],t[e+10]=s[8]},"mat4x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<16;n++)t[e+n]=s[n]},"mat3x2<f32>":(i,t,e,r,s)=>{for(let n=0;n<6;n++)t[e+(n/3|0)*4+n%3]=s[n]},"mat4x2<f32>":(i,t,e,r,s)=>{for(let n=0;n<8;n++)t[e+(n/4|0)*4+n%4]=s[n]},"mat2x3<f32>":(i,t,e,r,s)=>{for(let n=0;n<6;n++)t[e+(n/2|0)*4+n%2]=s[n]},"mat4x3<f32>":(i,t,e,r,s)=>{for(let n=0;n<12;n++)t[e+(n/4|0)*4+n%4]=s[n]},"mat2x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<8;n++)t[e+(n/2|0)*4+n%2]=s[n]},"mat3x4<f32>":(i,t,e,r,s)=>{for(let n=0;n<12;n++)t[e+(n/3|0)*4+n%3]=s[n]}};function rv(i){return sv(i,ev,t=>{let e=Math.max(_n[t.data.type]/16,1),r=t.data.value.length/t.data.size,s=(4-r%4)%4;return(n,o,a,l,c)=>{let h=0;for(let u=0;u<t.data.size*e;u++){for(let d=0;d<r;d++)o[a++]=c[h++];a+=s}}})}function iv(i){return sv(i,tv,t=>{let{size:e,align:r}=Nr[t.data.type],s=(e-r)/4;return(n,o,a,l,c)=>{let h=0;for(let u=0;u<t.data.size*(e/4);u++){for(let d=0;d<e/4;d++)o[a++]=c[h++];a+=s}}})}function sv(i,t,e){let r={};for(let s in i){let n=i[s],o=n.data,a=!1;r[o.name]={offset:n.offset/4,func:null};for(let l=0;l<Jt.length;l++){let c=Jt[l];if(o.type===c.type&&c.test(o)){r[o.name].func=J0[l],a=!0;break}}a||(o.size===1?r[o.name].func=t[o.type]:r[o.name].func=e(n))}return(s,n,o)=>{for(let a in r)r[a].func(a,n,o+r[a].offset,s,s[a])}}Qs();var nv={f32(i,t,e,r,s,n,o){e!==r&&(t.value=r,o.uniform1f(s[i].location,r))},"vec2<f32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1])&&(e[0]=r[0],e[1]=r[1],o.uniform2f(s[i].location,r[0],r[1]))},"vec3<f32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],o.uniform3f(s[i].location,r[0],r[1],r[2]))},"vec4<f32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],o.uniform4f(s[i].location,r[0],r[1],r[2],r[3]))},i32(i,t,e,r,s,n,o){e!==r&&(t.value=r,o.uniform1i(s[i].location,r))},"vec2<i32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1])&&(e[0]=r[0],e[1]=r[1],o.uniform2i(s[i].location,r[0],r[1]))},"vec3<i32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],o.uniform3i(s[i].location,r[0],r[1],r[2]))},"vec4<i32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],o.uniform4i(s[i].location,r[0],r[1],r[2],r[3]))},u32(i,t,e,r,s,n,o){e!==r&&(t.value=r,o.uniform1ui(s[i].location,r))},"vec2<u32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1])&&(e[0]=r[0],e[1]=r[1],o.uniform2ui(s[i].location,r[0],r[1]))},"vec3<u32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],o.uniform3ui(s[i].location,r[0],r[1],r[2]))},"vec4<u32>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],o.uniform4ui(s[i].location,r[0],r[1],r[2],r[3]))},bool(i,t,e,r,s,n,o){e!==r&&(t.value=r,o.uniform1i(s[i].location,r))},"vec2<bool>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1])&&(e[0]=r[0],e[1]=r[1],o.uniform2i(s[i].location,r[0],r[1]))},"vec3<bool>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],o.uniform3i(s[i].location,r[0],r[1],r[2]))},"vec4<bool>"(i,t,e,r,s,n,o){(e[0]!==r[0]||e[1]!==r[1]||e[2]!==r[2]||e[3]!==r[3])&&(e[0]=r[0],e[1]=r[1],e[2]=r[2],e[3]=r[3],o.uniform4i(s[i].location,r[0],r[1],r[2],r[3]))},"mat2x2<f32>"(i,t,e,r,s,n,o){o.uniformMatrix2fv(s[i].location,!1,r)},"mat3x3<f32>"(i,t,e,r,s,n,o){o.uniformMatrix3fv(s[i].location,!1,r)},"mat4x4<f32>"(i,t,e,r,s,n,o){o.uniformMatrix4fv(s[i].location,!1,r)}},ov={f32(i,t,e,r,s,n,o){o.uniform1fv(s[i].location,r)},"vec2<f32>"(i,t,e,r,s,n,o){o.uniform2fv(s[i].location,r)},"vec3<f32>"(i,t,e,r,s,n,o){o.uniform3fv(s[i].location,r)},"vec4<f32>"(i,t,e,r,s,n,o){o.uniform4fv(s[i].location,r)},"mat2x2<f32>"(i,t,e,r,s,n,o){o.uniformMatrix2fv(s[i].location,!1,r)},"mat3x3<f32>"(i,t,e,r,s,n,o){o.uniformMatrix3fv(s[i].location,!1,r)},"mat4x4<f32>"(i,t,e,r,s,n,o){o.uniformMatrix4fv(s[i].location,!1,r)},i32(i,t,e,r,s,n,o){o.uniform1iv(s[i].location,r)},"vec2<i32>"(i,t,e,r,s,n,o){o.uniform2iv(s[i].location,r)},"vec3<i32>"(i,t,e,r,s,n,o){o.uniform3iv(s[i].location,r)},"vec4<i32>"(i,t,e,r,s,n,o){o.uniform4iv(s[i].location,r)},u32(i,t,e,r,s,n,o){o.uniform1iv(s[i].location,r)},"vec2<u32>"(i,t,e,r,s,n,o){o.uniform2iv(s[i].location,r)},"vec3<u32>"(i,t,e,r,s,n,o){o.uniform3iv(s[i].location,r)},"vec4<u32>"(i,t,e,r,s,n,o){o.uniform4iv(s[i].location,r)},bool(i,t,e,r,s,n,o){o.uniform1iv(s[i].location,r)},"vec2<bool>"(i,t,e,r,s,n,o){o.uniform2iv(s[i].location,r)},"vec3<bool>"(i,t,e,r,s,n,o){o.uniform3iv(s[i].location,r)},"vec4<bool>"(i,t,e,r,s,n,o){o.uniform4iv(s[i].location,r)}},av=[(i,t,e,r,s,n,o)=>{o.uniformMatrix3fv(s[i].location,!1,n[i].toArray(!0))},(i,t,e,r,s,n,o)=>{e=s[i].value,r=n[i],(e[0]!==r.x||e[1]!==r.y||e[2]!==r.width||e[3]!==r.height)&&(e[0]=r.x,e[1]=r.y,e[2]=r.width,e[3]=r.height,o.uniform4f(s[i].location,r.x,r.y,r.width,r.height))},(i,t,e,r,s,n,o)=>{e=s[i].value,r=n[i],(e[0]!==r.x||e[1]!==r.y)&&(e[0]=r.x,e[1]=r.y,o.uniform2f(s[i].location,r.x,r.y))},(i,t,e,r,s,n,o)=>{e=s[i].value,r=n[i],(e[0]!==r.red||e[1]!==r.green||e[2]!==r.blue||e[3]!==r.alpha)&&(e[0]=r.red,e[1]=r.green,e[2]=r.blue,e[3]=r.alpha,o.uniform4f(s[i].location,r.red,r.green,r.blue,r.alpha))},(i,t,e,r,s,n,o)=>{e=s[i].value,r=n[i],(e[0]!==r.red||e[1]!==r.green||e[2]!==r.blue)&&(e[0]=r.red,e[1]=r.green,e[2]=r.blue,o.uniform3f(s[i].location,r.red,r.green,r.blue))}];function lv(i,t){let e={};for(let r in i.uniformStructures){if(!t[r])continue;let s=i.uniformStructures[r],n=!1;for(let o=0;o<Jt.length;o++){let a=Jt[o];if(s.type===a.type&&a.test(s)){e[r]=av[o],n=!0;break}}if(!n){let o=s.size===1?nv:ov;e[r]=o[s.type]}}return(r,s,n)=>{let o=n.gl;for(let a in e){let l=s[a],c=r[a],h=r[a].value;e[a](a,c,h,l,r,s,o)}}}function zE(){Object.assign(ue.prototype,{_unsafeEvalCheck(){}}),Object.assign(cr.prototype,{_systemCheck(){}}),Object.assign(zr.prototype,{_generateUniformsSync:lv}),Object.assign(Wr.prototype,{_generateUboSync:rv}),Object.assign(Hr.prototype,{_generateUboSync:iv}),Object.assign(Vr.prototype,{_generateShaderSync:Q0}),Object.assign(Ja.prototype,{generateParticleUpdate:Z0})}zE();var cv=33;function Yu(i,t){let e=i.code&&String(i.code).startsWith("Digit")?String(i.code).slice(5):"";return e&&Number(e)>=1&&Number(e)<=9?`KeyboardCraftspersonKey${e}${t}`:""}function hv(i,t,e,r){return{x:(i.clientX-t.left)*e/t.width,y:(t.bottom-i.clientY)*r/t.height}}function uv({renderer:i,api:t,onSnapshot:e,onStatus:r,onError:s,isActive:n}={}){let o=null,a=!1,l=!1,c=null,h=null,u=0,d=null,f=null,m=[];function g(F){s&&s(F)}async function y(F){o=F,a=F?.running!==!1,F?.scene&&F.scene.format==="tree-v1"?(F.scene.reset&&(u=0),await i.applyScene(F.scene,F.canvasWidth,F.canvasHeight),u=F.scene.revision||u):Array.isArray(F?.paint)&&await i.render(F.paint,F.canvasWidth,F.canvasHeight),e&&await e(F)}async function x(){if(!(!a||l)&&!(n&&!n())){l=!0;try{await y(await t("get",{view:!0,sceneRev:u,compact:!0}))}catch(F){a=!1,v(),g(F)}finally{l=!1}}}function b(){c||(c=setInterval(()=>{x()},33))}function v(){c&&clearInterval(c),c=null,h&&clearTimeout(h),h=null}function T(F=30){h||(h=setTimeout(()=>{h=null,x()},F))}function S(){a=!1,u=0,v()}async function E(F,A){if(n&&!n())return null;try{let k=await t(F,{light:!0,...A||{}});return k&&typeof k=="object"&&k.frame!==void 0&&r&&r(k),T(30),k}catch(k){return g(k),null}}async function w(F={}){u=0;let A=await t("start",{view:!0,compact:!0,...F});return await y({...A,running:!0}),a=!0,v(),b(),A}async function I(){u=0,v();let F=await t("get",{view:!0,compact:!0,sceneRev:0});return await y(F),a&&b(),F}async function G(F={}){u=0,v();let A=await t("device",{view:!0,compact:!0,...F});return await y({...A,running:!0}),a=!0,b(),A}async function M(F={}){u=0;let A=await t("view",{view:!0,compact:!0,...F});return await y({...A,running:!0}),A}async function C(){return S(),t("stop")}function R(F,A){return hv(F,A.getBoundingClientRect(),o.canvasWidth,o.canvasHeight)}function L(F,{keysOn:A}={}){let k=A||F,X=z=>{!o||!a||n&&!n()||(F.setPointerCapture?.(z.pointerId),E("pointer",{type:"down",...R(z,F)}))},D=z=>{!o||!a||n&&!n()||E("pointer",{type:"up",...R(z,F)})},Z=z=>{!o||!a||n&&!n()||(f=R(z,F),!d&&(d=setTimeout(()=>{d=null,f&&E("pointer",{type:"move",...f})},60)))},ht=()=>{o&&a&&(!n||n())&&E("pointer",{type:"move",x:-1,y:-1})},xt=z=>{if(!o||!a||n&&!n())return;let Dt=Yu(z,"Down");Dt&&(z.preventDefault(),E("key",{key:Dt}))},st=z=>{if(!o||!a||n&&!n())return;let Dt=Yu(z,"Up");Dt&&(z.preventDefault(),E("key",{key:Dt}))};F.addEventListener("pointerdown",X),F.addEventListener("pointerup",D),F.addEventListener("pointermove",Z),F.addEventListener("pointerleave",ht),k.addEventListener("keydown",xt),k.addEventListener("keyup",st);let at=()=>{F.removeEventListener("pointerdown",X),F.removeEventListener("pointerup",D),F.removeEventListener("pointermove",Z),F.removeEventListener("pointerleave",ht),k.removeEventListener("keydown",xt),k.removeEventListener("keyup",st),d&&clearTimeout(d),d=null};return m.push(at),at}function V(){for(S();m.length;)m.pop()();i?.destroy?.()}return{get snapshot(){return o},get running(){return a},get sceneRev(){return u},applyScene:y,poll:x,pollSoon:T,startPolling:b,stopPolling:v,reset:S,act:E,start:w,attach:I,device:G,view:M,stop:C,bindInput:L,destroy:V}}var XE=[0,-.5,.5,.5,-.5,.5],YE=[0,-.5,.12,-.12,.5,0,.12,.12,0,.5,-.12,.12,-.5,0,-.12,-.12],jE=[0,-.5,.11,-.15,.48,-.15,.18,.07,.29,.41,0,.2,-.29,.41,-.18,.07,-.48,-.15,-.11,-.15],$E=new Set(["image","textbox","textwindow","button"]);function Ln(i,t=4294967295){let e=Number(i??t)>>>0;return{color:e&16777215,alpha:(e>>>24&255)/255}}function Zt(i,t=0){let e=Number(i);return Number.isFinite(e)?e:t}function KE(i){let t=i?.matrix;if(!t||typeof t!="object")return null;let e=[t.a,t.b,t.c,t.d,t.tx,t.ty].map(Number);return e.every(Number.isFinite)?e:null}function qE(i){let t=i.horizontalAlignment==="Right"?1:i.horizontalAlignment==="Middle"?.5:0,e=i.verticalAlignment==="Bottom"?1:i.verticalAlignment==="Middle"?.5:0;return{x:t,y:e}}function ZE(i,t,e){let r=i.primitive==="triangle"?XE:i.primitive==="fourstar"?YE:jE,s=[];for(let n=0;n<r.length;n+=2)s.push(r[n]*t,r[n+1]*e);return s}function QE(i,t,e){return dv(i)?[i.kind,i.primitive,i.imageId,"sprite"].join(" "):[i.kind,i.primitive,t,e,i.imageColor,i.imageId,i.fillType,i.fillHorizontalType,i.fillVerticalType,i.fillAmount,i.text,i.fontSize,i.fontColor,i.bgColor,i.enableOutline,i.outlineColor,i.horizontalAlignment,i.verticalAlignment,i.pressed].join(" ")}function dv(i){return i.kind==="image"&&i.primitive==="circle"&&(!i.fillType||i.fillType==="Unused")}function JE(i){let t=W.get().createCanvas(i,i);t.width=t.height=i;let e=t.getContext("2d");return e.fillStyle="#ffffff",e.beginPath(),e.arc(i/2,i/2,i/2,0,Math.PI*2),e.fill(),new U({source:new vt({resource:t,width:i,height:i,resolution:1})})}var ju=class{constructor(t){this.canvas=t,this.app=null,this.nodes=new Map,this.circleTextures=new Map,this.canvasWidth=0,this.canvasHeight=0,this.scratch=new B,this.ready=this.initialize()}async initialize(){let t=new za;await t.init({canvas:this.canvas,width:1,height:1,autoStart:!1,autoDensity:!1,resolution:Math.min(2,window.devicePixelRatio||1),antialias:!0,backgroundAlpha:0,preference:"webgl",powerPreference:"high-performance"}),t.ticker.stop(),t.stage.eventMode="none",t.stage.sortableChildren=!0,this.app=t}resize(t,e){let r=Math.max(1,Math.round(Zt(t,1))),s=Math.max(1,Math.round(Zt(e,1)));r===this.canvasWidth&&s===this.canvasHeight||(this.canvasWidth=r,this.canvasHeight=s,this.app.renderer.resize(r,s))}createNode(t,{group:e=!1}={}){let r=new ut({isRenderGroup:!!e});return r.label=`runtime:${t.id}`,r.eventMode="none",r.sortableChildren=!0,r.__runtimeId=t.id,r.__group=!!e,this.nodes.set(t.id,r),this.app.stage.addChild(r),r}clearVisual(t){t.__visual&&(t.removeChild(t.__visual),t.__visual.destroy({children:!0,context:!0}),t.__visual=null,t.__visualKey="")}circleTexture(t){let e=this.app?.renderer.resolution||2,r=Math.min(4096,Math.max(256,2**Math.ceil(Math.log2(Math.max(1,t*e)))));this.circleTextures||=new Map;let s=this.circleTextures.get(r);return s||(s=JE(r),this.circleTextures.set(r,s)),s}replaceVisual(t,e,r,s){if(this.clearVisual(t),!$E.has(e.kind))return;let n=new ut;if(n.eventMode="none",n.label=`visual:${e.id}`,e.kind==="textbox"||e.kind==="textwindow"){let o=new Se,a=Ln(e.bgColor,16777215);o.rect(-r/2,-s/2,r,s).fill(a),n.addChild(o);let l=Math.max(8,Zt(e.fontSize,12)),c=qE(e),h=new On({text:String(e.text||""),style:new qe({fontFamily:'Inter, "Microsoft YaHei UI", "Microsoft YaHei", sans-serif',fontSize:l,fill:Ln(e.fontColor,4294967295),stroke:e.enableOutline?{color:Ln(e.outlineColor,4278190080).color,width:Math.max(2,l*.12),join:"round"}:void 0,wordWrap:!0,wordWrapWidth:Math.max(4,r-4),breakWords:!0,align:c.x===1?"right":c.x===.5?"center":"left",lineHeight:l*1.2})});h.anchor.set(c.x,c.y),h.x=c.x===0?-r/2+2:c.x===1?r/2-2:0,h.y=c.y===0?-s/2:c.y===1?s/2:0;let u=new Se().rect(-r/2,-s/2,r,s).fill({color:16777215,alpha:1});h.mask=u,n.addChild(u,h)}else if(e.kind==="button"){let o=new Se;o.roundRect(-r/2,-s/2,r,s,6).fill({color:3303631,alpha:1}),o.roundRect(-r/2,-s/2,r,s,6).stroke({color:7381247,alpha:.8,width:1}),e.pressed&&o.roundRect(-r/2,-s/2,r,s,6).fill({color:0,alpha:.28}),n.addChild(o)}else if(dv(e)){let o=new Me({texture:this.circleTexture(Math.max(r,s)),anchor:.5});n.__circle=o,n.addChild(o)}else{let o=new Se,a=Ln(e.imageColor,4294967295);e.primitive==="missing"?(o.rect(-r/2,-s/2,r,s).fill({color:4727336,alpha:.36}),o.rect(-r/2+.5,-s/2+.5,Math.max(0,r-1),Math.max(0,s-1)).stroke({color:16741505,alpha:1,width:1})):e.primitive==="circle"?o.ellipse(0,0,r/2,s/2).fill(a):e.primitive==="ring"?o.ellipse(0,0,Math.max(1,r/2-3.5),Math.max(1,s/2-3.5)).stroke({...a,width:7}):e.primitive==="triangle"||e.primitive==="fourstar"||e.primitive==="fivestar"?o.poly(ZE(e,r,s)).fill(a):o.rect(-r/2,-s/2,r,s).fill(a);let l=$0(e,r,s);if(l&&(o.visible=l.width>0&&l.height>0,o.visible)){let c=new Se().rect(l.x,l.y,l.width,l.height).fill({color:16777215,alpha:1});o.mask=c,n.addChild(c)}n.addChild(o)}n.scale.set(e.pressed?.98:1),t.addChildAt(n,0),t.__visual=n}applyMatrix(t,e,r){let s=KE(e);if(!s){let u=Math.max(0,Zt(e.sourceWidth,Zt(e.width))),d=Math.max(0,Zt(e.sourceHeight,Zt(e.height)));t.x=Zt(e.left)+u/2,t.y=this.canvasHeight-Zt(e.bottom)-d/2,t.rotation=-Zt(e.rotationZ)*Math.PI/180,t.scale.set(1);return}let[n,o,a,l,c,h]=s;this.scratch.set(n,-o,-a,l,c,r?-h:this.canvasHeight-h),t.setFromMatrix(this.scratch)}updateNode(t,e,{nested:r=!1}={}){let s=Math.max(0,Zt(e.sourceWidth,Zt(e.width))),n=Math.max(0,Zt(e.sourceHeight,Zt(e.height))),o=QE(e,s,n);t.__visualKey!==o&&(this.replaceVisual(t,e,s,n),t.__visualKey=o),t.__visual&&t.__visual.scale.set(e.pressed?.98:1);let a=t.__visual?.__circle;if(a){let l=Math.max(s,n),c=Ln(e.imageColor,4294967295);a.texture=this.circleTexture(l),a.width=s,a.height=n,a.tint=c.color,a.alpha=c.alpha,a.visible=s>0&&n>0}this.applyMatrix(t,e,r)}attachNode(t,e){let r=e.parent,n=(r==null?this.app.stage:this.nodes.get(r))||this.app.stage;t.parent!==n&&n.addChild(t),n.sortableChildren=!0,t.zIndex=-Zt(e.z)}upsertSceneNode(t){if(!t||t.id===void 0||t.id===null)return;let e=t.group===!0,r=this.nodes.get(t.id);r?r.__group!==e&&(e?r.enableRenderGroup?.():r.disableRenderGroup?.(),r.__group=e):r=this.createNode(t,{group:e}),this.updateNode(r,t,{nested:t.parent!=null}),this.attachNode(r,t)}removeNode(t){let e=this.nodes.get(t);if(e){for(let r of[...e.children])r.__runtimeId!=null&&e.removeChild(r);e.parent?.removeChild(e),this.clearVisual(e),e.destroy({children:!1}),this.nodes.delete(t)}}clearNodes(){for(let t of[...this.nodes.keys()])this.removeNode(t)}async applyScene(t,e,r){if(await this.ready,this.resize(e,r),!t||t.format!=="tree-v1"){this.app.render();return}t.reset&&this.clearNodes();for(let n of t.removed||[])this.removeNode(n);let s=t.reset?t.nodes:t.changed;for(let n=0;n<(s||[]).length;n+=1){let o=s[n];!o||o.id===void 0||o.id===null||this.nodes.has(o.id)||this.createNode(o,{group:o.group===!0})}for(let n=0;n<(s||[]).length;n+=1)this.upsertSceneNode(s[n]);this.app.render()}async render(t,e,r){await this.ready,this.resize(e,r);let s=new Set,n=Array.isArray(t)?t:[];for(let o=0;o<n.length;o+=1){let a=n[o];if(!a||a.id===void 0||a.id===null)continue;s.add(a.id);let l=this.nodes.get(a.id)||this.createNode(a);this.updateNode(l,a),l.zIndex=o,l.parent!==this.app.stage&&this.app.stage.addChild(l)}for(let[o]of this.nodes)s.has(o)||this.removeNode(o);this.app.render()}destroy(){this.clearNodes();for(let t of this.circleTextures.values())t.destroy(!0);this.circleTextures.clear(),this.app?.destroy({removeView:!1},{children:!0,texture:!0,textureSource:!0}),this.app=null}};export{cv as PLAY_POLL_INTERVAL_MS,ju as PixiPlayRenderer,uv as createPlaySession};
|
|
926
926
|
/*! Bundled license information:
|
|
927
927
|
|
|
928
928
|
tiny-lru/dist/tiny-lru.js:
|