UNPKG

@arcgis/core

Version:

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

6 lines (5 loc) 1.61 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.33/esri/copyright.txt for details. */ import{baseTypedArrayMemory as t,baseArrayMemory as i,estimateNumberMemory as e}from"../../../../core/memoryEstimations.js";import{isTypedArray as s}from"../../../../core/typedArrayUtil.js";import{l as o,n as h,c as r}from"../../../../chunks/vec32.js";import{fromValues as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";class f{constructor(t,i,e,s,o){this.vertices=t,this.positionsES=i,this.offset=s,this.positions=o;const h=t.length,r=Math.floor(h/2),f=this.offset+3*r,g=e[f],v=e[f+1],c=e[f+2];this.origin=n(g,v,c);const l=this.offset+3*h;for(let n=this.offset;n<l;n+=3)o[n]=e[n]-g,o[n+1]=e[n+1]-v,o[n+2]=e[n+2]-c;this.updatePathVertexInformation()}get usedMemory(){return this._getSharedBufferSliceMemory(this.positions)}_getSharedBufferSliceMemory(o){return s(o)?(0===this.offset?t:0)+3*this.vertices.length*o.BYTES_PER_ELEMENT:(0===this.offset?i:0)+3*this.vertices.length*e}updatePathVertexInformation(){const t=this.vertices.length,i=this.vertices[0];let e=this.offset;const s=this.positions;i.vRight[0]=s[e+3]-s[e],i.vRight[1]=s[e+4]-s[e+1],i.vRight[2]=s[e+5]-s[e+2],e+=3;let n=o(i.vRight);i.vMinSiblingLength=n,h(i.vRight,i.vRight);let f=i;for(let g=1;g<t;++g){const i=this.vertices[g];if(i.vLeft=f.vRight,g<t-1){i.vRight[0]=s[e+3]-s[e],i.vRight[1]=s[e+4]-s[e+1],i.vRight[2]=s[e+5]-s[e+2];const t=o(i.vRight);i.vMinSiblingLength=Math.min(n,t),n=t,h(i.vRight,i.vRight)}else r(i.vRight,i.vLeft),i.vMinSiblingLength=n;f=i,e+=3}}}export{f as Path};