@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.31 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.32/esri/copyright.txt for details.
*/
import{c as t,i as e,g as r,l as s,n as o,e as i}from"../../../../chunks/vec32.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,fromPositionAndNormal as f,intersectRay as p}from"../../../../geometry/support/plane.js";import{wrap as c}from"../../../../geometry/support/ray.js";import{makeOrthoBasisDirUpFallback as g}from"./GeometryUtil.js";function l(l,v){let h=null;const u=l.vertices.length,j=.99619469809,R=m(),y=m(),x=m(),L=m(),b=m(),k=m(),q=a();let G=l.vertices[0];t(y,v),e(R,0,1,0),g(G.vRight,y,R,R,x,y,j),t(G.frame.up,y),t(G.frame.right,x);const M=l.positions;let U=l.offset;h=G;for(let m=1;m<u;++m){G=l.vertices[m],r(b,G.vLeft,G.vRight);let a=s(b);a>0?(a=1/Math.sqrt(a),b[0]=b[0]*a,b[1]=b[1]*a,b[2]=b[2]*a):(b[0]=G.vRight[0],b[1]=G.vRight[1],b[2]=G.vRight[2]),k[0]=M[U]+h.frame.up[0],k[1]=M[U+1]+h.frame.up[1],k[2]=M[U+2]+h.frame.up[2],U+=3;const v=e(n,M[U],M[U+1],M[U+2]);f(v,b,q);p(q,c(k,G.vLeft),L)?(L[0]-=M[U],L[1]-=M[U+1],L[2]-=M[U+2],o(y,L),i(x,b,y),o(x,x)):g(b,h.frame.up,h.frame.right,R,x,y,j),t(G.frame.up,y),t(G.frame.right,x),h=G}}const n=m();export{l as computeMinimumRotationTangentFrame};