Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@loaders.gl/gltf

Package Overview
Dependencies
Maintainers
9
Versions
342
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/gltf - npm Package Compare versions

Comparing version 1.0.3 to 1.1.0-alpha.1

dist/es5/glb-loader.js

2

dist/dist.min.js

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

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var s=t[n]={i:n,l:!1,exports:{}};return e[n].call(s.exports,s,s.exports,r),s.l=!0,s.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)r.d(n,s,function(t){return e[t]}.bind(null,s));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=5)}([,function(e,t){},function(e,t,r){"use strict";(function(e,n){r.d(t,"a",function(){return s});const s="object"!=typeof e||"[object process]"!==String(e)||e.browser;"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof document&&document}).call(this,r(7),r(4))},function(e,t){},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){(function(t){const n=r(8),s="undefined"==typeof window?t:window;s.loaders=s.loaders||{},e.exports=Object.assign(s.loaders,n)}).call(this,r(4))},,function(e,t){var r,n,s=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function u(e){if(r===setTimeout)return setTimeout(e,0);if((r===i||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:i}catch(e){r=i}try{n="function"==typeof clearTimeout?clearTimeout:o}catch(e){n=o}}();var a,f=[],c=!1,h=-1;function l(){c&&a&&(c=!1,a.length?f=a.concat(f):h=-1,f.length&&g())}function g(){if(!c){var e=u(l);c=!0;for(var t=f.length;t;){for(a=f,f=[];++h<t;)a&&a[h].run();h=-1,t=f.length}a=null,c=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===o||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];f.push(new d(e,t)),1!==f.length||c||u(g)},d.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=y,s.addListener=y,s.once=y,s.off=y,s.removeListener=y,s.removeAllListeners=y,s.emit=y,s.prependListener=y,s.prependOnceListener=y,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(e,t,r){"use strict";r.r(t);var n=r(2),s=r(1);function i(e,t){if(!e)throw new Error(t||"loader assertion failed.")}async function o(e,t){return await fetch(e,t)}let u="";const a={};function f(e){for(const t in a)if(e.startsWith(t)){const r=a[t];return e.replace(t,r)}return e+=u}var c=r(9);function h(e){return e+3&-4}function l(e,t,r,n=t.byteLength){const s=new Uint8Array(e,r,n),i=new Uint8Array(t);return s.set(i),e}function g(e,t,r){let n;if(e instanceof ArrayBuffer)n=new Uint8Array(e);else{const t=e.byteOffset,r=e.byteLength;n=new Uint8Array(e.buffer,t,r)}return t.set(n,r),r+h(n.byteLength)}const d=1735152710,y=12,m=8,p=1313821514,b=5130562,w=!0,x=!1;function A(e,t,r=0,n={}){const s=new DataView(t);e.byteOffset=r,e.magic=s.getUint32(r+0,x),e.version=s.getUint32(r+4,w),e.byteLength=s.getUint32(r+8,w),e.type=function(e){return`${String.fromCharCode(e.getUint8(0))}${String.fromCharCode(e.getUint8(1))}${String.fromCharCode(e.getUint8(2))}${String.fromCharCode(e.getUint8(3))}`}(s);const{magic:o=d}=n;e.magic===d||e.magic===o||console.warn(`Invalid GLB magic string ${e.type}`),i(2===e.version,`Invalid GLB version ${e.version}. Only .glb v2 supported`),i(e.byteLength>20),e.jsonChunkLength=s.getUint32(r+12,w),e.jsonChunkFormat=s.getUint32(r+16,w),i(e.jsonChunkFormat===p||0===e.jsonChunkFormat,`JSON chunk format ${e.jsonChunkFormat}`),e.jsonChunkByteOffset=y+m;const u=new Uint8Array(t,r+e.jsonChunkByteOffset,e.jsonChunkLength),a=new c.TextDecoder("utf8").decode(u);e.json=JSON.parse(a);const f=e.jsonChunkByteOffset+h(e.jsonChunkLength);if(e.hasBinChunk=f+8<=e.byteLength,e.binChunkByteOffset=0,e.binChunkLength=0,e.hasBinChunk){e.binChunkLength=s.getUint32(r+f+0,w),e.binChunkFormat=s.getUint32(r+f+4,w),i(e.binChunkFormat===b||1===e.binChunkFormat,`BIN chunk format ${e.binChunkFormat}`),e.binChunkByteOffset=f+m}return r+e.byteLength}const _={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},j={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},B={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function v(e,t,r){r&&(e=function(e,t){const r=e.byteLength-t,n=new ArrayBuffer(r),s=new Uint8Array(e),i=new Uint8Array(n);for(let e=0;e<r;e++)i[e]=s[t+e];return n}(e,r));const n=t.bufferViews||[];for(let e=0;e<n.length;++e){i(n[e].byteLength>=0)}return{accessors:T(e,n,t),images:L(e,n,t)}}function T(e,t,r){const n=r.accessors||[],s=[];for(let r=0;r<n.length;++r){const o=n[r];i(o);const u=t[o.bufferView];if(u){const{ArrayType:t,length:r}=U(o,u),n=new t(e,u.byteOffset,r);n.accessor=o,s.push(n)}}return s}function L(e,t,r){const n=r.images||[],s=[];for(let r=0;r<n.length;++r){const o=n[r];i(o);const u=t[o.bufferView];i(u);const a=new Uint8Array(e,u.byteOffset,u.byteLength);a.imate=o,s.push(a)}return s}function U(e,t){const r=B[e.componentType],n=_[e.type],s=j[e.componentType],o=e.count*n,u=e.count*n*s;return i(u>=0&&u<=t.byteLength),{ArrayType:r,length:o,byteLength:u}}function V(e,t,r={}){return function e(t,r,n,s={}){const i=t;const o=function(e,t){const r=function(e){if("string"==typeof e){if(0===e.indexOf("##/"))return e.slice(1);let t=e.match(/\#\/([a-z]+)\/([0-9]+)/);if(t){const e=parseInt(t[2],10);return[t[1],e]}if(t=e.match(/\$\$\$([0-9]+)/)){const e=parseInt(t[1],10);return["accessors",e]}}return null}(e);if(r){const[n,s]=r,i=t[n]&&t[n][s];if(i)return i;console.error(`Invalid JSON pointer ${e}: #/${n}/${s}`)}return null}(i,n);if(o)return o;if(Array.isArray(i))return i.map(t=>e(t,r,n,s));if(null!==i&&"object"==typeof i){const t={};for(const o in i)t[o]=e(i[o],r,n,s);return t}return i}(e,e,t,r)}const E=["SCALAR","VEC2","VEC3","VEC4"],C=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126]]);function k(e){const t=C.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}const S={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},O={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},R={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array},M=1735152710;class I{static isGLB(e,t={}){const{magic:r=M}=t,n=new DataView(e).getUint32(0,!1);return n===r||n===M}parse(e,t={}){return this.parseSync(e,t)}parseSync(e,t={}){if(this.glbArrayBuffer=e,this.binaryByteOffset=null,this.packedJson=null,this.json=null,null===this.json&&null===this.binaryByteOffset){const e=0;A(this,this.glbArrayBuffer,e,t),this.binaryByteOffset=this.binChunkByteOffset,this.packedJson=this.json,this.unpackedBuffers=v(this.glbArrayBuffer,this.json,this.binaryByteOffset),this.json=V(this.json,this.unpackedBuffers)}return this}getApplicationData(e){return this.json[e]}getJSON(){return this.json}getArrayBuffer(){return this.glbArrayBuffer}getBinaryByteOffset(){return this.binaryByteOffset}getBufferView(e){const t=(e.byteOffset||0)+this.binaryByteOffset;return new Uint8Array(this.glbArrayBuffer,t,e.byteLength)}getBuffer(e){const t=R[e.componentType],r=S[e.type],n=O[e.componentType],s=e.count*r,o=e.count*r*n,u=this.json.bufferViews[e.bufferView];i(o>=0&&e.byteOffset+o<=u.byteLength);const a=u.byteOffset+this.binaryByteOffset+e.byteOffset;return new t(this.glbArrayBuffer,a,s)}getImageData(e){return{typedArray:this.getBufferView(e.bufferView),mimeType:e.mimeType||"image/jpeg"}}getImage(e){const t=this.getBufferView(e.bufferView),r=e.mimeType||"image/jpeg",n=new Blob([t],{type:r}),s=(self.URL||self.webkitURL).createObjectURL(n),i=new Image;return i.src=s,i}getImageAsync(e){return new Promise(t=>{const r=this.getBufferView(e.bufferView),n=e.mimeType||"image/jpeg",s=new Blob([r],{type:n}),i=(self.URL||self.webkitURL).createObjectURL(s),o=new Image;o.onload=(()=>t(o)),o.src=i})}}function P(e,t){return e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:")?e:t.substr(0,t.lastIndexOf("/")+1)+e}const D={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},F={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},$={magFilter:10240,minFilter:10241,wrapS:10242,wrapT:10243};class N{postProcess(e,t,r={}){return this.gltf=e,this.glbParser=t,this._resolveToTree(r),this.gltf}_resolveToTree(e={}){const{gltf:t}=this;return(t.bufferViews||[]).forEach((e,t)=>this._resolveBufferView(e,t)),(t.images||[]).forEach((t,r)=>this._resolveImage(t,r,e)),(t.samplers||[]).forEach((e,t)=>this._resolveSampler(e,t)),(t.textures||[]).forEach((e,t)=>this._resolveTexture(e,t)),(t.accessors||[]).forEach((e,t)=>this._resolveAccessor(e,t)),(t.materials||[]).forEach((e,t)=>this._resolveMaterial(e,t)),(t.meshes||[]).forEach((e,t)=>this._resolveMesh(e,t)),(t.nodes||[]).forEach((e,t)=>this._resolveNode(e,t)),(t.skins||[]).forEach((e,t)=>this._resolveSkin(e,t)),(t.scenes||[]).forEach((e,t)=>this._resolveScene(e,t)),void 0!==t.scene&&(t.scene=t.scenes[this.gltf.scene]),this._process_extension_KHR_lights_punctual(),t}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const r=this.gltf[e]&&this.gltf[e][t];return r||console.warn(`glTF file error: Could not find ${e}[${t}]`),r}_resolveScene(e,t){e.id=`scene-${t}`,e.nodes=(e.nodes||[]).map(e=>this.getNode(e))}_resolveNode(e,t){e.id=`node-${t}`,e.children=(e.children||[]).map(e=>this.getNode(e)),void 0!==e.mesh&&(e.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin))}_resolveSkin(e,t){e.id=`skin-${t}`,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices)}_resolveMesh(e,t){e.id=`mesh-${t}`;for(const t of e.primitives){for(const e in t.attributes)t.attributes[e]=this.getAccessor(t.attributes[e]);void 0!==t.indices&&(t.indices=this.getAccessor(t.indices)),void 0!==t.material&&(t.material=this.getMaterial(t.material))}}_resolveMaterial(e,t){if(e.id=`material-${t}`,e.normalTexture&&(e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.pbrMetallicRoughness){const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}}_resolveAccessor(e,t){e.id=`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=F[e],e.components=D[e],e.bytesPerElement=e.bytesPerComponent*e.components}_resolveTexture(e,t){e.id=`texture-${t}`,e.sampler=this.getSampler(e.sampler),e.source=this.getImage(e.source)}_resolveSampler(e,t){e.id=`sampler-${t}`,e.parameters={};for(const t in e){const r=this._enumSamplerParameter(t);void 0!==r&&(e.parameters[r]=e[t])}}_enumSamplerParameter(e){return $[e]}_resolveImage(e,t,r){e.id=`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const{createImages:n=!0}=r;n?e.image=this.glbParser.getImage(e):e.getImageAsync=(()=>this.glbParser?this.glbParser.getImageAsync(e):e.uri?new Promise(t=>{const n=new Image;n.crossOrigin="anonymous",n.onload=(()=>t(n)),n.src=P(e.uri,r.uri)}):null)}_resolveBufferView(e,t){if(e.id=`bufferView-${t}`,e.buffer=this.getBuffer(e.buffer),this.glbParser)e.data=this.glbParser.getBufferView(e);else{const t=e.byteOffset||0;e.data=new Uint8Array(e.buffer.data,t,e.byteLength)}}_resolveCamera(e){e.perspective,e.orthographic}_process_extension_KHR_lights_punctual(){const{gltf:e}=this,t=e.extensions&&e.extensions.KHR_lights_punctual;t&&(e.lights=t.lights),this._removeExtension("KHR_lights_punctual");for(const t of e.nodes||[]){const e=t.extensions&&t.extensions.KHR_lights_punctual;e&&(t.light=this._get("lights",e.light),delete t.extensions.KHR_lights_punctual)}delete e.lights}_removeExtension(e){this.gltf.extensionsRequired&&this._removeStringFromArray(this.gltf.extensionsRequired,e),this.gltf.extensionsUsed&&this._removeStringFromArray(this.gltf.extensionsUsed,e),this.gltf.extensions&&delete this.gltf.extensions[e]}_removeStringFromArray(e,t){let r=!0;for(;r;){const n=e.indexOf(t);n>-1?e.splice(n,1):r=!1}}}const q="KHR_draco_mesh_compression",G="UBER_draco_point_cloud_compression";const W=["SCALAR","VEC2","VEC3","VEC4"],z=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126]]);function J(e){return W[e-1]||W[0]}function K(e){const t=z.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function H(e,t){const{buffer:r,size:n,count:s}=function(e,t){let r=e,n=1,s=0;e&&e.value&&(r=e.value,n=e.size||1);r&&(ArrayBuffer.isView(r)||(r=function(e,t,r=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(r&&!(e instanceof t))return new t(e);return e}(r,Float32Array)),s=r.length/n);return{buffer:r,size:n,count:s}}(e);return{value:r,size:n,bufferView:null,byteOffset:0,count:s,type:J(n),componentType:K(r)}}const X={fetchLinkedResources:!0,fetch:async function(e,t){return e=f(e),(n.a?o:s.fetchFile)(e,t)},decompress:!1,DracoLoader:null,postProcess:!0,createImages:!1,log:console};class Q{async parse(e,t={}){if(t=Object.assign({},X,t),this.parseSync(e,{...t,postProcess:!1,decompress:!1}),t.fetchLinkedResources&&await this._loadLinkedAssets(t),t.decompress&&this._decompressMeshes(t),t.postProcess){(new N).postProcess(this.gltf,this.glbParser,t)}return this.gltf}parseSync(e,t={}){if(t=Object.assign({},X,t),e instanceof ArrayBuffer&&!I.isGLB(e,t)){e=(new c.TextDecoder).decode(e)}if("string"==typeof e&&(e=JSON.parse(e)),e instanceof ArrayBuffer?(this.glbParser=new I,this.gltf=this.glbParser.parseSync(e).json,this.json=this.gltf):(this.glbParser=null,this.gltf=e,this.json=e),t.decompress&&this._decompressMeshes(t),t.postProcess){(new N).postProcess(this.gltf,this.glbParser,t)}return this.gltf}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),r=this.json.extensions||{};return t?r[e]||!0:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const r=this.gltf[e]&&this.gltf[e][t];return r||console.warn(`glTF file error: Could not find ${e}[${t}]`),r}async _loadLinkedAssets(e){return await Promise.all(this.gltf.buffers.map(t=>this._loadBuffer(t,e)))}async _loadBuffer(e,t){if(e.uri){const r=t.fetch||window.fetch,n=P(e.uri,t.uri),s=await r(n),i=await s.arrayBuffer();e.data=i,e.uri=null}}_decompressMeshes(e){if(e.DracoLoader&&e.decompress){for(const t of this.gltf.meshes||[])for(const r of t.primitives)if(this._decompressKhronosDracoPrimitive(r,e),this._decompressUberDracoPrimitive(r,e),!r.attributes||0===Object.keys(r.attributes).length)throw new Error("Empty glTF primitive: decompression failure?");this._removeExtension(q),this._removeExtension(G)}}_decompressKhronosDracoPrimitive(e,t){const r=e.extensions&&e.extensions[q];if(!r)return;delete e.extensions[q];const n=this._getBufferViewArray(r.bufferView),s=t.DracoLoader.parseSync(n);e.attributes=function(e){const t={};for(const r in e){const n=e[r];if("indices"!==r){const e=H(n);t[r]=e}}return t}(s.attributes),s.indices&&(e.indices=H(s.indices))}_decompressUberDracoPrimitive(e,t){const r=e.extensions&&e.extensions[G];if(!r)return;if(0!==e.mode)throw new Error(G);delete e.extensions[G];const n=this._getBufferViewArray(r.bufferView),s=t.DracoLoader.parseSync(n);e.attributes=s.attributes}_getBufferViewArray(e){const t=this.gltf.bufferViews[e];if(this.glbParser)return this.glbParser.getBufferView(t);const r=this.gltf.buffers[t.buffer].data,n=t.byteOffset||0;return new Uint8Array(r,n,t.byteLength)}_removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}_removeStringFromArray(e,t){let r=!0;for(;r;){const n=e.indexOf(t);n>-1?e.splice(n,1):r=!1}}}var Y={name:"glTF",extension:["gltf","glb"],text:!0,binary:!0,parse:function(e,t={}){return(new Q).parse(e,t)},parseSync:function(e,t={}){return(new Q).parseSync(e,t)}},Z=r(3);const ee=!1,te=!0,re=new Map([["image/png",function(e){const t=ie(e);if(t.byteLength<24||2303741511!==t.getUint32(0,ee))return null;return{width:t.getUint32(16,ee),height:t.getUint32(20,ee)}}],["image/jpeg",function(e){const t=ie(e);if(t.byteLength<2||65496!==t.getUint16(0,ee))return null;const{tableMarkers:r,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let s=2;for(;s<t.byteLength;){const e=t.getUint16(s,ee);if(n.has(e))return{height:t.getUint16(s+5,ee),width:t.getUint16(s+7,ee)};if(!r.has(e))return null;s+=2,s+=t.getUint16(s,ee)}return null}],["image/gif",function(e){const t=ie(e);if(t.byteLength<10||1195984440!==t.getUint32(0,ee))return null;return{width:t.getUint16(6,te),height:t.getUint16(8,te)}}],["image/bmp",function(e){const t=ie(e);if(16973!==t.getUint16(0,ee))return null;return{width:t.getUint32(18,te),height:t.getUint32(22,te)}}]]),ne=`Invalid MIME type. Supported MIME types are: ${Array.from(re.keys()).join(", ")}`;function se(e,t){for(const[t,r]of re.entries()){const n=r(e);if(n)return n.mimeType=t,n}return null}function ie(e){if(Z.bufferToArrayBuffer&&(e=Object(Z.bufferToArrayBuffer)(e)),e instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}function oe(e,t=null){return function(e,t=null){if(t){const r=re.get(t);if(!r)throw new Error(ne);const n=r(e);if(!n)throw new Error(`invalid image data for type: ${t}`);return n}const r=se(e);if(!r)throw new Error(ne);return r}(e)}function ue(e,t=Float32Array){if(0===e.length)return new Float32Array(0);if(!function e(t,r=Number.isFinite){let n=-1;for(;++n<t.length;){const s=t[n];if(Array.isArray(s)||ArrayBuffer.isView(s)){if(!e(s,r))return!1}else if(!r(s))return!1}return!0}(e))return null;const r=new t(function e(t,r=3){let n=0;let s=0;let i=-1;for(;++i<t.length;){const r=t[i];Array.isArray(r)||ArrayBuffer.isView(r)?n+=e(r):s++}return n+(0===n&&s<r?r:s)}(e));return function(e,t,r=3){(function e(t,r,n,s){let i=-1,o=0;for(;++i<t.length;){const u=t[i];Array.isArray(u)||ArrayBuffer.isView(u)?s=e(u,r,n,s):o<n&&(r[s++]=u,o++)}return o>0&&o<n&&(r[s++]=0),s})(e,t,r,0)}(e,r),r}function ae(e,t,r={}){const{flattenArrays:n=!1}=r;let s=e;if("string"==typeof s&&0===s.indexOf("#/"))return`#${s}`;if(Array.isArray(s)){const e=n&&ue(s);if(!e)return s.map(e=>ae(e,t,r));s=e}if(ArrayBuffer.isView(s)&&t){if(t.isImage(s)){return`#/images/${t.addImage(s)}`}return`#/accessors/${t.addBuffer(s)}`}if(null!==s&&"object"==typeof s){const e={};for(const n in s)e[n]=ae(s[n],t,r);return e}return s}const fe=1179937895,ce=1313821514,he=5130562,le=!0,ge=12,de=8;class ye{constructor(e={}){this.byteLength=0,this.json={buffers:[{byteLength:0}],bufferViews:[],accessors:[],images:[],meshes:[]},this.sourceBuffers=[],this.log=e.log||console}getByteLength(){return this.byteLength}isImage(e){return function(e){const t=se(e);return!!t&&t.mimeType}(e)}encodeSync(e={}){return this.encodeAsGLB(e)}encodeAsGLB(e={}){return this._createGLBBuffer(e)}addApplicationData(e,t,r={}){const n=r.packTypedArrays?ae(t,this,r):t;return this.json[e]=n,this}addBuffer(e,t={size:3}){const r=this.addBufferView(e),n={size:t.size,componentType:k(e),count:Math.round(e.length/t.size)};return this.addAccessor(r,Object.assign(n,t))}addBufferView(e){const t=e.byteLength||e.length;return this.json.bufferViews.push({buffer:0,byteOffset:this.byteLength,byteLength:t}),this.byteLength+=h(t),this.sourceBuffers.push(e),this.json.bufferViews.length-1}addAccessor(e,t){var r;return this.json.accessors.push({bufferView:e,type:(r=t.size,E[r-1]||E[0]),componentType:t.componentType,count:t.count}),this.json.accessors.length-1}_pack(){return this._packBinaryChunk(),{arrayBuffer:this.arrayBuffer,json:this.json}}_packBinaryChunk(){if(this.arrayBuffer)return;const e=this.byteLength,t=new ArrayBuffer(e),r=new Uint8Array(t);let n=0;for(let e=0;e<this.sourceBuffers.length;e++){n=g(this.sourceBuffers[e],r,n)}this.json.buffers[0].byteLength=e,this.arrayBuffer=t,this.sourceBuffers=[]}_createGLBBuffer(e={}){this._packBinaryChunk();const t=this.arrayBuffer;e.magic&&console.warn("Custom glTF magic number no longer supported");const r=ge+de,n=this._convertObjectToJsonChunk(this.json),s=h(n.byteLength),i=s+r,o=i+de+h(t.byteLength),u=new ArrayBuffer(o),a=new DataView(u);a.setUint32(0,fe,le),a.setUint32(4,2,le),a.setUint32(8,o,le),a.setUint32(12,n.byteLength,le),a.setUint32(16,ce,le),l(u,n,r);for(let e=0;e<s-n.byteLength;++e)a.setUint8(r+n.byteLength+e,32);const f=h(t.byteLength);a.setUint32(i+0,f,le),a.setUint32(i+4,he,le),l(u,t,i+de);for(let e=0;e<f-t.byteLength;++e)a.setUint8(i+de+t.byteLength+e,0);return u}_getInternalCounts(){return{buffers:this.json.buffers.length,bufferViews:this.json.bufferViews.length,accessors:this.json.accessors.length,images:this.json.images.length}}_convertObjectToJsonChunk(e){const t=JSON.stringify(e);return new c.TextEncoder("utf8").encode(t)}}class me extends ye{constructor(e={}){super(e),this.DracoWriter=e.DracoWriter,this.DracoLoader=e.DracoLoader}addApplicationData(e,t,r={}){const n=r.packTypedArrays?ae(t,this,r):t;return this.json[e]=n,this}addExtraData(e,t,r={}){const n=r.packedTypedArrays?ae(t,this,r):t;return this.json.extras=this.json.extras||{},this.json.extras[e]=n,this}addExtension(e,t,r={}){i(t);const n=r.packTypedArrays?ae(t,this,r):t;return this.json.extensions=this.json.extensions||{},this.json.extensions[e]=n,this.registerUsedExtension(e),this}addRequiredExtension(e,t,r={}){i(t);const n=r.packTypedArrays?ae(t,this,r):t;return this.addExtension(e,n),this.registerRequiredExtension(e),this}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}addMesh(e,t,r=4){const n={primitives:[{attributes:this._addAttributes(e),indices:t,mode:r}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(n),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addCompressedMesh(e,t,r=4){if(!this.DracoWriter||!this.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");this.registerRequiredExtension(q);const n=this.DracoWriter.encodeSync({attributes:e}),s=this.DracoLoader.parseSync({attributes:e}),i=this._addFauxAttributes(s.attributes),o=this.addBufferView(n),u={primitives:[{attributes:i,mode:r,extensions:{[q]:{bufferView:o,attributes:i}}}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(u),this.json.meshes.length-1}addCompressedPointCloud(e){if(!this.DracoWriter||!this.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");e.mode=0;const t=this.DracoWriter.encodeSync(e,{pointcloud:!0}),r=this.addBufferView(t),n={primitives:[{attributes:{},mode:0,extensions:{[G]:{bufferView:r}}}]};return this.registerRequiredExtension(G),this.json.meshes=this.json.meshes||[],this.json.meshes.push(n),this.json.meshes.length-1}addImage(e){const t=this.addBufferView(e),r=oe(e)||{};if(r){const{mimeType:e,width:n,height:s}=r;this.json.images.push({bufferView:t,mimeType:e,width:n,height:s})}else this.json.images.push({bufferView:t});return this.json.images.length-1}}var pe={name:"GLB",extensions:["glb"],encodeSync:function(e,t){return(new me).encodeSync(e,t)}};r.d(t,"GLTFLoader",function(){return Y}),r.d(t,"GLTFWriter",function(){return pe}),r.d(t,"GLTFParser",function(){return Q}),r.d(t,"GLTFBuilder",function(){return me}),r.d(t,"GLBParser",function(){return I}),r.d(t,"GLBBuilder",function(){return ye}),r.d(t,"KHR_DRACO_MESH_COMPRESSION",function(){return q}),r.d(t,"UBER_POINT_CLOUD_EXTENSION",function(){return G}),r.d(t,"_parseGLBSync",function(){return A})},function(e,t){"undefined"==typeof TextDecoder?e.exports={}:e.exports={TextEncoder:TextEncoder,TextDecoder:TextDecoder}}])});
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var s=t();for(var r in s)("object"==typeof exports?exports:e)[r]=s[r]}}(window,function(){return function(e){var t={};function s(r){if(t[r])return t[r].exports;var n=t[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,s),n.l=!0,n.exports}return s.m=e,s.c=t,s.d=function(e,t,r){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(s.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)s.d(r,n,function(t){return e[t]}.bind(null,n));return r},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="",s(s.s=8)}([function(e,t,s){"use strict";(function(e,r){s.d(t,"b",function(){return n}),s.d(t,"a",function(){return o});const n="object"!=typeof e||"[object process]"!==String(e)||e.browser,i={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==r&&r,document:"undefined"!=typeof document&&document},o=i.global||i.self||i.window}).call(this,s(9),s(6))},,,,,,function(e,t){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(e){"object"==typeof window&&(s=window)}e.exports=s},,function(e,t,s){(function(t){const r=s(10),n="undefined"==typeof window?t:window;n.loaders=n.loaders||{},e.exports=Object.assign(n.loaders,r)}).call(this,s(6))},function(e,t){var s,r,n=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function u(e){if(s===setTimeout)return setTimeout(e,0);if((s===i||!s)&&setTimeout)return s=setTimeout,setTimeout(e,0);try{return s(e,0)}catch(t){try{return s.call(null,e,0)}catch(t){return s.call(this,e,0)}}}!function(){try{s="function"==typeof setTimeout?setTimeout:i}catch(e){s=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var a,c=[],f=!1,h=-1;function l(){f&&a&&(f=!1,a.length?c=a.concat(c):h=-1,c.length&&g())}function g(){if(!f){var e=u(l);f=!0;for(var t=c.length;t;){for(a=c,c=[];++h<t;)a&&a[h].run();h=-1,t=c.length}a=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function m(){}n.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var s=1;s<arguments.length;s++)t[s-1]=arguments[s];c.push(new d(e,t)),1!==c.length||f||u(g)},d.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=m,n.addListener=m,n.once=m,n.off=m,n.removeListener=m,n.removeAllListeners=m,n.emit=m,n.prependListener=m,n.prependOnceListener=m,n.listeners=function(e){return[]},n.binding=function(e){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(e){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},function(e,t,s){"use strict";s.r(t);var r={};s.r(r),s.d(r,"KHR_draco_mesh_compression",function(){return te}),s.d(r,"KHR_lights_punctual",function(){return se});const n="KHR_draco_mesh_compression",i="UBER_draco_point_cloud_compression",o="KHR_lights_punctual";let u="";const a={};function c(e){for(const t in a)if(e.startsWith(t)){const s=a[t];return e.replace(t,s)}return e+=u}async function f(e,t){return e=c(e),fetch(e,t)}function h(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const l={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},g={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},d={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function m(e,t,s){s&&(e=function(e,t){const s=e.byteLength-t,r=new ArrayBuffer(s),n=new Uint8Array(e),i=new Uint8Array(r);for(let e=0;e<s;e++)i[e]=n[t+e];return r}(e,s));const r=t.bufferViews||[];for(let e=0;e<r.length;++e){h(r[e].byteLength>=0)}return{accessors:p(e,r,t),images:y(e,r,t)}}function p(e,t,s){const r=s.accessors||[],n=[];for(let s=0;s<r.length;++s){const i=r[s];h(i);const o=t[i.bufferView];if(o){const{ArrayType:t,length:s}=b(i,o),r=new t(e,o.byteOffset,s);r.accessor=i,n.push(r)}}return n}function y(e,t,s){const r=s.images||[],n=[];for(let s=0;s<r.length;++s){const i=r[s];h(i);const o=t[i.bufferView];h(o);const u=new Uint8Array(e,o.byteOffset,o.byteLength);u.imate=i,n.push(u)}return n}function b(e,t){const s=d[e.componentType],r=l[e.type],n=g[e.componentType],i=e.count*r,o=e.count*r*n;return h(o>=0&&o<=t.byteLength),{ArrayType:s,length:i,byteLength:o}}function w(e,t){if(!e)throw new Error(t||"gltf/glb assertion failed.")}function x(e,t){return e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:")?e:t.substr(0,t.lastIndexOf("/")+1)+e}new Map;var j=s(0);const _=j.a.TextEncoder,v=j.a.TextDecoder;function A(e){return e+3&-4}const T=1735152710,B=12,L=8,V=1313821514,E=5130562,U=!0,S=!1;function O(e,t=0,s={}){const r=new DataView(e),{magic:n=T}=s,i=r.getUint32(t,!1);return i===n||i===T}function R(e,t,s=0,r={}){const n=new DataView(t);e.byteOffset=s,e.magic=n.getUint32(s+0,S),e.version=n.getUint32(s+4,U),e.byteLength=n.getUint32(s+8,U),e.type=function(e){return`${String.fromCharCode(e.getUint8(0))}${String.fromCharCode(e.getUint8(1))}${String.fromCharCode(e.getUint8(2))}${String.fromCharCode(e.getUint8(3))}`}(n);const{magic:i=T}=r;e.magic===T||e.magic===i||console.warn(`Invalid GLB magic string ${e.type}`),h(2===e.version,`Invalid GLB version ${e.version}. Only .glb v2 supported`),h(e.byteLength>20);const o=n.getUint32(s+12,U),u=n.getUint32(s+16,U);h(u===V||0===u,`JSON chunk format ${u}`);const a=B+L,c=new Uint8Array(t,s+a,o),f=new v("utf8").decode(c);e.json=JSON.parse(f);const l=a+A(o);if(e.hasBinChunk=l+8<=e.byteLength,e.hasBinChunk){const t=n.getUint32(s+l+0,U),r=n.getUint32(s+l+4,U);h(r===E||1===r,`BIN chunk format ${r}`);const i=l+L;e.binChunkByteOffset=i,e.binChunkLength=t}return s+e.byteLength}const k=!1,C=!0,M=new Map([["image/png",{test:function(e){return e.byteLength>=24&&2303741511===e.getUint32(0,k)},getSize:function(e){return{width:e.getUint32(16,k),height:e.getUint32(20,k)}}}],["image/jpeg",{test:function(e){return e.byteLength>=2&&65496===e.getUint16(0,k)},getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,k))return null;const{tableMarkers:t,sofMarkers:s}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r<e.byteLength;){const n=e.getUint16(r,k);if(s.has(n))return{height:e.getUint16(r+5,k),width:e.getUint16(r+7,k)};if(!t.has(n))return null;r+=2,r+=e.getUint16(r,k)}return null}}],["image/gif",{test:function(e){return e.byteLength>=10&&1195984440===e.getUint32(0,k)},getSize:function(e){return{width:e.getUint16(6,C),height:e.getUint16(8,C)}}}],["image/bmp",{test:function(e){return e.byteLength>=2&&16973===e.getUint16(0,k)},getSize:function(e){return{width:e.getUint32(18,C),height:e.getUint32(22,C)}}}]]);const P=`Invalid MIME type. Supported MIME types are: ${Array.from(M.keys()).join(", ")}`;function D(e){const t=F(e);for(const[e,{test:s}]of M.entries())if(s(t))return e;return null}function I(e,t=null){const s=function(e,t=null){t=t||D(e);const{getSize:s}=$(t),r=s(F(e));if(!r)throw new Error(`invalid image data for type: ${t}`);return r}(e,t=t||D(e));return s.mimeType=t,s}function $(e){const t=M.get(e);if(!t)throw new Error(P);return t}function F(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}function q(e,t,s,r){const n=G(s.byteLength),i=n-s.byteLength;if(e){const r=new Uint8Array(e.buffer,e.byteOffset+t,s.byteLength),n=new Uint8Array(s);r.set(n);for(let r=0;r<i;++r)e.setUint8(t+s.byteLength+r,32)}return t+=n}function G(e){return e+3&-4}function N(e,t,s){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{const t=e.byteOffset,s=e.byteLength;r=new Uint8Array(e.buffer,t,s)}return t.set(r,s),s+G(r.byteLength)}const z=["SCALAR","VEC2","VEC3","VEC4"],W=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126]]);function K(e){return z[e-1]||z[0]}function H(e){const t=W.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}const J={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},X={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Q={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};class Y{constructor(e){if(e instanceof Y)return e;e||(e={json:{version:2,buffers:[]},binary:null}),this.gltf=e}get json(){return this.gltf.json}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),s=this.json.extensions||{};return t?s[e]||!0:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getObjectExtension(e,t){return(e.extensions||{})[t]}getScene(e){return this.getObject("scenes",e)}getNode(e){return this.getObject("nodes",e)}getSkin(e){return this.getObject("skins",e)}getMesh(e){return this.getObject("meshes",e)}getMaterial(e){return this.getObject("materials",e)}getAccessor(e){return this.getObject("accessors",e)}getCamera(e){return null}getTexture(e){return this.getObject("textures",e)}getSampler(e){return this.getObject("samplers",e)}getImage(e){return this.getObject("images",e)}getBufferView(e){return this.getObject("bufferViews",e)}getBuffer(e){return this.getObject("buffers",e)}getObject(e,t){if("object"==typeof t)return t;const s=this.gltf[e]&&this.gltf[e][t];return s||console.warn(`glTF file error: Could not find ${e}[${t}]`),s}getBufferViewArray(e){const t=this.gltf.bufferViews[e];if(this.glbParser)return this.glbParser.getBufferView(t);const s=this.gltf.buffers[t.buffer].data,r=t.byteOffset||0;return new Uint8Array(s,r,t.byteLength)}addApplicationData(e,t){return this.json[e]=t,this}addExtraData(e,t){return this.json.extras=this.json.extras||{},this.json.extras[e]=t,this}addExtension(e,t){return w(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),this}addRequiredExtension(e,t){return w(t),this.addExtension(e,t),this.registerRequiredExtension(e),this}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}setObjectExtension(e,t,s){(e.extensions||{})[t]=s}addMesh(e,t,s=4){const r={primitives:[{attributes:this._addAttributes(e),indices:t,mode:s}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(r),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addImage(e,t){t=t||D(e);const s={bufferView:this.addBufferView(e),mimeType:t};return this.json.images=this.json.images||[],this.json.images.push(s),this.json.images.length-1}addBufferView(e){const t=e.byteLength||e.length;this.byteLength+=G(t),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const s={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(s),this.json.bufferViews.length-1}addAccessor(e,t){const s={bufferView:e,type:K(t.size),componentType:t.componentType,count:t.count};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(s),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const s=this.addBufferView(e),r={size:t.size,componentType:H(e),count:Math.round(e.length/t.size)};return this.addAccessor(s,Object.assign(r,t))}_removeStringFromArray(e,t){let s=!0;for(;s;){const r=e.indexOf(t);r>-1?e.splice(r,1):s=!1}}}function Z(e){const t={};for(const s in e){const r=e[s];if("indices"!==s){const e=ee(r);t[s]=e}}return t}function ee(e,t){const{buffer:s,size:r,count:n}=function(e,t){let s=e,r=1,n=0;e&&e.value&&(s=e.value,r=e.size||1);s&&(ArrayBuffer.isView(s)||(s=function(e,t,s=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(s&&!(e instanceof t))return new t(e);return e}(s,Float32Array)),n=s.length/r);return{buffer:s,size:r,count:n}}(e);return{value:s,size:r,bufferView:null,byteOffset:0,count:n,type:K(r),componentType:H(s)}}class te{static get name(){return n}static decode(e,t){const s=new Y(e);for(const e of s.json.meshes||[])te.decompressMesh(e,t);s.removeExtension(n)}static encode(e,t){const s=new Y(e);for(const e of s.json.meshes||[])te.compressMesh(e,t),s.addRequiredExtension(n)}static compressMesh(e,t,s=4,r={}){if(!r.DracoWriter||!r.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");const i=r.DracoWriter.encodeSync({attributes:e}),o=r.DracoLoader.parseSync({attributes:e}),u=r._addFauxAttributes(o.attributes),a=r.addBufferView(i);return{primitives:[{attributes:u,mode:s,extensions:{[n]:{bufferView:a,attributes:u}}}]}}static decompressMesh(e,t={}){for(const s of e.primitives)if(te._decompressMeshPrimitive(s,t),!s.attributes||0===Object.keys(s.attributes).length)throw new Error("Empty glTF primitive: decompression failure?")}static _decompressMeshPrimitive(e,t){const s=e.extensions&&e.extensions[n];if(!s)return;if(!t.DracoLoader||!t.decompress)return;delete e.extensions[n];const r=this._getBufferViewArray(s.bufferView),i=t.DracoLoader.parseSync(r);e.attributes=Z(i.attributes),i.indices&&(e.indices=ee(i.indices))}}class se{static get name(){return o}static decode(e,t){const s=new Y(e),r=s.getExtension(o);r&&(s.json.lights=r.lights,s.removeExtension(o));for(const e of s.nodes||[]){const t=e.extensions&&e.extensions.KHR_lights_punctual;t&&(e.light=s._get("lights",t.light),delete e.extensions.KHR_lights_punctual)}}static encode(e,t){const s=new Y(e),{json:r}=s;if(r.lights){const e=s.addExtensions(o);w(!e.lights),e.lights=r.lights,delete r.lights}if(s.json.lights){for(const e of s.json.lights){const t=e.node;s.addObjectExtension(t,o,e)}delete s.json.lights}}}const re={fetchLinkedResources:!1,decompress:!1,DracoLoader:null,postProcess:!0,createImages:!1,log:console},ne={fetchLinkedResources:!0,fetch:f,decompress:!1,DracoLoader:null,postProcess:!0,createImages:!1,log:console};function ie(e,t,s=0,n={}){n=Object.assign({},re,n);let i=t;if(i instanceof ArrayBuffer&&!O(i,s,n)){i=(new TextDecoder).decode(i)}if(e.buffers=[],"string"==typeof i?e.json=JSON.parse(i):i instanceof ArrayBuffer?(s=R(e,i,s,n),e.hasBinChunk&&(e.buffers.push({arrayBuffer:i,byteOffset:e.binChunkByteOffset,byteLength:e.binChunkLength}),e.unpackedBuffers=m(e.buffers[0].arrayBuffer,e.json,e.buffers[0].byteOffset))):e.json=i,n.uri&&(e.baseUri=n.uri),n.fetchLinkedResources)for(const t of e.json.buffers||[])if(t.uri)throw new Error("parseGLTFSync: Cannot decode uri buffers");return function(e,t){for(const s in r){const n=s in t&&!t[s];if(!n){const n=r[s];n.decode(e,t)}}}(e,n),s}async function oe(e,t,s=0,r={}){return r=Object.assign({},ne,r),ie(e,t,s,{...r,fetchLinkedResources:!1,postProcess:!1,decompress:!1}),r.fetchLinkedResources&&await async function(e,t){for(const s of e.json.buffers)if(s.uri){const e=t.fetch||window.fetch;w(e);const r=x(s.uri,t.uri),n=await e(r),i=await n.arrayBuffer();s.data=i,delete s.uri}}(e,r),e}function ue(e,t,s={}){return function e(t,s,r,n={}){const i=t;const o=function(e,t){const s=function(e){if("string"==typeof e){if(0===e.indexOf("##/"))return e.slice(1);let t=e.match(/#\/([a-z]+)\/([0-9]+)/);if(t){const e=parseInt(t[2],10);return[t[1],e]}if(t=e.match(/\$\$\$([0-9]+)/)){const e=parseInt(t[1],10);return["accessors",e]}}return null}(e);if(s){const[r,n]=s,i=t[r]&&t[r][n];if(i)return i;console.error(`Invalid JSON pointer ${e}: #/${r}/${n}`)}return null}(i,r);if(o)return o;if(Array.isArray(i))return i.map(t=>e(t,s,r,n));if(null!==i&&"object"==typeof i){const t={};for(const o in i)t[o]=e(i[o],s,r,n);return t}return i}(e,e,t,s)}class ae{static isGLB(e,t={}){return O(e,0)}parse(e,t={}){return this.parseSync(e,t)}parseSync(e,t={}){if(this.glbArrayBuffer=e,this.binaryByteOffset=null,this.packedJson=null,this.json=null,null===this.json&&null===this.binaryByteOffset){const e=0;R(this,this.glbArrayBuffer,e,t),this.binaryByteOffset=this.binChunkByteOffset,this.packedJson=this.json,this.unpackedBuffers=m(this.glbArrayBuffer,this.json,this.binaryByteOffset),this.json=ue(this.json,this.unpackedBuffers)}return this}getApplicationData(e){return this.json[e]}getJSON(){return this.json}getArrayBuffer(){return this.glbArrayBuffer}getBinaryByteOffset(){return this.binaryByteOffset}getBufferView(e){const t=(e.byteOffset||0)+this.binaryByteOffset;return new Uint8Array(this.glbArrayBuffer,t,e.byteLength)}getBuffer(e){const t=Q[e.componentType],s=J[e.type],r=X[e.componentType],n=e.count*s,i=e.count*s*r,o=this.json.bufferViews[e.bufferView];w(i>=0&&e.byteOffset+i<=o.byteLength);const u=o.byteOffset+this.binaryByteOffset+e.byteOffset;return new t(this.glbArrayBuffer,u,n)}getImageData(e){return{typedArray:this.getBufferView(e.bufferView),mimeType:e.mimeType||"image/jpeg"}}getImage(e){const t=this.getBufferView(e.bufferView),s=e.mimeType||"image/jpeg",r=new Blob([t],{type:s}),n=(self.URL||self.webkitURL).createObjectURL(r),i=new Image;return i.src=n,i}getImageAsync(e){return new Promise(t=>{const s=this.getBufferView(e.bufferView),r=e.mimeType||"image/jpeg",n=new Blob([s],{type:r}),i=(self.URL||self.webkitURL).createObjectURL(n),o=new Image;o.onload=(()=>t(o)),o.src=i})}}const ce={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},fe={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},he={magFilter:10240,minFilter:10241,wrapS:10242,wrapT:10243};class le{postProcess(e,t,s={}){return this.gltf=e,this.glbParser=t,this._resolveToTree(s),this.gltf}_resolveToTree(e={}){const{gltf:t}=this;return(t.bufferViews||[]).forEach((e,t)=>this._resolveBufferView(e,t)),(t.images||[]).forEach((t,s)=>this._resolveImage(t,s,e)),(t.samplers||[]).forEach((e,t)=>this._resolveSampler(e,t)),(t.textures||[]).forEach((e,t)=>this._resolveTexture(e,t)),(t.accessors||[]).forEach((e,t)=>this._resolveAccessor(e,t)),(t.materials||[]).forEach((e,t)=>this._resolveMaterial(e,t)),(t.meshes||[]).forEach((e,t)=>this._resolveMesh(e,t)),(t.nodes||[]).forEach((e,t)=>this._resolveNode(e,t)),(t.skins||[]).forEach((e,t)=>this._resolveSkin(e,t)),(t.scenes||[]).forEach((e,t)=>this._resolveScene(e,t)),void 0!==t.scene&&(t.scene=t.scenes[this.gltf.scene]),this._process_extension_KHR_lights_punctual(),t}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const s=this.gltf[e]&&this.gltf[e][t];return s||console.warn(`glTF file error: Could not find ${e}[${t}]`),s}_resolveScene(e,t){e.id=`scene-${t}`,e.nodes=(e.nodes||[]).map(e=>this.getNode(e))}_resolveNode(e,t){e.id=`node-${t}`,e.children=(e.children||[]).map(e=>this.getNode(e)),void 0!==e.mesh&&(e.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin))}_resolveSkin(e,t){e.id=`skin-${t}`,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices)}_resolveMesh(e,t){e.id=`mesh-${t}`;for(const t of e.primitives){for(const e in t.attributes)t.attributes[e]=this.getAccessor(t.attributes[e]);void 0!==t.indices&&(t.indices=this.getAccessor(t.indices)),void 0!==t.material&&(t.material=this.getMaterial(t.material))}}_resolveMaterial(e,t){if(e.id=`material-${t}`,e.normalTexture&&(e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.pbrMetallicRoughness){const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}}_resolveAccessor(e,t){e.id=`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=fe[e],e.components=ce[e],e.bytesPerElement=e.bytesPerComponent*e.components}_resolveTexture(e,t){e.id=`texture-${t}`,e.sampler=this.getSampler(e.sampler),e.source=this.getImage(e.source)}_resolveSampler(e,t){e.id=`sampler-${t}`,e.parameters={};for(const t in e){const s=this._enumSamplerParameter(t);void 0!==s&&(e.parameters[s]=e[t])}}_enumSamplerParameter(e){return he[e]}_resolveImage(e,t,s){e.id=`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const{createImages:r=!0}=s;r?e.image=this.glbParser.getImage(e):e.getImageAsync=(()=>this.glbParser?this.glbParser.getImageAsync(e):e.uri?new Promise(t=>{const r=new Image;r.crossOrigin="anonymous",r.onload=(()=>t(r)),r.src=x(e.uri,s.uri)}):null)}_resolveBufferView(e,t){if(e.id=`bufferView-${t}`,e.buffer=this.getBuffer(e.buffer),this.glbParser)e.data=this.glbParser.getBufferView(e);else{const t=e.byteOffset||0;e.data=new Uint8Array(e.buffer.data,t,e.byteLength)}}_resolveCamera(e){e.perspective,e.orthographic}_process_extension_KHR_lights_punctual(){const{gltf:e}=this,t=e.extensions&&e.extensions.KHR_lights_punctual;t&&(e.lights=t.lights),this._removeExtension("KHR_lights_punctual");for(const t of e.nodes||[]){const e=t.extensions&&t.extensions.KHR_lights_punctual;e&&(t.light=this._get("lights",e.light),delete t.extensions.KHR_lights_punctual)}delete e.lights}_removeExtension(e){this.gltf.extensionsRequired&&this._removeStringFromArray(this.gltf.extensionsRequired,e),this.gltf.extensionsUsed&&this._removeStringFromArray(this.gltf.extensionsUsed,e),this.gltf.extensions&&delete this.gltf.extensions[e]}_removeStringFromArray(e,t){let s=!0;for(;s;){const r=e.indexOf(t);r>-1?e.splice(r,1):s=!1}}}const ge={fetchLinkedResources:!0,fetch:f,decompress:!1,DracoLoader:null,postProcess:!0,createImages:!1,log:console};class de{async parse(e,t={}){if(t=Object.assign({},ge,t),this.parseSync(e,{...t,postProcess:!1,decompress:!1}),t.fetchLinkedResources&&await this._loadLinkedAssets(t),t.decompress&&this._decompressMeshes(t),t.postProcess){(new le).postProcess(this.gltf,this.glbParser,t)}return this.gltf}parseSync(e,t={}){if(t=Object.assign({},ge,t),e instanceof ArrayBuffer&&!ae.isGLB(e,t)){e=(new v).decode(e)}if("string"==typeof e&&(e=JSON.parse(e)),e instanceof ArrayBuffer?(this.glbParser=new ae,this.gltf=this.glbParser.parseSync(e).json,this.json=this.gltf):(this.glbParser=null,this.gltf=e,this.json=e),t.decompress&&this._decompressMeshes(t),t.postProcess){(new le).postProcess(this.gltf,this.glbParser,t)}return this.gltf}getApplicationData(e){return this.json[e]}getExtraData(e){return(this.json.extras||{})[e]}getExtension(e){const t=this.getUsedExtensions().find(t=>t===e),s=this.json.extensions||{};return t?s[e]||!0:null}getRequiredExtension(e){return this.getRequiredExtensions().find(t=>t===e)?this.getExtension(e):null}getRequiredExtensions(){return this.json.extensionsRequired||[]}getUsedExtensions(){return this.json.extensionsUsed||[]}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const s=this.gltf[e]&&this.gltf[e][t];return s||console.warn(`glTF file error: Could not find ${e}[${t}]`),s}async _loadLinkedAssets(e){return await Promise.all(this.gltf.buffers.map(t=>this._loadBuffer(t,e)))}async _loadBuffer(e,t){if(e.uri){const s=t.fetch||window.fetch,r=x(e.uri,t.uri),n=await s(r),i=await n.arrayBuffer();e.data=i,e.uri=null}}_decompressMeshes(e){if(e.DracoLoader&&e.decompress){for(const t of this.gltf.meshes||[])for(const s of t.primitives)if(this._decompressKhronosDracoPrimitive(s,e),this._decompressUberDracoPrimitive(s,e),!s.attributes||0===Object.keys(s.attributes).length)throw new Error("Empty glTF primitive: decompression failure?");this._removeExtension(n),this._removeExtension(i)}}_decompressKhronosDracoPrimitive(e,t){const s=e.extensions&&e.extensions[n];if(!s)return;delete e.extensions[n];const r=this._getBufferViewArray(s.bufferView),i=t.DracoLoader.parseSync(r);e.attributes=Z(i.attributes),i.indices&&(e.indices=ee(i.indices))}_decompressUberDracoPrimitive(e,t){const s=e.extensions&&e.extensions[i];if(!s)return;if(0!==e.mode)throw new Error(i);delete e.extensions[i];const r=this._getBufferViewArray(s.bufferView),n=t.DracoLoader.parseSync(r);e.attributes=n.attributes}_getBufferViewArray(e){const t=this.gltf.bufferViews[e];if(this.glbParser)return this.glbParser.getBufferView(t);const s=this.gltf.buffers[t.buffer].data,r=t.byteOffset||0;return new Uint8Array(s,r,t.byteLength)}_removeExtension(e){this.json.extensionsRequired&&this._removeStringFromArray(this.json.extensionsRequired,e),this.json.extensionsUsed&&this._removeStringFromArray(this.json.extensionsUsed,e),this.json.extensions&&delete this.json.extensions[e]}_removeStringFromArray(e,t){let s=!0;for(;s;){const r=e.indexOf(t);r>-1?e.splice(r,1):s=!1}}}const me={useGLTFParser:!0};var pe={name:"glTF",extension:["gltf","glb"],text:!0,binary:!0,parse:async function(e,t={}){if((t={...me,...t}).useGLTFParser)return(new de).parse(e,t);const{byteOffset:s=0}=t,r={};return await oe(r,e,s,t),r},parseSync:function(e,t={}){if((t={...me,...t}).useGLTFParser)return(new de).parseSync(e,t);const{byteOffset:s=0}=t,r={};return ie(r,e,s,t),r},defaultOptions:me};const ye=1179937895,be=1313821514,we=5130562,xe=!0;function je(e,t,s=0,r={}){const{magic:n=ye,version:i=2,json:o={},binary:u}=e,a=s;t&&(t.setUint32(s+0,n,xe),t.setUint32(s+4,i,xe),t.setUint32(s+8,0,xe));const c=s+8,f=s+=12;if(t&&(t.setUint32(s+0,0,xe),t.setUint32(s+4,be,xe)),s=function(e,t,s,r){return t=q(e,t,new _("utf8").encode(s))}(t,s+=8,JSON.stringify(o)),t){const e=s-f-8;t.setUint32(f+0,e,xe)}if(u){const e=s;if(t&&(t.setUint32(s+0,0,xe),t.setUint32(s+4,we,xe)),s=q(t,s+=8,u),t){const r=s-e-8;t.setUint32(e+0,r,xe)}}if(t){const e=s-a;t.setUint32(c,e,xe)}return s}function _e(e,t,s,r){return function(e,{firstBuffer:t=0}={}){if(e.buffers&&e.buffers.length>t)throw new Error("encodeGLTF: multiple buffers not yet implemented")}(e),je(e,t,s,r)}var ve={name:"glTF",extensions:["glb"],encodeSync:function(e,t={}){const{byteOffset:s=0}=t,r=_e(e,null,s,t),n=new ArrayBuffer(r);return _e(e,new DataView(n),s,t),n},binary:!0,defaultOptions:{useGLTFBuilder:!0}},Ae={name:"GLB",extension:["glb"],text:!0,binary:!0,parseSync:function(e,t){const{byteOffset:s=0}=t,r={};return R(r,e,s,t),r}};var Te={name:"GLB",extensions:["glb"],encodeSync:function(e,t){const{byteOffset:s=0}=t,r=je(e,null,s,t),n=new ArrayBuffer(r),i=new DataView(n);return je(e,i,s,t),n},binary:!0};const Be={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Le={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Ve={magFilter:10240,minFilter:10241,wrapS:10242,wrapT:10243};class Ee{postProcess(e,t={}){return this.gltf=e,this.json=e.json,this.buffers=e.buffers,this._resolveTree(e.json,t)}_resolveTree(e,t={}){return e.bufferViews&&(e.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(e.images=e.images.map((e,s)=>this._resolveImage(e,s,t))),e.samplers&&(e.samplers=e.samplers.map((e,t)=>this._resolveSampler(e,t))),e.textures&&(e.textures=e.textures.map((e,t)=>this._resolveTexture(e,t))),e.accessors&&(e.accessors=e.accessors.map((e,t)=>this._resolveAccessor(e,t))),e.materials&&(e.materials=e.materials.map((e,t)=>this._resolveMaterial(e,t))),e.meshes&&(e.meshes=e.meshes.map((e,t)=>this._resolveMesh(e,t))),e.nodes&&(e.nodes=e.nodes.map((e,t)=>this._resolveNode(e,t))),e.skins&&(e.skins=e.skins.map((e,t)=>this._resolveSkin(e,t))),e.scenes&&(e.scenes=e.scenes.map((e,t)=>this._resolveScene(e,t))),void 0!==e.scene&&(e.scene=e.scenes[this.json.scene]),e}getScene(e){return this._get("scenes",e)}getNode(e){return this._get("nodes",e)}getSkin(e){return this._get("skins",e)}getMesh(e){return this._get("meshes",e)}getMaterial(e){return this._get("materials",e)}getAccessor(e){return this._get("accessors",e)}getCamera(e){return null}getTexture(e){return this._get("textures",e)}getSampler(e){return this._get("samplers",e)}getImage(e){return this._get("images",e)}getBufferView(e){return this._get("bufferViews",e)}getBuffer(e){return this._get("buffers",e)}_get(e,t){if("object"==typeof t)return t;const s=this.json[e]&&this.json[e][t];return s||console.warn(`glTF file error: Could not find ${e}[${t}]`),s}_resolveScene(e,t){return(e={...e}).id=e.id||`scene-${t}`,e.nodes=(e.nodes||[]).map(e=>this.getNode(e)),e}_resolveNode(e,t){return(e={...e}).id=e.id||`node-${t}`,e.children&&(e.children=e.children.map(e=>this.getNode(e))),void 0!==e.mesh&&(e.mesh=this.getMesh(e.mesh)),void 0!==e.camera&&(e.camera=this.getCamera(e.camera)),void 0!==e.skin&&(e.skin=this.getSkin(e.skin)),e}_resolveSkin(e,t){return(e={...e}).id=e.id||`skin-${t}`,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return(e={...e}).id=e.id||`mesh-${t}`,e.primitives&&(e.primitives=e.primitives.map(e=>{const t=(e={...e}).attributes;e.attributes={};for(const s in t)e.attributes[s]=this.getAccessor(t[s]);return void 0!==e.indices&&(e.indices=this.getAccessor(e.indices)),void 0!==e.material&&(e.material=this.getMaterial(e.material)),e})),e}_resolveMaterial(e,t){if((e={...e}).id=e.id||`material-${t}`,e.normalTexture&&(e.normalTexture={...e.normalTexture},e.normalTexture.texture=this.getTexture(e.normalTexture.index)),e.occlusionTexture&&(e.occlustionTexture={...e.occlustionTexture},e.occlusionTexture.texture=this.getTexture(e.occlusionTexture.index)),e.emissiveTexture&&(e.emmisiveTexture={...e.emmisiveTexture},e.emissiveTexture.texture=this.getTexture(e.emissiveTexture.index)),e.pbrMetallicRoughness){e.pbrMetallicRoughness={...e.pbrMetallicRoughness};const t=e.pbrMetallicRoughness;t.baseColorTexture&&(t.baseColorTexture={...t.baseColorTexture},t.baseColorTexture.texture=this.getTexture(t.baseColorTexture.index)),t.metallicRoughnessTexture&&(t.metallicRoughnessTexture={...t.metallicRoughnessTexture},t.metallicRoughnessTexture.texture=this.getTexture(t.metallicRoughnessTexture.index))}return e}_resolveAccessor(e,t){var s,r;return(e={...e}).id=e.id||`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(s=e.componentType,Le[s]),e.components=(r=e.type,Be[r]),e.bytesPerElement=e.bytesPerComponent*e.components,e}_resolveTexture(e,t){return(e={...e}).id=e.id||`texture-${t}`,e.sampler=this.getSampler(e.sampler),e.source=this.getImage(e.source),e}_resolveSampler(e,t){(e={...e}).id=e.id||`sampler-${t}`,e.parameters={};for(const t in e){const s=this._enumSamplerParameter(t);void 0!==s&&(e.parameters[s]=e[t])}return e}_enumSamplerParameter(e){return Ve[e]}_resolveImage(e,t,s){if((e={...e}).id=e.id||`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),"uri"in e){const t=s.uri||this.gltf.baseUri;t&&(e.baseUri=t,e.fullUri=x(e.uri,t))}return e.getImageAsync=function(){return e.uri?new Promise(t=>{const s=new Image;s.crossOrigin="anonymous",s.onload=(()=>t(s)),s.src=e.fullUri||e.uri}):null},e}_resolveBufferView(e,t){(e={...e}).id=e.id||`bufferView-${t}`;const s=e.buffer;e.buffer=this.getBuffer(s);const r=this.buffers[s].arrayBuffer;let n=this.buffers[s].byteOffset||0;return"byteOffset"in e&&(n+=e.byteOffset),e.data=new Uint8Array(r,n,e.byteLength),e}_resolveCamera(e,t){return e.id=e.id||`camera-${t}`,e.perspective,e.orthographic,e}}function Ue(e,t){return(new Ee).postProcess(e,t)}function Se(e,t=Float32Array){if(0===e.length)return new Float32Array(0);if(!function e(t,s=Number.isFinite){let r=-1;for(;++r<t.length;){const n=t[r];if(Array.isArray(n)||ArrayBuffer.isView(n)){if(!e(n,s))return!1}else if(!s(n))return!1}return!0}(e))return null;const s=new t(function e(t,s=3){let r=0;let n=0;let i=-1;for(;++i<t.length;){const s=t[i];Array.isArray(s)||ArrayBuffer.isView(s)?r+=e(s):n++}return r+(0===r&&n<s?s:n)}(e));return function(e,t,s=3){(function e(t,s,r,n){let i=-1,o=0;for(;++i<t.length;){const u=t[i];Array.isArray(u)||ArrayBuffer.isView(u)?n=e(u,s,r,n):o<r&&(s[n++]=u,o++)}return o>0&&o<r&&(s[n++]=0),n})(e,t,s,0)}(e,s),s}function Oe(e,t,s={}){const{flattenArrays:r=!1}=s;let n=e;if("string"==typeof n&&0===n.indexOf("#/"))return`#${n}`;if(Array.isArray(n)){const e=r&&Se(n);if(!e)return n.map(e=>Oe(e,t,s));n=e}if(ArrayBuffer.isView(n)&&t){if(t.isImage(n)){return`#/images/${t.addImage(n)}`}return`#/accessors/${t.addBuffer(n)}`}if(null!==n&&"object"==typeof n){const e={};for(const r in n)e[r]=Oe(n[r],t,s);return e}return n}class Re{constructor(e={}){this.byteLength=0,this.json={buffers:[{byteLength:0}],bufferViews:[],accessors:[],images:[],meshes:[]},this.sourceBuffers=[],this.log=e.log||console}getByteLength(){return this.byteLength}isImage(e){return function(e,t){if(t){const{test:s}=$(t);return s(F(e))}return Boolean(D(e))}(e)}encodeSync(e={}){return this.encodeAsGLB(e)}encodeAsGLB(e={}){this._packBinaryChunk(),e.magic&&console.warn("Custom glTF magic number no longer supported");const t={version:2,json:this.json,binary:this.arrayBuffer},s=je(t,null,0,e),r=new ArrayBuffer(s);return je(t,new DataView(r),0,e),r}addApplicationData(e,t,s={}){const r=s.packTypedArrays?Oe(t,this,s):t;return this.json[e]=r,this}addBuffer(e,t={size:3}){const s=this.addBufferView(e),r={size:t.size,componentType:H(e),count:Math.round(e.length/t.size)};return this.addAccessor(s,Object.assign(r,t))}addBufferView(e){const t=e.byteLength||e.length;return this.json.bufferViews.push({buffer:0,byteOffset:this.byteLength,byteLength:t}),this.byteLength+=G(t),this.sourceBuffers.push(e),this.json.bufferViews.length-1}addAccessor(e,t){return this.json.accessors.push({bufferView:e,type:K(t.size),componentType:t.componentType,count:t.count}),this.json.accessors.length-1}_pack(){return this._packBinaryChunk(),{arrayBuffer:this.arrayBuffer,json:this.json}}_packBinaryChunk(){if(this.arrayBuffer)return;const e=this.byteLength,t=new ArrayBuffer(e),s=new Uint8Array(t);let r=0;for(let e=0;e<this.sourceBuffers.length;e++){r=N(this.sourceBuffers[e],s,r)}this.json.buffers[0].byteLength=e,this.arrayBuffer=t,this.sourceBuffers=[]}_getInternalCounts(){return{buffers:this.json.buffers.length,bufferViews:this.json.bufferViews.length,accessors:this.json.accessors.length,images:this.json.images.length}}}class ke extends Re{constructor(e={}){super(e),this.DracoWriter=e.DracoWriter,this.DracoLoader=e.DracoLoader}addApplicationData(e,t,s={}){const r=s.packTypedArrays?Oe(t,this,s):t;return this.json[e]=r,this}addExtraData(e,t,s={}){const r=s.packedTypedArrays?Oe(t,this,s):t;return this.json.extras=this.json.extras||{},this.json.extras[e]=r,this}addExtension(e,t,s={}){h(t);const r=s.packTypedArrays?Oe(t,this,s):t;return this.json.extensions=this.json.extensions||{},this.json.extensions[e]=r,this.registerUsedExtension(e),this}addRequiredExtension(e,t,s={}){h(t);const r=s.packTypedArrays?Oe(t,this,s):t;return this.addExtension(e,r),this.registerRequiredExtension(e),this}registerUsedExtension(e){this.json.extensionsUsed=this.json.extensionsUsed||[],this.json.extensionsUsed.find(t=>t===e)||this.json.extensionsUsed.push(e)}registerRequiredExtension(e){this.registerUsedExtension(e),this.json.extensionsRequired=this.json.extensionsRequired||[],this.json.extensionsRequired.find(t=>t===e)||this.json.extensionsRequired.push(e)}addMesh(e,t,s=4){const r={primitives:[{attributes:this._addAttributes(e),indices:t,mode:s}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(r),this.json.meshes.length-1}addPointCloud(e){const t={primitives:[{attributes:this._addAttributes(e),mode:0}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(t),this.json.meshes.length-1}addCompressedMesh(e,t,s=4){if(!this.DracoWriter||!this.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");this.registerRequiredExtension(n);const r=this.DracoWriter.encodeSync({attributes:e}),i=this.DracoLoader.parseSync({attributes:e}),o=this._addFauxAttributes(i.attributes),u=this.addBufferView(r),a={primitives:[{attributes:o,mode:s,extensions:{[n]:{bufferView:u,attributes:o}}}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(a),this.json.meshes.length-1}addCompressedPointCloud(e){if(!this.DracoWriter||!this.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");e.mode=0;const t=this.DracoWriter.encodeSync(e,{pointcloud:!0}),s=this.addBufferView(t),r={primitives:[{attributes:{},mode:0,extensions:{[i]:{bufferView:s}}}]};return this.registerRequiredExtension(i),this.json.meshes=this.json.meshes||[],this.json.meshes.push(r),this.json.meshes.length-1}addImage(e){const t=this.addBufferView(e),s=I(e)||{};if(s){const{mimeType:e,width:r,height:n}=s;this.json.images.push({bufferView:t,mimeType:e,width:r,height:n})}else this.json.images.push({bufferView:t});return this.json.images.length-1}}s.d(t,"KHR_DRACO_MESH_COMPRESSION",function(){return n}),s.d(t,"UBER_POINT_CLOUD_EXTENSION",function(){return i}),s.d(t,"GLTFLoader",function(){return pe}),s.d(t,"GLTFWriter",function(){return ve}),s.d(t,"GLBLoader",function(){return Ae}),s.d(t,"GLBWriter",function(){return Te}),s.d(t,"GLTFScenegraph",function(){return Y}),s.d(t,"postProcessGLTF",function(){return Ue}),s.d(t,"parseGLTFSync",function(){return ie}),s.d(t,"encodeGLTFSync",function(){return _e}),s.d(t,"packBinaryJson",function(){return Oe}),s.d(t,"unpackBinaryJson",function(){return ue}),s.d(t,"GLBParser",function(){return ae}),s.d(t,"GLBBuilder",function(){return Re}),s.d(t,"GLTFParser",function(){return de}),s.d(t,"GLTFBuilder",function(){return ke})}])});

@@ -8,2 +8,14 @@ "use strict";

});
Object.defineProperty(exports, "KHR_DRACO_MESH_COMPRESSION", {
enumerable: true,
get: function get() {
return _gltfConstants.KHR_DRACO_MESH_COMPRESSION;
}
});
Object.defineProperty(exports, "UBER_POINT_CLOUD_EXTENSION", {
enumerable: true,
get: function get() {
return _gltfConstants.UBER_POINT_CLOUD_EXTENSION;
}
});
Object.defineProperty(exports, "GLTFLoader", {

@@ -21,14 +33,50 @@ enumerable: true,

});
Object.defineProperty(exports, "GLTFParser", {
Object.defineProperty(exports, "GLBLoader", {
enumerable: true,
get: function get() {
return _gltfParser["default"];
return _glbLoader["default"];
}
});
Object.defineProperty(exports, "GLTFBuilder", {
Object.defineProperty(exports, "GLBWriter", {
enumerable: true,
get: function get() {
return _gltfBuilder["default"];
return _glbWriter["default"];
}
});
Object.defineProperty(exports, "GLTFScenegraph", {
enumerable: true,
get: function get() {
return _gltfScenegraph["default"];
}
});
Object.defineProperty(exports, "postProcessGLTF", {
enumerable: true,
get: function get() {
return _postProcessGltf["default"];
}
});
Object.defineProperty(exports, "parseGLTFSync", {
enumerable: true,
get: function get() {
return _parseGltf.parseGLTFSync;
}
});
Object.defineProperty(exports, "encodeGLTFSync", {
enumerable: true,
get: function get() {
return _encodeGltf.encodeGLTFSync;
}
});
Object.defineProperty(exports, "packBinaryJson", {
enumerable: true,
get: function get() {
return _packBinaryJson["default"];
}
});
Object.defineProperty(exports, "unpackBinaryJson", {
enumerable: true,
get: function get() {
return _unpackBinaryJson["default"];
}
});
Object.defineProperty(exports, "GLBParser", {

@@ -46,36 +94,44 @@ enumerable: true,

});
Object.defineProperty(exports, "KHR_DRACO_MESH_COMPRESSION", {
Object.defineProperty(exports, "GLTFParser", {
enumerable: true,
get: function get() {
return _gltfConstants.KHR_DRACO_MESH_COMPRESSION;
return _gltfParser["default"];
}
});
Object.defineProperty(exports, "UBER_POINT_CLOUD_EXTENSION", {
Object.defineProperty(exports, "GLTFBuilder", {
enumerable: true,
get: function get() {
return _gltfConstants.UBER_POINT_CLOUD_EXTENSION;
return _gltfBuilder["default"];
}
});
Object.defineProperty(exports, "_parseGLBSync", {
enumerable: true,
get: function get() {
return _parseGlb.parseGLBSync;
}
});
var _gltfLoader = _interopRequireDefault(require("./gltf/gltf-loader"));
var _gltfConstants = require("./lib/gltf-constants");
var _gltfWriter = _interopRequireDefault(require("./gltf/gltf-writer"));
var _gltfLoader = _interopRequireDefault(require("./gltf-loader"));
var _gltfParser = _interopRequireDefault(require("./gltf/gltf-parser"));
var _gltfWriter = _interopRequireDefault(require("./gltf-writer"));
var _gltfBuilder = _interopRequireDefault(require("./gltf/gltf-builder"));
var _glbLoader = _interopRequireDefault(require("./glb-loader"));
var _glbParser = _interopRequireDefault(require("./glb/glb-parser"));
var _glbWriter = _interopRequireDefault(require("./glb-writer"));
var _glbBuilder = _interopRequireDefault(require("./glb/glb-builder"));
var _gltfScenegraph = _interopRequireDefault(require("./lib/gltf-scenegraph"));
var _gltfConstants = require("./gltf/gltf-constants");
var _postProcessGltf = _interopRequireDefault(require("./lib/post-process-gltf"));
var _parseGlb = require("./glb/parse-glb");
var _parseGltf = require("./lib/parse-gltf");
var _encodeGltf = require("./lib/encode-gltf");
var _packBinaryJson = _interopRequireDefault(require("./lib/deprecated/packed-json/pack-binary-json"));
var _unpackBinaryJson = _interopRequireDefault(require("./lib/deprecated/packed-json/unpack-binary-json"));
var _glbParser = _interopRequireDefault(require("./lib/deprecated/glb-parser"));
var _glbBuilder = _interopRequireDefault(require("./lib/deprecated/glb-builder"));
var _gltfParser = _interopRequireDefault(require("./lib/deprecated/gltf-parser"));
var _gltfBuilder = _interopRequireDefault(require("./lib/deprecated/gltf-builder"));
//# sourceMappingURL=index.js.map

@@ -1,9 +0,16 @@

export { default as GLTFLoader } from './gltf/gltf-loader';
export { default as GLTFWriter } from './gltf/gltf-writer';
export { default as GLTFParser } from './gltf/gltf-parser';
export { default as GLTFBuilder } from './gltf/gltf-builder';
export { default as GLBParser } from './glb/glb-parser';
export { default as GLBBuilder } from './glb/glb-builder';
export { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from './gltf/gltf-constants';
export { parseGLBSync as _parseGLBSync } from './glb/parse-glb';
export { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from './lib/gltf-constants';
export { default as GLTFLoader } from './gltf-loader';
export { default as GLTFWriter } from './gltf-writer';
export { default as GLBLoader } from './glb-loader';
export { default as GLBWriter } from './glb-writer';
export { default as GLTFScenegraph } from './lib/gltf-scenegraph';
export { default as postProcessGLTF } from './lib/post-process-gltf';
export { parseGLTFSync } from './lib/parse-gltf';
export { encodeGLTFSync } from './lib/encode-gltf';
export { default as packBinaryJson } from './lib/deprecated/packed-json/pack-binary-json';
export { default as unpackBinaryJson } from './lib/deprecated/packed-json/unpack-binary-json';
export { default as GLBParser } from './lib/deprecated/glb-parser';
export { default as GLBBuilder } from './lib/deprecated/glb-builder';
export { default as GLTFParser } from './lib/deprecated/gltf-parser';
export { default as GLTFBuilder } from './lib/deprecated/gltf-builder';
//# sourceMappingURL=index.js.map

@@ -1,9 +0,16 @@

export { default as GLTFLoader } from './gltf/gltf-loader';
export { default as GLTFWriter } from './gltf/gltf-writer';
export { default as GLTFParser } from './gltf/gltf-parser';
export { default as GLTFBuilder } from './gltf/gltf-builder';
export { default as GLBParser } from './glb/glb-parser';
export { default as GLBBuilder } from './glb/glb-builder';
export { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from './gltf/gltf-constants';
export { parseGLBSync as _parseGLBSync } from './glb/parse-glb';
export { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from './lib/gltf-constants';
export { default as GLTFLoader } from './gltf-loader';
export { default as GLTFWriter } from './gltf-writer';
export { default as GLBLoader } from './glb-loader';
export { default as GLBWriter } from './glb-writer';
export { default as GLTFScenegraph } from './lib/gltf-scenegraph';
export { default as postProcessGLTF } from './lib/post-process-gltf';
export { parseGLTFSync } from './lib/parse-gltf';
export { encodeGLTFSync } from './lib/encode-gltf';
export { default as packBinaryJson } from './lib/deprecated/packed-json/pack-binary-json';
export { default as unpackBinaryJson } from './lib/deprecated/packed-json/unpack-binary-json';
export { default as GLBParser } from './lib/deprecated/glb-parser';
export { default as GLBBuilder } from './lib/deprecated/glb-builder';
export { default as GLTFParser } from './lib/deprecated/gltf-parser';
export { default as GLTFBuilder } from './lib/deprecated/gltf-builder';
//# sourceMappingURL=index.js.map
{
"name": "@loaders.gl/gltf",
"version": "1.0.3",
"version": "1.1.0-alpha.1",
"description": "Framework-independent loader for the glTF format",

@@ -41,5 +41,5 @@ "license": "MIT",

"dependencies": {
"@loaders.gl/core": "1.0.3",
"@loaders.gl/images": "1.0.3"
"@loaders.gl/core": "1.1.0-alpha.1",
"@loaders.gl/images": "1.1.0-alpha.1"
}
}

@@ -6,1 +6,3 @@ # @loaders.gl/gltf

This module contains loader and writers for the glTF format.
For documentation please visit the [website](https://loaders.gl).

@@ -0,15 +1,28 @@

// Constants
export {KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION} from './lib/gltf-constants';
// glTF loader/writer definition objects
export {default as GLTFLoader} from './gltf/gltf-loader';
export {default as GLTFWriter} from './gltf/gltf-writer';
export {default as GLTFLoader} from './gltf-loader';
export {default as GLTFWriter} from './gltf-writer';
// glTF Parser & Builder
export {default as GLTFParser} from './gltf/gltf-parser';
export {default as GLTFBuilder} from './gltf/gltf-builder';
// GLB Loader & Writer (for custom formats that want to leverage the GLB binary "envelope")
export {default as GLBLoader} from './glb-loader';
export {default as GLBWriter} from './glb-writer';
// GLB Parser & Builder (for custom formats that want to leverage the GLB binary "envelope")
export {default as GLBParser} from './glb/glb-parser';
export {default as GLBBuilder} from './glb/glb-builder';
// glTF Data Access Helper Class
export {default as GLTFScenegraph} from './lib/gltf-scenegraph';
export {default as postProcessGLTF} from './lib/post-process-gltf';
export {KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION} from './gltf/gltf-constants';
// For 3D Tiles
export {parseGLTFSync} from './lib/parse-gltf';
export {encodeGLTFSync} from './lib/encode-gltf';
export {parseGLBSync as _parseGLBSync} from './glb/parse-glb';
// DEPRECATED
export {default as packBinaryJson} from './lib/deprecated/packed-json/pack-binary-json';
export {default as unpackBinaryJson} from './lib/deprecated/packed-json/unpack-binary-json';
export {default as GLBParser} from './lib/deprecated/glb-parser';
export {default as GLBBuilder} from './lib/deprecated/glb-builder';
export {default as GLTFParser} from './lib/deprecated/gltf-parser';
export {default as GLTFBuilder} from './lib/deprecated/gltf-builder';

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

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