@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 7.47 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.19/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import{equals as i}from"../../../../core/lang.js";import{deg2rad as s}from"../../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../../core/maybe.js";import{watch as r,initial as a}from"../../../../core/reactiveUtils.js";import{property as l,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{fromRotation as h}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{transformMat4 as m,set as d,sub as u,len as p,normalize as _,scale as V,angle as f,negate as v,copy as w,add as E}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as b,clone as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{viewshedVisualizationConfiguration as C,arcAnglePerSegment as L}from"./ViewshedConfiguration.js";import{ViewshedShapeVisualElement as A}from"./ViewshedShapeVisualElement.js";import D from"./ViewshedTool.js";import{LineVisualElement as y}from"../../interactive/visualElements/LineVisualElement.js";import{PointVisualElement as j}from"../../interactive/visualElements/PointVisualElement.js";import{createStipplePatternSimple as F}from"../../webgl-engine/materials/lineStippleUtils.js";let R=class extends t{constructor(e){super(e),this.visible=!0,this._viewshedCorners={topLeft:b(),topRight:b(),bottomLeft:b(),bottomRight:b()},this._arcCenterPoints={top:b(),bottom:b(),left:b(),right:b()},this._parallelCenters={top:b(),bottom:b()}}initialize(){const e={view:this.view,isDecoration:!0},t={...e,color:this._color,renderOccluded:4},s={...t,stipplePattern:F(2)};this._observerVisualElement=new j({...e,...C.observerPointConfiguration}),this._shapeVisualElement=new A({...e,isDecoration:this.isDecoration}),this._frameLinesVisualElement=new y(t),this._leftArcVisualElement=new y(t),this._rightArcVisualElement=new y(t),this._topArcVisualElement=new y(t),this._bottomArcVisualElement=new y(t),this._centralLongitude=new y(s),this._centralLatitude=new y(s),this.addHandles([r(()=>{const e=this.viewshedComputedData;if(!e?.valid)return null;const t=this._viewshedCorners,i=this._arcCenterPoints,s=this._parallelCenters;return e.cornerPoints(t),e.arcCentersPoints(i),e.parallelCenterPoints(s),{viewshedComputedData:e,corners:t,arcCenters:i,parallelCenters:s,interactive:this.analysisViewData.interactive,selected:this._selected}},e=>{const t=null!=e;this._forEachVisualElement(e=>e.attached=t),t&&this._updateVisualElements(e)},{initial:!0,equals:i}),r(()=>{const{viewshedComputedData:e}=this,{horizontalFieldOfView:t,verticalFieldOfView:i}=e??{};return{viewshedComputedData:e,horizontalFieldOfView:t,verticalFieldOfView:i}},({viewshedComputedData:e})=>{const{_shapeVisualElement:t}=this;e!==t.viewshedComputedData&&(t.viewshedComputedData=e),this._shapeVisualElement.recreateGeometry()},a),r(()=>{const{interactive:e}=this.analysisViewData;return{visible:this.visible,selected:e&&this._selected,staged:e&&this._staged,horFovNot360:360!==this.viewshedComputedData?.horizontalFieldOfView}},({visible:e,selected:t,staged:i,horFovNot360:s})=>{const o=t||i;this._shapeVisualElement.visible=e,this._topArcVisualElement.visible=e,this._bottomArcVisualElement.visible=e,this._frameLinesVisualElement.visible=e&&s;const r=e&&(t||s);this._leftArcVisualElement.visible=r,this._rightArcVisualElement.visible=r,this._forEachLineVisualElement(e=>{e.width=o?C.frameWidthSelected:C.frameWidthNotSelected,e.renderOccluded=t?4:1}),[this._centralLatitude,this._centralLongitude].forEach(i=>{i.width=2*(o?C.frameWidthSelected:C.frameWidthNotSelected),i.visible=e&&t})},a),r(()=>{const{analysisViewData:{interactive:e,tool:t},_selected:i,visible:s}=this,o=this.view.activeTool,r=!t?.active&&o instanceof D&&o.creating;return{observerVisible:s&&!i&&(!e||(t?.creating??!1)||r),color:this._color}},({observerVisible:e,color:t})=>{this._observerVisualElement.visible=e,this._forEachLineVisualElement(e=>e.color=t)},a)])}get _color(){const{viewshedComputedData:e,_selected:t,analysisViewData:i}=this;if(null==e)return C.frameColor.toUnitRGBA();const s=i.tool?.active||i.interactive,o=e.viewshed===i.tool?.stagedViewshed;return(s&&(t||o)?this.view.effectiveTheme.accentColor:C.frameColor).toUnitRGBA()}get _selected(){const{viewshedComputedData:e,analysisViewData:{selectedViewshedComputedData:t}}=this;return null!=e&&e===t}get _staged(){const{analysisViewData:{tool:e},viewshedComputedData:t}=this;return null!=e&&e.creating&&e.stagedViewshed===t?.viewshed}destroy(){this._observerVisualElement=o(this._observerVisualElement),this._shapeVisualElement=o(this._shapeVisualElement),this._frameLinesVisualElement=o(this._frameLinesVisualElement),this._leftArcVisualElement=o(this._leftArcVisualElement),this._rightArcVisualElement=o(this._rightArcVisualElement),this._topArcVisualElement=o(this._topArcVisualElement),this._bottomArcVisualElement=o(this._bottomArcVisualElement),this._centralLongitude=o(this._centralLongitude),this._centralLatitude=o(this._centralLatitude)}_forEachLineVisualElement(e){[this._frameLinesVisualElement,this._leftArcVisualElement,this._rightArcVisualElement,this._topArcVisualElement,this._bottomArcVisualElement,this._centralLatitude,this._centralLongitude].forEach(e)}_forEachVisualElement(e){this._forEachLineVisualElement(e),e(this._observerVisualElement),e(this._shapeVisualElement)}_updateVisualElements(e){const{viewshedComputedData:t,corners:i,arcCenters:s,parallelCenters:o}=e,r=g(t.observerRenderSpace);this._observerVisualElement.geometry=t.observer,this._shapeVisualElement.updateTransform(),this._updateFrameLines(r,i),this._updateFrameArcs(t,i,o),this._updateCentralHelperArcs(t,s)}_updateFrameLines(e,t){this._frameLinesVisualElement.geometry=[[e,t.topLeft],[e,t.topRight],[e,t.bottomLeft],[e,t.bottomRight]]}_updateFrameArcs(e,t,i){const{observerRenderSpace:o,rightVector:r,horizontalFieldOfView:a,tiltedUpVector:l}=e,n=s(a),u=b(),p=c();h(p,n/2,l),m(u,r,p),S(this._leftArcVisualElement,o,t.bottomLeft,t.topLeft,"forward",u),h(p,-n/2,l),d(u,0,0,0),m(u,r,p),S(this._rightArcVisualElement,o,t.bottomRight,t.topRight,"forward",u);const _=a>180?"backward":"forward";S(this._topArcVisualElement,i.top,t.topRight,t.topLeft,_,l),S(this._bottomArcVisualElement,i.bottom,t.bottomRight,t.bottomLeft,_,l)}_updateCentralHelperArcs(e,t){const i=e.observerRenderSpace,s=e.horizontalFieldOfView>=180?"backward":"forward";S(this._centralLatitude,i,t.right,t.left,s,e.tiltedUpVector),S(this._centralLongitude,i,t.top,t.bottom,"forward",e.leftVector)}get test(){}};function S(e,t,i,s,o,r,a=L){const l=b();u(l,i,t);const n=p(l),d=b();u(d,s,t),_(d,d),V(d,d,n);let C=f(l,d);const A=g(r);"backward"===o&&(v(A,A),C=-(2*Math.PI-C));const D=[],y=Math.ceil(Math.abs(C)/a),j=c();h(j,C/y,A);const F=b();w(F,l);const R=b();w(R,i);for(let h=0;h<y;h++){const e=b();w(e,R),m(F,F,j),E(R,t,F);const i=b();w(i,R),D.push([e,i])}e.geometry=D}e([l()],R.prototype,"view",void 0),e([l({constructOnly:!0})],R.prototype,"isDecoration",void 0),e([l()],R.prototype,"analysisViewData",void 0),e([l()],R.prototype,"viewshedComputedData",void 0),e([l()],R.prototype,"visible",void 0),e([l()],R.prototype,"_color",null),e([l()],R.prototype,"_selected",null),e([l()],R.prototype,"_staged",null),R=e([n("esri.views.3d.analysis.Viewshed.ViewshedSubVisualization")],R);export{R as default};