/*
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/maybe","../../../chunks/mat4","../../../chunks/vec3","../../../chunks/vec4f64","../../../geometry/support/vectorStacks","../../../layers/graphics/hydratedFeatures","./Manipulator3D","../layers/graphics/graphicUtils","../webgl-engine/lib/basicInterfaces","../webgl-engine/lib/GeometryUtil","../webgl-engine/lib/Material","../webgl-engine/materials/ColorMaterial","../webgl-engine/materials/ShadedColorMaterial"],(function(e,t,r,n,a,c,o,l,i,s,u,d,g,p){"use strict";function m(e,t=d.RenderOccludedFlag.OccludeAndTransparent,r=!0){const n=a.fromValues(e[0],e[1],e[2],e.length>3?e[3]:1),c=e[3]<1;return r?new p.ShadedColorMaterial({color:n,transparent:c,writeDepth:!0,cullFace:s.CullFaceOptions.Back,renderOccluded:t}):new g.ColorMaterial({color:n,transparent:c,writeDepth:!0,cullFace:s.CullFaceOptions.Back,renderOccluded:t})}function h(e,t=d.RenderOccludedFlag.OccludeAndTransparent){const r=a.fromValues(e[0],e[1],e[2],4===e.length?e[3]:1);return new g.ColorMaterial({color:r,transparent:!0,writeDepth:!0,cullFace:s.CullFaceOptions.Front,renderOccluded:t})}function f(e,t,r){return new l.Manipulator3D({view:e,renderObjects:[{geometry:u.createSphereGeometry(1,32,32),material:m(a.fromValues(t[0],t[1],t[2],null!=r?r:1))}]})}function M(e,t,a,o){const l=n.subtract(c.sv3d.get(),e,a),i=O(l,n.cross(c.sv3d.get(),o,l),a,c.sm4d.get());r.invert(i,i);const s=n.transformMat4(c.sv3d.get(),t,i);return Math.atan2(s[1],s[0])}function O(e,t,r,a){const o=n.normalize(c.sv3d.get(),e),l=n.normalize(c.sv3d.get(),t),i=n.cross(c.sv3d.get(),o,l);return a[0]=o[0],a[1]=o[1],a[2]=o[2],a[3]=0,a[4]=l[0],a[5]=l[1],a[6]=l[2],a[7]=0,a[8]=i[0],a[9]=i[1],a[10]=i[2],a[11]=0,a[12]=r[0],a[13]=r[1],a[14]=r[2],a[15]=1,a}function b(e,r){const n=e.getViewForGraphic(r);return t.isSome(n)&&"computeAttachmentOrigin"in n?n.computeAttachmentOrigin(r,e.spatialReference):null}function v(e,r,n){const a=b(e,n);t.isSome(a)?r.elevationAlignedLocation=a:w(r,n.geometry)}function w(e,r){if(t.isNone(r))return;const n="mesh"===r.type?r.anchor:i.computeCentroid(r);t.isNone(n)||(e.location=o.hydrateGeometry(n))}e.calculateInputRotationTransform=M,e.calculateTranslateRotateFromBases=O,e.createManipulatorMaterial=m,e.createManipulatorOutlineMaterial=h,e.createSphereManipulator=f,e.getGraphicAttachmentOrigin=b,e.placeAtGraphic=v,Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})}));
