threenative-animation-mcp 0.1.18 → 0.1.20
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.
- package/dist/client/app.js +4020 -59766
- package/dist/index.js +16 -16
- package/dist/pose-lab.d.ts +13 -0
- package/dist/pose-lab.js +189 -0
- package/package.json +6 -2
package/dist/pose-lab.js
ADDED
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import {readFile,mkdir,writeFile,readdir}from'fs/promises';import'http';import at from'path';var gr=[{id:"right-hand",label:"Right hand",patterns:[/righthand/u,/handright/u,/rhand/u]},{id:"left-hand",label:"Left hand",patterns:[/lefthand/u,/handleft/u,/lhand/u]},{id:"head",label:"Head",patterns:[/head/u]},{id:"hips",label:"Hips / root",patterns:[/hips/u,/pelvis/u,/^root$/u]},{id:"right-foot",label:"Right foot",patterns:[/rightfoot/u,/footright/u,/rfoot/u]},{id:"left-foot",label:"Left foot",patterns:[/leftfoot/u,/footleft/u,/lfoot/u]}];function yn(n){return n.toLowerCase().replaceAll(/[^a-z0-9]/gu,"")}function _r(n,e){return e.filter(t=>n.patterns.some(i=>i.test(yn(t)))).sort((t,i)=>yn(t).length-yn(i).length)[0]}function Ai(n){return gr.flatMap(e=>{let t=_r(e,n);return t===void 0?[]:[{id:e.id,label:e.label,node:t,source:"detected"}]})}var Ri=class{_listeners={};addEventListener(n,e){let t=this._listeners;return t[n]===void 0&&(t[n]=[]),t[n].indexOf(e)===-1&&t[n].push(e),this}removeEventListener(n,e){let t=this._listeners[n];if(t!==void 0){let i=t.indexOf(e);i!==-1&&t.splice(i,1);}return this}dispatchEvent(n){let e=this._listeners[n.type];if(e!==void 0){let t=e.slice(0);for(let i=0,s=t.length;i<s;i++)t[i].call(this,n);}return this}dispose(){for(let n in this._listeners)delete this._listeners[n];}},Ue=class{_disposed=false;_name;_parent;_child;_attributes;constructor(n,e,t,i={}){if(this._name=n,this._parent=e,this._child=t,this._attributes=i,!e.isOnGraph(t))throw new Error("Cannot connect disconnected graphs.")}getName(){return this._name}getParent(){return this._parent}getChild(){return this._child}setChild(n){return this._child=n,this}getAttributes(){return this._attributes}dispose(){this._disposed||(this._parent._destroyRef(this),this._disposed=true);}isDisposed(){return this._disposed}},vn=class extends Ri{_emptySet=new Set;_edges=new Set;_parentEdges=new Map;_childEdges=new Map;listEdges(){return Array.from(this._edges)}listParentEdges(n){return Array.from(this._childEdges.get(n)||this._emptySet)}listParents(n){let e=new Set;for(let t of this.listParentEdges(n))e.add(t.getParent());return Array.from(e)}listChildEdges(n){return Array.from(this._parentEdges.get(n)||this._emptySet)}listChildren(n){let e=new Set;for(let t of this.listChildEdges(n))e.add(t.getChild());return Array.from(e)}disconnectParents(n,e){for(let t of this.listParentEdges(n))(!e||e(t.getParent()))&&t.dispose();return this}_createEdge(n,e,t,i){let s=new Ue(n,e,t,i);this._edges.add(s);let r=s.getParent();this._parentEdges.has(r)||this._parentEdges.set(r,new Set),this._parentEdges.get(r).add(s);let o=s.getChild();return this._childEdges.has(o)||this._childEdges.set(o,new Set),this._childEdges.get(o).add(s),s}_destroyEdge(n){return this._edges.delete(n),this._parentEdges.get(n.getParent()).delete(n),this._childEdges.get(n.getChild()).delete(n),this}},ne=class{list=[];constructor(n){if(n)for(let e of n)this.list.push(e);}add(n){this.list.push(n);}remove(n){let e=this.list.indexOf(n);e>=0&&this.list.splice(e,1);}removeChild(n){let e=[];for(let t of this.list)t.getChild()===n&&e.push(t);for(let t of e)this.remove(t);return e}listRefsByChild(n){let e=[];for(let t of this.list)t.getChild()===n&&e.push(t);return e}values(){return this.list}},H=class{set=new Set;map=new Map;constructor(n){if(n)for(let e of n)this.add(e);}add(n){let e=n.getChild();this.removeChild(e),this.set.add(n),this.map.set(e,n);}remove(n){this.set.delete(n),this.map.delete(n.getChild());}removeChild(n){let e=this.map.get(n)||null;return e&&this.remove(e),e}getRefByChild(n){return this.map.get(n)||null}values(){return Array.from(this.set)}},$=class{map={};constructor(n){n&&Object.assign(this.map,n);}set(n,e){this.map[n]=e;}delete(n){delete this.map[n];}get(n){return this.map[n]||null}keys(){return Object.keys(this.map)}values(){return Object.values(this.map)}},z=Symbol("attributes"),Fe=Symbol("immutableKeys"),wi=class Ci extends Ri{_disposed=false;graph;[z];[Fe];constructor(e){super(),this.graph=e,this[Fe]=new Set,this[z]=this._createAttributes();}getDefaults(){return {}}_createAttributes(){let e=this.getDefaults(),t={};for(let i in e){let s=e[i];if(s instanceof Ci){let r=this.graph._createEdge(i,this,s);this[Fe].add(i),t[i]=r;}else t[i]=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=true,this.dispatchEvent({type:"dispose"}));}detach(){return this.graph.disconnectParents(this),this}swap(e,t){for(let i in this[z]){let s=this[z][i];if(s instanceof Ue){let r=s;r.getChild()===e&&this.setRef(i,t,r.getAttributes());}else if(s instanceof ne)for(let r of s.listRefsByChild(e)){let o=r.getAttributes();this.removeRef(i,e),this.addRef(i,t,o);}else if(s instanceof H){let r=s.getRefByChild(e);if(r){let o=r.getAttributes();this.removeRef(i,e),this.addRef(i,t,o);}}else if(s instanceof $)for(let r of s.keys()){let o=s.get(r);o.getChild()===e&&this.setRefMap(i,r,t,o.getAttributes());}}return this}get(e){return this[z][e]}set(e,t){return this[z][e]=t,this.dispatchEvent({type:"change",attribute:e})}getRef(e){let t=this[z][e];return t?t.getChild():null}setRef(e,t,i){if(this[Fe].has(e))throw new Error(`Cannot overwrite immutable attribute, "${e}".`);let s=this[z][e];if(s&&s.dispose(),!t)return this;let r=this.graph._createEdge(e,this,t,i);return this[z][e]=r,this.dispatchEvent({type:"change",attribute:e})}listRefs(e){return this.assertRefList(e).values().map(t=>t.getChild())}addRef(e,t,i){let s=this.graph._createEdge(e,this,t,i);return this.assertRefList(e).add(s),this.dispatchEvent({type:"change",attribute:e})}removeRef(e,t){let i=this.assertRefList(e);if(i instanceof ne)for(let s of i.listRefsByChild(t))s.dispose();else {let s=i.getRefByChild(t);s&&s.dispose();}return this}assertRefList(e){let t=this[z][e];if(t instanceof ne||t instanceof H)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){let i=this.assertRefMap(e).get(t);return i?i.getChild():null}setRefMap(e,t,i,s){let r=this.assertRefMap(e),o=r.get(t);if(o&&o.dispose(),!i)return this;s=Object.assign(s||{},{key:t});let a=this.graph._createEdge(e,this,i,{...s,key:t});return r.set(t,a),this.dispatchEvent({type:"change",attribute:e,key:t})}assertRefMap(e){let t=this[z][e];if(t instanceof $)return t;throw new Error(`Expected RefMap for attribute "${e}"`)}dispatchEvent(e){return super.dispatchEvent({...e,target:this}),this.graph.dispatchEvent({...e,target:this,type:`node:${e.type}`}),this}_destroyRef(e){let t=e.getName();if(this[z][t]===e)this[z][t]=null,this[Fe].has(t)&&e.getChild().dispose();else if(this[z][t]instanceof ne)this[z][t].remove(e);else if(this[z][t]instanceof H)this[z][t].remove(e);else if(this[z][t]instanceof $){let i=this[z][t];for(let s of i.keys())i.get(s)===e&&i.delete(s);}else return;this.graph._destroyEdge(e),this.dispatchEvent({type:"change",attribute:t});}};var Fi="v4.4.2",Ve="@glb.bin",T=(function(n){return n.ACCESSOR="Accessor",n.ANIMATION="Animation",n.ANIMATION_CHANNEL="AnimationChannel",n.ANIMATION_SAMPLER="AnimationSampler",n.BUFFER="Buffer",n.CAMERA="Camera",n.MATERIAL="Material",n.MESH="Mesh",n.PRIMITIVE="Primitive",n.PRIMITIVE_TARGET="PrimitiveTarget",n.NODE="Node",n.ROOT="Root",n.SCENE="Scene",n.SKIN="Skin",n.TEXTURE="Texture",n.TEXTURE_INFO="TextureInfo",n})({});var xr=(function(n){return n.ARRAY_BUFFER="ARRAY_BUFFER",n.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",n.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",n.OTHER="OTHER",n.SPARSE="SPARSE",n})({}),Se=(function(n){return n[n.R=4096]="R",n[n.G=256]="G",n[n.B=16]="B",n[n.A=1]="A",n})({});var yr=class extends Float32Array{constructor(){throw super(),new Error("Unsupported typed array instantiation.")}},zt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5131:typeof Float16Array<"u"?Float16Array:yr,5126:Float32Array,5130:Float64Array},P=class{static createBufferFromDataURI(n){if(typeof Buffer>"u"){let e=atob(n.split(",")[1]),t=new Uint8Array(e.length);for(let i=0;i<e.length;i++)t[i]=e.charCodeAt(i);return t}else {let e=n.split(",")[1],t=n.indexOf("base64")>=0;return Buffer.from(e,t?"base64":"utf8")}}static encodeText(n){return new TextEncoder().encode(n)}static decodeText(n){return new TextDecoder().decode(n)}static concat(n){let e=0;for(let s of n)e+=s.byteLength;let t=new Uint8Array(e),i=0;for(let s of n)t.set(s,i),i+=s.byteLength;return t}static pad(n,e=0){let t=this.padNumber(n.byteLength);if(t===n.byteLength)return n;let i=new Uint8Array(t);if(i.set(n),e!==0)for(let s=n.byteLength;s<t;s++)i[s]=e;return i}static padNumber(n){return Math.ceil(n/4)*4}static equals(n,e){if(n===e)return true;if(n.byteLength!==e.byteLength)return false;let t=n.byteLength;for(;t--;)if(n[t]!==e[t])return false;return true}static toView(n,e=0,t=1/0){return new Uint8Array(n.buffer,n.byteOffset+e,Math.min(n.byteLength,t))}static assertView(n){if(n&&!ArrayBuffer.isView(n))throw new Error(`Method requires Uint8Array parameter; received "${typeof n}".`);return n}};var vr=class{match(n){return n.length>=3&&n[0]===255&&n[1]===216&&n[2]===255}getSize(n){let e=new DataView(n.buffer,n.byteOffset+4),t,i;for(;e.byteLength;){if(t=e.getUint16(0,false),Sr(e,t),i=e.getUint8(t+1),i===192||i===193||i===194)return [e.getUint16(t+7,false),e.getUint16(t+5,false)];e=new DataView(n.buffer,e.byteOffset+t+2);}throw new TypeError("Invalid JPG, no size found")}getChannels(n){return 3}},Mr=class Ui{static PNG_FRIED_CHUNK_NAME="CgBI";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){let t=new DataView(e.buffer,e.byteOffset);return P.decodeText(e.slice(12,16))===Ui.PNG_FRIED_CHUNK_NAME?[t.getUint32(32,false),t.getUint32(36,false)]:[t.getUint32(16,false),t.getUint32(20,false)]}getChannels(e){return 4}},Re=class{static impls={"image/jpeg":new vr,"image/png":new Mr};static registerFormat(n,e){this.impls[n]=e;}static getMimeType(n){for(let e in this.impls)if(this.impls[e].match(n))return e;return null}static getSize(n,e){return this.impls[e]?this.impls[e].getSize(n):null}static getChannels(n,e){return this.impls[e]?this.impls[e].getChannels(n):null}static getVRAMByteLength(n,e){if(!this.impls[e])return null;if(this.impls[e].getVRAMByteLength)return this.impls[e].getVRAMByteLength(n);let t=0,i=4,s=this.getSize(n,e);if(!s)return null;for(;s[0]>1||s[1]>1;)t+=s[0]*s[1]*i,s[0]=Math.max(Math.floor(s[0]/2),1),s[1]=Math.max(Math.floor(s[1]/2),1);return t+=1*i,t}static mimeTypeToExtension(n){return n==="image/jpeg"?"jpg":n.split("/").pop()}static extensionToMimeType(n){return n==="jpg"?"image/jpeg":n?`image/${n}`:""}};function Sr(n,e){if(e>n.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(n.getUint8(e)!==255)throw new TypeError("Invalid JPG, marker table corrupted");return n}var lt=class{static basename(n){let e=n.split(/[\\/]/).pop();return e.substring(0,e.lastIndexOf("."))}static extension(n){if(n.startsWith("data:image/")){let e=n.match(/data:(image\/\w+)/)[1];return Re.mimeTypeToExtension(e)}else {if(n.startsWith("data:model/gltf+json"))return "gltf";if(n.startsWith("data:model/gltf-binary"))return "glb";if(n.startsWith("data:application/"))return "bin"}return n.split(/[\\/]/).pop().split(/[.]/).pop()}},Sn=typeof Float32Array<"u"?Float32Array:Array;function Tr(){var n=new Sn(3);return Sn!=Float32Array&&(n[0]=0,n[1]=0,n[2]=0),n}function Mn(n){var e=n[0],t=n[1],i=n[2];return Math.sqrt(e*e+t*t+i*i)}function br(n,e,t){var i=e[0],s=e[1],r=e[2],o=t[3]*i+t[7]*s+t[11]*r+t[15];return o=o||1,n[0]=(t[0]*i+t[4]*s+t[8]*r+t[12])/o,n[1]=(t[1]*i+t[5]*s+t[9]*r+t[13])/o,n[2]=(t[2]*i+t[6]*s+t[10]*r+t[14])/o,n}(function(){var n=Tr();return function(e,t,i,s,r,o){var a,c;for(t||(t=3),i||(i=0),s?c=Math.min(s*t+i,e.length):c=e.length,a=i;a<c;a+=t)n[0]=e[a],n[1]=e[a+1],n[2]=e[a+2],r(n,n,o),e[a]=n[0],e[a+1]=n[1],e[a+2]=n[2];return e}})();function Bi(n){let e=Vi(),t=n.propertyType==="Node"?[n]:n.listChildren();for(let i of t)i.traverse(s=>{let r=s.getMesh();if(!r)return;let o=Er(r,s.getWorldMatrix());o.min.every(isFinite)&&o.max.every(isFinite)&&(Tn(o.min,e),Tn(o.max,e));});return e}function Er(n,e){let t=Vi();for(let i of n.listPrimitives()){let s=i.getAttribute("POSITION"),r=i.getIndices();if(!s)continue;let o=[0,0,0],a=[0,0,0];for(let c=0,l=r?r.getCount():s.getCount();c<l;c++){let u=r?r.getScalar(c):c;o=s.getElement(u,o),a=br(a,o,e),Tn(a,t);}}return t}function Tn(n,e){for(let t=0;t<3;t++)e.min[t]=Math.min(n[t],e.min[t]),e.max[t]=Math.max(n[t],e.max[t]);}function Vi(){return {min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}var Ii="https://null.example",Ie=class{static DEFAULT_INIT={};static PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//;static dirname(n){let e=n.lastIndexOf("/");return e===-1?"./":n.substring(0,e+1)}static basename(n){return lt.basename(new URL(n,Ii).pathname)}static extension(n){return lt.extension(new URL(n,Ii).pathname)}static resolve(n,e){if(!this.isRelativePath(e))return e;let t=n.split("/"),i=e.split("/");t.pop();for(let s=0;s<i.length;s++)i[s]!=="."&&(i[s]===".."?t.pop():t.push(i[s]));return t.join("/")}static isAbsoluteURL(n){return this.PROTOCOL_REGEXP.test(n)}static isRelativePath(n){return !/^(?:[a-zA-Z]+:)?\//.test(n)}};function Ni(n){return Object.prototype.toString.call(n)==="[object Object]"}function ct(n){if(Ni(n)===false)return false;let e=n.constructor;if(e===void 0)return true;let t=e.prototype;return !(Ni(t)===false||Object.hasOwn(t,"isPrototypeOf")===false)}var Ar=(function(n){return n[n.SILENT=4]="SILENT",n[n.ERROR=3]="ERROR",n[n.WARN=2]="WARN",n[n.INFO=1]="INFO",n[n.DEBUG=0]="DEBUG",n})({}),kt=class Gi{verbosity;static Verbosity=Ar;static DEFAULT_INSTANCE=new Gi(1);constructor(e){this.verbosity=e;}debug(e){this.verbosity<=0&&console.debug(e);}info(e){this.verbosity<=1&&console.info(e);}warn(e){this.verbosity<=2&&console.warn(e);}error(e){this.verbosity<=3&&console.error(e);}};function Rr(n){var e=n[0],t=n[1],i=n[2],s=n[3],r=n[4],o=n[5],a=n[6],c=n[7],l=n[8],u=n[9],d=n[10],m=n[11],p=n[12],_=n[13],f=n[14],v=n[15],h=e*o-t*r,x=e*a-i*r,g=t*a-i*o,y=l*_-u*p,M=l*f-d*p,S=u*f-d*_,b=e*S-t*M+i*y,A=r*S-o*M+a*y,w=l*g-u*x+d*h,R=p*g-_*x+f*h;return c*b-s*A+v*w-m*R}function wr(n,e,t){var i=e[0],s=e[1],r=e[2],o=e[3],a=e[4],c=e[5],l=e[6],u=e[7],d=e[8],m=e[9],p=e[10],_=e[11],f=e[12],v=e[13],h=e[14],x=e[15],g=t[0],y=t[1],M=t[2],S=t[3];return n[0]=g*i+y*a+M*d+S*f,n[1]=g*s+y*c+M*m+S*v,n[2]=g*r+y*l+M*p+S*h,n[3]=g*o+y*u+M*_+S*x,g=t[4],y=t[5],M=t[6],S=t[7],n[4]=g*i+y*a+M*d+S*f,n[5]=g*s+y*c+M*m+S*v,n[6]=g*r+y*l+M*p+S*h,n[7]=g*o+y*u+M*_+S*x,g=t[8],y=t[9],M=t[10],S=t[11],n[8]=g*i+y*a+M*d+S*f,n[9]=g*s+y*c+M*m+S*v,n[10]=g*r+y*l+M*p+S*h,n[11]=g*o+y*u+M*_+S*x,g=t[12],y=t[13],M=t[14],S=t[15],n[12]=g*i+y*a+M*d+S*f,n[13]=g*s+y*c+M*m+S*v,n[14]=g*r+y*l+M*p+S*h,n[15]=g*o+y*u+M*_+S*x,n}function Cr(n,e){var t=e[0],i=e[1],s=e[2],r=e[4],o=e[5],a=e[6],c=e[8],l=e[9],u=e[10];return n[0]=Math.sqrt(t*t+i*i+s*s),n[1]=Math.sqrt(r*r+o*o+a*a),n[2]=Math.sqrt(c*c+l*l+u*u),n}function Ir(n,e){var t=new Sn(3);Cr(t,e);var i=1/t[0],s=1/t[1],r=1/t[2],o=e[0]*i,a=e[1]*s,c=e[2]*r,l=e[4]*i,u=e[5]*s,d=e[6]*r,m=e[8]*i,p=e[9]*s,_=e[10]*r,f=o+u+_,v=0;return f>0?(v=Math.sqrt(f+1)*2,n[3]=.25*v,n[0]=(d-p)/v,n[1]=(m-c)/v,n[2]=(a-l)/v):o>u&&o>_?(v=Math.sqrt(1+o-u-_)*2,n[3]=(d-p)/v,n[0]=.25*v,n[1]=(a+l)/v,n[2]=(m+c)/v):u>_?(v=Math.sqrt(1+u-o-_)*2,n[3]=(m-c)/v,n[0]=(a+l)/v,n[1]=.25*v,n[2]=(d+p)/v):(v=Math.sqrt(1+_-o-u)*2,n[3]=(a-l)/v,n[0]=(m+c)/v,n[1]=(d+p)/v,n[2]=.25*v),n}var X=class St{static identity(e){return e}static eq(e,t,i=1e-5){if(e.length!==t.length)return false;for(let s=0;s<e.length;s++)if(Math.abs(e[s]-t[s])>i)return false;return true}static clamp(e,t,i){return e<t?t:e>i?i: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(St.clamp(e,0,1)*65535);case 5121:return Math.round(St.clamp(e,0,1)*255);case 5122:return Math.round(St.clamp(e,-1,1)*32767);case 5120:return Math.round(St.clamp(e,-1,1)*127);default:throw new Error("Invalid component type.")}}static decompose(e,t,i,s){let r=Mn([e[0],e[1],e[2]]),o=Mn([e[4],e[5],e[6]]),a=Mn([e[8],e[9],e[10]]);Rr(e)<0&&(r=-r),t[0]=e[12],t[1]=e[13],t[2]=e[14];let c=e.slice(),l=1/r,u=1/o,d=1/a;c[0]*=l,c[1]*=l,c[2]*=l,c[4]*=u,c[5]*=u,c[6]*=u,c[8]*=d,c[9]*=d,c[10]*=d,Ir(i,c),s[0]=r,s[1]=o,s[2]=a;}static compose(e,t,i,s){let r=s,o=t[0],a=t[1],c=t[2],l=t[3],u=o+o,d=a+a,m=c+c,p=o*u,_=o*d,f=o*m,v=a*d,h=a*m,x=c*m,g=l*u,y=l*d,M=l*m,S=i[0],b=i[1],A=i[2];return r[0]=(1-(v+x))*S,r[1]=(_+M)*S,r[2]=(f-y)*S,r[3]=0,r[4]=(_-M)*b,r[5]=(1-(p+x))*b,r[6]=(h+g)*b,r[7]=0,r[8]=(f+y)*A,r[9]=(h-g)*A,r[10]=(1-(p+v))*A,r[11]=0,r[12]=e[0],r[13]=e[1],r[14]=e[2],r[15]=1,r}};function Nr(n,e){if(!!n!=!!e)return false;let t=n.getChild(),i=e.getChild();return t===i||t.equals(i)}function Pr(n,e){if(!!n!=!!e)return false;let t=n.values(),i=e.values();if(t.length!==i.length)return false;for(let s=0;s<t.length;s++){let r=t[s],o=i[s];if(r.getChild()!==o.getChild()&&!r.getChild().equals(o.getChild()))return false}return true}function Or(n,e){if(!!n!=!!e)return false;let t=n.keys(),i=e.keys();if(t.length!==i.length)return false;for(let s of t){let r=n.get(s),o=e.get(s);if(!!r!=!!o)return false;let a=r.getChild(),c=o.getChild();if(a!==c&&!a.equals(c))return false}return true}function zi(n,e){if(n===e)return true;if(!!n!=!!e||!n||!e||n.length!==e.length)return false;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return false;return true}function ki(n,e){if(n===e)return true;if(!!n!=!!e)return false;if(!ct(n)||!ct(e))return n===e;let t=n,i=e,s=0,r=0,o;for(o in t)s++;for(o in i)r++;if(s!==r)return false;for(o in t){let a=t[o],c=i[o];if(Vt(a)&&Vt(c)){if(!zi(a,c))return false}else if(ct(a)&&ct(c)){if(!ki(a,c))return false}else if(a!==c)return false}return true}function Vt(n){return Array.isArray(n)||ArrayBuffer.isView(n)}var Lr="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",Dr=999,Fr=6,Pi=new Set,Ur=function(){let n="";for(let e=0;e<Fr;e++)n+=Lr.charAt(Math.floor(Math.random()*42));return n},Br=function(){for(let n=0;n<Dr;n++){let e=Ur();if(!Pi.has(e))return Pi.add(e),e}return ""},Ge=n=>n,Vr=new Set,An=class extends wi{constructor(n,e=""){super(n),this[z].name=e,this.init(),this.dispatchEvent({type:"create"});}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(n,e){return Array.isArray(e)&&(e=e.slice()),super.set(n,e)}getName(){return this.get("name")}setName(n){return this.set("name",n)}getExtras(){return this.get("extras")}setExtras(n){return this.set("extras",n)}clone(){let n=this.constructor;return new n(this.graph).copy(this,Ge)}copy(n,e=Ge){for(let t in this[z]){let i=this[z][t];if(i instanceof Ue)this[Fe].has(t)||i.dispose();else if(i instanceof ne||i instanceof H)for(let s of i.values())s.dispose();else if(i instanceof $)for(let s of i.values())s.dispose();}for(let t in n[z]){let i=this[z][t],s=n[z][t];if(s instanceof Ue)this[Fe].has(t)?i.getChild().copy(e(s.getChild()),e):this.setRef(t,e(s.getChild()),s.getAttributes());else if(s instanceof H||s instanceof ne)for(let r of s.values())this.addRef(t,e(r.getChild()),r.getAttributes());else if(s instanceof $)for(let r of s.keys()){let o=s.get(r);this.setRefMap(t,r,e(o.getChild()),o.getAttributes());}else ct(s)?this[z][t]=JSON.parse(JSON.stringify(s)):Array.isArray(s)||s instanceof ArrayBuffer||ArrayBuffer.isView(s)?this[z][t]=s.slice():this[z][t]=s;}return this}equals(n,e=Vr){if(this===n)return true;if(this.propertyType!==n.propertyType)return false;for(let t in this[z]){if(e.has(t))continue;let i=this[z][t],s=n[z][t];if(i instanceof Ue||s instanceof Ue){if(!Nr(i,s))return false}else if(i instanceof H||s instanceof H||i instanceof ne||s instanceof ne){if(!Pr(i,s))return false}else if(i instanceof $||s instanceof $){if(!Or(i,s))return false}else if(ct(i)||ct(s)){if(!ki(i,s))return false}else if(Vt(i)||Vt(s)){if(!zi(i,s))return false}else if(i!==s)return false}return true}detach(){return this.graph.disconnectParents(this,n=>n.propertyType!=="Root"),this}listParents(){return this.graph.listParents(this)}},oe=class extends An{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new $})}getExtension(n){return this.getRefMap("extensions",n)}setExtension(n,e){return e&&e._validateParent(this),this.setRefMap("extensions",n,e)}listExtensions(){return this.listRefMapValues("extensions")}},C=class J extends oe{static Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"};static ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126,FLOAT16:5131,FLOAT64:5130};init(){this.propertyType="Accessor";}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:J.Type.SCALAR,componentType:J.ComponentType.FLOAT,normalized:false,sparse:false,buffer:null})}static getElementSize(e){switch(e){case J.Type.SCALAR:return 1;case J.Type.VEC2:return 2;case J.Type.VEC3:return 3;case J.Type.VEC4:return 4;case J.Type.MAT2:return 4;case J.Type.MAT3:return 9;case J.Type.MAT4:return 16;default:throw new Error("Unexpected type: "+e)}}static getComponentSize(e){switch(e){case J.ComponentType.BYTE:case J.ComponentType.UNSIGNED_BYTE:return 1;case J.ComponentType.SHORT:case J.ComponentType.UNSIGNED_SHORT:return 2;case J.ComponentType.UNSIGNED_INT:case J.ComponentType.FLOAT:return 4;case J.ComponentType.FLOAT16:return 2;case J.ComponentType.FLOAT64:return 8;default:throw new Error("Unexpected component type: "+e)}}getMinNormalized(e){let t=this.getNormalized(),i=this.getElementSize(),s=this.getComponentType();if(this.getMin(e),t)for(let r=0;r<i;r++)e[r]=X.decodeNormalizedInt(e[r],s);return e}getMin(e){let t=this.getArray(),i=this.getCount(),s=this.getElementSize();for(let r=0;r<s;r++)e[r]=1/0;for(let r=0;r<i*s;r+=s)for(let o=0;o<s;o++){let a=t[r+o];Number.isFinite(a)&&(e[o]=Math.min(e[o],a));}return e}getMaxNormalized(e){let t=this.getNormalized(),i=this.getElementSize(),s=this.getComponentType();if(this.getMax(e),t)for(let r=0;r<i;r++)e[r]=X.decodeNormalizedInt(e[r],s);return e}getMax(e){let t=this.get("array"),i=this.getCount(),s=this.getElementSize();for(let r=0;r<s;r++)e[r]=-1/0;for(let r=0;r<i*s;r+=s)for(let o=0;o<s;o++){let a=t[r+o];Number.isFinite(a)&&(e[o]=Math.max(e[o],a));}return e}getCount(){let 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 J.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){let t=this.getElementSize(),i=this.getComponentType(),s=this.getArray();return this.getNormalized()?X.decodeNormalizedInt(s[e*t],i):s[e*t]}setScalar(e,t){let i=this.getElementSize(),s=this.getComponentType(),r=this.getArray();return this.getNormalized()?r[e*i]=X.encodeNormalizedInt(t,s):r[e*i]=t,this}getElement(e,t){let i=this.getNormalized(),s=this.getElementSize(),r=this.getComponentType(),o=this.getArray();for(let a=0;a<s;a++)i?t[a]=X.decodeNormalizedInt(o[e*s+a],r):t[a]=o[e*s+a];return t}setElement(e,t){let i=this.getNormalized(),s=this.getElementSize(),r=this.getComponentType(),o=this.getArray();for(let a=0;a<s;a++)i?o[e*s+a]=X.encodeNormalizedInt(t[a],r):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?Gr(e):J.ComponentType.FLOAT),this.set("array",e),this}getByteLength(){let e=this.get("array");return e?e.byteLength:0}};function Gr(n){switch(n.constructor){case Float32Array:return C.ComponentType.FLOAT;case Uint32Array:return C.ComponentType.UNSIGNED_INT;case Uint16Array:return C.ComponentType.UNSIGNED_SHORT;case Uint8Array:return C.ComponentType.UNSIGNED_BYTE;case Int16Array:return C.ComponentType.SHORT;case Int8Array:return C.ComponentType.BYTE;case Float64Array:return C.ComponentType.FLOAT64}if(typeof Float16Array<"u"&&n.constructor===Float16Array)return C.ComponentType.FLOAT16;throw new Error("Unknown accessor componentType.")}var Hi=class extends oe{init(){this.propertyType="Animation";}getDefaults(){return Object.assign(super.getDefaults(),{channels:new H,samplers:new H})}addChannel(n){return this.addRef("channels",n)}removeChannel(n){return this.removeRef("channels",n)}listChannels(){return this.listRefs("channels")}addSampler(n){return this.addRef("samplers",n)}removeSampler(n){return this.removeRef("samplers",n)}listSamplers(){return this.listRefs("samplers")}},Rn=class extends oe{static TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};init(){this.propertyType="AnimationChannel";}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(n){return this.set("targetPath",n)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(n){return this.setRef("targetNode",n)}getSampler(){return this.getRef("sampler")}setSampler(n){return this.setRef("sampler",n)}},Ht=class Wi extends oe{static Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};init(){this.propertyType="AnimationSampler";}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:Wi.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:"OTHER"})}getOutput(){return this.getRef("output")}setOutput(e){return this.setRef("output",e,{usage:"OTHER"})}},Xi=class extends oe{init(){this.propertyType="Buffer";}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(n){return this.set("uri",n)}},Wt=class Ki extends oe{static Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};init(){this.propertyType="Camera";}getDefaults(){return Object.assign(super.getDefaults(),{type:Ki.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)}},F=class extends An{static EXTENSION_NAME;_validateParent(n){if(!this.parentTypes.includes(n.propertyType))throw new Error(`Parent "${n.propertyType}" invalid for child "${this.propertyType}".`)}},W=class bn extends oe{static WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497};static MagFilter={NEAREST:9728,LINEAR:9729};static MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};init(){this.propertyType="TextureInfo";}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:bn.WrapMode.REPEAT,wrapT:bn.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)}},{R:Lt,G:Dt,B:Ft,A:zr}=Se,Gt=class qi extends oe{static AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};init(){this.propertyType="Material";}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:qi.AlphaMode.OPAQUE,alphaCutoff:.5,doubleSided:false,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new W(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new W(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new W(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new W(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new W(this.graph,"metallicRoughnessTextureInfo")})}getDoubleSided(){return this.get("doubleSided")}setDoubleSided(e){return this.set("doubleSided",e)}getAlpha(){return this.get("baseColorFactor")[3]}setAlpha(e){let 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:Lt|Dt|Ft|zr,isColor:true})}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:Lt|Dt|Ft,isColor:true})}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:Lt|Dt|Ft})}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:Lt})}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:Dt|Ft})}},Yi=class extends oe{init(){this.propertyType="Mesh";}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new H})}addPrimitive(n){return this.addRef("primitives",n)}removePrimitive(n){return this.removeRef("primitives",n)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(n){return this.set("weights",n)}},ji=class extends oe{init(){this.propertyType="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 H})}copy(n,e=Ge){if(e===Ge)throw new Error("Node cannot be copied.");return super.copy(n,e)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(n){return this.set("translation",n)}setRotation(n){return this.set("rotation",n)}setScale(n){return this.set("scale",n)}getMatrix(){return X.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(n){let e=this.get("translation").slice(),t=this.get("rotation").slice(),i=this.get("scale").slice();return X.decompose(n,e,t,i),this.set("translation",e).set("rotation",t).set("scale",i)}getWorldTranslation(){let n=[0,0,0];return X.decompose(this.getWorldMatrix(),n,[0,0,0,1],[1,1,1]),n}getWorldRotation(){let n=[0,0,0,1];return X.decompose(this.getWorldMatrix(),[0,0,0],n,[1,1,1]),n}getWorldScale(){let n=[1,1,1];return X.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],n),n}getWorldMatrix(){let n=[];for(let i=this;i!=null;i=i.getParentNode())n.push(i);let e,t=n.pop().getMatrix();for(;e=n.pop();)wr(t,t,e.getMatrix());return t}addChild(n){let e=n.getParentNode();e&&e.removeChild(n);for(let t of n.listParents())t.propertyType==="Scene"&&t.removeChild(n);return this.addRef("children",n)}removeChild(n){return this.removeRef("children",n)}listChildren(){return this.listRefs("children")}getParentNode(){for(let n of this.listParents())if(n.propertyType==="Node")return n;return null}getMesh(){return this.getRef("mesh")}setMesh(n){return this.setRef("mesh",n)}getCamera(){return this.getRef("camera")}setCamera(n){return this.setRef("camera",n)}getSkin(){return this.getRef("skin")}setSkin(n){return this.setRef("skin",n)}getWeights(){return this.get("weights")}setWeights(n){return this.set("weights",n)}traverse(n){n(this);for(let e of this.listChildren())e.traverse(n);return this}},Tt=class $i extends oe{static Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};init(){this.propertyType="Primitive";}getDefaults(){return Object.assign(super.getDefaults(),{mode:$i.Mode.TRIANGLES,material:null,indices:null,attributes:new $,targets:new H})}getIndices(){return this.getRef("indices")}setIndices(e){return this.setRef("indices",e,{usage:"ELEMENT_ARRAY_BUFFER"})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:"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)}},kr=class extends An{init(){this.propertyType="PrimitiveTarget";}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new $})}getAttribute(n){return this.getRefMap("attributes",n)}setAttribute(n,e){return this.setRefMap("attributes",n,e,{usage:"ARRAY_BUFFER"})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},Ji=class extends oe{init(){this.propertyType="Scene";}getDefaults(){return Object.assign(super.getDefaults(),{children:new H})}copy(n,e=Ge){if(e===Ge)throw new Error("Scene cannot be copied.");return super.copy(n,e)}addChild(n){let e=n.getParentNode();return e&&e.removeChild(n),this.addRef("children",n)}removeChild(n){return this.removeRef("children",n)}listChildren(){return this.listRefs("children")}traverse(n){for(let e of this.listChildren())e.traverse(n);return this}},Zi=class extends oe{init(){this.propertyType="Skin";}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new H})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(n){return this.setRef("skeleton",n)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(n){return this.setRef("inverseBindMatrices",n,{usage:"INVERSE_BIND_MATRICES"})}addJoint(n){return this.addRef("joints",n)}removeJoint(n){return this.removeRef("joints",n)}listJoints(){return this.listRefs("joints")}},Qi=class extends oe{init(){this.propertyType="Texture";}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||Re.extensionToMimeType(lt.extension(this.get("uri")))}setMimeType(n){return this.set("mimeType",n)}getURI(){return this.get("uri")}setURI(n){this.set("uri",n);let e=Re.extensionToMimeType(lt.extension(n));return e&&this.set("mimeType",e),this}getImage(){return this.get("image")}setImage(n){return this.set("image",P.assertView(n))}getSize(){let n=this.get("image");return n?Re.getSize(n,this.getMimeType()):null}},wn=class extends oe{_extensions=new Set;init(){this.propertyType="Root";}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${Fi}`,version:"2.0"},defaultScene:null,accessors:new H,animations:new H,buffers:new H,cameras:new H,materials:new H,meshes:new H,nodes:new H,scenes:new H,skins:new H,textures:new H})}constructor(n){super(n),n.addEventListener("node:create",e=>{this._addChildOfRoot(e.target);});}clone(){throw new Error("Root cannot be cloned.")}copy(n,e=Ge){if(e===Ge)throw new Error("Root cannot be copied.");this.set("asset",{...n.get("asset")}),this.setName(n.getName()),this.setExtras({...n.getExtras()}),this.setDefaultScene(n.getDefaultScene()?e(n.getDefaultScene()):null);for(let t of n.listRefMapKeys("extensions")){let i=n.getExtension(t);this.setExtension(t,e(i));}return this}_addChildOfRoot(n){return n instanceof Ji?this.addRef("scenes",n):n instanceof ji?this.addRef("nodes",n):n instanceof Wt?this.addRef("cameras",n):n instanceof Zi?this.addRef("skins",n):n instanceof Yi?this.addRef("meshes",n):n instanceof Gt?this.addRef("materials",n):n instanceof Qi?this.addRef("textures",n):n instanceof Hi?this.addRef("animations",n):n instanceof C?this.addRef("accessors",n):n instanceof Xi&&this.addRef("buffers",n),this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter(n=>n.isRequired())}_enableExtension(n){return this._extensions.add(n),this}_disableExtension(n){return this._extensions.delete(n),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(n){return this.setRef("defaultScene",n)}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")}},Hr=class En{_graph=new vn;_root=new wn(this._graph);_logger=kt.DEFAULT_INSTANCE;static _GRAPH_DOCUMENTS=new WeakMap;static fromGraph(e){return En._GRAPH_DOCUMENTS.get(e)||null}constructor(){En._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){let t=e.map(i=>i.name);for(let i of e)await i(this,{stack:t});return this}hasExtension(e){return this.getRoot().listExtensionsUsed().some(t=>t.extensionName===e)}createExtension(e){let t=e.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(i=>i.extensionName===t)||new e(this)}disposeExtension(e){let t=this.getRoot().listExtensionsUsed().find(i=>i.extensionName===e);t&&t.dispose();}createScene(e=""){return new Ji(this._graph,e)}createNode(e=""){return new ji(this._graph,e)}createCamera(e=""){return new Wt(this._graph,e)}createSkin(e=""){return new Zi(this._graph,e)}createMesh(e=""){return new Yi(this._graph,e)}createPrimitive(){return new Tt(this._graph)}createPrimitiveTarget(e=""){return new kr(this._graph,e)}createMaterial(e=""){return new Gt(this._graph,e)}createTexture(e=""){return new Qi(this._graph,e)}createAnimation(e=""){return new Hi(this._graph,e)}createAnimationChannel(e=""){return new Rn(this._graph,e)}createAnimationSampler(e=""){return new Ht(this._graph,e)}createAccessor(e="",t=null){return t||(t=this.getRoot().listBuffers()[0]),new C(this._graph,e).setBuffer(t)}createBuffer(e=""){return new Xi(this._graph,e)}},k=class{static EXTENSION_NAME;extensionName="";prereadTypes=[];prewriteTypes=[];readDependencies=[];writeDependencies=[];document;required=false;properties=new Set;_listener;constructor(n){this.document=n,n.getRoot()._enableExtension(this),this._listener=t=>{let i=t,s=i.target;s instanceof F&&s.extensionName===this.extensionName&&(i.type==="node:create"&&this._addExtensionProperty(s),i.type==="node:dispose"&&this._removeExtensionProperty(s));};let e=n.getGraph();e.addEventListener("node:create",this._listener),e.addEventListener("node:dispose",this._listener);}dispose(){this.document.getRoot()._disableExtension(this);let n=this.document.getGraph();n.removeEventListener("node:create",this._listener),n.removeEventListener("node:dispose",this._listener);for(let e of this.properties)e.dispose();}static register(){}isRequired(){return this.required}setRequired(n){return this.required=n,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(n){return this.properties.add(n),this}_removeExtensionProperty(n){return this.properties.delete(n),this}install(n,e){return this}preread(n,e){return this}prewrite(n,e){return this}},Wr=class{jsonDoc;buffers=[];bufferViews=[];bufferViewBuffers=[];accessors=[];textures=[];textureInfos=new Map;materials=[];meshes=[];cameras=[];nodes=[];skins=[];animations=[];scenes=[];constructor(n){this.jsonDoc=n;}setTextureInfo(n,e){this.textureInfos.set(n,e),e.texCoord!==void 0&&n.setTexCoord(e.texCoord),e.extras!==void 0&&n.setExtras(e.extras);let t=this.jsonDoc.json.textures[e.index];if(t.sampler===void 0)return;let i=this.jsonDoc.json.samplers[t.sampler];i.magFilter!==void 0&&n.setMagFilter(i.magFilter),i.minFilter!==void 0&&n.setMinFilter(i.minFilter),i.wrapS!==void 0&&n.setWrapS(i.wrapS),i.wrapT!==void 0&&n.setWrapT(i.wrapT);}},Oi={logger:kt.DEFAULT_INSTANCE,extensions:[],dependencies:{}},Xr=new Set(["Buffer","Texture","Material","Mesh","Primitive","Node","Scene"]),Kr=class{static read(n,e=Oi){let t={...Oi,...e},{json:i}=n,s=new Hr().setLogger(t.logger);this.validate(n,t);let r=new Wr(n),o=i.asset,a=s.getRoot().getAsset();o.copyright&&(a.copyright=o.copyright),o.extras&&(a.extras=o.extras),i.extras!==void 0&&s.getRoot().setExtras({...i.extras});let c=i.extensionsUsed||[],l=i.extensionsRequired||[];t.extensions.sort((h,x)=>h.EXTENSION_NAME>x.EXTENSION_NAME?1:-1);for(let h of t.extensions)if(c.includes(h.EXTENSION_NAME)){let x=s.createExtension(h).setRequired(l.includes(h.EXTENSION_NAME)),g=x.prereadTypes.filter(y=>!Xr.has(y));g.length&&t.logger.warn(`Preread hooks for some types (${g.join()}), requested by extension ${x.extensionName}, are unsupported. Please file an issue or a PR.`);for(let y of x.readDependencies)x.install(y,t.dependencies[y]);}let u=i.buffers||[];s.getRoot().listExtensionsUsed().filter(h=>h.prereadTypes.includes("Buffer")).forEach(h=>h.preread(r,"Buffer")),r.buffers=u.map(h=>{let x=s.createBuffer(h.name);return h.extras&&x.setExtras(h.extras),h.uri&&h.uri.indexOf("__")!==0&&x.setURI(h.uri),x}),r.bufferViewBuffers=(i.bufferViews||[]).map((h,x)=>{if(!r.bufferViews[x]){let g=n.json.buffers[h.buffer],y=g.uri?n.resources[g.uri]:n.resources[Ve],M=h.byteOffset||0;r.bufferViews[x]=P.toView(y,M,h.byteLength);}return r.buffers[h.buffer]});let d=i.accessors||[];r.accessors=d.map(h=>{let x=r.bufferViewBuffers[h.bufferView],g=s.createAccessor(h.name,x).setType(h.type);return h.extras&&g.setExtras(h.extras),h.normalized!==void 0&&g.setNormalized(h.normalized),h.bufferView===void 0||g.setArray(Bt(h,r)),g});let m=i.images||[],p=i.textures||[];s.getRoot().listExtensionsUsed().filter(h=>h.prereadTypes.includes("Texture")).forEach(h=>h.preread(r,"Texture")),r.textures=m.map(h=>{let x=s.createTexture(h.name);if(h.extras&&x.setExtras(h.extras),h.bufferView!==void 0){let g=i.bufferViews[h.bufferView],y=n.json.buffers[g.buffer],M=y.uri?n.resources[y.uri]:n.resources[Ve],S=g.byteOffset||0,b=g.byteLength,A=M.slice(S,S+b);x.setImage(A);}else h.uri!==void 0&&(x.setImage(n.resources[h.uri]),h.uri.indexOf("__")!==0&&x.setURI(h.uri));if(h.mimeType!==void 0)x.setMimeType(h.mimeType);else if(h.uri){let g=lt.extension(h.uri);x.setMimeType(Re.extensionToMimeType(g));}return x}),s.getRoot().listExtensionsUsed().filter(h=>h.prereadTypes.includes("Material")).forEach(h=>h.preread(r,"Material")),r.materials=(i.materials||[]).map(h=>{let x=s.createMaterial(h.name);h.extras&&x.setExtras(h.extras),h.alphaMode!==void 0&&x.setAlphaMode(h.alphaMode),h.alphaCutoff!==void 0&&x.setAlphaCutoff(h.alphaCutoff),h.doubleSided!==void 0&&x.setDoubleSided(h.doubleSided);let g=h.pbrMetallicRoughness||{};if(g.baseColorFactor!==void 0&&x.setBaseColorFactor(g.baseColorFactor),h.emissiveFactor!==void 0&&x.setEmissiveFactor(h.emissiveFactor),g.metallicFactor!==void 0&&x.setMetallicFactor(g.metallicFactor),g.roughnessFactor!==void 0&&x.setRoughnessFactor(g.roughnessFactor),g.baseColorTexture!==void 0){let y=g.baseColorTexture,M=r.textures[p[y.index].source];x.setBaseColorTexture(M),r.setTextureInfo(x.getBaseColorTextureInfo(),y);}if(h.emissiveTexture!==void 0){let y=h.emissiveTexture,M=r.textures[p[y.index].source];x.setEmissiveTexture(M),r.setTextureInfo(x.getEmissiveTextureInfo(),y);}if(h.normalTexture!==void 0){let y=h.normalTexture,M=r.textures[p[y.index].source];x.setNormalTexture(M),r.setTextureInfo(x.getNormalTextureInfo(),y),h.normalTexture.scale!==void 0&&x.setNormalScale(h.normalTexture.scale);}if(h.occlusionTexture!==void 0){let y=h.occlusionTexture,M=r.textures[p[y.index].source];x.setOcclusionTexture(M),r.setTextureInfo(x.getOcclusionTextureInfo(),y),h.occlusionTexture.strength!==void 0&&x.setOcclusionStrength(h.occlusionTexture.strength);}if(g.metallicRoughnessTexture!==void 0){let y=g.metallicRoughnessTexture,M=r.textures[p[y.index].source];x.setMetallicRoughnessTexture(M),r.setTextureInfo(x.getMetallicRoughnessTextureInfo(),y);}return x}),s.getRoot().listExtensionsUsed().filter(h=>h.prereadTypes.includes("Mesh")).forEach(h=>h.preread(r,"Mesh"));let _=i.meshes||[];s.getRoot().listExtensionsUsed().filter(h=>h.prereadTypes.includes("Primitive")).forEach(h=>h.preread(r,"Primitive")),r.meshes=_.map(h=>{let x=s.createMesh(h.name);return h.extras&&x.setExtras(h.extras),h.weights!==void 0&&x.setWeights(h.weights),(h.primitives||[]).forEach(g=>{let y=s.createPrimitive();g.extras&&y.setExtras(g.extras),g.material!==void 0&&y.setMaterial(r.materials[g.material]),g.mode!==void 0&&y.setMode(g.mode);for(let[S,b]of Object.entries(g.attributes||{}))y.setAttribute(S,r.accessors[b]);g.indices!==void 0&&y.setIndices(r.accessors[g.indices]);let M=h.extras&&h.extras.targetNames||[];(g.targets||[]).forEach((S,b)=>{let A=M[b]||b.toString(),w=s.createPrimitiveTarget(A);for(let[R,U]of Object.entries(S))w.setAttribute(R,r.accessors[U]);y.addTarget(w);}),x.addPrimitive(y);}),x}),r.cameras=(i.cameras||[]).map(h=>{let x=s.createCamera(h.name).setType(h.type);if(h.extras&&x.setExtras(h.extras),h.type===Wt.Type.PERSPECTIVE){let g=h.perspective;x.setYFov(g.yfov),x.setZNear(g.znear),g.zfar!==void 0&&x.setZFar(g.zfar),g.aspectRatio!==void 0&&x.setAspectRatio(g.aspectRatio);}else {let g=h.orthographic;x.setZNear(g.znear).setZFar(g.zfar).setXMag(g.xmag).setYMag(g.ymag);}return x});let f=i.nodes||[];s.getRoot().listExtensionsUsed().filter(h=>h.prereadTypes.includes("Node")).forEach(h=>h.preread(r,"Node")),r.nodes=f.map(h=>{let x=s.createNode(h.name);if(h.extras&&x.setExtras(h.extras),h.translation!==void 0&&x.setTranslation(h.translation),h.rotation!==void 0&&x.setRotation(h.rotation),h.scale!==void 0&&x.setScale(h.scale),h.matrix!==void 0){let g=[0,0,0],y=[0,0,0,1],M=[1,1,1];X.decompose(h.matrix,g,y,M),x.setTranslation(g),x.setRotation(y),x.setScale(M);}return h.weights!==void 0&&x.setWeights(h.weights),x}),r.skins=(i.skins||[]).map(h=>{let x=s.createSkin(h.name);h.extras&&x.setExtras(h.extras),h.inverseBindMatrices!==void 0&&x.setInverseBindMatrices(r.accessors[h.inverseBindMatrices]),h.skeleton!==void 0&&x.setSkeleton(r.nodes[h.skeleton]);for(let g of h.joints)x.addJoint(r.nodes[g]);return x}),f.map((h,x)=>{let g=r.nodes[x];(h.children||[]).forEach(y=>g.addChild(r.nodes[y])),h.mesh!==void 0&&g.setMesh(r.meshes[h.mesh]),h.camera!==void 0&&g.setCamera(r.cameras[h.camera]),h.skin!==void 0&&g.setSkin(r.skins[h.skin]);}),r.animations=(i.animations||[]).map(h=>{let x=s.createAnimation(h.name);h.extras&&x.setExtras(h.extras);let g=(h.samplers||[]).map(y=>{let M=s.createAnimationSampler().setInput(r.accessors[y.input]).setOutput(r.accessors[y.output]).setInterpolation(y.interpolation||Ht.Interpolation.LINEAR);return y.extras&&M.setExtras(y.extras),x.addSampler(M),M});return (h.channels||[]).forEach(y=>{let M=s.createAnimationChannel().setSampler(g[y.sampler]).setTargetPath(y.target.path);y.target.node!==void 0&&M.setTargetNode(r.nodes[y.target.node]),y.extras&&M.setExtras(y.extras),x.addChannel(M);}),x});let v=i.scenes||[];return s.getRoot().listExtensionsUsed().filter(h=>h.prereadTypes.includes("Scene")).forEach(h=>h.preread(r,"Scene")),r.scenes=v.map(h=>{let x=s.createScene(h.name);return h.extras&&x.setExtras(h.extras),(h.nodes||[]).map(g=>r.nodes[g]).forEach(g=>x.addChild(g)),x}),i.scene!==void 0&&s.getRoot().setDefaultScene(r.scenes[i.scene]),s.getRoot().listExtensionsUsed().forEach(h=>h.read(r)),d.forEach((h,x)=>{let g=r.accessors[x],y=!!h.sparse,M=!h.bufferView&&!g.getArray();(y||M)&&g.setSparse(true).setArray(Yr(h,r));}),s}static validate(n,e){let t=n.json;if(t.asset.version!=="2.0")throw new Error(`Unsupported glTF version, "${t.asset.version}".`);if(t.extensionsRequired){for(let i of t.extensionsRequired)if(!e.extensions.find(s=>s.EXTENSION_NAME===i))throw new Error(`Missing required extension, "${i}".`)}if(t.extensionsUsed)for(let i of t.extensionsUsed)e.extensions.find(s=>s.EXTENSION_NAME===i)||e.logger.warn(`Missing optional extension, "${i}".`);}};function qr(n,e){let t=e.jsonDoc,i=e.bufferViews[n.bufferView],s=t.json.bufferViews[n.bufferView],r=zt[n.componentType],o=C.getElementSize(n.type),a=r.BYTES_PER_ELEMENT,c=n.byteOffset||0,l=new r(n.count*o),u=new DataView(i.buffer,i.byteOffset,i.byteLength),d=s.byteStride;for(let m=0;m<n.count;m++)for(let p=0;p<o;p++){let _=c+m*d+p*a,f;switch(n.componentType){case C.ComponentType.FLOAT:f=u.getFloat32(_,true);break;case C.ComponentType.UNSIGNED_INT:f=u.getUint32(_,true);break;case C.ComponentType.UNSIGNED_SHORT:f=u.getUint16(_,true);break;case C.ComponentType.UNSIGNED_BYTE:f=u.getUint8(_);break;case C.ComponentType.SHORT:f=u.getInt16(_,true);break;case C.ComponentType.BYTE:f=u.getInt8(_);break;case C.ComponentType.FLOAT16:f=u.getFloat16(_,true);break;case C.ComponentType.FLOAT64:f=u.getFloat64(_,true);break;default:throw new Error(`Unexpected componentType "${n.componentType}".`)}l[m*o+p]=f;}return l}function Bt(n,e){let t=e.jsonDoc,i=e.bufferViews[n.bufferView],s=t.json.bufferViews[n.bufferView],r=zt[n.componentType],o=C.getElementSize(n.type),a=r.BYTES_PER_ELEMENT,c=o*a;if(s.byteStride!==void 0&&s.byteStride!==c)return qr(n,e);let l=i.byteOffset+(n.byteOffset||0),u=n.count*o*a;return new r(i.buffer.slice(l,l+u))}function Yr(n,e){let t=zt[n.componentType],i=C.getElementSize(n.type),s;n.bufferView!==void 0?s=Bt(n,e):s=new t(n.count*i);let r=n.sparse;if(!r)return s;let o=r.count,a={...n,...r.indices,count:o,type:"SCALAR"},c={...n,...r.values,count:o},l=Bt(a,e),u=Bt(c,e);for(let d=0;d<a.count;d++)for(let m=0;m<i;m++)s[l[d]*i+m]=u[d*i+m];return s}var es=(function(n){return n[n.ARRAY_BUFFER=34962]="ARRAY_BUFFER",n[n.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER",n})(es||{}),Be=class{_doc;jsonDoc;options;static BufferViewTarget=es;static BufferViewUsage=xr;static USAGE_TO_TARGET={ARRAY_BUFFER:34962,ELEMENT_ARRAY_BUFFER:34963};accessorIndexMap=new Map;animationIndexMap=new Map;bufferIndexMap=new Map;cameraIndexMap=new Map;skinIndexMap=new Map;materialIndexMap=new Map;meshIndexMap=new Map;nodeIndexMap=new Map;imageIndexMap=new Map;textureDefIndexMap=new Map;textureInfoDefMap=new Map;samplerDefIndexMap=new Map;sceneIndexMap=new Map;imageBufferViews=[];otherBufferViews=new Map;otherBufferViewsIndexMap=new Map;extensionData={};bufferURIGenerator;imageURIGenerator;logger;_accessorUsageMap=new Map;accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]);accessorParents=new Map;constructor(n,e,t){this._doc=n,this.jsonDoc=e,this.options=t;let i=n.getRoot(),s=i.listBuffers().length,r=i.listTextures().length;this.bufferURIGenerator=new Li(s>1,()=>t.basename||"buffer"),this.imageURIGenerator=new Li(r>1,o=>jr(n,o)||t.basename||"texture"),this.logger=n.getLogger();}createTextureInfoDef(n,e){let t={magFilter:e.getMagFilter()||void 0,minFilter:e.getMinFilter()||void 0,wrapS:e.getWrapS(),wrapT:e.getWrapT()},i=JSON.stringify(t);this.samplerDefIndexMap.has(i)||(this.samplerDefIndexMap.set(i,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(t));let s={source:this.imageIndexMap.get(n),sampler:this.samplerDefIndexMap.get(i)},r=JSON.stringify(s);this.textureDefIndexMap.has(r)||(this.textureDefIndexMap.set(r,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(s));let o={index:this.textureDefIndexMap.get(r)};return e.getTexCoord()!==0&&(o.texCoord=e.getTexCoord()),Object.keys(e.getExtras()).length>0&&(o.extras=e.getExtras()),this.textureInfoDefMap.set(e,o),o}createPropertyDef(n){let e={};return n.getName()&&(e.name=n.getName()),Object.keys(n.getExtras()).length>0&&(e.extras=n.getExtras()),e}createAccessorDef(n){let e=this.createPropertyDef(n);return e.type=n.getType(),e.componentType=n.getComponentType(),e.count=n.getCount(),this._doc.getGraph().listParentEdges(n).some(t=>t.getName()==="attributes"&&t.getAttributes().key==="POSITION"||t.getName()==="input")&&(e.max=n.getMax([]).map(Math.fround),e.min=n.getMin([]).map(Math.fround)),n.getNormalized()&&(e.normalized=n.getNormalized()),e}createImageData(n,e,t){if(this.options.format==="GLB")this.imageBufferViews.push(e),n.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:e.byteLength});else {let i=Re.mimeTypeToExtension(t.getMimeType());n.uri=this.imageURIGenerator.createURI(t,i),this.assignResourceURI(n.uri,e,false);}}assignResourceURI(n,e,t){let i=this.jsonDoc.resources;if(!(n in i)){i[n]=e;return}if(e===i[n]){this.logger.warn(`Duplicate resource URI, "${n}".`);return}let s=`Resource URI "${n}" already assigned to different data.`;if(!t){this.logger.warn(s);return}throw new Error(s)}getAccessorUsage(n){let e=this._accessorUsageMap.get(n);if(e)return e;if(n.getSparse())return "SPARSE";for(let t of this._doc.getGraph().listParentEdges(n)){let{usage:i}=t.getAttributes();if(i)return i;t.getParent().propertyType!=="Root"&&this.logger.warn(`Missing attribute ".usage" on edge, "${t.getName()}".`);}return "OTHER"}addAccessorToUsageGroup(n,e){let t=this._accessorUsageMap.get(n);if(t&&t!==e)throw new Error(`Accessor with usage "${t}" cannot be reused as "${e}".`);return this._accessorUsageMap.set(n,e),this}},Li=class{multiple;basename;counter={};constructor(n,e){this.multiple=n,this.basename=e;}createURI(n,e){if(n.getURI())return n.getURI();if(this.multiple){let t=this.basename(n);return this.counter[t]=this.counter[t]||1,`${t}_${this.counter[t]++}.${e}`}else return `${this.basename(n)}.${e}`}};function jr(n,e){let t=n.getGraph().listParentEdges(e).find(i=>i.getParent()!==n.getRoot());return t?t.getName().replace(/texture$/i,""):""}var{BufferViewUsage:Ut}=Be,{UNSIGNED_INT:$r,UNSIGNED_SHORT:Jr,UNSIGNED_BYTE:Zr}=C.ComponentType,Qr=new Set(["Accessor","Buffer","Material","Mesh"]),eo=class{static write(n,e){let t=n.getGraph(),i=n.getRoot(),s={asset:{generator:`glTF-Transform ${Fi}`,...i.getAsset()},extras:{...i.getExtras()}},r={json:s,resources:{}},o=new Be(n,r,e),a=e.logger||kt.DEFAULT_INSTANCE,c=new Set(e.extensions.map(f=>f.EXTENSION_NAME)),l=n.getRoot().listExtensionsUsed().filter(f=>c.has(f.extensionName)).sort((f,v)=>f.extensionName>v.extensionName?1:-1),u=n.getRoot().listExtensionsRequired().filter(f=>c.has(f.extensionName)).sort((f,v)=>f.extensionName>v.extensionName?1:-1);l.length<n.getRoot().listExtensionsUsed().length&&a.warn("Some extensions were not registered for I/O, and will not be written.");for(let f of l){let v=f.prewriteTypes.filter(h=>!Qr.has(h));v.length&&a.warn(`Prewrite hooks for some types (${v.join()}), requested by extension ${f.extensionName}, are unsupported. Please file an issue or a PR.`);for(let h of f.writeDependencies)f.install(h,e.dependencies[h]);}function d(f,v,h,x){let g=[],y=0;for(let S of f){let b=o.createAccessorDef(S);b.bufferView=s.bufferViews.length;let A=S.getArray(),w=P.pad(P.toView(A));b.byteOffset=y,y+=w.byteLength,g.push(w),o.accessorIndexMap.set(S,s.accessors.length),s.accessors.push(b);}let M={buffer:v,byteOffset:h,byteLength:P.concat(g).byteLength};return x&&(M.target=x),s.bufferViews.push(M),{buffers:g,byteLength:y}}function m(f,v,h){let x=f[0].getCount(),g=0;for(let A of f){let w=o.createAccessorDef(A);w.bufferView=s.bufferViews.length,w.byteOffset=g;let R=A.getElementSize(),U=A.getComponentSize();g+=P.padNumber(R*U),o.accessorIndexMap.set(A,s.accessors.length),s.accessors.push(w);}let y=x*g,M=new ArrayBuffer(y),S=new DataView(M);for(let A=0;A<x;A++){let w=0;for(let R of f){let U=R.getElementSize(),G=R.getComponentSize(),I=R.getComponentType(),O=R.getArray();for(let D=0;D<U;D++){let Q=A*g+w+D*G,j=O[A*U+D];switch(I){case C.ComponentType.FLOAT:S.setFloat32(Q,j,true);break;case C.ComponentType.BYTE:S.setInt8(Q,j);break;case C.ComponentType.SHORT:S.setInt16(Q,j,true);break;case C.ComponentType.UNSIGNED_BYTE:S.setUint8(Q,j);break;case C.ComponentType.UNSIGNED_SHORT:S.setUint16(Q,j,true);break;case C.ComponentType.UNSIGNED_INT:S.setUint32(Q,j,true);break;case C.ComponentType.FLOAT16:S.setFloat16(Q,j,true);break;case C.ComponentType.FLOAT64:S.setFloat64(Q,j,true);break;default:throw new Error("Unexpected component type: "+I)}}w+=P.padNumber(U*G);}}let b={buffer:v,byteOffset:h,byteLength:y,byteStride:g,target:Be.BufferViewTarget.ARRAY_BUFFER};return s.bufferViews.push(b),{byteLength:y,buffers:[new Uint8Array(M)]}}function p(f,v,h){let x=[],g=0,y=new Map,M=-1/0,S=false;for(let I of f){let O=o.createAccessorDef(I);s.accessors.push(O),o.accessorIndexMap.set(I,s.accessors.length-1);let D=[],Q=[],j=[],we=new Array(I.getElementSize()).fill(0);for(let De=0,Pt=I.getCount();De<Pt;De++)if(I.getElement(De,j),!X.eq(j,we,0)){M=Math.max(De,M),D.push(De);for(let ht=0;ht<j.length;ht++)Q.push(j[ht]);}let Me=D.length,Ae={accessorDef:O,count:Me};if(y.set(I,Ae),Me===0)continue;Me>I.getCount()/2&&(S=true);let Ce=zt[I.getComponentType()];Ae.indices=D,Ae.values=new Ce(Q);}if(!Number.isFinite(M))return {buffers:x,byteLength:g};S&&a.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let b=M<255?Uint8Array:M<65535?Uint16Array:Uint32Array,A=M<255?Zr:M<65535?Jr:$r,w={buffer:v,byteOffset:h+g,byteLength:0};for(let I of f){let O=y.get(I);if(O.count===0)continue;O.indicesByteOffset=w.byteLength;let D=P.pad(P.toView(new b(O.indices)));x.push(D),g+=D.byteLength,w.byteLength+=D.byteLength;}s.bufferViews.push(w);let R=s.bufferViews.length-1,U={buffer:v,byteOffset:h+g,byteLength:0};for(let I of f){let O=y.get(I);if(O.count===0)continue;O.valuesByteOffset=U.byteLength;let D=P.pad(P.toView(O.values));x.push(D),g+=D.byteLength,U.byteLength+=D.byteLength;}s.bufferViews.push(U);let G=s.bufferViews.length-1;for(let I of f){let O=y.get(I);O.count!==0&&(O.accessorDef.sparse={count:O.count,indices:{bufferView:R,byteOffset:O.indicesByteOffset,componentType:A},values:{bufferView:G,byteOffset:O.valuesByteOffset}});}return {buffers:x,byteLength:g}}if(s.accessors=[],s.bufferViews=[],s.samplers=[],s.textures=[],s.images=i.listTextures().map((f,v)=>{let h=o.createPropertyDef(f);f.getMimeType()&&(h.mimeType=f.getMimeType());let x=f.getImage();return x&&o.createImageData(h,x,f),o.imageIndexMap.set(f,v),h}),l.filter(f=>f.prewriteTypes.includes("Accessor")).forEach(f=>f.prewrite(o,"Accessor")),i.listAccessors().forEach(f=>{let v=o.accessorUsageGroupedByParent,h=o.accessorParents;if(o.accessorIndexMap.has(f))return;let x=o.getAccessorUsage(f);if(o.addAccessorToUsageGroup(f,x),v.has(x)){let g=t.listParents(f).find(y=>y.propertyType!=="Root");h.set(f,g);}}),l.filter(f=>f.prewriteTypes.includes("Buffer")).forEach(f=>f.prewrite(o,"Buffer")),(i.listAccessors().length>0||o.otherBufferViews.size>0||i.listTextures().length>0&&e.format==="GLB")&&i.listBuffers().length===0)throw new Error("Buffer required for Document resources, but none was found.");s.buffers=[],i.listBuffers().forEach((f,v)=>{let h=o.createPropertyDef(f),x=o.accessorUsageGroupedByParent,g=f.listParents().filter(R=>R instanceof C),y=new Set(g.map(R=>o.accessorParents.get(R))),M=new Map(Array.from(y).map((R,U)=>[R,U])),S={};for(let R of g){if(o.accessorIndexMap.has(R))continue;let U=o.getAccessorUsage(R),G=U;if(x.has(U)){let I=o.accessorParents.get(R);G+=`:${M.get(I)}`;}S[G]||={usage:U,accessors:[]},S[G].accessors.push(R);}let b=[],A=s.buffers.length,w=0;for(let{usage:R,accessors:U}of Object.values(S))if(R===Ut.ARRAY_BUFFER&&e.vertexLayout==="interleaved"){let G=m(U,A,w);w+=G.byteLength;for(let I of G.buffers)b.push(I);}else if(R===Ut.ARRAY_BUFFER)for(let G of U){let I=m([G],A,w);w+=I.byteLength;for(let O of I.buffers)b.push(O);}else if(R===Ut.SPARSE){let G=p(U,A,w);w+=G.byteLength;for(let I of G.buffers)b.push(I);}else if(R===Ut.ELEMENT_ARRAY_BUFFER){let G=Be.BufferViewTarget.ELEMENT_ARRAY_BUFFER,I=d(U,A,w,G);w+=I.byteLength;for(let O of I.buffers)b.push(O);}else {let G=d(U,A,w);w+=G.byteLength;for(let I of G.buffers)b.push(I);}if(o.imageBufferViews.length&&v===0){for(let R=0;R<o.imageBufferViews.length;R++)if(s.bufferViews[s.images[R].bufferView].byteOffset=w,w+=o.imageBufferViews[R].byteLength,b.push(o.imageBufferViews[R]),w%8){let U=8-w%8;w+=U,b.push(new Uint8Array(U));}}if(o.otherBufferViews.has(f))for(let R of o.otherBufferViews.get(f))s.bufferViews.push({buffer:A,byteOffset:w,byteLength:R.byteLength}),o.otherBufferViewsIndexMap.set(R,s.bufferViews.length-1),w+=R.byteLength,b.push(R);if(w){let R;e.format==="GLB"?R=Ve:(R=o.bufferURIGenerator.createURI(f,"bin"),h.uri=R),h.byteLength=w,o.assignResourceURI(R,P.concat(b),true);}s.buffers.push(h),o.bufferIndexMap.set(f,v);}),i.listAccessors().find(f=>!f.getBuffer())&&a.warn("Skipped writing one or more Accessors: no Buffer assigned."),l.filter(f=>f.prewriteTypes.includes("Material")).forEach(f=>f.prewrite(o,"Material")),s.materials=i.listMaterials().map((f,v)=>{let h=o.createPropertyDef(f);if(f.getAlphaMode()!==Gt.AlphaMode.OPAQUE&&(h.alphaMode=f.getAlphaMode()),f.getAlphaMode()===Gt.AlphaMode.MASK&&(h.alphaCutoff=f.getAlphaCutoff()),f.getDoubleSided()&&(h.doubleSided=true),h.pbrMetallicRoughness={},X.eq(f.getBaseColorFactor(),[1,1,1,1])||(h.pbrMetallicRoughness.baseColorFactor=f.getBaseColorFactor()),X.eq(f.getEmissiveFactor(),[0,0,0])||(h.emissiveFactor=f.getEmissiveFactor()),f.getRoughnessFactor()!==1&&(h.pbrMetallicRoughness.roughnessFactor=f.getRoughnessFactor()),f.getMetallicFactor()!==1&&(h.pbrMetallicRoughness.metallicFactor=f.getMetallicFactor()),f.getBaseColorTexture()){let x=f.getBaseColorTexture(),g=f.getBaseColorTextureInfo();h.pbrMetallicRoughness.baseColorTexture=o.createTextureInfoDef(x,g);}if(f.getEmissiveTexture()){let x=f.getEmissiveTexture(),g=f.getEmissiveTextureInfo();h.emissiveTexture=o.createTextureInfoDef(x,g);}if(f.getNormalTexture()){let x=f.getNormalTexture(),g=f.getNormalTextureInfo(),y=o.createTextureInfoDef(x,g);f.getNormalScale()!==1&&(y.scale=f.getNormalScale()),h.normalTexture=y;}if(f.getOcclusionTexture()){let x=f.getOcclusionTexture(),g=f.getOcclusionTextureInfo(),y=o.createTextureInfoDef(x,g);f.getOcclusionStrength()!==1&&(y.strength=f.getOcclusionStrength()),h.occlusionTexture=y;}if(f.getMetallicRoughnessTexture()){let x=f.getMetallicRoughnessTexture(),g=f.getMetallicRoughnessTextureInfo();h.pbrMetallicRoughness.metallicRoughnessTexture=o.createTextureInfoDef(x,g);}return o.materialIndexMap.set(f,v),h}),l.filter(f=>f.prewriteTypes.includes("Mesh")).forEach(f=>f.prewrite(o,"Mesh")),s.meshes=i.listMeshes().map((f,v)=>{let h=o.createPropertyDef(f),x=null;return h.primitives=f.listPrimitives().map(g=>{let y={attributes:{}};y.mode=g.getMode();let M=g.getMaterial();M&&(y.material=o.materialIndexMap.get(M)),Object.keys(g.getExtras()).length&&(y.extras=g.getExtras());let S=g.getIndices();S&&(y.indices=o.accessorIndexMap.get(S));for(let b of g.listSemantics())y.attributes[b]=o.accessorIndexMap.get(g.getAttribute(b));for(let b of g.listTargets()){let A={};for(let w of b.listSemantics())A[w]=o.accessorIndexMap.get(b.getAttribute(w));y.targets=y.targets||[],y.targets.push(A);}return g.listTargets().length&&!x&&(x=g.listTargets().map(b=>b.getName())),y}),f.getWeights().length&&(h.weights=f.getWeights()),x&&(h.extras=h.extras||{},h.extras.targetNames=x),o.meshIndexMap.set(f,v),h}),s.cameras=i.listCameras().map((f,v)=>{let h=o.createPropertyDef(f);if(h.type=f.getType(),h.type===Wt.Type.PERSPECTIVE){h.perspective={znear:f.getZNear(),zfar:f.getZFar(),yfov:f.getYFov()};let x=f.getAspectRatio();x!==null&&(h.perspective.aspectRatio=x);}else h.orthographic={znear:f.getZNear(),zfar:f.getZFar(),xmag:f.getXMag(),ymag:f.getYMag()};return o.cameraIndexMap.set(f,v),h}),s.nodes=i.listNodes().map((f,v)=>{let h=o.createPropertyDef(f);return X.eq(f.getTranslation(),[0,0,0])||(h.translation=f.getTranslation()),X.eq(f.getRotation(),[0,0,0,1])||(h.rotation=f.getRotation()),X.eq(f.getScale(),[1,1,1])||(h.scale=f.getScale()),f.getWeights().length&&(h.weights=f.getWeights()),o.nodeIndexMap.set(f,v),h}),s.skins=i.listSkins().map((f,v)=>{let h=o.createPropertyDef(f),x=f.getInverseBindMatrices();x&&(h.inverseBindMatrices=o.accessorIndexMap.get(x));let g=f.getSkeleton();return g&&(h.skeleton=o.nodeIndexMap.get(g)),h.joints=f.listJoints().map(y=>o.nodeIndexMap.get(y)),o.skinIndexMap.set(f,v),h}),i.listNodes().forEach((f,v)=>{let h=s.nodes[v],x=f.getMesh();x&&(h.mesh=o.meshIndexMap.get(x));let g=f.getCamera();g&&(h.camera=o.cameraIndexMap.get(g));let y=f.getSkin();y&&(h.skin=o.skinIndexMap.get(y)),f.listChildren().length>0&&(h.children=f.listChildren().map(M=>o.nodeIndexMap.get(M)));}),s.animations=i.listAnimations().map((f,v)=>{let h=o.createPropertyDef(f),x=new Map;return h.samplers=f.listSamplers().map((g,y)=>{let M=o.createPropertyDef(g);return M.input=o.accessorIndexMap.get(g.getInput()),M.output=o.accessorIndexMap.get(g.getOutput()),M.interpolation=g.getInterpolation(),x.set(g,y),M}),h.channels=f.listChannels().map(g=>{let y=o.createPropertyDef(g);return y.sampler=x.get(g.getSampler()),y.target={node:o.nodeIndexMap.get(g.getTargetNode()),path:g.getTargetPath()},y}),o.animationIndexMap.set(f,v),h}),s.scenes=i.listScenes().map((f,v)=>{let h=o.createPropertyDef(f);return h.nodes=f.listChildren().map(x=>o.nodeIndexMap.get(x)),o.sceneIndexMap.set(f,v),h});let _=i.getDefaultScene();return _&&(s.scene=i.listScenes().indexOf(_)),s.extensionsUsed=l.map(f=>f.extensionName),s.extensionsRequired=u.map(f=>f.extensionName),l.forEach(f=>f.write(o)),to(s),r}};function to(n){let e=[];for(let t in n){let i=n[t];(Array.isArray(i)&&i.length===0||i===null||i===""||i&&typeof i=="object"&&Object.keys(i).length===0)&&e.push(t);}for(let t of e)delete n[t];}var no=class{_logger=kt.DEFAULT_INSTANCE;_extensions=new Set;_dependencies={};_vertexLayout="interleaved";_strictResources=true;lastReadBytes=0;lastWriteBytes=0;setLogger(n){return this._logger=n,this}registerExtensions(n){for(let e of n)this._extensions.add(e),e.register();return this}registerDependencies(n){return Object.assign(this._dependencies,n),this}setVertexLayout(n){return this._vertexLayout=n,this}setStrictResources(n){return this._strictResources=n,this}async read(n){return await this.readJSON(await this.readAsJSON(n))}async readAsJSON(n){let e=await this.readURI(n,"view");this.lastReadBytes=e.byteLength;let t=Di(e)?this._binaryToJSON(e):{json:JSON.parse(P.decodeText(e)),resources:{}};return await this._readResourcesExternal(t,this.dirname(n)),this._readResourcesInternal(t),t}async readJSON(n){return n=this._copyJSON(n),this._readResourcesInternal(n),Kr.read(n,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(n){let e=this._binaryToJSON(P.assertView(n));this._readResourcesInternal(e);let t=e.json;if(t.buffers&&t.buffers.some(i=>io(e,i)))throw new Error("Cannot resolve external buffers with binaryToJSON().");if(t.images&&t.images.some(i=>so(e,i)))throw new Error("Cannot resolve external images with binaryToJSON().");return e}async readBinary(n){return this.readJSON(await this.binaryToJSON(P.assertView(n)))}async writeJSON(n,e={}){if(e.format==="GLB"&&n.getRoot().listBuffers().length>1)throw new Error("GLB must have 0\u20131 buffers.");return eo.write(n,{format:e.format||"GLTF",basename:e.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,dependencies:{...this._dependencies},extensions:Array.from(this._extensions)})}async writeBinary(n){let{json:e,resources:t}=await this.writeJSON(n,{format:"GLB"}),i=new Uint32Array([1179937895,2,12]),s=JSON.stringify(e),r=P.pad(P.encodeText(s),32),o=P.toView(new Uint32Array([r.byteLength,1313821514])),a=P.concat([o,r]);i[i.length-1]+=a.byteLength;let c=Object.values(t)[0];if(!c||!c.byteLength)return P.concat([P.toView(i),a]);let l=P.pad(c,0),u=P.toView(new Uint32Array([l.byteLength,5130562])),d=P.concat([u,l]);return i[i.length-1]+=d.byteLength,P.concat([P.toView(i),a,d])}async _readResourcesExternal(n,e){let t=n.json.images||[],i=n.json.buffers||[],s=[...t,...i].map(async r=>{let o=r.uri;if(!o||o.match(/data:/))return Promise.resolve();try{n.resources[o]=await this.readURI(this.resolve(e,o),"view"),this.lastReadBytes+=n.resources[o].byteLength;}catch(a){if(!this._strictResources&&t.includes(r))this._logger.warn(`Failed to load image URI, "${o}". ${a}`),n.resources[o]=null;else throw a}});await Promise.all(s);}_readResourcesInternal(n){function e(t){if(t.uri){if(t.uri in n.resources){P.assertView(n.resources[t.uri]);return}if(t.uri.match(/data:/)){let i=`__${Br()}.${lt.extension(t.uri)}`;n.resources[i]=P.createBufferFromDataURI(t.uri),t.uri=i;}}}(n.json.images||[]).forEach(t=>{if(t.bufferView===void 0&&t.uri===void 0)throw new Error("Missing resource URI or buffer view.");e(t);}),(n.json.buffers||[]).forEach(e);}_copyJSON(n){let{images:e,buffers:t}=n.json;return n={json:{...n.json},resources:{...n.resources}},e&&(n.json.images=e.map(i=>({...i}))),t&&(n.json.buffers=t.map(i=>({...i}))),n}_binaryToJSON(n){if(!Di(n))throw new Error("Invalid glTF 2.0 binary.");let e=new Uint32Array(n.buffer,n.byteOffset+12,2);if(e[1]!==1313821514)throw new Error("Missing required GLB JSON chunk.");let t=20,i=e[0],s=P.decodeText(P.toView(n,t,i)),r=JSON.parse(s),o=t+i;if(n.byteLength<=o)return {json:r,resources:{}};let a=new Uint32Array(n.buffer,n.byteOffset+o,2);if(a[1]!==5130562)return {json:r,resources:{}};let c=a[0],l=P.toView(n,o+8,c);return {json:r,resources:{[Ve]:l}}}};function io(n,e){return e.uri!==void 0&&!(e.uri in n.resources)}function so(n,e){return e.uri!==void 0&&!(e.uri in n.resources)&&e.bufferView===void 0}function Di(n){if(n.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return false;let e=new Uint32Array(n.buffer,n.byteOffset,3);return e[0]===1179937895&&e[1]===2}var ts=class extends no{_fetch;_fetchConfig;_init;_fetchEnabled=false;constructor(n=null,e=Ie.DEFAULT_INIT){super(),this._fetch=n,this._fetchConfig=e,this._init=this.init();}async init(){return this._init?this._init:Promise.all([import('fs'),import('path')]).then(([n,e])=>{this._fs=n.promises,this._path=e;})}setAllowNetwork(n){if(n&&!this._fetch)throw new Error("NodeIO requires a Fetch API implementation for HTTP requests.");return this._fetchEnabled=n,this}async readURI(n,e){if(await this.init(),Ie.isAbsoluteURL(n)){if(!this._fetchEnabled||!this._fetch)throw new Error("Network request blocked. Allow HTTP requests explicitly, if needed.");let t=await this._fetch(n,this._fetchConfig);switch(e){case "view":return new Uint8Array(await t.arrayBuffer());case "text":return t.text()}}else switch(e){case "view":return this._fs.readFile(n);case "text":return this._fs.readFile(n,"utf8")}}resolve(n,e){return Ie.isAbsoluteURL(n)||Ie.isAbsoluteURL(e)?Ie.resolve(n,e):this._path.resolve(n,decodeURIComponent(e))}dirname(n){return Ie.isAbsoluteURL(n)?Ie.dirname(n):this._path.dirname(n)}async write(n,e){await this.init(),await(n.match(/\.glb$/)?this._writeGLB(n,e):this._writeGLTF(n,e));}async _writeGLTF(n,e){this.lastWriteBytes=0;let{json:t,resources:i}=await this.writeJSON(e,{format:"GLTF",basename:lt.basename(n)}),{_fs:s,_path:r}=this,o=r.dirname(n),a=JSON.stringify(t,null,2);await s.writeFile(n,a),this.lastWriteBytes+=a.length;for(let c of ro(Object.keys(i),10))await Promise.all(c.map(async l=>{if(Ie.isAbsoluteURL(l)){if(Ie.extension(l)==="bin")throw new Error(`Cannot write buffer to path "${l}".`);return}let u=r.join(o,decodeURIComponent(l));await s.mkdir(r.dirname(u),{recursive:true}),await s.writeFile(u,i[l]),this.lastWriteBytes+=i[l].byteLength;}));}async _writeGLB(n,e){let t=await this.writeBinary(e);await this._fs.writeFile(n,t),this.lastWriteBytes=t.byteLength;}};function ro(n,e){let t=[];for(let i=0,s=n.length;i<s;i+=e){let r=[];for(let o=0;o<e&&i+o<s;o++)r.push(n[i+o]);t.push(r);}return t}function oo(){return {vkFormat:0,typeSize:1,pixelWidth:0,pixelHeight:0,pixelDepth:0,layerCount:0,faceCount:1,levelCount:0,supercompressionScheme:0,levels:[],dataFormatDescriptor:[{vendorId:0,descriptorType:0,versionNumber:2,colorModel:0,colorPrimaries:1,transferFunction:2,flags:0,texelBlockDimension:[0,0,0,0],bytesPlane:[0,0,0,0,0,0,0,0],samples:[]}],keyValue:{},globalData:null}}var ut=class{constructor(e,t,i,s){this._dataView=void 0,this._littleEndian=void 0,this._offset=void 0,this._dataView=new DataView(e.buffer,e.byteOffset+t,i),this._littleEndian=s,this._offset=0;}_nextUint8(){let e=this._dataView.getUint8(this._offset);return this._offset+=1,e}_nextUint16(){let e=this._dataView.getUint16(this._offset,this._littleEndian);return this._offset+=2,e}_nextUint32(){let e=this._dataView.getUint32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint64(){let e=this._dataView.getUint32(this._offset,this._littleEndian),t=this._dataView.getUint32(this._offset+4,this._littleEndian),i=e+2**32*t;return this._offset+=8,i}_nextInt32(){let e=this._dataView.getInt32(this._offset,this._littleEndian);return this._offset+=4,e}_nextUint8Array(e){let t=new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+this._offset,e);return this._offset+=e,t}_skip(e){return this._offset+=e,this}_scan(e,t=0){let i=this._offset,s=0;for(;this._dataView.getUint8(this._offset)!==t&&s<e;)s++,this._offset++;return s<e&&this._offset++,new Uint8Array(this._dataView.buffer,this._dataView.byteOffset+i,s)}};var ae=[171,75,84,88,32,50,48,187,13,10,26,10];function ns(n){return new TextDecoder().decode(n)}function Xt(n){let e=new Uint8Array(n.buffer,n.byteOffset,ae.length);if(e[0]!==ae[0]||e[1]!==ae[1]||e[2]!==ae[2]||e[3]!==ae[3]||e[4]!==ae[4]||e[5]!==ae[5]||e[6]!==ae[6]||e[7]!==ae[7]||e[8]!==ae[8]||e[9]!==ae[9]||e[10]!==ae[10]||e[11]!==ae[11])throw new Error("Missing KTX 2.0 identifier.");let t=oo(),i=17*Uint32Array.BYTES_PER_ELEMENT,s=new ut(n,ae.length,i,true);t.vkFormat=s._nextUint32(),t.typeSize=s._nextUint32(),t.pixelWidth=s._nextUint32(),t.pixelHeight=s._nextUint32(),t.pixelDepth=s._nextUint32(),t.layerCount=s._nextUint32(),t.faceCount=s._nextUint32(),t.levelCount=s._nextUint32(),t.supercompressionScheme=s._nextUint32();let r=s._nextUint32(),o=s._nextUint32(),a=s._nextUint32(),c=s._nextUint32(),l=s._nextUint64(),u=s._nextUint64(),d=Math.max(t.levelCount,1)*3*8,m=new ut(n,ae.length+i,d,true);for(let le=0,he=Math.max(t.levelCount,1);le<he;le++)t.levels.push({levelData:new Uint8Array(n.buffer,n.byteOffset+m._nextUint64(),m._nextUint64()),uncompressedByteLength:m._nextUint64()});let p=new ut(n,r,o,true);p._skip(4);let _=p._nextUint16(),f=p._nextUint16(),v=p._nextUint16(),h=p._nextUint16(),x=p._nextUint8(),g=p._nextUint8(),y=p._nextUint8(),M=p._nextUint8(),S=[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],b=[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],w={vendorId:_,descriptorType:f,versionNumber:v,colorModel:x,colorPrimaries:g,transferFunction:y,flags:M,texelBlockDimension:S,bytesPlane:b,samples:[]},G=(h/4-6)/4;for(let le=0;le<G;le++){let he={bitOffset:p._nextUint16(),bitLength:p._nextUint8(),channelType:p._nextUint8(),samplePosition:[p._nextUint8(),p._nextUint8(),p._nextUint8(),p._nextUint8()],sampleLower:Number.NEGATIVE_INFINITY,sampleUpper:Number.POSITIVE_INFINITY};he.channelType&64?(he.sampleLower=p._nextInt32(),he.sampleUpper=p._nextInt32()):(he.sampleLower=p._nextUint32(),he.sampleUpper=p._nextUint32()),w.samples[le]=he;}t.dataFormatDescriptor.length=0,t.dataFormatDescriptor.push(w);let I=new ut(n,a,c,true);for(;I._offset<c;){let le=I._nextUint32(),he=I._scan(le),Ot=ns(he);if(t.keyValue[Ot]=I._nextUint8Array(le-he.byteLength-1),Ot.match(/^ktx/i)){let Ei=ns(t.keyValue[Ot]);t.keyValue[Ot]=Ei.substring(0,Ei.lastIndexOf("\0"));}let mr=le%4?4-le%4:0;I._skip(mr);}if(u<=0)return t;let O=new ut(n,l,u,true),D=O._nextUint16(),Q=O._nextUint16(),j=O._nextUint32(),we=O._nextUint32(),Me=O._nextUint32(),Ae=O._nextUint32(),Ce=[];for(let le=0,he=Math.max(t.levelCount,1);le<he;le++)Ce.push({imageFlags:O._nextUint32(),rgbSliceByteOffset:O._nextUint32(),rgbSliceByteLength:O._nextUint32(),alphaSliceByteOffset:O._nextUint32(),alphaSliceByteLength:O._nextUint32()});let De=l+O._offset,Pt=De+j,ht=Pt+we,ur=ht+Me,hr=new Uint8Array(n.buffer,n.byteOffset+De,j),fr=new Uint8Array(n.buffer,n.byteOffset+Pt,we),dr=new Uint8Array(n.buffer,n.byteOffset+ht,Me),pr=new Uint8Array(n.buffer,n.byteOffset+ur,Ae);return t.globalData={endpointCount:D,selectorCount:Q,imageDescs:Ce,endpointsData:hr,selectorsData:fr,tablesData:dr,extendedData:pr},t}var ze="EXT_mesh_gpu_instancing",Pe="EXT_mesh_features",ue="EXT_meshopt_compression",N="EXT_structural_metadata",Kt="EXT_texture_webp",qt="EXT_texture_avif",fo="KHR_accessor_float16",po="KHR_accessor_float64",Y="KHR_draco_mesh_compression",Ne="KHR_lights_punctual",ke="KHR_materials_anisotropy",He="KHR_materials_clearcoat",We="KHR_materials_diffuse_transmission",Xe="KHR_materials_dispersion",Ke="KHR_materials_emissive_strength",qe="KHR_materials_ior",Ye="KHR_materials_iridescence",je="KHR_materials_pbrSpecularGlossiness",$e="KHR_materials_sheen",Je="KHR_materials_specular",Ze="KHR_materials_transmission",ft="KHR_materials_unlit",Qe="KHR_materials_volume",fe="KHR_materials_variants",is="KHR_mesh_primitive_restart",ss="KHR_mesh_quantization",et="KHR_node_visibility",Yt="KHR_texture_basisu",tt="KHR_texture_transform",Te="KHR_xmp_json_ld",mo=class extends F{static EXTENSION_NAME=Pe;init(){this.extensionName=Pe,this.propertyType="FeatureID",this.parentTypes=["Features"];}getDefaults(){return Object.assign(super.getDefaults(),{nullFeatureId:null,label:"",attribute:null,texture:null,propertyTable:null})}getFeatureCount(){return this.get("featureCount")}setFeatureCount(n){return this.set("featureCount",n)}getNullFeatureID(){return this.get("nullFeatureId")}setNullFeatureID(n){return this.set("nullFeatureId",n)}getLabel(){return this.get("label")}setLabel(n){return this.set("label",n)}getAttribute(){return this.get("attribute")}setAttribute(n){return this.set("attribute",n)}getTexture(){return this.getRef("texture")}setTexture(n){return this.setRef("texture",n)}getPropertyTable(){return this.getRef("propertyTable")}setPropertyTable(n){return this.setRef("propertyTable",n)}},go=class extends F{static EXTENSION_NAME=Pe;init(){this.extensionName=Pe,this.propertyType="FeatureIDTexture",this.parentTypes=["FeatureID"];}getDefaults(){let n=new W(this.graph,"textureInfo");return n.setMinFilter(W.MagFilter.NEAREST),n.setMagFilter(W.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:n})}getChannels(){return this.get("channels")}setChannels(n){return this.set("channels",n)}getTexture(){return this.getRef("texture")}setTexture(n){return this.setRef("texture",n)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}},_o=class extends F{static EXTENSION_NAME=Pe;init(){this.extensionName=Pe,this.propertyType="Features",this.parentTypes=[T.PRIMITIVE];}getDefaults(){return Object.assign(super.getDefaults(),{featureIds:new H([])})}listFeatureIDs(){return this.listRefs("featureIds")}addFeatureID(n){return this.addRef("featureIds",n)}removeFeatureID(n){return this.removeRef("featureIds",n)}},bt=Pe,xo=class extends k{extensionName=Pe;static EXTENSION_NAME=Pe;createFeatures(){return new _o(this.document.getGraph())}createFeatureID(){return new mo(this.document.getGraph())}createFeatureIDTexture(){return new go(this.document.getGraph())}read(n){return (n.jsonDoc.json.meshes||[]).forEach((e,t)=>{(e.primitives||[]).forEach((i,s)=>{this._readPrimitive(n,t,i,s);});}),this}_readPrimitive(n,e,t,i){if(!t.extensions||!t.extensions[bt])return;let s=this.createFeatures(),r=t.extensions[bt];for(let o of r.featureIds){let a=yo(this.document,this,n,o);s.addFeatureID(a);}n.meshes[e].listPrimitives()[i].setExtension(bt,s);}write(n){let e=n.jsonDoc.json.meshes;if(!e)return this;for(let t of this.document.getRoot().listMeshes()){let i=e[n.meshIndexMap.get(t)];t.listPrimitives().forEach((s,r)=>{let o=i.primitives[r];this._writePrimitive(n,s,o);});}return this}_writePrimitive(n,e,t){let i=e.getExtension(bt);if(!i)return;let s={featureIds:[]};i.listFeatureIDs().forEach(r=>{s.featureIds.push(Mo(this.document,n,r));}),t.extensions=t.extensions||{},t.extensions[bt]=s;}};function yo(n,e,t,i){let s=e.createFeatureID().setFeatureCount(i.featureCount);i.nullFeatureId!==void 0&&s.setNullFeatureID(i.nullFeatureId),i.label!==void 0&&s.setLabel(i.label),i.attribute!==void 0&&s.setAttribute(i.attribute);let r=i.texture;if(r!==void 0){let o=vo(e,t,r);s.setTexture(o);}if(i.propertyTable!==void 0){let o=n.getRoot().getExtension(N).listPropertyTables();s.setPropertyTable(o[i.propertyTable]);}return s}function vo(n,e,t){let i=n.createFeatureIDTexture(),{json:s}=e.jsonDoc;if(t.channels&&i.setChannels(t.channels),t.index!==void 0){let r=s.textures[t.index].source;i.setTexture(e.textures[r]),e.setTextureInfo(i.getTextureInfo(),t);}return i}function Mo(n,e,t){let i=n.getRoot(),s={featureCount:t.getFeatureCount()};if(t.getNullFeatureID()!=null&&(s.nullFeatureId=t.getNullFeatureID()),t.getLabel()&&(s.label=t.getLabel()),t.getAttribute()!=null&&(s.attribute=t.getAttribute()),t.getTexture()){let r=t.getTexture(),o=r.getTexture(),a=r.getTextureInfo();s.texture=e.createTextureInfoDef(o,a);let c=r.getChannels();X.eq(c,[0])||(s.texture.channels=c);}if(t.getPropertyTable()){let r=i.getExtension(N),o=t.getPropertyTable();s.propertyTable=r.listPropertyTables().indexOf(o);}return s}var Nn="INSTANCE_ATTRIBUTE",So=class extends F{static EXTENSION_NAME=ze;init(){this.extensionName=ze,this.propertyType="InstancedMesh",this.parentTypes=[T.NODE];}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new $})}getAttribute(n){return this.getRefMap("attributes",n)}setAttribute(n,e){return this.setRefMap("attributes",n,e,{usage:Nn})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}},To=class extends k{static EXTENSION_NAME=ze;extensionName=ze;prewriteTypes=[T.ACCESSOR];createInstancedMesh(){return new So(this.document.getGraph())}read(n){return (n.jsonDoc.json.nodes||[]).forEach((e,t)=>{if(!e.extensions||!e.extensions.EXT_mesh_gpu_instancing)return;let i=e.extensions[ze],s=this.createInstancedMesh();for(let r in i.attributes)s.setAttribute(r,n.accessors[i.attributes[r]]);n.nodes[t].setExtension(ze,s);}),this}prewrite(n){n.accessorUsageGroupedByParent.add(Nn);for(let e of this.properties)for(let t of e.listAttributes())n.addAccessorToUsageGroup(t,Nn);return this}write(n){let e=n.jsonDoc;return this.document.getRoot().listNodes().forEach(t=>{let i=t.getExtension(ze);if(i){let s=n.nodeIndexMap.get(t),r=e.json.nodes[s],o={attributes:{}};i.listSemantics().forEach(a=>{let c=i.getAttribute(a);o.attributes[a]=n.accessorIndexMap.get(c);}),r.extensions=r.extensions||{},r.extensions[ze]=o;}}),this}},bo=(function(n){return n.QUANTIZE="quantize",n.FILTER="filter",n})({});function Eo(n){return !n.extensions||!n.extensions.EXT_meshopt_compression?false:!!n.extensions[ue].fallback}var{BYTE:Ao,SHORT:rs,FLOAT:Ro}=C.ComponentType,{encodeNormalizedInt:os,decodeNormalizedInt:Pn}=X;function wo(n,e,t,i){let{filter:s,bits:r}=i,o={array:n.getArray(),byteStride:n.getElementSize()*n.getComponentSize(),componentType:n.getComponentType(),normalized:n.getNormalized()};if(t!=="ATTRIBUTES")return o;if(s!=="NONE"){let a=n.getNormalized()?Co(n):new Float32Array(o.array);switch(s){case "EXPONENTIAL":o.byteStride=n.getElementSize()*4,o.componentType=Ro,o.normalized=false,o.array=e.encodeFilterExp(a,n.getCount(),o.byteStride,r);break;case "OCTAHEDRAL":o.byteStride=r>8?8:4,o.componentType=r>8?rs:Ao,o.normalized=true,a=n.getElementSize()===3?No(a):a,o.array=e.encodeFilterOct(a,n.getCount(),o.byteStride,r);break;case "QUATERNION":o.byteStride=8,o.componentType=rs,o.normalized=true,o.array=e.encodeFilterQuat(a,n.getCount(),o.byteStride,r);break;default:throw new Error("Invalid filter.")}o.min=n.getMin([]),o.max=n.getMax([]),n.getNormalized()&&(o.min=o.min.map(c=>Pn(c,n.getComponentType())),o.max=o.max.map(c=>Pn(c,n.getComponentType()))),o.normalized&&(o.min=o.min.map(c=>os(c,o.componentType)),o.max=o.max.map(c=>os(c,o.componentType)));}else o.byteStride%4&&(o.array=Io(o.array,n.getElementSize()),o.byteStride=o.array.byteLength/n.getCount());return o}function Co(n){let e=n.getComponentType(),t=n.getArray(),i=new Float32Array(t.length);for(let s=0;s<t.length;s++)i[s]=Pn(t[s],e);return i}function Io(n,e){let t=P.padNumber(n.BYTES_PER_ELEMENT*e)/n.BYTES_PER_ELEMENT,i=n.length/e,s=new n.constructor(i*t);for(let r=0;r*e<n.length;r++)for(let o=0;o<e;o++)s[r*t+o]=n[r*e+o];return s}function No(n){let e=new Float32Array(n.length*4/3);for(let t=0,i=n.length/3;t<i;t++)e[t*4]=n[t*3],e[t*4+1]=n[t*3+1],e[t*4+2]=n[t*3+2];return e}function Po(n,e){return e===Be.BufferViewUsage.ELEMENT_ARRAY_BUFFER?n.listParents().some(t=>t instanceof Tt&&t.getMode()===Tt.Mode.TRIANGLES)?"TRIANGLES":"INDICES":"ATTRIBUTES"}function Oo(n,e){let t=e.getGraph().listParentEdges(n).filter(i=>!(i.getParent()instanceof wn));for(let i of t){let s=i.getName(),r=i.getAttributes().key||"",o=i.getParent().propertyType===T.PRIMITIVE_TARGET;if(s==="indices")return {filter:"NONE"};if(s==="attributes"){if(r==="POSITION")return {filter:"NONE"};if(r==="TEXCOORD_0")return {filter:"NONE"};if(r.startsWith("JOINTS_"))return {filter:"NONE"};if(r.startsWith("WEIGHTS_"))return {filter:"NONE"};if(r==="NORMAL"||r==="TANGENT")return o?{filter:"NONE"}:{filter:"OCTAHEDRAL",bits:8}}if(s==="output"){let a=Ts(n);return a==="rotation"?{filter:"QUATERNION",bits:16}:a==="translation"?{filter:"EXPONENTIAL",bits:12}:a==="scale"?{filter:"EXPONENTIAL",bits:12}:{filter:"NONE"}}if(s==="input")return {filter:"NONE"};if(s==="inverseBindMatrices")return {filter:"NONE"}}return {filter:"NONE"}}function Ts(n){for(let e of n.listParents())if(e instanceof Ht){for(let t of e.listParents())if(t instanceof Rn)return t.getTargetPath()}return null}var as={method:"quantize"},Lo=class extends k{extensionName=ue;prereadTypes=[T.BUFFER,T.PRIMITIVE];prewriteTypes=[T.BUFFER,T.ACCESSOR];readDependencies=["meshopt.decoder"];writeDependencies=["meshopt.encoder"];static EXTENSION_NAME=ue;static EncoderMethod=bo;_decoder=null;_decoderFallbackBufferMap=new Map;_encoder=null;_encoderOptions=as;_encoderFallbackBuffer=null;_encoderBufferViews={};_encoderBufferViewData={};_encoderBufferViewAccessors={};install(n,e){return n==="meshopt.decoder"&&(this._decoder=e),n==="meshopt.encoder"&&(this._encoder=e),this}setEncoderOptions(n){return this._encoderOptions={...as,...n},this}preread(n,e){if(!this._decoder){if(!this.isRequired())return this;throw new Error(`[${ue}] Please install extension dependency, "meshopt.decoder".`)}if(!this._decoder.supported){if(!this.isRequired())return this;throw new Error(`[${ue}]: Missing WASM support.`)}return e===T.BUFFER?this._prereadBuffers(n):e===T.PRIMITIVE&&this._prereadPrimitives(n),this}_prereadBuffers(n){let e=n.jsonDoc;(e.json.bufferViews||[]).forEach((t,i)=>{if(!t.extensions||!t.extensions.EXT_meshopt_compression)return;let s=t.extensions[ue],r=s.byteOffset||0,o=s.byteLength||0,a=s.count,c=s.byteStride,l=new Uint8Array(a*c),u=e.json.buffers[s.buffer],d=u.uri?e.resources[u.uri]:e.resources[Ve],m=P.toView(d,r,o);this._decoder.decodeGltfBuffer(l,a,c,m,s.mode,s.filter),n.bufferViews[i]=l;});}_prereadPrimitives(n){let e=n.jsonDoc;(e.json.bufferViews||[]).forEach(t=>{if(!t.extensions||!t.extensions.EXT_meshopt_compression)return;let i=t.extensions[ue],s=n.buffers[i.buffer],r=n.buffers[t.buffer],o=e.json.buffers[t.buffer];Eo(o)&&this._decoderFallbackBufferMap.set(r,s);});}read(n){if(!this.isRequired())return this;for(let[e,t]of this._decoderFallbackBufferMap){for(let i of e.listParents())i instanceof C&&i.swap(e,t);e.dispose();}return this}prewrite(n,e){return e===T.ACCESSOR?this._prewriteAccessors(n):e===T.BUFFER&&this._prewriteBuffers(n),this}_prewriteAccessors(n){let e=n.jsonDoc.json,t=this._encoder,i=this._encoderOptions,s=this.document.getGraph(),r=this.document.createBuffer(),o=this.document.getRoot().listBuffers().indexOf(r),a=1,c=new Map,l=u=>{for(let d of s.listParents(u)){if(d.propertyType===T.ROOT)continue;let m=c.get(u);return m===void 0&&c.set(u,m=a++),m}return -1};this._encoderFallbackBuffer=r,this._encoderBufferViews={},this._encoderBufferViewData={},this._encoderBufferViewAccessors={};for(let u of this.document.getRoot().listAccessors()){if(Ts(u)==="weights"||u.getSparse())continue;let d=n.getAccessorUsage(u),m=n.accessorUsageGroupedByParent.has(d)?l(u):null,p=Po(u,d),_=i.method==="filter"?Oo(u,this.document):{filter:"NONE"},f=wo(u,t,p,_),{array:v,byteStride:h}=f,x=u.getBuffer();if(!x)throw new Error(`${ue}: Missing buffer for accessor.`);let g=this.document.getRoot().listBuffers().indexOf(x),y=[d,m,p,_.filter,h,g].join(":"),M=this._encoderBufferViews[y],S=this._encoderBufferViewData[y],b=this._encoderBufferViewAccessors[y];(!M||!S)&&(b=this._encoderBufferViewAccessors[y]=[],S=this._encoderBufferViewData[y]=[],M=this._encoderBufferViews[y]={buffer:o,target:Be.USAGE_TO_TARGET[d],byteOffset:0,byteLength:0,byteStride:d===Be.BufferViewUsage.ARRAY_BUFFER?h:void 0,extensions:{[ue]:{buffer:g,byteOffset:0,byteLength:0,mode:p,filter:_.filter!=="NONE"?_.filter:void 0,byteStride:h,count:0}}});let A=n.createAccessorDef(u);A.componentType=f.componentType,A.normalized=f.normalized,A.byteOffset=M.byteLength,A.min&&f.min&&(A.min=f.min),A.max&&f.max&&(A.max=f.max),n.accessorIndexMap.set(u,e.accessors.length),e.accessors.push(A),b.push(A),S.push(new Uint8Array(v.buffer,v.byteOffset,v.byteLength)),M.byteLength+=v.byteLength,M.extensions.EXT_meshopt_compression.count+=u.getCount();}}_prewriteBuffers(n){let e=this._encoder;for(let t in this._encoderBufferViews){let i=this._encoderBufferViews[t],s=this._encoderBufferViewData[t],r=this.document.getRoot().listBuffers()[i.extensions[ue].buffer],o=n.otherBufferViews.get(r)||[],{count:a,byteStride:c,mode:l}=i.extensions[ue],u=P.concat(s),d=e.encodeGltfBuffer(u,a,c,l),m=P.pad(d);i.extensions[ue].byteLength=d.byteLength,s.length=0,s.push(m),o.push(m),n.otherBufferViews.set(r,o);}}write(n){let e=0;for(let r in this._encoderBufferViews){let o=this._encoderBufferViews[r],a=this._encoderBufferViewData[r][0],c=n.otherBufferViewsIndexMap.get(a),l=this._encoderBufferViewAccessors[r];for(let p of l)p.bufferView=c;let u=n.jsonDoc.json.bufferViews[c],d=u.byteOffset||0;Object.assign(u,o),u.byteOffset=e;let m=u.extensions[ue];m.byteOffset=d,e+=P.padNumber(o.byteLength);}let t=this._encoderFallbackBuffer,i=n.bufferIndexMap.get(t),s=n.jsonDoc.json.buffers[i];return s.byteLength=e,s.extensions={[ue]:{fallback:true}},t.dispose(),this}},Do=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="StructuralMetadata",this.parentTypes=[T.ROOT];}getDefaults(){return Object.assign(super.getDefaults(),{schema:null,schemaUri:"",propertyTables:new ne,propertyTextures:new ne,propertyAttributes:new ne})}getSchema(){return this.getRef("schema")}setSchema(n){return this.setRef("schema",n)}getSchemaUri(){return this.get("schemaUri")}setSchemaUri(n){return this.set("schemaUri",n)}listPropertyTables(){return this.listRefs("propertyTables")}addPropertyTable(n){return this.addRef("propertyTables",n)}removePropertyTable(n){return this.removeRef("propertyTables",n)}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(n){return this.addRef("propertyTextures",n)}removePropertyTexture(n){return this.removeRef("propertyTextures",n)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(n){return this.addRef("propertyAttributes",n)}removePropertyAttribute(n){return this.removeRef("propertyAttributes",n)}},Fo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="Schema",this.parentTypes=["StructuralMetadata"];}getDefaults(){return Object.assign(super.getDefaults(),{description:"",version:"",classes:new $,enums:new $})}getId(){return this.get("id")}setId(n){return this.set("id",n)}getDescription(){return this.get("description")}setDescription(n){return this.set("description",n)}getVersion(){return this.get("version")}setVersion(n){return this.set("version",n)}setClass(n,e){return this.setRefMap("classes",n,e)}getClass(n){return this.getRefMap("classes",n)}listClassKeys(){return this.listRefMapKeys("classes")}listClassValues(){return this.listRefMapValues("classes")}setEnum(n,e){return this.setRefMap("enums",n,e)}getEnum(n){return this.getRefMap("enums",n)}listEnumKeys(){return this.listRefMapKeys("enums")}listEnumValues(){return this.listRefMapValues("enums")}},Uo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="Class",this.parentTypes=["Schema"];}getDefaults(){return Object.assign(super.getDefaults(),{description:"",properties:new $})}getDescription(){return this.get("description")}setDescription(n){return this.set("description",n)}setProperty(n,e){return this.setRefMap("properties",n,e)}getProperty(n){return this.getRefMap("properties",n)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},Bo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="ClassProperty",this.parentTypes=["Class"];}getDefaults(){return Object.assign(super.getDefaults(),{description:"",componentType:null,enumType:null,array:null,count:null,normalized:null,offset:null,scale:null,max:null,min:null,required:null,noData:null,default:null})}getDescription(){return this.get("description")}setDescription(n){return this.set("description",n)}getType(){return this.get("type")}setType(n){return this.set("type",n)}getComponentType(){return this.get("componentType")}setComponentType(n){return this.set("componentType",n)}getEnumType(){return this.get("enumType")}setEnumType(n){return this.set("enumType",n)}getArray(){return this.get("array")}setArray(n){return this.set("array",n)}getCount(){return this.get("count")}setCount(n){return this.set("count",n)}getNormalized(){return this.get("normalized")}setNormalized(n){return this.set("normalized",n)}getOffset(){return this.get("offset")}setOffset(n){return this.set("offset",n)}getScale(){return this.get("scale")}setScale(n){return this.set("scale",n)}getMax(){return this.get("max")}setMax(n){return this.set("max",n)}getMin(){return this.get("min")}setMin(n){return this.set("min",n)}getRequired(){return this.get("required")}setRequired(n){return this.set("required",n)}getNoData(){return this.get("noData")}setNoData(n){return this.set("noData",n)}getDefault(){return this.get("default")}setDefault(n){return this.set("default",n)}},Vo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="Enum",this.parentTypes=["Schema"];}getDefaults(){return Object.assign(super.getDefaults(),{description:"",valueType:"UINT16",values:new ne})}getDescription(){return this.get("description")}setDescription(n){return this.set("description",n)}getValueType(){return this.get("valueType")}setValueType(n){return this.set("valueType",n)}listValues(){return this.listRefs("values")}addEnumValue(n){return this.addRef("values",n)}removeEnumValue(n){return this.removeRef("values",n)}},Go=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="EnumValue",this.parentTypes=["Enum"];}getDefaults(){return Object.assign(super.getDefaults(),{description:null})}getDescription(){return this.get("description")}setDescription(n){return this.set("description",n)}getValue(){return this.get("value")}setValue(n){return this.set("value",n)}},zo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="PropertyTable",this.parentTypes=["StructuralMetadata"];}getDefaults(){return Object.assign(super.getDefaults(),{properties:new $})}getClass(){return this.get("class")}setClass(n){return this.set("class",n)}getCount(){return this.get("count")}setCount(n){return this.set("count",n)}setProperty(n,e){return this.setRefMap("properties",n,e)}getProperty(n){return this.getRefMap("properties",n)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},ko=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="PropertyTableProperty",this.parentTypes=["PropertyTable"];}getDefaults(){return Object.assign(super.getDefaults(),{arrayOffsets:null,stringOffsets:null,arrayOffsetType:null,stringOffsetType:null,offset:null,scale:null,max:null,min:null})}getValues(){return this.get("values")}setValues(n){return this.set("values",n)}getArrayOffsets(){return this.get("arrayOffsets")}setArrayOffsets(n){return this.set("arrayOffsets",n)}getStringOffsets(){return this.get("stringOffsets")}setStringOffsets(n){return this.set("stringOffsets",n)}getArrayOffsetType(){return this.get("arrayOffsetType")}setArrayOffsetType(n){return this.set("arrayOffsetType",n)}getStringOffsetType(){return this.get("stringOffsetType")}setStringOffsetType(n){return this.set("stringOffsetType",n)}getOffset(){return this.get("offset")}setOffset(n){return this.set("offset",n)}getScale(){return this.get("scale")}setScale(n){return this.set("scale",n)}getMax(){return this.get("max")}setMax(n){return this.set("max",n)}getMin(){return this.get("min")}setMin(n){return this.set("min",n)}},Ho=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="PropertyTexture",this.parentTypes=["StructuralMetadata"];}getDefaults(){return Object.assign(super.getDefaults(),{properties:new $})}getClass(){return this.get("class")}setClass(n){return this.set("class",n)}setProperty(n,e){return this.setRefMap("properties",n,e)}getProperty(n){return this.getRefMap("properties",n)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},Wo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="PropertyTextureProperty",this.parentTypes=["PropertyTexture"];}getDefaults(){let n=new W(this.graph,"textureInfo");return n.setMinFilter(W.MagFilter.NEAREST),n.setMagFilter(W.MagFilter.NEAREST),Object.assign(super.getDefaults(),{channels:[0],texture:null,textureInfo:n,offset:null,scale:null,max:null,min:null})}getChannels(){return this.get("channels")}setChannels(n){return this.set("channels",n)}getTexture(){return this.getRef("texture")}setTexture(n){return this.setRef("texture",n)}getTextureInfo(){return this.getRef("texture")?this.getRef("textureInfo"):null}getOffset(){return this.get("offset")}setOffset(n){return this.set("offset",n)}getScale(){return this.get("scale")}setScale(n){return this.set("scale",n)}getMax(){return this.get("max")}setMax(n){return this.set("max",n)}getMin(){return this.get("min")}setMin(n){return this.set("min",n)}},Xo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="PropertyAttribute",this.parentTypes=["StructuralMetadata"];}getDefaults(){return Object.assign(super.getDefaults(),{properties:new $})}getClass(){return this.get("class")}setClass(n){return this.set("class",n)}setProperty(n,e){return this.setRefMap("properties",n,e)}getProperty(n){return this.getRefMap("properties",n)}listPropertyKeys(){return this.listRefMapKeys("properties")}listPropertyValues(){return this.listRefMapValues("properties")}},Ko=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="PropertyAttributeProperty",this.parentTypes=["PropertyAttribute"];}getDefaults(){return Object.assign(super.getDefaults(),{offset:null,scale:null,max:null,min:null})}getAttribute(){return this.get("attribute")}setAttribute(n){return this.set("attribute",n)}getOffset(){return this.get("offset")}setOffset(n){return this.set("offset",n)}getScale(){return this.get("scale")}setScale(n){return this.set("scale",n)}getMax(){return this.get("max")}setMax(n){return this.set("max",n)}getMin(){return this.get("min")}setMin(n){return this.set("min",n)}},qo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="NodeStructuralMetadata",this.parentTypes=[T.NODE];}getDefaults(){return Object.assign(super.getDefaults(),{class:"",properties:{}})}getClass(){return this.get("class")}setClass(n){return this.set("class",n)}getProperties(){return this.get("properties")}setProperties(n){return this.set("properties",n)}},Yo=class extends F{static EXTENSION_NAME=N;init(){this.extensionName=N,this.propertyType="MeshPrimitiveStructuralMetadata",this.parentTypes=[T.PRIMITIVE];}getDefaults(){return Object.assign(super.getDefaults(),{propertyTextures:new ne,propertyAttributes:new ne})}listPropertyTextures(){return this.listRefs("propertyTextures")}addPropertyTexture(n){return this.addRef("propertyTextures",n)}removePropertyTexture(n){return this.removeRef("propertyTextures",n)}listPropertyAttributes(){return this.listRefs("propertyAttributes")}addPropertyAttribute(n){return this.addRef("propertyAttributes",n)}removePropertyAttribute(n){return this.removeRef("propertyAttributes",n)}},jo=class extends k{extensionName=N;static EXTENSION_NAME=N;prewriteTypes=[T.BUFFER];prereadTypes=[T.SCENE];createStructuralMetadata(){return new Do(this.document.getGraph())}createSchema(){return new Fo(this.document.getGraph())}createClass(){return new Uo(this.document.getGraph())}createClassProperty(){return new Bo(this.document.getGraph())}createEnum(){return new Vo(this.document.getGraph())}createEnumValue(){return new Go(this.document.getGraph())}createPropertyTable(){return new zo(this.document.getGraph())}createPropertyTableProperty(){return new ko(this.document.getGraph())}createPropertyTexture(){return new Ho(this.document.getGraph())}createPropertyTextureProperty(){return new Wo(this.document.getGraph())}createPropertyAttribute(){return new Xo(this.document.getGraph())}createPropertyAttributeProperty(){return new Ko(this.document.getGraph())}createNodeStructuralMetadata(){return new qo(this.document.getGraph())}createMeshPrimitiveStructuralMetadata(){return new Yo(this.document.getGraph())}read(n){return this}preread(n){let e=this.document.getRoot(),{json:t}=n.jsonDoc,i=t.extensions[N],s=$o(this,n,i);return e.setExtension(N,s),(t.meshes||[]).forEach((r,o)=>{let a=n.meshes[o].listPrimitives();(r.primitives||[]).forEach((c,l)=>{let u=a[l];this._readPrimitive(s,u,c);});}),(t.nodes||[]).forEach((r,o)=>{this._readNode(n.nodes[o],r);}),this}_readPrimitive(n,e,t){if(!t.extensions||!t.extensions.EXT_structural_metadata)return;let i=this.createMeshPrimitiveStructuralMetadata(),s=t.extensions[N],r=n.listPropertyTextures(),o=s.propertyTextures||[];for(let l of o){let u=r[l];i.addPropertyTexture(u);}let a=n.listPropertyAttributes(),c=s.propertyAttributes||[];for(let l of c){let u=a[l];i.addPropertyAttribute(u);}e.setExtension(N,i);}_readNode(n,e){if(!e.extensions||!e.extensions.EXT_structural_metadata)return;let t=e.extensions[N],i=this.createNodeStructuralMetadata().setClass(t.class).setProperties(t.properties);n.setExtension(N,i);}write(n){let e=this.document.getRoot(),t=e.getExtension(N);if(!t)return this;let i=n.jsonDoc.json,s=ca(n,t);i.extensions=i.extensions||{},i.extensions[N]=s;let r=e.listMeshes(),o=i.meshes;if(o)for(let l of r){let u=o[n.meshIndexMap.get(l)];l.listPrimitives().forEach((d,m)=>{let p=u.primitives[m];this._writePrimitive(t,d,p);});}let a=e.listNodes(),c=i.nodes;if(c)for(let l of a){let u=n.nodeIndexMap.get(l);this._writeNode(l,c[u]);}return this}_writePrimitive(n,e,t){let i=e.getExtension(N);if(!i)return;let s=n.listPropertyTextures(),r=n.listPropertyAttributes(),o,a,c=i.listPropertyTextures();if(c.length>0){o=[];for(let d of c){let m=s.indexOf(d);if(m>=0)o.push(m);else throw new Error(`${N}: Invalid property texture in mesh primitive`)}}let l=i.listPropertyAttributes();if(l.length>0){a=[];for(let d of l){let m=r.indexOf(d);if(m>=0)a.push(m);else throw new Error(`${N}: Invalid property attribute in mesh primitive`)}}let u={propertyTextures:o,propertyAttributes:a};t.extensions=t.extensions||{},t.extensions[N]=u;}_writeNode(n,e){let t=n.getExtension("EXT_structural_metadata");t&&(e.extensions=e.extensions||{},e.extensions[N]={class:t.getClass(),properties:t.getProperties()});}prewrite(n,e){return e===T.BUFFER&&this._prewriteBuffers(n),this}_prewriteBuffers(n){let e=this.document,t=e.getRoot().getExtension(N);n.jsonDoc.json.bufferViews||=[];for(let i of t.listPropertyTables())for(let s of i.listPropertyValues()){let r=va(e,n);r.push(s.getValues());let o=s.getArrayOffsets();o&&r.push(o);let a=s.getStringOffsets();a&&r.push(a);}}};function $o(n,e,t){let i=n.createStructuralMetadata();if(t.schema!==void 0){let a=Jo(n,t.schema);i.setSchema(a);}else if(t.schemaUri){let a=t.schemaUri;i.setSchemaUri(a);}let s=t.propertyTextures||[];for(let a of s){let c=na(n,e,a);i.addPropertyTexture(c);}let r=t.propertyTables||[];for(let a of r){let c=sa(n,e,a);i.addPropertyTable(c);}let o=t.propertyAttributes||[];for(let a of o){let c=oa(n,a);i.addPropertyAttribute(c);}return i}function Jo(n,e){let t=n.createSchema().setId(e.id);e.name!==void 0&&t.setName(e.name),e.description!==void 0&&t.setDescription(e.description),e.version!==void 0&&t.setVersion(e.version);let i=e.classes||{};for(let r of Object.keys(i)){let o=i[r];t.setClass(r,Zo(n,o));}let s=e.enums||{};for(let r of Object.keys(s))t.setEnum(r,ea(n,s[r]));return t}function Zo(n,e){let t=n.createClass();e.name!==void 0&&t.setName(e.name),e.description!==void 0&&t.setDescription(e.description);let i=e.properties||{};for(let s of Object.keys(i)){let r=Qo(n,i[s]);t.setProperty(s,r);}return t}function Qo(n,e){let t=n.createClassProperty().setType(e.type);return e.name!==void 0&&t.setName(e.name),e.description!==void 0&&t.setDescription(e.description),e.componentType!==void 0&&t.setComponentType(e.componentType),e.enumType!==void 0&&t.setEnumType(e.enumType),e.array!==void 0&&t.setArray(e.array),e.count!==void 0&&t.setCount(e.count),e.normalized!==void 0&&t.setNormalized(e.normalized),e.offset!==void 0&&t.setOffset(e.offset),e.scale!==void 0&&t.setScale(e.scale),e.max!==void 0&&t.setMax(e.max),e.min!==void 0&&t.setMin(e.min),e.required!==void 0&&t.setRequired(e.required),e.noData!==void 0&&t.setNoData(e.noData),e.default!==void 0&&t.setDefault(e.default),t}function ea(n,e){let t=n.createEnum();e.name!==void 0&&t.setName(e.name),e.description!==void 0&&t.setDescription(e.description),e.valueType!==void 0&&t.setValueType(e.valueType);let i=e.values||{};for(let s of i)t.addEnumValue(ta(n,s));return t}function ta(n,e){let t=n.createEnumValue();return e.name!==void 0&&t.setName(e.name),e.description!==void 0&&t.setDescription(e.description),e.value!==void 0&&t.setValue(e.value),t}function na(n,e,t){let i=n.createPropertyTexture();i.setClass(t.class),t.name!==void 0&&i.setName(t.name);let s=t.properties||{};for(let r of Object.keys(s)){let o=ia(n,e,s[r]);i.setProperty(r,o);}return i}function ia(n,e,t){let i=n.createPropertyTextureProperty(),s=e.jsonDoc.json.textures||[];t.channels&&i.setChannels(t.channels);let r=s[t.index].source;if(r!==void 0){let o=e.textures[r];i.setTexture(o);let a=i.getTextureInfo();a&&e.setTextureInfo(a,t);}return t.offset!==void 0&&i.setOffset(t.offset),t.scale!==void 0&&i.setScale(t.scale),t.max!==void 0&&i.setMax(t.max),t.min!==void 0&&i.setMin(t.min),i}function sa(n,e,t){let i=n.createPropertyTable().setClass(t.class).setCount(t.count);t.name!==void 0&&i.setName(t.name);let s=t.properties||{};for(let r of Object.keys(s)){let o=ra(n,e,s[r]);i.setProperty(r,o);}return i}function ra(n,e,t){let i=n.createPropertyTableProperty(),s=Cn(e,t.values);if(i.setValues(s),t.arrayOffsets!==void 0){let r=Cn(e,t.arrayOffsets);i.setArrayOffsets(r);}if(t.stringOffsets!==void 0){let r=Cn(e,t.stringOffsets);i.setStringOffsets(r);}return t.arrayOffsetType!==void 0&&i.setArrayOffsetType(t.arrayOffsetType),t.stringOffsetType!==void 0&&i.setStringOffsetType(t.stringOffsetType),t.offset!==void 0&&i.setOffset(t.offset),t.scale!==void 0&&i.setScale(t.scale),t.max!==void 0&&i.setMax(t.max),t.min!==void 0&&i.setMin(t.min),i}function oa(n,e){let t=n.createPropertyAttribute();t.setClass(e.class),e.name!==void 0&&t.setName(e.name);let i=e.properties||{};for(let s of Object.keys(i)){let r=aa(n,i[s]);t.setProperty(s,r);}return t}function aa(n,e){let t=n.createPropertyAttributeProperty();return t.setAttribute(e.attribute),e.offset!==void 0&&t.setOffset(e.offset),e.scale!==void 0&&t.setScale(e.scale),e.max!==void 0&&t.setMax(e.max),e.min!==void 0&&t.setMin(e.min),t}function ca(n,e){let t={},i=e.getSchema();i&&(t.schema=la(i));let s=e.getSchemaUri();s&&(t.schemaUri=s);let r=e.listPropertyTables();if(r.length>0){let c=[];for(let l of r){let u=pa(n,l);c.push(u);}t.propertyTables=c;}let o=e.listPropertyTextures();if(o.length>0){let c=[];for(let l of o){let u=xa(n,l);c.push(u);}t.propertyTextures=c;}let a=e.listPropertyAttributes();if(a.length>0){let c=[];for(let l of a){let u=ga(l);c.push(u);}t.propertyAttributes=c;}return t}function la(n){let e={id:n.getId()},t=n.listClassKeys();if(t.length>0){e.classes={};for(let s of t){let r=ua(n.getClass(s));e.classes[s]=r;}}let i=n.listEnumKeys();if(i.length>0){e.enums={};for(let s of i){let r=fa(n.getEnum(s));e.enums[s]=r;}}return n.getName()&&(e.name=n.getName()),n.getDescription()&&(e.description=n.getDescription()),n.getVersion()&&(e.version=n.getVersion()),e}function ua(n){let e={},t=n.listPropertyKeys();if(t.length>0){e.properties={};for(let i of t){let s=n.getProperty(i);e.properties[i]=ha(s);}}return n.getName()&&(e.name=n.getName()),n.getDescription()&&(e.description=n.getDescription()),e}function ha(n){let e={type:n.getType()};return n.getArray()&&(e.array=n.getArray()),n.getNormalized()&&(e.normalized=n.getNormalized()),n.getRequired()&&(e.required=n.getRequired()),n.getName()&&(e.name=n.getName()),n.getDescription()&&(e.description=n.getDescription()),n.getComponentType()!=null&&(e.componentType=n.getComponentType()),n.getEnumType()!=null&&(e.enumType=n.getEnumType()),n.getCount()!=null&&(e.count=n.getCount()),n.getOffset()!=null&&(e.offset=n.getOffset()),n.getScale()!=null&&(e.scale=n.getScale()),n.getMax()!=null&&(e.max=n.getMax()),n.getMin()!=null&&(e.min=n.getMin()),n.getNoData()!=null&&(e.noData=n.getNoData()),n.getDefault()!=null&&(e.default=n.getDefault()),e}function fa(n){let e={values:n.listValues().map(da)};return n.getName()&&(e.name=n.getName()),n.getDescription()&&(e.description=n.getDescription()),n.getValueType()!=="UINT16"&&(e.valueType=n.getValueType()),e}function da(n){let e={name:n.getName(),value:n.getValue()};return n.getDescription()&&(e.description=n.getDescription()),e}function pa(n,e){let t={class:e.getClass(),count:e.getCount()};e.getName()&&(t.name=e.getName());let i=e.listPropertyKeys();if(i.length>0){t.properties={};for(let s of i){let r=ma(n,e.getProperty(s));t.properties[s]=r;}}return t}function ma(n,e){let t=e.getValues(),i={values:n.otherBufferViewsIndexMap.get(t)};if(e.getArrayOffsets()){let s=e.getArrayOffsets();i.arrayOffsets=n.otherBufferViewsIndexMap.get(s);}if(e.getStringOffsets()){let s=e.getStringOffsets();i.stringOffsets=n.otherBufferViewsIndexMap.get(s);}return e.getArrayOffsetType()!=null&&(i.arrayOffsetType=e.getArrayOffsetType()),e.getStringOffsetType()!=null&&(i.stringOffsetType=e.getStringOffsetType()),e.getOffset()!=null&&(i.offset=e.getOffset()),e.getScale()!=null&&(i.scale=e.getScale()),e.getMax()!=null&&(i.max=e.getMax()),e.getMin()!=null&&(i.min=e.getMin()),i}function ga(n){let e={class:n.getClass()};n.getName()&&(e.name=n.getName());let t=n.listPropertyKeys();if(t.length>0){e.properties={};for(let i of t){let s=_a(n.getProperty(i));e.properties[i]=s;}}return e}function _a(n){let e={attribute:n.getAttribute()};return n.getOffset()!=null&&(e.offset=n.getOffset()),n.getScale()!=null&&(e.scale=n.getScale()),n.getMax()!=null&&(e.max=n.getMax()),n.getMin()!=null&&(e.min=n.getMin()),e}function xa(n,e){let t={class:e.getClass()};e.getName()&&(t.name=e.getName());let i=e.listPropertyKeys();if(i.length>0){t.properties={};for(let s of i){let r=ya(n,e.getProperty(s));t.properties[s]=r;}}return t}function ya(n,e){let t=e.getTexture(),i=e.getTextureInfo(),s=e.getChannels(),r=n.createTextureInfoDef(t,i);return X.eq(s,[0])||(r.channels=s),e.getOffset()!=null&&(r.offset=e.getOffset()),e.getScale()!=null&&(r.scale=e.getScale()),e.getMax()!=null&&(r.max=e.getMax()),e.getMin()!=null&&(r.min=e.getMin()),r}function Cn(n,e){let t=n.jsonDoc,i=t.json.buffers||[],s=(t.json.bufferViews||[])[e],r=i[s.buffer],o=r.uri?t.resources[r.uri]:t.resources[Ve],a=s.byteOffset||0,c=s.byteLength;return o.slice(a,a+c)}function va(n,e){let t=n.getRoot().listBuffers()[0],i=e.otherBufferViews.get(t);return i||(i=[],e.otherBufferViews.set(t,i)),i}var Ma=class{match(n){return n.length>=12&&P.decodeText(n.slice(4,12))==="ftypavif"}getSize(n){if(!this.match(n))return null;let e=new DataView(n.buffer,n.byteOffset,n.byteLength),t=cs(e,0);if(!t)return null;let i=t.end;for(;t=cs(e,i);)if(t.type==="meta")i=t.start+4;else if(t.type==="iprp"||t.type==="ipco")i=t.start;else {if(t.type==="ispe")return [e.getUint32(t.start+4),e.getUint32(t.start+8)];if(t.type==="mdat")break;i=t.end;}return null}getChannels(n){return 4}},Sa=class extends k{extensionName=qt;prereadTypes=[T.TEXTURE];static EXTENSION_NAME=qt;static register(){Re.registerFormat("image/avif",new Ma);}preread(n){return (n.jsonDoc.json.textures||[]).forEach(e=>{e.extensions&&e.extensions.EXT_texture_avif&&(e.source=e.extensions[qt].source);}),this}read(n){return this}write(n){let e=n.jsonDoc;return this.document.getRoot().listTextures().forEach(t=>{if(t.getMimeType()==="image/avif"){let i=n.imageIndexMap.get(t);(e.json.textures||[]).forEach(s=>{s.source===i&&(s.extensions=s.extensions||{},s.extensions[qt]={source:s.source},delete s.source);});}}),this}};function cs(n,e){if(n.byteLength<4+e)return null;let t=n.getUint32(e);return n.byteLength<t+e||t<8?null:{type:P.decodeText(new Uint8Array(n.buffer,n.byteOffset+e+4,4)),start:e+8,end:e+t}}var Ta=class{match(n){return n.length>=12&&n[8]===87&&n[9]===69&&n[10]===66&&n[11]===80}getSize(n){let e=P.decodeText(n.slice(0,4)),t=P.decodeText(n.slice(8,12));if(e!=="RIFF"||t!=="WEBP")return null;let i=new DataView(n.buffer,n.byteOffset),s=12;for(;s<i.byteLength;){let r=P.decodeText(new Uint8Array([i.getUint8(s),i.getUint8(s+1),i.getUint8(s+2),i.getUint8(s+3)])),o=i.getUint32(s+4,true);if(r==="VP8 ")return [i.getInt16(s+14,true)&16383,i.getInt16(s+16,true)&16383];if(r==="VP8L"){let a=i.getUint8(s+9),c=i.getUint8(s+10),l=i.getUint8(s+11),u=i.getUint8(s+12);return [1+((c&63)<<8|a),1+((u&15)<<10|l<<2|(c&192)>>6)]}s+=8+o+o%2;}return null}getChannels(n){return 4}},ba=class extends k{extensionName=Kt;prereadTypes=[T.TEXTURE];static EXTENSION_NAME=Kt;static register(){Re.registerFormat("image/webp",new Ta);}preread(n){return (n.jsonDoc.json.textures||[]).forEach(e=>{e.extensions&&e.extensions.EXT_texture_webp&&(e.source=e.extensions[Kt].source);}),this}read(n){return this}write(n){let e=n.jsonDoc;return this.document.getRoot().listTextures().forEach(t=>{if(t.getMimeType()==="image/webp"){let i=n.imageIndexMap.get(t);(e.json.textures||[]).forEach(s=>{s.source===i&&(s.extensions=s.extensions||{},s.extensions[Kt]={source:s.source},delete s.source);});}}),this}},ls=fo,Ea=class extends k{extensionName=ls;static EXTENSION_NAME=ls;read(n){return this}write(n){return this}},us=po,Aa=class extends k{extensionName=us;static EXTENSION_NAME=us;read(n){return this}write(n){return this}},Z,bs,Es;function Ra(n,e){let t=new Z.DecoderBuffer;try{if(t.Init(e,e.length),n.GetEncodedGeometryType(t)!==Z.TRIANGULAR_MESH)throw new Error(`[${Y}] Unknown geometry type.`);let i=new Z.Mesh;if(!n.DecodeBufferToMesh(t,i).ok()||i.ptr===0)throw new Error(`[${Y}] Decoding failure.`);return i}finally{Z.destroy(t);}}function wa(n,e){let t=e.num_faces()*3,i,s;if(e.num_points()<=65534){let r=t*Uint16Array.BYTES_PER_ELEMENT;i=Z._malloc(r),n.GetTrianglesUInt16Array(e,r,i),s=new Uint16Array(Z.HEAPU16.buffer,i,t).slice();}else {let r=t*Uint32Array.BYTES_PER_ELEMENT;i=Z._malloc(r),n.GetTrianglesUInt32Array(e,r,i),s=new Uint32Array(Z.HEAPU32.buffer,i,t).slice();}return Z._free(i),s}function Ca(n,e,t,i){let s=Es[i.componentType],r=bs[i.componentType],o=t.num_components(),a=e.num_points()*o,c=a*r.BYTES_PER_ELEMENT,l=Z._malloc(c);n.GetAttributeDataArrayForAllPoints(e,t,s,c,l);let u=new r(Z.HEAPF32.buffer,l,a).slice();return Z._free(l),u}function Ia(n){Z=n,bs={[C.ComponentType.FLOAT]:Float32Array,[C.ComponentType.UNSIGNED_INT]:Uint32Array,[C.ComponentType.UNSIGNED_SHORT]:Uint16Array,[C.ComponentType.UNSIGNED_BYTE]:Uint8Array,[C.ComponentType.SHORT]:Int16Array,[C.ComponentType.BYTE]:Int8Array},Es={[C.ComponentType.FLOAT]:Z.DT_FLOAT32,[C.ComponentType.UNSIGNED_INT]:Z.DT_UINT32,[C.ComponentType.UNSIGNED_SHORT]:Z.DT_UINT16,[C.ComponentType.UNSIGNED_BYTE]:Z.DT_UINT8,[C.ComponentType.SHORT]:Z.DT_INT16,[C.ComponentType.BYTE]:Z.DT_INT8};}var ge,Na=(function(n){return n[n.EDGEBREAKER=1]="EDGEBREAKER",n[n.SEQUENTIAL=0]="SEQUENTIAL",n})({}),As={POSITION:14,NORMAL:10,COLOR:8,TEX_COORD:12,GENERIC:12},hs={decodeSpeed:5,encodeSpeed:5,method:1,quantizationBits:As,quantizationVolume:"mesh"};function Pa(n){ge=n;}function Oa(n,e=hs){let t={...hs,...e};t.quantizationBits={...As,...e.quantizationBits};let i=new ge.MeshBuilder,s=new ge.Mesh,r=new ge.ExpertEncoder(s),o={},a=new ge.DracoInt8Array,c=n.listTargets().length>0,l=false;for(let f of n.listSemantics()){let v=n.getAttribute(f);if(v.getSparse()){l=true;continue}let h=La(f),x=Da(i,v.getComponentType(),s,ge[h],v.getCount(),v.getElementSize(),v.getArray());if(x===-1)throw new Error(`Error compressing "${f}" attribute.`);if(o[f]=x,t.quantizationVolume==="mesh"||f!=="POSITION")r.SetAttributeQuantization(x,t.quantizationBits[h]);else if(typeof t.quantizationVolume=="object"){let{quantizationVolume:g}=t,y=Math.max(g.max[0]-g.min[0],g.max[1]-g.min[1],g.max[2]-g.min[2]);r.SetAttributeExplicitQuantization(x,t.quantizationBits[h],v.getElementSize(),g.min,y);}else throw new Error("Invalid quantization volume state.")}let u=n.getIndices();if(!u)throw new On("Primitive must have indices.");i.AddFacesToMesh(s,u.getCount()/3,u.getArray()),r.SetSpeedOptions(t.encodeSpeed,t.decodeSpeed),r.SetTrackEncodedProperties(true),t.method===0||c||l?r.SetEncodingMethod(ge.MESH_SEQUENTIAL_ENCODING):r.SetEncodingMethod(ge.MESH_EDGEBREAKER_ENCODING);let d=r.EncodeToDracoBuffer(!(c||l),a);if(d<=0)throw new On("Error applying Draco compression.");let m=new Uint8Array(d);for(let f=0;f<d;++f)m[f]=a.GetValue(f);let p=r.GetNumberOfEncodedPoints(),_=r.GetNumberOfEncodedFaces()*3;return ge.destroy(a),ge.destroy(s),ge.destroy(i),ge.destroy(r),{numVertices:p,numIndices:_,data:m,attributeIDs:o}}function La(n){return n==="POSITION"?"POSITION":n==="NORMAL"?"NORMAL":n.startsWith("COLOR_")?"COLOR":n.startsWith("TEXCOORD_")?"TEX_COORD":"GENERIC"}function Da(n,e,t,i,s,r,o){switch(e){case C.ComponentType.UNSIGNED_BYTE:return n.AddUInt8Attribute(t,i,s,r,o);case C.ComponentType.BYTE:return n.AddInt8Attribute(t,i,s,r,o);case C.ComponentType.UNSIGNED_SHORT:return n.AddUInt16Attribute(t,i,s,r,o);case C.ComponentType.SHORT:return n.AddInt16Attribute(t,i,s,r,o);case C.ComponentType.UNSIGNED_INT:return n.AddUInt32Attribute(t,i,s,r,o);case C.ComponentType.FLOAT:return n.AddFloatAttribute(t,i,s,r,o);default:throw new Error(`Unexpected component type, "${e}".`)}}var On=class extends Error{},Fa=class extends k{extensionName=Y;prereadTypes=[T.PRIMITIVE];prewriteTypes=[T.ACCESSOR];readDependencies=["draco3d.decoder"];writeDependencies=["draco3d.encoder"];static EXTENSION_NAME=Y;static EncoderMethod=Na;_decoderModule=null;_encoderModule=null;_encoderOptions={};install(n,e){return n==="draco3d.decoder"&&(this._decoderModule=e,Ia(this._decoderModule)),n==="draco3d.encoder"&&(this._encoderModule=e,Pa(this._encoderModule)),this}setEncoderOptions(n){return this._encoderOptions=n,this}preread(n){if(!this._decoderModule)throw new Error(`[${Y}] Please install extension dependency, "draco3d.decoder".`);let e=this.document.getLogger(),t=n.jsonDoc,i=new Map;try{let s=t.json.meshes||[];for(let r of s)for(let o of r.primitives){if(!o.extensions||!o.extensions.KHR_draco_mesh_compression)continue;let a=o.extensions[Y],[c,l]=i.get(a.bufferView)||[];if(!l||!c){let u=t.json.bufferViews[a.bufferView],d=t.json.buffers[u.buffer],m=d.uri?t.resources[d.uri]:t.resources[Ve],p=u.byteOffset||0,_=u.byteLength,f=P.toView(m,p,_);c=new this._decoderModule.Decoder,l=Ra(c,f),i.set(a.bufferView,[c,l]),e.debug(`[${Y}] Decompressed ${f.byteLength} bytes.`);}for(let u in a.attributes){let d=n.jsonDoc.json.accessors[o.attributes[u]],m=c.GetAttributeByUniqueId(l,a.attributes[u]),p=Ca(c,l,m,d);n.accessors[o.attributes[u]].setArray(p);}o.indices!==void 0&&n.accessors[o.indices].setArray(wa(c,l));}}finally{for(let[s,r]of Array.from(i.values()))this._decoderModule.destroy(s),this._decoderModule.destroy(r);}return this}read(n){return this}prewrite(n,e){if(!this._encoderModule)throw new Error(`[${Y}] Please install extension dependency, "draco3d.encoder".`);let t=this.document.getLogger();t.debug(`[${Y}] Compression options: ${JSON.stringify(this._encoderOptions)}`);let i=Ua(this.document),s=new Map,r="mesh";this._encoderOptions.quantizationVolume==="scene"&&(this.document.getRoot().listScenes().length!==1?t.warn(`[${Y}]: quantizationVolume=scene requires exactly 1 scene.`):r=Bi(this.document.getRoot().listScenes().pop()));for(let o of Array.from(i.keys())){let a=i.get(o);if(!a)throw new Error("Unexpected primitive.");if(s.has(a)){s.set(a,s.get(a));continue}let c=o.getIndices(),l=n.jsonDoc.json.accessors,u;try{u=Oa(o,{...this._encoderOptions,quantizationVolume:r});}catch(p){if(p instanceof On){t.warn(`[${Y}]: ${p.message} Skipping primitive compression.`);continue}throw p}s.set(a,u);let d=n.createAccessorDef(c);d.count=u.numIndices,n.accessorIndexMap.set(c,l.length),l.push(d),u.numVertices>65534&&C.getComponentSize(d.componentType)<=2?d.componentType=C.ComponentType.UNSIGNED_INT:u.numVertices>254&&C.getComponentSize(d.componentType)<=1&&(d.componentType=C.ComponentType.UNSIGNED_SHORT);for(let p of o.listSemantics()){let _=o.getAttribute(p);if(u.attributeIDs[p]===void 0)continue;let f=n.createAccessorDef(_);f.count=u.numVertices,n.accessorIndexMap.set(_,l.length),l.push(f);}let m=o.getAttribute("POSITION").getBuffer()||this.document.getRoot().listBuffers()[0];n.otherBufferViews.has(m)||n.otherBufferViews.set(m,[]),n.otherBufferViews.get(m).push(u.data);}return t.debug(`[${Y}] Compressed ${i.size} primitives.`),n.extensionData[Y]={primitiveHashMap:i,primitiveEncodingMap:s},this}write(n){let e=n.extensionData[Y];for(let t of this.document.getRoot().listMeshes()){let i=n.jsonDoc.json.meshes[n.meshIndexMap.get(t)];for(let s=0;s<t.listPrimitives().length;s++){let r=t.listPrimitives()[s],o=i.primitives[s],a=e.primitiveHashMap.get(r);if(!a)continue;let c=e.primitiveEncodingMap.get(a);c&&(o.extensions=o.extensions||{},o.extensions[Y]={bufferView:n.otherBufferViewsIndexMap.get(c.data),attributes:c.attributeIDs});}}if(!e.primitiveHashMap.size){let t=n.jsonDoc.json;t.extensionsUsed=(t.extensionsUsed||[]).filter(i=>i!==Y),t.extensionsRequired=(t.extensionsRequired||[]).filter(i=>i!==Y);}return this}};function Ua(n){let e=n.getLogger(),t=new Set,i=new Set,s=0,r=0;for(let d of n.getRoot().listMeshes())for(let m of d.listPrimitives())m.getIndices()?m.getMode()!==Tt.Mode.TRIANGLES?(i.add(m),r++):t.add(m):(i.add(m),s++);s>0&&e.warn(`[${Y}] Skipping Draco compression of ${s} non-indexed primitives.`),r>0&&e.warn(`[${Y}] Skipping Draco compression of ${r} non-TRIANGLES primitives.`);let o=n.getRoot().listAccessors(),a=new Map;for(let d=0;d<o.length;d++)a.set(o[d],d);let c=new Map,l=new Set,u=new Map;for(let d of Array.from(t)){let m=fs(d,a);if(l.has(m)){u.set(d,m);continue}if(c.has(d.getIndices())){let p=d.getIndices(),_=p.clone();a.set(_,n.getRoot().listAccessors().length-1),d.swap(p,_);}for(let p of d.listAttributes())if(c.has(p)){let _=p.clone();a.set(_,n.getRoot().listAccessors().length-1),d.swap(p,_);}m=fs(d,a),l.add(m),u.set(d,m),c.set(d.getIndices(),m);for(let p of d.listAttributes())c.set(p,m);}for(let d of Array.from(c.keys())){let m=new Set(d.listParents().map(p=>p.propertyType));if(m.size!==2||!m.has(T.PRIMITIVE)||!m.has(T.ROOT))throw new Error(`[${Y}] Compressed accessors must only be used as indices or vertex attributes.`)}for(let d of Array.from(t)){let m=u.get(d),p=d.getIndices();if(c.get(p)!==m||d.listAttributes().some(_=>c.get(_)!==m))throw new Error(`[${Y}] Draco primitives must share all, or no, accessors.`)}for(let d of Array.from(i)){let m=d.getIndices();if(c.has(m)||d.listAttributes().some(p=>c.has(p)))throw new Error(`[${Y}] Accessor cannot be shared by compressed and uncompressed primitives.`)}return u}function fs(n,e){let t=[],i=n.getIndices();t.push(e.get(i));for(let s of n.listAttributes())t.push(e.get(s));return t.sort().join("|")}var ds=class Rs extends F{static EXTENSION_NAME=Ne;static Type={POINT:"point",SPOT:"spot",DIRECTIONAL:"directional"};init(){this.extensionName=Ne,this.propertyType="Light",this.parentTypes=[T.NODE];}getDefaults(){return Object.assign(super.getDefaults(),{color:[1,1,1],intensity:1,type:Rs.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)}},Ba=class extends k{extensionName=Ne;static EXTENSION_NAME=Ne;createLight(n=""){return new ds(this.document.getGraph(),n)}read(n){let e=n.jsonDoc;if(!e.json.extensions||!e.json.extensions.KHR_lights_punctual)return this;let t=(e.json.extensions.KHR_lights_punctual.lights||[]).map(i=>{let s=this.createLight().setName(i.name||"").setType(i.type);return i.extras&&s.setExtras(i.extras),i.color!==void 0&&s.setColor(i.color),i.intensity!==void 0&&s.setIntensity(i.intensity),i.range!==void 0&&s.setRange(i.range),i.spot?.innerConeAngle!==void 0&&s.setInnerConeAngle(i.spot.innerConeAngle),i.spot?.outerConeAngle!==void 0&&s.setOuterConeAngle(i.spot.outerConeAngle),s});return e.json.nodes.forEach((i,s)=>{if(!i.extensions||!i.extensions.KHR_lights_punctual)return;let r=i.extensions[Ne];n.nodes[s].setExtension(Ne,t[r.light]);}),this}write(n){let e=n.jsonDoc;if(this.properties.size===0)return this;let t=[],i=new Map;for(let s of this.properties){let r=s,o=n.createPropertyDef(s);o.type=r.getType(),X.eq(r.getColor(),[1,1,1])||(o.color=r.getColor()),r.getIntensity()!==1&&(o.intensity=r.getIntensity()),r.getRange()!=null&&(o.range=r.getRange()),r.getName()&&(o.name=r.getName()),r.getType()===ds.Type.SPOT&&(o.spot={innerConeAngle:r.getInnerConeAngle(),outerConeAngle:r.getOuterConeAngle()}),t.push(o),i.set(r,t.length-1);}return this.document.getRoot().listNodes().forEach(s=>{let r=s.getExtension(Ne);if(r){let o=n.nodeIndexMap.get(s),a=e.json.nodes[o];a.extensions=a.extensions||{},a.extensions[Ne]={light:i.get(r)};}}),e.json.extensions=e.json.extensions||{},e.json.extensions[Ne]={lights:t},this}},{R:Va,G:Ga,B:za}=Se,ka=class extends F{static EXTENSION_NAME=ke;init(){this.extensionName=ke,this.propertyType="Anisotropy",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{anisotropyStrength:0,anisotropyRotation:0,anisotropyTexture:null,anisotropyTextureInfo:new W(this.graph,"anisotropyTextureInfo")})}getAnisotropyStrength(){return this.get("anisotropyStrength")}setAnisotropyStrength(n){return this.set("anisotropyStrength",n)}getAnisotropyRotation(){return this.get("anisotropyRotation")}setAnisotropyRotation(n){return this.set("anisotropyRotation",n)}getAnisotropyTexture(){return this.getRef("anisotropyTexture")}getAnisotropyTextureInfo(){return this.getRef("anisotropyTexture")?this.getRef("anisotropyTextureInfo"):null}setAnisotropyTexture(n){return this.setRef("anisotropyTexture",n,{channels:Va|Ga|za})}},Ha=class extends k{static EXTENSION_NAME=ke;extensionName=ke;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createAnisotropy(){return new ka(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_anisotropy){let o=this.createAnisotropy();n.materials[r].setExtension(ke,o);let a=s.extensions[ke];if(a.extras&&o.setExtras(a.extras),a.anisotropyStrength!==void 0&&o.setAnisotropyStrength(a.anisotropyStrength),a.anisotropyRotation!==void 0&&o.setAnisotropyRotation(a.anisotropyRotation),a.anisotropyTexture!==void 0){let c=a.anisotropyTexture,l=n.textures[i[c.index].source];o.setAnisotropyTexture(l),n.setTextureInfo(o.getAnisotropyTextureInfo(),c);}}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(ke);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[ke]=o,i.getAnisotropyStrength()>0&&(o.anisotropyStrength=i.getAnisotropyStrength()),i.getAnisotropyRotation()!==0&&(o.anisotropyRotation=i.getAnisotropyRotation()),i.getAnisotropyTexture()){let a=i.getAnisotropyTexture(),c=i.getAnisotropyTextureInfo();o.anisotropyTexture=n.createTextureInfoDef(a,c);}}}),this}},{R:ps,G:ms,B:Wa}=Se,Xa=class extends F{static EXTENSION_NAME=He;init(){this.extensionName=He,this.propertyType="Clearcoat",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{clearcoatFactor:0,clearcoatTexture:null,clearcoatTextureInfo:new W(this.graph,"clearcoatTextureInfo"),clearcoatRoughnessFactor:0,clearcoatRoughnessTexture:null,clearcoatRoughnessTextureInfo:new W(this.graph,"clearcoatRoughnessTextureInfo"),clearcoatNormalScale:1,clearcoatNormalTexture:null,clearcoatNormalTextureInfo:new W(this.graph,"clearcoatNormalTextureInfo")})}getClearcoatFactor(){return this.get("clearcoatFactor")}setClearcoatFactor(n){return this.set("clearcoatFactor",n)}getClearcoatTexture(){return this.getRef("clearcoatTexture")}getClearcoatTextureInfo(){return this.getRef("clearcoatTexture")?this.getRef("clearcoatTextureInfo"):null}setClearcoatTexture(n){return this.setRef("clearcoatTexture",n,{channels:ps})}getClearcoatRoughnessFactor(){return this.get("clearcoatRoughnessFactor")}setClearcoatRoughnessFactor(n){return this.set("clearcoatRoughnessFactor",n)}getClearcoatRoughnessTexture(){return this.getRef("clearcoatRoughnessTexture")}getClearcoatRoughnessTextureInfo(){return this.getRef("clearcoatRoughnessTexture")?this.getRef("clearcoatRoughnessTextureInfo"):null}setClearcoatRoughnessTexture(n){return this.setRef("clearcoatRoughnessTexture",n,{channels:ms})}getClearcoatNormalScale(){return this.get("clearcoatNormalScale")}setClearcoatNormalScale(n){return this.set("clearcoatNormalScale",n)}getClearcoatNormalTexture(){return this.getRef("clearcoatNormalTexture")}getClearcoatNormalTextureInfo(){return this.getRef("clearcoatNormalTexture")?this.getRef("clearcoatNormalTextureInfo"):null}setClearcoatNormalTexture(n){return this.setRef("clearcoatNormalTexture",n,{channels:ps|ms|Wa})}},Ka=class extends k{static EXTENSION_NAME=He;extensionName=He;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createClearcoat(){return new Xa(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_clearcoat){let o=this.createClearcoat();n.materials[r].setExtension(He,o);let a=s.extensions[He];if(a.extras&&o.setExtras(a.extras),a.clearcoatFactor!==void 0&&o.setClearcoatFactor(a.clearcoatFactor),a.clearcoatRoughnessFactor!==void 0&&o.setClearcoatRoughnessFactor(a.clearcoatRoughnessFactor),a.clearcoatTexture!==void 0){let c=a.clearcoatTexture,l=n.textures[i[c.index].source];o.setClearcoatTexture(l),n.setTextureInfo(o.getClearcoatTextureInfo(),c);}if(a.clearcoatRoughnessTexture!==void 0){let c=a.clearcoatRoughnessTexture,l=n.textures[i[c.index].source];o.setClearcoatRoughnessTexture(l),n.setTextureInfo(o.getClearcoatRoughnessTextureInfo(),c);}if(a.clearcoatNormalTexture!==void 0){let c=a.clearcoatNormalTexture,l=n.textures[i[c.index].source];o.setClearcoatNormalTexture(l),n.setTextureInfo(o.getClearcoatNormalTextureInfo(),c),c.scale!==void 0&&o.setClearcoatNormalScale(c.scale);}}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(He);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[He]=o,o.clearcoatFactor=i.getClearcoatFactor(),o.clearcoatRoughnessFactor=i.getClearcoatRoughnessFactor(),i.getClearcoatTexture()){let a=i.getClearcoatTexture(),c=i.getClearcoatTextureInfo();o.clearcoatTexture=n.createTextureInfoDef(a,c);}if(i.getClearcoatRoughnessTexture()){let a=i.getClearcoatRoughnessTexture(),c=i.getClearcoatRoughnessTextureInfo();o.clearcoatRoughnessTexture=n.createTextureInfoDef(a,c);}if(i.getClearcoatNormalTexture()){let a=i.getClearcoatNormalTexture(),c=i.getClearcoatNormalTextureInfo();o.clearcoatNormalTexture=n.createTextureInfoDef(a,c),i.getClearcoatNormalScale()!==1&&(o.clearcoatNormalTexture.scale=i.getClearcoatNormalScale());}}}),this}},{R:qa,G:Ya,B:ja,A:$a}=Se,Ja=class extends F{static EXTENSION_NAME=We;init(){this.extensionName=We,this.propertyType="DiffuseTransmission",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{diffuseTransmissionFactor:0,diffuseTransmissionTexture:null,diffuseTransmissionTextureInfo:new W(this.graph,"diffuseTransmissionTextureInfo"),diffuseTransmissionColorFactor:[1,1,1],diffuseTransmissionColorTexture:null,diffuseTransmissionColorTextureInfo:new W(this.graph,"diffuseTransmissionColorTextureInfo")})}getDiffuseTransmissionFactor(){return this.get("diffuseTransmissionFactor")}setDiffuseTransmissionFactor(n){return this.set("diffuseTransmissionFactor",n)}getDiffuseTransmissionTexture(){return this.getRef("diffuseTransmissionTexture")}getDiffuseTransmissionTextureInfo(){return this.getRef("diffuseTransmissionTexture")?this.getRef("diffuseTransmissionTextureInfo"):null}setDiffuseTransmissionTexture(n){return this.setRef("diffuseTransmissionTexture",n,{channels:$a})}getDiffuseTransmissionColorFactor(){return this.get("diffuseTransmissionColorFactor")}setDiffuseTransmissionColorFactor(n){return this.set("diffuseTransmissionColorFactor",n)}getDiffuseTransmissionColorTexture(){return this.getRef("diffuseTransmissionColorTexture")}getDiffuseTransmissionColorTextureInfo(){return this.getRef("diffuseTransmissionColorTexture")?this.getRef("diffuseTransmissionColorTextureInfo"):null}setDiffuseTransmissionColorTexture(n){return this.setRef("diffuseTransmissionColorTexture",n,{channels:qa|Ya|ja})}},Za=class extends k{extensionName=We;static EXTENSION_NAME=We;createDiffuseTransmission(){return new Ja(this.document.getGraph())}read(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_diffuse_transmission){let o=this.createDiffuseTransmission();n.materials[r].setExtension(We,o);let a=s.extensions[We];if(a.extras&&o.setExtras(a.extras),a.diffuseTransmissionFactor!==void 0&&o.setDiffuseTransmissionFactor(a.diffuseTransmissionFactor),a.diffuseTransmissionColorFactor!==void 0&&o.setDiffuseTransmissionColorFactor(a.diffuseTransmissionColorFactor),a.diffuseTransmissionTexture!==void 0){let c=a.diffuseTransmissionTexture,l=n.textures[i[c.index].source];o.setDiffuseTransmissionTexture(l),n.setTextureInfo(o.getDiffuseTransmissionTextureInfo(),c);}if(a.diffuseTransmissionColorTexture!==void 0){let c=a.diffuseTransmissionColorTexture,l=n.textures[i[c.index].source];o.setDiffuseTransmissionColorTexture(l),n.setTextureInfo(o.getDiffuseTransmissionColorTextureInfo(),c);}}}),this}write(n){let e=n.jsonDoc;for(let t of this.document.getRoot().listMaterials()){let i=t.getExtension(We);if(!i)continue;let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[We]=o,o.diffuseTransmissionFactor=i.getDiffuseTransmissionFactor(),o.diffuseTransmissionColorFactor=i.getDiffuseTransmissionColorFactor(),i.getDiffuseTransmissionTexture()){let a=i.getDiffuseTransmissionTexture(),c=i.getDiffuseTransmissionTextureInfo();o.diffuseTransmissionTexture=n.createTextureInfoDef(a,c);}if(i.getDiffuseTransmissionColorTexture()){let a=i.getDiffuseTransmissionColorTexture(),c=i.getDiffuseTransmissionColorTextureInfo();o.diffuseTransmissionColorTexture=n.createTextureInfoDef(a,c);}}return this}},Qa=class extends F{static EXTENSION_NAME=Xe;init(){this.extensionName=Xe,this.propertyType="Dispersion",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{dispersion:0})}getDispersion(){return this.get("dispersion")}setDispersion(n){return this.set("dispersion",n)}},ec=class extends k{static EXTENSION_NAME=Xe;extensionName=Xe;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createDispersion(){return new Qa(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){return (n.jsonDoc.json.materials||[]).forEach((e,t)=>{if(e.extensions&&e.extensions.KHR_materials_dispersion){let i=this.createDispersion();n.materials[t].setExtension(Xe,i);let s=e.extensions[Xe];s.extras&&i.setExtras(s.extras),s.dispersion!==void 0&&i.setDispersion(s.dispersion);}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(Xe);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);r.extensions=r.extensions||{},r.extensions[Xe]=o,o.dispersion=i.getDispersion();}}),this}},tc=class extends F{static EXTENSION_NAME=Ke;init(){this.extensionName=Ke,this.propertyType="EmissiveStrength",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{emissiveStrength:1})}getEmissiveStrength(){return this.get("emissiveStrength")}setEmissiveStrength(n){return this.set("emissiveStrength",n)}},nc=class extends k{static EXTENSION_NAME=Ke;extensionName=Ke;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createEmissiveStrength(){return new tc(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){return (n.jsonDoc.json.materials||[]).forEach((e,t)=>{if(e.extensions&&e.extensions.KHR_materials_emissive_strength){let i=this.createEmissiveStrength();n.materials[t].setExtension(Ke,i);let s=e.extensions[Ke];s.extras&&i.setExtras(s.extras),s.emissiveStrength!==void 0&&i.setEmissiveStrength(s.emissiveStrength);}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(Ke);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);r.extensions=r.extensions||{},r.extensions[Ke]=o,o.emissiveStrength=i.getEmissiveStrength();}}),this}},ic=class extends F{static EXTENSION_NAME=qe;init(){this.extensionName=qe,this.propertyType="IOR",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{ior:1.5})}getIOR(){return this.get("ior")}setIOR(n){return this.set("ior",n)}},sc=class extends k{static EXTENSION_NAME=qe;extensionName=qe;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createIOR(){return new ic(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){return (n.jsonDoc.json.materials||[]).forEach((e,t)=>{if(e.extensions&&e.extensions.KHR_materials_ior){let i=this.createIOR();n.materials[t].setExtension(qe,i);let s=e.extensions[qe];s.extras&&i.setExtras(s.extras),s.ior!==void 0&&i.setIOR(s.ior);}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(qe);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);r.extensions=r.extensions||{},r.extensions[qe]=o,o.ior=i.getIOR();}}),this}},{R:rc,G:oc}=Se,ac=class extends F{static EXTENSION_NAME=Ye;init(){this.extensionName=Ye,this.propertyType="Iridescence",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{iridescenceFactor:0,iridescenceTexture:null,iridescenceTextureInfo:new W(this.graph,"iridescenceTextureInfo"),iridescenceIOR:1.3,iridescenceThicknessMinimum:100,iridescenceThicknessMaximum:400,iridescenceThicknessTexture:null,iridescenceThicknessTextureInfo:new W(this.graph,"iridescenceThicknessTextureInfo")})}getIridescenceFactor(){return this.get("iridescenceFactor")}setIridescenceFactor(n){return this.set("iridescenceFactor",n)}getIridescenceTexture(){return this.getRef("iridescenceTexture")}getIridescenceTextureInfo(){return this.getRef("iridescenceTexture")?this.getRef("iridescenceTextureInfo"):null}setIridescenceTexture(n){return this.setRef("iridescenceTexture",n,{channels:rc})}getIridescenceIOR(){return this.get("iridescenceIOR")}setIridescenceIOR(n){return this.set("iridescenceIOR",n)}getIridescenceThicknessMinimum(){return this.get("iridescenceThicknessMinimum")}setIridescenceThicknessMinimum(n){return this.set("iridescenceThicknessMinimum",n)}getIridescenceThicknessMaximum(){return this.get("iridescenceThicknessMaximum")}setIridescenceThicknessMaximum(n){return this.set("iridescenceThicknessMaximum",n)}getIridescenceThicknessTexture(){return this.getRef("iridescenceThicknessTexture")}getIridescenceThicknessTextureInfo(){return this.getRef("iridescenceThicknessTexture")?this.getRef("iridescenceThicknessTextureInfo"):null}setIridescenceThicknessTexture(n){return this.setRef("iridescenceThicknessTexture",n,{channels:oc})}},cc=class extends k{static EXTENSION_NAME=Ye;extensionName=Ye;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createIridescence(){return new ac(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_iridescence){let o=this.createIridescence();n.materials[r].setExtension(Ye,o);let a=s.extensions[Ye];if(a.extras&&o.setExtras(a.extras),a.iridescenceFactor!==void 0&&o.setIridescenceFactor(a.iridescenceFactor),a.iridescenceIor!==void 0&&o.setIridescenceIOR(a.iridescenceIor),a.iridescenceThicknessMinimum!==void 0&&o.setIridescenceThicknessMinimum(a.iridescenceThicknessMinimum),a.iridescenceThicknessMaximum!==void 0&&o.setIridescenceThicknessMaximum(a.iridescenceThicknessMaximum),a.iridescenceTexture!==void 0){let c=a.iridescenceTexture,l=n.textures[i[c.index].source];o.setIridescenceTexture(l),n.setTextureInfo(o.getIridescenceTextureInfo(),c);}if(a.iridescenceThicknessTexture!==void 0){let c=a.iridescenceThicknessTexture,l=n.textures[i[c.index].source];o.setIridescenceThicknessTexture(l),n.setTextureInfo(o.getIridescenceThicknessTextureInfo(),c);}}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(Ye);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[Ye]=o,i.getIridescenceFactor()>0&&(o.iridescenceFactor=i.getIridescenceFactor()),i.getIridescenceIOR()!==1.3&&(o.iridescenceIor=i.getIridescenceIOR()),i.getIridescenceThicknessMinimum()!==100&&(o.iridescenceThicknessMinimum=i.getIridescenceThicknessMinimum()),i.getIridescenceThicknessMaximum()!==400&&(o.iridescenceThicknessMaximum=i.getIridescenceThicknessMaximum()),i.getIridescenceTexture()){let a=i.getIridescenceTexture(),c=i.getIridescenceTextureInfo();o.iridescenceTexture=n.createTextureInfoDef(a,c);}if(i.getIridescenceThicknessTexture()){let a=i.getIridescenceThicknessTexture(),c=i.getIridescenceThicknessTextureInfo();o.iridescenceThicknessTexture=n.createTextureInfoDef(a,c);}}}),this}},{R:gs,G:_s,B:xs,A:ys}=Se,lc=class extends F{static EXTENSION_NAME=je;init(){this.extensionName=je,this.propertyType="PBRSpecularGlossiness",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{diffuseFactor:[1,1,1,1],diffuseTexture:null,diffuseTextureInfo:new W(this.graph,"diffuseTextureInfo"),specularFactor:[1,1,1],glossinessFactor:1,specularGlossinessTexture:null,specularGlossinessTextureInfo:new W(this.graph,"specularGlossinessTextureInfo")})}getDiffuseFactor(){return this.get("diffuseFactor")}setDiffuseFactor(n){return this.set("diffuseFactor",n)}getDiffuseTexture(){return this.getRef("diffuseTexture")}getDiffuseTextureInfo(){return this.getRef("diffuseTexture")?this.getRef("diffuseTextureInfo"):null}setDiffuseTexture(n){return this.setRef("diffuseTexture",n,{channels:gs|_s|xs|ys,isColor:true})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(n){return this.set("specularFactor",n)}getGlossinessFactor(){return this.get("glossinessFactor")}setGlossinessFactor(n){return this.set("glossinessFactor",n)}getSpecularGlossinessTexture(){return this.getRef("specularGlossinessTexture")}getSpecularGlossinessTextureInfo(){return this.getRef("specularGlossinessTexture")?this.getRef("specularGlossinessTextureInfo"):null}setSpecularGlossinessTexture(n){return this.setRef("specularGlossinessTexture",n,{channels:gs|_s|xs|ys})}},uc=class extends k{static EXTENSION_NAME=je;extensionName=je;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createPBRSpecularGlossiness(){return new lc(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_pbrSpecularGlossiness){let o=this.createPBRSpecularGlossiness();n.materials[r].setExtension(je,o);let a=s.extensions[je];if(a.extras&&o.setExtras(a.extras),a.diffuseFactor!==void 0&&o.setDiffuseFactor(a.diffuseFactor),a.specularFactor!==void 0&&o.setSpecularFactor(a.specularFactor),a.glossinessFactor!==void 0&&o.setGlossinessFactor(a.glossinessFactor),a.diffuseTexture!==void 0){let c=a.diffuseTexture,l=n.textures[i[c.index].source];o.setDiffuseTexture(l),n.setTextureInfo(o.getDiffuseTextureInfo(),c);}if(a.specularGlossinessTexture!==void 0){let c=a.specularGlossinessTexture,l=n.textures[i[c.index].source];o.setSpecularGlossinessTexture(l),n.setTextureInfo(o.getSpecularGlossinessTextureInfo(),c);}}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(je);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[je]=o,o.diffuseFactor=i.getDiffuseFactor(),o.specularFactor=i.getSpecularFactor(),o.glossinessFactor=i.getGlossinessFactor(),i.getDiffuseTexture()){let a=i.getDiffuseTexture(),c=i.getDiffuseTextureInfo();o.diffuseTexture=n.createTextureInfoDef(a,c);}if(i.getSpecularGlossinessTexture()){let a=i.getSpecularGlossinessTexture(),c=i.getSpecularGlossinessTextureInfo();o.specularGlossinessTexture=n.createTextureInfoDef(a,c);}}}),this}},{R:hc,G:fc,B:dc,A:pc}=Se,mc=class extends F{static EXTENSION_NAME=$e;init(){this.extensionName=$e,this.propertyType="Sheen",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{sheenColorFactor:[0,0,0],sheenColorTexture:null,sheenColorTextureInfo:new W(this.graph,"sheenColorTextureInfo"),sheenRoughnessFactor:0,sheenRoughnessTexture:null,sheenRoughnessTextureInfo:new W(this.graph,"sheenRoughnessTextureInfo")})}getSheenColorFactor(){return this.get("sheenColorFactor")}setSheenColorFactor(n){return this.set("sheenColorFactor",n)}getSheenColorTexture(){return this.getRef("sheenColorTexture")}getSheenColorTextureInfo(){return this.getRef("sheenColorTexture")?this.getRef("sheenColorTextureInfo"):null}setSheenColorTexture(n){return this.setRef("sheenColorTexture",n,{channels:hc|fc|dc,isColor:true})}getSheenRoughnessFactor(){return this.get("sheenRoughnessFactor")}setSheenRoughnessFactor(n){return this.set("sheenRoughnessFactor",n)}getSheenRoughnessTexture(){return this.getRef("sheenRoughnessTexture")}getSheenRoughnessTextureInfo(){return this.getRef("sheenRoughnessTexture")?this.getRef("sheenRoughnessTextureInfo"):null}setSheenRoughnessTexture(n){return this.setRef("sheenRoughnessTexture",n,{channels:pc})}},gc=class extends k{static EXTENSION_NAME=$e;extensionName=$e;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createSheen(){return new mc(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_sheen){let o=this.createSheen();n.materials[r].setExtension($e,o);let a=s.extensions[$e];if(a.extras&&o.setExtras(a.extras),a.sheenColorFactor!==void 0&&o.setSheenColorFactor(a.sheenColorFactor),a.sheenRoughnessFactor!==void 0&&o.setSheenRoughnessFactor(a.sheenRoughnessFactor),a.sheenColorTexture!==void 0){let c=a.sheenColorTexture,l=n.textures[i[c.index].source];o.setSheenColorTexture(l),n.setTextureInfo(o.getSheenColorTextureInfo(),c);}if(a.sheenRoughnessTexture!==void 0){let c=a.sheenRoughnessTexture,l=n.textures[i[c.index].source];o.setSheenRoughnessTexture(l),n.setTextureInfo(o.getSheenRoughnessTextureInfo(),c);}}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension($e);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[$e]=o,o.sheenColorFactor=i.getSheenColorFactor(),o.sheenRoughnessFactor=i.getSheenRoughnessFactor(),i.getSheenColorTexture()){let a=i.getSheenColorTexture(),c=i.getSheenColorTextureInfo();o.sheenColorTexture=n.createTextureInfoDef(a,c);}if(i.getSheenRoughnessTexture()){let a=i.getSheenRoughnessTexture(),c=i.getSheenRoughnessTextureInfo();o.sheenRoughnessTexture=n.createTextureInfoDef(a,c);}}}),this}},{R:_c,G:xc,B:yc,A:vc}=Se,Mc=class extends F{static EXTENSION_NAME=Je;init(){this.extensionName=Je,this.propertyType="Specular",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{specularFactor:1,specularTexture:null,specularTextureInfo:new W(this.graph,"specularTextureInfo"),specularColorFactor:[1,1,1],specularColorTexture:null,specularColorTextureInfo:new W(this.graph,"specularColorTextureInfo")})}getSpecularFactor(){return this.get("specularFactor")}setSpecularFactor(n){return this.set("specularFactor",n)}getSpecularColorFactor(){return this.get("specularColorFactor")}setSpecularColorFactor(n){return this.set("specularColorFactor",n)}getSpecularTexture(){return this.getRef("specularTexture")}getSpecularTextureInfo(){return this.getRef("specularTexture")?this.getRef("specularTextureInfo"):null}setSpecularTexture(n){return this.setRef("specularTexture",n,{channels:vc})}getSpecularColorTexture(){return this.getRef("specularColorTexture")}getSpecularColorTextureInfo(){return this.getRef("specularColorTexture")?this.getRef("specularColorTextureInfo"):null}setSpecularColorTexture(n){return this.setRef("specularColorTexture",n,{channels:_c|xc|yc,isColor:true})}},Sc=class extends k{static EXTENSION_NAME=Je;extensionName=Je;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createSpecular(){return new Mc(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_specular){let o=this.createSpecular();n.materials[r].setExtension(Je,o);let a=s.extensions[Je];if(a.extras&&o.setExtras(a.extras),a.specularFactor!==void 0&&o.setSpecularFactor(a.specularFactor),a.specularColorFactor!==void 0&&o.setSpecularColorFactor(a.specularColorFactor),a.specularTexture!==void 0){let c=a.specularTexture,l=n.textures[i[c.index].source];o.setSpecularTexture(l),n.setTextureInfo(o.getSpecularTextureInfo(),c);}if(a.specularColorTexture!==void 0){let c=a.specularColorTexture,l=n.textures[i[c.index].source];o.setSpecularColorTexture(l),n.setTextureInfo(o.getSpecularColorTextureInfo(),c);}}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(Je);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[Je]=o,i.getSpecularFactor()!==1&&(o.specularFactor=i.getSpecularFactor()),X.eq(i.getSpecularColorFactor(),[1,1,1])||(o.specularColorFactor=i.getSpecularColorFactor()),i.getSpecularTexture()){let a=i.getSpecularTexture(),c=i.getSpecularTextureInfo();o.specularTexture=n.createTextureInfoDef(a,c);}if(i.getSpecularColorTexture()){let a=i.getSpecularColorTexture(),c=i.getSpecularColorTextureInfo();o.specularColorTexture=n.createTextureInfoDef(a,c);}}}),this}},{R:Tc}=Se,bc=class extends F{static EXTENSION_NAME=Ze;init(){this.extensionName=Ze,this.propertyType="Transmission",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{transmissionFactor:0,transmissionTexture:null,transmissionTextureInfo:new W(this.graph,"transmissionTextureInfo")})}getTransmissionFactor(){return this.get("transmissionFactor")}setTransmissionFactor(n){return this.set("transmissionFactor",n)}getTransmissionTexture(){return this.getRef("transmissionTexture")}getTransmissionTextureInfo(){return this.getRef("transmissionTexture")?this.getRef("transmissionTextureInfo"):null}setTransmissionTexture(n){return this.setRef("transmissionTexture",n,{channels:Tc})}},Ec=class extends k{static EXTENSION_NAME=Ze;extensionName=Ze;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createTransmission(){return new bc(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_transmission){let o=this.createTransmission();n.materials[r].setExtension(Ze,o);let a=s.extensions[Ze];if(a.extras&&o.setExtras(a.extras),a.transmissionFactor!==void 0&&o.setTransmissionFactor(a.transmissionFactor),a.transmissionTexture!==void 0){let c=a.transmissionTexture,l=n.textures[i[c.index].source];o.setTransmissionTexture(l),n.setTextureInfo(o.getTransmissionTextureInfo(),c);}}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(Ze);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[Ze]=o,o.transmissionFactor=i.getTransmissionFactor(),i.getTransmissionTexture()){let a=i.getTransmissionTexture(),c=i.getTransmissionTextureInfo();o.transmissionTexture=n.createTextureInfoDef(a,c);}}}),this}},Ac=class extends F{static EXTENSION_NAME=ft;init(){this.extensionName=ft,this.propertyType="Unlit",this.parentTypes=[T.MATERIAL];}},Rc=class extends k{static EXTENSION_NAME=ft;extensionName=ft;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createUnlit(){return new Ac(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){return (n.jsonDoc.json.materials||[]).forEach((e,t)=>{e.extensions&&e.extensions.KHR_materials_unlit&&n.materials[t].setExtension(ft,this.createUnlit());}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{if(t.getExtension("KHR_materials_unlit")){let i=n.materialIndexMap.get(t),s=e.json.materials[i];s.extensions=s.extensions||{},s.extensions[ft]={};}}),this}},wc=class extends F{static EXTENSION_NAME=fe;init(){this.extensionName=fe,this.propertyType="Mapping",this.parentTypes=["MappingList"];}getDefaults(){return Object.assign(super.getDefaults(),{material:null,variants:new H})}getMaterial(){return this.getRef("material")}setMaterial(n){return this.setRef("material",n)}addVariant(n){return this.addRef("variants",n)}removeVariant(n){return this.removeRef("variants",n)}listVariants(){return this.listRefs("variants")}},Cc=class extends F{static EXTENSION_NAME=fe;init(){this.extensionName=fe,this.propertyType="MappingList",this.parentTypes=[T.PRIMITIVE];}getDefaults(){return Object.assign(super.getDefaults(),{mappings:new H})}addMapping(n){return this.addRef("mappings",n)}removeMapping(n){return this.removeRef("mappings",n)}listMappings(){return this.listRefs("mappings")}},vs=class extends F{static EXTENSION_NAME=fe;init(){this.extensionName=fe,this.propertyType="Variant",this.parentTypes=["MappingList"];}},Ic=class extends k{extensionName=fe;static EXTENSION_NAME=fe;createMappingList(){return new Cc(this.document.getGraph())}createVariant(n=""){return new vs(this.document.getGraph(),n)}createMapping(){return new wc(this.document.getGraph())}listVariants(){return Array.from(this.properties).filter(n=>n instanceof vs)}read(n){let e=n.jsonDoc;if(!e.json.extensions||!e.json.extensions.KHR_materials_variants)return this;let t=(e.json.extensions.KHR_materials_variants.variants||[]).map(i=>this.createVariant().setName(i.name||""));return (e.json.meshes||[]).forEach((i,s)=>{let r=n.meshes[s];(i.primitives||[]).forEach((o,a)=>{if(!o.extensions||!o.extensions.KHR_materials_variants)return;let c=this.createMappingList(),l=o.extensions[fe];for(let u of l.mappings){let d=this.createMapping();u.material!==void 0&&d.setMaterial(n.materials[u.material]);for(let m of u.variants||[])d.addVariant(t[m]);c.addMapping(d);}r.listPrimitives()[a].setExtension(fe,c);});}),this}write(n){let e=n.jsonDoc,t=this.listVariants();if(!t.length)return this;let i=[],s=new Map;for(let r of t)s.set(r,i.length),i.push(n.createPropertyDef(r));for(let r of this.document.getRoot().listMeshes()){let o=n.meshIndexMap.get(r);r.listPrimitives().forEach((a,c)=>{let l=a.getExtension(fe);if(!l)return;let u=n.jsonDoc.json.meshes[o].primitives[c],d=l.listMappings().map(m=>{let p=n.createPropertyDef(m),_=m.getMaterial();return _&&(p.material=n.materialIndexMap.get(_)),p.variants=m.listVariants().map(f=>s.get(f)),p});u.extensions=u.extensions||{},u.extensions[fe]={mappings:d};});}return e.json.extensions=e.json.extensions||{},e.json.extensions[fe]={variants:i},this}},{G:Nc}=Se,Pc=class extends F{static EXTENSION_NAME=Qe;init(){this.extensionName=Qe,this.propertyType="Volume",this.parentTypes=[T.MATERIAL];}getDefaults(){return Object.assign(super.getDefaults(),{thicknessFactor:0,thicknessTexture:null,thicknessTextureInfo:new W(this.graph,"thicknessTexture"),attenuationDistance:1/0,attenuationColor:[1,1,1]})}getThicknessFactor(){return this.get("thicknessFactor")}setThicknessFactor(n){return this.set("thicknessFactor",n)}getThicknessTexture(){return this.getRef("thicknessTexture")}getThicknessTextureInfo(){return this.getRef("thicknessTexture")?this.getRef("thicknessTextureInfo"):null}setThicknessTexture(n){return this.setRef("thicknessTexture",n,{channels:Nc})}getAttenuationDistance(){return this.get("attenuationDistance")}setAttenuationDistance(n){return this.set("attenuationDistance",n)}getAttenuationColor(){return this.get("attenuationColor")}setAttenuationColor(n){return this.set("attenuationColor",n)}},Oc=class extends k{static EXTENSION_NAME=Qe;extensionName=Qe;prereadTypes=[T.MESH];prewriteTypes=[T.MESH];createVolume(){return new Pc(this.document.getGraph())}read(n){return this}write(n){return this}preread(n){let e=n.jsonDoc,t=e.json.materials||[],i=e.json.textures||[];return t.forEach((s,r)=>{if(s.extensions&&s.extensions.KHR_materials_volume){let o=this.createVolume();n.materials[r].setExtension(Qe,o);let a=s.extensions[Qe];if(a.extras&&o.setExtras(a.extras),a.thicknessFactor!==void 0&&o.setThicknessFactor(a.thicknessFactor),a.attenuationDistance!==void 0&&o.setAttenuationDistance(a.attenuationDistance),a.attenuationColor!==void 0&&o.setAttenuationColor(a.attenuationColor),a.thicknessTexture!==void 0){let c=a.thicknessTexture,l=n.textures[i[c.index].source];o.setThicknessTexture(l),n.setTextureInfo(o.getThicknessTextureInfo(),c);}}}),this}prewrite(n){let e=n.jsonDoc;return this.document.getRoot().listMaterials().forEach(t=>{let i=t.getExtension(Qe);if(i){let s=n.materialIndexMap.get(t),r=e.json.materials[s],o=n.createPropertyDef(i);if(r.extensions=r.extensions||{},r.extensions[Qe]=o,i.getThicknessFactor()>0&&(o.thicknessFactor=i.getThicknessFactor()),Number.isFinite(i.getAttenuationDistance())&&(o.attenuationDistance=i.getAttenuationDistance()),X.eq(i.getAttenuationColor(),[1,1,1])||(o.attenuationColor=i.getAttenuationColor()),i.getThicknessTexture()){let a=i.getThicknessTexture(),c=i.getThicknessTextureInfo();o.thicknessTexture=n.createTextureInfoDef(a,c);}}}),this}},Lc=class extends k{extensionName=is;static EXTENSION_NAME=is;read(n){return this}write(n){return this}},Dc=class extends k{extensionName=ss;static EXTENSION_NAME=ss;read(n){return this}write(n){return this}},Fc=class extends F{static EXTENSION_NAME=et;init(){this.extensionName=et,this.propertyType="Visibility",this.parentTypes=[T.NODE];}getDefaults(){return Object.assign(super.getDefaults(),{visible:true})}getVisible(){return this.get("visible")}setVisible(n){return this.set("visible",n)}},Uc=class extends k{static EXTENSION_NAME=et;extensionName=et;createVisibility(){return new Fc(this.document.getGraph())}read(n){return (n.jsonDoc.json.nodes||[]).forEach((e,t)=>{if(e.extensions&&e.extensions.KHR_node_visibility){let i=this.createVisibility();n.nodes[t].setExtension(et,i);let s=e.extensions[et];s.visible!==void 0&&i.setVisible(s.visible);}}),this}write(n){let e=n.jsonDoc;for(let t of this.document.getRoot().listNodes()){let i=t.getExtension(et);if(!i)continue;let s=n.nodeIndexMap.get(t),r=e.json.nodes[s];r.extensions=r.extensions||{},r.extensions[et]={visible:i.getVisible()};}return this}};function Bc(n){return n.vkFormat>0&&n.vkFormat<=123}function Ms(n){let e=n.vkFormat===1000066e3&&n.dataFormatDescriptor[0].colorModel===167;return n.vkFormat===0||e}var Vc=class{match(n){return n[0]===171&&n[1]===75&&n[2]===84&&n[3]===88&&n[4]===32&&n[5]===50&&n[6]===48&&n[7]===187&&n[8]===13&&n[9]===10&&n[10]===26&&n[11]===10}getSize(n){let e=Xt(n);return [e.pixelWidth,e.pixelHeight]}getChannels(n){let e=Xt(n),t=e.dataFormatDescriptor[0];if(Bc(e))return t.samples.length;if(Ms(e))switch(t.colorModel){case 163:return t.samples.length===2&&(t.samples[1].channelType&15)===15?4:3;case 166:return (t.samples[0].channelType&15)===3?4:3;default:throw new Error(`Unexpected KTX2 colorModel, "${t.colorModel}".`)}throw new Error(`Unexpected KTX2 vkFormat, "${e.vkFormat}".`)}getVRAMByteLength(n){let e=Xt(n),t=0;if(Ms(e)){let i=this.getChannels(n)>3;for(let s=0;s<e.levels.length;s++){let r=e.levels[s];if(r.uncompressedByteLength)t+=r.uncompressedByteLength;else {let o=Math.max(1,Math.floor(e.pixelWidth/Math.pow(2,s))),a=Math.max(1,Math.floor(e.pixelHeight/Math.pow(2,s))),c=i?16:8;t+=o/4*(a/4)*c;}}}else for(let i of e.levels)e.supercompressionScheme===0?t+=i.levelData.byteLength:t+=i.uncompressedByteLength;return t}},Gc=class extends k{static EXTENSION_NAME=Yt;extensionName=Yt;prereadTypes=[T.TEXTURE];static register(){Re.registerFormat("image/ktx2",new Vc);}preread(n){return n.jsonDoc.json.textures&&n.jsonDoc.json.textures.forEach(e=>{e.extensions&&e.extensions.KHR_texture_basisu&&(e.source=e.extensions[Yt].source);}),this}read(n){return this}write(n){let e=n.jsonDoc;return this.document.getRoot().listTextures().forEach(t=>{if(t.getMimeType()==="image/ktx2"){let i=n.imageIndexMap.get(t);e.json.textures.forEach(s=>{s.source===i&&(s.extensions=s.extensions||{},s.extensions[Yt]={source:s.source},delete s.source);});}}),this}},zc=class extends F{static EXTENSION_NAME=tt;init(){this.extensionName=tt,this.propertyType="Transform",this.parentTypes=[T.TEXTURE_INFO];}getDefaults(){return Object.assign(super.getDefaults(),{offset:[0,0],rotation:0,scale:[1,1],texCoord:null})}getOffset(){return this.get("offset")}setOffset(n){return this.set("offset",n)}getRotation(){return this.get("rotation")}setRotation(n){return this.set("rotation",n)}getScale(){return this.get("scale")}setScale(n){return this.set("scale",n)}getTexCoord(){return this.get("texCoord")}setTexCoord(n){return this.set("texCoord",n)}},kc=class extends k{extensionName=tt;static EXTENSION_NAME=tt;createTransform(){return new zc(this.document.getGraph())}read(n){for(let[e,t]of Array.from(n.textureInfos.entries())){if(!t.extensions||!t.extensions.KHR_texture_transform)continue;let i=this.createTransform(),s=t.extensions[tt];s.offset!==void 0&&i.setOffset(s.offset),s.rotation!==void 0&&i.setRotation(s.rotation),s.scale!==void 0&&i.setScale(s.scale),s.texCoord!==void 0&&i.setTexCoord(s.texCoord),e.setExtension(tt,i);}return this}write(n){let e=Array.from(n.textureInfoDefMap.entries());for(let[t,i]of e){let s=t.getExtension(tt);if(!s)continue;i.extensions=i.extensions||{};let r={},o=X.eq;o(s.getOffset(),[0,0])||(r.offset=s.getOffset()),s.getRotation()!==0&&(r.rotation=s.getRotation()),o(s.getScale(),[1,1])||(r.scale=s.getScale()),s.getTexCoord()!=null&&(r.texCoord=s.getTexCoord()),i.extensions[tt]=r;}return this}},Hc=[T.ROOT,T.SCENE,T.NODE,T.MESH,T.MATERIAL,T.TEXTURE,T.ANIMATION],Wc=class extends F{static EXTENSION_NAME=Te;init(){this.extensionName=Te,this.propertyType="Packet",this.parentTypes=Hc;}getDefaults(){return Object.assign(super.getDefaults(),{context:{},properties:{}})}getContext(){return this.get("context")}setContext(n){return this.set("context",{...n})}listProperties(){return Object.keys(this.get("properties"))}getProperty(n){let e=this.get("properties");return n in e?e[n]:null}setProperty(n,e){this._assertContext(n);let t={...this.get("properties")};return e?t[n]=e:delete t[n],this.set("properties",t)}toJSONLD(){return {"@context":In(this.get("context")),...In(this.get("properties"))}}fromJSONLD(n){n=In(n);let e=n["@context"];return e&&this.set("context",e),delete n["@context"],this.set("properties",n)}_assertContext(n){if(!(n.split(":")[0]in this.get("context")))throw new Error(`${Te}: Missing context for term, "${n}".`)}};function In(n){return JSON.parse(JSON.stringify(n))}var Xc=class extends k{extensionName=Te;static EXTENSION_NAME=Te;createPacket(){return new Wc(this.document.getGraph())}listPackets(){return Array.from(this.properties)}read(n){let e=n.jsonDoc.json.extensions?.[Te];if(!e||!e.packets)return this;let t=n.jsonDoc.json,i=this.document.getRoot(),s=e.packets.map(a=>this.createPacket().fromJSONLD(a)),r=[[t.asset],t.scenes,t.nodes,t.meshes,t.materials,t.images,t.animations],o=[[i],i.listScenes(),i.listNodes(),i.listMeshes(),i.listMaterials(),i.listTextures(),i.listAnimations()];for(let a=0;a<r.length;a++){let c=r[a]||[];for(let l=0;l<c.length;l++){let u=c[l];if(u.extensions&&u.extensions.KHR_xmp_json_ld){let d=u.extensions[Te];o[a][l].setExtension(Te,s[d.packet]);}}}return this}write(n){let{json:e}=n.jsonDoc,t=[];for(let i of this.properties){t.push(i.toJSONLD());for(let s of i.listParents()){let r;switch(s.propertyType){case T.ROOT:r=e.asset;break;case T.SCENE:r=e.scenes[n.sceneIndexMap.get(s)];break;case T.NODE:r=e.nodes[n.nodeIndexMap.get(s)];break;case T.MESH:r=e.meshes[n.meshIndexMap.get(s)];break;case T.MATERIAL:r=e.materials[n.materialIndexMap.get(s)];break;case T.TEXTURE:r=e.images[n.imageIndexMap.get(s)];break;case T.ANIMATION:r=e.animations[n.animationIndexMap.get(s)];break;default:r=null,this.document.getLogger().warn(`[${Te}]: Unsupported parent property, "${s.propertyType}"`);break}r&&(r.extensions=r.extensions||{},r.extensions[Te]={packet:t.length-1});}}return t.length>0&&(e.extensions=e.extensions||{},e.extensions[Te]={packets:t}),this}},Kc=[Ea,Aa,Fa,Ba,Ha,Ka,Za,ec,nc,sc,cc,uc,Sc,gc,Ec,Rc,Ic,Oc,Lc,Dc,Uc,Gc,kc,Xc],ws=[To,xo,Lo,jo,Sa,ba,...Kc];var gi="",xe="srgb",ti="srgb-linear",ni="linear",en="srgb";var Rt=2e3,ii=2001;var Cs={};function Qs(n){let e=n[0];if(typeof e=="string"&&e.startsWith("TSL:")){let t=n[1];t&&t.isStackTrace?n[0]+=" "+t.getLocation():n[1]='Stack trace not available. Enable "THREE.Node.captureStackTrace" to capture stack traces.';}return n}function re(...n){n=Qs(n);let e="THREE."+n.shift();{let t=n[0];t&&t.isStackTrace?console.warn(t.getError(e)):console.warn(e,...n);}}function tn(...n){let e=n.join(" ");e in Cs||(Cs[e]=true,re(...n));}function V(n,e,t){return Math.max(e,Math.min(t,n))}function $c(n,e){return (n%e+e)%e}function Ln(n,e,t){return (1-t)*n+t*e}var Ee=class{static{this.prototype.isVector2=true;}constructor(e=0,t=0){this.x=e,this.y=t;}get width(){return this.x}set width(e){this.x=e;}get height(){return this.y}set height(e){this.y=e;}set(e,t){return this.x=e,this.y=t,this}setScalar(e){return this.x=e,this.y=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;default:throw new Error("THREE.Vector2: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;default:throw new Error("THREE.Vector2: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y)}copy(e){return this.x=e.x,this.y=e.y,this}add(e){return this.x+=e.x,this.y+=e.y,this}addScalar(e){return this.x+=e,this.y+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this}subScalar(e){return this.x-=e,this.y-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this}multiply(e){return this.x*=e.x,this.y*=e.y,this}multiplyScalar(e){return this.x*=e,this.y*=e,this}divide(e){return this.x/=e.x,this.y/=e.y,this}divideScalar(e){return this.multiplyScalar(1/e)}applyMatrix3(e){let t=this.x,i=this.y,s=e.elements;return this.x=s[0]*t+s[3]*i+s[6],this.y=s[1]*t+s[4]*i+s[7],this}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this}clamp(e,t){return this.x=V(this.x,e.x,t.x),this.y=V(this.y,e.y,t.y),this}clampScalar(e,t){return this.x=V(this.x,e,t),this.y=V(this.y,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(V(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this}negate(){return this.x=-this.x,this.y=-this.y,this}dot(e){return this.x*e.x+this.y*e.y}cross(e){return this.x*e.y-this.y*e.x}lengthSq(){return this.x*this.x+this.y*this.y}length(){return Math.sqrt(this.x*this.x+this.y*this.y)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)}normalize(){return this.divideScalar(this.length()||1)}angle(){return Math.atan2(-this.y,-this.x)+Math.PI}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(V(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y;return t*t+i*i}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this}equals(e){return e.x===this.x&&e.y===this.y}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this}rotateAround(e,t){let i=Math.cos(t),s=Math.sin(t),r=this.x-e.x,o=this.y-e.y;return this.x=r*i-o*s+e.x,this.y=r*s+o*i+e.y,this}random(){return this.x=Math.random(),this.y=Math.random(),this}*[Symbol.iterator](){yield this.x,yield this.y;}},pe=class{constructor(e=0,t=0,i=0,s=1){this.isQuaternion=true,this._x=e,this._y=t,this._z=i,this._w=s;}static slerpFlat(e,t,i,s,r,o,a){let c=i[s+0],l=i[s+1],u=i[s+2],d=i[s+3],m=r[o+0],p=r[o+1],_=r[o+2],f=r[o+3];if(d!==f||c!==m||l!==p||u!==_){let v=c*m+l*p+u*_+d*f;v<0&&(m=-m,p=-p,_=-_,f=-f,v=-v);let h=1-a;if(v<.9995){let x=Math.acos(v),g=Math.sin(x);h=Math.sin(h*x)/g,a=Math.sin(a*x)/g,c=c*h+m*a,l=l*h+p*a,u=u*h+_*a,d=d*h+f*a;}else {c=c*h+m*a,l=l*h+p*a,u=u*h+_*a,d=d*h+f*a;let x=1/Math.sqrt(c*c+l*l+u*u+d*d);c*=x,l*=x,u*=x,d*=x;}}e[t]=c,e[t+1]=l,e[t+2]=u,e[t+3]=d;}static multiplyQuaternionsFlat(e,t,i,s,r,o){let a=i[s],c=i[s+1],l=i[s+2],u=i[s+3],d=r[o],m=r[o+1],p=r[o+2],_=r[o+3];return e[t]=a*_+u*d+c*p-l*m,e[t+1]=c*_+u*m+l*d-a*p,e[t+2]=l*_+u*p+a*m-c*d,e[t+3]=u*_-a*d-c*m-l*p,e}get x(){return this._x}set x(e){this._x=e,this._onChangeCallback();}get y(){return this._y}set y(e){this._y=e,this._onChangeCallback();}get z(){return this._z}set z(e){this._z=e,this._onChangeCallback();}get w(){return this._w}set w(e){this._w=e,this._onChangeCallback();}set(e,t,i,s){return this._x=e,this._y=t,this._z=i,this._w=s,this._onChangeCallback(),this}clone(){return new this.constructor(this._x,this._y,this._z,this._w)}copy(e){return this._x=e.x,this._y=e.y,this._z=e.z,this._w=e.w,this._onChangeCallback(),this}setFromEuler(e,t=true){let i=e._x,s=e._y,r=e._z,o=e._order,a=Math.cos,c=Math.sin,l=a(i/2),u=a(s/2),d=a(r/2),m=c(i/2),p=c(s/2),_=c(r/2);switch(o){case "XYZ":this._x=m*u*d+l*p*_,this._y=l*p*d-m*u*_,this._z=l*u*_+m*p*d,this._w=l*u*d-m*p*_;break;case "YXZ":this._x=m*u*d+l*p*_,this._y=l*p*d-m*u*_,this._z=l*u*_-m*p*d,this._w=l*u*d+m*p*_;break;case "ZXY":this._x=m*u*d-l*p*_,this._y=l*p*d+m*u*_,this._z=l*u*_+m*p*d,this._w=l*u*d-m*p*_;break;case "ZYX":this._x=m*u*d-l*p*_,this._y=l*p*d+m*u*_,this._z=l*u*_-m*p*d,this._w=l*u*d+m*p*_;break;case "YZX":this._x=m*u*d+l*p*_,this._y=l*p*d+m*u*_,this._z=l*u*_-m*p*d,this._w=l*u*d-m*p*_;break;case "XZY":this._x=m*u*d-l*p*_,this._y=l*p*d-m*u*_,this._z=l*u*_+m*p*d,this._w=l*u*d+m*p*_;break;default:re("Quaternion: .setFromEuler() encountered an unknown order: "+o);}return t===true&&this._onChangeCallback(),this}setFromAxisAngle(e,t){let i=t/2,s=Math.sin(i);return this._x=e.x*s,this._y=e.y*s,this._z=e.z*s,this._w=Math.cos(i),this._onChangeCallback(),this}setFromRotationMatrix(e){let t=e.elements,i=t[0],s=t[4],r=t[8],o=t[1],a=t[5],c=t[9],l=t[2],u=t[6],d=t[10],m=i+a+d;if(m>0){let p=.5/Math.sqrt(m+1);this._w=.25/p,this._x=(u-c)*p,this._y=(r-l)*p,this._z=(o-s)*p;}else if(i>a&&i>d){let p=2*Math.sqrt(1+i-a-d);this._w=(u-c)/p,this._x=.25*p,this._y=(s+o)/p,this._z=(r+l)/p;}else if(a>d){let p=2*Math.sqrt(1+a-i-d);this._w=(r-l)/p,this._x=(s+o)/p,this._y=.25*p,this._z=(c+u)/p;}else {let p=2*Math.sqrt(1+d-i-a);this._w=(o-s)/p,this._x=(r+l)/p,this._y=(c+u)/p,this._z=.25*p;}return this._onChangeCallback(),this}setFromUnitVectors(e,t){let i=e.dot(t)+1;return i<1e-8?(i=0,Math.abs(e.x)>Math.abs(e.z)?(this._x=-e.y,this._y=e.x,this._z=0,this._w=i):(this._x=0,this._y=-e.z,this._z=e.y,this._w=i)):(this._x=e.y*t.z-e.z*t.y,this._y=e.z*t.x-e.x*t.z,this._z=e.x*t.y-e.y*t.x,this._w=i),this.normalize()}angleTo(e){return 2*Math.acos(Math.abs(V(this.dot(e),-1,1)))}rotateTowards(e,t){let i=this.angleTo(e);if(i===0)return this;let s=Math.min(1,t/i);return this.slerp(e,s),this}identity(){return this.set(0,0,0,1)}invert(){return this.conjugate()}conjugate(){return this._x*=-1,this._y*=-1,this._z*=-1,this._onChangeCallback(),this}dot(e){return this._x*e._x+this._y*e._y+this._z*e._z+this._w*e._w}lengthSq(){return this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w}length(){return Math.sqrt(this._x*this._x+this._y*this._y+this._z*this._z+this._w*this._w)}normalize(){let e=this.length();return e===0?(this._x=0,this._y=0,this._z=0,this._w=1):(e=1/e,this._x=this._x*e,this._y=this._y*e,this._z=this._z*e,this._w=this._w*e),this._onChangeCallback(),this}multiply(e){return this.multiplyQuaternions(this,e)}premultiply(e){return this.multiplyQuaternions(e,this)}multiplyQuaternions(e,t){let i=e._x,s=e._y,r=e._z,o=e._w,a=t._x,c=t._y,l=t._z,u=t._w;return this._x=i*u+o*a+s*l-r*c,this._y=s*u+o*c+r*a-i*l,this._z=r*u+o*l+i*c-s*a,this._w=o*u-i*a-s*c-r*l,this._onChangeCallback(),this}slerp(e,t){let i=e._x,s=e._y,r=e._z,o=e._w,a=this.dot(e);a<0&&(i=-i,s=-s,r=-r,o=-o,a=-a);let c=1-t;if(a<.9995){let l=Math.acos(a),u=Math.sin(l);c=Math.sin(c*l)/u,t=Math.sin(t*l)/u,this._x=this._x*c+i*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+o*t,this._onChangeCallback();}else this._x=this._x*c+i*t,this._y=this._y*c+s*t,this._z=this._z*c+r*t,this._w=this._w*c+o*t,this.normalize();return this}slerpQuaternions(e,t,i){return this.copy(e).slerp(t,i)}random(){let e=2*Math.PI*Math.random(),t=2*Math.PI*Math.random(),i=Math.random(),s=Math.sqrt(1-i),r=Math.sqrt(i);return this.set(s*Math.sin(e),s*Math.cos(e),r*Math.sin(t),r*Math.cos(t))}equals(e){return e._x===this._x&&e._y===this._y&&e._z===this._z&&e._w===this._w}fromArray(e,t=0){return this._x=e[t],this._y=e[t+1],this._z=e[t+2],this._w=e[t+3],this._onChangeCallback(),this}toArray(e=[],t=0){return e[t]=this._x,e[t+1]=this._y,e[t+2]=this._z,e[t+3]=this._w,e}fromBufferAttribute(e,t){return this._x=e.getX(t),this._y=e.getY(t),this._z=e.getZ(t),this._w=e.getW(t),this._onChangeCallback(),this}toJSON(){return this.toArray()}_onChange(e){return this._onChangeCallback=e,this}_onChangeCallback(){}*[Symbol.iterator](){yield this._x,yield this._y,yield this._z,yield this._w;}},K=class{static{this.prototype.isVector3=true;}constructor(e=0,t=0,i=0){this.x=e,this.y=t,this.z=i;}set(e,t,i){return i===void 0&&(i=this.z),this.x=e,this.y=t,this.z=i,this}setScalar(e){return this.x=e,this.y=e,this.z=e,this}setX(e){return this.x=e,this}setY(e){return this.y=e,this}setZ(e){return this.z=e,this}setComponent(e,t){switch(e){case 0:this.x=t;break;case 1:this.y=t;break;case 2:this.z=t;break;default:throw new Error("THREE.Vector3: index is out of range: "+e)}return this}getComponent(e){switch(e){case 0:return this.x;case 1:return this.y;case 2:return this.z;default:throw new Error("THREE.Vector3: index is out of range: "+e)}}clone(){return new this.constructor(this.x,this.y,this.z)}copy(e){return this.x=e.x,this.y=e.y,this.z=e.z,this}add(e){return this.x+=e.x,this.y+=e.y,this.z+=e.z,this}addScalar(e){return this.x+=e,this.y+=e,this.z+=e,this}addVectors(e,t){return this.x=e.x+t.x,this.y=e.y+t.y,this.z=e.z+t.z,this}addScaledVector(e,t){return this.x+=e.x*t,this.y+=e.y*t,this.z+=e.z*t,this}sub(e){return this.x-=e.x,this.y-=e.y,this.z-=e.z,this}subScalar(e){return this.x-=e,this.y-=e,this.z-=e,this}subVectors(e,t){return this.x=e.x-t.x,this.y=e.y-t.y,this.z=e.z-t.z,this}multiply(e){return this.x*=e.x,this.y*=e.y,this.z*=e.z,this}multiplyScalar(e){return this.x*=e,this.y*=e,this.z*=e,this}multiplyVectors(e,t){return this.x=e.x*t.x,this.y=e.y*t.y,this.z=e.z*t.z,this}applyEuler(e){return this.applyQuaternion(Is.setFromEuler(e))}applyAxisAngle(e,t){return this.applyQuaternion(Is.setFromAxisAngle(e,t))}applyMatrix3(e){let t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[3]*i+r[6]*s,this.y=r[1]*t+r[4]*i+r[7]*s,this.z=r[2]*t+r[5]*i+r[8]*s,this}applyNormalMatrix(e){return this.applyMatrix3(e).normalize()}applyMatrix4(e){let t=this.x,i=this.y,s=this.z,r=e.elements,o=1/(r[3]*t+r[7]*i+r[11]*s+r[15]);return this.x=(r[0]*t+r[4]*i+r[8]*s+r[12])*o,this.y=(r[1]*t+r[5]*i+r[9]*s+r[13])*o,this.z=(r[2]*t+r[6]*i+r[10]*s+r[14])*o,this}applyQuaternion(e){let t=this.x,i=this.y,s=this.z,r=e.x,o=e.y,a=e.z,c=e.w,l=2*(o*s-a*i),u=2*(a*t-r*s),d=2*(r*i-o*t);return this.x=t+c*l+o*d-a*u,this.y=i+c*u+a*l-r*d,this.z=s+c*d+r*u-o*l,this}project(e){return this.applyMatrix4(e.matrixWorldInverse).applyMatrix4(e.projectionMatrix)}unproject(e){return this.applyMatrix4(e.projectionMatrixInverse).applyMatrix4(e.matrixWorld)}transformDirection(e){let t=this.x,i=this.y,s=this.z,r=e.elements;return this.x=r[0]*t+r[4]*i+r[8]*s,this.y=r[1]*t+r[5]*i+r[9]*s,this.z=r[2]*t+r[6]*i+r[10]*s,this.normalize()}divide(e){return this.x/=e.x,this.y/=e.y,this.z/=e.z,this}divideScalar(e){return this.multiplyScalar(1/e)}min(e){return this.x=Math.min(this.x,e.x),this.y=Math.min(this.y,e.y),this.z=Math.min(this.z,e.z),this}max(e){return this.x=Math.max(this.x,e.x),this.y=Math.max(this.y,e.y),this.z=Math.max(this.z,e.z),this}clamp(e,t){return this.x=V(this.x,e.x,t.x),this.y=V(this.y,e.y,t.y),this.z=V(this.z,e.z,t.z),this}clampScalar(e,t){return this.x=V(this.x,e,t),this.y=V(this.y,e,t),this.z=V(this.z,e,t),this}clampLength(e,t){let i=this.length();return this.divideScalar(i||1).multiplyScalar(V(i,e,t))}floor(){return this.x=Math.floor(this.x),this.y=Math.floor(this.y),this.z=Math.floor(this.z),this}ceil(){return this.x=Math.ceil(this.x),this.y=Math.ceil(this.y),this.z=Math.ceil(this.z),this}round(){return this.x=Math.round(this.x),this.y=Math.round(this.y),this.z=Math.round(this.z),this}roundToZero(){return this.x=Math.trunc(this.x),this.y=Math.trunc(this.y),this.z=Math.trunc(this.z),this}negate(){return this.x=-this.x,this.y=-this.y,this.z=-this.z,this}dot(e){return this.x*e.x+this.y*e.y+this.z*e.z}lengthSq(){return this.x*this.x+this.y*this.y+this.z*this.z}length(){return Math.sqrt(this.x*this.x+this.y*this.y+this.z*this.z)}manhattanLength(){return Math.abs(this.x)+Math.abs(this.y)+Math.abs(this.z)}normalize(){return this.divideScalar(this.length()||1)}setLength(e){return this.normalize().multiplyScalar(e)}lerp(e,t){return this.x+=(e.x-this.x)*t,this.y+=(e.y-this.y)*t,this.z+=(e.z-this.z)*t,this}lerpVectors(e,t,i){return this.x=e.x+(t.x-e.x)*i,this.y=e.y+(t.y-e.y)*i,this.z=e.z+(t.z-e.z)*i,this}cross(e){return this.crossVectors(this,e)}crossVectors(e,t){let i=e.x,s=e.y,r=e.z,o=t.x,a=t.y,c=t.z;return this.x=s*c-r*a,this.y=r*o-i*c,this.z=i*a-s*o,this}projectOnVector(e){let t=e.lengthSq();if(t===0)return this.set(0,0,0);let i=e.dot(this)/t;return this.copy(e).multiplyScalar(i)}projectOnPlane(e){return Dn.copy(this).projectOnVector(e),this.sub(Dn)}reflect(e){return this.sub(Dn.copy(e).multiplyScalar(2*this.dot(e)))}angleTo(e){let t=Math.sqrt(this.lengthSq()*e.lengthSq());if(t===0)return Math.PI/2;let i=this.dot(e)/t;return Math.acos(V(i,-1,1))}distanceTo(e){return Math.sqrt(this.distanceToSquared(e))}distanceToSquared(e){let t=this.x-e.x,i=this.y-e.y,s=this.z-e.z;return t*t+i*i+s*s}manhattanDistanceTo(e){return Math.abs(this.x-e.x)+Math.abs(this.y-e.y)+Math.abs(this.z-e.z)}setFromSpherical(e){return this.setFromSphericalCoords(e.radius,e.phi,e.theta)}setFromSphericalCoords(e,t,i){let s=Math.sin(t)*e;return this.x=s*Math.sin(i),this.y=Math.cos(t)*e,this.z=s*Math.cos(i),this}setFromCylindrical(e){return this.setFromCylindricalCoords(e.radius,e.theta,e.y)}setFromCylindricalCoords(e,t,i){return this.x=e*Math.sin(t),this.y=i,this.z=e*Math.cos(t),this}setFromMatrixPosition(e){let t=e.elements;return this.x=t[12],this.y=t[13],this.z=t[14],this}setFromMatrixScale(e){let t=this.setFromMatrixColumn(e,0).length(),i=this.setFromMatrixColumn(e,1).length(),s=this.setFromMatrixColumn(e,2).length();return this.x=t,this.y=i,this.z=s,this}setFromMatrixColumn(e,t){return this.fromArray(e.elements,t*4)}setFromMatrix3Column(e,t){return this.fromArray(e.elements,t*3)}setFromEuler(e){return this.x=e._x,this.y=e._y,this.z=e._z,this}setFromColor(e){return this.x=e.r,this.y=e.g,this.z=e.b,this}equals(e){return e.x===this.x&&e.y===this.y&&e.z===this.z}fromArray(e,t=0){return this.x=e[t],this.y=e[t+1],this.z=e[t+2],this}toArray(e=[],t=0){return e[t]=this.x,e[t+1]=this.y,e[t+2]=this.z,e}fromBufferAttribute(e,t){return this.x=e.getX(t),this.y=e.getY(t),this.z=e.getZ(t),this}random(){return this.x=Math.random(),this.y=Math.random(),this.z=Math.random(),this}randomDirection(){let e=Math.random()*Math.PI*2,t=Math.random()*2-1,i=Math.sqrt(1-t*t);return this.x=i*Math.cos(e),this.y=t,this.z=i*Math.sin(e),this}*[Symbol.iterator](){yield this.x,yield this.y,yield this.z;}},Dn=new K,Is=new pe,L=class{static{this.prototype.isMatrix3=true;}constructor(e,t,i,s,r,o,a,c,l){this.elements=[1,0,0,0,1,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,o,a,c,l);}set(e,t,i,s,r,o,a,c,l){let u=this.elements;return u[0]=e,u[1]=s,u[2]=a,u[3]=t,u[4]=r,u[5]=c,u[6]=i,u[7]=o,u[8]=l,this}identity(){return this.set(1,0,0,0,1,0,0,0,1),this}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],this}extractBasis(e,t,i){return e.setFromMatrix3Column(this,0),t.setFromMatrix3Column(this,1),i.setFromMatrix3Column(this,2),this}setFromMatrix4(e){let t=e.elements;return this.set(t[0],t[4],t[8],t[1],t[5],t[9],t[2],t[6],t[10]),this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,s=t.elements,r=this.elements,o=i[0],a=i[3],c=i[6],l=i[1],u=i[4],d=i[7],m=i[2],p=i[5],_=i[8],f=s[0],v=s[3],h=s[6],x=s[1],g=s[4],y=s[7],M=s[2],S=s[5],b=s[8];return r[0]=o*f+a*x+c*M,r[3]=o*v+a*g+c*S,r[6]=o*h+a*y+c*b,r[1]=l*f+u*x+d*M,r[4]=l*v+u*g+d*S,r[7]=l*h+u*y+d*b,r[2]=m*f+p*x+_*M,r[5]=m*v+p*g+_*S,r[8]=m*h+p*y+_*b,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[3]*=e,t[6]*=e,t[1]*=e,t[4]*=e,t[7]*=e,t[2]*=e,t[5]*=e,t[8]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8];return t*o*u-t*a*l-i*r*u+i*a*c+s*r*l-s*o*c}invert(){let e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=u*o-a*l,m=a*c-u*r,p=l*r-o*c,_=t*d+i*m+s*p;if(_===0)return this.set(0,0,0,0,0,0,0,0,0);let f=1/_;return e[0]=d*f,e[1]=(s*l-u*i)*f,e[2]=(a*i-s*o)*f,e[3]=m*f,e[4]=(u*t-s*c)*f,e[5]=(s*r-a*t)*f,e[6]=p*f,e[7]=(i*c-l*t)*f,e[8]=(o*t-i*r)*f,this}transpose(){let e,t=this.elements;return e=t[1],t[1]=t[3],t[3]=e,e=t[2],t[2]=t[6],t[6]=e,e=t[5],t[5]=t[7],t[7]=e,this}getNormalMatrix(e){return this.setFromMatrix4(e).invert().transpose()}transposeIntoArray(e){let t=this.elements;return e[0]=t[0],e[1]=t[3],e[2]=t[6],e[3]=t[1],e[4]=t[4],e[5]=t[7],e[6]=t[2],e[7]=t[5],e[8]=t[8],this}setUvTransform(e,t,i,s,r,o,a){let c=Math.cos(r),l=Math.sin(r);return this.set(i*c,i*l,-i*(c*o+l*a)+o+e,-s*l,s*c,-s*(-l*o+c*a)+a+t,0,0,1),this}scale(e,t){return tn("Matrix3: .scale() is deprecated. Use .makeScale() instead."),this.premultiply(Fn.makeScale(e,t)),this}rotate(e){return tn("Matrix3: .rotate() is deprecated. Use .makeRotation() instead."),this.premultiply(Fn.makeRotation(-e)),this}translate(e,t){return tn("Matrix3: .translate() is deprecated. Use .makeTranslation() instead."),this.premultiply(Fn.makeTranslation(e,t)),this}makeTranslation(e,t){return e.isVector2?this.set(1,0,e.x,0,1,e.y,0,0,1):this.set(1,0,e,0,1,t,0,0,1),this}makeRotation(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,i,t,0,0,0,1),this}makeScale(e,t){return this.set(e,0,0,0,t,0,0,0,1),this}equals(e){let t=this.elements,i=e.elements;for(let s=0;s<9;s++)if(t[s]!==i[s])return false;return true}fromArray(e,t=0){for(let i=0;i<9;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e}clone(){return new this.constructor().fromArray(this.elements)}},Fn=new L,Ns=new L().set(.4123908,.3575843,.1804808,.212639,.7151687,.0721923,.0193308,.1191948,.9505322),Ps=new L().set(3.2409699,-1.5373832,-0.4986108,-0.9692436,1.8759675,.0415551,.0556301,-0.203977,1.0569715);function Jc(){let n={enabled:true,workingColorSpace:ti,spaces:{},convert:function(s,r,o){return this.enabled===false||r===o||!r||!o||(this.spaces[r].transfer===en&&(s.r=Le(s.r),s.g=Le(s.g),s.b=Le(s.b)),this.spaces[r].primaries!==this.spaces[o].primaries&&(s.applyMatrix3(this.spaces[r].toXYZ),s.applyMatrix3(this.spaces[o].fromXYZ)),this.spaces[o].transfer===en&&(s.r=xt(s.r),s.g=xt(s.g),s.b=xt(s.b))),s},workingToColorSpace:function(s,r){return this.convert(s,this.workingColorSpace,r)},colorSpaceToWorking:function(s,r){return this.convert(s,r,this.workingColorSpace)},getPrimaries:function(s){return this.spaces[s].primaries},getTransfer:function(s){return s===gi?ni:this.spaces[s].transfer},getToneMappingMode:function(s){return this.spaces[s].outputColorSpaceConfig.toneMappingMode||"standard"},getLuminanceCoefficients:function(s,r=this.workingColorSpace){return s.fromArray(this.spaces[r].luminanceCoefficients)},define:function(s){Object.assign(this.spaces,s);},_getMatrix:function(s,r,o){return s.copy(this.spaces[o].fromXYZ).multiply(this.spaces[r].toXYZ)},_getDrawingBufferColorSpace:function(s){return this.spaces[s].outputColorSpaceConfig.drawingBufferColorSpace},_getUnpackColorSpace:function(s=this.workingColorSpace){return this.spaces[s].workingColorSpaceConfig.unpackColorSpace}},e=[.64,.33,.3,.6,.15,.06],t=[.2126,.7152,.0722],i=[.3127,.329];return n.define({[ti]:{primaries:e,whitePoint:i,transfer:ni,toXYZ:Ns,fromXYZ:Ps,luminanceCoefficients:t,workingColorSpaceConfig:{unpackColorSpace:xe},outputColorSpaceConfig:{drawingBufferColorSpace:xe}},[xe]:{primaries:e,whitePoint:i,transfer:en,toXYZ:Ns,fromXYZ:Ps,luminanceCoefficients:t,outputColorSpaceConfig:{drawingBufferColorSpace:xe}}}),n}var _e=Jc();function Le(n){return n<.04045?n*.0773993808:Math.pow(n*.9478672986+.0521327014,2.4)}function xt(n){return n<.0031308?n*12.92:1.055*Math.pow(n,.41666)-.055}var ye=class n{static{this.prototype.isMatrix4=true;}constructor(e,t,i,s,r,o,a,c,l,u,d,m,p,_,f,v){this.elements=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1],e!==void 0&&this.set(e,t,i,s,r,o,a,c,l,u,d,m,p,_,f,v);}set(e,t,i,s,r,o,a,c,l,u,d,m,p,_,f,v){let h=this.elements;return h[0]=e,h[4]=t,h[8]=i,h[12]=s,h[1]=r,h[5]=o,h[9]=a,h[13]=c,h[2]=l,h[6]=u,h[10]=d,h[14]=m,h[3]=p,h[7]=_,h[11]=f,h[15]=v,this}identity(){return this.set(1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1),this}clone(){return new n().fromArray(this.elements)}copy(e){let t=this.elements,i=e.elements;return t[0]=i[0],t[1]=i[1],t[2]=i[2],t[3]=i[3],t[4]=i[4],t[5]=i[5],t[6]=i[6],t[7]=i[7],t[8]=i[8],t[9]=i[9],t[10]=i[10],t[11]=i[11],t[12]=i[12],t[13]=i[13],t[14]=i[14],t[15]=i[15],this}copyPosition(e){let t=this.elements,i=e.elements;return t[12]=i[12],t[13]=i[13],t[14]=i[14],this}setFromMatrix3(e){let t=e.elements;return this.set(t[0],t[3],t[6],0,t[1],t[4],t[7],0,t[2],t[5],t[8],0,0,0,0,1),this}extractBasis(e,t,i){return this.determinantAffine()===0?(e.set(1,0,0),t.set(0,1,0),i.set(0,0,1),this):(e.setFromMatrixColumn(this,0),t.setFromMatrixColumn(this,1),i.setFromMatrixColumn(this,2),this)}makeBasis(e,t,i){return this.set(e.x,t.x,i.x,0,e.y,t.y,i.y,0,e.z,t.z,i.z,0,0,0,0,1),this}extractRotation(e){if(e.determinantAffine()===0)return this.identity();let t=this.elements,i=e.elements,s=1/pt.setFromMatrixColumn(e,0).length(),r=1/pt.setFromMatrixColumn(e,1).length(),o=1/pt.setFromMatrixColumn(e,2).length();return t[0]=i[0]*s,t[1]=i[1]*s,t[2]=i[2]*s,t[3]=0,t[4]=i[4]*r,t[5]=i[5]*r,t[6]=i[6]*r,t[7]=0,t[8]=i[8]*o,t[9]=i[9]*o,t[10]=i[10]*o,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromEuler(e){let t=this.elements,i=e.x,s=e.y,r=e.z,o=Math.cos(i),a=Math.sin(i),c=Math.cos(s),l=Math.sin(s),u=Math.cos(r),d=Math.sin(r);if(e.order==="XYZ"){let m=o*u,p=o*d,_=a*u,f=a*d;t[0]=c*u,t[4]=-c*d,t[8]=l,t[1]=p+_*l,t[5]=m-f*l,t[9]=-a*c,t[2]=f-m*l,t[6]=_+p*l,t[10]=o*c;}else if(e.order==="YXZ"){let m=c*u,p=c*d,_=l*u,f=l*d;t[0]=m+f*a,t[4]=_*a-p,t[8]=o*l,t[1]=o*d,t[5]=o*u,t[9]=-a,t[2]=p*a-_,t[6]=f+m*a,t[10]=o*c;}else if(e.order==="ZXY"){let m=c*u,p=c*d,_=l*u,f=l*d;t[0]=m-f*a,t[4]=-o*d,t[8]=_+p*a,t[1]=p+_*a,t[5]=o*u,t[9]=f-m*a,t[2]=-o*l,t[6]=a,t[10]=o*c;}else if(e.order==="ZYX"){let m=o*u,p=o*d,_=a*u,f=a*d;t[0]=c*u,t[4]=_*l-p,t[8]=m*l+f,t[1]=c*d,t[5]=f*l+m,t[9]=p*l-_,t[2]=-l,t[6]=a*c,t[10]=o*c;}else if(e.order==="YZX"){let m=o*c,p=o*l,_=a*c,f=a*l;t[0]=c*u,t[4]=f-m*d,t[8]=_*d+p,t[1]=d,t[5]=o*u,t[9]=-a*u,t[2]=-l*u,t[6]=p*d+_,t[10]=m-f*d;}else if(e.order==="XZY"){let m=o*c,p=o*l,_=a*c,f=a*l;t[0]=c*u,t[4]=-d,t[8]=l*u,t[1]=m*d+f,t[5]=o*u,t[9]=p*d-_,t[2]=_*d-p,t[6]=a*u,t[10]=f*d+m;}return t[3]=0,t[7]=0,t[11]=0,t[12]=0,t[13]=0,t[14]=0,t[15]=1,this}makeRotationFromQuaternion(e){return this.compose(el,e,tl)}lookAt(e,t,i){let s=this.elements;return de.subVectors(e,t),de.lengthSq()===0&&(de.z=1),de.normalize(),nt.crossVectors(i,de),nt.lengthSq()===0&&(Math.abs(i.z)===1?de.x+=1e-4:de.z+=1e-4,de.normalize(),nt.crossVectors(i,de)),nt.normalize(),jt.crossVectors(de,nt),s[0]=nt.x,s[4]=jt.x,s[8]=de.x,s[1]=nt.y,s[5]=jt.y,s[9]=de.y,s[2]=nt.z,s[6]=jt.z,s[10]=de.z,this}multiply(e){return this.multiplyMatrices(this,e)}premultiply(e){return this.multiplyMatrices(e,this)}multiplyMatrices(e,t){let i=e.elements,s=t.elements,r=this.elements,o=i[0],a=i[4],c=i[8],l=i[12],u=i[1],d=i[5],m=i[9],p=i[13],_=i[2],f=i[6],v=i[10],h=i[14],x=i[3],g=i[7],y=i[11],M=i[15],S=s[0],b=s[4],A=s[8],w=s[12],R=s[1],U=s[5],G=s[9],I=s[13],O=s[2],D=s[6],Q=s[10],j=s[14],we=s[3],Me=s[7],Ae=s[11],Ce=s[15];return r[0]=o*S+a*R+c*O+l*we,r[4]=o*b+a*U+c*D+l*Me,r[8]=o*A+a*G+c*Q+l*Ae,r[12]=o*w+a*I+c*j+l*Ce,r[1]=u*S+d*R+m*O+p*we,r[5]=u*b+d*U+m*D+p*Me,r[9]=u*A+d*G+m*Q+p*Ae,r[13]=u*w+d*I+m*j+p*Ce,r[2]=_*S+f*R+v*O+h*we,r[6]=_*b+f*U+v*D+h*Me,r[10]=_*A+f*G+v*Q+h*Ae,r[14]=_*w+f*I+v*j+h*Ce,r[3]=x*S+g*R+y*O+M*we,r[7]=x*b+g*U+y*D+M*Me,r[11]=x*A+g*G+y*Q+M*Ae,r[15]=x*w+g*I+y*j+M*Ce,this}multiplyScalar(e){let t=this.elements;return t[0]*=e,t[4]*=e,t[8]*=e,t[12]*=e,t[1]*=e,t[5]*=e,t[9]*=e,t[13]*=e,t[2]*=e,t[6]*=e,t[10]*=e,t[14]*=e,t[3]*=e,t[7]*=e,t[11]*=e,t[15]*=e,this}determinant(){let e=this.elements,t=e[0],i=e[4],s=e[8],r=e[12],o=e[1],a=e[5],c=e[9],l=e[13],u=e[2],d=e[6],m=e[10],p=e[14],_=e[3],f=e[7],v=e[11],h=e[15],x=c*p-l*m,g=a*p-l*d,y=a*m-c*d,M=o*p-l*u,S=o*m-c*u,b=o*d-a*u;return t*(f*x-v*g+h*y)-i*(_*x-v*M+h*S)+s*(_*g-f*M+h*b)-r*(_*y-f*S+v*b)}determinantAffine(){let e=this.elements,t=e[0],i=e[4],s=e[8],r=e[1],o=e[5],a=e[9],c=e[2],l=e[6],u=e[10];return t*(o*u-a*l)-i*(r*u-a*c)+s*(r*l-o*c)}transpose(){let e=this.elements,t;return t=e[1],e[1]=e[4],e[4]=t,t=e[2],e[2]=e[8],e[8]=t,t=e[6],e[6]=e[9],e[9]=t,t=e[3],e[3]=e[12],e[12]=t,t=e[7],e[7]=e[13],e[13]=t,t=e[11],e[11]=e[14],e[14]=t,this}setPosition(e,t,i){let s=this.elements;return e.isVector3?(s[12]=e.x,s[13]=e.y,s[14]=e.z):(s[12]=e,s[13]=t,s[14]=i),this}invert(){let e=this.elements,t=e[0],i=e[1],s=e[2],r=e[3],o=e[4],a=e[5],c=e[6],l=e[7],u=e[8],d=e[9],m=e[10],p=e[11],_=e[12],f=e[13],v=e[14],h=e[15],x=t*a-i*o,g=t*c-s*o,y=t*l-r*o,M=i*c-s*a,S=i*l-r*a,b=s*l-r*c,A=u*f-d*_,w=u*v-m*_,R=u*h-p*_,U=d*v-m*f,G=d*h-p*f,I=m*h-p*v,O=x*I-g*G+y*U+M*R-S*w+b*A;if(O===0)return this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0);let D=1/O;return e[0]=(a*I-c*G+l*U)*D,e[1]=(s*G-i*I-r*U)*D,e[2]=(f*b-v*S+h*M)*D,e[3]=(m*S-d*b-p*M)*D,e[4]=(c*R-o*I-l*w)*D,e[5]=(t*I-s*R+r*w)*D,e[6]=(v*y-_*b-h*g)*D,e[7]=(u*b-m*y+p*g)*D,e[8]=(o*G-a*R+l*A)*D,e[9]=(i*R-t*G-r*A)*D,e[10]=(_*S-f*y+h*x)*D,e[11]=(d*y-u*S-p*x)*D,e[12]=(a*w-o*U-c*A)*D,e[13]=(t*U-i*w+s*A)*D,e[14]=(f*g-_*M-v*x)*D,e[15]=(u*M-d*g+m*x)*D,this}scale(e){let t=this.elements,i=e.x,s=e.y,r=e.z;return t[0]*=i,t[4]*=s,t[8]*=r,t[1]*=i,t[5]*=s,t[9]*=r,t[2]*=i,t[6]*=s,t[10]*=r,t[3]*=i,t[7]*=s,t[11]*=r,this}getMaxScaleOnAxis(){let e=this.elements,t=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],i=e[4]*e[4]+e[5]*e[5]+e[6]*e[6],s=e[8]*e[8]+e[9]*e[9]+e[10]*e[10];return Math.sqrt(Math.max(t,i,s))}makeTranslation(e,t,i){return e.isVector3?this.set(1,0,0,e.x,0,1,0,e.y,0,0,1,e.z,0,0,0,1):this.set(1,0,0,e,0,1,0,t,0,0,1,i,0,0,0,1),this}makeRotationX(e){let t=Math.cos(e),i=Math.sin(e);return this.set(1,0,0,0,0,t,-i,0,0,i,t,0,0,0,0,1),this}makeRotationY(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,0,i,0,0,1,0,0,-i,0,t,0,0,0,0,1),this}makeRotationZ(e){let t=Math.cos(e),i=Math.sin(e);return this.set(t,-i,0,0,i,t,0,0,0,0,1,0,0,0,0,1),this}makeRotationAxis(e,t){let i=Math.cos(t),s=Math.sin(t),r=1-i,o=e.x,a=e.y,c=e.z,l=r*o,u=r*a;return this.set(l*o+i,l*a-s*c,l*c+s*a,0,l*a+s*c,u*a+i,u*c-s*o,0,l*c-s*a,u*c+s*o,r*c*c+i,0,0,0,0,1),this}makeScale(e,t,i){return this.set(e,0,0,0,0,t,0,0,0,0,i,0,0,0,0,1),this}makeShear(e,t,i,s,r,o){return this.set(1,i,r,0,e,1,o,0,t,s,1,0,0,0,0,1),this}compose(e,t,i){let s=this.elements,r=t._x,o=t._y,a=t._z,c=t._w,l=r+r,u=o+o,d=a+a,m=r*l,p=r*u,_=r*d,f=o*u,v=o*d,h=a*d,x=c*l,g=c*u,y=c*d,M=i.x,S=i.y,b=i.z;return s[0]=(1-(f+h))*M,s[1]=(p+y)*M,s[2]=(_-g)*M,s[3]=0,s[4]=(p-y)*S,s[5]=(1-(m+h))*S,s[6]=(v+x)*S,s[7]=0,s[8]=(_+g)*b,s[9]=(v-x)*b,s[10]=(1-(m+f))*b,s[11]=0,s[12]=e.x,s[13]=e.y,s[14]=e.z,s[15]=1,this}decompose(e,t,i){let s=this.elements;e.x=s[12],e.y=s[13],e.z=s[14];let r=this.determinantAffine();if(r===0)return i.set(1,1,1),t.identity(),this;let o=pt.set(s[0],s[1],s[2]).length(),a=pt.set(s[4],s[5],s[6]).length(),c=pt.set(s[8],s[9],s[10]).length();r<0&&(o=-o),be.copy(this);let l=1/o,u=1/a,d=1/c;return be.elements[0]*=l,be.elements[1]*=l,be.elements[2]*=l,be.elements[4]*=u,be.elements[5]*=u,be.elements[6]*=u,be.elements[8]*=d,be.elements[9]*=d,be.elements[10]*=d,t.setFromRotationMatrix(be),i.x=o,i.y=a,i.z=c,this}makePerspective(e,t,i,s,r,o,a=Rt,c=false){let l=this.elements,u=2*r/(t-e),d=2*r/(i-s),m=(t+e)/(t-e),p=(i+s)/(i-s),_,f;if(c)_=r/(o-r),f=o*r/(o-r);else if(a===Rt)_=-(o+r)/(o-r),f=-2*o*r/(o-r);else if(a===ii)_=-o/(o-r),f=-o*r/(o-r);else throw new Error("THREE.Matrix4.makePerspective(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=m,l[12]=0,l[1]=0,l[5]=d,l[9]=p,l[13]=0,l[2]=0,l[6]=0,l[10]=_,l[14]=f,l[3]=0,l[7]=0,l[11]=-1,l[15]=0,this}makeOrthographic(e,t,i,s,r,o,a=Rt,c=false){let l=this.elements,u=2/(t-e),d=2/(i-s),m=-(t+e)/(t-e),p=-(i+s)/(i-s),_,f;if(c)_=1/(o-r),f=o/(o-r);else if(a===Rt)_=-2/(o-r),f=-(o+r)/(o-r);else if(a===ii)_=-1/(o-r),f=-r/(o-r);else throw new Error("THREE.Matrix4.makeOrthographic(): Invalid coordinate system: "+a);return l[0]=u,l[4]=0,l[8]=0,l[12]=m,l[1]=0,l[5]=d,l[9]=0,l[13]=p,l[2]=0,l[6]=0,l[10]=_,l[14]=f,l[3]=0,l[7]=0,l[11]=0,l[15]=1,this}equals(e){let t=this.elements,i=e.elements;for(let s=0;s<16;s++)if(t[s]!==i[s])return false;return true}fromArray(e,t=0){for(let i=0;i<16;i++)this.elements[i]=e[i+t];return this}toArray(e=[],t=0){let i=this.elements;return e[t]=i[0],e[t+1]=i[1],e[t+2]=i[2],e[t+3]=i[3],e[t+4]=i[4],e[t+5]=i[5],e[t+6]=i[6],e[t+7]=i[7],e[t+8]=i[8],e[t+9]=i[9],e[t+10]=i[10],e[t+11]=i[11],e[t+12]=i[12],e[t+13]=i[13],e[t+14]=i[14],e[t+15]=i[15],e}},pt=new K,be=new ye,el=new K(0,0,0),tl=new K(1,1,1),nt=new K,jt=new K,de=new K;new ye;new ye;var er={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074},it={h:0,s:0,l:0},Jt={h:0,s:0,l:0};function Gn(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*6*(2/3-t):n}var te=class{constructor(e,t,i){return this.isColor=true,this.r=1,this.g=1,this.b=1,this.set(e,t,i)}set(e,t,i){if(t===void 0&&i===void 0){let s=e;s&&s.isColor?this.copy(s):typeof s=="number"?this.setHex(s):typeof s=="string"&&this.setStyle(s);}else this.setRGB(e,t,i);return this}setScalar(e){return this.r=e,this.g=e,this.b=e,this}setHex(e,t=xe){return e=Math.floor(e),this.r=(e>>16&255)/255,this.g=(e>>8&255)/255,this.b=(e&255)/255,_e.colorSpaceToWorking(this,t),this}setRGB(e,t,i,s=_e.workingColorSpace){return this.r=e,this.g=t,this.b=i,_e.colorSpaceToWorking(this,s),this}setHSL(e,t,i,s=_e.workingColorSpace){if(e=$c(e,1),t=V(t,0,1),i=V(i,0,1),t===0)this.r=this.g=this.b=i;else {let r=i<=.5?i*(1+t):i+t-i*t,o=2*i-r;this.r=Gn(o,r,e+1/3),this.g=Gn(o,r,e),this.b=Gn(o,r,e-1/3);}return _e.colorSpaceToWorking(this,s),this}setStyle(e,t=xe){function i(r){r!==void 0&&parseFloat(r)<1&&re("Color: Alpha component of "+e+" will be ignored.");}let s;if(s=/^(\w+)\(([^\)]*)\)/.exec(e)){let r,o=s[1],a=s[2];switch(o){case "rgb":case "rgba":if(r=/^\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(255,parseInt(r[1],10))/255,Math.min(255,parseInt(r[2],10))/255,Math.min(255,parseInt(r[3],10))/255,t);if(r=/^\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return i(r[4]),this.setRGB(Math.min(100,parseFloat(r[1]))/100,Math.min(100,parseFloat(r[2]))/100,Math.min(100,parseFloat(r[3]))/100,t);break;case "hsl":case "hsla":if(r=/^\s*([+-]?(?:\d+(?:\.\d+)?|\.\d+))\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*,\s*(\d+(?:\.\d+)?|\.\d+)\%\s*(?:,\s*(\d+(?:\.\d+)?|\.\d+)\s*)?$/.exec(a))return i(r[4]),this.setHSL(parseFloat(r[1])/360,parseFloat(r[2])/100,parseFloat(r[3])/100,t);break;default:re("Color: Unknown color model "+e);}}else if(s=/^\#([A-Fa-f\d]+)$/.exec(e)){let r=s[1],o=r.length;if(o===3)return this.setRGB(parseInt(r.charAt(0),16)/15,parseInt(r.charAt(1),16)/15,parseInt(r.charAt(2),16)/15,t);if(o===6)return this.setHex(parseInt(r,16),t);re("Color: Invalid hex color "+e);}else if(e&&e.length>0)return this.setColorName(e,t);return this}setColorName(e,t=xe){let i=er[e.toLowerCase()];return i!==void 0?this.setHex(i,t):re("Color: Unknown color "+e),this}clone(){return new this.constructor(this.r,this.g,this.b)}copy(e){return this.r=e.r,this.g=e.g,this.b=e.b,this}copySRGBToLinear(e){return this.r=Le(e.r),this.g=Le(e.g),this.b=Le(e.b),this}copyLinearToSRGB(e){return this.r=xt(e.r),this.g=xt(e.g),this.b=xt(e.b),this}convertSRGBToLinear(){return this.copySRGBToLinear(this),this}convertLinearToSRGB(){return this.copyLinearToSRGB(this),this}getHex(e=xe){return _e.workingToColorSpace(se.copy(this),e),Math.round(V(se.r*255,0,255))*65536+Math.round(V(se.g*255,0,255))*256+Math.round(V(se.b*255,0,255))}getHexString(e=xe){return ("000000"+this.getHex(e).toString(16)).slice(-6)}getHSL(e,t=_e.workingColorSpace){_e.workingToColorSpace(se.copy(this),t);let i=se.r,s=se.g,r=se.b,o=Math.max(i,s,r),a=Math.min(i,s,r),c,l,u=(a+o)/2;if(a===o)c=0,l=0;else {let d=o-a;switch(l=u<=.5?d/(o+a):d/(2-o-a),o){case i:c=(s-r)/d+(s<r?6:0);break;case s:c=(r-i)/d+2;break;case r:c=(i-s)/d+4;break}c/=6;}return e.h=c,e.s=l,e.l=u,e}getRGB(e,t=_e.workingColorSpace){return _e.workingToColorSpace(se.copy(this),t),e.r=se.r,e.g=se.g,e.b=se.b,e}getStyle(e=xe){_e.workingToColorSpace(se.copy(this),e);let t=se.r,i=se.g,s=se.b;return e!==xe?`color(${e} ${t.toFixed(3)} ${i.toFixed(3)} ${s.toFixed(3)})`:`rgb(${Math.round(t*255)},${Math.round(i*255)},${Math.round(s*255)})`}offsetHSL(e,t,i){return this.getHSL(it),this.setHSL(it.h+e,it.s+t,it.l+i)}add(e){return this.r+=e.r,this.g+=e.g,this.b+=e.b,this}addColors(e,t){return this.r=e.r+t.r,this.g=e.g+t.g,this.b=e.b+t.b,this}addScalar(e){return this.r+=e,this.g+=e,this.b+=e,this}sub(e){return this.r=Math.max(0,this.r-e.r),this.g=Math.max(0,this.g-e.g),this.b=Math.max(0,this.b-e.b),this}multiply(e){return this.r*=e.r,this.g*=e.g,this.b*=e.b,this}multiplyScalar(e){return this.r*=e,this.g*=e,this.b*=e,this}lerp(e,t){return this.r+=(e.r-this.r)*t,this.g+=(e.g-this.g)*t,this.b+=(e.b-this.b)*t,this}lerpColors(e,t,i){return this.r=e.r+(t.r-e.r)*i,this.g=e.g+(t.g-e.g)*i,this.b=e.b+(t.b-e.b)*i,this}lerpHSL(e,t){this.getHSL(it),e.getHSL(Jt);let i=Ln(it.h,Jt.h,t),s=Ln(it.s,Jt.s,t),r=Ln(it.l,Jt.l,t);return this.setHSL(i,s,r),this}setFromVector3(e){return this.r=e.x,this.g=e.y,this.b=e.z,this}applyMatrix3(e){let t=this.r,i=this.g,s=this.b,r=e.elements;return this.r=r[0]*t+r[3]*i+r[6]*s,this.g=r[1]*t+r[4]*i+r[7]*s,this.b=r[2]*t+r[5]*i+r[8]*s,this}equals(e){return e.r===this.r&&e.g===this.g&&e.b===this.b}fromArray(e,t=0){return this.r=e[t],this.g=e[t+1],this.b=e[t+2],this}toArray(e=[],t=0){return e[t]=this.r,e[t+1]=this.g,e[t+2]=this.b,e}fromBufferAttribute(e,t){return this.r=e.getX(t),this.g=e.getY(t),this.b=e.getZ(t),this}toJSON(){return this.getHex()}*[Symbol.iterator](){yield this.r,yield this.g,yield this.b;}},se=new te;te.NAMES=er;function tr(n){let e={};for(let t in n){e[t]={};for(let i in n[t]){let s=n[t][i];if(Gs(s))s.isRenderTargetTexture?(re("UniformsUtils: Textures of render targets cannot be cloned via cloneUniforms() or mergeUniforms()."),e[t][i]=null):e[t][i]=s.clone();else if(Array.isArray(s))if(Gs(s[0])){let r=[];for(let o=0,a=s.length;o<a;o++)r[o]=s[o].clone();e[t][i]=r;}else e[t][i]=s.slice();else e[t][i]=s;}}return e}function ce(n){let e={};for(let t=0;t<n.length;t++){let i=tr(n[t]);for(let s in i)e[s]=i[s];}return e}function Gs(n){return n&&(n.isColor||n.isMatrix3||n.isMatrix4||n.isVector2||n.isVector3||n.isVector4||n.isTexture||n.isQuaternion)}var xi="\\[\\]\\.:\\/",yi="[^"+xi+"]",ll="[^"+xi.replace("\\.","")+"]";/((?:WC+[\/:])*)/.source.replace("WC",yi);/(WCOD+)?/.source.replace("WCOD",ll);/(?:\.(WC+)(?:\[(.+)\])?)?/.source.replace("WC",yi);/\.(WC+)(?:\[(.+)\])?/.source.replace("WC",yi);typeof __THREE_DEVTOOLS__<"u"&&__THREE_DEVTOOLS__.dispatchEvent(new CustomEvent("register",{detail:{revision:"187"}}));typeof window<"u"&&(window.__THREE__?re("WARNING: Multiple instances of Three.js being imported."):window.__THREE__="187");var Vh=`#define STANDARD
|
|
2
|
+
varying vec3 vViewPosition;
|
|
3
|
+
#ifdef USE_TRANSMISSION
|
|
4
|
+
varying vec3 vWorldPosition;
|
|
5
|
+
#endif
|
|
6
|
+
#include <common>
|
|
7
|
+
#include <batching_pars_vertex>
|
|
8
|
+
#include <uv_pars_vertex>
|
|
9
|
+
#include <displacementmap_pars_vertex>
|
|
10
|
+
#include <color_pars_vertex>
|
|
11
|
+
#include <fog_pars_vertex>
|
|
12
|
+
#include <normal_pars_vertex>
|
|
13
|
+
#include <morphtarget_pars_vertex>
|
|
14
|
+
#include <skinning_pars_vertex>
|
|
15
|
+
#include <shadowmap_pars_vertex>
|
|
16
|
+
#include <logdepthbuf_pars_vertex>
|
|
17
|
+
#include <clipping_planes_pars_vertex>
|
|
18
|
+
void main() {
|
|
19
|
+
#include <uv_vertex>
|
|
20
|
+
#include <color_vertex>
|
|
21
|
+
#include <morphinstance_vertex>
|
|
22
|
+
#include <morphcolor_vertex>
|
|
23
|
+
#include <batching_vertex>
|
|
24
|
+
#include <beginnormal_vertex>
|
|
25
|
+
#include <morphnormal_vertex>
|
|
26
|
+
#include <skinbase_vertex>
|
|
27
|
+
#include <skinnormal_vertex>
|
|
28
|
+
#include <defaultnormal_vertex>
|
|
29
|
+
#include <normal_vertex>
|
|
30
|
+
#include <begin_vertex>
|
|
31
|
+
#include <morphtarget_vertex>
|
|
32
|
+
#include <skinning_vertex>
|
|
33
|
+
#include <displacementmap_vertex>
|
|
34
|
+
#include <project_vertex>
|
|
35
|
+
#include <logdepthbuf_vertex>
|
|
36
|
+
#include <clipping_planes_vertex>
|
|
37
|
+
vViewPosition = - mvPosition.xyz;
|
|
38
|
+
#include <worldpos_vertex>
|
|
39
|
+
#include <shadowmap_vertex>
|
|
40
|
+
#include <fog_vertex>
|
|
41
|
+
#ifdef USE_TRANSMISSION
|
|
42
|
+
vWorldPosition = worldPosition.xyz;
|
|
43
|
+
#endif
|
|
44
|
+
}`,Gh=`#define STANDARD
|
|
45
|
+
#ifdef PHYSICAL
|
|
46
|
+
#define IOR
|
|
47
|
+
#define USE_SPECULAR
|
|
48
|
+
#endif
|
|
49
|
+
uniform vec3 diffuse;
|
|
50
|
+
uniform vec3 emissive;
|
|
51
|
+
uniform float roughness;
|
|
52
|
+
uniform float metalness;
|
|
53
|
+
uniform float opacity;
|
|
54
|
+
#ifdef IOR
|
|
55
|
+
uniform float ior;
|
|
56
|
+
#endif
|
|
57
|
+
#ifdef USE_SPECULAR
|
|
58
|
+
uniform float specularIntensity;
|
|
59
|
+
uniform vec3 specularColor;
|
|
60
|
+
#ifdef USE_SPECULAR_COLORMAP
|
|
61
|
+
uniform sampler2D specularColorMap;
|
|
62
|
+
#endif
|
|
63
|
+
#ifdef USE_SPECULAR_INTENSITYMAP
|
|
64
|
+
uniform sampler2D specularIntensityMap;
|
|
65
|
+
#endif
|
|
66
|
+
#endif
|
|
67
|
+
#ifdef USE_CLEARCOAT
|
|
68
|
+
uniform float clearcoat;
|
|
69
|
+
uniform float clearcoatRoughness;
|
|
70
|
+
#endif
|
|
71
|
+
#ifdef USE_DIFFUSE_ROUGHNESS
|
|
72
|
+
uniform float diffuseRoughness;
|
|
73
|
+
#ifdef USE_DIFFUSE_ROUGHNESSMAP
|
|
74
|
+
uniform sampler2D diffuseRoughnessMap;
|
|
75
|
+
#endif
|
|
76
|
+
#endif
|
|
77
|
+
#ifdef USE_DISPERSION
|
|
78
|
+
uniform float dispersion;
|
|
79
|
+
#endif
|
|
80
|
+
#ifdef USE_RETROREFLECTION
|
|
81
|
+
uniform float retroreflectivity;
|
|
82
|
+
#endif
|
|
83
|
+
#ifdef USE_IRIDESCENCE
|
|
84
|
+
uniform float iridescence;
|
|
85
|
+
uniform float iridescenceIOR;
|
|
86
|
+
uniform float iridescenceThicknessMinimum;
|
|
87
|
+
uniform float iridescenceThicknessMaximum;
|
|
88
|
+
#endif
|
|
89
|
+
#ifdef USE_SHEEN
|
|
90
|
+
uniform vec3 sheenColor;
|
|
91
|
+
uniform float sheenRoughness;
|
|
92
|
+
#ifdef USE_SHEEN_COLORMAP
|
|
93
|
+
uniform sampler2D sheenColorMap;
|
|
94
|
+
#endif
|
|
95
|
+
#ifdef USE_SHEEN_ROUGHNESSMAP
|
|
96
|
+
uniform sampler2D sheenRoughnessMap;
|
|
97
|
+
#endif
|
|
98
|
+
#endif
|
|
99
|
+
#ifdef USE_ANISOTROPY
|
|
100
|
+
uniform vec2 anisotropyVector;
|
|
101
|
+
#ifdef USE_ANISOTROPYMAP
|
|
102
|
+
uniform sampler2D anisotropyMap;
|
|
103
|
+
#endif
|
|
104
|
+
#endif
|
|
105
|
+
varying vec3 vViewPosition;
|
|
106
|
+
#include <common>
|
|
107
|
+
#include <dithering_pars_fragment>
|
|
108
|
+
#include <color_pars_fragment>
|
|
109
|
+
#include <uv_pars_fragment>
|
|
110
|
+
#include <map_pars_fragment>
|
|
111
|
+
#include <alphamap_pars_fragment>
|
|
112
|
+
#include <alphatest_pars_fragment>
|
|
113
|
+
#include <alphahash_pars_fragment>
|
|
114
|
+
#include <aomap_pars_fragment>
|
|
115
|
+
#include <lightmap_pars_fragment>
|
|
116
|
+
#include <emissivemap_pars_fragment>
|
|
117
|
+
#include <iridescence_fragment>
|
|
118
|
+
#include <envmap_common_pars_fragment>
|
|
119
|
+
#include <envmap_physical_pars_fragment>
|
|
120
|
+
#include <fog_pars_fragment>
|
|
121
|
+
#include <lights_pars_begin>
|
|
122
|
+
#include <normal_pars_fragment>
|
|
123
|
+
#include <lights_physical_pars_fragment>
|
|
124
|
+
#include <transmission_pars_fragment>
|
|
125
|
+
#include <shadowmap_pars_fragment>
|
|
126
|
+
#include <bumpmap_pars_fragment>
|
|
127
|
+
#include <normalmap_pars_fragment>
|
|
128
|
+
#include <clearcoat_pars_fragment>
|
|
129
|
+
#include <iridescence_pars_fragment>
|
|
130
|
+
#include <roughnessmap_pars_fragment>
|
|
131
|
+
#include <metalnessmap_pars_fragment>
|
|
132
|
+
#include <logdepthbuf_pars_fragment>
|
|
133
|
+
#include <clipping_planes_pars_fragment>
|
|
134
|
+
void main() {
|
|
135
|
+
vec4 diffuseColor = vec4( diffuse, opacity );
|
|
136
|
+
#include <clipping_planes_fragment>
|
|
137
|
+
ReflectedLight reflectedLight = ReflectedLight( vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ), vec3( 0.0 ) );
|
|
138
|
+
vec3 totalEmissiveRadiance = emissive;
|
|
139
|
+
#include <logdepthbuf_fragment>
|
|
140
|
+
#include <map_fragment>
|
|
141
|
+
#include <color_fragment>
|
|
142
|
+
#include <alphamap_fragment>
|
|
143
|
+
#include <alphatest_fragment>
|
|
144
|
+
#include <alphahash_fragment>
|
|
145
|
+
#include <roughnessmap_fragment>
|
|
146
|
+
#include <metalnessmap_fragment>
|
|
147
|
+
#include <normal_fragment_begin>
|
|
148
|
+
#include <normal_fragment_maps>
|
|
149
|
+
#include <clearcoat_normal_fragment_begin>
|
|
150
|
+
#include <clearcoat_normal_fragment_maps>
|
|
151
|
+
#include <emissivemap_fragment>
|
|
152
|
+
#include <lights_physical_fragment>
|
|
153
|
+
#include <lights_fragment_begin>
|
|
154
|
+
#include <lights_fragment_maps>
|
|
155
|
+
#include <lights_fragment_end>
|
|
156
|
+
#include <aomap_fragment>
|
|
157
|
+
vec3 totalDiffuse = reflectedLight.directDiffuse + reflectedLight.indirectDiffuse;
|
|
158
|
+
vec3 totalSpecular = reflectedLight.directSpecular + reflectedLight.indirectSpecular;
|
|
159
|
+
#include <transmission_fragment>
|
|
160
|
+
vec3 outgoingLight = totalDiffuse + totalSpecular + totalEmissiveRadiance;
|
|
161
|
+
#ifdef USE_SHEEN
|
|
162
|
+
|
|
163
|
+
outgoingLight = outgoingLight + sheenSpecularDirect + sheenSpecularIndirect;
|
|
164
|
+
|
|
165
|
+
#endif
|
|
166
|
+
#ifdef USE_CLEARCOAT
|
|
167
|
+
float dotNVcc = saturate( dot( geometryClearcoatNormal, geometryViewDir ) );
|
|
168
|
+
vec3 Fcc = F_Schlick( material.clearcoatF0, material.clearcoatF90, dotNVcc );
|
|
169
|
+
outgoingLight = outgoingLight * ( 1.0 - material.clearcoat * Fcc ) + ( clearcoatSpecularDirect + clearcoatSpecularIndirect ) * material.clearcoat;
|
|
170
|
+
#endif
|
|
171
|
+
#include <opaque_fragment>
|
|
172
|
+
#include <tonemapping_fragment>
|
|
173
|
+
#include <colorspace_fragment>
|
|
174
|
+
#include <fog_fragment>
|
|
175
|
+
#include <premultiplied_alpha_fragment>
|
|
176
|
+
#include <dithering_fragment>
|
|
177
|
+
}`,B={meshphysical_vert:Vh,meshphysical_frag:Gh},E={common:{diffuse:{value:new te(16777215)},opacity:{value:1},map:{value:null},mapTransform:{value:new L},alphaMap:{value:null},alphaMapTransform:{value:new L},alphaTest:{value:0}},specularmap:{specularMap:{value:null},specularMapTransform:{value:new L}},envmap:{envMap:{value:null},envMapRotation:{value:new L},reflectivity:{value:1},ior:{value:1.5},refractionRatio:{value:.98},dfgLUT:{value:null}},aomap:{aoMap:{value:null},aoMapIntensity:{value:1},aoMapTransform:{value:new L}},lightmap:{lightMap:{value:null},lightMapIntensity:{value:1},lightMapTransform:{value:new L}},bumpmap:{bumpMap:{value:null},bumpMapTransform:{value:new L},bumpScale:{value:1}},normalmap:{normalMap:{value:null},normalMapTransform:{value:new L},normalScale:{value:new Ee(1,1)}},displacementmap:{displacementMap:{value:null},displacementMapTransform:{value:new L},displacementScale:{value:1},displacementBias:{value:0}},emissivemap:{emissiveMap:{value:null},emissiveMapTransform:{value:new L}},metalnessmap:{metalnessMap:{value:null},metalnessMapTransform:{value:new L}},roughnessmap:{roughnessMap:{value:null},roughnessMapTransform:{value:new L}},gradientmap:{gradientMap:{value:null}},fog:{fogDensity:{value:25e-5},fogNear:{value:1},fogFar:{value:2e3},fogColor:{value:new te(16777215)}},lights:{ambientLightColor:{value:[]},lightProbe:{value:[]},sunLights:{value:[],properties:{direction:{},color:{}}},sunLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},sunShadowMatrix:{value:[]},sunShadowCascade:{value:[]},directionalLights:{value:[],properties:{direction:{},color:{}}},directionalLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},directionalShadowMatrix:{value:[]},spotLights:{value:[],properties:{color:{},position:{},direction:{},distance:{},coneCos:{},penumbraCos:{},decay:{}}},spotLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{}}},spotLightMap:{value:[]},spotLightMatrix:{value:[]},pointLights:{value:[],properties:{color:{},position:{},decay:{},distance:{}}},pointLightShadows:{value:[],properties:{shadowIntensity:1,shadowBias:{},shadowNormalBias:{},shadowRadius:{},shadowMapSize:{},shadowCameraNear:{},shadowCameraFar:{}}},pointShadowMatrix:{value:[]},hemisphereLights:{value:[],properties:{direction:{},skyColor:{},groundColor:{}}},rectAreaLights:{value:[],properties:{color:{},position:{},width:{},height:{}}},ltc_1:{value:null},ltc_2:{value:null},probesSH:{value:[]},probesMin:{value:[]},probesMax:{value:[]},probesResolution:{value:[]}},points:{diffuse:{value:new te(16777215)},opacity:{value:1},size:{value:1},scale:{value:1},map:{value:null},alphaMap:{value:null},alphaMapTransform:{value:new L},alphaTest:{value:0},uvTransform:{value:new L}},sprite:{diffuse:{value:new te(16777215)},opacity:{value:1},center:{value:new Ee(.5,.5)},rotation:{value:0},map:{value:null},mapTransform:{value:new L},alphaMap:{value:null},alphaMapTransform:{value:new L},alphaTest:{value:0}}},sr={basic:{uniforms:ce([E.common,E.specularmap,E.envmap,E.aomap,E.lightmap,E.fog])},lambert:{uniforms:ce([E.common,E.specularmap,E.envmap,E.aomap,E.lightmap,E.emissivemap,E.bumpmap,E.normalmap,E.displacementmap,E.fog,E.lights,{emissive:{value:new te(0)},envMapIntensity:{value:1}}])},phong:{uniforms:ce([E.common,E.specularmap,E.envmap,E.aomap,E.lightmap,E.emissivemap,E.bumpmap,E.normalmap,E.displacementmap,E.fog,E.lights,{emissive:{value:new te(0)},specular:{value:new te(1118481)},shininess:{value:30},envMapIntensity:{value:1}}])},standard:{uniforms:ce([E.common,E.envmap,E.aomap,E.lightmap,E.emissivemap,E.bumpmap,E.normalmap,E.displacementmap,E.roughnessmap,E.metalnessmap,E.fog,E.lights,{emissive:{value:new te(0)},roughness:{value:1},metalness:{value:0},envMapIntensity:{value:1}}])},toon:{uniforms:ce([E.common,E.aomap,E.lightmap,E.emissivemap,E.bumpmap,E.normalmap,E.displacementmap,E.gradientmap,E.fog,E.lights,{emissive:{value:new te(0)}}])},matcap:{uniforms:ce([E.common,E.bumpmap,E.normalmap,E.displacementmap,E.fog,{matcap:{value:null}}])},points:{uniforms:ce([E.points,E.fog])},dashed:{uniforms:ce([E.common,E.fog,{scale:{value:1},dashSize:{value:1},totalSize:{value:2}}])},depth:{uniforms:ce([E.common,E.displacementmap])},normal:{uniforms:ce([E.common,E.bumpmap,E.normalmap,E.displacementmap,{opacity:{value:1}}])},sprite:{uniforms:ce([E.sprite,E.fog])},background:{uniforms:{uvTransform:{value:new L}}},backgroundCube:{uniforms:{backgroundRotation:{value:new L}}},distance:{uniforms:ce([E.common,E.displacementmap,{referencePosition:{value:new K},nearDistance:{value:1},farDistance:{value:1e3}}])},shadow:{uniforms:ce([E.lights,E.fog,{color:{value:new te(0)},opacity:{value:1}}])}};sr.physical={uniforms:ce([sr.standard.uniforms,{clearcoat:{value:0},clearcoatMap:{value:null},clearcoatMapTransform:{value:new L},clearcoatNormalMap:{value:null},clearcoatNormalMapTransform:{value:new L},clearcoatNormalScale:{value:new Ee(1,1)},clearcoatRoughness:{value:0},clearcoatRoughnessMap:{value:null},clearcoatRoughnessMapTransform:{value:new L},diffuseRoughness:{value:0},diffuseRoughnessMap:{value:null},diffuseRoughnessMapTransform:{value:new L},dispersion:{value:0},retroreflectivity:{value:0},iridescence:{value:0},iridescenceMap:{value:null},iridescenceMapTransform:{value:new L},iridescenceIOR:{value:1.3},iridescenceThicknessMinimum:{value:100},iridescenceThicknessMaximum:{value:400},iridescenceThicknessMap:{value:null},iridescenceThicknessMapTransform:{value:new L},sheen:{value:0},sheenColor:{value:new te(0)},sheenColorMap:{value:null},sheenColorMapTransform:{value:new L},sheenRoughness:{value:1},sheenRoughnessMap:{value:null},sheenRoughnessMapTransform:{value:new L},transmission:{value:0},transmissionMap:{value:null},transmissionMapTransform:{value:new L},transmissionSamplerSize:{value:new Ee},transmissionSamplerMap:{value:null},thickness:{value:0},thicknessMap:{value:null},thicknessMapTransform:{value:new L},attenuationDistance:{value:0},attenuationColor:{value:new te(0)},specularColor:{value:new te(1,1,1)},specularColorMap:{value:null},specularColorMapTransform:{value:new L},specularIntensity:{value:1},specularIntensityMap:{value:null},specularIntensityMapTransform:{value:new L},anisotropyVector:{value:new Ee},anisotropyMap:{value:null},anisotropyMapTransform:{value:new L}}]),vertexShader:B.meshphysical_vert,fragmentShader:B.meshphysical_frag};var jh=new L;jh.set(-1,0,0,0,1,0,0,0,1);var $h=new L;$h.set(-1,0,0,0,1,0,0,0,1);var Jh=()=>new ts().registerExtensions(ws);function vi(n,e,t){let{times:i,values:s}=n,r=i.length,o=n.interpolation==="CUBICSPLINE",a=o?e*3:e,c=(g,y)=>s[g*a+(o?e:0)+y]??0,l=i[0]??0,u=i[r-1]??l,d=g=>Array.from({length:e},(y,M)=>c(g,M));if(r===0)return new Array(e).fill(0);if(t<=l)return d(0);if(t>=u)return d(r-1);let m=1;for(;m<r&&(i[m]??0)<t;)m+=1;let p=m-1,_=i[p]??0,f=i[m]??_,v=d(p);if(n.interpolation==="STEP"||f-_<=1e-9)return v;let h=(t-_)/(f-_),x=d(m);return v.map((g,y)=>g+((x[y]??0)-g)*h)}function Zh(n,e,t){let i=e.get(n.getName()),s=[...n.getTranslation()],r=[...n.getRotation()],o=[...n.getScale()],a=i?.get("translation");a!==void 0&&s.splice(0,3,...vi(a,3,t));let c=i?.get("rotation");c!==void 0&&r.splice(0,4,...vi(c,4,t));let l=i?.get("scale");return l!==void 0&&o.splice(0,3,...vi(l,3,t)),{matrix:new ye().compose(new K(s[0]??0,s[1]??0,s[2]??0),new pe(r[0]??0,r[1]??0,r[2]??0,r[3]??1),new K(o[0]??1,o[1]??1,o[2]??1)),translation:s}}function rr(n,e){let t=0;for(let i of e.get(n.getName())?.values()??[])t=Math.max(t,i.times.at(-1)??0);for(let i of n.listChildren())t=Math.max(t,rr(i,e));return t}async function or(n,e,t=30){return Qh(await Jh().read(n),e,t)}function Qh(n,e,t=30){let i=n.getRoot().listAnimations().find(p=>p.getName()===e);if(i===void 0){let p=n.getRoot().listAnimations().map(_=>_.getName());throw new Error(`The GLB has no clip '${e}'. It carries: ${p.length===0?"none":p.join(", ")}.`)}let s=new Map;for(let p of i.listChannels()){let _=p.getTargetNode(),f=p.getSampler(),v=p.getTargetPath();if(_===null||f===null||v===null)continue;let h=f.getInput()?.getArray(),x=f.getOutput()?.getArray();if(h==null||x===null||x===void 0)continue;let g=s.get(_.getName())??new Map;g.set(v,{interpolation:f.getInterpolation(),times:h,values:x}),s.set(_.getName(),g);}let r=n.getRoot().listScenes().flatMap(p=>p.listChildren()),o=r.reduce((p,_)=>Math.max(p,rr(_,s)),0),a=n.getRoot().listSkins().flatMap(p=>p.listJoints()).map(p=>p.getName()),c=new Set(a.length>0?a:n.getRoot().listNodes().map(p=>p.getName()).filter(p=>p.length>0)),l=[...c],u={},d=Math.max(1,Math.round(o*t)),m=[];for(let p=0;p<=d;p+=1){let _=Math.min(o,p/t),f={},v={},h={},x=(g,y,M)=>{let S=y.clone().multiply(Zh(g,s,_).matrix),b=g.getName();if(c.has(b)){let A=new K().setFromMatrixPosition(S),w=new pe().setFromRotationMatrix(S),R=new pe().setFromRotationMatrix(y);f[b]=[A.x,A.y,A.z],v[b]=[w.x,w.y,w.z,w.w],h[b]=[R.x,R.y,R.z,R.w],M!==void 0&&c.has(M)&&(u[b]=M);}for(let A of g.listChildren())x(A,S,b);};for(let g of r)x(g,new ye);m.push({parents:h,positions:f,rotations:v,time:_});}return {bones:l,duration:o,fps:t,frames:m,parentsOf:u}}var Mt=Object.freeze({contact:.03,jitter:.05,penetration:.01,seam:5,skate:.02,stretch:.02}),Mi=(n,e)=>Math.hypot((n[0]??0)-(e[0]??0),(n[1]??0)-(e[1]??0),(n[2]??0)-(e[2]??0)),ef=(n,e)=>Math.hypot((n[0]??0)-(e[0]??0),(n[2]??0)-(e[2]??0));function tf(n,e){let t=s=>Math.hypot(s[0]??0,s[1]??0,s[2]??0,s[3]??1)||1,i=((n[0]??0)*(e[0]??0)+(n[1]??0)*(e[1]??0)+(n[2]??0)*(e[2]??0)+(n[3]??1)*(e[3]??1))/(t(n)*t(e));return 2*Math.acos(Math.min(1,Math.abs(i)))*180/Math.PI}function Si(n,e=2){let t=[],i,s;for(let r of n)(i===void 0||s===void 0||r-s>e)&&(i!==void 0&&s!==void 0&&t.push({from:i,to:s}),i=r),s=r;return i!==void 0&&s!==void 0&&t.push({from:i,to:s}),t}function nf(n,e,t,i){let s=[];for(let r of e){let o=n.frames.map(p=>p.positions[r]?.[1]??0),a=Math.min(...o),c=n.frames.map((p,_)=>({index:_,frame:p})).filter(({frame:p})=>(p.positions[r]?.[1]??0)<=a+i),l,u,d=()=>{u!==void 0&&(u.worst>t&&s.push({bone:r,detail:`the planted foot slid ${(u.worst*1e3).toFixed(0)} mm between frames ${u.first} and ${u.last}`,fromFrame:u.first,fromTime:n.frames[u.first]?.time??0,kind:"foot-skate",limit:t,measured:u.worst,toFrame:u.last,toTime:n.frames[u.last]?.time??0}),u=void 0,l=void 0);},m;for(let{index:p,frame:_}of c){m!==void 0&&p-m>1&&d(),l??=_;let f=ef(_.positions[r]??[0,0,0],l.positions[r]??[0,0,0]);u??={first:p,last:p,worst:0},u.last=p,u.worst=Math.max(u.worst,f),m=p;}d();}return s}function sf(n,e,t){let i=[];for(let s of e){let r=n.frames.map((o,a)=>({index:a,y:o.positions[s]?.[1]})).filter(({y:o})=>o!==void 0&&o<-t);for(let o of Si(r.map(({index:a})=>a))){let a=r.filter(({index:c})=>c>=o.from&&c<=o.to).reduce((c,{y:l})=>Math.min(c,l??0),0);i.push({bone:s,detail:`reaches ${(Math.abs(a)*1e3).toFixed(0)} mm below the floor`,fromFrame:o.from,fromTime:n.frames[o.from]?.time??0,kind:"ground-penetration",limit:t,measured:Math.abs(a),toFrame:o.to,toTime:n.frames[o.to]?.time??0});}}return i}function rf(n,e){let t=n.frames[0],i=n.frames.at(-1);if(t===void 0||i===void 0||n.frames.length<3)return [];let s,r=0;for(let o of n.bones){let a=t.rotations[o],c=i.rotations[o];if(a===void 0||c===void 0)continue;let l=tf(a,c);l<=e||(r+=1,(s===void 0||l>s.angle)&&(s={angle:l,bone:o}));}return s===void 0?[]:[{bone:s.bone,detail:`the clip ends ${s.angle.toFixed(1)}\xB0 from where it started${r>1?`, and ${r-1} more bones with it`:""}`,fromFrame:0,fromTime:t.time,kind:"loop-seam",limit:e,measured:s.angle,toFrame:n.frames.length-1,toTime:i.time}]}function of(n,e,t){let i=[];for(let s of e){let r=n.frames.map(l=>l.positions[s]),o=[],a=new Map,c=0;for(let l=1;l<r.length-1;l+=1){let u=r[l-1],d=r[l],m=r[l+1];if(u===void 0||d===void 0||m===void 0)continue;let p=Mi([2*(d[0]??0)-(u[0]??0),2*(d[1]??0)-(u[1]??0),2*(d[2]??0)-(u[2]??0)],[m[0]??0,m[1]??0,m[2]??0]);p>t&&(o.push(l),a.set(l,Math.max(a.get(l)??0,p)),c=Math.max(c,p));}for(let l of Si(o.map(u=>u)))i.push({bone:s,detail:`a frame-direction spike of ${((a.get(l.from)??c)*1e3).toFixed(0)} mm`,fromFrame:l.from,fromTime:n.frames[l.from]?.time??0,kind:"jitter",limit:t,measured:c,toFrame:l.to,toTime:n.frames[l.to]?.time??0});}return i}function af(n,e){let t=n.frames[0];if(t===void 0)return [];let i=[];for(let[s,r]of Object.entries(n.parentsOf)){let o=Mi(t.positions[s]??[0,0,0],t.positions[r]??[0,0,0]);if(o<=1e-6)continue;let a=n.frames.map((l,u)=>({index:u,ratio:Math.abs(Mi(l.positions[s]??[0,0,0],l.positions[r]??[0,0,0])/o-1)})).filter(({ratio:l})=>l>e);if(a.length===0)continue;let c=a.reduce((l,{ratio:u})=>Math.max(l,u),0);for(let l of Si(a.map(({index:u})=>u)))i.push({bone:s,detail:`distance to its parent '${r}' changes by ${(c*100).toFixed(1)}%`,fromFrame:l.from,fromTime:n.frames[l.from]?.time??0,kind:"bone-stretch",limit:e,measured:c,toFrame:l.to,toTime:n.frames[l.to]?.time??0});}return i}var cf=new Set(["left-foot","right-foot"]);async function ar(n,e,t={}){let i=t.scale??1,s={contact:(t.thresholds?.contact??Mt.contact)/i,jitter:(t.thresholds?.jitter??Mt.jitter)/i,penetration:(t.thresholds?.penetration??Mt.penetration)/i,seam:t.thresholds?.seam??Mt.seam,skate:(t.thresholds?.skate??Mt.skate)/i,stretch:t.thresholds?.stretch??Mt.stretch},r=await or(n,e,t.fps??30),o=Ai(r.bones).filter(c=>cf.has(c.id)).map(c=>c.node),a=[...nf(r,o,s.skate,s.contact),...sf(r,r.bones,s.penetration),...rf(r,s.seam),...of(r,r.bones,s.jitter),...af(r,s.stretch)];return {bones:r.bones.length,clip:e,defects:a,duration:r.duration,file:n,fps:r.fps,frames:r.frames.length,passed:a.length===0,scale:i,thresholds:s}}var lf=String.raw`
|
|
178
|
+
:root{color-scheme:dark;font-family:"IBM Plex Mono","Azeret Mono",ui-monospace,monospace;background:#080b0a;color:#dce4de;--line:#27302c;--line2:#38433e;--panel:#111613;--panel2:#171d1a;--acid:#b7f34a;--cyan:#68d9d0;--muted:#77837c;--red:#ff705d}*{box-sizing:border-box}body{margin:0;overflow:hidden;background:#080b0a}button{cursor:pointer}.lab{height:100vh;display:grid;grid-template-rows:50px 1fr 26px}.bar{display:flex;align-items:center;gap:14px;padding:0 14px;border-bottom:1px solid var(--line);background:#0d120f}.brand{font:800 13px sans-serif;letter-spacing:.18em}.brand b{display:inline-grid;place-items:center;width:24px;height:24px;margin-right:9px;background:var(--acid);color:#101808}.bar small,.status{color:var(--muted)}.grow{flex:1}.bar button{border:1px solid #789e3f;border-radius:2px;background:var(--acid);color:#111908;padding:8px 14px;font:800 10px inherit}.body{min-height:0;display:grid;grid-template-columns:230px minmax(0,1fr) 285px}.side{overflow:auto;background:var(--panel)}.left{border-right:1px solid var(--line)}.right{border-left:1px solid var(--line)}.section{padding:13px;border-bottom:1px solid var(--line)}h2{margin:0 0 10px;color:var(--muted);font-size:9px;letter-spacing:.16em;text-transform:uppercase}label{display:grid;gap:5px;margin-bottom:10px;color:#91a097;font-size:9px;text-transform:uppercase}select,input{width:100%;border:1px solid var(--line);border-radius:2px;background:#090d0b;color:#dce4de;padding:8px;font:10px inherit;outline:none}select:focus,input:focus{border-color:var(--acid)}input:disabled{opacity:.38}.workspace{min-width:0;min-height:0;display:grid;grid-template-rows:minmax(280px,1fr) 224px;background:#090d0b}.viewport{position:relative;min-width:0;min-height:0}.viewport canvas{display:block;width:100%;height:100%}.title{position:absolute;top:18px;left:18px;pointer-events:none;font:800 23px sans-serif}.title small{display:block;margin-top:6px;color:var(--acid);font:9px ui-monospace;letter-spacing:.14em}.tools{position:absolute;bottom:16px;left:50%;display:flex;transform:translateX(-50%);border:1px solid var(--line2);background:#090d0be8}.tools button,.preset button{border:0;background:none;color:var(--muted);padding:9px 15px;font:9px inherit;text-transform:uppercase}.tools button.on{background:#263328;color:var(--acid)}.tools button:disabled{opacity:.28;cursor:not-allowed}.release-note{position:absolute;top:18px;right:18px;padding:7px 10px;border:1px solid #8b493d;background:#2b1713d9;color:#ff9b86;font-size:9px;letter-spacing:.13em}.landmarks{display:grid;gap:5px}.landmark{display:grid;grid-template-columns:8px 1fr auto;gap:8px;align-items:center;width:100%;padding:8px;border:1px solid transparent;border-radius:2px;background:#0c110f;color:var(--muted);font:10px inherit;text-align:left}.landmark.on{border-color:#668c34;color:#dce4de}.landmark i{width:6px;height:6px;border-radius:50%;background:#71b9ff}.landmark.detected i{background:var(--acid)}.landmark small{font-size:8px;color:#69756f}.axis{display:grid;grid-template-columns:repeat(3,1fr);gap:6px}.axis label{margin:0}.preset{display:grid;grid-template-columns:repeat(4,1fr);margin-top:8px}.preset button{padding:7px 2px;border:1px solid var(--line)}.wide,.editor-bar button,.segmented button{border:1px solid var(--line2);border-radius:2px;background:#1a211d;color:#dce4de;padding:8px;font:10px inherit}.wide{width:100%}.secondary{color:var(--muted)!important;background:#0d1210!important}.segmented{display:grid;grid-template-columns:1fr 1fr;gap:3px}.segmented button.on{border-color:var(--acid);color:var(--acid);background:#243021}.segmented button.danger.on{border-color:var(--red);color:#ff9b86;background:#321a16}.hint{margin:8px 0 0;color:var(--muted);font-size:9px;line-height:1.5}.status{display:flex;justify-content:space-between;align-items:center;padding:0 12px;border-top:1px solid var(--line);font-size:9px}.status b{color:var(--acid)}.error{position:absolute;top:18px;right:18px;max-width:360px;padding:10px;border:1px solid #81452f;background:#321a12;color:#ffb08a;font-size:10px}.saved{color:var(--acid);font-size:9px}.dope-editor{min-width:0;border-top:1px solid #46504b;background:#101512;box-shadow:0 -12px 30px #0008}.editor-bar{height:44px;display:flex;align-items:center;gap:7px;padding:6px 9px;border-bottom:1px solid var(--line2);background:#171c19}.editor-bar select{width:180px;padding:7px}.editor-bar button{white-space:nowrap;padding:7px 10px}.editor-bar button:disabled{opacity:.3;cursor:not-allowed}.editor-bar .transport{width:34px;border-color:#738d47;color:var(--acid);font-size:13px}.timecode{min-width:90px;color:#e1e7e3;font-size:11px;letter-spacing:.08em}.timecode i{color:var(--muted);font-style:normal}.compact{display:flex}.sheet{position:relative;height:179px;display:grid;grid-template-columns:132px 1fr;grid-template-rows:27px repeat(4,38px);overflow:hidden;background:repeating-linear-gradient(90deg,transparent 0,transparent calc(10% - 1px),#252d29 calc(10% - 1px),#252d29 10%)}.ruler-label{grid-column:1;grid-row:1}.ruler{position:relative;grid-column:2;grid-row:1;border-bottom:1px solid var(--line2);background:#0c100e}.ruler span{position:absolute;bottom:5px;transform:translateX(-50%);color:#68736d;font-size:8px}.lane-row{display:contents}.lane-label{z-index:3;display:flex;align-items:center;gap:8px;padding-left:13px;border-right:1px solid var(--line2);border-bottom:1px solid #222a26;background:#151a17;color:#87938c;font-size:9px;letter-spacing:.1em}.lane-label i{width:6px;height:6px;border:1px solid var(--cyan);transform:rotate(45deg)}.lane-track{position:relative;border-bottom:1px solid #222a26;background:#0d120f66}.key-diamond{position:absolute;z-index:4;top:14px;width:10px;height:10px;padding:0;transform:translate(-50%,-50%) rotate(45deg);border:1px solid #e2ffae;background:var(--acid);box-shadow:0 0 0 2px #0a0e0c}.attachment-lane .lane-label{grid-column:1;grid-row:5}.event-clip{align-self:center;grid-column:2;grid-row:5;height:23px;margin:0 8px;padding:6px 10px;border-left:3px solid var(--cyan);background:#17312d;color:#8ce7df;font-size:9px;letter-spacing:.08em}.event-clip.released{border-left-color:var(--red);background:#321a16;color:#ff9b86}.playhead{position:absolute;z-index:6;top:0;bottom:0;width:1px;background:#f3f7f4;pointer-events:none}.playhead b{position:absolute;top:0;left:-4px;width:9px;height:9px;background:#f3f7f4;clip-path:polygon(0 0,100% 0,50% 100%)}.scrubber{position:absolute;z-index:7;top:0;right:0;bottom:0;left:132px;width:calc(100% - 132px);height:100%;margin:0;padding:0;opacity:0;cursor:ew-resize}.ruler{grid-column:2;grid-row:1}.lane-row:nth-of-type(1) .lane-label,.lane-row:nth-of-type(1) .lane-track{grid-row:2}.lane-row:nth-of-type(2) .lane-label,.lane-row:nth-of-type(2) .lane-track{grid-row:3}.lane-row:nth-of-type(3) .lane-label,.lane-row:nth-of-type(3) .lane-track{grid-row:4}.lane-row .lane-label{grid-column:1}.lane-row .lane-track{grid-column:2}@media(max-width:980px){.body{grid-template-columns:210px 1fr}.right{display:none}.workspace{grid-template-rows:minmax(260px,1fr) 224px}.compact{display:none}}
|
|
179
|
+
`;function cr(n){return n.replaceAll("&","&").replaceAll("<","<").replaceAll('"',""")}function lr(n){return `<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Pose Lab \u2014 ${cr(n)}</title><style>${lf}</style></head><body><div id="root" data-project="${cr(n)}"></div><script type="module" src="app.js"></script></body></html>`}var df=new URL("./client/app.js",import.meta.url),pf=256e3;function bi(n,e){if(e.length===0||at.isAbsolute(e)||e.split(/[\\/]/u).some(s=>s.length===0||s.startsWith(".")))return;let t=at.resolve(n),i=at.resolve(t,e);return i.startsWith(`${t}${at.sep}`)?i:void 0}async function mf(n){let e=[],t=new Set([".git","build","dist","node_modules"]),i=async(s,r,o)=>{if(o>6||e.length>=2e3)return;let a=await readdir(s,{withFileTypes:true}).catch(()=>[]);for(let c of a){if(c.name.startsWith(".")||t.has(c.name))continue;let l=r.length===0?c.name:`${r}/${c.name}`;c.isDirectory()?await i(at.join(s,c.name),l,o+1):c.name.toLowerCase().endsWith(".glb")&&e.push(l);}};return await i(n,"",0),e.sort((s,r)=>s.localeCompare(r))}async function gf(n){let e=[],t=0;for await(let i of n){let s=Buffer.from(i);if(t+=s.length,t>pf)throw new Error("Request exceeds 256 KB.");e.push(s);}return JSON.parse(Buffer.concat(e).toString("utf8"))}function xn(n,e,t,i){n.writeHead(e,{"cache-control":"no-store","content-type":i,"x-content-type-options":"nosniff"}),n.end(t);}function ve(n,e,t){xn(n,e,JSON.stringify(t),"application/json; charset=utf-8");}function _f(n){let e=at.resolve(n);return async(t,i,s)=>{try{let r=new URL(t.url??"/","http://pose-lab");if(t.method==="GET"&&(s==="/"||s==="/pose"))return xn(i,200,lr(at.basename(e)),"text/html; charset=utf-8");if(t.method==="GET"&&s==="/app.js")return xn(i,200,await readFile(df),"text/javascript; charset=utf-8");if(t.method==="GET"&&s==="/favicon.ico"){i.writeHead(204),i.end();return}if(t.method==="GET"&&s==="/api/models")return ve(i,200,{models:await mf(e)});if(t.method==="GET"&&s==="/api/model"){let o=r.searchParams.get("path")??"",a=o.endsWith(".glb")?bi(e,o):void 0;if(a===void 0)return ve(i,404,{error:"GLB not found."});let c=await readFile(a).catch(()=>{});return c===void 0?ve(i,404,{error:"GLB not found."}):xn(i,200,c,"model/gltf-binary")}if(t.method==="GET"&&s==="/api/verify"){let o=r.searchParams.get("path")??"",a=/\.(glb|gltf)$/u.test(o)?bi(e,o):void 0,c=r.searchParams.get("clip")??"";if(a===void 0||c==="")return ve(i,400,{error:"verify needs ?path=<model.glb>&clip=<name>."});let l=Number(r.searchParams.get("scale")??"1");return ve(i,200,await ar(a,c,{scale:l}))}if(s==="/api/recipe"){let o=r.searchParams.get("path")??"",a=o.endsWith(".json")?bi(e,o):void 0;if(a===void 0)return ve(i,404,{error:"Recipe not found."});if(t.method==="GET"){let c=await readFile(a,"utf8").catch(()=>{});return c===void 0?ve(i,404,{error:"Recipe not found."}):ve(i,200,{recipe:JSON.parse(c),path:o})}if(t.method==="PUT"){let c=await gf(t);return typeof c.recipe!="object"||c.recipe===null?ve(i,400,{error:"Body must contain a recipe object."}):(await mkdir(at.dirname(a),{recursive:!0}),await writeFile(a,`${JSON.stringify(c.recipe,null,2)}
|
|
180
|
+
`,"utf8"),ve(i,200,{path:o,saved:!0}))}}return ve(i,404,{error:"Not found."})}catch(r){return ve(i,500,{error:r instanceof Error?r.message:String(r)})}}}/*! Bundled license information:
|
|
181
|
+
|
|
182
|
+
three/build/three.core.js:
|
|
183
|
+
three/build/three.module.js:
|
|
184
|
+
(**
|
|
185
|
+
* @license
|
|
186
|
+
* Copyright 2010-2026 Three.js Authors
|
|
187
|
+
* SPDX-License-Identifier: MIT
|
|
188
|
+
*)
|
|
189
|
+
*/export{_f as createPoseLabHandler};
|