1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[92715],{97207:(e,t,r)=>{r.d(t,{Ad:()=>m,Cd:()=>k,Hg:()=>y,Jk:()=>eE,Rw:()=>eS,TZ:()=>T,Ut:()=>s,X6:()=>$,YY:()=>ec,Z5:()=>eo,a8:()=>X,a_:()=>W,bL:()=>ef,bP:()=>es,cj:()=>O,dB:()=>p,fW:()=>q,gP:()=>eu,gW:()=>M,gz:()=>d,i5:()=>ew,ik:()=>R,im:()=>et,sG:()=>ei,vJ:()=>i,x9:()=>a,yo:()=>eh});var s,i,n,a,o,l,u,f,h=r(84705),c=r(81029).hp;let g="v4.3.0",p="@glb.bin";!function(e){e.ACCESSOR="Accessor",e.ANIMATION="Animation",e.ANIMATION_CHANNEL="AnimationChannel",e.ANIMATION_SAMPLER="AnimationSampler",e.BUFFER="Buffer",e.CAMERA="Camera",e.MATERIAL="Material",e.MESH="Mesh",e.PRIMITIVE="Primitive",e.PRIMITIVE_TARGET="PrimitiveTarget",e.NODE="Node",e.ROOT="Root",e.SCENE="Scene",e.SKIN="Skin",e.TEXTURE="Texture",e.TEXTURE_INFO="TextureInfo"}(s||(s={})),function(e){e.INTERLEAVED="interleaved",e.SEPARATE="separate"}(i||(i={})),function(e){e.ARRAY_BUFFER="ARRAY_BUFFER",e.ELEMENT_ARRAY_BUFFER="ELEMENT_ARRAY_BUFFER",e.INVERSE_BIND_MATRICES="INVERSE_BIND_MATRICES",e.OTHER="OTHER",e.SPARSE="SPARSE"}(n||(n={})),function(e){e[e.R=4096]="R",e[e.G=256]="G",e[e.B=16]="B",e[e.A=1]="A"}(a||(a={})),function(e){e.GLTF="GLTF",e.GLB="GLB"}(o||(o={}));let d={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};class m{static createBufferFromDataURI(e){if(void 0===c){let t=atob(e.split(",")[1]),r=new Uint8Array(t.length);for(let e=0;e<t.length;e++)r[e]=t.charCodeAt(e);return r}{let t=e.split(",")[1],r=e.indexOf("base64")>=0;return c.from(t,r?"base64":"utf8")}}static encodeText(e){return new TextEncoder().encode(e)}static decodeText(e){return new TextDecoder().decode(e)}static concat(e){let t=0;for(let r of e)t+=r.byteLength;let r=new Uint8Array(t),s=0;for(let t of e)r.set(t,s),s+=t.byteLength;return r}static pad(e,t=0){let r=this.padNumber(e.byteLength);if(r===e.byteLength)return e;let s=new Uint8Array(r);if(s.set(e),0!==t)for(let i=e.byteLength;i<r;i++)s[i]=t;return s}static padNumber(e){return 4*Math.ceil(e/4)}static equals(e,t){if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;let r=e.byteLength;for(;r--;)if(e[r]!==t[r])return!1;return!0}static toView(e,t=0,r=1/0){return new Uint8Array(e.buffer,e.byteOffset+t,Math.min(e.byteLength,r))}static assertView(e){if(e&&!ArrayBuffer.isView(e))throw Error(`Method requires Uint8Array parameter; received "${typeof e}".`);return e}}class T{static hexToFactor(e,t){return e=Math.floor(e),t[0]=(e>>16&255)/255,t[1]=(e>>8&255)/255,t[2]=(255&e)/255,this.convertSRGBToLinear(t,t)}static factorToHex(e){let t=[...e],[r,s,i]=this.convertLinearToSRGB(e,t);return 255*r<<16^255*s<<8^(255*i|0)}static convertSRGBToLinear(e,t){for(let r=0;r<3;r++)t[r]=e[r]<.04045?.0773993808*e[r]:Math.pow(.9478672986*e[r]+.0521327014,2.4);return t}static convertLinearToSRGB(e,t){for(let r=0;r<3;r++)t[r]=e[r]<.0031308?12.92*e[r]:1.055*Math.pow(e[r],.41666)-.055;return t}}class E{match(e){return e.length>=3&&255===e[0]&&216===e[1]&&255===e[2]}getSize(e){let t,r,s=new DataView(e.buffer,e.byteOffset+4);for(;s.byteLength;){if(t=s.getUint16(0,!1),function(e,t){if(t>e.byteLength)throw TypeError("Corrupt JPG, exceeded buffer limits");if(255!==e.getUint8(t))throw TypeError("Invalid JPG, marker table corrupted")}(s,t),192===(r=s.getUint8(t+1))||193===r||194===r)return[s.getUint16(t+7,!1),s.getUint16(t+5,!1)];s=new DataView(e.buffer,s.byteOffset+t+2)}throw TypeError("Invalid JPG, no size found")}getChannels(e){return 3}}class x{match(e){return e.length>=8&&137===e[0]&&80===e[1]&&78===e[2]&&71===e[3]&&13===e[4]&&10===e[5]&&26===e[6]&&10===e[7]}getSize(e){let t=new DataView(e.buffer,e.byteOffset);return m.decodeText(e.slice(12,16))===x.PNG_FRIED_CHUNK_NAME?[t.getUint32(32,!1),t.getUint32(36,!1)]:[t.getUint32(16,!1),t.getUint32(20,!1)]}getChannels(e){return 4}}x.PNG_FRIED_CHUNK_NAME="CgBI";class y{static registerFormat(e,t){this.impls[e]=t}static getMimeType(e){for(let t in this.impls)if(this.impls[t].match(e))return t;return null}static getSize(e,t){return this.impls[t]?this.impls[t].getSize(e):null}static getChannels(e,t){return this.impls[t]?this.impls[t].getChannels(e):null}static getVRAMByteLength(e,t){if(!this.impls[t])return null;if(this.impls[t].getVRAMByteLength)return this.impls[t].getVRAMByteLength(e);let r=0,s=this.getSize(e,t);if(!s)return null;for(;s[0]>1||s[1]>1;)r+=s[0]*s[1]*4,s[0]=Math.max(Math.floor(s[0]/2),1),s[1]=Math.max(Math.floor(s[1]/2),1);return r+4}static mimeTypeToExtension(e){return"image/jpeg"===e?"jpg":e.split("/").pop()}static extensionToMimeType(e){return"jpg"===e?"image/jpeg":e?`image/${e}`:""}}y.impls={"image/jpeg":new E,"image/png":new x};class R{static basename(e){let t=e.split(/[\\/]/).pop();return t.substring(0,t.lastIndexOf("."))}static extension(e){if(e.startsWith("data:image/")){let t=e.match(/data:(image\/\w+)/)[1];return y.mimeTypeToExtension(t)}return e.startsWith("data:model/gltf+json")?"gltf":e.startsWith("data:model/gltf-binary")?"glb":e.startsWith("data:application/")?"bin":e.split(/[\\/]/).pop().split(/[.]/).pop()}}var b="undefined"!=typeof Float32Array?Float32Array:Array;function A(e){var t=e[0],r=e[1],s=e[2];return Math.sqrt(t*t+r*r+s*s)}function M(e){let t=w();for(let r of e.propertyType===s.NODE?[e]:e.listChildren())r.traverse(e=>{let r=e.getMesh();if(!r)return;let s=function(e,t){let r=w();for(let s of e.listPrimitives()){let e=s.getAttribute("POSITION"),i=s.getIndices();if(!e)continue;let n=[0,0,0],a=[0,0,0];for(let s=0,o=i?i.getCount():e.getCount();s<o;s++){let o=i?i.getScalar(s):s;I(a=function(e,t,r){var s=t[0],i=t[1],n=t[2],a=r[3]*s+r[7]*i+r[11]*n+r[15];return a=a||1,e[0]=(r[0]*s+r[4]*i+r[8]*n+r[12])/a,e[1]=(r[1]*s+r[5]*i+r[9]*n+r[13])/a,e[2]=(r[2]*s+r[6]*i+r[10]*n+r[14])/a,e}(a,n=e.getElement(o,n),t),r)}}return r}(r,e.getWorldMatrix());s.min.every(isFinite)&&s.max.every(isFinite)&&(I(s.min,t),I(s.max,t))});return t}function I(e,t){for(let r=0;r<3;r++)t.min[r]=Math.min(e[r],t.min[r]),t.max[r]=Math.max(e[r],t.max[r])}function w(){return{min:[1/0,1/0,1/0],max:[-1/0,-1/0,-1/0]}}!function(){var e;e=new b(3),b!=Float32Array&&(e[0]=0,e[1]=0,e[2]=0)}();let N="https://null.example";class S{static dirname(e){let t=e.lastIndexOf("/");return -1===t?"./":e.substring(0,t+1)}static basename(e){return R.basename(new URL(e,N).pathname)}static extension(e){return R.extension(new URL(e,N).pathname)}static resolve(e,t){if(!this.isRelativePath(t))return t;let r=e.split("/"),s=t.split("/");r.pop();for(let e=0;e<s.length;e++)"."!==s[e]&&(".."===s[e]?r.pop():r.push(s[e]));return r.join("/")}static isAbsoluteURL(e){return this.PROTOCOL_REGEXP.test(e)}static isRelativePath(e){return!/^(?:[a-zA-Z]+:)?\//.test(e)}}function v(e){return"[object Object]"===Object.prototype.toString.call(e)}function C(e){if(!1===v(e))return!1;let t=e.constructor;if(void 0===t)return!0;let r=t.prototype;return!1!==v(r)&&!1!==Object.hasOwn(r,"isPrototypeOf")}S.DEFAULT_INIT={},S.PROTOCOL_REGEXP=/^[a-zA-Z]+:\/\//,function(e){e[e.SILENT=4]="SILENT",e[e.ERROR=3]="ERROR",e[e.WARN=2]="WARN",e[e.INFO=1]="INFO",e[e.DEBUG=0]="DEBUG"}(l||(l={}));class _{constructor(e){this.verbosity=void 0,this.verbosity=e}debug(e){this.verbosity<=_.Verbosity.DEBUG&&console.debug(e)}info(e){this.verbosity<=_.Verbosity.INFO&&console.info(e)}warn(e){this.verbosity<=_.Verbosity.WARN&&console.warn(e)}error(e){this.verbosity<=_.Verbosity.ERROR&&console.error(e)}}_.Verbosity=l,_.DEFAULT_INSTANCE=new _(_.Verbosity.INFO);class O{static identity(e){return e}static eq(e,t,r=1e-5){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(Math.abs(e[s]-t[s])>r)return!1;return!0}static clamp(e,t,r){return e<t?t:e>r?r:e}static decodeNormalizedInt(e,t){switch(t){case 5126:return e;case 5123:return e/65535;case 5121:return e/255;case 5122:return Math.max(e/32767,-1);case 5120:return Math.max(e/127,-1);default:throw Error("Invalid component type.")}}static encodeNormalizedInt(e,t){switch(t){case 5126:return e;case 5123:return Math.round(65535*O.clamp(e,0,1));case 5121:return Math.round(255*O.clamp(e,0,1));case 5122:return Math.round(32767*O.clamp(e,-1,1));case 5120:return Math.round(127*O.clamp(e,-1,1));default:throw Error("Invalid component type.")}}static decompose(e,t,r,s){var i,n,a,o,l,u,f,h,c,g,p,d,m,T,E,x,y,R,M,I,w,N,S,v,C,_,O,F,U,L,D,B,P,V,j,z,G,k,Y,W,q,J,H,$,X,Z,K;let Q=A([e[0],e[1],e[2]]),ee=A([e[4],e[5],e[6]]),et=A([e[8],e[9],e[10]]);i=e[0],n=e[1],a=e[2],o=e[3],l=e[4],u=e[5],f=e[6],h=e[7],c=e[8],g=e[9],p=e[10],d=e[11],m=e[12],T=e[13],E=e[14],x=e[15],y=i*u-n*l,R=i*f-a*l,M=n*f-a*u,I=c*T-g*m,w=c*E-p*m,h*(i*(N=g*E-p*T)-n*w+a*I)-o*(l*N-u*w+f*I)+x*(c*M-g*R+p*y)-d*(m*M-T*R+E*y)<0&&(Q=-Q),t[0]=e[12],t[1]=e[13],t[2]=e[14];let er=e.slice(),es=1/Q,ei=1/ee,en=1/et;er[0]*=es,er[1]*=es,er[2]*=es,er[4]*=ei,er[5]*=ei,er[6]*=ei,er[8]*=en,er[9]*=en,er[10]*=en,v=S=new b(3),C=er[0],_=er[1],O=er[2],F=er[4],U=er[5],L=er[6],D=er[8],B=er[9],P=er[10],v[0]=Math.sqrt(C*C+_*_+O*O),v[1]=Math.sqrt(F
1*F+U*U+L*L),v[2]=Math.sqrt(D*D+B*B+P*P),V=1/S[0],j=1/S[1],z=1/S[2],G=er[0]*V,k=er[1]*j,Y=er[2]*z,W=er[4]*V,q=er[5]*j,J=er[6]*z,H=er[8]*V,$=er[9]*j,Z=G+q+(X=er[10]*z),K=0,Z>0?(K=2*Math.sqrt(Z+1),r[3]=.25*K,r[0]=(J-$)/K,r[1]=(H-Y)/K,r[2]=(k-W)/K):G>q&&G>X?(K=2*Math.sqrt(1+G-q-X),r[3]=(J-$)/K,r[0]=.25*K,r[1]=(k+W)/K,r[2]=(H+Y)/K):q>X?(K=2*Math.sqrt(1+q-G-X),r[3]=(H-Y)/K,r[0]=(k+W)/K,r[1]=.25*K,r[2]=(J+$)/K):(K=2*Math.sqrt(1+X-G-q),r[3]=(k-W)/K,r[0]=(H+Y)/K,r[1]=(J+$)/K,r[2]=.25*K),s[0]=Q,s[1]=ee,s[2]=et}static compose(e,t,r,s){let i=t[0],n=t[1],a=t[2],o=t[3],l=i+i,u=n+n,f=a+a,h=i*l,c=i*u,g=i*f,p=n*u,d=n*f,m=a*f,T=o*l,E=o*u,x=o*f,y=r[0],R=r[1],b=r[2];return s[0]=(1-(p+m))*y,s[1]=(c+x)*y,s[2]=(g-E)*y,s[3]=0,s[4]=(c-x)*R,s[5]=(1-(h+m))*R,s[6]=(d+T)*R,s[7]=0,s[8]=(g+E)*b,s[9]=(d-T)*b,s[10]=(1-(h+p))*b,s[11]=0,s[12]=e[0],s[13]=e[1],s[14]=e[2],s[15]=1,s}}function F(e,t){if(e===t)return!0;if(!!e!=!!t||!e||!t||e.length!==t.length)return!1;for(let r=0;r<e.length;r++)if(e[r]!==t[r])return!1;return!0}function U(e){return Array.isArray(e)||ArrayBuffer.isView(e)}let L="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",D=new Set,B=function(){let e="";for(let t=0;t<6;t++)e+=L.charAt(Math.floor(Math.random()*L.length));return e},P=function(){for(let e=0;e<999;e++){let e=B();if(!D.has(e))return D.add(e),e}return""},V=e=>e,j=new Set;class z extends h.tZ{constructor(e,t=""){super(e),this[h.id].name=t,this.init(),this.dispatchEvent({type:"create"})}getGraph(){return this.graph}getDefaults(){return Object.assign(super.getDefaults(),{name:"",extras:{}})}set(e,t){return Array.isArray(t)&&(t=t.slice()),super.set(e,t)}getName(){return this.get("name")}setName(e){return this.set("name",e)}getExtras(){return this.get("extras")}setExtras(e){return this.set("extras",e)}clone(){return new this.constructor(this.graph).copy(this,V)}copy(e,t=V){for(let e in this[h.id]){let t=this[h.id][e];if(t instanceof h.m$)this[h.Vy].has(e)||t.dispose();else if(t instanceof h._r||t instanceof h.mx)for(let e of t.values())e.dispose();else if(t instanceof h.kF)for(let e of t.values())e.dispose()}for(let r in e[h.id]){let s=this[h.id][r],i=e[h.id][r];if(i instanceof h.m$)this[h.Vy].has(r)?s.getChild().copy(t(i.getChild()),t):this.setRef(r,t(i.getChild()),i.getAttributes());else if(i instanceof h.mx||i instanceof h._r)for(let e of i.values())this.addRef(r,t(e.getChild()),e.getAttributes());else if(i instanceof h.kF)for(let e of i.keys()){let s=i.get(e);this.setRefMap(r,e,t(s.getChild()),s.getAttributes())}else C(i)?this[h.id][r]=JSON.parse(JSON.stringify(i)):Array.isArray(i)||i instanceof ArrayBuffer||ArrayBuffer.isView(i)?this[h.id][r]=i.slice():this[h.id][r]=i}return this}equals(e,t=j){if(this===e)return!0;if(this.propertyType!==e.propertyType)return!1;for(let r in this[h.id]){if(t.has(r))continue;let s=this[h.id][r],i=e[h.id][r];if(s instanceof h.m$||i instanceof h.m$){if(!function(e,t){if(!!e!=!!t)return!1;let r=e.getChild(),s=t.getChild();return r===s||r.equals(s)}(s,i))return!1}else if(s instanceof h.mx||i instanceof h.mx||s instanceof h._r||i instanceof h._r){if(!function(e,t){if(!!e!=!!t)return!1;let r=e.values(),s=t.values();if(r.length!==s.length)return!1;for(let e=0;e<r.length;e++){let t=r[e],i=s[e];if(t.getChild()!==i.getChild()&&!t.getChild().equals(i.getChild()))return!1}return!0}(s,i))return!1}else if(s instanceof h.kF||i instanceof h.kF){if(!function(e,t){if(!!e!=!!t)return!1;let r=e.keys(),s=t.keys();if(r.length!==s.length)return!1;for(let s of r){let r=e.get(s),i=t.get(s);if(!!r!=!!i)return!1;let n=r.getChild(),a=i.getChild();if(n!==a&&!n.equals(a))return!1}return!0}(s,i))return!1}else if(C(s)||C(i)){if(!function e(t,r){let s;if(t===r)return!0;if(!!t!=!!r)return!1;if(!C(t)||!C(r))return t===r;let i=0,n=0;for(s in t)i++;for(s in r)n++;if(i!==n)return!1;for(s in t){let i=t[s],n=r[s];if(U(i)&&U(n)){if(!F(i,n))return!1}else if(C(i)&&C(n)){if(!e(i,n))return!1}else if(i!==n)return!1}return!0}(s,i))return!1}else if(U(s)||U(i)){if(!F(s,i))return!1}else if(s!==i)return!1}return!0}detach(){return this.graph.disconnectParents(this,e=>"Root"!==e.propertyType),this}listParents(){return this.graph.listParents(this)}}class G extends z{getDefaults(){return Object.assign(super.getDefaults(),{extensions:new h.kF})}getExtension(e){return this.getRefMap("extensions",e)}setExtension(e,t){return t&&t._validateParent(this),this.setRefMap("extensions",e,t)}listExtensions(){return this.listRefMapValues("extensions")}}class k extends G{init(){this.propertyType=s.ACCESSOR}getDefaults(){return Object.assign(super.getDefaults(),{array:null,type:k.Type.SCALAR,componentType:k.ComponentType.FLOAT,normalized:!1,sparse:!1,buffer:null})}static getElementSize(e){switch(e){case k.Type.SCALAR:return 1;case k.Type.VEC2:return 2;case k.Type.VEC3:return 3;case k.Type.VEC4:case k.Type.MAT2:return 4;case k.Type.MAT3:return 9;
1case k.Type.MAT4:return 16;default:throw Error("Unexpected type: "+e)}}static getComponentSize(e){switch(e){case k.ComponentType.BYTE:case k.ComponentType.UNSIGNED_BYTE:return 1;case k.ComponentType.SHORT:case k.ComponentType.UNSIGNED_SHORT:return 2;case k.ComponentType.UNSIGNED_INT:case k.ComponentType.FLOAT:return 4;default:throw Error("Unexpected component type: "+e)}}getMinNormalized(e){let t=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType();if(this.getMin(e),t)for(let t=0;t<r;t++)e[t]=O.decodeNormalizedInt(e[t],s);return e}getMin(e){let t=this.getArray(),r=this.getCount(),s=this.getElementSize();for(let t=0;t<s;t++)e[t]=1/0;for(let i=0;i<r*s;i+=s)for(let r=0;r<s;r++){let s=t[i+r];Number.isFinite(s)&&(e[r]=Math.min(e[r],s))}return e}getMaxNormalized(e){let t=this.getNormalized(),r=this.getElementSize(),s=this.getComponentType();if(this.getMax(e),t)for(let t=0;t<r;t++)e[t]=O.decodeNormalizedInt(e[t],s);return e}getMax(e){let t=this.get("array"),r=this.getCount(),s=this.getElementSize();for(let t=0;t<s;t++)e[t]=-1/0;for(let i=0;i<r*s;i+=s)for(let r=0;r<s;r++){let s=t[i+r];Number.isFinite(s)&&(e[r]=Math.max(e[r],s))}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 k.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(),r=this.getComponentType(),s=this.getArray();return this.getNormalized()?O.decodeNormalizedInt(s[e*t],r):s[e*t]}setScalar(e,t){let r=this.getElementSize(),s=this.getComponentType(),i=this.getArray();return this.getNormalized()?i[e*r]=O.encodeNormalizedInt(t,s):i[e*r]=t,this}getElement(e,t){let r=this.getNormalized(),s=this.getElementSize(),i=this.getComponentType(),n=this.getArray();for(let a=0;a<s;a++)r?t[a]=O.decodeNormalizedInt(n[e*s+a],i):t[a]=n[e*s+a];return t}setElement(e,t){let r=this.getNormalized(),s=this.getElementSize(),i=this.getComponentType(),n=this.getArray();for(let a=0;a<s;a++)r?n[e*s+a]=O.encodeNormalizedInt(t[a],i):n[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?function(e){switch(e.constructor){case Float32Array:return k.ComponentType.FLOAT;case Uint32Array:return k.ComponentType.UNSIGNED_INT;case Uint16Array:return k.ComponentType.UNSIGNED_SHORT;case Uint8Array:return k.ComponentType.UNSIGNED_BYTE;case Int16Array:return k.ComponentType.SHORT;case Int8Array:return k.ComponentType.BYTE;default:throw Error("Unknown accessor componentType.")}}(e):k.ComponentType.FLOAT),this.set("array",e),this}getByteLength(){let e=this.get("array");return e?e.byteLength:0}}k.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT2:"MAT2",MAT3:"MAT3",MAT4:"MAT4"},k.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126};class Y extends G{init(){this.propertyType=s.ANIMATION}getDefaults(){return Object.assign(super.getDefaults(),{channels:new h.mx,samplers:new h.mx})}addChannel(e){return this.addRef("channels",e)}removeChannel(e){return this.removeRef("channels",e)}listChannels(){return this.listRefs("channels")}addSampler(e){return this.addRef("samplers",e)}removeSampler(e){return this.removeRef("samplers",e)}listSamplers(){return this.listRefs("samplers")}}class W extends G{init(){this.propertyType=s.ANIMATION_CHANNEL}getDefaults(){return Object.assign(super.getDefaults(),{targetPath:null,targetNode:null,sampler:null})}getTargetPath(){return this.get("targetPath")}setTargetPath(e){return this.set("targetPath",e)}getTargetNode(){return this.getRef("targetNode")}setTargetNode(e){return this.setRef("targetNode",e)}getSampler(){return this.getRef("sampler")}setSampler(e){return this.setRef("sampler",e)}}W.TargetPath={TRANSLATION:"translation",ROTATION:"rotation",SCALE:"scale",WEIGHTS:"weights"};
vendor: 4,293 bytes, line 1
1class q extends G{init(){this.propertyType=s.ANIMATION_SAMPLER}getDefaultAttributes(){return Object.assign(super.getDefaults(),{interpolation:q.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:n.OTHER})}getOutput(){return this.getRef("output")}setOutput(e){return this.setRef("output",e,{usage:n.OTHER})}}q.Interpolation={LINEAR:"LINEAR",STEP:"STEP",CUBICSPLINE:"CUBICSPLINE"};class J extends G{init(){this.propertyType=s.BUFFER}getDefaults(){return Object.assign(super.getDefaults(),{uri:""})}getURI(){return this.get("uri")}setURI(e){return this.set("uri",e)}}class H extends G{init(){this.propertyType=s.CAMERA}getDefaults(){return Object.assign(super.getDefaults(),{type:H.Type.PERSPECTIVE,znear:.1,zfar:100,aspectRatio:null,yfov:2*Math.PI*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)}}H.Type={PERSPECTIVE:"perspective",ORTHOGRAPHIC:"orthographic"};class $ extends z{_validateParent(e){if(!this.parentTypes.includes(e.propertyType))throw Error(`Parent "${e.propertyType}" invalid for child "${this.propertyType}".`)}}$.EXTENSION_NAME=void 0;class X extends G{init(){this.propertyType=s.TEXTURE_INFO}getDefaults(){return Object.assign(super.getDefaults(),{texCoord:0,magFilter:null,minFilter:null,wrapS:X.WrapMode.REPEAT,wrapT:X.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)}}X.WrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},X.MagFilter={NEAREST:9728,LINEAR:9729},X.MinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};let{R:Z,G:K,B:Q,A:ee}=a;class et extends G{init(){this.propertyType=s.MATERIAL}getDefaults(){return Object.assign(super.getDefaults(),{alphaMode:et.AlphaMode.OPAQUE,alphaCutoff:.5,doubleSided:!1,baseColorFactor:[1,1,1,1],baseColorTexture:null,baseColorTextureInfo:new X(this.graph,"baseColorTextureInfo"),emissiveFactor:[0,0,0],emissiveTexture:null,emissiveTextureInfo:new X(this.graph,"emissiveTextureInfo"),normalScale:1,normalTexture:null,normalTextureInfo:new X(this.graph,"normalTextureInfo"),occlusionStrength:1,occlusionTexture:null,occlusionTextureInfo:new X(this.graph,"occlusionTextureInfo"),roughnessFactor:1,metallicFactor:1,metallicRoughnessTexture:null,metallicRoughnessTextureInfo:new X(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:Z|K|Q|ee,isColor:!0})}getEmissiveFactor(){return this.get("emissiveFactor")}setEmissiveFactor(e){return this.set("emissiveFactor",e)}
1getEmissiveTexture(){return this.getRef("emissiveTexture")}getEmissiveTextureInfo(){return this.getRef("emissiveTexture")?this.getRef("emissiveTextureInfo"):null}setEmissiveTexture(e){return this.setRef("emissiveTexture",e,{channels:Z|K|Q,isColor:!0})}getNormalScale(){return this.get("normalScale")}setNormalScale(e){return this.set("normalScale",e)}getNormalTexture(){return this.getRef("normalTexture")}getNormalTextureInfo(){return this.getRef("normalTexture")?this.getRef("normalTextureInfo"):null}setNormalTexture(e){return this.setRef("normalTexture",e,{channels:Z|K|Q})}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:Z})}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:K|Q})}}et.AlphaMode={OPAQUE:"OPAQUE",MASK:"MASK",BLEND:"BLEND"};class er extends G{init(){this.propertyType=s.MESH}getDefaults(){return Object.assign(super.getDefaults(),{weights:[],primitives:new h.mx})}addPrimitive(e){return this.addRef("primitives",e)}removePrimitive(e){return this.removeRef("primitives",e)}listPrimitives(){return this.listRefs("primitives")}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}}class es extends G{init(){this.propertyType=s.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.mx})}copy(e,t=V){if(t===V)throw Error("Node cannot be copied.");return super.copy(e,t)}getTranslation(){return this.get("translation")}getRotation(){return this.get("rotation")}getScale(){return this.get("scale")}setTranslation(e){return this.set("translation",e)}setRotation(e){return this.set("rotation",e)}setScale(e){return this.set("scale",e)}getMatrix(){return O.compose(this.get("translation"),this.get("rotation"),this.get("scale"),[])}setMatrix(e){let t=this.get("translation").slice(),r=this.get("rotation").slice(),s=this.get("scale").slice();return O.decompose(e,t,r,s),this.set("translation",t).set("rotation",r).set("scale",s)}getWorldTranslation(){let e=[0,0,0];return O.decompose(this.getWorldMatrix(),e,[0,0,0,1],[1,1,1]),e}getWorldRotation(){let e=[0,0,0,1];return O.decompose(this.getWorldMatrix(),[0,0,0],e,[1,1,1]),e}getWorldScale(){let e=[1,1,1];return O.decompose(this.getWorldMatrix(),[0,0,0],[0,0,0,1],e),e}getWorldMatrix(){let e,t=[];for(let e=this;null!=e;e=e.getParentNode())t.push(e);let r=t.pop().getMatrix();for(;e=t.pop();)!function(e,t,r){var s=t[0],i=t[1],n=t[2],a=t[3],o=t[4],l=t[5],u=t[6],f=t[7],h=t[8],c=t[9],g=t[10],p=t[11],d=t[12],m=t[13],T=t[14],E=t[15],x=r[0],y=r[1],R=r[2],b=r[3];e[0]=x*s+y*o+R*h+b*d,e[1]=x*i+y*l+R*c+b*m,e[2]=x*n+y*u+R*g+b*T,e[3]=x*a+y*f+R*p+b*E,x=r[4],y=r[5],R=r[6],b=r[7],e[4]=x*s+y*o+R*h+b*d,e[5]=x*i+y*l+R*c+b*m,e[6]=x*n+y*u+R*g+b*T,e[7]=x*a+y*f+R*p+b*E,x=r[8],y=r[9],R=r[10],b=r[11],e[8]=x*s+y*o+R*h+b*d,e[9]=x*i+y*l+R*c+b*m,e[10]=x*n+y*u+R*g+b*T,e[11]=x*a+y*f+R*p+b*E,x=r[12],y=r[13],R=r[14],b=r[15],e[12]=x*s+y*o+R*h+b*d,e[13]=x*i+y*l+R*c+b*m,e[14]=x*n+y*u+R*g+b*T,e[15]=x*a+y*f+R*p+b*E}(r,r,e.getMatrix());return r}addChild(e){let t=e.getParentNode();for(let r of(t&&t.removeChild(e),e.listParents()))r.propertyType===s.SCENE&&r.removeChild(e);return this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}getParentNode(){for(let e of this.listParents())if(e.propertyType===s.NODE)return e;return null}getMesh(){return this.getRef("mesh")}setMesh(e){return this.setRef("mesh",e)}getCamera(){return this.getRef("camera")}setCamera(e){return this.setRef("camera",e)}getSkin(){return this.getRef("skin")}setSkin(e){return this.setRef("skin",e)}getWeights(){return this.get("weights")}setWeights(e){return this.set("weights",e)}traverse(e){for(let t of(e(this),this.listChildren()))t.traverse(e);return this}}class ei extends G{init(){this.propertyType=s.PRIMITIVE}getDefaults(){return Object.assign(super.getDefaults(),{mode:ei.Mode.TRIANGLES,material:null,indices:null,attributes:new h.kF,targets:new h.mx})}getIndices(){return this.getRef("indices")}setIndices(e){return this.setRef("indices",e,{usage:n.ELEMENT_ARRAY_BUFFER})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:n.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)}}ei.Mode={POINTS:0,LINES:1,LINE_LOOP:2,LINE_STRIP:3,TRIANGLES:4,TRIANGLE_STRIP:5,TRIANGLE_FAN:6};class en extends z{init(){this.propertyType=s.PRIMITIVE_TARGET}getDefaults(){return Object.assign(super.getDefaults(),{attributes:new h.kF})}getAttribute(e){return this.getRefMap("attributes",e)}setAttribute(e,t){return this.setRefMap("attributes",e,t,{usage:n.ARRAY_BUFFER})}listAttributes(){return this.listRefMapValues("attributes")}listSemantics(){return this.listRefMapKeys("attributes")}}function ea(){return(ea=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var s in r)({}
1).hasOwnProperty.call(r,s)&&(e[s]=r[s])}return e}).apply(null,arguments)}class eo extends G{init(){this.propertyType=s.SCENE}getDefaults(){return Object.assign(super.getDefaults(),{children:new h.mx})}copy(e,t=V){if(t===V)throw Error("Scene cannot be copied.");return super.copy(e,t)}addChild(e){let t=e.getParentNode();return t&&t.removeChild(e),this.addRef("children",e)}removeChild(e){return this.removeRef("children",e)}listChildren(){return this.listRefs("children")}traverse(e){for(let t of this.listChildren())t.traverse(e);return this}}class el extends G{init(){this.propertyType=s.SKIN}getDefaults(){return Object.assign(super.getDefaults(),{skeleton:null,inverseBindMatrices:null,joints:new h.mx})}getSkeleton(){return this.getRef("skeleton")}setSkeleton(e){return this.setRef("skeleton",e)}getInverseBindMatrices(){return this.getRef("inverseBindMatrices")}setInverseBindMatrices(e){return this.setRef("inverseBindMatrices",e,{usage:n.INVERSE_BIND_MATRICES})}addJoint(e){return this.addRef("joints",e)}removeJoint(e){return this.removeRef("joints",e)}listJoints(){return this.listRefs("joints")}}class eu extends G{init(){this.propertyType=s.TEXTURE}getDefaults(){return Object.assign(super.getDefaults(),{image:null,mimeType:"",uri:""})}getMimeType(){return this.get("mimeType")||y.extensionToMimeType(R.extension(this.get("uri")))}setMimeType(e){return this.set("mimeType",e)}getURI(){return this.get("uri")}setURI(e){this.set("uri",e);let t=y.extensionToMimeType(R.extension(e));return t&&this.set("mimeType",t),this}getImage(){return this.get("image")}setImage(e){return this.set("image",m.assertView(e))}getSize(){let e=this.get("image");return e?y.getSize(e,this.getMimeType()):null}}class ef extends G{init(){this.propertyType=s.ROOT}getDefaults(){return Object.assign(super.getDefaults(),{asset:{generator:`glTF-Transform ${g}`,version:"2.0"},defaultScene:null,accessors:new h.mx,animations:new h.mx,buffers:new h.mx,cameras:new h.mx,materials:new h.mx,meshes:new h.mx,nodes:new h.mx,scenes:new h.mx,skins:new h.mx,textures:new h.mx})}constructor(e){super(e),this._extensions=new Set,e.addEventListener("node:create",e=>{this._addChildOfRoot(e.target)})}clone(){throw Error("Root cannot be cloned.")}copy(e,t=V){if(t===V)throw Error("Root cannot be copied.");for(let r of(this.set("asset",ea({},e.get("asset"))),this.setName(e.getName()),this.setExtras(ea({},e.getExtras())),this.setDefaultScene(e.getDefaultScene()?t(e.getDefaultScene()):null),e.listRefMapKeys("extensions"))){let s=e.getExtension(r);this.setExtension(r,t(s))}return this}_addChildOfRoot(e){return e instanceof eo?this.addRef("scenes",e):e instanceof es?this.addRef("nodes",e):e instanceof H?this.addRef("cameras",e):e instanceof el?this.addRef("skins",e):e instanceof er?this.addRef("meshes",e):e instanceof et?this.addRef("materials",e):e instanceof eu?this.addRef("textures",e):e instanceof Y?this.addRef("animations",e):e instanceof k?this.addRef("accessors",e):e instanceof J&&this.addRef("buffers",e),this}getAsset(){return this.get("asset")}listExtensionsUsed(){return Array.from(this._extensions)}listExtensionsRequired(){return this.listExtensionsUsed().filter(e=>e.isRequired())}_enableExtension(e){return this._extensions.add(e),this}_disableExtension(e){return this._extensions.delete(e),this}listScenes(){return this.listRefs("scenes")}setDefaultScene(e){return this.setRef("defaultScene",e)}getDefaultScene(){return this.getRef("defaultScene")}listNodes(){return this.listRefs("nodes")}listCameras(){return this.listRefs("cameras")}listSkins(){return this.listRefs("skins")}listMeshes(){return this.listRefs("meshes")}listMaterials(){return this.listRefs("materials")}listTextures(){return this.listRefs("textures")}listAnimations(){return this.listRefs("animations")}listAccessors(){return this.listRefs("accessors")}listBuffers(){return this.listRefs("buffers")}}class eh{static fromGraph(e){return eh._GRAPH_DOCUMENTS.get(e)||null}constructor(){this._graph=new h.TS,this._root=new ef(this._graph),this._logger=_.DEFAULT_INSTANCE,eh._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 Error("Use 'cloneDocument(source)' from '@gltf-transform/functions'.")}merge(e){throw Error("Use 'mergeDocuments(target, source)' from '@gltf-transform/functions'.")}async transform(...e){let t=e.map(e=>e.name);for(let r of e)await r(this,{stack:t});return this}createExtension(e){let t=e.EXTENSION_NAME;return this.getRoot().listExtensionsUsed().find(e=>e.extensionName===t)||new e(this)}disposeExtension(e){let t=this.getRoot().listExtensionsUsed().find(t=>t.extensionName===e);t&&t.dispose()}createScene(e=""){return new eo(this._graph,e)}createNode(e=""){return new es(this._graph,e)}createCamera(e=""){return new H(this._graph,e)}createSkin(e=""){return new el(this._graph,e)}createMesh(e=""){return new er(this._graph,e)}createPrimitive(){return new ei(this._graph)}createPrimitiveTarget(e=""){return new en(this._graph,e)}createMaterial(e=""){return new et(this._graph,e)}createTexture(e=""){return new eu(this._graph,e)}createAnimation(e=""){return new Y(this._graph,e)}
1createAnimationChannel(e=""){return new W(this._graph,e)}createAnimationSampler(e=""){return new q(this._graph,e)}createAccessor(e="",t=null){return t||(t=this.getRoot().listBuffers()[0]),new k(this._graph,e).setBuffer(t)}createBuffer(e=""){return new J(this._graph,e)}}eh._GRAPH_DOCUMENTS=new WeakMap;class ec{constructor(e){this.extensionName="",this.prereadTypes=[],this.prewriteTypes=[],this.readDependencies=[],this.writeDependencies=[],this.document=void 0,this.required=!1,this.properties=new Set,this._listener=void 0,this.document=e,e.getRoot()._enableExtension(this),this._listener=e=>{let t=e.target;t instanceof $&&t.extensionName===this.extensionName&&("node:create"===e.type&&this._addExtensionProperty(t),"node:dispose"===e.type&&this._removeExtensionProperty(t))};let t=e.getGraph();t.addEventListener("node:create",this._listener),t.addEventListener("node:dispose",this._listener)}dispose(){this.document.getRoot()._disableExtension(this);let e=this.document.getGraph();for(let t of(e.removeEventListener("node:create",this._listener),e.removeEventListener("node:dispose",this._listener),this.properties))t.dispose()}static register(){}isRequired(){return this.required}setRequired(e){return this.required=e,this}listProperties(){return Array.from(this.properties)}_addExtensionProperty(e){return this.properties.add(e),this}_removeExtensionProperty(e){return this.properties.delete(e),this}install(e,t){return this}preread(e,t){return this}prewrite(e,t){return this}}ec.EXTENSION_NAME=void 0;class eg{constructor(e){this.jsonDoc=void 0,this.buffers=[],this.bufferViews=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[],this.jsonDoc=e}setTextureInfo(e,t){this.textureInfos.set(e,t),void 0!==t.texCoord&&e.setTexCoord(t.texCoord),void 0!==t.extras&&e.setExtras(t.extras);let r=this.jsonDoc.json.textures[t.index];if(void 0===r.sampler)return;let s=this.jsonDoc.json.samplers[r.sampler];void 0!==s.magFilter&&e.setMagFilter(s.magFilter),void 0!==s.minFilter&&e.setMinFilter(s.minFilter),void 0!==s.wrapS&&e.setWrapS(s.wrapS),void 0!==s.wrapT&&e.setWrapT(s.wrapT)}}let ep={logger:_.DEFAULT_INSTANCE,extensions:[],dependencies:{}},ed=new Set([s.BUFFER,s.TEXTURE,s.MATERIAL,s.MESH,s.PRIMITIVE,s.NODE,s.SCENE]);class em{static read(e,t=ep){let r=ea({},ep,t),{json:i}=e,n=new eh().setLogger(r.logger);this.validate(e,r);let a=new eg(e),o=i.asset,l=n.getRoot().getAsset();o.copyright&&(l.copyright=o.copyright),o.extras&&(l.extras=o.extras),void 0!==i.extras&&n.getRoot().setExtras(ea({},i.extras));let u=i.extensionsUsed||[],f=i.extensionsRequired||[];for(let e of(r.extensions.sort((e,t)=>e.EXTENSION_NAME>t.EXTENSION_NAME?1:-1),r.extensions))if(u.includes(e.EXTENSION_NAME)){let t=n.createExtension(e).setRequired(f.includes(e.EXTENSION_NAME)),s=t.prereadTypes.filter(e=>!ed.has(e));for(let e of(s.length&&r.logger.warn(`Preread hooks for some types (${s.join()}), requested by extension ${t.extensionName}, are unsupported. Please file an issue or a PR.`),t.readDependencies))t.install(e,r.dependencies[e])}let h=i.buffers||[];n.getRoot().listExtensionsUsed().filter(e=>e.prereadTypes.includes(s.BUFFER)).forEach(e=>e.preread(a,s.BUFFER)),a.buffers=h.map(e=>{let t=n.createBuffer(e.name);return e.extras&&t.setExtras(e.extras),e.uri&&0!==e.uri.indexOf("__")&&t.setURI(e.uri),t}),a.bufferViewBuffers=(i.bufferViews||[]).map((t,r)=>{if(!a.bufferViews[r]){let s=e.json.buffers[t.buffer],i=s.uri?e.resources[s.uri]:e.resources[p],n=t.byteOffset||0;a.bufferViews[r]=m.toView(i,n,t.byteLength)}return a.buffers[t.buffer]});let c=i.accessors||[];a.accessors=c.map(e=>{let t=a.bufferViewBuffers[e.bufferView],r=n.createAccessor(e.name,t).setType(e.type);return e.extras&&r.setExtras(e.extras),void 0!==e.normalized&&r.setNormalized(e.normalized),void 0===e.bufferView||r.setArray(eT(e,a)),r});let g=i.images||[],T=i.textures||[];n.getRoot().listExtensionsUsed().filter(e=>e.prereadTypes.includes(s.TEXTURE)).forEach(e=>e.preread(a,s.TEXTURE)),a.textures=g.map(t=>{let r=n.createTexture(t.name);if(t.extras&&r.setExtras(t.extras),void 0!==t.bufferView){let s=i.bufferViews[t.bufferView],n=e.json.buffers[s.buffer],a=n.uri?e.resources[n.uri]:e.resources[p],o=s.byteOffset||0,l=s.byteLength,u=a.slice(o,o+l);r.setImage(u)}else void 0!==t.uri&&(r.setImage(e.resources[t.uri]),0!==t.uri.indexOf("__")&&r.setURI(t.uri));if(void 0!==t.mimeType)r.setMimeType(t.mimeType);else if(t.uri){let e=R.extension(t.uri);r.setMimeType(y.extensionToMimeType(e))}return r}),n.getRoot().listExtensionsUsed().filter(e=>
1e.prereadTypes.includes(s.MATERIAL)).forEach(e=>e.preread(a,s.MATERIAL)),a.materials=(i.materials||[]).map(e=>{let t=n.createMaterial(e.name);e.extras&&t.setExtras(e.extras),void 0!==e.alphaMode&&t.setAlphaMode(e.alphaMode),void 0!==e.alphaCutoff&&t.setAlphaCutoff(e.alphaCutoff),void 0!==e.doubleSided&&t.setDoubleSided(e.doubleSided);let r=e.pbrMetallicRoughness||{};if(void 0!==r.baseColorFactor&&t.setBaseColorFactor(r.baseColorFactor),void 0!==e.emissiveFactor&&t.setEmissiveFactor(e.emissiveFactor),void 0!==r.metallicFactor&&t.setMetallicFactor(r.metallicFactor),void 0!==r.roughnessFactor&&t.setRoughnessFactor(r.roughnessFactor),void 0!==r.baseColorTexture){let e=r.baseColorTexture,s=a.textures[T[e.index].source];t.setBaseColorTexture(s),a.setTextureInfo(t.getBaseColorTextureInfo(),e)}if(void 0!==e.emissiveTexture){let r=e.emissiveTexture,s=a.textures[T[r.index].source];t.setEmissiveTexture(s),a.setTextureInfo(t.getEmissiveTextureInfo(),r)}if(void 0!==e.normalTexture){let r=e.normalTexture,s=a.textures[T[r.index].source];t.setNormalTexture(s),a.setTextureInfo(t.getNormalTextureInfo(),r),void 0!==e.normalTexture.scale&&t.setNormalScale(e.normalTexture.scale)}if(void 0!==e.occlusionTexture){let r=e.occlusionTexture,s=a.textures[T[r.index].source];t.setOcclusionTexture(s),a.setTextureInfo(t.getOcclusionTextureInfo(),r),void 0!==e.occlusionTexture.strength&&t.setOcclusionStrength(e.occlusionTexture.strength)}if(void 0!==r.metallicRoughnessTexture){let e=r.metallicRoughnessTexture,s=a.textures[T[e.index].source];t.setMetallicRoughnessTexture(s),a.setTextureInfo(t.getMetallicRoughnessTextureInfo(),e)}return t}),n.getRoot().listExtensionsUsed().filter(e=>e.prereadTypes.includes(s.MESH)).forEach(e=>e.preread(a,s.MESH));let E=i.meshes||[];n.getRoot().listExtensionsUsed().filter(e=>e.prereadTypes.includes(s.PRIMITIVE)).forEach(e=>e.preread(a,s.PRIMITIVE)),a.meshes=E.map(e=>{let t=n.createMesh(e.name);return e.extras&&t.setExtras(e.extras),void 0!==e.weights&&t.setWeights(e.weights),(e.primitives||[]).forEach(r=>{let s=n.createPrimitive();for(let[e,t]of(r.extras&&s.setExtras(r.extras),void 0!==r.material&&s.setMaterial(a.materials[r.material]),void 0!==r.mode&&s.setMode(r.mode),Object.entries(r.attributes||{})))s.setAttribute(e,a.accessors[t]);void 0!==r.indices&&s.setIndices(a.accessors[r.indices]);let i=e.extras&&e.extras.targetNames||[];(r.targets||[]).forEach((e,t)=>{let r=i[t]||t.toString(),o=n.createPrimitiveTarget(r);for(let[t,r]of Object.entries(e))o.setAttribute(t,a.accessors[r]);s.addTarget(o)}),t.addPrimitive(s)}),t}),a.cameras=(i.cameras||[]).map(e=>{let t=n.createCamera(e.name).setType(e.type);if(e.extras&&t.setExtras(e.extras),e.type===H.Type.PERSPECTIVE){let r=e.perspective;t.setYFov(r.yfov),t.setZNear(r.znear),void 0!==r.zfar&&t.setZFar(r.zfar),void 0!==r.aspectRatio&&t.setAspectRatio(r.aspectRatio)}else{let r=e.orthographic;t.setZNear(r.znear).setZFar(r.zfar).setXMag(r.xmag).setYMag(r.ymag)}return t});let x=i.nodes||[];n.getRoot().listExtensionsUsed().filter(e=>e.prereadTypes.includes(s.NODE)).forEach(e=>e.preread(a,s.NODE)),a.nodes=x.map(e=>{let t=n.createNode(e.name);if(e.extras&&t.setExtras(e.extras),void 0!==e.translation&&t.setTranslation(e.translation),void 0!==e.rotation&&t.setRotation(e.rotation),void 0!==e.scale&&t.setScale(e.scale),void 0!==e.matrix){let r=[0,0,0],s=[0,0,0,1],i=[1,1,1];O.decompose(e.matrix,r,s,i),t.setTranslation(r),t.setRotation(s),t.setScale(i)}return void 0!==e.weights&&t.setWeights(e.weights),t}),a.skins=(i.skins||[]).map(e=>{let t=n.createSkin(e.name);for(let r of(e.extras&&t.setExtras(e.extras),void 0!==e.inverseBindMatrices&&t.setInverseBindMatrices(a.accessors[e.inverseBindMatrices]),void 0!==e.skeleton&&t.setSkeleton(a.nodes[e.skeleton]),e.joints))t.addJoint(a.nodes[r]);return t}),x.map((e,t)=>{let r=a.nodes[t];(e.children||[]).forEach(e=>r.addChild(a.nodes[e])),void 0!==e.mesh&&r.setMesh(a.meshes[e.mesh]),void 0!==e.camera&&r.setCamera(a.cameras[e.camera]),void 0!==e.skin&&r.setSkin(a.skins[e.skin])}),a.animations=(i.animations||[]).map(e=>{let t=n.createAnimation(e.name);e.extras&&t.setExtras(e.extras);let r=(e.samplers||[]).map(e=>{let r=n.createAnimationSampler().setInput(a.accessors[e.input]).setOutput(a.accessors[e.output]).setInterpolation(e.interpolation||q.Interpolation.LINEAR);return e.extras&&r.setExtras(e.extras),t.addSampler(r),r});
1return(e.channels||[]).forEach(e=>{let s=n.createAnimationChannel().setSampler(r[e.sampler]).setTargetPath(e.target.path);void 0!==e.target.node&&s.setTargetNode(a.nodes[e.target.node]),e.extras&&s.setExtras(e.extras),t.addChannel(s)}),t});let b=i.scenes||[];return n.getRoot().listExtensionsUsed().filter(e=>e.prereadTypes.includes(s.SCENE)).forEach(e=>e.preread(a,s.SCENE)),a.scenes=b.map(e=>{let t=n.createScene(e.name);return e.extras&&t.setExtras(e.extras),(e.nodes||[]).map(e=>a.nodes[e]).forEach(e=>t.addChild(e)),t}),void 0!==i.scene&&n.getRoot().setDefaultScene(a.scenes[i.scene]),n.getRoot().listExtensionsUsed().forEach(e=>e.read(a)),c.forEach((e,t)=>{let r=a.accessors[t],s=!!e.sparse,i=!e.bufferView&&!r.getArray();(s||i)&&r.setSparse(!0).setArray(function(e,t){let r,s=d[e.componentType],i=k.getElementSize(e.type);r=void 0!==e.bufferView?eT(e,t):new s(e.count*i);let n=e.sparse;if(!n)return r;let a=n.count,o=ea({},e,n.indices,{count:a,type:"SCALAR"}),l=ea({},e,n.values,{count:a}),u=eT(o,t),f=eT(l,t);for(let e=0;e<o.count;e++)for(let t=0;t<i;t++)r[u[e]*i+t]=f[e*i+t];return r}(e,a))}),n}static validate(e,t){let r=e.json;if("2.0"!==r.asset.version)throw Error(`Unsupported glTF version, "${r.asset.version}".`);if(r.extensionsRequired){for(let e of r.extensionsRequired)if(!t.extensions.find(t=>t.EXTENSION_NAME===e))throw Error(`Missing required extension, "${e}".`)}if(r.extensionsUsed)for(let e of r.extensionsUsed)t.extensions.find(t=>t.EXTENSION_NAME===e)||t.logger.warn(`Missing optional extension, "${e}".`)}}function eT(e,t){let r=t.jsonDoc,s=t.bufferViews[e.bufferView],i=r.json.bufferViews[e.bufferView],n=d[e.componentType],a=k.getElementSize(e.type),o=n.BYTES_PER_ELEMENT;if(void 0!==i.byteStride&&i.byteStride!==a*o)return function(e,t){let r=t.jsonDoc,s=t.bufferViews[e.bufferView],i=r.json.bufferViews[e.bufferView],n=d[e.componentType],a=k.getElementSize(e.type),o=n.BYTES_PER_ELEMENT,l=e.byteOffset||0,u=new n(e.count*a),f=new DataView(s.buffer,s.byteOffset,s.byteLength),h=i.byteStride;for(let t=0;t<e.count;t++)for(let r=0;r<a;r++){let s,i=l+t*h+r*o;switch(e.componentType){case k.ComponentType.FLOAT:s=f.getFloat32(i,!0);break;case k.ComponentType.UNSIGNED_INT:s=f.getUint32(i,!0);break;case k.ComponentType.UNSIGNED_SHORT:s=f.getUint16(i,!0);break;case k.ComponentType.UNSIGNED_BYTE:s=f.getUint8(i);break;case k.ComponentType.SHORT:s=f.getInt16(i,!0);break;case k.ComponentType.BYTE:s=f.getInt8(i);break;default:throw Error(`Unexpected componentType "${e.componentType}".`)}u[t*a+r]=s}return u}(e,t);let l=s.byteOffset+(e.byteOffset||0),u=e.count*a*o;return new n(s.buffer.slice(l,l+u))}!function(e){e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"}(u||(u={}));class eE{constructor(e,t,r){this._doc=void 0,this.jsonDoc=void 0,this.options=void 0,this.accessorIndexMap=new Map,this.animationIndexMap=new Map,this.bufferIndexMap=new Map,this.cameraIndexMap=new Map,this.skinIndexMap=new Map,this.materialIndexMap=new Map,this.meshIndexMap=new Map,this.nodeIndexMap=new Map,this.imageIndexMap=new Map,this.textureDefIndexMap=new Map,this.textureInfoDefMap=new Map,this.samplerDefIndexMap=new Map,this.sceneIndexMap=new Map,this.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={},this.bufferURIGenerator=void 0,this.imageURIGenerator=void 0,this.logger=void 0,this._accessorUsageMap=new Map,this.accessorUsageGroupedByParent=new Set(["ARRAY_BUFFER"]),this.accessorParents=new Map,this._doc=e,this.jsonDoc=t,this.options=r;let s=e.getRoot(),i=s.listBuffers().length,n=s.listTextures().length;this.bufferURIGenerator=new ex(i>1,()=>r.basename||"buffer"),this.imageURIGenerator=new ex(n>1,t=>(function(e,t){let r=e.getGraph().listParentEdges(t).find(t=>t.getParent()!==e.getRoot());return r?r.getName().replace(/texture$/i,""):""})(e,t)||r.basename||"texture"),this.logger=e.getLogger()}createTextureInfoDef(e,t){let r={magFilter:t.getMagFilter()||void 0,minFilter:t.getMinFilter()||void 0,wrapS:t.getWrapS(),wrapT:t.getWrapT()},s=JSON.stringify(r);this.samplerDefIndexMap.has(s)||(this.samplerDefIndexMap.set(s,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(r));let i={source:this.imageIndexMap.get(e),sampler:this.samplerDefIndexMap.get(s)},n=JSON.stringify(i);this.textureDefIndexMap.has(n)||(this.textureDefIndexMap.set(n,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(i));let a={index:this.textureDefIndexMap.get(n)};return 0!==t.getTexCoord()&&(a.texCoord=t.getTexCoord()),Object.keys(t.getExtras()).length>0&&(a.extras=t.getExtras()),this.textureInfoDefMap.set(t,a),a}createPropertyDef(e){let t={};return e.getName()&&(t.name=e.getName()),Object.keys(e.getExtras()).length>0&&(t.extras=e.getExtras()),t}createAccessorDef(e){let t=this.createPropertyDef(e);return t.type=e.getType(),t.componentType=e.getComponentType(),t.count=e.getCount(),this._doc.getGraph().listParentEdges(e).some(e=>"attributes"===e.getName()&&"POSITION"===e.getAttributes().key||"input"===e.getName())&&(t.max=e.getMax([]).map(Math.fround),t.min=e.getMin([]).map(Math.fround)),e.getNormalized()&&(t.normalized=e.getNormalized()),t}createImageData(e,t,r){if(this.options.format===o.GLB)this.imageBufferViews.push(t),e.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:t.byteLength});else{let s=y.mimeTypeToExtension(r.getMimeType());e.uri=this.imageURIGenerator.createURI(r,s),this.assignResourceURI(e.uri,t,!1)}}assignResourceURI(e,t,r){let s=this.jsonDoc.resources;
1if(!(e in s)){s[e]=t;return}if(t===s[e])return void this.logger.warn(`Duplicate resource URI, "${e}".`);let i=`Resource URI "${e}" already assigned to different data.`;if(!r)return void this.logger.warn(i);throw Error(i)}getAccessorUsage(e){let t=this._accessorUsageMap.get(e);if(t)return t;if(e.getSparse())return n.SPARSE;for(let t of this._doc.getGraph().listParentEdges(e)){let{usage:e}=t.getAttributes();if(e)return e;t.getParent().propertyType!==s.ROOT&&this.logger.warn(`Missing attribute ".usage" on edge, "${t.getName()}".`)}return n.OTHER}addAccessorToUsageGroup(e,t){let r=this._accessorUsageMap.get(e);if(r&&r!==t)throw Error(`Accessor with usage "${r}" cannot be reused as "${t}".`);return this._accessorUsageMap.set(e,t),this}}eE.BufferViewTarget=u,eE.BufferViewUsage=n,eE.USAGE_TO_TARGET={[n.ARRAY_BUFFER]:u.ARRAY_BUFFER,[n.ELEMENT_ARRAY_BUFFER]:u.ELEMENT_ARRAY_BUFFER};class ex{constructor(e,t){this.multiple=void 0,this.basename=void 0,this.counter={},this.multiple=e,this.basename=t}createURI(e,t){if(e.getURI())return e.getURI();{if(!this.multiple)return`${this.basename(e)}.${t}`;let r=this.basename(e);return this.counter[r]=this.counter[r]||1,`${r}_${this.counter[r]++}.${t}`}}}let{BufferViewUsage:ey}=eE,{UNSIGNED_INT:eR,UNSIGNED_SHORT:eb,UNSIGNED_BYTE:eA}=k.ComponentType,eM=new Set([s.ACCESSOR,s.BUFFER,s.MATERIAL,s.MESH]);class eI{static write(e,t){let r=e.getGraph(),n=e.getRoot(),a={asset:ea({generator:`glTF-Transform ${g}`},n.getAsset()),extras:ea({},n.getExtras())},l={json:a,resources:{}},u=new eE(e,l,t),f=t.logger||_.DEFAULT_INSTANCE,h=new Set(t.extensions.map(e=>e.EXTENSION_NAME)),c=e.getRoot().listExtensionsUsed().filter(e=>h.has(e.extensionName)).sort((e,t)=>e.extensionName>t.extensionName?1:-1),T=e.getRoot().listExtensionsRequired().filter(e=>h.has(e.extensionName)).sort((e,t)=>e.extensionName>t.extensionName?1:-1);for(let r of(c.length<e.getRoot().listExtensionsUsed().length&&f.warn("Some extensions were not registered for I/O, and will not be written."),c)){let e=r.prewriteTypes.filter(e=>!eM.has(e));for(let s of(e.length&&f.warn(`Prewrite hooks for some types (${e.join()}), requested by extension ${r.extensionName}, are unsupported. Please file an issue or a PR.`),r.writeDependencies))r.install(s,t.dependencies[s])}function E(e,t,r,s){let i=[],n=0;for(let t of e){let e=u.createAccessorDef(t);e.bufferView=a.bufferViews.length;let r=t.getArray(),s=m.pad(m.toView(r));e.byteOffset=n,n+=s.byteLength,i.push(s),u.accessorIndexMap.set(t,a.accessors.length),a.accessors.push(e)}let o={buffer:t,byteOffset:r,byteLength:m.concat(i).byteLength};return s&&(o.target=s),a.bufferViews.push(o),{buffers:i,byteLength:n}}function x(e,t,r){let s=e[0].getCount(),i=0;for(let t of e){let e=u.createAccessorDef(t);e.bufferView=a.bufferViews.length,e.byteOffset=i;let r=t.getElementSize(),s=t.getComponentSize();i+=m.padNumber(r*s),u.accessorIndexMap.set(t,a.accessors.length),a.accessors.push(e)}let n=s*i,o=new ArrayBuffer(n),l=new DataView(o);for(let t=0;t<s;t++){let r=0;for(let s of e){let e=s.getElementSize(),n=s.getComponentSize(),a=s.getComponentType(),o=s.getArray();for(let s=0;s<e;s++){let u=t*i+r+s*n,f=o[t*e+s];switch(a){case k.ComponentType.FLOAT:l.setFloat32(u,f,!0);break;case k.ComponentType.BYTE:l.setInt8(u,f);break;case k.ComponentType.SHORT:l.setInt16(u,f,!0);break;case k.ComponentType.UNSIGNED_BYTE:l.setUint8(u,f);break;case k.ComponentType.UNSIGNED_SHORT:l.setUint16(u,f,!0);break;case k.ComponentType.UNSIGNED_INT:l.setUint32(u,f,!0);break;default:throw Error("Unexpected component type: "+a)}}r+=m.padNumber(e*n)}}let f={buffer:t,byteOffset:r,byteLength:n,byteStride:i,target:eE.BufferViewTarget.ARRAY_BUFFER};return a.bufferViews.push(f),{byteLength:n,buffers:[new Uint8Array(o)]}}if(a.accessors=[],a.bufferViews=[],a.samplers=[],a.textures=[],a.images=n.listTextures().map((e,t)=>{let r=u.createPropertyDef(e);e.getMimeType()&&(r.mimeType=e.getMimeType());let s=e.getImage();return s&&u.createImageData(r,s,e),u.imageIndexMap.set(e,t),r}),c.filter(e=>e.prewriteTypes.includes(s.ACCESSOR)).forEach(e=>
1e.prewrite(u,s.ACCESSOR)),n.listAccessors().forEach(e=>{let t=u.accessorUsageGroupedByParent,i=u.accessorParents;if(u.accessorIndexMap.has(e))return;let n=u.getAccessorUsage(e);if(u.addAccessorToUsageGroup(e,n),t.has(n)){let t=r.listParents(e).find(e=>e.propertyType!==s.ROOT);i.set(e,t)}}),c.filter(e=>e.prewriteTypes.includes(s.BUFFER)).forEach(e=>e.prewrite(u,s.BUFFER)),(n.listAccessors().length>0||u.otherBufferViews.size>0||n.listTextures().length>0&&t.format===o.GLB)&&0===n.listBuffers().length)throw Error("Buffer required for Document resources, but none was found.");a.buffers=[],n.listBuffers().forEach((e,r)=>{let s=u.createPropertyDef(e),n=u.accessorUsageGroupedByParent,l=e.listParents().filter(e=>e instanceof k),h=new Map(Array.from(new Set(l.map(e=>u.accessorParents.get(e)))).map((e,t)=>[e,t])),c={};for(let e of l){var g;if(u.accessorIndexMap.has(e))continue;let t=u.getAccessorUsage(e),r=t;if(n.has(t)){let t=u.accessorParents.get(e);r+=`:${h.get(t)}`}c[g=r]||(c[g]={usage:t,accessors:[]}),c[r].accessors.push(e)}let T=[],y=a.buffers.length,R=0;for(let{usage:e,accessors:r}of Object.values(c))if(e===ey.ARRAY_BUFFER&&t.vertexLayout===i.INTERLEAVED){let e=x(r,y,R);for(let t of(R+=e.byteLength,e.buffers))T.push(t)}else if(e===ey.ARRAY_BUFFER)for(let e of r){let t=x([e],y,R);for(let e of(R+=t.byteLength,t.buffers))T.push(e)}else if(e===ey.SPARSE){let e=function(e,t,r){let s=[],i=0,n=new Map,o=-1/0,l=!1;for(let t of e){let e=u.createAccessorDef(t);a.accessors.push(e),u.accessorIndexMap.set(t,a.accessors.length-1);let r=[],s=[],i=[],f=Array(t.getElementSize()).fill(0);for(let e=0,n=t.getCount();e<n;e++)if(t.getElement(e,i),!O.eq(i,f,0)){o=Math.max(e,o),r.push(e);for(let e=0;e<i.length;e++)s.push(i[e])}let h=r.length,c={accessorDef:e,count:h};if(n.set(t,c),0===h)continue;h>t.getCount()/2&&(l=!0);let g=d[t.getComponentType()];c.indices=r,c.values=new g(s)}if(!Number.isFinite(o))return{buffers:s,byteLength:i};l&&f.warn("Some sparse accessors have >50% non-zero elements, which may increase file size.");let h=o<255?Uint8Array:o<65535?Uint16Array:Uint32Array,c=o<255?eA:o<65535?eb:eR,g={buffer:t,byteOffset:r+i,byteLength:0};for(let t of e){let e=n.get(t);if(0===e.count)continue;e.indicesByteOffset=g.byteLength;let r=m.pad(m.toView(new h(e.indices)));s.push(r),i+=r.byteLength,g.byteLength+=r.byteLength}a.bufferViews.push(g);let p=a.bufferViews.length-1,T={buffer:t,byteOffset:r+i,byteLength:0};for(let t of e){let e=n.get(t);if(0===e.count)continue;e.valuesByteOffset=T.byteLength;let r=m.pad(m.toView(e.values));s.push(r),i+=r.byteLength,T.byteLength+=r.byteLength}a.bufferViews.push(T);let E=a.bufferViews.length-1;for(let t of e){let e=n.get(t);0!==e.count&&(e.accessorDef.sparse={count:e.count,indices:{bufferView:p,byteOffset:e.indicesByteOffset,componentType:c},values:{bufferView:E,byteOffset:e.valuesByteOffset}})}return{buffers:s,byteLength:i}}(r,y,R);for(let t of(R+=e.byteLength,e.buffers))T.push(t)}else if(e===ey.ELEMENT_ARRAY_BUFFER){let e=E(r,y,R,eE.BufferViewTarget.ELEMENT_ARRAY_BUFFER);for(let t of(R+=e.byteLength,e.buffers))T.push(t)}else{let e=E(r,y,R);for(let t of(R+=e.byteLength,e.buffers))T.push(t)}if(u.imageBufferViews.length&&0===r){for(let e=0;e<u.imageBufferViews.length;e++)if(a.bufferViews[a.images[e].bufferView].byteOffset=R,R+=u.imageBufferViews[e].byteLength,T.push(u.imageBufferViews[e]),R%8){let e=8-R%8;R+=e,T.push(new Uint8Array(e))}}if(u.otherBufferViews.has(e))for(let t of u.otherBufferViews.get(e))a.bufferViews.push({buffer:y,byteOffset:R,byteLength:t.byteLength}),u.otherBufferViewsIndexMap.set(t,a.bufferViews.length-1),R+=t.byteLength,T.push(t);if(R){let r;t.format===o.GLB?r=p:s.uri=r=u.bufferURIGenerator.createURI(e,"bin"),s.byteLength=R,u.assignResourceURI(r,m.concat(T),!0)}a.buffers.push(s),u.bufferIndexMap.set(e,r)}),n.listAccessors().find(e=>!e.getBuffer())&&f.warn("Skipped writing one or more Accessors: no Buffer assigned."),c.filter(e=>e.prewriteTypes.includes(s.MATERIAL)).forEach(e=>e.prewrite(u,s.MATERIAL)),a.materials=n.listMaterials().map((e,t)=>{let r=u.createPropertyDef(e);if(e.getAlphaMode()!==et.AlphaMode.OPAQUE&&(r.alphaMode=e.getAlphaMode()),e.getAlphaMode()===et.AlphaMode.MASK&&(r.alphaCutoff=e.getAlphaCutoff()),e.getDoubleSided()&&(r.doubleSided=!0),r.pbrMetallicRoughness={},O.eq(e.getBaseColorFactor(),[1,1,1,1])||(r.pbrMetallicRoughness.baseColorFactor=e.getBaseColorFactor()),O.eq(e.getEmissiveFactor(),[0,0,0])||(r.emissiveFactor=e.getEmissiveFactor()),1!==e.getRoughnessFactor()&&(r.pbrMetallicRoughness.roughnessFactor=e.getRoughnessFactor()),1!==e.getMetallicFactor()&&(r.pbrMetallicRoughness.metallicFactor=e.getMetallicFactor()),e.getBaseColorTexture()){let t=e.getBaseColorTexture(),s=e.getBaseColorTextureInfo();r.pbrMetallicRoughness.baseColorTexture=u.createTextureInfoDef(t,s)}if(e.getEmissiveTexture()){let t=e.getEmissiveTexture(),s=e.getEmissiveTextureInfo();r.emissiveTexture=u.createTextureInfoDef(t,s)}if(e.getNormalTexture()){let t=e.getNormalTexture(),s=e.getNormalTextureInfo(),i=u.createTextureInfoDef(t,s);1!==e.getNormalScale()&&(i.scale=e.getNormalScale()),r.normalTexture=i}if(e.getOcclusionTexture()){let t=e.getOcclusionTexture(),s=e.getOcclusionTextureInfo(),i=u.createTextureInfoDef(t,s);1!==e.getOcclusionStrength()&&(i.strength=e.getOcclusionStrength()),r.occlusionTexture=i}if(e.getMetallicRoughnessTexture()){let t=e.getMetallicRoughnessTexture(),s=e.getMetallicRoughnessTextureInfo();r.pbrMetallicRoughness.metallicRoughnessTexture=u.createTextureInfoDef(t,s)}return u.materialIndexMap.set(e,t),r}),c.filter(e=>
1e.prewriteTypes.includes(s.MESH)).forEach(e=>e.prewrite(u,s.MESH)),a.meshes=n.listMeshes().map((e,t)=>{let r=u.createPropertyDef(e),s=null;return r.primitives=e.listPrimitives().map(e=>{let t={attributes:{}};t.mode=e.getMode();let r=e.getMaterial();r&&(t.material=u.materialIndexMap.get(r)),Object.keys(e.getExtras()).length&&(t.extras=e.getExtras());let i=e.getIndices();for(let r of(i&&(t.indices=u.accessorIndexMap.get(i)),e.listSemantics()))t.attributes[r]=u.accessorIndexMap.get(e.getAttribute(r));for(let r of e.listTargets()){let e={};for(let t of r.listSemantics())e[t]=u.accessorIndexMap.get(r.getAttribute(t));t.targets=t.targets||[],t.targets.push(e)}return e.listTargets().length&&!s&&(s=e.listTargets().map(e=>e.getName())),t}),e.getWeights().length&&(r.weights=e.getWeights()),s&&(r.extras=r.extras||{},r.extras.targetNames=s),u.meshIndexMap.set(e,t),r}),a.cameras=n.listCameras().map((e,t)=>{let r=u.createPropertyDef(e);if(r.type=e.getType(),r.type===H.Type.PERSPECTIVE){r.perspective={znear:e.getZNear(),zfar:e.getZFar(),yfov:e.getYFov()};let t=e.getAspectRatio();null!==t&&(r.perspective.aspectRatio=t)}else r.orthographic={znear:e.getZNear(),zfar:e.getZFar(),xmag:e.getXMag(),ymag:e.getYMag()};return u.cameraIndexMap.set(e,t),r}),a.nodes=n.listNodes().map((e,t)=>{let r=u.createPropertyDef(e);return O.eq(e.getTranslation(),[0,0,0])||(r.translation=e.getTranslation()),O.eq(e.getRotation(),[0,0,0,1])||(r.rotation=e.getRotation()),O.eq(e.getScale(),[1,1,1])||(r.scale=e.getScale()),e.getWeights().length&&(r.weights=e.getWeights()),u.nodeIndexMap.set(e,t),r}),a.skins=n.listSkins().map((e,t)=>{let r=u.createPropertyDef(e),s=e.getInverseBindMatrices();s&&(r.inverseBindMatrices=u.accessorIndexMap.get(s));let i=e.getSkeleton();return i&&(r.skeleton=u.nodeIndexMap.get(i)),r.joints=e.listJoints().map(e=>u.nodeIndexMap.get(e)),u.skinIndexMap.set(e,t),r}),n.listNodes().forEach((e,t)=>{let r=a.nodes[t],s=e.getMesh();s&&(r.mesh=u.meshIndexMap.get(s));let i=e.getCamera();i&&(r.camera=u.cameraIndexMap.get(i));let n=e.getSkin();n&&(r.skin=u.skinIndexMap.get(n)),e.listChildren().length>0&&(r.children=e.listChildren().map(e=>u.nodeIndexMap.get(e)))}),a.animations=n.listAnimations().map((e,t)=>{let r=u.createPropertyDef(e),s=new Map;return r.samplers=e.listSamplers().map((e,t)=>{let r=u.createPropertyDef(e);return r.input=u.accessorIndexMap.get(e.getInput()),r.output=u.accessorIndexMap.get(e.getOutput()),r.interpolation=e.getInterpolation(),s.set(e,t),r}),r.channels=e.listChannels().map(e=>{let t=u.createPropertyDef(e);return t.sampler=s.get(e.getSampler()),t.target={node:u.nodeIndexMap.get(e.getTargetNode()),path:e.getTargetPath()},t}),u.animationIndexMap.set(e,t),r}),a.scenes=n.listScenes().map((e,t)=>{let r=u.createPropertyDef(e);return r.nodes=e.listChildren().map(e=>u.nodeIndexMap.get(e)),u.sceneIndexMap.set(e,t),r});let y=n.getDefaultScene();return y&&(a.scene=n.listScenes().indexOf(y)),a.extensionsUsed=c.map(e=>e.extensionName),a.extensionsRequired=T.map(e=>e.extensionName),c.forEach(e=>e.write(u)),function(e){let t=[];for(let r in e){let s=e[r];Array.isArray(s)&&0===s.length||null===s||""===s?t.push(r):s&&"object"==typeof s&&0===Object.keys(s).length&&t.push(r)}for(let r of t)delete e[r]}(a),l}}!function(e){e[e.JSON=0x4e4f534a]="JSON",e[e.BIN=5130562]="BIN"}(f||(f={}));class ew{constructor(){this._logger=_.DEFAULT_INSTANCE,this._extensions=new Set,this._dependencies={}
1,this._vertexLayout=i.INTERLEAVED,this._strictResources=!0,this.lastReadBytes=0,this.lastWriteBytes=0}setLogger(e){return this._logger=e,this}registerExtensions(e){for(let t of e)this._extensions.add(t),t.register();return this}registerDependencies(e){return Object.assign(this._dependencies,e),this}setVertexLayout(e){return this._vertexLayout=e,this}setStrictResources(e){return this._strictResources=e,this}async read(e){return await this.readJSON(await this.readAsJSON(e))}async readAsJSON(e){let t=await this.readURI(e,"view");this.lastReadBytes=t.byteLength;let r=eN(t)?this._binaryToJSON(t):{json:JSON.parse(m.decodeText(t)),resources:{}};return await this._readResourcesExternal(r,this.dirname(e)),this._readResourcesInternal(r),r}async readJSON(e){return e=this._copyJSON(e),this._readResourcesInternal(e),em.read(e,{extensions:Array.from(this._extensions),dependencies:this._dependencies,logger:this._logger})}async binaryToJSON(e){let t=this._binaryToJSON(m.assertView(e));this._readResourcesInternal(t);let r=t.json;if(r.buffers&&r.buffers.some(e=>{var r,s;return r=t,void 0!==(s=e).uri&&!(s.uri in r.resources)}))throw Error("Cannot resolve external buffers with binaryToJSON().");if(r.images&&r.images.some(e=>{var r,s;return r=t,void 0!==(s=e).uri&&!(s.uri in r.resources)&&void 0===s.bufferView}))throw Error("Cannot resolve external images with binaryToJSON().");return t}async readBinary(e){return this.readJSON(await this.binaryToJSON(m.assertView(e)))}async writeJSON(e,t={}){if(t.format===o.GLB&&e.getRoot().listBuffers().length>1)throw Error("GLB must have 0â1 buffers.");return eI.write(e,{format:t.format||o.GLTF,basename:t.basename||"",logger:this._logger,vertexLayout:this._vertexLayout,depen
1dencies:ea({},this._dependencies),extensions:Array.from(this._extensions)})}async writeBinary(e){let{json:t,resources:r}=await this.writeJSON(e,{format:o.GLB}),s=new Uint32Array([0x46546c67,2,12]),i=JSON.stringify(t),n=m.pad(m.encodeText(i),32),a=m.toView(new Uint32Array([n.byteLength,0x4e4f534a])),l=m.concat([a,n]);s[s.length-1]+=l.byteLength;let u=Object.values(r)[0];if(!u||!u.byteLength)return m.concat([m.toView(s),l]);let f=m.pad(u,0),h=m.toView(new Uint32Array([f.byteLength,5130562])),c=m.concat([h,f]);return s[s.length-1]+=c.byteLength,m.concat([m.toView(s),l,c])}async _readResourcesExternal(e,t){var r=this;let s=e.json.images||[],i=[...s,...e.json.buffers||[]].map(async function(i){let n=i.uri;if(!n||n.match(/data:/))return Promise.resolve();try{e.resources[n]=await r.readURI(r.resolve(t,n),"view"),r.lastReadBytes+=e.resources[n].byteLength}catch(t){if(!r._strictResources&&s.includes(i))r._logger.warn(`Failed to load image URI, "${n}". ${t}`),e.resources[n]=null;else throw t}});await Promise.all(i)}_readResourcesInternal(e){function t(t){if(t.uri){if(t.uri in e.resources)return void m.assertView(e.resources[t.uri]);if(t.uri.match(/data:/)){let r=`__${P()}.${R.extension(t.uri)}`;e.resources[r]=m.createBufferFromDataURI(t.uri),t.uri=r}}}(e.json.images||[]).forEach(e=>{if(void 0===e.bufferView&&void 0===e.uri)throw Error("Missing resource URI or buffer view.");t(e)}),(e.json.buffers||[]).forEach(t)}_copyJSON(e){let{images:t,buffers:r}=e.json;return e={json:ea({},e.json),resources:ea({},e.resources)},t&&(e.json.images=t.map(e=>ea({},e))),r&&(e.json.buffers=r.map(e=>ea({},e))),e}_binaryToJSON(e){if(!eN(e))throw Error("Invalid glTF 2.0 binary.");let t=new Uint32Array(e.buffer,e.byteOffset+12,2);if(t[1]!==f.JSON)throw Error("Missing required GLB JSON chunk.");let r=t[0],s=JSON.parse(m.decodeText(m.toView(e,20,r))),i=20+r;if(e.byteLength<=i)return{json:s,resources:{}};let n=new Uint32Array(e.buffer,e.byteOffset+i,2);if(n[1]!==f.BIN)return{json:s,resources:{}};let a=n[0];return{json:s,resources:{[p]:m.toView(e,i+8,a)}}}}function eN(e){if(e.byteLength<3*Uint32Array.BYTES_PER_ELEMENT)return!1;let t=new Uint32Array(e.buffer,e.byteOffset,3);return 0x46546c67===t[0]&&2===t[1]}class eS extends ew{constructor(e=S.DEFAULT_INIT){super(),this._fetchConfig=void 0,this._fetchConfig=e}async readURI(e,t){let r=await fetch(e,this._fetchConfig);switch(t){case"view":return new Uint8Array(await r.arrayBuffer());case"text":return r.text()}}resolve(e,t){return S.resolve(e,t)}dirname(e){return S.dirname(e)}}}}]);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.