@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.27 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import{estimateNumberArrayMemory as t}from"../../../../core/memoryEstimations.js";import{fromValues as e,clone as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{pathNumCircleProfileSubdivisions as o}from"../../layers/graphics/Graphics3DPathSymbolLayerConstants.js";class r{constructor(){this.vertices=new Array,this.normals=new Array,this.indices=new Array,this.poles=new Array,this.poleIndices=new Array}addVertex(t,e){return this.vertices.push(s(t)),this.normals.push(s(e)),this.vertices.length-1}addPole(t,e=null){return this.poles.push({position:s(t),normal:e?s(e):null}),this.poles.length-1}addSegment(t,e=null){this.indices.push(t.v0),this.indices.push(t.v1),e&&(this.poleIndices.push(e.v0),this.poleIndices.push(e.v1))}get numSegments(){return this.indices.length/2}translate(t,e){for(const s of this.vertices)s[0]+=t,s[1]+=e;for(const s of this.poles)s.position[0]+=t,s.position[1]+=e}get usedMemory(){return this.vertices.length*t(this.vertices[0])*2+t(this.indices)}}const n={top:[0,-.5],bottom:[0,.5]};function i(t){const s=.5,i=o,d=new r,a={v0:0,v1:0};d.addPole(e(0,0));for(let o=0;o<i;++o){const t=2*o*Math.PI/i,r=Math.cos(t),n=Math.sin(t),a=e(r*s,n*s),c=e(r,n);d.addVertex(a,c)}for(let e=0;e<i-1;++e){const t={v0:e,v1:e+1};d.addSegment(t,a)}const c={v0:i-1,v1:0};if(d.addSegment(c,a),"center"!==t){const e=n[t];d.translate(e[0],e[1])}return d}const d={center:i("center"),top:i("top"),bottom:i("bottom")},a={center:c("center"),top:c("top"),bottom:c("bottom")};function c(t){const s=1,o=1,i=new r,d=e(-.5,-.5),a=e(.5*s,-.5),c=e(.5*s,.5*o),h=e(-.5,.5*o),l=e(0,-1),v=e(1,0),m=e(0,1),p=e(-1,0);if(i.addPole(e(0,.5*o),m),i.addPole(e(0,.5*o)),i.addPole(e(0,-.5)),i.addPole(e(0,-.5),l),i.addVertex(d,l),i.addVertex(a,l),i.addSegment({v0:0,v1:1},{v0:3,v1:3}),i.addVertex(a,v),i.addVertex(c,v),i.addSegment({v0:2,v1:3},{v0:2,v1:1}),i.addVertex(c,m),i.addVertex(h,m),i.addSegment({v0:4,v1:5},{v0:0,v1:0}),i.addVertex(h,p),i.addVertex(d,p),i.addSegment({v0:6,v1:7},{v0:1,v1:2}),"center"!==t){const e=n[t];i.translate(e[0],e[1])}return i}export{r as PathProfile,d as circleProfiles,a as quadProfiles};