@loaders.gl/terrain
Advanced tools
Comparing version 3.0.0-beta.2 to 3.0.0-beta.3
@@ -1,2 +0,2 @@ | ||
!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 i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(window,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var s=t[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(i,s,function(t){return e[t]}.bind(null,s));return i},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=1)}([,function(e,t,n){(function(t){const i=n(3),s="undefined"==typeof window?t:window;s.loaders=s.loaders||{},e.exports=Object.assign(s.loaders,i)}).call(this,n(2))},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){"use strict";n.r(t),n.d(t,"TerrainLoader",(function(){return _})),n.d(t,"TerrainWorkerLoader",(function(){return c})),n.d(t,"QuantizedMeshLoader",(function(){return q})),n.d(t,"QuantizedMeshWorkerLoader",(function(){return x}));function i(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],h=a&&a.length;for(let e=0;e<h;e+=3){const h=a[e],u=a[e+1],d=a[e+2];t=h<t?h:t,n=u<n?u:n,i=d<i?d:i,s=h>s?h:s,r=u>r?u:r,o=d>o?d:o}return[[t,n,i],[s,r,o]]}class s{constructor(e=257){this.gridSize=e;const t=e-1;if(t&t-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=t*t*2-2,this.numParentTriangles=this.numTriangles-t*t,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let e=0;e<this.numTriangles;e++){let n=e+2,i=0,s=0,r=0,o=0,a=0,h=0;for(1&n?r=o=a=t:i=s=h=t;(n>>=1)>1;){const e=i+r>>1,t=s+o>>1;1&n?(r=i,o=s,i=a,s=h):(i=r,s=o,r=a,o=h),a=e,h=t}const u=4*e;this.coords[u+0]=i,this.coords[u+1]=s,this.coords[u+2]=r,this.coords[u+3]=o}}createTile(e){return new r(e,this)}}class r{constructor(e,t){const n=t.gridSize;if(e.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${e.length}.`);this.terrain=e,this.martini=t,this.errors=new Float32Array(e.length),this.update()}update(){const{numTriangles:e,numParentTriangles:t,coords:n,gridSize:i}=this.martini,{terrain:s,errors:r}=this;for(let o=e-1;o>=0;o--){const e=4*o,a=n[e+0],h=n[e+1],u=n[e+2],d=n[e+3],l=a+u>>1,c=h+d>>1,_=l+c-h,g=c+a-l,f=(s[h*i+a]+s[d*i+u])/2,E=c*i+l,p=Math.abs(f-s[E]);if(r[E]=Math.max(r[E],p),o<t){const e=(h+g>>1)*i+(a+_>>1),t=(d+g>>1)*i+(u+_>>1);r[E]=Math.max(r[E],r[e],r[t])}}}getMesh(e=0){const{gridSize:t,indices:n}=this.martini,{errors:i}=this;let s=0,r=0;const o=t-1;function a(o,h,u,d,l,c){const _=o+u>>1,g=h+d>>1;Math.abs(o-l)+Math.abs(h-c)>1&&i[g*t+_]>e?(a(l,c,o,h,_,g),a(u,d,l,c,_,g)):(n[h*t+o]=n[h*t+o]||++s,n[d*t+u]=n[d*t+u]||++s,n[c*t+l]=n[c*t+l]||++s,r++)}n.fill(0),a(0,0,o,o,o,0),a(o,o,0,0,0,o);const h=new Uint16Array(2*s),u=new Uint32Array(3*r);let d=0;function l(s,r,o,a,c,_){const g=s+o>>1,f=r+a>>1;if(Math.abs(s-c)+Math.abs(r-_)>1&&i[f*t+g]>e)l(c,_,s,r,g,f),l(o,a,c,_,g,f);else{const e=n[r*t+s]-1,i=n[a*t+o]-1,l=n[_*t+c]-1;h[2*e]=s,h[2*e+1]=r,h[2*i]=o,h[2*i+1]=a,h[2*l]=c,h[2*l+1]=_,u[d++]=e,u[d++]=i,u[d++]=l}}return l(0,0,o,o,o,0),l(o,o,0,0,0,o),{vertices:h,triangles:u}}}class o{constructor(e,t,n=t){this.data=e,this.width=t,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;const i=t-1,s=n-1,r=this._addPoint(0,0),o=this._addPoint(i,0),a=this._addPoint(0,s),h=this._addPoint(i,s),u=this._addTriangle(h,r,a,-1,-1,-1);this._addTriangle(r,h,o,u,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,t){return this.data[this.width*t+e]}_flush(){const e=this.coords;for(let t=0;t<this._pendingLen;t++){const n=this._pending[t],i=2*this.triangles[3*n+0],s=2*this.triangles[3*n+1],r=2*this.triangles[3*n+2];this._findCandidate(e[i],e[i+1],e[s],e[s+1],e[r],e[r+1],n)}this._pendingLen=0}_findCandidate(e,t,n,i,s,r,o){const h=Math.min(e,n,s),u=Math.min(t,i,r),d=Math.max(e,n,s),l=Math.max(t,i,r);let c=a(n,i,s,r,h,u),_=a(s,r,e,t,h,u),g=a(e,t,n,i,h,u);const f=i-t,E=e-n,p=r-i,T=n-s,m=t-r,y=s-e,S=a(e,t,n,i,s,r),b=this.heightAt(e,t)/S,w=this.heightAt(n,i)/S,P=this.heightAt(s,r)/S;let M=0,x=0,q=0,v=0;for(let e=u;e<=l;e++){let t=0;c<0&&0!==p&&(t=Math.max(t,Math.floor(-c/p))),_<0&&0!==m&&(t=Math.max(t,Math.floor(-_/m))),g<0&&0!==f&&(t=Math.max(t,Math.floor(-g/f)));let n=c+p*t,i=_+m*t,s=g+f*t,r=!1;for(let o=h+t;o<=d;o++){if(n>=0&&i>=0&&s>=0){r=!0;const t=b*n+w*i+P*s,a=Math.abs(t-this.heightAt(o,e));v+=a*a,a>M&&(M=a,x=o,q=e)}else if(r)break;n+=p,i+=m,s+=f}c+=T,_+=y,g+=E}(x===e&&q===t||x===n&&q===i||x===s&&q===r)&&(M=0),this._candidates[2*o]=x,this._candidates[2*o+1]=q,this._rms[o]=v,this._queuePush(o,M,v)}_step(){const e=this._queuePop(),t=3*e+0,n=3*e+1,i=3*e+2,s=this.triangles[t],r=this.triangles[n],o=this.triangles[i],h=this.coords[2*s],u=this.coords[2*s+1],d=this.coords[2*r],l=this.coords[2*r+1],c=this.coords[2*o],_=this.coords[2*o+1],g=this._candidates[2*e],f=this._candidates[2*e+1],E=this._addPoint(g,f);if(0===a(h,u,d,l,g,f))this._handleCollinear(E,t);else if(0===a(d,l,c,_,g,f))this._handleCollinear(E,n);else if(0===a(c,_,h,u,g,f))this._handleCollinear(E,i);else{const e=this._halfedges[t],a=this._halfedges[n],h=this._halfedges[i],u=this._addTriangle(s,r,E,e,-1,-1,t),d=this._addTriangle(r,o,E,a,-1,u+1),l=this._addTriangle(o,s,E,h,u+2,d+1);this._legalize(u),this._legalize(d),this._legalize(l)}}_addPoint(e,t){const n=this.coords.length>>1;return this.coords.push(e,t),n}_addTriangle(e,t,n,i,s,r,o=this.triangles.length){const a=o/3;return this.triangles[o+0]=e,this.triangles[o+1]=t,this.triangles[o+2]=n,this._halfedges[o+0]=i,this._halfedges[o+1]=s,this._halfedges[o+2]=r,i>=0&&(this._halfedges[i]=o+0),s>=0&&(this._halfedges[s]=o+1),r>=0&&(this._halfedges[r]=o+2),this._candidates[2*a+0]=0,this._candidates[2*a+1]=0,this._queueIndices[a]=-1,this._rms[a]=0,this._pending[this._pendingLen++]=a,o}_legalize(e){const t=this._halfedges[e];if(t<0)return;const n=e-e%3,i=t-t%3,s=n+(e+1)%3,r=n+(e+2)%3,o=i+(t+2)%3,a=i+(t+1)%3,h=this.triangles[r],u=this.triangles[e],d=this.triangles[s],l=this.triangles[o],c=this.coords;if(!function(e,t,n,i,s,r,o,a){const h=e-o,u=t-a,d=n-o,l=i-a,c=s-o,_=r-a,g=d*d+l*l,f=c*c+_*_;return h*(l*f-g*_)-u*(d*f-g*c)+(h*h+u*u)*(d*_-l*c)<0}(c[2*h],c[2*h+1],c[2*u],c[2*u+1],c[2*d],c[2*d+1],c[2*l],c[2*l+1]))return;const _=this._halfedges[s],g=this._halfedges[r],f=this._halfedges[o],E=this._halfedges[a];this._queueRemove(n/3),this._queueRemove(i/3);const p=this._addTriangle(h,l,d,-1,f,_,n),T=this._addTriangle(l,h,u,p,g,E,i);this._legalize(p+1),this._legalize(T+2)}_handleCollinear(e,t){const n=t-t%3,i=n+(t+1)%3,s=n+(t+2)%3,r=this.triangles[s],o=this.triangles[t],a=this.triangles[i],h=this._halfedges[i],u=this._halfedges[s],d=this._halfedges[t];if(d<0){const t=this._addTriangle(e,r,o,-1,u,-1,n),i=this._addTriangle(r,e,a,t,-1,h);return this._legalize(t+1),void this._legalize(i+2)}const l=d-d%3,c=l+(d+2)%3,_=l+(d+1)%3,g=this.triangles[c],f=this._halfedges[c],E=this._halfedges[_];this._queueRemove(l/3);const p=this._addTriangle(r,o,e,u,-1,-1,n),T=this._addTriangle(o,g,e,E,-1,p+1,l),m=this._addTriangle(g,a,e,f,-1,T+1),y=this._addTriangle(a,r,e,h,p+2,m+1);this._legalize(p),this._legalize(T),this._legalize(m),this._legalize(y)}_queuePush(e,t,n){const i=this._queue.length;this._queueIndices[e]=i,this._queue.push(e),this._errors.push(t),this._rmsSum+=n,this._queueUp(i)}_queuePop(){const e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){const e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){const t=this._queueIndices[e];if(t<0){const t=this._pending.indexOf(e);if(-1===t)throw new Error("Broken triangulation (something went wrong).");return void(this._pending[t]=this._pending[--this._pendingLen])}const n=this._queue.length-1;n!==t&&(this._queueSwap(t,n),this._queueDown(t,n)||this._queueUp(t)),this._queuePopBack()}_queueLess(e,t){return this._errors[e]>this._errors[t]}_queueSwap(e,t){const n=this._queue[e],i=this._queue[t];this._queue[e]=i,this._queue[t]=n,this._queueIndices[n]=t,this._queueIndices[i]=e;const s=this._errors[e];this._errors[e]=this._errors[t],this._errors[t]=s}_queueUp(e){let t=e;for(;;){const e=t-1>>1;if(e===t||!this._queueLess(t,e))break;this._queueSwap(e,t),t=e}}_queueDown(e,t){let n=e;for(;;){const e=2*n+1;if(e>=t||e<0)break;const i=e+1;let s=e;if(i<t&&this._queueLess(i,e)&&(s=i),!this._queueLess(s,n))break;this._queueSwap(n,s),n=s}return n>e}}function a(e,t,n,i,s,r){return(n-s)*(t-r)-(i-r)*(e-s)}function h(e,t,n,i,s){const{rScaler:r,bScaler:o,gScaler:a,offset:h}=i,u=new Float32Array((t+1)*(n+1));for(let i=0,s=0;s<n;s++)for(let n=0;n<t;n++,i++){const t=4*i,n=e[t+0],d=e[t+1],l=e[t+2];u[i+s]=n*r+d*a+l*o+h}if("martini"===s){for(let e=(t+1)*t,n=0;n<t;n++,e++)u[e]=u[e-t-1];for(let e=n,t=0;t<n+1;t++,e+=n+1)u[e]=u[e-1]}return u}function u(e,t){if(null===e)return null;const{meshMaxError:n,bounds:s,elevationDecoder:r}=t,{data:o,width:a,height:u}=e;let c,_;switch(t.tesselator){case"martini":c=h(o,a,u,r,t.tesselator),_=d(n,a,c);break;case"delatin":c=h(o,a,u,r,t.tesselator),_=l(n,a,u,c);break;default:a!==u||u&a-1?(c=h(o,a,u,r,"delatin"),_=l(n,a,u,c)):(c=h(o,a,u,r,"martini"),_=d(n,a,c))}const{vertices:g,triangles:f}=_,E=function(e,t,n,i,s){const r=n+1,o=e.length/2,a=new Float32Array(3*o),h=new Float32Array(2*o),[u,d,l,c]=s||[0,0,n,i],_=(l-u)/n,g=(c-d)/i;for(let s=0;s<o;s++){const o=e[2*s],d=e[2*s+1],l=d*r+o;a[3*s+0]=o*_+u,a[3*s+1]=-d*g+c,a[3*s+2]=t[l],h[2*s+0]=o/n,h[2*s+1]=d/i}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:h,size:2}}}(g,c,a,u,s);return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:i(E)},mode:4,indices:{value:Uint32Array.from(f),size:1},attributes:E}}function d(e,t,n){const i=new s(t+1).createTile(n),{vertices:r,triangles:o}=i.getMesh(e);return{vertices:r,triangles:o}}function l(e,t,n,i){const s=new o(i,t+1,n+1);s.run(e);const{coords:r,triangles:a}=s;return{vertices:r,triangles:a}}const c={name:"Terrain",id:"terrain",module:"terrain",version:"3.0.0-beta.2",worker:!0,extensions:["png","pngraw"],mimeTypes:["image/png"],options:{terrain:{tesselator:"auto",bounds:null,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0}}}},_={...c,parse:async function(e,t,n){return t.image=t.image||{},t.image.type="data",u(await n.parse(e,t,t.baseUri),t.terrain)}},g=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function f(e){return e>>1^-(1&e)}function E(e,t,n,i,s=!0){let r;if(r=2===i?new Uint16Array(e,t,n):new Uint32Array(e,t,n),!s)return r;let o=0;for(let e=0;e<r.length;++e){const t=r[e];r[e]=o-t,0===t&&++o}return r}function p(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}const T=1,m=2,y=3,S=4,b={maxDecodingStep:S};function w(e,t){const n=Object.assign({},b,t),i=new DataView(e),{header:s,headerEndPosition:r}=function(e){let t=0;const n={};for(const[i,s]of g){const r=8===s?e.getFloat64:e.getFloat32;n[i]=r.call(e,t,!0),t+=s}return{header:n,headerEndPosition:t}}(i);if(n.maxDecodingStep<T)return{header:s};const{vertexData:o,vertexDataEndPosition:a}=function(e,t){let n=t;const i=e.getUint32(n,!0),s=new Uint16Array(3*i);n+=Uint32Array.BYTES_PER_ELEMENT;const r=Uint16Array.BYTES_PER_ELEMENT,o=i*r,a=n,h=a+o,u=h+o;let d=0,l=0,c=0;for(let t=0;t<i;t++)d+=f(e.getUint16(a+r*t,!0)),l+=f(e.getUint16(h+r*t,!0)),c+=f(e.getUint16(u+r*t,!0)),s[t]=d,s[t+i]=l,s[t+2*i]=c;return n+=3*o,{vertexData:s,vertexDataEndPosition:n}}(i,r);if(n.maxDecodingStep<m)return{header:s,vertexData:o};const{triangleIndices:h,triangleIndicesEndPosition:u}=function(e,t,n){let i=n;const s=t.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;i%s!=0&&(i+=s-i%s);const r=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const o=3*r,a=E(e.buffer,i,o,s);return i+=o*s,{triangleIndicesEndPosition:i,triangleIndices:a}}(i,o,a);if(n.maxDecodingStep<y)return{header:s,vertexData:o,triangleIndices:h};const{westIndices:d,southIndices:l,eastIndices:c,northIndices:_,edgeIndicesEndPosition:w}=function(e,t,n){let i=n;const s=t.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,r=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const o=E(e.buffer,i,r,s,!1);i+=r*s;const a=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const h=E(e.buffer,i,a,s,!1);i+=a*s;const u=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const d=E(e.buffer,i,u,s,!1);i+=u*s;const l=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const c=E(e.buffer,i,l,s,!1);return i+=l*s,{edgeIndicesEndPosition:i,westIndices:o,southIndices:h,eastIndices:d,northIndices:c}}(i,o,u);if(n.maxDecodingStep<S)return{header:s,vertexData:o,triangleIndices:h,westIndices:d,northIndices:_,eastIndices:c,southIndices:l};const{extensions:P}=function(e,t){const n={};if(e.byteLength<=t)return{extensions:n,extensionsEndPosition:t};let i=t;for(;i<e.byteLength;){const t=e.getUint8(i,!0);i+=Uint8Array.BYTES_PER_ELEMENT;const r=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const o=new DataView(e.buffer,i,r);switch(t){case 1:n.vertexNormals=(s=o,new Uint8Array(s.buffer,s.byteOffset,s.byteLength));break;case 2:n.waterMask=p(o)}i+=r}var s;return{extensions:n,extensionsEndPosition:i}}(i,w);return{header:s,vertexData:o,triangleIndices:h,westIndices:d,northIndices:_,eastIndices:c,southIndices:l,extensions:P}}function P(e,t){if(!e)return null;const{bounds:n}=t,{header:s,vertexData:r,triangleIndices:o}=w(e,m),a=function(e,t,n){const{minHeight:i,maxHeight:s}=t,[r,o,a,h]=n||[0,0,1,1],u=a-r,d=h-o,l=s-i,c=e.length/3,_=new Float32Array(3*c),g=new Float32Array(2*c);for(let t=0;t<c;t++){const n=e[t]/32767,s=e[t+c]/32767,a=e[t+2*c]/32767;_[3*t+0]=n*u+r,_[3*t+1]=s*d+o,_[3*t+2]=a*l+i,g[2*t+0]=n,g[2*t+1]=s}return{POSITION:{value:_,size:3},TEXCOORD_0:{value:g,size:2}}}(r,s,n);return{loaderData:{header:{}},header:{vertexCount:o.length,boundingBox:i(a)},mode:4,indices:{value:o,size:1},attributes:a}}function M(e,t){return P(e,t["quantized-mesh"])}const x={name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:"3.0.0-beta.2",worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1]}}},q={...x,parseSync:M,parse:async(e,t)=>M(e,t)}}])})); | ||
!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 i in n)("object"==typeof exports?exports:e)[i]=n[i]}}(window,(function(){return function(e){var t={};function n(i){if(t[i])return t[i].exports;var s=t[i]={i:i,l:!1,exports:{}};return e[i].call(s.exports,s,s.exports,n),s.l=!0,s.exports}return n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var s in e)n.d(i,s,function(t){return e[t]}.bind(null,s));return i},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=1)}([,function(e,t,n){(function(t){const i=n(3),s="undefined"==typeof window?t:window;s.loaders=s.loaders||{},e.exports=Object.assign(s.loaders,i)}).call(this,n(2))},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){"use strict";n.r(t),n.d(t,"TerrainLoader",(function(){return _})),n.d(t,"TerrainWorkerLoader",(function(){return c})),n.d(t,"QuantizedMeshLoader",(function(){return q})),n.d(t,"QuantizedMeshWorkerLoader",(function(){return x}));function i(e){let t=1/0,n=1/0,i=1/0,s=-1/0,r=-1/0,o=-1/0;const a=e.POSITION?e.POSITION.value:[],h=a&&a.length;for(let e=0;e<h;e+=3){const h=a[e],u=a[e+1],d=a[e+2];t=h<t?h:t,n=u<n?u:n,i=d<i?d:i,s=h>s?h:s,r=u>r?u:r,o=d>o?d:o}return[[t,n,i],[s,r,o]]}class s{constructor(e=257){this.gridSize=e;const t=e-1;if(t&t-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=t*t*2-2,this.numParentTriangles=this.numTriangles-t*t,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let e=0;e<this.numTriangles;e++){let n=e+2,i=0,s=0,r=0,o=0,a=0,h=0;for(1&n?r=o=a=t:i=s=h=t;(n>>=1)>1;){const e=i+r>>1,t=s+o>>1;1&n?(r=i,o=s,i=a,s=h):(i=r,s=o,r=a,o=h),a=e,h=t}const u=4*e;this.coords[u+0]=i,this.coords[u+1]=s,this.coords[u+2]=r,this.coords[u+3]=o}}createTile(e){return new r(e,this)}}class r{constructor(e,t){const n=t.gridSize;if(e.length!==n*n)throw new Error(`Expected terrain data of length ${n*n} (${n} x ${n}), got ${e.length}.`);this.terrain=e,this.martini=t,this.errors=new Float32Array(e.length),this.update()}update(){const{numTriangles:e,numParentTriangles:t,coords:n,gridSize:i}=this.martini,{terrain:s,errors:r}=this;for(let o=e-1;o>=0;o--){const e=4*o,a=n[e+0],h=n[e+1],u=n[e+2],d=n[e+3],l=a+u>>1,c=h+d>>1,_=l+c-h,g=c+a-l,f=(s[h*i+a]+s[d*i+u])/2,E=c*i+l,p=Math.abs(f-s[E]);if(r[E]=Math.max(r[E],p),o<t){const e=(h+g>>1)*i+(a+_>>1),t=(d+g>>1)*i+(u+_>>1);r[E]=Math.max(r[E],r[e],r[t])}}}getMesh(e=0){const{gridSize:t,indices:n}=this.martini,{errors:i}=this;let s=0,r=0;const o=t-1;function a(o,h,u,d,l,c){const _=o+u>>1,g=h+d>>1;Math.abs(o-l)+Math.abs(h-c)>1&&i[g*t+_]>e?(a(l,c,o,h,_,g),a(u,d,l,c,_,g)):(n[h*t+o]=n[h*t+o]||++s,n[d*t+u]=n[d*t+u]||++s,n[c*t+l]=n[c*t+l]||++s,r++)}n.fill(0),a(0,0,o,o,o,0),a(o,o,0,0,0,o);const h=new Uint16Array(2*s),u=new Uint32Array(3*r);let d=0;function l(s,r,o,a,c,_){const g=s+o>>1,f=r+a>>1;if(Math.abs(s-c)+Math.abs(r-_)>1&&i[f*t+g]>e)l(c,_,s,r,g,f),l(o,a,c,_,g,f);else{const e=n[r*t+s]-1,i=n[a*t+o]-1,l=n[_*t+c]-1;h[2*e]=s,h[2*e+1]=r,h[2*i]=o,h[2*i+1]=a,h[2*l]=c,h[2*l+1]=_,u[d++]=e,u[d++]=i,u[d++]=l}}return l(0,0,o,o,o,0),l(o,o,0,0,0,o),{vertices:h,triangles:u}}}class o{constructor(e,t,n=t){this.data=e,this.width=t,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;const i=t-1,s=n-1,r=this._addPoint(0,0),o=this._addPoint(i,0),a=this._addPoint(0,s),h=this._addPoint(i,s),u=this._addTriangle(h,r,a,-1,-1,-1);this._addTriangle(r,h,o,u,-1,-1),this._flush()}run(e=1){for(;this.getMaxError()>e;)this.refine()}refine(){this._step(),this._flush()}getMaxError(){return this._errors[0]}getRMSD(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}heightAt(e,t){return this.data[this.width*t+e]}_flush(){const e=this.coords;for(let t=0;t<this._pendingLen;t++){const n=this._pending[t],i=2*this.triangles[3*n+0],s=2*this.triangles[3*n+1],r=2*this.triangles[3*n+2];this._findCandidate(e[i],e[i+1],e[s],e[s+1],e[r],e[r+1],n)}this._pendingLen=0}_findCandidate(e,t,n,i,s,r,o){const h=Math.min(e,n,s),u=Math.min(t,i,r),d=Math.max(e,n,s),l=Math.max(t,i,r);let c=a(n,i,s,r,h,u),_=a(s,r,e,t,h,u),g=a(e,t,n,i,h,u);const f=i-t,E=e-n,p=r-i,T=n-s,m=t-r,y=s-e,S=a(e,t,n,i,s,r),b=this.heightAt(e,t)/S,w=this.heightAt(n,i)/S,P=this.heightAt(s,r)/S;let M=0,x=0,q=0,v=0;for(let e=u;e<=l;e++){let t=0;c<0&&0!==p&&(t=Math.max(t,Math.floor(-c/p))),_<0&&0!==m&&(t=Math.max(t,Math.floor(-_/m))),g<0&&0!==f&&(t=Math.max(t,Math.floor(-g/f)));let n=c+p*t,i=_+m*t,s=g+f*t,r=!1;for(let o=h+t;o<=d;o++){if(n>=0&&i>=0&&s>=0){r=!0;const t=b*n+w*i+P*s,a=Math.abs(t-this.heightAt(o,e));v+=a*a,a>M&&(M=a,x=o,q=e)}else if(r)break;n+=p,i+=m,s+=f}c+=T,_+=y,g+=E}(x===e&&q===t||x===n&&q===i||x===s&&q===r)&&(M=0),this._candidates[2*o]=x,this._candidates[2*o+1]=q,this._rms[o]=v,this._queuePush(o,M,v)}_step(){const e=this._queuePop(),t=3*e+0,n=3*e+1,i=3*e+2,s=this.triangles[t],r=this.triangles[n],o=this.triangles[i],h=this.coords[2*s],u=this.coords[2*s+1],d=this.coords[2*r],l=this.coords[2*r+1],c=this.coords[2*o],_=this.coords[2*o+1],g=this._candidates[2*e],f=this._candidates[2*e+1],E=this._addPoint(g,f);if(0===a(h,u,d,l,g,f))this._handleCollinear(E,t);else if(0===a(d,l,c,_,g,f))this._handleCollinear(E,n);else if(0===a(c,_,h,u,g,f))this._handleCollinear(E,i);else{const e=this._halfedges[t],a=this._halfedges[n],h=this._halfedges[i],u=this._addTriangle(s,r,E,e,-1,-1,t),d=this._addTriangle(r,o,E,a,-1,u+1),l=this._addTriangle(o,s,E,h,u+2,d+1);this._legalize(u),this._legalize(d),this._legalize(l)}}_addPoint(e,t){const n=this.coords.length>>1;return this.coords.push(e,t),n}_addTriangle(e,t,n,i,s,r,o=this.triangles.length){const a=o/3;return this.triangles[o+0]=e,this.triangles[o+1]=t,this.triangles[o+2]=n,this._halfedges[o+0]=i,this._halfedges[o+1]=s,this._halfedges[o+2]=r,i>=0&&(this._halfedges[i]=o+0),s>=0&&(this._halfedges[s]=o+1),r>=0&&(this._halfedges[r]=o+2),this._candidates[2*a+0]=0,this._candidates[2*a+1]=0,this._queueIndices[a]=-1,this._rms[a]=0,this._pending[this._pendingLen++]=a,o}_legalize(e){const t=this._halfedges[e];if(t<0)return;const n=e-e%3,i=t-t%3,s=n+(e+1)%3,r=n+(e+2)%3,o=i+(t+2)%3,a=i+(t+1)%3,h=this.triangles[r],u=this.triangles[e],d=this.triangles[s],l=this.triangles[o],c=this.coords;if(!function(e,t,n,i,s,r,o,a){const h=e-o,u=t-a,d=n-o,l=i-a,c=s-o,_=r-a,g=d*d+l*l,f=c*c+_*_;return h*(l*f-g*_)-u*(d*f-g*c)+(h*h+u*u)*(d*_-l*c)<0}(c[2*h],c[2*h+1],c[2*u],c[2*u+1],c[2*d],c[2*d+1],c[2*l],c[2*l+1]))return;const _=this._halfedges[s],g=this._halfedges[r],f=this._halfedges[o],E=this._halfedges[a];this._queueRemove(n/3),this._queueRemove(i/3);const p=this._addTriangle(h,l,d,-1,f,_,n),T=this._addTriangle(l,h,u,p,g,E,i);this._legalize(p+1),this._legalize(T+2)}_handleCollinear(e,t){const n=t-t%3,i=n+(t+1)%3,s=n+(t+2)%3,r=this.triangles[s],o=this.triangles[t],a=this.triangles[i],h=this._halfedges[i],u=this._halfedges[s],d=this._halfedges[t];if(d<0){const t=this._addTriangle(e,r,o,-1,u,-1,n),i=this._addTriangle(r,e,a,t,-1,h);return this._legalize(t+1),void this._legalize(i+2)}const l=d-d%3,c=l+(d+2)%3,_=l+(d+1)%3,g=this.triangles[c],f=this._halfedges[c],E=this._halfedges[_];this._queueRemove(l/3);const p=this._addTriangle(r,o,e,u,-1,-1,n),T=this._addTriangle(o,g,e,E,-1,p+1,l),m=this._addTriangle(g,a,e,f,-1,T+1),y=this._addTriangle(a,r,e,h,p+2,m+1);this._legalize(p),this._legalize(T),this._legalize(m),this._legalize(y)}_queuePush(e,t,n){const i=this._queue.length;this._queueIndices[e]=i,this._queue.push(e),this._errors.push(t),this._rmsSum+=n,this._queueUp(i)}_queuePop(){const e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){const e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){const t=this._queueIndices[e];if(t<0){const t=this._pending.indexOf(e);if(-1===t)throw new Error("Broken triangulation (something went wrong).");return void(this._pending[t]=this._pending[--this._pendingLen])}const n=this._queue.length-1;n!==t&&(this._queueSwap(t,n),this._queueDown(t,n)||this._queueUp(t)),this._queuePopBack()}_queueLess(e,t){return this._errors[e]>this._errors[t]}_queueSwap(e,t){const n=this._queue[e],i=this._queue[t];this._queue[e]=i,this._queue[t]=n,this._queueIndices[n]=t,this._queueIndices[i]=e;const s=this._errors[e];this._errors[e]=this._errors[t],this._errors[t]=s}_queueUp(e){let t=e;for(;;){const e=t-1>>1;if(e===t||!this._queueLess(t,e))break;this._queueSwap(e,t),t=e}}_queueDown(e,t){let n=e;for(;;){const e=2*n+1;if(e>=t||e<0)break;const i=e+1;let s=e;if(i<t&&this._queueLess(i,e)&&(s=i),!this._queueLess(s,n))break;this._queueSwap(n,s),n=s}return n>e}}function a(e,t,n,i,s,r){return(n-s)*(t-r)-(i-r)*(e-s)}function h(e,t,n,i,s){const{rScaler:r,bScaler:o,gScaler:a,offset:h}=i,u=new Float32Array((t+1)*(n+1));for(let i=0,s=0;s<n;s++)for(let n=0;n<t;n++,i++){const t=4*i,n=e[t+0],d=e[t+1],l=e[t+2];u[i+s]=n*r+d*a+l*o+h}if("martini"===s){for(let e=(t+1)*t,n=0;n<t;n++,e++)u[e]=u[e-t-1];for(let e=n,t=0;t<n+1;t++,e+=n+1)u[e]=u[e-1]}return u}function u(e,t){if(null===e)return null;const{meshMaxError:n,bounds:s,elevationDecoder:r}=t,{data:o,width:a,height:u}=e;let c,_;switch(t.tesselator){case"martini":c=h(o,a,u,r,t.tesselator),_=d(n,a,c);break;case"delatin":c=h(o,a,u,r,t.tesselator),_=l(n,a,u,c);break;default:a!==u||u&a-1?(c=h(o,a,u,r,"delatin"),_=l(n,a,u,c)):(c=h(o,a,u,r,"martini"),_=d(n,a,c))}const{vertices:g,triangles:f}=_,E=function(e,t,n,i,s){const r=n+1,o=e.length/2,a=new Float32Array(3*o),h=new Float32Array(2*o),[u,d,l,c]=s||[0,0,n,i],_=(l-u)/n,g=(c-d)/i;for(let s=0;s<o;s++){const o=e[2*s],d=e[2*s+1],l=d*r+o;a[3*s+0]=o*_+u,a[3*s+1]=-d*g+c,a[3*s+2]=t[l],h[2*s+0]=o/n,h[2*s+1]=d/i}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:h,size:2}}}(g,c,a,u,s);return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:i(E)},mode:4,indices:{value:Uint32Array.from(f),size:1},attributes:E}}function d(e,t,n){const i=new s(t+1).createTile(n),{vertices:r,triangles:o}=i.getMesh(e);return{vertices:r,triangles:o}}function l(e,t,n,i){const s=new o(i,t+1,n+1);s.run(e);const{coords:r,triangles:a}=s;return{vertices:r,triangles:a}}const c={name:"Terrain",id:"terrain",module:"terrain",version:"3.0.0-beta.3",worker:!0,extensions:["png","pngraw"],mimeTypes:["image/png"],options:{terrain:{tesselator:"auto",bounds:null,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0}}}},_={...c,parse:async function(e,t,n){return t.image=t.image||{},t.image.type="data",u(await n.parse(e,t,t.baseUri),t.terrain)}},g=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function f(e){return e>>1^-(1&e)}function E(e,t,n,i,s=!0){let r;if(r=2===i?new Uint16Array(e,t,n):new Uint32Array(e,t,n),!s)return r;let o=0;for(let e=0;e<r.length;++e){const t=r[e];r[e]=o-t,0===t&&++o}return r}function p(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}const T=1,m=2,y=3,S=4,b={maxDecodingStep:S};function w(e,t){const n=Object.assign({},b,t),i=new DataView(e),{header:s,headerEndPosition:r}=function(e){let t=0;const n={};for(const[i,s]of g){const r=8===s?e.getFloat64:e.getFloat32;n[i]=r.call(e,t,!0),t+=s}return{header:n,headerEndPosition:t}}(i);if(n.maxDecodingStep<T)return{header:s};const{vertexData:o,vertexDataEndPosition:a}=function(e,t){let n=t;const i=e.getUint32(n,!0),s=new Uint16Array(3*i);n+=Uint32Array.BYTES_PER_ELEMENT;const r=Uint16Array.BYTES_PER_ELEMENT,o=i*r,a=n,h=a+o,u=h+o;let d=0,l=0,c=0;for(let t=0;t<i;t++)d+=f(e.getUint16(a+r*t,!0)),l+=f(e.getUint16(h+r*t,!0)),c+=f(e.getUint16(u+r*t,!0)),s[t]=d,s[t+i]=l,s[t+2*i]=c;return n+=3*o,{vertexData:s,vertexDataEndPosition:n}}(i,r);if(n.maxDecodingStep<m)return{header:s,vertexData:o};const{triangleIndices:h,triangleIndicesEndPosition:u}=function(e,t,n){let i=n;const s=t.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;i%s!=0&&(i+=s-i%s);const r=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const o=3*r,a=E(e.buffer,i,o,s);return i+=o*s,{triangleIndicesEndPosition:i,triangleIndices:a}}(i,o,a);if(n.maxDecodingStep<y)return{header:s,vertexData:o,triangleIndices:h};const{westIndices:d,southIndices:l,eastIndices:c,northIndices:_,edgeIndicesEndPosition:w}=function(e,t,n){let i=n;const s=t.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,r=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const o=E(e.buffer,i,r,s,!1);i+=r*s;const a=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const h=E(e.buffer,i,a,s,!1);i+=a*s;const u=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const d=E(e.buffer,i,u,s,!1);i+=u*s;const l=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const c=E(e.buffer,i,l,s,!1);return i+=l*s,{edgeIndicesEndPosition:i,westIndices:o,southIndices:h,eastIndices:d,northIndices:c}}(i,o,u);if(n.maxDecodingStep<S)return{header:s,vertexData:o,triangleIndices:h,westIndices:d,northIndices:_,eastIndices:c,southIndices:l};const{extensions:P}=function(e,t){const n={};if(e.byteLength<=t)return{extensions:n,extensionsEndPosition:t};let i=t;for(;i<e.byteLength;){const t=e.getUint8(i,!0);i+=Uint8Array.BYTES_PER_ELEMENT;const r=e.getUint32(i,!0);i+=Uint32Array.BYTES_PER_ELEMENT;const o=new DataView(e.buffer,i,r);switch(t){case 1:n.vertexNormals=(s=o,new Uint8Array(s.buffer,s.byteOffset,s.byteLength));break;case 2:n.waterMask=p(o)}i+=r}var s;return{extensions:n,extensionsEndPosition:i}}(i,w);return{header:s,vertexData:o,triangleIndices:h,westIndices:d,northIndices:_,eastIndices:c,southIndices:l,extensions:P}}function P(e,t){if(!e)return null;const{bounds:n}=t,{header:s,vertexData:r,triangleIndices:o}=w(e,m),a=function(e,t,n){const{minHeight:i,maxHeight:s}=t,[r,o,a,h]=n||[0,0,1,1],u=a-r,d=h-o,l=s-i,c=e.length/3,_=new Float32Array(3*c),g=new Float32Array(2*c);for(let t=0;t<c;t++){const n=e[t]/32767,s=e[t+c]/32767,a=e[t+2*c]/32767;_[3*t+0]=n*u+r,_[3*t+1]=s*d+o,_[3*t+2]=a*l+i,g[2*t+0]=n,g[2*t+1]=s}return{POSITION:{value:_,size:3},TEXCOORD_0:{value:g,size:2}}}(r,s,n);return{loaderData:{header:{}},header:{vertexCount:o.length,boundingBox:i(a)},mode:4,indices:{value:o,size:1},attributes:a}}function M(e,t){return P(e,t["quantized-mesh"])}const x={name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:"3.0.0-beta.3",worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1]}}},q={...x,parseSync:M,parse:async(e,t)=>M(e,t)}}])})); | ||
//# sourceMappingURL=dist.min.js.map |
@@ -7,4 +7,4 @@ "use strict"; | ||
exports.VERSION = void 0; | ||
var VERSION = typeof "3.0.0-beta.2" !== 'undefined' ? "3.0.0-beta.2" : 'latest'; | ||
var VERSION = typeof "3.0.0-beta.3" !== 'undefined' ? "3.0.0-beta.3" : 'latest'; | ||
exports.VERSION = VERSION; | ||
//# sourceMappingURL=version.js.map |
@@ -1,2 +0,2 @@ | ||
export const VERSION = typeof "3.0.0-beta.2" !== 'undefined' ? "3.0.0-beta.2" : 'latest'; | ||
export const VERSION = typeof "3.0.0-beta.3" !== 'undefined' ? "3.0.0-beta.3" : 'latest'; | ||
//# sourceMappingURL=version.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=14)}([function(e,t,r){e.exports=r(8)},function(e,t){function r(e,t,r,n,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function u(e){r(a,o,i,u,s,"next",e)}function s(e){r(a,o,i,u,s,"throw",e)}u(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(9),o=r(10),i=r(11),a=r(13);e.exports=function(e,t){return n(e)||o(e,t)||i(e,t)||a()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},,function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof l?t:l,i=Object.create(o.prototype),a=new _(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=b(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=c(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,a),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f={};function l(){}function p(){}function d(){}var y={};y[o]=function(){return this};var h=Object.getPrototypeOf,v=h&&h(h(O([])));v&&v!==t&&r.call(v,o)&&(y=v);var E=d.prototype=l.prototype=Object.create(y);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var n;this._invoke=function(o,i){function a(){return new t((function(n,a){!function n(o,i,a,u){var s=c(e[o],e,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(l).then((function(e){f.value=e,a(f)}),(function(e){return n("throw",e,a,u)}))}u(s.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:P}}function P(){return{value:void 0,done:!0}}return p.prototype=E.constructor=d,d.constructor=p,p.displayName=u(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,u(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},g(m.prototype),m.prototype[i]=function(){return this},e.AsyncIterator=m,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new m(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(E),u(E,a,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;w(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:O(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){var r=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=r){var n,o,i=[],a=!0,u=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(u)throw o}}return i}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.r(t);var n=r(2),o=r.n(n),i=r(1),a=r.n(i),u=r(0),s=r.n(u),c=r(4),f=r.n(c),l=r(5),p=r.n(l),d=r(6),y=r.n(d);function h(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var v=new Map,E=function(){function e(){f()(this,e)}return p()(e,null,[{key:"onmessage",set:function(e){self.onmessage=function(t){if(g(t)){var r=t.data,n=r.type,o=r.payload;e(n,o)}}}},{key:"addEventListener",value:function(e){var t=v.get(e);t||(t=function(t){if(g(t)){var r=t.data,n=r.type,o=r.payload;e(n,o)}}),self.addEventListener("message",t)}},{key:"removeEventListener",value:function(e){var t=v.get(e);v.delete(e),self.removeEventListener("message",t)}},{key:"postMessage",value:function(e,t){if(self){var r={source:"loaders.gl",type:e,payload:t},n=function e(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,o=n||new Set;if(t){if(h(t))o.add(t);else if(h(t.buffer))o.add(t.buffer);else if(ArrayBuffer.isView(t));else if(r&&"object"===y()(t))for(var i in t)e(t[i],r,o)}else;return void 0===n?Array.from(o):[]}(t);self.postMessage(r,n)}}}]),e}();function g(e){var t=e.type,r=e.data;return"message"===t&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var x=0;function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(r,n){var o=x++;E.addEventListener((function e(t,i){if(i.id===o)switch(t){case"done":E.removeEventListener(e),r(i.result);break;case"error":E.removeEventListener(e),n(i.error)}}));var i={id:o,input:e,options:t};E.postMessage("process",i)}))}function _(e){return O.apply(this,arguments)}function O(){return(O=a()(s.a.mark((function e(t){var r,n,o,i,a,u,c;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.loader,n=t.arrayBuffer,o=t.options,i=t.context,!r.parseSync&&!r.parse){e.next=6;break}a=n,u=r.parseSync||r.parse,e.next=13;break;case 6:if(!r.parseTextSync){e.next=12;break}c=new TextDecoder,a=c.decode(n),u=r.parseTextSync,e.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return o=b(b({},o),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),e.next=16,u(a,b({},o),i,r);case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var P=r(3),S=r.n(P);function T(e){for(var t=1/0,r=1/0,n=1/0,o=-1/0,i=-1/0,a=-1/0,u=e.POSITION?e.POSITION.value:[],s=u&&u.length,c=0;c<s;c+=3){var f=u[c],l=u[c+1],p=u[c+2];t=f<t?f:t,r=l<r?l:r,n=p<n?p:n,o=f>o?f:o,i=l>i?l:i,a=p>a?p:a}return[[t,r,n],[o,i,a]]}function L(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var j=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function A(e){return e>>1^-(1&e)}function I(e,t,r,n){var o,i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];if(o=2===n?new Uint16Array(e,t,r):new Uint32Array(e,t,r),!i)return o;for(var a=0,u=0;u<o.length;++u){var s=o[u];o[u]=a-s,0===s&&++a}return o}function N(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var B=1,k=2,U=3,Y=4,R={maxDecodingStep:Y};function D(e,t){var r=Object.assign({},R,t),n=new DataView(e),o=function(e){var t,r=0,n={},o=L(j);try{for(o.s();!(t=o.n()).done;){var i=S()(t.value,2),a=i[0],u=i[1],s=8===u?e.getFloat64:e.getFloat32;n[a]=s.call(e,r,!0),r+=u}}catch(e){o.e(e)}finally{o.f()}return{header:n,headerEndPosition:r}}(n),i=o.header,a=o.headerEndPosition;if(r.maxDecodingStep<B)return{header:i};var u=function(e,t){var r=t,n=e.getUint32(r,!0),o=new Uint16Array(3*n);r+=Uint32Array.BYTES_PER_ELEMENT;for(var i=Uint16Array.BYTES_PER_ELEMENT,a=n*i,u=r,s=u+a,c=s+a,f=0,l=0,p=0,d=0;d<n;d++)f+=A(e.getUint16(u+i*d,!0)),l+=A(e.getUint16(s+i*d,!0)),p+=A(e.getUint16(c+i*d,!0)),o[d]=f,o[d+n]=l,o[d+2*n]=p;return{vertexData:o,vertexDataEndPosition:r+=3*a}}(n,a),s=u.vertexData,c=u.vertexDataEndPosition;if(r.maxDecodingStep<k)return{header:i,vertexData:s};var f=function(e,t,r){var n=r,o=t.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;n%o!=0&&(n+=o-n%o);var i=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var a=3*i,u=I(e.buffer,n,a,o);return{triangleIndicesEndPosition:n+=a*o,triangleIndices:u}}(n,s,c),l=f.triangleIndices,p=f.triangleIndicesEndPosition;if(r.maxDecodingStep<U)return{header:i,vertexData:s,triangleIndices:l};var d=function(e,t,r){var n=r,o=t.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,i=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var a=I(e.buffer,n,i,o,!1);n+=i*o;var u=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var s=I(e.buffer,n,u,o,!1);n+=u*o;var c=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var f=I(e.buffer,n,c,o,!1);n+=c*o;var l=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var p=I(e.buffer,n,l,o,!1);return{edgeIndicesEndPosition:n+=l*o,westIndices:a,southIndices:s,eastIndices:f,northIndices:p}}(n,s,p),y=d.westIndices,h=d.southIndices,v=d.eastIndices,E=d.northIndices,g=d.edgeIndicesEndPosition;return r.maxDecodingStep<Y?{header:i,vertexData:s,triangleIndices:l,westIndices:y,northIndices:E,eastIndices:v,southIndices:h}:{header:i,vertexData:s,triangleIndices:l,westIndices:y,northIndices:E,eastIndices:v,southIndices:h,extensions:function(e,t){var r={};if(e.byteLength<=t)return{extensions:r,extensionsEndPosition:t};for(var n,o=t;o<e.byteLength;){var i=e.getUint8(o,!0);o+=Uint8Array.BYTES_PER_ELEMENT;var a=e.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var u=new DataView(e.buffer,o,a);switch(i){case 1:r.vertexNormals=(n=u,new Uint8Array(n.buffer,n.byteOffset,n.byteLength));break;case 2:r.waterMask=N(u)}o+=a}return{extensions:r,extensionsEndPosition:o}}(n,g).extensions}}function F(e,t){if(!e)return null;var r=t.bounds,n=D(e,k),o=n.header,i=n.vertexData,a=n.triangleIndices,u=function(e,t,r){for(var n=t.minHeight,o=t.maxHeight,i=r||[0,0,1,1],a=S()(i,4),u=a[0],s=a[1],c=a[2]-u,f=a[3]-s,l=o-n,p=e.length/3,d=new Float32Array(3*p),y=new Float32Array(2*p),h=0;h<p;h++){var v=e[h]/32767,E=e[h+p]/32767,g=e[h+2*p]/32767;d[3*h+0]=v*c+u,d[3*h+1]=E*f+s,d[3*h+2]=g*l+n,y[2*h+0]=v,y[2*h+1]=E}return{POSITION:{value:d,size:3},TEXCOORD_0:{value:y,size:2}}}(i,o,r);return{loaderData:{header:{}},header:{vertexCount:a.length,boundingBox:T(u)},mode:4,indices:{value:a,size:1},attributes:u}}function z(e,t){return F(e,t["quantized-mesh"])}function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var q,H,X=G(G({},{name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:"3.0.0-beta.2",worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1]}}}),{},{parseSync:z,parse:(q=a()(s.a.mark((function e(t,r){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",z(t,r));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return q.apply(this,arguments)})});H=X,"undefined"!=typeof self&&(E.onmessage=function(){var e=a()(s.a.mark((function e(t,r){var n,o,i,a;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t,e.next="process"===e.t0?3:15;break;case 3:return e.prev=3,n=r.input,o=r.options,i=void 0===o?{}:o,e.next=7,_({loader:H,arrayBuffer:n,options:i,context:{parse:w}});case 7:a=e.sent,E.postMessage("done",{result:a}),e.next=14;break;case 11:e.prev=11,e.t1=e.catch(3),E.postMessage("error",{error:e.t1.message});case 14:return e.abrupt("break",15);case 15:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t,r){return e.apply(this,arguments)}}())}]); | ||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=14)}([function(e,t,r){e.exports=r(8)},function(e,t){function r(e,t,r,n,o,i,a){try{var u=e[i](a),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(o,i){var a=e.apply(t,n);function u(e){r(a,o,i,u,s,"next",e)}function s(e){r(a,o,i,u,s,"throw",e)}u(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(9),o=r(10),i=r(11),a=r(13);e.exports=function(e,t){return n(e)||o(e,t)||i(e,t)||a()},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},,function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",i=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof l?t:l,i=Object.create(o.prototype),a=new _(n||[]);return i._invoke=function(e,t,r){var n="suspendedStart";return function(o,i){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return P()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var u=b(a,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=c(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,a),i}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f={};function l(){}function p(){}function d(){}var y={};y[o]=function(){return this};var h=Object.getPrototypeOf,v=h&&h(h(O([])));v&&v!==t&&r.call(v,o)&&(y=v);var E=d.prototype=l.prototype=Object.create(y);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var n;this._invoke=function(o,i){function a(){return new t((function(n,a){!function n(o,i,a,u){var s=c(e[o],e,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,a,u)}),(function(e){n("throw",e,a,u)})):t.resolve(l).then((function(e){f.value=e,a(f)}),(function(e){return n("throw",e,a,u)}))}u(s.arg)}(o,i,n,a)}))}return n=n?n.then(a,a):a()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function _(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function O(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,i=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return i.next=i}}return{next:P}}function P(){return{value:void 0,done:!0}}return p.prototype=E.constructor=d,d.constructor=p,p.displayName=u(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,u(e,a,"GeneratorFunction")),e.prototype=Object.create(E),e},e.awrap=function(e){return{__await:e}},g(m.prototype),m.prototype[i]=function(){return this},e.AsyncIterator=m,e.async=function(t,r,n,o,i){void 0===i&&(i=Promise);var a=new m(s(t,r,n,o),i);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},g(E),u(E,a,"Generator"),E[o]=function(){return this},E.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=O,_.prototype={constructor:_,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],a=i.completion;if("root"===i.tryLoc)return n("end");if(i.tryLoc<=this.prev){var u=r.call(i,"catchLoc"),s=r.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===e||"continue"===e)&&i.tryLoc<=t&&t<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=e,a.arg=t,i?(this.method="next",this.next=i.finallyLoc,f):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;w(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:O(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){var r=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=r){var n,o,i=[],a=!0,u=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(i.push(n.value),!t||i.length!==t);a=!0);}catch(e){u=!0,o=e}finally{try{a||null==r.return||r.return()}finally{if(u)throw o}}return i}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.r(t);var n=r(2),o=r.n(n),i=r(1),a=r.n(i),u=r(0),s=r.n(u),c=r(4),f=r.n(c),l=r(5),p=r.n(l),d=r(6),y=r.n(d);function h(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var v=new Map,E=function(){function e(){f()(this,e)}return p()(e,null,[{key:"onmessage",set:function(e){self.onmessage=function(t){if(g(t)){var r=t.data,n=r.type,o=r.payload;e(n,o)}}}},{key:"addEventListener",value:function(e){var t=v.get(e);t||(t=function(t){if(g(t)){var r=t.data,n=r.type,o=r.payload;e(n,o)}}),self.addEventListener("message",t)}},{key:"removeEventListener",value:function(e){var t=v.get(e);v.delete(e),self.removeEventListener("message",t)}},{key:"postMessage",value:function(e,t){if(self){var r={source:"loaders.gl",type:e,payload:t},n=function e(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,o=n||new Set;if(t){if(h(t))o.add(t);else if(h(t.buffer))o.add(t.buffer);else if(ArrayBuffer.isView(t));else if(r&&"object"===y()(t))for(var i in t)e(t[i],r,o)}else;return void 0===n?Array.from(o):[]}(t);self.postMessage(r,n)}}}]),e}();function g(e){var t=e.type,r=e.data;return"message"===t&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var x=0;function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(r,n){var o=x++;E.addEventListener((function e(t,i){if(i.id===o)switch(t){case"done":E.removeEventListener(e),r(i.result);break;case"error":E.removeEventListener(e),n(i.error)}}));var i={id:o,input:e,options:t};E.postMessage("process",i)}))}function _(e){return O.apply(this,arguments)}function O(){return(O=a()(s.a.mark((function e(t){var r,n,o,i,a,u,c;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.loader,n=t.arrayBuffer,o=t.options,i=t.context,!r.parseSync&&!r.parse){e.next=6;break}a=n,u=r.parseSync||r.parse,e.next=13;break;case 6:if(!r.parseTextSync){e.next=12;break}c=new TextDecoder,a=c.decode(n),u=r.parseTextSync,e.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return o=b(b({},o),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),e.next=16,u(a,b({},o),i,r);case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var P=r(3),S=r.n(P);function T(e){for(var t=1/0,r=1/0,n=1/0,o=-1/0,i=-1/0,a=-1/0,u=e.POSITION?e.POSITION.value:[],s=u&&u.length,c=0;c<s;c+=3){var f=u[c],l=u[c+1],p=u[c+2];t=f<t?f:t,r=l<r?l:r,n=p<n?p:n,o=f>o?f:o,i=l>i?l:i,a=p>a?p:a}return[[t,r,n],[o,i,a]]}function L(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!r){if(Array.isArray(e)||(r=function(e,t){if(!e)return;if("string"==typeof e)return M(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return M(e,t)}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0,o=function(){};return{s:o,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,a=!0,u=!1;return{s:function(){r=r.call(e)},n:function(){var e=r.next();return a=e.done,e},e:function(e){u=!0,i=e},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function M(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var j=new Map([["centerX",Float64Array.BYTES_PER_ELEMENT],["centerY",Float64Array.BYTES_PER_ELEMENT],["centerZ",Float64Array.BYTES_PER_ELEMENT],["minHeight",Float32Array.BYTES_PER_ELEMENT],["maxHeight",Float32Array.BYTES_PER_ELEMENT],["boundingSphereCenterX",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterY",Float64Array.BYTES_PER_ELEMENT],["boundingSphereCenterZ",Float64Array.BYTES_PER_ELEMENT],["boundingSphereRadius",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointX",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointY",Float64Array.BYTES_PER_ELEMENT],["horizonOcclusionPointZ",Float64Array.BYTES_PER_ELEMENT]]);function A(e){return e>>1^-(1&e)}function I(e,t,r,n){var o,i=!(arguments.length>4&&void 0!==arguments[4])||arguments[4];if(o=2===n?new Uint16Array(e,t,r):new Uint32Array(e,t,r),!i)return o;for(var a=0,u=0;u<o.length;++u){var s=o[u];o[u]=a-s,0===s&&++a}return o}function N(e){return e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength)}var B=1,k=2,U=3,Y=4,R={maxDecodingStep:Y};function D(e,t){var r=Object.assign({},R,t),n=new DataView(e),o=function(e){var t,r=0,n={},o=L(j);try{for(o.s();!(t=o.n()).done;){var i=S()(t.value,2),a=i[0],u=i[1],s=8===u?e.getFloat64:e.getFloat32;n[a]=s.call(e,r,!0),r+=u}}catch(e){o.e(e)}finally{o.f()}return{header:n,headerEndPosition:r}}(n),i=o.header,a=o.headerEndPosition;if(r.maxDecodingStep<B)return{header:i};var u=function(e,t){var r=t,n=e.getUint32(r,!0),o=new Uint16Array(3*n);r+=Uint32Array.BYTES_PER_ELEMENT;for(var i=Uint16Array.BYTES_PER_ELEMENT,a=n*i,u=r,s=u+a,c=s+a,f=0,l=0,p=0,d=0;d<n;d++)f+=A(e.getUint16(u+i*d,!0)),l+=A(e.getUint16(s+i*d,!0)),p+=A(e.getUint16(c+i*d,!0)),o[d]=f,o[d+n]=l,o[d+2*n]=p;return{vertexData:o,vertexDataEndPosition:r+=3*a}}(n,a),s=u.vertexData,c=u.vertexDataEndPosition;if(r.maxDecodingStep<k)return{header:i,vertexData:s};var f=function(e,t,r){var n=r,o=t.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;n%o!=0&&(n+=o-n%o);var i=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var a=3*i,u=I(e.buffer,n,a,o);return{triangleIndicesEndPosition:n+=a*o,triangleIndices:u}}(n,s,c),l=f.triangleIndices,p=f.triangleIndicesEndPosition;if(r.maxDecodingStep<U)return{header:i,vertexData:s,triangleIndices:l};var d=function(e,t,r){var n=r,o=t.length/3>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,i=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var a=I(e.buffer,n,i,o,!1);n+=i*o;var u=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var s=I(e.buffer,n,u,o,!1);n+=u*o;var c=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var f=I(e.buffer,n,c,o,!1);n+=c*o;var l=e.getUint32(n,!0);n+=Uint32Array.BYTES_PER_ELEMENT;var p=I(e.buffer,n,l,o,!1);return{edgeIndicesEndPosition:n+=l*o,westIndices:a,southIndices:s,eastIndices:f,northIndices:p}}(n,s,p),y=d.westIndices,h=d.southIndices,v=d.eastIndices,E=d.northIndices,g=d.edgeIndicesEndPosition;return r.maxDecodingStep<Y?{header:i,vertexData:s,triangleIndices:l,westIndices:y,northIndices:E,eastIndices:v,southIndices:h}:{header:i,vertexData:s,triangleIndices:l,westIndices:y,northIndices:E,eastIndices:v,southIndices:h,extensions:function(e,t){var r={};if(e.byteLength<=t)return{extensions:r,extensionsEndPosition:t};for(var n,o=t;o<e.byteLength;){var i=e.getUint8(o,!0);o+=Uint8Array.BYTES_PER_ELEMENT;var a=e.getUint32(o,!0);o+=Uint32Array.BYTES_PER_ELEMENT;var u=new DataView(e.buffer,o,a);switch(i){case 1:r.vertexNormals=(n=u,new Uint8Array(n.buffer,n.byteOffset,n.byteLength));break;case 2:r.waterMask=N(u)}o+=a}return{extensions:r,extensionsEndPosition:o}}(n,g).extensions}}function F(e,t){if(!e)return null;var r=t.bounds,n=D(e,k),o=n.header,i=n.vertexData,a=n.triangleIndices,u=function(e,t,r){for(var n=t.minHeight,o=t.maxHeight,i=r||[0,0,1,1],a=S()(i,4),u=a[0],s=a[1],c=a[2]-u,f=a[3]-s,l=o-n,p=e.length/3,d=new Float32Array(3*p),y=new Float32Array(2*p),h=0;h<p;h++){var v=e[h]/32767,E=e[h+p]/32767,g=e[h+2*p]/32767;d[3*h+0]=v*c+u,d[3*h+1]=E*f+s,d[3*h+2]=g*l+n,y[2*h+0]=v,y[2*h+1]=E}return{POSITION:{value:d,size:3},TEXCOORD_0:{value:y,size:2}}}(i,o,r);return{loaderData:{header:{}},header:{vertexCount:a.length,boundingBox:T(u)},mode:4,indices:{value:a,size:1},attributes:u}}function z(e,t){return F(e,t["quantized-mesh"])}function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function G(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var q,H,X=G(G({},{name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:"3.0.0-beta.3",worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1]}}}),{},{parseSync:z,parse:(q=a()(s.a.mark((function e(t,r){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",z(t,r));case 1:case"end":return e.stop()}}),e)}))),function(e,t){return q.apply(this,arguments)})});H=X,"undefined"!=typeof self&&(E.onmessage=function(){var e=a()(s.a.mark((function e(t,r){var n,o,i,a,u;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t,e.next="process"===e.t0?3:16;break;case 3:return e.prev=3,n=r.input,o=r.options,i=void 0===o?{}:o,e.next=7,_({loader:H,arrayBuffer:n,options:i,context:{parse:w}});case 7:a=e.sent,E.postMessage("done",{result:a}),e.next=15;break;case 11:e.prev=11,e.t1=e.catch(3),u=e.t1 instanceof Error?e.t1.message:"",E.postMessage("error",{error:u});case 15:return e.abrupt("break",16);case 16:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t,r){return e.apply(this,arguments)}}())}]); | ||
//# sourceMappingURL=quantized-mesh-worker.js.map |
@@ -1,2 +0,2 @@ | ||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=14)}([function(e,t,r){e.exports=r(8)},function(e,t){function r(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(9),i=r(10),o=r(11),a=r(13);e.exports=function(e,t){return n(e)||i(e,t)||o(e,t)||a()},e.exports.default=e.exports,e.exports.__esModule=!0},,function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof h?t:h,o=Object.create(i.prototype),a=new O(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return S()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function h(){}function f(){}function d(){}var p={};p[i]=function(){return this};var g=Object.getPrototypeOf,v=g&&g(g(k([])));v&&v!==t&&r.call(v,i)&&(p=v);var y=d.prototype=h.prototype=Object.create(p);function _(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(h).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function k(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:S}}function S(){return{value:void 0,done:!0}}return f.prototype=y.constructor=d,d.constructor=f,f.displayName=s(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},_(m.prototype),m.prototype[o]=function(){return this},e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(y),s(y,a,"Generator"),y[i]=function(){return this},y.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=k,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){var r=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.r(t);var n=r(2),i=r.n(n),o=r(1),a=r.n(o),s=r(0),u=r.n(s),c=r(3),l=r.n(c),h=r(4),f=r.n(h),d=r(5),p=r.n(d);function g(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var v=new Map,y=function(){function e(){l()(this,e)}return f()(e,null,[{key:"onmessage",set:function(e){self.onmessage=function(t){if(_(t)){var r=t.data,n=r.type,i=r.payload;e(n,i)}}}},{key:"addEventListener",value:function(e){var t=v.get(e);t||(t=function(t){if(_(t)){var r=t.data,n=r.type,i=r.payload;e(n,i)}}),self.addEventListener("message",t)}},{key:"removeEventListener",value:function(e){var t=v.get(e);v.delete(e),self.removeEventListener("message",t)}},{key:"postMessage",value:function(e,t){if(self){var r={source:"loaders.gl",type:e,payload:t},n=function e(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,i=n||new Set;if(t){if(g(t))i.add(t);else if(g(t.buffer))i.add(t.buffer);else if(ArrayBuffer.isView(t));else if(r&&"object"===p()(t))for(var o in t)e(t[o],r,i)}else;return void 0===n?Array.from(i):[]}(t);self.postMessage(r,n)}}}]),e}();function _(e){var t=e.type,r=e.data;return"message"===t&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){i()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var x=0;function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(r,n){var i=x++;y.addEventListener((function e(t,o){if(o.id===i)switch(t){case"done":y.removeEventListener(e),r(o.result);break;case"error":y.removeEventListener(e),n(o.error)}}));var o={id:i,input:e,options:t};y.postMessage("process",o)}))}function O(e){return k.apply(this,arguments)}function k(){return(k=a()(u.a.mark((function e(t){var r,n,i,o,a,s,c;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.loader,n=t.arrayBuffer,i=t.options,o=t.context,!r.parseSync&&!r.parse){e.next=6;break}a=n,s=r.parseSync||r.parse,e.next=13;break;case 6:if(!r.parseTextSync){e.next=12;break}c=new TextDecoder,a=c.decode(n),s=r.parseTextSync,e.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return i=b(b({},i),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),e.next=16,s(a,b({},i),o,r);case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var S=r(6),M=r.n(S);function P(e){for(var t=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=e.POSITION?e.POSITION.value:[],u=s&&s.length,c=0;c<u;c+=3){var l=s[c],h=s[c+1],f=s[c+2];t=l<t?l:t,r=h<r?h:r,n=f<n?f:n,i=l>i?l:i,o=h>o?h:o,a=f>a?f:a}return[[t,r,n],[i,o,a]]}class j{constructor(e=257){this.gridSize=e;const t=e-1;if(t&t-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=t*t*2-2,this.numParentTriangles=this.numTriangles-t*t,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let e=0;e<this.numTriangles;e++){let r=e+2,n=0,i=0,o=0,a=0,s=0,u=0;for(1&r?o=a=s=t:n=i=u=t;(r>>=1)>1;){const e=n+o>>1,t=i+a>>1;1&r?(o=n,a=i,n=s,i=u):(n=o,i=a,o=s,a=u),s=e,u=t}const c=4*e;this.coords[c+0]=n,this.coords[c+1]=i,this.coords[c+2]=o,this.coords[c+3]=a}}createTile(e){return new E(e,this)}}class E{constructor(e,t){const r=t.gridSize;if(e.length!==r*r)throw new Error(`Expected terrain data of length ${r*r} (${r} x ${r}), got ${e.length}.`);this.terrain=e,this.martini=t,this.errors=new Float32Array(e.length),this.update()}update(){const{numTriangles:e,numParentTriangles:t,coords:r,gridSize:n}=this.martini,{terrain:i,errors:o}=this;for(let a=e-1;a>=0;a--){const e=4*a,s=r[e+0],u=r[e+1],c=r[e+2],l=r[e+3],h=s+c>>1,f=u+l>>1,d=h+f-u,p=f+s-h,g=(i[u*n+s]+i[l*n+c])/2,v=f*n+h,y=Math.abs(g-i[v]);if(o[v]=Math.max(o[v],y),a<t){const e=(u+p>>1)*n+(s+d>>1),t=(l+p>>1)*n+(c+d>>1);o[v]=Math.max(o[v],o[e],o[t])}}}getMesh(e=0){const{gridSize:t,indices:r}=this.martini,{errors:n}=this;let i=0,o=0;const a=t-1;function s(a,u,c,l,h,f){const d=a+c>>1,p=u+l>>1;Math.abs(a-h)+Math.abs(u-f)>1&&n[p*t+d]>e?(s(h,f,a,u,d,p),s(c,l,h,f,d,p)):(r[u*t+a]=r[u*t+a]||++i,r[l*t+c]=r[l*t+c]||++i,r[f*t+h]=r[f*t+h]||++i,o++)}r.fill(0),s(0,0,a,a,a,0),s(a,a,0,0,0,a);const u=new Uint16Array(2*i),c=new Uint32Array(3*o);let l=0;function h(i,o,a,s,f,d){const p=i+a>>1,g=o+s>>1;if(Math.abs(i-f)+Math.abs(o-d)>1&&n[g*t+p]>e)h(f,d,i,o,p,g),h(a,s,f,d,p,g);else{const e=r[o*t+i]-1,n=r[s*t+a]-1,h=r[d*t+f]-1;u[2*e]=i,u[2*e+1]=o,u[2*n]=a,u[2*n+1]=s,u[2*h]=f,u[2*h+1]=d,c[l++]=e,c[l++]=n,c[l++]=h}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:u,triangles:c}}}var q=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;l()(this,e),this.data=t,this.width=r,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;var i=r-1,o=n-1,a=this._addPoint(0,0),s=this._addPoint(i,0),u=this._addPoint(0,o),c=this._addPoint(i,o),h=this._addTriangle(c,a,u,-1,-1,-1);this._addTriangle(a,c,s,h,-1,-1),this._flush()}return f()(e,[{key:"run",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.getMaxError()>e;)this.refine()}},{key:"refine",value:function(){this._step(),this._flush()}},{key:"getMaxError",value:function(){return this._errors[0]}},{key:"getRMSD",value:function(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}},{key:"heightAt",value:function(e,t){return this.data[this.width*t+e]}},{key:"_flush",value:function(){for(var e=this.coords,t=0;t<this._pendingLen;t++){var r=this._pending[t],n=2*this.triangles[3*r+0],i=2*this.triangles[3*r+1],o=2*this.triangles[3*r+2];this._findCandidate(e[n],e[n+1],e[i],e[i+1],e[o],e[o+1],r)}this._pendingLen=0}},{key:"_findCandidate",value:function(e,t,r,n,i,o,a){for(var s=Math.min(e,r,i),u=Math.min(t,n,o),c=Math.max(e,r,i),l=Math.max(t,n,o),h=L(r,n,i,o,s,u),f=L(i,o,e,t,s,u),d=L(e,t,r,n,s,u),p=n-t,g=e-r,v=o-n,y=r-i,_=t-o,m=i-e,b=L(e,t,r,n,i,o),x=this.heightAt(e,t)/b,w=this.heightAt(r,n)/b,O=this.heightAt(i,o)/b,k=0,S=0,M=0,P=0,j=u;j<=l;j++){var E=0;h<0&&0!==v&&(E=Math.max(E,Math.floor(-h/v))),f<0&&0!==_&&(E=Math.max(E,Math.floor(-f/_))),d<0&&0!==p&&(E=Math.max(E,Math.floor(-d/p)));for(var q=h+v*E,T=f+_*E,A=d+p*E,z=!1,I=s+E;I<=c;I++){if(q>=0&&T>=0&&A>=0){z=!0;var D=x*q+w*T+O*A,C=Math.abs(D-this.heightAt(I,j));P+=C*C,C>k&&(k=C,S=I,M=j)}else if(z)break;q+=v,T+=_,A+=p}h+=y,f+=m,d+=g}(S===e&&M===t||S===r&&M===n||S===i&&M===o)&&(k=0),this._candidates[2*a]=S,this._candidates[2*a+1]=M,this._rms[a]=P,this._queuePush(a,k,P)}},{key:"_step",value:function(){var e=this._queuePop(),t=3*e+0,r=3*e+1,n=3*e+2,i=this.triangles[t],o=this.triangles[r],a=this.triangles[n],s=this.coords[2*i],u=this.coords[2*i+1],c=this.coords[2*o],l=this.coords[2*o+1],h=this.coords[2*a],f=this.coords[2*a+1],d=this._candidates[2*e],p=this._candidates[2*e+1],g=this._addPoint(d,p);if(0===L(s,u,c,l,d,p))this._handleCollinear(g,t);else if(0===L(c,l,h,f,d,p))this._handleCollinear(g,r);else if(0===L(h,f,s,u,d,p))this._handleCollinear(g,n);else{var v=this._halfedges[t],y=this._halfedges[r],_=this._halfedges[n],m=this._addTriangle(i,o,g,v,-1,-1,t),b=this._addTriangle(o,a,g,y,-1,m+1),x=this._addTriangle(a,i,g,_,m+2,b+1);this._legalize(m),this._legalize(b),this._legalize(x)}}},{key:"_addPoint",value:function(e,t){var r=this.coords.length>>1;return this.coords.push(e,t),r}},{key:"_addTriangle",value:function(e,t,r,n,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this.triangles.length,s=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=t,this.triangles[a+2]=r,this._halfedges[a+0]=n,this._halfedges[a+1]=i,this._halfedges[a+2]=o,n>=0&&(this._halfedges[n]=a+0),i>=0&&(this._halfedges[i]=a+1),o>=0&&(this._halfedges[o]=a+2),this._candidates[2*s+0]=0,this._candidates[2*s+1]=0,this._queueIndices[s]=-1,this._rms[s]=0,this._pending[this._pendingLen++]=s,a}},{key:"_legalize",value:function(e){var t=this._halfedges[e];if(!(t<0)){var r=e-e%3,n=t-t%3,i=r+(e+1)%3,o=r+(e+2)%3,a=n+(t+2)%3,s=n+(t+1)%3,u=this.triangles[o],c=this.triangles[e],l=this.triangles[i],h=this.triangles[a],f=this.coords;if(d=f[2*u],p=f[2*u+1],g=f[2*c],v=f[2*c+1],y=f[2*l],_=f[2*l+1],m=f[2*h],b=f[2*h+1],(x=d-m)*((k=v-b)*(j=(S=y-m)*S+(M=_-b)*M)-(P=(O=g-m)*O+k*k)*M)-(w=p-b)*(O*j-P*S)+(x*x+w*w)*(O*M-k*S)<0){var d,p,g,v,y,_,m,b,x,w,O,k,S,M,P,j,E=this._halfedges[i],q=this._halfedges[o],L=this._halfedges[a],T=this._halfedges[s];this._queueRemove(r/3),this._queueRemove(n/3);var A=this._addTriangle(u,h,l,-1,L,E,r),z=this._addTriangle(h,u,c,A,q,T,n);this._legalize(A+1),this._legalize(z+2)}}}},{key:"_handleCollinear",value:function(e,t){var r=t-t%3,n=r+(t+1)%3,i=r+(t+2)%3,o=this.triangles[i],a=this.triangles[t],s=this.triangles[n],u=this._halfedges[n],c=this._halfedges[i],l=this._halfedges[t];if(l<0){var h=this._addTriangle(e,o,a,-1,c,-1,r),f=this._addTriangle(o,e,s,h,-1,u);return this._legalize(h+1),void this._legalize(f+2)}var d=l-l%3,p=d+(l+2)%3,g=d+(l+1)%3,v=this.triangles[p],y=this._halfedges[p],_=this._halfedges[g];this._queueRemove(d/3);var m=this._addTriangle(o,a,e,c,-1,-1,r),b=this._addTriangle(a,v,e,_,-1,m+1,d),x=this._addTriangle(v,s,e,y,-1,b+1),w=this._addTriangle(s,o,e,u,m+2,x+1);this._legalize(m),this._legalize(b),this._legalize(x),this._legalize(w)}},{key:"_queuePush",value:function(e,t,r){var n=this._queue.length;this._queueIndices[e]=n,this._queue.push(e),this._errors.push(t),this._rmsSum+=r,this._queueUp(n)}},{key:"_queuePop",value:function(){var e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}},{key:"_queuePopBack",value:function(){var e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}},{key:"_queueRemove",value:function(e){var t=this._queueIndices[e];if(t<0){var r=this._pending.indexOf(e);if(-1===r)throw new Error("Broken triangulation (something went wrong).");this._pending[r]=this._pending[--this._pendingLen]}else{var n=this._queue.length-1;n!==t&&(this._queueSwap(t,n),this._queueDown(t,n)||this._queueUp(t)),this._queuePopBack()}}},{key:"_queueLess",value:function(e,t){return this._errors[e]>this._errors[t]}},{key:"_queueSwap",value:function(e,t){var r=this._queue[e],n=this._queue[t];this._queue[e]=n,this._queue[t]=r,this._queueIndices[r]=t,this._queueIndices[n]=e;var i=this._errors[e];this._errors[e]=this._errors[t],this._errors[t]=i}},{key:"_queueUp",value:function(e){for(var t=e;;){var r=t-1>>1;if(r===t||!this._queueLess(t,r))break;this._queueSwap(r,t),t=r}}},{key:"_queueDown",value:function(e,t){for(var r=e;;){var n=2*r+1;if(n>=t||n<0)break;var i=n+1,o=n;if(i<t&&this._queueLess(i,n)&&(o=i),!this._queueLess(o,r))break;this._queueSwap(r,o),r=o}return r>e}}]),e}();function L(e,t,r,n,i,o){return(r-i)*(t-o)-(n-o)*(e-i)}function T(e,t,r,n,i){for(var o=n.rScaler,a=n.bScaler,s=n.gScaler,u=n.offset,c=new Float32Array((t+1)*(r+1)),l=0,h=0;h<r;h++)for(var f=0;f<t;f++,l++){var d=4*l,p=e[d+0],g=e[d+1],v=e[d+2];c[l+h]=p*o+g*s+v*a+u}if("martini"===i){for(var y=(t+1)*t,_=0;_<t;_++,y++)c[y]=c[y-t-1];for(var m=r,b=0;b<r+1;b++,m+=r+1)c[m]=c[m-1]}return c}function A(e,t){if(null===e)return null;var r,n,i=t.meshMaxError,o=t.bounds,a=t.elevationDecoder,s=e.data,u=e.width,c=e.height;switch(t.tesselator){case"martini":n=z(i,u,r=T(s,u,c,a,t.tesselator));break;case"delatin":n=I(i,u,c,r=T(s,u,c,a,t.tesselator));break;default:n=u!==c||c&u-1?I(i,u,c,r=T(s,u,c,a,"delatin")):z(i,u,r=T(s,u,c,a,"martini"))}var l=n,h=l.vertices,f=l.triangles,d=function(e,t,r,n,i){for(var o=r+1,a=e.length/2,s=new Float32Array(3*a),u=new Float32Array(2*a),c=i||[0,0,r,n],l=M()(c,4),h=l[0],f=l[1],d=l[2],p=l[3],g=(d-h)/r,v=(p-f)/n,y=0;y<a;y++){var _=e[2*y],m=e[2*y+1],b=m*o+_;s[3*y+0]=_*g+h,s[3*y+1]=-m*v+p,s[3*y+2]=t[b],u[2*y+0]=_/r,u[2*y+1]=m/n}return{POSITION:{value:s,size:3},TEXCOORD_0:{value:u,size:2}}}(h,r,u,c,o);return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:P(d)},mode:4,indices:{value:Uint32Array.from(f),size:1},attributes:d}}function z(e,t,r){var n=new j(t+1).createTile(r).getMesh(e);return{vertices:n.vertices,triangles:n.triangles}}function I(e,t,r,n){var i=new q(n,t+1,r+1);return i.run(e),{vertices:i.coords,triangles:i.triangles}}function D(){return(D=a()(u.a.mark((function e(t,r,n){var i;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.image=r.image||{},r.image.type="data",e.next=4,n.parse(t,r,r.baseUri);case 4:return i=e.sent,e.abrupt("return",A(i,r.terrain));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach((function(t){i()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var N,F=B(B({},{name:"Terrain",id:"terrain",module:"terrain",version:"3.0.0-beta.2",worker:!0,extensions:["png","pngraw"],mimeTypes:["image/png"],options:{terrain:{tesselator:"auto",bounds:null,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0}}}}),{},{parse:function(e,t,r){return D.apply(this,arguments)}});N=F,"undefined"!=typeof self&&(y.onmessage=function(){var e=a()(u.a.mark((function e(t,r){var n,i,o,a;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t,e.next="process"===e.t0?3:15;break;case 3:return e.prev=3,n=r.input,i=r.options,o=void 0===i?{}:i,e.next=7,O({loader:N,arrayBuffer:n,options:o,context:{parse:w}});case 7:a=e.sent,y.postMessage("done",{result:a}),e.next=14;break;case 11:e.prev=11,e.t1=e.catch(3),y.postMessage("error",{error:e.t1.message});case 14:return e.abrupt("break",15);case 15:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t,r){return e.apply(this,arguments)}}())}]); | ||
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var i=t[n]={i:n,l:!1,exports:{}};return e[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)r.d(n,i,function(t){return e[t]}.bind(null,i));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=14)}([function(e,t,r){e.exports=r(8)},function(e,t){function r(e,t,r,n,i,o,a){try{var s=e[o](a),u=s.value}catch(e){return void r(e)}s.done?t(u):Promise.resolve(u).then(n,i)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(i,o){var a=e.apply(t,n);function s(e){r(a,i,o,s,u,"next",e)}function u(e){r(a,i,o,s,u,"throw",e)}s(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(9),i=r(10),o=r(11),a=r(13);e.exports=function(e,t){return n(e)||i(e,t)||o(e,t)||a()},e.exports.default=e.exports,e.exports.__esModule=!0},,function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},i=n.iterator||"@@iterator",o=n.asyncIterator||"@@asyncIterator",a=n.toStringTag||"@@toStringTag";function s(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{s({},"")}catch(e){s=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var i=t&&t.prototype instanceof h?t:h,o=Object.create(i.prototype),a=new O(n||[]);return o._invoke=function(e,t,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return S()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=b(a,r);if(s){if(s===l)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=c(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===l)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var l={};function h(){}function f(){}function d(){}var p={};p[i]=function(){return this};var g=Object.getPrototypeOf,v=g&&g(g(k([])));v&&v!==t&&r.call(v,i)&&(p=v);var y=d.prototype=h.prototype=Object.create(p);function _(e){["next","throw","return"].forEach((function(t){s(e,t,(function(e){return this._invoke(t,e)}))}))}function m(e,t){var n;this._invoke=function(i,o){function a(){return new t((function(n,a){!function n(i,o,a,s){var u=c(e[i],e,o);if("throw"!==u.type){var l=u.arg,h=l.value;return h&&"object"==typeof h&&r.call(h,"__await")?t.resolve(h.__await).then((function(e){n("next",e,a,s)}),(function(e){n("throw",e,a,s)})):t.resolve(h).then((function(e){l.value=e,a(l)}),(function(e){return n("throw",e,a,s)}))}s(u.arg)}(i,o,n,a)}))}return n=n?n.then(a,a):a()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return l;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return l}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,l;var i=n.arg;return i?i.done?(t[e.resultName]=i.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,l):i:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,l)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function w(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function k(e){if(e){var t=e[i];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,o=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return o.next=o}}return{next:S}}function S(){return{value:void 0,done:!0}}return f.prototype=y.constructor=d,d.constructor=f,f.displayName=s(d,a,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===f||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,d):(e.__proto__=d,s(e,a,"GeneratorFunction")),e.prototype=Object.create(y),e},e.awrap=function(e){return{__await:e}},_(m.prototype),m.prototype[o]=function(){return this},e.AsyncIterator=m,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new m(u(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(e){return e.done?e.value:a.next()}))},_(y),s(y,a,"Generator"),y[i]=function(){return this},y.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=k,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(w),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var i=this.tryEntries.length-1;i>=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev<o.catchLoc)return n(o.catchLoc,!0);if(this.prev<o.finallyLoc)return n(o.finallyLoc)}else if(s){if(this.prev<o.catchLoc)return n(o.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return n(o.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=t&&t<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=t,o?(this.method="next",this.next=o.finallyLoc,l):this.complete(a)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),l},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),w(r),l}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var i=n.arg;w(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),l}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t){e.exports=function(e){if(Array.isArray(e))return e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){var r=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null!=r){var n,i,o=[],a=!0,s=!1;try{for(r=r.call(e);!(a=(n=r.next()).done)&&(o.push(n.value),!t||o.length!==t);a=!0);}catch(e){s=!0,i=e}finally{try{a||null==r.return||r.return()}finally{if(s)throw i}}return o}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(12);e.exports=function(e,t){if(e){if("string"==typeof e)return n(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(e,t):void 0}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.r(t);var n=r(2),i=r.n(n),o=r(1),a=r.n(o),s=r(0),u=r.n(s),c=r(3),l=r.n(c),h=r(4),f=r.n(h),d=r(5),p=r.n(d);function g(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var v=new Map,y=function(){function e(){l()(this,e)}return f()(e,null,[{key:"onmessage",set:function(e){self.onmessage=function(t){if(_(t)){var r=t.data,n=r.type,i=r.payload;e(n,i)}}}},{key:"addEventListener",value:function(e){var t=v.get(e);t||(t=function(t){if(_(t)){var r=t.data,n=r.type,i=r.payload;e(n,i)}}),self.addEventListener("message",t)}},{key:"removeEventListener",value:function(e){var t=v.get(e);v.delete(e),self.removeEventListener("message",t)}},{key:"postMessage",value:function(e,t){if(self){var r={source:"loaders.gl",type:e,payload:t},n=function e(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,i=n||new Set;if(t){if(g(t))i.add(t);else if(g(t.buffer))i.add(t.buffer);else if(ArrayBuffer.isView(t));else if(r&&"object"===p()(t))for(var o in t)e(t[o],r,i)}else;return void 0===n?Array.from(i):[]}(t);self.postMessage(r,n)}}}]),e}();function _(e){var t=e.type,r=e.data;return"message"===t&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function m(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?m(Object(r),!0).forEach((function(t){i()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):m(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var x=0;function w(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};return new Promise((function(r,n){var i=x++;y.addEventListener((function e(t,o){if(o.id===i)switch(t){case"done":y.removeEventListener(e),r(o.result);break;case"error":y.removeEventListener(e),n(o.error)}}));var o={id:i,input:e,options:t};y.postMessage("process",o)}))}function O(e){return k.apply(this,arguments)}function k(){return(k=a()(u.a.mark((function e(t){var r,n,i,o,a,s,c;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.loader,n=t.arrayBuffer,i=t.options,o=t.context,!r.parseSync&&!r.parse){e.next=6;break}a=n,s=r.parseSync||r.parse,e.next=13;break;case 6:if(!r.parseTextSync){e.next=12;break}c=new TextDecoder,a=c.decode(n),s=r.parseTextSync,e.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return i=b(b({},i),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),e.next=16,s(a,b({},i),o,r);case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var S=r(6),M=r.n(S);function P(e){for(var t=1/0,r=1/0,n=1/0,i=-1/0,o=-1/0,a=-1/0,s=e.POSITION?e.POSITION.value:[],u=s&&s.length,c=0;c<u;c+=3){var l=s[c],h=s[c+1],f=s[c+2];t=l<t?l:t,r=h<r?h:r,n=f<n?f:n,i=l>i?l:i,o=h>o?h:o,a=f>a?f:a}return[[t,r,n],[i,o,a]]}class E{constructor(e=257){this.gridSize=e;const t=e-1;if(t&t-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=t*t*2-2,this.numParentTriangles=this.numTriangles-t*t,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let e=0;e<this.numTriangles;e++){let r=e+2,n=0,i=0,o=0,a=0,s=0,u=0;for(1&r?o=a=s=t:n=i=u=t;(r>>=1)>1;){const e=n+o>>1,t=i+a>>1;1&r?(o=n,a=i,n=s,i=u):(n=o,i=a,o=s,a=u),s=e,u=t}const c=4*e;this.coords[c+0]=n,this.coords[c+1]=i,this.coords[c+2]=o,this.coords[c+3]=a}}createTile(e){return new j(e,this)}}class j{constructor(e,t){const r=t.gridSize;if(e.length!==r*r)throw new Error(`Expected terrain data of length ${r*r} (${r} x ${r}), got ${e.length}.`);this.terrain=e,this.martini=t,this.errors=new Float32Array(e.length),this.update()}update(){const{numTriangles:e,numParentTriangles:t,coords:r,gridSize:n}=this.martini,{terrain:i,errors:o}=this;for(let a=e-1;a>=0;a--){const e=4*a,s=r[e+0],u=r[e+1],c=r[e+2],l=r[e+3],h=s+c>>1,f=u+l>>1,d=h+f-u,p=f+s-h,g=(i[u*n+s]+i[l*n+c])/2,v=f*n+h,y=Math.abs(g-i[v]);if(o[v]=Math.max(o[v],y),a<t){const e=(u+p>>1)*n+(s+d>>1),t=(l+p>>1)*n+(c+d>>1);o[v]=Math.max(o[v],o[e],o[t])}}}getMesh(e=0){const{gridSize:t,indices:r}=this.martini,{errors:n}=this;let i=0,o=0;const a=t-1;function s(a,u,c,l,h,f){const d=a+c>>1,p=u+l>>1;Math.abs(a-h)+Math.abs(u-f)>1&&n[p*t+d]>e?(s(h,f,a,u,d,p),s(c,l,h,f,d,p)):(r[u*t+a]=r[u*t+a]||++i,r[l*t+c]=r[l*t+c]||++i,r[f*t+h]=r[f*t+h]||++i,o++)}r.fill(0),s(0,0,a,a,a,0),s(a,a,0,0,0,a);const u=new Uint16Array(2*i),c=new Uint32Array(3*o);let l=0;function h(i,o,a,s,f,d){const p=i+a>>1,g=o+s>>1;if(Math.abs(i-f)+Math.abs(o-d)>1&&n[g*t+p]>e)h(f,d,i,o,p,g),h(a,s,f,d,p,g);else{const e=r[o*t+i]-1,n=r[s*t+a]-1,h=r[d*t+f]-1;u[2*e]=i,u[2*e+1]=o,u[2*n]=a,u[2*n+1]=s,u[2*h]=f,u[2*h+1]=d,c[l++]=e,c[l++]=n,c[l++]=h}}return h(0,0,a,a,a,0),h(a,a,0,0,0,a),{vertices:u,triangles:c}}}var q=function(){function e(t,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:r;l()(this,e),this.data=t,this.width=r,this.height=n,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;var i=r-1,o=n-1,a=this._addPoint(0,0),s=this._addPoint(i,0),u=this._addPoint(0,o),c=this._addPoint(i,o),h=this._addTriangle(c,a,u,-1,-1,-1);this._addTriangle(a,c,s,h,-1,-1),this._flush()}return f()(e,[{key:"run",value:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;this.getMaxError()>e;)this.refine()}},{key:"refine",value:function(){this._step(),this._flush()}},{key:"getMaxError",value:function(){return this._errors[0]}},{key:"getRMSD",value:function(){return this._rmsSum>0?Math.sqrt(this._rmsSum/(this.width*this.height)):0}},{key:"heightAt",value:function(e,t){return this.data[this.width*t+e]}},{key:"_flush",value:function(){for(var e=this.coords,t=0;t<this._pendingLen;t++){var r=this._pending[t],n=2*this.triangles[3*r+0],i=2*this.triangles[3*r+1],o=2*this.triangles[3*r+2];this._findCandidate(e[n],e[n+1],e[i],e[i+1],e[o],e[o+1],r)}this._pendingLen=0}},{key:"_findCandidate",value:function(e,t,r,n,i,o,a){for(var s=Math.min(e,r,i),u=Math.min(t,n,o),c=Math.max(e,r,i),l=Math.max(t,n,o),h=L(r,n,i,o,s,u),f=L(i,o,e,t,s,u),d=L(e,t,r,n,s,u),p=n-t,g=e-r,v=o-n,y=r-i,_=t-o,m=i-e,b=L(e,t,r,n,i,o),x=this.heightAt(e,t)/b,w=this.heightAt(r,n)/b,O=this.heightAt(i,o)/b,k=0,S=0,M=0,P=0,E=u;E<=l;E++){var j=0;h<0&&0!==v&&(j=Math.max(j,Math.floor(-h/v))),f<0&&0!==_&&(j=Math.max(j,Math.floor(-f/_))),d<0&&0!==p&&(j=Math.max(j,Math.floor(-d/p)));for(var q=h+v*j,T=f+_*j,A=d+p*j,z=!1,I=s+j;I<=c;I++){if(q>=0&&T>=0&&A>=0){z=!0;var D=x*q+w*T+O*A,C=Math.abs(D-this.heightAt(I,E));P+=C*C,C>k&&(k=C,S=I,M=E)}else if(z)break;q+=v,T+=_,A+=p}h+=y,f+=m,d+=g}(S===e&&M===t||S===r&&M===n||S===i&&M===o)&&(k=0),this._candidates[2*a]=S,this._candidates[2*a+1]=M,this._rms[a]=P,this._queuePush(a,k,P)}},{key:"_step",value:function(){var e=this._queuePop(),t=3*e+0,r=3*e+1,n=3*e+2,i=this.triangles[t],o=this.triangles[r],a=this.triangles[n],s=this.coords[2*i],u=this.coords[2*i+1],c=this.coords[2*o],l=this.coords[2*o+1],h=this.coords[2*a],f=this.coords[2*a+1],d=this._candidates[2*e],p=this._candidates[2*e+1],g=this._addPoint(d,p);if(0===L(s,u,c,l,d,p))this._handleCollinear(g,t);else if(0===L(c,l,h,f,d,p))this._handleCollinear(g,r);else if(0===L(h,f,s,u,d,p))this._handleCollinear(g,n);else{var v=this._halfedges[t],y=this._halfedges[r],_=this._halfedges[n],m=this._addTriangle(i,o,g,v,-1,-1,t),b=this._addTriangle(o,a,g,y,-1,m+1),x=this._addTriangle(a,i,g,_,m+2,b+1);this._legalize(m),this._legalize(b),this._legalize(x)}}},{key:"_addPoint",value:function(e,t){var r=this.coords.length>>1;return this.coords.push(e,t),r}},{key:"_addTriangle",value:function(e,t,r,n,i,o){var a=arguments.length>6&&void 0!==arguments[6]?arguments[6]:this.triangles.length,s=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=t,this.triangles[a+2]=r,this._halfedges[a+0]=n,this._halfedges[a+1]=i,this._halfedges[a+2]=o,n>=0&&(this._halfedges[n]=a+0),i>=0&&(this._halfedges[i]=a+1),o>=0&&(this._halfedges[o]=a+2),this._candidates[2*s+0]=0,this._candidates[2*s+1]=0,this._queueIndices[s]=-1,this._rms[s]=0,this._pending[this._pendingLen++]=s,a}},{key:"_legalize",value:function(e){var t=this._halfedges[e];if(!(t<0)){var r=e-e%3,n=t-t%3,i=r+(e+1)%3,o=r+(e+2)%3,a=n+(t+2)%3,s=n+(t+1)%3,u=this.triangles[o],c=this.triangles[e],l=this.triangles[i],h=this.triangles[a],f=this.coords;if(d=f[2*u],p=f[2*u+1],g=f[2*c],v=f[2*c+1],y=f[2*l],_=f[2*l+1],m=f[2*h],b=f[2*h+1],(x=d-m)*((k=v-b)*(E=(S=y-m)*S+(M=_-b)*M)-(P=(O=g-m)*O+k*k)*M)-(w=p-b)*(O*E-P*S)+(x*x+w*w)*(O*M-k*S)<0){var d,p,g,v,y,_,m,b,x,w,O,k,S,M,P,E,j=this._halfedges[i],q=this._halfedges[o],L=this._halfedges[a],T=this._halfedges[s];this._queueRemove(r/3),this._queueRemove(n/3);var A=this._addTriangle(u,h,l,-1,L,j,r),z=this._addTriangle(h,u,c,A,q,T,n);this._legalize(A+1),this._legalize(z+2)}}}},{key:"_handleCollinear",value:function(e,t){var r=t-t%3,n=r+(t+1)%3,i=r+(t+2)%3,o=this.triangles[i],a=this.triangles[t],s=this.triangles[n],u=this._halfedges[n],c=this._halfedges[i],l=this._halfedges[t];if(l<0){var h=this._addTriangle(e,o,a,-1,c,-1,r),f=this._addTriangle(o,e,s,h,-1,u);return this._legalize(h+1),void this._legalize(f+2)}var d=l-l%3,p=d+(l+2)%3,g=d+(l+1)%3,v=this.triangles[p],y=this._halfedges[p],_=this._halfedges[g];this._queueRemove(d/3);var m=this._addTriangle(o,a,e,c,-1,-1,r),b=this._addTriangle(a,v,e,_,-1,m+1,d),x=this._addTriangle(v,s,e,y,-1,b+1),w=this._addTriangle(s,o,e,u,m+2,x+1);this._legalize(m),this._legalize(b),this._legalize(x),this._legalize(w)}},{key:"_queuePush",value:function(e,t,r){var n=this._queue.length;this._queueIndices[e]=n,this._queue.push(e),this._errors.push(t),this._rmsSum+=r,this._queueUp(n)}},{key:"_queuePop",value:function(){var e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}},{key:"_queuePopBack",value:function(){var e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}},{key:"_queueRemove",value:function(e){var t=this._queueIndices[e];if(t<0){var r=this._pending.indexOf(e);if(-1===r)throw new Error("Broken triangulation (something went wrong).");this._pending[r]=this._pending[--this._pendingLen]}else{var n=this._queue.length-1;n!==t&&(this._queueSwap(t,n),this._queueDown(t,n)||this._queueUp(t)),this._queuePopBack()}}},{key:"_queueLess",value:function(e,t){return this._errors[e]>this._errors[t]}},{key:"_queueSwap",value:function(e,t){var r=this._queue[e],n=this._queue[t];this._queue[e]=n,this._queue[t]=r,this._queueIndices[r]=t,this._queueIndices[n]=e;var i=this._errors[e];this._errors[e]=this._errors[t],this._errors[t]=i}},{key:"_queueUp",value:function(e){for(var t=e;;){var r=t-1>>1;if(r===t||!this._queueLess(t,r))break;this._queueSwap(r,t),t=r}}},{key:"_queueDown",value:function(e,t){for(var r=e;;){var n=2*r+1;if(n>=t||n<0)break;var i=n+1,o=n;if(i<t&&this._queueLess(i,n)&&(o=i),!this._queueLess(o,r))break;this._queueSwap(r,o),r=o}return r>e}}]),e}();function L(e,t,r,n,i,o){return(r-i)*(t-o)-(n-o)*(e-i)}function T(e,t,r,n,i){for(var o=n.rScaler,a=n.bScaler,s=n.gScaler,u=n.offset,c=new Float32Array((t+1)*(r+1)),l=0,h=0;h<r;h++)for(var f=0;f<t;f++,l++){var d=4*l,p=e[d+0],g=e[d+1],v=e[d+2];c[l+h]=p*o+g*s+v*a+u}if("martini"===i){for(var y=(t+1)*t,_=0;_<t;_++,y++)c[y]=c[y-t-1];for(var m=r,b=0;b<r+1;b++,m+=r+1)c[m]=c[m-1]}return c}function A(e,t){if(null===e)return null;var r,n,i=t.meshMaxError,o=t.bounds,a=t.elevationDecoder,s=e.data,u=e.width,c=e.height;switch(t.tesselator){case"martini":n=z(i,u,r=T(s,u,c,a,t.tesselator));break;case"delatin":n=I(i,u,c,r=T(s,u,c,a,t.tesselator));break;default:n=u!==c||c&u-1?I(i,u,c,r=T(s,u,c,a,"delatin")):z(i,u,r=T(s,u,c,a,"martini"))}var l=n,h=l.vertices,f=l.triangles,d=function(e,t,r,n,i){for(var o=r+1,a=e.length/2,s=new Float32Array(3*a),u=new Float32Array(2*a),c=i||[0,0,r,n],l=M()(c,4),h=l[0],f=l[1],d=l[2],p=l[3],g=(d-h)/r,v=(p-f)/n,y=0;y<a;y++){var _=e[2*y],m=e[2*y+1],b=m*o+_;s[3*y+0]=_*g+h,s[3*y+1]=-m*v+p,s[3*y+2]=t[b],u[2*y+0]=_/r,u[2*y+1]=m/n}return{POSITION:{value:s,size:3},TEXCOORD_0:{value:u,size:2}}}(h,r,u,c,o);return{loaderData:{header:{}},header:{vertexCount:f.length,boundingBox:P(d)},mode:4,indices:{value:Uint32Array.from(f),size:1},attributes:d}}function z(e,t,r){var n=new E(t+1).createTile(r).getMesh(e);return{vertices:n.vertices,triangles:n.triangles}}function I(e,t,r,n){var i=new q(n,t+1,r+1);return i.run(e),{vertices:i.coords,triangles:i.triangles}}function D(){return(D=a()(u.a.mark((function e(t,r,n){var i;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return r.image=r.image||{},r.image.type="data",e.next=4,n.parse(t,r,r.baseUri);case 4:return i=e.sent,e.abrupt("return",A(i,r.terrain));case 6:case"end":return e.stop()}}),e)})))).apply(this,arguments)}function C(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function B(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?C(Object(r),!0).forEach((function(t){i()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):C(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var N,F=B(B({},{name:"Terrain",id:"terrain",module:"terrain",version:"3.0.0-beta.3",worker:!0,extensions:["png","pngraw"],mimeTypes:["image/png"],options:{terrain:{tesselator:"auto",bounds:null,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0}}}}),{},{parse:function(e,t,r){return D.apply(this,arguments)}});N=F,"undefined"!=typeof self&&(y.onmessage=function(){var e=a()(u.a.mark((function e(t,r){var n,i,o,a,s;return u.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t,e.next="process"===e.t0?3:16;break;case 3:return e.prev=3,n=r.input,i=r.options,o=void 0===i?{}:i,e.next=7,O({loader:N,arrayBuffer:n,options:o,context:{parse:w}});case 7:a=e.sent,y.postMessage("done",{result:a}),e.next=15;break;case 11:e.prev=11,e.t1=e.catch(3),s=e.t1 instanceof Error?e.t1.message:"",y.postMessage("error",{error:s});case 15:return e.abrupt("break",16);case 16:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t,r){return e.apply(this,arguments)}}())}]); | ||
//# sourceMappingURL=terrain-worker.js.map |
{ | ||
"name": "@loaders.gl/terrain", | ||
"version": "3.0.0-beta.2", | ||
"version": "3.0.0-beta.3", | ||
"description": "Framework-independent loader for terrain raster formats", | ||
@@ -38,6 +38,6 @@ "license": "MIT", | ||
"@babel/runtime": "^7.3.1", | ||
"@loaders.gl/loader-utils": "3.0.0-beta.2", | ||
"@loaders.gl/loader-utils": "3.0.0-beta.3", | ||
"@mapbox/martini": "^0.2.0" | ||
}, | ||
"gitHead": "c9417c6232ad2109a9c269ecf83afbf7ebc46cf8" | ||
"gitHead": "59a9b2843ffc095c818dcd2894ed64b6e8fd52ae" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
895171
3503
+ Added@loaders.gl/loader-utils@3.0.0-beta.3(transitive)
+ Added@loaders.gl/worker-utils@3.0.0-beta.3(transitive)
- Removed@loaders.gl/loader-utils@3.0.0-beta.2(transitive)
- Removed@loaders.gl/worker-utils@3.0.0-beta.2(transitive)