@galacean/cli 2.0.0-alpha.27 → 2.0.0-alpha.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (96) hide show
  1. package/dist/cli.bundle.cjs +51489 -14885
  2. package/dist/preview-client/_static/{Accordion-4afac60c.js → Accordion-6f002a96.js} +1 -1
  3. package/dist/preview-client/_static/{AmbientLightAsset-3825f3bf.js → AmbientLightAsset-57a59fc2.js} +2 -2
  4. package/dist/preview-client/_static/{AnimationClipAsset-660ecb36.js → AnimationClipAsset-0a1f63eb.js} +1 -1
  5. package/dist/preview-client/_static/{AnimatorControllerAsset-dcf11a9d.js → AnimatorControllerAsset-9192e596.js} +1 -1
  6. package/dist/preview-client/_static/{AnimatorStore-aa58d85c.js → AnimatorStore-484b10cf.js} +1 -1
  7. package/dist/preview-client/_static/{AssetViewer-8338dfe1.js → AssetViewer-9f395efb.js} +1 -1
  8. package/dist/preview-client/_static/{AudioAsset-6e607154.js → AudioAsset-0ea4ba7b.js} +1 -1
  9. package/dist/preview-client/_static/{AudioComponent-b70cc31e.js → AudioComponent-9bf5944c.js} +1 -1
  10. package/dist/preview-client/_static/{Callout-155c30df.js → Callout-45631a14.js} +1 -1
  11. package/dist/preview-client/_static/{CameraComponent-76bc9102.js → CameraComponent-039457d1.js} +1 -1
  12. package/dist/preview-client/_static/{Component-398551a0.js → Component-c3c0c167.js} +1 -1
  13. package/dist/preview-client/_static/{DirectLight-50653e81.js → DirectLight-7b1f4b9f.js} +1 -1
  14. package/dist/preview-client/_static/{FontAsset-dc385d41.js → FontAsset-10273d05.js} +2 -2
  15. package/dist/preview-client/_static/{FormItemArray-9ca61884.js → FormItemArray-9d4196d8.js} +2 -2
  16. package/dist/preview-client/_static/{GlTFAsset-d2ee4f95.js → GlTFAsset-917bf1ee.js} +5 -5
  17. package/dist/preview-client/_static/{IconPlus-b3ed4c04.js → IconPlus-2bfc60da.js} +1 -1
  18. package/dist/preview-client/_static/{IconPointFilled-3ba6d082.js → IconPointFilled-192e99c9.js} +1 -1
  19. package/dist/preview-client/_static/{LightBaseComponent-4cfc9f48.js → LightBaseComponent-948d3192.js} +1 -1
  20. package/dist/preview-client/_static/{LottieAnimationComponent-aeb555ea.js → LottieAnimationComponent-da226765.js} +1 -1
  21. package/dist/preview-client/_static/{MarkdownAsset-02477e7c.js → MarkdownAsset-602f93bf.js} +1 -1
  22. package/dist/preview-client/_static/MaterialAsset-aa93db51.js +1 -0
  23. package/dist/preview-client/_static/{MaterialInspector-3fb471d9.js → MaterialInspector-45e208c7.js} +1 -1
  24. package/dist/preview-client/_static/Menu-beacc39d.js +17 -0
  25. package/dist/preview-client/_static/MeshAsset-585f4b18.js +1 -0
  26. package/dist/preview-client/_static/{MeshRendererBaseComponent-cd8b743b.js → MeshRendererBaseComponent-0bc9f5b3.js} +1 -1
  27. package/dist/preview-client/_static/{MeshRendererComponent-17a7fc72.js → MeshRendererComponent-84208d23.js} +1 -1
  28. package/dist/preview-client/_static/{MeshThumbnail-8c20ee92.js → MeshThumbnail-9bbe01dc.js} +1 -1
  29. package/dist/preview-client/_static/ParticleRendererComponent-f3ac8d1b.js +26 -0
  30. package/dist/preview-client/_static/{PhysicsMaterialAsset-e0491877.js → PhysicsMaterialAsset-2dd013f8.js} +1 -1
  31. package/dist/preview-client/_static/{PhysicsStore-ab32886e.js → PhysicsStore-fcb01282.js} +1 -1
  32. package/dist/preview-client/_static/{PointLight-97975350.js → PointLight-d9ace100.js} +1 -1
  33. package/dist/preview-client/_static/{PostProcessComponent-9590ec29.js → PostProcessComponent-2b5255d9.js} +3 -3
  34. package/dist/preview-client/_static/PrefabAsset-8c923465.js +1 -0
  35. package/dist/preview-client/_static/{PrimitiveMesh-0492d482.js → PrimitiveMesh-fde624a6.js} +1 -1
  36. package/dist/preview-client/_static/{ReferencedMaterial-49a7cbcc.js → ReferencedMaterial-890492a2.js} +1 -1
  37. package/dist/preview-client/_static/{RenderTargetAsset-dc1f9494.js → RenderTargetAsset-bf38a725.js} +1 -1
  38. package/dist/preview-client/_static/SceneAsset-7a9dbdd8.js +1 -0
  39. package/dist/preview-client/_static/{ShaderAsset-f4eead79.js → ShaderAsset-2f2c1e95.js} +1 -1
  40. package/dist/preview-client/_static/{ShaderChunkAsset-4bea2733.js → ShaderChunkAsset-a3ff3959.js} +2 -2
  41. package/dist/preview-client/_static/{ShaderUIScriptAsset-3c731f3b.js → ShaderUIScriptAsset-d3a2d680.js} +2 -2
  42. package/dist/preview-client/_static/{SkinnedMeshRendererComponent-e0f9b133.js → SkinnedMeshRendererComponent-96740600.js} +1 -1
  43. package/dist/preview-client/_static/{SpineAnimationComponent-1e1655fd.js → SpineAnimationComponent-3d4eec48.js} +1 -1
  44. package/dist/preview-client/_static/{SpineSkeletonDataAsset-afb4afae.js → SpineSkeletonDataAsset-a8598103.js} +1 -1
  45. package/dist/preview-client/_static/{SpotLight-69f361c9.js → SpotLight-680a6e17.js} +1 -1
  46. package/dist/preview-client/_static/{SpriteBaseComponent-2c2454ea.js → SpriteBaseComponent-96a500d7.js} +1 -1
  47. package/dist/preview-client/_static/{SpriteMaskComponent-a7ebcc50.js → SpriteMaskComponent-58c35ea2.js} +1 -1
  48. package/dist/preview-client/_static/{SpriteRendererComponent-f7604c68.js → SpriteRendererComponent-5c89f7dd.js} +1 -1
  49. package/dist/preview-client/_static/{TextBaseComponent-cd7ad9f7.js → TextBaseComponent-248ea222.js} +3 -3
  50. package/dist/preview-client/_static/{TextRendererComponent-a5357d52.js → TextRendererComponent-78458825.js} +1 -1
  51. package/dist/preview-client/_static/{TextureAsset-ff089b5a.js → TextureAsset-bf69040b.js} +4 -4
  52. package/dist/preview-client/_static/Tooltip-0268ffac.js +1 -0
  53. package/dist/preview-client/_static/{TrailRendererComponent-cdefa368.js → TrailRendererComponent-838e0118.js} +1 -1
  54. package/dist/preview-client/_static/{TransformBaseComponent-d26ff236.js → TransformBaseComponent-c92aa259.js} +1 -1
  55. package/dist/preview-client/_static/{TransformComponent-4ec4b7b5.js → TransformComponent-d28b4035.js} +1 -1
  56. package/dist/preview-client/_static/{XRReferenceImageAsset-ff82ab30.js → XRReferenceImageAsset-16071f5c.js} +1 -1
  57. package/dist/preview-client/_static/{audio-0a013eb6.js → audio-1d573775.js} +1 -1
  58. package/dist/preview-client/_static/{createOnModelChange-89f572a6.js → createOnModelChange-38471bb6.js} +1 -1
  59. package/dist/preview-client/_static/{createReactComponent-baa41397.js → createReactComponent-3e49f864.js} +1 -1
  60. package/dist/preview-client/_static/index-0a57ae09.js +1 -0
  61. package/dist/preview-client/_static/{index-a0afef01.js → index-1d0ae2e4.js} +1 -1
  62. package/dist/preview-client/_static/{index-5e4dedda.js → index-1fa3ba70.js} +1 -1
  63. package/dist/preview-client/_static/index-2c567b8d.js +1 -0
  64. package/dist/preview-client/_static/{index-29916a80.js → index-2f54d4c9.js} +1 -1
  65. package/dist/preview-client/_static/{index-70967035.js → index-4084db44.js} +1 -1
  66. package/dist/preview-client/_static/index-5c27dafa.js +1 -0
  67. package/dist/preview-client/_static/{index-8784a43a.js → index-65c6af4a.js} +3 -3
  68. package/dist/preview-client/_static/{index-cd09e78a.js → index-68806c86.js} +1 -1
  69. package/dist/preview-client/_static/{index-c8ed2a45.js → index-8a22fe59.js} +1 -1
  70. package/dist/preview-client/_static/{index-d1484803.js → index-9e3daa94.js} +1 -1
  71. package/dist/preview-client/_static/index-bdda02cf.js +1 -0
  72. package/dist/preview-client/_static/index-c88f78ce.js +1 -0
  73. package/dist/preview-client/_static/{index-4845b67c.js → index-ce381b62.js} +3 -3
  74. package/dist/preview-client/_static/{index-b126bb6b.js → index-d497fb6d.js} +219 -180
  75. package/dist/preview-client/_static/index-e4fb05d8.js +1 -0
  76. package/dist/preview-client/_static/{ktx2-encoder-8498815e.js → ktx2-encoder-772f6c33.js} +1 -1
  77. package/dist/preview-client/_static/{module-83a57161.js → module-136992e3.js} +1 -1
  78. package/dist/preview-client/_static/{module-113ac03a.js → module-1470d524.js} +1 -1
  79. package/dist/preview-client/_static/{module-8efda49c.js → module-77c2ea8c.js} +1 -1
  80. package/dist/preview-client/_static/{postmen-3b48c572.js → postmen-0413c689.js} +1 -1
  81. package/dist/preview-client/_static/{shader-data-utils-c90e48b8.js → shader-data-utils-e38a959d.js} +1 -1
  82. package/dist/preview-client/index.html +1 -1
  83. package/package.json +1 -1
  84. package/dist/preview-client/_static/MaterialAsset-8f3b3302.js +0 -1
  85. package/dist/preview-client/_static/Menu-36c201c0.js +0 -17
  86. package/dist/preview-client/_static/MeshAsset-3ddf1ac6.js +0 -1
  87. package/dist/preview-client/_static/ParticleRendererComponent-1834a159.js +0 -26
  88. package/dist/preview-client/_static/PrefabAsset-2f94de73.js +0 -1
  89. package/dist/preview-client/_static/SceneAsset-c3bb667f.js +0 -1
  90. package/dist/preview-client/_static/Tooltip-1bcb87b5.js +0 -1
  91. package/dist/preview-client/_static/index-0086cabc.js +0 -1
  92. package/dist/preview-client/_static/index-253f9e13.js +0 -1
  93. package/dist/preview-client/_static/index-8234e4e2.js +0 -1
  94. package/dist/preview-client/_static/index-94594d06.js +0 -1
  95. package/dist/preview-client/_static/index-ad57c6c8.js +0 -1
  96. package/dist/preview-client/_static/index-f7fcda86.js +0 -1
@@ -1,15 +1,15 @@
1
- var Ut=Object.defineProperty;var Ft=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var w=(e,t,n)=>(Ft(e,typeof t!="symbol"?t+"":t,n),n);import{f7 as Dt,aH as Bt,aJ as pt,av as I,bA as qt,q as mt,aK as Gt,aN as Fe,aw as te,f8 as ye,ds as ne,bz as De,aM as Wt,e2 as Be,bR as Ht,u as yt,S as Xt,x as j,aC as G,br as Kt,f9 as Qt,bX as qe,e as bt,fa as Jt,bV as Yt,cq as Zt,fb as Ge,Z as en,y as We,v as tn,aT as W,aU as nn,n as sn,o as rn,dM as an}from"./index-b126bb6b.js";import{B as N,P,a as A,A as Me,b as $e,K as At,N as on,M as V,E as ae,D as Le,u as be,R as pe,S as ln,T as Ne,c as vt,d as _t,e as Tt,C as cn,f as un,g as fn,G as Ae,h as He,F as hn,i as ve}from"./glTFIO-45ff9a17.js";import{a as oe}from"./meshopt_simplifier.module-cd99529d.js";import{u as Et,I as gn}from"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import{A as dn}from"./AssetViewer-8338dfe1.js";import{M as pn}from"./MaterialAsset-8f3b3302.js";import{k as mn}from"./ktx2-encoder-8498815e.js";function Xe(e){const t=e%4;return t===0?e:e+(4-t)}function yn(e){return e.toLowerCase().endsWith(".png")?"image/png":e.toLowerCase().endsWith(".jpg")||e.toLowerCase().endsWith(".jpeg")?"image/jpeg":e.toLowerCase().endsWith(".webp")?"image/webp":"application/octet-stream"}function wt(e){const{json:t,resources:n}=e,s=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),a=N.pad(N.encodeText(r),32),i=N.toView(new Uint32Array([a.byteLength,1313821514])),o=N.concat([i,a]);s[s.length-1]+=o.byteLength;const l=Object.values(n)[0];if(!l||!l.byteLength)return N.concat([N.toView(s),o]);const f=N.pad(l,0),c=N.toView(new Uint32Array([f.byteLength,5130562])),h=N.concat([c,f]);return s[s.length-1]+=h.byteLength,N.concat([N.toView(s),o,h])}function bn(e){const t=e.json,n=[],s=[];let r=0;function a(h){return h.uri===void 0?void 0:e.resources[h.uri]}const i=t.buffers??[],o=new Map;i.forEach((h,u)=>{const g=a(h);g!==void 0&&(n.push(new Uint8Array(g)),s.push(r),delete h.uri,h.byteLength=g.byteLength,o.set(u,r),r+=Xe(g.byteLength))});let l=i.length;(t.images||[]).forEach(h=>{const u=a(h);if(!u){delete h.uri;return}const g={buffer:0,byteOffset:r,byteLength:u.byteLength};o.set(l++,r),r+=Xe(u.byteLength);const d=t.bufferViews??[];h.bufferView=d.length,h.mimeType=yn(h.uri),delete h.uri,d.push(g),n.push(new Uint8Array(u)),s.push(g.byteOffset)});for(const h of t.bufferViews??[])h.byteOffset=(h.byteOffset??0)+(o.get(h.buffer)??0),h.buffer=0;const c=new Uint8Array(r);return n.forEach((h,u)=>{c.set(h,s[u])}),t.buffers=[{byteLength:r}],wt({json:t,resources:{"buffer.bin":c}})}function An(e){for(var t=new Array(e),n=0;n<e;++n)t[n]=n;return t}var vn=An;/*!
1
+ var Vt=Object.defineProperty;var Ft=(e,t,n)=>t in e?Vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var w=(e,t,n)=>(Ft(e,typeof t!="symbol"?t+"":t,n),n);import{f9 as Dt,aH as Bt,aJ as pt,aL as I,bC as qt,q as mt,aK as Gt,aO as Fe,aw as te,fa as ye,dt as ne,bB as De,aN as Wt,e3 as Be,bU as Ht,u as yt,S as Xt,x as j,aC as G,bs as Kt,fb as Qt,b_ as qe,e as bt,fc as Jt,bY as Yt,ct as Zt,fd as Ge,Z as en,y as We,v as tn,aU as W,aV as nn,n as sn,o as rn,dN as an}from"./index-d497fb6d.js";import{B as N,P,a as A,A as Me,b as $e,K as At,N as on,M as U,E as ae,D as Le,u as be,R as pe,S as ln,T as Ne,c as vt,d as _t,e as Tt,C as cn,f as un,g as fn,G as Ae,h as He,F as hn,i as ve}from"./glTFIO-45ff9a17.js";import{a as oe}from"./meshopt_simplifier.module-cd99529d.js";import{u as Et,I as gn}from"./index-8a22fe59.js";import"./postmen-0413c689.js";import{A as dn}from"./AssetViewer-9f395efb.js";import{M as pn}from"./MaterialAsset-aa93db51.js";import{k as mn}from"./ktx2-encoder-772f6c33.js";function Xe(e){const t=e%4;return t===0?e:e+(4-t)}function yn(e){return e.toLowerCase().endsWith(".png")?"image/png":e.toLowerCase().endsWith(".jpg")||e.toLowerCase().endsWith(".jpeg")?"image/jpeg":e.toLowerCase().endsWith(".webp")?"image/webp":"application/octet-stream"}function wt(e){const{json:t,resources:n}=e,s=new Uint32Array([1179937895,2,12]),r=JSON.stringify(t),a=N.pad(N.encodeText(r),32),i=N.toView(new Uint32Array([a.byteLength,1313821514])),o=N.concat([i,a]);s[s.length-1]+=o.byteLength;const l=Object.values(n)[0];if(!l||!l.byteLength)return N.concat([N.toView(s),o]);const f=N.pad(l,0),c=N.toView(new Uint32Array([f.byteLength,5130562])),h=N.concat([c,f]);return s[s.length-1]+=h.byteLength,N.concat([N.toView(s),o,h])}function bn(e){const t=e.json,n=[],s=[];let r=0;function a(h){return h.uri===void 0?void 0:e.resources[h.uri]}const i=t.buffers??[],o=new Map;i.forEach((h,u)=>{const g=a(h);g!==void 0&&(n.push(new Uint8Array(g)),s.push(r),delete h.uri,h.byteLength=g.byteLength,o.set(u,r),r+=Xe(g.byteLength))});let l=i.length;(t.images||[]).forEach(h=>{const u=a(h);if(!u){delete h.uri;return}const g={buffer:0,byteOffset:r,byteLength:u.byteLength};o.set(l++,r),r+=Xe(u.byteLength);const d=t.bufferViews??[];h.bufferView=d.length,h.mimeType=yn(h.uri),delete h.uri,d.push(g),n.push(new Uint8Array(u)),s.push(g.byteOffset)});for(const h of t.bufferViews??[])h.byteOffset=(h.byteOffset??0)+(o.get(h.buffer)??0),h.buffer=0;const c=new Uint8Array(r);return n.forEach((h,u)=>{c.set(h,s[u])}),t.buffers=[{byteLength:r}],wt({json:t,resources:{"buffer.bin":c}})}function An(e){for(var t=new Array(e),n=0;n<e;++n)t[n]=n;return t}var vn=An;/*!
2
2
  * Determine if an object is a Buffer
3
3
  *
4
4
  * @author Feross Aboukhadijeh <https://feross.org>
5
5
  * @license MIT
6
6
  */var _n=function(e){return e!=null&&(It(e)||Tn(e)||!!e._isBuffer)};function It(e){return!!e.constructor&&typeof e.constructor.isBuffer=="function"&&e.constructor.isBuffer(e)}function Tn(e){return typeof e.readFloatLE=="function"&&typeof e.slice=="function"&&It(e.slice(0,0))}var En=vn,wn=_n,In=typeof Float64Array<"u";function Mn(e,t){return e[0]-t[0]}function Nn(){var e=this.stride,t=new Array(e.length),n;for(n=0;n<t.length;++n)t[n]=[Math.abs(e[n]),n];t.sort(Mn);var s=new Array(t.length);for(n=0;n<s.length;++n)s[n]=t[n][1];return s}function Cn(e,t){var n=["View",t,"d",e].join("");t<0&&(n="View_Nil"+e);var s=e==="generic";if(t===-1){var r="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}",m=new Function(r);return m()}else if(t===0){var r="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(s?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(s?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}",m=new Function("TrivialArray",r);return m(le[e][0])}var r=["'use strict'"],a=En(t),i=a.map(function(p){return"i"+p}),o="this.offset+"+a.map(function(p){return"this.stride["+p+"]*i"+p}).join("+"),l=a.map(function(p){return"b"+p}).join(","),f=a.map(function(p){return"c"+p}).join(",");r.push("function "+n+"(a,"+l+","+f+",d){this.data=a","this.shape=["+l+"]","this.stride=["+f+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),r.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+a.map(function(p){return"this.shape["+p+"]"}).join("*"),"}})"),t===1?r.push("proto.order=[0]"):(r.push("Object.defineProperty(proto,'order',{get:"),t<4?(r.push("function "+n+"_order(){"),t===2?r.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):t===3&&r.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):r.push("ORDER})")),r.push("proto.set=function "+n+"_set("+i.join(",")+",v){"),s?r.push("return this.data.set("+o+",v)}"):r.push("return this.data["+o+"]=v}"),r.push("proto.get=function "+n+"_get("+i.join(",")+"){"),s?r.push("return this.data.get("+o+")}"):r.push("return this.data["+o+"]}"),r.push("proto.index=function "+n+"_index(",i.join(),"){return "+o+"}"),r.push("proto.hi=function "+n+"_hi("+i.join(",")+"){return new "+n+"(this.data,"+a.map(function(p){return["(typeof i",p,"!=='number'||i",p,"<0)?this.shape[",p,"]:i",p,"|0"].join("")}).join(",")+","+a.map(function(p){return"this.stride["+p+"]"}).join(",")+",this.offset)}");var c=a.map(function(p){return"a"+p+"=this.shape["+p+"]"}),h=a.map(function(p){return"c"+p+"=this.stride["+p+"]"});r.push("proto.lo=function "+n+"_lo("+i.join(",")+"){var b=this.offset,d=0,"+c.join(",")+","+h.join(","));for(var u=0;u<t;++u)r.push("if(typeof i"+u+"==='number'&&i"+u+">=0){d=i"+u+"|0;b+=c"+u+"*d;a"+u+"-=d}");r.push("return new "+n+"(this.data,"+a.map(function(p){return"a"+p}).join(",")+","+a.map(function(p){return"c"+p}).join(",")+",b)}"),r.push("proto.step=function "+n+"_step("+i.join(",")+"){var "+a.map(function(p){return"a"+p+"=this.shape["+p+"]"}).join(",")+","+a.map(function(p){return"b"+p+"=this.stride["+p+"]"}).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(var u=0;u<t;++u)r.push("if(typeof i"+u+"==='number'){d=i"+u+"|0;if(d<0){c+=b"+u+"*(a"+u+"-1);a"+u+"=ceil(-a"+u+"/d)}else{a"+u+"=ceil(a"+u+"/d)}b"+u+"*=d}");r.push("return new "+n+"(this.data,"+a.map(function(p){return"a"+p}).join(",")+","+a.map(function(p){return"b"+p}).join(",")+",c)}");for(var g=new Array(t),d=new Array(t),u=0;u<t;++u)g[u]="a[i"+u+"]",d[u]="b[i"+u+"]";r.push("proto.transpose=function "+n+"_transpose("+i+"){"+i.map(function(p,y){return p+"=("+p+"===undefined?"+y+":"+p+"|0)"}).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+g.join(",")+","+d.join(",")+",this.offset)}"),r.push("proto.pick=function "+n+"_pick("+i+"){var a=[],b=[],c=this.offset");for(var u=0;u<t;++u)r.push("if(typeof i"+u+"==='number'&&i"+u+">=0){c=(c+this.stride["+u+"]*i"+u+")|0}else{a.push(this.shape["+u+"]);b.push(this.stride["+u+"])}");r.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),r.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+a.map(function(p){return"shape["+p+"]"}).join(",")+","+a.map(function(p){return"stride["+p+"]"}).join(",")+",offset)}");var m=new Function("CTOR_LIST","ORDER",r.join(`
7
7
  `));return m(le[e],Nn)}function Sn(e){if(wn(e))return"buffer";if(In)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(e)?"array":"generic"}var le={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};function On(e,t,n,s){if(e===void 0){var f=le.array[0];return f([])}else typeof e=="number"&&(e=[e]);t===void 0&&(t=[e.length]);var r=t.length;if(n===void 0){n=new Array(r);for(var a=r-1,i=1;a>=0;--a)n[a]=i,i*=t[a]}if(s===void 0){s=0;for(var a=0;a<r;++a)n[a]<0&&(s-=(t[a]-1)*n[a])}for(var o=Sn(e),l=le[o];l.length<=r+1;)l.push(Cn(o,l.length-1));var f=l[r+1];return f(e,t,n,s)}var xn=On;const jn=Dt(xn);var Rn={};function Pn(e,t){for(var n=1,s=e.length,r=e[0],a=e[0],i=1;i<s;++i)if(a=r,r=e[i],t(r,a)){if(i===n){n++;continue}e[n++]=r}return e.length=n,e}function zn(e){for(var t=1,n=e.length,s=e[0],r=e[0],a=1;a<n;++a,r=s)if(r=s,s=e[a],s!==r){if(a===t){t++;continue}e[t++]=s}return e.length=t,e}function kn(e,t,n){return e.length===0?e:t?(n||e.sort(t),Pn(e,t)):(n||e.sort(),zn(e))}var $n=kn,Ln=$n;function Mt(e,t,n){var s=e.length,r=t.arrayArgs.length,a=t.indexArgs.length>0,i=[],o=[],l=0,f=0,c,h;for(c=0;c<s;++c)o.push(["i",c,"=0"].join(""));for(h=0;h<r;++h)for(c=0;c<s;++c)f=l,l=e[c],c===0?o.push(["d",h,"s",c,"=t",h,"p",l].join("")):o.push(["d",h,"s",c,"=(t",h,"p",l,"-s",f,"*t",h,"p",f,")"].join(""));for(o.length>0&&i.push("var "+o.join(",")),c=s-1;c>=0;--c)l=e[c],i.push(["for(i",c,"=0;i",c,"<s",l,";++i",c,"){"].join(""));for(i.push(n),c=0;c<s;++c){for(f=l,l=e[c],h=0;h<r;++h)i.push(["p",h,"+=d",h,"s",c].join(""));a&&(c>0&&i.push(["index[",f,"]-=s",f].join("")),i.push(["++index[",l,"]"].join(""))),i.push("}")}return i.join(`
8
- `)}function Vn(e,t,n,s){for(var r=t.length,a=n.arrayArgs.length,i=n.blockSize,o=n.indexArgs.length>0,l=[],f=0;f<a;++f)l.push(["var offset",f,"=p",f].join(""));for(var f=e;f<r;++f)l.push(["for(var j"+f+"=SS[",t[f],"]|0;j",f,">0;){"].join("")),l.push(["if(j",f,"<",i,"){"].join("")),l.push(["s",t[f],"=j",f].join("")),l.push(["j",f,"=0"].join("")),l.push(["}else{s",t[f],"=",i].join("")),l.push(["j",f,"-=",i,"}"].join("")),o&&l.push(["index[",t[f],"]=j",f].join(""));for(var f=0;f<a;++f){for(var c=["offset"+f],h=e;h<r;++h)c.push(["j",h,"*t",f,"p",t[h]].join(""));l.push(["p",f,"=(",c.join("+"),")"].join(""))}l.push(Mt(t,n,s));for(var f=e;f<r;++f)l.push("}");return l.join(`
9
- `)}function Un(e){for(var t=0,n=e[0].length;t<n;){for(var s=1;s<e.length;++s)if(e[s][t]!==e[0][t])return t;++t}return t}function _e(e,t,n){for(var s=e.body,r=[],a=[],i=0;i<e.args.length;++i){var o=e.args[i];if(!(o.count<=0)){var l=new RegExp(o.name,"g"),f="",c=t.arrayArgs.indexOf(i);switch(t.argTypes[i]){case"offset":var h=t.offsetArgIndex.indexOf(i),u=t.offsetArgs[h];c=u.array,f="+q"+h;case"array":f="p"+c+f;var g="l"+i,d="a"+c;if(t.arrayBlockIndices[c]===0)o.count===1?n[c]==="generic"?o.lvalue?(r.push(["var ",g,"=",d,".get(",f,")"].join("")),s=s.replace(l,g),a.push([d,".set(",f,",",g,")"].join(""))):s=s.replace(l,[d,".get(",f,")"].join("")):s=s.replace(l,[d,"[",f,"]"].join("")):n[c]==="generic"?(r.push(["var ",g,"=",d,".get(",f,")"].join("")),s=s.replace(l,g),o.lvalue&&a.push([d,".set(",f,",",g,")"].join(""))):(r.push(["var ",g,"=",d,"[",f,"]"].join("")),s=s.replace(l,g),o.lvalue&&a.push([d,"[",f,"]=",g].join("")));else{for(var m=[o.name],p=[f],y=0;y<Math.abs(t.arrayBlockIndices[c]);y++)m.push("\\s*\\[([^\\]]+)\\]"),p.push("$"+(y+1)+"*t"+c+"b"+y);if(l=new RegExp(m.join(""),"g"),f=p.join("+"),n[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");s=s.replace(l,[d,"[",f,"]"].join(""))}break;case"scalar":s=s.replace(l,"Y"+t.scalarArgs.indexOf(i));break;case"index":s=s.replace(l,"index");break;case"shape":s=s.replace(l,"shape");break}}}return[r.join(`
8
+ `)}function Un(e,t,n,s){for(var r=t.length,a=n.arrayArgs.length,i=n.blockSize,o=n.indexArgs.length>0,l=[],f=0;f<a;++f)l.push(["var offset",f,"=p",f].join(""));for(var f=e;f<r;++f)l.push(["for(var j"+f+"=SS[",t[f],"]|0;j",f,">0;){"].join("")),l.push(["if(j",f,"<",i,"){"].join("")),l.push(["s",t[f],"=j",f].join("")),l.push(["j",f,"=0"].join("")),l.push(["}else{s",t[f],"=",i].join("")),l.push(["j",f,"-=",i,"}"].join("")),o&&l.push(["index[",t[f],"]=j",f].join(""));for(var f=0;f<a;++f){for(var c=["offset"+f],h=e;h<r;++h)c.push(["j",h,"*t",f,"p",t[h]].join(""));l.push(["p",f,"=(",c.join("+"),")"].join(""))}l.push(Mt(t,n,s));for(var f=e;f<r;++f)l.push("}");return l.join(`
9
+ `)}function Vn(e){for(var t=0,n=e[0].length;t<n;){for(var s=1;s<e.length;++s)if(e[s][t]!==e[0][t])return t;++t}return t}function _e(e,t,n){for(var s=e.body,r=[],a=[],i=0;i<e.args.length;++i){var o=e.args[i];if(!(o.count<=0)){var l=new RegExp(o.name,"g"),f="",c=t.arrayArgs.indexOf(i);switch(t.argTypes[i]){case"offset":var h=t.offsetArgIndex.indexOf(i),u=t.offsetArgs[h];c=u.array,f="+q"+h;case"array":f="p"+c+f;var g="l"+i,d="a"+c;if(t.arrayBlockIndices[c]===0)o.count===1?n[c]==="generic"?o.lvalue?(r.push(["var ",g,"=",d,".get(",f,")"].join("")),s=s.replace(l,g),a.push([d,".set(",f,",",g,")"].join(""))):s=s.replace(l,[d,".get(",f,")"].join("")):s=s.replace(l,[d,"[",f,"]"].join("")):n[c]==="generic"?(r.push(["var ",g,"=",d,".get(",f,")"].join("")),s=s.replace(l,g),o.lvalue&&a.push([d,".set(",f,",",g,")"].join(""))):(r.push(["var ",g,"=",d,"[",f,"]"].join("")),s=s.replace(l,g),o.lvalue&&a.push([d,"[",f,"]=",g].join("")));else{for(var m=[o.name],p=[f],y=0;y<Math.abs(t.arrayBlockIndices[c]);y++)m.push("\\s*\\[([^\\]]+)\\]"),p.push("$"+(y+1)+"*t"+c+"b"+y);if(l=new RegExp(m.join(""),"g"),f=p.join("+"),n[c]==="generic")throw new Error("cwise: Generic arrays not supported in combination with blocks!");s=s.replace(l,[d,"[",f,"]"].join(""))}break;case"scalar":s=s.replace(l,"Y"+t.scalarArgs.indexOf(i));break;case"index":s=s.replace(l,"index");break;case"shape":s=s.replace(l,"shape");break}}}return[r.join(`
10
10
  `),s,a.join(`
11
11
  `)].join(`
12
- `).trim()}function Fn(e){for(var t=new Array(e.length),n=!0,s=0;s<e.length;++s){var r=e[s],a=r.match(/\d+/);a?a=a[0]:a="",r.charAt(0)===0?t[s]="u"+r.charAt(1)+a:t[s]=r.charAt(0)+a,s>0&&(n=n&&t[s]===t[s-1])}return n?t[0]:t.join("")}function Dn(e,t){for(var n=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,s=new Array(e.arrayArgs.length),r=new Array(e.arrayArgs.length),a=0;a<e.arrayArgs.length;++a)r[a]=t[2*a],s[a]=t[2*a+1];for(var i=[],o=[],l=[],f=[],c=[],a=0;a<e.arrayArgs.length;++a){e.arrayBlockIndices[a]<0?(l.push(0),f.push(n),i.push(n),o.push(n+e.arrayBlockIndices[a])):(l.push(e.arrayBlockIndices[a]),f.push(e.arrayBlockIndices[a]+n),i.push(0),o.push(e.arrayBlockIndices[a]));for(var h=[],u=0;u<s[a].length;u++)l[a]<=s[a][u]&&s[a][u]<f[a]&&h.push(s[a][u]-l[a]);c.push(h)}for(var g=["SS"],d=["'use strict'"],m=[],u=0;u<n;++u)m.push(["s",u,"=SS[",u,"]"].join(""));for(var a=0;a<e.arrayArgs.length;++a){g.push("a"+a),g.push("t"+a),g.push("p"+a);for(var u=0;u<n;++u)m.push(["t",a,"p",u,"=t",a,"[",l[a]+u,"]"].join(""));for(var u=0;u<Math.abs(e.arrayBlockIndices[a]);++u)m.push(["t",a,"b",u,"=t",a,"[",i[a]+u,"]"].join(""))}for(var a=0;a<e.scalarArgs.length;++a)g.push("Y"+a);if(e.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var p=new Array(n),a=0;a<n;++a)p[a]="0";m.push(["index=[",p.join(","),"]"].join(""))}for(var a=0;a<e.offsetArgs.length;++a){for(var y=e.offsetArgs[a],T=[],u=0;u<y.offset.length;++u)y.offset[u]!==0&&(y.offset[u]===1?T.push(["t",y.array,"p",u].join("")):T.push([y.offset[u],"*t",y.array,"p",u].join("")));T.length===0?m.push("q"+a+"=0"):m.push(["q",a,"=",T.join("+")].join(""))}var v=Ln([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));m=m.concat(v),m.length>0&&d.push("var "+m.join(","));for(var a=0;a<e.arrayArgs.length;++a)d.push("p"+a+"|=0");e.pre.body.length>3&&d.push(_e(e.pre,e,r));var b=_e(e.body,e,r),_=Un(c);_<n?d.push(Vn(_,c[0],e,b)):d.push(Mt(c[0],e,b)),e.post.body.length>3&&d.push(_e(e.post,e,r)),e.debug&&console.log("-----Generated cwise routine for ",t,`:
12
+ `).trim()}function Fn(e){for(var t=new Array(e.length),n=!0,s=0;s<e.length;++s){var r=e[s],a=r.match(/\d+/);a?a=a[0]:a="",r.charAt(0)===0?t[s]="u"+r.charAt(1)+a:t[s]=r.charAt(0)+a,s>0&&(n=n&&t[s]===t[s-1])}return n?t[0]:t.join("")}function Dn(e,t){for(var n=t[1].length-Math.abs(e.arrayBlockIndices[0])|0,s=new Array(e.arrayArgs.length),r=new Array(e.arrayArgs.length),a=0;a<e.arrayArgs.length;++a)r[a]=t[2*a],s[a]=t[2*a+1];for(var i=[],o=[],l=[],f=[],c=[],a=0;a<e.arrayArgs.length;++a){e.arrayBlockIndices[a]<0?(l.push(0),f.push(n),i.push(n),o.push(n+e.arrayBlockIndices[a])):(l.push(e.arrayBlockIndices[a]),f.push(e.arrayBlockIndices[a]+n),i.push(0),o.push(e.arrayBlockIndices[a]));for(var h=[],u=0;u<s[a].length;u++)l[a]<=s[a][u]&&s[a][u]<f[a]&&h.push(s[a][u]-l[a]);c.push(h)}for(var g=["SS"],d=["'use strict'"],m=[],u=0;u<n;++u)m.push(["s",u,"=SS[",u,"]"].join(""));for(var a=0;a<e.arrayArgs.length;++a){g.push("a"+a),g.push("t"+a),g.push("p"+a);for(var u=0;u<n;++u)m.push(["t",a,"p",u,"=t",a,"[",l[a]+u,"]"].join(""));for(var u=0;u<Math.abs(e.arrayBlockIndices[a]);++u)m.push(["t",a,"b",u,"=t",a,"[",i[a]+u,"]"].join(""))}for(var a=0;a<e.scalarArgs.length;++a)g.push("Y"+a);if(e.shapeArgs.length>0&&m.push("shape=SS.slice(0)"),e.indexArgs.length>0){for(var p=new Array(n),a=0;a<n;++a)p[a]="0";m.push(["index=[",p.join(","),"]"].join(""))}for(var a=0;a<e.offsetArgs.length;++a){for(var y=e.offsetArgs[a],T=[],u=0;u<y.offset.length;++u)y.offset[u]!==0&&(y.offset[u]===1?T.push(["t",y.array,"p",u].join("")):T.push([y.offset[u],"*t",y.array,"p",u].join("")));T.length===0?m.push("q"+a+"=0"):m.push(["q",a,"=",T.join("+")].join(""))}var v=Ln([].concat(e.pre.thisVars).concat(e.body.thisVars).concat(e.post.thisVars));m=m.concat(v),m.length>0&&d.push("var "+m.join(","));for(var a=0;a<e.arrayArgs.length;++a)d.push("p"+a+"|=0");e.pre.body.length>3&&d.push(_e(e.pre,e,r));var b=_e(e.body,e,r),_=Vn(c);_<n?d.push(Un(_,c[0],e,b)):d.push(Mt(c[0],e,b)),e.post.body.length>3&&d.push(_e(e.post,e,r)),e.debug&&console.log("-----Generated cwise routine for ",t,`:
13
13
  `+d.join(`
14
14
  `)+`
15
15
  ----------`);var E=[e.funcName||"unnamed","_cwise_loop_",s[0].join("s"),"m",_,Fn(r)].join(""),x=new Function(["function ",E,"(",g.join(","),"){",d.join(`
@@ -17,4 +17,4 @@ var Ut=Object.defineProperty;var Ft=(e,t,n)=>t in e?Ut(e,t,{enumerable:!0,config
17
17
  `+t.join(`
18
18
  `)+`
19
19
  ----------`);var h=new Function("compile",t.join(`
20
- `));return h(qn.bind(void 0,e))}var Wn=Gn,Hn=Wn;function Xn(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function Kn(e){var t=new Xn;t.pre=e.pre,t.body=e.body,t.post=e.post;var n=e.args.slice(0);t.argTypes=n;for(var s=0;s<n.length;++s){var r=n[s];if(r==="array"||typeof r=="object"&&r.blockIndices){if(t.argTypes[s]="array",t.arrayArgs.push(s),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+s),s<t.pre.args.length&&t.pre.args[s].count>0)throw new Error("cwise: pre() block may not reference array args");if(s<t.post.args.length&&t.post.args[s].count>0)throw new Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(s),t.shimArgs.push("scalar"+s);else if(r==="index"){if(t.indexArgs.push(s),s<t.pre.args.length&&t.pre.args[s].count>0)throw new Error("cwise: pre() block may not reference array index");if(s<t.body.args.length&&t.body.args[s].lvalue)throw new Error("cwise: body() block may not write to array index");if(s<t.post.args.length&&t.post.args[s].count>0)throw new Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(s),s<t.pre.args.length&&t.pre.args[s].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(s<t.body.args.length&&t.body.args[s].lvalue)throw new Error("cwise: body() block may not write to array shape");if(s<t.post.args.length&&t.post.args[s].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof r=="object"&&r.offset)t.argTypes[s]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(s);else throw new Error("cwise: Unknown argument type "+n[s])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>n.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,Hn(t)}var Qn=Kn;(function(e){var t=Qn,n={body:"",args:[],thisVars:[],localVars:[]};function s(u){if(!u)return n;for(var g=0;g<u.args.length;++g){var d=u.args[g];g===0?u.args[g]={name:d,lvalue:!0,rvalue:!!u.rvalue,count:u.count||1}:u.args[g]={name:d,lvalue:!1,rvalue:!0,count:1}}return u.thisVars||(u.thisVars=[]),u.localVars||(u.localVars=[]),u}function r(u){return t({args:u.args,pre:s(u.pre),body:s(u.body),post:s(u.proc),funcName:u.funcName})}function a(u){for(var g=[],d=0;d<u.args.length;++d)g.push("a"+d);var m=new Function("P",["return function ",u.funcName,"_ndarrayops(",g.join(","),") {P(",g.join(","),");return a0}"].join(""));return m(r(u))}var i={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var u in i){var g=i[u];e[u]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:u}),e[u+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+g+"=b"},rvalue:!0,funcName:u+"eq"}),e[u+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:u+"s"}),e[u+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+g+"=s"},rvalue:!0,funcName:u+"seq"})}})();var o={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var u in o){var g=o[u];e[u]=a({args:["array","array"],body:{args:["a","b"],body:"a="+g+"b"},funcName:u}),e[u+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+g+"a"},rvalue:!0,count:2,funcName:u+"eq"})}})();var l={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var u in l){var g=l[u];e[u]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:u}),e[u+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:u+"s"}),e[u+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+g+"b"},rvalue:!0,count:2,funcName:u+"eq"}),e[u+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+g+"s"},rvalue:!0,count:2,funcName:u+"seq"})}})();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var u=0;u<f.length;++u){var g=f[u];e[g]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:g}),e[g+"eq"]=a({args:["array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"})}})();var c=["max","min","atan2","pow"];(function(){for(var u=0;u<c.length;++u){var g=c[u];e[g]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g}),e[g+"s"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g+"s"}),e[g+"eq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"}),e[g+"seq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"seq"})}})();var h=["atan2","pow"];(function(){for(var u=0;u<h.length;++u){var g=h[u];e[g+"op"]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"op"}),e[g+"ops"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"ops"}),e[g+"opeq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opeq"}),e[g+"opseq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opseq"})}})(),e.any=t({args:["array"],pre:n,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),e.all=t({args:["array"],pre:n,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),e.sum=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),e.prod=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),e.norm2squared=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),e.norm2=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),e.norminf=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),e.norm1=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),e.sup=t({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.inf=t({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.argmin=t({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.argmax=t({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),e.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),e.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),e.equals=t({args:["array","array"],pre:n,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})})(Rn);function Jn(e,t){if(!(e instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");const n=new Blob([e],{type:t}),s=URL.createObjectURL(n);return new Promise((r,a)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=function(){URL.revokeObjectURL(s);const l=new OffscreenCanvas(i.width,i.height).getContext("2d");l.drawImage(i,0,0);const f=l.getImageData(0,0,i.width,i.height);r(jn(new Uint8Array(f.data),[i.width,i.height,4],[4,4*i.width,1],0))},i.onerror=o=>{URL.revokeObjectURL(s),a(o)},i.src=s})}async function Yn(e,t){return Jn(e,t)}function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},q.apply(null,arguments)}P.Mode;function D(e,t){return Object.defineProperty(t,"name",{value:e}),t}function H(e,t){const n=q({},e);for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}class Te{constructor(){this._map=new Map}get size(){return this._map.size}has(t){return this._map.has(t)}add(t,n){let s=this._map.get(t);return s||(s=new Set,this._map.set(t,s)),s.add(n),this}get(t){return this._map.get(t)||new Set}keys(){return this._map.keys()}}const Zn=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function Ke(e){return Zn.format(e)}function es(e,t,n=2){const s=e>t?"–":"+",r="%";return s+(Math.abs(e-t)/e*100).toFixed(n)+r}function ts(e,t){return`${Ke(e)} → ${Ke(t)} (${es(e,t)})`}function Nt(e){const t=[];for(const n of e.listAttributes())t.push(n);for(const n of e.listTargets())for(const s of n.listAttributes())t.push(s);return Array.from(new Set(t))}function ns(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ee(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function ss(e,t=e){const n=Ct(e,t);for(let s=0;s<n.length;s++)n[s]=s;return n}function Ct(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function St(e){for(const t in e)return!1;return!0}var ce=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function rs(e,t){var n=t[0],s=t[1],r=t[2],a=t[3],i=t[4],o=t[5],l=t[6],f=t[7],c=t[8],h=t[9],u=t[10],g=t[11],d=t[12],m=t[13],p=t[14],y=t[15],T=n*o-s*i,v=n*l-r*i,b=n*f-a*i,_=s*l-r*o,E=s*f-a*o,x=r*f-a*l,$=c*m-h*d,X=c*p-u*d,K=c*y-g*d,Q=h*p-u*m,J=h*y-g*m,Y=u*y-g*p,M=T*Y-v*J+b*Q+_*K-E*X+x*$;return M?(M=1/M,e[0]=(o*Y-l*J+f*Q)*M,e[1]=(r*J-s*Y-a*Q)*M,e[2]=(m*x-p*E+y*_)*M,e[3]=(u*E-h*x-g*_)*M,e[4]=(l*K-i*Y-f*X)*M,e[5]=(n*Y-r*K+a*X)*M,e[6]=(p*b-d*x-y*v)*M,e[7]=(c*x-u*b+g*v)*M,e[8]=(i*J-o*K+f*$)*M,e[9]=(s*K-n*J-a*$)*M,e[10]=(d*E-m*b+y*T)*M,e[11]=(h*b-c*E-g*T)*M,e[12]=(o*X-i*Q-l*$)*M,e[13]=(n*Q-s*X+r*$)*M,e[14]=(m*v-d*_-p*T)*M,e[15]=(c*_-h*v+u*T)*M,e):null}function Ve(e,t,n){var s=t[0],r=t[1],a=t[2],i=t[3],o=t[4],l=t[5],f=t[6],c=t[7],h=t[8],u=t[9],g=t[10],d=t[11],m=t[12],p=t[13],y=t[14],T=t[15],v=n[0],b=n[1],_=n[2],E=n[3];return e[0]=v*s+b*o+_*h+E*m,e[1]=v*r+b*l+_*u+E*p,e[2]=v*a+b*f+_*g+E*y,e[3]=v*i+b*c+_*d+E*T,v=n[4],b=n[5],_=n[6],E=n[7],e[4]=v*s+b*o+_*h+E*m,e[5]=v*r+b*l+_*u+E*p,e[6]=v*a+b*f+_*g+E*y,e[7]=v*i+b*c+_*d+E*T,v=n[8],b=n[9],_=n[10],E=n[11],e[8]=v*s+b*o+_*h+E*m,e[9]=v*r+b*l+_*u+E*p,e[10]=v*a+b*f+_*g+E*y,e[11]=v*i+b*c+_*d+E*T,v=n[12],b=n[13],_=n[14],E=n[15],e[12]=v*s+b*o+_*h+E*m,e[13]=v*r+b*l+_*u+E*p,e[14]=v*a+b*f+_*g+E*y,e[15]=v*i+b*c+_*d+E*T,e}function as(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function is(e,t,n,s){var r=t[0],a=t[1],i=t[2],o=t[3],l=r+r,f=a+a,c=i+i,h=r*l,u=r*f,g=r*c,d=a*f,m=a*c,p=i*c,y=o*l,T=o*f,v=o*c,b=s[0],_=s[1],E=s[2];return e[0]=(1-(d+p))*b,e[1]=(u+v)*b,e[2]=(g-T)*b,e[3]=0,e[4]=(u-v)*_,e[5]=(1-(h+p))*_,e[6]=(m+y)*_,e[7]=0,e[8]=(g+T)*E,e[9]=(m-y)*E,e[10]=(1-(h+d))*E,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function os(){var e=new ce(3);return ce!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ls(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function Ce(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function Se(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function Qe(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function cs(e,t,n){var s=t[0],r=t[1],a=t[2],i=n[3]*s+n[7]*r+n[11]*a+n[15];return i=i||1,e[0]=(n[0]*s+n[4]*r+n[8]*a+n[12])/i,e[1]=(n[1]*s+n[5]*r+n[9]*a+n[13])/i,e[2]=(n[2]*s+n[6]*r+n[10]*a+n[14])/i,e}var us=ls;(function(){var e=os();return function(t,n,s,r,a,i){var o,l;for(n||(n=3),s||(s=0),r?l=Math.min(r*n+s,t.length):l=t.length,o=s;o<l;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],a(e,e,i),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();const F="dedup",Ee={keepUniqueNames:!1,propertyTypes:[A.ACCESSOR,A.MESH,A.TEXTURE,A.MATERIAL,A.SKIN]};function fs(e=Ee){const t=H(Ee,e),n=new Set(t.propertyTypes);for(const s of t.propertyTypes)if(!Ee.propertyTypes.includes(s))throw new Error(`${F}: Unsupported deduplication on type "${s}".`);return D(F,s=>{const r=s.getLogger();n.has(A.ACCESSOR)&&hs(s),n.has(A.TEXTURE)&&ds(s,t),n.has(A.MATERIAL)&&ps(s,t),n.has(A.MESH)&&gs(s,t),n.has(A.SKIN)&&ms(s,t),r.debug(`${F}: Complete.`)})}function hs(e){const t=e.getLogger(),n=new Map,s=new Map,r=new Map,a=new Map,i=e.getRoot().listMeshes();i.forEach(h=>{h.listPrimitives().forEach(u=>{u.listAttributes().forEach(g=>o(g,s)),o(u.getIndices(),n)})});for(const h of e.getRoot().listAnimations())for(const u of h.listSamplers())o(u.getInput(),r),o(u.getOutput(),a);function o(h,u){if(!h)return;const g=[h.getCount(),h.getType(),h.getComponentType(),h.getNormalized(),h.getSparse()].join(":");let d=u.get(g);d||u.set(g,d=new Set),d.add(h)}function l(h,u){for(let g=0;g<h.length;g++){const d=h[g],m=N.toView(d.getArray());if(!u.has(d))for(let p=g+1;p<h.length;p++){const y=h[p];u.has(y)||N.equals(m,N.toView(y.getArray()))&&u.set(y,d)}}}let f=0;const c=new Map;for(const h of[s,n,r,a])for(const u of h.values())f+=u.size,l(Array.from(u),c);t.debug(`${F}: Merged ${c.size} of ${f} accessors.`),i.forEach(h=>{h.listPrimitives().forEach(u=>{u.listAttributes().forEach(d=>{c.has(d)&&u.swap(d,c.get(d))});const g=u.getIndices();g&&c.has(g)&&u.swap(g,c.get(g))})});for(const h of e.getRoot().listAnimations())for(const u of h.listSamplers()){const g=u.getInput(),d=u.getOutput();g&&c.has(g)&&u.swap(g,c.get(g)),d&&c.has(d)&&u.swap(d,c.get(d))}Array.from(c.keys()).forEach(h=>h.dispose())}function gs(e,t){const n=e.getLogger(),s=e.getRoot(),r=new Map;s.listAccessors().forEach((o,l)=>r.set(o,l)),s.listMaterials().forEach((o,l)=>r.set(o,l));const a=s.listMeshes().length,i=new Map;for(const o of s.listMeshes()){const l=[];for(const c of o.listPrimitives())l.push(Ot(c,r));let f="";if(t.keepUniqueNames&&(f+=o.getName()+";"),f+=l.join(";"),i.has(f)){const c=i.get(f);o.listParents().forEach(h=>{h.propertyType!==A.ROOT&&h.swap(o,c)}),o.dispose()}else i.set(f,o)}n.debug(`${F}: Merged ${a-i.size} of ${a} meshes.`)}function ds(e,t){const n=e.getLogger(),s=e.getRoot(),r=s.listTextures(),a=new Map;for(let i=0;i<r.length;i++){const o=r[i],l=o.getImage();if(!a.has(o))for(let f=i+1;f<r.length;f++){const c=r[f],h=c.getImage();if(a.has(c)||o.getMimeType()!==c.getMimeType()||t.keepUniqueNames&&o.getName()!==c.getName())continue;const u=o.getSize(),g=c.getSize();!u||!g||u[0]===g[0]&&u[1]===g[1]&&(!l||!h||N.equals(l,h)&&a.set(c,o))}}n.debug(`${F}: Merged ${a.size} of ${s.listTextures().length} textures.`),Array.from(a.entries()).forEach(([i,o])=>{i.listParents().forEach(l=>{l instanceof pe||l.swap(i,o)}),i.dispose()})}function ps(e,t){const n=e.getLogger(),r=e.getRoot().listMaterials(),a=new Map,i=new Map,o=new Set;t.keepUniqueNames||o.add("name");for(let l=0;l<r.length;l++){const f=r[l];if(!a.has(f)&&!Je(f,i))for(let c=l+1;c<r.length;c++){const h=r[c];a.has(h)||Je(h,i)||f.equals(h,o)&&a.set(h,f)}}n.debug(`${F}: Merged ${a.size} of ${r.length} materials.`),Array.from(a.entries()).forEach(([l,f])=>{l.listParents().forEach(c=>{c instanceof pe||c.swap(l,f)}),l.dispose()})}function ms(e,t){const n=e.getLogger(),r=e.getRoot().listSkins(),a=new Map,i=new Set(["joints"]);t.keepUniqueNames||i.add("name");for(let o=0;o<r.length;o++){const l=r[o];if(!a.has(l))for(let f=o+1;f<r.length;f++){const c=r[f];a.has(c)||l.equals(c,i)&&ns(l.listJoints(),c.listJoints())&&a.set(c,l)}}n.debug(`${F}: Merged ${a.size} of ${r.length} skins.`),Array.from(a.entries()).forEach(([o,l])=>{o.listParents().forEach(f=>{f instanceof pe||f.swap(o,l)}),o.dispose()})}function Ot(e,t){const n=[];for(const s of e.listSemantics()){const r=e.getAttribute(s);n.push(s+":"+t.get(r))}if(e instanceof P){const s=e.getIndices();s&&n.push("indices:"+t.get(s));const r=e.getMaterial();r&&n.push("material:"+t.get(r)),n.push("mode:"+e.getMode());for(const a of e.listTargets())n.push("target:"+Ot(a,t))}return n.join(",")}function Je(e,t){if(t.has(e))return t.get(e);const n=e.getGraph(),s=new Set,r=n.listParentEdges(e);for(;r.length>0;){const a=r.pop();if(a.getAttributes().modifyChild===!0)return t.set(e,!0),!0;const i=a.getChild();if(!s.has(i))for(const o of n.listChildEdges(i))r.push(o)}return t.set(e,!1),!1}function xt(){var e=new ce(4);return ce!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function ys(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function bs(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function As(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function vs(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function _s(e){var t=e[0],n=e[1],s=e[2],r=e[3];return Math.hypot(t,n,s,r)}var jt=bs,Ts=As,Rt=_s;(function(){var e=xt();return function(t,n,s,r,a,i){var o,l;for(n||(n=4),s||(s=0),r?l=Math.min(r*n+s,t.length):l=t.length,o=s;o<l;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],a(e,e,i),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();const Es=/color|emissive|diffuse/i;function ws(e){return e.getGraph().listParentEdges(e).some(r=>r.getAttributes().isColor||Es.test(r.getName()))?"srgb":null}function Is(e){const t=e.getGraph(),n=new Set,s=new Set;function r(a){const i=new Set;for(const o of t.listChildEdges(a))o.getChild()instanceof Ne&&i.add(o.getName()+"Info");for(const o of t.listChildEdges(a)){const l=o.getChild();n.has(l)||(n.add(l),l instanceof vt&&i.has(o.getName())?s.add(l):l instanceof _t&&r(l))}}return r(e),Array.from(s)}function Ms(e){const n=Le.fromGraph(e.getGraph()).getRoot(),s=e.getGraph().listParentEdges(e).filter(r=>r.getParent()!==n).map(r=>r.getName());return Array.from(new Set(s))}const B="prune",Oe=3/255,Ye={propertyTypes:[A.NODE,A.SKIN,A.MESH,A.CAMERA,A.PRIMITIVE,A.PRIMITIVE_TARGET,A.ANIMATION,A.MATERIAL,A.TEXTURE,A.ACCESSOR,A.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function Pt(e=Ye){const t=H(Ye,e),n=new Set(t.propertyTypes),s=t.keepExtras;return D(B,async r=>{const a=r.getLogger(),i=r.getRoot(),o=r.getGraph(),l=new Ns,f=c=>l.dispose(c.target);if(o.addEventListener("node:dispose",f),n.has(A.MESH))for(const c of i.listMeshes())c.listPrimitives().length>0||c.dispose();if(n.has(A.NODE)){if(!t.keepLeaves)for(const c of i.listScenes())zt(o,c,s);for(const c of i.listNodes())S(c,s)}if(n.has(A.SKIN))for(const c of i.listSkins())S(c,s);if(n.has(A.MESH))for(const c of i.listMeshes())S(c,s);if(n.has(A.CAMERA))for(const c of i.listCameras())S(c,s);if(n.has(A.PRIMITIVE)&&Ze(o,A.PRIMITIVE,s),n.has(A.PRIMITIVE_TARGET)&&Ze(o,A.PRIMITIVE_TARGET,s),!t.keepAttributes&&n.has(A.ACCESSOR)){const c=new Map;for(const h of i.listMeshes())for(const u of h.listPrimitives()){const g=u.getMaterial();if(!g)continue;const d=kt(r,u,g),m=Ss(u,d);et(u,m),u.listTargets().forEach(p=>et(p,m)),c.has(g)?c.get(g).add(u):c.set(g,new Set([u]))}for(const[h,u]of c)Os(h,Array.from(u))}if(!t.keepIndices&&n.has(A.ACCESSOR))for(const c of i.listMeshes())for(const h of c.listPrimitives())Cs(h);if(n.has(A.ANIMATION))for(const c of i.listAnimations()){for(const h of c.listChannels())h.getTargetNode()||h.dispose();if(c.listChannels().length)c.listSamplers().forEach(h=>S(h,s));else{const h=c.listSamplers();S(c,s),h.forEach(u=>S(u,s))}}if(n.has(A.MATERIAL)&&i.listMaterials().forEach(c=>S(c,s)),n.has(A.TEXTURE)&&(i.listTextures().forEach(c=>S(c,s)),t.keepSolidTextures||await xs(r)),n.has(A.ACCESSOR)&&i.listAccessors().forEach(c=>S(c,s)),n.has(A.BUFFER)&&i.listBuffers().forEach(c=>S(c,s)),o.removeEventListener("node:dispose",f),l.empty())a.debug(`${B}: No unused properties found.`);else{const c=l.entries().map(([h,u])=>`${h} (${u})`).join(", ");a.info(`${B}: Removed types... ${c}`)}a.debug(`${B}: Complete.`)})}class Ns{constructor(){this.disposed={}}empty(){for(const t in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(t){this.disposed[t.propertyType]=this.disposed[t.propertyType]||0,this.disposed[t.propertyType]++}}function S(e,t){const n=e.listParents().filter(r=>!(r instanceof pe||r instanceof $e)),s=t&&!St(e.getExtras());!n.length&&!s&&e.dispose()}function Ze(e,t,n){for(const s of e.listEdges()){const r=s.getParent();r.propertyType===t&&S(r,n)}}function zt(e,t,n){if(t.listChildren().forEach(i=>zt(e,i,n)),t instanceof ln)return;const s=e.listParentEdges(t).some(i=>{const o=i.getParent().propertyType;return o!==A.ROOT&&o!==A.SCENE&&o!==A.NODE}),r=e.listChildren(t).length===0,a=n&&!St(t.getExtras());r&&!s&&!a&&t.dispose()}function et(e,t){for(const n of t)e.setAttribute(n,null)}function Cs(e){const t=e.getIndices(),n=t&&t.getArray(),s=e.listAttributes()[0];if(!(!n||!s)&&t.getCount()===s.getCount()){for(let r=0,a=n.length;r<a;r++)if(r!==n[r])return;e.setIndices(null)}}function Ss(e,t){const n=[];for(const s of e.listSemantics())(s==="NORMAL"&&!t.has(s)||s==="TANGENT"&&!t.has(s)||s.startsWith("TEXCOORD_")&&!t.has(s)||s.startsWith("COLOR_")&&s!=="COLOR_0")&&n.push(s);return n}function kt(e,t,n,s=new Set){const a=e.getGraph().listChildEdges(n),i=new Set;for(const f of a)f.getChild()instanceof Ne&&i.add(f.getName());for(const f of a){const c=f.getName(),h=f.getChild();h instanceof vt&&i.has(c.replace(/Info$/,""))&&s.add(`TEXCOORD_${h.getTexCoord()}`),h instanceof Ne&&c.match(/normalTexture/i)&&s.add("TANGENT"),h instanceof _t&&kt(e,t,h,s)}const o=n instanceof Tt&&!n.getExtension("KHR_materials_unlit"),l=t.getMode()===P.Mode.POINTS;return o&&!l&&s.add("NORMAL"),s}function Os(e,t){const n=Is(e),s=new Set(n.map(l=>l.getTexCoord())),r=Array.from(s).sort(),a=new Map(r.map((l,f)=>[l,f])),i=new Map(r.map((l,f)=>[`TEXCOORD_${l}`,`TEXCOORD_${f}`]));for(const l of n){const f=l.getTexCoord();l.setTexCoord(a.get(f))}for(const l of t){const f=l.listSemantics().filter(c=>c.startsWith("TEXCOORD_")).sort();o(l,f),l.listTargets().forEach(c=>o(c,f))}function o(l,f){for(const c of f){const h=l.getAttribute(c);if(!h)continue;const u=i.get(c);u!==c&&(l.setAttribute(u,h),l.setAttribute(c,null))}}}async function xs(e){const t=e.getRoot(),n=e.getGraph(),s=e.getLogger(),a=t.listTextures().map(async i=>{var o;const l=await Rs(i);if(!l)return;ws(i)==="srgb"&&cn.convertSRGBToLinear(l,l);const f=i.getName()||i.getURI(),c=(o=i.getSize())==null?void 0:o.join("x"),h=Ms(i);for(const u of n.listParentEdges(i)){const g=u.getParent();g!==t&&js(g,l,u.getName(),s)&&u.dispose()}i.listParents().length===1&&(i.dispose(),s.debug(`${B}: Removed solid-color texture "${f}" (${c}px ${h.join(", ")})`))});await Promise.all(a)}function js(e,t,n,s){if(e instanceof Tt)switch(n){case"baseColorTexture":return e.setBaseColorFactor(Ts(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(us([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Oe;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return Rt(jt(xt(),t,[.5,.5,1,1]))<=Oe}return s.warn(`${B}: Detected single-color ${n} texture. Pruning ${n} not yet supported.`),!1}async function Rs(e){const t=await Ps(e);if(!t)return null;const n=[1/0,1/0,1/0,1/0],s=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[a,i]=t.shape;for(let o=0;o<a;o++){for(let l=0;l<i;l++)for(let f=0;f<4;f++)n[f]=Math.min(n[f],t.get(o,l,f)),s[f]=Math.max(s[f],t.get(o,l,f));if(Rt(jt(r,s,n))/255>Oe)return null}return vs(r,ys(r,s,n),.5/255)}async function Ps(e){try{return await Yn(e.getImage(),e.getMimeType())}catch{return null}}const tt=2**32-1;var C;(function(e){e.RENDER="render",e.RENDER_CACHED="render-cached",e.UPLOAD="upload",e.UPLOAD_NAIVE="upload-naive",e.DISTINCT="distinct",e.DISTINCT_POSITION="distinct-position",e.UNUSED="unused"})(C||(C={}));function ue(e,t){const n=e.getAttribute("POSITION"),s=e.getIndices();switch(t){case C.RENDER:return s?s.getCount():n.getCount();case C.RENDER_CACHED:return s?new Set(s.getArray()).size:n.getCount();case C.UPLOAD_NAIVE:case C.UPLOAD:return n.getCount();case C.DISTINCT:case C.DISTINCT_POSITION:return zs(t);case C.UNUSED:return s?n.getCount()-new Set(s.getArray()).size:0;default:return ks(t)}}function zs(e){throw new Error(`Not implemented: ${e}`)}function ks(e){throw new Error(`Unexpected value: ${e}`)}function $s(e,t,n){const s=Le.fromGraph(e.getGraph());(!t||!n)&&([t,n]=Ls(e));const r=e.getIndices(),a=r?r.getArray():null,i=ue(e,C.RENDER),o=s.createAccessor(),l=i,f=Ct(l,n);for(let h=0;h<l;h++)f[h]=t[a?a[h]:h];e.setIndices(o.setArray(f));const c=Nt(e);for(const h of e.listAttributes()){const u=ee(s,h);xe(h,r,t,u,n),e.swap(h,u)}for(const h of e.listTargets())for(const u of h.listAttributes()){const g=ee(s,u);xe(u,r,t,g,n),h.swap(u,g)}r&&r.listParents().length===1&&r.dispose();for(const h of c)h.listParents().length===1&&h.dispose();return e}function xe(e,t,n,s,r){const a=e.getElementSize(),i=e.getArray(),o=t?t.getArray():null,l=t?t.getCount():e.getCount(),f=new i.constructor(r*a),c=new Uint8Array(r);for(let h=0;h<l;h++){const u=o?o[h]:h,g=n[u];if(!c[g]){for(let d=0;d<a;d++)f[g*a+d]=i[u*a+d];c[g]=1}}return s.setArray(f)}function Ls(e){const t=ue(e,C.UPLOAD),n=e.getIndices(),s=n?n.getArray():null;if(!n||!s)return[ss(t,1e6),t];const r=new Uint32Array(t).fill(tt);let a=0;for(let i=0;i<s.length;i++){const o=s[i];r[o]===tt&&(r[o]=a++)}return[r,a]}Me.ComponentType;P.Mode;P.Mode;const se="reorder",Vs={target:"size",cleanup:!0};function Us(e){const t=H(Vs,e),n=t.encoder;if(!n)throw new Error(`${se}: encoder dependency required — install "meshoptimizer".`);return D(se,async s=>{const r=s.getLogger();await n.ready;const a=Fs(s);for(const i of a.indicesToAttributes.keys()){let o=i.getArray();o instanceof Uint32Array?o=o.slice():o=new Uint32Array(o);const[l,f]=n.reorderMesh(o,a.indicesToMode.get(i)===P.Mode.TRIANGLES,t.target==="size"),c=ee(s,i);c.setArray(f<=65534?new Uint16Array(o):o);for(const h of a.indicesToAttributes.get(i)){const u=ee(s,h);xe(h,i,l,u,f);for(const g of a.indicesToPrimitives.get(i)){g.getIndices()===i&&g.swap(i,c),g.swap(h,u);for(const d of g.listTargets())d.swap(h,u)}}}t.cleanup&&await s.transform(Pt({propertyTypes:[A.ACCESSOR],keepAttributes:!0,keepIndices:!0})),a.indicesToAttributes.size?r.debug(`${se}: Complete.`):r.warn(`${se}: No qualifying primitives found; may need to weld first.`)})}function Fs(e){const t=new Map,n=new Te,s=new Te,r=new Te;for(const a of e.getRoot().listMeshes())for(const i of a.listPrimitives()){const o=i.getIndices();if(o){t.set(o,i.getMode()),n.add(o,i);for(const l of Nt(i))s.add(o,l),r.add(l,i)}}return{indicesToPrimitives:n,indicesToAttributes:s,indicesToMode:t,attributesToPrimitives:r}}function Ds(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw new Error("Limit must be positive multiple of four.");const n=e.getAttribute("POSITION").getCount(),s=e.listSemantics().filter(f=>f.startsWith("WEIGHTS_")).length,r=new Uint16Array(s*4),a=new Float32Array(s*4),i=new Float32Array(s*4),o=new Uint32Array(s*4),l=new Uint32Array(s*4);for(let f=0;f<n;f++){fe(e,f,"WEIGHTS",a),fe(e,f,"JOINTS",o);for(let c=0;c<s*4;c++)r[c]=c;r.sort((c,h)=>a[c]>a[h]?-1:1);for(let c=0;c<r.length;c++)i[c]=a[r[c]],l[c]=o[r[c]];he(e,f,"WEIGHTS",i),he(e,f,"JOINTS",l)}for(let f=s;f*4>t;f--){const c=e.getAttribute(`WEIGHTS_${f-1}`),h=e.getAttribute(`JOINTS_${f-1}`);e.setAttribute(`WEIGHTS_${f-1}`,null),e.setAttribute(`JOINTS_${f-1}`,null),c.listParents().length===1&&c.dispose(),h.listParents().length===1&&h.dispose()}Bs(e)}function Bs(e){if(!qs(e))return;const t=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter(h=>h.startsWith("WEIGHTS_")).length,s=e.getAttribute("WEIGHTS_0"),r=s.getArray(),a=s.getComponentType(),i=s.getNormalized(),o=i?a:void 0,l=i?V.decodeNormalizedInt(1,a):Number.EPSILON,f=new Uint32Array(n*4).fill(0),c=r.slice(0,n*4).fill(0);for(let h=0;h<t;h++){fe(e,h,"JOINTS",f),fe(e,h,"WEIGHTS",c,o);let u=nt(c,o);if(u!==0&&u!==1){if(Math.abs(1-u)>l)for(let g=0;g<c.length;g++)if(i){const d=V.decodeNormalizedInt(c[g],a);c[g]=V.encodeNormalizedInt(d/u,a)}else c[g]/=u;if(u=nt(c,o),i&&u!==1){for(let g=c.length-1;g>=0;g--)if(c[g]>0){const d=1-u;c[g]+=Math.sign(d)*V.encodeNormalizedInt(Math.abs(d),a);break}}}for(let g=c.length-1;g>=0;g--)c[g]===0&&(f[g]=0);he(e,h,"JOINTS",f),he(e,h,"WEIGHTS",c,o)}}function fe(e,t,n,s,r){let a;const i=[0,0,0,0];for(let o=0;a=e.getAttribute(`${n}_${o}`);o++){a.getElement(t,i);for(let l=0;l<4;l++)r?s[o*4+l]=V.encodeNormalizedInt(i[l],r):s[o*4+l]=i[l]}return s}function he(e,t,n,s,r){let a;const i=[0,0,0,0];for(let o=0;a=e.getAttribute(`${n}_${o}`);o++){for(let l=0;l<4;l++)r?i[l]=V.decodeNormalizedInt(s[o*4+l],r):i[l]=s[o*4+l];a.setElement(t,i)}}function nt(e,t){let n=0;for(let s=0;s<e.length;s++)t?n+=V.decodeNormalizedInt(e[s],t):n+=e[s];return n}function qs(e){const t=e.listSemantics().filter(r=>r.startsWith("WEIGHTS_")).map(r=>e.getAttribute(r)),n=t.map(r=>r.getNormalized()),s=t.map(r=>r.getComponentType());return new Set(n).size===1&&new Set(s).size===1}const U="quantize",Gs=[Int8Array,Int16Array,Int32Array],{TRANSLATION:Ws,ROTATION:Hs,SCALE:Xs,WEIGHTS:Ks}=$e.TargetPath,Qs=[Ws,Hs,Xs],ie={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};function Ue(e=ie){const t=H(ie,q({patternTargets:e.pattern||ie.pattern},e));return D(U,async n=>{const s=n.getLogger(),r=n.getRoot();let a;t.quantizationVolume==="scene"&&(a=rt(rr(r.listMeshes().map(at))));for(const o of n.getRoot().listMeshes()){t.quantizationVolume==="mesh"&&(a=rt(at(o))),a&&t.pattern.test("POSITION")&&(Js(n,o,a),er(o,1/a.scale));for(const l of o.listPrimitives()){const f=ue(l,C.RENDER),c=ue(l,C.UPLOAD);f<c/2&&$s(l),st(n,l,a,t);for(const h of l.listTargets())st(n,h,a,t)}}r.listMeshes().flatMap(o=>o.listPrimitives()).some($t)&&n.createExtension(At).setRequired(!0),t.cleanup&&await n.transform(Pt({propertyTypes:[A.ACCESSOR,A.SKIN,A.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),fs({propertyTypes:[A.ACCESSOR,A.MATERIAL,A.SKIN],keepUniqueNames:!0})),s.debug(`${U}: Complete.`)})}function st(e,t,n,s){const r=t instanceof un,a=e.getLogger();for(const i of t.listSemantics()){if(!r&&!s.pattern.test(i)||r&&!s.patternTargets.test(i))continue;const o=t.getAttribute(i),{bits:l,ctor:f}=nr(i,o,a,s);if(!f)continue;if(l<8||l>16)throw new Error(`${U}: Requires bits = 8–16.`);if(o.getComponentSize()<=l/8)continue;const c=o.clone();if(i==="POSITION"){const h=n.scale,u=[];t instanceof P?rs(u,me(n)):as(u,[1/h,1/h,1/h]);for(let g=0,d=[0,0,0],m=c.getCount();g<m;g++)c.getElement(g,d),c.setElement(g,cs(d,d,u))}tr(c,f,l),t.setAttribute(i,c)}if(s.normalizeWeights&&t.getAttribute("WEIGHTS_0")&&Ds(t,1/0),t instanceof P&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){const i=t.getIndices();i.setArray(new Uint16Array(i.getArray()))}}function rt(e){const{min:t,max:n}=e,s=Math.max((n[0]-t[0])/2,(n[1]-t[1])/2,(n[2]-t[2])/2);return{offset:[t[0]+(n[0]-t[0])/2,t[1]+(n[1]-t[1])/2,t[2]+(n[2]-t[2])/2],scale:s}}function Js(e,t,n){const s=me(n);for(const r of t.listParents()){if(!(r instanceof on))continue;const a=r.listParents().filter(u=>u instanceof $e),i=a.some(u=>Qs.includes(u.getTargetPath())),o=r.listChildren().length>0,l=r.getSkin();if(l){r.setSkin(Ys(l,n));continue}const f=r.getExtension("EXT_mesh_gpu_instancing");if(f){r.setExtension("EXT_mesh_gpu_instancing",Zs(f,n));continue}let c;o||i?(c=e.createNode("").setMesh(t),r.addChild(c).setMesh(null),a.filter(u=>u.getTargetPath()===Ks).forEach(u=>u.setTargetNode(c))):c=r;const h=c.getMatrix();Ve(h,h,s),c.setMatrix(h)}}function Ys(e,t){e=e.clone();const n=me(t),s=e.getInverseBindMatrices().clone(),r=[];for(let a=0,i=s.getCount();a<i;a++)s.getElement(a,r),Ve(r,r,n),s.setElement(a,r);return e.setInverseBindMatrices(s)}function Zs(e,t){var n,s,r;if(!e.getAttribute("TRANSLATION")&&!e.getAttribute("ROTATION")&&!e.getAttribute("SCALE"))return e;e=e.clone();const a=(n=e.getAttribute("TRANSLATION"))==null?void 0:n.clone(),i=(s=e.getAttribute("ROTATION"))==null?void 0:s.clone(),o=(r=e.getAttribute("SCALE"))==null?void 0:r.clone(),l=a||i||o,f=[0,0,0],c=[0,0,0,1],h=[1,1,1],u=[0,0,0],g=[0,0,0,1],d=[1,1,1],m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],p=me(t);for(let y=0,T=l.getCount();y<T;y++)V.compose(a?a.getElement(y,u):f,i?i.getElement(y,g):c,o?o.getElement(y,d):h,m),Ve(m,m,p),V.decompose(m,u,g,d),a&&a.setElement(y,u),i&&i.setElement(y,g),o&&o.setElement(y,d);return a&&e.setAttribute("TRANSLATION",a),i&&e.setAttribute("ROTATION",i),o&&e.setAttribute("SCALE",o),e}function er(e,t){for(const n of e.listPrimitives()){let s=n.getMaterial();if(!s)continue;let r=s.getExtension("KHR_materials_volume");!r||r.getThicknessFactor()<=0||(r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),s=s.clone().setExtension("KHR_materials_volume",r),n.setMaterial(s))}}function tr(e,t,n){const s=new t(e.getArray().length),r=Gs.includes(t)?1:0,a=n-r,i=t.BYTES_PER_ELEMENT*8-r,o=Math.pow(2,a)-1,l=i-a,f=2*a-i,c=[r>0?-1:0,1];for(let h=0,u=0,g=[];h<e.getCount();h++){e.getElement(h,g);for(let d=0;d<g.length;d++){let m=ar(g[d],c);m=Math.round(Math.abs(m)*o),m=m<<l|m>>f,s[u++]=m*Math.sign(g[d])}}e.setArray(s).setNormalized(!0).setSparse(!1)}function nr(e,t,n,s){const r=t.getMinNormalized([]),a=t.getMaxNormalized([]);let i,o;if(e==="POSITION")i=s.quantizePosition,o=i<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")i=s.quantizeNormal,o=i<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))i=s.quantizeColor,o=i<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some(l=>l<0)||a.some(l=>l>1))return n.warn(`${U}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=s.quantizeTexcoord,o=i<=8?Uint8Array:Uint16Array}else{if(e.startsWith("JOINTS_"))return i=Math.max(...t.getMax([]))<=255?8:16,o=i<=8?Uint8Array:Uint16Array,t.getComponentSize()>i/8&&t.setArray(new o(t.getArray())),{bits:-1};if(e.startsWith("WEIGHTS_")){if(r.some(l=>l<0)||a.some(l=>l>1))return n.warn(`${U}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=s.quantizeWeight,o=i<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some(l=>l<-1)||a.some(l=>l>1))return n.warn(`${U}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};i=s.quantizeGeneric,o=r.some(l=>l<0)?o=i<=8?Int8Array:Int16Array:o=i<=8?Uint8Array:Uint16Array}else throw new Error(`${U}: Unexpected semantic, "${e}".`)}return{bits:i,ctor:o}}function at(e){const t=[],n=[];for(const r of e.listPrimitives()){const a=r.getAttribute("POSITION");a&&t.push(a);for(const i of r.listTargets()){const o=i.getAttribute("POSITION");o&&n.push(o)}}if(t.length===0)throw new Error(`${U}: Missing "POSITION" attribute.`);const s=it(t,3);if(n.length>0){const{min:r,max:a}=it(n,3);Ce(s.min,s.min,Ce(r,Qe(r,r,2),[0,0,0])),Se(s.max,s.max,Se(a,Qe(a,a,2),[0,0,0]))}return s}function sr(e,t){const n=t.getComponentSize();if(e==="POSITION"||e==="NORMAL"||e==="TANGENT")return n<4;if(e.startsWith("TEXCOORD_")){const s=t.getComponentType(),r=t.getNormalized();return n<4&&!(r&&s===Me.ComponentType.UNSIGNED_BYTE)&&!(r&&s===Me.ComponentType.UNSIGNED_SHORT)}return!1}function $t(e){for(const t of e.listSemantics()){const n=e.getAttribute("POSITION");if(sr(t,n))return!0}return e.propertyType===A.PRIMITIVE?e.listTargets().some($t):!1}function it(e,t){const n=new Array(t).fill(1/0),s=new Array(t).fill(-1/0),r=[],a=[];for(const i of e){i.getMinNormalized(r),i.getMaxNormalized(a);for(let o=0;o<t;o++)n[o]=Math.min(n[o],r[o]),s[o]=Math.max(s[o],a[o])}return{min:n,max:s}}function rr(e){const t=e[0];for(const n of e)Ce(t.min,t.min,n.min),Se(t.max,t.max,n.max);return t}function me(e){return is([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function ar(e,t){return Math.min(Math.max(e,t[0]),t[1])}const ir=q({level:"high"},ie),ot="meshopt";function Lt(e){const t=H(ir,e),n=t.encoder;if(!n)throw new Error(`${ot}: encoder dependency required — install "meshoptimizer".`);return D(ot,async s=>{let r,a,i=t.quantizeNormal;s.getRoot().listAccessors().length!==0&&(t.level==="medium"?(r=/.*/,a=/.*/):(r=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR)(_\d+)?$/,a=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR|NORMAL|TANGENT)(_\d+)?$/,i=Math.min(i,8)),await s.transform(Us({encoder:n,target:"size"}),Ue(q({},t,{pattern:r,patternTargets:a,quantizeNormal:i}))),s.createExtension(ae).setRequired(!0).setEncoderOptions({method:t.level==="medium"?ae.EncoderMethod.QUANTIZE:ae.EncoderMethod.FILTER}))})}const je="unweld",or={};function lr(e=or){return D(je,t=>{const n=t.getLogger(),s=new Map;for(const r of t.getRoot().listMeshes())for(const a of r.listPrimitives())cr(a,s);n.debug(`${je}: Complete.`)})}function cr(e,t=new Map){const n=e.getIndices();if(!n)return;const s=e.getGraph(),r=Le.fromGraph(s),a=r.getLogger(),i=e.getAttribute("POSITION").getCount();for(const l of e.listAttributes())e.swap(l,lt(r,l,n,t)),l.listParents().length===1&&l.dispose();for(const l of e.listTargets())for(const f of l.listAttributes())l.swap(f,lt(r,f,n,t)),f.listParents().length===1&&f.dispose();const o=e.getAttribute("POSITION").getCount();a.debug(`${je}: ${ts(i,o)} vertices.`),e.setIndices(null),n.listParents().length===1&&n.dispose()}function lt(e,t,n,s){if(s.has(t)&&s.get(t).has(n))return s.get(t).get(n);const r=t.getArray(),a=r.constructor,i=new a(n.getCount()*t.getElementSize()),o=n.getArray(),l=t.getElementSize();for(let c=0,h=n.getCount();c<h;c++)for(let u=0;u<l;u++)i[c*l+u]=r[o[c]*l+u];s.has(t)||s.set(t,new Map);const f=ee(e,t).setArray(i);return s.get(t).set(n,f),f}var ct;(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(ct||(ct={}));const ur=1e-6;function fr(e,t,n,s=1e-4){const r=t.length/e.length,a=new Array(r).fill(0),i=new Array(r).fill(0),o=new Array(r).fill(0),l=new Array(r).fill(0),f=e.length-1;let c=1;for(let h=1;h<f;++h){const u=e[c-1],g=e[h],d=e[h+1],m=(g-u)/(d-u);let p=!1;if(g!==d&&(h!==1||g!==e[0]))if(Z(t,c-1,l),Z(t,h,i),Z(t,h+1,o),n==="slerp"){const y=dr(a,l,o,m),T=ft(l,i)+ft(i,o);p=!re(i,y,s)||T+Number.EPSILON>=Math.PI}else if(n==="lerp"){const y=gr(a,l,o,m);p=!re(i,y,s)}else n==="step"&&(p=!re(i,l)||!re(i,o));p&&(h!==c&&(e[c]=e[h],ut(t,c,Z(t,h,a))),c++)}return f>0&&(e[c]=e[f],ut(t,c,Z(t,f,a)),c++),c}function Z(e,t,n){for(let s=0,r=n.length;s<r;s++)n[s]=e[t*r+s];return n}function ut(e,t,n){for(let s=0,r=n.length;s<r;s++)e[t*r+s]=n[s]}function re(e,t,n=0){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(Math.abs(e[s]-t[s])>n)return!1;return!0}function hr(e,t,n){return e*(1-n)+t*n}function gr(e,t,n,s){for(let r=0;r<t.length;r++)e[r]=hr(t[r],n[r],s);return e}function dr(e,t,n,s){let r=t[0],a=t[1],i=t[2],o=t[3],l=n[0],f=n[1],c=n[2],h=n[3],u,g,d,m,p;return g=r*l+a*f+i*c+o*h,g<0&&(g=-g,l=-l,f=-f,c=-c,h=-h),1-g>ur?(u=Math.acos(g),d=Math.sin(u),m=Math.sin((1-s)*u)/d,p=Math.sin(s*u)/d):(m=1-s,p=s),e[0]=m*r+p*l,e[1]=m*a+p*f,e[2]=m*i+p*c,e[3]=m*o+p*h,e}function ft(e,t){const n=pr(e,t);return Math.acos(2*n*n-1)}function pr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}Promise.resolve();P.Mode;var Re;(function(e){e.LANCZOS3="lanczos3",e.LANCZOS2="lanczos2"})(Re||(Re={}));Re.LANCZOS3;const L="tangents",ht={overwrite:!1};function mr(e=ht){const t=H(ht,e);if(!t.generateTangents)throw new Error(`${L}: generateTangents callback required — install "mikktspace".`);return D(L,n=>{const s=n.getLogger(),r=new Map,a=new Map;let i=0;for(const o of n.getRoot().listMeshes()){const l=o.getName(),f=o.listPrimitives();for(let c=0;c<f.length;c++){const h=f[c];if(!br(h,s,l,c,t.overwrite))continue;const u=yr(h),g=h.getAttribute("POSITION").getArray(),d=h.getAttribute("NORMAL").getArray(),m=h.getAttribute(u).getArray(),p=r.get(g)||be();r.set(g,p);const y=r.get(d)||be();r.set(d,y);const T=r.get(m)||be();r.set(m,T);const v=h.getAttribute("TANGENT");v&&v.listParents().length===2&&v.dispose();const b=`${p}|${y}|${T}`;let _=a.get(b);if(_){s.debug(`${L}: Found cache for primitive ${c} of mesh "${l}".`),h.setAttribute("TANGENT",_),i++;continue}s.debug(`${L}: Generating for primitive ${c} of mesh "${l}".`);const E=h.getAttribute("POSITION").getBuffer(),x=t.generateTangents(g instanceof Float32Array?g:new Float32Array(g),d instanceof Float32Array?d:new Float32Array(d),m instanceof Float32Array?m:new Float32Array(m));for(let $=3;$<x.length;$+=4)x[$]*=-1;_=n.createAccessor().setBuffer(E).setArray(x).setType("VEC4"),h.setAttribute("TANGENT",_),a.set(b,_),i++}}i?s.debug(`${L}: Complete.`):s.warn(`${L}: No qualifying primitives found. See debug output.`)})}function yr(e){const t=e.getMaterial();if(!t)return"TEXCOORD_0";const n=t.getNormalTextureInfo();if(!n)return"TEXCOORD_0";const r=`TEXCOORD_${n.getTexCoord()}`;return e.getAttribute(r)?r:"TEXCOORD_0"}function br(e,t,n,s,r){return e.getMode()!==P.Mode.TRIANGLES||!e.getAttribute("POSITION")||!e.getAttribute("NORMAL")||!e.getAttribute("TEXCOORD_0")?(t.debug(`${L}: Skipping primitive ${s} of mesh "${n}": primitives must have attributes=[POSITION, NORMAL, TEXCOORD_0] and mode=TRIANGLES.`),!1):e.getAttribute("TANGENT")&&!r?(t.debug(`${L}: Skipping primitive ${s} of mesh "${n}": TANGENT found.`),!1):e.getIndices()?(t.warn(`${L}: Skipping primitive ${s} of mesh "${n}": primitives must be unwelded.`),!1):!0}async function Ar(e,t,n,s={}){var y;const{remapMaterials:r,animationEvents:a,textureOptions:i,optimizeOptions:o}=n,l=await t.readBinary(e),f=l.getRoot().listExtensionsUsed(),c=f.some(T=>T.extensionName==="EXT_meshopt_compression"),h=f.some(T=>T.extensionName==="KHR_mesh_quantization");if((i==null?void 0:i.textureType)==="ktx2"&&s.ktx2Encode){const T=l.getRoot().listTextures();T.length>0&&l.createExtension(fn).setRequired(!0);const v=T.filter(b=>b.getMimeType()!=="image/ktx2");await Promise.all(v.map(async b=>{b.setMimeType("image/ktx2");const _=b.getImage(),E=await s.ktx2Encode(_.buffer,{isUASTC:i.mode==="UASTC",qualityLevel:i.quality??255});b.setImage(E)}))}r&&l.getRoot().listMaterials().forEach((T,v)=>{if(r[v]){const b=l.createExtension(Ae).createGlTFRemapping().setRefId(r[v].refId);T.setExtension(Ae.EXTENSION_NAME,b)}}),a&&l.getRoot().listAnimations().forEach((T,v)=>{if(a[v]){const b=l.createExtension(He).createAnimationEvent().setEvents(a[v]);T.setExtension(He.EXTENSION_NAME,b)}});const g=[];o!=null&&o.meshopt&&!c&&(await oe.ready,g.push(Lt({encoder:oe}))),o!=null&&o.meshQuantize&&!h&&g.push(Ue({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),g.length>0&&await l.transform(...g);const d=await t.writeJSON(l,{format:hn.GLB});if(s.resolveRef&&r){const T=Ae.EXTENSION_NAME;(y=d.json.materials)==null||y.forEach(v=>{var _;const b=(_=v.extensions)==null?void 0:_[T];if(b!=null&&b.refId){const E=s.resolveRef(b.refId);E&&(v.extensions[T]={url:E.url})}})}return{name:n.name.replace(/\.[^.]+$/,"")+".glb",content:wt(d)}}const gt=Bt("div",{color:"$gray10"}),vr=pt(({asset:e,index:t,originMaterial:n})=>{const{assetStore:s}=Et(),r=e.remapMaterials[t];let a=Object.values(s.assets);a=a.filter(o=>o.getMetaConfig().type==="Material"&&!o.isSubAsset);const i=s.assets[r==null?void 0:r.refId];return I.jsx(qt,{dropLayer:mt.Material,assets:a,customFilter:o=>o.mainId!==e.id,onSelect:o=>{(!i||o.engineObject!==i.engineObject)&&e.replaceMaterial(t,o.getCurrentRef())},onDelete:()=>{r&&e.resetMaterial(t)},onLocate:()=>{r&&r.refId&&s.selectAsset(r.refId)},label:n.name,value:i==null?void 0:i.name,asset:i})}),_r=pt(({asset:e})=>{var o;const t=e.engineObject.materials,{inspectorFacade:n}=Et(),s=e.glTFInfo,r=(o=s.issues)==null?void 0:o.messages,{t:a}=Gt();function i(l,f){n.assetChange(e.id,l,f,"asset-meta")}return I.jsxs(I.Fragment,{children:[I.jsxs(Fe,{title:a("asset.gltf.basic-info"),defaultOpen:!0,children:[s.triangles?I.jsx(te,{label:a("asset.gltf.triangles"),children:I.jsx(ye,{value:s.triangles,disabled:!0})}):null,s.drawcall?I.jsx(te,{label:a("asset.gltf.drawcall"),children:I.jsx(ye,{value:s.drawcall,disabled:!0})}):null,I.jsx(ne,{label:a("asset.gltf.compute-tangents"),value:e.needComputeTangents,onChange:l=>{i("needComputeTangents",l)},checkboxLabel:I.jsx(gt,{children:a("asset.gltf.refresh-tip")})}),I.jsx(ne,{label:a("asset.gltf.keep-mesh-data"),value:e.params.keepMeshData,onChange:l=>{e.params={...e.params,keepMeshData:l}},checkboxLabel:I.jsx(gt,{children:a("asset.gltf.refresh-tip")})})]}),I.jsx(De,{}),r?I.jsxs(Wt.Fragment,{children:[I.jsxs(Fe,{title:`${a("asset.gltf.issues")}: ${r.length}`,defaultOpen:!1,children:[r.slice(0,15).map((l,f)=>I.jsx(te,{label:l.pointer,children:I.jsx(ye,{value:l.message,css:{color:"red"},disabled:!0})},f)),r.length>15?I.jsx(te,{label:"..."}):null]}),I.jsx(De,{})]}):null,I.jsx(Be,{label:a("asset.gltf.remapped-materials"),children:t==null?void 0:t.map((l,f)=>I.jsx(vr,{originMaterial:l,asset:e,index:f},`${e.id}-${f}`))}),I.jsxs(Be,{label:a("asset.gltf.compression"),children:[!e.optimize.meshopt&&I.jsx(ne,{label:a("asset.gltf.quantize"),value:e.optimize.meshQuantize,onChange:l=>{Tracert.click("c351684.d417982",{checked:l}),i("optimize",{...e.optimize,meshQuantize:l})}}),I.jsx(ne,{label:a("asset.gltf.meshopt"),value:e.optimize.meshopt,onChange:l=>{Tracert.click("c351684.d417983",{checked:l}),i("optimize",{...e.optimize,meshopt:l})}})]})]})});function ge(e){return/^(?:http|blob|data:|\/)/.test(e)}function Vt(e){return/^data:(.+?);base64,/.test(e)}function de(e,t){return t.charAt(0)==="."?dt(e+t):dt(e.substring(0,e.lastIndexOf("/")+1)+t)}function dt(e){const t=[],n=e.split("/");for(let s=0;s<n.length;s++){const r=n[s];if(!(!r||r===".")){if(r===".."){t.length>0&&t.pop();continue}t.push(r)}}return t.join("/")}async function Tr(e,t){const n=JSON.parse(await e.text()),s=n.images,r={},a="",i=[];if(s)for(let l=0;l<s.length;l++){const c=s[l].uri;if(c)if(ge(c))i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}));else{const h=de(a,c);i.push(t[h].arrayBuffer().then(u=>{r[c]=new Uint8Array(u)}))}}const o=n.buffers;if(o)for(let l=0;l<o.length;l++){const c=o[l].uri;if(c)if(!ge(c)&&!Vt(c)){const h=de(a,c);i.push(t[h].arrayBuffer().then(u=>{r[c]=new Uint8Array(u)}))}else i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}))}return await Promise.all(i),bn({json:n,resources:r})}async function Er(e){const t={uploadFiles:[],errors:[]};for(const n in e){const s=e[n],a=s.name.toLowerCase();if(a.endsWith(".glb")||a.endsWith(".fbx"))t.uploadFiles.push({main:s});else if(a.endsWith(".gltf")){const i=await wr(s,e);typeof i=="string"?t.errors.push(i):t.uploadFiles.push(i)}}return t}async function wr(e,t){const n=JSON.parse(await e.text()),s=n.images,r=n.buffers,a="",i={main:e,subFiles:{},postfix:".glb"};if(s)for(let o=0;o<s.length;o++){const f=s[o].uri;if(f&&!ge(f)){const c=de(a,f);if(t[c])i.subFiles[c]=t[c];else return`${f} is not found in the files.`}}if(r)for(let o=0;o<r.length;o++){const f=r[o].uri;if(f&&!ge(f)&&!Vt(f)){const c=de(a,f);if(t[c])i.subFiles[c]=t[c];else return`${f} is not found in the files.`}}return i}async function Ir(e,t){const n=Ht(e.main,"model.gltf"),s=n.name.replace(/\.[^.]+$/,".glb");if(n.name.toLocaleLowerCase().endsWith(".gltf")){const r=e.subFiles??{},a=await Tr(n,r);return new File([a.buffer],s)}return n}class Pe{static update(t,n){!this.entity&&(this.entity=t.createChild("glTF"));const s=this.tempCloneEntity=n.engineObject.instantiateSceneRoot();this.entity.addChild(s)}static clear(){this.entity.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy()}}w(Pe,"entity"),w(Pe,"tempCloneEntity");var Mr=Object.defineProperty,Nr=Object.getOwnPropertyDescriptor,z=(e,t,n,s)=>{for(var r=s>1?void 0:s?Nr(t,n):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(s?i(t,n,r):i(r))||r);return s&&r&&Mr(t,n,r),r};class R extends dn{constructor(){super();w(this,"animationNames",[]);w(this,"frameTime",0);w(this,"duration",0);w(this,"playing",!1);w(this,"animationIndex",0);w(this,"selectedClip");w(this,"_updateComponent");w(this,"_clips",[]);yt(this)}setViewAsset(n,s){const{animations:r=[]}=n.engineObject;this._clips=r,this.animationIndex=0,this.animationNames=r.map(i=>i.name),this._entity=n.instantiateEngineObject(),s.addChild(this._entity);const a=this;r.length>0&&(this._updateComponent=this._entity.addComponent(class extends Xt{onUpdate(i){a._onUpdate(i)}})),this.duration=0}stopViewAsset(){var n;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(n=this._updateComponent)==null||n.destroy(),this.animationNames=null}selectAnimation(n){this.selectedClip=this._clips[n],this.frameTime=0,this.duration=this.selectedClip.length,this.animationIndex=n,this._sampleAnimation()}setFrameTime(n){this.frameTime=n,this._sampleAnimation()}playAnimation(){this.selectedClip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(n){!this.playing||!this.selectedClip||!this.duration||(this.frameTime+=n,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this.selectedClip._sampleAnimation(this._entity.children[0],this.frameTime)}catch(n){console.warn(n)}}}z([j],R.prototype,"animationNames",2);z([j],R.prototype,"frameTime",2);z([j],R.prototype,"duration",2);z([j],R.prototype,"playing",2);z([j],R.prototype,"animationIndex",2);z([G],R.prototype,"selectAnimation",1);z([G],R.prototype,"setFrameTime",1);z([G],R.prototype,"playAnimation",1);z([G],R.prototype,"pauseAnimation",1);z([G],R.prototype,"_onUpdate",1);function ze(e){return typeof e=="object"&&e!==null||typeof e=="function"}function ke(e){return e.getComponentsIncludeChildren(Kt,[])}function Cr(e){if(!e)return[];const t=[],n=new Set;for(const s of ke(e)){const r=s.animatorController;!ze(r)||n.has(r)||(n.add(r),t.push(r))}return t}function Sr(e,t,n){if(!e||!t||!n)return;const s=ke(e),r=ke(t),a=Math.min(s.length,r.length);for(let i=0;i<a;i++){const o=s[i].animatorController,l=r[i].animatorController;if(!ze(o)||!ze(l))continue;const f=n.engineObjectToAssetMap.get(o);f&&n.engineObjectToAssetMap.set(l,f)}}var Or=Object.defineProperty,xr=Object.getOwnPropertyDescriptor,k=(e,t,n,s)=>{for(var r=s>1?void 0:s?xr(t,n):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(s?i(t,n,r):i(r))||r);return s&&r&&Or(t,n,r),r};const we=an("gltf");function jr(e,t){const n=e.transform;!t||!n||(Ie(n.position,t.position,{x:0,y:0,z:0}),Ie(n.rotation,t.rotation,{x:0,y:0,z:0}),Ie(n.scale,t.scale,{x:1,y:1,z:1}))}function Ie(e,t,n){if(!t)return;const s=Number(t.x??e.x??n.x),r=Number(t.y??e.y??n.y),a=Number(t.z??e.z??n.z);if(typeof e.set=="function"){e.set(s,r,a);return}e.x=s,e.y=r,e.z=a}let O=class extends gn{constructor(t){super(t);w(this,"exportedUrl","");w(this,"glTFInfo",{drawcall:void 0,triangles:void 0,issues:void 0});w(this,"remapMaterials",{});w(this,"animationEvents",{});w(this,"needComputeTangents",!0);w(this,"fbxUrl",null);w(this,"optimize",{meshopt:!1,meshQuantize:!1});w(this,"params",{keepMeshData:!1});w(this,"initCompleted");w(this,"_rootKey","defaultSceneRoot");w(this,"mappedMaterialsPath",[]);w(this,"_initCompletedResolve");w(this,"_autorunDisposer",null);w(this,"_propertyChangeListeners",new Map);yt(this),this.initCompleted=new Promise(n=>{this._initCompletedResolve=n})}applyMetaFromDomain(t){if(super.applyMetaFromDomain(t),"needComputeTangents"in t&&(this.needComputeTangents=t.needComputeTangents),"optimize"in t&&typeof t.optimize=="object"){const n=t.optimize;this.optimize={...this.optimize,...n}}}async generateSubAssets(){const t=this.engineObject;if(this._subAssets=[],t.meshes)for(let s=0;s<t.meshes.length;s++){const r=t.meshes[s];for(let a=0;a<r.length;a++){const i=await this.root.assetStore.createSubAsset("Mesh",r[a],this.id,`meshes[${s}][${a}]`);this._subAssets.push(i)}}if(t.textures)for(let s=0;s<t.textures.length;s++){const r=await this.root.assetStore.createSubAsset("Texture",t.textures[s],this.id,`textures[${s}]`);this._subAssets.push(r)}if(t.animations)for(let s=0;s<t.animations.length;s++){const r=t.animations[s],a=this.animationEvents[s];a&&a.forEach(o=>{r.addEvent(o.functionName,o.time,o.parameter)});const i=await this.root.assetStore.createSubAsset("AnimationClip",r,this.id,`animations[${s}]`);this._subAssets.push(i)}const n=Cr(t.defaultSceneRoot);for(let s=0;s<n.length;s++){const r=await this.root.assetStore.createSubAsset("AnimatorController",n[s],this.id,`animatorController[${s}]`);this._subAssets.push(r)}if(t.materials)for(let s=0;s<t.materials.length;s++){const r=await this.root.assetStore.createSubAsset("Material",t.materials[s],this.id,`materials[${s}]`);this._subAssets.push(r)}}async initByMain(t,n){const{engine:s,meta:r}=this;this.url=n,this.animationEvents=r.animationEvents||{},this.optimize=r.optimize??this.optimize;let a=this.optimize.meshopt,i=this.optimize.meshQuantize;this._autorunDisposer=Qt(()=>{const c=this.optimize.meshQuantize;i!==c&&(this.optimize.meshQuantize=c,i=c,this._saveMetaAndReload());const h=this.optimize.meshopt;a!==h&&(this.optimize.meshopt=h,a=h,this._saveMetaAndReload())}),this.params=r.params??this.params;let o;try{o=URL.createObjectURL(t),await this.initByUrl(o+"#.glb",s)}finally{o!==void 0&&URL.revokeObjectURL(o)}this.needComputeTangents=r.needComputeTangents??!0;const f=Object.keys(r.remapMaterials||{}).filter(c=>r.remapMaterials[c]).map(c=>{const h=r.remapMaterials[c];return new Promise(u=>{this.on("initcomplete",async()=>{await this.replaceMaterial(Number(c),h,!1),u()})})});f.length?Promise.all(f).finally(()=>this._initCompletedResolve()).catch(()=>{}):this._initCompletedResolve(),this.fbxUrl=r.fbxUrl}_saveMetaAndReload(){qe.success(bt("Success. page will reload, please wait...")),this.root.assetFacade.persistAssetMetaImmediate(this.id).then(()=>{window.location.reload()}).catch(t=>{we.error("Failed to persist optimize config before reload",t),qe.error("Failed to save optimize config, reload canceled.")})}resetMaterial(t){const n=this._engineObject.materials[t];this._internalReplaceMaterial(t,n),this.remapMaterials[t]=void 0,this.root.assetFacade.persistAssetMeta(this.id)}async replaceMaterial(t,n,s=!0){this.remapMaterials[t]=n;const r=this._findComponentsByMaterialPathIndex(t),a=await this.root.assetStore.getAssetByRef(n);if(a instanceof pn){const i=a.engineObject;r.forEach(({component:c,materialIndex:h})=>{c.setMaterial(h,i)});const o=String(t),l=this._propertyChangeListeners.get(o);l&&a.off("propertychange",l);const f=()=>{this.updateThumbnail()};this._propertyChangeListeners.set(o,f),a.on("propertychange",f)}else we.warn(`${n.refId} shouldn't be selected`);s&&await this.root.assetFacade.persistAssetMeta(this.id),this.updateThumbnail()}updateAnimationEvents(t,n){this.animationEvents[t]=n,this.root.assetFacade.persistAssetMeta(this.id)}async instantiate(t,n,s){await this.initCompleted;const r=this.instantiateEngineObject();jr(r,n);const a=t.createByEngineObject(r,s==null?void 0:s.expectedRootId);if(await a.ensureReady(),a.name=this.name.replace(/\.glb$/g,""),this.addInstance(a),s!=null&&s.expectedBindingId&&a.pendingInstance&&(a.pendingInstance={...a.pendingInstance,bindingId:s.expectedBindingId}),s!=null&&s.deferDomainBinding){if(!s.deferredInstanceBindings)throw new Error(`GlTFAsset "${this.id}" cannot defer domain binding without a deferred binding queue.`);s.deferredInstanceBindings.push(()=>this._bindDeferredDomainInstance(a,s))}return a}_bindDeferredDomainInstance(t,n){var a;const s=((a=t.pendingInstance)==null?void 0:a.assetKind)==="glTF"&&t.pendingInstance.assetId===this.id?t.pendingInstance.bindingId:void 0,r=Jt({state:this.root.domainStore.state,assetId:this.id,rootEntityId:t.id,expectedBindingId:n==null?void 0:n.expectedBindingId,pendingBindingId:s,createBindingId:()=>`binding-${Yt().slice(0,8)}`});if(r.kind!=="none"){if(r.kind==="update"){this.root.prefabFacade.updateBindingSourceBaseline(r);return}this.root.prefabFacade.bindExistingInstance({assetId:r.assetId,assetKind:r.assetKind,bindingId:r.bindingId,instanceRootEntityId:r.instanceRootEntityId,entityMappings:r.entityMappings,componentMappings:r.componentMappings,sourceEntitySnapshots:r.sourceEntitySnapshots,undoable:!1})}}destroy(){var n;(n=this._autorunDisposer)==null||n.call(this),this._autorunDisposer=null,this._propertyChangeListeners.clear();const t=this.engineObject;t&&(t._defaultSceneRoot.destroy(),t.destroy()),super.destroy()}instantiateEngineObject(){var n;const t=super.instantiateEngineObject();return Sr((n=this.engineObject)==null?void 0:n.defaultSceneRoot,t,this.root.assetStore),this._fixClonedSkins(t),t}_fixClonedSkins(t){const n=t.getComponentsIncludeChildren(Zt,[]);for(const s of n){const r=s.skin;if(r&&r.bones.length>0&&!r._skinMatrices){const a=r.bones;r.bones=a}}}_instantiateEngineObject(){return this.engineObject.instantiateSceneRoot()}_internalReplaceMaterial(t,n){this._findComponentsByMaterialPathIndex(t).forEach(({component:r,materialIndex:a})=>{r.setMaterial(a,n)}),this.updateThumbnail()}_findComponentsByMaterialPathIndex(t){const n=[...this._clonedEntities,this._engineObject.defaultSceneRoot],s=this.mappedMaterialsPath[t],r=[];if(!s)return we.warn(`${this._name} replaced material not found.(gltf may be replaced either)`),r;for(let a=0;a<n.length;a++){const i=n[a];s.forEach(o=>{const f=Pr(o.entityPath,i).getComponents(Ge,[]);r.push({component:f[o.componentIndex],materialIndex:o.materialIndex})})}return r}async initByUrl(t,n){const s=await n.resourceManager.load({type:en.GLTF,url:t,params:this.params});return this.initMappedMaterialPath(s),this.bindEngineObject(s),this._updateDragTempEntity(),await this.generateSubAssets(),await this.initBasicInfo(s),this}async getRemappedMaterial(t){var s;const n=this.remapMaterials[t];return n?(s=await this.root.assetStore.getAssetByRef(n))==null?void 0:s.engineObject:this._engineObject.materials[t]}initMappedMaterialPath(t){const n=t.materials,s=t.defaultSceneRoot;if(n){const r=t.defaultSceneRoot.getComponentsIncludeChildren(We,[]);n.forEach(a=>{const i=[];this.mappedMaterialsPath.push(i);for(let o=0;o<r.length;o++){const l=r[o],f=l.getMaterials(),c=l.entity.getComponents(Ge,[]);for(let h=0;h<f.length;h++)f[h]===a&&i.push({entityPath:Rr(l.entity,s),componentIndex:c.indexOf(l),materialIndex:h})}})}}async initBasicInfo(t){this.glTFInfo.drawcall=t.defaultSceneRoot.getComponentsIncludeChildren(We,[]).length}};k([j,tn()],O.prototype,"exportedUrl",2);k([W(),j],O.prototype,"remapMaterials",2);k([W()],O.prototype,"animationEvents",2);k([W(),j],O.prototype,"needComputeTangents",2);k([W(),j],O.prototype,"fbxUrl",2);k([W(),j],O.prototype,"optimize",2);k([W(),j],O.prototype,"params",2);k([nn],O.prototype,"applyMetaFromDomain",1);k([G],O.prototype,"resetMaterial",1);O=k([sn({type:"glTF",label:bt("asset.gltf.title"),loaderType:"GLTF",importMenuConfig:{type:rn.Upload,tooltip:"请上传模型文件(支持gltf,glb,fbx,obj)或包含模型和资源文件(bin、贴图等)的zip压缩包",accept:".zip,.fbx,.gltf,.glb,application/json",subAccept:".bin,.jpeg,.jpg,.png",multiple:!0},filterUploadFiles:Er,preUpload:Ir,extname:"glb",dragLayer:mt.GlTF,customInspector:_r,viewer:R,thumbnail:Pe,async preInitialize({main:e,meta:t,name:n}){const s=new Uint8Array(await e.arrayBuffer()),r=await ve.readBinary(s),a=t.optimize||{},i=t.needComputeTangents??!0,o=a.meshQuantize,l=a.meshopt,f=[],c=r.getRoot().listExtensionsUsed(),h=c.some(d=>d.extensionName===At.EXTENSION_NAME),u=c.some(d=>d.extensionName===ae.EXTENSION_NAME);o&&!h&&f.push(Ue({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),l&&!u&&(await oe.ready,f.push(Lt({encoder:oe})));try{i&&(f.push(lr()),f.push(mr({generateTangents:window.mikktspace.generateTangents,overwrite:!0}))),await r.transform(...f)}catch(d){console.error("The gltf-transform plugin encountered some errors when performing meshopt, quantize, or calculating tangents, we have disabled these features automatically.",d)}const g=await ve.writeBinary(r);return new File([g.buffer],n,{type:"model/gltf-binary"})},async bundle({content:e,name:t,meta:n},s,r){var o;const a=new Uint8Array(await e.arrayBuffer()),i=await Ar(a,ve,{name:t,remapMaterials:n.remapMaterials,animationEvents:n.animationEvents??{},textureOptions:(o=s.assetOptions)==null?void 0:o.textureOptions,optimizeOptions:n.optimize},{resolveRef:r?l=>r.resolveRef(l):void 0,ktx2Encode:(l,f)=>mn.encode(l,f)});return{name:i.name,content:new Blob([i.content],{type:"model/gltf-binary"})}}})],O);function Rr(e,t){const n=[];for(;e!==t;)n.unshift(e.siblingIndex),e=e.parent;return n}function Pr(e,t){let n=t;for(let s=0;s<e.length;s++)n=n.children[e[s]];return n}const qr=Object.freeze(Object.defineProperty({__proto__:null,get GlTFAsset(){return O}},Symbol.toStringTag,{value:"Module"}));export{O as G,R as a,qr as b};
20
+ `));return h(qn.bind(void 0,e))}var Wn=Gn,Hn=Wn;function Xn(){this.argTypes=[],this.shimArgs=[],this.arrayArgs=[],this.arrayBlockIndices=[],this.scalarArgs=[],this.offsetArgs=[],this.offsetArgIndex=[],this.indexArgs=[],this.shapeArgs=[],this.funcName="",this.pre=null,this.body=null,this.post=null,this.debug=!1}function Kn(e){var t=new Xn;t.pre=e.pre,t.body=e.body,t.post=e.post;var n=e.args.slice(0);t.argTypes=n;for(var s=0;s<n.length;++s){var r=n[s];if(r==="array"||typeof r=="object"&&r.blockIndices){if(t.argTypes[s]="array",t.arrayArgs.push(s),t.arrayBlockIndices.push(r.blockIndices?r.blockIndices:0),t.shimArgs.push("array"+s),s<t.pre.args.length&&t.pre.args[s].count>0)throw new Error("cwise: pre() block may not reference array args");if(s<t.post.args.length&&t.post.args[s].count>0)throw new Error("cwise: post() block may not reference array args")}else if(r==="scalar")t.scalarArgs.push(s),t.shimArgs.push("scalar"+s);else if(r==="index"){if(t.indexArgs.push(s),s<t.pre.args.length&&t.pre.args[s].count>0)throw new Error("cwise: pre() block may not reference array index");if(s<t.body.args.length&&t.body.args[s].lvalue)throw new Error("cwise: body() block may not write to array index");if(s<t.post.args.length&&t.post.args[s].count>0)throw new Error("cwise: post() block may not reference array index")}else if(r==="shape"){if(t.shapeArgs.push(s),s<t.pre.args.length&&t.pre.args[s].lvalue)throw new Error("cwise: pre() block may not write to array shape");if(s<t.body.args.length&&t.body.args[s].lvalue)throw new Error("cwise: body() block may not write to array shape");if(s<t.post.args.length&&t.post.args[s].lvalue)throw new Error("cwise: post() block may not write to array shape")}else if(typeof r=="object"&&r.offset)t.argTypes[s]="offset",t.offsetArgs.push({array:r.array,offset:r.offset}),t.offsetArgIndex.push(s);else throw new Error("cwise: Unknown argument type "+n[s])}if(t.arrayArgs.length<=0)throw new Error("cwise: No array arguments specified");if(t.pre.args.length>n.length)throw new Error("cwise: Too many arguments in pre() block");if(t.body.args.length>n.length)throw new Error("cwise: Too many arguments in body() block");if(t.post.args.length>n.length)throw new Error("cwise: Too many arguments in post() block");return t.debug=!!e.printCode||!!e.debug,t.funcName=e.funcName||"cwise",t.blockSize=e.blockSize||64,Hn(t)}var Qn=Kn;(function(e){var t=Qn,n={body:"",args:[],thisVars:[],localVars:[]};function s(u){if(!u)return n;for(var g=0;g<u.args.length;++g){var d=u.args[g];g===0?u.args[g]={name:d,lvalue:!0,rvalue:!!u.rvalue,count:u.count||1}:u.args[g]={name:d,lvalue:!1,rvalue:!0,count:1}}return u.thisVars||(u.thisVars=[]),u.localVars||(u.localVars=[]),u}function r(u){return t({args:u.args,pre:s(u.pre),body:s(u.body),post:s(u.proc),funcName:u.funcName})}function a(u){for(var g=[],d=0;d<u.args.length;++d)g.push("a"+d);var m=new Function("P",["return function ",u.funcName,"_ndarrayops(",g.join(","),") {P(",g.join(","),");return a0}"].join(""));return m(r(u))}var i={add:"+",sub:"-",mul:"*",div:"/",mod:"%",band:"&",bor:"|",bxor:"^",lshift:"<<",rshift:">>",rrshift:">>>"};(function(){for(var u in i){var g=i[u];e[u]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:u}),e[u+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a"+g+"=b"},rvalue:!0,funcName:u+"eq"}),e[u+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:u+"s"}),e[u+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a"+g+"=s"},rvalue:!0,funcName:u+"seq"})}})();var o={not:"!",bnot:"~",neg:"-",recip:"1.0/"};(function(){for(var u in o){var g=o[u];e[u]=a({args:["array","array"],body:{args:["a","b"],body:"a="+g+"b"},funcName:u}),e[u+"eq"]=a({args:["array"],body:{args:["a"],body:"a="+g+"a"},rvalue:!0,count:2,funcName:u+"eq"})}})();var l={and:"&&",or:"||",eq:"===",neq:"!==",lt:"<",gt:">",leq:"<=",geq:">="};(function(){for(var u in l){var g=l[u];e[u]=a({args:["array","array","array"],body:{args:["a","b","c"],body:"a=b"+g+"c"},funcName:u}),e[u+"s"]=a({args:["array","array","scalar"],body:{args:["a","b","s"],body:"a=b"+g+"s"},funcName:u+"s"}),e[u+"eq"]=a({args:["array","array"],body:{args:["a","b"],body:"a=a"+g+"b"},rvalue:!0,count:2,funcName:u+"eq"}),e[u+"seq"]=a({args:["array","scalar"],body:{args:["a","s"],body:"a=a"+g+"s"},rvalue:!0,count:2,funcName:u+"seq"})}})();var f=["abs","acos","asin","atan","ceil","cos","exp","floor","log","round","sin","sqrt","tan"];(function(){for(var u=0;u<f.length;++u){var g=f[u];e[g]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b)",thisVars:["this_f"]},funcName:g}),e[g+"eq"]=a({args:["array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a"],body:"a=this_f(a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"})}})();var c=["max","min","atan2","pow"];(function(){for(var u=0;u<c.length;++u){var g=c[u];e[g]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g}),e[g+"s"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(b,c)",thisVars:["this_f"]},funcName:g+"s"}),e[g+"eq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"eq"}),e[g+"seq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(a,b)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"seq"})}})();var h=["atan2","pow"];(function(){for(var u=0;u<h.length;++u){var g=h[u];e[g+"op"]=a({args:["array","array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"op"}),e[g+"ops"]=a({args:["array","array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b","c"],body:"a=this_f(c,b)",thisVars:["this_f"]},funcName:g+"ops"}),e[g+"opeq"]=a({args:["array","array"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opeq"}),e[g+"opseq"]=a({args:["array","scalar"],pre:{args:[],body:"this_f=Math."+g,thisVars:["this_f"]},body:{args:["a","b"],body:"a=this_f(b,a)",thisVars:["this_f"]},rvalue:!0,count:2,funcName:g+"opseq"})}})(),e.any=t({args:["array"],pre:n,body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"if(a){return true}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return false"},funcName:"any"}),e.all=t({args:["array"],pre:n,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1}],body:"if(!x){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"all"}),e.sum=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s+=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"sum"}),e.prod=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=1"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:1}],body:"this_s*=a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"prod"}),e.norm2squared=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm2squared"}),e.norm2=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:2}],body:"this_s+=a*a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return Math.sqrt(this_s)"},funcName:"norm2"}),e.norminf=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:4}],body:"if(-a>this_s){this_s=-a}else if(a>this_s){this_s=a}",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norminf"}),e.norm1=t({args:["array"],pre:{args:[],localVars:[],thisVars:["this_s"],body:"this_s=0"},body:{args:[{name:"a",lvalue:!1,rvalue:!0,count:3}],body:"this_s+=a<0?-a:a",localVars:[],thisVars:["this_s"]},post:{args:[],localVars:[],thisVars:["this_s"],body:"return this_s"},funcName:"norm1"}),e.sup=t({args:["array"],pre:{body:"this_h=-Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_>this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.inf=t({args:["array"],pre:{body:"this_h=Infinity",args:[],thisVars:["this_h"],localVars:[]},body:{body:"if(_inline_1_arg0_<this_h)this_h=_inline_1_arg0_",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_h"],localVars:[]},post:{body:"return this_h",args:[],thisVars:["this_h"],localVars:[]}}),e.argmin=t({args:["index","array","shape"],pre:{body:"{this_v=Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_<this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.argmax=t({args:["index","array","shape"],pre:{body:"{this_v=-Infinity;this_i=_inline_0_arg2_.slice(0)}",args:[{name:"_inline_0_arg0_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg1_",lvalue:!1,rvalue:!1,count:0},{name:"_inline_0_arg2_",lvalue:!1,rvalue:!0,count:1}],thisVars:["this_i","this_v"],localVars:[]},body:{body:"{if(_inline_1_arg1_>this_v){this_v=_inline_1_arg1_;for(var _inline_1_k=0;_inline_1_k<_inline_1_arg0_.length;++_inline_1_k){this_i[_inline_1_k]=_inline_1_arg0_[_inline_1_k]}}}",args:[{name:"_inline_1_arg0_",lvalue:!1,rvalue:!0,count:2},{name:"_inline_1_arg1_",lvalue:!1,rvalue:!0,count:2}],thisVars:["this_i","this_v"],localVars:["_inline_1_k"]},post:{body:"{return this_i}",args:[],thisVars:["this_i"],localVars:[]}}),e.random=a({args:["array"],pre:{args:[],body:"this_f=Math.random",thisVars:["this_f"]},body:{args:["a"],body:"a=this_f()",thisVars:["this_f"]},funcName:"random"}),e.assign=a({args:["array","array"],body:{args:["a","b"],body:"a=b"},funcName:"assign"}),e.assigns=a({args:["array","scalar"],body:{args:["a","b"],body:"a=b"},funcName:"assigns"}),e.equals=t({args:["array","array"],pre:n,body:{args:[{name:"x",lvalue:!1,rvalue:!0,count:1},{name:"y",lvalue:!1,rvalue:!0,count:1}],body:"if(x!==y){return false}",localVars:[],thisVars:[]},post:{args:[],localVars:[],thisVars:[],body:"return true"},funcName:"equals"})})(Rn);function Jn(e,t){if(!(e instanceof Uint8Array))throw new Error("[ndarray-pixels] Input must be Uint8Array or Buffer.");const n=new Blob([e],{type:t}),s=URL.createObjectURL(n);return new Promise((r,a)=>{const i=new Image;i.crossOrigin="anonymous",i.onload=function(){URL.revokeObjectURL(s);const l=new OffscreenCanvas(i.width,i.height).getContext("2d");l.drawImage(i,0,0);const f=l.getImageData(0,0,i.width,i.height);r(jn(new Uint8Array(f.data),[i.width,i.height,4],[4,4*i.width,1],0))},i.onerror=o=>{URL.revokeObjectURL(s),a(o)},i.src=s})}async function Yn(e,t){return Jn(e,t)}function q(){return q=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var s in n)({}).hasOwnProperty.call(n,s)&&(e[s]=n[s])}return e},q.apply(null,arguments)}P.Mode;function D(e,t){return Object.defineProperty(t,"name",{value:e}),t}function H(e,t){const n=q({},e);for(const s in t)t[s]!==void 0&&(n[s]=t[s]);return n}class Te{constructor(){this._map=new Map}get size(){return this._map.size}has(t){return this._map.has(t)}add(t,n){let s=this._map.get(t);return s||(s=new Set,this._map.set(t,s)),s.add(n),this}get(t){return this._map.get(t)||new Set}keys(){return this._map.keys()}}const Zn=new Intl.NumberFormat(void 0,{maximumFractionDigits:0});function Ke(e){return Zn.format(e)}function es(e,t,n=2){const s=e>t?"–":"+",r="%";return s+(Math.abs(e-t)/e*100).toFixed(n)+r}function ts(e,t){return`${Ke(e)} → ${Ke(t)} (${es(e,t)})`}function Nt(e){const t=[];for(const n of e.listAttributes())t.push(n);for(const n of e.listTargets())for(const s of n.listAttributes())t.push(s);return Array.from(new Set(t))}function ns(e,t){if(e==null&&t==null)return!0;if(e==null||t==null||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return!1;return!0}function ee(e,t){return e.createAccessor(t.getName()).setArray(t.getArray()).setType(t.getType()).setBuffer(t.getBuffer()).setNormalized(t.getNormalized()).setSparse(t.getSparse())}function ss(e,t=e){const n=Ct(e,t);for(let s=0;s<n.length;s++)n[s]=s;return n}function Ct(e,t=e){return t<=65534?new Uint16Array(e):new Uint32Array(e)}function St(e){for(const t in e)return!1;return!0}var ce=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var e=0,t=arguments.length;t--;)e+=arguments[t]*arguments[t];return Math.sqrt(e)});function rs(e,t){var n=t[0],s=t[1],r=t[2],a=t[3],i=t[4],o=t[5],l=t[6],f=t[7],c=t[8],h=t[9],u=t[10],g=t[11],d=t[12],m=t[13],p=t[14],y=t[15],T=n*o-s*i,v=n*l-r*i,b=n*f-a*i,_=s*l-r*o,E=s*f-a*o,x=r*f-a*l,$=c*m-h*d,X=c*p-u*d,K=c*y-g*d,Q=h*p-u*m,J=h*y-g*m,Y=u*y-g*p,M=T*Y-v*J+b*Q+_*K-E*X+x*$;return M?(M=1/M,e[0]=(o*Y-l*J+f*Q)*M,e[1]=(r*J-s*Y-a*Q)*M,e[2]=(m*x-p*E+y*_)*M,e[3]=(u*E-h*x-g*_)*M,e[4]=(l*K-i*Y-f*X)*M,e[5]=(n*Y-r*K+a*X)*M,e[6]=(p*b-d*x-y*v)*M,e[7]=(c*x-u*b+g*v)*M,e[8]=(i*J-o*K+f*$)*M,e[9]=(s*K-n*J-a*$)*M,e[10]=(d*E-m*b+y*T)*M,e[11]=(h*b-c*E-g*T)*M,e[12]=(o*X-i*Q-l*$)*M,e[13]=(n*Q-s*X+r*$)*M,e[14]=(m*v-d*_-p*T)*M,e[15]=(c*_-h*v+u*T)*M,e):null}function Ue(e,t,n){var s=t[0],r=t[1],a=t[2],i=t[3],o=t[4],l=t[5],f=t[6],c=t[7],h=t[8],u=t[9],g=t[10],d=t[11],m=t[12],p=t[13],y=t[14],T=t[15],v=n[0],b=n[1],_=n[2],E=n[3];return e[0]=v*s+b*o+_*h+E*m,e[1]=v*r+b*l+_*u+E*p,e[2]=v*a+b*f+_*g+E*y,e[3]=v*i+b*c+_*d+E*T,v=n[4],b=n[5],_=n[6],E=n[7],e[4]=v*s+b*o+_*h+E*m,e[5]=v*r+b*l+_*u+E*p,e[6]=v*a+b*f+_*g+E*y,e[7]=v*i+b*c+_*d+E*T,v=n[8],b=n[9],_=n[10],E=n[11],e[8]=v*s+b*o+_*h+E*m,e[9]=v*r+b*l+_*u+E*p,e[10]=v*a+b*f+_*g+E*y,e[11]=v*i+b*c+_*d+E*T,v=n[12],b=n[13],_=n[14],E=n[15],e[12]=v*s+b*o+_*h+E*m,e[13]=v*r+b*l+_*u+E*p,e[14]=v*a+b*f+_*g+E*y,e[15]=v*i+b*c+_*d+E*T,e}function as(e,t){return e[0]=t[0],e[1]=0,e[2]=0,e[3]=0,e[4]=0,e[5]=t[1],e[6]=0,e[7]=0,e[8]=0,e[9]=0,e[10]=t[2],e[11]=0,e[12]=0,e[13]=0,e[14]=0,e[15]=1,e}function is(e,t,n,s){var r=t[0],a=t[1],i=t[2],o=t[3],l=r+r,f=a+a,c=i+i,h=r*l,u=r*f,g=r*c,d=a*f,m=a*c,p=i*c,y=o*l,T=o*f,v=o*c,b=s[0],_=s[1],E=s[2];return e[0]=(1-(d+p))*b,e[1]=(u+v)*b,e[2]=(g-T)*b,e[3]=0,e[4]=(u-v)*_,e[5]=(1-(h+p))*_,e[6]=(m+y)*_,e[7]=0,e[8]=(g+T)*E,e[9]=(m-y)*E,e[10]=(1-(h+d))*E,e[11]=0,e[12]=n[0],e[13]=n[1],e[14]=n[2],e[15]=1,e}function os(){var e=new ce(3);return ce!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0),e}function ls(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e}function Ce(e,t,n){return e[0]=Math.min(t[0],n[0]),e[1]=Math.min(t[1],n[1]),e[2]=Math.min(t[2],n[2]),e}function Se(e,t,n){return e[0]=Math.max(t[0],n[0]),e[1]=Math.max(t[1],n[1]),e[2]=Math.max(t[2],n[2]),e}function Qe(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e}function cs(e,t,n){var s=t[0],r=t[1],a=t[2],i=n[3]*s+n[7]*r+n[11]*a+n[15];return i=i||1,e[0]=(n[0]*s+n[4]*r+n[8]*a+n[12])/i,e[1]=(n[1]*s+n[5]*r+n[9]*a+n[13])/i,e[2]=(n[2]*s+n[6]*r+n[10]*a+n[14])/i,e}var us=ls;(function(){var e=os();return function(t,n,s,r,a,i){var o,l;for(n||(n=3),s||(s=0),r?l=Math.min(r*n+s,t.length):l=t.length,o=s;o<l;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],a(e,e,i),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2];return t}})();const F="dedup",Ee={keepUniqueNames:!1,propertyTypes:[A.ACCESSOR,A.MESH,A.TEXTURE,A.MATERIAL,A.SKIN]};function fs(e=Ee){const t=H(Ee,e),n=new Set(t.propertyTypes);for(const s of t.propertyTypes)if(!Ee.propertyTypes.includes(s))throw new Error(`${F}: Unsupported deduplication on type "${s}".`);return D(F,s=>{const r=s.getLogger();n.has(A.ACCESSOR)&&hs(s),n.has(A.TEXTURE)&&ds(s,t),n.has(A.MATERIAL)&&ps(s,t),n.has(A.MESH)&&gs(s,t),n.has(A.SKIN)&&ms(s,t),r.debug(`${F}: Complete.`)})}function hs(e){const t=e.getLogger(),n=new Map,s=new Map,r=new Map,a=new Map,i=e.getRoot().listMeshes();i.forEach(h=>{h.listPrimitives().forEach(u=>{u.listAttributes().forEach(g=>o(g,s)),o(u.getIndices(),n)})});for(const h of e.getRoot().listAnimations())for(const u of h.listSamplers())o(u.getInput(),r),o(u.getOutput(),a);function o(h,u){if(!h)return;const g=[h.getCount(),h.getType(),h.getComponentType(),h.getNormalized(),h.getSparse()].join(":");let d=u.get(g);d||u.set(g,d=new Set),d.add(h)}function l(h,u){for(let g=0;g<h.length;g++){const d=h[g],m=N.toView(d.getArray());if(!u.has(d))for(let p=g+1;p<h.length;p++){const y=h[p];u.has(y)||N.equals(m,N.toView(y.getArray()))&&u.set(y,d)}}}let f=0;const c=new Map;for(const h of[s,n,r,a])for(const u of h.values())f+=u.size,l(Array.from(u),c);t.debug(`${F}: Merged ${c.size} of ${f} accessors.`),i.forEach(h=>{h.listPrimitives().forEach(u=>{u.listAttributes().forEach(d=>{c.has(d)&&u.swap(d,c.get(d))});const g=u.getIndices();g&&c.has(g)&&u.swap(g,c.get(g))})});for(const h of e.getRoot().listAnimations())for(const u of h.listSamplers()){const g=u.getInput(),d=u.getOutput();g&&c.has(g)&&u.swap(g,c.get(g)),d&&c.has(d)&&u.swap(d,c.get(d))}Array.from(c.keys()).forEach(h=>h.dispose())}function gs(e,t){const n=e.getLogger(),s=e.getRoot(),r=new Map;s.listAccessors().forEach((o,l)=>r.set(o,l)),s.listMaterials().forEach((o,l)=>r.set(o,l));const a=s.listMeshes().length,i=new Map;for(const o of s.listMeshes()){const l=[];for(const c of o.listPrimitives())l.push(Ot(c,r));let f="";if(t.keepUniqueNames&&(f+=o.getName()+";"),f+=l.join(";"),i.has(f)){const c=i.get(f);o.listParents().forEach(h=>{h.propertyType!==A.ROOT&&h.swap(o,c)}),o.dispose()}else i.set(f,o)}n.debug(`${F}: Merged ${a-i.size} of ${a} meshes.`)}function ds(e,t){const n=e.getLogger(),s=e.getRoot(),r=s.listTextures(),a=new Map;for(let i=0;i<r.length;i++){const o=r[i],l=o.getImage();if(!a.has(o))for(let f=i+1;f<r.length;f++){const c=r[f],h=c.getImage();if(a.has(c)||o.getMimeType()!==c.getMimeType()||t.keepUniqueNames&&o.getName()!==c.getName())continue;const u=o.getSize(),g=c.getSize();!u||!g||u[0]===g[0]&&u[1]===g[1]&&(!l||!h||N.equals(l,h)&&a.set(c,o))}}n.debug(`${F}: Merged ${a.size} of ${s.listTextures().length} textures.`),Array.from(a.entries()).forEach(([i,o])=>{i.listParents().forEach(l=>{l instanceof pe||l.swap(i,o)}),i.dispose()})}function ps(e,t){const n=e.getLogger(),r=e.getRoot().listMaterials(),a=new Map,i=new Map,o=new Set;t.keepUniqueNames||o.add("name");for(let l=0;l<r.length;l++){const f=r[l];if(!a.has(f)&&!Je(f,i))for(let c=l+1;c<r.length;c++){const h=r[c];a.has(h)||Je(h,i)||f.equals(h,o)&&a.set(h,f)}}n.debug(`${F}: Merged ${a.size} of ${r.length} materials.`),Array.from(a.entries()).forEach(([l,f])=>{l.listParents().forEach(c=>{c instanceof pe||c.swap(l,f)}),l.dispose()})}function ms(e,t){const n=e.getLogger(),r=e.getRoot().listSkins(),a=new Map,i=new Set(["joints"]);t.keepUniqueNames||i.add("name");for(let o=0;o<r.length;o++){const l=r[o];if(!a.has(l))for(let f=o+1;f<r.length;f++){const c=r[f];a.has(c)||l.equals(c,i)&&ns(l.listJoints(),c.listJoints())&&a.set(c,l)}}n.debug(`${F}: Merged ${a.size} of ${r.length} skins.`),Array.from(a.entries()).forEach(([o,l])=>{o.listParents().forEach(f=>{f instanceof pe||f.swap(o,l)}),o.dispose()})}function Ot(e,t){const n=[];for(const s of e.listSemantics()){const r=e.getAttribute(s);n.push(s+":"+t.get(r))}if(e instanceof P){const s=e.getIndices();s&&n.push("indices:"+t.get(s));const r=e.getMaterial();r&&n.push("material:"+t.get(r)),n.push("mode:"+e.getMode());for(const a of e.listTargets())n.push("target:"+Ot(a,t))}return n.join(",")}function Je(e,t){if(t.has(e))return t.get(e);const n=e.getGraph(),s=new Set,r=n.listParentEdges(e);for(;r.length>0;){const a=r.pop();if(a.getAttributes().modifyChild===!0)return t.set(e,!0),!0;const i=a.getChild();if(!s.has(i))for(const o of n.listChildEdges(i))r.push(o)}return t.set(e,!1),!1}function xt(){var e=new ce(4);return ce!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0,e[3]=0),e}function ys(e,t,n){return e[0]=t[0]+n[0],e[1]=t[1]+n[1],e[2]=t[2]+n[2],e[3]=t[3]+n[3],e}function bs(e,t,n){return e[0]=t[0]-n[0],e[1]=t[1]-n[1],e[2]=t[2]-n[2],e[3]=t[3]-n[3],e}function As(e,t,n){return e[0]=t[0]*n[0],e[1]=t[1]*n[1],e[2]=t[2]*n[2],e[3]=t[3]*n[3],e}function vs(e,t,n){return e[0]=t[0]*n,e[1]=t[1]*n,e[2]=t[2]*n,e[3]=t[3]*n,e}function _s(e){var t=e[0],n=e[1],s=e[2],r=e[3];return Math.hypot(t,n,s,r)}var jt=bs,Ts=As,Rt=_s;(function(){var e=xt();return function(t,n,s,r,a,i){var o,l;for(n||(n=4),s||(s=0),r?l=Math.min(r*n+s,t.length):l=t.length,o=s;o<l;o+=n)e[0]=t[o],e[1]=t[o+1],e[2]=t[o+2],e[3]=t[o+3],a(e,e,i),t[o]=e[0],t[o+1]=e[1],t[o+2]=e[2],t[o+3]=e[3];return t}})();const Es=/color|emissive|diffuse/i;function ws(e){return e.getGraph().listParentEdges(e).some(r=>r.getAttributes().isColor||Es.test(r.getName()))?"srgb":null}function Is(e){const t=e.getGraph(),n=new Set,s=new Set;function r(a){const i=new Set;for(const o of t.listChildEdges(a))o.getChild()instanceof Ne&&i.add(o.getName()+"Info");for(const o of t.listChildEdges(a)){const l=o.getChild();n.has(l)||(n.add(l),l instanceof vt&&i.has(o.getName())?s.add(l):l instanceof _t&&r(l))}}return r(e),Array.from(s)}function Ms(e){const n=Le.fromGraph(e.getGraph()).getRoot(),s=e.getGraph().listParentEdges(e).filter(r=>r.getParent()!==n).map(r=>r.getName());return Array.from(new Set(s))}const B="prune",Oe=3/255,Ye={propertyTypes:[A.NODE,A.SKIN,A.MESH,A.CAMERA,A.PRIMITIVE,A.PRIMITIVE_TARGET,A.ANIMATION,A.MATERIAL,A.TEXTURE,A.ACCESSOR,A.BUFFER],keepLeaves:!1,keepAttributes:!1,keepIndices:!1,keepSolidTextures:!1,keepExtras:!1};function Pt(e=Ye){const t=H(Ye,e),n=new Set(t.propertyTypes),s=t.keepExtras;return D(B,async r=>{const a=r.getLogger(),i=r.getRoot(),o=r.getGraph(),l=new Ns,f=c=>l.dispose(c.target);if(o.addEventListener("node:dispose",f),n.has(A.MESH))for(const c of i.listMeshes())c.listPrimitives().length>0||c.dispose();if(n.has(A.NODE)){if(!t.keepLeaves)for(const c of i.listScenes())zt(o,c,s);for(const c of i.listNodes())S(c,s)}if(n.has(A.SKIN))for(const c of i.listSkins())S(c,s);if(n.has(A.MESH))for(const c of i.listMeshes())S(c,s);if(n.has(A.CAMERA))for(const c of i.listCameras())S(c,s);if(n.has(A.PRIMITIVE)&&Ze(o,A.PRIMITIVE,s),n.has(A.PRIMITIVE_TARGET)&&Ze(o,A.PRIMITIVE_TARGET,s),!t.keepAttributes&&n.has(A.ACCESSOR)){const c=new Map;for(const h of i.listMeshes())for(const u of h.listPrimitives()){const g=u.getMaterial();if(!g)continue;const d=kt(r,u,g),m=Ss(u,d);et(u,m),u.listTargets().forEach(p=>et(p,m)),c.has(g)?c.get(g).add(u):c.set(g,new Set([u]))}for(const[h,u]of c)Os(h,Array.from(u))}if(!t.keepIndices&&n.has(A.ACCESSOR))for(const c of i.listMeshes())for(const h of c.listPrimitives())Cs(h);if(n.has(A.ANIMATION))for(const c of i.listAnimations()){for(const h of c.listChannels())h.getTargetNode()||h.dispose();if(c.listChannels().length)c.listSamplers().forEach(h=>S(h,s));else{const h=c.listSamplers();S(c,s),h.forEach(u=>S(u,s))}}if(n.has(A.MATERIAL)&&i.listMaterials().forEach(c=>S(c,s)),n.has(A.TEXTURE)&&(i.listTextures().forEach(c=>S(c,s)),t.keepSolidTextures||await xs(r)),n.has(A.ACCESSOR)&&i.listAccessors().forEach(c=>S(c,s)),n.has(A.BUFFER)&&i.listBuffers().forEach(c=>S(c,s)),o.removeEventListener("node:dispose",f),l.empty())a.debug(`${B}: No unused properties found.`);else{const c=l.entries().map(([h,u])=>`${h} (${u})`).join(", ");a.info(`${B}: Removed types... ${c}`)}a.debug(`${B}: Complete.`)})}class Ns{constructor(){this.disposed={}}empty(){for(const t in this.disposed)return!1;return!0}entries(){return Object.entries(this.disposed)}dispose(t){this.disposed[t.propertyType]=this.disposed[t.propertyType]||0,this.disposed[t.propertyType]++}}function S(e,t){const n=e.listParents().filter(r=>!(r instanceof pe||r instanceof $e)),s=t&&!St(e.getExtras());!n.length&&!s&&e.dispose()}function Ze(e,t,n){for(const s of e.listEdges()){const r=s.getParent();r.propertyType===t&&S(r,n)}}function zt(e,t,n){if(t.listChildren().forEach(i=>zt(e,i,n)),t instanceof ln)return;const s=e.listParentEdges(t).some(i=>{const o=i.getParent().propertyType;return o!==A.ROOT&&o!==A.SCENE&&o!==A.NODE}),r=e.listChildren(t).length===0,a=n&&!St(t.getExtras());r&&!s&&!a&&t.dispose()}function et(e,t){for(const n of t)e.setAttribute(n,null)}function Cs(e){const t=e.getIndices(),n=t&&t.getArray(),s=e.listAttributes()[0];if(!(!n||!s)&&t.getCount()===s.getCount()){for(let r=0,a=n.length;r<a;r++)if(r!==n[r])return;e.setIndices(null)}}function Ss(e,t){const n=[];for(const s of e.listSemantics())(s==="NORMAL"&&!t.has(s)||s==="TANGENT"&&!t.has(s)||s.startsWith("TEXCOORD_")&&!t.has(s)||s.startsWith("COLOR_")&&s!=="COLOR_0")&&n.push(s);return n}function kt(e,t,n,s=new Set){const a=e.getGraph().listChildEdges(n),i=new Set;for(const f of a)f.getChild()instanceof Ne&&i.add(f.getName());for(const f of a){const c=f.getName(),h=f.getChild();h instanceof vt&&i.has(c.replace(/Info$/,""))&&s.add(`TEXCOORD_${h.getTexCoord()}`),h instanceof Ne&&c.match(/normalTexture/i)&&s.add("TANGENT"),h instanceof _t&&kt(e,t,h,s)}const o=n instanceof Tt&&!n.getExtension("KHR_materials_unlit"),l=t.getMode()===P.Mode.POINTS;return o&&!l&&s.add("NORMAL"),s}function Os(e,t){const n=Is(e),s=new Set(n.map(l=>l.getTexCoord())),r=Array.from(s).sort(),a=new Map(r.map((l,f)=>[l,f])),i=new Map(r.map((l,f)=>[`TEXCOORD_${l}`,`TEXCOORD_${f}`]));for(const l of n){const f=l.getTexCoord();l.setTexCoord(a.get(f))}for(const l of t){const f=l.listSemantics().filter(c=>c.startsWith("TEXCOORD_")).sort();o(l,f),l.listTargets().forEach(c=>o(c,f))}function o(l,f){for(const c of f){const h=l.getAttribute(c);if(!h)continue;const u=i.get(c);u!==c&&(l.setAttribute(u,h),l.setAttribute(c,null))}}}async function xs(e){const t=e.getRoot(),n=e.getGraph(),s=e.getLogger(),a=t.listTextures().map(async i=>{var o;const l=await Rs(i);if(!l)return;ws(i)==="srgb"&&cn.convertSRGBToLinear(l,l);const f=i.getName()||i.getURI(),c=(o=i.getSize())==null?void 0:o.join("x"),h=Ms(i);for(const u of n.listParentEdges(i)){const g=u.getParent();g!==t&&js(g,l,u.getName(),s)&&u.dispose()}i.listParents().length===1&&(i.dispose(),s.debug(`${B}: Removed solid-color texture "${f}" (${c}px ${h.join(", ")})`))});await Promise.all(a)}function js(e,t,n,s){if(e instanceof Tt)switch(n){case"baseColorTexture":return e.setBaseColorFactor(Ts(t,t,e.getBaseColorFactor())),!0;case"emissiveTexture":return e.setEmissiveFactor(us([0,0,0],t.slice(0,3),e.getEmissiveFactor())),!0;case"occlusionTexture":return Math.abs(t[0]-1)<=Oe;case"metallicRoughnessTexture":return e.setRoughnessFactor(t[1]*e.getRoughnessFactor()),e.setMetallicFactor(t[2]*e.getMetallicFactor()),!0;case"normalTexture":return Rt(jt(xt(),t,[.5,.5,1,1]))<=Oe}return s.warn(`${B}: Detected single-color ${n} texture. Pruning ${n} not yet supported.`),!1}async function Rs(e){const t=await Ps(e);if(!t)return null;const n=[1/0,1/0,1/0,1/0],s=[-1/0,-1/0,-1/0,-1/0],r=[0,0,0,0],[a,i]=t.shape;for(let o=0;o<a;o++){for(let l=0;l<i;l++)for(let f=0;f<4;f++)n[f]=Math.min(n[f],t.get(o,l,f)),s[f]=Math.max(s[f],t.get(o,l,f));if(Rt(jt(r,s,n))/255>Oe)return null}return vs(r,ys(r,s,n),.5/255)}async function Ps(e){try{return await Yn(e.getImage(),e.getMimeType())}catch{return null}}const tt=2**32-1;var C;(function(e){e.RENDER="render",e.RENDER_CACHED="render-cached",e.UPLOAD="upload",e.UPLOAD_NAIVE="upload-naive",e.DISTINCT="distinct",e.DISTINCT_POSITION="distinct-position",e.UNUSED="unused"})(C||(C={}));function ue(e,t){const n=e.getAttribute("POSITION"),s=e.getIndices();switch(t){case C.RENDER:return s?s.getCount():n.getCount();case C.RENDER_CACHED:return s?new Set(s.getArray()).size:n.getCount();case C.UPLOAD_NAIVE:case C.UPLOAD:return n.getCount();case C.DISTINCT:case C.DISTINCT_POSITION:return zs(t);case C.UNUSED:return s?n.getCount()-new Set(s.getArray()).size:0;default:return ks(t)}}function zs(e){throw new Error(`Not implemented: ${e}`)}function ks(e){throw new Error(`Unexpected value: ${e}`)}function $s(e,t,n){const s=Le.fromGraph(e.getGraph());(!t||!n)&&([t,n]=Ls(e));const r=e.getIndices(),a=r?r.getArray():null,i=ue(e,C.RENDER),o=s.createAccessor(),l=i,f=Ct(l,n);for(let h=0;h<l;h++)f[h]=t[a?a[h]:h];e.setIndices(o.setArray(f));const c=Nt(e);for(const h of e.listAttributes()){const u=ee(s,h);xe(h,r,t,u,n),e.swap(h,u)}for(const h of e.listTargets())for(const u of h.listAttributes()){const g=ee(s,u);xe(u,r,t,g,n),h.swap(u,g)}r&&r.listParents().length===1&&r.dispose();for(const h of c)h.listParents().length===1&&h.dispose();return e}function xe(e,t,n,s,r){const a=e.getElementSize(),i=e.getArray(),o=t?t.getArray():null,l=t?t.getCount():e.getCount(),f=new i.constructor(r*a),c=new Uint8Array(r);for(let h=0;h<l;h++){const u=o?o[h]:h,g=n[u];if(!c[g]){for(let d=0;d<a;d++)f[g*a+d]=i[u*a+d];c[g]=1}}return s.setArray(f)}function Ls(e){const t=ue(e,C.UPLOAD),n=e.getIndices(),s=n?n.getArray():null;if(!n||!s)return[ss(t,1e6),t];const r=new Uint32Array(t).fill(tt);let a=0;for(let i=0;i<s.length;i++){const o=s[i];r[o]===tt&&(r[o]=a++)}return[r,a]}Me.ComponentType;P.Mode;P.Mode;const se="reorder",Us={target:"size",cleanup:!0};function Vs(e){const t=H(Us,e),n=t.encoder;if(!n)throw new Error(`${se}: encoder dependency required — install "meshoptimizer".`);return D(se,async s=>{const r=s.getLogger();await n.ready;const a=Fs(s);for(const i of a.indicesToAttributes.keys()){let o=i.getArray();o instanceof Uint32Array?o=o.slice():o=new Uint32Array(o);const[l,f]=n.reorderMesh(o,a.indicesToMode.get(i)===P.Mode.TRIANGLES,t.target==="size"),c=ee(s,i);c.setArray(f<=65534?new Uint16Array(o):o);for(const h of a.indicesToAttributes.get(i)){const u=ee(s,h);xe(h,i,l,u,f);for(const g of a.indicesToPrimitives.get(i)){g.getIndices()===i&&g.swap(i,c),g.swap(h,u);for(const d of g.listTargets())d.swap(h,u)}}}t.cleanup&&await s.transform(Pt({propertyTypes:[A.ACCESSOR],keepAttributes:!0,keepIndices:!0})),a.indicesToAttributes.size?r.debug(`${se}: Complete.`):r.warn(`${se}: No qualifying primitives found; may need to weld first.`)})}function Fs(e){const t=new Map,n=new Te,s=new Te,r=new Te;for(const a of e.getRoot().listMeshes())for(const i of a.listPrimitives()){const o=i.getIndices();if(o){t.set(o,i.getMode()),n.add(o,i);for(const l of Nt(i))s.add(o,l),r.add(l,i)}}return{indicesToPrimitives:n,indicesToAttributes:s,indicesToMode:t,attributesToPrimitives:r}}function Ds(e,t=1/0){if(Number.isFinite(t)&&t%4||t<=0)throw new Error("Limit must be positive multiple of four.");const n=e.getAttribute("POSITION").getCount(),s=e.listSemantics().filter(f=>f.startsWith("WEIGHTS_")).length,r=new Uint16Array(s*4),a=new Float32Array(s*4),i=new Float32Array(s*4),o=new Uint32Array(s*4),l=new Uint32Array(s*4);for(let f=0;f<n;f++){fe(e,f,"WEIGHTS",a),fe(e,f,"JOINTS",o);for(let c=0;c<s*4;c++)r[c]=c;r.sort((c,h)=>a[c]>a[h]?-1:1);for(let c=0;c<r.length;c++)i[c]=a[r[c]],l[c]=o[r[c]];he(e,f,"WEIGHTS",i),he(e,f,"JOINTS",l)}for(let f=s;f*4>t;f--){const c=e.getAttribute(`WEIGHTS_${f-1}`),h=e.getAttribute(`JOINTS_${f-1}`);e.setAttribute(`WEIGHTS_${f-1}`,null),e.setAttribute(`JOINTS_${f-1}`,null),c.listParents().length===1&&c.dispose(),h.listParents().length===1&&h.dispose()}Bs(e)}function Bs(e){if(!qs(e))return;const t=e.getAttribute("POSITION").getCount(),n=e.listSemantics().filter(h=>h.startsWith("WEIGHTS_")).length,s=e.getAttribute("WEIGHTS_0"),r=s.getArray(),a=s.getComponentType(),i=s.getNormalized(),o=i?a:void 0,l=i?U.decodeNormalizedInt(1,a):Number.EPSILON,f=new Uint32Array(n*4).fill(0),c=r.slice(0,n*4).fill(0);for(let h=0;h<t;h++){fe(e,h,"JOINTS",f),fe(e,h,"WEIGHTS",c,o);let u=nt(c,o);if(u!==0&&u!==1){if(Math.abs(1-u)>l)for(let g=0;g<c.length;g++)if(i){const d=U.decodeNormalizedInt(c[g],a);c[g]=U.encodeNormalizedInt(d/u,a)}else c[g]/=u;if(u=nt(c,o),i&&u!==1){for(let g=c.length-1;g>=0;g--)if(c[g]>0){const d=1-u;c[g]+=Math.sign(d)*U.encodeNormalizedInt(Math.abs(d),a);break}}}for(let g=c.length-1;g>=0;g--)c[g]===0&&(f[g]=0);he(e,h,"JOINTS",f),he(e,h,"WEIGHTS",c,o)}}function fe(e,t,n,s,r){let a;const i=[0,0,0,0];for(let o=0;a=e.getAttribute(`${n}_${o}`);o++){a.getElement(t,i);for(let l=0;l<4;l++)r?s[o*4+l]=U.encodeNormalizedInt(i[l],r):s[o*4+l]=i[l]}return s}function he(e,t,n,s,r){let a;const i=[0,0,0,0];for(let o=0;a=e.getAttribute(`${n}_${o}`);o++){for(let l=0;l<4;l++)r?i[l]=U.decodeNormalizedInt(s[o*4+l],r):i[l]=s[o*4+l];a.setElement(t,i)}}function nt(e,t){let n=0;for(let s=0;s<e.length;s++)t?n+=U.decodeNormalizedInt(e[s],t):n+=e[s];return n}function qs(e){const t=e.listSemantics().filter(r=>r.startsWith("WEIGHTS_")).map(r=>e.getAttribute(r)),n=t.map(r=>r.getNormalized()),s=t.map(r=>r.getComponentType());return new Set(n).size===1&&new Set(s).size===1}const V="quantize",Gs=[Int8Array,Int16Array,Int32Array],{TRANSLATION:Ws,ROTATION:Hs,SCALE:Xs,WEIGHTS:Ks}=$e.TargetPath,Qs=[Ws,Hs,Xs],ie={pattern:/.*/,quantizationVolume:"mesh",quantizePosition:14,quantizeNormal:10,quantizeTexcoord:12,quantizeColor:8,quantizeWeight:8,quantizeGeneric:12,normalizeWeights:!0,cleanup:!0};function Ve(e=ie){const t=H(ie,q({patternTargets:e.pattern||ie.pattern},e));return D(V,async n=>{const s=n.getLogger(),r=n.getRoot();let a;t.quantizationVolume==="scene"&&(a=rt(rr(r.listMeshes().map(at))));for(const o of n.getRoot().listMeshes()){t.quantizationVolume==="mesh"&&(a=rt(at(o))),a&&t.pattern.test("POSITION")&&(Js(n,o,a),er(o,1/a.scale));for(const l of o.listPrimitives()){const f=ue(l,C.RENDER),c=ue(l,C.UPLOAD);f<c/2&&$s(l),st(n,l,a,t);for(const h of l.listTargets())st(n,h,a,t)}}r.listMeshes().flatMap(o=>o.listPrimitives()).some($t)&&n.createExtension(At).setRequired(!0),t.cleanup&&await n.transform(Pt({propertyTypes:[A.ACCESSOR,A.SKIN,A.MATERIAL],keepAttributes:!0,keepIndices:!0,keepLeaves:!0,keepSolidTextures:!0}),fs({propertyTypes:[A.ACCESSOR,A.MATERIAL,A.SKIN],keepUniqueNames:!0})),s.debug(`${V}: Complete.`)})}function st(e,t,n,s){const r=t instanceof un,a=e.getLogger();for(const i of t.listSemantics()){if(!r&&!s.pattern.test(i)||r&&!s.patternTargets.test(i))continue;const o=t.getAttribute(i),{bits:l,ctor:f}=nr(i,o,a,s);if(!f)continue;if(l<8||l>16)throw new Error(`${V}: Requires bits = 8–16.`);if(o.getComponentSize()<=l/8)continue;const c=o.clone();if(i==="POSITION"){const h=n.scale,u=[];t instanceof P?rs(u,me(n)):as(u,[1/h,1/h,1/h]);for(let g=0,d=[0,0,0],m=c.getCount();g<m;g++)c.getElement(g,d),c.setElement(g,cs(d,d,u))}tr(c,f,l),t.setAttribute(i,c)}if(s.normalizeWeights&&t.getAttribute("WEIGHTS_0")&&Ds(t,1/0),t instanceof P&&t.getIndices()&&t.listAttributes().length&&t.listAttributes()[0].getCount()<65535){const i=t.getIndices();i.setArray(new Uint16Array(i.getArray()))}}function rt(e){const{min:t,max:n}=e,s=Math.max((n[0]-t[0])/2,(n[1]-t[1])/2,(n[2]-t[2])/2);return{offset:[t[0]+(n[0]-t[0])/2,t[1]+(n[1]-t[1])/2,t[2]+(n[2]-t[2])/2],scale:s}}function Js(e,t,n){const s=me(n);for(const r of t.listParents()){if(!(r instanceof on))continue;const a=r.listParents().filter(u=>u instanceof $e),i=a.some(u=>Qs.includes(u.getTargetPath())),o=r.listChildren().length>0,l=r.getSkin();if(l){r.setSkin(Ys(l,n));continue}const f=r.getExtension("EXT_mesh_gpu_instancing");if(f){r.setExtension("EXT_mesh_gpu_instancing",Zs(f,n));continue}let c;o||i?(c=e.createNode("").setMesh(t),r.addChild(c).setMesh(null),a.filter(u=>u.getTargetPath()===Ks).forEach(u=>u.setTargetNode(c))):c=r;const h=c.getMatrix();Ue(h,h,s),c.setMatrix(h)}}function Ys(e,t){e=e.clone();const n=me(t),s=e.getInverseBindMatrices().clone(),r=[];for(let a=0,i=s.getCount();a<i;a++)s.getElement(a,r),Ue(r,r,n),s.setElement(a,r);return e.setInverseBindMatrices(s)}function Zs(e,t){var n,s,r;if(!e.getAttribute("TRANSLATION")&&!e.getAttribute("ROTATION")&&!e.getAttribute("SCALE"))return e;e=e.clone();const a=(n=e.getAttribute("TRANSLATION"))==null?void 0:n.clone(),i=(s=e.getAttribute("ROTATION"))==null?void 0:s.clone(),o=(r=e.getAttribute("SCALE"))==null?void 0:r.clone(),l=a||i||o,f=[0,0,0],c=[0,0,0,1],h=[1,1,1],u=[0,0,0],g=[0,0,0,1],d=[1,1,1],m=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],p=me(t);for(let y=0,T=l.getCount();y<T;y++)U.compose(a?a.getElement(y,u):f,i?i.getElement(y,g):c,o?o.getElement(y,d):h,m),Ue(m,m,p),U.decompose(m,u,g,d),a&&a.setElement(y,u),i&&i.setElement(y,g),o&&o.setElement(y,d);return a&&e.setAttribute("TRANSLATION",a),i&&e.setAttribute("ROTATION",i),o&&e.setAttribute("SCALE",o),e}function er(e,t){for(const n of e.listPrimitives()){let s=n.getMaterial();if(!s)continue;let r=s.getExtension("KHR_materials_volume");!r||r.getThicknessFactor()<=0||(r=r.clone().setThicknessFactor(r.getThicknessFactor()*t),s=s.clone().setExtension("KHR_materials_volume",r),n.setMaterial(s))}}function tr(e,t,n){const s=new t(e.getArray().length),r=Gs.includes(t)?1:0,a=n-r,i=t.BYTES_PER_ELEMENT*8-r,o=Math.pow(2,a)-1,l=i-a,f=2*a-i,c=[r>0?-1:0,1];for(let h=0,u=0,g=[];h<e.getCount();h++){e.getElement(h,g);for(let d=0;d<g.length;d++){let m=ar(g[d],c);m=Math.round(Math.abs(m)*o),m=m<<l|m>>f,s[u++]=m*Math.sign(g[d])}}e.setArray(s).setNormalized(!0).setSparse(!1)}function nr(e,t,n,s){const r=t.getMinNormalized([]),a=t.getMaxNormalized([]);let i,o;if(e==="POSITION")i=s.quantizePosition,o=i<=8?Int8Array:Int16Array;else if(e==="NORMAL"||e==="TANGENT")i=s.quantizeNormal,o=i<=8?Int8Array:Int16Array;else if(e.startsWith("COLOR_"))i=s.quantizeColor,o=i<=8?Uint8Array:Uint16Array;else if(e.startsWith("TEXCOORD_")){if(r.some(l=>l<0)||a.some(l=>l>1))return n.warn(`${V}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=s.quantizeTexcoord,o=i<=8?Uint8Array:Uint16Array}else{if(e.startsWith("JOINTS_"))return i=Math.max(...t.getMax([]))<=255?8:16,o=i<=8?Uint8Array:Uint16Array,t.getComponentSize()>i/8&&t.setArray(new o(t.getArray())),{bits:-1};if(e.startsWith("WEIGHTS_")){if(r.some(l=>l<0)||a.some(l=>l>1))return n.warn(`${V}: Skipping ${e}; out of [0,1] range.`),{bits:-1};i=s.quantizeWeight,o=i<=8?Uint8Array:Uint16Array}else if(e.startsWith("_")){if(r.some(l=>l<-1)||a.some(l=>l>1))return n.warn(`${V}: Skipping ${e}; out of [-1,1] range.`),{bits:-1};i=s.quantizeGeneric,o=r.some(l=>l<0)?o=i<=8?Int8Array:Int16Array:o=i<=8?Uint8Array:Uint16Array}else throw new Error(`${V}: Unexpected semantic, "${e}".`)}return{bits:i,ctor:o}}function at(e){const t=[],n=[];for(const r of e.listPrimitives()){const a=r.getAttribute("POSITION");a&&t.push(a);for(const i of r.listTargets()){const o=i.getAttribute("POSITION");o&&n.push(o)}}if(t.length===0)throw new Error(`${V}: Missing "POSITION" attribute.`);const s=it(t,3);if(n.length>0){const{min:r,max:a}=it(n,3);Ce(s.min,s.min,Ce(r,Qe(r,r,2),[0,0,0])),Se(s.max,s.max,Se(a,Qe(a,a,2),[0,0,0]))}return s}function sr(e,t){const n=t.getComponentSize();if(e==="POSITION"||e==="NORMAL"||e==="TANGENT")return n<4;if(e.startsWith("TEXCOORD_")){const s=t.getComponentType(),r=t.getNormalized();return n<4&&!(r&&s===Me.ComponentType.UNSIGNED_BYTE)&&!(r&&s===Me.ComponentType.UNSIGNED_SHORT)}return!1}function $t(e){for(const t of e.listSemantics()){const n=e.getAttribute("POSITION");if(sr(t,n))return!0}return e.propertyType===A.PRIMITIVE?e.listTargets().some($t):!1}function it(e,t){const n=new Array(t).fill(1/0),s=new Array(t).fill(-1/0),r=[],a=[];for(const i of e){i.getMinNormalized(r),i.getMaxNormalized(a);for(let o=0;o<t;o++)n[o]=Math.min(n[o],r[o]),s[o]=Math.max(s[o],a[o])}return{min:n,max:s}}function rr(e){const t=e[0];for(const n of e)Ce(t.min,t.min,n.min),Se(t.max,t.max,n.max);return t}function me(e){return is([],[0,0,0,1],e.offset,[e.scale,e.scale,e.scale])}function ar(e,t){return Math.min(Math.max(e,t[0]),t[1])}const ir=q({level:"high"},ie),ot="meshopt";function Lt(e){const t=H(ir,e),n=t.encoder;if(!n)throw new Error(`${ot}: encoder dependency required — install "meshoptimizer".`);return D(ot,async s=>{let r,a,i=t.quantizeNormal;s.getRoot().listAccessors().length!==0&&(t.level==="medium"?(r=/.*/,a=/.*/):(r=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR)(_\d+)?$/,a=/^(POSITION|TEXCOORD|JOINTS|WEIGHTS|COLOR|NORMAL|TANGENT)(_\d+)?$/,i=Math.min(i,8)),await s.transform(Vs({encoder:n,target:"size"}),Ve(q({},t,{pattern:r,patternTargets:a,quantizeNormal:i}))),s.createExtension(ae).setRequired(!0).setEncoderOptions({method:t.level==="medium"?ae.EncoderMethod.QUANTIZE:ae.EncoderMethod.FILTER}))})}const je="unweld",or={};function lr(e=or){return D(je,t=>{const n=t.getLogger(),s=new Map;for(const r of t.getRoot().listMeshes())for(const a of r.listPrimitives())cr(a,s);n.debug(`${je}: Complete.`)})}function cr(e,t=new Map){const n=e.getIndices();if(!n)return;const s=e.getGraph(),r=Le.fromGraph(s),a=r.getLogger(),i=e.getAttribute("POSITION").getCount();for(const l of e.listAttributes())e.swap(l,lt(r,l,n,t)),l.listParents().length===1&&l.dispose();for(const l of e.listTargets())for(const f of l.listAttributes())l.swap(f,lt(r,f,n,t)),f.listParents().length===1&&f.dispose();const o=e.getAttribute("POSITION").getCount();a.debug(`${je}: ${ts(i,o)} vertices.`),e.setIndices(null),n.listParents().length===1&&n.dispose()}function lt(e,t,n,s){if(s.has(t)&&s.get(t).has(n))return s.get(t).get(n);const r=t.getArray(),a=r.constructor,i=new a(n.getCount()*t.getElementSize()),o=n.getArray(),l=t.getElementSize();for(let c=0,h=n.getCount();c<h;c++)for(let u=0;u<l;u++)i[c*l+u]=r[o[c]*l+u];s.has(t)||s.set(t,new Map);const f=ee(e,t).setArray(i);return s.get(t).set(n,f),f}var ct;(function(e){e[e.STEP=0]="STEP",e[e.LERP=1]="LERP",e[e.SLERP=2]="SLERP"})(ct||(ct={}));const ur=1e-6;function fr(e,t,n,s=1e-4){const r=t.length/e.length,a=new Array(r).fill(0),i=new Array(r).fill(0),o=new Array(r).fill(0),l=new Array(r).fill(0),f=e.length-1;let c=1;for(let h=1;h<f;++h){const u=e[c-1],g=e[h],d=e[h+1],m=(g-u)/(d-u);let p=!1;if(g!==d&&(h!==1||g!==e[0]))if(Z(t,c-1,l),Z(t,h,i),Z(t,h+1,o),n==="slerp"){const y=dr(a,l,o,m),T=ft(l,i)+ft(i,o);p=!re(i,y,s)||T+Number.EPSILON>=Math.PI}else if(n==="lerp"){const y=gr(a,l,o,m);p=!re(i,y,s)}else n==="step"&&(p=!re(i,l)||!re(i,o));p&&(h!==c&&(e[c]=e[h],ut(t,c,Z(t,h,a))),c++)}return f>0&&(e[c]=e[f],ut(t,c,Z(t,f,a)),c++),c}function Z(e,t,n){for(let s=0,r=n.length;s<r;s++)n[s]=e[t*r+s];return n}function ut(e,t,n){for(let s=0,r=n.length;s<r;s++)e[t*r+s]=n[s]}function re(e,t,n=0){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(Math.abs(e[s]-t[s])>n)return!1;return!0}function hr(e,t,n){return e*(1-n)+t*n}function gr(e,t,n,s){for(let r=0;r<t.length;r++)e[r]=hr(t[r],n[r],s);return e}function dr(e,t,n,s){let r=t[0],a=t[1],i=t[2],o=t[3],l=n[0],f=n[1],c=n[2],h=n[3],u,g,d,m,p;return g=r*l+a*f+i*c+o*h,g<0&&(g=-g,l=-l,f=-f,c=-c,h=-h),1-g>ur?(u=Math.acos(g),d=Math.sin(u),m=Math.sin((1-s)*u)/d,p=Math.sin(s*u)/d):(m=1-s,p=s),e[0]=m*r+p*l,e[1]=m*a+p*f,e[2]=m*i+p*c,e[3]=m*o+p*h,e}function ft(e,t){const n=pr(e,t);return Math.acos(2*n*n-1)}function pr(e,t){return e[0]*t[0]+e[1]*t[1]+e[2]*t[2]+e[3]*t[3]}Promise.resolve();P.Mode;var Re;(function(e){e.LANCZOS3="lanczos3",e.LANCZOS2="lanczos2"})(Re||(Re={}));Re.LANCZOS3;const L="tangents",ht={overwrite:!1};function mr(e=ht){const t=H(ht,e);if(!t.generateTangents)throw new Error(`${L}: generateTangents callback required — install "mikktspace".`);return D(L,n=>{const s=n.getLogger(),r=new Map,a=new Map;let i=0;for(const o of n.getRoot().listMeshes()){const l=o.getName(),f=o.listPrimitives();for(let c=0;c<f.length;c++){const h=f[c];if(!br(h,s,l,c,t.overwrite))continue;const u=yr(h),g=h.getAttribute("POSITION").getArray(),d=h.getAttribute("NORMAL").getArray(),m=h.getAttribute(u).getArray(),p=r.get(g)||be();r.set(g,p);const y=r.get(d)||be();r.set(d,y);const T=r.get(m)||be();r.set(m,T);const v=h.getAttribute("TANGENT");v&&v.listParents().length===2&&v.dispose();const b=`${p}|${y}|${T}`;let _=a.get(b);if(_){s.debug(`${L}: Found cache for primitive ${c} of mesh "${l}".`),h.setAttribute("TANGENT",_),i++;continue}s.debug(`${L}: Generating for primitive ${c} of mesh "${l}".`);const E=h.getAttribute("POSITION").getBuffer(),x=t.generateTangents(g instanceof Float32Array?g:new Float32Array(g),d instanceof Float32Array?d:new Float32Array(d),m instanceof Float32Array?m:new Float32Array(m));for(let $=3;$<x.length;$+=4)x[$]*=-1;_=n.createAccessor().setBuffer(E).setArray(x).setType("VEC4"),h.setAttribute("TANGENT",_),a.set(b,_),i++}}i?s.debug(`${L}: Complete.`):s.warn(`${L}: No qualifying primitives found. See debug output.`)})}function yr(e){const t=e.getMaterial();if(!t)return"TEXCOORD_0";const n=t.getNormalTextureInfo();if(!n)return"TEXCOORD_0";const r=`TEXCOORD_${n.getTexCoord()}`;return e.getAttribute(r)?r:"TEXCOORD_0"}function br(e,t,n,s,r){return e.getMode()!==P.Mode.TRIANGLES||!e.getAttribute("POSITION")||!e.getAttribute("NORMAL")||!e.getAttribute("TEXCOORD_0")?(t.debug(`${L}: Skipping primitive ${s} of mesh "${n}": primitives must have attributes=[POSITION, NORMAL, TEXCOORD_0] and mode=TRIANGLES.`),!1):e.getAttribute("TANGENT")&&!r?(t.debug(`${L}: Skipping primitive ${s} of mesh "${n}": TANGENT found.`),!1):e.getIndices()?(t.warn(`${L}: Skipping primitive ${s} of mesh "${n}": primitives must be unwelded.`),!1):!0}async function Ar(e,t,n,s={}){var y;const{remapMaterials:r,animationEvents:a,textureOptions:i,optimizeOptions:o}=n,l=await t.readBinary(e),f=l.getRoot().listExtensionsUsed(),c=f.some(T=>T.extensionName==="EXT_meshopt_compression"),h=f.some(T=>T.extensionName==="KHR_mesh_quantization");if((i==null?void 0:i.textureType)==="ktx2"&&s.ktx2Encode){const T=l.getRoot().listTextures();T.length>0&&l.createExtension(fn).setRequired(!0);const v=T.filter(b=>b.getMimeType()!=="image/ktx2");await Promise.all(v.map(async b=>{b.setMimeType("image/ktx2");const _=b.getImage(),E=await s.ktx2Encode(_.buffer,{isUASTC:i.mode==="UASTC",qualityLevel:i.quality??255});b.setImage(E)}))}r&&l.getRoot().listMaterials().forEach((T,v)=>{if(r[v]){const b=l.createExtension(Ae).createGlTFRemapping().setRefId(r[v].refId);T.setExtension(Ae.EXTENSION_NAME,b)}}),a&&l.getRoot().listAnimations().forEach((T,v)=>{if(a[v]){const b=l.createExtension(He).createAnimationEvent().setEvents(a[v]);T.setExtension(He.EXTENSION_NAME,b)}});const g=[];o!=null&&o.meshopt&&!c&&(await oe.ready,g.push(Lt({encoder:oe}))),o!=null&&o.meshQuantize&&!h&&g.push(Ve({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),g.length>0&&await l.transform(...g);const d=await t.writeJSON(l,{format:hn.GLB});if(s.resolveRef&&r){const T=Ae.EXTENSION_NAME;(y=d.json.materials)==null||y.forEach(v=>{var _;const b=(_=v.extensions)==null?void 0:_[T];if(b!=null&&b.refId){const E=s.resolveRef(b.refId);E&&(v.extensions[T]={url:E.url})}})}return{name:n.name.replace(/\.[^.]+$/,"")+".glb",content:wt(d)}}const gt=Bt("div",{color:"$gray10"}),vr=pt(({asset:e,index:t,originMaterial:n})=>{const{assetStore:s}=Et(),r=e.remapMaterials[t];let a=Object.values(s.assets);a=a.filter(o=>o.getMetaConfig().type==="Material"&&!o.isSubAsset);const i=s.assets[r==null?void 0:r.refId];return I.jsx(qt,{dropLayer:mt.Material,assets:a,customFilter:o=>o.mainId!==e.id,onSelect:o=>{(!i||o.engineObject!==i.engineObject)&&e.replaceMaterial(t,o.getCurrentRef())},onDelete:()=>{r&&e.resetMaterial(t)},onLocate:()=>{r&&r.refId&&s.selectAsset(r.refId)},label:n.name,value:i==null?void 0:i.name,asset:i})}),_r=pt(({asset:e})=>{var o;const t=e.engineObject.materials,{inspectorFacade:n}=Et(),s=e.glTFInfo,r=(o=s.issues)==null?void 0:o.messages,{t:a}=Gt();function i(l,f){n.assetChange(e.id,l,f,"asset-meta")}return I.jsxs(I.Fragment,{children:[I.jsxs(Fe,{title:a("asset.gltf.basic-info"),defaultOpen:!0,children:[s.triangles?I.jsx(te,{label:a("asset.gltf.triangles"),children:I.jsx(ye,{value:s.triangles,disabled:!0})}):null,s.drawcall?I.jsx(te,{label:a("asset.gltf.drawcall"),children:I.jsx(ye,{value:s.drawcall,disabled:!0})}):null,I.jsx(ne,{label:a("asset.gltf.compute-tangents"),value:e.needComputeTangents,onChange:l=>{i("needComputeTangents",l)},checkboxLabel:I.jsx(gt,{children:a("asset.gltf.refresh-tip")})}),I.jsx(ne,{label:a("asset.gltf.keep-mesh-data"),value:e.params.keepMeshData,onChange:l=>{e.params={...e.params,keepMeshData:l}},checkboxLabel:I.jsx(gt,{children:a("asset.gltf.refresh-tip")})})]}),I.jsx(De,{}),r?I.jsxs(Wt.Fragment,{children:[I.jsxs(Fe,{title:`${a("asset.gltf.issues")}: ${r.length}`,defaultOpen:!1,children:[r.slice(0,15).map((l,f)=>I.jsx(te,{label:l.pointer,children:I.jsx(ye,{value:l.message,css:{color:"red"},disabled:!0})},f)),r.length>15?I.jsx(te,{label:"..."}):null]}),I.jsx(De,{})]}):null,I.jsx(Be,{label:a("asset.gltf.remapped-materials"),children:t==null?void 0:t.map((l,f)=>I.jsx(vr,{originMaterial:l,asset:e,index:f},`${e.id}-${f}`))}),I.jsxs(Be,{label:a("asset.gltf.compression"),children:[!e.optimize.meshopt&&I.jsx(ne,{label:a("asset.gltf.quantize"),value:e.optimize.meshQuantize,onChange:l=>{Tracert.click("c351684.d417982",{checked:l}),i("optimize",{...e.optimize,meshQuantize:l})}}),I.jsx(ne,{label:a("asset.gltf.meshopt"),value:e.optimize.meshopt,onChange:l=>{Tracert.click("c351684.d417983",{checked:l}),i("optimize",{...e.optimize,meshopt:l})}})]})]})});function ge(e){return/^(?:http|blob|data:|\/)/.test(e)}function Ut(e){return/^data:(.+?);base64,/.test(e)}function de(e,t){return t.charAt(0)==="."?dt(e+t):dt(e.substring(0,e.lastIndexOf("/")+1)+t)}function dt(e){const t=[],n=e.split("/");for(let s=0;s<n.length;s++){const r=n[s];if(!(!r||r===".")){if(r===".."){t.length>0&&t.pop();continue}t.push(r)}}return t.join("/")}async function Tr(e,t){const n=JSON.parse(await e.text()),s=n.images,r={},a="",i=[];if(s)for(let l=0;l<s.length;l++){const c=s[l].uri;if(c)if(ge(c))i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}));else{const h=de(a,c);i.push(t[h].arrayBuffer().then(u=>{r[c]=new Uint8Array(u)}))}}const o=n.buffers;if(o)for(let l=0;l<o.length;l++){const c=o[l].uri;if(c)if(!ge(c)&&!Ut(c)){const h=de(a,c);i.push(t[h].arrayBuffer().then(u=>{r[c]=new Uint8Array(u)}))}else i.push(fetch(c).then(h=>h.arrayBuffer()).then(h=>{r[c]=new Uint8Array(h)}))}return await Promise.all(i),bn({json:n,resources:r})}async function Er(e){const t={uploadFiles:[],errors:[]};for(const n in e){const s=e[n],a=s.name.toLowerCase();if(a.endsWith(".glb")||a.endsWith(".fbx"))t.uploadFiles.push({main:s});else if(a.endsWith(".gltf")){const i=await wr(s,e);typeof i=="string"?t.errors.push(i):t.uploadFiles.push(i)}}return t}async function wr(e,t){const n=JSON.parse(await e.text()),s=n.images,r=n.buffers,a="",i={main:e,subFiles:{},postfix:".glb"};if(s)for(let o=0;o<s.length;o++){const f=s[o].uri;if(f&&!ge(f)){const c=de(a,f);if(t[c])i.subFiles[c]=t[c];else return`${f} is not found in the files.`}}if(r)for(let o=0;o<r.length;o++){const f=r[o].uri;if(f&&!ge(f)&&!Ut(f)){const c=de(a,f);if(t[c])i.subFiles[c]=t[c];else return`${f} is not found in the files.`}}return i}async function Ir(e,t){const n=Ht(e.main,"model.gltf"),s=n.name.replace(/\.[^.]+$/,".glb");if(n.name.toLocaleLowerCase().endsWith(".gltf")){const r=e.subFiles??{},a=await Tr(n,r);return new File([a.buffer],s)}return n}class Pe{static update(t,n){!this.entity&&(this.entity=t.createChild("glTF"));const s=this.tempCloneEntity=n.engineObject.instantiateSceneRoot();this.entity.addChild(s)}static clear(){this.entity.clearChildren(),this.tempCloneEntity&&this.tempCloneEntity.destroy()}}w(Pe,"entity"),w(Pe,"tempCloneEntity");var Mr=Object.defineProperty,Nr=Object.getOwnPropertyDescriptor,z=(e,t,n,s)=>{for(var r=s>1?void 0:s?Nr(t,n):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(s?i(t,n,r):i(r))||r);return s&&r&&Mr(t,n,r),r};class R extends dn{constructor(){super();w(this,"animationNames",[]);w(this,"frameTime",0);w(this,"duration",0);w(this,"playing",!1);w(this,"animationIndex",0);w(this,"selectedClip");w(this,"_updateComponent");w(this,"_clips",[]);yt(this)}setViewAsset(n,s){const{animations:r=[]}=n.engineObject;this._clips=r,this.animationIndex=0,this.animationNames=r.map(i=>i.name),this._entity=n.instantiateEngineObject(),s.addChild(this._entity);const a=this;r.length>0&&(this._updateComponent=this._entity.addComponent(class extends Xt{onUpdate(i){a._onUpdate(i)}})),this.duration=0}stopViewAsset(){var n;super.stopViewAsset(),this.frameTime=0,this.pauseAnimation(),(n=this._updateComponent)==null||n.destroy(),this.animationNames=null}selectAnimation(n){this.selectedClip=this._clips[n],this.frameTime=0,this.duration=this.selectedClip.length,this.animationIndex=n,this._sampleAnimation()}setFrameTime(n){this.frameTime=n,this._sampleAnimation()}playAnimation(){this.selectedClip&&(this.playing=!0)}pauseAnimation(){this.playing=!1}_onUpdate(n){!this.playing||!this.selectedClip||!this.duration||(this.frameTime+=n,this.frameTime>this.duration&&(this.frameTime%=this.duration),this._sampleAnimation())}_sampleAnimation(){try{this.selectedClip._sampleAnimation(this._entity.children[0],this.frameTime)}catch(n){console.warn(n)}}}z([j],R.prototype,"animationNames",2);z([j],R.prototype,"frameTime",2);z([j],R.prototype,"duration",2);z([j],R.prototype,"playing",2);z([j],R.prototype,"animationIndex",2);z([G],R.prototype,"selectAnimation",1);z([G],R.prototype,"setFrameTime",1);z([G],R.prototype,"playAnimation",1);z([G],R.prototype,"pauseAnimation",1);z([G],R.prototype,"_onUpdate",1);function ze(e){return typeof e=="object"&&e!==null||typeof e=="function"}function ke(e){return e.getComponentsIncludeChildren(Kt,[])}function Cr(e){if(!e)return[];const t=[],n=new Set;for(const s of ke(e)){const r=s.animatorController;!ze(r)||n.has(r)||(n.add(r),t.push(r))}return t}function Sr(e,t,n){if(!e||!t||!n)return;const s=ke(e),r=ke(t),a=Math.min(s.length,r.length);for(let i=0;i<a;i++){const o=s[i].animatorController,l=r[i].animatorController;if(!ze(o)||!ze(l))continue;const f=n.engineObjectToAssetMap.get(o);f&&n.engineObjectToAssetMap.set(l,f)}}var Or=Object.defineProperty,xr=Object.getOwnPropertyDescriptor,k=(e,t,n,s)=>{for(var r=s>1?void 0:s?xr(t,n):t,a=e.length-1,i;a>=0;a--)(i=e[a])&&(r=(s?i(t,n,r):i(r))||r);return s&&r&&Or(t,n,r),r};const we=an("gltf");function jr(e,t){const n=e.transform;!t||!n||(Ie(n.position,t.position,{x:0,y:0,z:0}),Ie(n.rotation,t.rotation,{x:0,y:0,z:0}),Ie(n.scale,t.scale,{x:1,y:1,z:1}))}function Ie(e,t,n){if(!t)return;const s=Number(t.x??e.x??n.x),r=Number(t.y??e.y??n.y),a=Number(t.z??e.z??n.z);if(typeof e.set=="function"){e.set(s,r,a);return}e.x=s,e.y=r,e.z=a}let O=class extends gn{constructor(t){super(t);w(this,"exportedUrl","");w(this,"glTFInfo",{drawcall:void 0,triangles:void 0,issues:void 0});w(this,"remapMaterials",{});w(this,"animationEvents",{});w(this,"needComputeTangents",!0);w(this,"fbxUrl",null);w(this,"optimize",{meshopt:!1,meshQuantize:!1});w(this,"params",{keepMeshData:!1});w(this,"initCompleted");w(this,"_rootKey","defaultSceneRoot");w(this,"mappedMaterialsPath",[]);w(this,"_initCompletedResolve");w(this,"_autorunDisposer",null);w(this,"_propertyChangeListeners",new Map);yt(this),this.initCompleted=new Promise(n=>{this._initCompletedResolve=n})}applyMetaFromDomain(t){if(super.applyMetaFromDomain(t),"needComputeTangents"in t&&(this.needComputeTangents=t.needComputeTangents),"optimize"in t&&typeof t.optimize=="object"){const n=t.optimize;this.optimize={...this.optimize,...n}}}async generateSubAssets(){const t=this.engineObject;if(this._subAssets=[],t.meshes)for(let s=0;s<t.meshes.length;s++){const r=t.meshes[s];for(let a=0;a<r.length;a++){const i=await this.root.assetStore.createSubAsset("Mesh",r[a],this.id,`meshes[${s}][${a}]`);this._subAssets.push(i)}}if(t.textures)for(let s=0;s<t.textures.length;s++){const r=await this.root.assetStore.createSubAsset("Texture",t.textures[s],this.id,`textures[${s}]`);this._subAssets.push(r)}if(t.animations)for(let s=0;s<t.animations.length;s++){const r=t.animations[s],a=this.animationEvents[s];a&&a.forEach(o=>{r.addEvent(o.functionName,o.time,o.parameter)});const i=await this.root.assetStore.createSubAsset("AnimationClip",r,this.id,`animations[${s}]`);this._subAssets.push(i)}const n=Cr(t.defaultSceneRoot);for(let s=0;s<n.length;s++){const r=await this.root.assetStore.createSubAsset("AnimatorController",n[s],this.id,`animatorController[${s}]`);this._subAssets.push(r)}if(t.materials)for(let s=0;s<t.materials.length;s++){const r=await this.root.assetStore.createSubAsset("Material",t.materials[s],this.id,`materials[${s}]`);this._subAssets.push(r)}}async initByMain(t,n){const{engine:s,meta:r}=this;this.url=n,this.animationEvents=r.animationEvents||{},this.optimize=r.optimize??this.optimize;let a=this.optimize.meshopt,i=this.optimize.meshQuantize;this._autorunDisposer=Qt(()=>{const c=this.optimize.meshQuantize;i!==c&&(this.optimize.meshQuantize=c,i=c,this._saveMetaAndReload());const h=this.optimize.meshopt;a!==h&&(this.optimize.meshopt=h,a=h,this._saveMetaAndReload())}),this.params=r.params??this.params;let o;try{o=URL.createObjectURL(t),await this.initByUrl(o+"#.glb",s)}finally{o!==void 0&&URL.revokeObjectURL(o)}this.needComputeTangents=r.needComputeTangents??!0;const f=Object.keys(r.remapMaterials||{}).filter(c=>r.remapMaterials[c]).map(c=>{const h=r.remapMaterials[c];return new Promise(u=>{this.on("initcomplete",async()=>{await this.replaceMaterial(Number(c),h,!1),u()})})});f.length?Promise.all(f).finally(()=>this._initCompletedResolve()).catch(()=>{}):this._initCompletedResolve(),this.fbxUrl=r.fbxUrl}_saveMetaAndReload(){qe.success(bt("Success. page will reload, please wait...")),this.root.assetFacade.persistAssetMetaImmediate(this.id).then(()=>{window.location.reload()}).catch(t=>{we.error("Failed to persist optimize config before reload",t),qe.error("Failed to save optimize config, reload canceled.")})}resetMaterial(t){const n=this._engineObject.materials[t];this._internalReplaceMaterial(t,n),this.remapMaterials[t]=void 0,this.root.assetFacade.persistAssetMeta(this.id)}async replaceMaterial(t,n,s=!0){this.remapMaterials[t]=n;const r=this._findComponentsByMaterialPathIndex(t),a=await this.root.assetStore.getAssetByRef(n);if(a instanceof pn){const i=a.engineObject;r.forEach(({component:c,materialIndex:h})=>{c.setMaterial(h,i)});const o=String(t),l=this._propertyChangeListeners.get(o);l&&a.off("propertychange",l);const f=()=>{this.updateThumbnail()};this._propertyChangeListeners.set(o,f),a.on("propertychange",f)}else we.warn(`${n.refId} shouldn't be selected`);s&&await this.root.assetFacade.persistAssetMeta(this.id),this.updateThumbnail()}updateAnimationEvents(t,n){this.animationEvents[t]=n,this.root.assetFacade.persistAssetMeta(this.id)}async instantiate(t,n,s){await this.initCompleted;const r=this.instantiateEngineObject();jr(r,n);const a=t.createByEngineObject(r,s==null?void 0:s.expectedRootId);if(await a.ensureReady(),a.name=this.name.replace(/\.glb$/g,""),this.addInstance(a),s!=null&&s.expectedBindingId&&a.pendingInstance&&(a.pendingInstance={...a.pendingInstance,bindingId:s.expectedBindingId}),s!=null&&s.deferDomainBinding){if(!s.deferredInstanceBindings)throw new Error(`GlTFAsset "${this.id}" cannot defer domain binding without a deferred binding queue.`);s.deferredInstanceBindings.push(()=>this._bindDeferredDomainInstance(a,s))}return a}_bindDeferredDomainInstance(t,n){var a;const s=((a=t.pendingInstance)==null?void 0:a.assetKind)==="glTF"&&t.pendingInstance.assetId===this.id?t.pendingInstance.bindingId:void 0,r=Jt({state:this.root.domainStore.state,assetId:this.id,rootEntityId:t.id,expectedBindingId:n==null?void 0:n.expectedBindingId,pendingBindingId:s,createBindingId:()=>`binding-${Yt().slice(0,8)}`});if(r.kind!=="none"){if(r.kind==="update"){this.root.prefabFacade.updateBindingSourceBaseline(r);return}this.root.prefabFacade.bindExistingInstance({assetId:r.assetId,assetKind:r.assetKind,bindingId:r.bindingId,instanceRootEntityId:r.instanceRootEntityId,entityMappings:r.entityMappings,componentMappings:r.componentMappings,sourceEntitySnapshots:r.sourceEntitySnapshots,undoable:!1})}}destroy(){var n;(n=this._autorunDisposer)==null||n.call(this),this._autorunDisposer=null,this._propertyChangeListeners.clear();const t=this.engineObject;t&&(t._defaultSceneRoot.destroy(),t.destroy()),super.destroy()}instantiateEngineObject(){var n;const t=super.instantiateEngineObject();return Sr((n=this.engineObject)==null?void 0:n.defaultSceneRoot,t,this.root.assetStore),this._fixClonedSkins(t),t}_fixClonedSkins(t){const n=t.getComponentsIncludeChildren(Zt,[]);for(const s of n){const r=s.skin;if(r&&r.bones.length>0&&!r._skinMatrices){const a=r.bones;r.bones=a}}}_instantiateEngineObject(){return this.engineObject.instantiateSceneRoot()}_internalReplaceMaterial(t,n){this._findComponentsByMaterialPathIndex(t).forEach(({component:r,materialIndex:a})=>{r.setMaterial(a,n)}),this.updateThumbnail()}_findComponentsByMaterialPathIndex(t){const n=[...this._clonedEntities,this._engineObject.defaultSceneRoot],s=this.mappedMaterialsPath[t],r=[];if(!s)return we.warn(`${this._name} replaced material not found.(gltf may be replaced either)`),r;for(let a=0;a<n.length;a++){const i=n[a];s.forEach(o=>{const f=Pr(o.entityPath,i).getComponents(Ge,[]);r.push({component:f[o.componentIndex],materialIndex:o.materialIndex})})}return r}async initByUrl(t,n){const s=await n.resourceManager.load({type:en.GLTF,url:t,params:this.params});return this.initMappedMaterialPath(s),this.bindEngineObject(s),this._updateDragTempEntity(),await this.generateSubAssets(),await this.initBasicInfo(s),this}async getRemappedMaterial(t){var s;const n=this.remapMaterials[t];return n?(s=await this.root.assetStore.getAssetByRef(n))==null?void 0:s.engineObject:this._engineObject.materials[t]}initMappedMaterialPath(t){const n=t.materials,s=t.defaultSceneRoot;if(n){const r=t.defaultSceneRoot.getComponentsIncludeChildren(We,[]);n.forEach(a=>{const i=[];this.mappedMaterialsPath.push(i);for(let o=0;o<r.length;o++){const l=r[o],f=l.getMaterials(),c=l.entity.getComponents(Ge,[]);for(let h=0;h<f.length;h++)f[h]===a&&i.push({entityPath:Rr(l.entity,s),componentIndex:c.indexOf(l),materialIndex:h})}})}}async initBasicInfo(t){this.glTFInfo.drawcall=t.defaultSceneRoot.getComponentsIncludeChildren(We,[]).length}};k([j,tn()],O.prototype,"exportedUrl",2);k([W(),j],O.prototype,"remapMaterials",2);k([W()],O.prototype,"animationEvents",2);k([W(),j],O.prototype,"needComputeTangents",2);k([W(),j],O.prototype,"fbxUrl",2);k([W(),j],O.prototype,"optimize",2);k([W(),j],O.prototype,"params",2);k([nn],O.prototype,"applyMetaFromDomain",1);k([G],O.prototype,"resetMaterial",1);O=k([sn({type:"glTF",label:bt("asset.gltf.title"),loaderType:"GLTF",importMenuConfig:{type:rn.Upload,tooltip:"请上传模型文件(支持gltf,glb,fbx,obj)或包含模型和资源文件(bin、贴图等)的zip压缩包",accept:".zip,.fbx,.gltf,.glb,application/json",subAccept:".bin,.jpeg,.jpg,.png",multiple:!0},filterUploadFiles:Er,preUpload:Ir,extname:"glb",dragLayer:mt.GlTF,customInspector:_r,viewer:R,thumbnail:Pe,async preInitialize({main:e,meta:t,name:n}){const s=new Uint8Array(await e.arrayBuffer()),r=await ve.readBinary(s),a=t.optimize||{},i=t.needComputeTangents??!0,o=a.meshQuantize,l=a.meshopt,f=[],c=r.getRoot().listExtensionsUsed(),h=c.some(d=>d.extensionName===At.EXTENSION_NAME),u=c.some(d=>d.extensionName===ae.EXTENSION_NAME);o&&!h&&f.push(Ve({quantizePosition:16,quantizeNormal:12,quantizeTexcoord:14})),l&&!u&&(await oe.ready,f.push(Lt({encoder:oe})));try{i&&(f.push(lr()),f.push(mr({generateTangents:window.mikktspace.generateTangents,overwrite:!0}))),await r.transform(...f)}catch(d){console.error("The gltf-transform plugin encountered some errors when performing meshopt, quantize, or calculating tangents, we have disabled these features automatically.",d)}const g=await ve.writeBinary(r);return new File([g.buffer],n,{type:"model/gltf-binary"})},async bundle({content:e,name:t,meta:n},s,r){var o;const a=new Uint8Array(await e.arrayBuffer()),i=await Ar(a,ve,{name:t,remapMaterials:n.remapMaterials,animationEvents:n.animationEvents??{},textureOptions:(o=s.assetOptions)==null?void 0:o.textureOptions,optimizeOptions:n.optimize},{resolveRef:r?l=>r.resolveRef(l):void 0,ktx2Encode:(l,f)=>mn.encode(l,f)});return{name:i.name,content:new Blob([i.content],{type:"model/gltf-binary"})}}})],O);function Rr(e,t){const n=[];for(;e!==t;)n.unshift(e.siblingIndex),e=e.parent;return n}function Pr(e,t){let n=t;for(let s=0;s<e.length;s++)n=n.children[e[s]];return n}const qr=Object.freeze(Object.defineProperty({__proto__:null,get GlTFAsset(){return O}},Symbol.toStringTag,{value:"Module"}));export{O as G,R as a,qr as b};
@@ -1,4 +1,4 @@
1
- import{c as e}from"./createReactComponent-baa41397.js";/**
1
+ import{c as e}from"./createReactComponent-3e49f864.js";/**
2
2
  * @license @tabler/icons-react v3.24.0 - MIT
3
3
  *
4
4
  * This source code is licensed under the MIT license.
@@ -1,4 +1,4 @@
1
- import{c as e}from"./createReactComponent-baa41397.js";/**
1
+ import{c as e}from"./createReactComponent-3e49f864.js";/**
2
2
  * @license @tabler/icons-react v3.24.0 - MIT
3
3
  *
4
4
  * This source code is licensed under the MIT license.
@@ -1 +1 @@
1
- var m=Object.defineProperty;var u=(r,e,o)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var p=(r,e,o)=>(u(r,typeof e!="symbol"?e+"":e,o),o);import{a as n,s as y,aD as v,p as c,C as g,l as P,f as b,h as f,g as C,E as L,d as _}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";var x=Object.defineProperty,O=Object.getOwnPropertyDescriptor,h=(r,e,o,l)=>{for(var a=l>1?void 0:l?O(e,o):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(a=(l?i(e,o,a):i(a))||a);return l&&a&&x(e,o,a),a};const t=[n.Everything,n.Nothing];class d extends L{constructor(){super(...arguments);p(this,"color",{r:1,g:1,b:1,a:1,intensity:1});p(this,"cullingMask",_(n.Everything,t))}}h([y(v()),c({label:"light.color",type:g.Color,mode:"hdr",bindPath:"color"})],d.prototype,"color",2);h([y(P(t)),b(f(t)),c({label:"light.culling-mask",type:g.Select,...C(t),bindPath:"cullingMask"})],d.prototype,"cullingMask",2);export{d as L};
1
+ var m=Object.defineProperty;var u=(r,e,o)=>e in r?m(r,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[e]=o;var p=(r,e,o)=>(u(r,typeof e!="symbol"?e+"":e,o),o);import{a as n,s as y,aD as v,p as c,C as g,l as P,f as b,h as f,g as C,E as L,d as _}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";var x=Object.defineProperty,O=Object.getOwnPropertyDescriptor,h=(r,e,o,l)=>{for(var a=l>1?void 0:l?O(e,o):e,s=r.length-1,i;s>=0;s--)(i=r[s])&&(a=(l?i(e,o,a):i(a))||a);return l&&a&&x(e,o,a),a};const t=[n.Everything,n.Nothing];class d extends L{constructor(){super(...arguments);p(this,"color",{r:1,g:1,b:1,a:1,intensity:1});p(this,"cullingMask",_(n.Everything,t))}}h([y(v()),c({label:"light.color",type:g.Color,mode:"hdr",bindPath:"color"})],d.prototype,"color",2);h([y(P(t)),b(f(t)),c({label:"light.culling-mask",type:g.Select,...C(t),bindPath:"cullingMask"})],d.prototype,"cullingMask",2);export{d as L};
@@ -1 +1 @@
1
- var f=Object.defineProperty;var c=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(c(o,typeof e!="symbol"?e+"":e,t),t);import{L as g}from"./module-83a57161.js";import{E as b,p as l,C as a,s}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import{c as P}from"./Component-398551a0.js";import"./postmen-3b48c572.js";var d=Object.defineProperty,L=Object.getOwnPropertyDescriptor,n=(o,e,t,y)=>{for(var i=y>1?void 0:y?L(e,t):e,u=o.length-1,m;u>=0;u--)(m=o[u])&&(i=(y?m(e,t,i):m(i))||i);return y&&i&&d(e,t,i),i};let r=class extends b{constructor(e,t){super(e,t);p(this,"resource",null);p(this,"autoPlay",!0);p(this,"isLooping",!0);p(this,"speed",1);p(this,"priority",0)}};n([l({label:"lottie.resource.label",info:"lottie.resource.info",type:a.AssetPicker,assetType:"Lottie",bindPath:"resource"}),s()],r.prototype,"resource",2);n([l({label:"lottie.auto-play.label",info:"lottie.auto-play.info",type:a.Toggle,bindPath:"autoPlay",onChange(o,e,t){t||o.engineObject.pause()}}),s()],r.prototype,"autoPlay",2);n([l({label:"lottie.is-looping.label",info:"lottie.is-looping.info",type:a.Toggle,bindPath:"isLooping"}),s()],r.prototype,"isLooping",2);n([l({label:"lottie.speed.label",info:"lottie.speed.info",type:a.Number,dragStep:.01,bindPath:"speed"}),s()],r.prototype,"speed",2);n([l({label:"lottie.priority.label",info:"lottie.priority.info",type:a.Number,bindPath:"priority"}),s()],r.prototype,"priority",2);r=n([P({type:"LottieAnimation",external:!0,componentsMenu:{group:"2D",label:"component.lottie-animation.title"}})],r);b.registerCustomEngineComponent("LottieAnimation",g);export{r as LottieAnimationComponent};
1
+ var f=Object.defineProperty;var c=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var p=(o,e,t)=>(c(o,typeof e!="symbol"?e+"":e,t),t);import{L as g}from"./module-136992e3.js";import{E as b,p as l,C as a,s}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import{c as P}from"./Component-c3c0c167.js";import"./postmen-0413c689.js";var d=Object.defineProperty,L=Object.getOwnPropertyDescriptor,n=(o,e,t,y)=>{for(var i=y>1?void 0:y?L(e,t):e,u=o.length-1,m;u>=0;u--)(m=o[u])&&(i=(y?m(e,t,i):m(i))||i);return y&&i&&d(e,t,i),i};let r=class extends b{constructor(e,t){super(e,t);p(this,"resource",null);p(this,"autoPlay",!0);p(this,"isLooping",!0);p(this,"speed",1);p(this,"priority",0)}};n([l({label:"lottie.resource.label",info:"lottie.resource.info",type:a.AssetPicker,assetType:"Lottie",bindPath:"resource"}),s()],r.prototype,"resource",2);n([l({label:"lottie.auto-play.label",info:"lottie.auto-play.info",type:a.Toggle,bindPath:"autoPlay",onChange(o,e,t){t||o.engineObject.pause()}}),s()],r.prototype,"autoPlay",2);n([l({label:"lottie.is-looping.label",info:"lottie.is-looping.info",type:a.Toggle,bindPath:"isLooping"}),s()],r.prototype,"isLooping",2);n([l({label:"lottie.speed.label",info:"lottie.speed.info",type:a.Number,dragStep:.01,bindPath:"speed"}),s()],r.prototype,"speed",2);n([l({label:"lottie.priority.label",info:"lottie.priority.info",type:a.Number,bindPath:"priority"}),s()],r.prototype,"priority",2);r=n([P({type:"LottieAnimation",external:!0,componentsMenu:{group:"2D",label:"component.lottie-animation.title"}})],r);b.registerCustomEngineComponent("LottieAnimation",g);export{r as LottieAnimationComponent};
@@ -1 +1 @@
1
- var c=Object.defineProperty;var u=(e,t,o)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var p=(e,t,o)=>(u(e,typeof t!="symbol"?t+"":t,o),o);import{j as d,u as m,w as b,x as h,n as w,e as f,o as y}from"./index-b126bb6b.js";import"./index-c8ed2a45.js";import"./postmen-3b48c572.js";var v=Object.defineProperty,D=Object.getOwnPropertyDescriptor,l=(e,t,o,r)=>{for(var n=r>1?void 0:r?D(t,o):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(n=(r?a(t,o,n):a(n))||n);return r&&n&&v(t,o,n),n};let i=class extends d{constructor(t){super(t);p(this,"content","");m(this),this.onDoubleClick=this.onDoubleClick.bind(this)}async initByMain(t){this.content=await t.text()}async initByCreation(){return""}getMainData(){return this.content}onDoubleClick(){b(this.root.projectStore.id,this.id)}};l([h],i.prototype,"content",2);i=l([w({type:"Markdown",label:f("asset.markdown.title"),defaultName:"Document.md",extname:"md",importMenuConfig:{type:y.Add},bundle({content:e}){return{content:new Blob([e],{type:"text/markdown; charset=utf-8"})}}})],i);export{i as MarkdownAsset};
1
+ var c=Object.defineProperty;var u=(e,t,o)=>t in e?c(e,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[t]=o;var p=(e,t,o)=>(u(e,typeof t!="symbol"?t+"":t,o),o);import{j as d,u as m,w as b,x as h,n as w,e as f,o as y}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";var v=Object.defineProperty,D=Object.getOwnPropertyDescriptor,l=(e,t,o,r)=>{for(var n=r>1?void 0:r?D(t,o):t,s=e.length-1,a;s>=0;s--)(a=e[s])&&(n=(r?a(t,o,n):a(n))||n);return r&&n&&v(t,o,n),n};let i=class extends d{constructor(t){super(t);p(this,"content","");m(this),this.onDoubleClick=this.onDoubleClick.bind(this)}async initByMain(t){this.content=await t.text()}async initByCreation(){return""}getMainData(){return this.content}onDoubleClick(){b(this.root.projectStore.id,this.id)}};l([h],i.prototype,"content",2);i=l([w({type:"Markdown",label:f("asset.markdown.title"),defaultName:"Document.md",extname:"md",importMenuConfig:{type:y.Add},bundle({content:e}){return{content:new Blob([e],{type:"text/markdown; charset=utf-8"})}}})],i);export{i as MarkdownAsset};
@@ -0,0 +1 @@
1
+ var N=Object.defineProperty;var $=(p,t,e)=>t in p?N(p,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):p[t]=e;var f=(p,t,e)=>($(p,typeof t!="symbol"?t+"":t,e),e);import{y as j,bG as F,bH as V,bI as U,F as G,ai as K,V as z,b4 as H,b3 as b,j as Q,q as k,u as W,bJ as D,bK as A,a1 as m,a2 as T,bL as J,C as O,bM as w,bN as Y,aE as S,bO as q,e as E,bP as X,K as Z,ae as ee,ah as te,af as C,R as v,_ as ae,z as re,x as L,aC as _,n as se,o as ie}from"./index-d497fb6d.js";import"./index-8a22fe59.js";import"./postmen-0413c689.js";import{M as ne}from"./MaterialInspector-45e208c7.js";import{A as oe}from"./AssetViewer-9f395efb.js";import{E as g,s as x}from"./shader-data-utils-e38a959d.js";class he extends oe{constructor(){super(...arguments);f(this,"_sphereRenderer",null);f(this,"_particleRenderer",null);f(this,"_asset",null);f(this,"_shaderReactionDisposer",null);f(this,"onShaderChange",()=>{const{_asset:e}=this;e.engineObject.shader.name==="Effect/Particle"?(this._particleRenderer.entity.isActive=!0,this._sphereRenderer.entity.isActive=!1,this._particleRenderer.setMaterial(e.engineObject)):(this._particleRenderer.entity.isActive=!1,this._sphereRenderer.entity.isActive=!0,this._sphereRenderer.setMaterial(e.engineObject))})}setViewAsset(e,r){if(!(e instanceof y))return;const i=r.createChild("material");this._asset=e;const a=this._sphereRenderer=i.createChild("mat").addComponent(j);a.mesh=F.createSphere(r.engine,1,32,!0);const n=this._particleRenderer=i.createChild("pat").addComponent(V);n.generator.main.duration=1e3,n.generator.main.startSpeed.constant=0,this._entity=i,r.addChild(this._entity),this.onShaderChange(),this._shaderReactionDisposer=U(()=>{var o,l;return(l=(o=this._asset)==null?void 0:o.shaderRef)==null?void 0:l.refId},()=>{this.onShaderChange()})}stopViewAsset(){var e;super.stopViewAsset(),(e=this._shaderReactionDisposer)==null||e.call(this),this._shaderReactionDisposer=null,this._asset=null}}class P{static update(t,e){if(!(e instanceof y))return;const r=e.engineObject;if(!r||!r.shader){this.entity&&this.sphereRenderer&&this.particleRenderer&&this.clear();return}this.entity?this.entity.isActive=!0:this.initScene(t),r.shader.name==="Effect/Particle"?(this.sphereRenderer.entity.isActive=!1,this.particleRenderer.entity.isActive=!0,this.particleRenderer.setMaterial(r),this.particleRenderer.generator._playTime=5):(this.particleRenderer.entity.isActive=!1,this.sphereRenderer.entity.isActive=!0,this.sphereRenderer.setMaterial(r))}static clear(){var t,e;(t=this.sphereRenderer)!=null&&t.entity&&(this.sphereRenderer.entity.isActive=!1),(e=this.particleRenderer)!=null&&e.entity&&(this.particleRenderer.entity.isActive=!1),this.entity&&(this.entity.isActive=!1)}static initScene(t){const e=this.entity=t.createChild("material"),r=this.sphereRenderer=e.createChild("mat").addComponent(j);r.mesh=F.createSphere(t.engine,2,64,!0),this.particleRenderer=e.createChild("pat").addComponent(V),this.particleRenderer.bounds.max.set(.5,.5,.5),this.particleRenderer.bounds.min.set(-.5,-.5,-.5)}}f(P,"entity",null),f(P,"sphereRenderer",null),f(P,"particleRenderer",null);function B(p){return p instanceof G?{x:p.x,y:p.y}:p instanceof K?{x:p.x,y:p.y,z:p.z}:p instanceof z?{x:p.x,y:p.y,z:p.z,w:p.w}:p instanceof H?{r:p.r,g:p.g,b:p.b,a:p.a}:p}function pe(p){switch(p){case b.Color:return"Color";case b.Float:return"Float";case b.Int:return"Integer";case b.Matrix:return"Matrix";case b.Texture:return"Texture";case b.TextureArray:return"TextureArray";case b.Vector2:return"Vector2";case b.Vector3:return"Vector3";case b.Vector4:return"Vector4"}}var ce=Object.defineProperty,de=Object.getOwnPropertyDescriptor,I=(p,t,e,r)=>{for(var i=r>1?void 0:r?de(t,e):t,a=p.length-1,n;a>=0;a--)(n=p[a])&&(i=(r?n(t,e,i):n(i))||i);return r&&i&&ce(t,e,i),i};let y=class extends Q{constructor(t){super(t);f(this,"acceptDragLayer",k.Texture);f(this,"shaderRef",{refId:null});f(this,"shaderDataKeys",new Set);f(this,"formConfig",null);f(this,"_autoSaveSuppressed",!1);W(this),D(this,{proxyConfigs:[]})}static initBuiltinMaterial(t,e){t.shader=e;const r=t.shaderData;switch(r.disableMacro("MATERIAL_NEED_WORLD_POS"),r.disableMacro("MATERIAL_OMIT_NORMAL"),r.disableMacro("MATERIAL_NEED_TILING_OFFSET"),r.disableMacro("MATERIAL_SUN_HIGH_QUALITY"),e.name){case"Unlit":r.enableMacro("MATERIAL_OMIT_NORMAL"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"PBR":case"bake-pbr":case"BlinnPhong":r.enableMacro("MATERIAL_NEED_WORLD_POS"),r.enableMacro("MATERIAL_NEED_TILING_OFFSET");break;case"Sky/SkyProcedural":r.enableMacro("MATERIAL_SUN_HIGH_QUALITY");break;case"Effect/Particle":r.enableMacro("MATERIAL_OMIT_NORMAL");break}}setAutoSaveSuppressed(t){this._autoSaveSuppressed=t}setRenderQueueType(t){this.engineObject.shaderData.setInt("renderQueueType",t)}setBlendStateEnabled(t){this.engineObject.shaderData.setInt("blendEnabled",t?1:0)}setDepthWriteEnabled(t){this.engineObject.shaderData.setInt("depthWriteEnabled",t?1:0)}setCullMode(t){this.engineObject.shaderData.setInt("rasterStateCullMode",t)}setBlendMode(t){const e=this.engineObject.shaderData;switch(t){case A.Normal:e.setInt("sourceColorBlendFactor",m.SourceAlpha),e.setInt("destinationColorBlendFactor",m.OneMinusSourceAlpha),e.setInt("sourceAlphaBlendFactor",m.One),e.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),e.setInt("colorBlendOperation",T.Add),e.setInt("alphaBlendOperation",T.Add);break;case A.Additive:e.setInt("sourceColorBlendFactor",m.SourceAlpha),e.setInt("destinationColorBlendFactor",m.One),e.setInt("sourceAlphaBlendFactor",m.One),e.setInt("destinationAlphaBlendFactor",m.OneMinusSourceAlpha),e.setInt("colorBlendOperation",T.Add),e.setInt("alphaBlendOperation",T.Add);break}}bindShaderAsset(t,e){for(const r of this.shaderDataKeys)this.removePropertyChangeListener(r);return this.shaderDataKeys.clear(),t.onReady().then(async()=>{var i;if(this.isInitCompleted){if(t.shaderScriptRefId){const a=this.root.assetStore.getAsset(t.shaderScriptRefId.refId);a==null||a.onShaderChange(this._engineObject)}else t.builtinUIScript&&t.builtinUIScript.onMaterialShaderSwitched(this._engineObject);e=this._getMainData()}const r=t.properties?J(t.properties):[];t.isBuiltinShader()&&y.initBuiltinMaterial(this.engineObject,t.engineObject),e=e||this._getMainData(),await this._proxyShaderProps(r,e,this.isInitCompleted),this.refreshFormConfig(r,e),this.refreshAnimatableProperties(r),this.shaderRef&&this.root.assetStore.getAssetByRef(this.shaderRef).then(a=>{a!==t&&(a==null||a.removeReferencedMaterial(this))}).catch(()=>{}),t.addReferencedMaterial(this),this.shaderRef={refId:t.id},await this.applyBoundPathChange("shader",O.AssetPicker,this.shaderRef),(i=this.updateThumbnail)==null||i.call(this)})}async _proxyShaderProps(t,e,r=!0){var n;this.proxyConfigs=t;const i=(n=this.extraData)==null?void 0:n.disabledMacros,a=t.map(async o=>{var l;if(this.proxySetter(o),this._virualShaderProps(t),o.bundleType==="macro"){const s=o.macroInfo,h=e.macros.find(c=>c.name===o.prop);if(!w(this,o.prop)){let c;h!=null?(c=h.value,s&&(s.checked=!0)):i!=null&&i.includes(o.prop)?(c=void 0,s&&(s.checked=!1)):c=o.defaultValue,D(this,{[o.prop]:c})}if(r)if(h){const c=h.value??o.defaultValue;c==null?s==null||s.onSwitch(!0,this):await o.onChange(this,o.prop,c)}else!(i!=null&&i.includes(o.prop))&&(s!=null&&s.checked)&&(s==null||s.onSwitch(!0,this))}else{const s=e.shaderData[o.prop];let h=s?s.value:this[o.prop]??o.defaultValue;if(h!=null&&h.refId&&!this.root.assetStore.assets[h.refId]&&(h=void 0),((l=o.uiInfo)==null?void 0:l.type)===g.Color)if(o.uiInfo.mode==="hdr"){const c=h.intensity??1;c!==0&&(h.r/=c,h.g/=c,h.b/=c),h.intensity=c}else h.intensity=1;w(this,o.prop)||D(this,{[o.prop]:h}),r&&this.notifyPropertyChange(o.prop,!1)}});await Promise.all(a)}proxySetter(t){const{prop:e,onChange:r,bundleType:i}=t,a=async(n,o)=>{var s;const l=this._engineObject.shaderData;i==="macro"?l.enableMacro(e,n):await x(this,e,n,t.engineType??((s=t.uiInfo)==null?void 0:s.type)),await r(this,e,n),o!==!1&&!this._autoSaveSuppressed&&(await this.root.assetFacade.persistAssetMain(this.id),this.updateThumbnail())};this.addPropertyChangeListener(e,a),this.shaderDataKeys.add(e)}_virualShaderProps(t){const e=this;t.forEach(r=>{Y(e,r.prop)})}refreshFormConfig(t,e){var i,a,n,o,l;const r={root:[],groups:{}};if(e){for(const s of t)if(!((i=s.uiInfo)!=null&&i.hide)){if((a=s.uiInfo)!=null&&a.group){if((n=s.uiInfo)!=null&&n.group){let h=r.groups[s.uiInfo.group];h||(h={type:O.Group,property:s.uiInfo.group,children:[]},r.groups[s.uiInfo.group]=h);const c=s.uiInfo;c.property=s.prop,s.macroInfo&&(c.macroConfig=s.macroInfo),h.children.push(c)}}else{const h=s.uiInfo;h.property=s.prop,s.macroInfo&&(h.macroConfig=s.macroInfo),r.root.push(h)}s.bundleType==="macro"?this[s.prop]=((o=e.macros.find(h=>h.name===s.prop))==null?void 0:o.value)??s.defaultValue:this[s.prop]=((l=e.shaderData[s.prop])==null?void 0:l.value)??s.defaultValue}}this.formConfig=r}refreshAnimatableProperties(t){var e,r,i;this._additionAnimatableProperties.length=0;for(const a of t){if(!a.uiInfo||a.uiInfo.hide||a.bundleType==="macro")continue;let n={};if((a.setPath||a.getPath||a.valueType||a.interpolationType)&&(n={setPath:a.setPath,getPath:a.getPath,valueType:a.valueType,interpolationType:a.interpolationType}),!n.setPath&&!n.getPath&&a.engineType&&(a.bundleType==="shaderData"||!a.bundleType))switch(a.engineType){case g.Float:n={setPath:`shaderData.setFloat('${a.prop}', $value)`,getPath:`shaderData.getFloat('${a.prop}')`,valueType:S.Float};break;case g.Integer:n={setPath:`shaderData.setInt('${a.prop}', $value)`,getPath:`shaderData.getInt('${a.prop}')`,valueType:S.Float,interpolationType:q.Step};break;case g.Vector2:n={setPath:`shaderData.getVector2('${a.prop}')`,getPath:`shaderData.getVector2('${a.prop}')`,valueType:S.Vector2};break;case g.Vector3:n={setPath:`shaderData.getVector3('${a.prop}')`,getPath:`shaderData.getVector3('${a.prop}')`,valueType:S.Vector3};break;case g.Vector4:n={setPath:`shaderData.getVector4('${a.prop}')`,getPath:`shaderData.getVector4('${a.prop}')`,valueType:S.Vector4};break;case g.Color:n={setPath:`shaderData.getColor('${a.prop}')`,getPath:`shaderData.getColor('${a.prop}')`,valueType:S.Color};break;case g.Boolean:n={setPath:`shaderData.setBoolean('${a.prop}', $value)`,getPath:`shaderData.getBoolean('${a.prop}')`,valueType:S.Boolean};break;case g.Texture:n={setPath:`shaderData.setTexture('${a.prop}', $value)`,getPath:`shaderData.getTexture('${a.prop}')`,valueType:S.ReferResource};break}if(!n.setPath&&!n.getPath){if(a.bundleType==="other")continue;continue}this._additionAnimatableProperties.push({property:a.prop,label:(e=a.uiInfo)!=null&&e.label?E(a.uiInfo.label):a.prop,type:(r=a.uiInfo)==null?void 0:r.type,propertyProxyConfig:n}),(i=a.uiInfo)!=null&&i.label&&(n.label=E(a.uiInfo.label)),X(this,a.prop,n)}}async initByMain(t){var c;const e=JSON.parse(await t.text());let r=e.shaderRef;const i=e.shaderData,a=e.macros;if(!r&&typeof e.shader=="string"){const d=Object.values(this.root.assetStore.assets).find(u=>u.meta.type==="Shader"&&u.meta.builtinShaderName===e.shader);d&&(r={refId:d.id})}if(!r)throw"invalid material";this.shaderRef=r;const n=new Z(this.engine);this.setDragTempEntity(n);const o=await this.root.assetStore.getAssetByRef(r),l=o.engineObject??ee.find("Unlit"),s=new te(this.engine,l);this.bindEngineObject(s);const h=s.shaderData;if(a)for(const d of a)h.enableMacro(d.name,d.value);if(i)for(const d in i){const u=i[d];let R=u.value;if(u.type===g.Color){R={...u.value};const M=u.value.intensity??1;M!==0&&(R.r/=M,R.g/=M,R.b/=M)}x(this,d,R,u.type)}await this.bindShaderAsset(o,e),(c=this.updateThumbnail)==null||c.call(this),await this.applyBoundPathChange("name",O.Input,this.name),this._checkSchemaOnInit(e,o)}_checkSchemaOnInit(t,e){t.shader!==e.engineObject.name&&this.root.assetFacade.persistAssetMain(this.id)}initByEngineObject(t){const e=this;this.bindEngineObject(t),e.shader=t.shader.name,e._name=t.name??"";const i=Object.values(this.root.assetStore.assets).filter(h=>h.meta.type==="Shader"&&!!h.meta.builtinShaderName).find(h=>h.meta.builtinShaderName===t.shader.name);this.shaderRef={refId:i.id};const a=t.shaderData,n=new Set((i.properties??[]).map(h=>h.prop));if(n.has("isTransparent")&&(e.isTransparent=a.getInt("blendEnabled")===1),n.has("material_AlphaCutoff")&&(e.alphaCutoff=a.getFloat("material_AlphaCutoff")),n.has("renderFace"))switch(a.getInt("rasterStateCullMode")){case C.Back:e.renderFace=v.Front;break;case C.Front:e.renderFace=v.Back;break;case C.Off:e.renderFace=v.Double;break}n.has("blendMode")&&(e.blendMode=a.getInt("destinationColorBlendFactor")===m.One?A.Additive:A.Normal),a.getProperties().forEach(h=>{const c=a.getPropertyValue(h);if(c instanceof ae){const d=this.root.assetStore.engineObjectToAssetMap.get(c);this[h.name]=d==null?void 0:d.getCurrentRef()}else this[h.name]=B(c)});const l=this._getMainData(),s=i.properties?[...i.properties]:[];this._proxyShaderProps(s,l,!1),this.bindShaderAsset(i,l)}afterDelete(){var t;(t=this.engineObject)==null||t.destroy(!0)}rename(t){return this.root.assetFacade.persistAssetMain(this.id),super.rename(t)}_getMainData(t){var s,h,c;const e=[],r=(t??this.engineObject).shaderData;r.getMacros(e);const i=e.map(({name:d,value:u})=>u===void 0?{name:d}:{name:d,value:u}),a=[],n={};r.getProperties(a);for(const d of a){let u;if(d.type===b.Texture||d.type===b.TextureArray)u=this[d.name];else{const R=r.getPropertyValue(d);u=B(R),((s=this[d.name])==null?void 0:s.intensity)!=null&&(u.intensity=(h=this[d.name])==null?void 0:h.intensity)}u!=null&&(n[d.name]={type:pe(d.type),value:u})}const o=(c=this.shaderRef)!=null&&c.refId?this.root.assetStore.getAsset(this.shaderRef.refId):void 0,l=!!(o!=null&&o.builtinShaderName);return{name:this.name,shader:this.engineObject.shader.name,macros:i,shaderData:n,...l?{}:{shaderRef:this.shaderRef}}}getMainData(){return JSON.stringify(this._getMainData())}async initByCreation(){var l;const t=new re(this.engine),e=[];t.shaderData.getMacros(e);const r=e.map(({name:s,value:h})=>h===void 0?{name:s}:{name:s,value:h});this.bindEngineObject(t);const i=this.root.assetStore.getAsset("0000501"),a=i!=null&&i.properties?[...i.properties]:[],n={};for(const s of a)s.defaultValue&&(n[s.prop]={value:s.defaultValue,type:s.engineType??((l=s.uiInfo)==null?void 0:l.type)});const o={shaderData:n,name:this.name,shader:t.shader.name,macros:r};return this._proxyShaderProps(a,o,!1),o}async onSubAssetEdit(){var i;const t=await this.root.assetFacade.createAssetByAdd({assetType:"Material",name:`${this._name}-copied`});this.engineObject.cloneTo(t.engineObject),await t.applyBoundPathChange("name",O.Input,t.name),t.initByEngineObject(t.engineObject),t.updateThumbnail(),await this.root.assetFacade.persistAssetMain(t.id);const e=await this.root.assetStore.getAssetByRef({refId:this.mainId}),r=((i=e.engineObject.materials)==null?void 0:i.indexOf(this._engineObject))??-1;r>=0&&await e.replaceMaterial(r,t.getCurrentRef()),this.root.assetStore.selectAsset(t.id)}saveMainImmediately(t){return!this.engineObject||!this.engineObject.shaderData?Promise.resolve(void 0):(this.root.projectStore.setSyncStatus("syncing"),super.saveMainImmediately(t).then(e=>(e&&this.root.projectStore.setSyncStatus("success"),e)).catch(e=>{throw this.root.projectStore.setSyncStatus("error"),e}))}async _onDrop(t,e){var i,a;const r="material_BaseTexture";if(r in this){const n=e.getCurrentRef();this[r]=n;const o=this.root.assetStore.getAsset((i=this.shaderRef)==null?void 0:i.refId),l=(a=o==null?void 0:o.properties)==null?void 0:a.find(s=>s.prop===r);l&&await l.onChange(this,r,n),await this.root.assetFacade.persistAssetMain(this.id)}this.dropping=!1}async onDropToViewport(){const{sceneStore:t,sceneUIStore:e}=this.root,r=e.hoveredEntityId;if(r){const i=t.getEntityModel(r);if(i){const a=i.getComponentByTypeName("MeshRenderer"),n=i.getComponentByTypeName("SkinnedMeshRenderer"),o=a||n;o&&this.root.componentFacade.updateComponent(i.id,o.id,{material:this.getCurrentRef()})}}this.root.projectStore.currentViewport.viewport.onDrop()}};I([L],y.prototype,"shaderRef",2);I([L.ref],y.prototype,"formConfig",2);I([_],y.prototype,"bindShaderAsset",1);I([_],y.prototype,"_proxyShaderProps",1);I([_],y.prototype,"proxySetter",1);I([_],y.prototype,"_virualShaderProps",1);I([_],y.prototype,"refreshAnimatableProperties",1);I([_],y.prototype,"_onDrop",1);y=I([se({type:"Material",label:E("asset.material.title"),loaderType:"Material",extname:"mat",importMenuConfig:{type:ie.Add},customInspector:ne,viewer:he,thumbnail:P,dragLayer:k.Material})],y);const Ie=Object.freeze(Object.defineProperty({__proto__:null,get MaterialAsset(){return y}},Symbol.toStringTag,{value:"Module"}));export{y as M,he as a,Ie as b};
@@ -1 +1 @@
1
- var E=Object.defineProperty;var L=(d,e,t)=>e in d?E(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var j=(d,e,t)=>(L(d,typeof e!="symbol"?e+"":e,t),t);import{aH as x,aP as N,aJ as S,aM as $,av as s,aI as M,C as n,b7 as V,aw as F,bz as B,aO as f,aK as A,bA as z,e as O}from"./index-b126bb6b.js";import{u as T}from"./index-c8ed2a45.js";import"./postmen-3b48c572.js";import{I as W}from"./IconPointFilled-3ba6d082.js";const H=x(W,{marginRight:"-$1",variants:{checked:{true:{color:"$green10"}}}}),J=x(N,{width:"100%",border:"none",position:"relative",whiteSpace:"pre-wrap",boxShadow:"$2","& > svg":{marginRight:"$1"}});function b(d){return S(function(t){const{inspectorConfig:r,macroConfig:c,...p}=t,{model:i}=p;let{models:g}=p;const{checked:u,onSwitch:h}=c,{type:m,...a}=r,[o,l]=$.useState(u);$.useEffect(()=>{l(u)},[u]),g=g||[i];const R=()=>{const I=!o;if(h)for(const k of g)h(I,k);l(I)},v=r.label;return s.jsxs(M,{direction:"column",fullWidth:!0,children:[m!==n.Null&&o&&V.createElement(d,{...p,inspectorConfig:{...a,type:m}}),s.jsx(F,{label:o?"":v,children:s.jsx(J,{size:"sm",variant:"subtle",startSlot:s.jsx(H,{size:"12px",checked:o}),onClick:R,children:o?"Enabled ":"Disabled"})})]})})}const K=x(M),U=x(B,{backgroundColor:"$gray1",height:"2px !important"});function q(d){const{inspectorConfig:e,models:t,onModelChange:r,model:c,macroConfig:p}=d,{type:i,property:g,info:u}=e,{t:h}=A(),m=!c&&t&&t.length>1;if(m&&!t.find(y=>e.when?e.when(y):!0)||e.when&&!e.when(c))return null;const a=p?w.getRegisteredMacroComponent(i):w.getRegisteredComponent(i);if(!a)return console.warn(`缺少${i}类型的组件`),null;let o=e.disabled;!m&&c.getEditable&&(o=c.getEditable(e.property)===!1);const l=typeof e.label=="string"?h(e.label):e.label;let R=e.options;R&&(R=R.map(y=>({label:typeof y.label=="string"?h(y.label):y.label,value:y.value})));const v={...e,label:l,info:u,options:R,disabled:o},{triggerAfterInit:I,customComponent:k,...P}=v;return s.jsx(a,{inspectorConfig:P,macroConfig:p,models:t,model:c,onModelChange:r},g)}const C=class C{static registerComponent(e,t){this.components[e]=t}static getRegisteredComponent(e){return C.components[e]}static getRegisteredMacroComponent(e){return C.macroComponents[e]}};j(C,"components",f.getRegisteredComponents()),j(C,"macroComponents",{[n.Color]:b(f.getRegisteredComponent(n.Color)),[n.Vector4]:b(f.getRegisteredComponent(n.Vector4)),[n.Vector3]:b(f.getRegisteredComponent(n.Vector3)),[n.Vector2]:b(f.getRegisteredComponent(n.Vector2)),[n.Number]:b(f.getRegisteredComponent(n.Number)),[n.AssetPicker]:b(f.getRegisteredComponent(n.AssetPicker)),[n.Boolean]:b(f.getRegisteredComponent(n.Boolean)),[n.Null]:b(f.getRegisteredComponent(n.Null))}),j(C,"Item",S(q)),j(C,"List",S(function(t){const{configs:r,models:c,css:p,onModelChange:i,model:g,children:u,fullWidth:h=!1,withSeparator:m}=t;return r!=null&&r.length&&r.sort((a,o)=>{const l=a.priority??0;return(o.priority??0)-l}),r?s.jsxs(K,{css:p,className:"shader-inspector-form",fullWidth:h,children:[r.map(a=>s.jsxs($.Fragment,{children:[s.jsx(C.Item,{inspectorConfig:a,macroConfig:a.macroConfig,model:g,models:c,onModelChange:i},a.property),m&&s.jsx(U,{})]},a.property)),u]}):null}));let w=C;const G=x("div",{backgroundColor:"$appBg",width:"100%"}),Q=x("div",{backgroundColor:"$panelBg",borderRadius:"0 0 $2 $2",overflow:"hidden",paddingBottom:"$1"}),X=x("div",{width:"100%",backgroundColor:"$gray3",paddingBottom:"$0_5"}),Y=x(B,{backgroundColor:"$appBg",height:"2px !important"}),Z=d=>{var a;const{asset:e}=d,t=e.formConfig,{assetStore:r,inspectorFacade:c}=T(),{i18n:p}=A(),i=r.getAsset(e.shaderRef.refId),g=i==null?void 0:i.name,u=Object.values(r.assets).filter(o=>o.meta.type==="Shader"&&o.meta.utility!=="error"),h=()=>{r.selectAsset(e.shaderRef.refId)},m=(o,l)=>{c.assetChange(e.id,o,l)};if(t.root)for(const o of t.root){const l=o.comments;l&&(o.info=l[p.language]??l.default??void 0)}return s.jsxs(G,{children:[s.jsx(X,{children:s.jsx(z,{label:O("asset.shader.title"),assets:u,disabled:!!(i!=null&&i.isSubAsset)||e.isSubAsset||!e.getEditable(),value:g,dropLayer:0,onSelect:async o=>{await e.bindShaderAsset(o,e._getMainData()),await c.assetChanges(e.id,{shaderRef:e.shaderRef,shader:e.shader})},onLocate:h})}),((a=t.root)==null?void 0:a.length)>0&&s.jsx(Q,{children:s.jsx(w.List,{model:e,onModelChange:m,configs:t.root,withSeparator:!1})}),s.jsx(Y,{}),s.jsx(w.List,{model:e,onModelChange:m,configs:Object.values(t.groups)})]})},ne=S(Z);export{ne as M};
1
+ var E=Object.defineProperty;var L=(d,e,t)=>e in d?E(d,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):d[e]=t;var j=(d,e,t)=>(L(d,typeof e!="symbol"?e+"":e,t),t);import{aH as x,aQ as N,aJ as S,aN as $,aL as s,aI as M,C as n,bA as V,aw as F,bB as B,aP as f,aK as A,bC as T,e as W}from"./index-d497fb6d.js";import{u as z}from"./index-8a22fe59.js";import"./postmen-0413c689.js";import{I as O}from"./IconPointFilled-192e99c9.js";const H=x(O,{marginRight:"-$1",variants:{checked:{true:{color:"$green10"}}}}),J=x(N,{width:"100%",border:"none",position:"relative",whiteSpace:"pre-wrap",boxShadow:"$2","& > svg":{marginRight:"$1"}});function b(d){return S(function(t){const{inspectorConfig:r,macroConfig:c,...p}=t,{model:i}=p;let{models:g}=p;const{checked:u,onSwitch:h}=c,{type:m,...a}=r,[o,l]=$.useState(u);$.useEffect(()=>{l(u)},[u]),g=g||[i];const R=()=>{const I=!o;if(h)for(const k of g)h(I,k);l(I)},v=r.label;return s.jsxs(M,{direction:"column",fullWidth:!0,children:[m!==n.Null&&o&&V.createElement(d,{...p,inspectorConfig:{...a,type:m}}),s.jsx(F,{label:o?"":v,children:s.jsx(J,{size:"sm",variant:"subtle",startSlot:s.jsx(H,{size:"12px",checked:o}),onClick:R,children:o?"Enabled ":"Disabled"})})]})})}const K=x(M),Q=x(B,{backgroundColor:"$gray1",height:"2px !important"});function U(d){const{inspectorConfig:e,models:t,onModelChange:r,model:c,macroConfig:p}=d,{type:i,property:g,info:u}=e,{t:h}=A(),m=!c&&t&&t.length>1;if(m&&!t.find(y=>e.when?e.when(y):!0)||e.when&&!e.when(c))return null;const a=p?w.getRegisteredMacroComponent(i):w.getRegisteredComponent(i);if(!a)return console.warn(`缺少${i}类型的组件`),null;let o=e.disabled;!m&&c.getEditable&&(o=c.getEditable(e.property)===!1);const l=typeof e.label=="string"?h(e.label):e.label;let R=e.options;R&&(R=R.map(y=>({label:typeof y.label=="string"?h(y.label):y.label,value:y.value})));const v={...e,label:l,info:u,options:R,disabled:o},{triggerAfterInit:I,customComponent:k,...P}=v;return s.jsx(a,{inspectorConfig:P,macroConfig:p,models:t,model:c,onModelChange:r},g)}const C=class C{static registerComponent(e,t){this.components[e]=t}static getRegisteredComponent(e){return C.components[e]}static getRegisteredMacroComponent(e){return C.macroComponents[e]}};j(C,"components",f.getRegisteredComponents()),j(C,"macroComponents",{[n.Color]:b(f.getRegisteredComponent(n.Color)),[n.Vector4]:b(f.getRegisteredComponent(n.Vector4)),[n.Vector3]:b(f.getRegisteredComponent(n.Vector3)),[n.Vector2]:b(f.getRegisteredComponent(n.Vector2)),[n.Number]:b(f.getRegisteredComponent(n.Number)),[n.AssetPicker]:b(f.getRegisteredComponent(n.AssetPicker)),[n.Boolean]:b(f.getRegisteredComponent(n.Boolean)),[n.Null]:b(f.getRegisteredComponent(n.Null))}),j(C,"Item",S(U)),j(C,"List",S(function(t){const{configs:r,models:c,css:p,onModelChange:i,model:g,children:u,fullWidth:h=!1,withSeparator:m}=t;return r!=null&&r.length&&r.sort((a,o)=>{const l=a.priority??0;return(o.priority??0)-l}),r?s.jsxs(K,{css:p,className:"shader-inspector-form",fullWidth:h,children:[r.map(a=>s.jsxs($.Fragment,{children:[s.jsx(C.Item,{inspectorConfig:a,macroConfig:a.macroConfig,model:g,models:c,onModelChange:i},a.property),m&&s.jsx(Q,{})]},a.property)),u]}):null}));let w=C;const q=x("div",{backgroundColor:"$appBg",width:"100%"}),G=x("div",{backgroundColor:"$panelBg",borderRadius:"0 0 $2 $2",overflow:"hidden",paddingBottom:"$1"}),X=x("div",{width:"100%",backgroundColor:"$gray3",paddingBottom:"$0_5"}),Y=x(B,{backgroundColor:"$appBg",height:"2px !important"}),Z=d=>{var a;const{asset:e}=d,t=e.formConfig,{assetStore:r,inspectorFacade:c}=z(),{i18n:p}=A(),i=r.getAsset(e.shaderRef.refId),g=i==null?void 0:i.name,u=Object.values(r.assets).filter(o=>o.meta.type==="Shader"&&o.meta.utility!=="error"),h=()=>{r.selectAsset(e.shaderRef.refId)},m=(o,l)=>{c.assetChange(e.id,o,l)};if(t.root)for(const o of t.root){const l=o.comments;l&&(o.info=l[p.language]??l.default??void 0)}return s.jsxs(q,{children:[s.jsx(X,{children:s.jsx(T,{label:W("asset.shader.title"),assets:u,disabled:!!(i!=null&&i.isSubAsset)||e.isSubAsset||!e.getEditable(),value:g,dropLayer:0,onSelect:async o=>{await e.bindShaderAsset(o,e._getMainData()),await c.assetChanges(e.id,{shaderRef:e.shaderRef,shader:e.shader})},onLocate:h})}),((a=t.root)==null?void 0:a.length)>0&&s.jsx(G,{children:s.jsx(w.List,{model:e,onModelChange:m,configs:t.root,withSeparator:!1})}),s.jsx(Y,{}),s.jsx(w.List,{model:e,onModelChange:m,configs:Object.values(t.groups)})]})},ne=S(Z);export{ne as M};