Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@loaders.gl/terrain

Package Overview
Dependencies
Maintainers
9
Versions
270
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/terrain - npm Package Compare versions

Comparing version 4.2.0-alpha.6 to 4.2.0-beta.1

5

dist/dist.dev.js

@@ -1157,2 +1157,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

var TerrainLoader = {
dataType: null,
batchType: null,
name: "Terrain",

@@ -1183,2 +1185,5 @@ id: "terrain",

var QuantizedMeshLoader = {
dataType: null,
// Mesh,
batchType: null,
name: "Quantized Mesh",

@@ -1185,0 +1190,0 @@ id: "quantized-mesh",

2

dist/dist.min.js

@@ -7,4 +7,4 @@ (function webpackUniversalModuleDefinition(root, factory) {

else root['loaders'] = factory();})(globalThis, function () {
"use strict";var __exports__=(()=>{var de=Object.create;var U=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty;var pe=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Ee=(s,e)=>{for(var r in e)U(s,r,{get:e[r],enumerable:!0})},q=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of me(e))!_e.call(s,n)&&n!==r&&U(s,n,{get:()=>e[n],enumerable:!(t=fe(e,n))||t.enumerable});return s},D=(s,e,r)=>(q(s,e,"default"),r&&q(r,e,"default")),Te=(s,e,r)=>(r=s!=null?de(ge(s)):{},q(e||!s||!s.__esModule?U(r,"default",{value:s,enumerable:!0}):r,s)),xe=s=>q(U({},"__esModule",{value:!0}),s);var se=pe((Re,ne)=>{ne.exports=globalThis.loaders});var v={};Ee(v,{QuantizedMeshLoader:()=>ke,QuantizedMeshWorkerLoader:()=>te,TerrainLoader:()=>ce,TerrainWorkerLoader:()=>ee,parseTerrain:()=>le});D(v,Te(se(),1));async function $(s,e,r,t){return t._parse(s,e,r,t)}function B(...s){let e=s,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let t=e.reduce((o,a)=>o+a.length,0),n=new r(t),i=0;for(let o of e)n.set(o,i),i+=o.length;return n}function L(s){let e=1/0,r=1/0,t=1/0,n=-1/0,i=-1/0,o=-1/0,a=s.POSITION?s.POSITION.value:[],l=a&&a.length;for(let c=0;c<l;c+=3){let h=a[c],u=a[c+1],f=a[c+2];e=h<e?h:e,r=u<r?u:r,t=f<t?f:t,n=h>n?h:n,i=u>i?u:i,o=f>o?f:o}return[[e,r,t],[n,i,o]]}var ye=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 G(s){return s>>1^-(s&1)}function Se(s){let e=0,r={};for(let[t,n]of ye){let i=n===8?s.getFloat64:s.getFloat32;r[t]=i.call(s,e,!0),e+=n}return{header:r,headerEndPosition:e}}function Ie(s,e){let r=e,t=3,n=s.getUint32(r,!0),i=new Uint16Array(n*t);r+=Uint32Array.BYTES_PER_ELEMENT;let o=Uint16Array.BYTES_PER_ELEMENT,a=n*o,l=r,c=l+a,h=c+a,u=0,f=0,d=0;for(let g=0;g<n;g++)u+=G(s.getUint16(l+o*g,!0)),f+=G(s.getUint16(c+o*g,!0)),d+=G(s.getUint16(h+o*g,!0)),i[g]=u,i[g+n]=f,i[g+n*2]=d;return r+=a*3,{vertexData:i,vertexDataEndPosition:r}}function F(s,e,r,t,n=!0){let i;if(t===2?i=new Uint16Array(s,e,r):i=new Uint32Array(s,e,r),!n)return i;let o=0;for(let a=0;a<i.length;++a){let l=i[a];i[a]=o-l,l===0&&++o}return i}function Ae(s,e,r){let t=r,n=3,o=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;t%o!==0&&(t+=o-t%o);let a=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let l=a*3,c=F(s.buffer,t,l,o);return t+=l*o,{triangleIndicesEndPosition:t,triangleIndices:c}}function be(s,e,r){let t=r,n=3,o=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let l=F(s.buffer,t,a,o,!1);t+=a*o;let c=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let h=F(s.buffer,t,c,o,!1);t+=c*o;let u=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let f=F(s.buffer,t,u,o,!1);t+=u*o;let d=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let g=F(s.buffer,t,d,o,!1);return t+=d*o,{edgeIndicesEndPosition:t,westIndices:l,southIndices:h,eastIndices:f,northIndices:g}}function Me(s){return new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}function Pe(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function we(s,e){let r={};if(s.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let t=e;for(;t<s.byteLength;){let n=s.getUint8(t,!0);t+=Uint8Array.BYTES_PER_ELEMENT;let i=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let o=new DataView(s.buffer,t,i);switch(n){case 1:{r.vertexNormals=Me(o);break}case 2:{r.waterMask=Pe(o);break}default:}t+=i}return{extensions:r,extensionsEndPosition:t}}var b={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},Be={maxDecodingStep:b.extensions};function J(s,e){let r=Object.assign({},Be,e),t=new DataView(s),{header:n,headerEndPosition:i}=Se(t);if(r.maxDecodingStep<b.vertices)return{header:n};let{vertexData:o,vertexDataEndPosition:a}=Ie(t,i);if(r.maxDecodingStep<b.triangleIndices)return{header:n,vertexData:o};let{triangleIndices:l,triangleIndicesEndPosition:c}=Ae(t,o,a);if(r.maxDecodingStep<b.edgeIndices)return{header:n,vertexData:o,triangleIndices:l};let{westIndices:h,southIndices:u,eastIndices:f,northIndices:d,edgeIndicesEndPosition:g}=be(t,o,c);if(r.maxDecodingStep<b.extensions)return{header:n,vertexData:o,triangleIndices:l,westIndices:h,northIndices:d,eastIndices:f,southIndices:u};let{extensions:m}=we(t,g);return{header:n,vertexData:o,triangleIndices:l,westIndices:h,northIndices:d,eastIndices:f,southIndices:u,extensions:m}}function Y(s,e,r,t){let n=t?Fe(t,s.POSITION.value):Le(e),i=new s.POSITION.value.constructor(n.length*6),o=new s.TEXCOORD_0.value.constructor(n.length*4),a=new e.constructor(n.length*6);for(let c=0;c<n.length;c++){let h=n[c];Ne({edge:h,edgeIndex:c,attributes:s,skirtHeight:r,newPosition:i,newTexcoord0:o,newTriangles:a})}s.POSITION.value=B(s.POSITION.value,i),s.TEXCOORD_0.value=B(s.TEXCOORD_0.value,o);let l=e instanceof Array?e.concat(a):B(e,a);return{attributes:s,triangles:l}}function Le(s){let e=[];for(let n=0;n<s.length;n+=3)e.push([s[n],s[n+1]]),e.push([s[n+1],s[n+2]]),e.push([s[n+2],s[n]]);e.sort((n,i)=>Math.min(...n)-Math.min(...i)||Math.max(...n)-Math.max(...i));let r=[],t=0;for(;t<e.length;)e[t][0]===e[t+1]?.[1]&&e[t][1]===e[t+1]?.[0]?t+=2:(r.push(e[t]),t++);return r}function Fe(s,e){s.westIndices.sort((t,n)=>e[3*t+1]-e[3*n+1]),s.eastIndices.sort((t,n)=>e[3*n+1]-e[3*t+1]),s.southIndices.sort((t,n)=>e[3*n]-e[3*t]),s.northIndices.sort((t,n)=>e[3*t]-e[3*n]);let r=[];for(let t in s){let n=s[t];for(let i=0;i<n.length-1;i++)r.push([n[i],n[i+1]])}return r}function Ne({edge:s,edgeIndex:e,attributes:r,skirtHeight:t,newPosition:n,newTexcoord0:i,newTriangles:o}){let a=r.POSITION.value.length,l=e*2,c=e*2+1;n.set(r.POSITION.value.subarray(s[0]*3,s[0]*3+3),l*3),n[l*3+2]=n[l*3+2]-t,n.set(r.POSITION.value.subarray(s[1]*3,s[1]*3+3),c*3),n[c*3+2]=n[c*3+2]-t,i.set(r.TEXCOORD_0.value.subarray(s[0]*2,s[0]*2+2),l*2),i.set(r.TEXCOORD_0.value.subarray(s[1]*2,s[1]*2+2),c*2);let h=e*2*3;o[h]=s[0],o[h+1]=a/3+c,o[h+2]=s[1],o[h+3]=a/3+c,o[h+4]=s[0],o[h+5]=a/3+l}function V(s,e={}){let{bounds:r}=e,{header:t,vertexData:n,triangleIndices:i,westIndices:o,northIndices:a,eastIndices:l,southIndices:c}=J(s,b.triangleIndices),h=i,u=Oe(n,t,r),f=L(u);if(e?.skirtHeight){let{attributes:d,triangles:g}=Y(u,h,e.skirtHeight,{westIndices:o,northIndices:a,eastIndices:l,southIndices:c});u=d,h=g}return{loaderData:{header:{}},header:{vertexCount:h.length,boundingBox:f},schema:void 0,topology:"triangle-list",mode:4,indices:{value:h,size:1},attributes:u}}function Oe(s,e,r){let{minHeight:t,maxHeight:n}=e,[i,o,a,l]=r||[0,0,1,1],c=a-i,h=l-o,u=n-t,f=s.length/3,d=new Float32Array(f*3),g=new Float32Array(f*2);for(let m=0;m<f;m++){let _=s[m]/32767,E=s[m+f]/32767,p=s[m+f*2]/32767;d[3*m+0]=_*c+i,d[3*m+1]=E*h+o,d[3*m+2]=p*u+t,g[2*m+0]=_,g[2*m+1]=E}return{POSITION:{value:d,size:3},TEXCOORD_0:{value:g,size:2}}}var N=class{constructor(e=257){this.gridSize=e;let r=e-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let t=0;t<this.numTriangles;t++){let n=t+2,i=0,o=0,a=0,l=0,c=0,h=0;for(n&1?a=l=c=r:i=o=h=r;(n>>=1)>1;){let f=i+a>>1,d=o+l>>1;n&1?(a=i,l=o,i=c,o=h):(i=a,o=l,a=c,l=h),c=f,h=d}let u=t*4;this.coords[u+0]=i,this.coords[u+1]=o,this.coords[u+2]=a,this.coords[u+3]=l}}createTile(e){return new K(e,this)}},K=class{constructor(e,r){let t=r.gridSize;if(e.length!==t*t)throw new Error(`Expected terrain data of length ${t*t} (${t} x ${t}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:t,gridSize:n}=this.martini,{terrain:i,errors:o}=this;for(let a=e-1;a>=0;a--){let l=a*4,c=t[l+0],h=t[l+1],u=t[l+2],f=t[l+3],d=c+u>>1,g=h+f>>1,m=d+g-h,_=g+c-d,E=(i[h*n+c]+i[f*n+u])/2,p=g*n+d,T=Math.abs(E-i[p]);if(o[p]=Math.max(o[p],T),a<r){let x=(h+_>>1)*n+(c+m>>1),y=(f+_>>1)*n+(u+m>>1);o[p]=Math.max(o[p],o[x],o[y])}}}getMesh(e=0){let{gridSize:r,indices:t}=this.martini,{errors:n}=this,i=0,o=0,a=r-1;t.fill(0);function l(d,g,m,_,E,p){let T=d+m>>1,x=g+_>>1;Math.abs(d-E)+Math.abs(g-p)>1&&n[x*r+T]>e?(l(E,p,d,g,T,x),l(m,_,E,p,T,x)):(t[g*r+d]=t[g*r+d]||++i,t[_*r+m]=t[_*r+m]||++i,t[p*r+E]=t[p*r+E]||++i,o++)}l(0,0,a,a,a,0),l(a,a,0,0,0,a);let c=new Uint16Array(i*2),h=new Uint32Array(o*3),u=0;function f(d,g,m,_,E,p){let T=d+m>>1,x=g+_>>1;if(Math.abs(d-E)+Math.abs(g-p)>1&&n[x*r+T]>e)f(E,p,d,g,T,x),f(m,_,E,p,T,x);else{let y=t[g*r+d]-1,S=t[_*r+m]-1,A=t[p*r+E]-1;c[2*y]=d,c[2*y+1]=g,c[2*S]=m,c[2*S+1]=_,c[2*A]=E,c[2*A+1]=p,h[u++]=y,h[u++]=S,h[u++]=A}}return f(0,0,a,a,a,0),f(a,a,0,0,0,a),{vertices:c,triangles:h}}};var O=class{constructor(e,r,t=r){this.data=e,this.width=r,this.height=t,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let n=r-1,i=t-1,o=this._addPoint(0,0),a=this._addPoint(n,0),l=this._addPoint(0,i),c=this._addPoint(n,i),h=this._addTriangle(c,o,l,-1,-1,-1);this._addTriangle(o,c,a,h,-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,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r<this._pendingLen;r++){let t=this._pending[r],n=2*this.triangles[t*3+0],i=2*this.triangles[t*3+1],o=2*this.triangles[t*3+2];this._findCandidate(e[n],e[n+1],e[i],e[i+1],e[o],e[o+1],t)}this._pendingLen=0}_findCandidate(e,r,t,n,i,o,a){let l=Math.min(e,t,i),c=Math.min(r,n,o),h=Math.max(e,t,i),u=Math.max(r,n,o),f=M(t,n,i,o,l,c),d=M(i,o,e,r,l,c),g=M(e,r,t,n,l,c),m=n-r,_=e-t,E=o-n,p=t-i,T=r-o,x=i-e,y=M(e,r,t,n,i,o),S=this.heightAt(e,r)/y,A=this.heightAt(t,n)/y,he=this.heightAt(i,o)/y,z=0,P=0,w=0,W=0;for(let k=c;k<=u;k++){let I=0;f<0&&E!==0&&(I=Math.max(I,Math.floor(-f/E))),d<0&&T!==0&&(I=Math.max(I,Math.floor(-d/T))),g<0&&m!==0&&(I=Math.max(I,Math.floor(-g/m)));let Q=f+E*I,j=d+T*I,Z=g+m*I,re=!1;for(let C=l+I;C<=h;C++){if(Q>=0&&j>=0&&Z>=0){re=!0;let ue=S*Q+A*j+he*Z,R=Math.abs(ue-this.heightAt(C,k));W+=R*R,R>z&&(z=R,P=C,w=k)}else if(re)break;Q+=E,j+=T,Z+=m}f+=p,d+=x,g+=_}(P===e&&w===r||P===t&&w===n||P===i&&w===o)&&(z=0),this._candidates[2*a]=P,this._candidates[2*a+1]=w,this._rms[a]=W,this._queuePush(a,z,W)}_step(){let e=this._queuePop(),r=e*3+0,t=e*3+1,n=e*3+2,i=this.triangles[r],o=this.triangles[t],a=this.triangles[n],l=this.coords[2*i],c=this.coords[2*i+1],h=this.coords[2*o],u=this.coords[2*o+1],f=this.coords[2*a],d=this.coords[2*a+1],g=this._candidates[2*e],m=this._candidates[2*e+1],_=this._addPoint(g,m);if(M(l,c,h,u,g,m)===0)this._handleCollinear(_,r);else if(M(h,u,f,d,g,m)===0)this._handleCollinear(_,t);else if(M(f,d,l,c,g,m)===0)this._handleCollinear(_,n);else{let E=this._halfedges[r],p=this._halfedges[t],T=this._halfedges[n],x=this._addTriangle(i,o,_,E,-1,-1,r),y=this._addTriangle(o,a,_,p,-1,x+1),S=this._addTriangle(a,i,_,T,x+2,y+1);this._legalize(x),this._legalize(y),this._legalize(S)}}_addPoint(e,r){let t=this.coords.length>>1;return this.coords.push(e,r),t}_addTriangle(e,r,t,n,i,o,a=this.triangles.length){let l=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=t,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*l+0]=0,this._candidates[2*l+1]=0,this._queueIndices[l]=-1,this._rms[l]=0,this._pending[this._pendingLen++]=l,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let t=e-e%3,n=r-r%3,i=t+(e+1)%3,o=t+(e+2)%3,a=n+(r+2)%3,l=n+(r+1)%3,c=this.triangles[o],h=this.triangles[e],u=this.triangles[i],f=this.triangles[a],d=this.coords;if(!ve(d[2*c],d[2*c+1],d[2*h],d[2*h+1],d[2*u],d[2*u+1],d[2*f],d[2*f+1]))return;let g=this._halfedges[i],m=this._halfedges[o],_=this._halfedges[a],E=this._halfedges[l];this._queueRemove(t/3),this._queueRemove(n/3);let p=this._addTriangle(c,f,u,-1,_,g,t),T=this._addTriangle(f,c,h,p,m,E,n);this._legalize(p+1),this._legalize(T+2)}_handleCollinear(e,r){let t=r-r%3,n=t+(r+1)%3,i=t+(r+2)%3,o=this.triangles[i],a=this.triangles[r],l=this.triangles[n],c=this._halfedges[n],h=this._halfedges[i],u=this._halfedges[r];if(u<0){let S=this._addTriangle(e,o,a,-1,h,-1,t),A=this._addTriangle(o,e,l,S,-1,c);this._legalize(S+1),this._legalize(A+2);return}let f=u-u%3,d=f+(u+2)%3,g=f+(u+1)%3,m=this.triangles[d],_=this._halfedges[d],E=this._halfedges[g];this._queueRemove(f/3);let p=this._addTriangle(o,a,e,h,-1,-1,t),T=this._addTriangle(a,m,e,E,-1,p+1,f),x=this._addTriangle(m,l,e,_,-1,T+1),y=this._addTriangle(l,o,e,c,p+2,x+1);this._legalize(p),this._legalize(T),this._legalize(x),this._legalize(y)}_queuePush(e,r,t){let n=this._queue.length;this._queueIndices[e]=n,this._queue.push(e),this._errors.push(r),this._rmsSum+=t,this._queueUp(n)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let n=this._pending.indexOf(e);if(n!==-1)this._pending[n]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let t=this._queue.length-1;t!==r&&(this._queueSwap(r,t),this._queueDown(r,t)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let t=this._queue[e],n=this._queue[r];this._queue[e]=n,this._queue[r]=t,this._queueIndices[t]=r,this._queueIndices[n]=e;let i=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=i}_queueUp(e){let r=e;for(;;){let t=r-1>>1;if(t===r||!this._queueLess(r,t))break;this._queueSwap(t,r),r=t}}_queueDown(e,r){let t=e;for(;;){let n=2*t+1;if(n>=r||n<0)break;let i=n+1,o=n;if(i<r&&this._queueLess(i,n)&&(o=i),!this._queueLess(o,t))break;this._queueSwap(t,o),t=o}return t>e}};function M(s,e,r,t,n,i){return(r-n)*(e-i)-(t-i)*(s-n)}function ve(s,e,r,t,n,i,o,a){let l=s-o,c=e-a,h=r-o,u=t-a,f=n-o,d=i-a,g=l*l+c*c,m=h*h+u*u,_=f*f+d*d;return l*(u*_-m*d)-c*(h*_-m*f)+g*(h*d-u*f)<0}function ae(s,e){let{meshMaxError:r,bounds:t,elevationDecoder:n}=e,{data:i,width:o,height:a}=s,l,c;switch(e.tesselator){case"martini":l=X(i,o,a,n,e.tesselator),c=oe(r,o,l);break;case"delatin":l=X(i,o,a,n,e.tesselator),c=ie(r,o,a,l);break;default:o===a&&!(a&o-1)?(l=X(i,o,a,n,"martini"),c=oe(r,o,l)):(l=X(i,o,a,n,"delatin"),c=ie(r,o,a,l));break}let{vertices:h}=c,{triangles:u}=c,f=ze(h,l,o,a,t),d=L(f);if(e.skirtHeight){let{attributes:g,triangles:m}=Y(f,u,e.skirtHeight);f=g,u=m}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:d},mode:4,indices:{value:Uint32Array.from(u),size:1},attributes:f}}function oe(s,e,r){let t=e+1,i=new N(t).createTile(r),{vertices:o,triangles:a}=i.getMesh(s);return{vertices:o,triangles:a}}function ie(s,e,r,t){let n=new O(t,e+1,r+1);n.run(s);let{coords:i,triangles:o}=n;return{vertices:i,triangles:o}}function X(s,e,r,t,n){let{rScaler:i,bScaler:o,gScaler:a,offset:l}=t,c=new Float32Array((e+1)*(r+1));for(let h=0,u=0;u<r;u++)for(let f=0;f<e;f++,h++){let d=h*4,g=s[d+0],m=s[d+1],_=s[d+2];c[h+u]=g*i+m*a+_*o+l}if(n==="martini"){for(let h=(e+1)*e,u=0;u<e;u++,h++)c[h]=c[h-e-1];for(let h=r,u=0;u<r+1;u++,h+=r+1)c[h]=c[h-1]}return c}function ze(s,e,r,t,n){let i=r+1,o=s.length/2,a=new Float32Array(o*3),l=new Float32Array(o*2),[c,h,u,f]=n||[0,0,r,t],d=(u-c)/r,g=(f-h)/t;for(let m=0;m<o;m++){let _=s[m*2],E=s[m*2+1],p=E*i+_;a[3*m+0]=_*d+c,a[3*m+1]=-E*g+f,a[3*m+2]=e[p],l[2*m+0]=_/r,l[2*m+1]=E/t}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:l,size:2}}}var H="4.2.0-alpha.5";var ee={name:"Terrain",id:"terrain",module:"terrain",version:H,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var te={name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:H,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var ce={...ee,parse:le};async function le(s,e,r){let t={...e,mimeType:"application/x.image",image:{...e?.image,type:"data"}},n=await $(s,[],t,r),i={...ce.options.terrain,...e?.terrain};return ae(n,i)}var ke={...te,parseSync:(s,e)=>V(s,e?.["quantized-mesh"]),parse:async(s,e)=>V(s,e?.["quantized-mesh"])};return xe(v);})();
"use strict";var __exports__=(()=>{var de=Object.create;var U=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var me=Object.getOwnPropertyNames;var ge=Object.getPrototypeOf,_e=Object.prototype.hasOwnProperty;var pe=(s,e)=>()=>(e||s((e={exports:{}}).exports,e),e.exports),Ee=(s,e)=>{for(var r in e)U(s,r,{get:e[r],enumerable:!0})},q=(s,e,r,t)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of me(e))!_e.call(s,n)&&n!==r&&U(s,n,{get:()=>e[n],enumerable:!(t=fe(e,n))||t.enumerable});return s},D=(s,e,r)=>(q(s,e,"default"),r&&q(r,e,"default")),Te=(s,e,r)=>(r=s!=null?de(ge(s)):{},q(e||!s||!s.__esModule?U(r,"default",{value:s,enumerable:!0}):r,s)),xe=s=>q(U({},"__esModule",{value:!0}),s);var se=pe((Re,ne)=>{ne.exports=globalThis.loaders});var v={};Ee(v,{QuantizedMeshLoader:()=>ke,QuantizedMeshWorkerLoader:()=>te,TerrainLoader:()=>ce,TerrainWorkerLoader:()=>ee,parseTerrain:()=>le});D(v,Te(se(),1));async function J(s,e,r,t){return t._parse(s,e,r,t)}function B(...s){let e=s,r=e&&e.length>1&&e[0].constructor||null;if(!r)throw new Error('"concatenateTypedArrays" - incorrect quantity of arguments or arguments have incompatible data types');let t=e.reduce((o,a)=>o+a.length,0),n=new r(t),i=0;for(let o of e)n.set(o,i),i+=o.length;return n}function L(s){let e=1/0,r=1/0,t=1/0,n=-1/0,i=-1/0,o=-1/0,a=s.POSITION?s.POSITION.value:[],l=a&&a.length;for(let c=0;c<l;c+=3){let h=a[c],u=a[c+1],f=a[c+2];e=h<e?h:e,r=u<r?u:r,t=f<t?f:t,n=h>n?h:n,i=u>i?u:i,o=f>o?f:o}return[[e,r,t],[n,i,o]]}var ye=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 $(s){return s>>1^-(s&1)}function Se(s){let e=0,r={};for(let[t,n]of ye){let i=n===8?s.getFloat64:s.getFloat32;r[t]=i.call(s,e,!0),e+=n}return{header:r,headerEndPosition:e}}function Ie(s,e){let r=e,t=3,n=s.getUint32(r,!0),i=new Uint16Array(n*t);r+=Uint32Array.BYTES_PER_ELEMENT;let o=Uint16Array.BYTES_PER_ELEMENT,a=n*o,l=r,c=l+a,h=c+a,u=0,f=0,d=0;for(let g=0;g<n;g++)u+=$(s.getUint16(l+o*g,!0)),f+=$(s.getUint16(c+o*g,!0)),d+=$(s.getUint16(h+o*g,!0)),i[g]=u,i[g+n]=f,i[g+n*2]=d;return r+=a*3,{vertexData:i,vertexDataEndPosition:r}}function N(s,e,r,t,n=!0){let i;if(t===2?i=new Uint16Array(s,e,r):i=new Uint32Array(s,e,r),!n)return i;let o=0;for(let a=0;a<i.length;++a){let l=i[a];i[a]=o-l,l===0&&++o}return i}function Ae(s,e,r){let t=r,n=3,o=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT;t%o!==0&&(t+=o-t%o);let a=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let l=a*3,c=N(s.buffer,t,l,o);return t+=l*o,{triangleIndicesEndPosition:t,triangleIndices:c}}function be(s,e,r){let t=r,n=3,o=e.length/n>65536?Uint32Array.BYTES_PER_ELEMENT:Uint16Array.BYTES_PER_ELEMENT,a=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let l=N(s.buffer,t,a,o,!1);t+=a*o;let c=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let h=N(s.buffer,t,c,o,!1);t+=c*o;let u=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let f=N(s.buffer,t,u,o,!1);t+=u*o;let d=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let g=N(s.buffer,t,d,o,!1);return t+=d*o,{edgeIndicesEndPosition:t,westIndices:l,southIndices:h,eastIndices:f,northIndices:g}}function Me(s){return new Uint8Array(s.buffer,s.byteOffset,s.byteLength)}function Pe(s){return s.buffer.slice(s.byteOffset,s.byteOffset+s.byteLength)}function we(s,e){let r={};if(s.byteLength<=e)return{extensions:r,extensionsEndPosition:e};let t=e;for(;t<s.byteLength;){let n=s.getUint8(t,!0);t+=Uint8Array.BYTES_PER_ELEMENT;let i=s.getUint32(t,!0);t+=Uint32Array.BYTES_PER_ELEMENT;let o=new DataView(s.buffer,t,i);switch(n){case 1:{r.vertexNormals=Me(o);break}case 2:{r.waterMask=Pe(o);break}default:}t+=i}return{extensions:r,extensionsEndPosition:t}}var b={header:0,vertices:1,triangleIndices:2,edgeIndices:3,extensions:4},Be={maxDecodingStep:b.extensions};function G(s,e){let r=Object.assign({},Be,e),t=new DataView(s),{header:n,headerEndPosition:i}=Se(t);if(r.maxDecodingStep<b.vertices)return{header:n};let{vertexData:o,vertexDataEndPosition:a}=Ie(t,i);if(r.maxDecodingStep<b.triangleIndices)return{header:n,vertexData:o};let{triangleIndices:l,triangleIndicesEndPosition:c}=Ae(t,o,a);if(r.maxDecodingStep<b.edgeIndices)return{header:n,vertexData:o,triangleIndices:l};let{westIndices:h,southIndices:u,eastIndices:f,northIndices:d,edgeIndicesEndPosition:g}=be(t,o,c);if(r.maxDecodingStep<b.extensions)return{header:n,vertexData:o,triangleIndices:l,westIndices:h,northIndices:d,eastIndices:f,southIndices:u};let{extensions:m}=we(t,g);return{header:n,vertexData:o,triangleIndices:l,westIndices:h,northIndices:d,eastIndices:f,southIndices:u,extensions:m}}function Y(s,e,r,t){let n=t?Ne(t,s.POSITION.value):Le(e),i=new s.POSITION.value.constructor(n.length*6),o=new s.TEXCOORD_0.value.constructor(n.length*4),a=new e.constructor(n.length*6);for(let c=0;c<n.length;c++){let h=n[c];Fe({edge:h,edgeIndex:c,attributes:s,skirtHeight:r,newPosition:i,newTexcoord0:o,newTriangles:a})}s.POSITION.value=B(s.POSITION.value,i),s.TEXCOORD_0.value=B(s.TEXCOORD_0.value,o);let l=e instanceof Array?e.concat(a):B(e,a);return{attributes:s,triangles:l}}function Le(s){let e=[];for(let n=0;n<s.length;n+=3)e.push([s[n],s[n+1]]),e.push([s[n+1],s[n+2]]),e.push([s[n+2],s[n]]);e.sort((n,i)=>Math.min(...n)-Math.min(...i)||Math.max(...n)-Math.max(...i));let r=[],t=0;for(;t<e.length;)e[t][0]===e[t+1]?.[1]&&e[t][1]===e[t+1]?.[0]?t+=2:(r.push(e[t]),t++);return r}function Ne(s,e){s.westIndices.sort((t,n)=>e[3*t+1]-e[3*n+1]),s.eastIndices.sort((t,n)=>e[3*n+1]-e[3*t+1]),s.southIndices.sort((t,n)=>e[3*n]-e[3*t]),s.northIndices.sort((t,n)=>e[3*t]-e[3*n]);let r=[];for(let t in s){let n=s[t];for(let i=0;i<n.length-1;i++)r.push([n[i],n[i+1]])}return r}function Fe({edge:s,edgeIndex:e,attributes:r,skirtHeight:t,newPosition:n,newTexcoord0:i,newTriangles:o}){let a=r.POSITION.value.length,l=e*2,c=e*2+1;n.set(r.POSITION.value.subarray(s[0]*3,s[0]*3+3),l*3),n[l*3+2]=n[l*3+2]-t,n.set(r.POSITION.value.subarray(s[1]*3,s[1]*3+3),c*3),n[c*3+2]=n[c*3+2]-t,i.set(r.TEXCOORD_0.value.subarray(s[0]*2,s[0]*2+2),l*2),i.set(r.TEXCOORD_0.value.subarray(s[1]*2,s[1]*2+2),c*2);let h=e*2*3;o[h]=s[0],o[h+1]=a/3+c,o[h+2]=s[1],o[h+3]=a/3+c,o[h+4]=s[0],o[h+5]=a/3+l}function V(s,e={}){let{bounds:r}=e,{header:t,vertexData:n,triangleIndices:i,westIndices:o,northIndices:a,eastIndices:l,southIndices:c}=G(s,b.triangleIndices),h=i,u=Oe(n,t,r),f=L(u);if(e?.skirtHeight){let{attributes:d,triangles:g}=Y(u,h,e.skirtHeight,{westIndices:o,northIndices:a,eastIndices:l,southIndices:c});u=d,h=g}return{loaderData:{header:{}},header:{vertexCount:h.length,boundingBox:f},schema:void 0,topology:"triangle-list",mode:4,indices:{value:h,size:1},attributes:u}}function Oe(s,e,r){let{minHeight:t,maxHeight:n}=e,[i,o,a,l]=r||[0,0,1,1],c=a-i,h=l-o,u=n-t,f=s.length/3,d=new Float32Array(f*3),g=new Float32Array(f*2);for(let m=0;m<f;m++){let _=s[m]/32767,E=s[m+f]/32767,p=s[m+f*2]/32767;d[3*m+0]=_*c+i,d[3*m+1]=E*h+o,d[3*m+2]=p*u+t,g[2*m+0]=_,g[2*m+1]=E}return{POSITION:{value:d,size:3},TEXCOORD_0:{value:g,size:2}}}var F=class{constructor(e=257){this.gridSize=e;let r=e-1;if(r&r-1)throw new Error(`Expected grid size to be 2^n+1, got ${e}.`);this.numTriangles=r*r*2-2,this.numParentTriangles=this.numTriangles-r*r,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(this.numTriangles*4);for(let t=0;t<this.numTriangles;t++){let n=t+2,i=0,o=0,a=0,l=0,c=0,h=0;for(n&1?a=l=c=r:i=o=h=r;(n>>=1)>1;){let f=i+a>>1,d=o+l>>1;n&1?(a=i,l=o,i=c,o=h):(i=a,o=l,a=c,l=h),c=f,h=d}let u=t*4;this.coords[u+0]=i,this.coords[u+1]=o,this.coords[u+2]=a,this.coords[u+3]=l}}createTile(e){return new K(e,this)}},K=class{constructor(e,r){let t=r.gridSize;if(e.length!==t*t)throw new Error(`Expected terrain data of length ${t*t} (${t} x ${t}), got ${e.length}.`);this.terrain=e,this.martini=r,this.errors=new Float32Array(e.length),this.update()}update(){let{numTriangles:e,numParentTriangles:r,coords:t,gridSize:n}=this.martini,{terrain:i,errors:o}=this;for(let a=e-1;a>=0;a--){let l=a*4,c=t[l+0],h=t[l+1],u=t[l+2],f=t[l+3],d=c+u>>1,g=h+f>>1,m=d+g-h,_=g+c-d,E=(i[h*n+c]+i[f*n+u])/2,p=g*n+d,T=Math.abs(E-i[p]);if(o[p]=Math.max(o[p],T),a<r){let x=(h+_>>1)*n+(c+m>>1),y=(f+_>>1)*n+(u+m>>1);o[p]=Math.max(o[p],o[x],o[y])}}}getMesh(e=0){let{gridSize:r,indices:t}=this.martini,{errors:n}=this,i=0,o=0,a=r-1;t.fill(0);function l(d,g,m,_,E,p){let T=d+m>>1,x=g+_>>1;Math.abs(d-E)+Math.abs(g-p)>1&&n[x*r+T]>e?(l(E,p,d,g,T,x),l(m,_,E,p,T,x)):(t[g*r+d]=t[g*r+d]||++i,t[_*r+m]=t[_*r+m]||++i,t[p*r+E]=t[p*r+E]||++i,o++)}l(0,0,a,a,a,0),l(a,a,0,0,0,a);let c=new Uint16Array(i*2),h=new Uint32Array(o*3),u=0;function f(d,g,m,_,E,p){let T=d+m>>1,x=g+_>>1;if(Math.abs(d-E)+Math.abs(g-p)>1&&n[x*r+T]>e)f(E,p,d,g,T,x),f(m,_,E,p,T,x);else{let y=t[g*r+d]-1,S=t[_*r+m]-1,A=t[p*r+E]-1;c[2*y]=d,c[2*y+1]=g,c[2*S]=m,c[2*S+1]=_,c[2*A]=E,c[2*A+1]=p,h[u++]=y,h[u++]=S,h[u++]=A}}return f(0,0,a,a,a,0),f(a,a,0,0,0,a),{vertices:c,triangles:h}}};var O=class{constructor(e,r,t=r){this.data=e,this.width=r,this.height=t,this.coords=[],this.triangles=[],this._halfedges=[],this._candidates=[],this._queueIndices=[],this._queue=[],this._errors=[],this._rms=[],this._pending=[],this._pendingLen=0,this._rmsSum=0;let n=r-1,i=t-1,o=this._addPoint(0,0),a=this._addPoint(n,0),l=this._addPoint(0,i),c=this._addPoint(n,i),h=this._addTriangle(c,o,l,-1,-1,-1);this._addTriangle(o,c,a,h,-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,r){return this.data[this.width*r+e]}_flush(){let e=this.coords;for(let r=0;r<this._pendingLen;r++){let t=this._pending[r],n=2*this.triangles[t*3+0],i=2*this.triangles[t*3+1],o=2*this.triangles[t*3+2];this._findCandidate(e[n],e[n+1],e[i],e[i+1],e[o],e[o+1],t)}this._pendingLen=0}_findCandidate(e,r,t,n,i,o,a){let l=Math.min(e,t,i),c=Math.min(r,n,o),h=Math.max(e,t,i),u=Math.max(r,n,o),f=M(t,n,i,o,l,c),d=M(i,o,e,r,l,c),g=M(e,r,t,n,l,c),m=n-r,_=e-t,E=o-n,p=t-i,T=r-o,x=i-e,y=M(e,r,t,n,i,o),S=this.heightAt(e,r)/y,A=this.heightAt(t,n)/y,he=this.heightAt(i,o)/y,z=0,P=0,w=0,W=0;for(let k=c;k<=u;k++){let I=0;f<0&&E!==0&&(I=Math.max(I,Math.floor(-f/E))),d<0&&T!==0&&(I=Math.max(I,Math.floor(-d/T))),g<0&&m!==0&&(I=Math.max(I,Math.floor(-g/m)));let Q=f+E*I,j=d+T*I,Z=g+m*I,re=!1;for(let C=l+I;C<=h;C++){if(Q>=0&&j>=0&&Z>=0){re=!0;let ue=S*Q+A*j+he*Z,R=Math.abs(ue-this.heightAt(C,k));W+=R*R,R>z&&(z=R,P=C,w=k)}else if(re)break;Q+=E,j+=T,Z+=m}f+=p,d+=x,g+=_}(P===e&&w===r||P===t&&w===n||P===i&&w===o)&&(z=0),this._candidates[2*a]=P,this._candidates[2*a+1]=w,this._rms[a]=W,this._queuePush(a,z,W)}_step(){let e=this._queuePop(),r=e*3+0,t=e*3+1,n=e*3+2,i=this.triangles[r],o=this.triangles[t],a=this.triangles[n],l=this.coords[2*i],c=this.coords[2*i+1],h=this.coords[2*o],u=this.coords[2*o+1],f=this.coords[2*a],d=this.coords[2*a+1],g=this._candidates[2*e],m=this._candidates[2*e+1],_=this._addPoint(g,m);if(M(l,c,h,u,g,m)===0)this._handleCollinear(_,r);else if(M(h,u,f,d,g,m)===0)this._handleCollinear(_,t);else if(M(f,d,l,c,g,m)===0)this._handleCollinear(_,n);else{let E=this._halfedges[r],p=this._halfedges[t],T=this._halfedges[n],x=this._addTriangle(i,o,_,E,-1,-1,r),y=this._addTriangle(o,a,_,p,-1,x+1),S=this._addTriangle(a,i,_,T,x+2,y+1);this._legalize(x),this._legalize(y),this._legalize(S)}}_addPoint(e,r){let t=this.coords.length>>1;return this.coords.push(e,r),t}_addTriangle(e,r,t,n,i,o,a=this.triangles.length){let l=a/3;return this.triangles[a+0]=e,this.triangles[a+1]=r,this.triangles[a+2]=t,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*l+0]=0,this._candidates[2*l+1]=0,this._queueIndices[l]=-1,this._rms[l]=0,this._pending[this._pendingLen++]=l,a}_legalize(e){let r=this._halfedges[e];if(r<0)return;let t=e-e%3,n=r-r%3,i=t+(e+1)%3,o=t+(e+2)%3,a=n+(r+2)%3,l=n+(r+1)%3,c=this.triangles[o],h=this.triangles[e],u=this.triangles[i],f=this.triangles[a],d=this.coords;if(!ve(d[2*c],d[2*c+1],d[2*h],d[2*h+1],d[2*u],d[2*u+1],d[2*f],d[2*f+1]))return;let g=this._halfedges[i],m=this._halfedges[o],_=this._halfedges[a],E=this._halfedges[l];this._queueRemove(t/3),this._queueRemove(n/3);let p=this._addTriangle(c,f,u,-1,_,g,t),T=this._addTriangle(f,c,h,p,m,E,n);this._legalize(p+1),this._legalize(T+2)}_handleCollinear(e,r){let t=r-r%3,n=t+(r+1)%3,i=t+(r+2)%3,o=this.triangles[i],a=this.triangles[r],l=this.triangles[n],c=this._halfedges[n],h=this._halfedges[i],u=this._halfedges[r];if(u<0){let S=this._addTriangle(e,o,a,-1,h,-1,t),A=this._addTriangle(o,e,l,S,-1,c);this._legalize(S+1),this._legalize(A+2);return}let f=u-u%3,d=f+(u+2)%3,g=f+(u+1)%3,m=this.triangles[d],_=this._halfedges[d],E=this._halfedges[g];this._queueRemove(f/3);let p=this._addTriangle(o,a,e,h,-1,-1,t),T=this._addTriangle(a,m,e,E,-1,p+1,f),x=this._addTriangle(m,l,e,_,-1,T+1),y=this._addTriangle(l,o,e,c,p+2,x+1);this._legalize(p),this._legalize(T),this._legalize(x),this._legalize(y)}_queuePush(e,r,t){let n=this._queue.length;this._queueIndices[e]=n,this._queue.push(e),this._errors.push(r),this._rmsSum+=t,this._queueUp(n)}_queuePop(){let e=this._queue.length-1;return this._queueSwap(0,e),this._queueDown(0,e),this._queuePopBack()}_queuePopBack(){let e=this._queue.pop();return this._errors.pop(),this._rmsSum-=this._rms[e],this._queueIndices[e]=-1,e}_queueRemove(e){let r=this._queueIndices[e];if(r<0){let n=this._pending.indexOf(e);if(n!==-1)this._pending[n]=this._pending[--this._pendingLen];else throw new Error("Broken triangulation (something went wrong).");return}let t=this._queue.length-1;t!==r&&(this._queueSwap(r,t),this._queueDown(r,t)||this._queueUp(r)),this._queuePopBack()}_queueLess(e,r){return this._errors[e]>this._errors[r]}_queueSwap(e,r){let t=this._queue[e],n=this._queue[r];this._queue[e]=n,this._queue[r]=t,this._queueIndices[t]=r,this._queueIndices[n]=e;let i=this._errors[e];this._errors[e]=this._errors[r],this._errors[r]=i}_queueUp(e){let r=e;for(;;){let t=r-1>>1;if(t===r||!this._queueLess(r,t))break;this._queueSwap(t,r),r=t}}_queueDown(e,r){let t=e;for(;;){let n=2*t+1;if(n>=r||n<0)break;let i=n+1,o=n;if(i<r&&this._queueLess(i,n)&&(o=i),!this._queueLess(o,t))break;this._queueSwap(t,o),t=o}return t>e}};function M(s,e,r,t,n,i){return(r-n)*(e-i)-(t-i)*(s-n)}function ve(s,e,r,t,n,i,o,a){let l=s-o,c=e-a,h=r-o,u=t-a,f=n-o,d=i-a,g=l*l+c*c,m=h*h+u*u,_=f*f+d*d;return l*(u*_-m*d)-c*(h*_-m*f)+g*(h*d-u*f)<0}function ae(s,e){let{meshMaxError:r,bounds:t,elevationDecoder:n}=e,{data:i,width:o,height:a}=s,l,c;switch(e.tesselator){case"martini":l=X(i,o,a,n,e.tesselator),c=oe(r,o,l);break;case"delatin":l=X(i,o,a,n,e.tesselator),c=ie(r,o,a,l);break;default:o===a&&!(a&o-1)?(l=X(i,o,a,n,"martini"),c=oe(r,o,l)):(l=X(i,o,a,n,"delatin"),c=ie(r,o,a,l));break}let{vertices:h}=c,{triangles:u}=c,f=ze(h,l,o,a,t),d=L(f);if(e.skirtHeight){let{attributes:g,triangles:m}=Y(f,u,e.skirtHeight);f=g,u=m}return{loaderData:{header:{}},header:{vertexCount:u.length,boundingBox:d},mode:4,indices:{value:Uint32Array.from(u),size:1},attributes:f}}function oe(s,e,r){let t=e+1,i=new F(t).createTile(r),{vertices:o,triangles:a}=i.getMesh(s);return{vertices:o,triangles:a}}function ie(s,e,r,t){let n=new O(t,e+1,r+1);n.run(s);let{coords:i,triangles:o}=n;return{vertices:i,triangles:o}}function X(s,e,r,t,n){let{rScaler:i,bScaler:o,gScaler:a,offset:l}=t,c=new Float32Array((e+1)*(r+1));for(let h=0,u=0;u<r;u++)for(let f=0;f<e;f++,h++){let d=h*4,g=s[d+0],m=s[d+1],_=s[d+2];c[h+u]=g*i+m*a+_*o+l}if(n==="martini"){for(let h=(e+1)*e,u=0;u<e;u++,h++)c[h]=c[h-e-1];for(let h=r,u=0;u<r+1;u++,h+=r+1)c[h]=c[h-1]}return c}function ze(s,e,r,t,n){let i=r+1,o=s.length/2,a=new Float32Array(o*3),l=new Float32Array(o*2),[c,h,u,f]=n||[0,0,r,t],d=(u-c)/r,g=(f-h)/t;for(let m=0;m<o;m++){let _=s[m*2],E=s[m*2+1],p=E*i+_;a[3*m+0]=_*d+c,a[3*m+1]=-E*g+f,a[3*m+2]=e[p],l[2*m+0]=_/r,l[2*m+1]=E/t}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:l,size:2}}}var H="4.2.0-alpha.6";var ee={dataType:null,batchType:null,name:"Terrain",id:"terrain",module:"terrain",version:H,worker:!0,extensions:["png","pngraw","jpg","jpeg","gif","webp","bmp"],mimeTypes:["image/png","image/jpeg","image/gif","image/webp","image/bmp"],options:{terrain:{tesselator:"auto",bounds:void 0,meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0},skirtHeight:void 0}}};var te={dataType:null,batchType:null,name:"Quantized Mesh",id:"quantized-mesh",module:"terrain",version:H,worker:!0,extensions:["terrain"],mimeTypes:["application/vnd.quantized-mesh"],options:{"quantized-mesh":{bounds:[0,0,1,1],skirtHeight:null}}};var ce={...ee,parse:le};async function le(s,e,r){let t={...e,mimeType:"application/x.image",image:{...e?.image,type:"data"}},n=await J(s,[],t,r),i={...ce.options.terrain,...e?.terrain};return ae(n,i)}var ke={...te,parseSync:(s,e)=>V(s,e?.["quantized-mesh"]),parse:async(s,e)=>V(s,e?.["quantized-mesh"])};return xe(v);})();
return __exports__;
});

@@ -1,6 +0,31 @@

import type { LoaderContext, LoaderWithParser } from '@loaders.gl/loader-utils';
import type { LoaderContext } from '@loaders.gl/loader-utils';
import { TerrainLoader as TerrainWorkerLoader, TerrainLoaderOptions } from "./terrain-loader.js";
import { QuantizedMeshLoader as QuantizedMeshWorkerLoader, QuantizedMeshLoaderOptions } from "./quantized-mesh-loader.js";
export { TerrainWorkerLoader };
export declare const TerrainLoader: LoaderWithParser<any, never, TerrainLoaderOptions>;
export declare const TerrainLoader: {
readonly parse: typeof parseTerrain;
readonly dataType: import("@loaders.gl/schema").Mesh;
readonly batchType: never;
readonly name: "Terrain";
readonly id: "terrain";
readonly module: "terrain";
readonly version: any;
readonly worker: true;
readonly extensions: ["png", "pngraw", "jpg", "jpeg", "gif", "webp", "bmp"];
readonly mimeTypes: ["image/png", "image/jpeg", "image/gif", "image/webp", "image/bmp"];
readonly options: {
readonly terrain: {
readonly tesselator: "auto";
readonly bounds: never;
readonly meshMaxError: 10;
readonly elevationDecoder: {
readonly rScaler: 1;
readonly gScaler: 0;
readonly bScaler: 0;
readonly offset: 0;
};
readonly skirtHeight: undefined;
};
};
};
export declare function parseTerrain(arrayBuffer: ArrayBuffer, options?: TerrainLoaderOptions, context?: LoaderContext): Promise<{

@@ -34,3 +59,21 @@ loaderData: {

*/
export declare const QuantizedMeshLoader: LoaderWithParser<any, never, QuantizedMeshLoaderOptions>;
export declare const QuantizedMeshLoader: {
readonly parseSync: (arrayBuffer: ArrayBuffer, options: QuantizedMeshLoaderOptions | undefined) => import("@loaders.gl/schema").Mesh;
readonly parse: (arrayBuffer: ArrayBuffer, options: QuantizedMeshLoaderOptions | undefined) => Promise<import("@loaders.gl/schema").Mesh>;
readonly dataType: any;
readonly batchType: never;
readonly name: "Quantized Mesh";
readonly id: "quantized-mesh";
readonly module: "terrain";
readonly version: any;
readonly worker: true;
readonly extensions: ["terrain"];
readonly mimeTypes: ["application/vnd.quantized-mesh"];
readonly options: {
readonly 'quantized-mesh': {
readonly bounds: [0, 0, 1, 1];
readonly skirtHeight: null;
};
};
};
//# sourceMappingURL=index.d.ts.map

@@ -7,2 +7,2 @@ // loaders.gl

// @ts-ignore TS2304: Cannot find name '__VERSION__'.
export const VERSION = typeof "4.2.0-alpha.5" !== 'undefined' ? "4.2.0-alpha.5" : 'latest';
export const VERSION = typeof "4.2.0-alpha.6" !== 'undefined' ? "4.2.0-alpha.6" : 'latest';

@@ -1,6 +0,10 @@

import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
import type { LoaderOptions } from '@loaders.gl/loader-utils';
/** QuantizedMeshLoader options */
export type QuantizedMeshLoaderOptions = LoaderOptions & {
/** QuantizedMeshLoader options */
'quantized-mesh'?: {
bounds?: [number, number, number, number];
skirtHeight?: number | null;
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
workerUrl?: string;
};

@@ -11,3 +15,19 @@ };

*/
export declare const QuantizedMeshLoader: Loader<any, never, QuantizedMeshLoaderOptions>;
export declare const QuantizedMeshLoader: {
readonly dataType: any;
readonly batchType: never;
readonly name: "Quantized Mesh";
readonly id: "quantized-mesh";
readonly module: "terrain";
readonly version: any;
readonly worker: true;
readonly extensions: ["terrain"];
readonly mimeTypes: ["application/vnd.quantized-mesh"];
readonly options: {
readonly 'quantized-mesh': {
readonly bounds: [0, 0, 1, 1];
readonly skirtHeight: null;
};
};
};
//# sourceMappingURL=quantized-mesh-loader.d.ts.map

@@ -9,2 +9,4 @@ // loaders.gl

export const QuantizedMeshLoader = {
dataType: null, // Mesh,
batchType: null,
name: 'Quantized Mesh',

@@ -11,0 +13,0 @@ id: 'quantized-mesh',

@@ -1296,6 +1296,8 @@ "use strict";

// src/lib/utils/version.ts
var VERSION = true ? "4.2.0-alpha.5" : "latest";
var VERSION = true ? "4.2.0-alpha.6" : "latest";
// src/terrain-loader.ts
var TerrainLoader = {
dataType: null,
batchType: null,
name: "Terrain",

@@ -1326,2 +1328,5 @@ id: "terrain",

var QuantizedMeshLoader = {
dataType: null,
// Mesh,
batchType: null,
name: "Quantized Mesh",

@@ -1328,0 +1333,0 @@ id: "quantized-mesh",

@@ -1,7 +0,11 @@

import type { Loader } from '@loaders.gl/loader-utils';
import type { ImageLoaderOptions } from '@loaders.gl/images';
import { TerrainOptions } from "./lib/parse-terrain.js";
import { Mesh } from '@loaders.gl/schema';
/** TerrainLoader options */
export type TerrainLoaderOptions = ImageLoaderOptions & {
terrain?: TerrainOptions;
/** TerrainLoader options */
terrain?: TerrainOptions & {
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
workerUrl?: string;
};
};

@@ -11,3 +15,27 @@ /**

*/
export declare const TerrainLoader: Loader<Mesh, never, TerrainLoaderOptions>;
export declare const TerrainLoader: {
readonly dataType: Mesh;
readonly batchType: never;
readonly name: "Terrain";
readonly id: "terrain";
readonly module: "terrain";
readonly version: any;
readonly worker: true;
readonly extensions: ["png", "pngraw", "jpg", "jpeg", "gif", "webp", "bmp"];
readonly mimeTypes: ["image/png", "image/jpeg", "image/gif", "image/webp", "image/bmp"];
readonly options: {
readonly terrain: {
readonly tesselator: "auto";
readonly bounds: never;
readonly meshMaxError: 10;
readonly elevationDecoder: {
readonly rScaler: 1;
readonly gScaler: 0;
readonly bScaler: 0;
readonly offset: 0;
};
readonly skirtHeight: undefined;
};
};
};
//# sourceMappingURL=terrain-loader.d.ts.map

@@ -9,2 +9,4 @@ // loaders.gl

export const TerrainLoader = {
dataType: null,
batchType: null,
name: 'Terrain',

@@ -11,0 +13,0 @@ id: 'terrain',

@@ -1296,6 +1296,8 @@ "use strict";

// src/lib/utils/version.ts
var VERSION = true ? "4.2.0-alpha.5" : "latest";
var VERSION = true ? "4.2.0-alpha.6" : "latest";
// src/terrain-loader.ts
var TerrainLoader = {
dataType: null,
batchType: null,
name: "Terrain",

@@ -1326,2 +1328,5 @@ id: "terrain",

var QuantizedMeshLoader = {
dataType: null,
// Mesh,
batchType: null,
name: "Quantized Mesh",

@@ -1328,0 +1333,0 @@ id: "quantized-mesh",

{
"name": "@loaders.gl/terrain",
"version": "4.2.0-alpha.6",
"version": "4.2.0-beta.1",
"description": "Framework-independent loader for terrain raster formats",

@@ -46,5 +46,5 @@ "license": "MIT",

"dependencies": {
"@loaders.gl/images": "4.2.0-alpha.6",
"@loaders.gl/loader-utils": "4.2.0-alpha.6",
"@loaders.gl/schema": "4.2.0-alpha.6",
"@loaders.gl/images": "4.2.0-beta.1",
"@loaders.gl/loader-utils": "4.2.0-beta.1",
"@loaders.gl/schema": "4.2.0-beta.1",
"@mapbox/martini": "^0.2.0"

@@ -55,3 +55,3 @@ },

},
"gitHead": "37bd8ca71763529f18727ee4bf29dd176aa914ca"
"gitHead": "c386a9196516fe3ff24847b40e6c77be039cf905"
}

@@ -20,6 +20,6 @@ // loaders.gl

export const TerrainLoader: LoaderWithParser<any, never, TerrainLoaderOptions> = {
export const TerrainLoader = {
...TerrainWorkerLoader,
parse: parseTerrain
};
} as const satisfies LoaderWithParser<any, never, TerrainLoaderOptions>;

@@ -50,3 +50,3 @@ export async function parseTerrain(

*/
export const QuantizedMeshLoader: LoaderWithParser<any, never, QuantizedMeshLoaderOptions> = {
export const QuantizedMeshLoader = {
...QuantizedMeshWorkerLoader,

@@ -56,2 +56,2 @@ parseSync: (arrayBuffer, options) => parseQuantizedMesh(arrayBuffer, options?.['quantized-mesh']),

parseQuantizedMesh(arrayBuffer, options?.['quantized-mesh'])
};
} as const satisfies LoaderWithParser<any, never, QuantizedMeshLoaderOptions>;

@@ -8,6 +8,10 @@ // loaders.gl

/** QuantizedMeshLoader options */
export type QuantizedMeshLoaderOptions = LoaderOptions & {
/** QuantizedMeshLoader options */
'quantized-mesh'?: {
bounds?: [number, number, number, number];
skirtHeight?: number | null;
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
workerUrl?: string;
};

@@ -19,3 +23,6 @@ };

*/
export const QuantizedMeshLoader: Loader<any, never, QuantizedMeshLoaderOptions> = {
export const QuantizedMeshLoader = {
dataType: null as unknown as any, // Mesh,
batchType: null as never,
name: 'Quantized Mesh',

@@ -34,2 +41,2 @@ id: 'quantized-mesh',

}
};
} as const satisfies Loader<any, never, QuantizedMeshLoaderOptions>;

@@ -12,4 +12,9 @@ // loaders.gl

/** TerrainLoader options */
export type TerrainLoaderOptions = ImageLoaderOptions & {
terrain?: TerrainOptions;
/** TerrainLoader options */
terrain?: TerrainOptions & {
/** Override the URL to the worker bundle (by default loads from unpkg.com) */
workerUrl?: string;
};
};

@@ -20,3 +25,6 @@

*/
export const TerrainLoader: Loader<Mesh, never, TerrainLoaderOptions> = {
export const TerrainLoader = {
dataType: null as unknown as Mesh,
batchType: null as never,
name: 'Terrain',

@@ -43,2 +51,2 @@ id: 'terrain',

}
};
} as const satisfies Loader<Mesh, never, TerrainLoaderOptions>;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc