@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
6 lines (5 loc) • 1.6 kB
JavaScript
/*
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
*/
import e from"../../../core/Handles.js";import{destroyMaybe as t}from"../../../core/maybe.js";import{watch as i,syncAndInitial as o}from"../../../core/reactiveUtils.js";import{ElevationProfileState as s}from"./constants.js";import{HoveredPoints as n}from"./HoveredPoints.js";import{InputRepresentation3D as r}from"./InputRepresentation3D.js";import{ProfileLines3D as h}from"./ProfileLines3D.js";class p{constructor(t,s){this._handles=new e,this._inputRepresentation=new r({view:t}),this._hoveredPoints=new n({view:t}),this._profileLines=new h({view:t}),this._handles.add([i((()=>s.viewModel.hoveredPoints),(e=>this._hoveredPoints.update(e)),o),i((()=>{const{state:e,editable:t,highlightEnabled:i,viewModel:o}=s,n=o.input;return n&&(n.commitProperty("geometry"),n.commitProperty("layer")),{input:n,state:e,editable:t,highlightEnabled:i}}),(e=>this._updateInputRepresentation(e)),o),i((()=>s.viewModel.chartData),(e=>this._profileLines.update(e)),o),i((()=>s.viewModel.input?.geometry),(()=>{this._profileLines.remove()}),o)])}destroy(){this._handles=t(this._handles),this._inputRepresentation=t(this._inputRepresentation),this._hoveredPoints=t(this._hoveredPoints),this._profileLines=t(this._profileLines)}_updateInputRepresentation({input:e,state:t,editable:i,highlightEnabled:o}){const n=this._inputRepresentation;if(!o)return n.remove();t===s.Selected?n.showHighlight(e):t!==s.Created||i?n.remove():n.showReshaping(e)}}export{p as ElevationProfileView3D};