UNPKG

@arcgis/core

Version:

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

3 lines (2 loc) 2.65 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{acosClamped as t,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{set as r}from"../../../../core/libs/gl-matrix-2/math/mat2.js";import{create as e}from"../../../../core/libs/gl-matrix-2/factories/mat2f64.js";import{transformMat2 as s,set as h}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{UNIT_X as a,create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{dot as n,cross as m,scale as g,normalize as f,add as c,negate as l,subtract as u,copy as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Frame2D as M}from"./PathExtruder.js";class b{constructor(){this.vLeft=v(),this.vRight=v(),this.vMinSiblingLength=0,this.frame=new M}setFrameFromUpVector(t){p(this.frame.up,t),c(y,this.vLeft,this.vRight),f(y,y),g(I,this.frame.up,n(y,this.frame.up)),u(D,y,I),f(D,D),m(this.frame.right,D,this.frame.up)}get foldingAngle(){return Math.PI-this.rotationAngle}}class x extends b{get rotationFrameUp(){return this.frame.up}get rotationRight(){return a}get rotationAngle(){g(w,this.frame.up,n(this.frame.up,this.vLeft)),u(w,this.vLeft,w),l(w,w),f(w,w),g(P,this.frame.up,n(this.frame.up,this.vRight)),u(P,this.vRight,P),f(P,P),m(U,this.rotationFrameUp,this.vLeft);return Math.sign(n(U,this.vRight))*(Math.PI-t(n(w,P)))}get maxStretchDistance(){return Math.abs(this.vMinSiblingLength/Math.cos(.5*this.foldingAngle))}applyMiterStretch(t,r){const e=this.rotationAngle;if(Math.abs(e)<=0)return r;const s=i(Math.cos(.5*e));return h(t,(s-1+1)*r[0],r[1])}}class R extends b{get rotationFrameUp(){const t=Math.sign(n(this.frame.right,this.vRight));return m(A,this.vRight,this.vLeft),g(A,A,t),f(A,A)}get rotationRight(){const t=this.rotationFrameUp,i=n(t,this.frame.up),r=n(t,this.frame.right);return g(d,this.frame.up,-r),g(F,this.frame.right,i),c(d,d,F),f(d,d),L(S,this.frame,d),S}get rotationAngle(){const i=Math.sign(n(this.frame.right,this.vRight));return l(U,this.vLeft),-i*(Math.PI-t(n(U,this.vRight)))}get maxStretchDistance(){return Math.abs(this.vMinSiblingLength*i(Math.cos(.5*this.foldingAngle)))}applyMiterStretch(t,e){const h=this.rotationAngle;if(0===Math.abs(h))return e;const a=i(Math.cos(.5*h)),o=this.rotationRight,n=r(E,1+(a-1)*o[0]*o[0],(a-1)*o[0]*o[1],(a-1)*o[0]*o[1],1+(a-1)*o[1]*o[1]);return s(t,e,n)}}function L(t,i,r){h(t,n(r,i.right),n(r,i.up))}function j(t){switch(t){case 0:return new x;case 1:return new R}}const A=v(),S=o(),d=v(),F=v(),U=v(),w=v(),P=v(),I=v(),y=v(),D=v(),E=e();export{b as PathVertex,j as newPathVertex};