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.4.0-alpha.2 to 0.4.0-alpha.3

2

dist/core.modern.js

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

import{getTranslation as t,getRotation as e,getScaling as s}from"gl-matrix/mat4";function r(t,e,s,r){var i,n=arguments.length,h=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,s,r);else for(var o=t.length-1;o>=0;o--)(i=t[o])&&(h=(n<3?i(h):n>3?i(e,s,h):i(e,s))||h);return n>3&&h&&Object.defineProperty(e,s,h),h}var i;!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",t.TEXTURE_SAMPLER="TextureSampler"}(i||(i={}));class n{constructor(t,e,s){if(this.t=t,this.s=e,this.i=s,this.h=!1,this.o=[],!e.canLink(s))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 h{constructor(){this.u=[]}getLinks(){return this.u}listParents(t){return this.u.filter(e=>e.getChild()===t).map(t=>t.getParent())}listChildren(t){return this.u.filter(e=>e.getParent()===t).map(t=>t.getChild())}disconnectChildren(t){return this.u.filter(e=>e.getParent()===t).forEach(t=>t.dispose()),this}disconnectParents(t,e){let s=this.u.filter(e=>e.getChild()===t);return e&&(s=s.filter(t=>e(t.getParent()))),s.forEach(t=>t.dispose()),this}link(t,e,s){if(!s)return null;const r=new n(t,e,s);return this.registerLink(r),r}registerLink(t){return this.u.push(t),t.onDispose(()=>this.unlink(t)),t}unlink(t){return this.u=this.u.filter(e=>e!==t),this}}function o(t,e){Object.defineProperty(t,e,{get:function(){return this["__"+e]},set:function(t){const s=this["__"+e];s&&!Array.isArray(s)&&s.dispose(),t&&!Array.isArray(t)&&t.onDispose(()=>{this["__"+e]=null}),this["__"+e]=t},enumerable:!0})}function u(t,e){}class c extends class{constructor(t){this.h=!1,this.l=t}canLink(t){return this.l===t.l}isDisposed(){return this.h}dispose(){this.l.disconnectChildren(this),this.l.disconnectParents(this),this.h=!0}detach(){return this.l.disconnectParents(this),this}swap(t,e){return this.l.getLinks().filter(e=>e.getParent()===this&&e.getChild()===t).forEach(t=>t.setChild(e)),this}addGraphChild(t,e){return t.push(e),e.onDispose(()=>{const s=t.filter(t=>t!==e);t.length=0,t.push(...s)}),this}removeGraphChild(t,e){return t.filter(t=>t.getChild()===e).forEach(t=>t.dispose()),this}listGraphParents(){return this.l.listParents(this)}}{constructor(t,e=""){super(t),this.t="",this.g={},this.t=e}getName(){return this.t}setName(t){return this.t=t,this}getExtras(){return this.g}setExtras(t){return this.g=t,this}clone(){throw new Error("Not implemented.")}detach(){return this.l.disconnectParents(this,t=>"Root"!==t.propertyType),this}listParents(){return this.listGraphParents()}}class a extends c{constructor(){super(...arguments),this.extensions=[]}getExtension(t){const e=t.EXTENSION_NAME,s=this.extensions.find(t=>t.getChild().extensionName===e);return s?s.getChild():null}setExtension(t,e){const s=this.getExtension(t);return s&&this.removeGraphChild(this.extensions,s),e?(e.p(this),this.addGraphChild(this.extensions,this.l.link(e.extensionName,this,e))):this}listExtensions(){return this.extensions.map(t=>t.getChild())}}r([u],a.prototype,"extensions",void 0);class l extends a{constructor(){super(...arguments),this.propertyType=i.ACCESSOR,this.m=null,this.v="SCALAR",this.A=null,this.T=!1,this.M=d,this.S=d,this.buffer=null}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 e=this.getElementSize();this.getMin(t);for(let s=0;s<e;s++)t[s]=this.S(t[s]);return t}getMin(t){const e=this.getCount(),s=this.getElementSize();for(let e=0;e<s;e++)t[e]=Infinity;for(let r=0;r<e*s;r+=s)for(let e=0;e<s;e++){const s=this.m[r+e];Number.isFinite(s)&&(t[e]=Math.min(t[e],s))}return t}getMaxNormalized(t){const e=this.getElementSize();this.getMax(t);for(let s=0;s<e;s++)t[s]=this.S(t[s]);return t}getMax(t){const e=this.getCount(),s=this.getElementSize();for(let e=0;e<s;e++)t[e]=-Infinity;for(let r=0;r<e*s;r+=s)for(let e=0;e<s;e++){const s=this.m[r+e];Number.isFinite(s)&&(t[e]=Math.max(t[e],s))}return t}getCount(){return this.m.length/this.getElementSize()}getType(){return this.v}setType(t){return this.v=t,this}getElementSize(){return l.getElementSize(this.v)}getComponentSize(){return this.m.BYTES_PER_ELEMENT}getComponentType(){return this.A}getNormalized(){return this.T}setNormalized(t){return this.T=t,t?(this.S=t=>function(t,e){switch(e){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)}}(t,this.A),this.M=t=>function(t,e){switch(e){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)}}(t,this.A)):(this.S=d,this.M=d),this}getScalar(t){const e=this.getElementSize();return this.S(this.m[t*e])}setScalar(t,e){return this.m[t*this.getElementSize()]=this.M(e),this}getElement(t,e){const s=this.getElementSize();for(let r=0;r<s;r++)e[r]=this.S(this.m[t*s+r]);return e}setElement(t,e){const s=this.getElementSize();for(let r=0;r<s;r++)this.m[t*s+r]=this.M(e[r]);return this}getBuffer(){return this.buffer.getChild()}setBuffer(t){return this.buffer=this.l.link("buffer",this,t),this}getArray(){return this.m}setArray(t){return this.A=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.m=t,this}getByteLength(){return this.m.byteLength}}function d(t){return t}l.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT3:"MAT3",MAT4:"MAT4"},l.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},r([o],l.prototype,"buffer",void 0);class f extends a{constructor(){super(...arguments),this.propertyType=i.ANIMATION,this.channels=[],this.samplers=[]}addChannel(t){const e=this.l.link("channel",this,t);return this.addGraphChild(this.channels,e)}removeChannel(t){return this.removeGraphChild(this.channels,t)}listChannels(){return this.channels.map(t=>t.getChild())}addSampler(t){const e=this.l.link("sampler",this,t);return this.addGraphChild(this.samplers,e)}removeSampler(t){return this.removeGraphChild(this.samplers,t)}listSamplers(){return this.samplers.map(t=>t.getChild())}}r([u],f.prototype,"channels",void 0),r([u],f.prototype,"samplers",void 0);class g extends c{constructor(){super(...arguments),this.propertyType=i.ANIMATION_CHANNEL,this.N=null,this.targetNode=null,this.sampler=null}getTargetPath(){return this.N}setTargetPath(t){return this.N=t,this}getTargetNode(){return this.targetNode?this.targetNode.getChild():null}setTargetNode(t){return this.targetNode=this.l.link("target.node",this,t),this}getSampler(){return this.sampler?this.sampler.getChild():null}setSampler(t){return this.sampler=this.l.link("sampler",this,t),this}}r([o],g.prototype,"targetNode",void 0),r([o],g.prototype,"sampler",void 0);class p extends c{constructor(){super(...arguments),this.propertyType=i.ANIMATION_SAMPLER,this.R="LINEAR",this.input=null,this.output=null}getInterpolation(){return this.R}setInterpolation(t){return this.R=t,this}getInput(){return this.input?this.input.getChild():null}setInput(t){return this.input=this.l.link("input",this,t),this}getOutput(){return this.output?this.output.getChild():null}setOutput(t){return this.output=this.l.link("output",this,t),this}}r([o],p.prototype,"input",void 0),r([o],p.prototype,"output",void 0);class m extends a{constructor(){super(...arguments),this.propertyType=i.BUFFER}getURI(){return this.I}setURI(t){return this.I=t,this}}class w extends a{constructor(){super(...arguments),this.propertyType=i.CAMERA,this.v="perspective"}getType(){return this.v}setType(t){return this.v=t,this}getZNear(){return this.C}setZNear(t){return this.C=t,this}getZFar(){return this._}setZFar(t){return this._=t,this}getAspectRatio(){return this.B}setAspectRatio(t){return this.B=t,this}getYFov(){return this.U}setYFov(t){return this.U=t,this}getXMag(){return this.k}setXMag(t){return this.k=t,this}getYMag(){return this.L}setYMag(t){return this.L=t,this}}class v extends c{constructor(t,e){super(t),this.P=e,this.P.addExtensionProperty(this)}dispose(){this.P.removeExtensionProperty(this),super.dispose()}p(t){if(!this.parentTypes.includes(t.propertyType))throw new Error(`Parent "${t.propertyType}" invalid for child "${this.propertyType}".`)}}class x{static createBufferFromDataURI(t){if("undefined"==typeof Buffer){const e=atob(t.split(",")[1]),s=new Uint8Array(e.length);for(let t=0;t<e.length;t++)s[t]=e.charCodeAt(t);return s.buffer}{const e=t.split(",")[1],s=t.indexOf("base64")>=0;return this.trim(Buffer.from(e,s?"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:e,byteLength:s}=t;return t.buffer.slice(e,e+s)}static concat(t){let e=0;for(const s of t)e+=s.byteLength;const s=new Uint8Array(e);let r=0;for(const e of t)s.set(new Uint8Array(e),r),r+=e.byteLength;return s.buffer}static pad(t,e=0){const s=this.padNumber(t.byteLength);if(s!==t.byteLength){const r=new Uint8Array(s);if(r.set(new Uint8Array(t)),0!==e)for(let i=t.byteLength;i<s;i++)r[i]=e;return r.buffer}return t}static padNumber(t){return 4*Math.ceil(t/4)}static equals(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;const s=new DataView(t),r=new DataView(e);let i=t.byteLength;for(;i--;)if(s.getUint8(i)!==r.getUint8(i))return!1;return!0}}class A{static basename(t){return t.split(/[\\/]/).pop().split(/[.]/).shift()}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 T{static getSizeJPEG(t){let e,s;for(t=t.slice(4);t.length;){if(e=t.readUInt16BE(0),E(t,e),s=t[e+1],192===s||193===s||194===s)return[t.readUInt16BE(e+7),t.readUInt16BE(e+5)];t=t.slice(e+2)}throw new TypeError("Invalid JPG, no size found")}static getSizePNG(t){return"CgBI"===t.toString("ascii",12,16)?[t.readUInt32BE(32),t.readUInt32BE(36)]:[t.readUInt32BE(16),t.readUInt32BE(20)]}static mimeTypeToExtension(t){return"image/jpeg"===t?"jpg":t.split("/").pop()}static extensionToMimeType(t){return"jpg"===t?"image/jpeg":"image/"+t}}function E(t,e){if(e>t.length)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(255!==t[e])throw new TypeError("Invalid JPG, marker table corrupted")}class y{constructor(t){this.verbosity=t}debug(t){this.verbosity<=y.Verbosity.DEBUG&&console.debug(t)}info(t){this.verbosity<=y.Verbosity.INFO&&console.info(t)}warn(t){this.verbosity<=y.Verbosity.WARN&&console.warn(t)}error(t){this.verbosity<=y.Verbosity.ERROR&&console.error(t)}}y.Verbosity={SILENT:4,ERROR:3,WARN:2,INFO:1,DEBUG:0};const b="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",M=new Set,S=function(){let t="";for(let e=0;e<6;e++)t+=b.charAt(Math.floor(Math.random()*b.length));return t},N=function(){for(let t=0;t<999;t++){const t=S();if(!M.has(t))return M.add(t),t}};class R extends a{constructor(){super(...arguments),this.propertyType=i.TEXTURE,this.image=null,this.mimeType="",this.uri=""}getMimeType(){return this.mimeType}setMimeType(t){return this.mimeType=t,this}getURI(){return this.uri}setURI(t){return this.uri=t,this}getImage(){return this.image}setImage(t){return this.image=t,this}getSize(){let t;return t=this.mimeType?"image/png"===this.mimeType:this.uri.match(/\.png$/),t?T.getSizePNG(Buffer.from(this.image)):T.getSizeJPEG(Buffer.from(this.image))}}class I{constructor(){this.propertyType=i.TEXTURE_INFO,this.texCoord=0}getTexCoord(){return this.texCoord}setTexCoord(t){return this.texCoord=t,this}}class C{constructor(){this.propertyType=i.TEXTURE_SAMPLER,this.O=null,this.F=null,this.G=10497,this.j=10497}getMagFilter(){return this.O}setMagFilter(t){return this.O=t,this}getMinFilter(){return this.F}setMinFilter(t){return this.F=t,this}getWrapS(){return this.G}setWrapS(t){return this.G=t,this}getWrapT(){return this.j}setWrapT(t){return this.j=t,this}}C.TextureWrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},C.TextureMagFilter={NEAREST:9728,LINEAR:9729},C.TextureMinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};class _ extends n{constructor(){super(...arguments),this.textureInfo=new I,this.sampler=new C}}class B extends n{constructor(){super(...arguments),this.semantic=""}}class U extends n{}class k extends h{linkTexture(t,e,s){if(!s)return null;const r=new _(t,e,s);return this.registerLink(r),r}linkAttribute(t,e,s){if(!s)return null;const r=new B(t,e,s);return this.registerLink(r),r}linkIndex(t,e,s){if(!s)return null;const r=new U(t,e,s);return this.registerLink(r),r}}class L extends a{constructor(){super(...arguments),this.propertyType=i.MATERIAL,this.D="OPAQUE",this.$=.5,this.J=!1,this.V=[1,1,1,1],this.W=[0,0,0],this.Y=1,this.q=1,this.Z=1,this.X=1,this.baseColorTexture=null,this.emissiveTexture=null,this.normalTexture=null,this.occlusionTexture=null,this.metallicRoughnessTexture=null}getDoubleSided(){return this.J}setDoubleSided(t){return this.J=t,this}getAlphaMode(){return this.D}setAlphaMode(t){return this.D=t,this}getAlphaCutoff(){return this.$}setAlphaCutoff(t){return this.$=t,this}getBaseColorFactor(){return this.V}setBaseColorFactor(t){return this.V=t,this}getBaseColorTexture(){return this.baseColorTexture?this.baseColorTexture.getChild():null}getBaseColorTextureInfo(){return this.baseColorTexture?this.baseColorTexture.textureInfo:null}getBaseColorTextureSampler(){return this.baseColorTexture?this.baseColorTexture.sampler:null}setBaseColorTexture(t){return this.baseColorTexture=this.l.linkTexture("baseColorTexture",this,t),this}getEmissiveFactor(){return this.W}setEmissiveFactor(t){return this.W=t,this}getEmissiveTexture(){return this.emissiveTexture?this.emissiveTexture.getChild():null}getEmissiveTextureInfo(){return this.emissiveTexture?this.emissiveTexture.textureInfo:null}getEmissiveTextureSampler(){return this.emissiveTexture?this.emissiveTexture.sampler:null}setEmissiveTexture(t){return this.emissiveTexture=this.l.linkTexture("emissiveTexture",this,t),this}getNormalScale(){return this.Y}setNormalScale(t){return this.Y=t,this}getNormalTexture(){return this.normalTexture?this.normalTexture.getChild():null}getNormalTextureInfo(){return this.normalTexture?this.normalTexture.textureInfo:null}getNormalTextureSampler(){return this.normalTexture?this.normalTexture.sampler:null}setNormalTexture(t){return this.normalTexture=this.l.linkTexture("normalTexture",this,t),this}getOcclusionStrength(){return this.q}setOcclusionStrength(t){return this.q=t,this}getOcclusionTexture(){return this.occlusionTexture?this.occlusionTexture.getChild():null}getOcclusionTextureInfo(){return this.occlusionTexture?this.occlusionTexture.textureInfo:null}getOcclusionTextureSampler(){return this.occlusionTexture?this.occlusionTexture.sampler:null}setOcclusionTexture(t){return this.occlusionTexture=this.l.linkTexture("occlusionTexture",this,t),this}getRoughnessFactor(){return this.Z}setRoughnessFactor(t){return this.Z=t,this}getMetallicFactor(){return this.X}setMetallicFactor(t){return this.X=t,this}getMetallicRoughnessTexture(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.getChild():null}getMetallicRoughnessTextureInfo(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.textureInfo:null}getMetallicRoughnessTextureSampler(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.sampler:null}setMetallicRoughnessTexture(t){return this.metallicRoughnessTexture=this.l.linkTexture("metallicRoughnessTexture",this,t),this}}r([o],L.prototype,"baseColorTexture",void 0),r([o],L.prototype,"emissiveTexture",void 0),r([o],L.prototype,"normalTexture",void 0),r([o],L.prototype,"occlusionTexture",void 0),r([o],L.prototype,"metallicRoughnessTexture",void 0);class P extends a{constructor(){super(...arguments),this.propertyType=i.MESH,this.H=[],this.primitives=[]}addPrimitive(t){return this.addGraphChild(this.primitives,this.l.link("primitive",this,t))}removePrimitive(t){return this.removeGraphChild(this.primitives,t)}listPrimitives(){return this.primitives.map(t=>t.getChild())}getWeights(){return this.H}setWeights(t){return this.H=t,this}}r([u],P.prototype,"primitives",void 0);class O extends c{constructor(){super(...arguments),this.propertyType=i.PRIMITIVE,this.K=4,this.indices=null,this.attributes=[],this.targets=[],this.material=null}getIndices(){return this.indices?this.indices.getChild():null}setIndices(t){return this.indices=this.l.linkIndex("index",this,t),this}getAttribute(t){const e=this.attributes.find(e=>e.semantic===t);return e?e.getChild():null}setAttribute(t,e){const s=this.getAttribute(t);if(s&&this.removeGraphChild(this.attributes,s),!e)return this;const r=this.l.linkAttribute(t.toLowerCase(),this,e);return r.semantic=t,this.addGraphChild(this.attributes,r)}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.l.link("material",this,t),this}getMode(){return this.K}setMode(t){return this.K=t,this}listTargets(){return this.targets.map(t=>t.getChild())}addTarget(t){return this.addGraphChild(this.targets,this.l.link("target",this,t)),this}removeTarget(t){return this.removeGraphChild(this.targets,t)}}r([o],O.prototype,"indices",void 0),r([u],O.prototype,"attributes",void 0),r([u],O.prototype,"targets",void 0),r([o],O.prototype,"material",void 0);class F extends c{constructor(){super(...arguments),this.propertyType=i.PRIMITIVE_TARGET,this.attributes=[]}getAttribute(t){const e=this.attributes.find(e=>e.semantic===t);return e?e.getChild():null}setAttribute(t,e){const s=this.getAttribute(t);if(s&&this.removeGraphChild(this.attributes,s),!e)return this;const r=this.l.linkAttribute(t.toLowerCase(),this,e);return r.semantic=t,this.addGraphChild(this.attributes,r)}listAttributes(){return this.attributes.map(t=>t.getChild())}listSemantics(){return this.attributes.map(t=>t.semantic)}}r([u],F.prototype,"attributes",void 0);class G extends a{constructor(){super(...arguments),this.propertyType=i.NODE,this.tt=[0,0,0],this.et=[0,0,0,1],this.st=[1,1,1],this.H=[],this.camera=null,this.mesh=null,this.skin=null,this.children=[]}getTranslation(){return this.tt}getRotation(){return this.et}getScale(){return this.st}setTranslation(t){return this.tt=t,this}setRotation(t){return this.et=t,this}setScale(t){return this.st=t,this}addChild(t){const e=this.l.link("child",this,t);return this.addGraphChild(this.children,e)}removeChild(t){return this.removeGraphChild(this.children,t)}listChildren(){return this.children.map(t=>t.getChild())}getMesh(){return this.mesh?this.mesh.getChild():null}setMesh(t){return this.mesh=this.l.link("mesh",this,t),this}getCamera(){return this.camera?this.camera.getChild():null}setCamera(t){return this.camera=this.l.link("camera",this,t),this}getSkin(){return this.skin?this.skin.getChild():null}setSkin(t){return this.skin=this.l.link("skin",this,t),this}getWeights(){return this.H}setWeights(t){return this.H=t,this}}r([o],G.prototype,"camera",void 0),r([o],G.prototype,"mesh",void 0),r([o],G.prototype,"skin",void 0),r([u],G.prototype,"children",void 0);class j extends c{constructor(){super(...arguments),this.propertyType=i.ROOT,this.rt={generator:"glTF-Transform v0.4.0-alpha.2",version:"2.0"},this.it=new Set,this.scenes=[],this.nodes=[],this.cameras=[],this.skins=[],this.meshes=[],this.materials=[],this.textures=[],this.animations=[],this.accessors=[],this.buffers=[]}getAsset(){return this.rt}listExtensionsUsed(){return Array.from(this.it)}listExtensionsRequired(){return this.listExtensionsUsed().filter(t=>t.isRequired())}nt(t){if(this.it.has(t))throw new Error(`Extension "${t.extensionName}" is already enabled.`);return this.it.add(t),this}ht(t){return this.it.delete(t),this}ot(t){return this.addGraphChild(this.scenes,this.l.link("scene",this,t))}listScenes(){return this.scenes.map(t=>t.getChild())}ut(t){return this.addGraphChild(this.nodes,this.l.link("node",this,t))}listNodes(){return this.nodes.map(t=>t.getChild())}ct(t){return this.addGraphChild(this.cameras,this.l.link("camera",this,t))}listCameras(){return this.cameras.map(t=>t.getChild())}at(t){return this.addGraphChild(this.skins,this.l.link("skin",this,t))}listSkins(){return this.skins.map(t=>t.getChild())}lt(t){return this.addGraphChild(this.meshes,this.l.link("mesh",this,t))}listMeshes(){return this.meshes.map(t=>t.getChild())}dt(t){return this.addGraphChild(this.materials,this.l.link("material",this,t))}listMaterials(){return this.materials.map(t=>t.getChild())}ft(t){return this.addGraphChild(this.textures,this.l.link("texture",this,t))}listTextures(){return this.textures.map(t=>t.getChild())}gt(t){return this.addGraphChild(this.animations,this.l.link("animation",this,t))}listAnimations(){return this.animations.map(t=>t.getChild())}pt(t){return this.addGraphChild(this.accessors,this.l.link("accessor",this,t))}listAccessors(){return this.accessors.map(t=>t.getChild())}wt(t){return this.addGraphChild(this.buffers,this.l.link("buffer",this,t))}listBuffers(){return this.buffers.map(t=>t.getChild())}}r([u],j.prototype,"scenes",void 0),r([u],j.prototype,"nodes",void 0),r([u],j.prototype,"cameras",void 0),r([u],j.prototype,"skins",void 0),r([u],j.prototype,"meshes",void 0),r([u],j.prototype,"materials",void 0),r([u],j.prototype,"textures",void 0),r([u],j.prototype,"animations",void 0),r([u],j.prototype,"accessors",void 0),r([u],j.prototype,"buffers",void 0);class D extends a{constructor(){super(...arguments),this.propertyType=i.SCENE,this.nodes=[]}addNode(t){return this.addGraphChild(this.nodes,this.l.link("node",this,t))}removeNode(t){return this.removeGraphChild(this.nodes,t)}listNodes(){return this.nodes.map(t=>t.getChild())}}r([u],D.prototype,"nodes",void 0);class $ extends a{constructor(){super(...arguments),this.propertyType=i.SKIN,this.skeleton=null,this.inverseBindMatrices=null,this.joints=[]}getSkeleton(){return this.skeleton?this.skeleton.getChild():null}setSkeleton(t){return this.skeleton=this.l.link("skeleton",this,t),this}getInverseBindMatrices(){return this.inverseBindMatrices?this.inverseBindMatrices.getChild():null}setInverseBindMatrices(t){return this.inverseBindMatrices=this.l.link("inverseBindMatrices",this,t),this}addJoint(t){const e=this.l.link("joint",this,t);return this.addGraphChild(this.joints,e)}removeJoint(t){return this.removeGraphChild(this.joints,t)}listJoints(){return this.joints.map(t=>t.getChild())}}r([o],$.prototype,"skeleton",void 0),r([o],$.prototype,"inverseBindMatrices",void 0),r([u],$.prototype,"joints",void 0);class z{constructor(){this.graph=new k,this.root=new j(this.graph),this.logger=new y(y.Verbosity.INFO)}getRoot(){return this.root}getGraph(){return this.graph}getLogger(){return this.logger}setLogger(t){return this.logger=t,this}clone(){throw new Error("Not implemented.")}transform(...t){for(const e of t)e(this);return this}createExtension(t){return this.getRoot().listExtensionsUsed().find(e=>e.extensionName===t.EXTENSION_NAME)||new t(this)}createScene(t){const e=new D(this.graph,t);return this.root.ot(e),e}createNode(t){const e=new G(this.graph,t);return this.root.ut(e),e}createCamera(t){const e=new w(this.graph,t);return this.root.ct(e),e}createSkin(t){const e=new $(this.graph,t);return this.root.at(e),e}createMesh(t){const e=new P(this.graph,t);return this.root.lt(e),e}createPrimitive(){return new O(this.graph)}createPrimitiveTarget(t){return new F(this.graph,t)}createMaterial(t){const e=new L(this.graph,t);return this.root.dt(e),e}createTexture(t){const e=new R(this.graph,t);return this.root.ft(e),e}createAnimation(t){const e=new f(this.graph,t);return this.root.gt(e),e}createAnimationChannel(){return new g(this.graph)}createAnimationSampler(){return new p(this.graph)}createAccessor(t,e=null){e||(e=this.getRoot().listBuffers()[0]);const s=new l(this.graph,t).setBuffer(e);return this.root.pt(s),s}createBuffer(t){const e=new m(this.graph,t);return this.root.wt(e),e}}class J{constructor(t){this.doc=t,this.vt=!1,this.xt=new Set,t.getRoot().nt(this)}dispose(){this.doc.getRoot().ht(this);for(const t of this.xt)t.dispose()}isRequired(){return this.vt}setRequired(t){return this.vt=t,this}addExtensionProperty(t){return this.xt.add(t),this}removeExtensionProperty(t){return this.xt.delete(t),this}}class V{constructor(t){this.nativeDocument=t,this.buffers=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[]}}const W={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};class Y{static read(r,i){const{json:n}=r,h=new z;if("2.0"!==n.asset.version)throw new Error(`Unsupported glTF version: "${n.asset.version}".`);const o=new V(r);o.buffers=(n.buffers||[]).map(t=>{const e=h.createBuffer(t.name);return t.uri&&0!==t.uri.indexOf("__")&&e.setURI(t.uri),e}),o.bufferViewBuffers=(n.bufferViews||[]).map(t=>o.buffers[t.buffer]),o.accessors=(n.accessors||[]).map(t=>{const e=h.createAccessor(t.name,o.bufferViewBuffers[t.bufferView]);let s;return e.setType(t.type),s=void 0!==t.sparse?function(t,e){const s=W[t.componentType],r=l.getElementSize(t.type);let i;i=void 0!==t.bufferView?X(t,e).slice():new s(t.count*r);const n=t.sparse.count,h={...t,...t.sparse.indices,count:n,type:"SCALAR"},o={...t,...t.sparse.values,count:n},u=X(h,e),c=X(o,e);for(let t=0;t<h.count;t++)for(let e=0;e<r;e++)i[u[t]*r+e]=c[t*r+e];return i}(t,r):X(t,r).slice(),void 0!==t.normalized&&e.setNormalized(t.normalized),e.setArray(s),e});const u=n.textures||[];o.textures=(n.images||[]).map(t=>{const e=h.createTexture(t.name);if(void 0!==t.bufferView){const s=n.bufferViews[t.bufferView],i=r.json.buffers[s.buffer],h=s.byteOffset||0,o=(i.uri?r.resources[i.uri]:r.resources["At"]).slice(h,h+s.byteLength);e.setImage(o)}else void 0!==t.uri&&(e.setImage(r.resources[t.uri]),0!==t.uri.indexOf("__")&&e.setURI(t.uri));if(void 0!==t.mimeType)e.setMimeType(t.mimeType);else if(t.uri){const s=A.extension(t.uri);e.setMimeType(T.extensionToMimeType(s))}return e}),o.materials=(n.materials||[]).map(t=>{const e=h.createMaterial(t.name);void 0!==t.alphaMode&&e.setAlphaMode(t.alphaMode),void 0!==t.alphaCutoff&&e.setAlphaCutoff(t.alphaCutoff),void 0!==t.doubleSided&&e.setDoubleSided(t.doubleSided);const s=t.pbrMetallicRoughness||{};if(void 0!==s.baseColorFactor&&e.setBaseColorFactor(s.baseColorFactor),void 0!==t.emissiveFactor&&e.setEmissiveFactor(t.emissiveFactor),void 0!==s.metallicFactor&&e.setMetallicFactor(s.metallicFactor),void 0!==s.roughnessFactor&&e.setRoughnessFactor(s.roughnessFactor),void 0!==s.baseColorTexture){const t=s.baseColorTexture;e.setBaseColorTexture(o.textures[u[t.index].source]),q(e.getBaseColorTextureInfo(),t),Z(e.getBaseColorTextureSampler(),t,r)}if(void 0!==t.emissiveTexture){const s=t.emissiveTexture;e.setEmissiveTexture(o.textures[u[s.index].source]),q(e.getEmissiveTextureInfo(),s),Z(e.getEmissiveTextureSampler(),s,r)}if(void 0!==t.normalTexture){const s=t.normalTexture;e.setNormalTexture(o.textures[u[s.index].source]),q(e.getNormalTextureInfo(),s),Z(e.getNormalTextureSampler(),s,r),void 0!==t.normalTexture.scale&&e.setNormalScale(t.normalTexture.scale)}if(void 0!==t.occlusionTexture){const s=t.occlusionTexture;e.setOcclusionTexture(o.textures[u[s.index].source]),q(e.getOcclusionTextureInfo(),s),Z(e.getOcclusionTextureSampler(),s,r),void 0!==t.occlusionTexture.strength&&e.setOcclusionStrength(t.occlusionTexture.strength)}if(void 0!==s.metallicRoughnessTexture){const t=s.metallicRoughnessTexture;e.setMetallicRoughnessTexture(o.textures[u[t.index].source]),q(e.getMetallicRoughnessTextureInfo(),t),Z(e.getMetallicRoughnessTextureSampler(),t,r)}return e}),o.meshes=(n.meshes||[]).map(t=>{const e=h.createMesh(t.name);return void 0!==t.weights&&e.setWeights(t.weights),t.primitives.forEach(s=>{const r=h.createPrimitive();void 0!==s.material&&r.setMaterial(o.materials[s.material]),void 0!==s.mode&&r.setMode(s.mode);for(const[t,e]of Object.entries(s.attributes||{}))r.setAttribute(t,o.accessors[e]);void 0!==s.indices&&r.setIndices(o.accessors[s.indices]);const i=t.extras&&t.extras.targetNames||[];(s.targets||[]).forEach((t,e)=>{const s=i[e]||e.toString(),n=h.createPrimitiveTarget(s);for(const[e,s]of Object.entries(t))n.setAttribute(e,o.accessors[s]);r.addTarget(n)}),e.addPrimitive(r)}),e}),o.cameras=(n.cameras||[]).map(t=>{const e=h.createCamera(t.name).setType(t.type);return"perspective"===t.type?e.setZNear(t.perspective.znear).setZFar(t.perspective.zfar).setYFov(t.perspective.yfov).setAspectRatio(t.perspective.aspectRatio):e.setZNear(t.orthographic.znear).setZFar(t.orthographic.zfar).setXMag(t.orthographic.xmag).setYMag(t.orthographic.ymag),e});const c=n.nodes||[];o.nodes=c.map(r=>{const i=h.createNode(r.name);return void 0!==r.translation&&i.setTranslation(r.translation),void 0!==r.rotation&&i.setRotation(r.rotation),void 0!==r.scale&&i.setScale(r.scale),void 0!==r.matrix&&(i.setTranslation(t([],r.matrix)),i.setRotation(e([],r.matrix)),i.setScale(s([],r.matrix))),void 0!==r.weights&&i.setWeights(r.weights),i}),o.skins=(n.skins||[]).map(t=>{const e=h.createSkin(t.name);void 0!==t.inverseBindMatrices&&e.setInverseBindMatrices(o.accessors[t.inverseBindMatrices]),void 0!==t.skeleton&&e.setSkeleton(o.nodes[t.skeleton]);for(const s of t.joints)e.addJoint(o.nodes[s]);return e}),c.map((t,e)=>{const s=o.nodes[e];(t.children||[]).forEach(t=>s.addChild(o.nodes[t])),void 0!==t.mesh&&s.setMesh(o.meshes[t.mesh]),void 0!==t.camera&&s.setCamera(o.cameras[t.camera]),void 0!==t.skin&&s.setSkin(o.skins[t.skin])}),o.animations=(n.animations||[]).map(t=>{const e=h.createAnimation(t.name),s=(t.samplers||[]).map(t=>{const s=h.createAnimationSampler().setInput(o.accessors[t.input]).setOutput(o.accessors[t.output]).setInterpolation(t.interpolation||"LINEAR");return e.addSampler(s),s});return(t.channels||[]).forEach(t=>{const r=h.createAnimationChannel().setSampler(s[t.sampler]).setTargetNode(o.nodes[t.target.node]).setTargetPath(t.target.path);e.addChannel(r)}),e}),o.scenes=(n.scenes||[]).map(t=>{const e=h.createScene(t.name);return(t.nodes||[]).map(t=>o.nodes[t]).forEach(t=>e.addNode(t)),e});const a=n.extensionsUsed||[],d=n.extensionsRequired||[];for(const t of i.extensions)a.includes(t.EXTENSION_NAME)&&h.createExtension(t).setRequired(d.includes(t.EXTENSION_NAME)).read(o);return h}}function q(t,e){void 0!==e.texCoord&&t.setTexCoord(e.texCoord)}function Z(t,e,s){const r=s.json.textures[e.index];if(void 0===r.sampler)return;const i=s.json.samplers[r.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)}function X(t,e){const s=e.json.bufferViews[t.bufferView],r=e.json.buffers[s.buffer],i=r.uri?e.resources[r.uri]:e.resources["At"],n=W[t.componentType],h=l.getElementSize(t.type);if(void 0!==s.byteStride&&s.byteStride!==h*n.BYTES_PER_ELEMENT)return function(t,e){const s=e.json.bufferViews[t.bufferView],r=e.json.buffers[s.buffer],i=r.uri?e.resources[r.uri]:e.resources["At"],n=W[t.componentType],h=l.getElementSize(t.type),o=n.BYTES_PER_ELEMENT,u=t.byteOffset||0,c=new n(t.count*h),a=new DataView(i,s.byteOffset,s.byteLength),d=s.byteStride;for(let e=0;e<t.count;e++)for(let s=0;s<h;s++){const r=u+e*d+s*o;let i;switch(t.componentType){case 5126:i=a.getFloat32(r,!0);break;case 5125:i=a.getUint32(r,!0);break;case 5123:i=a.getUint16(r,!0);break;case 5121:i=a.getUint8(r);break;case 5122:i=a.getInt16(r,!0);break;case 5120:i=a.getInt8(r);break;default:throw new Error(`Unexpected componentType "${t.componentType}".`)}c[e*h+s]=i}return c}(t,e);const o=(s.byteOffset||0)+(t.byteOffset||0);switch(t.componentType){case 5126:return new Float32Array(i,o,t.count*h);case 5125:return new Uint32Array(i,o,t.count*h);case 5123:return new Uint16Array(i,o,t.count*h);case 5121:return new Uint8Array(i,o,t.count*h);case 5122:return new Int16Array(i,o,t.count*h);case 5120:return new Int8Array(i,o,t.count*h);default:throw new Error(`Unexpected componentType "${t.componentType}".`)}}class H{constructor(t,e){this.nativeDocument=t,this.options=e,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.samplerDefIndexMap=new Map,this.imageData=[]}createTextureInfoDef(t,e,s){const r={magFilter:s.getMagFilter()||void 0,minFilter:s.getMinFilter()||void 0,wrapS:s.getWrapS(),wrapT:s.getWrapT()},i=JSON.stringify(r);this.samplerDefIndexMap.has(i)||(this.samplerDefIndexMap.set(i,this.nativeDocument.json.samplers.length),this.nativeDocument.json.samplers.push(r));const n={source:this.imageIndexMap.get(t),sampler:this.samplerDefIndexMap.get(i)},h=JSON.stringify(n);return this.textureDefIndexMap.has(h)||(this.textureDefIndexMap.set(h,this.nativeDocument.json.textures.length),this.nativeDocument.json.textures.push(n)),{index:this.textureDefIndexMap.get(h),texCoord:e.getTexCoord()}}createPropertyDef(t){const e={};return t.getName()&&(e.name=t.getName()),Object.keys(t.getExtras()).length>0&&(e.extras=t.getExtras()),e}createAccessorDef(t){const e=this.createPropertyDef(t);return e.type=t.getType(),e.componentType=t.getComponentType(),e.count=t.getCount(),t.getMax(e.max=[]),t.getMin(e.min=[]),e.normalized=t.getNormalized(),e}createImageData(t,e,s){if(this.options.isGLB)this.imageData.push(e),t.bufferView=this.nativeDocument.json.bufferViews.length,this.nativeDocument.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:e.byteLength});else{const r=T.mimeTypeToExtension(s.getMimeType());t.uri=this.imageURIGenerator.createURI(s,r),this.nativeDocument.resources[t.uri]=e}}}class K{constructor(t,e){this.multiple=t,this.basename=e,this.counter=1}createURI(t,e){return t.getURI()?t.getURI():this.multiple?`${this.basename}_${this.counter++}.${e}`:`${this.basename}.${e}`}}class Q{static write(t,e){const s=t.getRoot(),r={json:{asset:s.getAsset()},resources:{}},i=r.json,n=new H(r,e),h=s.listBuffers().length,o=s.listTextures().length;function u(t,e,s,r){const h=[];let o=0;for(const e of t){const t=n.createAccessorDef(e);t.bufferView=i.bufferViews.length;const s=x.pad(e.getArray().buffer);t.byteOffset=o,o+=s.byteLength,h.push(s),n.accessorIndexMap.set(e,i.accessors.length),i.accessors.push(t)}const u={buffer:e,byteOffset:s,byteLength:x.concat(h).byteLength};return r&&(u.target=r),i.bufferViews.push(u),{buffers:h,byteLength:o}}function c(t,e,s){const r=t[0].getCount();let h=0;for(const e of t){const t=n.createAccessorDef(e);t.bufferView=i.bufferViews.length,t.byteOffset=h;const s=e.getElementSize(),r=e.getComponentSize();h+=x.padNumber(s*r),n.accessorIndexMap.set(e,i.accessors.length),i.accessors.push(t)}const o=r*h,u=new ArrayBuffer(o),c=new DataView(u);for(let e=0;e<r;e++){let s=0;for(const r of t){const t=r.getElementSize(),i=r.getComponentSize(),n=r.getComponentType(),o=r.getArray();for(let r=0;r<t;r++){const u=e*h+s+r*i,a=o[e*t+r];switch(n){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: "+n)}}s+=x.padNumber(t*i)}}return i.bufferViews.push({buffer:e,byteOffset:s,byteLength:o,byteStride:h,target:34962}),{byteLength:o,buffers:[u]}}n.bufferURIGenerator=new K(h>1,e.basename),n.imageURIGenerator=new K(o>1,e.basename),n.logger=t.getLogger();const a=new Map;for(const e of t.getGraph().getLinks()){if(e.getParent()===s)continue;const t=e.getChild();if(t instanceof l){const s=a.get(t)||[];s.push(e),a.set(t,s)}}return i.accessors=[],i.bufferViews=[],i.samplers=[],i.textures=[],i.images=s.listTextures().map((t,e)=>{const s=n.createPropertyDef(t);return t.getMimeType()&&(s.mimeType=t.getMimeType()),t.getImage()&&n.createImageData(s,t.getImage(),t),n.imageIndexMap.set(t,e),s}),i.buffers=[],s.listBuffers().forEach(t=>{const s=n.createPropertyDef(t),h=new Map,o=new Set,d=new Set,f=t.listParents().filter(t=>!(t instanceof j));for(const t of f){if(!(t instanceof l))throw new Error("Unimplemented buffer reference: "+t);let e=!1,s=!1,r=!1;const i=a.get(t)||[];for(const t of i)t instanceof B?e=!0:t instanceof U?s=!0:r=!0;if(e||s||r||(r=!0),!e||s||r)if(!s||e||r){if(!r||e||s)throw new Error("Attribute or index accessors must be used only for that purpose.");d.add(t)}else o.add(t);else{const e=i[0].getParent(),s=h.get(e)||new Set;s.add(t),h.set(e,s)}}const g=[],p=i.buffers.length;let m,w=0;if(o.size){const t=u(Array.from(o),p,w,34963);w+=t.byteLength,g.push(...t.buffers)}for(const t of Array.from(h.values()))if(t.size){const e=c(Array.from(t),p,w);w+=e.byteLength,g.push(...e.buffers)}if(d.size){const t=u(Array.from(d),p,w);w+=t.byteLength,g.push(...t.buffers)}if(n.imageData.length)for(let t=0;t<n.imageData.length;t++)i.bufferViews[i.images[t].bufferView].byteOffset=w,w+=n.imageData[t].byteLength,g.push(n.imageData[t]);w?(e.isGLB?m="__glb.bin":(m=n.bufferURIGenerator.createURI(t,"bin"),s.uri=m),s.byteLength=w,r.resources[m]=x.concat(g),i.buffers.push(s)):n.logger.warn(`@gltf-transform/core: Skipping empty buffer, "${t.getName()}".`)}),i.materials=s.listMaterials().map((t,e)=>{const s=n.createPropertyDef(t);if(s.alphaMode=t.getAlphaMode(),"MASK"===t.getAlphaMode()&&(s.alphaCutoff=t.getAlphaCutoff()),s.doubleSided=t.getDoubleSided(),s.pbrMetallicRoughness={},s.pbrMetallicRoughness.baseColorFactor=t.getBaseColorFactor(),s.emissiveFactor=t.getEmissiveFactor(),s.pbrMetallicRoughness.roughnessFactor=t.getRoughnessFactor(),s.pbrMetallicRoughness.metallicFactor=t.getMetallicFactor(),t.getBaseColorTexture()){const e=t.getBaseColorTexture(),r=t.getBaseColorTextureInfo(),i=t.getBaseColorTextureSampler();s.pbrMetallicRoughness.baseColorTexture=n.createTextureInfoDef(e,r,i)}if(t.getEmissiveTexture()){const e=t.getEmissiveTexture(),r=t.getEmissiveTextureInfo(),i=t.getEmissiveTextureSampler();s.emissiveTexture=n.createTextureInfoDef(e,r,i)}if(t.getNormalTexture()){const e=t.getNormalTexture(),r=t.getNormalTextureInfo(),i=t.getNormalTextureSampler(),h=n.createTextureInfoDef(e,r,i);1!==t.getNormalScale()&&(h.scale=t.getNormalScale()),s.normalTexture=h}if(t.getOcclusionTexture()){const e=t.getOcclusionTexture(),r=t.getOcclusionTextureInfo(),i=t.getOcclusionTextureSampler(),h=n.createTextureInfoDef(e,r,i);1!==t.getOcclusionStrength()&&(h.strength=t.getOcclusionStrength()),s.occlusionTexture=h}if(t.getMetallicRoughnessTexture()){const e=t.getMetallicRoughnessTexture(),r=t.getMetallicRoughnessTextureInfo(),i=t.getMetallicRoughnessTextureSampler();s.pbrMetallicRoughness.metallicRoughnessTexture=n.createTextureInfoDef(e,r,i)}return n.materialIndexMap.set(t,e),s}),i.meshes=s.listMeshes().map((t,e)=>{const s=n.createPropertyDef(t);let r;return s.primitives=t.listPrimitives().map(t=>{const e={attributes:{}};e.material=n.materialIndexMap.get(t.getMaterial()),e.mode=t.getMode(),t.getIndices()&&(e.indices=n.accessorIndexMap.get(t.getIndices()));for(const s of t.listSemantics())e.attributes[s]=n.accessorIndexMap.get(t.getAttribute(s));for(const s of t.listTargets()){const t={};for(const e of s.listSemantics())t[e]=n.accessorIndexMap.get(s.getAttribute(e));e.targets=e.targets||[],e.targets.push(t)}return t.listTargets().length&&!r&&(r=t.listTargets().map(t=>t.getName())),e}),t.getWeights().length&&(s.weights=t.getWeights()),r&&(s.extras=s.extras||{},s.extras.targetNames=r),n.meshIndexMap.set(t,e),s}),i.cameras=s.listCameras().map((t,e)=>{const s=n.createPropertyDef(t);return s.type=t.getType(),"perspective"===s.type?s.perspective={znear:t.getZNear(),zfar:t.getZFar(),yfov:t.getYFov(),aspectRatio:t.getAspectRatio()}:s.orthographic={znear:t.getZNear(),zfar:t.getZFar(),xmag:t.getXMag(),ymag:t.getYMag()},n.cameraIndexMap.set(t,e),s}),i.nodes=s.listNodes().map((t,e)=>{const s=n.createPropertyDef(t);return s.translation=t.getTranslation(),s.rotation=t.getRotation(),s.scale=t.getScale(),t.getWeights().length&&(s.weights=t.getWeights()),n.nodeIndexMap.set(t,e),s}),i.skins=s.listSkins().map((t,e)=>{const s=n.createPropertyDef(t);return t.getInverseBindMatrices()&&(s.inverseBindMatrices=n.accessorIndexMap.get(t.getInverseBindMatrices())),t.getSkeleton()&&(s.skeleton=n.nodeIndexMap.get(t.getSkeleton())),s.joints=t.listJoints().map(t=>n.nodeIndexMap.get(t)),n.skinIndexMap.set(t,e),s}),s.listNodes().forEach((t,e)=>{const s=i.nodes[e];t.getMesh()&&(s.mesh=n.meshIndexMap.get(t.getMesh())),t.getCamera()&&(s.camera=n.cameraIndexMap.get(t.getCamera())),t.getSkin()&&(s.skin=n.skinIndexMap.get(t.getSkin())),t.listChildren().length>0&&(s.children=t.listChildren().map(t=>n.nodeIndexMap.get(t)))}),i.animations=s.listAnimations().map(t=>{const e=n.createPropertyDef(t),s=new Map;return e.samplers=t.listSamplers().map((t,e)=>{const r=n.createPropertyDef(t);return r.input=n.accessorIndexMap.get(t.getInput()),r.output=n.accessorIndexMap.get(t.getOutput()),r.interpolation=t.getInterpolation(),s.set(t,e),r}),e.channels=t.listChannels().map(t=>{const e=n.createPropertyDef(t);return e.sampler=s.get(t.getSampler()),e.target={node:n.nodeIndexMap.get(t.getTargetNode()),path:t.getTargetPath()},e}),e}),i.scenes=s.listScenes().map(t=>{const e=n.createPropertyDef(t);return e.nodes=t.listNodes().map(t=>n.nodeIndexMap.get(t)),e}),i.extensionsUsed=s.listExtensionsUsed().map(t=>t.extensionName),i.extensionsRequired=s.listExtensionsRequired().map(t=>t.extensionName),s.listExtensionsUsed().forEach(t=>t.write(n)),function(t){const e=[];for(const s in t){const r=t[s];Array.isArray(r)&&0===r.length?e.push(s):null!==r&&""!==r||e.push(r)}for(const s of e)delete t[s]}(i),r}}class tt{constructor(){this.it=[]}registerExtensions(t){return this.it.push(...t),this}createDocument(t){return Y.read(t,{extensions:this.it})}createNativeDocument(t,e){if(e.isGLB&&1!==t.getRoot().listBuffers().length)throw new Error("GLB must have exactly 1 buffer.");return Q.write(t,e)}unpackGLB(t){const e=new Uint32Array(t,0,3);if(1179937895!==e[0])throw new Error("Invalid glTF asset.");if(2!==e[1])throw new Error(`Unsupported glTF binary version, "${e[1]}".`);const s=new Uint32Array(t,12,2),r=s[0],i=new Uint32Array(t,20+r,2);if(1313821514!==s[1]||5130562!==i[1])throw new Error("Unexpected GLB layout.");const n=x.decodeText(t.slice(20,20+r)),h=JSON.parse(n),o=20+r+8,u=t.slice(o,o+i[0]);return this.createDocument({json:h,resources:{At:u}})}packGLB(t){const{json:e,resources:s}=this.createNativeDocument(t,{basename:"",isGLB:!0}),r=JSON.stringify(e),i=x.pad(x.encodeText(r),32),n=new Uint32Array([i.byteLength,1313821514]).buffer,h=x.concat([n,i]),o=x.pad(Object.values(s)[0],0),u=new Uint32Array([o.byteLength,5130562]).buffer,c=x.concat([u,o]),a=new Uint32Array([1179937895,2,12+h.byteLength+c.byteLength]).buffer;return x.concat([a,h,c])}}class et extends tt{constructor(t,e){super(),this.fs=t,this.path=e}read(t){return t.match(/\.glb$/)?this.readGLB(t):this.readGLTF(t)}write(t,e){t.match(/\.glb$/)?this.writeGLB(t,e):this.writeGLTF(t,e)}readGLB(t){const e=this.fs.readFileSync(t),s=x.trim(e);return this.unpackGLB(s)}readGLTF(t){const e=this.path.dirname(t),s={json:JSON.parse(this.fs.readFileSync(t,"utf8")),resources:{}};return[...s.json.images||[],...s.json.buffers||[]].forEach(t=>{if(t.uri&&!t.uri.match(/data:/)){const r=this.path.resolve(e,t.uri);s.resources[t.uri]=x.trim(this.fs.readFileSync(r))}else{const e=`__${N()}.${A.extension(t.uri)}`;s.resources[e]=x.createBufferFromDataURI(t.uri),t.uri=e}}),Y.read(s,{extensions:this.it})}writeGLTF(t,e){const s={basename:A.basename(t),isGLB:!1},{json:r,resources:i}=Q.write(e,s),{fs:n,path:h}=this,o=h.dirname(t);n.writeFileSync(t,JSON.stringify(r,null,2)),Object.keys(i).forEach(t=>{const e=Buffer.from(i[t]);n.writeFileSync(h.join(o,t),e)})}writeGLB(t,e){const s=Buffer.from(this.packGLB(e));this.fs.writeFileSync(t,s)}}class st extends tt{constructor(t){super(),this.fetchConfig=t}read(t){return t.match(/\.glb$/)?this.readGLB(t):this.readGLTF(t)}readGLTF(t){const e={json:{},resources:{}};return fetch(t,this.fetchConfig).then(t=>t.json()).then(t=>{e.json=t;const s=[...t.images,...t.buffers].map(t=>{if(t.uri)return fetch(t.uri,this.fetchConfig).then(t=>t.arrayBuffer()).then(s=>{e.resources[t.uri]=s})});return Promise.all(s).then(()=>this.createDocument(e))})}readGLB(t){return fetch(t,this.fetchConfig).then(t=>t.arrayBuffer()).then(t=>this.unpackGLB(t))}}export{l as Accessor,f as Animation,g as AnimationChannel,p as AnimationSampler,m as Buffer,x as BufferUtils,w as Camera,z as Document,J as Extension,v as ExtensionProperty,A as FileUtils,h as Graph,T as ImageUtils,y as Logger,L as Material,P as Mesh,G as Node,et as NodeIO,O as Primitive,F as PrimitiveTarget,c as Property,i as PropertyType,V as ReaderContext,j as Root,D as Scene,$ as Skin,R as Texture,I as TextureInfo,C as TextureSampler,st as WebIO,H as WriterContext,N as uuid};
import{getTranslation as t,getRotation as e,getScaling as s}from"gl-matrix/mat4";function r(t,e,s,r){var i,n=arguments.length,h=n<3?e:null===r?r=Object.getOwnPropertyDescriptor(e,s):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)h=Reflect.decorate(t,e,s,r);else for(var o=t.length-1;o>=0;o--)(i=t[o])&&(h=(n<3?i(h):n>3?i(e,s,h):i(e,s))||h);return n>3&&h&&Object.defineProperty(e,s,h),h}var i;!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",t.TEXTURE_SAMPLER="TextureSampler"}(i||(i={}));class n{constructor(t,e,s){if(this.t=t,this.s=e,this.i=s,this.h=!1,this.o=[],!e.canLink(s))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 h{constructor(){this.u=[]}getLinks(){return this.u}listParents(t){return this.u.filter(e=>e.getChild()===t).map(t=>t.getParent())}listChildren(t){return this.u.filter(e=>e.getParent()===t).map(t=>t.getChild())}disconnectChildren(t){return this.u.filter(e=>e.getParent()===t).forEach(t=>t.dispose()),this}disconnectParents(t,e){let s=this.u.filter(e=>e.getChild()===t);return e&&(s=s.filter(t=>e(t.getParent()))),s.forEach(t=>t.dispose()),this}link(t,e,s){if(!s)return null;const r=new n(t,e,s);return this.registerLink(r),r}registerLink(t){return this.u.push(t),t.onDispose(()=>this.unlink(t)),t}unlink(t){return this.u=this.u.filter(e=>e!==t),this}}function o(t,e){Object.defineProperty(t,e,{get:function(){return this["__"+e]},set:function(t){const s=this["__"+e];s&&!Array.isArray(s)&&s.dispose(),t&&!Array.isArray(t)&&t.onDispose(()=>{this["__"+e]=null}),this["__"+e]=t},enumerable:!0})}function u(t,e){}class c extends class{constructor(t){this.h=!1,this.l=t}canLink(t){return this.l===t.l}isDisposed(){return this.h}dispose(){this.l.disconnectChildren(this),this.l.disconnectParents(this),this.h=!0}detach(){return this.l.disconnectParents(this),this}swap(t,e){return this.l.getLinks().filter(e=>e.getParent()===this&&e.getChild()===t).forEach(t=>t.setChild(e)),this}addGraphChild(t,e){return t.push(e),e.onDispose(()=>{const s=t.filter(t=>t!==e);t.length=0,t.push(...s)}),this}removeGraphChild(t,e){return t.filter(t=>t.getChild()===e).forEach(t=>t.dispose()),this}listGraphParents(){return this.l.listParents(this)}}{constructor(t,e=""){super(t),this.t="",this.g={},this.t=e}getName(){return this.t}setName(t){return this.t=t,this}getExtras(){return this.g}setExtras(t){return this.g=t,this}clone(){throw new Error("Not implemented.")}detach(){return this.l.disconnectParents(this,t=>"Root"!==t.propertyType),this}listParents(){return this.listGraphParents()}}class a extends c{constructor(){super(...arguments),this.extensions=[]}getExtension(t){const e=t.EXTENSION_NAME,s=this.extensions.find(t=>t.getChild().extensionName===e);return s?s.getChild():null}setExtension(t,e){const s=this.getExtension(t);return s&&this.removeGraphChild(this.extensions,s),e?(e.p(this),this.addGraphChild(this.extensions,this.l.link(e.extensionName,this,e))):this}listExtensions(){return this.extensions.map(t=>t.getChild())}}r([u],a.prototype,"extensions",void 0);class l extends a{constructor(){super(...arguments),this.propertyType=i.ACCESSOR,this.m=null,this.v="SCALAR",this.A=null,this.T=!1,this.M=d,this.S=d,this.buffer=null}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 e=this.getElementSize();this.getMin(t);for(let s=0;s<e;s++)t[s]=this.S(t[s]);return t}getMin(t){const e=this.getCount(),s=this.getElementSize();for(let e=0;e<s;e++)t[e]=Infinity;for(let r=0;r<e*s;r+=s)for(let e=0;e<s;e++){const s=this.m[r+e];Number.isFinite(s)&&(t[e]=Math.min(t[e],s))}return t}getMaxNormalized(t){const e=this.getElementSize();this.getMax(t);for(let s=0;s<e;s++)t[s]=this.S(t[s]);return t}getMax(t){const e=this.getCount(),s=this.getElementSize();for(let e=0;e<s;e++)t[e]=-Infinity;for(let r=0;r<e*s;r+=s)for(let e=0;e<s;e++){const s=this.m[r+e];Number.isFinite(s)&&(t[e]=Math.max(t[e],s))}return t}getCount(){return this.m.length/this.getElementSize()}getType(){return this.v}setType(t){return this.v=t,this}getElementSize(){return l.getElementSize(this.v)}getComponentSize(){return this.m.BYTES_PER_ELEMENT}getComponentType(){return this.A}getNormalized(){return this.T}setNormalized(t){return this.T=t,t?(this.S=t=>function(t,e){switch(e){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)}}(t,this.A),this.M=t=>function(t,e){switch(e){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)}}(t,this.A)):(this.S=d,this.M=d),this}getScalar(t){const e=this.getElementSize();return this.S(this.m[t*e])}setScalar(t,e){return this.m[t*this.getElementSize()]=this.M(e),this}getElement(t,e){const s=this.getElementSize();for(let r=0;r<s;r++)e[r]=this.S(this.m[t*s+r]);return e}setElement(t,e){const s=this.getElementSize();for(let r=0;r<s;r++)this.m[t*s+r]=this.M(e[r]);return this}getBuffer(){return this.buffer.getChild()}setBuffer(t){return this.buffer=this.l.link("buffer",this,t),this}getArray(){return this.m}setArray(t){return this.A=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.m=t,this}getByteLength(){return this.m.byteLength}}function d(t){return t}l.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT3:"MAT3",MAT4:"MAT4"},l.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},r([o],l.prototype,"buffer",void 0);class f extends a{constructor(){super(...arguments),this.propertyType=i.ANIMATION,this.channels=[],this.samplers=[]}addChannel(t){const e=this.l.link("channel",this,t);return this.addGraphChild(this.channels,e)}removeChannel(t){return this.removeGraphChild(this.channels,t)}listChannels(){return this.channels.map(t=>t.getChild())}addSampler(t){const e=this.l.link("sampler",this,t);return this.addGraphChild(this.samplers,e)}removeSampler(t){return this.removeGraphChild(this.samplers,t)}listSamplers(){return this.samplers.map(t=>t.getChild())}}r([u],f.prototype,"channels",void 0),r([u],f.prototype,"samplers",void 0);class g extends c{constructor(){super(...arguments),this.propertyType=i.ANIMATION_CHANNEL,this.N=null,this.targetNode=null,this.sampler=null}getTargetPath(){return this.N}setTargetPath(t){return this.N=t,this}getTargetNode(){return this.targetNode?this.targetNode.getChild():null}setTargetNode(t){return this.targetNode=this.l.link("target.node",this,t),this}getSampler(){return this.sampler?this.sampler.getChild():null}setSampler(t){return this.sampler=this.l.link("sampler",this,t),this}}r([o],g.prototype,"targetNode",void 0),r([o],g.prototype,"sampler",void 0);class p extends c{constructor(){super(...arguments),this.propertyType=i.ANIMATION_SAMPLER,this.R="LINEAR",this.input=null,this.output=null}getInterpolation(){return this.R}setInterpolation(t){return this.R=t,this}getInput(){return this.input?this.input.getChild():null}setInput(t){return this.input=this.l.link("input",this,t),this}getOutput(){return this.output?this.output.getChild():null}setOutput(t){return this.output=this.l.link("output",this,t),this}}r([o],p.prototype,"input",void 0),r([o],p.prototype,"output",void 0);class m extends a{constructor(){super(...arguments),this.propertyType=i.BUFFER}getURI(){return this.I}setURI(t){return this.I=t,this}}class w extends a{constructor(){super(...arguments),this.propertyType=i.CAMERA,this.v="perspective"}getType(){return this.v}setType(t){return this.v=t,this}getZNear(){return this.C}setZNear(t){return this.C=t,this}getZFar(){return this._}setZFar(t){return this._=t,this}getAspectRatio(){return this.B}setAspectRatio(t){return this.B=t,this}getYFov(){return this.U}setYFov(t){return this.U=t,this}getXMag(){return this.k}setXMag(t){return this.k=t,this}getYMag(){return this.L}setYMag(t){return this.L=t,this}}class v extends c{constructor(t,e){super(t),this.P=e,this.P.addExtensionProperty(this)}dispose(){this.P.removeExtensionProperty(this),super.dispose()}p(t){if(!this.parentTypes.includes(t.propertyType))throw new Error(`Parent "${t.propertyType}" invalid for child "${this.propertyType}".`)}}class x{static createBufferFromDataURI(t){if("undefined"==typeof Buffer){const e=atob(t.split(",")[1]),s=new Uint8Array(e.length);for(let t=0;t<e.length;t++)s[t]=e.charCodeAt(t);return s.buffer}{const e=t.split(",")[1],s=t.indexOf("base64")>=0;return this.trim(Buffer.from(e,s?"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:e,byteLength:s}=t;return t.buffer.slice(e,e+s)}static concat(t){let e=0;for(const s of t)e+=s.byteLength;const s=new Uint8Array(e);let r=0;for(const e of t)s.set(new Uint8Array(e),r),r+=e.byteLength;return s.buffer}static pad(t,e=0){const s=this.padNumber(t.byteLength);if(s!==t.byteLength){const r=new Uint8Array(s);if(r.set(new Uint8Array(t)),0!==e)for(let i=t.byteLength;i<s;i++)r[i]=e;return r.buffer}return t}static padNumber(t){return 4*Math.ceil(t/4)}static equals(t,e){if(t===e)return!0;if(t.byteLength!==e.byteLength)return!1;const s=new DataView(t),r=new DataView(e);let i=t.byteLength;for(;i--;)if(s.getUint8(i)!==r.getUint8(i))return!1;return!0}}class A{static basename(t){return t.split(/[\\/]/).pop().split(/[.]/).shift()}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 T{static getSizeJPEG(t){let e,s;for(t=t.slice(4);t.length;){if(e=t.readUInt16BE(0),E(t,e),s=t[e+1],192===s||193===s||194===s)return[t.readUInt16BE(e+7),t.readUInt16BE(e+5)];t=t.slice(e+2)}throw new TypeError("Invalid JPG, no size found")}static getSizePNG(t){return"CgBI"===t.toString("ascii",12,16)?[t.readUInt32BE(32),t.readUInt32BE(36)]:[t.readUInt32BE(16),t.readUInt32BE(20)]}static mimeTypeToExtension(t){return"image/jpeg"===t?"jpg":t.split("/").pop()}static extensionToMimeType(t){return"jpg"===t?"image/jpeg":"image/"+t}}function E(t,e){if(e>t.length)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(255!==t[e])throw new TypeError("Invalid JPG, marker table corrupted")}class y{constructor(t){this.verbosity=t}debug(t){this.verbosity<=y.Verbosity.DEBUG&&console.debug(t)}info(t){this.verbosity<=y.Verbosity.INFO&&console.info(t)}warn(t){this.verbosity<=y.Verbosity.WARN&&console.warn(t)}error(t){this.verbosity<=y.Verbosity.ERROR&&console.error(t)}}y.Verbosity={SILENT:4,ERROR:3,WARN:2,INFO:1,DEBUG:0};const b="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",M=new Set,S=function(){let t="";for(let e=0;e<6;e++)t+=b.charAt(Math.floor(Math.random()*b.length));return t},N=function(){for(let t=0;t<999;t++){const t=S();if(!M.has(t))return M.add(t),t}};class R extends a{constructor(){super(...arguments),this.propertyType=i.TEXTURE,this.image=null,this.mimeType="",this.uri=""}getMimeType(){return this.mimeType}setMimeType(t){return this.mimeType=t,this}getURI(){return this.uri}setURI(t){return this.uri=t,this}getImage(){return this.image}setImage(t){return this.image=t,this}getSize(){let t;return t=this.mimeType?"image/png"===this.mimeType:this.uri.match(/\.png$/),t?T.getSizePNG(Buffer.from(this.image)):T.getSizeJPEG(Buffer.from(this.image))}}class I{constructor(){this.propertyType=i.TEXTURE_INFO,this.texCoord=0}getTexCoord(){return this.texCoord}setTexCoord(t){return this.texCoord=t,this}}class C{constructor(){this.propertyType=i.TEXTURE_SAMPLER,this.O=null,this.F=null,this.G=10497,this.j=10497}getMagFilter(){return this.O}setMagFilter(t){return this.O=t,this}getMinFilter(){return this.F}setMinFilter(t){return this.F=t,this}getWrapS(){return this.G}setWrapS(t){return this.G=t,this}getWrapT(){return this.j}setWrapT(t){return this.j=t,this}}C.TextureWrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},C.TextureMagFilter={NEAREST:9728,LINEAR:9729},C.TextureMinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};class _ extends n{constructor(){super(...arguments),this.textureInfo=new I,this.sampler=new C}}class B extends n{constructor(){super(...arguments),this.semantic=""}}class U extends n{}class k extends h{linkTexture(t,e,s){if(!s)return null;const r=new _(t,e,s);return this.registerLink(r),r}linkAttribute(t,e,s){if(!s)return null;const r=new B(t,e,s);return this.registerLink(r),r}linkIndex(t,e,s){if(!s)return null;const r=new U(t,e,s);return this.registerLink(r),r}}class L extends a{constructor(){super(...arguments),this.propertyType=i.MATERIAL,this.D="OPAQUE",this.$=.5,this.J=!1,this.V=[1,1,1,1],this.W=[0,0,0],this.Y=1,this.q=1,this.Z=1,this.X=1,this.baseColorTexture=null,this.emissiveTexture=null,this.normalTexture=null,this.occlusionTexture=null,this.metallicRoughnessTexture=null}getDoubleSided(){return this.J}setDoubleSided(t){return this.J=t,this}getAlphaMode(){return this.D}setAlphaMode(t){return this.D=t,this}getAlphaCutoff(){return this.$}setAlphaCutoff(t){return this.$=t,this}getBaseColorFactor(){return this.V}setBaseColorFactor(t){return this.V=t,this}getBaseColorTexture(){return this.baseColorTexture?this.baseColorTexture.getChild():null}getBaseColorTextureInfo(){return this.baseColorTexture?this.baseColorTexture.textureInfo:null}getBaseColorTextureSampler(){return this.baseColorTexture?this.baseColorTexture.sampler:null}setBaseColorTexture(t){return this.baseColorTexture=this.l.linkTexture("baseColorTexture",this,t),this}getEmissiveFactor(){return this.W}setEmissiveFactor(t){return this.W=t,this}getEmissiveTexture(){return this.emissiveTexture?this.emissiveTexture.getChild():null}getEmissiveTextureInfo(){return this.emissiveTexture?this.emissiveTexture.textureInfo:null}getEmissiveTextureSampler(){return this.emissiveTexture?this.emissiveTexture.sampler:null}setEmissiveTexture(t){return this.emissiveTexture=this.l.linkTexture("emissiveTexture",this,t),this}getNormalScale(){return this.Y}setNormalScale(t){return this.Y=t,this}getNormalTexture(){return this.normalTexture?this.normalTexture.getChild():null}getNormalTextureInfo(){return this.normalTexture?this.normalTexture.textureInfo:null}getNormalTextureSampler(){return this.normalTexture?this.normalTexture.sampler:null}setNormalTexture(t){return this.normalTexture=this.l.linkTexture("normalTexture",this,t),this}getOcclusionStrength(){return this.q}setOcclusionStrength(t){return this.q=t,this}getOcclusionTexture(){return this.occlusionTexture?this.occlusionTexture.getChild():null}getOcclusionTextureInfo(){return this.occlusionTexture?this.occlusionTexture.textureInfo:null}getOcclusionTextureSampler(){return this.occlusionTexture?this.occlusionTexture.sampler:null}setOcclusionTexture(t){return this.occlusionTexture=this.l.linkTexture("occlusionTexture",this,t),this}getRoughnessFactor(){return this.Z}setRoughnessFactor(t){return this.Z=t,this}getMetallicFactor(){return this.X}setMetallicFactor(t){return this.X=t,this}getMetallicRoughnessTexture(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.getChild():null}getMetallicRoughnessTextureInfo(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.textureInfo:null}getMetallicRoughnessTextureSampler(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.sampler:null}setMetallicRoughnessTexture(t){return this.metallicRoughnessTexture=this.l.linkTexture("metallicRoughnessTexture",this,t),this}}r([o],L.prototype,"baseColorTexture",void 0),r([o],L.prototype,"emissiveTexture",void 0),r([o],L.prototype,"normalTexture",void 0),r([o],L.prototype,"occlusionTexture",void 0),r([o],L.prototype,"metallicRoughnessTexture",void 0);class P extends a{constructor(){super(...arguments),this.propertyType=i.MESH,this.H=[],this.primitives=[]}addPrimitive(t){return this.addGraphChild(this.primitives,this.l.link("primitive",this,t))}removePrimitive(t){return this.removeGraphChild(this.primitives,t)}listPrimitives(){return this.primitives.map(t=>t.getChild())}getWeights(){return this.H}setWeights(t){return this.H=t,this}}r([u],P.prototype,"primitives",void 0);class O extends c{constructor(){super(...arguments),this.propertyType=i.PRIMITIVE,this.K=4,this.indices=null,this.attributes=[],this.targets=[],this.material=null}getIndices(){return this.indices?this.indices.getChild():null}setIndices(t){return this.indices=this.l.linkIndex("index",this,t),this}getAttribute(t){const e=this.attributes.find(e=>e.semantic===t);return e?e.getChild():null}setAttribute(t,e){const s=this.getAttribute(t);if(s&&this.removeGraphChild(this.attributes,s),!e)return this;const r=this.l.linkAttribute(t.toLowerCase(),this,e);return r.semantic=t,this.addGraphChild(this.attributes,r)}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.l.link("material",this,t),this}getMode(){return this.K}setMode(t){return this.K=t,this}listTargets(){return this.targets.map(t=>t.getChild())}addTarget(t){return this.addGraphChild(this.targets,this.l.link("target",this,t)),this}removeTarget(t){return this.removeGraphChild(this.targets,t)}}r([o],O.prototype,"indices",void 0),r([u],O.prototype,"attributes",void 0),r([u],O.prototype,"targets",void 0),r([o],O.prototype,"material",void 0);class F extends c{constructor(){super(...arguments),this.propertyType=i.PRIMITIVE_TARGET,this.attributes=[]}getAttribute(t){const e=this.attributes.find(e=>e.semantic===t);return e?e.getChild():null}setAttribute(t,e){const s=this.getAttribute(t);if(s&&this.removeGraphChild(this.attributes,s),!e)return this;const r=this.l.linkAttribute(t.toLowerCase(),this,e);return r.semantic=t,this.addGraphChild(this.attributes,r)}listAttributes(){return this.attributes.map(t=>t.getChild())}listSemantics(){return this.attributes.map(t=>t.semantic)}}r([u],F.prototype,"attributes",void 0);class G extends a{constructor(){super(...arguments),this.propertyType=i.NODE,this.tt=[0,0,0],this.et=[0,0,0,1],this.st=[1,1,1],this.H=[],this.camera=null,this.mesh=null,this.skin=null,this.children=[]}getTranslation(){return this.tt}getRotation(){return this.et}getScale(){return this.st}setTranslation(t){return this.tt=t,this}setRotation(t){return this.et=t,this}setScale(t){return this.st=t,this}addChild(t){const e=this.l.link("child",this,t);return this.addGraphChild(this.children,e)}removeChild(t){return this.removeGraphChild(this.children,t)}listChildren(){return this.children.map(t=>t.getChild())}getMesh(){return this.mesh?this.mesh.getChild():null}setMesh(t){return this.mesh=this.l.link("mesh",this,t),this}getCamera(){return this.camera?this.camera.getChild():null}setCamera(t){return this.camera=this.l.link("camera",this,t),this}getSkin(){return this.skin?this.skin.getChild():null}setSkin(t){return this.skin=this.l.link("skin",this,t),this}getWeights(){return this.H}setWeights(t){return this.H=t,this}}r([o],G.prototype,"camera",void 0),r([o],G.prototype,"mesh",void 0),r([o],G.prototype,"skin",void 0),r([u],G.prototype,"children",void 0);class j extends c{constructor(){super(...arguments),this.propertyType=i.ROOT,this.rt={generator:"glTF-Transform v0.4.0-alpha.3",version:"2.0"},this.it=new Set,this.scenes=[],this.nodes=[],this.cameras=[],this.skins=[],this.meshes=[],this.materials=[],this.textures=[],this.animations=[],this.accessors=[],this.buffers=[]}getAsset(){return this.rt}listExtensionsUsed(){return Array.from(this.it)}listExtensionsRequired(){return this.listExtensionsUsed().filter(t=>t.isRequired())}nt(t){if(this.it.has(t))throw new Error(`Extension "${t.extensionName}" is already enabled.`);return this.it.add(t),this}ht(t){return this.it.delete(t),this}ot(t){return this.addGraphChild(this.scenes,this.l.link("scene",this,t))}listScenes(){return this.scenes.map(t=>t.getChild())}ut(t){return this.addGraphChild(this.nodes,this.l.link("node",this,t))}listNodes(){return this.nodes.map(t=>t.getChild())}ct(t){return this.addGraphChild(this.cameras,this.l.link("camera",this,t))}listCameras(){return this.cameras.map(t=>t.getChild())}at(t){return this.addGraphChild(this.skins,this.l.link("skin",this,t))}listSkins(){return this.skins.map(t=>t.getChild())}lt(t){return this.addGraphChild(this.meshes,this.l.link("mesh",this,t))}listMeshes(){return this.meshes.map(t=>t.getChild())}dt(t){return this.addGraphChild(this.materials,this.l.link("material",this,t))}listMaterials(){return this.materials.map(t=>t.getChild())}ft(t){return this.addGraphChild(this.textures,this.l.link("texture",this,t))}listTextures(){return this.textures.map(t=>t.getChild())}gt(t){return this.addGraphChild(this.animations,this.l.link("animation",this,t))}listAnimations(){return this.animations.map(t=>t.getChild())}pt(t){return this.addGraphChild(this.accessors,this.l.link("accessor",this,t))}listAccessors(){return this.accessors.map(t=>t.getChild())}wt(t){return this.addGraphChild(this.buffers,this.l.link("buffer",this,t))}listBuffers(){return this.buffers.map(t=>t.getChild())}}r([u],j.prototype,"scenes",void 0),r([u],j.prototype,"nodes",void 0),r([u],j.prototype,"cameras",void 0),r([u],j.prototype,"skins",void 0),r([u],j.prototype,"meshes",void 0),r([u],j.prototype,"materials",void 0),r([u],j.prototype,"textures",void 0),r([u],j.prototype,"animations",void 0),r([u],j.prototype,"accessors",void 0),r([u],j.prototype,"buffers",void 0);class D extends a{constructor(){super(...arguments),this.propertyType=i.SCENE,this.nodes=[]}addNode(t){return this.addGraphChild(this.nodes,this.l.link("node",this,t))}removeNode(t){return this.removeGraphChild(this.nodes,t)}listNodes(){return this.nodes.map(t=>t.getChild())}}r([u],D.prototype,"nodes",void 0);class $ extends a{constructor(){super(...arguments),this.propertyType=i.SKIN,this.skeleton=null,this.inverseBindMatrices=null,this.joints=[]}getSkeleton(){return this.skeleton?this.skeleton.getChild():null}setSkeleton(t){return this.skeleton=this.l.link("skeleton",this,t),this}getInverseBindMatrices(){return this.inverseBindMatrices?this.inverseBindMatrices.getChild():null}setInverseBindMatrices(t){return this.inverseBindMatrices=this.l.link("inverseBindMatrices",this,t),this}addJoint(t){const e=this.l.link("joint",this,t);return this.addGraphChild(this.joints,e)}removeJoint(t){return this.removeGraphChild(this.joints,t)}listJoints(){return this.joints.map(t=>t.getChild())}}r([o],$.prototype,"skeleton",void 0),r([o],$.prototype,"inverseBindMatrices",void 0),r([u],$.prototype,"joints",void 0);class z{constructor(){this.graph=new k,this.root=new j(this.graph),this.logger=new y(y.Verbosity.INFO)}getRoot(){return this.root}getGraph(){return this.graph}getLogger(){return this.logger}setLogger(t){return this.logger=t,this}clone(){throw new Error("Not implemented.")}transform(...t){for(const e of t)e(this);return this}createExtension(t){return this.getRoot().listExtensionsUsed().find(e=>e.extensionName===t.EXTENSION_NAME)||new t(this)}createScene(t){const e=new D(this.graph,t);return this.root.ot(e),e}createNode(t){const e=new G(this.graph,t);return this.root.ut(e),e}createCamera(t){const e=new w(this.graph,t);return this.root.ct(e),e}createSkin(t){const e=new $(this.graph,t);return this.root.at(e),e}createMesh(t){const e=new P(this.graph,t);return this.root.lt(e),e}createPrimitive(){return new O(this.graph)}createPrimitiveTarget(t){return new F(this.graph,t)}createMaterial(t){const e=new L(this.graph,t);return this.root.dt(e),e}createTexture(t){const e=new R(this.graph,t);return this.root.ft(e),e}createAnimation(t){const e=new f(this.graph,t);return this.root.gt(e),e}createAnimationChannel(){return new g(this.graph)}createAnimationSampler(){return new p(this.graph)}createAccessor(t,e=null){e||(e=this.getRoot().listBuffers()[0]);const s=new l(this.graph,t).setBuffer(e);return this.root.pt(s),s}createBuffer(t){const e=new m(this.graph,t);return this.root.wt(e),e}}class J{constructor(t){this.doc=t,this.vt=!1,this.xt=new Set,t.getRoot().nt(this)}dispose(){this.doc.getRoot().ht(this);for(const t of this.xt)t.dispose()}isRequired(){return this.vt}setRequired(t){return this.vt=t,this}addExtensionProperty(t){return this.xt.add(t),this}removeExtensionProperty(t){return this.xt.delete(t),this}}class V{constructor(t){this.nativeDocument=t,this.buffers=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[]}}const W={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};class Y{static read(r,i){const{json:n}=r,h=new z;if("2.0"!==n.asset.version)throw new Error(`Unsupported glTF version: "${n.asset.version}".`);const o=new V(r);o.buffers=(n.buffers||[]).map(t=>{const e=h.createBuffer(t.name);return t.uri&&0!==t.uri.indexOf("__")&&e.setURI(t.uri),e}),o.bufferViewBuffers=(n.bufferViews||[]).map(t=>o.buffers[t.buffer]),o.accessors=(n.accessors||[]).map(t=>{const e=h.createAccessor(t.name,o.bufferViewBuffers[t.bufferView]);let s;return e.setType(t.type),s=void 0!==t.sparse?function(t,e){const s=W[t.componentType],r=l.getElementSize(t.type);let i;i=void 0!==t.bufferView?X(t,e).slice():new s(t.count*r);const n=t.sparse.count,h={...t,...t.sparse.indices,count:n,type:"SCALAR"},o={...t,...t.sparse.values,count:n},u=X(h,e),c=X(o,e);for(let t=0;t<h.count;t++)for(let e=0;e<r;e++)i[u[t]*r+e]=c[t*r+e];return i}(t,r):X(t,r).slice(),void 0!==t.normalized&&e.setNormalized(t.normalized),e.setArray(s),e});const u=n.textures||[];o.textures=(n.images||[]).map(t=>{const e=h.createTexture(t.name);if(void 0!==t.bufferView){const s=n.bufferViews[t.bufferView],i=r.json.buffers[s.buffer],h=s.byteOffset||0,o=(i.uri?r.resources[i.uri]:r.resources["At"]).slice(h,h+s.byteLength);e.setImage(o)}else void 0!==t.uri&&(e.setImage(r.resources[t.uri]),0!==t.uri.indexOf("__")&&e.setURI(t.uri));if(void 0!==t.mimeType)e.setMimeType(t.mimeType);else if(t.uri){const s=A.extension(t.uri);e.setMimeType(T.extensionToMimeType(s))}return e}),o.materials=(n.materials||[]).map(t=>{const e=h.createMaterial(t.name);void 0!==t.alphaMode&&e.setAlphaMode(t.alphaMode),void 0!==t.alphaCutoff&&e.setAlphaCutoff(t.alphaCutoff),void 0!==t.doubleSided&&e.setDoubleSided(t.doubleSided);const s=t.pbrMetallicRoughness||{};if(void 0!==s.baseColorFactor&&e.setBaseColorFactor(s.baseColorFactor),void 0!==t.emissiveFactor&&e.setEmissiveFactor(t.emissiveFactor),void 0!==s.metallicFactor&&e.setMetallicFactor(s.metallicFactor),void 0!==s.roughnessFactor&&e.setRoughnessFactor(s.roughnessFactor),void 0!==s.baseColorTexture){const t=s.baseColorTexture;e.setBaseColorTexture(o.textures[u[t.index].source]),q(e.getBaseColorTextureInfo(),t),Z(e.getBaseColorTextureSampler(),t,r)}if(void 0!==t.emissiveTexture){const s=t.emissiveTexture;e.setEmissiveTexture(o.textures[u[s.index].source]),q(e.getEmissiveTextureInfo(),s),Z(e.getEmissiveTextureSampler(),s,r)}if(void 0!==t.normalTexture){const s=t.normalTexture;e.setNormalTexture(o.textures[u[s.index].source]),q(e.getNormalTextureInfo(),s),Z(e.getNormalTextureSampler(),s,r),void 0!==t.normalTexture.scale&&e.setNormalScale(t.normalTexture.scale)}if(void 0!==t.occlusionTexture){const s=t.occlusionTexture;e.setOcclusionTexture(o.textures[u[s.index].source]),q(e.getOcclusionTextureInfo(),s),Z(e.getOcclusionTextureSampler(),s,r),void 0!==t.occlusionTexture.strength&&e.setOcclusionStrength(t.occlusionTexture.strength)}if(void 0!==s.metallicRoughnessTexture){const t=s.metallicRoughnessTexture;e.setMetallicRoughnessTexture(o.textures[u[t.index].source]),q(e.getMetallicRoughnessTextureInfo(),t),Z(e.getMetallicRoughnessTextureSampler(),t,r)}return e}),o.meshes=(n.meshes||[]).map(t=>{const e=h.createMesh(t.name);return void 0!==t.weights&&e.setWeights(t.weights),t.primitives.forEach(s=>{const r=h.createPrimitive();void 0!==s.material&&r.setMaterial(o.materials[s.material]),void 0!==s.mode&&r.setMode(s.mode);for(const[t,e]of Object.entries(s.attributes||{}))r.setAttribute(t,o.accessors[e]);void 0!==s.indices&&r.setIndices(o.accessors[s.indices]);const i=t.extras&&t.extras.targetNames||[];(s.targets||[]).forEach((t,e)=>{const s=i[e]||e.toString(),n=h.createPrimitiveTarget(s);for(const[e,s]of Object.entries(t))n.setAttribute(e,o.accessors[s]);r.addTarget(n)}),e.addPrimitive(r)}),e}),o.cameras=(n.cameras||[]).map(t=>{const e=h.createCamera(t.name).setType(t.type);return"perspective"===t.type?e.setZNear(t.perspective.znear).setZFar(t.perspective.zfar).setYFov(t.perspective.yfov).setAspectRatio(t.perspective.aspectRatio):e.setZNear(t.orthographic.znear).setZFar(t.orthographic.zfar).setXMag(t.orthographic.xmag).setYMag(t.orthographic.ymag),e});const c=n.nodes||[];o.nodes=c.map(r=>{const i=h.createNode(r.name);return void 0!==r.translation&&i.setTranslation(r.translation),void 0!==r.rotation&&i.setRotation(r.rotation),void 0!==r.scale&&i.setScale(r.scale),void 0!==r.matrix&&(i.setTranslation(t([],r.matrix)),i.setRotation(e([],r.matrix)),i.setScale(s([],r.matrix))),void 0!==r.weights&&i.setWeights(r.weights),i}),o.skins=(n.skins||[]).map(t=>{const e=h.createSkin(t.name);void 0!==t.inverseBindMatrices&&e.setInverseBindMatrices(o.accessors[t.inverseBindMatrices]),void 0!==t.skeleton&&e.setSkeleton(o.nodes[t.skeleton]);for(const s of t.joints)e.addJoint(o.nodes[s]);return e}),c.map((t,e)=>{const s=o.nodes[e];(t.children||[]).forEach(t=>s.addChild(o.nodes[t])),void 0!==t.mesh&&s.setMesh(o.meshes[t.mesh]),void 0!==t.camera&&s.setCamera(o.cameras[t.camera]),void 0!==t.skin&&s.setSkin(o.skins[t.skin])}),o.animations=(n.animations||[]).map(t=>{const e=h.createAnimation(t.name),s=(t.samplers||[]).map(t=>{const s=h.createAnimationSampler().setInput(o.accessors[t.input]).setOutput(o.accessors[t.output]).setInterpolation(t.interpolation||"LINEAR");return e.addSampler(s),s});return(t.channels||[]).forEach(t=>{const r=h.createAnimationChannel().setSampler(s[t.sampler]).setTargetNode(o.nodes[t.target.node]).setTargetPath(t.target.path);e.addChannel(r)}),e}),o.scenes=(n.scenes||[]).map(t=>{const e=h.createScene(t.name);return(t.nodes||[]).map(t=>o.nodes[t]).forEach(t=>e.addNode(t)),e});const a=n.extensionsUsed||[],d=n.extensionsRequired||[];for(const t of i.extensions)a.includes(t.EXTENSION_NAME)&&h.createExtension(t).setRequired(d.includes(t.EXTENSION_NAME)).read(o);return h}}function q(t,e){void 0!==e.texCoord&&t.setTexCoord(e.texCoord)}function Z(t,e,s){const r=s.json.textures[e.index];if(void 0===r.sampler)return;const i=s.json.samplers[r.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)}function X(t,e){const s=e.json.bufferViews[t.bufferView],r=e.json.buffers[s.buffer],i=r.uri?e.resources[r.uri]:e.resources["At"],n=W[t.componentType],h=l.getElementSize(t.type);if(void 0!==s.byteStride&&s.byteStride!==h*n.BYTES_PER_ELEMENT)return function(t,e){const s=e.json.bufferViews[t.bufferView],r=e.json.buffers[s.buffer],i=r.uri?e.resources[r.uri]:e.resources["At"],n=W[t.componentType],h=l.getElementSize(t.type),o=n.BYTES_PER_ELEMENT,u=t.byteOffset||0,c=new n(t.count*h),a=new DataView(i,s.byteOffset,s.byteLength),d=s.byteStride;for(let e=0;e<t.count;e++)for(let s=0;s<h;s++){const r=u+e*d+s*o;let i;switch(t.componentType){case 5126:i=a.getFloat32(r,!0);break;case 5125:i=a.getUint32(r,!0);break;case 5123:i=a.getUint16(r,!0);break;case 5121:i=a.getUint8(r);break;case 5122:i=a.getInt16(r,!0);break;case 5120:i=a.getInt8(r);break;default:throw new Error(`Unexpected componentType "${t.componentType}".`)}c[e*h+s]=i}return c}(t,e);const o=(s.byteOffset||0)+(t.byteOffset||0);switch(t.componentType){case 5126:return new Float32Array(i,o,t.count*h);case 5125:return new Uint32Array(i,o,t.count*h);case 5123:return new Uint16Array(i,o,t.count*h);case 5121:return new Uint8Array(i,o,t.count*h);case 5122:return new Int16Array(i,o,t.count*h);case 5120:return new Int8Array(i,o,t.count*h);default:throw new Error(`Unexpected componentType "${t.componentType}".`)}}class H{constructor(t,e){this.nativeDocument=t,this.options=e,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.samplerDefIndexMap=new Map,this.imageData=[]}createTextureInfoDef(t,e,s){const r={magFilter:s.getMagFilter()||void 0,minFilter:s.getMinFilter()||void 0,wrapS:s.getWrapS(),wrapT:s.getWrapT()},i=JSON.stringify(r);this.samplerDefIndexMap.has(i)||(this.samplerDefIndexMap.set(i,this.nativeDocument.json.samplers.length),this.nativeDocument.json.samplers.push(r));const n={source:this.imageIndexMap.get(t),sampler:this.samplerDefIndexMap.get(i)},h=JSON.stringify(n);return this.textureDefIndexMap.has(h)||(this.textureDefIndexMap.set(h,this.nativeDocument.json.textures.length),this.nativeDocument.json.textures.push(n)),{index:this.textureDefIndexMap.get(h),texCoord:e.getTexCoord()}}createPropertyDef(t){const e={};return t.getName()&&(e.name=t.getName()),Object.keys(t.getExtras()).length>0&&(e.extras=t.getExtras()),e}createAccessorDef(t){const e=this.createPropertyDef(t);return e.type=t.getType(),e.componentType=t.getComponentType(),e.count=t.getCount(),t.getMax(e.max=[]),t.getMin(e.min=[]),e.normalized=t.getNormalized(),e}createImageData(t,e,s){if(this.options.isGLB)this.imageData.push(e),t.bufferView=this.nativeDocument.json.bufferViews.length,this.nativeDocument.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:e.byteLength});else{const r=T.mimeTypeToExtension(s.getMimeType());t.uri=this.imageURIGenerator.createURI(s,r),this.nativeDocument.resources[t.uri]=e}}}class K{constructor(t,e){this.multiple=t,this.basename=e,this.counter=1}createURI(t,e){return t.getURI()?t.getURI():this.multiple?`${this.basename}_${this.counter++}.${e}`:`${this.basename}.${e}`}}class Q{static write(t,e){const s=t.getRoot(),r={json:{asset:s.getAsset()},resources:{}},i=r.json,n=new H(r,e),h=s.listBuffers().length,o=s.listTextures().length;function u(t,e,s,r){const h=[];let o=0;for(const e of t){const t=n.createAccessorDef(e);t.bufferView=i.bufferViews.length;const s=x.pad(e.getArray().buffer);t.byteOffset=o,o+=s.byteLength,h.push(s),n.accessorIndexMap.set(e,i.accessors.length),i.accessors.push(t)}const u={buffer:e,byteOffset:s,byteLength:x.concat(h).byteLength};return r&&(u.target=r),i.bufferViews.push(u),{buffers:h,byteLength:o}}function c(t,e,s){const r=t[0].getCount();let h=0;for(const e of t){const t=n.createAccessorDef(e);t.bufferView=i.bufferViews.length,t.byteOffset=h;const s=e.getElementSize(),r=e.getComponentSize();h+=x.padNumber(s*r),n.accessorIndexMap.set(e,i.accessors.length),i.accessors.push(t)}const o=r*h,u=new ArrayBuffer(o),c=new DataView(u);for(let e=0;e<r;e++){let s=0;for(const r of t){const t=r.getElementSize(),i=r.getComponentSize(),n=r.getComponentType(),o=r.getArray();for(let r=0;r<t;r++){const u=e*h+s+r*i,a=o[e*t+r];switch(n){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: "+n)}}s+=x.padNumber(t*i)}}return i.bufferViews.push({buffer:e,byteOffset:s,byteLength:o,byteStride:h,target:34962}),{byteLength:o,buffers:[u]}}n.bufferURIGenerator=new K(h>1,e.basename),n.imageURIGenerator=new K(o>1,e.basename),n.logger=t.getLogger();const a=new Map;for(const e of t.getGraph().getLinks()){if(e.getParent()===s)continue;const t=e.getChild();if(t instanceof l){const s=a.get(t)||[];s.push(e),a.set(t,s)}}return i.accessors=[],i.bufferViews=[],i.samplers=[],i.textures=[],i.images=s.listTextures().map((t,e)=>{const s=n.createPropertyDef(t);return t.getMimeType()&&(s.mimeType=t.getMimeType()),t.getImage()&&n.createImageData(s,t.getImage(),t),n.imageIndexMap.set(t,e),s}),i.buffers=[],s.listBuffers().forEach(t=>{const s=n.createPropertyDef(t),h=new Map,o=new Set,d=new Set,f=t.listParents().filter(t=>!(t instanceof j));for(const t of f){if(!(t instanceof l))throw new Error("Unimplemented buffer reference: "+t);let e=!1,s=!1,r=!1;const i=a.get(t)||[];for(const t of i)t instanceof B?e=!0:t instanceof U?s=!0:r=!0;if(e||s||r||(r=!0),!e||s||r)if(!s||e||r){if(!r||e||s)throw new Error("Attribute or index accessors must be used only for that purpose.");d.add(t)}else o.add(t);else{const e=i[0].getParent(),s=h.get(e)||new Set;s.add(t),h.set(e,s)}}const g=[],p=i.buffers.length;let m,w=0;if(o.size){const t=u(Array.from(o),p,w,34963);w+=t.byteLength,g.push(...t.buffers)}for(const t of Array.from(h.values()))if(t.size){const e=c(Array.from(t),p,w);w+=e.byteLength,g.push(...e.buffers)}if(d.size){const t=u(Array.from(d),p,w);w+=t.byteLength,g.push(...t.buffers)}if(n.imageData.length)for(let t=0;t<n.imageData.length;t++)i.bufferViews[i.images[t].bufferView].byteOffset=w,w+=n.imageData[t].byteLength,g.push(n.imageData[t]);w?(e.isGLB?m="__glb.bin":(m=n.bufferURIGenerator.createURI(t,"bin"),s.uri=m),s.byteLength=w,r.resources[m]=x.concat(g),i.buffers.push(s)):n.logger.warn(`@gltf-transform/core: Skipping empty buffer, "${t.getName()}".`)}),i.materials=s.listMaterials().map((t,e)=>{const s=n.createPropertyDef(t);if(s.alphaMode=t.getAlphaMode(),"MASK"===t.getAlphaMode()&&(s.alphaCutoff=t.getAlphaCutoff()),s.doubleSided=t.getDoubleSided(),s.pbrMetallicRoughness={},s.pbrMetallicRoughness.baseColorFactor=t.getBaseColorFactor(),s.emissiveFactor=t.getEmissiveFactor(),s.pbrMetallicRoughness.roughnessFactor=t.getRoughnessFactor(),s.pbrMetallicRoughness.metallicFactor=t.getMetallicFactor(),t.getBaseColorTexture()){const e=t.getBaseColorTexture(),r=t.getBaseColorTextureInfo(),i=t.getBaseColorTextureSampler();s.pbrMetallicRoughness.baseColorTexture=n.createTextureInfoDef(e,r,i)}if(t.getEmissiveTexture()){const e=t.getEmissiveTexture(),r=t.getEmissiveTextureInfo(),i=t.getEmissiveTextureSampler();s.emissiveTexture=n.createTextureInfoDef(e,r,i)}if(t.getNormalTexture()){const e=t.getNormalTexture(),r=t.getNormalTextureInfo(),i=t.getNormalTextureSampler(),h=n.createTextureInfoDef(e,r,i);1!==t.getNormalScale()&&(h.scale=t.getNormalScale()),s.normalTexture=h}if(t.getOcclusionTexture()){const e=t.getOcclusionTexture(),r=t.getOcclusionTextureInfo(),i=t.getOcclusionTextureSampler(),h=n.createTextureInfoDef(e,r,i);1!==t.getOcclusionStrength()&&(h.strength=t.getOcclusionStrength()),s.occlusionTexture=h}if(t.getMetallicRoughnessTexture()){const e=t.getMetallicRoughnessTexture(),r=t.getMetallicRoughnessTextureInfo(),i=t.getMetallicRoughnessTextureSampler();s.pbrMetallicRoughness.metallicRoughnessTexture=n.createTextureInfoDef(e,r,i)}return n.materialIndexMap.set(t,e),s}),i.meshes=s.listMeshes().map((t,e)=>{const s=n.createPropertyDef(t);let r;return s.primitives=t.listPrimitives().map(t=>{const e={attributes:{}};e.material=n.materialIndexMap.get(t.getMaterial()),e.mode=t.getMode(),t.getIndices()&&(e.indices=n.accessorIndexMap.get(t.getIndices()));for(const s of t.listSemantics())e.attributes[s]=n.accessorIndexMap.get(t.getAttribute(s));for(const s of t.listTargets()){const t={};for(const e of s.listSemantics())t[e]=n.accessorIndexMap.get(s.getAttribute(e));e.targets=e.targets||[],e.targets.push(t)}return t.listTargets().length&&!r&&(r=t.listTargets().map(t=>t.getName())),e}),t.getWeights().length&&(s.weights=t.getWeights()),r&&(s.extras=s.extras||{},s.extras.targetNames=r),n.meshIndexMap.set(t,e),s}),i.cameras=s.listCameras().map((t,e)=>{const s=n.createPropertyDef(t);return s.type=t.getType(),"perspective"===s.type?s.perspective={znear:t.getZNear(),zfar:t.getZFar(),yfov:t.getYFov(),aspectRatio:t.getAspectRatio()}:s.orthographic={znear:t.getZNear(),zfar:t.getZFar(),xmag:t.getXMag(),ymag:t.getYMag()},n.cameraIndexMap.set(t,e),s}),i.nodes=s.listNodes().map((t,e)=>{const s=n.createPropertyDef(t);return s.translation=t.getTranslation(),s.rotation=t.getRotation(),s.scale=t.getScale(),t.getWeights().length&&(s.weights=t.getWeights()),n.nodeIndexMap.set(t,e),s}),i.skins=s.listSkins().map((t,e)=>{const s=n.createPropertyDef(t);return t.getInverseBindMatrices()&&(s.inverseBindMatrices=n.accessorIndexMap.get(t.getInverseBindMatrices())),t.getSkeleton()&&(s.skeleton=n.nodeIndexMap.get(t.getSkeleton())),s.joints=t.listJoints().map(t=>n.nodeIndexMap.get(t)),n.skinIndexMap.set(t,e),s}),s.listNodes().forEach((t,e)=>{const s=i.nodes[e];t.getMesh()&&(s.mesh=n.meshIndexMap.get(t.getMesh())),t.getCamera()&&(s.camera=n.cameraIndexMap.get(t.getCamera())),t.getSkin()&&(s.skin=n.skinIndexMap.get(t.getSkin())),t.listChildren().length>0&&(s.children=t.listChildren().map(t=>n.nodeIndexMap.get(t)))}),i.animations=s.listAnimations().map(t=>{const e=n.createPropertyDef(t),s=new Map;return e.samplers=t.listSamplers().map((t,e)=>{const r=n.createPropertyDef(t);return r.input=n.accessorIndexMap.get(t.getInput()),r.output=n.accessorIndexMap.get(t.getOutput()),r.interpolation=t.getInterpolation(),s.set(t,e),r}),e.channels=t.listChannels().map(t=>{const e=n.createPropertyDef(t);return e.sampler=s.get(t.getSampler()),e.target={node:n.nodeIndexMap.get(t.getTargetNode()),path:t.getTargetPath()},e}),e}),i.scenes=s.listScenes().map(t=>{const e=n.createPropertyDef(t);return e.nodes=t.listNodes().map(t=>n.nodeIndexMap.get(t)),e}),i.extensionsUsed=s.listExtensionsUsed().map(t=>t.extensionName),i.extensionsRequired=s.listExtensionsRequired().map(t=>t.extensionName),s.listExtensionsUsed().forEach(t=>t.write(n)),function(t){const e=[];for(const s in t){const r=t[s];Array.isArray(r)&&0===r.length?e.push(s):null!==r&&""!==r||e.push(r)}for(const s of e)delete t[s]}(i),r}}class tt{constructor(){this.it=[]}registerExtensions(t){return this.it.push(...t),this}createDocument(t){return Y.read(t,{extensions:this.it})}createNativeDocument(t,e){if(e.isGLB&&1!==t.getRoot().listBuffers().length)throw new Error("GLB must have exactly 1 buffer.");return Q.write(t,e)}unpackGLB(t){const e=new Uint32Array(t,0,3);if(1179937895!==e[0])throw new Error("Invalid glTF asset.");if(2!==e[1])throw new Error(`Unsupported glTF binary version, "${e[1]}".`);const s=new Uint32Array(t,12,2),r=s[0],i=new Uint32Array(t,20+r,2);if(1313821514!==s[1]||5130562!==i[1])throw new Error("Unexpected GLB layout.");const n=x.decodeText(t.slice(20,20+r)),h=JSON.parse(n),o=20+r+8,u=t.slice(o,o+i[0]);return this.createDocument({json:h,resources:{At:u}})}packGLB(t){const{json:e,resources:s}=this.createNativeDocument(t,{basename:"",isGLB:!0}),r=JSON.stringify(e),i=x.pad(x.encodeText(r),32),n=new Uint32Array([i.byteLength,1313821514]).buffer,h=x.concat([n,i]),o=x.pad(Object.values(s)[0],0),u=new Uint32Array([o.byteLength,5130562]).buffer,c=x.concat([u,o]),a=new Uint32Array([1179937895,2,12+h.byteLength+c.byteLength]).buffer;return x.concat([a,h,c])}}class et extends tt{constructor(t,e){super(),this.fs=t,this.path=e}read(t){return t.match(/\.glb$/)?this.readGLB(t):this.readGLTF(t)}write(t,e){t.match(/\.glb$/)?this.writeGLB(t,e):this.writeGLTF(t,e)}readGLB(t){const e=this.fs.readFileSync(t),s=x.trim(e);return this.unpackGLB(s)}readGLTF(t){const e=this.path.dirname(t),s={json:JSON.parse(this.fs.readFileSync(t,"utf8")),resources:{}};return[...s.json.images||[],...s.json.buffers||[]].forEach(t=>{if(t.uri&&!t.uri.match(/data:/)){const r=this.path.resolve(e,t.uri);s.resources[t.uri]=x.trim(this.fs.readFileSync(r))}else{const e=`__${N()}.${A.extension(t.uri)}`;s.resources[e]=x.createBufferFromDataURI(t.uri),t.uri=e}}),Y.read(s,{extensions:this.it})}writeGLTF(t,e){const s={basename:A.basename(t),isGLB:!1},{json:r,resources:i}=Q.write(e,s),{fs:n,path:h}=this,o=h.dirname(t);n.writeFileSync(t,JSON.stringify(r,null,2)),Object.keys(i).forEach(t=>{const e=Buffer.from(i[t]);n.writeFileSync(h.join(o,t),e)})}writeGLB(t,e){const s=Buffer.from(this.packGLB(e));this.fs.writeFileSync(t,s)}}class st extends tt{constructor(t){super(),this.fetchConfig=t}read(t){return t.match(/\.glb$/)?this.readGLB(t):this.readGLTF(t)}readGLTF(t){const e={json:{},resources:{}};return fetch(t,this.fetchConfig).then(t=>t.json()).then(t=>{e.json=t;const s=[...t.images,...t.buffers].map(t=>{if(t.uri)return fetch(t.uri,this.fetchConfig).then(t=>t.arrayBuffer()).then(s=>{e.resources[t.uri]=s})});return Promise.all(s).then(()=>this.createDocument(e))})}readGLB(t){return fetch(t,this.fetchConfig).then(t=>t.arrayBuffer()).then(t=>this.unpackGLB(t))}}export{l as Accessor,f as Animation,g as AnimationChannel,p as AnimationSampler,m as Buffer,x as BufferUtils,w as Camera,z as Document,J as Extension,v as ExtensionProperty,A as FileUtils,h as Graph,T as ImageUtils,y as Logger,L as Material,P as Mesh,G as Node,et as NodeIO,O as Primitive,F as PrimitiveTarget,c as Property,i as PropertyType,V as ReaderContext,j as Root,D as Scene,$ as Skin,R as Texture,I as TextureInfo,C as TextureSampler,st as WebIO,H as WriterContext,N as uuid};
//# sourceMappingURL=core.modern.js.map

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

!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("gl-matrix/mat4")):"function"==typeof define&&define.amd?define(["exports","gl-matrix/mat4"],n):n((t=t||self).core={},t.mat4)}(this,function(t,n){function r(){return(r=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function i(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}function u(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=t[r];return i}function e(t){var n=0;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=function(t,n){if(t){if("string"==typeof t)return u(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,void 0):void 0}}(t)))return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}function s(t,n,r,i){var u,e=arguments.length,s=e<3?n:null===i?i=Object.getOwnPropertyDescriptor(n,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,n,r,i);else for(var o=t.length-1;o>=0;o--)(u=t[o])&&(s=(e<3?u(s):e>3?u(n,r,s):u(n,r))||s);return e>3&&s&&Object.defineProperty(n,r,s),s}var o;(o=t.PropertyType||(t.PropertyType={})).ACCESSOR="Accessor",o.ANIMATION="Animation",o.ANIMATION_CHANNEL="AnimationChannel",o.ANIMATION_SAMPLER="AnimationSampler",o.BUFFER="Buffer",o.CAMERA="Camera",o.MATERIAL="Material",o.MESH="Mesh",o.PRIMITIVE="Primitive",o.PRIMITIVE_TARGET="PrimitiveTarget",o.NODE="Node",o.ROOT="Root",o.SCENE="Scene",o.SKIN="Skin",o.TEXTURE="Texture",o.TEXTURE_INFO="TextureInfo",o.TEXTURE_SAMPLER="TextureSampler";var h=function(){function t(t,n,r){if(this.t=t,this.i=n,this.u=r,this.s=!1,this.o=[],!n.canLink(r))throw new Error("Cannot link disconnected graphs/documents.")}var n=t.prototype;return n.getName=function(){return this.t},n.getParent=function(){return this.i},n.getChild=function(){return this.u},n.setChild=function(t){return this.u=t,this},n.dispose=function(){this.s||(this.s=!0,this.o.forEach(function(t){return t()}),this.o.length=0)},n.onDispose=function(t){return this.o.push(t),this},n.isDisposed=function(){return this.s},t}(),f=function(){function t(){this.h=[]}var n=t.prototype;return n.getLinks=function(){return this.h},n.listParents=function(t){return this.h.filter(function(n){return n.getChild()===t}).map(function(t){return t.getParent()})},n.listChildren=function(t){return this.h.filter(function(n){return n.getParent()===t}).map(function(t){return t.getChild()})},n.disconnectChildren=function(t){return this.h.filter(function(n){return n.getParent()===t}).forEach(function(t){return t.dispose()}),this},n.disconnectParents=function(t,n){var r=this.h.filter(function(n){return n.getChild()===t});return n&&(r=r.filter(function(t){return n(t.getParent())})),r.forEach(function(t){return t.dispose()}),this},n.link=function(t,n,r){if(!r)return null;var i=new h(t,n,r);return this.registerLink(i),i},n.registerLink=function(t){var n=this;return this.h.push(t),t.onDispose(function(){return n.unlink(t)}),t},n.unlink=function(t){return this.h=this.h.filter(function(n){return n!==t}),this},t}();function c(t,n){Object.defineProperty(t,n,{get:function(){return this["__"+n]},set:function(t){var r=this,i=this["__"+n];i&&!Array.isArray(i)&&i.dispose(),t&&!Array.isArray(t)&&t.onDispose(function(){r["__"+n]=null}),this["__"+n]=t},enumerable:!0})}function a(t,n){}var v=function(t){function n(n,r){var i;return void 0===r&&(r=""),(i=t.call(this,n)||this).t="",i.v={},i.t=r,i}i(n,t);var r=n.prototype;return r.getName=function(){return this.t},r.setName=function(t){return this.t=t,this},r.getExtras=function(){return this.v},r.setExtras=function(t){return this.v=t,this},r.clone=function(){throw new Error("Not implemented.")},r.detach=function(){return this.l.disconnectParents(this,function(t){return"Root"!==t.propertyType}),this},r.listParents=function(){return this.listGraphParents()},n}(function(){function t(t){this.s=!1,this.l=t}var n=t.prototype;return n.canLink=function(t){return this.l===t.l},n.isDisposed=function(){return this.s},n.dispose=function(){this.l.disconnectChildren(this),this.l.disconnectParents(this),this.s=!0},n.detach=function(){return this.l.disconnectParents(this),this},n.swap=function(t,n){var r=this;return this.l.getLinks().filter(function(n){return n.getParent()===r&&n.getChild()===t}).forEach(function(t){return t.setChild(n)}),this},n.addGraphChild=function(t,n){return t.push(n),n.onDispose(function(){var r=t.filter(function(t){return t!==n});t.length=0,t.push.apply(t,r)}),this},n.removeGraphChild=function(t,n){return t.filter(function(t){return t.getChild()===n}).forEach(function(t){return t.dispose()}),this},n.listGraphParents=function(){return this.l.listParents(this)},t}()),l=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).extensions=[],n}i(n,t);var r=n.prototype;return r.getExtension=function(t){var n=t.EXTENSION_NAME,r=this.extensions.find(function(t){return t.getChild().extensionName===n});return r?r.getChild():null},r.setExtension=function(t,n){var r=this.getExtension(t);return r&&this.removeGraphChild(this.extensions,r),n?(n.p(this),this.addGraphChild(this.extensions,this.l.link(n.extensionName,this,n))):this},r.listExtensions=function(){return this.extensions.map(function(t){return t.getChild()})},n}(v);s([a],l.prototype,"extensions",void 0);var d=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ACCESSOR,r.A=null,r.m="SCALAR",r.T=null,r.g=!1,r.M=w,r.S=w,r.buffer=null,r}i(r,n),r.getElementSize=function(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)}},r.getComponentSize=function(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)}};var u=r.prototype;return u.getMinNormalized=function(t){var n=this.getElementSize();this.getMin(t);for(var r=0;r<n;r++)t[r]=this.S(t[r]);return t},u.getMin=function(t){for(var n=this.getCount(),r=this.getElementSize(),i=0;i<r;i++)t[i]=Infinity;for(var u=0;u<n*r;u+=r)for(var e=0;e<r;e++){var s=this.A[u+e];Number.isFinite(s)&&(t[e]=Math.min(t[e],s))}return t},u.getMaxNormalized=function(t){var n=this.getElementSize();this.getMax(t);for(var r=0;r<n;r++)t[r]=this.S(t[r]);return t},u.getMax=function(t){for(var n=this.getCount(),r=this.getElementSize(),i=0;i<r;i++)t[i]=-Infinity;for(var u=0;u<n*r;u+=r)for(var e=0;e<r;e++){var s=this.A[u+e];Number.isFinite(s)&&(t[e]=Math.max(t[e],s))}return t},u.getCount=function(){return this.A.length/this.getElementSize()},u.getType=function(){return this.m},u.setType=function(t){return this.m=t,this},u.getElementSize=function(){return r.getElementSize(this.m)},u.getComponentSize=function(){return this.A.BYTES_PER_ELEMENT},u.getComponentType=function(){return this.T},u.getNormalized=function(){return this.g},u.setNormalized=function(t){var n=this;return this.g=t,t?(this.S=function(t){return function(t,n){switch(n){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)}}(t,n.T)},this.M=function(t){return function(t,n){switch(n){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)}}(t,n.T)}):(this.S=w,this.M=w),this},u.getScalar=function(t){var n=this.getElementSize();return this.S(this.A[t*n])},u.setScalar=function(t,n){return this.A[t*this.getElementSize()]=this.M(n),this},u.getElement=function(t,n){for(var r=this.getElementSize(),i=0;i<r;i++)n[i]=this.S(this.A[t*r+i]);return n},u.setElement=function(t,n){for(var r=this.getElementSize(),i=0;i<r;i++)this.A[t*r+i]=this.M(n[i]);return this},u.getBuffer=function(){return this.buffer.getChild()},u.setBuffer=function(t){return this.buffer=this.l.link("buffer",this,t),this},u.getArray=function(){return this.A},u.setArray=function(t){return this.T=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.A=t,this},u.getByteLength=function(){return this.A.byteLength},r}(l);function w(t){return t}d.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT3:"MAT3",MAT4:"MAT4"},d.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},s([c],d.prototype,"buffer",void 0);var p=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ANIMATION,r.channels=[],r.samplers=[],r}i(r,n);var u=r.prototype;return u.addChannel=function(t){var n=this.l.link("channel",this,t);return this.addGraphChild(this.channels,n)},u.removeChannel=function(t){return this.removeGraphChild(this.channels,t)},u.listChannels=function(){return this.channels.map(function(t){return t.getChild()})},u.addSampler=function(t){var n=this.l.link("sampler",this,t);return this.addGraphChild(this.samplers,n)},u.removeSampler=function(t){return this.removeGraphChild(this.samplers,t)},u.listSamplers=function(){return this.samplers.map(function(t){return t.getChild()})},r}(l);s([a],p.prototype,"channels",void 0),s([a],p.prototype,"samplers",void 0);var A=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ANIMATION_CHANNEL,r.R=null,r.targetNode=null,r.sampler=null,r}i(r,n);var u=r.prototype;return u.getTargetPath=function(){return this.R},u.setTargetPath=function(t){return this.R=t,this},u.getTargetNode=function(){return this.targetNode?this.targetNode.getChild():null},u.setTargetNode=function(t){return this.targetNode=this.l.link("target.node",this,t),this},u.getSampler=function(){return this.sampler?this.sampler.getChild():null},u.setSampler=function(t){return this.sampler=this.l.link("sampler",this,t),this},r}(v);s([c],A.prototype,"targetNode",void 0),s([c],A.prototype,"sampler",void 0);var y=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ANIMATION_SAMPLER,r.N="LINEAR",r.input=null,r.output=null,r}i(r,n);var u=r.prototype;return u.getInterpolation=function(){return this.N},u.setInterpolation=function(t){return this.N=t,this},u.getInput=function(){return this.input?this.input.getChild():null},u.setInput=function(t){return this.input=this.l.link("input",this,t),this},u.getOutput=function(){return this.output?this.output.getChild():null},u.setOutput=function(t){return this.output=this.l.link("output",this,t),this},r}(v);s([c],y.prototype,"input",void 0),s([c],y.prototype,"output",void 0);var b=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.BUFFER,r}i(r,n);var u=r.prototype;return u.getURI=function(){return this.U},u.setURI=function(t){return this.U=t,this},r}(l),m=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.CAMERA,r.m="perspective",r}i(r,n);var u=r.prototype;return u.getType=function(){return this.m},u.setType=function(t){return this.m=t,this},u.getZNear=function(){return this.I},u.setZNear=function(t){return this.I=t,this},u.getZFar=function(){return this._},u.setZFar=function(t){return this._=t,this},u.getAspectRatio=function(){return this.O},u.setAspectRatio=function(t){return this.O=t,this},u.getYFov=function(){return this.j},u.setYFov=function(t){return this.j=t,this},u.getXMag=function(){return this.L},u.setXMag=function(t){return this.L=t,this},u.getYMag=function(){return this.k},u.setYMag=function(t){return this.k=t,this},r}(l),E=function(t){function n(n,r){var i;return(i=t.call(this,n)||this).C=r,i.C.addExtensionProperty(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(i)),i}i(n,t);var r=n.prototype;return r.dispose=function(){this.C.removeExtensionProperty(this),t.prototype.dispose.call(this)},r.p=function(t){if(!this.parentTypes.includes(t.propertyType))throw new Error('Parent "'+t.propertyType+'" invalid for child "'+this.propertyType+'".')},n}(v),T=function(){function t(){}return t.createBufferFromDataURI=function(t){if("undefined"==typeof Buffer){for(var n=atob(t.split(",")[1]),r=new Uint8Array(n.length),i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r.buffer}var u=t.split(",")[1],e=t.indexOf("base64")>=0;return this.trim(Buffer.from(u,e?"base64":"utf8"))},t.encodeText=function(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t).buffer:this.trim(Buffer.from(t))},t.decodeText=function(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")},t.trim=function(t){var n=t.byteOffset;return t.buffer.slice(n,n+t.byteLength)},t.concat=function(t){for(var n,r=0,i=e(t);!(n=i()).done;)r+=n.value.byteLength;for(var u,s=new Uint8Array(r),o=0,h=e(t);!(u=h()).done;){var f=u.value;s.set(new Uint8Array(f),o),o+=f.byteLength}return s.buffer},t.pad=function(t,n){void 0===n&&(n=0);var r=this.padNumber(t.byteLength);if(r!==t.byteLength){var i=new Uint8Array(r);if(i.set(new Uint8Array(t)),0!==n)for(var u=t.byteLength;u<r;u++)i[u]=n;return i.buffer}return t},t.padNumber=function(t){return 4*Math.ceil(t/4)},t.equals=function(t,n){if(t===n)return!0;if(t.byteLength!==n.byteLength)return!1;for(var r=new DataView(t),i=new DataView(n),u=t.byteLength;u--;)if(r.getUint8(u)!==i.getUint8(u))return!1;return!0},t}(),g=function(){function t(){}return t.basename=function(t){return t.split(/[\\/]/).pop().split(/[.]/).shift()},t.extension=function(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"},t}(),M=function(){function t(){}return t.getSizeJPEG=function(t){var n,r;for(t=t.slice(4);t.length;){if(n=t.readUInt16BE(0),x(t,n),192===(r=t[n+1])||193===r||194===r)return[t.readUInt16BE(n+7),t.readUInt16BE(n+5)];t=t.slice(n+2)}throw new TypeError("Invalid JPG, no size found")},t.getSizePNG=function(t){return"CgBI"===t.toString("ascii",12,16)?[t.readUInt32BE(32),t.readUInt32BE(36)]:[t.readUInt32BE(16),t.readUInt32BE(20)]},t.mimeTypeToExtension=function(t){return"image/jpeg"===t?"jpg":t.split("/").pop()},t.extensionToMimeType=function(t){return"jpg"===t?"image/jpeg":"image/"+t},t}();function x(t,n){if(n>t.length)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(255!==t[n])throw new TypeError("Invalid JPG, marker table corrupted")}var S=function(){function t(t){this.verbosity=t}var n=t.prototype;return n.debug=function(n){this.verbosity<=t.Verbosity.DEBUG&&console.debug(n)},n.info=function(n){this.verbosity<=t.Verbosity.INFO&&console.info(n)},n.warn=function(n){this.verbosity<=t.Verbosity.WARN&&console.warn(n)},n.error=function(n){this.verbosity<=t.Verbosity.ERROR&&console.error(n)},t}();S.Verbosity={SILENT:4,ERROR:3,WARN:2,INFO:1,DEBUG:0};var R="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",N=new Set,U=function(){for(var t="",n=0;n<6;n++)t+=R.charAt(Math.floor(Math.random()*R.length));return t},I=function(){for(var t=0;t<999;t++){var n=U();if(!N.has(n))return N.add(n),n}},_=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.TEXTURE,r.image=null,r.mimeType="",r.uri="",r}i(r,n);var u=r.prototype;return u.getMimeType=function(){return this.mimeType},u.setMimeType=function(t){return this.mimeType=t,this},u.getURI=function(){return this.uri},u.setURI=function(t){return this.uri=t,this},u.getImage=function(){return this.image},u.setImage=function(t){return this.image=t,this},u.getSize=function(){return(this.mimeType?"image/png"===this.mimeType:this.uri.match(/\.png$/))?M.getSizePNG(Buffer.from(this.image)):M.getSizeJPEG(Buffer.from(this.image))},r}(l),O=function(){function n(){this.propertyType=t.PropertyType.TEXTURE_INFO,this.texCoord=0}var r=n.prototype;return r.getTexCoord=function(){return this.texCoord},r.setTexCoord=function(t){return this.texCoord=t,this},n}(),j=function(){function n(){this.propertyType=t.PropertyType.TEXTURE_SAMPLER,this.B=null,this.P=null,this.V=10497,this.D=10497}var r=n.prototype;return r.getMagFilter=function(){return this.B},r.setMagFilter=function(t){return this.B=t,this},r.getMinFilter=function(){return this.P},r.setMinFilter=function(t){return this.P=t,this},r.getWrapS=function(){return this.V},r.setWrapS=function(t){return this.V=t,this},r.getWrapT=function(){return this.D},r.setWrapT=function(t){return this.D=t,this},n}();j.TextureWrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},j.TextureMagFilter={NEAREST:9728,LINEAR:9729},j.TextureMinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var L=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).textureInfo=new O,n.sampler=new j,n}return i(n,t),n}(h),k=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).semantic="",n}return i(n,t),n}(h),C=function(t){function n(){return t.apply(this,arguments)||this}return i(n,t),n}(h),B=function(t){function n(){return t.apply(this,arguments)||this}i(n,t);var r=n.prototype;return r.linkTexture=function(t,n,r){if(!r)return null;var i=new L(t,n,r);return this.registerLink(i),i},r.linkAttribute=function(t,n,r){if(!r)return null;var i=new k(t,n,r);return this.registerLink(i),i},r.linkIndex=function(t,n,r){if(!r)return null;var i=new C(t,n,r);return this.registerLink(i),i},n}(f),P=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.MATERIAL,r.G="OPAQUE",r.F=.5,r.J=!1,r.$=[1,1,1,1],r.Y=[0,0,0],r.q=1,r.H=1,r.K=1,r.W=1,r.baseColorTexture=null,r.emissiveTexture=null,r.normalTexture=null,r.occlusionTexture=null,r.metallicRoughnessTexture=null,r}i(r,n);var u=r.prototype;return u.getDoubleSided=function(){return this.J},u.setDoubleSided=function(t){return this.J=t,this},u.getAlphaMode=function(){return this.G},u.setAlphaMode=function(t){return this.G=t,this},u.getAlphaCutoff=function(){return this.F},u.setAlphaCutoff=function(t){return this.F=t,this},u.getBaseColorFactor=function(){return this.$},u.setBaseColorFactor=function(t){return this.$=t,this},u.getBaseColorTexture=function(){return this.baseColorTexture?this.baseColorTexture.getChild():null},u.getBaseColorTextureInfo=function(){return this.baseColorTexture?this.baseColorTexture.textureInfo:null},u.getBaseColorTextureSampler=function(){return this.baseColorTexture?this.baseColorTexture.sampler:null},u.setBaseColorTexture=function(t){return this.baseColorTexture=this.l.linkTexture("baseColorTexture",this,t),this},u.getEmissiveFactor=function(){return this.Y},u.setEmissiveFactor=function(t){return this.Y=t,this},u.getEmissiveTexture=function(){return this.emissiveTexture?this.emissiveTexture.getChild():null},u.getEmissiveTextureInfo=function(){return this.emissiveTexture?this.emissiveTexture.textureInfo:null},u.getEmissiveTextureSampler=function(){return this.emissiveTexture?this.emissiveTexture.sampler:null},u.setEmissiveTexture=function(t){return this.emissiveTexture=this.l.linkTexture("emissiveTexture",this,t),this},u.getNormalScale=function(){return this.q},u.setNormalScale=function(t){return this.q=t,this},u.getNormalTexture=function(){return this.normalTexture?this.normalTexture.getChild():null},u.getNormalTextureInfo=function(){return this.normalTexture?this.normalTexture.textureInfo:null},u.getNormalTextureSampler=function(){return this.normalTexture?this.normalTexture.sampler:null},u.setNormalTexture=function(t){return this.normalTexture=this.l.linkTexture("normalTexture",this,t),this},u.getOcclusionStrength=function(){return this.H},u.setOcclusionStrength=function(t){return this.H=t,this},u.getOcclusionTexture=function(){return this.occlusionTexture?this.occlusionTexture.getChild():null},u.getOcclusionTextureInfo=function(){return this.occlusionTexture?this.occlusionTexture.textureInfo:null},u.getOcclusionTextureSampler=function(){return this.occlusionTexture?this.occlusionTexture.sampler:null},u.setOcclusionTexture=function(t){return this.occlusionTexture=this.l.linkTexture("occlusionTexture",this,t),this},u.getRoughnessFactor=function(){return this.K},u.setRoughnessFactor=function(t){return this.K=t,this},u.getMetallicFactor=function(){return this.W},u.setMetallicFactor=function(t){return this.W=t,this},u.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.getChild():null},u.getMetallicRoughnessTextureInfo=function(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.textureInfo:null},u.getMetallicRoughnessTextureSampler=function(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.sampler:null},u.setMetallicRoughnessTexture=function(t){return this.metallicRoughnessTexture=this.l.linkTexture("metallicRoughnessTexture",this,t),this},r}(l);s([c],P.prototype,"baseColorTexture",void 0),s([c],P.prototype,"emissiveTexture",void 0),s([c],P.prototype,"normalTexture",void 0),s([c],P.prototype,"occlusionTexture",void 0),s([c],P.prototype,"metallicRoughnessTexture",void 0);var V=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.MESH,r.X=[],r.primitives=[],r}i(r,n);var u=r.prototype;return u.addPrimitive=function(t){return this.addGraphChild(this.primitives,this.l.link("primitive",this,t))},u.removePrimitive=function(t){return this.removeGraphChild(this.primitives,t)},u.listPrimitives=function(){return this.primitives.map(function(t){return t.getChild()})},u.getWeights=function(){return this.X},u.setWeights=function(t){return this.X=t,this},r}(l);s([a],V.prototype,"primitives",void 0);var D=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.PRIMITIVE,r.Z=4,r.indices=null,r.attributes=[],r.targets=[],r.material=null,r}i(r,n);var u=r.prototype;return u.getIndices=function(){return this.indices?this.indices.getChild():null},u.setIndices=function(t){return this.indices=this.l.linkIndex("index",this,t),this},u.getAttribute=function(t){var n=this.attributes.find(function(n){return n.semantic===t});return n?n.getChild():null},u.setAttribute=function(t,n){var r=this.getAttribute(t);if(r&&this.removeGraphChild(this.attributes,r),!n)return this;var i=this.l.linkAttribute(t.toLowerCase(),this,n);return i.semantic=t,this.addGraphChild(this.attributes,i)},u.listAttributes=function(){return this.attributes.map(function(t){return t.getChild()})},u.listSemantics=function(){return this.attributes.map(function(t){return t.semantic})},u.getMaterial=function(){return this.material?this.material.getChild():null},u.setMaterial=function(t){return this.material=this.l.link("material",this,t),this},u.getMode=function(){return this.Z},u.setMode=function(t){return this.Z=t,this},u.listTargets=function(){return this.targets.map(function(t){return t.getChild()})},u.addTarget=function(t){return this.addGraphChild(this.targets,this.l.link("target",this,t)),this},u.removeTarget=function(t){return this.removeGraphChild(this.targets,t)},r}(v);s([c],D.prototype,"indices",void 0),s([a],D.prototype,"attributes",void 0),s([a],D.prototype,"targets",void 0),s([c],D.prototype,"material",void 0);var G=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.PRIMITIVE_TARGET,r.attributes=[],r}i(r,n);var u=r.prototype;return u.getAttribute=function(t){var n=this.attributes.find(function(n){return n.semantic===t});return n?n.getChild():null},u.setAttribute=function(t,n){var r=this.getAttribute(t);if(r&&this.removeGraphChild(this.attributes,r),!n)return this;var i=this.l.linkAttribute(t.toLowerCase(),this,n);return i.semantic=t,this.addGraphChild(this.attributes,i)},u.listAttributes=function(){return this.attributes.map(function(t){return t.getChild()})},u.listSemantics=function(){return this.attributes.map(function(t){return t.semantic})},r}(v);s([a],G.prototype,"attributes",void 0);var F=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.NODE,r.tt=[0,0,0],r.nt=[0,0,0,1],r.rt=[1,1,1],r.X=[],r.camera=null,r.mesh=null,r.skin=null,r.children=[],r}i(r,n);var u=r.prototype;return u.getTranslation=function(){return this.tt},u.getRotation=function(){return this.nt},u.getScale=function(){return this.rt},u.setTranslation=function(t){return this.tt=t,this},u.setRotation=function(t){return this.nt=t,this},u.setScale=function(t){return this.rt=t,this},u.addChild=function(t){var n=this.l.link("child",this,t);return this.addGraphChild(this.children,n)},u.removeChild=function(t){return this.removeGraphChild(this.children,t)},u.listChildren=function(){return this.children.map(function(t){return t.getChild()})},u.getMesh=function(){return this.mesh?this.mesh.getChild():null},u.setMesh=function(t){return this.mesh=this.l.link("mesh",this,t),this},u.getCamera=function(){return this.camera?this.camera.getChild():null},u.setCamera=function(t){return this.camera=this.l.link("camera",this,t),this},u.getSkin=function(){return this.skin?this.skin.getChild():null},u.setSkin=function(t){return this.skin=this.l.link("skin",this,t),this},u.getWeights=function(){return this.X},u.setWeights=function(t){return this.X=t,this},r}(l);s([c],F.prototype,"camera",void 0),s([c],F.prototype,"mesh",void 0),s([c],F.prototype,"skin",void 0),s([a],F.prototype,"children",void 0);var J=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ROOT,r.it={generator:"glTF-Transform v0.4.0-alpha.2",version:"2.0"},r.ut=new Set,r.scenes=[],r.nodes=[],r.cameras=[],r.skins=[],r.meshes=[],r.materials=[],r.textures=[],r.animations=[],r.accessors=[],r.buffers=[],r}i(r,n);var u=r.prototype;return u.getAsset=function(){return this.it},u.listExtensionsUsed=function(){return Array.from(this.ut)},u.listExtensionsRequired=function(){return this.listExtensionsUsed().filter(function(t){return t.isRequired()})},u.et=function(t){if(this.ut.has(t))throw new Error('Extension "'+t.extensionName+'" is already enabled.');return this.ut.add(t),this},u.st=function(t){return this.ut.delete(t),this},u.ot=function(t){return this.addGraphChild(this.scenes,this.l.link("scene",this,t))},u.listScenes=function(){return this.scenes.map(function(t){return t.getChild()})},u.ht=function(t){return this.addGraphChild(this.nodes,this.l.link("node",this,t))},u.listNodes=function(){return this.nodes.map(function(t){return t.getChild()})},u.ft=function(t){return this.addGraphChild(this.cameras,this.l.link("camera",this,t))},u.listCameras=function(){return this.cameras.map(function(t){return t.getChild()})},u.ct=function(t){return this.addGraphChild(this.skins,this.l.link("skin",this,t))},u.listSkins=function(){return this.skins.map(function(t){return t.getChild()})},u.at=function(t){return this.addGraphChild(this.meshes,this.l.link("mesh",this,t))},u.listMeshes=function(){return this.meshes.map(function(t){return t.getChild()})},u.vt=function(t){return this.addGraphChild(this.materials,this.l.link("material",this,t))},u.listMaterials=function(){return this.materials.map(function(t){return t.getChild()})},u.lt=function(t){return this.addGraphChild(this.textures,this.l.link("texture",this,t))},u.listTextures=function(){return this.textures.map(function(t){return t.getChild()})},u.dt=function(t){return this.addGraphChild(this.animations,this.l.link("animation",this,t))},u.listAnimations=function(){return this.animations.map(function(t){return t.getChild()})},u.wt=function(t){return this.addGraphChild(this.accessors,this.l.link("accessor",this,t))},u.listAccessors=function(){return this.accessors.map(function(t){return t.getChild()})},u.pt=function(t){return this.addGraphChild(this.buffers,this.l.link("buffer",this,t))},u.listBuffers=function(){return this.buffers.map(function(t){return t.getChild()})},r}(v);s([a],J.prototype,"scenes",void 0),s([a],J.prototype,"nodes",void 0),s([a],J.prototype,"cameras",void 0),s([a],J.prototype,"skins",void 0),s([a],J.prototype,"meshes",void 0),s([a],J.prototype,"materials",void 0),s([a],J.prototype,"textures",void 0),s([a],J.prototype,"animations",void 0),s([a],J.prototype,"accessors",void 0),s([a],J.prototype,"buffers",void 0);var z=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.SCENE,r.nodes=[],r}i(r,n);var u=r.prototype;return u.addNode=function(t){return this.addGraphChild(this.nodes,this.l.link("node",this,t))},u.removeNode=function(t){return this.removeGraphChild(this.nodes,t)},u.listNodes=function(){return this.nodes.map(function(t){return t.getChild()})},r}(l);s([a],z.prototype,"nodes",void 0);var $=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.SKIN,r.skeleton=null,r.inverseBindMatrices=null,r.joints=[],r}i(r,n);var u=r.prototype;return u.getSkeleton=function(){return this.skeleton?this.skeleton.getChild():null},u.setSkeleton=function(t){return this.skeleton=this.l.link("skeleton",this,t),this},u.getInverseBindMatrices=function(){return this.inverseBindMatrices?this.inverseBindMatrices.getChild():null},u.setInverseBindMatrices=function(t){return this.inverseBindMatrices=this.l.link("inverseBindMatrices",this,t),this},u.addJoint=function(t){var n=this.l.link("joint",this,t);return this.addGraphChild(this.joints,n)},u.removeJoint=function(t){return this.removeGraphChild(this.joints,t)},u.listJoints=function(){return this.joints.map(function(t){return t.getChild()})},r}(l);s([c],$.prototype,"skeleton",void 0),s([c],$.prototype,"inverseBindMatrices",void 0),s([a],$.prototype,"joints",void 0);var Y=function(){function t(){this.graph=new B,this.root=new J(this.graph),this.logger=new S(S.Verbosity.INFO)}var n=t.prototype;return n.getRoot=function(){return this.root},n.getGraph=function(){return this.graph},n.getLogger=function(){return this.logger},n.setLogger=function(t){return this.logger=t,this},n.clone=function(){throw new Error("Not implemented.")},n.transform=function(){for(var t,n=e([].slice.call(arguments));!(t=n()).done;){var r=t.value;r(this)}return this},n.createExtension=function(t){return this.getRoot().listExtensionsUsed().find(function(n){return n.extensionName===t.EXTENSION_NAME})||new t(this)},n.createScene=function(t){var n=new z(this.graph,t);return this.root.ot(n),n},n.createNode=function(t){var n=new F(this.graph,t);return this.root.ht(n),n},n.createCamera=function(t){var n=new m(this.graph,t);return this.root.ft(n),n},n.createSkin=function(t){var n=new $(this.graph,t);return this.root.ct(n),n},n.createMesh=function(t){var n=new V(this.graph,t);return this.root.at(n),n},n.createPrimitive=function(){return new D(this.graph)},n.createPrimitiveTarget=function(t){return new G(this.graph,t)},n.createMaterial=function(t){var n=new P(this.graph,t);return this.root.vt(n),n},n.createTexture=function(t){var n=new _(this.graph,t);return this.root.lt(n),n},n.createAnimation=function(t){var n=new p(this.graph,t);return this.root.dt(n),n},n.createAnimationChannel=function(){return new A(this.graph)},n.createAnimationSampler=function(){return new y(this.graph)},n.createAccessor=function(t,n){void 0===n&&(n=null),n||(n=this.getRoot().listBuffers()[0]);var r=new d(this.graph,t).setBuffer(n);return this.root.wt(r),r},n.createBuffer=function(t){var n=new b(this.graph,t);return this.root.pt(n),n},t}(),q=function(){function t(t){this.doc=t,this.At=!1,this.yt=new Set,t.getRoot().et(this)}var n=t.prototype;return n.dispose=function(){this.doc.getRoot().st(this);for(var t,n=e(this.yt);!(t=n()).done;)t.value.dispose()},n.isRequired=function(){return this.At},n.setRequired=function(t){return this.At=t,this},n.addExtensionProperty=function(t){return this.yt.add(t),this},n.removeExtensionProperty=function(t){return this.yt.delete(t),this},t}(),H=function(t){this.nativeDocument=t,this.buffers=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[]},K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q=function(){function t(){}return t.read=function(t,i){var u=t.json,s=new Y;if("2.0"!==u.asset.version)throw new Error('Unsupported glTF version: "'+u.asset.version+'".');var o=new H(t);o.buffers=(u.buffers||[]).map(function(t){var n=s.createBuffer(t.name);return t.uri&&0!==t.uri.indexOf("__")&&n.setURI(t.uri),n}),o.bufferViewBuffers=(u.bufferViews||[]).map(function(t){return o.buffers[t.buffer]}),o.accessors=(u.accessors||[]).map(function(n){var i,u=s.createAccessor(n.name,o.bufferViewBuffers[n.bufferView]);return u.setType(n.type),i=void 0!==n.sparse?function(t,n){var i,u=K[t.componentType],e=d.getElementSize(t.type);i=void 0!==t.bufferView?Z(t,n).slice():new u(t.count*e);for(var s=t.sparse.count,o=r(r(r({},t),t.sparse.indices),{},{count:s,type:"SCALAR"}),h=r(r(r({},t),t.sparse.values),{},{count:s}),f=Z(o,n),c=Z(h,n),a=0;a<o.count;a++)for(var v=0;v<e;v++)i[f[a]*e+v]=c[a*e+v];return i}(n,t):Z(n,t).slice(),void 0!==n.normalized&&u.setNormalized(n.normalized),u.setArray(i),u});var h=u.textures||[];o.textures=(u.images||[]).map(function(n){var r=s.createTexture(n.name);if(void 0!==n.bufferView){var i=u.bufferViews[n.bufferView],e=t.json.buffers[i.buffer],o=i.byteOffset||0,h=(e.uri?t.resources[e.uri]:t.resources["bt"]).slice(o,o+i.byteLength);r.setImage(h)}else void 0!==n.uri&&(r.setImage(t.resources[n.uri]),0!==n.uri.indexOf("__")&&r.setURI(n.uri));if(void 0!==n.mimeType)r.setMimeType(n.mimeType);else if(n.uri){var f=g.extension(n.uri);r.setMimeType(M.extensionToMimeType(f))}return r}),o.materials=(u.materials||[]).map(function(n){var r=s.createMaterial(n.name);void 0!==n.alphaMode&&r.setAlphaMode(n.alphaMode),void 0!==n.alphaCutoff&&r.setAlphaCutoff(n.alphaCutoff),void 0!==n.doubleSided&&r.setDoubleSided(n.doubleSided);var i=n.pbrMetallicRoughness||{};if(void 0!==i.baseColorFactor&&r.setBaseColorFactor(i.baseColorFactor),void 0!==n.emissiveFactor&&r.setEmissiveFactor(n.emissiveFactor),void 0!==i.metallicFactor&&r.setMetallicFactor(i.metallicFactor),void 0!==i.roughnessFactor&&r.setRoughnessFactor(i.roughnessFactor),void 0!==i.baseColorTexture){var u=i.baseColorTexture;r.setBaseColorTexture(o.textures[h[u.index].source]),W(r.getBaseColorTextureInfo(),u),X(r.getBaseColorTextureSampler(),u,t)}if(void 0!==n.emissiveTexture){var e=n.emissiveTexture;r.setEmissiveTexture(o.textures[h[e.index].source]),W(r.getEmissiveTextureInfo(),e),X(r.getEmissiveTextureSampler(),e,t)}if(void 0!==n.normalTexture){var f=n.normalTexture;r.setNormalTexture(o.textures[h[f.index].source]),W(r.getNormalTextureInfo(),f),X(r.getNormalTextureSampler(),f,t),void 0!==n.normalTexture.scale&&r.setNormalScale(n.normalTexture.scale)}if(void 0!==n.occlusionTexture){var c=n.occlusionTexture;r.setOcclusionTexture(o.textures[h[c.index].source]),W(r.getOcclusionTextureInfo(),c),X(r.getOcclusionTextureSampler(),c,t),void 0!==n.occlusionTexture.strength&&r.setOcclusionStrength(n.occlusionTexture.strength)}if(void 0!==i.metallicRoughnessTexture){var a=i.metallicRoughnessTexture;r.setMetallicRoughnessTexture(o.textures[h[a.index].source]),W(r.getMetallicRoughnessTextureInfo(),a),X(r.getMetallicRoughnessTextureSampler(),a,t)}return r}),o.meshes=(u.meshes||[]).map(function(t){var n=s.createMesh(t.name);return void 0!==t.weights&&n.setWeights(t.weights),t.primitives.forEach(function(r){var i=s.createPrimitive();void 0!==r.material&&i.setMaterial(o.materials[r.material]),void 0!==r.mode&&i.setMode(r.mode);for(var u=0,e=Object.entries(r.attributes||{});u<e.length;u++){var h=e[u];i.setAttribute(h[0],o.accessors[h[1]])}void 0!==r.indices&&i.setIndices(o.accessors[r.indices]);var f=t.extras&&t.extras.targetNames||[];(r.targets||[]).forEach(function(t,n){for(var r=f[n]||n.toString(),u=s.createPrimitiveTarget(r),e=0,h=Object.entries(t);e<h.length;e++){var c=h[e];u.setAttribute(c[0],o.accessors[c[1]])}i.addTarget(u)}),n.addPrimitive(i)}),n}),o.cameras=(u.cameras||[]).map(function(t){var n=s.createCamera(t.name).setType(t.type);return"perspective"===t.type?n.setZNear(t.perspective.znear).setZFar(t.perspective.zfar).setYFov(t.perspective.yfov).setAspectRatio(t.perspective.aspectRatio):n.setZNear(t.orthographic.znear).setZFar(t.orthographic.zfar).setXMag(t.orthographic.xmag).setYMag(t.orthographic.ymag),n});var f=u.nodes||[];o.nodes=f.map(function(t){var r=s.createNode(t.name);return void 0!==t.translation&&r.setTranslation(t.translation),void 0!==t.rotation&&r.setRotation(t.rotation),void 0!==t.scale&&r.setScale(t.scale),void 0!==t.matrix&&(r.setTranslation(n.getTranslation([],t.matrix)),r.setRotation(n.getRotation([],t.matrix)),r.setScale(n.getScaling([],t.matrix))),void 0!==t.weights&&r.setWeights(t.weights),r}),o.skins=(u.skins||[]).map(function(t){var n=s.createSkin(t.name);void 0!==t.inverseBindMatrices&&n.setInverseBindMatrices(o.accessors[t.inverseBindMatrices]),void 0!==t.skeleton&&n.setSkeleton(o.nodes[t.skeleton]);for(var r,i=e(t.joints);!(r=i()).done;)n.addJoint(o.nodes[r.value]);return n}),f.map(function(t,n){var r=o.nodes[n];(t.children||[]).forEach(function(t){return r.addChild(o.nodes[t])}),void 0!==t.mesh&&r.setMesh(o.meshes[t.mesh]),void 0!==t.camera&&r.setCamera(o.cameras[t.camera]),void 0!==t.skin&&r.setSkin(o.skins[t.skin])}),o.animations=(u.animations||[]).map(function(t){var n=s.createAnimation(t.name),r=(t.samplers||[]).map(function(t){var r=s.createAnimationSampler().setInput(o.accessors[t.input]).setOutput(o.accessors[t.output]).setInterpolation(t.interpolation||"LINEAR");return n.addSampler(r),r});return(t.channels||[]).forEach(function(t){var i=s.createAnimationChannel().setSampler(r[t.sampler]).setTargetNode(o.nodes[t.target.node]).setTargetPath(t.target.path);n.addChannel(i)}),n}),o.scenes=(u.scenes||[]).map(function(t){var n=s.createScene(t.name);return(t.nodes||[]).map(function(t){return o.nodes[t]}).forEach(function(t){return n.addNode(t)}),n});for(var c,a=u.extensionsUsed||[],v=u.extensionsRequired||[],l=e(i.extensions);!(c=l()).done;){var w=c.value;a.includes(w.EXTENSION_NAME)&&s.createExtension(w).setRequired(v.includes(w.EXTENSION_NAME)).read(o)}return s},t}();function W(t,n){void 0!==n.texCoord&&t.setTexCoord(n.texCoord)}function X(t,n,r){var i=r.json.textures[n.index];if(void 0!==i.sampler){var u=r.json.samplers[i.sampler];void 0!==u.magFilter&&t.setMagFilter(u.magFilter),void 0!==u.minFilter&&t.setMinFilter(u.minFilter),void 0!==u.wrapS&&t.setWrapS(u.wrapS),void 0!==u.wrapT&&t.setWrapT(u.wrapT)}}function Z(t,n){var r=n.json.bufferViews[t.bufferView],i=n.json.buffers[r.buffer],u=i.uri?n.resources[i.uri]:n.resources["bt"],e=K[t.componentType],s=d.getElementSize(t.type);if(void 0!==r.byteStride&&r.byteStride!==s*e.BYTES_PER_ELEMENT)return function(t,n){for(var r=n.json.bufferViews[t.bufferView],i=n.json.buffers[r.buffer],u=i.uri?n.resources[i.uri]:n.resources["bt"],e=K[t.componentType],s=d.getElementSize(t.type),o=e.BYTES_PER_ELEMENT,h=t.byteOffset||0,f=new e(t.count*s),c=new DataView(u,r.byteOffset,r.byteLength),a=r.byteStride,v=0;v<t.count;v++)for(var l=0;l<s;l++){var w=h+v*a+l*o,p=void 0;switch(t.componentType){case 5126:p=c.getFloat32(w,!0);break;case 5125:p=c.getUint32(w,!0);break;case 5123:p=c.getUint16(w,!0);break;case 5121:p=c.getUint8(w);break;case 5122:p=c.getInt16(w,!0);break;case 5120:p=c.getInt8(w);break;default:throw new Error('Unexpected componentType "'+t.componentType+'".')}f[v*s+l]=p}return f}(t,n);var o=(r.byteOffset||0)+(t.byteOffset||0);switch(t.componentType){case 5126:return new Float32Array(u,o,t.count*s);case 5125:return new Uint32Array(u,o,t.count*s);case 5123:return new Uint16Array(u,o,t.count*s);case 5121:return new Uint8Array(u,o,t.count*s);case 5122:return new Int16Array(u,o,t.count*s);case 5120:return new Int8Array(u,o,t.count*s);default:throw new Error('Unexpected componentType "'+t.componentType+'".')}}var tt=function(){function t(t,n){this.nativeDocument=t,this.options=n,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.samplerDefIndexMap=new Map,this.imageData=[]}var n=t.prototype;return n.createTextureInfoDef=function(t,n,r){var i={magFilter:r.getMagFilter()||void 0,minFilter:r.getMinFilter()||void 0,wrapS:r.getWrapS(),wrapT:r.getWrapT()},u=JSON.stringify(i);this.samplerDefIndexMap.has(u)||(this.samplerDefIndexMap.set(u,this.nativeDocument.json.samplers.length),this.nativeDocument.json.samplers.push(i));var e={source:this.imageIndexMap.get(t),sampler:this.samplerDefIndexMap.get(u)},s=JSON.stringify(e);return this.textureDefIndexMap.has(s)||(this.textureDefIndexMap.set(s,this.nativeDocument.json.textures.length),this.nativeDocument.json.textures.push(e)),{index:this.textureDefIndexMap.get(s),texCoord:n.getTexCoord()}},n.createPropertyDef=function(t){var n={};return t.getName()&&(n.name=t.getName()),Object.keys(t.getExtras()).length>0&&(n.extras=t.getExtras()),n},n.createAccessorDef=function(t){var n=this.createPropertyDef(t);return n.type=t.getType(),n.componentType=t.getComponentType(),n.count=t.getCount(),t.getMax(n.max=[]),t.getMin(n.min=[]),n.normalized=t.getNormalized(),n},n.createImageData=function(t,n,r){if(this.options.isGLB)this.imageData.push(n),t.bufferView=this.nativeDocument.json.bufferViews.length,this.nativeDocument.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:n.byteLength});else{var i=M.mimeTypeToExtension(r.getMimeType());t.uri=this.imageURIGenerator.createURI(r,i),this.nativeDocument.resources[t.uri]=n}},t}(),nt=function(){function t(t,n){this.multiple=t,this.basename=n,this.counter=1}return t.prototype.createURI=function(t,n){return t.getURI()?t.getURI():this.multiple?this.basename+"_"+this.counter+++"."+n:this.basename+"."+n},t}(),rt=function(){function t(){}return t.write=function(t,n){var r=t.getRoot(),i={json:{asset:r.getAsset()},resources:{}},u=i.json,s=new tt(i,n),o=r.listBuffers().length,h=r.listTextures().length;function f(t,n,r,i){for(var o,h=[],f=0,c=e(t);!(o=c()).done;){var a=o.value,v=s.createAccessorDef(a);v.bufferView=u.bufferViews.length;var l=T.pad(a.getArray().buffer);v.byteOffset=f,f+=l.byteLength,h.push(l),s.accessorIndexMap.set(a,u.accessors.length),u.accessors.push(v)}var d={buffer:n,byteOffset:r,byteLength:T.concat(h).byteLength};return i&&(d.target=i),u.bufferViews.push(d),{buffers:h,byteLength:f}}function c(t,n,r){for(var i,o=t[0].getCount(),h=0,f=e(t);!(i=f()).done;){var c=i.value,a=s.createAccessorDef(c);a.bufferView=u.bufferViews.length,a.byteOffset=h;var v=c.getElementSize(),l=c.getComponentSize();h+=T.padNumber(v*l),s.accessorIndexMap.set(c,u.accessors.length),u.accessors.push(a)}for(var d=o*h,w=new ArrayBuffer(d),p=new DataView(w),A=0;A<o;A++)for(var y,b=0,m=e(t);!(y=m()).done;){for(var E=y.value,g=E.getElementSize(),M=E.getComponentSize(),x=E.getComponentType(),S=E.getArray(),R=0;R<g;R++){var N=A*h+b+R*M,U=S[A*g+R];switch(x){case 5126:p.setFloat32(N,U,!0);break;case 5120:p.setInt8(N,U);break;case 5122:p.setInt16(N,U,!0);break;case 5121:p.setUint8(N,U);break;case 5123:p.setUint16(N,U,!0);break;case 5125:p.setUint32(N,U,!0);break;default:throw new Error("Unexpected component type: "+x)}}b+=T.padNumber(g*M)}return u.bufferViews.push({buffer:n,byteOffset:r,byteLength:d,byteStride:h,target:34962}),{byteLength:d,buffers:[w]}}s.bufferURIGenerator=new nt(o>1,n.basename),s.imageURIGenerator=new nt(h>1,n.basename),s.logger=t.getLogger();for(var a,v=new Map,l=e(t.getGraph().getLinks());!(a=l()).done;){var w=a.value;if(w.getParent()!==r){var p=w.getChild();if(p instanceof d){var A=v.get(p)||[];A.push(w),v.set(p,A)}}}return u.accessors=[],u.bufferViews=[],u.samplers=[],u.textures=[],u.images=r.listTextures().map(function(t,n){var r=s.createPropertyDef(t);return t.getMimeType()&&(r.mimeType=t.getMimeType()),t.getImage()&&s.createImageData(r,t.getImage(),t),s.imageIndexMap.set(t,n),r}),u.buffers=[],r.listBuffers().forEach(function(t){for(var r,o=s.createPropertyDef(t),h=new Map,a=new Set,l=new Set,w=e(t.listParents().filter(function(t){return!(t instanceof J)}));!(r=w()).done;){var p=r.value;if(!(p instanceof d))throw new Error("Unimplemented buffer reference: "+p);for(var A,y=!1,b=!1,m=!1,E=v.get(p)||[],g=e(E);!(A=g()).done;){var M=A.value;M instanceof k?y=!0:M instanceof C?b=!0:m=!0}if(y||b||m||(m=!0),!y||b||m)if(!b||y||m){if(!m||y||b)throw new Error("Attribute or index accessors must be used only for that purpose.");l.add(p)}else a.add(p);else{var x=E[0].getParent(),S=h.get(x)||new Set;S.add(p),h.set(x,S)}}var R,N=[],U=u.buffers.length,I=0;if(a.size){var _=f(Array.from(a),U,I,34963);I+=_.byteLength,N.push.apply(N,_.buffers)}for(var O=0,j=Array.from(h.values());O<j.length;O++){var L=j[O];if(L.size){var B=c(Array.from(L),U,I);I+=B.byteLength,N.push.apply(N,B.buffers)}}if(l.size){var P=f(Array.from(l),U,I);I+=P.byteLength,N.push.apply(N,P.buffers)}if(s.imageData.length)for(var V=0;V<s.imageData.length;V++)u.bufferViews[u.images[V].bufferView].byteOffset=I,I+=s.imageData[V].byteLength,N.push(s.imageData[V]);I?(n.isGLB?R="__glb.bin":(R=s.bufferURIGenerator.createURI(t,"bin"),o.uri=R),o.byteLength=I,i.resources[R]=T.concat(N),u.buffers.push(o)):s.logger.warn('@gltf-transform/core: Skipping empty buffer, "'+t.getName()+'".')}),u.materials=r.listMaterials().map(function(t,n){var r=s.createPropertyDef(t);if(r.alphaMode=t.getAlphaMode(),"MASK"===t.getAlphaMode()&&(r.alphaCutoff=t.getAlphaCutoff()),r.doubleSided=t.getDoubleSided(),r.pbrMetallicRoughness={},r.pbrMetallicRoughness.baseColorFactor=t.getBaseColorFactor(),r.emissiveFactor=t.getEmissiveFactor(),r.pbrMetallicRoughness.roughnessFactor=t.getRoughnessFactor(),r.pbrMetallicRoughness.metallicFactor=t.getMetallicFactor(),t.getBaseColorTexture()){var i=t.getBaseColorTexture(),u=t.getBaseColorTextureInfo(),e=t.getBaseColorTextureSampler();r.pbrMetallicRoughness.baseColorTexture=s.createTextureInfoDef(i,u,e)}if(t.getEmissiveTexture()){var o=t.getEmissiveTexture(),h=t.getEmissiveTextureInfo(),f=t.getEmissiveTextureSampler();r.emissiveTexture=s.createTextureInfoDef(o,h,f)}if(t.getNormalTexture()){var c=t.getNormalTexture(),a=t.getNormalTextureInfo(),v=t.getNormalTextureSampler(),l=s.createTextureInfoDef(c,a,v);1!==t.getNormalScale()&&(l.scale=t.getNormalScale()),r.normalTexture=l}if(t.getOcclusionTexture()){var d=t.getOcclusionTexture(),w=t.getOcclusionTextureInfo(),p=t.getOcclusionTextureSampler(),A=s.createTextureInfoDef(d,w,p);1!==t.getOcclusionStrength()&&(A.strength=t.getOcclusionStrength()),r.occlusionTexture=A}if(t.getMetallicRoughnessTexture()){var y=t.getMetallicRoughnessTexture(),b=t.getMetallicRoughnessTextureInfo(),m=t.getMetallicRoughnessTextureSampler();r.pbrMetallicRoughness.metallicRoughnessTexture=s.createTextureInfoDef(y,b,m)}return s.materialIndexMap.set(t,n),r}),u.meshes=r.listMeshes().map(function(t,n){var r,i=s.createPropertyDef(t);return i.primitives=t.listPrimitives().map(function(t){var n={attributes:{}};n.material=s.materialIndexMap.get(t.getMaterial()),n.mode=t.getMode(),t.getIndices()&&(n.indices=s.accessorIndexMap.get(t.getIndices()));for(var i,u=e(t.listSemantics());!(i=u()).done;){var o=i.value;n.attributes[o]=s.accessorIndexMap.get(t.getAttribute(o))}for(var h,f=e(t.listTargets());!(h=f()).done;){for(var c,a=h.value,v={},l=e(a.listSemantics());!(c=l()).done;){var d=c.value;v[d]=s.accessorIndexMap.get(a.getAttribute(d))}n.targets=n.targets||[],n.targets.push(v)}return t.listTargets().length&&!r&&(r=t.listTargets().map(function(t){return t.getName()})),n}),t.getWeights().length&&(i.weights=t.getWeights()),r&&(i.extras=i.extras||{},i.extras.targetNames=r),s.meshIndexMap.set(t,n),i}),u.cameras=r.listCameras().map(function(t,n){var r=s.createPropertyDef(t);return r.type=t.getType(),"perspective"===r.type?r.perspective={znear:t.getZNear(),zfar:t.getZFar(),yfov:t.getYFov(),aspectRatio:t.getAspectRatio()}:r.orthographic={znear:t.getZNear(),zfar:t.getZFar(),xmag:t.getXMag(),ymag:t.getYMag()},s.cameraIndexMap.set(t,n),r}),u.nodes=r.listNodes().map(function(t,n){var r=s.createPropertyDef(t);return r.translation=t.getTranslation(),r.rotation=t.getRotation(),r.scale=t.getScale(),t.getWeights().length&&(r.weights=t.getWeights()),s.nodeIndexMap.set(t,n),r}),u.skins=r.listSkins().map(function(t,n){var r=s.createPropertyDef(t);return t.getInverseBindMatrices()&&(r.inverseBindMatrices=s.accessorIndexMap.get(t.getInverseBindMatrices())),t.getSkeleton()&&(r.skeleton=s.nodeIndexMap.get(t.getSkeleton())),r.joints=t.listJoints().map(function(t){return s.nodeIndexMap.get(t)}),s.skinIndexMap.set(t,n),r}),r.listNodes().forEach(function(t,n){var r=u.nodes[n];t.getMesh()&&(r.mesh=s.meshIndexMap.get(t.getMesh())),t.getCamera()&&(r.camera=s.cameraIndexMap.get(t.getCamera())),t.getSkin()&&(r.skin=s.skinIndexMap.get(t.getSkin())),t.listChildren().length>0&&(r.children=t.listChildren().map(function(t){return s.nodeIndexMap.get(t)}))}),u.animations=r.listAnimations().map(function(t){var n=s.createPropertyDef(t),r=new Map;return n.samplers=t.listSamplers().map(function(t,n){var i=s.createPropertyDef(t);return i.input=s.accessorIndexMap.get(t.getInput()),i.output=s.accessorIndexMap.get(t.getOutput()),i.interpolation=t.getInterpolation(),r.set(t,n),i}),n.channels=t.listChannels().map(function(t){var n=s.createPropertyDef(t);return n.sampler=r.get(t.getSampler()),n.target={node:s.nodeIndexMap.get(t.getTargetNode()),path:t.getTargetPath()},n}),n}),u.scenes=r.listScenes().map(function(t){var n=s.createPropertyDef(t);return n.nodes=t.listNodes().map(function(t){return s.nodeIndexMap.get(t)}),n}),u.extensionsUsed=r.listExtensionsUsed().map(function(t){return t.extensionName}),u.extensionsRequired=r.listExtensionsRequired().map(function(t){return t.extensionName}),r.listExtensionsUsed().forEach(function(t){return t.write(s)}),function(t){var n=[];for(var r in t){var i=t[r];Array.isArray(i)&&0===i.length?n.push(r):null!==i&&""!==i||n.push(i)}for(var u=0,e=n;u<e.length;u++)delete t[e[u]]}(u),i},t}(),it=function(){function t(){this.ut=[]}var n=t.prototype;return n.registerExtensions=function(t){var n;return(n=this.ut).push.apply(n,t),this},n.createDocument=function(t){return Q.read(t,{extensions:this.ut})},n.createNativeDocument=function(t,n){if(n.isGLB&&1!==t.getRoot().listBuffers().length)throw new Error("GLB must have exactly 1 buffer.");return rt.write(t,n)},n.unpackGLB=function(t){var n,r=new Uint32Array(t,0,3);if(1179937895!==r[0])throw new Error("Invalid glTF asset.");if(2!==r[1])throw new Error('Unsupported glTF binary version, "'+r[1]+'".');var i=new Uint32Array(t,12,2),u=i[0],e=new Uint32Array(t,20+u,2);if(1313821514!==i[1]||5130562!==e[1])throw new Error("Unexpected GLB layout.");var s=T.decodeText(t.slice(20,20+u)),o=JSON.parse(s),h=20+u+8,f=t.slice(h,h+e[0]);return this.createDocument({json:o,resources:(n={},n["bt"]=f,n)})},n.packGLB=function(t){var n=this.createNativeDocument(t,{basename:"",isGLB:!0}),r=n.resources,i=JSON.stringify(n.json),u=T.pad(T.encodeText(i),32),e=new Uint32Array([u.byteLength,1313821514]).buffer,s=T.concat([e,u]),o=T.pad(Object.values(r)[0],0),h=new Uint32Array([o.byteLength,5130562]).buffer,f=T.concat([h,o]),c=new Uint32Array([1179937895,2,12+s.byteLength+f.byteLength]).buffer;return T.concat([c,s,f])},t}(),ut=function(t){function n(n,r){var i;return(i=t.call(this)||this).fs=n,i.path=r,i}i(n,t);var r=n.prototype;return r.read=function(t){return t.match(/\.glb$/)?this.readGLB(t):this.readGLTF(t)},r.write=function(t,n){t.match(/\.glb$/)?this.writeGLB(t,n):this.writeGLTF(t,n)},r.readGLB=function(t){var n=this.fs.readFileSync(t),r=T.trim(n);return this.unpackGLB(r)},r.readGLTF=function(t){var n=this,r=this.path.dirname(t),i={json:JSON.parse(this.fs.readFileSync(t,"utf8")),resources:{}};return[].concat(i.json.images||[],i.json.buffers||[]).forEach(function(t){if(t.uri&&!t.uri.match(/data:/)){var u=n.path.resolve(r,t.uri);i.resources[t.uri]=T.trim(n.fs.readFileSync(u))}else{var e="__"+I()+"."+g.extension(t.uri);i.resources[e]=T.createBufferFromDataURI(t.uri),t.uri=e}}),Q.read(i,{extensions:this.ut})},r.writeGLTF=function(t,n){var r={basename:g.basename(t),isGLB:!1},i=rt.write(n,r),u=i.json,e=i.resources,s=this.fs,o=this.path,h=o.dirname(t);s.writeFileSync(t,JSON.stringify(u,null,2)),Object.keys(e).forEach(function(t){var n=Buffer.from(e[t]);s.writeFileSync(o.join(h,t),n)})},r.writeGLB=function(t,n){var r=Buffer.from(this.packGLB(n));this.fs.writeFileSync(t,r)},n}(it),et=function(t){function n(n){var r;return(r=t.call(this)||this).fetchConfig=n,r}i(n,t);var r=n.prototype;return r.read=function(t){return t.match(/\.glb$/)?this.readGLB(t):this.readGLTF(t)},r.readGLTF=function(t){var n=this,r={json:{},resources:{}};return fetch(t,this.fetchConfig).then(function(t){return t.json()}).then(function(t){r.json=t;var i=[].concat(t.images,t.buffers).map(function(t){if(t.uri)return fetch(t.uri,n.fetchConfig).then(function(t){return t.arrayBuffer()}).then(function(n){r.resources[t.uri]=n})});return Promise.all(i).then(function(){return n.createDocument(r)})})},r.readGLB=function(t){var n=this;return fetch(t,this.fetchConfig).then(function(t){return t.arrayBuffer()}).then(function(t){return n.unpackGLB(t)})},n}(it);t.Accessor=d,t.Animation=p,t.AnimationChannel=A,t.AnimationSampler=y,t.Buffer=b,t.BufferUtils=T,t.Camera=m,t.Document=Y,t.Extension=q,t.ExtensionProperty=E,t.FileUtils=g,t.Graph=f,t.ImageUtils=M,t.Logger=S,t.Material=P,t.Mesh=V,t.Node=F,t.NodeIO=ut,t.Primitive=D,t.PrimitiveTarget=G,t.Property=v,t.ReaderContext=H,t.Root=J,t.Scene=z,t.Skin=$,t.Texture=_,t.TextureInfo=O,t.TextureSampler=j,t.WebIO=et,t.WriterContext=tt,t.uuid=I});
!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("gl-matrix/mat4")):"function"==typeof define&&define.amd?define(["exports","gl-matrix/mat4"],n):n((t=t||self).core={},t.mat4)}(this,function(t,n){function r(){return(r=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var r=arguments[n];for(var i in r)Object.prototype.hasOwnProperty.call(r,i)&&(t[i]=r[i])}return t}).apply(this,arguments)}function i(t,n){t.prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n}function u(t,n){(null==n||n>t.length)&&(n=t.length);for(var r=0,i=new Array(n);r<n;r++)i[r]=t[r];return i}function e(t){var n=0;if("undefined"==typeof Symbol||null==t[Symbol.iterator]){if(Array.isArray(t)||(t=function(t,n){if(t){if("string"==typeof t)return u(t,void 0);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,void 0):void 0}}(t)))return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}};throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}return(n=t[Symbol.iterator]()).next.bind(n)}function s(t,n,r,i){var u,e=arguments.length,s=e<3?n:null===i?i=Object.getOwnPropertyDescriptor(n,r):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,n,r,i);else for(var o=t.length-1;o>=0;o--)(u=t[o])&&(s=(e<3?u(s):e>3?u(n,r,s):u(n,r))||s);return e>3&&s&&Object.defineProperty(n,r,s),s}var o;(o=t.PropertyType||(t.PropertyType={})).ACCESSOR="Accessor",o.ANIMATION="Animation",o.ANIMATION_CHANNEL="AnimationChannel",o.ANIMATION_SAMPLER="AnimationSampler",o.BUFFER="Buffer",o.CAMERA="Camera",o.MATERIAL="Material",o.MESH="Mesh",o.PRIMITIVE="Primitive",o.PRIMITIVE_TARGET="PrimitiveTarget",o.NODE="Node",o.ROOT="Root",o.SCENE="Scene",o.SKIN="Skin",o.TEXTURE="Texture",o.TEXTURE_INFO="TextureInfo",o.TEXTURE_SAMPLER="TextureSampler";var h=function(){function t(t,n,r){if(this.t=t,this.i=n,this.u=r,this.s=!1,this.o=[],!n.canLink(r))throw new Error("Cannot link disconnected graphs/documents.")}var n=t.prototype;return n.getName=function(){return this.t},n.getParent=function(){return this.i},n.getChild=function(){return this.u},n.setChild=function(t){return this.u=t,this},n.dispose=function(){this.s||(this.s=!0,this.o.forEach(function(t){return t()}),this.o.length=0)},n.onDispose=function(t){return this.o.push(t),this},n.isDisposed=function(){return this.s},t}(),f=function(){function t(){this.h=[]}var n=t.prototype;return n.getLinks=function(){return this.h},n.listParents=function(t){return this.h.filter(function(n){return n.getChild()===t}).map(function(t){return t.getParent()})},n.listChildren=function(t){return this.h.filter(function(n){return n.getParent()===t}).map(function(t){return t.getChild()})},n.disconnectChildren=function(t){return this.h.filter(function(n){return n.getParent()===t}).forEach(function(t){return t.dispose()}),this},n.disconnectParents=function(t,n){var r=this.h.filter(function(n){return n.getChild()===t});return n&&(r=r.filter(function(t){return n(t.getParent())})),r.forEach(function(t){return t.dispose()}),this},n.link=function(t,n,r){if(!r)return null;var i=new h(t,n,r);return this.registerLink(i),i},n.registerLink=function(t){var n=this;return this.h.push(t),t.onDispose(function(){return n.unlink(t)}),t},n.unlink=function(t){return this.h=this.h.filter(function(n){return n!==t}),this},t}();function c(t,n){Object.defineProperty(t,n,{get:function(){return this["__"+n]},set:function(t){var r=this,i=this["__"+n];i&&!Array.isArray(i)&&i.dispose(),t&&!Array.isArray(t)&&t.onDispose(function(){r["__"+n]=null}),this["__"+n]=t},enumerable:!0})}function a(t,n){}var v=function(t){function n(n,r){var i;return void 0===r&&(r=""),(i=t.call(this,n)||this).t="",i.v={},i.t=r,i}i(n,t);var r=n.prototype;return r.getName=function(){return this.t},r.setName=function(t){return this.t=t,this},r.getExtras=function(){return this.v},r.setExtras=function(t){return this.v=t,this},r.clone=function(){throw new Error("Not implemented.")},r.detach=function(){return this.l.disconnectParents(this,function(t){return"Root"!==t.propertyType}),this},r.listParents=function(){return this.listGraphParents()},n}(function(){function t(t){this.s=!1,this.l=t}var n=t.prototype;return n.canLink=function(t){return this.l===t.l},n.isDisposed=function(){return this.s},n.dispose=function(){this.l.disconnectChildren(this),this.l.disconnectParents(this),this.s=!0},n.detach=function(){return this.l.disconnectParents(this),this},n.swap=function(t,n){var r=this;return this.l.getLinks().filter(function(n){return n.getParent()===r&&n.getChild()===t}).forEach(function(t){return t.setChild(n)}),this},n.addGraphChild=function(t,n){return t.push(n),n.onDispose(function(){var r=t.filter(function(t){return t!==n});t.length=0,t.push.apply(t,r)}),this},n.removeGraphChild=function(t,n){return t.filter(function(t){return t.getChild()===n}).forEach(function(t){return t.dispose()}),this},n.listGraphParents=function(){return this.l.listParents(this)},t}()),l=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).extensions=[],n}i(n,t);var r=n.prototype;return r.getExtension=function(t){var n=t.EXTENSION_NAME,r=this.extensions.find(function(t){return t.getChild().extensionName===n});return r?r.getChild():null},r.setExtension=function(t,n){var r=this.getExtension(t);return r&&this.removeGraphChild(this.extensions,r),n?(n.p(this),this.addGraphChild(this.extensions,this.l.link(n.extensionName,this,n))):this},r.listExtensions=function(){return this.extensions.map(function(t){return t.getChild()})},n}(v);s([a],l.prototype,"extensions",void 0);var d=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ACCESSOR,r.A=null,r.m="SCALAR",r.T=null,r.g=!1,r.M=w,r.S=w,r.buffer=null,r}i(r,n),r.getElementSize=function(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)}},r.getComponentSize=function(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)}};var u=r.prototype;return u.getMinNormalized=function(t){var n=this.getElementSize();this.getMin(t);for(var r=0;r<n;r++)t[r]=this.S(t[r]);return t},u.getMin=function(t){for(var n=this.getCount(),r=this.getElementSize(),i=0;i<r;i++)t[i]=Infinity;for(var u=0;u<n*r;u+=r)for(var e=0;e<r;e++){var s=this.A[u+e];Number.isFinite(s)&&(t[e]=Math.min(t[e],s))}return t},u.getMaxNormalized=function(t){var n=this.getElementSize();this.getMax(t);for(var r=0;r<n;r++)t[r]=this.S(t[r]);return t},u.getMax=function(t){for(var n=this.getCount(),r=this.getElementSize(),i=0;i<r;i++)t[i]=-Infinity;for(var u=0;u<n*r;u+=r)for(var e=0;e<r;e++){var s=this.A[u+e];Number.isFinite(s)&&(t[e]=Math.max(t[e],s))}return t},u.getCount=function(){return this.A.length/this.getElementSize()},u.getType=function(){return this.m},u.setType=function(t){return this.m=t,this},u.getElementSize=function(){return r.getElementSize(this.m)},u.getComponentSize=function(){return this.A.BYTES_PER_ELEMENT},u.getComponentType=function(){return this.T},u.getNormalized=function(){return this.g},u.setNormalized=function(t){var n=this;return this.g=t,t?(this.S=function(t){return function(t,n){switch(n){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)}}(t,n.T)},this.M=function(t){return function(t,n){switch(n){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)}}(t,n.T)}):(this.S=w,this.M=w),this},u.getScalar=function(t){var n=this.getElementSize();return this.S(this.A[t*n])},u.setScalar=function(t,n){return this.A[t*this.getElementSize()]=this.M(n),this},u.getElement=function(t,n){for(var r=this.getElementSize(),i=0;i<r;i++)n[i]=this.S(this.A[t*r+i]);return n},u.setElement=function(t,n){for(var r=this.getElementSize(),i=0;i<r;i++)this.A[t*r+i]=this.M(n[i]);return this},u.getBuffer=function(){return this.buffer.getChild()},u.setBuffer=function(t){return this.buffer=this.l.link("buffer",this,t),this},u.getArray=function(){return this.A},u.setArray=function(t){return this.T=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.A=t,this},u.getByteLength=function(){return this.A.byteLength},r}(l);function w(t){return t}d.Type={SCALAR:"SCALAR",VEC2:"VEC2",VEC3:"VEC3",VEC4:"VEC4",MAT3:"MAT3",MAT4:"MAT4"},d.ComponentType={BYTE:5120,UNSIGNED_BYTE:5121,SHORT:5122,UNSIGNED_SHORT:5123,UNSIGNED_INT:5125,FLOAT:5126},s([c],d.prototype,"buffer",void 0);var p=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ANIMATION,r.channels=[],r.samplers=[],r}i(r,n);var u=r.prototype;return u.addChannel=function(t){var n=this.l.link("channel",this,t);return this.addGraphChild(this.channels,n)},u.removeChannel=function(t){return this.removeGraphChild(this.channels,t)},u.listChannels=function(){return this.channels.map(function(t){return t.getChild()})},u.addSampler=function(t){var n=this.l.link("sampler",this,t);return this.addGraphChild(this.samplers,n)},u.removeSampler=function(t){return this.removeGraphChild(this.samplers,t)},u.listSamplers=function(){return this.samplers.map(function(t){return t.getChild()})},r}(l);s([a],p.prototype,"channels",void 0),s([a],p.prototype,"samplers",void 0);var A=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ANIMATION_CHANNEL,r.R=null,r.targetNode=null,r.sampler=null,r}i(r,n);var u=r.prototype;return u.getTargetPath=function(){return this.R},u.setTargetPath=function(t){return this.R=t,this},u.getTargetNode=function(){return this.targetNode?this.targetNode.getChild():null},u.setTargetNode=function(t){return this.targetNode=this.l.link("target.node",this,t),this},u.getSampler=function(){return this.sampler?this.sampler.getChild():null},u.setSampler=function(t){return this.sampler=this.l.link("sampler",this,t),this},r}(v);s([c],A.prototype,"targetNode",void 0),s([c],A.prototype,"sampler",void 0);var y=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ANIMATION_SAMPLER,r.N="LINEAR",r.input=null,r.output=null,r}i(r,n);var u=r.prototype;return u.getInterpolation=function(){return this.N},u.setInterpolation=function(t){return this.N=t,this},u.getInput=function(){return this.input?this.input.getChild():null},u.setInput=function(t){return this.input=this.l.link("input",this,t),this},u.getOutput=function(){return this.output?this.output.getChild():null},u.setOutput=function(t){return this.output=this.l.link("output",this,t),this},r}(v);s([c],y.prototype,"input",void 0),s([c],y.prototype,"output",void 0);var b=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.BUFFER,r}i(r,n);var u=r.prototype;return u.getURI=function(){return this.U},u.setURI=function(t){return this.U=t,this},r}(l),m=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.CAMERA,r.m="perspective",r}i(r,n);var u=r.prototype;return u.getType=function(){return this.m},u.setType=function(t){return this.m=t,this},u.getZNear=function(){return this.I},u.setZNear=function(t){return this.I=t,this},u.getZFar=function(){return this._},u.setZFar=function(t){return this._=t,this},u.getAspectRatio=function(){return this.O},u.setAspectRatio=function(t){return this.O=t,this},u.getYFov=function(){return this.j},u.setYFov=function(t){return this.j=t,this},u.getXMag=function(){return this.L},u.setXMag=function(t){return this.L=t,this},u.getYMag=function(){return this.k},u.setYMag=function(t){return this.k=t,this},r}(l),E=function(t){function n(n,r){var i;return(i=t.call(this,n)||this).C=r,i.C.addExtensionProperty(function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(i)),i}i(n,t);var r=n.prototype;return r.dispose=function(){this.C.removeExtensionProperty(this),t.prototype.dispose.call(this)},r.p=function(t){if(!this.parentTypes.includes(t.propertyType))throw new Error('Parent "'+t.propertyType+'" invalid for child "'+this.propertyType+'".')},n}(v),T=function(){function t(){}return t.createBufferFromDataURI=function(t){if("undefined"==typeof Buffer){for(var n=atob(t.split(",")[1]),r=new Uint8Array(n.length),i=0;i<n.length;i++)r[i]=n.charCodeAt(i);return r.buffer}var u=t.split(",")[1],e=t.indexOf("base64")>=0;return this.trim(Buffer.from(u,e?"base64":"utf8"))},t.encodeText=function(t){return"undefined"!=typeof TextEncoder?(new TextEncoder).encode(t).buffer:this.trim(Buffer.from(t))},t.decodeText=function(t){return"undefined"!=typeof TextDecoder?(new TextDecoder).decode(t):Buffer.from(t).toString("utf8")},t.trim=function(t){var n=t.byteOffset;return t.buffer.slice(n,n+t.byteLength)},t.concat=function(t){for(var n,r=0,i=e(t);!(n=i()).done;)r+=n.value.byteLength;for(var u,s=new Uint8Array(r),o=0,h=e(t);!(u=h()).done;){var f=u.value;s.set(new Uint8Array(f),o),o+=f.byteLength}return s.buffer},t.pad=function(t,n){void 0===n&&(n=0);var r=this.padNumber(t.byteLength);if(r!==t.byteLength){var i=new Uint8Array(r);if(i.set(new Uint8Array(t)),0!==n)for(var u=t.byteLength;u<r;u++)i[u]=n;return i.buffer}return t},t.padNumber=function(t){return 4*Math.ceil(t/4)},t.equals=function(t,n){if(t===n)return!0;if(t.byteLength!==n.byteLength)return!1;for(var r=new DataView(t),i=new DataView(n),u=t.byteLength;u--;)if(r.getUint8(u)!==i.getUint8(u))return!1;return!0},t}(),g=function(){function t(){}return t.basename=function(t){return t.split(/[\\/]/).pop().split(/[.]/).shift()},t.extension=function(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"},t}(),M=function(){function t(){}return t.getSizeJPEG=function(t){var n,r;for(t=t.slice(4);t.length;){if(n=t.readUInt16BE(0),x(t,n),192===(r=t[n+1])||193===r||194===r)return[t.readUInt16BE(n+7),t.readUInt16BE(n+5)];t=t.slice(n+2)}throw new TypeError("Invalid JPG, no size found")},t.getSizePNG=function(t){return"CgBI"===t.toString("ascii",12,16)?[t.readUInt32BE(32),t.readUInt32BE(36)]:[t.readUInt32BE(16),t.readUInt32BE(20)]},t.mimeTypeToExtension=function(t){return"image/jpeg"===t?"jpg":t.split("/").pop()},t.extensionToMimeType=function(t){return"jpg"===t?"image/jpeg":"image/"+t},t}();function x(t,n){if(n>t.length)throw new TypeError("Corrupt JPG, exceeded buffer limits");if(255!==t[n])throw new TypeError("Invalid JPG, marker table corrupted")}var S=function(){function t(t){this.verbosity=t}var n=t.prototype;return n.debug=function(n){this.verbosity<=t.Verbosity.DEBUG&&console.debug(n)},n.info=function(n){this.verbosity<=t.Verbosity.INFO&&console.info(n)},n.warn=function(n){this.verbosity<=t.Verbosity.WARN&&console.warn(n)},n.error=function(n){this.verbosity<=t.Verbosity.ERROR&&console.error(n)},t}();S.Verbosity={SILENT:4,ERROR:3,WARN:2,INFO:1,DEBUG:0};var R="23456789abdegjkmnpqrvwxyzABDEGJKMNPQRVWXYZ",N=new Set,U=function(){for(var t="",n=0;n<6;n++)t+=R.charAt(Math.floor(Math.random()*R.length));return t},I=function(){for(var t=0;t<999;t++){var n=U();if(!N.has(n))return N.add(n),n}},_=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.TEXTURE,r.image=null,r.mimeType="",r.uri="",r}i(r,n);var u=r.prototype;return u.getMimeType=function(){return this.mimeType},u.setMimeType=function(t){return this.mimeType=t,this},u.getURI=function(){return this.uri},u.setURI=function(t){return this.uri=t,this},u.getImage=function(){return this.image},u.setImage=function(t){return this.image=t,this},u.getSize=function(){return(this.mimeType?"image/png"===this.mimeType:this.uri.match(/\.png$/))?M.getSizePNG(Buffer.from(this.image)):M.getSizeJPEG(Buffer.from(this.image))},r}(l),O=function(){function n(){this.propertyType=t.PropertyType.TEXTURE_INFO,this.texCoord=0}var r=n.prototype;return r.getTexCoord=function(){return this.texCoord},r.setTexCoord=function(t){return this.texCoord=t,this},n}(),j=function(){function n(){this.propertyType=t.PropertyType.TEXTURE_SAMPLER,this.B=null,this.P=null,this.V=10497,this.D=10497}var r=n.prototype;return r.getMagFilter=function(){return this.B},r.setMagFilter=function(t){return this.B=t,this},r.getMinFilter=function(){return this.P},r.setMinFilter=function(t){return this.P=t,this},r.getWrapS=function(){return this.V},r.setWrapS=function(t){return this.V=t,this},r.getWrapT=function(){return this.D},r.setWrapT=function(t){return this.D=t,this},n}();j.TextureWrapMode={CLAMP_TO_EDGE:33071,MIRRORED_REPEAT:33648,REPEAT:10497},j.TextureMagFilter={NEAREST:9728,LINEAR:9729},j.TextureMinFilter={NEAREST:9728,LINEAR:9729,NEAREST_MIPMAP_NEAREST:9984,LINEAR_MIPMAP_NEAREST:9985,NEAREST_MIPMAP_LINEAR:9986,LINEAR_MIPMAP_LINEAR:9987};var L=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).textureInfo=new O,n.sampler=new j,n}return i(n,t),n}(h),k=function(t){function n(){var n;return(n=t.apply(this,arguments)||this).semantic="",n}return i(n,t),n}(h),C=function(t){function n(){return t.apply(this,arguments)||this}return i(n,t),n}(h),B=function(t){function n(){return t.apply(this,arguments)||this}i(n,t);var r=n.prototype;return r.linkTexture=function(t,n,r){if(!r)return null;var i=new L(t,n,r);return this.registerLink(i),i},r.linkAttribute=function(t,n,r){if(!r)return null;var i=new k(t,n,r);return this.registerLink(i),i},r.linkIndex=function(t,n,r){if(!r)return null;var i=new C(t,n,r);return this.registerLink(i),i},n}(f),P=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.MATERIAL,r.G="OPAQUE",r.F=.5,r.J=!1,r.$=[1,1,1,1],r.Y=[0,0,0],r.q=1,r.H=1,r.K=1,r.W=1,r.baseColorTexture=null,r.emissiveTexture=null,r.normalTexture=null,r.occlusionTexture=null,r.metallicRoughnessTexture=null,r}i(r,n);var u=r.prototype;return u.getDoubleSided=function(){return this.J},u.setDoubleSided=function(t){return this.J=t,this},u.getAlphaMode=function(){return this.G},u.setAlphaMode=function(t){return this.G=t,this},u.getAlphaCutoff=function(){return this.F},u.setAlphaCutoff=function(t){return this.F=t,this},u.getBaseColorFactor=function(){return this.$},u.setBaseColorFactor=function(t){return this.$=t,this},u.getBaseColorTexture=function(){return this.baseColorTexture?this.baseColorTexture.getChild():null},u.getBaseColorTextureInfo=function(){return this.baseColorTexture?this.baseColorTexture.textureInfo:null},u.getBaseColorTextureSampler=function(){return this.baseColorTexture?this.baseColorTexture.sampler:null},u.setBaseColorTexture=function(t){return this.baseColorTexture=this.l.linkTexture("baseColorTexture",this,t),this},u.getEmissiveFactor=function(){return this.Y},u.setEmissiveFactor=function(t){return this.Y=t,this},u.getEmissiveTexture=function(){return this.emissiveTexture?this.emissiveTexture.getChild():null},u.getEmissiveTextureInfo=function(){return this.emissiveTexture?this.emissiveTexture.textureInfo:null},u.getEmissiveTextureSampler=function(){return this.emissiveTexture?this.emissiveTexture.sampler:null},u.setEmissiveTexture=function(t){return this.emissiveTexture=this.l.linkTexture("emissiveTexture",this,t),this},u.getNormalScale=function(){return this.q},u.setNormalScale=function(t){return this.q=t,this},u.getNormalTexture=function(){return this.normalTexture?this.normalTexture.getChild():null},u.getNormalTextureInfo=function(){return this.normalTexture?this.normalTexture.textureInfo:null},u.getNormalTextureSampler=function(){return this.normalTexture?this.normalTexture.sampler:null},u.setNormalTexture=function(t){return this.normalTexture=this.l.linkTexture("normalTexture",this,t),this},u.getOcclusionStrength=function(){return this.H},u.setOcclusionStrength=function(t){return this.H=t,this},u.getOcclusionTexture=function(){return this.occlusionTexture?this.occlusionTexture.getChild():null},u.getOcclusionTextureInfo=function(){return this.occlusionTexture?this.occlusionTexture.textureInfo:null},u.getOcclusionTextureSampler=function(){return this.occlusionTexture?this.occlusionTexture.sampler:null},u.setOcclusionTexture=function(t){return this.occlusionTexture=this.l.linkTexture("occlusionTexture",this,t),this},u.getRoughnessFactor=function(){return this.K},u.setRoughnessFactor=function(t){return this.K=t,this},u.getMetallicFactor=function(){return this.W},u.setMetallicFactor=function(t){return this.W=t,this},u.getMetallicRoughnessTexture=function(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.getChild():null},u.getMetallicRoughnessTextureInfo=function(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.textureInfo:null},u.getMetallicRoughnessTextureSampler=function(){return this.metallicRoughnessTexture?this.metallicRoughnessTexture.sampler:null},u.setMetallicRoughnessTexture=function(t){return this.metallicRoughnessTexture=this.l.linkTexture("metallicRoughnessTexture",this,t),this},r}(l);s([c],P.prototype,"baseColorTexture",void 0),s([c],P.prototype,"emissiveTexture",void 0),s([c],P.prototype,"normalTexture",void 0),s([c],P.prototype,"occlusionTexture",void 0),s([c],P.prototype,"metallicRoughnessTexture",void 0);var V=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.MESH,r.X=[],r.primitives=[],r}i(r,n);var u=r.prototype;return u.addPrimitive=function(t){return this.addGraphChild(this.primitives,this.l.link("primitive",this,t))},u.removePrimitive=function(t){return this.removeGraphChild(this.primitives,t)},u.listPrimitives=function(){return this.primitives.map(function(t){return t.getChild()})},u.getWeights=function(){return this.X},u.setWeights=function(t){return this.X=t,this},r}(l);s([a],V.prototype,"primitives",void 0);var D=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.PRIMITIVE,r.Z=4,r.indices=null,r.attributes=[],r.targets=[],r.material=null,r}i(r,n);var u=r.prototype;return u.getIndices=function(){return this.indices?this.indices.getChild():null},u.setIndices=function(t){return this.indices=this.l.linkIndex("index",this,t),this},u.getAttribute=function(t){var n=this.attributes.find(function(n){return n.semantic===t});return n?n.getChild():null},u.setAttribute=function(t,n){var r=this.getAttribute(t);if(r&&this.removeGraphChild(this.attributes,r),!n)return this;var i=this.l.linkAttribute(t.toLowerCase(),this,n);return i.semantic=t,this.addGraphChild(this.attributes,i)},u.listAttributes=function(){return this.attributes.map(function(t){return t.getChild()})},u.listSemantics=function(){return this.attributes.map(function(t){return t.semantic})},u.getMaterial=function(){return this.material?this.material.getChild():null},u.setMaterial=function(t){return this.material=this.l.link("material",this,t),this},u.getMode=function(){return this.Z},u.setMode=function(t){return this.Z=t,this},u.listTargets=function(){return this.targets.map(function(t){return t.getChild()})},u.addTarget=function(t){return this.addGraphChild(this.targets,this.l.link("target",this,t)),this},u.removeTarget=function(t){return this.removeGraphChild(this.targets,t)},r}(v);s([c],D.prototype,"indices",void 0),s([a],D.prototype,"attributes",void 0),s([a],D.prototype,"targets",void 0),s([c],D.prototype,"material",void 0);var G=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.PRIMITIVE_TARGET,r.attributes=[],r}i(r,n);var u=r.prototype;return u.getAttribute=function(t){var n=this.attributes.find(function(n){return n.semantic===t});return n?n.getChild():null},u.setAttribute=function(t,n){var r=this.getAttribute(t);if(r&&this.removeGraphChild(this.attributes,r),!n)return this;var i=this.l.linkAttribute(t.toLowerCase(),this,n);return i.semantic=t,this.addGraphChild(this.attributes,i)},u.listAttributes=function(){return this.attributes.map(function(t){return t.getChild()})},u.listSemantics=function(){return this.attributes.map(function(t){return t.semantic})},r}(v);s([a],G.prototype,"attributes",void 0);var F=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.NODE,r.tt=[0,0,0],r.nt=[0,0,0,1],r.rt=[1,1,1],r.X=[],r.camera=null,r.mesh=null,r.skin=null,r.children=[],r}i(r,n);var u=r.prototype;return u.getTranslation=function(){return this.tt},u.getRotation=function(){return this.nt},u.getScale=function(){return this.rt},u.setTranslation=function(t){return this.tt=t,this},u.setRotation=function(t){return this.nt=t,this},u.setScale=function(t){return this.rt=t,this},u.addChild=function(t){var n=this.l.link("child",this,t);return this.addGraphChild(this.children,n)},u.removeChild=function(t){return this.removeGraphChild(this.children,t)},u.listChildren=function(){return this.children.map(function(t){return t.getChild()})},u.getMesh=function(){return this.mesh?this.mesh.getChild():null},u.setMesh=function(t){return this.mesh=this.l.link("mesh",this,t),this},u.getCamera=function(){return this.camera?this.camera.getChild():null},u.setCamera=function(t){return this.camera=this.l.link("camera",this,t),this},u.getSkin=function(){return this.skin?this.skin.getChild():null},u.setSkin=function(t){return this.skin=this.l.link("skin",this,t),this},u.getWeights=function(){return this.X},u.setWeights=function(t){return this.X=t,this},r}(l);s([c],F.prototype,"camera",void 0),s([c],F.prototype,"mesh",void 0),s([c],F.prototype,"skin",void 0),s([a],F.prototype,"children",void 0);var J=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.ROOT,r.it={generator:"glTF-Transform v0.4.0-alpha.3",version:"2.0"},r.ut=new Set,r.scenes=[],r.nodes=[],r.cameras=[],r.skins=[],r.meshes=[],r.materials=[],r.textures=[],r.animations=[],r.accessors=[],r.buffers=[],r}i(r,n);var u=r.prototype;return u.getAsset=function(){return this.it},u.listExtensionsUsed=function(){return Array.from(this.ut)},u.listExtensionsRequired=function(){return this.listExtensionsUsed().filter(function(t){return t.isRequired()})},u.et=function(t){if(this.ut.has(t))throw new Error('Extension "'+t.extensionName+'" is already enabled.');return this.ut.add(t),this},u.st=function(t){return this.ut.delete(t),this},u.ot=function(t){return this.addGraphChild(this.scenes,this.l.link("scene",this,t))},u.listScenes=function(){return this.scenes.map(function(t){return t.getChild()})},u.ht=function(t){return this.addGraphChild(this.nodes,this.l.link("node",this,t))},u.listNodes=function(){return this.nodes.map(function(t){return t.getChild()})},u.ft=function(t){return this.addGraphChild(this.cameras,this.l.link("camera",this,t))},u.listCameras=function(){return this.cameras.map(function(t){return t.getChild()})},u.ct=function(t){return this.addGraphChild(this.skins,this.l.link("skin",this,t))},u.listSkins=function(){return this.skins.map(function(t){return t.getChild()})},u.at=function(t){return this.addGraphChild(this.meshes,this.l.link("mesh",this,t))},u.listMeshes=function(){return this.meshes.map(function(t){return t.getChild()})},u.vt=function(t){return this.addGraphChild(this.materials,this.l.link("material",this,t))},u.listMaterials=function(){return this.materials.map(function(t){return t.getChild()})},u.lt=function(t){return this.addGraphChild(this.textures,this.l.link("texture",this,t))},u.listTextures=function(){return this.textures.map(function(t){return t.getChild()})},u.dt=function(t){return this.addGraphChild(this.animations,this.l.link("animation",this,t))},u.listAnimations=function(){return this.animations.map(function(t){return t.getChild()})},u.wt=function(t){return this.addGraphChild(this.accessors,this.l.link("accessor",this,t))},u.listAccessors=function(){return this.accessors.map(function(t){return t.getChild()})},u.pt=function(t){return this.addGraphChild(this.buffers,this.l.link("buffer",this,t))},u.listBuffers=function(){return this.buffers.map(function(t){return t.getChild()})},r}(v);s([a],J.prototype,"scenes",void 0),s([a],J.prototype,"nodes",void 0),s([a],J.prototype,"cameras",void 0),s([a],J.prototype,"skins",void 0),s([a],J.prototype,"meshes",void 0),s([a],J.prototype,"materials",void 0),s([a],J.prototype,"textures",void 0),s([a],J.prototype,"animations",void 0),s([a],J.prototype,"accessors",void 0),s([a],J.prototype,"buffers",void 0);var z=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.SCENE,r.nodes=[],r}i(r,n);var u=r.prototype;return u.addNode=function(t){return this.addGraphChild(this.nodes,this.l.link("node",this,t))},u.removeNode=function(t){return this.removeGraphChild(this.nodes,t)},u.listNodes=function(){return this.nodes.map(function(t){return t.getChild()})},r}(l);s([a],z.prototype,"nodes",void 0);var $=function(n){function r(){var r;return(r=n.apply(this,arguments)||this).propertyType=t.PropertyType.SKIN,r.skeleton=null,r.inverseBindMatrices=null,r.joints=[],r}i(r,n);var u=r.prototype;return u.getSkeleton=function(){return this.skeleton?this.skeleton.getChild():null},u.setSkeleton=function(t){return this.skeleton=this.l.link("skeleton",this,t),this},u.getInverseBindMatrices=function(){return this.inverseBindMatrices?this.inverseBindMatrices.getChild():null},u.setInverseBindMatrices=function(t){return this.inverseBindMatrices=this.l.link("inverseBindMatrices",this,t),this},u.addJoint=function(t){var n=this.l.link("joint",this,t);return this.addGraphChild(this.joints,n)},u.removeJoint=function(t){return this.removeGraphChild(this.joints,t)},u.listJoints=function(){return this.joints.map(function(t){return t.getChild()})},r}(l);s([c],$.prototype,"skeleton",void 0),s([c],$.prototype,"inverseBindMatrices",void 0),s([a],$.prototype,"joints",void 0);var Y=function(){function t(){this.graph=new B,this.root=new J(this.graph),this.logger=new S(S.Verbosity.INFO)}var n=t.prototype;return n.getRoot=function(){return this.root},n.getGraph=function(){return this.graph},n.getLogger=function(){return this.logger},n.setLogger=function(t){return this.logger=t,this},n.clone=function(){throw new Error("Not implemented.")},n.transform=function(){for(var t,n=e([].slice.call(arguments));!(t=n()).done;){var r=t.value;r(this)}return this},n.createExtension=function(t){return this.getRoot().listExtensionsUsed().find(function(n){return n.extensionName===t.EXTENSION_NAME})||new t(this)},n.createScene=function(t){var n=new z(this.graph,t);return this.root.ot(n),n},n.createNode=function(t){var n=new F(this.graph,t);return this.root.ht(n),n},n.createCamera=function(t){var n=new m(this.graph,t);return this.root.ft(n),n},n.createSkin=function(t){var n=new $(this.graph,t);return this.root.ct(n),n},n.createMesh=function(t){var n=new V(this.graph,t);return this.root.at(n),n},n.createPrimitive=function(){return new D(this.graph)},n.createPrimitiveTarget=function(t){return new G(this.graph,t)},n.createMaterial=function(t){var n=new P(this.graph,t);return this.root.vt(n),n},n.createTexture=function(t){var n=new _(this.graph,t);return this.root.lt(n),n},n.createAnimation=function(t){var n=new p(this.graph,t);return this.root.dt(n),n},n.createAnimationChannel=function(){return new A(this.graph)},n.createAnimationSampler=function(){return new y(this.graph)},n.createAccessor=function(t,n){void 0===n&&(n=null),n||(n=this.getRoot().listBuffers()[0]);var r=new d(this.graph,t).setBuffer(n);return this.root.wt(r),r},n.createBuffer=function(t){var n=new b(this.graph,t);return this.root.pt(n),n},t}(),q=function(){function t(t){this.doc=t,this.At=!1,this.yt=new Set,t.getRoot().et(this)}var n=t.prototype;return n.dispose=function(){this.doc.getRoot().st(this);for(var t,n=e(this.yt);!(t=n()).done;)t.value.dispose()},n.isRequired=function(){return this.At},n.setRequired=function(t){return this.At=t,this},n.addExtensionProperty=function(t){return this.yt.add(t),this},n.removeExtensionProperty=function(t){return this.yt.delete(t),this},t}(),H=function(t){this.nativeDocument=t,this.buffers=[],this.bufferViewBuffers=[],this.accessors=[],this.textures=[],this.materials=[],this.meshes=[],this.cameras=[],this.nodes=[],this.skins=[],this.animations=[],this.scenes=[]},K={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},Q=function(){function t(){}return t.read=function(t,i){var u=t.json,s=new Y;if("2.0"!==u.asset.version)throw new Error('Unsupported glTF version: "'+u.asset.version+'".');var o=new H(t);o.buffers=(u.buffers||[]).map(function(t){var n=s.createBuffer(t.name);return t.uri&&0!==t.uri.indexOf("__")&&n.setURI(t.uri),n}),o.bufferViewBuffers=(u.bufferViews||[]).map(function(t){return o.buffers[t.buffer]}),o.accessors=(u.accessors||[]).map(function(n){var i,u=s.createAccessor(n.name,o.bufferViewBuffers[n.bufferView]);return u.setType(n.type),i=void 0!==n.sparse?function(t,n){var i,u=K[t.componentType],e=d.getElementSize(t.type);i=void 0!==t.bufferView?Z(t,n).slice():new u(t.count*e);for(var s=t.sparse.count,o=r(r(r({},t),t.sparse.indices),{},{count:s,type:"SCALAR"}),h=r(r(r({},t),t.sparse.values),{},{count:s}),f=Z(o,n),c=Z(h,n),a=0;a<o.count;a++)for(var v=0;v<e;v++)i[f[a]*e+v]=c[a*e+v];return i}(n,t):Z(n,t).slice(),void 0!==n.normalized&&u.setNormalized(n.normalized),u.setArray(i),u});var h=u.textures||[];o.textures=(u.images||[]).map(function(n){var r=s.createTexture(n.name);if(void 0!==n.bufferView){var i=u.bufferViews[n.bufferView],e=t.json.buffers[i.buffer],o=i.byteOffset||0,h=(e.uri?t.resources[e.uri]:t.resources["bt"]).slice(o,o+i.byteLength);r.setImage(h)}else void 0!==n.uri&&(r.setImage(t.resources[n.uri]),0!==n.uri.indexOf("__")&&r.setURI(n.uri));if(void 0!==n.mimeType)r.setMimeType(n.mimeType);else if(n.uri){var f=g.extension(n.uri);r.setMimeType(M.extensionToMimeType(f))}return r}),o.materials=(u.materials||[]).map(function(n){var r=s.createMaterial(n.name);void 0!==n.alphaMode&&r.setAlphaMode(n.alphaMode),void 0!==n.alphaCutoff&&r.setAlphaCutoff(n.alphaCutoff),void 0!==n.doubleSided&&r.setDoubleSided(n.doubleSided);var i=n.pbrMetallicRoughness||{};if(void 0!==i.baseColorFactor&&r.setBaseColorFactor(i.baseColorFactor),void 0!==n.emissiveFactor&&r.setEmissiveFactor(n.emissiveFactor),void 0!==i.metallicFactor&&r.setMetallicFactor(i.metallicFactor),void 0!==i.roughnessFactor&&r.setRoughnessFactor(i.roughnessFactor),void 0!==i.baseColorTexture){var u=i.baseColorTexture;r.setBaseColorTexture(o.textures[h[u.index].source]),W(r.getBaseColorTextureInfo(),u),X(r.getBaseColorTextureSampler(),u,t)}if(void 0!==n.emissiveTexture){var e=n.emissiveTexture;r.setEmissiveTexture(o.textures[h[e.index].source]),W(r.getEmissiveTextureInfo(),e),X(r.getEmissiveTextureSampler(),e,t)}if(void 0!==n.normalTexture){var f=n.normalTexture;r.setNormalTexture(o.textures[h[f.index].source]),W(r.getNormalTextureInfo(),f),X(r.getNormalTextureSampler(),f,t),void 0!==n.normalTexture.scale&&r.setNormalScale(n.normalTexture.scale)}if(void 0!==n.occlusionTexture){var c=n.occlusionTexture;r.setOcclusionTexture(o.textures[h[c.index].source]),W(r.getOcclusionTextureInfo(),c),X(r.getOcclusionTextureSampler(),c,t),void 0!==n.occlusionTexture.strength&&r.setOcclusionStrength(n.occlusionTexture.strength)}if(void 0!==i.metallicRoughnessTexture){var a=i.metallicRoughnessTexture;r.setMetallicRoughnessTexture(o.textures[h[a.index].source]),W(r.getMetallicRoughnessTextureInfo(),a),X(r.getMetallicRoughnessTextureSampler(),a,t)}return r}),o.meshes=(u.meshes||[]).map(function(t){var n=s.createMesh(t.name);return void 0!==t.weights&&n.setWeights(t.weights),t.primitives.forEach(function(r){var i=s.createPrimitive();void 0!==r.material&&i.setMaterial(o.materials[r.material]),void 0!==r.mode&&i.setMode(r.mode);for(var u=0,e=Object.entries(r.attributes||{});u<e.length;u++){var h=e[u];i.setAttribute(h[0],o.accessors[h[1]])}void 0!==r.indices&&i.setIndices(o.accessors[r.indices]);var f=t.extras&&t.extras.targetNames||[];(r.targets||[]).forEach(function(t,n){for(var r=f[n]||n.toString(),u=s.createPrimitiveTarget(r),e=0,h=Object.entries(t);e<h.length;e++){var c=h[e];u.setAttribute(c[0],o.accessors[c[1]])}i.addTarget(u)}),n.addPrimitive(i)}),n}),o.cameras=(u.cameras||[]).map(function(t){var n=s.createCamera(t.name).setType(t.type);return"perspective"===t.type?n.setZNear(t.perspective.znear).setZFar(t.perspective.zfar).setYFov(t.perspective.yfov).setAspectRatio(t.perspective.aspectRatio):n.setZNear(t.orthographic.znear).setZFar(t.orthographic.zfar).setXMag(t.orthographic.xmag).setYMag(t.orthographic.ymag),n});var f=u.nodes||[];o.nodes=f.map(function(t){var r=s.createNode(t.name);return void 0!==t.translation&&r.setTranslation(t.translation),void 0!==t.rotation&&r.setRotation(t.rotation),void 0!==t.scale&&r.setScale(t.scale),void 0!==t.matrix&&(r.setTranslation(n.getTranslation([],t.matrix)),r.setRotation(n.getRotation([],t.matrix)),r.setScale(n.getScaling([],t.matrix))),void 0!==t.weights&&r.setWeights(t.weights),r}),o.skins=(u.skins||[]).map(function(t){var n=s.createSkin(t.name);void 0!==t.inverseBindMatrices&&n.setInverseBindMatrices(o.accessors[t.inverseBindMatrices]),void 0!==t.skeleton&&n.setSkeleton(o.nodes[t.skeleton]);for(var r,i=e(t.joints);!(r=i()).done;)n.addJoint(o.nodes[r.value]);return n}),f.map(function(t,n){var r=o.nodes[n];(t.children||[]).forEach(function(t){return r.addChild(o.nodes[t])}),void 0!==t.mesh&&r.setMesh(o.meshes[t.mesh]),void 0!==t.camera&&r.setCamera(o.cameras[t.camera]),void 0!==t.skin&&r.setSkin(o.skins[t.skin])}),o.animations=(u.animations||[]).map(function(t){var n=s.createAnimation(t.name),r=(t.samplers||[]).map(function(t){var r=s.createAnimationSampler().setInput(o.accessors[t.input]).setOutput(o.accessors[t.output]).setInterpolation(t.interpolation||"LINEAR");return n.addSampler(r),r});return(t.channels||[]).forEach(function(t){var i=s.createAnimationChannel().setSampler(r[t.sampler]).setTargetNode(o.nodes[t.target.node]).setTargetPath(t.target.path);n.addChannel(i)}),n}),o.scenes=(u.scenes||[]).map(function(t){var n=s.createScene(t.name);return(t.nodes||[]).map(function(t){return o.nodes[t]}).forEach(function(t){return n.addNode(t)}),n});for(var c,a=u.extensionsUsed||[],v=u.extensionsRequired||[],l=e(i.extensions);!(c=l()).done;){var w=c.value;a.includes(w.EXTENSION_NAME)&&s.createExtension(w).setRequired(v.includes(w.EXTENSION_NAME)).read(o)}return s},t}();function W(t,n){void 0!==n.texCoord&&t.setTexCoord(n.texCoord)}function X(t,n,r){var i=r.json.textures[n.index];if(void 0!==i.sampler){var u=r.json.samplers[i.sampler];void 0!==u.magFilter&&t.setMagFilter(u.magFilter),void 0!==u.minFilter&&t.setMinFilter(u.minFilter),void 0!==u.wrapS&&t.setWrapS(u.wrapS),void 0!==u.wrapT&&t.setWrapT(u.wrapT)}}function Z(t,n){var r=n.json.bufferViews[t.bufferView],i=n.json.buffers[r.buffer],u=i.uri?n.resources[i.uri]:n.resources["bt"],e=K[t.componentType],s=d.getElementSize(t.type);if(void 0!==r.byteStride&&r.byteStride!==s*e.BYTES_PER_ELEMENT)return function(t,n){for(var r=n.json.bufferViews[t.bufferView],i=n.json.buffers[r.buffer],u=i.uri?n.resources[i.uri]:n.resources["bt"],e=K[t.componentType],s=d.getElementSize(t.type),o=e.BYTES_PER_ELEMENT,h=t.byteOffset||0,f=new e(t.count*s),c=new DataView(u,r.byteOffset,r.byteLength),a=r.byteStride,v=0;v<t.count;v++)for(var l=0;l<s;l++){var w=h+v*a+l*o,p=void 0;switch(t.componentType){case 5126:p=c.getFloat32(w,!0);break;case 5125:p=c.getUint32(w,!0);break;case 5123:p=c.getUint16(w,!0);break;case 5121:p=c.getUint8(w);break;case 5122:p=c.getInt16(w,!0);break;case 5120:p=c.getInt8(w);break;default:throw new Error('Unexpected componentType "'+t.componentType+'".')}f[v*s+l]=p}return f}(t,n);var o=(r.byteOffset||0)+(t.byteOffset||0);switch(t.componentType){case 5126:return new Float32Array(u,o,t.count*s);case 5125:return new Uint32Array(u,o,t.count*s);case 5123:return new Uint16Array(u,o,t.count*s);case 5121:return new Uint8Array(u,o,t.count*s);case 5122:return new Int16Array(u,o,t.count*s);case 5120:return new Int8Array(u,o,t.count*s);default:throw new Error('Unexpected componentType "'+t.componentType+'".')}}var tt=function(){function t(t,n){this.nativeDocument=t,this.options=n,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.samplerDefIndexMap=new Map,this.imageData=[]}var n=t.prototype;return n.createTextureInfoDef=function(t,n,r){var i={magFilter:r.getMagFilter()||void 0,minFilter:r.getMinFilter()||void 0,wrapS:r.getWrapS(),wrapT:r.getWrapT()},u=JSON.stringify(i);this.samplerDefIndexMap.has(u)||(this.samplerDefIndexMap.set(u,this.nativeDocument.json.samplers.length),this.nativeDocument.json.samplers.push(i));var e={source:this.imageIndexMap.get(t),sampler:this.samplerDefIndexMap.get(u)},s=JSON.stringify(e);return this.textureDefIndexMap.has(s)||(this.textureDefIndexMap.set(s,this.nativeDocument.json.textures.length),this.nativeDocument.json.textures.push(e)),{index:this.textureDefIndexMap.get(s),texCoord:n.getTexCoord()}},n.createPropertyDef=function(t){var n={};return t.getName()&&(n.name=t.getName()),Object.keys(t.getExtras()).length>0&&(n.extras=t.getExtras()),n},n.createAccessorDef=function(t){var n=this.createPropertyDef(t);return n.type=t.getType(),n.componentType=t.getComponentType(),n.count=t.getCount(),t.getMax(n.max=[]),t.getMin(n.min=[]),n.normalized=t.getNormalized(),n},n.createImageData=function(t,n,r){if(this.options.isGLB)this.imageData.push(n),t.bufferView=this.nativeDocument.json.bufferViews.length,this.nativeDocument.json.bufferViews.push({buffer:0,byteOffset:-1,byteLength:n.byteLength});else{var i=M.mimeTypeToExtension(r.getMimeType());t.uri=this.imageURIGenerator.createURI(r,i),this.nativeDocument.resources[t.uri]=n}},t}(),nt=function(){function t(t,n){this.multiple=t,this.basename=n,this.counter=1}return t.prototype.createURI=function(t,n){return t.getURI()?t.getURI():this.multiple?this.basename+"_"+this.counter+++"."+n:this.basename+"."+n},t}(),rt=function(){function t(){}return t.write=function(t,n){var r=t.getRoot(),i={json:{asset:r.getAsset()},resources:{}},u=i.json,s=new tt(i,n),o=r.listBuffers().length,h=r.listTextures().length;function f(t,n,r,i){for(var o,h=[],f=0,c=e(t);!(o=c()).done;){var a=o.value,v=s.createAccessorDef(a);v.bufferView=u.bufferViews.length;var l=T.pad(a.getArray().buffer);v.byteOffset=f,f+=l.byteLength,h.push(l),s.accessorIndexMap.set(a,u.accessors.length),u.accessors.push(v)}var d={buffer:n,byteOffset:r,byteLength:T.concat(h).byteLength};return i&&(d.target=i),u.bufferViews.push(d),{buffers:h,byteLength:f}}function c(t,n,r){for(var i,o=t[0].getCount(),h=0,f=e(t);!(i=f()).done;){var c=i.value,a=s.createAccessorDef(c);a.bufferView=u.bufferViews.length,a.byteOffset=h;var v=c.getElementSize(),l=c.getComponentSize();h+=T.padNumber(v*l),s.accessorIndexMap.set(c,u.accessors.length),u.accessors.push(a)}for(var d=o*h,w=new ArrayBuffer(d),p=new DataView(w),A=0;A<o;A++)for(var y,b=0,m=e(t);!(y=m()).done;){for(var E=y.value,g=E.getElementSize(),M=E.getComponentSize(),x=E.getComponentType(),S=E.getArray(),R=0;R<g;R++){var N=A*h+b+R*M,U=S[A*g+R];switch(x){case 5126:p.setFloat32(N,U,!0);break;case 5120:p.setInt8(N,U);break;case 5122:p.setInt16(N,U,!0);break;case 5121:p.setUint8(N,U);break;case 5123:p.setUint16(N,U,!0);break;case 5125:p.setUint32(N,U,!0);break;default:throw new Error("Unexpected component type: "+x)}}b+=T.padNumber(g*M)}return u.bufferViews.push({buffer:n,byteOffset:r,byteLength:d,byteStride:h,target:34962}),{byteLength:d,buffers:[w]}}s.bufferURIGenerator=new nt(o>1,n.basename),s.imageURIGenerator=new nt(h>1,n.basename),s.logger=t.getLogger();for(var a,v=new Map,l=e(t.getGraph().getLinks());!(a=l()).done;){var w=a.value;if(w.getParent()!==r){var p=w.getChild();if(p instanceof d){var A=v.get(p)||[];A.push(w),v.set(p,A)}}}return u.accessors=[],u.bufferViews=[],u.samplers=[],u.textures=[],u.images=r.listTextures().map(function(t,n){var r=s.createPropertyDef(t);return t.getMimeType()&&(r.mimeType=t.getMimeType()),t.getImage()&&s.createImageData(r,t.getImage(),t),s.imageIndexMap.set(t,n),r}),u.buffers=[],r.listBuffers().forEach(function(t){for(var r,o=s.createPropertyDef(t),h=new Map,a=new Set,l=new Set,w=e(t.listParents().filter(function(t){return!(t instanceof J)}));!(r=w()).done;){var p=r.value;if(!(p instanceof d))throw new Error("Unimplemented buffer reference: "+p);for(var A,y=!1,b=!1,m=!1,E=v.get(p)||[],g=e(E);!(A=g()).done;){var M=A.value;M instanceof k?y=!0:M instanceof C?b=!0:m=!0}if(y||b||m||(m=!0),!y||b||m)if(!b||y||m){if(!m||y||b)throw new Error("Attribute or index accessors must be used only for that purpose.");l.add(p)}else a.add(p);else{var x=E[0].getParent(),S=h.get(x)||new Set;S.add(p),h.set(x,S)}}var R,N=[],U=u.buffers.length,I=0;if(a.size){var _=f(Array.from(a),U,I,34963);I+=_.byteLength,N.push.apply(N,_.buffers)}for(var O=0,j=Array.from(h.values());O<j.length;O++){var L=j[O];if(L.size){var B=c(Array.from(L),U,I);I+=B.byteLength,N.push.apply(N,B.buffers)}}if(l.size){var P=f(Array.from(l),U,I);I+=P.byteLength,N.push.apply(N,P.buffers)}if(s.imageData.length)for(var V=0;V<s.imageData.length;V++)u.bufferViews[u.images[V].bufferView].byteOffset=I,I+=s.imageData[V].byteLength,N.push(s.imageData[V]);I?(n.isGLB?R="__glb.bin":(R=s.bufferURIGenerator.createURI(t,"bin"),o.uri=R),o.byteLength=I,i.resources[R]=T.concat(N),u.buffers.push(o)):s.logger.warn('@gltf-transform/core: Skipping empty buffer, "'+t.getName()+'".')}),u.materials=r.listMaterials().map(function(t,n){var r=s.createPropertyDef(t);if(r.alphaMode=t.getAlphaMode(),"MASK"===t.getAlphaMode()&&(r.alphaCutoff=t.getAlphaCutoff()),r.doubleSided=t.getDoubleSided(),r.pbrMetallicRoughness={},r.pbrMetallicRoughness.baseColorFactor=t.getBaseColorFactor(),r.emissiveFactor=t.getEmissiveFactor(),r.pbrMetallicRoughness.roughnessFactor=t.getRoughnessFactor(),r.pbrMetallicRoughness.metallicFactor=t.getMetallicFactor(),t.getBaseColorTexture()){var i=t.getBaseColorTexture(),u=t.getBaseColorTextureInfo(),e=t.getBaseColorTextureSampler();r.pbrMetallicRoughness.baseColorTexture=s.createTextureInfoDef(i,u,e)}if(t.getEmissiveTexture()){var o=t.getEmissiveTexture(),h=t.getEmissiveTextureInfo(),f=t.getEmissiveTextureSampler();r.emissiveTexture=s.createTextureInfoDef(o,h,f)}if(t.getNormalTexture()){var c=t.getNormalTexture(),a=t.getNormalTextureInfo(),v=t.getNormalTextureSampler(),l=s.createTextureInfoDef(c,a,v);1!==t.getNormalScale()&&(l.scale=t.getNormalScale()),r.normalTexture=l}if(t.getOcclusionTexture()){var d=t.getOcclusionTexture(),w=t.getOcclusionTextureInfo(),p=t.getOcclusionTextureSampler(),A=s.createTextureInfoDef(d,w,p);1!==t.getOcclusionStrength()&&(A.strength=t.getOcclusionStrength()),r.occlusionTexture=A}if(t.getMetallicRoughnessTexture()){var y=t.getMetallicRoughnessTexture(),b=t.getMetallicRoughnessTextureInfo(),m=t.getMetallicRoughnessTextureSampler();r.pbrMetallicRoughness.metallicRoughnessTexture=s.createTextureInfoDef(y,b,m)}return s.materialIndexMap.set(t,n),r}),u.meshes=r.listMeshes().map(function(t,n){var r,i=s.createPropertyDef(t);return i.primitives=t.listPrimitives().map(function(t){var n={attributes:{}};n.material=s.materialIndexMap.get(t.getMaterial()),n.mode=t.getMode(),t.getIndices()&&(n.indices=s.accessorIndexMap.get(t.getIndices()));for(var i,u=e(t.listSemantics());!(i=u()).done;){var o=i.value;n.attributes[o]=s.accessorIndexMap.get(t.getAttribute(o))}for(var h,f=e(t.listTargets());!(h=f()).done;){for(var c,a=h.value,v={},l=e(a.listSemantics());!(c=l()).done;){var d=c.value;v[d]=s.accessorIndexMap.get(a.getAttribute(d))}n.targets=n.targets||[],n.targets.push(v)}return t.listTargets().length&&!r&&(r=t.listTargets().map(function(t){return t.getName()})),n}),t.getWeights().length&&(i.weights=t.getWeights()),r&&(i.extras=i.extras||{},i.extras.targetNames=r),s.meshIndexMap.set(t,n),i}),u.cameras=r.listCameras().map(function(t,n){var r=s.createPropertyDef(t);return r.type=t.getType(),"perspective"===r.type?r.perspective={znear:t.getZNear(),zfar:t.getZFar(),yfov:t.getYFov(),aspectRatio:t.getAspectRatio()}:r.orthographic={znear:t.getZNear(),zfar:t.getZFar(),xmag:t.getXMag(),ymag:t.getYMag()},s.cameraIndexMap.set(t,n),r}),u.nodes=r.listNodes().map(function(t,n){var r=s.createPropertyDef(t);return r.translation=t.getTranslation(),r.rotation=t.getRotation(),r.scale=t.getScale(),t.getWeights().length&&(r.weights=t.getWeights()),s.nodeIndexMap.set(t,n),r}),u.skins=r.listSkins().map(function(t,n){var r=s.createPropertyDef(t);return t.getInverseBindMatrices()&&(r.inverseBindMatrices=s.accessorIndexMap.get(t.getInverseBindMatrices())),t.getSkeleton()&&(r.skeleton=s.nodeIndexMap.get(t.getSkeleton())),r.joints=t.listJoints().map(function(t){return s.nodeIndexMap.get(t)}),s.skinIndexMap.set(t,n),r}),r.listNodes().forEach(function(t,n){var r=u.nodes[n];t.getMesh()&&(r.mesh=s.meshIndexMap.get(t.getMesh())),t.getCamera()&&(r.camera=s.cameraIndexMap.get(t.getCamera())),t.getSkin()&&(r.skin=s.skinIndexMap.get(t.getSkin())),t.listChildren().length>0&&(r.children=t.listChildren().map(function(t){return s.nodeIndexMap.get(t)}))}),u.animations=r.listAnimations().map(function(t){var n=s.createPropertyDef(t),r=new Map;return n.samplers=t.listSamplers().map(function(t,n){var i=s.createPropertyDef(t);return i.input=s.accessorIndexMap.get(t.getInput()),i.output=s.accessorIndexMap.get(t.getOutput()),i.interpolation=t.getInterpolation(),r.set(t,n),i}),n.channels=t.listChannels().map(function(t){var n=s.createPropertyDef(t);return n.sampler=r.get(t.getSampler()),n.target={node:s.nodeIndexMap.get(t.getTargetNode()),path:t.getTargetPath()},n}),n}),u.scenes=r.listScenes().map(function(t){var n=s.createPropertyDef(t);return n.nodes=t.listNodes().map(function(t){return s.nodeIndexMap.get(t)}),n}),u.extensionsUsed=r.listExtensionsUsed().map(function(t){return t.extensionName}),u.extensionsRequired=r.listExtensionsRequired().map(function(t){return t.extensionName}),r.listExtensionsUsed().forEach(function(t){return t.write(s)}),function(t){var n=[];for(var r in t){var i=t[r];Array.isArray(i)&&0===i.length?n.push(r):null!==i&&""!==i||n.push(i)}for(var u=0,e=n;u<e.length;u++)delete t[e[u]]}(u),i},t}(),it=function(){function t(){this.ut=[]}var n=t.prototype;return n.registerExtensions=function(t){var n;return(n=this.ut).push.apply(n,t),this},n.createDocument=function(t){return Q.read(t,{extensions:this.ut})},n.createNativeDocument=function(t,n){if(n.isGLB&&1!==t.getRoot().listBuffers().length)throw new Error("GLB must have exactly 1 buffer.");return rt.write(t,n)},n.unpackGLB=function(t){var n,r=new Uint32Array(t,0,3);if(1179937895!==r[0])throw new Error("Invalid glTF asset.");if(2!==r[1])throw new Error('Unsupported glTF binary version, "'+r[1]+'".');var i=new Uint32Array(t,12,2),u=i[0],e=new Uint32Array(t,20+u,2);if(1313821514!==i[1]||5130562!==e[1])throw new Error("Unexpected GLB layout.");var s=T.decodeText(t.slice(20,20+u)),o=JSON.parse(s),h=20+u+8,f=t.slice(h,h+e[0]);return this.createDocument({json:o,resources:(n={},n["bt"]=f,n)})},n.packGLB=function(t){var n=this.createNativeDocument(t,{basename:"",isGLB:!0}),r=n.resources,i=JSON.stringify(n.json),u=T.pad(T.encodeText(i),32),e=new Uint32Array([u.byteLength,1313821514]).buffer,s=T.concat([e,u]),o=T.pad(Object.values(r)[0],0),h=new Uint32Array([o.byteLength,5130562]).buffer,f=T.concat([h,o]),c=new Uint32Array([1179937895,2,12+s.byteLength+f.byteLength]).buffer;return T.concat([c,s,f])},t}(),ut=function(t){function n(n,r){var i;return(i=t.call(this)||this).fs=n,i.path=r,i}i(n,t);var r=n.prototype;return r.read=function(t){return t.match(/\.glb$/)?this.readGLB(t):this.readGLTF(t)},r.write=function(t,n){t.match(/\.glb$/)?this.writeGLB(t,n):this.writeGLTF(t,n)},r.readGLB=function(t){var n=this.fs.readFileSync(t),r=T.trim(n);return this.unpackGLB(r)},r.readGLTF=function(t){var n=this,r=this.path.dirname(t),i={json:JSON.parse(this.fs.readFileSync(t,"utf8")),resources:{}};return[].concat(i.json.images||[],i.json.buffers||[]).forEach(function(t){if(t.uri&&!t.uri.match(/data:/)){var u=n.path.resolve(r,t.uri);i.resources[t.uri]=T.trim(n.fs.readFileSync(u))}else{var e="__"+I()+"."+g.extension(t.uri);i.resources[e]=T.createBufferFromDataURI(t.uri),t.uri=e}}),Q.read(i,{extensions:this.ut})},r.writeGLTF=function(t,n){var r={basename:g.basename(t),isGLB:!1},i=rt.write(n,r),u=i.json,e=i.resources,s=this.fs,o=this.path,h=o.dirname(t);s.writeFileSync(t,JSON.stringify(u,null,2)),Object.keys(e).forEach(function(t){var n=Buffer.from(e[t]);s.writeFileSync(o.join(h,t),n)})},r.writeGLB=function(t,n){var r=Buffer.from(this.packGLB(n));this.fs.writeFileSync(t,r)},n}(it),et=function(t){function n(n){var r;return(r=t.call(this)||this).fetchConfig=n,r}i(n,t);var r=n.prototype;return r.read=function(t){return t.match(/\.glb$/)?this.readGLB(t):this.readGLTF(t)},r.readGLTF=function(t){var n=this,r={json:{},resources:{}};return fetch(t,this.fetchConfig).then(function(t){return t.json()}).then(function(t){r.json=t;var i=[].concat(t.images,t.buffers).map(function(t){if(t.uri)return fetch(t.uri,n.fetchConfig).then(function(t){return t.arrayBuffer()}).then(function(n){r.resources[t.uri]=n})});return Promise.all(i).then(function(){return n.createDocument(r)})})},r.readGLB=function(t){var n=this;return fetch(t,this.fetchConfig).then(function(t){return t.arrayBuffer()}).then(function(t){return n.unpackGLB(t)})},n}(it);t.Accessor=d,t.Animation=p,t.AnimationChannel=A,t.AnimationSampler=y,t.Buffer=b,t.BufferUtils=T,t.Camera=m,t.Document=Y,t.Extension=q,t.ExtensionProperty=E,t.FileUtils=g,t.Graph=f,t.ImageUtils=M,t.Logger=S,t.Material=P,t.Mesh=V,t.Node=F,t.NodeIO=ut,t.Primitive=D,t.PrimitiveTarget=G,t.Property=v,t.ReaderContext=H,t.Root=J,t.Scene=z,t.Skin=$,t.Texture=_,t.TextureInfo=O,t.TextureSampler=j,t.WebIO=et,t.WriterContext=tt,t.uuid=I});
//# sourceMappingURL=core.umd.js.map
{
"name": "@gltf-transform/core",
"version": "0.4.0-alpha.2",
"version": "0.4.0-alpha.3",
"repository": "github:donmccurdy/glTF-Transform",

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

},
"gitHead": "f744d10a839f51261f72ddc81c8eb559b2fe70ae"
"gitHead": "6ab967a22de4bfb41845d8d0cfb9ca743f324adb"
}
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