@doegis/core
Version:
DOE GIS API
3 lines (1 loc) • 4.82 kB
JavaScript
import e from"../../../Color.js";import"../../../core/has.js";import{destroyHandle as n}from"../../../core/handleUtils.js";import{isNone as i,isSome as t,unwrap as r}from"../../../core/maybe.js";import{h as a}from"../../../chunks/vec3.js";import{c as o}from"../../../chunks/vec3f64.js";import{projectVectorToVector as s}from"../../../geometry/projection.js";import{onTheGroundElevationInfo as l,absoluteHeightElevationInfo as p}from"../../../support/elevationInfoUtils.js";import{ExtendedLineVisualElement as d,ExtensionType as c}from"./visualElements/ExtendedLineVisualElement.js";import{ParallelLineVisualElement as m}from"./visualElements/ParallelLineVisualElement.js";import{PointVisualElement as g}from"./visualElements/PointVisualElement.js";import{RightAngleQuadVisualElement as u}from"./visualElements/RightAngleQuadVisualElement.js";import{DrapedRenderGroup as f}from"../layers/interfaces.js";import{RenderOccludedFlag as h}from"../webgl-engine/lib/Material.js";import{defaults as v}from"../../interactive/snapping/Settings.js";import{SnappingDomain as E}from"../../interactive/snapping/SnappingDomain.js";import{snappingPointToDehydratedPoint as S,createSnappingPoint as R}from"../../interactive/snapping/SnappingPoint.js";import{LineSegmentHintType as j}from"../../interactive/snapping/snappingUtils.js";import{SnappingVisualizer as w}from"../../interactive/snapping/SnappingVisualizer.js";import{LineSnappingHint as _}from"../../interactive/snapping/hints/LineSnappingHint.js";import{vectorToRender as H}from"../../interactive/support/viewUtils.js";class x extends w{sortUniqueHints(e){return e.sort(((e,n)=>(n instanceof _?n.length:0)-(e instanceof _?e.length:0)))}visualizeIntersectionPoint(i,t){const{spatialReference:r,view:a}=t;return n(new g({view:a,primitive:"circle",geometry:S(i.intersectionPoint,r),elevationInfo:i.isDraped?l:p,size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizePoint(i,t){const{view:r,spatialReference:a}=t,o=this._alignPoint(i.point,i.domain,t);return n(new g({view:r,primitive:"circle",geometry:S(o,a),elevationInfo:this._hintElevationInfo(i,t),size:20,outlineSize:2,color:[0,0,0,0],outlineColor:e.toUnitRGBA(v.orange),pixelSnappingEnabled:!1}))}visualizeLine(e,i){const{view:t,spatialReference:r}=i,a=this._alignPoint(e.lineStart,e.domain,i),o=this._alignPoint(e.lineEnd,e.domain,i);return n(this._createLineSegmentHint(e.type,a,o,r,this._hintElevationInfo(e,i),t,e.isDraped,e.fadeLeft,e.fadeRight))}visualizeParallelSign(i,t){const{view:r,spatialReference:o}=t,{isDraped:s}=i,l=this._hintElevationInfo(i,t),p=this._alignPoint(i.lineStart,i.domain,t),d=this._alignPoint(i.lineEnd,i.domain,t),c=A(p,o,l,r,s),g=A(d,o,l,r,s),u=a(g,c,g,.5),E=new m({view:r,attached:!1,offset:v.parallelLineHintOffset,length:v.parallelLineHintLength,width:v.parallelLineHintWidth,color:e.toUnitRGBA(v.orange),location:u,renderOccluded:s?h.OccludeAndTransparent:h.Opaque,isDraped:s,renderGroup:f.SnappingHint});return E.setDirectionFromPoints(c,u),E.attached=!0,n(E)}visualizeRightAngleQuad(i,t){const{view:r,spatialReference:a}=t,o=this._hintElevationInfo(i,t),{isDraped:s}=i,l=this._alignPoint(i.previousVertex,i.domain,t),p=this._alignPoint(i.centerVertex,i.domain,t),d=this._alignPoint(i.nextVertex,i.domain,t),c=A(l,a,o,r,s),m=A(p,a,o,r,s),g=A(d,a,o,r,s);return n(new u({view:r,attached:!0,color:s?e.toUnitRGBA(v.orangeTransparent):e.toUnitRGBA(v.orange),renderOccluded:s?h.OccludeAndTransparent:h.Transparent,outlineRenderOccluded:s?h.OccludeAndTransparent:h.Opaque,outlineColor:e.toUnitRGBA(v.orange),outlineSize:v.rightAngleHintOutlineSize,size:v.rightAngleHintSize,isDraped:s,geometry:{previous:c,center:m,next:g},renderGroup:f.SnappingHint}))}_createLineSegmentHint(n,i,t,r,a,o,s=!1,l=!0,p=!0){const m=A(i,r,a,o,s),g=A(t,r,a,o,s),u=new d({view:o,extensionType:c.FADED,start:m,end:g,isDraped:s,color:e.toUnitRGBA(v.orange),renderOccluded:s?h.OccludeAndTransparent:h.Opaque,renderGroup:f.SnappingHint});switch(n){case j.TARGET:u.width=v.lineHintWidthTarget,u.fadedExtensions={start:0,end:v.lineHintFadedExtensions};break;case j.REFERENCE_EXTENSION:u.width=v.lineHintWidthReference,u.fadedExtensions={start:0,end:0};break;case j.REFERENCE:u.width=v.lineHintWidthReference,u.fadedExtensions={start:l?v.lineHintFadedExtensions:0,end:p?v.lineHintFadedExtensions:0}}return u.attached=!0,u}_alignPoint(e,n,t){const r=this._getSelfSnappingZ(n,t);return i(r)?e:R(e[0],e[1],r)}_hintElevationInfo(e,n){return t(this._getSelfSnappingZ(e.domain,n))?r(n.selfSnappingZ).elevationInfo:e.isDraped?l:p}_getSelfSnappingZ(e,{selfSnappingZ:n}){return e===E.SELF&&t(n)?n.value:null}}function A(e,n,i,t,r,a=o()){if(r){const i=t.basemapTerrain.overlayManager.renderer.spatialReference;s(e,n,a,i)}else H(e,n,i,t,a);return a}export{x as SnappingVisualizer3D};