@arcgis/core 4.34.0-next.72 → 4.34.0-next.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/11acefc48c0354e675df.js +1 -0
- package/assets/esri/core/workers/chunks/433c4dc666a6b2c99063.js +353 -0
- package/assets/esri/core/workers/chunks/{1f51c94d392826fdbdf4.js → 8ce653c3c5dde10ccbcf.js} +46 -46
- package/assets/esri/core/workers/chunks/8d91e2d185be4a4e8598.js +1 -0
- package/assets/esri/core/workers/chunks/{bcc233a86e01ff1eac16.js → ae7b86bd08a44e26b339.js} +1 -1
- package/assets/esri/core/workers/chunks/be9edd9791a00cab9c2b.js +1 -0
- package/assets/esri/core/workers/chunks/e8d25d4ca9b335883f34.js +1 -0
- package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
- package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
- package/chunks/Fog.glsl.js +5 -10
- package/chunks/GlowComposition.glsl.js +4 -4
- package/chunks/Terrain.glsl.js +29 -43
- package/chunks/boundedPlane.js +1 -1
- package/config.js +1 -1
- package/geometry/support/boundedPlane.js +1 -1
- package/interfaces.d.ts +26 -3
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/support/gaussianSplatUtils.js +1 -1
- package/package.json +3 -3
- package/support/basemapDefinitions.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/flow/FlowDisplayData.js +1 -1
- package/views/2d/engine/flow/FlowStrategy.js +1 -1
- package/views/2d/engine/flow/dataUtils.js +1 -1
- package/views/2d/engine/flow/utils.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
- package/views/3d/analysis/Slice/SliceController.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/environment/Fog.glsl.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
- package/views/3d/interactive/support/viewUtils.js +1 -1
- package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
- package/views/3d/state/ScreenSizePerspective.js +5 -0
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/SharedSymbolResources.js +1 -1
- package/views/3d/support/ViewSlice.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/flow/FlowWorker.js +1 -1
- package/views/3d/support/flow/geometryUtils.js +1 -1
- package/views/3d/support/geometryUtils/ray.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/ScreenSizePerspective.glsl.js +4 -4
- package/views/3d/webgl-engine/effects/glow/GlowComposition.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/raymarching/RayDistanceFalloff.glsl.js +10 -0
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/SliceHelper.js +1 -1
- package/views/3d/webgl-engine/lib/screenSizePerspectiveUtils.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
- package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +28 -10
- package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/draw/support/tooltipUtils.js +1 -1
- package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
- package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
- package/views/support/GroundViewElevationSampler.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch/VisibleElements.js +1 -1
- package/widgets/Sketch/support/OperationHandle.js +1 -1
- package/widgets/Sketch/support/sketchUtils.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/assets/esri/core/workers/chunks/16cfbe7bedf75d3a86e5.js +0 -1
- package/assets/esri/core/workers/chunks/226833d408eb1225e168.js +0 -1
- package/assets/esri/core/workers/chunks/cf69f6afeaf1229e032c.js +0 -1
- package/assets/esri/core/workers/chunks/e21eeb4e78a46fb7e32e.js +0 -1
- package/assets/esri/core/workers/chunks/f87a6b32292c1464b7b7.js +0 -353
- package/views/3d/webgl-engine/materials/ScaleInfo.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../../core/Handles.js";import{set as i,normalize as e}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as a,b as s,d as n,l as o,e as l}from"../../../../../chunks/vec32.js";import{create as
|
|
5
|
+
import t from"../../../../../core/Handles.js";import{set as i,normalize as e}from"../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as r}from"../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as a,b as s,d as n,l as o,e as l}from"../../../../../chunks/vec32.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as c,d as p}from"../../../../../chunks/boundedPlane.js";import{getInfo as u}from"../../../../../geometry/support/spatialReferenceUtils.js";import{Manipulation as _}from"./Manipulation.js";import{onGrabChangedHandle as d}from"./utils.js";import{createManipulatorDragEventPipeline as m,screenToMap as f}from"../../../../interactive/dragEventPipeline.js";import{GraphicManipulator as g}from"../../../../interactive/GraphicManipulator.js";import{apply as v}from"../../../../interactive/editGeometry/support/editPlaneUtils.js";const b=10,x=1e-6,C=.3;function y(t){const i=o(t.basis1),e=o(t.basis2);return C*Math.min(i,e)}class j extends _{constructor(i){super(),this._handles=new t,this._planeStart=c(),this._displayPlaneStart=c(),this._originCache=h(),this._axisCache=r(),this._renderStartCache=h(),this._renderEndCache=h(),this._resizeOriginCache=h(),this._view=i.view,this._tool=i.tool,this._graphic=i.graphic,this._direction=i.direction,this._preserveAspectRatio=i.preserveAspectRatio,this._manipulator=this._createManipulator(),this._handles.add([this._manipulator.events.on("grab-changed",t=>d(t,this._manipulator))]),this.forEachManipulator(t=>this._tool.manipulators.add(t))}destroy(){this._handles.destroy(),this.forEachManipulator(t=>{this._tool.manipulators.remove(t),t.destroy()}),this._tool=null,this._view=null,this._graphic=null,this._manipulator=null,this._direction=null,this._handles=null,this._planeStart=null,this._displayPlaneStart=null,this._originCache=null,this._axisCache=null,this._renderStartCache=null,this._renderEndCache=null,this._resizeOriginCache=null,this._preserveAspectRatio=null}forEachManipulator(t){t(this._manipulator,1)}createDragPipeline(t,r){let h=null,c=null,_=null,d=0,g=null,C=null;const j=this._planeStart,w=this._displayPlaneStart,S=this._direction;return m(this._manipulator,(m,E)=>{E.next(i=>{if("start"===i.action){m.cursor="grabbing";const i=t();h=i.plane,c=i.displayPlane,_=i.editGeometryOperations,d=b*this._view.resolution,p(h,j),p(c,w);const e=u(_.data.spatialReference);g=e?e.valid[1]-e.valid[0]-3*b*this._view.resolution:null}return i}).next(f(this._view)).next(t=>{const i=a(this._renderStartCache,[t.mapStart.x,t.mapStart.y,0]),e=a(this._renderEndCache,[t.mapEnd.x,t.mapEnd.y,0]),r=a(this._resizeOriginCache,w.origin);s(r,r,w.basis1,-S[0]),s(r,r,w.basis2,-S[1]),n(e,e,r),n(i,i,r);const h=0!==S[0]&&0!==S[1],p=y(w),u=y(c)/p,_=(t,r)=>{if(0===t)return 1;let a=o(r),s=.5*t*l(r,e)/a;const n=s<0?-1:1;if(h){s+=(a-.5*t*l(r,i)/a)*n*u}const c=a<1.5*d?1:x;return a=Math.max(a-d,x),n>0&&(s-=b*this._view.resolution),n*Math.max(n*(s/a),c)},m=_(S[0],w.basis1),f=_(S[1],w.basis2);return{...t,direction:S,factor1:m,factor2:f}}).next(this._preserveAspectRatio.createDragEventPipelineStep(),this._preserveAspectRatio.next).next(t=>{const n=a(this._originCache,j.origin);s(n,n,j.basis1,-S[0]),s(n,n,j.basis2,-S[1]);const o=i(this._axisCache,j.basis1[0],j.basis1[1]);e(o,o);const l=_.data.allVerticesUnordered,c="start"===t.action?0:1,u=_.scaleVertices(l,n,o,t.factor1,t.factor2,c,1);return g&&g<_.data.geometry.extent.width&&C?_.updateVertices(l,C):(p(j,h),v(u,h),C=u.operation,r(t,u)),t}).next(t=>("end"===t.action&&(m.cursor="grab"),t))})}_createManipulator(){return new g({view:this._view,graphic:this._graphic,selectable:!0,cursor:"grab"})}}export{j as ScaleManipulation,y as calculateDiagonalResizeHandleScale};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import"../../../../intl.js";import t from"../../../../core/Accessor.js";import{unitRGBAFromColor as i,multiplyOpacityToUnitRGBA as s,getContrast as n,multiplyOpacity as o}from"../../../../core/colorUtils.js";import"../../../../core/has.js";import{nextHighestPowerOfTen as l,deg2rad as r}from"../../../../core/mathUtils.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import{formatDecimal as c,formatImperialVerticalLength as h,formatImperialLength as u,formatMetricVerticalLength as d,formatMetricLength as m}from"../../../../core/quantityFormatUtils.js";import{toUnit as g}from"../../../../core/quantityUtils.js";import{watch as p,syncAndInitial as _,initial as v}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as b,createRenderScreenPointArray as L}from"../../../../core/screenUtils.js";import{adaptiveImperialLengthUnit as w,convertUnit as y}from"../../../../core/unitUtils.js";import{property as S}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{dot as E}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{g as V,f as z}from"../../../../chunks/vec32.js";import{create as A}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{renderScreenSpaceTangent as P}from"../../interactive/support/viewUtils.js";import{LabelVisualElement as j,mirrorPosition as M}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as C}from"../../interactive/visualElements/LineVisualElement.js";import{MeasurementArrowVisualElement as O}from"../../interactive/visualElements/MeasurementArrowVisualElement.js";import{RightAngleQuadVisualElement as x}from"../../interactive/visualElements/RightAngleQuadVisualElement.js";import{GeodesicSegment as D,EuclideanSegment as G}from"../../interactive/visualElements/support/Segment.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";import{geodesicDistanceThreshold as k}from"../../../support/geodesicMeasurementUtils.js";import{onLocaleChange as T}from"../../../../intl/locale.js";import{fetchMessageBundle as U}from"../../../../intl/messages.js";let R=class extends t{get _parameters(){const e=this.view.effectiveTheme,{accentColor:t,textColor:l}=e,r=i(t),a=s(t,.75),c=i(n(t)),h=n(l,160);return{accentColor:r,contrastColor:c,translucentAccentColor:a,triangleLineWidth:3,geodesicProjectionLineWidth:2,guideLineWidth:2,guideStippleLengthPixels:3,directLabelFontSize:16,horizontalLabelFontSize:12,verticalLabelFontSize:12,textColor:l,textBackgroundColor:o(h,.6),textCalloutColor:o(h,.5)}}get visible(){return this.analysisView.visible}get viewMode(){const{elevationAlignedStartPoint:e,elevationAlignedEndPoint:t}=this.analysisView;if(null==e||null==t||e.equals(t))return 0;const i=this.analysisView.result;if(null==i)return 1;if("geodesic"===this.actualVisualizedMeasurement)return this._requiresGeodesicGuideAt(this._startPosition)||this._requiresGeodesicGuideAt(this._endPosition)?3:1;const{verticalDistance:s,horizontalDistance:n}=i,o=g(s,"meters").value,l=g(n,"meters").value;return Math.min(o/l,l/o)<this.triangleCollapseRatioThreshold?1:2}get actualVisualizedMeasurement(){const{measurementMode:e,result:t}=this.analysisView;switch(e){case 0:return null!=t&&g(t.horizontalDistance,"meters").value>k?"geodesic":"euclidean";case 1:return"euclidean";case 2:return"geodesic"}}get allowVisualElementsOrientationChange(){return null==this._triangleOrientationOverride}set allowVisualElementsOrientationChange(e){null==this._triangleOrientationOverride!==e&&(null==this._triangleOrientationOverride?this._triangleOrientationOverride=this._actualVisualElementsOrientation:this._triangleOrientationOverride=null)}get labels(){return"geodesic"===this.actualVisualizedMeasurement?{direct:null,horizontal:this._segmentLabel,vertical:this._verticalLabel}:{direct:this._segmentLabel,horizontal:this._horizontalLabel,vertical:this._verticalLabel}}constructor(e){super(e),this._segmentVisualElement=null,this._triangleVisualElement=null,this._rightAngleQuad=null,this._projectedGeodesicLine=null,this._geodesicStartHint=null,this._geodesicEndHint=null,this._segmentLabel=null,this._verticalLabel=null,this._horizontalLabel=null,this._startPosition=A(),this._endPosition=A(),this._cornerPosition=A(),this._startPositionAtSeaLevel=A(),this._endPositionAtSeaLevel=A(),this._triangleOrientationOverride=null,this.messages=null,this.loadingMessages=!0,this.visualElementOrientation=0,this.triangleCollapseRatioThreshold=.03}initialize(){const e={attached:!0,view:this.view,isDecoration:!0},{guideLineWidth:t,guideStippleLengthPixels:i,triangleLineWidth:s,geodesicProjectionLineWidth:n,directLabelFontSize:o,verticalLabelFontSize:l,horizontalLabelFontSize:r}=this._parameters;this._segmentVisualElement=new O({...e,geometry:null,renderOccluded:4}),this._triangleVisualElement=new C({...e,width:s,renderOccluded:4}),this._rightAngleQuad=new x({...e,renderOccluded:4});const a={...e,polygonOffset:!0,renderOccluded:4};this._projectedGeodesicLine=new C({...a,width:n,stipplePattern:H(i)}),this._geodesicStartHint=new C({...a,width:t,stipplePattern:H(i)}),this._geodesicEndHint=new C({...a,width:t,stipplePattern:H(i)}),this._segmentLabel=new j({...e,fontSize:o}),this._verticalLabel=new j({...e,fontSize:l}),this._horizontalLabel=new j({...e,fontSize:r}),this.addHandles([p(()=>{const{elevationAlignedStartPoint:e,elevationAlignedEndPoint:t}=this.analysisView,i=this.view;return{view:i,camera:i.state.camera,viewMode:this.viewMode,elevationAlignedStartPoint:e,elevationAlignedEndPoint:t,orientation:this._actualVisualElementsOrientation,visualizedMeasurement:this.actualVisualizedMeasurement,stripeLength:this._measurementArrowStripeLength}},e=>this._updateGeometryAndViewMode(e),_),p(()=>({visible:this.visible,viewMode:this.viewMode}),e=>this._updateVisualElementVisibility(e),_),p(()=>({text:this._labelsText,visualizedMeasurement:this.actualVisualizedMeasurement}),e=>this._updateLabelText(e),_),p(()=>({visible:this.visible,viewMode:this.viewMode}),e=>this._updateLabelVisibility(e),_),p(()=>this._measurementArrowStripeLength,e=>this._updateSegmentStripeLength(e),_),T(()=>this._updateMessageBundle()),p(()=>this._parameters,({textBackgroundColor:e,textCalloutColor:t,textColor:i,translucentAccentColor:s,accentColor:n,contrastColor:o})=>{const{_segmentLabel:l,_verticalLabel:r,_horizontalLabel:a,_triangleVisualElement:c,_rightAngleQuad:h,_projectedGeodesicLine:u,_geodesicStartHint:d,_geodesicEndHint:m,_segmentVisualElement:g}=this;l.backgroundColor=e,l.calloutColor=t,l.textColor=i,r.backgroundColor=e,r.calloutColor=t,r.textColor=i,a.backgroundColor=e,a.calloutColor=t,a.textColor=i,c.color=s,h.color=s,u.color=s,d.color=s,m.color=s,g.color=n,g.contrastColor=o},v)]),this._updateMessageBundle()}destroy(){this._segmentVisualElement=a(this._segmentVisualElement),this._triangleVisualElement=a(this._triangleVisualElement),this._rightAngleQuad=a(this._rightAngleQuad),this._projectedGeodesicLine=a(this._projectedGeodesicLine),this._geodesicStartHint=a(this._geodesicStartHint),this._geodesicEndHint=a(this._geodesicEndHint),this._segmentLabel=a(this._segmentLabel),this._verticalLabel=a(this._verticalLabel),this._horizontalLabel=a(this._horizontalLabel),this.set("view",null)}_updateVisualElementVisibility({visible:e,viewMode:t}){if(this._segmentVisualElement.visible=!1,this._triangleVisualElement.visible=!1,this._rightAngleQuad.visible=!1,this._projectedGeodesicLine.visible=!1,this._geodesicStartHint.visible=!1,this._geodesicEndHint.visible=!1,e)switch(t){case 0:break;case 1:this._segmentVisualElement.visible=!0;break;case 2:this._segmentVisualElement.visible=!0,this._triangleVisualElement.visible=!0,this._rightAngleQuad.visible=!0;break;case 3:this._segmentVisualElement.visible=!0,this._projectedGeodesicLine.visible=!0,this._geodesicStartHint.visible=!0,this._geodesicEndHint.visible=!0}}_updateGeometryAndViewMode({view:e,camera:t,viewMode:i,elevationAlignedStartPoint:s,elevationAlignedEndPoint:n,orientation:o,visualizedMeasurement:l,stripeLength:r}){const a=e.renderCoordsHelper;if(null==a||null==s||null==n||s.equals(n))return;let c=this._startPosition,h=this._endPosition;a.toRenderCoords(s,c),a.toRenderCoords(n,h);const u=1===o?1:-1,d=u*(a.getAltitude(h)-a.getAltitude(c));d<0&&(c=this._endPosition,h=this._startPosition);const m="geodesic"===l?new D(this._startPosition,this._endPosition,a.spatialReference):new G(this._startPosition,this._endPosition);switch(this._segmentVisualElement.geometry=m,this._updateSegmentStripeLength(r),i){case 1:this._updateSegment(m,o);break;case 2:this._updateSegmentAndTriangle({view:e,camera:t,segment:m,orientation:o,startPosition:c,endPosition:h,deltaSign:u,altitudeDelta:d});break;case 3:this._updateSegmentAndProjection({view:e,orientation:o,startPosition:c,endPosition:h})}}_updateSegment(e,t){this._segmentLabel.anchor=1===t?"top":"bottom",this._segmentLabel.geometry={type:"segment",segment:e,sampleLocation:"center"}}_updateSegmentAndTriangle({view:{renderCoordsHelper:e},camera:t,segment:i,orientation:s,startPosition:n,endPosition:o,deltaSign:l,altitudeDelta:r}){const a=this._cornerPosition;e.worldUpAtPosition(n,a),V(a,a,l*Math.abs(r)),z(a,a,n),this._triangleVisualElement.geometry=[[[n[0],n[1],n[2]],[a[0],a[1],a[2]],[o[0],o[1],o[2]]]],this._rightAngleQuad.geometry={previous:n,center:a,next:o};const c=new G(n,a),h=new G(a,o),u=F(n,o,a,s,t);this._segmentLabel.anchor=u.segment,this._segmentLabel.geometry={type:"segment",segment:i,sampleLocation:"center"},this._verticalLabel.geometry={type:"segment",segment:c,sampleLocation:"center"},this._verticalLabel.anchor=u.vertical,this._horizontalLabel.geometry={type:"segment",segment:h,sampleLocation:"center"},this._horizontalLabel.anchor=u.horizontal}_updateSegmentAndProjection({view:{renderCoordsHelper:e},orientation:t,startPosition:i,endPosition:s}){e.setAltitude(this._startPositionAtSeaLevel,0,i),e.setAltitude(this._endPositionAtSeaLevel,0,s);const n=new D(this._startPositionAtSeaLevel,this._endPositionAtSeaLevel,e.spatialReference);this._projectedGeodesicLine.setGeometryFromSegment(n),this._geodesicStartHint.setGeometryFromSegment(new G(this._startPositionAtSeaLevel,i)),this._geodesicEndHint.setGeometryFromSegment(new G(this._endPositionAtSeaLevel,s)),this._segmentLabel.geometry={type:"segment",segment:n,sampleLocation:"center"},this._segmentLabel.anchor=1===t?"top":"bottom"}_updateLabelText({text:e,visualizedMeasurement:t}){null!=e?(this._segmentLabel.text="euclidean"===t?e.directDistance:e.horizontalDistance,this._horizontalLabel.text=e.horizontalDistance,this._verticalLabel.text=e.verticalDistance):(this._segmentLabel.text=null,this._horizontalLabel.text=null,this._verticalLabel.text=null),this.notifyChange("labels")}_updateLabelVisibility({visible:e,viewMode:t}){const i=this._segmentLabel,s=this._horizontalLabel,n=this._verticalLabel;if(i.visible=!1,s.visible=!1,n.visible=!1,e)switch(t){case 1:case 3:i.visible=!0;break;case 2:i.visible=!0,s.visible=!0,n.visible=!0}}get _labelsText(){if(this.destroyed)return null;const e=this.messages,t=this.analysisView.result;if(null==t||null==e)return null;const{directDistance:i,horizontalDistance:s,verticalDistance:n}=t,o=this.analysisView.unit,l=e=>({directDistance:"",horizontalDistance:"",verticalDistance:"",...e});switch(o){case"metric":return l({directDistance:i&&m(e,i),horizontalDistance:s&&m(e,s),verticalDistance:n&&d(e,n)});case"imperial":return l({directDistance:i&&u(e,i),horizontalDistance:s&&u(e,s),verticalDistance:n&&h(e,n)});default:return l({directDistance:i&&c(e,i,o),horizontalDistance:s&&c(e,s,o),verticalDistance:n&&c(e,n,o)})}}_updateSegmentStripeLength(e){const t=this._segmentVisualElement;null!=e?(t.stripeLength=e,t.stripesEnabled=!0):t.stripesEnabled=!1}get _actualVisualElementsOrientation(){if(null!=this._triangleOrientationOverride)return this._triangleOrientationOverride;const e=this.visualElementOrientation;return 0===e?this.view.state.camera.aboveGround?1:2:e}_requiresGeodesicGuideAt(e){const t=this.view;if(!t?.state)return!1;const i=t.state.camera,s=t.renderCoordsHelper;if(!s)return!1;const n=i.computeScreenPixelSizeAt(e);return s.getAltitude(e)/n>=10}get _measurementArrowStripeLength(){const{result:e,unit:t}=this.analysisView;if(null==e)return null;let i=null;const s=e.directDistance;switch(t){case"metric":i=s&&g(s,"meters");break;case"imperial":i=s&&g(s,w(s.value,s.unit));break;default:i=s&&g(s,t)}if(null==i)return null;return l(i.value/30)*y(1,i.unit,"meters")}_updateMessageBundle(){this.loadingMessages=!0,U("esri/core/t9n/Units").then(e=>{this.messages=e}).finally(()=>{this.loadingMessages=!1})}get testData(){}};function F(e,t,i,s,n){const o=q,l=W;n.projectToRenderScreen(i,o),n.projectToRenderScreen(t,l);const r={segment:"bottom",horizontal:"top",vertical:o[0]<l[0]?"left":"right"};{const s=B,o=I;if(P(e,i,n,s),P(e,t,n,o),E(s,o)>=Q){const e=Math.sign(s[1])===Math.sign(o[1]);r.segment=e?M(r.vertical):r.vertical}else{const e=J;P(i,t,n,e),E(e,o)>=Q&&(r.segment=Math.sign(e[0])===Math.sign(o[0])?M(r.horizontal):r.horizontal)}}if(2===s){const e=e=>"top"===e?"bottom":"top";r.segment=e(r.segment),r.horizontal=e(r.horizontal),r.vertical=e(r.vertical)}return r}e([S()],R.prototype,"_parameters",null),e([S()],R.prototype,"_triangleOrientationOverride",void 0),e([S()],R.prototype,"messages",void 0),e([S()],R.prototype,"view",void 0),e([S()],R.prototype,"analysis",void 0),e([S()],R.prototype,"analysisView",void 0),e([S()],R.prototype,"loadingMessages",void 0),e([S()],R.prototype,"visible",null),e([S()],R.prototype,"viewMode",null),e([S()],R.prototype,"actualVisualizedMeasurement",null),e([S()],R.prototype,"visualElementOrientation",void 0),e([S()],R.prototype,"triangleCollapseRatioThreshold",void 0),e([S()],R.prototype,"allowVisualElementsOrientationChange",null),e([S()],R.prototype,"labels",null),e([S()],R.prototype,"_labelsText",null),e([S()],R.prototype,"_actualVisualElementsOrientation",null),e([S()],R.prototype,"_measurementArrowStripeLength",null),R=e([f("esri.views.3d.analysis.DirectLineMeasurement.DirectLineMeasurementVisualization")],R);const Q=Math.cos(r(12)),q=b(),W=b(),B=L(),I=L(),J=L();export{R as DirectLineMeasurementVisualization};
|
|
5
|
+
import{__decorate as e}from"tslib";import"../../../../intl.js";import t from"../../../../core/Accessor.js";import{unitRGBAFromColor as i,multiplyOpacityToUnitRGBA as s,getContrast as n,multiplyOpacity as l}from"../../../../core/colorUtils.js";import"../../../../core/has.js";import{nextHighestPowerOfTen as o,deg2rad as r}from"../../../../core/mathUtils.js";import{destroyMaybe as a}from"../../../../core/maybe.js";import{formatDecimal as c,formatImperialVerticalLength as h,formatImperialLength as u,formatMetricVerticalLength as d,formatMetricLength as m}from"../../../../core/quantityFormatUtils.js";import{toUnit as g}from"../../../../core/quantityUtils.js";import{watch as p,syncAndInitial as _,initial as v}from"../../../../core/reactiveUtils.js";import{createRenderScreenPointArray3 as b,createRenderScreenPointArray as L}from"../../../../core/screenUtils.js";import{adaptiveImperialLengthUnit as w,convertUnit as y}from"../../../../core/unitUtils.js";import{property as S}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{dot as E}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{g as V,f as z}from"../../../../chunks/vec32.js";import{create as A}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{renderScreenSpaceTangent as P}from"../../interactive/support/viewUtils.js";import{LabelVisualElement as j,mirrorPosition as M}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as C}from"../../interactive/visualElements/LineVisualElement.js";import{MeasurementArrowVisualElement as O}from"../../interactive/visualElements/MeasurementArrowVisualElement.js";import{RightAngleQuadVisualElement as x}from"../../interactive/visualElements/RightAngleQuadVisualElement.js";import{GeodesicSegment as D,EuclideanSegment as G}from"../../interactive/visualElements/support/Segment.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";import{geodesicDistanceThreshold as k}from"../../../support/geodesicMeasurementUtils.js";import{onLocaleChange as T}from"../../../../intl/locale.js";import{fetchMessageBundle as U}from"../../../../intl/messages.js";let R=class extends t{get _parameters(){const e=this.view.effectiveTheme,{accentColor:t,textColor:o}=e,r=i(t),a=s(t,.75),c=i(n(t)),h=n(o,160);return{accentColor:r,contrastColor:c,translucentAccentColor:a,triangleLineWidth:3,geodesicProjectionLineWidth:2,guideLineWidth:2,guideStippleLengthPixels:3,directLabelFontSize:16,horizontalLabelFontSize:12,verticalLabelFontSize:12,textColor:o,textBackgroundColor:l(h,.6),textCalloutColor:l(h,.5)}}get visible(){return this.analysisView.visible}get viewMode(){const{elevationAlignedStartPoint:e,elevationAlignedEndPoint:t}=this.analysisView;if(null==e||null==t||e.equals(t))return 0;const i=this.analysisView.result;if(null==i)return 1;if("geodesic"===this.actualVisualizedMeasurement)return this._requiresGeodesicGuideAt(this._startPosition)||this._requiresGeodesicGuideAt(this._endPosition)?3:1;const{verticalDistance:s,horizontalDistance:n}=i,l=g(s,"meters").value,o=g(n,"meters").value;return Math.min(l/o,o/l)<this.triangleCollapseRatioThreshold?1:2}get actualVisualizedMeasurement(){const{measurementMode:e,result:t}=this.analysisView;switch(e){case 0:return null!=t&&g(t.horizontalDistance,"meters").value>k?"geodesic":"euclidean";case 1:return"euclidean";case 2:return"geodesic"}}get allowVisualElementsOrientationChange(){return null==this._triangleOrientationOverride}set allowVisualElementsOrientationChange(e){null==this._triangleOrientationOverride!==e&&(null==this._triangleOrientationOverride?this._triangleOrientationOverride=this._actualVisualElementsOrientation:this._triangleOrientationOverride=null)}get labels(){return"geodesic"===this.actualVisualizedMeasurement?{direct:null,horizontal:this._segmentLabel,vertical:this._verticalLabel}:{direct:this._segmentLabel,horizontal:this._horizontalLabel,vertical:this._verticalLabel}}constructor(e){super(e),this._segmentVisualElement=null,this._triangleVisualElement=null,this._rightAngleQuad=null,this._projectedGeodesicLine=null,this._geodesicStartHint=null,this._geodesicEndHint=null,this._segmentLabel=null,this._verticalLabel=null,this._horizontalLabel=null,this._startPosition=A(),this._endPosition=A(),this._cornerPosition=A(),this._startPositionAtSeaLevel=A(),this._endPositionAtSeaLevel=A(),this._triangleOrientationOverride=null,this.messages=null,this.loadingMessages=!0,this.visualElementOrientation=0,this.triangleCollapseRatioThreshold=.03}initialize(){const e={attached:!0,view:this.view,isDecoration:!0},{guideLineWidth:t,guideStippleLengthPixels:i,triangleLineWidth:s,geodesicProjectionLineWidth:n,directLabelFontSize:l,verticalLabelFontSize:o,horizontalLabelFontSize:r}=this._parameters;this._segmentVisualElement=new O({...e,geometry:null,renderOccluded:4}),this._triangleVisualElement=new C({...e,width:s,renderOccluded:4}),this._rightAngleQuad=new x({...e,renderOccluded:4});const a={...e,polygonOffset:!0,renderOccluded:4};this._projectedGeodesicLine=new C({...a,width:n,stipplePattern:H(i)}),this._geodesicStartHint=new C({...a,width:t,stipplePattern:H(i)}),this._geodesicEndHint=new C({...a,width:t,stipplePattern:H(i)}),this._segmentLabel=new j({...e,fontSize:l}),this._verticalLabel=new j({...e,fontSize:o}),this._horizontalLabel=new j({...e,fontSize:r}),this.addHandles([p(()=>{const{elevationAlignedStartPoint:e,elevationAlignedEndPoint:t}=this.analysisView,i=this.view;return{view:i,camera:i.state.camera,viewMode:this.viewMode,elevationAlignedStartPoint:e,elevationAlignedEndPoint:t,orientation:this._actualVisualElementsOrientation,visualizedMeasurement:this.actualVisualizedMeasurement,stripeLength:this._measurementArrowStripeLength}},e=>this._updateGeometryAndViewMode(e),_),p(()=>({visible:this.visible,viewMode:this.viewMode}),e=>this._updateVisualElementVisibility(e),_),p(()=>({text:this._labelsText,visualizedMeasurement:this.actualVisualizedMeasurement}),e=>this._updateLabelText(e),_),p(()=>({visible:this.visible,viewMode:this.viewMode}),e=>this._updateLabelVisibility(e),_),p(()=>this._measurementArrowStripeLength,e=>this._updateSegmentStripeLength(e),_),T(()=>this._updateMessageBundle()),p(()=>this._parameters,({textBackgroundColor:e,textCalloutColor:t,textColor:i,translucentAccentColor:s,accentColor:n,contrastColor:l})=>{const{_segmentLabel:o,_verticalLabel:r,_horizontalLabel:a,_triangleVisualElement:c,_rightAngleQuad:h,_projectedGeodesicLine:u,_geodesicStartHint:d,_geodesicEndHint:m,_segmentVisualElement:g}=this;o.backgroundColor=e,o.calloutColor=t,o.textColor=i,r.backgroundColor=e,r.calloutColor=t,r.textColor=i,a.backgroundColor=e,a.calloutColor=t,a.textColor=i,c.color=s,h.color=s,u.color=s,d.color=s,m.color=s,g.color=n,g.contrastColor=l},v)]),this._updateMessageBundle()}destroy(){this._segmentVisualElement=a(this._segmentVisualElement),this._triangleVisualElement=a(this._triangleVisualElement),this._rightAngleQuad=a(this._rightAngleQuad),this._projectedGeodesicLine=a(this._projectedGeodesicLine),this._geodesicStartHint=a(this._geodesicStartHint),this._geodesicEndHint=a(this._geodesicEndHint),this._segmentLabel=a(this._segmentLabel),this._verticalLabel=a(this._verticalLabel),this._horizontalLabel=a(this._horizontalLabel),this.set("view",null)}_updateVisualElementVisibility({visible:e,viewMode:t}){if(this._segmentVisualElement.visible=!1,this._triangleVisualElement.visible=!1,this._rightAngleQuad.visible=!1,this._projectedGeodesicLine.visible=!1,this._geodesicStartHint.visible=!1,this._geodesicEndHint.visible=!1,e)switch(t){case 0:break;case 1:this._segmentVisualElement.visible=!0;break;case 2:this._segmentVisualElement.visible=!0,this._triangleVisualElement.visible=!0,this._rightAngleQuad.visible=!0;break;case 3:this._segmentVisualElement.visible=!0,this._projectedGeodesicLine.visible=!0,this._geodesicStartHint.visible=!0,this._geodesicEndHint.visible=!0}}_updateGeometryAndViewMode({view:e,camera:t,viewMode:i,elevationAlignedStartPoint:s,elevationAlignedEndPoint:n,orientation:l,visualizedMeasurement:o,stripeLength:r}){const a=e.renderCoordsHelper;if(null==a||null==s||null==n||s.equals(n))return;let c=this._startPosition,h=this._endPosition;a.toRenderCoords(s,c),a.toRenderCoords(n,h);const u=1===l?1:-1,d=u*(a.getAltitude(h)-a.getAltitude(c));d<0&&(c=this._endPosition,h=this._startPosition);const m="geodesic"===o?new D(this._startPosition,this._endPosition,a.spatialReference):new G(this._startPosition,this._endPosition);switch(this._segmentVisualElement.geometry=m,this._updateSegmentStripeLength(r),i){case 1:this._updateSegment(m,l);break;case 2:this._updateSegmentAndTriangle({view:e,camera:t,segment:m,orientation:l,startPosition:c,endPosition:h,deltaSign:u,altitudeDelta:d});break;case 3:this._updateSegmentAndProjection({view:e,orientation:l,startPosition:c,endPosition:h})}}_updateSegment(e,t){this._segmentLabel.anchor=1===t?"top":"bottom",this._segmentLabel.geometry={type:"segment",segment:e,sampleLocation:"center"}}_updateSegmentAndTriangle({view:{renderCoordsHelper:e},camera:t,segment:i,orientation:s,startPosition:n,endPosition:l,deltaSign:o,altitudeDelta:r}){const a=this._cornerPosition;e.worldUpAtPosition(n,a),V(a,a,o*Math.abs(r)),z(a,a,n),this._triangleVisualElement.geometry=[[[n[0],n[1],n[2]],[a[0],a[1],a[2]],[l[0],l[1],l[2]]]],this._rightAngleQuad.geometry={previous:n,center:a,next:l};const c=new G(n,a),h=new G(a,l),u=F(n,l,a,s,t);u&&(this._segmentLabel.anchor=u.segment,this._segmentLabel.geometry={type:"segment",segment:i,sampleLocation:"center"},this._verticalLabel.geometry={type:"segment",segment:c,sampleLocation:"center"},this._verticalLabel.anchor=u.vertical,this._horizontalLabel.geometry={type:"segment",segment:h,sampleLocation:"center"},this._horizontalLabel.anchor=u.horizontal)}_updateSegmentAndProjection({view:{renderCoordsHelper:e},orientation:t,startPosition:i,endPosition:s}){e.setAltitude(this._startPositionAtSeaLevel,0,i),e.setAltitude(this._endPositionAtSeaLevel,0,s);const n=new D(this._startPositionAtSeaLevel,this._endPositionAtSeaLevel,e.spatialReference);this._projectedGeodesicLine.setGeometryFromSegment(n),this._geodesicStartHint.setGeometryFromSegment(new G(this._startPositionAtSeaLevel,i)),this._geodesicEndHint.setGeometryFromSegment(new G(this._endPositionAtSeaLevel,s)),this._segmentLabel.geometry={type:"segment",segment:n,sampleLocation:"center"},this._segmentLabel.anchor=1===t?"top":"bottom"}_updateLabelText({text:e,visualizedMeasurement:t}){null!=e?(this._segmentLabel.text="euclidean"===t?e.directDistance:e.horizontalDistance,this._horizontalLabel.text=e.horizontalDistance,this._verticalLabel.text=e.verticalDistance):(this._segmentLabel.text=null,this._horizontalLabel.text=null,this._verticalLabel.text=null),this.notifyChange("labels")}_updateLabelVisibility({visible:e,viewMode:t}){const i=this._segmentLabel,s=this._horizontalLabel,n=this._verticalLabel;if(i.visible=!1,s.visible=!1,n.visible=!1,e)switch(t){case 1:case 3:i.visible=!0;break;case 2:i.visible=!0,s.visible=!0,n.visible=!0}}get _labelsText(){if(this.destroyed)return null;const e=this.messages,t=this.analysisView.result;if(null==t||null==e)return null;const{directDistance:i,horizontalDistance:s,verticalDistance:n}=t,l=this.analysisView.unit,o=e=>({directDistance:"",horizontalDistance:"",verticalDistance:"",...e});switch(l){case"metric":return o({directDistance:i&&m(e,i),horizontalDistance:s&&m(e,s),verticalDistance:n&&d(e,n)});case"imperial":return o({directDistance:i&&u(e,i),horizontalDistance:s&&u(e,s),verticalDistance:n&&h(e,n)});default:return o({directDistance:i&&c(e,i,l),horizontalDistance:s&&c(e,s,l),verticalDistance:n&&c(e,n,l)})}}_updateSegmentStripeLength(e){const t=this._segmentVisualElement;null!=e?(t.stripeLength=e,t.stripesEnabled=!0):t.stripesEnabled=!1}get _actualVisualElementsOrientation(){if(null!=this._triangleOrientationOverride)return this._triangleOrientationOverride;const e=this.visualElementOrientation;return 0===e?this.view.state.camera.aboveGround?1:2:e}_requiresGeodesicGuideAt(e){const t=this.view;if(!t?.state)return!1;const i=t.state.camera,s=t.renderCoordsHelper;if(!s)return!1;const n=i.computeScreenPixelSizeAt(e);return s.getAltitude(e)/n>=10}get _measurementArrowStripeLength(){const{result:e,unit:t}=this.analysisView;if(null==e)return null;let i=null;const s=e.directDistance;switch(t){case"metric":i=s&&g(s,"meters");break;case"imperial":i=s&&g(s,w(s.value,s.unit));break;default:i=s&&g(s,t)}if(null==i)return null;return o(i.value/30)*y(1,i.unit,"meters")}_updateMessageBundle(){this.loadingMessages=!0,U("esri/core/t9n/Units").then(e=>{this.messages=e}).finally(()=>{this.loadingMessages=!1})}get testData(){}};function F(e,t,i,s,n){const l=P(e,i,n,B),o=P(e,t,n,I);if(null==l||null==o)return null;const r=n.projectToRenderScreen(i,q),a=n.projectToRenderScreen(t,W),c={segment:"bottom",horizontal:"top",vertical:null==r||null==a||r[0]<a[0]?"left":"right"};if(E(l,o)>=Q){const e=Math.sign(l[1])===Math.sign(o[1]);c.segment=e?M(c.vertical):c.vertical}else{const e=J;P(i,t,n,e),E(e,o)>=Q&&(c.segment=Math.sign(e[0])===Math.sign(o[0])?M(c.horizontal):c.horizontal)}if(2===s){const e=e=>"top"===e?"bottom":"top";c.segment=e(c.segment),c.horizontal=e(c.horizontal),c.vertical=e(c.vertical)}return c}e([S()],R.prototype,"_parameters",null),e([S()],R.prototype,"_triangleOrientationOverride",void 0),e([S()],R.prototype,"messages",void 0),e([S()],R.prototype,"view",void 0),e([S()],R.prototype,"analysis",void 0),e([S()],R.prototype,"analysisView",void 0),e([S()],R.prototype,"loadingMessages",void 0),e([S()],R.prototype,"visible",null),e([S()],R.prototype,"viewMode",null),e([S()],R.prototype,"actualVisualizedMeasurement",null),e([S()],R.prototype,"visualElementOrientation",void 0),e([S()],R.prototype,"triangleCollapseRatioThreshold",void 0),e([S()],R.prototype,"allowVisualElementsOrientationChange",null),e([S()],R.prototype,"labels",null),e([S()],R.prototype,"_labelsText",null),e([S()],R.prototype,"_actualVisualElementsOrientation",null),e([S()],R.prototype,"_measurementArrowStripeLength",null),R=e([f("esri.views.3d.analysis.DirectLineMeasurement.DirectLineMeasurementVisualization")],R);const Q=Math.cos(r(12)),q=b(),W=b(),B=L(),I=L(),J=L();export{R as DirectLineMeasurementVisualization};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import i from"../../../../analysis/SlicePlane.js";import t from"../../../../core/Accessor.js";import a from"../../../../core/Logger.js";import{watch as l,sync as s}from"../../../../core/reactiveUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{
|
|
5
|
+
import{__decorate as e}from"tslib";import i from"../../../../analysis/SlicePlane.js";import t from"../../../../core/Accessor.js";import a from"../../../../core/Logger.js";import{watch as l,sync as s}from"../../../../core/reactiveUtils.js";import{property as n}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as r}from"../../../../core/accessorSupport/decorators/subclass.js";import{a as o}from"../../../../chunks/boundedPlane.js";import c from"../../../../layers/Layer.js";import h from"../../../../layers/buildingSublayers/BuildingComponentSublayer.js";import{isBuildingSceneLayerView3D as u,projectAndElevationAlignShape as d,projectedShapeToPlane as p,planeToShape as y}from"./sliceToolUtils.js";import{logFailedGeometryProjectionError as w}from"../support/projectionUtils.js";import{isTerrainSurfaceLayer as v}from"../../terrain/isTerrainSurfaceLayer.js";let f=class extends t{constructor(e){super(e),this._internalChange=!1,this._currentSlicePlane=null}initialize(){this.addHandles(this.analysis.excludedLayers.on("before-add",e=>{const i=e.item;null!=i&&(i instanceof c||i instanceof h)?i instanceof c&&v(i)?(a.getLogger(this).error("excludedLayers",`Layer '${i.title}, id:${i.id}' of type '${i.type}' can not be individually excluded from slicing. Use 'excludeGroundSurface' instead.`),e.preventDefault()):this.analysis.excludedLayers.includes(i)&&e.preventDefault():(a.getLogger(this).error("excludedLayers","Invalid layer type, layer must derive from Layer or BuildingComponentSublayer"),e.preventDefault())})),S(this.view,this),this.addHandles([l(()=>this.analysisViewData.plane,()=>{this._internalChange||this._updateSlicePlaneFromBoundedPlane(),this._updateLayerViews()},s),l(()=>this.analysis.excludeGroundSurface,()=>this._updateLayerViews(),s),this.analysis.excludedLayers.on("change",()=>this._updateLayerViews()),l(()=>[this.analysisViewData.active,this.analysisViewData.visible],()=>{this._updateActiveController(),this._updateViewSlicePlane(),this._updateViewSlicePlaneDecoration()},s),l(()=>this._allLayerAndSubLayerViews,()=>this._updateLayerViews())]),this.addHandles([l(()=>this.analysis.shape,()=>{this._internalChange||(this._updateBoundedPlaneFromSlicePlane(),this._updateViewSlicePlane())},s),l(()=>"web-scene"!==this.analysis.origin?.type,()=>this._updateViewSlicePlaneDecoration(),s)],"analysis"),this._updateActiveController(),this._updateBoundedPlaneFromSlicePlane(),this._updateViewSlicePlane(),this._updateViewSlicePlaneDecoration()}destroy(){this.analysisViewData.active&&(this.analysisViewData.active=!1,this.view.slice.plane=null,this._updateActiveController(),this._updateViewSlicePlane()),L(this.view,this),this.set("view",null)}get _allLayerAndSubLayerViews(){const e=this.view.allLayerViews.items;return e.concat(e.filter(u).flatMap(({sublayerViews:e})=>e.items))}_updateBoundedPlaneFromSlicePlane(){const e=this.analysis.shape,t=this._currentSlicePlane;if(null==t&&null==e||null!=t&&null!=e&&e.equals(t))return;let l=null,s=null;if(null!=e?.position){const t=e.position.spatialReference,n=d(e,this.view);null==n&&w(this.analysis,t,a.getLogger(this)),l=p(n,this.view,{tiltEnabled:this.analysis.tiltEnabled},o()),null!=l&&(s=new i({heading:e.heading,tilt:e.tilt,position:e.position,width:e.width,height:e.height}))}this._currentSlicePlane=s,this._internalChange=!0,this.analysisViewData.plane=l,this._internalChange=!1}_updateSlicePlaneFromBoundedPlane(){const e=this.analysisViewData.plane,t=y(e,this.view,this.view.spatialReference,new i);let a=null;null!=t&&(a=new i({heading:t.heading,tilt:t.tilt,position:t.position,width:t.width,height:t.height})),this._currentSlicePlane=a,this._internalChange=!0,this.analysis.shape=t,this._internalChange=!1,this._updateViewSlicePlane()}_updateActiveController(){if(g)return;const e=b(this.view);if(!e)return;if(this.analysisViewData.active)null!=e.activeController&&e.activeController!==this?(g=!0,e.activeController.analysisViewData.active=!1,g=!1):null!=e.activeController&&e.activeController,this._updateLayerViews(),e.activeController=this;else{if(null!=e.activeController&&e.activeController!==this)return;null!=e.activeController&&e.activeController===this&&(e.activeController=null,this._updateLayerViews())}}_updateViewSlicePlane(){V(this.view)}_updateViewSlicePlaneDecoration(){_(this.view)}_updateLayerViews(){const e=null!=this.analysisViewData.plane&&this.analysisViewData.visible&&this.analysisViewData.active,i=[],t=e=>{"layers"in e?e.layers.forEach(t):i.push(e)};this.analysis.excludedLayers.forEach(t),this.view.allLayerViews.forEach(t=>{t.destroyed||("slicePlaneEnabled"in t&&(t.slicePlaneEnabled=e&&!i.includes(t.layer)),"sublayerViews"in t&&t.sublayerViews.forEach(t=>{t.slicePlaneEnabled=e&&!i.includes(t.sublayer)}))}),null!=this.view.basemapTerrain&&(this.view.basemapTerrain.slicePlaneEnabled=e&&!this.analysis.excludeGroundSurface)}};e([n()],f.prototype,"view",void 0),e([n()],f.prototype,"analysis",void 0),e([n()],f.prototype,"analysisViewData",void 0),e([n()],f.prototype,"_allLayerAndSubLayerViews",null),f=e([r("esri.views.3d.analysis.Slice.SliceController")],f);const m=new Map;let g=!1;function V(e){const i=b(e),t=i?.activeController;null!=t?.analysisViewData.plane&&t.analysisViewData.visible?e.slice.plane=t.analysisViewData.plane:e.slice.plane=null}function _(e){const i=b(e),t=i?.activeController;e.slice.isDecoration="web-scene"!==t?.analysis.origin?.type}function S(e,i){m.has(e)||m.set(e,{all:[],activeController:null}),m.get(e)?.all.push(i)}function b(e){return m.get(e)}function L(e,i){if(!m.has(e))throw new Error("view expected in global slice register");const t=m.get(e),a=t?.all.lastIndexOf(i)??-1;if(!t||-1===a)throw new Error("controller expected in global slice register");t.all.splice(a,1),0===t.all.length&&m.delete(e)}export{f as SliceController};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as t}from"tslib";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import{destroyMaybe as a,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as r,when as l,syncAndInitial as o}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{createScreenPoint as p,screenPointObjectToArray as u}from"../../../../core/screenUtils.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 d}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromRotation as _,fromScaling as v,multiply as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{e as P,l as y,c as w,g,f,t as M,n as D,i as V}from"../../../../chunks/vec32.js";import{create as b,clone as T}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as S,ZEROS as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{c as x,a as E,n as j,f as C}from"../../../../chunks/boundedPlane.js";import{signedDistance as H,create as R,intersectRay as I,getNormal as z}from"../../../../geometry/support/plane.js";import{create as O}from"../../../../geometry/support/ray.js";import{sv3d as G,sm4d as U,sv2d as K}from"../../../../geometry/support/vectorStacks.js";import{getSliceableContainer as B}from"../../../../graphic/getSliceableContainer.js";import{getRotateHeadingTexture as A,getTiltRotateTexture as F}from"../images/Factory.js";import{ResizeManipulator as L}from"./ResizeManipulator.js";import{RotateManipulator as q}from"./RotateManipulator.js";import{getOutlineColor as N,planeColor as J}from"./settings.js";import{ShiftManipulator as Q}from"./ShiftManipulator.js";import{pointerMoveTimerMs as W,planePreviewOutlineWidth as X,forceVerticalModifier as Y,forceHorizontalModifier as Z,previewFadeDurationSeconds as $,previewFadeDotThreshold as tt,initialDepthOffsetFrac as et}from"./sliceToolConfig.js";import{createGridVisualElement as it,createOutlineVisualElement as at,planeToShape as st,createRotatePlane as nt,resizePlane as rt,calculatePlaneHalfSize as lt,createPlane as ot,DidPointerMoveRecentlyFlag as ht,calculateBoundedPlaneTranslateRotate as pt,updateShiftRestartHandle as ut,updateRotateHeadingHandle as ct,updateRotateTiltHandle as dt,updateResizeHandle as _t,createShiftPlane as vt}from"./sliceToolUtils.js";import{calculateInputRotationTransform as mt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as Pt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreenNormalized as yt}from"../../support/geometryUtils/ray.js";import{AnalysisToolBase as wt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as gt}from"../../../interactive/dragEventPipeline.js";import{newToolIntersector as ft}from"../../../interactive/ToolIntersector.js";import{createScreenPointFromEvent as Mt}from"../../../support/screenUtils.js";var Dt;let Vt=class extends wt{static{Dt=this}constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this._mode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._frameTask=null,this._pointerMoveTimerMs=W,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=x(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=p(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=ft(t.view.state.viewingMode)}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&E(this.analysisViewData.plane,this._startPlane),this.inputState=null)},e=new Q(this.view,1);this.shiftManipulator=e,this.manipulators.add(e),this.addHandles([this._createShiftDragPipeline(e),e.events.on("grab-changed",i=>{this._onShiftGrab(i),t(e)})]);const i=!this.view.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,a=new q(this.view,(t,e)=>A(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateHeadingManipulator=a,this.manipulators.add(a),this.addHandles([this._createRotateHeadingDragPipeline(a),a.events.on("grab-changed",e=>{this._onRotateHeadingGrab(e),t(a)})]);const s=new q(this.view,(t,e)=>F(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateTiltManipulator=s,this.manipulators.add(s),this.addHandles([this._createRotateTiltDragPipeline(s),s.events.on("grab-changed",e=>{this._onRotateTiltGrab(e),t(s)})]),this.resizeManipulators=this._resizeHandles.map((e,i)=>{const a=new L(this.view,e);return this.addHandles([this._createResizeDragPipeline(a),a.events.on("grab-changed",e=>{this._onResizeGrab(e,i),t(a)})]),a}),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=it(this.view),this._previewPlaneOutlineVisualElement=at(this.view),this._previewPlaneOutlineVisualElement.width=X,this.addHandles(n(()=>[this.analysisViewData.plane,this.analysis.tiltEnabled],()=>this._updateManipulators(),r)),this.addHandles([l(()=>"sliced"===this.state,()=>{this.finishToolCreation(),this.stop()},o),n(()=>this.view.state.camera,()=>this._onCameraChange())])}destroy(){this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=a(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=a(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this.active?this._placingSlicePlane||"exclude"===this.mode?"crosshair":null!=this._creatingPointerId?"grabbing":null:null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this.removeHandles("analysis"),this._set("analysis",t)}get mode(){return this._mode}static{this.disableEngineLayers=!1}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _placingSlicePlane(){return this.active&&!this.inputState&&"place"===this._mode}get _creatingPointerId(){return null!=this.inputState&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}start(t){this._finishToolCreationIfValid(),this._mode=t,this.active||(this.view.activeTool=this)}stop(){this.active&&(this.view.activeTool=null)}onActivate(){this._finishToolCreationIfValid(),"none"===this._mode&&null==this.analysisViewData.plane&&(this._mode="place")}onDeactivate(){this._mode="none",this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-drag":if(!Tt(t))return;this._placingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!Tt(t))return;"exclude"===this._mode?t.defer(async()=>{await this._onClickExcludeLayer(t)&&t.stopPropagation()}):this._onClickPlacePlane(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&null!=e&&"shift"===e.type){const i=Mt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Mt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&null!=this.analysisViewData.plane){const e=Mt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),E(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if(!this._placingSlicePlane)return!1;const i=Mt(t),a=x();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if("pointer-drag"===t.type){const e=yt(this.view.state.camera,i,kt);this.inputState=bt(e,t.pointerId,a.origin,a)}return E(a,this._startPlane),this.analysis.shape=st(a,this.view,this.view.spatialReference,new e),"pointer-drag"!==t.type&&this.stop(),!0}return!1}async _onClickExcludeLayer(t){if("exclude"!==this.mode)return!1;const e=await this.view.hitTest(Mt(t)),i=e.results.at(0);if(i){const t="graphic"===i.type&&i.graphic;if(t){const e=B(t.origin)??t.sourceLayer??t.layer;e&&"subtype-sublayer"!==e.type&&this.analysis.excludedLayers.push(e)}}else e.ground.layer?this.analysis.excludedLayers.push(e.ground.layer):this.analysis.excludeGroundSurface=!0;return this.stop(),!0}_onKeyDown(t){return(t.key===Y||t.key===Z)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==Y&&t.key!==Z||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=yt(this.view.state.camera,t.screenPoint,kt);E(this.analysisViewData.plane,this._startPlane),this.inputState=bt(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?E(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(P(j(this.analysisViewData.plane),e.ray.direction)/y(e.ray.direction)))/i,1),s=-H(this._startPlane.plane,e.renderEnd),n=-H(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=w(G.get(),this._startPlane.origin),i=w(G.get(),j(this._startPlane));g(i,i,-t.depth),f(i,i,e);const a=C(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,x());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,1,R()),i=yt(this.view.state.camera,t.screenPoint,kt),a=b();I(e,i,a)&&(E(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?E(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,2,R()),i=yt(this.view.state.camera,t.screenPoint,kt),a=b();I(e,i,a)&&(E(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?E(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=z(t.rotatePlane),a=mt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=_(U.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=M(G.get(),this._startPlane.basis1,e),a=M(G.get(),this._startPlane.basis2,e),s=C(this.analysisViewData.plane.origin,i,a,x());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=yt(this.view.state.camera,t.screenPoint,kt),a=G.get();I(this.analysisViewData.plane.plane,i,a)&&(E(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:T(a)})}_createResizeDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=E(this.analysisViewData.plane,x());e.next(Pt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next(()=>{this._updateBoundedPlane(s)})})}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=rt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,E(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){if("exclude"===this.mode)return;let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(this.active){const a=null!=i?i:x();if(i=null!=i?E(i,St):null,this._pickPlane(t,!0,e,a)){const t=tt;let e=!1;null!=i&&(e=P(z(i.plane),z(a.plane))<t||P(D(G.get(),i.basis1),D(G.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=h({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*$),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=s(this._frameTask)}_pickMinResult(t){const e=u(t,K.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=G.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(G.get()),l=this.view.state.camera;P(r,l.viewForward)>0&&g(r,r,-1);const o=lt(n,l),h=(e?1:-1)*o*et,p=g(G.get(),r,h);f(p,p,n);const u=this.analysis.tiltEnabled?3:0,c=i[Y]?2:i[Z]?1:u;return ot(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=s(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=ht,this.rotateHeadingManipulator.state|=ht,this.rotateTiltManipulator.state|=ht,this._prevPointerMoveTimeout=this._clock.setTimeout(()=>{this.shiftManipulator.state&=~ht,this.rotateHeadingManipulator.state&=~ht,this.rotateTiltManipulator.state&=~ht},this._pointerMoveTimerMs)}_updateManipulators(){if(Dt.disableEngineLayers)return;let t,e,i=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=this._previewPlane??t,i=!1;else{if(null==this._previewPlane)return this._setManipulatorVisibility(!1),void this._setPreviewPlaneVisibility(!1);e=t=this._previewPlane,i=!0}if(this._setManipulatorVisibility(!i),!i){const e=pt(t,U.get());ut(this.shiftManipulator,e,t,this.view.state.camera),ct(this.rotateHeadingManipulator,e,t,this.view.renderCoordsHelper),dt(this.rotateTiltManipulator,e,t),this.resizeManipulators.forEach((i,a)=>_t(i,this._resizeHandles[a],e,t))}this._setPreviewPlaneVisibility(!this._creatingPointerId&&(i||"place"===this._mode)),this._updatePreviewPlaneTransform(e),this._updateMaterials()}_setManipulatorVisibility(t){this.shiftManipulator.available=t,this.rotateHeadingManipulator.available=t,this.rotateTiltManipulator.available=t&&this.analysis.tiltEnabled,this.resizeManipulators.forEach(e=>e.available=t)}_updatePreviewPlaneTransform(t){const e=pt(t,U.get()),i=V(G.get(),y(t.basis1),y(t.basis2),1),a=v(U.get(),i),s=m(a,e,a);this._previewPlaneOutlineVisualElement.transform=s,this._previewPlaneGridVisualElement.transform=s}_setPreviewPlaneVisibility(t){const e=this._previewPlaneOutlineVisualElement,i=this._previewPlaneGridVisualElement;t&&(e.attached=!0,i.attached=!0),e.visible=t,i.visible=t}_updateMaterials(){const t=N(this.view.effectiveTheme);t[3]*=this._previewPlaneOpacity;const e=S(J);e[3]*=this._previewPlaneOpacity,this._previewPlaneOutlineVisualElement.color=t,this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=k}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach(t=>{t.interactive=!0});this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach(e=>{e.interactive=e===t})}_finishToolCreationIfValid(){this.analysis.valid&&this.finishToolCreation()}get test(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function bt(t,e,i,a){const s=vt(i,j(a),t.direction,R()),n=b();return I(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function Tt(t){return"mouse"!==t.pointerType||0===t.button}t([c()],Vt.prototype,"_clock",void 0),t([c({constructOnly:!0})],Vt.prototype,"view",void 0),t([c()],Vt.prototype,"analysisViewData",void 0),t([c({readOnly:!0})],Vt.prototype,"state",null),t([c({readOnly:!0})],Vt.prototype,"cursor",null),t([c()],Vt.prototype,"analysis",null),t([c()],Vt.prototype,"removeIncompleteOnCancel",void 0),t([c()],Vt.prototype,"_mode",void 0),t([c()],Vt.prototype,"mode",null),t([c({value:null})],Vt.prototype,"inputState",null),t([c()],Vt.prototype,"_placingSlicePlane",null),t([c()],Vt.prototype,"_creatingPointerId",null),Vt=Dt=t([d("esri.views.3d.analysis.Slice.SliceTool")],Vt);const St=x(),kt=O();export{Vt as default};
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../../analysis/SlicePlane.js";import{clock as i}from"../../../../core/clock.js";import{destroyMaybe as a,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as r,when as l,syncAndInitial as o}from"../../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../../core/scheduling.js";import{createScreenPoint as p,screenPointObjectToArray as u}from"../../../../core/screenUtils.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 d}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromRotation as _,fromScaling as v,multiply as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{e as P,l as y,c as w,g,f,t as M,n as D,i as V}from"../../../../chunks/vec32.js";import{create as b,clone as T}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{clone as S,ZEROS as k}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{a as x,d as E,n as j,f as C}from"../../../../chunks/boundedPlane.js";import{signedDistance as H,create as R,intersectRay as I,getNormal as z}from"../../../../geometry/support/plane.js";import{create as O}from"../../../../geometry/support/ray.js";import{sv3d as G,sm4d as U,sv2d as K}from"../../../../geometry/support/vectorStacks.js";import{getSliceableContainer as B}from"../../../../graphic/getSliceableContainer.js";import{getRotateHeadingTexture as A,getTiltRotateTexture as F}from"../images/Factory.js";import{ResizeManipulator as L}from"./ResizeManipulator.js";import{RotateManipulator as q}from"./RotateManipulator.js";import{getOutlineColor as N,planeColor as J}from"./settings.js";import{ShiftManipulator as Q}from"./ShiftManipulator.js";import{pointerMoveTimerMs as W,planePreviewOutlineWidth as X,forceVerticalModifier as Y,forceHorizontalModifier as Z,previewFadeDurationSeconds as $,previewFadeDotThreshold as tt,initialDepthOffsetFrac as et}from"./sliceToolConfig.js";import{createGridVisualElement as it,createOutlineVisualElement as at,planeToShape as st,createRotatePlane as nt,resizePlane as rt,calculatePlaneHalfSize as lt,createPlane as ot,DidPointerMoveRecentlyFlag as ht,calculateBoundedPlaneTranslateRotate as pt,updateShiftRestartHandle as ut,updateRotateHeadingHandle as ct,updateRotateTiltHandle as dt,updateResizeHandle as _t,createShiftPlane as vt}from"./sliceToolUtils.js";import{calculateInputRotationTransform as mt}from"../../interactive/manipulatorUtils.js";import{screenToRenderPlane as Pt}from"../../interactive/editingTools/dragEventPipeline3D.js";import{fromScreenNormalized as yt}from"../../support/geometryUtils/ray.js";import{AnalysisToolBase as wt}from"../../../interactive/AnalysisToolBase.js";import{createManipulatorDragEventPipeline as gt}from"../../../interactive/dragEventPipeline.js";import{newToolIntersector as ft}from"../../../interactive/ToolIntersector.js";import{createScreenPointFromEvent as Mt}from"../../../support/screenUtils.js";var Dt;let Vt=class extends wt{static{Dt=this}constructor(t){super(t),this._clock=i,this._previewPlaneOpacity=1,this.removeIncompleteOnCancel=!1,this._mode="none",this.shiftManipulator=null,this.rotateHeadingManipulator=null,this.rotateTiltManipulator=null,this.resizeManipulators=null,this._frameTask=null,this._pointerMoveTimerMs=W,this._prevPointerMoveTimeout=null,this._previewPlaneGridVisualElement=null,this._previewPlaneOutlineVisualElement=null,this._startPlane=x(),this._previewPlane=null,this._activeKeyModifiers={},this._lastCursorPosition=p(),this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._intersector=ft(t.view.state.viewingMode)}initialize(){if(null==this.analysis)throw new Error("SliceTool requires valid analysis, but null was provided.");const t=t=>{this._updateManipulatorsInteractive(t),t.grabbing||(null!=this.analysisViewData.plane&&E(this.analysisViewData.plane,this._startPlane),this.inputState=null)},e=new Q(this.view,1);this.shiftManipulator=e,this.manipulators.add(e),this.addHandles([this._createShiftDragPipeline(e),e.events.on("grab-changed",i=>{this._onShiftGrab(i),t(e)})]);const i=!this.view.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result,a=new q(this.view,(t,e)=>A(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateHeadingManipulator=a,this.manipulators.add(a),this.addHandles([this._createRotateHeadingDragPipeline(a),a.events.on("grab-changed",e=>{this._onRotateHeadingGrab(e),t(a)})]);const s=new q(this.view,(t,e)=>F(this.view.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:i}));this.rotateTiltManipulator=s,this.manipulators.add(s),this.addHandles([this._createRotateTiltDragPipeline(s),s.events.on("grab-changed",e=>{this._onRotateTiltGrab(e),t(s)})]),this.resizeManipulators=this._resizeHandles.map((e,i)=>{const a=new L(this.view,e);return this.addHandles([this._createResizeDragPipeline(a),a.events.on("grab-changed",e=>{this._onResizeGrab(e,i),t(a)})]),a}),this.manipulators.addMany(this.resizeManipulators),this._previewPlaneGridVisualElement=it(this.view),this._previewPlaneOutlineVisualElement=at(this.view),this._previewPlaneOutlineVisualElement.width=X,this.addHandles(n(()=>[this.analysisViewData.plane,this.analysis.tiltEnabled],()=>this._updateManipulators(),r)),this.addHandles([l(()=>"sliced"===this.state,()=>{this.finishToolCreation(),this.stop()},o),n(()=>this.view.state.camera,()=>this._onCameraChange())])}destroy(){this._removeFrameTask(),this._clearPointerMoveTimeout(),this._previewPlaneOutlineVisualElement=a(this._previewPlaneOutlineVisualElement),this._previewPlaneGridVisualElement=a(this._previewPlaneGridVisualElement)}get state(){const t=!!this.analysisViewData.plane,e=!!this.inputState;return t?t&&e?"slicing":t&&!e?"sliced":"ready":"ready"}get cursor(){return this.active?this._placingSlicePlane||"exclude"===this.mode?"crosshair":null!=this._creatingPointerId?"grabbing":null:null}set analysis(t){if(null==t)throw new Error("SliceTool requires valid analysis, but null was provided.");this.removeHandles("analysis"),this._set("analysis",t)}get mode(){return this._mode}static{this.disableEngineLayers=!1}get inputState(){return this._get("inputState")}set inputState(t){this._set("inputState",t),this.analysisViewData.showGrid=null!=t&&"resize"===t.type,this._updateMaterials()}get _placingSlicePlane(){return this.active&&!this.inputState&&"place"===this._mode}get _creatingPointerId(){return null!=this.inputState&&"shift"===this.inputState.type?this.inputState.creatingPointerId:null}start(t){this._finishToolCreationIfValid(),this._mode=t,this.active||(this.view.activeTool=this)}stop(){this.active&&(this.view.activeTool=null)}onActivate(){this._finishToolCreationIfValid(),"none"===this._mode&&null==this.analysisViewData.plane&&(this._mode="place")}onDeactivate(){this._mode="none",this._updatePreviewPlane(null)}onShow(){this._updateVisibility(!0)}onHide(){this._updateVisibility(!1)}_updateVisibility(t){this._updateManipulators(),t||this._clearPointerMoveTimeout()}onInputEvent(t){switch(t.type){case"pointer-drag":if(!Tt(t))return;this._placingSlicePlane?this._onClickPlacePlane(t)&&t.stopPropagation():this._onPointerDrag(t)&&t.stopPropagation();break;case"pointer-move":this._onPointerMove(t);break;case"pointer-up":this._onPointerUp(t)&&t.stopPropagation();break;case"immediate-click":if(!Tt(t))return;"exclude"===this._mode?t.defer(async()=>{await this._onClickExcludeLayer(t)&&t.stopPropagation()}):this._onClickPlacePlane(t)&&t.stopPropagation();break;case"drag":this.inputState&&t.stopPropagation();break;case"key-down":this._onKeyDown(t)&&t.stopPropagation();break;case"key-up":this._onKeyUp(t)&&t.stopPropagation()}}onEditableChange(){this.analysisViewData.editable=this.internallyEditable}_onPointerDrag(t){const e=this.inputState;if(t.pointerId===this._creatingPointerId&&null!=e&&"shift"===e.type){const i=Mt(t);return this.shiftManipulator.events.emit("drag",{action:e.hasBeenDragged?"update":"start",pointerType:t.pointerType,start:i,screenPoint:i}),e.hasBeenDragged=!0,!0}return!1}_onPointerMove(t){this._lastCursorPosition.x=t.x,this._lastCursorPosition.y=t.y,this._resetPointerMoveTimeout(),"touch"!==t.pointerType&&this._updatePreviewPlane(Mt(t),this._activeKeyModifiers)}_onCameraChange(){this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),this._updateManipulators()}_onPointerUp(t){if(t.pointerId===this._creatingPointerId&&null!=this.analysisViewData.plane){const e=Mt(t);return this.shiftManipulator.events.emit("drag",{action:"end",start:e,screenPoint:e}),E(this.analysisViewData.plane,this._startPlane),this.inputState=null,!0}return!1}_onClickPlacePlane(t){if(!this._placingSlicePlane)return!1;const i=Mt(t),a=x();if(this._pickPlane(i,!1,this._activeKeyModifiers,a)){if("pointer-drag"===t.type){const e=yt(this.view.state.camera,i,kt);this.inputState=bt(e,t.pointerId,a.origin,a)}return E(a,this._startPlane),this.analysis.shape=st(a,this.view,this.view.spatialReference,new e),"pointer-drag"!==t.type&&this.stop(),!0}return!1}async _onClickExcludeLayer(t){if("exclude"!==this.mode)return!1;const e=await this.view.hitTest(Mt(t)),i=e.results.at(0);if(i){const t="graphic"===i.type&&i.graphic;if(t){const e=B(t.origin)??t.sourceLayer??t.layer;e&&"subtype-sublayer"!==e.type&&this.analysis.excludedLayers.push(e)}}else e.ground.layer?this.analysis.excludedLayers.push(e.ground.layer):this.analysis.excludeGroundSurface=!0;return this.stop(),!0}_onKeyDown(t){return(t.key===Y||t.key===Z)&&(this._activeKeyModifiers[t.key]=!0,null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onKeyUp(t){return!(t.key!==Y&&t.key!==Z||!this._activeKeyModifiers[t.key])&&(delete this._activeKeyModifiers[t.key],null!=this._previewPlane&&this._updatePreviewPlane(this._lastCursorPosition,this._activeKeyModifiers),!0)}_onShiftGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=yt(this.view.state.camera,t.screenPoint,kt);E(this.analysisViewData.plane,this._startPlane),this.inputState=bt(e,null,this.shiftManipulator.renderLocation,this.analysisViewData.plane)}_createShiftDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"shift"!==a.type)return;const s=null!=this.analysisViewData.plane?E(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.shiftPlane)).next(this._shiftDragAdjustSensitivity(a)).next(this._shiftDragUpdatePlane(a)),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_shiftDragAdjustSensitivity(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=.001,a=Math.min((1-Math.abs(P(j(this.analysisViewData.plane),e.ray.direction)/y(e.ray.direction)))/i,1),s=-H(this._startPlane.plane,e.renderEnd),n=-H(this._startPlane.plane,t.startPoint);return t.depth=t.depth*(1-a)+s*a-n,e}}_shiftDragUpdatePlane(t){return()=>{if(null==this.analysisViewData.plane)return;const e=w(G.get(),this._startPlane.origin),i=w(G.get(),j(this._startPlane));g(i,i,-t.depth),f(i,i,e);const a=C(i,this.analysisViewData.plane.basis1,this.analysisViewData.plane.basis2,x());this._updateBoundedPlane(a)}}_onRotateHeadingGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,1,R()),i=yt(this.view.state.camera,t.screenPoint,kt),a=b();I(e,i,a)&&(E(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateHeadingDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?E(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_onRotateTiltGrab(t){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const e=nt(this.analysisViewData.plane,this.view.renderCoordsHelper,2,R()),i=yt(this.view.state.camera,t.screenPoint,kt),a=b();I(e,i,a)&&(E(this.analysisViewData.plane,this._startPlane),this.inputState={type:"rotate",rotatePlane:e,startPoint:a})}_createRotateTiltDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"rotate"!==a.type)return;const s=null!=this.analysisViewData.plane?E(this.analysisViewData.plane,x()):null;e.next(Pt(this.view,a.rotatePlane)).next(this._rotateDragRenderPlaneToRotate(a)).next(this._rotateDragUpdatePlaneFromRotate()),i.next(()=>{null!=s&&this._updateBoundedPlane(s)})})}_rotateDragRenderPlaneToRotate(t){return e=>{if(null==this.analysisViewData.plane)return null;const i=z(t.rotatePlane),a=mt(t.startPoint,e.renderEnd,this.analysisViewData.plane.origin,i);return{...e,rotateAxis:i,rotateAngle:a}}}_rotateDragUpdatePlaneFromRotate(){return t=>{if(null==this.analysisViewData.plane)return;const e=_(U.get(),t.rotateAngle,t.rotateAxis);if(null==e)return;const i=M(G.get(),this._startPlane.basis1,e),a=M(G.get(),this._startPlane.basis2,e),s=C(this.analysisViewData.plane.origin,i,a,x());this._updateBoundedPlane(s)}}_onResizeGrab(t,e){if("start"!==t.action||null==this.analysisViewData.plane||!t.screenPoint)return;const i=yt(this.view.state.camera,t.screenPoint,kt),a=G.get();I(this.analysisViewData.plane.plane,i,a)&&(E(this.analysisViewData.plane,this._startPlane),this.inputState={type:"resize",activeHandleIdx:e,startPoint:T(a)})}_createResizeDragPipeline(t){return gt(t,(t,e,i)=>{const a=this.inputState;if(null==a||"resize"!==a.type||null==this.analysisViewData.plane)return;const s=E(this.analysisViewData.plane,x());e.next(Pt(this.view,this.analysisViewData.plane.plane)).next(this._resizeDragUpdatePlane(a)),i.next(()=>{this._updateBoundedPlane(s)})})}_resizeDragUpdatePlane(t){return e=>{if(null==this.analysisViewData.plane)return;const i=this._resizeHandles[t.activeHandleIdx],a=rt(i,t.startPoint,e.renderEnd,this.view.state.camera,this._startPlane,E(this.analysisViewData.plane));this._updateBoundedPlane(a)}}_updateBoundedPlane(t){const e=this.analysisViewData;if(null==e)throw new Error("valid internal object expected");e.plane=t}_updatePreviewPlane(t,e={}){if("exclude"===this.mode)return;let i=this._previewPlane;if(this._previewPlane=null,null==t)return this._removeFrameTask(),void this._updateManipulators();if(this.active){const a=null!=i?i:x();if(i=null!=i?E(i,St):null,this._pickPlane(t,!0,e,a)){const t=tt;let e=!1;null!=i&&(e=P(z(i.plane),z(a.plane))<t||P(D(G.get(),i.basis1),D(G.get(),a.basis1))<t),e&&(this._previewPlaneOpacity=0),this._previewPlane=a}}null!=this._previewPlane&&null==this._frameTask&&0===this._previewPlaneOpacity?this._frameTask=h({update:({deltaTime:t})=>{this._previewPlaneOpacity=Math.min(this._previewPlaneOpacity+t/(1e3*$),1),this._updateManipulators(),1===this._previewPlaneOpacity&&this._removeFrameTask()}}):null==this._previewPlane&&null!=this._frameTask?this._removeFrameTask():null!=this._previewPlane&&this._updateManipulators()}_removeFrameTask(){this._frameTask=s(this._frameTask)}_pickMinResult(t){const e=u(t,K.get());return this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(e,this._intersector),this._intersector.results.min}_pickPlane(t,e,i,a){const s=this._pickMinResult(t),n=G.get();if(!s.getIntersectionPoint(n))return!1;const r=s.getTransformedNormal(G.get()),l=this.view.state.camera;P(r,l.viewForward)>0&&g(r,r,-1);const o=lt(n,l),h=(e?1:-1)*o*et,p=g(G.get(),r,h);f(p,p,n);const u=this.analysis.tiltEnabled?3:0,c=i[Y]?2:i[Z]?1:u;return ot(p,r,o,o,l,c,this.view.renderCoordsHelper,a),!0}_clearPointerMoveTimeout(){this._prevPointerMoveTimeout=s(this._prevPointerMoveTimeout)}_resetPointerMoveTimeout(){this._clearPointerMoveTimeout(),this.shiftManipulator.state|=ht,this.rotateHeadingManipulator.state|=ht,this.rotateTiltManipulator.state|=ht,this._prevPointerMoveTimeout=this._clock.setTimeout(()=>{this.shiftManipulator.state&=~ht,this.rotateHeadingManipulator.state&=~ht,this.rotateTiltManipulator.state&=~ht},this._pointerMoveTimerMs)}_updateManipulators(){if(Dt.disableEngineLayers)return;let t,e,i=!1;if(null!=this.analysisViewData.plane)t=this.analysisViewData.plane,e=this._previewPlane??t,i=!1;else{if(null==this._previewPlane)return this._setManipulatorVisibility(!1),void this._setPreviewPlaneVisibility(!1);e=t=this._previewPlane,i=!0}if(this._setManipulatorVisibility(!i),!i){const e=pt(t,U.get());ut(this.shiftManipulator,e,t,this.view.state.camera),ct(this.rotateHeadingManipulator,e,t,this.view.renderCoordsHelper),dt(this.rotateTiltManipulator,e,t),this.resizeManipulators.forEach((i,a)=>_t(i,this._resizeHandles[a],e,t))}this._setPreviewPlaneVisibility(!this._creatingPointerId&&(i||"place"===this._mode)),this._updatePreviewPlaneTransform(e),this._updateMaterials()}_setManipulatorVisibility(t){this.shiftManipulator.available=t,this.rotateHeadingManipulator.available=t,this.rotateTiltManipulator.available=t&&this.analysis.tiltEnabled,this.resizeManipulators.forEach(e=>e.available=t)}_updatePreviewPlaneTransform(t){const e=pt(t,U.get()),i=V(G.get(),y(t.basis1),y(t.basis2),1),a=v(U.get(),i),s=m(a,e,a);this._previewPlaneOutlineVisualElement.transform=s,this._previewPlaneGridVisualElement.transform=s}_setPreviewPlaneVisibility(t){const e=this._previewPlaneOutlineVisualElement,i=this._previewPlaneGridVisualElement;t&&(e.attached=!0,i.attached=!0),e.visible=t,i.visible=t}_updateMaterials(){const t=N(this.view.effectiveTheme);t[3]*=this._previewPlaneOpacity;const e=S(J);e[3]*=this._previewPlaneOpacity,this._previewPlaneOutlineVisualElement.color=t,this._previewPlaneGridVisualElement.backgroundColor=e,this._previewPlaneGridVisualElement.gridColor=k}_updateManipulatorsInteractive(t){if(!t.grabbing)return this.shiftManipulator.interactive=!0,this.rotateHeadingManipulator.interactive=!0,this.rotateTiltManipulator.interactive=!0,void this.resizeManipulators.forEach(t=>{t.interactive=!0});this.shiftManipulator.interactive=this.shiftManipulator===t,this.rotateHeadingManipulator.interactive=this.rotateHeadingManipulator===t,this.rotateTiltManipulator.interactive=this.rotateTiltManipulator===t,this.resizeManipulators.forEach(e=>{e.interactive=e===t})}_finishToolCreationIfValid(){this.analysis.valid&&this.finishToolCreation()}get test(){return{plane:this.analysisViewData.plane,setPointerMoveTimerMs:t=>{this._pointerMoveTimerMs=t}}}};function bt(t,e,i,a){const s=vt(i,j(a),t.direction,R()),n=b();return I(s,t,n)?{type:"shift",creatingPointerId:e,hasBeenDragged:!1,shiftPlane:s,depth:0,startPoint:n}:null}function Tt(t){return"mouse"!==t.pointerType||0===t.button}t([c()],Vt.prototype,"_clock",void 0),t([c({constructOnly:!0})],Vt.prototype,"view",void 0),t([c()],Vt.prototype,"analysisViewData",void 0),t([c({readOnly:!0})],Vt.prototype,"state",null),t([c({readOnly:!0})],Vt.prototype,"cursor",null),t([c()],Vt.prototype,"analysis",null),t([c()],Vt.prototype,"removeIncompleteOnCancel",void 0),t([c()],Vt.prototype,"_mode",void 0),t([c()],Vt.prototype,"mode",null),t([c({value:null})],Vt.prototype,"inputState",null),t([c()],Vt.prototype,"_placingSlicePlane",null),t([c()],Vt.prototype,"_creatingPointerId",null),Vt=Dt=t([d("esri.views.3d.analysis.Slice.SliceTool")],Vt);const St=x(),kt=O();export{Vt as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import i from"../../../../analysis/SlicePlane.js";import"../../../../core/has.js";import e from"../../../../core/Logger.js";import{rad2deg as t,deg2rad as n}from"../../../../core/mathUtils.js";import{castRenderScreenPointArray3 as o}from"../../../../core/screenUtils.js";import{fromZRotation as s,scale as r,multiply as a,rotateZ as c,rotateX as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{l as u,i as d,f as g,g as m,c as p,d as f,e as b,n as h,h as j,k as w,a as v}from"../../../../chunks/vec32.js";import{clone as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import M from"../../../../geometry/Extent.js";import U from"../../../../geometry/Point.js";import{tryProjectWithZConversion as y}from"../../../../geometry/projectionUtils.js";import{
|
|
5
|
+
import i from"../../../../analysis/SlicePlane.js";import"../../../../core/has.js";import e from"../../../../core/Logger.js";import{rad2deg as t,deg2rad as n}from"../../../../core/mathUtils.js";import{castRenderScreenPointArray3 as o}from"../../../../core/screenUtils.js";import{fromZRotation as s,scale as r,multiply as a,rotateZ as c,rotateX as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{l as u,i as d,f as g,g as m,c as p,d as f,e as b,n as h,h as j,k as w,a as v}from"../../../../chunks/vec32.js";import{clone as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import M from"../../../../geometry/Extent.js";import U from"../../../../geometry/Point.js";import{tryProjectWithZConversion as y}from"../../../../geometry/projectionUtils.js";import{a as R,r as x,n as S,u as T,f as k,i as A}from"../../../../chunks/boundedPlane.js";import{fromPositionAndNormal as C,fromVectorsAndPoint as L}from"../../../../geometry/support/plane.js";import{create as E}from"../../../../geometry/support/ray.js";import{angleAroundAxis as H}from"../../../../geometry/support/vector.js";import{sv3d as I,sm4d as z}from"../../../../geometry/support/vectorStacks.js";import{getGridColor as F,planeColor as W,getOutlineColor as B}from"./settings.js";import{resizeHandleEdgePaddingFrac as D,planeOutlineWidth as O,planeMinBasisScreenLen2 as V,initialPlaneHalfSizeViewProportion as $,shiftRestartOffsetDistance as q,smallAngleDotThreshold as G,verticalDotThreshold as J}from"./sliceToolConfig.js";import{applyProjectionAndElevationAlignment as K}from"../support/projectionUtils.js";import{calculateTranslateRotateFromBases as N}from"../../interactive/manipulatorUtils.js";import{LineVisualElement as Q}from"../../interactive/visualElements/LineVisualElement.js";import{SlicePlaneVisualElement as X}from"../../interactive/visualElements/SlicePlaneVisualElement.js";import{RenderCoordsHelper as Y}from"../../support/RenderCoordsHelper.js";import{fromRender as Z}from"../../support/geometryUtils/ray.js";function _(i,e,t,n,o,s,r,a){return ii(e,r.worldUpAtPosition(i,I.get()),o,s,a.basis1,a.basis2),m(a.basis1,a.basis1,t),m(a.basis2,a.basis2,n),p(a.origin,i),L(a.basis2,a.basis1,a.origin,a.plane),a}function ii(i,e,t,n,o,s){const r=b(i,e),a=I.get(),c=I.get();switch(0===n?Math.abs(r)>J?1:2:n){case 2:{const n=Math.abs(r)<=G?i:t.viewUp;j(a,n,e),p(c,e);break}case 1:j(a,t.viewUp,e),j(c,e,a);break;case 3:{const n=Math.abs(r)<=G?e:t.viewUp;j(a,n,i),j(c,i,a);break}}const l=j(I.get(),a,c);b(l,t.viewForward)>0&&m(c,c,-1),h(o,a),h(s,c)}function ei(i,e,t){const n=e.worldUpAtPosition(i.origin,I.get()),o=i.basis1,s=Pi(i,n),r=Math.round(s/ki)*ki;return x(i,r-s,o,t)}function ti(i,e,t,n,o,s){const r=p(I.get(),o.origin);g(r,r,m(I.get(),o.basis1,i.direction[0]<0?1:-1)),g(r,r,m(I.get(),o.basis2,i.direction[1]<0?1:-1));const a=u(o.basis1),c=u(o.basis2),l=f(I.get(),t,r),d=f(I.get(),e,r);let h=0,j=0;if(bi(i)){const e=fi(o),t=fi(s);h=a-.5*i.direction[0]*b(o.basis1,d)/a,j=c-.5*i.direction[1]*b(o.basis2,d)/c;const n=t/e;h*=n,j*=n}const w=h+.5*i.direction[0]*b(o.basis1,l)/a,v=j+.5*i.direction[1]*b(o.basis2,l)/c,P=m(I.get(),o.basis1,w/a),M=m(I.get(),o.basis2,v/c);(w<=0||mi(s.origin,P,n)<=V)&&p(P,s.basis1),(v<=0||mi(s.origin,M,n)<=V)&&p(M,s.basis2);const U=p(I.get(),r);return g(U,U,m(I.get(),P,i.direction[0]<0?-1:1)),g(U,U,m(I.get(),M,i.direction[1]<0?-1:1)),k(U,P,M,s)}function ni(i,e){return $*Math.min(e.width,e.height)*e.computeRenderPixelSizeAt(i)}function oi(i,e,t,n){const o=j(I.get(),e,t);return j(o,o,e),C(i,o,n)}function si(i,e){return N(i.basis1,i.basis2,i.origin,e)}function ri(i,e,t,n){const o=e.worldUpAtPosition(i.origin,I.get()),s=I.get();switch(t){case 1:p(s,o);break;case 2:p(s,i.basis1)}return C(i.origin,s,n)}function ai(i,e,t,n){const s=gi(t,2),r=z.get();c(r,e,s.edge*Math.PI/2);const a=h(I.get(),s.basis);let l=m(I.get(),a,s.direction*n.computeScreenPixelSizeAt(s.position)*q);g(l,l,s.position);const u=n.projectToRenderScreen(l,o(I.get())),d=ci(n,u);Z(n,u,Ti),h(Ti.direction,Ti.direction);const p=I.get();!d&&A(t,Ti,p)&&(l=p),r[12]=0,r[13]=0,r[14]=0,i.modelTransform=r,i.renderLocation=P(l),d?i.state|=Si:i.state&=~Si}function ci(i,e){if(null==e)return!1;const[t,n,o,s]=i.viewport,r=Math.min(o,s)/16;let a=!0;return e[0]<t+r?(e[0]=t+r,a=!1):e[0]>t+o-r&&(e[0]=t+o-r,a=!1),e[1]<n+r?(e[1]=n+r,a=!1):e[1]>n+s-r&&(e[1]=n+s-r,a=!1),a}function li(i,e,t,n){const o=u(n.basis1),c=u(n.basis2),l=pi(n),p=fi(n),f=d(I.get(),0,0,0);g(f,m(I.get(),n.basis1,e.direction[0]),m(I.get(),n.basis2,e.direction[1])),g(f,n.origin,f);let b=0,h=1;if(bi(e))1===e.direction[0]&&-1===e.direction[1]?b=ki:1===e.direction[0]&&1===e.direction[1]?b=Math.PI:-1===e.direction[0]&&1===e.direction[1]&&(b=3*Math.PI/2),h=p;else{const i=0!==e.direction[0]?1:2;b=1===i?ki:0,h=(1===i?c:o)-l}const j=s(z.get(),b);r(j,j,d(I.get(),h,h,h)),a(j,t,j),j[12]=0,j[13]=0,j[14]=0,i.modelTransform=j,i.renderLocation=f}function ui(i,e,t,n){const o=n.worldUpAtPosition(t.origin,I.get()),r=gi(t,0),c=s(z.get(),r.edge*Math.PI/2);l(c,c,-Pi(t,o)),a(c,e,c),c[12]=0,c[13]=0,c[14]=0,i.modelTransform=c,i.renderLocation=r.position}function di(i,e,t){const n=gi(t,1),o=s(z.get(),n.edge*Math.PI/2);l(o,o,ki),a(o,e,o),o[12]=0,o[13]=0,o[14]=0,i.modelTransform=o,i.renderLocation=n.position}function gi(i,e){switch(e){case 0:return{basis:i.basis1,direction:1,position:g(I.get(),i.origin,i.basis1),edge:e};case 1:return{basis:i.basis2,direction:1,position:g(I.get(),i.origin,i.basis2),edge:e};case 2:return{basis:i.basis1,direction:-1,position:f(I.get(),i.origin,i.basis1),edge:e};case 3:return{basis:i.basis2,direction:-1,position:f(I.get(),i.origin,i.basis2),edge:e}}}function mi(i,e,t){const n=t.projectToRenderScreen(g(I.get(),i,e),o(I.get())),s=t.projectToRenderScreen(f(I.get(),i,e),o(I.get()));return n&&s?w(f(n,n,s)):0}function pi(i){const e=u(i.basis1),t=u(i.basis2);return D*Math.min(e,t)}function fi(i){return pi(i)}function bi(i){return 0!==i.direction[0]&&0!==i.direction[1]}function hi(i){const e=[[-1,-1,0],[1,-1,0],[1,1,0],[-1,1,0],[-1,-1,0]];return new Q({view:i,attached:!1,color:B(i.effectiveTheme),width:O,renderOccluded:4,geometry:[e],isDecoration:!0})}function ji(i){return new X({view:i,attached:!1,backgroundColor:W,gridColor:F(i.effectiveTheme),gridWidth:4,renderOccluded:4,isDecoration:!0})}function wi(e,n,o,s=new i){if(null==e)return null;const{renderCoordsHelper:r}=n,a=r.fromRenderCoords(e.origin,new U({spatialReference:n.spatialReference}));if(null==a)return null;const c=y(a,o);if(null==c)return null;s.position=c;const l=2*u(e.basis1),d=2*u(e.basis2),g=Y.renderUnitScaleFactor(n.spatialReference,o);s.width=l*g,s.height=d*g;const m=r.worldUpAtPosition(e.origin,I.get());return s.tilt=t(Pi(e,m)),s.heading=r.headingAtPosition(e.origin,e.basis1)-90,s}function vi(i,e,t){if(null==i)return null;const n=i.origin,o=I.get(),s=I.get(),r=I.get(),a=I.get();let c,l,u,d,m,p;g(o,n,i.basis1),g(o,o,i.basis2),g(s,n,i.basis1),v(s,s,i.basis2),v(r,n,i.basis1),v(r,r,i.basis2),v(a,n,i.basis1),g(a,a,i.basis2);for(const g of[o,s,r,a]){const i=e.fromRenderCoords(g,g,t);if(null==i)return null;c=null==c?i[0]:Math.min(c,i[0]),l=null==l?i[0]:Math.max(l,i[0]),u=null==u?i[1]:Math.min(u,i[1]),d=null==d?i[1]:Math.max(d,i[1]),m=null==m?i[2]:Math.min(m,i[2]),p=null==p?i[2]:Math.max(p,i[2])}return new M({xmin:c,xmax:l,ymin:u,ymax:d,zmin:m,zmax:p,spatialReference:t})}function Pi(i,e){return H(e,i.basis2,i.basis1)+ki}function Mi(i,t,o,s,r,a,c=R()){return a.toRenderCoords(i,c.origin)?(a.worldBasisAtPosition(c.origin,0,c.basis1),a.worldBasisAtPosition(c.origin,1,c.basis2),L(c.basis2,c.basis1,c.origin,c.plane),x(c,-n(t),S(c),c),x(c,n(o),c.basis1,c),m(c.basis1,c.basis1,s/2),m(c.basis2,c.basis2,r/2),T(c),c):(e.getLogger("esri.views.3d.analysis.Slice.sliceToolUtils").error(`Failed to project slice plane position, projection from ${i.spatialReference.wkid} is not supported`),null)}function Ui(i,e){if(null==i?.position)return null;const t=K(i.position,e.spatialReference,e.elevationProvider);if(null==t)return null;const n=Y.renderUnitScaleFactor(i.position.spatialReference,e.spatialReference),o=i.width*n,s=i.height*n;return{position:t,heading:i.heading,tilt:i.tilt,renderWidth:o,renderHeight:s}}function yi(i,e,t,n=R()){const o=Ui(i,e);return null==o?null:Ri(o,e,t,n)}function Ri(i,e,t,n=R()){if(null==i)return null;const o=Mi(i.position,i.heading,i.tilt,i.renderWidth,i.renderHeight,e.renderCoordsHelper,n);return t.tiltEnabled||null==o||ei(o,e.renderCoordsHelper,o),o}const xi=16,Si=32,Ti=E(),ki=Math.PI/2,Ai=16,Ci=32;function Li(i){return null!=("building-scene-3d"===i.type?i:null)}export{xi as DidPointerMoveRecentlyFlag,Si as IsShiftEdgeOnScreenFlag,si as calculateBoundedPlaneTranslateRotate,fi as calculateDiagonalResizeHandleScale,ni as calculatePlaneHalfSize,ji as createGridVisualElement,hi as createOutlineVisualElement,_ as createPlane,ri as createRotatePlane,oi as createShiftPlane,ei as forceHorizontalOrVertical,Li as isBuildingSceneLayerView3D,bi as isDiagonalResizeHandle,ii as normalToBases,vi as planeToExtent,wi as planeToShape,Ui as projectAndElevationAlignShape,Ri as projectedShapeToPlane,Ai as resizeNormal,Ci as resizeOutlineOnly,ti as resizePlane,yi as shapeToPlane,li as updateResizeHandle,ui as updateRotateHeadingHandle,di as updateRotateTiltHandle,ai as updateShiftRestartHandle};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js";import"../webgl-engine/core/shaderModules/
|
|
5
|
+
import"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import"../webgl-engine/core/shaderLibrary/output/ReadDepth.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js";import"../webgl-engine/core/shaderModules/Float3PassUniform.js";import"../webgl-engine/core/shaderModules/FloatPassUniform.js";import"../webgl-engine/core/shaderModules/glsl.js";import"../webgl-engine/core/shaderModules/Texture2DBindUniform.js";import"../webgl-engine/core/shaderModules/Texture2DPassUniform.js";import"../webgl-engine/effects/raymarching/RayDistanceFalloff.glsl.js";import"../webgl-engine/shaders/ScreenSpacePassAtmosphere.glsl.js";import"../webgl-engine/shaders/ToneMapping.glsl.js";import"../../webgl/ShaderBuilder.js";export{F as FogPassParameters,b as build}from"../../../chunks/Fog.glsl.js";
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{neverReached as e}from"../../../core/compilerUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import{makeHandle as i}from"../../../core/handleUtils.js";import"../../../core/has.js";import{deg2rad as s}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{createRenderScreenPointArray3 as r,createScreenPointArray as n,screenPointObjectToArray as a,castRenderScreenPointArray as c}from"../../../core/screenUtils.js";import{fromMat4 as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy as d,set as _,multiply as u,identity as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{squaredDistance as f}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{f as p,o as b,t as v,g as y,c as j,s as L,i as S,d as O}from"../../../chunks/vec32.js";import{create as R,ZEROS as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import A from"../../../geometry/Point.js";import{canProjectWithoutEngine as E,projectPoint as D}from"../../../geometry/projectionUtils.js";import{computeENUToPCPFLocalRotation as F}from"../../../geometry/projection/localRotationUtils.js";import{sphericalPCPFtoLonLatElevation as z}from"../../../geometry/projection/projectors.js";import{containsPointObject as P}from"../../../geometry/support/aaBoundingRect.js";import{distance2 as C,fromPoints as x,create as M,closestRayDistance2 as k}from"../../../geometry/support/lineSegment.js";import{fromPositionAndNormal as I,create as U,intersectRay as W}from"../../../geometry/support/plane.js";import{create as B}from"../../../geometry/support/ray.js";import{sv3d as H}from"../../../geometry/support/vectorStacks.js";import{clonePoint as q,hydratedSpatialReference as G}from"../../../layers/graphics/hydratedFeatures.js";import{getElevationOffset as V}from"../../../support/elevationInfoUtils.js";import{getElevationAtPoint as J}from"../support/ElevationProvider.js";import{fromScreen as K}from"../support/geometryUtils/ray.js";import N from"../webgl/RenderCamera.js";import{Object3D as Q}from"../webgl-engine/lib/Object3D.js";import{WebGLLayer as X}from"../webgl-engine/lib/WebGLLayer.js";class Y{constructor(e){this.metadata=void 0,this._camera=new N,this._elevation={offset:0,override:null},this.collisionType={type:"point"},this.collisionPriority=0,this._renderObjects=new Array,this.autoScaleRenderObjects=!0,this._available=!0,this._noDisplayCount=0,this._radius=10,this._worldSized=!1,this.focusMultiplier=2,this.touchMultiplier=2.5,this.worldOriented=!1,this._modelTransform=m(),this._worldFrame=null,this._renderLocation=R(),this._renderLocationDirty=!0,this._location=new A({x:0,y:0,z:0}),this._elevationAlignedLocation=new A,this._elevationAlignedLocationDirty=!0,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.consumesClicks=!0,this.cursor=null,this.grabCursor=null,this._grabbing=!1,this.dragging=!1,this._hovering=!1,this._selected=!1,this._state=0,this._focused=!1,this.events=new t,this._screenLocation={screenPointArray:n(),renderScreenPointArray:r(),pixelSize:0},this._screenLocationDirty=!0,this._engineResourcesAddedToStage=!1,this._attached=!1,this._location.spatialReference=e.view.spatialReference,Object.assign(this,e);const i=this.view.state?.camera;i&&this._camera.copyFrom(i)}destroy(){this._applyObjectTransform=ge,this._removeResourcesFromStage(),this._engineResources=null,this.view=null,this._camera=null}get _stage(){return this.view?.stage}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this._elevationAlignedLocationDirty=!0,this._renderLocationDirty=!0,this._updateEngineObject()}get renderObjects(){return this._renderObjects}set renderObjects(e){this._removeResourcesFromStage(),this._engineResources=null,this._renderObjects=e.slice(),this._updateEngineObject()}set available(e){e!==this._available&&(this._available=e,this._updateEngineObject())}get available(){return this._available}disableDisplay(){return this._noDisplayCount++,1===this._noDisplayCount&&this._updateEngineObject(),i(()=>{this._noDisplayCount--,0===this._noDisplayCount&&this._updateEngineObject()})}set radius(e){e!==this._radius&&(this._radius=e,this._updateEngineObject())}get radius(){return this._radius}set worldSized(e){e!==this._worldSized&&(this._worldSized=e,this._updateEngineObject())}get worldSized(){return this._worldSized}get modelTransform(){return this._modelTransform}set modelTransform(e){Z(e)&&(this._screenLocationDirty=!0),d(this._modelTransform,e),this._updateEngineObject()}get renderLocation(){return this._renderLocationDirty&&(this._renderLocationDirty=!1,this.view.renderCoordsHelper.toRenderCoords(this.elevationAlignedLocation,this._renderLocation),this.worldOriented?(this._worldFrame||(this._worldFrame=m()),$(this.view,this._renderLocation,this._worldFrame)):this._worldFrame&&(this._worldFrame=null)),this._renderLocation}set renderLocation(e){this.view.renderCoordsHelper.fromRenderCoords(e,this._location),this.elevationAlignedLocation=this._location}get location(){return this._location}set location(e){q(e,this._location),this._notifyLocationChanged()}_notifyLocationChanged(){this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!0,this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}get elevationAlignedLocation(){return this._elevationAlignedLocationDirty?(this._evaluateElevationAlignment(),this._updateElevationAlignedLocation(),this._elevationAlignedLocation):this._elevationAlignedLocation}set elevationAlignedLocation(e){q(e,this._location),this._evaluateElevationAlignment(),this._location.z-=this._elevation.offset,this._updateElevationAlignedLocation(),this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}_updateElevationAlignedLocation(){const e=null!=this._elevation.override?this._elevation.override:this.location.z||0;this._elevationAlignedLocation.x=this.location.x,this._elevationAlignedLocation.y=this.location.y,this._elevationAlignedLocation.z=e+this._elevation.offset,this._elevationAlignedLocation.spatialReference=G(this.location.spatialReference),this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!1}grabbableForEvent(){return!0}get grabbing(){return this._grabbing}set grabbing(e){e!==this._grabbing&&(this._grabbing=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get hovering(){return this._hovering}set hovering(e){e!==this._hovering&&(this._hovering=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get selected(){return this._selected}set selected(e){e!==this._selected&&(this._selected=e,this._updateEngineObject(),this.events.emit("select-changed",{action:e?"select":"deselect"}))}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._updateEngineObject())}updateStateEnabled(e,t){t?this.state|=e:this.state&=~e}_setFocused(e){e!==this._focused&&(this._focused=e,this.events.emit("focus-changed",{action:!0===e?"focus":"unfocus"}))}get focused(){return this._focused}get screenLocation(){return this._ensureScreenLocation(),this._screenLocation}_ensureScreenLocation(){if(!this._screenLocationDirty)return;this._screenLocation.pixelSize=this._camera.computeScreenPixelSizeAt(this.renderLocation),this._screenLocationDirty=!1;let e;if(Z(this._modelTransform)){const t=this._calculateModelTransformOffset(_e);e=p(t,t,this.renderLocation)}else e=this.renderLocation;this._camera.projectToRenderScreen(e,this._screenLocation.renderScreenPointArray),this._camera.renderToScreen(this._screenLocation.renderScreenPointArray,this._screenLocation.screenPointArray)}get applyObjectTransform(){return this._applyObjectTransform}set applyObjectTransform(e){this._applyObjectTransform=e,this._screenLocationDirty=!0,this._updateEngineObject()}get attached(){return this._attached}intersectionDistance(t,i){if(!this.available)return null;const s=a(t,ee),o=this._getCollisionRadius(i),r=-1*this.collisionPriority;switch(this.collisionType.type){case"point":if(f(this.screenLocation.screenPointArray,s)<o*o)return this.screenLocation.renderScreenPointArray[2]+r;break;case"line":{const e=this.collisionType.paths,t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,re),n=o*this.screenLocation.pixelSize,a=K(this._camera,s,ie);if(null==a)return null;for(const s of e){if(0===s.length)continue;const e=v(ae,s[0],i);for(let t=1;t<s.length;t++){const o=v(ce,s[t],i),l=k(x(e,o,te),a);if(null!=l&&l<n*n){const t=p(H.get(),e,o);y(t,t,.5);const i=c(H.get());return this._camera.projectToRenderScreen(t,i),i[2]+r}j(e,o)}}break}case"disc":{const e=this.collisionType.direction,t=this.collisionType.offset??w,i=this._getWorldToScreenObjectScale(),n=this._calculateObjectTransform(i,re),a=o*this.screenLocation.pixelSize,c=K(this._camera,s,ie);if(null==c)return null;const h=l(se,n),d=b(he,e,h),_=v(de,t,n);I(_,d,ne);const u=le;if(W(ne,c,u)&&L(u,_)<a*a)return this.screenLocation.renderScreenPointArray[2]+r;break}case"ribbon":{const{paths:e,direction:t}=this.collisionType,i=this._getWorldToScreenObjectScale(),n=this._calculateObjectTransform(i,re),a=o*this._camera.computeScreenPixelSizeAt(this.renderLocation),h=K(this._camera,s,ie);if(null==h)return null;const d=l(se,n),_=b(he,t,d),u=this._calculateModelTransformPosition(de);I(u,_,ne);const g=le;if(!W(ne,h,g))break;for(const s of e){if(0===s.length)continue;const e=v(ae,s[0],n);for(let t=1;t<s.length;t++){const i=v(ce,s[t],n),o=C(x(e,i,te),g);if(null!=o&&o<a*a){const t=p(H.get(),e,i);y(t,t,.5);const s=c(H.get());return this._camera.projectToRenderScreen(t,s),s[2]+r}j(e,i)}}break}default:e(this.collisionType)}return null}attach(e={manipulator3D:{}}){const t=this._stage;if(!t)return;const i=e.manipulator3D;null==i.engineLayerId?(this._engineLayer=new X(t,{pickable:!1,updatePolicy:1}),i.engineLayerId=this._engineLayer.id):t?.getLayer&&(this._engineLayer=t.getLayer(i.engineLayerId)),i.engineLayerReferences=(i.engineLayerReferences||0)+1,this._camera.copyFrom(this.view.state.camera),this._attached=!0,this._updateEngineObject(),E(this._location.spatialReference,this.view.spatialReference)||(this.location=new A({x:0,y:0,z:0,spatialReference:this.view.spatialReference}))}detach(e={manipulator3D:{}}){const t=e.manipulator3D;t.engineLayerReferences--;const i=0===t.engineLayerReferences;this._removeResourcesFromStage(),i&&(t.engineLayerId=null,o(this._engineLayer)),this._engineResources=null,this._engineLayer=null,this._attached=!1}onViewChange(){this._camera.copyFrom(this.view.state.camera),this._screenLocationDirty=!0,this._updateEngineObject()}onElevationChange(e){D(this.location,ue,e.spatialReference)&&P(e.extent,ue)&&this._notifyLocationChanged()}_evaluateElevationAlignment(){if(null==this.elevationInfo)return;let e=null,t=0;const i=V(this.elevationInfo,this.location.spatialReference??this.view.elevationProvider.spatialReference);switch(this.elevationInfo.mode){case"on-the-ground":e=J(this.view.elevationProvider,this.location,"ground")??0;break;case"relative-to-ground":t=(J(this.view.elevationProvider,this.location,"ground")??0)+i;break;case"relative-to-scene":t=(J(this.view.elevationProvider,this.location,"scene")??0)+i;break;case"absolute-height":t=i}return t!==this._elevation.offset||e!==this._elevation.override?(this._elevation.offset=t,void(this._elevation.override=e)):void 0}_updateEngineObject(){if(!this._attached)return;if(!this.available)return void this._removeResourcesFromStage();const e=this._getWorldToScreenObjectScale(),t=re;if(!0===this.autoScaleRenderObjects){const i=this._getFocusedSize(this._radius,this.focused)*e;this._calculateObjectTransform(i,t)}else this._calculateObjectTransform(e,t);const{objectsByState:i}=this._ensureEngineResources(),s=(this.focused?2:1)|(this.selected?8:4),o=this._noDisplayCount>0;for(const{stateMask:r,objects:n}of i){if(o){for(const e of n)e.visible=!1;continue}const e=!!!(15&r)||(s&r)===(15&r),i=!!!(65520&r)||(this.state&r)===(65520&r);if(e&&i)for(const s of n)s.visible=!0,s.transformation=t;else for(const t of n)t.visible=!1}}_ensureEngineResources(){if(null==this._engineResources){const e=this._engineLayer,t=[],i=new Set;this.renderObjects.forEach(({geometry:{material:e}})=>{i.has(e)||(t.push(e),i.add(e))});const s=new Map;this._renderObjects.forEach(e=>{const t=new Q({castShadow:!1,geometries:[e.geometry]}),i=s.get(e.stateMask)||[];i.push(t),s.set(e.stateMask,i)});const o=[];s.forEach((e,t)=>o.push({stateMask:t,objects:e})),this._engineResources={objectsByState:o,layer:e,materials:t}}return this._addResourcesToStage(),this._engineResources}_addResourcesToStage(){const e=this._stage;if(this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i}=this._engineResources;t.forEach(({objects:e})=>i.addMany(e)),this._engineResourcesAddedToStage=!0}_removeResourcesFromStage(){const e=this._stage;if(!this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i}=this._engineResources;t.forEach(({objects:e})=>i.removeMany(e)),this._engineResourcesAddedToStage=!1}_getCollisionRadius(e){return this._getFocusedSize(this.radius,!0)*("touch"===e?this.touchMultiplier:1)}_getFocusedSize(e,t){return e*(t?this.focusMultiplier:1)}_getWorldToScreenObjectScale(){return this._worldSized?1:this.screenLocation.pixelSize}_calculateModelTransformPosition(e){const t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,oe);return S(e,i[12],i[13],i[14])}_calculateModelTransformOffset(e){const t=this._calculateModelTransformPosition(e);return O(e,t,this.renderLocation)}_calculateObjectTransform(e,t){return _(t,e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1),this._worldFrame&&u(t,t,this._worldFrame),u(t,t,this._modelTransform),t[12]+=this.renderLocation[0],t[13]+=this.renderLocation[1],t[14]+=this.renderLocation[2],t[15]=1,null!=this._applyObjectTransform&&this._applyObjectTransform(t),t}get test(){}}function Z(e){return 0!==e[12]||0!==e[13]||0!==e[14]}function $(e,t,i){switch(e.viewingMode){case"local":return g(i),!0;case"global":{const o=T(e.renderCoordsHelper.spatialReference);return z(t,0,ae,0,o.radius),F(s(ae[0]),s(ae[1]),i),!0}}}const ee=n(),te=M(),ie=B(),se=h(),oe=m(),re=m(),ne=U(),ae=R(),ce=R(),le=R(),he=R(),de=R(),_e=R(),ue=new A({x:0,y:0,z:0,spatialReference:null}),ge=()=>{};export{Y as Manipulator3D};
|
|
5
|
+
import{neverReached as e}from"../../../core/compilerUtils.js";import{EventEmitter as t}from"../../../core/Evented.js";import{makeHandle as i}from"../../../core/handleUtils.js";import"../../../core/has.js";import{deg2rad as s}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{createRenderScreenPointArray3 as r,createScreenPointArray as n,screenPointObjectToArray as a,castRenderScreenPointArray as c}from"../../../core/screenUtils.js";import{fromMat4 as l}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as h}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{copy as d,set as _,multiply as u,identity as g}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{squaredDistance as f}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{f as p,o as b,t as v,g as y,c as j,s as L,i as S,d as O}from"../../../chunks/vec32.js";import{create as R,ZEROS as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as T}from"../../../geometry/ellipsoidUtils.js";import A from"../../../geometry/Point.js";import{canProjectWithoutEngine as E,projectPoint as D}from"../../../geometry/projectionUtils.js";import{computeENUToPCPFLocalRotation as F}from"../../../geometry/projection/localRotationUtils.js";import{sphericalPCPFtoLonLatElevation as z}from"../../../geometry/projection/projectors.js";import{containsPointObject as P}from"../../../geometry/support/aaBoundingRect.js";import{distance2 as C,fromPoints as x,create as M,closestRayDistance2 as k}from"../../../geometry/support/lineSegment.js";import{fromPositionAndNormal as I,create as U,intersectRay as W}from"../../../geometry/support/plane.js";import{create as B}from"../../../geometry/support/ray.js";import{sv3d as H}from"../../../geometry/support/vectorStacks.js";import{clonePoint as q,hydratedSpatialReference as G}from"../../../layers/graphics/hydratedFeatures.js";import{getElevationOffset as V}from"../../../support/elevationInfoUtils.js";import{getElevationAtPoint as J}from"../support/ElevationProvider.js";import{fromScreen as K}from"../support/geometryUtils/ray.js";import N from"../webgl/RenderCamera.js";import{Object3D as Q}from"../webgl-engine/lib/Object3D.js";import{WebGLLayer as X}from"../webgl-engine/lib/WebGLLayer.js";class Y{constructor(e){this.metadata=void 0,this._camera=new N,this._elevation={offset:0,override:null},this.collisionType={type:"point"},this.collisionPriority=0,this._renderObjects=new Array,this.autoScaleRenderObjects=!0,this._available=!0,this._noDisplayCount=0,this._radius=10,this._worldSized=!1,this.focusMultiplier=2,this.touchMultiplier=2.5,this.worldOriented=!1,this._modelTransform=m(),this._worldFrame=null,this._renderLocation=R(),this._renderLocationDirty=!0,this._location=new A({x:0,y:0,z:0}),this._elevationAlignedLocation=new A,this._elevationAlignedLocationDirty=!0,this.interactive=!0,this.selectable=!1,this.grabbable=!0,this.consumesClicks=!0,this.cursor=null,this.grabCursor=null,this._grabbing=!1,this.dragging=!1,this._hovering=!1,this._selected=!1,this._state=0,this._focused=!1,this.events=new t,this._screenLocation={screenPointArray:n(),renderScreenPointArray:r(),pixelSize:0},this._screenLocationDirty=!0,this._engineResourcesAddedToStage=!1,this._attached=!1,this._location.spatialReference=e.view.spatialReference,Object.assign(this,e);const i=this.view.state?.camera;i&&this._camera.copyFrom(i)}destroy(){this._applyObjectTransform=ge,this._removeResourcesFromStage(),this._engineResources=null,this.view=null,this._camera=null}get _stage(){return this.view?.stage}get elevationInfo(){return this._elevationInfo}set elevationInfo(e){this._elevationInfo=e,this._elevationAlignedLocationDirty=!0,this._renderLocationDirty=!0,this._updateEngineObject()}get renderObjects(){return this._renderObjects}set renderObjects(e){this._removeResourcesFromStage(),this._engineResources=null,this._renderObjects=e.slice(),this._updateEngineObject()}set available(e){e!==this._available&&(this._available=e,this._updateEngineObject())}get available(){return this._available}disableDisplay(){return this._noDisplayCount++,1===this._noDisplayCount&&this._updateEngineObject(),i(()=>{this._noDisplayCount--,0===this._noDisplayCount&&this._updateEngineObject()})}set radius(e){e!==this._radius&&(this._radius=e,this._updateEngineObject())}get radius(){return this._radius}set worldSized(e){e!==this._worldSized&&(this._worldSized=e,this._updateEngineObject())}get worldSized(){return this._worldSized}get modelTransform(){return this._modelTransform}set modelTransform(e){Z(e)&&(this._screenLocationDirty=!0),d(this._modelTransform,e),this._updateEngineObject()}get renderLocation(){return this._renderLocationDirty&&(this._renderLocationDirty=!1,this.view.renderCoordsHelper.toRenderCoords(this.elevationAlignedLocation,this._renderLocation),this.worldOriented?(this._worldFrame||(this._worldFrame=m()),$(this.view,this._renderLocation,this._worldFrame)):this._worldFrame&&(this._worldFrame=null)),this._renderLocation}set renderLocation(e){this.view.renderCoordsHelper.fromRenderCoords(e,this._location),this.elevationAlignedLocation=this._location}get location(){return this._location}set location(e){q(e,this._location),this._notifyLocationChanged()}_notifyLocationChanged(){this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!0,this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}get elevationAlignedLocation(){return this._elevationAlignedLocationDirty?(this._evaluateElevationAlignment(),this._updateElevationAlignedLocation(),this._elevationAlignedLocation):this._elevationAlignedLocation}set elevationAlignedLocation(e){q(e,this._location),this._evaluateElevationAlignment(),this._location.z-=this._elevation.offset,this._updateElevationAlignedLocation(),this._updateEngineObject(),this.events.emit("location-update",{location:this._location})}_updateElevationAlignedLocation(){const e=null!=this._elevation.override?this._elevation.override:this.location.z||0;this._elevationAlignedLocation.x=this.location.x,this._elevationAlignedLocation.y=this.location.y,this._elevationAlignedLocation.z=e+this._elevation.offset,this._elevationAlignedLocation.spatialReference=G(this.location.spatialReference),this._renderLocationDirty=!0,this._screenLocationDirty=!0,this._elevationAlignedLocationDirty=!1}grabbableForEvent(){return!0}get grabbing(){return this._grabbing}set grabbing(e){e!==this._grabbing&&(this._grabbing=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get hovering(){return this._hovering}set hovering(e){e!==this._hovering&&(this._hovering=e,this._setFocused(this._hovering||this._grabbing),this._updateEngineObject())}get selected(){return this._selected}set selected(e){e!==this._selected&&(this._selected=e,this._updateEngineObject(),this.events.emit("select-changed",{action:e?"select":"deselect"}))}get state(){return this._state}set state(e){e!==this._state&&(this._state=e,this._updateEngineObject())}updateStateEnabled(e,t){t?this.state|=e:this.state&=~e}_setFocused(e){e!==this._focused&&(this._focused=e,this.events.emit("focus-changed",{action:!0===e?"focus":"unfocus"}))}get focused(){return this._focused}get screenLocation(){return this._ensureScreenLocation(),this._screenLocation}_ensureScreenLocation(){if(!this._screenLocationDirty)return;this._screenLocation.pixelSize=this._camera.computeScreenPixelSizeAt(this.renderLocation),this._screenLocationDirty=!1;let e;if(Z(this._modelTransform)){const t=this._calculateModelTransformOffset(_e);e=p(t,t,this.renderLocation)}else e=this.renderLocation;this._camera.projectToRenderScreen(e,this._screenLocation.renderScreenPointArray),this._camera.renderToScreen(this._screenLocation.renderScreenPointArray,this._screenLocation.screenPointArray)}get applyObjectTransform(){return this._applyObjectTransform}set applyObjectTransform(e){this._applyObjectTransform=e,this._screenLocationDirty=!0,this._updateEngineObject()}get attached(){return this._attached}intersectionDistance(t,i){if(!this.available)return null;const s=a(t,ee),o=this._getCollisionRadius(i),r=-1*this.collisionPriority;switch(this.collisionType.type){case"point":if(f(this.screenLocation.screenPointArray,s)<o*o)return this.screenLocation.renderScreenPointArray[2]+r;break;case"line":{const e=this.collisionType.paths,t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,re),n=o*this.screenLocation.pixelSize,a=K(this._camera,s,ie);if(null==a)return null;for(const s of e){if(0===s.length)continue;const e=v(ae,s[0],i);for(let t=1;t<s.length;t++){const o=v(ce,s[t],i),l=k(x(e,o,te),a);if(null!=l&&l<n*n){const t=p(H.get(),e,o);y(t,t,.5);const i=c(H.get());if(this._camera.projectToRenderScreen(t,i))return i[2]+r}j(e,o)}}break}case"disc":{const e=this.collisionType.direction,t=this.collisionType.offset??w,i=this._getWorldToScreenObjectScale(),n=this._calculateObjectTransform(i,re),a=o*this.screenLocation.pixelSize,c=K(this._camera,s,ie);if(null==c)return null;const h=l(se,n),d=b(he,e,h),_=v(de,t,n);I(_,d,ne);const u=le;if(W(ne,c,u)&&L(u,_)<a*a)return this.screenLocation.renderScreenPointArray[2]+r;break}case"ribbon":{const{paths:e,direction:t}=this.collisionType,i=this._getWorldToScreenObjectScale(),n=this._calculateObjectTransform(i,re),a=o*this._camera.computeScreenPixelSizeAt(this.renderLocation),h=K(this._camera,s,ie);if(null==h)return null;const d=l(se,n),_=b(he,t,d),u=this._calculateModelTransformPosition(de);I(u,_,ne);const g=le;if(!W(ne,h,g))break;for(const s of e){if(0===s.length)continue;const e=v(ae,s[0],n);for(let t=1;t<s.length;t++){const i=v(ce,s[t],n),o=C(x(e,i,te),g);if(null!=o&&o<a*a){const t=p(H.get(),e,i);y(t,t,.5);const s=c(H.get());if(this._camera.projectToRenderScreen(t,s))return s[2]+r}j(e,i)}}break}default:e(this.collisionType)}return null}attach(e={manipulator3D:{}}){const t=this._stage;if(!t)return;const i=e.manipulator3D;null==i.engineLayerId?(this._engineLayer=new X(t,{pickable:!1,updatePolicy:1}),i.engineLayerId=this._engineLayer.id):t?.getLayer&&(this._engineLayer=t.getLayer(i.engineLayerId)),i.engineLayerReferences=(i.engineLayerReferences||0)+1,this._camera.copyFrom(this.view.state.camera),this._attached=!0,this._updateEngineObject(),E(this._location.spatialReference,this.view.spatialReference)||(this.location=new A({x:0,y:0,z:0,spatialReference:this.view.spatialReference}))}detach(e={manipulator3D:{}}){const t=e.manipulator3D;t.engineLayerReferences--;const i=0===t.engineLayerReferences;this._removeResourcesFromStage(),i&&(t.engineLayerId=null,o(this._engineLayer)),this._engineResources=null,this._engineLayer=null,this._attached=!1}onViewChange(){this._camera.copyFrom(this.view.state.camera),this._screenLocationDirty=!0,this._updateEngineObject()}onElevationChange(e){D(this.location,ue,e.spatialReference)&&P(e.extent,ue)&&this._notifyLocationChanged()}_evaluateElevationAlignment(){if(null==this.elevationInfo)return;let e=null,t=0;const i=V(this.elevationInfo,this.location.spatialReference??this.view.elevationProvider.spatialReference);switch(this.elevationInfo.mode){case"on-the-ground":e=J(this.view.elevationProvider,this.location,"ground")??0;break;case"relative-to-ground":t=(J(this.view.elevationProvider,this.location,"ground")??0)+i;break;case"relative-to-scene":t=(J(this.view.elevationProvider,this.location,"scene")??0)+i;break;case"absolute-height":t=i}return t!==this._elevation.offset||e!==this._elevation.override?(this._elevation.offset=t,void(this._elevation.override=e)):void 0}_updateEngineObject(){if(!this._attached)return;if(!this.available)return void this._removeResourcesFromStage();const e=this._getWorldToScreenObjectScale(),t=re;if(!0===this.autoScaleRenderObjects){const i=this._getFocusedSize(this._radius,this.focused)*e;this._calculateObjectTransform(i,t)}else this._calculateObjectTransform(e,t);const{objectsByState:i}=this._ensureEngineResources(),s=(this.focused?2:1)|(this.selected?8:4),o=this._noDisplayCount>0;for(const{stateMask:r,objects:n}of i){if(o){for(const e of n)e.visible=!1;continue}const e=!!!(15&r)||(s&r)===(15&r),i=!!!(65520&r)||(this.state&r)===(65520&r);if(e&&i)for(const s of n)s.visible=!0,s.transformation=t;else for(const t of n)t.visible=!1}}_ensureEngineResources(){if(null==this._engineResources){const e=this._engineLayer,t=[],i=new Set;this.renderObjects.forEach(({geometry:{material:e}})=>{i.has(e)||(t.push(e),i.add(e))});const s=new Map;this._renderObjects.forEach(e=>{const t=new Q({castShadow:!1,geometries:[e.geometry]}),i=s.get(e.stateMask)||[];i.push(t),s.set(e.stateMask,i)});const o=[];s.forEach((e,t)=>o.push({stateMask:t,objects:e})),this._engineResources={objectsByState:o,layer:e,materials:t}}return this._addResourcesToStage(),this._engineResources}_addResourcesToStage(){const e=this._stage;if(this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i}=this._engineResources;t.forEach(({objects:e})=>i.addMany(e)),this._engineResourcesAddedToStage=!0}_removeResourcesFromStage(){const e=this._stage;if(!this._engineResourcesAddedToStage||null==this._engineResources||!e)return;const{objectsByState:t,layer:i}=this._engineResources;t.forEach(({objects:e})=>i.removeMany(e)),this._engineResourcesAddedToStage=!1}_getCollisionRadius(e){return this._getFocusedSize(this.radius,!0)*("touch"===e?this.touchMultiplier:1)}_getFocusedSize(e,t){return e*(t?this.focusMultiplier:1)}_getWorldToScreenObjectScale(){return this._worldSized?1:this.screenLocation.pixelSize}_calculateModelTransformPosition(e){const t=this._getWorldToScreenObjectScale(),i=this._calculateObjectTransform(t,oe);return S(e,i[12],i[13],i[14])}_calculateModelTransformOffset(e){const t=this._calculateModelTransformPosition(e);return O(e,t,this.renderLocation)}_calculateObjectTransform(e,t){return _(t,e,0,0,0,0,e,0,0,0,0,e,0,0,0,0,1),this._worldFrame&&u(t,t,this._worldFrame),u(t,t,this._modelTransform),t[12]+=this.renderLocation[0],t[13]+=this.renderLocation[1],t[14]+=this.renderLocation[2],t[15]=1,null!=this._applyObjectTransform&&this._applyObjectTransform(t),t}get test(){}}function Z(e){return 0!==e[12]||0!==e[13]||0!==e[14]}function $(e,t,i){switch(e.viewingMode){case"local":return g(i),!0;case"global":{const o=T(e.renderCoordsHelper.spatialReference);return z(t,0,ae,0,o.radius),F(s(ae[0]),s(ae[1]),i),!0}}}const ee=n(),te=M(),ie=B(),se=h(),oe=m(),re=m(),ne=U(),ae=R(),ce=R(),le=R(),he=R(),de=R(),_e=R(),ue=new A({x:0,y:0,z:0,spatialReference:null}),ge=()=>{};export{Y as Manipulator3D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{rad2deg as t}from"../../../../../../core/mathUtils.js";import{rotateX as e}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{f as o,c as
|
|
5
|
+
import{rad2deg as t}from"../../../../../../core/mathUtils.js";import{rotateX as e}from"../../../../../../core/libs/gl-matrix-2/math/mat4.js";import{f as o,c as r}from"../../../../../../chunks/vec32.js";import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{d as n}from"../../../../../../chunks/boundedPlane.js";import{create as s,intersectRay as i,getNormal as l}from"../../../../../../geometry/support/plane.js";import{sm4d as p,sv3d as u}from"../../../../../../geometry/support/vectorStacks.js";import{getRotateHeadingTexture as c}from"../../../../analysis/images/Factory.js";import{RotateManipulator as m}from"../../../../analysis/Slice/RotateManipulator.js";import{createRotatePlane as d}from"../../../../analysis/Slice/sliceToolUtils.js";import{calculateInputRotationTransform as h}from"../../../manipulatorUtils.js";import{screenToRenderPlane as g}from"../../dragEventPipeline3D.js";import{fromScreenNormalized as _}from"../../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as f}from"../../../../../interactive/dragEventPipeline.js";import{ExtentRotateTooltipInfo as j}from"../../../../../interactive/tooltip/infos/ExtentRotateTooltipInfo.js";class v{get _object(){return this._tool.object}get _operations(){return this._object.operations}constructor(t,e,o){this._tool=t,this._bounds=e,this._snapRotation=o,this._rotateTooltipInfo=null,this._startAngle=0,this._endAngle=0;const r=this._tool,a=r.view,n=!a.stage?.renderView.renderingContext.driverTest.svgPremultipliesAlpha.result;this.rotateManipulator=new m(a,(t,e)=>c(a.stage.textures,{accentColor:t,contrastColor:e,preMultiplyAlpha:n})),r.addHandles([this.rotateManipulator.events.on("grab-changed",t=>this._onGrabChanged(t)),this._createRotateDragPipeline(this.rotateManipulator)]),r.manipulators.add(this.rotateManipulator),r.addHandles([r.events.on("rotate-start",t=>this._startAngle=t.angle),r.events.on("rotate",t=>this._endAngle=t.angle),r.events.on("rotate-stop",()=>{this._startAngle=0,this._endAngle=0})])}destroy(){this._tool.manipulators.remove(this.rotateManipulator),this.rotateManipulator.destroy()}forEachManipulator(t){t(this.rotateManipulator,3)}updateManipulators(t,r){const a=this._bounds.mapBounds.plane[2]<0?Math.PI:0,n=e(p.get(),t,a);n[12]=0,n[13]=0,n[14]=0,this.rotateManipulator.modelTransform=n,this.rotateManipulator.renderLocation=o(u.get(),r.origin,r.basis1)}getUpdatedTooltipInfo(){return this.rotateManipulator.focused?this._computeRotateTooltipInfo():null}_computeRotateTooltipInfo(){const t=this._rotateTooltipInfo??=new j({sketchOptions:this._tool.sketchOptions});return t.angle=this._startAngle-this._endAngle,t}_onGrabChanged({action:t,screenPoint:e}){const o=this._tool,r=this._bounds;if("start"!==t||!e)return;const a=d(r.displayBounds,o.view.renderCoordsHelper,1,s()),n=_(o.view.state.camera,e);i(a,n,u.get())&&(r.backupMapBounds(),o.inputState={type:"rotate",rotatePlane:a})}_createRotateDragPipeline(e){const{_tool:o,_object:r}=this;return f(e,(e,a,n)=>{const s=o.inputState;null!=s&&(a.next(t=>("start"===t.action&&o.events.emit("rotate-start",{object:r,angle:0}),t)).next(g(o.view,s.rotatePlane)).next(this._renderPlaneToAngle()).next(...this._snapRotation()).next(this._updateGeometry()).next(e=>{const a={object:r,angle:t(e.rotateAngle)};switch(e.action){case"start":case"update":o.events.emit("rotate",a);break;case"end":o.inputState=null,o.events.emit("rotate-stop",a)}return e}),n.next(()=>{null!=o.inputState&&o.events.emit("rotate-stop",{object:r,angle:0}),o.cancelDrag()}))})}_renderPlaneToAngle(){return t=>{const e=h(t.renderStart,t.renderEnd,this._bounds.displayBounds.origin,l(t.plane));return{...t,rotateAngle:e}}}_updateGeometry(){const t=this._bounds;return e=>{const o=r(a(),t.mapBoundsStart.origin),s="start"===e.action?0:1;if(this._operations){const r=this._operations.rotate(o,e.rotateAngle,s,1);n(t.mapBoundsStart,t.mapBounds),t.updateMapBoundsFromOperation(r)}return e}}}export{v as ExtentRotate};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{set as t,normalize as e}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as a,b as i,d as o,l as r,e as n}from"../../../../../../chunks/vec32.js";import{create as c}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{
|
|
5
|
+
import{set as t,normalize as e}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as s}from"../../../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{c as a,b as i,d as o,l as r,e as n}from"../../../../../../chunks/vec32.js";import{create as c}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as p,d as l}from"../../../../../../chunks/boundedPlane.js";import{intersectRay as d}from"../../../../../../geometry/support/plane.js";import{sv3d as h}from"../../../../../../geometry/support/vectorStacks.js";import{ResizeManipulator as u}from"../../../../analysis/Slice/ResizeManipulator.js";import{updateResizeHandle as m,isDiagonalResizeHandle as _,calculateDiagonalResizeHandleScale as f}from"../../../../analysis/Slice/sliceToolUtils.js";import{screenToRenderPlane as S}from"../../dragEventPipeline3D.js";import{mapPlaneAutoSize2D as g}from"./extentUtils.js";import{fromScreenNormalized as y}from"../../../../support/geometryUtils/ray.js";import{createManipulatorDragEventPipeline as x}from"../../../../../interactive/dragEventPipeline.js";import{ExtentScaleTooltipInfo as M}from"../../../../../interactive/tooltip/infos/ExtentScaleTooltipInfo.js";class b{get _object(){return this._tool.object}get _operations(){return this._object.operations}get zMax(){if(!this._zMaxDirty||!this._operations)return this._zMax;const t=this._operations.data;if(t.geometry.hasZ){const e=t.coordinateHelper;this._zMax=Number.NEGATIVE_INFINITY;for(const s of t.parts)for(const t of s.vertices){const s=e.getZ(t.pos)??0;this._zMax=Math.max(s,this._zMax)}}else this._zMax=0;return this._zMaxDirty=!1,this._zMax}constructor(t,e,s){this._tool=t,this._bounds=e,this._preserveAspectRatioStep=s,this._resizeHandles=[{direction:[1,0]},{direction:[1,1]},{direction:[0,1]},{direction:[-1,1]},{direction:[-1,0]},{direction:[-1,-1]},{direction:[0,-1]},{direction:[1,-1]}],this._displayBoundsStart=p(),this._displayBoundsMarginStart=0,this._zMax=0,this._zMaxDirty=!0;const a=this._tool,i=a.view;this.resizeManipulators=this._resizeHandles.map(t=>{const e=new u(i,t);return a.addHandles([e.events.on("grab-changed",t=>this._onGrabChanged(t)),this._createResizeDragPipeline(e,t)]),e}),a.manipulators.addMany(this.resizeManipulators),this._operations&&a.addHandles(this._operations.data.on("change",()=>{"resize"!==a.inputState?.type&&(this._zMaxDirty=!0)}))}destroy(){this.forEachManipulator(t=>{this._tool.manipulators.remove(t),t.destroy()})}forEachManipulator(t){this.resizeManipulators.forEach(e=>t(e,2))}updateManipulators(t,e){this.resizeManipulators.forEach((s,a)=>{m(s,this._resizeHandles[a],t,e)})}getUpdatedTooltipInfo(){if(!this.resizeManipulators.some(t=>t.focused))return null;const t=this._tooltipInfo??=new M({sketchOptions:this._tool.sketchOptions}),e=g(this._bounds.mapBounds,this.zMax,this._bounds.spatialReference,this._tool.automaticLengthMeasurementUtils);return e&&(t.xSize=e.xSize,t.ySize=e.ySize),this.resizeManipulators.some(t=>t.dragging)||(t.xScale=1,t.yScale=1),t}_onGrabChanged({action:t,screenPoint:e}){const s=this._tool,a=this._bounds;if("start"!==t||!e)return;const i=y(s.view.state.camera,e);d(a.displayBounds.plane,i,h.get())&&(a.backupMapBounds(),l(a.displayBounds,this._displayBoundsStart),this._displayBoundsMarginStart=a.displayBoundsMargin,s.inputState={type:"resize"})}_createResizeDragPipeline(t,e){const{_tool:s,_object:a}=this;return x(t,(t,i,o)=>{null!=s.inputState&&(i.next(t=>("start"===t.action&&s.events.emit("scale-start",{object:a,xScale:1,yScale:1}),{...t,handle:e})).next(S(s.view,this._displayBoundsStart.plane)).next(this._renderPlaneToFactors()).next(...this._preserveAspectRatioStep()).next(this._updateGeometry()).next(t=>{const e=this._tooltipInfo;e&&(e.xScale=t.factor1,e.yScale=t.factor2);const i={object:a,xScale:t.factor1,yScale:t.factor2};switch(t.action){case"start":case"update":s.events.emit("scale",i);break;case"end":s.inputState=null,s.events.emit("scale-stop",i)}return t}),o.next(()=>{null!=s.inputState&&s.events.emit("scale-stop",{object:a,xScale:1,yScale:1}),s.cancelDrag()}))})}_renderPlaneToFactors(){const t=this._bounds;return e=>{const s=this._displayBoundsStart,c=e.handle.direction,p=t.displayBoundsMargin,l=this._displayBoundsMarginStart,d=a(h.get(),s.origin);i(d,d,s.basis1,-c[0]),i(d,d,s.basis2,-c[1]);const u=o(h.get(),e.renderEnd,d),m=o(h.get(),e.renderStart,d),S=_(e.handle),g=f(s),y=f(t.displayBounds)/g,x=(t,e)=>{if(0===t)return 1;let s=r(e),a=.5*t*n(e,u)/s;const i=a<0?-1:1;if(S){a+=(s-.5*t*n(e,m)/s)*i*y}const o=s<1.5*l?1:z;return s=Math.max(s-l,z),i>0&&(a-=p),i*Math.max(i*(a/s),o)};return{...e,factor1:x(c[0],s.basis1),factor2:x(c[1],s.basis2)}}}_updateGeometry(){const o=this._bounds;return r=>{const n=a(c(),o.mapBoundsStart.origin);i(n,n,o.mapBoundsStart.basis1,-r.handle.direction[0]),i(n,n,o.mapBoundsStart.basis2,-r.handle.direction[1]);const p=t(s(),o.mapBoundsStart.basis1[0],o.mapBoundsStart.basis1[1]);e(p,p);const d="start"===r.action?0:1;if(this._operations){const t=this._operations.scale(n,p,r.factor1,r.factor2,d,1);l(o.mapBoundsStart,o.mapBounds),o.updateMapBoundsFromOperation(t)}return r}}}const z=1e-6;export{b as ExtentScale,z as scaleEpsilon};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{on as s}from"../../../../../../core/reactiveUtils.js";import{scale as t}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{f as i,d as o,g as a,m as e,h as n,n as r,e as p,c as d,b as c}from"../../../../../../chunks/vec32.js";import{create as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{
|
|
5
|
+
import{on as s}from"../../../../../../core/reactiveUtils.js";import{scale as t}from"../../../../../../core/libs/gl-matrix-2/math/vec2.js";import{f as i,d as o,g as a,m as e,h as n,n as r,e as p,c as d,b as c}from"../../../../../../chunks/vec32.js";import{create as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{a as u,d as m,u as b}from"../../../../../../chunks/boundedPlane.js";import{fromPositionAndNormal as h,projectPoint as g}from"../../../../../../geometry/support/plane.js";import{sv3d as f}from"../../../../../../geometry/support/vectorStacks.js";import{mainAxis as B}from"../../geometryUtils.js";import{manipulatedObjectGeometry as M}from"../../manipulatedObjectUtils.js";import{evaluateElevationAlignmentAtPoint as y}from"../../../../layers/graphics/elevationAlignmentUtils.js";import{ElevationContext as j}from"../../../../layers/graphics/ElevationContext.js";import{apply as v,applyInverse as _,calculateOrientedBounds as R}from"../../../../../interactive/editGeometry/support/editPlaneUtils.js";import{autoSize2D as x}from"../../../../../support/extentUtils.js";class C{constructor(t,i){this._tool=t,this.mapBounds=u(),this.mapBoundsStart=u(),this.displayBounds=u(),t.addHandles(s(()=>t.object,"modified-externally",()=>this._resetMapBounds(),{onListenerAdd:()=>this._resetMapBounds()})),this._onDisplayBoundsChanged=i}get displayBoundsMargin(){const{view:s,object:t}=this._tool,i=M(t),o=s.pointsOfInterest?.centerOnSurfaceFrequent.location??i?.extent?.center;return o?D*s.pixelSizeAt(o):0}backupMapBounds(){m(this.mapBounds,this.mapBoundsStart)}updateDisplayBounds(){this._calculateDisplayBounds(),this._onDisplayBoundsChanged?.()}updateMapBoundsFromOperation(s){v(s,this.mapBounds),this.updateDisplayBounds()}updateMapBoundsFromOperationInverse(s){_(s,this.mapBounds),this.updateDisplayBounds()}_resetMapBounds(){this._calculateMapBounds(),this.updateDisplayBounds()}_calculateMapBounds(){const{view:s,attachmentOrigin:i,object:o}=this._tool,a=o.operations?.data;if(!a)return;const e=a.geometry;this.spatialReference=e.spatialReference;const n=B(e);t(n,n,-1);const r=i?s.pixelSizeAt(i,e.spatialReference):0,p=O*r,d=a.coordinateHelper.hasZ()&&"on-the-ground"!==o.elevationInfo.mode;R(n,a,p,this.mapBounds,d)}_calculateDisplayBounds(){const{view:s,attachmentOrigin:t}=this._tool,i=t?.z??y(this.mapBounds.origin,s.elevationProvider,j.fromElevationInfo(this._tool.object.elevationInfo),s.renderCoordsHelper);U(this.mapBounds,i??0,s.renderCoordsHelper,this.spatialReference,this.displayBoundsMargin,this.displayBounds)}}const D=10,O=80;function U(s,t,c,l,m=0,B){B||(B=u());const M=f.get();i(M,s.origin,s.basis1),i(M,M,s.basis2),c.toRenderCoords(M,l,M);const y=f.get();i(y,s.origin,s.basis1),o(y,y,s.basis2),c.toRenderCoords(y,l,y);const j=f.get();o(j,s.origin,s.basis1),o(j,j,s.basis2),c.toRenderCoords(j,l,j);const v=f.get();o(v,s.origin,s.basis1),i(v,v,s.basis2),c.toRenderCoords(v,l,v),i(B.origin,M,y),i(B.origin,B.origin,j),i(B.origin,B.origin,v),a(B.origin,B.origin,.25),o(M,M,B.origin),o(y,y,B.origin),o(j,j,B.origin),o(v,v,B.origin);const _=e(f.get(),M,y,.5),R=e(f.get(),j,v,.5);a(R,R,-1),e(B.basis1,_,R,.5);const x=e(f.get(),M,v,.5),C=e(f.get(),y,j,.5);a(C,C,-1),e(B.basis2,x,C,.5);const D=n(f.get(),B.basis1,B.basis2);n(B.basis2,D,B.basis1),r(B.basis1,B.basis1);const O=Math.max(Math.abs(p(B.basis1,M)),Math.abs(p(B.basis1,y)),Math.abs(p(B.basis1,j)),Math.abs(p(B.basis1,v)));r(B.basis2,B.basis2);const U=Math.max(Math.abs(p(B.basis2,M)),Math.abs(p(B.basis2,y)),Math.abs(p(B.basis2,j)),Math.abs(p(B.basis2,v)));a(B.basis1,B.basis1,O+m),a(B.basis2,B.basis2,U+m);const S=d(f.get(),s.origin);return S[2]=t,c.toRenderCoords(S,l,S),h(S,D,B.plane),g(B.plane,B.origin,B.origin),b(B),B}function S(s,t,i,a){return o(H,o(H,s.origin,s.basis1),s.basis2),c(A,H,s.basis1,2),c(k,A,s.basis2,2),c(I,H,s.basis2,2),H[2]=A[2]=k[2]=I[2]=t,x({topLeft:I,topRight:k,bottomRight:A,bottomLeft:H,spatialReference:i,automaticLengthMeasurementUtils:a})}const I=l(),k=l(),A=l(),H=l();export{C as TransformBounds,S as mapPlaneAutoSize2D};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{createRenderScreenPointArray as r}from"../../../../core/screenUtils.js";import{subtract as o,normalize as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{c as t}from"../../../../chunks/vec32.js";import{create as
|
|
5
|
+
import{createRenderScreenPointArray as r}from"../../../../core/screenUtils.js";import{subtract as o,normalize as e}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{c as t}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getConvertedElevationFromVector as c}from"../../../../support/elevationInfoUtils.js";function s(r,t,n,c){const s=n.projectToRenderScreen(r,m),i=n.projectToRenderScreen(t,p);return null==s||null==i?null:(o(c,i,s),e(c,c),c)}function i(r,o,e,s,i=n()){const m=t(l,r);return m[2]=c(s,m,o,e)||0,s.renderCoordsHelper.toRenderCoords(m,o,i),i}const l=n(),m=r(),p=r();export{s as renderScreenSpaceTangent,i as vectorToRender};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.34/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../Color.js";import e from"../../../../core/Handles.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{createScreenPointArray as i,createRenderScreenPointArray as s,createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{add as a,set as
|
|
5
|
+
import t from"../../../../Color.js";import e from"../../../../core/Handles.js";import{watch as o}from"../../../../core/reactiveUtils.js";import{createScreenPointArray as i,createRenderScreenPointArray as s,createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{add as a,set as n,scale as h,negate as l,normalize as c,length as _}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{f as m}from"../../../../chunks/vec32.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{renderScreenSpaceTangent as d}from"../support/viewUtils.js";import{VisualElement as p}from"./VisualElement.js";import x from"../../../overlay/LineOverlayItem.js";import b from"../../../overlay/TextOverlayItem.js";class f extends p{constructor(o){super(o),this._handles=new e,this._textItem=null,this._calloutItem=null,this._showCallout=!0,this._showText=!0,this._geometry=null,this._text="-",this._fontSize=14,this._backgroundColor=new t([0,0,0,.6]),this._calloutColor=new t([0,0,0,.5]),this._textColor=new t([255,255,255]),this._distance=25,this._anchor="right",this.updatePositionOnCameraMove=!0,this.applyProperties(o)}get geometry(){return this._geometry}set geometry(t){this._geometry=t,this.updateLabelPosition()}get isDecoration(){return this._isDecoration}set isDecoration(t){this._isDecoration=t,this._textItem&&(this._textItem.isDecoration=t),this._calloutItem&&(this._calloutItem.isDecoration=t)}get textItem(){return this._textItem}get text(){return this._text}set text(t){this._text=t,this.attached&&(this._textItem.text=this._text)}get fontSize(){return this._fontSize}set fontSize(t){this._fontSize=t,this.attached&&(this._textItem.fontSize=this._fontSize)}get backgroundColor(){return this._backgroundColor}set backgroundColor(t){this._backgroundColor=t,this.attached&&(this._textItem.backgroundColor=this._backgroundColor)}get calloutColor(){return this._calloutColor}set calloutColor(t){this._calloutColor=t,this.attached&&(this._calloutItem.color=this._calloutColor.toRgba())}get textColor(){return this._textColor}set textColor(t){this._textColor=t,this.attached&&(this._textItem.textColor=this._textColor)}get distance(){return this._distance}set distance(t){this._distance!==t&&(this._distance=t,this.updateLabelPosition())}get anchor(){return this._anchor}set anchor(t){this._anchor!==t&&(this._anchor=t,this.updateLabelPosition())}get _camera(){return this.view.state.cssCamera}overlaps(t){return!!this.attached&&(this.textItem.visible&&t.textItem.visible&&!!this.view.overlay?.overlaps(this._textItem,t.textItem))}updateLabelPosition(){if(!this.attached)return;this._showText=!1,this._showCallout=!1;const{geometry:t,view:e,visible:o}=this;if(null!=t&&e.stage)switch(t.type){case"point":if(!this._computeLabelPositionFromPoint(t.point,L))break;if(t.callout){const e=this._camera,o=t.callout.distance;a(j,j,[0,t.callout.offset]),e.renderToScreen(j,L),n(P,0,1),h(P,P,o),a(P,P,j),e.renderToScreen(P,D),this._showCallout=this._updatePosition(L,D)}else this._textItem.position=[L[0],L[1]],this._textItem.anchor="center";this._showText=!0;break;case"corner":if(!this._computeLabelPositionFromCorner(t,this._distance,L,D))break;this._showCallout=this._updatePosition(L,D),this._showText=!0;break;case"segment":{if(!this._computeLabelPositionFromSegment(t,this._distance,this._anchor,L,D))break;this._showText=!0;const e=this._updatePosition(L,D);this._showCallout=!1!==t.callout&&e,this._showCallout||(this._textItem.anchor="center")}}this.updateVisibility(o)}_computeLabelPositionFromPoint(t,e){const o=this._camera,i=o.projectToRenderScreen(t,T);return!!i&&(!(i[2]<0||i[2]>1)&&(o.renderToScreen(i,e),!0))}_computeLabelPositionFromCorner(t,e,o,i){if(!t)return!1;const s=this._camera,r=g(t.left,1,s,S),n=g(t.right,0,s,y);if(null==r||null==n)return!1;l(S,S),a(P,r,n),l(P,P),c(P,P);const _=s.projectToRenderScreen(t.left.endRenderSpace,T);return!(!_||_[2]<0||_[2]>1)&&(s.renderToScreen(_,o),h(P,P,e),a(P,P,_),s.renderToScreen(P,i),!0)}_computeLabelPositionFromSegment(t,e,o,i,s){if(!t)return!1;const r=t.segment,c=this._camera;d(r.startRenderSpace,r.endRenderSpace,c,S),n(P,-S[1],S[0]);let m=!1;switch(o){case"top":m=P[1]<0;break;case"bottom":m=P[1]>0;break;case"left":m=P[0]>0;break;case"right":m=P[0]<0}if(m&&l(P,P),0===_(P))switch(o){case"top":P[1]=1;break;case"bottom":P[1]=-1;break;case"left":P[0]=-1;break;case"right":P[0]=1}r.eval(R[t.sampleLocation],k);const u=c.projectToRenderScreen(k,T);return!(!u||u[2]<0||u[2]>1)&&(c.renderToScreen(T,i),h(P,P,e),a(P,P,T),c.renderToScreen(P,s),!0)}_updatePosition(t,e){if(e){const o=e[0]-t[0],i=e[1]-t[1];return this._textItem.position=[e[0],e[1]],this._textItem.anchor=Math.abs(o)>Math.abs(i)?o>0?"left":"right":i>0?"top":"bottom",this._calloutItem.startPosition=[t[0],t[1]],this._calloutItem.endPosition=[e[0],e[1]],!0}return this._textItem.position=[t[0],t[1]],this._textItem.anchor="center",!1}createResources(){this._textItem=new b({visible:!0,text:this._text,fontSize:this._fontSize,backgroundColor:this._backgroundColor,textColor:this._textColor,isDecoration:this._isDecoration}),this._calloutItem=new x({color:this._calloutColor.toRgba(),visible:!0,width:2,isDecoration:this._isDecoration}),this.updateLabelPosition(),this.view.overlay?.items.addMany([this._textItem,this._calloutItem]),this.updatePositionOnCameraMove&&this._handles.add(o(()=>this.view.state.camera,()=>this.updateLabelPosition()))}destroyResources(){this.view.overlay&&!this.view.overlay.destroyed&&this.view.overlay.items.removeMany([this._textItem,this._calloutItem]),this._handles.removeAll()}updateVisibility(t){this._textItem.visible=this._showText&&t,this._calloutItem.visible=this._showCallout&&t}forEachMaterial(){}}function g(t,e,o,i){return t.eval(e,v,w),m(I,v,w),d(v,I,o,i)}function C(t){switch(t){case"top":return"bottom";case"right":return"left";case"bottom":return"top";case"left":return"right"}}const v=u(),I=u(),w=u(),S=s(),y=s(),P=s(),k=u(),T=r(),j=s(),L=i(),D=i(),R={start:0,center:.5,end:1};export{f as LabelVisualElement,C as mirrorPosition};
|