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.3.0 to 1.3.1

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 s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(window,function(){return function(e){var t={};function r(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,s){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},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 s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(s,n,function(t){return e[t]}.bind(null,n));return s},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=13)}([function(e,t,r){"use strict";(function(e,s){r.d(t,"b",function(){return n}),r.d(t,"a",function(){return o}),r.d(t,"c",function(){return a});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!==s&&s,document:"undefined"!=typeof document&&document},o=i.global||i.self||i.window,u=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/),a=u&&parseFloat(u[1])||0}).call(this,r(14),r(9))},,,,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 s=r(15),n="undefined"==typeof window?t:window;n.loaders=n.loaders||{},e.exports=Object.assign(n.loaders,s)}).call(this,r(9))},function(e,t){var r,s,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(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{s="function"==typeof clearTimeout?clearTimeout:o}catch(e){s=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(s===clearTimeout)return clearTimeout(e);if((s===o||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}n.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)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=y,n.addListener=y,n.once=y,n.off=y,n.removeListener=y,n.removeAllListeners=y,n.emit=y,n.prependListener=y,n.prependOnceListener=y,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,r){"use strict";r.r(t);const s="KHR_draco_mesh_compression",n="UBER_draco_point_cloud_compression",i="KHR_lights_punctual";const o=e=>"undefined"!=typeof Response&&e instanceof Response||e.arrayBuffer&&e.text&&e.json,u=e=>(e=>"undefined"!=typeof File&&e instanceof File)(e)||(e=>"undefined"!=typeof Blob&&e instanceof Blob)(e);let a="";const f={};function c(e){for(const t in f)if(e.startsWith(t)){const r=f[t];return e.replace(t,r)}return e+=a}function h(e,t){if(!e)throw new Error(t||"loader assertion failed.")}class l{constructor(e){this._fileOrBlob=e,this.bodyUsed=!1}get headers(){return new Headers({"Content-Length":this._fileOrBlob.size,"Content-Type":this._fileOrBlob.type})}get ok(){return!0}get status(){return 200}url(){return this._fileOrBlob.name||""}async arrayBuffer(){const{reader:e,promise:t}=this._getFileReader();return e.readAsArrayBuffer(this._fileOrBlob),t}async text(){const{reader:e,promise:t}=this._getFileReader();return e.readAsText(this._fileOrBlob),t}async json(){const e=await this.text();return JSON.parse(e)}_getFileReader(){let e;h(!this.bodyUsed),this.bodyUsed=!0;const t=new Promise((t,r)=>{try{(e=new FileReader).onerror=e=>r(new Error(e)),e.onabort=()=>r(new Error("Read aborted.")),e.onload=()=>t(e.result)}catch(e){r(e)}});return{reader:e,promise:t}}}function g(e,t){return Promise.resolve(new l(e,t))}async function d(e,t){return u(e)?g(e,t):(e=c(e),fetch(e,t))}function y(e,t){if(!e)throw new Error(t||"gltf/glb assertion failed.")}const m=["SCALAR","VEC2","VEC3","VEC4"],b=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126]]),p={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},w={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},x={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function _(e){return m[e-1]||m[0]}function T(e){const t=b.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function A(e,t){const r=x[e.componentType],s=p[e.type],n=w[e.componentType],i=e.count*s,o=e.count*s*n;return y(o>=0&&o<=t.byteLength),{ArrayType:r,length:i,byteLength:o}}function j(e,t){return e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:")?e:t.substr(0,t.lastIndexOf("/")+1)+e}const E=!1,v=!0,B=new Map([["image/png",{test:function(e){return e.byteLength>=24&&2303741511===e.getUint32(0,E)},getSize:function(e){return{width:e.getUint32(16,E),height:e.getUint32(20,E)}}}],["image/jpeg",{test:function(e){return e.byteLength>=3&&65496===e.getUint16(0,E)&&255===e.getUint8(2,E)},getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,E))return null;const{tableMarkers:t,sofMarkers:r}=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<e.byteLength;){const n=e.getUint16(s,E);if(r.has(n))return{height:e.getUint16(s+5,E),width:e.getUint16(s+7,E)};if(!t.has(n))return null;s+=2,s+=e.getUint16(s,E)}return null}}],["image/gif",{test:function(e){return e.byteLength>=10&&1195984440===e.getUint32(0,E)},getSize:function(e){return{width:e.getUint16(6,v),height:e.getUint16(8,v)}}}],["image/bmp",{test:function(e){return e.byteLength>=2&&16973===e.getUint16(0,E)},getSize:function(e){return{width:e.getUint32(18,v),height:e.getUint32(22,v)}}}]]);const R=`Invalid MIME type. Supported MIME types are: ${Array.from(B.keys()).join(", ")}`;function L(e){const t=V(e);for(const[e,{test:r}]of B.entries())if(r(t))return e;return null}function U(e,t=null){const r=function(e,t=null){t=t||L(e);const{getSize:r}=O(t),s=r(V(e));if(!s)throw new Error(`invalid image data for type: ${t}`);return s}(e,t=t||L(e));return r.mimeType=t,r}function O(e){const t=B.get(e);if(!t)throw new Error(R);return t}function V(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}function S(e){return e+3&-4}function k(e,t,r){let s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{const t=e.byteOffset,r=e.byteLength;s=new Uint8Array(e.buffer,t,r)}return t.set(s,r),r+S(s.byteLength)}class C{constructor(e){if(e instanceof C)return e;e||(e={json:{version:2,buffers:[]},buffers:[]}),this.gltf=e,y(this.gltf.json)}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),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||[]}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 r=this.json[e]&&this.json[e][t];if(!r)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return r}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,r=this.gltf.buffers[t];y(r);const s=e.byteOffset||0+r.byteOffset;return new Uint8Array(r.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBuffer(e.bufferView),r=this.getBuffer(t.buffer).data,{ArrayType:s,length:n}=A(e,t);return new s(r,t.byteOffset+e.byteOffset,n)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBuffer(e.bufferView),r=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(r,s,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 y(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),this}addRequiredExtension(e,t){return y(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,r){(e.extensions||{})[t]=r}addMesh(e,t,r=4){const s={primitives:[{attributes:this._addAttributes(e),indices:t,mode:r}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),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||L(e);const r={bufferView:this.addBufferView(e),mimeType:t};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e){const t=e.byteLength;y(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=S(t),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const r={bufferView:e,type:_(t.size),componentType:t.componentType,count:t.count};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(r),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const r=this.addBufferView(e),s={size:t.size,componentType:T(e),count:Math.round(e.length/t.size)};return this.addAccessor(r,Object.assign(s,t))}createBinaryChunk(){if(this.arrayBuffer)return;const e=this.byteLength,t=new ArrayBuffer(e),r=new Uint8Array(t);let s=0;for(let e=0;e<this.sourceBuffers.length;e++){s=k(this.sourceBuffers[e],r,s)}this.json.buffers[0].byteLength=e,this.arrayBuffer=t,this.sourceBuffers=[]}_removeStringFromArray(e,t){let r=!0;for(;r;){const s=e.indexOf(t);s>-1?e.splice(s,1):r=!1}}}function P(e){const t={};for(const r in e){const s=e[r];if("indices"!==r){const e=M(s);t[r]=e}}return t}function M(e,t){const{buffer:r,size:s,count:n}=function(e,t){let r=e,s=1,n=0;e&&e.value&&(r=e.value,s=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)),n=r.length/s);return{buffer:r,size:s,count:n}}(e);return{value:r,size:s,bufferView:null,byteOffset:0,count:n,type:_(s),componentType:T(r)}}function I(e){if(!e)return!1;return Array.isArray(e)&&(e=e[0]),e.parseTextSync||e.parseSync||e.parse||e.loadAndParse||e.parseStream||e.parseInBatches||e.worker}function D(e){let t;return h(I(e)),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),e.extension&&(e.extensions=e.extensions||e.extension,delete e.extension),Array.isArray(e.extensions)||(e.extensions=[e.extensions]),h(e.extensions&&e.extensions.length>0&&e.extensions[0]),e.parseTextSync&&(e.text=!0),e.text||(e.binary=!0),e}let F={};const $=/[^.]+$/;function N(e,t="",r=null,{nothrow:s=!1}={}){if(t=t||"",e&&!Array.isArray(e)){const t=e;return D(t),t}(function(e){for(const t of e)D(t)})(e=e||Object.values(F)),t=t.replace(/\?.*/,"");let n=null;if(!(n=(n=n||function(e,t){const r=t.match($),s=r&&r[0];return s&&function(e,t){t=t.toLowerCase();for(const r of e)for(const e of r.extensions)if(e.toLowerCase()===t)return r;return null}(e,s)}(e,t))||function(e,t){if(!t)return null;for(const r of e)if("string"==typeof t){if(W(t,r))return r}else if(ArrayBuffer.isView(t)){if(q(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer){if(q(t,0,r))return r}return null}(e,r))){if(s)return null;throw new Error(`No valid loader found for ${t}`)}return n}function W(e,t){return t.testText&&t.testText(e)}function q(e,t,r){switch(Array.isArray(r.test)?"array":typeof r.test){case"function":return r.test(e,r);case"string":case"array":return(Array.isArray(r.test)?r.test:[r.test]).some(r=>{return r===function(e,t,r){if(e.byteLength<=t+r)return"";const s=new DataView(e);let n="";for(let e=0;e<r;e++)n+=String.fromCharCode(s.getUint8(t+e));return n}(e,t,r.length)});default:return!1}}class G{log(){}info(){}warn(){}error(){}}function X(e,t){return null===(e=Object.assign({},t&&t.DEFAULT_OPTIONS,t&&t.defaultOptions,t&&t.options,e,{dataType:"arraybuffer"})).log&&(e.log=new G),"log"in e||(e.log=console),e}var z=r(0);const J="Cannot convert supplied data type";function H(e,t){if(t.text&&"string"==typeof e)return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){const r=e.buffer||e;if(t.text&&!t.binary){return new TextDecoder("utf8").decode(r)}return r}throw new Error(J)}async function K(e,t){const r=(e=await e)instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||r)return H(e,t);if(u(e)&&(e=await g(e)),o(e))return await async function(e){if(!e.ok){let t=`fetch failed ${e.status} `;try{t+=await e.text()}catch(e){}throw new Error(t)}}(e),t.binary?await e.arrayBuffer():await e.text();throw new Error(J)}var Q=r(4);function Y(e){if(Q.toArrayBuffer&&(e=Object(Q.toArrayBuffer)(e)),e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}return h(!1)}function Z(e,t=!0,r=[]){if(e){if(e instanceof ArrayBuffer)r.push(e);else if(e.buffer&&e.buffer instanceof ArrayBuffer)r.push(e.buffer);else if(t&&"object"==typeof e)for(const s in e)Z(e[s],t,r)}else;return r}const ee=new Map;let te=0;function re({data:e,resolve:t}){t(e)}class se{constructor({source:e,name:t=`web-worker-${te++}`,onMessage:r}){const s=function(e){if(h("string"==typeof e,"worker source"),e.startsWith("url(")&&e.endsWith(")"))return e.match(/^url\((.*)\)$/)[1];let t=ee.get(e);if(!t){const r=new Blob([e],{type:"application/javascript"});t=URL.createObjectURL(r),ee.set(e,t)}return t}(e);this.worker=new Worker(s,{name:t}),this.name=t,this.onMessage=r||re}async process(e){return new Promise((t,r)=>{this.worker.onmessage=e=>this.onMessage({worker:this.worker,data:e.data,resolve:t,reject:r}),this.worker.onerror=e=>r(e);const s=Z(e);this.worker.postMessage(e,s)})}destroy(){this.worker.terminate(),this.worker=null}}class ne{constructor({source:e,name:t="unnamed",maxConcurrency:r=1,onMessage:s,onDebug:n=(()=>{})}){this.source=e,this.name=t,this.maxConcurrency=r,this.onMessage=s,this.onDebug=n,this.jobQueue=[],this.idleQueue=[],this.count=0,this.isDestroyed=!1}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}async process(e,t){return new Promise((r,s)=>{this.jobQueue.push({data:e,jobName:t,resolve:r,reject:s}),this._startQueuedJob()})}_startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();this.onDebug({message:"processing",worker:e.name,job:t.jobName,backlog:this.jobQueue.length}),e.process(t.data).then(e=>t.resolve(e)).catch(e=>t.reject(e)).then(()=>this._onWorkerDone(e))}_onWorkerDone(e){this.isDestroyed?e.destroy():(this.idleQueue.push(e),this._startQueuedJob())}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift();if(this.count<this.maxConcurrency){this.count++;const e=`${this.name.toLowerCase()}-worker-${this.count}-of-${this.maxConcurrency}`;return new se({source:this.source,onMessage:this.onMessage,name:e})}return null}}const ie=5;class oe{constructor({maxConcurrency:e=ie,onMessage:t,onDebug:r=(()=>{})}){this.maxConcurrency=e,this.onMessage=t,this.onDebug=r,this.workerPools=new Map}setProps(e){"maxConcurrency"in e&&(this.maxConcurrency=e.maxConcurrency),"onDebug"in e&&(this.onDebug=e.onDebug)}destroy(){this.workerPools.forEach(e=>e.destroy())}async process(e,t,r){return this._getWorkerPool(e,t).process(r)}_getWorkerPool(e,t){let r=this.workerPools.get(t);return r||(r=new ne({source:e,name:t,onMessage:this.onMessage,maxConcurrency:this.maxConcurrency,onDebug:this.onDebug}),this.workerPools.set(t,r)),r}}let ue=null;async function ae({worker:e,data:t,resolve:r,reject:s}){switch(t.type){case"done":r(t.result);break;case"process":try{const r=await ce(t.arraybuffer,t.options,t.url);e.postMessage({type:"process-done",id:t.id,result:r},Z(r))}catch(r){e.postMessage({type:"process-error",id:t.id,message:r.message})}break;case"error":s(t.message)}}function fe(e,t,r,s={}){const n=function(e={}){const t={};return e.maxConcurrency&&(t.maxConcurrency=e.maxConcurrency),e.onDebug&&(t.onDebug=e.onDebug),(ue=ue||new oe({onMessage:ae})).setProps(t),ue}(s);return s=JSON.parse(JSON.stringify(s)),n.process(e,`loaders.gl-${t}`,{arraybuffer:Y(r),options:s,source:"loaders.gl",type:"process"})}async function ce(e,t,r,s){!t||Array.isArray(t)||I(t)||(s=r,r=t,t=null),r=r||{};const n=function(e,t){return o(e)?t=t||e.url:u(t)&&(t=t.name),"string"==typeof t?t.replace(/\?.*/,""):t}(e,s),i=N(t,n,e);return r=X(r,i),await async function(e,t,r,s){return e=await K(e,t),t.parseTextSync&&"string"==typeof e?(r.dataType="text",t.parseTextSync(e,r,s,t)):t.parse?await t.parse(e,r,s,t):t.parseSync?t.parseSync(e,r,s,t):t.worker?await fe(t.worker,t.name,e,r):h(!1)}(e,i,r,n)}async function he(e,t,r){const n=t.getObjectExtension(e,s),i=t.getTypedArrayForBufferView(n.bufferView),o=new Uint8Array(i.buffer).subarray(i.byteOffset),u=new Uint8Array(o),a=await ce(u);e.attributes=P(a.attributes),a.indices&&(e.indices=M(a.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("Empty glTF primitive detected: Draco decompression failure?")}(e)}function le(e,t,r=4,n={}){if(!n.DracoWriter||!n.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");const i=n.DracoWriter.encodeSync({attributes:e}),o=n.DracoLoader.parseSync({attributes:e}),u=n._addFauxAttributes(o.attributes),a=n.addBufferView(i);return{primitives:[{attributes:u,mode:r,extensions:{[s]:{bufferView:a,attributes:u}}}]}}const ge={KHR_draco_mesh_compression:class{static get name(){return s}static async decode(e,t={}){if(!t.decompress)return;const r=new C(e),n=[];for(const e of function*(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}(r))r.getObjectExtension(e,s)&&n.push(he(e,r,t));await Promise.all(n),r.removeExtension(s)}static decodeSync(e,t){if(!t.decompress)return;if(new C(e).getRequiredExtension(s))throw new Error("Cannot synchronously decode Draco")}static encode(e,t={}){const r=new C(e);for(const e of r.json.meshes||[])le(e,t),r.addRequiredExtension(s)}},KHR_lights_punctual:class{static get name(){return i}static decode(e,t){const r=new C(e),s=r.getExtension(i);s&&(r.json.lights=s.lights,r.removeExtension(i));for(const e of r.nodes||[]){const t=e.extensions&&e.extensions.KHR_lights_punctual;t&&(e.light=r._get("lights",t.light),delete e.extensions.KHR_lights_punctual)}}static encode(e,t){const r=new C(e),{json:s}=r;if(s.lights){const e=r.addExtensions(i);y(!e.lights),e.lights=s.lights,delete s.lights}if(r.json.lights){for(const e of r.json.lights){const t=e.node;r.addObjectExtension(t,i,e)}delete r.json.lights}}}};function de(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const ye=1735152710,me=12,be=8,pe=1313821514,we=5130562,xe=!0;function _e(e,t=0,r={}){const s=new DataView(e),{magic:n=ye}=r,i=s.getUint32(t,!1);return i===n||i===ye}function Te(e,t,r=0,s={}){const n=new DataView(t);e.type=function(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}(n,r+0),e.version=n.getUint32(r+4,xe);const i=n.getUint32(r+8,xe);return e.header={byteOffset:r,byteLength:i},"glTF"!==e.type&&console.warn(`Invalid GLB magic string ${e.type}`),de(2===e.version,`Invalid GLB version ${e.version}. Only .glb v2 supported`),de(e.header.byteLength>me+be),e.json={},e.hasBinChunk=!1,e.binChunks=[],function(e,t,r,s){for(;r+8<=e.header.byteLength;){const n=t.getUint32(r+0,xe),i=t.getUint32(r+4,xe);switch(r+=be,i){case pe:Ae(e,t,r,n,s);break;case we:je(e,t,r,n,s)}switch(i){case 0:s.strict||Ae(e,t,r,n,s);break;case 1:s.strict||je(e,t,r,n,s)}r+=S(n)}}(e,n,r+12,s),function(e){e.byteOffset=e.header.byteOffset,e.magic=e.header.magic,e.version=e.header.version,e.byteLength=e.header.byteLength,e.hasBinChunk=e.binChunks.length>=1,e.binChunkByteOffset=e.header.hasBinChunk?e.binChunks[0].byteOffset:0,e.binChunkLength=e.header.hasBinChunk?e.binChunks[0].byteLength:0}(e),r+e.header.byteLength}function Ae(e,t,r,s,n){const i=new Uint8Array(t.buffer,r,s),o=new TextDecoder("utf8").decode(i);e.json=JSON.parse(o)}function je(e,t,r,s,n){e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:r,byteLength:s,arrayBuffer:t.buffer})}const Ee={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},ve={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Be={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},Re={magFilter:Be.TEXTURE_MAG_FILTER,minFilter:Be.TEXTURE_MIN_FILTER,wrapS:Be.TEXTURE_WRAP_S,wrapT:Be.TEXTURE_WRAP_T},Le={[Be.TEXTURE_MAG_FILTER]:Be.LINEAR,[Be.TEXTURE_MIN_FILTER]:Be.NEAREST_MIPMAP_LINEAR,[Be.TEXTURE_WRAP_S]:Be.REPEAT,[Be.TEXTURE_WRAP_]:Be.REPEAT};class Ue{postProcess(e,t={}){const{json:r,buffers:s=[],images:n=[],baseUri:i=""}=e;return y(r),this.baseUri=i,this.json=r,this.buffers=s,this.images=n,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(e.images=e.images.map((e,r)=>this._resolveImage(e,r,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])}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.json[e]&&this.json[e][t];return r||console.warn(`glTF file error: Could not find ${e}[${t}]`),r}_resolveScene(e,t){return e.id=e.id||`scene-${t}`,e.nodes=(e.nodes||[]).map(e=>this.getNode(e)),e}_resolveNode(e,t){return 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.id=e.id||`skin-${t}`,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||`mesh-${t}`,e.primitives&&(e.primitives=e.primitives.map(e=>{const t=(e={...e}).attributes;e.attributes={};for(const r in t)e.attributes[r]=this.getAccessor(t[r]);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.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 r,s;return e.id=e.id||`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(r=e.componentType,ve[r]),e.components=(s=e.type,Ee[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e}_resolveTexture(e,t){return e.id=e.id||`texture-${t}`,e.sampler="sampler"in e?this.getSampler(e.sampler):Le,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||`sampler-${t}`,e.parameters={};for(const t in e){const r=this._enumSamplerParameter(t);void 0!==r&&(e.parameters[r]=e[t])}return e}_enumSamplerParameter(e){return Re[e]}_resolveImage(e,t,r){if(e.id=e.id||`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),"uri"in e){const s=this.images[t];s&&s.image&&(e.image=s.image,delete e.uri);const n=r.uri||this.baseUri;if(n){const t=e.uri;e.uri=j(e.uri,n),e.originalUri=t,e.baseUri=n,e.fullUri=e.uri}}return e.getImageAsync=()=>e.bufferView?new Promise(t=>{const r=this.getBufferView(e.bufferView),s=e.mimeType||"image/jpeg",n=new Blob([r.data],{type:s}),i=(self.URL||self.webkitURL).createObjectURL(n),o=new Image;o.onload=()=>t(o),o.src=i}):e.uri?new Promise(t=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>t(r),r.src=e.fullUri||e.uri}):null,e}_resolveBufferView(e,t){e.id=e.id||`bufferView-${t}`;const r=e.buffer;e.buffer=this.getBuffer(r);const s=this.buffers[r].arrayBuffer;let n=this.buffers[r].byteOffset||0;return"byteOffset"in e&&(n+=e.byteOffset),e.data=new Uint8Array(s,n,e.byteLength),e}_resolveCamera(e,t){return e.id=e.id||`camera-${t}`,e.perspective,e.orthographic,e}}function Oe(e,t){return(new Ue).postProcess(e,t)}const Ve={fetchLinkedResources:!0,fetchImages:!1,createImages:!1,fetch:d,decompress:!1,DracoLoader:null,postProcess:!1,log:console};async function Se(e,t,r=0,s={}){Ce(e,t,r,s={...Ve,...s});const n=[];if(s.fetchImages){const t=async function(e,t){const r=e.json.images||[],s=[];for(let n=0;n<r.length;++n){const i=r[n];"uri"in i&&s.push(Pe(e,i,n,t))}return await Promise.all(s)}(e,s);n.push(t)}s.fetchLinkedResources&&await async function(e,t){for(let r=0;r<e.json.buffers.length;++r){const s=e.json.buffers[r];if(t.uri||console.warn("options.uri must be set to decode embedded glTF buffers"),s.uri&&t.uri){const n=t.fetch||window.fetch;y(n);const i=j(s.uri,t.uri),o=await n(i),u=await o.arrayBuffer();e.buffers[r]={arrayBuffer:u,byteOffset:0,byteLength:u.byteLength},delete s.uri}}}(e,s);const i=async function(e,t){for(const r in ge){if(!(r in t&&!t[r])){const s=ge[r];await s.decode(e,t)}}}(e,s);return n.push(i),await Promise.all(n),s.postProcess?Oe(e,s):e}function ke(e,t,r=0,s={}){return Ce(e,t,r,s={...Ve,...s}),s.fetchLinkedResources&&function(e,t){for(const t of e.json.buffers||[])if(t.uri)throw new Error("parseGLTFSync: Cannot decode uri buffers")}(e),s.decodeExtensions&&function(e,t){for(const r in ge){if(!(r in t&&!t[r])){ge[r].decodeSync(e,t)}}}(e,s),s.postProcess?Oe(e,s):e}function Ce(e,t,r,s){if(s.uri&&(e.baseUri=s.uri),t instanceof ArrayBuffer&&!_e(t,r,s)){t=(new TextDecoder).decode(t)}"string"==typeof t?e.json=JSON.parse(t):t instanceof ArrayBuffer?(e._glb={},r=Te(e._glb,t,r,s),e.json=e._glb.json):e.json=t;const n=e.json.buffers||[];e.buffers=new Array(n.length).fill({}),e._glb&&e._glb.hasBinChunk&&(e.buffers[0]={arrayBuffer:e._glb.binChunks[0].arrayBuffer,byteOffset:e._glb.binChunks[0].byteOffset,byteLength:e._glb.binChunks[0].byteLength},e.json.buffers[0].data=e.buffers[0].arrayBuffer,e.json.buffers[0].byteOffset=e.buffers[0].byteOffset);const i=e.json.images||[];e.images=new Array(i.length).fill({})}async function Pe(e,t,r,s){y(s.fetch||window.fetch);const n=j(t.uri,s.uri);e.images[r]=await new Promise((e,t)=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>e(r),r.onerror=e=>t(e),r.src=n})}z.a.TextEncoder;const Me=z.a.TextDecoder;function Ie(e,t,r={}){return function e(t,r,s,n={}){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]+)/)){return["accessors",parseInt(t[1],10)]}}return null}(e);if(r){const[s,n]=r,i=t[s]&&t[s][n];if(i)return i;console.error(`Invalid JSON pointer ${e}: #/${s}/${n}`)}return null}(i,s);if(o)return o;if(Array.isArray(i))return i.map(t=>e(t,r,s,n));if(null!==i&&"object"==typeof i){const t={};for(const o in i)t[o]=e(i[o],r,s,n);return t}return i}(e,e,t,r)}function De(e,t,r){r&&(e=function(e,t){const r=e.byteLength-t,s=new ArrayBuffer(r),n=new Uint8Array(e),i=new Uint8Array(s);for(let e=0;e<r;e++)i[e]=n[t+e];return s}(e,r));const s=t.bufferViews||[];for(let e=0;e<s.length;++e){y(s[e].byteLength>=0)}return{accessors:Fe(e,s,t),images:$e(e,s,t)}}function Fe(e,t,r){const s=r.accessors||[],n=[];for(let r=0;r<s.length;++r){const i=s[r];y(i);const o=t[i.bufferView];if(o){const{ArrayType:t,length:r}=A(i,o),s=new t(e,o.byteOffset,r);s.accessor=i,n.push(s)}}return n}function $e(e,t,r){const s=r.images||[],n=[];for(let r=0;r<s.length;++r){const i=s[r];y(i);const o=t[i.bufferView];y(o);const u=new Uint8Array(e,o.byteOffset,o.byteLength);u.imate=i,n.push(u)}return n}class Ne{static isGLB(e,t={}){return _e(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;Te(this,this.glbArrayBuffer,e,t),this.binaryByteOffset=this.binChunkByteOffset,this.packedJson=this.json;const r=De(this.glbArrayBuffer,this.json,this.binaryByteOffset);this.json=Ie(this.json,r),this.unpackedBuffers=r}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=x[e.componentType],r=p[e.type],s=w[e.componentType],n=e.count*r,i=e.count*r*s,o=this.json.bufferViews[e.bufferView];y(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),r=e.mimeType||"image/jpeg",s=new Blob([t],{type:r}),n=(self.URL||self.webkitURL).createObjectURL(s),i=new Image;return i.src=n,i}getImageAsync(e){return new Promise(t=>{const r=this.getBufferView(e.bufferView),s=e.mimeType||"image/jpeg",n=new Blob([r],{type:s}),i=(self.URL||self.webkitURL).createObjectURL(n),o=new Image;o.onload=()=>t(o),o.src=i})}}const We={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},qe={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Ge={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},Xe={magFilter:Ge.TEXTURE_MAG_FILTER,minFilter:Ge.TEXTURE_MIN_FILTER,wrapS:Ge.TEXTURE_WRAP_S,wrapT:Ge.TEXTURE_WRAP_T},ze={[Ge.TEXTURE_MAG_FILTER]:Ge.LINEAR,[Ge.TEXTURE_MIN_FILTER]:Ge.NEAREST_MIPMAP_LINEAR,[Ge.TEXTURE_WRAP_S]:Ge.REPEAT,[Ge.TEXTURE_WRAP_]:Ge.REPEAT};class Je{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=qe[e],e.components=We[e],e.bytesPerElement=e.bytesPerComponent*e.components}_resolveTexture(e,t){e.id=`texture-${t}`,e.sampler="sampler"in e?this.getSampler(e.sampler):ze,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 Xe[e]}_resolveImage(e,t,r){e.id=`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const{createImages:s=!0}=r;s?e.image=this.glbParser.getImage(e):e.getImageAsync=()=>this.glbParser?this.glbParser.getImageAsync(e):e.uri?new Promise(t=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>t(s),s.src=j(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 s=e.indexOf(t);s>-1?e.splice(s,1):r=!1}}}const He={fetchLinkedResources:!0,fetch:d,decompress:!1,DracoLoader:null,postProcess:!0,createImages:!1,log:console};class Ke{async parse(e,t={}){if(t=Object.assign({},He,t),this.parseSync(e,{...t,postProcess:!1,decompress:!1}),t.fetchLinkedResources&&await this._loadLinkedAssets(t),t.decompress&&this._decompressMeshes(t),t.postProcess){(new Je).postProcess(this.gltf,this.glbParser,t)}return this.gltf}parseSync(e,t={}){if(t=Object.assign({},He,t),e instanceof ArrayBuffer&&!Ne.isGLB(e,t)){e=(new Me).decode(e)}if("string"==typeof e&&(e=JSON.parse(e)),e instanceof ArrayBuffer?(this.glbParser=new Ne,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 Je).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&&t.uri){const r=t.fetch||window.fetch,s=j(e.uri,t.uri),n=await r(s),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 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(s),this._removeExtension(n)}}_decompressKhronosDracoPrimitive(e,t){const r=e.extensions&&e.extensions[s];if(!r)return;delete e.extensions[s];const n=this._getBufferViewArray(r.bufferView),i=t.DracoLoader.parseSync(n);e.attributes=P(i.attributes),i.indices&&(e.indices=M(i.indices))}_decompressUberDracoPrimitive(e,t){const r=e.extensions&&e.extensions[n];if(!r)return;if(0!==e.mode)throw new Error(n);delete e.extensions[n];const s=this._getBufferViewArray(r.bufferView),i=t.DracoLoader.parseSync(s);e.attributes=i.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,s=t.byteOffset||0;return new Uint8Array(r,s,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 s=e.indexOf(t);s>-1?e.splice(s,1):r=!1}}}const Qe={gltf:{parserVersion:1},uri:""};var Ye={name:"glTF",extensions:["gltf","glb"],text:!0,binary:!0,test:"glTF",parse:async function(e,t={}){if(2!==(t={...Qe,...t}).gltf.parserVersion&&!1!==t.useGLTFParser){return(new Ke).parse(e,t)}const{byteOffset:r=0}=t;return await Se({},e,r,t)},parseSync:function(e,t={}){if(2!==(t={...Qe,...t}).gltf.parserVersion&&!1!==t.useGLTFParser)return(new Ke).parseSync(e,t);const{byteOffset:r=0}=t;return ke({},e,r,t)},defaultOptions:Qe};function Ze(e,t,r,s){const n=S(r.byteLength),i=n-r.byteLength;if(e){const s=new Uint8Array(e.buffer,e.byteOffset+t,r.byteLength),n=new Uint8Array(r);s.set(n);for(let s=0;s<i;++s)e.setUint8(t+r.byteLength+s,32)}return t+=n}const et=1179937895,tt=1313821514,rt=5130562,st=!0;function nt(e,t,r=0,s={}){const{magic:n=et,version:i=2,json:o={},binary:u}=e,a=r;t&&(t.setUint32(r+0,n,st),t.setUint32(r+4,i,st),t.setUint32(r+8,0,st));const f=r+8,c=r+=12;if(t&&(t.setUint32(r+0,0,st),t.setUint32(r+4,tt,st)),r=function(e,t,r,s){return t=Ze(e,t,(new TextEncoder).encode(r))}(t,r+=8,JSON.stringify(o)),t){const e=r-c-8;t.setUint32(c+0,e,st)}if(u){const e=r;if(t&&(t.setUint32(r+0,0,st),t.setUint32(r+4,rt,st)),r=Ze(t,r+=8,u),t){const s=r-e-8;t.setUint32(e+0,s,st)}}if(t){const e=r-a;t.setUint32(f,e,st)}return r}function it(e,t,r,s){return function(e,{firstBuffer:t=0}={}){if(e.buffers&&e.buffers.length>t)throw new Error("encodeGLTF: multiple buffers not yet implemented")}(e),nt(e,t,r,s)}var ot={name:"glTF",extensions:["glb"],encodeSync:function(e,t={}){const{byteOffset:r=0}=t,s=it(e,null,r,t),n=new ArrayBuffer(s);return it(e,new DataView(n),r,t),n},binary:!0,defaultOptions:{useGLTFBuilder:!0}},ut={name:"GLB",extension:["glb"],text:!0,binary:!0,parseSync:function(e,t){const{byteOffset:r=0}=t,s={};return Te(s,e,r,t),s},defaultOptions:{strict:!1}};var at={name:"GLB",extensions:["glb"],encodeSync:function(e,t){const{byteOffset:r=0}=t,s=nt(e,null,r,t),n=new ArrayBuffer(s),i=new DataView(n);return nt(e,i,r,t),n},binary:!0};function ft(e,t=Float32Array){if(0===e.length)return new Float32Array(0);if(!function e(t,r=Number.isFinite){let s=-1;for(;++s<t.length;){const n=t[s];if(Array.isArray(n)||ArrayBuffer.isView(n)){if(!e(n,r))return!1}else if(!r(n))return!1}return!0}(e))return null;const r=new t(function e(t,r=3){let s=0;let n=0;let i=-1;for(;++i<t.length;){const r=t[i];Array.isArray(r)||ArrayBuffer.isView(r)?s+=e(r):n++}return s+(0===s&&n<r?r:n)}(e));return function(e,t,r=3){(function e(t,r,s,n){let i=-1;let o=0;for(;++i<t.length;){const u=t[i];Array.isArray(u)||ArrayBuffer.isView(u)?n=e(u,r,s,n):o<s&&(r[n++]=u,o++)}o>0&&o<s&&(r[n++]=0);return n})(e,t,r,0)}(e,r),r}function ct(e,t,r={}){const{flattenArrays:s=!1}=r;let n=e;if("string"==typeof n&&0===n.indexOf("#/"))return`#${n}`;if(Array.isArray(n)){const e=s&&ft(n);if(!e)return n.map(e=>ct(e,t,r));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 s in n)e[s]=ct(n[s],t,r);return e}return n}class ht{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:r}=O(t);return r(V(e))}return Boolean(L(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},r=nt(t,null,0,e),s=new ArrayBuffer(r);return nt(t,new DataView(s),0,e),s}addApplicationData(e,t,r={}){const s=r.packTypedArrays?ct(t,this,r):t;return this.json[e]=s,this}addBuffer(e,t={size:3}){const r=this.addBufferView(e),s={size:t.size,componentType:T(e),count:Math.round(e.length/t.size)};return this.addAccessor(r,Object.assign(s,t))}addBufferView(e){const t=e.byteLength||e.length;return this.json.bufferViews.push({buffer:0,byteOffset:this.byteLength,byteLength:t}),this.byteLength+=S(t),this.sourceBuffers.push(e),this.json.bufferViews.length-1}addAccessor(e,t){return this.json.accessors.push({bufferView:e,type:_(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),r=new Uint8Array(t);let s=0;for(let e=0;e<this.sourceBuffers.length;e++){s=k(this.sourceBuffers[e],r,s)}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 lt extends ht{constructor(e={}){super(e),this.DracoWriter=e.DracoWriter,this.DracoLoader=e.DracoLoader}addApplicationData(e,t,r={}){const s=r.packTypedArrays?ct(t,this,r):t;return this.json[e]=s,this}addExtraData(e,t,r={}){const s=r.packedTypedArrays?ct(t,this,r):t;return this.json.extras=this.json.extras||{},this.json.extras[e]=s,this}addExtension(e,t,r={}){y(t);const s=r.packTypedArrays?ct(t,this,r):t;return this.json.extensions=this.json.extensions||{},this.json.extensions[e]=s,this.registerUsedExtension(e),this}addRequiredExtension(e,t,r={}){y(t);const s=r.packTypedArrays?ct(t,this,r):t;return this.addExtension(e,s),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 s={primitives:[{attributes:this._addAttributes(e),indices:t,mode:r}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),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(s);const n=this.DracoWriter.encodeSync({attributes:e}),i=this.DracoLoader.parseSync({attributes:e}),o=this._addFauxAttributes(i.attributes),u=this.addBufferView(n),a={primitives:[{attributes:o,mode:r,extensions:{[s]:{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}),r=this.addBufferView(t),s={primitives:[{attributes:{},mode:0,extensions:{[n]:{bufferView:r}}}]};return this.registerRequiredExtension(n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),this.json.meshes.length-1}addImage(e){const t=this.addBufferView(e),r=U(e)||{};if(r){const{mimeType:e,width:s,height:n}=r;this.json.images.push({bufferView:t,mimeType:e,width:s,height:n})}else this.json.images.push({bufferView:t});return this.json.images.length-1}}r.d(t,"KHR_DRACO_MESH_COMPRESSION",function(){return s}),r.d(t,"UBER_POINT_CLOUD_EXTENSION",function(){return n}),r.d(t,"GLTFLoader",function(){return Ye}),r.d(t,"GLTFWriter",function(){return ot}),r.d(t,"GLBLoader",function(){return ut}),r.d(t,"GLBWriter",function(){return at}),r.d(t,"GLTFScenegraph",function(){return C}),r.d(t,"postProcessGLTF",function(){return Oe}),r.d(t,"parseGLTFSync",function(){return ke}),r.d(t,"encodeGLTFSync",function(){return it}),r.d(t,"packBinaryJson",function(){return ct}),r.d(t,"unpackBinaryJson",function(){return Ie}),r.d(t,"GLBParser",function(){return Ne}),r.d(t,"GLBBuilder",function(){return ht}),r.d(t,"GLTFParser",function(){return Ke}),r.d(t,"GLTFBuilder",function(){return lt})}])});
!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 s in r)("object"==typeof exports?exports:e)[s]=r[s]}}(window,function(){return function(e){var t={};function r(s){if(t[s])return t[s].exports;var n=t[s]={i:s,l:!1,exports:{}};return e[s].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=e,r.c=t,r.d=function(e,t,s){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},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 s=Object.create(null);if(r.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)r.d(s,n,function(t){return e[t]}.bind(null,n));return s},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=14)}([function(e,t,r){"use strict";(function(e,s){r.d(t,"b",function(){return n}),r.d(t,"a",function(){return o}),r.d(t,"c",function(){return a});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!==s&&s,document:"undefined"!=typeof document&&document},o=i.global||i.self||i.window,u=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/),a=u&&parseFloat(u[1])||0}).call(this,r(15),r(9))},,,,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 s=r(16),n="undefined"==typeof window?t:window;n.loaders=n.loaders||{},e.exports=Object.assign(n.loaders,s)}).call(this,r(9))},function(e,t){var r,s,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(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{s="function"==typeof clearTimeout?clearTimeout:o}catch(e){s=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(s===clearTimeout)return clearTimeout(e);if((s===o||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(e);try{s(e)}catch(t){try{return s.call(null,e)}catch(t){return s.call(this,e)}}}(e)}}function d(e,t){this.fun=e,this.array=t}function y(){}n.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)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=y,n.addListener=y,n.once=y,n.off=y,n.removeListener=y,n.removeAllListeners=y,n.emit=y,n.prependListener=y,n.prependOnceListener=y,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,r){"use strict";r.r(t);const s="KHR_draco_mesh_compression",n="UBER_draco_point_cloud_compression",i="KHR_lights_punctual";function o(e,t){if(!e)throw new Error(t||"gltf/glb assertion failed.")}const u=["SCALAR","VEC2","VEC3","VEC4"],a=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126]]),f={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},c={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},h={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function l(e){return u[e-1]||u[0]}function g(e){const t=a.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function d(e,t){const r=h[e.componentType],s=f[e.type],n=c[e.componentType],i=e.count*s,u=e.count*s*n;return o(u>=0&&u<=t.byteLength),{ArrayType:r,length:i,byteLength:u}}function y(e,t){return e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:")?e:t.substr(0,t.lastIndexOf("/")+1)+e}const m=!1,b=!0,p=new Map([["image/png",{test:function(e){return e.byteLength>=24&&2303741511===e.getUint32(0,m)},getSize:function(e){return{width:e.getUint32(16,m),height:e.getUint32(20,m)}}}],["image/jpeg",{test:function(e){return e.byteLength>=3&&65496===e.getUint16(0,m)&&255===e.getUint8(2,m)},getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,m))return null;const{tableMarkers:t,sofMarkers:r}=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<e.byteLength;){const n=e.getUint16(s,m);if(r.has(n))return{height:e.getUint16(s+5,m),width:e.getUint16(s+7,m)};if(!t.has(n))return null;s+=2,s+=e.getUint16(s,m)}return null}}],["image/gif",{test:function(e){return e.byteLength>=10&&1195984440===e.getUint32(0,m)},getSize:function(e){return{width:e.getUint16(6,b),height:e.getUint16(8,b)}}}],["image/bmp",{test:function(e){return e.byteLength>=2&&16973===e.getUint16(0,m)},getSize:function(e){return{width:e.getUint32(18,b),height:e.getUint32(22,b)}}}]]);const w=`Invalid MIME type. Supported MIME types are: ${Array.from(p.keys()).join(", ")}`;function x(e){const t=A(e);for(const[e,{test:r}]of p.entries())if(r(t))return e;return null}function _(e,t=null){const r=function(e,t=null){t=t||x(e);const{getSize:r}=T(t),s=r(A(e));if(!s)throw new Error(`invalid image data for type: ${t}`);return s}(e,t=t||x(e));return r.mimeType=t,r}function T(e){const t=p.get(e);if(!t)throw new Error(w);return t}function A(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}function j(e){return e+3&-4}function E(e,t,r){let s;if(e instanceof ArrayBuffer)s=new Uint8Array(e);else{const t=e.byteOffset,r=e.byteLength;s=new Uint8Array(e.buffer,t,r)}return t.set(s,r),r+j(s.byteLength)}class v{constructor(e){if(e instanceof v)return e;e||(e={json:{version:2,buffers:[]},buffers:[]}),this.gltf=e,o(this.gltf.json)}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),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||[]}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 r=this.json[e]&&this.json[e][t];if(!r)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return r}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,r=this.gltf.buffers[t];o(r);const s=e.byteOffset||0+r.byteOffset;return new Uint8Array(r.arrayBuffer,s,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBuffer(e.bufferView),r=this.getBuffer(t.buffer).data,{ArrayType:s,length:n}=d(e,t);return new s(r,t.byteOffset+e.byteOffset,n)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBuffer(e.bufferView),r=this.getBuffer(t.buffer).data,s=t.byteOffset||0;return new Uint8Array(r,s,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 o(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),this}addRequiredExtension(e,t){return o(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,r){(e.extensions||{})[t]=r}addMesh(e,t,r=4){const s={primitives:[{attributes:this._addAttributes(e),indices:t,mode:r}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),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||x(e);const r={bufferView:this.addBufferView(e),mimeType:t};return this.json.images=this.json.images||[],this.json.images.push(r),this.json.images.length-1}addBufferView(e){const t=e.byteLength;o(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const r={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=j(t),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(r),this.json.bufferViews.length-1}addAccessor(e,t){const r={bufferView:e,type:l(t.size),componentType:t.componentType,count:t.count};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(r),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const r=this.addBufferView(e),s={size:t.size,componentType:g(e),count:Math.round(e.length/t.size)};return this.addAccessor(r,Object.assign(s,t))}createBinaryChunk(){if(this.arrayBuffer)return;const e=this.byteLength,t=new ArrayBuffer(e),r=new Uint8Array(t);let s=0;for(let e=0;e<this.sourceBuffers.length;e++){s=E(this.sourceBuffers[e],r,s)}this.json.buffers[0].byteLength=e,this.arrayBuffer=t,this.sourceBuffers=[]}_removeStringFromArray(e,t){let r=!0;for(;r;){const s=e.indexOf(t);s>-1?e.splice(s,1):r=!1}}}function B(e){const t={};for(const r in e){const s=e[r];if("indices"!==r){const e=R(s);t[r]=e}}return t}function R(e,t){const{buffer:r,size:s,count:n}=function(e,t){let r=e,s=1,n=0;e&&e.value&&(r=e.value,s=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)),n=r.length/s);return{buffer:r,size:s,count:n}}(e);return{value:r,size:s,bufferView:null,byteOffset:0,count:n,type:l(s),componentType:g(r)}}function L(e,t){if(!e)throw new Error(t||"loader assertion failed.")}function U(e){if(!e)return!1;return Array.isArray(e)&&(e=e[0]),e.parseTextSync||e.parseSync||e.parse||e.loadAndParse||e.parseStream||e.parseInBatches||e.worker}function O(e){let t;return L(U(e)),Array.isArray(e)&&(t=e[1],e=e[0],e={...e,options:{...e.options,...t}}),e.extension&&(e.extensions=e.extensions||e.extension,delete e.extension),Array.isArray(e.extensions)||(e.extensions=[e.extensions]),L(e.extensions&&e.extensions.length>0&&e.extensions[0]),e.parseTextSync&&(e.text=!0),e.text||(e.binary=!0),e}class V{log(){}info(){}warn(){}error(){}}function S(e,t){return null===(e=Object.assign({},t&&t.DEFAULT_OPTIONS,t&&t.defaultOptions,t&&t.options,e,{dataType:"arraybuffer"})).log&&(e.log=new V),"log"in e||(e.log=console),e}const k=e=>"undefined"!=typeof Response&&e instanceof Response||e.arrayBuffer&&e.text&&e.json,C=e=>(e=>"undefined"!=typeof File&&e instanceof File)(e)||(e=>"undefined"!=typeof Blob&&e instanceof Blob)(e);var P=r(0);class M{constructor(e){this._fileOrBlob=e,this.bodyUsed=!1}get headers(){return new Headers({"Content-Length":this._fileOrBlob.size,"Content-Type":this._fileOrBlob.type})}get ok(){return!0}get status(){return 200}url(){return this._fileOrBlob.name||""}async arrayBuffer(){const{reader:e,promise:t}=this._getFileReader();return e.readAsArrayBuffer(this._fileOrBlob),t}async text(){const{reader:e,promise:t}=this._getFileReader();return e.readAsText(this._fileOrBlob),t}async json(){const e=await this.text();return JSON.parse(e)}_getFileReader(){let e;L(!this.bodyUsed),this.bodyUsed=!0;const t=new Promise((t,r)=>{try{(e=new FileReader).onerror=e=>r(new Error(e)),e.onabort=()=>r(new Error("Read aborted.")),e.onload=()=>t(e.result)}catch(e){r(e)}});return{reader:e,promise:t}}}function I(e,t){return Promise.resolve(new M(e,t))}const D="Cannot convert supplied data type";function F(e,t){if(t.text&&"string"==typeof e)return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){const r=e.buffer||e;if(t.text&&!t.binary){return new TextDecoder("utf8").decode(r)}return r}throw new Error(D)}async function $(e,t){const r=(e=await e)instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||r)return F(e,t);if(C(e)&&(e=await I(e)),k(e))return await async function(e){if(!e.ok){let t=`fetch failed ${e.status} `;try{t+=await e.text()}catch(e){}throw new Error(t)}}(e),t.binary?await e.arrayBuffer():await e.text();throw new Error(D)}function N(e,t){return{fetch:"undefined"!=typeof window&&window.fetch,...e}}var W=r(4);function q(e){if(W.toArrayBuffer&&(e=Object(W.toArrayBuffer)(e)),e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}return L(!1)}function G(e,t=!0,r=[]){if(e){if(e instanceof ArrayBuffer)r.push(e);else if(e.buffer&&e.buffer instanceof ArrayBuffer)r.push(e.buffer);else if(t&&"object"==typeof e)for(const s in e)G(e[s],t,r)}else;return r}const X=new Map;let z=0;function J({data:e,resolve:t}){t(e)}class H{constructor({source:e,name:t=`web-worker-${z++}`,onMessage:r}){const s=function(e){if(L("string"==typeof e,"worker source"),e.startsWith("url(")&&e.endsWith(")"))return e.match(/^url\((.*)\)$/)[1];let t=X.get(e);if(!t){const r=new Blob([e],{type:"application/javascript"});t=URL.createObjectURL(r),X.set(e,t)}return t}(e);this.worker=new Worker(s,{name:t}),this.name=t,this.onMessage=r||J}async process(e){return new Promise((t,r)=>{this.worker.onmessage=e=>this.onMessage({worker:this.worker,data:e.data,resolve:t,reject:r}),this.worker.onerror=e=>r(e);const s=G(e);this.worker.postMessage(e,s)})}destroy(){this.worker.terminate(),this.worker=null}}class K{constructor({source:e,name:t="unnamed",maxConcurrency:r=1,onMessage:s,onDebug:n=(()=>{})}){this.source=e,this.name=t,this.maxConcurrency=r,this.onMessage=s,this.onDebug=n,this.jobQueue=[],this.idleQueue=[],this.count=0,this.isDestroyed=!1}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}async process(e,t){return new Promise((r,s)=>{this.jobQueue.push({data:e,jobName:t,resolve:r,reject:s}),this._startQueuedJob()})}_startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();this.onDebug({message:"processing",worker:e.name,job:t.jobName,backlog:this.jobQueue.length}),e.process(t.data).then(e=>t.resolve(e)).catch(e=>t.reject(e)).then(()=>this._onWorkerDone(e))}_onWorkerDone(e){this.isDestroyed?e.destroy():(this.idleQueue.push(e),this._startQueuedJob())}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift();if(this.count<this.maxConcurrency){this.count++;const e=`${this.name.toLowerCase()}-worker-${this.count}-of-${this.maxConcurrency}`;return new H({source:this.source,onMessage:this.onMessage,name:e})}return null}}const Q=5;class Y{constructor({maxConcurrency:e=Q,onMessage:t,onDebug:r=(()=>{})}){this.maxConcurrency=e,this.onMessage=t,this.onDebug=r,this.workerPools=new Map}setProps(e){"maxConcurrency"in e&&(this.maxConcurrency=e.maxConcurrency),"onDebug"in e&&(this.onDebug=e.onDebug)}destroy(){this.workerPools.forEach(e=>e.destroy())}async process(e,t,r){return this._getWorkerPool(e,t).process(r)}_getWorkerPool(e,t){let r=this.workerPools.get(t);return r||(r=new K({source:e,name:t,onMessage:this.onMessage,maxConcurrency:this.maxConcurrency,onDebug:this.onDebug}),this.workerPools.set(t,r)),r}}let Z=null;async function ee({worker:e,data:t,resolve:r,reject:s}){switch(t.type){case"done":r(t.result);break;case"process":try{const r=await ue(t.arraybuffer,t.options,t.url);e.postMessage({type:"process-done",id:t.id,result:r},G(r))}catch(r){e.postMessage({type:"process-error",id:t.id,message:r.message})}break;case"error":s(t.message)}}function te(e,t,r,s={},n={}){const i=function(e={}){const t={};return e.maxConcurrency&&(t.maxConcurrency=e.maxConcurrency),e.onDebug&&(t.onDebug=e.onDebug),Z||(Z=new Y({onMessage:ee})),Z.setProps(t),Z}(s);return s=JSON.parse(JSON.stringify(s)),i.process(e,`loaders.gl-${t}`,{arraybuffer:q(r),options:s,source:"loaders.gl",type:"process"})}let re={};const se=/[^.]+$/;function ne(e,t="",r=null,{nothrow:s=!1}={}){if(t=t||"",e&&!Array.isArray(e)){const t=e;return O(t),t}(function(e){for(const t of e)O(t)})(e=e||Object.values(re)),t=t.replace(/\?.*/,"");let n=null;if(!(n=(n=n||function(e,t){const r=t.match(se),s=r&&r[0];return s&&function(e,t){t=t.toLowerCase();for(const r of e)for(const e of r.extensions)if(e.toLowerCase()===t)return r;return null}(e,s)}(e,t))||function(e,t){if(!t)return null;for(const r of e)if("string"==typeof t){if(ie(t,r))return r}else if(ArrayBuffer.isView(t)){if(oe(t.buffer,t.byteOffset,r))return r}else if(t instanceof ArrayBuffer){if(oe(t,0,r))return r}return null}(e,r))){if(s)return null;throw new Error(`No valid loader found for ${t}`)}return n}function ie(e,t){return t.testText&&t.testText(e)}function oe(e,t,r){switch(Array.isArray(r.test)?"array":typeof r.test){case"function":return r.test(e,r);case"string":case"array":return(Array.isArray(r.test)?r.test:[r.test]).some(r=>{return r===function(e,t,r){if(e.byteLength<=t+r)return"";const s=new DataView(e);let n="";for(let e=0;e<r;e++)n+=String.fromCharCode(s.getUint8(t+e));return n}(e,t,r.length)});default:return!1}}async function ue(e,t,r,s){!t||Array.isArray(t)||U(t)||(s=r,r=t,t=null),r=r||{};const n=function(e,t){return k(e)?t=t||e.url:C(t)&&(t=t.name),"string"==typeof t?t.replace(/\?.*/,""):t}(e,s),i=ne(t,n,e);r=S(r,i);const o=N({url:n,parse:ue});return await async function(e,t,r,s){if(t=await $(t,e),e.parseTextSync&&"string"==typeof t)return r.dataType="text",e.parseTextSync(t,r,s,e);if(e.parse)return await e.parse(t,r,s,e);if(e.parseSync)return e.parseSync(t,r,s,e);if(e.worker)return await te(e.worker,e.name,t,r,s);return L(!1)}(i,e,r,o)}async function ae(e,t,r){const n=t.getObjectExtension(e,s),i=t.getTypedArrayForBufferView(n.bufferView),o=new Uint8Array(i.buffer).subarray(i.byteOffset),u=new Uint8Array(o),a=await ue(u);e.attributes=B(a.attributes),a.indices&&(e.indices=R(a.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("Empty glTF primitive detected: Draco decompression failure?")}(e)}function fe(e,t,r=4,n={}){if(!n.DracoWriter||!n.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");const i=n.DracoWriter.encodeSync({attributes:e}),o=n.DracoLoader.parseSync({attributes:e}),u=n._addFauxAttributes(o.attributes),a=n.addBufferView(i);return{primitives:[{attributes:u,mode:r,extensions:{[s]:{bufferView:a,attributes:u}}}]}}const ce={KHR_draco_mesh_compression:class{static get name(){return s}static async decode(e,t={}){if(!t.decompress)return;const r=new v(e),n=[];for(const e of function*(e){for(const t of e.json.meshes||[])for(const e of t.primitives)yield e}(r))r.getObjectExtension(e,s)&&n.push(ae(e,r,t));await Promise.all(n),r.removeExtension(s)}static decodeSync(e,t){if(!t.decompress)return;if(new v(e).getRequiredExtension(s))throw new Error("Cannot synchronously decode Draco")}static encode(e,t={}){const r=new v(e);for(const e of r.json.meshes||[])fe(e,t),r.addRequiredExtension(s)}},KHR_lights_punctual:class{static get name(){return i}static decode(e,t){const r=new v(e),s=r.getExtension(i);s&&(r.json.lights=s.lights,r.removeExtension(i));for(const e of r.nodes||[]){const t=e.extensions&&e.extensions.KHR_lights_punctual;t&&(e.light=r._get("lights",t.light),delete e.extensions.KHR_lights_punctual)}}static encode(e,t){const r=new v(e),{json:s}=r;if(s.lights){const e=r.addExtensions(i);o(!e.lights),e.lights=s.lights,delete s.lights}if(r.json.lights){for(const e of r.json.lights){const t=e.node;r.addObjectExtension(t,i,e)}delete r.json.lights}}}};function he(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const le=1735152710,ge=12,de=8,ye=1313821514,me=5130562,be=!0;function pe(e,t=0,r={}){const s=new DataView(e),{magic:n=le}=r,i=s.getUint32(t,!1);return i===n||i===le}function we(e,t,r=0,s={}){const n=new DataView(t);e.type=function(e,t=0){return`${String.fromCharCode(e.getUint8(t+0))}${String.fromCharCode(e.getUint8(t+1))}${String.fromCharCode(e.getUint8(t+2))}${String.fromCharCode(e.getUint8(t+3))}`}(n,r+0),e.version=n.getUint32(r+4,be);const i=n.getUint32(r+8,be);return e.header={byteOffset:r,byteLength:i},"glTF"!==e.type&&console.warn(`Invalid GLB magic string ${e.type}`),he(2===e.version,`Invalid GLB version ${e.version}. Only .glb v2 supported`),he(e.header.byteLength>ge+de),e.json={},e.hasBinChunk=!1,e.binChunks=[],function(e,t,r,s){for(;r+8<=e.header.byteLength;){const n=t.getUint32(r+0,be),i=t.getUint32(r+4,be);switch(r+=de,i){case ye:xe(e,t,r,n,s);break;case me:_e(e,t,r,n,s)}switch(i){case 0:s.strict||xe(e,t,r,n,s);break;case 1:s.strict||_e(e,t,r,n,s)}r+=j(n)}}(e,n,r+12,s),function(e){e.byteOffset=e.header.byteOffset,e.magic=e.header.magic,e.version=e.header.version,e.byteLength=e.header.byteLength,e.hasBinChunk=e.binChunks.length>=1,e.binChunkByteOffset=e.header.hasBinChunk?e.binChunks[0].byteOffset:0,e.binChunkLength=e.header.hasBinChunk?e.binChunks[0].byteLength:0}(e),r+e.header.byteLength}function xe(e,t,r,s,n){const i=new Uint8Array(t.buffer,r,s),o=new TextDecoder("utf8").decode(i);e.json=JSON.parse(o)}function _e(e,t,r,s,n){e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:r,byteLength:s,arrayBuffer:t.buffer})}const Te={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ae={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},je={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},Ee={magFilter:je.TEXTURE_MAG_FILTER,minFilter:je.TEXTURE_MIN_FILTER,wrapS:je.TEXTURE_WRAP_S,wrapT:je.TEXTURE_WRAP_T},ve={[je.TEXTURE_MAG_FILTER]:je.LINEAR,[je.TEXTURE_MIN_FILTER]:je.NEAREST_MIPMAP_LINEAR,[je.TEXTURE_WRAP_S]:je.REPEAT,[je.TEXTURE_WRAP_]:je.REPEAT};class Be{postProcess(e,t={}){const{json:r,buffers:s=[],images:n=[],baseUri:i=""}=e;return o(r),this.baseUri=i,this.json=r,this.buffers=s,this.images=n,this._resolveTree(this.json,t),this.json}_resolveTree(e,t={}){e.bufferViews&&(e.bufferViews=e.bufferViews.map((e,t)=>this._resolveBufferView(e,t))),e.images&&(e.images=e.images.map((e,r)=>this._resolveImage(e,r,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])}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.json[e]&&this.json[e][t];return r||console.warn(`glTF file error: Could not find ${e}[${t}]`),r}_resolveScene(e,t){return e.id=e.id||`scene-${t}`,e.nodes=(e.nodes||[]).map(e=>this.getNode(e)),e}_resolveNode(e,t){return 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.id=e.id||`skin-${t}`,e.inverseBindMatrices=this.getAccessor(e.inverseBindMatrices),e}_resolveMesh(e,t){return e.id=e.id||`mesh-${t}`,e.primitives&&(e.primitives=e.primitives.map(e=>{const t=(e={...e}).attributes;e.attributes={};for(const r in t)e.attributes[r]=this.getAccessor(t[r]);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.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 r,s;return e.id=e.id||`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(r=e.componentType,Ae[r]),e.components=(s=e.type,Te[s]),e.bytesPerElement=e.bytesPerComponent*e.components,e}_resolveTexture(e,t){return e.id=e.id||`texture-${t}`,e.sampler="sampler"in e?this.getSampler(e.sampler):ve,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||`sampler-${t}`,e.parameters={};for(const t in e){const r=this._enumSamplerParameter(t);void 0!==r&&(e.parameters[r]=e[t])}return e}_enumSamplerParameter(e){return Ee[e]}_resolveImage(e,t,r){if(e.id=e.id||`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),"uri"in e){const s=this.images[t];s&&s.image&&(e.image=s.image,delete e.uri);const n=r.uri||this.baseUri;if(n){const t=e.uri;e.uri=y(e.uri,n),e.originalUri=t,e.baseUri=n,e.fullUri=e.uri}}return e.getImageAsync=()=>e.bufferView?new Promise(t=>{const r=this.getBufferView(e.bufferView),s=e.mimeType||"image/jpeg",n=new Blob([r.data],{type:s}),i=(self.URL||self.webkitURL).createObjectURL(n),o=new Image;o.onload=()=>t(o),o.src=i}):e.uri?new Promise(t=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>t(r),r.src=e.fullUri||e.uri}):null,e}_resolveBufferView(e,t){e.id=e.id||`bufferView-${t}`;const r=e.buffer;e.buffer=this.getBuffer(r);const s=this.buffers[r].arrayBuffer;let n=this.buffers[r].byteOffset||0;return"byteOffset"in e&&(n+=e.byteOffset),e.data=new Uint8Array(s,n,e.byteLength),e}_resolveCamera(e,t){return e.id=e.id||`camera-${t}`,e.perspective,e.orthographic,e}}function Re(e,t){return(new Be).postProcess(e,t)}const Le={fetchLinkedResources:!0,fetchImages:!1,createImages:!1,decompress:!1,postProcess:!1,log:console};async function Ue(e,t,r=0,s,n){Ve(e,t,r,s={...Le,...s.gltf});const i=[];if(s.fetchImages){const t=async function(e,t,r){const s=e.json.images||[],n=[];for(let r=0;r<s.length;++r){const i=s[r];"uri"in i&&n.push(Se(e,i,r,t))}return await Promise.all(n)}(e,s);i.push(t)}s.fetchLinkedResources&&await async function(e,t,r){for(let s=0;s<e.json.buffers.length;++s){const n=e.json.buffers[s];if(n.uri){if(!t.uri)return void console.warn("options.uri must be set to decode embedded glTF buffers");const{fetch:i}=r;o(i);const u=y(n.uri,t.uri),a=await i(u),f=await a.arrayBuffer();e.buffers[s]={arrayBuffer:f,byteOffset:0,byteLength:f.byteLength},delete n.uri}}}(e,s,n);const u=async function(e,t){for(const r in ce){if(!(r in t&&!t[r])){const s=ce[r];await s.decode(e,t)}}}(e,s);return i.push(u),await Promise.all(i),s.postProcess?Re(e,s):e}function Oe(e,t,r=0,s,n){return Ve(e,t,r,s={...Le,...s}),s.fetchLinkedResources&&function(e,t){for(const t of e.json.buffers||[])if(t.uri)throw new Error("parseGLTFSync: Cannot decode uri buffers")}(e),s.decodeExtensions&&function(e,t){for(const r in ce){if(!(r in t&&!t[r])){ce[r].decodeSync(e,t)}}}(e,s),s.postProcess?Re(e,s):e}function Ve(e,t,r,s){if(s.uri&&(e.baseUri=s.uri),t instanceof ArrayBuffer&&!pe(t,r,s)){t=(new TextDecoder).decode(t)}"string"==typeof t?e.json=JSON.parse(t):t instanceof ArrayBuffer?(e._glb={},r=we(e._glb,t,r,s),e.json=e._glb.json):e.json=t;const n=e.json.buffers||[];e.buffers=new Array(n.length).fill({}),e._glb&&e._glb.hasBinChunk&&(e.buffers[0]={arrayBuffer:e._glb.binChunks[0].arrayBuffer,byteOffset:e._glb.binChunks[0].byteOffset,byteLength:e._glb.binChunks[0].byteLength},e.json.buffers[0].data=e.buffers[0].arrayBuffer,e.json.buffers[0].byteOffset=e.buffers[0].byteOffset);const i=e.json.images||[];e.images=new Array(i.length).fill({})}async function Se(e,t,r,s,n){const i=y(t.uri,s.uri);e.images[r]=await new Promise((e,t)=>{const r=new Image;r.crossOrigin="anonymous",r.onload=()=>e(r),r.onerror=e=>t(e),r.src=i})}let ke="";const Ce={};function Pe(e){for(const t in Ce)if(e.startsWith(t)){const r=Ce[t];return e.replace(t,r)}return e+=ke}async function Me(e,t){return C(e)?I(e,t):(e=Pe(e),fetch(e,t))}P.a.TextEncoder;const Ie=P.a.TextDecoder;function De(e,t,r={}){return function e(t,r,s,n={}){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]+)/)){return["accessors",parseInt(t[1],10)]}}return null}(e);if(r){const[s,n]=r,i=t[s]&&t[s][n];if(i)return i;console.error(`Invalid JSON pointer ${e}: #/${s}/${n}`)}return null}(i,s);if(o)return o;if(Array.isArray(i))return i.map(t=>e(t,r,s,n));if(null!==i&&"object"==typeof i){const t={};for(const o in i)t[o]=e(i[o],r,s,n);return t}return i}(e,e,t,r)}function Fe(e,t,r){r&&(e=function(e,t){const r=e.byteLength-t,s=new ArrayBuffer(r),n=new Uint8Array(e),i=new Uint8Array(s);for(let e=0;e<r;e++)i[e]=n[t+e];return s}(e,r));const s=t.bufferViews||[];for(let e=0;e<s.length;++e){o(s[e].byteLength>=0)}return{accessors:$e(e,s,t),images:Ne(e,s,t)}}function $e(e,t,r){const s=r.accessors||[],n=[];for(let r=0;r<s.length;++r){const i=s[r];o(i);const u=t[i.bufferView];if(u){const{ArrayType:t,length:r}=d(i,u),s=new t(e,u.byteOffset,r);s.accessor=i,n.push(s)}}return n}function Ne(e,t,r){const s=r.images||[],n=[];for(let r=0;r<s.length;++r){const i=s[r];o(i);const u=t[i.bufferView];o(u);const a=new Uint8Array(e,u.byteOffset,u.byteLength);a.imate=i,n.push(a)}return n}class We{static isGLB(e,t={}){return pe(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;we(this,this.glbArrayBuffer,e,t),this.binaryByteOffset=this.binChunkByteOffset,this.packedJson=this.json;const r=Fe(this.glbArrayBuffer,this.json,this.binaryByteOffset);this.json=De(this.json,r),this.unpackedBuffers=r}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=h[e.componentType],r=f[e.type],s=c[e.componentType],n=e.count*r,i=e.count*r*s,u=this.json.bufferViews[e.bufferView];o(i>=0&&e.byteOffset+i<=u.byteLength);const a=u.byteOffset+this.binaryByteOffset+e.byteOffset;return new t(this.glbArrayBuffer,a,n)}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",s=new Blob([t],{type:r}),n=(self.URL||self.webkitURL).createObjectURL(s),i=new Image;return i.src=n,i}getImageAsync(e){return new Promise(t=>{const r=this.getBufferView(e.bufferView),s=e.mimeType||"image/jpeg",n=new Blob([r],{type:s}),i=(self.URL||self.webkitURL).createObjectURL(n),o=new Image;o.onload=()=>t(o),o.src=i})}}const qe={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ge={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},Xe={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},ze={magFilter:Xe.TEXTURE_MAG_FILTER,minFilter:Xe.TEXTURE_MIN_FILTER,wrapS:Xe.TEXTURE_WRAP_S,wrapT:Xe.TEXTURE_WRAP_T},Je={[Xe.TEXTURE_MAG_FILTER]:Xe.LINEAR,[Xe.TEXTURE_MIN_FILTER]:Xe.NEAREST_MIPMAP_LINEAR,[Xe.TEXTURE_WRAP_S]:Xe.REPEAT,[Xe.TEXTURE_WRAP_]:Xe.REPEAT};class He{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=Ge[e],e.components=qe[e],e.bytesPerElement=e.bytesPerComponent*e.components}_resolveTexture(e,t){e.id=`texture-${t}`,e.sampler="sampler"in e?this.getSampler(e.sampler):Je,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 ze[e]}_resolveImage(e,t,r){e.id=`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const{createImages:s=!0}=r;s?e.image=this.glbParser.getImage(e):e.getImageAsync=()=>this.glbParser?this.glbParser.getImageAsync(e):e.uri?new Promise(t=>{const s=new Image;s.crossOrigin="anonymous",s.onload=()=>t(s),s.src=y(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 s=e.indexOf(t);s>-1?e.splice(s,1):r=!1}}}const Ke={fetchLinkedResources:!0,fetch:Me,decompress:!1,DracoLoader:null,postProcess:!0,createImages:!1,log:console};class Qe{async parse(e,t={}){if(t=Object.assign({},Ke,t),this.parseSync(e,{...t,postProcess:!1,decompress:!1}),t.fetchLinkedResources&&await this._loadLinkedAssets(t),t.decompress&&this._decompressMeshes(t),t.postProcess){(new He).postProcess(this.gltf,this.glbParser,t)}return this.gltf}parseSync(e,t={}){if(t=Object.assign({},Ke,t),e instanceof ArrayBuffer&&!We.isGLB(e,t)){e=(new Ie).decode(e)}if("string"==typeof e&&(e=JSON.parse(e)),e instanceof ArrayBuffer?(this.glbParser=new We,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 He).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&&t.uri){const r=t.fetch||window.fetch,s=y(e.uri,t.uri),n=await r(s),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 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(s),this._removeExtension(n)}}_decompressKhronosDracoPrimitive(e,t){const r=e.extensions&&e.extensions[s];if(!r)return;delete e.extensions[s];const n=this._getBufferViewArray(r.bufferView),i=t.DracoLoader.parseSync(n);e.attributes=B(i.attributes),i.indices&&(e.indices=R(i.indices))}_decompressUberDracoPrimitive(e,t){const r=e.extensions&&e.extensions[n];if(!r)return;if(0!==e.mode)throw new Error(n);delete e.extensions[n];const s=this._getBufferViewArray(r.bufferView),i=t.DracoLoader.parseSync(s);e.attributes=i.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,s=t.byteOffset||0;return new Uint8Array(r,s,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 s=e.indexOf(t);s>-1?e.splice(s,1):r=!1}}}const Ye={gltf:{parserVersion:1},uri:""};var Ze={name:"glTF",extensions:["gltf","glb"],mimeType:"model/gltf+json",text:!0,binary:!0,test:"glTF",parse:async function(e,t={},r){if(2!==(t={...Ye,...t}).gltf.parserVersion&&!1!==t.useGLTFParser){return(new Qe).parse(e,t)}const{byteOffset:s=0}=t;return await Ue({},e,s,t,r)},parseSync:function(e,t={},r){if(2!==(t={...Ye,...t}).gltf.parserVersion&&!1!==t.useGLTFParser)return(new Qe).parseSync(e,t);const{byteOffset:s=0}=t;return Oe({},e,s,t)},defaultOptions:Ye};function et(e,t,r,s){const n=j(r.byteLength),i=n-r.byteLength;if(e){const s=new Uint8Array(e.buffer,e.byteOffset+t,r.byteLength),n=new Uint8Array(r);s.set(n);for(let s=0;s<i;++s)e.setUint8(t+r.byteLength+s,32)}return t+=n}const tt=1179937895,rt=1313821514,st=5130562,nt=!0;function it(e,t,r=0,s={}){const{magic:n=tt,version:i=2,json:o={},binary:u}=e,a=r;t&&(t.setUint32(r+0,n,nt),t.setUint32(r+4,i,nt),t.setUint32(r+8,0,nt));const f=r+8,c=r+=12;if(t&&(t.setUint32(r+0,0,nt),t.setUint32(r+4,rt,nt)),r=function(e,t,r,s){return t=et(e,t,(new TextEncoder).encode(r))}(t,r+=8,JSON.stringify(o)),t){const e=r-c-8;t.setUint32(c+0,e,nt)}if(u){const e=r;if(t&&(t.setUint32(r+0,0,nt),t.setUint32(r+4,st,nt)),r=et(t,r+=8,u),t){const s=r-e-8;t.setUint32(e+0,s,nt)}}if(t){const e=r-a;t.setUint32(f,e,nt)}return r}function ot(e,t,r,s){return function(e,{firstBuffer:t=0}={}){if(e.buffers&&e.buffers.length>t)throw new Error("encodeGLTF: multiple buffers not yet implemented")}(e),it(e,t,r,s)}var ut={name:"glTF",extensions:["glb"],mimeType:"model/gltf+json",encodeSync:function(e,t={}){const{byteOffset:r=0}=t,s=ot(e,null,r,t),n=new ArrayBuffer(s),i=new DataView(n);return ot(e,i,r,t),n},binary:!0,defaultOptions:{useGLTFBuilder:!0}};var at={name:"GLB",extensions:["glb"],mimeType:"model/gltf-binary",binary:!0,parse:async(e,t)=>ft(e,t),parseSync:ft,defaultOptions:{strict:!1}};function ft(e,t){const{byteOffset:r=0}=t,s={};return we(s,e,r,t),s}var ct={name:"GLB",extensions:["glb"],mimeType:"model/gltf-binary",encodeSync:function(e,t){const{byteOffset:r=0}=t,s=it(e,null,r,t),n=new ArrayBuffer(s),i=new DataView(n);return it(e,i,r,t),n},binary:!0};function ht(e,t=Float32Array){if(0===e.length)return new Float32Array(0);if(!function e(t,r=Number.isFinite){let s=-1;for(;++s<t.length;){const n=t[s];if(Array.isArray(n)||ArrayBuffer.isView(n)){if(!e(n,r))return!1}else if(!r(n))return!1}return!0}(e))return null;const r=new t(function e(t,r=3){let s=0;let n=0;let i=-1;for(;++i<t.length;){const r=t[i];Array.isArray(r)||ArrayBuffer.isView(r)?s+=e(r):n++}return s+(0===s&&n<r?r:n)}(e));return function(e,t,r=3){(function e(t,r,s,n){let i=-1;let o=0;for(;++i<t.length;){const u=t[i];Array.isArray(u)||ArrayBuffer.isView(u)?n=e(u,r,s,n):o<s&&(r[n++]=u,o++)}o>0&&o<s&&(r[n++]=0);return n})(e,t,r,0)}(e,r),r}function lt(e,t,r={}){const{flattenArrays:s=!1}=r;let n=e;if("string"==typeof n&&0===n.indexOf("#/"))return`#${n}`;if(Array.isArray(n)){const e=s&&ht(n);if(!e)return n.map(e=>lt(e,t,r));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 s in n)e[s]=lt(n[s],t,r);return e}return n}class gt{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:r}=T(t);return r(A(e))}return Boolean(x(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},r=it(t,null,0,e),s=new ArrayBuffer(r);return it(t,new DataView(s),0,e),s}addApplicationData(e,t,r={}){const s=r.packTypedArrays?lt(t,this,r):t;return this.json[e]=s,this}addBuffer(e,t={size:3}){const r=this.addBufferView(e),s={size:t.size,componentType:g(e),count:Math.round(e.length/t.size)};return this.addAccessor(r,Object.assign(s,t))}addBufferView(e){const t=e.byteLength||e.length;return this.json.bufferViews.push({buffer:0,byteOffset:this.byteLength,byteLength:t}),this.byteLength+=j(t),this.sourceBuffers.push(e),this.json.bufferViews.length-1}addAccessor(e,t){return this.json.accessors.push({bufferView:e,type:l(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),r=new Uint8Array(t);let s=0;for(let e=0;e<this.sourceBuffers.length;e++){s=E(this.sourceBuffers[e],r,s)}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 dt extends gt{constructor(e={}){super(e),this.DracoWriter=e.DracoWriter,this.DracoLoader=e.DracoLoader}addApplicationData(e,t,r={}){const s=r.packTypedArrays?lt(t,this,r):t;return this.json[e]=s,this}addExtraData(e,t,r={}){const s=r.packedTypedArrays?lt(t,this,r):t;return this.json.extras=this.json.extras||{},this.json.extras[e]=s,this}addExtension(e,t,r={}){o(t);const s=r.packTypedArrays?lt(t,this,r):t;return this.json.extensions=this.json.extensions||{},this.json.extensions[e]=s,this.registerUsedExtension(e),this}addRequiredExtension(e,t,r={}){o(t);const s=r.packTypedArrays?lt(t,this,r):t;return this.addExtension(e,s),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 s={primitives:[{attributes:this._addAttributes(e),indices:t,mode:r}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),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(s);const n=this.DracoWriter.encodeSync({attributes:e}),i=this.DracoLoader.parseSync({attributes:e}),o=this._addFauxAttributes(i.attributes),u=this.addBufferView(n),a={primitives:[{attributes:o,mode:r,extensions:{[s]:{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}),r=this.addBufferView(t),s={primitives:[{attributes:{},mode:0,extensions:{[n]:{bufferView:r}}}]};return this.registerRequiredExtension(n),this.json.meshes=this.json.meshes||[],this.json.meshes.push(s),this.json.meshes.length-1}addImage(e){const t=this.addBufferView(e),r=_(e)||{};if(r){const{mimeType:e,width:s,height:n}=r;this.json.images.push({bufferView:t,mimeType:e,width:s,height:n})}else this.json.images.push({bufferView:t});return this.json.images.length-1}}r.d(t,"KHR_DRACO_MESH_COMPRESSION",function(){return s}),r.d(t,"UBER_POINT_CLOUD_EXTENSION",function(){return n}),r.d(t,"GLTFLoader",function(){return Ze}),r.d(t,"GLTFWriter",function(){return ut}),r.d(t,"GLBLoader",function(){return at}),r.d(t,"GLBWriter",function(){return ct}),r.d(t,"GLTFScenegraph",function(){return v}),r.d(t,"postProcessGLTF",function(){return Re}),r.d(t,"parseGLTFSync",function(){return Oe}),r.d(t,"encodeGLTFSync",function(){return ot}),r.d(t,"packBinaryJson",function(){return lt}),r.d(t,"unpackBinaryJson",function(){return De}),r.d(t,"GLBParser",function(){return We}),r.d(t,"GLBBuilder",function(){return gt}),r.d(t,"GLTFParser",function(){return Qe}),r.d(t,"GLTFBuilder",function(){return dt})}])});

@@ -10,2 +10,6 @@ "use strict";

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _parseGlb = _interopRequireDefault(require("./lib/parse-glb"));

@@ -15,5 +19,27 @@

name: 'GLB',
extension: ['glb'],
text: true,
extensions: ['glb'],
mimeType: 'model/gltf-binary',
binary: true,
parse: function () {
var _parse = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(arrayBuffer, options) {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", parseSync(arrayBuffer, options));
case 1:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function parse(_x, _x2) {
return _parse.apply(this, arguments);
}
return parse;
}(),
parseSync: parseSync,

@@ -20,0 +46,0 @@ defaultOptions: {

@@ -15,2 +15,3 @@ "use strict";

extensions: ['glb'],
mimeType: 'model/gltf-binary',
encodeSync: encodeSync,

@@ -17,0 +18,0 @@ binary: true

@@ -26,3 +26,3 @@ "use strict";

var DEFAULT_OPTIONS = {
var defaultOptions = {
gltf: {

@@ -33,2 +33,14 @@ parserVersion: 1

};
var _default = {
name: 'glTF',
extensions: ['gltf', 'glb'],
mimeType: 'model/gltf+json',
text: true,
binary: true,
test: 'glTF',
parse: parse,
parseSync: parseSync,
defaultOptions: defaultOptions
};
exports["default"] = _default;

@@ -42,2 +54,3 @@ function parse(_x) {

var options,
context,
gltfParser,

@@ -55,6 +68,7 @@ _options2,

options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
context = _args.length > 2 ? _args[2] : undefined;
options = _objectSpread({}, defaultOptions, {}, options);
if (!(options.gltf.parserVersion !== 2 && options.useGLTFParser !== false)) {
_context.next = 5;
_context.next = 6;
break;

@@ -66,12 +80,12 @@ }

case 5:
case 6:
_options2 = options, _options2$byteOffset = _options2.byteOffset, byteOffset = _options2$byteOffset === void 0 ? 0 : _options2$byteOffset;
gltf = {};
_context.next = 9;
return (0, _parseGltf.parseGLTF)(gltf, arrayBuffer, byteOffset, options);
_context.next = 10;
return (0, _parseGltf.parseGLTF)(gltf, arrayBuffer, byteOffset, options, context);
case 9:
case 10:
return _context.abrupt("return", _context.sent);
case 10:
case 11:
case "end":

@@ -88,3 +102,4 @@ return _context.stop();

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
var context = arguments.length > 2 ? arguments[2] : undefined;
options = _objectSpread({}, defaultOptions, {}, options);

@@ -99,16 +114,4 @@ if (options.gltf.parserVersion !== 2 && options.useGLTFParser !== false) {

var gltf = {};
return (0, _parseGltf.parseGLTFSync)(gltf, arrayBuffer, byteOffset, options);
return (0, _parseGltf.parseGLTFSync)(gltf, arrayBuffer, byteOffset, options, context);
}
var _default = {
name: 'glTF',
extensions: ['gltf', 'glb'],
text: true,
binary: true,
test: 'glTF',
parse: parse,
parseSync: parseSync,
defaultOptions: DEFAULT_OPTIONS
};
exports["default"] = _default;
//# sourceMappingURL=gltf-loader.js.map

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

var _default = {
name: 'glTF',
extensions: ['glb'],
mimeType: 'model/gltf+json',
encodeSync: encodeSync,
binary: true,
defaultOptions: {
useGLTFBuilder: true
}
};
exports["default"] = _default;
function encodeSync(gltf) {

@@ -21,13 +33,2 @@ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};

}
var _default = {
name: 'glTF',
extensions: ['glb'],
encodeSync: encodeSync,
binary: true,
defaultOptions: {
useGLTFBuilder: true
}
};
exports["default"] = _default;
//# sourceMappingURL=gltf-writer.js.map

@@ -20,4 +20,2 @@ "use strict";

var _core = require("@loaders.gl/core");
var _assert = _interopRequireDefault(require("./utils/assert"));

@@ -41,5 +39,3 @@

createImages: false,
fetch: _core.fetchFile,
decompress: false,
DracoLoader: null,
postProcess: false,

@@ -64,2 +60,3 @@ log: console

options,
context,
promises,

@@ -75,4 +72,5 @@ _promise,

byteOffset = _args.length > 2 && _args[2] !== undefined ? _args[2] : 0;
options = _args.length > 3 && _args[3] !== undefined ? _args[3] : {};
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
options = _args.length > 3 ? _args[3] : undefined;
context = _args.length > 4 ? _args[4] : undefined;
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options.gltf);
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);

@@ -82,3 +80,3 @@ promises = [];

if (options.fetchImages) {
_promise = fetchImages(gltf, options);
_promise = fetchImages(gltf, options, context);
promises.push(_promise);

@@ -88,19 +86,19 @@ }

if (!options.fetchLinkedResources) {
_context.next = 9;
_context.next = 10;
break;
}
_context.next = 9;
return fetchBuffers(gltf, options);
_context.next = 10;
return fetchBuffers(gltf, options, context);
case 9:
promise = (0, _extensions.decodeExtensions)(gltf, options);
case 10:
promise = (0, _extensions.decodeExtensions)(gltf, options, context);
promises.push(promise);
_context.next = 13;
_context.next = 14;
return Promise.all(promises);
case 13:
case 14:
return _context.abrupt("return", options.postProcess ? (0, _postProcessGltf["default"])(gltf, options) : gltf);
case 14:
case 15:
case "end":

@@ -117,3 +115,4 @@ return _context.stop();

var byteOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var options = arguments.length > 3 ? arguments[3] : undefined;
var context = arguments.length > 4 ? arguments[4] : undefined;
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);

@@ -170,3 +169,3 @@ parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);

function fetchBuffers(_x3, _x4) {
function fetchBuffers(_x3, _x4, _x5) {
return _fetchBuffers.apply(this, arguments);

@@ -176,3 +175,3 @@ }

function _fetchBuffers() {
_fetchBuffers = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(gltf, options) {
_fetchBuffers = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(gltf, options, context) {
var i, buffer, fetch, uri, response, arrayBuffer;

@@ -187,3 +186,3 @@ return _regenerator["default"].wrap(function _callee2$(_context2) {

if (!(i < gltf.json.buffers.length)) {
_context2.next = 19;
_context2.next = 21;
break;

@@ -194,23 +193,28 @@ }

if (!options.uri) {
console.warn('options.uri must be set to decode embedded glTF buffers');
if (!buffer.uri) {
_context2.next = 18;
break;
}
if (!(buffer.uri && options.uri)) {
_context2.next = 16;
if (options.uri) {
_context2.next = 7;
break;
}
fetch = options.fetch || window.fetch;
console.warn('options.uri must be set to decode embedded glTF buffers');
return _context2.abrupt("return");
case 7:
fetch = context.fetch;
(0, _assert["default"])(fetch);
uri = (0, _gltfUtils.getFullUri)(buffer.uri, options.uri);
_context2.next = 10;
_context2.next = 12;
return fetch(uri);
case 10:
case 12:
response = _context2.sent;
_context2.next = 13;
_context2.next = 15;
return response.arrayBuffer();
case 13:
case 15:
arrayBuffer = _context2.sent;

@@ -224,3 +228,3 @@ gltf.buffers[i] = {

case 16:
case 18:
++i;

@@ -230,3 +234,3 @@ _context2.next = 1;

case 19:
case 21:
case "end":

@@ -270,3 +274,3 @@ return _context2.stop();

function fetchImages(_x5, _x6) {
function fetchImages(_x6, _x7, _x8) {
return _fetchImages.apply(this, arguments);

@@ -276,3 +280,3 @@ }

function _fetchImages() {
_fetchImages = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(gltf, options) {
_fetchImages = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(gltf, options, context) {
var images, promises, i, image;

@@ -310,3 +314,3 @@ return _regenerator["default"].wrap(function _callee3$(_context3) {

function fetchAndParseLinkedImage(_x7, _x8, _x9, _x10) {
function fetchAndParseLinkedImage(_x9, _x10, _x11, _x12, _x13) {
return _fetchAndParseLinkedImage.apply(this, arguments);

@@ -316,4 +320,4 @@ }

function _fetchAndParseLinkedImage() {
_fetchAndParseLinkedImage = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(gltf, image, i, options) {
var fetch, uri;
_fetchAndParseLinkedImage = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(gltf, image, i, options, context) {
var uri;
return _regenerator["default"].wrap(function _callee4$(_context4) {

@@ -323,6 +327,4 @@ while (1) {

case 0:
fetch = options.fetch || window.fetch;
(0, _assert["default"])(fetch);
uri = (0, _gltfUtils.getFullUri)(image.uri, options.uri);
_context4.next = 5;
_context4.next = 3;
return new Promise(function (resolve, reject) {

@@ -343,6 +345,6 @@ var img = new Image();

case 5:
case 3:
gltf.images[i] = _context4.sent;
case 6:
case 4:
case "end":

@@ -349,0 +351,0 @@ return _context4.stop();

import parseGLBSync from './lib/parse-glb';
export default {
name: 'GLB',
extension: ['glb'],
text: true,
extensions: ['glb'],
mimeType: 'model/gltf-binary',
binary: true,
parse: async (arrayBuffer, options) => parseSync(arrayBuffer, options),
parseSync,

@@ -8,0 +9,0 @@ defaultOptions: {

@@ -5,2 +5,3 @@ import encodeGLBSync from './lib/encode-glb';

extensions: ['glb'],
mimeType: 'model/gltf-binary',
encodeSync,

@@ -7,0 +8,0 @@ binary: true

@@ -9,3 +9,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import GLTFParser from './lib/deprecated/gltf-parser';
const DEFAULT_OPTIONS = {
const defaultOptions = {
gltf: {

@@ -16,4 +16,15 @@ parserVersion: 1

};
export async function parse(arrayBuffer, options = {}) {
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
export default {
name: 'glTF',
extensions: ['gltf', 'glb'],
mimeType: 'model/gltf+json',
text: true,
binary: true,
test: 'glTF',
parse,
parseSync,
defaultOptions
};
export async function parse(arrayBuffer, options = {}, context) {
options = _objectSpread({}, defaultOptions, {}, options);

@@ -29,6 +40,6 @@ if (options.gltf.parserVersion !== 2 && options.useGLTFParser !== false) {

const gltf = {};
return await parseGLTF(gltf, arrayBuffer, byteOffset, options);
return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
}
export function parseSync(arrayBuffer, options = {}) {
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
export function parseSync(arrayBuffer, options = {}, context) {
options = _objectSpread({}, defaultOptions, {}, options);

@@ -43,14 +54,4 @@ if (options.gltf.parserVersion !== 2 && options.useGLTFParser !== false) {

const gltf = {};
return parseGLTFSync(gltf, arrayBuffer, byteOffset, options);
return parseGLTFSync(gltf, arrayBuffer, byteOffset, options, context);
}
export default {
name: 'glTF',
extensions: ['gltf', 'glb'],
text: true,
binary: true,
test: 'glTF',
parse,
parseSync,
defaultOptions: DEFAULT_OPTIONS
};
//# sourceMappingURL=gltf-loader.js.map
import { encodeGLTFSync } from './lib/encode-gltf';
export default {
name: 'glTF',
extensions: ['glb'],
mimeType: 'model/gltf+json',
encodeSync,
binary: true,
defaultOptions: {
useGLTFBuilder: true
}
};

@@ -13,12 +23,2 @@ function encodeSync(gltf, options = {}) {

}
export default {
name: 'glTF',
extensions: ['glb'],
encodeSync,
binary: true,
defaultOptions: {
useGLTFBuilder: true
}
};
//# sourceMappingURL=gltf-writer.js.map

@@ -7,3 +7,2 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import { fetchFile } from '@loaders.gl/core';
import assert from './utils/assert';

@@ -18,5 +17,3 @@ import { getFullUri } from './gltf-utils/gltf-utils';

createImages: false,
fetch: fetchFile,
decompress: false,
DracoLoader: null,
postProcess: false,

@@ -30,4 +27,4 @@ log: console

}
export async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options = {}) {
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
export async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options.gltf);
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);

@@ -37,3 +34,3 @@ const promises = [];

if (options.fetchImages) {
const promise = fetchImages(gltf, options);
const promise = fetchImages(gltf, options, context);
promises.push(promise);

@@ -43,6 +40,6 @@ }

if (options.fetchLinkedResources) {
await fetchBuffers(gltf, options);
await fetchBuffers(gltf, options, context);
}
const promise = decodeExtensions(gltf, options);
const promise = decodeExtensions(gltf, options, context);
promises.push(promise);

@@ -52,3 +49,3 @@ await Promise.all(promises);

}
export function parseGLTFSync(gltf, arrayBufferOrString, byteOffset = 0, options = {}) {
export function parseGLTFSync(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);

@@ -105,12 +102,15 @@ parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);

async function fetchBuffers(gltf, options) {
async function fetchBuffers(gltf, options, context) {
for (let i = 0; i < gltf.json.buffers.length; ++i) {
const buffer = gltf.json.buffers[i];
if (!options.uri) {
console.warn('options.uri must be set to decode embedded glTF buffers');
}
if (buffer.uri) {
if (!options.uri) {
console.warn('options.uri must be set to decode embedded glTF buffers');
return;
}
if (buffer.uri && options.uri) {
const fetch = options.fetch || window.fetch;
const {
fetch
} = context;
assert(fetch);

@@ -138,3 +138,3 @@ const uri = getFullUri(buffer.uri, options.uri);

async function fetchImages(gltf, options) {
async function fetchImages(gltf, options, context) {
const images = gltf.json.images || [];

@@ -154,5 +154,3 @@ const promises = [];

async function fetchAndParseLinkedImage(gltf, image, i, options) {
const fetch = options.fetch || window.fetch;
assert(fetch);
async function fetchAndParseLinkedImage(gltf, image, i, options, context) {
const uri = getFullUri(image.uri, options.uri);

@@ -159,0 +157,0 @@ gltf.images[i] = await new Promise((resolve, reject) => {

@@ -0,7 +1,31 @@

import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import parseGLBSync from './lib/parse-glb';
export default {
name: 'GLB',
extension: ['glb'],
text: true,
extensions: ['glb'],
mimeType: 'model/gltf-binary',
binary: true,
parse: function () {
var _parse = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(arrayBuffer, options) {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
return _context.abrupt("return", parseSync(arrayBuffer, options));
case 1:
case "end":
return _context.stop();
}
}
}, _callee);
}));
function parse(_x, _x2) {
return _parse.apply(this, arguments);
}
return parse;
}(),
parseSync: parseSync,

@@ -8,0 +32,0 @@ defaultOptions: {

@@ -5,2 +5,3 @@ import encodeGLBSync from './lib/encode-glb';

extensions: ['glb'],
mimeType: 'model/gltf-binary',
encodeSync: encodeSync,

@@ -7,0 +8,0 @@ binary: true

@@ -11,3 +11,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

import GLTFParser from './lib/deprecated/gltf-parser';
var DEFAULT_OPTIONS = {
var defaultOptions = {
gltf: {

@@ -18,2 +18,13 @@ parserVersion: 1

};
export default {
name: 'glTF',
extensions: ['gltf', 'glb'],
mimeType: 'model/gltf+json',
text: true,
binary: true,
test: 'glTF',
parse: parse,
parseSync: parseSync,
defaultOptions: defaultOptions
};
export function parse(_x) {

@@ -26,2 +37,3 @@ return _parse.apply(this, arguments);

var options,
context,
gltfParser,

@@ -39,6 +51,7 @@ _options2,

options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {};
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
context = _args.length > 2 ? _args[2] : undefined;
options = _objectSpread({}, defaultOptions, {}, options);
if (!(options.gltf.parserVersion !== 2 && options.useGLTFParser !== false)) {
_context.next = 5;
_context.next = 6;
break;

@@ -50,12 +63,12 @@ }

case 5:
case 6:
_options2 = options, _options2$byteOffset = _options2.byteOffset, byteOffset = _options2$byteOffset === void 0 ? 0 : _options2$byteOffset;
gltf = {};
_context.next = 9;
return parseGLTF(gltf, arrayBuffer, byteOffset, options);
_context.next = 10;
return parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
case 9:
case 10:
return _context.abrupt("return", _context.sent);
case 10:
case 11:
case "end":

@@ -72,3 +85,4 @@ return _context.stop();

var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
var context = arguments.length > 2 ? arguments[2] : undefined;
options = _objectSpread({}, defaultOptions, {}, options);

@@ -83,14 +97,4 @@ if (options.gltf.parserVersion !== 2 && options.useGLTFParser !== false) {

var gltf = {};
return parseGLTFSync(gltf, arrayBuffer, byteOffset, options);
return parseGLTFSync(gltf, arrayBuffer, byteOffset, options, context);
}
export default {
name: 'glTF',
extensions: ['gltf', 'glb'],
text: true,
binary: true,
test: 'glTF',
parse: parse,
parseSync: parseSync,
defaultOptions: DEFAULT_OPTIONS
};
//# sourceMappingURL=gltf-loader.js.map
import { encodeGLTFSync } from './lib/encode-gltf';
export default {
name: 'glTF',
extensions: ['glb'],
mimeType: 'model/gltf+json',
encodeSync: encodeSync,
binary: true,
defaultOptions: {
useGLTFBuilder: true
}
};

@@ -13,12 +23,2 @@ function encodeSync(gltf) {

}
export default {
name: 'glTF',
extensions: ['glb'],
encodeSync: encodeSync,
binary: true,
defaultOptions: {
useGLTFBuilder: true
}
};
//# sourceMappingURL=gltf-writer.js.map

@@ -9,3 +9,2 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

import { fetchFile } from '@loaders.gl/core';
import assert from './utils/assert';

@@ -20,5 +19,3 @@ import { getFullUri } from './gltf-utils/gltf-utils';

createImages: false,
fetch: fetchFile,
decompress: false,
DracoLoader: null,
postProcess: false,

@@ -41,2 +38,3 @@ log: console

options,
context,
promises,

@@ -52,4 +50,5 @@ _promise,

byteOffset = _args.length > 2 && _args[2] !== undefined ? _args[2] : 0;
options = _args.length > 3 && _args[3] !== undefined ? _args[3] : {};
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);
options = _args.length > 3 ? _args[3] : undefined;
context = _args.length > 4 ? _args[4] : undefined;
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options.gltf);
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);

@@ -59,3 +58,3 @@ promises = [];

if (options.fetchImages) {
_promise = fetchImages(gltf, options);
_promise = fetchImages(gltf, options, context);
promises.push(_promise);

@@ -65,19 +64,19 @@ }

if (!options.fetchLinkedResources) {
_context.next = 9;
_context.next = 10;
break;
}
_context.next = 9;
return fetchBuffers(gltf, options);
_context.next = 10;
return fetchBuffers(gltf, options, context);
case 9:
promise = decodeExtensions(gltf, options);
case 10:
promise = decodeExtensions(gltf, options, context);
promises.push(promise);
_context.next = 13;
_context.next = 14;
return Promise.all(promises);
case 13:
case 14:
return _context.abrupt("return", options.postProcess ? postProcessGLTF(gltf, options) : gltf);
case 14:
case 15:
case "end":

@@ -94,3 +93,4 @@ return _context.stop();

var byteOffset = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var options = arguments.length > 3 ? arguments[3] : undefined;
var context = arguments.length > 4 ? arguments[4] : undefined;
options = _objectSpread({}, DEFAULT_OPTIONS, {}, options);

@@ -147,3 +147,3 @@ parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);

function fetchBuffers(_x3, _x4) {
function fetchBuffers(_x3, _x4, _x5) {
return _fetchBuffers.apply(this, arguments);

@@ -153,3 +153,3 @@ }

function _fetchBuffers() {
_fetchBuffers = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(gltf, options) {
_fetchBuffers = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(gltf, options, context) {
var i, buffer, fetch, uri, response, arrayBuffer;

@@ -164,3 +164,3 @@ return _regeneratorRuntime.wrap(function _callee2$(_context2) {

if (!(i < gltf.json.buffers.length)) {
_context2.next = 19;
_context2.next = 21;
break;

@@ -171,23 +171,28 @@ }

if (!options.uri) {
console.warn('options.uri must be set to decode embedded glTF buffers');
if (!buffer.uri) {
_context2.next = 18;
break;
}
if (!(buffer.uri && options.uri)) {
_context2.next = 16;
if (options.uri) {
_context2.next = 7;
break;
}
fetch = options.fetch || window.fetch;
console.warn('options.uri must be set to decode embedded glTF buffers');
return _context2.abrupt("return");
case 7:
fetch = context.fetch;
assert(fetch);
uri = getFullUri(buffer.uri, options.uri);
_context2.next = 10;
_context2.next = 12;
return fetch(uri);
case 10:
case 12:
response = _context2.sent;
_context2.next = 13;
_context2.next = 15;
return response.arrayBuffer();
case 13:
case 15:
arrayBuffer = _context2.sent;

@@ -201,3 +206,3 @@ gltf.buffers[i] = {

case 16:
case 18:
++i;

@@ -207,3 +212,3 @@ _context2.next = 1;

case 19:
case 21:
case "end":

@@ -247,3 +252,3 @@ return _context2.stop();

function fetchImages(_x5, _x6) {
function fetchImages(_x6, _x7, _x8) {
return _fetchImages.apply(this, arguments);

@@ -253,3 +258,3 @@ }

function _fetchImages() {
_fetchImages = _asyncToGenerator(_regeneratorRuntime.mark(function _callee3(gltf, options) {
_fetchImages = _asyncToGenerator(_regeneratorRuntime.mark(function _callee3(gltf, options, context) {
var images, promises, i, image;

@@ -287,3 +292,3 @@ return _regeneratorRuntime.wrap(function _callee3$(_context3) {

function fetchAndParseLinkedImage(_x7, _x8, _x9, _x10) {
function fetchAndParseLinkedImage(_x9, _x10, _x11, _x12, _x13) {
return _fetchAndParseLinkedImage.apply(this, arguments);

@@ -293,4 +298,4 @@ }

function _fetchAndParseLinkedImage() {
_fetchAndParseLinkedImage = _asyncToGenerator(_regeneratorRuntime.mark(function _callee4(gltf, image, i, options) {
var fetch, uri;
_fetchAndParseLinkedImage = _asyncToGenerator(_regeneratorRuntime.mark(function _callee4(gltf, image, i, options, context) {
var uri;
return _regeneratorRuntime.wrap(function _callee4$(_context4) {

@@ -300,6 +305,4 @@ while (1) {

case 0:
fetch = options.fetch || window.fetch;
assert(fetch);
uri = getFullUri(image.uri, options.uri);
_context4.next = 5;
_context4.next = 3;
return new Promise(function (resolve, reject) {

@@ -320,6 +323,6 @@ var img = new Image();

case 5:
case 3:
gltf.images[i] = _context4.sent;
case 6:
case 4:
case "end":

@@ -326,0 +329,0 @@ return _context4.stop();

{
"name": "@loaders.gl/gltf",
"version": "1.3.0",
"version": "1.3.1",
"description": "Framework-independent loader for the glTF format",

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

"dependencies": {
"@loaders.gl/core": "1.3.0",
"@loaders.gl/images": "1.3.0",
"@loaders.gl/loader-utils": "1.3.0"
"@loaders.gl/core": "1.3.1",
"@loaders.gl/images": "1.3.1",
"@loaders.gl/loader-utils": "1.3.1"
},
"gitHead": "4d3e7ecfc49016fdeb3a37d5432d35c7f6ce3e30"
"gitHead": "d1e0103b82f81c574f7acba46b645ab9d74e3f06"
}

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

// Binary container format for glTF
// Binary container format for GLB

@@ -7,5 +7,6 @@ import parseGLBSync from './lib/parse-glb';

name: 'GLB',
extension: ['glb'],
text: true,
extensions: ['glb'],
mimeType: 'model/gltf-binary',
binary: true,
parse: async (arrayBuffer, options) => parseSync(arrayBuffer, options),
parseSync,

@@ -12,0 +13,0 @@ defaultOptions: {

@@ -6,2 +6,3 @@ import encodeGLBSync from './lib/encode-glb';

extensions: ['glb'],
mimeType: 'model/gltf-binary',
encodeSync,

@@ -8,0 +9,0 @@ binary: true

@@ -6,3 +6,3 @@ // Binary container format for glTF

const DEFAULT_OPTIONS = {
const defaultOptions = {
gltf: {

@@ -14,6 +14,20 @@ parserVersion: 1 // the new parser that will be the only option in V2.

export async function parse(arrayBuffer, options = {}) {
export default {
name: 'glTF',
extensions: ['gltf', 'glb'],
// mimeType: 'model/gltf-binary',
mimeType: 'model/gltf+json',
text: true,
binary: true,
test: 'glTF',
parse,
parseSync, // Less features when parsing synchronously
defaultOptions
};
export async function parse(arrayBuffer, options = {}, context) {
// Apps like to call the parse method directly so apply default options here
options = {...DEFAULT_OPTIONS, ...options};
// Deprecated: Return GLTFParser instance
options = {...defaultOptions, ...options};
// Deprecated v1 Parser: Returns `GLTFParser` instance, instead of "pure" js object
if (options.gltf.parserVersion !== 2 && options.useGLTFParser !== false) {

@@ -24,11 +38,10 @@ const gltfParser = new GLTFParser();

// Return pure javascript object
const {byteOffset = 0} = options;
const gltf = {};
return await parseGLTF(gltf, arrayBuffer, byteOffset, options);
return await parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
}
export function parseSync(arrayBuffer, options = {}) {
export function parseSync(arrayBuffer, options = {}, context) {
// Apps like to call the parse method directly so apply default options here
options = {...DEFAULT_OPTIONS, ...options};
options = {...defaultOptions, ...options};

@@ -43,14 +56,3 @@ // Deprecated: Return GLTFParser instance

const gltf = {};
return parseGLTFSync(gltf, arrayBuffer, byteOffset, options);
return parseGLTFSync(gltf, arrayBuffer, byteOffset, options, context);
}
export default {
name: 'glTF',
extensions: ['gltf', 'glb'],
text: true,
binary: true,
test: 'glTF',
parse,
parseSync, // Less features when parsing synchronously
defaultOptions: DEFAULT_OPTIONS
};
import {encodeGLTFSync} from './lib/encode-gltf';
export default {
name: 'glTF',
extensions: ['glb'], // We only support encoding to binary GLB, not to JSON GLTF
// mimeType: 'model/gltf-binary',
mimeType: 'model/gltf+json',
encodeSync,
binary: true,
defaultOptions: {
useGLTFBuilder: true // Note: GLTFBuilder will be removed in v2
}
};
function encodeSync(gltf, options = {}) {

@@ -14,11 +26,1 @@ const {byteOffset = 0} = options;

}
export default {
name: 'glTF',
extensions: ['glb'], // We only support encoding to binary GLB, not to JSON GLTF
encodeSync,
binary: true,
defaultOptions: {
useGLTFBuilder: true // Note: GLTFBuilder will be removed in v2
}
};
/* eslint-disable camelcase, max-statements, no-restricted-globals */
/* global TextDecoder */
import {fetchFile} from '@loaders.gl/core';
import assert from './utils/assert';

@@ -14,5 +13,3 @@ import {getFullUri} from './gltf-utils/gltf-utils';

createImages: false, // Create image objects
fetch: fetchFile,
decompress: false, // Decompress Draco compressed meshes (if DracoLoader available)
DracoLoader: null,
decompress: false, // Decompress Draco compressed meshes
postProcess: false,

@@ -28,4 +25,4 @@ log: console // eslint-disable-line

export async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options = {}) {
options = {...DEFAULT_OPTIONS, ...options};
export async function parseGLTF(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
options = {...DEFAULT_OPTIONS, ...options.gltf};

@@ -37,3 +34,3 @@ parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options);

if (options.fetchImages) {
const promise = fetchImages(gltf, options);
const promise = fetchImages(gltf, options, context);
promises.push(promise);

@@ -44,6 +41,6 @@ }

if (options.fetchLinkedResources) {
await fetchBuffers(gltf, options);
await fetchBuffers(gltf, options, context);
}
const promise = decodeExtensions(gltf, options);
const promise = decodeExtensions(gltf, options, context);
promises.push(promise);

@@ -61,3 +58,3 @@

// eslint-disable-next-line complexity
export function parseGLTFSync(gltf, arrayBufferOrString, byteOffset = 0, options = {}) {
export function parseGLTFSync(gltf, arrayBufferOrString, byteOffset = 0, options, context) {
options = {...DEFAULT_OPTIONS, ...options};

@@ -133,13 +130,16 @@

// Asynchronously fetch and parse buffers, store in buffers array outside of json
async function fetchBuffers(gltf, options) {
async function fetchBuffers(gltf, options, context) {
for (let i = 0; i < gltf.json.buffers.length; ++i) {
const buffer = gltf.json.buffers[i];
// TODO - remove this defensive hack and auto-infer the base URI
if (!options.uri) {
// eslint-disable-next-line
console.warn('options.uri must be set to decode embedded glTF buffers');
}
if (buffer.uri && options.uri) {
const fetch = options.fetch || window.fetch;
if (buffer.uri) {
if (!options.uri) {
// TODO - remove this defensive hack and auto-infer the base URI
// eslint-disable-next-line
console.warn('options.uri must be set to decode embedded glTF buffers');
return;
}
const {fetch} = context;
assert(fetch);
const uri = getFullUri(buffer.uri, options.uri);

@@ -168,3 +168,3 @@ const response = await fetch(uri);

async function fetchImages(gltf, options) {
async function fetchImages(gltf, options, context) {
const images = gltf.json.images || [];

@@ -183,5 +183,5 @@

// Asynchronously fetches and parses one image, store in images array outside of json
async function fetchAndParseLinkedImage(gltf, image, i, options) {
const fetch = options.fetch || window.fetch;
assert(fetch);
async function fetchAndParseLinkedImage(gltf, image, i, options, context) {
// const fetch = options.fetch || window.fetch;
// assert(fetch);

@@ -188,0 +188,0 @@ /*

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

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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

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

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

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

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