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 2.0.0-alpha.1 to 2.0.0-alpha.2

dist/es5/lib/gltf-utils/resolve-url.js

2

dist/dist.min.js

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

!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var 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=18)}([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 u}));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,a=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/),u=a&&parseFloat(a[1])||0}).call(this,s(11),s(6))},,function(e,t,s){"use strict";(function(e,r){s.d(t,"b",(function(){return n})),s.d(t,"a",(function(){return o}));const n="object"!=typeof e||"[object process]"!==String(e)||e.browser,i={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==r&&r,document:"undefined"!=typeof document&&document},o=i.global||i.self||i.window,a=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/);a&&parseFloat(a[1])}).call(this,s(11),s(6))},,,,function(e,t){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(e){"object"==typeof window&&(s=window)}e.exports=s},function(e,t){},,,,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 a(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 u,f=[],c=!1,h=-1;function l(){c&&u&&(c=!1,u.length?f=u.concat(f):h=-1,f.length&&g())}function g(){if(!c){var e=a(l);c=!0;for(var t=f.length;t;){for(u=f,f=[];++h<t;)u&&u[h].run();h=-1,t=f.length}u=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||a(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){(function(t){const r=s(19),n="undefined"==typeof window?t:window;n.loaders=n.loaders||{},e.exports=Object.assign(n.loaders,r)}).call(this,s(6))},function(e,t,s){"use strict";s.r(t);var r={};s.r(r),s.d(r,"decode",(function(){return K})),s.d(r,"encode",(function(){return J}));var n={};s.r(n),s.d(n,"decode",(function(){return Z})),s.d(n,"encode",(function(){return ee}));var i={};s.r(i),s.d(i,"decode",(function(){return te})),s.d(i,"encode",(function(){return se}));const o="KHR_draco_mesh_compression",a="UBER_draco_point_cloud_compression",u="KHR_lights_punctual",f="KHR_materials_unlit";function c(e,t){if(!e)throw new Error(t)}var h=s(2);const l=!1,g=!0,d=new Map([["image/png",{test:m,getSize:function(e){return{width:e.getUint32(16,l),height:e.getUint32(20,l)}}}],["image/jpeg",{test:p,getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,l))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,l);if(s.has(n))return{height:e.getUint16(r+5,l),width:e.getUint16(r+7,l)};if(!t.has(n))return null;r+=2,r+=e.getUint16(r,l)}return null}}],["image/gif",{test:b,getSize:function(e){return{width:e.getUint16(6,g),height:e.getUint16(8,g)}}}],["image/bmp",{test:y,getSize:function(e){return{width:e.getUint32(18,g),height:e.getUint32(22,g)}}}]]);function m(e){return e.byteLength>=24&&2303741511===e.getUint32(0,l)}function b(e){return e.byteLength>=10&&1195984440===e.getUint32(0,l)}function y(e){return e.byteLength>=2&&16973===e.getUint16(0,l)}function p(e){return e.byteLength>=3&&65496===e.getUint16(0,l)&&255===e.getUint8(2,l)}const w=`Invalid MIME type. Supported MIME types are: ${Array.from(d.keys()).join(", ")}`;function x(e){const t=j(e);for(const[e,{test:s}]of d.entries())if(s(t))return e;return null}function _(e,t=null){const s=function(e,t=null){t=t||x(e);const{getSize:s}=T(t),r=s(j(e));if(!r)throw new Error(`invalid image data for type: ${t}`);return r}(e,t=t||x(e));return s.mimeType=t,s}function T(e){const t=d.get(e);if(!t)throw new Error(w);return t}function j(e){if((e=e.buffer||e)instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}const E=Boolean(h.a._parseImageNode);const A=void 0!==typeof Image;async function v(e,t){const s=new Image;return s.crossOrigin=t&&t.crossOrigin||"anonymous",t.images.decodeHTML&&s.decode?await s.decode():await new Promise((t,r)=>{try{s.onload=()=>t(s),s.onerror=t=>r(new Error(`Could not load image ${e}: ${t}`)),s.src=e}catch(e){r(e)}})}const B="undefined"!=typeof ImageBitmap;const R={name:"Images",extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,s){const{url:r}=s;if(r&&/\.svg((\?|#).*)?$/.test(r))return await async function(e,t){const s=(new TextDecoder).decode(e),r=`data:image/svg+xml;base64,${btoa(s)}`;return await v(r,t)}(e,t);switch(function(e={}){const t=(e.image||{}).format||"auto";switch(t){case"imagebitmap":return c(B),t;case"html":return c(A),t;default:case"auto":if(E)return"ndarray";if(!h.b)throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");return B?"imagebitmap":A?"html":c(!1)}}(t)){case"imagebitmap":return await function(e,t){const s=new Blob([new Uint8Array(e)]);return createImageBitmap(s)}(e);case"html":return await async function(e,t){const s=new Blob([e],{type:"image/jpeg"}),r=self.URL||self.webkitURL,n=r.createObjectURL(s);try{return await v(n,t)}finally{r.revokeObjectURL(n)}}(e,t);case"ndarray":return await function(e,t){c(h.a._parseImageNode);const{mimeType:s}=_(e);return h.a._parseImageNode(e,s,t)}(e,t);default:return c(!1)}},test:e=>{const t=new DataView(e);return p(t)||y(t)||b(t)||m(t)},options:{images:{format:"auto",decodeHTML:!0}}};var L=R;function U(e,t,s){if(e.byteLength<=t+s)return"";const r=new DataView(e);let n="";for(let e=0;e<s;e++)n+=String.fromCharCode(r.getUint8(t+e));return n}function V(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return U(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return U(e,0,t)}return""}(e)}"`)}}function O(e){return e+3&-4}function S(e,t,s){const r=s?new Uint8Array(e).subarray(t,t+s):new Uint8Array(e).subarray(t);return new Uint8Array(r).buffer}function I(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+O(r.byteLength)}function M(e,t){if(!e)throw new Error(t||"gltf/glb assertion failed.")}const P=["SCALAR","VEC2","VEC3","VEC4"],k=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126]]),C={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},F={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},D={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function $(e){return P[e-1]||P[0]}function N(e){const t=k.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function q(e,t){const s=D[e.componentType],r=C[e.type],n=F[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 G(e,t){return e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:")?e:t.substr(0,t.lastIndexOf("/")+1)+e}function W(e,t,s){const r=e.bufferViews[s];M(r);const n=t[r.buffer];M(n);const i=(r.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,i,r.byteLength)}class X{constructor(e){if(e instanceof X)return e;e||(e={json:{version:2,buffers:[]},buffers:[]}),this.gltf=e,M(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),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.json[e]&&this.json[e][t];if(!s)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return s}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,s=this.gltf.buffers[t];M(s);const r=(e.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,r,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),s=this.getBuffer(t.buffer).data,{ArrayType:r,length:n}=q(e,t);return new r(s,t.byteOffset+e.byteOffset,n)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(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}addObjectExtension(e,t,s){return M(s),e.extensions=e.extensions||{},e.extensions[t]=s,this.registerUsedExtension(t),this}removeObjectExtension(e,t){return delete(e.extensions||{})[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||x(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+=O(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:N(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=I(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 z(e){const t={};for(const s in e){const r=e[s];if("indices"!==s){const e=H(r);t[s]=e}}return t}function H(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:N(s)}}async function K(e,t,s){if(!t.gltf.decompressMeshes)return;const r=new X(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,o)&&n.push(Q(e,r,t,s));await Promise.all(n),r.removeExtension(o)}function J(e,t={}){const s=new X(e);for(const e of s.json.meshes||[])Y(e,t),s.addRequiredExtension(o)}async function Q(e,t,s,r){const n=t.getObjectExtension(e,o),i=t.getTypedArrayForBufferView(n.bufferView),a=S(i.buffer,i.byteOffset),{parse:u}=r,f=await u(a,s);e.attributes=z(f.attributes),f.indices&&(e.indices=H(f.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("Empty glTF primitive detected: Draco decompression failure?")}(e)}function Y(e,t,s=4,r,n){if(!r.DracoWriter||!r.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");const i=r.DracoWriter.encodeSync({attributes:e}),{parseSync:a}=n,u=a({attributes:e}),f=r._addFauxAttributes(u.attributes),c=r.addBufferView(i);return{primitives:[{attributes:f,mode:s,extensions:{[o]:{bufferView:c,attributes:f}}}]}}function Z(e,t){const s=new X(e),{json:r}=s,n=s.getExtension(u);n&&(s.json.lights=n.lights,s.removeExtension(u));for(const e of r.nodes||[]){const t=s.getObjectExtension(e,u);t&&(e.light=t.light),s.removeObjectExtension(e,u)}}function ee(e,t){const s=new X(e),{json:r}=s;if(r.lights){const e=s.addExtensions(u);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,u,e)}delete s.json.lights}}function te(e,t){const s=new X(e),{json:r}=s;s.removeExtension(f);for(const e of r.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),s.removeObjectExtension(e,f)}}function se(e,t){const s=new X(e),{json:r}=s;if(s.materials)for(const e of r.materials)e.unlit&&(delete e.unlit,s.addObjectExtension(e,f),s.addExtensions(f))}const re={KHR_draco_mesh_compression:r,KHR_lights_punctual:n,KHR_materials_unlit:i};function ne(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const ie=1735152710,oe=12,ae=8,ue=1313821514,fe=5130562,ce=0,he=1,le=!0;function ge(e,t=0,s={}){const r=new DataView(e),{magic:n=ie}=s,i=r.getUint32(t,!1);return i===n||i===ie}function de(e,t,s=0,r={}){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,s+0),e.version=n.getUint32(s+4,le);const i=n.getUint32(s+8,le);return e.header={byteOffset:s,byteLength:i},ne(2===e.version,`Invalid GLB version ${e.version}. Only supports v2.`),ne(e.header.byteLength>oe+ae),e.json={},e.hasBinChunk=!1,e.binChunks=[],function(e,t,s,r){for(;s+8<=e.header.byteLength;){const n=t.getUint32(s+0,le),i=t.getUint32(s+4,le);switch(s+=ae,i){case ue:me(e,t,s,n,r);break;case fe:be(e,t,s,n,r);break;case ce:r.glb.strict||me(e,t,s,n,r);break;case he:r.glb.strict||be(e,t,s,n,r)}s+=O(n)}}(e,n,s+oe,r),function(e){e.byteOffset=e.header.byteOffset,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),s+e.header.byteLength}function me(e,t,s,r,n){const i=new Uint8Array(t.buffer,s,r),o=new TextDecoder("utf8").decode(i);e.json=JSON.parse(o)}function be(e,t,s,r,n){e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:s,byteLength:r,arrayBuffer:t.buffer})}const ye={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},pe={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},we={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:we.TEXTURE_MAG_FILTER,minFilter:we.TEXTURE_MIN_FILTER,wrapS:we.TEXTURE_WRAP_S,wrapT:we.TEXTURE_WRAP_T},_e={[we.TEXTURE_MAG_FILTER]:we.LINEAR,[we.TEXTURE_MIN_FILTER]:we.NEAREST_MIPMAP_LINEAR,[we.TEXTURE_WRAP_S]:we.REPEAT,[we.TEXTURE_WRAP_]:we.REPEAT};class Te{postProcess(e,t={}){const{json:s,buffers:r=[],images:n=[],baseUri:i=""}=e;return M(s),this.baseUri=i,this.json=s,this.buffers=r,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,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])}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.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 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.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.id=e.id||`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(s=e.componentType,pe[s]),e.components=(r=e.type,ye[r]),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):_e,e.source=this.getImage(e.source),e}_resolveSampler(e,t){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 xe[e]}_resolveImage(e,t,s){e.id=e.id||`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const r=this.images[t];return r&&(e.image=r),e.getImageAsync=()=>(M(e.image),e.image),e}_resolveBufferView(e,t){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 je(e,t){return(new Te).postProcess(e,t)}async function Ee(e,t,s=0,r,n){!function(e,t,s,r){r.uri&&(e.baseUri=r.uri);if(t instanceof ArrayBuffer&&!ge(t,s,r)){const e=new TextDecoder;t=e.decode(t)}if("string"==typeof t)e.json=V(t);else if(t instanceof ArrayBuffer){const n={};s=de(n,t,s,r),M("glTF"===n.type,`Invalid GLB magic string ${n.type}`),e._glb=n,e.json=n.json}else M(!1,"GLTF: must be ArrayBuffer or string");const n=e.json.buffers||[];if(e.buffers=new Array(n.length).fill({}),e._glb&&e._glb.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const i=e.json.images||[];e.images=new Array(i.length).fill({})}(e,t,s,r);const i=[];if(r.gltf.loadImages){const t=async function(e,t,s){const r=e.json.images||[],n=[];for(let i=0;i<r.length;++i)n.push(Ae(e,r[i],i,t,s));return await Promise.all(n)}(e,r,n);i.push(t)}r.gltf.loadBuffers&&await async function(e,t,s){for(let r=0;r<e.json.buffers.length;++r){const n=e.json.buffers[r];if(n.uri){if(!t.uri)return void console.warn("options.uri must be set to decode embedded glTF buffers");const{fetch:i}=s;M(i);const o=G(n.uri,t.uri),a=await i(o),u=await a.arrayBuffer();e.buffers[r]={arrayBuffer:u,byteOffset:0,byteLength:u.byteLength},delete n.uri}}}(e,r,n);const o=async function(e,t={},s){t.gltf=t.gltf||{};for(const r in re){const n=t.gltf.excludeExtensions||{};if(!(r in n&&!n[r])){const n=re[r];await n.decode(e,t,s)}}}(e,r,n);return i.push(o),await Promise.all(i),r.gltf.postProcess?je(e,r):e}async function Ae(e,t,s,r,n){const{fetch:i,parse:o}=n;let a;if(t.uri){const e=G(t.uri,r.uri),s=await i(e);a=await s.arrayBuffer()}if(Number.isFinite(t.bufferView)){const s=W(e.json,e.buffers,t.bufferView);a=S(s.buffer,s.byteOffset,s.byteLength)}M(a,"glTF image has no data");const u=await o(a,L,{},n);e.images[s]=u}const ve=e=>(e=>"undefined"!=typeof File&&e instanceof File)(e)||(e=>"undefined"!=typeof Blob&&e instanceof Blob)(e);let Be="";const Re={};function Le(e){for(const t in Re)if(e.startsWith(t)){const s=Re[t];return e.replace(t,s)}return e+=Be}function Ue(e,t){if(!e)throw new Error(t||"loader assertion failed.")}class Ve{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}get 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;Ue(!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 Oe(e,t){return Promise.resolve(new Ve(e,t))}async function Se(e,t){return ve(e)?Oe(e,t):(e=Le(e),fetch(e,t))}new class{constructor(){this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}};var Ie=s(0);s(7);new Map;Ie.a.TextEncoder;const Me=Ie.a.TextDecoder;function Pe(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]+)/)){return["accessors",parseInt(t[1],10)]}}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 ke(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:Ce(e,r,t),images:Fe(e,r,t)}}function Ce(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}=q(i,o),r=new t(e,o.byteOffset,s);r.accessor=i,n.push(r)}}return n}function Fe(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 a=new Uint8Array(e,o.byteOffset,o.byteLength);a.imate=i,n.push(a)}return n}class De{static isGLB(e,t={}){return ge(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;de(this,this.glbArrayBuffer,e,t),this.binaryByteOffset=this.binChunkByteOffset,this.packedJson=this.json;const s=ke(this.glbArrayBuffer,this.json,this.binaryByteOffset);this.json=Pe(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=D[e.componentType],s=C[e.type],r=F[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 a=o.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),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 $e={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},Ne={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},qe={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},Ge={magFilter:qe.TEXTURE_MAG_FILTER,minFilter:qe.TEXTURE_MIN_FILTER,wrapS:qe.TEXTURE_WRAP_S,wrapT:qe.TEXTURE_WRAP_T},We={[qe.TEXTURE_MAG_FILTER]:qe.LINEAR,[qe.TEXTURE_MIN_FILTER]:qe.NEAREST_MIPMAP_LINEAR,[qe.TEXTURE_WRAP_S]:qe.REPEAT,[qe.TEXTURE_WRAP_]:qe.REPEAT};class Xe{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=Ne[e],e.components=$e[e],e.bytesPerElement=e.bytesPerComponent*e.components}_resolveTexture(e,t){e.id=`texture-${t}`,e.sampler="sampler"in e?this.getSampler(e.sampler):We,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 Ge[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=G(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 ze={fetchLinkedResources:!0,fetch:Se,decompress:!1,DracoLoader:null,postProcess:!0,createImages:!1,log:console};class He{async parse(e,t={}){if(t=Object.assign({},ze,t),this.parseSync(e,{...t,postProcess:!1,decompress:!1}),t.fetchLinkedResources&&await this._loadLinkedAssets(t),t.decompress&&this._decompressMeshes(t),t.postProcess){(new Xe).postProcess(this.gltf,this.glbParser,t)}return this.gltf}parseSync(e,t={}){if(t=Object.assign({},ze,t),e instanceof ArrayBuffer&&!De.isGLB(e,t)){e=(new Me).decode(e)}if("string"==typeof e&&(e=V(e)),e instanceof ArrayBuffer?(this.glbParser=new De,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 Xe).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=G(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(o),this._removeExtension(a)}}_decompressKhronosDracoPrimitive(e,t){const s=e.extensions&&e.extensions[o];if(!s)return;delete e.extensions[o];const r=this._getBufferViewArray(s.bufferView),n=t.DracoLoader.parseSync(r);e.attributes=z(n.attributes),n.indices&&(e.indices=H(n.indices))}_decompressUberDracoPrimitive(e,t){const s=e.extensions&&e.extensions[a];if(!s)return;if(0!==e.mode)throw new Error(a);delete e.extensions[a];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 Ke={name:"glTF",extensions:["gltf","glb"],mimeType:"model/gltf+json",text:!0,binary:!0,test:"glTF",parse:async function(e,t={},s){if((t={...Ke.options,...t}).gltf={...Ke.options.gltf,...t.gltf},Qe(t),2!==t.gltf.parserVersion&&!1!==t.useGLTFParser){return(new He).parse(e,t)}const{byteOffset:r=0}=t;return await Ee({},e,r,t,s)},options:{gltf:{parserVersion:1,loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},uri:"",log:console}};var Je=Ke;function Qe(e){"fetchImages"in e&&(e.gltf.loadImages=e.fetchImages),"createImages"in e&&(e.gltf.loadImages=e.createImages),"fetchLinkedResources"in e&&(e.gltf.fetchBuffers=e.fetchLinkedResources),"decompress"in e&&(e.gltf.decompressMeshes=e.decompress),"decompress"in e.gltf&&(e.gltf.decompressMeshes=e.gltf.decompress),"postProcess"in e&&(e.gltf.postProcess=e.postProcess)}function Ye(e,t,s,r){const n=O(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 Ze=1179937895,et=1313821514,tt=5130562,st=!0;function rt(e,t,s=0,r={}){const{magic:n=Ze,version:i=2,json:o={},binary:a}=e,u=s;t&&(t.setUint32(s+0,n,st),t.setUint32(s+4,i,st),t.setUint32(s+8,0,st));const f=s+8,c=s+=12;if(t&&(t.setUint32(s+0,0,st),t.setUint32(s+4,et,st)),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,st)}if(a){const e=s;if(t&&(t.setUint32(s+0,0,st),t.setUint32(s+4,tt,st)),s=Ye(t,s+=8,a),t){const r=s-e-8;t.setUint32(e+0,r,st)}}if(t){const e=s-u;t.setUint32(f,e,st)}return s}function nt(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),rt(e,t,s,r)}var it={name:"glTF",extensions:["glb"],mimeType:"model/gltf+json",encodeSync:function(e,t={}){const{byteOffset:s=0}=t,r=nt(e,null,s,t),n=new ArrayBuffer(r),i=new DataView(n);return nt(e,i,s,t),n},binary:!0,defaultOptions:{useGLTFBuilder:!0}};var ot={name:"GLB",extensions:["glb"],mimeType:"model/gltf-binary",binary:!0,parse:async(e,t)=>at(e,t),parseSync:at,options:{glb:{strict:!1}}};function at(e,t){const{byteOffset:s=0}=t,r={};return de(r,e,s,t),r}var ut={name:"GLB",extensions:["glb"],mimeType:"model/gltf-binary",encodeSync:function(e,t){const{byteOffset:s=0}=t,r=rt(e,null,s,t),n=new ArrayBuffer(r),i=new DataView(n);return rt(e,i,s,t),n},binary:!0,options:{glb:{}}};function ft(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;let o=0;for(;++i<t.length;){const a=t[i];Array.isArray(a)||ArrayBuffer.isView(a)?n=e(a,s,r,n):o<r&&(s[n++]=a,o++)}o>0&&o<r&&(s[n++]=0);return n})(e,t,s,0)}(e,s),s}function ct(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&&ft(n);if(!e)return n.map(e=>ct(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]=ct(n[r],t,s);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:s}=T(t);return s(j(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},s=rt(t,null,0,e),r=new ArrayBuffer(s);return rt(t,new DataView(r),0,e),r}addApplicationData(e,t,s={}){const r=s.packTypedArrays?ct(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:N(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+=O(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=I(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 lt extends ht{constructor(e={}){super(e),this.DracoWriter=e.DracoWriter,this.DracoLoader=e.DracoLoader}addApplicationData(e,t,s={}){const r=s.packTypedArrays?ct(t,this,s):t;return this.json[e]=r,this}addExtraData(e,t,s={}){const r=s.packedTypedArrays?ct(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?ct(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?ct(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(o);const r=this.DracoWriter.encodeSync({attributes:e}),n=this.DracoLoader.parseSync({attributes:e}),i=this._addFauxAttributes(n.attributes),a=this.addBufferView(r),u={primitives:[{attributes:i,mode:s,extensions:{[o]:{bufferView:a,attributes:i}}}]};return this.json.meshes=this.json.meshes||[],this.json.meshes.push(u),this.json.meshes.length-1}addCompressedPointCloud(e){if(!this.DracoWriter||!this.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");e.mode=0;const t=this.DracoWriter.encodeSync(e,{pointcloud:!0}),s=this.addBufferView(t),r={primitives:[{attributes:{},mode:0,extensions:{[a]:{bufferView:s}}}]};return this.registerRequiredExtension(a),this.json.meshes=this.json.meshes||[],this.json.meshes.push(r),this.json.meshes.length-1}addImage(e){const t=this.addBufferView(e),s=_(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 o})),s.d(t,"UBER_POINT_CLOUD_EXTENSION",(function(){return a})),s.d(t,"GLTFLoader",(function(){return Je})),s.d(t,"GLTFWriter",(function(){return it})),s.d(t,"GLBLoader",(function(){return ot})),s.d(t,"GLBWriter",(function(){return ut})),s.d(t,"GLTFScenegraph",(function(){return X})),s.d(t,"postProcessGLTF",(function(){return je})),s.d(t,"encodeGLTFSync",(function(){return nt})),s.d(t,"packBinaryJson",(function(){return ct})),s.d(t,"unpackBinaryJson",(function(){return Pe})),s.d(t,"GLBParser",(function(){return De})),s.d(t,"GLBBuilder",(function(){return ht})),s.d(t,"GLTFParser",(function(){return He})),s.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 n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var s=t[r]={i:r,l:!1,exports:{}};return e[r].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(r,s,function(t){return e[t]}.bind(null,s));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=4)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return o}));const s="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,a=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/);a&&parseFloat(a[1])}).call(this,n(5),n(3))},,,function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},function(e,t,n){(function(t){const r=n(6),s="undefined"==typeof window?t:window;s.loaders=s.loaders||{},e.exports=Object.assign(s.loaders,r)}).call(this,n(3))},function(e,t){var n,r,s=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(e){r=o}}();var u,f=[],c=!1,h=-1;function l(){c&&u&&(c=!1,u.length?f=u.concat(f):h=-1,f.length&&g())}function g(){if(!c){var e=a(l);c=!0;for(var t=f.length;t;){for(u=f,f=[];++h<t;)u&&u[h].run();h=-1,t=f.length}u=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(){}s.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];f.push(new d(e,t)),1!==f.length||c||a(g)},d.prototype.run=function(){this.fun.apply(null,this.array)},s.title="browser",s.browser=!0,s.env={},s.argv=[],s.version="",s.versions={},s.on=m,s.addListener=m,s.once=m,s.off=m,s.removeListener=m,s.removeAllListeners=m,s.emit=m,s.prependListener=m,s.prependOnceListener=m,s.listeners=function(e){return[]},s.binding=function(e){throw new Error("process.binding is not supported")},s.cwd=function(){return"/"},s.chdir=function(e){throw new Error("process.chdir is not supported")},s.umask=function(){return 0}},function(e,t,n){"use strict";n.r(t);var r={};n.r(r),n.d(r,"decode",(function(){return z})),n.d(r,"encode",(function(){return q}));var s={};n.r(s),n.d(s,"decode",(function(){return H})),n.d(s,"encode",(function(){return K}));var i={};n.r(i),n.d(i,"decode",(function(){return J})),n.d(i,"encode",(function(){return Q}));const o="KHR_draco_mesh_compression",a="KHR_lights_punctual",u="KHR_materials_unlit";function f(e,t){if(!e)throw new Error(t)}var c=n(0);const h="undefined"!=typeof ImageBitmap,l=void 0!==typeof Image,g=Boolean(c.a._parseImageNode);function d(e){switch(e){case"imagebitmap":return h;case"html":return l;case"ndarray":return g;default:throw new Error(`Unknown image format ${e}`)}}function m(e={}){const t=(e.image||{}).type||"auto";switch(t){case"imagebitmap":case"html":case"ndarray":if(!d(t))throw new Error(`Requested image type ${t} not available in current environment`);return t;case"auto":return function(){if(d("ndarray"))return"ndarray";if(d("html"))return"html";if(d("imagebitmap"))return"imagebitmap";if(!c.b)throw new Error("Install '@loaders.gl/polyfills' to parse images under Node.js");return f(!1)}();default:throw new Error(`Unknown image format ${t}`)}}const b=!1,y=!0,p=new Map([["image/png",{test:w,getSize:function(e){return{width:e.getUint32(16,b),height:e.getUint32(20,b)}}}],["image/jpeg",{test:T,getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,b))return null;const{tableMarkers:t,sofMarkers:n}=function(){const e=new Set([65499,65476,65484,65501,65534]);for(let t=65504;t<65520;++t)e.add(t);const t=new Set([65472,65473,65474,65475,65477,65478,65479,65481,65482,65483,65485,65486,65487,65502]);return{tableMarkers:e,sofMarkers:t}}();let r=2;for(;r<e.byteLength;){const s=e.getUint16(r,b);if(n.has(s))return{height:e.getUint16(r+5,b),width:e.getUint16(r+7,b)};if(!t.has(s))return null;r+=2,r+=e.getUint16(r,b)}return null}}],["image/gif",{test:j,getSize:function(e){return{width:e.getUint16(6,y),height:e.getUint16(8,y)}}}],["image/bmp",{test:x,getSize:function(e){return{width:e.getUint32(18,y),height:e.getUint32(22,y)}}}]]);function w(e){return e.byteLength>=24&&2303741511===e.getUint32(0,b)}function j(e){return e.byteLength>=10&&1195984440===e.getUint32(0,b)}function x(e){return e.byteLength>=2&&16973===e.getUint16(0,b)}function T(e){return e.byteLength>=3&&65496===e.getUint16(0,b)&&255===e.getUint8(2,b)}Array.from(p.keys()).join(", ");function v(e){const t=E(e);for(const[e,{test:n}]of p.entries())if(n(t))return e;return null}function E(e){if((e=e.buffer||e)instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}async function A(e,t){const n=new Image;return n.src=e,t.image&&t.image.decode&&n.decode?(await n.decode(),n):await new Promise((t,r)=>{try{n.onload=()=>t(n),n.onerror=t=>r(new Error(`Could not load image ${e}: ${t}`))}catch(e){r(e)}})}var _={name:"Images",extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,n){"image"in t&&(t={...t,image:{}});const{url:r}=n||{};if(r&&/\.svg((\?|#).*)?$/.test(r))return console.warn("@loaders.gl/images: SVG parsing needs to be fixed for 2.0"),await async function(e,t){const n=(new TextDecoder).decode(e),r=`data:image/svg+xml;base64,${btoa(n)}`;return await A(r,t)}(e,t);switch(m(t)){case"imagebitmap":return await function(e,t){const n=new Blob([new Uint8Array(e)]);return createImageBitmap(n)}(e);case"html":return await async function(e,t){const n=new Blob([e],{type:"image/jpeg"}),r=self.URL||self.webkitURL,s=r.createObjectURL(n);try{return await A(s,t)}finally{r.revokeObjectURL(s)}}(e,t);case"ndarray":return await function(e,t){f(c.a._parseImageNode);const n=v(e);return c.a._parseImageNode(e,n,t)}(e,t);default:return f(!1)}},test:e=>{const t=new DataView(e);return T(t)||x(t)||j(t)||w(t)},options:{images:{format:"auto",decodeHTML:!0}}};function B(e,t,n){if(e.byteLength<=t+n)return"";const r=new DataView(e);let s="";for(let e=0;e<n;e++)s+=String.fromCharCode(r.getUint8(t+e));return s}function U(e){try{return JSON.parse(e)}catch(t){throw new Error(`Failed to parse JSON from data starting with "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return B(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return B(e,0,t)}return""}(e)}"`)}}function L(e){return e+3&-4}function R(e,t,n){const r=n?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(r).buffer}function O(e,t,n){let r;if(e instanceof ArrayBuffer)r=new Uint8Array(e);else{const t=e.byteOffset,n=e.byteLength;r=new Uint8Array(e.buffer,t,n)}return t.set(r,n),n+L(r.byteLength)}function V(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function S(e,t){if(e.startsWith("data:")||e.startsWith("http:")||e.startsWith("https:"))return e;const n=t.baseUri||t.uri;if(!n)throw new Error(`'baseUri' must be provided to resolve relative url ${e}`);return n.substr(0,n.lastIndexOf("/")+1)+e}function I(e,t,n){const r=e.bufferViews[n];V(r);const s=t[r.buffer];V(s);const i=(r.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,i,r.byteLength)}const M=["SCALAR","VEC2","VEC3","VEC4"],C=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126]]),k={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},F={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},P={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function $(e){return M[e-1]||M[0]}function N(e){const t=C.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}class D{constructor(e){if(e instanceof D)return e;e||(e={json:{version:2,buffers:[]},buffers:[]}),this.gltf=e,V(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),n=this.json.extensions||{};return t?n[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 n=this.json[e]&&this.json[e][t];if(!n)throw new Error(`glTF file error: Could not find ${e}[${t}]`);return n}getTypedArrayForBufferView(e){const t=(e=this.getBufferView(e)).buffer,n=this.gltf.buffers[t];V(n);const r=(e.byteOffset||0)+n.byteOffset;return new Uint8Array(n.arrayBuffer,r,e.byteLength)}getTypedArrayForAccessor(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,{ArrayType:r,length:s}=function(e,t){const n=P[e.componentType],r=k[e.type],s=F[e.componentType],i=e.count*r,o=e.count*r*s;return V(o>=0&&o<=t.byteLength),{ArrayType:n,length:i,byteLength:o}}(e,t);return new r(n,t.byteOffset+e.byteOffset,s)}getTypedArrayForImageData(e){e=this.getAccessor(e);const t=this.getBufferView(e.bufferView),n=this.getBuffer(t.buffer).data,r=t.byteOffset||0;return new Uint8Array(n,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}addObjectExtension(e,t,n){return V(n),e.extensions=e.extensions||{},e.extensions[t]=n,this.registerUsedExtension(t),this}removeObjectExtension(e,t){return delete(e.extensions||{})[t],this}addExtension(e,t){return V(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),this}addRequiredExtension(e,t){return V(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,n){(e.extensions||{})[t]=n}addMesh(e,t,n=4){const r={primitives:[{attributes:this._addAttributes(e),indices:t,mode:n}]};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||v(e);const n={bufferView:this.addBufferView(e),mimeType:t};return this.json.images=this.json.images||[],this.json.images.push(n),this.json.images.length-1}addBufferView(e){const t=e.byteLength;V(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const n={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=L(t),this.json.bufferViews=this.json.bufferViews||[],this.json.bufferViews.push(n),this.json.bufferViews.length-1}addAccessor(e,t){const n={bufferView:e,type:$(t.size),componentType:t.componentType,count:t.count};return this.json.accessors=this.json.accessors||[],this.json.accessors.push(n),this.json.accessors.length-1}addBinaryBuffer(e,t={size:3}){const n=this.addBufferView(e),r={size:t.size,componentType:N(e),count:Math.round(e.length/t.size)};return this.addAccessor(n,Object.assign(r,t))}createBinaryChunk(){if(this.arrayBuffer)return;const e=this.byteLength,t=new ArrayBuffer(e),n=new Uint8Array(t);let r=0;for(let e=0;e<this.sourceBuffers.length;e++){r=O(this.sourceBuffers[e],n,r)}this.json.buffers[0].byteLength=e,this.arrayBuffer=t,this.sourceBuffers=[]}_removeStringFromArray(e,t){let n=!0;for(;n;){const r=e.indexOf(t);r>-1?e.splice(r,1):n=!1}}}function G(e,t){const{buffer:n,size:r,count:s}=function(e,t){let n=e,r=1,s=0;e&&e.value&&(n=e.value,r=e.size||1);n&&(ArrayBuffer.isView(n)||(n=function(e,t,n=!1){if(!e)return null;if(Array.isArray(e))return new t(e);if(n&&!(e instanceof t))return new t(e);return e}(n,Float32Array)),s=n.length/r);return{buffer:n,size:r,count:s}}(e);return{value:n,size:r,bufferView:null,byteOffset:0,count:s,type:$(r),componentType:N(n)}}async function z(e,t,n){if(!t.gltf.decompressMeshes)return;const r=new D(e),s=[];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,o)&&s.push(W(e,r,t,n));await Promise.all(s),r.removeExtension(o)}function q(e,t={}){const n=new D(e);for(const e of n.json.meshes||[])X(e,t),n.addRequiredExtension(o)}async function W(e,t,n,r){const s=t.getObjectExtension(e,o),i=t.getTypedArrayForBufferView(s.bufferView),a=R(i.buffer,i.byteOffset),{parse:u}=r,f=await u(a,[],n,r);e.attributes=function(e){const t={};for(const n in e){const r=e[n];if("indices"!==n){const e=G(r);t[n]=e}}return t}(f.attributes),f.indices&&(e.indices=G(f.indices)),function(e){if(!e.attributes&&Object.keys(e.attributes).length>0)throw new Error("Empty glTF primitive detected: Draco decompression failure?")}(e)}function X(e,t,n=4,r,s){if(!r.DracoWriter||!r.DracoLoader)throw new Error("DracoWriter/DracoLoader not available");const i=r.DracoWriter.encodeSync({attributes:e}),{parseSync:a}=s,u=a({attributes:e}),f=r._addFauxAttributes(u.attributes),c=r.addBufferView(i);return{primitives:[{attributes:f,mode:n,extensions:{[o]:{bufferView:c,attributes:f}}}]}}function H(e,t){const n=new D(e),{json:r}=n,s=n.getExtension(a);s&&(n.json.lights=s.lights,n.removeExtension(a));for(const e of r.nodes||[]){const t=n.getObjectExtension(e,a);t&&(e.light=t.light),n.removeObjectExtension(e,a)}}function K(e,t){const n=new D(e),{json:r}=n;if(r.lights){const e=n.addExtensions(a);V(!e.lights),e.lights=r.lights,delete r.lights}if(n.json.lights){for(const e of n.json.lights){const t=e.node;n.addObjectExtension(t,a,e)}delete n.json.lights}}function J(e,t){const n=new D(e),{json:r}=n;n.removeExtension(u);for(const e of r.materials||[]){e.extensions&&e.extensions.KHR_materials_unlit&&(e.unlit=!0),n.removeObjectExtension(e,u)}}function Q(e,t){const n=new D(e),{json:r}=n;if(n.materials)for(const e of r.materials)e.unlit&&(delete e.unlit,n.addObjectExtension(e,u),n.addExtensions(u))}const Y={KHR_draco_mesh_compression:r,KHR_lights_punctual:s,KHR_materials_unlit:i};function Z(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const ee=1735152710,te=12,ne=8,re=1313821514,se=5130562,ie=0,oe=1,ae=!0;function ue(e,t=0,n={}){const r=new DataView(e),{magic:s=ee}=n,i=r.getUint32(t,!1);return i===s||i===ee}function fe(e,t,n=0,r={}){const s=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))}`}(s,n+0),e.version=s.getUint32(n+4,ae);const i=s.getUint32(n+8,ae);return e.header={byteOffset:n,byteLength:i},Z(2===e.version,`Invalid GLB version ${e.version}. Only supports v2.`),Z(e.header.byteLength>te+ne),e.json={},e.binChunks=[],function(e,t,n,r){for(;n+8<=e.header.byteLength;){const s=t.getUint32(n+0,ae),i=t.getUint32(n+4,ae);switch(n+=ne,i){case re:ce(e,t,n,s,r);break;case se:he(e,t,n,s,r);break;case ie:r.glb.strict||ce(e,t,n,s,r);break;case oe:r.glb.strict||he(e,t,n,s,r)}n+=L(s)}}(e,s,n+te,r),n+e.header.byteLength}function ce(e,t,n,r,s){const i=new Uint8Array(t.buffer,n,r),o=new TextDecoder("utf8").decode(i);e.json=JSON.parse(o)}function he(e,t,n,r,s){e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:r,arrayBuffer:t.buffer})}const le={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},de={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},me={magFilter:de.TEXTURE_MAG_FILTER,minFilter:de.TEXTURE_MIN_FILTER,wrapS:de.TEXTURE_WRAP_S,wrapT:de.TEXTURE_WRAP_T},be={[de.TEXTURE_MAG_FILTER]:de.LINEAR,[de.TEXTURE_MIN_FILTER]:de.NEAREST_MIPMAP_LINEAR,[de.TEXTURE_WRAP_S]:de.REPEAT,[de.TEXTURE_WRAP_]:de.REPEAT};class ye{postProcess(e,t={}){const{json:n,buffers:r=[],images:s=[],baseUri:i=""}=e;return V(n),this.baseUri=i,this.json=n,this.buffers=r,this.images=s,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,n)=>this._resolveImage(e,n,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 n=this.json[e]&&this.json[e][t];return n||console.warn(`glTF file error: Could not find ${e}[${t}]`),n}_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 n in t)e.attributes[n]=this.getAccessor(t[n]);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 n,r;return e.id=e.id||`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(n=e.componentType,ge[n]),e.components=(r=e.type,le[r]),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):be,e.source=this.getImage(e.source),e}_resolveSampler(e,t){e.id=e.id||`sampler-${t}`,e.parameters={};for(const t in e){const n=this._enumSamplerParameter(t);void 0!==n&&(e.parameters[n]=e[t])}return e}_enumSamplerParameter(e){return me[e]}_resolveImage(e,t,n){e.id=e.id||`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const r=this.images[t];return r&&(e.image=r),e.getImageAsync=async()=>(console.warn("loaders.gl/gltf: image.getImageAsync will be removed in 2.0"),e.image),e}_resolveBufferView(e,t){e.id=e.id||`bufferView-${t}`;const n=e.buffer;e.buffer=this.getBuffer(n);const r=this.buffers[n].arrayBuffer;let s=this.buffers[n].byteOffset||0;return"byteOffset"in e&&(s+=e.byteOffset),e.data=new Uint8Array(r,s,e.byteLength),e}_resolveCamera(e,t){return e.id=e.id||`camera-${t}`,e.perspective,e.orthographic,e}}function pe(e,t){return(new ye).postProcess(e,t)}async function we(e,t,n=0,r,s){!function(e,t,n,r){r.uri&&(e.baseUri=r.uri);if(t instanceof ArrayBuffer&&!ue(t,n,r)){const e=new TextDecoder;t=e.decode(t)}if("string"==typeof t)e.json=U(t);else if(t instanceof ArrayBuffer){const s={};n=fe(s,t,n,r),V("glTF"===s.type,`Invalid GLB magic string ${s.type}`),e._glb=s,e.json=s.json}else V(!1,"GLTF: must be ArrayBuffer or string");const s=e.json.buffers||[];if(e.buffers=new Array(s.length).fill(null),e._glb&&e._glb.header.hasBinChunk){const{binChunks:t}=e._glb;e.buffers[0]={arrayBuffer:t[0].arrayBuffer,byteOffset:t[0].byteOffset,byteLength:t[0].byteLength}}const i=e.json.images||[];e.images=new Array(i.length).fill({})}(e,t,n,r);const i=[];if(r.gltf.loadImages){const t=async function(e,t,n){const r=e.json.images||[],s=[];for(let i=0;i<r.length;++i)s.push(je(e,r[i],i,t,n));return await Promise.all(s)}(e,r,s);i.push(t)}r.gltf.loadBuffers&&await async function(e,t,n){for(let r=0;r<e.json.buffers.length;++r){const s=e.json.buffers[r];if(s.uri){const{fetch:i}=n;V(i);const o=S(s.uri,t),a=await i(o),u=await a.arrayBuffer();e.buffers[r]={arrayBuffer:u,byteOffset:0,byteLength:u.byteLength},delete s.uri}}}(e,r,s);const o=async function(e,t={},n){t.gltf=t.gltf||{};for(const r in Y){const s=t.gltf.excludeExtensions||{};if(!(r in s&&!s[r])){const s=Y[r];await s.decode(e,t,n)}}}(e,r,s);return i.push(o),await Promise.all(i),r.gltf.postProcess?pe(e,r):e}async function je(e,t,n,r,s){const{fetch:i,parse:o}=s;let a;if(t.uri){const e=S(t.uri,r),n=await i(e);a=await n.arrayBuffer()}if(Number.isFinite(t.bufferView)){const n=I(e.json,e.buffers,t.bufferView);a=R(n.buffer,n.byteOffset,n.byteLength)}V(a,"glTF image has no data");const u=await o(a,_,{},s);e.images[n]=u}const xe={name:"glTF",extensions:["gltf","glb"],mimeType:"model/gltf+json",text:!0,binary:!0,test:"glTF",parse:async function(e,t={},n){(t={...xe.options,...t}).gltf={...xe.options.gltf,...t.gltf},function(e){"fetchImages"in e&&(e.gltf.loadImages=e.fetchImages);"createImages"in e&&(e.gltf.loadImages=e.createImages);"fetchLinkedResources"in e&&(e.gltf.fetchBuffers=e.fetchLinkedResources);"decompress"in e&&(e.gltf.decompressMeshes=e.decompress);"decompress"in e.gltf&&(e.gltf.decompressMeshes=e.gltf.decompress);"postProcess"in e&&(e.gltf.postProcess=e.postProcess)}(t);const{byteOffset:r=0}=t;return await we({},e,r,t,n)},options:{gltf:{loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},uri:"",log:console}};var Te=xe;function ve(e,t,n,r){const s=L(n.byteLength),i=s-n.byteLength;if(e){const r=new Uint8Array(e.buffer,e.byteOffset+t,n.byteLength),s=new Uint8Array(n);r.set(s);for(let r=0;r<i;++r)e.setUint8(t+n.byteLength+r,32)}return t+=s}const Ee=1179937895,Ae=1313821514,_e=5130562,Be=!0;function Ue(e,t,n=0,r={}){const{magic:s=Ee,version:i=2,json:o={},binary:a}=e,u=n;t&&(t.setUint32(n+0,s,Be),t.setUint32(n+4,i,Be),t.setUint32(n+8,0,Be));const f=n+8,c=n+=12;if(t&&(t.setUint32(n+0,0,Be),t.setUint32(n+4,Ae,Be)),n=function(e,t,n,r){return t=ve(e,t,(new TextEncoder).encode(n))}(t,n+=8,JSON.stringify(o)),t){const e=n-c-8;t.setUint32(c+0,e,Be)}if(a){const e=n;if(t&&(t.setUint32(n+0,0,Be),t.setUint32(n+4,_e,Be)),n=ve(t,n+=8,a),t){const r=n-e-8;t.setUint32(e+0,r,Be)}}if(t){const e=n-u;t.setUint32(f,e,Be)}return n}function Le(e,t,n,r){return function(e,{firstBuffer:t=0}={}){if(e.buffers&&e.buffers.length>t)throw new Error("encodeGLTF: multiple buffers not yet implemented")}(e),Ue(e,t,n,r)}var Re={name:"glTF",extensions:["glb"],mimeType:"model/gltf+json",encodeSync:function(e,t={}){const{byteOffset:n=0}=t,r=Le(e,null,n,t),s=new ArrayBuffer(r),i=new DataView(s);return Le(e,i,n,t),s},binary:!0,options:{}};var Oe={name:"GLB",extensions:["glb"],mimeType:"model/gltf-binary",binary:!0,parse:async(e,t)=>Ve(e,t),parseSync:Ve,options:{glb:{strict:!1}}};function Ve(e,t){const{byteOffset:n=0}=t,r={};return fe(r,e,n,t),r}var Se={name:"GLB",extensions:["glb"],mimeType:"model/gltf-binary",encodeSync:function(e,t){const{byteOffset:n=0}=t,r=Ue(e,null,n,t),s=new ArrayBuffer(r),i=new DataView(s);return Ue(e,i,n,t),s},binary:!0,options:{glb:{}}};function Ie(e){return"undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap?"imagebitmap":"undefined"!=typeof Image&&e instanceof Image?"html":e&&"object"==typeof e&&e.data&&e.width&&e.height?"ndarray":Array.isArray(e)?"ndarray":null}class Me{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 Boolean(Ie(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},n=Ue(t,null,0,e),r=new ArrayBuffer(n);return Ue(t,new DataView(r),0,e),r}addApplicationData(e,t,n={}){return this.json[e]=t,this}addBuffer(e,t={size:3}){const n=this.addBufferView(e),r={size:t.size,componentType:N(e),count:Math.round(e.length/t.size)};return this.addAccessor(n,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+=L(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),n=new Uint8Array(t);let r=0;for(let e=0;e<this.sourceBuffers.length;e++){r=O(this.sourceBuffers[e],n,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}}}n.d(t,"KHR_DRACO_MESH_COMPRESSION",(function(){return o})),n.d(t,"UBER_POINT_CLOUD_EXTENSION",(function(){return"UBER_draco_point_cloud_compression"})),n.d(t,"GLTFLoader",(function(){return Te})),n.d(t,"GLTFWriter",(function(){return Re})),n.d(t,"GLBLoader",(function(){return Oe})),n.d(t,"GLBWriter",(function(){return Se})),n.d(t,"GLTFScenegraph",(function(){return D})),n.d(t,"postProcessGLTF",(function(){return pe})),n.d(t,"GLBBuilder",(function(){return Me})),n.d(t,"encodeGLTFSync",(function(){return Le}))}])}));

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

var _gltfParser = _interopRequireDefault(require("./lib/deprecated/gltf-parser"));
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

@@ -36,3 +34,2 @@

gltf: {
parserVersion: 1,
loadBuffers: true,

@@ -58,3 +55,2 @@ loadImages: true,

context,
gltfParser,
_options,

@@ -75,21 +71,11 @@ _options$byteOffset,

addDeprecatedGLTFOptions(options);
if (!(options.gltf.parserVersion !== 2 && options.useGLTFParser !== false)) {
_context.next = 8;
break;
}
gltfParser = new _gltfParser["default"]();
return _context.abrupt("return", gltfParser.parse(arrayBuffer, options));
case 8:
_options = options, _options$byteOffset = _options.byteOffset, byteOffset = _options$byteOffset === void 0 ? 0 : _options$byteOffset;
gltf = {};
_context.next = 12;
_context.next = 9;
return (0, _parseGltf.parseGLTF)(gltf, arrayBuffer, byteOffset, options, context);
case 12:
case 9:
return _context.abrupt("return", _context.sent);
case 13:
case 10:
case "end":

@@ -96,0 +82,0 @@ return _context.stop();

@@ -16,5 +16,3 @@ "use strict";

binary: true,
defaultOptions: {
useGLTFBuilder: true
}
options: {}
};

@@ -21,0 +19,0 @@ exports["default"] = _default;

@@ -56,26 +56,2 @@ "use strict";

});
Object.defineProperty(exports, "encodeGLTFSync", {
enumerable: true,
get: function get() {
return _encodeGltf.encodeGLTFSync;
}
});
Object.defineProperty(exports, "packBinaryJson", {
enumerable: true,
get: function get() {
return _packBinaryJson["default"];
}
});
Object.defineProperty(exports, "unpackBinaryJson", {
enumerable: true,
get: function get() {
return _unpackBinaryJson["default"];
}
});
Object.defineProperty(exports, "GLBParser", {
enumerable: true,
get: function get() {
return _glbParser["default"];
}
});
Object.defineProperty(exports, "GLBBuilder", {

@@ -87,14 +63,8 @@ enumerable: true,

});
Object.defineProperty(exports, "GLTFParser", {
Object.defineProperty(exports, "encodeGLTFSync", {
enumerable: true,
get: function get() {
return _gltfParser["default"];
return _encodeGltf.encodeGLTFSync;
}
});
Object.defineProperty(exports, "GLTFBuilder", {
enumerable: true,
get: function get() {
return _gltfBuilder["default"];
}
});

@@ -115,15 +85,5 @@ var _gltfConstants = require("./lib/gltf-constants");

var _encodeGltf = require("./lib/encode-gltf");
var _packBinaryJson = _interopRequireDefault(require("./lib/deprecated/packed-json/pack-binary-json"));
var _unpackBinaryJson = _interopRequireDefault(require("./lib/deprecated/packed-json/unpack-binary-json"));
var _glbParser = _interopRequireDefault(require("./lib/deprecated/glb-parser"));
var _glbBuilder = _interopRequireDefault(require("./lib/deprecated/glb-builder"));
var _gltfParser = _interopRequireDefault(require("./lib/deprecated/gltf-parser"));
var _gltfBuilder = _interopRequireDefault(require("./lib/deprecated/gltf-builder"));
var _encodeGltf = require("./lib/encode-gltf");
//# sourceMappingURL=index.js.map

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

var _packBinaryJson = _interopRequireDefault(require("./packed-json/pack-binary-json"));
var GLBBuilder = function () {

@@ -85,4 +83,3 @@ function GLBBuilder() {

var packOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var jsonData = packOptions.packTypedArrays ? (0, _packBinaryJson["default"])(data, this, packOptions) : data;
this.json[key] = jsonData;
this.json[key] = data;
return this;

@@ -89,0 +86,0 @@ }

@@ -204,8 +204,9 @@ "use strict";

var bufferViewIndex = this.addBufferView(imageData);
var sizeAndType = (0, _images.getImageMetadata)(imageData) || {};
var mimeType = (0, _images.getBinaryImageMIMEType)(imageData) || {};
if (sizeAndType) {
var mimeType = sizeAndType.mimeType,
width = sizeAndType.width,
height = sizeAndType.height;
if (mimeType) {
var _ref = (0, _images.getBinaryImageSize)(imageData, mimeType) || {},
width = _ref.width,
height = _ref.height;
this.json.images.push({

@@ -212,0 +213,0 @@ bufferView: bufferViewIndex,

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

_context3.next = 6;
return parse(bufferCopy, options);
return parse(bufferCopy, [], options, context);

@@ -160,0 +160,0 @@ case 6:

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

value: function addImage(imageData, mimeType) {
mimeType = mimeType || (0, _images.getImageMIMEType)(imageData);
mimeType = mimeType || (0, _images.getBinaryImageMIMEType)(imageData);
var bufferViewIndex = this.addBufferView(imageData);

@@ -330,0 +330,0 @@ var glTFImage = {

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

exports.getAccessorArrayTypeAndLength = getAccessorArrayTypeAndLength;
exports.getFullUri = getFullUri;
exports.ATTRIBUTE_COMPONENT_TYPE_TO_ARRAY = exports.ATTRIBUTE_COMPONENT_TYPE_TO_BYTE_SIZE = exports.ATTRIBUTE_TYPE_TO_COMPONENTS = void 0;

@@ -76,7 +75,2 @@

}
function getFullUri(uri, base) {
var absolute = uri.startsWith('data:') || uri.startsWith('http:') || uri.startsWith('https:');
return absolute ? uri : base.substr(0, base.lastIndexOf('/') + 1) + uri;
}
//# sourceMappingURL=gltf-utils.js.map

@@ -49,6 +49,4 @@ "use strict";

glb.json = {};
glb.hasBinChunk = false;
glb.binChunks = [];
parseGLBChunksSync(glb, dataView, byteOffset + GLB_FILE_HEADER_SIZE, options);
addDeprecatedFields(glb);
return byteOffset + glb.header.byteLength;

@@ -111,10 +109,2 @@ }

}
function addDeprecatedFields(glb) {
glb.byteOffset = glb.header.byteOffset;
glb.byteLength = glb.header.byteLength;
glb.hasBinChunk = glb.binChunks.length >= 1;
glb.binChunkByteOffset = glb.header.hasBinChunk ? glb.binChunks[0].byteOffset : 0;
glb.binChunkLength = glb.header.hasBinChunk ? glb.binChunks[0].byteLength : 0;
}
//# sourceMappingURL=parse-glb.js.map

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

var _gltfUtils = require("./gltf-utils/gltf-utils");
var _resolveUrl = require("./gltf-utils/resolve-url");

@@ -120,5 +120,5 @@ var _getTypedArray = require("./gltf-utils/get-typed-array");

var buffers = gltf.json.buffers || [];
gltf.buffers = new Array(buffers.length).fill({});
gltf.buffers = new Array(buffers.length).fill(null);
if (gltf._glb && gltf._glb.hasBinChunk) {
if (gltf._glb && gltf._glb.header.hasBinChunk) {
var binChunks = gltf._glb.binChunks;

@@ -151,3 +151,3 @@ gltf.buffers[0] = {

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

@@ -159,27 +159,18 @@ }

if (!buffer.uri) {
_context2.next = 18;
_context2.next = 15;
break;
}
if (options.uri) {
_context2.next = 7;
break;
}
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 = 12;
uri = (0, _resolveUrl.resolveUrl)(buffer.uri, options);
_context2.next = 9;
return fetch(uri);
case 12:
case 9:
response = _context2.sent;
_context2.next = 15;
_context2.next = 12;
return response.arrayBuffer();
case 15:
case 12:
arrayBuffer = _context2.sent;

@@ -193,3 +184,3 @@ gltf.buffers[i] = {

case 18:
case 15:
++i;

@@ -199,3 +190,3 @@ _context2.next = 1;

case 21:
case 18:
case "end":

@@ -262,3 +253,3 @@ return _context2.stop();

uri = (0, _gltfUtils.getFullUri)(image.uri, options.uri);
uri = (0, _resolveUrl.resolveUrl)(image.uri, options);
_context4.next = 5;

@@ -265,0 +256,0 @@ return fetch(uri);

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

var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));

@@ -412,7 +416,17 @@

image.getImageAsync = function () {
(0, _assert["default"])(image.image);
return image.image;
};
image.getImageAsync = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee() {
return _regenerator["default"].wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
console.warn('loaders.gl/gltf: image.getImageAsync will be removed in 2.0');
return _context.abrupt("return", image.image);
case 2:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return image;

@@ -419,0 +433,0 @@ }

@@ -10,5 +10,5 @@ "use strict";

if (!condition) {
throw new Error(message || 'gltf/glb assertion failed.');
throw new Error(message || 'assert failed: gltf');
}
}
//# sourceMappingURL=assert.js.map

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

import { parseGLTF } from './lib/parse-gltf';
import GLTFParser from './lib/deprecated/gltf-parser';
const GLTFLoader = {

@@ -20,3 +19,2 @@ name: 'glTF',

gltf: {
parserVersion: 1,
loadBuffers: true,

@@ -36,8 +34,2 @@ loadImages: true,

addDeprecatedGLTFOptions(options);
if (options.gltf.parserVersion !== 2 && options.useGLTFParser !== false) {
const gltfParser = new GLTFParser();
return gltfParser.parse(arrayBuffer, options);
}
const {

@@ -44,0 +36,0 @@ byteOffset = 0

@@ -8,5 +8,3 @@ import { encodeGLTFSync } from './lib/encode-gltf';

binary: true,
defaultOptions: {
useGLTFBuilder: true
}
options: {}
};

@@ -13,0 +11,0 @@

@@ -8,9 +8,4 @@ export { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from './lib/gltf-constants';

export { default as postProcessGLTF } from './lib/post-process-gltf';
export { default as GLBBuilder } from './lib/deprecated/glb-builder';
export { encodeGLTFSync } from './lib/encode-gltf';
export { default as packBinaryJson } from './lib/deprecated/packed-json/pack-binary-json';
export { default as unpackBinaryJson } from './lib/deprecated/packed-json/unpack-binary-json';
export { default as GLBParser } from './lib/deprecated/glb-parser';
export { default as GLBBuilder } from './lib/deprecated/glb-builder';
export { default as GLTFParser } from './lib/deprecated/gltf-parser';
export { default as GLTFBuilder } from './lib/deprecated/gltf-builder';
//# sourceMappingURL=index.js.map

@@ -5,3 +5,2 @@ import { padTo4Bytes, copyToArray } from '@loaders.gl/loader-utils';

import encodeGLBSync from '../encode-glb';
import packBinaryJson from './packed-json/pack-binary-json';
export default class GLBBuilder {

@@ -55,4 +54,3 @@ constructor(options = {}) {

addApplicationData(key, data, packOptions = {}) {
const jsonData = packOptions.packTypedArrays ? packBinaryJson(data, this, packOptions) : data;
this.json[key] = jsonData;
this.json[key] = data;
return this;

@@ -59,0 +57,0 @@ }

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

import { getImageMetadata } from '@loaders.gl/images';
import { getBinaryImageMIMEType, getBinaryImageSize } from '@loaders.gl/images';
import assert from '../utils/assert';

@@ -151,10 +151,9 @@ import { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from '../gltf-constants';

const bufferViewIndex = this.addBufferView(imageData);
const sizeAndType = getImageMetadata(imageData) || {};
const mimeType = getBinaryImageMIMEType(imageData) || {};
if (sizeAndType) {
if (mimeType) {
const {
mimeType,
width,
height
} = sizeAndType;
} = getBinaryImageSize(imageData, mimeType) || {};
this.json.images.push({

@@ -161,0 +160,0 @@ bufferView: bufferViewIndex,

@@ -38,3 +38,3 @@ import { getZeroOffsetArrayBuffer } from '@loaders.gl/loader-utils';

} = context;
const decodedData = await parse(bufferCopy, options);
const decodedData = await parse(bufferCopy, [], options, context);
primitive.attributes = getGLTFAccessors(decodedData.attributes);

@@ -41,0 +41,0 @@

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

import { getImageMIMEType } from '@loaders.gl/images';
import { getBinaryImageMIMEType } from '@loaders.gl/images';
import { padTo4Bytes, copyToArray } from '@loaders.gl/loader-utils';

@@ -262,3 +262,3 @@ import assert from './utils/assert';

addImage(imageData, mimeType) {
mimeType = mimeType || getImageMIMEType(imageData);
mimeType = mimeType || getBinaryImageMIMEType(imageData);
const bufferViewIndex = this.addBufferView(imageData);

@@ -265,0 +265,0 @@ const glTFImage = {

@@ -55,6 +55,2 @@ import assert from '../utils/assert';

}
export function getFullUri(uri, base) {
const absolute = uri.startsWith('data:') || uri.startsWith('http:') || uri.startsWith('https:');
return absolute ? uri : base.substr(0, base.lastIndexOf('/') + 1) + uri;
}
//# sourceMappingURL=gltf-utils.js.map

@@ -35,6 +35,4 @@ import { padTo4Bytes, assert } from '@loaders.gl/loader-utils';

glb.json = {};
glb.hasBinChunk = false;
glb.binChunks = [];
parseGLBChunksSync(glb, dataView, byteOffset + GLB_FILE_HEADER_SIZE, options);
addDeprecatedFields(glb);
return byteOffset + glb.header.byteLength;

@@ -97,10 +95,2 @@ }

}
function addDeprecatedFields(glb) {
glb.byteOffset = glb.header.byteOffset;
glb.byteLength = glb.header.byteLength;
glb.hasBinChunk = glb.binChunks.length >= 1;
glb.binChunkByteOffset = glb.header.hasBinChunk ? glb.binChunks[0].byteOffset : 0;
glb.binChunkLength = glb.header.hasBinChunk ? glb.binChunks[0].byteLength : 0;
}
//# sourceMappingURL=parse-glb.js.map
import { ImageLoader } from '@loaders.gl/images';
import { parseJSON, getZeroOffsetArrayBuffer } from '@loaders.gl/loader-utils';
import assert from './utils/assert';
import { getFullUri } from './gltf-utils/gltf-utils';
import { resolveUrl } from './gltf-utils/resolve-url';
import { getTypedArrayForBufferView } from './gltf-utils/get-typed-array';

@@ -56,5 +56,5 @@ import { decodeExtensions } from './extensions/gltf-extensions';

const buffers = gltf.json.buffers || [];
gltf.buffers = new Array(buffers.length).fill({});
gltf.buffers = new Array(buffers.length).fill(null);
if (gltf._glb && gltf._glb.hasBinChunk) {
if (gltf._glb && gltf._glb.header.hasBinChunk) {
const {

@@ -79,7 +79,2 @@ binChunks

if (buffer.uri) {
if (!options.uri) {
console.warn('options.uri must be set to decode embedded glTF buffers');
return;
}
const {

@@ -89,3 +84,3 @@ fetch

assert(fetch);
const uri = getFullUri(buffer.uri, options.uri);
const uri = resolveUrl(buffer.uri, options);
const response = await fetch(uri);

@@ -122,3 +117,3 @@ const arrayBuffer = await response.arrayBuffer();

if (image.uri) {
const uri = getFullUri(image.uri, options.uri);
const uri = resolveUrl(image.uri, options);
const response = await fetch(uri);

@@ -125,0 +120,0 @@ arrayBuffer = await response.arrayBuffer();

@@ -332,4 +332,4 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

image.getImageAsync = () => {
assert(image.image);
image.getImageAsync = async () => {
console.warn('loaders.gl/gltf: image.getImageAsync will be removed in 2.0');
return image.image;

@@ -336,0 +336,0 @@ };

export default function assert(condition, message) {
if (!condition) {
throw new Error(message || 'gltf/glb assertion failed.');
throw new Error(message || 'assert failed: gltf');
}
}
//# sourceMappingURL=assert.js.map

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

import { parseGLTF } from './lib/parse-gltf';
import GLTFParser from './lib/deprecated/gltf-parser';
var GLTFLoader = {

@@ -22,3 +21,2 @@ name: 'glTF',

gltf: {
parserVersion: 1,
loadBuffers: true,

@@ -42,3 +40,2 @@ loadImages: true,

context,
gltfParser,
_options,

@@ -59,21 +56,11 @@ _options$byteOffset,

addDeprecatedGLTFOptions(options);
if (!(options.gltf.parserVersion !== 2 && options.useGLTFParser !== false)) {
_context.next = 8;
break;
}
gltfParser = new GLTFParser();
return _context.abrupt("return", gltfParser.parse(arrayBuffer, options));
case 8:
_options = options, _options$byteOffset = _options.byteOffset, byteOffset = _options$byteOffset === void 0 ? 0 : _options$byteOffset;
gltf = {};
_context.next = 12;
_context.next = 9;
return parseGLTF(gltf, arrayBuffer, byteOffset, options, context);
case 12:
case 9:
return _context.abrupt("return", _context.sent);
case 13:
case 10:
case "end":

@@ -80,0 +67,0 @@ return _context.stop();

@@ -8,5 +8,3 @@ import { encodeGLTFSync } from './lib/encode-gltf';

binary: true,
defaultOptions: {
useGLTFBuilder: true
}
options: {}
};

@@ -13,0 +11,0 @@

@@ -8,9 +8,4 @@ export { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from './lib/gltf-constants';

export { default as postProcessGLTF } from './lib/post-process-gltf';
export { default as GLBBuilder } from './lib/deprecated/glb-builder';
export { encodeGLTFSync } from './lib/encode-gltf';
export { default as packBinaryJson } from './lib/deprecated/packed-json/pack-binary-json';
export { default as unpackBinaryJson } from './lib/deprecated/packed-json/unpack-binary-json';
export { default as GLBParser } from './lib/deprecated/glb-parser';
export { default as GLBBuilder } from './lib/deprecated/glb-builder';
export { default as GLTFParser } from './lib/deprecated/gltf-parser';
export { default as GLTFBuilder } from './lib/deprecated/gltf-builder';
//# sourceMappingURL=index.js.map

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

import encodeGLBSync from '../encode-glb';
import packBinaryJson from './packed-json/pack-binary-json';

@@ -72,4 +71,3 @@ var GLBBuilder = function () {

var packOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
var jsonData = packOptions.packTypedArrays ? packBinaryJson(data, this, packOptions) : data;
this.json[key] = jsonData;
this.json[key] = data;
return this;

@@ -76,0 +74,0 @@ }

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

import _inherits from "@babel/runtime/helpers/esm/inherits";
import { getImageMetadata } from '@loaders.gl/images';
import { getBinaryImageMIMEType, getBinaryImageSize } from '@loaders.gl/images';
import assert from '../utils/assert';

@@ -188,8 +188,9 @@ import { KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION } from '../gltf-constants';

var bufferViewIndex = this.addBufferView(imageData);
var sizeAndType = getImageMetadata(imageData) || {};
var mimeType = getBinaryImageMIMEType(imageData) || {};
if (sizeAndType) {
var mimeType = sizeAndType.mimeType,
width = sizeAndType.width,
height = sizeAndType.height;
if (mimeType) {
var _ref = getBinaryImageSize(imageData, mimeType) || {},
width = _ref.width,
height = _ref.height;
this.json.images.push({

@@ -196,0 +197,0 @@ bufferView: bufferViewIndex,

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

_context3.next = 6;
return parse(bufferCopy, options);
return parse(bufferCopy, [], options, context);

@@ -144,0 +144,0 @@ case 6:

import _typeof from "@babel/runtime/helpers/esm/typeof";
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
import _createClass from "@babel/runtime/helpers/esm/createClass";
import { getImageMIMEType } from '@loaders.gl/images';
import { getBinaryImageMIMEType } from '@loaders.gl/images';
import { padTo4Bytes, copyToArray } from '@loaders.gl/loader-utils';

@@ -312,3 +312,3 @@ import assert from './utils/assert';

value: function addImage(imageData, mimeType) {
mimeType = mimeType || getImageMIMEType(imageData);
mimeType = mimeType || getBinaryImageMIMEType(imageData);
var bufferViewIndex = this.addBufferView(imageData);

@@ -315,0 +315,0 @@ var glTFImage = {

@@ -55,6 +55,2 @@ import assert from '../utils/assert';

}
export function getFullUri(uri, base) {
var absolute = uri.startsWith('data:') || uri.startsWith('http:') || uri.startsWith('https:');
return absolute ? uri : base.substr(0, base.lastIndexOf('/') + 1) + uri;
}
//# sourceMappingURL=gltf-utils.js.map

@@ -39,6 +39,4 @@ import { padTo4Bytes, assert } from '@loaders.gl/loader-utils';

glb.json = {};
glb.hasBinChunk = false;
glb.binChunks = [];
parseGLBChunksSync(glb, dataView, byteOffset + GLB_FILE_HEADER_SIZE, options);
addDeprecatedFields(glb);
return byteOffset + glb.header.byteLength;

@@ -101,10 +99,2 @@ }

}
function addDeprecatedFields(glb) {
glb.byteOffset = glb.header.byteOffset;
glb.byteLength = glb.header.byteLength;
glb.hasBinChunk = glb.binChunks.length >= 1;
glb.binChunkByteOffset = glb.header.hasBinChunk ? glb.binChunks[0].byteOffset : 0;
glb.binChunkLength = glb.header.hasBinChunk ? glb.binChunks[0].byteLength : 0;
}
//# sourceMappingURL=parse-glb.js.map

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

import assert from './utils/assert';
import { getFullUri } from './gltf-utils/gltf-utils';
import { resolveUrl } from './gltf-utils/resolve-url';
import { getTypedArrayForBufferView } from './gltf-utils/get-typed-array';

@@ -97,5 +97,5 @@ import { decodeExtensions } from './extensions/gltf-extensions';

var buffers = gltf.json.buffers || [];
gltf.buffers = new Array(buffers.length).fill({});
gltf.buffers = new Array(buffers.length).fill(null);
if (gltf._glb && gltf._glb.hasBinChunk) {
if (gltf._glb && gltf._glb.header.hasBinChunk) {
var binChunks = gltf._glb.binChunks;

@@ -128,3 +128,3 @@ gltf.buffers[0] = {

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

@@ -136,27 +136,18 @@ }

if (!buffer.uri) {
_context2.next = 18;
_context2.next = 15;
break;
}
if (options.uri) {
_context2.next = 7;
break;
}
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 = 12;
uri = resolveUrl(buffer.uri, options);
_context2.next = 9;
return fetch(uri);
case 12:
case 9:
response = _context2.sent;
_context2.next = 15;
_context2.next = 12;
return response.arrayBuffer();
case 15:
case 12:
arrayBuffer = _context2.sent;

@@ -170,3 +161,3 @@ gltf.buffers[i] = {

case 18:
case 15:
++i;

@@ -176,3 +167,3 @@ _context2.next = 1;

case 21:
case 18:
case "end":

@@ -239,3 +230,3 @@ return _context2.stop();

uri = getFullUri(image.uri, options.uri);
uri = resolveUrl(image.uri, options);
_context4.next = 5;

@@ -242,0 +233,0 @@ return fetch(uri);

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

import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import _typeof from "@babel/runtime/helpers/esm/typeof";

@@ -398,7 +400,17 @@ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";

image.getImageAsync = function () {
assert(image.image);
return image.image;
};
image.getImageAsync = _asyncToGenerator(_regeneratorRuntime.mark(function _callee() {
return _regeneratorRuntime.wrap(function _callee$(_context) {
while (1) {
switch (_context.prev = _context.next) {
case 0:
console.warn('loaders.gl/gltf: image.getImageAsync will be removed in 2.0');
return _context.abrupt("return", image.image);
case 2:
case "end":
return _context.stop();
}
}
}, _callee);
}));
return image;

@@ -405,0 +417,0 @@ }

export default function assert(condition, message) {
if (!condition) {
throw new Error(message || 'gltf/glb assertion failed.');
throw new Error(message || 'assert failed: gltf');
}
}
//# sourceMappingURL=assert.js.map

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

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
var _toArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toArray"));
var _require = require('@loaders.gl/gltf'),
GLBParser = _require.GLBParser,
GLTFParser = _require.GLTFParser;
var _require2 = require('@loaders.gl/core'),
toArrayBuffer = _require2.toArrayBuffer;
var fs = require('fs');
var MAX_LENGTH = 76;
function printHelp() {
console.log('glbdump: no glb files specified...');
console.log('glbdump --json Pretty prints the JSON chunk...');
console.log('glbdump --gltf Parses as glTF and pretty prints all scenes...');
process.exit(0);
}
var options;
function main() {
var _process$argv = (0, _toArray2["default"])(process.argv),
args = _process$argv.slice(2);
if (args.length === 0) {
printHelp();
}
options = parseOptions(args);
var _iteratorNormalCompletion = true;
var _didIteratorError = false;
var _iteratorError = undefined;
try {
for (var _iterator = args[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
var filename = _step.value;
if (filename.indexOf('--') !== 0) {
dumpFile(filename);
}
}
} catch (err) {
_didIteratorError = true;
_iteratorError = err;
} finally {
try {
if (!_iteratorNormalCompletion && _iterator["return"] != null) {
_iterator["return"]();
}
} finally {
if (_didIteratorError) {
throw _iteratorError;
}
}
}
}
main();
function dumpFile(filename) {
console.log("\nGLB dump of ".concat(filename, ":"));
var binary = fs.readFileSync(filename);
var arrayBuffer = toArrayBuffer(binary);
var data = new GLBParser().parseSync(arrayBuffer, {
ignoreMagic: true
}).getJSON();
if (options.dumpGLTF) {
dumpGLTFScenes(data);
} else {
dumpGLBSegments(data);
}
if (options.dumpJSON) {
console.log(JSON.stringify(data, null, 2));
}
}
function dumpGLBSegments(data) {
for (var key in data) {
var array = data[key];
if (Array.isArray(array)) {
logArray(key, array);
} else if (array && (0, _typeof2["default"])(array) === 'object') {
logObject(key, array);
}
}
}
var prevHeading = null;
function printHeading(heading) {
if (heading !== prevHeading) {
console.log(heading.toUpperCase());
prevHeading = heading;
}
}
function logArray(key, array) {
array.forEach(function (object, i) {
printHeading(key);
console.log(" ".concat(i, ": ").concat(JSON.stringify(object).slice(0, MAX_LENGTH), "..."));
});
}
function logObject(field, object) {
Object.keys(object).forEach(function (key, i) {
printHeading(field);
console.log(" ".concat(i, ": ").concat(JSON.stringify(object[key]).slice(0, MAX_LENGTH), "..."));
});
}
function dumpGLTFScenes(data) {
var gltfParser = new GLTFParser();
var gltf = gltfParser.parseSync(data);
if (gltf.asset) {
console.log(JSON.stringify(gltf.asset, null, 2));
}
var scenes = gltf.scenes || [];
var _iteratorNormalCompletion2 = true;
var _didIteratorError2 = false;
var _iteratorError2 = undefined;
try {
for (var _iterator2 = scenes[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
var scene = _step2.value;
console.log(JSON.stringify(scene, null, 2));
}
} catch (err) {
_didIteratorError2 = true;
_iteratorError2 = err;
} finally {
try {
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) {
_iterator2["return"]();
}
} finally {
if (_didIteratorError2) {
throw _iteratorError2;
}
}
}
}
function parseOptions(args) {
var opts = {
dumpJSON: false
};
var _iteratorNormalCompletion3 = true;
var _didIteratorError3 = false;
var _iteratorError3 = undefined;
try {
for (var _iterator3 = args[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
var arg = _step3.value;
if (arg.indexOf('--') === 0) {
switch (arg) {
case '--json':
opts.dumpJSON = true;
break;
case '--gltf':
opts.dumpGLTF = true;
break;
case '--help':
printHelp();
break;
default:
console.warn("Unknown option ".concat(arg));
}
}
}
} catch (err) {
_didIteratorError3 = true;
_iteratorError3 = err;
} finally {
try {
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) {
_iterator3["return"]();
}
} finally {
if (_didIteratorError3) {
throw _iteratorError3;
}
}
}
return opts;
}
"use strict";
{
"name": "@loaders.gl/gltf",
"version": "2.0.0-alpha.1",
"version": "2.0.0-alpha.2",
"description": "Framework-independent loader for the glTF format",

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

"dependencies": {
"@loaders.gl/core": "2.0.0-alpha.1",
"@loaders.gl/images": "2.0.0-alpha.1",
"@loaders.gl/loader-utils": "2.0.0-alpha.1"
"@loaders.gl/core": "2.0.0-alpha.2",
"@loaders.gl/images": "2.0.0-alpha.2",
"@loaders.gl/loader-utils": "2.0.0-alpha.2"
},
"gitHead": "cff57d05c0495fa661119005cffd886ed6ed1025"
"gitHead": "1bc3e4e6522a2a337f972799f63682464500a313"
}
// Binary container format for glTF
import {parseGLTF} from './lib/parse-gltf';
import GLTFParser from './lib/deprecated/gltf-parser';

@@ -19,5 +18,2 @@ const GLTFLoader = {

gltf: {
parserVersion: 1, // the new parser that will be the only option in V2 is not default in V1
// Note: The following options are used only when parserVersion === 2
loadBuffers: true, // Fetch any linked .BIN buffers, decode base64

@@ -29,10 +25,2 @@ loadImages: true, // Create image objects

// DEPRECATED OPTIONS for the v1 glTF parser
// useGLTFParser: false,
// fetchImages: true, // Fetch any linked .BIN buffers, decode base64
// createImages: false, // Create image objects
// decompress: true,
// postProcess: true,
// fetchLinkedResources: true, // Fetch any linked .BIN buffers, decode base64
// common?

@@ -52,8 +40,2 @@ uri: '', // base URI

// Deprecated v1 Parser: Returns `GLTFParser` instance, instead of "pure" js object
if (options.gltf.parserVersion !== 2 && options.useGLTFParser !== false) {
const gltfParser = new GLTFParser();
return gltfParser.parse(arrayBuffer, options);
}
const {byteOffset = 0} = options;

@@ -60,0 +42,0 @@ const gltf = {};

@@ -10,5 +10,3 @@ import {encodeGLTFSync} from './lib/encode-gltf';

binary: true,
defaultOptions: {
useGLTFBuilder: true // Note: GLTFBuilder will be removed in v2
}
options: {}
};

@@ -15,0 +13,0 @@

@@ -16,13 +16,5 @@ // Constants

// For 3D Tiles
export {encodeGLTFSync} from './lib/encode-gltf';
// DEPRECATED
export {default as packBinaryJson} from './lib/deprecated/packed-json/pack-binary-json';
export {default as unpackBinaryJson} from './lib/deprecated/packed-json/unpack-binary-json';
export {default as GLBParser} from './lib/deprecated/glb-parser';
export {default as GLBBuilder} from './lib/deprecated/glb-builder';
export {default as GLTFParser} from './lib/deprecated/gltf-parser';
export {default as GLTFBuilder} from './lib/deprecated/gltf-builder';
export {encodeGLTFSync} from './lib/encode-gltf'; // For 3D Tiles

@@ -6,3 +6,2 @@ /* eslint-disable camelcase, max-statements */

import encodeGLBSync from '../encode-glb';
import packBinaryJson from './packed-json/pack-binary-json';

@@ -84,4 +83,3 @@ export default class GLBBuilder {

addApplicationData(key, data, packOptions = {}) {
const jsonData = packOptions.packTypedArrays ? packBinaryJson(data, this, packOptions) : data;
this.json[key] = jsonData;
this.json[key] = data;
return this;

@@ -88,0 +86,0 @@ }

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

import {getImageMetadata} from '@loaders.gl/images';
import {getBinaryImageMIMEType, getBinaryImageSize} from '@loaders.gl/images';
import assert from '../utils/assert';

@@ -206,6 +206,5 @@ import {KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION} from '../gltf-constants';

// Get the properties of the image to add as metadata.
const sizeAndType = getImageMetadata(imageData) || {};
if (sizeAndType) {
// width and height are non-spec fields
const {mimeType, width, height} = sizeAndType;
const mimeType = getBinaryImageMIMEType(imageData) || {};
if (mimeType) {
const {width, height} = getBinaryImageSize(imageData, mimeType) || {};
this.json.images.push({

@@ -212,0 +211,0 @@ bufferView: bufferViewIndex,

@@ -58,4 +58,5 @@ // https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_draco_mesh_compression

// this will generate an exception if DracoLoader is not installed
const {parse} = context;
const decodedData = await parse(bufferCopy, options);
const decodedData = await parse(bufferCopy, [], options, context);

@@ -62,0 +63,0 @@ primitive.attributes = getGLTFAccessors(decodedData.attributes);

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

import {getImageMIMEType} from '@loaders.gl/images';
import {getBinaryImageMIMEType} from '@loaders.gl/images';
import {padTo4Bytes, copyToArray} from '@loaders.gl/loader-utils';

@@ -302,3 +302,3 @@ import assert from './utils/assert';

// "a reference to a bufferView; in that case mimeType must be defined."
mimeType = mimeType || getImageMIMEType(imageData);
mimeType = mimeType || getBinaryImageMIMEType(imageData);

@@ -305,0 +305,0 @@ const bufferViewIndex = this.addBufferView(imageData);

@@ -64,7 +64,1 @@ import assert from '../utils/assert';

}
export function getFullUri(uri, base) {
// TODO: Use better logic to handle all protocols plus not delay on data
const absolute = uri.startsWith('data:') || uri.startsWith('http:') || uri.startsWith('https:');
return absolute ? uri : base.substr(0, base.lastIndexOf('/') + 1) + uri;
}

@@ -56,3 +56,2 @@ /* eslint-disable camelcase, max-statements */

glb.json = {};
glb.hasBinChunk = false;
glb.binChunks = [];

@@ -62,5 +61,2 @@

// DEPRECATED - duplicate header fields in root of returned object
addDeprecatedFields(glb);
return byteOffset + glb.header.byteLength;

@@ -85,3 +81,3 @@ }

// DEPRECATED - Backward compatibility for very old xviz files
// Backward compatibility for very old xviz files
case GLB_CHUNK_TYPE_JSON_XVIZ_DEPRECATED:

@@ -134,11 +130,1 @@ if (!options.glb.strict) {

}
// DEPRECATED
function addDeprecatedFields(glb) {
glb.byteOffset = glb.header.byteOffset;
glb.byteLength = glb.header.byteLength;
glb.hasBinChunk = glb.binChunks.length >= 1;
glb.binChunkByteOffset = glb.header.hasBinChunk ? glb.binChunks[0].byteOffset : 0;
glb.binChunkLength = glb.header.hasBinChunk ? glb.binChunks[0].byteLength : 0;
}

@@ -6,3 +6,3 @@ /* eslint-disable camelcase, max-statements, no-restricted-globals */

import assert from './utils/assert';
import {getFullUri} from './gltf-utils/gltf-utils';
import {resolveUrl} from './gltf-utils/resolve-url';
import {getTypedArrayForBufferView} from './gltf-utils/get-typed-array';

@@ -76,6 +76,6 @@ import {decodeExtensions} from './extensions/gltf-extensions';

const buffers = gltf.json.buffers || [];
gltf.buffers = new Array(buffers.length).fill({});
gltf.buffers = new Array(buffers.length).fill(null);
// Populates JSON and some bin chunk info
if (gltf._glb && gltf._glb.hasBinChunk) {
if (gltf._glb && gltf._glb.header.hasBinChunk) {
const {binChunks} = gltf._glb;

@@ -103,13 +103,6 @@ gltf.buffers[0] = {

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);
const uri = resolveUrl(buffer.uri, options);
const response = await fetch(uri);

@@ -147,3 +140,3 @@ const arrayBuffer = await response.arrayBuffer();

if (image.uri) {
const uri = getFullUri(image.uri, options.uri);
const uri = resolveUrl(image.uri, options);
const response = await fetch(uri);

@@ -150,0 +143,0 @@ arrayBuffer = await response.arrayBuffer();

@@ -327,10 +327,8 @@ import assert from './utils/assert';

image.image = preloadedImage;
// delete image.uri;
// delete image.bufferView;
}
// DEPRECATED: just use image.image
image.getImageAsync = () => {
// Check if already loaded
assert(image.image);
// TODO - DEPRECATED - remove as soon as luma.gl is updated
image.getImageAsync = async () => {
// eslint-disable-next-line
console.warn('loaders.gl/gltf: image.getImageAsync will be removed in 2.0');
return image.image;

@@ -337,0 +335,0 @@ };

@@ -6,4 +6,4 @@ // Replacement for the external assert method to reduce bundle size

if (!condition) {
throw new Error(message || 'gltf/glb assertion failed.');
throw new Error(message || 'assert failed: gltf');
}
}

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

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

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