@loaders.gl/gltf
Advanced tools
Comparing version 2.0.0 to 2.0.1
@@ -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 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,"a",(function(){return i})),n.d(t,"b",(function(){return o}));const s={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document},i=s.global||s.self||s.window,o="object"!=typeof r||"[object process]"!==String(r)||r.browser,a=void 0!==r&&r.version&&r.version.match(/v([0-9]*)/);a&&parseFloat(a[1])}).call(this,n(3),n(5))},,,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 q})),n.d(r,"encode",(function(){return W}));var s={};n.r(s),n.d(s,"decode",(function(){return K})),n.d(s,"encode",(function(){return J}));var i={};n.r(i),n.d(i,"decode",(function(){return Q})),n.d(i,"encode",(function(){return Y}));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",version:"2.0.0",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vndmicrosofticon","image/svg+xml"],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)]),r=t&&t.imagebitmap;return r?createImageBitmap(n):createImageBitmap(n,r)}(e,t);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 O(e,t,n){const r=n?new Uint8Array(e).subarray(t,t+n):new Uint8Array(e).subarray(t);return new Uint8Array(r).buffer}function R(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}function D(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}}class G{constructor(e){if(e instanceof G)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}=D(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=R(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 z(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 q(e,t,n){if(!t.gltf.decompressMeshes)return;const r=new G(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(X(e,r,t,n));await Promise.all(s),r.removeExtension(o)}function W(e,t={}){const n=new G(e);for(const e of n.json.meshes||[])H(e,t),n.addRequiredExtension(o)}async function X(e,t,n,r){const s=t.getObjectExtension(e,o),i=t.getTypedArrayForBufferView(s.bufferView),a=O(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=z(r);t[n]=e}}return t}(f.attributes),f.indices&&(e.indices=z(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 H(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 K(e,t){const n=new G(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 J(e,t){const n=new G(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 Q(e,t){const n=new G(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 Y(e,t){const n=new G(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 Z={KHR_draco_mesh_compression:r,KHR_lights_punctual:s,KHR_materials_unlit:i};function ee(e,t){if(!e)throw new Error(t||"loader assertion failed.")}const te=1735152710,ne=12,re=8,se=1313821514,ie=5130562,oe=0,ae=1,ue=!0;function fe(e,t=0,n={}){const r=new DataView(e),{magic:s=te}=n,i=r.getUint32(t,!1);return i===s||i===te}function ce(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,ue);const i=s.getUint32(n+8,ue);return e.header={byteOffset:n,byteLength:i},ee(2===e.version,`Invalid GLB version ${e.version}. Only supports v2.`),ee(e.header.byteLength>ne+re),e.json={},e.binChunks=[],function(e,t,n,r){for(;n+8<=e.header.byteLength;){const s=t.getUint32(n+0,ue),i=t.getUint32(n+4,ue);switch(n+=re,i){case se:he(e,t,n,s,r);break;case ie:le(e,t,n,s,r);break;case oe:r.glb.strict||he(e,t,n,s,r);break;case ae:r.glb.strict||le(e,t,n,s,r)}n+=L(s)}}(e,s,n+ne,r),n+e.header.byteLength}function he(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 le(e,t,n,r,s){e.header.hasBinChunk=!0,e.binChunks.push({byteOffset:n,byteLength:r,arrayBuffer:t.buffer})}const ge={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},de={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},me={TEXTURE_MAG_FILTER:10240,TEXTURE_MIN_FILTER:10241,TEXTURE_WRAP_S:10242,TEXTURE_WRAP_T:10243,REPEAT:10497,LINEAR:9729,NEAREST_MIPMAP_LINEAR:9986},be={magFilter:me.TEXTURE_MAG_FILTER,minFilter:me.TEXTURE_MIN_FILTER,wrapS:me.TEXTURE_WRAP_S,wrapT:me.TEXTURE_WRAP_T},ye={[me.TEXTURE_MAG_FILTER]:me.LINEAR,[me.TEXTURE_MIN_FILTER]:me.NEAREST_MIPMAP_LINEAR,[me.TEXTURE_WRAP_S]:me.REPEAT,[me.TEXTURE_WRAP_]:me.REPEAT};class pe{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,n)=>this._resolveAccessor(e,n,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;if(e.id=e.id||`accessor-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView)),e.bytesPerComponent=(n=e.componentType,de[n]),e.components=(r=e.type,ge[r]),e.bytesPerElement=e.bytesPerComponent*e.components,e.bufferView){const t=e.bufferView.buffer,{ArrayType:n,length:r}=D(e,e.bufferView),s=(e.bufferView.byteOffset||0)+t.byteOffset;e.value=new n(t.arrayBuffer,s,r)}return e}_resolveTexture(e,t){return e.id=e.id||`texture-${t}`,e.sampler="sampler"in e?this.getSampler(e.sampler):ye,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 be[e]}_resolveImage(e,t){e.id=e.id||`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const n=this.images[t];return n&&(e.image=n),e}_resolveBufferView(e,t){e.id=e.id||`bufferView-${t}`;const n=e.buffer;e.buffer=this.buffers[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 we(e,t){return(new pe).postProcess(e,t)}async function je(e,t,n=0,r,s){!function(e,t,n,r){r.uri&&(e.baseUri=r.uri);if(t instanceof ArrayBuffer&&!fe(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=ce(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(xe(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 Z){const s=t.gltf.excludeExtensions||{};if(!(r in s&&!s[r])){const s=Z[r];await s.decode(e,t,n)}}}(e,r,s);return i.push(o),await Promise.all(i),r.gltf.postProcess?we(e,r):e}async function xe(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=O(n.buffer,n.byteOffset,n.byteLength)}V(a,"glTF image has no data");const u=await o(a,_,{},s);e.images[n]=u}const Te={id:"gltf",name:"glTF",version:"2.0.0",extensions:["gltf","glb"],mimeType:"model/gltf+json",text:!0,binary:!0,test:"glTF",parse:async function(e,t={},n){(t={...Te.options,...t}).gltf={...Te.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 je({},e,r,t,n)},options:{gltf:{loadBuffers:!0,loadImages:!0,decompressMeshes:!0,postProcess:!0},uri:"",log:console}};var ve=Te;function Ee(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 Ae=1179937895,_e=1313821514,Be=5130562,Ue=!0;function Le(e,t,n=0,r={}){const{magic:s=Ae,version:i=2,json:o={},binary:a}=e,u=n;t&&(t.setUint32(n+0,s,Ue),t.setUint32(n+4,i,Ue),t.setUint32(n+8,0,Ue));const f=n+8,c=n+=12;if(t&&(t.setUint32(n+0,0,Ue),t.setUint32(n+4,_e,Ue)),n=function(e,t,n,r){return t=Ee(e,t,(new TextEncoder).encode(n))}(t,n+=8,JSON.stringify(o)),t){const e=n-c-8;t.setUint32(c+0,e,Ue)}if(a){const e=n;if(t&&(t.setUint32(n+0,0,Ue),t.setUint32(n+4,Be,Ue)),n=Ee(t,n+=8,a),t){const r=n-e-8;t.setUint32(e+0,r,Ue)}}if(t){const e=n-u;t.setUint32(f,e,Ue)}return n}function Oe(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),Le(e,t,n,r)}var Re={name:"glTF",extensions:["glb"],mimeType:"model/gltf+json",encodeSync:function(e,t={}){const{byteOffset:n=0}=t,r=Oe(e,null,n,t),s=new ArrayBuffer(r),i=new DataView(s);return Oe(e,i,n,t),s},binary:!0,options:{}};var Ve={id:"glb",name:"GLB",version:"2.0.0",extensions:["glb"],mimeType:"model/gltf-binary",binary:!0,parse:async(e,t)=>Se(e,t),parseSync:Se,options:{glb:{strict:!1}}};function Se(e,t){const{byteOffset:n=0}=t,r={};return ce(r,e,n,t),r}var Ie={name:"GLB",extensions:["glb"],mimeType:"model/gltf-binary",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:{glb:{}}};function Me(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 Ce{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(Me(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=Le(t,null,0,e),r=new ArrayBuffer(n);return Le(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=R(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 ve})),n.d(t,"GLTFWriter",(function(){return Re})),n.d(t,"GLBLoader",(function(){return Ve})),n.d(t,"GLBWriter",(function(){return Ie})),n.d(t,"GLTFScenegraph",(function(){return G})),n.d(t,"postProcessGLTF",(function(){return we})),n.d(t,"GLBBuilder",(function(){return Ce})),n.d(t,"encodeGLTFSync",(function(){return Oe}))}])})); | ||
!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,"a",(function(){return i})),n.d(t,"b",(function(){return o}));const s={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document},i=s.global||s.self||s.window,o="object"!=typeof r||"[object process]"!==String(r)||r.browser,a=void 0!==r&&r.version&&r.version.match(/v([0-9]*)/);a&&parseFloat(a[1])}).call(this,n(3),n(5))},,,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="undefined"!=typeof Image,g=Boolean(c.a._parseImageNode);function d(e){switch(e){case"auto":return!0;case"imagebitmap":return h;case"html":return l;case"ndarray":return g;default:throw new Error(`Unknown image format ${e}`)}}const m=!1,b=!0,y=new Map([["image/png",{test:p,getSize:function(e){return{width:e.getUint32(16,m),height:e.getUint32(20,m)}}}],["image/jpeg",{test:x,getSize:function(e){if(e.byteLength<2||65496!==e.getUint16(0,m))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,m);if(n.has(s))return{height:e.getUint16(r+5,m),width:e.getUint16(r+7,m)};if(!t.has(s))return null;r+=2,r+=e.getUint16(r,m)}return null}}],["image/gif",{test:w,getSize:function(e){return{width:e.getUint16(6,b),height:e.getUint16(8,b)}}}],["image/bmp",{test:j,getSize:function(e){return{width:e.getUint32(18,b),height:e.getUint32(22,b)}}}]]);function p(e){return e.byteLength>=24&&2303741511===e.getUint32(0,m)}function w(e){return e.byteLength>=10&&1195984440===e.getUint32(0,m)}function j(e){return e.byteLength>=2&&16973===e.getUint16(0,m)}function x(e){return e.byteLength>=3&&65496===e.getUint16(0,m)&&255===e.getUint8(2,m)}Array.from(y.keys()).join(", ");function T(e){const t=v(e);for(const[e,{test:n}]of y.entries())if(n(t))return e;return null}function v(e){if((e=e.buffer||e)instanceof ArrayBuffer||ArrayBuffer.isView(e))return new DataView(e.buffer||e);throw new Error("toDataView")}async function E(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 A={name:"Images",version:"2.0.0",mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp","image/vndmicrosofticon","image/svg+xml"],extensions:["png","jpg","jpeg","gif","webp","bmp","ico","svg"],parse:async function(e,t,n){t=t||{};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 E(r,t)}(e,t);switch(function(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}`)}}(t)){case"imagebitmap":return await function(e,t){const n=new Blob([new Uint8Array(e)]),r=t&&t.imagebitmap;return r?createImageBitmap(n):createImageBitmap(n,r)}(e,t);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 E(s,t)}finally{r.revokeObjectURL(s)}}(e,t);case"ndarray":return await function(e,t){f(c.a._parseImageNode);const n=T(e);return c.a._parseImageNode(e,n,t)}(e,t);default:return f(!1)}},test:e=>{const t=new DataView(e);return x(t)||j(t)||w(t)||p(t)},options:{image:{format:"auto",decode:!0}}};function _(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 B(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 _(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return _(e,0,t)}return""}(e)}"`)}}function U(e){return e+3&-4}function L(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+U(r.byteLength)}function R(e,t){if(!e)throw new Error(t||"assert failed: gltf")}function V(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 S(e,t,n){const r=e.bufferViews[n];R(r);const s=t[r.buffer];R(s);const i=(r.byteOffset||0)+s.byteOffset;return new Uint8Array(s.arrayBuffer,i,r.byteLength)}const I=["SCALAR","VEC2","VEC3","VEC4"],C=new Map([[Int8Array,5120],[Uint8Array,5121],[Int16Array,5122],[Uint16Array,5123],[Uint32Array,5125],[Float32Array,5126]]),M={SCALAR:1,VEC2:2,VEC3:3,VEC4:4,MAT2:4,MAT3:9,MAT4:16},k={5120:1,5121:1,5122:2,5123:2,5125:4,5126:4},F={5120:Int8Array,5121:Uint8Array,5122:Int16Array,5123:Uint16Array,5125:Uint32Array,5126:Float32Array};function P(e){return I[e-1]||I[0]}function $(e){const t=C.get(e.constructor);if(!t)throw new Error("Illegal typed array");return t}function N(e,t){const n=F[e.componentType],r=M[e.type],s=k[e.componentType],i=e.count*r,o=e.count*r*s;return R(o>=0&&o<=t.byteLength),{ArrayType:n,length:i,byteLength:o}}class D{constructor(e){if(e instanceof D)return e;e||(e={json:{version:2,buffers:[]},buffers:[]}),this.gltf=e,R(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];R(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}=N(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 R(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 R(t),this.json.extensions=this.json.extensions||{},this.json.extensions[e]=t,this.registerUsedExtension(e),this}addRequiredExtension(e,t){return R(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||T(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;R(Number.isFinite(t)),this.sourceBuffers=this.sourceBuffers||[],this.sourceBuffers.push(e);const n={buffer:0,byteOffset:this.byteLength,byteLength:t};return this.byteLength+=U(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:P(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:$(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:P(r),componentType:$(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=L(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.addExtension(a);R(!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.addExtension(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+=U(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 R(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,n)=>this._resolveAccessor(e,n,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;if(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.bufferView){const t=e.bufferView.buffer,{ArrayType:n,length:r}=N(e,e.bufferView),s=(e.bufferView.byteOffset||0)+t.byteOffset;e.value=new n(t.arrayBuffer,s,r)}return 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){e.id=e.id||`image-${t}`,void 0!==e.bufferView&&(e.bufferView=this.getBufferView(e.bufferView));const n=this.images[t];return n&&(e.image=n),e}_resolveBufferView(e,t){e.id=e.id||`bufferView-${t}`;const n=e.buffer;e.buffer=this.buffers[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=B(t);else if(t instanceof ArrayBuffer){const s={};n=fe(s,t,n,r),R("glTF"===s.type,`Invalid GLB magic string ${s.type}`),e._glb=s,e.json=s.json}else R(!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;R(i);const o=V(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=V(t.uri,r),n=await i(e);a=await n.arrayBuffer()}if(Number.isFinite(t.bufferView)){const n=S(e.json,e.buffers,t.bufferView);a=L(n.buffer,n.byteOffset,n.byteLength)}R(a,"glTF image has no data");const u=await o(a,A,{},s);e.images[n]=u}const xe={id:"gltf",name:"glTF",version:"2.0.0",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=U(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 Oe={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 Re={id:"glb",name:"GLB",version:"2.0.0",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 Ce{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:$(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+=U(t),this.sourceBuffers.push(e),this.json.bufferViews.length-1}addAccessor(e,t){return this.json.accessors.push({bufferView:e,type:P(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 Oe})),n.d(t,"GLBLoader",(function(){return Re})),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 Ce})),n.d(t,"encodeGLTFSync",(function(){return Le}))}])})); |
@@ -12,2 +12,4 @@ "use strict"; | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _parseGlb = _interopRequireDefault(require("./lib/parse-glb")); | ||
@@ -23,16 +25,24 @@ | ||
binary: true, | ||
parse: function parse(arrayBuffer, options) { | ||
return _regenerator["default"].async(function parse$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", parseSync(arrayBuffer, options)); | ||
parse: function () { | ||
var _parse = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(arrayBuffer, options) { | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", parseSync(arrayBuffer, options)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, | ||
}, _callee); | ||
})); | ||
function parse(_x, _x2) { | ||
return _parse.apply(this, arguments); | ||
} | ||
return parse; | ||
}(), | ||
parseSync: parseSync, | ||
@@ -39,0 +49,0 @@ options: { |
@@ -15,2 +15,4 @@ "use strict"; | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _parseGltf = require("./lib/parse-gltf"); | ||
@@ -47,34 +49,41 @@ | ||
function parse(arrayBuffer) { | ||
var options, | ||
context, | ||
_options, | ||
_options$byteOffset, | ||
byteOffset, | ||
gltf, | ||
_args = arguments; | ||
function parse(_x) { | ||
return _parse.apply(this, arguments); | ||
} | ||
return _regenerator["default"].async(function parse$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
context = _args.length > 2 ? _args[2] : undefined; | ||
options = _objectSpread({}, GLTFLoader.options, {}, options); | ||
options.gltf = _objectSpread({}, GLTFLoader.options.gltf, {}, options.gltf); | ||
addDeprecatedGLTFOptions(options); | ||
_options = options, _options$byteOffset = _options.byteOffset, byteOffset = _options$byteOffset === void 0 ? 0 : _options$byteOffset; | ||
gltf = {}; | ||
_context.next = 9; | ||
return _regenerator["default"].awrap((0, _parseGltf.parseGLTF)(gltf, arrayBuffer, byteOffset, options, context)); | ||
function _parse() { | ||
_parse = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(arrayBuffer) { | ||
var options, | ||
context, | ||
_options, | ||
_options$byteOffset, | ||
byteOffset, | ||
gltf, | ||
_args = arguments; | ||
case 9: | ||
return _context.abrupt("return", _context.sent); | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
context = _args.length > 2 ? _args[2] : undefined; | ||
options = _objectSpread({}, GLTFLoader.options, {}, options); | ||
options.gltf = _objectSpread({}, GLTFLoader.options.gltf, {}, options.gltf); | ||
addDeprecatedGLTFOptions(options); | ||
_options = options, _options$byteOffset = _options.byteOffset, byteOffset = _options$byteOffset === void 0 ? 0 : _options$byteOffset; | ||
gltf = {}; | ||
_context.next = 9; | ||
return (0, _parseGltf.parseGLTF)(gltf, arrayBuffer, byteOffset, options, context); | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
case 9: | ||
return _context.abrupt("return", _context.sent); | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee); | ||
})); | ||
return _parse.apply(this, arguments); | ||
} | ||
@@ -81,0 +90,0 @@ |
@@ -183,3 +183,5 @@ "use strict"; | ||
var compressedData = this.DracoWriter.encodeSync(attributes, { | ||
pointcloud: true | ||
draco: { | ||
pointcloud: true | ||
} | ||
}); | ||
@@ -186,0 +188,0 @@ var bufferViewIndex = this.addBufferView(compressedData); |
@@ -15,2 +15,4 @@ "use strict"; | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var KHR_draco_mesh_compression = _interopRequireWildcard(require("./KHR_draco_mesh_compression")); | ||
@@ -29,49 +31,56 @@ | ||
function decodeExtensions(gltf) { | ||
var options, | ||
context, | ||
extensionName, | ||
excludes, | ||
exclude, | ||
extension, | ||
_args = arguments; | ||
return _regenerator["default"].async(function decodeExtensions$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
context = _args.length > 2 ? _args[2] : undefined; | ||
options.gltf = options.gltf || {}; | ||
_context.t0 = _regenerator["default"].keys(EXTENSIONS); | ||
function decodeExtensions(_x) { | ||
return _decodeExtensions.apply(this, arguments); | ||
} | ||
case 4: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 14; | ||
break; | ||
} | ||
function _decodeExtensions() { | ||
_decodeExtensions = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(gltf) { | ||
var options, | ||
context, | ||
extensionName, | ||
excludes, | ||
exclude, | ||
extension, | ||
_args = arguments; | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
context = _args.length > 2 ? _args[2] : undefined; | ||
options.gltf = options.gltf || {}; | ||
_context.t0 = _regenerator["default"].keys(EXTENSIONS); | ||
extensionName = _context.t1.value; | ||
excludes = options.gltf.excludeExtensions || {}; | ||
exclude = extensionName in excludes && !excludes[extensionName]; | ||
case 4: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 14; | ||
break; | ||
} | ||
if (exclude) { | ||
extensionName = _context.t1.value; | ||
excludes = options.gltf.excludeExtensions || {}; | ||
exclude = extensionName in excludes && !excludes[extensionName]; | ||
if (exclude) { | ||
_context.next = 12; | ||
break; | ||
} | ||
extension = EXTENSIONS[extensionName]; | ||
_context.next = 12; | ||
return extension.decode(gltf, options, context); | ||
case 12: | ||
_context.next = 4; | ||
break; | ||
} | ||
extension = EXTENSIONS[extensionName]; | ||
_context.next = 12; | ||
return _regenerator["default"].awrap(extension.decode(gltf, options, context)); | ||
case 12: | ||
_context.next = 4; | ||
break; | ||
case 14: | ||
case "end": | ||
return _context.stop(); | ||
case 14: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee); | ||
})); | ||
return _decodeExtensions.apply(this, arguments); | ||
} | ||
//# sourceMappingURL=gltf-extensions.js.map |
@@ -11,5 +11,7 @@ "use strict"; | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty")); | ||
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator")); | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
@@ -26,78 +28,85 @@ var _loaderUtils = require("@loaders.gl/loader-utils"); | ||
function decode(gltfData, options, context) { | ||
var scenegraph, promises, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, primitive; | ||
function decode(_x, _x2, _x3) { | ||
return _decode.apply(this, arguments); | ||
} | ||
return _regenerator["default"].async(function decode$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (options.gltf.decompressMeshes) { | ||
_context.next = 2; | ||
break; | ||
} | ||
function _decode() { | ||
_decode = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(gltfData, options, context) { | ||
var scenegraph, promises, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, primitive; | ||
return _context.abrupt("return"); | ||
return _regenerator["default"].wrap(function _callee$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (options.gltf.decompressMeshes) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
case 2: | ||
scenegraph = new _gltfScenegraph["default"](gltfData); | ||
promises = []; | ||
_iteratorNormalCompletion = true; | ||
_didIteratorError = false; | ||
_iteratorError = undefined; | ||
_context.prev = 7; | ||
return _context2.abrupt("return"); | ||
for (_iterator = meshPrimitiveIterator(scenegraph)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
primitive = _step.value; | ||
case 2: | ||
scenegraph = new _gltfScenegraph["default"](gltfData); | ||
promises = []; | ||
_iteratorNormalCompletion4 = true; | ||
_didIteratorError4 = false; | ||
_iteratorError4 = undefined; | ||
_context2.prev = 7; | ||
if (scenegraph.getObjectExtension(primitive, _gltfConstants.KHR_DRACO_MESH_COMPRESSION)) { | ||
promises.push(decompressPrimitive(primitive, scenegraph, options, context)); | ||
for (_iterator4 = meshPrimitiveIterator(scenegraph)[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
primitive = _step4.value; | ||
if (scenegraph.getObjectExtension(primitive, _gltfConstants.KHR_DRACO_MESH_COMPRESSION)) { | ||
promises.push(decompressPrimitive(primitive, scenegraph, options, context)); | ||
} | ||
} | ||
} | ||
_context.next = 15; | ||
break; | ||
_context2.next = 15; | ||
break; | ||
case 11: | ||
_context.prev = 11; | ||
_context.t0 = _context["catch"](7); | ||
_didIteratorError = true; | ||
_iteratorError = _context.t0; | ||
case 11: | ||
_context2.prev = 11; | ||
_context2.t0 = _context2["catch"](7); | ||
_didIteratorError4 = true; | ||
_iteratorError4 = _context2.t0; | ||
case 15: | ||
_context.prev = 15; | ||
_context.prev = 16; | ||
case 15: | ||
_context2.prev = 15; | ||
_context2.prev = 16; | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) { | ||
_iterator4["return"](); | ||
} | ||
case 18: | ||
_context.prev = 18; | ||
case 18: | ||
_context2.prev = 18; | ||
if (!_didIteratorError) { | ||
_context.next = 21; | ||
break; | ||
} | ||
if (!_didIteratorError4) { | ||
_context2.next = 21; | ||
break; | ||
} | ||
throw _iteratorError; | ||
throw _iteratorError4; | ||
case 21: | ||
return _context.finish(18); | ||
case 21: | ||
return _context2.finish(18); | ||
case 22: | ||
return _context.finish(15); | ||
case 22: | ||
return _context2.finish(15); | ||
case 23: | ||
_context.next = 25; | ||
return _regenerator["default"].awrap(Promise.all(promises)); | ||
case 23: | ||
_context2.next = 25; | ||
return Promise.all(promises); | ||
case 25: | ||
scenegraph.removeExtension(_gltfConstants.KHR_DRACO_MESH_COMPRESSION); | ||
case 25: | ||
scenegraph.removeExtension(_gltfConstants.KHR_DRACO_MESH_COMPRESSION); | ||
case 26: | ||
case "end": | ||
return _context.stop(); | ||
case 26: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}, null, null, [[7, 11, 15, 23], [16,, 18, 22]]); | ||
}, _callee, null, [[7, 11, 15, 23], [16,, 18, 22]]); | ||
})); | ||
return _decode.apply(this, arguments); | ||
} | ||
@@ -108,9 +117,9 @@ | ||
var scenegraph = new _gltfScenegraph["default"](gltfData); | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator2 = (scenegraph.json.meshes || [])[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var mesh = _step2.value; | ||
for (var _iterator = (scenegraph.json.meshes || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var mesh = _step.value; | ||
compressMesh(mesh, options); | ||
@@ -120,12 +129,12 @@ scenegraph.addRequiredExtension(_gltfConstants.KHR_DRACO_MESH_COMPRESSION); | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) { | ||
_iterator2["return"](); | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
@@ -136,31 +145,38 @@ } | ||
function decompressPrimitive(primitive, scenegraph, options, context) { | ||
var compressedPrimitive, buffer, bufferCopy, parse, decodedData; | ||
return _regenerator["default"].async(function decompressPrimitive$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
compressedPrimitive = scenegraph.getObjectExtension(primitive, _gltfConstants.KHR_DRACO_MESH_COMPRESSION); | ||
buffer = scenegraph.getTypedArrayForBufferView(compressedPrimitive.bufferView); | ||
bufferCopy = (0, _loaderUtils.getZeroOffsetArrayBuffer)(buffer.buffer, buffer.byteOffset); | ||
parse = context.parse; | ||
_context2.next = 6; | ||
return _regenerator["default"].awrap(parse(bufferCopy, [], options, context)); | ||
function decompressPrimitive(_x4, _x5, _x6, _x7) { | ||
return _decompressPrimitive.apply(this, arguments); | ||
} | ||
case 6: | ||
decodedData = _context2.sent; | ||
primitive.attributes = (0, _gltfAttributeUtils.getGLTFAccessors)(decodedData.attributes); | ||
function _decompressPrimitive() { | ||
_decompressPrimitive = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(primitive, scenegraph, options, context) { | ||
var compressedPrimitive, buffer, bufferCopy, parse, decodedData; | ||
return _regenerator["default"].wrap(function _callee2$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
compressedPrimitive = scenegraph.getObjectExtension(primitive, _gltfConstants.KHR_DRACO_MESH_COMPRESSION); | ||
buffer = scenegraph.getTypedArrayForBufferView(compressedPrimitive.bufferView); | ||
bufferCopy = (0, _loaderUtils.getZeroOffsetArrayBuffer)(buffer.buffer, buffer.byteOffset); | ||
parse = context.parse; | ||
_context3.next = 6; | ||
return parse(bufferCopy, [], options, context); | ||
if (decodedData.indices) { | ||
primitive.indices = (0, _gltfAttributeUtils.getGLTFAccessor)(decodedData.indices); | ||
} | ||
case 6: | ||
decodedData = _context3.sent; | ||
primitive.attributes = (0, _gltfAttributeUtils.getGLTFAccessors)(decodedData.attributes); | ||
checkPrimitive(primitive); | ||
if (decodedData.indices) { | ||
primitive.indices = (0, _gltfAttributeUtils.getGLTFAccessor)(decodedData.indices); | ||
} | ||
case 10: | ||
case "end": | ||
return _context2.stop(); | ||
checkPrimitive(primitive); | ||
case 10: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee2); | ||
})); | ||
return _decompressPrimitive.apply(this, arguments); | ||
} | ||
@@ -208,118 +224,118 @@ | ||
function meshPrimitiveIterator(scenegraph) { | ||
var _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, mesh, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, primitive; | ||
var _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, mesh, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, primitive; | ||
return _regenerator["default"].wrap(function meshPrimitiveIterator$(_context3) { | ||
return _regenerator["default"].wrap(function meshPrimitiveIterator$(_context) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_iteratorNormalCompletion3 = true; | ||
_didIteratorError3 = false; | ||
_iteratorError3 = undefined; | ||
_context3.prev = 3; | ||
_iterator3 = (scenegraph.json.meshes || [])[Symbol.iterator](); | ||
_iteratorNormalCompletion2 = true; | ||
_didIteratorError2 = false; | ||
_iteratorError2 = undefined; | ||
_context.prev = 3; | ||
_iterator2 = (scenegraph.json.meshes || [])[Symbol.iterator](); | ||
case 5: | ||
if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) { | ||
_context3.next = 36; | ||
if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) { | ||
_context.next = 36; | ||
break; | ||
} | ||
mesh = _step3.value; | ||
_iteratorNormalCompletion4 = true; | ||
_didIteratorError4 = false; | ||
_iteratorError4 = undefined; | ||
_context3.prev = 10; | ||
_iterator4 = mesh.primitives[Symbol.iterator](); | ||
mesh = _step2.value; | ||
_iteratorNormalCompletion3 = true; | ||
_didIteratorError3 = false; | ||
_iteratorError3 = undefined; | ||
_context.prev = 10; | ||
_iterator3 = mesh.primitives[Symbol.iterator](); | ||
case 12: | ||
if (_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done) { | ||
_context3.next = 19; | ||
if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) { | ||
_context.next = 19; | ||
break; | ||
} | ||
primitive = _step4.value; | ||
_context3.next = 16; | ||
primitive = _step3.value; | ||
_context.next = 16; | ||
return primitive; | ||
case 16: | ||
_iteratorNormalCompletion4 = true; | ||
_context3.next = 12; | ||
_iteratorNormalCompletion3 = true; | ||
_context.next = 12; | ||
break; | ||
case 19: | ||
_context3.next = 25; | ||
_context.next = 25; | ||
break; | ||
case 21: | ||
_context3.prev = 21; | ||
_context3.t0 = _context3["catch"](10); | ||
_didIteratorError4 = true; | ||
_iteratorError4 = _context3.t0; | ||
_context.prev = 21; | ||
_context.t0 = _context["catch"](10); | ||
_didIteratorError3 = true; | ||
_iteratorError3 = _context.t0; | ||
case 25: | ||
_context3.prev = 25; | ||
_context3.prev = 26; | ||
_context.prev = 25; | ||
_context.prev = 26; | ||
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) { | ||
_iterator4["return"](); | ||
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) { | ||
_iterator3["return"](); | ||
} | ||
case 28: | ||
_context3.prev = 28; | ||
_context.prev = 28; | ||
if (!_didIteratorError4) { | ||
_context3.next = 31; | ||
if (!_didIteratorError3) { | ||
_context.next = 31; | ||
break; | ||
} | ||
throw _iteratorError4; | ||
throw _iteratorError3; | ||
case 31: | ||
return _context3.finish(28); | ||
return _context.finish(28); | ||
case 32: | ||
return _context3.finish(25); | ||
return _context.finish(25); | ||
case 33: | ||
_iteratorNormalCompletion3 = true; | ||
_context3.next = 5; | ||
_iteratorNormalCompletion2 = true; | ||
_context.next = 5; | ||
break; | ||
case 36: | ||
_context3.next = 42; | ||
_context.next = 42; | ||
break; | ||
case 38: | ||
_context3.prev = 38; | ||
_context3.t1 = _context3["catch"](3); | ||
_didIteratorError3 = true; | ||
_iteratorError3 = _context3.t1; | ||
_context.prev = 38; | ||
_context.t1 = _context["catch"](3); | ||
_didIteratorError2 = true; | ||
_iteratorError2 = _context.t1; | ||
case 42: | ||
_context3.prev = 42; | ||
_context3.prev = 43; | ||
_context.prev = 42; | ||
_context.prev = 43; | ||
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) { | ||
_iterator3["return"](); | ||
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) { | ||
_iterator2["return"](); | ||
} | ||
case 45: | ||
_context3.prev = 45; | ||
_context.prev = 45; | ||
if (!_didIteratorError3) { | ||
_context3.next = 48; | ||
if (!_didIteratorError2) { | ||
_context.next = 48; | ||
break; | ||
} | ||
throw _iteratorError3; | ||
throw _iteratorError2; | ||
case 48: | ||
return _context3.finish(45); | ||
return _context.finish(45); | ||
case 49: | ||
return _context3.finish(42); | ||
return _context.finish(42); | ||
case 50: | ||
case "end": | ||
return _context3.stop(); | ||
return _context.stop(); | ||
} | ||
@@ -326,0 +342,0 @@ } |
@@ -63,3 +63,3 @@ "use strict"; | ||
if (json.lights) { | ||
var extension = gltfScenegraph.addExtensions(_gltfConstants.KHR_LIGHTS_PUNCTUAL); | ||
var extension = gltfScenegraph.addExtension(_gltfConstants.KHR_LIGHTS_PUNCTUAL); | ||
(0, _assert["default"])(!extension.lights); | ||
@@ -66,0 +66,0 @@ extension.lights = json.lights; |
@@ -66,3 +66,3 @@ "use strict"; | ||
gltfScenegraph.addObjectExtension(material, _gltfConstants.KHR_MATERIALS_UNLIT); | ||
gltfScenegraph.addExtensions(_gltfConstants.KHR_MATERIALS_UNLIT); | ||
gltfScenegraph.addExtension(_gltfConstants.KHR_MATERIALS_UNLIT); | ||
} | ||
@@ -69,0 +69,0 @@ } |
@@ -15,2 +15,4 @@ "use strict"; | ||
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator")); | ||
var _images = require("@loaders.gl/images"); | ||
@@ -39,49 +41,56 @@ | ||
function parseGLTF(gltf, arrayBufferOrString) { | ||
var byteOffset, | ||
options, | ||
context, | ||
promises, | ||
_promise, | ||
promise, | ||
_args = arguments; | ||
function parseGLTF(_x, _x2) { | ||
return _parseGLTF.apply(this, arguments); | ||
} | ||
return _regenerator["default"].async(function parseGLTF$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
byteOffset = _args.length > 2 && _args[2] !== undefined ? _args[2] : 0; | ||
options = _args.length > 3 ? _args[3] : undefined; | ||
context = _args.length > 4 ? _args[4] : undefined; | ||
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options); | ||
promises = []; | ||
function _parseGLTF() { | ||
_parseGLTF = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(gltf, arrayBufferOrString) { | ||
var byteOffset, | ||
options, | ||
context, | ||
promises, | ||
_promise, | ||
promise, | ||
_args = arguments; | ||
if (options.gltf.loadImages) { | ||
_promise = loadImages(gltf, options, context); | ||
promises.push(_promise); | ||
} | ||
return _regenerator["default"].wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
byteOffset = _args.length > 2 && _args[2] !== undefined ? _args[2] : 0; | ||
options = _args.length > 3 ? _args[3] : undefined; | ||
context = _args.length > 4 ? _args[4] : undefined; | ||
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options); | ||
promises = []; | ||
if (!options.gltf.loadBuffers) { | ||
if (options.gltf.loadImages) { | ||
_promise = loadImages(gltf, options, context); | ||
promises.push(_promise); | ||
} | ||
if (!options.gltf.loadBuffers) { | ||
_context.next = 9; | ||
break; | ||
} | ||
_context.next = 9; | ||
break; | ||
} | ||
return loadBuffers(gltf, options, context); | ||
_context.next = 9; | ||
return _regenerator["default"].awrap(loadBuffers(gltf, options, context)); | ||
case 9: | ||
promise = (0, _gltfExtensions.decodeExtensions)(gltf, options, context); | ||
promises.push(promise); | ||
_context.next = 13; | ||
return Promise.all(promises); | ||
case 9: | ||
promise = (0, _gltfExtensions.decodeExtensions)(gltf, options, context); | ||
promises.push(promise); | ||
_context.next = 13; | ||
return _regenerator["default"].awrap(Promise.all(promises)); | ||
case 13: | ||
return _context.abrupt("return", options.gltf.postProcess ? (0, _postProcessGltf["default"])(gltf, options) : gltf); | ||
case 13: | ||
return _context.abrupt("return", options.gltf.postProcess ? (0, _postProcessGltf["default"])(gltf, options) : gltf); | ||
case 14: | ||
case "end": | ||
return _context.stop(); | ||
case 14: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee); | ||
})); | ||
return _parseGLTF.apply(this, arguments); | ||
} | ||
@@ -127,129 +136,150 @@ | ||
function loadBuffers(gltf, options, context) { | ||
var i, buffer, fetch, uri, response, arrayBuffer; | ||
return _regenerator["default"].async(function loadBuffers$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
i = 0; | ||
function loadBuffers(_x3, _x4, _x5) { | ||
return _loadBuffers.apply(this, arguments); | ||
} | ||
case 1: | ||
if (!(i < gltf.json.buffers.length)) { | ||
_context2.next = 18; | ||
break; | ||
} | ||
function _loadBuffers() { | ||
_loadBuffers = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee2(gltf, options, context) { | ||
var i, buffer, fetch, uri, response, arrayBuffer; | ||
return _regenerator["default"].wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
i = 0; | ||
buffer = gltf.json.buffers[i]; | ||
case 1: | ||
if (!(i < gltf.json.buffers.length)) { | ||
_context2.next = 18; | ||
break; | ||
} | ||
if (!buffer.uri) { | ||
_context2.next = 15; | ||
break; | ||
} | ||
buffer = gltf.json.buffers[i]; | ||
fetch = context.fetch; | ||
(0, _assert["default"])(fetch); | ||
uri = (0, _resolveUrl.resolveUrl)(buffer.uri, options); | ||
_context2.next = 9; | ||
return _regenerator["default"].awrap(fetch(uri)); | ||
if (!buffer.uri) { | ||
_context2.next = 15; | ||
break; | ||
} | ||
case 9: | ||
response = _context2.sent; | ||
_context2.next = 12; | ||
return _regenerator["default"].awrap(response.arrayBuffer()); | ||
fetch = context.fetch; | ||
(0, _assert["default"])(fetch); | ||
uri = (0, _resolveUrl.resolveUrl)(buffer.uri, options); | ||
_context2.next = 9; | ||
return fetch(uri); | ||
case 12: | ||
arrayBuffer = _context2.sent; | ||
gltf.buffers[i] = { | ||
arrayBuffer: arrayBuffer, | ||
byteOffset: 0, | ||
byteLength: arrayBuffer.byteLength | ||
}; | ||
delete buffer.uri; | ||
case 9: | ||
response = _context2.sent; | ||
_context2.next = 12; | ||
return response.arrayBuffer(); | ||
case 15: | ||
++i; | ||
_context2.next = 1; | ||
break; | ||
case 12: | ||
arrayBuffer = _context2.sent; | ||
gltf.buffers[i] = { | ||
arrayBuffer: arrayBuffer, | ||
byteOffset: 0, | ||
byteLength: arrayBuffer.byteLength | ||
}; | ||
delete buffer.uri; | ||
case 18: | ||
case "end": | ||
return _context2.stop(); | ||
case 15: | ||
++i; | ||
_context2.next = 1; | ||
break; | ||
case 18: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee2); | ||
})); | ||
return _loadBuffers.apply(this, arguments); | ||
} | ||
function loadImages(gltf, options, context) { | ||
var images, promises, i; | ||
return _regenerator["default"].async(function loadImages$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
images = gltf.json.images || []; | ||
promises = []; | ||
function loadImages(_x6, _x7, _x8) { | ||
return _loadImages.apply(this, arguments); | ||
} | ||
for (i = 0; i < images.length; ++i) { | ||
promises.push(loadImage(gltf, images[i], i, options, context)); | ||
} | ||
function _loadImages() { | ||
_loadImages = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee3(gltf, options, context) { | ||
var images, promises, i; | ||
return _regenerator["default"].wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
images = gltf.json.images || []; | ||
promises = []; | ||
_context3.next = 5; | ||
return _regenerator["default"].awrap(Promise.all(promises)); | ||
for (i = 0; i < images.length; ++i) { | ||
promises.push(loadImage(gltf, images[i], i, options, context)); | ||
} | ||
case 5: | ||
return _context3.abrupt("return", _context3.sent); | ||
_context3.next = 5; | ||
return Promise.all(promises); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
case 5: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee3); | ||
})); | ||
return _loadImages.apply(this, arguments); | ||
} | ||
function loadImage(gltf, image, i, options, context) { | ||
var fetch, parse, arrayBuffer, uri, response, array, parsedImage; | ||
return _regenerator["default"].async(function loadImage$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
fetch = context.fetch, parse = context.parse; | ||
function loadImage(_x9, _x10, _x11, _x12, _x13) { | ||
return _loadImage.apply(this, arguments); | ||
} | ||
if (!image.uri) { | ||
_context4.next = 9; | ||
break; | ||
} | ||
function _loadImage() { | ||
_loadImage = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee4(gltf, image, i, options, context) { | ||
var fetch, parse, arrayBuffer, uri, response, array, parsedImage; | ||
return _regenerator["default"].wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
fetch = context.fetch, parse = context.parse; | ||
uri = (0, _resolveUrl.resolveUrl)(image.uri, options); | ||
_context4.next = 5; | ||
return _regenerator["default"].awrap(fetch(uri)); | ||
if (!image.uri) { | ||
_context4.next = 9; | ||
break; | ||
} | ||
case 5: | ||
response = _context4.sent; | ||
_context4.next = 8; | ||
return _regenerator["default"].awrap(response.arrayBuffer()); | ||
uri = (0, _resolveUrl.resolveUrl)(image.uri, options); | ||
_context4.next = 5; | ||
return fetch(uri); | ||
case 8: | ||
arrayBuffer = _context4.sent; | ||
case 5: | ||
response = _context4.sent; | ||
_context4.next = 8; | ||
return response.arrayBuffer(); | ||
case 9: | ||
if (Number.isFinite(image.bufferView)) { | ||
array = (0, _getTypedArray.getTypedArrayForBufferView)(gltf.json, gltf.buffers, image.bufferView); | ||
arrayBuffer = (0, _loaderUtils.getZeroOffsetArrayBuffer)(array.buffer, array.byteOffset, array.byteLength); | ||
} | ||
case 8: | ||
arrayBuffer = _context4.sent; | ||
(0, _assert["default"])(arrayBuffer, 'glTF image has no data'); | ||
_context4.next = 13; | ||
return _regenerator["default"].awrap(parse(arrayBuffer, _images.ImageLoader, {}, context)); | ||
case 9: | ||
if (Number.isFinite(image.bufferView)) { | ||
array = (0, _getTypedArray.getTypedArrayForBufferView)(gltf.json, gltf.buffers, image.bufferView); | ||
arrayBuffer = (0, _loaderUtils.getZeroOffsetArrayBuffer)(array.buffer, array.byteOffset, array.byteLength); | ||
} | ||
case 13: | ||
parsedImage = _context4.sent; | ||
gltf.images[i] = parsedImage; | ||
(0, _assert["default"])(arrayBuffer, 'glTF image has no data'); | ||
_context4.next = 13; | ||
return parse(arrayBuffer, _images.ImageLoader, {}, context); | ||
case 15: | ||
case "end": | ||
return _context4.stop(); | ||
case 13: | ||
parsedImage = _context4.sent; | ||
gltf.images[i] = parsedImage; | ||
case 15: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee4); | ||
})); | ||
return _loadImage.apply(this, arguments); | ||
} | ||
//# sourceMappingURL=parse-gltf.js.map |
@@ -129,3 +129,5 @@ import { getBinaryImageMIMEType, getBinaryImageSize } from '@loaders.gl/images'; | ||
const compressedData = this.DracoWriter.encodeSync(attributes, { | ||
pointcloud: true | ||
draco: { | ||
pointcloud: true | ||
} | ||
}); | ||
@@ -132,0 +134,0 @@ const bufferViewIndex = this.addBufferView(compressedData); |
@@ -33,3 +33,3 @@ import assert from '../utils/assert'; | ||
if (json.lights) { | ||
const extension = gltfScenegraph.addExtensions(KHR_LIGHTS_PUNCTUAL); | ||
const extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL); | ||
assert(!extension.lights); | ||
@@ -36,0 +36,0 @@ extension.lights = json.lights; |
@@ -31,3 +31,3 @@ import GLTFScenegraph from '../gltf-scenegraph'; | ||
gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT); | ||
gltfScenegraph.addExtensions(KHR_MATERIALS_UNLIT); | ||
gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT); | ||
} | ||
@@ -34,0 +34,0 @@ } |
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import parseGLBSync from './lib/parse-glb'; | ||
@@ -11,16 +12,24 @@ var VERSION = typeof "2.0.0" !== 'undefined' ? "2.0.0" : 'latest'; | ||
binary: true, | ||
parse: function parse(arrayBuffer, options) { | ||
return _regeneratorRuntime.async(function parse$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", parseSync(arrayBuffer, options)); | ||
parse: function () { | ||
var _parse = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(arrayBuffer, options) { | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
return _context.abrupt("return", parseSync(arrayBuffer, options)); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
case 1: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, | ||
}, _callee); | ||
})); | ||
function parse(_x, _x2) { | ||
return _parse.apply(this, arguments); | ||
} | ||
return parse; | ||
}(), | ||
parseSync: parseSync, | ||
@@ -27,0 +36,0 @@ options: { |
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
@@ -32,34 +33,41 @@ 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; } | ||
export default GLTFLoader; | ||
export function parse(arrayBuffer) { | ||
var options, | ||
context, | ||
_options, | ||
_options$byteOffset, | ||
byteOffset, | ||
gltf, | ||
_args = arguments; | ||
export function parse(_x) { | ||
return _parse.apply(this, arguments); | ||
} | ||
return _regeneratorRuntime.async(function parse$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
context = _args.length > 2 ? _args[2] : undefined; | ||
options = _objectSpread({}, GLTFLoader.options, {}, options); | ||
options.gltf = _objectSpread({}, GLTFLoader.options.gltf, {}, options.gltf); | ||
addDeprecatedGLTFOptions(options); | ||
_options = options, _options$byteOffset = _options.byteOffset, byteOffset = _options$byteOffset === void 0 ? 0 : _options$byteOffset; | ||
gltf = {}; | ||
_context.next = 9; | ||
return _regeneratorRuntime.awrap(parseGLTF(gltf, arrayBuffer, byteOffset, options, context)); | ||
function _parse() { | ||
_parse = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(arrayBuffer) { | ||
var options, | ||
context, | ||
_options, | ||
_options$byteOffset, | ||
byteOffset, | ||
gltf, | ||
_args = arguments; | ||
case 9: | ||
return _context.abrupt("return", _context.sent); | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
context = _args.length > 2 ? _args[2] : undefined; | ||
options = _objectSpread({}, GLTFLoader.options, {}, options); | ||
options.gltf = _objectSpread({}, GLTFLoader.options.gltf, {}, options.gltf); | ||
addDeprecatedGLTFOptions(options); | ||
_options = options, _options$byteOffset = _options.byteOffset, byteOffset = _options$byteOffset === void 0 ? 0 : _options$byteOffset; | ||
gltf = {}; | ||
_context.next = 9; | ||
return parseGLTF(gltf, arrayBuffer, byteOffset, options, context); | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
case 9: | ||
return _context.abrupt("return", _context.sent); | ||
case 10: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee); | ||
})); | ||
return _parse.apply(this, arguments); | ||
} | ||
@@ -66,0 +74,0 @@ |
@@ -166,3 +166,5 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
var compressedData = this.DracoWriter.encodeSync(attributes, { | ||
pointcloud: true | ||
draco: { | ||
pointcloud: true | ||
} | ||
}); | ||
@@ -169,0 +171,0 @@ var bufferViewIndex = this.addBufferView(compressedData); |
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import * as KHR_draco_mesh_compression from './KHR_draco_mesh_compression'; | ||
@@ -10,49 +11,56 @@ import * as KHR_lights_punctual from './KHR_lights_punctual'; | ||
}; | ||
export function decodeExtensions(gltf) { | ||
var options, | ||
context, | ||
extensionName, | ||
excludes, | ||
exclude, | ||
extension, | ||
_args = arguments; | ||
return _regeneratorRuntime.async(function decodeExtensions$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
context = _args.length > 2 ? _args[2] : undefined; | ||
options.gltf = options.gltf || {}; | ||
_context.t0 = _regeneratorRuntime.keys(EXTENSIONS); | ||
export function decodeExtensions(_x) { | ||
return _decodeExtensions.apply(this, arguments); | ||
} | ||
case 4: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 14; | ||
break; | ||
} | ||
function _decodeExtensions() { | ||
_decodeExtensions = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(gltf) { | ||
var options, | ||
context, | ||
extensionName, | ||
excludes, | ||
exclude, | ||
extension, | ||
_args = arguments; | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
options = _args.length > 1 && _args[1] !== undefined ? _args[1] : {}; | ||
context = _args.length > 2 ? _args[2] : undefined; | ||
options.gltf = options.gltf || {}; | ||
_context.t0 = _regeneratorRuntime.keys(EXTENSIONS); | ||
extensionName = _context.t1.value; | ||
excludes = options.gltf.excludeExtensions || {}; | ||
exclude = extensionName in excludes && !excludes[extensionName]; | ||
case 4: | ||
if ((_context.t1 = _context.t0()).done) { | ||
_context.next = 14; | ||
break; | ||
} | ||
if (exclude) { | ||
extensionName = _context.t1.value; | ||
excludes = options.gltf.excludeExtensions || {}; | ||
exclude = extensionName in excludes && !excludes[extensionName]; | ||
if (exclude) { | ||
_context.next = 12; | ||
break; | ||
} | ||
extension = EXTENSIONS[extensionName]; | ||
_context.next = 12; | ||
return extension.decode(gltf, options, context); | ||
case 12: | ||
_context.next = 4; | ||
break; | ||
} | ||
extension = EXTENSIONS[extensionName]; | ||
_context.next = 12; | ||
return _regeneratorRuntime.awrap(extension.decode(gltf, options, context)); | ||
case 12: | ||
_context.next = 4; | ||
break; | ||
case 14: | ||
case "end": | ||
return _context.stop(); | ||
case 14: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee); | ||
})); | ||
return _decodeExtensions.apply(this, arguments); | ||
} | ||
//# sourceMappingURL=gltf-extensions.js.map |
@@ -0,3 +1,4 @@ | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
@@ -10,89 +11,97 @@ var _marked = _regeneratorRuntime.mark(meshPrimitiveIterator); | ||
import { getGLTFAccessors, getGLTFAccessor } from '../gltf-utils/gltf-attribute-utils'; | ||
export function decode(gltfData, options, context) { | ||
var scenegraph, promises, _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, primitive; | ||
export function decode(_x, _x2, _x3) { | ||
return _decode.apply(this, arguments); | ||
} | ||
return _regeneratorRuntime.async(function decode$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
if (options.gltf.decompressMeshes) { | ||
_context.next = 2; | ||
break; | ||
} | ||
function _decode() { | ||
_decode = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(gltfData, options, context) { | ||
var scenegraph, promises, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, primitive; | ||
return _context.abrupt("return"); | ||
return _regeneratorRuntime.wrap(function _callee$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
if (options.gltf.decompressMeshes) { | ||
_context2.next = 2; | ||
break; | ||
} | ||
case 2: | ||
scenegraph = new GLTFScenegraph(gltfData); | ||
promises = []; | ||
_iteratorNormalCompletion = true; | ||
_didIteratorError = false; | ||
_iteratorError = undefined; | ||
_context.prev = 7; | ||
return _context2.abrupt("return"); | ||
for (_iterator = meshPrimitiveIterator(scenegraph)[Symbol.iterator](); !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
primitive = _step.value; | ||
case 2: | ||
scenegraph = new GLTFScenegraph(gltfData); | ||
promises = []; | ||
_iteratorNormalCompletion4 = true; | ||
_didIteratorError4 = false; | ||
_iteratorError4 = undefined; | ||
_context2.prev = 7; | ||
if (scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION)) { | ||
promises.push(decompressPrimitive(primitive, scenegraph, options, context)); | ||
for (_iterator4 = meshPrimitiveIterator(scenegraph)[Symbol.iterator](); !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) { | ||
primitive = _step4.value; | ||
if (scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION)) { | ||
promises.push(decompressPrimitive(primitive, scenegraph, options, context)); | ||
} | ||
} | ||
} | ||
_context.next = 15; | ||
break; | ||
_context2.next = 15; | ||
break; | ||
case 11: | ||
_context.prev = 11; | ||
_context.t0 = _context["catch"](7); | ||
_didIteratorError = true; | ||
_iteratorError = _context.t0; | ||
case 11: | ||
_context2.prev = 11; | ||
_context2.t0 = _context2["catch"](7); | ||
_didIteratorError4 = true; | ||
_iteratorError4 = _context2.t0; | ||
case 15: | ||
_context.prev = 15; | ||
_context.prev = 16; | ||
case 15: | ||
_context2.prev = 15; | ||
_context2.prev = 16; | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) { | ||
_iterator4["return"](); | ||
} | ||
case 18: | ||
_context.prev = 18; | ||
case 18: | ||
_context2.prev = 18; | ||
if (!_didIteratorError) { | ||
_context.next = 21; | ||
break; | ||
} | ||
if (!_didIteratorError4) { | ||
_context2.next = 21; | ||
break; | ||
} | ||
throw _iteratorError; | ||
throw _iteratorError4; | ||
case 21: | ||
return _context.finish(18); | ||
case 21: | ||
return _context2.finish(18); | ||
case 22: | ||
return _context.finish(15); | ||
case 22: | ||
return _context2.finish(15); | ||
case 23: | ||
_context.next = 25; | ||
return _regeneratorRuntime.awrap(Promise.all(promises)); | ||
case 23: | ||
_context2.next = 25; | ||
return Promise.all(promises); | ||
case 25: | ||
scenegraph.removeExtension(KHR_DRACO_MESH_COMPRESSION); | ||
case 25: | ||
scenegraph.removeExtension(KHR_DRACO_MESH_COMPRESSION); | ||
case 26: | ||
case "end": | ||
return _context.stop(); | ||
case 26: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}, null, null, [[7, 11, 15, 23], [16,, 18, 22]]); | ||
}, _callee, null, [[7, 11, 15, 23], [16,, 18, 22]]); | ||
})); | ||
return _decode.apply(this, arguments); | ||
} | ||
export function encode(gltfData) { | ||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; | ||
var scenegraph = new GLTFScenegraph(gltfData); | ||
var _iteratorNormalCompletion2 = true; | ||
var _didIteratorError2 = false; | ||
var _iteratorError2 = undefined; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator2 = (scenegraph.json.meshes || [])[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) { | ||
var mesh = _step2.value; | ||
for (var _iterator = (scenegraph.json.meshes || [])[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var mesh = _step.value; | ||
compressMesh(mesh, options); | ||
@@ -102,12 +111,12 @@ scenegraph.addRequiredExtension(KHR_DRACO_MESH_COMPRESSION); | ||
} catch (err) { | ||
_didIteratorError2 = true; | ||
_iteratorError2 = err; | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) { | ||
_iterator2["return"](); | ||
if (!_iteratorNormalCompletion && _iterator["return"] != null) { | ||
_iterator["return"](); | ||
} | ||
} finally { | ||
if (_didIteratorError2) { | ||
throw _iteratorError2; | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
@@ -118,31 +127,38 @@ } | ||
function decompressPrimitive(primitive, scenegraph, options, context) { | ||
var compressedPrimitive, buffer, bufferCopy, parse, decodedData; | ||
return _regeneratorRuntime.async(function decompressPrimitive$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
compressedPrimitive = scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION); | ||
buffer = scenegraph.getTypedArrayForBufferView(compressedPrimitive.bufferView); | ||
bufferCopy = getZeroOffsetArrayBuffer(buffer.buffer, buffer.byteOffset); | ||
parse = context.parse; | ||
_context2.next = 6; | ||
return _regeneratorRuntime.awrap(parse(bufferCopy, [], options, context)); | ||
function decompressPrimitive(_x4, _x5, _x6, _x7) { | ||
return _decompressPrimitive.apply(this, arguments); | ||
} | ||
case 6: | ||
decodedData = _context2.sent; | ||
primitive.attributes = getGLTFAccessors(decodedData.attributes); | ||
function _decompressPrimitive() { | ||
_decompressPrimitive = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(primitive, scenegraph, options, context) { | ||
var compressedPrimitive, buffer, bufferCopy, parse, decodedData; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
compressedPrimitive = scenegraph.getObjectExtension(primitive, KHR_DRACO_MESH_COMPRESSION); | ||
buffer = scenegraph.getTypedArrayForBufferView(compressedPrimitive.bufferView); | ||
bufferCopy = getZeroOffsetArrayBuffer(buffer.buffer, buffer.byteOffset); | ||
parse = context.parse; | ||
_context3.next = 6; | ||
return parse(bufferCopy, [], options, context); | ||
if (decodedData.indices) { | ||
primitive.indices = getGLTFAccessor(decodedData.indices); | ||
} | ||
case 6: | ||
decodedData = _context3.sent; | ||
primitive.attributes = getGLTFAccessors(decodedData.attributes); | ||
checkPrimitive(primitive); | ||
if (decodedData.indices) { | ||
primitive.indices = getGLTFAccessor(decodedData.indices); | ||
} | ||
case 10: | ||
case "end": | ||
return _context2.stop(); | ||
checkPrimitive(primitive); | ||
case 10: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee2); | ||
})); | ||
return _decompressPrimitive.apply(this, arguments); | ||
} | ||
@@ -190,118 +206,118 @@ | ||
function meshPrimitiveIterator(scenegraph) { | ||
var _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, mesh, _iteratorNormalCompletion4, _didIteratorError4, _iteratorError4, _iterator4, _step4, primitive; | ||
var _iteratorNormalCompletion2, _didIteratorError2, _iteratorError2, _iterator2, _step2, mesh, _iteratorNormalCompletion3, _didIteratorError3, _iteratorError3, _iterator3, _step3, primitive; | ||
return _regeneratorRuntime.wrap(function meshPrimitiveIterator$(_context3) { | ||
return _regeneratorRuntime.wrap(function meshPrimitiveIterator$(_context) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
_iteratorNormalCompletion3 = true; | ||
_didIteratorError3 = false; | ||
_iteratorError3 = undefined; | ||
_context3.prev = 3; | ||
_iterator3 = (scenegraph.json.meshes || [])[Symbol.iterator](); | ||
_iteratorNormalCompletion2 = true; | ||
_didIteratorError2 = false; | ||
_iteratorError2 = undefined; | ||
_context.prev = 3; | ||
_iterator2 = (scenegraph.json.meshes || [])[Symbol.iterator](); | ||
case 5: | ||
if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) { | ||
_context3.next = 36; | ||
if (_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done) { | ||
_context.next = 36; | ||
break; | ||
} | ||
mesh = _step3.value; | ||
_iteratorNormalCompletion4 = true; | ||
_didIteratorError4 = false; | ||
_iteratorError4 = undefined; | ||
_context3.prev = 10; | ||
_iterator4 = mesh.primitives[Symbol.iterator](); | ||
mesh = _step2.value; | ||
_iteratorNormalCompletion3 = true; | ||
_didIteratorError3 = false; | ||
_iteratorError3 = undefined; | ||
_context.prev = 10; | ||
_iterator3 = mesh.primitives[Symbol.iterator](); | ||
case 12: | ||
if (_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done) { | ||
_context3.next = 19; | ||
if (_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done) { | ||
_context.next = 19; | ||
break; | ||
} | ||
primitive = _step4.value; | ||
_context3.next = 16; | ||
primitive = _step3.value; | ||
_context.next = 16; | ||
return primitive; | ||
case 16: | ||
_iteratorNormalCompletion4 = true; | ||
_context3.next = 12; | ||
_iteratorNormalCompletion3 = true; | ||
_context.next = 12; | ||
break; | ||
case 19: | ||
_context3.next = 25; | ||
_context.next = 25; | ||
break; | ||
case 21: | ||
_context3.prev = 21; | ||
_context3.t0 = _context3["catch"](10); | ||
_didIteratorError4 = true; | ||
_iteratorError4 = _context3.t0; | ||
_context.prev = 21; | ||
_context.t0 = _context["catch"](10); | ||
_didIteratorError3 = true; | ||
_iteratorError3 = _context.t0; | ||
case 25: | ||
_context3.prev = 25; | ||
_context3.prev = 26; | ||
_context.prev = 25; | ||
_context.prev = 26; | ||
if (!_iteratorNormalCompletion4 && _iterator4["return"] != null) { | ||
_iterator4["return"](); | ||
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) { | ||
_iterator3["return"](); | ||
} | ||
case 28: | ||
_context3.prev = 28; | ||
_context.prev = 28; | ||
if (!_didIteratorError4) { | ||
_context3.next = 31; | ||
if (!_didIteratorError3) { | ||
_context.next = 31; | ||
break; | ||
} | ||
throw _iteratorError4; | ||
throw _iteratorError3; | ||
case 31: | ||
return _context3.finish(28); | ||
return _context.finish(28); | ||
case 32: | ||
return _context3.finish(25); | ||
return _context.finish(25); | ||
case 33: | ||
_iteratorNormalCompletion3 = true; | ||
_context3.next = 5; | ||
_iteratorNormalCompletion2 = true; | ||
_context.next = 5; | ||
break; | ||
case 36: | ||
_context3.next = 42; | ||
_context.next = 42; | ||
break; | ||
case 38: | ||
_context3.prev = 38; | ||
_context3.t1 = _context3["catch"](3); | ||
_didIteratorError3 = true; | ||
_iteratorError3 = _context3.t1; | ||
_context.prev = 38; | ||
_context.t1 = _context["catch"](3); | ||
_didIteratorError2 = true; | ||
_iteratorError2 = _context.t1; | ||
case 42: | ||
_context3.prev = 42; | ||
_context3.prev = 43; | ||
_context.prev = 42; | ||
_context.prev = 43; | ||
if (!_iteratorNormalCompletion3 && _iterator3["return"] != null) { | ||
_iterator3["return"](); | ||
if (!_iteratorNormalCompletion2 && _iterator2["return"] != null) { | ||
_iterator2["return"](); | ||
} | ||
case 45: | ||
_context3.prev = 45; | ||
_context.prev = 45; | ||
if (!_didIteratorError3) { | ||
_context3.next = 48; | ||
if (!_didIteratorError2) { | ||
_context.next = 48; | ||
break; | ||
} | ||
throw _iteratorError3; | ||
throw _iteratorError2; | ||
case 48: | ||
return _context3.finish(45); | ||
return _context.finish(45); | ||
case 49: | ||
return _context3.finish(42); | ||
return _context.finish(42); | ||
case 50: | ||
case "end": | ||
return _context3.stop(); | ||
return _context.stop(); | ||
} | ||
@@ -308,0 +324,0 @@ } |
@@ -49,3 +49,3 @@ import assert from '../utils/assert'; | ||
if (json.lights) { | ||
var extension = gltfScenegraph.addExtensions(KHR_LIGHTS_PUNCTUAL); | ||
var extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL); | ||
assert(!extension.lights); | ||
@@ -52,0 +52,0 @@ extension.lights = json.lights; |
@@ -53,3 +53,3 @@ import GLTFScenegraph from '../gltf-scenegraph'; | ||
gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT); | ||
gltfScenegraph.addExtensions(KHR_MATERIALS_UNLIT); | ||
gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT); | ||
} | ||
@@ -56,0 +56,0 @@ } |
import _regeneratorRuntime from "@babel/runtime/regenerator"; | ||
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator"; | ||
import { ImageLoader } from '@loaders.gl/images'; | ||
@@ -16,49 +17,56 @@ import { parseJSON, getZeroOffsetArrayBuffer } from '@loaders.gl/loader-utils'; | ||
} | ||
export function parseGLTF(gltf, arrayBufferOrString) { | ||
var byteOffset, | ||
options, | ||
context, | ||
promises, | ||
_promise, | ||
promise, | ||
_args = arguments; | ||
export function parseGLTF(_x, _x2) { | ||
return _parseGLTF.apply(this, arguments); | ||
} | ||
return _regeneratorRuntime.async(function parseGLTF$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
byteOffset = _args.length > 2 && _args[2] !== undefined ? _args[2] : 0; | ||
options = _args.length > 3 ? _args[3] : undefined; | ||
context = _args.length > 4 ? _args[4] : undefined; | ||
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options); | ||
promises = []; | ||
function _parseGLTF() { | ||
_parseGLTF = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(gltf, arrayBufferOrString) { | ||
var byteOffset, | ||
options, | ||
context, | ||
promises, | ||
_promise, | ||
promise, | ||
_args = arguments; | ||
if (options.gltf.loadImages) { | ||
_promise = loadImages(gltf, options, context); | ||
promises.push(_promise); | ||
} | ||
return _regeneratorRuntime.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
byteOffset = _args.length > 2 && _args[2] !== undefined ? _args[2] : 0; | ||
options = _args.length > 3 ? _args[3] : undefined; | ||
context = _args.length > 4 ? _args[4] : undefined; | ||
parseGLTFContainerSync(gltf, arrayBufferOrString, byteOffset, options); | ||
promises = []; | ||
if (!options.gltf.loadBuffers) { | ||
if (options.gltf.loadImages) { | ||
_promise = loadImages(gltf, options, context); | ||
promises.push(_promise); | ||
} | ||
if (!options.gltf.loadBuffers) { | ||
_context.next = 9; | ||
break; | ||
} | ||
_context.next = 9; | ||
break; | ||
} | ||
return loadBuffers(gltf, options, context); | ||
_context.next = 9; | ||
return _regeneratorRuntime.awrap(loadBuffers(gltf, options, context)); | ||
case 9: | ||
promise = decodeExtensions(gltf, options, context); | ||
promises.push(promise); | ||
_context.next = 13; | ||
return Promise.all(promises); | ||
case 9: | ||
promise = decodeExtensions(gltf, options, context); | ||
promises.push(promise); | ||
_context.next = 13; | ||
return _regeneratorRuntime.awrap(Promise.all(promises)); | ||
case 13: | ||
return _context.abrupt("return", options.gltf.postProcess ? postProcessGLTF(gltf, options) : gltf); | ||
case 13: | ||
return _context.abrupt("return", options.gltf.postProcess ? postProcessGLTF(gltf, options) : gltf); | ||
case 14: | ||
case "end": | ||
return _context.stop(); | ||
case 14: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee); | ||
})); | ||
return _parseGLTF.apply(this, arguments); | ||
} | ||
@@ -104,129 +112,150 @@ | ||
function loadBuffers(gltf, options, context) { | ||
var i, buffer, fetch, uri, response, arrayBuffer; | ||
return _regeneratorRuntime.async(function loadBuffers$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
i = 0; | ||
function loadBuffers(_x3, _x4, _x5) { | ||
return _loadBuffers.apply(this, arguments); | ||
} | ||
case 1: | ||
if (!(i < gltf.json.buffers.length)) { | ||
_context2.next = 18; | ||
break; | ||
} | ||
function _loadBuffers() { | ||
_loadBuffers = _asyncToGenerator(_regeneratorRuntime.mark(function _callee2(gltf, options, context) { | ||
var i, buffer, fetch, uri, response, arrayBuffer; | ||
return _regeneratorRuntime.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
i = 0; | ||
buffer = gltf.json.buffers[i]; | ||
case 1: | ||
if (!(i < gltf.json.buffers.length)) { | ||
_context2.next = 18; | ||
break; | ||
} | ||
if (!buffer.uri) { | ||
_context2.next = 15; | ||
break; | ||
} | ||
buffer = gltf.json.buffers[i]; | ||
fetch = context.fetch; | ||
assert(fetch); | ||
uri = resolveUrl(buffer.uri, options); | ||
_context2.next = 9; | ||
return _regeneratorRuntime.awrap(fetch(uri)); | ||
if (!buffer.uri) { | ||
_context2.next = 15; | ||
break; | ||
} | ||
case 9: | ||
response = _context2.sent; | ||
_context2.next = 12; | ||
return _regeneratorRuntime.awrap(response.arrayBuffer()); | ||
fetch = context.fetch; | ||
assert(fetch); | ||
uri = resolveUrl(buffer.uri, options); | ||
_context2.next = 9; | ||
return fetch(uri); | ||
case 12: | ||
arrayBuffer = _context2.sent; | ||
gltf.buffers[i] = { | ||
arrayBuffer: arrayBuffer, | ||
byteOffset: 0, | ||
byteLength: arrayBuffer.byteLength | ||
}; | ||
delete buffer.uri; | ||
case 9: | ||
response = _context2.sent; | ||
_context2.next = 12; | ||
return response.arrayBuffer(); | ||
case 15: | ||
++i; | ||
_context2.next = 1; | ||
break; | ||
case 12: | ||
arrayBuffer = _context2.sent; | ||
gltf.buffers[i] = { | ||
arrayBuffer: arrayBuffer, | ||
byteOffset: 0, | ||
byteLength: arrayBuffer.byteLength | ||
}; | ||
delete buffer.uri; | ||
case 18: | ||
case "end": | ||
return _context2.stop(); | ||
case 15: | ||
++i; | ||
_context2.next = 1; | ||
break; | ||
case 18: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee2); | ||
})); | ||
return _loadBuffers.apply(this, arguments); | ||
} | ||
function loadImages(gltf, options, context) { | ||
var images, promises, i; | ||
return _regeneratorRuntime.async(function loadImages$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
images = gltf.json.images || []; | ||
promises = []; | ||
function loadImages(_x6, _x7, _x8) { | ||
return _loadImages.apply(this, arguments); | ||
} | ||
for (i = 0; i < images.length; ++i) { | ||
promises.push(loadImage(gltf, images[i], i, options, context)); | ||
} | ||
function _loadImages() { | ||
_loadImages = _asyncToGenerator(_regeneratorRuntime.mark(function _callee3(gltf, options, context) { | ||
var images, promises, i; | ||
return _regeneratorRuntime.wrap(function _callee3$(_context3) { | ||
while (1) { | ||
switch (_context3.prev = _context3.next) { | ||
case 0: | ||
images = gltf.json.images || []; | ||
promises = []; | ||
_context3.next = 5; | ||
return _regeneratorRuntime.awrap(Promise.all(promises)); | ||
for (i = 0; i < images.length; ++i) { | ||
promises.push(loadImage(gltf, images[i], i, options, context)); | ||
} | ||
case 5: | ||
return _context3.abrupt("return", _context3.sent); | ||
_context3.next = 5; | ||
return Promise.all(promises); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
case 5: | ||
return _context3.abrupt("return", _context3.sent); | ||
case 6: | ||
case "end": | ||
return _context3.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee3); | ||
})); | ||
return _loadImages.apply(this, arguments); | ||
} | ||
function loadImage(gltf, image, i, options, context) { | ||
var fetch, parse, arrayBuffer, uri, response, array, parsedImage; | ||
return _regeneratorRuntime.async(function loadImage$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
fetch = context.fetch, parse = context.parse; | ||
function loadImage(_x9, _x10, _x11, _x12, _x13) { | ||
return _loadImage.apply(this, arguments); | ||
} | ||
if (!image.uri) { | ||
_context4.next = 9; | ||
break; | ||
} | ||
function _loadImage() { | ||
_loadImage = _asyncToGenerator(_regeneratorRuntime.mark(function _callee4(gltf, image, i, options, context) { | ||
var fetch, parse, arrayBuffer, uri, response, array, parsedImage; | ||
return _regeneratorRuntime.wrap(function _callee4$(_context4) { | ||
while (1) { | ||
switch (_context4.prev = _context4.next) { | ||
case 0: | ||
fetch = context.fetch, parse = context.parse; | ||
uri = resolveUrl(image.uri, options); | ||
_context4.next = 5; | ||
return _regeneratorRuntime.awrap(fetch(uri)); | ||
if (!image.uri) { | ||
_context4.next = 9; | ||
break; | ||
} | ||
case 5: | ||
response = _context4.sent; | ||
_context4.next = 8; | ||
return _regeneratorRuntime.awrap(response.arrayBuffer()); | ||
uri = resolveUrl(image.uri, options); | ||
_context4.next = 5; | ||
return fetch(uri); | ||
case 8: | ||
arrayBuffer = _context4.sent; | ||
case 5: | ||
response = _context4.sent; | ||
_context4.next = 8; | ||
return response.arrayBuffer(); | ||
case 9: | ||
if (Number.isFinite(image.bufferView)) { | ||
array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView); | ||
arrayBuffer = getZeroOffsetArrayBuffer(array.buffer, array.byteOffset, array.byteLength); | ||
} | ||
case 8: | ||
arrayBuffer = _context4.sent; | ||
assert(arrayBuffer, 'glTF image has no data'); | ||
_context4.next = 13; | ||
return _regeneratorRuntime.awrap(parse(arrayBuffer, ImageLoader, {}, context)); | ||
case 9: | ||
if (Number.isFinite(image.bufferView)) { | ||
array = getTypedArrayForBufferView(gltf.json, gltf.buffers, image.bufferView); | ||
arrayBuffer = getZeroOffsetArrayBuffer(array.buffer, array.byteOffset, array.byteLength); | ||
} | ||
case 13: | ||
parsedImage = _context4.sent; | ||
gltf.images[i] = parsedImage; | ||
assert(arrayBuffer, 'glTF image has no data'); | ||
_context4.next = 13; | ||
return parse(arrayBuffer, ImageLoader, {}, context); | ||
case 15: | ||
case "end": | ||
return _context4.stop(); | ||
case 13: | ||
parsedImage = _context4.sent; | ||
gltf.images[i] = parsedImage; | ||
case 15: | ||
case "end": | ||
return _context4.stop(); | ||
} | ||
} | ||
} | ||
}); | ||
}, _callee4); | ||
})); | ||
return _loadImage.apply(this, arguments); | ||
} | ||
//# sourceMappingURL=parse-gltf.js.map |
{ | ||
"name": "@loaders.gl/gltf", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Framework-independent loader for the glTF format", | ||
@@ -41,7 +41,7 @@ "license": "MIT", | ||
"dependencies": { | ||
"@loaders.gl/core": "2.0.0", | ||
"@loaders.gl/images": "2.0.0", | ||
"@loaders.gl/loader-utils": "2.0.0" | ||
"@loaders.gl/core": "2.0.1", | ||
"@loaders.gl/images": "2.0.1", | ||
"@loaders.gl/loader-utils": "2.0.1" | ||
}, | ||
"gitHead": "addaa8e2e634bd0c9e96da200d0388f62a669666" | ||
"gitHead": "ae0763bd05bbe9b14aedf2a99e5873db16739bb7" | ||
} |
@@ -174,3 +174,3 @@ import {getBinaryImageMIMEType, getBinaryImageSize} from '@loaders.gl/images'; | ||
attributes.mode = 0; | ||
const compressedData = this.DracoWriter.encodeSync(attributes, {pointcloud: true}); | ||
const compressedData = this.DracoWriter.encodeSync(attributes, {draco: {pointcloud: true}}); | ||
@@ -177,0 +177,0 @@ const bufferViewIndex = this.addBufferView(compressedData); |
@@ -1,18 +0,1 @@ | ||
/* | ||
import {assert} from '@loaders.gl/core'; | ||
import {getImageSize} from '@loaders.gl/images'; | ||
import {isImage} from '@loaders.gl/images'; | ||
import {getAccessorTypeFromSize, getComponentTypeFromArray} from './gltf-utils/gltf-utils'; | ||
import {KHR_DRACO_MESH_COMPRESSION, UBER_POINT_CLOUD_EXTENSION} from './gltf-constants'; | ||
const DEFAULT_GTLF = { | ||
buffers: [], | ||
bufferViews: [], | ||
accessors: [], | ||
images: [], | ||
meshes: [] | ||
}; | ||
*/ | ||
import encodeGLBSync from './encode-glb'; | ||
@@ -19,0 +2,0 @@ |
@@ -36,3 +36,3 @@ // GLTF EXTENSION: KHR_lights_punctual | ||
if (json.lights) { | ||
const extension = gltfScenegraph.addExtensions(KHR_LIGHTS_PUNCTUAL); | ||
const extension = gltfScenegraph.addExtension(KHR_LIGHTS_PUNCTUAL); | ||
assert(!extension.lights); | ||
@@ -39,0 +39,0 @@ extension.lights = json.lights; |
@@ -36,3 +36,3 @@ // GLTF EXTENSION: KHR_materials_unlit | ||
gltfScenegraph.addObjectExtension(material, KHR_MATERIALS_UNLIT); | ||
gltfScenegraph.addExtensions(KHR_MATERIALS_UNLIT); | ||
gltfScenegraph.addExtension(KHR_MATERIALS_UNLIT); | ||
} | ||
@@ -39,0 +39,0 @@ } |
@@ -11,3 +11,3 @@ /* TODO: Not yet implemented | ||
attributes.mode = 0; | ||
const compressedData = options.DracoWriter.encodeSync(attributes, {pointcloud: true}); | ||
const compressedData = options.DracoWriter.encodeSync(attributes, {draco: {pointcloud: true}}); | ||
@@ -14,0 +14,0 @@ const bufferViewIndex = this.addBufferView(compressedData); |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
967370
12395
+ Added@loaders.gl/core@2.0.1(transitive)
+ Added@loaders.gl/images@2.0.1(transitive)
+ Added@loaders.gl/loader-utils@2.0.1(transitive)
- Removed@loaders.gl/core@2.0.0(transitive)
- Removed@loaders.gl/images@2.0.0(transitive)
- Removed@loaders.gl/loader-utils@2.0.0(transitive)
Updated@loaders.gl/core@2.0.1
Updated@loaders.gl/images@2.0.1