@arcgis/core 5.0.0-next.37 → 5.0.0-next.39

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.
Files changed (147) hide show
  1. package/Color.js +1 -1
  2. package/analysis/DimensionSimpleStyle.js +1 -1
  3. package/analysis/ElevationProfileAnalysis.js +1 -1
  4. package/applications/Components/testUtils.d.ts +4 -0
  5. package/applications/Components/testUtils.js +5 -0
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/02a65563779b4c64b2cf.js +1 -0
  8. package/assets/esri/core/workers/chunks/{328106e181e5957ceaa5.js → 09ac2bbc7327e6e6b5a2.js} +1 -1
  9. package/assets/esri/core/workers/chunks/1a9ed3c59a9a8bafb251.js +1 -0
  10. package/assets/esri/core/workers/chunks/{b96af22ec1470905e4fb.js → 1c857191e5898aba50fe.js} +1 -1
  11. package/assets/esri/core/workers/chunks/2795e491f803654413d2.js +1 -0
  12. package/assets/esri/core/workers/chunks/{3904f8732c9953cb177d.js → 28b235b56a83c498d73f.js} +1 -1
  13. package/assets/esri/core/workers/chunks/36d15c35fbbd4dedd5cb.js +1 -0
  14. package/assets/esri/core/workers/chunks/48f805929fe6241952f5.js +1 -0
  15. package/assets/esri/core/workers/chunks/4c278fb2d51ca6226050.js +1 -0
  16. package/assets/esri/core/workers/chunks/6052eccb9395c8efb295.js +1 -0
  17. package/assets/esri/core/workers/chunks/613cbac9cb925cd20b48.js +1 -0
  18. package/assets/esri/core/workers/chunks/{febce0d80f019dc2a427.js → 646f58b69d2354f1ef27.js} +1 -1
  19. package/assets/esri/core/workers/chunks/7eab0bb42f9f062522ef.js +1 -0
  20. package/assets/esri/core/workers/chunks/{5e34a183420e7007a989.js → 8e8d5422f57269d8c8d2.js} +1 -1
  21. package/assets/esri/core/workers/chunks/9100330ed4b4437c819d.js +1 -0
  22. package/assets/esri/core/workers/chunks/95cb062cae4c31c07124.js +1 -0
  23. package/assets/esri/core/workers/chunks/{ce8fc1ca229d53a4b68d.js → 96f798ee286b59396131.js} +50 -50
  24. package/assets/esri/core/workers/chunks/{e9bc3c6482ba778c9349.js → 9d95f38da21f97214f83.js} +1 -1
  25. package/assets/esri/core/workers/chunks/ad4fcb73cfe9a1e4b710.js +1 -0
  26. package/assets/esri/core/workers/chunks/{a8a017d7969562d21d2e.js → b48aceaeefa07214e430.js} +1 -1
  27. package/assets/esri/core/workers/chunks/c1a4d1ec0125617374b4.js +1 -0
  28. package/assets/esri/core/workers/chunks/{d2a6f035022a3f060ffa.js → c320a29df40e85fb4a8e.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{52c8687b473c9953c2f2.js → d9958654c6438f28237b.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{27ec791318e81285c222.js → dca6a61fd239cf1ff90c.js} +1 -1
  31. package/assets/esri/core/workers/chunks/e66bcdfd75e0113d1cec.js +1 -0
  32. package/assets/esri/core/workers/chunks/f1381c5a2a1de1ef9139.js +1 -0
  33. package/assets/esri/core/workers/chunks/f21cb5b34d4d1e3af1a9.js +1 -0
  34. package/chunks/ChapmanAtmosphere.glsl.js +20 -20
  35. package/chunks/GaussianSplat.glsl.js +2 -2
  36. package/chunks/HUDMaterial.glsl.js +38 -38
  37. package/chunks/Haze.glsl.js +23 -23
  38. package/config.js +1 -1
  39. package/core/Collection.js +1 -1
  40. package/core/CollectionFlattener.js +1 -1
  41. package/core/arrayUtils.js +1 -1
  42. package/geometry/support/buffer/BufferView.js +1 -1
  43. package/geometry/support/curves/densifyCurvedGeometry.js +1 -1
  44. package/interfaces.d.ts +74 -0
  45. package/kernel.js +1 -1
  46. package/layers/ImageryTileLayer.js +1 -1
  47. package/layers/RouteLayer.js +1 -1
  48. package/layers/support/FeatureReductionCluster.js +1 -1
  49. package/layers/support/LabelClass.js +1 -1
  50. package/package.json +3 -3
  51. package/renderers/FlowRenderer.js +1 -1
  52. package/renderers/HeatmapRenderer.js +1 -1
  53. package/renderers/PieChartRenderer.js +1 -1
  54. package/rest/route/utils.js +1 -1
  55. package/rest/support/PointBarrier.js +1 -1
  56. package/rest/support/Stop.js +1 -1
  57. package/support/revision.js +1 -1
  58. package/support/tests/meshUtils.js +5 -0
  59. package/support/tests/serviceMockDependencies.js +5 -0
  60. package/support/tests/setupServiceMocksMesh.js +5 -0
  61. package/symbols/Font.js +1 -1
  62. package/symbols/IconSymbol3DLayer.js +1 -1
  63. package/symbols/LineSymbol.js +1 -1
  64. package/symbols/LineSymbol3DLayer.js +1 -1
  65. package/symbols/MarkerSymbol.js +1 -1
  66. package/symbols/PictureFillSymbol.js +1 -1
  67. package/symbols/PictureMarkerSymbol.js +1 -1
  68. package/symbols/TextSymbol.js +1 -1
  69. package/symbols/TextSymbol3DLayer.js +1 -1
  70. package/symbols/callouts/LineCallout3D.js +1 -1
  71. package/symbols/edges/Edges3D.js +1 -1
  72. package/symbols/support/Symbol3DIconOutline.js +1 -1
  73. package/symbols/support/Symbol3DOutline.js +1 -1
  74. package/symbols/support/Symbol3DVerticalOffset.js +1 -1
  75. package/views/2d/layers/RouteLayerView2D.js +1 -1
  76. package/views/2d/layers/support/RouteLayerInteraction.js +1 -1
  77. package/views/2d/layers/support/util.js +1 -1
  78. package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
  79. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  80. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  81. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
  82. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementShiftTool.js +1 -1
  83. package/views/3d/camera/intersectionUtils.js +1 -1
  84. package/views/3d/environment/ChapmanApproximation.glsl.js +8 -8
  85. package/views/3d/environment/ChapmanAtmosphere.glsl.js +1 -1
  86. package/views/3d/environment/ChapmanRaymarching.glsl.js +16 -15
  87. package/views/3d/layers/FlowSubView3D.js +1 -1
  88. package/views/3d/layers/PointCloudWorker.js +1 -1
  89. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  90. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  91. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  92. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  93. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  94. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  95. package/views/3d/state/NearFarHeuristic.js +1 -1
  96. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  97. package/views/3d/support/gaussianSplatting/GaussianSplatDataStore.js +1 -1
  98. package/views/3d/support/gaussianSplatting/GaussianSplatFadeHelper.js +1 -1
  99. package/views/3d/terrain/OverlayRenderer.js +1 -1
  100. package/views/3d/terrain/TerrainSurface.js +1 -1
  101. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +4 -4
  102. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +1 -1
  103. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +12 -12
  104. package/views/3d/webgl-engine/core/shaderLibrary/util/GaussianSplatUnpacking.glsl.js +8 -8
  105. package/views/3d/webgl-engine/lib/CutFillColor.js +1 -1
  106. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  107. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  108. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  109. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFieldCreation.js +5 -0
  110. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFields.js +1 -1
  111. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  112. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayoutField.js +5 -0
  113. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferUtils.js +5 -0
  114. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBuffer.js +5 -0
  115. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +5 -0
  116. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  117. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  118. package/views/BreakpointsOwner.js +1 -1
  119. package/views/ToolViewManager.js +1 -1
  120. package/views/View.js +1 -1
  121. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  122. package/views/draw/support/Reshape.js +1 -1
  123. package/views/interactive/InteractiveToolBase.js +1 -1
  124. package/views/interactive/ToolViewManagerManipulatorState.js +1 -1
  125. package/views/layers/GroupLayerView.js +1 -1
  126. package/views/support/Scheduler.js +1 -1
  127. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  128. package/widgets/ScaleRangeSlider.js +1 -1
  129. package/widgets/Slider.js +1 -1
  130. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  131. package/assets/esri/core/workers/chunks/1d877c3c96c40eab906c.js +0 -1
  132. package/assets/esri/core/workers/chunks/22f745539ca54d8cd30d.js +0 -1
  133. package/assets/esri/core/workers/chunks/42f3e83826b3a3dedaaa.js +0 -1
  134. package/assets/esri/core/workers/chunks/44471962c30344dfafdf.js +0 -1
  135. package/assets/esri/core/workers/chunks/8ca83a9af9d24b192128.js +0 -1
  136. package/assets/esri/core/workers/chunks/951a3442d4342539f2ea.js +0 -1
  137. package/assets/esri/core/workers/chunks/9527f1a611557a7af237.js +0 -1
  138. package/assets/esri/core/workers/chunks/ad3a4d139613b4c0e0b4.js +0 -1
  139. package/assets/esri/core/workers/chunks/c1c77a00f639eaee9c0d.js +0 -1
  140. package/assets/esri/core/workers/chunks/c5967133f3ba34a883f8.js +0 -1
  141. package/assets/esri/core/workers/chunks/c8d2cce4a426c72ab173.js +0 -1
  142. package/assets/esri/core/workers/chunks/e0a74250d22fa1d7dc18.js +0 -1
  143. package/assets/esri/core/workers/chunks/e3be67c762af672ec602.js +0 -1
  144. package/assets/esri/core/workers/chunks/eefad79be500667af96e.js +0 -1
  145. package/assets/esri/core/workers/chunks/f8caceeaa14d99c35526.js +0 -1
  146. package/assets/esri/core/workers/chunks/f919f0db9f9ec0c649b9.js +0 -1
  147. package/views/3d/webgl-engine/core/shaderLibrary/util/FastApproximateTrigonometry.glsl.js +0 -26
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../analysis/Viewshed.js";import{makeHandle as i}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{mapCollection as s}from"../../../../core/mapCollectionUtils.js";import{rad2deg as a}from"../../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{when as o,watch as l,syncAndInitial as r,sync as d,initial as c}from"../../../../core/reactiveUtils.js";import{property as h,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as m,H as g,h as v,k as w,g as _}from"../../../../chunks/vec32.js";import{create as V}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{fromPositionAndNormal as b,create as y,projectPoint as S}from"../../../../geometry/support/plane.js";import{creationVerticalOffset as T}from"./ViewshedConfiguration.js";import{ViewshedSubTool as C}from"./ViewshedSubTool.js";import{Manipulator3D as D}from"../../interactive/Manipulator3D.js";import{Settings as M}from"../../interactive/editingTools/settings.js";import{ExtendedLineVisualElement as H}from"../../interactive/visualElements/ExtendedLineVisualElement.js";import{LaserlineVisualElement as I}from"../../interactive/visualElements/LaserlineVisualElement.js";import{toGraphic as P}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{AnalysisToolBase as j}from"../../../interactive/AnalysisToolBase.js";import{sketchKeys as E}from"../../../interactive/keybindings.js";import{newToolIntersector as k}from"../../../interactive/ToolIntersector.js";import{createScreenPointArrayFromEvent as L}from"../../../support/screenUtils.js";const W=Symbol("interactionVisuals");let x=class extends j{constructor(e){super(e),this.removeIncompleteOnCancel=!1,this.automaticManipulatorSelection=!1,this._stagedViewshed=null,this._stagedViewshedComputedData=null,this._placementMode=G,this._creationState=!1,this._interactionVisualElements=null,this._settings=new M({getTheme:()=>this.view.effectiveTheme}),this._selectedManipulator=null}initialize(){this._intersector=k(this.view.state.viewingMode),this._createInteractionVisuals();const e=this.analysisViewData.viewshedComputedDataHandles;this.subToolHandles=s(()=>e,({viewshedComputedData:e})=>{const t=new C({analysis:this.analysis,analysisViewData:this.analysisViewData,parentTool:this,view:this.view,viewshedComputedData:e});return{subTool:t,remove:()=>{this.selectedViewshed===e.viewshed&&(this.selectedViewshed=null),t.destroy()}}}),this.addHandles([o(()=>this._valid,()=>this.finishToolCreation(),r),l(()=>this._stagedViewshed,e=>{const t=this.analysisViewData.viewshedComputedDataHandles;this._stagedViewshedComputedData=null!=e&&null!=t?this._findSubTool(e)?.viewshedComputedData:null},r),this.analysis.viewsheds.on("after-remove",e=>{const t=this._stagedViewshed;null!=t&&e.item===t&&this.analysis.viewsheds.add(t)}),l(()=>this.firstGrabbedManipulator,e=>{if(null!=e){const t=this._findSubTool(e)?.viewshed;this.selectedViewshed=t,this._selectManipulator(e)}else this._selectedSubTool?.onManipulatorSelectionChanged()},d),l(()=>this.view.activeTool,e=>{e!==this&&null!=e&&(this.selectedViewshed=null)}),o(()=>{const e=this.selectedViewshedComputedData;return null==e?null:{subTool:this._selectedSubTool,observer:e.observerRenderSpace,target:e.targetRenderSpace}},e=>{const{subTool:t,observer:i,target:s}=e;t?.moveInteractionState.dragging?this._updateInteractionVisualsLocation(i,!0):t?.scaleOrientInteractionState.dragging&&this._updateInteractionVisualsLocation(s,!1)},c),l(()=>this.creating,()=>this.updateInteractionVisualsVisibility()),l(()=>this.selectedViewshed,e=>{const t=this._selectedManipulator,i=this._selectedSubTool;null==e?this._selectManipulator(null):null!=t&&i.hasManipulator(t)||this._selectManipulator(i.discManipulator)},c)])}destroy(){this.subToolHandles=n(this.subToolHandles),this.removeHandles(W)}onDeactivate(){this.removeStaged(),this._creationState=!1}get _valid(){return this.analysisViewData.viewshedComputedDataHandles?.some(e=>e.viewshedComputedData.valid)??!1}get cursor(){return this.creating?"crosshair":null}get _selectedSubTool(){return this._findSubTool(this.selectedViewshed)}_selectManipulator(e){const t=this._selectedManipulator;t!==e&&(this._selectedManipulator=e,null!=t&&(t.selected=!1),null!=e&&(e.selected=!0),this._findSubTool(t)?.onManipulatorSelectionChanged(),this._selectedSubTool?.onManipulatorSelectionChanged())}get selectedViewshed(){return this.analysisViewData.selectedViewshed}set selectedViewshed(e){this.analysisViewData.selectedViewshed=e}get selectedViewshedComputedData(){return this._selectedSubTool?.viewshedComputedData}get stagedViewshed(){return this._stagedViewshed}get grabbing(){return this.subToolHandles.some(({subTool:e})=>e.grabbing)}get creating(){return this._creationState&&this.active}get isPlacingTarget(){return"placing-target"===this._creationState}place(e){this.selectedViewshed=null,this._placementMode=e,this._creationState="placing-observer",this._finishToolCreationIfValid()}onManipulatorSelectionChanged(){this.subToolHandles.forEach(e=>e.subTool.onManipulatorSelectionChanged())}onInputEvent(e){switch(e.type){case"immediate-double-click":this._doubleClickHandler(e);break;case"pointer-move":this._pointerMoveHandler(e);break;case"key-down":E.cancel===e.key?this._cancelKeyHandler(e):E.delete.includes(e.key)&&this._deleteKeyHandler();break;case"hold":this.updateInteractionVisualsVisibility(!0)}}onInputEventAfter(e){if("immediate-click"===e.type)this._clickPlacementHandler(e)}onActivate(){this._placementMode=G}_clickPlacementHandler(e){if(!this.creating||this.hasFocusedManipulators)return;const i=this._intersectScreen(e,B);if(null!=i){if("placing-observer"===this._creationState){i.mapPoint.z=(i.mapPoint.z??0)+T;const e=new t({observer:i.mapPoint.clone(),feature:i.feature});this.analysis.viewsheds.add(e),this._stagedViewshed=e,this._creationState="placing-target",this._updateStagedViewshed(i.scenePoint)}else if("placing-target"===this._creationState){this._updateStagedViewshed(i.scenePoint);const e=this._stagedViewshed;this._stagedViewshed=null,"multiple"===this._placementMode?this._creationState="placing-observer":(this._creationState=!1,this._stagedViewshed=null,this._finishToolCreationIfValid(),this.view.activeTool=null),this.selectedViewshed=e}e.stopPropagation()}}_doubleClickHandler(e){this.creating&&(this.removeStaged(),this._creationState=!1,this.view.activeTool=null,e.stopPropagation())}_pointerMoveHandler(e){if(!this.creating)return;const t=this._intersectScreen(e,B);null!=t&&(this._updateInteractionVisualsLocation(t.scenePoint,!1),this._updateStagedViewshed(t.scenePoint))}_cancelKeyHandler(e){this.creating?this._onCancelWhileCreating(e):this.grabbing||(this.selectedViewshed=null,e.stopPropagation())}_onCancelWhileCreating(e){const t=this.removeStaged();this._finishToolCreationIfValid(),t?(this._creationState="placing-observer",this.selectedViewshed=null,"multiple"===this._placementMode&&e.stopPropagation()):this._creationState=!1}_deleteKeyHandler(){this.creating&&(this.removeStaged(),this._creationState="placing-observer"),null!=this.selectedViewshed&&this.analysis.viewsheds.remove(this.selectedViewshed)}_finishToolCreationIfValid(){this._valid&&this.finishToolCreation()}_updateStagedViewshed(e){const t=this._stagedViewshed,i=this._stagedViewshedComputedData;if(null==t||null==i)return;const{heading:s,tilt:a,farDistance:n}=O(this.view,i,e);t.farDistance=n,t.tilt=a,t.heading=s}removeStaged(){const e=this._stagedViewshed;return null!=e&&(this._stagedViewshed=null,this.analysis.viewsheds.remove(e),!0)}_intersectScreen(e,t){const i=L(e);this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(i,this._intersector);const s=this._intersector.results.min,a=t.scenePoint;if(!s.getIntersectionPoint(a))return null;const n=t.mapPoint;return n.spatialReference=this.view.spatialReference,this.view.renderCoordsHelper.fromRenderCoords(a,n),null==n?null:(t.feature=P(s,this.view),t)}_createInteractionVisuals(){this.removeHandles(W);const e=this._settings.visualElements,t=new I({view:this.view,attached:!1,style:{glowWidth:e.heightPlane.glowWidth,innerWidth:e.heightPlane.innerWidth},isDecoration:!0}),s=new H({view:this.view,extensionType:e.zVerticalLine.extensionType,attached:!1,innerWidth:1,writeDepthEnabled:!1,renderOccluded:4,isDecoration:!0});this._interactionVisualElements={laserline:t,verticalLine:s},this.addHandles([l(()=>e.zVerticalLine,e=>e.apply(s),r),l(()=>e.heightPlane,e=>e.apply(t),r),i(()=>{t.destroy(),s.destroy(),this._interactionVisualElements=null})],W)}updateInteractionVisualsVisibility(e=!1){const t=this.creating,i=this.analysisViewData.visible,s=this._selectedSubTool,a=this.selectedViewshedComputedData,n=(e,t)=>{const i=this._interactionVisualElements;null!=i&&(i.verticalLine.attached=t,i.laserline.attached=e)};if(t)return void n(i,!1);if(null==s||null==a)return void n(!1,!1);const o=s.moveInteractionState,l=e?o.grabbing:o.dragging,r=s.scaleOrientInteractionState,d=e?r.grabbing:r.dragging,c=i&&(l||d);if(n(c,l),c){const e=l?a.observerRenderSpace:a.targetRenderSpace;this._updateInteractionVisualsLocation(e,l)}}_updateInteractionVisualsLocation(e,t){const i=this._interactionVisualElements;if(null==i)return;const{laserline:s,verticalLine:a}=i;s.heightManifoldTarget=e,s.intersectsWorldUpAtLocation=t?e:null,null!=e&&a.setStartEndFromWorldDownAtLocation(e)}_findSubTool(e){if(null==e)return null;const t=e instanceof D?t=>t.subTool.hasManipulator(e):t=>t.subTool.viewshed===e;return this.subToolHandles?.find(t)?.subTool}get test(){}};function O(e,t,i){const s=t.observerRenderSpace,n=m(R,i,s),o=g(n)*t.metersPerUnit,l=e.renderCoordsHelper.basisMatrixAtPosition(s,K),r=v(U,l[8],l[9],l[10]),d=b(s,r,F),c=S(d,i,A),h=m(c,c,s),u=(g(h)<1e-4?90:a(w(n,h)))*(_(r,n)<0?-1:1)+90,p=v(z,l[4],l[5],l[6]),V=a(w(p,h)),f=v(z,l[0],l[1],l[2]);return{heading:_(h,f)<0?360-V:V,tilt:u,farDistance:o}}e([h({constructOnly:!0})],x.prototype,"view",void 0),e([h()],x.prototype,"analysisViewData",void 0),e([h()],x.prototype,"removeIncompleteOnCancel",void 0),e([h()],x.prototype,"automaticManipulatorSelection",void 0),e([h({constructOnly:!0})],x.prototype,"analysis",void 0),e([h()],x.prototype,"subToolHandles",void 0),e([h()],x.prototype,"_stagedViewshed",void 0),e([h()],x.prototype,"_stagedViewshedComputedData",void 0),e([h()],x.prototype,"_placementMode",void 0),e([h()],x.prototype,"_creationState",void 0),e([h()],x.prototype,"_valid",null),e([h({readOnly:!0})],x.prototype,"cursor",null),e([h()],x.prototype,"_selectedManipulator",void 0),e([h()],x.prototype,"_selectedSubTool",null),e([h()],x.prototype,"selectedViewshed",null),e([h()],x.prototype,"selectedViewshedComputedData",null),e([h()],x.prototype,"stagedViewshed",null),e([h()],x.prototype,"grabbing",null),e([h()],x.prototype,"creating",null),e([h()],x.prototype,"isPlacingTarget",null),x=e([u("esri.views.3d.analysis.Viewshed.ViewshedTool")],x);const R=V(),U=V(),A=V(),z=V(),K=p(),F=y(),B={mapPoint:new f,scenePoint:V(),feature:null},G="multiple";export{x as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../../analysis/Viewshed.js";import{makeHandle as i}from"../../../../core/handleUtils.js";import"../../../../core/has.js";import{mapCollection as s}from"../../../../core/mapCollectionUtils.js";import{rad2deg as a}from"../../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{when as o,watch as l,syncAndInitial as r,sync as d,initial as c}from"../../../../core/reactiveUtils.js";import{property as h,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{a as m,H as g,h as v,k as w,g as _}from"../../../../chunks/vec32.js";import{create as V}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import f from"../../../../geometry/Point.js";import{fromPositionAndNormal as b,create as y,projectPoint as S}from"../../../../geometry/support/plane.js";import{creationVerticalOffset as T}from"./ViewshedConfiguration.js";import{ViewshedSubTool as C}from"./ViewshedSubTool.js";import{Manipulator3D as D}from"../../interactive/Manipulator3D.js";import{Settings as M}from"../../interactive/editingTools/settings.js";import{ExtendedLineVisualElement as H}from"../../interactive/visualElements/ExtendedLineVisualElement.js";import{LaserlineVisualElement as I}from"../../interactive/visualElements/LaserlineVisualElement.js";import{toGraphic as P}from"../../webgl-engine/lib/intersectorUtilsConversions.js";import{AnalysisToolBase as j}from"../../../interactive/AnalysisToolBase.js";import{sketchKeys as E}from"../../../interactive/keybindings.js";import{newToolIntersector as k}from"../../../interactive/ToolIntersector.js";import{createScreenPointArrayFromEvent as L}from"../../../support/screenUtils.js";const W=Symbol("interactionVisuals");let x=class extends j{constructor(e){super(e),this.removeIncompleteOnCancel=!1,this.automaticManipulatorSelection=!1,this.multiTouchEnabled=!1,this._stagedViewshed=null,this._stagedViewshedComputedData=null,this._placementMode=G,this._creationState=!1,this._interactionVisualElements=null,this._settings=new M({getTheme:()=>this.view.effectiveTheme}),this._selectedManipulator=null}initialize(){this._intersector=k(this.view.state.viewingMode),this._createInteractionVisuals();const e=this.analysisViewData.viewshedComputedDataHandles;this.subToolHandles=s(()=>e,({viewshedComputedData:e})=>{const t=new C({analysis:this.analysis,analysisViewData:this.analysisViewData,parentTool:this,view:this.view,viewshedComputedData:e});return{subTool:t,remove:()=>{this.selectedViewshed===e.viewshed&&(this.selectedViewshed=null),t.destroy()}}}),this.addHandles([o(()=>this._valid,()=>this.finishToolCreation(),r),l(()=>this._stagedViewshed,e=>{const t=this.analysisViewData.viewshedComputedDataHandles;this._stagedViewshedComputedData=null!=e&&null!=t?this._findSubTool(e)?.viewshedComputedData:null},r),this.analysis.viewsheds.on("after-remove",e=>{const t=this._stagedViewshed;null!=t&&e.item===t&&this.analysis.viewsheds.add(t)}),l(()=>this.firstGrabbedManipulator,e=>{if(null!=e){const t=this._findSubTool(e)?.viewshed;this.selectedViewshed=t,this._selectManipulator(e)}else this._selectedSubTool?.onManipulatorSelectionChanged()},d),l(()=>this.view.activeTool,e=>{e!==this&&null!=e&&(this.selectedViewshed=null)}),o(()=>{const e=this.selectedViewshedComputedData;return null==e?null:{subTool:this._selectedSubTool,observer:e.observerRenderSpace,target:e.targetRenderSpace}},e=>{const{subTool:t,observer:i,target:s}=e;t?.moveInteractionState.dragging?this._updateInteractionVisualsLocation(i,!0):t?.scaleOrientInteractionState.dragging&&this._updateInteractionVisualsLocation(s,!1)},c),l(()=>this.creating,()=>this.updateInteractionVisualsVisibility()),l(()=>this.selectedViewshed,e=>{const t=this._selectedManipulator,i=this._selectedSubTool;null==e?this._selectManipulator(null):null!=t&&i.hasManipulator(t)||this._selectManipulator(i.discManipulator)},c)])}destroy(){this.subToolHandles=n(this.subToolHandles),this.removeHandles(W)}onDeactivate(){this.removeStaged(),this._creationState=!1}get _valid(){return this.analysisViewData.viewshedComputedDataHandles?.some(e=>e.viewshedComputedData.valid)??!1}get cursor(){return this.creating?"crosshair":null}get _selectedSubTool(){return this._findSubTool(this.selectedViewshed)}_selectManipulator(e){const t=this._selectedManipulator;t!==e&&(this._selectedManipulator=e,null!=t&&(t.selected=!1),null!=e&&(e.selected=!0),this._findSubTool(t)?.onManipulatorSelectionChanged(),this._selectedSubTool?.onManipulatorSelectionChanged())}get selectedViewshed(){return this.analysisViewData.selectedViewshed}set selectedViewshed(e){this.analysisViewData.selectedViewshed=e}get selectedViewshedComputedData(){return this._selectedSubTool?.viewshedComputedData}get stagedViewshed(){return this._stagedViewshed}get grabbing(){return this.subToolHandles.some(({subTool:e})=>e.grabbing)}get creating(){return this._creationState&&this.active}get isPlacingTarget(){return"placing-target"===this._creationState}place(e){this.selectedViewshed=null,this._placementMode=e,this._creationState="placing-observer",this._finishToolCreationIfValid()}onManipulatorSelectionChanged(){this.subToolHandles.forEach(e=>e.subTool.onManipulatorSelectionChanged())}onInputEvent(e){switch(e.type){case"immediate-double-click":this._doubleClickHandler(e);break;case"pointer-move":this._pointerMoveHandler(e);break;case"key-down":E.cancel===e.key?this._cancelKeyHandler(e):E.delete.includes(e.key)&&this._deleteKeyHandler();break;case"hold":this.updateInteractionVisualsVisibility(!0)}}onInputEventAfter(e){if("immediate-click"===e.type)this._clickPlacementHandler(e)}onActivate(){this._placementMode=G}_clickPlacementHandler(e){if(!this.creating||this.hasFocusedManipulators)return;const i=this._intersectScreen(e,B);if(null!=i){if("placing-observer"===this._creationState){i.mapPoint.z=(i.mapPoint.z??0)+T;const e=new t({observer:i.mapPoint.clone(),feature:i.feature});this.analysis.viewsheds.add(e),this._stagedViewshed=e,this._creationState="placing-target",this._updateStagedViewshed(i.scenePoint)}else if("placing-target"===this._creationState){this._updateStagedViewshed(i.scenePoint);const e=this._stagedViewshed;this._stagedViewshed=null,"multiple"===this._placementMode?this._creationState="placing-observer":(this._creationState=!1,this._stagedViewshed=null,this._finishToolCreationIfValid(),this.view.activeTool=null),this.selectedViewshed=e}e.stopPropagation()}}_doubleClickHandler(e){this.creating&&(this.removeStaged(),this._creationState=!1,this.view.activeTool=null,e.stopPropagation())}_pointerMoveHandler(e){if(!this.creating)return;const t=this._intersectScreen(e,B);null!=t&&(this._updateInteractionVisualsLocation(t.scenePoint,!1),this._updateStagedViewshed(t.scenePoint))}_cancelKeyHandler(e){this.creating?this._onCancelWhileCreating(e):this.grabbing||(this.selectedViewshed=null,e.stopPropagation())}_onCancelWhileCreating(e){const t=this.removeStaged();this._finishToolCreationIfValid(),t?(this._creationState="placing-observer",this.selectedViewshed=null,"multiple"===this._placementMode&&e.stopPropagation()):this._creationState=!1}_deleteKeyHandler(){this.creating&&(this.removeStaged(),this._creationState="placing-observer"),null!=this.selectedViewshed&&this.analysis.viewsheds.remove(this.selectedViewshed)}_finishToolCreationIfValid(){this._valid&&this.finishToolCreation()}_updateStagedViewshed(e){const t=this._stagedViewshed,i=this._stagedViewshedComputedData;if(null==t||null==i)return;const{heading:s,tilt:a,farDistance:n}=O(this.view,i,e);t.farDistance=n,t.tilt=a,t.heading=s}removeStaged(){const e=this._stagedViewshed;return null!=e&&(this._stagedViewshed=null,this.analysis.viewsheds.remove(e),!0)}_intersectScreen(e,t){const i=L(e);this.view.sceneIntersectionHelper.intersectToolIntersectorScreen(i,this._intersector);const s=this._intersector.results.min,a=t.scenePoint;if(!s.getIntersectionPoint(a))return null;const n=t.mapPoint;return n.spatialReference=this.view.spatialReference,this.view.renderCoordsHelper.fromRenderCoords(a,n),null==n?null:(t.feature=P(s,this.view),t)}_createInteractionVisuals(){this.removeHandles(W);const e=this._settings.visualElements,t=new I({view:this.view,attached:!1,style:{glowWidth:e.heightPlane.glowWidth,innerWidth:e.heightPlane.innerWidth},isDecoration:!0}),s=new H({view:this.view,extensionType:e.zVerticalLine.extensionType,attached:!1,innerWidth:1,writeDepthEnabled:!1,renderOccluded:4,isDecoration:!0});this._interactionVisualElements={laserline:t,verticalLine:s},this.addHandles([l(()=>e.zVerticalLine,e=>e.apply(s),r),l(()=>e.heightPlane,e=>e.apply(t),r),i(()=>{t.destroy(),s.destroy(),this._interactionVisualElements=null})],W)}updateInteractionVisualsVisibility(e=!1){const t=this.creating,i=this.analysisViewData.visible,s=this._selectedSubTool,a=this.selectedViewshedComputedData,n=(e,t)=>{const i=this._interactionVisualElements;null!=i&&(i.verticalLine.attached=t,i.laserline.attached=e)};if(t)return void n(i,!1);if(null==s||null==a)return void n(!1,!1);const o=s.moveInteractionState,l=e?o.grabbing:o.dragging,r=s.scaleOrientInteractionState,d=e?r.grabbing:r.dragging,c=i&&(l||d);if(n(c,l),c){const e=l?a.observerRenderSpace:a.targetRenderSpace;this._updateInteractionVisualsLocation(e,l)}}_updateInteractionVisualsLocation(e,t){const i=this._interactionVisualElements;if(null==i)return;const{laserline:s,verticalLine:a}=i;s.heightManifoldTarget=e,s.intersectsWorldUpAtLocation=t?e:null,null!=e&&a.setStartEndFromWorldDownAtLocation(e)}_findSubTool(e){if(null==e)return null;const t=e instanceof D?t=>t.subTool.hasManipulator(e):t=>t.subTool.viewshed===e;return this.subToolHandles?.find(t)?.subTool}get test(){}};function O(e,t,i){const s=t.observerRenderSpace,n=m(R,i,s),o=g(n)*t.metersPerUnit,l=e.renderCoordsHelper.basisMatrixAtPosition(s,K),r=v(U,l[8],l[9],l[10]),d=b(s,r,F),c=S(d,i,A),h=m(c,c,s),u=(g(h)<1e-4?90:a(w(n,h)))*(_(r,n)<0?-1:1)+90,p=v(z,l[4],l[5],l[6]),V=a(w(p,h)),f=v(z,l[0],l[1],l[2]);return{heading:_(h,f)<0?360-V:V,tilt:u,farDistance:o}}e([h({constructOnly:!0})],x.prototype,"view",void 0),e([h()],x.prototype,"analysisViewData",void 0),e([h()],x.prototype,"removeIncompleteOnCancel",void 0),e([h()],x.prototype,"automaticManipulatorSelection",void 0),e([h()],x.prototype,"multiTouchEnabled",void 0),e([h({constructOnly:!0})],x.prototype,"analysis",void 0),e([h()],x.prototype,"subToolHandles",void 0),e([h()],x.prototype,"_stagedViewshed",void 0),e([h()],x.prototype,"_stagedViewshedComputedData",void 0),e([h()],x.prototype,"_placementMode",void 0),e([h()],x.prototype,"_creationState",void 0),e([h()],x.prototype,"_valid",null),e([h({readOnly:!0})],x.prototype,"cursor",null),e([h()],x.prototype,"_selectedManipulator",void 0),e([h()],x.prototype,"_selectedSubTool",null),e([h()],x.prototype,"selectedViewshed",null),e([h()],x.prototype,"selectedViewshedComputedData",null),e([h()],x.prototype,"stagedViewshed",null),e([h()],x.prototype,"grabbing",null),e([h()],x.prototype,"creating",null),e([h()],x.prototype,"isPlacingTarget",null),x=e([u("esri.views.3d.analysis.Viewshed.ViewshedTool")],x);const R=V(),U=V(),A=V(),z=V(),K=p(),F=y(),B={mapPoint:new f,scenePoint:V(),feature:null},G="multiple";export{x 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../Color.js";import{onLocaleChange as i,substitute as s,fetchMessageBundle as o}from"../../../../intl.js";import{volumeMeasurementConfiguration as r}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import l from"../../../../core/Accessor.js";import{equals as n}from"../../../../core/arrayUtils.js";import{cyclicalPI as a}from"../../../../core/Cyclical.js";import{destroyMaybe as c}from"../../../../core/maybe.js";import{formatDecimal as u}from"../../../../core/quantityFormatUtils.js";import{watch as m,initial as d}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as h}from"../../../../core/units.js";import{property as p,subclass as g}from"../../../../core/accessorSupport/decorators.js";import{e as y}from"../../../../chunks/earcut.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as f,n as v,e as j,f as L,g as b}from"../../../../chunks/vec32.js";import{create as C,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as G}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as P}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as V}from"../../../../geometry/support/Indices.js";import{angleAroundAxis as R}from"../../../../geometry/support/vector.js";import{t as F}from"../../../../chunks/vec3.js";import A from"../../../../symbols/support/ElevationInfo.js";import{LabelVisualElement as O}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as x}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as D}from"../../interactive/visualElements/OutlineVisualElement.js";import{EuclideanSegment as M}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as S}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as U}from"../../layers/graphics/Graphics3DExtrudeSymbolLayer.js";import{polygonToRenderInfo as E}from"../../support/renderInfoUtils/polygon.js";import{CutFillColor as B,VolumeGeometry as N}from"../../webgl-engine/lib/CutFillColor.js";import{createStipplePatternSimple as H}from"../../webgl-engine/materials/lineStippleUtils.js";let T=class extends l{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get updating(){return this.loadingMessages}get hasUnsupportedError(){const{error:e}=this.analysisViewData;return!!e&&["unsupported-coordinate-system","unsupported-layer-transparency"].includes(e.name)}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._elevationContext=S.fromElevationInfo(new A({mode:"absolute-height"})),this._extrusionHeight=r.targetElevationRange,this._projectionLines=[]}initialize(){const{view:e}=this,s={view:e,isDecoration:!0},o=r,l={...s,width:o.geometryOutlineWidth};this._elevationAlignedGeometry=new D({...l,isDraped:!0,color:t.toUnitRGBA(o.geometryOutlineColor)}),this._targetGeometry=new D(l);const n={...s,attached:!0,width:o.projectionLineWidth,renderOccluded:4,polygonOffset:!0},a={...n,stipplePattern:H(o.projectionLineStippleSize)},c=t.toUnitRGBA(o.cutProjectionLineColor),u=t.toUnitRGBA(o.fillProjectionLineColor);this._cutProjectionLines=new x({...n,color:c}),this._occludedCutProjectionLines=new x({...a,color:c}),this._fillProjectionLines=new x({...n,color:u}),this._occludedFillProjectionLines=new x({...a,color:u});const h={...s,attached:!0};this._cutVolumeLabel=new O(h),this._fillVolumeLabel=new O(h),this._cutFillRenderNode=new B({view:e,cutColor:o.cutColor,fillColor:o.fillColor,borderColor:o.geometryOutlineColor}),this.addHandles([m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry}),({elevationAlignedGeometry:e,targetGeometry:t})=>{this._elevationAlignedGeometry.geometry=e,this._targetGeometry.geometry=t},d),m(()=>({interactive:this.analysisViewData.interactive,measureType:this.analysis.measureType,visible:this.visible}),({visible:e,interactive:t,measureType:i})=>{this._elevationAlignedGeometry.visible=e&&!t,this._targetGeometry.visible=e&&"cut-fill"===i},d),m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry,visible:this.visible}),({elevationAlignedGeometry:e,targetGeometry:t,visible:i})=>this._updateProjectionLines(e,t,i),d),m(()=>({interactive:this.analysisViewData.interactive,accentColor:this.view.effectiveTheme.accentColor,hasResult:!!this.analysisViewData.result}),({interactive:e,accentColor:t,hasResult:i})=>{this._updateColors(e,t,i)},d),m(()=>this.analysisViewData.targetGeometry,()=>this._updateCutFillGeometry(),d),m(()=>this.visible&&!this.hasUnsupportedError,e=>this._updateCutFillVisibility(e),d),m(()=>{const{messages:e,unitsMessages:t,visible:i,analysisViewData:s}=this;return{labelAnchors:s.labelAnchors,effectiveDisplayUnits:s.effectiveDisplayUnits,messages:e,unitsMessages:t,result:s.result,visible:i&&!!s.result}},e=>this._updateLabels(e)),m(()=>this.view.state.camera,e=>this._updateProjectionLineOcclusion(e),d),i(()=>this._updateMessageBundle())]),this._updateMessageBundle()}destroy(){this._elevationAlignedGeometry=c(this._elevationAlignedGeometry),this._targetGeometry=c(this._targetGeometry),this._cutProjectionLines=c(this._cutProjectionLines),this._occludedCutProjectionLines=c(this._occludedCutProjectionLines),this._fillProjectionLines=c(this._fillProjectionLines),this._occludedFillProjectionLines=c(this._occludedFillProjectionLines),this._cutVolumeLabel=c(this._cutVolumeLabel),this._fillVolumeLabel=c(this._fillVolumeLabel),this._cutFillRenderNode.destroy()}_updateProjectionLines(e,t,i){if(this._cutProjectionLines.visible=i,this._occludedCutProjectionLines.visible=i,this._fillProjectionLines.visible=i,this._occludedFillProjectionLines.visible=i,!e||!t)return;const{renderCoordsHelper:s}=this.view,o=[],r=e.spatialReference,l=e.rings[0],a=l.length>1&&n(l[0],l[l.length-1]),c=l.length-(a?1:0);for(let n=0;n<c;++n){const e=l[n],i=f(C(),e[0],e[1],e[2]);s.toRenderCoords(i,r,i);const a=t.rings[0][n],c=f(C(),a[0],a[1],a[2]);s.toRenderCoords(c,r,c);const u=new M(i,c);o.push(u)}e.isClockwise(l)||o.reverse();const u=[],m=[],d=[],h=[],p=[],g=this.view.state.camera;for(let n=0;n<o.length;++n){const i=o[n],s=o[0===n?o.length-1:n-1],r=o[n===o.length-1?0:n+1],l=e.rings[0][n],a=t.rings[0][n],c=l[2]>a[2],y=new k(i,s,r,c);u.push(y),y.updateOccluded(g);const _=y.isOccluded;c?(_?d:m).push(i):(_?p:h).push(i)}this._projectionLines=u,this._cutProjectionLines.setGeometryFromSegments(m),this._occludedCutProjectionLines.setGeometryFromSegments(d),this._fillProjectionLines.setGeometryFromSegments(h),this._occludedFillProjectionLines.setGeometryFromSegments(p)}_updateProjectionLineOcclusion(e){const t=[],i=[],s=[],o=[];let r=!1,l=!1;for(const n of this._projectionLines){n.updateOccluded(e)&&(r||=n.isCut,l||=!n.isCut);const a=n.isOccluded;(n.isCut?a?i:t:a?o:s).push(n.segment)}l&&(this._fillProjectionLines.setGeometryFromSegments(s),this._occludedFillProjectionLines.setGeometryFromSegments(o)),r&&(this._cutProjectionLines.setGeometryFromSegments(t),this._occludedCutProjectionLines.setGeometryFromSegments(i))}_updateColors(e,i,s){const{geometryOutlineColor:o,cutColor:l,fillColor:n,cutColorMuted:a,fillColorMuted:c,cutProjectionLineColor:u,fillProjectionLineColor:m}=r;if(this._cutFillRenderNode.cutColor=s?l:a,this._cutFillRenderNode.fillColor=s?n:c,e){const e=t.toUnitRGBA(i);this._targetGeometry.color=e,this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e,this._fillProjectionLines.color=e,this._occludedFillProjectionLines.color=e,this._cutFillRenderNode.borderColor=i}else{this._targetGeometry.color=t.toUnitRGBA(o);const e=t.toUnitRGBA(s?u:a);this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e;const i=t.toUnitRGBA(s?m:c);this._fillProjectionLines.color=i,this._occludedFillProjectionLines.color=i,this._cutFillRenderNode.borderColor=o}}_updateLabels(e){const{labelDistance:t}=r,{effectiveDisplayUnits:i,labelAnchors:o,messages:l,unitsMessages:n,result:a,visible:c}=e;if(this._cutVolumeLabel.visible=c,this._fillVolumeLabel.visible=c,this._cutVolumeLabel.geometry=o.cut?{type:"point",point:o.cut,callout:{distance:t,offset:0}}:null,this._fillVolumeLabel.geometry=o.fill?{type:"point",point:o.fill,callout:{distance:-t,offset:0}}:null,null==a||null==l||null==n)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const u=i.volume,m=s(l.labels.cut,{volume:I(n,a.cutVolume,u)}),d=s(l.labels.fill,{volume:I(n,a.fillVolume,u)});this._cutVolumeLabel.text=m,this._fillVolumeLabel.text=d}_updateCutFillVisibility(e){e?this._cutFillRenderNode.enable():this._cutFillRenderNode.disable()}_updateCutFillGeometry(){const{renderCoordsHelper:e}=this.view,{targetGeometry:t}=this.analysisViewData;if(!t?.extent)return;const{center:i}=t.extent,s=w(i.x,i.y,0),o=C();e.toRenderCoords(s,t.spatialReference,o);const r=this._getExtrudedVolumes(t,this._extrusionHeight,s),l=this._getExtrudedVolumes(t,-this._extrusionHeight,s);this._cutFillRenderNode.updateGeometries(r,l,o)}_getExtrudedVolumes(e,t,i){const{renderCoordsHelper:s,spatialReference:o,elevationProvider:r}=this.view,l=C(),n=1===s.viewingMode;n||s.worldUpAtPosition([0,0,0],l);const a=E(e,r,s,this._elevationContext),{polygons:c,mapPositions:u,position:m}=a,d=c[0],h=d.count,p=y(d.mapPositions,d.holeIndices,3),g=p.length,f=6*h,v=V(f+g),j=V(g),L=P(3*f),b=P(3*f);U(m,u,p,d,L,null,b,null,v,j,t,l,n);const w=_(),R=_();return G(o,i,w,s.spatialReference),R[12]=-w[12],R[13]=-w[13],R[14]=-w[14],F(L,L,R),new N(L,j,v,b)}async _updateMessageBundle(){this.loadingMessages=!0;try{this.unitsMessages=await o("esri/core/t9n/Units"),this.messages=await o("esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis")}finally{this.loadingMessages=!1}}};function I(e,t,i){if(!t||!e)return null;const s=h(t.value,t.unit,i),o=r.labelPrecisions[s];return u(e,t,s,o)}e([p({constructOnly:!0})],T.prototype,"view",void 0),e([p({constructOnly:!0})],T.prototype,"analysis",void 0),e([p({constructOnly:!0})],T.prototype,"analysisViewData",void 0),e([p()],T.prototype,"unitsMessages",void 0),e([p()],T.prototype,"messages",void 0),e([p()],T.prototype,"loadingMessages",void 0),e([p({readOnly:!0})],T.prototype,"visible",null),e([p()],T.prototype,"updating",null),e([p()],T.prototype,"hasUnsupportedError",null),T=e([g("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],T);class k{constructor(e,t,i,s){this.segment=e,this.previous=t,this.next=i,this.isCut=s,this._isOccluded=!1,this._n1=C(),this._n2=C();const o=v(z,j(z,e.endRenderSpace,e.startRenderSpace));v(this._n1,L(this._n1,o,v(W,j(W,t.startRenderSpace,e.startRenderSpace)))),v(this._n2,L(this._n2,o,v(W,j(W,e.startRenderSpace,i.startRenderSpace)))),this._isConvex=a.normalize(R(this._n1,this._n2,o))<0}get isOccluded(){return this._isOccluded}updateOccluded(e){j(z,this.segment.startRenderSpace,e.eye);const t=b(this._n1,z)<0,i=b(this._n2,z)<0,s=this._isOccluded;return this._isOccluded=this._isConvex?t&&i:t||i,this._isOccluded!==s}}const z=C(),W=C();export{T as VolumeMeasurementCutFillVisualization};
5
+ import{__decorate as e}from"tslib";import t from"../../../../Color.js";import{onLocaleChange as i,substitute as s,fetchMessageBundle as o}from"../../../../intl.js";import{volumeMeasurementConfiguration as r}from"../../../../analysis/VolumeMeasurement/volumeMeasurementConfiguration.js";import l from"../../../../core/Accessor.js";import{equals as n}from"../../../../core/arrayUtils.js";import{cyclicalPI as a}from"../../../../core/Cyclical.js";import{destroyMaybe as c}from"../../../../core/maybe.js";import{formatDecimal as u}from"../../../../core/quantityFormatUtils.js";import{watch as m,initial as d}from"../../../../core/reactiveUtils.js";import{adaptiveVolumeUnit as h}from"../../../../core/units.js";import{property as p,subclass as y}from"../../../../core/accessorSupport/decorators.js";import{e as g}from"../../../../chunks/earcut.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as f,n as v,e as j,f as L,g as b}from"../../../../chunks/vec32.js";import{create as C,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as G}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{newDoubleArray as P}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as V}from"../../../../geometry/support/Indices.js";import{angleAroundAxis as R}from"../../../../geometry/support/vector.js";import{t as F}from"../../../../chunks/vec3.js";import A from"../../../../symbols/support/ElevationInfo.js";import{LabelVisualElement as O}from"../../interactive/visualElements/LabelVisualElement.js";import{LineVisualElement as x}from"../../interactive/visualElements/LineVisualElement.js";import{OutlineVisualElement as D}from"../../interactive/visualElements/OutlineVisualElement.js";import{EuclideanSegment as M}from"../../interactive/visualElements/support/Segment.js";import{ElevationContext as S}from"../../layers/graphics/ElevationContext.js";import{extrudePolygon as U}from"../../layers/graphics/Graphics3DExtrudeSymbolLayer.js";import{polygonToRenderInfo as E}from"../../support/renderInfoUtils/polygon.js";import{CutFillColor as B,VolumeGeometry as N}from"../../webgl-engine/lib/CutFillColor.js";import{createStipplePatternSimple as T}from"../../webgl-engine/materials/lineStippleUtils.js";let H=class extends l{get visible(){return this.analysisViewData.visible&&null!=this.analysisViewData.elevationAlignedGeometry&&null!=this.analysisViewData.targetGeometry}get updating(){return this.loadingMessages}get hasUnsupportedError(){const{error:e}=this.analysisViewData;return!!e&&["unsupported-coordinate-system","unsupported-layer-transparency"].includes(e.name)}constructor(e){super(e),this.unitsMessages=null,this.messages=null,this.loadingMessages=!0,this._elevationContext=S.fromElevationInfo(new A({mode:"absolute-height"})),this._extrusionHeight=r.targetElevationRange,this._projectionLines=[]}initialize(){const{view:e}=this,s={view:e,isDecoration:!0},o=r,l={...s,width:o.geometryOutlineWidth};this._elevationAlignedGeometry=new D({...l,isDraped:!0,color:t.toUnitRGBA(o.geometryOutlineColor)}),this._targetGeometry=new D(l);const n={...s,attached:!0,width:o.projectionLineWidth,renderOccluded:4,polygonOffset:!0},a={...n,stipplePattern:T(o.projectionLineStippleSize)},c=t.toUnitRGBA(o.cutProjectionLineColor),u=t.toUnitRGBA(o.fillProjectionLineColor);this._cutProjectionLines=new x({...n,color:c}),this._occludedCutProjectionLines=new x({...a,color:c}),this._fillProjectionLines=new x({...n,color:u}),this._occludedFillProjectionLines=new x({...a,color:u});const h={...s,attached:!0};this._cutVolumeLabel=new O(h),this._fillVolumeLabel=new O(h),this._cutFillRenderNode=new B({view:e,cutColor:o.cutColor,fillColor:o.fillColor,borderColor:o.geometryOutlineColor}),this.addHandles([m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry}),({elevationAlignedGeometry:e,targetGeometry:t})=>{this._elevationAlignedGeometry.geometry=e,this._targetGeometry.geometry=t},d),m(()=>({interactive:this.analysisViewData.interactive,measureType:this.analysis.measureType,visible:this.visible}),({visible:e,interactive:t,measureType:i})=>{this._elevationAlignedGeometry.visible=e&&!t,this._targetGeometry.visible=e&&"cut-fill"===i,this._cutFillRenderNode.measureType=i},d),m(()=>({elevationAlignedGeometry:this.analysisViewData.elevationAlignedGeometry,targetGeometry:this.analysisViewData.targetGeometry,visible:this.visible}),({elevationAlignedGeometry:e,targetGeometry:t,visible:i})=>this._updateProjectionLines(e,t,i),d),m(()=>({interactive:this.analysisViewData.interactive,accentColor:this.view.effectiveTheme.accentColor,hasResult:!!this.analysisViewData.result}),({interactive:e,accentColor:t,hasResult:i})=>{this._updateColors(e,t,i)},d),m(()=>this.analysisViewData.targetGeometry,()=>this._updateCutFillGeometry(),d),m(()=>this.visible&&!this.hasUnsupportedError,e=>this._updateCutFillVisibility(e),d),m(()=>{const{messages:e,unitsMessages:t,visible:i,analysisViewData:s}=this;return{labelAnchors:s.labelAnchors,effectiveDisplayUnits:s.effectiveDisplayUnits,messages:e,unitsMessages:t,result:s.result,visible:i&&!!s.result}},e=>this._updateLabels(e)),m(()=>this.view.state.camera,e=>this._updateProjectionLineOcclusion(e),d),i(()=>this._updateMessageBundle())]),this._updateMessageBundle()}destroy(){this._elevationAlignedGeometry=c(this._elevationAlignedGeometry),this._targetGeometry=c(this._targetGeometry),this._cutProjectionLines=c(this._cutProjectionLines),this._occludedCutProjectionLines=c(this._occludedCutProjectionLines),this._fillProjectionLines=c(this._fillProjectionLines),this._occludedFillProjectionLines=c(this._occludedFillProjectionLines),this._cutVolumeLabel=c(this._cutVolumeLabel),this._fillVolumeLabel=c(this._fillVolumeLabel),this._cutFillRenderNode.destroy()}_updateProjectionLines(e,t,i){if(this._cutProjectionLines.visible=i,this._occludedCutProjectionLines.visible=i,this._fillProjectionLines.visible=i,this._occludedFillProjectionLines.visible=i,!e||!t)return;const{renderCoordsHelper:s}=this.view,o=[],r=e.spatialReference,l=e.rings[0],a=l.length>1&&n(l[0],l[l.length-1]),c=l.length-(a?1:0);for(let n=0;n<c;++n){const e=l[n],i=f(C(),e[0],e[1],e[2]);s.toRenderCoords(i,r,i);const a=t.rings[0][n],c=f(C(),a[0],a[1],a[2]);s.toRenderCoords(c,r,c);const u=new M(i,c);o.push(u)}e.isClockwise(l)||o.reverse();const u=[],m=[],d=[],h=[],p=[],y=this.view.state.camera;for(let n=0;n<o.length;++n){const i=o[n],s=o[0===n?o.length-1:n-1],r=o[n===o.length-1?0:n+1],l=e.rings[0][n],a=t.rings[0][n],c=l[2]>a[2],g=new I(i,s,r,c);u.push(g),g.updateOccluded(y);const _=g.isOccluded;c?(_?d:m).push(i):(_?p:h).push(i)}this._projectionLines=u,this._cutProjectionLines.setGeometryFromSegments(m),this._occludedCutProjectionLines.setGeometryFromSegments(d),this._fillProjectionLines.setGeometryFromSegments(h),this._occludedFillProjectionLines.setGeometryFromSegments(p)}_updateProjectionLineOcclusion(e){const t=[],i=[],s=[],o=[];let r=!1,l=!1;for(const n of this._projectionLines){n.updateOccluded(e)&&(r||=n.isCut,l||=!n.isCut);const a=n.isOccluded;(n.isCut?a?i:t:a?o:s).push(n.segment)}l&&(this._fillProjectionLines.setGeometryFromSegments(s),this._occludedFillProjectionLines.setGeometryFromSegments(o)),r&&(this._cutProjectionLines.setGeometryFromSegments(t),this._occludedCutProjectionLines.setGeometryFromSegments(i))}_updateColors(e,i,s){const{geometryOutlineColor:o,cutColor:l,fillColor:n,cutColorMuted:a,fillColorMuted:c,cutProjectionLineColor:u,fillProjectionLineColor:m}=r;if(this._cutFillRenderNode.cutColor=s?l:a,this._cutFillRenderNode.fillColor=s?n:c,e){const e=t.toUnitRGBA(i);this._targetGeometry.color=e,this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e,this._fillProjectionLines.color=e,this._occludedFillProjectionLines.color=e,this._cutFillRenderNode.borderColor=i}else{this._targetGeometry.color=t.toUnitRGBA(o);const e=t.toUnitRGBA(s?u:a);this._cutProjectionLines.color=e,this._occludedCutProjectionLines.color=e;const i=t.toUnitRGBA(s?m:c);this._fillProjectionLines.color=i,this._occludedFillProjectionLines.color=i,this._cutFillRenderNode.borderColor=o}}_updateLabels(e){const{labelDistance:t}=r,{effectiveDisplayUnits:i,labelAnchors:o,messages:l,unitsMessages:n,result:a,visible:c}=e;if(this._cutVolumeLabel.visible=c,this._fillVolumeLabel.visible=c,this._cutVolumeLabel.geometry=o.cut?{type:"point",point:o.cut,callout:{distance:t,offset:0}}:null,this._fillVolumeLabel.geometry=o.fill?{type:"point",point:o.fill,callout:{distance:-t,offset:0}}:null,null==a||null==l||null==n)return this._cutVolumeLabel.text="-",void(this._fillVolumeLabel.text="-");const u=i.volume,m=s(l.labels.cut,{volume:k(n,a.cutVolume,u)}),d=s(l.labels.fill,{volume:k(n,a.fillVolume,u)});this._cutVolumeLabel.text=m,this._fillVolumeLabel.text=d}_updateCutFillVisibility(e){e?this._cutFillRenderNode.enable():this._cutFillRenderNode.disable()}_updateCutFillGeometry(){const{renderCoordsHelper:e}=this.view,{targetGeometry:t}=this.analysisViewData;if(!t?.extent)return;const{center:i}=t.extent,s=w(i.x,i.y,0),o=C();e.toRenderCoords(s,t.spatialReference,o);const r=this._getExtrudedVolume(t,this._extrusionHeight,s,o),l=this._getExtrudedVolume(t,-this._extrusionHeight,s,o);this._cutFillRenderNode.updateGeometries(r,l,o)}_getExtrudedVolume(e,t,i,s){const{renderCoordsHelper:o,spatialReference:r,elevationProvider:l}=this.view,n=C(),a=1===o.viewingMode;o.worldUpAtPosition(s,n);const c=E(e,l,o,this._elevationContext),{polygons:u,mapPositions:m,position:d}=c,h=u[0],p=h.count,y=g(h.mapPositions,h.holeIndices,3),f=y.length,v=6*p,j=V(v+f),L=V(f),b=P(3*v),w=P(3*v);U(d,m,y,h,b,null,w,null,j,L,t,n,a);const R=_(),A=_();if(G(r,i,R,o.spatialReference),A[12]=-R[12],A[13]=-R[13],A[14]=-R[14],F(b,b,A),"stockpile"===this.analysis.measureType)for(let g=0;g<w.length;g+=3)w[g]=n[0],w[g+1]=n[1],w[g+2]=n[2];return new N(b,L,j,w)}async _updateMessageBundle(){this.loadingMessages=!0;try{this.unitsMessages=await o("esri/core/t9n/Units"),this.messages=await o("esri/views/3d/analysis/VolumeMeasurement/t9n/VolumeMeasurementAnalysis")}finally{this.loadingMessages=!1}}};function k(e,t,i){if(!t||!e)return null;const s=h(t.value,t.unit,i),o=r.labelPrecisions[s];return u(e,t,s,o)}e([p({constructOnly:!0})],H.prototype,"view",void 0),e([p({constructOnly:!0})],H.prototype,"analysis",void 0),e([p({constructOnly:!0})],H.prototype,"analysisViewData",void 0),e([p()],H.prototype,"unitsMessages",void 0),e([p()],H.prototype,"messages",void 0),e([p()],H.prototype,"loadingMessages",void 0),e([p({readOnly:!0})],H.prototype,"visible",null),e([p()],H.prototype,"updating",null),e([p()],H.prototype,"hasUnsupportedError",null),H=e([y("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementCutFillVisualization")],H);class I{constructor(e,t,i,s){this.segment=e,this.previous=t,this.next=i,this.isCut=s,this._isOccluded=!1,this._n1=C(),this._n2=C();const o=v(z,j(z,e.endRenderSpace,e.startRenderSpace));v(this._n1,L(this._n1,o,v(W,j(W,t.startRenderSpace,e.startRenderSpace)))),v(this._n2,L(this._n2,o,v(W,j(W,e.startRenderSpace,i.startRenderSpace)))),this._isConvex=a.normalize(R(this._n1,this._n2,o))<0}get isOccluded(){return this._isOccluded}updateOccluded(e){j(z,this.segment.startRenderSpace,e.eye);const t=b(this._n1,z)<0,i=b(this._n2,z)<0,s=this._isOccluded;return this._isOccluded=this._isConvex?t&&i:t||i,this._isOccluded!==s}}const z=C(),W=C();export{H as VolumeMeasurementCutFillVisualization};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import{deg2rad as i}from"../../../../core/mathUtils.js";import{valueInUnit as o}from"../../../../core/quantity.js";import{watch as e,sync as s,syncAndInitial as a}from"../../../../core/reactiveUtils.js";import{verticalLengthUnitFromSpatialReference as n,convertUnit as r}from"../../../../core/units.js";import{property as l,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{rotateZ as h}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{e as c,l as u}from"../../../../chunks/vec32.js";import{fromArray as d,clone as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sv3d as f,sm4d as v}from"../../../../geometry/support/vectorStacks.js";import{ShiftManipulator as y}from"../Slice/ShiftManipulator.js";import{IsShiftEdgeOnScreenFlag as _}from"../Slice/sliceToolUtils.js";import{calculateTranslateRotateFromBases as w}from"../../interactive/manipulatorUtils.js";import{screenToZConstrained as g}from"../../interactive/editingTools/dragEventPipeline3D.js";import{createManipulatorDragEventPipeline as T,addMapTranslation as U}from"../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as j}from"../../../interactive/InteractiveToolBase.js";import M from"../../../interactive/sketch/SketchOptions.js";import O from"../../../interactive/sketch/Units.js";import{makeTooltip as k,enterInputModeIfAvailable as V}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{ElevationTooltipInfo as S}from"../../../interactive/tooltip/infos/ElevationTooltipInfo.js";import{elevationFromZ as I}from"../../../support/euclideanLengthMeasurementUtils.js";let D=class extends j{constructor(t){super(t),this.sketchOptions=new M}initialize(){const{view:t}=this;this._shiftManipulator=new y(t,0),this._shiftManipulator.state|=_,this.manipulators.add(this._shiftManipulator),this.addHandles([this._createDragPipeline(),e(()=>this.analysisViewData.targetGeometry,()=>this._updateManipulatorPosition(),s),e(()=>[this.analysisViewData.interactive,this.analysisViewData.targetGeometry,this.analysis.measureType],()=>this._updateManipulatorVisibility(),a)]),this._initializeTooltip(),this.finishToolCreation()}_initializeTooltip(){const{view:t}=this;this.tooltip=k(()=>({view:t,options:this.sketchOptions.tooltips})),this._tooltipInfo=new S({sketchOptions:this.sketchOptions}),this.sketchOptions.tooltips.placement="trailing",this._updateSketchOptions(),this.addHandles([e(()=>this.analysisViewData.effectiveTargetElevation,()=>this._updateTooltip()),e(()=>this._shouldShowTooltip,t=>{t?this._showTooltip():this._hideTooltip()}),this.tooltip.on("commit",()=>{const t=this._tooltipInfo.elevation.actual,i=n(this.view.spatialReference);if(null==t||null==i)return;const e=o(t,i);this._updateValue(e,{recordUndo:this.analysis.cutFillOptions.targetElevation})}),e(()=>[this.analysis.displayUnits.elevation,this.analysis.inputUnits.elevation],()=>this._updateSketchOptions(),a)])}destroy(){this._shiftManipulator.destroy(),this.tooltip.destroy()}onInputEvent(t){if(!this.destroyed&&!V(t,this.tooltip))return super.onInputEvent(t)}get _shouldShowTooltip(){return this.hasFocusedManipulators||"input"===this.tooltip.mode}_createDragPipeline(){return T(this._shiftManipulator,(t,i,o)=>{const e=m(t.renderLocation),s=this.analysis.inputUnits.elevation??"meters",a=n(this.view.spatialReference);let l;i.next(g(this.view,e,this.view.spatialReference)).next(U()).next(t=>{if("start"===t.action){const{targetElevation:t}=this.analysis.cutFillOptions;l=t&&a?r(t,s,a):void 0}return this._updateValue(null!=l?l+t.translationZ:t.mapEnd.z,"end"===t.action?{recordUndo:l}:void 0),t}),o.next(()=>{this._updateValue(l)})})}_updateManipulatorPosition(){const{targetGeometry:t}=this.analysisViewData,{renderCoordsHelper:o}=this.view;if(!t)return;const e=.5,s=t.rings[0],a=d(s[0]),n=d(s[1]);o.toRenderCoords(a,t.spatialReference,a),o.toRenderCoords(n,t.spatialReference,n);const r=f.get();c(r,n,a);const l=f.get();u(l,a,n,e);const p=o.worldBasisAtPosition(l,1,f.get()),y=o.worldBasisAtPosition(l,0,f.get()),_=w(p,y,l,v.get()),g=o.headingAtPosition(l,r),T=t.isClockwise(t.rings[0])?-Math.PI/2:Math.PI/2;h(_,_,i(g)+T),_[12]=0,_[13]=0,_[14]=0,this._shiftManipulator.renderLocation=m(l),this._shiftManipulator.modelTransform=_}_updateManipulatorVisibility(){const{interactive:t,targetGeometry:i}=this.analysisViewData,{measureType:o}=this.analysis,e=t&&null!=i&&"cut-fill"===o;this._shiftManipulator.available=e}_updateValue(t,i){const o=I(t,this.view.spatialReference);if(null==o)return;const e=this.analysis.inputUnits.elevation??"meters",s=r(o.value,o.unit,e),a=t=>{this.analysis.cutFillOptions.targetElevation=t};if(a(s),i&&"recordUndo"in i){const t=i.recordUndo;this.emit("record-undo",{apply:()=>a(s),undo:()=>a(t)})}}_getUpdatedTooltipInfo(){const{effectiveTargetElevation:t}=this.analysisViewData;return t?(this._tooltipInfo.elevation.actual=I(t,this.view.spatialReference),this._tooltipInfo):this._tooltipInfo}_updateTooltip(){this._shouldShowTooltip&&(this.tooltip.info=this._getUpdatedTooltipInfo())}_showTooltip(){this._updateTooltip()}_hideTooltip(){this.tooltip?.clear()}_updateSketchOptions(){const{analysis:t}=this,{displayUnits:i,inputUnits:o}=t;this.sketchOptions.values.inputUnits=new O({verticalLength:o.elevation}),this.sketchOptions.values.displayUnits=new O({verticalLength:i.elevation})}};t([l({constructOnly:!0})],D.prototype,"analysis",void 0),t([l({constructOnly:!0})],D.prototype,"view",void 0),t([l({constructOnly:!0})],D.prototype,"analysisViewData",void 0),t([l({constructOnly:!0,type:M})],D.prototype,"sketchOptions",void 0),t([l()],D.prototype,"_shouldShowTooltip",null),D=t([p("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementShiftTool")],D);export{D as VolumeMeasurementShiftTool};
5
+ import{__decorate as t}from"tslib";import{deg2rad as i}from"../../../../core/mathUtils.js";import{valueInUnit as o}from"../../../../core/quantity.js";import{watch as e,sync as s,syncAndInitial as a}from"../../../../core/reactiveUtils.js";import{verticalLengthUnitFromSpatialReference as n,convertUnit as r}from"../../../../core/units.js";import{property as l,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{rotateZ as h}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{e as c,l as u}from"../../../../chunks/vec32.js";import{fromArray as d,clone as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{sv3d as f,sm4d as v}from"../../../../geometry/support/vectorStacks.js";import{ShiftManipulator as y}from"../Slice/ShiftManipulator.js";import{IsShiftEdgeOnScreenFlag as _}from"../Slice/sliceToolUtils.js";import{calculateTranslateRotateFromBases as w}from"../../interactive/manipulatorUtils.js";import{screenToZConstrained as g}from"../../interactive/editingTools/dragEventPipeline3D.js";import{createManipulatorDragEventPipeline as T,addMapTranslation as U}from"../../../interactive/dragEventPipeline.js";import{InteractiveToolBase as j}from"../../../interactive/InteractiveToolBase.js";import M from"../../../interactive/sketch/SketchOptions.js";import O from"../../../interactive/sketch/Units.js";import{makeTooltip as k,enterInputModeIfAvailable as V}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{ElevationTooltipInfo as S}from"../../../interactive/tooltip/infos/ElevationTooltipInfo.js";import{elevationFromZ as E}from"../../../support/euclideanLengthMeasurementUtils.js";let I=class extends j{constructor(t){super(t),this.multiTouchEnabled=!1,this.sketchOptions=new M}initialize(){const{view:t}=this;this._shiftManipulator=new y(t,0),this._shiftManipulator.state|=_,this.manipulators.add(this._shiftManipulator),this.addHandles([this._createDragPipeline(),e(()=>this.analysisViewData.targetGeometry,()=>this._updateManipulatorPosition(),s),e(()=>[this.analysisViewData.interactive,this.analysisViewData.targetGeometry,this.analysis.measureType],()=>this._updateManipulatorVisibility(),a)]),this._initializeTooltip(),this.finishToolCreation()}_initializeTooltip(){const{view:t}=this;this.tooltip=k(()=>({view:t,options:this.sketchOptions.tooltips})),this._tooltipInfo=new S({sketchOptions:this.sketchOptions}),this.sketchOptions.tooltips.placement="trailing",this._updateSketchOptions(),this.addHandles([e(()=>this.analysisViewData.effectiveTargetElevation,()=>this._updateTooltip()),e(()=>this._shouldShowTooltip,t=>{t?this._showTooltip():this._hideTooltip()}),this.tooltip.on("commit",()=>{const t=this._tooltipInfo.elevation.actual,i=n(this.view.spatialReference);if(null==t||null==i)return;const e=o(t,i);this._updateValue(e,{recordUndo:this.analysis.cutFillOptions.targetElevation})}),e(()=>[this.analysis.displayUnits.elevation,this.analysis.inputUnits.elevation],()=>this._updateSketchOptions(),a)])}destroy(){this._shiftManipulator.destroy(),this.tooltip.destroy()}onInputEvent(t){if(!this.destroyed&&!V(t,this.tooltip))return super.onInputEvent(t)}get _shouldShowTooltip(){return this.hasFocusedManipulators||"input"===this.tooltip.mode}_createDragPipeline(){return T(this._shiftManipulator,(t,i,o)=>{const e=m(t.renderLocation),s=this.analysis.inputUnits.elevation??"meters",a=n(this.view.spatialReference);let l;i.next(g(this.view,e,this.view.spatialReference)).next(U()).next(t=>{if("start"===t.action){const{targetElevation:t}=this.analysis.cutFillOptions;l=t&&a?r(t,s,a):void 0}return this._updateValue(null!=l?l+t.translationZ:t.mapEnd.z,"end"===t.action?{recordUndo:l}:void 0),t}),o.next(()=>{this._updateValue(l)})})}_updateManipulatorPosition(){const{targetGeometry:t}=this.analysisViewData,{renderCoordsHelper:o}=this.view;if(!t)return;const e=.5,s=t.rings[0],a=d(s[0]),n=d(s[1]);o.toRenderCoords(a,t.spatialReference,a),o.toRenderCoords(n,t.spatialReference,n);const r=f.get();c(r,n,a);const l=f.get();u(l,a,n,e);const p=o.worldBasisAtPosition(l,1,f.get()),y=o.worldBasisAtPosition(l,0,f.get()),_=w(p,y,l,v.get()),g=o.headingAtPosition(l,r),T=t.isClockwise(t.rings[0])?-Math.PI/2:Math.PI/2;h(_,_,i(g)+T),_[12]=0,_[13]=0,_[14]=0,this._shiftManipulator.renderLocation=m(l),this._shiftManipulator.modelTransform=_}_updateManipulatorVisibility(){const{interactive:t,targetGeometry:i}=this.analysisViewData,{measureType:o}=this.analysis,e=t&&null!=i&&"cut-fill"===o;this._shiftManipulator.available=e}_updateValue(t,i){const o=E(t,this.view.spatialReference);if(null==o)return;const e=this.analysis.inputUnits.elevation??"meters",s=r(o.value,o.unit,e),a=t=>{this.analysis.cutFillOptions.targetElevation=t};if(a(s),i&&"recordUndo"in i){const t=i.recordUndo;this.emit("record-undo",{apply:()=>a(s),undo:()=>a(t)})}}_getUpdatedTooltipInfo(){const{effectiveTargetElevation:t}=this.analysisViewData;return t?(this._tooltipInfo.elevation.actual=E(t,this.view.spatialReference),this._tooltipInfo):this._tooltipInfo}_updateTooltip(){this._shouldShowTooltip&&(this.tooltip.info=this._getUpdatedTooltipInfo())}_showTooltip(){this._updateTooltip()}_hideTooltip(){this.tooltip?.clear()}_updateSketchOptions(){const{analysis:t}=this,{displayUnits:i,inputUnits:o}=t;this.sketchOptions.values.inputUnits=new O({verticalLength:o.elevation}),this.sketchOptions.values.displayUnits=new O({verticalLength:i.elevation})}};t([l()],I.prototype,"multiTouchEnabled",void 0),t([l({constructOnly:!0})],I.prototype,"analysis",void 0),t([l({constructOnly:!0})],I.prototype,"view",void 0),t([l({constructOnly:!0})],I.prototype,"analysisViewData",void 0),t([l({constructOnly:!0,type:M})],I.prototype,"sketchOptions",void 0),t([l()],I.prototype,"_shouldShowTooltip",null),I=t([p("esri.views.3d.analysis.VolumeMeasurement.VolumeMeasurementShiftTool")],I);export{I as VolumeMeasurementShiftTool};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{d as e,s as r,j as t,e as n,i,g as o,b as s}from"../../../chunks/vec32.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{containsPoint as l}from"../../../geometry/support/aaBoundingRect.js";import d from"../webgl/RenderCamera.js";import{DepthRange as g}from"../webgl-engine/lib/DepthRange.js";import{Intersector as u}from"../webgl-engine/lib/Intersector.js";function f(e,r,t,n){return null!=e.renderCoordsHelper.fromRenderCoords(r.eye,j,n)&&l(t,j)}function m(e,r){return e.elevationProvider?e.elevationProvider.getElevation(r[0],r[1],r[2],e.renderCoordsHelper.spatialReference,"ground")??0:0}function p(o,s,a,c){const l=o.state.camera.clone();s&&a&&c&&(l.eye=s,l.center=a,l.up=c),v(o,l.ray,R)||e(R,l.center);const d=o.state.constraints,g=d.minimumPoiDistance;if(r(l.eye,R)<g){const r=d.collision.enabled;e(C,l.viewForward),t(C,C,g),r?l.eye=n(j,R,C):i(R,l.eye,C);const s=o.renderCoordsHelper,a=s.getAltitude(l.eye),c=d.collision.elevationMargin;r&&a<c&&(n(C,R,l.eye),l.eye=s.setAltitude(j,c,l.eye),i(R,l.eye,C))}return l.center=R,l}function y(e,t,n){if(!e.state.isGlobal||!e.stateManager.constraintsManager)return!1;const i=m(e,t),o=e.stateManager.constraintsManager.nearFarHeuristic;let s=H.get(e);void 0===s&&(s=new d,H.set(e,s)),s.eye=t,s.center=n;const{far:a}=o.compute(s,e.renderDataExtent,g.Infinite,i),c=a*a;return r(t,n)>c}function v(e,r,t){let n=w[e.viewingMode];n||(n=new u(e.state.viewingMode),n.options.backfacesTerrain=!e.state.isGlobal,n.options.invisibleTerrain=!0,w[e.viewingMode]=n);const{isGlobal:i}=e.state;return!(!e.sceneIntersectionHelper.intersectRay(r,n,t)||y(e,r.origin,t))||(!(!e.renderCoordsHelper.intersectManifold(r,0,t)||y(e,r.origin,t))||!!i&&b(r,t,c(e.spatialReference).radius))}function b(e,r,n){const a=o(e.origin,e.origin)-n*n,c=a>0?Math.sqrt(a)/3:1;return t(r,e.direction,c/s(e.direction)),i(r,r,e.origin),!0}let w={};function M(){w={}}const j=a(),R=a(),C=a(),H=new WeakMap;export{p as cameraOnContentAlongViewDirection,M as cleanupIntersectionUtils,f as eyeWithinExtent,m as surfaceElevationBelowRenderLocation};
5
+ import{d as e,s as r,j as t,e as n,i,g as o,b as s}from"../../../chunks/vec32.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as c}from"../../../geometry/ellipsoidUtils.js";import{containsPoint as l}from"../../../geometry/support/aaBoundingRect.js";import{Intersector as d}from"../webgl-engine/lib/Intersector.js";function u(e,r,t,n){return null!=e.renderCoordsHelper.fromRenderCoords(r.eye,M,n)&&l(t,M)}function g(e,r){return e.elevationProvider?e.elevationProvider.getElevation(r[0],r[1],r[2],e.renderCoordsHelper.spatialReference,"ground")??0:0}function f(o,s,a,c){const l=o.state.camera.clone();s&&a&&c&&(l.eye=s,l.center=a,l.up=c),m(o,l.ray,w)||e(w,l.center);const d=o.state.constraints,u=d.minimumPoiDistance;if(r(l.eye,w)<u){const r=d.collision.enabled;e(j,l.viewForward),t(j,j,u),r?l.eye=n(M,w,j):i(w,l.eye,j);const s=o.renderCoordsHelper,a=s.getAltitude(l.eye),c=d.collision.elevationMargin;r&&a<c&&(n(j,w,l.eye),l.eye=s.setAltitude(M,c,l.eye),i(w,l.eye,j))}return l.center=w,l}function p(e,t,n){if(!e.state.isGlobal||!e.stateManager.constraintsManager)return!1;const i=g(e,t),o=e.stateManager.constraintsManager.nearFarHeuristic.computeFarDistance(t,i),s=o*o;return r(t,n)>s}function m(e,r,t){let n=v[e.viewingMode];n||(n=new d(e.state.viewingMode),n.options.backfacesTerrain=!e.state.isGlobal,n.options.invisibleTerrain=!0,v[e.viewingMode]=n);const{isGlobal:i}=e.state;return!(!e.sceneIntersectionHelper.intersectRay(r,n,t)||p(e,r.origin,t))||(!(!e.renderCoordsHelper.intersectManifold(r,0,t)||p(e,r.origin,t))||!!i&&y(r,t,c(e.spatialReference).radius))}function y(e,r,n){const a=o(e.origin,e.origin)-n*n,c=a>0?Math.sqrt(a)/3:1;return t(r,e.direction,c/s(e.direction)),i(r,r,e.origin),!0}let v={};function b(){v={}}const M=a(),w=a(),j=a();export{f as cameraOnContentAlongViewDirection,b as cleanupIntersectionUtils,u as eyeWithinExtent,g as surfaceElevationBelowRenderLocation};
@@ -2,7 +2,7 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{create as e}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{earth as r}from"../../../geometry/support/Ellipsoid.js";import{Float2PassUniform as a}from"../webgl-engine/core/shaderModules/Float2PassUniform.js";import{Float4PassUniform as s}from"../webgl-engine/core/shaderModules/Float4PassUniform.js";import{glsl as i}from"../webgl-engine/core/shaderModules/glsl.js";import{NoParameters as o}from"../../webgl/NoParameters.js";class c extends o{constructor(){super(...arguments),this.radii=e(),this.heightParameters=t()}}function n(e){e.uniforms.add(new a("radii",e=>e.radii),new s("heightParameters",e=>e.heightParameters)),e.constants.add("scaleHeight","float",r.scaleHeight*r.atmosphereHeight),e.code.add(i`float chapmanApproximation(float thickness, float height, float cosZenith) {
5
+ import{create as e}from"../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{create as t}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{earth as r}from"../../../geometry/support/Ellipsoid.js";import{Float2PassUniform as a}from"../webgl-engine/core/shaderModules/Float2PassUniform.js";import{Float3BindUniform as s}from"../webgl-engine/core/shaderModules/Float3BindUniform.js";import{Float4PassUniform as i}from"../webgl-engine/core/shaderModules/Float4PassUniform.js";import{glsl as o}from"../webgl-engine/core/shaderModules/glsl.js";import{NoParameters as n}from"../../webgl/NoParameters.js";class c extends n{constructor(){super(...arguments),this.radii=e(),this.heightParameters=t()}}function h(e){e.code.add(o`float chapmanApproximation(float thickness, float height, float cosZenith) {
6
6
  float c = sqrt(thickness + height);
7
7
  float cExpH = c * exp(-height);
8
8
  if (cosZenith >= 0.0) {
@@ -12,26 +12,26 @@ float x0 = sqrt(1.0 - cosZenith * cosZenith) * (thickness + height);
12
12
  float c0 = sqrt(x0);
13
13
  return 2.0 * c0 * exp(thickness - x0) - cExpH / (1.0 - c * cosZenith);
14
14
  }
15
- }`),e.code.add(i`float getOpticalDepth(vec3 position, vec3 dir, float h) {
15
+ }`),e.constants.add("scaleHeight","float",r.scaleHeight*r.atmosphereHeight).uniforms.add(new a("radii",e=>e.radii)).code.add(o`float getOpticalDepth(vec3 position, vec3 dir, float h) {
16
16
  return scaleHeight * chapmanApproximation(radii[0] / scaleHeight, h, dot(normalize(position), dir));
17
- }`),e.code.add(i`vec4 planetIntersect(vec3 cameraPos, vec3 rayDir) {
17
+ }`),e.uniforms.add(new i("heightParameters",e=>e.heightParameters),new s("cameraPosition",e=>e.camera.eye)).code.add(o`vec4 planetIntersect(vec3 rayDir) {
18
18
  float reducedPlanetRadius = radii[0] - 20000.0;
19
19
  float rayPlanetDistance = heightParameters[1] - reducedPlanetRadius * reducedPlanetRadius;
20
- vec2 rayPlanetIntersect = sphereIntersect(cameraPos, rayDir, rayPlanetDistance);
21
- vec2 rayAtmosphereIntersect = sphereIntersect(cameraPos, rayDir, heightParameters[2]);
20
+ vec2 rayPlanetIntersect = sphereIntersect(cameraPosition, rayDir, rayPlanetDistance);
21
+ vec2 rayAtmosphereIntersect = sphereIntersect(cameraPosition, rayDir, heightParameters[2]);
22
22
  bool hitsAtmosphere = (rayAtmosphereIntersect.x <= rayAtmosphereIntersect.y) && rayAtmosphereIntersect.x > 0.0;
23
23
  bool insideAtmosphere = heightParameters[0] < radii[1];
24
- if (!(hitsAtmosphere || insideAtmosphere)) {
24
+ if (!hitsAtmosphere && !insideAtmosphere) {
25
25
  return vec4(1.0, 0.0, 0.0, 0.0);
26
26
  }
27
27
  bool hitsPlanet = (rayPlanetIntersect.x <= rayPlanetIntersect.y) && rayPlanetIntersect.x > 0.0;
28
28
  float start = insideAtmosphere ? 0.0 : rayAtmosphereIntersect.x;
29
29
  if (heightParameters[0] < reducedPlanetRadius) {
30
- if (dot(rayDir, normalize(cameraPos)) < -0.025) {
30
+ if (dot(rayDir, normalize(cameraPosition)) < -0.025) {
31
31
  return vec4(1.0, 0.0, 0.0, 0.0);
32
32
  }
33
33
  start = rayPlanetIntersect.y;
34
34
  }
35
35
  float end = hitsPlanet ? rayPlanetIntersect.x : rayAtmosphereIntersect.y;
36
36
  return vec4(0.0, hitsPlanet ? 1.0 : 0.0, start, end);
37
- }`)}export{n as ChapmanApproximation,c as ChapmanApproximationParameters};
37
+ }`)}export{h as ChapmanApproximation,c as ChapmanApproximationParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import"./ChapmanRaymarching.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/MainLighting.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/shaders/ScreenSpacePassAtmosphere.glsl.js";import"../webgl-engine/shaders/SphereIntersect.glsl.js";import"../webgl-engine/shaders/ToneMapping.glsl.js";import"../../webgl/ShaderBuilder.js";export{b as build}from"../../../chunks/ChapmanAtmosphere.glsl.js";
5
+ import"./ChapmanRaymarching.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/Gamma.glsl.js";import"../webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js";import"../webgl-engine/core/shaderModules/Float2PassUniform.js";import"../webgl-engine/core/shaderModules/Float3BindUniform.js";import"../webgl-engine/core/shaderModules/Float3PassUniform.js";import"../webgl-engine/core/shaderModules/Float4PassUniform.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/shaders/ScreenSpacePassAtmosphere.glsl.js";import"../webgl-engine/shaders/SphereIntersect.glsl.js";import"../webgl-engine/shaders/ToneMapping.glsl.js";import"../../webgl/ShaderBuilder.js";export{b as build}from"../../../chunks/ChapmanAtmosphere.glsl.js";
@@ -2,37 +2,37 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{betaRayleigh as e,betaCombined as a,betaMie as t}from"./atmosphereUtils.js";import{ChapmanApproximation as i}from"./ChapmanApproximation.glsl.js";import{Float3BindUniform as l}from"../webgl-engine/core/shaderModules/Float3BindUniform.js";import{If as r,glsl as o}from"../webgl-engine/core/shaderModules/glsl.js";function s(s,c){s.include(i);const p=6;s.uniforms.add(new l("cameraPosition",e=>e.camera.eye)),s.constants.add("betaRayleigh","vec3",e),s.constants.add("betaCombined","vec3",a),s.constants.add("betaMie","float",t),s.code.add(o`
6
- vec3 raymarchAtmosphere(vec3 cameraPos, vec3 rayDir, vec3 lightDir, float terrainDepth) {
7
- vec4 ray = planetIntersect(cameraPos, rayDir);
5
+ import{betaRayleigh as e,betaCombined as t,betaMie as a}from"./atmosphereUtils.js";import{ChapmanApproximation as i}from"./ChapmanApproximation.glsl.js";import{Float3BindUniform as l}from"../webgl-engine/core/shaderModules/Float3BindUniform.js";import{If as r,glsl as s}from"../webgl-engine/core/shaderModules/glsl.js";function o(o,p){o.include(i),o.constants.add("betaRayleigh","vec3",e),o.constants.add("betaCombined","vec3",t),o.constants.add("betaMie","float",a),o.constants.add("steps","int",6),o.uniforms.add(new l("cameraPosition",e=>e.camera.eye)).code.add(s`
6
+ vec3 raymarchAtmosphere(vec3 rayDir, vec3 lightDir, float terrainDepth) {
7
+ vec4 ray = planetIntersect(rayDir);
8
8
  if(ray.x == 1.0) {
9
9
  return vec3(0);
10
10
  }
11
- ${r(c,"if (terrainDepth != -1.0) { ray.w = terrainDepth; }")}
11
+ ${r(p,"if (terrainDepth != -1.0) { ray.w = terrainDepth; }")}
12
12
 
13
- vec3 samplePoint = cameraPos + rayDir * ray.w;
13
+ vec3 samplePoint = cameraPosition + rayDir * ray.w;
14
14
  float multiplier = ray.y == 1.0 ? -1.0 : 1.0;
15
15
 
16
16
  vec3 scattering = vec3(0);
17
17
  float scaleFract = (length(samplePoint) - radii[0]) / scaleHeight;
18
18
  float lastOpticalDepth = getOpticalDepth(samplePoint, rayDir, scaleFract);
19
- float stepSize = (ray.w - ray.z) / ${o.float(p)};
19
+ float stepSize = (ray.w - ray.z) / float(steps);
20
20
 
21
- for (int i = 0; i < ${o.int(p)}; i++) {
21
+ for (int i = 0; i < steps; i++) {
22
22
  samplePoint -= stepSize * rayDir;
23
23
  scaleFract = (length(samplePoint) - radii[0]) / scaleHeight;
24
24
  float opticalDepth = multiplier * getOpticalDepth(samplePoint, rayDir * multiplier, scaleFract);
25
25
 
26
26
  if (i > 0) {
27
27
  scattering *= exp(-(mix(betaCombined, betaRayleigh, 0.5) + betaMie) * max(0.0, (opticalDepth - lastOpticalDepth)));
28
- ${r(!c,"scattering *= mix(2.5, 1.0, clamp((length(cameraPos) - radii[0]) / 50e3, 0.0, 1.0))")};
28
+ ${r(!p,"scattering *= mix(2.5, 1.0, clamp((length(cameraPosition) - radii[0]) / 50e3, 0.0, 1.0))")};
29
29
  }
30
30
 
31
31
  if (dot(normalize(samplePoint), lightDir) > -0.3) {
32
32
  float scale = exp(-scaleFract);
33
33
  float lightDepth = getOpticalDepth(samplePoint, lightDir, scaleFract);
34
34
  scattering += scale * exp(-(betaCombined + betaMie) * lightDepth);
35
- ${r(!c,"scattering += scale * exp(-(0.25 * betaCombined ) * lightDepth);")}
35
+ ${r(!p,"scattering += scale * exp(-(0.25 * betaCombined ) * lightDepth);")}
36
36
  }
37
37
  lastOpticalDepth = opticalDepth;
38
38
  }
@@ -41,9 +41,10 @@ import{betaRayleigh as e,betaCombined as a,betaMie as t}from"./atmosphereUtils.j
41
41
  float mumu = 1.0 + mu * mu;
42
42
 
43
43
  float phaseRayleigh = 0.0596831 * mumu;
44
- ${c?"return 3.0 * scattering * stepSize * phaseRayleigh * betaRayleigh;":o`const float g = 0.8;
45
- const float gg = g * g;
46
- float phaseMie = 0.1193662 * ((1.0 - gg) * mumu) / (pow(1.0 + gg - 2.0 * mu * g, 1.5) * (2.0 + gg));
47
- phaseMie = clamp(phaseMie, 0.0, 128.0);
48
- return 3.0 * scattering * stepSize * (phaseRayleigh * betaRayleigh + 0.025 * phaseMie * betaMie);`}
49
- }`)}export{s as ChapmanRaymarching};
44
+ ${p?"return 3.0 * scattering * stepSize * phaseRayleigh * betaRayleigh;":s`
45
+ const float g = 0.8;
46
+ const float gg = g * g;
47
+ float phaseMie = 0.1193662 * ((1.0 - gg) * mumu) / (pow(1.0 + gg - 2.0 * mu * g, 1.5) * (2.0 + gg));
48
+ phaseMie = clamp(phaseMie, 0.0, 128.0);
49
+ return 3.0 * scattering * stepSize * (phaseRayleigh * betaRayleigh + 0.025 * phaseMie * betaMie);`}
50
+ }`)}export{o as ChapmanRaymarching};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as s}from"../../../core/maybe.js";import{debounce as r,ignoreAbortErrors as l,throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as o,when as a,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as p,secondsFromMilliseconds as c}from"../../../core/time.js";import{property as g,subclass as m}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as f}from"../../../geometry/projectionUtils.js";import{fromExtent as _,intersection as y,toExtent as v,create as T,contains as w,area as S,intersects as b}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as R}from"../../../geometry/support/spatialReferenceUtils.js";import x from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as L,getPositions as A,getFlowSimulationSettings as j}from"../../2d/engine/flow/utils.js";import M from"./SubView3D.js";import{getFeatureTileId as E}from"./support/FeatureTileDescriptor.js";import{makeScheduleFunction as U}from"./support/makeScheduleFunction.js";import{debugFlags as P}from"../support/debugFlags.js";import{tileFilterDistance as I,scaleThresholdForLoadingAllTiles as F,fadeOutTime as D,fadeInTime as C,defaultTransitionDuration as q,transitionDurationFactor as k,seamlessTransitionEnabled as O,densityFactor as V,loadAllTilesDensityFactor as W,averageLoadingTimeSmoothingFactor as G,minimumTracingResolution as B}from"../support/flow/constants.js";import{isFullExtent as H,wrappedWidth as z,FlowQuery3D as N}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as Q}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as J,createStreamlineGeometry as K}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as X}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as Y}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as Z}from"../support/flow/StreamlineResources3DShape.js";import{descendantsAtLevel as $,tilesAreRelated as ee}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as te}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as ie}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as se,hasLayerBasedScaleVisibility as re}from"../../support/layerViewUtils.js";import{TaskPriority as le}from"../../support/Scheduler.js";let ne=class extends M{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=r(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*s(s){for(let r=0;r<e.length;++r){const l=e.at(r);t(l)&&i.add(l),s.madeProgress(),s.done&&(s=yield)}}await this.frameTask.scheduleGenerator(s),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new Q(U(i)),this.frameTask=i.scheduler.registerTask(le.FLOW_GENERATOR),this._updateTask=h({update:e=>this._update(e)}),this.addHandles([o(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&L(e,t)}),o(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this._visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),o(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),e.on("tiles-changed",()=>{this._triggerTilesUpdate()}),t.enableFeatureTiles(),o(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),o(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],s=e?.visualVariables??[];s.length===i.length&&s.every((e,t)=>e.type===i[t].type)||this.clear()}),a(()=>!t.featureTiles?.updating,()=>{this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=s(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=f(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:_(e)}get _dataBounds(){const e=this._fullExtentSurfaceSpatialReference;return null==e?null:_(e)}get _fullExtentSurfaceSpatialReference(){return f(this.layer.fullExtent,this.surface.spatialReference).geometry}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get extent(){if(this.loadAllTiles)return this._fullExtentSurfaceSpatialReference;const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<I&&e.add(t)}),t=e}const s=X(t,this.spatialReferenceInfo);return null==s?null:(y(s,this._clippingArea,s),v(s,e))}get loadAllTiles(){return this.view.scale>(P.FLOW_GLOBAL_SCALE_THRESHOLD??F)}get isDataGlobal(){const{extent:e,spatialReferenceInfo:t}=this;return null!=e&&H(e.xmin,e.xmax,t)}get loadAllTilesLevel(){const{tilingScheme:e}=this.surface;return Math.min(Math.ceil(e.levelAtScale(P.FLOW_GLOBAL_SCALE_THRESHOLD??F)),e.getMaxLod())}get targetTiles(){const e=new Map;if(this.loadAllTiles){const{_dataBounds:t}=this;if(null==t)return e;const i=T(),s=this.loadAllTilesLevel,r=this.surface.tilingScheme,l=r.rootTilesInExtent(t).flatMap(e=>$(e,s));for(const n of l){const[l,o,a]=n;r.getExtent(s,o,a,i),ae(t,i)&&e.set(E(s,o,a),n)}return e}const{renderedTiles:t}=this;for(const i of t??[])e.set(i.key,i.lij);return e}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=f(e,this.surface.spatialReference).geometry;return null==t?null:_(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...J(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),fadeInTime:C,fadeOutTime:D,...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&te(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?q:this._averageLoadingTime*k)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:O}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=z(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,s]=this.view.size;let r,l;i<s?(r=i,l=i/t):(r=s*t,l=s);const n=B,o=this.view.qualitySettings.flow.maxTracingResolution,a=Math.max(1,n/Math.min(r,l)),u=a*Math.min(1,o/Math.max(r*a,l*a));return[Math.round(r*u),Math.round(l*u)]}get _visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i,loadAllTiles:s}=this;if(null==t||null==i)return 0;const r=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density;if(s)return 2*r;const l=null==e?null:_(e);if(null==l)return 0;let n=0;for(const u of i)w(l,u.extent)&&(n+=S(u.extent));const o=S(l),a=0===o?0:n/o;return 2*Math.round(r*a)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:s}=this.view;if(null==t)return 0;const r=i.flow.maxTotalNumberOfStreamlines,l=e>=r?r/e:1,n=t.density*l*s;return t.lineSpacing/Math.sqrt(n)<t.lineCollisionWidth?(t.lineSpacing/t.lineCollisionWidth)**2:n}get elevationInfo(){return this.layer.elevationInfo??oe}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:A(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return R(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&(this.renderedTiles.size>0||this.loadAllTiles)}getUpdating(){return this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState}get updating(){return this.getUpdating()}get visibleAtCurrentScale(){return!re()||se(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=j(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,i.density*=V,this.loadAllTiles&&this.isDataGlobal&&(i.density*=W),null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const s="global"===this.view.viewingMode&&null!=i&&H(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:s,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){this.triggerLoad()}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(e){const t=c(e.time);this._lastResources?.hasFadedOut(t)&&this._lastResources.detach();const i=this._nextStateForTransition(t);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==i||!this.loadRequirementsMet)return void(this._loadingState=i);this._loadingState="loading";const s=async()=>{const e=performance.now(),i=this._seamlessTransitionEnabled&&null!=this._resources?p(t+this._seamlessTransitionWaitingTime):t;await this._load(i);const s=p((performance.now()-e)/1e3);this._updateAverageLoadingTime(s)};this.updatingHandles.addPromise(l(s())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=G;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.requireLoad=!0)}async _load(e){const{extent:t,view:i}=this;if(!this._visible)return this.clear(),void(this._loadingState="ready-to-load");if(null==t)return void(this._loadingState="ready-to-load");const s=new N(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const r=this._abortController,l=await this._loadStreamlines(s,r.signal);if(n(r.signal),this._visible&&null!=l){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=l;const t=performance.now()/1e3,i=t>e?t:e;null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,await l.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:s,material:r}=await this._createGeometry(e,i);return this._draped?new Y(e,i,r,s,this.layerView):new Z(e,i,r,s,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new ie(this._materialParameters,this.view.state.isGlobal),s=new Array,{elevationInfo:r,_draped:l,view:n}=this;function*o(o){for(let a=0;a<t.length;++a)s.push(K(n,e,t[a],r,i,l)),o.madeProgress(),o.done&&(o=yield)}return await this.frameTask.scheduleGenerator(o),{geometries:s,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(l(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:s,loadAllTiles:r}=this;if(r){const{loadAllTilesLevel:t}=this;return i=>i.level===t&&ae(e,i.extent)}const l=t=>t.rendered&&t.visible&&ae(e,t.extent),{featureTiles:n}=i;if(!n)return l;const o=n.tiles.filter(e=>e.measures.visible);return e=>l(e)&&ae(s,e.extent)&&o.some(({lij:i})=>t(i,e.lij)||ee(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+D?"transitioning":"ready-to-load"}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([g()],ne.prototype,"type",void 0),e([g()],ne.prototype,"renderedTiles",void 0),e([g()],ne.prototype,"_resources",void 0),e([g()],ne.prototype,"_lastResources",void 0),e([g()],ne.prototype,"requireLoad",void 0),e([g()],ne.prototype,"_averageLoadingTime",void 0),e([g()],ne.prototype,"_loadingState",void 0),e([g()],ne.prototype,"emissiveStrength",void 0),e([g()],ne.prototype,"_clippingArea",null),e([g()],ne.prototype,"_dataBounds",null),e([g()],ne.prototype,"_fullExtentSurfaceSpatialReference",null),e([g()],ne.prototype,"_draped",null),e([g()],ne.prototype,"extent",null),e([g()],ne.prototype,"loadAllTiles",null),e([g()],ne.prototype,"isDataGlobal",null),e([g()],ne.prototype,"loadAllTilesLevel",null),e([g()],ne.prototype,"targetTiles",null),e([g()],ne.prototype,"_featureTilesBounds",null),e([g()],ne.prototype,"_flowRenderer",null),e([g()],ne.prototype,"_materialParameters",null),e([g()],ne.prototype,"_opacity",null),e([g()],ne.prototype,"_seamlessTransitionWaitingTime",null),e([g()],ne.prototype,"_seamlessTransitionEnabled",null),e([g()],ne.prototype,"_tracingResolution",null),e([g()],ne.prototype,"_visible",null),e([g()],ne.prototype,"_estimatedStreamlines",null),e([g()],ne.prototype,"_effectiveDensity",null),e([g()],ne.prototype,"elevationInfo",null),e([g()],ne.prototype,"needsMagnitude",null),e([g()],ne.prototype,"spatialReferenceInfo",null),e([g()],ne.prototype,"layer",null),e([g()],ne.prototype,"loadingState",null),e([g()],ne.prototype,"updating",null),e([g()],ne.prototype,"visibleAtCurrentScale",null),e([g()],ne.prototype,"_overrideMaterialParameters",void 0),e([g()],ne.prototype,"_overrideSimulationSettings",void 0),e([g()],ne.prototype,"_overrideTransitionEnabled",void 0),e([g()],ne.prototype,"_simulationSettings",null),e([g()],ne.prototype,"surface",null),ne=e([m("esri.views.3d.layers.FlowSubView3D")],ne);const oe=new x({mode:"on-the-ground"});function ae(e,t){return null==e||null==t||b(e,t)}export{ne as default};
5
+ import{__decorate as e}from"tslib";import{equals as t}from"../../../core/arrayUtils.js";import"../../../core/has.js";import{removeMaybe as i,abortMaybe as r}from"../../../core/maybe.js";import{debounce as s,ignoreAbortErrors as l,throwIfAborted as n}from"../../../core/promiseUtils.js";import{watch as o,when as a,sync as u,whenOnce as d}from"../../../core/reactiveUtils.js";import{addFrameTask as h}from"../../../core/scheduling.js";import{Seconds as p,secondsFromMilliseconds as c}from"../../../core/time.js";import{property as m,subclass as g}from"../../../core/accessorSupport/decorators.js";import{projectOrLoad as f}from"../../../geometry/projectionUtils.js";import _ from"../../../geometry/SpatialReference.js";import{fromExtent as y,intersection as v,toExtent as T,create as w,contains as S,area as b,intersects as R}from"../../../geometry/support/aaBoundingRect.js";import{getInfo as x}from"../../../geometry/support/spatialReferenceUtils.js";import L from"../../../symbols/support/ElevationInfo.js";import{simulationSettingsEqual as A,getPositions as j,getFlowSimulationSettings as M}from"../../2d/engine/flow/utils.js";import E from"./SubView3D.js";import{getFeatureTileId as U}from"./support/FeatureTileDescriptor.js";import{makeScheduleFunction as P}from"./support/makeScheduleFunction.js";import{debugFlags as I}from"../support/debugFlags.js";import{tileFilterDistance as C,scaleThresholdForLoadingAllTiles as F,fadeOutTime as D,fadeInTime as W,defaultTransitionDuration as q,transitionDurationFactor as k,seamlessTransitionEnabled as O,densityFactor as V,loadAllTilesDensityFactor as G,averageLoadingTimeSmoothingFactor as B,minimumTracingResolution as H}from"../support/flow/constants.js";import{isFullExtent as z,wrappedWidth as N,FlowQuery3D as Q}from"../support/flow/FlowQuery3D.js";import{FlowWorkerHandle as J}from"../support/flow/FlowWorkerHandle.js";import{materialParametersFromRenderer as K,createStreamlineGeometry as X}from"../support/flow/geometryUtils.js";import{boundingRectOfTiles as Y}from"../support/flow/loadUtils.js";import{StreamlineResources3DOverlay as Z}from"../support/flow/StreamlineResources3DOverlay.js";import{StreamlineResources3DShape as $}from"../support/flow/StreamlineResources3DShape.js";import{webMercatorWorldExtent as ee}from"../terrain/TerrainConst.js";import{descendantsAtLevel as te,tilesAreRelated as ie}from"../terrain/tileUtils.js";import{isScreenSizePerspectiveEnabled as re}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{RibbonLineMaterial as se}from"../webgl-engine/materials/RibbonLineMaterial.js";import{isInEffectiveScaleRange as le,hasLayerBasedScaleVisibility as ne}from"../../support/layerViewUtils.js";import{TaskPriority as oe}from"../../support/Scheduler.js";let ae=class extends E{constructor(e){super(e),this.type="flow",this.renderedTiles=null,this.requireLoad=!1,this.workerHandle=null,this.frameTask=null,this._averageLoadingTime=p(0),this._abortController=null,this._loadingState="ready-to-load",this._tilesUpdateIsWaiting=!1,this._debugAllowAutoLoading=!0,this.emissiveStrength=0,this._overrideMaterialParameters=null,this._overrideSimulationSettings=null,this._overrideTransitionEnabled=null,this._updateTask=null,this._debouncedTileUpdate=s(async()=>{const{allTiles:e}=this.surface,t=this._getTileFilterFunction(),i=new Set;function*r(r){for(let s=0;s<e.length;++s){const l=e.at(s);t(l)&&i.add(l),r.madeProgress(),r.done&&(r=yield)}}await this.frameTask.scheduleGenerator(r),this.renderedTiles=i})}initialize(){const{surface:e,view:t}=this,{resourceController:i}=t;this.workerHandle=new J(P(i)),this.frameTask=i.scheduler.registerTask(oe.FLOW_GENERATOR),this._updateTask=h({update:e=>this._update(e)}),this.addHandles([o(()=>this._simulationSettings,()=>this.triggerLoad(),{sync:!0,equals:(e,t)=>null==e&&null==t||null!=e&&null!=t&&A(e,t)}),o(()=>{const{elevationInfo:e}=this;return[this._clippingArea,this._visible,this._draped,this.view.state.contentPixelRatio,this.view.viewingMode,e?.mode,e?.offset,e?.unit,this._effectiveDensity]},()=>this.triggerLoad(),u),o(()=>this._materialParameters,e=>{this._resources?.setMaterialParameters(e),this._lastResources?.setMaterialParameters(e)}),a(()=>e.allTilesCreated,()=>this._triggerTilesUpdate,u),t.enableFeatureTiles(),o(()=>[this._dataBounds,this._featureTilesBounds,this.loadAllTiles],()=>this._triggerTilesUpdate()),o(()=>this._flowRenderer,(e,t)=>{const i=t?.visualVariables??[],r=e?.visualVariables??[];r.length===i.length&&r.every((e,t)=>e.type===i[t].type)||this.clear()}),a(()=>!t.featureTiles?.updating,()=>{this._triggerTilesUpdate()})]),this._triggerTilesUpdate()}destroy(){this._updateTask=i(this._updateTask),this.abort(),this.clear()}abort(){this._abortController=r(this._abortController),this.requireLoad=!1}get _clippingArea(){const e=f(this.view.clippingArea,this.surface.spatialReference).geometry;return null==e?null:y(e)}get _dataBounds(){const e=this._fullExtentSurfaceSpatialReference;return null==e?null:y(e)}get _fullExtentSurfaceSpatialReference(){return f(this.layer.fullExtent,this.surface.spatialReference).geometry}get _draped(){return"on-the-ground"===this.elevationInfo.mode}get extent(){if(this.loadAllTiles)return pe(this._fullExtentSurfaceSpatialReference);const{spatialReference:e}=this.surface;let t=this.renderedTiles;if(null==e||null==t)return null;const i=this.view.terrainLevel;if(null!=i){const e=new Set;t.forEach(t=>{Math.abs(i-t.level)<C&&e.add(t)}),t=e}const r=Y(t,this.spatialReferenceInfo);return null==r?null:(v(r,this._clippingArea,r),pe(T(r,e)))}get loadAllTiles(){return this.view.scale>(I.FLOW_GLOBAL_SCALE_THRESHOLD??F)}get isDataGlobal(){const{extent:e,spatialReferenceInfo:t}=this;return null!=e&&z(e.xmin,e.xmax,t)}get loadAllTilesLevel(){const{tilingScheme:e}=this.surface;return Math.min(Math.ceil(e.levelAtScale(I.FLOW_GLOBAL_SCALE_THRESHOLD??F)),e.getMaxLod())}get targetTiles(){const e=new Map;if(this.loadAllTiles){const{_dataBounds:t}=this;if(null==t)return e;const i=w(),r=this.loadAllTilesLevel,s=this.surface.tilingScheme,l=s.rootTilesInExtent(t).flatMap(e=>te(e,r));for(const n of l){const[l,o,a]=n;s.getExtent(r,o,a,i),de(t,i)&&e.set(U(r,o,a),n)}return e}const{renderedTiles:t}=this;for(const i of t??[])e.set(i.key,i.lij);return e}get _featureTilesBounds(){const e=this.view.featureTiles?.filterExtent,t=f(e,this.surface.spatialReference).geometry;return null==t?null:y(t)}get _flowRenderer(){const e=this.layer.renderer;return"flow"!==e?.type?null:e}get _materialParameters(){return{...K(this._flowRenderer,this.layerView.fullOpacity,this.emissiveStrength),fadeInTime:W,fadeOutTime:D,...this._overrideMaterialParameters,hasSlicePlane:this.layerView.slicePlaneEnabled,screenSizePerspective:!this._draped&&re(this.layer.screenSizePerspectiveEnabled)?this.view.screenSizePerspective.parameters:null}}get _opacity(){return this.layerView.fullOpacity}get _seamlessTransitionWaitingTime(){const{_averageLoadingTime:e}=this;return p(0===e?q:this._averageLoadingTime*k)}get _seamlessTransitionEnabled(){return null!=this._overrideTransitionEnabled?this._overrideTransitionEnabled:O}get _tracingResolution(){const{extent:e}=this;if(!e)return[0,0];const t=N(e.xmin,e.xmax,this.spatialReferenceInfo?.valid)/(e.ymax-e.ymin),[i,r]=this.view.size;let s,l;i<r?(s=i,l=i/t):(s=r*t,l=r);const n=H,o=this.view.qualitySettings.flow.maxTracingResolution,a=Math.max(1,n/Math.min(s,l)),u=a*Math.min(1,o/Math.max(s*a,l*a));return[Math.round(s*u),Math.round(l*u)]}get _visible(){const e=this._flowRenderer?.color;return this.visibleAtCurrentScale&&this.layer.effectiveVisible&&this._opacity>0&&(null==e||e.a>0)}get _estimatedStreamlines(){const{extent:e,_simulationSettings:t,renderedTiles:i,loadAllTiles:r}=this;if(null==t||null==i)return 0;const s=this._tracingResolution[0]*this._tracingResolution[1]/t.lineSpacing**2*t.density;if(r)return 2*s;const l=null==e?null:y(e);if(null==l)return 0;let n=0;for(const u of i)S(l,u.extent)&&(n+=b(u.extent));const o=b(l),a=0===o?0:n/o;return 2*Math.round(s*a)}get _effectiveDensity(){const{_estimatedStreamlines:e,_simulationSettings:t}=this,{qualitySettings:i,quality:r}=this.view;if(null==t)return 0;const s=i.flow.maxTotalNumberOfStreamlines,l=e>=s?s/e:1,n=t.density*l*r;return t.lineSpacing/Math.sqrt(n)<t.lineCollisionWidth?(t.lineSpacing/t.lineCollisionWidth)**2:n}get elevationInfo(){return this.layer.elevationInfo??ue}startPositions(e){if(!this._seamlessTransitionEnabled)return[];const{_flowRenderer:t,_resources:i}=this;return null==t||null==i?[]:j(i.streamlines,i.query,e,t.flowSpeed)}get needsMagnitude(){return this._flowRenderer?.hasVisualVariables()??!1}get spatialReferenceInfo(){return x(this.surface.spatialReference)}get layer(){return this.layerView.layer}get loadingState(){return this._loadingState}get loadRequirementsMet(){return null!=this.renderedTiles&&(this.renderedTiles.size>0||this.loadAllTiles)&&null!=this.extent}getUpdating(){return!this.destroyed&&(null==this.extent||this.updatingHandles.updating||this.requireLoad||"before-transition"===this._loadingState)}get updating(){return this.getUpdating()}get visibleAtCurrentScale(){return!ne()||le(this.layer.effectiveScaleRange,this.view.scale)}get _simulationSettings(){const{_flowRenderer:e,_overrideSimulationSettings:t}=this;if(null==e)return null;let i=M(e);return i.segmentLength=i.lineCollisionWidth/2,i.onlyForwardTracing=!1,i.density*=V,this.loadAllTiles&&this.isDataGlobal&&(i.density*=G),null!=t&&(i={...i,...t}),i}getSimulationSettings(e){const{_simulationSettings:t,spatialReferenceInfo:i}=this;if(null==t)return null;const r="global"===this.view.viewingMode&&null!=i&&z(e.extent.xmin,e.extent.xmax,i);return{...t,wrapAround:r,density:this._effectiveDensity}}get surface(){return this.view.basemapTerrain}doRefresh(){this.triggerLoad()}clear(){this._resources?.detach(),this._resources=null,this._lastResources?.detach(),this._lastResources=null,this._loadingState="ready-to-load"}_update(e){const t=c(e.time);this._lastResources?.hasFadedOut(t)&&this._lastResources.detach();const i=this._nextStateForTransition(t);if(!this.requireLoad||this.updatingHandles.updating||"ready-to-load"!==i||!this.loadRequirementsMet)return void(this._loadingState=i);this._loadingState="loading";const r=async()=>{const e=performance.now(),i=this._seamlessTransitionEnabled&&null!=this._resources?p(t+this._seamlessTransitionWaitingTime):t;await this._load(i);const r=p((performance.now()-e)/1e3);this._updateAverageLoadingTime(r)};this.updatingHandles.addPromise(l(r())),this.requireLoad=!1}_updateAverageLoadingTime(e){const t=B;this._averageLoadingTime=p(t*e+(1-t)*this._averageLoadingTime)}triggerLoad(){this._debugAllowAutoLoading&&(this.requireLoad=!0)}async _load(e){const{extent:t,view:i}=this;if(!this._visible)return this.clear(),void(this._loadingState="ready-to-load");if(null==t)return void(this._loadingState="ready-to-load");const r=new Q(t,this.layerView.timeExtent,this._tracingResolution,i.state.contentPixelRatio,e);null==this._abortController&&(this._abortController=new AbortController);const s=this._abortController,l=await this._loadStreamlines(r,s.signal);if(n(s.signal),this._visible&&null!=l){this._lastResources?.detach(),this._lastResources=this._resources,this._resources=l;const t=performance.now()/1e3,i=t>e?t:e;null!=this._lastResources&&(this._lastResources.endTime=i),this._resources.startTime=i,await l.attach(),this._loadingState=this._seamlessTransitionEnabled?"before-transition":"transitioning"}else this._loadingState="ready-to-load"}async _loadStreamlines(e,t){const i=await this.fetchDataAndGenerateStreamlines(e,t);if(null==i)return null;const{geometries:r,material:s}=await this._createGeometry(e,i);return this._draped?new Z(e,i,s,r,this.layerView):new $(e,i,s,r,this.view)}async fetchDataAndGenerateStreamlines(e,t){return null}async _createGeometry(e,t){const i=new se(this._materialParameters,this.view.state.isGlobal),r=new Array,{elevationInfo:s,_draped:l,view:n}=this;function*o(o){for(let a=0;a<t.length;++a)r.push(X(n,e,t[a],s,i,l)),o.madeProgress(),o.done&&(o=yield)}return await this.frameTask.scheduleGenerator(o),{geometries:r,material:i}}_triggerTilesUpdate(){if(this._tilesUpdateIsWaiting)return;this._tilesUpdateIsWaiting=!0;const e=async()=>{await d(()=>this.view.stationary),this._tilesUpdateIsWaiting=!1,await this._debouncedTileUpdate()};this.updatingHandles.addPromise(l(e()))}_getTileFilterFunction(){const{_dataBounds:e,view:i,_featureTilesBounds:r,loadAllTiles:s}=this;if(s){const{loadAllTilesLevel:t}=this;return i=>i.level===t&&de(e,i.extent)}const l=t=>t.rendered&&t.visible&&de(e,t.extent),{featureTiles:n}=i;if(!n)return l;const o=n.tiles.filter(e=>e.measures.visible);return e=>l(e)&&de(r,e.extent)&&o.some(({lij:i})=>t(i,e.lij)||ie(i,e.lij))}_nextStateForTransition(e){const{_resources:t}=this;if(null==this._flowRenderer||null==t||"ready-to-load"===this._loadingState||"loading"===this._loadingState)return this._loadingState;const i=t.startTime;return e<i?"before-transition":e<i+D?"transitioning":"ready-to-load"}get usedMemory(){return(this._lastResources?.usedMemory??0)+(this._resources?.usedMemory??0)}get test(){}};e([m()],ae.prototype,"type",void 0),e([m()],ae.prototype,"renderedTiles",void 0),e([m()],ae.prototype,"_resources",void 0),e([m()],ae.prototype,"_lastResources",void 0),e([m()],ae.prototype,"requireLoad",void 0),e([m()],ae.prototype,"_averageLoadingTime",void 0),e([m()],ae.prototype,"_loadingState",void 0),e([m()],ae.prototype,"emissiveStrength",void 0),e([m()],ae.prototype,"_clippingArea",null),e([m()],ae.prototype,"_dataBounds",null),e([m()],ae.prototype,"_fullExtentSurfaceSpatialReference",null),e([m()],ae.prototype,"_draped",null),e([m()],ae.prototype,"extent",null),e([m()],ae.prototype,"loadAllTiles",null),e([m()],ae.prototype,"isDataGlobal",null),e([m()],ae.prototype,"loadAllTilesLevel",null),e([m()],ae.prototype,"targetTiles",null),e([m()],ae.prototype,"_featureTilesBounds",null),e([m()],ae.prototype,"_flowRenderer",null),e([m()],ae.prototype,"_materialParameters",null),e([m()],ae.prototype,"_opacity",null),e([m()],ae.prototype,"_seamlessTransitionWaitingTime",null),e([m()],ae.prototype,"_seamlessTransitionEnabled",null),e([m()],ae.prototype,"_tracingResolution",null),e([m()],ae.prototype,"_visible",null),e([m()],ae.prototype,"_estimatedStreamlines",null),e([m()],ae.prototype,"_effectiveDensity",null),e([m()],ae.prototype,"elevationInfo",null),e([m()],ae.prototype,"needsMagnitude",null),e([m()],ae.prototype,"spatialReferenceInfo",null),e([m()],ae.prototype,"layer",null),e([m()],ae.prototype,"loadingState",null),e([m()],ae.prototype,"updating",null),e([m()],ae.prototype,"visibleAtCurrentScale",null),e([m()],ae.prototype,"_overrideMaterialParameters",void 0),e([m()],ae.prototype,"_overrideSimulationSettings",void 0),e([m()],ae.prototype,"_overrideTransitionEnabled",void 0),e([m()],ae.prototype,"_simulationSettings",null),e([m()],ae.prototype,"surface",null),ae=e([g("esri.views.3d.layers.FlowSubView3D")],ae);const ue=new L({mode:"on-the-ground"});function de(e,t){return null==e||null==t||R(e,t)}const he=T(ee,_.WebMercator);function pe(e){return null!=e&&e.spatialReference.isWebMercator?e?.intersection(he):e}export{ae 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t}from"../../../core/arrayUtils.js";import{isArrayBuffer as r}from"../../../core/typedArrayUtil.js";import{conjugate as e}from"../../../core/libs/gl-matrix-2/math/quat.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{r as a}from"../../../chunks/vec32.js";import{clone as i,create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import n from"../../../geometry/SpatialReference.js";import{projectBuffer as s}from"../../../geometry/projection/projectBuffer.js";import{readGeometry as u,getAttributeValues as l,evaluateRenderer as m,filterInPlace as b}from"./i3s/PointCloudWorkerUtil.js";import{Obb as p}from"../support/orientedBoundingBox.js";class c{transform(t){const e=this._transform(t),o=[e.points.buffer,e.rgb.buffer];null!=e.pointIdFilterMap&&o.push(e.pointIdFilterMap.buffer);for(const a of e.attributes)"buffer"in a.values&&r(a.values.buffer)&&a.values.buffer!==e.rgb.buffer&&o.push(a.values.buffer);return Promise.resolve({result:e,transferList:o})}_transform(r){const e=u(r.schema,r.geometryBuffer);let o=e.length/3,a=null;const i=new Array,f=l(r.primaryAttributeData,e,o);null!=r.primaryAttributeData&&f&&i.push({attributeInfo:r.primaryAttributeData.attributeInfo,values:f});const s=l(r.modulationAttributeData,e,o);null!=r.modulationAttributeData&&s&&i.push({attributeInfo:r.modulationAttributeData.attributeInfo,values:s});let c=m(r.rendererInfo,f,s,o);if(r.filterInfo&&r.filterInfo.length>0&&null!=r.filterAttributesData){const f=r.filterAttributesData.filter(t).map(t=>{const r=l(t,e,o),a={attributeInfo:t.attributeInfo,values:r};return i.push(a),a});a=new Uint32Array(o),o=b(e,c,a,r.filterInfo,f)}for(const t of r.userAttributesData){const r=l(t,e,o);i.push({attributeInfo:t.attributeInfo,values:r})}3*o<c.length&&(c=new Uint8Array(c.buffer.slice(0,3*o))),I(e,o,r.elevationOffset);const A=h(e,o,p.fromData(r.obbData),n.fromJSON(r.inSR),n.fromJSON(r.outSR));return{obbData:r.obbData,points:A,rgb:c,attributes:i,pointIdFilterMap:a}}}function h(t,r,o,n,u){if(!s(t,n,0,t,u,0,r))throw new Error("Can't reproject");const l=i(o.center),m=f(),b=f(),p=i(o.halfSize);e(A,o.quaternion);const c=new Float32Array(3*r);for(let e=0;e<r;e++){let r=3*e;m[0]=t[r]-l[0],m[1]=t[r+1]-l[1],m[2]=t[r+2]-l[2],a(b,m,A),p[0]=Math.max(p[0],Math.abs(b[0])),p[1]=Math.max(p[1],Math.abs(b[1])),p[2]=Math.max(p[2],Math.abs(b[2])),c[r++]=m[0],c[r++]=m[1],c[r]=m[2]}return o.halfSize=p,c}function I(t,r,e){if(0!==e)for(let o=0;o<r;o++)t[3*o+2]+=e}const A=o();function g(){return new c}export{g as default};
5
+ import{isSome as t}from"../../../core/arrayUtils.js";import{isArrayBuffer as r}from"../../../core/typedArrayUtil.js";import{conjugate as e}from"../../../core/libs/gl-matrix-2/math/quat.js";import{create as o}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{r as a}from"../../../chunks/vec32.js";import{clone as i,create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import n from"../../../geometry/SpatialReference.js";import{projectBuffer as s}from"../../../geometry/projection/projectBuffer.js";import{readGeometry as u,getAttributeValues as l,evaluateRenderer as m,filterInPlace as b}from"./i3s/PointCloudWorkerUtil.js";import{Obb as p}from"../support/orientedBoundingBox.js";class c{transform(t){const e=this._transform(t),o=[e.points.buffer,e.rgb.buffer];null!=e.pointIdFilterMap&&o.push(e.pointIdFilterMap.buffer);for(const a of e.attributes)"buffer"in a.values&&r(a.values.buffer)&&a.values.buffer!==e.rgb.buffer&&o.push(a.values.buffer);return Promise.resolve({result:e,transferList:o})}_transform(r){const e=u(r.schema,r.geometryBuffer);let o=e.length/3,a=null;const i=new Array,f=l(r.primaryAttributeData,e,o);null!=r.primaryAttributeData&&f&&i.push({attributeInfo:r.primaryAttributeData.attributeInfo,values:f});const s=l(r.modulationAttributeData,e,o);null!=r.modulationAttributeData&&s&&i.push({attributeInfo:r.modulationAttributeData.attributeInfo,values:s});let c=m(r.rendererInfo,f,s,o);if(r.filterInfo&&r.filterInfo.length>0&&null!=r.filterAttributesData){const f=r.filterAttributesData.filter(t).map(t=>{const r=l(t,e,o),a={attributeInfo:t.attributeInfo,values:r};return i.push(a),a});a=new Uint32Array(o),o=b(e,c,a,r.filterInfo,f)}for(const t of r.userAttributesData){const r=l(t,e,o);i.push({attributeInfo:t.attributeInfo,values:r})}3*o<c.length&&(c=c.slice(0,3*o)),I(e,o,r.elevationOffset);const g=h(e,o,p.fromData(r.obbData),n.fromJSON(r.inSR),n.fromJSON(r.outSR));return{obbData:r.obbData,points:g,rgb:c,attributes:i,pointIdFilterMap:a}}}function h(t,r,o,n,u){if(!s(t,n,0,t,u,0,r))throw new Error("Can't reproject");const l=i(o.center),m=f(),b=f(),p=i(o.halfSize);e(g,o.quaternion);const c=new Float32Array(3*r);for(let e=0;e<r;e++){let r=3*e;m[0]=t[r]-l[0],m[1]=t[r+1]-l[1],m[2]=t[r+2]-l[2],a(b,m,g),p[0]=Math.max(p[0],Math.abs(b[0])),p[1]=Math.max(p[1],Math.abs(b[1])),p[2]=Math.max(p[2],Math.abs(b[2])),c[r++]=m[0],c[r++]=m[1],c[r]=m[2]}return o.halfSize=p,c}function I(t,r,e){if(0!==e)for(let o=0;o<r;o++)t[3*o+2]+=e}const g=o();function j(){return new c}export{j 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as i}from"tslib";import t from"../../../../core/Accessor.js";import{lerp as e}from"../../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{transpose as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as l,j as h,h as u,d}from"../../../../chunks/vec32.js";import{ZEROS as p,create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as y,t as f,s as g}from"../../../../chunks/vec42.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{create as O,empty as w,copy as D,offset as G,width as I,height as j,expand as k}from"../../../../geometry/support/aaBoundingRect.js";import{e as Q,a as P,d as C}from"../../../../chunks/boundedPlane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as T,sphereCSO as V}from"../../../../geometry/support/sphere.js";import{DeconflictAABR as x}from"./DeconflictAABR.js";import{prepare as R,drawPoly as A}from"./deconflictorDebug.js";import U from"../../webgl/RenderCamera.js";import{GPUPointOcclusionQuery as H}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as M}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as N}from"../../webgl-engine/materials/HUDMaterial.js";import{Yield as E}from"../../../support/Yield.js";const z=_(),F=_(),B=m(),W=m(),L=_(),q=n(),Y=new T,J=S(),K=_(),X=O();class Z{constructor(i){this.id=i,this.aabr=O(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function $(i,t){const e=0!==i.distanceToOccluder&&i.distance>i.distanceToOccluder,s=0!==t.distanceToOccluder&&t.distance>t.distanceToOccluder;return e!==s?+e-+s:i.priority!==t.priority?t.priority-i.priority:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?+t.visible-+i.visible:i.id-t.id}class ii{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(i){let t=this.getInfo(i);return t||(t=new Z(this.graphics3DGraphic.graphic.uid),this._setInfo(i,t)),t}getInfo(i){return 16===i?this._labelInfo:this._info}removeInfo(i){this._setInfo(i,null)}_setInfo(i,t){16===i?this._labelInfo=t:this._info=t}}class ti{constructor(){this.camera=new U,this.slicePlane=P(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.equals(i.camera)||this.camera.copyFrom(i.camera),C(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let ei=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ti,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=new Array,this._updatingHandles=new v,this._deconflictor=new x((i,t)=>{i.visible=t,this._setGraphicVisibility(this._active.get(i.id),t)},(i,t)=>i.id!==t.id,$),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange("_readyToRun"))}setPriority(i,t){const e=this._active.get(i.graphic.uid)?.getInfo(this.visibilityGroup);e&&(e.priority=t)}get _readyToRun(){return 0!==this._state||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;const i=this._state/5;return this._dirty?.5*i:i}get readyToRun(){return this.view.ready&&null!=this.view.state&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+4*(this._occlusionQueryUids?.length??0)}runTask(i){switch(this._state){case 0:this._startUpdate(),i.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(i))return;case 2:if(this._state=2,this._occlusionQuery&&!this._occlusionQuery.done)return E;this._readOcclusionQueryResult(),i.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(i))return;case 4:if(this._state=4,this._deconflictor.run(i),!this._deconflictor.done)return;default:this._state=0,this.notifyChange("_readyToRun")}}setGraphicsActive(i,t){t?i.forEach(i=>this.addToActiveGraphics(i)):i.forEach(i=>this.removeFromActiveGraphics(i))}layerSupportsDeconfliction(i){if(null==i||"object3d"!==i.type)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const e=t?.geometries[0],s=e?.material;return s instanceof N}_startUpdate(){R(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(i,t),this._resetIterators(),this._occlusionQueryUids.length=0,this._checkOcclusion.size||(this._occlusionQuery=s(this._occlusionQuery))}addToActiveGraphics(i){i.ensureInfo(this.visibilityGroup),this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){si(i,this.visibilityGroup),i.removeInfo(this.visibilityGroup),this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}addToCheckOcclusion(i){this._checkOcclusion.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromCheckOcclusion(i){this._checkOcclusion.delete(i.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(i){if(0===this._checkOcclusion.size)return!0;const t=this._ensureCheckOcclusionIterator(),e=this._viewState.camera,r=c(q,e.viewInverseTransposeMatrix),o=this.view.map.ground.opacity>0,n="global"===this.view.viewingMode&&o&&e.relativeElevation>0?Y:null;let a=0;null!=n&&(l(n.center,p,e.viewMatrix),n.radius=b(this.view.spatialReference).radius,a=V.distanceToSilhouette(n,p));const h=O();for(;;){if(i.done)return!1;i.madeProgress();const s=t.next();if(!0===s.done)break;const o=s.value,c=o.graphics3DGraphic;if(c.destroyed)continue;if(!c.isVisible(1,8))continue;const u=ni(c,this.visibilityGroup);let d=null,p=!0;for(const i of u){if(!this.layerSupportsDeconfliction(i))continue;d=ai,this._projectHudLayer(i,e,d),w(h);const t=i.stageObject.geometries[0].material;if(this._expandBoundingRect(h,e,i,t,d),d.isOutsideScreen){p=!1;break}if(this._isCulledBySlice(o,d.positionView)){p=!1;break}if(null!=n&&ci(d,n,a)){p=!1;break}l(F,d.positionView,r),d.altitude=this.view.renderCoordsHelper.getAltitude(F);const s=o.ensureInfo(this.visibilityGroup);if(s.altitude=d.altitude,s.distance=d.distance,s.distanceToOccluder=d.distanceToOccluder,s.culled=!1,D(s.aabr,h),t.parameters.occlusionTest)break;this._ensureOcclusionQuery().addPosition(F)===this._occlusionQueryUids.length&&this._occlusionQueryUids.push(c.graphic.uid);break}if(this._active.has(c.graphic.uid)&&(!p||!d)){const i=o.ensureInfo(this.visibilityGroup);i.visible=!d,i.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=s(this._occlusionQuery)),this._occlusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;const i=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(i.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){const i=this._occlusionQueryUids[e],s=this._checkOcclusion.get(i);if(!s)continue;const r=this._occlusionQuery.getOcclusion(e)??-1,o=s.getInfo(this.visibilityGroup);o&&(o.distanceToOccluder=r>0?o.distance-r:0);const c=r<=0||this._occludedVisibility(o?.distanceToOccluder??0,o?.distance??r,o?.altitude??0,t);this._active.has(i)?o&&(o.culled=!c,o.visible=c):this._setGraphicVisibility(s,c)}this._occlusionQueryUids.length=0}_collectActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),e=16===this.visibilityGroup;for(;!i.done;){i.madeProgress();const s=t.next();if(!0===s.done)return this._activeIterator=null,!0;const r=s.value,o=r.getInfo(this.visibilityGroup);if(!o)continue;!(!e||r.graphics3DGraphic.isVisible())||o.culled?(A(o.aabr,!1,!0),this._setGraphicVisibility(r,o.visible)):this._deconflictor.add(o)}return!1}_occludedVisibility(i,t,e,s){const r=Math.max(this._minAltitudeDifference,Math.abs(e-s))-this._minAltitudeDifference;return 0===i||t-i<=this._baseOccludedVisibility+this._altitudeFactor*r}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_ensureOcclusionQuery(){return this._occlusionQuery??=new H({view:this.view}),this._occlusionQueryUids.length||this._occlusionQuery.init(this._checkOcclusion.size,this._viewState.camera.eye),this._occlusionQuery}_projectHudLayer(i,t,e){const s=i.stageObject,r=s.geometries[0],o=r.material;l(z,s.boundingVolumeWorldSpace.bounds.center,t.viewMatrix);const c=r.attributes,n=c.get("normal").data,a=c.get("centerOffsetAndDistance").data;o.applyShaderOffsetsView(z,n,s.transformation,a,t,e.screenSizePerspectiveEvaluators,z),y(B,z[0],z[1],z[2],1),f(W,B,t.projectionMatrix),h(e.positionNDC,W,1/W[3]),o.applyShaderOffsetsNDC(e.positionNDC,a,t,e.positionNDC,L),e.distanceWithoutPolygonOffset=t.depthNDCToWorld(L[2]),e.distance=L[2]===e.positionNDC[2]?e.distanceWithoutPolygonOffset:t.depthNDCToWorld(e.positionNDC[2]),y(W,e.positionNDC[0],e.positionNDC[1],e.positionNDC[2],1),f(B,W,t.inverseProjectionMatrix),g(B,B,1/B[3]),u(e.positionView,z[0],z[1],z[2])}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&Q(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,s,r,{positionNDC:o,screenSizePerspectiveEvaluators:c}){const n=s.getScreenSize(ri);c.evaluator.applyVec2(n,n),n[0]*=t.pixelRatio,n[1]*=t.pixelRatio;const a=G(r.calculateRelativeScreenBounds(n,c.alignmentEvaluator.apply(t.pixelRatio),X),e(0,t.fullWidth,.5+.5*o[0]),e(0,t.fullHeight,.5+.5*o[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(I(a),j(a));a[0]-=i,a[1]-=i,a[2]+=i,a[3]+=i}k(i,a,i)}_setGraphicVisibility(i,t){const e=i?.graphics3DGraphic;e&&!e.destroyed&&(e.setVisibilityFlag(this.visibilityGroup,8,t),16===this.visibilityGroup&&this.view.labeler.setLabelGraphicVisibility(e,t))}};function si(i,t){const e=i.graphics3DGraphic;e.destroyed||e.setVisibilityFlag(t,8,!0)}i([r({constructOnly:!0})],ei.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],ei.prototype,"_readyToRun",null),i([r({type:Boolean,readOnly:!0})],ei.prototype,"updating",null),i([r({readOnly:!0})],ei.prototype,"_updatingHandles",void 0),ei=i([o("esri.views.3d.layers.graphics.Deconflictor")],ei);const ri=a();class oi{constructor(){this.positionView=_(),this.positionNDC=_(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new M}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1||i[2]>=1}}function ci(i,t,e){return d(J.direction,i.positionView),u(J.origin,0,0,0),!!t.intersectRay(J,K)&&i.distanceWithoutPolygonOffset>e}function ni(i,t){return 16===t?i.labelLayers:i.layers}const ai=new oi;export{ei as Deconflictor,ii as DeconflictorGraphic,ti as DeconflictorViewState};
5
+ import{__decorate as i}from"tslib";import t from"../../../../core/Accessor.js";import{lerp as e}from"../../../../core/mathUtils.js";import{destroyMaybe as s}from"../../../../core/maybe.js";import{property as r,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{transpose as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{p as l,j as h,h as u,d}from"../../../../chunks/vec32.js";import{ZEROS as p,create as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as y,t as f,s as g}from"../../../../chunks/vec42.js";import{create as m}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as v}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{create as O,empty as w,copy as D,offset as G,width as I,height as j,expand as k}from"../../../../geometry/support/aaBoundingRect.js";import{e as Q,a as P,d as C}from"../../../../chunks/boundedPlane.js";import{create as S}from"../../../../geometry/support/ray.js";import{Sphere as T,sphereCSO as V}from"../../../../geometry/support/sphere.js";import{DeconflictAABR as x}from"./DeconflictAABR.js";import{prepare as R,drawPoly as A}from"./deconflictorDebug.js";import U from"../../webgl/RenderCamera.js";import{GPUPointOcclusionQuery as H}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as M}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as N}from"../../webgl-engine/materials/HUDMaterial.js";import{Yield as E}from"../../../support/Yield.js";const z=_(),F=_(),B=m(),W=m(),L=_(),q=n(),Y=new T,J=S(),K=_(),X=O();class Z{constructor(i){this.id=i,this.aabr=O(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function $(i,t){const e=0!==i.distanceToOccluder&&i.distance>i.distanceToOccluder,s=0!==t.distanceToOccluder&&t.distance>t.distanceToOccluder;return e!==s?+e-+s:i.priority!==t.priority?t.priority-i.priority:i.distance!==t.distance?i.distance-t.distance:i.visible!==t.visible?+t.visible-+i.visible:i.id-t.id}class ii{constructor(i,t){this.graphics3DGraphic=i,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(i){let t=this.getInfo(i);return t||(t=new Z(this.graphics3DGraphic.graphic.uid),this._setInfo(i,t)),t}getInfo(i){return 16===i?this._labelInfo:this._info}removeInfo(i){this._setInfo(i,null)}_setInfo(i,t){16===i?this._labelInfo=t:this._info=t}}class ti{constructor(){this.camera=new U,this.slicePlane=P(),this.slicePlaneEnabled=!1}copyFrom(i){this.camera.equals(i.camera)||this.camera.copyFrom(i.camera),C(i.slicePlane,this.slicePlane),this.slicePlaneEnabled=i.slicePlaneEnabled}}let ei=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(i){super(i),this._dirty=!1,this._viewState=new ti,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=new Array,this._updatingHandles=new v,this._deconflictor=new x((i,t)=>{i.visible=t,this._setGraphicVisibility(this._active.get(i.id),t)},(i,t)=>i.id!==t.id,$),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange("_readyToRun"))}setPriority(i,t){const e=this._active.get(i.graphic.uid)?.getInfo(this.visibilityGroup);e&&(e.priority=t)}get _readyToRun(){return 0!==this._state||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;const i=this._state/5;return this._dirty?.5*i:i}get readyToRun(){return this.view.ready&&null!=this.view.state&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+4*(this._occlusionQueryUids?.length??0)}runTask(i){switch(this._state){case 0:this._startUpdate(),i.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(i))return;case 2:if(this._state=2,this._occlusionQuery&&!this._occlusionQuery.done)return E;this._readOcclusionQueryResult(),i.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(i))return;case 4:if(this._state=4,this._deconflictor.run(i),!this._deconflictor.done)return;default:this._state=0,this.notifyChange("_readyToRun")}}setGraphicsActive(i,t){t?i.forEach(i=>this.addToActiveGraphics(i)):i.forEach(i=>this.removeFromActiveGraphics(i))}layerSupportsDeconfliction(i){if(null==i||!("hiddenIfDeconflicted"in i)||!i.hiddenIfDeconflicted)return!1;const t=i.stageObject;if(1!==(t?.geometries.length??0))return!1;const e=t?.geometries[0],s=e?.material;return s instanceof N}_startUpdate(){R(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);const{fullWidth:i,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(i,t),this._resetIterators(),this._occlusionQueryUids.length=0,this._checkOcclusion.size||(this._occlusionQuery=s(this._occlusionQuery))}addToActiveGraphics(i){i.ensureInfo(this.visibilityGroup),this._active.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromActiveGraphics(i){si(i,this.visibilityGroup),i.removeInfo(this.visibilityGroup),this._active.delete(i.graphics3DGraphic.graphic.uid),this.setDirty()}addToCheckOcclusion(i){this._checkOcclusion.set(i.graphics3DGraphic.graphic.uid,i),this.setDirty()}removeFromCheckOcclusion(i){this._checkOcclusion.delete(i.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(i){if(0===this._checkOcclusion.size)return!0;const t=this._ensureCheckOcclusionIterator(),e=this._viewState.camera,r=c(q,e.viewInverseTransposeMatrix),o=this.view.map.ground.opacity>0,n="global"===this.view.viewingMode&&o&&e.relativeElevation>0?Y:null;let a=0;null!=n&&(l(n.center,p,e.viewMatrix),n.radius=b(this.view.spatialReference).radius,a=V.distanceToSilhouette(n,p));const h=O();for(;;){if(i.done)return!1;i.madeProgress();const s=t.next();if(!0===s.done)break;const o=s.value,c=o.graphics3DGraphic;if(c.destroyed)continue;if(!c.isVisible(1,8))continue;const u=ni(c,this.visibilityGroup);let d=null,p=!0;for(const i of u){if(!this.layerSupportsDeconfliction(i))continue;d=ai,this._projectHudLayer(i,e,d),w(h);const t=i.stageObject.geometries[0].material;if(this._expandBoundingRect(h,e,i,t,d),d.isOutsideScreen){p=!1;break}if(this._isCulledBySlice(o,d.positionView)){p=!1;break}if(null!=n&&ci(d,n,a)){p=!1;break}l(F,d.positionView,r),d.altitude=this.view.renderCoordsHelper.getAltitude(F);const s=o.ensureInfo(this.visibilityGroup);if(s.altitude=d.altitude,s.distance=d.distance,s.distanceToOccluder=d.distanceToOccluder,s.culled=!1,D(s.aabr,h),t.parameters.occlusionTest)break;this._ensureOcclusionQuery().addPosition(F)===this._occlusionQueryUids.length&&this._occlusionQueryUids.push(c.graphic.uid);break}if(this._active.has(c.graphic.uid)&&(!p||!d)){const i=o.ensureInfo(this.visibilityGroup);i.visible=!d,i.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=s(this._occlusionQuery)),this._occlusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;const i=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(i.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){const i=this._occlusionQueryUids[e],s=this._checkOcclusion.get(i);if(!s)continue;const r=this._occlusionQuery.getOcclusion(e)??-1,o=s.getInfo(this.visibilityGroup);o&&(o.distanceToOccluder=r>0?o.distance-r:0);const c=r<=0||this._occludedVisibility(o?.distanceToOccluder??0,o?.distance??r,o?.altitude??0,t);this._active.has(i)?o&&(o.culled=!c,o.visible=c):this._setGraphicVisibility(s,c)}this._occlusionQueryUids.length=0}_collectActiveGraphics(i){const t=this._ensureActiveGraphicsIterator(),e=16===this.visibilityGroup;for(;!i.done;){i.madeProgress();const s=t.next();if(!0===s.done)return this._activeIterator=null,!0;const r=s.value,o=r.getInfo(this.visibilityGroup);if(!o)continue;!(!e||r.graphics3DGraphic.isVisible())||o.culled?(A(o.aabr,!1,!0),this._setGraphicVisibility(r,o.visible)):this._deconflictor.add(o)}return!1}_occludedVisibility(i,t,e,s){const r=Math.max(this._minAltitudeDifference,Math.abs(e-s))-this._minAltitudeDifference;return 0===i||t-i<=this._baseOccludedVisibility+this._altitudeFactor*r}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_ensureOcclusionQuery(){return this._occlusionQuery??=new H({view:this.view}),this._occlusionQueryUids.length||this._occlusionQuery.init(this._checkOcclusion.size,this._viewState.camera.eye),this._occlusionQuery}_projectHudLayer(i,t,e){const s=i.stageObject,r=s.geometries[0],o=r.material;l(z,s.boundingVolumeWorldSpace.bounds.center,t.viewMatrix);const c=r.attributes,n=c.get("normal").data,a=c.get("centerOffsetAndDistance").data;o.applyShaderOffsetsView(z,n,s.transformation,a,t,e.screenSizePerspectiveEvaluators,z),y(B,z[0],z[1],z[2],1),f(W,B,t.projectionMatrix),h(e.positionNDC,W,1/W[3]),o.applyShaderOffsetsNDC(e.positionNDC,a,t,e.positionNDC,L),e.distanceWithoutPolygonOffset=t.depthNDCToWorld(L[2]),e.distance=L[2]===e.positionNDC[2]?e.distanceWithoutPolygonOffset:t.depthNDCToWorld(e.positionNDC[2]),y(W,e.positionNDC[0],e.positionNDC[1],e.positionNDC[2],1),f(B,W,t.inverseProjectionMatrix),g(B,B,1/B[3]),u(e.positionView,z[0],z[1],z[2])}_isCulledBySlice(i,t){return i.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&Q(this._viewState.slicePlane,t)}_expandBoundingRect(i,t,s,r,{positionNDC:o,screenSizePerspectiveEvaluators:c}){const n=s.getScreenSize(ri);c.evaluator.applyVec2(n,n),n[0]*=t.pixelRatio,n[1]*=t.pixelRatio;const a=G(r.calculateRelativeScreenBounds(n,c.alignmentEvaluator.apply(t.pixelRatio),X),e(0,t.fullWidth,.5+.5*o[0]),e(0,t.fullHeight,.5+.5*o[1])),l=this.marginFactor;if(0!==l){const i=l*Math.min(I(a),j(a));a[0]-=i,a[1]-=i,a[2]+=i,a[3]+=i}k(i,a,i)}_setGraphicVisibility(i,t){const e=i?.graphics3DGraphic;e&&!e.destroyed&&(e.setVisibilityFlag(this.visibilityGroup,8,t),16===this.visibilityGroup&&this.view.labeler.setLabelGraphicVisibility(e,t))}};function si(i,t){const e=i.graphics3DGraphic;e.destroyed||e.setVisibilityFlag(t,8,!0)}i([r({constructOnly:!0})],ei.prototype,"view",void 0),i([r({type:Boolean,readOnly:!0})],ei.prototype,"_readyToRun",null),i([r({type:Boolean,readOnly:!0})],ei.prototype,"updating",null),i([r({readOnly:!0})],ei.prototype,"_updatingHandles",void 0),ei=i([o("esri.views.3d.layers.graphics.Deconflictor")],ei);const ri=a();class oi{constructor(){this.positionView=_(),this.positionNDC=_(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new M}get isOutsideScreen(){const i=this.positionNDC;return i[0]<-1||i[1]<-1||i[2]<-1||i[0]>=1||i[1]>=1||i[2]>=1}}function ci(i,t,e){return d(J.direction,i.positionView),u(J.origin,0,0,0),!!t.intersectRay(J,K)&&i.distanceWithoutPolygonOffset>e}function ni(i,t){return 16===t?i.labelLayers:i.layers}const ai=new oi;export{ei as Deconflictor,ii as DeconflictorGraphic,ti as DeconflictorViewState};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{emptyArray as e}from"../../../../core/arrayUtils.js";import{forEach as t}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{estimateAttributesMemory as i}from"../../../../core/memoryEstimations.js";import r from"../../../../core/ObjectPool.js";import{scale as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import n from"../../../../geometry/Polygon.js";import{projectBoundingRect as h}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as c,expandWithAABB as p,allFinite as y,toRect as m,create as u,set as d,zero as b}from"../../../../geometry/support/aaBoundingBox.js";import{create as g,allFinite as f}from"../../../../geometry/support/aaBoundingRect.js";import{equals as _}from"../../../../geometry/support/spatialReferenceUtils.js";import{computeAABR as E}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromGeometry as L}from"../../../../layers/graphics/featureConversionUtils.js";const G=new r(()=>u(),e=>d(e,b),null,10,5),j=g();class v{get labelLayers(){return this._labelLayers||e}get extent(){return this._extent}get isElevationSource(){return this.layers.some(e=>e?.isElevationSource)}constructor(e,t,i){this.graphic=e,this.graphics3DSymbol=t,this.layers=i,this._visibleFlags=255,++t.referenced}initialize(e){this._layer=e,this._forEachSymbolLayerGraphic(t=>{t.initialize(e),t.setVisibility(this.isVisible())})}destroy(){this._forEachSymbolLayerGraphic(e=>e.destroy()),this._calloutLayer=null,--this.graphics3DSymbol.referenced,this.graphics3DSymbol=null}get destroyed(){return null==this.layers}clearLabelGraphics(){this._forEachLabelGraphic(e=>e.destroy()),this._labelLayers=null}addLabelGraphic(e,t){this._labelLayers||(this._labelLayers=new Array),this._labelLayers.push(e),e.initialize(t),e.setVisibility(this.isVisible(16))}setCalloutGraphic(e){this._calloutLayer=e,this._layer&&(e.initialize(this._layer),e.setVisibility(this.isVisible()))}get calloutLayer(){return this._calloutLayer}get isDraped(){let e=!1;return this._forEachSymbolLayerGraphic(t=>{"draped"===t.type&&(e=!0)}),e}isVisible(e=1,t){const i=t?this._visibleFlags|t|16*t:this._visibleFlags;return 1===e?!(15&~i):!(255&~i)}setVisibilityFlag(e,t,i){const r=this.isVisible(e);i?this._visibleFlags|=e*t:this._visibleFlags&=~(e*t);const s=this.isVisible(e);if(r===s)return!1;if(16===e)this._forEachLabelGraphic(e=>e.setVisibility(s));else{this._forEachSymbolLayerGraphic(e=>e.setVisibility(s));const e=this.isVisible(16);this._forEachLabelGraphic(t=>t.setVisibility(e))}return!0}getVisibilityFlag(e,t){return 0!==(this._visibleFlags&e*t)}computeExtent(e){if(!this._extent){const t=this.graphic.geometry;if(null==t)return!1;this._extent=g(),E(t,this._extent);const i=t.spatialReference;if(!_(i,e)&&!h(this._extent,i,this._extent,e))return this._extent=null,!1}return!0}getAsOptimizedGeometry(e,t){return this._optimizedGeometry||(this._optimizedGeometry=this._convertGraphicToOptimizedGeometry(this.graphic,e,t)),this._optimizedGeometry}_convertGraphicToOptimizedGeometry(e,t,i){let r=e.geometry;return"mesh"!==r.type&&"extent"!==r.type||(r=n.fromExtent("mesh"===r.type?r.extent:r)),L(r,t,i)}get usedMemory(){let e=i(this.graphic.attributes);return this._forEachSymbolLayerGraphic(t=>e+=t.usedMemory),e}computeAttachmentOrigin(){const e={render:{origin:l(),num:0},draped:{origin:a(),num:0}};for(const t of this.layers)null!=t&&t.computeAttachmentOrigin(e);return e.render.num>1&&o(e.render.origin,e.render.origin,1/e.render.num),e.draped.num>1&&s(e.draped.origin,e.draped.origin,1/e.draped.num),e}async getProjectedBoundingBox(e,i,r,s,a){return a||(a={boundingBox:null,requiresDrapedElevation:!1,screenSpaceObjects:[]}),a.boundingBox?c(a.boundingBox):a.boundingBox=c(),a.requiresDrapedElevation=!1,await t(this.layers,async t=>{if(null==t)return;const o="draped"===t.type?i:e,l=G.acquire(),n=await t.getProjectedBoundingBox(o,r,a.screenSpaceObjects,s,l);isFinite(n[2])&&isFinite(n[5])||(a.requiresDrapedElevation=!0),n&&p(a.boundingBox,l),G.release(l)}),y(a.boundingBox)||f(m(a.boundingBox,j))?a:null}needsElevationUpdates(){for(const e of this.layers)if(null!=e&&("object3d"===e.type||"lod-instance"===e.type)&&e.needsElevationUpdates)return!0;return this._labelLayers?.some(e=>e?.needsElevationUpdates??!1)??!1}alignWithElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"!==r.type&&"lod-instance"!==r.type||r.alignWithElevation(e,t,i)})}alignWithAbsoluteElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"===r.type&&r.alignWithAbsoluteElevation(e,t,i)})}addObjectStateSet(e){this._forEachSymbolLayerGraphic(t=>t.addObjectState(e))}removeObjectState(e){this._forEachSymbolLayerGraphic(t=>t.removeObjectState(e))}updateHighlights(e){this._forEachSymbolLayerGraphic(t=>t.updateHighlights(e))}_forEachGraphicList(e,t){e?.forEach(e=>e&&t(e))}_forEachSymbolLayerGraphic(e){this._forEachGraphicList(this.layers,e),this._calloutLayer&&e(this._calloutLayer)}_forEachLabelGraphic(e){this._forEachGraphicList(this.labelLayers,e)}_forEachRenderedGraphic(e){this._forEachSymbolLayerGraphic(e),this._forEachLabelGraphic(e)}get test(){}}export{v as Graphics3DGraphic};
5
+ import{emptyArray as e}from"../../../../core/arrayUtils.js";import{forEach as t}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{estimateAttributesMemory as i}from"../../../../core/memoryEstimations.js";import r from"../../../../core/ObjectPool.js";import{scale as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import n from"../../../../geometry/Polygon.js";import{projectBoundingRect as c}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as h,expandWithAABB as p,allFinite as d,toRect as m,create as y,set as u,zero as g}from"../../../../geometry/support/aaBoundingBox.js";import{create as b,allFinite as f}from"../../../../geometry/support/aaBoundingRect.js";import{equals as _}from"../../../../geometry/support/spatialReferenceUtils.js";import{computeAABR as E}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromGeometry as v}from"../../../../layers/graphics/featureConversionUtils.js";const L=new r(()=>y(),e=>u(e,g),null,10,5),j=b();class G{get labelLayers(){return this._labelLayers||e}get extent(){return this._extent}get isElevationSource(){return this.layers.some(e=>e?.isElevationSource)}constructor(e,t,i){this.graphic=e,this.graphics3DSymbol=t,this.layers=i,this._visibleFlags=255,++t.referenced;i.every(e=>e&&"hiddenIfDeconflicted"in e&&e.hiddenIfDeconflicted)&&(this._visibleFlags|=256)}initialize(e){this._layer=e,this._forEachSymbolLayerGraphic(t=>{t.initialize(e),x(this._visibleFlags,1,t)})}destroy(){this._forEachSymbolLayerGraphic(e=>e.destroy()),this._calloutLayer=null,--this.graphics3DSymbol.referenced,this.graphics3DSymbol=null}get destroyed(){return null==this.layers}clearLabelGraphics(){this._forEachLabelGraphic(e=>e.destroy()),this._labelLayers=null}addLabelGraphic(e,t){this._labelLayers||(this._labelLayers=new Array),this._labelLayers.push(e),e.initialize(t),x(this._visibleFlags,16,e)}setCalloutGraphic(e){this._calloutLayer=e,this._layer&&(e.initialize(this._layer),x(this._visibleFlags,1,e))}get calloutLayer(){return this._calloutLayer}get isDraped(){let e=!1;return this._forEachSymbolLayerGraphic(t=>{"draped"===t.type&&(e=!0)}),e}isVisible(e=1,t=0){const i=this._visibleFlags;return S(i,e,t|16*t|(256&i?0:8))}setVisibilityFlag(e,t,i){const r=e*t;return i!==((this._visibleFlags&r)===r)&&(i?this._visibleFlags|=r:this._visibleFlags&=~r,1===e&&this._forEachSymbolLayerGraphic(e=>x(this._visibleFlags,1,e)),this._forEachLabelGraphic(e=>x(this._visibleFlags,16,e)),!0)}getVisibilityFlag(e,t){return 0!==(this._visibleFlags&e*t)}computeExtent(e){if(!this._extent){const t=this.graphic.geometry;if(null==t)return!1;this._extent=b(),E(t,this._extent);const i=t.spatialReference;if(!_(i,e)&&!c(this._extent,i,this._extent,e))return this._extent=null,!1}return!0}getAsOptimizedGeometry(e,t){return this._optimizedGeometry||(this._optimizedGeometry=this._convertGraphicToOptimizedGeometry(this.graphic,e,t)),this._optimizedGeometry}_convertGraphicToOptimizedGeometry(e,t,i){let r=e.geometry;return"mesh"!==r.type&&"extent"!==r.type||(r=n.fromExtent("mesh"===r.type?r.extent:r)),v(r,t,i)}get usedMemory(){let e=i(this.graphic.attributes);return this._forEachSymbolLayerGraphic(t=>e+=t.usedMemory),e}computeAttachmentOrigin(){const e={render:{origin:l(),num:0},draped:{origin:a(),num:0}};for(const t of this.layers)null!=t&&t.computeAttachmentOrigin(e);return e.render.num>1&&o(e.render.origin,e.render.origin,1/e.render.num),e.draped.num>1&&s(e.draped.origin,e.draped.origin,1/e.draped.num),e}async getProjectedBoundingBox(e,i,r,s,a){return a||(a={boundingBox:null,requiresDrapedElevation:!1,screenSpaceObjects:[]}),a.boundingBox?h(a.boundingBox):a.boundingBox=h(),a.requiresDrapedElevation=!1,await t(this.layers,async t=>{if(null==t)return;const o="draped"===t.type?i:e,l=L.acquire(),n=await t.getProjectedBoundingBox(o,r,a.screenSpaceObjects,s,l);isFinite(n[2])&&isFinite(n[5])||(a.requiresDrapedElevation=!0),n&&p(a.boundingBox,l),L.release(l)}),d(a.boundingBox)||f(m(a.boundingBox,j))?a:null}needsElevationUpdates(){for(const e of this.layers)if(null!=e&&("object3d"===e.type||"lod-instance"===e.type)&&e.needsElevationUpdates)return!0;return this._labelLayers?.some(e=>e?.needsElevationUpdates??!1)??!1}alignWithElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"!==r.type&&"lod-instance"!==r.type||r.alignWithElevation(e,t,i)})}alignWithAbsoluteElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"===r.type&&r.alignWithAbsoluteElevation(e,t,i)})}addObjectStateSet(e){this._forEachSymbolLayerGraphic(t=>t.addObjectState(e))}removeObjectState(e){this._forEachSymbolLayerGraphic(t=>t.removeObjectState(e))}updateHighlights(e){this._forEachSymbolLayerGraphic(t=>t.updateHighlights(e))}_forEachGraphicList(e,t){e?.forEach(e=>e&&t(e))}_forEachSymbolLayerGraphic(e){this._forEachGraphicList(this.layers,e),this._calloutLayer&&e(this._calloutLayer)}_forEachLabelGraphic(e){this._forEachGraphicList(this.labelLayers,e)}_forEachRenderedGraphic(e){this._forEachSymbolLayerGraphic(e),this._forEachLabelGraphic(e)}get test(){}}function x(e,t,i){const r=1===t?"hiddenIfDeconflicted"in i&&i.hiddenIfDeconflicted?0:8:256&e?0:8;i.setVisibility(S(e,t,r))}function S(e,t,i=0){const r=(1===t?15:255)&~i;return(e&r)===r}export{G as Graphics3DGraphic};