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.6.0 to 0.7.0-alpha.0

dist/json-document.d.ts

2

dist/core.modern.js

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

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

@@ -23,2 +23,3 @@ import { Extension, ExtensionConstructor } from './extension';

* import { Document } from '@gltf-transform/core';
* import { dedup } from '@gltf-transform/lib';
*

@@ -38,3 +39,3 @@ * const doc = new Document();

* await doc.transform(
* prune({textures: true}),
* dedup({textures: true}),
* // ...

@@ -41,0 +42,0 @@ * );

@@ -79,3 +79,3 @@ import { PropertyType } from './constants';

* be given a ReaderContext instance, and is expected to update either the context or its
* NativeDocument with resources known to the Extension. *Most extensions don't need to
* {@link JSONDocument} with resources known to the Extension. *Most extensions don't need to
* implement this.*

@@ -93,3 +93,3 @@ */

* implemented by each extension in order to support writing files. The extension will be
* given a WriterContext instance, and should modify the {@link NativeDocument} output
* given a WriterContext instance, and should modify the {@link JSONDocument} output
* accordingly. Adding the extension name to the `extensionsUsed` and `extensionsRequired` list

@@ -96,0 +96,0 @@ * is done automatically, and should not be included here.

import { Document } from '../document';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { PlatformIO } from './platform-io';

@@ -9,2 +9,6 @@ /**

*
* The most common use of the I/O service is to read/write a {@link Document} with a given path.
* Methods are also available for converting in-memory representations of raw glTF files, both
* binary (*ArrayBuffer*) and JSON ({@link JSONDocument}).
*
* Usage:

@@ -17,11 +21,11 @@ *

*
* const io = new NodeIO(fs, path);
* const io = new NodeIO();
*
* // Read.
* io.read('model.glb'); // → Document
* io.unpackGLB(ArrayBuffer); // → Document
* io.readBinary(ArrayBuffer); // → Document
*
* // Write.
* io.write('model.glb', doc); // → void
* io.packGLB(doc); // → ArrayBuffer
* io.writeBinary(doc); // → ArrayBuffer
* ```

@@ -32,20 +36,26 @@ *

export declare class NodeIO extends PlatformIO {
private readonly fs;
private readonly path;
/**
* Constructs a new NodeIO service. Instances are reusable.
* @param fs
* @param path
private _fs;
private _path;
/** Constructs a new NodeIO service. Instances are reusable. */
constructor();
/**********************************************************************************************
* Public.
*/
constructor(fs: any, path: any);
/** Loads a local path and returns a {@link NativeDocument} struct. */
readNativeDocument(uri: string): NativeDocument;
/** Loads a local path and returns a {@link Document} instance. */
read(uri: string): Document;
/** Loads a local path and returns a {@link JSONDocument} struct, without parsing. */
readAsJSON(uri: string): JSONDocument;
/** Writes a {@link Document} instance to a local path. */
write(uri: string, doc: Document): void;
private readGLB;
private readGLTF;
private writeGLTF;
private writeGLB;
/**********************************************************************************************
* Private.
*/
/** @hidden */
private _readGLB;
/** @hidden */
private _readGLTF;
/** @hidden */
private _writeGLTF;
/** @hidden */
private _writeGLB;
}
import { Document } from '../document';
import { Extension } from '../extension';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Logger } from '../utils/';

@@ -11,2 +11,6 @@ import { WriterOptions } from './writer';

*
* The most common use of the I/O service is to read/write a {@link Document} with a given path.
* Methods are also available for converting in-memory representations of raw glTF files, both
* binary (*ArrayBuffer*) and JSON ({@link JSONDocument}).
*
* For platform-specific implementations, see {@link NodeIO} and {@link WebIO}.

@@ -23,12 +27,21 @@ *

registerExtensions(extensions: typeof Extension[]): this;
/**********************************************************************************************
* JSON.
*/
/** Converts glTF-formatted JSON and a resource map to a {@link Document}. */
createDocument(nativeDoc: NativeDocument): Document;
readJSON(jsonDoc: JSONDocument): Document;
/** Converts a {@link Document} to glTF-formatted JSON and a resource map. */
createNativeDocument(doc: Document, options: WriterOptions): NativeDocument;
/** Converts a GLB-formatted ArrayBuffer to a {@link NativeDocument}. */
unpackGLBToNativeDocument(glb: ArrayBuffer): NativeDocument;
writeJSON(doc: Document, options: WriterOptions): JSONDocument;
/**********************************************************************************************
* Binary -> JSON.
*/
/** Converts a GLB-formatted ArrayBuffer to a {@link JSONDocument}. */
binaryToJSON(glb: ArrayBuffer): JSONDocument;
/**********************************************************************************************
* Binary.
*/
/** Converts a GLB-formatted ArrayBuffer to a {@link Document}. */
unpackGLB(glb: ArrayBuffer): Document;
readBinary(glb: ArrayBuffer): Document;
/** Converts a {@link Document} to a GLB-formatted ArrayBuffer. */
packGLB(doc: Document): ArrayBuffer;
writeBinary(doc: Document): ArrayBuffer;
}

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

import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Accessor, Animation, Buffer, Camera, Material, Mesh, Node, Scene, Skin, Texture, TextureInfo, TextureSampler } from '../properties';

@@ -9,3 +9,3 @@ /**

export declare class ReaderContext {
readonly nativeDocument: NativeDocument;
readonly jsonDoc: JSONDocument;
buffers: Buffer[];

@@ -22,5 +22,5 @@ bufferViewBuffers: Buffer[];

scenes: Scene[];
constructor(nativeDocument: NativeDocument);
constructor(jsonDoc: JSONDocument);
setTextureInfo(textureInfo: TextureInfo, textureInfoDef: GLTF.ITextureInfo): void;
setTextureSampler(textureSampler: TextureSampler, textureInfoDef: GLTF.ITextureInfo): void;
}
import { Document } from '../document';
import { Extension } from '../extension';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Logger } from '../utils';

@@ -11,4 +11,4 @@ export interface ReaderOptions {

export declare class GLTFReader {
static read(nativeDoc: NativeDocument, options?: ReaderOptions): Document;
static read(jsonDoc: JSONDocument, options?: ReaderOptions): Document;
private static validate;
}
import { Document } from '../document';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { PlatformIO } from './platform-io';

@@ -9,2 +9,6 @@ /**

*
* The most common use of the I/O service is to read/write a {@link Document} with a given path.
* Methods are also available for converting in-memory representations of raw glTF files, both
* binary (*ArrayBuffer*) and JSON ({@link JSONDocument}).
*
* Usage:

@@ -18,7 +22,7 @@ *

* // Read.
* const doc = await io.read('model.glb'); // → Document
* const doc = io.unpackGLB(ArrayBuffer); // → Document
* const doc = await io.read('model.glb'); // → Document
* const doc = io.readBinary(ArrayBuffer); // → Document
*
* // Write.
* const arrayBuffer = io.packGLB(doc); // → ArrayBuffer
* const arrayBuffer = io.writeBinary(doc); // → ArrayBuffer
* ```

@@ -29,14 +33,22 @@ *

export declare class WebIO extends PlatformIO {
private readonly fetchConfig;
private readonly _fetchConfig;
/**
* Constructs a new WebIO service. Instances are reusable.
* @param fetchConfig Configuration object for Fetch API.
* @param _fetchConfig Configuration object for Fetch API.
*/
constructor(fetchConfig: RequestInit);
/** Loads a URI and returns a {@link NativeDocument} struct. */
readNativeDocument(uri: string): Promise<NativeDocument>;
constructor(_fetchConfig?: RequestInit);
/**********************************************************************************************
* Public.
*/
/** Loads a URI and returns a {@link Document} instance. */
read(uri: string): Promise<Document>;
private readGLTF;
private readGLB;
/** Loads a local path and returns a {@link JSONDocument} struct, without parsing. */
readAsJSON(uri: string): Promise<JSONDocument>;
/**********************************************************************************************
* Private.
*/
/** @hidden */
private _readGLTF;
/** @hidden */
private _readGLB;
}

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

import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Accessor, Buffer, Camera, Material, Mesh, Node, Property, Skin, Texture, TextureInfo, TextureSampler } from '../properties';

@@ -13,3 +13,3 @@ import { Logger } from '../utils';

export declare class WriterContext {
readonly nativeDocument: NativeDocument;
readonly jsonDoc: JSONDocument;
readonly options: WriterOptions;

@@ -29,3 +29,3 @@ readonly accessorIndexMap: Map<Accessor, number>;

logger: Logger;
constructor(nativeDocument: NativeDocument, options: WriterOptions);
constructor(jsonDoc: JSONDocument, options: WriterOptions);
/**

@@ -32,0 +32,0 @@ * Creates a TextureInfo definition, and any Texture or Sampler definitions it requires. If

import { Document } from '../document';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Logger } from '../utils';

@@ -11,3 +11,3 @@ export interface WriterOptions {

export declare class GLTFWriter {
static write(doc: Document, options?: WriterOptions): NativeDocument;
static write(doc: Document, options?: WriterOptions): JSONDocument;
}

@@ -10,3 +10,3 @@ import { PropertyType, vec2 } from '../constants';

* should be unique within a document, such that no other texture contains the same
* {@link getImage}() data. Where duplicates may already exist, the `prune({textures: true})`
* {@link getImage}() data. Where duplicates may already exist, the `dedup({textures: true})`
* transform can remove them. A {@link Document} with N texture properties will be exported to a

@@ -13,0 +13,0 @@ * glTF file with N `image` properties, and the minimum number of `texture` properties necessary

{
"name": "@gltf-transform/core",
"version": "0.6.0",
"version": "0.7.0-alpha.0",
"repository": "github:donmccurdy/glTF-Transform",

@@ -32,2 +32,6 @@ "description": "glTF 2.0 SDK for JavaScript, TypeScript, and Node.js",

],
"browser": {
"fs": false,
"path": false
},
"dependencies": {

@@ -39,3 +43,3 @@ "gl-matrix": "^3.3.0"

},
"gitHead": "ed6c21760264b5103036dfed2f6add6bed6ba427"
"gitHead": "3ff3817832e138ef570b00dd3642d6a0b70a6453"
}

@@ -25,2 +25,3 @@ import { Extension, ExtensionConstructor } from './extension';

* import { Document } from '@gltf-transform/core';
* import { dedup } from '@gltf-transform/lib';
*

@@ -40,3 +41,3 @@ * const doc = new Document();

* await doc.transform(
* prune({textures: true}),
* dedup({textures: true}),
* // ...

@@ -43,0 +44,0 @@ * );

@@ -105,3 +105,3 @@ import { PropertyType } from './constants';

* be given a ReaderContext instance, and is expected to update either the context or its
* NativeDocument with resources known to the Extension. *Most extensions don't need to
* {@link JSONDocument} with resources known to the Extension. *Most extensions don't need to
* implement this.*

@@ -124,3 +124,3 @@ */

* implemented by each extension in order to support writing files. The extension will be
* given a WriterContext instance, and should modify the {@link NativeDocument} output
* given a WriterContext instance, and should modify the {@link JSONDocument} output
* accordingly. Adding the extension name to the `extensionsUsed` and `extensionsRequired` list

@@ -127,0 +127,0 @@ * is done automatically, and should not be included here.

import { Document } from '../document';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { BufferUtils, FileUtils, uuid } from '../utils/';

@@ -13,2 +13,6 @@ import { PlatformIO } from './platform-io';

*
* The most common use of the I/O service is to read/write a {@link Document} with a given path.
* Methods are also available for converting in-memory representations of raw glTF files, both
* binary (*ArrayBuffer*) and JSON ({@link JSONDocument}).
*
* Usage:

@@ -21,11 +25,11 @@ *

*
* const io = new NodeIO(fs, path);
* const io = new NodeIO();
*
* // Read.
* io.read('model.glb'); // → Document
* io.unpackGLB(ArrayBuffer); // → Document
* io.readBinary(ArrayBuffer); // → Document
*
* // Write.
* io.write('model.glb', doc); // → void
* io.packGLB(doc); // → ArrayBuffer
* io.writeBinary(doc); // → ArrayBuffer
* ```

@@ -36,48 +40,56 @@ *

export class NodeIO extends PlatformIO {
/**
* Constructs a new NodeIO service. Instances are reusable.
* @param fs
* @param path
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
constructor(private readonly fs: any, private readonly path: any) {
private _fs;
private _path;
/** Constructs a new NodeIO service. Instances are reusable. */
constructor() {
super();
// Excluded from browser builds with 'package.browser' field.
this._fs = require('fs');
this._path = require('path');
}
/* Public. */
/**********************************************************************************************
* Public.
*/
/** Loads a local path and returns a {@link NativeDocument} struct. */
public readNativeDocument (uri: string): NativeDocument {
const isGLB = !!(uri.match(/\.glb$/) || uri.match(/^data:application\/octet-stream;/));
return isGLB ? this.readGLB(uri) : this.readGLTF(uri);
}
/** Loads a local path and returns a {@link Document} instance. */
public read (uri: string): Document {
const nativeDoc = this.readNativeDocument(uri);
return GLTFReader.read(nativeDoc, {extensions: this._extensions, logger: this._logger});
const jsonDoc = this.readAsJSON(uri);
return GLTFReader.read(jsonDoc, {extensions: this._extensions, logger: this._logger});
}
/** Loads a local path and returns a {@link JSONDocument} struct, without parsing. */
public readAsJSON (uri: string): JSONDocument {
const isGLB = !!(uri.match(/\.glb$/) || uri.match(/^data:application\/octet-stream;/));
return isGLB ? this._readGLB(uri) : this._readGLTF(uri);
}
/** Writes a {@link Document} instance to a local path. */
public write (uri: string, doc: Document): void {
const isGLB = !!uri.match(/\.glb$/);
isGLB ? this.writeGLB(uri, doc) : this.writeGLTF(uri, doc);
isGLB ? this._writeGLB(uri, doc) : this._writeGLTF(uri, doc);
}
/* Internal. */
/**********************************************************************************************
* Private.
*/
private readGLB (uri: string): NativeDocument {
const buffer: Buffer = this.fs.readFileSync(uri);
/** @hidden */
private _readGLB (uri: string): JSONDocument {
const buffer: Buffer = this._fs.readFileSync(uri);
const arrayBuffer = BufferUtils.trim(buffer);
return this.unpackGLBToNativeDocument(arrayBuffer);
return this.binaryToJSON(arrayBuffer);
}
private readGLTF (uri: string): NativeDocument {
const dir = this.path.dirname(uri);
const nativeDoc = {
json: JSON.parse(this.fs.readFileSync(uri, 'utf8')),
/** @hidden */
private _readGLTF (uri: string): JSONDocument {
const dir = this._path.dirname(uri);
const jsonDoc = {
json: JSON.parse(this._fs.readFileSync(uri, 'utf8')),
resources: {}
} as NativeDocument;
const images = nativeDoc.json.images || [];
const buffers = nativeDoc.json.buffers || [];
} as JSONDocument;
const images = jsonDoc.json.images || [];
const buffers = jsonDoc.json.buffers || [];
[...images, ...buffers].forEach((resource: GLTF.IBuffer|GLTF.IImage) => {

@@ -87,15 +99,16 @@ if (!resource.uri) return; // Skip image.bufferView.

if (!resource.uri.match(/data:/)) {
const absURI = this.path.resolve(dir, resource.uri);
nativeDoc.resources[resource.uri] = BufferUtils.trim(this.fs.readFileSync(absURI));
const absURI = this._path.resolve(dir, resource.uri);
jsonDoc.resources[resource.uri] = BufferUtils.trim(this._fs.readFileSync(absURI));
} else {
// Rewrite Data URIs to something short and unique.
const resourceUUID = `__${uuid()}.${FileUtils.extension(resource.uri)}`;
nativeDoc.resources[resourceUUID] = BufferUtils.createBufferFromDataURI(resource.uri);
jsonDoc.resources[resourceUUID] = BufferUtils.createBufferFromDataURI(resource.uri);
resource.uri = resourceUUID;
}
});
return nativeDoc;
return jsonDoc;
}
private writeGLTF (uri: string, doc: Document): void {
/** @hidden */
private _writeGLTF (uri: string, doc: Document): void {
const {json, resources} = GLTFWriter.write(doc, {

@@ -106,3 +119,3 @@ basename: FileUtils.basename(uri),

});
const {fs, path} = this;
const {_fs: fs, _path: path} = this;
const dir = path.dirname(uri);

@@ -116,6 +129,7 @@ fs.writeFileSync(uri, JSON.stringify(json, null, 2));

private writeGLB (uri: string, doc: Document): void {
const buffer = Buffer.from(this.packGLB(doc));
this.fs.writeFileSync(uri, buffer);
/** @hidden */
private _writeGLB (uri: string, doc: Document): void {
const buffer = Buffer.from(this.writeBinary(doc));
this._fs.writeFileSync(uri, buffer);
}
}
import { GLB_BUFFER } from '../constants';
import { Document } from '../document';
import { Extension } from '../extension';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { BufferUtils, Logger } from '../utils/';

@@ -14,2 +14,6 @@ import { GLTFReader } from './reader';

*
* The most common use of the I/O service is to read/write a {@link Document} with a given path.
* Methods are also available for converting in-memory representations of raw glTF files, both
* binary (*ArrayBuffer*) and JSON ({@link JSONDocument}).
*
* For platform-specific implementations, see {@link NodeIO} and {@link WebIO}.

@@ -37,9 +41,13 @@ *

/**********************************************************************************************
* JSON.
*/
/** Converts glTF-formatted JSON and a resource map to a {@link Document}. */
public createDocument (nativeDoc: NativeDocument): Document {
return GLTFReader.read(nativeDoc, {extensions: this._extensions, logger: this._logger});
public readJSON (jsonDoc: JSONDocument): Document {
return GLTFReader.read(jsonDoc, {extensions: this._extensions, logger: this._logger});
}
/** Converts a {@link Document} to glTF-formatted JSON and a resource map. */
public createNativeDocument (doc: Document, options: WriterOptions): NativeDocument {
public writeJSON (doc: Document, options: WriterOptions): JSONDocument {
if (options.isGLB && doc.getRoot().listBuffers().length !== 1) {

@@ -51,4 +59,8 @@ throw new Error('GLB must have exactly 1 buffer.');

/** Converts a GLB-formatted ArrayBuffer to a {@link NativeDocument}. */
public unpackGLBToNativeDocument(glb: ArrayBuffer): NativeDocument {
/**********************************************************************************************
* Binary -> JSON.
*/
/** Converts a GLB-formatted ArrayBuffer to a {@link JSONDocument}. */
public binaryToJSON(glb: ArrayBuffer): JSONDocument {
// Decode and verify GLB header.

@@ -83,10 +95,14 @@ const header = new Uint32Array(glb, 0, 3);

/**********************************************************************************************
* Binary.
*/
/** Converts a GLB-formatted ArrayBuffer to a {@link Document}. */
public unpackGLB(glb: ArrayBuffer): Document {
return this.createDocument(this.unpackGLBToNativeDocument(glb));
public readBinary(glb: ArrayBuffer): Document {
return this.readJSON(this.binaryToJSON(glb));
}
/** Converts a {@link Document} to a GLB-formatted ArrayBuffer. */
public packGLB(doc: Document): ArrayBuffer {
const {json, resources} = this.createNativeDocument(doc, {
public writeBinary(doc: Document): ArrayBuffer {
const {json, resources} = this.writeJSON(doc, {
basename: '',

@@ -93,0 +109,0 @@ isGLB: true,

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

import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Accessor, Animation, Buffer, Camera, Material, Mesh, Node, Scene, Skin, Texture, TextureInfo, TextureSampler } from '../properties';

@@ -22,3 +22,3 @@

constructor (public readonly nativeDocument: NativeDocument) {}
constructor (public readonly jsonDoc: JSONDocument) {}

@@ -33,7 +33,7 @@ public setTextureInfo(textureInfo: TextureInfo, textureInfoDef: GLTF.ITextureInfo): void {

public setTextureSampler(textureSampler: TextureSampler, textureInfoDef: GLTF.ITextureInfo): void {
const textureDef = this.nativeDocument.json.textures[textureInfoDef.index];
const textureDef = this.jsonDoc.json.textures[textureInfoDef.index];
if (textureDef.sampler === undefined) return;
const samplerDef = this.nativeDocument.json.samplers[textureDef.sampler];
const samplerDef = this.jsonDoc.json.samplers[textureDef.sampler];

@@ -40,0 +40,0 @@ if (samplerDef.magFilter !== undefined) {

@@ -5,3 +5,3 @@ import { getRotation, getScaling, getTranslation } from 'gl-matrix/mat4'

import { Extension, ExtensionConstructor } from '../extension';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Accessor } from '../properties';

@@ -32,15 +32,15 @@ import { FileUtils, ImageUtils, Logger } from '../utils';

export class GLTFReader {
public static read(nativeDoc: NativeDocument, options: ReaderOptions = DEFAULT_OPTIONS): Document {
const {json} = nativeDoc;
public static read(jsonDoc: JSONDocument, options: ReaderOptions = DEFAULT_OPTIONS): Document {
const {json} = jsonDoc;
const doc = new Document();
this.validate(nativeDoc, options);
this.validate(jsonDoc, options);
/* Reader context. */
const context = new ReaderContext(nativeDoc);
const context = new ReaderContext(jsonDoc);
/** Asset. */
const assetDef = nativeDoc.json.asset;
const assetDef = jsonDoc.json.asset;
const asset = doc.getRoot().getAsset();

@@ -99,6 +99,6 @@

if (accessorDef.sparse !== undefined) {
array = getSparseArray(accessorDef, nativeDoc);
array = getSparseArray(accessorDef, jsonDoc);
} else {
// TODO(cleanup): Relying to much on ArrayBuffers: requires copying.
array = getAccessorArray(accessorDef, nativeDoc).slice();
array = getAccessorArray(accessorDef, jsonDoc).slice();
}

@@ -132,6 +132,6 @@

const bufferViewDef = json.bufferViews[imageDef.bufferView];
const bufferDef = nativeDoc.json.buffers[bufferViewDef.buffer];
const bufferDef = jsonDoc.json.buffers[bufferViewDef.buffer];
const bufferData = bufferDef.uri
? nativeDoc.resources[bufferDef.uri]
: nativeDoc.resources[GLB_BUFFER];
? jsonDoc.resources[bufferDef.uri]
: jsonDoc.resources[GLB_BUFFER];
const byteOffset = bufferViewDef.byteOffset || 0;

@@ -142,3 +142,3 @@ const byteLength = bufferViewDef.byteLength;

} else if (imageDef.uri !== undefined) {
texture.setImage(nativeDoc.resources[imageDef.uri]);
texture.setImage(jsonDoc.resources[imageDef.uri]);
if (imageDef.uri.indexOf('__') !== 0) {

@@ -463,5 +463,5 @@ texture.setURI(imageDef.uri);

private static validate(nativeDoc: NativeDocument, options: ReaderOptions): void {
private static validate(jsonDoc: JSONDocument, options: ReaderOptions): void {
const json = nativeDoc.json;
const json = jsonDoc.json;

@@ -497,6 +497,6 @@ if (json.asset.version !== '2.0') {

*/
function getInterleavedArray(accessorDef: GLTF.IAccessor, nativeDoc: NativeDocument): TypedArray {
const bufferViewDef = nativeDoc.json.bufferViews[accessorDef.bufferView];
const bufferDef = nativeDoc.json.buffers[bufferViewDef.buffer];
const resource = bufferDef.uri ? nativeDoc.resources[bufferDef.uri] : nativeDoc.resources[GLB_BUFFER];
function getInterleavedArray(accessorDef: GLTF.IAccessor, jsonDoc: JSONDocument): TypedArray {
const bufferViewDef = jsonDoc.json.bufferViews[accessorDef.bufferView];
const bufferDef = jsonDoc.json.buffers[bufferViewDef.buffer];
const resource = bufferDef.uri ? jsonDoc.resources[bufferDef.uri] : jsonDoc.resources[GLB_BUFFER];

@@ -549,6 +549,6 @@ const TypedArray = ComponentTypeToTypedArray[accessorDef.componentType];

*/
function getAccessorArray(accessorDef: GLTF.IAccessor, nativeDoc: NativeDocument): TypedArray {
const bufferViewDef = nativeDoc.json.bufferViews[accessorDef.bufferView];
const bufferDef = nativeDoc.json.buffers[bufferViewDef.buffer];
const resource = bufferDef.uri ? nativeDoc.resources[bufferDef.uri] : nativeDoc.resources[GLB_BUFFER];
function getAccessorArray(accessorDef: GLTF.IAccessor, jsonDoc: JSONDocument): TypedArray {
const bufferViewDef = jsonDoc.json.bufferViews[accessorDef.bufferView];
const bufferDef = jsonDoc.json.buffers[bufferViewDef.buffer];
const resource = bufferDef.uri ? jsonDoc.resources[bufferDef.uri] : jsonDoc.resources[GLB_BUFFER];

@@ -562,3 +562,3 @@ const TypedArray = ComponentTypeToTypedArray[accessorDef.componentType];

if (bufferViewDef.byteStride !== undefined && bufferViewDef.byteStride !== elementStride) {
return getInterleavedArray(accessorDef, nativeDoc);
return getInterleavedArray(accessorDef, jsonDoc);
}

@@ -590,3 +590,3 @@

*/
function getSparseArray(accessorDef: GLTF.IAccessor, nativeDoc: NativeDocument): TypedArray {
function getSparseArray(accessorDef: GLTF.IAccessor, jsonDoc: JSONDocument): TypedArray {
const TypedArray = ComponentTypeToTypedArray[accessorDef.componentType];

@@ -598,3 +598,3 @@ const elementSize = Accessor.getElementSize(accessorDef.type);

// TODO(cleanup): Relying to much on ArrayBuffers: requires copying.
array = getAccessorArray(accessorDef, nativeDoc).slice();
array = getAccessorArray(accessorDef, jsonDoc).slice();
} else {

@@ -607,4 +607,4 @@ array = new TypedArray(accessorDef.count * elementSize);

const valuesDef = {...accessorDef, ...accessorDef.sparse.values, count};
const indices = getAccessorArray(indicesDef as GLTF.IAccessor, nativeDoc);
const values = getAccessorArray(valuesDef, nativeDoc);
const indices = getAccessorArray(indicesDef as GLTF.IAccessor, jsonDoc);
const values = getAccessorArray(valuesDef, jsonDoc);

@@ -611,0 +611,0 @@ // Override indices given in the sparse data.

import { Document } from '../document';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { PlatformIO } from './platform-io';
const DEFAULT_INIT: RequestInit = {};
/**

@@ -10,2 +12,6 @@ * # WebIO

*
* The most common use of the I/O service is to read/write a {@link Document} with a given path.
* Methods are also available for converting in-memory representations of raw glTF files, both
* binary (*ArrayBuffer*) and JSON ({@link JSONDocument}).
*
* Usage:

@@ -19,7 +25,7 @@ *

* // Read.
* const doc = await io.read('model.glb'); // → Document
* const doc = io.unpackGLB(ArrayBuffer); // → Document
* const doc = await io.read('model.glb'); // → Document
* const doc = io.readBinary(ArrayBuffer); // → Document
*
* // Write.
* const arrayBuffer = io.packGLB(doc); // → ArrayBuffer
* const arrayBuffer = io.writeBinary(doc); // → ArrayBuffer
* ```

@@ -33,49 +39,54 @@ *

* Constructs a new WebIO service. Instances are reusable.
* @param fetchConfig Configuration object for Fetch API.
* @param _fetchConfig Configuration object for Fetch API.
*/
constructor(private readonly fetchConfig: RequestInit) {
constructor(private readonly _fetchConfig: RequestInit = DEFAULT_INIT) {
super();
}
/* Public. */
/**********************************************************************************************
* Public.
*/
/** Loads a URI and returns a {@link NativeDocument} struct. */
public readNativeDocument (uri: string): Promise<NativeDocument> {
const isGLB = !!(uri.match(/\.glb$/) || uri.match(/^data:application\/octet-stream;/));
return isGLB ? this.readGLB(uri) : this.readGLTF(uri);
}
/** Loads a URI and returns a {@link Document} instance. */
public read (uri: string): Promise<Document> {
return this.readNativeDocument(uri)
.then((nativeDoc) => this.createDocument(nativeDoc));
return this.readAsJSON(uri).then((jsonDoc) => this.readJSON(jsonDoc));
}
/* Internal. */
/** Loads a local path and returns a {@link JSONDocument} struct, without parsing. */
public readAsJSON (uri: string): Promise<JSONDocument> {
const isGLB = !!(uri.match(/\.glb$/) || uri.match(/^data:application\/octet-stream;/));
return isGLB ? this._readGLB(uri) : this._readGLTF(uri);
}
private readGLTF (uri: string): Promise<NativeDocument> {
const nativeDoc = {json: {}, resources: {}} as NativeDocument;
return fetch(uri, this.fetchConfig)
/**********************************************************************************************
* Private.
*/
/** @hidden */
private _readGLTF (uri: string): Promise<JSONDocument> {
const jsonDoc = {json: {}, resources: {}} as JSONDocument;
return fetch(uri, this._fetchConfig)
.then((response) => response.json())
.then((json: GLTF.IGLTF) => {
nativeDoc.json = json;
jsonDoc.json = json;
const pendingResources: Array<Promise<void>> = [...json.images, ...json.buffers]
.map((resource: GLTF.IBuffer|GLTF.IImage) => {
if (resource.uri) {
return fetch(resource.uri, this.fetchConfig)
return fetch(resource.uri, this._fetchConfig)
.then((response) => response.arrayBuffer())
.then((arrayBuffer) => {
nativeDoc.resources[resource.uri] = arrayBuffer;
jsonDoc.resources[resource.uri] = arrayBuffer;
});
}
});
return Promise.all(pendingResources).then(() => nativeDoc);
return Promise.all(pendingResources).then(() => jsonDoc);
});
}
private readGLB (uri: string): Promise<NativeDocument> {
return fetch(uri, this.fetchConfig)
/** @hidden */
private _readGLB (uri: string): Promise<JSONDocument> {
return fetch(uri, this._fetchConfig)
.then((response) => response.arrayBuffer())
.then((arrayBuffer) => this.unpackGLBToNativeDocument(arrayBuffer));
.then((arrayBuffer) => this.binaryToJSON(arrayBuffer));
}
}

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

import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Accessor, Buffer, Camera, Material, Mesh, Node, Property, Skin, Texture, TextureInfo, TextureSampler } from '../properties';

@@ -31,3 +31,3 @@ import { ImageUtils, Logger } from '../utils';

constructor (public readonly nativeDocument: NativeDocument, public readonly options: WriterOptions) {}
constructor (public readonly jsonDoc: JSONDocument, public readonly options: WriterOptions) {}

@@ -48,4 +48,4 @@ /**

if (!this.samplerDefIndexMap.has(samplerKey)) {
this.samplerDefIndexMap.set(samplerKey, this.nativeDocument.json.samplers.length);
this.nativeDocument.json.samplers.push(samplerDef);
this.samplerDefIndexMap.set(samplerKey, this.jsonDoc.json.samplers.length);
this.jsonDoc.json.samplers.push(samplerDef);
}

@@ -60,4 +60,4 @@

if (!this.textureDefIndexMap.has(textureKey)) {
this.textureDefIndexMap.set(textureKey, this.nativeDocument.json.textures.length);
this.nativeDocument.json.textures.push(textureDef);
this.textureDefIndexMap.set(textureKey, this.jsonDoc.json.textures.length);
this.jsonDoc.json.textures.push(textureDef);
}

@@ -96,4 +96,4 @@

this.imageData.push(data);
imageDef.bufferView = this.nativeDocument.json.bufferViews.length;
this.nativeDocument.json.bufferViews.push({
imageDef.bufferView = this.jsonDoc.json.bufferViews.length;
this.jsonDoc.json.bufferViews.push({
buffer: 0,

@@ -106,3 +106,3 @@ byteOffset: -1, // determined while iterating buffers, in Writer.ts.

imageDef.uri = this.imageURIGenerator.createURI(texture, extension);
this.nativeDocument.resources[imageDef.uri] = data;
this.jsonDoc.resources[imageDef.uri] = data;
}

@@ -109,0 +109,0 @@ }

import { GLB_BUFFER, NAME, VERSION } from '../constants';
import { Document } from '../document';
import { Link } from '../graph';
import { NativeDocument } from '../native-document';
import { JSONDocument } from '../json-document';
import { Accessor, AnimationSampler, AttributeLink, IndexLink, Primitive, Property, Root } from '../properties';

@@ -28,7 +28,7 @@ import { BufferUtils, Logger } from '../utils';

export class GLTFWriter {
public static write(doc: Document, options: WriterOptions = DEFAULT_OPTIONS): NativeDocument {
public static write(doc: Document, options: WriterOptions = DEFAULT_OPTIONS): JSONDocument {
const root = doc.getRoot();
const nativeDoc = {json: {asset: root.getAsset()}, resources: {}} as NativeDocument;
const jsonDoc = {json: {asset: root.getAsset()}, resources: {}} as JSONDocument;
const logger = options.logger || Logger.DEFAULT_INSTANCE;
const json = nativeDoc.json;
const json = jsonDoc.json;
json.asset.generator = `glTF-Transform ${VERSION}`;

@@ -38,3 +38,3 @@

const context = new WriterContext(nativeDoc, options);
const context = new WriterContext(jsonDoc, options);
const numBuffers = root.listBuffers().length;

@@ -330,3 +330,3 @@ const numImages = root.listTextures().length;

bufferDef.byteLength = bufferByteLength;
nativeDoc.resources[uri] = BufferUtils.concat(buffers);
jsonDoc.resources[uri] = BufferUtils.concat(buffers);

@@ -598,3 +598,3 @@ json.buffers.push(bufferDef);

return nativeDoc;
return jsonDoc;
}

@@ -601,0 +601,0 @@ }

@@ -13,3 +13,3 @@ import { PropertyType, vec2 } from '../constants';

* should be unique within a document, such that no other texture contains the same
* {@link getImage}() data. Where duplicates may already exist, the `prune({textures: true})`
* {@link getImage}() data. Where duplicates may already exist, the `dedup({textures: true})`
* transform can remove them. A {@link Document} with N texture properties will be exported to a

@@ -16,0 +16,0 @@ * glTF file with N `image` properties, and the minimum number of `texture` properties necessary

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc