Socket
Socket
Sign inDemoInstall

@gltf-transform/core

Package Overview
Dependencies
Maintainers
1
Versions
205
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@gltf-transform/core - npm Package Compare versions

Comparing version 0.8.0 to 0.8.1

2

dist/core.modern.js

@@ -1,2 +0,2 @@

import{fromRotationTranslationScale as t,getTranslation as s,getRotation as e,getScaling as i,multiply as r,determinant as n}from"gl-matrix/mat4";import{length as h}from"gl-matrix/vec3";const o="@glb.bin";var u;function c(t,s,e,i){var r,n=arguments.length,h=n<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,s,e,i);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(h=(n<3?r(h):n>3?r(s,e,h):r(s,e))||h);return n>3&&h&&Object.defineProperty(s,e,h),h}!function(t){t.ACCESSOR="Accessor",t.ANIMATION="Animation",t.ANIMATION_CHANNEL="AnimationChannel",t.ANIMATION_SAMPLER="AnimationSampler",t.BUFFER="Buffer",t.CAMERA="Camera",t.MATERIAL="Material",t.MESH="Mesh",t.PRIMITIVE="Primitive",t.PRIMITIVE_TARGET="PrimitiveTarget",t.NODE="Node",t.ROOT="Root",t.SCENE="Scene",t.SKIN="Skin",t.TEXTURE="Texture",t.TEXTURE_INFO="TextureInfo"}(u||(u={}));class a{constructor(t,s,e){if(this.t=t,this.s=s,this.i=e,this.h=!1,this.o=[],!s.canLink(e))throw new Error("Cannot link disconnected graphs/documents.")}getName(){return this.t}getParent(){return this.s}getChild(){return this.i}setChild(t){return this.i=t,this}dispose(){this.h||(this.h=!0,this.o.forEach(t=>t()),this.o.length=0)}onDispose(t){return this.o.push(t),this}isDisposed(){return this.h}}class l{constructor(){this.u=new Set,this.l=new Set,this.p=new Map,this.g=new Map,this.o={}}on(t,s){return this.o[t]=this.o[t]||[],this.o[t].push(s),this}emit(t,s){for(const e of this.o[t]||[])e(s);return this}getLinks(){return Array.from(this.l)}listParents(t){const s=this.g.get(t)||this.u;return Array.from(s).map(t=>t.getParent())}listChildren(t){const s=this.p.get(t)||this.u;return Array.from(s).map(t=>t.getChild())}disconnectChildren(t){return(this.p.get(t)||this.u).forEach(t=>t.dispose()),this}disconnectParents(t,s){let e=Array.from(this.g.get(t)||this.u);return s&&(e=e.filter(t=>s(t.getParent()))),e.forEach(t=>t.dispose()),this}swapChild(t,s,e){const i=this.p.get(t)||this.u;return Array.from(i).filter(t=>t.getChild()===s).forEach(t=>{this.g.get(s).delete(t),t.setChild(e),this.g.has(e)||this.g.set(e,new Set),this.g.get(e).add(t)}),this}link(t,s,e){if(!e)return null;const i=new a(t,s,e);return this.registerLink(i),i}registerLink(t){this.l.add(t);const s=t.getParent();this.p.has(s)||this.p.set(s,new Set),this.p.get(s).add(t);const e=t.getChild();return this.g.has(e)||this.g.set(e,new Set),this.g.get(e).add(t),t.onDispose(()=>this.unlink(t)),t}unlink(t){return this.l.delete(t),this.p.get(t.getParent()).delete(t),this.g.get(t.getChild()).delete(t),this}}function f(t,s){Object.defineProperty(t,s,{get:function(){return this["__"+s]},set:function(t){const e=this["__"+s];e&&!Array.isArray(e)&&e.dispose(),t&&!Array.isArray(t)&&t.onDispose(()=>{this["__"+s]=null}),this["__"+s]=t},enumerable:!0})}function d(t,s){}class p{static createBufferFromDataURI(t){if("undefined"==typeof Buffer){const s=atob(t.split(",")[1]),e=new Uint8Array(s.length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e.buffer}{const s=t.split(",")[1],e=t.indexOf("base64")>=0;return this.trim(Buffer.from(s,e?"base64":"utf8"))}}static encodeText(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t).buffer:this.trim(Buffer.from(t))}static decodeText(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")}static trim(t){const{byteOffset:s,byteLength:e}=t;return t.buffer.slice(s,s+e)}static concat(t){let s=0;for(const e of t)s+=e.byteLength;const e=new Uint8Array(s);let i=0;for(const s of t)e.set(new Uint8Array(s),i),i+=s.byteLength;return e.buffer}static pad(t,s=0){const e=this.padNumber(t.byteLength);if(e!==t.byteLength){const i=new Uint8Array(e);if(i.set(new Uint8Array(t)),0!==s)for(let r=t.byteLength;r<e;r++)i[r]=s;return i.buffer}return t}static padNumber(t){return 4*Math.ceil(t/4)}static equals(t,s){if(t===s)return!0;if(t.byteLength!==s.byteLength)return!1;const e=new DataView(t),i=new DataView(s);let r=t.byteLength;for(;r--;)if(e.getUint8(r)!==i.getUint8(r))return!1;return!0}}class g{static hexToFactor(t,s){return t=Math.floor(t),s[0]=(t>>16&255)/255,s[1]=(t>>8&255)/255,s[2]=(255&t)/255,this.convertSRGBToLinear(s,s)}static factorToHex(t){const s=[...t],[e,i,r]=this.convertLinearToSRGB(t,s);return 255*e<<16^255*i<<8^255*r<<0}static convertSRGBToLinear(t,s){for(let e=0;e<3;e++)s[e]=t[e]<.04045?.0773993808*t[e]:Math.pow(.9478672986*t[e]+.0521327014,2.4);return s}static convertLinearToSRGB(t,s){for(let e=0;e<3;e++)s[e]=t[e]<.0031308?12.92*t[e]:1.055*Math.pow(t[e],.41666)-.055;return s}}class w{static basename(t){const s=t.split(/[\\/]/).pop();return s.substr(0,s.lastIndexOf("."))}static extension(t){return 0!==t.indexOf("data:")?t.split(/[\\/]/).pop().split(/[.]/).pop():0===t.indexOf("data:image/png")?"png":0===t.indexOf("data:image/jpeg")?"jpeg":"bin"}}class m{static getSize(t,s){switch(s){case"image/png":return this.m(t);case"image/jpeg":return this.v(t);case"image/webp":return this.T(t);case"image/ktx2":return this.A(t);default:return null}}static getChannels(t,s){switch(s){case"image/png":return 4;case"image/jpeg":return 3;case"image/webp":case"image/ktx2":default:return 4}}static getMemSize(t,s){if("image/ktx2"===s){const s=new DataView(t);v(s);const e=s.getUint32(40,!0),i=80;let r=0;for(let t=0;t<e;t++)r+=y(s,i+3*t*8+16,!0)||y(s,i+3*t*8+8,!0);return r}const e=this.getSize(t,s),i=this.getChannels(t,s);return e?e[0]*e[1]*i:null}static v(t){let s,e,i=new DataView(t,4);for(;i.byteLength;){if(s=i.getUint16(0,!1),x(i,s),e=i.getUint8(s+1),192===e||193===e||194===e)return[i.getUint16(s+7,!1),i.getUint16(s+5,!1)];i=new DataView(t,i.byteOffset+s+2)}throw new TypeError("Invalid JPG, no size found")}static m(t){const s=new DataView(t);return"CgBI"===p.decodeText(t.slice(12,16))?[s.getUint32(32,!1),s.getUint32(36,!1)]:[s.getUint32(16,!1),s.getUint32(20,!1)]}static T(t){const s=p.decodeText(t.slice(0,4)),e=p.decodeText(t.slice(8,12));if("RIFF"!==s||"WEBP"!==e)return null;const i=new DataView(t);let r=12;for(;r<t.byteLength;){const s=p.decodeText(t.slice(r,r+4)),e=i.getUint32(r+4,!0);if("VP8 "===s)return[16383&i.getInt16(r+14,!0),16383&i.getInt16(r+16,!0)];if("VP8L"===s){const t=i.getUint8(r+9),s=i.getUint8(r+10),e=i.getUint8(r+11);return[1+((63&s)<<8|t),1+((15&i.getUint8(r+12))<<10|e<<2|(192&s)>>6)]}r+=8+e+e%2}return null}static A(t){v(new DataView(t));const s=new DataView(t);return[s.getUint32(20,!0),s.getUint32(24,!0)]}static mimeTypeToExtension(t){return"image/jpeg"===t?"jpg":t.split("/").pop()}static extensionToMimeType(t){return"jpg"===t?"image/jpeg":"image/"+t}}function v(t){const s=t.buffer.slice(t.byteOffset+1,t.byteOffset+7);if("KTX 20"!==p.decodeText(s))throw new TypeError("Corrupt KTX2.")}function x(t,s){if(s>t.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(255!==t.getUint8(s))throw new TypeError("Invalid JPG, marker table corrupted")}function y(t,s,e){const i=t.getUint32(s,e),r=t.getUint32(s+4,e);return e?i+2**32*r:2**32*i+r}class T{static identity(t){return t}static denormalize(t,s){switch(s){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1)}}static normalize(t,s){switch(s){case 5126:return t;case 5123:return Math.round(65535*t);case 5121:return Math.round(255*t);case 5122:return Math.round(32767*t);case 5120:return Math.round(127*t)}}}class A{constructor(t){this.verbosity=t}debug(t){this.verbosity<=A.Verbosity.DEBUG&&console.debug(t)}info(t){this.verbosity<=A.Verbosity.INFO&&console.info(t)}warn(t){this.verbosity<=A.Verbosity.WARN&&console.warn(t)}error(t){this.verbosity<=A.Verbosity.ERROR&&console.error(t)}}A.Verbosity={SILENT:4,ERROR:3,WARN:2,INFO:1,DEBUG:0},A.DEFAULT_INSTANCE=new A(A.Verbosity.INFO);const b="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",E=new Set,M=function(){let t="";for(let s=0;s<6;s++)t+=b.charAt(Math.floor(Math.random()*b.length));return t},S=function(){for(let t=0;t<999;t++){const t=M();if(!E.has(t))return E.add(t),t}},I=t=>t;class R extends class{constructor(t){this.h=!1,this.graph=t}canLink(t){return this.graph===t.graph}isDisposed(){return this.h}dispose(){this.graph.disconnectChildren(this),this.graph.disconnectParents(this),this.h=!0}detach(){return this.graph.disconnectParents(this),this}swap(t,s){return this.graph.swapChild(this,t,s),this}addGraphChild(t,s){return t.push(s),s.onDispose(()=>{const e=t.filter(t=>t!==s);t.length=0;for(const s of e)t.push(s)}),this}removeGraphChild(t,s){return t.filter(t=>t.getChild()===s).forEach(t=>t.dispose()),this}clearGraphChildList(t){for(;t.length>0;)t[0].dispose();return this}listGraphParents(){return this.graph.listParents(this)}}{constructor(t,s=""){super(t),this.M={},this.t="",this.t=s}getName(){return this.t}setName(t){return this.t=t,this}getExtras(){return this.M}setExtras(t){return this.M=t,this}clone(){const t=new(0,this.constructor)(this.graph).copy(this,I);return this.graph.emit("clone",t),t}copy(t,s=I){return this.t=t.t,this.M=JSON.parse(JSON.stringify(t.M)),this}detach(){return this.graph.disconnectParents(this,t=>"Root"!==t.propertyType),this}listParents(){return this.listGraphParents()}}const C="Pass extension name (string) as lookup token, not a constructor.";class N extends R{constructor(){super(...arguments),this.extensions=[]}copy(t,s=I){return super.copy(t,s),this.clearGraphChildList(this.extensions),t.extensions.forEach(t=>{const e=t.getChild();this.setExtension(e.extensionName,s(e))}),this}getExtension(t){if("string"!=typeof t)throw new Error(C);const s=this.extensions.find(s=>s.getChild().extensionName===t);return s?s.getChild():null}setExtension(t,s){if("string"!=typeof t)throw new Error(C);const e=this.getExtension(t);return e&&this.removeGraphChild(this.extensions,e),s?(s.S(this),this.addGraphChild(this.extensions,this.graph.link(t,this,s))):this}listExtensions(){return this.extensions.map(t=>t.getChild())}}c([d],N.prototype,"extensions",void 0);class _ extends N{constructor(){super(...arguments),this.propertyType=u.ACCESSOR,this.I=null,this.R="SCALAR",this.C=null,this.N=!1,this._=T.identity,this.B=T.identity,this.buffer=null}copy(t,s=I){return super.copy(t,s),this.R=t.R,this.C=t.C,this.N=t.N,this._=t._,this.B=t.B,t.I&&(this.I=t.I.slice()),t.buffer&&this.setBuffer(s(t.buffer.getChild())),this}static getElementSize(t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:throw new Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5125:case 5126:return 4;default:throw new Error("Unexpected component type: "+t)}}getMinNormalized(t){const s=this.getElementSize();this.getMin(t);for(let e=0;e<s;e++)t[e]=this.B(t[e]);return t}getMin(t){const s=this.getCount(),e=this.getElementSize();for(let s=0;s<e;s++)t[s]=Infinity;for(let i=0;i<s*e;i+=e)for(let s=0;s<e;s++){const e=this.I[i+s];Number.isFinite(e)&&(t[s]=Math.min(t[s],e))}return t}getMaxNormalized(t){const s=this.getElementSize();this.getMax(t);for(let e=0;e<s;e++)t[e]=this.B(t[e]);return t}getMax(t){const s=this.getCount(),e=this.getElementSize();for(let s=0;s<e;s++)t[s]=-Infinity;for(let i=0;i<s*e;i+=e)for(let s=0;s<e;s++){const e=this.I[i+s];Number.isFinite(e)&&(t[s]=Math.max(t[s],e))}return t}getCount(){return this.I.length/this.getElementSize()}getType(){return this.R}setType(t){return this.R=t,this}getElementSize(){return _.getElementSize(this.R)}getComponentSize(){return this.I.BYTES_PER_ELEMENT}getComponentType(){return this.C}getNormalized(){return this.N}setNormalized(t){return this.N=t,t?(this.B=t=>T.denormalize(t,this.C),this._=t=>T.normalize(t,this.C)):(this.B=T.identity,this._=T.identity),this}getScalar(t){const s=this.getElementSize();return this.B(this.I[t*s])}setScalar(t,s){return this.I[t*this.getElementSize()]=this._(s),this}getElement(t,s){const e=this.getElementSize();for(let i=0;i<e;i++)s[i]=this.B(this.I[t*e+i]);return s}setElement(t,s){const e=this.getElementSize();for(let i=0;i<e;i++)this.I[t*e+i]=this._(s[i]);return this}getBuffer(){return this.buffer?this.buffer.getChild():null}setBuffer(t){return this.buffer=this.graph.link("buffer",this,t),this}getArray(){return this.I}setArray(t){return this.C=function(t){switch(t.constructor){case Float32Array:return 5126;case Uint32Array:return 5125;case Uint16Array:return 5123;case Uint8Array:return 5121;case Int16Array:return 5122;case Int8Array:return 5120;default:throw new Error("Unknown accessor componentType.")}}(t),this.I=t,this}getByteLength(){return this.I.byteLength}}_.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT3:"MAT3",MAT4:"MAT4"},_.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},c([f],_.prototype,"buffer",void 0);class B extends N{constructor(){super(...arguments),this.propertyType=u.ANIMATION,this.channels=[],this.samplers=[]}copy(t,s=I){return super.copy(t,s),this.clearGraphChildList(this.channels),this.clearGraphChildList(this.samplers),t.channels.forEach(t=>this.addChannel(s(t.getChild()))),t.samplers.forEach(t=>this.addSampler(s(t.getChild()))),this}addChannel(t){const s=this.graph.link("channel",this,t);return this.addGraphChild(this.channels,s)}removeChannel(t){return this.removeGraphChild(this.channels,t)}listChannels(){return this.channels.map(t=>t.getChild())}addSampler(t){const s=this.graph.link("sampler",this,t);return this.addGraphChild(this.samplers,s)}removeSampler(t){return this.removeGraphChild(this.samplers,t)}listSamplers(){return this.samplers.map(t=>t.getChild())}}c([d],B.prototype,"channels",void 0),c([d],B.prototype,"samplers",void 0);class L extends R{constructor(){super(...arguments),this.propertyType=u.ANIMATION_CHANNEL,this.L=null,this.targetNode=null,this.sampler=null}copy(t,s=I){return super.copy(t,s),this.L=t.L,t.targetNode&&this.setTargetNode(s(t.targetNode.getChild())),t.sampler&&this.setSampler(s(t.sampler.getChild())),this}getTargetPath(){return this.L}setTargetPath(t){return this.L=t,this}getTargetNode(){return this.targetNode?this.targetNode.getChild():null}setTargetNode(t){return this.targetNode=this.graph.link("target.node",this,t),this}getSampler(){return this.sampler?this.sampler.getChild():null}setSampler(t){return this.sampler=this.graph.link("sampler",this,t),this}}c([f],L.prototype,"targetNode",void 0),c([f],L.prototype,"sampler",void 0);class O extends R{constructor(){super(...arguments),this.propertyType=u.ANIMATION_SAMPLER,this.O="LINEAR",this.input=null,this.output=null}copy(t,s=I){return super.copy(t,s),this.O=t.O,t.input&&this.setInput(s(t.input.getChild())),t.output&&this.setOutput(s(t.output.getChild())),this}getInterpolation(){return this.O}setInterpolation(t){return this.O=t,this}getInput(){return this.input?this.input.getChild():null}setInput(t){return this.input=this.graph.link("input",this,t),this}getOutput(){return this.output?this.output.getChild():null}setOutput(t){return this.output=this.graph.link("output",this,t),this}}c([f],O.prototype,"input",void 0),c([f],O.prototype,"output",void 0);class k extends N{constructor(){super(...arguments),this.propertyType=u.BUFFER}copy(t,s=I){return super.copy(t,s),this.k=t.k,this}getURI(){return this.k}setURI(t){return this.k=t,this}}class P extends N{constructor(){super(...arguments),this.propertyType=u.CAMERA,this.R="perspective"}copy(t,s=I){return super.copy(t,s),this.R=t.R,this.P=t.P,this.U=t.U,this.F=t.F,this.D=t.D,this.j=t.j,this.G=t.G,this}getType(){return this.R}setType(t){return this.R=t,this}getZNear(){return this.P}setZNear(t){return this.P=t,this}getZFar(){return this.U}setZFar(t){return this.U=t,this}getAspectRatio(){return this.F}setAspectRatio(t){return this.F=t,this}getYFov(){return this.D}setYFov(t){return this.D=t,this}getXMag(){return this.j}setXMag(t){return this.j=t,this}getYMag(){return this.G}setYMag(t){return this.G=t,this}}class U extends R{constructor(t,s){super(t),this.V=s,this.V.addExtensionProperty(this)}dispose(){this.V.removeExtensionProperty(this),super.dispose()}S(t){if(!this.parentTypes.includes(t.propertyType))throw new Error(`Parent "${t.propertyType}" invalid for child "${this.propertyType}".`)}}class F extends a{constructor(){super(...arguments),this.semantic=""}copy(t){return this.semantic=t.semantic,this}}class D extends a{copy(t){return this}}class j extends l{linkAttribute(t,s,e){if(!e)return null;const i=new F(t,s,e);return this.registerLink(i),i}linkIndex(t,s,e){if(!e)return null;const i=new D(t,s,e);return this.registerLink(i),i}}class G extends N{constructor(){super(...arguments),this.propertyType=u.TEXTURE_INFO,this.J=0,this.$=null,this.W=null,this.q=10497,this.H=10497}copy(t,s=I){return super.copy(t,s),this.J=t.J,this.$=t.$,this.W=t.W,this.q=t.q,this.H=t.H,this}getTexCoord(){return this.J}setTexCoord(t){return this.J=t,this}getMagFilter(){return this.$}setMagFilter(t){return this.$=t,this}getMinFilter(){return this.W}setMinFilter(t){return this.W=t,this}getWrapS(){return this.q}setWrapS(t){return this.q=t,this}getWrapT(){return this.H}setWrapT(t){return this.H=t,this}}G.TextureWrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},G.TextureMagFilter={NEAREST:9728,LINEAR:9729},G.TextureMinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};class z extends N{constructor(){super(...arguments),this.propertyType=u.MATERIAL,this.Y="OPAQUE",this.X=.5,this.K=!1,this.Z=[1,1,1,1],this.tt=[0,0,0],this.st=1,this.et=1,this.it=1,this.rt=1,this.baseColorTexture=null,this.baseColorTextureInfo=this.graph.link("baseColorTextureInfo",this,new G(this.graph)),this.emissiveTexture=null,this.emissiveTextureInfo=this.graph.link("emissiveTextureInfo",this,new G(this.graph)),this.normalTexture=null,this.normalTextureInfo=this.graph.link("normalTextureInfo",this,new G(this.graph)),this.occlusionTexture=null,this.occlusionTextureInfo=this.graph.link("occlusionTextureInfo",this,new G(this.graph)),this.metallicRoughnessTexture=null,this.metallicRoughnessTextureInfo=this.graph.link("metallicRoughnessTextureInfo",this,new G(this.graph))}copy(t,s=I){return super.copy(t,s),this.Y=t.Y,this.X=t.X,this.K=t.K,this.Z=[...t.Z],this.tt=[...t.tt],this.st=t.st,this.et=t.et,this.it=t.it,this.rt=t.rt,t.baseColorTexture&&(this.setBaseColorTexture(s(t.baseColorTexture.getChild())),this.getBaseColorTextureInfo().copy(s(t.baseColorTextureInfo.getChild()),s)),t.emissiveTexture&&(this.setEmissiveTexture(s(t.emissiveTexture.getChild())),this.getEmissiveTextureInfo().copy(s(t.emissiveTextureInfo.getChild()),s)),t.normalTexture&&(this.setNormalTexture(s(t.normalTexture.getChild())),this.getNormalTextureInfo().copy(s(t.normalTextureInfo.getChild()),s)),t.occlusionTexture&&(this.setOcclusionTexture(s(t.occlusionTexture.getChild())),this.getOcclusionTextureInfo().copy(s(t.occlusionTextureInfo.getChild()),s)),t.metallicRoughnessTexture&&(this.setMetallicRoughnessTexture(s(t.metallicRoughnessTexture.getChild())),this.getMetallicRoughnessTextureInfo().copy(s(t.metallicRoughnessTextureInfo.getChild()),s)),this}dispose(){this.baseColorTextureInfo.getChild().dispose(),this.emissiveTextureInfo.getChild().dispose(),this.normalTextureInfo.getChild().dispose(),this.occlusionTextureInfo.getChild().dispose(),this.metallicRoughnessTextureInfo.getChild().dispose(),super.dispose()}getDoubleSided(){return this.K}setDoubleSided(t){return this.K=t,this}getAlpha(){return this.Z[3]}setAlpha(t){return this.Z[3]=t,this}getAlphaMode(){return this.Y}setAlphaMode(t){return this.Y=t,this}getAlphaCutoff(){return this.X}setAlphaCutoff(t){return this.X=t,this}getBaseColorFactor(){return this.Z}setBaseColorFactor(t){return this.Z=t,this}getBaseColorHex(){return g.factorToHex(this.Z)}setBaseColorHex(t){return g.hexToFactor(t,this.Z),this}getBaseColorTexture(){return this.baseColorTexture?this.baseColorTexture.getChild():null}getBaseColorTextureInfo(){return this.baseColorTexture?this.baseColorTextureInfo.getChild():null}setBaseColorTexture(t){return this.baseColorTexture=this.graph.link("baseColorTexture",this,t),this}getEmissiveFactor(){return this.tt}setEmissiveFactor(t){return this.tt=t,this}getEmissiveHex(){return g.factorToHex(this.tt)}setEmissiveHex(t){return g.hexToFactor(t,this.tt),this}getEmissiveTexture(){return this.emissiveTexture?this.emissiveTexture.getChild():null}getEmissiveTextureInfo(){return this.emissiveTexture?this.emissiveTextureInfo.getChild():null}setEmissiveTexture(t){return this.emissiveTexture=this.graph.link("emissiveTexture",this,t),this}getNormalScale(){return this.st}setNormalScale(t){return this.st=t,this}getNormalTexture(){return this.normalTexture?this.normalTexture.getChild():null}getNormalTextureInfo(){return this.normalTexture?this.normalTextureInfo.getChild():null}setNormalTexture(t){return this.normalTexture=this.graph.link("normalTexture",this,t),this}getOcclusionStrength(){return this.et}setOcclusionStrength(t){return this.et=t,this}getOcclusionTexture(){return this.occlusionTexture?this.occlusionTexture.getChild():null}getOcclusionTextureInfo(){return this.occlusionTexture?this.occlusionTextureInfo.getChild():null}setOcclusionTexture(t){return this.occlusionTexture=this.graph.link("occlusionTexture",this,t),this}getRoughnessFactor(){return this.it}setRoughnessFactor(t){return this.it=t,this}getMetallicFactor(){return this.rt}setMetallicFactor(t){return this.rt=t,this}getMetallicRoughnessTexture(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.getChild():null}getMetallicRoughnessTextureInfo(){return this.metallicRoughnessTexture?this.metallicRoughnessTextureInfo.getChild():null}setMetallicRoughnessTexture(t){return this.metallicRoughnessTexture=this.graph.link("metallicRoughnessTexture",this,t),this}}c([f],z.prototype,"baseColorTexture",void 0),c([f],z.prototype,"baseColorTextureInfo",void 0),c([f],z.prototype,"emissiveTexture",void 0),c([f],z.prototype,"emissiveTextureInfo",void 0),c([f],z.prototype,"normalTexture",void 0),c([f],z.prototype,"normalTextureInfo",void 0),c([f],z.prototype,"occlusionTexture",void 0),c([f],z.prototype,"occlusionTextureInfo",void 0),c([f],z.prototype,"metallicRoughnessTexture",void 0),c([f],z.prototype,"metallicRoughnessTextureInfo",void 0);class V extends N{constructor(){super(...arguments),this.propertyType=u.MESH,this.nt=[],this.primitives=[]}copy(t,s=I){return super.copy(t,s),this.nt=[...t.nt],this.clearGraphChildList(this.primitives),t.primitives.forEach(t=>this.addPrimitive(s(t.getChild()))),this}addPrimitive(t){return this.addGraphChild(this.primitives,this.graph.link("primitive",this,t))}removePrimitive(t){return this.removeGraphChild(this.primitives,t)}listPrimitives(){return this.primitives.map(t=>t.getChild())}getWeights(){return this.nt}setWeights(t){return this.nt=t,this}}c([d],V.prototype,"primitives",void 0);class J extends N{constructor(){super(...arguments),this.propertyType=u.NODE,this.ht=[0,0,0],this.ot=[0,0,0,1],this.ut=[1,1,1],this.nt=[],this.s=null,this.camera=null,this.mesh=null,this.skin=null,this.children=[]}copy(t,s=I){return super.copy(t,s),this.ht=[...t.ht],this.ot=[...t.ot],this.ut=[...t.ut],this.nt=[...t.nt],t.camera&&this.setCamera(s(t.camera.getChild())),t.mesh&&this.setMesh(s(t.mesh.getChild())),t.skin&&this.setSkin(s(t.skin.getChild())),s!==I&&(this.clearGraphChildList(this.children),t.children.forEach(t=>this.addChild(s(t.getChild())))),this}getTranslation(){return this.ht}getRotation(){return this.ot}getScale(){return this.ut}setTranslation(t){return this.ht=t,this}setRotation(t){return this.ot=t,this}setScale(t){return this.ut=t,this}getMatrix(){return t([],this.ot,this.ht,this.ut)}getWorldTranslation(){return s([],this.getWorldMatrix())}getWorldRotation(){return e([],this.getWorldMatrix())}getWorldScale(){return i([],this.getWorldMatrix())}getWorldMatrix(){const t=[];for(let s=this;s instanceof J;s=s.s)t.push(s);let s;const e=t.pop().getMatrix();for(;s=t.pop();)r(e,e,s.getMatrix());return e}addChild(t){t.s&&t.s.removeChild(t);const s=this.graph.link("child",this,t);return this.addGraphChild(this.children,s),t.s=this,s.onDispose(()=>t.s=null),this}removeChild(t){return this.removeGraphChild(this.children,t)}listChildren(){return this.children.map(t=>t.getChild())}getParent(){return this.s}getMesh(){return this.mesh?this.mesh.getChild():null}setMesh(t){return this.mesh=this.graph.link("mesh",this,t),this}getCamera(){return this.camera?this.camera.getChild():null}setCamera(t){return this.camera=this.graph.link("camera",this,t),this}getSkin(){return this.skin?this.skin.getChild():null}setSkin(t){return this.skin=this.graph.link("skin",this,t),this}getWeights(){return this.nt}setWeights(t){return this.nt=t,this}traverse(t){t(this);for(const s of this.listChildren())s.traverse(t);return this}}c([f],J.prototype,"camera",void 0),c([f],J.prototype,"mesh",void 0),c([f],J.prototype,"skin",void 0),c([d],J.prototype,"children",void 0);class $ extends N{constructor(){super(...arguments),this.propertyType=u.PRIMITIVE,this.ct=4,this.material=null,this.indices=null,this.attributes=[],this.targets=[]}copy(t,s=I){return super.copy(t,s),this.ct=t.ct,t.indices&&this.setIndices(s(t.indices.getChild())),t.material&&this.setMaterial(s(t.material.getChild())),this.clearGraphChildList(this.attributes),t.listSemantics().forEach(e=>{this.setAttribute(e,s(t.getAttribute(e)))}),this.clearGraphChildList(this.targets),t.targets.forEach(t=>this.addTarget(s(t.getChild()))),this}getIndices(){return this.indices?this.indices.getChild():null}setIndices(t){return this.indices=this.graph.linkIndex("index",this,t),this}getAttribute(t){const s=this.attributes.find(s=>s.semantic===t);return s?s.getChild():null}setAttribute(t,s){const e=this.getAttribute(t);if(e&&this.removeGraphChild(this.attributes,e),!s)return this;const i=this.graph.linkAttribute(t.toLowerCase(),this,s);return i.semantic=t,this.addGraphChild(this.attributes,i)}listAttributes(){return this.attributes.map(t=>t.getChild())}listSemantics(){return this.attributes.map(t=>t.semantic)}getMaterial(){return this.material?this.material.getChild():null}setMaterial(t){return this.material=this.graph.link("material",this,t),this}getMode(){return this.ct}setMode(t){return this.ct=t,this}listTargets(){return this.targets.map(t=>t.getChild())}addTarget(t){return this.addGraphChild(this.targets,this.graph.link("target",this,t)),this}removeTarget(t){return this.removeGraphChild(this.targets,t)}}c([f],$.prototype,"material",void 0),c([f],$.prototype,"indices",void 0),c([d],$.prototype,"attributes",void 0),c([d],$.prototype,"targets",void 0);class W extends R{constructor(){super(...arguments),this.propertyType=u.PRIMITIVE_TARGET,this.attributes=[]}copy(t,s=I){return super.copy(t,s),this.clearGraphChildList(this.attributes),t.listSemantics().forEach(e=>{this.setAttribute(e,s(t.getAttribute(e)))}),this}getAttribute(t){const s=this.attributes.find(s=>s.semantic===t);return s?s.getChild():null}setAttribute(t,s){const e=this.getAttribute(t);if(e&&this.removeGraphChild(this.attributes,e),!s)return this;const i=this.graph.linkAttribute(t.toLowerCase(),this,s);return i.semantic=t,this.addGraphChild(this.attributes,i)}listAttributes(){return this.attributes.map(t=>t.getChild())}listSemantics(){return this.attributes.map(t=>t.semantic)}}c([d],W.prototype,"attributes",void 0);class q extends N{constructor(){super(...arguments),this.propertyType=u.SCENE,this.children=[]}copy(t,s=I){return super.copy(t,s),s!==I&&(this.clearGraphChildList(this.children),t.children.forEach(t=>this.addChild(s(t.getChild())))),this}addChild(t){t.s&&t.s.removeChild(t);const s=this.graph.link("child",this,t);return this.addGraphChild(this.children,s),t.s=this,s.onDispose(()=>t.s=null),this}removeChild(t){return this.removeGraphChild(this.children,t)}listChildren(){return this.children.map(t=>t.getChild())}traverse(t){for(const s of this.listChildren())s.traverse(t);return this}}c([d],q.prototype,"children",void 0);class H extends N{constructor(){super(...arguments),this.propertyType=u.SKIN,this.skeleton=null,this.inverseBindMatrices=null,this.joints=[]}copy(t,s=I){return super.copy(t,s),t.skeleton&&this.setSkeleton(s(t.skeleton.getChild())),t.inverseBindMatrices&&this.setInverseBindMatrices(s(t.inverseBindMatrices.getChild())),this.clearGraphChildList(this.joints),t.joints.forEach(t=>this.addJoint(s(t.getChild()))),this}getSkeleton(){return this.skeleton?this.skeleton.getChild():null}setSkeleton(t){return this.skeleton=this.graph.link("skeleton",this,t),this}getInverseBindMatrices(){return this.inverseBindMatrices?this.inverseBindMatrices.getChild():null}setInverseBindMatrices(t){return this.inverseBindMatrices=this.graph.link("inverseBindMatrices",this,t),this}addJoint(t){const s=this.graph.link("joint",this,t);return this.addGraphChild(this.joints,s)}removeJoint(t){return this.removeGraphChild(this.joints,t)}listJoints(){return this.joints.map(t=>t.getChild())}}c([f],H.prototype,"skeleton",void 0),c([f],H.prototype,"inverseBindMatrices",void 0),c([d],H.prototype,"joints",void 0);class Y extends N{constructor(){super(...arguments),this.propertyType=u.TEXTURE,this.at=null,this.lt="",this.k=""}copy(t,s=I){return super.copy(t,s),this.lt=t.lt,this.k=t.k,t.at&&(this.at=t.at.slice(0)),this}getMimeType(){return this.lt||m.extensionToMimeType(w.extension(this.k))}setMimeType(t){return this.lt=t,this}getURI(){return this.k}setURI(t){return this.k=t,this.lt=m.extensionToMimeType(w.extension(t)),this}getImage(){return this.at}setImage(t){return this.at=t,this}getSize(){return m.getSize(this.at,this.getMimeType())}}class X extends R{constructor(t){super(t),this.propertyType=u.ROOT,this.ft={generator:"glTF-Transform v0.8.0",version:"2.0"},this.dt=new Set,this.accessors=[],this.animations=[],this.buffers=[],this.cameras=[],this.materials=[],this.meshes=[],this.nodes=[],this.scenes=[],this.skins=[],this.textures=[],t.on("clone",t=>this.pt(t))}clone(){throw new Error("Root cannot be cloned.")}copy(t,s=I){if(super.copy(t,s),s===I)throw new Error("Root cannot be copied.");return Object.assign(this.ft,t.ft),t.accessors.forEach(t=>this.gt(s(t.getChild()))),t.animations.forEach(t=>this.wt(s(t.getChild()))),t.buffers.forEach(t=>this.vt(s(t.getChild()))),t.cameras.forEach(t=>this.xt(s(t.getChild()))),t.materials.forEach(t=>this.yt(s(t.getChild()))),t.meshes.forEach(t=>this.Tt(s(t.getChild()))),t.nodes.forEach(t=>this.At(s(t.getChild()))),t.scenes.forEach(t=>this.bt(s(t.getChild()))),t.skins.forEach(t=>this.Et(s(t.getChild()))),t.textures.forEach(t=>this.Mt(s(t.getChild()))),this}pt(t){return t instanceof q?this.bt(t):t instanceof J?this.At(t):t instanceof P?this.xt(t):t instanceof H?this.Et(t):t instanceof V?this.Tt(t):t instanceof z?this.yt(t):t instanceof Y?this.Mt(t):t instanceof B?this.wt(t):t instanceof _?this.gt(t):t instanceof k&&this.vt(t),this}getAsset(){return this.ft}listExtensionsUsed(){return Array.from(this.dt)}listExtensionsRequired(){return this.listExtensionsUsed().filter(t=>t.isRequired())}St(t){return this.dt.add(t),this}It(t){return this.dt.delete(t),this}bt(t){return this.addGraphChild(this.scenes,this.graph.link("scene",this,t))}listScenes(){return this.scenes.map(t=>t.getChild())}At(t){return this.addGraphChild(this.nodes,this.graph.link("node",this,t))}listNodes(){return this.nodes.map(t=>t.getChild())}xt(t){return this.addGraphChild(this.cameras,this.graph.link("camera",this,t))}listCameras(){return this.cameras.map(t=>t.getChild())}Et(t){return this.addGraphChild(this.skins,this.graph.link("skin",this,t))}listSkins(){return this.skins.map(t=>t.getChild())}Tt(t){return this.addGraphChild(this.meshes,this.graph.link("mesh",this,t))}listMeshes(){return this.meshes.map(t=>t.getChild())}yt(t){return this.addGraphChild(this.materials,this.graph.link("material",this,t))}listMaterials(){return this.materials.map(t=>t.getChild())}Mt(t){return this.addGraphChild(this.textures,this.graph.link("texture",this,t))}listTextures(){return this.textures.map(t=>t.getChild())}wt(t){return this.addGraphChild(this.animations,this.graph.link("animation",this,t))}listAnimations(){return this.animations.map(t=>t.getChild())}gt(t){return this.addGraphChild(this.accessors,this.graph.link("accessor",this,t))}listAccessors(){return this.accessors.map(t=>t.getChild())}vt(t){return this.addGraphChild(this.buffers,this.graph.link("buffer",this,t))}listBuffers(){return this.buffers.map(t=>t.getChild())}}c([d],X.prototype,"accessors",void 0),c([d],X.prototype,"animations",void 0),c([d],X.prototype,"buffers",void 0),c([d],X.prototype,"cameras",void 0),c([d],X.prototype,"materials",void 0),c([d],X.prototype,"meshes",void 0),c([d],X.prototype,"nodes",void 0),c([d],X.prototype,"scenes",void 0),c([d],X.prototype,"skins",void 0),c([d],X.prototype,"textures",void 0);class K{constructor(){this.Rt=new j,this.Ct=new X(this.Rt),this.Nt=A.DEFAULT_INSTANCE}getRoot(){return this.Ct}getGraph(){return this.Rt}getLogger(){return this.Nt}setLogger(t){return this.Nt=t,this}clone(){return(new K).merge(this)}merge(t){const s={};for(const e of t.getRoot().listExtensionsUsed()){const t=this.createExtension(e.constructor);e.isRequired()&&t.setRequired(!0),s[t.extensionName]=t}const e=new Set,i=new Map;e.add(t.Ct),i.set(t.Ct,this.Ct);for(const r of t.Rt.getLinks())for(const t of[r.getParent(),r.getChild()]){if(e.has(t))continue;let r;if(t.propertyType===u.TEXTURE_INFO)r=t;else{const e=t.constructor;r=t instanceof U?new e(this.Rt,s[t.extensionName]):new e(this.Rt)}i.set(t,r),e.add(t)}const r=t=>i.get(t);for(const t of e)i.get(t).copy(t,r);return this}async transform(...t){for(const s of t)await s(this);return this}createExtension(t){return this.getRoot().listExtensionsUsed().find(s=>s.extensionName===t.EXTENSION_NAME)||new t(this)}createScene(t=""){const s=new q(this.Rt,t);return this.Ct.bt(s),s}createNode(t=""){const s=new J(this.Rt,t);return this.Ct.At(s),s}createCamera(t=""){const s=new P(this.Rt,t);return this.Ct.xt(s),s}createSkin(t=""){const s=new H(this.Rt,t);return this.Ct.Et(s),s}createMesh(t=""){const s=new V(this.Rt,t);return this.Ct.Tt(s),s}createPrimitive(){return new $(this.Rt)}createPrimitiveTarget(t=""){return new W(this.Rt,t)}createMaterial(t=""){const s=new z(this.Rt,t);return this.Ct.yt(s),s}createTexture(t=""){const s=new Y(this.Rt,t);return this.Ct.Mt(s),s}createAnimation(t=""){const s=new B(this.Rt,t);return this.Ct.wt(s),s}createAnimationChannel(t=""){return new L(this.Rt,t)}createAnimationSampler(t=""){return new O(this.Rt,t)}createAccessor(t="",s=null){s||(s=this.getRoot().listBuffers()[0]);const e=new _(this.Rt,t).setBuffer(s);return this.Ct.gt(e),e}createBuffer(t=""){const s=new k(this.Rt,t);return this.Ct.vt(s),s}}class Z{constructor(t){this.doc=t,this.prereadTypes=[],this.prewriteTypes=[],this.dependencies=[],this.required=!1,this.properties=new Set,t.getRoot().St(this)}dispose(){this.doc.getRoot().It(this);for(const t of this.properties)t.dispose()}isRequired(){return this.required}setRequired(t){return this.required=t,this}addExtensionProperty(t){return this.properties.add(t),this}removeExtensionProperty(t){return this.properties.delete(t),this}install(t,s){return this}preread(t,s){return this}prewrite(t,s){return this}}class Q{constructor(t){this.jsonDoc=t,this.buffers=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[]}setTextureInfo(t,s){this.textureInfos.set(t,s),void 0!==s.texCoord&&t.setTexCoord(s.texCoord);const e=this.jsonDoc.json.textures[s.index];if(void 0===e.sampler)return;const i=this.jsonDoc.json.samplers[e.sampler];void 0!==i.magFilter&&t.setMagFilter(i.magFilter),void 0!==i.minFilter&&t.setMinFilter(i.minFilter),void 0!==i.wrapS&&t.setWrapS(i.wrapS),void 0!==i.wrapT&&t.setWrapT(i.wrapT)}}const tt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},st={logger:A.DEFAULT_INSTANCE,extensions:[],dependencies:{}};class et{static read(t,s=st){const{json:i}=t,r=new K;this.validate(t,s);const o=new Q(t),c=t.json.asset,a=r.getRoot().getAsset();c.copyright&&(a.copyright=c.copyright),c.extras&&(a.extras=c.extras),c.generator&&(a.generator=c.generator),c.minVersion&&(a.minVersion=c.minVersion);const l=i.extensionsUsed||[],f=i.extensionsRequired||[];for(const t of s.extensions)if(l.includes(t.EXTENSION_NAME)){const e=r.createExtension(t).setRequired(f.includes(t.EXTENSION_NAME));for(const t of e.dependencies)e.install(t,s.dependencies[t])}o.buffers=(i.buffers||[]).map(t=>{const s=r.createBuffer(t.name);return t.extras&&s.setExtras(t.extras),t.uri&&0!==t.uri.indexOf("__")&&s.setURI(t.uri),s}),o.bufferViewBuffers=(i.bufferViews||[]).map(t=>o.buffers[t.buffer]),o.accessors=(i.accessors||[]).map(s=>{const e=r.createAccessor(s.name,o.bufferViewBuffers[s.bufferView]).setType(s.type);if(s.extras&&e.setExtras(s.extras),void 0!==s.normalized&&e.setNormalized(s.normalized),void 0===s.bufferView&&!s.sparse)return e;let i;return i=void 0!==s.sparse?function(t,s){const e=tt[t.componentType],i=_.getElementSize(t.type);let r;r=void 0!==t.bufferView?it(t,s).slice():new e(t.count*i);const n=t.sparse.count,h={...t,...t.sparse.indices,count:n,type:"SCALAR"},o={...t,...t.sparse.values,count:n},u=it(h,s),c=it(o,s);for(let t=0;t<h.count;t++)for(let s=0;s<i;s++)r[u[t]*i+s]=c[t*i+s];return r}(s,t):it(s,t).slice(),e.setArray(i),e});const d=i.images||[],p=i.textures||[];r.getRoot().listExtensionsUsed().filter(t=>t.prereadTypes.includes(u.TEXTURE)).forEach(t=>t.preread(o,u.TEXTURE)),o.textures=d.map(s=>{const e=r.createTexture(s.name);if(s.extras&&e.setExtras(s.extras),void 0!==s.bufferView){const r=i.bufferViews[s.bufferView],n=t.json.buffers[r.buffer],h=r.byteOffset||0,o=(n.uri?t.resources[n.uri]:t.resources["@glb.bin"]).slice(h,h+r.byteLength);e.setImage(o)}else void 0!==s.uri&&(e.setImage(t.resources[s.uri]),0!==s.uri.indexOf("__")&&e.setURI(s.uri));if(void 0!==s.mimeType)e.setMimeType(s.mimeType);else if(s.uri){const t=w.extension(s.uri);e.setMimeType(m.extensionToMimeType(t))}return e}),o.materials=(i.materials||[]).map(t=>{const s=r.createMaterial(t.name);t.extras&&s.setExtras(t.extras),void 0!==t.alphaMode&&s.setAlphaMode(t.alphaMode),void 0!==t.alphaCutoff&&s.setAlphaCutoff(t.alphaCutoff),void 0!==t.doubleSided&&s.setDoubleSided(t.doubleSided);const e=t.pbrMetallicRoughness||{};if(void 0!==e.baseColorFactor&&s.setBaseColorFactor(e.baseColorFactor),void 0!==t.emissiveFactor&&s.setEmissiveFactor(t.emissiveFactor),void 0!==e.metallicFactor&&s.setMetallicFactor(e.metallicFactor),void 0!==e.roughnessFactor&&s.setRoughnessFactor(e.roughnessFactor),void 0!==e.baseColorTexture){const t=e.baseColorTexture;s.setBaseColorTexture(o.textures[p[t.index].source]),o.setTextureInfo(s.getBaseColorTextureInfo(),t)}if(void 0!==t.emissiveTexture){const e=t.emissiveTexture;s.setEmissiveTexture(o.textures[p[e.index].source]),o.setTextureInfo(s.getEmissiveTextureInfo(),e)}if(void 0!==t.normalTexture){const e=t.normalTexture;s.setNormalTexture(o.textures[p[e.index].source]),o.setTextureInfo(s.getNormalTextureInfo(),e),void 0!==t.normalTexture.scale&&s.setNormalScale(t.normalTexture.scale)}if(void 0!==t.occlusionTexture){const e=t.occlusionTexture;s.setOcclusionTexture(o.textures[p[e.index].source]),o.setTextureInfo(s.getOcclusionTextureInfo(),e),void 0!==t.occlusionTexture.strength&&s.setOcclusionStrength(t.occlusionTexture.strength)}if(void 0!==e.metallicRoughnessTexture){const t=e.metallicRoughnessTexture;s.setMetallicRoughnessTexture(o.textures[p[t.index].source]),o.setTextureInfo(s.getMetallicRoughnessTextureInfo(),t)}return s});const g=i.meshes||[];r.getRoot().listExtensionsUsed().filter(t=>t.prereadTypes.includes(u.PRIMITIVE)).forEach(t=>t.preread(o,u.PRIMITIVE)),o.meshes=g.map(t=>{const s=r.createMesh(t.name);return t.extras&&s.setExtras(t.extras),void 0!==t.weights&&s.setWeights(t.weights),t.primitives.forEach(e=>{const i=r.createPrimitive();e.extras&&i.setExtras(e.extras),void 0!==e.material&&i.setMaterial(o.materials[e.material]),void 0!==e.mode&&i.setMode(e.mode);for(const[t,s]of Object.entries(e.attributes||{}))i.setAttribute(t,o.accessors[s]);void 0!==e.indices&&i.setIndices(o.accessors[e.indices]);const n=t.extras&&t.extras.targetNames||[];(e.targets||[]).forEach((t,s)=>{const e=n[s]||s.toString(),h=r.createPrimitiveTarget(e);for(const[s,e]of Object.entries(t))h.setAttribute(s,o.accessors[e]);i.addTarget(h)}),s.addPrimitive(i)}),s}),o.cameras=(i.cameras||[]).map(t=>{const s=r.createCamera(t.name).setType(t.type);return t.extras&&s.setExtras(t.extras),"perspective"===t.type?s.setZNear(t.perspective.znear).setZFar(t.perspective.zfar).setYFov(t.perspective.yfov).setAspectRatio(t.perspective.aspectRatio):s.setZNear(t.orthographic.znear).setZFar(t.orthographic.zfar).setXMag(t.orthographic.xmag).setYMag(t.orthographic.ymag),s});const v=i.nodes||[];return o.nodes=v.map(t=>{const s=r.createNode(t.name);if(t.extras&&s.setExtras(t.extras),void 0!==t.translation&&s.setTranslation(t.translation),void 0!==t.rotation&&s.setRotation(t.rotation),void 0!==t.scale&&s.setScale(t.scale),void 0!==t.matrix){const i=[0,0,0],r=[0,0,0,1],o=[1,1,1];!function(t,s,i,r){let o=h([t[0],t[1],t[2]]);const u=h([t[4],t[5],t[6]]),c=h([t[8],t[9],t[10]]);n(t)<0&&(o=-o),i[0]=t[12],i[1]=t[13],i[2]=t[14];const a=t.slice(),l=1/o,f=1/u,d=1/c;a[0]*=l,a[1]*=l,a[2]*=l,a[4]*=f,a[5]*=f,a[6]*=f,a[8]*=d,a[9]*=d,a[10]*=d,e(s,a),r[0]=o,r[1]=u,r[2]=c}(t.matrix,r,i,o),s.setTranslation(i),s.setRotation(r),s.setScale(o)}return void 0!==t.weights&&s.setWeights(t.weights),s}),o.skins=(i.skins||[]).map(t=>{const s=r.createSkin(t.name);t.extras&&s.setExtras(t.extras),void 0!==t.inverseBindMatrices&&s.setInverseBindMatrices(o.accessors[t.inverseBindMatrices]),void 0!==t.skeleton&&s.setSkeleton(o.nodes[t.skeleton]);for(const e of t.joints)s.addJoint(o.nodes[e]);return s}),v.map((t,s)=>{const e=o.nodes[s];(t.children||[]).forEach(t=>e.addChild(o.nodes[t])),void 0!==t.mesh&&e.setMesh(o.meshes[t.mesh]),void 0!==t.camera&&e.setCamera(o.cameras[t.camera]),void 0!==t.skin&&e.setSkin(o.skins[t.skin])}),o.animations=(i.animations||[]).map(t=>{const s=r.createAnimation(t.name);t.extras&&s.setExtras(t.extras);const e=(t.samplers||[]).map(t=>{const e=r.createAnimationSampler().setInput(o.accessors[t.input]).setOutput(o.accessors[t.output]).setInterpolation(t.interpolation||"LINEAR");return t.extras&&e.setExtras(t.extras),s.addSampler(e),e});return(t.channels||[]).forEach(t=>{const i=r.createAnimationChannel().setSampler(e[t.sampler]).setTargetNode(o.nodes[t.target.node]).setTargetPath(t.target.path);t.extras&&i.setExtras(t.extras),s.addChannel(i)}),s}),o.scenes=(i.scenes||[]).map(t=>{const s=r.createScene(t.name);return t.extras&&s.setExtras(t.extras),(t.nodes||[]).map(t=>o.nodes[t]).forEach(t=>s.addChild(t)),s}),r.getRoot().listExtensionsUsed().forEach(t=>t.read(o)),r}static validate(t,s){const e=t.json;if("2.0"!==e.asset.version)throw new Error(`Unsupported glTF version, "${e.asset.version}".`);if(e.extensionsRequired)for(const t of e.extensionsRequired)if(!s.extensions.find(s=>s.EXTENSION_NAME===t))throw new Error(`Missing required extension, "${t}".`);if(e.extensionsUsed)for(const t of e.extensionsUsed)s.extensions.find(s=>s.EXTENSION_NAME===t)||s.logger.warn(`Missing optional extension, "${t}".`)}}function it(t,s){const e=s.json.bufferViews[t.bufferView],i=s.json.buffers[e.buffer],r=i.uri?s.resources[i.uri]:s.resources["@glb.bin"],n=tt[t.componentType],h=_.getElementSize(t.type);if(void 0!==e.byteStride&&e.byteStride!==h*n.BYTES_PER_ELEMENT)return function(t,s){const e=s.json.bufferViews[t.bufferView],i=s.json.buffers[e.buffer],r=i.uri?s.resources[i.uri]:s.resources["@glb.bin"],n=tt[t.componentType],h=_.getElementSize(t.type),o=n.BYTES_PER_ELEMENT,u=t.byteOffset||0,c=new n(t.count*h),a=new DataView(r,e.byteOffset,e.byteLength),l=e.byteStride;for(let s=0;s<t.count;s++)for(let e=0;e<h;e++){const i=u+s*l+e*o;let r;switch(t.componentType){case 5126:r=a.getFloat32(i,!0);break;case 5125:r=a.getUint32(i,!0);break;case 5123:r=a.getUint16(i,!0);break;case 5121:r=a.getUint8(i);break;case 5122:r=a.getInt16(i,!0);break;case 5120:r=a.getInt8(i);break;default:throw new Error(`Unexpected componentType "${t.componentType}".`)}c[s*h+e]=r}return c}(t,s);const o=(e.byteOffset||0)+(t.byteOffset||0);switch(t.componentType){case 5126:return new Float32Array(r,o,t.count*h);case 5125:return new Uint32Array(r,o,t.count*h);case 5123:return new Uint16Array(r,o,t.count*h);case 5121:return new Uint8Array(r,o,t.count*h);case 5122:return new Int16Array(r,o,t.count*h);case 5120:return new Int8Array(r,o,t.count*h);default:throw new Error(`Unexpected componentType "${t.componentType}".`)}}class rt{constructor(t,s){this.jsonDoc=t,this.options=s,this.accessorIndexMap=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.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={}}createTextureInfoDef(t,s){const e={magFilter:s.getMagFilter()||void 0,minFilter:s.getMinFilter()||void 0,wrapS:s.getWrapS(),wrapT:s.getWrapT()},i=JSON.stringify(e);this.samplerDefIndexMap.has(i)||(this.samplerDefIndexMap.set(i,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(e));const r={source:this.imageIndexMap.get(t),sampler:this.samplerDefIndexMap.get(i)},n=JSON.stringify(r);this.textureDefIndexMap.has(n)||(this.textureDefIndexMap.set(n,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(r));const h={index:this.textureDefIndexMap.get(n),texCoord:s.getTexCoord()};return this.textureInfoDefMap.set(s,h),h}createPropertyDef(t){const s={};return t.getName()&&(s.name=t.getName()),Object.keys(t.getExtras()).length>0&&(s.extras=t.getExtras()),s}createAccessorDef(t){const s=this.createPropertyDef(t);return s.type=t.getType(),s.componentType=t.getComponentType(),s.count=t.getCount(),t.getMax(s.max=[]),t.getMin(s.min=[]),s.normalized=t.getNormalized(),s}createImageData(t,s,e){if(this.options.isGLB)this.imageBufferViews.push(s),t.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:s.byteLength});else{const i=m.mimeTypeToExtension(e.getMimeType());t.uri=this.imageURIGenerator.createURI(e,i),this.jsonDoc.resources[t.uri]=s}}}class nt{constructor(t,s){this.multiple=t,this.basename=s,this.counter=1}createURI(t,s){return t.getURI()?t.getURI():this.multiple?`${this.basename}_${this.counter++}.${s}`:`${this.basename}.${s}`}}const ht={logger:A.DEFAULT_INSTANCE,basename:"",isGLB:!0,dependencies:{}};class ot{static write(t,s=ht){const e=t.getRoot(),i={json:{asset:e.getAsset()},resources:{}},r=s.logger||A.DEFAULT_INSTANCE,n=i.json;n.asset.generator="glTF-Transform v0.8.0";const h=new rt(i,s),o=e.listBuffers().length,c=e.listTextures().length;h.bufferURIGenerator=new nt(o>1,s.basename),h.imageURIGenerator=new nt(c>1,s.basename),h.logger=t.getLogger();for(const e of t.getRoot().listExtensionsUsed())for(const t of e.dependencies)e.install(t,s.dependencies[t]);function a(t,s,e,i){const r=[];let o=0;for(const s of t){const t=h.createAccessorDef(s);t.bufferView=n.bufferViews.length;const e=p.pad(s.getArray().buffer);t.byteOffset=o,o+=e.byteLength,r.push(e),h.accessorIndexMap.set(s,n.accessors.length),n.accessors.push(t)}const u={buffer:s,byteOffset:e,byteLength:p.concat(r).byteLength};return i&&(u.target=i),n.bufferViews.push(u),{buffers:r,byteLength:o}}function l(t,s,e){const i=t[0].getCount();let r=0;for(const s of t){const t=h.createAccessorDef(s);t.bufferView=n.bufferViews.length,t.byteOffset=r;const e=s.getElementSize(),i=s.getComponentSize();r+=p.padNumber(e*i),h.accessorIndexMap.set(s,n.accessors.length),n.accessors.push(t)}const o=i*r,u=new ArrayBuffer(o),c=new DataView(u);for(let s=0;s<i;s++){let e=0;for(const i of t){const t=i.getElementSize(),n=i.getComponentSize(),h=i.getComponentType(),o=i.getArray();for(let i=0;i<t;i++){const u=s*r+e+i*n,a=o[s*t+i];switch(h){case 5126:c.setFloat32(u,a,!0);break;case 5120:c.setInt8(u,a);break;case 5122:c.setInt16(u,a,!0);break;case 5121:c.setUint8(u,a);break;case 5123:c.setUint16(u,a,!0);break;case 5125:c.setUint32(u,a,!0);break;default:throw new Error("Unexpected component type: "+h)}}e+=p.padNumber(t*n)}}return n.bufferViews.push({buffer:s,byteOffset:e,byteLength:o,byteStride:r,target:34962}),{byteLength:o,buffers:[u]}}const f=new Map;for(const s of t.getGraph().getLinks()){if(s.getParent()===e)continue;const t=s.getChild();if(t instanceof _){const e=f.get(t)||[];e.push(s),f.set(t,e)}}return n.accessors=[],n.bufferViews=[],n.samplers=[],n.textures=[],n.images=e.listTextures().map((t,s)=>{const e=h.createPropertyDef(t);return t.getMimeType()&&(e.mimeType=t.getMimeType()),t.getImage()&&h.createImageData(e,t.getImage(),t),h.imageIndexMap.set(t,s),e}),t.getRoot().listExtensionsUsed().filter(t=>t.prewriteTypes.includes(u.ACCESSOR)).forEach(t=>t.prewrite(h,u.ACCESSOR)),n.buffers=[],e.listBuffers().forEach(t=>{const e=h.createPropertyDef(t),r=new Map,o=new Set,u=new Set,c=new Set,d=t.listParents().filter(t=>!(t instanceof X));for(const t of d){if(!(t instanceof _))throw new Error("Unimplemented buffer reference: "+t);if(h.accessorIndexMap.has(t))continue;let s=!1,e=!1,i=!1,n=!1;const a=f.get(t)||[];for(const t of a)t instanceof F?s=!0:t instanceof D?e=!0:"inverseBindMatrices"===t.getName()?i=!0:n=!0;if(s||e||i||n||(n=!0),!s||e||i||n)if(!e||s||i||n)if(!i||s||e||n){if(!n||s||e||i)throw new Error("Attribute, index, or IBM accessors must be used only for that purpose.");c.add(t)}else u.add(t);else o.add(t);else{const s=a[0].getParent(),e=r.get(s)||new Set;e.add(t),r.set(s,e)}}const g=[],w=n.buffers.length;let m,v=0;if(o.size){const t=a(Array.from(o),w,v,34963);v+=t.byteLength,g.push(...t.buffers)}for(const t of Array.from(r.values()))if(t.size){const s=l(Array.from(t),w,v);v+=s.byteLength,g.push(...s.buffers)}if(u.size){const t=a(Array.from(u),w,v);v+=t.byteLength,g.push(...t.buffers)}if(c.size){const t=a(Array.from(c),w,v);v+=t.byteLength,g.push(...t.buffers)}if(h.imageBufferViews.length)for(let t=0;t<h.imageBufferViews.length;t++)n.bufferViews[n.images[t].bufferView].byteOffset=v,v+=h.imageBufferViews[t].byteLength,g.push(h.imageBufferViews[t]);if(h.otherBufferViews.has(t))for(const s of h.otherBufferViews.get(t))n.bufferViews.push({buffer:w,byteOffset:v,byteLength:s.byteLength}),h.otherBufferViewsIndexMap.set(s,n.bufferViews.length-1),v+=s.byteLength,g.push(s);v?(s.isGLB?m="@glb.bin":(m=h.bufferURIGenerator.createURI(t,"bin"),e.uri=m),e.byteLength=v,i.resources[m]=p.concat(g),n.buffers.push(e)):h.logger.warn(`@gltf-transform/core: Skipping empty buffer, "${t.getName()}".`)}),e.listAccessors().find(t=>!t.getBuffer())&&r.warn("Skipped writing one or more Accessors: no Buffer assigned."),n.materials=e.listMaterials().map((t,s)=>{const e=h.createPropertyDef(t);if(e.alphaMode=t.getAlphaMode(),"MASK"===t.getAlphaMode()&&(e.alphaCutoff=t.getAlphaCutoff()),e.doubleSided=t.getDoubleSided(),e.pbrMetallicRoughness={},e.pbrMetallicRoughness.baseColorFactor=t.getBaseColorFactor(),e.emissiveFactor=t.getEmissiveFactor(),e.pbrMetallicRoughness.roughnessFactor=t.getRoughnessFactor(),e.pbrMetallicRoughness.metallicFactor=t.getMetallicFactor(),t.getBaseColorTexture()){const s=t.getBaseColorTexture(),i=t.getBaseColorTextureInfo();e.pbrMetallicRoughness.baseColorTexture=h.createTextureInfoDef(s,i)}if(t.getEmissiveTexture()){const s=t.getEmissiveTexture(),i=t.getEmissiveTextureInfo();e.emissiveTexture=h.createTextureInfoDef(s,i)}if(t.getNormalTexture()){const s=t.getNormalTexture(),i=t.getNormalTextureInfo(),r=h.createTextureInfoDef(s,i);1!==t.getNormalScale()&&(r.scale=t.getNormalScale()),e.normalTexture=r}if(t.getOcclusionTexture()){const s=t.getOcclusionTexture(),i=t.getOcclusionTextureInfo(),r=h.createTextureInfoDef(s,i);1!==t.getOcclusionStrength()&&(r.strength=t.getOcclusionStrength()),e.occlusionTexture=r}if(t.getMetallicRoughnessTexture()){const s=t.getMetallicRoughnessTexture(),i=t.getMetallicRoughnessTextureInfo();e.pbrMetallicRoughness.metallicRoughnessTexture=h.createTextureInfoDef(s,i)}return h.materialIndexMap.set(t,s),e}),n.meshes=e.listMeshes().map((t,s)=>{const e=h.createPropertyDef(t);let i;return e.primitives=t.listPrimitives().map(t=>{const s={attributes:{}};s.mode=t.getMode(),t.getMaterial()&&(s.material=h.materialIndexMap.get(t.getMaterial())),Object.keys(t.getExtras()).length&&(s.extras=t.getExtras()),t.getIndices()&&(s.indices=h.accessorIndexMap.get(t.getIndices()));for(const e of t.listSemantics())s.attributes[e]=h.accessorIndexMap.get(t.getAttribute(e));for(const e of t.listTargets()){const t={};for(const s of e.listSemantics())t[s]=h.accessorIndexMap.get(e.getAttribute(s));s.targets=s.targets||[],s.targets.push(t)}return t.listTargets().length&&!i&&(i=t.listTargets().map(t=>t.getName())),s}),t.getWeights().length&&(e.weights=t.getWeights()),i&&(e.extras=e.extras||{},e.extras.targetNames=i),h.meshIndexMap.set(t,s),e}),n.cameras=e.listCameras().map((t,s)=>{const e=h.createPropertyDef(t);return e.type=t.getType(),"perspective"===e.type?e.perspective={znear:t.getZNear(),zfar:t.getZFar(),yfov:t.getYFov(),aspectRatio:t.getAspectRatio()}:e.orthographic={znear:t.getZNear(),zfar:t.getZFar(),xmag:t.getXMag(),ymag:t.getYMag()},h.cameraIndexMap.set(t,s),e}),n.nodes=e.listNodes().map((t,s)=>{const e=h.createPropertyDef(t);return e.translation=t.getTranslation(),e.rotation=t.getRotation(),e.scale=t.getScale(),t.getWeights().length&&(e.weights=t.getWeights()),h.nodeIndexMap.set(t,s),e}),n.skins=e.listSkins().map((t,s)=>{const e=h.createPropertyDef(t);return t.getInverseBindMatrices()&&(e.inverseBindMatrices=h.accessorIndexMap.get(t.getInverseBindMatrices())),t.getSkeleton()&&(e.skeleton=h.nodeIndexMap.get(t.getSkeleton())),e.joints=t.listJoints().map(t=>h.nodeIndexMap.get(t)),h.skinIndexMap.set(t,s),e}),e.listNodes().forEach((t,s)=>{const e=n.nodes[s];t.getMesh()&&(e.mesh=h.meshIndexMap.get(t.getMesh())),t.getCamera()&&(e.camera=h.cameraIndexMap.get(t.getCamera())),t.getSkin()&&(e.skin=h.skinIndexMap.get(t.getSkin())),t.listChildren().length>0&&(e.children=t.listChildren().map(t=>h.nodeIndexMap.get(t)))}),n.animations=e.listAnimations().map(t=>{const s=h.createPropertyDef(t),e=new Map;return s.samplers=t.listSamplers().map((t,s)=>{const i=h.createPropertyDef(t);return i.input=h.accessorIndexMap.get(t.getInput()),i.output=h.accessorIndexMap.get(t.getOutput()),i.interpolation=t.getInterpolation(),e.set(t,s),i}),s.channels=t.listChannels().map(t=>{const s=h.createPropertyDef(t);return s.sampler=e.get(t.getSampler()),s.target={node:h.nodeIndexMap.get(t.getTargetNode()),path:t.getTargetPath()},s}),s}),n.scenes=e.listScenes().map(t=>{const s=h.createPropertyDef(t);return s.nodes=t.listChildren().map(t=>h.nodeIndexMap.get(t)),s}),n.extensionsUsed=e.listExtensionsUsed().map(t=>t.extensionName),n.extensionsRequired=e.listExtensionsRequired().map(t=>t.extensionName),e.listExtensionsUsed().forEach(t=>t.write(h)),function(t){const s=[];for(const e in t){const i=t[e];Array.isArray(i)&&0===i.length?s.push(e):null!==i&&""!==i||s.push(i)}for(const e of s)delete t[e]}(n),i}}class ut{constructor(){this.Nt=A.DEFAULT_INSTANCE,this.dt=[],this._t={}}setLogger(t){return this.Nt=t,this}registerExtensions(t){return this.dt.push(...t),this}registerDependencies(t){return Object.assign(this._t,t),this}readJSON(t){return et.read(t,{extensions:this.dt,dependencies:this._t,logger:this.Nt})}writeJSON(t,s){if(s.isGLB&&1!==t.getRoot().listBuffers().length)throw new Error("GLB must have exactly 1 buffer.");return s.dependencies={...this._t,...s.dependencies},ot.write(t,s)}binaryToJSON(t){const s=new Uint32Array(t,0,3);if(1179937895!==s[0])throw new Error("Invalid glTF asset.");if(2!==s[1])throw new Error(`Unsupported glTF binary version, "${s[1]}".`);const e=new Uint32Array(t,12,2),i=e[0],r=new Uint32Array(t,20+i,2);if(1313821514!==e[1]||5130562!==r[1])throw new Error("Unexpected GLB layout.");const n=p.decodeText(t.slice(20,20+i)),h=20+i+8;return{json:JSON.parse(n),resources:{"@glb.bin":t.slice(h,h+r[0])}}}readBinary(t){return this.readJSON(this.binaryToJSON(t))}writeBinary(t){const{json:s,resources:e}=this.writeJSON(t,{basename:"",isGLB:!0,logger:this.Nt,dependencies:this._t}),i=JSON.stringify(s),r=p.pad(p.encodeText(i),32),n=new Uint32Array([r.byteLength,1313821514]).buffer,h=p.concat([n,r]),o=p.pad(Object.values(e)[0]||new ArrayBuffer(0),0),u=new Uint32Array([o.byteLength,5130562]).buffer,c=p.concat([u,o]),a=new Uint32Array([1179937895,2,12+h.byteLength+c.byteLength]).buffer;return p.concat([a,h,c])}}class ct extends ut{constructor(){super(),this.lastReadBytes=0,this.lastWriteBytes=0,this.Bt=require("fs"),this.Lt=require("path")}read(t){const s=this.readAsJSON(t);return et.read(s,{extensions:this.dt,dependencies:this._t,logger:this.Nt})}readAsJSON(t){return t.match(/\.glb$/)||t.match(/^data:application\/octet-stream;/)?this.Ot(t):this.kt(t)}write(t,s){t.match(/\.glb$/)?this.Pt(t,s):this.Ut(t,s)}Ot(t){const s=this.Bt.readFileSync(t),e=p.trim(s);return this.lastReadBytes=e.byteLength,this.binaryToJSON(e)}kt(t){this.lastReadBytes=0;const s=this.Lt.dirname(t),e=this.Bt.readFileSync(t,"utf8");this.lastReadBytes+=e.length;const i={json:JSON.parse(e),resources:{}};return[...i.json.images||[],...i.json.buffers||[]].forEach(t=>{if(t.uri)if(t.uri.match(/data:/)){const s=`__${S()}.${w.extension(t.uri)}`;i.resources[s]=p.createBufferFromDataURI(t.uri),t.uri=s}else{const e=this.Lt.resolve(s,t.uri);i.resources[t.uri]=p.trim(this.Bt.readFileSync(e)),this.lastReadBytes+=i.resources[t.uri].byteLength}}),i}Ut(t,s){this.lastWriteBytes=0;const{json:e,resources:i}=ot.write(s,{basename:w.basename(t),isGLB:!1,logger:this.Nt,dependencies:this._t}),{Bt:r,Lt:n}=this,h=n.dirname(t),o=JSON.stringify(e,null,2);this.lastWriteBytes+=o.length,r.writeFileSync(t,o),Object.keys(i).forEach(t=>{const s=Buffer.from(i[t]);r.writeFileSync(n.join(h,t),s),this.lastWriteBytes+=s.byteLength})}Pt(t,s){const e=Buffer.from(this.writeBinary(s));this.Bt.writeFileSync(t,e),this.lastWriteBytes=e.byteLength}}const at={};class lt extends ut{constructor(t=at){super(),this.Ft=t}read(t){return this.readAsJSON(t).then(t=>this.readJSON(t))}readAsJSON(t){return t.match(/\.glb$/)||t.match(/^data:application\/octet-stream;/)?this.Ot(t):this.kt(t)}kt(t){const s={json:{},resources:{}};return fetch(t,this.Ft).then(t=>t.json()).then(t=>{s.json=t;const e=[...t.images||[],...t.buffers||[]].map(t=>{if(t.uri)return fetch(t.uri,this.Ft).then(t=>t.arrayBuffer()).then(e=>{s.resources[t.uri]=e})});return Promise.all(e).then(()=>s)})}Ot(t){return fetch(t,this.Ft).then(t=>t.arrayBuffer()).then(t=>this.binaryToJSON(t))}}export{_ as Accessor,B as Animation,L as AnimationChannel,O as AnimationSampler,k as Buffer,p as BufferUtils,I as COPY_IDENTITY,P as Camera,g as ColorUtils,K as Document,Z as Extension,U as ExtensionProperty,w as FileUtils,o as GLB_BUFFER,l as Graph,f as GraphChild,d as GraphChildList,m as ImageUtils,a as Link,A as Logger,z as Material,T as MathUtils,V as Mesh,J as Node,ct as NodeIO,$ as Primitive,W as PrimitiveTarget,R as Property,u as PropertyType,Q as ReaderContext,X as Root,q as Scene,H as Skin,Y as Texture,G as TextureInfo,lt as WebIO,rt as WriterContext,S as uuid};
import{fromRotationTranslationScale as t,getTranslation as s,getRotation as e,getScaling as i,multiply as r,determinant as n}from"gl-matrix/mat4";import{length as h}from"gl-matrix/vec3";const o="@glb.bin";var u;function c(t,s,e,i){var r,n=arguments.length,h=n<3?s:null===i?i=Object.getOwnPropertyDescriptor(s,e):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,s,e,i);else for(var o=t.length-1;o>=0;o--)(r=t[o])&&(h=(n<3?r(h):n>3?r(s,e,h):r(s,e))||h);return n>3&&h&&Object.defineProperty(s,e,h),h}!function(t){t.ACCESSOR="Accessor",t.ANIMATION="Animation",t.ANIMATION_CHANNEL="AnimationChannel",t.ANIMATION_SAMPLER="AnimationSampler",t.BUFFER="Buffer",t.CAMERA="Camera",t.MATERIAL="Material",t.MESH="Mesh",t.PRIMITIVE="Primitive",t.PRIMITIVE_TARGET="PrimitiveTarget",t.NODE="Node",t.ROOT="Root",t.SCENE="Scene",t.SKIN="Skin",t.TEXTURE="Texture",t.TEXTURE_INFO="TextureInfo"}(u||(u={}));class a{constructor(t,s,e){if(this.t=t,this.s=s,this.i=e,this.h=!1,this.o=[],!s.canLink(e))throw new Error("Cannot link disconnected graphs/documents.")}getName(){return this.t}getParent(){return this.s}getChild(){return this.i}setChild(t){return this.i=t,this}dispose(){this.h||(this.h=!0,this.o.forEach(t=>t()),this.o.length=0)}onDispose(t){return this.o.push(t),this}isDisposed(){return this.h}}class l{constructor(){this.u=new Set,this.l=new Set,this.p=new Map,this.g=new Map,this.o={}}on(t,s){return this.o[t]=this.o[t]||[],this.o[t].push(s),this}emit(t,s){for(const e of this.o[t]||[])e(s);return this}getLinks(){return Array.from(this.l)}listParents(t){const s=this.g.get(t)||this.u;return Array.from(s).map(t=>t.getParent())}listChildren(t){const s=this.p.get(t)||this.u;return Array.from(s).map(t=>t.getChild())}disconnectChildren(t){return(this.p.get(t)||this.u).forEach(t=>t.dispose()),this}disconnectParents(t,s){let e=Array.from(this.g.get(t)||this.u);return s&&(e=e.filter(t=>s(t.getParent()))),e.forEach(t=>t.dispose()),this}swapChild(t,s,e){const i=this.p.get(t)||this.u;return Array.from(i).filter(t=>t.getChild()===s).forEach(t=>{this.g.get(s).delete(t),t.setChild(e),this.g.has(e)||this.g.set(e,new Set),this.g.get(e).add(t)}),this}link(t,s,e){if(!e)return null;const i=new a(t,s,e);return this.registerLink(i),i}registerLink(t){this.l.add(t);const s=t.getParent();this.p.has(s)||this.p.set(s,new Set),this.p.get(s).add(t);const e=t.getChild();return this.g.has(e)||this.g.set(e,new Set),this.g.get(e).add(t),t.onDispose(()=>this.unlink(t)),t}unlink(t){return this.l.delete(t),this.p.get(t.getParent()).delete(t),this.g.get(t.getChild()).delete(t),this}}function f(t,s){Object.defineProperty(t,s,{get:function(){return this["__"+s]},set:function(t){const e=this["__"+s];e&&!Array.isArray(e)&&e.dispose(),t&&!Array.isArray(t)&&t.onDispose(()=>{this["__"+s]=null}),this["__"+s]=t},enumerable:!0})}function d(t,s){}class p{static createBufferFromDataURI(t){if("undefined"==typeof Buffer){const s=atob(t.split(",")[1]),e=new Uint8Array(s.length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e.buffer}{const s=t.split(",")[1],e=t.indexOf("base64")>=0;return this.trim(Buffer.from(s,e?"base64":"utf8"))}}static encodeText(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t).buffer:this.trim(Buffer.from(t))}static decodeText(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")}static trim(t){const{byteOffset:s,byteLength:e}=t;return t.buffer.slice(s,s+e)}static concat(t){let s=0;for(const e of t)s+=e.byteLength;const e=new Uint8Array(s);let i=0;for(const s of t)e.set(new Uint8Array(s),i),i+=s.byteLength;return e.buffer}static pad(t,s=0){const e=this.padNumber(t.byteLength);if(e!==t.byteLength){const i=new Uint8Array(e);if(i.set(new Uint8Array(t)),0!==s)for(let r=t.byteLength;r<e;r++)i[r]=s;return i.buffer}return t}static padNumber(t){return 4*Math.ceil(t/4)}static equals(t,s){if(t===s)return!0;if(t.byteLength!==s.byteLength)return!1;const e=new DataView(t),i=new DataView(s);let r=t.byteLength;for(;r--;)if(e.getUint8(r)!==i.getUint8(r))return!1;return!0}}class g{static hexToFactor(t,s){return t=Math.floor(t),s[0]=(t>>16&255)/255,s[1]=(t>>8&255)/255,s[2]=(255&t)/255,this.convertSRGBToLinear(s,s)}static factorToHex(t){const s=[...t],[e,i,r]=this.convertLinearToSRGB(t,s);return 255*e<<16^255*i<<8^255*r<<0}static convertSRGBToLinear(t,s){for(let e=0;e<3;e++)s[e]=t[e]<.04045?.0773993808*t[e]:Math.pow(.9478672986*t[e]+.0521327014,2.4);return s}static convertLinearToSRGB(t,s){for(let e=0;e<3;e++)s[e]=t[e]<.0031308?12.92*t[e]:1.055*Math.pow(t[e],.41666)-.055;return s}}class w{static basename(t){const s=t.split(/[\\/]/).pop();return s.substr(0,s.lastIndexOf("."))}static extension(t){return 0!==t.indexOf("data:")?t.split(/[\\/]/).pop().split(/[.]/).pop():0===t.indexOf("data:image/png")?"png":0===t.indexOf("data:image/jpeg")?"jpeg":"bin"}}class m{static getSize(t,s){switch(s){case"image/png":return this.m(t);case"image/jpeg":return this.v(t);case"image/webp":return this.T(t);case"image/ktx2":return this.A(t);default:return null}}static getChannels(t,s){switch(s){case"image/png":return 4;case"image/jpeg":return 3;case"image/webp":case"image/ktx2":default:return 4}}static getMemSize(t,s){if("image/ktx2"===s){const s=new DataView(t);v(s);const e=s.getUint32(40,!0),i=80;let r=0;for(let t=0;t<e;t++)r+=y(s,i+3*t*8+16,!0)||y(s,i+3*t*8+8,!0);return r}const e=this.getSize(t,s),i=this.getChannels(t,s);return e?e[0]*e[1]*i:null}static v(t){let s,e,i=new DataView(t,4);for(;i.byteLength;){if(s=i.getUint16(0,!1),x(i,s),e=i.getUint8(s+1),192===e||193===e||194===e)return[i.getUint16(s+7,!1),i.getUint16(s+5,!1)];i=new DataView(t,i.byteOffset+s+2)}throw new TypeError("Invalid JPG, no size found")}static m(t){const s=new DataView(t);return"CgBI"===p.decodeText(t.slice(12,16))?[s.getUint32(32,!1),s.getUint32(36,!1)]:[s.getUint32(16,!1),s.getUint32(20,!1)]}static T(t){const s=p.decodeText(t.slice(0,4)),e=p.decodeText(t.slice(8,12));if("RIFF"!==s||"WEBP"!==e)return null;const i=new DataView(t);let r=12;for(;r<t.byteLength;){const s=p.decodeText(t.slice(r,r+4)),e=i.getUint32(r+4,!0);if("VP8 "===s)return[16383&i.getInt16(r+14,!0),16383&i.getInt16(r+16,!0)];if("VP8L"===s){const t=i.getUint8(r+9),s=i.getUint8(r+10),e=i.getUint8(r+11);return[1+((63&s)<<8|t),1+((15&i.getUint8(r+12))<<10|e<<2|(192&s)>>6)]}r+=8+e+e%2}return null}static A(t){v(new DataView(t));const s=new DataView(t);return[s.getUint32(20,!0),s.getUint32(24,!0)]}static mimeTypeToExtension(t){return"image/jpeg"===t?"jpg":t.split("/").pop()}static extensionToMimeType(t){return"jpg"===t?"image/jpeg":"image/"+t}}function v(t){const s=t.buffer.slice(t.byteOffset+1,t.byteOffset+7);if("KTX 20"!==p.decodeText(s))throw new TypeError("Corrupt KTX2.")}function x(t,s){if(s>t.byteLength)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(255!==t.getUint8(s))throw new TypeError("Invalid JPG, marker table corrupted")}function y(t,s,e){const i=t.getUint32(s,e),r=t.getUint32(s+4,e);return e?i+2**32*r:2**32*i+r}class T{static identity(t){return t}static denormalize(t,s){switch(s){case 5126:return t;case 5123:return t/65535;case 5121:return t/255;case 5122:return Math.max(t/32767,-1);case 5120:return Math.max(t/127,-1)}}static normalize(t,s){switch(s){case 5126:return t;case 5123:return Math.round(65535*t);case 5121:return Math.round(255*t);case 5122:return Math.round(32767*t);case 5120:return Math.round(127*t)}}}class A{constructor(t){this.verbosity=t}debug(t){this.verbosity<=A.Verbosity.DEBUG&&console.debug(t)}info(t){this.verbosity<=A.Verbosity.INFO&&console.info(t)}warn(t){this.verbosity<=A.Verbosity.WARN&&console.warn(t)}error(t){this.verbosity<=A.Verbosity.ERROR&&console.error(t)}}A.Verbosity={SILENT:4,ERROR:3,WARN:2,INFO:1,DEBUG:0},A.DEFAULT_INSTANCE=new A(A.Verbosity.INFO);const b="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",E=new Set,M=function(){let t="";for(let s=0;s<6;s++)t+=b.charAt(Math.floor(Math.random()*b.length));return t},S=function(){for(let t=0;t<999;t++){const t=M();if(!E.has(t))return E.add(t),t}},I=t=>t;class R extends class{constructor(t){this.h=!1,this.graph=t}canLink(t){return this.graph===t.graph}isDisposed(){return this.h}dispose(){this.graph.disconnectChildren(this),this.graph.disconnectParents(this),this.h=!0}detach(){return this.graph.disconnectParents(this),this}swap(t,s){return this.graph.swapChild(this,t,s),this}addGraphChild(t,s){return t.push(s),s.onDispose(()=>{const e=t.filter(t=>t!==s);t.length=0;for(const s of e)t.push(s)}),this}removeGraphChild(t,s){return t.filter(t=>t.getChild()===s).forEach(t=>t.dispose()),this}clearGraphChildList(t){for(;t.length>0;)t[0].dispose();return this}listGraphParents(){return this.graph.listParents(this)}}{constructor(t,s=""){super(t),this.M={},this.t="",this.t=s}getName(){return this.t}setName(t){return this.t=t,this}getExtras(){return this.M}setExtras(t){return this.M=t,this}clone(){const t=new(0,this.constructor)(this.graph).copy(this,I);return this.graph.emit("clone",t),t}copy(t,s=I){return this.t=t.t,this.M=JSON.parse(JSON.stringify(t.M)),this}detach(){return this.graph.disconnectParents(this,t=>"Root"!==t.propertyType),this}listParents(){return this.listGraphParents()}}const C="Pass extension name (string) as lookup token, not a constructor.";class N extends R{constructor(){super(...arguments),this.extensions=[]}copy(t,s=I){return super.copy(t,s),this.clearGraphChildList(this.extensions),t.extensions.forEach(t=>{const e=t.getChild();this.setExtension(e.extensionName,s(e))}),this}getExtension(t){if("string"!=typeof t)throw new Error(C);const s=this.extensions.find(s=>s.getChild().extensionName===t);return s?s.getChild():null}setExtension(t,s){if("string"!=typeof t)throw new Error(C);const e=this.getExtension(t);return e&&this.removeGraphChild(this.extensions,e),s?(s.S(this),this.addGraphChild(this.extensions,this.graph.link(t,this,s))):this}listExtensions(){return this.extensions.map(t=>t.getChild())}}c([d],N.prototype,"extensions",void 0);class _ extends N{constructor(){super(...arguments),this.propertyType=u.ACCESSOR,this.I=null,this.R="SCALAR",this.C=null,this.N=!1,this._=T.identity,this.B=T.identity,this.buffer=null}copy(t,s=I){return super.copy(t,s),this.R=t.R,this.C=t.C,this.N=t.N,this._=t._,this.B=t.B,t.I&&(this.I=t.I.slice()),t.buffer&&this.setBuffer(s(t.buffer.getChild())),this}static getElementSize(t){switch(t){case"SCALAR":return 1;case"VEC2":return 2;case"VEC3":return 3;case"VEC4":case"MAT2":return 4;case"MAT3":return 9;case"MAT4":return 16;default:throw new Error("Unexpected type: "+t)}}static getComponentSize(t){switch(t){case 5120:case 5121:return 1;case 5122:case 5123:return 2;case 5125:case 5126:return 4;default:throw new Error("Unexpected component type: "+t)}}getMinNormalized(t){const s=this.getElementSize();this.getMin(t);for(let e=0;e<s;e++)t[e]=this.B(t[e]);return t}getMin(t){const s=this.getCount(),e=this.getElementSize();for(let s=0;s<e;s++)t[s]=Infinity;for(let i=0;i<s*e;i+=e)for(let s=0;s<e;s++){const e=this.I[i+s];Number.isFinite(e)&&(t[s]=Math.min(t[s],e))}return t}getMaxNormalized(t){const s=this.getElementSize();this.getMax(t);for(let e=0;e<s;e++)t[e]=this.B(t[e]);return t}getMax(t){const s=this.getCount(),e=this.getElementSize();for(let s=0;s<e;s++)t[s]=-Infinity;for(let i=0;i<s*e;i+=e)for(let s=0;s<e;s++){const e=this.I[i+s];Number.isFinite(e)&&(t[s]=Math.max(t[s],e))}return t}getCount(){return this.I.length/this.getElementSize()}getType(){return this.R}setType(t){return this.R=t,this}getElementSize(){return _.getElementSize(this.R)}getComponentSize(){return this.I.BYTES_PER_ELEMENT}getComponentType(){return this.C}getNormalized(){return this.N}setNormalized(t){return this.N=t,t?(this.B=t=>T.denormalize(t,this.C),this._=t=>T.normalize(t,this.C)):(this.B=T.identity,this._=T.identity),this}getScalar(t){const s=this.getElementSize();return this.B(this.I[t*s])}setScalar(t,s){return this.I[t*this.getElementSize()]=this._(s),this}getElement(t,s){const e=this.getElementSize();for(let i=0;i<e;i++)s[i]=this.B(this.I[t*e+i]);return s}setElement(t,s){const e=this.getElementSize();for(let i=0;i<e;i++)this.I[t*e+i]=this._(s[i]);return this}getBuffer(){return this.buffer?this.buffer.getChild():null}setBuffer(t){return this.buffer=this.graph.link("buffer",this,t),this}getArray(){return this.I}setArray(t){return this.C=function(t){switch(t.constructor){case Float32Array:return 5126;case Uint32Array:return 5125;case Uint16Array:return 5123;case Uint8Array:return 5121;case Int16Array:return 5122;case Int8Array:return 5120;default:throw new Error("Unknown accessor componentType.")}}(t),this.I=t,this}getByteLength(){return this.I.byteLength}}_.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT3:"MAT3",MAT4:"MAT4"},_.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},c([f],_.prototype,"buffer",void 0);class B extends N{constructor(){super(...arguments),this.propertyType=u.ANIMATION,this.channels=[],this.samplers=[]}copy(t,s=I){return super.copy(t,s),this.clearGraphChildList(this.channels),this.clearGraphChildList(this.samplers),t.channels.forEach(t=>this.addChannel(s(t.getChild()))),t.samplers.forEach(t=>this.addSampler(s(t.getChild()))),this}addChannel(t){const s=this.graph.link("channel",this,t);return this.addGraphChild(this.channels,s)}removeChannel(t){return this.removeGraphChild(this.channels,t)}listChannels(){return this.channels.map(t=>t.getChild())}addSampler(t){const s=this.graph.link("sampler",this,t);return this.addGraphChild(this.samplers,s)}removeSampler(t){return this.removeGraphChild(this.samplers,t)}listSamplers(){return this.samplers.map(t=>t.getChild())}}c([d],B.prototype,"channels",void 0),c([d],B.prototype,"samplers",void 0);class L extends R{constructor(){super(...arguments),this.propertyType=u.ANIMATION_CHANNEL,this.L=null,this.targetNode=null,this.sampler=null}copy(t,s=I){return super.copy(t,s),this.L=t.L,t.targetNode&&this.setTargetNode(s(t.targetNode.getChild())),t.sampler&&this.setSampler(s(t.sampler.getChild())),this}getTargetPath(){return this.L}setTargetPath(t){return this.L=t,this}getTargetNode(){return this.targetNode?this.targetNode.getChild():null}setTargetNode(t){return this.targetNode=this.graph.link("target.node",this,t),this}getSampler(){return this.sampler?this.sampler.getChild():null}setSampler(t){return this.sampler=this.graph.link("sampler",this,t),this}}c([f],L.prototype,"targetNode",void 0),c([f],L.prototype,"sampler",void 0);class O extends R{constructor(){super(...arguments),this.propertyType=u.ANIMATION_SAMPLER,this.O="LINEAR",this.input=null,this.output=null}copy(t,s=I){return super.copy(t,s),this.O=t.O,t.input&&this.setInput(s(t.input.getChild())),t.output&&this.setOutput(s(t.output.getChild())),this}getInterpolation(){return this.O}setInterpolation(t){return this.O=t,this}getInput(){return this.input?this.input.getChild():null}setInput(t){return this.input=this.graph.link("input",this,t),this}getOutput(){return this.output?this.output.getChild():null}setOutput(t){return this.output=this.graph.link("output",this,t),this}}c([f],O.prototype,"input",void 0),c([f],O.prototype,"output",void 0);class k extends N{constructor(){super(...arguments),this.propertyType=u.BUFFER}copy(t,s=I){return super.copy(t,s),this.k=t.k,this}getURI(){return this.k}setURI(t){return this.k=t,this}}class P extends N{constructor(){super(...arguments),this.propertyType=u.CAMERA,this.R="perspective"}copy(t,s=I){return super.copy(t,s),this.R=t.R,this.P=t.P,this.U=t.U,this.F=t.F,this.D=t.D,this.j=t.j,this.G=t.G,this}getType(){return this.R}setType(t){return this.R=t,this}getZNear(){return this.P}setZNear(t){return this.P=t,this}getZFar(){return this.U}setZFar(t){return this.U=t,this}getAspectRatio(){return this.F}setAspectRatio(t){return this.F=t,this}getYFov(){return this.D}setYFov(t){return this.D=t,this}getXMag(){return this.j}setXMag(t){return this.j=t,this}getYMag(){return this.G}setYMag(t){return this.G=t,this}}class U extends R{constructor(t,s){super(t),this.V=s,this.V.addExtensionProperty(this)}dispose(){this.V.removeExtensionProperty(this),super.dispose()}S(t){if(!this.parentTypes.includes(t.propertyType))throw new Error(`Parent "${t.propertyType}" invalid for child "${this.propertyType}".`)}}class F extends a{constructor(){super(...arguments),this.semantic=""}copy(t){return this.semantic=t.semantic,this}}class D extends a{copy(t){return this}}class j extends l{linkAttribute(t,s,e){if(!e)return null;const i=new F(t,s,e);return this.registerLink(i),i}linkIndex(t,s,e){if(!e)return null;const i=new D(t,s,e);return this.registerLink(i),i}}class G extends N{constructor(){super(...arguments),this.propertyType=u.TEXTURE_INFO,this.J=0,this.$=null,this.W=null,this.q=10497,this.H=10497}copy(t,s=I){return super.copy(t,s),this.J=t.J,this.$=t.$,this.W=t.W,this.q=t.q,this.H=t.H,this}getTexCoord(){return this.J}setTexCoord(t){return this.J=t,this}getMagFilter(){return this.$}setMagFilter(t){return this.$=t,this}getMinFilter(){return this.W}setMinFilter(t){return this.W=t,this}getWrapS(){return this.q}setWrapS(t){return this.q=t,this}getWrapT(){return this.H}setWrapT(t){return this.H=t,this}}G.TextureWrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},G.TextureMagFilter={NEAREST:9728,LINEAR:9729},G.TextureMinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};class z extends N{constructor(){super(...arguments),this.propertyType=u.MATERIAL,this.Y="OPAQUE",this.X=.5,this.K=!1,this.Z=[1,1,1,1],this.tt=[0,0,0],this.st=1,this.et=1,this.it=1,this.rt=1,this.baseColorTexture=null,this.baseColorTextureInfo=this.graph.link("baseColorTextureInfo",this,new G(this.graph)),this.emissiveTexture=null,this.emissiveTextureInfo=this.graph.link("emissiveTextureInfo",this,new G(this.graph)),this.normalTexture=null,this.normalTextureInfo=this.graph.link("normalTextureInfo",this,new G(this.graph)),this.occlusionTexture=null,this.occlusionTextureInfo=this.graph.link("occlusionTextureInfo",this,new G(this.graph)),this.metallicRoughnessTexture=null,this.metallicRoughnessTextureInfo=this.graph.link("metallicRoughnessTextureInfo",this,new G(this.graph))}copy(t,s=I){return super.copy(t,s),this.Y=t.Y,this.X=t.X,this.K=t.K,this.Z=[...t.Z],this.tt=[...t.tt],this.st=t.st,this.et=t.et,this.it=t.it,this.rt=t.rt,t.baseColorTexture&&(this.setBaseColorTexture(s(t.baseColorTexture.getChild())),this.getBaseColorTextureInfo().copy(s(t.baseColorTextureInfo.getChild()),s)),t.emissiveTexture&&(this.setEmissiveTexture(s(t.emissiveTexture.getChild())),this.getEmissiveTextureInfo().copy(s(t.emissiveTextureInfo.getChild()),s)),t.normalTexture&&(this.setNormalTexture(s(t.normalTexture.getChild())),this.getNormalTextureInfo().copy(s(t.normalTextureInfo.getChild()),s)),t.occlusionTexture&&(this.setOcclusionTexture(s(t.occlusionTexture.getChild())),this.getOcclusionTextureInfo().copy(s(t.occlusionTextureInfo.getChild()),s)),t.metallicRoughnessTexture&&(this.setMetallicRoughnessTexture(s(t.metallicRoughnessTexture.getChild())),this.getMetallicRoughnessTextureInfo().copy(s(t.metallicRoughnessTextureInfo.getChild()),s)),this}dispose(){this.baseColorTextureInfo.getChild().dispose(),this.emissiveTextureInfo.getChild().dispose(),this.normalTextureInfo.getChild().dispose(),this.occlusionTextureInfo.getChild().dispose(),this.metallicRoughnessTextureInfo.getChild().dispose(),super.dispose()}getDoubleSided(){return this.K}setDoubleSided(t){return this.K=t,this}getAlpha(){return this.Z[3]}setAlpha(t){return this.Z[3]=t,this}getAlphaMode(){return this.Y}setAlphaMode(t){return this.Y=t,this}getAlphaCutoff(){return this.X}setAlphaCutoff(t){return this.X=t,this}getBaseColorFactor(){return this.Z}setBaseColorFactor(t){return this.Z=t,this}getBaseColorHex(){return g.factorToHex(this.Z)}setBaseColorHex(t){return g.hexToFactor(t,this.Z),this}getBaseColorTexture(){return this.baseColorTexture?this.baseColorTexture.getChild():null}getBaseColorTextureInfo(){return this.baseColorTexture?this.baseColorTextureInfo.getChild():null}setBaseColorTexture(t){return this.baseColorTexture=this.graph.link("baseColorTexture",this,t),this}getEmissiveFactor(){return this.tt}setEmissiveFactor(t){return this.tt=t,this}getEmissiveHex(){return g.factorToHex(this.tt)}setEmissiveHex(t){return g.hexToFactor(t,this.tt),this}getEmissiveTexture(){return this.emissiveTexture?this.emissiveTexture.getChild():null}getEmissiveTextureInfo(){return this.emissiveTexture?this.emissiveTextureInfo.getChild():null}setEmissiveTexture(t){return this.emissiveTexture=this.graph.link("emissiveTexture",this,t),this}getNormalScale(){return this.st}setNormalScale(t){return this.st=t,this}getNormalTexture(){return this.normalTexture?this.normalTexture.getChild():null}getNormalTextureInfo(){return this.normalTexture?this.normalTextureInfo.getChild():null}setNormalTexture(t){return this.normalTexture=this.graph.link("normalTexture",this,t),this}getOcclusionStrength(){return this.et}setOcclusionStrength(t){return this.et=t,this}getOcclusionTexture(){return this.occlusionTexture?this.occlusionTexture.getChild():null}getOcclusionTextureInfo(){return this.occlusionTexture?this.occlusionTextureInfo.getChild():null}setOcclusionTexture(t){return this.occlusionTexture=this.graph.link("occlusionTexture",this,t),this}getRoughnessFactor(){return this.it}setRoughnessFactor(t){return this.it=t,this}getMetallicFactor(){return this.rt}setMetallicFactor(t){return this.rt=t,this}getMetallicRoughnessTexture(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.getChild():null}getMetallicRoughnessTextureInfo(){return this.metallicRoughnessTexture?this.metallicRoughnessTextureInfo.getChild():null}setMetallicRoughnessTexture(t){return this.metallicRoughnessTexture=this.graph.link("metallicRoughnessTexture",this,t),this}}c([f],z.prototype,"baseColorTexture",void 0),c([f],z.prototype,"baseColorTextureInfo",void 0),c([f],z.prototype,"emissiveTexture",void 0),c([f],z.prototype,"emissiveTextureInfo",void 0),c([f],z.prototype,"normalTexture",void 0),c([f],z.prototype,"normalTextureInfo",void 0),c([f],z.prototype,"occlusionTexture",void 0),c([f],z.prototype,"occlusionTextureInfo",void 0),c([f],z.prototype,"metallicRoughnessTexture",void 0),c([f],z.prototype,"metallicRoughnessTextureInfo",void 0);class V extends N{constructor(){super(...arguments),this.propertyType=u.MESH,this.nt=[],this.primitives=[]}copy(t,s=I){return super.copy(t,s),this.nt=[...t.nt],this.clearGraphChildList(this.primitives),t.primitives.forEach(t=>this.addPrimitive(s(t.getChild()))),this}addPrimitive(t){return this.addGraphChild(this.primitives,this.graph.link("primitive",this,t))}removePrimitive(t){return this.removeGraphChild(this.primitives,t)}listPrimitives(){return this.primitives.map(t=>t.getChild())}getWeights(){return this.nt}setWeights(t){return this.nt=t,this}}c([d],V.prototype,"primitives",void 0);class J extends N{constructor(){super(...arguments),this.propertyType=u.NODE,this.ht=[0,0,0],this.ot=[0,0,0,1],this.ut=[1,1,1],this.nt=[],this.s=null,this.camera=null,this.mesh=null,this.skin=null,this.children=[]}copy(t,s=I){return super.copy(t,s),this.ht=[...t.ht],this.ot=[...t.ot],this.ut=[...t.ut],this.nt=[...t.nt],t.camera&&this.setCamera(s(t.camera.getChild())),t.mesh&&this.setMesh(s(t.mesh.getChild())),t.skin&&this.setSkin(s(t.skin.getChild())),s!==I&&(this.clearGraphChildList(this.children),t.children.forEach(t=>this.addChild(s(t.getChild())))),this}getTranslation(){return this.ht}getRotation(){return this.ot}getScale(){return this.ut}setTranslation(t){return this.ht=t,this}setRotation(t){return this.ot=t,this}setScale(t){return this.ut=t,this}getMatrix(){return t([],this.ot,this.ht,this.ut)}getWorldTranslation(){return s([],this.getWorldMatrix())}getWorldRotation(){return e([],this.getWorldMatrix())}getWorldScale(){return i([],this.getWorldMatrix())}getWorldMatrix(){const t=[];for(let s=this;s instanceof J;s=s.s)t.push(s);let s;const e=t.pop().getMatrix();for(;s=t.pop();)r(e,e,s.getMatrix());return e}addChild(t){t.s&&t.s.removeChild(t);const s=this.graph.link("child",this,t);return this.addGraphChild(this.children,s),t.s=this,s.onDispose(()=>t.s=null),this}removeChild(t){return this.removeGraphChild(this.children,t)}listChildren(){return this.children.map(t=>t.getChild())}getParent(){return this.s}getMesh(){return this.mesh?this.mesh.getChild():null}setMesh(t){return this.mesh=this.graph.link("mesh",this,t),this}getCamera(){return this.camera?this.camera.getChild():null}setCamera(t){return this.camera=this.graph.link("camera",this,t),this}getSkin(){return this.skin?this.skin.getChild():null}setSkin(t){return this.skin=this.graph.link("skin",this,t),this}getWeights(){return this.nt}setWeights(t){return this.nt=t,this}traverse(t){t(this);for(const s of this.listChildren())s.traverse(t);return this}}c([f],J.prototype,"camera",void 0),c([f],J.prototype,"mesh",void 0),c([f],J.prototype,"skin",void 0),c([d],J.prototype,"children",void 0);class $ extends N{constructor(){super(...arguments),this.propertyType=u.PRIMITIVE,this.ct=4,this.material=null,this.indices=null,this.attributes=[],this.targets=[]}copy(t,s=I){return super.copy(t,s),this.ct=t.ct,t.indices&&this.setIndices(s(t.indices.getChild())),t.material&&this.setMaterial(s(t.material.getChild())),this.clearGraphChildList(this.attributes),t.listSemantics().forEach(e=>{this.setAttribute(e,s(t.getAttribute(e)))}),this.clearGraphChildList(this.targets),t.targets.forEach(t=>this.addTarget(s(t.getChild()))),this}getIndices(){return this.indices?this.indices.getChild():null}setIndices(t){return this.indices=this.graph.linkIndex("index",this,t),this}getAttribute(t){const s=this.attributes.find(s=>s.semantic===t);return s?s.getChild():null}setAttribute(t,s){const e=this.getAttribute(t);if(e&&this.removeGraphChild(this.attributes,e),!s)return this;const i=this.graph.linkAttribute(t.toLowerCase(),this,s);return i.semantic=t,this.addGraphChild(this.attributes,i)}listAttributes(){return this.attributes.map(t=>t.getChild())}listSemantics(){return this.attributes.map(t=>t.semantic)}getMaterial(){return this.material?this.material.getChild():null}setMaterial(t){return this.material=this.graph.link("material",this,t),this}getMode(){return this.ct}setMode(t){return this.ct=t,this}listTargets(){return this.targets.map(t=>t.getChild())}addTarget(t){return this.addGraphChild(this.targets,this.graph.link("target",this,t)),this}removeTarget(t){return this.removeGraphChild(this.targets,t)}}c([f],$.prototype,"material",void 0),c([f],$.prototype,"indices",void 0),c([d],$.prototype,"attributes",void 0),c([d],$.prototype,"targets",void 0);class W extends R{constructor(){super(...arguments),this.propertyType=u.PRIMITIVE_TARGET,this.attributes=[]}copy(t,s=I){return super.copy(t,s),this.clearGraphChildList(this.attributes),t.listSemantics().forEach(e=>{this.setAttribute(e,s(t.getAttribute(e)))}),this}getAttribute(t){const s=this.attributes.find(s=>s.semantic===t);return s?s.getChild():null}setAttribute(t,s){const e=this.getAttribute(t);if(e&&this.removeGraphChild(this.attributes,e),!s)return this;const i=this.graph.linkAttribute(t.toLowerCase(),this,s);return i.semantic=t,this.addGraphChild(this.attributes,i)}listAttributes(){return this.attributes.map(t=>t.getChild())}listSemantics(){return this.attributes.map(t=>t.semantic)}}c([d],W.prototype,"attributes",void 0);class q extends N{constructor(){super(...arguments),this.propertyType=u.SCENE,this.children=[]}copy(t,s=I){return super.copy(t,s),s!==I&&(this.clearGraphChildList(this.children),t.children.forEach(t=>this.addChild(s(t.getChild())))),this}addChild(t){t.s&&t.s.removeChild(t);const s=this.graph.link("child",this,t);return this.addGraphChild(this.children,s),t.s=this,s.onDispose(()=>t.s=null),this}removeChild(t){return this.removeGraphChild(this.children,t)}listChildren(){return this.children.map(t=>t.getChild())}traverse(t){for(const s of this.listChildren())s.traverse(t);return this}}c([d],q.prototype,"children",void 0);class H extends N{constructor(){super(...arguments),this.propertyType=u.SKIN,this.skeleton=null,this.inverseBindMatrices=null,this.joints=[]}copy(t,s=I){return super.copy(t,s),t.skeleton&&this.setSkeleton(s(t.skeleton.getChild())),t.inverseBindMatrices&&this.setInverseBindMatrices(s(t.inverseBindMatrices.getChild())),this.clearGraphChildList(this.joints),t.joints.forEach(t=>this.addJoint(s(t.getChild()))),this}getSkeleton(){return this.skeleton?this.skeleton.getChild():null}setSkeleton(t){return this.skeleton=this.graph.link("skeleton",this,t),this}getInverseBindMatrices(){return this.inverseBindMatrices?this.inverseBindMatrices.getChild():null}setInverseBindMatrices(t){return this.inverseBindMatrices=this.graph.link("inverseBindMatrices",this,t),this}addJoint(t){const s=this.graph.link("joint",this,t);return this.addGraphChild(this.joints,s)}removeJoint(t){return this.removeGraphChild(this.joints,t)}listJoints(){return this.joints.map(t=>t.getChild())}}c([f],H.prototype,"skeleton",void 0),c([f],H.prototype,"inverseBindMatrices",void 0),c([d],H.prototype,"joints",void 0);class Y extends N{constructor(){super(...arguments),this.propertyType=u.TEXTURE,this.at=null,this.lt="",this.k=""}copy(t,s=I){return super.copy(t,s),this.lt=t.lt,this.k=t.k,t.at&&(this.at=t.at.slice(0)),this}getMimeType(){return this.lt||m.extensionToMimeType(w.extension(this.k))}setMimeType(t){return this.lt=t,this}getURI(){return this.k}setURI(t){return this.k=t,this.lt=m.extensionToMimeType(w.extension(t)),this}getImage(){return this.at}setImage(t){return this.at=t,this}getSize(){return m.getSize(this.at,this.getMimeType())}}class X extends R{constructor(t){super(t),this.propertyType=u.ROOT,this.ft={generator:"glTF-Transform v0.8.1",version:"2.0"},this.dt=new Set,this.accessors=[],this.animations=[],this.buffers=[],this.cameras=[],this.materials=[],this.meshes=[],this.nodes=[],this.scenes=[],this.skins=[],this.textures=[],t.on("clone",t=>this.pt(t))}clone(){throw new Error("Root cannot be cloned.")}copy(t,s=I){if(super.copy(t,s),s===I)throw new Error("Root cannot be copied.");return Object.assign(this.ft,t.ft),t.accessors.forEach(t=>this.gt(s(t.getChild()))),t.animations.forEach(t=>this.wt(s(t.getChild()))),t.buffers.forEach(t=>this.vt(s(t.getChild()))),t.cameras.forEach(t=>this.xt(s(t.getChild()))),t.materials.forEach(t=>this.yt(s(t.getChild()))),t.meshes.forEach(t=>this.Tt(s(t.getChild()))),t.nodes.forEach(t=>this.At(s(t.getChild()))),t.scenes.forEach(t=>this.bt(s(t.getChild()))),t.skins.forEach(t=>this.Et(s(t.getChild()))),t.textures.forEach(t=>this.Mt(s(t.getChild()))),this}pt(t){return t instanceof q?this.bt(t):t instanceof J?this.At(t):t instanceof P?this.xt(t):t instanceof H?this.Et(t):t instanceof V?this.Tt(t):t instanceof z?this.yt(t):t instanceof Y?this.Mt(t):t instanceof B?this.wt(t):t instanceof _?this.gt(t):t instanceof k&&this.vt(t),this}getAsset(){return this.ft}listExtensionsUsed(){return Array.from(this.dt)}listExtensionsRequired(){return this.listExtensionsUsed().filter(t=>t.isRequired())}St(t){return this.dt.add(t),this}It(t){return this.dt.delete(t),this}bt(t){return this.addGraphChild(this.scenes,this.graph.link("scene",this,t))}listScenes(){return this.scenes.map(t=>t.getChild())}At(t){return this.addGraphChild(this.nodes,this.graph.link("node",this,t))}listNodes(){return this.nodes.map(t=>t.getChild())}xt(t){return this.addGraphChild(this.cameras,this.graph.link("camera",this,t))}listCameras(){return this.cameras.map(t=>t.getChild())}Et(t){return this.addGraphChild(this.skins,this.graph.link("skin",this,t))}listSkins(){return this.skins.map(t=>t.getChild())}Tt(t){return this.addGraphChild(this.meshes,this.graph.link("mesh",this,t))}listMeshes(){return this.meshes.map(t=>t.getChild())}yt(t){return this.addGraphChild(this.materials,this.graph.link("material",this,t))}listMaterials(){return this.materials.map(t=>t.getChild())}Mt(t){return this.addGraphChild(this.textures,this.graph.link("texture",this,t))}listTextures(){return this.textures.map(t=>t.getChild())}wt(t){return this.addGraphChild(this.animations,this.graph.link("animation",this,t))}listAnimations(){return this.animations.map(t=>t.getChild())}gt(t){return this.addGraphChild(this.accessors,this.graph.link("accessor",this,t))}listAccessors(){return this.accessors.map(t=>t.getChild())}vt(t){return this.addGraphChild(this.buffers,this.graph.link("buffer",this,t))}listBuffers(){return this.buffers.map(t=>t.getChild())}}c([d],X.prototype,"accessors",void 0),c([d],X.prototype,"animations",void 0),c([d],X.prototype,"buffers",void 0),c([d],X.prototype,"cameras",void 0),c([d],X.prototype,"materials",void 0),c([d],X.prototype,"meshes",void 0),c([d],X.prototype,"nodes",void 0),c([d],X.prototype,"scenes",void 0),c([d],X.prototype,"skins",void 0),c([d],X.prototype,"textures",void 0);class K{constructor(){this.Rt=new j,this.Ct=new X(this.Rt),this.Nt=A.DEFAULT_INSTANCE}getRoot(){return this.Ct}getGraph(){return this.Rt}getLogger(){return this.Nt}setLogger(t){return this.Nt=t,this}clone(){return(new K).merge(this)}merge(t){const s={};for(const e of t.getRoot().listExtensionsUsed()){const t=this.createExtension(e.constructor);e.isRequired()&&t.setRequired(!0),s[t.extensionName]=t}const e=new Set,i=new Map;e.add(t.Ct),i.set(t.Ct,this.Ct);for(const r of t.Rt.getLinks())for(const t of[r.getParent(),r.getChild()]){if(e.has(t))continue;let r;if(t.propertyType===u.TEXTURE_INFO)r=t;else{const e=t.constructor;r=t instanceof U?new e(this.Rt,s[t.extensionName]):new e(this.Rt)}i.set(t,r),e.add(t)}const r=t=>i.get(t);for(const t of e)i.get(t).copy(t,r);return this}async transform(...t){for(const s of t)await s(this);return this}createExtension(t){return this.getRoot().listExtensionsUsed().find(s=>s.extensionName===t.EXTENSION_NAME)||new t(this)}createScene(t=""){const s=new q(this.Rt,t);return this.Ct.bt(s),s}createNode(t=""){const s=new J(this.Rt,t);return this.Ct.At(s),s}createCamera(t=""){const s=new P(this.Rt,t);return this.Ct.xt(s),s}createSkin(t=""){const s=new H(this.Rt,t);return this.Ct.Et(s),s}createMesh(t=""){const s=new V(this.Rt,t);return this.Ct.Tt(s),s}createPrimitive(){return new $(this.Rt)}createPrimitiveTarget(t=""){return new W(this.Rt,t)}createMaterial(t=""){const s=new z(this.Rt,t);return this.Ct.yt(s),s}createTexture(t=""){const s=new Y(this.Rt,t);return this.Ct.Mt(s),s}createAnimation(t=""){const s=new B(this.Rt,t);return this.Ct.wt(s),s}createAnimationChannel(t=""){return new L(this.Rt,t)}createAnimationSampler(t=""){return new O(this.Rt,t)}createAccessor(t="",s=null){s||(s=this.getRoot().listBuffers()[0]);const e=new _(this.Rt,t).setBuffer(s);return this.Ct.gt(e),e}createBuffer(t=""){const s=new k(this.Rt,t);return this.Ct.vt(s),s}}class Z{constructor(t){this.doc=t,this.prereadTypes=[],this.prewriteTypes=[],this.dependencies=[],this.required=!1,this.properties=new Set,t.getRoot().St(this)}dispose(){this.doc.getRoot().It(this);for(const t of this.properties)t.dispose()}isRequired(){return this.required}setRequired(t){return this.required=t,this}addExtensionProperty(t){return this.properties.add(t),this}removeExtensionProperty(t){return this.properties.delete(t),this}install(t,s){return this}preread(t,s){return this}prewrite(t,s){return this}}class Q{constructor(t){this.jsonDoc=t,this.buffers=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.textureInfos=new Map,this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[]}setTextureInfo(t,s){this.textureInfos.set(t,s),void 0!==s.texCoord&&t.setTexCoord(s.texCoord);const e=this.jsonDoc.json.textures[s.index];if(void 0===e.sampler)return;const i=this.jsonDoc.json.samplers[e.sampler];void 0!==i.magFilter&&t.setMagFilter(i.magFilter),void 0!==i.minFilter&&t.setMinFilter(i.minFilter),void 0!==i.wrapS&&t.setWrapS(i.wrapS),void 0!==i.wrapT&&t.setWrapT(i.wrapT)}}const tt={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},st={logger:A.DEFAULT_INSTANCE,extensions:[],dependencies:{}};class et{static read(t,s=st){const{json:i}=t,r=new K;this.validate(t,s);const o=new Q(t),c=t.json.asset,a=r.getRoot().getAsset();c.copyright&&(a.copyright=c.copyright),c.extras&&(a.extras=c.extras),c.generator&&(a.generator=c.generator),c.minVersion&&(a.minVersion=c.minVersion);const l=i.extensionsUsed||[],f=i.extensionsRequired||[];for(const t of s.extensions)if(l.includes(t.EXTENSION_NAME)){const e=r.createExtension(t).setRequired(f.includes(t.EXTENSION_NAME));for(const t of e.dependencies)e.install(t,s.dependencies[t])}o.buffers=(i.buffers||[]).map(t=>{const s=r.createBuffer(t.name);return t.extras&&s.setExtras(t.extras),t.uri&&0!==t.uri.indexOf("__")&&s.setURI(t.uri),s}),o.bufferViewBuffers=(i.bufferViews||[]).map(t=>o.buffers[t.buffer]),o.accessors=(i.accessors||[]).map(s=>{const e=r.createAccessor(s.name,o.bufferViewBuffers[s.bufferView]).setType(s.type);if(s.extras&&e.setExtras(s.extras),void 0!==s.normalized&&e.setNormalized(s.normalized),void 0===s.bufferView&&!s.sparse)return e;let i;return i=void 0!==s.sparse?function(t,s){const e=tt[t.componentType],i=_.getElementSize(t.type);let r;r=void 0!==t.bufferView?it(t,s).slice():new e(t.count*i);const n=t.sparse.count,h={...t,...t.sparse.indices,count:n,type:"SCALAR"},o={...t,...t.sparse.values,count:n},u=it(h,s),c=it(o,s);for(let t=0;t<h.count;t++)for(let s=0;s<i;s++)r[u[t]*i+s]=c[t*i+s];return r}(s,t):it(s,t).slice(),e.setArray(i),e});const d=i.images||[],p=i.textures||[];r.getRoot().listExtensionsUsed().filter(t=>t.prereadTypes.includes(u.TEXTURE)).forEach(t=>t.preread(o,u.TEXTURE)),o.textures=d.map(s=>{const e=r.createTexture(s.name);if(s.extras&&e.setExtras(s.extras),void 0!==s.bufferView){const r=i.bufferViews[s.bufferView],n=t.json.buffers[r.buffer],h=r.byteOffset||0,o=(n.uri?t.resources[n.uri]:t.resources["@glb.bin"]).slice(h,h+r.byteLength);e.setImage(o)}else void 0!==s.uri&&(e.setImage(t.resources[s.uri]),0!==s.uri.indexOf("__")&&e.setURI(s.uri));if(void 0!==s.mimeType)e.setMimeType(s.mimeType);else if(s.uri){const t=w.extension(s.uri);e.setMimeType(m.extensionToMimeType(t))}return e}),o.materials=(i.materials||[]).map(t=>{const s=r.createMaterial(t.name);t.extras&&s.setExtras(t.extras),void 0!==t.alphaMode&&s.setAlphaMode(t.alphaMode),void 0!==t.alphaCutoff&&s.setAlphaCutoff(t.alphaCutoff),void 0!==t.doubleSided&&s.setDoubleSided(t.doubleSided);const e=t.pbrMetallicRoughness||{};if(void 0!==e.baseColorFactor&&s.setBaseColorFactor(e.baseColorFactor),void 0!==t.emissiveFactor&&s.setEmissiveFactor(t.emissiveFactor),void 0!==e.metallicFactor&&s.setMetallicFactor(e.metallicFactor),void 0!==e.roughnessFactor&&s.setRoughnessFactor(e.roughnessFactor),void 0!==e.baseColorTexture){const t=e.baseColorTexture;s.setBaseColorTexture(o.textures[p[t.index].source]),o.setTextureInfo(s.getBaseColorTextureInfo(),t)}if(void 0!==t.emissiveTexture){const e=t.emissiveTexture;s.setEmissiveTexture(o.textures[p[e.index].source]),o.setTextureInfo(s.getEmissiveTextureInfo(),e)}if(void 0!==t.normalTexture){const e=t.normalTexture;s.setNormalTexture(o.textures[p[e.index].source]),o.setTextureInfo(s.getNormalTextureInfo(),e),void 0!==t.normalTexture.scale&&s.setNormalScale(t.normalTexture.scale)}if(void 0!==t.occlusionTexture){const e=t.occlusionTexture;s.setOcclusionTexture(o.textures[p[e.index].source]),o.setTextureInfo(s.getOcclusionTextureInfo(),e),void 0!==t.occlusionTexture.strength&&s.setOcclusionStrength(t.occlusionTexture.strength)}if(void 0!==e.metallicRoughnessTexture){const t=e.metallicRoughnessTexture;s.setMetallicRoughnessTexture(o.textures[p[t.index].source]),o.setTextureInfo(s.getMetallicRoughnessTextureInfo(),t)}return s});const g=i.meshes||[];r.getRoot().listExtensionsUsed().filter(t=>t.prereadTypes.includes(u.PRIMITIVE)).forEach(t=>t.preread(o,u.PRIMITIVE)),o.meshes=g.map(t=>{const s=r.createMesh(t.name);return t.extras&&s.setExtras(t.extras),void 0!==t.weights&&s.setWeights(t.weights),(t.primitives||[]).forEach(e=>{const i=r.createPrimitive();e.extras&&i.setExtras(e.extras),void 0!==e.material&&i.setMaterial(o.materials[e.material]),void 0!==e.mode&&i.setMode(e.mode);for(const[t,s]of Object.entries(e.attributes||{}))i.setAttribute(t,o.accessors[s]);void 0!==e.indices&&i.setIndices(o.accessors[e.indices]);const n=t.extras&&t.extras.targetNames||[];(e.targets||[]).forEach((t,s)=>{const e=n[s]||s.toString(),h=r.createPrimitiveTarget(e);for(const[s,e]of Object.entries(t))h.setAttribute(s,o.accessors[e]);i.addTarget(h)}),s.addPrimitive(i)}),s}),o.cameras=(i.cameras||[]).map(t=>{const s=r.createCamera(t.name).setType(t.type);return t.extras&&s.setExtras(t.extras),"perspective"===t.type?s.setZNear(t.perspective.znear).setZFar(t.perspective.zfar).setYFov(t.perspective.yfov).setAspectRatio(t.perspective.aspectRatio):s.setZNear(t.orthographic.znear).setZFar(t.orthographic.zfar).setXMag(t.orthographic.xmag).setYMag(t.orthographic.ymag),s});const v=i.nodes||[];return o.nodes=v.map(t=>{const s=r.createNode(t.name);if(t.extras&&s.setExtras(t.extras),void 0!==t.translation&&s.setTranslation(t.translation),void 0!==t.rotation&&s.setRotation(t.rotation),void 0!==t.scale&&s.setScale(t.scale),void 0!==t.matrix){const i=[0,0,0],r=[0,0,0,1],o=[1,1,1];!function(t,s,i,r){let o=h([t[0],t[1],t[2]]);const u=h([t[4],t[5],t[6]]),c=h([t[8],t[9],t[10]]);n(t)<0&&(o=-o),i[0]=t[12],i[1]=t[13],i[2]=t[14];const a=t.slice(),l=1/o,f=1/u,d=1/c;a[0]*=l,a[1]*=l,a[2]*=l,a[4]*=f,a[5]*=f,a[6]*=f,a[8]*=d,a[9]*=d,a[10]*=d,e(s,a),r[0]=o,r[1]=u,r[2]=c}(t.matrix,r,i,o),s.setTranslation(i),s.setRotation(r),s.setScale(o)}return void 0!==t.weights&&s.setWeights(t.weights),s}),o.skins=(i.skins||[]).map(t=>{const s=r.createSkin(t.name);t.extras&&s.setExtras(t.extras),void 0!==t.inverseBindMatrices&&s.setInverseBindMatrices(o.accessors[t.inverseBindMatrices]),void 0!==t.skeleton&&s.setSkeleton(o.nodes[t.skeleton]);for(const e of t.joints)s.addJoint(o.nodes[e]);return s}),v.map((t,s)=>{const e=o.nodes[s];(t.children||[]).forEach(t=>e.addChild(o.nodes[t])),void 0!==t.mesh&&e.setMesh(o.meshes[t.mesh]),void 0!==t.camera&&e.setCamera(o.cameras[t.camera]),void 0!==t.skin&&e.setSkin(o.skins[t.skin])}),o.animations=(i.animations||[]).map(t=>{const s=r.createAnimation(t.name);t.extras&&s.setExtras(t.extras);const e=(t.samplers||[]).map(t=>{const e=r.createAnimationSampler().setInput(o.accessors[t.input]).setOutput(o.accessors[t.output]).setInterpolation(t.interpolation||"LINEAR");return t.extras&&e.setExtras(t.extras),s.addSampler(e),e});return(t.channels||[]).forEach(t=>{const i=r.createAnimationChannel().setSampler(e[t.sampler]).setTargetNode(o.nodes[t.target.node]).setTargetPath(t.target.path);t.extras&&i.setExtras(t.extras),s.addChannel(i)}),s}),o.scenes=(i.scenes||[]).map(t=>{const s=r.createScene(t.name);return t.extras&&s.setExtras(t.extras),(t.nodes||[]).map(t=>o.nodes[t]).forEach(t=>s.addChild(t)),s}),r.getRoot().listExtensionsUsed().forEach(t=>t.read(o)),r}static validate(t,s){const e=t.json;if("2.0"!==e.asset.version)throw new Error(`Unsupported glTF version, "${e.asset.version}".`);if(e.extensionsRequired)for(const t of e.extensionsRequired)if(!s.extensions.find(s=>s.EXTENSION_NAME===t))throw new Error(`Missing required extension, "${t}".`);if(e.extensionsUsed)for(const t of e.extensionsUsed)s.extensions.find(s=>s.EXTENSION_NAME===t)||s.logger.warn(`Missing optional extension, "${t}".`)}}function it(t,s){const e=s.json.bufferViews[t.bufferView],i=s.json.buffers[e.buffer],r=i.uri?s.resources[i.uri]:s.resources["@glb.bin"],n=tt[t.componentType],h=_.getElementSize(t.type);if(void 0!==e.byteStride&&e.byteStride!==h*n.BYTES_PER_ELEMENT)return function(t,s){const e=s.json.bufferViews[t.bufferView],i=s.json.buffers[e.buffer],r=i.uri?s.resources[i.uri]:s.resources["@glb.bin"],n=tt[t.componentType],h=_.getElementSize(t.type),o=n.BYTES_PER_ELEMENT,u=t.byteOffset||0,c=new n(t.count*h),a=new DataView(r,e.byteOffset,e.byteLength),l=e.byteStride;for(let s=0;s<t.count;s++)for(let e=0;e<h;e++){const i=u+s*l+e*o;let r;switch(t.componentType){case 5126:r=a.getFloat32(i,!0);break;case 5125:r=a.getUint32(i,!0);break;case 5123:r=a.getUint16(i,!0);break;case 5121:r=a.getUint8(i);break;case 5122:r=a.getInt16(i,!0);break;case 5120:r=a.getInt8(i);break;default:throw new Error(`Unexpected componentType "${t.componentType}".`)}c[s*h+e]=r}return c}(t,s);const o=(e.byteOffset||0)+(t.byteOffset||0);switch(t.componentType){case 5126:return new Float32Array(r,o,t.count*h);case 5125:return new Uint32Array(r,o,t.count*h);case 5123:return new Uint16Array(r,o,t.count*h);case 5121:return new Uint8Array(r,o,t.count*h);case 5122:return new Int16Array(r,o,t.count*h);case 5120:return new Int8Array(r,o,t.count*h);default:throw new Error(`Unexpected componentType "${t.componentType}".`)}}class rt{constructor(t,s){this.jsonDoc=t,this.options=s,this.accessorIndexMap=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.imageBufferViews=[],this.otherBufferViews=new Map,this.otherBufferViewsIndexMap=new Map,this.extensionData={}}createTextureInfoDef(t,s){const e={magFilter:s.getMagFilter()||void 0,minFilter:s.getMinFilter()||void 0,wrapS:s.getWrapS(),wrapT:s.getWrapT()},i=JSON.stringify(e);this.samplerDefIndexMap.has(i)||(this.samplerDefIndexMap.set(i,this.jsonDoc.json.samplers.length),this.jsonDoc.json.samplers.push(e));const r={source:this.imageIndexMap.get(t),sampler:this.samplerDefIndexMap.get(i)},n=JSON.stringify(r);this.textureDefIndexMap.has(n)||(this.textureDefIndexMap.set(n,this.jsonDoc.json.textures.length),this.jsonDoc.json.textures.push(r));const h={index:this.textureDefIndexMap.get(n),texCoord:s.getTexCoord()};return this.textureInfoDefMap.set(s,h),h}createPropertyDef(t){const s={};return t.getName()&&(s.name=t.getName()),Object.keys(t.getExtras()).length>0&&(s.extras=t.getExtras()),s}createAccessorDef(t){const s=this.createPropertyDef(t);return s.type=t.getType(),s.componentType=t.getComponentType(),s.count=t.getCount(),t.getMax(s.max=[]),t.getMin(s.min=[]),s.normalized=t.getNormalized(),s}createImageData(t,s,e){if(this.options.isGLB)this.imageBufferViews.push(s),t.bufferView=this.jsonDoc.json.bufferViews.length,this.jsonDoc.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:s.byteLength});else{const i=m.mimeTypeToExtension(e.getMimeType());t.uri=this.imageURIGenerator.createURI(e,i),this.jsonDoc.resources[t.uri]=s}}}class nt{constructor(t,s){this.multiple=t,this.basename=s,this.counter=1}createURI(t,s){return t.getURI()?t.getURI():this.multiple?`${this.basename}_${this.counter++}.${s}`:`${this.basename}.${s}`}}const ht={logger:A.DEFAULT_INSTANCE,basename:"",isGLB:!0,dependencies:{}};class ot{static write(t,s=ht){const e=t.getRoot(),i={json:{asset:e.getAsset()},resources:{}},r=s.logger||A.DEFAULT_INSTANCE,n=i.json;n.asset.generator="glTF-Transform v0.8.1";const h=new rt(i,s),o=e.listBuffers().length,c=e.listTextures().length;h.bufferURIGenerator=new nt(o>1,s.basename),h.imageURIGenerator=new nt(c>1,s.basename),h.logger=t.getLogger();for(const e of t.getRoot().listExtensionsUsed())for(const t of e.dependencies)e.install(t,s.dependencies[t]);function a(t,s,e,i){const r=[];let o=0;for(const s of t){const t=h.createAccessorDef(s);t.bufferView=n.bufferViews.length;const e=p.pad(s.getArray().buffer);t.byteOffset=o,o+=e.byteLength,r.push(e),h.accessorIndexMap.set(s,n.accessors.length),n.accessors.push(t)}const u={buffer:s,byteOffset:e,byteLength:p.concat(r).byteLength};return i&&(u.target=i),n.bufferViews.push(u),{buffers:r,byteLength:o}}function l(t,s,e){const i=t[0].getCount();let r=0;for(const s of t){const t=h.createAccessorDef(s);t.bufferView=n.bufferViews.length,t.byteOffset=r;const e=s.getElementSize(),i=s.getComponentSize();r+=p.padNumber(e*i),h.accessorIndexMap.set(s,n.accessors.length),n.accessors.push(t)}const o=i*r,u=new ArrayBuffer(o),c=new DataView(u);for(let s=0;s<i;s++){let e=0;for(const i of t){const t=i.getElementSize(),n=i.getComponentSize(),h=i.getComponentType(),o=i.getArray();for(let i=0;i<t;i++){const u=s*r+e+i*n,a=o[s*t+i];switch(h){case 5126:c.setFloat32(u,a,!0);break;case 5120:c.setInt8(u,a);break;case 5122:c.setInt16(u,a,!0);break;case 5121:c.setUint8(u,a);break;case 5123:c.setUint16(u,a,!0);break;case 5125:c.setUint32(u,a,!0);break;default:throw new Error("Unexpected component type: "+h)}}e+=p.padNumber(t*n)}}return n.bufferViews.push({buffer:s,byteOffset:e,byteLength:o,byteStride:r,target:34962}),{byteLength:o,buffers:[u]}}const f=new Map;for(const s of t.getGraph().getLinks()){if(s.getParent()===e)continue;const t=s.getChild();if(t instanceof _){const e=f.get(t)||[];e.push(s),f.set(t,e)}}return n.accessors=[],n.bufferViews=[],n.samplers=[],n.textures=[],n.images=e.listTextures().map((t,s)=>{const e=h.createPropertyDef(t);return t.getMimeType()&&(e.mimeType=t.getMimeType()),t.getImage()&&h.createImageData(e,t.getImage(),t),h.imageIndexMap.set(t,s),e}),t.getRoot().listExtensionsUsed().filter(t=>t.prewriteTypes.includes(u.ACCESSOR)).forEach(t=>t.prewrite(h,u.ACCESSOR)),n.buffers=[],e.listBuffers().forEach(t=>{const e=h.createPropertyDef(t),r=new Map,o=new Set,u=new Set,c=new Set,d=t.listParents().filter(t=>!(t instanceof X));for(const t of d){if(!(t instanceof _))throw new Error("Unimplemented buffer reference: "+t);if(h.accessorIndexMap.has(t))continue;let s=!1,e=!1,i=!1,n=!1;const a=f.get(t)||[];for(const t of a)t instanceof F?s=!0:t instanceof D?e=!0:"inverseBindMatrices"===t.getName()?i=!0:n=!0;if(s||e||i||n||(n=!0),!s||e||i||n)if(!e||s||i||n)if(!i||s||e||n){if(!n||s||e||i)throw new Error("Attribute, index, or IBM accessors must be used only for that purpose.");c.add(t)}else u.add(t);else o.add(t);else{const s=a[0].getParent(),e=r.get(s)||new Set;e.add(t),r.set(s,e)}}const g=[],w=n.buffers.length;let m,v=0;if(o.size){const t=a(Array.from(o),w,v,34963);v+=t.byteLength,g.push(...t.buffers)}for(const t of Array.from(r.values()))if(t.size){const s=l(Array.from(t),w,v);v+=s.byteLength,g.push(...s.buffers)}if(u.size){const t=a(Array.from(u),w,v);v+=t.byteLength,g.push(...t.buffers)}if(c.size){const t=a(Array.from(c),w,v);v+=t.byteLength,g.push(...t.buffers)}if(h.imageBufferViews.length)for(let t=0;t<h.imageBufferViews.length;t++)n.bufferViews[n.images[t].bufferView].byteOffset=v,v+=h.imageBufferViews[t].byteLength,g.push(h.imageBufferViews[t]);if(h.otherBufferViews.has(t))for(const s of h.otherBufferViews.get(t))n.bufferViews.push({buffer:w,byteOffset:v,byteLength:s.byteLength}),h.otherBufferViewsIndexMap.set(s,n.bufferViews.length-1),v+=s.byteLength,g.push(s);v?(s.isGLB?m="@glb.bin":(m=h.bufferURIGenerator.createURI(t,"bin"),e.uri=m),e.byteLength=v,i.resources[m]=p.concat(g),n.buffers.push(e)):h.logger.warn(`@gltf-transform/core: Skipping empty buffer, "${t.getName()}".`)}),e.listAccessors().find(t=>!t.getBuffer())&&r.warn("Skipped writing one or more Accessors: no Buffer assigned."),n.materials=e.listMaterials().map((t,s)=>{const e=h.createPropertyDef(t);if(e.alphaMode=t.getAlphaMode(),"MASK"===t.getAlphaMode()&&(e.alphaCutoff=t.getAlphaCutoff()),e.doubleSided=t.getDoubleSided(),e.pbrMetallicRoughness={},e.pbrMetallicRoughness.baseColorFactor=t.getBaseColorFactor(),e.emissiveFactor=t.getEmissiveFactor(),e.pbrMetallicRoughness.roughnessFactor=t.getRoughnessFactor(),e.pbrMetallicRoughness.metallicFactor=t.getMetallicFactor(),t.getBaseColorTexture()){const s=t.getBaseColorTexture(),i=t.getBaseColorTextureInfo();e.pbrMetallicRoughness.baseColorTexture=h.createTextureInfoDef(s,i)}if(t.getEmissiveTexture()){const s=t.getEmissiveTexture(),i=t.getEmissiveTextureInfo();e.emissiveTexture=h.createTextureInfoDef(s,i)}if(t.getNormalTexture()){const s=t.getNormalTexture(),i=t.getNormalTextureInfo(),r=h.createTextureInfoDef(s,i);1!==t.getNormalScale()&&(r.scale=t.getNormalScale()),e.normalTexture=r}if(t.getOcclusionTexture()){const s=t.getOcclusionTexture(),i=t.getOcclusionTextureInfo(),r=h.createTextureInfoDef(s,i);1!==t.getOcclusionStrength()&&(r.strength=t.getOcclusionStrength()),e.occlusionTexture=r}if(t.getMetallicRoughnessTexture()){const s=t.getMetallicRoughnessTexture(),i=t.getMetallicRoughnessTextureInfo();e.pbrMetallicRoughness.metallicRoughnessTexture=h.createTextureInfoDef(s,i)}return h.materialIndexMap.set(t,s),e}),n.meshes=e.listMeshes().map((t,s)=>{const e=h.createPropertyDef(t);let i;return e.primitives=t.listPrimitives().map(t=>{const s={attributes:{}};s.mode=t.getMode(),t.getMaterial()&&(s.material=h.materialIndexMap.get(t.getMaterial())),Object.keys(t.getExtras()).length&&(s.extras=t.getExtras()),t.getIndices()&&(s.indices=h.accessorIndexMap.get(t.getIndices()));for(const e of t.listSemantics())s.attributes[e]=h.accessorIndexMap.get(t.getAttribute(e));for(const e of t.listTargets()){const t={};for(const s of e.listSemantics())t[s]=h.accessorIndexMap.get(e.getAttribute(s));s.targets=s.targets||[],s.targets.push(t)}return t.listTargets().length&&!i&&(i=t.listTargets().map(t=>t.getName())),s}),t.getWeights().length&&(e.weights=t.getWeights()),i&&(e.extras=e.extras||{},e.extras.targetNames=i),h.meshIndexMap.set(t,s),e}),n.cameras=e.listCameras().map((t,s)=>{const e=h.createPropertyDef(t);return e.type=t.getType(),"perspective"===e.type?e.perspective={znear:t.getZNear(),zfar:t.getZFar(),yfov:t.getYFov(),aspectRatio:t.getAspectRatio()}:e.orthographic={znear:t.getZNear(),zfar:t.getZFar(),xmag:t.getXMag(),ymag:t.getYMag()},h.cameraIndexMap.set(t,s),e}),n.nodes=e.listNodes().map((t,s)=>{const e=h.createPropertyDef(t);return e.translation=t.getTranslation(),e.rotation=t.getRotation(),e.scale=t.getScale(),t.getWeights().length&&(e.weights=t.getWeights()),h.nodeIndexMap.set(t,s),e}),n.skins=e.listSkins().map((t,s)=>{const e=h.createPropertyDef(t);return t.getInverseBindMatrices()&&(e.inverseBindMatrices=h.accessorIndexMap.get(t.getInverseBindMatrices())),t.getSkeleton()&&(e.skeleton=h.nodeIndexMap.get(t.getSkeleton())),e.joints=t.listJoints().map(t=>h.nodeIndexMap.get(t)),h.skinIndexMap.set(t,s),e}),e.listNodes().forEach((t,s)=>{const e=n.nodes[s];t.getMesh()&&(e.mesh=h.meshIndexMap.get(t.getMesh())),t.getCamera()&&(e.camera=h.cameraIndexMap.get(t.getCamera())),t.getSkin()&&(e.skin=h.skinIndexMap.get(t.getSkin())),t.listChildren().length>0&&(e.children=t.listChildren().map(t=>h.nodeIndexMap.get(t)))}),n.animations=e.listAnimations().map(t=>{const s=h.createPropertyDef(t),e=new Map;return s.samplers=t.listSamplers().map((t,s)=>{const i=h.createPropertyDef(t);return i.input=h.accessorIndexMap.get(t.getInput()),i.output=h.accessorIndexMap.get(t.getOutput()),i.interpolation=t.getInterpolation(),e.set(t,s),i}),s.channels=t.listChannels().map(t=>{const s=h.createPropertyDef(t);return s.sampler=e.get(t.getSampler()),s.target={node:h.nodeIndexMap.get(t.getTargetNode()),path:t.getTargetPath()},s}),s}),n.scenes=e.listScenes().map(t=>{const s=h.createPropertyDef(t);return s.nodes=t.listChildren().map(t=>h.nodeIndexMap.get(t)),s}),n.extensionsUsed=e.listExtensionsUsed().map(t=>t.extensionName),n.extensionsRequired=e.listExtensionsRequired().map(t=>t.extensionName),e.listExtensionsUsed().forEach(t=>t.write(h)),function(t){const s=[];for(const e in t){const i=t[e];Array.isArray(i)&&0===i.length?s.push(e):null!==i&&""!==i||s.push(i)}for(const e of s)delete t[e]}(n),i}}class ut{constructor(){this.Nt=A.DEFAULT_INSTANCE,this.dt=[],this._t={}}setLogger(t){return this.Nt=t,this}registerExtensions(t){return this.dt.push(...t),this}registerDependencies(t){return Object.assign(this._t,t),this}readJSON(t){return et.read(t,{extensions:this.dt,dependencies:this._t,logger:this.Nt})}writeJSON(t,s){if(s.isGLB&&1!==t.getRoot().listBuffers().length)throw new Error("GLB must have exactly 1 buffer.");return s.dependencies={...this._t,...s.dependencies},ot.write(t,s)}binaryToJSON(t){const s=new Uint32Array(t,0,3);if(1179937895!==s[0])throw new Error("Invalid glTF asset.");if(2!==s[1])throw new Error(`Unsupported glTF binary version, "${s[1]}".`);const e=new Uint32Array(t,12,2),i=e[0],r=new Uint32Array(t,20+i,2);if(1313821514!==e[1]||5130562!==r[1])throw new Error("Unexpected GLB layout.");const n=p.decodeText(t.slice(20,20+i)),h=20+i+8;return{json:JSON.parse(n),resources:{"@glb.bin":t.slice(h,h+r[0])}}}readBinary(t){return this.readJSON(this.binaryToJSON(t))}writeBinary(t){const{json:s,resources:e}=this.writeJSON(t,{basename:"",isGLB:!0,logger:this.Nt,dependencies:this._t}),i=JSON.stringify(s),r=p.pad(p.encodeText(i),32),n=new Uint32Array([r.byteLength,1313821514]).buffer,h=p.concat([n,r]),o=p.pad(Object.values(e)[0]||new ArrayBuffer(0),0),u=new Uint32Array([o.byteLength,5130562]).buffer,c=p.concat([u,o]),a=new Uint32Array([1179937895,2,12+h.byteLength+c.byteLength]).buffer;return p.concat([a,h,c])}}class ct extends ut{constructor(){super(),this.lastReadBytes=0,this.lastWriteBytes=0,this.Bt=require("fs"),this.Lt=require("path")}read(t){const s=this.readAsJSON(t);return et.read(s,{extensions:this.dt,dependencies:this._t,logger:this.Nt})}readAsJSON(t){return t.match(/\.glb$/)||t.match(/^data:application\/octet-stream;/)?this.Ot(t):this.kt(t)}write(t,s){t.match(/\.glb$/)?this.Pt(t,s):this.Ut(t,s)}Ot(t){const s=this.Bt.readFileSync(t),e=p.trim(s);return this.lastReadBytes=e.byteLength,this.binaryToJSON(e)}kt(t){this.lastReadBytes=0;const s=this.Lt.dirname(t),e=this.Bt.readFileSync(t,"utf8");this.lastReadBytes+=e.length;const i={json:JSON.parse(e),resources:{}};return[...i.json.images||[],...i.json.buffers||[]].forEach(t=>{if(t.uri)if(t.uri.match(/data:/)){const s=`__${S()}.${w.extension(t.uri)}`;i.resources[s]=p.createBufferFromDataURI(t.uri),t.uri=s}else{const e=this.Lt.resolve(s,t.uri);i.resources[t.uri]=p.trim(this.Bt.readFileSync(e)),this.lastReadBytes+=i.resources[t.uri].byteLength}}),i}Ut(t,s){this.lastWriteBytes=0;const{json:e,resources:i}=ot.write(s,{basename:w.basename(t),isGLB:!1,logger:this.Nt,dependencies:this._t}),{Bt:r,Lt:n}=this,h=n.dirname(t),o=JSON.stringify(e,null,2);this.lastWriteBytes+=o.length,r.writeFileSync(t,o),Object.keys(i).forEach(t=>{const s=Buffer.from(i[t]);r.writeFileSync(n.join(h,t),s),this.lastWriteBytes+=s.byteLength})}Pt(t,s){const e=Buffer.from(this.writeBinary(s));this.Bt.writeFileSync(t,e),this.lastWriteBytes=e.byteLength}}const at={};class lt extends ut{constructor(t=at){super(),this.Ft=t}read(t){return this.readAsJSON(t).then(t=>this.readJSON(t))}readAsJSON(t){return t.match(/\.glb$/)||t.match(/^data:application\/octet-stream;/)?this.Ot(t):this.kt(t)}kt(t){const s={json:{},resources:{}};return fetch(t,this.Ft).then(t=>t.json()).then(t=>{s.json=t;const e=[...t.images||[],...t.buffers||[]].map(t=>{if(t.uri)return fetch(t.uri,this.Ft).then(t=>t.arrayBuffer()).then(e=>{s.resources[t.uri]=e})});return Promise.all(e).then(()=>s)})}Ot(t){return fetch(t,this.Ft).then(t=>t.arrayBuffer()).then(t=>this.binaryToJSON(t))}}export{_ as Accessor,B as Animation,L as AnimationChannel,O as AnimationSampler,k as Buffer,p as BufferUtils,I as COPY_IDENTITY,P as Camera,g as ColorUtils,K as Document,Z as Extension,U as ExtensionProperty,w as FileUtils,o as GLB_BUFFER,l as Graph,f as GraphChild,d as GraphChildList,m as ImageUtils,a as Link,A as Logger,z as Material,T as MathUtils,V as Mesh,J as Node,ct as NodeIO,$ as Primitive,W as PrimitiveTarget,R as Property,u as PropertyType,Q as ReaderContext,X as Root,q as Scene,H as Skin,Y as Texture,G as TextureInfo,lt as WebIO,rt as WriterContext,S as uuid};
//# sourceMappingURL=core.modern.js.map
{
"name": "@gltf-transform/core",
"version": "0.8.0",
"version": "0.8.1",
"repository": "github:donmccurdy/glTF-Transform",

@@ -42,3 +42,3 @@ "description": "glTF 2.0 SDK for JavaScript, TypeScript, and Node.js",

},
"gitHead": "21c57ed43e83a4c47b8e48541fc7364ea1a04b5f"
"gitHead": "0a4bd744cedbfd87c0dd46f4c38337b5951da97c"
}

@@ -268,3 +268,4 @@ import { determinant, getRotation } from 'gl-matrix/mat4'

meshDef.primitives.forEach((primitiveDef) => {
const primitiveDefs = meshDef.primitives || [];
primitiveDefs.forEach((primitiveDef) => {
const primitive = doc.createPrimitive();

@@ -271,0 +272,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc