UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 3.03 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__addDisposableResource as t,__disposeResources as s}from"tslib";import{getAssetUrl as r}from"../assets.js";import e from"../core/Error.js";import"../core/has.js";let o=null,i=null,n=null,l=null;const a=4;async function c(){return o??=d(),o}function h(){return null!==n}async function u(){return i??=b(),i}function y(){return null!==l}async function d(){const t=await import("../chunks/libtess-f32.js"),s=await t.default({locateFile:t=>r(`esri/core/libs/libtess/${t}`)});n=s}async function b(){const t=await import("../chunks/libtess-f64.js"),s=await t.default({locateFile:t=>r(`esri/core/libs/libtess/${t}`)});l=s}function f(r,o,i=2){const l={stack:[],error:void 0,hasError:!1};try{const s=n;if(!s)throw new e("mesh:not-loaded","libtessF32 not loaded");const c=t(l,C.from(s,r),!1),h=t(l,w.from(s,o),!1),u=a*(r.length/i),y=t(l,new C(s,u*i),!1),d=s.triangulate(c.ptr,h.ptr,h.size,i,y.ptr,u);0;return{buffer:y.slice(0,d*i),vertexCount:d}}catch(c){l.error=c,l.hasError=!0}finally{s(l)}}function p(r,o,i=2){const n={stack:[],error:void 0,hasError:!1};try{const s=l;if(!s)throw new e("mesh:not-loaded","libtessF64 not loaded");const c=t(n,P.from(s,r),!1),h=t(n,w.from(s,o),!1),u=a*(r.length/i),y=t(n,new P(s,u*i),!1),d=s.triangulate(c.ptr,h.ptr,h.size,i,y.ptr,u);0;return{buffer:y.slice(0,d*i),vertexCount:d}}catch(c){n.error=c,n.hasError=!0}finally{s(n)}}function E(t){return t.HEAPF64}function m(t){return t.HEAPF32}function _(t){return t.HEAP32}class C{static from(t,s){const r=new C(t,s.length);return r.set(s),r}constructor(t,s){this._libtess=t,this.size=s,this.ptr=t.allocateCoordinateArray(s)}destroy(){this._libtess.destroyCoordinateArray(this.ptr)}[Symbol.dispose](){this.destroy()}get bytesPerCoordinate(){return Float32Array.BYTES_PER_ELEMENT}set(t){m(this._libtess).set(t,this.ptr/this.bytesPerCoordinate)}slice(t,s){const r=this.ptr/this.bytesPerCoordinate;return m(this._libtess).slice(r+t,r+s)}}class P{static from(t,s){const r=new P(t,s.length);return r.set(s),r}constructor(t,s){this._libtess=t,this.size=s,this.ptr=t.allocateCoordinateArray(s)}destroy(){this._libtess.destroyCoordinateArray(this.ptr)}[Symbol.dispose](){this.destroy()}get bytesPerCoordinate(){return Float64Array.BYTES_PER_ELEMENT}set(t){E(this._libtess).set(t,this.ptr/this.bytesPerCoordinate)}slice(t,s){const r=this.ptr/this.bytesPerCoordinate;return E(this._libtess).slice(r+t,r+s)}}class w{static from(t,s){const r=new w(t,s.length);return r.set(s),r}constructor(t,s){this._libtess=t,this.size=s,this.ptr=t.allocateLengthsArray(s)}destroy(){this._libtess.destroyLengthsArray(this.ptr)}[Symbol.dispose](){this.destroy()}get bytesPerCoordinate(){return Int32Array.BYTES_PER_ELEMENT}set(t){_(this._libtess).set(t,this.ptr/this.bytesPerCoordinate)}slice(t,s){const r=this.ptr/this.bytesPerCoordinate;return _(this._libtess).slice(r+t,r+s)}}export{h as isLibtessF32Loaded,y as isLibtessF64Loaded,c as loadLibtessF32,u as loadLibtessF64,f as triangulateF32,p as triangulateF64};