@galacean/cli 2.0.0-alpha.12 → 2.0.0-alpha.14

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 (160) hide show
  1. package/dist/cli.bundle.cjs +134 -135
  2. package/dist/viewport-client/_static/Accordion-3d330bc6.js +1 -0
  3. package/dist/viewport-client/_static/{AmbientLightAsset-f70b95f1.js → AmbientLightAsset-bdbc4e1d.js} +2 -2
  4. package/dist/viewport-client/_static/AnimationClipAsset-9167378a.js +1 -0
  5. package/dist/viewport-client/_static/AnimatorControllerAsset-21dc6332.js +1 -0
  6. package/dist/viewport-client/_static/AnimatorStore-18d3c551.js +1 -0
  7. package/dist/viewport-client/_static/{AssetViewer-bc198e16.js → AssetViewer-64cd01fa.js} +1 -1
  8. package/dist/viewport-client/_static/AudioAsset-0c828c80.js +1 -0
  9. package/dist/viewport-client/_static/AudioComponent-fbff3825.js +1 -0
  10. package/dist/viewport-client/_static/{Callout-cb4a55ff.js → Callout-ba7e2adf.js} +1 -1
  11. package/dist/viewport-client/_static/CameraComponent-74975570.js +1 -0
  12. package/dist/viewport-client/_static/{Component-f923abb1.js → Component-ed7aa0ab.js} +1 -1
  13. package/dist/viewport-client/_static/DirectLight-b884e7db.js +1 -0
  14. package/dist/viewport-client/_static/FontAsset-d1ced18d.js +5 -0
  15. package/dist/viewport-client/_static/FormItemArray-6d69acd4.js +6 -0
  16. package/dist/viewport-client/_static/{GlTFAsset-9c68f862.js → GlTFAsset-2723b84a.js} +9 -9
  17. package/dist/viewport-client/_static/IconEdit-ab77303f.js +6 -0
  18. package/dist/viewport-client/_static/{IconPointFilled-a304fd34.js → IconPointFilled-811fc660.js} +1 -1
  19. package/dist/viewport-client/_static/LightBaseComponent-12dc27d1.js +1 -0
  20. package/dist/viewport-client/_static/LottieAnimationComponent-c48c5eb5.js +1 -0
  21. package/dist/viewport-client/_static/LottieAsset-3692580d.js +6 -0
  22. package/dist/viewport-client/_static/MarkdownAsset-bcb90be4.js +1 -0
  23. package/dist/viewport-client/_static/MaterialAsset-6ef9b4ed.js +1 -0
  24. package/dist/viewport-client/_static/MaterialInspector-e8242674.js +1 -0
  25. package/dist/viewport-client/_static/Menu-0b8da92f.js +17 -0
  26. package/dist/viewport-client/_static/MeshAsset-ca9305e5.js +1 -0
  27. package/dist/viewport-client/_static/MeshRendererBaseComponent-9efd3943.js +1 -0
  28. package/dist/viewport-client/_static/MeshRendererComponent-c9a03641.js +1 -0
  29. package/dist/viewport-client/_static/{MeshThumbnail-49273f71.js → MeshThumbnail-ab28b3b8.js} +1 -1
  30. package/dist/viewport-client/_static/ParticleRendererComponent-96947c1d.js +26 -0
  31. package/dist/viewport-client/_static/PhysicsMaterialAsset-4a1e5ea3.js +1 -0
  32. package/dist/viewport-client/_static/PhysicsStore-33cac578.js +1 -0
  33. package/dist/viewport-client/_static/PointLight-fd514526.js +1 -0
  34. package/dist/viewport-client/_static/PostProcessComponent-d0ea27a4.js +6 -0
  35. package/dist/viewport-client/_static/PrefabAsset-9179b95c.js +1 -0
  36. package/dist/viewport-client/_static/PrimitiveMesh-0572a073.js +1 -0
  37. package/dist/viewport-client/_static/ProxyConfigs-3a5fd860.js +1 -0
  38. package/dist/viewport-client/_static/{ReferencedMaterial-a87818f3.js → ReferencedMaterial-5773c9d2.js} +1 -1
  39. package/dist/viewport-client/_static/RenderTargetAsset-ab6e06d2.js +1 -0
  40. package/dist/viewport-client/_static/SceneAsset-385fa837.js +1 -0
  41. package/dist/viewport-client/_static/{ShaderAsset-cb3ff628.js → ShaderAsset-f4514b03.js} +6 -6
  42. package/dist/viewport-client/_static/ShaderChunkAsset-34116f2c.js +5 -0
  43. package/dist/viewport-client/_static/{ShaderUIScriptAsset-d13fa4e2.js → ShaderUIScriptAsset-fc503291.js} +5 -5
  44. package/dist/viewport-client/_static/SkinnedMeshRendererComponent-494ad439.js +1 -0
  45. package/dist/viewport-client/_static/SpineAnimationComponent-3918d7b5.js +1 -0
  46. package/dist/viewport-client/_static/SpineSkeletonDataAsset-27244892.js +1 -0
  47. package/dist/viewport-client/_static/SpotLight-f9972dc0.js +1 -0
  48. package/dist/viewport-client/_static/SpriteAsset-558ffca8.js +6 -0
  49. package/dist/viewport-client/_static/SpriteAtlasAsset-cdc34386.js +1 -0
  50. package/dist/viewport-client/_static/SpriteBaseComponent-3edafa31.js +1 -0
  51. package/dist/viewport-client/_static/SpriteMaskComponent-de2e5231.js +1 -0
  52. package/dist/viewport-client/_static/SpriteRendererComponent-e999e735.js +1 -0
  53. package/dist/viewport-client/_static/{TextBaseComponent-69233798.js → TextBaseComponent-ce1402c3.js} +2 -2
  54. package/dist/viewport-client/_static/TextRendererComponent-f7c0deae.js +1 -0
  55. package/dist/viewport-client/_static/TextureAsset-39fb07fe.js +36 -0
  56. package/dist/viewport-client/_static/Tooltip-82063435.js +1 -0
  57. package/dist/viewport-client/_static/TrailRendererComponent-37f5c981.js +1 -0
  58. package/dist/viewport-client/_static/TransformBaseComponent-713d57e9.js +1 -0
  59. package/dist/viewport-client/_static/TransformComponent-40a57948.js +1 -0
  60. package/dist/viewport-client/_static/XRReferenceImageAsset-2f6ff226.js +1 -0
  61. package/dist/viewport-client/_static/audio-7120ec91.js +1 -0
  62. package/dist/viewport-client/_static/glTFIO-79bbca27.js +1 -0
  63. package/dist/viewport-client/_static/index-483b5738.js +1 -0
  64. package/dist/viewport-client/_static/{index-98982ce2.js → index-74130ff3.js} +1 -1
  65. package/dist/viewport-client/_static/index-78269e76.js +1 -0
  66. package/dist/viewport-client/_static/index-7834b582.js +1 -0
  67. package/dist/viewport-client/_static/{index-237c84cd.js → index-7917f782.js} +3 -3
  68. package/dist/viewport-client/_static/index-7acd49d2.js +1 -0
  69. package/dist/viewport-client/_static/index-9d3917da.js +1 -0
  70. package/dist/viewport-client/_static/index-a9b2675e.js +1 -0
  71. package/dist/viewport-client/_static/index-aec7e708.js +11487 -0
  72. package/dist/viewport-client/_static/index-b5582401.js +1 -0
  73. package/dist/viewport-client/_static/{index-e46ec5b1.js → index-bfe6f30e.js} +7 -7
  74. package/dist/viewport-client/_static/index-c63c9606.js +2 -0
  75. package/dist/viewport-client/_static/index-cd1fee9d.js +1 -0
  76. package/dist/viewport-client/_static/index-e73ceaed.js +1 -0
  77. package/dist/viewport-client/_static/index-e8a45e82.js +1 -0
  78. package/dist/viewport-client/_static/index-f2cb64af.js +1 -0
  79. package/dist/viewport-client/_static/index-fbe040bf.js +31 -0
  80. package/dist/viewport-client/_static/ktx2-encoder-53b21bdc.js +1 -0
  81. package/dist/viewport-client/_static/{module-5c85b07e.js → module-220b3921.js} +1 -1
  82. package/dist/viewport-client/_static/{module-6406b050.js → module-8816772d.js} +1 -1
  83. package/dist/viewport-client/_static/{module-107b7430.js → module-ffeaf99f.js} +1 -1
  84. package/dist/viewport-client/_static/postmen-2f47f6bb.js +1 -0
  85. package/dist/viewport-client/index.html +2 -2
  86. package/package.json +1 -1
  87. package/dist/viewport-client/_static/Accordion-4897319b.js +0 -6
  88. package/dist/viewport-client/_static/AnimationClipAsset-01f3deb6.js +0 -1
  89. package/dist/viewport-client/_static/AnimatorControllerAsset-b7424e9c.js +0 -1
  90. package/dist/viewport-client/_static/AnimatorStore-fd98c00e.js +0 -1
  91. package/dist/viewport-client/_static/AssetPreviewer-24e31d97.js +0 -6
  92. package/dist/viewport-client/_static/AudioAsset-eae03324.js +0 -1
  93. package/dist/viewport-client/_static/AudioComponent-44070c2c.js +0 -1
  94. package/dist/viewport-client/_static/CameraComponent-907ac745.js +0 -1
  95. package/dist/viewport-client/_static/CanvasRenderer-9dd98cb3.js +0 -1
  96. package/dist/viewport-client/_static/DirectLight-58f5fe9e.js +0 -1
  97. package/dist/viewport-client/_static/FontAsset-abfb9a8a.js +0 -5
  98. package/dist/viewport-client/_static/FormItemArray-66be8701.js +0 -1
  99. package/dist/viewport-client/_static/IconPlayerPlayFilled-b058c98f.js +0 -6
  100. package/dist/viewport-client/_static/InstanceEditorAsset-a70e73fe.js +0 -1
  101. package/dist/viewport-client/_static/LightBaseComponent-fbc3ae49.js +0 -1
  102. package/dist/viewport-client/_static/LottieAnimationComponent-1c3e02a5.js +0 -1
  103. package/dist/viewport-client/_static/LottieAsset-377c1419.js +0 -1
  104. package/dist/viewport-client/_static/MarkdownAsset-7ea387a9.js +0 -1
  105. package/dist/viewport-client/_static/MaterialAsset-74a15124.js +0 -1
  106. package/dist/viewport-client/_static/MaterialInspector-aec1248b.js +0 -1
  107. package/dist/viewport-client/_static/Menu-cd3be298.js +0 -17
  108. package/dist/viewport-client/_static/MeshAsset-73e2cc8e.js +0 -1
  109. package/dist/viewport-client/_static/MeshRendererBaseComponent-3a0e09ed.js +0 -1
  110. package/dist/viewport-client/_static/MeshRendererComponent-5385d30f.js +0 -1
  111. package/dist/viewport-client/_static/ParticleRendererComponent-5a7b57d9.js +0 -21
  112. package/dist/viewport-client/_static/PhysicsMaterialAsset-a5ac9f82.js +0 -1
  113. package/dist/viewport-client/_static/PhysicsStore-0729e76d.js +0 -1
  114. package/dist/viewport-client/_static/PointLight-0e1d1546.js +0 -1
  115. package/dist/viewport-client/_static/PostProcessComponent-8276d33c.js +0 -1
  116. package/dist/viewport-client/_static/PrefabAsset-1a7edfbd.js +0 -1
  117. package/dist/viewport-client/_static/PrimitiveMesh-3ce6fa2f.js +0 -1
  118. package/dist/viewport-client/_static/ProxyConfigs-4de3304c.js +0 -1
  119. package/dist/viewport-client/_static/RenderTargetAsset-33c0d9e7.js +0 -1
  120. package/dist/viewport-client/_static/SceneAsset-8917c210.js +0 -1
  121. package/dist/viewport-client/_static/ShaderChunkAsset-83f923f4.js +0 -5
  122. package/dist/viewport-client/_static/SkinnedMeshRendererComponent-2a8323bf.js +0 -1
  123. package/dist/viewport-client/_static/SpineAnimationComponent-e733d50f.js +0 -1
  124. package/dist/viewport-client/_static/SpineSkeletonDataAsset-b64a3ee3.js +0 -1
  125. package/dist/viewport-client/_static/SpotLight-ca6c0c3b.js +0 -1
  126. package/dist/viewport-client/_static/SpriteAsset-9a31ec24.js +0 -1
  127. package/dist/viewport-client/_static/SpriteAtlasAsset-a862db46.js +0 -1
  128. package/dist/viewport-client/_static/SpriteBaseComponent-f6f1731f.js +0 -1
  129. package/dist/viewport-client/_static/SpriteMaskComponent-778be04f.js +0 -1
  130. package/dist/viewport-client/_static/SpriteRendererComponent-2b4d153b.js +0 -1
  131. package/dist/viewport-client/_static/TextRendererComponent-130b4e99.js +0 -1
  132. package/dist/viewport-client/_static/TextureAsset-28fedf2a.js +0 -36
  133. package/dist/viewport-client/_static/ThumbnailMixin-35997457.js +0 -1
  134. package/dist/viewport-client/_static/ThumbnailRegistry-495c18c9.js +0 -1
  135. package/dist/viewport-client/_static/Tooltip-33f770ba.js +0 -1
  136. package/dist/viewport-client/_static/TrailRendererComponent-148550b5.js +0 -1
  137. package/dist/viewport-client/_static/TransformBaseComponent-02318c5a.js +0 -1
  138. package/dist/viewport-client/_static/TransformComponent-96106065.js +0 -1
  139. package/dist/viewport-client/_static/ViewerManager-202b570a.js +0 -1
  140. package/dist/viewport-client/_static/XRReferenceImageAsset-6a6adb3b.js +0 -1
  141. package/dist/viewport-client/_static/audio-244358e2.js +0 -1
  142. package/dist/viewport-client/_static/glTFIO-45ff9a17.js +0 -1
  143. package/dist/viewport-client/_static/index-0a8702e2.js +0 -11217
  144. package/dist/viewport-client/_static/index-37c74ae9.js +0 -26
  145. package/dist/viewport-client/_static/index-4cca0201.js +0 -1
  146. package/dist/viewport-client/_static/index-59732f86.js +0 -1
  147. package/dist/viewport-client/_static/index-6c8198f6.js +0 -2
  148. package/dist/viewport-client/_static/index-6f827618.js +0 -1
  149. package/dist/viewport-client/_static/index-803ca489.js +0 -1
  150. package/dist/viewport-client/_static/index-85a6cf6a.js +0 -1
  151. package/dist/viewport-client/_static/index-b3d51f87.js +0 -1
  152. package/dist/viewport-client/_static/index-be6bc38a.js +0 -177
  153. package/dist/viewport-client/_static/index-c403cbcd.js +0 -1
  154. package/dist/viewport-client/_static/index-e73966ae.js +0 -1
  155. package/dist/viewport-client/_static/index-e95b4498.js +0 -1
  156. package/dist/viewport-client/_static/index-f5a67a46.js +0 -1
  157. package/dist/viewport-client/_static/ktx-parse.modern-6c9f771f.js +0 -1
  158. package/dist/viewport-client/_static/ktx2-encoder-1e63c1eb.js +0 -1
  159. package/dist/viewport-client/_static/postmen-45d4c238.js +0 -1
  160. package/dist/viewport-client/_static/utilities-e09052e3.js +0 -11
@@ -1,36 +0,0 @@
1
- var be=Object.defineProperty;var ye=(n,e,t)=>e in n?be(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var v=(n,e,t)=>(ye(n,typeof e!="symbol"?e+"":e,t),t);import{aC as ge,e6 as we,ao as $,bo as Y,$ as J,a9 as Z,O as Q,b$ as ee,ap as te,aT as q,aU as xe,aD as w,b8 as ne,aK as z,aG as G,by as ve,cH as Me,aV as Ce,e as P,cF as Se,aJ as _e,aY as Re,_ as Te,j as Be,an as U,a0 as C,p as D,C as j,b0 as T,u as Oe,x as Ae,n as De,bu as X,bv as ae,eq as je,er as ie,es as Ee}from"./index-0a8702e2.js";import{H as re}from"./enum-58295f88.js";import{u as Ue,a as Ie,A as Pe}from"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{e as se}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import{T as Le}from"./Tooltip-33f770ba.js";import{A as Fe}from"./AssetViewer-bc198e16.js";import{k as H}from"./ktx2-encoder-1e63c1eb.js";/**
2
- * @license @tabler/icons-react v3.24.0 - MIT
3
- *
4
- * This source code is licensed under the MIT license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */var Ve=ge("filled","help-circle-filled","IconHelpCircleFilled",[["path",{d:"M12 2c5.523 0 10 4.477 10 10a10 10 0 0 1 -19.995 .324l-.005 -.324l.004 -.28c.148 -5.393 4.566 -9.72 9.996 -9.72zm0 13a1 1 0 0 0 -.993 .883l-.007 .117l.007 .127a1 1 0 0 0 1.986 0l.007 -.117l-.007 -.127a1 1 0 0 0 -.993 -.883zm1.368 -6.673a2.98 2.98 0 0 0 -3.631 .728a1 1 0 0 0 1.44 1.383l.171 -.18a.98 .98 0 0 1 1.11 -.15a1 1 0 0 1 -.34 1.886l-.232 .012a1 1 0 0 0 .111 1.994a3 3 0 0 0 1.371 -5.673z",key:"svg-0"}]]);const K=function(n,e,t){return n>=t?t:n<=e?e:n};function oe(n,e,t,i,a){const r=new Uint8Array(n);i=K(i,0,255),a=K(a,0,255);const s=(d,p)=>(p*e+d)*4,o=[[-1,0],[1,0],[0,-1],[0,1]],l=[];for(let d=0;d<t;d++)for(let p=0;p<e;p++)if(r[s(p,d)+3]!==0)for(const[y,b]of o){const h=p+y,m=d+b;if(h>=0&&h<e&&m>=0&&m<t&&r[s(h,m)+3]===0){l.push([p,d]);break}}const c=new Set,u=[];for(;l.length>0;){const d=[];for(const[p,y]of l)for(const[b,h]of o){const m=p+b,f=y+h;if(m<0||m>=e||f<0||f>=t)continue;const x=s(m,f);if(r[x+3]>i)continue;const g=f*e+m;if(c.has(g))continue;c.add(g);const S=s(p,y);r[x]=r[S],r[x+1]=r[S+1],r[x+2]=r[S+2],r[x+3]=255,d.push([m,f]),u.push(x)}l.length=0;for(let p=0;p<d.length;p++)l.push(d[p])}for(const d of u)r[d+3]=a;return r}async function le(n,e={range:10,alpha:0}){return typeof document<"u"?Ge(n,e):He(n,e)}async function Ge(n,e){const t=URL.createObjectURL(new Blob([n])),i=await new Promise((l,c)=>{const u=new Image;u.crossOrigin="*",u.onload=()=>l(u),u.onerror=c,u.src=t});URL.revokeObjectURL(t);const a=document.createElement("canvas");a.width=i.width,a.height=i.height;const r=a.getContext("2d");if(!r)return null;r.drawImage(i,0,0);const s=r.getImageData(0,0,i.width,i.height),o=oe(new Uint8Array(s.data.buffer),i.width,i.height,e.range,e.alpha);return r.putImageData(new ImageData(new Uint8ClampedArray(o),i.width,i.height),0,0),new Promise(l=>{a.toBlob(c=>l(c))})}async function He(n,e){const t=(await we(()=>import("./index-6c8198f6.js").then(o=>o.i),["_static/index-6c8198f6.js","_static/index-0a8702e2.js"])).default,{data:i,info:a}=await t(Buffer.from(n)).ensureAlpha().raw().toBuffer({resolveWithObject:!0}),r=oe(new Uint8Array(i.buffer,i.byteOffset,i.byteLength),a.width,a.height,e.range,e.alpha),s=await t(Buffer.from(r),{raw:{width:a.width,height:a.height,channels:4}}).png().toBuffer();return new Blob([new Uint8Array(s)])}function L(n){const e=n instanceof Uint8Array?n:new Uint8Array(n);return e[0]===35&&e[1]===63}function k(n,e){const t=new Float32Array(1),i=new Uint32Array(t.buffer);for(let a=0;a<n.length;a++){t[0]=n[a];const r=i[0],s=r>>16&32768,o=(r>>23&255)-127+15,l=r&8388607;o<=0?e[a]=s:o>=31?e[a]=s|31744:e[a]=s|o<<10|l>>13}}function F(n){const e=ze(n),{width:t,height:i,dataPosition:a}=e,r=Ne(n.subarray(a),t,i),s=ke(r,t,i);return{width:t,height:i,pixels:s}}function ke(n,e,t){const i=e*t,a=new Float32Array(i*4);for(let r=0;r<i;r++){const s=r*4,o=r*4,l=Math.pow(2,n[s+3]-128-8);a[o]=Math.min(n[s]*l,65504),a[o+1]=Math.min(n[s+1]*l,65504),a[o+2]=Math.min(n[s+2]*l,65504),a[o+3]=1}return a}function ze(n){let e=N(n,0);if(e[0]!=="#"||e[1]!=="?")throw new Error("HDR: invalid header");let t=0,i=!1,a=!1;do t+=e.length+1,e=N(n,t),e==="FORMAT=32-bit_rle_rgbe"?i=!0:e.length===0&&(a=!0);while(!a);if(!i)throw new Error("HDR: unsupported format");t+=e.length+1,e=N(n,t);const r=/^\-Y (.*) \+X (.*)$/g.exec(e);if(!r||r.length<3)throw new Error("HDR: missing size");return{width:parseInt(r[2]),height:parseInt(r[1]),dataPosition:t+e.length+1}}function Ne(n,e,t){const i=n.byteLength,a=new Uint8Array(4*e*t);let r=0,s=0;const o=4*e,l=new Uint8Array(o);let c=t;for(;c>0&&s<i;){const u=n[s++],d=n[s++],p=n[s++],y=n[s++];if(u!==2||d!==2||p&128||e<8||e>32767)return n;if((p<<8|y)!==e)throw new Error("HDR: wrong scanline width");let b=0;for(;b<o&&s<i;){let h=n[s++];const m=h>128;if(m&&(h-=128),h===0||b+h>o)throw new Error("HDR: bad scanline");if(m){const f=n[s++];for(let x=0;x<h;x++)l[b++]=f}else l.set(n.subarray(s,s+h),b),b+=h,s+=h}for(let h=0;h<e;h++,r+=4)a[r]=l[h],a[r+1]=l[h+e],a[r+2]=l[h+e*2],a[r+3]=l[h+e*3];c--}return a}function N(n,e){let t="";for(let i=e;i<n.length;i++){const a=String.fromCharCode(n[i]);if(a===`
7
- `)break;t+=a}return t}function $e(n,e,t){if(n.length!==e*t*4)throw new Error(`HDREncoder: pixel count mismatch (expected ${e*t*4}, got ${n.length})`);const i=qe(e,t),a=Xe(n,e,t),r=new Uint8Array(i.length+a.length);return r.set(i,0),r.set(a,i.length),r.buffer}function qe(n,e){const t=`#?RADIANCE
8
- # Written by Galacean HDREncoder
9
- FORMAT=32-bit_rle_rgbe
10
-
11
- -Y ${e} +X ${n}
12
- `;return new TextEncoder().encode(t)}function Xe(n,e,t){const i=t*(4+4*e*2),a=new Uint8Array(i);let r=0;const s=new Uint8Array(4*e);for(let o=0;o<t;o++){Ke(n,o*e*4,e,s),a[r++]=2,a[r++]=2,a[r++]=e>>8&255,a[r++]=e&255;for(let l=0;l<4;l++)r=We(s,l,e,a,r)}return a.subarray(0,r)}function Ke(n,e,t,i){for(let a=0;a<t;a++){const r=e+a*4,s=a*4,o=n[r],l=n[r+1],c=n[r+2],u=Math.max(o,l,c);if(u<1e-32)i[s]=0,i[s+1]=0,i[s+2]=0,i[s+3]=0;else{const d=Math.ceil(Math.log2(u)),p=256/Math.pow(2,d);i[s]=Math.min(255,Math.max(0,Math.round(o*p))),i[s+1]=Math.min(255,Math.max(0,Math.round(l*p))),i[s+2]=Math.min(255,Math.max(0,Math.round(c*p))),i[s+3]=d+128}}}function We(n,e,t,i,a){let r=0;for(;r<t;){const s=r,o=n[r*4+e];let l=1;for(;r+l<t&&l<127&&n[(r+l)*4+e]===o;)l++;if(l>=4)i[a++]=128+l,i[a++]=o,r+=l;else{let c=1;for(r=s;r+c<t&&c<128;){const u=n[(r+c)*4+e];let d=1;for(;r+c+d<t&&d<4&&n[(r+c+d)*4+e]===u;)d++;if(d>=4)break;c++}i[a++]=c;for(let u=0;u<c;u++)i[a++]=n[(r+u)*4+e];r+=c}}return a}const Ye=[[1,-1,-1,1,-1,1,1,1,-1,1,1,1],[-1,-1,1,-1,-1,-1,-1,1,1,-1,1,-1],[-1,-1,1,1,-1,1,-1,-1,-1,1,-1,-1],[-1,1,-1,1,1,-1,-1,1,1,1,1,1],[-1,-1,-1,1,-1,-1,-1,1,-1,1,1,-1],[1,-1,1,-1,-1,1,1,1,1,-1,1,1]];function ce(n,e,t,i){const a=i??t>>1,r=[];for(let s=0;s<6;s++){const o=Ye[s],l=new Float32Array(a*a*4);Je(n,e,t,o,a,l),r.push(l)}return{faceSize:a,faces:r}}function Je(n,e,t,i,a,r){const s=1/a,o=(i[3]-i[0])*s,l=(i[4]-i[1])*s,c=(i[5]-i[2])*s,u=(i[9]-i[6])*s,d=(i[10]-i[7])*s,p=(i[11]-i[8])*s;let y=0;for(let b=0;b<a;b++){let h=i[0],m=i[1],f=i[2],x=i[6],g=i[7],S=i[8];for(let B=0;B<a;B++){let O=h+(x-h)*y,A=m+(g-m)*y,I=f+(S-f)*y;const R=1/Math.sqrt(O*O+A*A+I*I);O*=R,A*=R,I*=R;const he=Math.atan2(O,I)/Math.PI*.5+.5,me=Math.acos(A)/Math.PI,fe=(b*a+B)*4;Ze(n,e,t,he,me,r,fe),h+=o,m+=l,f+=c,x+=u,g+=d,S+=p}y+=s}}function Ze(n,e,t,i,a,r,s){const o=i*e-.5,l=(1-a)*t-.5,c=Math.floor(o),u=Math.floor(l),d=o-c,p=l-u,y=(c%e+e)%e,b=((c+1)%e+e)%e,h=Math.max(0,Math.min(u,t-1)),m=Math.max(0,Math.min(u+1,t-1)),f=(h*e+y)*4,x=(h*e+b)*4,g=(m*e+y)*4,S=(m*e+b)*4,B=(1-d)*(1-p),O=d*(1-p),A=(1-d)*p,I=d*p;for(let R=0;R<4;R++)r[s+R]=n[f+R]*B+n[x+R]*O+n[g+R]*A+n[S+R]*I}$.create("editor-cube-preview",`
13
- attribute vec3 POSITION;
14
- attribute vec3 NORMAL;
15
-
16
- uniform mat4 renderer_MVPMat;
17
- uniform vec3 camera_Position;
18
- uniform mat4 renderer_ModelMat;
19
- varying vec3 v_reflectDir;
20
-
21
- void main(){
22
- gl_Position = renderer_MVPMat * vec4(POSITION, 1.0);
23
- // All in object space, same as Unity's PreviewCubemap.shader
24
- mat4 worldToModel = inverse(renderer_ModelMat);
25
- vec3 objSpaceCameraPos = (worldToModel * vec4(camera_Position, 1.0)).xyz;
26
- vec3 objSpaceViewDir = -normalize(objSpaceCameraPos - POSITION);
27
- v_reflectDir = reflect(objSpaceViewDir, NORMAL);
28
- }
29
- `,`
30
- varying vec3 v_reflectDir;
31
- uniform samplerCube u_cubeTexture;
32
-
33
- void main(){
34
- gl_FragColor = textureCube(u_cubeTexture, normalize(v_reflectDir));
35
- }
36
- `);class E{static update(e,t){t.shape===V.Cube?this.updateCube(e,t):this.update2D(e,t)}static clear(){this.spriteEntity&&(this.spriteEntity.isActive=!1),this.cubeEntity&&(this.cubeEntity.isActive=!1)}static update2D(e,t){this.cubeEntity&&(this.cubeEntity.isActive=!1),this.spriteEntity?this.spriteEntity.isActive=!0:this.init2DScene(e),this.entity=this.spriteEntity,this.sprite.texture=t.engineObject}static updateCube(e,t){this.spriteEntity&&(this.spriteEntity.isActive=!1),this.cubeEntity?this.cubeEntity.isActive=!0:this.initCubeScene(e),this.entity=this.cubeEntity,this.cubeMaterial.shaderData.setTexture(Y.getByName("u_cubeTexture"),t.engineObject)}static init2DScene(e){const t=this.spriteEntity=e.createChild("sprite");this.spriteRenderer=t.addComponent(J),this.spriteRenderer.sprite=this.sprite=new Z(e.engine)}static initCubeScene(e){const{engine:t}=e,a=(this.cubeEntity=e.createChild("cube-preview-sphere")).addComponent(Q);a.mesh=ee.createSphere(t,.5,32),this.cubeMaterial=new te(t,$.find("editor-cube-preview")),a.setMaterial(this.cubeMaterial)}}v(E,"entity"),v(E,"spriteEntity"),v(E,"spriteRenderer"),v(E,"sprite"),v(E,"cubeEntity"),v(E,"cubeMaterial");const Qe=q(function(n){const{t:e}=xe(),t=n.encodeOptions,i=n.isHDR;return w.jsxs(w.Fragment,{children:[w.jsx(ne,{formStartSlot:w.jsx(z,{css:{marginLeft:"$4"}}),label:e("asset.ktx2.mode.label"),formEndSlot:w.jsx(Le,{content:w.jsxs(z,{direction:"column",children:[w.jsx(G,{size:"1",weight:"medium",children:e("asset.ktx2.mode.uastc.label")}),w.jsx(G,{size:"1",muted:!0,children:e("asset.ktx2.mode.uastc.desc")}),w.jsx(ve,{css:{margin:"$1 0"}}),w.jsx(G,{size:"1",weight:"medium",children:e("asset.ktx2.mode.etc1s.label")}),w.jsx(G,{size:"1",muted:!0,children:e("asset.ktx2.mode.etc1s.desc")})]}),children:w.jsx(Ve,{size:"18px"})}),value:i?"UASTC":t.mode,disabled:n.disabled||i,onChange:a=>{t.mode=a,n.onChange&&n.onChange(),Tracert.click("c351684.d417985",{type:a})},options:[{label:e("asset.ktx2.mode.uastc.label"),value:"UASTC"},{label:e("asset.ktx2.mode.etc1s.label"),value:"ETC1S"}]}),!i&&t.mode==="ETC1S"?w.jsx(Me,{formStartSlot:w.jsx(z,{css:{marginLeft:"$8"}}),disabled:n.disabled,label:e("asset.ktx2.quality"),min:0,max:255,step:1,value:t.quality,onChange:a=>{t.quality=Math.floor(a),n.onChange&&n.onChange()}}):null]})}),et=q(({textureOptions:n,onChange:e,disabled:t,isHDR:i})=>w.jsx(w.Fragment,{children:w.jsxs(Ce,{defaultOpen:!0,title:P("texture.bundle.format-options"),children:[w.jsx(Se,{label:P("texture.bundle.overwrite"),disabled:t,value:n.overwrite,onChange:a=>{n.overwrite=a,e&&e()}}),w.jsx(ne,{label:P("texture.bundle.texture-compression"),value:n.textureType,disabled:!n.overwrite||t,onChange:a=>{n.textureType=a,e&&e()},options:[{label:P("texture.bundle.type.ktx2"),value:"ktx2"},{label:P("texture.bundle.type.original"),value:"original"}]}),n.textureType==="ktx2"?w.jsx(Qe,{labelFirst:!1,onChange:e,disabled:!n.overwrite||t,encodeOptions:n,isHDR:i}):null]})})),tt=new Set(["colorDilate"]),nt=new Set(["isSRGBColorSpace","mipmap","filterMode","wrapModeU","wrapModeV","anisoLevel"]),at=q(n=>{var l;const e=n.asset,{inspectorFacade:t}=Ue(),i=e.runtimeOptions,a=!e.getEditable(),r=e instanceof M&&e.shape===V.Cube,s=e instanceof M&&((l=e.name)==null?void 0:l.endsWith(".hdr")),o=_e.useMemo(()=>{let c=e.formSchema.items;return e.isSubAsset?c=c.filter(u=>nt.has(u.property)):r&&(c=c.filter(u=>!tt.has(u.property))),s&&(c=c.map(u=>u.property==="isSRGBColorSpace"?{...u,disabled:!0}:u)),c},[r,s,e.isSubAsset,e.formSchema.items]);return w.jsxs(w.Fragment,{children:[w.jsx(Re.List,{model:e,configs:o,onModelChange:(c,u)=>{t.assetChange(e.id,c,u)}}),!e.isSubAsset&&w.jsx(et,{onChange:()=>{t.assetChange(e.id,"runtimeOptions",{...i},"asset-meta")},textureOptions:i,disabled:a,isHDR:s})]})});async function ue(n){var i;const{asset:e,shouldRefresh:t}=n;if(!(!e.isInitCompleted||!t)){if(e.isSubAsset){const a=(i=e.mainAsset)==null?void 0:i._rebuild;await(a==null?void 0:a());return}await e.updateEngineObject()}}async function it(n){var e;(e=n.currentTexture)==null||e.destroy(),await n.rebuild(),n.notifyReady()}class rt extends Fe{constructor(){super(...arguments);v(this,"_asset");v(this,"_rootEntity");v(this,"_onRebuild",()=>{var t;this._entity&&(this._entity.destroy(),this._entity=null),this._rebuild(),(t=this._requestResetCamera)==null||t.call(this)})}setViewAsset(t,i){this._asset=t,this._rootEntity=i,this._rebuild(),t.addPropertyChangeListener("engineObjectReady",this._onRebuild)}stopViewAsset(){var t;(t=this._asset)==null||t.removePropertyChangeListener("engineObjectReady",this._onRebuild),super.stopViewAsset(),this._asset=null,this._rootEntity=null}getDescription(t){return`${t.width}x${t.height}`}_rebuild(){const{_asset:t,_rootEntity:i}=this;!t||!i||!t.engineObject||t.engineObject.destroyed||(t.shape===V.Cube?this._buildCubePreview(i,t):this._build2DPreview(i,t))}_buildCubePreview(t,i){const a=t.engine,r=new Te(a,"cube-preview-sphere"),s=r.addComponent(Q);s.mesh=ee.createSphere(a,1,32);const o=new te(a,$.find("editor-cube-preview"));s.setMaterial(o),o.shaderData.setTexture(Y.getByName("u_cubeTexture"),i.engineObject),t.addChild(r),this._entity=r}_build2DPreview(t,i){const a=t.createChild("texture-preview"),r=a.addComponent(J);r.sprite=new Z(t.engine,i.engineObject),this._entity=a}}var st=Object.defineProperty,ot=Object.getOwnPropertyDescriptor,_=(n,e,t,i)=>{for(var a=i>1?void 0:i?ot(e,t):e,r=n.length-1,s;r>=0;r--)(s=n[r])&&(a=(i?s(e,t,a):s(a))||a);return i&&a&&st(e,t,a),a},V=(n=>(n["2D"]="2D",n.Cube="Cube",n))(V||{}),pe=(n=>(n[n.Default=0]="Default",n[n.Sprite=1]="Sprite",n))(pe||{});function lt(n){const{pixels:e,width:t,height:i}=F(new Uint8Array(n)),a=new Uint16Array(e.length);return k(e,a),{input:a.buffer,options:{isUASTC:!0,isHDR:!0,imageType:re.RGBAHalfFloat,width:t,height:i}}}function de(n){return createImageBitmap(n,{premultiplyAlpha:"none"}).then(e=>{const i=new OffscreenCanvas(e.width,e.height).getContext("2d");i.drawImage(e,0,0);const a=i.getImageData(0,0,e.width,e.height),r=new Float32Array(a.data.length);for(let s=0;s<a.data.length;s++)r[s]=a.data[s]/255;return{pixels:r,width:e.width,height:e.height}})}async function ct(n,e,t,i,a){if(L(e)){const{pixels:r,width:s,height:o}=F(new Uint8Array(e)),l=new Uint16Array(r.length);k(r,l);const c=new X(n,s,o,ae.R16G16B16A16,t,!1);return c.name=a,c.setPixelBuffer(l),t&&c.generateMipmaps(),{texture:c,width:s,height:o}}else{const r=await createImageBitmap(new Blob([e]),{premultiplyAlpha:"none"}),s=new X(n,r.width,r.height,void 0,t,i);return s.name=a,s.setImageSource(r),t&&s.generateMipmaps(),{texture:s,width:r.width,height:r.height}}}async function ut(n,e,t,i,a){const r=L(e),{pixels:s,width:o,height:l}=r?F(new Uint8Array(e)):await de(new Blob([e])),{faceSize:c,faces:u}=ce(s,o,l),d=r?ae.R16G16B16A16:void 0,p=new je(n,c,d,t,!r&&i);p.name=a;for(let y=0;y<6;y++)if(r){const b=new Uint16Array(c*c*4);k(u[y],b),p.setPixelBuffer(y,b,0)}else{const b=new OffscreenCanvas(c,c),h=b.getContext("2d"),m=h.createImageData(c,c),f=u[y];for(let g=0;g<f.length;g++)m.data[g]=Math.round(Math.min(1,Math.max(0,f[g]))*255);h.putImageData(m,0,0);const x=await createImageBitmap(b);p.setImageSource(y,x)}return t&&p.generateMipmaps(),{texture:p,faceSize:c}}async function pt({content:n,meta:e,name:t,path:i},a){let r=await n.arrayBuffer();const s=e.runtimeOptions;let o=a.assetOptions.textureOptions;s!=null&&s.overwrite&&(o=Object.assign({},a.assetOptions.textureOptions,s)),e.colorDilate&&(r=await(await le(r,{range:4,alpha:2})).arrayBuffer());const l=e.filterMode??U.Bilinear,c=e.wrapModeU??C.Repeat,u=e.wrapModeV??C.Repeat,d=e.anisoLevel??1,p=e.mipmap??!0,y=e.isSRGBColorSpace??!0,b=L(r);if(o.textureType==="ktx2")try{const{input:f,options:x}=b?lt(r):{input:r,options:{isUASTC:o.mode==="UASTC",qualityLevel:o.quality}};let g=await H.encode(f,{...x,generateMipmap:p,isSetKTX2SRGBTransferFunc:!b&&y});return g=H.setTextureParams(g,{wrapModeU:c,wrapModeV:u,filterMode:l,anisoLevel:d}),{name:ie(t,".ktx2"),type:"KTX2",content:new Blob([g],{type:"image/ktx2"})}}catch(f){console.error(f),console.error("downgrade to uncompressed texture")}let h,m;if(b){const f=F(new Uint8Array(r));h=f.width,m=f.height}else{const f=URL.createObjectURL(n);try{const x=await Ee(f);h=x.width,m=x.height}finally{URL.revokeObjectURL(f)}}return{type:"Texture",content:new Blob([se(r,{type:"Texture2D",name:t,width:h,height:m,mipmap:Number(p),isSRGBColorSpace:Number(b?0:y),filterMode:l,wrapModeU:c,wrapModeV:u,anisoLevel:d,format:b?7:e.format,url:i})])}}async function W(n,e){return Promise.all(n.map(async t=>{const i=new OffscreenCanvas(e,e),a=i.getContext("2d"),r=a.createImageData(e,e);for(let o=0;o<t.length;o++)r.data[o]=Math.round(Math.min(1,Math.max(0,t[o]))*255);return a.putImageData(r,0,0),(await i.convertToBlob({type:"image/png"})).arrayBuffer()}))}async function dt({content:n,meta:e,name:t},i){const a=e.runtimeOptions;let r=i.assetOptions.textureOptions;a!=null&&a.overwrite&&(r=Object.assign({},r,a));const s=e.filterMode??U.Bilinear,o=e.wrapModeU??C.Clamp,l=e.wrapModeV??C.Clamp,c=e.anisoLevel??1,u=e.mipmap??!0,d=await n.arrayBuffer(),p=L(d),{pixels:y,width:b,height:h}=p?F(new Uint8Array(d)):await de(n),{faceSize:m,faces:f}=ce(y,b,h);if(r.textureType==="ktx2")try{let g,S;p?(g=f.map(O=>{const A=new Uint16Array(O.length);return k(O,A),A.buffer}),S={isUASTC:!0,isHDR:!0,imageType:re.RGBAHalfFloat,width:m,height:m}):(g=await W(f,m),S={isUASTC:r.mode==="UASTC",qualityLevel:r.quality});let B=await H.encode(g,{...S,generateMipmap:u,isSetKTX2SRGBTransferFunc:!p});return B=H.setTextureParams(B,{wrapModeU:o,wrapModeV:l,filterMode:s,anisoLevel:c}),{name:ie(t,".ktx2"),type:"KTX2",content:new Blob([B],{type:"image/ktx2"})}}catch(g){console.error(g),console.error("Cube: downgrade to uncompressed texture")}const x=p?f.map(g=>$e(g,m,m)):await W(f,m);return{type:"Texture",content:new Blob([se(x,{type:"TextureCube",name:t,faceSize:m,mipmap:Number(u),filterMode:s,anisoLevel:c,wrapModeU:o,wrapModeV:l,isSRGBColorSpace:Number(e.isSRGBColorSpace??0)})])}}let M=class extends Be{constructor(){super(...arguments);v(this,"shape","2D");v(this,"isSRGBColorSpace",!0);v(this,"mipmap",!0);v(this,"filterMode",U.Bilinear);v(this,"wrapModeU",C.Repeat);v(this,"wrapModeV",C.Repeat);v(this,"anisoLevel",1);v(this,"width",0);v(this,"height",0);v(this,"colorDilate",!1);v(this,"runtimeOptions",{overwrite:!1,textureType:"ktx2",mode:"ETC1S",quality:150,isNormal:!1});v(this,"_imageBuffer")}get imageBuffer(){return this._imageBuffer}beforeDelete(){}afterDelete(){var e;(e=this.engineObject)==null||e.destroy(!0)}setTextureType(e){e===1&&(this.wrapModeU=this.wrapModeV=C.Clamp,this.mipmap=!1,this.root.assetFacade.updateAssetMeta(this.id,{wrapModeU:this.wrapModeU,wrapModeV:this.wrapModeV,mipmap:this.mipmap}))}async initByEngineObject(e){this.bindEngineObject(e),this.filterMode=e.filterMode,this.wrapModeU=e.wrapModeU,this.wrapModeV=e.wrapModeV,this.anisoLevel=e.anisoLevel,this.width=e.width,this.height=e.height,this.mipmap=e._mipmap,this.isSRGBColorSpace=e.isSRGBColorSpace,this._name=e.name}async initByMain(e){const{meta:t}=this;this._imageBuffer=await e.arrayBuffer(),t.runtimeOptions&&(this.runtimeOptions=t.runtimeOptions),this.shape=t.shape??this.shape,this.filterMode=t.filterMode??this.filterMode,this.anisoLevel=t.anisoLevel??this.anisoLevel,this.wrapModeU=t.wrapModeU??this.wrapModeU,this.wrapModeV=t.wrapModeV??this.wrapModeV,this.colorDilate=t.colorDilate??this.colorDilate,this.mipmap=t.mipmap??this.mipmap,this.isSRGBColorSpace=t.isSRGBColorSpace??this.isSRGBColorSpace,await this._rebuildEngineObject()}async updateEngineObject(){await it({currentTexture:this.engineObject,rebuild:async()=>{await this._rebuildEngineObject()},notifyReady:()=>{this.triggerPropertyChange("engineObjectReady",!1)}})}async updateTextureImageSource(e){const t=await createImageBitmap(new Blob([e]),{premultiplyAlpha:"none"});this.engineObject.setImageSource(t),this.mipmap&&this.engineObject.generateMipmaps()}async onShapeChanged(e){const t=this.engineObject;await this._rebuildEngineObject(),t==null||t.destroy(!0),await this.root.assetFacade.updateAssetMeta(this.id,{shape:e}),this.updateThumbnail(),this.triggerPropertyChange("engineObjectReady",!1)}async _rebuildEngineObject(){if(this.shape==="Cube"){const{texture:e,faceSize:t}=await ut(this.engine,this._imageBuffer,this.mipmap,this.isSRGBColorSpace,this.name);this.width=t,this.height=t,this.bindEngineObject(e)}else{const{texture:e,width:t,height:i}=await ct(this.engine,this._imageBuffer,this.mipmap,this.isSRGBColorSpace,this.name);this.width=t,this.height=i,this.bindEngineObject(e)}}};_([D({label:"texture.shape.title",type:j.Select,onChange:async(n,e,t)=>{n.isInitCompleted&&await n.onShapeChanged(t)},options:[{label:"2D",value:"2D"},{label:"Cube",value:"Cube"}]}),T()],M.prototype,"shape",2);_([D({label:"texture.sRGB.title",type:j.Toggle,onChange:async(n,e,t)=>{await ue({asset:n,shouldRefresh:n.shape==="2D"})}}),T()],M.prototype,"isSRGBColorSpace",2);_([D({label:"texture.mipmap.title",type:j.Toggle,onChange:async(n,e,t)=>{await ue({asset:n,shouldRefresh:!0})}}),T()],M.prototype,"mipmap",2);_([D({label:"texture.filter-mode.title",type:j.Select,value:U.Bilinear,bindPath:"filterMode",options:[{label:"texture.filter-mode.point",value:U.Point},{label:"texture.filter-mode.bilinear",value:U.Bilinear},{label:"texture.filter-mode.trilinear",value:U.Trilinear}]}),T()],M.prototype,"filterMode",2);_([D({label:"texture.wrap-mode.u.title",type:j.Select,bindPath:"wrapModeU",options:[{label:"texture.wrap-mode.clamp",value:C.Clamp},{label:"texture.wrap-mode.repeat",value:C.Repeat},{label:"texture.wrap-mode.mirror",value:C.Mirror}]}),T()],M.prototype,"wrapModeU",2);_([D({label:"texture.wrap-mode.v.title",type:j.Select,bindPath:"wrapModeV",options:[{label:"texture.wrap-mode.clamp",value:C.Clamp},{label:"texture.wrap-mode.repeat",value:C.Repeat},{label:"texture.wrap-mode.mirror",value:C.Mirror}]}),T()],M.prototype,"wrapModeV",2);_([D({label:"texture.aniso-level.title",type:j.Slider,dragStep:1,max:16,min:1,bindPath:"anisoLevel"}),T()],M.prototype,"anisoLevel",2);_([T()],M.prototype,"width",2);_([T()],M.prototype,"height",2);_([D({label:"texture.dilate.title",info:"texture.dilate.info",type:j.Toggle}),T()],M.prototype,"colorDilate",2);_([Oe,T()],M.prototype,"runtimeOptions",2);M=_([Ie({type:"Texture",label:P("asset.texture.title"),loaderType:"Texture",importMenuConfig:{type:Pe.Upload,accept:".png,.jpg,.jpeg,.webp,.hdr",multiple:!0},preUpload:async n=>{const e=await n.main.arrayBuffer();return L(e)?{main:n.main,meta:JSON.stringify({isSRGBColorSpace:!1})}:n.main},viewer:rt,thumbnail:E,extname:"tex",icon:{bgSolidColor:new Ae(0,0,0,0)},dragLayer:De.Texture,customInspector:at,async preInitialize({main:n,meta:e,name:t}){if(e.colorDilate){const i=await n.arrayBuffer(),a=await le(i,{range:4,alpha:2});return new File([a],t,{type:"Texture"})}return n},async bundle({content:n,meta:e,name:t,path:i},a){return e.shape==="Cube"?dt({content:n,meta:e,name:t},a):pt({content:n,meta:e,name:t,path:i},a)}})],M);const Ct=Object.freeze(Object.defineProperty({__proto__:null,get TextureAsset(){return M},TextureShape:V,TextureUseType:pe},Symbol.toStringTag,{value:"Module"}));export{Qe as K,V as T,pe as a,M as b,at as c,Ct as d};
@@ -1 +0,0 @@
1
- var h=Object.defineProperty;var u=(e,A,a)=>A in e?h(e,A,{enumerable:!0,configurable:!0,writable:!0,value:a}):e[A]=a;var m=(e,A,a)=>(u(e,typeof A!="symbol"?A+"":A,a),a);import{J as g,K as b,u as p}from"./index-0a8702e2.js";import{C as d}from"./CanvasRenderer-9dd98cb3.js";import{g as _,a as f}from"./ThumbnailRegistry-495c18c9.js";import"./AssetPreviewer-24e31d97.js";import"./IconPlayerPlayFilled-b058c98f.js";var Q=Object.defineProperty,j=Object.getOwnPropertyDescriptor,y=(e,A,a,i)=>{for(var t=i>1?void 0:i?j(A,a):A,s=e.length-1,o;s>=0;s--)(o=e[s])&&(t=(i?o(A,a,t):o(t))||t);return i&&t&&Q(A,a,t),t};const r=window.devicePixelRatio,k=Math.round(70*r),D=Math.round(70*r),R={Scene:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*Z36ZQ4DCa58AAAAAAAAAAAAADuiaAQ/original",script:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*rMekSIWSS4oAAAAAAAAAAAAADuiaAQ/original",Folder:"https://mdn.alipayobjects.com/huamei_x9dkln/afts/img/A*FCaHQb2o4LsAAAAAAAAAAAAADsGIAQ/original",FolderLocked:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*q3h-RoSMm8AAAAAAQCAAAAgAeuiaAQ/original",Font:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*fYh9QKvlmX0AAAAAAAAAAAAADuiaAQ/original",Lottie:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*G7AkQoIP5c4AAAAAAAAAAAAADuiaAQ/original",SpriteAtlas:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*3R4xR5csHVEAAAAAAAAAAAAADuiaAQ/original",AnimatorController:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*-kFKQ5avQB8AAAAAAAAAAAAADuiaAQ/original",AnimationClip:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*_oBXQrnu50sAAAAAAAAAAAAADuiaAQ/original",Spine:"https://mdn.alipayobjects.com/huamei_x9dkln/afts/img/A*IQVfRLMioacAAAAAAAAAAAAADsGIAQ/original",Shader:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*kM0jQIKIzlgAAAAAAAAAAAAADuiaAQ/original",ShaderChunk:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*kM0jQIKIzlgAAAAAAAAAAAAADuiaAQ/original",XRReferenceImage:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*L0kBS4FGJLIAAAAAAAAAAAAADuiaAQ/original",glTF:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*HQs2QrqBTawAAAAAAAAAAAAADuiaAQ/original",Prefab:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*HQs2QrqBTawAAAAAAAAAAAAADuiaAQ/original",SpineSkeletonData:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*UnoLR4LjgcEAAAAAAAAAAAAADuiaAQ/original",SpineAtlas:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*q7BUSabi8scAAAAAAAAAAAAADuiaAQ/original",PhysicsMaterial:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*v6BsQbKRjKsAAAAAAAAAAAAADuiaAQ/original",Audio:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*r-1FSpQZvcUAAAAAAAAAAAAADuiaAQ/original",RenderTarget:"https://mdn.alipayobjects.com/huamei_ic2ff1/afts/img/2fpfRbIC87EAAAAAQBAAAAgADhHBAQFr/original",Markdown:"https://mdn.alipayobjects.com/huamei_dc3kgb/afts/img/A*427uS5hw3wgAAAAAMOAAAAgAeuiaAQ/original"};var n;const c=(n=class{constructor(A){m(this,"_state",p({thumbnailUrl:""}));m(this,"_updateThumbnailDebounced");this.asset=A,this._updateThumbnailDebounced=b(this._updateThumbnail.bind(this),100,{edges:["trailing"]}),n.registerCanvas(k,D,A.engine)}static async createThumbnailUrl(A){const a=A.getMetaConfig().type,i=_(a);if(!i){console.error("can't find '"+a+"' ThumbnailItem.");return}const t=this._canvasRenderer,{rootEntity:s,width:o,height:l}=t;return i.update(s,A),t.renderOneFrame(o,l),i.clear(),t.createImageUrl()}static registerCanvas(A,a,i){if(!this._canvasRenderer){this._canvasRenderer=new d(A,a,i);const t=f();for(const s in t)t[s].entity=null}}get thumbnailUrl(){return this._state.thumbnailUrl||(R[this.asset.getMetaConfig().type]??"")}set thumbnailUrl(A){this._state.thumbnailUrl=A}updateThumbnail(A){this._updateThumbnailDebounced(A)}async _updateThumbnail(A=!1){if(A){URL.revokeObjectURL(this._state.thumbnailUrl),this._state.thumbnailUrl="";return}this.asset.engineObject&&(URL.revokeObjectURL(this._state.thumbnailUrl),this._state.thumbnailUrl=await n.createThumbnailUrl(this.asset))}dispose(){this._state.thumbnailUrl&&(URL.revokeObjectURL(this._state.thumbnailUrl),this._state.thumbnailUrl="")}},m(n,"_canvasRenderer"),n);y([g],c.prototype,"_updateThumbnail",1);let C=c;export{C as ThumbnailMixin};
@@ -1 +0,0 @@
1
- const t={};function i(e){return t[e]}function r(){return t}function s(e,n){t[e]=n}export{r as a,i as g,s as r};
@@ -1 +0,0 @@
1
- import{aJ as s,bI as _,dR as le,aD as f,bL as O,bK as g,dS as G,dT as ce,dU as ue,dV as de,dW as fe,bF as pe,dX as Y,dY as ve,dZ as z,d_ as he,d$ as ye,bM as xe,bH as Ee,e0 as be,bQ as me,aH as Ce}from"./index-0a8702e2.js";var ge="DismissableLayer",I="dismissableLayer.update",Te="dismissableLayer.pointerDownOutside",Pe="dismissableLayer.focusOutside",V,X=s.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),q=s.forwardRef((e,n)=>{const{disableOutsidePointerEvents:t=!1,onEscapeKeyDown:r,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:u,...c}=e,d=s.useContext(X),[l,h]=s.useState(null),v=(l==null?void 0:l.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,y]=s.useState({}),x=_(n,p=>h(p)),E=Array.from(d.layers),[b]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),C=E.indexOf(b),m=l?E.indexOf(l):-1,P=d.layersWithOutsidePointerEventsDisabled.size>0,T=m>=C,w=De(p=>{const A=p.target,$=[...d.branches].some(k=>k.contains(A));!T||$||(o==null||o(p),i==null||i(p),p.defaultPrevented||u==null||u())},v),D=Oe(p=>{const A=p.target;[...d.branches].some(k=>k.contains(A))||(a==null||a(p),i==null||i(p),p.defaultPrevented||u==null||u())},v);return le(p=>{m===d.layers.size-1&&(r==null||r(p),!p.defaultPrevented&&u&&(p.preventDefault(),u()))},v),s.useEffect(()=>{if(l)return t&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(V=v.body.style.pointerEvents,v.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(l)),d.layers.add(l),U(),()=>{t&&d.layersWithOutsidePointerEventsDisabled.size===1&&(v.body.style.pointerEvents=V)}},[l,v,t,d]),s.useEffect(()=>()=>{l&&(d.layers.delete(l),d.layersWithOutsidePointerEventsDisabled.delete(l),U())},[l,d]),s.useEffect(()=>{const p=()=>y({});return document.addEventListener(I,p),()=>document.removeEventListener(I,p)},[]),f.jsx(O.div,{...c,ref:x,style:{pointerEvents:P?T?"auto":"none":void 0,...e.style},onFocusCapture:g(e.onFocusCapture,D.onFocusCapture),onBlurCapture:g(e.onBlurCapture,D.onBlurCapture),onPointerDownCapture:g(e.onPointerDownCapture,w.onPointerDownCapture)})});q.displayName=ge;var we="DismissableLayerBranch",Re=s.forwardRef((e,n)=>{const t=s.useContext(X),r=s.useRef(null),o=_(n,r);return s.useEffect(()=>{const a=r.current;if(a)return t.branches.add(a),()=>{t.branches.delete(a)}},[t.branches]),f.jsx(O.div,{...e,ref:o})});Re.displayName=we;function De(e,n=globalThis==null?void 0:globalThis.document){const t=G(e),r=s.useRef(!1),o=s.useRef(()=>{});return s.useEffect(()=>{const a=u=>{if(u.target&&!r.current){let c=function(){K(Te,t,d,{discrete:!0})};const d={originalEvent:u};u.pointerType==="touch"?(n.removeEventListener("click",o.current),o.current=c,n.addEventListener("click",o.current,{once:!0})):c()}else n.removeEventListener("click",o.current);r.current=!1},i=window.setTimeout(()=>{n.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),n.removeEventListener("pointerdown",a),n.removeEventListener("click",o.current)}},[n,t]),{onPointerDownCapture:()=>r.current=!0}}function Oe(e,n=globalThis==null?void 0:globalThis.document){const t=G(e),r=s.useRef(!1);return s.useEffect(()=>{const o=a=>{a.target&&!r.current&&K(Pe,t,{originalEvent:a},{discrete:!1})};return n.addEventListener("focusin",o),()=>n.removeEventListener("focusin",o)},[n,t]),{onFocusCapture:()=>r.current=!0,onBlurCapture:()=>r.current=!1}}function U(){const e=new CustomEvent(I);document.dispatchEvent(e)}function K(e,n,t,{discrete:r}){const o=t.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:t});n&&o.addEventListener(e,n,{once:!0}),r?ce(o,a):o.dispatchEvent(a)}var Le="Portal",Z=s.forwardRef((e,n)=>{var u;const{container:t,...r}=e,[o,a]=s.useState(!1);ue(()=>a(!0),[]);const i=t||o&&((u=globalThis==null?void 0:globalThis.document)==null?void 0:u.body);return i?de.createPortal(f.jsx(O.div,{...r,ref:n}),i):null});Z.displayName=Le;var Ae=s.forwardRef((e,n)=>{const{children:t,...r}=e,o=s.Children.toArray(t),a=o.find(_e);if(a){const i=a.props.children,u=o.map(c=>c===a?s.Children.count(i)>1?s.Children.only(null):s.isValidElement(i)?i.props.children:null:c);return f.jsx(M,{...r,ref:n,children:s.isValidElement(i)?s.cloneElement(i,void 0,u):null})}return f.jsx(M,{...r,ref:n,children:t})});Ae.displayName="Slot";var M=s.forwardRef((e,n)=>{const{children:t,...r}=e;if(s.isValidElement(t)){const o=je(t);return s.cloneElement(t,{...Se(r,t.props),ref:n?fe(n,o):o})}return s.Children.count(t)>1?s.Children.only(null):null});M.displayName="SlotClone";var J=({children:e})=>f.jsx(f.Fragment,{children:e});function _e(e){return s.isValidElement(e)&&e.type===J}function Se(e,n){const t={...n};for(const r in n){const o=e[r],a=n[r];/^on[A-Z]/.test(r)?o&&a?t[r]=(...u)=>{a(...u),o(...u)}:o&&(t[r]=o):r==="style"?t[r]={...o,...a}:r==="className"&&(t[r]=[o,a].filter(Boolean).join(" "))}return{...e,...t}}function je(e){var r,o;let n=(r=Object.getOwnPropertyDescriptor(e.props,"ref"))==null?void 0:r.get,t=n&&"isReactWarning"in n&&n.isReactWarning;return t?e.ref:(n=(o=Object.getOwnPropertyDescriptor(e,"ref"))==null?void 0:o.get,t=n&&"isReactWarning"in n&&n.isReactWarning,t?e.props.ref:e.props.ref||e.ref)}var Ne="VisuallyHidden",Q=s.forwardRef((e,n)=>f.jsx(O.span,{...e,ref:n,style:{position:"absolute",border:0,width:1,height:1,padding:0,margin:-1,overflow:"hidden",clip:"rect(0, 0, 0, 0)",whiteSpace:"nowrap",wordWrap:"normal",...e.style}}));Q.displayName=Ne;var ke=Q,[S,ot]=pe("Tooltip",[Y]),j=Y(),ee="TooltipProvider",Ie=700,H="tooltip.open",[Me,B]=S(ee),te=e=>{const{__scopeTooltip:n,delayDuration:t=Ie,skipDelayDuration:r=300,disableHoverableContent:o=!1,children:a}=e,[i,u]=s.useState(!0),c=s.useRef(!1),d=s.useRef(0);return s.useEffect(()=>{const l=d.current;return()=>window.clearTimeout(l)},[]),f.jsx(Me,{scope:n,isOpenDelayed:i,delayDuration:t,onOpen:s.useCallback(()=>{window.clearTimeout(d.current),u(!1)},[]),onClose:s.useCallback(()=>{window.clearTimeout(d.current),d.current=window.setTimeout(()=>u(!0),r)},[r]),isPointerInTransitRef:c,onPointerInTransitChange:s.useCallback(l=>{c.current=l},[]),disableHoverableContent:o,children:a})};te.displayName=ee;var N="Tooltip",[He,L]=S(N),ne=e=>{const{__scopeTooltip:n,children:t,open:r,defaultOpen:o=!1,onOpenChange:a,disableHoverableContent:i,delayDuration:u}=e,c=B(N,e.__scopeTooltip),d=j(n),[l,h]=s.useState(null),v=xe(),y=s.useRef(0),x=i??c.disableHoverableContent,E=u??c.delayDuration,b=s.useRef(!1),[C=!1,m]=Ee({prop:r,defaultProp:o,onChange:p=>{p?(c.onOpen(),document.dispatchEvent(new CustomEvent(H))):c.onClose(),a==null||a(p)}}),P=s.useMemo(()=>C?b.current?"delayed-open":"instant-open":"closed",[C]),T=s.useCallback(()=>{window.clearTimeout(y.current),b.current=!1,m(!0)},[m]),w=s.useCallback(()=>{window.clearTimeout(y.current),m(!1)},[m]),D=s.useCallback(()=>{window.clearTimeout(y.current),y.current=window.setTimeout(()=>{b.current=!0,m(!0)},E)},[E,m]);return s.useEffect(()=>()=>window.clearTimeout(y.current),[]),f.jsx(be,{...d,children:f.jsx(He,{scope:n,contentId:v,open:C,stateAttribute:P,trigger:l,onTriggerChange:h,onTriggerEnter:s.useCallback(()=>{c.isOpenDelayed?D():T()},[c.isOpenDelayed,D,T]),onTriggerLeave:s.useCallback(()=>{x?w():window.clearTimeout(y.current)},[w,x]),onOpen:T,onClose:w,disableHoverableContent:x,children:t})})};ne.displayName=N;var W="TooltipTrigger",re=s.forwardRef((e,n)=>{const{__scopeTooltip:t,...r}=e,o=L(W,t),a=B(W,t),i=j(t),u=s.useRef(null),c=_(n,u,o.onTriggerChange),d=s.useRef(!1),l=s.useRef(!1),h=s.useCallback(()=>d.current=!1,[]);return s.useEffect(()=>()=>document.removeEventListener("pointerup",h),[h]),f.jsx(ve,{asChild:!0,...i,children:f.jsx(O.button,{"aria-describedby":o.open?o.contentId:void 0,"data-state":o.stateAttribute,...r,ref:c,onPointerMove:g(e.onPointerMove,v=>{v.pointerType!=="touch"&&!l.current&&!a.isPointerInTransitRef.current&&(o.onTriggerEnter(),l.current=!0)}),onPointerLeave:g(e.onPointerLeave,()=>{o.onTriggerLeave(),l.current=!1}),onPointerDown:g(e.onPointerDown,()=>{d.current=!0,document.addEventListener("pointerup",h,{once:!0})}),onFocus:g(e.onFocus,()=>{d.current||o.onOpen()}),onBlur:g(e.onBlur,o.onClose),onClick:g(e.onClick,o.onClose)})})});re.displayName=W;var F="TooltipPortal",[We,Be]=S(F,{forceMount:void 0}),oe=e=>{const{__scopeTooltip:n,forceMount:t,children:r,container:o}=e,a=L(F,n);return f.jsx(We,{scope:n,forceMount:t,children:f.jsx(z,{present:t||a.open,children:f.jsx(Z,{asChild:!0,container:o,children:r})})})};oe.displayName=F;var R="TooltipContent",se=s.forwardRef((e,n)=>{const t=Be(R,e.__scopeTooltip),{forceMount:r=t.forceMount,side:o="top",...a}=e,i=L(R,e.__scopeTooltip);return f.jsx(z,{present:r||i.open,children:i.disableHoverableContent?f.jsx(ae,{side:o,...a,ref:n}):f.jsx(Fe,{side:o,...a,ref:n})})}),Fe=s.forwardRef((e,n)=>{const t=L(R,e.__scopeTooltip),r=B(R,e.__scopeTooltip),o=s.useRef(null),a=_(n,o),[i,u]=s.useState(null),{trigger:c,onClose:d}=t,l=o.current,{onPointerInTransitChange:h}=r,v=s.useCallback(()=>{u(null),h(!1)},[h]),y=s.useCallback((x,E)=>{const b=x.currentTarget,C={x:x.clientX,y:x.clientY},m=Ge(C,b.getBoundingClientRect()),P=Ye(C,m),T=ze(E.getBoundingClientRect()),w=qe([...P,...T]);u(w),h(!0)},[h]);return s.useEffect(()=>()=>v(),[v]),s.useEffect(()=>{if(c&&l){const x=b=>y(b,l),E=b=>y(b,c);return c.addEventListener("pointerleave",x),l.addEventListener("pointerleave",E),()=>{c.removeEventListener("pointerleave",x),l.removeEventListener("pointerleave",E)}}},[c,l,y,v]),s.useEffect(()=>{if(i){const x=E=>{const b=E.target,C={x:E.clientX,y:E.clientY},m=(c==null?void 0:c.contains(b))||(l==null?void 0:l.contains(b)),P=!Xe(C,i);m?v():P&&(v(),d())};return document.addEventListener("pointermove",x),()=>document.removeEventListener("pointermove",x)}},[c,l,i,d,v]),f.jsx(ae,{...e,ref:a})}),[$e,Ve]=S(N,{isInside:!1}),ae=s.forwardRef((e,n)=>{const{__scopeTooltip:t,children:r,"aria-label":o,onEscapeKeyDown:a,onPointerDownOutside:i,...u}=e,c=L(R,t),d=j(t),{onClose:l}=c;return s.useEffect(()=>(document.addEventListener(H,l),()=>document.removeEventListener(H,l)),[l]),s.useEffect(()=>{if(c.trigger){const h=v=>{const y=v.target;y!=null&&y.contains(c.trigger)&&l()};return window.addEventListener("scroll",h,{capture:!0}),()=>window.removeEventListener("scroll",h,{capture:!0})}},[c.trigger,l]),f.jsx(q,{asChild:!0,disableOutsidePointerEvents:!1,onEscapeKeyDown:a,onPointerDownOutside:i,onFocusOutside:h=>h.preventDefault(),onDismiss:l,children:f.jsxs(he,{"data-state":c.stateAttribute,...d,...u,ref:n,style:{...u.style,"--radix-tooltip-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-tooltip-content-available-width":"var(--radix-popper-available-width)","--radix-tooltip-content-available-height":"var(--radix-popper-available-height)","--radix-tooltip-trigger-width":"var(--radix-popper-anchor-width)","--radix-tooltip-trigger-height":"var(--radix-popper-anchor-height)"},children:[f.jsx(J,{children:r}),f.jsx($e,{scope:t,isInside:!0,children:f.jsx(ke,{id:c.contentId,role:"tooltip",children:o||r})})]})})});se.displayName=R;var ie="TooltipArrow",Ue=s.forwardRef((e,n)=>{const{__scopeTooltip:t,...r}=e,o=j(t);return Ve(ie,t).isInside?null:f.jsx(ye,{...o,...r,ref:n})});Ue.displayName=ie;function Ge(e,n){const t=Math.abs(n.top-e.y),r=Math.abs(n.bottom-e.y),o=Math.abs(n.right-e.x),a=Math.abs(n.left-e.x);switch(Math.min(t,r,o,a)){case a:return"left";case o:return"right";case t:return"top";case r:return"bottom";default:throw new Error("unreachable")}}function Ye(e,n,t=5){const r=[];switch(n){case"top":r.push({x:e.x-t,y:e.y+t},{x:e.x+t,y:e.y+t});break;case"bottom":r.push({x:e.x-t,y:e.y-t},{x:e.x+t,y:e.y-t});break;case"left":r.push({x:e.x+t,y:e.y-t},{x:e.x+t,y:e.y+t});break;case"right":r.push({x:e.x-t,y:e.y-t},{x:e.x-t,y:e.y+t});break}return r}function ze(e){const{top:n,right:t,bottom:r,left:o}=e;return[{x:o,y:n},{x:t,y:n},{x:t,y:r},{x:o,y:r}]}function Xe(e,n){const{x:t,y:r}=e;let o=!1;for(let a=0,i=n.length-1;a<n.length;i=a++){const u=n[a].x,c=n[a].y,d=n[i].x,l=n[i].y;c>r!=l>r&&t<(d-u)*(r-c)/(l-c)+u&&(o=!o)}return o}function qe(e){const n=e.slice();return n.sort((t,r)=>t.x<r.x?-1:t.x>r.x?1:t.y<r.y?-1:t.y>r.y?1:0),Ke(n)}function Ke(e){if(e.length<=1)return e.slice();const n=[];for(let r=0;r<e.length;r++){const o=e[r];for(;n.length>=2;){const a=n[n.length-1],i=n[n.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))n.pop();else break}n.push(o)}n.pop();const t=[];for(let r=e.length-1;r>=0;r--){const o=e[r];for(;t.length>=2;){const a=t[t.length-1],i=t[t.length-2];if((a.x-i.x)*(o.y-i.y)>=(a.y-i.y)*(o.x-i.x))t.pop();else break}t.push(o)}return t.pop(),n.length===1&&t.length===1&&n[0].x===t[0].x&&n[0].y===t[0].y?n:n.concat(t)}var Ze=ne,Je=re,Qe=oe,et=se;const tt=me({"0%":{opacity:0,transform:"scale(0) translateY(-4px)"},"100%":{opacity:1,transform:"scale(1) translateY(0px)"}}),nt=Ce(et,{display:"flex",alignItems:"center",fontSize:"13px",padding:"$2 $3",backgroundColor:"$gray2",borderRadius:"$4",color:"$gray12",boxShadow:"inset 0 0 0 1px $colors$grayA4",transformOrigin:"var(--radix-tooltip-content-transform-origin)",animation:`${tt} 0.2s ease forwards`});function st(e){const{children:n,content:t,side:r="bottom",sideOffset:o=6,delayDuration:a=0,...i}=e;return f.jsx(te,{children:f.jsxs(Ze,{delayDuration:a,...i,children:[f.jsx(Je,{asChild:!0,children:n}),f.jsx(Qe,{children:f.jsx(nt,{sideOffset:o,side:r,children:t})})]})})}export{st as T};
@@ -1 +0,0 @@
1
- var j=Object.defineProperty;var F=(t,e,r)=>e in t?j(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var u=(t,e,r)=>(F(t,typeof e!="symbol"?e+"":e,r),r);import{aT as O,aU as D,aJ as S,aD as p,aE as I,ck as L,cl as Y,cm as z,cn as K,co as N,cp as B,cq as M,x as U,cr as q,aY as H,E as J,cs as A,p as P,C as f,s as h,f as G,t as W,e as $,w as Q}from"./index-0a8702e2.js";import{u as X}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as Z}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import{B as k}from"./index-37c74ae9.js";import{c as tt}from"./createOnModelChange-b57a0da8.js";import{R as et}from"./ReferencedMaterial-a87818f3.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";import"./Menu-cd3be298.js";import"./MaterialInspector-aec1248b.js";import"./IconPointFilled-a304fd34.js";const v=(t=[[0,1],[1,1]])=>({class:"ParticleCurve",constructParams:t.map(([e,r])=>({class:"CurveKey",constructParams:[e,r]}))}),w=t=>({class:"ParticleCurve",constructParams:t.constructParams.map(e=>({class:"CurveKey",constructParams:[e.constructParams[0],e.constructParams[1]]})),editorYTickScale:t.editorYTickScale}),R=(t,e=v())=>{var r;return(r=t==null?void 0:t.constructParams)!=null&&r.length?w(t):w(e)},rt=(t,e=v())=>{const r=new L;return R(t,e).constructParams.forEach(a=>{r.addKey(new Y(a.constructParams[0],a.constructParams[1]))}),r},at=(t,e=v())=>(r,i,a)=>{const n=R(a,e);t(r,rt(n,e)),r[i]=n},it=O(({model:t,inspectorConfig:e,onModelChange:r})=>{const{t:i}=D(),a=e.property,n=e.defaultCurve??v(),o=R(t[a],n),g=o.editorYTickScale??e.yTickScale??1;S.useEffect(()=>{t[a]||(o.editorYTickScale=g,t[a]=o)},[]);const y=s=>{const l=t[a],V=s/g;t[a]={...l,constructParams:l.constructParams.map(x=>({...x,constructParams:[x.constructParams[0],x.constructParams[1]*V]})),editorYTickScale:s},r==null||r(a)},c=s=>{!s||s.length>4||(t[a]={class:"ParticleCurve",constructParams:s.map(l=>({class:"CurveKey",constructParams:[l.x,l.y*g]})),editorYTickScale:g},r==null||r(a))};return p.jsx(I,{label:i(e.label||a),info:i(e.info),children:p.jsx(k,{algo:"linear",yRangeMode:e.yRangeMode,yTickScale:g,yTickScaleMin:e.yTickScaleMin,yTickScaleMax:e.yTickScaleMax,onYTickScaleChange:y,onYTickScaleCommit:()=>r==null?void 0:r(a),value:o.constructParams.map(s=>({x:s.constructParams[0],y:s.constructParams[1]/g})),onChange:c})})}),b=(t=[{time:0,color:{r:1,g:1,b:1,a:1}},{time:1,color:{r:1,g:1,b:1,a:1}}],e=[{time:0,alpha:1},{time:1,alpha:1}])=>({class:"ParticleGradient",constructParams:[t.map(r=>({time:r.time,color:{r:r.color.r,g:r.color.g,b:r.color.b,a:r.color.a}})),e.map(r=>({time:r.time,alpha:r.alpha}))]}),_=t=>b(t.constructParams[0],t.constructParams[1]),E=(t,e=b())=>{var r,i,a;return!((i=(r=t==null?void 0:t.constructParams)==null?void 0:r[0])!=null&&i.length)||!((a=t.constructParams[1])!=null&&a.length)?_(e):_(t)},nt=(t,e=b())=>{const r=E(t,e);return new B(r.constructParams[0].map(i=>new M(i.time,new U(i.color.r,i.color.g,i.color.b,i.color.a))),r.constructParams[1].map(i=>new q(i.time,i.alpha)))},ot=(t,e=b())=>(r,i,a)=>{const n=E(a,e);t(r,nt(n,e)),r[i]=n},ct=O(({model:t,inspectorConfig:e,onModelChange:r})=>{const{t:i}=D(),a=e.property,n=e.defaultGradient??b(),o=E(t[a],n);S.useEffect(()=>{t[a]||(t[a]=o)},[]);const g={color:o.constructParams[0].map(c=>({value:z(c.color),position:c.time})),alpha:o.constructParams[1].map(c=>({value:{r:255,g:255,b:255,a:c.alpha},position:c.time}))},y=c=>{if(!c||c.color.length>4||c.alpha.length>4)return;const s={class:"ParticleGradient",constructParams:[c.color.map(l=>({time:l.position,color:N(l.value)})),c.alpha.map(l=>({time:l.position,alpha:l.value.a}))]};t[a]=s,r==null||r(a)};return p.jsx(I,{label:i(e.label||a),info:i(e.info),children:p.jsx(K,{fullsize:!0,mode:"particle",value:g,onValueChange:y})})}),st=O(function(t){const[e,r]=S.useState(null),i=t.data,{assetStore:a,inspectorFacade:n}=X();return S.useEffect(()=>{a.getAssetByRef(i.material).then(o=>{r(o)})},[i.material]),p.jsxs(p.Fragment,{children:[p.jsx(H.List,{model:i,configs:i.formSchema.items,onModelChange:tt("component",i.id,n,i)}),e&&p.jsx(p.Fragment,{children:p.jsx(et,{materialAsset:e})})]})});var lt=Object.defineProperty,mt=Object.getOwnPropertyDescriptor,d=(t,e,r,i)=>{for(var a=i>1?void 0:i?mt(e,r):e,n=t.length-1,o;n>=0;n--)(o=t[n])&&(a=(i?o(e,r,a):o(a))||a);return i&&a&&lt(e,r,a),a};const ut="0000205",T=v([[0,1],[1,1]]),C=b([{time:0,color:{r:1,g:1,b:1,a:1}},{time:1,color:{r:1,g:1,b:1,a:1}}],[{time:0,alpha:1},{time:1,alpha:1}]);let m=class extends J{constructor(){super(...arguments);u(this,"emitting",!0);u(this,"time",5);u(this,"minVertexDistance",.1);u(this,"widthCurve",T);u(this,"colorGradient",C);u(this,"textureMode",A.Stretch);u(this,"textureScale",{x:1,y:1});u(this,"material",{refId:ut});u(this,"priority",0)}};d([P({type:f.Toggle,bindPath:"emitting",label:"trail.emitting.label",info:"trail.emitting.info"}),h()],m.prototype,"emitting",2);d([P({type:f.Number,bindPath:"time",min:0,dragStep:.1,label:"trail.time.label",info:"trail.time.info"}),h()],m.prototype,"time",2);d([P({type:f.Number,bindPath:"minVertexDistance",min:0,dragStep:.01,label:"trail.min-vertex-distance.label",info:"trail.min-vertex-distance.info"}),h()],m.prototype,"minVertexDistance",2);d([G({getPath:"widthCurve",setPath:"widthCurve"}),P({customComponent:it,label:"trail.width-curve.label",info:"trail.width-curve.info",defaultCurve:T,yRangeMode:"positive",onChange:at((t,e)=>{t.setBoundPathValue("widthCurve",f.Input,e)},T)}),h()],m.prototype,"widthCurve",2);d([G({getPath:"colorGradient",setPath:"colorGradient"}),P({customComponent:ct,label:"trail.color-gradient.label",info:"trail.color-gradient.info",defaultGradient:C,onChange:ot((t,e)=>{t.setBoundPathValue("colorGradient",f.Input,e)},C)}),h()],m.prototype,"colorGradient",2);d([P({type:f.Select,bindPath:"textureMode",label:"trail.texture-mode.label",info:"trail.texture-mode.info",options:W(A,void 0,t=>$(`trail.texture-mode.${t.toLowerCase()}`))}),h()],m.prototype,"textureMode",2);d([P({type:f.Vector2,bindPath:"textureScale",min:.01,dragStep:.1,label:"trail.texture-scale.label",info:"trail.texture-scale.info"}),h()],m.prototype,"textureScale",2);d([G({engineKey:"setMaterial",setPath:"setMaterial()",getPath:"getMaterial()",valueType:Q.ReferResource,getEngineValue:t=>t.getMaterial()}),P({type:f.AssetPicker,assetType:"Material",label:"trail.material.label",info:"trail.material.info",customFilter:t=>{var e;return((e=t.engineObject.shader)==null?void 0:e.name)==="trail"}}),h({type:"methods",key:"setMaterial",onSerialize:t=>t?[[t]]:void 0,onDeserialize(t){return t?t[0][0]:void 0}})],m.prototype,"material",2);d([P({type:f.Number,bindPath:"priority",min:0,dragStep:1,label:"trail.priority.label",info:"trail.priority.info"}),h()],m.prototype,"priority",2);m=d([Z({type:"TrailRenderer",customInspector:st,componentsMenu:{group:"effects",label:"component.trail-renderer.title"}})],m);export{m as TrailRendererComponent};
@@ -1 +0,0 @@
1
- var C=Object.defineProperty;var P=(r,e,t)=>e in r?C(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var c=(r,e,t)=>(P(r,typeof e!="symbol"?e+"":e,t),t);import{aT as g,b9 as D,aU as O,aD as l,ba as A,aM as M,bb as B,p as f,e as p,C as T,s as u,E as F}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";function I(r){return l.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",width:"24",height:"24",viewBox:"0 0 24 24",...r,children:l.jsx("path",{fill:"currentColor",d:"M3 9a1 1 0 0 0 1-1V5a1 1 0 0 1 1-1h3a1 1 0 0 0 0-2H5a3 3 0 0 0-3 3v3a1 1 0 0 0 1 1m5 11H5a1 1 0 0 1-1-1v-3a1 1 0 0 0-2 0v3a3 3 0 0 0 3 3h3a1 1 0 0 0 0-2m9-7a1 1 0 0 0 0-2h-1.14A4 4 0 0 0 13 8.14V7a1 1 0 0 0-2 0v1.14A4 4 0 0 0 8.14 11H7a1 1 0 0 0 0 2h1.14A4 4 0 0 0 11 15.86V17a1 1 0 0 0 2 0v-1.14A4 4 0 0 0 15.86 13Zm-5 1a2 2 0 1 1 2-2a2 2 0 0 1-2 2m9 1a1 1 0 0 0-1 1v3a1 1 0 0 1-1 1h-3a1 1 0 0 0 0 2h3a3 3 0 0 0 3-3v-3a1 1 0 0 0-1-1M19 2h-3a1 1 0 0 0 0 2h3a1 1 0 0 1 1 1v3a1 1 0 0 0 2 0V5a3 3 0 0 0-3-3"})})}const S=g(D),H=g(({inspectorConfig:r,models:e,onModelChange:t,model:o})=>{const{label:n,property:a,disabled:h}=r,{t:v}=O(),E=!o;e=e||[o];const z=o.root.sceneStore.entities,d=e[0],b=o.root.sceneStore.rootEntity.children,_=e.map(i=>i.id);function j(i){const V=d.engineObject,y=z.get(i);if(!y)return;const w=y.engineObject.getComponent(B);V.lookAt(w.worldPosition),d.syncRotation()}return l.jsx(S,{disabled:h,label:v(n),value:E?{x:null,y:null,z:null}:o[a],onChange:(i,V)=>{e.forEach(y=>y[a]=i),t&&t(a,i)},formEndSlot:l.jsx(A,{trigger:l.jsx(M,{variant:"subtle",corner:!0,children:l.jsx(I,{style:{width:"13px",height:"13px"}})}),disabledEntities:_,entityMap:b,entities:b,label:n,onSelect:j})})});var R=Object.defineProperty,q=Object.getOwnPropertyDescriptor,x=(r,e,t,o)=>{for(var n=o>1?void 0:o?q(e,t):e,a=r.length-1,h;a>=0;a--)(h=r[a])&&(n=(o?h(e,t,n):h(n))||n);return o&&n&&R(e,t,n),n},s;const m=(s=class extends F{constructor(){super(...arguments);c(this,"position",{x:0,y:0,z:0});c(this,"rotation",{x:0,y:0,z:0});c(this,"scale",{x:1,y:1,z:1})}static equalVector3(t,o){return t.x===o.x&&t.y===o.y&&t.z===o.z}static roundToThreeDecimal(t){return Math.round(t*1e3)/1e3}static roundVector2(t,o){return o.x=this.roundToThreeDecimal(t.x),o.y=this.roundToThreeDecimal(t.y),o}static copyVector2(t,o){o.x=t.x,o.y=t.y}static roundVector3(t,o){return o.x=this.roundToThreeDecimal(t.x),o.y=this.roundToThreeDecimal(t.y),o.z=this.roundToThreeDecimal(t.z),o}static copyVector3(t,o){o.x=t.x,o.y=t.y,o.z=t.z}syncTransformToEditor(t){this._syncTransformToEditor("position",t.position),this._syncTransformToEditor("rotation",t.rotation),this._syncTransformToEditor("scale",t.scale)}_syncTransformToEditor(t,o){const n=this[t],a=s.roundVector3(o,s._tempVector3);s.equalVector3(a,n)||(s.copyVector3(a,n),this.notifyPropertyChange(t,!1))}},c(s,"_tempVector2",{x:0,y:0}),c(s,"_tempVector3",{x:0,y:0,z:0}),s);x([f({label:p("transform.position.title"),info:p("transform.position.info"),type:T.Vector3,bindPath:"position"}),u()],m.prototype,"position",2);x([f({label:p("transform.rotation.title"),info:p("transform.rotation.info"),customComponent:H,type:T.Vector3,bindPath:"rotation"}),u()],m.prototype,"rotation",2);x([f({label:p("transform.scale.title"),info:p("transform.scale.info"),type:T.Vector3,constrainable:!0,bindPath:"scale"}),u()],m.prototype,"scale",2);let K=m;export{K as T};
@@ -1 +0,0 @@
1
- var p=Object.defineProperty;var h=(r,t,o)=>t in r?p(r,t,{enumerable:!0,configurable:!0,writable:!0,value:o}):r[t]=o;var m=(r,t,o)=>(h(r,typeof t!="symbol"?t+"":t,o),o);import{J as l,e as s}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./AssetPreviewer-24e31d97.js";import{c as u}from"./Component-f923abb1.js";import{T}from"./TransformBaseComponent-02318c5a.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var d=Object.defineProperty,g=Object.getOwnPropertyDescriptor,f=(r,t,o,n)=>{for(var e=n>1?void 0:n?g(t,o):t,i=r.length-1,a;i>=0;i--)(a=r[i])&&(e=(n?a(t,o,e):a(e))||e);return n&&e&&d(t,o,e),e};let c=class extends T{constructor(t,o){super(t,o);m(this,"syncEngineToEditor",l(()=>{const{position:t,rotation:o,scale:n}=this.engineObject;this._syncTransformToEditor("position",t),this._syncTransformToEditor("rotation",o),this._syncTransformToEditor("scale",n)}))}syncRotation(){this._syncTransformToEditor("rotation",this.engineObject.rotation)}checkCanDisable(){return{code:1,msg:s("transform.error.cant-disable")}}checkCanDeletable(){return{code:1,msg:s("transform.error.cant-delete")}}get ignoreToJSON(){return!0}onAddToEntity(t){for(let o=0;o<t.components.length;o++){const n=t.components[o];(n.type==="Transform"||n.type==="UITransform")&&n!==this&&t.removeComponent(n)}t.setComponentIndex(this,0)}getAnimatableProperties(){let t=[];const o=n=>{if(!(n!=null&&n.length))return t;n.filter(e=>!e.when||e.when(this)).forEach(e=>{e.type==="Group"?o(e.children):t.push({property:e.property,label:s(e.label),type:e.type})})};return o(this.formSchema.items),t=t.concat(this._additionAnimatableProperties),t}};f([l],c.prototype,"syncRotation",1);c=f([u({type:"Transform",componentsMenu:{hide:!0,label:s("component.transform.title")}})],c);export{c as TransformComponent};
@@ -1 +0,0 @@
1
- var n=Object.defineProperty;var a=(r,e,t)=>e in r?n(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var i=(r,e,t)=>(a(r,typeof e!="symbol"?e+"":e,t),t);import{o,u as c,aW as h,aX as w}from"./index-0a8702e2.js";import{C as _}from"./CanvasRenderer-9dd98cb3.js";import"./AssetPreviewer-24e31d97.js";import"./IconPlayerPlayFilled-b058c98f.js";class V{constructor(e){i(this,"isPreviewReady",!1);i(this,"_canvas");i(this,"_rootEntity");i(this,"_currentViewer",null);i(this,"_canvasRenderer");o(this,{isPreviewReady:c});const t=new _(100,100,e,!0);this._canvas=t.canvas,this._canvas.style.width="100%",this._canvas.style.height="100%",this._canvasRenderer=t,this._rootEntity=t.scene.createRootEntity("root_object")}get currentViewer(){return this._currentViewer}get rootEntity(){return this._rootEntity}async startPreview(e,t){const s=t.getMetaConfig().type;if(this._currentViewer=h(s)??null,!this._currentViewer){console.error("Not support this asset type: ",s);return}await this._currentViewer.setViewAsset(t,this._rootEntity),this._canvasRenderer.addToContainer(e,this._currentViewer,this._rootEntity),this.isPreviewReady=!0}stopPreview(){this._rootEntity.clearChildren(),this._currentViewer.stopViewAsset(),this.isPreviewReady=!1,this._canvasRenderer.removeFromContainer()}}function p(r,e){w(r,e)}export{V as ViewerManager,p as registerViewer};
@@ -1 +0,0 @@
1
- var h=Object.defineProperty;var g=(t,e,r)=>e in t?h(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var c=(t,e,r)=>(g(t,typeof e!="symbol"?e+"":e,r),r);import{$ as f,j as u,a9 as d,bu as b,bv as y,b0 as U,p as R,e as p,C as w}from"./index-0a8702e2.js";import{X as j}from"./module-5c85b07e.js";import{a as O,A as I}from"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import"./postmen-45d4c238.js";import{A as v}from"./AssetViewer-bc198e16.js";import{e as C}from"./encode-ac4bb64e.js";import"./meshopt_simplifier.module-cd99529d.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";class _ extends v{constructor(){super()}setViewAsset(e,r){const s=r.createChild("sprite_entity"),i=s.addComponent(f);i.sprite=e._sprite,this._entity=s}}function x(t){const e=t.getCurrentUrl();return e&&(t.revokeObjectUrl(e),t.setCurrentUrl("")),new Promise((r,s)=>{const i=t.createImage();i.crossOrigin="*";const n=t.createObjectUrl(t.blob),a=()=>{t.revokeObjectUrl(n),t.getCurrentUrl()===n&&t.setCurrentUrl("")};t.setCurrentUrl(n),i.src=n,i.onload=()=>{a(),r(i)},i.onerror=m=>{a(),s(m)}})}var W=Object.defineProperty,A=Object.getOwnPropertyDescriptor,o=(t,e,r,s)=>{for(var i=s>1?void 0:s?A(e,r):e,n=t.length-1,a;n>=0;n--)(a=t[n])&&(i=(s?a(e,r,i):a(i))||i);return s&&i&&W(e,r,i),i};let l=class extends u{constructor(e){super(e);c(this,"imgUrl");c(this,"_sprite");c(this,"physicalWidth",.1);this._sprite=new d(this.engine)}async initByMain(e){const r=await x({blob:e,getCurrentUrl:()=>this.imgUrl,setCurrentUrl:a=>{this.imgUrl=a},createImage:()=>new Image,createObjectUrl:a=>URL.createObjectURL(a),revokeObjectUrl:a=>URL.revokeObjectURL(a)}),{_sprite:s}=this,i=new j("reference",r,r.width/100),n=new b(this.engine,r.width,r.height,y.R8G8B8A8,!1);n.setImageSource(r),s.texture=n,s.width=r.width/100,s.height=r.height/100,this.physicalWidth=i.physicalWidth=this.meta.physicalWidth,this.bindEngineObject(i)}initByEngineObject(e){this.bindEngineObject(e),this.physicalWidth=e.physicalWidth}};o([U(),R({label:p("xr.image.width.label"),info:p("xr.image.width.info"),type:w.Number})],l.prototype,"physicalWidth",2);l=o([O({type:"XRReferenceImage",label:p("asset.xr-reference-image.title"),loaderType:"XRReferenceImage",importMenuConfig:{type:I.Upload,tooltip:"支持多选",accept:".png,.jpg,.jpeg,.webp",multiple:!0},viewer:_,defaultName:"ReferenceImage",extname:"bin",async bundle({content:t,meta:e,name:r}){const s=await t.arrayBuffer();return{type:"XRReferenceImage",content:new Blob([C([s],{type:"XRReferenceImage",name:r,physicalWidth:e.physicalWidth})])}}})],l);export{l as XRReferenceImageAsset};
@@ -1 +0,0 @@
1
- var l=Object.defineProperty;var u=(e,o,r)=>o in e?l(e,o,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[o]=r;var n=(e,o,r)=>(u(e,typeof o!="symbol"?o+"":o,r),r);import{E as c,s as v,p as d,C as f}from"./index-0a8702e2.js";import"./InstanceEditorAsset-a70e73fe.js";import"./ThumbnailMixin-35997457.js";import"./AssetPreviewer-24e31d97.js";import"./CanvasRenderer-9dd98cb3.js";import{c as _}from"./Component-f923abb1.js";import"./postmen-45d4c238.js";import"./ThumbnailRegistry-495c18c9.js";import"./IconPlayerPlayFilled-b058c98f.js";var y=Object.defineProperty,C=Object.getOwnPropertyDescriptor,a=(e,o,r,t)=>{for(var p=t>1?void 0:t?C(o,r):o,m=e.length-1,i;m>=0;m--)(i=e[m])&&(p=(t?i(o,r,p):i(p))||p);return t&&p&&y(o,r,p),p};let s=class extends c{constructor(o,r){super(o,r);n(this,"volume",0)}};a([v(),d({type:f.Slider,min:0,max:10,dragStep:.01,bindPath:"volume"})],s.prototype,"volume",2);s=a([_({type:"Audio",class:"AudioSource"})],s);export{s as AudioComponent};
@@ -1 +0,0 @@
1
- var bn=Object.defineProperty;var _n=(i,e,t)=>e in i?bn(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Y=(i,e,t)=>(_n(i,typeof e!="symbol"?e+"":e,t),t);import{r as ht,K as Cn,a as On}from"./ktx-parse.modern-6c9f771f.js";import{M as $t,a as Xt}from"./meshopt_simplifier.module-cd99529d.js";class ps{constructor(){this._listeners={}}addEventListener(e,t){const r=this._listeners;return r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t),this}removeEventListener(e,t){const s=this._listeners[e];if(s!==void 0){const n=s.indexOf(t);n!==-1&&s.splice(n,1)}return this}dispatchEvent(e){const r=this._listeners[e.type];if(r!==void 0){const s=r.slice(0);for(let n=0,o=s.length;n<o;n++)s[n].call(this,e)}return this}dispose(){for(const e in this._listeners)delete this._listeners[e]}}class Be{constructor(e,t,r,s={}){if(this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=e,this._parent=t,this._child=r,this._attributes=s,!t.isOnGraph(r))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){this._disposed||(this._parent._destroyRef(this),this._disposed=!0)}isDisposed(){return this._disposed}}class Dn extends ps{constructor(...e){super(...e),this._emptySet=new Set,this._edges=new Set,this._parentEdges=new Map,this._childEdges=new Map}listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){const t=new Set;for(const r of this.listParentEdges(e))t.add(r.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){const t=new Set;for(const r of this.listChildEdges(e))t.add(r.getChild());return Array.from(t)}disconnectParents(e,t){for(const r of this.listParentEdges(e))(!t||t(r.getParent()))&&r.dispose();return this}_createEdge(e,t,r,s){const n=new Be(e,t,r,s);this._edges.add(n);const o=n.getParent();this._parentEdges.has(o)||this._parentEdges.set(o,new Set),this._parentEdges.get(o).add(n);const a=n.getChild();return this._childEdges.has(a)||this._childEdges.set(a,new Set),this._childEdges.get(a).add(n),n}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}}function Xe(){return Xe=Object.assign||function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},Xe.apply(this,arguments)}class he{constructor(e){if(this.list=[],e)for(const t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){const t=this.list.indexOf(e);t>=0&&this.list.splice(t,1)}removeChild(e){const t=[];for(const r of this.list)r.getChild()===e&&t.push(r);for(const r of t)this.remove(r);return t}listRefsByChild(e){const t=[];for(const r of this.list)r.getChild()===e&&t.push(r);return t}values(){return this.list}}class P{constructor(e){if(this.set=new Set,this.map=new Map,e)for(const t of e)this.add(t)}add(e){const t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){const t=this.map.get(e)||null;return t&&this.remove(t),t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}}class ne{constructor(e){this.map={},e&&Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}}const F=Symbol("attributes"),_e=Symbol("immutableKeys");class At extends ps{constructor(e){super(),this._disposed=!1,this.graph=void 0,this[F]=void 0,this[_e]=void 0,this.graph=e,this[_e]=new Set,this[F]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){const e=this.getDefaults(),t={};for(const r in e){const s=e[r];if(s instanceof At){const n=this.graph._createEdge(r,this,s);this[_e].add(r),t[r]=n}else t[r]=s}return t}isOnGraph(e){return this.graph===e.graph}isDisposed(){return this._disposed}dispose(){this._disposed||(this.graph.listChildEdges(this).forEach(e=>e.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"}))}detach(){return this.graph.disconnectParents(this),this}swap(e,t){for(const r in this[F]){const s=this[F][r];if(s instanceof Be){const n=s;n.getChild()===e&&this.setRef(r,t,n.getAttributes())}else if(s instanceof he)for(const n of s.listRefsByChild(e)){const o=n.getAttributes();this.removeRef(r,e),this.addRef(r,t,o)}else if(s instanceof P){const n=s.getRefByChild(e);if(n){const o=n.getAttributes();this.removeRef(r,e),this.addRef(r,t,o)}}else if(s instanceof ne)for(const n of s.keys()){const o=s.get(n);o.getChild()===e&&this.setRefMap(r,n,t,o.getAttributes())}}return this}get(e){return this[F][e]}set(e,t){return this[F][e]=t,this.dispatchEvent({type:"change",attribute:e})}getRef(e){const t=this[F][e];return t?t.getChild():null}setRef(e,t,r){if(this[_e].has(e))throw new Error(`Cannot overwrite immutable attribute, "${e}".`);const s=this[F][e];if(s&&s.dispose(),!t)return this;const n=this.graph._createEdge(e,this,t,r);return this[F][e]=n,this.dispatchEvent({type:"change",attribute:e})}listRefs(e){return this.assertRefList(e).values().map(r=>r.getChild())}addRef(e,t,r){const s=this.graph._createEdge(e,this,t,r);return this.assertRefList(e).add(s),this.dispatchEvent({type:"change",attribute:e})}removeRef(e,t){const r=this.assertRefList(e);if(r instanceof he)for(const s of r.listRefsByChild(t))s.dispose();else{const s=r.getRefByChild(t);s&&s.dispose()}return this}assertRefList(e){const t=this[F][e];if(t instanceof he||t instanceof P)return t;throw new Error(`Expected RefList or RefSet for attribute "${e}"`)}listRefMapKeys(e){return this.assertRefMap(e).keys()}listRefMapValues(e){return this.assertRefMap(e).values().map(t=>t.getChild())}getRefMap(e,t){const s=this.assertRefMap(e).get(t);return s?s.getChild():null}setRefMap(e,t,r,s){const n=this.assertRefMap(e),o=n.get(t);if(o&&o.dispose(),!r)return this;s=Object.assign(s||{},{key:t});const a=this.graph._createEdge(e,this,r,Xe({},s,{key:t}));return n.set(t,a),this.dispatchEvent({type:"change",attribute:e,key:t})}assertRefMap(e){const t=this[F][e];if(t instanceof ne)return t;throw new Error(`Expected RefMap for attribute "${e}"`)}dispatchEvent(e){return super.dispatchEvent(Xe({},e,{target:this})),this.graph.dispatchEvent(Xe({},e,{target:this,type:`node:${e.type}`})),this}_destroyRef(e){const t=e.getName();if(this[F][t]===e)this[F][t]=null,this[_e].has(t)&&e.getChild().dispose();else if(this[F][t]instanceof he)this[F][t].remove(e);else if(this[F][t]instanceof P)this[F][t].remove(e);else if(this[F][t]instanceof ne){const r=this[F][t];for(const s of r.keys())r.get(s)===e&&r.delete(s)}else return;this.graph._destroyEdge(e),this.dispatchEvent({type:"change",attribute:t})}}const ds="v4.1.0",Ue="@glb.bin";var h;(function(i){i.ACCESSOR="Accessor",i.ANIMATION="Animation",i.ANIMATION_CHANNEL="AnimationChannel",i.ANIMATION_SAMPLER="AnimationSampler",i.BUFFER="Buffer",i.CAMERA="Camera",i.MATERIAL="Material",i.MESH="Mesh",i.PRIMITIVE="Primitive",i.PRIMITIVE_TARGET="PrimitiveTarget",i.NODE="Node",i.ROOT="Root",i.SCENE="Scene",i.SKIN="Skin",i.TEXTURE="Texture",i.TEXTURE_INFO="TextureInfo"})(h||(h={}));var nt;(function(i){i.INTERLEAVED="interleaved",i.SEPARATE="separate"})(nt||(nt={}));var J;(function(i){i.ARRAY_BUFFER="ARRAY_BUFFER",i.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",i.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",i.OTHER="OTHER",i.SPARSE="SPARSE"})(J||(J={}));var te;(function(i){i[i.R=4096]="R",i[i.G=256]="G",i[i.B=16]="B",i[i.A=1]="A"})(te||(te={}));var ge;(function(i){i.GLTF="GLTF",i.GLB="GLB"})(ge||(ge={}));const at={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};var dt=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});function vn(){var i=new dt(3);return dt!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function gt(i){var e=i[0],t=i[1],r=i[2];return Math.hypot(e,t,r)}function Fn(i,e,t){var r=e[0],s=e[1],n=e[2],o=t[3]*r+t[7]*s+t[11]*n+t[15];return o=o||1,i[0]=(t[0]*r+t[4]*s+t[8]*n+t[12])/o,i[1]=(t[1]*r+t[5]*s+t[9]*n+t[13])/o,i[2]=(t[2]*r+t[6]*s+t[10]*n+t[14])/o,i}(function(){var i=vn();return function(e,t,r,s,n,o){var a,c;for(t||(t=3),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,a=r;a<c;a+=t)i[0]=e[a],i[1]=e[a+1],i[2]=e[a+2],n(i,i,o),e[a]=i[0],e[a+1]=i[1],e[a+2]=i[2];return e}})();function Ln(i){const e=Ts(),t=i.propertyType===h.NODE?[i]:i.listChildren();for(const r of t)r.traverse(s=>{const n=s.getMesh();if(!n)return;const o=Bn(n,s.getWorldMatrix());o.min.every(isFinite)&&o.max.every(isFinite)&&(Tt(o.min,e),Tt(o.max,e))});return e}function Bn(i,e){const t=Ts();for(const r of i.listPrimitives()){const s=r.getAttribute("POSITION"),n=r.getIndices();if(!s)continue;let o=[0,0,0],a=[0,0,0];for(let c=0,u=n?n.getCount():s.getCount();c<u;c++){const g=n?n.getScalar(c):c;o=s.getElement(g,o),a=Fn(a,o,e),Tt(a,t)}}return t}function Tt(i,e){for(let t=0;t<3;t++)e.min[t]=Math.min(i[t],e.min[t]),e.max[t]=Math.max(i[t],e.max[t])}function Ts(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class D{static createBufferFromDataURI(e){if(typeof Buffer>"u"){const t=atob(e.split(",")[1]),r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}else{const t=e.split(",")[1],r=e.indexOf("base64")>=0;return Buffer.from(t,r?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(const n of e)t+=n.byteLength;const r=new Uint8Array(t);let s=0;for(const n of e)r.set(n,s),s+=n.byteLength;return r}static pad(e,t=0){const r=this.padNumber(e.byteLength);if(r===e.byteLength)return e;const s=new Uint8Array(r);if(s.set(e),t!==0)for(let n=e.byteLength;n<r;n++)s[n]=t;return s}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let r=e.byteLength;for(;r--;)if(e[r]!==t[r])return!1;return!0}static toView(e,t=0,r=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,r))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw new Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}}class pi{static hexToFactor(e,t){e=Math.floor(e);const r=t;return r[0]=(e>>16&255)/255,r[1]=(e>>8&255)/255,r[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){const t=[...e],[r,s,n]=this.convertLinearToSRGB(e,t);return r*255<<16^s*255<<8^n*255<<0}static convertSRGBToLinear(e,t){const r=e,s=t;for(let n=0;n<3;n++)s[n]=r[n]<.04045?r[n]*.0773993808:Math.pow(r[n]*.9478672986+.0521327014,2.4);return t}static convertLinearToSRGB(e,t){const r=e,s=t;for(let n=0;n<3;n++)s[n]=r[n]<.0031308?r[n]*12.92:1.055*Math.pow(r[n],.41666)-.055;return t}}class jn{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),r,s;for(;t.byteLength;){if(r=t.getUint16(0,!1),Un(t,r),s=t.getUint8(r+1),s===192||s===193||s===194)return[t.getUint16(r+7,!1),t.getUint16(r+5,!1)];t=new DataView(e.buffer,t.byteOffset+r+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(e){return 3}}class ct{match(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10}getSize(e){const t=new DataView(e.buffer,e.byteOffset);return D.decodeText(e.slice(12,16))===ct.PNG_FRIED_CHUNK_NAME?[t.getUint32(32,!1),t.getUint32(36,!1)]:[t.getUint32(16,!1),t.getUint32(20,!1)]}getChannels(e){return 4}}ct.PNG_FRIED_CHUNK_NAME="CgBI";class ae{static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(const t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){return this.impls[t]?this.impls[t].getSize(e):null}static getChannels(e,t){return this.impls[t]?this.impls[t].getChannels(e):null}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let r=0;const s=4,n=this.getSize(e,t);if(!n)return null;for(;n[0]>1||n[1]>1;)r+=n[0]*n[1]*s,n[0]=Math.max(Math.floor(n[0]/2),1),n[1]=Math.max(Math.floor(n[1]/2),1);return r+=1*1*s,r}static mimeTypeToExtension(e){return e==="image/jpeg"?"jpg":e.split("/").pop()}static extensionToMimeType(e){return e==="jpg"?"image/jpeg":e?`image/${e}`:""}}ae.impls={"image/jpeg":new jn,"image/png":new ct};function Un(i,e){if(e>i.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(i.getUint8(e)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return i}class Pe{static basename(e){const t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){const t=e.match(/data:(image\/\w+)/)[1];return ae.mimeTypeToExtension(t)}else{if(e.startsWith("data:model/gltf+json"))return"gltf";if(e.startsWith("data:model/gltf-binary"))return"glb";if(e.startsWith("data:application/"))return"bin"}return e.split(/[\\/]/).pop().split(/[.]/).pop()}}function Kt(i){return Object.prototype.toString.call(i)==="[object Object]"}function Ce(i){if(Kt(i)===!1)return!1;const e=i.constructor;if(e===void 0)return!0;const t=e.prototype;return!(Kt(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var mt,xt;(function(i){i[i.SILENT=4]="SILENT",i[i.ERROR=3]="ERROR",i[i.WARN=2]="WARN",i[i.INFO=1]="INFO",i[i.DEBUG=0]="DEBUG"})(xt||(xt={}));class ee{constructor(e){this.verbosity=void 0,this.verbosity=e}debug(e){this.verbosity<=ee.Verbosity.DEBUG&&console.debug(e)}info(e){this.verbosity<=ee.Verbosity.INFO&&console.info(e)}warn(e){this.verbosity<=ee.Verbosity.WARN&&console.warn(e)}error(e){this.verbosity<=ee.Verbosity.ERROR&&console.error(e)}}mt=ee;ee.Verbosity=xt;ee.DEFAULT_INSTANCE=new mt(mt.Verbosity.INFO);function Pn(i){var e=i[0],t=i[1],r=i[2],s=i[3],n=i[4],o=i[5],a=i[6],c=i[7],u=i[8],g=i[9],p=i[10],m=i[11],N=i[12],S=i[13],w=i[14],M=i[15],l=e*o-t*n,b=e*a-r*n,T=e*c-s*n,R=t*a-r*o,x=t*c-s*o,y=r*c-s*a,f=u*S-g*N,d=u*w-p*N,E=u*M-m*N,I=g*w-p*S,_=g*M-m*S,O=p*M-m*w;return l*O-b*_+T*I+R*E-x*d+y*f}function Gn(i,e,t){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],c=e[5],u=e[6],g=e[7],p=e[8],m=e[9],N=e[10],S=e[11],w=e[12],M=e[13],l=e[14],b=e[15],T=t[0],R=t[1],x=t[2],y=t[3];return i[0]=T*r+R*a+x*p+y*w,i[1]=T*s+R*c+x*m+y*M,i[2]=T*n+R*u+x*N+y*l,i[3]=T*o+R*g+x*S+y*b,T=t[4],R=t[5],x=t[6],y=t[7],i[4]=T*r+R*a+x*p+y*w,i[5]=T*s+R*c+x*m+y*M,i[6]=T*n+R*u+x*N+y*l,i[7]=T*o+R*g+x*S+y*b,T=t[8],R=t[9],x=t[10],y=t[11],i[8]=T*r+R*a+x*p+y*w,i[9]=T*s+R*c+x*m+y*M,i[10]=T*n+R*u+x*N+y*l,i[11]=T*o+R*g+x*S+y*b,T=t[12],R=t[13],x=t[14],y=t[15],i[12]=T*r+R*a+x*p+y*w,i[13]=T*s+R*c+x*m+y*M,i[14]=T*n+R*u+x*N+y*l,i[15]=T*o+R*g+x*S+y*b,i}function Vn(i,e){var t=e[0],r=e[1],s=e[2],n=e[4],o=e[5],a=e[6],c=e[8],u=e[9],g=e[10];return i[0]=Math.hypot(t,r,s),i[1]=Math.hypot(n,o,a),i[2]=Math.hypot(c,u,g),i}function kn(i,e){var t=new dt(3);Vn(t,e);var r=1/t[0],s=1/t[1],n=1/t[2],o=e[0]*r,a=e[1]*s,c=e[2]*n,u=e[4]*r,g=e[5]*s,p=e[6]*n,m=e[8]*r,N=e[9]*s,S=e[10]*n,w=o+g+S,M=0;return w>0?(M=Math.sqrt(w+1)*2,i[3]=.25*M,i[0]=(p-N)/M,i[1]=(m-c)/M,i[2]=(a-u)/M):o>g&&o>S?(M=Math.sqrt(1+o-g-S)*2,i[3]=(p-N)/M,i[0]=.25*M,i[1]=(a+u)/M,i[2]=(m+c)/M):g>S?(M=Math.sqrt(1+g-o-S)*2,i[3]=(m-c)/M,i[0]=(a+u)/M,i[1]=.25*M,i[2]=(p+N)/M):(M=Math.sqrt(1+S-o-g)*2,i[3]=(a-u)/M,i[0]=(m+c)/M,i[1]=(p+N)/M,i[2]=.25*M),i}class B{static identity(e){return e}static eq(e,t,r=1e-5){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(Math.abs(e[s]-t[s])>r)return!1;return!0}static clamp(e,t,r){return e<t?t:e>r?r:e}static decodeNormalizedInt(e,t){switch(t){case 5126:return e;case 5123:return e/65535;case 5121:return e/255;case 5122:return Math.max(e/32767,-1);case 5120:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(e,t){switch(t){case 5126:return e;case 5123:return Math.round(B.clamp(e,0,1)*65535);case 5121:return Math.round(B.clamp(e,0,1)*255);case 5122:return Math.round(B.clamp(e,-1,1)*32767);case 5120:return Math.round(B.clamp(e,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(e,t,r,s){let n=gt([e[0],e[1],e[2]]);const o=gt([e[4],e[5],e[6]]),a=gt([e[8],e[9],e[10]]);Pn(e)<0&&(n=-n),t[0]=e[12],t[1]=e[13],t[2]=e[14];const u=e.slice(),g=1/n,p=1/o,m=1/a;u[0]*=g,u[1]*=g,u[2]*=g,u[4]*=p,u[5]*=p,u[6]*=p,u[8]*=m,u[9]*=m,u[10]*=m,kn(r,u),s[0]=n,s[1]=o,s[2]=a}static compose(e,t,r,s){const n=s,o=t[0],a=t[1],c=t[2],u=t[3],g=o+o,p=a+a,m=c+c,N=o*g,S=o*p,w=o*m,M=a*p,l=a*m,b=c*m,T=u*g,R=u*p,x=u*m,y=r[0],f=r[1],d=r[2];return n[0]=(1-(M+b))*y,n[1]=(S+x)*y,n[2]=(w-R)*y,n[3]=0,n[4]=(S-x)*f,n[5]=(1-(N+b))*f,n[6]=(l+T)*f,n[7]=0,n[8]=(w+R)*d,n[9]=(l-T)*d,n[10]=(1-(N+M))*d,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}}function Hn(i,e){if(!!i!=!!e)return!1;const t=i.getChild(),r=e.getChild();return t===r||t.equals(r)}function zn(i,e){if(!!i!=!!e)return!1;const t=i.values(),r=e.values();if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++){const n=t[s],o=r[s];if(n.getChild()!==o.getChild()&&!n.getChild().equals(o.getChild()))return!1}return!0}function $n(i,e){if(!!i!=!!e)return!1;const t=i.keys(),r=e.keys();if(t.length!==r.length)return!1;for(const s of t){const n=i.get(s),o=e.get(s);if(!!n!=!!o)return!1;const a=n.getChild(),c=o.getChild();if(a!==c&&!a.equals(c))return!1}return!0}function ms(i,e){if(i===e)return!0;if(!!i!=!!e||!i||!e||i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!==e[t])return!1;return!0}function xs(i,e){if(i===e)return!0;if(!!i!=!!e)return!1;if(!Ce(i)||!Ce(e))return i===e;const t=i,r=e;let s=0,n=0,o;for(o in t)s++;for(o in r)n++;if(s!==n)return!1;for(o in t){const a=t[o],c=r[o];if(rt(a)&&rt(c)){if(!ms(a,c))return!1}else if(Ce(a)&&Ce(c)){if(!xs(a,c))return!1}else if(a!==c)return!1}return!0}function rt(i){return Array.isArray(i)||ArrayBuffer.isView(i)}const qt="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",Xn=999,Kn=6,Yt=new Set,qn=function(){let e="";for(let t=0;t<Kn;t++)e+=qt.charAt(Math.floor(Math.random()*qt.length));return e},Yn=function(){for(let e=0;e<Xn;e++){const t=qn();if(!Yt.has(t))return Yt.add(t),t}return""},Wt="https://null.example";class Ke{static dirname(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substring(0,t+1)}static basename(e){return Pe.basename(new URL(e,Wt).pathname)}static extension(e){return Pe.extension(new URL(e,Wt).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;const r=e.split("/"),s=t.split("/");r.pop();for(let n=0;n<s.length;n++)s[n]!=="."&&(s[n]===".."?r.pop():r.push(s[n]));return r.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}}Ke.DEFAULT_INIT={};Ke.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;const pe=i=>i,Wn=new Set;class St extends At{constructor(e,t=""){super(e),this[F].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){return Array.isArray(t)&&(t=t.slice()),super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){const e=this.constructor;return new e(this.graph).copy(this,pe)}copy(e,t=pe){for(const r in this[F]){const s=this[F][r];if(s instanceof Be)this[_e].has(r)||s.dispose();else if(s instanceof he||s instanceof P)for(const n of s.values())n.dispose();else if(s instanceof ne)for(const n of s.values())n.dispose()}for(const r in e[F]){const s=this[F][r],n=e[F][r];if(n instanceof Be)this[_e].has(r)?s.getChild().copy(t(n.getChild()),t):this.setRef(r,t(n.getChild()),n.getAttributes());else if(n instanceof P||n instanceof he)for(const o of n.values())this.addRef(r,t(o.getChild()),o.getAttributes());else if(n instanceof ne)for(const o of n.keys()){const a=n.get(o);this.setRefMap(r,o,t(a.getChild()),a.getAttributes())}else Ce(n)?this[F][r]=JSON.parse(JSON.stringify(n)):Array.isArray(n)||n instanceof ArrayBuffer||ArrayBuffer.isView(n)?this[F][r]=n.slice():this[F][r]=n}return this}equals(e,t=Wn){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(const r in this[F]){if(t.has(r))continue;const s=this[F][r],n=e[F][r];if(s instanceof Be||n instanceof Be){if(!Hn(s,n))return!1}else if(s instanceof P||n instanceof P||s instanceof he||n instanceof he){if(!zn(s,n))return!1}else if(s instanceof ne||n instanceof ne){if(!$n(s,n))return!1}else if(Ce(s)||Ce(n)){if(!xs(s,n))return!1}else if(rt(s)||rt(n)){if(!ms(s,n))return!1}else if(s!==n)return!1}return!0}detach(){return this.graph.disconnectParents(this,e=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}}class q extends St{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new ne})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){return t&&t._validateParent(this),this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}}class A extends q{init(){this.propertyType=h.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:A.Type.SCALAR,componentType:A.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(e){switch(e){case A.Type.SCALAR:return 1;case A.Type.VEC2:return 2;case A.Type.VEC3:return 3;case A.Type.VEC4:return 4;case A.Type.MAT2:return 4;case A.Type.MAT3:return 9;case A.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+e)}}static getComponentSize(e){switch(e){case A.ComponentType.BYTE:return 1;case A.ComponentType.UNSIGNED_BYTE:return 1;case A.ComponentType.SHORT:return 2;case A.ComponentType.UNSIGNED_SHORT:return 2;case A.ComponentType.UNSIGNED_INT:return 4;case A.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+e)}}getMinNormalized(e){const t=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType();if(this.getMin(e),t)for(let n=0;n<r;n++)e[n]=B.decodeNormalizedInt(e[n],s);return e}getMin(e){const t=this.getArray(),r=this.getCount(),s=this.getElementSize();for(let n=0;n<s;n++)e[n]=1/0;for(let n=0;n<r*s;n+=s)for(let o=0;o<s;o++){const a=t[n+o];Number.isFinite(a)&&(e[o]=Math.min(e[o],a))}return e}getMaxNormalized(e){const t=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType();if(this.getMax(e),t)for(let n=0;n<r;n++)e[n]=B.decodeNormalizedInt(e[n],s);return e}getMax(e){const t=this.get("array"),r=this.getCount(),s=this.getElementSize();for(let n=0;n<s;n++)e[n]=-1/0;for(let n=0;n<r*s;n+=s)for(let o=0;o<s;o++){const a=t[n+o];Number.isFinite(a)&&(e[o]=Math.max(e[o],a))}return e}getCount(){const e=this.get("array");return e?e.length/this.getElementSize():0}getType(){return this.get("type")}setType(e){return this.set("type",e)}getElementSize(){return A.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(e){return this.set("normalized",e)}getScalar(e){const t=this.getElementSize(),r=this.getComponentType(),s=this.getArray();return this.getNormalized()?B.decodeNormalizedInt(s[e*t],r):s[e*t]}setScalar(e,t){const r=this.getElementSize(),s=this.getComponentType(),n=this.getArray();return this.getNormalized()?n[e*r]=B.encodeNormalizedInt(t,s):n[e*r]=t,this}getElement(e,t){const r=this.getNormalized(),s=this.getElementSize(),n=this.getComponentType(),o=this.getArray();for(let a=0;a<s;a++)r?t[a]=B.decodeNormalizedInt(o[e*s+a],n):t[a]=o[e*s+a];return t}setElement(e,t){const r=this.getNormalized(),s=this.getElementSize(),n=this.getComponentType(),o=this.getArray();for(let a=0;a<s;a++)r?o[e*s+a]=B.encodeNormalizedInt(t[a],n):o[e*s+a]=t[a];return this}getSparse(){return this.get("sparse")}setSparse(e){return this.set("sparse",e)}getBuffer(){return this.getRef("buffer")}setBuffer(e){return this.setRef("buffer",e)}getArray(){return this.get("array")}setArray(e){return this.set("componentType",e?Jn(e):A.ComponentType.FLOAT),this.set("array",e),this}getByteLength(){const e=this.get("array");return e?e.byteLength:0}}A.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};A.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function Jn(i){switch(i.constructor){case Float32Array:return A.ComponentType.FLOAT;case Uint32Array:return A.ComponentType.UNSIGNED_INT;case Uint16Array:return A.ComponentType.UNSIGNED_SHORT;case Uint8Array:return A.ComponentType.UNSIGNED_BYTE;case Int16Array:return A.ComponentType.SHORT;case Int8Array:return A.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class Es extends q{init(){this.propertyType=h.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new P,samplers:new P})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}}class Mt extends q{init(){this.propertyType=h.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}}Mt.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class Ve extends q{init(){this.propertyType=h.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:Ve.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(e){return this.set("interpolation",e)}getInput(){return this.getRef("input")}setInput(e){return this.setRef("input",e,{usage:J.OTHER})}getOutput(){return this.getRef("output")}setOutput(e){return this.setRef("output",e,{usage:J.OTHER})}}Ve.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class Rs extends q{init(){this.propertyType=h.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}}class ve extends q{init(){this.propertyType=h.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:ve.Type.PERSPECTIVE,znear:.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(e){return this.set("type",e)}getZNear(){return this.get("znear")}setZNear(e){return this.set("znear",e)}getZFar(){return this.get("zfar")}setZFar(e){return this.set("zfar",e)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(e){return this.set("aspectRatio",e)}getYFov(){return this.get("yfov")}setYFov(e){return this.set("yfov",e)}getXMag(){return this.get("xmag")}setXMag(e){return this.set("xmag",e)}getYMag(){return this.get("ymag")}setYMag(e){return this.set("ymag",e)}}ve.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class V extends St{_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw new Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}}V.EXTENSION_NAME=void 0;class j extends q{init(){this.propertyType=h.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:j.WrapMode.REPEAT,wrapT:j.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}getMagFilter(){return this.get("magFilter")}setMagFilter(e){return this.set("magFilter",e)}getMinFilter(){return this.get("minFilter")}setMinFilter(e){return this.set("minFilter",e)}getWrapS(){return this.get("wrapS")}setWrapS(e){return this.set("wrapS",e)}getWrapT(){return this.get("wrapT")}setWrapT(e){return this.set("wrapT",e)}}j.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};j.MagFilter={NEAREST:9728,LINEAR:9729};j.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};const{R:Qe,G:Ze,B:et,A:Qn}=te;class Oe extends q{init(){this.propertyType=h.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:Oe.AlphaMode.OPAQUE,alphaCutoff:.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new j(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new j(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new j(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new j(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new j(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(e){return this.set("doubleSided",e)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(e){const t=this.get("baseColorFactor").slice();return t[3]=e,this.set("baseColorFactor",t)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(e){return this.set("alphaMode",e)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(e){return this.set("alphaCutoff",e)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(e){return this.set("baseColorFactor",e)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(e){return this.setRef("baseColorTexture",e,{channels:Qe|Ze|et|Qn,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(e){return this.set("emissiveFactor",e)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(e){return this.setRef("emissiveTexture",e,{channels:Qe|Ze|et,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(e){return this.set("normalScale",e)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(e){return this.setRef("normalTexture",e,{channels:Qe|Ze|et})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(e){return this.set("occlusionStrength",e)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(e){return this.setRef("occlusionTexture",e,{channels:Qe})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(e){return this.set("roughnessFactor",e)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(e){return this.set("metallicFactor",e)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(e){return this.setRef("metallicRoughnessTexture",e,{channels:Ze|et})}}Oe.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class Is extends q{init(){this.propertyType=h.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new P})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}}class ys extends q{init(){this.propertyType=h.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new P})}copy(e,t=pe){if(t===pe)throw new Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return B.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){const t=this.get("translation").slice(),r=this.get("rotation").slice(),s=this.get("scale").slice();return B.decompose(e,t,r,s),this.set("translation",t).set("rotation",r).set("scale",s)}getWorldTranslation(){const e=[0,0,0];return B.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){const e=[0,0,0,1];return B.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){const e=[1,1,1];return B.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){const e=[];for(let s=this;s!=null;s=s.getParentNode())e.push(s);let t;const r=e.pop().getMatrix();for(;t=e.pop();)Gn(r,r,t.getMatrix());return r}addChild(e){const t=e.getParentNode();t&&t.removeChild(e);for(const r of e.listParents())r.propertyType===h.SCENE&&r.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(const e of this.listParents())if(e.propertyType===h.NODE)return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(const t of this.listChildren())t.traverse(e);return this}}class De extends q{init(){this.propertyType=h.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:De.Mode.TRIANGLES,material:null,indices:null,attributes:new ne,targets:new P})}getIndices(){return this.getRef("indices")}setIndices(e){return this.setRef("indices",e,{usage:J.ELEMENT_ARRAY_BUFFER})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:J.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}getMode(){return this.get("mode")}setMode(e){return this.set("mode",e)}listTargets(){return this.listRefs("targets")}addTarget(e){return this.addRef("targets",e)}removeTarget(e){return this.removeRef("targets",e)}}De.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Zn extends St{init(){this.propertyType=h.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new ne})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:J.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function K(){return K=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},K.apply(null,arguments)}class Ns extends q{init(){this.propertyType=h.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new P})}copy(e,t=pe){if(t===pe)throw new Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){const t=e.getParentNode();return t&&t.removeChild(e),this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(const t of this.listChildren())t.traverse(e);return this}}class As extends q{init(){this.propertyType=h.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new P})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:J.INVERSE_BIND_MATRICES})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}}class Ss extends q{init(){this.propertyType=h.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||ae.extensionToMimeType(Pe.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);const t=ae.extensionToMimeType(Pe.extension(e));return t&&this.set("mimeType",t),this}getImage(){return this.get("image")}setImage(e){return this.set("image",D.assertView(e))}getSize(){const e=this.get("image");return e?ae.getSize(e,this.getMimeType()):null}}class Ms extends q{init(){this.propertyType=h.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${ds}`,version:"2.0"},defaultScene:null,accessors:new P,animations:new P,buffers:new P,cameras:new P,materials:new P,meshes:new P,nodes:new P,scenes:new P,skins:new P,textures:new P})}constructor(e){super(e),this._extensions=new Set,e.addEventListener("node:create",t=>{this._addChildOfRoot(t.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(e,t=pe){if(t===pe)throw new Error("Root cannot be copied.");this.set("asset",K({},e.get("asset"))),this.setName(e.getName()),this.setExtras(K({},e.getExtras())),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(const r of e.listRefMapKeys("extensions")){const s=e.getExtension(r);this.setExtension(r,t(s))}return this}_addChildOfRoot(e){return e instanceof Ns?this.addRef("scenes",e):e instanceof ys?this.addRef("nodes",e):e instanceof ve?this.addRef("cameras",e):e instanceof As?this.addRef("skins",e):e instanceof Is?this.addRef("meshes",e):e instanceof Oe?this.addRef("materials",e):e instanceof Ss?this.addRef("textures",e):e instanceof Es?this.addRef("animations",e):e instanceof A?this.addRef("accessors",e):e instanceof Rs&&this.addRef("buffers",e),this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter(e=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class qe{static fromGraph(e){return qe._GRAPH_DOCUMENTS.get(e)||null}constructor(){this._graph=new Dn,this._root=new Ms(this._graph),this._logger=ee.DEFAULT_INSTANCE,qe._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(e){return this._logger=e,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(e){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...e){const t=e.map(r=>r.name);for(const r of e)await r(this,{stack:t});return this}createExtension(e){const t=e.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(s=>s.extensionName===t)||new e(this)}createScene(e=""){return new Ns(this._graph,e)}createNode(e=""){return new ys(this._graph,e)}createCamera(e=""){return new ve(this._graph,e)}createSkin(e=""){return new As(this._graph,e)}createMesh(e=""){return new Is(this._graph,e)}createPrimitive(){return new De(this._graph)}createPrimitiveTarget(e=""){return new Zn(this._graph,e)}createMaterial(e=""){return new Oe(this._graph,e)}createTexture(e=""){return new Ss(this._graph,e)}createAnimation(e=""){return new Es(this._graph,e)}createAnimationChannel(e=""){return new Mt(this._graph,e)}createAnimationSampler(e=""){return new Ve(this._graph,e)}createAccessor(e="",t=null){return t||(t=this.getRoot().listBuffers()[0]),new A(this._graph,e).setBuffer(t)}createBuffer(e=""){return new Rs(this._graph,e)}}qe._GRAPH_DOCUMENTS=new WeakMap;class U{constructor(e){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=e,e.getRoot()._enableExtension(this),this._listener=r=>{const s=r,n=s.target;n instanceof V&&n.extensionName===this.extensionName&&(s.type==="node:create"&&this._addExtensionProperty(n),s.type==="node:dispose"&&this._removeExtensionProperty(n))};const t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);const e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(const t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}}U.EXTENSION_NAME=void 0;class er{constructor(e){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=e}setTextureInfo(e,t){this.textureInfos.set(e,t),t.texCoord!==void 0&&e.setTexCoord(t.texCoord),t.extras!==void 0&&e.setExtras(t.extras);const r=this.jsonDoc.json.textures[t.index];if(r.sampler===void 0)return;const s=this.jsonDoc.json.samplers[r.sampler];s.magFilter!==void 0&&e.setMagFilter(s.magFilter),s.minFilter!==void 0&&e.setMinFilter(s.minFilter),s.wrapS!==void 0&&e.setWrapS(s.wrapS),s.wrapT!==void 0&&e.setWrapT(s.wrapT)}}const Jt={logger:ee.DEFAULT_INSTANCE,extensions:[],dependencies:{}},tr=new Set([h.BUFFER,h.TEXTURE,h.MATERIAL,h.MESH,h.PRIMITIVE,h.NODE,h.SCENE]);class sr{static read(e,t=Jt){const r=K({},Jt,t),{json:s}=e,n=new qe().setLogger(r.logger);this.validate(e,r);const o=new er(e),a=s.asset,c=n.getRoot().getAsset();a.copyright&&(c.copyright=a.copyright),a.extras&&(c.extras=a.extras),s.extras!==void 0&&n.getRoot().setExtras(K({},s.extras));const u=s.extensionsUsed||[],g=s.extensionsRequired||[];r.extensions.sort((f,d)=>f.EXTENSION_NAME>d.EXTENSION_NAME?1:-1);for(const f of r.extensions)if(u.includes(f.EXTENSION_NAME)){const d=n.createExtension(f).setRequired(g.includes(f.EXTENSION_NAME)),E=d.prereadTypes.filter(I=>!tr.has(I));E.length&&r.logger.warn(`Preread hooks for some types (${E.join()}), requested by extension ${d.extensionName}, are unsupported. Please file an issue or a PR.`);for(const I of d.readDependencies)d.install(I,r.dependencies[I])}const p=s.buffers||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.BUFFER)).forEach(f=>f.preread(o,h.BUFFER)),o.buffers=p.map(f=>{const d=n.createBuffer(f.name);return f.extras&&d.setExtras(f.extras),f.uri&&f.uri.indexOf("__")!==0&&d.setURI(f.uri),d});const m=s.bufferViews||[];o.bufferViewBuffers=m.map((f,d)=>{if(!o.bufferViews[d]){const E=e.json.buffers[f.buffer],I=E.uri?e.resources[E.uri]:e.resources[Ue],_=f.byteOffset||0;o.bufferViews[d]=D.toView(I,_,f.byteLength)}return o.buffers[f.buffer]});const N=s.accessors||[];o.accessors=N.map(f=>{const d=o.bufferViewBuffers[f.bufferView],E=n.createAccessor(f.name,d).setType(f.type);return f.extras&&E.setExtras(f.extras),f.normalized!==void 0&&E.setNormalized(f.normalized),f.bufferView===void 0||E.setArray(st(f,o)),E});const S=s.images||[],w=s.textures||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.TEXTURE)).forEach(f=>f.preread(o,h.TEXTURE)),o.textures=S.map(f=>{const d=n.createTexture(f.name);if(f.extras&&d.setExtras(f.extras),f.bufferView!==void 0){const E=s.bufferViews[f.bufferView],I=e.json.buffers[E.buffer],_=I.uri?e.resources[I.uri]:e.resources[Ue],O=E.byteOffset||0,C=E.byteLength,G=_.slice(O,O+C);d.setImage(G)}else f.uri!==void 0&&(d.setImage(e.resources[f.uri]),f.uri.indexOf("__")!==0&&d.setURI(f.uri));if(f.mimeType!==void 0)d.setMimeType(f.mimeType);else if(f.uri){const E=Pe.extension(f.uri);d.setMimeType(ae.extensionToMimeType(E))}return d}),n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.MATERIAL)).forEach(f=>f.preread(o,h.MATERIAL));const M=s.materials||[];o.materials=M.map(f=>{const d=n.createMaterial(f.name);f.extras&&d.setExtras(f.extras),f.alphaMode!==void 0&&d.setAlphaMode(f.alphaMode),f.alphaCutoff!==void 0&&d.setAlphaCutoff(f.alphaCutoff),f.doubleSided!==void 0&&d.setDoubleSided(f.doubleSided);const E=f.pbrMetallicRoughness||{};if(E.baseColorFactor!==void 0&&d.setBaseColorFactor(E.baseColorFactor),f.emissiveFactor!==void 0&&d.setEmissiveFactor(f.emissiveFactor),E.metallicFactor!==void 0&&d.setMetallicFactor(E.metallicFactor),E.roughnessFactor!==void 0&&d.setRoughnessFactor(E.roughnessFactor),E.baseColorTexture!==void 0){const I=E.baseColorTexture,_=o.textures[w[I.index].source];d.setBaseColorTexture(_),o.setTextureInfo(d.getBaseColorTextureInfo(),I)}if(f.emissiveTexture!==void 0){const I=f.emissiveTexture,_=o.textures[w[I.index].source];d.setEmissiveTexture(_),o.setTextureInfo(d.getEmissiveTextureInfo(),I)}if(f.normalTexture!==void 0){const I=f.normalTexture,_=o.textures[w[I.index].source];d.setNormalTexture(_),o.setTextureInfo(d.getNormalTextureInfo(),I),f.normalTexture.scale!==void 0&&d.setNormalScale(f.normalTexture.scale)}if(f.occlusionTexture!==void 0){const I=f.occlusionTexture,_=o.textures[w[I.index].source];d.setOcclusionTexture(_),o.setTextureInfo(d.getOcclusionTextureInfo(),I),f.occlusionTexture.strength!==void 0&&d.setOcclusionStrength(f.occlusionTexture.strength)}if(E.metallicRoughnessTexture!==void 0){const I=E.metallicRoughnessTexture,_=o.textures[w[I.index].source];d.setMetallicRoughnessTexture(_),o.setTextureInfo(d.getMetallicRoughnessTextureInfo(),I)}return d}),n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.MESH)).forEach(f=>f.preread(o,h.MESH));const l=s.meshes||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.PRIMITIVE)).forEach(f=>f.preread(o,h.PRIMITIVE)),o.meshes=l.map(f=>{const d=n.createMesh(f.name);return f.extras&&d.setExtras(f.extras),f.weights!==void 0&&d.setWeights(f.weights),(f.primitives||[]).forEach(I=>{const _=n.createPrimitive();I.extras&&_.setExtras(I.extras),I.material!==void 0&&_.setMaterial(o.materials[I.material]),I.mode!==void 0&&_.setMode(I.mode);for(const[G,v]of Object.entries(I.attributes||{}))_.setAttribute(G,o.accessors[v]);I.indices!==void 0&&_.setIndices(o.accessors[I.indices]);const O=f.extras&&f.extras.targetNames||[];(I.targets||[]).forEach((G,v)=>{const L=O[v]||v.toString(),z=n.createPrimitiveTarget(L);for(const[se,W]of Object.entries(G))z.setAttribute(se,o.accessors[W]);_.addTarget(z)}),d.addPrimitive(_)}),d});const b=s.cameras||[];o.cameras=b.map(f=>{const d=n.createCamera(f.name).setType(f.type);if(f.extras&&d.setExtras(f.extras),f.type===ve.Type.PERSPECTIVE){const E=f.perspective;d.setYFov(E.yfov),d.setZNear(E.znear),E.zfar!==void 0&&d.setZFar(E.zfar),E.aspectRatio!==void 0&&d.setAspectRatio(E.aspectRatio)}else{const E=f.orthographic;d.setZNear(E.znear).setZFar(E.zfar).setXMag(E.xmag).setYMag(E.ymag)}return d});const T=s.nodes||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.NODE)).forEach(f=>f.preread(o,h.NODE)),o.nodes=T.map(f=>{const d=n.createNode(f.name);if(f.extras&&d.setExtras(f.extras),f.translation!==void 0&&d.setTranslation(f.translation),f.rotation!==void 0&&d.setRotation(f.rotation),f.scale!==void 0&&d.setScale(f.scale),f.matrix!==void 0){const E=[0,0,0],I=[0,0,0,1],_=[1,1,1];B.decompose(f.matrix,E,I,_),d.setTranslation(E),d.setRotation(I),d.setScale(_)}return f.weights!==void 0&&d.setWeights(f.weights),d});const R=s.skins||[];o.skins=R.map(f=>{const d=n.createSkin(f.name);f.extras&&d.setExtras(f.extras),f.inverseBindMatrices!==void 0&&d.setInverseBindMatrices(o.accessors[f.inverseBindMatrices]),f.skeleton!==void 0&&d.setSkeleton(o.nodes[f.skeleton]);for(const E of f.joints)d.addJoint(o.nodes[E]);return d}),T.map((f,d)=>{const E=o.nodes[d];(f.children||[]).forEach(_=>E.addChild(o.nodes[_])),f.mesh!==void 0&&E.setMesh(o.meshes[f.mesh]),f.camera!==void 0&&E.setCamera(o.cameras[f.camera]),f.skin!==void 0&&E.setSkin(o.skins[f.skin])});const x=s.animations||[];o.animations=x.map(f=>{const d=n.createAnimation(f.name);f.extras&&d.setExtras(f.extras);const I=(f.samplers||[]).map(O=>{const C=n.createAnimationSampler().setInput(o.accessors[O.input]).setOutput(o.accessors[O.output]).setInterpolation(O.interpolation||Ve.Interpolation.LINEAR);return O.extras&&C.setExtras(O.extras),d.addSampler(C),C});return(f.channels||[]).forEach(O=>{const C=n.createAnimationChannel().setSampler(I[O.sampler]).setTargetPath(O.target.path);O.target.node!==void 0&&C.setTargetNode(o.nodes[O.target.node]),O.extras&&C.setExtras(O.extras),d.addChannel(C)}),d});const y=s.scenes||[];return n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.SCENE)).forEach(f=>f.preread(o,h.SCENE)),o.scenes=y.map(f=>{const d=n.createScene(f.name);return f.extras&&d.setExtras(f.extras),(f.nodes||[]).map(I=>o.nodes[I]).forEach(I=>d.addChild(I)),d}),s.scene!==void 0&&n.getRoot().setDefaultScene(o.scenes[s.scene]),n.getRoot().listExtensionsUsed().forEach(f=>f.read(o)),N.forEach((f,d)=>{const E=o.accessors[d],I=!!f.sparse,_=!f.bufferView&&!E.getArray();(I||_)&&E.setSparse(!0).setArray(rr(f,o))}),n}static validate(e,t){const r=e.json;if(r.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${r.asset.version}".`);if(r.extensionsRequired){for(const s of r.extensionsRequired)if(!t.extensions.find(n=>n.EXTENSION_NAME===s))throw new Error(`Missing required extension, "${s}".`)}if(r.extensionsUsed)for(const s of r.extensionsUsed)t.extensions.find(n=>n.EXTENSION_NAME===s)||t.logger.warn(`Missing optional extension, "${s}".`)}}function nr(i,e){const t=e.jsonDoc,r=e.bufferViews[i.bufferView],s=t.json.bufferViews[i.bufferView],n=at[i.componentType],o=A.getElementSize(i.type),a=n.BYTES_PER_ELEMENT,c=i.byteOffset||0,u=new n(i.count*o),g=new DataView(r.buffer,r.byteOffset,r.byteLength),p=s.byteStride;for(let m=0;m<i.count;m++)for(let N=0;N<o;N++){const S=c+m*p+N*a;let w;switch(i.componentType){case A.ComponentType.FLOAT:w=g.getFloat32(S,!0);break;case A.ComponentType.UNSIGNED_INT:w=g.getUint32(S,!0);break;case A.ComponentType.UNSIGNED_SHORT:w=g.getUint16(S,!0);break;case A.ComponentType.UNSIGNED_BYTE:w=g.getUint8(S);break;case A.ComponentType.SHORT:w=g.getInt16(S,!0);break;case A.ComponentType.BYTE:w=g.getInt8(S);break;default:throw new Error(`Unexpected componentType "${i.componentType}".`)}u[m*o+N]=w}return u}function st(i,e){const t=e.jsonDoc,r=e.bufferViews[i.bufferView],s=t.json.bufferViews[i.bufferView],n=at[i.componentType],o=A.getElementSize(i.type),a=n.BYTES_PER_ELEMENT,c=o*a;if(s.byteStride!==void 0&&s.byteStride!==c)return nr(i,e);const u=r.byteOffset+(i.byteOffset||0),g=i.count*o*a;return new n(r.buffer.slice(u,u+g))}function rr(i,e){const t=at[i.componentType],r=A.getElementSize(i.type);let s;i.bufferView!==void 0?s=st(i,e):s=new t(i.count*r);const n=i.sparse;if(!n)return s;const o=n.count,a=K({},i,n.indices,{count:o,type:"SCALAR"}),c=K({},i,n.values,{count:o}),u=st(a,e),g=st(c,e);for(let p=0;p<a.count;p++)for(let m=0;m<r;m++)s[u[p]*r+m]=g[p*r+m];return s}var Ye;(function(i){i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(Ye||(Ye={}));class ce{constructor(e,t,r){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=e,this.jsonDoc=t,this.options=r;const s=e.getRoot(),n=s.listBuffers().length,o=s.listTextures().length;this.bufferURIGenerator=new Qt(n>1,()=>r.basename||"buffer"),this.imageURIGenerator=new Qt(o>1,a=>ir(e,a)||r.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){const r={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},s=JSON.stringify(r);this.samplerDefIndexMap.has(s)||(this.samplerDefIndexMap.set(s,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(r));const n={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(s)},o=JSON.stringify(n);this.textureDefIndexMap.has(o)||(this.textureDefIndexMap.set(o,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(n));const a={index:this.textureDefIndexMap.get(o)};return t.getTexCoord()!==0&&(a.texCoord=t.getTexCoord()),Object.keys(t.getExtras()).length>0&&(a.extras=t.getExtras()),this.textureInfoDefMap.set(t,a),a}createPropertyDef(e){const t={};return e.getName()&&(t.name=e.getName()),Object.keys(e.getExtras()).length>0&&(t.extras=e.getExtras()),t}createAccessorDef(e){const t=this.createPropertyDef(e);return t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some(s=>s.getName()==="attributes"&&s.getAttributes().key==="POSITION"||s.getName()==="input")&&(t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround)),e.getNormalized()&&(t.normalized=e.getNormalized()),t}createImageData(e,t,r){if(this.options.format===ge.GLB)this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{const s=ae.mimeTypeToExtension(r.getMimeType());e.uri=this.imageURIGenerator.createURI(r,s),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,r){const s=this.jsonDoc.resources;if(!(e in s)){s[e]=t;return}if(t===s[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}const n=`Resource URI "${e}" already assigned to different data.`;if(!r){this.logger.warn(n);return}throw new Error(n)}getAccessorUsage(e){const t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return J.SPARSE;for(const r of this._doc.getGraph().listParentEdges(e)){const{usage:s}=r.getAttributes();if(s)return s;r.getParent().propertyType!==h.ROOT&&this.logger.warn(`Missing attribute ".usage" on edge, "${r.getName()}".`)}return J.OTHER}addAccessorToUsageGroup(e,t){const r=this._accessorUsageMap.get(e);if(r&&r!==t)throw new Error(`Accessor with usage "${r}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}}ce.BufferViewTarget=Ye;ce.BufferViewUsage=J;ce.USAGE_TO_TARGET={[J.ARRAY_BUFFER]:Ye.ARRAY_BUFFER,[J.ELEMENT_ARRAY_BUFFER]:Ye.ELEMENT_ARRAY_BUFFER};class Qt{constructor(e,t){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();if(this.multiple){const r=this.basename(e);return this.counter[r]=this.counter[r]||1,`${r}_${this.counter[r]++}.${t}`}else return`${this.basename(e)}.${t}`}}function ir(i,e){const t=i.getGraph().listParentEdges(e).find(r=>r.getParent()!==i.getRoot());return t?t.getName().replace(/texture$/i,""):""}const{BufferViewUsage:tt}=ce,{UNSIGNED_INT:or,UNSIGNED_SHORT:ar,UNSIGNED_BYTE:cr}=A.ComponentType,ur=new Set([h.ACCESSOR,h.BUFFER,h.MATERIAL,h.MESH]);class fr{static write(e,t){const r=e.getGraph(),s=e.getRoot(),n={asset:K({generator:`glTF-Transform ${ds}`},s.getAsset()),extras:K({},s.getExtras())},o={json:n,resources:{}},a=new ce(e,o,t),c=t.logger||ee.DEFAULT_INSTANCE,u=new Set(t.extensions.map(l=>l.EXTENSION_NAME)),g=e.getRoot().listExtensionsUsed().filter(l=>u.has(l.extensionName)).sort((l,b)=>l.extensionName>b.extensionName?1:-1),p=e.getRoot().listExtensionsRequired().filter(l=>u.has(l.extensionName)).sort((l,b)=>l.extensionName>b.extensionName?1:-1);g.length<e.getRoot().listExtensionsUsed().length&&c.warn("Some extensions were not registered for I/O, and will not be written.");for(const l of g){const b=l.prewriteTypes.filter(T=>!ur.has(T));b.length&&c.warn(`Prewrite hooks for some types (${b.join()}), requested by extension ${l.extensionName}, are unsupported. Please file an issue or a PR.`);for(const T of l.writeDependencies)l.install(T,t.dependencies[T])}function m(l,b,T,R){const x=[];let y=0;for(const E of l){const I=a.createAccessorDef(E);I.bufferView=n.bufferViews.length;const _=E.getArray(),O=D.pad(D.toView(_));I.byteOffset=y,y+=O.byteLength,x.push(O),a.accessorIndexMap.set(E,n.accessors.length),n.accessors.push(I)}const f=D.concat(x),d={buffer:b,byteOffset:T,byteLength:f.byteLength};return R&&(d.target=R),n.bufferViews.push(d),{buffers:x,byteLength:y}}function N(l,b,T){const R=l[0].getCount();let x=0;for(const I of l){const _=a.createAccessorDef(I);_.bufferView=n.bufferViews.length,_.byteOffset=x;const O=I.getElementSize(),C=I.getComponentSize();x+=D.padNumber(O*C),a.accessorIndexMap.set(I,n.accessors.length),n.accessors.push(_)}const y=R*x,f=new ArrayBuffer(y),d=new DataView(f);for(let I=0;I<R;I++){let _=0;for(const O of l){const C=O.getElementSize(),G=O.getComponentSize(),v=O.getComponentType(),L=O.getArray();for(let z=0;z<C;z++){const se=I*x+_+z*G,W=L[I*C+z];switch(v){case A.ComponentType.FLOAT:d.setFloat32(se,W,!0);break;case A.ComponentType.BYTE:d.setInt8(se,W);break;case A.ComponentType.SHORT:d.setInt16(se,W,!0);break;case A.ComponentType.UNSIGNED_BYTE:d.setUint8(se,W);break;case A.ComponentType.UNSIGNED_SHORT:d.setUint16(se,W,!0);break;case A.ComponentType.UNSIGNED_INT:d.setUint32(se,W,!0);break;default:throw new Error("Unexpected component type: "+v)}}_+=D.padNumber(C*G)}}const E={buffer:b,byteOffset:T,byteLength:y,byteStride:x,target:ce.BufferViewTarget.ARRAY_BUFFER};return n.bufferViews.push(E),{byteLength:y,buffers:[new Uint8Array(f)]}}function S(l,b,T){const R=[];let x=0;const y=new Map;let f=-1/0,d=!1;for(const v of l){const L=a.createAccessorDef(v);n.accessors.push(L),a.accessorIndexMap.set(v,n.accessors.length-1);const z=[],se=[],W=[],Sn=new Array(v.getElementSize()).fill(0);for(let ke=0,wn=v.getCount();ke<wn;ke++)if(v.getElement(ke,W),!B.eq(W,Sn,0)){f=Math.max(ke,f),z.push(ke);for(let lt=0;lt<W.length;lt++)se.push(W[lt])}const ut=z.length,ft={accessorDef:L,count:ut};if(y.set(v,ft),ut===0)continue;ut>v.getCount()/2&&(d=!0);const Mn=at[v.getComponentType()];ft.indices=z,ft.values=new Mn(se)}if(!Number.isFinite(f))return{buffers:R,byteLength:x};d&&c.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");const E=f<255?Uint8Array:f<65535?Uint16Array:Uint32Array,I=f<255?cr:f<65535?ar:or,_={buffer:b,byteOffset:T+x,byteLength:0};for(const v of l){const L=y.get(v);if(L.count===0)continue;L.indicesByteOffset=_.byteLength;const z=D.pad(D.toView(new E(L.indices)));R.push(z),x+=z.byteLength,_.byteLength+=z.byteLength}n.bufferViews.push(_);const O=n.bufferViews.length-1,C={buffer:b,byteOffset:T+x,byteLength:0};for(const v of l){const L=y.get(v);if(L.count===0)continue;L.valuesByteOffset=C.byteLength;const z=D.pad(D.toView(L.values));R.push(z),x+=z.byteLength,C.byteLength+=z.byteLength}n.bufferViews.push(C);const G=n.bufferViews.length-1;for(const v of l){const L=y.get(v);L.count!==0&&(L.accessorDef.sparse={count:L.count,indices:{bufferView:O,byteOffset:L.indicesByteOffset,componentType:I},values:{bufferView:G,byteOffset:L.valuesByteOffset}})}return{buffers:R,byteLength:x}}if(n.accessors=[],n.bufferViews=[],n.samplers=[],n.textures=[],n.images=s.listTextures().map((l,b)=>{const T=a.createPropertyDef(l);l.getMimeType()&&(T.mimeType=l.getMimeType());const R=l.getImage();return R&&a.createImageData(T,R,l),a.imageIndexMap.set(l,b),T}),g.filter(l=>l.prewriteTypes.includes(h.ACCESSOR)).forEach(l=>l.prewrite(a,h.ACCESSOR)),s.listAccessors().forEach(l=>{const b=a.accessorUsageGroupedByParent,T=a.accessorParents;if(a.accessorIndexMap.has(l))return;const R=a.getAccessorUsage(l);if(a.addAccessorToUsageGroup(l,R),b.has(R)){const x=r.listParents(l).find(y=>y.propertyType!==h.ROOT);T.set(l,x)}}),g.filter(l=>l.prewriteTypes.includes(h.BUFFER)).forEach(l=>l.prewrite(a,h.BUFFER)),(s.listAccessors().length>0||a.otherBufferViews.size>0||s.listTextures().length>0&&t.format===ge.GLB)&&s.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");n.buffers=[],s.listBuffers().forEach((l,b)=>{const T=a.createPropertyDef(l),R=a.accessorUsageGroupedByParent,x=l.listParents().filter(C=>C instanceof A),y=new Set(x.map(C=>a.accessorParents.get(C))),f=new Map(Array.from(y).map((C,G)=>[C,G])),d={};for(const C of x){var E;if(a.accessorIndexMap.has(C))continue;const G=a.getAccessorUsage(C);let v=G;if(R.has(G)){const L=a.accessorParents.get(C);v+=`:${f.get(L)}`}d[E=v]||(d[E]={usage:G,accessors:[]}),d[v].accessors.push(C)}const I=[],_=n.buffers.length;let O=0;for(const{usage:C,accessors:G}of Object.values(d))if(C===tt.ARRAY_BUFFER&&t.vertexLayout===nt.INTERLEAVED){const v=N(G,_,O);O+=v.byteLength,I.push(...v.buffers)}else if(C===tt.ARRAY_BUFFER)for(const v of G){const L=N([v],_,O);O+=L.byteLength,I.push(...L.buffers)}else if(C===tt.SPARSE){const v=S(G,_,O);O+=v.byteLength,I.push(...v.buffers)}else if(C===tt.ELEMENT_ARRAY_BUFFER){const v=ce.BufferViewTarget.ELEMENT_ARRAY_BUFFER,L=m(G,_,O,v);O+=L.byteLength,I.push(...L.buffers)}else{const v=m(G,_,O);O+=v.byteLength,I.push(...v.buffers)}if(a.imageBufferViews.length&&b===0){for(let C=0;C<a.imageBufferViews.length;C++)if(n.bufferViews[n.images[C].bufferView].byteOffset=O,O+=a.imageBufferViews[C].byteLength,I.push(a.imageBufferViews[C]),O%8){const G=8-O%8;O+=G,I.push(new Uint8Array(G))}}if(a.otherBufferViews.has(l))for(const C of a.otherBufferViews.get(l))n.bufferViews.push({buffer:_,byteOffset:O,byteLength:C.byteLength}),a.otherBufferViewsIndexMap.set(C,n.bufferViews.length-1),O+=C.byteLength,I.push(C);if(O){let C;t.format===ge.GLB?C=Ue:(C=a.bufferURIGenerator.createURI(l,"bin"),T.uri=C),T.byteLength=O,a.assignResourceURI(C,D.concat(I),!0)}n.buffers.push(T),a.bufferIndexMap.set(l,b)}),s.listAccessors().find(l=>!l.getBuffer())&&c.warn("Skipped writing one or more Accessors: no Buffer assigned."),g.filter(l=>l.prewriteTypes.includes(h.MATERIAL)).forEach(l=>l.prewrite(a,h.MATERIAL)),n.materials=s.listMaterials().map((l,b)=>{const T=a.createPropertyDef(l);if(l.getAlphaMode()!==Oe.AlphaMode.OPAQUE&&(T.alphaMode=l.getAlphaMode()),l.getAlphaMode()===Oe.AlphaMode.MASK&&(T.alphaCutoff=l.getAlphaCutoff()),l.getDoubleSided()&&(T.doubleSided=!0),T.pbrMetallicRoughness={},B.eq(l.getBaseColorFactor(),[1,1,1,1])||(T.pbrMetallicRoughness.baseColorFactor=l.getBaseColorFactor()),B.eq(l.getEmissiveFactor(),[0,0,0])||(T.emissiveFactor=l.getEmissiveFactor()),l.getRoughnessFactor()!==1&&(T.pbrMetallicRoughness.roughnessFactor=l.getRoughnessFactor()),l.getMetallicFactor()!==1&&(T.pbrMetallicRoughness.metallicFactor=l.getMetallicFactor()),l.getBaseColorTexture()){const R=l.getBaseColorTexture(),x=l.getBaseColorTextureInfo();T.pbrMetallicRoughness.baseColorTexture=a.createTextureInfoDef(R,x)}if(l.getEmissiveTexture()){const R=l.getEmissiveTexture(),x=l.getEmissiveTextureInfo();T.emissiveTexture=a.createTextureInfoDef(R,x)}if(l.getNormalTexture()){const R=l.getNormalTexture(),x=l.getNormalTextureInfo(),y=a.createTextureInfoDef(R,x);l.getNormalScale()!==1&&(y.scale=l.getNormalScale()),T.normalTexture=y}if(l.getOcclusionTexture()){const R=l.getOcclusionTexture(),x=l.getOcclusionTextureInfo(),y=a.createTextureInfoDef(R,x);l.getOcclusionStrength()!==1&&(y.strength=l.getOcclusionStrength()),T.occlusionTexture=y}if(l.getMetallicRoughnessTexture()){const R=l.getMetallicRoughnessTexture(),x=l.getMetallicRoughnessTextureInfo();T.pbrMetallicRoughness.metallicRoughnessTexture=a.createTextureInfoDef(R,x)}return a.materialIndexMap.set(l,b),T}),g.filter(l=>l.prewriteTypes.includes(h.MESH)).forEach(l=>l.prewrite(a,h.MESH)),n.meshes=s.listMeshes().map((l,b)=>{const T=a.createPropertyDef(l);let R=null;return T.primitives=l.listPrimitives().map(x=>{const y={attributes:{}};y.mode=x.getMode();const f=x.getMaterial();f&&(y.material=a.materialIndexMap.get(f)),Object.keys(x.getExtras()).length&&(y.extras=x.getExtras());const d=x.getIndices();d&&(y.indices=a.accessorIndexMap.get(d));for(const E of x.listSemantics())y.attributes[E]=a.accessorIndexMap.get(x.getAttribute(E));for(const E of x.listTargets()){const I={};for(const _ of E.listSemantics())I[_]=a.accessorIndexMap.get(E.getAttribute(_));y.targets=y.targets||[],y.targets.push(I)}return x.listTargets().length&&!R&&(R=x.listTargets().map(E=>E.getName())),y}),l.getWeights().length&&(T.weights=l.getWeights()),R&&(T.extras=T.extras||{},T.extras.targetNames=R),a.meshIndexMap.set(l,b),T}),n.cameras=s.listCameras().map((l,b)=>{const T=a.createPropertyDef(l);if(T.type=l.getType(),T.type===ve.Type.PERSPECTIVE){T.perspective={znear:l.getZNear(),zfar:l.getZFar(),yfov:l.getYFov()};const R=l.getAspectRatio();R!==null&&(T.perspective.aspectRatio=R)}else T.orthographic={znear:l.getZNear(),zfar:l.getZFar(),xmag:l.getXMag(),ymag:l.getYMag()};return a.cameraIndexMap.set(l,b),T}),n.nodes=s.listNodes().map((l,b)=>{const T=a.createPropertyDef(l);return B.eq(l.getTranslation(),[0,0,0])||(T.translation=l.getTranslation()),B.eq(l.getRotation(),[0,0,0,1])||(T.rotation=l.getRotation()),B.eq(l.getScale(),[1,1,1])||(T.scale=l.getScale()),l.getWeights().length&&(T.weights=l.getWeights()),a.nodeIndexMap.set(l,b),T}),n.skins=s.listSkins().map((l,b)=>{const T=a.createPropertyDef(l),R=l.getInverseBindMatrices();R&&(T.inverseBindMatrices=a.accessorIndexMap.get(R));const x=l.getSkeleton();return x&&(T.skeleton=a.nodeIndexMap.get(x)),T.joints=l.listJoints().map(y=>a.nodeIndexMap.get(y)),a.skinIndexMap.set(l,b),T}),s.listNodes().forEach((l,b)=>{const T=n.nodes[b],R=l.getMesh();R&&(T.mesh=a.meshIndexMap.get(R));const x=l.getCamera();x&&(T.camera=a.cameraIndexMap.get(x));const y=l.getSkin();y&&(T.skin=a.skinIndexMap.get(y)),l.listChildren().length>0&&(T.children=l.listChildren().map(f=>a.nodeIndexMap.get(f)))}),n.animations=s.listAnimations().map((l,b)=>{const T=a.createPropertyDef(l),R=new Map;return T.samplers=l.listSamplers().map((x,y)=>{const f=a.createPropertyDef(x);return f.input=a.accessorIndexMap.get(x.getInput()),f.output=a.accessorIndexMap.get(x.getOutput()),f.interpolation=x.getInterpolation(),R.set(x,y),f}),T.channels=l.listChannels().map(x=>{const y=a.createPropertyDef(x);return y.sampler=R.get(x.getSampler()),y.target={node:a.nodeIndexMap.get(x.getTargetNode()),path:x.getTargetPath()},y}),a.animationIndexMap.set(l,b),T}),n.scenes=s.listScenes().map((l,b)=>{const T=a.createPropertyDef(l);return T.nodes=l.listChildren().map(R=>a.nodeIndexMap.get(R)),a.sceneIndexMap.set(l,b),T});const M=s.getDefaultScene();return M&&(n.scene=s.listScenes().indexOf(M)),n.extensionsUsed=g.map(l=>l.extensionName),n.extensionsRequired=p.map(l=>l.extensionName),g.forEach(l=>l.write(a)),lr(n),o}}function lr(i){const e=[];for(const t in i){const r=i[t];(Array.isArray(r)&&r.length===0||r===null||r===""||r&&typeof r=="object"&&Object.keys(r).length===0)&&e.push(t)}for(const t of e)delete i[t]}var it;(function(i){i[i.JSON=1313821514]="JSON",i[i.BIN=5130562]="BIN"})(it||(it={}));class hr{constructor(){this._logger=ee.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=nt.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(e){return this._logger=e,this}registerExtensions(e){for(const t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){const t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;const r=Zt(t)?this._binaryToJSON(t):{json:JSON.parse(D.decodeText(t)),resources:{}};return await this._readResourcesExternal(r,this.dirname(e)),this._readResourcesInternal(r),r}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),sr.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){const t=this._binaryToJSON(D.assertView(e));this._readResourcesInternal(t);const r=t.json;if(r.buffers&&r.buffers.some(s=>gr(t,s)))throw new Error("Cannot resolve external buffers with binaryToJSON().");if(r.images&&r.images.some(s=>pr(t,s)))throw new Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(D.assertView(e)))}async writeJSON(e,t={}){if(t.format===ge.GLB&&e.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return fr.write(e,{format:t.format||ge.GLTF,basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:K({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(e){const{json:t,resources:r}=await this.writeJSON(e,{format:ge.GLB}),s=new Uint32Array([1179937895,2,12]),n=JSON.stringify(t),o=D.pad(D.encodeText(n),32),a=D.toView(new Uint32Array([o.byteLength,1313821514])),c=D.concat([a,o]);s[s.length-1]+=c.byteLength;const u=Object.values(r)[0];if(!u||!u.byteLength)return D.concat([D.toView(s),c]);const g=D.pad(u,0),p=D.toView(new Uint32Array([g.byteLength,5130562])),m=D.concat([p,g]);return s[s.length-1]+=m.byteLength,D.concat([D.toView(s),c,m])}async _readResourcesExternal(e,t){var r=this;const s=e.json.images||[],n=e.json.buffers||[],o=[...s,...n].map(async function(a){const c=a.uri;if(!c||c.match(/data:/))return Promise.resolve();e.resources[c]=await r.readURI(r.resolve(t,c),"view"),r.lastReadBytes+=e.resources[c].byteLength});await Promise.all(o)}_readResourcesInternal(e){function t(n){if(n.uri){if(n.uri in e.resources){D.assertView(e.resources[n.uri]);return}if(n.uri.match(/data:/)){const o=`__${Yn()}.${Pe.extension(n.uri)}`;e.resources[o]=D.createBufferFromDataURI(n.uri),n.uri=o}}}(e.json.images||[]).forEach(n=>{if(n.bufferView===void 0&&n.uri===void 0)throw new Error("Missing resource URI or buffer view.");t(n)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){const{images:t,buffers:r}=e.json;return e={json:K({},e.json),resources:K({},e.resources)},t&&(e.json.images=t.map(s=>K({},s))),r&&(e.json.buffers=r.map(s=>K({},s))),e}_binaryToJSON(e){if(!Zt(e))throw new Error("Invalid glTF 2.0 binary.");const t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==it.JSON)throw new Error("Missing required GLB JSON chunk.");const r=20,s=t[0],n=D.decodeText(D.toView(e,r,s)),o=JSON.parse(n),a=r+s;if(e.byteLength<=a)return{json:o,resources:{}};const c=new Uint32Array(e.buffer,e.byteOffset+a,2);if(c[1]!==it.BIN)return{json:o,resources:{}};const u=c[0],g=D.toView(e,a+8,u);return{json:o,resources:{[Ue]:g}}}}function gr(i,e){return e.uri!==void 0&&!(e.uri in i.resources)}function pr(i,e){return e.uri!==void 0&&!(e.uri in i.resources)&&e.bufferView===void 0}function Zt(i){if(i.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;const e=new Uint32Array(i.buffer,i.byteOffset,3);return e[0]===1179937895&&e[1]===2}class dr extends hr{constructor(e=Ke.DEFAULT_INIT){super(),this._fetchConfig=void 0,this._fetchConfig=e}async readURI(e,t){const r=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await r.arrayBuffer());case"text":return r.text()}}resolve(e,t){return Ke.resolve(e,t)}dirname(e){return Ke.dirname(e)}}const le="GALACEAN_materials_remap";class ws extends V{constructor(){super(...arguments);Y(this,"parentTypes",[h.MATERIAL]);Y(this,"propertyType");Y(this,"extensionName",le)}init(){this.extensionName=le,this.propertyType="GlTFRemapping",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{refId:""})}getRefId(){return this.get("refId")}setRefId(t){return this.set("refId",t)}}Y(ws,"EXTENSION_NAME",le);class bs extends U{constructor(){super(...arguments);Y(this,"extensionName","GALACEAN_materials_remap")}createGlTFRemapping(){return new ws(this.document.getGraph())}read(t){return(t.jsonDoc.json.materials||[]).forEach((n,o)=>{if(n.extensions&&n.extensions[le]){const a=this.createGlTFRemapping();t.materials[o].setExtension(le,a);const c=n.extensions[le];c.refId!==void 0&&a.setRefId(c.refId)}}),this}write(t){const r=t.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(le);if(n){const o=t.materialIndexMap.get(s),a=r.json.materials[o];a.extensions=a.extensions||{},a.extensions[le]={refId:n.getRefId()}}}),this}}Y(bs,"EXTENSION_NAME","GALACEAN_materials_remap");const oe="GALACEAN_animation_event";class _s extends V{constructor(){super(...arguments);Y(this,"parentTypes",[h.ANIMATION]);Y(this,"propertyType");Y(this,"extensionName",oe)}init(){this.extensionName=oe,this.propertyType="GlTFAnimationEvent"}getDefaults(){return Object.assign(super.getDefaults(),{events:{}})}getEvents(){return this.get("events")}setEvents(t){return this.set("events",t)}}Y(_s,"EXTENSION_NAME",oe);class Cs extends U{constructor(){super(...arguments);Y(this,"extensionName",oe);Y(this,"eventProperty")}createAnimationEvent(){return this.eventProperty=new _s(this.document.getGraph()),this.eventProperty}read(t){return(t.jsonDoc.json.animations||[]).forEach((n,o)=>{if(n.extensions&&n.extensions[oe]){const a=this.createAnimationEvent();t.animations[o].setExtension(oe,a);const u=n.extensions[oe].events;u&&a.setEvents(u)}}),this}write(t){const r=t.jsonDoc;return this.document.getRoot().listAnimations().forEach(s=>{const n=s.getExtension(oe);if(n){const o=t.animationIndexMap.get(s),a=r.json.animations[o];a.extensions=a.extensions||{},a.extensions[oe]={events:n.getEvents()}}}),this}}Y(Cs,"EXTENSION_NAME",oe);const wt="EXT_mesh_gpu_instancing",Et="EXT_meshopt_compression",Tr="EXT_texture_webp",mr="EXT_texture_avif",Os="KHR_draco_mesh_compression",bt="KHR_lights_punctual",_t="KHR_materials_anisotropy",Ct="KHR_materials_clearcoat",Ot="KHR_materials_diffuse_transmission",Dt="KHR_materials_dispersion",vt="KHR_materials_emissive_strength",Ft="KHR_materials_ior",Lt="KHR_materials_iridescence",Bt="KHR_materials_pbrSpecularGlossiness",jt="KHR_materials_sheen",Ut="KHR_materials_specular",Pt="KHR_materials_transmission",Gt="KHR_materials_unlit",Vt="KHR_materials_volume",Fe="KHR_materials_variants",xr="KHR_mesh_quantization",Er="KHR_texture_basisu",kt="KHR_texture_transform",ot="KHR_xmp_json_ld",Rt="INSTANCE_ATTRIBUTE";class Ds extends V{init(){this.extensionName=wt,this.propertyType="InstancedMesh",this.parentTypes=[h.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new ne})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:Rt})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}Ds.EXTENSION_NAME=wt;const de=wt;class vs extends U{constructor(...e){super(...e),this.extensionName=de,this.provideTypes=[h.NODE],this.prewriteTypes=[h.ACCESSOR]}createInstancedMesh(){return new Ds(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((s,n)=>{if(!s.extensions||!s.extensions[de])return;const o=s.extensions[de],a=this.createInstancedMesh();for(const c in o.attributes)a.setAttribute(c,e.accessors[o.attributes[c]]);e.nodes[n].setExtension(de,a)}),this}prewrite(e){e.accessorUsageGroupedByParent.add(Rt);for(const t of this.properties)for(const r of t.listAttributes())e.addAccessorToUsageGroup(r,Rt);return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listNodes().forEach(r=>{const s=r.getExtension(de);if(s){const n=e.nodeIndexMap.get(r),o=t.json.nodes[n],a={attributes:{}};s.listSemantics().forEach(c=>{const u=s.getAttribute(c);a.attributes[c]=e.accessorIndexMap.get(u)}),o.extensions=o.extensions||{},o.extensions[de]=a}}),this}}vs.EXTENSION_NAME=de;function fe(){return fe=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},fe.apply(null,arguments)}var We;(function(i){i.QUANTIZE="quantize",i.FILTER="filter"})(We||(We={}));var je;(function(i){i.ATTRIBUTES="ATTRIBUTES",i.TRIANGLES="TRIANGLES",i.INDICES="INDICES"})(je||(je={}));var k;(function(i){i.NONE="NONE",i.OCTAHEDRAL="OCTAHEDRAL",i.QUATERNION="QUATERNION",i.EXPONENTIAL="EXPONENTIAL"})(k||(k={}));const{BYTE:Rr,SHORT:es,FLOAT:Ir}=A.ComponentType,{encodeNormalizedInt:ts,decodeNormalizedInt:It}=B;function yr(i,e,t,r){const{filter:s,bits:n}=r,o={array:i.getArray(),byteStride:i.getElementSize()*i.getComponentSize(),componentType:i.getComponentType(),normalized:i.getNormalized()};if(t!==je.ATTRIBUTES)return o;if(s!==k.NONE){let a=i.getNormalized()?Nr(i):new Float32Array(o.array);switch(s){case k.EXPONENTIAL:o.byteStride=i.getElementSize()*4,o.componentType=Ir,o.normalized=!1,o.array=e.encodeFilterExp(a,i.getCount(),o.byteStride,n);break;case k.OCTAHEDRAL:o.byteStride=n>8?8:4,o.componentType=n>8?es:Rr,o.normalized=!0,a=i.getElementSize()===3?Sr(a):a,o.array=e.encodeFilterOct(a,i.getCount(),o.byteStride,n);break;case k.QUATERNION:o.byteStride=8,o.componentType=es,o.normalized=!0,o.array=e.encodeFilterQuat(a,i.getCount(),o.byteStride,n);break;default:throw new Error("Invalid filter.")}o.min=i.getMin([]),o.max=i.getMax([]),i.getNormalized()&&(o.min=o.min.map(c=>It(c,i.getComponentType())),o.max=o.max.map(c=>It(c,i.getComponentType()))),o.normalized&&(o.min=o.min.map(c=>ts(c,o.componentType)),o.max=o.max.map(c=>ts(c,o.componentType)))}else o.byteStride%4&&(o.array=Ar(o.array,i.getElementSize()),o.byteStride=o.array.byteLength/i.getCount());return o}function Nr(i){const e=i.getComponentType(),t=i.getArray(),r=new Float32Array(t.length);for(let s=0;s<t.length;s++)r[s]=It(t[s],e);return r}function Ar(i,e){const r=D.padNumber(i.BYTES_PER_ELEMENT*e)/i.BYTES_PER_ELEMENT,s=i.length/e,n=new i.constructor(s*r);for(let o=0;o*e<i.length;o++)for(let a=0;a<e;a++)n[o*r+a]=i[o*e+a];return n}function Sr(i){const e=new Float32Array(i.length*4/3);for(let t=0,r=i.length/3;t<r;t++)e[t*4]=i[t*3],e[t*4+1]=i[t*3+1],e[t*4+2]=i[t*3+2];return e}function Mr(i,e){return e===ce.BufferViewUsage.ELEMENT_ARRAY_BUFFER?i.listParents().some(r=>r instanceof De&&r.getMode()===De.Mode.TRIANGLES)?je.TRIANGLES:je.INDICES:je.ATTRIBUTES}function wr(i,e){const t=e.getGraph().listParentEdges(i).filter(r=>!(r.getParent()instanceof Ms));for(const r of t){const s=r.getName(),n=r.getAttributes().key||"",o=r.getParent().propertyType===h.PRIMITIVE_TARGET;if(s==="indices")return{filter:k.NONE};if(s==="attributes"){if(n==="POSITION")return{filter:k.NONE};if(n==="TEXCOORD_0")return{filter:k.NONE};if(n.startsWith("JOINTS_"))return{filter:k.NONE};if(n.startsWith("WEIGHTS_"))return{filter:k.NONE};if(n==="NORMAL"||n==="TANGENT")return o?{filter:k.NONE}:{filter:k.OCTAHEDRAL,bits:8}}if(s==="output"){const a=Fs(i);return a==="rotation"?{filter:k.QUATERNION,bits:16}:a==="translation"?{filter:k.EXPONENTIAL,bits:12}:a==="scale"?{filter:k.EXPONENTIAL,bits:12}:{filter:k.NONE}}if(s==="input")return{filter:k.NONE};if(s==="inverseBindMatrices")return{filter:k.NONE}}return{filter:k.NONE}}function Fs(i){for(const e of i.listParents())if(e instanceof Ve){for(const t of e.listParents())if(t instanceof Mt)return t.getTargetPath()}return null}function br(i){return!i.extensions||!i.extensions[Et]?!1:!!i.extensions[Et].fallback}const X=Et,ss={method:We.QUANTIZE};class Ht extends U{constructor(...e){super(...e),this.extensionName=X,this.prereadTypes=[h.BUFFER,h.PRIMITIVE],this.prewriteTypes=[h.BUFFER,h.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=ss,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(e,t){return e==="meshopt.decoder"&&(this._decoder=t),e==="meshopt.encoder"&&(this._encoder=t),this}setEncoderOptions(e){return this._encoderOptions=fe({},ss,e),this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${X}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${X}]: Missing WASM support.`)}return t===h.BUFFER?this._prereadBuffers(e):t===h.PRIMITIVE&&this._prereadPrimitives(e),this}_prereadBuffers(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach((s,n)=>{if(!s.extensions||!s.extensions[X])return;const o=s.extensions[X],a=o.byteOffset||0,c=o.byteLength||0,u=o.count,g=o.byteStride,p=new Uint8Array(u*g),m=t.json.buffers[o.buffer],N=m.uri?t.resources[m.uri]:t.resources[Ue],S=D.toView(N,a,c);this._decoder.decodeGltfBuffer(p,u,g,S,o.mode,o.filter),e.bufferViews[n]=p})}_prereadPrimitives(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach(s=>{if(!s.extensions||!s.extensions[X])return;const n=s.extensions[X],o=e.buffers[n.buffer],a=e.buffers[s.buffer],c=t.json.buffers[s.buffer];br(c)&&this._decoderFallbackBufferMap.set(a,o)})}read(e){if(!this.isRequired())return this;for(const[t,r]of this._decoderFallbackBufferMap){for(const s of t.listParents())s instanceof A&&s.swap(t,r);t.dispose()}return this}prewrite(e,t){return t===h.ACCESSOR?this._prewriteAccessors(e):t===h.BUFFER&&this._prewriteBuffers(e),this}_prewriteAccessors(e){const t=e.jsonDoc.json,r=this._encoder,s=this._encoderOptions,n=this.document.getGraph(),o=this.document.createBuffer(),a=this.document.getRoot().listBuffers().indexOf(o);let c=1;const u=new Map,g=p=>{for(const m of n.listParents(p)){if(m.propertyType===h.ROOT)continue;let N=u.get(p);return N===void 0&&u.set(p,N=c++),N}return-1};this._encoderFallbackBuffer=o,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(const p of this.document.getRoot().listAccessors()){if(Fs(p)==="weights"||p.getSparse())continue;const m=e.getAccessorUsage(p),N=e.accessorUsageGroupedByParent.has(m)?g(p):null,S=Mr(p,m),w=s.method===We.FILTER?wr(p,this.document):{filter:k.NONE},M=yr(p,r,S,w),{array:l,byteStride:b}=M,T=p.getBuffer();if(!T)throw new Error(`${X}: Missing buffer for accessor.`);const R=this.document.getRoot().listBuffers().indexOf(T),x=[m,N,S,w.filter,b,R].join(":");let y=this._encoderBufferViews[x],f=this._encoderBufferViewData[x],d=this._encoderBufferViewAccessors[x];(!y||!f)&&(d=this._encoderBufferViewAccessors[x]=[],f=this._encoderBufferViewData[x]=[],y=this._encoderBufferViews[x]={buffer:a,target:ce.USAGE_TO_TARGET[m],byteOffset:0,byteLength:0,byteStride:m===ce.BufferViewUsage.ARRAY_BUFFER?b:void 0,extensions:{[X]:{buffer:R,byteOffset:0,byteLength:0,mode:S,filter:w.filter!==k.NONE?w.filter:void 0,byteStride:b,count:0}}});const E=e.createAccessorDef(p);E.componentType=M.componentType,E.normalized=M.normalized,E.byteOffset=y.byteLength,E.min&&M.min&&(E.min=M.min),E.max&&M.max&&(E.max=M.max),e.accessorIndexMap.set(p,t.accessors.length),t.accessors.push(E),d.push(E),f.push(new Uint8Array(l.buffer,l.byteOffset,l.byteLength)),y.byteLength+=l.byteLength,y.extensions.EXT_meshopt_compression.count+=p.getCount()}}_prewriteBuffers(e){const t=this._encoder;for(const r in this._encoderBufferViews){const s=this._encoderBufferViews[r],n=this._encoderBufferViewData[r],o=this.document.getRoot().listBuffers()[s.extensions[X].buffer],a=e.otherBufferViews.get(o)||[],{count:c,byteStride:u,mode:g}=s.extensions[X],p=D.concat(n),m=t.encodeGltfBuffer(p,c,u,g),N=D.pad(m);s.extensions[X].byteLength=m.byteLength,n.length=0,n.push(N),a.push(N),e.otherBufferViews.set(o,a)}}write(e){let t=0;for(const o in this._encoderBufferViews){const a=this._encoderBufferViews[o],c=this._encoderBufferViewData[o][0],u=e.otherBufferViewsIndexMap.get(c),g=this._encoderBufferViewAccessors[o];for(const S of g)S.bufferView=u;const p=e.jsonDoc.json.bufferViews[u],m=p.byteOffset||0;Object.assign(p,a),p.byteOffset=t;const N=p.extensions[X];N.byteOffset=m,t+=D.padNumber(a.byteLength)}const r=this._encoderFallbackBuffer,s=e.bufferIndexMap.get(r),n=e.jsonDoc.json.buffers[s];return n.byteLength=t,n.extensions={[X]:{fallback:!0}},r.dispose(),this}}Ht.EXTENSION_NAME=X;Ht.EncoderMethod=We;const He=mr;class _r{match(e){return e.length>=12&&D.decodeText(e.slice(4,12))==="ftypavif"}getSize(e){if(!this.match(e))return null;const t=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=ns(t,0);if(!r)return null;let s=r.end;for(;r=ns(t,s);)if(r.type==="meta")s=r.start+4;else if(r.type==="iprp"||r.type==="ipco")s=r.start;else{if(r.type==="ispe")return[t.getUint32(r.start+4),t.getUint32(r.start+8)];if(r.type==="mdat")break;s=r.end}return null}getChannels(e){return 4}}class Ls extends U{constructor(...e){super(...e),this.extensionName=He,this.prereadTypes=[h.TEXTURE]}static register(){ae.registerFormat("image/avif",new _r)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(r=>{r.extensions&&r.extensions[He]&&(r.source=r.extensions[He].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(r=>{if(r.getMimeType()==="image/avif"){const s=e.imageIndexMap.get(r);(t.json.textures||[]).forEach(o=>{o.source===s&&(o.extensions=o.extensions||{},o.extensions[He]={source:o.source},delete o.source)})}}),this}}Ls.EXTENSION_NAME=He;function ns(i,e){if(i.byteLength<4+e)return null;const t=i.getUint32(e);return i.byteLength<t+e||t<8?null:{type:D.decodeText(new Uint8Array(i.buffer,i.byteOffset+e+4,4)),start:e+8,end:e+t}}const ze=Tr;class Cr{match(e){return e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}getSize(e){const t=D.decodeText(e.slice(0,4)),r=D.decodeText(e.slice(8,12));if(t!=="RIFF"||r!=="WEBP")return null;const s=new DataView(e.buffer,e.byteOffset);let n=12;for(;n<s.byteLength;){const o=D.decodeText(new Uint8Array([s.getUint8(n),s.getUint8(n+1),s.getUint8(n+2),s.getUint8(n+3)])),a=s.getUint32(n+4,!0);if(o==="VP8 "){const c=s.getInt16(n+14,!0)&16383,u=s.getInt16(n+16,!0)&16383;return[c,u]}else if(o==="VP8L"){const c=s.getUint8(n+9),u=s.getUint8(n+10),g=s.getUint8(n+11),p=s.getUint8(n+12),m=1+((u&63)<<8|c),N=1+((p&15)<<10|g<<2|(u&192)>>6);return[m,N]}n+=8+a+a%2}return null}getChannels(e){return 4}}class Bs extends U{constructor(...e){super(...e),this.extensionName=ze,this.prereadTypes=[h.TEXTURE]}static register(){ae.registerFormat("image/webp",new Cr)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(r=>{r.extensions&&r.extensions[ze]&&(r.source=r.extensions[ze].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(r=>{if(r.getMimeType()==="image/webp"){const s=e.imageIndexMap.get(r);(t.json.textures||[]).forEach(o=>{o.source===s&&(o.extensions=o.extensions||{},o.extensions[ze]={source:o.source},delete o.source)})}}),this}}Bs.EXTENSION_NAME=ze;const rs=Os;let $,js,Us;function Or(i,e){const t=new $.DecoderBuffer;try{if(t.Init(e,e.length),i.GetEncodedGeometryType(t)!==$.TRIANGULAR_MESH)throw new Error(`[${rs}] Unknown geometry type.`);const s=new $.Mesh;if(!i.DecodeBufferToMesh(t,s).ok()||s.ptr===0)throw new Error(`[${rs}] Decoding failure.`);return s}finally{$.destroy(t)}}function Dr(i,e){const r=e.num_faces()*3;let s,n;if(e.num_points()<=65534){const o=r*Uint16Array.BYTES_PER_ELEMENT;s=$._malloc(o),i.GetTrianglesUInt16Array(e,o,s),n=new Uint16Array($.HEAPU16.buffer,s,r).slice()}else{const o=r*Uint32Array.BYTES_PER_ELEMENT;s=$._malloc(o),i.GetTrianglesUInt32Array(e,o,s),n=new Uint32Array($.HEAPU32.buffer,s,r).slice()}return $._free(s),n}function vr(i,e,t,r){const s=Us[r.componentType],n=js[r.componentType],o=t.num_components(),c=e.num_points()*o,u=c*n.BYTES_PER_ELEMENT,g=$._malloc(u);i.GetAttributeDataArrayForAllPoints(e,t,s,u,g);const p=new n($.HEAPF32.buffer,g,c).slice();return $._free(g),p}function Fr(i){$=i,js={[A.ComponentType.FLOAT]:Float32Array,[A.ComponentType.UNSIGNED_INT]:Uint32Array,[A.ComponentType.UNSIGNED_SHORT]:Uint16Array,[A.ComponentType.UNSIGNED_BYTE]:Uint8Array,[A.ComponentType.SHORT]:Int16Array,[A.ComponentType.BYTE]:Int8Array},Us={[A.ComponentType.FLOAT]:$.DT_FLOAT32,[A.ComponentType.UNSIGNED_INT]:$.DT_UINT32,[A.ComponentType.UNSIGNED_SHORT]:$.DT_UINT16,[A.ComponentType.UNSIGNED_BYTE]:$.DT_UINT8,[A.ComponentType.SHORT]:$.DT_INT16,[A.ComponentType.BYTE]:$.DT_INT8}}let Q;var Je;(function(i){i[i.EDGEBREAKER=1]="EDGEBREAKER",i[i.SEQUENTIAL=0]="SEQUENTIAL"})(Je||(Je={}));var Z;(function(i){i.POSITION="POSITION",i.NORMAL="NORMAL",i.COLOR="COLOR",i.TEX_COORD="TEX_COORD",i.GENERIC="GENERIC"})(Z||(Z={}));const Ps={[Z.POSITION]:14,[Z.NORMAL]:10,[Z.COLOR]:8,[Z.TEX_COORD]:12,[Z.GENERIC]:12},is={decodeSpeed:5,encodeSpeed:5,method:Je.EDGEBREAKER,quantizationBits:Ps,quantizationVolume:"mesh"};function Lr(i){Q=i}function Br(i,e=is){const t=fe({},is,e);t.quantizationBits=fe({},Ps,e.quantizationBits);const r=new Q.MeshBuilder,s=new Q.Mesh,n=new Q.ExpertEncoder(s),o={},a=new Q.DracoInt8Array,c=i.listTargets().length>0;let u=!1;for(const w of i.listSemantics()){const M=i.getAttribute(w);if(M.getSparse()){u=!0;continue}const l=jr(w),b=Ur(r,M.getComponentType(),s,Q[l],M.getCount(),M.getElementSize(),M.getArray());if(b===-1)throw new Error(`Error compressing "${w}" attribute.`);if(o[w]=b,t.quantizationVolume==="mesh"||w!=="POSITION")n.SetAttributeQuantization(b,t.quantizationBits[l]);else if(typeof t.quantizationVolume=="object"){const{quantizationVolume:T}=t,R=Math.max(T.max[0]-T.min[0],T.max[1]-T.min[1],T.max[2]-T.min[2]);n.SetAttributeExplicitQuantization(b,t.quantizationBits[l],M.getElementSize(),T.min,R)}else throw new Error("Invalid quantization volume state.")}const g=i.getIndices();if(!g)throw new yt("Primitive must have indices.");r.AddFacesToMesh(s,g.getCount()/3,g.getArray()),n.SetSpeedOptions(t.encodeSpeed,t.decodeSpeed),n.SetTrackEncodedProperties(!0),t.method===Je.SEQUENTIAL||c||u?n.SetEncodingMethod(Q.MESH_SEQUENTIAL_ENCODING):n.SetEncodingMethod(Q.MESH_EDGEBREAKER_ENCODING);const p=n.EncodeToDracoBuffer(!(c||u),a);if(p<=0)throw new yt("Error applying Draco compression.");const m=new Uint8Array(p);for(let w=0;w<p;++w)m[w]=a.GetValue(w);const N=n.GetNumberOfEncodedPoints(),S=n.GetNumberOfEncodedFaces()*3;return Q.destroy(a),Q.destroy(s),Q.destroy(r),Q.destroy(n),{numVertices:N,numIndices:S,data:m,attributeIDs:o}}function jr(i){return i==="POSITION"?Z.POSITION:i==="NORMAL"?Z.NORMAL:i.startsWith("COLOR_")?Z.COLOR:i.startsWith("TEXCOORD_")?Z.TEX_COORD:Z.GENERIC}function Ur(i,e,t,r,s,n,o){switch(e){case A.ComponentType.UNSIGNED_BYTE:return i.AddUInt8Attribute(t,r,s,n,o);case A.ComponentType.BYTE:return i.AddInt8Attribute(t,r,s,n,o);case A.ComponentType.UNSIGNED_SHORT:return i.AddUInt16Attribute(t,r,s,n,o);case A.ComponentType.SHORT:return i.AddInt16Attribute(t,r,s,n,o);case A.ComponentType.UNSIGNED_INT:return i.AddUInt32Attribute(t,r,s,n,o);case A.ComponentType.FLOAT:return i.AddFloatAttribute(t,r,s,n,o);default:throw new Error(`Unexpected component type, "${e}".`)}}class yt extends Error{}const H=Os;class zt extends U{constructor(...e){super(...e),this.extensionName=H,this.prereadTypes=[h.PRIMITIVE],this.prewriteTypes=[h.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(e,t){return e==="draco3d.decoder"&&(this._decoderModule=t,Fr(this._decoderModule)),e==="draco3d.encoder"&&(this._encoderModule=t,Lr(this._encoderModule)),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error(`[${H}] Please install extension dependency, "draco3d.decoder".`);const t=this.document.getLogger(),r=e.jsonDoc,s=new Map;try{const n=r.json.meshes||[];for(const o of n)for(const a of o.primitives){if(!a.extensions||!a.extensions[H])continue;const c=a.extensions[H];let[u,g]=s.get(c.bufferView)||[];if(!g||!u){const p=r.json.bufferViews[c.bufferView],m=r.json.buffers[p.buffer],N=m.uri?r.resources[m.uri]:r.resources[Ue],S=p.byteOffset||0,w=p.byteLength,M=D.toView(N,S,w);u=new this._decoderModule.Decoder,g=Or(u,M),s.set(c.bufferView,[u,g]),t.debug(`[${H}] Decompressed ${M.byteLength} bytes.`)}for(const p in a.attributes){const m=e.jsonDoc.json.accessors[a.attributes[p]],N=u.GetAttributeByUniqueId(g,c.attributes[p]),S=vr(u,g,N,m);e.accessors[a.attributes[p]].setArray(S)}a.indices!==void 0&&e.accessors[a.indices].setArray(Dr(u,g))}}finally{for(const[n,o]of Array.from(s.values()))this._decoderModule.destroy(n),this._decoderModule.destroy(o)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw new Error(`[${H}] Please install extension dependency, "draco3d.encoder".`);const r=this.document.getLogger();r.debug(`[${H}] Compression options: ${JSON.stringify(this._encoderOptions)}`);const s=Pr(this.document),n=new Map;let o="mesh";this._encoderOptions.quantizationVolume==="scene"&&(this.document.getRoot().listScenes().length!==1?r.warn(`[${H}]: quantizationVolume=scene requires exactly 1 scene.`):o=Ln(this.document.getRoot().listScenes().pop()));for(const a of Array.from(s.keys())){const c=s.get(a);if(!c)throw new Error("Unexpected primitive.");if(n.has(c)){n.set(c,n.get(c));continue}const u=a.getIndices(),g=e.jsonDoc.json.accessors;let p;try{p=Br(a,fe({},this._encoderOptions,{quantizationVolume:o}))}catch(S){if(S instanceof yt){r.warn(`[${H}]: ${S.message} Skipping primitive compression.`);continue}throw S}n.set(c,p);const m=e.createAccessorDef(u);m.count=p.numIndices,e.accessorIndexMap.set(u,g.length),g.push(m),p.numVertices>65534&&m.componentType!==A.ComponentType.UNSIGNED_INT&&(m.componentType=A.ComponentType.UNSIGNED_INT);for(const S of a.listSemantics()){const w=a.getAttribute(S);if(p.attributeIDs[S]===void 0)continue;const M=e.createAccessorDef(w);M.count=p.numVertices,e.accessorIndexMap.set(w,g.length),g.push(M)}const N=a.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];e.otherBufferViews.has(N)||e.otherBufferViews.set(N,[]),e.otherBufferViews.get(N).push(p.data)}return r.debug(`[${H}] Compressed ${s.size} primitives.`),e.extensionData[H]={primitiveHashMap:s,primitiveEncodingMap:n},this}write(e){const t=e.extensionData[H];for(const r of this.document.getRoot().listMeshes()){const s=e.jsonDoc.json.meshes[e.meshIndexMap.get(r)];for(let n=0;n<r.listPrimitives().length;n++){const o=r.listPrimitives()[n],a=s.primitives[n],c=t.primitiveHashMap.get(o);if(!c)continue;const u=t.primitiveEncodingMap.get(c);u&&(a.extensions=a.extensions||{},a.extensions[H]={bufferView:e.otherBufferViewsIndexMap.get(u.data),attributes:u.attributeIDs})}}if(!t.primitiveHashMap.size){const r=e.jsonDoc.json;r.extensionsUsed=(r.extensionsUsed||[]).filter(s=>s!==H),r.extensionsRequired=(r.extensionsRequired||[]).filter(s=>s!==H)}return this}}zt.EXTENSION_NAME=H;zt.EncoderMethod=Je;function Pr(i){const e=i.getLogger(),t=new Set,r=new Set;let s=0,n=0;for(const p of i.getRoot().listMeshes())for(const m of p.listPrimitives())m.getIndices()?m.getMode()!==De.Mode.TRIANGLES?(r.add(m),n++):t.add(m):(r.add(m),s++);s>0&&e.warn(`[${H}] Skipping Draco compression of ${s} non-indexed primitives.`),n>0&&e.warn(`[${H}] Skipping Draco compression of ${n} non-TRIANGLES primitives.`);const o=i.getRoot().listAccessors(),a=new Map;for(let p=0;p<o.length;p++)a.set(o[p],p);const c=new Map,u=new Set,g=new Map;for(const p of Array.from(t)){let m=os(p,a);if(u.has(m)){g.set(p,m);continue}if(c.has(p.getIndices())){const N=p.getIndices(),S=N.clone();a.set(S,i.getRoot().listAccessors().length-1),p.swap(N,S)}for(const N of p.listAttributes())if(c.has(N)){const S=N.clone();a.set(S,i.getRoot().listAccessors().length-1),p.swap(N,S)}m=os(p,a),u.add(m),g.set(p,m),c.set(p.getIndices(),m);for(const N of p.listAttributes())c.set(N,m)}for(const p of Array.from(c.keys())){const m=new Set(p.listParents().map(N=>N.propertyType));if(m.size!==2||!m.has(h.PRIMITIVE)||!m.has(h.ROOT))throw new Error(`[${H}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const p of Array.from(t)){const m=g.get(p),N=p.getIndices();if(c.get(N)!==m||p.listAttributes().some(S=>c.get(S)!==m))throw new Error(`[${H}] Draco primitives must share all, or no, accessors.`)}for(const p of Array.from(r)){const m=p.getIndices();if(c.has(m)||p.listAttributes().some(N=>c.has(N)))throw new Error(`[${H}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return g}function os(i,e){const t=[],r=i.getIndices();t.push(e.get(r));for(const s of i.listAttributes())t.push(e.get(s));return t.sort().join("|")}class Ge extends V{init(){this.extensionName=bt,this.propertyType="Light",this.parentTypes=[h.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:Ge.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(e){return this.set("color",e)}getIntensity(){return this.get("intensity")}setIntensity(e){return this.set("intensity",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getRange(){return this.get("range")}setRange(e){return this.set("range",e)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(e){return this.set("innerConeAngle",e)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(e){return this.set("outerConeAngle",e)}}Ge.EXTENSION_NAME=bt;Ge.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};const re=bt;class Gs extends U{constructor(...e){super(...e),this.extensionName=re}createLight(e=""){return new Ge(this.document.getGraph(),e)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[re])return this;const n=(t.json.extensions[re].lights||[]).map(o=>{var a,c;const u=this.createLight().setName(o.name||"").setType(o.type);return o.color!==void 0&&u.setColor(o.color),o.intensity!==void 0&&u.setIntensity(o.intensity),o.range!==void 0&&u.setRange(o.range),((a=o.spot)==null?void 0:a.innerConeAngle)!==void 0&&u.setInnerConeAngle(o.spot.innerConeAngle),((c=o.spot)==null?void 0:c.outerConeAngle)!==void 0&&u.setOuterConeAngle(o.spot.outerConeAngle),u});return t.json.nodes.forEach((o,a)=>{if(!o.extensions||!o.extensions[re])return;const c=o.extensions[re];e.nodes[a].setExtension(re,n[c.light])}),this}write(e){const t=e.jsonDoc;if(this.properties.size===0)return this;const r=[],s=new Map;for(const n of this.properties){const o=n,a={type:o.getType()};B.eq(o.getColor(),[1,1,1])||(a.color=o.getColor()),o.getIntensity()!==1&&(a.intensity=o.getIntensity()),o.getRange()!=null&&(a.range=o.getRange()),o.getName()&&(a.name=o.getName()),o.getType()===Ge.Type.SPOT&&(a.spot={innerConeAngle:o.getInnerConeAngle(),outerConeAngle:o.getOuterConeAngle()}),r.push(a),s.set(o,r.length-1)}return this.document.getRoot().listNodes().forEach(n=>{const o=n.getExtension(re);if(o){const a=e.nodeIndexMap.get(n),c=t.json.nodes[a];c.extensions=c.extensions||{},c.extensions[re]={light:s.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[re]={lights:r},this}}Gs.EXTENSION_NAME=re;const{R:Gr,G:Vr,B:kr}=te;class Vs extends V{init(){this.extensionName=_t,this.propertyType="Anisotropy",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new j(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:Gr|Vr|kr})}}Vs.EXTENSION_NAME=_t;const Te=_t;class ks extends U{constructor(...e){super(...e),this.extensionName=Te,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createAnisotropy(){return new Vs(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Te]){const a=this.createAnisotropy();e.materials[o].setExtension(Te,a);const c=n.extensions[Te];if(c.anisotropyStrength!==void 0&&a.setAnisotropyStrength(c.anisotropyStrength),c.anisotropyRotation!==void 0&&a.setAnisotropyRotation(c.anisotropyRotation),c.anisotropyTexture!==void 0){const u=c.anisotropyTexture,g=e.textures[s[u.index].source];a.setAnisotropyTexture(g),e.setTextureInfo(a.getAnisotropyTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Te);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Te]={};if(s.getAnisotropyStrength()>0&&(a.anisotropyStrength=s.getAnisotropyStrength()),s.getAnisotropyRotation()!==0&&(a.anisotropyRotation=s.getAnisotropyRotation()),s.getAnisotropyTexture()){const c=s.getAnisotropyTexture(),u=s.getAnisotropyTextureInfo();a.anisotropyTexture=e.createTextureInfoDef(c,u)}}}),this}}ks.EXTENSION_NAME=Te;const{R:as,G:cs,B:Hr}=te;class Hs extends V{init(){this.extensionName=Ct,this.propertyType="Clearcoat",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new j(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new j(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new j(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:as})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:cs})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:as|cs|Hr})}}Hs.EXTENSION_NAME=Ct;const me=Ct;class zs extends U{constructor(...e){super(...e),this.extensionName=me,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createClearcoat(){return new Hs(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[me]){const a=this.createClearcoat();e.materials[o].setExtension(me,a);const c=n.extensions[me];if(c.clearcoatFactor!==void 0&&a.setClearcoatFactor(c.clearcoatFactor),c.clearcoatRoughnessFactor!==void 0&&a.setClearcoatRoughnessFactor(c.clearcoatRoughnessFactor),c.clearcoatTexture!==void 0){const u=c.clearcoatTexture,g=e.textures[s[u.index].source];a.setClearcoatTexture(g),e.setTextureInfo(a.getClearcoatTextureInfo(),u)}if(c.clearcoatRoughnessTexture!==void 0){const u=c.clearcoatRoughnessTexture,g=e.textures[s[u.index].source];a.setClearcoatRoughnessTexture(g),e.setTextureInfo(a.getClearcoatRoughnessTextureInfo(),u)}if(c.clearcoatNormalTexture!==void 0){const u=c.clearcoatNormalTexture,g=e.textures[s[u.index].source];a.setClearcoatNormalTexture(g),e.setTextureInfo(a.getClearcoatNormalTextureInfo(),u),u.scale!==void 0&&a.setClearcoatNormalScale(u.scale)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(me);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[me]={clearcoatFactor:s.getClearcoatFactor(),clearcoatRoughnessFactor:s.getClearcoatRoughnessFactor()};if(s.getClearcoatTexture()){const c=s.getClearcoatTexture(),u=s.getClearcoatTextureInfo();a.clearcoatTexture=e.createTextureInfoDef(c,u)}if(s.getClearcoatRoughnessTexture()){const c=s.getClearcoatRoughnessTexture(),u=s.getClearcoatRoughnessTextureInfo();a.clearcoatRoughnessTexture=e.createTextureInfoDef(c,u)}if(s.getClearcoatNormalTexture()){const c=s.getClearcoatNormalTexture(),u=s.getClearcoatNormalTextureInfo();a.clearcoatNormalTexture=e.createTextureInfoDef(c,u),s.getClearcoatNormalScale()!==1&&(a.clearcoatNormalTexture.scale=s.getClearcoatNormalScale())}}}),this}}zs.EXTENSION_NAME=me;const{R:zr,G:$r,B:Xr,A:Kr}=te;class $s extends V{init(){this.extensionName=Ot,this.propertyType="DiffuseTransmission",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new j(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new j(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(e){return this.set("diffuseTransmissionFactor",e)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(e){return this.setRef("diffuseTransmissionTexture",e,{channels:Kr})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(e){return this.set("diffuseTransmissionColorFactor",e)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(e){return this.setRef("diffuseTransmissionColorTexture",e,{channels:zr|$r|Xr})}}$s.EXTENSION_NAME=Ot;const xe=Ot;class Xs extends U{constructor(...e){super(...e),this.extensionName=xe}createDiffuseTransmission(){return new $s(this.document.getGraph())}read(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[xe]){const a=this.createDiffuseTransmission();e.materials[o].setExtension(xe,a);const c=n.extensions[xe];if(c.diffuseTransmissionFactor!==void 0&&a.setDiffuseTransmissionFactor(c.diffuseTransmissionFactor),c.diffuseTransmissionColorFactor!==void 0&&a.setDiffuseTransmissionColorFactor(c.diffuseTransmissionColorFactor),c.diffuseTransmissionTexture!==void 0){const u=c.diffuseTransmissionTexture,g=e.textures[s[u.index].source];a.setDiffuseTransmissionTexture(g),e.setTextureInfo(a.getDiffuseTransmissionTextureInfo(),u)}if(c.diffuseTransmissionColorTexture!==void 0){const u=c.diffuseTransmissionColorTexture,g=e.textures[s[u.index].source];a.setDiffuseTransmissionColorTexture(g),e.setTextureInfo(a.getDiffuseTransmissionColorTextureInfo(),u)}}}),this}write(e){const t=e.jsonDoc;for(const r of this.document.getRoot().listMaterials()){const s=r.getExtension(xe);if(!s)continue;const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[xe]={diffuseTransmissionFactor:s.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:s.getDiffuseTransmissionColorFactor()};if(s.getDiffuseTransmissionTexture()){const c=s.getDiffuseTransmissionTexture(),u=s.getDiffuseTransmissionTextureInfo();a.diffuseTransmissionTexture=e.createTextureInfoDef(c,u)}if(s.getDiffuseTransmissionColorTexture()){const c=s.getDiffuseTransmissionColorTexture(),u=s.getDiffuseTransmissionColorTextureInfo();a.diffuseTransmissionColorTexture=e.createTextureInfoDef(c,u)}}return this}}Xs.EXTENSION_NAME=xe;class Ks extends V{init(){this.extensionName=Dt,this.propertyType="Dispersion",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(e){return this.set("dispersion",e)}}Ks.EXTENSION_NAME=Dt;const Ee=Dt;class qs extends U{constructor(...e){super(...e),this.extensionName=Ee,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createDispersion(){return new Ks(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((s,n)=>{if(s.extensions&&s.extensions[Ee]){const o=this.createDispersion();e.materials[n].setExtension(Ee,o);const a=s.extensions[Ee];a.dispersion!==void 0&&o.setDispersion(a.dispersion)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Ee);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Ee]={dispersion:s.getDispersion()}}}),this}}qs.EXTENSION_NAME=Ee;class Ys extends V{init(){this.extensionName=vt,this.propertyType="EmissiveStrength",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}}Ys.EXTENSION_NAME=vt;const Re=vt;class Ws extends U{constructor(...e){super(...e),this.extensionName=Re,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createEmissiveStrength(){return new Ys(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((s,n)=>{if(s.extensions&&s.extensions[Re]){const o=this.createEmissiveStrength();e.materials[n].setExtension(Re,o);const a=s.extensions[Re];a.emissiveStrength!==void 0&&o.setEmissiveStrength(a.emissiveStrength)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Re);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Re]={emissiveStrength:s.getEmissiveStrength()}}}),this}}Ws.EXTENSION_NAME=Re;class Js extends V{init(){this.extensionName=Ft,this.propertyType="IOR",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}}Js.EXTENSION_NAME=Ft;const Ie=Ft;class Qs extends U{constructor(...e){super(...e),this.extensionName=Ie,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createIOR(){return new Js(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((s,n)=>{if(s.extensions&&s.extensions[Ie]){const o=this.createIOR();e.materials[n].setExtension(Ie,o);const a=s.extensions[Ie];a.ior!==void 0&&o.setIOR(a.ior)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Ie);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Ie]={ior:s.getIOR()}}}),this}}Qs.EXTENSION_NAME=Ie;const{R:qr,G:Yr}=te;class Zs extends V{init(){this.extensionName=Lt,this.propertyType="Iridescence",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new j(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new j(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:qr})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:Yr})}}Zs.EXTENSION_NAME=Lt;const ye=Lt;class en extends U{constructor(...e){super(...e),this.extensionName=ye,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createIridescence(){return new Zs(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[ye]){const a=this.createIridescence();e.materials[o].setExtension(ye,a);const c=n.extensions[ye];if(c.iridescenceFactor!==void 0&&a.setIridescenceFactor(c.iridescenceFactor),c.iridescenceIor!==void 0&&a.setIridescenceIOR(c.iridescenceIor),c.iridescenceThicknessMinimum!==void 0&&a.setIridescenceThicknessMinimum(c.iridescenceThicknessMinimum),c.iridescenceThicknessMaximum!==void 0&&a.setIridescenceThicknessMaximum(c.iridescenceThicknessMaximum),c.iridescenceTexture!==void 0){const u=c.iridescenceTexture,g=e.textures[s[u.index].source];a.setIridescenceTexture(g),e.setTextureInfo(a.getIridescenceTextureInfo(),u)}if(c.iridescenceThicknessTexture!==void 0){const u=c.iridescenceThicknessTexture,g=e.textures[s[u.index].source];a.setIridescenceThicknessTexture(g),e.setTextureInfo(a.getIridescenceThicknessTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(ye);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[ye]={};if(s.getIridescenceFactor()>0&&(a.iridescenceFactor=s.getIridescenceFactor()),s.getIridescenceIOR()!==1.3&&(a.iridescenceIor=s.getIridescenceIOR()),s.getIridescenceThicknessMinimum()!==100&&(a.iridescenceThicknessMinimum=s.getIridescenceThicknessMinimum()),s.getIridescenceThicknessMaximum()!==400&&(a.iridescenceThicknessMaximum=s.getIridescenceThicknessMaximum()),s.getIridescenceTexture()){const c=s.getIridescenceTexture(),u=s.getIridescenceTextureInfo();a.iridescenceTexture=e.createTextureInfoDef(c,u)}if(s.getIridescenceThicknessTexture()){const c=s.getIridescenceThicknessTexture(),u=s.getIridescenceThicknessTextureInfo();a.iridescenceThicknessTexture=e.createTextureInfoDef(c,u)}}}),this}}en.EXTENSION_NAME=ye;const{R:us,G:fs,B:ls,A:hs}=te;class tn extends V{init(){this.extensionName=Bt,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new j(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new j(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:us|fs|ls|hs,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:us|fs|ls|hs})}}tn.EXTENSION_NAME=Bt;const Ne=Bt;class sn extends U{constructor(...e){super(...e),this.extensionName=Ne,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createPBRSpecularGlossiness(){return new tn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Ne]){const a=this.createPBRSpecularGlossiness();e.materials[o].setExtension(Ne,a);const c=n.extensions[Ne];if(c.diffuseFactor!==void 0&&a.setDiffuseFactor(c.diffuseFactor),c.specularFactor!==void 0&&a.setSpecularFactor(c.specularFactor),c.glossinessFactor!==void 0&&a.setGlossinessFactor(c.glossinessFactor),c.diffuseTexture!==void 0){const u=c.diffuseTexture,g=e.textures[s[u.index].source];a.setDiffuseTexture(g),e.setTextureInfo(a.getDiffuseTextureInfo(),u)}if(c.specularGlossinessTexture!==void 0){const u=c.specularGlossinessTexture,g=e.textures[s[u.index].source];a.setSpecularGlossinessTexture(g),e.setTextureInfo(a.getSpecularGlossinessTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Ne);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Ne]={diffuseFactor:s.getDiffuseFactor(),specularFactor:s.getSpecularFactor(),glossinessFactor:s.getGlossinessFactor()};if(s.getDiffuseTexture()){const c=s.getDiffuseTexture(),u=s.getDiffuseTextureInfo();a.diffuseTexture=e.createTextureInfoDef(c,u)}if(s.getSpecularGlossinessTexture()){const c=s.getSpecularGlossinessTexture(),u=s.getSpecularGlossinessTextureInfo();a.specularGlossinessTexture=e.createTextureInfoDef(c,u)}}}),this}}sn.EXTENSION_NAME=Ne;const{R:Wr,G:Jr,B:Qr,A:Zr}=te;class nn extends V{init(){this.extensionName=jt,this.propertyType="Sheen",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new j(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new j(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:Wr|Jr|Qr,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:Zr})}}nn.EXTENSION_NAME=jt;const Ae=jt;class rn extends U{constructor(...e){super(...e),this.extensionName=Ae,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createSheen(){return new nn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Ae]){const a=this.createSheen();e.materials[o].setExtension(Ae,a);const c=n.extensions[Ae];if(c.sheenColorFactor!==void 0&&a.setSheenColorFactor(c.sheenColorFactor),c.sheenRoughnessFactor!==void 0&&a.setSheenRoughnessFactor(c.sheenRoughnessFactor),c.sheenColorTexture!==void 0){const u=c.sheenColorTexture,g=e.textures[s[u.index].source];a.setSheenColorTexture(g),e.setTextureInfo(a.getSheenColorTextureInfo(),u)}if(c.sheenRoughnessTexture!==void 0){const u=c.sheenRoughnessTexture,g=e.textures[s[u.index].source];a.setSheenRoughnessTexture(g),e.setTextureInfo(a.getSheenRoughnessTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Ae);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Ae]={sheenColorFactor:s.getSheenColorFactor(),sheenRoughnessFactor:s.getSheenRoughnessFactor()};if(s.getSheenColorTexture()){const c=s.getSheenColorTexture(),u=s.getSheenColorTextureInfo();a.sheenColorTexture=e.createTextureInfoDef(c,u)}if(s.getSheenRoughnessTexture()){const c=s.getSheenRoughnessTexture(),u=s.getSheenRoughnessTextureInfo();a.sheenRoughnessTexture=e.createTextureInfoDef(c,u)}}}),this}}rn.EXTENSION_NAME=Ae;const{R:ei,G:ti,B:si,A:ni}=te;class on extends V{init(){this.extensionName=Ut,this.propertyType="Specular",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new j(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new j(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:ni})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:ei|ti|si,isColor:!0})}}on.EXTENSION_NAME=Ut;const Se=Ut;class an extends U{constructor(...e){super(...e),this.extensionName=Se,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createSpecular(){return new on(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Se]){const a=this.createSpecular();e.materials[o].setExtension(Se,a);const c=n.extensions[Se];if(c.specularFactor!==void 0&&a.setSpecularFactor(c.specularFactor),c.specularColorFactor!==void 0&&a.setSpecularColorFactor(c.specularColorFactor),c.specularTexture!==void 0){const u=c.specularTexture,g=e.textures[s[u.index].source];a.setSpecularTexture(g),e.setTextureInfo(a.getSpecularTextureInfo(),u)}if(c.specularColorTexture!==void 0){const u=c.specularColorTexture,g=e.textures[s[u.index].source];a.setSpecularColorTexture(g),e.setTextureInfo(a.getSpecularColorTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Se);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Se]={};if(s.getSpecularFactor()!==1&&(a.specularFactor=s.getSpecularFactor()),B.eq(s.getSpecularColorFactor(),[1,1,1])||(a.specularColorFactor=s.getSpecularColorFactor()),s.getSpecularTexture()){const c=s.getSpecularTexture(),u=s.getSpecularTextureInfo();a.specularTexture=e.createTextureInfoDef(c,u)}if(s.getSpecularColorTexture()){const c=s.getSpecularColorTexture(),u=s.getSpecularColorTextureInfo();a.specularColorTexture=e.createTextureInfoDef(c,u)}}}),this}}an.EXTENSION_NAME=Se;const{R:ri}=te;class cn extends V{init(){this.extensionName=Pt,this.propertyType="Transmission",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new j(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:ri})}}cn.EXTENSION_NAME=Pt;const Me=Pt;class un extends U{constructor(...e){super(...e),this.extensionName=Me,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createTransmission(){return new cn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Me]){const a=this.createTransmission();e.materials[o].setExtension(Me,a);const c=n.extensions[Me];if(c.transmissionFactor!==void 0&&a.setTransmissionFactor(c.transmissionFactor),c.transmissionTexture!==void 0){const u=c.transmissionTexture,g=e.textures[s[u.index].source];a.setTransmissionTexture(g),e.setTextureInfo(a.getTransmissionTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Me);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Me]={transmissionFactor:s.getTransmissionFactor()};if(s.getTransmissionTexture()){const c=s.getTransmissionTexture(),u=s.getTransmissionTextureInfo();a.transmissionTexture=e.createTextureInfoDef(c,u)}}}),this}}un.EXTENSION_NAME=Me;class fn extends V{init(){this.extensionName=Gt,this.propertyType="Unlit",this.parentTypes=[h.MATERIAL]}}fn.EXTENSION_NAME=Gt;const Le=Gt;class ln extends U{constructor(...e){super(...e),this.extensionName=Le,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createUnlit(){return new fn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((r,s)=>{r.extensions&&r.extensions[Le]&&e.materials[s].setExtension(Le,this.createUnlit())}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{if(r.getExtension(Le)){const s=e.materialIndexMap.get(r),n=t.json.materials[s];n.extensions=n.extensions||{},n.extensions[Le]={}}}),this}}ln.EXTENSION_NAME=Le;class hn extends V{init(){this.extensionName=Fe,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new P})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}}hn.EXTENSION_NAME=Fe;class gn extends V{init(){this.extensionName=Fe,this.propertyType="MappingList",this.parentTypes=[h.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new P})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}}gn.EXTENSION_NAME=Fe;class Nt extends V{init(){this.extensionName=Fe,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Nt.EXTENSION_NAME=Fe;const ie=Fe;class pn extends U{constructor(...e){super(...e),this.extensionName=ie}createMappingList(){return new gn(this.document.getGraph())}createVariant(e=""){return new Nt(this.document.getGraph(),e)}createMapping(){return new hn(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter(e=>e instanceof Nt)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ie])return this;const n=(t.json.extensions[ie].variants||[]).map(a=>this.createVariant().setName(a.name||""));return(t.json.meshes||[]).forEach((a,c)=>{const u=e.meshes[c];(a.primitives||[]).forEach((p,m)=>{if(!p.extensions||!p.extensions[ie])return;const N=this.createMappingList(),S=p.extensions[ie];for(const w of S.mappings){const M=this.createMapping();w.material!==void 0&&M.setMaterial(e.materials[w.material]);for(const l of w.variants||[])M.addVariant(n[l]);N.addMapping(M)}u.listPrimitives()[m].setExtension(ie,N)})}),this}write(e){const t=e.jsonDoc,r=this.listVariants();if(!r.length)return this;const s=[],n=new Map;for(const o of r)n.set(o,s.length),s.push(e.createPropertyDef(o));for(const o of this.document.getRoot().listMeshes()){const a=e.meshIndexMap.get(o);o.listPrimitives().forEach((c,u)=>{const g=c.getExtension(ie);if(!g)return;const p=e.jsonDoc.json.meshes[a].primitives[u],m=g.listMappings().map(N=>{const S=e.createPropertyDef(N),w=N.getMaterial();return w&&(S.material=e.materialIndexMap.get(w)),S.variants=N.listVariants().map(M=>n.get(M)),S});p.extensions=p.extensions||{},p.extensions[ie]={mappings:m}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[ie]={variants:s},this}}pn.EXTENSION_NAME=ie;const{G:ii}=te;class dn extends V{init(){this.extensionName=Vt,this.propertyType="Volume",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new j(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:ii})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}}dn.EXTENSION_NAME=Vt;const we=Vt;class Tn extends U{constructor(...e){super(...e),this.extensionName=we,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createVolume(){return new dn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[we]){const a=this.createVolume();e.materials[o].setExtension(we,a);const c=n.extensions[we];if(c.thicknessFactor!==void 0&&a.setThicknessFactor(c.thicknessFactor),c.attenuationDistance!==void 0&&a.setAttenuationDistance(c.attenuationDistance),c.attenuationColor!==void 0&&a.setAttenuationColor(c.attenuationColor),c.thicknessTexture!==void 0){const u=c.thicknessTexture,g=e.textures[s[u.index].source];a.setThicknessTexture(g),e.setTextureInfo(a.getThicknessTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(we);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[we]={};if(s.getThicknessFactor()>0&&(a.thicknessFactor=s.getThicknessFactor()),Number.isFinite(s.getAttenuationDistance())&&(a.attenuationDistance=s.getAttenuationDistance()),B.eq(s.getAttenuationColor(),[1,1,1])||(a.attenuationColor=s.getAttenuationColor()),s.getThicknessTexture()){const c=s.getThicknessTexture(),u=s.getThicknessTextureInfo();a.thicknessTexture=e.createTextureInfoDef(c,u)}}}),this}}Tn.EXTENSION_NAME=we;const mn=xr;class xn extends U{constructor(...e){super(...e),this.extensionName=mn}read(e){return this}write(e){return this}}xn.EXTENSION_NAME=mn;const $e=Er;class oi{match(e){return e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10}getSize(e){const t=ht(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){const r=ht(e).dataFormatDescriptor[0];if(r.colorModel===Cn)return r.samples.length===2&&(r.samples[1].channelType&15)===15?4:3;if(r.colorModel===On)return(r.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${r.colorModel}".`)}getVRAMByteLength(e){const t=ht(e),r=this.getChannels(e)>3;let s=0;for(let n=0;n<t.levels.length;n++){const o=t.levels[n];if(o.uncompressedByteLength)s+=o.uncompressedByteLength;else{const a=Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,n))),c=Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,n))),u=r?16:8;s+=a/4*(c/4)*u}}return s}}class En extends U{constructor(...e){super(...e),this.extensionName=$e,this.prereadTypes=[h.TEXTURE]}static register(){ae.registerFormat("image/ktx2",new oi)}preread(e){return e.jsonDoc.json.textures.forEach(t=>{if(t.extensions&&t.extensions[$e]){const r=t.extensions[$e];t.source=r.source}}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(r=>{if(r.getMimeType()==="image/ktx2"){const s=e.imageIndexMap.get(r);t.json.textures.forEach(n=>{n.source===s&&(n.extensions=n.extensions||{},n.extensions[$e]={source:n.source},delete n.source)})}}),this}}En.EXTENSION_NAME=$e;class Rn extends V{init(){this.extensionName=kt,this.propertyType="Transform",this.parentTypes=[h.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}}Rn.EXTENSION_NAME=kt;const be=kt;class In extends U{constructor(...e){super(...e),this.extensionName=be}createTransform(){return new Rn(this.document.getGraph())}read(e){for(const[t,r]of Array.from(e.textureInfos.entries())){if(!r.extensions||!r.extensions[be])continue;const s=this.createTransform(),n=r.extensions[be];n.offset!==void 0&&s.setOffset(n.offset),n.rotation!==void 0&&s.setRotation(n.rotation),n.scale!==void 0&&s.setScale(n.scale),n.texCoord!==void 0&&s.setTexCoord(n.texCoord),t.setExtension(be,s)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[r,s]of t){const n=r.getExtension(be);if(!n)continue;s.extensions=s.extensions||{};const o={},a=B.eq;a(n.getOffset(),[0,0])||(o.offset=n.getOffset()),n.getRotation()!==0&&(o.rotation=n.getRotation()),a(n.getScale(),[1,1])||(o.scale=n.getScale()),n.getTexCoord()!=null&&(o.texCoord=n.getTexCoord()),s.extensions[be]=o}return this}}In.EXTENSION_NAME=be;const ai=[h.ROOT,h.SCENE,h.NODE,h.MESH,h.MATERIAL,h.TEXTURE,h.ANIMATION];class yn extends V{init(){this.extensionName=ot,this.propertyType="Packet",this.parentTypes=ai}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",fe({},e))}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){const t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);const r=fe({},this.get("properties"));return t?r[e]=t:delete r[e],this.set("properties",r)}toJSONLD(){const e=pt(this.get("context")),t=pt(this.get("properties"));return fe({"@context":e},t)}fromJSONLD(e){e=pt(e);const t=e["@context"];return t&&this.set("context",t),delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw new Error(`${ot}: Missing context for term, "${e}".`)}}yn.EXTENSION_NAME=ot;function pt(i){return JSON.parse(JSON.stringify(i))}const ue=ot;class Nn extends U{constructor(...e){super(...e),this.extensionName=ue}createPacket(){return new yn(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){var t;const r=(t=e.jsonDoc.json.extensions)==null?void 0:t[ue];if(!r||!r.packets)return this;const s=e.jsonDoc.json,n=this.document.getRoot(),o=r.packets.map(u=>this.createPacket().fromJSONLD(u)),a=[[s.asset],s.scenes,s.nodes,s.meshes,s.materials,s.images,s.animations],c=[[n],n.listScenes(),n.listNodes(),n.listMeshes(),n.listMaterials(),n.listTextures(),n.listAnimations()];for(let u=0;u<a.length;u++){const g=a[u]||[];for(let p=0;p<g.length;p++){const m=g[p];if(m.extensions&&m.extensions[ue]){const N=m.extensions[ue];c[u][p].setExtension(ue,o[N.packet])}}}return this}write(e){const{json:t}=e.jsonDoc,r=[];for(const s of this.properties){r.push(s.toJSONLD());for(const n of s.listParents()){let o;switch(n.propertyType){case h.ROOT:o=t.asset;break;case h.SCENE:o=t.scenes[e.sceneIndexMap.get(n)];break;case h.NODE:o=t.nodes[e.nodeIndexMap.get(n)];break;case h.MESH:o=t.meshes[e.meshIndexMap.get(n)];break;case h.MATERIAL:o=t.materials[e.materialIndexMap.get(n)];break;case h.TEXTURE:o=t.images[e.imageIndexMap.get(n)];break;case h.ANIMATION:o=t.animations[e.animationIndexMap.get(n)];break;default:o=null,this.document.getLogger().warn(`[${ue}]: Unsupported parent property, "${n.propertyType}"`);break}o&&(o.extensions=o.extensions||{},o.extensions[ue]={packet:r.length-1})}}return r.length>0&&(t.extensions=t.extensions||{},t.extensions[ue]={packets:r}),this}}Nn.EXTENSION_NAME=ue;const ci=[zt,Gs,ks,zs,Xs,qs,Ws,Qs,en,sn,an,rn,un,ln,pn,Tn,xn,En,In,Nn],ui=[vs,Ht,Ls,Bs,...ci],An=new dr;let gs=!1;async function fi(){gs||(await $t.ready,await Xt.ready,An.registerExtensions([...ui,bs,Cs]).registerDependencies({"meshopt.decoder":$t,"meshopt.encoder":Xt}),gs=!0)}const di=Object.freeze(Object.defineProperty({__proto__:null,initGlTFIO:fi,io:An},Symbol.toStringTag,{value:"Module"}));export{A,D as B,pi as C,qe as D,Ht as E,ge as F,bs as G,xn as K,B as M,ys as N,De as P,Ms as R,Ns as S,Ss as T,h as a,Mt as b,j as c,V as d,Oe as e,Zn as f,En as g,Cs as h,An as i,di as j,Yn as u};