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

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 (103) hide show
  1. package/dist/cli.bundle.cjs +3083 -2856
  2. package/dist/viewport-client/_static/Accordion-4897319b.js +6 -0
  3. package/dist/viewport-client/_static/AmbientLightAsset-f70b95f1.js +5 -0
  4. package/dist/viewport-client/_static/AnimationClipAsset-01f3deb6.js +1 -0
  5. package/dist/viewport-client/_static/AnimatorControllerAsset-b7424e9c.js +1 -0
  6. package/dist/viewport-client/_static/AnimatorStore-fd98c00e.js +1 -0
  7. package/dist/viewport-client/_static/AssetPreviewer-24e31d97.js +6 -0
  8. package/dist/viewport-client/_static/AssetViewer-bc198e16.js +1 -0
  9. package/dist/viewport-client/_static/AudioAsset-eae03324.js +1 -0
  10. package/dist/viewport-client/_static/AudioComponent-44070c2c.js +1 -0
  11. package/dist/viewport-client/_static/Callout-cb4a55ff.js +1 -0
  12. package/dist/viewport-client/_static/CameraComponent-907ac745.js +1 -0
  13. package/dist/viewport-client/_static/CanvasRenderer-9dd98cb3.js +1 -0
  14. package/dist/viewport-client/_static/Component-f923abb1.js +1 -0
  15. package/dist/viewport-client/_static/DirectLight-58f5fe9e.js +1 -0
  16. package/dist/viewport-client/_static/FontAsset-abfb9a8a.js +5 -0
  17. package/dist/viewport-client/_static/FormItemArray-66be8701.js +1 -0
  18. package/dist/viewport-client/_static/GlTFAsset-9c68f862.js +20 -0
  19. package/dist/viewport-client/_static/IconPlayerPlayFilled-b058c98f.js +6 -0
  20. package/dist/viewport-client/_static/IconPointFilled-a304fd34.js +6 -0
  21. package/dist/viewport-client/_static/InstanceEditorAsset-a70e73fe.js +1 -0
  22. package/dist/viewport-client/_static/LightBaseComponent-fbc3ae49.js +1 -0
  23. package/dist/viewport-client/_static/LottieAnimationComponent-1c3e02a5.js +1 -0
  24. package/dist/viewport-client/_static/LottieAsset-377c1419.js +1 -0
  25. package/dist/viewport-client/_static/MarkdownAsset-7ea387a9.js +1 -0
  26. package/dist/viewport-client/_static/MaterialAsset-74a15124.js +1 -0
  27. package/dist/viewport-client/_static/MaterialInspector-aec1248b.js +1 -0
  28. package/dist/viewport-client/_static/Menu-cd3be298.js +17 -0
  29. package/dist/viewport-client/_static/MeshAsset-73e2cc8e.js +1 -0
  30. package/dist/viewport-client/_static/MeshRendererBaseComponent-3a0e09ed.js +1 -0
  31. package/dist/viewport-client/_static/MeshRendererComponent-5385d30f.js +1 -0
  32. package/dist/viewport-client/_static/MeshThumbnail-49273f71.js +1 -0
  33. package/dist/viewport-client/_static/ParticleRendererComponent-5a7b57d9.js +21 -0
  34. package/dist/viewport-client/_static/PhysicsMaterialAsset-a5ac9f82.js +1 -0
  35. package/dist/viewport-client/_static/PhysicsStore-0729e76d.js +1 -0
  36. package/dist/viewport-client/_static/PointLight-0e1d1546.js +1 -0
  37. package/dist/viewport-client/_static/PostProcessComponent-8276d33c.js +1 -0
  38. package/dist/viewport-client/_static/PrefabAsset-1a7edfbd.js +1 -0
  39. package/dist/viewport-client/_static/PrimitiveMesh-3ce6fa2f.js +1 -0
  40. package/dist/viewport-client/_static/ProxyConfigs-4de3304c.js +1 -0
  41. package/dist/viewport-client/_static/ReferencedMaterial-a87818f3.js +1 -0
  42. package/dist/viewport-client/_static/RenderTargetAsset-33c0d9e7.js +1 -0
  43. package/dist/viewport-client/_static/SceneAsset-8917c210.js +1 -0
  44. package/dist/viewport-client/_static/ShaderAsset-cb3ff628.js +185 -0
  45. package/dist/viewport-client/_static/ShaderChunkAsset-83f923f4.js +5 -0
  46. package/dist/viewport-client/_static/ShaderUIScriptAsset-d13fa4e2.js +516 -0
  47. package/dist/viewport-client/_static/SkinnedMeshRendererComponent-2a8323bf.js +1 -0
  48. package/dist/viewport-client/_static/SpineAnimationComponent-e733d50f.js +1 -0
  49. package/dist/viewport-client/_static/SpineSkeletonDataAsset-b64a3ee3.js +1 -0
  50. package/dist/viewport-client/_static/SpotLight-ca6c0c3b.js +1 -0
  51. package/dist/viewport-client/_static/SpriteAsset-9a31ec24.js +1 -0
  52. package/dist/viewport-client/_static/SpriteAtlasAsset-a862db46.js +1 -0
  53. package/dist/viewport-client/_static/SpriteBaseComponent-f6f1731f.js +1 -0
  54. package/dist/viewport-client/_static/SpriteMaskComponent-778be04f.js +1 -0
  55. package/dist/viewport-client/_static/SpriteRendererComponent-2b4d153b.js +1 -0
  56. package/dist/viewport-client/_static/TaskQueue-05c94a4d.js +1 -0
  57. package/dist/viewport-client/_static/TextBaseComponent-69233798.js +11 -0
  58. package/dist/viewport-client/_static/TextRendererComponent-130b4e99.js +1 -0
  59. package/dist/viewport-client/_static/TextureAsset-28fedf2a.js +36 -0
  60. package/dist/viewport-client/_static/ThumbnailMixin-35997457.js +1 -0
  61. package/dist/viewport-client/_static/ThumbnailRegistry-495c18c9.js +1 -0
  62. package/dist/viewport-client/_static/Tooltip-33f770ba.js +1 -0
  63. package/dist/viewport-client/_static/TrailRendererComponent-148550b5.js +1 -0
  64. package/dist/viewport-client/_static/TransformBaseComponent-02318c5a.js +1 -0
  65. package/dist/viewport-client/_static/TransformComponent-96106065.js +1 -0
  66. package/dist/viewport-client/_static/ViewerManager-202b570a.js +1 -0
  67. package/dist/viewport-client/_static/XRReferenceImageAsset-6a6adb3b.js +1 -0
  68. package/dist/viewport-client/_static/assetEditorActions-c4e5962f.js +1 -0
  69. package/dist/viewport-client/_static/audio-244358e2.js +1 -0
  70. package/dist/viewport-client/_static/bundlers-9b0d37fc.js +1 -0
  71. package/dist/viewport-client/_static/createOnModelChange-b57a0da8.js +1 -0
  72. package/dist/viewport-client/_static/encode-ac4bb64e.js +1 -0
  73. package/dist/viewport-client/_static/enum-58295f88.js +1 -0
  74. package/dist/viewport-client/_static/glTFIO-45ff9a17.js +1 -0
  75. package/dist/viewport-client/_static/index-0a8702e2.js +11217 -0
  76. package/dist/viewport-client/_static/index-237c84cd.js +20 -0
  77. package/dist/viewport-client/_static/index-37c74ae9.js +26 -0
  78. package/dist/viewport-client/_static/index-4cca0201.js +1 -0
  79. package/dist/viewport-client/_static/index-59732f86.js +1 -0
  80. package/dist/viewport-client/_static/index-6c8198f6.js +2 -0
  81. package/dist/viewport-client/_static/index-6f827618.js +1 -0
  82. package/dist/viewport-client/_static/index-803ca489.js +1 -0
  83. package/dist/viewport-client/_static/index-85a6cf6a.js +1 -0
  84. package/dist/viewport-client/_static/index-98982ce2.js +1 -0
  85. package/dist/viewport-client/_static/index-b3d51f87.js +1 -0
  86. package/dist/viewport-client/_static/index-be6bc38a.js +177 -0
  87. package/dist/viewport-client/_static/index-c403cbcd.js +1 -0
  88. package/dist/viewport-client/_static/index-e46ec5b1.js +16 -0
  89. package/dist/viewport-client/_static/index-e73966ae.js +1 -0
  90. package/dist/viewport-client/_static/index-e95b4498.js +1 -0
  91. package/dist/viewport-client/_static/index-f5a67a46.js +1 -0
  92. package/dist/viewport-client/_static/ktx-parse.modern-6c9f771f.js +1 -0
  93. package/dist/viewport-client/_static/ktx2-encoder-1e63c1eb.js +1 -0
  94. package/dist/viewport-client/_static/ktx2-worker-a04f41ea.js +1 -0
  95. package/dist/viewport-client/_static/meshopt_simplifier.module-cd99529d.js +1 -0
  96. package/dist/viewport-client/_static/module-107b7430.js +56 -0
  97. package/dist/viewport-client/_static/module-5c85b07e.js +1 -0
  98. package/dist/viewport-client/_static/module-6406b050.js +1 -0
  99. package/dist/viewport-client/_static/postmen-45d4c238.js +1 -0
  100. package/dist/viewport-client/_static/scriptPropertyActions-d3a583d2.js +1 -0
  101. package/dist/viewport-client/_static/utilities-e09052e3.js +11 -0
  102. package/dist/viewport-client/index.html +20 -0
  103. package/package.json +2 -1
@@ -0,0 +1 @@
1
+ var bn=Object.defineProperty;var _n=(i,e,t)=>e in i?bn(i,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):i[e]=t;var Y=(i,e,t)=>(_n(i,typeof e!="symbol"?e+"":e,t),t);import{r as ht,K as Cn,a as On}from"./ktx-parse.modern-6c9f771f.js";import{M as $t,a as Xt}from"./meshopt_simplifier.module-cd99529d.js";class ps{constructor(){this._listeners={}}addEventListener(e,t){const r=this._listeners;return r[e]===void 0&&(r[e]=[]),r[e].indexOf(t)===-1&&r[e].push(t),this}removeEventListener(e,t){const s=this._listeners[e];if(s!==void 0){const n=s.indexOf(t);n!==-1&&s.splice(n,1)}return this}dispatchEvent(e){const r=this._listeners[e.type];if(r!==void 0){const s=r.slice(0);for(let n=0,o=s.length;n<o;n++)s[n].call(this,e)}return this}dispose(){for(const e in this._listeners)delete this._listeners[e]}}class Be{constructor(e,t,r,s={}){if(this._name=void 0,this._parent=void 0,this._child=void 0,this._attributes=void 0,this._disposed=!1,this._name=e,this._parent=t,this._child=r,this._attributes=s,!t.isOnGraph(r))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(e){return this._child=e,this}getAttributes(){return this._attributes}dispose(){this._disposed||(this._parent._destroyRef(this),this._disposed=!0)}isDisposed(){return this._disposed}}class Dn extends ps{constructor(...e){super(...e),this._emptySet=new Set,this._edges=new Set,this._parentEdges=new Map,this._childEdges=new Map}listEdges(){return Array.from(this._edges)}listParentEdges(e){return Array.from(this._childEdges.get(e)||this._emptySet)}listParents(e){const t=new Set;for(const r of this.listParentEdges(e))t.add(r.getParent());return Array.from(t)}listChildEdges(e){return Array.from(this._parentEdges.get(e)||this._emptySet)}listChildren(e){const t=new Set;for(const r of this.listChildEdges(e))t.add(r.getChild());return Array.from(t)}disconnectParents(e,t){for(const r of this.listParentEdges(e))(!t||t(r.getParent()))&&r.dispose();return this}_createEdge(e,t,r,s){const n=new Be(e,t,r,s);this._edges.add(n);const o=n.getParent();this._parentEdges.has(o)||this._parentEdges.set(o,new Set),this._parentEdges.get(o).add(n);const a=n.getChild();return this._childEdges.has(a)||this._childEdges.set(a,new Set),this._childEdges.get(a).add(n),n}_destroyEdge(e){return this._edges.delete(e),this._parentEdges.get(e.getParent()).delete(e),this._childEdges.get(e.getChild()).delete(e),this}}function Xe(){return Xe=Object.assign||function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},Xe.apply(this,arguments)}class he{constructor(e){if(this.list=[],e)for(const t of e)this.list.push(t)}add(e){this.list.push(e)}remove(e){const t=this.list.indexOf(e);t>=0&&this.list.splice(t,1)}removeChild(e){const t=[];for(const r of this.list)r.getChild()===e&&t.push(r);for(const r of t)this.remove(r);return t}listRefsByChild(e){const t=[];for(const r of this.list)r.getChild()===e&&t.push(r);return t}values(){return this.list}}class P{constructor(e){if(this.set=new Set,this.map=new Map,e)for(const t of e)this.add(t)}add(e){const t=e.getChild();this.removeChild(t),this.set.add(e),this.map.set(t,e)}remove(e){this.set.delete(e),this.map.delete(e.getChild())}removeChild(e){const t=this.map.get(e)||null;return t&&this.remove(t),t}getRefByChild(e){return this.map.get(e)||null}values(){return Array.from(this.set)}}class ne{constructor(e){this.map={},e&&Object.assign(this.map,e)}set(e,t){this.map[e]=t}delete(e){delete this.map[e]}get(e){return this.map[e]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}}const F=Symbol("attributes"),_e=Symbol("immutableKeys");class At extends ps{constructor(e){super(),this._disposed=!1,this.graph=void 0,this[F]=void 0,this[_e]=void 0,this.graph=e,this[_e]=new Set,this[F]=this._createAttributes()}getDefaults(){return{}}_createAttributes(){const e=this.getDefaults(),t={};for(const r in e){const s=e[r];if(s instanceof At){const n=this.graph._createEdge(r,this,s);this[_e].add(r),t[r]=n}else t[r]=s}return t}isOnGraph(e){return this.graph===e.graph}isDisposed(){return this._disposed}dispose(){this._disposed||(this.graph.listChildEdges(this).forEach(e=>e.dispose()),this.graph.disconnectParents(this),this._disposed=!0,this.dispatchEvent({type:"dispose"}))}detach(){return this.graph.disconnectParents(this),this}swap(e,t){for(const r in this[F]){const s=this[F][r];if(s instanceof Be){const n=s;n.getChild()===e&&this.setRef(r,t,n.getAttributes())}else if(s instanceof he)for(const n of s.listRefsByChild(e)){const o=n.getAttributes();this.removeRef(r,e),this.addRef(r,t,o)}else if(s instanceof P){const n=s.getRefByChild(e);if(n){const o=n.getAttributes();this.removeRef(r,e),this.addRef(r,t,o)}}else if(s instanceof ne)for(const n of s.keys()){const o=s.get(n);o.getChild()===e&&this.setRefMap(r,n,t,o.getAttributes())}}return this}get(e){return this[F][e]}set(e,t){return this[F][e]=t,this.dispatchEvent({type:"change",attribute:e})}getRef(e){const t=this[F][e];return t?t.getChild():null}setRef(e,t,r){if(this[_e].has(e))throw new Error(`Cannot overwrite immutable attribute, "${e}".`);const s=this[F][e];if(s&&s.dispose(),!t)return this;const n=this.graph._createEdge(e,this,t,r);return this[F][e]=n,this.dispatchEvent({type:"change",attribute:e})}listRefs(e){return this.assertRefList(e).values().map(r=>r.getChild())}addRef(e,t,r){const s=this.graph._createEdge(e,this,t,r);return this.assertRefList(e).add(s),this.dispatchEvent({type:"change",attribute:e})}removeRef(e,t){const r=this.assertRefList(e);if(r instanceof he)for(const s of r.listRefsByChild(t))s.dispose();else{const s=r.getRefByChild(t);s&&s.dispose()}return this}assertRefList(e){const t=this[F][e];if(t instanceof he||t instanceof P)return t;throw new Error(`Expected RefList or RefSet for attribute "${e}"`)}listRefMapKeys(e){return this.assertRefMap(e).keys()}listRefMapValues(e){return this.assertRefMap(e).values().map(t=>t.getChild())}getRefMap(e,t){const s=this.assertRefMap(e).get(t);return s?s.getChild():null}setRefMap(e,t,r,s){const n=this.assertRefMap(e),o=n.get(t);if(o&&o.dispose(),!r)return this;s=Object.assign(s||{},{key:t});const a=this.graph._createEdge(e,this,r,Xe({},s,{key:t}));return n.set(t,a),this.dispatchEvent({type:"change",attribute:e,key:t})}assertRefMap(e){const t=this[F][e];if(t instanceof ne)return t;throw new Error(`Expected RefMap for attribute "${e}"`)}dispatchEvent(e){return super.dispatchEvent(Xe({},e,{target:this})),this.graph.dispatchEvent(Xe({},e,{target:this,type:`node:${e.type}`})),this}_destroyRef(e){const t=e.getName();if(this[F][t]===e)this[F][t]=null,this[_e].has(t)&&e.getChild().dispose();else if(this[F][t]instanceof he)this[F][t].remove(e);else if(this[F][t]instanceof P)this[F][t].remove(e);else if(this[F][t]instanceof ne){const r=this[F][t];for(const s of r.keys())r.get(s)===e&&r.delete(s)}else return;this.graph._destroyEdge(e),this.dispatchEvent({type:"change",attribute:t})}}const ds="v4.1.0",Ue="@glb.bin";var h;(function(i){i.ACCESSOR="Accessor",i.ANIMATION="Animation",i.ANIMATION_CHANNEL="AnimationChannel",i.ANIMATION_SAMPLER="AnimationSampler",i.BUFFER="Buffer",i.CAMERA="Camera",i.MATERIAL="Material",i.MESH="Mesh",i.PRIMITIVE="Primitive",i.PRIMITIVE_TARGET="PrimitiveTarget",i.NODE="Node",i.ROOT="Root",i.SCENE="Scene",i.SKIN="Skin",i.TEXTURE="Texture",i.TEXTURE_INFO="TextureInfo"})(h||(h={}));var nt;(function(i){i.INTERLEAVED="interleaved",i.SEPARATE="separate"})(nt||(nt={}));var J;(function(i){i.ARRAY_BUFFER="ARRAY_BUFFER",i.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",i.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",i.OTHER="OTHER",i.SPARSE="SPARSE"})(J||(J={}));var te;(function(i){i[i.R=4096]="R",i[i.G=256]="G",i[i.B=16]="B",i[i.A=1]="A"})(te||(te={}));var ge;(function(i){i.GLTF="GLTF",i.GLB="GLB"})(ge||(ge={}));const at={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};var dt=typeof Float32Array<"u"?Float32Array:Array;Math.hypot||(Math.hypot=function(){for(var i=0,e=arguments.length;e--;)i+=arguments[e]*arguments[e];return Math.sqrt(i)});function vn(){var i=new dt(3);return dt!=Float32Array&&(i[0]=0,i[1]=0,i[2]=0),i}function gt(i){var e=i[0],t=i[1],r=i[2];return Math.hypot(e,t,r)}function Fn(i,e,t){var r=e[0],s=e[1],n=e[2],o=t[3]*r+t[7]*s+t[11]*n+t[15];return o=o||1,i[0]=(t[0]*r+t[4]*s+t[8]*n+t[12])/o,i[1]=(t[1]*r+t[5]*s+t[9]*n+t[13])/o,i[2]=(t[2]*r+t[6]*s+t[10]*n+t[14])/o,i}(function(){var i=vn();return function(e,t,r,s,n,o){var a,c;for(t||(t=3),r||(r=0),s?c=Math.min(s*t+r,e.length):c=e.length,a=r;a<c;a+=t)i[0]=e[a],i[1]=e[a+1],i[2]=e[a+2],n(i,i,o),e[a]=i[0],e[a+1]=i[1],e[a+2]=i[2];return e}})();function Ln(i){const e=Ts(),t=i.propertyType===h.NODE?[i]:i.listChildren();for(const r of t)r.traverse(s=>{const n=s.getMesh();if(!n)return;const o=Bn(n,s.getWorldMatrix());o.min.every(isFinite)&&o.max.every(isFinite)&&(Tt(o.min,e),Tt(o.max,e))});return e}function Bn(i,e){const t=Ts();for(const r of i.listPrimitives()){const s=r.getAttribute("POSITION"),n=r.getIndices();if(!s)continue;let o=[0,0,0],a=[0,0,0];for(let c=0,u=n?n.getCount():s.getCount();c<u;c++){const g=n?n.getScalar(c):c;o=s.getElement(g,o),a=Fn(a,o,e),Tt(a,t)}}return t}function Tt(i,e){for(let t=0;t<3;t++)e.min[t]=Math.min(i[t],e.min[t]),e.max[t]=Math.max(i[t],e.max[t])}function Ts(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}class D{static createBufferFromDataURI(e){if(typeof Buffer>"u"){const t=atob(e.split(",")[1]),r=new Uint8Array(t.length);for(let s=0;s<t.length;s++)r[s]=t.charCodeAt(s);return r}else{const t=e.split(",")[1],r=e.indexOf("base64")>=0;return Buffer.from(t,r?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(const n of e)t+=n.byteLength;const r=new Uint8Array(t);let s=0;for(const n of e)r.set(n,s),s+=n.byteLength;return r}static pad(e,t=0){const r=this.padNumber(e.byteLength);if(r===e.byteLength)return e;const s=new Uint8Array(r);if(s.set(e),t!==0)for(let n=e.byteLength;n<r;n++)s[n]=t;return s}static padNumber(e){return Math.ceil(e/4)*4}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let r=e.byteLength;for(;r--;)if(e[r]!==t[r])return!1;return!0}static toView(e,t=0,r=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,r))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw new Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}}class pi{static hexToFactor(e,t){e=Math.floor(e);const r=t;return r[0]=(e>>16&255)/255,r[1]=(e>>8&255)/255,r[2]=(e&255)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){const t=[...e],[r,s,n]=this.convertLinearToSRGB(e,t);return r*255<<16^s*255<<8^n*255<<0}static convertSRGBToLinear(e,t){const r=e,s=t;for(let n=0;n<3;n++)s[n]=r[n]<.04045?r[n]*.0773993808:Math.pow(r[n]*.9478672986+.0521327014,2.4);return t}static convertLinearToSRGB(e,t){const r=e,s=t;for(let n=0;n<3;n++)s[n]=r[n]<.0031308?r[n]*12.92:1.055*Math.pow(r[n],.41666)-.055;return t}}class jn{match(e){return e.length>=3&&e[0]===255&&e[1]===216&&e[2]===255}getSize(e){let t=new DataView(e.buffer,e.byteOffset+4),r,s;for(;t.byteLength;){if(r=t.getUint16(0,!1),Un(t,r),s=t.getUint8(r+1),s===192||s===193||s===194)return[t.getUint16(r+7,!1),t.getUint16(r+5,!1)];t=new DataView(e.buffer,t.byteOffset+r+2)}throw new TypeError("Invalid JPG, no size found")}getChannels(e){return 3}}class ct{match(e){return e.length>=8&&e[0]===137&&e[1]===80&&e[2]===78&&e[3]===71&&e[4]===13&&e[5]===10&&e[6]===26&&e[7]===10}getSize(e){const t=new DataView(e.buffer,e.byteOffset);return D.decodeText(e.slice(12,16))===ct.PNG_FRIED_CHUNK_NAME?[t.getUint32(32,!1),t.getUint32(36,!1)]:[t.getUint32(16,!1),t.getUint32(20,!1)]}getChannels(e){return 4}}ct.PNG_FRIED_CHUNK_NAME="CgBI";class ae{static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(const t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){return this.impls[t]?this.impls[t].getSize(e):null}static getChannels(e,t){return this.impls[t]?this.impls[t].getChannels(e):null}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let r=0;const s=4,n=this.getSize(e,t);if(!n)return null;for(;n[0]>1||n[1]>1;)r+=n[0]*n[1]*s,n[0]=Math.max(Math.floor(n[0]/2),1),n[1]=Math.max(Math.floor(n[1]/2),1);return r+=1*1*s,r}static mimeTypeToExtension(e){return e==="image/jpeg"?"jpg":e.split("/").pop()}static extensionToMimeType(e){return e==="jpg"?"image/jpeg":e?`image/${e}`:""}}ae.impls={"image/jpeg":new jn,"image/png":new ct};function Un(i,e){if(e>i.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(i.getUint8(e)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return i}class Pe{static basename(e){const t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){const t=e.match(/data:(image\/\w+)/)[1];return ae.mimeTypeToExtension(t)}else{if(e.startsWith("data:model/gltf+json"))return"gltf";if(e.startsWith("data:model/gltf-binary"))return"glb";if(e.startsWith("data:application/"))return"bin"}return e.split(/[\\/]/).pop().split(/[.]/).pop()}}function Kt(i){return Object.prototype.toString.call(i)==="[object Object]"}function Ce(i){if(Kt(i)===!1)return!1;const e=i.constructor;if(e===void 0)return!0;const t=e.prototype;return!(Kt(t)===!1||Object.prototype.hasOwnProperty.call(t,"isPrototypeOf")===!1)}var mt,xt;(function(i){i[i.SILENT=4]="SILENT",i[i.ERROR=3]="ERROR",i[i.WARN=2]="WARN",i[i.INFO=1]="INFO",i[i.DEBUG=0]="DEBUG"})(xt||(xt={}));class ee{constructor(e){this.verbosity=void 0,this.verbosity=e}debug(e){this.verbosity<=ee.Verbosity.DEBUG&&console.debug(e)}info(e){this.verbosity<=ee.Verbosity.INFO&&console.info(e)}warn(e){this.verbosity<=ee.Verbosity.WARN&&console.warn(e)}error(e){this.verbosity<=ee.Verbosity.ERROR&&console.error(e)}}mt=ee;ee.Verbosity=xt;ee.DEFAULT_INSTANCE=new mt(mt.Verbosity.INFO);function Pn(i){var e=i[0],t=i[1],r=i[2],s=i[3],n=i[4],o=i[5],a=i[6],c=i[7],u=i[8],g=i[9],p=i[10],m=i[11],N=i[12],S=i[13],w=i[14],M=i[15],l=e*o-t*n,b=e*a-r*n,T=e*c-s*n,R=t*a-r*o,x=t*c-s*o,y=r*c-s*a,f=u*S-g*N,d=u*w-p*N,E=u*M-m*N,I=g*w-p*S,_=g*M-m*S,O=p*M-m*w;return l*O-b*_+T*I+R*E-x*d+y*f}function Gn(i,e,t){var r=e[0],s=e[1],n=e[2],o=e[3],a=e[4],c=e[5],u=e[6],g=e[7],p=e[8],m=e[9],N=e[10],S=e[11],w=e[12],M=e[13],l=e[14],b=e[15],T=t[0],R=t[1],x=t[2],y=t[3];return i[0]=T*r+R*a+x*p+y*w,i[1]=T*s+R*c+x*m+y*M,i[2]=T*n+R*u+x*N+y*l,i[3]=T*o+R*g+x*S+y*b,T=t[4],R=t[5],x=t[6],y=t[7],i[4]=T*r+R*a+x*p+y*w,i[5]=T*s+R*c+x*m+y*M,i[6]=T*n+R*u+x*N+y*l,i[7]=T*o+R*g+x*S+y*b,T=t[8],R=t[9],x=t[10],y=t[11],i[8]=T*r+R*a+x*p+y*w,i[9]=T*s+R*c+x*m+y*M,i[10]=T*n+R*u+x*N+y*l,i[11]=T*o+R*g+x*S+y*b,T=t[12],R=t[13],x=t[14],y=t[15],i[12]=T*r+R*a+x*p+y*w,i[13]=T*s+R*c+x*m+y*M,i[14]=T*n+R*u+x*N+y*l,i[15]=T*o+R*g+x*S+y*b,i}function Vn(i,e){var t=e[0],r=e[1],s=e[2],n=e[4],o=e[5],a=e[6],c=e[8],u=e[9],g=e[10];return i[0]=Math.hypot(t,r,s),i[1]=Math.hypot(n,o,a),i[2]=Math.hypot(c,u,g),i}function kn(i,e){var t=new dt(3);Vn(t,e);var r=1/t[0],s=1/t[1],n=1/t[2],o=e[0]*r,a=e[1]*s,c=e[2]*n,u=e[4]*r,g=e[5]*s,p=e[6]*n,m=e[8]*r,N=e[9]*s,S=e[10]*n,w=o+g+S,M=0;return w>0?(M=Math.sqrt(w+1)*2,i[3]=.25*M,i[0]=(p-N)/M,i[1]=(m-c)/M,i[2]=(a-u)/M):o>g&&o>S?(M=Math.sqrt(1+o-g-S)*2,i[3]=(p-N)/M,i[0]=.25*M,i[1]=(a+u)/M,i[2]=(m+c)/M):g>S?(M=Math.sqrt(1+g-o-S)*2,i[3]=(m-c)/M,i[0]=(a+u)/M,i[1]=.25*M,i[2]=(p+N)/M):(M=Math.sqrt(1+S-o-g)*2,i[3]=(a-u)/M,i[0]=(m+c)/M,i[1]=(p+N)/M,i[2]=.25*M),i}class B{static identity(e){return e}static eq(e,t,r=1e-5){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(Math.abs(e[s]-t[s])>r)return!1;return!0}static clamp(e,t,r){return e<t?t:e>r?r:e}static decodeNormalizedInt(e,t){switch(t){case 5126:return e;case 5123:return e/65535;case 5121:return e/255;case 5122:return Math.max(e/32767,-1);case 5120:return Math.max(e/127,-1);default:throw new Error("Invalid component type.")}}static encodeNormalizedInt(e,t){switch(t){case 5126:return e;case 5123:return Math.round(B.clamp(e,0,1)*65535);case 5121:return Math.round(B.clamp(e,0,1)*255);case 5122:return Math.round(B.clamp(e,-1,1)*32767);case 5120:return Math.round(B.clamp(e,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(e,t,r,s){let n=gt([e[0],e[1],e[2]]);const o=gt([e[4],e[5],e[6]]),a=gt([e[8],e[9],e[10]]);Pn(e)<0&&(n=-n),t[0]=e[12],t[1]=e[13],t[2]=e[14];const u=e.slice(),g=1/n,p=1/o,m=1/a;u[0]*=g,u[1]*=g,u[2]*=g,u[4]*=p,u[5]*=p,u[6]*=p,u[8]*=m,u[9]*=m,u[10]*=m,kn(r,u),s[0]=n,s[1]=o,s[2]=a}static compose(e,t,r,s){const n=s,o=t[0],a=t[1],c=t[2],u=t[3],g=o+o,p=a+a,m=c+c,N=o*g,S=o*p,w=o*m,M=a*p,l=a*m,b=c*m,T=u*g,R=u*p,x=u*m,y=r[0],f=r[1],d=r[2];return n[0]=(1-(M+b))*y,n[1]=(S+x)*y,n[2]=(w-R)*y,n[3]=0,n[4]=(S-x)*f,n[5]=(1-(N+b))*f,n[6]=(l+T)*f,n[7]=0,n[8]=(w+R)*d,n[9]=(l-T)*d,n[10]=(1-(N+M))*d,n[11]=0,n[12]=e[0],n[13]=e[1],n[14]=e[2],n[15]=1,n}}function Hn(i,e){if(!!i!=!!e)return!1;const t=i.getChild(),r=e.getChild();return t===r||t.equals(r)}function zn(i,e){if(!!i!=!!e)return!1;const t=i.values(),r=e.values();if(t.length!==r.length)return!1;for(let s=0;s<t.length;s++){const n=t[s],o=r[s];if(n.getChild()!==o.getChild()&&!n.getChild().equals(o.getChild()))return!1}return!0}function $n(i,e){if(!!i!=!!e)return!1;const t=i.keys(),r=e.keys();if(t.length!==r.length)return!1;for(const s of t){const n=i.get(s),o=e.get(s);if(!!n!=!!o)return!1;const a=n.getChild(),c=o.getChild();if(a!==c&&!a.equals(c))return!1}return!0}function ms(i,e){if(i===e)return!0;if(!!i!=!!e||!i||!e||i.length!==e.length)return!1;for(let t=0;t<i.length;t++)if(i[t]!==e[t])return!1;return!0}function xs(i,e){if(i===e)return!0;if(!!i!=!!e)return!1;if(!Ce(i)||!Ce(e))return i===e;const t=i,r=e;let s=0,n=0,o;for(o in t)s++;for(o in r)n++;if(s!==n)return!1;for(o in t){const a=t[o],c=r[o];if(rt(a)&&rt(c)){if(!ms(a,c))return!1}else if(Ce(a)&&Ce(c)){if(!xs(a,c))return!1}else if(a!==c)return!1}return!0}function rt(i){return Array.isArray(i)||ArrayBuffer.isView(i)}const qt="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",Xn=999,Kn=6,Yt=new Set,qn=function(){let e="";for(let t=0;t<Kn;t++)e+=qt.charAt(Math.floor(Math.random()*qt.length));return e},Yn=function(){for(let e=0;e<Xn;e++){const t=qn();if(!Yt.has(t))return Yt.add(t),t}return""},Wt="https://null.example";class Ke{static dirname(e){const t=e.lastIndexOf("/");return t===-1?"./":e.substring(0,t+1)}static basename(e){return Pe.basename(new URL(e,Wt).pathname)}static extension(e){return Pe.extension(new URL(e,Wt).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;const r=e.split("/"),s=t.split("/");r.pop();for(let n=0;n<s.length;n++)s[n]!=="."&&(s[n]===".."?r.pop():r.push(s[n]));return r.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}}Ke.DEFAULT_INIT={};Ke.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;const pe=i=>i,Wn=new Set;class St extends At{constructor(e,t=""){super(e),this[F].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){return Array.isArray(t)&&(t=t.slice()),super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){const e=this.constructor;return new e(this.graph).copy(this,pe)}copy(e,t=pe){for(const r in this[F]){const s=this[F][r];if(s instanceof Be)this[_e].has(r)||s.dispose();else if(s instanceof he||s instanceof P)for(const n of s.values())n.dispose();else if(s instanceof ne)for(const n of s.values())n.dispose()}for(const r in e[F]){const s=this[F][r],n=e[F][r];if(n instanceof Be)this[_e].has(r)?s.getChild().copy(t(n.getChild()),t):this.setRef(r,t(n.getChild()),n.getAttributes());else if(n instanceof P||n instanceof he)for(const o of n.values())this.addRef(r,t(o.getChild()),o.getAttributes());else if(n instanceof ne)for(const o of n.keys()){const a=n.get(o);this.setRefMap(r,o,t(a.getChild()),a.getAttributes())}else Ce(n)?this[F][r]=JSON.parse(JSON.stringify(n)):Array.isArray(n)||n instanceof ArrayBuffer||ArrayBuffer.isView(n)?this[F][r]=n.slice():this[F][r]=n}return this}equals(e,t=Wn){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(const r in this[F]){if(t.has(r))continue;const s=this[F][r],n=e[F][r];if(s instanceof Be||n instanceof Be){if(!Hn(s,n))return!1}else if(s instanceof P||n instanceof P||s instanceof he||n instanceof he){if(!zn(s,n))return!1}else if(s instanceof ne||n instanceof ne){if(!$n(s,n))return!1}else if(Ce(s)||Ce(n)){if(!xs(s,n))return!1}else if(rt(s)||rt(n)){if(!ms(s,n))return!1}else if(s!==n)return!1}return!0}detach(){return this.graph.disconnectParents(this,e=>e.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}}class q extends St{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new ne})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){return t&&t._validateParent(this),this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}}class A extends q{init(){this.propertyType=h.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:A.Type.SCALAR,componentType:A.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(e){switch(e){case A.Type.SCALAR:return 1;case A.Type.VEC2:return 2;case A.Type.VEC3:return 3;case A.Type.VEC4:return 4;case A.Type.MAT2:return 4;case A.Type.MAT3:return 9;case A.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+e)}}static getComponentSize(e){switch(e){case A.ComponentType.BYTE:return 1;case A.ComponentType.UNSIGNED_BYTE:return 1;case A.ComponentType.SHORT:return 2;case A.ComponentType.UNSIGNED_SHORT:return 2;case A.ComponentType.UNSIGNED_INT:return 4;case A.ComponentType.FLOAT:return 4;default:throw new Error("Unexpected component type: "+e)}}getMinNormalized(e){const t=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType();if(this.getMin(e),t)for(let n=0;n<r;n++)e[n]=B.decodeNormalizedInt(e[n],s);return e}getMin(e){const t=this.getArray(),r=this.getCount(),s=this.getElementSize();for(let n=0;n<s;n++)e[n]=1/0;for(let n=0;n<r*s;n+=s)for(let o=0;o<s;o++){const a=t[n+o];Number.isFinite(a)&&(e[o]=Math.min(e[o],a))}return e}getMaxNormalized(e){const t=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType();if(this.getMax(e),t)for(let n=0;n<r;n++)e[n]=B.decodeNormalizedInt(e[n],s);return e}getMax(e){const t=this.get("array"),r=this.getCount(),s=this.getElementSize();for(let n=0;n<s;n++)e[n]=-1/0;for(let n=0;n<r*s;n+=s)for(let o=0;o<s;o++){const a=t[n+o];Number.isFinite(a)&&(e[o]=Math.max(e[o],a))}return e}getCount(){const e=this.get("array");return e?e.length/this.getElementSize():0}getType(){return this.get("type")}setType(e){return this.set("type",e)}getElementSize(){return A.getElementSize(this.get("type"))}getComponentSize(){return this.get("array").BYTES_PER_ELEMENT}getComponentType(){return this.get("componentType")}getNormalized(){return this.get("normalized")}setNormalized(e){return this.set("normalized",e)}getScalar(e){const t=this.getElementSize(),r=this.getComponentType(),s=this.getArray();return this.getNormalized()?B.decodeNormalizedInt(s[e*t],r):s[e*t]}setScalar(e,t){const r=this.getElementSize(),s=this.getComponentType(),n=this.getArray();return this.getNormalized()?n[e*r]=B.encodeNormalizedInt(t,s):n[e*r]=t,this}getElement(e,t){const r=this.getNormalized(),s=this.getElementSize(),n=this.getComponentType(),o=this.getArray();for(let a=0;a<s;a++)r?t[a]=B.decodeNormalizedInt(o[e*s+a],n):t[a]=o[e*s+a];return t}setElement(e,t){const r=this.getNormalized(),s=this.getElementSize(),n=this.getComponentType(),o=this.getArray();for(let a=0;a<s;a++)r?o[e*s+a]=B.encodeNormalizedInt(t[a],n):o[e*s+a]=t[a];return this}getSparse(){return this.get("sparse")}setSparse(e){return this.set("sparse",e)}getBuffer(){return this.getRef("buffer")}setBuffer(e){return this.setRef("buffer",e)}getArray(){return this.get("array")}setArray(e){return this.set("componentType",e?Jn(e):A.ComponentType.FLOAT),this.set("array",e),this}getByteLength(){const e=this.get("array");return e?e.byteLength:0}}A.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};A.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};function Jn(i){switch(i.constructor){case Float32Array:return A.ComponentType.FLOAT;case Uint32Array:return A.ComponentType.UNSIGNED_INT;case Uint16Array:return A.ComponentType.UNSIGNED_SHORT;case Uint8Array:return A.ComponentType.UNSIGNED_BYTE;case Int16Array:return A.ComponentType.SHORT;case Int8Array:return A.ComponentType.BYTE;default:throw new Error("Unknown accessor componentType.")}}class Es extends q{init(){this.propertyType=h.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new P,samplers:new P})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}}class Mt extends q{init(){this.propertyType=h.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}}Mt.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};class Ve extends q{init(){this.propertyType=h.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:Ve.Interpolation.LINEAR,input:null,output:null})}getInterpolation(){return this.get("interpolation")}setInterpolation(e){return this.set("interpolation",e)}getInput(){return this.getRef("input")}setInput(e){return this.setRef("input",e,{usage:J.OTHER})}getOutput(){return this.getRef("output")}setOutput(e){return this.setRef("output",e,{usage:J.OTHER})}}Ve.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class Rs extends q{init(){this.propertyType=h.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}}class ve extends q{init(){this.propertyType=h.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:ve.Type.PERSPECTIVE,znear:.1,zfar:100,aspectRatio:null,yfov:Math.PI*2*50/360,xmag:1,ymag:1})}getType(){return this.get("type")}setType(e){return this.set("type",e)}getZNear(){return this.get("znear")}setZNear(e){return this.set("znear",e)}getZFar(){return this.get("zfar")}setZFar(e){return this.set("zfar",e)}getAspectRatio(){return this.get("aspectRatio")}setAspectRatio(e){return this.set("aspectRatio",e)}getYFov(){return this.get("yfov")}setYFov(e){return this.set("yfov",e)}getXMag(){return this.get("xmag")}setXMag(e){return this.set("xmag",e)}getYMag(){return this.get("ymag")}setYMag(e){return this.set("ymag",e)}}ve.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class V extends St{_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw new Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}}V.EXTENSION_NAME=void 0;class j extends q{init(){this.propertyType=h.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:j.WrapMode.REPEAT,wrapT:j.WrapMode.REPEAT})}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}getMagFilter(){return this.get("magFilter")}setMagFilter(e){return this.set("magFilter",e)}getMinFilter(){return this.get("minFilter")}setMinFilter(e){return this.set("minFilter",e)}getWrapS(){return this.get("wrapS")}setWrapS(e){return this.set("wrapS",e)}getWrapT(){return this.get("wrapT")}setWrapT(e){return this.set("wrapT",e)}}j.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};j.MagFilter={NEAREST:9728,LINEAR:9729};j.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};const{R:Qe,G:Ze,B:et,A:Qn}=te;class Oe extends q{init(){this.propertyType=h.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:Oe.AlphaMode.OPAQUE,alphaCutoff:.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new j(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new j(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new j(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new j(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new j(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(e){return this.set("doubleSided",e)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(e){const t=this.get("baseColorFactor").slice();return t[3]=e,this.set("baseColorFactor",t)}getAlphaMode(){return this.get("alphaMode")}setAlphaMode(e){return this.set("alphaMode",e)}getAlphaCutoff(){return this.get("alphaCutoff")}setAlphaCutoff(e){return this.set("alphaCutoff",e)}getBaseColorFactor(){return this.get("baseColorFactor")}setBaseColorFactor(e){return this.set("baseColorFactor",e)}getBaseColorTexture(){return this.getRef("baseColorTexture")}getBaseColorTextureInfo(){return this.getRef("baseColorTexture")?this.getRef("baseColorTextureInfo"):null}setBaseColorTexture(e){return this.setRef("baseColorTexture",e,{channels:Qe|Ze|et|Qn,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(e){return this.set("emissiveFactor",e)}getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(e){return this.setRef("emissiveTexture",e,{channels:Qe|Ze|et,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(e){return this.set("normalScale",e)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(e){return this.setRef("normalTexture",e,{channels:Qe|Ze|et})}getOcclusionStrength(){return this.get("occlusionStrength")}setOcclusionStrength(e){return this.set("occlusionStrength",e)}getOcclusionTexture(){return this.getRef("occlusionTexture")}getOcclusionTextureInfo(){return this.getRef("occlusionTexture")?this.getRef("occlusionTextureInfo"):null}setOcclusionTexture(e){return this.setRef("occlusionTexture",e,{channels:Qe})}getRoughnessFactor(){return this.get("roughnessFactor")}setRoughnessFactor(e){return this.set("roughnessFactor",e)}getMetallicFactor(){return this.get("metallicFactor")}setMetallicFactor(e){return this.set("metallicFactor",e)}getMetallicRoughnessTexture(){return this.getRef("metallicRoughnessTexture")}getMetallicRoughnessTextureInfo(){return this.getRef("metallicRoughnessTexture")?this.getRef("metallicRoughnessTextureInfo"):null}setMetallicRoughnessTexture(e){return this.setRef("metallicRoughnessTexture",e,{channels:Ze|et})}}Oe.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class Is extends q{init(){this.propertyType=h.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new P})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}}class ys extends q{init(){this.propertyType=h.NODE}getDefaults(){return Object.assign(super.getDefaults(),{translation:[0,0,0],rotation:[0,0,0,1],scale:[1,1,1],weights:[],camera:null,mesh:null,skin:null,children:new P})}copy(e,t=pe){if(t===pe)throw new Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return B.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){const t=this.get("translation").slice(),r=this.get("rotation").slice(),s=this.get("scale").slice();return B.decompose(e,t,r,s),this.set("translation",t).set("rotation",r).set("scale",s)}getWorldTranslation(){const e=[0,0,0];return B.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){const e=[0,0,0,1];return B.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){const e=[1,1,1];return B.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){const e=[];for(let s=this;s!=null;s=s.getParentNode())e.push(s);let t;const r=e.pop().getMatrix();for(;t=e.pop();)Gn(r,r,t.getMatrix());return r}addChild(e){const t=e.getParentNode();t&&t.removeChild(e);for(const r of e.listParents())r.propertyType===h.SCENE&&r.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(const e of this.listParents())if(e.propertyType===h.NODE)return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){e(this);for(const t of this.listChildren())t.traverse(e);return this}}class De extends q{init(){this.propertyType=h.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:De.Mode.TRIANGLES,material:null,indices:null,attributes:new ne,targets:new P})}getIndices(){return this.getRef("indices")}setIndices(e){return this.setRef("indices",e,{usage:J.ELEMENT_ARRAY_BUFFER})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:J.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}getMode(){return this.get("mode")}setMode(e){return this.set("mode",e)}listTargets(){return this.listRefs("targets")}addTarget(e){return this.addRef("targets",e)}removeTarget(e){return this.removeRef("targets",e)}}De.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class Zn extends St{init(){this.propertyType=h.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new ne})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:J.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function K(){return K=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},K.apply(null,arguments)}class Ns extends q{init(){this.propertyType=h.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new P})}copy(e,t=pe){if(t===pe)throw new Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){const t=e.getParentNode();return t&&t.removeChild(e),this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(const t of this.listChildren())t.traverse(e);return this}}class As extends q{init(){this.propertyType=h.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new P})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:J.INVERSE_BIND_MATRICES})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}}class Ss extends q{init(){this.propertyType=h.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||ae.extensionToMimeType(Pe.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);const t=ae.extensionToMimeType(Pe.extension(e));return t&&this.set("mimeType",t),this}getImage(){return this.get("image")}setImage(e){return this.set("image",D.assertView(e))}getSize(){const e=this.get("image");return e?ae.getSize(e,this.getMimeType()):null}}class Ms extends q{init(){this.propertyType=h.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${ds}`,version:"2.0"},defaultScene:null,accessors:new P,animations:new P,buffers:new P,cameras:new P,materials:new P,meshes:new P,nodes:new P,scenes:new P,skins:new P,textures:new P})}constructor(e){super(e),this._extensions=new Set,e.addEventListener("node:create",t=>{this._addChildOfRoot(t.target)})}clone(){throw new Error("Root cannot be cloned.")}copy(e,t=pe){if(t===pe)throw new Error("Root cannot be copied.");this.set("asset",K({},e.get("asset"))),this.setName(e.getName()),this.setExtras(K({},e.getExtras())),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null);for(const r of e.listRefMapKeys("extensions")){const s=e.getExtension(r);this.setExtension(r,t(s))}return this}_addChildOfRoot(e){return e instanceof Ns?this.addRef("scenes",e):e instanceof ys?this.addRef("nodes",e):e instanceof ve?this.addRef("cameras",e):e instanceof As?this.addRef("skins",e):e instanceof Is?this.addRef("meshes",e):e instanceof Oe?this.addRef("materials",e):e instanceof Ss?this.addRef("textures",e):e instanceof Es?this.addRef("animations",e):e instanceof A?this.addRef("accessors",e):e instanceof Rs&&this.addRef("buffers",e),this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter(e=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class qe{static fromGraph(e){return qe._GRAPH_DOCUMENTS.get(e)||null}constructor(){this._graph=new Dn,this._root=new Ms(this._graph),this._logger=ee.DEFAULT_INSTANCE,qe._GRAPH_DOCUMENTS.set(this._graph,this)}getRoot(){return this._root}getGraph(){return this._graph}getLogger(){return this._logger}setLogger(e){return this._logger=e,this}clone(){throw new Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(e){throw new Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...e){const t=e.map(r=>r.name);for(const r of e)await r(this,{stack:t});return this}createExtension(e){const t=e.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(s=>s.extensionName===t)||new e(this)}createScene(e=""){return new Ns(this._graph,e)}createNode(e=""){return new ys(this._graph,e)}createCamera(e=""){return new ve(this._graph,e)}createSkin(e=""){return new As(this._graph,e)}createMesh(e=""){return new Is(this._graph,e)}createPrimitive(){return new De(this._graph)}createPrimitiveTarget(e=""){return new Zn(this._graph,e)}createMaterial(e=""){return new Oe(this._graph,e)}createTexture(e=""){return new Ss(this._graph,e)}createAnimation(e=""){return new Es(this._graph,e)}createAnimationChannel(e=""){return new Mt(this._graph,e)}createAnimationSampler(e=""){return new Ve(this._graph,e)}createAccessor(e="",t=null){return t||(t=this.getRoot().listBuffers()[0]),new A(this._graph,e).setBuffer(t)}createBuffer(e=""){return new Rs(this._graph,e)}}qe._GRAPH_DOCUMENTS=new WeakMap;class U{constructor(e){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=e,e.getRoot()._enableExtension(this),this._listener=r=>{const s=r,n=s.target;n instanceof V&&n.extensionName===this.extensionName&&(s.type==="node:create"&&this._addExtensionProperty(n),s.type==="node:dispose"&&this._removeExtensionProperty(n))};const t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);const e=this.document.getGraph();e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener);for(const t of this.properties)t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}}U.EXTENSION_NAME=void 0;class er{constructor(e){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=e}setTextureInfo(e,t){this.textureInfos.set(e,t),t.texCoord!==void 0&&e.setTexCoord(t.texCoord),t.extras!==void 0&&e.setExtras(t.extras);const r=this.jsonDoc.json.textures[t.index];if(r.sampler===void 0)return;const s=this.jsonDoc.json.samplers[r.sampler];s.magFilter!==void 0&&e.setMagFilter(s.magFilter),s.minFilter!==void 0&&e.setMinFilter(s.minFilter),s.wrapS!==void 0&&e.setWrapS(s.wrapS),s.wrapT!==void 0&&e.setWrapT(s.wrapT)}}const Jt={logger:ee.DEFAULT_INSTANCE,extensions:[],dependencies:{}},tr=new Set([h.BUFFER,h.TEXTURE,h.MATERIAL,h.MESH,h.PRIMITIVE,h.NODE,h.SCENE]);class sr{static read(e,t=Jt){const r=K({},Jt,t),{json:s}=e,n=new qe().setLogger(r.logger);this.validate(e,r);const o=new er(e),a=s.asset,c=n.getRoot().getAsset();a.copyright&&(c.copyright=a.copyright),a.extras&&(c.extras=a.extras),s.extras!==void 0&&n.getRoot().setExtras(K({},s.extras));const u=s.extensionsUsed||[],g=s.extensionsRequired||[];r.extensions.sort((f,d)=>f.EXTENSION_NAME>d.EXTENSION_NAME?1:-1);for(const f of r.extensions)if(u.includes(f.EXTENSION_NAME)){const d=n.createExtension(f).setRequired(g.includes(f.EXTENSION_NAME)),E=d.prereadTypes.filter(I=>!tr.has(I));E.length&&r.logger.warn(`Preread hooks for some types (${E.join()}), requested by extension ${d.extensionName}, are unsupported. Please file an issue or a PR.`);for(const I of d.readDependencies)d.install(I,r.dependencies[I])}const p=s.buffers||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.BUFFER)).forEach(f=>f.preread(o,h.BUFFER)),o.buffers=p.map(f=>{const d=n.createBuffer(f.name);return f.extras&&d.setExtras(f.extras),f.uri&&f.uri.indexOf("__")!==0&&d.setURI(f.uri),d});const m=s.bufferViews||[];o.bufferViewBuffers=m.map((f,d)=>{if(!o.bufferViews[d]){const E=e.json.buffers[f.buffer],I=E.uri?e.resources[E.uri]:e.resources[Ue],_=f.byteOffset||0;o.bufferViews[d]=D.toView(I,_,f.byteLength)}return o.buffers[f.buffer]});const N=s.accessors||[];o.accessors=N.map(f=>{const d=o.bufferViewBuffers[f.bufferView],E=n.createAccessor(f.name,d).setType(f.type);return f.extras&&E.setExtras(f.extras),f.normalized!==void 0&&E.setNormalized(f.normalized),f.bufferView===void 0||E.setArray(st(f,o)),E});const S=s.images||[],w=s.textures||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.TEXTURE)).forEach(f=>f.preread(o,h.TEXTURE)),o.textures=S.map(f=>{const d=n.createTexture(f.name);if(f.extras&&d.setExtras(f.extras),f.bufferView!==void 0){const E=s.bufferViews[f.bufferView],I=e.json.buffers[E.buffer],_=I.uri?e.resources[I.uri]:e.resources[Ue],O=E.byteOffset||0,C=E.byteLength,G=_.slice(O,O+C);d.setImage(G)}else f.uri!==void 0&&(d.setImage(e.resources[f.uri]),f.uri.indexOf("__")!==0&&d.setURI(f.uri));if(f.mimeType!==void 0)d.setMimeType(f.mimeType);else if(f.uri){const E=Pe.extension(f.uri);d.setMimeType(ae.extensionToMimeType(E))}return d}),n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.MATERIAL)).forEach(f=>f.preread(o,h.MATERIAL));const M=s.materials||[];o.materials=M.map(f=>{const d=n.createMaterial(f.name);f.extras&&d.setExtras(f.extras),f.alphaMode!==void 0&&d.setAlphaMode(f.alphaMode),f.alphaCutoff!==void 0&&d.setAlphaCutoff(f.alphaCutoff),f.doubleSided!==void 0&&d.setDoubleSided(f.doubleSided);const E=f.pbrMetallicRoughness||{};if(E.baseColorFactor!==void 0&&d.setBaseColorFactor(E.baseColorFactor),f.emissiveFactor!==void 0&&d.setEmissiveFactor(f.emissiveFactor),E.metallicFactor!==void 0&&d.setMetallicFactor(E.metallicFactor),E.roughnessFactor!==void 0&&d.setRoughnessFactor(E.roughnessFactor),E.baseColorTexture!==void 0){const I=E.baseColorTexture,_=o.textures[w[I.index].source];d.setBaseColorTexture(_),o.setTextureInfo(d.getBaseColorTextureInfo(),I)}if(f.emissiveTexture!==void 0){const I=f.emissiveTexture,_=o.textures[w[I.index].source];d.setEmissiveTexture(_),o.setTextureInfo(d.getEmissiveTextureInfo(),I)}if(f.normalTexture!==void 0){const I=f.normalTexture,_=o.textures[w[I.index].source];d.setNormalTexture(_),o.setTextureInfo(d.getNormalTextureInfo(),I),f.normalTexture.scale!==void 0&&d.setNormalScale(f.normalTexture.scale)}if(f.occlusionTexture!==void 0){const I=f.occlusionTexture,_=o.textures[w[I.index].source];d.setOcclusionTexture(_),o.setTextureInfo(d.getOcclusionTextureInfo(),I),f.occlusionTexture.strength!==void 0&&d.setOcclusionStrength(f.occlusionTexture.strength)}if(E.metallicRoughnessTexture!==void 0){const I=E.metallicRoughnessTexture,_=o.textures[w[I.index].source];d.setMetallicRoughnessTexture(_),o.setTextureInfo(d.getMetallicRoughnessTextureInfo(),I)}return d}),n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.MESH)).forEach(f=>f.preread(o,h.MESH));const l=s.meshes||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.PRIMITIVE)).forEach(f=>f.preread(o,h.PRIMITIVE)),o.meshes=l.map(f=>{const d=n.createMesh(f.name);return f.extras&&d.setExtras(f.extras),f.weights!==void 0&&d.setWeights(f.weights),(f.primitives||[]).forEach(I=>{const _=n.createPrimitive();I.extras&&_.setExtras(I.extras),I.material!==void 0&&_.setMaterial(o.materials[I.material]),I.mode!==void 0&&_.setMode(I.mode);for(const[G,v]of Object.entries(I.attributes||{}))_.setAttribute(G,o.accessors[v]);I.indices!==void 0&&_.setIndices(o.accessors[I.indices]);const O=f.extras&&f.extras.targetNames||[];(I.targets||[]).forEach((G,v)=>{const L=O[v]||v.toString(),z=n.createPrimitiveTarget(L);for(const[se,W]of Object.entries(G))z.setAttribute(se,o.accessors[W]);_.addTarget(z)}),d.addPrimitive(_)}),d});const b=s.cameras||[];o.cameras=b.map(f=>{const d=n.createCamera(f.name).setType(f.type);if(f.extras&&d.setExtras(f.extras),f.type===ve.Type.PERSPECTIVE){const E=f.perspective;d.setYFov(E.yfov),d.setZNear(E.znear),E.zfar!==void 0&&d.setZFar(E.zfar),E.aspectRatio!==void 0&&d.setAspectRatio(E.aspectRatio)}else{const E=f.orthographic;d.setZNear(E.znear).setZFar(E.zfar).setXMag(E.xmag).setYMag(E.ymag)}return d});const T=s.nodes||[];n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.NODE)).forEach(f=>f.preread(o,h.NODE)),o.nodes=T.map(f=>{const d=n.createNode(f.name);if(f.extras&&d.setExtras(f.extras),f.translation!==void 0&&d.setTranslation(f.translation),f.rotation!==void 0&&d.setRotation(f.rotation),f.scale!==void 0&&d.setScale(f.scale),f.matrix!==void 0){const E=[0,0,0],I=[0,0,0,1],_=[1,1,1];B.decompose(f.matrix,E,I,_),d.setTranslation(E),d.setRotation(I),d.setScale(_)}return f.weights!==void 0&&d.setWeights(f.weights),d});const R=s.skins||[];o.skins=R.map(f=>{const d=n.createSkin(f.name);f.extras&&d.setExtras(f.extras),f.inverseBindMatrices!==void 0&&d.setInverseBindMatrices(o.accessors[f.inverseBindMatrices]),f.skeleton!==void 0&&d.setSkeleton(o.nodes[f.skeleton]);for(const E of f.joints)d.addJoint(o.nodes[E]);return d}),T.map((f,d)=>{const E=o.nodes[d];(f.children||[]).forEach(_=>E.addChild(o.nodes[_])),f.mesh!==void 0&&E.setMesh(o.meshes[f.mesh]),f.camera!==void 0&&E.setCamera(o.cameras[f.camera]),f.skin!==void 0&&E.setSkin(o.skins[f.skin])});const x=s.animations||[];o.animations=x.map(f=>{const d=n.createAnimation(f.name);f.extras&&d.setExtras(f.extras);const I=(f.samplers||[]).map(O=>{const C=n.createAnimationSampler().setInput(o.accessors[O.input]).setOutput(o.accessors[O.output]).setInterpolation(O.interpolation||Ve.Interpolation.LINEAR);return O.extras&&C.setExtras(O.extras),d.addSampler(C),C});return(f.channels||[]).forEach(O=>{const C=n.createAnimationChannel().setSampler(I[O.sampler]).setTargetPath(O.target.path);O.target.node!==void 0&&C.setTargetNode(o.nodes[O.target.node]),O.extras&&C.setExtras(O.extras),d.addChannel(C)}),d});const y=s.scenes||[];return n.getRoot().listExtensionsUsed().filter(f=>f.prereadTypes.includes(h.SCENE)).forEach(f=>f.preread(o,h.SCENE)),o.scenes=y.map(f=>{const d=n.createScene(f.name);return f.extras&&d.setExtras(f.extras),(f.nodes||[]).map(I=>o.nodes[I]).forEach(I=>d.addChild(I)),d}),s.scene!==void 0&&n.getRoot().setDefaultScene(o.scenes[s.scene]),n.getRoot().listExtensionsUsed().forEach(f=>f.read(o)),N.forEach((f,d)=>{const E=o.accessors[d],I=!!f.sparse,_=!f.bufferView&&!E.getArray();(I||_)&&E.setSparse(!0).setArray(rr(f,o))}),n}static validate(e,t){const r=e.json;if(r.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${r.asset.version}".`);if(r.extensionsRequired){for(const s of r.extensionsRequired)if(!t.extensions.find(n=>n.EXTENSION_NAME===s))throw new Error(`Missing required extension, "${s}".`)}if(r.extensionsUsed)for(const s of r.extensionsUsed)t.extensions.find(n=>n.EXTENSION_NAME===s)||t.logger.warn(`Missing optional extension, "${s}".`)}}function nr(i,e){const t=e.jsonDoc,r=e.bufferViews[i.bufferView],s=t.json.bufferViews[i.bufferView],n=at[i.componentType],o=A.getElementSize(i.type),a=n.BYTES_PER_ELEMENT,c=i.byteOffset||0,u=new n(i.count*o),g=new DataView(r.buffer,r.byteOffset,r.byteLength),p=s.byteStride;for(let m=0;m<i.count;m++)for(let N=0;N<o;N++){const S=c+m*p+N*a;let w;switch(i.componentType){case A.ComponentType.FLOAT:w=g.getFloat32(S,!0);break;case A.ComponentType.UNSIGNED_INT:w=g.getUint32(S,!0);break;case A.ComponentType.UNSIGNED_SHORT:w=g.getUint16(S,!0);break;case A.ComponentType.UNSIGNED_BYTE:w=g.getUint8(S);break;case A.ComponentType.SHORT:w=g.getInt16(S,!0);break;case A.ComponentType.BYTE:w=g.getInt8(S);break;default:throw new Error(`Unexpected componentType "${i.componentType}".`)}u[m*o+N]=w}return u}function st(i,e){const t=e.jsonDoc,r=e.bufferViews[i.bufferView],s=t.json.bufferViews[i.bufferView],n=at[i.componentType],o=A.getElementSize(i.type),a=n.BYTES_PER_ELEMENT,c=o*a;if(s.byteStride!==void 0&&s.byteStride!==c)return nr(i,e);const u=r.byteOffset+(i.byteOffset||0),g=i.count*o*a;return new n(r.buffer.slice(u,u+g))}function rr(i,e){const t=at[i.componentType],r=A.getElementSize(i.type);let s;i.bufferView!==void 0?s=st(i,e):s=new t(i.count*r);const n=i.sparse;if(!n)return s;const o=n.count,a=K({},i,n.indices,{count:o,type:"SCALAR"}),c=K({},i,n.values,{count:o}),u=st(a,e),g=st(c,e);for(let p=0;p<a.count;p++)for(let m=0;m<r;m++)s[u[p]*r+m]=g[p*r+m];return s}var Ye;(function(i){i[i.ARRAY_BUFFER=34962]="ARRAY_BUFFER",i[i.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"})(Ye||(Ye={}));class ce{constructor(e,t,r){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=e,this.jsonDoc=t,this.options=r;const s=e.getRoot(),n=s.listBuffers().length,o=s.listTextures().length;this.bufferURIGenerator=new Qt(n>1,()=>r.basename||"buffer"),this.imageURIGenerator=new Qt(o>1,a=>ir(e,a)||r.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){const r={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},s=JSON.stringify(r);this.samplerDefIndexMap.has(s)||(this.samplerDefIndexMap.set(s,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(r));const n={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(s)},o=JSON.stringify(n);this.textureDefIndexMap.has(o)||(this.textureDefIndexMap.set(o,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(n));const a={index:this.textureDefIndexMap.get(o)};return t.getTexCoord()!==0&&(a.texCoord=t.getTexCoord()),Object.keys(t.getExtras()).length>0&&(a.extras=t.getExtras()),this.textureInfoDefMap.set(t,a),a}createPropertyDef(e){const t={};return e.getName()&&(t.name=e.getName()),Object.keys(e.getExtras()).length>0&&(t.extras=e.getExtras()),t}createAccessorDef(e){const t=this.createPropertyDef(e);return t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some(s=>s.getName()==="attributes"&&s.getAttributes().key==="POSITION"||s.getName()==="input")&&(t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround)),e.getNormalized()&&(t.normalized=e.getNormalized()),t}createImageData(e,t,r){if(this.options.format===ge.GLB)this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{const s=ae.mimeTypeToExtension(r.getMimeType());e.uri=this.imageURIGenerator.createURI(r,s),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,r){const s=this.jsonDoc.resources;if(!(e in s)){s[e]=t;return}if(t===s[e]){this.logger.warn(`Duplicate resource URI, "${e}".`);return}const n=`Resource URI "${e}" already assigned to different data.`;if(!r){this.logger.warn(n);return}throw new Error(n)}getAccessorUsage(e){const t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return J.SPARSE;for(const r of this._doc.getGraph().listParentEdges(e)){const{usage:s}=r.getAttributes();if(s)return s;r.getParent().propertyType!==h.ROOT&&this.logger.warn(`Missing attribute ".usage" on edge, "${r.getName()}".`)}return J.OTHER}addAccessorToUsageGroup(e,t){const r=this._accessorUsageMap.get(e);if(r&&r!==t)throw new Error(`Accessor with usage "${r}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}}ce.BufferViewTarget=Ye;ce.BufferViewUsage=J;ce.USAGE_TO_TARGET={[J.ARRAY_BUFFER]:Ye.ARRAY_BUFFER,[J.ELEMENT_ARRAY_BUFFER]:Ye.ELEMENT_ARRAY_BUFFER};class Qt{constructor(e,t){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();if(this.multiple){const r=this.basename(e);return this.counter[r]=this.counter[r]||1,`${r}_${this.counter[r]++}.${t}`}else return`${this.basename(e)}.${t}`}}function ir(i,e){const t=i.getGraph().listParentEdges(e).find(r=>r.getParent()!==i.getRoot());return t?t.getName().replace(/texture$/i,""):""}const{BufferViewUsage:tt}=ce,{UNSIGNED_INT:or,UNSIGNED_SHORT:ar,UNSIGNED_BYTE:cr}=A.ComponentType,ur=new Set([h.ACCESSOR,h.BUFFER,h.MATERIAL,h.MESH]);class fr{static write(e,t){const r=e.getGraph(),s=e.getRoot(),n={asset:K({generator:`glTF-Transform ${ds}`},s.getAsset()),extras:K({},s.getExtras())},o={json:n,resources:{}},a=new ce(e,o,t),c=t.logger||ee.DEFAULT_INSTANCE,u=new Set(t.extensions.map(l=>l.EXTENSION_NAME)),g=e.getRoot().listExtensionsUsed().filter(l=>u.has(l.extensionName)).sort((l,b)=>l.extensionName>b.extensionName?1:-1),p=e.getRoot().listExtensionsRequired().filter(l=>u.has(l.extensionName)).sort((l,b)=>l.extensionName>b.extensionName?1:-1);g.length<e.getRoot().listExtensionsUsed().length&&c.warn("Some extensions were not registered for I/O, and will not be written.");for(const l of g){const b=l.prewriteTypes.filter(T=>!ur.has(T));b.length&&c.warn(`Prewrite hooks for some types (${b.join()}), requested by extension ${l.extensionName}, are unsupported. Please file an issue or a PR.`);for(const T of l.writeDependencies)l.install(T,t.dependencies[T])}function m(l,b,T,R){const x=[];let y=0;for(const E of l){const I=a.createAccessorDef(E);I.bufferView=n.bufferViews.length;const _=E.getArray(),O=D.pad(D.toView(_));I.byteOffset=y,y+=O.byteLength,x.push(O),a.accessorIndexMap.set(E,n.accessors.length),n.accessors.push(I)}const f=D.concat(x),d={buffer:b,byteOffset:T,byteLength:f.byteLength};return R&&(d.target=R),n.bufferViews.push(d),{buffers:x,byteLength:y}}function N(l,b,T){const R=l[0].getCount();let x=0;for(const I of l){const _=a.createAccessorDef(I);_.bufferView=n.bufferViews.length,_.byteOffset=x;const O=I.getElementSize(),C=I.getComponentSize();x+=D.padNumber(O*C),a.accessorIndexMap.set(I,n.accessors.length),n.accessors.push(_)}const y=R*x,f=new ArrayBuffer(y),d=new DataView(f);for(let I=0;I<R;I++){let _=0;for(const O of l){const C=O.getElementSize(),G=O.getComponentSize(),v=O.getComponentType(),L=O.getArray();for(let z=0;z<C;z++){const se=I*x+_+z*G,W=L[I*C+z];switch(v){case A.ComponentType.FLOAT:d.setFloat32(se,W,!0);break;case A.ComponentType.BYTE:d.setInt8(se,W);break;case A.ComponentType.SHORT:d.setInt16(se,W,!0);break;case A.ComponentType.UNSIGNED_BYTE:d.setUint8(se,W);break;case A.ComponentType.UNSIGNED_SHORT:d.setUint16(se,W,!0);break;case A.ComponentType.UNSIGNED_INT:d.setUint32(se,W,!0);break;default:throw new Error("Unexpected component type: "+v)}}_+=D.padNumber(C*G)}}const E={buffer:b,byteOffset:T,byteLength:y,byteStride:x,target:ce.BufferViewTarget.ARRAY_BUFFER};return n.bufferViews.push(E),{byteLength:y,buffers:[new Uint8Array(f)]}}function S(l,b,T){const R=[];let x=0;const y=new Map;let f=-1/0,d=!1;for(const v of l){const L=a.createAccessorDef(v);n.accessors.push(L),a.accessorIndexMap.set(v,n.accessors.length-1);const z=[],se=[],W=[],Sn=new Array(v.getElementSize()).fill(0);for(let ke=0,wn=v.getCount();ke<wn;ke++)if(v.getElement(ke,W),!B.eq(W,Sn,0)){f=Math.max(ke,f),z.push(ke);for(let lt=0;lt<W.length;lt++)se.push(W[lt])}const ut=z.length,ft={accessorDef:L,count:ut};if(y.set(v,ft),ut===0)continue;ut>v.getCount()/2&&(d=!0);const Mn=at[v.getComponentType()];ft.indices=z,ft.values=new Mn(se)}if(!Number.isFinite(f))return{buffers:R,byteLength:x};d&&c.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");const E=f<255?Uint8Array:f<65535?Uint16Array:Uint32Array,I=f<255?cr:f<65535?ar:or,_={buffer:b,byteOffset:T+x,byteLength:0};for(const v of l){const L=y.get(v);if(L.count===0)continue;L.indicesByteOffset=_.byteLength;const z=D.pad(D.toView(new E(L.indices)));R.push(z),x+=z.byteLength,_.byteLength+=z.byteLength}n.bufferViews.push(_);const O=n.bufferViews.length-1,C={buffer:b,byteOffset:T+x,byteLength:0};for(const v of l){const L=y.get(v);if(L.count===0)continue;L.valuesByteOffset=C.byteLength;const z=D.pad(D.toView(L.values));R.push(z),x+=z.byteLength,C.byteLength+=z.byteLength}n.bufferViews.push(C);const G=n.bufferViews.length-1;for(const v of l){const L=y.get(v);L.count!==0&&(L.accessorDef.sparse={count:L.count,indices:{bufferView:O,byteOffset:L.indicesByteOffset,componentType:I},values:{bufferView:G,byteOffset:L.valuesByteOffset}})}return{buffers:R,byteLength:x}}if(n.accessors=[],n.bufferViews=[],n.samplers=[],n.textures=[],n.images=s.listTextures().map((l,b)=>{const T=a.createPropertyDef(l);l.getMimeType()&&(T.mimeType=l.getMimeType());const R=l.getImage();return R&&a.createImageData(T,R,l),a.imageIndexMap.set(l,b),T}),g.filter(l=>l.prewriteTypes.includes(h.ACCESSOR)).forEach(l=>l.prewrite(a,h.ACCESSOR)),s.listAccessors().forEach(l=>{const b=a.accessorUsageGroupedByParent,T=a.accessorParents;if(a.accessorIndexMap.has(l))return;const R=a.getAccessorUsage(l);if(a.addAccessorToUsageGroup(l,R),b.has(R)){const x=r.listParents(l).find(y=>y.propertyType!==h.ROOT);T.set(l,x)}}),g.filter(l=>l.prewriteTypes.includes(h.BUFFER)).forEach(l=>l.prewrite(a,h.BUFFER)),(s.listAccessors().length>0||a.otherBufferViews.size>0||s.listTextures().length>0&&t.format===ge.GLB)&&s.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");n.buffers=[],s.listBuffers().forEach((l,b)=>{const T=a.createPropertyDef(l),R=a.accessorUsageGroupedByParent,x=l.listParents().filter(C=>C instanceof A),y=new Set(x.map(C=>a.accessorParents.get(C))),f=new Map(Array.from(y).map((C,G)=>[C,G])),d={};for(const C of x){var E;if(a.accessorIndexMap.has(C))continue;const G=a.getAccessorUsage(C);let v=G;if(R.has(G)){const L=a.accessorParents.get(C);v+=`:${f.get(L)}`}d[E=v]||(d[E]={usage:G,accessors:[]}),d[v].accessors.push(C)}const I=[],_=n.buffers.length;let O=0;for(const{usage:C,accessors:G}of Object.values(d))if(C===tt.ARRAY_BUFFER&&t.vertexLayout===nt.INTERLEAVED){const v=N(G,_,O);O+=v.byteLength,I.push(...v.buffers)}else if(C===tt.ARRAY_BUFFER)for(const v of G){const L=N([v],_,O);O+=L.byteLength,I.push(...L.buffers)}else if(C===tt.SPARSE){const v=S(G,_,O);O+=v.byteLength,I.push(...v.buffers)}else if(C===tt.ELEMENT_ARRAY_BUFFER){const v=ce.BufferViewTarget.ELEMENT_ARRAY_BUFFER,L=m(G,_,O,v);O+=L.byteLength,I.push(...L.buffers)}else{const v=m(G,_,O);O+=v.byteLength,I.push(...v.buffers)}if(a.imageBufferViews.length&&b===0){for(let C=0;C<a.imageBufferViews.length;C++)if(n.bufferViews[n.images[C].bufferView].byteOffset=O,O+=a.imageBufferViews[C].byteLength,I.push(a.imageBufferViews[C]),O%8){const G=8-O%8;O+=G,I.push(new Uint8Array(G))}}if(a.otherBufferViews.has(l))for(const C of a.otherBufferViews.get(l))n.bufferViews.push({buffer:_,byteOffset:O,byteLength:C.byteLength}),a.otherBufferViewsIndexMap.set(C,n.bufferViews.length-1),O+=C.byteLength,I.push(C);if(O){let C;t.format===ge.GLB?C=Ue:(C=a.bufferURIGenerator.createURI(l,"bin"),T.uri=C),T.byteLength=O,a.assignResourceURI(C,D.concat(I),!0)}n.buffers.push(T),a.bufferIndexMap.set(l,b)}),s.listAccessors().find(l=>!l.getBuffer())&&c.warn("Skipped writing one or more Accessors: no Buffer assigned."),g.filter(l=>l.prewriteTypes.includes(h.MATERIAL)).forEach(l=>l.prewrite(a,h.MATERIAL)),n.materials=s.listMaterials().map((l,b)=>{const T=a.createPropertyDef(l);if(l.getAlphaMode()!==Oe.AlphaMode.OPAQUE&&(T.alphaMode=l.getAlphaMode()),l.getAlphaMode()===Oe.AlphaMode.MASK&&(T.alphaCutoff=l.getAlphaCutoff()),l.getDoubleSided()&&(T.doubleSided=!0),T.pbrMetallicRoughness={},B.eq(l.getBaseColorFactor(),[1,1,1,1])||(T.pbrMetallicRoughness.baseColorFactor=l.getBaseColorFactor()),B.eq(l.getEmissiveFactor(),[0,0,0])||(T.emissiveFactor=l.getEmissiveFactor()),l.getRoughnessFactor()!==1&&(T.pbrMetallicRoughness.roughnessFactor=l.getRoughnessFactor()),l.getMetallicFactor()!==1&&(T.pbrMetallicRoughness.metallicFactor=l.getMetallicFactor()),l.getBaseColorTexture()){const R=l.getBaseColorTexture(),x=l.getBaseColorTextureInfo();T.pbrMetallicRoughness.baseColorTexture=a.createTextureInfoDef(R,x)}if(l.getEmissiveTexture()){const R=l.getEmissiveTexture(),x=l.getEmissiveTextureInfo();T.emissiveTexture=a.createTextureInfoDef(R,x)}if(l.getNormalTexture()){const R=l.getNormalTexture(),x=l.getNormalTextureInfo(),y=a.createTextureInfoDef(R,x);l.getNormalScale()!==1&&(y.scale=l.getNormalScale()),T.normalTexture=y}if(l.getOcclusionTexture()){const R=l.getOcclusionTexture(),x=l.getOcclusionTextureInfo(),y=a.createTextureInfoDef(R,x);l.getOcclusionStrength()!==1&&(y.strength=l.getOcclusionStrength()),T.occlusionTexture=y}if(l.getMetallicRoughnessTexture()){const R=l.getMetallicRoughnessTexture(),x=l.getMetallicRoughnessTextureInfo();T.pbrMetallicRoughness.metallicRoughnessTexture=a.createTextureInfoDef(R,x)}return a.materialIndexMap.set(l,b),T}),g.filter(l=>l.prewriteTypes.includes(h.MESH)).forEach(l=>l.prewrite(a,h.MESH)),n.meshes=s.listMeshes().map((l,b)=>{const T=a.createPropertyDef(l);let R=null;return T.primitives=l.listPrimitives().map(x=>{const y={attributes:{}};y.mode=x.getMode();const f=x.getMaterial();f&&(y.material=a.materialIndexMap.get(f)),Object.keys(x.getExtras()).length&&(y.extras=x.getExtras());const d=x.getIndices();d&&(y.indices=a.accessorIndexMap.get(d));for(const E of x.listSemantics())y.attributes[E]=a.accessorIndexMap.get(x.getAttribute(E));for(const E of x.listTargets()){const I={};for(const _ of E.listSemantics())I[_]=a.accessorIndexMap.get(E.getAttribute(_));y.targets=y.targets||[],y.targets.push(I)}return x.listTargets().length&&!R&&(R=x.listTargets().map(E=>E.getName())),y}),l.getWeights().length&&(T.weights=l.getWeights()),R&&(T.extras=T.extras||{},T.extras.targetNames=R),a.meshIndexMap.set(l,b),T}),n.cameras=s.listCameras().map((l,b)=>{const T=a.createPropertyDef(l);if(T.type=l.getType(),T.type===ve.Type.PERSPECTIVE){T.perspective={znear:l.getZNear(),zfar:l.getZFar(),yfov:l.getYFov()};const R=l.getAspectRatio();R!==null&&(T.perspective.aspectRatio=R)}else T.orthographic={znear:l.getZNear(),zfar:l.getZFar(),xmag:l.getXMag(),ymag:l.getYMag()};return a.cameraIndexMap.set(l,b),T}),n.nodes=s.listNodes().map((l,b)=>{const T=a.createPropertyDef(l);return B.eq(l.getTranslation(),[0,0,0])||(T.translation=l.getTranslation()),B.eq(l.getRotation(),[0,0,0,1])||(T.rotation=l.getRotation()),B.eq(l.getScale(),[1,1,1])||(T.scale=l.getScale()),l.getWeights().length&&(T.weights=l.getWeights()),a.nodeIndexMap.set(l,b),T}),n.skins=s.listSkins().map((l,b)=>{const T=a.createPropertyDef(l),R=l.getInverseBindMatrices();R&&(T.inverseBindMatrices=a.accessorIndexMap.get(R));const x=l.getSkeleton();return x&&(T.skeleton=a.nodeIndexMap.get(x)),T.joints=l.listJoints().map(y=>a.nodeIndexMap.get(y)),a.skinIndexMap.set(l,b),T}),s.listNodes().forEach((l,b)=>{const T=n.nodes[b],R=l.getMesh();R&&(T.mesh=a.meshIndexMap.get(R));const x=l.getCamera();x&&(T.camera=a.cameraIndexMap.get(x));const y=l.getSkin();y&&(T.skin=a.skinIndexMap.get(y)),l.listChildren().length>0&&(T.children=l.listChildren().map(f=>a.nodeIndexMap.get(f)))}),n.animations=s.listAnimations().map((l,b)=>{const T=a.createPropertyDef(l),R=new Map;return T.samplers=l.listSamplers().map((x,y)=>{const f=a.createPropertyDef(x);return f.input=a.accessorIndexMap.get(x.getInput()),f.output=a.accessorIndexMap.get(x.getOutput()),f.interpolation=x.getInterpolation(),R.set(x,y),f}),T.channels=l.listChannels().map(x=>{const y=a.createPropertyDef(x);return y.sampler=R.get(x.getSampler()),y.target={node:a.nodeIndexMap.get(x.getTargetNode()),path:x.getTargetPath()},y}),a.animationIndexMap.set(l,b),T}),n.scenes=s.listScenes().map((l,b)=>{const T=a.createPropertyDef(l);return T.nodes=l.listChildren().map(R=>a.nodeIndexMap.get(R)),a.sceneIndexMap.set(l,b),T});const M=s.getDefaultScene();return M&&(n.scene=s.listScenes().indexOf(M)),n.extensionsUsed=g.map(l=>l.extensionName),n.extensionsRequired=p.map(l=>l.extensionName),g.forEach(l=>l.write(a)),lr(n),o}}function lr(i){const e=[];for(const t in i){const r=i[t];(Array.isArray(r)&&r.length===0||r===null||r===""||r&&typeof r=="object"&&Object.keys(r).length===0)&&e.push(t)}for(const t of e)delete i[t]}var it;(function(i){i[i.JSON=1313821514]="JSON",i[i.BIN=5130562]="BIN"})(it||(it={}));class hr{constructor(){this._logger=ee.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={},this._vertexLayout=nt.INTERLEAVED,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(e){return this._logger=e,this}registerExtensions(e){for(const t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){const t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;const r=Zt(t)?this._binaryToJSON(t):{json:JSON.parse(D.decodeText(t)),resources:{}};return await this._readResourcesExternal(r,this.dirname(e)),this._readResourcesInternal(r),r}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),sr.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){const t=this._binaryToJSON(D.assertView(e));this._readResourcesInternal(t);const r=t.json;if(r.buffers&&r.buffers.some(s=>gr(t,s)))throw new Error("Cannot resolve external buffers with binaryToJSON().");if(r.images&&r.images.some(s=>pr(t,s)))throw new Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(D.assertView(e)))}async writeJSON(e,t={}){if(t.format===ge.GLB&&e.getRoot().listBuffers().length>1)throw new Error("GLB must have 0–1 buffers.");return fr.write(e,{format:t.format||ge.GLTF,basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:K({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(e){const{json:t,resources:r}=await this.writeJSON(e,{format:ge.GLB}),s=new Uint32Array([1179937895,2,12]),n=JSON.stringify(t),o=D.pad(D.encodeText(n),32),a=D.toView(new Uint32Array([o.byteLength,1313821514])),c=D.concat([a,o]);s[s.length-1]+=c.byteLength;const u=Object.values(r)[0];if(!u||!u.byteLength)return D.concat([D.toView(s),c]);const g=D.pad(u,0),p=D.toView(new Uint32Array([g.byteLength,5130562])),m=D.concat([p,g]);return s[s.length-1]+=m.byteLength,D.concat([D.toView(s),c,m])}async _readResourcesExternal(e,t){var r=this;const s=e.json.images||[],n=e.json.buffers||[],o=[...s,...n].map(async function(a){const c=a.uri;if(!c||c.match(/data:/))return Promise.resolve();e.resources[c]=await r.readURI(r.resolve(t,c),"view"),r.lastReadBytes+=e.resources[c].byteLength});await Promise.all(o)}_readResourcesInternal(e){function t(n){if(n.uri){if(n.uri in e.resources){D.assertView(e.resources[n.uri]);return}if(n.uri.match(/data:/)){const o=`__${Yn()}.${Pe.extension(n.uri)}`;e.resources[o]=D.createBufferFromDataURI(n.uri),n.uri=o}}}(e.json.images||[]).forEach(n=>{if(n.bufferView===void 0&&n.uri===void 0)throw new Error("Missing resource URI or buffer view.");t(n)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){const{images:t,buffers:r}=e.json;return e={json:K({},e.json),resources:K({},e.resources)},t&&(e.json.images=t.map(s=>K({},s))),r&&(e.json.buffers=r.map(s=>K({},s))),e}_binaryToJSON(e){if(!Zt(e))throw new Error("Invalid glTF 2.0 binary.");const t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==it.JSON)throw new Error("Missing required GLB JSON chunk.");const r=20,s=t[0],n=D.decodeText(D.toView(e,r,s)),o=JSON.parse(n),a=r+s;if(e.byteLength<=a)return{json:o,resources:{}};const c=new Uint32Array(e.buffer,e.byteOffset+a,2);if(c[1]!==it.BIN)return{json:o,resources:{}};const u=c[0],g=D.toView(e,a+8,u);return{json:o,resources:{[Ue]:g}}}}function gr(i,e){return e.uri!==void 0&&!(e.uri in i.resources)}function pr(i,e){return e.uri!==void 0&&!(e.uri in i.resources)&&e.bufferView===void 0}function Zt(i){if(i.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;const e=new Uint32Array(i.buffer,i.byteOffset,3);return e[0]===1179937895&&e[1]===2}class dr extends hr{constructor(e=Ke.DEFAULT_INIT){super(),this._fetchConfig=void 0,this._fetchConfig=e}async readURI(e,t){const r=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await r.arrayBuffer());case"text":return r.text()}}resolve(e,t){return Ke.resolve(e,t)}dirname(e){return Ke.dirname(e)}}const le="GALACEAN_materials_remap";class ws extends V{constructor(){super(...arguments);Y(this,"parentTypes",[h.MATERIAL]);Y(this,"propertyType");Y(this,"extensionName",le)}init(){this.extensionName=le,this.propertyType="GlTFRemapping",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{refId:""})}getRefId(){return this.get("refId")}setRefId(t){return this.set("refId",t)}}Y(ws,"EXTENSION_NAME",le);class bs extends U{constructor(){super(...arguments);Y(this,"extensionName","GALACEAN_materials_remap")}createGlTFRemapping(){return new ws(this.document.getGraph())}read(t){return(t.jsonDoc.json.materials||[]).forEach((n,o)=>{if(n.extensions&&n.extensions[le]){const a=this.createGlTFRemapping();t.materials[o].setExtension(le,a);const c=n.extensions[le];c.refId!==void 0&&a.setRefId(c.refId)}}),this}write(t){const r=t.jsonDoc;return this.document.getRoot().listMaterials().forEach(s=>{const n=s.getExtension(le);if(n){const o=t.materialIndexMap.get(s),a=r.json.materials[o];a.extensions=a.extensions||{},a.extensions[le]={refId:n.getRefId()}}}),this}}Y(bs,"EXTENSION_NAME","GALACEAN_materials_remap");const oe="GALACEAN_animation_event";class _s extends V{constructor(){super(...arguments);Y(this,"parentTypes",[h.ANIMATION]);Y(this,"propertyType");Y(this,"extensionName",oe)}init(){this.extensionName=oe,this.propertyType="GlTFAnimationEvent"}getDefaults(){return Object.assign(super.getDefaults(),{events:{}})}getEvents(){return this.get("events")}setEvents(t){return this.set("events",t)}}Y(_s,"EXTENSION_NAME",oe);class Cs extends U{constructor(){super(...arguments);Y(this,"extensionName",oe);Y(this,"eventProperty")}createAnimationEvent(){return this.eventProperty=new _s(this.document.getGraph()),this.eventProperty}read(t){return(t.jsonDoc.json.animations||[]).forEach((n,o)=>{if(n.extensions&&n.extensions[oe]){const a=this.createAnimationEvent();t.animations[o].setExtension(oe,a);const u=n.extensions[oe].events;u&&a.setEvents(u)}}),this}write(t){const r=t.jsonDoc;return this.document.getRoot().listAnimations().forEach(s=>{const n=s.getExtension(oe);if(n){const o=t.animationIndexMap.get(s),a=r.json.animations[o];a.extensions=a.extensions||{},a.extensions[oe]={events:n.getEvents()}}}),this}}Y(Cs,"EXTENSION_NAME",oe);const wt="EXT_mesh_gpu_instancing",Et="EXT_meshopt_compression",Tr="EXT_texture_webp",mr="EXT_texture_avif",Os="KHR_draco_mesh_compression",bt="KHR_lights_punctual",_t="KHR_materials_anisotropy",Ct="KHR_materials_clearcoat",Ot="KHR_materials_diffuse_transmission",Dt="KHR_materials_dispersion",vt="KHR_materials_emissive_strength",Ft="KHR_materials_ior",Lt="KHR_materials_iridescence",Bt="KHR_materials_pbrSpecularGlossiness",jt="KHR_materials_sheen",Ut="KHR_materials_specular",Pt="KHR_materials_transmission",Gt="KHR_materials_unlit",Vt="KHR_materials_volume",Fe="KHR_materials_variants",xr="KHR_mesh_quantization",Er="KHR_texture_basisu",kt="KHR_texture_transform",ot="KHR_xmp_json_ld",Rt="INSTANCE_ATTRIBUTE";class Ds extends V{init(){this.extensionName=wt,this.propertyType="InstancedMesh",this.parentTypes=[h.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new ne})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:Rt})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}Ds.EXTENSION_NAME=wt;const de=wt;class vs extends U{constructor(...e){super(...e),this.extensionName=de,this.provideTypes=[h.NODE],this.prewriteTypes=[h.ACCESSOR]}createInstancedMesh(){return new Ds(this.document.getGraph())}read(e){return(e.jsonDoc.json.nodes||[]).forEach((s,n)=>{if(!s.extensions||!s.extensions[de])return;const o=s.extensions[de],a=this.createInstancedMesh();for(const c in o.attributes)a.setAttribute(c,e.accessors[o.attributes[c]]);e.nodes[n].setExtension(de,a)}),this}prewrite(e){e.accessorUsageGroupedByParent.add(Rt);for(const t of this.properties)for(const r of t.listAttributes())e.addAccessorToUsageGroup(r,Rt);return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listNodes().forEach(r=>{const s=r.getExtension(de);if(s){const n=e.nodeIndexMap.get(r),o=t.json.nodes[n],a={attributes:{}};s.listSemantics().forEach(c=>{const u=s.getAttribute(c);a.attributes[c]=e.accessorIndexMap.get(u)}),o.extensions=o.extensions||{},o.extensions[de]=a}}),this}}vs.EXTENSION_NAME=de;function fe(){return fe=Object.assign?Object.assign.bind():function(i){for(var e=1;e<arguments.length;e++){var t=arguments[e];for(var r in t)({}).hasOwnProperty.call(t,r)&&(i[r]=t[r])}return i},fe.apply(null,arguments)}var We;(function(i){i.QUANTIZE="quantize",i.FILTER="filter"})(We||(We={}));var je;(function(i){i.ATTRIBUTES="ATTRIBUTES",i.TRIANGLES="TRIANGLES",i.INDICES="INDICES"})(je||(je={}));var k;(function(i){i.NONE="NONE",i.OCTAHEDRAL="OCTAHEDRAL",i.QUATERNION="QUATERNION",i.EXPONENTIAL="EXPONENTIAL"})(k||(k={}));const{BYTE:Rr,SHORT:es,FLOAT:Ir}=A.ComponentType,{encodeNormalizedInt:ts,decodeNormalizedInt:It}=B;function yr(i,e,t,r){const{filter:s,bits:n}=r,o={array:i.getArray(),byteStride:i.getElementSize()*i.getComponentSize(),componentType:i.getComponentType(),normalized:i.getNormalized()};if(t!==je.ATTRIBUTES)return o;if(s!==k.NONE){let a=i.getNormalized()?Nr(i):new Float32Array(o.array);switch(s){case k.EXPONENTIAL:o.byteStride=i.getElementSize()*4,o.componentType=Ir,o.normalized=!1,o.array=e.encodeFilterExp(a,i.getCount(),o.byteStride,n);break;case k.OCTAHEDRAL:o.byteStride=n>8?8:4,o.componentType=n>8?es:Rr,o.normalized=!0,a=i.getElementSize()===3?Sr(a):a,o.array=e.encodeFilterOct(a,i.getCount(),o.byteStride,n);break;case k.QUATERNION:o.byteStride=8,o.componentType=es,o.normalized=!0,o.array=e.encodeFilterQuat(a,i.getCount(),o.byteStride,n);break;default:throw new Error("Invalid filter.")}o.min=i.getMin([]),o.max=i.getMax([]),i.getNormalized()&&(o.min=o.min.map(c=>It(c,i.getComponentType())),o.max=o.max.map(c=>It(c,i.getComponentType()))),o.normalized&&(o.min=o.min.map(c=>ts(c,o.componentType)),o.max=o.max.map(c=>ts(c,o.componentType)))}else o.byteStride%4&&(o.array=Ar(o.array,i.getElementSize()),o.byteStride=o.array.byteLength/i.getCount());return o}function Nr(i){const e=i.getComponentType(),t=i.getArray(),r=new Float32Array(t.length);for(let s=0;s<t.length;s++)r[s]=It(t[s],e);return r}function Ar(i,e){const r=D.padNumber(i.BYTES_PER_ELEMENT*e)/i.BYTES_PER_ELEMENT,s=i.length/e,n=new i.constructor(s*r);for(let o=0;o*e<i.length;o++)for(let a=0;a<e;a++)n[o*r+a]=i[o*e+a];return n}function Sr(i){const e=new Float32Array(i.length*4/3);for(let t=0,r=i.length/3;t<r;t++)e[t*4]=i[t*3],e[t*4+1]=i[t*3+1],e[t*4+2]=i[t*3+2];return e}function Mr(i,e){return e===ce.BufferViewUsage.ELEMENT_ARRAY_BUFFER?i.listParents().some(r=>r instanceof De&&r.getMode()===De.Mode.TRIANGLES)?je.TRIANGLES:je.INDICES:je.ATTRIBUTES}function wr(i,e){const t=e.getGraph().listParentEdges(i).filter(r=>!(r.getParent()instanceof Ms));for(const r of t){const s=r.getName(),n=r.getAttributes().key||"",o=r.getParent().propertyType===h.PRIMITIVE_TARGET;if(s==="indices")return{filter:k.NONE};if(s==="attributes"){if(n==="POSITION")return{filter:k.NONE};if(n==="TEXCOORD_0")return{filter:k.NONE};if(n.startsWith("JOINTS_"))return{filter:k.NONE};if(n.startsWith("WEIGHTS_"))return{filter:k.NONE};if(n==="NORMAL"||n==="TANGENT")return o?{filter:k.NONE}:{filter:k.OCTAHEDRAL,bits:8}}if(s==="output"){const a=Fs(i);return a==="rotation"?{filter:k.QUATERNION,bits:16}:a==="translation"?{filter:k.EXPONENTIAL,bits:12}:a==="scale"?{filter:k.EXPONENTIAL,bits:12}:{filter:k.NONE}}if(s==="input")return{filter:k.NONE};if(s==="inverseBindMatrices")return{filter:k.NONE}}return{filter:k.NONE}}function Fs(i){for(const e of i.listParents())if(e instanceof Ve){for(const t of e.listParents())if(t instanceof Mt)return t.getTargetPath()}return null}function br(i){return!i.extensions||!i.extensions[Et]?!1:!!i.extensions[Et].fallback}const X=Et,ss={method:We.QUANTIZE};class Ht extends U{constructor(...e){super(...e),this.extensionName=X,this.prereadTypes=[h.BUFFER,h.PRIMITIVE],this.prewriteTypes=[h.BUFFER,h.ACCESSOR],this.readDependencies=["meshopt.decoder"],this.writeDependencies=["meshopt.encoder"],this._decoder=null,this._decoderFallbackBufferMap=new Map,this._encoder=null,this._encoderOptions=ss,this._encoderFallbackBuffer=null,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={}}install(e,t){return e==="meshopt.decoder"&&(this._decoder=t),e==="meshopt.encoder"&&(this._encoder=t),this}setEncoderOptions(e){return this._encoderOptions=fe({},ss,e),this}preread(e,t){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${X}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${X}]: Missing WASM support.`)}return t===h.BUFFER?this._prereadBuffers(e):t===h.PRIMITIVE&&this._prereadPrimitives(e),this}_prereadBuffers(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach((s,n)=>{if(!s.extensions||!s.extensions[X])return;const o=s.extensions[X],a=o.byteOffset||0,c=o.byteLength||0,u=o.count,g=o.byteStride,p=new Uint8Array(u*g),m=t.json.buffers[o.buffer],N=m.uri?t.resources[m.uri]:t.resources[Ue],S=D.toView(N,a,c);this._decoder.decodeGltfBuffer(p,u,g,S,o.mode,o.filter),e.bufferViews[n]=p})}_prereadPrimitives(e){const t=e.jsonDoc;(t.json.bufferViews||[]).forEach(s=>{if(!s.extensions||!s.extensions[X])return;const n=s.extensions[X],o=e.buffers[n.buffer],a=e.buffers[s.buffer],c=t.json.buffers[s.buffer];br(c)&&this._decoderFallbackBufferMap.set(a,o)})}read(e){if(!this.isRequired())return this;for(const[t,r]of this._decoderFallbackBufferMap){for(const s of t.listParents())s instanceof A&&s.swap(t,r);t.dispose()}return this}prewrite(e,t){return t===h.ACCESSOR?this._prewriteAccessors(e):t===h.BUFFER&&this._prewriteBuffers(e),this}_prewriteAccessors(e){const t=e.jsonDoc.json,r=this._encoder,s=this._encoderOptions,n=this.document.getGraph(),o=this.document.createBuffer(),a=this.document.getRoot().listBuffers().indexOf(o);let c=1;const u=new Map,g=p=>{for(const m of n.listParents(p)){if(m.propertyType===h.ROOT)continue;let N=u.get(p);return N===void 0&&u.set(p,N=c++),N}return-1};this._encoderFallbackBuffer=o,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(const p of this.document.getRoot().listAccessors()){if(Fs(p)==="weights"||p.getSparse())continue;const m=e.getAccessorUsage(p),N=e.accessorUsageGroupedByParent.has(m)?g(p):null,S=Mr(p,m),w=s.method===We.FILTER?wr(p,this.document):{filter:k.NONE},M=yr(p,r,S,w),{array:l,byteStride:b}=M,T=p.getBuffer();if(!T)throw new Error(`${X}: Missing buffer for accessor.`);const R=this.document.getRoot().listBuffers().indexOf(T),x=[m,N,S,w.filter,b,R].join(":");let y=this._encoderBufferViews[x],f=this._encoderBufferViewData[x],d=this._encoderBufferViewAccessors[x];(!y||!f)&&(d=this._encoderBufferViewAccessors[x]=[],f=this._encoderBufferViewData[x]=[],y=this._encoderBufferViews[x]={buffer:a,target:ce.USAGE_TO_TARGET[m],byteOffset:0,byteLength:0,byteStride:m===ce.BufferViewUsage.ARRAY_BUFFER?b:void 0,extensions:{[X]:{buffer:R,byteOffset:0,byteLength:0,mode:S,filter:w.filter!==k.NONE?w.filter:void 0,byteStride:b,count:0}}});const E=e.createAccessorDef(p);E.componentType=M.componentType,E.normalized=M.normalized,E.byteOffset=y.byteLength,E.min&&M.min&&(E.min=M.min),E.max&&M.max&&(E.max=M.max),e.accessorIndexMap.set(p,t.accessors.length),t.accessors.push(E),d.push(E),f.push(new Uint8Array(l.buffer,l.byteOffset,l.byteLength)),y.byteLength+=l.byteLength,y.extensions.EXT_meshopt_compression.count+=p.getCount()}}_prewriteBuffers(e){const t=this._encoder;for(const r in this._encoderBufferViews){const s=this._encoderBufferViews[r],n=this._encoderBufferViewData[r],o=this.document.getRoot().listBuffers()[s.extensions[X].buffer],a=e.otherBufferViews.get(o)||[],{count:c,byteStride:u,mode:g}=s.extensions[X],p=D.concat(n),m=t.encodeGltfBuffer(p,c,u,g),N=D.pad(m);s.extensions[X].byteLength=m.byteLength,n.length=0,n.push(N),a.push(N),e.otherBufferViews.set(o,a)}}write(e){let t=0;for(const o in this._encoderBufferViews){const a=this._encoderBufferViews[o],c=this._encoderBufferViewData[o][0],u=e.otherBufferViewsIndexMap.get(c),g=this._encoderBufferViewAccessors[o];for(const S of g)S.bufferView=u;const p=e.jsonDoc.json.bufferViews[u],m=p.byteOffset||0;Object.assign(p,a),p.byteOffset=t;const N=p.extensions[X];N.byteOffset=m,t+=D.padNumber(a.byteLength)}const r=this._encoderFallbackBuffer,s=e.bufferIndexMap.get(r),n=e.jsonDoc.json.buffers[s];return n.byteLength=t,n.extensions={[X]:{fallback:!0}},r.dispose(),this}}Ht.EXTENSION_NAME=X;Ht.EncoderMethod=We;const He=mr;class _r{match(e){return e.length>=12&&D.decodeText(e.slice(4,12))==="ftypavif"}getSize(e){if(!this.match(e))return null;const t=new DataView(e.buffer,e.byteOffset,e.byteLength);let r=ns(t,0);if(!r)return null;let s=r.end;for(;r=ns(t,s);)if(r.type==="meta")s=r.start+4;else if(r.type==="iprp"||r.type==="ipco")s=r.start;else{if(r.type==="ispe")return[t.getUint32(r.start+4),t.getUint32(r.start+8)];if(r.type==="mdat")break;s=r.end}return null}getChannels(e){return 4}}class Ls extends U{constructor(...e){super(...e),this.extensionName=He,this.prereadTypes=[h.TEXTURE]}static register(){ae.registerFormat("image/avif",new _r)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(r=>{r.extensions&&r.extensions[He]&&(r.source=r.extensions[He].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(r=>{if(r.getMimeType()==="image/avif"){const s=e.imageIndexMap.get(r);(t.json.textures||[]).forEach(o=>{o.source===s&&(o.extensions=o.extensions||{},o.extensions[He]={source:o.source},delete o.source)})}}),this}}Ls.EXTENSION_NAME=He;function ns(i,e){if(i.byteLength<4+e)return null;const t=i.getUint32(e);return i.byteLength<t+e||t<8?null:{type:D.decodeText(new Uint8Array(i.buffer,i.byteOffset+e+4,4)),start:e+8,end:e+t}}const ze=Tr;class Cr{match(e){return e.length>=12&&e[8]===87&&e[9]===69&&e[10]===66&&e[11]===80}getSize(e){const t=D.decodeText(e.slice(0,4)),r=D.decodeText(e.slice(8,12));if(t!=="RIFF"||r!=="WEBP")return null;const s=new DataView(e.buffer,e.byteOffset);let n=12;for(;n<s.byteLength;){const o=D.decodeText(new Uint8Array([s.getUint8(n),s.getUint8(n+1),s.getUint8(n+2),s.getUint8(n+3)])),a=s.getUint32(n+4,!0);if(o==="VP8 "){const c=s.getInt16(n+14,!0)&16383,u=s.getInt16(n+16,!0)&16383;return[c,u]}else if(o==="VP8L"){const c=s.getUint8(n+9),u=s.getUint8(n+10),g=s.getUint8(n+11),p=s.getUint8(n+12),m=1+((u&63)<<8|c),N=1+((p&15)<<10|g<<2|(u&192)>>6);return[m,N]}n+=8+a+a%2}return null}getChannels(e){return 4}}class Bs extends U{constructor(...e){super(...e),this.extensionName=ze,this.prereadTypes=[h.TEXTURE]}static register(){ae.registerFormat("image/webp",new Cr)}preread(e){return(e.jsonDoc.json.textures||[]).forEach(r=>{r.extensions&&r.extensions[ze]&&(r.source=r.extensions[ze].source)}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(r=>{if(r.getMimeType()==="image/webp"){const s=e.imageIndexMap.get(r);(t.json.textures||[]).forEach(o=>{o.source===s&&(o.extensions=o.extensions||{},o.extensions[ze]={source:o.source},delete o.source)})}}),this}}Bs.EXTENSION_NAME=ze;const rs=Os;let $,js,Us;function Or(i,e){const t=new $.DecoderBuffer;try{if(t.Init(e,e.length),i.GetEncodedGeometryType(t)!==$.TRIANGULAR_MESH)throw new Error(`[${rs}] Unknown geometry type.`);const s=new $.Mesh;if(!i.DecodeBufferToMesh(t,s).ok()||s.ptr===0)throw new Error(`[${rs}] Decoding failure.`);return s}finally{$.destroy(t)}}function Dr(i,e){const r=e.num_faces()*3;let s,n;if(e.num_points()<=65534){const o=r*Uint16Array.BYTES_PER_ELEMENT;s=$._malloc(o),i.GetTrianglesUInt16Array(e,o,s),n=new Uint16Array($.HEAPU16.buffer,s,r).slice()}else{const o=r*Uint32Array.BYTES_PER_ELEMENT;s=$._malloc(o),i.GetTrianglesUInt32Array(e,o,s),n=new Uint32Array($.HEAPU32.buffer,s,r).slice()}return $._free(s),n}function vr(i,e,t,r){const s=Us[r.componentType],n=js[r.componentType],o=t.num_components(),c=e.num_points()*o,u=c*n.BYTES_PER_ELEMENT,g=$._malloc(u);i.GetAttributeDataArrayForAllPoints(e,t,s,u,g);const p=new n($.HEAPF32.buffer,g,c).slice();return $._free(g),p}function Fr(i){$=i,js={[A.ComponentType.FLOAT]:Float32Array,[A.ComponentType.UNSIGNED_INT]:Uint32Array,[A.ComponentType.UNSIGNED_SHORT]:Uint16Array,[A.ComponentType.UNSIGNED_BYTE]:Uint8Array,[A.ComponentType.SHORT]:Int16Array,[A.ComponentType.BYTE]:Int8Array},Us={[A.ComponentType.FLOAT]:$.DT_FLOAT32,[A.ComponentType.UNSIGNED_INT]:$.DT_UINT32,[A.ComponentType.UNSIGNED_SHORT]:$.DT_UINT16,[A.ComponentType.UNSIGNED_BYTE]:$.DT_UINT8,[A.ComponentType.SHORT]:$.DT_INT16,[A.ComponentType.BYTE]:$.DT_INT8}}let Q;var Je;(function(i){i[i.EDGEBREAKER=1]="EDGEBREAKER",i[i.SEQUENTIAL=0]="SEQUENTIAL"})(Je||(Je={}));var Z;(function(i){i.POSITION="POSITION",i.NORMAL="NORMAL",i.COLOR="COLOR",i.TEX_COORD="TEX_COORD",i.GENERIC="GENERIC"})(Z||(Z={}));const Ps={[Z.POSITION]:14,[Z.NORMAL]:10,[Z.COLOR]:8,[Z.TEX_COORD]:12,[Z.GENERIC]:12},is={decodeSpeed:5,encodeSpeed:5,method:Je.EDGEBREAKER,quantizationBits:Ps,quantizationVolume:"mesh"};function Lr(i){Q=i}function Br(i,e=is){const t=fe({},is,e);t.quantizationBits=fe({},Ps,e.quantizationBits);const r=new Q.MeshBuilder,s=new Q.Mesh,n=new Q.ExpertEncoder(s),o={},a=new Q.DracoInt8Array,c=i.listTargets().length>0;let u=!1;for(const w of i.listSemantics()){const M=i.getAttribute(w);if(M.getSparse()){u=!0;continue}const l=jr(w),b=Ur(r,M.getComponentType(),s,Q[l],M.getCount(),M.getElementSize(),M.getArray());if(b===-1)throw new Error(`Error compressing "${w}" attribute.`);if(o[w]=b,t.quantizationVolume==="mesh"||w!=="POSITION")n.SetAttributeQuantization(b,t.quantizationBits[l]);else if(typeof t.quantizationVolume=="object"){const{quantizationVolume:T}=t,R=Math.max(T.max[0]-T.min[0],T.max[1]-T.min[1],T.max[2]-T.min[2]);n.SetAttributeExplicitQuantization(b,t.quantizationBits[l],M.getElementSize(),T.min,R)}else throw new Error("Invalid quantization volume state.")}const g=i.getIndices();if(!g)throw new yt("Primitive must have indices.");r.AddFacesToMesh(s,g.getCount()/3,g.getArray()),n.SetSpeedOptions(t.encodeSpeed,t.decodeSpeed),n.SetTrackEncodedProperties(!0),t.method===Je.SEQUENTIAL||c||u?n.SetEncodingMethod(Q.MESH_SEQUENTIAL_ENCODING):n.SetEncodingMethod(Q.MESH_EDGEBREAKER_ENCODING);const p=n.EncodeToDracoBuffer(!(c||u),a);if(p<=0)throw new yt("Error applying Draco compression.");const m=new Uint8Array(p);for(let w=0;w<p;++w)m[w]=a.GetValue(w);const N=n.GetNumberOfEncodedPoints(),S=n.GetNumberOfEncodedFaces()*3;return Q.destroy(a),Q.destroy(s),Q.destroy(r),Q.destroy(n),{numVertices:N,numIndices:S,data:m,attributeIDs:o}}function jr(i){return i==="POSITION"?Z.POSITION:i==="NORMAL"?Z.NORMAL:i.startsWith("COLOR_")?Z.COLOR:i.startsWith("TEXCOORD_")?Z.TEX_COORD:Z.GENERIC}function Ur(i,e,t,r,s,n,o){switch(e){case A.ComponentType.UNSIGNED_BYTE:return i.AddUInt8Attribute(t,r,s,n,o);case A.ComponentType.BYTE:return i.AddInt8Attribute(t,r,s,n,o);case A.ComponentType.UNSIGNED_SHORT:return i.AddUInt16Attribute(t,r,s,n,o);case A.ComponentType.SHORT:return i.AddInt16Attribute(t,r,s,n,o);case A.ComponentType.UNSIGNED_INT:return i.AddUInt32Attribute(t,r,s,n,o);case A.ComponentType.FLOAT:return i.AddFloatAttribute(t,r,s,n,o);default:throw new Error(`Unexpected component type, "${e}".`)}}class yt extends Error{}const H=Os;class zt extends U{constructor(...e){super(...e),this.extensionName=H,this.prereadTypes=[h.PRIMITIVE],this.prewriteTypes=[h.ACCESSOR],this.readDependencies=["draco3d.decoder"],this.writeDependencies=["draco3d.encoder"],this._decoderModule=null,this._encoderModule=null,this._encoderOptions={}}install(e,t){return e==="draco3d.decoder"&&(this._decoderModule=t,Fr(this._decoderModule)),e==="draco3d.encoder"&&(this._encoderModule=t,Lr(this._encoderModule)),this}setEncoderOptions(e){return this._encoderOptions=e,this}preread(e){if(!this._decoderModule)throw new Error(`[${H}] Please install extension dependency, "draco3d.decoder".`);const t=this.document.getLogger(),r=e.jsonDoc,s=new Map;try{const n=r.json.meshes||[];for(const o of n)for(const a of o.primitives){if(!a.extensions||!a.extensions[H])continue;const c=a.extensions[H];let[u,g]=s.get(c.bufferView)||[];if(!g||!u){const p=r.json.bufferViews[c.bufferView],m=r.json.buffers[p.buffer],N=m.uri?r.resources[m.uri]:r.resources[Ue],S=p.byteOffset||0,w=p.byteLength,M=D.toView(N,S,w);u=new this._decoderModule.Decoder,g=Or(u,M),s.set(c.bufferView,[u,g]),t.debug(`[${H}] Decompressed ${M.byteLength} bytes.`)}for(const p in a.attributes){const m=e.jsonDoc.json.accessors[a.attributes[p]],N=u.GetAttributeByUniqueId(g,c.attributes[p]),S=vr(u,g,N,m);e.accessors[a.attributes[p]].setArray(S)}a.indices!==void 0&&e.accessors[a.indices].setArray(Dr(u,g))}}finally{for(const[n,o]of Array.from(s.values()))this._decoderModule.destroy(n),this._decoderModule.destroy(o)}return this}read(e){return this}prewrite(e,t){if(!this._encoderModule)throw new Error(`[${H}] Please install extension dependency, "draco3d.encoder".`);const r=this.document.getLogger();r.debug(`[${H}] Compression options: ${JSON.stringify(this._encoderOptions)}`);const s=Pr(this.document),n=new Map;let o="mesh";this._encoderOptions.quantizationVolume==="scene"&&(this.document.getRoot().listScenes().length!==1?r.warn(`[${H}]: quantizationVolume=scene requires exactly 1 scene.`):o=Ln(this.document.getRoot().listScenes().pop()));for(const a of Array.from(s.keys())){const c=s.get(a);if(!c)throw new Error("Unexpected primitive.");if(n.has(c)){n.set(c,n.get(c));continue}const u=a.getIndices(),g=e.jsonDoc.json.accessors;let p;try{p=Br(a,fe({},this._encoderOptions,{quantizationVolume:o}))}catch(S){if(S instanceof yt){r.warn(`[${H}]: ${S.message} Skipping primitive compression.`);continue}throw S}n.set(c,p);const m=e.createAccessorDef(u);m.count=p.numIndices,e.accessorIndexMap.set(u,g.length),g.push(m),p.numVertices>65534&&m.componentType!==A.ComponentType.UNSIGNED_INT&&(m.componentType=A.ComponentType.UNSIGNED_INT);for(const S of a.listSemantics()){const w=a.getAttribute(S);if(p.attributeIDs[S]===void 0)continue;const M=e.createAccessorDef(w);M.count=p.numVertices,e.accessorIndexMap.set(w,g.length),g.push(M)}const N=a.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];e.otherBufferViews.has(N)||e.otherBufferViews.set(N,[]),e.otherBufferViews.get(N).push(p.data)}return r.debug(`[${H}] Compressed ${s.size} primitives.`),e.extensionData[H]={primitiveHashMap:s,primitiveEncodingMap:n},this}write(e){const t=e.extensionData[H];for(const r of this.document.getRoot().listMeshes()){const s=e.jsonDoc.json.meshes[e.meshIndexMap.get(r)];for(let n=0;n<r.listPrimitives().length;n++){const o=r.listPrimitives()[n],a=s.primitives[n],c=t.primitiveHashMap.get(o);if(!c)continue;const u=t.primitiveEncodingMap.get(c);u&&(a.extensions=a.extensions||{},a.extensions[H]={bufferView:e.otherBufferViewsIndexMap.get(u.data),attributes:u.attributeIDs})}}if(!t.primitiveHashMap.size){const r=e.jsonDoc.json;r.extensionsUsed=(r.extensionsUsed||[]).filter(s=>s!==H),r.extensionsRequired=(r.extensionsRequired||[]).filter(s=>s!==H)}return this}}zt.EXTENSION_NAME=H;zt.EncoderMethod=Je;function Pr(i){const e=i.getLogger(),t=new Set,r=new Set;let s=0,n=0;for(const p of i.getRoot().listMeshes())for(const m of p.listPrimitives())m.getIndices()?m.getMode()!==De.Mode.TRIANGLES?(r.add(m),n++):t.add(m):(r.add(m),s++);s>0&&e.warn(`[${H}] Skipping Draco compression of ${s} non-indexed primitives.`),n>0&&e.warn(`[${H}] Skipping Draco compression of ${n} non-TRIANGLES primitives.`);const o=i.getRoot().listAccessors(),a=new Map;for(let p=0;p<o.length;p++)a.set(o[p],p);const c=new Map,u=new Set,g=new Map;for(const p of Array.from(t)){let m=os(p,a);if(u.has(m)){g.set(p,m);continue}if(c.has(p.getIndices())){const N=p.getIndices(),S=N.clone();a.set(S,i.getRoot().listAccessors().length-1),p.swap(N,S)}for(const N of p.listAttributes())if(c.has(N)){const S=N.clone();a.set(S,i.getRoot().listAccessors().length-1),p.swap(N,S)}m=os(p,a),u.add(m),g.set(p,m),c.set(p.getIndices(),m);for(const N of p.listAttributes())c.set(N,m)}for(const p of Array.from(c.keys())){const m=new Set(p.listParents().map(N=>N.propertyType));if(m.size!==2||!m.has(h.PRIMITIVE)||!m.has(h.ROOT))throw new Error(`[${H}] Compressed accessors must only be used as indices or vertex attributes.`)}for(const p of Array.from(t)){const m=g.get(p),N=p.getIndices();if(c.get(N)!==m||p.listAttributes().some(S=>c.get(S)!==m))throw new Error(`[${H}] Draco primitives must share all, or no, accessors.`)}for(const p of Array.from(r)){const m=p.getIndices();if(c.has(m)||p.listAttributes().some(N=>c.has(N)))throw new Error(`[${H}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return g}function os(i,e){const t=[],r=i.getIndices();t.push(e.get(r));for(const s of i.listAttributes())t.push(e.get(s));return t.sort().join("|")}class Ge extends V{init(){this.extensionName=bt,this.propertyType="Light",this.parentTypes=[h.NODE]}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:Ge.Type.POINT,range:null,innerConeAngle:0,outerConeAngle:Math.PI/4})}getColor(){return this.get("color")}setColor(e){return this.set("color",e)}getIntensity(){return this.get("intensity")}setIntensity(e){return this.set("intensity",e)}getType(){return this.get("type")}setType(e){return this.set("type",e)}getRange(){return this.get("range")}setRange(e){return this.set("range",e)}getInnerConeAngle(){return this.get("innerConeAngle")}setInnerConeAngle(e){return this.set("innerConeAngle",e)}getOuterConeAngle(){return this.get("outerConeAngle")}setOuterConeAngle(e){return this.set("outerConeAngle",e)}}Ge.EXTENSION_NAME=bt;Ge.Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};const re=bt;class Gs extends U{constructor(...e){super(...e),this.extensionName=re}createLight(e=""){return new Ge(this.document.getGraph(),e)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[re])return this;const n=(t.json.extensions[re].lights||[]).map(o=>{var a,c;const u=this.createLight().setName(o.name||"").setType(o.type);return o.color!==void 0&&u.setColor(o.color),o.intensity!==void 0&&u.setIntensity(o.intensity),o.range!==void 0&&u.setRange(o.range),((a=o.spot)==null?void 0:a.innerConeAngle)!==void 0&&u.setInnerConeAngle(o.spot.innerConeAngle),((c=o.spot)==null?void 0:c.outerConeAngle)!==void 0&&u.setOuterConeAngle(o.spot.outerConeAngle),u});return t.json.nodes.forEach((o,a)=>{if(!o.extensions||!o.extensions[re])return;const c=o.extensions[re];e.nodes[a].setExtension(re,n[c.light])}),this}write(e){const t=e.jsonDoc;if(this.properties.size===0)return this;const r=[],s=new Map;for(const n of this.properties){const o=n,a={type:o.getType()};B.eq(o.getColor(),[1,1,1])||(a.color=o.getColor()),o.getIntensity()!==1&&(a.intensity=o.getIntensity()),o.getRange()!=null&&(a.range=o.getRange()),o.getName()&&(a.name=o.getName()),o.getType()===Ge.Type.SPOT&&(a.spot={innerConeAngle:o.getInnerConeAngle(),outerConeAngle:o.getOuterConeAngle()}),r.push(a),s.set(o,r.length-1)}return this.document.getRoot().listNodes().forEach(n=>{const o=n.getExtension(re);if(o){const a=e.nodeIndexMap.get(n),c=t.json.nodes[a];c.extensions=c.extensions||{},c.extensions[re]={light:s.get(o)}}}),t.json.extensions=t.json.extensions||{},t.json.extensions[re]={lights:r},this}}Gs.EXTENSION_NAME=re;const{R:Gr,G:Vr,B:kr}=te;class Vs extends V{init(){this.extensionName=_t,this.propertyType="Anisotropy",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new j(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(e){return this.set("anisotropyStrength",e)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(e){return this.set("anisotropyRotation",e)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(e){return this.setRef("anisotropyTexture",e,{channels:Gr|Vr|kr})}}Vs.EXTENSION_NAME=_t;const Te=_t;class ks extends U{constructor(...e){super(...e),this.extensionName=Te,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createAnisotropy(){return new Vs(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Te]){const a=this.createAnisotropy();e.materials[o].setExtension(Te,a);const c=n.extensions[Te];if(c.anisotropyStrength!==void 0&&a.setAnisotropyStrength(c.anisotropyStrength),c.anisotropyRotation!==void 0&&a.setAnisotropyRotation(c.anisotropyRotation),c.anisotropyTexture!==void 0){const u=c.anisotropyTexture,g=e.textures[s[u.index].source];a.setAnisotropyTexture(g),e.setTextureInfo(a.getAnisotropyTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Te);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Te]={};if(s.getAnisotropyStrength()>0&&(a.anisotropyStrength=s.getAnisotropyStrength()),s.getAnisotropyRotation()!==0&&(a.anisotropyRotation=s.getAnisotropyRotation()),s.getAnisotropyTexture()){const c=s.getAnisotropyTexture(),u=s.getAnisotropyTextureInfo();a.anisotropyTexture=e.createTextureInfoDef(c,u)}}}),this}}ks.EXTENSION_NAME=Te;const{R:as,G:cs,B:Hr}=te;class Hs extends V{init(){this.extensionName=Ct,this.propertyType="Clearcoat",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new j(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new j(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new j(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(e){return this.set("clearcoatFactor",e)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(e){return this.setRef("clearcoatTexture",e,{channels:as})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(e){return this.set("clearcoatRoughnessFactor",e)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(e){return this.setRef("clearcoatRoughnessTexture",e,{channels:cs})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(e){return this.set("clearcoatNormalScale",e)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(e){return this.setRef("clearcoatNormalTexture",e,{channels:as|cs|Hr})}}Hs.EXTENSION_NAME=Ct;const me=Ct;class zs extends U{constructor(...e){super(...e),this.extensionName=me,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createClearcoat(){return new Hs(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[me]){const a=this.createClearcoat();e.materials[o].setExtension(me,a);const c=n.extensions[me];if(c.clearcoatFactor!==void 0&&a.setClearcoatFactor(c.clearcoatFactor),c.clearcoatRoughnessFactor!==void 0&&a.setClearcoatRoughnessFactor(c.clearcoatRoughnessFactor),c.clearcoatTexture!==void 0){const u=c.clearcoatTexture,g=e.textures[s[u.index].source];a.setClearcoatTexture(g),e.setTextureInfo(a.getClearcoatTextureInfo(),u)}if(c.clearcoatRoughnessTexture!==void 0){const u=c.clearcoatRoughnessTexture,g=e.textures[s[u.index].source];a.setClearcoatRoughnessTexture(g),e.setTextureInfo(a.getClearcoatRoughnessTextureInfo(),u)}if(c.clearcoatNormalTexture!==void 0){const u=c.clearcoatNormalTexture,g=e.textures[s[u.index].source];a.setClearcoatNormalTexture(g),e.setTextureInfo(a.getClearcoatNormalTextureInfo(),u),u.scale!==void 0&&a.setClearcoatNormalScale(u.scale)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(me);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[me]={clearcoatFactor:s.getClearcoatFactor(),clearcoatRoughnessFactor:s.getClearcoatRoughnessFactor()};if(s.getClearcoatTexture()){const c=s.getClearcoatTexture(),u=s.getClearcoatTextureInfo();a.clearcoatTexture=e.createTextureInfoDef(c,u)}if(s.getClearcoatRoughnessTexture()){const c=s.getClearcoatRoughnessTexture(),u=s.getClearcoatRoughnessTextureInfo();a.clearcoatRoughnessTexture=e.createTextureInfoDef(c,u)}if(s.getClearcoatNormalTexture()){const c=s.getClearcoatNormalTexture(),u=s.getClearcoatNormalTextureInfo();a.clearcoatNormalTexture=e.createTextureInfoDef(c,u),s.getClearcoatNormalScale()!==1&&(a.clearcoatNormalTexture.scale=s.getClearcoatNormalScale())}}}),this}}zs.EXTENSION_NAME=me;const{R:zr,G:$r,B:Xr,A:Kr}=te;class $s extends V{init(){this.extensionName=Ot,this.propertyType="DiffuseTransmission",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new j(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new j(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(e){return this.set("diffuseTransmissionFactor",e)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(e){return this.setRef("diffuseTransmissionTexture",e,{channels:Kr})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(e){return this.set("diffuseTransmissionColorFactor",e)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(e){return this.setRef("diffuseTransmissionColorTexture",e,{channels:zr|$r|Xr})}}$s.EXTENSION_NAME=Ot;const xe=Ot;class Xs extends U{constructor(...e){super(...e),this.extensionName=xe}createDiffuseTransmission(){return new $s(this.document.getGraph())}read(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[xe]){const a=this.createDiffuseTransmission();e.materials[o].setExtension(xe,a);const c=n.extensions[xe];if(c.diffuseTransmissionFactor!==void 0&&a.setDiffuseTransmissionFactor(c.diffuseTransmissionFactor),c.diffuseTransmissionColorFactor!==void 0&&a.setDiffuseTransmissionColorFactor(c.diffuseTransmissionColorFactor),c.diffuseTransmissionTexture!==void 0){const u=c.diffuseTransmissionTexture,g=e.textures[s[u.index].source];a.setDiffuseTransmissionTexture(g),e.setTextureInfo(a.getDiffuseTransmissionTextureInfo(),u)}if(c.diffuseTransmissionColorTexture!==void 0){const u=c.diffuseTransmissionColorTexture,g=e.textures[s[u.index].source];a.setDiffuseTransmissionColorTexture(g),e.setTextureInfo(a.getDiffuseTransmissionColorTextureInfo(),u)}}}),this}write(e){const t=e.jsonDoc;for(const r of this.document.getRoot().listMaterials()){const s=r.getExtension(xe);if(!s)continue;const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[xe]={diffuseTransmissionFactor:s.getDiffuseTransmissionFactor(),diffuseTransmissionColorFactor:s.getDiffuseTransmissionColorFactor()};if(s.getDiffuseTransmissionTexture()){const c=s.getDiffuseTransmissionTexture(),u=s.getDiffuseTransmissionTextureInfo();a.diffuseTransmissionTexture=e.createTextureInfoDef(c,u)}if(s.getDiffuseTransmissionColorTexture()){const c=s.getDiffuseTransmissionColorTexture(),u=s.getDiffuseTransmissionColorTextureInfo();a.diffuseTransmissionColorTexture=e.createTextureInfoDef(c,u)}}return this}}Xs.EXTENSION_NAME=xe;class Ks extends V{init(){this.extensionName=Dt,this.propertyType="Dispersion",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(e){return this.set("dispersion",e)}}Ks.EXTENSION_NAME=Dt;const Ee=Dt;class qs extends U{constructor(...e){super(...e),this.extensionName=Ee,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createDispersion(){return new Ks(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((s,n)=>{if(s.extensions&&s.extensions[Ee]){const o=this.createDispersion();e.materials[n].setExtension(Ee,o);const a=s.extensions[Ee];a.dispersion!==void 0&&o.setDispersion(a.dispersion)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Ee);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Ee]={dispersion:s.getDispersion()}}}),this}}qs.EXTENSION_NAME=Ee;class Ys extends V{init(){this.extensionName=vt,this.propertyType="EmissiveStrength",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(e){return this.set("emissiveStrength",e)}}Ys.EXTENSION_NAME=vt;const Re=vt;class Ws extends U{constructor(...e){super(...e),this.extensionName=Re,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createEmissiveStrength(){return new Ys(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((s,n)=>{if(s.extensions&&s.extensions[Re]){const o=this.createEmissiveStrength();e.materials[n].setExtension(Re,o);const a=s.extensions[Re];a.emissiveStrength!==void 0&&o.setEmissiveStrength(a.emissiveStrength)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Re);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Re]={emissiveStrength:s.getEmissiveStrength()}}}),this}}Ws.EXTENSION_NAME=Re;class Js extends V{init(){this.extensionName=Ft,this.propertyType="IOR",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(e){return this.set("ior",e)}}Js.EXTENSION_NAME=Ft;const Ie=Ft;class Qs extends U{constructor(...e){super(...e),this.extensionName=Ie,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createIOR(){return new Js(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((s,n)=>{if(s.extensions&&s.extensions[Ie]){const o=this.createIOR();e.materials[n].setExtension(Ie,o);const a=s.extensions[Ie];a.ior!==void 0&&o.setIOR(a.ior)}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Ie);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{},o.extensions[Ie]={ior:s.getIOR()}}}),this}}Qs.EXTENSION_NAME=Ie;const{R:qr,G:Yr}=te;class Zs extends V{init(){this.extensionName=Lt,this.propertyType="Iridescence",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new j(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new j(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(e){return this.set("iridescenceFactor",e)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(e){return this.setRef("iridescenceTexture",e,{channels:qr})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(e){return this.set("iridescenceIOR",e)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(e){return this.set("iridescenceThicknessMinimum",e)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(e){return this.set("iridescenceThicknessMaximum",e)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(e){return this.setRef("iridescenceThicknessTexture",e,{channels:Yr})}}Zs.EXTENSION_NAME=Lt;const ye=Lt;class en extends U{constructor(...e){super(...e),this.extensionName=ye,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createIridescence(){return new Zs(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[ye]){const a=this.createIridescence();e.materials[o].setExtension(ye,a);const c=n.extensions[ye];if(c.iridescenceFactor!==void 0&&a.setIridescenceFactor(c.iridescenceFactor),c.iridescenceIor!==void 0&&a.setIridescenceIOR(c.iridescenceIor),c.iridescenceThicknessMinimum!==void 0&&a.setIridescenceThicknessMinimum(c.iridescenceThicknessMinimum),c.iridescenceThicknessMaximum!==void 0&&a.setIridescenceThicknessMaximum(c.iridescenceThicknessMaximum),c.iridescenceTexture!==void 0){const u=c.iridescenceTexture,g=e.textures[s[u.index].source];a.setIridescenceTexture(g),e.setTextureInfo(a.getIridescenceTextureInfo(),u)}if(c.iridescenceThicknessTexture!==void 0){const u=c.iridescenceThicknessTexture,g=e.textures[s[u.index].source];a.setIridescenceThicknessTexture(g),e.setTextureInfo(a.getIridescenceThicknessTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(ye);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[ye]={};if(s.getIridescenceFactor()>0&&(a.iridescenceFactor=s.getIridescenceFactor()),s.getIridescenceIOR()!==1.3&&(a.iridescenceIor=s.getIridescenceIOR()),s.getIridescenceThicknessMinimum()!==100&&(a.iridescenceThicknessMinimum=s.getIridescenceThicknessMinimum()),s.getIridescenceThicknessMaximum()!==400&&(a.iridescenceThicknessMaximum=s.getIridescenceThicknessMaximum()),s.getIridescenceTexture()){const c=s.getIridescenceTexture(),u=s.getIridescenceTextureInfo();a.iridescenceTexture=e.createTextureInfoDef(c,u)}if(s.getIridescenceThicknessTexture()){const c=s.getIridescenceThicknessTexture(),u=s.getIridescenceThicknessTextureInfo();a.iridescenceThicknessTexture=e.createTextureInfoDef(c,u)}}}),this}}en.EXTENSION_NAME=ye;const{R:us,G:fs,B:ls,A:hs}=te;class tn extends V{init(){this.extensionName=Bt,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new j(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new j(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(e){return this.set("diffuseFactor",e)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(e){return this.setRef("diffuseTexture",e,{channels:us|fs|ls|hs,isColor:!0})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(e){return this.set("glossinessFactor",e)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(e){return this.setRef("specularGlossinessTexture",e,{channels:us|fs|ls|hs})}}tn.EXTENSION_NAME=Bt;const Ne=Bt;class sn extends U{constructor(...e){super(...e),this.extensionName=Ne,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createPBRSpecularGlossiness(){return new tn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Ne]){const a=this.createPBRSpecularGlossiness();e.materials[o].setExtension(Ne,a);const c=n.extensions[Ne];if(c.diffuseFactor!==void 0&&a.setDiffuseFactor(c.diffuseFactor),c.specularFactor!==void 0&&a.setSpecularFactor(c.specularFactor),c.glossinessFactor!==void 0&&a.setGlossinessFactor(c.glossinessFactor),c.diffuseTexture!==void 0){const u=c.diffuseTexture,g=e.textures[s[u.index].source];a.setDiffuseTexture(g),e.setTextureInfo(a.getDiffuseTextureInfo(),u)}if(c.specularGlossinessTexture!==void 0){const u=c.specularGlossinessTexture,g=e.textures[s[u.index].source];a.setSpecularGlossinessTexture(g),e.setTextureInfo(a.getSpecularGlossinessTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Ne);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Ne]={diffuseFactor:s.getDiffuseFactor(),specularFactor:s.getSpecularFactor(),glossinessFactor:s.getGlossinessFactor()};if(s.getDiffuseTexture()){const c=s.getDiffuseTexture(),u=s.getDiffuseTextureInfo();a.diffuseTexture=e.createTextureInfoDef(c,u)}if(s.getSpecularGlossinessTexture()){const c=s.getSpecularGlossinessTexture(),u=s.getSpecularGlossinessTextureInfo();a.specularGlossinessTexture=e.createTextureInfoDef(c,u)}}}),this}}sn.EXTENSION_NAME=Ne;const{R:Wr,G:Jr,B:Qr,A:Zr}=te;class nn extends V{init(){this.extensionName=jt,this.propertyType="Sheen",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new j(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new j(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(e){return this.set("sheenColorFactor",e)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(e){return this.setRef("sheenColorTexture",e,{channels:Wr|Jr|Qr,isColor:!0})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(e){return this.set("sheenRoughnessFactor",e)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(e){return this.setRef("sheenRoughnessTexture",e,{channels:Zr})}}nn.EXTENSION_NAME=jt;const Ae=jt;class rn extends U{constructor(...e){super(...e),this.extensionName=Ae,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createSheen(){return new nn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Ae]){const a=this.createSheen();e.materials[o].setExtension(Ae,a);const c=n.extensions[Ae];if(c.sheenColorFactor!==void 0&&a.setSheenColorFactor(c.sheenColorFactor),c.sheenRoughnessFactor!==void 0&&a.setSheenRoughnessFactor(c.sheenRoughnessFactor),c.sheenColorTexture!==void 0){const u=c.sheenColorTexture,g=e.textures[s[u.index].source];a.setSheenColorTexture(g),e.setTextureInfo(a.getSheenColorTextureInfo(),u)}if(c.sheenRoughnessTexture!==void 0){const u=c.sheenRoughnessTexture,g=e.textures[s[u.index].source];a.setSheenRoughnessTexture(g),e.setTextureInfo(a.getSheenRoughnessTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Ae);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Ae]={sheenColorFactor:s.getSheenColorFactor(),sheenRoughnessFactor:s.getSheenRoughnessFactor()};if(s.getSheenColorTexture()){const c=s.getSheenColorTexture(),u=s.getSheenColorTextureInfo();a.sheenColorTexture=e.createTextureInfoDef(c,u)}if(s.getSheenRoughnessTexture()){const c=s.getSheenRoughnessTexture(),u=s.getSheenRoughnessTextureInfo();a.sheenRoughnessTexture=e.createTextureInfoDef(c,u)}}}),this}}rn.EXTENSION_NAME=Ae;const{R:ei,G:ti,B:si,A:ni}=te;class on extends V{init(){this.extensionName=Ut,this.propertyType="Specular",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new j(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new j(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(e){return this.set("specularFactor",e)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(e){return this.set("specularColorFactor",e)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(e){return this.setRef("specularTexture",e,{channels:ni})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(e){return this.setRef("specularColorTexture",e,{channels:ei|ti|si,isColor:!0})}}on.EXTENSION_NAME=Ut;const Se=Ut;class an extends U{constructor(...e){super(...e),this.extensionName=Se,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createSpecular(){return new on(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Se]){const a=this.createSpecular();e.materials[o].setExtension(Se,a);const c=n.extensions[Se];if(c.specularFactor!==void 0&&a.setSpecularFactor(c.specularFactor),c.specularColorFactor!==void 0&&a.setSpecularColorFactor(c.specularColorFactor),c.specularTexture!==void 0){const u=c.specularTexture,g=e.textures[s[u.index].source];a.setSpecularTexture(g),e.setTextureInfo(a.getSpecularTextureInfo(),u)}if(c.specularColorTexture!==void 0){const u=c.specularColorTexture,g=e.textures[s[u.index].source];a.setSpecularColorTexture(g),e.setTextureInfo(a.getSpecularColorTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Se);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Se]={};if(s.getSpecularFactor()!==1&&(a.specularFactor=s.getSpecularFactor()),B.eq(s.getSpecularColorFactor(),[1,1,1])||(a.specularColorFactor=s.getSpecularColorFactor()),s.getSpecularTexture()){const c=s.getSpecularTexture(),u=s.getSpecularTextureInfo();a.specularTexture=e.createTextureInfoDef(c,u)}if(s.getSpecularColorTexture()){const c=s.getSpecularColorTexture(),u=s.getSpecularColorTextureInfo();a.specularColorTexture=e.createTextureInfoDef(c,u)}}}),this}}an.EXTENSION_NAME=Se;const{R:ri}=te;class cn extends V{init(){this.extensionName=Pt,this.propertyType="Transmission",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new j(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(e){return this.set("transmissionFactor",e)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(e){return this.setRef("transmissionTexture",e,{channels:ri})}}cn.EXTENSION_NAME=Pt;const Me=Pt;class un extends U{constructor(...e){super(...e),this.extensionName=Me,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createTransmission(){return new cn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[Me]){const a=this.createTransmission();e.materials[o].setExtension(Me,a);const c=n.extensions[Me];if(c.transmissionFactor!==void 0&&a.setTransmissionFactor(c.transmissionFactor),c.transmissionTexture!==void 0){const u=c.transmissionTexture,g=e.textures[s[u.index].source];a.setTransmissionTexture(g),e.setTextureInfo(a.getTransmissionTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(Me);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[Me]={transmissionFactor:s.getTransmissionFactor()};if(s.getTransmissionTexture()){const c=s.getTransmissionTexture(),u=s.getTransmissionTextureInfo();a.transmissionTexture=e.createTextureInfoDef(c,u)}}}),this}}un.EXTENSION_NAME=Me;class fn extends V{init(){this.extensionName=Gt,this.propertyType="Unlit",this.parentTypes=[h.MATERIAL]}}fn.EXTENSION_NAME=Gt;const Le=Gt;class ln extends U{constructor(...e){super(...e),this.extensionName=Le,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createUnlit(){return new fn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){return(e.jsonDoc.json.materials||[]).forEach((r,s)=>{r.extensions&&r.extensions[Le]&&e.materials[s].setExtension(Le,this.createUnlit())}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{if(r.getExtension(Le)){const s=e.materialIndexMap.get(r),n=t.json.materials[s];n.extensions=n.extensions||{},n.extensions[Le]={}}}),this}}ln.EXTENSION_NAME=Le;class hn extends V{init(){this.extensionName=Fe,this.propertyType="Mapping",this.parentTypes=["MappingList"]}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new P})}getMaterial(){return this.getRef("material")}setMaterial(e){return this.setRef("material",e)}addVariant(e){return this.addRef("variants",e)}removeVariant(e){return this.removeRef("variants",e)}listVariants(){return this.listRefs("variants")}}hn.EXTENSION_NAME=Fe;class gn extends V{init(){this.extensionName=Fe,this.propertyType="MappingList",this.parentTypes=[h.PRIMITIVE]}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new P})}addMapping(e){return this.addRef("mappings",e)}removeMapping(e){return this.removeRef("mappings",e)}listMappings(){return this.listRefs("mappings")}}gn.EXTENSION_NAME=Fe;class Nt extends V{init(){this.extensionName=Fe,this.propertyType="Variant",this.parentTypes=["MappingList"]}}Nt.EXTENSION_NAME=Fe;const ie=Fe;class pn extends U{constructor(...e){super(...e),this.extensionName=ie}createMappingList(){return new gn(this.document.getGraph())}createVariant(e=""){return new Nt(this.document.getGraph(),e)}createMapping(){return new hn(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter(e=>e instanceof Nt)}read(e){const t=e.jsonDoc;if(!t.json.extensions||!t.json.extensions[ie])return this;const n=(t.json.extensions[ie].variants||[]).map(a=>this.createVariant().setName(a.name||""));return(t.json.meshes||[]).forEach((a,c)=>{const u=e.meshes[c];(a.primitives||[]).forEach((p,m)=>{if(!p.extensions||!p.extensions[ie])return;const N=this.createMappingList(),S=p.extensions[ie];for(const w of S.mappings){const M=this.createMapping();w.material!==void 0&&M.setMaterial(e.materials[w.material]);for(const l of w.variants||[])M.addVariant(n[l]);N.addMapping(M)}u.listPrimitives()[m].setExtension(ie,N)})}),this}write(e){const t=e.jsonDoc,r=this.listVariants();if(!r.length)return this;const s=[],n=new Map;for(const o of r)n.set(o,s.length),s.push(e.createPropertyDef(o));for(const o of this.document.getRoot().listMeshes()){const a=e.meshIndexMap.get(o);o.listPrimitives().forEach((c,u)=>{const g=c.getExtension(ie);if(!g)return;const p=e.jsonDoc.json.meshes[a].primitives[u],m=g.listMappings().map(N=>{const S=e.createPropertyDef(N),w=N.getMaterial();return w&&(S.material=e.materialIndexMap.get(w)),S.variants=N.listVariants().map(M=>n.get(M)),S});p.extensions=p.extensions||{},p.extensions[ie]={mappings:m}})}return t.json.extensions=t.json.extensions||{},t.json.extensions[ie]={variants:s},this}}pn.EXTENSION_NAME=ie;const{G:ii}=te;class dn extends V{init(){this.extensionName=Vt,this.propertyType="Volume",this.parentTypes=[h.MATERIAL]}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new j(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(e){return this.set("thicknessFactor",e)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(e){return this.setRef("thicknessTexture",e,{channels:ii})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(e){return this.set("attenuationDistance",e)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(e){return this.set("attenuationColor",e)}}dn.EXTENSION_NAME=Vt;const we=Vt;class Tn extends U{constructor(...e){super(...e),this.extensionName=we,this.prereadTypes=[h.MESH],this.prewriteTypes=[h.MESH]}createVolume(){return new dn(this.document.getGraph())}read(e){return this}write(e){return this}preread(e){const t=e.jsonDoc,r=t.json.materials||[],s=t.json.textures||[];return r.forEach((n,o)=>{if(n.extensions&&n.extensions[we]){const a=this.createVolume();e.materials[o].setExtension(we,a);const c=n.extensions[we];if(c.thicknessFactor!==void 0&&a.setThicknessFactor(c.thicknessFactor),c.attenuationDistance!==void 0&&a.setAttenuationDistance(c.attenuationDistance),c.attenuationColor!==void 0&&a.setAttenuationColor(c.attenuationColor),c.thicknessTexture!==void 0){const u=c.thicknessTexture,g=e.textures[s[u.index].source];a.setThicknessTexture(g),e.setTextureInfo(a.getThicknessTextureInfo(),u)}}}),this}prewrite(e){const t=e.jsonDoc;return this.document.getRoot().listMaterials().forEach(r=>{const s=r.getExtension(we);if(s){const n=e.materialIndexMap.get(r),o=t.json.materials[n];o.extensions=o.extensions||{};const a=o.extensions[we]={};if(s.getThicknessFactor()>0&&(a.thicknessFactor=s.getThicknessFactor()),Number.isFinite(s.getAttenuationDistance())&&(a.attenuationDistance=s.getAttenuationDistance()),B.eq(s.getAttenuationColor(),[1,1,1])||(a.attenuationColor=s.getAttenuationColor()),s.getThicknessTexture()){const c=s.getThicknessTexture(),u=s.getThicknessTextureInfo();a.thicknessTexture=e.createTextureInfoDef(c,u)}}}),this}}Tn.EXTENSION_NAME=we;const mn=xr;class xn extends U{constructor(...e){super(...e),this.extensionName=mn}read(e){return this}write(e){return this}}xn.EXTENSION_NAME=mn;const $e=Er;class oi{match(e){return e[0]===171&&e[1]===75&&e[2]===84&&e[3]===88&&e[4]===32&&e[5]===50&&e[6]===48&&e[7]===187&&e[8]===13&&e[9]===10&&e[10]===26&&e[11]===10}getSize(e){const t=ht(e);return[t.pixelWidth,t.pixelHeight]}getChannels(e){const r=ht(e).dataFormatDescriptor[0];if(r.colorModel===Cn)return r.samples.length===2&&(r.samples[1].channelType&15)===15?4:3;if(r.colorModel===On)return(r.samples[0].channelType&15)===3?4:3;throw new Error(`Unexpected KTX2 colorModel, "${r.colorModel}".`)}getVRAMByteLength(e){const t=ht(e),r=this.getChannels(e)>3;let s=0;for(let n=0;n<t.levels.length;n++){const o=t.levels[n];if(o.uncompressedByteLength)s+=o.uncompressedByteLength;else{const a=Math.max(1,Math.floor(t.pixelWidth/Math.pow(2,n))),c=Math.max(1,Math.floor(t.pixelHeight/Math.pow(2,n))),u=r?16:8;s+=a/4*(c/4)*u}}return s}}class En extends U{constructor(...e){super(...e),this.extensionName=$e,this.prereadTypes=[h.TEXTURE]}static register(){ae.registerFormat("image/ktx2",new oi)}preread(e){return e.jsonDoc.json.textures.forEach(t=>{if(t.extensions&&t.extensions[$e]){const r=t.extensions[$e];t.source=r.source}}),this}read(e){return this}write(e){const t=e.jsonDoc;return this.document.getRoot().listTextures().forEach(r=>{if(r.getMimeType()==="image/ktx2"){const s=e.imageIndexMap.get(r);t.json.textures.forEach(n=>{n.source===s&&(n.extensions=n.extensions||{},n.extensions[$e]={source:n.source},delete n.source)})}}),this}}En.EXTENSION_NAME=$e;class Rn extends V{init(){this.extensionName=kt,this.propertyType="Transform",this.parentTypes=[h.TEXTURE_INFO]}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(e){return this.set("offset",e)}getRotation(){return this.get("rotation")}setRotation(e){return this.set("rotation",e)}getScale(){return this.get("scale")}setScale(e){return this.set("scale",e)}getTexCoord(){return this.get("texCoord")}setTexCoord(e){return this.set("texCoord",e)}}Rn.EXTENSION_NAME=kt;const be=kt;class In extends U{constructor(...e){super(...e),this.extensionName=be}createTransform(){return new Rn(this.document.getGraph())}read(e){for(const[t,r]of Array.from(e.textureInfos.entries())){if(!r.extensions||!r.extensions[be])continue;const s=this.createTransform(),n=r.extensions[be];n.offset!==void 0&&s.setOffset(n.offset),n.rotation!==void 0&&s.setRotation(n.rotation),n.scale!==void 0&&s.setScale(n.scale),n.texCoord!==void 0&&s.setTexCoord(n.texCoord),t.setExtension(be,s)}return this}write(e){const t=Array.from(e.textureInfoDefMap.entries());for(const[r,s]of t){const n=r.getExtension(be);if(!n)continue;s.extensions=s.extensions||{};const o={},a=B.eq;a(n.getOffset(),[0,0])||(o.offset=n.getOffset()),n.getRotation()!==0&&(o.rotation=n.getRotation()),a(n.getScale(),[1,1])||(o.scale=n.getScale()),n.getTexCoord()!=null&&(o.texCoord=n.getTexCoord()),s.extensions[be]=o}return this}}In.EXTENSION_NAME=be;const ai=[h.ROOT,h.SCENE,h.NODE,h.MESH,h.MATERIAL,h.TEXTURE,h.ANIMATION];class yn extends V{init(){this.extensionName=ot,this.propertyType="Packet",this.parentTypes=ai}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(e){return this.set("context",fe({},e))}listProperties(){return Object.keys(this.get("properties"))}getProperty(e){const t=this.get("properties");return e in t?t[e]:null}setProperty(e,t){this._assertContext(e);const r=fe({},this.get("properties"));return t?r[e]=t:delete r[e],this.set("properties",r)}toJSONLD(){const e=pt(this.get("context")),t=pt(this.get("properties"));return fe({"@context":e},t)}fromJSONLD(e){e=pt(e);const t=e["@context"];return t&&this.set("context",t),delete e["@context"],this.set("properties",e)}_assertContext(e){if(!(e.split(":")[0]in this.get("context")))throw new Error(`${ot}: Missing context for term, "${e}".`)}}yn.EXTENSION_NAME=ot;function pt(i){return JSON.parse(JSON.stringify(i))}const ue=ot;class Nn extends U{constructor(...e){super(...e),this.extensionName=ue}createPacket(){return new yn(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(e){var t;const r=(t=e.jsonDoc.json.extensions)==null?void 0:t[ue];if(!r||!r.packets)return this;const s=e.jsonDoc.json,n=this.document.getRoot(),o=r.packets.map(u=>this.createPacket().fromJSONLD(u)),a=[[s.asset],s.scenes,s.nodes,s.meshes,s.materials,s.images,s.animations],c=[[n],n.listScenes(),n.listNodes(),n.listMeshes(),n.listMaterials(),n.listTextures(),n.listAnimations()];for(let u=0;u<a.length;u++){const g=a[u]||[];for(let p=0;p<g.length;p++){const m=g[p];if(m.extensions&&m.extensions[ue]){const N=m.extensions[ue];c[u][p].setExtension(ue,o[N.packet])}}}return this}write(e){const{json:t}=e.jsonDoc,r=[];for(const s of this.properties){r.push(s.toJSONLD());for(const n of s.listParents()){let o;switch(n.propertyType){case h.ROOT:o=t.asset;break;case h.SCENE:o=t.scenes[e.sceneIndexMap.get(n)];break;case h.NODE:o=t.nodes[e.nodeIndexMap.get(n)];break;case h.MESH:o=t.meshes[e.meshIndexMap.get(n)];break;case h.MATERIAL:o=t.materials[e.materialIndexMap.get(n)];break;case h.TEXTURE:o=t.images[e.imageIndexMap.get(n)];break;case h.ANIMATION:o=t.animations[e.animationIndexMap.get(n)];break;default:o=null,this.document.getLogger().warn(`[${ue}]: Unsupported parent property, "${n.propertyType}"`);break}o&&(o.extensions=o.extensions||{},o.extensions[ue]={packet:r.length-1})}}return r.length>0&&(t.extensions=t.extensions||{},t.extensions[ue]={packets:r}),this}}Nn.EXTENSION_NAME=ue;const ci=[zt,Gs,ks,zs,Xs,qs,Ws,Qs,en,sn,an,rn,un,ln,pn,Tn,xn,En,In,Nn],ui=[vs,Ht,Ls,Bs,...ci],An=new dr;let gs=!1;async function fi(){gs||(await $t.ready,await Xt.ready,An.registerExtensions([...ui,bs,Cs]).registerDependencies({"meshopt.decoder":$t,"meshopt.encoder":Xt}),gs=!0)}const di=Object.freeze(Object.defineProperty({__proto__:null,initGlTFIO:fi,io:An},Symbol.toStringTag,{value:"Module"}));export{A,D as B,pi as C,qe as D,Ht as E,ge as F,bs as G,xn as K,B as M,ys as N,De as P,Ms as R,Ns as S,Ss as T,h as a,Mt as b,j as c,V as d,Oe as e,Zn as f,En as g,Cs as h,An as i,di as j,Yn as u};