@arcgis/core 4.30.0-next.20240319 → 4.30.0-next.20240321

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 (119) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{ef19c4fabc3682fc7aa7.js → 0b1ccc2cfb7a6361eae6.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{2d0a01d0957b3e4512f6.js → 2cc832f9f5b10817f300.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{95d7b168991ddb3a96ca.js → 2fe91a15fcdae540babe.js} +1 -1
  5. package/assets/esri/core/workers/chunks/4be6d5660ec1c8ac7606.js +1 -0
  6. package/assets/esri/core/workers/chunks/4f854e0e3a65b768f6be.js +1 -0
  7. package/assets/esri/core/workers/chunks/505f35a02ac6a67a255b.js +1 -0
  8. package/assets/esri/core/workers/chunks/{51fc02ce8cab70b363b1.js → 5162ba2975b4b025590e.js} +1 -1
  9. package/assets/esri/core/workers/chunks/51700be6f50efba0bc82.js +1 -0
  10. package/assets/esri/core/workers/chunks/{766ca6ab0d11ab637278.js → 52274afa07468bc555aa.js} +1 -1
  11. package/assets/esri/core/workers/chunks/5628fa534b2560933230.js +1 -0
  12. package/assets/esri/core/workers/chunks/689a122c77b39e5c73eb.js +1 -0
  13. package/assets/esri/core/workers/chunks/7530fef3ee217643898e.js +1 -0
  14. package/assets/esri/core/workers/chunks/75bd66a0a1b42e057c1a.js +1 -0
  15. package/assets/esri/core/workers/chunks/7819a446d3c9749ff74f.js +1 -0
  16. package/assets/esri/core/workers/chunks/7ca976273f1f64f75aa7.js +1 -0
  17. package/assets/esri/core/workers/chunks/{36d697a3788b86f24588.js → 9403e2ee9c97488ce4f0.js} +1 -1
  18. package/assets/esri/core/workers/chunks/a0de5ad1d08f511cf3d8.js +1 -0
  19. package/assets/esri/core/workers/chunks/b3cd5f8691ba0b5b5729.js +1 -0
  20. package/assets/esri/core/workers/chunks/b3d905c6b100831ad3c4.js +1 -0
  21. package/assets/esri/core/workers/chunks/{50a7742a7e7f7eda5bee.js → df38774f63984be0a478.js} +1 -1
  22. package/assets/esri/core/workers/chunks/e22a13ff683d207e0434.js +1 -0
  23. package/assets/esri/core/workers/chunks/e93cc8cdeaaf81210dc2.js +1 -0
  24. package/assets/esri/core/workers/chunks/{ac8606f2e4719c96a732.js → ee1345b212cde1ff4755.js} +1 -1
  25. package/assets/esri/core/workers/chunks/eecb0064c5343e88bfde.js +1 -0
  26. package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
  27. package/geometry/support/normalizeUtils.js +1 -1
  28. package/interfaces.d.ts +33 -106
  29. package/layers/SceneLayer.js +1 -1
  30. package/layers/graphics/sources/support/QueryTask.js +1 -1
  31. package/package.json +1 -1
  32. package/rest/geoprocessor/utils.js +1 -1
  33. package/rest/utils.js +1 -1
  34. package/support/revision.js +1 -1
  35. package/views/2d/AnimationManager.js +1 -1
  36. package/views/2d/FrameTask.js +1 -1
  37. package/views/2d/engine/webgl/ClippingInfo.js +1 -1
  38. package/views/2d/engine/webgl/Mesh2D.js +1 -1
  39. package/views/2d/engine/webgl/shaderGraph/techniques/TechniqueDebugLayerView.js +1 -1
  40. package/views/2d/input/MapViewInputManager.js +1 -1
  41. package/views/2d/input/handlers/KeyPan.js +1 -1
  42. package/views/2d/input/handlers/KeyRotate.js +1 -1
  43. package/views/2d/layers/BaseDynamicLayerView2D.js +1 -1
  44. package/views/2d/layers/BaseLayerView2D.js +1 -1
  45. package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
  46. package/views/2d/layers/CatalogDynamicGroupLayerView2D.js +1 -1
  47. package/views/2d/layers/CatalogLayerView2D.js +1 -1
  48. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  49. package/views/2d/layers/GeoRSSLayerView2D.js +1 -1
  50. package/views/2d/layers/GraphicsLayerView2D.js +1 -1
  51. package/views/2d/layers/GroupLayerView2D.js +1 -1
  52. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  53. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  54. package/views/2d/layers/KMLLayerView2D.js +1 -1
  55. package/views/2d/layers/KnowledgeGraphLayerView2D.js +1 -1
  56. package/views/2d/layers/MapImageLayerView2D.js +1 -1
  57. package/views/2d/layers/MapNotesLayerView2D.js +1 -1
  58. package/views/2d/layers/MediaLayerView2D.js +1 -1
  59. package/views/2d/layers/RouteLayerView2D.js +1 -1
  60. package/views/2d/layers/TileLayerView2D.js +1 -1
  61. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  62. package/views/2d/layers/VideoLayerView2D.js +1 -1
  63. package/views/2d/layers/WMSLayerView2D.js +1 -1
  64. package/views/2d/layers/WMTSLayerView2D.js +1 -1
  65. package/views/2d/layers/features/sources/FeatureSourceQueryInfo.js +1 -1
  66. package/views/2d/layers/features/sources/strategies/AFetchLoadStrategy.js +1 -1
  67. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  68. package/views/2d/navigation/MapViewNavigation.js +1 -1
  69. package/views/2d/navigation/ZoomBox.js +1 -1
  70. package/views/2d/navigation/actions/Pan.js +1 -1
  71. package/views/2d/navigation/actions/Pinch.js +1 -1
  72. package/views/2d/support/clippingUtils.js +5 -0
  73. package/views/2d/support/hitTestUtils.js +1 -1
  74. package/views/2d/viewpointUtils.js +1 -1
  75. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  76. package/views/3d/layers/graphics/Graphics3DElevationAlignment.js +1 -1
  77. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  78. package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
  79. package/views/3d/layers/graphics/GraphicsDeconflictor.js +1 -1
  80. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  81. package/views/3d/layers/graphics/Labeler.js +1 -1
  82. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  83. package/views/3d/terrain/TerrainRenderer.js +1 -1
  84. package/views/3d/webgl-engine/collections/Component/ComponentIntersectionData.js +1 -1
  85. package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
  86. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  87. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  88. package/views/draw/DrawOperation.js +1 -1
  89. package/views/input/InputManager.js +1 -1
  90. package/views/input/keys.js +1 -1
  91. package/views/interactive/snapping/SnappingManager.js +1 -1
  92. package/widgets/BasemapLayerList.js +1 -1
  93. package/widgets/Editor/workflowUtils.js +1 -1
  94. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  95. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  96. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  97. package/widgets/FeatureTable.js +1 -1
  98. package/widgets/LayerList.js +1 -1
  99. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  100. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  101. package/widgets/OrientedImageryViewer.js +1 -1
  102. package/widgets/Popup.js +1 -1
  103. package/widgets/TableList.js +1 -1
  104. package/assets/esri/core/workers/chunks/13b6de78894ba1a70ace.js +0 -1
  105. package/assets/esri/core/workers/chunks/17a33c1eca0f2908b1a1.js +0 -1
  106. package/assets/esri/core/workers/chunks/187e056c251e69c9b5d2.js +0 -1
  107. package/assets/esri/core/workers/chunks/2427699e34e1895ed024.js +0 -1
  108. package/assets/esri/core/workers/chunks/4e9740f3955a8c45fb2d.js +0 -1
  109. package/assets/esri/core/workers/chunks/5c9e6d1a88fac48baf3a.js +0 -1
  110. package/assets/esri/core/workers/chunks/5f5f6bba98e5671e63a7.js +0 -1
  111. package/assets/esri/core/workers/chunks/7bba67d345da6eced804.js +0 -1
  112. package/assets/esri/core/workers/chunks/92fc6c48ff9f50a7351a.js +0 -1
  113. package/assets/esri/core/workers/chunks/955d7a0c8b2cdabfa8a3.js +0 -1
  114. package/assets/esri/core/workers/chunks/99283ac67e6b73695df7.js +0 -1
  115. package/assets/esri/core/workers/chunks/b9e8c2e2c5b4c9564319.js +0 -1
  116. package/assets/esri/core/workers/chunks/d344e99dd999aaaabbe3.js +0 -1
  117. package/assets/esri/core/workers/chunks/e78e92e024275eccea4e.js +0 -1
  118. package/assets/esri/core/workers/chunks/f7cfdba77cb614fd3725.js +0 -1
  119. package/assets/esri/core/workers/chunks/fc2a12f9e4068ab89628.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import i from"../../../../Graphic.js";import e from"../../../../core/Accessor.js";import s from"../../../../core/Collection.js";import{makeHandle as r}from"../../../../core/handleUtils.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{isAbortError as o}from"../../../../core/promiseUtils.js";import{watch as a,sync as l,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../layers/Layer.js";import{hydrateGraphic as g}from"../../../../layers/graphics/hydratedFeatures.js";import{getRenderingInfo as m,getRenderingInfoAsync as f}from"../../../../renderers/support/renderingInfoUtils.js";import b from"../../../../rest/support/Query.js";import{DrapeSourceType as C}from"../interfaces.js";import{suspendResumeExtentOptimism as j}from"./constants.js";import{Graphics3DCore as w}from"./Graphics3DCore.js";import{Graphics3DElevationAlignment as S}from"./Graphics3DElevationAlignment.js";import{Graphics3DFrustumVisibility as V}from"./Graphics3DFrustumVisibility.js";import{Graphics3DObjectStates as v}from"./Graphics3DObjectStates.js";import{Graphics3DScaleVisibility as G}from"./Graphics3DScaleVisibility.js";import{enlargeExtent as E}from"./graphicUtils.js";import{Object3DState as _}from"../../webgl-engine/lib/basicInterfaces.js";import{UpdatePolicy as x}from"../../webgl-engine/lib/UpdatePolicy.js";let O=class extends e{constructor(t){super(t),this.type="graphics-3d",this.graphicsCore=null,this.drapeSourceType=C.Features,this.scaleVisibilityEnabled=!1,this.frustumVisibilityEnabled=!1,this._suspendResumeExtent=null,this._updatingHandles=new d}initialize(){const{layer:t}=this,i="effectiveScaleRange"in t?t:null,e=this.scaleVisibilityEnabled&&null!=i,s=new w({owner:this,layer:this.owner.layer,preferredUpdatePolicy:x.SYNC,graphicSymbolSupported:!0,componentFactories:{elevationAlignment:(t,i)=>new S({graphicsCoreOwner:this,graphicsCore:t,queryGraphicUIDsInExtent:i,elevationProvider:this.view.elevationProvider}),scaleVisibility:e?(t,e)=>new G({graphicsCoreOwner:this,layer:i,queryGraphicUIDsInExtent:e,graphicsCore:t,basemapTerrain:this.owner.view.basemapTerrain}):null,objectStates:t=>new v(t)}});if(this._set("graphicsCore",s),this.frustumVisibilityEnabled&&this._set("frustumVisibility",new V({graphicsCoreOwner:this})),"fullOpacity"in this.owner){const t=this.owner;this._updatingHandles.add((()=>t.fullOpacity),(()=>this.graphicsCore.opacityChange()))}if("elevationInfo"in t){const i=t;this._updatingHandles.add((()=>i.elevationInfo),((t,i)=>{u(t,i)&&this._updatingHandles.addPromise(this.graphicsCore.elevationInfoChange())}))}this._set("initializePromise",this._initializeAsync()),this._updatingHandles.addPromise(this.initializePromise)}async _initializeAsync(){try{await this.graphicsCore.initializePromise}catch(t){if(o(t))return;throw t}this.destroyed||(this.addHandles(a((()=>this.view.clippingArea),(()=>this._updateClippingExtent()),l)),this._updateClippingExtent(),this._setupSuspendResumeExtent(),this.graphicsCore.startCreateGraphics())}destroy(){this._updatingHandles.destroy(),this._set("frustumVisibility",n(this.frustumVisibility)),this._set("graphicsCore",n(this.graphicsCore))}get layer(){return this.owner.layer}get view(){return this.owner.view}get scaleVisibility(){return this.graphicsCore?.scaleVisibility}get elevationAlignment(){return this.graphicsCore?.elevationAlignment}get objectStates(){return this.graphicsCore?.objectStates}get scaleVisibilitySuspended(){return!(null==this.scaleVisibility||!this.scaleVisibility.suspended)}get frustumVisibilitySuspended(){return null!=this.frustumVisibility&&this.frustumVisibility.suspended}get suspended(){return this.owner.suspended??!1}get updating(){return!!(this.graphicsCore?.updating||null!=this.scaleVisibility&&this.scaleVisibility.updating||null!=this.frustumVisibility&&this.frustumVisibility.updating||this._updatingHandles.updating)}get graphics3DGraphics(){return this.graphicsCore?.graphics3DGraphics}get graphics3DGraphicsByObjectID(){return this.graphicsCore?.graphics3DGraphicsByObjectID}get loadedGraphics(){return this.owner.loadedGraphics}get fullOpacity(){return this.owner.fullOpacity??1}get slicePlaneEnabled(){return this.owner.slicePlaneEnabled}get updatePolicy(){return this.owner.updatePolicy}notifyGraphicGeometryChanged(t){this.graphicsCore.notifyGraphicGeometryChanged(t)}notifyGraphicVisibilityChanged(t){this.graphicsCore.notifyGraphicVisibilityChanged(t)}getRenderingInfo(t,i,e){const s=m(t,{renderer:i,arcade:e});if(s?.color){const t=s.color;t[0]=t[0]/255,t[1]=t[1]/255,t[2]=t[2]/255}return s}getRenderingInfoAsync(t,i,e,s){return f(t,{renderer:i,arcade:e,...s})}getHit(t){if(this.owner.loadedGraphics){const i=this.owner.loadedGraphics.find((i=>i.uid===t));if(i){const t=this.layer instanceof y?this.layer:null,e=g(i,t);return{type:"graphic",graphic:e,layer:e.layer}}}return null}whenGraphicBounds(t,i){return this.graphicsCore?this.graphicsCore.whenGraphicBounds(t,i):Promise.reject()}computeAttachmentOrigin(t,i){return this.graphicsCore?this.graphicsCore.computeAttachmentOrigin(t,i):null}getSymbolLayerSize(t,i){return this.graphicsCore?this.graphicsCore.getSymbolLayerSize(t,i):null}maskOccludee(t){const{set:i,handle:e}=this.objectStates.acquireSet(_.MaskOccludee,null);return this.objectStates.setUid(i,t.uid),e}highlight(t){if(t instanceof b)return P;if("number"==typeof t)return this.highlight([t]);if(t instanceof i)return this.highlight([t]);if(t instanceof s&&(t=t.toArray()),Array.isArray(t)&&t.length>0){if(t[0]instanceof i){const i=t.map((t=>t.uid)),{set:e,handle:s}=this.objectStates.acquireSet(_.Highlight,null);return this.objectStates.setUids(e,i),s}if("number"==typeof t[0]){const i=t,{set:e,handle:s}=this.objectStates.acquireSet(_.Highlight,null);return this.objectStates.setObjectIds(e,i),s}}return P}_setupSuspendResumeExtent(){const{scaleVisibility:t,frustumVisibility:i}=this;if(null==t&&null==i)return;const e=({computedExtent:e,extentPadding:s})=>{this._suspendResumeExtent=E(e,this._suspendResumeExtent,j,s),null!=t&&t.setExtent(this._suspendResumeExtent),null!=i&&i.setExtent(this._suspendResumeExtent)};this.addHandles(a((()=>({computedExtent:this.graphicsCore?.computedExtent,extentPadding:this.graphicsCore?.extentPadding})),(t=>e(t)),p))}_updateClippingExtent(){const t=this.view.clippingArea;this.graphicsCore.setClippingExtent(t,this.view.spatialReference)&&this.graphicsCore.recreateAllGraphics()}};t([c()],O.prototype,"type",void 0),t([c({constructOnly:!0})],O.prototype,"owner",void 0),t([c()],O.prototype,"layer",null),t([c()],O.prototype,"view",null),t([c({constructOnly:!0})],O.prototype,"graphicsCore",void 0),t([c()],O.prototype,"scaleVisibility",null),t([c({constructOnly:!0})],O.prototype,"frustumVisibility",void 0),t([c()],O.prototype,"elevationAlignment",null),t([c()],O.prototype,"objectStates",null),t([c()],O.prototype,"scaleVisibilitySuspended",null),t([c({readOnly:!0})],O.prototype,"frustumVisibilitySuspended",null),t([c()],O.prototype,"suspended",null),t([c({readOnly:!0})],O.prototype,"updating",null),t([c()],O.prototype,"loadedGraphics",null),t([c()],O.prototype,"fullOpacity",null),t([c()],O.prototype,"slicePlaneEnabled",null),t([c()],O.prototype,"drapeSourceType",void 0),t([c()],O.prototype,"updatePolicy",null),t([c({constructOnly:!0})],O.prototype,"scaleVisibilityEnabled",void 0),t([c({constructOnly:!0})],O.prototype,"frustumVisibilityEnabled",void 0),t([c()],O.prototype,"initializePromise",void 0),O=t([h("esri.views.3d.layers.graphics.GraphicsProcessor")],O);const P=r();export{O as GraphicsProcessor};
5
+ import{_ as i}from"../../../../chunks/tslib.es6.js";import e from"../../../../Graphic.js";import t from"../../../../core/Accessor.js";import r from"../../../../core/Collection.js";import{makeHandle as s}from"../../../../core/handleUtils.js";import{destroyMaybe as n}from"../../../../core/maybe.js";import{isAbortError as o}from"../../../../core/promiseUtils.js";import{watch as a,sync as l,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{property as c}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as h}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as d}from"../../../../core/support/UpdatingHandles.js";import y from"../../../../layers/Layer.js";import{hydrateGraphic as g}from"../../../../layers/graphics/hydratedFeatures.js";import{getRenderingInfo as m,getRenderingInfoAsync as f}from"../../../../renderers/support/renderingInfoUtils.js";import b from"../../../../rest/support/Query.js";import{DrapeSourceType as C}from"../interfaces.js";import{suspendResumeExtentOptimism as w}from"./constants.js";import{Graphics3DCore as j}from"./Graphics3DCore.js";import{Graphics3DElevationAlignment as V}from"./Graphics3DElevationAlignment.js";import{Graphics3DFrustumVisibility as v}from"./Graphics3DFrustumVisibility.js";import{Graphics3DObjectStates as G}from"./Graphics3DObjectStates.js";import{Graphics3DScaleVisibility as E}from"./Graphics3DScaleVisibility.js";import{enlargeExtent as S}from"./graphicUtils.js";import{Object3DState as _}from"../../webgl-engine/lib/basicInterfaces.js";import{UpdatePolicy as x}from"../../webgl-engine/lib/UpdatePolicy.js";let O=class extends t{constructor(i){super(i),this.type="graphics-3d",this.graphicsCore=null,this.drapeSourceType=C.Features,this.scaleVisibilityEnabled=!1,this.frustumVisibilityEnabled=!1,this._suspendResumeExtent=null,this._updatingHandles=new d}initialize(){const{layer:i}=this,e="effectiveScaleRange"in i?i:null,t=this.scaleVisibilityEnabled&&null!=e,r=new j({owner:this,layer:this.owner.layer,preferredUpdatePolicy:x.SYNC,graphicSymbolSupported:!0,componentFactories:{elevationAlignment:(i,e)=>new V({graphicsCoreOwner:this,graphicsCore:i,queryGraphicUIDsInExtent:e,elevationProvider:this.view.elevationProvider}),scaleVisibility:t?(i,t)=>new E({graphicsCoreOwner:this,layer:e,queryGraphicUIDsInExtent:t,graphicsCore:i,basemapTerrain:this.owner.view.basemapTerrain}):null,objectStates:i=>new G(i)}});if(this._set("graphicsCore",r),this.frustumVisibilityEnabled&&this._set("frustumVisibility",new v({graphicsCoreOwner:this})),"fullOpacity"in this.owner){const i=this.owner;this._updatingHandles.add((()=>i.fullOpacity),(()=>this.graphicsCore.opacityChange()))}if("elevationInfo"in i){const e=i;this._updatingHandles.add((()=>e.elevationInfo),((i,e)=>{u(i,e)&&this._updatingHandles.addPromise(this.graphicsCore.elevationInfoChange())}))}this._set("initializePromise",this._initializeAsync()),this._updatingHandles.addPromise(this.initializePromise)}async _initializeAsync(){try{await this.graphicsCore.initializePromise}catch(i){if(o(i))return;throw i}this.destroyed||(this.addHandles(a((()=>this.view.clippingArea),(()=>this._updateClippingExtent()),l)),this._updateClippingExtent(),this._setupSuspendResumeExtent(),this.graphicsCore.startCreateGraphics())}destroy(){this._updatingHandles.destroy(),this._set("frustumVisibility",n(this.frustumVisibility)),this._set("graphicsCore",n(this.graphicsCore))}get layer(){return this.owner.layer}get view(){return this.owner.view}get scaleVisibility(){return this.graphicsCore?.scaleVisibility}get elevationAlignment(){return this.graphicsCore?.elevationAlignment}get scaleVisibilitySuspended(){return!(null==this.scaleVisibility||!this.scaleVisibility.suspended)}get frustumVisibilitySuspended(){return null!=this.frustumVisibility&&this.frustumVisibility.suspended}get suspended(){return this.owner.suspended??!1}get updating(){return!!(this.graphicsCore?.updating||null!=this.scaleVisibility&&this.scaleVisibility.updating||null!=this.frustumVisibility&&this.frustumVisibility.updating||this._updatingHandles.updating)}get graphics3DGraphics(){return this.graphicsCore?.graphics3DGraphics}get graphics3DGraphicsByObjectID(){return this.graphicsCore?.graphics3DGraphicsByObjectID}get loadedGraphics(){return this.owner.loadedGraphics}get fullOpacity(){return this.owner.fullOpacity??1}get slicePlaneEnabled(){return this.owner.slicePlaneEnabled}get updatePolicy(){return this.owner.updatePolicy}notifyGraphicGeometryChanged(i){this.graphicsCore.notifyGraphicGeometryChanged(i)}notifyGraphicVisibilityChanged(i){this.graphicsCore.notifyGraphicVisibilityChanged(i)}getRenderingInfo(i,e,t){const r=m(i,{renderer:e,arcade:t});if(r?.color){const i=r.color;i[0]=i[0]/255,i[1]=i[1]/255,i[2]=i[2]/255}return r}getRenderingInfoAsync(i,e,t,r){return f(i,{renderer:e,arcade:t,...r})}getHit(i){if(this.owner.loadedGraphics){const e=this.owner.loadedGraphics.find((e=>e.uid===i));if(e){const i=this.layer instanceof y?this.layer:null,t=g(e,i);return{type:"graphic",graphic:t,layer:t.layer}}}return null}whenGraphicBounds(i,e){return this.graphicsCore?this.graphicsCore.whenGraphicBounds(i,e):Promise.reject()}computeAttachmentOrigin(i,e){return this.graphicsCore?this.graphicsCore.computeAttachmentOrigin(i,e):null}getSymbolLayerSize(i,e){return this.graphicsCore?this.graphicsCore.getSymbolLayerSize(i,e):null}maskOccludee(i){const e=this.graphicsCore?.objectStates;if(!e)return s();const{set:t,handle:r}=e.acquireSet(_.MaskOccludee,null);return e.setUid(t,i.uid),r}highlight(i){const t=this.graphicsCore?.objectStates;if(!t)return s();if(i instanceof b)return P;if("number"==typeof i)return this.highlight([i]);if(i instanceof e)return this.highlight([i]);if(i instanceof r&&(i=i.toArray()),Array.isArray(i)&&i.length>0){if(i[0]instanceof e){const e=i.map((i=>i.uid)),{set:r,handle:s}=t.acquireSet(_.Highlight,null);return t.setUids(r,e),s}if("number"==typeof i[0]){const e=i,{set:r,handle:s}=t.acquireSet(_.Highlight,null);return t.setObjectIds(r,e),s}}return P}_setupSuspendResumeExtent(){const{scaleVisibility:i,frustumVisibility:e}=this;if(null==i&&null==e)return;const t=({computedExtent:t,extentPadding:r})=>{this._suspendResumeExtent=S(t,this._suspendResumeExtent,w,r),null!=i&&i.setExtent(this._suspendResumeExtent),null!=e&&e.setExtent(this._suspendResumeExtent)};this.addHandles(a((()=>({computedExtent:this.graphicsCore?.computedExtent,extentPadding:this.graphicsCore?.extentPadding})),(i=>t(i)),p))}_updateClippingExtent(){const i=this.view.clippingArea;this.graphicsCore.setClippingExtent(i,this.view.spatialReference)&&this.graphicsCore.recreateAllGraphics()}};i([c()],O.prototype,"type",void 0),i([c({constructOnly:!0})],O.prototype,"owner",void 0),i([c()],O.prototype,"layer",null),i([c()],O.prototype,"view",null),i([c({constructOnly:!0})],O.prototype,"graphicsCore",void 0),i([c()],O.prototype,"scaleVisibility",null),i([c({constructOnly:!0})],O.prototype,"frustumVisibility",void 0),i([c()],O.prototype,"elevationAlignment",null),i([c()],O.prototype,"scaleVisibilitySuspended",null),i([c({readOnly:!0})],O.prototype,"frustumVisibilitySuspended",null),i([c()],O.prototype,"suspended",null),i([c({readOnly:!0})],O.prototype,"updating",null),i([c()],O.prototype,"loadedGraphics",null),i([c()],O.prototype,"fullOpacity",null),i([c()],O.prototype,"slicePlaneEnabled",null),i([c()],O.prototype,"drapeSourceType",void 0),i([c()],O.prototype,"updatePolicy",null),i([c({constructOnly:!0})],O.prototype,"scaleVisibilityEnabled",void 0),i([c({constructOnly:!0})],O.prototype,"frustumVisibilityEnabled",void 0),i([c()],O.prototype,"initializePromise",void 0),O=i([h("esri.views.3d.layers.graphics.GraphicsProcessor")],O);const P=s();export{O as GraphicsProcessor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import l from"../../../../core/Logger.js";import{someMap as a}from"../../../../core/MapUtils.js";import{disposeMaybe as r,abortMaybe as o}from"../../../../core/maybe.js";import{throwIfAborted as n,isAbortError as c}from"../../../../core/promiseUtils.js";import{watch as h}from"../../../../core/reactiveUtils.js";import{property as b}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as p}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as y}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as g}from"../../../../symbols/callouts/calloutUtils.js";import{VisibilityGroup as m,VisibilityFlag as f}from"./enums.js";import{make as x}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutSymbolLayerRenderingInfo as C,LineCalloutCreationContext as _}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as L}from"./graphicSymbolUtils.js";import{LabelParameters as v}from"./LabelParameters.js";import{getLabelPlacement as T,LabelInfo as G}from"./labelPlacement.js";import{horizontalPlacementFromAnchor as A,verticalPlacementFromAnchor as w,textRenderAlignmentFromHorizontalPlacement as D}from"./placementUtils.js";import{MaterialCollection as I}from"../../webgl-engine/lib/MaterialCollection.js";import{TextRenderer as R}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as P}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as S}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as j}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as E}from"../../../support/Scheduler.js";import{Yield as O}from"../../../support/Yield.js";class z{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.addedToTextureAtlas=!1,this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class V{constructor(e,t,s,i,l){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=l,this.calloutSymbolLayerIndex=0}}class F{constructor(e,t,s,i,l,a,r,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=l,this.elevationInfoOverride=a,this.disablePlacement=r,this.active=o,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new j(e,{pickable:!0,disableOctree:!0},t.uid)}destroy(){this.stageLayer.destroy()}}let M=class extends t{constructor(e){super(e),this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([h((()=>this.view.state?.camera),(()=>this.setDirty())),h((()=>this.view.state?.rasterPixelRatio),(()=>this._resetAllLabels())),this.view.resourceController.scheduler.registerTask(E.LABELER,this)]),this._textTextureAtlas=new S({view:this.view}),this._hudMaterialCollection=new I(this.view._stage),this._calloutMaterialCollection=new I(this.view._stage)}dispose(){this.removeAllHandles(),this._textTextureAtlas=r(this._textTextureAtlas),this._hudMaterialCollection=r(this._hudMaterialCollection),this._calloutMaterialCollection=r(this._calloutMaterialCollection),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),H.graphic=null,H.renderingInfo=null,H.layer=null}_activateLabelingContext(e){e.graphics.forEach(((t,s)=>{const i=new z(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(m.LABEL,f.USER,!0)})),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach(((e,t)=>{e.setVisibilityFlag(m.LABEL,f.USER,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)})),e.active=!1}_addLabelTextureToAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];s&&(this._textTextureAtlas.addTextTexture(s,t.stageObject),e.addedToTextureAtlas=!0)}}_removeLabelTextureFromAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];null!=s&&(this._textTextureAtlas.removeTextTexture(s,t.stageObject),e.addedToTextureAtlas=!1)}}get running(){return this.view.ready&&(this._dirty||this.deconflictor.running)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e),O}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(U(t))this._dirty=!0;else if(k(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else a(t.labelsToInitialize,((s,i)=>(this._ensureGraphics3DResources(s)&&(this._labels.set(i,s),this.deconflictor.setDirty(),e.madeProgress()),(s.visible&&s.textInitialized||!s.visible&&s.hasGraphics3DResources)&&(t.labelsToInitialize.delete(i),e.madeProgress()),e.done)))&&(this._dirty=!0);this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),n(t),e.scaleVisibility&&e.scaleVisibility.updateScaleRangeActive();const a=e.graphics3DCore,r=a.layer,o=r.labelingInfo?.filter((e=>!!e.symbol));if(!o||0===o.length)return;let c=!1;await s(o,(async(s,r)=>{const o=s.symbol,h=L(a.getOrCreateGraphics3DSymbol(o));if(null==h)return void l.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),n(t);let b=null;g(o)&&o.hasVisibleCallout()&&(b=x(o,a.symbolCreationContext),await b.load(),n(t));const d=await i(y(s,e.layer.fieldsIndex,this.view.spatialReference));if(n(t),!0===d.ok){const i=await this._createTextRenderParameters(h.symbol);n(t),e.labelClassContexts[r]=new V(s,h,b,i,d.value)}else l.getLogger(this).error(`Label expression failed to evaluate: ${d.error}`),c=!0})),n(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(c(t))throw t;e.labelClassContexts.length=0})).then((()=>{e.labelClassAbortController=null,this.notifyChange("updating")})).catch((()=>{})),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.at(0);return"text"!==t?.type?null:P.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,o(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,l,a){const r=new v(s,A(s.anchor),w(s.anchor),e.text,u(e.displayWidth,e.displayHeight));return H.graphic=t,H.renderingInfo=null,H.layer=i,l.createLabel(H,r,this._hudMaterialCollection,this._textTextureAtlas,(()=>{const e=T(a);return e?e.elevationOffset:null}))}_createLineCalloutGraphic(e,t,s,i,l){H.graphic=e,H.layer=l;const a=i.screenOffset[0];return H.renderingInfo=new C(null,t,i.translation,i.centerOffset,a,i.centerOffsetUnits,i.elevationOffset,this._calloutMaterialCollection),s.createGraphics3DGraphic(H)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(k(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let l=!1;const a=t.graphic,r=s.layer,o=B(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],d=b.graphics3DSymbol,u=d.symbol&&"label-3d"===d.symbol.type?d.symbol:null,p=d.symbolLayers[0];if(!p)continue;p.setElevationInfoOverride(s.elevationInfoOverride);const y=new G(t,u,b.labelClass),g=this._createTextSymbolGraphic(c,a,h,r,p,y);if(null==g)return!1;g._labelClass=b.labelClass,g._labelIndex=n,t.addLabelGraphic(g,s.stageLayer),t.deconflictionPriority=b.textRenderParameters?.definition.size??0,t.setVisibilityFlag(m.LABEL,f.USER,o),t.setVisibilityFlag(m.LABEL,f.SCALE_RANGE,!0),t.setVisibilityFlag(m.LABEL,f.DECONFLICTION,!1),l=!0;const x=b.graphics3DCalloutSymbolLayer;if(x&&h.hasLabelVerticalOffset){x.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,u,x,h,r);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return s.scaleVisibility&&l&&s.scaleVisibility.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s._labelClass)continue;const e=t[s._labelIndex].graphics3DSymbol.symbolLayers[0];e?.onRemoveGraphic(s)}e.graphics3DGraphic.deconflictionPriority=0,e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(k(s))return;const i=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const r=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,null==r?.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?p(i,t.layer):i;n=o.evaluate(e)}catch(l){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol,h="label-3d"===c.symbol?.type?c.symbol:null;if(!c.symbolLayers[0])continue;const b=e.graphics3DGraphic,d=r.labelClass,u=t.disablePlacement,y=T({graphics3DGraphic:b,labelSymbol:h,labelClass:d,disablePlacement:u});if(null==y)continue;const g=A(y.anchor),m=D(g);e.textRenderers[a]=new R(n,m,r.textRenderParameters,S.maxSize),e.textLabelPlacements[a]=y}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const i=new z(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.addedToTextureAtlas&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const i=new Map;t.graphics.forEach((e=>i.set(e.graphic.uid,e)));const l=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,l),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=B(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach(((t,s)=>{const i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))})),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const i=s&&s.emptySymbolLabelSupported||!1,l=s?.elevationInfoOverride||null,a=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new F(this.view._stage,r,e,t,i,l,a,B(r));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),featureReductionChange:()=>{},layerLabelsEnabled:()=>B(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),clear:()=>{}}}removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach((e=>this._removeGraphic(t,e))),t.destroy(),this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.addedToTextureAtlas?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.addedToTextureAtlas&&this._removeLabelTextureFromAtlas(i),i.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some((e=>U(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(U(t)?0:1)),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get test(){return{textTextureAtlas:this._textTextureAtlas,resetAllLabels:()=>this._resetAllLabels()}}};function U(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function k(e){return!e||0===e.length}function B(e){return!0===e.labelsVisible&&!!e.labelingInfo?.some((e=>!!e.symbol))}e([b({constructOnly:!0})],M.prototype,"view",void 0),e([b({constructOnly:!0})],M.prototype,"deconflictor",void 0),e([b()],M.prototype,"_textTextureAtlas",void 0),e([b({type:Boolean,readOnly:!0})],M.prototype,"updating",null),M=e([d("esri.views.3d.layers.graphics.Labeler")],M);const H=new _(null,null,null);export{M as Labeler,B as areLabelsVisible};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as i}from"../../../../core/asyncUtils.js";import l from"../../../../core/Logger.js";import{someMap as a}from"../../../../core/MapUtils.js";import{disposeMaybe as r,abortMaybe as o}from"../../../../core/maybe.js";import{throwIfAborted as n,isAbortError as c}from"../../../../core/promiseUtils.js";import{watch as h}from"../../../../core/reactiveUtils.js";import{property as b}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import"../../../../core/RandomLCG.js";import{subclass as d}from"../../../../core/accessorSupport/decorators/subclass.js";import{fromValues as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{hydrateGraphic as p}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as y}from"../../../../layers/support/labelFormatUtils.js";import{hasCalloutSupport as g}from"../../../../symbols/callouts/calloutUtils.js";import{VisibilityGroup as m,VisibilityFlag as f}from"./enums.js";import{make as x}from"./Graphics3DCalloutSymbolLayerFactory.js";import{LineCalloutSymbolLayerRenderingInfo as C,LineCalloutCreationContext as _}from"./Graphics3DLineCalloutSymbolLayer.js";import{getGraphics3DSymbol as L}from"./graphicSymbolUtils.js";import{LabelParameters as v}from"./LabelParameters.js";import{getLabelPlacement as T,LabelInfo as G}from"./labelPlacement.js";import{horizontalPlacementFromAnchor as D,verticalPlacementFromAnchor as w,textRenderAlignmentFromHorizontalPlacement as A}from"./placementUtils.js";import{MaterialCollection as I}from"../../webgl-engine/lib/MaterialCollection.js";import{TextRenderer as R}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as P}from"../../webgl-engine/lib/TextRenderParameters.js";import{TextTextureAtlas as S}from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as j}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as O}from"../../../support/Scheduler.js";import{Yield as E}from"../../../support/Yield.js";class z{constructor(e,t){this.labelingContext=e,this.graphics3DGraphic=t,this.hasGraphics3DResources=!1,this.visible=!1,this.addedToTextureAtlas=!1,this.textInitialized=!1,this.textRenderers=new Array,this.textLabelPlacements=new Array}}class F{constructor(e,t,s,i,l){this.labelClass=e,this.graphics3DSymbol=t,this.graphics3DCalloutSymbolLayer=s,this.textRenderParameters=i,this.labelFunction=l,this.calloutSymbolLayerIndex=0}}class M{constructor(e,t,s,i,l,a,r,o){this.layer=t,this.graphics3DCore=s,this.scaleVisibility=i,this.emptySymbolLabelSupported=l,this.elevationInfoOverride=a,this.disablePlacement=r,this.active=o,this.labelClassAbortController=new AbortController,this.labelClassContexts=new Array,this.graphics=new Map,this.labelsToInitialize=new Map,this.stageLayer=new j(e,{pickable:!0,disableOctree:!0},t.uid)}destroy(){this.stageLayer.destroy()}}let V=class extends t{constructor(e){super(e),this._dirty=!1,this._labels=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this.addHandles([h((()=>this.view.state?.camera),(()=>this.setDirty())),h((()=>this.view.state?.rasterPixelRatio),(()=>this._resetAllLabels())),this.view.resourceController.scheduler.registerTask(O.LABELER,this)]),this._textTextureAtlas=new S({view:this.view}),this._hudMaterialCollection=new I(this.view._stage),this._calloutMaterialCollection=new I(this.view._stage)}dispose(){this.removeAllHandles(),this._textTextureAtlas=r(this._textTextureAtlas),this._hudMaterialCollection=r(this._hudMaterialCollection),this._calloutMaterialCollection=r(this._calloutMaterialCollection),this._labelingContexts.length=0,this._labels.clear()}destroy(){this.dispose(),H.graphic=null,H.renderingInfo=null,H.layer=null}_activateLabelingContext(e){e.graphics.forEach(((t,s)=>{const i=new z(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i),t.setVisibilityFlag(m.LABEL,f.USER,!0)})),e.active=!0}_deactivateLabelingContext(e){e.graphics.forEach(((e,t)=>{e.setVisibilityFlag(m.LABEL,f.USER,!1),this.setLabelGraphicVisibility(e,!1),e.clearLabelGraphics(),this._labels.delete(t)})),e.active=!1}_addLabelTextureToAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];s&&(this._textTextureAtlas.addTextTexture(s,t.stageObject),e.addedToTextureAtlas=!0)}}_removeLabelTextureFromAtlas(e){for(const t of e.graphics3DGraphic.labelLayers){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];null!=s&&(this._textTextureAtlas.removeTextTexture(s,t.stageObject),e.addedToTextureAtlas=!1)}}get running(){return this.view.ready&&(this._dirty||this.deconflictor.running)}runTask(e){return this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e),E}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(t.active)if(U(t))this._dirty=!0;else if(k(t.labelClassContexts)){if(null===t.labelClassContexts){this._deactivateLabelingContext(t);continue}this._createLabelClassContext(t),this._dirty=!0}else a(t.labelsToInitialize,((s,i)=>(this._ensureGraphics3DResources(s)&&(this._labels.set(i,s),this.deconflictor.setDirty(),e.madeProgress()),(s.visible&&s.textInitialized||!s.visible&&s.hasGraphics3DResources)&&(t.labelsToInitialize.delete(i),e.madeProgress()),e.done)))&&(this._dirty=!0);this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController?.signal;e.layer.when&&await e.layer.when(),n(t),e.scaleVisibility?.updateScaleRangeActive();const a=e.graphics3DCore,r=a.layer,o=r.labelingInfo?.filter((e=>!!e.symbol));if(!o||0===o.length)return;let c=!1;await s(o,(async(s,r)=>{const o=s.symbol,h=L(a.getOrCreateGraphics3DSymbol(o));if(null==h)return void l.getLogger(this).error("Failed to create Graphics3DSymbol for label");await h.load(),n(t);let b=null;g(o)&&o.hasVisibleCallout()&&(b=x(o,a.symbolCreationContext),await b.load(),n(t));const d=await i(y(s,e.layer.fieldsIndex,this.view.spatialReference));if(n(t),!0===d.ok){const i=await this._createTextRenderParameters(h.symbol);n(t),e.labelClassContexts[r]=new F(s,h,b,i,d.value)}else l.getLogger(this).error(`Label expression failed to evaluate: ${d.error}`),c=!0})),n(t)}async _createLabelClassContext(e){return null==e.labelClassPromise&&(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(c(t))throw t;e.labelClassContexts.length=0})).then((()=>{e.labelClassAbortController=null,this.notifyChange("updating")})).catch((()=>{})),this.notifyChange("updating")),e.labelClassPromise}async _createTextRenderParameters(e){const t=e.symbolLayers.at(0);return"text"!==t?.type?null:P.fromSymbol(t,this.view.state.rasterPixelRatio)}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,o(t),e.labelClassContexts.length=0,e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,i,l,a){const r=new v(s,D(s.anchor),w(s.anchor),e.text,u(e.displayWidth,e.displayHeight));return H.graphic=t,H.renderingInfo=null,H.layer=i,l.createLabel(H,r,this._hudMaterialCollection,this._textTextureAtlas,(()=>{const e=T(a);return e?e.elevationOffset:null}))}_createLineCalloutGraphic(e,t,s,i,l){H.graphic=e,H.layer=l;const a=i.screenOffset[0];return H.renderingInfo=new C(null,t,i.translation,i.centerOffset,a,i.centerOffsetUnits,i.elevationOffset,this._calloutMaterialCollection),s.createGraphics3DGraphic(H)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,i=s.labelClassContexts;if(k(i)||!s.emptySymbolLabelSupported&&0===t.layers.length)return!1;let l=!1;const a=t.graphic,r=s.layer,o=B(s.layer);for(let n=0;n<i.length;n++){const c=e.textRenderers[n],h=e.textLabelPlacements[n];if(null==c||null==h)continue;const b=i[n],d=b.graphics3DSymbol,u=d.symbol&&"label-3d"===d.symbol.type?d.symbol:null,p=d.symbolLayers[0];if(!p)continue;p.setElevationInfoOverride(s.elevationInfoOverride);const y=new G(t,u,b.labelClass),g=this._createTextSymbolGraphic(c,a,h,r,p,y);if(null==g)return!1;g._labelClass=b.labelClass,g._labelIndex=n,t.addLabelGraphic(g,s.stageLayer),t.deconflictionPriority=b.textRenderParameters?.definition.size??0,t.setVisibilityFlag(m.LABEL,f.USER,o),t.setVisibilityFlag(m.LABEL,f.SCALE_RANGE,!0),t.setVisibilityFlag(m.LABEL,f.DECONFLICTION,!1),l=!0;const x=b.graphics3DCalloutSymbolLayer;if(x&&h.hasLabelVerticalOffset){x.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(a,u,x,h,r);null!=e&&(b.calloutSymbolLayerIndex=t.labelLayers.length,t.addLabelGraphic(e,s.stageLayer))}break}return l&&s.scaleVisibility?.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelLayers){if(null==s._labelClass)continue;const e=t[s._labelIndex].graphics3DSymbol.symbolLayers[0];e?.onRemoveGraphic(s)}e.graphics3DGraphic.deconflictionPriority=0,e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.textInitialized)return;const t=e.labelingContext,s=t.labelClassContexts;if(k(s))return;const i=e.graphics3DGraphic.graphic;for(let a=0;a<s.length;a++){const r=s[a];if(e.textRenderers[a]=null,e.textLabelPlacements[a]=null,null==r?.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?p(i,t.layer):i;n=o.evaluate(e)}catch(l){n=null}else n=o.evaluate(i);if(null==n||""===n||/^\s+$/.test(n))continue;const c=r.graphics3DSymbol,h="label-3d"===c.symbol?.type?c.symbol:null;if(!c.symbolLayers[0])continue;const b=e.graphics3DGraphic,d=r.labelClass,u=t.disablePlacement,y=T({graphics3DGraphic:b,labelSymbol:h,labelClass:d,disablePlacement:u});if(null==y)continue;const g=D(y.anchor),m=A(g);e.textRenderers[a]=new R(n,m,r.textRenderParameters,S.maxSize),e.textLabelPlacements[a]=y}e.textInitialized=!0}_destroyTextTextureResources(e){e.textInitialized=!1,e.textRenderers.length=0,e.textLabelPlacements.length=0}_addGraphic(e,t){const s=t.graphic.uid;if(e.graphics.set(s,t),e.active){const i=new z(e,t);this._labels.set(s,i),e.labelsToInitialize.set(s,i)}this.setDirty(),this.deconflictor.setDirty()}_removeGraphic(e,t){const s=t.graphic.uid,i=this._labels.get(s);e.graphics.delete(s),i&&(this._destroyGraphic(i,s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.delete(t),e.addedToTextureAtlas&&this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.graphics.get(s);t&&(this._removeGraphic(e,t),this._addGraphic(e,t))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const i=new Map;t.graphics.forEach((e=>i.set(e.graphic.uid,e)));const l=e=>e.labelLayers[0];if(s.graphics3DSymbol.symbolLayers[0].globalPropertyChanged(e,i,l),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelLayers[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,i,t)}}}_visibilityInfoChange(e){const t=B(e.layer);t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.graphics.forEach(((t,s)=>{const i=this._labels.get(s);i&&(this._destroyGraphic(i,s),i.visible=!1,e.labelsToInitialize.set(s,i))})),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const i=s&&s.emptySymbolLabelSupported||!1,l=s?.elevationInfoOverride||null,a=s?.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o=new M(this.view._stage,r,e,t,i,l,a,B(r));return this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),layerLabelsEnabled:()=>B(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),remove:()=>this._removeGraphicsOwner(e),setDirty:()=>this.setDirty()}}_removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.graphics.forEach((e=>this._removeGraphic(t,e))),t.destroy(),this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,i=this._labels.get(s);i&&i.visible!==t&&(t&&!i.addedToTextureAtlas?(this._addLabelTextureToAtlas(i),i.textInitialized||i.labelingContext.labelsToInitialize.set(s,i)):!t&&i.addedToTextureAtlas&&this._removeLabelTextureFromAtlas(i),i.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){return this._dirty||this._textTextureAtlas?.updating||this.deconflictor.updating||this._labelingContexts.some((e=>U(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(U(t)?0:1)),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get test(){return{textTextureAtlas:this._textTextureAtlas,resetAllLabels:()=>this._resetAllLabels()}}};function U(e){return!!e.labelClassPromise&&!!e.labelClassAbortController}function k(e){return!e||0===e.length}function B(e){return!0===e.labelsVisible&&!!e.labelingInfo?.some((e=>!!e.symbol))}e([b({constructOnly:!0})],V.prototype,"view",void 0),e([b({constructOnly:!0})],V.prototype,"deconflictor",void 0),e([b()],V.prototype,"_textTextureAtlas",void 0),e([b({type:Boolean,readOnly:!0})],V.prototype,"updating",null),V=e([d("esri.views.3d.layers.graphics.Labeler")],V);const H=new _(null,null,null);export{V as Labeler,B as areLabelsVisible};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Logger.js";import{s as t,l as n}from"../../../../chunks/vec32.js";import{ZEROS as r,fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,center as c,height as s}from"../../../../geometry/support/aaBoundingBox.js";import{labelMarginPx as o}from"./constants.js";import{getGraphics3DSymbol as i}from"./graphicSymbolUtils.js";import{LabelPlacement as f}from"./LabelParameters.js";import{textVerticalPaddingPx as m}from"../../webgl-engine/lib/TextRenderer.js";import{HUDMaterial as p}from"../../webgl-engine/materials/HUDMaterial.js";const u=()=>e.getLogger("esri.views.3d.layers.graphics.labelPlacement");class h{constructor(e,t,n,r=null){this.graphics3DGraphic=e,this.labelSymbol=t,this.labelClass=n,this.disablePlacement=r}}function b(e){const t=C(e);if(null==t)return null;const n=g(e,t);if(null==n)return null;const r=n.anchor,l=!!t.hasLabelVerticalOffset,a=t.verticalOffset;return P(new f(a,r,l),n,e)}function g(e,t){if(t.anchor)return t;const n=e.labelClass.labelPlacement,r=k[n],l=r||y(e);return n&&!r&&u().warnOncePerTick(`the requested label placement '${n}' is currently unsupported in SceneView.`),d(l,e)}function O(e){const t=e.graphics3DGraphic.graphics3DSymbol,n=i(t);return null!=n?n.symbol.symbolLayers.at(0):null}function d(e,t){const n=t.graphics3DGraphic.graphic.geometry;if(null==n)return null;if(null!=t.disablePlacement){return t.labelClass.labelPlacement?(u().warnOncePerTick(v(e?.placement,t.disablePlacement.logEntityDescription)),y(t)):e}const r=n.type;switch(r){case"polyline":case"polygon":case"extent":case"multipoint":if(t.labelClass.labelPlacement)return u().warnOncePerTick(v(e?.placement,`'${r}' geometries`)),y(t);break;case"point":case"mesh":return e}return e}function v(e,t){return`the requested label placement '${e}' is currently unsupported for ${t} in SceneView.`}function y(e){const t=e.graphics3DGraphic.graphic.geometry;if(null==t)return null;switch(t.type){case"polyline":case"extent":case"multipoint":return{placement:"center-center",normalizedOffset:r,anchor:"center"};case"polygon":{const t=O(e);return null!=t&&"extrude"===t.type?k["above-center"]:{placement:"center-center",normalizedOffset:r,anchor:"center"}}case"point":case"mesh":return k["above-center"];default:return}}function P(e,t,n){const r=n.graphics3DGraphic.graphic.geometry;if(null==r)return null;switch(r.type){case"point":z(e,t,n);break;case"polygon":w(e,t,n);break;case"mesh":j(e,t,n.graphics3DGraphic.layers[0])}const l=o-m;return e.screenOffset[0]+=l*t.normalizedOffset[0],e.screenOffset[1]+=l*t.normalizedOffset[1],e}function w(e,n,r){const l=O(r);if(null!=l)switch(l.type){case"extrude":{const l=r.graphics3DGraphic.layers[0];null!=l?(l.getBoundingBoxObjectSpace(B),c(B,e.translation),e.translation[2]=s(B)/2):t(e.translation,0,0,0),j(e,n,l);break}}}function z(e,n,r){const l=O(r);if(null==l)return;const a=r.graphics3DGraphic.layers[0];switch(null!=a?a.getCenterObjectSpace(e.translation):t(e.translation,0,0,0),l.type){case"icon":case"text":L(e,n,r,a);break;case"object":j(e,n,a)}}function L(e,t,n,r){const{graphics3DGraphic:l}=n,a=null!=r?r.getScreenSize():null;if(l.isDraped||null==a)e.hasLabelVerticalOffset||"center"===e.anchor||(k[n.labelClass.labelPlacement]&&u().warnOncePerTick(`the requested placement '${t.placement}' is currently unsupported for draped graphics`),e.anchor="center");else{const r=S(n);e.screenOffset[0]=a[0]/2*(t.normalizedOffset[0]-r[0]);const l=a[1]/2*(t.normalizedOffset[1]-r[1]);e.hasLabelVerticalOffset?(e.centerOffset[1]=l,e.centerOffsetUnits="screen"):e.screenOffset[1]=l}}function S(e,t=G){const{graphics3DGraphic:n}=e,r=n.layers[0],l=r?.stageObject.geometries[0].material??null;if(l&&l instanceof p){const e=l.parameters.anchorPosition;t[0]=2*(e[0]-.5),t[1]=2*(e[1]-.5)}else t[0]=0,t[1]=0;return t}function j(e,t,r){const a=null!=r?r.getBoundingBoxObjectSpace(B):B,c=l(a[3]-a[0],a[4]-a[1],a[5]-a[2]),s=Math.sqrt(c[0]*c[0]+c[1]*c[1]);e.centerOffset[0]=s/2*t.normalizedOffset[0];const o=e.translation[2],i=c[2]/2*t.normalizedOffset[1];e.translation[2]=0,e.elevationOffset=o+i;const f=n(c);e.centerOffset[2]=f/2*t.normalizedOffset[2]}function D(e){return"above-center"===e}function C(e){const t=e.labelClass.labelPlacement,{labelSymbol:n,graphics3DGraphic:r}=e,l=i(r.graphics3DSymbol),a="point-3d"===l?.symbol.type?l.symbol:null,c=k[t]||y(e);return null!=a&&a.supportsCallout()&&a.hasVisibleVerticalOffset()&&!r.isDraped?{placement:null,hasLabelVerticalOffset:!1,verticalOffset:x(a.verticalOffset),anchor:null,normalizedOffset:null}:!n||!n.hasVisibleVerticalOffset()||null!=a&&a.supportsCallout()&&a.verticalOffset&&!r.isDraped?{placement:null,verticalOffset:null,anchor:null,normalizedOffset:null,hasLabelVerticalOffset:!1}:c&&D(c.placement)?{placement:"above-center",verticalOffset:x(n.verticalOffset),anchor:"bottom",normalizedOffset:[0,c.normalizedOffset[1],0],hasLabelVerticalOffset:!0}:(u().errorOncePerTick("Callouts and vertical offset on labels are currently only supported with 'above-center' label placement (not with "+t+" placement)"),null)}function x(e){const{screenLength:t,minWorldLength:n,maxWorldLength:r}=e;return{screenLength:t,minWorldLength:n,maxWorldLength:r}}const k={"above-center":{placement:"above-center",normalizedOffset:[0,1,0],anchor:"bottom"},"above-left":{placement:"above-left",normalizedOffset:[-1,1,0],anchor:"bottom-right"},"above-right":{placement:"above-right",normalizedOffset:[1,1,0],anchor:"bottom-left"},"below-center":{placement:"below-center",normalizedOffset:[0,-1,2],anchor:"top"},"below-left":{placement:"below-left",normalizedOffset:[-1,-1,0],anchor:"top-right"},"below-right":{placement:"below-right",normalizedOffset:[1,-1,0],anchor:"top-left"},"center-center":{placement:"center-center",normalizedOffset:[0,0,1],anchor:"center"},"center-left":{placement:"center-left",normalizedOffset:[-1,0,0],anchor:"right"},"center-right":{placement:"center-right",normalizedOffset:[1,0,0],anchor:"left"}},V={"above-center":["default","esriServerPointLabelPlacementAboveCenter"],"above-left":["esriServerPointLabelPlacementAboveLeft"],"above-right":["esriServerPointLabelPlacementAboveRight"],"below-center":["esriServerPointLabelPlacementBelowCenter"],"below-left":["esriServerPointLabelPlacementBelowLeft"],"below-right":["esriServerPointLabelPlacementBelowRight"],"center-center":["esriServerPointLabelPlacementCenterCenter"],"center-left":["esriServerPointLabelPlacementCenterLeft"],"center-right":["esriServerPointLabelPlacementCenterRight"]};for(const T in V){const e=V[T],t=k[T];e.forEach((e=>{k[e]=t}))}Object.freeze&&(Object.freeze(k),Object.keys(k).forEach((e=>{Object.freeze(k[e]),Object.freeze(k[e]?.normalizedOffset)})));const G=[0,0],B=a();export{h as LabelInfo,b as getLabelPlacement};
5
+ import"../../../../core/has.js";import e from"../../../../core/Logger.js";import{s as t,l as n}from"../../../../chunks/vec32.js";import{ZEROS as r,fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,center as c,height as s}from"../../../../geometry/support/aaBoundingBox.js";import{labelMarginPx as o}from"./constants.js";import{getGraphics3DSymbol as i}from"./graphicSymbolUtils.js";import{LabelPlacement as f}from"./LabelParameters.js";import{textVerticalPaddingPx as m}from"../../webgl-engine/lib/TextRenderer.js";import{HUDMaterial as p}from"../../webgl-engine/materials/HUDMaterial.js";const u=()=>e.getLogger("esri.views.3d.layers.graphics.labelPlacement");class h{constructor(e,t,n,r=null){this.graphics3DGraphic=e,this.labelSymbol=t,this.labelClass=n,this.disablePlacement=r}}function b(e){const t=C(e);if(null==t)return null;const n=g(e,t);if(null==n)return null;const r=n.anchor,l=!!t.hasLabelVerticalOffset,a=t.verticalOffset;return P(new f(a,r,l),n,e)}function g(e,t){if(t.anchor)return t;const n=e.labelClass.labelPlacement,r=V[n],l=r||y(e);return n&&!r&&u().warnOncePerTick(`the requested label placement '${n}' is currently unsupported in SceneView.`),d(l,e)}function O(e){const t=e.graphics3DGraphic.graphics3DSymbol,n=i(t);return null!=n?n.symbol.symbolLayers.at(0):null}function d(e,t){const n=t.graphics3DGraphic.graphic.geometry;if(null==n)return null;if(null!=t.disablePlacement){return t.labelClass.labelPlacement?(u().warnOncePerTick(v(e?.placement,t.disablePlacement.logEntityDescription)),y(t)):e}const r=n.type;switch(r){case"polyline":case"polygon":case"extent":case"multipoint":if(t.labelClass.labelPlacement)return u().warnOncePerTick(v(e?.placement,`'${r}' geometries`)),y(t);break;case"point":case"mesh":return e}return e}function v(e,t){return`the requested label placement '${e}' is currently unsupported for ${t} in SceneView.`}function y(e){const t=e.graphics3DGraphic.graphic.geometry;if(null==t)return null;switch(t.type){case"polyline":case"extent":case"multipoint":return{placement:"center-center",normalizedOffset:r,anchor:"center"};case"polygon":{const t=O(e);return null!=t&&"extrude"===t.type?V["above-center"]:{placement:"center-center",normalizedOffset:r,anchor:"center"}}case"point":case"mesh":return V["above-center"];default:return}}function P(e,t,n){const r=n.graphics3DGraphic.graphic.geometry;if(null==r)return null;switch(r.type){case"point":case"mesh":z(e,t,n);break;case"polygon":w(e,t,n)}const l=o-m;return e.screenOffset[0]+=l*t.normalizedOffset[0],e.screenOffset[1]+=l*t.normalizedOffset[1],e}function w(e,n,r){const l=O(r);if(null!=l)switch(l.type){case"extrude":{const l=r.graphics3DGraphic.layers[0];null!=l?(l.getBoundingBoxObjectSpace(B),c(B,e.translation),e.translation[2]=s(B)/2):t(e.translation,0,0,0),j(e,n,l);break}}}function z(e,n,r){const l=O(r);if(null==l)return;const a=r.graphics3DGraphic.layers[0];switch(null!=a?a.getCenterObjectSpace(e.translation):t(e.translation,0,0,0),l.type){case"icon":case"text":L(e,n,r,a);break;case"object":case"fill":j(e,n,a)}}function L(e,t,n,r){const{graphics3DGraphic:l}=n,a=null!=r?r.getScreenSize():null;if(l.isDraped||null==a)e.hasLabelVerticalOffset||"center"===e.anchor||(V[n.labelClass.labelPlacement]&&u().warnOncePerTick(`the requested placement '${t.placement}' is currently unsupported for draped graphics`),e.anchor="center");else{const r=S(n);e.screenOffset[0]=a[0]/2*(t.normalizedOffset[0]-r[0]);const l=a[1]/2*(t.normalizedOffset[1]-r[1]);e.hasLabelVerticalOffset?(e.centerOffset[1]=l,e.centerOffsetUnits="screen"):e.screenOffset[1]=l}}function S(e,t=G){const{graphics3DGraphic:n}=e,r=n.layers[0],l=r?.stageObject.geometries[0].material??null;if(l&&l instanceof p){const e=l.parameters.anchorPosition;t[0]=2*(e[0]-.5),t[1]=2*(e[1]-.5)}else t[0]=0,t[1]=0;return t}function j(e,t,r){const a=null!=r?r.getBoundingBoxObjectSpace(B):B,c=l(a[3]-a[0],a[4]-a[1],a[5]-a[2]),s=Math.sqrt(c[0]*c[0]+c[1]*c[1]);e.centerOffset[0]=s/2*t.normalizedOffset[0];const o=e.translation[2],i=c[2]/2*t.normalizedOffset[1];e.translation[2]=0,e.elevationOffset=o+i;const f=n(c);e.centerOffset[2]=f/2*t.normalizedOffset[2]}function D(e){return"above-center"===e}function C(e){const t=e.labelClass.labelPlacement,{labelSymbol:n,graphics3DGraphic:r}=e,l=i(r.graphics3DSymbol),a="point-3d"===l?.symbol.type?l.symbol:null,c=V[t]||y(e);return null!=a&&a.supportsCallout()&&a.hasVisibleVerticalOffset()&&!r.isDraped?{placement:null,hasLabelVerticalOffset:!1,verticalOffset:x(a.verticalOffset),anchor:null,normalizedOffset:null}:!n||!n.hasVisibleVerticalOffset()||null!=a&&a.supportsCallout()&&a.verticalOffset&&!r.isDraped?{placement:null,verticalOffset:null,anchor:null,normalizedOffset:null,hasLabelVerticalOffset:!1}:c&&D(c.placement)?{placement:"above-center",verticalOffset:x(n.verticalOffset),anchor:"bottom",normalizedOffset:[0,c.normalizedOffset[1],0],hasLabelVerticalOffset:!0}:(u().errorOncePerTick("Callouts and vertical offset on labels are currently only supported with 'above-center' label placement (not with "+t+" placement)"),null)}function x(e){const{screenLength:t,minWorldLength:n,maxWorldLength:r}=e;return{screenLength:t,minWorldLength:n,maxWorldLength:r}}const V={"above-center":{placement:"above-center",normalizedOffset:[0,1,0],anchor:"bottom"},"above-left":{placement:"above-left",normalizedOffset:[-1,1,0],anchor:"bottom-right"},"above-right":{placement:"above-right",normalizedOffset:[1,1,0],anchor:"bottom-left"},"below-center":{placement:"below-center",normalizedOffset:[0,-1,2],anchor:"top"},"below-left":{placement:"below-left",normalizedOffset:[-1,-1,0],anchor:"top-right"},"below-right":{placement:"below-right",normalizedOffset:[1,-1,0],anchor:"top-left"},"center-center":{placement:"center-center",normalizedOffset:[0,0,1],anchor:"center"},"center-left":{placement:"center-left",normalizedOffset:[-1,0,0],anchor:"right"},"center-right":{placement:"center-right",normalizedOffset:[1,0,0],anchor:"left"}},k={"above-center":["default","esriServerPointLabelPlacementAboveCenter"],"above-left":["esriServerPointLabelPlacementAboveLeft"],"above-right":["esriServerPointLabelPlacementAboveRight"],"below-center":["esriServerPointLabelPlacementBelowCenter"],"below-left":["esriServerPointLabelPlacementBelowLeft"],"below-right":["esriServerPointLabelPlacementBelowRight"],"center-center":["esriServerPointLabelPlacementCenterCenter"],"center-left":["esriServerPointLabelPlacementCenterLeft"],"center-right":["esriServerPointLabelPlacementCenterRight"]};for(const T in k){const e=k[T],t=V[T];e.forEach((e=>{V[e]=t}))}Object.freeze&&(Object.freeze(V),Object.keys(V).forEach((e=>{Object.freeze(V[e]),Object.freeze(V[e]?.normalizedOffset)})));const G=[0,0],B=a();export{h as LabelInfo,b as getLabelPlacement};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as h}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as c,s as d,k as u}from"../../../chunks/vec32.js";import{ZEROS as p,fromValues as _,create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as C}from"./LayerClass.js";import{OverlayContent as R}from"./OverlayContent.js";import{overlayRenderOccludedFlag as x}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as w}from"./TileRenderer.js";import{TileUpdate as q}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as A,compareTiles as N}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as j,ComponentIntersectionData as B}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as F}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as U,ConsumesDepth as G,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as M}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as z}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as V}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as W,StoreResults as Y}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as Q}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as X,intersectTriangles as K}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as Z}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as J}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as $}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ee,getVerticalOffsetTerrain as te}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as ie}from"../webgl-engine/materials/DrawParameters.js";import{TerrainTechnique as re}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as se}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as ne}from"../../webgl/enums.js";const ae=7,oe=10,le=g();var he;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(he||(he={}));let ce=class extends U{get _isGlobal(){return this._stage.viewingMode===T.Global}get _techniques(){return this._context.techniqueRepository}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=W.TERRAIN,this.isGround=!0,this._tileSize=256,this._techniqueConfiguration=new se,this._passParameters=new L,this._drawParameters=new ie,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._transparencyState=he.Opaque,this._castShadows=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=Q.Occlude,this.produces=new Map([[Z.OPAQUE_TERRAIN,()=>this._produces()],[Z.TRANSPARENT_TERRAIN,()=>this._produces()],[Z.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?x:Q.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?G:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===he.TransparentWithDraped||e===he.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ee}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,q.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===q.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[C.ELEVATION])i.pendingUpdates&=~q.GEOMETRY;e.resetPendingUpdate(q.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=oe-ae,i=Math.max(0,Math.floor((e.level-t)/ae)*ae);if(this._isGlobal&&0===i)return p;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=z.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=z.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=z.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new w(this._rctx,this._tileSize,this._techniques,this._tileTextureCache),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==he.Opaque)return;const s=de,n=ue;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,p=e.options.store===Y.MIN,_=!!e.results.ground.target,f=te(e.verticalOffset),m=e.tolerance;let g,T=p&&null!=a.dist?a.dist:1/0;const O=d=>{const _=d.renderData;if(!_?.vao)return;const O=_.geometry;b(le,O.boundingBox);const C=_.localOrigin;null!=f&&(f.localOrigin=C,f.applyToAabb(le));const R=le;if(pe[0]=i[0]-C[0],pe[1]=i[1]-C[1],pe[2]=i[2]-C[2],!X(R,pe,n,m,T))return;const x=(e,t,i)=>{e.set(this.type,d,t,i,h),T=p&&null!=a.dist?a.dist:1/0},P=(n,h)=>{if(null!=h&&n>=0&&(e.options.backfacesTerrain||u(h,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&x(l,n,h),e.options.isFiltered)return;e.options.store===Y.ALL&&(null==g?(g=V(e.ray),x(g,n,h),e.results.all.push(g)):n<g.dist&&x(g,n,h)),(null==a.dist||n<a.dist)&&x(a,n,h),e.options.store!==Y.MIN&&(null==o.dist||n>o.dist)&&x(o,n,h)}},v=_e;c(v,r,C);const{indices:D,indexCount:S}=O,w=O.vertexAttributes,q=w.getField($.POSITION,y),E=new M(q.typedBuffer,3,w.stride/4),A=S/3;if(!f&&A>j){const e=d.renderData;null==e.intersectionData&&(e.intersectionData=new B(D,0,A,E)),e.intersectionData.intersectRay(pe,v,P)}else K(pe,v,0,A,D,E,null,f,P)},C=this._rootTiles;if(null!=C){(()=>{const t=this._tileIterator;t.reset(C);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==f&&!e.intersectsRay(i,s,m,T)||_&&this._useStencilForTile(e)?t.skipSubtree():O(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;if(t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0),e.bindParameters.slot===Z.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&x))return null}else{const t=this.transparency===he.Opaque?Z.OPAQUE_TERRAIN:Z.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===he.Empty)return null;switch(e.output){case I.Color:return this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._techniqueConfiguration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(I.Color,e.bindParameters.slot===Z.OCCLUDED_TERRAIN);case I.Shadow:case I.ShadowExcludeHighlight:return this._castShadows?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Shadow,!1)):null;case I.LinearDepth:return this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.LinearDepth,!1);case I.Normal:return this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Normal,!1);case I.ObjectAndLayerIdColor:return this._updateTechnique(I.ObjectAndLayerIdColor,!1);case I.Highlight:return this._overlayRenderer.hasHighlights?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case I.Color:{const i=e.bindParameters.slot===Z.OCCLUDED_TERRAIN?R.Occluded:R.Color;this._renderMaterialPass(e,t,i);break}case I.LinearDepth:case I.Normal:this._renderAuxiliaryPass(e,t,R.Color,this._visiblePatchesByOrigin);break;case I.Highlight:this._renderAuxiliaryPass(e,t,R.Highlight,this._visiblePatchesByOrigin);break;case I.Shadow:case I.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case I.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=_(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,O.FADING))),this._techniqueConfiguration.tileBlendInput=i.backgroundIsGrid?F.GridComposite:null!=i.backgroundColor?F.ColorComposite:F.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)A(this.renderOrder,i,t);e.sort(((e,t)=>N(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(this._drawParameters,e.bindParameters,this._passParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],ne.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.camera,n=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=J(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===R.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",p),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:p;this._techniqueConfiguration.tileBlendInput===F.ColorComposite&&n.setUniform3fv("backgroundColor",l);const h=this.wireframe?ne.LINES:ne.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const r=d[0].renderData.localOrigin;t.program.bindDraw(new ie(r),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const s of d){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,h,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(S&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const h=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const c=a.geometry.indexCount;e.rctx.bindVAO(o),h.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(re,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([o({readOnly:!0})],ce.prototype,"_isGlobal",null),e([o()],ce.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ce.prototype,"renderingDisabled",null),e([o({value:!0})],ce.prototype,"visible",null),e([o()],ce.prototype,"renderPatchBorders",null),e([o()],ce.prototype,"visualizeNormals",null),e([o()],ce.prototype,"cullBackFaces",null),e([o({value:v.FRONT_TO_BACK})],ce.prototype,"renderOrder",null),e([o()],ce.prototype,"wireframe",null),ce=e([l("esri.views.3d.terrain.TerrainRenderer")],ce);const de=f(),ue=f(),pe=f(),_e=f();export{ce as TerrainRenderer,he as TransparencyMode};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as h}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as c,s as d,k as u}from"../../../chunks/vec32.js";import{ZEROS as p,fromValues as _,create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as C}from"./LayerClass.js";import{OverlayContent as R}from"./OverlayContent.js";import{overlayRenderOccludedFlag as x}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as w}from"./TileRenderer.js";import{TileUpdate as q}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as A,compareTiles as N}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as j,ComponentIntersectionData as B}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as F}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as U,ConsumesDepth as G,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as M}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as z}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as V}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as W,StoreResults as Y}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as Q}from"../webgl-engine/lib/Material.js";import{intersectAabbInvDirBefore as X,intersectTriangles as K}from"../webgl-engine/lib/RayIntersections.js";import{RenderSlot as Z}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as J}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as $}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as ee,getVerticalOffsetTerrain as te}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as ie}from"../webgl-engine/materials/DrawParameters.js";import{TerrainTechnique as re}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as se}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as ne}from"../../webgl/enums.js";const ae=7,oe=10,le=g();var he;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(he||(he={}));let ce=class extends U{get _isGlobal(){return this._stage.viewingMode===T.Global}get _techniques(){return this._context.techniqueRepository}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=W.TERRAIN,this.isGround=!0,this._tileSize=256,this._techniqueConfiguration=new se,this._passParameters=new L,this._drawParameters=new ie,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._transparencyState=he.Opaque,this._castShadows=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=Q.Occlude,this.produces=new Map([[Z.OPAQUE_TERRAIN,()=>this._produces()],[Z.TRANSPARENT_TERRAIN,()=>this._produces()],[Z.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?x:Q.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?G:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===he.TransparentWithDraped||e===he.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return ee}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,q.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===q.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[C.ELEVATION])i.pendingUpdates&=~q.GEOMETRY;e.resetPendingUpdate(q.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=oe-ae,i=Math.max(0,Math.floor((e.level-t)/ae)*ae);if(this._isGlobal&&0===i)return p;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=z.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=z.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=z.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new w(this._rctx,this._tileSize,this._techniques,this._tileTextureCache),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==he.Opaque)return;const s=de,n=ue;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,p=e.options.store===Y.MIN,_=!!e.results.ground.target,f=te(e.verticalOffset),m=e.tolerance;let g,T=p&&null!=a.dist?a.dist:1/0;const O=d=>{const _=d.renderData;if(!_?.vao)return;const O=_.geometry;b(le,O.boundingBox);const C=_.localOrigin;null!=f&&(f.localOrigin=C,f.applyToAabb(le));const R=le;if(pe[0]=i[0]-C[0],pe[1]=i[1]-C[1],pe[2]=i[2]-C[2],!X(R,pe,n,m,T))return;const x=(e,t,i)=>{e.set(this.type,d,t,i,h),T=p&&null!=a.dist?a.dist:1/0},P=(n,h)=>{if(null!=h&&n>=0&&(e.options.backfacesTerrain||u(h,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&x(l,n,h),e.options.isFiltered)return;e.options.store===Y.ALL&&(null==g?(g=V(e.ray),x(g,n,h),e.results.all.push(g)):n<g.dist&&x(g,n,h)),(null==a.dist||n<a.dist)&&x(a,n,h),e.options.store!==Y.MIN&&(null==o.dist||n>o.dist)&&x(o,n,h)}},v=_e;c(v,r,C);const{indices:D,indexCount:S}=O,w=O.vertexAttributes,q=w.getField($.POSITION,y),E=new M(q.typedBuffer,3,w.stride/4),A=S/3;if(!f&&A>j){const e=d.renderData;null==e.intersectionData&&(e.intersectionData=new B(D,0,A,E)),e.intersectionData.intersectRay(pe,v,P)}else K(pe,v,0,A,D,E,f,P)},C=this._rootTiles;if(null!=C){(()=>{const t=this._tileIterator;t.reset(C);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==f&&!e.intersectsRay(i,s,m,T)||_&&this._useStencilForTile(e)?t.skipSubtree():O(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;if(t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0),e.bindParameters.slot===Z.OCCLUDED_TERRAIN){if(!(e.renderOccludedMask&x))return null}else{const t=this.transparency===he.Opaque?Z.OPAQUE_TERRAIN:Z.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===he.Empty)return null;switch(e.output){case I.Color:return this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._techniqueConfiguration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(I.Color,e.bindParameters.slot===Z.OCCLUDED_TERRAIN);case I.Shadow:case I.ShadowExcludeHighlight:return this._castShadows?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Shadow,!1)):null;case I.LinearDepth:return this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.LinearDepth,!1);case I.Normal:return this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Normal,!1);case I.ObjectAndLayerIdColor:return this._updateTechnique(I.ObjectAndLayerIdColor,!1);case I.Highlight:return this._overlayRenderer.hasHighlights?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case I.Color:{const i=e.bindParameters.slot===Z.OCCLUDED_TERRAIN?R.Occluded:R.Color;this._renderMaterialPass(e,t,i);break}case I.LinearDepth:case I.Normal:this._renderAuxiliaryPass(e,t,R.Color,this._visiblePatchesByOrigin);break;case I.Highlight:this._renderAuxiliaryPass(e,t,R.Highlight,this._visiblePatchesByOrigin);break;case I.Shadow:case I.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case I.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=_(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,O.FADING))),this._techniqueConfiguration.tileBlendInput=i.backgroundIsGrid?F.GridComposite:null!=i.backgroundColor?F.ColorComposite:F.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)A(this.renderOrder,i,t);e.sort(((e,t)=>N(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(this._drawParameters,e.bindParameters,this._passParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],ne.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.camera,n=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=J(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===R.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",p),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:p;this._techniqueConfiguration.tileBlendInput===F.ColorComposite&&n.setUniform3fv("backgroundColor",l);const h=this.wireframe?ne.LINES:ne.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const r=d[0].renderData.localOrigin;t.program.bindDraw(new ie(r),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const s of d){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,h,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(S&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const h=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const c=a.geometry.indexCount;e.rctx.bindVAO(o),h.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(re,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([o({readOnly:!0})],ce.prototype,"_isGlobal",null),e([o()],ce.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ce.prototype,"renderingDisabled",null),e([o({value:!0})],ce.prototype,"visible",null),e([o()],ce.prototype,"renderPatchBorders",null),e([o()],ce.prototype,"visualizeNormals",null),e([o()],ce.prototype,"cullBackFaces",null),e([o({value:v.FRONT_TO_BACK})],ce.prototype,"renderOrder",null),e([o()],ce.prototype,"wireframe",null),ce=e([l("esri.views.3d.terrain.TerrainRenderer")],ce);const de=f(),ue=f(),pe=f(),_e=f();export{ce as TerrainRenderer,he as TransparencyMode};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as t}from"../../../../../core/mathUtils.js";import{create as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as i}from"../../../../../geometry/support/aaBoundingBox.js";import{intersectRayTriangles as n}from"../../lib/RayIntersections.js";const r=200,s=40,o=.8,a=10,c=1e-6;function h(t,e,i){const n=e,r=i;let s=0,o=1/0;for(let a=0;a<3;++a){{const e=t[a];if(n[a]<e){if(r[a]<=c)return!1;const t=(e-n[a])/r[a];s=Math.max(s,t)}else if(r[a]<=-c){const t=(e-n[a])/r[a];o=Math.min(o,t)}if(s>o)return!1}{const e=t[a+3];if(n[a]>e){if(r[a]>=-c)return!1;const t=(e-n[a])/r[a];s=Math.max(s,t)}else if(r[a]>=c){const t=(e-n[a])/r[a];o=Math.min(o,t)}if(s>o)return!1}}return!0}class f{constructor(t,e,i,n,r){this.aabb=t,this.axis=e,this.d=i,this.midStartIndex=n,this.rightStartIndex=r}}class l{constructor(i,n,r,c){this.globalTriangleVertexIndices=i,this.firstTriangleIndex=n,this.positions=c,this._rayDirection=e(),this.bspNodeTree=new Array;const h=r-n,l=h<=p?new Uint16Array(h):new Uint32Array(h);this.indices=l;for(let t=0;t<h;++t)l[t]=t;{const e=y(i,n,r,c.data,c.stride),d=t(Math.log2(h/s),2,a),m=(t,i,n)=>{const r=g(l,e,t,i),a=i-t;if(a<=s){const e=new f(r,void 0,0,t,i);return this.bspNodeTree.push(e),e}const{axis:c,midValue:h}=x(r),y=u(l,e,t,i,c,h),N=(t,e)=>{if(n>d)return;const i=e-t;return i<s||i>=o*a?void 0:m(t,e,n+1)},p=new f(r,c,h,y.next,y.mid);return this.bspNodeTree.push(p),p.leftNode=N(t,y.next),p.rightNode=N(y.mid,i),p};m(0,h,0),this.triangleVertexIndices=N(l,i,n,r)}}intersectRayTriangleRange(t,e){if(t>=e)return;const i=this.triangleVertexIndices,r=this.positions.data,s=this.positions.stride;n(this._rayFrom,this._rayDirection,t,e,s,i,r,this._callback),l.numFacesTested+=e-t}intersectRay(t,e,i){l.numFacesTested=0;const n=t,r=e,s=r[0]-n[0],o=r[1]-n[1],a=r[2]-n[2];if(s*s+o*o+a*a<c)return;this._rayFrom=n;const h=this._rayDirection;h[0]=s,h[1]=o,h[2]=a;const f=this.triangleVertexIndices.length/3;this._callback=i;const d=this.bspNodeTree[0];this.intersectRayBSP(d,0,f)}intersectRayBSP(t,e,i){const n=this._rayFrom,r=this._rayDirection;if(!h(t.aabb,n,r))return;const s=t.axis,o=t.d;if(n[s]<o||r[s]<0){const i=e,n=t.midStartIndex;if(i<n){const e=t.leftNode;void 0!==e?this.intersectRayBSP(e,i,n):this.intersectRayTriangleRange(i,n)}}if(this.intersectRayTriangleRange(t.midStartIndex,t.rightStartIndex),n[s]>o||r[s]>0){const e=t.rightStartIndex,n=i;if(e<n){const i=t.rightNode;void 0!==i?this.intersectRayBSP(i,e,n):this.intersectRayTriangleRange(e,n)}}}get estimatedMemoryUsage(){return this.triangleVertexIndices.byteLength+this.indices.byteLength}}l.numFacesTested=0;const d=[1/0,1/0,1/0],m=[-1/0,-1/0,-1/0];function u(t,e,i,n,r,s){let o=i,a=n;for(;o<a;){const i=t[o];e[6*i+r+3]<=s?++o:(--a,t[o]=t[a],t[a]=i)}let c=o;for(a=n;c<a;){const i=t[a-1];e[6*i+r]>=s?--a:(t[a-1]=t[c],t[c]=i,++c)}return{next:o,mid:c}}function g(t,e,n,r){if(r<=n)return i(NaN,NaN,NaN,NaN,NaN,NaN);{const i=6*t[n];for(let t=0;t<3;++t)d[t]=e[i+0+t],m[t]=e[i+3+t]}for(let i=n+1;i<r;++i){const n=6*t[i];for(let t=0;t<3;++t)d[t]=Math.min(d[t],e[n+0+t]),m[t]=Math.max(m[t],e[n+3+t])}return i(d[0],d[1],d[2],m[0],m[1],m[2])}function x(t){const e=t[3]-t[0],i=t[4]-t[1],n=t[5]-t[2],r=e>i?e>n?0:i>n?1:2:i>n?1:n>e?2:0;return{axis:r,midValue:(t[r]+t[r+3])/2}}function y(t,e,i,n,r){const s=i-e,o=new Float32Array(6*s);for(let a=0;a<s;++a){const i=3*(a+e),s=t[i]*r,c=t[i+1]*r,h=t[i+2]*r;for(let t=0;t<3;++t){const e=n[s+t],i=n[c+t],r=n[h+t];o[6*a+t]=Math.min(e,i,r),o[6*a+3+t]=Math.max(e,i,r)}}return o}function N(t,e,i,n){const r=n-i;let s=0;for(let a=i;a<n;++a)for(let t=0;t<3;++t)s=Math.max(e[3*a+t],s);const o=s<=p?new Uint16Array(3*r):new Uint32Array(3*r);for(let a=0;a<r;++a){const n=3*(t[a]+i);for(let t=0;t<3;++t){const i=e[n+t];o[3*a+t]=i}}return o}const p=65535;export{l as ComponentIntersectionData,r as componentMinimalSizeForIntersectionData};
5
+ import{clamp as t}from"../../../../../core/mathUtils.js";import{create as e}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as i}from"../../../../../geometry/support/aaBoundingBox.js";import{intersectRayTriangles as n}from"../../lib/RayIntersections.js";const r=200,s=40,a=.8,o=10,c=1e-6;function h(t,e,i){const n=e,r=i;let s=0,a=1/0;for(let o=0;o<3;++o){{const e=t[o];if(n[o]<e){if(r[o]<=c)return!1;const t=(e-n[o])/r[o];s=Math.max(s,t)}else if(r[o]<=-c){const t=(e-n[o])/r[o];a=Math.min(a,t)}if(s>a)return!1}{const e=t[o+3];if(n[o]>e){if(r[o]>=-c)return!1;const t=(e-n[o])/r[o];s=Math.max(s,t)}else if(r[o]>=c){const t=(e-n[o])/r[o];a=Math.min(a,t)}if(s>a)return!1}}return!0}class d{constructor(t,e,i,n,r){this.aabb=t,this.axis=e,this.d=i,this.midStartIndex=n,this.rightStartIndex=r}}class l{constructor(i,n,r,c){this.globalTriangleVertexIndices=i,this.firstTriangleIndex=n,this.positions=c,this._rayDirection=e(),this.bspNodeTree=new Array;const h=r-n,l=new(h<N?Uint8Array:h<p?Uint16Array:Uint32Array)(h);this.triangleIndexMap=l;for(let t=0;t<h;++t)l[t]=t;{const e=y(i,n,r,c.data,c.stride),f=t(Math.log2(h/s),2,o),m=(t,i,n)=>{const r=g(l,e,t,i),o=i-t;if(o<=s){const e=new d(r,void 0,0,t,i);return this.bspNodeTree.push(e),e}const{axis:c,midValue:h}=x(r),y=u(l,e,t,i,c,h),N=(t,e)=>{if(n>f)return;const i=e-t;return i<s||i>=a*o?void 0:m(t,e,n+1)},p=new d(r,c,h,y.next,y.mid);return this.bspNodeTree.push(p),p.leftNode=N(t,y.next),p.rightNode=N(y.mid,i),p};m(0,h,0)}}intersectRayTriangleRange(t,e){if(t>=e)return;const i=this.positions;n(this._rayFrom,this._rayDirection,t,e,this.globalTriangleVertexIndices,i.data,i.stride,this._callback,this.triangleIndexMap,this.firstTriangleIndex),l.numFacesTested+=e-t}intersectRay(t,e,i){l.numFacesTested=0;const n=t,r=e,s=r[0]-n[0],a=r[1]-n[1],o=r[2]-n[2];if(s*s+a*a+o*o<c)return;this._rayFrom=n;const h=this._rayDirection;h[0]=s,h[1]=a,h[2]=o;const d=this.triangleIndexMap.length;this._callback=i;const f=this.bspNodeTree[0];this.intersectRayBSP(f,0,d)}intersectRayBSP(t,e,i){const n=this._rayFrom,r=this._rayDirection;if(!h(t.aabb,n,r))return;const s=t.axis,a=t.d;if(n[s]<a||r[s]<0){const i=e,n=t.midStartIndex;if(i<n){const e=t.leftNode;void 0!==e?this.intersectRayBSP(e,i,n):this.intersectRayTriangleRange(i,n)}}if(this.intersectRayTriangleRange(t.midStartIndex,t.rightStartIndex),n[s]>a||r[s]>0){const e=t.rightStartIndex,n=i;if(e<n){const i=t.rightNode;void 0!==i?this.intersectRayBSP(i,e,n):this.intersectRayTriangleRange(e,n)}}}get estimatedMemoryUsage(){return this.triangleIndexMap.byteLength}}l.numFacesTested=0;const f=[1/0,1/0,1/0],m=[-1/0,-1/0,-1/0];function u(t,e,i,n,r,s){let a=i,o=n;for(;a<o;){const i=t[a];e[6*i+r+3]<=s?++a:(--o,t[a]=t[o],t[o]=i)}let c=a;for(o=n;c<o;){const i=t[o-1];e[6*i+r]>=s?--o:(t[o-1]=t[c],t[c]=i,++c)}return{next:a,mid:c}}function g(t,e,n,r){if(r<=n)return i(NaN,NaN,NaN,NaN,NaN,NaN);{const i=6*t[n];for(let t=0;t<3;++t)f[t]=e[i+0+t],m[t]=e[i+3+t]}for(let i=n+1;i<r;++i){const n=6*t[i];for(let t=0;t<3;++t)f[t]=Math.min(f[t],e[n+0+t]),m[t]=Math.max(m[t],e[n+3+t])}return i(f[0],f[1],f[2],m[0],m[1],m[2])}function x(t){const e=t[3]-t[0],i=t[4]-t[1],n=t[5]-t[2],r=e>i?e>n?0:i>n?1:2:i>n?1:n>e?2:0;return{axis:r,midValue:(t[r]+t[r+3])/2}}function y(t,e,i,n,r){const s=i-e,a=new Float32Array(6*s);for(let o=0;o<s;++o){const i=3*(o+e),s=t[i]*r,c=t[i+1]*r,h=t[i+2]*r;for(let t=0;t<3;++t){const e=n[s+t],i=n[c+t],r=n[h+t];a[6*o+t]=Math.min(e,i,r),a[6*o+3+t]=Math.max(e,i,r)}}return a}const N=255,p=65535;export{l as ComponentIntersectionData,r as componentMinimalSizeForIntersectionData};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{invert as t,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{z as e,t as s,F as i,s as a,n as m,c,k as p,b as r,o as h}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as x}from"../../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../../geometry/support/FloatArray.js";import{compactIndices as _,getContinuousIndexArray as I}from"../../../../../geometry/support/Indices.js";import{ViewingMode as f}from"../../../../ViewingMode.js";import{componentMinimalSizeForIntersectionData as C,ComponentIntersectionData as u}from"./ComponentIntersectionData.js";import{Vertices as M}from"../../lib/Attribute.js";import{getVisibility as g}from"../../lib/ComponentUtils.js";import{computeInvDir as A,intersectAabbInvDir as j,intersectTriangles as y}from"../../lib/RayIntersections.js";class B{constructor(t,n,o){this.viewingMode=t,this.positionData=n,this._components=o,this._planetCenter=d(),this._planetNorth=d(),this._componentIndicesForBsp=null,this._componentBspNodes=[],this._aabb=[0,0,0,0,0,0],this._indices=n.indices?_(n.indices):I(n.positions.length/3),this._positions=n.positions,this._componentIntersectionData=new Array(o.count)}destroy(){this._positions=null,this._indices=null,this._componentIntersectionData.length=0,this._perComponentAabbs=null}getComponentAabb(t,n){const o=this._ensureComponentAabbs(),e=6*t;return n[0]=o[e],n[1]=o[e+1],n[2]=o[e+2],n[3]=o[e+3],n[4]=o[e+4],n[5]=o[e+5],n}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs()),this._perComponentAabbs}getComponentPositions(t,n){n.indices=this._indices,n.data=this._positions,n.stride=3,n.startIndex=this._components.offsets[t],n.endIndex=this._components.offsets[t+1]}intersect(o,p,r,h,d,l,x,b){const{position:_}=x,I=e(D,o,_),g=e(F,p,_),B=t(R,x.rotationScale);s(I,I,B),s(g,g,B);const v=n(P,B),k=new M(this._positions,3),z=this._indices,E=this._components.offsets,G=A(I,g,w);if(this.viewingMode===f.Global){const t=this._planetCenter;i(t,_),s(t,t,B);const n=this._planetNorth;a(n,0,0,1),s(n,n,B),m(n,n)}const L=c(U,I),O=c(V,g),S=e(q,g,I);m(S,S);const T=t=>{const n=this.getComponentAabb(t,N);if(null!=d){const n=d[t];null==h||b?(I[2]=L[2]-n,g[2]=O[2]-n):h.componentOffset=n}if(null==h||b||h.applyToAabb(n),!j(n,I,G,r))return;const o=E[t]/3,e=E[t+1]/3,i=(n,o,e)=>l(t,n,s(o,o,v),e);(null==h||b)&&e-o>C?(null==this._componentIntersectionData[t]&&(this._componentIntersectionData[t]=new u(this._indices,o,e,k)),this._componentIntersectionData[t].intersectRay(I,g,i)):y(I,g,o,e,z,k,void 0,h,i)};this._intersectComponents(T,b,I,g)}_intersectComponents(t,n,o,s){const i=this._components.pickability,a=this._components.visibility;if(this._components.visibility.componentCount<H){const n=n=>(g(i,n)&&t(n),!0);return void a.forEachComponent(n)}0===this._componentBspNodes.length&&this._generateComponentBspRoot();const c=this._componentIndicesForBsp,r=n=>{g(i,n)&&a.isVisible(n)&&t(n)},h=(t,n)=>{for(let o=t;o<n;++o)r(c[o])};if(n){let t=0;for(;t>=0;){const n=this._componentBspNodes[t],e=n.plane;if(!e||-1===n.child0&&-1===n.child1){h(n.minComponentIndexIndex,n.maxComponentIndexIndex);break}{h(n.minMidComponentIndexIndex,n.maxMidComponentIndexIndex);const s=p(e,o)-e[3];if(s<0){if(-1===n.child0){h(n.minComponentIndexIndex,n.minMidComponentIndexIndex);break}t=n.child0}else{if(!(s>0))break;if(-1===n.child1){h(n.maxMidComponentIndexIndex,n.maxComponentIndexIndex);break}t=n.child1}}}}else{const t=J;e(t,s,o),m(t,t);const n=this._componentBspNodes,i=e=>{const s=n[e],a=s.plane;if(!a||-1===s.child0&&-1===s.child1)h(s.minComponentIndexIndex,s.maxComponentIndexIndex);else{const n=p(a,o)-a[3],e=p(a,t);s.minComponentIndexIndex<s.minMidComponentIndexIndex&&(n<=0||e<0)&&(-1!==s.child0?i(s.child0):h(s.minComponentIndexIndex,s.minMidComponentIndexIndex)),h(s.minMidComponentIndexIndex,s.maxMidComponentIndexIndex),s.maxMidComponentIndexIndex<s.maxComponentIndexIndex&&(n>=0||e>0)&&(-1!==s.child1?i(s.child1):h(s.maxMidComponentIndexIndex,s.maxComponentIndexIndex))}};i(0)}}_generateComponentBspRoot(){const t=this._components.count,n=new Uint16Array(t);this._componentIndicesForBsp=n;for(let e=0;e<t;++e)n[e]=e;const o=this._ensureComponentAabbs(),s=this._planetCenter,d=this._planetNorth,x=G;i(x,s),m(x,x);r(L,d,x);const b=this._aabb,_=b[2],I=[];let C=0;const u=this._componentBspNodes;u.length=0;const M=(t,n)=>{const e=6*t,s=o[e],i=o[e+1],m=o[e+2],c=o[e+3],r=o[e+4],h=o[e+5],d=a(O,.5*(s+c),.5*(i+r),.5*(m+h)),l=.5*(c-s),x=.5*(r-i),b=.5*(h-m),_=Math.sqrt(l*l+x*x+b*b),I=n,f=n[3],C=p(I,d)-f;return Math.abs(C)>_?Math.sign(C):0},g=(t,e,s)=>{let i=1/0,a=1/0,m=1/0,c=-1/0,p=-1/0,r=-1/0;for(let h=e;h<s;++h){const t=6*n[h];i=Math.min(i,o[t]),c=Math.max(c,o[t+3]),a=Math.min(a,o[t+1]),p=Math.max(p,o[t+4]),m=Math.min(m,o[t+2]),r=Math.max(r,o[t+5])}t[0]=i,t[1]=a,t[2]=m,t[3]=c,t[4]=p,t[5]=r},A=this.viewingMode===f.Local;let j=!1;if(!A){const t=a(O,.5*(b[0]+b[3]),.5*(b[1]+b[4]),.5*(b[2]+b[5])),n=h(s,t);j=_>.5*n}const y=(t,o,i,h,x)=>{const b=u.length;let _;if(j||i>=T||o-t<S)_=new v(t,o,o,o,null);else{g(k,t,o);const h=k[0],x=k[1],f=k[2],C=k[3],u=k[4],j=C-h,B=u-x,w=l(),N=w;if(A)j>=B?(a(N,1,0,0),w[3]=-.5*(h+C)):(a(N,0,1,0),w[3]=-.5*(x+u));else{const t=z,n=E;a(t,.5*(h+C),.5*(x+u),f),e(t,t,s),m(t,t),r(n,t,d),m(n,n),j>=B?c(N,n):(r(N,n,t),m(N,N)),w[3]=p(N,s)}let D,F;{let e=t,s=o;for(;e<s;){const t=n[e];M(t,w)<0?++e:(--s,n[e]=n[s],n[s]=t)}D=e;let i=e;for(s=o;i<s;){const t=n[s-1];M(t,w)>0?--s:(n[s-1]=n[i],n[i]=t,++i)}F=s}_=new v(t,D,F,o,w),D>=t+S&&I.push((()=>y(t,D,i+1,b,!0))),o>=F+S&&I.push((()=>y(F,o,i+1,b,!1)))}if(u.push(_),-1!==h){const t=u[h];x?t.child0=b:t.child1=b}};for(I.push((()=>y(0,t,0,-1,!1)));C<I.length;){(0,I[C])(),++C}}_computePerComponentAabbs(){const t=this._components.count,n=b(6*t),o=this._indices,e=this._positions,s=this._components.offsets;let i=0,a=1/0,m=1/0,c=1/0,p=-1/0,r=-1/0,h=-1/0;for(let d=0;d<t;d++){const t=s[d],l=s[d+1];let x=1/0,b=1/0,_=1/0,I=-1/0,f=-1/0,C=-1/0;for(let n=t;n<l;n++){const t=3*o[n],s=e[t],i=e[t+1],a=e[t+2];x=Math.min(x,s),b=Math.min(b,i),_=Math.min(_,a),I=Math.max(I,s),f=Math.max(f,i),C=Math.max(C,a)}n[i++]=x,n[i++]=b,n[i++]=_,n[i++]=I,n[i++]=f,n[i++]=C,a=Math.min(a,x),m=Math.min(m,b),c=Math.min(c,_),p=Math.max(p,I),r=Math.max(r,f),h=Math.max(h,C)}return this._aabb[0]=a,this._aabb[1]=m,this._aabb[2]=c,this._aabb[3]=p,this._aabb[4]=r,this._aabb[5]=h,n}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}class v{constructor(t,n,o,e,s){this.minComponentIndexIndex=t,this.minMidComponentIndexIndex=n,this.maxMidComponentIndexIndex=o,this.maxComponentIndexIndex=e,this.plane=s,this.child0=-1,this.child1=-1}}const w=d(),N=x(),k=[0,0,0,0,0,0],D=d(),F=d(),R=o(),P=o(),U=d(),V=d(),q=d(),z=d(),E=d(),G=d(),L=d(),O=d(),S=5,T=10,H=7,J=d();export{B as default};
5
+ import{invert as t,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{z as e,t as s,F as i,s as a,n as m,c,k as p,b as r,o as h}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as x}from"../../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../../geometry/support/FloatArray.js";import{compactIndices as _,getContinuousIndexArray as I}from"../../../../../geometry/support/Indices.js";import{ViewingMode as f}from"../../../../ViewingMode.js";import{componentMinimalSizeForIntersectionData as C,ComponentIntersectionData as u}from"./ComponentIntersectionData.js";import{Vertices as M}from"../../lib/Attribute.js";import{getVisibility as g}from"../../lib/ComponentUtils.js";import{computeInvDir as A,intersectAabbInvDir as j,intersectTriangles as y}from"../../lib/RayIntersections.js";class B{constructor(t,n,o){this.viewingMode=t,this.positionData=n,this._components=o,this._planetCenter=d(),this._planetNorth=d(),this._componentIndicesForBsp=null,this._componentBspNodes=[],this._aabb=[0,0,0,0,0,0],this._indices=n.indices?_(n.indices):I(n.positions.length/3),this._positions=n.positions,this._componentIntersectionData=new Array(o.count)}destroy(){this._positions=null,this._indices=null,this._componentIntersectionData.length=0,this._perComponentAabbs=null}getComponentAabb(t,n){const o=this._ensureComponentAabbs(),e=6*t;return n[0]=o[e],n[1]=o[e+1],n[2]=o[e+2],n[3]=o[e+3],n[4]=o[e+4],n[5]=o[e+5],n}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs()),this._perComponentAabbs}getComponentPositions(t,n){n.indices=this._indices,n.data=this._positions,n.stride=3,n.startIndex=this._components.offsets[t],n.endIndex=this._components.offsets[t+1]}intersect(o,p,r,h,d,l,x,b){const{position:_}=x,I=e(D,o,_),g=e(F,p,_),B=t(R,x.rotationScale);s(I,I,B),s(g,g,B);const w=n(P,B),k=new M(this._positions,3),z=this._indices,E=this._components.offsets,G=A(I,g,v);if(this.viewingMode===f.Global){const t=this._planetCenter;i(t,_),s(t,t,B);const n=this._planetNorth;a(n,0,0,1),s(n,n,B),m(n,n)}const L=c(U,I),O=c(V,g),S=e(q,g,I);m(S,S);const T=t=>{const n=this.getComponentAabb(t,N);if(null!=d){const n=d[t];null==h||b?(I[2]=L[2]-n,g[2]=O[2]-n):h.componentOffset=n}if(null==h||b||h.applyToAabb(n),!j(n,I,G,r))return;const o=E[t]/3,e=E[t+1]/3,i=(n,o,e)=>l(t,n,s(o,o,w),e);(null==h||b)&&e-o>C?(null==this._componentIntersectionData[t]&&(this._componentIntersectionData[t]=new u(this._indices,o,e,k)),this._componentIntersectionData[t].intersectRay(I,g,i)):y(I,g,o,e,z,k,h,i)};this._intersectComponents(T,b,I,g)}_intersectComponents(t,n,o,s){const i=this._components.pickability,a=this._components.visibility;if(this._components.visibility.componentCount<H){const n=n=>(g(i,n)&&t(n),!0);return void a.forEachComponent(n)}0===this._componentBspNodes.length&&this._generateComponentBspRoot();const c=this._componentIndicesForBsp,r=n=>{g(i,n)&&a.isVisible(n)&&t(n)},h=(t,n)=>{for(let o=t;o<n;++o)r(c[o])};if(n){let t=0;for(;t>=0;){const n=this._componentBspNodes[t],e=n.plane;if(!e||-1===n.child0&&-1===n.child1){h(n.minComponentIndexIndex,n.maxComponentIndexIndex);break}{h(n.minMidComponentIndexIndex,n.maxMidComponentIndexIndex);const s=p(e,o)-e[3];if(s<0){if(-1===n.child0){h(n.minComponentIndexIndex,n.minMidComponentIndexIndex);break}t=n.child0}else{if(!(s>0))break;if(-1===n.child1){h(n.maxMidComponentIndexIndex,n.maxComponentIndexIndex);break}t=n.child1}}}}else{const t=J;e(t,s,o),m(t,t);const n=this._componentBspNodes,i=e=>{const s=n[e],a=s.plane;if(!a||-1===s.child0&&-1===s.child1)h(s.minComponentIndexIndex,s.maxComponentIndexIndex);else{const n=p(a,o)-a[3],e=p(a,t);s.minComponentIndexIndex<s.minMidComponentIndexIndex&&(n<=0||e<0)&&(-1!==s.child0?i(s.child0):h(s.minComponentIndexIndex,s.minMidComponentIndexIndex)),h(s.minMidComponentIndexIndex,s.maxMidComponentIndexIndex),s.maxMidComponentIndexIndex<s.maxComponentIndexIndex&&(n>=0||e>0)&&(-1!==s.child1?i(s.child1):h(s.maxMidComponentIndexIndex,s.maxComponentIndexIndex))}};i(0)}}_generateComponentBspRoot(){const t=this._components.count,n=new Uint16Array(t);this._componentIndicesForBsp=n;for(let e=0;e<t;++e)n[e]=e;const o=this._ensureComponentAabbs(),s=this._planetCenter,d=this._planetNorth,x=G;i(x,s),m(x,x);r(L,d,x);const b=this._aabb,_=b[2],I=[];let C=0;const u=this._componentBspNodes;u.length=0;const M=(t,n)=>{const e=6*t,s=o[e],i=o[e+1],m=o[e+2],c=o[e+3],r=o[e+4],h=o[e+5],d=a(O,.5*(s+c),.5*(i+r),.5*(m+h)),l=.5*(c-s),x=.5*(r-i),b=.5*(h-m),_=Math.sqrt(l*l+x*x+b*b),I=n,f=n[3],C=p(I,d)-f;return Math.abs(C)>_?Math.sign(C):0},g=(t,e,s)=>{let i=1/0,a=1/0,m=1/0,c=-1/0,p=-1/0,r=-1/0;for(let h=e;h<s;++h){const t=6*n[h];i=Math.min(i,o[t]),c=Math.max(c,o[t+3]),a=Math.min(a,o[t+1]),p=Math.max(p,o[t+4]),m=Math.min(m,o[t+2]),r=Math.max(r,o[t+5])}t[0]=i,t[1]=a,t[2]=m,t[3]=c,t[4]=p,t[5]=r},A=this.viewingMode===f.Local;let j=!1;if(!A){const t=a(O,.5*(b[0]+b[3]),.5*(b[1]+b[4]),.5*(b[2]+b[5])),n=h(s,t);j=_>.5*n}const y=(t,o,i,h,x)=>{const b=u.length;let _;if(j||i>=T||o-t<S)_=new w(t,o,o,o,null);else{g(k,t,o);const h=k[0],x=k[1],f=k[2],C=k[3],u=k[4],j=C-h,B=u-x,v=l(),N=v;if(A)j>=B?(a(N,1,0,0),v[3]=-.5*(h+C)):(a(N,0,1,0),v[3]=-.5*(x+u));else{const t=z,n=E;a(t,.5*(h+C),.5*(x+u),f),e(t,t,s),m(t,t),r(n,t,d),m(n,n),j>=B?c(N,n):(r(N,n,t),m(N,N)),v[3]=p(N,s)}let D,F;{let e=t,s=o;for(;e<s;){const t=n[e];M(t,v)<0?++e:(--s,n[e]=n[s],n[s]=t)}D=e;let i=e;for(s=o;i<s;){const t=n[s-1];M(t,v)>0?--s:(n[s-1]=n[i],n[i]=t,++i)}F=s}_=new w(t,D,F,o,v),D>=t+S&&I.push((()=>y(t,D,i+1,b,!0))),o>=F+S&&I.push((()=>y(F,o,i+1,b,!1)))}if(u.push(_),-1!==h){const t=u[h];x?t.child0=b:t.child1=b}};for(I.push((()=>y(0,t,0,-1,!1)));C<I.length;){(0,I[C])(),++C}}_computePerComponentAabbs(){const t=this._components.count,n=b(6*t),o=this._indices,e=this._positions,s=this._components.offsets;let i=0,a=1/0,m=1/0,c=1/0,p=-1/0,r=-1/0,h=-1/0;for(let d=0;d<t;d++){const t=s[d],l=s[d+1];let x=1/0,b=1/0,_=1/0,I=-1/0,f=-1/0,C=-1/0;for(let n=t;n<l;n++){const t=3*o[n],s=e[t],i=e[t+1],a=e[t+2];x=Math.min(x,s),b=Math.min(b,i),_=Math.min(_,a),I=Math.max(I,s),f=Math.max(f,i),C=Math.max(C,a)}n[i++]=x,n[i++]=b,n[i++]=_,n[i++]=I,n[i++]=f,n[i++]=C,a=Math.min(a,x),m=Math.min(m,b),c=Math.min(c,_),p=Math.max(p,I),r=Math.max(r,f),h=Math.max(h,C)}return this._aabb[0]=a,this._aabb[1]=m,this._aabb[2]=c,this._aabb[3]=p,this._aabb[4]=r,this._aabb[5]=h,n}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}class w{constructor(t,n,o,e,s){this.minComponentIndexIndex=t,this.minMidComponentIndexIndex=n,this.maxMidComponentIndexIndex=o,this.maxComponentIndexIndex=e,this.plane=s,this.child0=-1,this.child1=-1}}const v=d(),N=x(),k=[0,0,0,0,0,0],D=d(),F=d(),R=o(),P=o(),U=d(),V=d(),q=d(),z=d(),E=d(),G=d(),L=d(),O=d(),S=5,T=10,H=7,J=d();export{B as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{set as t,length as e,normalize as r,dot as i,scale as s,add as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as n,b as h}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newFloatArray as u}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as b}from"../../../../geometry/support/Indices.js";import{Attribute as v,Vertices as m}from"./Attribute.js";import{compressNormal as p}from"./Normals.js";import{intersectTriangles as x}from"./RayIntersections.js";import{VertexAttribute as A}from"./VertexAttribute.js";class d{constructor(t){this.builder=t}onPathChanged(t){this.builder.onPathChanged()}}class f extends d{constructor(t){super(t),this.vertexAttributeColor=c(255,255,255,255),this.size=new Array,this.vertexAttributePosition=u(3*this.builder.numVerticesTotal),this.vertexAttributeNormal=new Int16Array(2*this.builder.numVerticesTotal)}bakeVertexColors(t){this.vertexAttributeColor[0]=255*t[0],this.vertexAttributeColor[1]=255*t[1],this.vertexAttributeColor[2]=255*t[2],this.vertexAttributeColor[3]=255*(t.length>3?t[3]:1)}bake(a){this.size=a;const{numVerticesTotal:l,pathVertexData:c,path:u,positions:b,profileRightAxes:v,profileUpAxes:m,profileVertexAndNormals:x}=this.builder;for(let A=0;A<l;++A){let l=c[A];const d=0===l||l===u.vertices.length-1;l*=3;const f=V;let g=0,D=0;const N=4*A,j=n(R,v[N],v[N+1],v[N+2]),E=n(w,m[N],m[N+1],m[N+2]),y=t(P,x[N]*a[0],x[N+1]*a[1]);if(d)h(f,E,j),g=v[N+3]*a[0],D=m[N+3];else{const a=I,h=C;t(a,v[N+3],m[N+3]);const l=e(a);r(a,a);const c=i(y,a);if(Math.abs(c)>l){t(h,-a[1],a[0]);const e=i(y,h);s(a,a,l*Math.sign(c)),s(h,h,e),o(y,a,h)}n(f,0,0,0)}const T=n(O,j[0]*y[0]+E[0]*y[1],j[1]*y[0]+E[1]*y[1],j[2]*y[0]+E[2]*y[1]),L=3*A;this.vertexAttributePosition[L]=b[l]+T[0]+f[0]*g,this.vertexAttributePosition[L+1]=b[l+1]+T[1]+f[1]*g,this.vertexAttributePosition[L+2]=b[l+2]+T[2]+f[2]*g;const M=t(P,x[N+2],x[N+3]);p(this.vertexAttributeNormal,A,j[0]*M[0]+E[0]*M[1]+f[0]*D,j[1]*M[0]+E[1]*M[1]+f[1]*D,j[2]*M[0]+E[2]*M[1]+f[2]*D)}}createGeometryData(){const t=this.builder.vertexIndices.length,{normalIndices:e,vertexIndices:r}=this.builder;return[[A.POSITION,new v(this.vertexAttributePosition,r,3,!0)],[A.NORMALCOMPRESSED,new v(this.vertexAttributeNormal,e,2,!0)],[A.COLOR,new v(this.vertexAttributeColor,b(t),4)]]}onPathChanged(t){super.onPathChanged(t),this.bake(this.size)}intersect(t,e,r){const i=this.builder.vertexIndices,s=new m(this.vertexAttributePosition,3),o=i.length/3;x(t,e,0,o,i,s,void 0,void 0,r)}}class g extends d{constructor(t,e,r,i){super(t),this.sizeAttributeValue=e,this.colorAttributeValue=r,this.opacityAttributeValue=i,this.vvData=null,this.baked=new f(t),this.vvData=u(4*this.builder.path.vertices.length);for(let s=0;s<this.builder.path.vertices.length;++s){this.vvData[4*s]=e,this.vvData[4*s+1]=r,this.vvData[4*s+2]=i;const t=0===s||s===this.builder.path.vertices.length-1;this.vvData[4*s+3]=t?1:0}}createGeometryData(){const{positions:t,profileRightAxes:e,profileUpAxes:r,profileVertexAndNormals:i,pathVertexIndices:s,vertexIndices:o}=this.builder;return[[A.POSITION,new v(t,s,3,!0)],[A.PROFILERIGHT,new v(e,o,4,!0)],[A.PROFILEUP,new v(r,o,4,!0)],[A.PROFILEVERTEXANDNORMAL,new v(i,o,4,!0)],[A.FEATUREVALUE,new v(this.vvData,s,4,!0)]]}onPathChanged(t){super.onPathChanged(t);const e=t.getMutableAttribute(A.POSITION);e&&(e.data=this.builder.positions)}}const P=a(),I=a(),C=a(),O=l(),V=l(),R=l(),w=l();export{g as FastUpdatePathGeometry,d as PathGeometryData,f as StaticPathGeometry};
5
+ import{set as t,length as e,normalize as r,dot as i,scale as s,add as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as n,b as h}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as c}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{newFloatArray as u}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as b}from"../../../../geometry/support/Indices.js";import{Attribute as v,Vertices as m}from"./Attribute.js";import{compressNormal as p}from"./Normals.js";import{intersectTriangles as x}from"./RayIntersections.js";import{VertexAttribute as A}from"./VertexAttribute.js";class d{constructor(t){this.builder=t}onPathChanged(t){this.builder.onPathChanged()}}class f extends d{constructor(t){super(t),this.vertexAttributeColor=c(255,255,255,255),this.size=new Array,this.vertexAttributePosition=u(3*this.builder.numVerticesTotal),this.vertexAttributeNormal=new Int16Array(2*this.builder.numVerticesTotal)}bakeVertexColors(t){this.vertexAttributeColor[0]=255*t[0],this.vertexAttributeColor[1]=255*t[1],this.vertexAttributeColor[2]=255*t[2],this.vertexAttributeColor[3]=255*(t.length>3?t[3]:1)}bake(a){this.size=a;const{numVerticesTotal:l,pathVertexData:c,path:u,positions:b,profileRightAxes:v,profileUpAxes:m,profileVertexAndNormals:x}=this.builder;for(let A=0;A<l;++A){let l=c[A];const d=0===l||l===u.vertices.length-1;l*=3;const f=V;let g=0,D=0;const N=4*A,j=n(R,v[N],v[N+1],v[N+2]),E=n(w,m[N],m[N+1],m[N+2]),y=t(P,x[N]*a[0],x[N+1]*a[1]);if(d)h(f,E,j),g=v[N+3]*a[0],D=m[N+3];else{const a=I,h=C;t(a,v[N+3],m[N+3]);const l=e(a);r(a,a);const c=i(y,a);if(Math.abs(c)>l){t(h,-a[1],a[0]);const e=i(y,h);s(a,a,l*Math.sign(c)),s(h,h,e),o(y,a,h)}n(f,0,0,0)}const T=n(O,j[0]*y[0]+E[0]*y[1],j[1]*y[0]+E[1]*y[1],j[2]*y[0]+E[2]*y[1]),L=3*A;this.vertexAttributePosition[L]=b[l]+T[0]+f[0]*g,this.vertexAttributePosition[L+1]=b[l+1]+T[1]+f[1]*g,this.vertexAttributePosition[L+2]=b[l+2]+T[2]+f[2]*g;const M=t(P,x[N+2],x[N+3]);p(this.vertexAttributeNormal,A,j[0]*M[0]+E[0]*M[1]+f[0]*D,j[1]*M[0]+E[1]*M[1]+f[1]*D,j[2]*M[0]+E[2]*M[1]+f[2]*D)}}createGeometryData(){const t=this.builder.vertexIndices.length,{normalIndices:e,vertexIndices:r}=this.builder;return[[A.POSITION,new v(this.vertexAttributePosition,r,3,!0)],[A.NORMALCOMPRESSED,new v(this.vertexAttributeNormal,e,2,!0)],[A.COLOR,new v(this.vertexAttributeColor,b(t),4)]]}onPathChanged(t){super.onPathChanged(t),this.bake(this.size)}intersect(t,e,r){const i=this.builder.vertexIndices,s=new m(this.vertexAttributePosition,3),o=i.length/3;x(t,e,0,o,i,s,void 0,r)}}class g extends d{constructor(t,e,r,i){super(t),this.sizeAttributeValue=e,this.colorAttributeValue=r,this.opacityAttributeValue=i,this.vvData=null,this.baked=new f(t),this.vvData=u(4*this.builder.path.vertices.length);for(let s=0;s<this.builder.path.vertices.length;++s){this.vvData[4*s]=e,this.vvData[4*s+1]=r,this.vvData[4*s+2]=i;const t=0===s||s===this.builder.path.vertices.length-1;this.vvData[4*s+3]=t?1:0}}createGeometryData(){const{positions:t,profileRightAxes:e,profileUpAxes:r,profileVertexAndNormals:i,pathVertexIndices:s,vertexIndices:o}=this.builder;return[[A.POSITION,new v(t,s,3,!0)],[A.PROFILERIGHT,new v(e,o,4,!0)],[A.PROFILEUP,new v(r,o,4,!0)],[A.PROFILEVERTEXANDNORMAL,new v(i,o,4,!0)],[A.FEATUREVALUE,new v(this.vvData,s,4,!0)]]}onPathChanged(t){super.onPathChanged(t);const e=t.getMutableAttribute(A.POSITION);e&&(e.data=this.builder.positions)}}const P=a(),I=a(),C=a(),O=l(),V=l(),R=l(),w=l();export{g as FastUpdatePathGeometry,d as PathGeometryData,f as StaticPathGeometry};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{z as t,s as n,b as o,n as i,c as e}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s,setMin as f,setMax as r}from"../../../../geometry/support/aaBoundingBox.js";import{ContentObjectType as a}from"./ContentObjectType.js";import{assert as u}from"./Util.js";import{VertexAttribute as l}from"./VertexAttribute.js";const p=s();function m(t,n,o,i,e,c){if(t.visible)if(t.boundingInfo){u(t.type===a.Mesh);const s=n.tolerance;b(t.boundingInfo,o,i,s,e,c)}else{const n=t.attributes.get(l.POSITION),s=n.indices;d(o,i,0,s.length/3,s,n,void 0,e,c)}}const h=c();function b(t,n,o,i,e,c){if(null==t)return;const s=I(n,o,h);if(f(p,t.bbMin),r(p,t.bbMax),null!=e&&e.applyToAabb(p),O(p,n,s,i)){const{primitiveIndices:s,position:f}=t,r=s?s.length:f.indices.length/3;if(r>B){const s=t.getChildren();if(void 0!==s){for(const t of s)b(t,n,o,i,e,c);return}}d(n,o,0,r,f.indices,f,s,e,c)}}const M=c(),x=c();function d(n,o,i,e,c,s,f,r,a){const u=t(x,o,n);if(f)return g(n,u,i,e,c,s,f,r,a);const{data:l,stride:p}=s;k(n,o,i,e,p,c,l,a,r)}function y(t,n,o,i,e,c,s,f){const r=t[0],a=t[1],u=t[2],l=n[0],p=n[1],m=n[2];for(let h=o;h<i;++h){const t=3*h,n=e*c[t],o=s[n],i=s[n+1],b=s[n+2],x=e*c[t+1],d=s[x],y=s[x+1],T=s[x+2],g=e*c[t+2],V=d-o,j=y-i,I=T-b,O=s[g]-o,A=s[g+1]-i,B=s[g+2]-b,k=p*B-A*m,z=m*O-B*l,N=l*A-O*p,P=V*k+j*z+I*N;if(Math.abs(P)<=C)continue;const S=r-o,U=a-i,q=u-b,w=S*k+U*z+q*N;if(P>0){if(w<0||w>P)continue}else if(w>0||w<P)continue;const D=U*I-j*q,E=q*V-I*S,F=S*j-V*U,G=l*D+p*E+m*F;if(P>0){if(G<0||w+G>P)continue}else if(G>0||w+G<P)continue;const H=(O*D+A*E+B*F)/P;if(H>=0){f(H,v(V,j,I,O,A,B,M),h,!1)}}}function T(t,n,o,i,e,c,s,f,r){const a=t[0],u=t[1],l=t[2],p=n[0],m=n[1],h=n[2];for(let b=o;b<i;++b){const t=3*b,n=e*c[t],o=s[n],i=s[n+1],x=s[n+2],d=e*c[t+1],y=s[d],T=s[d+1],g=s[d+2],V=e*c[t+2],j=s[V],I=s[V+1],O=s[V+2],[A,B,k]=f.applyToVertex(o,i,x,b),[z,N,P]=f.applyToVertex(y,T,g,b),[S,U,q]=f.applyToVertex(j,I,O,b),w=z-A,D=N-B,E=P-k,F=S-A,G=U-B,H=q-k,J=m*H-G*h,K=h*F-H*p,L=p*G-F*m,Q=w*J+D*K+E*L;if(Math.abs(Q)<=C)continue;const R=a-A,W=u-B,X=l-k,Y=R*J+W*K+X*L;if(Q>0){if(Y<0||Y>Q)continue}else if(Y>0||Y<Q)continue;const Z=W*E-D*X,$=X*w-E*R,_=R*D-w*W,tt=p*Z+m*$+h*_;if(Q>0){if(tt<0||Y+tt>Q)continue}else if(tt>0||Y+tt<Q)continue;const nt=(F*Z+G*$+H*_)/Q;if(nt>=0){r(nt,v(w,D,E,F,G,H,M),b,!1)}}}function g(t,n,o,i,e,c,s,f,r){const{data:a,stride:u}=c,l=t[0],p=t[1],m=t[2],h=n[0],b=n[1],x=n[2];for(let d=o;d<i;++d){const t=s[d],n=3*t,o=u*e[n];let i=a[o],c=a[o+1],y=a[o+2];const T=u*e[n+1];let g=a[T],V=a[T+1],j=a[T+2];const I=u*e[n+2];let O=a[I],A=a[I+1],B=a[I+2];null!=f&&([i,c,y]=f.applyToVertex(i,c,y,d),[g,V,j]=f.applyToVertex(g,V,j,d),[O,A,B]=f.applyToVertex(O,A,B,d));const k=g-i,z=V-c,N=j-y,P=O-i,S=A-c,U=B-y,q=b*U-S*x,w=x*P-U*h,D=h*S-P*b,E=k*q+z*w+N*D;if(Math.abs(E)<=C)continue;const F=l-i,G=p-c,H=m-y,J=F*q+G*w+H*D;if(E>0){if(J<0||J>E)continue}else if(J>0||J<E)continue;const K=G*N-z*H,L=H*k-N*F,Q=F*z-k*G,R=h*K+b*L+x*Q;if(E>0){if(R<0||J+R>E)continue}else if(R>0||J+R<E)continue;const W=(P*K+S*L+U*Q)/E;if(W>=0){r(W,v(k,z,N,P,S,U,M),t,!1)}}}const V=c(),j=c();function v(t,e,c,s,f,r,a){return n(V,t,e,c),n(j,s,f,r),o(a,V,j),i(a,a),a}function I(t,o,i){return n(i,1/(o[0]-t[0]),1/(o[1]-t[1]),1/(o[2]-t[2]))}function O(t,n,o,i){return A(t,n,o,i,1/0)}function A(t,n,o,i,e){const c=(t[0]-i-n[0])*o[0],s=(t[3]+i-n[0])*o[0];let f=Math.min(c,s),r=Math.max(c,s);const a=(t[1]-i-n[1])*o[1],u=(t[4]+i-n[1])*o[1];if(r=Math.min(r,Math.max(a,u)),r<0)return!1;if(f=Math.max(f,Math.min(a,u)),f>r)return!1;const l=(t[2]-i-n[2])*o[2],p=(t[5]+i-n[2])*o[2];return r=Math.min(r,Math.max(l,p)),!(r<0)&&(f=Math.max(f,Math.min(l,p)),!(f>r)&&f<e)}const B=1e3,C=1e-7;function k(c,s,f,r,a,u,l,p,m){const h=t(z,s,c),b=N,x=()=>(t(V,b[1],b[0]),t(j,b[2],b[0]),o(M,V,j),i(M,M),M),d=Math.abs(h[0]),y=Math.abs(h[1]),T=Math.abs(h[2]),g=d>=y?d>=T?0:2:y>=T?1:2,v=g,I=h[v]<0?2:1,O=(g+I)%3,A=(g+(3-I))%3,B=h[O]/h[v],C=h[A]/h[v],k=1/h[v],q=P,w=S,D=U;for(let o=f;o<r;++o){const i=3*o,s=a*u[i];n(b[0],l[s+0],l[s+1],l[s+2]);const f=a*u[i+1];n(b[1],l[f+0],l[f+1],l[f+2]);const r=a*u[i+2];n(b[2],l[r+0],l[r+1],l[r+2]),m&&(e(b[0],m.applyToVertex(b[0][0],b[0][1],b[0][2],o)),e(b[1],m.applyToVertex(b[1][0],b[1][1],b[1][2],o)),e(b[2],m.applyToVertex(b[2][0],b[2][1],b[2][2],o))),t(q,b[0],c),t(w,b[1],c),t(D,b[2],c);const h=q[O]-B*q[v],M=q[A]-C*q[v],d=w[O]-B*w[v],y=w[A]-C*w[v],T=D[O]-B*D[v],g=D[A]-C*D[v],V=T*y-g*d,j=h*g-M*T,I=d*M-y*h;if((V<0||j<0||I<0)&&(V>0||j>0||I>0))continue;const z=V+j+I;if(0===z)continue;const N=V*(k*q[v])+j*(k*w[v])+I*(k*D[v]);if(N*Math.sign(z)<0)continue;const P=N/z;if(P>=0){p(P,x(),o,!1)}}}const z=c(),N=[c(),c(),c()],P=c(),S=c(),U=c();export{I as computeInvDir,v as computeNormal,O as intersectAabbInvDir,A as intersectAabbInvDirBefore,y as intersectRayTriangles,T as intersectRayTrianglesWithDisplacement,m as intersectTriangleGeometry,d as intersectTriangles};
5
+ import{z as t,s as n,b as o,n as i,c as e}from"../../../../chunks/vec32.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as s,setMin as f,setMax as r}from"../../../../geometry/support/aaBoundingBox.js";import{ContentObjectType as a}from"./ContentObjectType.js";import{assert as u}from"./Util.js";import{VertexAttribute as l}from"./VertexAttribute.js";const p=s();function m(n,o,i,e,c,s){if(!n.visible)return;const f=t(z,e,i);if(n.boundingInfo){u(n.type===a.Mesh);const t=o.tolerance;b(n.boundingInfo,i,f,t,c,s)}else{const t=n.attributes.get(l.POSITION),o=t.indices;k(i,f,0,o.length/3,o,t.data,t.stride,c,s)}}const h=c();function b(t,n,o,i,e,c){if(null==t)return;const s=I(o,h);if(f(p,t.bbMin),r(p,t.bbMax),null!=e&&e.applyToAabb(p),O(p,n,s,i)){const{primitiveIndices:s,position:f}=t,r=s?s.length:f.indices.length/3;if(r>B){const s=t.getChildren();if(void 0!==s){for(const t of s)b(t,n,o,i,e,c);return}}T(n,o,0,r,f.indices,f.data,f.stride,s,e,c)}}const M=c();function x(n,o,i,e,c,s,f,r){const{data:a,stride:u}=s;k(n,t(z,o,n),i,e,c,a,u,f,r)}function d(t,n,o,i,e,c,s,f,r,a){const u=t[0],l=t[1],p=t[2],m=n[0],h=n[1],b=n[2];for(let x=o;x<i;++x){const t=r[x]+a,n=3*t,o=s*e[n],i=c[o],d=c[o+1],y=c[o+2],T=s*e[n+1],g=c[T],V=c[T+1],v=c[T+2],I=s*e[n+2],O=g-i,A=V-d,B=v-y,k=c[I]-i,z=c[I+1]-d,N=c[I+2]-y,P=h*N-z*b,S=b*k-N*m,U=m*z-k*h,q=O*P+A*S+B*U;if(Math.abs(q)<=C)continue;const w=u-i,D=l-d,E=p-y,F=w*P+D*S+E*U;if(q>0){if(F<0||F>q)continue}else if(F>0||F<q)continue;const G=D*B-A*E,H=E*O-B*w,J=w*A-O*D,K=m*G+h*H+b*J;if(q>0){if(K<0||F+K>q)continue}else if(K>0||F+K<q)continue;const L=(k*G+z*H+N*J)/q;if(L>=0){f(L,j(O,A,B,k,z,N,M),t,!1)}}}function y(t,n,o,i,e,c,s,f,r){const a=t[0],u=t[1],l=t[2],p=n[0],m=n[1],h=n[2];for(let b=o;b<i;++b){const t=3*b,n=s*e[t],o=c[n],i=c[n+1],x=c[n+2],d=s*e[t+1],y=c[d],T=c[d+1],g=c[d+2],V=s*e[t+2],v=c[V],I=c[V+1],O=c[V+2],[A,B,k]=f.applyToVertex(o,i,x,b),[z,N,P]=f.applyToVertex(y,T,g,b),[S,U,q]=f.applyToVertex(v,I,O,b),w=z-A,D=N-B,E=P-k,F=S-A,G=U-B,H=q-k,J=m*H-G*h,K=h*F-H*p,L=p*G-F*m,Q=w*J+D*K+E*L;if(Math.abs(Q)<=C)continue;const R=a-A,W=u-B,X=l-k,Y=R*J+W*K+X*L;if(Q>0){if(Y<0||Y>Q)continue}else if(Y>0||Y<Q)continue;const Z=W*E-D*X,$=X*w-E*R,_=R*D-w*W,tt=p*Z+m*$+h*_;if(Q>0){if(tt<0||Y+tt>Q)continue}else if(tt>0||Y+tt<Q)continue;const nt=(F*Z+G*$+H*_)/Q;if(nt>=0){r(nt,j(w,D,E,F,G,H,M),b,!1)}}}function T(t,n,o,i,e,c,s,f,r,a){const u=t[0],l=t[1],p=t[2],m=n[0],h=n[1],b=n[2];for(let x=o;x<i;++x){const t=f[x],n=3*t,o=s*e[n];let i=c[o],d=c[o+1],y=c[o+2];const T=s*e[n+1];let g=c[T],V=c[T+1],v=c[T+2];const I=s*e[n+2];let O=c[I],A=c[I+1],B=c[I+2];null!=r&&([i,d,y]=r.applyToVertex(i,d,y,x),[g,V,v]=r.applyToVertex(g,V,v,x),[O,A,B]=r.applyToVertex(O,A,B,x));const k=g-i,z=V-d,N=v-y,P=O-i,S=A-d,U=B-y,q=h*U-S*b,w=b*P-U*m,D=m*S-P*h,E=k*q+z*w+N*D;if(Math.abs(E)<=C)continue;const F=u-i,G=l-d,H=p-y,J=F*q+G*w+H*D;if(E>0){if(J<0||J>E)continue}else if(J>0||J<E)continue;const K=G*N-z*H,L=H*k-N*F,Q=F*z-k*G,R=m*K+h*L+b*Q;if(E>0){if(R<0||J+R>E)continue}else if(R>0||J+R<E)continue;const W=(P*K+S*L+U*Q)/E;if(W>=0){a(W,j(k,z,N,P,S,U,M),t,!1)}}}const g=c(),V=c();function j(t,e,c,s,f,r,a){return n(g,t,e,c),n(V,s,f,r),o(a,g,V),i(a,a),a}function v(t,o,i){return n(i,1/(o[0]-t[0]),1/(o[1]-t[1]),1/(o[2]-t[2]))}function I(t,o){return n(o,1/t[0],1/t[1],1/t[2])}function O(t,n,o,i){return A(t,n,o,i,1/0)}function A(t,n,o,i,e){const c=(t[0]-i-n[0])*o[0],s=(t[3]+i-n[0])*o[0];let f=Math.min(c,s),r=Math.max(c,s);const a=(t[1]-i-n[1])*o[1],u=(t[4]+i-n[1])*o[1];if(r=Math.min(r,Math.max(a,u)),r<0)return!1;if(f=Math.max(f,Math.min(a,u)),f>r)return!1;const l=(t[2]-i-n[2])*o[2],p=(t[5]+i-n[2])*o[2];return r=Math.min(r,Math.max(l,p)),!(r<0)&&(f=Math.max(f,Math.min(l,p)),!(f>r)&&f<e)}const B=1e3,C=1e-7;function k(c,s,f,r,a,u,l,p,m){const h=s,b=N,x=()=>(t(g,b[1],b[0]),t(V,b[2],b[0]),o(M,g,V),i(M,M),M),d=Math.abs(h[0]),y=Math.abs(h[1]),T=Math.abs(h[2]),j=d>=y?d>=T?0:2:y>=T?1:2,v=j,I=h[v]<0?2:1,O=(j+I)%3,A=(j+(3-I))%3,B=h[O]/h[v],C=h[A]/h[v],k=1/h[v],z=P,q=S,w=U;for(let o=f;o<r;++o){const i=3*o,s=l*a[i];n(b[0],u[s+0],u[s+1],u[s+2]);const f=l*a[i+1];n(b[1],u[f+0],u[f+1],u[f+2]);const r=l*a[i+2];n(b[2],u[r+0],u[r+1],u[r+2]),p&&(e(b[0],p.applyToVertex(b[0][0],b[0][1],b[0][2],o)),e(b[1],p.applyToVertex(b[1][0],b[1][1],b[1][2],o)),e(b[2],p.applyToVertex(b[2][0],b[2][1],b[2][2],o))),t(z,b[0],c),t(q,b[1],c),t(w,b[2],c);const h=z[O]-B*z[v],M=z[A]-C*z[v],d=q[O]-B*q[v],y=q[A]-C*q[v],T=w[O]-B*w[v],g=w[A]-C*w[v],V=T*y-g*d,j=h*g-M*T,I=d*M-y*h;if((V<0||j<0||I<0)&&(V>0||j>0||I>0))continue;const N=V+j+I;if(0===N)continue;const P=V*(k*z[v])+j*(k*q[v])+I*(k*w[v]);if(P*Math.sign(N)<0)continue;const S=P/N;if(S>=0){m(S,x(),o,!1)}}}const z=c(),N=[c(),c(),c()],P=c(),S=c(),U=c();export{v as computeInvDir,I as computeInvDirFromDirection,j as computeNormal,O as intersectAabbInvDir,A as intersectAabbInvDirBefore,d as intersectRayTriangles,y as intersectRayTrianglesWithDisplacement,m as intersectTriangleGeometry,x as intersectTriangles};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{pointEquals as g,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as f}from"./DrawingMode.js";import{DrawManipulator as x}from"./DrawManipulator.js";import{createCoordinateHelper as C}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as b,sceneSnappingAtLocation as T}from"../interactive/dragEventPipeline.js";import{EditGeometry as S,Component as P}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as V}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as w}from"../interactive/sketch/constraints.js";import{pointToConstraintSpace as O,constraintSpaceToPoint as M,getPointConstraint as D,getPolylineOrPolygonConstraint as E}from"../interactive/sketch/constraintUtils.js";import I from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as j}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as G}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as k}from"../interactive/snapping/snappingUtils.js";const Z="crosshair",A="progress";let L=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new m,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(D),this._getPolylineOrPolygonConstraint=s(E),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new I,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,n="viewingMode"in e.state?e.state.viewingMode:v.Local,o="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=C(this.hasZ,this.hasM,i),this._editGeometryOperations=new V(new S(o,this.coordinateHelper),n),this._snappingOperation=new G({view:e}),this.addHandles([p((()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint})),(({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&w(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))}),{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&r(t.constraint,e.constraint)}),p((()=>this.view.viewpoint),((t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()}))]),this._activeComponent=new P(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const s=this.segmentLabels;null!=s&&(s.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles(p((()=>this.labelOptions.enabled),(t=>{s.visible=t}),c))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates)),n=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getFirstVertex()?.pos)??null;g(n,this.firstVertex)||(this.firstVertex=n);const o=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getLastVertex()?.pos)??null;g(o,this.lastVertex)||(this.lastVertex=o);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.edges.at(-1)?.leftVertex?.pos)??null;switch(g(r,this.secondToLastVertex)||(this.secondToLastVertex=r),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}})));const l=this._manipulator=new x({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(t=>this._onImmediateClick(t))),l.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),p((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:t})=>{l.cursor=t}),c)]),k(this,(()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);null!=this.snappingManager&&this._updatingHandles.addPromise(a(this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e)))}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":return this._getPointConstraint(t.elevation,t.context);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t.distance,t.direction,t.elevation,t.context)}}set drawingMode(t){this._set("drawingMode",t??f)}get effectiveCursor(){return this.loading?A:this._hideDefaultCursor?null:this.cursor||Z}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,o="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!o,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),r=this._snapToClosingVertex(o),s=this._applyConstraints(r);y(e,s)||(this._set("cursorVertex",s),this.segmentLabels?.set("stagedVertex",null!=s?this.coordinateHelper.pointToVector(s):null),null==s||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(s)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activeComponent;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return b(t,((t,e,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=H({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((t=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t))).next(s),e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||o&&!this.numCommittedVertices)&&this.commitStagedVertex()),t))).next(T(this.view,this.elevationInfo)).next(...r).next((t=>(o&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t)))}))}_createManipulatorDragPipelineFreehand(t){return b(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return b(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),this._processCursor(t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:o}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const r=this.elevationInfo?.mode;let s=this.defaultZ,a=t||"absolute-height"===r;if(null!=o&&(a=o),"on-the-ground"===r&&(a=!1),this._drawAtFixedElevation){s=(t?this.constraintZ:null)??e.getZ(this._activeComponent.vertices[0].pos),a=!1}return a?i:(n.defaultZ=s,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=l(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(t.pointerId)||n.grabbing||!n.interactive?i.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){const t=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!t.grabbing&&t.interactive?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),o=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const r=this.snappingManager;if(null==r)return this._processCursor(n),void i.abort();const s=this._getSnappingContext(e);this._updatingHandles.addPromise(a(i.snap({point:n,scenePoint:o},r,s)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=O(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=M(r,t,n);return null!=s&&"absolute-height"!==n.elevationInfo.mode&&null!=this.constraintZ&&this.hasZ&&(s.z=this.constraintZ),s}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function z(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([d()],L.prototype,"_hideDefaultCursor",void 0),t([d()],L.prototype,"_snappingOperation",void 0),t([d()],L.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],L.prototype,"graphic",void 0),t([d()],L.prototype,"constraintsEnabled",void 0),t([d()],L.prototype,"constraints",void 0),t([d()],L.prototype,"_constraint",null),t([d()],L.prototype,"constraintZ",void 0),t([d()],L.prototype,"defaultZ",void 0),t([d()],L.prototype,"isDraped",void 0),t([d({value:f})],L.prototype,"drawingMode",null),t([d({constructOnly:!0})],L.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:I})],L.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],L.prototype,"geometryType",void 0),t([d({constructOnly:!0})],L.prototype,"hasM",void 0),t([d({constructOnly:!0})],L.prototype,"hasZ",void 0),t([d()],L.prototype,"cursor",void 0),t([d()],L.prototype,"effectiveCursor",null),t([d()],L.prototype,"loading",void 0),t([d({constructOnly:!0})],L.prototype,"manipulators",void 0),t([d({constructOnly:!0})],L.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],L.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],L.prototype,"snappingVisualizer",void 0),t([d()],L.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],L.prototype,"cursorVertex",null),t([d({readOnly:!0})],L.prototype,"visualizationCursorVertex",null),t([d()],L.prototype,"committableVertex",null),t([d()],L.prototype,"firstVertex",void 0),t([d()],L.prototype,"lastVertex",void 0),t([d()],L.prototype,"secondToLastVertex",void 0),t([d()],L.prototype,"updating",null),t([d({constructOnly:!0})],L.prototype,"view",void 0),L=t([h("esri.views.draw.DrawOperation")],L);export{L as DrawOperation,Z as defaultCursor,A as defaultLoadingCursor};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Accessor.js";import i from"../../core/Evented.js";import{clone as n}from"../../core/lang.js";import{destroyMaybe as o,equalsMaybe as r}from"../../core/maybe.js";import{memoize as s}from"../../core/memoize.js";import{ignoreAbortErrors as a}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as c}from"../../core/reactiveUtils.js";import{createScreenPoint as l}from"../../core/screenUtils.js";import{property as d}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import{subclass as h}from"../../core/accessorSupport/decorators/subclass.js";import{diff as u}from"../../core/accessorSupport/diffUtils.js";import{UpdatingHandles as m}from"../../core/support/UpdatingHandles.js";import{pointEquals as g,pointNear as y}from"../../layers/graphics/dehydratedFeatureComparison.js";import{getEffectiveElevationInfo as _}from"../../support/elevationInfoUtils.js";import{ViewingMode as v}from"../ViewingMode.js";import{defaultDrawingMode as f}from"./DrawingMode.js";import{DrawManipulator as x}from"./DrawManipulator.js";import{createCoordinateHelper as C}from"../interactive/coordinateHelper.js";import{createManipulatorDragEventPipeline as b,sceneSnappingAtLocation as T}from"../interactive/dragEventPipeline.js";import{EditGeometry as S,Component as P}from"../interactive/editGeometry/EditGeometry.js";import{EditGeometryOperations as V}from"../interactive/editGeometry/EditGeometryOperations.js";import{isPoint as w}from"../interactive/sketch/constraints.js";import{pointToConstraintSpace as O,constraintSpaceToPoint as M,getPointConstraint as D,getPolylineOrPolygonConstraint as E}from"../interactive/sketch/constraintUtils.js";import I from"../interactive/sketch/SketchLabelOptions.js";import{SnappingContext as j}from"../interactive/snapping/SnappingContext.js";import{createSnapDragEventPipelineStep as H}from"../interactive/snapping/SnappingDragPipelineStep.js";import{SnappingOperation as G}from"../interactive/snapping/SnappingOperation.js";import{setupSnappingToggleHandles as k}from"../interactive/snapping/snappingUtils.js";const Z="crosshair",A="progress";let L=class extends(i.EventedMixin(e)){constructor(t){super(t),this._createOperationCompleted=!1,this._hideDefaultCursor=!1,this._pointerDownStates=new Set,this._stagedScreenPoint=null,this._stagedPointerType=null,this._stagedPointerId=null,this._updatingHandles=new m,this.constraintsEnabled=!1,this.constraints=void 0,this._getPointConstraint=s(D),this._getPolylineOrPolygonConstraint=s(E),this.constraintZ=null,this.defaultZ=null,this.isDraped=!0,this.labelOptions=new I,this.cursor=null,this.loading=!1,this.snapToSceneEnabled=null,this.firstVertex=null,this.lastVertex=null,this.secondToLastVertex=null,null==t.elevationInfo&&(this.elevationInfo=_(!!t.hasZ))}initialize(){const{geometryType:t,view:e}=this,i=e.spatialReference,n="viewingMode"in e.state?e.state.viewingMode:v.Local,o="segment"===t||"multipoint"===t?"polyline":t;this.coordinateHelper=C(this.hasZ,this.hasM,i),this._editGeometryOperations=new V(new S(o,this.coordinateHelper),n),this._snappingOperation=new G({view:e}),this.addHandles([p((()=>({stagedPoint:this._snappingOperation.stagedPoint,constraint:this._constraint})),(({stagedPoint:t,constraint:e},i)=>{const{snappingOptions:n}=this;n&&(n.forceDisabled=null!=e&&w(e));if(null!=i&&t===i.stagedPoint&&e!==i.constraint)return this._onKeyboardBasedChange();this._processCursor(t??this._screenToMap(this._stagedScreenPoint))}),{equals:(t,e)=>t.stagedPoint===e.stagedPoint&&r(t.constraint,e.constraint)}),p((()=>this.view.viewpoint),((t,e)=>{t&&e&&u(t,e)&&this._onKeyboardBasedChange()}))]),this._activeComponent=new P(i,n),this._editGeometryOperations.data.components.push(this._activeComponent);const s=this.segmentLabels;null!=s&&(s.context={view:e,editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,labelOptions:this.labelOptions},this.addHandles(p((()=>this.labelOptions.enabled),(t=>{s.visible=t}),c))),this.addHandles(this._editGeometryOperations.on(["vertex-add","vertex-update","vertex-remove"],(t=>{const e=t.vertices.map((t=>({componentIndex:0,vertexIndex:t.index,coordinates:this.coordinateHelper.vectorToArray(t.pos)}))),i=e.map((t=>t.coordinates)),n=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getFirstVertex()?.pos)??null;g(n,this.firstVertex)||(this.firstVertex=n);const o=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.getLastVertex()?.pos)??null;g(o,this.lastVertex)||(this.lastVertex=o);const r=this.coordinateHelper.vectorToDehydratedPoint(this._activeComponent.edges.at(-1)?.leftVertex?.pos)??null;switch(g(r,this.secondToLastVertex)||(this.secondToLastVertex=r),this._processCursor(this.cursorVertex),t.type){case"vertex-add":this.emit(t.type,{...t,added:i,vertices:e});break;case"vertex-update":this.emit(t.type,{...t,updated:i,vertices:e});break;case"vertex-remove":this.emit(t.type,{...t,removed:i,vertices:e})}})));const l=this._manipulator=new x({consumesClicks:!1,grabbableForEvent:t=>"click"!==this.drawingMode||"touch"===t.pointerType&&this._snappingEnabled&&1===this._pointerDownStates.size});this.manipulators.add(l),l.grabbable="point"!==t,this.addHandles([this._createManipulatorDragPipeline(l),l.events.on("immediate-click",(t=>this._onImmediateClick(t))),l.events.on("immediate-double-click",(t=>this._onImmediateDoubleClick(t))),p((()=>({effectiveCursor:this.effectiveCursor})),(({effectiveCursor:t})=>{l.cursor=t}),c)]),k(this,(()=>{const t=this.view.inputManager.latestPointerType??"mouse",e=this._getSnappingContext(t);if(null!=this.snappingManager){const t=this._snappingOperation.snapAgainNearPreviousMapPoint(this.snappingManager,e);this._updatingHandles.addPromise(a(t))}}))}destroy(){o(this.segmentLabels),o(this._snappingOperation),this._editGeometryOperations=o(this._editGeometryOperations),this._updatingHandles.destroy()}get _snappingEnabled(){return null!=this.snappingManager&&this.snappingManager.options.effectiveEnabled}get _requiresScenePoint(){const t=this._updateAndGetEffectiveDrawSurface();return"3d"===this.view.type&&this.drawSurface!==t}get canRedo(){return this._editGeometryOperations.canRedo}get canUndo(){return this._editGeometryOperations.canUndo}get committedVertices(){return this._activeComponent.vertices.map((t=>this.coordinateHelper.vectorToArray(t.pos)))}get _constraint(){const{constraints:t,constraintsEnabled:e}=this;if(t&&e)switch(this.geometryType){case"point":return this._getPointConstraint(t.elevation,t.context);case"polygon":case"polyline":return this._getPolylineOrPolygonConstraint(this.lastVertex,this.secondToLastVertex,t.distance,t.direction,t.elevation,t.context)}}set drawingMode(t){this._set("drawingMode",t??f)}get effectiveCursor(){return this.loading?A:this._hideDefaultCursor?null:this.cursor||Z}get interactive(){return this._manipulator.interactive}set interactive(t){this._manipulator.interactive=t}get isCompleted(){return this._createOperationCompleted}get numCommittedVertices(){return this._activeComponent.vertices.length}get snappingOptions(){return null!=this.snappingManager?this.snappingManager.options:null}get cursorVertex(){return this._get("cursorVertex")}get visualizationCursorVertex(){return"mouse"===this._stagedPointerType?this.cursorVertex:null}get committableVertex(){const{cursorVertex:t,lastVertex:e,firstVertex:i,geometryType:n}=this;return"polygon"===n&&y(t,i)||y(t,e)?null:t}get updating(){return this._updatingHandles.updating}get geometryIncludingUncommittedVertices(){const{committedVertices:t,committableVertex:e,coordinateHelper:i}=this,n=t.slice();return null!=e&&n.push(i.pointToArray(e)),n}cancel(){this.complete({aborted:!0})}commitStagedVertex(){this._snappingOperation.abort();const{committableVertex:t}=this;null!=t&&this._editGeometryOperations.appendVertex(this.coordinateHelper.pointToVector(t))}complete(t){const e=t?.aborted||!1;this._snappingOperation.abort(),this.snappingManager?.doneSnapping();const{geometryType:i,numCommittedVertices:n}=this,o="multipoint"===i&&0===n||"polyline"===i&&n<2||"polygon"===i&&n<3;"segment"!==i&&"point"!==i||this.commitStagedVertex(),this._createOperationCompleted=!o,(this.isCompleted||e)&&(this._stagedScreenPoint=null,this._stagedPointerId=null,this._stagedPointerType=null,this._processCursor(null),this.emit("complete",{vertices:this.committedVertices.map(((t,e)=>({componentIndex:0,vertexIndex:e,coordinates:t}))),aborted:e,type:"complete"}))}onInputEvent(t){switch(t.type){case"pointer-down":this._pointerDownStates.add(t.pointerId);break;case"pointer-up":this._pointerDownStates.delete(t.pointerId)}switch(t.type){case"pointer-move":return this._onPointerMove(t);case"hold":return this._onHold(t)}}redo(){this._editGeometryOperations.redo()}undo(){null!=this.snappingManager&&this.snappingManager.doneSnapping(),this._editGeometryOperations.undo()}_processCursor(t){const e=n(this.cursorVertex),i=n(t),o=i&&(this._updateAndGetEffectiveDrawSurface()?.constrainZ(i)??i),r=this._snapToClosingVertex(o),s=this._applyConstraints(r);y(e,s)||(this._set("cursorVertex",s),this.segmentLabels?.set("stagedVertex",null!=s?this.coordinateHelper.pointToVector(s):null),null==s||"mouse"!==this._stagedPointerType?this.emit("cursor-remove"):this.emit("cursor-update",{updated:null,vertices:[{componentIndex:0,vertexIndex:this._activeComponent.vertices.length,coordinates:this.coordinateHelper.pointToArray(s)}],operation:"apply",type:"vertex-update"}))}_snapToClosingVertex(t){if(null==t||"polygon"!==this.geometryType||this.numCommittedVertices<=2)return t;const e=this._mapToScreen(t);if(!e)return t;const i=this._activeComponent;return this._vertexWithinPointerDistance(i.vertices[0].pos,e)?this.firstVertex:this._vertexWithinPointerDistance(i.vertices.at(-1).pos,e)?this.lastVertex:t}_createManipulatorDragPipeline(t){switch(this.drawingMode){case"click":return this._createManipulatorDragPipelineClick(t);case"freehand":return this._createManipulatorDragPipelineFreehand(t);case"hybrid":return this._createManipulatorDragPipelineHybrid(t)}}_createManipulatorDragPipelineClick(t){return b(t,((t,e,i,n)=>{const o="touch"===n&&this._snappingEnabled;if(this.isCompleted||!o)return;const{snappingStep:r,cancelSnapping:s}=H({predicate:()=>o,snappingManager:this.snappingManager,snappingContext:new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,feature:this.graphic,pointer:n,visualizer:this.snappingVisualizer,drawConstraints:this.constraints}),updatingHandles:this._updatingHandles,useZ:!this._requiresScenePoint});i=i.next((t=>(o&&null!=this.snappingManager&&this.snappingManager.doneSnapping(),t))).next(s),e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._processCursor(t.mapStart),("segment"===this.geometryType||o&&!this.numCommittedVertices)&&this.commitStagedVertex()),t))).next(T(this.view,this.elevationInfo)).next(...r).next((t=>(o&&(this._processCursor(t.mapEnd),"end"===t.action&&this.commitStagedVertex()),t))).next((t=>("end"===t.action&&("mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()),t)))}))}_createManipulatorDragPipelineFreehand(t){return b(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),null==this.committableVertex&&this._processCursor(t.mapStart),"segment"===this.geometryType&&this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":this.complete()}return t}))}))}_createManipulatorDragPipelineHybrid(t){return b(t,((t,e)=>{this.isCompleted||e.next(this._screenToMapDragEventStep()).next((t=>("start"===t.action&&(this._snappingOperation.abort(),this._processCursor(t.mapStart),this.commitStagedVertex()),t))).next((t=>{switch(t.action){case"start":case"update":this._processCursor(t.mapEnd),"polygon"!==this.geometryType&&"polyline"!==this.geometryType||this.commitStagedVertex();break;case"end":"mouse"!==this._stagedPointerType&&this._snappingOperation.abort(),"segment"!==this.geometryType&&"point"!==this.geometryType||this.complete()}return t}))}))}get _drawAtFixedElevation(){const{constraintsEnabled:t,constraintZ:e,geometryType:i,numCommittedVertices:n}=this;return t?null!=e||"segment"===i&&n>0:("segment"===i||"polygon"===i)&&n>0}_updateAndGetEffectiveDrawSurface(){const{constraintsEnabled:t,coordinateHelper:e,drawSurface:i,elevationDrawSurface:n,snapToSceneEnabled:o}=this;if(null==n)return i;if(!this.hasZ)return n.defaultZ=null,n;const r=this.elevationInfo?.mode;let s=this.defaultZ,a=t||"absolute-height"===r;if(null!=o&&(a=o),"on-the-ground"===r&&(a=!1),this._drawAtFixedElevation){s=(t?this.constraintZ:null)??e.getZ(this._activeComponent.vertices[0].pos),a=!1}return a?i:(n.defaultZ=s,n)}_mapToScreen(t){return this._updateAndGetEffectiveDrawSurface()?.mapToScreen(t)}_onHold(t){this._snappingOperation.abort(),"click"===this.drawingMode&&"touch"===t.pointerType&&this._snappingEnabled&&this._processCursor(t.mapPoint),t.stopPropagation()}_onImmediateClick(t){if(!("mouse"===t.pointerType&&2===t.button||this._manipulator.dragging))try{const{drawingMode:e,geometryType:i}=this;this._stagedPointerType=t.pointerType,this._stagedScreenPoint=t.screenPoint;const n=this._screenToMap(t.screenPoint);if(null==n)return;if(null==n||"freehand"===e&&"point"!==i)return;if(this._snappingEnabled&&null!=this.cursorVertex||this._processCursor(n),null==this.committableVertex)return void this.complete();this.commitStagedVertex(),"mouse"!==t.pointerType&&this._processCursor(null),("freehand"===e||"point"===i||"segment"===i&&2===this.numCommittedVertices||"segment"===i&&"hybrid"===e&&1===this.numCommittedVertices)&&this.complete()}finally{t.stopPropagation()}}_onImmediateDoubleClick(t){this._manipulator.dragging||"point"===this.geometryType||(this.complete(),t.stopPropagation())}_onPointerMove(t){const e=l(t.x,t.y);this._stagedScreenPoint=e,this._stagedPointerType=t.pointerType,this._stagedPointerId=t.pointerId;const i=this._snappingOperation,n=this._manipulator;this._pointerDownStates.has(t.pointerId)||n.grabbing||!n.interactive?i.abort():(t.stopPropagation(),this._processCursorMovementRelativeToSurface(e,t.pointerType))}_onKeyboardBasedChange(){const t=this._manipulator;"mouse"===this._stagedPointerType&&this._stagedScreenPoint&&null!=this._stagedPointerId&&!this._pointerDownStates.has(this._stagedPointerId)&&!t.grabbing&&t.interactive?this._processCursorMovementRelativeToSurface(this._stagedScreenPoint,this._stagedPointerType):this._snappingOperation.abort()}_processCursorMovementRelativeToSurface(t,e){const i=this._snappingOperation,n=this._screenToMap(t),o=this._requiresScenePoint?this.drawSurface?.screenToMap(t):null;if(null==n)return this._hideDefaultCursor=!0,this._processCursor(null),void i.abort();this._hideDefaultCursor=!1;const r=this.snappingManager;if(null==r)return this._processCursor(n),void i.abort();const s=this._getSnappingContext(e);this._updatingHandles.addPromise(a(i.snap({point:n,scenePoint:o},r,s)))}_applyConstraints(t){const{_constraint:e,constraints:i}=this;if(!t||!i||!e)return t;const{context:n}=i,o=O(t,n),r=o?e.closestTo(o):void 0;if(!r)return t;const s=M(r,t,n);return null!=s&&"absolute-height"!==n.elevationInfo.mode&&null!=this.constraintZ&&this.hasZ&&(s.z=this.constraintZ),s}_screenToMap(t){return t?this._updateAndGetEffectiveDrawSurface()?.screenToMap(t):null}_screenToMapDragEventStep(){let t=null;return e=>{if("start"===e.action&&(t=this._screenToMap(e.screenStart)),null==t)return null;const i=this._screenToMap(e.screenEnd);return null!=i?{...e,mapStart:t,mapEnd:i}:null}}_vertexWithinPointerDistance(t,e){const i=25,n=this._mapToScreen(this.coordinateHelper.vectorToDehydratedPoint(t));return null!=n&&z(n,e,i)}_getSnappingContext(t){const e=this._drawAtFixedElevation?this.elevationDrawSurface?.defaultZ:null;return new j({editGeometryOperations:this._editGeometryOperations,elevationInfo:this.elevationInfo,pointer:t,feature:this.graphic,visualizer:this.snappingVisualizer,selfSnappingZ:null!=e?{value:e,elevationInfo:this.elevationInfo}:null,drawConstraints:this.constraints})}};function z(t,e,i){const n=t.x-e.x,o=t.y-e.y;return n*n+o*o<=i}t([d()],L.prototype,"_hideDefaultCursor",void 0),t([d()],L.prototype,"_snappingOperation",void 0),t([d()],L.prototype,"_snappingEnabled",null),t([d({constructOnly:!0})],L.prototype,"graphic",void 0),t([d()],L.prototype,"constraintsEnabled",void 0),t([d()],L.prototype,"constraints",void 0),t([d()],L.prototype,"_constraint",null),t([d()],L.prototype,"constraintZ",void 0),t([d()],L.prototype,"defaultZ",void 0),t([d()],L.prototype,"isDraped",void 0),t([d({value:f})],L.prototype,"drawingMode",null),t([d({constructOnly:!0})],L.prototype,"elevationDrawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"elevationInfo",void 0),t([d({constructOnly:!0,type:I})],L.prototype,"labelOptions",void 0),t([d({constructOnly:!0})],L.prototype,"geometryType",void 0),t([d({constructOnly:!0})],L.prototype,"hasM",void 0),t([d({constructOnly:!0})],L.prototype,"hasZ",void 0),t([d()],L.prototype,"cursor",void 0),t([d()],L.prototype,"effectiveCursor",null),t([d()],L.prototype,"loading",void 0),t([d({constructOnly:!0})],L.prototype,"manipulators",void 0),t([d({constructOnly:!0})],L.prototype,"drawSurface",void 0),t([d({constructOnly:!0})],L.prototype,"segmentLabels",void 0),t([d({constructOnly:!0})],L.prototype,"snappingManager",void 0),t([d({constructOnly:!0})],L.prototype,"snappingVisualizer",void 0),t([d()],L.prototype,"snapToSceneEnabled",void 0),t([d({readOnly:!0})],L.prototype,"cursorVertex",null),t([d({readOnly:!0})],L.prototype,"visualizationCursorVertex",null),t([d()],L.prototype,"committableVertex",null),t([d()],L.prototype,"firstVertex",void 0),t([d()],L.prototype,"lastVertex",void 0),t([d()],L.prototype,"secondToLastVertex",void 0),t([d()],L.prototype,"updating",null),t([d({constructOnly:!0})],L.prototype,"view",void 0),L=t([h("esri.views.draw.DrawOperation")],L);export{L as DrawOperation,Z as defaultCursor,A as defaultLoadingCursor};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.30/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Logger.js";import i from"../../core/Queue.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{PropertiesPool as o}from"../3d/support/PropertiesPool.js";import{primaryKey as a,isSystemModifier as h}from"./keys.js";import{LatestPointer as l}from"./handlers/LatestPointer.js";import{MultiTouch as p}from"./handlers/MultiTouch.js";let d=class extends t{constructor(e){super(e),this._pointerCaptures=new Map,this._nameToGroup={},this._handlers=[],this._handlersPriority=[],this._currentPropagation=null,this._updateDependenciesAfterPropagation=!1,this._sourceEvents=new Set,this._keyModifiers=new Set,this._activeKeyModifiers=new Set,this._stoppedPropagationEventIds=new Set,this.primaryKey=a,this._latestPointerType="mouse",this._propertiesPool=new o({latestPointerLocation:v},this),this.latestPointerLocation=null,this._paused=!1,this.test={timestamp:void 0,hasCurrentPropagation:()=>!!this._currentPropagation}}initialize(){this.eventSource.onEventReceived=this._onEventReceived.bind(this),this._installRecognizers()}destroy(){const e=Object.keys(this._nameToGroup);for(const t of e)this.uninstallHandlers(t);this.eventSource.destroy(),this._currentPropagation=null,this._propertiesPool.destroy()}get hasPendingInputs(){return this._handlers.some((e=>e.handler.hasPendingInputs))}get latestPointerType(){return this._latestPointerType}get multiTouchActive(){return this._multiTouchHandler.multiTouchActive}get updating(){return this.hasPendingInputs||this._paused}installHandlers(e,t,i=_.INTERNAL){if(this._nameToGroup[e])return void r.getLogger(this).error("There is already an InputHandler group registered under the name `"+e+"`");if(0===t.length)return void r.getLogger(this).error("Can't register a group of zero handlers");const n={name:e,handlers:t.map((e=>({handler:e,active:!0,removed:!1,priorityIndex:0,groupPriority:i,eventCallback:null,uninstallCallback:null})))};this._nameToGroup[e]=n;for(let r=n.handlers.length-1;r>=0;r--){const e=n.handlers[r];this._handlers.push(e),e.handler.onInstall({updateDependencies:()=>{this.updateDependencies()},emit:(t,r,i,n,s)=>{this._emitInputEvent(e.priorityIndex+1,t,r,i,s,n)},setPointerCapture:(t,r)=>{this._setPointerCapture(n,e,t,r)},setEventCallback:t=>{e.eventCallback=t},setUninstallCallback:t=>{e.uninstallCallback=t},refreshHasPendingInputs:()=>{this.notifyChange("hasPendingInputs")}})}this.updateDependencies()}uninstallHandlers(e){const t=this._nameToGroup[e];t?(t.handlers.forEach((e=>{e.removed=!0,e.uninstallCallback?.()})),delete this._nameToGroup[e],this._currentPropagation?this._currentPropagation.needsHandlerGarbageCollect=!0:this._garbageCollectRemovedHandlers()):r.getLogger(this).error("There is no InputHandler group registered under the name `"+e+"`")}hasHandlers(e){return void 0!==this._nameToGroup[e]}isModifierKeyDown(e){return this._activeKeyModifiers&&this._activeKeyModifiers.has(e)}updateDependencies(){if(this._currentPropagation)return void(this._updateDependenciesAfterPropagation=!0);this._updateDependenciesAfterPropagation=!1;const e=new Set,t=new Set;this._handlersPriority=[];for(let r=this._handlers.length-1;r>=0;r--){const e=this._handlers[r];e.priorityIndex=r,this._handlersPriority.push(e)}this._handlersPriority=this._sortHandlersPriority(this._handlersPriority);for(let r=this._handlersPriority.length-1;r>=0;r--){const i=this._handlersPriority[r];i.priorityIndex=r;let n=i.handler.hasSideEffects;if(!n)for(const t of i.handler.outgoingEventTypes)if(e.has(t)){n=!0;break}if(n)for(const r of i.handler.incomingEventMatches){e.add(r.eventType);for(const e of r.keyModifiers)h(e)||t.add(e)}i.active=n}this._sourceEvents=e,this._keyModifiers=t,this._pointerCaptures.size>0&&this._sourceEvents.add("pointer-capture-lost"),this._keyModifiers.size>0&&(this._sourceEvents.add("key-down"),this._sourceEvents.add("key-up")),this.eventSource&&(this.eventSource.activeEvents=this._sourceEvents)}_setLatestPointer(e,t,r){this._latestPointerType=e;const i=this._get("latestPointerLocation");if(null==i||i.x!==t||i.y!==r){const e=this._propertiesPool.get("latestPointerLocation");e.x=t,e.y=r,this._set("latestPointerLocation",e)}}_onEventReceived(e,t){if("pointer-capture-lost"===e){const e=t;this._pointerCaptures.delete(e.native.pointerId)}this._updateKeyModifiers(e,t);const r=null!=this.test.timestamp?this.test.timestamp:t.native?t.native.timestamp:void 0,i=t.native?t.native.cancelable:void 0;this._emitInputEventFromSource(e,t,r,i)}_updateKeyModifiers(e,t){if(!t)return;let r=!1;const i=()=>{if(!r){const e=new Set;this._activeKeyModifiers.forEach((t=>{e.add(t)})),this._activeKeyModifiers=e,r=!0}},n=(e,t)=>{t&&!this._activeKeyModifiers.has(e)?(i(),this._activeKeyModifiers.add(e)):!t&&this._activeKeyModifiers.has(e)&&(i(),this._activeKeyModifiers.delete(e))};if("key-down"===e||"key-up"===e){const r=t.key;this._keyModifiers.has(r)&&n(r,"key-down"===e)}const s=t.native;n("Alt",!(!s||!s.altKey)),n("Ctrl",!(!s||!s.ctrlKey)),n("Shift",!(!s||!s.shiftKey)),n("Meta",!(!s||!s.metaKey)),n("Primary",this._activeKeyModifiers.has(this.primaryKey))}_installRecognizers(){this._latestPointerHandler=new l(((e,t,r)=>this._setLatestPointer(e,t,r))),this._multiTouchHandler=new p,this.installHandlers("input-manager-logic",[this._latestPointerHandler,this._multiTouchHandler],_.ALWAYS),this.recognizers.length>0&&this.installHandlers("default",this.recognizers,_.INTERNAL)}_setPointerCapture(e,t,r,i){const n=e.name+"-"+t.priorityIndex,s=this._pointerCaptures.get(r.pointerId)||new Set;this._pointerCaptures.set(r.pointerId,s),i?(s.add(n),1===s.size&&this.eventSource&&this.eventSource.setPointerCapture(r,!0)):s.has(n)&&(s.delete(n),0===s.size&&(this._pointerCaptures.delete(r.pointerId),this.eventSource&&this.eventSource.setPointerCapture(r,!1)))}_garbageCollectRemovedHandlers(){this._handlers=this._handlers.filter((e=>!e.removed)),this.updateDependencies()}_emitInputEventFromSource(e,t,r,i){this._emitInputEvent(0,e,t,r,i)}_emitInputEvent(e,t,r,i,n,s){const o=void 0!==i?i:this._currentPropagation?this._currentPropagation.timestamp:performance.now(),a=void 0!==n&&n,h={event:new u(t,r,o,s||this._activeKeyModifiers,a),priorityIndex:e};this._currentPropagation?this._currentPropagation.events.push(h):this._doNewPropagation(h)}_doNewPropagation(e){this._currentPropagation={events:new i,currentHandler:null,needsHandlerGarbageCollect:!1,timestamp:e.event.timestamp},this._currentPropagation.events.push(e),this._continuePropagation()}_continuePropagation(){this._paused=!1;const e=this._currentPropagation;if(e){for(;e.events.length>0;){const{event:t,priorityIndex:r}=e.events.pop(),i=t.data?.eventId;if(!(null!=i&&this._stoppedPropagationEventIds.has(i)))for(e.currentHandler=this._handlersPriority[r];e.currentHandler;){if(e.currentHandler.removed)e.needsHandlerGarbageCollect=!0;else{if(e.currentHandler.active&&!t.shouldStopPropagation()&&e.currentHandler.eventCallback?.(t),t.shouldStopPropagation()){null!=i&&this._stoppedPropagationEventIds.add(i);break}if(t.shouldPausePropagation((()=>this._continuePropagation())))return void this._pausePropagation({event:t,priorityIndex:e.currentHandler.priorityIndex+1})}e.currentHandler=this._handlersPriority[e.currentHandler.priorityIndex+1]}}e.needsHandlerGarbageCollect&&this._garbageCollectRemovedHandlers(),this.hasPendingInputs||this._stoppedPropagationEventIds.clear(),this._currentPropagation=null,this._updateDependenciesAfterPropagation&&this.updateDependencies()}}_pausePropagation(e){const t=new i;t.push(e);const r=this._currentPropagation;if(r){for(;r.events.length;)t.push(r.events.pop());r.events=t,r.currentHandler=null,this._paused=!0}}_compareHandlerPriority(e,t){if(e.handler.hasSideEffects!==t.handler.hasSideEffects)return e.handler.hasSideEffects?1:-1;if(e.groupPriority!==t.groupPriority)return e.groupPriority>t.groupPriority?-1:1;for(const r of e.handler.incomingEventMatches)for(const e of t.handler.incomingEventMatches){if(r.eventType!==e.eventType)continue;const t=r.keyModifiers.filter((t=>e.keyModifiers.includes(t)));if(t.length===r.keyModifiers.length!==(t.length===e.keyModifiers.length))return r.keyModifiers.length>e.keyModifiers.length?-1:1}return e.priorityIndex>t.priorityIndex?-1:1}_sortHandlersPriority(e){const t=[];for(const r of e){let e=0;for(;e<t.length&&this._compareHandlerPriority(r,t[e])>=0;)e++;t.splice(e,0,r)}return t}get debug(){const e=e=>{const t=this._setPointerCapture;this._setPointerCapture=()=>{},e(),this._setPointerCapture=t};return{injectEvent:(t,r)=>{e((()=>{this._onEventReceived(t,r)}))},disablePointerCapture:e}}};e([n({readOnly:!0})],d.prototype,"hasPendingInputs",null),e([n({constructOnly:!0})],d.prototype,"eventSource",void 0),e([n({constructOnly:!0})],d.prototype,"recognizers",void 0),e([n()],d.prototype,"_latestPointerType",void 0),e([n()],d.prototype,"latestPointerType",null),e([n()],d.prototype,"multiTouchActive",null),e([n({readOnly:!0})],d.prototype,"latestPointerLocation",void 0),e([n()],d.prototype,"_paused",void 0),e([n({readOnly:!0})],d.prototype,"updating",null),d=e([s("esri.views.input.InputManager")],d);class u{constructor(e,t,r,i,n){this.type=e,this.data=t,this.timestamp=r,this.modifiers=i,this.cancelable=n,this._propagationState=c.NONE,this._resumeCallback=null}stopPropagation(){this._propagationState|=c.STOPPED}shouldStopPropagation(){return!!(this._propagationState&c.STOPPED)}async(e){this._propagationState|=c.PAUSED;const t=(e,t)=>{this._propagationState&=~c.PAUSED;const r=this._resumeCallback;if(this._resumeCallback=null,r&&r(),t)throw e;return e};return("function"==typeof e?e():e).then((e=>t(e,!1)),(e=>t(e,!0)))}shouldPausePropagation(e){return!!(this._propagationState&c.PAUSED)&&(this._resumeCallback=e,!0)}preventDefault(){this.data.native.preventDefault()}}var c;!function(e){e[e.NONE=0]="NONE",e[e.STOPPED=1]="STOPPED",e[e.PAUSED=2]="PAUSED"}(c||(c={}));const _={ALWAYS:1,DEFAULT:0,TOOL:-1,WIDGET:-2,INTERNAL:-3};class g{}const v=g;export{d as InputManager,_ as ViewEventPriorities};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../core/Accessor.js";import r from"../../core/Logger.js";import i from"../../core/Queue.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/RandomLCG.js";import{subclass as s}from"../../core/accessorSupport/decorators/subclass.js";import{PropertiesPool as o}from"../3d/support/PropertiesPool.js";import{primaryKey as a,isSystemModifier as h}from"./keys.js";import{LatestPointer as l}from"./handlers/LatestPointer.js";import{MultiTouch as p}from"./handlers/MultiTouch.js";let d=class extends t{constructor(e){super(e),this._pointerCaptures=new Map,this._nameToGroup={},this._handlers=[],this._handlersPriority=[],this._currentPropagation=null,this._updateDependenciesAfterPropagation=!1,this._sourceEvents=new Set,this._keyModifiers=new Set,this._activeKeyModifiers=new Set,this._stoppedPropagationEventIds=new Set,this.primaryKey=a,this._latestPointerType="mouse",this._propertiesPool=new o({latestPointerLocation:v},this),this.latestPointerLocation=null,this._paused=!1,this.test={timestamp:void 0,hasCurrentPropagation:()=>!!this._currentPropagation}}initialize(){this.eventSource.onEventReceived=this._onEventReceived.bind(this),this._installRecognizers()}destroy(){const e=Object.keys(this._nameToGroup);for(const t of e)this.uninstallHandlers(t);this.eventSource.destroy(),this._currentPropagation=null,this._propertiesPool.destroy()}get hasPendingInputs(){return this._handlers.some((e=>e.handler.hasPendingInputs))}get latestPointerType(){return this._latestPointerType}get multiTouchActive(){return this._multiTouchHandler.multiTouchActive}get updating(){return this.hasPendingInputs||this._paused}installHandlers(e,t,i=_.INTERNAL){if(this._nameToGroup[e])return void r.getLogger(this).error("There is already an InputHandler group registered under the name `"+e+"`");if(0===t.length)return void r.getLogger(this).error("Can't register a group of zero handlers");const n={name:e,handlers:t.map((e=>({handler:e,active:!0,removed:!1,priorityIndex:0,groupPriority:i,eventCallback:null,uninstallCallback:null})))};this._nameToGroup[e]=n;for(let r=n.handlers.length-1;r>=0;r--){const e=n.handlers[r];this._handlers.push(e),e.handler.onInstall({updateDependencies:()=>{this.updateDependencies()},emit:(t,r,i,n,s)=>{this._emitInputEvent(e.priorityIndex+1,t,r,i,s,n)},setPointerCapture:(t,r)=>{this._setPointerCapture(n,e,t,r)},setEventCallback:t=>{e.eventCallback=t},setUninstallCallback:t=>{e.uninstallCallback=t},refreshHasPendingInputs:()=>{this.notifyChange("hasPendingInputs")}})}this.updateDependencies()}uninstallHandlers(e){const t=this._nameToGroup[e];t?(t.handlers.forEach((e=>{e.removed=!0,e.uninstallCallback?.()})),delete this._nameToGroup[e],this._currentPropagation?this._currentPropagation.needsHandlerGarbageCollect=!0:this._garbageCollectRemovedHandlers()):r.getLogger(this).error("There is no InputHandler group registered under the name `"+e+"`")}hasHandlers(e){return void 0!==this._nameToGroup[e]}isModifierKeyDown(e){return this._activeKeyModifiers&&this._activeKeyModifiers.has(e)}updateDependencies(){if(this._currentPropagation)return void(this._updateDependenciesAfterPropagation=!0);this._updateDependenciesAfterPropagation=!1;const e=new Set,t=new Set;this._handlersPriority=[];for(let r=this._handlers.length-1;r>=0;r--){const e=this._handlers[r];e.priorityIndex=r,this._handlersPriority.push(e)}this._handlersPriority=this._sortHandlersPriority(this._handlersPriority);for(let r=this._handlersPriority.length-1;r>=0;r--){const i=this._handlersPriority[r];i.priorityIndex=r;let n=i.handler.hasSideEffects;if(!n)for(const t of i.handler.outgoingEventTypes)if(e.has(t)){n=!0;break}if(n)for(const r of i.handler.incomingEventMatches){e.add(r.eventType);for(const e of r.keyModifiers)h(e)||t.add(e)}i.active=n}this._sourceEvents=e,this._keyModifiers=t,this._pointerCaptures.size>0&&this._sourceEvents.add("pointer-capture-lost"),this._keyModifiers.size>0&&(this._sourceEvents.add("key-down"),this._sourceEvents.add("key-up")),this.eventSource&&(this.eventSource.activeEvents=this._sourceEvents)}_setLatestPointer(e,t,r){this._latestPointerType=e;const i=this._get("latestPointerLocation");if(null==i||i.x!==t||i.y!==r){const e=this._propertiesPool.get("latestPointerLocation");e.x=t,e.y=r,this._set("latestPointerLocation",e)}}_onEventReceived(e,t){if("pointer-capture-lost"===e){const e=t;this._pointerCaptures.delete(e.native.pointerId)}this._updateKeyModifiers(e,t);const r=null!=this.test.timestamp?this.test.timestamp:t.native?t.native.timestamp:void 0,i=t.native?t.native.cancelable:void 0;this._emitInputEventFromSource(e,t,r,i)}_updateKeyModifiers(e,t){if(!t)return;let r=!1;const i=()=>{if(!r){const e=new Set;this._activeKeyModifiers.forEach((t=>{e.add(t)})),this._activeKeyModifiers=e,r=!0}},n=(e,t)=>{t&&!this._activeKeyModifiers.has(e)?(i(),this._activeKeyModifiers.add(e)):!t&&this._activeKeyModifiers.has(e)&&(i(),this._activeKeyModifiers.delete(e))};if("key-down"===e||"key-up"===e){const r=t.key;this._keyModifiers.has(r)&&n(r,"key-down"===e)}const s=t.native;n("Alt",!(!s||!s.altKey)),n("Control",!(!s||!s.ctrlKey)),n("Ctrl",!(!s||!s.ctrlKey)),n("Shift",!(!s||!s.shiftKey)),n("Meta",!(!s||!s.metaKey)),n("Primary",this._activeKeyModifiers.has(this.primaryKey))}_installRecognizers(){this._latestPointerHandler=new l(((e,t,r)=>this._setLatestPointer(e,t,r))),this._multiTouchHandler=new p,this.installHandlers("input-manager-logic",[this._latestPointerHandler,this._multiTouchHandler],_.ALWAYS),this.recognizers.length>0&&this.installHandlers("default",this.recognizers,_.INTERNAL)}_setPointerCapture(e,t,r,i){const n=e.name+"-"+t.priorityIndex,s=this._pointerCaptures.get(r.pointerId)||new Set;this._pointerCaptures.set(r.pointerId,s),i?(s.add(n),1===s.size&&this.eventSource&&this.eventSource.setPointerCapture(r,!0)):s.has(n)&&(s.delete(n),0===s.size&&(this._pointerCaptures.delete(r.pointerId),this.eventSource&&this.eventSource.setPointerCapture(r,!1)))}_garbageCollectRemovedHandlers(){this._handlers=this._handlers.filter((e=>!e.removed)),this.updateDependencies()}_emitInputEventFromSource(e,t,r,i){this._emitInputEvent(0,e,t,r,i)}_emitInputEvent(e,t,r,i,n,s){const o=void 0!==i?i:this._currentPropagation?this._currentPropagation.timestamp:performance.now(),a=void 0!==n&&n,h={event:new u(t,r,o,s||this._activeKeyModifiers,a),priorityIndex:e};this._currentPropagation?this._currentPropagation.events.push(h):this._doNewPropagation(h)}_doNewPropagation(e){this._currentPropagation={events:new i,currentHandler:null,needsHandlerGarbageCollect:!1,timestamp:e.event.timestamp},this._currentPropagation.events.push(e),this._continuePropagation()}_continuePropagation(){this._paused=!1;const e=this._currentPropagation;if(e){for(;e.events.length>0;){const{event:t,priorityIndex:r}=e.events.pop(),i=t.data?.eventId;if(!(null!=i&&this._stoppedPropagationEventIds.has(i)))for(e.currentHandler=this._handlersPriority[r];e.currentHandler;){if(e.currentHandler.removed)e.needsHandlerGarbageCollect=!0;else{if(e.currentHandler.active&&!t.shouldStopPropagation()&&e.currentHandler.eventCallback?.(t),t.shouldStopPropagation()){null!=i&&this._stoppedPropagationEventIds.add(i);break}if(t.shouldPausePropagation((()=>this._continuePropagation())))return void this._pausePropagation({event:t,priorityIndex:e.currentHandler.priorityIndex+1})}e.currentHandler=this._handlersPriority[e.currentHandler.priorityIndex+1]}}e.needsHandlerGarbageCollect&&this._garbageCollectRemovedHandlers(),this.hasPendingInputs||this._stoppedPropagationEventIds.clear(),this._currentPropagation=null,this._updateDependenciesAfterPropagation&&this.updateDependencies()}}_pausePropagation(e){const t=new i;t.push(e);const r=this._currentPropagation;if(r){for(;r.events.length;)t.push(r.events.pop());r.events=t,r.currentHandler=null,this._paused=!0}}_compareHandlerPriority(e,t){if(e.handler.hasSideEffects!==t.handler.hasSideEffects)return e.handler.hasSideEffects?1:-1;if(e.groupPriority!==t.groupPriority)return e.groupPriority>t.groupPriority?-1:1;for(const r of e.handler.incomingEventMatches)for(const e of t.handler.incomingEventMatches){if(r.eventType!==e.eventType)continue;const t=r.keyModifiers.filter((t=>e.keyModifiers.includes(t)));if(t.length===r.keyModifiers.length!==(t.length===e.keyModifiers.length))return r.keyModifiers.length>e.keyModifiers.length?-1:1}return e.priorityIndex>t.priorityIndex?-1:1}_sortHandlersPriority(e){const t=[];for(const r of e){let e=0;for(;e<t.length&&this._compareHandlerPriority(r,t[e])>=0;)e++;t.splice(e,0,r)}return t}get debug(){const e=e=>{const t=this._setPointerCapture;this._setPointerCapture=()=>{},e(),this._setPointerCapture=t};return{injectEvent:(t,r)=>{e((()=>{this._onEventReceived(t,r)}))},disablePointerCapture:e}}};e([n({readOnly:!0})],d.prototype,"hasPendingInputs",null),e([n({constructOnly:!0})],d.prototype,"eventSource",void 0),e([n({constructOnly:!0})],d.prototype,"recognizers",void 0),e([n()],d.prototype,"_latestPointerType",void 0),e([n()],d.prototype,"latestPointerType",null),e([n()],d.prototype,"multiTouchActive",null),e([n({readOnly:!0})],d.prototype,"latestPointerLocation",void 0),e([n()],d.prototype,"_paused",void 0),e([n({readOnly:!0})],d.prototype,"updating",null),d=e([s("esri.views.input.InputManager")],d);class u{constructor(e,t,r,i,n){this.type=e,this.data=t,this.timestamp=r,this.modifiers=i,this.cancelable=n,this._propagationState=c.NONE,this._resumeCallback=null}stopPropagation(){this._propagationState|=c.STOPPED}shouldStopPropagation(){return!!(this._propagationState&c.STOPPED)}async(e){this._propagationState|=c.PAUSED;const t=(e,t)=>{this._propagationState&=~c.PAUSED;const r=this._resumeCallback;if(this._resumeCallback=null,r&&r(),t)throw e;return e};return("function"==typeof e?e():e).then((e=>t(e,!1)),(e=>t(e,!0)))}shouldPausePropagation(e){return!!(this._propagationState&c.PAUSED)&&(this._resumeCallback=e,!0)}preventDefault(){this.data.native.preventDefault()}}var c;!function(e){e[e.NONE=0]="NONE",e[e.STOPPED=1]="STOPPED",e[e.PAUSED=2]="PAUSED"}(c||(c={}));const _={ALWAYS:1,DEFAULT:0,TOOL:-1,WIDGET:-2,INTERNAL:-3};class g{}const v=g;export{d as InputManager,_ as ViewEventPriorities};