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