UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

6 lines (5 loc) 7.83 kB
/* All material copyright ESRI, All Rights Reserved, unless otherwise specified. See https://js.arcgis.com/4.32/esri/copyright.txt for details. */ import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{handlesGroup as i,makeHandle as r}from"../../../../../core/handleUtils.js";import{destroyMaybe as s}from"../../../../../core/maybe.js";import{watch as o,when as n,syncAndInitial as a,initial as l}from"../../../../../core/reactiveUtils.js";import{property as c}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/has.js";import"../../../../../core/Logger.js";import"../../../../../core/RandomLCG.js";import{subclass as m}from"../../../../../core/accessorSupport/decorators/subclass.js";import{i as p}from"../../../../../chunks/vec32.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEffectiveElevationInfo as u,getEffectiveElevationMode as d}from"../../../../../support/elevationInfoUtils.js";import v from"../../../../../symbols/support/ElevationInfo.js";import{SegmentLabels3D as f}from"../../SegmentLabels3D.js";import{SnappingVisualizer3D as g}from"../../SnappingVisualizer3D.js";import{meshTransformFastUpdateHandles as w}from"../meshFastUpdateUtils.js";import{Settings as y}from"../settings.js";import{ExtendedLineVisualElement as V}from"../../visualElements/ExtendedLineVisualElement.js";import{OutlineVisualElement as E}from"../../visualElements/OutlineVisualElement.js";import{VerticesVisualElement as _}from"../../visualElements/VerticesVisualElement.js";import{evaluateElevationAlignmentAtPoint as j}from"../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as I}from"../../../layers/graphics/ElevationContext.js";import{GraphicState as L}from"../../../layers/graphics/GraphicState.js";import{RenderOccludedFlag as S}from"../../../webgl-engine/lib/Material.js";import{DrawGraphicTool as D,geometryTypeToDrawOperationGeometryType as G}from"../../../../draw/DrawGraphicTool.js";import{DrawOperation as x}from"../../../../draw/DrawOperation.js";import{SceneDrawSurface as C,ElevationDrawSurface as O}from"../../../../draw/drawSurfaces.js";import{updateMeshTransformFromTooltipInfo as T}from"../../../../interactive/tooltip/tooltipCommonUtils.js";import{autorun as b}from"../../../../../core/accessorSupport/trackingUtils.js";let z=class extends D{constructor(e){super(e),this._activeVertexVisualElement=null,this._createGraphicState=null,this._outlineVisualElement=null,this._verticesVisualElement=null,this._verticalLineVisualElement=null,this._settings=new y({getTheme:()=>this.view.effectiveTheme}),this.geometryType=null,this.type="draw-3d"}initialize(){const{mode:e,offset:t,unit:i}=this.elevationInfo;this.internalGraphicsLayer.elevationInfo=new v({mode:e,offset:t,unit:i})}normalizeCtorArgs(e){if(!e.elevationInfo){const t=e.hasZ??!0;return{...e,elevationInfo:u(t)}}return e}initializeGraphic(e){const{view:t}=this,r=this._createGraphicState=new L({graphic:e});return i([t.maskOccludee(e),t.trackGraphicState(r),o((()=>({element:this._outlineVisualElement,isDraped:r.isDraped})),(({element:e,isDraped:t})=>{e&&(e.isDraped=t)}),a),b((()=>{T(this.tooltipInfos.mesh,this.geometryToPlace)})),this._setupLoadingIndicator(r),...w(r)])}makeDrawOperation(){const{geometryType:e}=this,t="circle"!==e&&"rectangle"!==e;return new x({view:this.view,manipulators:this.manipulators,geometryType:G(e),drawingMode:this.mode,hasZ:this.hasZ,defaultZ:this.defaultZ,snapToSceneEnabled:this.snapToScene,drawSurface:new C(this.view,this.elevationInfo,[this.internalGraphicsLayer]),elevationDrawSurface:new O(this.elevationInfo,this.defaultZ,this.view,this.internalGraphicsLayer),hasM:!1,elevationInfo:this.elevationInfo,snappingManager:this.snappingManager,snappingVisualizer:new g,segmentLabels:t?new f:null,labelOptions:this.sketchOptions.labels,isDraped:this._createGraphicState?this._createGraphicState.isDraped:"on-the-ground"===d(this.hasZ,this.elevationInfo),cursor:this.cursor,constraintsEnabled:!0})}onActiveVertexChanged(e){const{view:n}=this;if(this._activeVertexVisualElement)return this._activeVertexVisualElement.vertices=[e],this._activeVertexVisualElement.recreate(),this._updateVerticalLineVisualElement(e),r();const a=this._settings,c=a.manipulators.vertex,m=new _({view:n,spatialReference:n.spatialReference,vertices:[e],elevationInfo:this.internalGraphicsLayer.elevationInfo,size:c.size,outlineSize:c.outlineSize,renderOccluded:c.renderOccluded,attached:!1,isDecoration:!0});this._activeVertexVisualElement=m;const p=a.visualElements.zVerticalLine,h=new V({view:n,extensionType:p.extensionType,innerWidth:1,attached:!1,writeDepthEnabled:!1,renderOccluded:S.OccludeAndTransparent,isDecoration:!0});this._verticalLineVisualElement=h;const u=i([o((()=>a.visualElements.zVerticalLine),(e=>e.apply(h)),l),o((()=>({selectedColor:t(a.colors.selected),outlineColor:t(a.manipulators.vertex.outlineColor)})),(({selectedColor:e,outlineColor:t})=>{m.color=e,m.outlineColor=t}),l),r((()=>{this._activeVertexVisualElement=s(this._activeVertexVisualElement),this._verticalLineVisualElement=s(this._verticalLineVisualElement)}))]);return m.attached=!0,this._updateVerticalLineVisualElement(e),u}_updateVerticalLineVisualElement(e){const t=this._verticalLineVisualElement;if(!t)return;const{renderCoordsHelper:i,elevationProvider:r}=this.view;p(A,e[0],e[1],e[2]),U.setFromElevationInfo(this.elevationInfo),A[2]=j(A,r,U,i);i.toRenderCoords(A,this.view.spatialReference,A)?(t.setStartEndFromWorldDownAtLocation(A),t.attached=!0):t.attached=!1}onOutlineChanged(e){if(this._outlineVisualElement)return this._outlineVisualElement.geometry=e,r();const t=this.internalGraphicsLayer.elevationInfo,{view:n}=this,a=this._settings,c=new E({view:n,geometry:e,elevationInfo:t,isDraped:this._createGraphicState?this._createGraphicState.isDraped:"on-the-ground"===d(this.hasZ,t),attached:!1,isDecoration:!0});this._outlineVisualElement=c;const m=i([o((()=>a.visualElements.lineObjects.outline),(e=>e.apply(c)),l),o((()=>a.visualElements.lineObjects.shadowStyle),(e=>e.apply(c)),l),r((()=>{this._outlineVisualElement=s(this._outlineVisualElement)}))]);return c.attached=!0,c.laserlineEnabled=!0,m}onRegularVerticesChanged(e){if(this._verticesVisualElement)return this._verticesVisualElement.vertices=e,r();const{view:n}=this,a=this._settings,c=a.manipulators.vertex,m=new _({view:n,spatialReference:n.spatialReference,vertices:e,elevationInfo:this.internalGraphicsLayer.elevationInfo,size:c.size,outlineSize:c.outlineSize,renderOccluded:c.renderOccluded,attached:!1,isDecoration:!0}),p=i([o((()=>({color:t(a.manipulators.vertex.color),outlineColor:t(a.manipulators.vertex.outlineColor)})),(({color:e,outlineColor:t})=>{m.color=e,m.outlineColor=t}),l),r((()=>{this._verticesVisualElement=s(this._verticesVisualElement)}))]);return m.attached=!0,this._verticesVisualElement=m,p}updateGraphicGeometry(e){if("mesh"!==this.geometryType||"point"!==e?.type)super.updateGraphicGeometry(e);else{const t=this.geometryToPlace;t?.centerAt(e),T(this.tooltipInfos.mesh,t);const i=this._graphic;t&&i.geometry===t||(i.geometry=t)}}_setupLoadingIndicator(e){const{drawOperation:t}=this;if(!this.geometryToPlace)return t.loading=!1,null;t.loading=!0;const s=r((()=>{t.loading=!1}));let o;const l=()=>o&&cancelAnimationFrame(o);return i([n((()=>e.displaying),(()=>{l(),o=requestAnimationFrame((()=>s.remove()))}),{...a,once:!0}),r(l),s])}};e([c({constructOnly:!0})],z.prototype,"elevationInfo",void 0),e([c({constructOnly:!0})],z.prototype,"geometryType",void 0),e([c()],z.prototype,"type",void 0),e([c({constructOnly:!0})],z.prototype,"view",void 0),z=e([m("esri.views.3d.interactive.editingTools.draw.DrawGraphicTool3D")],z);const U=new I,A=h();export{z as DrawGraphicTool3D};