@loaders.gl/terrain
Advanced tools
Comparing version 2.1.0-alpha.4 to 2.1.0-alpha.5
@@ -100,5 +100,5 @@ (function webpackUniversalModuleDefinition(root, factory) { | ||
/***/ "../../node_modules/@mapbox/martini/index.js": | ||
/*!*******************************************************************************!*\ | ||
!*** /Users/missx/Documents/loaders.gl/node_modules/@mapbox/martini/index.js ***! | ||
\*******************************************************************************/ | ||
/*!***************************************************************************!*\ | ||
!*** /Users/xintong/dev/loaders.gl/node_modules/@mapbox/martini/index.js ***! | ||
\***************************************************************************/ | ||
/*! exports provided: default */ | ||
@@ -474,3 +474,3 @@ /***/ (function(module, __webpack_exports__, __webpack_require__) { | ||
const VERSION = true ? "2.1.0-alpha.4" : undefined; | ||
const VERSION = true ? "2.1.0-alpha.5" : undefined; | ||
@@ -477,0 +477,0 @@ const TerrainWorkerLoader = { |
@@ -1,1 +0,1 @@ | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(){return 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}return 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=0)}([function(e,t,r){(function(t){const n=r(2),o="undefined"==typeof window?t:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,n)}).call(this,r(1))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";r.r(t);class n{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,o=0,i=0,a=0,s=0,c=0;for(1&r?i=a=s=t:n=o=c=t;(r>>=1)>1;){const e=n+i>>1,t=o+a>>1;1&r?(i=n,a=o,n=s,o=c):(n=i,o=a,i=s,a=c),s=e,c=t}const l=4*e;this.coords[l+0]=n,this.coords[l+1]=o,this.coords[l+2]=i,this.coords[l+3]=a}}createTile(e){return new o(e,this)}}class o{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:o,errors:i}=this;for(let a=e-1;a>=0;a--){const e=4*a,s=r[e+0],c=r[e+1],l=r[e+2],u=r[e+3],f=s+l>>1,d=c+u>>1,h=f+d-c,g=d+s-f,p=(o[c*n+s]+o[u*n+l])/2,m=d*n+f,w=Math.abs(p-o[m]);if(i[m]=Math.max(i[m],w),a<t){const e=(c+g>>1)*n+(s+h>>1),t=(u+g>>1)*n+(l+h>>1);i[m]=Math.max(i[m],i[e],i[t])}}}getMesh(e=0){const{gridSize:t,indices:r}=this.martini,{errors:n}=this;let o=0,i=0;const a=t-1;function s(a,c,l,u,f,d){const h=a+l>>1,g=c+u>>1;Math.abs(a-f)+Math.abs(c-d)>1&&n[g*t+h]>e?(s(f,d,a,c,h,g),s(l,u,f,d,h,g)):(r[c*t+a]=r[c*t+a]||++o,r[u*t+l]=r[u*t+l]||++o,r[d*t+f]=r[d*t+f]||++o,i++)}r.fill(0),s(0,0,a,a,a,0),s(a,a,0,0,0,a);const c=new Uint16Array(2*o),l=new Uint32Array(3*i);let u=0;function f(o,i,a,s,d,h){const g=o+a>>1,p=i+s>>1;if(Math.abs(o-d)+Math.abs(i-h)>1&&n[p*t+g]>e)f(d,h,o,i,g,p),f(a,s,d,h,g,p);else{const e=r[i*t+o]-1,n=r[s*t+a]-1,f=r[h*t+d]-1;c[2*e]=o,c[2*e+1]=i,c[2*n]=a,c[2*n+1]=s,c[2*f]=d,c[2*f+1]=h,l[u++]=e,l[u++]=n,l[u++]=f}}return f(0,0,a,a,a,0),f(a,a,0,0,0,a),{vertices:c,triangles:l}}}function i(e,t,r,n){const o=r+1,i=e.length/2,a=new Float32Array(3*i),s=new Float32Array(2*i),[c,l,u,f]=n||[0,0,r,r],d=(u-c)/r,h=(f-l)/r;for(let n=0;n<i;n++){const i=e[2*n],l=e[2*n+1],u=l*o+i;a[3*n+0]=i*d+c,a[3*n+1]=-l*h+f,a[3*n+2]=t[u],s[2*n+0]=i/r,s[2*n+1]=l/r}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:s,size:2}}}function a(e,t){if(null===e)return null;const{meshMaxError:r,bounds:o,elevationDecoder:a}=t,s=e.data,c=e.width,l=c+1,u=function(e,t,r){const{rScaler:n,bScaler:o,gScaler:i,offset:a}=r,s=t+1,c=new Float32Array(s*s);for(let r=0,s=0;s<t;s++)for(let l=0;l<t;l++,r++){const t=4*r,l=e[t+0],u=e[t+1],f=e[t+2];c[r+s]=l*n+u*i+f*o+a}for(let e=s*(s-1),t=0;t<s-1;t++,e++)c[e]=c[e-s];for(let e=s-1,t=0;t<s;t++,e+=s)c[e]=c[e-1];return c}(s,c,a),f=new n(l).createTile(u),{vertices:d,triangles:h}=f.getMesh(r);return{loaderData:{header:{}},header:{vertexCount:h.length},mode:4,indices:{value:h,size:1},attributes:i(d,u,c,o)}}const s={id:"terrain",name:"Terrain",version:"2.1.0-alpha.4",extensions:["png","pngraw"],mimeType:"image/png",options:{terrain:{workerUrl:"https://unpkg.com/@loaders.gl/terrain@2.1.0-alpha.4/dist/terrain-loader.worker.js",meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0}}}},c={...s,parse:async function(e,t,r){return t.image=t.image||{},t.image.type="data",a(await r.parse(e,t,t.baseUri),t.terrain)}};r.d(t,"TerrainLoader",(function(){return c})),r.d(t,"TerrainWorkerLoader",(function(){return s}))}])})); | ||
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var r=t();for(var n in r)("object"==typeof exports?exports:e)[n]=r[n]}}(window,(function(){return 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}return 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=0)}([function(e,t,r){(function(t){const n=r(2),o="undefined"==typeof window?t:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,n)}).call(this,r(1))},function(e,t){var r;r=function(){return this}();try{r=r||new Function("return this")()}catch(e){"object"==typeof window&&(r=window)}e.exports=r},function(e,t,r){"use strict";r.r(t);class n{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,o=0,i=0,a=0,s=0,c=0;for(1&r?i=a=s=t:n=o=c=t;(r>>=1)>1;){const e=n+i>>1,t=o+a>>1;1&r?(i=n,a=o,n=s,o=c):(n=i,o=a,i=s,a=c),s=e,c=t}const l=4*e;this.coords[l+0]=n,this.coords[l+1]=o,this.coords[l+2]=i,this.coords[l+3]=a}}createTile(e){return new o(e,this)}}class o{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:o,errors:i}=this;for(let a=e-1;a>=0;a--){const e=4*a,s=r[e+0],c=r[e+1],l=r[e+2],u=r[e+3],f=s+l>>1,d=c+u>>1,h=f+d-c,g=d+s-f,p=(o[c*n+s]+o[u*n+l])/2,m=d*n+f,w=Math.abs(p-o[m]);if(i[m]=Math.max(i[m],w),a<t){const e=(c+g>>1)*n+(s+h>>1),t=(u+g>>1)*n+(l+h>>1);i[m]=Math.max(i[m],i[e],i[t])}}}getMesh(e=0){const{gridSize:t,indices:r}=this.martini,{errors:n}=this;let o=0,i=0;const a=t-1;function s(a,c,l,u,f,d){const h=a+l>>1,g=c+u>>1;Math.abs(a-f)+Math.abs(c-d)>1&&n[g*t+h]>e?(s(f,d,a,c,h,g),s(l,u,f,d,h,g)):(r[c*t+a]=r[c*t+a]||++o,r[u*t+l]=r[u*t+l]||++o,r[d*t+f]=r[d*t+f]||++o,i++)}r.fill(0),s(0,0,a,a,a,0),s(a,a,0,0,0,a);const c=new Uint16Array(2*o),l=new Uint32Array(3*i);let u=0;function f(o,i,a,s,d,h){const g=o+a>>1,p=i+s>>1;if(Math.abs(o-d)+Math.abs(i-h)>1&&n[p*t+g]>e)f(d,h,o,i,g,p),f(a,s,d,h,g,p);else{const e=r[i*t+o]-1,n=r[s*t+a]-1,f=r[h*t+d]-1;c[2*e]=o,c[2*e+1]=i,c[2*n]=a,c[2*n+1]=s,c[2*f]=d,c[2*f+1]=h,l[u++]=e,l[u++]=n,l[u++]=f}}return f(0,0,a,a,a,0),f(a,a,0,0,0,a),{vertices:c,triangles:l}}}function i(e,t,r,n){const o=r+1,i=e.length/2,a=new Float32Array(3*i),s=new Float32Array(2*i),[c,l,u,f]=n||[0,0,r,r],d=(u-c)/r,h=(f-l)/r;for(let n=0;n<i;n++){const i=e[2*n],l=e[2*n+1],u=l*o+i;a[3*n+0]=i*d+c,a[3*n+1]=-l*h+f,a[3*n+2]=t[u],s[2*n+0]=i/r,s[2*n+1]=l/r}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:s,size:2}}}function a(e,t){if(null===e)return null;const{meshMaxError:r,bounds:o,elevationDecoder:a}=t,s=e.data,c=e.width,l=c+1,u=function(e,t,r){const{rScaler:n,bScaler:o,gScaler:i,offset:a}=r,s=t+1,c=new Float32Array(s*s);for(let r=0,s=0;s<t;s++)for(let l=0;l<t;l++,r++){const t=4*r,l=e[t+0],u=e[t+1],f=e[t+2];c[r+s]=l*n+u*i+f*o+a}for(let e=s*(s-1),t=0;t<s-1;t++,e++)c[e]=c[e-s];for(let e=s-1,t=0;t<s;t++,e+=s)c[e]=c[e-1];return c}(s,c,a),f=new n(l).createTile(u),{vertices:d,triangles:h}=f.getMesh(r);return{loaderData:{header:{}},header:{vertexCount:h.length},mode:4,indices:{value:h,size:1},attributes:i(d,u,c,o)}}const s={id:"terrain",name:"Terrain",version:"2.1.0-alpha.5",extensions:["png","pngraw"],mimeType:"image/png",options:{terrain:{workerUrl:"https://unpkg.com/@loaders.gl/terrain@2.1.0-alpha.5/dist/terrain-loader.worker.js",meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0}}}},c={...s,parse:async function(e,t,r){return t.image=t.image||{},t.image.type="data",a(await r.parse(e,t,t.baseUri),t.terrain)}};r.d(t,"TerrainLoader",(function(){return c})),r.d(t,"TerrainWorkerLoader",(function(){return s}))}])})); |
@@ -18,3 +18,3 @@ "use strict"; | ||
var VERSION = typeof "2.1.0-alpha.4" !== 'undefined' ? "2.1.0-alpha.4" : 'latest'; | ||
var VERSION = typeof "2.1.0-alpha.5" !== 'undefined' ? "2.1.0-alpha.5" : 'latest'; | ||
var TerrainWorkerLoader = { | ||
@@ -21,0 +21,0 @@ id: 'terrain', |
@@ -8,3 +8,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import loadTerrain from './lib/parse-terrain'; | ||
const VERSION = typeof "2.1.0-alpha.4" !== 'undefined' ? "2.1.0-alpha.4" : 'latest'; | ||
const VERSION = typeof "2.1.0-alpha.5" !== 'undefined' ? "2.1.0-alpha.5" : 'latest'; | ||
export const TerrainWorkerLoader = { | ||
@@ -11,0 +11,0 @@ id: 'terrain', |
@@ -8,3 +8,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
import loadTerrain from './lib/parse-terrain'; | ||
var VERSION = typeof "2.1.0-alpha.4" !== 'undefined' ? "2.1.0-alpha.4" : 'latest'; | ||
var VERSION = typeof "2.1.0-alpha.5" !== 'undefined' ? "2.1.0-alpha.5" : 'latest'; | ||
export var TerrainWorkerLoader = { | ||
@@ -11,0 +11,0 @@ id: 'terrain', |
@@ -1,1 +0,1 @@ | ||
!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=9)}([function(t,e,r){t.exports=r(5)},function(t,e){function r(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function s(t){r(a,o,i,s,c,"next",t)}function c(t){r(a,o,i,s,c,"throw",t)}s(void 0)}))}}},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},function(t,e){function r(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=r=function(t){return typeof t}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(e)}t.exports=r},function(t,e,r){var n=r(6),o=r(7),i=r(8);t.exports=function(t,e){return n(t)||o(t,e)||i()}},function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new L(n||[]);return i._invoke=function(t,e,r){var n=f;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=S(a,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var c=u(t,e,r);if("normal"===c.type){if(n=r.done?h:l,c.arg===y)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=h,r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f="suspendedStart",l="suspendedYield",p="executing",h="completed",y={};function d(){}function v(){}function g(){}var m={};m[i]=function(){return this};var b=Object.getPrototypeOf,w=b&&b(b(k([])));w&&w!==r&&n.call(w,i)&&(m=w);var x=g.prototype=d.prototype=Object.create(m);function O(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function j(t){var e;this._invoke=function(r,o){function i(){return new Promise((function(e,i){!function e(r,o,i,a){var s=u(t[r],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?Promise.resolve(f.__await).then((function(t){e("next",t,i,a)}),(function(t){e("throw",t,i,a)})):Promise.resolve(f).then((function(t){c.value=t,i(c)}),(function(t){return e("throw",t,i,a)}))}a(s.arg)}(r,o,e,i)}))}return e=e?e.then(i,i):i()}}function S(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,S(t,r),"throw"===r.method))return y;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var o=u(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function k(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:T}}function T(){return{value:e,done:!0}}return v.prototype=x.constructor=g,g.constructor=v,g[s]=v.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},O(j.prototype),j.prototype[a]=function(){return this},t.AsyncIterator=j,t.async=function(e,r,n,o){var i=new j(c(e,r,n,o));return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},O(x),x[s]="Generator",x[i]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(P),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==s.return||s.return()}finally{if(o)throw i}}return r}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,r){"use strict";r.r(e);var n=r(2),o=r.n(n),i=r(0),a=r.n(i),s=r(1),c=r.n(s),u=r(4),f=r.n(u);class l{constructor(t=257){this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let t=0;t<this.numTriangles;t++){let r=t+2,n=0,o=0,i=0,a=0,s=0,c=0;for(1&r?i=a=s=e:n=o=c=e;(r>>=1)>1;){const t=n+i>>1,e=o+a>>1;1&r?(i=n,a=o,n=s,o=c):(n=i,o=a,i=s,a=c),s=t,c=e}const u=4*t;this.coords[u+0]=n,this.coords[u+1]=o,this.coords[u+2]=i,this.coords[u+3]=a}}createTile(t){return new p(t,this)}}class p{constructor(t,e){const r=e.gridSize;if(t.length!==r*r)throw new Error(`Expected terrain data of length ${r*r} (${r} x ${r}), got ${t.length}.`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:r,gridSize:n}=this.martini,{terrain:o,errors:i}=this;for(let a=t-1;a>=0;a--){const t=4*a,s=r[t+0],c=r[t+1],u=r[t+2],f=r[t+3],l=s+u>>1,p=c+f>>1,h=l+p-c,y=p+s-l,d=(o[c*n+s]+o[f*n+u])/2,v=p*n+l,g=Math.abs(d-o[v]);if(i[v]=Math.max(i[v],g),a<e){const t=(c+y>>1)*n+(s+h>>1),e=(f+y>>1)*n+(u+h>>1);i[v]=Math.max(i[v],i[t],i[e])}}}getMesh(t=0){const{gridSize:e,indices:r}=this.martini,{errors:n}=this;let o=0,i=0;const a=e-1;function s(a,c,u,f,l,p){const h=a+u>>1,y=c+f>>1;Math.abs(a-l)+Math.abs(c-p)>1&&n[y*e+h]>t?(s(l,p,a,c,h,y),s(u,f,l,p,h,y)):(r[c*e+a]=r[c*e+a]||++o,r[f*e+u]=r[f*e+u]||++o,r[p*e+l]=r[p*e+l]||++o,i++)}r.fill(0),s(0,0,a,a,a,0),s(a,a,0,0,0,a);const c=new Uint16Array(2*o),u=new Uint32Array(3*i);let f=0;function l(o,i,a,s,p,h){const y=o+a>>1,d=i+s>>1;if(Math.abs(o-p)+Math.abs(i-h)>1&&n[d*e+y]>t)l(p,h,o,i,y,d),l(a,s,p,h,y,d);else{const t=r[i*e+o]-1,n=r[s*e+a]-1,l=r[h*e+p]-1;c[2*t]=o,c[2*t+1]=i,c[2*n]=a,c[2*n+1]=s,c[2*l]=p,c[2*l+1]=h,u[f++]=t,u[f++]=n,u[f++]=l}}return l(0,0,a,a,a,0),l(a,a,0,0,0,a),{vertices:c,triangles:u}}}function h(t,e,r,n){for(var o=r+1,i=t.length/2,a=new Float32Array(3*i),s=new Float32Array(2*i),c=n||[0,0,r,r],u=f()(c,4),l=u[0],p=u[1],h=u[2],y=u[3],d=(h-l)/r,v=(y-p)/r,g=0;g<i;g++){var m=t[2*g],b=t[2*g+1],w=b*o+m;a[3*g+0]=m*d+l,a[3*g+1]=-b*v+y,a[3*g+2]=e[w],s[2*g+0]=m/r,s[2*g+1]=b/r}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:s,size:2}}}function y(t,e){if(null===t)return null;var r=e.meshMaxError,n=e.bounds,o=e.elevationDecoder,i=t.data,a=t.width,s=a+1,c=function(t,e,r){for(var n=r.rScaler,o=r.bScaler,i=r.gScaler,a=r.offset,s=e+1,c=new Float32Array(s*s),u=0,f=0;f<e;f++)for(var l=0;l<e;l++,u++){var p=4*u,h=t[p+0],y=t[p+1],d=t[p+2];c[u+f]=h*n+y*i+d*o+a}for(var v=s*(s-1),g=0;g<s-1;g++,v++)c[v]=c[v-s];for(var m=s-1,b=0;b<s;b++,m+=s)c[m]=c[m-1];return c}(i,a,o),u=new l(s).createTile(c).getMesh(r),f=u.vertices,p=u.triangles;return{loaderData:{header:{}},header:{vertexCount:p.length},mode:4,indices:{value:p,size:1},attributes:h(f,c,a,n)}}function d(){return(d=c()(a.a.mark((function t(e,r,n){var o;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.image=r.image||{},r.image.type="data",t.next=4,n.parse(e,r,r.baseUri);case 4:return o=t.sent,t.abrupt("return",y(o,r.terrain));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function v(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}var g=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?v(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},{id:"terrain",name:"Terrain",version:"2.1.0-alpha.4",extensions:["png","pngraw"],mimeType:"image/png",options:{terrain:{workerUrl:"https://unpkg.com/@loaders.gl/terrain@".concat("2.1.0-alpha.4","/dist/terrain-loader.worker.js"),meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0}}}},{parse:function(t,e,r){return d.apply(this,arguments)}}),m=r(3),b=r.n(m);function w(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0,n=r||new Set;if(t){if(x(t))n.add(t);else if(x(t.buffer))n.add(t.buffer);else if(e&&"object"===b()(t))for(var o in t)w(t[o],e,n)}else;return void 0===r?Array.from(n):null}function x(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}var O="2.1.0-alpha.4";function j(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O;!function(t,e){if(!t)throw new Error(e||"loader assertion failed.")}(t,"no loader provided");var r=t.version;e&&r&&(e=S(e),r=S(r))}function S(t){var e=t.split(".").map(Number);return{major:e[0],minor:e[1]}}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function P(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function L(t){return k.apply(this,arguments)}function k(){return(k=c()(a.a.mark((function t(e){var r,n,o,i,s,c,u;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.loader,n=e.arraybuffer,e.byteOffset,e.byteLength,o=e.options,i=e.context,!r.parseSync&&!r.parse){t.next=6;break}s=n,c=r.parseSync||r.parse,t.next=13;break;case 6:if(!r.parseTextSync){t.next=12;break}u=new TextDecoder,s=u.decode(n),c=r.parseTextSync,t.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return o=P({},o,{modules:r&&r.options&&r.options.modules||{},worker:!1}),t.next=16,c(s,P({},o),i,r);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function T(t,e){return t&&"parse"===t.type&&t.source&&t.source.startsWith("loaders.gl")}!function(t){if("undefined"!=typeof self){var e=0,r=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((function(o,i){var a=e++;self.addEventListener("message",(function t(e){var r=e.data;if(r&&r.id===a)switch(r.type){case"parse-done":self.removeEventListener("message",t),o(r.result);break;case"parse-error":self.removeEventListener("message",t),i(r.message)}})),self.postMessage({type:"parse",id:a,arraybuffer:t,options:r,url:n},[t])}))};self.onmessage=function(){var e=c()(a.a.mark((function e(n){var o,i,s,c,u,f,l,p,h,y;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.data,e.prev=1,T(o,t.name)){e.next=4;break}return e.abrupt("return");case 4:return j(t,o.source.split("@")[1]),i=o.arraybuffer,s=o.byteOffset,c=void 0===s?0:s,u=o.byteLength,f=void 0===u?0:u,l=o.options,p=void 0===l?{}:l,e.next=8,L({loader:t,arraybuffer:i,byteOffset:c,byteLength:f,options:p,context:{parse:r}});case 8:h=e.sent,y=w(h),self.postMessage({type:"done",result:h},y),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),self.postMessage({type:"error",message:e.t0.message});case 16:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(t){return e.apply(this,arguments)}}()}}(g)}]); | ||
!function(t){var e={};function r(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)r.d(n,o,function(e){return t[e]}.bind(null,o));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=9)}([function(t,e,r){t.exports=r(5)},function(t,e){function r(t,e,r,n,o,i,a){try{var s=t[i](a),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}t.exports=function(t){return function(){var e=this,n=arguments;return new Promise((function(o,i){var a=t.apply(e,n);function s(t){r(a,o,i,s,c,"next",t)}function c(t){r(a,o,i,s,c,"throw",t)}s(void 0)}))}}},function(t,e){t.exports=function(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}},function(t,e){function r(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?t.exports=r=function(t){return typeof t}:t.exports=r=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},r(e)}t.exports=r},function(t,e,r){var n=r(6),o=r(7),i=r(8);t.exports=function(t,e){return n(t)||o(t,e)||i()}},function(t,e,r){var n=function(t){"use strict";var e,r=Object.prototype,n=r.hasOwnProperty,o="function"==typeof Symbol?Symbol:{},i=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",s=o.toStringTag||"@@toStringTag";function c(t,e,r,n){var o=e&&e.prototype instanceof d?e:d,i=Object.create(o.prototype),a=new L(n||[]);return i._invoke=function(t,e,r){var n=f;return function(o,i){if(n===p)throw new Error("Generator is already running");if(n===h){if("throw"===o)throw i;return T()}for(r.method=o,r.arg=i;;){var a=r.delegate;if(a){var s=S(a,r);if(s){if(s===y)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===f)throw n=h,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=p;var c=u(t,e,r);if("normal"===c.type){if(n=r.done?h:l,c.arg===y)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n=h,r.method="throw",r.arg=c.arg)}}}(t,r,a),i}function u(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f="suspendedStart",l="suspendedYield",p="executing",h="completed",y={};function d(){}function v(){}function g(){}var m={};m[i]=function(){return this};var b=Object.getPrototypeOf,w=b&&b(b(k([])));w&&w!==r&&n.call(w,i)&&(m=w);var x=g.prototype=d.prototype=Object.create(m);function O(t){["next","throw","return"].forEach((function(e){t[e]=function(t){return this._invoke(e,t)}}))}function j(t){var e;this._invoke=function(r,o){function i(){return new Promise((function(e,i){!function e(r,o,i,a){var s=u(t[r],t,o);if("throw"!==s.type){var c=s.arg,f=c.value;return f&&"object"==typeof f&&n.call(f,"__await")?Promise.resolve(f.__await).then((function(t){e("next",t,i,a)}),(function(t){e("throw",t,i,a)})):Promise.resolve(f).then((function(t){c.value=t,i(c)}),(function(t){return e("throw",t,i,a)}))}a(s.arg)}(r,o,e,i)}))}return e=e?e.then(i,i):i()}}function S(t,r){var n=t.iterator[r.method];if(n===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=e,S(t,r),"throw"===r.method))return y;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return y}var o=u(n,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,y;var i=o.arg;return i?i.done?(r[t.resultName]=i.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,y):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,y)}function E(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(E,this),this.reset(!0)}function k(t){if(t){var r=t[i];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,a=function r(){for(;++o<t.length;)if(n.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return a.next=a}}return{next:T}}function T(){return{value:e,done:!0}}return v.prototype=x.constructor=g,g.constructor=v,g[s]=v.displayName="GeneratorFunction",t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===v||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,g):(t.__proto__=g,s in t||(t[s]="GeneratorFunction")),t.prototype=Object.create(x),t},t.awrap=function(t){return{__await:t}},O(j.prototype),j.prototype[a]=function(){return this},t.AsyncIterator=j,t.async=function(e,r,n,o){var i=new j(c(e,r,n,o));return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},O(x),x[s]="Generator",x[i]=function(){return this},x.toString=function(){return"[object Generator]"},t.keys=function(t){var e=[];for(var r in t)e.push(r);return e.reverse(),function r(){for(;e.length;){var n=e.pop();if(n in t)return r.value=n,r.done=!1,r}return r.done=!0,r}},t.values=k,L.prototype={constructor:L,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method="next",this.arg=e,this.tryEntries.forEach(P),!t)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function o(n,o){return s.type="throw",s.arg=t,r.next=n,o&&(r.method="next",r.arg=e),!!o}for(var i=this.tryEntries.length-1;i>=0;--i){var a=this.tryEntries[i],s=a.completion;if("root"===a.tryLoc)return o("end");if(a.tryLoc<=this.prev){var c=n.call(a,"catchLoc"),u=n.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return o(a.catchLoc,!0);if(this.prev<a.finallyLoc)return o(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return o(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return o(a.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var i=o;break}}i&&("break"===t||"continue"===t)&&i.tryLoc<=e&&e<=i.finallyLoc&&(i=null);var a=i?i.completion:{};return a.type=t,a.arg=e,i?(this.method="next",this.next=i.finallyLoc,y):this.complete(a)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),y},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),y}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:k(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),y}},t}(t.exports);try{regeneratorRuntime=n}catch(t){Function("r","regeneratorRuntime = r")(n)}},function(t,e){t.exports=function(t){if(Array.isArray(t))return t}},function(t,e){t.exports=function(t,e){if(Symbol.iterator in Object(t)||"[object Arguments]"===Object.prototype.toString.call(t)){var r=[],n=!0,o=!1,i=void 0;try{for(var a,s=t[Symbol.iterator]();!(n=(a=s.next()).done)&&(r.push(a.value),!e||r.length!==e);n=!0);}catch(t){o=!0,i=t}finally{try{n||null==s.return||s.return()}finally{if(o)throw i}}return r}}},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}},function(t,e,r){"use strict";r.r(e);var n=r(2),o=r.n(n),i=r(0),a=r.n(i),s=r(1),c=r.n(s),u=r(4),f=r.n(u);class l{constructor(t=257){this.gridSize=t;const e=t-1;if(e&e-1)throw new Error(`Expected grid size to be 2^n+1, got ${t}.`);this.numTriangles=e*e*2-2,this.numParentTriangles=this.numTriangles-e*e,this.indices=new Uint32Array(this.gridSize*this.gridSize),this.coords=new Uint16Array(4*this.numTriangles);for(let t=0;t<this.numTriangles;t++){let r=t+2,n=0,o=0,i=0,a=0,s=0,c=0;for(1&r?i=a=s=e:n=o=c=e;(r>>=1)>1;){const t=n+i>>1,e=o+a>>1;1&r?(i=n,a=o,n=s,o=c):(n=i,o=a,i=s,a=c),s=t,c=e}const u=4*t;this.coords[u+0]=n,this.coords[u+1]=o,this.coords[u+2]=i,this.coords[u+3]=a}}createTile(t){return new p(t,this)}}class p{constructor(t,e){const r=e.gridSize;if(t.length!==r*r)throw new Error(`Expected terrain data of length ${r*r} (${r} x ${r}), got ${t.length}.`);this.terrain=t,this.martini=e,this.errors=new Float32Array(t.length),this.update()}update(){const{numTriangles:t,numParentTriangles:e,coords:r,gridSize:n}=this.martini,{terrain:o,errors:i}=this;for(let a=t-1;a>=0;a--){const t=4*a,s=r[t+0],c=r[t+1],u=r[t+2],f=r[t+3],l=s+u>>1,p=c+f>>1,h=l+p-c,y=p+s-l,d=(o[c*n+s]+o[f*n+u])/2,v=p*n+l,g=Math.abs(d-o[v]);if(i[v]=Math.max(i[v],g),a<e){const t=(c+y>>1)*n+(s+h>>1),e=(f+y>>1)*n+(u+h>>1);i[v]=Math.max(i[v],i[t],i[e])}}}getMesh(t=0){const{gridSize:e,indices:r}=this.martini,{errors:n}=this;let o=0,i=0;const a=e-1;function s(a,c,u,f,l,p){const h=a+u>>1,y=c+f>>1;Math.abs(a-l)+Math.abs(c-p)>1&&n[y*e+h]>t?(s(l,p,a,c,h,y),s(u,f,l,p,h,y)):(r[c*e+a]=r[c*e+a]||++o,r[f*e+u]=r[f*e+u]||++o,r[p*e+l]=r[p*e+l]||++o,i++)}r.fill(0),s(0,0,a,a,a,0),s(a,a,0,0,0,a);const c=new Uint16Array(2*o),u=new Uint32Array(3*i);let f=0;function l(o,i,a,s,p,h){const y=o+a>>1,d=i+s>>1;if(Math.abs(o-p)+Math.abs(i-h)>1&&n[d*e+y]>t)l(p,h,o,i,y,d),l(a,s,p,h,y,d);else{const t=r[i*e+o]-1,n=r[s*e+a]-1,l=r[h*e+p]-1;c[2*t]=o,c[2*t+1]=i,c[2*n]=a,c[2*n+1]=s,c[2*l]=p,c[2*l+1]=h,u[f++]=t,u[f++]=n,u[f++]=l}}return l(0,0,a,a,a,0),l(a,a,0,0,0,a),{vertices:c,triangles:u}}}function h(t,e,r,n){for(var o=r+1,i=t.length/2,a=new Float32Array(3*i),s=new Float32Array(2*i),c=n||[0,0,r,r],u=f()(c,4),l=u[0],p=u[1],h=u[2],y=u[3],d=(h-l)/r,v=(y-p)/r,g=0;g<i;g++){var m=t[2*g],b=t[2*g+1],w=b*o+m;a[3*g+0]=m*d+l,a[3*g+1]=-b*v+y,a[3*g+2]=e[w],s[2*g+0]=m/r,s[2*g+1]=b/r}return{POSITION:{value:a,size:3},TEXCOORD_0:{value:s,size:2}}}function y(t,e){if(null===t)return null;var r=e.meshMaxError,n=e.bounds,o=e.elevationDecoder,i=t.data,a=t.width,s=a+1,c=function(t,e,r){for(var n=r.rScaler,o=r.bScaler,i=r.gScaler,a=r.offset,s=e+1,c=new Float32Array(s*s),u=0,f=0;f<e;f++)for(var l=0;l<e;l++,u++){var p=4*u,h=t[p+0],y=t[p+1],d=t[p+2];c[u+f]=h*n+y*i+d*o+a}for(var v=s*(s-1),g=0;g<s-1;g++,v++)c[v]=c[v-s];for(var m=s-1,b=0;b<s;b++,m+=s)c[m]=c[m-1];return c}(i,a,o),u=new l(s).createTile(c).getMesh(r),f=u.vertices,p=u.triangles;return{loaderData:{header:{}},header:{vertexCount:p.length},mode:4,indices:{value:p,size:1},attributes:h(f,c,a,n)}}function d(){return(d=c()(a.a.mark((function t(e,r,n){var o;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r.image=r.image||{},r.image.type="data",t.next=4,n.parse(e,r,r.baseUri);case 4:return o=t.sent,t.abrupt("return",y(o,r.terrain));case 6:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function v(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}var g=function(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?v(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):v(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}({},{id:"terrain",name:"Terrain",version:"2.1.0-alpha.5",extensions:["png","pngraw"],mimeType:"image/png",options:{terrain:{workerUrl:"https://unpkg.com/@loaders.gl/terrain@".concat("2.1.0-alpha.5","/dist/terrain-loader.worker.js"),meshMaxError:10,elevationDecoder:{rScaler:1,gScaler:0,bScaler:0,offset:0}}}},{parse:function(t,e,r){return d.apply(this,arguments)}}),m=r(3),b=r.n(m);function w(t){var e=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=arguments.length>2?arguments[2]:void 0,n=r||new Set;if(t){if(x(t))n.add(t);else if(x(t.buffer))n.add(t.buffer);else if(e&&"object"===b()(t))for(var o in t)w(t[o],e,n)}else;return void 0===r?Array.from(n):null}function x(t){return!!t&&(t instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&t instanceof MessagePort||("undefined"!=typeof ImageBitmap&&t instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&t instanceof OffscreenCanvas)))}var O="2.1.0-alpha.5";function j(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:O;!function(t,e){if(!t)throw new Error(e||"loader assertion failed.")}(t,"no loader provided");var r=t.version;e&&r&&(e=S(e),r=S(r))}function S(t){var e=t.split(".").map(Number);return{major:e[0],minor:e[1]}}function E(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function P(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?E(Object(r),!0).forEach((function(e){o()(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):E(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function L(t){return k.apply(this,arguments)}function k(){return(k=c()(a.a.mark((function t(e){var r,n,o,i,s,c,u;return a.a.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e.loader,n=e.arraybuffer,e.byteOffset,e.byteLength,o=e.options,i=e.context,!r.parseSync&&!r.parse){t.next=6;break}s=n,c=r.parseSync||r.parse,t.next=13;break;case 6:if(!r.parseTextSync){t.next=12;break}u=new TextDecoder,s=u.decode(n),c=r.parseTextSync,t.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return o=P({},o,{modules:r&&r.options&&r.options.modules||{},worker:!1}),t.next=16,c(s,P({},o),i,r);case 16:return t.abrupt("return",t.sent);case 17:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function T(t,e){return t&&"parse"===t.type&&t.source&&t.source.startsWith("loaders.gl")}!function(t){if("undefined"!=typeof self){var e=0,r=function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2?arguments[2]:void 0;return new Promise((function(o,i){var a=e++;self.addEventListener("message",(function t(e){var r=e.data;if(r&&r.id===a)switch(r.type){case"parse-done":self.removeEventListener("message",t),o(r.result);break;case"parse-error":self.removeEventListener("message",t),i(r.message)}})),self.postMessage({type:"parse",id:a,arraybuffer:t,options:r,url:n},[t])}))};self.onmessage=function(){var e=c()(a.a.mark((function e(n){var o,i,s,c,u,f,l,p,h,y;return a.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(o=n.data,e.prev=1,T(o,t.name)){e.next=4;break}return e.abrupt("return");case 4:return j(t,o.source.split("@")[1]),i=o.arraybuffer,s=o.byteOffset,c=void 0===s?0:s,u=o.byteLength,f=void 0===u?0:u,l=o.options,p=void 0===l?{}:l,e.next=8,L({loader:t,arraybuffer:i,byteOffset:c,byteLength:f,options:p,context:{parse:r}});case 8:h=e.sent,y=w(h),self.postMessage({type:"done",result:h},y),e.next=16;break;case 13:e.prev=13,e.t0=e.catch(1),self.postMessage({type:"error",message:e.t0.message});case 16:case"end":return e.stop()}}),e,null,[[1,13]])})));return function(t){return e.apply(this,arguments)}}()}}(g)}]); |
{ | ||
"name": "@loaders.gl/terrain", | ||
"version": "2.1.0-alpha.4", | ||
"version": "2.1.0-alpha.5", | ||
"description": "Framework-independent loader for terrain raster formats", | ||
@@ -37,6 +37,6 @@ "license": "MIT", | ||
"@babel/runtime": "^7.3.1", | ||
"@loaders.gl/loader-utils": "2.1.0-alpha.4", | ||
"@loaders.gl/loader-utils": "2.1.0-alpha.5", | ||
"@mapbox/martini": "^0.2.0" | ||
}, | ||
"gitHead": "2a1c53d6311d82b9080c7aec124d80d23291d846" | ||
"gitHead": "de3b920ad0d80988cd5235217d238a32ec6ca12b" | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
99774
1
+ Added@loaders.gl/loader-utils@2.1.0-alpha.5(transitive)
- Removed@loaders.gl/loader-utils@2.1.0-alpha.4(transitive)