UNPKG

@doegis/core

Version:

DOE GIS API

3 lines (1 loc) 4.31 kB
import{isSome as e,isNone as t}from"../../../core/maybe.js";import{a as r}from"../../../chunks/mat4.js";import{b as n,f as o,m as i,n as a}from"../../../chunks/vec3.js";import{f as c}from"../../../chunks/vec3f64.js";import{f as l}from"../../../chunks/vec4f64.js";import{sv3d as s,sm4d as u}from"../../../geometry/support/vectorStacks.js";import{hydrateGeometry as m}from"../../../layers/graphics/hydratedFeatures.js";import{Manipulator3D as d}from"./Manipulator3D.js";import{RenderObject as p}from"./RenderObject.js";import{computeCentroid as f}from"../layers/graphics/graphicUtils.js";import{Attribute as g}from"../webgl-engine/lib/Attribute.js";import{CullFaceOptions as w}from"../webgl-engine/lib/basicInterfaces.js";import{Geometry as b}from"../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as j,createSphereGeometry as h}from"../webgl-engine/lib/GeometryUtil.js";import{RenderOccludedFlag as O}from"../webgl-engine/lib/Material.js";import{VertexAttribute as y}from"../webgl-engine/lib/VertexAttribute.js";import{ColorMaterial as M}from"../webgl-engine/materials/ColorMaterial.js";import{ImageMaterial as v}from"../webgl-engine/materials/ImageMaterial.js";import{NativeLineMaterial as S}from"../webgl-engine/materials/NativeLineMaterial.js";import{RibbonLineMaterial as k}from"../webgl-engine/materials/RibbonLineMaterial.js";import{ShadedColorMaterial as A}from"../webgl-engine/materials/ShadedColorMaterial.js";import{ManipulatorStateCustomFlags as F,ManipulatorStateFlags as I}from"../../interactive/interfaces.js";function R(e,t=O.OccludeAndTransparent,r=!0){const n=l(e[0],e[1],e[2],e.length>3?e[3]:1),o=e[3]<1;return r?new A({color:n,transparent:o,writeDepth:!0,cullFace:w.Back,renderOccluded:t}):new M({color:n,transparent:o,writeDepth:!0,cullFace:w.Back,renderOccluded:t})}function L(e,t=O.OccludeAndTransparent){const r=l(e[0],e[1],e[2],4===e.length?e[3]:1);return new M({color:r,transparent:!0,writeDepth:!0,cullFace:w.Front,renderOccluded:t})}const T=Object.freeze({calloutLength:40,calloutWidth:1,discRadius:27,focusMultiplier:1.1,calloutColor:c(1,.5,0)});function U(e,t){const r=new d({view:e,autoScaleRenderObjects:!1,collisionPriority:1,metadata:t.metadata});return D(r,t),r}function D(e,t){const r=t.material??new v({transparent:!0,writeDepth:!1,textureId:t.texture?.id,renderOccluded:O.Opaque}),n=t.focusMultiplier??T.focusMultiplier,o=t.calloutLength??T.calloutLength,i=T.discRadius*(t.discScale??1),a=i*n,c=(e,t)=>{const r=[0,1,2,2,3,0];return new b(t,[[y.POSITION,new g([o-e,-e,0,o+e,-e,0,o+e,e,0,o-e,e,0],3,!0)],[y.UV0,new g([0,0,1,0,1,1,0,1],2,!0)]],[[y.POSITION,r],[y.UV0,r]])},s=T.calloutColor,u=t.calloutWidth??T.calloutWidth,m=new(u>1?k:S)({width:u,color:l(s[0],s[1],s[2],t.calloutOpacity??1),renderOccluded:O.OccludeAndTransparent}),d=j(m,[[0,0,0],[o-i,0,0]]),f=j(m,[[0,0,0],[o-a,0,0]]),w=t.customStateMask??F.None;e.collisionType={type:"disc",direction:[0,0,1],offset:[o,0,0]},e.focusMultiplier=n,e.metadata=t.metadata,e.radius=i,e.renderObjects=[new p(c(i,r),I.Unfocused|w),new p(d,I.Unfocused|w),new p(c(a,r),I.Focused|w),new p(f,I.Focused|w)]}function N(e,t,r=1,n=F.None){const o=R(l(t[0],t[1],t[2],null!=r?r:1)),i=[new p(h(o,1,32,32),n)];return new d({view:e,renderObjects:i})}const x=Object.freeze({autoScaleRenderObjects:!1,worldSized:!0});function C(e,t,a,c){const l=n(s.get(),e,a),m=V(l,o(s.get(),c,l),a,u.get());r(m,m);const d=i(s.get(),t,m);return Math.atan2(d[1],d[0])}function V(e,t,r,n){const i=a(s.get(),e),c=a(s.get(),t),l=o(s.get(),i,c);return n[0]=i[0],n[1]=i[1],n[2]=i[2],n[3]=0,n[4]=c[0],n[5]=c[1],n[6]=c[2],n[7]=0,n[8]=l[0],n[9]=l[1],n[10]=l[2],n[11]=0,n[12]=r[0],n[13]=r[1],n[14]=r[2],n[15]=1,n}function z(t,r){const n=t.getViewForGraphic(r);return e(n)&&"computeAttachmentOrigin"in n?n.computeAttachmentOrigin(r,t.spatialReference):null}function G(t,r,n){const o=z(t,n);e(o)?r.elevationAlignedLocation=o:P(r,n.geometry)}function P(e,r){if(t(r))return;const n="mesh"===r.type?r.anchor:f(r);t(n)||(e.location=m(n))}export{C as calculateInputRotationTransform,V as calculateTranslateRotateFromBases,R as createManipulatorMaterial,L as createManipulatorOutlineMaterial,U as createRotateManipulator,N as createSphereManipulator,z as getGraphicAttachmentOrigin,G as placeAtGraphic,D as updateRotateManipulator,x as worldScaledManipulatorSettings};