@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 2.7 kB
JavaScript
import{isSome as t}from"../../../../core/maybe.js";import{c as o}from"../../../../chunks/mat4f64.js";import{s}from"../../../../chunks/vec2.js";import{a as n}from"../../../../chunks/vec2f64.js";import{s as r,e,b as m,g as a,a as i,c,z as f,n as I,f as l}from"../../../../chunks/vec3.js";import{c as h}from"../../../../chunks/vec3f64.js";import{getReferenceEllipsoid as u}from"../../../../geometry/ellipsoidUtils.js";import{lonLatToWebMercatorComparable as N}from"../../../../geometry/projection.js";import{create as p,fromManyPointsSampleAt as g,normal as b}from"../../../../geometry/support/plane.js";import{ViewingMode as j}from"../../../ViewingMode.js";import{newDoubleArray as M}from"../../webgl-engine/lib/DoubleArray.js";function T(t,o,n,r,e=1){if(n.isGeographic&&r===j.Global){const t=M(o.length),s=o.length,r=u(n);for(let n=0;n<s;n+=3)N(o,n,t,n,r);o=t}s(P,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY);for(let s=0;s<o.length;s+=3)P[0]=Math.min(P[0],o[s]),P[1]=Math.min(P[1],o[s+1]);const m=P[0]%e,a=P[1]%e,i=P[0]-m,c=P[1]-a;for(let s=0;s<o.length;s+=3){const n=s/3*4;t[n]=(o[s]-i)/e,t[n+1]=(o[s+1]-c)/e,t[n+2]=i/e,t[n+3]=c/e}}function E(t,o,n,c,f=1){r(_,1,0,0),r(k,0,1,0),r(y,0,0,1),U(V,n),O(n,Y)&&S(Y,_,k,y,c,V),s(P,Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY),s(v,Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY);for(let s=0;s<n.length;s+=3){r(F,n[s],n[s+1],n[s+2]);const t=e(_,F),o=e(k,F);P[0]=Math.min(P[0],t),P[1]=Math.min(P[1],o),v[0]=Math.max(v[0],t),v[1]=Math.max(v[1],o)}const I=e(y,V);B(x,P[0],P[1],I,_,k,y),B(A,v[0],P[1],I,_,k,y),B(G,P[0],v[1],I,_,k,y),m(A,A,x),a(A,A,.5),m(G,G,x),a(G,G,.5),i(x,x,A),i(x,x,G);const l=P[0]%f,h=P[1]%f,u=P[0]-l,N=P[1]-h;for(let s=0;s<n.length;s+=3){r(F,n[s],n[s+1],n[s+2]);const m=s/3,a=4*m;t[a]=(e(_,F)-u)/f,t[a+1]=(e(k,F)-N)/f,t[a+2]=u/f,t[a+3]=N/f;const i=9*m;for(let t=0;t<3;t++)o[i+t]=x[t],o[i+t+3]=A[t],o[i+t+6]=G[t]}}const V=h(),F=h(),Y=p(),_=h(),k=h(),y=h(),P=n(),v=n(),x=h(),A=h(),G=h();function O(t,o){const s=t.length/3-1;return g(t,o,0,Math.floor(s/3),Math.floor(s*(2/3)))}function S(o,s,n,m,i,h){t(i)?(i.basisMatrixAtPosition(h,d),r(w,d[0],d[1],d[2]),r(z,d[4],d[5],d[6]),r(D,d[8],d[9],d[10])):(r(w,1,0,0),r(z,0,1,0),r(D,0,0,1));const u=b(o);e(u,D)<0&&a(u,u,-1),c(m,u);const N=e(u,z),p=e(u,w);Math.abs(N)<Math.abs(p)?(f(s,w,u,-p),I(s,s),l(n,s,u),I(n,n),a(n,n,-1)):(f(n,z,u,-N),I(n,n),l(s,n,u),I(s,s))}const d=o(),w=h(),z=h(),D=h();function U(t,o){r(q,0,0,0);for(let s=0;s<o.length-3;s+=3)q[0]+=o[s],q[1]+=o[s+1],q[2]+=o[s+2];a(t,q,1/(o.length/3-1))}const q=h();function B(t,o,s,n,e,m,a){r(t,o*e[0]+s*m[0]+n*a[0],o*e[1]+s*m[1]+n*a[1],o*e[2]+s*m[2]+n*a[2])}export{E as createMapSpaceUVCoords,T as createMapSpaceUVCoordsDraped};