@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 3.02 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import e from"../../../core/Logger.js";import{fromRotationTranslationScaleOrigin as t,multiply as r,getScale as o,scale as i,getTranslation as n}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{IDENTITY as l}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{set as a,inverse as c,scale as f}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{ZEROS as m,create as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import g from"../../Point.js";import{getSphericalPCPF as u}from"../../spatialReferenceEllipsoidUtils.js";import{projectPointToVector as x}from"../../projection/projectPointToVector.js";import{fromMatrix as j}from"../axisAngleDegrees.js";import v from"../MeshTransform.js";import{isMeshWithRelativeVertexSpace as A}from"../meshVertexSpaceUtils.js";import{performGlobalOperation as b}from"./geographicUtils.js";import{logProjectionError as h,loadProjectErrorMessage as R,projectToPCPF as d,projectNormalToPCPF as y,projectTangentToPCPF as w,projectFromPCPF as F,projectNormalFromPCPF as S,projectTangentFromPCPF as U}from"./projection.js";import{projectPointToVertexSpace as C}from"./vertexSpaceConversion.js";const q=()=>e.getLogger("esri.geometry.support.meshUtils.scale");function z(e,t,r){if(!e.vertexAttributes?.position)return;const{vertexSpace:o,spatialReference:i}=e,n=r?.origin??e.origin;if(A(e))L(e,t,n);else{b(o,i)?M(e,t,n):P(e,t,n)}}function L(e,s,f){e.transform??=new v;const{vertexSpace:u,transform:x,spatialReference:A}=e,[b,d,y]=u.origin,w=new g({x:b,y:d,z:y,spatialReference:A}),F=V;if(w.equals(f))a(F,0,0,0);else if(!C(F,f,e))return void h(q(),f.spatialReference,A,R);const S=a(k,s,s,s),U=t(D,l,m,S,F),{localMatrix:z}=x,L=r(D,U,z);x.scale=o(p(),L),i(L,L,c(V,x.scale));const M=x.rotationAxis;x.rotation=j(L),0===x.rotationAngle&&(x.rotationAxis=M),x.translation=n(p(),L)}function M(e,t,r){const o=e.spatialReference,i=u(o),n=E;if(!x(r,n,i)&&(h(q(),r.spatialReference,i,"Falling back to mesh origin"),!x(e.origin,n,i)))return void h(q(),e.origin.spatialReference,i);const s=e.vertexAttributes.position,l=e.vertexAttributes.normal,a=e.vertexAttributes.tangent,c=new Float64Array(s.length),f=null!=l?new Float32Array(l.length):null,m=null!=a?new Float32Array(a.length):null;d(s,o,c,i)&&(null==l||null==f||y(l,s,o,c,i,f))&&(null==a||null==m||w(a,s,o,c,i,m))?(T(c,t,n),F(c,i,s,o)&&(null==l||null==f||S(f,s,o,c,i,l))&&(null==a||null==m||U(m,s,o,c,i,a))?e.vertexAttributesChanged():h(q(),i,o)):h(q(),o,i)}function P(e,t,r){const o=E;if(!x(r,o,e.spatialReference)){const t=e.origin;return o[0]=t.x,o[1]=t.y,o[2]=t.z,void h(q(),r.spatialReference,e.spatialReference,R)}T(e.vertexAttributes.position,t,o),e.vertexAttributesChanged()}function T(e,t,r=m){if(e)for(let o=0;o<e.length;o+=3){for(let t=0;t<3;t++)V[t]=e[o+t]-r[t];f(V,V,t);for(let t=0;t<3;t++)e[o+t]=V[t]+r[t]}}const V=p(),k=p(),D=s(),E=p();export{z as scale};