12 |
- (window["webpackJsonp"]=window["webpackJsonp"]||[]).push([["chunk-2d23775c"],{fae0:function(e,t,s){"use strict";s.r(t),s.d(t,"toBinaryGLTF",(function(){return X}));var i,r=s("e041"),n=s("f4cc"),a=s("4ae5");!function(e){e[e.JSON=1313821514]="JSON",e[e.BIN=5130562]="BIN"}(i||(i={}));class o{constructor(e,t){if(!e)throw new Error("GLB requires a JSON gltf chunk");this.length=o.HEADER_SIZE,this.length+=o.CHUNK_HEADER_SIZE;const s=this._textToArrayBuffer(e);if(this.length+=this._alignTo(s.byteLength,4),t&&(this.length+=o.CHUNK_HEADER_SIZE,this.length+=t.byteLength,t.byteLength%4))throw new Error("Expected BIN chunk length to be divisible by 4 at this point");this.buffer=new ArrayBuffer(this.length),this.outView=new DataView(this.buffer),this._writeHeader();const r=this._writeChunk(s,12,i.JSON,32);t&&this._writeChunk(t,r,i.BIN)}_writeHeader(){this.outView.setUint32(0,o.MAGIC,!0),this.outView.setUint32(4,o.VERSION,!0),this.outView.setUint32(8,this.length,!0)}_writeChunk(e,t,s,i=0){const r=this._alignTo(e.byteLength,4);for(this.outView.setUint32(t,r,!0),this.outView.setUint32(t+=4,s,!0),this._writeArrayBuffer(this.outView.buffer,e,t+=4,0,e.byteLength),t+=e.byteLength;t%4;)i&&this.outView.setUint8(t,i),t++;return t}_writeArrayBuffer(e,t,s,i,r){new Uint8Array(e,s,r).set(new Uint8Array(t,i,r),0)}_textToArrayBuffer(e){return(new TextEncoder).encode(e).buffer}_alignTo(e,t){return t*Math.ceil(e/t)}}o.HEADER_SIZE=12,o.CHUNK_HEADER_SIZE=8,o.MAGIC=1179937895,o.VERSION=2;var c,h,f,u,l,d,p,g=s("28eb"),m=s("b2b2"),b=s("04f0"),w=s("b139"),E=s("e431"),A=s("0b2d"),T=s("83fa"),y=s("e9ba");!function(e){e[e.External=0]="External",e[e.DataURI=1]="DataURI",e[e.GLB=2]="GLB"}(c||(c={})),function(e){e[e.External=0]="External",e[e.DataURI=1]="DataURI",e[e.GLB=2]="GLB"}(h||(h={})),function(e){e[e.ARRAY_BUFFER=34962]="ARRAY_BUFFER",e[e.ELEMENT_ARRAY_BUFFER=34963]="ELEMENT_ARRAY_BUFFER"}(f||(f={})),function(e){e.SCALAR="SCALAR",e.VEC2="VEC2",e.VEC3="VEC3",e.VEC4="VEC4",e.MAT2="MAT2",e.MAT3="MAT3",e.MAT4="MAT4"}(u||(u={})),function(e){e[e.POINTS=0]="POINTS",e[e.LINES=1]="LINES",e[e.LINE_LOOP=2]="LINE_LOOP",e[e.LINE_STRIP=3]="LINE_STRIP",e[e.TRIANGLES=4]="TRIANGLES",e[e.TRIANGLE_STRIP=5]="TRIANGLE_STRIP",e[e.TRIANGLE_FAN=6]="TRIANGLE_FAN"}(l||(l={})),function(e){e.OPAQUE="OPAQUE",e.MASK="MASK",e.BLEND="BLEND"}(d||(d={})),function(e){e[e.NoColor=0]="NoColor",e[e.FaceColor=1]="FaceColor",e[e.VertexColor=2]="VertexColor"}(p||(p={}));var _=s("d17d");class O{constructor(e,t,s,i,r){this.buffer=e,this.componentType=s,this.dataType=i,this.data=[],this.isFinalized=!1,this.accessorIndex=-1,this.accessorAttribute=null,this.accessorMin=null,this.accessorMax=null,t.bufferViews||(t.bufferViews=[]),this.index=t.bufferViews.length,this.bufferView={buffer:e.index,byteLength:-1,target:r};const n=this._getElementSize();n>=4&&r!==f.ELEMENT_ARRAY_BUFFER&&(this.bufferView.byteStride=n),t.bufferViews.push(this.bufferView),this.numComponentsForDataType=this._calculateNumComponentsForDataType()}push(e){const t=this.data.length;if(this.data.push(e),this.accessorIndex>=0){const s=t%this.numComponentsForDataType,i=this.accessorMin[s];this.accessorMin[s]="number"!=typeof i?e:Math.min(i,e);const r=this.accessorMax[s];this.accessorMax[s]="number"!=typeof r?e:Math.max(r,e)}}get dataSize(){return this.data.length*this._sizeComponentType()}get byteSize(){function e(e,t){return t*Math.ceil(e/t)}return e(this.dataSize,4)}getByteOffset(){if(!this.isFinalized)throw new Error("Cannot get BufferView offset until it is finalized");return this.buffer.getByteOffset(this)}get byteOffset(){if(!this.isFinalized)throw new Error("Cannot get BufferView offset until it is finalized");return this.buffer.getByteOffset(this)}_createTypedArray(e,t){switch(this.componentType){case _["k"].BYTE:return new Int8Array(e,t);case _["k"].FLOAT:return new Float32Array(e,t);case _["k"].SHORT:return new Int16Array(e,t);case _["k"].UNSIGNED_BYTE:return new Uint8Array(e,t);case _["k"].UNSIGNED_INT:return new Uint32Array(e,t);case _["k"].UNSIGNED_SHORT:return new Uint16Array(e,t)}}writeOutToBuffer(e,t){this._createTypedArray(e,t).set(this.data)}writeAsync(e){if(this.asyncWritePromise)throw new Error("Can't write multiple bufferView values asynchronously");return this.asyncWritePromise=e.then(e=>{const t=new Uint8Array(e);for(let s=0;s<t.length;++s)this.data.push(t[s]);delete this.asyncWritePromise}),this.asyncWritePromise}startAccessor(e){if(this.accessorIndex>=0)throw new Error("Accessor was started without ending the previous one");this.accessorIndex=this.data.length,this.accessorAttribute=e;const t=this.numComponentsForDataType;this.accessorMin=new Array(t),this.accessorMax=new Array(t)}endAccessor(){if(this.accessorIndex<0)throw new Error("An accessor was not started, but was attempted to be ended");const e=this._getElementSize(),t=this.numComponentsForDataType,s=(this.data.length-this.accessorIndex)/t;if(s%1)throw new Error("An accessor was ended with missing component values");for(let r=0;r<this.accessorMin.length;++r)"number"!=typeof this.accessorMin[r]&&(this.accessorMin[r]=0),"number"!=typeof this.accessorMax[r]&&(this.accessorMax[r]=0);const i={byteOffset:e*(this.accessorIndex/t),componentType:this.componentType,count:s,type:this.dataType,min:this.accessorMin,max:this.accessorMax,name:this.accessorAttribute};switch(this.accessorAttribute){case"TEXCOORD_0":case"TEXCOORD_1":case"COLOR_0":case"WEIGHTS_0":switch(this.componentType){case _["k"].UNSIGNED_BYTE:case _["k"].UNSIGNED_SHORT:i.normalized=!0}}return this.accessorIndex=-1,this.accessorAttribute=null,this.accessorMin=null,this.accessorMax=null,i}get finalized(){return this.finalizedPromise?this.finalizedPromise:this.isFinalized?this.finalizedPromise=Promise.resolve():this.finalizedPromise=new Promise(e=>this.finalizedPromiseResolve=e)}finalize(){const e=this.bufferView;return new Promise(e=>{const t=this.buffer.getViewFinalizePromises(this);this.asyncWritePromise&&t.push(this.asyncWritePromise),e(Object(n["j"])(t))}).then(()=>{this.isFinalized=!0,e.byteOffset=this.getByteOffset(),e.byteLength=this.dataSize,this.finalizedPromiseResolve&&this.finalizedPromiseResolve()})}_getElementSize(){return this._sizeComponentType()*this.numComponentsForDataType}_sizeComponentType(){switch(this.componentType){case _["k"].BYTE:case _["k"].UNSIGNED_BYTE:return 1;case _["k"].SHORT:case _["k"].UNSIGNED_SHORT:return 2;case _["k"].UNSIGNED_INT:case _["k"].FLOAT:return 4}}_calculateNumComponentsForDataType(){switch(this.dataType){case u.SCALAR:return 1;case u.VEC2:return 2;case u.VEC3:return 3;case u.VEC4:case u.MAT2:return 4;case u.MAT3:return 9;case u.MAT4:return 16}}}class x{constructor(e){this.gltf=e,this.bufferViews=[],this.isFinalized=!1,e.buffers||(e.buffers=[]),this.index=e.buffers.length;const t={byteLength:-1};e.buffers.push(t),this.buffer=t}addBufferView(e,t,s){if(this.finalizePromise)throw new Error("Cannot add buffer view after fiinalizing buffer");const i=new O(this,this.gltf,e,t,s);return this.bufferViews.push(i),i}getByteOffset(e){let t=0;for(const s of this.bufferViews){if(s===e)return t;t+=s.byteSize}throw new Error("Given bufferView was not present in this buffer")}getViewFinalizePromises(e){const t=[];for(const s of this.bufferViews){if(e&&s===e)return t;t.push(s.finalized)}return t}getArrayBuffer(){if(!this.isFinalized)throw new Error("Cannot get ArrayBuffer from Buffer before it is finalized");const e=this._getTotalSize(),t=new ArrayBuffer(e);let s=0;for(const i of this.bufferViews)i.writeOutToBuffer(t,s),s+=i.byteSize;return t}finalize(){if(this.finalizePromise)throw new Error(`Buffer ${this.index} was already finalized`);return this.finalizePromise=new Promise(e=>{e(Object(n["j"])(this.getViewFinalizePromises()))}).then(()=>{this.isFinalized=!0;const e=this.getArrayBuffer();this.buffer.byteLength=e.byteLength,this.buffer.uri=e}),this.gltf.extras.promises.push(this.finalizePromise),this.finalizePromise}_getTotalSize(){let e=0;for(const t of this.bufferViews)e+=t.byteSize;return e}}s("e06a");function R(e,t){if(e.components)for(const s of e.components)s.faces&&"smooth"===s.shading&&B(s,t)}function B(e,t){Object(m["j"])(t.normal)&&(t.normal=new Float32Array(t.position.length));const s=e.faces,{position:i,normal:r}=t,n=s.length/3;for(let a=0;a<n;++a){const e=3*s[3*a+0],t=3*s[3*a+1],n=3*s[3*a+2],o=Object(E["y"])(S,i[e+0],i[e+1],i[e+2]),c=Object(E["y"])(I,i[t+0],i[t+1],i[t+2]),h=Object(E["y"])(M,i[n+0],i[n+1],i[n+2]),f=Object(E["l"])(c,c,o),u=Object(E["l"])(h,h,o),l=Object(E["i"])(f,f,u);r[e+0]+=l[0],r[e+1]+=l[1],r[e+2]+=l[2],r[t+0]+=l[0],r[t+1]+=l[1],r[t+2]+=l[2],r[n+0]+=l[0],r[n+1]+=l[1],r[n+2]+=l[2]}for(let a=0;a<r.length;a+=3)Object(E["y"])(C,r[a],r[a+1],r[a+2]),Object(E["t"])(C,C),r[a+0]=C[0],r[a+1]=C[1],r[a+2]=C[2]}function N(e){if(Object(m["k"])(e.transform))return e.transform.getOriginPoint(e.spatialReference);const t=e.extent.xmax-e.extent.width/2,s=e.extent.ymax-e.extent.height/2,i=e.extent.zmin;return new a["a"]({x:t,y:s,z:i,spatialReference:e.extent.spatialReference})}const S=Object(A["f"])(),I=Object(A["f"])(),M=Object(A["f"])(),C=Object(A["f"])();s("c120");var L=s("ce50");function z(e){const t=F(e);return Object(m["k"])(t)?t.toDataURL():""}async function j(e){const t=F(e);if(Object(m["j"])(t))throw new L["a"]("imageToArrayBuffer","Unsupported image type");const s=await V(e),i=await new Promise(e=>t.toBlob(e,s));if(!i)throw new L["a"]("imageToArrayBuffer","Failed to encode image");return{data:await i.arrayBuffer(),type:s}}async function V(e){if(!(e instanceof HTMLImageElement))return"image/png";const t=e.src;if(Object(r["w"])(t)){const{mediaType:e}=Object(r["h"])(t);return"image/jpeg"===e?e:"image/png"}return/\.png$/i.test(t)?"image/png":/\.(jpg|jpeg)$/i.test(t)?"image/jpeg":"image/png"}function F(e){if(e instanceof HTMLCanvasElement)return e;if(e instanceof HTMLVideoElement)return null;const t=document.createElement("canvas");t.width=e.width,t.height=e.height;const s=t.getContext("2d");return e instanceof HTMLImageElement?s.drawImage(e,0,0,e.width,e.height):e instanceof ImageData&&s.putImageData(e,e.width,e.height),t}function k(e){const t=[],s=new Uint8Array(e);for(let i=0;i<s.length;i++)t.push(String.fromCharCode(s[i]));return"data:application/octet-stream;base64,"+btoa(t.join(""))}function D(e){if(e.byteLength<8)return!1;const t=new Uint8Array(e);return 137===t[0]&&80===t[1]&&78===t[2]&&71===t[3]&&13===t[4]&&10===t[5]&&26===t[6]&&10===t[7]}class P{constructor(e,t,s){this.params={},this.materialMap=new Array,this.imageMap=new Map,this.textureMap=new Map,this.gltf={asset:{version:"2.0",copyright:e.copyright,generator:e.generator},extras:{options:t,binChunkBuffer:null,promises:[]}},s&&(this.params=s),this._addScenes(e)}_addScenes(e){this.gltf.scene=e.defaultScene;const t=this.gltf.extras.options.bufferOutputType===c.GLB||this.gltf.extras.options.imageOutputType===h.GLB;t&&(this.gltf.extras.binChunkBuffer=new x(this.gltf)),e.forEachScene(e=>{this._addScene(e)}),t&&this.gltf.extras.binChunkBuffer.finalize()}_addScene(e){this.gltf.scenes||(this.gltf.scenes=[]);const t={};e.name&&(t.name=e.name),e.forEachNode(e=>{t.nodes||(t.nodes=[]);const s=this._addNode(e);t.nodes.push(s)}),this.gltf.scenes.push(t)}_addNode(e){this.gltf.nodes||(this.gltf.nodes=[]);const t={};e.name&&(t.name=e.name);const s=e.translation;Object(E["q"])(s,A["c"])||(t.translation=Object(A["d"])(s));const i=e.rotation;Object(b["d"])(i,w["a"])||(t.rotation=Object(w["c"])(i));const r=e.scale;Object(E["q"])(r,A["a"])||(t.scale=Object(A["d"])(r)),e.mesh&&e.mesh.vertexAttributes.position?t.mesh=this._addMesh(e.mesh):e.forEachNode(e=>{t.children||(t.children=[]);const s=this._addNode(e);t.children.push(s)});const n=this.gltf.nodes.length;return this.gltf.nodes.push(t),n}_addMesh(e){this.gltf.meshes||(this.gltf.meshes=[]);const t={primitives:[]},s=this.gltf.extras.options.bufferOutputType===c.GLB;let i;i=s?this.gltf.extras.binChunkBuffer:new x(this.gltf),this.params.origin||(this.params.origin=N(e));const r=Object(y["e"])(e.vertexAttributes,e.transform,this.params.origin,{geographic:this.params.geographic,unit:"meters"});R(e,r),this._flipYZAxis(r);const n=i.addBufferView(_["k"].FLOAT,u.VEC3,f.ARRAY_BUFFER);let a,o,h,l;r.normal&&(a=i.addBufferView(_["k"].FLOAT,u.VEC3,f.ARRAY_BUFFER)),e.vertexAttributes.uv&&(o=i.addBufferView(_["k"].FLOAT,u.VEC2,f.ARRAY_BUFFER)),r.tangent&&(h=i.addBufferView(_["k"].FLOAT,u.VEC4,f.ARRAY_BUFFER)),e.vertexAttributes.color&&(l=i.addBufferView(_["k"].UNSIGNED_BYTE,u.VEC4,f.ARRAY_BUFFER)),n.startAccessor("POSITION"),a&&a.startAccessor("NORMAL"),o&&o.startAccessor("TEXCOORD_0"),h&&h.startAccessor("TANGENT"),l&&l.startAccessor("COLOR_0");const d=r.position.length/3,{position:p,normal:g,tangent:b}=r,{color:w,uv:E}=e.vertexAttributes;for(let c=0;c<d;++c)n.push(p[3*c+0]),n.push(p[3*c+1]),n.push(p[3*c+2]),a&&Object(m["k"])(g)&&(a.push(g[3*c+0]),a.push(g[3*c+1]),a.push(g[3*c+2])),o&&Object(m["k"])(E)&&(o.push(E[2*c+0]),o.push(E[2*c+1])),h&&Object(m["k"])(b)&&(h.push(b[4*c+0]),h.push(b[4*c+1]),h.push(b[4*c+2]),h.push(b[4*c+3])),l&&Object(m["k"])(w)&&(l.push(w[4*c+0]),l.push(w[4*c+1]),l.push(w[4*c+2]),l.push(w[4*c+3]));const A=n.endAccessor(),T=this._addAccessor(n.index,A);let O,B,S,I,M;if(a){const e=a.endAccessor();O=this._addAccessor(a.index,e)}if(o){const e=o.endAccessor();B=this._addAccessor(o.index,e)}if(h){const e=h.endAccessor();S=this._addAccessor(h.index,e)}if(l){const e=l.endAccessor();I=this._addAccessor(l.index,e)}e.components&&e.components.length>0&&e.components[0].faces?(M=i.addBufferView(_["k"].UNSIGNED_INT,u.SCALAR,f.ELEMENT_ARRAY_BUFFER),this._addMeshVertexIndexed(M,e.components,t,T,O,B,S,I)):this._addMeshVertexNonIndexed(e.components,t,T,O,B,S,I),n.finalize(),a&&a.finalize(),o&&o.finalize(),h&&h.finalize(),M&&M.finalize(),l&&l.finalize(),s||i.finalize();const C=this.gltf.meshes.length;return this.gltf.meshes.push(t),C}_flipYZAxis({position:e,normal:t,tangent:s}){this._flipYZBuffer(e,3),this._flipYZBuffer(t,3),this._flipYZBuffer(s,4)}_flipYZBuffer(e,t){if(!Object(m["j"])(e))for(let s=1,i=2;s<e.length;s+=t,i+=t){const t=e[s],r=e[i];e[s]=r,e[i]=-t}}_addMaterial(e){if(null===e)return;const t=this.materialMap.indexOf(e);if(-1!==t)return t;this.gltf.materials||(this.gltf.materials=[]);const s={};switch(e.alphaMode){case"mask":s.alphaMode=d.MASK;break;case"auto":case"blend":s.alphaMode=d.BLEND}.5!==e.alphaCutoff&&(s.alphaCutoff=e.alphaCutoff),e.doubleSided&&(s.doubleSided=e.doubleSided),s.pbrMetallicRoughness={};const i=e=>e**2.1,r=e=>{const t=e.toRgba();return t[0]=i(t[0]/255),t[1]=i(t[1]/255),t[2]=i(t[2]/255),t};if(Object(m["k"])(e.color)&&(s.pbrMetallicRoughness.baseColorFactor=r(e.color)),Object(m["k"])(e.colorTexture)&&(s.pbrMetallicRoughness.baseColorTexture={index:this._addTexture(e.colorTexture)}),Object(m["k"])(e.normalTexture)&&(s.normalTexture={index:this._addTexture(e.normalTexture)}),e instanceof T["a"]){if(Object(m["k"])(e.emissiveTexture)&&(s.emissiveTexture={index:this._addTexture(e.emissiveTexture)}),Object(m["k"])(e.emissiveColor)){const t=r(e.emissiveColor);s.emissiveFactor=[t[0],t[1],t[2]]}Object(m["k"])(e.occlusionTexture)&&(s.occlusionTexture={index:this._addTexture(e.occlusionTexture)}),Object(m["k"])(e.metallicRoughnessTexture)&&(s.pbrMetallicRoughness.metallicRoughnessTexture={index:this._addTexture(e.metallicRoughnessTexture)}),s.pbrMetallicRoughness.metallicFactor=e.metallic,s.pbrMetallicRoughness.roughnessFactor=e.roughness}else s.pbrMetallicRoughness.metallicFactor=1,s.pbrMetallicRoughness.roughnessFactor=1;const n=this.gltf.materials.length;return this.gltf.materials.push(s),this.materialMap.push(e),n}_addTexture(e){return this.gltf.textures||(this.gltf.textures=[]),Object(g["b"])(this.textureMap,e,()=>{const t={sampler:this._addSampler(e),source:this._addImage(e)},s=this.gltf.textures.length;return this.gltf.textures.push(t),s})}_addImage(e){const t=this.imageMap.get(e);if(null!=t)return t;this.gltf.images||(this.gltf.images=[]);const s={};if(e.url)s.uri=e.url;else{s.extras=e.data;for(let t=0;t<this.gltf.images.length;++t)if(e.data===this.gltf.images[t].extras)return t;switch(this.gltf.extras.options.imageOutputType){case h.GLB:{const t=this.gltf.extras.binChunkBuffer.addBufferView(_["k"].UNSIGNED_BYTE,u.SCALAR),i=j(e.data).then(({data:e,type:t})=>(s.mimeType=t,e));t.writeAsync(i).then(()=>{t.finalize()}),s.bufferView=t.index;break}case h.DataURI:s.uri=z(e.data);break;default:this.gltf.extras.promises.push(j(e.data).then(({data:e,type:t})=>{s.uri=e,s.mimeType=t}))}}const i=this.gltf.images.length;return this.gltf.images.push(s),this.imageMap.set(e,i),i}_addSampler(e){this.gltf.samplers||(this.gltf.samplers=[]);let t=_["B"].REPEAT,s=_["B"].REPEAT;if("string"==typeof e.wrap)switch(e.wrap){case"clamp":t=_["B"].CLAMP_TO_EDGE,s=_["B"].CLAMP_TO_EDGE;break;case"mirror":t=_["B"].MIRRORED_REPEAT,s=_["B"].MIRRORED_REPEAT}else{switch(e.wrap.vertical){case"clamp":s=_["B"].CLAMP_TO_EDGE;break;case"mirror":s=_["B"].MIRRORED_REPEAT}switch(e.wrap.horizontal){case"clamp":t=_["B"].CLAMP_TO_EDGE;break;case"mirror":t=_["B"].MIRRORED_REPEAT}}const i={wrapS:t,wrapT:s};for(let n=0;n<this.gltf.samplers.length;++n)if(JSON.stringify(i)===JSON.stringify(this.gltf.samplers[n]))return n;const r=this.gltf.samplers.length;return this.gltf.samplers.push(i),r}_addAccessor(e,t){this.gltf.accessors||(this.gltf.accessors=[]);const s={bufferView:e,byteOffset:t.byteOffset,componentType:t.componentType,count:t.count,type:t.type,min:t.min,max:t.max,name:t.name};t.normalized&&(s.normalized=!0);const i=this.gltf.accessors.length;return this.gltf.accessors.push(s),i}_addMeshVertexIndexed(e,t,s,i,r,n,a,o){for(const c of t){e.startAccessor("INDICES");for(let s=0;s<c.faces.length;++s)e.push(c.faces[s]);const t=e.endAccessor(),h={attributes:{POSITION:i},indices:this._addAccessor(e.index,t),material:this._addMaterial(c.material)};r&&"flat"!==c.shading&&(h.attributes.NORMAL=r),n&&(h.attributes.TEXCOORD_0=n),a&&"flat"!==c.shading&&(h.attributes.TANGENT=a),o&&(h.attributes.COLOR_0=o),s.primitives.push(h)}}_addMeshVertexNonIndexed(e,t,s,i,r,n,a){const o={attributes:{POSITION:s}};i&&(o.attributes.NORMAL=i),r&&(o.attributes.TEXCOORD_0=r),n&&(o.attributes.TANGENT=n),a&&(o.attributes.COLOR_0=a),e&&(o.material=this._addMaterial(e[0].material)),t.primitives.push(o)}}var U=s("b50f");class G{constructor(){this.copyright="",this.defaultScene=0,this.generator="",this._scenes=[]}addScene(e){if(this._scenes.includes(e))throw new Error("Scene already added");this._scenes.push(e)}removeScene(e){Object(U["j"])(this._scenes,e)}forEachScene(e){this._scenes.forEach(e)}}class v{constructor(){this.name="",this._nodes=[]}addNode(e){if(this._nodes.includes(e))throw new Error("Node already added");this._nodes.push(e)}forEachNode(e){this._nodes.forEach(e)}}class Y{constructor(e){this.mesh=e,this.name="",this.translation=Object(A["f"])(),this.rotation=Object(w["b"])(),this.scale=Object(A["d"])(A["a"]),this._nodes=[]}addNode(e){if(this._nodes.includes(e))throw new Error("Node already added");this._nodes.push(e)}forEachNode(e){this._nodes.forEach(e)}set rotationAngles(e){Object(b["e"])(this.rotation,e[0],e[1],e[2])}}const H="model.gltf",Z="model.glb";function J(e,t,s){const i=new P(e,t=t||{},s);let r=i.params;r?r.origin||(r.origin=new a["a"]({x:-1,y:-1,z:-1})):r={origin:new a["a"]({x:-1,y:-1,z:-1})};const f=r.origin,u=i.gltf,l=u.extras.promises;let d=1,p=1,g=null;return Object(n["j"])(l).then(()=>{const e={origin:f};delete u.extras;const s="number"==typeof t.jsonSpacing?t.jsonSpacing:4,i=JSON.stringify(u,(s,i)=>{if("extras"!==s){if(i instanceof ArrayBuffer){if(D(i))switch(t.imageOutputType){case h.DataURI:case h.GLB:break;case h.External:default:{const t=`img${p}.png`;return p++,e[t]=i,t}}switch(t.bufferOutputType){case c.DataURI:return k(i);case c.GLB:if(g)throw new Error("Already encountered an ArrayBuffer, there should only be one in the GLB format.");return void(g=i);case c.External:default:{const t=`data${d}.bin`;return d++,e[t]=i,t}}}return i}},s);return t.bufferOutputType===c.GLB||t.imageOutputType===h.GLB?e[Z]=new o(i,g).buffer:e[H]=i,e})}function W(e,t){return J(e,{bufferOutputType:c.GLB,imageOutputType:h.GLB,jsonSpacing:0},t)}class K{constructor(e,t){this._file={type:"model/gltf-binary",data:e},this.origin=t}buffer(){return Promise.resolve(this._file)}download(e){Object(r["j"])(new Blob([this._file.data],{type:this._file.type}),e)}}function X(e,t){const s=new G,i=new v;return s.addScene(i),i.addNode(new Y(e)),W(s,t).then(e=>new K(e[Z],e.origin))}}}]);
- //# sourceMappingURL=chunk-2d23775c.ab85503c.js.map
|