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