/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.24/esri/copyright.txt for details.
*/
define(["exports","../../../core/Logger","../../../core/maybe","../../../chunks/vec3f64","../../projection","./geographicUtils","./georeference"],(function(e,t,r,i,o,n,s){"use strict";const c=t.getLogger("esri.geometry.support.meshUtils.centerAt");function a(e,t,i){var o;if(!e.vertexAttributes||!e.vertexAttributes.position)return;const s=null!=(o=null==i?void 0:i.origin)?o:e.origin;if(r.isSome(e.transform))null!=(null==i?void 0:i.geographic)&&i.geographic!==e.transform.geographic&&c.warn(`Specifying the 'geographic' parameter (${i.geographic}) different from the Mesh transform setting (${e.transform.geographic}) is not supported`),g(e.transform,t,s);else{n.isGeographicMesh(e.spatialReference,i)?f(e,t,s):p(e,t,s)}}function g(e,t,r){const i=t.x-r.x,o=t.y-r.y,n=t.hasZ&&r.hasZ?t.z-r.z:0,s=e.origin;e.origin=[s[0]+i,s[1]+o,s[2]+n]}function f(e,t,r){const i=s.ungeoreference(e.vertexAttributes,r,{geographic:!0}),{position:o,normal:n,tangent:c}=s.georeference(i,t,{geographic:!0});e.vertexAttributes.position=o,e.vertexAttributes.normal=n,e.vertexAttributes.tangent=c,e.vertexAttributesChanged()}function p(e,t,r){const i=h,n=u;if(o.projectPointToVector(t,n,e.spatialReference)){if(!o.projectPointToVector(r,i,e.spatialReference)){const t=e.origin;i[0]=t.x,i[1]=t.y,i[2]=t.z,c.error(`Failed to project specified origin (wkid:${r.spatialReference.wkid}) to mesh spatial reference (wkid:${e.spatialReference.wkid}).`)}l(e.vertexAttributes.position,n,i),e.vertexAttributesChanged()}else c.error(`Failed to project centerAt location (wkid:${t.spatialReference.wkid}) to mesh spatial reference (wkid:${e.spatialReference.wkid})`)}function l(e,t,r){if(e)for(let i=0;i<e.length;i+=3)for(let o=0;o<3;o++)e[i+o]+=t[o]-r[o]}const u=i.create(),h=i.create();e.centerAt=a,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
