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

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 +154 -140
  2. package/dist/viewport-client/_static/Accordion-930aedee.js +1 -0
  3. package/dist/viewport-client/_static/{AmbientLightAsset-f70b95f1.js → AmbientLightAsset-f9c1eb91.js} +2 -2
  4. package/dist/viewport-client/_static/AnimationClipAsset-61699477.js +1 -0
  5. package/dist/viewport-client/_static/AnimatorControllerAsset-1c05f4db.js +1 -0
  6. package/dist/viewport-client/_static/AnimatorStore-6a3679e5.js +1 -0
  7. package/dist/viewport-client/_static/{AssetViewer-bc198e16.js → AssetViewer-0ce46fa1.js} +1 -1
  8. package/dist/viewport-client/_static/AudioAsset-5127eeec.js +1 -0
  9. package/dist/viewport-client/_static/AudioComponent-18a3e59f.js +1 -0
  10. package/dist/viewport-client/_static/{Callout-cb4a55ff.js → Callout-b6ac1af7.js} +1 -1
  11. package/dist/viewport-client/_static/CameraComponent-0a115258.js +1 -0
  12. package/dist/viewport-client/_static/{Component-f923abb1.js → Component-746be670.js} +1 -1
  13. package/dist/viewport-client/_static/DirectLight-4c53e9f6.js +1 -0
  14. package/dist/viewport-client/_static/FontAsset-a3a92f7d.js +5 -0
  15. package/dist/viewport-client/_static/FormItemArray-a2f72cf1.js +6 -0
  16. package/dist/viewport-client/_static/{GlTFAsset-9c68f862.js → GlTFAsset-5f37feef.js} +9 -9
  17. package/dist/viewport-client/_static/IconEdit-2c768a0a.js +6 -0
  18. package/dist/viewport-client/_static/{IconPointFilled-a304fd34.js → IconPointFilled-209638e2.js} +1 -1
  19. package/dist/viewport-client/_static/LightBaseComponent-51d498ea.js +1 -0
  20. package/dist/viewport-client/_static/LottieAnimationComponent-bff0244b.js +1 -0
  21. package/dist/viewport-client/_static/LottieAsset-9d3ef507.js +6 -0
  22. package/dist/viewport-client/_static/MarkdownAsset-a17933fb.js +1 -0
  23. package/dist/viewport-client/_static/MaterialAsset-3b56ac00.js +1 -0
  24. package/dist/viewport-client/_static/MaterialInspector-a36197f2.js +1 -0
  25. package/dist/viewport-client/_static/Menu-0a7dbec0.js +17 -0
  26. package/dist/viewport-client/_static/MeshAsset-2cf47eb2.js +1 -0
  27. package/dist/viewport-client/_static/MeshRendererBaseComponent-4a3af376.js +1 -0
  28. package/dist/viewport-client/_static/MeshRendererComponent-ac4c3954.js +1 -0
  29. package/dist/viewport-client/_static/{MeshThumbnail-49273f71.js → MeshThumbnail-25cd4a13.js} +1 -1
  30. package/dist/viewport-client/_static/ParticleRendererComponent-0a470dee.js +26 -0
  31. package/dist/viewport-client/_static/PhysicsMaterialAsset-d87d35aa.js +1 -0
  32. package/dist/viewport-client/_static/PhysicsStore-c283b2be.js +1 -0
  33. package/dist/viewport-client/_static/PointLight-b7de209f.js +1 -0
  34. package/dist/viewport-client/_static/PostProcessComponent-d4c9ef58.js +6 -0
  35. package/dist/viewport-client/_static/PrefabAsset-d0c0cd25.js +1 -0
  36. package/dist/viewport-client/_static/PrimitiveMesh-35092ad0.js +1 -0
  37. package/dist/viewport-client/_static/ProxyConfigs-ad92ebc7.js +1 -0
  38. package/dist/viewport-client/_static/{ReferencedMaterial-a87818f3.js → ReferencedMaterial-800a1955.js} +1 -1
  39. package/dist/viewport-client/_static/RenderTargetAsset-a003f9f5.js +1 -0
  40. package/dist/viewport-client/_static/SceneAsset-87f2ea92.js +1 -0
  41. package/dist/viewport-client/_static/{ShaderAsset-cb3ff628.js → ShaderAsset-98ce1f70.js} +6 -6
  42. package/dist/viewport-client/_static/ShaderChunkAsset-e9072307.js +5 -0
  43. package/dist/viewport-client/_static/{ShaderUIScriptAsset-d13fa4e2.js → ShaderUIScriptAsset-ac824e68.js} +5 -5
  44. package/dist/viewport-client/_static/SkinnedMeshRendererComponent-5f34bf46.js +1 -0
  45. package/dist/viewport-client/_static/SpineAnimationComponent-7c5db747.js +1 -0
  46. package/dist/viewport-client/_static/SpineSkeletonDataAsset-5b202ba0.js +1 -0
  47. package/dist/viewport-client/_static/SpotLight-2b4e593e.js +1 -0
  48. package/dist/viewport-client/_static/SpriteAsset-4e895da5.js +6 -0
  49. package/dist/viewport-client/_static/SpriteAtlasAsset-c2894c12.js +1 -0
  50. package/dist/viewport-client/_static/SpriteBaseComponent-a75e84c1.js +1 -0
  51. package/dist/viewport-client/_static/SpriteMaskComponent-a31f3384.js +1 -0
  52. package/dist/viewport-client/_static/SpriteRendererComponent-c2123918.js +1 -0
  53. package/dist/viewport-client/_static/{TextBaseComponent-69233798.js → TextBaseComponent-95846acf.js} +2 -2
  54. package/dist/viewport-client/_static/TextRendererComponent-429cf17b.js +1 -0
  55. package/dist/viewport-client/_static/TextureAsset-93475ade.js +36 -0
  56. package/dist/viewport-client/_static/Tooltip-dfde37c6.js +1 -0
  57. package/dist/viewport-client/_static/TrailRendererComponent-112b1618.js +1 -0
  58. package/dist/viewport-client/_static/TransformBaseComponent-a8050787.js +1 -0
  59. package/dist/viewport-client/_static/TransformComponent-c95e25c2.js +1 -0
  60. package/dist/viewport-client/_static/XRReferenceImageAsset-dbf129aa.js +1 -0
  61. package/dist/viewport-client/_static/audio-10589bb4.js +1 -0
  62. package/dist/viewport-client/_static/glTFIO-79bbca27.js +1 -0
  63. package/dist/viewport-client/_static/index-010da0b3.js +1 -0
  64. package/dist/viewport-client/_static/index-07bbf729.js +31 -0
  65. package/dist/viewport-client/_static/index-1e23212d.js +11487 -0
  66. package/dist/viewport-client/_static/index-2cdbb69f.js +1 -0
  67. package/dist/viewport-client/_static/index-31b7a6d3.js +1 -0
  68. package/dist/viewport-client/_static/index-3439012b.js +1 -0
  69. package/dist/viewport-client/_static/index-48760ac4.js +2 -0
  70. package/dist/viewport-client/_static/index-65a103b6.js +1 -0
  71. package/dist/viewport-client/_static/{index-e46ec5b1.js → index-77b1de5c.js} +7 -7
  72. package/dist/viewport-client/_static/index-92830754.js +1 -0
  73. package/dist/viewport-client/_static/{index-237c84cd.js → index-93eab932.js} +3 -3
  74. package/dist/viewport-client/_static/index-b259cf2e.js +1 -0
  75. package/dist/viewport-client/_static/{index-98982ce2.js → index-b2e1cba4.js} +1 -1
  76. package/dist/viewport-client/_static/index-b7bf2586.js +1 -0
  77. package/dist/viewport-client/_static/index-c20fc198.js +1 -0
  78. package/dist/viewport-client/_static/index-dc62ba4b.js +1 -0
  79. package/dist/viewport-client/_static/index-ea9ea505.js +1 -0
  80. package/dist/viewport-client/_static/ktx2-encoder-075abd75.js +1 -0
  81. package/dist/viewport-client/_static/{module-6406b050.js → module-251ecc50.js} +1 -1
  82. package/dist/viewport-client/_static/{module-107b7430.js → module-498119f3.js} +1 -1
  83. package/dist/viewport-client/_static/{module-5c85b07e.js → module-c6e2d190.js} +1 -1
  84. package/dist/viewport-client/_static/postmen-9e1e15bd.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
@@ -0,0 +1 @@
1
+ var On=Object.defineProperty;var Dn=(i,e,t)=>e in i?On(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Q=(i,e,t)=>(Dn(i,typeof e!="symbol"?e+"":e,t),t);import{M as Yt,a as Wt}from"./meshopt_simplifier.module-cd99529d.js";class Es{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 ke{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 vn extends Es{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 ke(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 Je(){return Je=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},Je.apply(this,arguments)}class xe{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 V{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 oe{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"),Fe=Symbol("immutableKeys");class bt extends Es{constructor(e){super(),this._disposed=!1,this.graph=void 0,this[F]=void 0,this[Fe]=void 0,this.graph=e,this[Fe]=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 bt){const n=this.graph._createEdge(r,this,s);this[Fe].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 ke){const n=s;n.getChild()===e&&this.setRef(r,t,n.getAttributes())}else if(s instanceof xe)for(const n of s.listRefsByChild(e)){const o=n.getAttributes();this.removeRef(r,e),this.addRef(r,t,o)}else if(s instanceof V){const n=s.getRefByChild(e);if(n){const o=n.getAttributes();this.removeRef(r,e),this.addRef(r,t,o)}}else if(s instanceof oe)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[Fe].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 xe)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 xe||t instanceof V)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,Je({},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 oe)return t;throw new Error(`Expected RefMap for attribute "${e}"`)}dispatchEvent(e){return super.dispatchEvent(Je({},e,{target:this})),this.graph.dispatchEvent(Je({},e,{target:this,type:`node:${e.type}`})),this}_destroyRef(e){const t=e.getName();if(this[F][t]===e)this[F][t]=null,this[Fe].has(t)&&e.getChild().dispose();else if(this[F][t]instanceof xe)this[F][t].remove(e);else if(this[F][t]instanceof V)this[F][t].remove(e);else if(this[F][t]instanceof oe){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 ys="v4.1.0",He="@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 ct;(function(i){i.INTERLEAVED="interleaved",i.SEPARATE="separate"})(ct||(ct={}));var te;(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"})(te||(te={}));var ie;(function(i){i[i.R=4096]="R",i[i.G=256]="G",i[i.B=16]="B",i[i.A=1]="A"})(ie||(ie={}));var me;(function(i){i.GLTF="GLTF",i.GLB="GLB"})(me||(me={}));const ht={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};var Et=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 Fn(){var i=new Et(3);return Et!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function Tt(i){var e=i[0],t=i[1],r=i[2];return Math.hypot(e,t,r)}function Un(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=Fn();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 Bn(i){const e=Rs(),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=Ln(n,s.getWorldMatrix());o.min.every(isFinite)&&o.max.every(isFinite)&&(yt(o.min,e),yt(o.max,e))});return e}function Ln(i,e){const t=Rs();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=Un(a,o,e),yt(a,t)}}return t}function yt(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 Rs(){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 _i{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),Pn(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 gt{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))===gt.PNG_FRIED_CHUNK_NAME?[t.getUint32(32,!1),t.getUint32(36,!1)]:[t.getUint32(16,!1),t.getUint32(20,!1)]}getChannels(e){return 4}}gt.PNG_FRIED_CHUNK_NAME="CgBI";class fe{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}`:""}}fe.impls={"image/jpeg":new jn,"image/png":new gt};function Pn(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 ze{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 fe.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 Jt(i){return Object.prototype.toString.call(i)==="[object Object]"}function Ue(i){if(Jt(i)===!1)return!1;const e=i.constructor;if(e===void 0)return!0;const t=e.prototype;return!(Jt(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var Rt,It;(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"})(It||(It={}));class re{constructor(e){this.verbosity=void 0,this.verbosity=e}debug(e){this.verbosity<=re.Verbosity.DEBUG&&console.debug(e)}info(e){this.verbosity<=re.Verbosity.INFO&&console.info(e)}warn(e){this.verbosity<=re.Verbosity.WARN&&console.warn(e)}error(e){this.verbosity<=re.Verbosity.ERROR&&console.error(e)}}Rt=re;re.Verbosity=It;re.DEFAULT_INSTANCE=new Rt(Rt.Verbosity.INFO);function Vn(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],x=i[11],I=i[12],m=i[13],_=i[14],M=i[15],l=e*o-t*n,b=e*a-r*n,T=e*c-s*n,y=t*a-r*o,E=t*c-s*o,N=r*c-s*a,f=u*m-g*I,d=u*_-p*I,R=u*M-x*I,A=g*_-p*m,w=g*M-x*m,O=p*M-x*_;return l*O-b*w+T*A+y*R-E*d+N*f}function kn(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],x=e[9],I=e[10],m=e[11],_=e[12],M=e[13],l=e[14],b=e[15],T=t[0],y=t[1],E=t[2],N=t[3];return i[0]=T*r+y*a+E*p+N*_,i[1]=T*s+y*c+E*x+N*M,i[2]=T*n+y*u+E*I+N*l,i[3]=T*o+y*g+E*m+N*b,T=t[4],y=t[5],E=t[6],N=t[7],i[4]=T*r+y*a+E*p+N*_,i[5]=T*s+y*c+E*x+N*M,i[6]=T*n+y*u+E*I+N*l,i[7]=T*o+y*g+E*m+N*b,T=t[8],y=t[9],E=t[10],N=t[11],i[8]=T*r+y*a+E*p+N*_,i[9]=T*s+y*c+E*x+N*M,i[10]=T*n+y*u+E*I+N*l,i[11]=T*o+y*g+E*m+N*b,T=t[12],y=t[13],E=t[14],N=t[15],i[12]=T*r+y*a+E*p+N*_,i[13]=T*s+y*c+E*x+N*M,i[14]=T*n+y*u+E*I+N*l,i[15]=T*o+y*g+E*m+N*b,i}function Gn(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 Hn(i,e){var t=new Et(3);Gn(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,x=e[8]*r,I=e[9]*s,m=e[10]*n,_=o+g+m,M=0;return _>0?(M=Math.sqrt(_+1)*2,i[3]=.25*M,i[0]=(p-I)/M,i[1]=(x-c)/M,i[2]=(a-u)/M):o>g&&o>m?(M=Math.sqrt(1+o-g-m)*2,i[3]=(p-I)/M,i[0]=.25*M,i[1]=(a+u)/M,i[2]=(x+c)/M):g>m?(M=Math.sqrt(1+g-o-m)*2,i[3]=(x-c)/M,i[0]=(a+u)/M,i[1]=.25*M,i[2]=(p+I)/M):(M=Math.sqrt(1+m-o-g)*2,i[3]=(a-u)/M,i[0]=(x+c)/M,i[1]=(p+I)/M,i[2]=.25*M),i}class L{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(L.clamp(e,0,1)*65535);case 5121:return Math.round(L.clamp(e,0,1)*255);case 5122:return Math.round(L.clamp(e,-1,1)*32767);case 5120:return Math.round(L.clamp(e,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(e,t,r,s){let n=Tt([e[0],e[1],e[2]]);const o=Tt([e[4],e[5],e[6]]),a=Tt([e[8],e[9],e[10]]);Vn(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,x=1/a;u[0]*=g,u[1]*=g,u[2]*=g,u[4]*=p,u[5]*=p,u[6]*=p,u[8]*=x,u[9]*=x,u[10]*=x,Hn(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,x=c+c,I=o*g,m=o*p,_=o*x,M=a*p,l=a*x,b=c*x,T=u*g,y=u*p,E=u*x,N=r[0],f=r[1],d=r[2];return n[0]=(1-(M+b))*N,n[1]=(m+E)*N,n[2]=(_-y)*N,n[3]=0,n[4]=(m-E)*f,n[5]=(1-(I+b))*f,n[6]=(l+T)*f,n[7]=0,n[8]=(_+y)*d,n[9]=(l-T)*d,n[10]=(1-(I+M))*d,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}}function zn(i,e){if(!!i!=!!e)return!1;const t=i.getChild(),r=e.getChild();return t===r||t.equals(r)}function $n(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 Xn(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 Is(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 As(i,e){if(i===e)return!0;if(!!i!=!!e)return!1;if(!Ue(i)||!Ue(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(ut(a)&&ut(c)){if(!Is(a,c))return!1}else if(Ue(a)&&Ue(c)){if(!As(a,c))return!1}else if(a!==c)return!1}return!0}function ut(i){return Array.isArray(i)||ArrayBuffer.isView(i)}const Qt="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",Kn=999,qn=6,Zt=new Set,Yn=function(){let e="";for(let t=0;t<qn;t++)e+=Qt.charAt(Math.floor(Math.random()*Qt.length));return e},Wn=function(){for(let e=0;e<Kn;e++){const t=Yn();if(!Zt.has(t))return Zt.add(t),t}return""},es="https://null.example";class Qe{static dirname(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substring(0,t+1)}static basename(e){return ze.basename(new URL(e,es).pathname)}static extension(e){return ze.extension(new URL(e,es).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)}}Qe.DEFAULT_INIT={};Qe.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;const Ee=i=>i,Jn=new Set;class wt extends bt{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,Ee)}copy(e,t=Ee){for(const r in this[F]){const s=this[F][r];if(s instanceof ke)this[Fe].has(r)||s.dispose();else if(s instanceof xe||s instanceof V)for(const n of s.values())n.dispose();else if(s instanceof oe)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 ke)this[Fe].has(r)?s.getChild().copy(t(n.getChild()),t):this.setRef(r,t(n.getChild()),n.getAttributes());else if(n instanceof V||n instanceof xe)for(const o of n.values())this.addRef(r,t(o.getChild()),o.getAttributes());else if(n instanceof oe)for(const o of n.keys()){const a=n.get(o);this.setRefMap(r,o,t(a.getChild()),a.getAttributes())}else Ue(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=Jn){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 ke||n instanceof ke){if(!zn(s,n))return!1}else if(s instanceof V||n instanceof V||s instanceof xe||n instanceof xe){if(!$n(s,n))return!1}else if(s instanceof oe||n instanceof oe){if(!Xn(s,n))return!1}else if(Ue(s)||Ue(n)){if(!As(s,n))return!1}else if(ut(s)||ut(n)){if(!Is(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 J extends wt{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new oe})}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 S extends J{init(){this.propertyType=h.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:S.Type.SCALAR,componentType:S.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(e){switch(e){case S.Type.SCALAR:return 1;case S.Type.VEC2:return 2;case S.Type.VEC3:return 3;case S.Type.VEC4:return 4;case S.Type.MAT2:return 4;case S.Type.MAT3:return 9;case S.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+e)}}static getComponentSize(e){switch(e){case S.ComponentType.BYTE:return 1;case S.ComponentType.UNSIGNED_BYTE:return 1;case S.ComponentType.SHORT:return 2;case S.ComponentType.UNSIGNED_SHORT:return 2;case S.ComponentType.UNSIGNED_INT:return 4;case S.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]=L.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]=L.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 S.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()?L.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]=L.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]=L.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]=L.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?Qn(e):S.ComponentType.FLOAT),this.set("array",e),this}getByteLength(){const e=this.get("array");return e?e.byteLength:0}}S.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};S.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function Qn(i){switch(i.constructor){case Float32Array:return S.ComponentType.FLOAT;case Uint32Array:return S.ComponentType.UNSIGNED_INT;case Uint16Array:return S.ComponentType.UNSIGNED_SHORT;case Uint8Array:return S.ComponentType.UNSIGNED_BYTE;case Int16Array:return S.ComponentType.SHORT;case Int8Array:return S.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class Ns extends J{init(){this.propertyType=h.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new V,samplers:new V})}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 Ct extends J{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)}}Ct.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class Xe extends J{init(){this.propertyType=h.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:Xe.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:te.OTHER})}getOutput(){return this.getRef("output")}setOutput(e){return this.setRef("output",e,{usage:te.OTHER})}}Xe.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class Ss extends J{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 je extends J{init(){this.propertyType=h.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:je.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)}}je.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class k extends wt{_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw new Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}}k.EXTENSION_NAME=void 0;class j extends J{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:nt,G:rt,B:it,A:Zn}=ie;class Be extends J{init(){this.propertyType=h.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:Be.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:nt|rt|it|Zn,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:nt|rt|it,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:nt|rt|it})}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:nt})}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:rt|it})}}Be.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class Ms extends J{init(){this.propertyType=h.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new V})}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 _s extends J{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 V})}copy(e,t=Ee){if(t===Ee)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 L.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 L.decompose(e,t,r,s),this.set("translation",t).set("rotation",r).set("scale",s)}getWorldTranslation(){const e=[0,0,0];return L.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){const e=[0,0,0,1];return L.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){const e=[1,1,1];return L.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();)kn(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 Le extends J{init(){this.propertyType=h.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:Le.Mode.TRIANGLES,material:null,indices:null,attributes:new oe,targets:new V})}getIndices(){return this.getRef("indices")}setIndices(e){return this.setRef("indices",e,{usage:te.ELEMENT_ARRAY_BUFFER})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:te.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)}}Le.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class er extends wt{init(){this.propertyType=h.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new oe})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:te.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function W(){return W=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},W.apply(null,arguments)}class bs extends J{init(){this.propertyType=h.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new V})}copy(e,t=Ee){if(t===Ee)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 ws extends J{init(){this.propertyType=h.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new V})}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:te.INVERSE_BIND_MATRICES})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}}class Cs extends J{init(){this.propertyType=h.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||fe.extensionToMimeType(ze.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);const t=fe.extensionToMimeType(ze.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?fe.getSize(e,this.getMimeType()):null}}class Os extends J{init(){this.propertyType=h.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${ys}`,version:"2.0"},defaultScene:null,accessors:new V,animations:new V,buffers:new V,cameras:new V,materials:new V,meshes:new V,nodes:new V,scenes:new V,skins:new V,textures:new V})}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=Ee){if(t===Ee)throw new Error("Root cannot be copied.");this.set("asset",W({},e.get("asset"))),this.setName(e.getName()),this.setExtras(W({},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 bs?this.addRef("scenes",e):e instanceof _s?this.addRef("nodes",e):e instanceof je?this.addRef("cameras",e):e instanceof ws?this.addRef("skins",e):e instanceof Ms?this.addRef("meshes",e):e instanceof Be?this.addRef("materials",e):e instanceof Cs?this.addRef("textures",e):e instanceof Ns?this.addRef("animations",e):e instanceof S?this.addRef("accessors",e):e instanceof Ss&&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 Ze{static fromGraph(e){return Ze._GRAPH_DOCUMENTS.get(e)||null}constructor(){this._graph=new vn,this._root=new Os(this._graph),this._logger=re.DEFAULT_INSTANCE,Ze._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 bs(this._graph,e)}createNode(e=""){return new _s(this._graph,e)}createCamera(e=""){return new je(this._graph,e)}createSkin(e=""){return new ws(this._graph,e)}createMesh(e=""){return new Ms(this._graph,e)}createPrimitive(){return new Le(this._graph)}createPrimitiveTarget(e=""){return new er(this._graph,e)}createMaterial(e=""){return new Be(this._graph,e)}createTexture(e=""){return new Cs(this._graph,e)}createAnimation(e=""){return new Ns(this._graph,e)}createAnimationChannel(e=""){return new Ct(this._graph,e)}createAnimationSampler(e=""){return new Xe(this._graph,e)}createAccessor(e="",t=null){return t||(t=this.getRoot().listBuffers()[0]),new S(this._graph,e).setBuffer(t)}createBuffer(e=""){return new Ss(this._graph,e)}}Ze._GRAPH_DOCUMENTS=new WeakMap;class P{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 k&&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}}P.EXTENSION_NAME=void 0;class tr{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 ts={logger:re.DEFAULT_INSTANCE,extensions:[],dependencies:{}},sr=new Set([h.BUFFER,h.TEXTURE,h.MATERIAL,h.MESH,h.PRIMITIVE,h.NODE,h.SCENE]);class nr{static read(e,t=ts){const r=W({},ts,t),{json:s}=e,n=new Ze().setLogger(r.logger);this.validate(e,r);const o=new tr(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(W({},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)),R=d.prereadTypes.filter(A=>!sr.has(A));R.length&&r.logger.warn(`Preread hooks for some types (${R.join()}), requested by extension ${d.extensionName}, are unsupported. Please file an issue or a PR.`);for(const A of d.readDependencies)d.install(A,r.dependencies[A])}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 x=s.bufferViews||[];o.bufferViewBuffers=x.map((f,d)=>{if(!o.bufferViews[d]){const R=e.json.buffers[f.buffer],A=R.uri?e.resources[R.uri]:e.resources[He],w=f.byteOffset||0;o.bufferViews[d]=D.toView(A,w,f.byteLength)}return o.buffers[f.buffer]});const I=s.accessors||[];o.accessors=I.map(f=>{const d=o.bufferViewBuffers[f.bufferView],R=n.createAccessor(f.name,d).setType(f.type);return f.extras&&R.setExtras(f.extras),f.normalized!==void 0&&R.setNormalized(f.normalized),f.bufferView===void 0||R.setArray(at(f,o)),R});const m=s.images||[],_=s.textures||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.TEXTURE)).forEach(f=>f.preread(o,h.TEXTURE)),o.textures=m.map(f=>{const d=n.createTexture(f.name);if(f.extras&&d.setExtras(f.extras),f.bufferView!==void 0){const R=s.bufferViews[f.bufferView],A=e.json.buffers[R.buffer],w=A.uri?e.resources[A.uri]:e.resources[He],O=R.byteOffset||0,C=R.byteLength,B=w.slice(O,O+C);d.setImage(B)}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 R=ze.extension(f.uri);d.setMimeType(fe.extensionToMimeType(R))}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 R=f.pbrMetallicRoughness||{};if(R.baseColorFactor!==void 0&&d.setBaseColorFactor(R.baseColorFactor),f.emissiveFactor!==void 0&&d.setEmissiveFactor(f.emissiveFactor),R.metallicFactor!==void 0&&d.setMetallicFactor(R.metallicFactor),R.roughnessFactor!==void 0&&d.setRoughnessFactor(R.roughnessFactor),R.baseColorTexture!==void 0){const A=R.baseColorTexture,w=o.textures[_[A.index].source];d.setBaseColorTexture(w),o.setTextureInfo(d.getBaseColorTextureInfo(),A)}if(f.emissiveTexture!==void 0){const A=f.emissiveTexture,w=o.textures[_[A.index].source];d.setEmissiveTexture(w),o.setTextureInfo(d.getEmissiveTextureInfo(),A)}if(f.normalTexture!==void 0){const A=f.normalTexture,w=o.textures[_[A.index].source];d.setNormalTexture(w),o.setTextureInfo(d.getNormalTextureInfo(),A),f.normalTexture.scale!==void 0&&d.setNormalScale(f.normalTexture.scale)}if(f.occlusionTexture!==void 0){const A=f.occlusionTexture,w=o.textures[_[A.index].source];d.setOcclusionTexture(w),o.setTextureInfo(d.getOcclusionTextureInfo(),A),f.occlusionTexture.strength!==void 0&&d.setOcclusionStrength(f.occlusionTexture.strength)}if(R.metallicRoughnessTexture!==void 0){const A=R.metallicRoughnessTexture,w=o.textures[_[A.index].source];d.setMetallicRoughnessTexture(w),o.setTextureInfo(d.getMetallicRoughnessTextureInfo(),A)}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(A=>{const w=n.createPrimitive();A.extras&&w.setExtras(A.extras),A.material!==void 0&&w.setMaterial(o.materials[A.material]),A.mode!==void 0&&w.setMode(A.mode);for(const[B,v]of Object.entries(A.attributes||{}))w.setAttribute(B,o.accessors[v]);A.indices!==void 0&&w.setIndices(o.accessors[A.indices]);const O=f.extras&&f.extras.targetNames||[];(A.targets||[]).forEach((B,v)=>{const U=O[v]||v.toString(),H=n.createPrimitiveTarget(U);for(const[Z,K]of Object.entries(B))H.setAttribute(Z,o.accessors[K]);w.addTarget(H)}),d.addPrimitive(w)}),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===je.Type.PERSPECTIVE){const R=f.perspective;d.setYFov(R.yfov),d.setZNear(R.znear),R.zfar!==void 0&&d.setZFar(R.zfar),R.aspectRatio!==void 0&&d.setAspectRatio(R.aspectRatio)}else{const R=f.orthographic;d.setZNear(R.znear).setZFar(R.zfar).setXMag(R.xmag).setYMag(R.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 R=[0,0,0],A=[0,0,0,1],w=[1,1,1];L.decompose(f.matrix,R,A,w),d.setTranslation(R),d.setRotation(A),d.setScale(w)}return f.weights!==void 0&&d.setWeights(f.weights),d});const y=s.skins||[];o.skins=y.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 R of f.joints)d.addJoint(o.nodes[R]);return d}),T.map((f,d)=>{const R=o.nodes[d];(f.children||[]).forEach(w=>R.addChild(o.nodes[w])),f.mesh!==void 0&&R.setMesh(o.meshes[f.mesh]),f.camera!==void 0&&R.setCamera(o.cameras[f.camera]),f.skin!==void 0&&R.setSkin(o.skins[f.skin])});const E=s.animations||[];o.animations=E.map(f=>{const d=n.createAnimation(f.name);f.extras&&d.setExtras(f.extras);const A=(f.samplers||[]).map(O=>{const C=n.createAnimationSampler().setInput(o.accessors[O.input]).setOutput(o.accessors[O.output]).setInterpolation(O.interpolation||Xe.Interpolation.LINEAR);return O.extras&&C.setExtras(O.extras),d.addSampler(C),C});return(f.channels||[]).forEach(O=>{const C=n.createAnimationChannel().setSampler(A[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 N=s.scenes||[];return n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.SCENE)).forEach(f=>f.preread(o,h.SCENE)),o.scenes=N.map(f=>{const d=n.createScene(f.name);return f.extras&&d.setExtras(f.extras),(f.nodes||[]).map(A=>o.nodes[A]).forEach(A=>d.addChild(A)),d}),s.scene!==void 0&&n.getRoot().setDefaultScene(o.scenes[s.scene]),n.getRoot().listExtensionsUsed().forEach(f=>f.read(o)),I.forEach((f,d)=>{const R=o.accessors[d],A=!!f.sparse,w=!f.bufferView&&!R.getArray();(A||w)&&R.setSparse(!0).setArray(ir(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 rr(i,e){const t=e.jsonDoc,r=e.bufferViews[i.bufferView],s=t.json.bufferViews[i.bufferView],n=ht[i.componentType],o=S.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 x=0;x<i.count;x++)for(let I=0;I<o;I++){const m=c+x*p+I*a;let _;switch(i.componentType){case S.ComponentType.FLOAT:_=g.getFloat32(m,!0);break;case S.ComponentType.UNSIGNED_INT:_=g.getUint32(m,!0);break;case S.ComponentType.UNSIGNED_SHORT:_=g.getUint16(m,!0);break;case S.ComponentType.UNSIGNED_BYTE:_=g.getUint8(m);break;case S.ComponentType.SHORT:_=g.getInt16(m,!0);break;case S.ComponentType.BYTE:_=g.getInt8(m);break;default:throw new Error(`Unexpected componentType "${i.componentType}".`)}u[x*o+I]=_}return u}function at(i,e){const t=e.jsonDoc,r=e.bufferViews[i.bufferView],s=t.json.bufferViews[i.bufferView],n=ht[i.componentType],o=S.getElementSize(i.type),a=n.BYTES_PER_ELEMENT,c=o*a;if(s.byteStride!==void 0&&s.byteStride!==c)return rr(i,e);const u=r.byteOffset+(i.byteOffset||0),g=i.count*o*a;return new n(r.buffer.slice(u,u+g))}function ir(i,e){const t=ht[i.componentType],r=S.getElementSize(i.type);let s;i.bufferView!==void 0?s=at(i,e):s=new t(i.count*r);const n=i.sparse;if(!n)return s;const o=n.count,a=W({},i,n.indices,{count:o,type:"SCALAR"}),c=W({},i,n.values,{count:o}),u=at(a,e),g=at(c,e);for(let p=0;p<a.count;p++)for(let x=0;x<r;x++)s[u[p]*r+x]=g[p*r+x];return s}var et;(function(i){i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(et||(et={}));class le{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 ss(n>1,()=>r.basename||"buffer"),this.imageURIGenerator=new ss(o>1,a=>or(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===me.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=fe.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 te.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 te.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}}le.BufferViewTarget=et;le.BufferViewUsage=te;le.USAGE_TO_TARGET={[te.ARRAY_BUFFER]:et.ARRAY_BUFFER,[te.ELEMENT_ARRAY_BUFFER]:et.ELEMENT_ARRAY_BUFFER};class ss{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 or(i,e){const t=i.getGraph().listParentEdges(e).find(r=>r.getParent()!==i.getRoot());return t?t.getName().replace(/texture$/i,""):""}const{BufferViewUsage:ot}=le,{UNSIGNED_INT:ar,UNSIGNED_SHORT:cr,UNSIGNED_BYTE:ur}=S.ComponentType,fr=new Set([h.ACCESSOR,h.BUFFER,h.MATERIAL,h.MESH]);class lr{static write(e,t){const r=e.getGraph(),s=e.getRoot(),n={asset:W({generator:`glTF-Transform ${ys}`},s.getAsset()),extras:W({},s.getExtras())},o={json:n,resources:{}},a=new le(e,o,t),c=t.logger||re.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=>!fr.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 x(l,b,T,y){const E=[];let N=0;for(const R of l){const A=a.createAccessorDef(R);A.bufferView=n.bufferViews.length;const w=R.getArray(),O=D.pad(D.toView(w));A.byteOffset=N,N+=O.byteLength,E.push(O),a.accessorIndexMap.set(R,n.accessors.length),n.accessors.push(A)}const f=D.concat(E),d={buffer:b,byteOffset:T,byteLength:f.byteLength};return y&&(d.target=y),n.bufferViews.push(d),{buffers:E,byteLength:N}}function I(l,b,T){const y=l[0].getCount();let E=0;for(const A of l){const w=a.createAccessorDef(A);w.bufferView=n.bufferViews.length,w.byteOffset=E;const O=A.getElementSize(),C=A.getComponentSize();E+=D.padNumber(O*C),a.accessorIndexMap.set(A,n.accessors.length),n.accessors.push(w)}const N=y*E,f=new ArrayBuffer(N),d=new DataView(f);for(let A=0;A<y;A++){let w=0;for(const O of l){const C=O.getElementSize(),B=O.getComponentSize(),v=O.getComponentType(),U=O.getArray();for(let H=0;H<C;H++){const Z=A*E+w+H*B,K=U[A*C+H];switch(v){case S.ComponentType.FLOAT:d.setFloat32(Z,K,!0);break;case S.ComponentType.BYTE:d.setInt8(Z,K);break;case S.ComponentType.SHORT:d.setInt16(Z,K,!0);break;case S.ComponentType.UNSIGNED_BYTE:d.setUint8(Z,K);break;case S.ComponentType.UNSIGNED_SHORT:d.setUint16(Z,K,!0);break;case S.ComponentType.UNSIGNED_INT:d.setUint32(Z,K,!0);break;default:throw new Error("Unexpected component type: "+v)}}w+=D.padNumber(C*B)}}const R={buffer:b,byteOffset:T,byteLength:N,byteStride:E,target:le.BufferViewTarget.ARRAY_BUFFER};return n.bufferViews.push(R),{byteLength:N,buffers:[new Uint8Array(f)]}}function m(l,b,T){const y=[];let E=0;const N=new Map;let f=-1/0,d=!1;for(const v of l){const U=a.createAccessorDef(v);n.accessors.push(U),a.accessorIndexMap.set(v,n.accessors.length-1);const H=[],Z=[],K=[],X=new Array(v.getElementSize()).fill(0);for(let de=0,Cn=v.getCount();de<Cn;de++)if(v.getElement(de,K),!L.eq(K,X,0)){f=Math.max(de,f),H.push(de);for(let dt=0;dt<K.length;dt++)Z.push(K[dt])}const ee=H.length,pe={accessorDef:U,count:ee};if(N.set(v,pe),ee===0)continue;ee>v.getCount()/2&&(d=!0);const pt=ht[v.getComponentType()];pe.indices=H,pe.values=new pt(Z)}if(!Number.isFinite(f))return{buffers:y,byteLength:E};d&&c.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");const R=f<255?Uint8Array:f<65535?Uint16Array:Uint32Array,A=f<255?ur:f<65535?cr:ar,w={buffer:b,byteOffset:T+E,byteLength:0};for(const v of l){const U=N.get(v);if(U.count===0)continue;U.indicesByteOffset=w.byteLength;const H=D.pad(D.toView(new R(U.indices)));y.push(H),E+=H.byteLength,w.byteLength+=H.byteLength}n.bufferViews.push(w);const O=n.bufferViews.length-1,C={buffer:b,byteOffset:T+E,byteLength:0};for(const v of l){const U=N.get(v);if(U.count===0)continue;U.valuesByteOffset=C.byteLength;const H=D.pad(D.toView(U.values));y.push(H),E+=H.byteLength,C.byteLength+=H.byteLength}n.bufferViews.push(C);const B=n.bufferViews.length-1;for(const v of l){const U=N.get(v);U.count!==0&&(U.accessorDef.sparse={count:U.count,indices:{bufferView:O,byteOffset:U.indicesByteOffset,componentType:A},values:{bufferView:B,byteOffset:U.valuesByteOffset}})}return{buffers:y,byteLength:E}}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 y=l.getImage();return y&&a.createImageData(T,y,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 y=a.getAccessorUsage(l);if(a.addAccessorToUsageGroup(l,y),b.has(y)){const E=r.listParents(l).find(N=>N.propertyType!==h.ROOT);T.set(l,E)}}),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===me.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),y=a.accessorUsageGroupedByParent,E=l.listParents().filter(C=>C instanceof S),N=new Set(E.map(C=>a.accessorParents.get(C))),f=new Map(Array.from(N).map((C,B)=>[C,B])),d={};for(const C of E){var R;if(a.accessorIndexMap.has(C))continue;const B=a.getAccessorUsage(C);let v=B;if(y.has(B)){const U=a.accessorParents.get(C);v+=`:${f.get(U)}`}d[R=v]||(d[R]={usage:B,accessors:[]}),d[v].accessors.push(C)}const A=[],w=n.buffers.length;let O=0;for(const{usage:C,accessors:B}of Object.values(d))if(C===ot.ARRAY_BUFFER&&t.vertexLayout===ct.INTERLEAVED){const v=I(B,w,O);O+=v.byteLength,A.push(...v.buffers)}else if(C===ot.ARRAY_BUFFER)for(const v of B){const U=I([v],w,O);O+=U.byteLength,A.push(...U.buffers)}else if(C===ot.SPARSE){const v=m(B,w,O);O+=v.byteLength,A.push(...v.buffers)}else if(C===ot.ELEMENT_ARRAY_BUFFER){const v=le.BufferViewTarget.ELEMENT_ARRAY_BUFFER,U=x(B,w,O,v);O+=U.byteLength,A.push(...U.buffers)}else{const v=x(B,w,O);O+=v.byteLength,A.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,A.push(a.imageBufferViews[C]),O%8){const B=8-O%8;O+=B,A.push(new Uint8Array(B))}}if(a.otherBufferViews.has(l))for(const C of a.otherBufferViews.get(l))n.bufferViews.push({buffer:w,byteOffset:O,byteLength:C.byteLength}),a.otherBufferViewsIndexMap.set(C,n.bufferViews.length-1),O+=C.byteLength,A.push(C);if(O){let C;t.format===me.GLB?C=He:(C=a.bufferURIGenerator.createURI(l,"bin"),T.uri=C),T.byteLength=O,a.assignResourceURI(C,D.concat(A),!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()!==Be.AlphaMode.OPAQUE&&(T.alphaMode=l.getAlphaMode()),l.getAlphaMode()===Be.AlphaMode.MASK&&(T.alphaCutoff=l.getAlphaCutoff()),l.getDoubleSided()&&(T.doubleSided=!0),T.pbrMetallicRoughness={},L.eq(l.getBaseColorFactor(),[1,1,1,1])||(T.pbrMetallicRoughness.baseColorFactor=l.getBaseColorFactor()),L.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 y=l.getBaseColorTexture(),E=l.getBaseColorTextureInfo();T.pbrMetallicRoughness.baseColorTexture=a.createTextureInfoDef(y,E)}if(l.getEmissiveTexture()){const y=l.getEmissiveTexture(),E=l.getEmissiveTextureInfo();T.emissiveTexture=a.createTextureInfoDef(y,E)}if(l.getNormalTexture()){const y=l.getNormalTexture(),E=l.getNormalTextureInfo(),N=a.createTextureInfoDef(y,E);l.getNormalScale()!==1&&(N.scale=l.getNormalScale()),T.normalTexture=N}if(l.getOcclusionTexture()){const y=l.getOcclusionTexture(),E=l.getOcclusionTextureInfo(),N=a.createTextureInfoDef(y,E);l.getOcclusionStrength()!==1&&(N.strength=l.getOcclusionStrength()),T.occlusionTexture=N}if(l.getMetallicRoughnessTexture()){const y=l.getMetallicRoughnessTexture(),E=l.getMetallicRoughnessTextureInfo();T.pbrMetallicRoughness.metallicRoughnessTexture=a.createTextureInfoDef(y,E)}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 y=null;return T.primitives=l.listPrimitives().map(E=>{const N={attributes:{}};N.mode=E.getMode();const f=E.getMaterial();f&&(N.material=a.materialIndexMap.get(f)),Object.keys(E.getExtras()).length&&(N.extras=E.getExtras());const d=E.getIndices();d&&(N.indices=a.accessorIndexMap.get(d));for(const R of E.listSemantics())N.attributes[R]=a.accessorIndexMap.get(E.getAttribute(R));for(const R of E.listTargets()){const A={};for(const w of R.listSemantics())A[w]=a.accessorIndexMap.get(R.getAttribute(w));N.targets=N.targets||[],N.targets.push(A)}return E.listTargets().length&&!y&&(y=E.listTargets().map(R=>R.getName())),N}),l.getWeights().length&&(T.weights=l.getWeights()),y&&(T.extras=T.extras||{},T.extras.targetNames=y),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===je.Type.PERSPECTIVE){T.perspective={znear:l.getZNear(),zfar:l.getZFar(),yfov:l.getYFov()};const y=l.getAspectRatio();y!==null&&(T.perspective.aspectRatio=y)}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 L.eq(l.getTranslation(),[0,0,0])||(T.translation=l.getTranslation()),L.eq(l.getRotation(),[0,0,0,1])||(T.rotation=l.getRotation()),L.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),y=l.getInverseBindMatrices();y&&(T.inverseBindMatrices=a.accessorIndexMap.get(y));const E=l.getSkeleton();return E&&(T.skeleton=a.nodeIndexMap.get(E)),T.joints=l.listJoints().map(N=>a.nodeIndexMap.get(N)),a.skinIndexMap.set(l,b),T}),s.listNodes().forEach((l,b)=>{const T=n.nodes[b],y=l.getMesh();y&&(T.mesh=a.meshIndexMap.get(y));const E=l.getCamera();E&&(T.camera=a.cameraIndexMap.get(E));const N=l.getSkin();N&&(T.skin=a.skinIndexMap.get(N)),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),y=new Map;return T.samplers=l.listSamplers().map((E,N)=>{const f=a.createPropertyDef(E);return f.input=a.accessorIndexMap.get(E.getInput()),f.output=a.accessorIndexMap.get(E.getOutput()),f.interpolation=E.getInterpolation(),y.set(E,N),f}),T.channels=l.listChannels().map(E=>{const N=a.createPropertyDef(E);return N.sampler=y.get(E.getSampler()),N.target={node:a.nodeIndexMap.get(E.getTargetNode()),path:E.getTargetPath()},N}),a.animationIndexMap.set(l,b),T}),n.scenes=s.listScenes().map((l,b)=>{const T=a.createPropertyDef(l);return T.nodes=l.listChildren().map(y=>a.nodeIndexMap.get(y)),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)),hr(n),o}}function hr(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 ft;(function(i){i[i.JSON=1313821514]="JSON",i[i.BIN=5130562]="BIN"})(ft||(ft={}));class gr{constructor(){this._logger=re.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=ct.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=ns(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),nr.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=>pr(t,s)))throw new Error("Cannot resolve external buffers with binaryToJSON().");if(r.images&&r.images.some(s=>dr(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===me.GLB&&e.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return lr.write(e,{format:t.format||me.GLTF,basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:W({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(e){const{json:t,resources:r}=await this.writeJSON(e,{format:me.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])),x=D.concat([p,g]);return s[s.length-1]+=x.byteLength,D.concat([D.toView(s),c,x])}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=`__${Wn()}.${ze.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:W({},e.json),resources:W({},e.resources)},t&&(e.json.images=t.map(s=>W({},s))),r&&(e.json.buffers=r.map(s=>W({},s))),e}_binaryToJSON(e){if(!ns(e))throw new Error("Invalid glTF 2.0 binary.");const t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==ft.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]!==ft.BIN)return{json:o,resources:{}};const u=c[0],g=D.toView(e,a+8,u);return{json:o,resources:{[He]:g}}}}function pr(i,e){return e.uri!==void 0&&!(e.uri in i.resources)}function dr(i,e){return e.uri!==void 0&&!(e.uri in i.resources)&&e.bufferView===void 0}function ns(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 Tr extends gr{constructor(e=Qe.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 Qe.resolve(e,t)}dirname(e){return Qe.dirname(e)}}const Te="GALACEAN_materials_remap";class Ds extends k{constructor(){super(...arguments);Q(this,"parentTypes",[h.MATERIAL]);Q(this,"propertyType");Q(this,"extensionName",Te)}init(){this.extensionName=Te,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)}}Q(Ds,"EXTENSION_NAME",Te);class vs extends P{constructor(){super(...arguments);Q(this,"extensionName","GALACEAN_materials_remap")}createGlTFRemapping(){return new Ds(this.document.getGraph())}read(t){return(t.jsonDoc.json.materials||[]).forEach((n,o)=>{if(n.extensions&&n.extensions[Te]){const a=this.createGlTFRemapping();t.materials[o].setExtension(Te,a);const c=n.extensions[Te];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(Te);if(n){const o=t.materialIndexMap.get(s),a=r.json.materials[o];a.extensions=a.extensions||{},a.extensions[Te]={refId:n.getRefId()}}}),this}}Q(vs,"EXTENSION_NAME","GALACEAN_materials_remap");const ue="GALACEAN_animation_event";class Fs extends k{constructor(){super(...arguments);Q(this,"parentTypes",[h.ANIMATION]);Q(this,"propertyType");Q(this,"extensionName",ue)}init(){this.extensionName=ue,this.propertyType="GlTFAnimationEvent"}getDefaults(){return Object.assign(super.getDefaults(),{events:{}})}getEvents(){return this.get("events")}setEvents(t){return this.set("events",t)}}Q(Fs,"EXTENSION_NAME",ue);class Us extends P{constructor(){super(...arguments);Q(this,"extensionName",ue);Q(this,"eventProperty")}createAnimationEvent(){return this.eventProperty=new Fs(this.document.getGraph()),this.eventProperty}read(t){return(t.jsonDoc.json.animations||[]).forEach((n,o)=>{if(n.extensions&&n.extensions[ue]){const a=this.createAnimationEvent();t.animations[o].setExtension(ue,a);const u=n.extensions[ue].events;u&&a.setEvents(u)}}),this}write(t){const r=t.jsonDoc;return this.document.getRoot().listAnimations().forEach(s=>{const n=s.getExtension(ue);if(n){const o=t.animationIndexMap.get(s),a=r.json.animations[o];a.extensions=a.extensions||{},a.extensions[ue]={events:n.getEvents()}}}),this}}Q(Us,"EXTENSION_NAME",ue);const xr=0,mr=0,Er=0,yr=2,Rr=0,Ir=163,Ar=166,Nr=0,Sr=2,Mr=1,_r=64,br=0;class wr{constructor(){this.vkFormat=br,this.typeSize=1,this.pixelWidth=0,this.pixelHeight=0,this.pixelDepth=0,this.layerCount=0,this.faceCount=1,this.supercompressionScheme=xr,this.levels=[],this.dataFormatDescriptor=[{vendorId:Er,descriptorType:mr,descriptorBlockSize:0,versionNumber:yr,colorModel:Rr,colorPrimaries:Mr,transferFunction:Sr,flags:Nr,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],this.keyValue={},this.globalData=null}}class Ke{constructor(e,t,r,s){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,r),this._littleEndian=s,this._offset=0}_nextUint8(){const e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){const e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){const e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){const e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian),r=e+2**32*t;return this._offset+=8,r}_nextInt32(){const e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){const t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){const r=this._offset;let s=0;for(;this._dataView.getUint8(this._offset)!==t&&s<e;)s++,this._offset++;return s<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+r,s)}}const q=[171,75,84,88,32,50,48,187,13,10,26,10];function rs(i){return new TextDecoder().decode(i)}function xt(i){const e=new Uint8Array(i.buffer,i.byteOffset,q.length);if(e[0]!==q[0]||e[1]!==q[1]||e[2]!==q[2]||e[3]!==q[3]||e[4]!==q[4]||e[5]!==q[5]||e[6]!==q[6]||e[7]!==q[7]||e[8]!==q[8]||e[9]!==q[9]||e[10]!==q[10]||e[11]!==q[11])throw new Error("Missing KTX 2.0 identifier.");const t=new wr,r=17*Uint32Array.BYTES_PER_ELEMENT,s=new Ke(i,q.length,r,!0);t.vkFormat=s._nextUint32(),t.typeSize=s._nextUint32(),t.pixelWidth=s._nextUint32(),t.pixelHeight=s._nextUint32(),t.pixelDepth=s._nextUint32(),t.layerCount=s._nextUint32(),t.faceCount=s._nextUint32();const n=s._nextUint32();t.supercompressionScheme=s._nextUint32();const o=s._nextUint32(),a=s._nextUint32(),c=s._nextUint32(),u=s._nextUint32(),g=s._nextUint64(),p=s._nextUint64(),x=n*3*8,I=new Ke(i,q.length+r,x,!0);for(let X=0;X<n;X++)t.levels.push({levelData:new Uint8Array(i.buffer,i.byteOffset+I._nextUint64(),I._nextUint64()),uncompressedByteLength:I._nextUint64()});const m=new Ke(i,o,a,!0),_={vendorId:m._skip(4)._nextUint16(),descriptorType:m._nextUint16(),versionNumber:m._nextUint16(),descriptorBlockSize:m._nextUint16(),colorModel:m._nextUint8(),colorPrimaries:m._nextUint8(),transferFunction:m._nextUint8(),flags:m._nextUint8(),texelBlockDimension:[m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8()],bytesPlane:[m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8()],samples:[]},M=6,l=4,b=(_.descriptorBlockSize/4-M)/l;for(let X=0;X<b;X++){const ee={bitOffset:m._nextUint16(),bitLength:m._nextUint8(),channelType:m._nextUint8(),samplePosition:[m._nextUint8(),m._nextUint8(),m._nextUint8(),m._nextUint8()],sampleLower:-1/0,sampleUpper:1/0};ee.channelType&_r?(ee.sampleLower=m._nextInt32(),ee.sampleUpper=m._nextInt32()):(ee.sampleLower=m._nextUint32(),ee.sampleUpper=m._nextUint32()),_.samples[X]=ee}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(_);const T=new Ke(i,c,u,!0);for(;T._offset<u;){const X=T._nextUint32(),ee=T._scan(X),pe=rs(ee);if(t.keyValue[pe]=T._nextUint8Array(X-ee.byteLength-1),pe.match(/^ktx/i)){const de=rs(t.keyValue[pe]);t.keyValue[pe]=de.substring(0,de.lastIndexOf("\0"))}const pt=X%4?4-X%4:0;T._skip(pt)}if(p<=0)return t;const y=new Ke(i,g,p,!0),E=y._nextUint16(),N=y._nextUint16(),f=y._nextUint32(),d=y._nextUint32(),R=y._nextUint32(),A=y._nextUint32(),w=[];for(let X=0;X<n;X++)w.push({imageFlags:y._nextUint32(),rgbSliceByteOffset:y._nextUint32(),rgbSliceByteLength:y._nextUint32(),alphaSliceByteOffset:y._nextUint32(),alphaSliceByteLength:y._nextUint32()});const O=g+y._offset,C=O+f,B=C+d,v=B+R,U=new Uint8Array(i.buffer,i.byteOffset+O,f),H=new Uint8Array(i.buffer,i.byteOffset+C,d),Z=new Uint8Array(i.buffer,i.byteOffset+B,R),K=new Uint8Array(i.buffer,i.byteOffset+v,A);return t.globalData={endpointCount:E,selectorCount:N,imageDescs:w,endpointsData:U,selectorsData:H,tablesData:Z,extendedData:K},t}const Ot="EXT_mesh_gpu_instancing",At="EXT_meshopt_compression",Cr="EXT_texture_webp",Or="EXT_texture_avif",Bs="KHR_draco_mesh_compression",Dt="KHR_lights_punctual",vt="KHR_materials_anisotropy",Ft="KHR_materials_clearcoat",Ut="KHR_materials_diffuse_transmission",Bt="KHR_materials_dispersion",Lt="KHR_materials_emissive_strength",jt="KHR_materials_ior",Pt="KHR_materials_iridescence",Vt="KHR_materials_pbrSpecularGlossiness",kt="KHR_materials_sheen",Gt="KHR_materials_specular",Ht="KHR_materials_transmission",zt="KHR_materials_unlit",$t="KHR_materials_volume",Pe="KHR_materials_variants",Dr="KHR_mesh_quantization",vr="KHR_texture_basisu",Xt="KHR_texture_transform",lt="KHR_xmp_json_ld",Nt="INSTANCE_ATTRIBUTE";class Ls extends k{init(){this.extensionName=Ot,this.propertyType="InstancedMesh",this.parentTypes=[h.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new oe})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:Nt})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}Ls.EXTENSION_NAME=Ot;const ye=Ot;class js extends P{constructor(...e){super(...e),this.extensionName=ye,this.provideTypes=[h.NODE],this.prewriteTypes=[h.ACCESSOR]}createInstancedMesh(){return new Ls(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((s,n)=>{if(!s.extensions||!s.extensions[ye])return;const o=s.extensions[ye],a=this.createInstancedMesh();for(const c in o.attributes)a.setAttribute(c,e.accessors[o.attributes[c]]);e.nodes[n].setExtension(ye,a)}),this}prewrite(e){e.accessorUsageGroupedByParent.add(Nt);for(const t of this.properties)for(const r of t.listAttributes())e.addAccessorToUsageGroup(r,Nt);return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listNodes().forEach(r=>{const s=r.getExtension(ye);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[ye]=a}}),this}}js.EXTENSION_NAME=ye;function ge(){return ge=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},ge.apply(null,arguments)}var tt;(function(i){i.QUANTIZE="quantize",i.FILTER="filter"})(tt||(tt={}));var Ge;(function(i){i.ATTRIBUTES="ATTRIBUTES",i.TRIANGLES="TRIANGLES",i.INDICES="INDICES"})(Ge||(Ge={}));var G;(function(i){i.NONE="NONE",i.OCTAHEDRAL="OCTAHEDRAL",i.QUATERNION="QUATERNION",i.EXPONENTIAL="EXPONENTIAL"})(G||(G={}));const{BYTE:Fr,SHORT:is,FLOAT:Ur}=S.ComponentType,{encodeNormalizedInt:os,decodeNormalizedInt:St}=L;function Br(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!==Ge.ATTRIBUTES)return o;if(s!==G.NONE){let a=i.getNormalized()?Lr(i):new Float32Array(o.array);switch(s){case G.EXPONENTIAL:o.byteStride=i.getElementSize()*4,o.componentType=Ur,o.normalized=!1,o.array=e.encodeFilterExp(a,i.getCount(),o.byteStride,n);break;case G.OCTAHEDRAL:o.byteStride=n>8?8:4,o.componentType=n>8?is:Fr,o.normalized=!0,a=i.getElementSize()===3?Pr(a):a,o.array=e.encodeFilterOct(a,i.getCount(),o.byteStride,n);break;case G.QUATERNION:o.byteStride=8,o.componentType=is,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=>St(c,i.getComponentType())),o.max=o.max.map(c=>St(c,i.getComponentType()))),o.normalized&&(o.min=o.min.map(c=>os(c,o.componentType)),o.max=o.max.map(c=>os(c,o.componentType)))}else o.byteStride%4&&(o.array=jr(o.array,i.getElementSize()),o.byteStride=o.array.byteLength/i.getCount());return o}function Lr(i){const e=i.getComponentType(),t=i.getArray(),r=new Float32Array(t.length);for(let s=0;s<t.length;s++)r[s]=St(t[s],e);return r}function jr(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 Pr(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 Vr(i,e){return e===le.BufferViewUsage.ELEMENT_ARRAY_BUFFER?i.listParents().some(r=>r instanceof Le&&r.getMode()===Le.Mode.TRIANGLES)?Ge.TRIANGLES:Ge.INDICES:Ge.ATTRIBUTES}function kr(i,e){const t=e.getGraph().listParentEdges(i).filter(r=>!(r.getParent()instanceof Os));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:G.NONE};if(s==="attributes"){if(n==="POSITION")return{filter:G.NONE};if(n==="TEXCOORD_0")return{filter:G.NONE};if(n.startsWith("JOINTS_"))return{filter:G.NONE};if(n.startsWith("WEIGHTS_"))return{filter:G.NONE};if(n==="NORMAL"||n==="TANGENT")return o?{filter:G.NONE}:{filter:G.OCTAHEDRAL,bits:8}}if(s==="output"){const a=Ps(i);return a==="rotation"?{filter:G.QUATERNION,bits:16}:a==="translation"?{filter:G.EXPONENTIAL,bits:12}:a==="scale"?{filter:G.EXPONENTIAL,bits:12}:{filter:G.NONE}}if(s==="input")return{filter:G.NONE};if(s==="inverseBindMatrices")return{filter:G.NONE}}return{filter:G.NONE}}function Ps(i){for(const e of i.listParents())if(e instanceof Xe){for(const t of e.listParents())if(t instanceof Ct)return t.getTargetPath()}return null}function Gr(i){return!i.extensions||!i.extensions[At]?!1:!!i.extensions[At].fallback}const Y=At,as={method:tt.QUANTIZE};class Kt extends P{constructor(...e){super(...e),this.extensionName=Y,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=as,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=ge({},as,e),this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${Y}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${Y}]: 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[Y])return;const o=s.extensions[Y],a=o.byteOffset||0,c=o.byteLength||0,u=o.count,g=o.byteStride,p=new Uint8Array(u*g),x=t.json.buffers[o.buffer],I=x.uri?t.resources[x.uri]:t.resources[He],m=D.toView(I,a,c);this._decoder.decodeGltfBuffer(p,u,g,m,o.mode,o.filter),e.bufferViews[n]=p})}_prereadPrimitives(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach(s=>{if(!s.extensions||!s.extensions[Y])return;const n=s.extensions[Y],o=e.buffers[n.buffer],a=e.buffers[s.buffer],c=t.json.buffers[s.buffer];Gr(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 S&&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 x of n.listParents(p)){if(x.propertyType===h.ROOT)continue;let I=u.get(p);return I===void 0&&u.set(p,I=c++),I}return-1};this._encoderFallbackBuffer=o,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(const p of this.document.getRoot().listAccessors()){if(Ps(p)==="weights"||p.getSparse())continue;const x=e.getAccessorUsage(p),I=e.accessorUsageGroupedByParent.has(x)?g(p):null,m=Vr(p,x),_=s.method===tt.FILTER?kr(p,this.document):{filter:G.NONE},M=Br(p,r,m,_),{array:l,byteStride:b}=M,T=p.getBuffer();if(!T)throw new Error(`${Y}: Missing buffer for accessor.`);const y=this.document.getRoot().listBuffers().indexOf(T),E=[x,I,m,_.filter,b,y].join(":");let N=this._encoderBufferViews[E],f=this._encoderBufferViewData[E],d=this._encoderBufferViewAccessors[E];(!N||!f)&&(d=this._encoderBufferViewAccessors[E]=[],f=this._encoderBufferViewData[E]=[],N=this._encoderBufferViews[E]={buffer:a,target:le.USAGE_TO_TARGET[x],byteOffset:0,byteLength:0,byteStride:x===le.BufferViewUsage.ARRAY_BUFFER?b:void 0,extensions:{[Y]:{buffer:y,byteOffset:0,byteLength:0,mode:m,filter:_.filter!==G.NONE?_.filter:void 0,byteStride:b,count:0}}});const R=e.createAccessorDef(p);R.componentType=M.componentType,R.normalized=M.normalized,R.byteOffset=N.byteLength,R.min&&M.min&&(R.min=M.min),R.max&&M.max&&(R.max=M.max),e.accessorIndexMap.set(p,t.accessors.length),t.accessors.push(R),d.push(R),f.push(new Uint8Array(l.buffer,l.byteOffset,l.byteLength)),N.byteLength+=l.byteLength,N.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[Y].buffer],a=e.otherBufferViews.get(o)||[],{count:c,byteStride:u,mode:g}=s.extensions[Y],p=D.concat(n),x=t.encodeGltfBuffer(p,c,u,g),I=D.pad(x);s.extensions[Y].byteLength=x.byteLength,n.length=0,n.push(I),a.push(I),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 m of g)m.bufferView=u;const p=e.jsonDoc.json.bufferViews[u],x=p.byteOffset||0;Object.assign(p,a),p.byteOffset=t;const I=p.extensions[Y];I.byteOffset=x,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={[Y]:{fallback:!0}},r.dispose(),this}}Kt.EXTENSION_NAME=Y;Kt.EncoderMethod=tt;const qe=Or;class Hr{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=cs(t,0);if(!r)return null;let s=r.end;for(;r=cs(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 Vs extends P{constructor(...e){super(...e),this.extensionName=qe,this.prereadTypes=[h.TEXTURE]}static register(){fe.registerFormat("image/avif",new Hr)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(r=>{r.extensions&&r.extensions[qe]&&(r.source=r.extensions[qe].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[qe]={source:o.source},delete o.source)})}}),this}}Vs.EXTENSION_NAME=qe;function cs(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 Ye=Cr;class zr{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),x=1+((u&63)<<8|c),I=1+((p&15)<<10|g<<2|(u&192)>>6);return[x,I]}n+=8+a+a%2}return null}getChannels(e){return 4}}class ks extends P{constructor(...e){super(...e),this.extensionName=Ye,this.prereadTypes=[h.TEXTURE]}static register(){fe.registerFormat("image/webp",new zr)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(r=>{r.extensions&&r.extensions[Ye]&&(r.source=r.extensions[Ye].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[Ye]={source:o.source},delete o.source)})}}),this}}ks.EXTENSION_NAME=Ye;const us=Bs;let $,Gs,Hs;function $r(i,e){const t=new $.DecoderBuffer;try{if(t.Init(e,e.length),i.GetEncodedGeometryType(t)!==$.TRIANGULAR_MESH)throw new Error(`[${us}] Unknown geometry type.`);const s=new $.Mesh;if(!i.DecodeBufferToMesh(t,s).ok()||s.ptr===0)throw new Error(`[${us}] Decoding failure.`);return s}finally{$.destroy(t)}}function Xr(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 Kr(i,e,t,r){const s=Hs[r.componentType],n=Gs[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 qr(i){$=i,Gs={[S.ComponentType.FLOAT]:Float32Array,[S.ComponentType.UNSIGNED_INT]:Uint32Array,[S.ComponentType.UNSIGNED_SHORT]:Uint16Array,[S.ComponentType.UNSIGNED_BYTE]:Uint8Array,[S.ComponentType.SHORT]:Int16Array,[S.ComponentType.BYTE]:Int8Array},Hs={[S.ComponentType.FLOAT]:$.DT_FLOAT32,[S.ComponentType.UNSIGNED_INT]:$.DT_UINT32,[S.ComponentType.UNSIGNED_SHORT]:$.DT_UINT16,[S.ComponentType.UNSIGNED_BYTE]:$.DT_UINT8,[S.ComponentType.SHORT]:$.DT_INT16,[S.ComponentType.BYTE]:$.DT_INT8}}let se;var st;(function(i){i[i.EDGEBREAKER=1]="EDGEBREAKER",i[i.SEQUENTIAL=0]="SEQUENTIAL"})(st||(st={}));var ne;(function(i){i.POSITION="POSITION",i.NORMAL="NORMAL",i.COLOR="COLOR",i.TEX_COORD="TEX_COORD",i.GENERIC="GENERIC"})(ne||(ne={}));const zs={[ne.POSITION]:14,[ne.NORMAL]:10,[ne.COLOR]:8,[ne.TEX_COORD]:12,[ne.GENERIC]:12},fs={decodeSpeed:5,encodeSpeed:5,method:st.EDGEBREAKER,quantizationBits:zs,quantizationVolume:"mesh"};function Yr(i){se=i}function Wr(i,e=fs){const t=ge({},fs,e);t.quantizationBits=ge({},zs,e.quantizationBits);const r=new se.MeshBuilder,s=new se.Mesh,n=new se.ExpertEncoder(s),o={},a=new se.DracoInt8Array,c=i.listTargets().length>0;let u=!1;for(const _ of i.listSemantics()){const M=i.getAttribute(_);if(M.getSparse()){u=!0;continue}const l=Jr(_),b=Qr(r,M.getComponentType(),s,se[l],M.getCount(),M.getElementSize(),M.getArray());if(b===-1)throw new Error(`Error compressing "${_}" attribute.`);if(o[_]=b,t.quantizationVolume==="mesh"||_!=="POSITION")n.SetAttributeQuantization(b,t.quantizationBits[l]);else if(typeof t.quantizationVolume=="object"){const{quantizationVolume:T}=t,y=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,y)}else throw new Error("Invalid quantization volume state.")}const g=i.getIndices();if(!g)throw new Mt("Primitive must have indices.");r.AddFacesToMesh(s,g.getCount()/3,g.getArray()),n.SetSpeedOptions(t.encodeSpeed,t.decodeSpeed),n.SetTrackEncodedProperties(!0),t.method===st.SEQUENTIAL||c||u?n.SetEncodingMethod(se.MESH_SEQUENTIAL_ENCODING):n.SetEncodingMethod(se.MESH_EDGEBREAKER_ENCODING);const p=n.EncodeToDracoBuffer(!(c||u),a);if(p<=0)throw new Mt("Error applying Draco compression.");const x=new Uint8Array(p);for(let _=0;_<p;++_)x[_]=a.GetValue(_);const I=n.GetNumberOfEncodedPoints(),m=n.GetNumberOfEncodedFaces()*3;return se.destroy(a),se.destroy(s),se.destroy(r),se.destroy(n),{numVertices:I,numIndices:m,data:x,attributeIDs:o}}function Jr(i){return i==="POSITION"?ne.POSITION:i==="NORMAL"?ne.NORMAL:i.startsWith("COLOR_")?ne.COLOR:i.startsWith("TEXCOORD_")?ne.TEX_COORD:ne.GENERIC}function Qr(i,e,t,r,s,n,o){switch(e){case S.ComponentType.UNSIGNED_BYTE:return i.AddUInt8Attribute(t,r,s,n,o);case S.ComponentType.BYTE:return i.AddInt8Attribute(t,r,s,n,o);case S.ComponentType.UNSIGNED_SHORT:return i.AddUInt16Attribute(t,r,s,n,o);case S.ComponentType.SHORT:return i.AddInt16Attribute(t,r,s,n,o);case S.ComponentType.UNSIGNED_INT:return i.AddUInt32Attribute(t,r,s,n,o);case S.ComponentType.FLOAT:return i.AddFloatAttribute(t,r,s,n,o);default:throw new Error(`Unexpected component type, "${e}".`)}}class Mt extends Error{}const z=Bs;class qt extends P{constructor(...e){super(...e),this.extensionName=z,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,qr(this._decoderModule)),e==="draco3d.encoder"&&(this._encoderModule=t,Yr(this._encoderModule)),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error(`[${z}] 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[z])continue;const c=a.extensions[z];let[u,g]=s.get(c.bufferView)||[];if(!g||!u){const p=r.json.bufferViews[c.bufferView],x=r.json.buffers[p.buffer],I=x.uri?r.resources[x.uri]:r.resources[He],m=p.byteOffset||0,_=p.byteLength,M=D.toView(I,m,_);u=new this._decoderModule.Decoder,g=$r(u,M),s.set(c.bufferView,[u,g]),t.debug(`[${z}] Decompressed ${M.byteLength} bytes.`)}for(const p in a.attributes){const x=e.jsonDoc.json.accessors[a.attributes[p]],I=u.GetAttributeByUniqueId(g,c.attributes[p]),m=Kr(u,g,I,x);e.accessors[a.attributes[p]].setArray(m)}a.indices!==void 0&&e.accessors[a.indices].setArray(Xr(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(`[${z}] Please install extension dependency, "draco3d.encoder".`);const r=this.document.getLogger();r.debug(`[${z}] Compression options: ${JSON.stringify(this._encoderOptions)}`);const s=Zr(this.document),n=new Map;let o="mesh";this._encoderOptions.quantizationVolume==="scene"&&(this.document.getRoot().listScenes().length!==1?r.warn(`[${z}]: quantizationVolume=scene requires exactly 1 scene.`):o=Bn(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=Wr(a,ge({},this._encoderOptions,{quantizationVolume:o}))}catch(m){if(m instanceof Mt){r.warn(`[${z}]: ${m.message} Skipping primitive compression.`);continue}throw m}n.set(c,p);const x=e.createAccessorDef(u);x.count=p.numIndices,e.accessorIndexMap.set(u,g.length),g.push(x),p.numVertices>65534&&x.componentType!==S.ComponentType.UNSIGNED_INT&&(x.componentType=S.ComponentType.UNSIGNED_INT);for(const m of a.listSemantics()){const _=a.getAttribute(m);if(p.attributeIDs[m]===void 0)continue;const M=e.createAccessorDef(_);M.count=p.numVertices,e.accessorIndexMap.set(_,g.length),g.push(M)}const I=a.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];e.otherBufferViews.has(I)||e.otherBufferViews.set(I,[]),e.otherBufferViews.get(I).push(p.data)}return r.debug(`[${z}] Compressed ${s.size} primitives.`),e.extensionData[z]={primitiveHashMap:s,primitiveEncodingMap:n},this}write(e){const t=e.extensionData[z];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[z]={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!==z),r.extensionsRequired=(r.extensionsRequired||[]).filter(s=>s!==z)}return this}}qt.EXTENSION_NAME=z;qt.EncoderMethod=st;function Zr(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 x of p.listPrimitives())x.getIndices()?x.getMode()!==Le.Mode.TRIANGLES?(r.add(x),n++):t.add(x):(r.add(x),s++);s>0&&e.warn(`[${z}] Skipping Draco compression of ${s} non-indexed primitives.`),n>0&&e.warn(`[${z}] 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 x=ls(p,a);if(u.has(x)){g.set(p,x);continue}if(c.has(p.getIndices())){const I=p.getIndices(),m=I.clone();a.set(m,i.getRoot().listAccessors().length-1),p.swap(I,m)}for(const I of p.listAttributes())if(c.has(I)){const m=I.clone();a.set(m,i.getRoot().listAccessors().length-1),p.swap(I,m)}x=ls(p,a),u.add(x),g.set(p,x),c.set(p.getIndices(),x);for(const I of p.listAttributes())c.set(I,x)}for(const p of Array.from(c.keys())){const x=new Set(p.listParents().map(I=>I.propertyType));if(x.size!==2||!x.has(h.PRIMITIVE)||!x.has(h.ROOT))throw new Error(`[${z}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const p of Array.from(t)){const x=g.get(p),I=p.getIndices();if(c.get(I)!==x||p.listAttributes().some(m=>c.get(m)!==x))throw new Error(`[${z}] Draco primitives must share all, or no, accessors.`)}for(const p of Array.from(r)){const x=p.getIndices();if(c.has(x)||p.listAttributes().some(I=>c.has(I)))throw new Error(`[${z}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return g}function ls(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 $e extends k{init(){this.extensionName=Dt,this.propertyType="Light",this.parentTypes=[h.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:$e.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)}}$e.EXTENSION_NAME=Dt;$e.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};const ae=Dt;class $s extends P{constructor(...e){super(...e),this.extensionName=ae}createLight(e=""){return new $e(this.document.getGraph(),e)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ae])return this;const n=(t.json.extensions[ae].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[ae])return;const c=o.extensions[ae];e.nodes[a].setExtension(ae,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()};L.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()===$e.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(ae);if(o){const a=e.nodeIndexMap.get(n),c=t.json.nodes[a];c.extensions=c.extensions||{},c.extensions[ae]={light:s.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[ae]={lights:r},this}}$s.EXTENSION_NAME=ae;const{R:ei,G:ti,B:si}=ie;class Xs extends k{init(){this.extensionName=vt,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:ei|ti|si})}}Xs.EXTENSION_NAME=vt;const Re=vt;class Ks extends P{constructor(...e){super(...e),this.extensionName=Re,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createAnisotropy(){return new Xs(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[Re]){const a=this.createAnisotropy();e.materials[o].setExtension(Re,a);const c=n.extensions[Re];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(Re);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Re]={};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=Re;const{R:hs,G:gs,B:ni}=ie;class qs extends k{init(){this.extensionName=Ft,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:hs})}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:gs})}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:hs|gs|ni})}}qs.EXTENSION_NAME=Ft;const Ie=Ft;class Ys extends P{constructor(...e){super(...e),this.extensionName=Ie,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createClearcoat(){return new qs(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[Ie]){const a=this.createClearcoat();e.materials[o].setExtension(Ie,a);const c=n.extensions[Ie];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(Ie);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Ie]={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}}Ys.EXTENSION_NAME=Ie;const{R:ri,G:ii,B:oi,A:ai}=ie;class Ws extends k{init(){this.extensionName=Ut,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:ai})}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:ri|ii|oi})}}Ws.EXTENSION_NAME=Ut;const Ae=Ut;class Js extends P{constructor(...e){super(...e),this.extensionName=Ae}createDiffuseTransmission(){return new Ws(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[Ae]){const a=this.createDiffuseTransmission();e.materials[o].setExtension(Ae,a);const c=n.extensions[Ae];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(Ae);if(!s)continue;const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Ae]={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}}Js.EXTENSION_NAME=Ae;class Qs extends k{init(){this.extensionName=Bt,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)}}Qs.EXTENSION_NAME=Bt;const Ne=Bt;class Zs extends P{constructor(...e){super(...e),this.extensionName=Ne,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createDispersion(){return new Qs(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[Ne]){const o=this.createDispersion();e.materials[n].setExtension(Ne,o);const a=s.extensions[Ne];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(Ne);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Ne]={dispersion:s.getDispersion()}}}),this}}Zs.EXTENSION_NAME=Ne;class en extends k{init(){this.extensionName=Lt,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)}}en.EXTENSION_NAME=Lt;const Se=Lt;class tn extends P{constructor(...e){super(...e),this.extensionName=Se,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createEmissiveStrength(){return new en(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[Se]){const o=this.createEmissiveStrength();e.materials[n].setExtension(Se,o);const a=s.extensions[Se];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(Se);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Se]={emissiveStrength:s.getEmissiveStrength()}}}),this}}tn.EXTENSION_NAME=Se;class sn extends k{init(){this.extensionName=jt,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)}}sn.EXTENSION_NAME=jt;const Me=jt;class nn extends P{constructor(...e){super(...e),this.extensionName=Me,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createIOR(){return new sn(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[Me]){const o=this.createIOR();e.materials[n].setExtension(Me,o);const a=s.extensions[Me];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(Me);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Me]={ior:s.getIOR()}}}),this}}nn.EXTENSION_NAME=Me;const{R:ci,G:ui}=ie;class rn extends k{init(){this.extensionName=Pt,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:ci})}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:ui})}}rn.EXTENSION_NAME=Pt;const _e=Pt;class on extends P{constructor(...e){super(...e),this.extensionName=_e,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createIridescence(){return new rn(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[_e]){const a=this.createIridescence();e.materials[o].setExtension(_e,a);const c=n.extensions[_e];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(_e);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[_e]={};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}}on.EXTENSION_NAME=_e;const{R:ps,G:ds,B:Ts,A:xs}=ie;class an extends k{init(){this.extensionName=Vt,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:ps|ds|Ts|xs,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:ps|ds|Ts|xs})}}an.EXTENSION_NAME=Vt;const be=Vt;class cn extends P{constructor(...e){super(...e),this.extensionName=be,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createPBRSpecularGlossiness(){return new an(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[be]){const a=this.createPBRSpecularGlossiness();e.materials[o].setExtension(be,a);const c=n.extensions[be];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(be);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[be]={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}}cn.EXTENSION_NAME=be;const{R:fi,G:li,B:hi,A:gi}=ie;class un extends k{init(){this.extensionName=kt,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:fi|li|hi,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:gi})}}un.EXTENSION_NAME=kt;const we=kt;class fn extends P{constructor(...e){super(...e),this.extensionName=we,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createSheen(){return new un(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.createSheen();e.materials[o].setExtension(we,a);const c=n.extensions[we];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(we);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[we]={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}}fn.EXTENSION_NAME=we;const{R:pi,G:di,B:Ti,A:xi}=ie;class ln extends k{init(){this.extensionName=Gt,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:xi})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:pi|di|Ti,isColor:!0})}}ln.EXTENSION_NAME=Gt;const Ce=Gt;class hn extends P{constructor(...e){super(...e),this.extensionName=Ce,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createSpecular(){return new ln(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[Ce]){const a=this.createSpecular();e.materials[o].setExtension(Ce,a);const c=n.extensions[Ce];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(Ce);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Ce]={};if(s.getSpecularFactor()!==1&&(a.specularFactor=s.getSpecularFactor()),L.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}}hn.EXTENSION_NAME=Ce;const{R:mi}=ie;class gn extends k{init(){this.extensionName=Ht,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:mi})}}gn.EXTENSION_NAME=Ht;const Oe=Ht;class pn extends P{constructor(...e){super(...e),this.extensionName=Oe,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createTransmission(){return new gn(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[Oe]){const a=this.createTransmission();e.materials[o].setExtension(Oe,a);const c=n.extensions[Oe];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(Oe);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Oe]={transmissionFactor:s.getTransmissionFactor()};if(s.getTransmissionTexture()){const c=s.getTransmissionTexture(),u=s.getTransmissionTextureInfo();a.transmissionTexture=e.createTextureInfoDef(c,u)}}}),this}}pn.EXTENSION_NAME=Oe;class dn extends k{init(){this.extensionName=zt,this.propertyType="Unlit",this.parentTypes=[h.MATERIAL]}}dn.EXTENSION_NAME=zt;const Ve=zt;class Tn extends P{constructor(...e){super(...e),this.extensionName=Ve,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createUnlit(){return new dn(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[Ve]&&e.materials[s].setExtension(Ve,this.createUnlit())}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{if(r.getExtension(Ve)){const s=e.materialIndexMap.get(r),n=t.json.materials[s];n.extensions=n.extensions||{},n.extensions[Ve]={}}}),this}}Tn.EXTENSION_NAME=Ve;class xn extends k{init(){this.extensionName=Pe,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new V})}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")}}xn.EXTENSION_NAME=Pe;class mn extends k{init(){this.extensionName=Pe,this.propertyType="MappingList",this.parentTypes=[h.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new V})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}}mn.EXTENSION_NAME=Pe;class _t extends k{init(){this.extensionName=Pe,this.propertyType="Variant",this.parentTypes=["MappingList"]}}_t.EXTENSION_NAME=Pe;const ce=Pe;class En extends P{constructor(...e){super(...e),this.extensionName=ce}createMappingList(){return new mn(this.document.getGraph())}createVariant(e=""){return new _t(this.document.getGraph(),e)}createMapping(){return new xn(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter(e=>e instanceof _t)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ce])return this;const n=(t.json.extensions[ce].variants||[]).map(a=>this.createVariant().setName(a.name||""));return(t.json.meshes||[]).forEach((a,c)=>{const u=e.meshes[c];(a.primitives||[]).forEach((p,x)=>{if(!p.extensions||!p.extensions[ce])return;const I=this.createMappingList(),m=p.extensions[ce];for(const _ of m.mappings){const M=this.createMapping();_.material!==void 0&&M.setMaterial(e.materials[_.material]);for(const l of _.variants||[])M.addVariant(n[l]);I.addMapping(M)}u.listPrimitives()[x].setExtension(ce,I)})}),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(ce);if(!g)return;const p=e.jsonDoc.json.meshes[a].primitives[u],x=g.listMappings().map(I=>{const m=e.createPropertyDef(I),_=I.getMaterial();return _&&(m.material=e.materialIndexMap.get(_)),m.variants=I.listVariants().map(M=>n.get(M)),m});p.extensions=p.extensions||{},p.extensions[ce]={mappings:x}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[ce]={variants:s},this}}En.EXTENSION_NAME=ce;const{G:Ei}=ie;class yn extends k{init(){this.extensionName=$t,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:Ei})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}}yn.EXTENSION_NAME=$t;const De=$t;class Rn extends P{constructor(...e){super(...e),this.extensionName=De,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createVolume(){return new yn(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[De]){const a=this.createVolume();e.materials[o].setExtension(De,a);const c=n.extensions[De];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(De);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[De]={};if(s.getThicknessFactor()>0&&(a.thicknessFactor=s.getThicknessFactor()),Number.isFinite(s.getAttenuationDistance())&&(a.attenuationDistance=s.getAttenuationDistance()),L.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}}Rn.EXTENSION_NAME=De;const In=Dr;class An extends P{constructor(...e){super(...e),this.extensionName=In}read(e){return this}write(e){return this}}An.EXTENSION_NAME=In;const We=vr;class yi{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=xt(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){const r=xt(e).dataFormatDescriptor[0];if(r.colorModel===Ir)return r.samples.length===2&&(r.samples[1].channelType&15)===15?4:3;if(r.colorModel===Ar)return(r.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${r.colorModel}".`)}getVRAMByteLength(e){const t=xt(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 Nn extends P{constructor(...e){super(...e),this.extensionName=We,this.prereadTypes=[h.TEXTURE]}static register(){fe.registerFormat("image/ktx2",new yi)}preread(e){return e.jsonDoc.json.textures.forEach(t=>{if(t.extensions&&t.extensions[We]){const r=t.extensions[We];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[We]={source:n.source},delete n.source)})}}),this}}Nn.EXTENSION_NAME=We;class Sn extends k{init(){this.extensionName=Xt,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)}}Sn.EXTENSION_NAME=Xt;const ve=Xt;class Mn extends P{constructor(...e){super(...e),this.extensionName=ve}createTransform(){return new Sn(this.document.getGraph())}read(e){for(const[t,r]of Array.from(e.textureInfos.entries())){if(!r.extensions||!r.extensions[ve])continue;const s=this.createTransform(),n=r.extensions[ve];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(ve,s)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[r,s]of t){const n=r.getExtension(ve);if(!n)continue;s.extensions=s.extensions||{};const o={},a=L.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[ve]=o}return this}}Mn.EXTENSION_NAME=ve;const Ri=[h.ROOT,h.SCENE,h.NODE,h.MESH,h.MATERIAL,h.TEXTURE,h.ANIMATION];class _n extends k{init(){this.extensionName=lt,this.propertyType="Packet",this.parentTypes=Ri}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",ge({},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=ge({},this.get("properties"));return t?r[e]=t:delete r[e],this.set("properties",r)}toJSONLD(){const e=mt(this.get("context")),t=mt(this.get("properties"));return ge({"@context":e},t)}fromJSONLD(e){e=mt(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(`${lt}: Missing context for term, "${e}".`)}}_n.EXTENSION_NAME=lt;function mt(i){return JSON.parse(JSON.stringify(i))}const he=lt;class bn extends P{constructor(...e){super(...e),this.extensionName=he}createPacket(){return new _n(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){var t;const r=(t=e.jsonDoc.json.extensions)==null?void 0:t[he];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 x=g[p];if(x.extensions&&x.extensions[he]){const I=x.extensions[he];c[u][p].setExtension(he,o[I.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(`[${he}]: Unsupported parent property, "${n.propertyType}"`);break}o&&(o.extensions=o.extensions||{},o.extensions[he]={packet:r.length-1})}}return r.length>0&&(t.extensions=t.extensions||{},t.extensions[he]={packets:r}),this}}bn.EXTENSION_NAME=he;const Ii=[qt,$s,Ks,Ys,Js,Zs,tn,nn,on,cn,hn,fn,pn,Tn,En,Rn,An,Nn,Mn,bn],Ai=[js,Kt,Vs,ks,...Ii],wn=new Tr;let ms=!1;async function Ni(){ms||(await Yt.ready,await Wt.ready,wn.registerExtensions([...Ai,vs,Us]).registerDependencies({"meshopt.decoder":Yt,"meshopt.encoder":Wt}),ms=!0)}const bi=Object.freeze(Object.defineProperty({__proto__:null,initGlTFIO:Ni,io:wn},Symbol.toStringTag,{value:"Module"}));export{S as A,D as B,_i as C,Ze as D,Kt as E,me as F,vs as G,An as K,L as M,_s as N,Le as P,Os as R,bs as S,Cs as T,h as a,Ct as b,j as c,k as d,Be as e,er as f,Nn as g,Us as h,wn as i,bi as j,Wn as u};
@@ -0,0 +1 @@
1
+ import{C,D as s,F as l,H as c,P as S,a as d,S as J}from"./PhysicsStore-c283b2be.js";import"./index-1e23212d.js";import"./index-92830754.js";import"./Component-746be670.js";import"./postmen-9e1e15bd.js";import"./FormItemArray-a2f72cf1.js";import"./Accordion-930aedee.js";import"./IconEdit-2c768a0a.js";export{C as CharacterControllerComponent,s as DynamicColliderComponent,l as FixedJointComponent,c as HingeJointComponent,S as PhysicsStore,d as SpringJointComponent,J as StaticColliderComponent};
@@ -0,0 +1,31 @@
1
+ import{aH as q,aO as b,b3 as S,aC as n,b8 as w,b9 as De,ex as G,ey as Oe,aP as Ye,ez as it,aT as se,aX as st,eA as at}from"./index-1e23212d.js";import{C as lt,M as ct}from"./Menu-0a7dbec0.js";/**
2
+ * @license @tabler/icons-react v3.17.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 ut=q("outline","zoom-reset","IconZoomReset",[["path",{d:"M21 21l-6 -6",key:"svg-0"}],["path",{d:"M3.268 12.043a7.017 7.017 0 0 0 6.634 4.957a7.012 7.012 0 0 0 7.043 -6.131a7 7 0 0 0 -5.314 -7.672a7.021 7.021 0 0 0 -8.241 4.403",key:"svg-1"}],["path",{d:"M3 4v4h4",key:"svg-2"}]]);/**
7
+ * @license @tabler/icons-react v3.17.0 - MIT
8
+ *
9
+ * This source code is licensed under the MIT license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */var dt=q("filled","circle-plus-filled","IconCirclePlusFilled",[["path",{d:"M4.929 4.929a10 10 0 1 1 14.141 14.141a10 10 0 0 1 -14.14 -14.14zm8.071 4.071a1 1 0 1 0 -2 0v2h-2a1 1 0 1 0 0 2h2v2a1 1 0 1 0 2 0v-2h2a1 1 0 1 0 0 -2h-2v-2z",key:"svg-0"}]]);/**
12
+ * @license @tabler/icons-react v3.17.0 - MIT
13
+ *
14
+ * This source code is licensed under the MIT license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */var xt=q("filled","circle-x-filled","IconCircleXFilled",[["path",{d:"M17 3.34a10 10 0 1 1 -14.995 8.984l-.005 -.324l.005 -.324a10 10 0 0 1 14.995 -8.336zm-6.489 5.8a1 1 0 0 0 -1.218 1.567l1.292 1.293l-1.292 1.293l-.083 .094a1 1 0 0 0 1.497 1.32l1.293 -1.292l1.293 1.292l.094 .083a1 1 0 0 0 1.32 -1.497l-1.292 -1.293l1.292 -1.293l.083 -.094a1 1 0 0 0 -1.497 -1.32l-1.293 1.292l-1.293 -1.292l-.094 -.083z",key:"svg-0"}]]);/**
17
+ * @license @tabler/icons-react v3.17.0 - MIT
18
+ *
19
+ * This source code is licensed under the MIT license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */var ht=q("filled","player-play-filled","IconPlayerPlayFilled",[["path",{d:"M6 4v16a1 1 0 0 0 1.524 .852l13 -8a1 1 0 0 0 0 -1.704l-13 -8a1 1 0 0 0 -1.524 .852z",key:"svg-0"}]]);/**
22
+ * @license @tabler/icons-react v3.17.0 - MIT
23
+ *
24
+ * This source code is licensed under the MIT license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */var yt=q("filled","zoom-in-filled","IconZoomInFilled",[["path",{d:"M14 3.072a8 8 0 0 1 2.617 11.424l4.944 4.943a1.5 1.5 0 0 1 -2.008 2.225l-.114 -.103l-4.943 -4.944a8 8 0 0 1 -12.49 -6.332l-.006 -.285l.005 -.285a8 8 0 0 1 11.995 -6.643zm-4 2.928a1 1 0 0 0 -.993 .883l-.007 .117v2h-2l-.117 .007a1 1 0 0 0 0 1.986l.117 .007h2v2l.007 .117a1 1 0 0 0 1.986 0l.007 -.117v-2h2l.117 -.007a1 1 0 0 0 0 -1.986l-.117 -.007h-2v-2l-.007 -.117a1 1 0 0 0 -.993 -.883z",key:"svg-0"}]]);/**
27
+ * @license @tabler/icons-react v3.17.0 - MIT
28
+ *
29
+ * This source code is licensed under the MIT license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */var ft=q("filled","zoom-out-filled","IconZoomOutFilled",[["path",{d:"M14 3.072a8 8 0 0 1 2.617 11.424l4.944 4.943a1.5 1.5 0 0 1 -2.008 2.225l-.114 -.103l-4.943 -4.944a8 8 0 0 1 -12.49 -6.332l-.006 -.285l.005 -.285a8 8 0 0 1 11.995 -6.643zm-1 5.928h-6l-.117 .007a1 1 0 0 0 0 1.986l.117 .007h6l.117 -.007a1 1 0 0 0 0 -1.986l-.117 -.007z",key:"svg-0"}]]);function Fe(r,o){return r.map(t=>({point:{x:t.point.x/o,y:t.point.y/o},controlPoint:t.controlPoint?{x:t.controlPoint.x/o,y:t.controlPoint.y/o}:null}))}function Be(r,o=1,t,e){const l=Fe(r,o),a=l[0],x=l[l.length-1];let s=t!==void 0?`M ${t} ${a.point.y} L ${a.point.x} ${a.point.y}`:`M ${a.point.x} ${a.point.y}`;return s+=` C ${a.controlPoint.x} ${a.controlPoint.y}, ${l[1].controlPoint.x} ${l[1].controlPoint.y} ${l[1].point.x} ${l[1].point.y}`,s+=l.slice(2).map(u=>` S ${u.controlPoint.x} ${u.controlPoint.y}, ${u.point.x} ${u.point.y}`).join(""),e!==void 0&&(s+=` L ${e} ${x.point.y}`),s}function Ge(r,o=1,t,e){const l=Fe(r,o),a=l[0],x=l[l.length-1];let s=t!==void 0?`M ${t} ${a.point.y} L ${a.point.x} ${a.point.y}`:`M ${a.point.x} ${a.point.y}`;return s+=l.slice(1).map(u=>` L ${u.point.x} ${u.point.y}`).join(""),e!==void 0&&(s+=` L ${e} ${x.point.y}`),s}function ye(r,o="bezier"){if(r.length<=3&&(o="linear"),o==="linear")return r.map(s=>({point:s,controlPoint:null}));const[t,e,...l]=r,a=[{point:t,controlPoint:e}],x=l.length;for(let s=0;s<x;s+=2){const[u,f]=l.slice(s,s+2);a.push({point:f,controlPoint:u})}return a}function Xe(r,o="bezier"){if(o==="linear")return r.map(e=>e.point);const t=[];for(const e of r)t.length===0?t.push(e.point,e.controlPoint):t.push(e.controlPoint,e.point);return t}function fe(r,o,t,e=1){return r.map(l=>({x:l.x*o*e,y:-l.y*t*e}))}function gt(r,o,t,e=1){return r.map(l=>({x:l.x/o*e,y:-l.y/t*e}))}function pt(r){return{x:0,y:-Math.round(r/2)}}function de(r){if(r===0)return 1;let o=1;for(let t=2;t<=r;t++)o*=t;return o}function mt(r,o){if(r.length<2)throw new Error("At least 2 points are required to calculate the point on a linear curve");o=Math.max(0,Math.min(1,o));const t=r.length-1,e=Math.min(Math.floor(o*t),t-1),l=o*t-e,a=r[e],x=r[e+1];return{x:a.x+(x.x-a.x)*l,y:a.y+(x.y-a.y)*l}}function Pt(r,o){const t=r.length-1;let e=0,l=0;for(let a=0;a<=t;a++){const s=de(t)/(de(a)*de(t-a))*Math.pow(o,a)*Math.pow(1-o,t-a);e+=s*r[a].x,l+=s*r[a].y}return{x:e,y:l}}const ee=10,vt=5,$t=2,Ct=10,St=6,te=b("circle",{fill:"$green9",cursor:"pointer",transition:"r 0.2s ease",variants:{pointType:{main:{fill:"$orange9",'&[data-point-type="ring"]':{fill:"$orange4"}},control:{fill:"$green8",'&[data-point-type="ring"]':{fill:"$green4"}},placeholder:{fill:"$amber9",'&[data-point-type="ring"]':{fill:"$amber4"}}}},'&[data-point-type="hitpoint"]':{stroke:"transparent",fill:"transparent"},'&[data-point-type="ring"]':{fill:"$green4"}}),bt=b("g",{cursor:"grab",touchAction:"none","&:hover":{[`${te}[data-point-type="ring"]`]:{r:Ct},[`${te}[data-point-type="point"]`]:{r:St}}}),It=b("text",{fill:"$gray12",fontSize:"10px",pointerEvents:"none",userSelect:"none"}),Mt=b("rect",{fill:"$gray2",stroke:"$gray7",strokeWidth:1,rx:3,ry:3,pointerEvents:"none"});function xe(r){const{point:o,main:t,type:e="pivot",onPointChange:l,onHoverChange:a,getRoot:x,hoverLabel:s,pointClipPath:u}=r,f=S.useRef(l);f.current=l;const c=S.useRef(x);c.current=x;const g=S.useRef(),[$,A]=S.useState(!1),[E,I]=S.useState(!1);function m(P,p){g.current||(g.current=c.current().createSVGPoint()),g.current.x=P,g.current.y=p;const k=c.current().getScreenCTM();if(!k)return{x:0,y:0};const C=g.current.matrixTransform(k.inverse());return{x:C.x,y:C.y}}function h(P){var p;P.button===0&&(P.preventDefault(),P.stopPropagation(),(p=window.getSelection())==null||p.removeAllRanges(),$||A(!0))}return S.useEffect(()=>{if(!$)return;const P=()=>A(!1),p=k=>{k.preventDefault(),f.current(m(k.clientX,k.clientY))};return window.addEventListener("mouseup",P),window.addEventListener("mousemove",p),()=>{window.removeEventListener("mouseup",P),window.removeEventListener("mousemove",p)}},[$]),n.jsxs(bt,{onMouseDown:h,onMouseEnter:()=>{I(!0),a==null||a(!0)},onMouseLeave:()=>{I(!1),a==null||a(!1)},children:[s&&(E||$)&&n.jsxs(n.Fragment,{children:[n.jsx(Mt,{x:o.x-(s.length*6+8)/2,y:o.y-24,width:s.length*6+8,height:14}),n.jsx(It,{x:o.x,y:o.y-14,textAnchor:"middle",children:s})]}),n.jsxs("g",{style:u?{clipPath:u}:void 0,children:[n.jsx(te,{"data-point-type":"hitpoint",cx:o.x,cy:o.y,r:ee}),n.jsx(te,{"data-point-type":"ring",pointType:t?"main":"control",cx:o.x,cy:o.y,r:vt}),n.jsx(te,{"data-point-type":"point",pointType:t?"main":"control",type:e,cx:o.x,cy:o.y,r:$t})]})]})}const Ie=b("line",{stroke:"$gray5"});function kt(r){const{pointId:o,bezierPoint:t,onPointChange:e,onHoverChange:l,algo:a,doublePoint:x=!1,pointHoverLabel:s,pointClipPath:u,getRoot:f}=r,{point:c,controlPoint:g}=t,$=u?{clipPath:u}:void 0,A=a==="bezier"?{x:2*c.x-g.x,y:2*c.y-g.y}:null,E=h=>{const P=h.x-c.x,p=h.y-c.y;e(o,{point:h,controlPoint:a==="bezier"?{x:g.x+P,y:g.y+p}:null})},I=h=>{e(o,{point:c,controlPoint:h})},m=h=>{e(o,{point:c,controlPoint:{x:2*c.x-h.x,y:2*c.y-h.y}})};return n.jsxs(n.Fragment,{children:[a==="bezier"&&n.jsxs(n.Fragment,{children:[n.jsx(Ie,{strokeWidth:1,x1:c.x,y1:c.y,x2:g.x,y2:g.y,style:$}),x&&n.jsx(Ie,{strokeWidth:1,x1:c.x,y1:c.y,x2:A.x,y2:A.y,style:$})]}),n.jsx(xe,{type:"pivot",main:!0,point:c,getRoot:f,onPointChange:E,onHoverChange:h=>l==null?void 0:l(o,h),hoverLabel:s,pointClipPath:u}),a==="bezier"&&n.jsxs(n.Fragment,{children:[n.jsx(xe,{type:"control",point:g,getRoot:f,onPointChange:I,pointClipPath:u}),x&&n.jsx(xe,{type:"control",point:A,getRoot:f,onPointChange:m,pointClipPath:u})]})]})}const Me=b("path",{strokeWidth:1,stroke:"$orange10",fill:"none",variants:{hitline:{true:{strokeWidth:5,stroke:"transparent"}}}}),jt=b("path",{strokeWidth:1,stroke:"$orange6",fill:"none"}),Tt=b("circle",{fill:"$orange11",r:3,transition:"transform .1s ease",strokeWidth:1,stroke:"$orange12"});function wt(r){const{points:o,getRoot:t,zoom:e=1,algo:l="bezier",extendMinX:a,extendMaxX:x}=r,s=o.length===2?l:"linear",u=s==="linear"?Ge:Be,f=u(o),c=u(o,1,a,x),g=o[0].point,$=o[o.length-1].point,A=a!==void 0?`M ${a} ${g.y} L ${g.x} ${g.y} M ${$.x} ${$.y} L ${x} ${$.y}`:void 0,[E,I]=S.useState(!1),m=w.useRef(),[h,P]=S.useState(null);S.useEffect(()=>{P(null)},[e]);function p(j){m.current||(m.current=t().createSVGPoint()),m.current.x=j.clientX,m.current.y=j.clientY;const O=t().getScreenCTM();return O?m.current.matrixTransform(O.inverse()):{x:0,y:0}}const k=j=>{I(!0),P(p(j))},C=j=>{P(p(j))},L=()=>{if(!h)return;const j={point:{x:h.x,y:h.y},controlPoint:{x:h.x+20,y:h.y+20}};l==="linear"&&(j.controlPoint=null);let O=0;for(let Y=1;Y<o.length;Y++){const W=Math.sqrt(Math.pow(o[Y].point.x-j.point.x,2)+Math.pow(o[Y].point.y-j.point.y,2)),M=Math.sqrt(Math.pow(o[O].point.x-j.point.x,2)+Math.pow(o[O].point.y-j.point.y,2));W<M&&(O=Y)}r.onAddPoint&&r.onAddPoint(j,O)},N=j=>{j.stopPropagation(),I(!1),P(null)};return n.jsxs("g",{className:"bezier-path",onMouseLeave:N,children:[A&&n.jsx(jt,{d:A}),n.jsx(Me,{d:f}),n.jsx(Me,{hitline:!0,d:c,onMouseEnter:k,onMouseMove:C}),s==="linear"&&E&&h&&n.jsx(Tt,{cx:h.x,cy:h.y,onClick:L})]})}const U=1e-8,At=1,Rt=2;function ge(r,o=At,t=Rt){if(!Number.isFinite(r)||r<=0)return o;for(let e=0;e<=t;e++){const l=r*Math.pow(10,e);if(Math.abs(l-Math.round(l))<U)return Math.max(o,e)}return t}function Z(r,o){return(Math.abs(r)<U?0:r).toFixed(o)}function zt(r,o){return Z(r,o).replace(/\.?0+$/,"")}function ke(r,o){return r.reduce((t,e)=>{const l=zt(e,o),a=l.indexOf("."),x=a===-1?0:l.length-a-1;return Math.max(t,x)},0)}const He=8,je=He,_t=16,Et=22,Te=56,we=8,Lt=He,Nt=16,Dt=12,Ae=b("text",{fontSize:"10px",fill:"$gray10",userSelect:"none",pointerEvents:"none",variants:{direction:{vertical:{textOrientation:"mixed",textAnchor:"end"},horizontal:{textAnchor:"middle"}}},defaultVariants:{direction:"horizontal"}}),Ot=b("text",{fontSize:"11px",textAnchor:"middle",fill:"$grayA11",userSelect:"none",pointerEvents:"none"}),Re=b("rect",{fill:"$grayA3"}),ze=b("line",{stroke:"$grayA6"});function Yt(r){const{size:{width:o,height:t},offset:e,zoom:l,yTickScale:a=1,axisYScale:x=.4,tick:s={x:10,y:10},axisLabel:u}=r,f=Math.ceil(s.x*l)+1,c=o/(s.x*l),g=Math.ceil(s.y*l)+1,$=t/(s.y*l),A=w.useId().replace(/:/g,""),E=`${A}-grid`,I=`${A}-x-ticks`,m=`${A}-y-ticks`,h=10,P=ge(1/s.x),p=ge(Math.abs(a/(s.y*x))),k=R=>-R/(t*x)*l,C=R=>k(R)*a;function L(){return Math.abs(e.x)<U?null:n.jsx(ze,{className:"y-axis",x1:0,y1:e.y,x2:0,y2:e.y+t,strokeWidth:"1"})}function N(){return n.jsx("g",{className:"grid-x-lines",children:[...Array(g).keys()].map(R=>n.jsx(Re,{x:e.x,y:R*$+e.y-e.y%$,width:o,height:1},R))})}function j(R=-16,T=0){const X=[...Array(g).keys()].map(D=>{const z=D*$+e.y-e.y%$;return{index:D,worldY:z,value:C(z)}}),B=ke(X.map(D=>D.value),p);return n.jsx("g",{className:"grid-y-ticks",style:{clipPath:`url(#${m})`},children:X.map(D=>n.jsx(Ae,{className:"y-axis-tick",x:R,direction:"vertical",y:D.worldY+T,children:Z(D.value,B)},`y-${D.index}`))})}function O(){return n.jsx(Ot,{className:"x-axis-label",x:e.x+o/2,y:e.y+t-h,children:u??"x"})}function Y(){return n.jsx("g",{className:"grid-y-lines",children:[...Array(f).keys()].map(R=>{const T=R*c+e.x-e.x%c;return Math.abs(T-e.x)<U?null:n.jsx(Re,{x:T,y:e.y,width:1,height:t},R)})})}function W(R=-10,T=100){const X=e.x>0?Math.floor(e.x/c):Math.ceil(e.x/c),B=[...Array(f).keys()].map(z=>({index:z,value:(z+X)/s.x,x:z*c+e.x-e.x%c+R})),D=ke(B.map(z=>z.value),P);return n.jsx("g",{className:"grid-x-ticks",style:{clipPath:`url(#${I})`},children:B.map(z=>n.jsx(Ae,{className:"x-axis-tick",y:T,x:z.x,children:Z(z.value,D)},`x-${z.index}`))})}function M(){return n.jsx(ze,{className:"x-axis",x1:e.x,y1:0,x2:e.x+o,y2:0,strokeWidth:"1"})}return n.jsxs(n.Fragment,{children:[n.jsxs("defs",{children:[n.jsx("clipPath",{id:E,children:n.jsx("rect",{x:e.x,y:e.y,width:o,height:t})}),n.jsx("clipPath",{id:I,children:n.jsx("rect",{x:e.x-je,y:e.y+t,width:o+je+_t,height:Et})}),n.jsx("clipPath",{id:m,children:n.jsx("rect",{x:e.x-Te,y:e.y-we,width:Te,height:t+we+Lt})})]}),n.jsxs("g",{className:"bezier-curve-grid",height:t,width:o,style:{clipPath:`url(#${E})`,overflow:"hidden"},children:[N(),Y(),M(),L(),O(),r.children]}),r.overlay,j(e.x-Dt,4),W(0,t+e.y+Nt)]})}const Ft=b("circle",{fill:"transparent",transition:"fill 0.3s ease",pointerEvents:"none",variants:{display:{false:{fill:"transparent"},true:{fill:"$orange10",display:"block"}}}}),Bt=S.forwardRef(function(o,t){const{points:e,algo:l}=o,a=w.useRef(0),x=w.useRef(null),s=w.useRef(0),[u,f]=w.useState(!1),c=S.useMemo(()=>Xe(e,l),[e,l]);S.useImperativeHandle(t,()=>({play:g,getIsPlaying:()=>u,stop:$}),[u,c]);function g(A=800){var m,h;f(!0),(m=x.current)==null||m.setAttribute("cx",c[0].x.toString()),(h=x.current)==null||h.setAttribute("cy",c[0].y.toString());const E=Date.now(),I=()=>{var C,L;const p=(Date.now()-E)/A;a.current=p;const k=l==="bezier"?Pt(c,p):mt(c,p);(C=x.current)==null||C.setAttribute("cx",k.x.toString()),(L=x.current)==null||L.setAttribute("cy",k.y.toString()),p<1&&(s.current=requestAnimationFrame(I)),p>=1&&$()};s.current=requestAnimationFrame(I)}function $(){f(!1),cancelAnimationFrame(s.current)}return n.jsx(Ft,{ref:x,r:"6",cx:c[0].x,cy:c[0].y,display:u})}),_e=1e-4,Gt=10,Xt=-10,Ht=-3.5;function Ee(r,o,t){return r<=o+_e?o:r>=t-_e?t:r}function Le(r,o,t){return r.map(e=>({x:G(e.x,0,1),y:G(e.y,o,t)}))}const Kt=b("svg",{overflow:"unset",fontSize:0,userSelect:"none",backgroundImage:"linear-gradient(180deg, rgba(0,0,0,0) 0%, $orangeA2 100%)"}),Wt=b("rect",{fill:"none",stroke:"$orange7",strokeWidth:1,shapeRendering:"crispEdges",pointerEvents:"none"}),Vt=b("div",{position:"relative",marginLeft:"$7",outline:"none"}),Zt=b("div",{position:"absolute",left:`${Xt}px`,top:`${Ht}px`,transform:"translateX(-100%)",width:"1.2ch",height:"10px",fontSize:"10px",fontVariantNumeric:"tabular-nums",zIndex:3,pointerEvents:"auto",display:"flex",alignItems:"center",borderRadius:"$1",backgroundColor:"$gray3",boxShadow:"inset 0 0 0 1px $colors$grayA6"}),Ut=b("input",{all:"unset",boxSizing:"border-box",display:"block",width:"100%",height:"100%",backgroundColor:"$gray3",color:"$gray12",fontSize:"10px",lineHeight:"10px",textAlign:"right",fontVariantNumeric:"tabular-nums",userSelect:"text"}),qt=[{x:0,y:0},{x:.25,y:.25},{x:.75,y:.75},{x:1,y:1}];function Jt(r,o){const{width:t=300,height:e=300,points:l,defaultPoints:a,doubleControlPoint:x=!0,algo:s="linear",zoomable:u=!0,zoomLimit:f=[.2,1],zoomSpeed:c=.03,yRangeMode:g="symmetric",yTickScale:$=1,yTickScaleMin:A=.01,yTickScaleMax:E}=r,I=w.useRef(null),m=w.useRef(null),h=g==="positive"?1:.5,P=g==="positive"?0:-1,p=1,k=Math.min(f[0],f[1]),C=Math.max(f[0],f[1]),L=G(1,k,C),N=g==="positive"?{x:0,y:-e}:pt(e),j=w.useRef(null),O=w.useRef(0),Y=w.useRef([]),W=w.useId().replace(/:/g,""),[M,R]=S.useState(L),[T,X]=S.useState(N),B=1/M,D=t*B,z=e*h*B,Ve=Math.min(-P*z,-p*z),Ze=Math.max(-P*z,-p*z),Ue=E??Number.MAX_VALUE,V=Z($,ge(Math.abs($/(Gt*h)),0)),[ne,J]=S.useState(V),ae=w.useRef(!1),Q=w.useRef(null),oe=w.useRef(null),pe=w.useRef(!1),qe=i=>{const d=i.x/t*M,y=-i.y/(e*h)*M;return`${Z(d,3)}, ${Z(y,3)}`},me=i=>({point:{x:Ee(i.point.x,0,D),y:Ee(i.point.y,Ve,Ze)},controlPoint:i.controlPoint}),Pe=()=>`bezier-point-${O.current++}`,re=i=>{const d=Y.current;for(;d.length<i;)d.push(Pe());return d.length>i&&(d.length=i),d},[H,le]=De({prop:l?ye(fe(Le(l,P,p),t,e*h,B),s):void 0,defaultProp:ye(fe(Le(a||qt,P,p),t,e*h,B),s),onChange:i=>{var y;const d=gt(Xe(i,s),t,e*h,M);(y=r.onPointsChange)==null||y.call(r,d)}}),ve=(i,d)=>{const y=i.map((v,_)=>_).sort((v,_)=>{const F=i[v].point.x-i[_].point.x;return Math.abs(F)<=U?v-_:F});return Y.current=y.map(v=>d[v]),y.map(v=>i[v])},Je=(i,d)=>{le(y=>{if(!y)return y;const v=re(y.length),_=v.indexOf(i);if(_===-1)return y;const F=me(d),K=y.map((ue,rt)=>rt===_?F:ue);return ve(K,v)})},$e=w.useCallback((i,d)=>{const y=1/d,v=Math.max(0,t*y-t),_=-P*e*h*y,F=-p*e*h*y,K=Math.min(_,F),ue=Math.max(_,F);return{x:G(i.x,0,v),y:G(i.y,K,ue-e)}},[h,e,p,P,t]),ie=w.useCallback((i,d)=>{const y=G(i,k,C);if(Math.abs(y-M)<U)return;const v=M/y,_=T.x+d.x*t,F=T.y+d.y*e,K={x:_*v-d.x*t,y:F*v-d.y*e};R(y),X($e(K,y))},[$e,e,C,k,T.x,T.y,t,M]),ce=w.useCallback(i=>{if(i.preventDefault(),i.stopPropagation(),!m.current)return;const d=m.current.getBoundingClientRect();if(!d.width||!d.height)return;const y={x:G((i.clientX-d.left)/d.width,0,1),y:G((i.clientY-d.top)/d.height,0,1)},v=i.deltaY>0?M+c:M-c;ie(v,y)},[ie,M,c]),Qe=(i,d)=>{le(y=>{const v=[...y];v.splice(d,0,me(i));const _=[...re(y.length)];return _.splice(d,0,Pe()),ve(v,_)})},et=()=>{!pe.current&&!(document.activeElement instanceof HTMLInputElement)&&I.current.focus()},Ce=i=>{le(d=>{if(d.length<=1)return d;const y=re(d.length),v=y.indexOf(i);if(v===-1)return d;const _=d.filter((F,K)=>K!==v);return y.splice(v,1),_}),Q.current=null},tt=(i,d)=>{Q.current=d?i:null,d&&et()},nt=i=>{oe.current=Q.current,oe.current||(i.preventDefault(),i.stopPropagation())},ot=i=>{i.target instanceof HTMLInputElement||(i.key==="Delete"||i.key==="Backspace")&&Q.current&&H.length>1&&(i.preventDefault(),Ce(Q.current))},Se=i=>{if(!r.onYTickScaleChange||Number.isNaN(i))return;const d=G(i,A,Ue);r.onYTickScaleChange(d)};S.useEffect(()=>{if(!m.current||!u)return;const i=m.current;return i.addEventListener("wheel",ce,{passive:!1}),()=>{i.removeEventListener("wheel",ce)}},[ce,u]),S.useEffect(()=>{R(L),X(N)},[N.x,N.y,L]),S.useEffect(()=>{ae.current||J(V)},[V,$]);const be=H?re(H.length):[];return n.jsx(lt,{onOpenChange:i=>{pe.current=i,i||I.current.focus()},trigger:n.jsxs(Vt,{ref:I,tabIndex:0,onKeyDown:ot,children:[n.jsxs(Kt,{xmlns:"http://www.w3.org/2000/svg",viewBox:`${T.x} ${T.y} ${t} ${e}`,width:t,height:e,ref:Oe([o,m]),onMouseDown:i=>i.preventDefault(),onContextMenu:nt,children:[n.jsx("defs",{children:n.jsx("clipPath",{id:W,clipPathUnits:"userSpaceOnUse",children:n.jsx("rect",{x:T.x-ee,y:T.y-ee,width:t+ee*2,height:e+ee*2})})}),n.jsxs(Yt,{size:{width:t,height:e},offset:T,axisLabel:r.axisLabel,zoom:M,yTickScale:$,axisYScale:h,overlay:n.jsxs(n.Fragment,{children:[n.jsx(Wt,{x:T.x,y:T.y,width:t,height:e}),n.jsx("g",{className:"bezier-curve-points",children:H.map((i,d)=>n.jsx(kt,{pointId:be[d],bezierPoint:i,pointHoverLabel:qe(i.point),pointClipPath:`url(#${W})`,onPointChange:Je,onHoverChange:tt,getRoot:()=>m.current,doublePoint:x,algo:s},be[d]))})]}),children:[n.jsx(wt,{algo:s,points:H,zoom:M,getRoot:()=>m.current,onAddPoint:Qe,extendMinX:T.x,extendMaxX:T.x+t}),n.jsx(Bt,{points:H,algo:s,ref:j})]})]}),r.onYTickScaleChange&&n.jsx(Zt,{style:{width:`${ne.length-(ne.match(/[.\-]/g)||[]).length*.5+.2}ch`},children:n.jsx(Ut,{type:"text",inputMode:"decimal",value:ne,onFocus:()=>{ae.current=!0},onBlur:i=>{var y;if(ae.current=!1,i.currentTarget.dataset.escaping){delete i.currentTarget.dataset.escaping,J(V);return}const d=Number(ne.trim()||0);Number.isNaN(d)||Se(d),J(V),(y=r.onYTickScaleCommit)==null||y.call(r)},onKeyDown:i=>{i.key==="Enter"?i.currentTarget.blur():i.key==="Escape"&&(i.currentTarget.dataset.escaping="1",i.currentTarget.blur())},onChange:i=>{const d=i.target.value;J(d);const y=d.trim(),v=Number(y);y!==""&&!Number.isNaN(v)&&Se(v)}})}),n.jsx(Ye,{gap:"xs",style:{position:"absolute",bottom:10,right:10},children:n.jsxs(it,{children:[n.jsx(se,{onClick:()=>{var i;return(i=j.current)==null?void 0:i.play()},size:"xs",children:n.jsx(ht,{})}),n.jsx(se,{size:"xs",onClick:()=>ie(M-.05,{x:.5,y:.5}),disabled:M<=k,children:n.jsx(yt,{})}),n.jsx(se,{size:"xs",onClick:()=>ie(M+.05,{x:.5,y:.5}),disabled:M>=C,children:n.jsx(ft,{})}),n.jsx(se,{size:"xs",onClick:()=>{R(L),X(N)},disabled:M===L,children:n.jsx(ut,{})})]})})]}),asChild:!0,children:n.jsx(ct,{name:"Delete Keyframe",disabled:H.length<=1,onSelect:()=>oe.current&&Ce(oe.current)})})}const Qt=w.forwardRef(Jt),Ke=b("path",{fill:"none",stroke:"$grayA8",strokeWidth:"1.5px",transition:"stroke .2s ease-in-out, stroke-width .2s ease-in-out"}),en=b("svg",{width:"100%",height:"100%",overflow:"hidden","&:hover":{[`& ${Ke}`]:{stroke:"$orange10",strokeWidth:"2px"}}}),tn=[[{x:0,y:0},{x:.2,y:.8},{x:.8,y:.2},{x:1,y:1}],[{x:0,y:0},{x:.25,y:.75},{x:.75,y:.75},{x:1,y:0}],[{x:0,y:0},{x:.7,y:0},{x:1,y:.5},{x:1,y:1}],[{x:0,y:0},{x:.42,y:0},{x:.58,y:1},{x:1,y:1}]],nn=b("div",{width:"100%",display:"grid",padding:"$1 0",gridTemplateColumns:"repeat(5, 1fr)",alignItems:"center",gap:"$2"}),on=b("button",{all:"unset",position:"absolute",right:0,top:0,borderRadius:"$round",color:"$gray9",transform:"translate(50%, -50%)","&:hover":{color:"$red10"}}),We=b("div",{position:"relative",display:"flex",justifyContent:"center",alignItems:"center",height:"$8",borderRadius:"$2",color:"$grayA9",cursor:"pointer",backgroundColor:"$appBackground",border:"1px solid $grayA3",transition:"color .2s ease-in-out","&:hover":{color:"$orange10"}});function Ne(r){const{points:o,width:t=74,height:e=34,deletable:l=!1,onDelete:a,...x}=r,s=u=>{if(u.length<4)return"";let f=`M${u[0].x*t} ${-u[0].y*e}`;for(let c=1;c<u.length;c+=3)f+=` C${u[c].x*t} ${-u[c].y*e}, ${u[c+1].x*t} ${-u[c+1].y*e}, ${u[c+2].x*t} ${-u[c+2].y*e}`;return f};return n.jsxs(We,{...x,children:[n.jsx(en,{width:t,height:e,viewBox:`0 -${e} ${t} ${e}`,children:n.jsx(Ke,{d:s(o)})}),l&&n.jsx(on,{children:n.jsx(xt,{size:"14px",onClick:a})})]})}function rn(r){const{presets:o=[],onApplyPreset:t,onAddPreset:e,onDeletePreset:l}=r,[a,x]=S.useState(!1);return n.jsxs(n.Fragment,{children:[n.jsxs(Ye,{align:"v",justifyContent:"between",css:{fontSize:"$1",marginTop:"$7",color:"$gray11",userSelect:"none"},children:["Presets",o.length>0&&n.jsx(st,{variant:"subtle",onClick:()=>x(!a),children:a?"Done":"Edit"})]}),n.jsxs(nn,{children:[tn.map((s,u)=>n.jsx(Ne,{points:s,onClick:()=>t&&t(s)},u)),o.map((s,u)=>n.jsx(Ne,{deletable:a,points:s,onDelete:()=>l(u),onClick:()=>t&&t(s)},u)),n.jsx(We,{onClick:e,children:n.jsx(dt,{size:"16px"})})]})]})}const sn=b("div",{display:"flex",height:"$6",width:"100%",background:"$grayA3",borderRadius:"$2",overflow:"hidden",fontSize:"$1",cursor:"pointer","& > svg":{stroke:"$orange9",fill:"none"}}),an=[{x:0,y:0},{x:.25,y:.25},{x:.75,y:.75},{x:1,y:1}],ln=S.forwardRef(function(o,t){const{points:e,algo:l,...a}=o,x=S.useRef(null),[s,u]=S.useState({width:0,height:0});S.useLayoutEffect(()=>{x.current&&u(x.current.getBoundingClientRect())},[]);let f="";if(s.width!==0&&e.length){const c=ye(fe(e,s.width,s.height),l);f=(l==="bezier"?Be:Ge)(c,1,0,s.width)}return n.jsx(sn,{ref:Oe([x,t]),...a,children:!!s.width&&n.jsx("svg",{width:s.width,height:s.height,viewBox:`0 -${s.height} ${s.width} ${s.height}`,children:n.jsx("path",{d:f})})})}),cn=b("div",{borderRadius:"$3",backgroundColor:"$gray1",padding:"$2"}),he="_bezier_curve_presets",xn=function(o){const{onChange:t,value:e,defaultValue:l,algo:a="bezier",axisLabel:x,yTickScale:s=1,yRangeMode:u="symmetric",onYTickScaleChange:f,onYTickScaleCommit:c,yTickScaleMin:g=.01,yTickScaleMax:$}=o,A=x??"time",[E,I]=S.useState([]),[m,h]=De({prop:e,defaultProp:l||an,onChange:t});S.useEffect(()=>{const C=localStorage.getItem(he);C&&I(JSON.parse(C))},[]);function P(C){h(C)}function p(){const C=[...E,m];I(C),localStorage.setItem(he,JSON.stringify(C))}function k(C){I(L=>{const N=[...L];return N.splice(C,1),localStorage.setItem(he,JSON.stringify(N)),N})}return n.jsx(at,{trigger:n.jsx(ln,{points:m,algo:a}),sideOffset:2,compact:!0,onOpenAutoFocus:C=>C.preventDefault(),children:n.jsxs(cn,{children:[n.jsx(Qt,{algo:a,width:400,height:220,points:m,yTickScale:s,yRangeMode:u,onYTickScaleChange:f,onYTickScaleCommit:c,yTickScaleMin:g,yTickScaleMax:$,axisLabel:A,onPointsChange:h}),n.jsx(rn,{presets:E,onApplyPreset:P,onAddPreset:p,onDeletePreset:k})]})})};export{xn as B};