@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 2.85 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{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as e,e as s,d as i,g as a,f as m,c as n,b as c,n as l,h as f}from"../../../../chunks/vec32.js";import{create as I}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as h}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as p}from"../../../../geometry/projection/projectors.js";import{newDoubleArray as N}from"../../../../geometry/support/DoubleArray.js";import{fromArray as g,getNormal as b,create as u}from"../../../../geometry/support/plane.js";import{ViewingMode as j}from"../../../ViewingMode.js";function T(t,r,e,s,i=1){if(e.isGeographic&&s===j.Global){const t=N(r.length),o=r.length,s=h(e);for(let e=0;e<o;e+=3)p(r,e,t,e,s);r=t}o(y,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);for(let o=0;o<r.length;o+=3)y[0]=Math.min(y[0],r[o]),y[1]=Math.min(y[1],r[o+1]);const a=y[0]%i,m=y[1]%i,n=y[0]-a,c=y[1]-m;for(let o=0;o<r.length;o+=3){const e=o/3*4;t[e]=(r[o]-n)/i,t[e+1]=(r[o+1]-c)/i,t[e+2]=n/i,t[e+3]=c/i}}function M(t,r,n,c,l=1){e(F,1,0,0),e(Y,0,1,0),e(_,0,0,1),D(x,n),g(V,n)&&O(V,F,Y,_,c,x),o(y,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),o(P,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(let o=0;o<n.length;o+=3){e(E,n[o],n[o+1],n[o+2]);const t=s(F,E),r=s(Y,E);y[0]=Math.min(y[0],t),y[1]=Math.min(y[1],r),P[0]=Math.max(P[0],t),P[1]=Math.max(P[1],r)}const f=s(_,x);q(v,y[0],y[1],f,F,Y,_),q(A,P[0],y[1],f,F,Y,_),q(G,y[0],P[1],f,F,Y,_),i(A,A,v),a(A,A,.5),i(G,G,v),a(G,G,.5),m(v,v,A),m(v,v,G);const I=y[0]%l,h=y[1]%l,p=y[0]-I,N=y[1]-h;for(let o=0;o<n.length;o+=3){e(E,n[o],n[o+1],n[o+2]);const i=o/3,a=4*i;t[a]=(s(F,E)-p)/l,t[a+1]=(s(Y,E)-N)/l,t[a+2]=p/l,t[a+3]=N/l;const m=9*i;for(let t=0;t<3;t++)r[m+t]=v[t],r[m+t+3]=A[t],r[m+t+6]=G[t]}}const x=I(),E=I(),V=u(),F=I(),Y=I(),_=I(),y=r(),P=r(),v=I(),A=I(),G=I();function O(t,o,r,i,m,I){null!=m?(m.basisMatrixAtPosition(I,S),e(d,S[0],S[1],S[2]),e(k,S[4],S[5],S[6]),e(w,S[8],S[9],S[10])):(e(d,1,0,0),e(k,0,1,0),e(w,0,0,1));const h=b(t);s(h,w)<0&&a(h,h,-1),n(i,h);const p=s(h,k),N=s(h,d);Math.abs(p)>Math.abs(N)?(c(o,d,h,-N),l(o,o),f(r,o,h),l(r,r),a(r,r,-1)):(c(r,k,h,-p),l(r,r),f(o,r,h),l(o,o))}const S=t(),d=I(),k=I(),w=I();function D(t,o){e(U,0,0,0);for(let r=0;r<o.length-3;r+=3)U[0]+=o[r],U[1]+=o[r+1],U[2]+=o[r+2];a(t,U,1/(o.length/3-1))}const U=I();function q(t,o,r,s,i,a,m){e(t,o*i[0]+r*a[0]+s*m[0],o*i[1]+r*a[1]+s*m[1],o*i[2]+r*a[2]+s*m[2])}export{M as createMapSpaceUVCoords,T as createMapSpaceUVCoordsDraped};