@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.81 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{width as t,height as e,intersects as r}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as o}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as n}from"../../../../geometry/support/FloatArray.js";import{Attribute as i}from"../../webgl-engine/lib/Attribute.js";import{Geometry as m}from"../../webgl-engine/lib/Geometry.js";import{createSquareGeometry as h}from"../../webgl-engine/lib/GeometryUtil.js";import{VertexAttribute as g}from"../../webgl-engine/lib/VertexAttribute.js";function u(r,o,n){const i=t(r)/e(r),m={width:n,height:n};return i>1.0001?m.height=n/i:i<.9999&&(m.width=n*i),m.width=Math.round(m.width/(t(r)/t(o))),m.height=Math.round(m.height/(e(r)/e(o))),m}function l(t,e){return h(t,[[e[0],e[1],-1],[e[2],e[1],-1],[e[2],e[3],-1],[e[0],e[3],-1]])}function s(t,e,h){if(!r(e,h))return l(t,h);const u=[e[1]-h[1],Math.min(e[3],h[3])-Math.max(e[1],h[1]),h[3]-e[3],123456],s=[e[0]-h[0],Math.min(e[2],h[2])-Math.max(e[0],h[0]),h[2]-e[2],123456],f=h[2]-h[0],p=h[3]-h[1],w=s[0]>0&&s[2]>0?3:2,b=u[0]>0&&u[2]>0?3:2,c=(b+1)*(w+1),y=o(3*c),d=n(2*c),j=new Array(6*(b*w-1));let A=0,M=0,x=0,O=0,G=0;for(let r=0;r<4;r++){const t=u[r];if(t<=0)continue;let e=0;for(let o=0;o<4;o++){const t=s[o];t<=0||(y[M++]=h[0]+e,y[M++]=h[1]+A,y[M++]=-1,d[x++]=e/f,d[x++]=A/p,o<3&&r<3&&(1!==o||1!==r)&&(j[G++]=O,j[G++]=O+1,j[G++]=O+w+1,j[G++]=O+1,j[G++]=O+w+2,j[G++]=O+w+1),O++,e+=t)}A+=t}const I=new Array(j.length);return new m(t,[[g.POSITION,new i(y,j,3,!0)],[g.NORMAL,new i(a,I,3,!0)],[g.UV0,new i(d,j,2,!0)]])}const a=[0,0,1];export{u as computeImageExportSize,l as createGeometryForExtent,s as createOuterImageGeometry};