@arcgis/core 5.0.0-next.33 → 5.0.0-next.35

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 (220) hide show
  1. package/applications/Components/SketchTooltipControls.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{f8a5b26e0231244972d8.js → 032444974011118127d7.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{9252854b512237b6a0ef.js → 0446562aee0639c61485.js} +1 -1
  5. package/assets/esri/core/workers/chunks/15c1a48e8cd2a8882d85.js +1 -0
  6. package/assets/esri/core/workers/chunks/{1dd867fa7c58c06b79ea.js → 1bacdd17e199e22b5cd1.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{b56c07c0b43cb1999070.js → 1fa55d4c4b092a98bdd7.js} +1 -1
  8. package/assets/esri/core/workers/chunks/234ffd08c2be03a0b9fe.js +1 -0
  9. package/assets/esri/core/workers/chunks/32d32d3c3b38a215d20d.js +1 -0
  10. package/assets/esri/core/workers/chunks/{e7f4d135ef9665de1468.js → 33431e8131f6017de2f9.js} +1 -1
  11. package/assets/esri/core/workers/chunks/36130910ba141f34531b.js +1 -0
  12. package/assets/esri/core/workers/chunks/{096e5f94eaa226814569.js → 4356274cfa477eb6d749.js} +1 -1
  13. package/assets/esri/core/workers/chunks/48d1a443b324753921de.js +1 -0
  14. package/assets/esri/core/workers/chunks/{3c1e50c3505e5e7c946a.js → 4d5591c1b4ef37075921.js} +1 -1
  15. package/assets/esri/core/workers/chunks/4f4d51181ae7db9fbe6d.js +1 -0
  16. package/assets/esri/core/workers/chunks/{d21ae4980741be98f948.js → 59889855d23baec1adf9.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{fee942ef802a162e0248.js → 5dc0d853c21ccb6054c7.js} +1 -1
  18. package/assets/esri/core/workers/chunks/5f9e64f00329cb646f0c.js +1 -0
  19. package/assets/esri/core/workers/chunks/{d786b17cc9062b1450ac.js → 726a797f5df7eeee0b3d.js} +1 -1
  20. package/assets/esri/core/workers/chunks/768d9b6eaba7bfa18dde.js +1 -0
  21. package/assets/esri/core/workers/chunks/{a4b7ba8aec109beb5b4d.js → 7d3e665613927904ba4f.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{a2cee5ac0d4df0108425.js → 82cc758bddd9f8397b9f.js} +1 -1
  23. package/assets/esri/core/workers/chunks/{433d249c35c56bf15806.js → 97650ee3d0eecb69ccbb.js} +3 -3
  24. package/assets/esri/core/workers/chunks/{866a608d489bf56bc371.js → a372d9af43ade7c6314c.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{add17e95f47e6904bf6d.js → a59dab47a58695c639da.js} +1 -1
  26. package/assets/esri/core/workers/chunks/{f441fc74451330384fb0.js → abb05a903440d97a6a74.js} +1 -1
  27. package/assets/esri/core/workers/chunks/ad138b989c2c7a1168ac.js +1 -0
  28. package/assets/esri/core/workers/chunks/{5baef729beef0199c3d9.js → b536fdb655ad293d9024.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{1d4ea8db272655c0608c.js → c7c721de93bc8688e13c.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{446f76356fc116204ec3.js → c8d2cce4a426c72ab173.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{14feb12826e0c8ba7fb8.js → d14bd320f72d8e8a0ad8.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{4b6a44c6265c8959abd8.js → d3db7244fac7398cc700.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{7aa730e5ac7b268e3c98.js → dd34d56caafa38d4b8e4.js} +1 -1
  34. package/assets/esri/core/workers/chunks/ef5b13ee3362763c1096.js +1 -0
  35. package/assets/esri/core/workers/chunks/{2a17991923abc64c84c6.js → f55328aabf84770c8e6a.js} +1 -1
  36. package/assets/esri/core/workers/chunks/{e32fc0b2c6530d28ce85.js → fa01d1813fa78034526e.js} +1 -1
  37. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  38. package/chunks/ComponentShader.glsl.js +19 -21
  39. package/chunks/Laserlines.glsl.js +1 -1
  40. package/chunks/Terrain.glsl.js +9 -11
  41. package/chunks/boundedPlane.js +1 -1
  42. package/chunks/cameraUtilsSpherical.js +1 -1
  43. package/chunks/lyr3DMain.js +1 -1
  44. package/chunks/vec32.js +1 -1
  45. package/config.js +1 -1
  46. package/core/deprecate.js +1 -1
  47. package/core/has.js +1 -1
  48. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  49. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  50. package/core/workers/registry.js +1 -1
  51. package/geometry/geometryEngineJSON.js +1 -1
  52. package/geometry/operators/integrateOperator.js +1 -1
  53. package/geometry/support/buffer/BufferView.js +1 -1
  54. package/geometry/support/coordsUtils.js +1 -1
  55. package/geometry/support/curves/curveUtils.js +1 -1
  56. package/geometry/support/curves/interpolateCurve.js +5 -0
  57. package/geometry/support/lineSegment.js +1 -1
  58. package/geometry/support/meshUtils/Metadata.js +1 -1
  59. package/geometry/support/meshUtils/merge.js +1 -1
  60. package/geometry/support/sphere.js +1 -1
  61. package/geometry/support/vector.js +1 -1
  62. package/interfaces.d.ts +71 -445
  63. package/intl/locale.js +1 -1
  64. package/kernel.js +1 -1
  65. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  66. package/layers/SceneLayer.js +1 -1
  67. package/layers/VoxelWasmPerSceneView.js +1 -1
  68. package/layers/graphics/data/QueryEngine.js +1 -1
  69. package/layers/graphics/data/QueryEngineResult.js +1 -1
  70. package/layers/graphics/sources/support/uploadAssets.js +1 -1
  71. package/layers/orientedImagery/transformations/worldToImage.js +1 -1
  72. package/layers/support/layerOriginUtils.js +1 -1
  73. package/layers/voxel/VoxelVolume.js +1 -1
  74. package/package.json +3 -3
  75. package/request/config.js +1 -1
  76. package/request/process.js +1 -1
  77. package/smartMapping/statistics/support/statsWorker.js +1 -1
  78. package/support/revision.js +1 -1
  79. package/views/2d/interactive/SegmentLabels2D.js +5 -0
  80. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  81. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  82. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  83. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  84. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  85. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  86. package/views/3d/analysis/Viewshed/ViewshedScaleOrientManipulation.js +1 -1
  87. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  88. package/views/3d/analysis/Viewshed/ViewshedSubVisualization.js +1 -1
  89. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  90. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  91. package/views/3d/camera/constraintUtils/distance.js +1 -1
  92. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  93. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  94. package/views/3d/environment/CloudsParameters.js +1 -1
  95. package/views/3d/environment/EnvironmentManager.js +1 -1
  96. package/views/3d/environment/MarsAtmosphere.js +1 -1
  97. package/views/3d/interactive/SegmentLabels3D.js +1 -1
  98. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  99. package/views/3d/interactive/editingTools/media/MediaElementManipulator3D.js +1 -1
  100. package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
  101. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  102. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  103. package/views/3d/layers/I3SMeshView3D.js +1 -1
  104. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  105. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  106. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  107. package/views/3d/layers/i3s/PointCloudRenderer.js +1 -1
  108. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  109. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  110. package/views/3d/state/Frustum.js +1 -1
  111. package/views/3d/state/controllers/FovController.js +1 -1
  112. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  113. package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
  114. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  115. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  116. package/views/3d/support/cameraUtils.js +1 -1
  117. package/views/3d/support/intersectionUtils.js +1 -1
  118. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  119. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  120. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  121. package/views/3d/support/viewpointUtils.js +1 -1
  122. package/views/3d/terrain/OverlayManager.js +1 -1
  123. package/views/3d/terrain/PatchRenderData.js +1 -1
  124. package/views/3d/terrain/SphericalPatch.js +1 -1
  125. package/views/3d/terrain/Tile.js +1 -1
  126. package/views/3d/webgl/RenderCamera.js +1 -1
  127. package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
  128. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +63 -0
  129. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  130. package/views/3d/webgl-engine/collections/Component/Material/ComponentShader.glsl.js +5 -0
  131. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  132. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  133. package/views/3d/webgl-engine/collections/Component/Material/{shader/DecodeSymbolColor.glsl.js → DecodeSymbolColor.glsl.js} +1 -1
  134. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +1 -1
  135. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +8 -8
  136. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBufferFields.glsl.js +7 -12
  137. package/views/3d/webgl-engine/core/shaderModules/Texture2DUintDrawUniform.js +5 -0
  138. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  139. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  140. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  141. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  142. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBuffer.js +1 -1
  143. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferFields.js +1 -1
  144. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  145. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  146. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  147. package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
  148. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  149. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  150. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  151. package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
  152. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  153. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  154. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  155. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  156. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  157. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  158. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  159. package/views/3d/webgl-engine/shaders/SphereDepthInterpolate.glsl.js +1 -1
  160. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +18 -18
  161. package/views/Attribution.js +1 -1
  162. package/views/SelectionManager.js +1 -1
  163. package/views/draw/support/Reshape.js +1 -1
  164. package/views/interactive/GraphicManipulator.js +1 -1
  165. package/views/interactive/SegmentLabels.js +1 -1
  166. package/views/interactive/coordinateHelper.js +1 -1
  167. package/views/interactive/editGeometry/EditGeometry.js +1 -1
  168. package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
  169. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  170. package/views/interactive/editGeometry/operations/SetAllVertexPositions.js +1 -1
  171. package/views/interactive/sketch/constraints.js +1 -1
  172. package/views/interactive/sketch/normalizedPoint.js +1 -1
  173. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  174. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  175. package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
  176. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  177. package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
  178. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  179. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  180. package/views/support/geometry3dUtils.js +1 -1
  181. package/views/support/selectionUtils.js +1 -1
  182. package/widgets/Attachments/AttachmentsViewModel.js +1 -1
  183. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  184. package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
  185. package/widgets/BuildingExplorer.js +1 -1
  186. package/widgets/Editor/EditorViewModel.js +1 -1
  187. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  188. package/widgets/Editor/Upload.js +1 -1
  189. package/widgets/Editor/components/Settings.js +1 -1
  190. package/widgets/Editor/support/SketchController.js +1 -1
  191. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  192. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  193. package/widgets/ShadowCast/DiscreteOptions.js +1 -1
  194. package/widgets/ShadowCast/DurationOptions.js +1 -1
  195. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  196. package/widgets/ShadowCast/ThresholdOptions.js +1 -1
  197. package/widgets/ShadowCast.js +1 -1
  198. package/widgets/Sketch/SketchViewModel.js +1 -1
  199. package/widgets/Sketch.js +1 -1
  200. package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
  201. package/widgets/support/SketchTooltipControls.js +1 -1
  202. package/assets/esri/core/workers/chunks/08957e462d06c4dc8ab5.js +0 -1
  203. package/assets/esri/core/workers/chunks/22d66d1c8dfccdbbcf30.js +0 -1
  204. package/assets/esri/core/workers/chunks/484cd728dd17b8dc1f72.js +0 -1
  205. package/assets/esri/core/workers/chunks/6c8f5a56e94fdbe6a4a5.js +0 -1
  206. package/assets/esri/core/workers/chunks/745fc2b89fd7d816f2e0.js +0 -1
  207. package/assets/esri/core/workers/chunks/79c7391f00a55e7bcf6b.js +0 -1
  208. package/assets/esri/core/workers/chunks/7f8b85de079614b9c336.js +0 -1
  209. package/assets/esri/core/workers/chunks/c2596f48b37092dd566c.js +0 -1
  210. package/assets/esri/core/workers/chunks/c6cc3db057da49755d15.js +0 -1
  211. package/assets/esri/core/workers/chunks/d6d03f22c91f528b97e5.js +0 -1
  212. package/assets/esri/core/workers/chunks/ea5bf896acfcc3106bf5.js +0 -1
  213. package/assets/esri/core/workers/chunks/f3127bdf28a1d9b8db27.js +0 -1
  214. package/chunks/geometryEngineJSON.js +0 -5
  215. package/geometry/geometryEngineAsync.d.ts +0 -39
  216. package/geometry/geometryEngineAsync.js +0 -5
  217. package/geometry/geometryEngineWorker.js +0 -5
  218. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +0 -57
  219. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentDataConstants.js +0 -5
  220. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e,deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,rotate as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as u,p as f,n as p,e as h,j as m,d,b as g,C as b,i as v,a as x,t as S,g as y}from"../../../../chunks/vec32.js";import{create as O,fromValues as z}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as _,create as P,freeze as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as M}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as V}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as C}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as D}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as R}from"../../support/debugFlags.js";import{isColorHighlightOrOID as A,isColor as w}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as F}from"../core/shaderLibrary/hud/HUD.glsl.js";import{GLTextureMaterialBindParameters as T,GLTextureMaterial as L}from"../lib/GLTextureMaterial.js";import{Material as E}from"../lib/Material.js";import{SeparateScreenSizePerspectiveEvaluators as U}from"../lib/screenSizePerspectiveUtils.js";import{assert as B}from"../lib/Util.js";import{writePosition as I,writeNormal as q,writeColor as G,writeBufferVec2 as W,writeBufferFloat as H,writeBufferVec4 as N,writeBufferVec4Zeros as X,writeOlidColor as Y}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as k}from"./internal/MaterialUtil.js";import{c as J,f as K}from"../../../../chunks/HUDMaterial.glsl.js";import{baseLayout as Q,getInstanceLayout as Z,HUDMaterialTechnique as $}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as ee}from"../shaders/HUDMaterialTechniqueConfiguration.js";import{alphaCutoff as te}from"../../../../webscene/support/AlphaCutoff.js";class ie extends E{constructor(e,t){super(e,Ve),this.produces=new Map([[13,e=>A(e)&&!this.parameters.drawAsLabel],[14,e=>A(e)&&this.parameters.drawAsLabel],[12,()=>this.parameters.occlusionTest],[18,e=>this.parameters.draped&&A(e)]]),this._visible=!0,this._configuration=new ee(t)}getConfiguration(e,t){const i=this.parameters.draped;return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=i,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.hasRotation=this.parameters.hasRotation,this._configuration.hasVVSize=!!this.parameters.vvSize,this._configuration.hasVVColor=!!this.parameters.vvColor,this._configuration.occlusionPass=12===t.slot,this._configuration.occludedFragmentFade=!i&&this.parameters.occludedFragmentFade,this._configuration.horizonCullingEnabled=this.parameters.horizonCullingEnabled,this._configuration.isFocused=this.parameters.isFocused,this._configuration.depthTestEnabled=this.parameters.depthEnabled||12===t.slot,w(e)&&(this._configuration.debugDrawLabelBorder=!!R.LABELS_SHOW_BORDER),this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}intersect(e,t,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:v},point:x,camera:S}=s,{parameters:y}=this;if(!l||!c||v&&y.isLabel||!e.visible||!x||!S)return;const z=e.attributes.get("featureAttribute"),P=null==z?null:_(z.data,Oe),{scaleX:j,scaleY:M}=De(P,y,S.pixelRatio);i(ge,t),e.attributes.has("featureAttribute")&&ne(ge);const V=e.attributes.get("position"),C=e.attributes.get("size"),D=e.attributes.get("normal"),R=e.attributes.get("rotation"),A=e.attributes.get("centerOffsetAndDistance");B(V.size>=3);const w=J(y),F="screen"===this.parameters.centerOffsetUnits;for(let i=0;i<V.data.length/V.size;i++){const e=i*V.size;u(ce,V.data[e],V.data[e+1],V.data[e+2]),f(ce,ce,t),f(ce,ce,S.viewMatrix);const a=i*A.size;if(u(Se,A.data[a],A.data[a+1],A.data[a+2]),!F&&(ce[0]+=Se[0],ce[1]+=Se[1],0!==Se[2])){const e=Se[2];p(Se,ce),h(ce,ce,m(Se,Se,e))}const n=i*D.size;if(u(ue,D.data[n],D.data[n+1],D.data[n+2]),ae(ue,ge,S,ze),Re(this.parameters,ce,ze,S,le),S.applyProjection(ce,fe),fe[0]>-1){F&&(Se[0]||Se[1])&&(fe[0]+=Se[0]*S.pixelRatio,0!==Se[1]&&(fe[1]+=le.alignmentEvaluator.apply(Se[1])*S.pixelRatio),S.unapplyProjection(fe,ce)),fe[0]+=this.parameters.screenOffset[0]*S.pixelRatio,fe[1]+=this.parameters.screenOffset[1]*S.pixelRatio,fe[0]=Math.floor(fe[0]),fe[1]=Math.floor(fe[1]);const e=i*C.size;je[0]=C.data[e],je[1]=C.data[e+1],le.evaluator.applyVec2(je,je);const t=_e*S.pixelRatio;let a=0;if(y.textureIsSignedDistanceField){a=Math.min(y.outlineSize,.5*je[0])*S.pixelRatio/2}je[0]*=j,je[1]*=M;const n=i*R.size,l=y.rotation+R.data[n];if(oe(x,fe[0],fe[1],je,t,a,l,y,w)){const e=s.ray;if(f(he,ce,r(ve,S.viewMatrix)),fe[0]=x[0],fe[1]=x[1],S.unprojectFromRenderScreen(fe,ce)){const t=O();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ce)*i,t,-1,he)}}}}}intersectDraped(e,t,i,s,r){const a=e.attributes.get("position"),n=e.attributes.get("size"),o=e.attributes.get("rotation"),l=this.parameters,c=J(l),u=e.attributes.get("featureAttribute"),f=null==u?null:_(u.data,Oe),{scaleX:p,scaleY:h}=De(f,l,e.screenToWorldRatio),m=Pe*e.screenToWorldRatio;for(let d=0;d<a.data.length/a.size;d++){const t=d*a.size,u=a.data[t],f=a.data[t+1],g=d*n.size;je[0]=n.data[g],je[1]=n.data[g+1];let b=0;if(l.textureIsSignedDistanceField){b=Math.min(l.outlineSize,.5*je[0])*e.screenToWorldRatio/2}je[0]*=p,je[1]*=h;const v=d*o.size,x=l.rotation+o.data[v];oe(i,u,f,je,m,b,x,l,c)&&s(r.distance,r.normal,-1)}}createBufferWriter(){return new Ce}applyShaderOffsetsView(e,t,i,s,r,a,n){const o=ae(t,i,r,ze);return this._applyVerticalGroundOffsetView(e,o,r,n),Re(this.parameters,n,o,r,a),this._applyPolygonOffsetView(n,o,s[3],r,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,i,s,r){return this._applyCenterOffsetNDC(e,t,i,s),null!=r&&d(r,s),this._applyPolygonOffsetNDC(s,t,i,s),s}_applyPolygonOffsetView(t,i,s,r,a){const n=r.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return d(a,t);const c=e(Math.abs(i.cosAngle),.01,1),u=1-Math.sqrt(1-c*c)/c/r.viewport[2];return m(a,t,l>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,i,s){const r=g(e),a=i.aboveGround?1:-1,n=i.computeRenderPixelSizeAtDist(r)*F,o=m(ce,t.normal,a*n);return v(s,e,o),s}_applyCenterOffsetView(e,t,i){const s="screen"!==this.parameters.centerOffsetUnits;return i!==e&&d(i,e),s&&(i[0]+=t[0],i[1]+=t[1],t[2]&&(p(ue,i),x(i,i,m(ue,ue,t[2])))),i}_applyCenterOffsetNDC(e,t,i,s){const r="screen"!==this.parameters.centerOffsetUnits;return s!==e&&d(s,e),r||(s[0]+=t[0]/i.fullWidth*2,s[1]+=t[1]/i.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,i,s){const r=this.parameters.shaderPolygonOffset;if(e!==s&&d(s,e),r){const e=i.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*r}return s}set visible(e){this._visible=e}get visible(){const{color:e,outlineSize:t,outlineColor:i}=this.parameters,s=e[3]>=te||t>=te&&i[3]>=te;return this._visible&&s}createGLMaterial(e){return new se(e)}calculateRelativeScreenBounds(e,t,i=V()){return re(this.parameters,e,t,i),i[2]=i[0]+e[0],i[3]=i[1]+e[1],i}}class se extends L{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.getTechnique($,e)}}function re(e,t,i,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*i,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*i}function ae(e,t,s,r){return M(t)&&(t=i(be,t)),S(r.normal,e,t),f(r.normal,r.normal,s.viewInverseTransposeMatrix),r.cosAngle=y(pe,Me),r}function ne(e){const t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],u=1/Math.sqrt(t*t+i*i+s*s),f=1/Math.sqrt(r*r+a*a+n*n),p=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*u,e[1]=i*u,e[2]=s*u,e[3]=r*f,e[4]=a*f,e[5]=n*f,e[6]=o*p,e[7]=l*p,e[8]=c*p,e}function oe(e,i,s,r,a,l,c,u,f){let p=i-a-r[0]*f[0],h=p+r[0]+2*a,m=s-a-r[1]*f[1],d=m+r[1]+2*a;const g=u.distanceFieldBoundingBox;return u.textureIsSignedDistanceField&&null!=g&&(p+=r[0]*g[0],m+=r[1]*g[1],h-=r[0]*(1-g[2]),d-=r[1]*(1-g[3]),p-=l,h+=l,m-=l,d+=l),n(de,i,s),o(me,e,de,t(c)),me[0]>p&&me[0]<h&&me[1]>m&&me[1]<d}const le=new U,ce=O(),ue=O(),fe=P(),pe=O(),he=O(),me=c(),de=c(),ge=s(),be=s(),ve=a(),xe=P(),Se=O(),ye=O(),Oe=P(),ze={normal:pe,cosAngle:0},_e=1,Pe=2,je=l(0,0),Me=z(0,0,1);class Ve extends T{constructor(){super(...arguments),this.renderOccluded=1,this.isDecoration=!1,this.color=j(1,1,1,1),this.polygonOffset=!1,this.anchorPosition=l(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=j(1,1,1,1),this.outlineSize=0,this.distanceFieldBoundingBox=P(),this.rotation=0,this.hasRotation=!1,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.occludedFragmentFade=!1,this.horizonCullingEnabled=!1,this.centerOffsetUnits="world",this.drawAsLabel=!1,this.depthEnabled=!0,this.isFocused=!0,this.focusStyle="bright",this.draped=!1,this.isLabel=!1}get hasVVSize(){return!!this.vvSize}get hasVVColor(){return!!this.vvColor}get hasVVOpacity(){return!!this.vvOpacity}}class Ce{constructor(){this.layout=Q,this.instanceLayout=Z()}elementCount(e){return e.get("position").indices.length}elementCountBaseInstance(e){return e.get("uv0").indices.length}write(e,t,i,s,r,a){const{position:n,normal:o,color:l,size:c,rotation:u,centerOffsetAndDistance:f,featureAttribute:p,uvi:h}=r;I(i.get("position"),e,n,a),q(i.get("normal"),t,o,a);const m=i.get("position").indices.length;let d=0,g=0,b=K,v=K;const x=i.get("uvi")?.data;x&&x.length>=4&&(d=x[0],g=x[1],b=x[2],v=x[3]);for(let S=0;S<m;++S){const e=a+S;h.setValues(e,d,g,b,v)}if(G(i.get("color"),4,l,a),W(i.get("size"),c,a),H(i.get("rotation"),u,a),i.get("centerOffsetAndDistance")?N(i.get("centerOffsetAndDistance"),f,a):X(f,a,m),i.get("featureAttribute")?N(i.get("featureAttribute"),p,a):X(p,a,m),null!=s){const e=i.get("position")?.indices;if(e){const t=e.length,i=r.getField("olidColor",C);Y(s,i,t,a)}}return{numVerticesPerItem:1,numItems:m}}writeBaseInstance(e,t){const{uv0:i}=t;W(e.get("uv0"),i,0)}intersect(e,t,i,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:x},point:S,camera:y}=s;if(!l||!c||x&&t.isLabel||!S)return;const z=this.instanceLayout.createView(e),{position:_,normal:P,rotation:j,size:M,featureAttribute:V,centerOffsetAndDistance:C}=z,D="screen"===t.centerOffsetUnits,R=J(t);if(null==_||null==P||null==j||null==M||null==C||null==y)return;const A=null==V?null:V.getVec(0,Oe),{scaleX:w,scaleY:F}=De(A,t,y.pixelRatio),T=_.count;for(let L=0;L<T;L++){if(_.getVec(L,ce),null!=i&&v(ce,ce,i),f(ce,ce,y.viewMatrix),C.getVec(L,xe),u(Se,xe[0],xe[1],xe[2]),!D&&(ce[0]+=Se[0],ce[1]+=Se[1],0!==Se[2])){const e=Se[2];p(Se,ce),h(ce,ce,m(Se,Se,e))}if(P.getVec(L,ue),ae(ue,ge,y,ze),Re(t,ce,ze,y,le),y.applyProjection(ce,fe),fe[0]>-1){D&&(Se[0]||Se[1])&&(fe[0]+=Se[0]*y.pixelRatio,0!==Se[1]&&(fe[1]+=le.alignmentEvaluator.apply(Se[1])*y.pixelRatio),y.unapplyProjection(fe,ce)),fe[0]+=t.screenOffset[0]*y.pixelRatio,fe[1]+=t.screenOffset[1]*y.pixelRatio,fe[0]=Math.floor(fe[0]),fe[1]=Math.floor(fe[1]),M.getVec(L,je),le.evaluator.applyVec2(je,je);const e=_e*y.pixelRatio;let i=0;if(t.textureIsSignedDistanceField){i=Math.min(t.outlineSize,.5*je[0])*y.pixelRatio/2}je[0]*=w,je[1]*=F;const a=j.get(L),n=t.rotation+a;if(oe(S,fe[0],fe[1],je,e,i,n,t,R)){const e=s.ray;if(f(he,ce,r(ve,y.viewMatrix)),fe[0]=S[0],fe[1]=S[1],y.unprojectFromRenderScreen(fe,ce)){const t=O();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ce)*i,t,L,he)}}}}}}function De(e,t,i){return null==e||null==t.vvSize?{scaleX:i,scaleY:i}:(D(ye,t,e),{scaleX:ye[0]*i,scaleY:ye[1]*i})}function Re(e,t,i,s,r){if(!e.verticalOffset?.screenLength){const s=g(t);return r.update(i.cosAngle,s,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),t}const a=g(t),n=e.screenSizePerspectiveAlignment??e.screenSizePerspective,o=k(s,a,e.verticalOffset,i.cosAngle,n,e.screenSizePerspectiveMinPixelReferenceSize);return r.update(i.cosAngle,a,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),m(i.normal,i.normal,o),v(t,t,i.normal)}export{ie as HUDMaterial,Ve as Parameters};
5
+ import{clamp as e,deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,rotate as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as u,p as f,n as p,e as h,j as m,d,b as g,D as b,i as v,a as x,t as S,g as y}from"../../../../chunks/vec32.js";import{create as O,fromValues as z}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as _,create as P,freeze as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as M}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as D}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as V}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as R}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as A}from"../../support/debugFlags.js";import{isColorHighlightOrOID as C,isColor as w}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as F}from"../core/shaderLibrary/hud/HUD.glsl.js";import{GLTextureMaterialBindParameters as T,GLTextureMaterial as L}from"../lib/GLTextureMaterial.js";import{Material as E}from"../lib/Material.js";import{SeparateScreenSizePerspectiveEvaluators as U}from"../lib/screenSizePerspectiveUtils.js";import{assert as B}from"../lib/Util.js";import{writePosition as I,writeNormal as q,writeColor as G,writeBufferVec2 as W,writeBufferFloat as H,writeBufferVec4 as N,writeBufferVec4Zeros as X,writeOlidColor as Y}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as k}from"./internal/MaterialUtil.js";import{c as J,f as K}from"../../../../chunks/HUDMaterial.glsl.js";import{baseLayout as Q,getInstanceLayout as Z,HUDMaterialTechnique as $}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as ee}from"../shaders/HUDMaterialTechniqueConfiguration.js";import{alphaCutoff as te}from"../../../../webscene/support/AlphaCutoff.js";class ie extends E{constructor(e,t){super(e,De),this.produces=new Map([[13,e=>C(e)&&!this.parameters.drawAsLabel],[14,e=>C(e)&&this.parameters.drawAsLabel],[12,()=>this.parameters.occlusionTest],[18,e=>this.parameters.draped&&C(e)]]),this._visible=!0,this._configuration=new ee(t)}getConfiguration(e,t){const i=this.parameters.draped;return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=i,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.hasRotation=this.parameters.hasRotation,this._configuration.hasVVSize=!!this.parameters.vvSize,this._configuration.hasVVColor=!!this.parameters.vvColor,this._configuration.occlusionPass=12===t.slot,this._configuration.occludedFragmentFade=!i&&this.parameters.occludedFragmentFade,this._configuration.horizonCullingEnabled=this.parameters.horizonCullingEnabled,this._configuration.isFocused=this.parameters.isFocused,this._configuration.depthTestEnabled=this.parameters.depthEnabled||12===t.slot,w(e)&&(this._configuration.debugDrawLabelBorder=!!A.LABELS_SHOW_BORDER),this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}intersect(e,t,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:v},point:x,camera:S}=s,{parameters:y}=this;if(!l||!c||v&&y.isLabel||!e.visible||!x||!S)return;const z=e.attributes.get("featureAttribute"),P=null==z?null:_(z.data,Oe),{scaleX:j,scaleY:M}=Re(P,y,S.pixelRatio);i(ge,t),e.attributes.has("featureAttribute")&&ne(ge);const D=e.attributes.get("position"),V=e.attributes.get("size"),R=e.attributes.get("normal"),A=e.attributes.get("rotation"),C=e.attributes.get("centerOffsetAndDistance");B(D.size>=3);const w=J(y),F="screen"===this.parameters.centerOffsetUnits;for(let i=0;i<D.data.length/D.size;i++){const e=i*D.size;u(ce,D.data[e],D.data[e+1],D.data[e+2]),f(ce,ce,t),f(ce,ce,S.viewMatrix);const a=i*C.size;if(u(Se,C.data[a],C.data[a+1],C.data[a+2]),!F&&(ce[0]+=Se[0],ce[1]+=Se[1],0!==Se[2])){const e=Se[2];p(Se,ce),h(ce,ce,m(Se,Se,e))}const n=i*R.size;if(u(ue,R.data[n],R.data[n+1],R.data[n+2]),ae(ue,ge,S,ze),Ae(this.parameters,ce,ze,S,le),S.applyProjection(ce,fe),fe[0]>-1){F&&(Se[0]||Se[1])&&(fe[0]+=Se[0]*S.pixelRatio,0!==Se[1]&&(fe[1]+=le.alignmentEvaluator.apply(Se[1])*S.pixelRatio),S.unapplyProjection(fe,ce)),fe[0]+=this.parameters.screenOffset[0]*S.pixelRatio,fe[1]+=this.parameters.screenOffset[1]*S.pixelRatio,fe[0]=Math.floor(fe[0]),fe[1]=Math.floor(fe[1]);const e=i*V.size;je[0]=V.data[e],je[1]=V.data[e+1],le.evaluator.applyVec2(je,je);const t=_e*S.pixelRatio;let a=0;if(y.textureIsSignedDistanceField){a=Math.min(y.outlineSize,.5*je[0])*S.pixelRatio/2}je[0]*=j,je[1]*=M;const n=i*A.size,l=y.rotation+A.data[n];if(oe(x,fe[0],fe[1],je,t,a,l,y,w)){const e=s.ray;if(f(he,ce,r(ve,S.viewMatrix)),fe[0]=x[0],fe[1]=x[1],S.unprojectFromRenderScreen(fe,ce)){const t=O();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ce)*i,t,-1,he)}}}}}intersectDraped(e,t,i,s,r){const a=e.attributes.get("position"),n=e.attributes.get("size"),o=e.attributes.get("rotation"),l=this.parameters,c=J(l),u=e.attributes.get("featureAttribute"),f=null==u?null:_(u.data,Oe),{scaleX:p,scaleY:h}=Re(f,l,e.screenToWorldRatio),m=Pe*e.screenToWorldRatio;for(let d=0;d<a.data.length/a.size;d++){const t=d*a.size,u=a.data[t],f=a.data[t+1],g=d*n.size;je[0]=n.data[g],je[1]=n.data[g+1];let b=0;if(l.textureIsSignedDistanceField){b=Math.min(l.outlineSize,.5*je[0])*e.screenToWorldRatio/2}je[0]*=p,je[1]*=h;const v=d*o.size,x=l.rotation+o.data[v];oe(i,u,f,je,m,b,x,l,c)&&s(r.distance,r.normal,-1)}}createBufferWriter(){return new Ve}applyShaderOffsetsView(e,t,i,s,r,a,n){const o=ae(t,i,r,ze);return this._applyVerticalGroundOffsetView(e,o,r,n),Ae(this.parameters,n,o,r,a),this._applyPolygonOffsetView(n,o,s[3],r,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,i,s,r){return this._applyCenterOffsetNDC(e,t,i,s),null!=r&&d(r,s),this._applyPolygonOffsetNDC(s,t,i,s),s}_applyPolygonOffsetView(t,i,s,r,a){const n=r.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return d(a,t);const c=e(Math.abs(i.cosAngle),.01,1),u=1-Math.sqrt(1-c*c)/c/r.viewport[2];return m(a,t,l>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,i,s){const r=g(e),a=i.aboveGround?1:-1,n=i.computeRenderPixelSizeAtDist(r)*F,o=m(ce,t.normal,a*n);return v(s,e,o),s}_applyCenterOffsetView(e,t,i){const s="screen"!==this.parameters.centerOffsetUnits;return i!==e&&d(i,e),s&&(i[0]+=t[0],i[1]+=t[1],t[2]&&(p(ue,i),x(i,i,m(ue,ue,t[2])))),i}_applyCenterOffsetNDC(e,t,i,s){const r="screen"!==this.parameters.centerOffsetUnits;return s!==e&&d(s,e),r||(s[0]+=t[0]/i.fullWidth*2,s[1]+=t[1]/i.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,i,s){const r=this.parameters.shaderPolygonOffset;if(e!==s&&d(s,e),r){const e=i.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*r}return s}set visible(e){this._visible=e}get visible(){const{color:e,outlineSize:t,outlineColor:i}=this.parameters,s=e[3]>=te||t>=te&&i[3]>=te;return this._visible&&s}createGLMaterial(e){return new se(e)}calculateRelativeScreenBounds(e,t,i=D()){return re(this.parameters,e,t,i),i[2]=i[0]+e[0],i[3]=i[1]+e[1],i}}class se extends L{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.getTechnique($,e)}}function re(e,t,i,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*i,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*i}function ae(e,t,s,r){return M(t)&&(t=i(be,t)),S(r.normal,e,t),f(r.normal,r.normal,s.viewInverseTransposeMatrix),r.cosAngle=y(pe,Me),r}function ne(e){const t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],u=1/Math.sqrt(t*t+i*i+s*s),f=1/Math.sqrt(r*r+a*a+n*n),p=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*u,e[1]=i*u,e[2]=s*u,e[3]=r*f,e[4]=a*f,e[5]=n*f,e[6]=o*p,e[7]=l*p,e[8]=c*p,e}function oe(e,i,s,r,a,l,c,u,f){let p=i-a-r[0]*f[0],h=p+r[0]+2*a,m=s-a-r[1]*f[1],d=m+r[1]+2*a;const g=u.distanceFieldBoundingBox;return u.textureIsSignedDistanceField&&null!=g&&(p+=r[0]*g[0],m+=r[1]*g[1],h-=r[0]*(1-g[2]),d-=r[1]*(1-g[3]),p-=l,h+=l,m-=l,d+=l),n(de,i,s),o(me,e,de,t(c)),me[0]>p&&me[0]<h&&me[1]>m&&me[1]<d}const le=new U,ce=O(),ue=O(),fe=P(),pe=O(),he=O(),me=c(),de=c(),ge=s(),be=s(),ve=a(),xe=P(),Se=O(),ye=O(),Oe=P(),ze={normal:pe,cosAngle:0},_e=1,Pe=2,je=l(0,0),Me=z(0,0,1);class De extends T{constructor(){super(...arguments),this.renderOccluded=1,this.isDecoration=!1,this.color=j(1,1,1,1),this.polygonOffset=!1,this.anchorPosition=l(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=j(1,1,1,1),this.outlineSize=0,this.distanceFieldBoundingBox=P(),this.rotation=0,this.hasRotation=!1,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.occludedFragmentFade=!1,this.horizonCullingEnabled=!1,this.centerOffsetUnits="world",this.drawAsLabel=!1,this.depthEnabled=!0,this.isFocused=!0,this.focusStyle="bright",this.draped=!1,this.isLabel=!1}get hasVVSize(){return!!this.vvSize}get hasVVColor(){return!!this.vvColor}get hasVVOpacity(){return!!this.vvOpacity}}class Ve{constructor(){this.layout=Q,this.instanceLayout=Z()}elementCount(e){return e.get("position").indices.length}elementCountBaseInstance(e){return e.get("uv0").indices.length}write(e,t,i,s,r,a){const{position:n,normal:o,color:l,size:c,rotation:u,centerOffsetAndDistance:f,featureAttribute:p,uvi:h}=r;I(i.get("position"),e,n,a),q(i.get("normal"),t,o,a);const m=i.get("position").indices.length;let d=0,g=0,b=K,v=K;const x=i.get("uvi")?.data;x&&x.length>=4&&(d=x[0],g=x[1],b=x[2],v=x[3]);for(let S=0;S<m;++S){const e=a+S;h.setValues(e,d,g,b,v)}if(G(i.get("color"),4,l,a),W(i.get("size"),c,a),H(i.get("rotation"),u,a),i.get("centerOffsetAndDistance")?N(i.get("centerOffsetAndDistance"),f,a):X(f,a,m),i.get("featureAttribute")?N(i.get("featureAttribute"),p,a):X(p,a,m),null!=s){const e=i.get("position")?.indices;if(e){const t=e.length,i=r.getField("olidColor",V);Y(s,i,t,a)}}return{numVerticesPerItem:1,numItems:m}}writeBaseInstance(e,t){const{uv0:i}=t;W(e.get("uv0"),i,0)}intersect(e,t,i,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:x},point:S,camera:y}=s;if(!l||!c||x&&t.isLabel||!S)return;const z=this.instanceLayout.createView(e),{position:_,normal:P,rotation:j,size:M,featureAttribute:D,centerOffsetAndDistance:V}=z,R="screen"===t.centerOffsetUnits,A=J(t);if(null==_||null==P||null==j||null==M||null==V||null==y)return;const C=null==D?null:D.getVec(0,Oe),{scaleX:w,scaleY:F}=Re(C,t,y.pixelRatio),T=_.count;for(let L=0;L<T;L++){if(_.getVec(L,ce),null!=i&&v(ce,ce,i),f(ce,ce,y.viewMatrix),V.getVec(L,xe),u(Se,xe[0],xe[1],xe[2]),!R&&(ce[0]+=Se[0],ce[1]+=Se[1],0!==Se[2])){const e=Se[2];p(Se,ce),h(ce,ce,m(Se,Se,e))}if(P.getVec(L,ue),ae(ue,ge,y,ze),Ae(t,ce,ze,y,le),y.applyProjection(ce,fe),fe[0]>-1){R&&(Se[0]||Se[1])&&(fe[0]+=Se[0]*y.pixelRatio,0!==Se[1]&&(fe[1]+=le.alignmentEvaluator.apply(Se[1])*y.pixelRatio),y.unapplyProjection(fe,ce)),fe[0]+=t.screenOffset[0]*y.pixelRatio,fe[1]+=t.screenOffset[1]*y.pixelRatio,fe[0]=Math.floor(fe[0]),fe[1]=Math.floor(fe[1]),M.getVec(L,je),le.evaluator.applyVec2(je,je);const e=_e*y.pixelRatio;let i=0;if(t.textureIsSignedDistanceField){i=Math.min(t.outlineSize,.5*je[0])*y.pixelRatio/2}je[0]*=w,je[1]*=F;const a=j.get(L),n=t.rotation+a;if(oe(S,fe[0],fe[1],je,e,i,n,t,A)){const e=s.ray;if(f(he,ce,r(ve,y.viewMatrix)),fe[0]=S[0],fe[1]=S[1],y.unprojectFromRenderScreen(fe,ce)){const t=O();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ce)*i,t,L,he)}}}}}}function Re(e,t,i){return null==e||null==t.vvSize?{scaleX:i,scaleY:i}:(R(ye,t,e),{scaleX:ye[0]*i,scaleY:ye[1]*i})}function Ae(e,t,i,s,r){if(!e.verticalOffset?.screenLength){const s=g(t);return r.update(i.cosAngle,s,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),t}const a=g(t),n=e.screenSizePerspectiveAlignment??e.screenSizePerspective,o=k(s,a,e.verticalOffset,i.cosAngle,n,e.screenSizePerspectiveMinPixelReferenceSize);return r.update(i.cosAngle,a,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),m(i.normal,i.normal,o),v(t,t,i.normal)}export{ie as HUDMaterial,De as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{h as e,F as t,p as r}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{makeFloat16Array as s}from"../../../../geometry/support/float16.js";import{isColor as a,isDepth as o,isColorHighlightOIDOrDepth as n}from"../core/shaderLibrary/ShaderOutput.js";import h from"../lib/GLMaterial.js";import{Material as c}from"../lib/Material.js";import{VisualVariablePassParameters as p}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as l}from"./internal/bufferWriterUtils.js";import{getLayout as m,LineMarkerTechnique as u}from"../shaders/LineMarkerTechnique.js";import{LineMarkerTechniqueConfiguration as d}from"../shaders/LineMarkerTechniqueConfiguration.js";import{alphaCutoff as f}from"../../../../webscene/support/AlphaCutoff.js";class g extends c{constructor(e,t){super(e,v),this.produces=new Map([[2,e=>8===e||a(e)&&8===this.parameters.renderOccluded],[3,e=>o(e)],[10,e=>n(e)&&8===this.parameters.renderOccluded],[11,e=>n(e)&&8===this.parameters.renderOccluded],[4,e=>a(e)&&this.parameters.writeDepth],[8,e=>a(e)&&!this.parameters.writeDepth],[18,e=>a(e)||8===e]]),this.intersectDraped=void 0,this._configuration=new d(t)}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.space=18===t.slot?0:this.parameters.worldSpace?2:1,this._configuration.hideOnShortSegments=this.parameters.hideOnShortSegments,this._configuration.hasCap=0!==this.parameters.cap,this._configuration.anchor=this.parameters.anchor,this._configuration.hasTip=this.parameters.hasTip,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=t.hasOccludees,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest&&a(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.hasScreenSizePerspective=null!=this.parameters.screenSizePerspective,this._configuration}get visible(){return this.parameters.color[3]>=f}intersect(){}createBufferWriter(){return new S(m(this.parameters),this.parameters)}createGLMaterial(e){return new _(e)}}class _ extends h{dispose(){super.dispose(),this._markerTextures?.release(this._markerPrimitive),this._markerPrimitive=null}beginSlot(e){const t=this._material.parameters.markerPrimitive;return t!==this._markerPrimitive&&(this._material.setParameters({markerTexture:this._markerTextures.swap(t,this._markerPrimitive)}),this._markerPrimitive=t),this.getTechnique(u,e)}}class v extends p{constructor(){super(...arguments),this.width=0,this.color=[1,1,1,1],this.markerPrimitive="arrow",this.placement="end",this.cap=0,this.anchor=0,this.hasTip=!1,this.worldSpace=!1,this.hideOnShortSegments=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.stipplePattern=null,this.markerTexture=null}}class S{constructor(e,t){this.layout=e,this._parameters=t}elementCount(){return"begin-end"===this._parameters.placement?12:6}write(i,a,o,n,h,c){const p=o.get("position").data,m=p.length/3;let u=[1,0,0];const d=o.get("normal");this._parameters.worldSpace&&null!=d&&(u=d.data);let f=1,g=0;this._parameters.vvSize?g=o.get("sizeFeatureAttribute").data[0]:o.has("size")&&(f=o.get("size").data[0]);let _=[1,1,1,1],v=0;this._parameters.vvColor?v=o.get("colorFeatureAttribute").data[0]:o.has("color")&&(_=o.get("color").data);let S=0;this._parameters.vvOpacity&&(S=o.get("opacityFeatureAttribute").data[0]);const P=new Float32Array(h.buffer),T=s(h.buffer),k=new Uint8Array(h.buffer);let O=c*(this.layout.stride/4);const V=P.BYTES_PER_ELEMENT/T.BYTES_PER_ELEMENT,j=4/V,y=(e,t,r,i)=>{P[O++]=e[0],P[O++]=e[1],P[O++]=e[2],l(t,e,T,O*V),O+=j;let s=O*V;if(T[s++]=r[0],T[s++]=r[1],O=Math.ceil(s/V),this._parameters.vvColor)P[O++]=v;else{const e=Math.min(4*i,_.length-4),t=4*O++;k[t]=255*_[e],k[t+1]=255*_[e+1],k[t+2]=255*_[e+2],k[t+3]=255*_[e+3]}this._parameters.vvOpacity&&(P[O++]=S),s=O*V,this._parameters.vvSize?(P[O++]=g,s+=2):T[s++]=f,this._parameters.worldSpace&&(T[s++]=u[0],T[s++]=u[1],T[s++]=u[2]),O=Math.ceil(s/V)},M=(s,a)=>{const o=e(b,p[3*s],p[3*s+1],p[3*s+2]),n=w;let h=s+a;do{e(n,p[3*h],p[3*h+1],p[3*h+2]),h+=a}while(t(o,n)&&h>=0&&h<m);i&&(r(o,o,i),r(n,n,i)),y(o,n,[-1,-1],s),y(o,n,[1,-1],s),y(o,n,[1,1],s),y(o,n,[-1,-1],s),y(o,n,[1,1],s),y(o,n,[-1,1],s)},C=this._parameters.placement;return"begin"!==C&&"begin-end"!==C||M(0,1),"end"!==C&&"begin-end"!==C||M(m-1,-1),null}}const b=i(),w=i();export{g as LineMarkerMaterial,v as Parameters};
5
+ import{h as e,G as t,p as r}from"../../../../chunks/vec32.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{makeFloat16Array as s}from"../../../../geometry/support/float16.js";import{isColor as a,isDepth as o,isColorHighlightOIDOrDepth as n}from"../core/shaderLibrary/ShaderOutput.js";import h from"../lib/GLMaterial.js";import{Material as c}from"../lib/Material.js";import{VisualVariablePassParameters as p}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as l}from"./internal/bufferWriterUtils.js";import{getLayout as m,LineMarkerTechnique as u}from"../shaders/LineMarkerTechnique.js";import{LineMarkerTechniqueConfiguration as d}from"../shaders/LineMarkerTechniqueConfiguration.js";import{alphaCutoff as f}from"../../../../webscene/support/AlphaCutoff.js";class g extends c{constructor(e,t){super(e,v),this.produces=new Map([[2,e=>8===e||a(e)&&8===this.parameters.renderOccluded],[3,e=>o(e)],[10,e=>n(e)&&8===this.parameters.renderOccluded],[11,e=>n(e)&&8===this.parameters.renderOccluded],[4,e=>a(e)&&this.parameters.writeDepth],[8,e=>a(e)&&!this.parameters.writeDepth],[18,e=>a(e)||8===e]]),this.intersectDraped=void 0,this._configuration=new d(t)}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.space=18===t.slot?0:this.parameters.worldSpace?2:1,this._configuration.hideOnShortSegments=this.parameters.hideOnShortSegments,this._configuration.hasCap=0!==this.parameters.cap,this._configuration.anchor=this.parameters.anchor,this._configuration.hasTip=this.parameters.hasTip,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasOccludees=t.hasOccludees,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest&&a(e),this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration.hasScreenSizePerspective=null!=this.parameters.screenSizePerspective,this._configuration}get visible(){return this.parameters.color[3]>=f}intersect(){}createBufferWriter(){return new S(m(this.parameters),this.parameters)}createGLMaterial(e){return new _(e)}}class _ extends h{dispose(){super.dispose(),this._markerTextures?.release(this._markerPrimitive),this._markerPrimitive=null}beginSlot(e){const t=this._material.parameters.markerPrimitive;return t!==this._markerPrimitive&&(this._material.setParameters({markerTexture:this._markerTextures.swap(t,this._markerPrimitive)}),this._markerPrimitive=t),this.getTechnique(u,e)}}class v extends p{constructor(){super(...arguments),this.width=0,this.color=[1,1,1,1],this.markerPrimitive="arrow",this.placement="end",this.cap=0,this.anchor=0,this.hasTip=!1,this.worldSpace=!1,this.hideOnShortSegments=!1,this.writeDepth=!0,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.stipplePattern=null,this.markerTexture=null}}class S{constructor(e,t){this.layout=e,this._parameters=t}elementCount(){return"begin-end"===this._parameters.placement?12:6}write(i,a,o,n,h,c){const p=o.get("position").data,m=p.length/3;let u=[1,0,0];const d=o.get("normal");this._parameters.worldSpace&&null!=d&&(u=d.data);let f=1,g=0;this._parameters.vvSize?g=o.get("sizeFeatureAttribute").data[0]:o.has("size")&&(f=o.get("size").data[0]);let _=[1,1,1,1],v=0;this._parameters.vvColor?v=o.get("colorFeatureAttribute").data[0]:o.has("color")&&(_=o.get("color").data);let S=0;this._parameters.vvOpacity&&(S=o.get("opacityFeatureAttribute").data[0]);const P=new Float32Array(h.buffer),T=s(h.buffer),k=new Uint8Array(h.buffer);let O=c*(this.layout.stride/4);const V=P.BYTES_PER_ELEMENT/T.BYTES_PER_ELEMENT,j=4/V,y=(e,t,r,i)=>{P[O++]=e[0],P[O++]=e[1],P[O++]=e[2],l(t,e,T,O*V),O+=j;let s=O*V;if(T[s++]=r[0],T[s++]=r[1],O=Math.ceil(s/V),this._parameters.vvColor)P[O++]=v;else{const e=Math.min(4*i,_.length-4),t=4*O++;k[t]=255*_[e],k[t+1]=255*_[e+1],k[t+2]=255*_[e+2],k[t+3]=255*_[e+3]}this._parameters.vvOpacity&&(P[O++]=S),s=O*V,this._parameters.vvSize?(P[O++]=g,s+=2):T[s++]=f,this._parameters.worldSpace&&(T[s++]=u[0],T[s++]=u[1],T[s++]=u[2]),O=Math.ceil(s/V)},M=(s,a)=>{const o=e(b,p[3*s],p[3*s+1],p[3*s+2]),n=w;let h=s+a;do{e(n,p[3*h],p[3*h+1],p[3*h+2]),h+=a}while(t(o,n)&&h>=0&&h<m);i&&(r(o,o,i),r(n,n,i)),y(o,n,[-1,-1],s),y(o,n,[1,-1],s),y(o,n,[1,1],s),y(o,n,[-1,-1],s),y(o,n,[1,1],s),y(o,n,[-1,1],s)},C=this._parameters.placement;return"begin"!==C&&"begin-end"!==C||M(0,1),"end"!==C&&"begin-end"!==C||M(m-1,-1),null}}const b=i(),w=i();export{g as LineMarkerMaterial,v as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{h as t,n as e,e as r,f as s,C as o,p as i}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isColor as c}from"../core/shaderLibrary/ShaderOutput.js";import l from"../lib/GLMaterial.js";import{Material as u,MaterialParameters as p}from"../lib/Material.js";import{MeasurementArrowTechnique as h,layout as f}from"../shaders/MeasurementArrowTechnique.js";import{MeasurementArrowTechniqueConfiguration as m}from"../shaders/MeasurementArrowTechniqueConfiguration.js";import{alphaCutoff as g}from"../../../../webscene/support/AlphaCutoff.js";class d extends u{constructor(t){super(t,w),this._configuration=new m,this.intersectDraped=void 0,this.produces=new Map([[2,t=>!this._transparent&&c(t)],[8,t=>this._transparent&&c(t)]])}getConfiguration(t,e){return super.getConfiguration(t,e,this._configuration),this._configuration.polygonOffsetEnabled=this.parameters.polygonOffset,this._configuration.transparent=this._transparent,this._configuration.oitPass=e.oitPass,this._configuration}get visible(){const{outlineColor:t,stripeEvenColor:e,stripeOddColor:r}=this.parameters;return t[3]>=g||e[3]>=g||r[3]>=g}intersect(){}createGLMaterial(t){return new C(t)}createBufferWriter(){return new O}get _transparent(){const{parameters:t}=this;return t.outlineColor[3]<1||t.stripeEvenColor[3]<1||t.stripeOddColor[3]<1}}class C extends l{beginSlot(t){return this.getTechnique(h,t)}}class w extends p{constructor(){super(...arguments),this.width=32,this.outlineSize=.2,this.outlineColor=a(1,.5,0,1),this.stripeEvenColor=a(1,1,1,1),this.stripeOddColor=a(1,.5,0,1),this.stripeLength=1,this.polygonOffset=!1}}const _=n(),b=n(),j=n(),v=n(),M=n();class O{constructor(){this.layout=f}elementCount(t){return 2*(t.get("position").indices.length/2+1)}write(n,a,c,l,u,p){const{data:h,indices:f}=c.get("position"),m=c.get("normal").data,g=h.length/3;f&&f.length!==2*(g-1)&&console.warn("MeasurementArrowMaterial does not support indices");const d=_,C=b,w=j,O=v,x=M,y=u.position,A=u.normal,E=u.uv0;let L=0;for(let _=0;_<g;++_){const c=3*_;if(t(d,h[c],h[c+1],h[c+2]),_<g-1){const o=3*(_+1);t(C,h[o],h[o+1],h[o+2]),t(x,m[o],m[o+1],m[o+2]),e(x,x),r(w,C,d),e(w,w),s(O,x,w),e(O,O)}const l=o(d,C);n&&a&&(i(d,d,n),i(C,C,n),i(O,O,a));const u=p+2*_,f=u+1;y.setVec(u,d),y.setVec(f,d),A.setVec(u,O),A.setVec(f,O),E.set(u,0,L),E.set(u,1,-1),E.set(f,0,L),E.set(f,1,1),_<g-1&&(L+=l)}const V=u.length;for(let t=0;t<2*g;++t)V.set(p+t,L);return null}}export{d as MeasurementArrowMaterial,w as Parameters};
5
+ import{h as t,n as e,e as r,f as s,D as o,p as i}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isColor as c}from"../core/shaderLibrary/ShaderOutput.js";import l from"../lib/GLMaterial.js";import{Material as u,MaterialParameters as p}from"../lib/Material.js";import{MeasurementArrowTechnique as h,layout as f}from"../shaders/MeasurementArrowTechnique.js";import{MeasurementArrowTechniqueConfiguration as m}from"../shaders/MeasurementArrowTechniqueConfiguration.js";import{alphaCutoff as g}from"../../../../webscene/support/AlphaCutoff.js";class d extends u{constructor(t){super(t,w),this._configuration=new m,this.intersectDraped=void 0,this.produces=new Map([[2,t=>!this._transparent&&c(t)],[8,t=>this._transparent&&c(t)]])}getConfiguration(t,e){return super.getConfiguration(t,e,this._configuration),this._configuration.polygonOffsetEnabled=this.parameters.polygonOffset,this._configuration.transparent=this._transparent,this._configuration.oitPass=e.oitPass,this._configuration}get visible(){const{outlineColor:t,stripeEvenColor:e,stripeOddColor:r}=this.parameters;return t[3]>=g||e[3]>=g||r[3]>=g}intersect(){}createGLMaterial(t){return new C(t)}createBufferWriter(){return new O}get _transparent(){const{parameters:t}=this;return t.outlineColor[3]<1||t.stripeEvenColor[3]<1||t.stripeOddColor[3]<1}}class C extends l{beginSlot(t){return this.getTechnique(h,t)}}class w extends p{constructor(){super(...arguments),this.width=32,this.outlineSize=.2,this.outlineColor=a(1,.5,0,1),this.stripeEvenColor=a(1,1,1,1),this.stripeOddColor=a(1,.5,0,1),this.stripeLength=1,this.polygonOffset=!1}}const _=n(),b=n(),j=n(),v=n(),M=n();class O{constructor(){this.layout=f}elementCount(t){return 2*(t.get("position").indices.length/2+1)}write(n,a,c,l,u,p){const{data:h,indices:f}=c.get("position"),m=c.get("normal").data,g=h.length/3;f&&f.length!==2*(g-1)&&console.warn("MeasurementArrowMaterial does not support indices");const d=_,C=b,w=j,O=v,x=M,y=u.position,A=u.normal,E=u.uv0;let L=0;for(let _=0;_<g;++_){const c=3*_;if(t(d,h[c],h[c+1],h[c+2]),_<g-1){const o=3*(_+1);t(C,h[o],h[o+1],h[o+2]),t(x,m[o],m[o+1],m[o+2]),e(x,x),r(w,C,d),e(w,w),s(O,x,w),e(O,O)}const l=o(d,C);n&&a&&(i(d,d,n),i(C,C,n),i(O,O,a));const u=p+2*_,f=u+1;y.setVec(u,d),y.setVec(f,d),A.setVec(u,O),A.setVec(f,O),E.set(u,0,L),E.set(u,1,-1),E.set(f,0,L),E.set(f,1,1),_<g-1&&(L+=l)}const V=u.length;for(let t=0;t<2*g;++t)V.set(p+t,L);return null}}export{d as MeasurementArrowMaterial,w as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{copy as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{h as i,e as s,g as n,j as a,i as c,d as l,b as m,C as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as p}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{distance2 as h,fromPoints as g,create as d,closestLineSegmentPoint as j}from"../../../../geometry/support/lineSegment.js";import{fromPoints as b,create as x,signedDistance as L,getNormal as v}from"../../../../geometry/support/plane.js";import{isColorHighlightOrOID as y}from"../core/shaderLibrary/ShaderOutput.js";import S from"../lib/GLMaterial.js";import{Material as M,MaterialParameters as _}from"../lib/Material.js";import{isTranslationMatrix as w}from"../lib/Util.js";import{DefaultBufferWriter as C}from"./DefaultBufferWriter.js";import{PositionColorLayout as T,PositionLayout as A}from"./DefaultLayouts.js";import{NativeLineTechnique as V}from"../shaders/NativeLineTechnique.js";import{NativeLineTechniqueConfiguration as N}from"../shaders/NativeLineTechniqueConfiguration.js";import{alphaCutoff as R}from"../../../../webscene/support/AlphaCutoff.js";class U extends M{constructor(e){super(e,P),this._configuration=new N,this.produces=new Map([[2,e=>y(e)]])}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVertexColors=this.parameters.hasVertexColors,this._configuration.transparent=this.parameters.color[3]<1||this.parameters.width<1,this._configuration.hasOccludees=t.hasOccludees,this._configuration}get visible(){return this.parameters.color[3]>=R}intersect(t,r,f,p,d,x){const{options:y,camera:S,rayBegin:M,rayEnd:_}=f;if(!y.selectionMode||!t.visible||!S)return;if(!w(r))return void e.getLogger("esri.views.3d.webgl-engine.materials.NativeLineMaterial").error("intersection assumes a translation-only matrix");const C=t.attributes.get("position").data,T=H;o(T,f.point);const A=2;i(I[0],T[0]-A,T[1]+A,0),i(I[1],T[0]+A,T[1]+A,0),i(I[2],T[0]+A,T[1]-A,0),i(I[3],T[0]-A,T[1]-A,0);for(let e=0;e<4;e++)if(!S.unprojectFromRenderScreen(I[e],J[e]))return;b(S.eye,J[0],J[1],K),b(S.eye,J[1],J[2],Q),b(S.eye,J[2],J[3],Y),b(S.eye,J[3],J[0],Z);let V=Number.MAX_VALUE,N=0;for(let e=0;e<C.length-5;e+=3){if(q[0]=C[e]+r[12],q[1]=C[e+1]+r[13],q[2]=C[e+2]+r[14],B[0]=C[e+3]+r[12],B[1]=C[e+4]+r[13],B[2]=C[e+5]+r[14],L(K,q)<0&&L(K,B)<0||L(Q,q)<0&&L(Q,B)<0||L(Y,q)<0&&L(Y,B)<0||L(Z,q)<0&&L(Z,B)<0)continue;const t=S.projectToRenderScreen(q,W),o=S.projectToRenderScreen(B,X);if(null==t||null==o)continue;if(t[2]<0&&o[2]>0){s(D,q,B);const e=S.frustum,r=-L(e[4],q)/n(D,v(e[4]));if(a(D,D,r),c(q,q,D),!S.projectToRenderScreen(q,t))continue}else if(t[2]>0&&o[2]<0){s(D,B,q);const e=S.frustum,t=-L(e[4],B)/n(D,v(e[4]));if(a(D,D,t),c(B,B,D),!S.projectToRenderScreen(B,o))continue}else if(t[2]<0&&o[2]<0)continue;t[2]=0,o[2]=0;const i=h(g(t,o,z),T);i<V&&(V=i,l(G,q),l(k,B),N=e/3)}if(V<A*A){let e=Number.MAX_VALUE;if(j(g(G,k,z),g(M,_,F),O)){s(O,O,M);const t=m(O);a(O,O,1/t),e=t/u(M,_)}x(e,O,N)}}intersectDraped(e,r,o,i,s){if(!r.options.selectionMode)return;const n=e.attributes.get("position").data,a=e.attributes.get("size"),c=a?a.data[0]:0,l=o[0],m=o[1],u=((c+1)/2+4)*e.screenToWorldRatio;let f=Number.MAX_VALUE,p=0;for(let h=0;h<n.length-5;h+=3){const e=n[h],r=n[h+1],o=l-e,i=m-r,s=n[h+3]-e,a=n[h+4]-r,c=t((s*o+a*i)/(s*s+a*a),0,1),u=s*c-o,g=a*c-i,d=u*u+g*g;d<f&&(f=d,p=h/3)}f<u*u&&i(s.distance,s.normal,p)}createGLMaterial(e){return new E(e)}createBufferWriter(){const e=this.parameters.hasVertexColors?T:A;return new C(e)}}class E extends S{beginSlot(e){return this.getTechnique(V,e)}}class P extends _{constructor(){super(...arguments),this.color=p,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.width=1}}const q=f(),B=f(),D=f(),O=f(),W=r(),X=r(),G=f(),k=f(),z=d(),F=d(),H=f(),I=[r(),r(),r(),r()],J=[f(),f(),f(),f()],K=x(),Q=x(),Y=x(),Z=x();export{U as NativeLineMaterial,P as Parameters};
5
+ import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{copy as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{h as i,e as s,g as n,j as a,i as c,d as l,b as m,D as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as p}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{distance2 as h,fromPoints as g,create as d,closestLineSegmentPoint as j}from"../../../../geometry/support/lineSegment.js";import{fromPoints as b,create as x,signedDistance as L,getNormal as v}from"../../../../geometry/support/plane.js";import{isColorHighlightOrOID as y}from"../core/shaderLibrary/ShaderOutput.js";import S from"../lib/GLMaterial.js";import{Material as M,MaterialParameters as _}from"../lib/Material.js";import{isTranslationMatrix as w}from"../lib/Util.js";import{DefaultBufferWriter as C}from"./DefaultBufferWriter.js";import{PositionColorLayout as T,PositionLayout as A}from"./DefaultLayouts.js";import{NativeLineTechnique as V}from"../shaders/NativeLineTechnique.js";import{NativeLineTechniqueConfiguration as N}from"../shaders/NativeLineTechniqueConfiguration.js";import{alphaCutoff as R}from"../../../../webscene/support/AlphaCutoff.js";class U extends M{constructor(e){super(e,E),this._configuration=new N,this.produces=new Map([[2,e=>y(e)]])}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVertexColors=this.parameters.hasVertexColors,this._configuration.transparent=this.parameters.color[3]<1||this.parameters.width<1,this._configuration.hasOccludees=t.hasOccludees,this._configuration}get visible(){return this.parameters.color[3]>=R}intersect(t,r,f,p,d,x){const{options:y,camera:S,rayBegin:M,rayEnd:_}=f;if(!y.selectionMode||!t.visible||!S)return;if(!w(r))return void e.getLogger("esri.views.3d.webgl-engine.materials.NativeLineMaterial").error("intersection assumes a translation-only matrix");const C=t.attributes.get("position").data,T=H;o(T,f.point);const A=2;i(I[0],T[0]-A,T[1]+A,0),i(I[1],T[0]+A,T[1]+A,0),i(I[2],T[0]+A,T[1]-A,0),i(I[3],T[0]-A,T[1]-A,0);for(let e=0;e<4;e++)if(!S.unprojectFromRenderScreen(I[e],J[e]))return;b(S.eye,J[0],J[1],K),b(S.eye,J[1],J[2],Q),b(S.eye,J[2],J[3],Y),b(S.eye,J[3],J[0],Z);let V=Number.MAX_VALUE,N=0;for(let e=0;e<C.length-5;e+=3){if(P[0]=C[e]+r[12],P[1]=C[e+1]+r[13],P[2]=C[e+2]+r[14],q[0]=C[e+3]+r[12],q[1]=C[e+4]+r[13],q[2]=C[e+5]+r[14],L(K,P)<0&&L(K,q)<0||L(Q,P)<0&&L(Q,q)<0||L(Y,P)<0&&L(Y,q)<0||L(Z,P)<0&&L(Z,q)<0)continue;const t=S.projectToRenderScreen(P,W),o=S.projectToRenderScreen(q,X);if(null==t||null==o)continue;if(t[2]<0&&o[2]>0){s(B,P,q);const e=S.frustum,r=-L(e[4],P)/n(B,v(e[4]));if(a(B,B,r),c(P,P,B),!S.projectToRenderScreen(P,t))continue}else if(t[2]>0&&o[2]<0){s(B,q,P);const e=S.frustum,t=-L(e[4],q)/n(B,v(e[4]));if(a(B,B,t),c(q,q,B),!S.projectToRenderScreen(q,o))continue}else if(t[2]<0&&o[2]<0)continue;t[2]=0,o[2]=0;const i=h(g(t,o,z),T);i<V&&(V=i,l(G,P),l(k,q),N=e/3)}if(V<A*A){let e=Number.MAX_VALUE;if(j(g(G,k,z),g(M,_,F),O)){s(O,O,M);const t=m(O);a(O,O,1/t),e=t/u(M,_)}x(e,O,N)}}intersectDraped(e,r,o,i,s){if(!r.options.selectionMode)return;const n=e.attributes.get("position").data,a=e.attributes.get("size"),c=a?a.data[0]:0,l=o[0],m=o[1],u=((c+1)/2+4)*e.screenToWorldRatio;let f=Number.MAX_VALUE,p=0;for(let h=0;h<n.length-5;h+=3){const e=n[h],r=n[h+1],o=l-e,i=m-r,s=n[h+3]-e,a=n[h+4]-r,c=t((s*o+a*i)/(s*s+a*a),0,1),u=s*c-o,g=a*c-i,d=u*u+g*g;d<f&&(f=d,p=h/3)}f<u*u&&i(s.distance,s.normal,p)}createGLMaterial(e){return new D(e)}createBufferWriter(){const e=this.parameters.hasVertexColors?T:A;return new C(e)}}class D extends S{beginSlot(e){return this.getTechnique(V,e)}}class E extends _{constructor(){super(...arguments),this.color=p,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.width=1}}const P=f(),q=f(),B=f(),O=f(),W=r(),X=r(),G=f(),k=f(),z=d(),F=d(),H=f(),I=[r(),r(),r(),r()],J=[f(),f(),f(),f()],K=x(),Q=x(),Y=x(),Z=x();export{U as NativeLineMaterial,E as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../core/Logger.js";import{clamp as e}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as r}from"../../../../core/time.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{h as a,e as n,g as o,j as l,i as h,d as c,b as m,C as p,p as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as d}from"../../../../chunks/vec42.js";import{ONES as g,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as _}from"../../../../geometry/support/float16.js";import{distance2 as S,fromPoints as v,create as P,closestLineSegmentPoint as j}from"../../../../geometry/support/lineSegment.js";import{fromPoints as E,create as w,signedDistance as y,getNormal as T}from"../../../../geometry/support/plane.js";import{isHighlightOrOID as z,isColor as A,isDepth as C,isColorHighlightOIDOrDepth as O,is2DGeometryOutput as L}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as M}from"../effects/geometry/olidUtils.js";import V from"../lib/GLMaterial.js";import{Material as R}from"../lib/Material.js";import{isTranslationMatrix as x}from"../lib/Util.js";import{VisualVariablePassParameters as F}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as k}from"./internal/bufferWriterUtils.js";import{r as N}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as U,RibbonLineTechnique as D}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as B}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as W}from"../../../../webscene/support/AlphaCutoff.js";class J extends R{constructor(t,e){super(t,q),this.produces=new Map([[2,t=>z(t)||A(t)&&8===this.parameters.renderOccluded],[3,t=>C(t)],[10,t=>O(t)&&8===this.parameters.renderOccluded],[11,t=>O(t)&&8===this.parameters.renderOccluded],[4,t=>A(t)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[8,t=>A(t)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[18,t=>L(t)]]),this._configuration=new B(e)}getConfiguration(t,e){super.getConfiguration(t,e,this._configuration),this._configuration.oitPass=e.oitPass,this._configuration.draped=18===e.slot;const i=null!=this.parameters.stipplePattern&&8!==t;return this._configuration.stippleEnabled=i,this._configuration.stippleOffColorEnabled=i&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=i&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&H(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=e.hasOccludees,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.terrainDepthTest=e.terrainDepthTest&&A(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.hasEmissions?1:0,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration}get visible(){return this.parameters.color[3]>=W||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>W}setParameters(t,e){t.animation=this.parameters.animation,super.setParameters(t,e)}intersectDraped({attributes:t,screenToWorldRatio:i},r,s,a,n){if(!r.options.selectionMode)return;const o=t.get("size");let l=this.parameters.width;if(this.parameters.vvSize){const i=t.get("sizeFeatureAttribute").data[0];Number.isNaN(i)?l*=this.parameters.vvSize.fallback[0]:l*=e(this.parameters.vvSize.offset[0]+i*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else o&&(l*=o.data[0]);const h=s[0],c=s[1],m=(l/2+4)*i;let p=Number.MAX_VALUE,u=0;const f=t.get("position").data,d=I(this.parameters,t)?f.length-2:f.length-5;for(let g=0;g<d;g+=3){const t=f[g],i=f[g+1],r=(g+3)%f.length,s=h-t,a=c-i,n=f[r]-t,o=f[r+1]-i,l=e((n*s+o*a)/(n*n+o*o),0,1),m=n*l-s,d=o*l-a,b=m*m+d*d;b<p&&(p=b,u=g/3)}p<m*m&&a(n.distance,n.normal,u)}intersect(i,r,u,f,d,g){const{options:b,camera:_,rayBegin:P,rayEnd:w}=u;if(!b.selectionMode||!i.visible||!_)return;if(!x(r))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const z=i.attributes,A=z.get("position").data;let C=this.parameters.width;if(this.parameters.vvSize){const t=z.get("sizeFeatureAttribute").data[0];Number.isNaN(t)||(C*=e(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else z.has("size")&&(C*=z.get("size").data[0]);const O=tt;s(O,u.point);const L=C*_.pixelRatio/2+4*_.pixelRatio;a(mt[0],O[0]-L,O[1]+L,0),a(mt[1],O[0]+L,O[1]+L,0),a(mt[2],O[0]+L,O[1]-L,0),a(mt[3],O[0]-L,O[1]-L,0);for(let t=0;t<4;t++)if(!_.unprojectFromRenderScreen(mt[t],pt[t]))return;E(_.eye,pt[0],pt[1],ut),E(_.eye,pt[1],pt[2],ft),E(_.eye,pt[2],pt[3],dt),E(_.eye,pt[3],pt[0],gt);let M=Number.MAX_VALUE,V=0;const R=I(this.parameters,z)?A.length-2:A.length-5;for(let t=0;t<R;t+=3){K[0]=A[t]+r[12],K[1]=A[t+1]+r[13],K[2]=A[t+2]+r[14];const e=(t+3)%A.length;if(Q[0]=A[e]+r[12],Q[1]=A[e+1]+r[13],Q[2]=A[e+2]+r[14],y(ut,K)<0&&y(ut,Q)<0||y(ft,K)<0&&y(ft,Q)<0||y(dt,K)<0&&y(dt,Q)<0||y(gt,K)<0&&y(gt,Q)<0)continue;const i=_.projectToRenderScreen(K,et),s=_.projectToRenderScreen(Q,it);if(null==i||null==s)continue;if(i[2]<0&&s[2]>0){n(Z,K,Q);const t=_.frustum,e=-y(t[4],K)/o(Z,T(t[4]));if(l(Z,Z,e),h(K,K,Z),!_.projectToRenderScreen(K,i))continue}else if(i[2]>0&&s[2]<0){n(Z,Q,K);const t=_.frustum,e=-y(t[4],Q)/o(Z,T(t[4]));if(l(Z,Z,e),h(Q,Q,Z),!_.projectToRenderScreen(Q,s))continue}else if(i[2]<0&&s[2]<0)continue;i[2]=0,s[2]=0;const a=S(v(i,s,at),O);a<M&&(M=a,c(rt,K),c(st,Q),V=t/3)}if(M<L*L){let t=Number.MAX_VALUE;if(j(v(rt,st,at),v(P,w,nt),$)){n($,$,P);const e=m($);l($,$,1/e),t=e/p(P,w)}g(t,$,V)}}get hasEmissions(){return this.parameters.emissiveStrength>0}createBufferWriter(){return new X(U(this.parameters),this.parameters)}createGLMaterial(t){return new Y(t)}validateParameters(t){"miter"!==t.join&&(t.miterLimit=0),null!=t.markerParameters&&(t.markerScale=t.markerParameters.width/t.width)}update(t){return!!this.parameters.hasAnimation&&(this.setParameters({timeElapsed:r(t.time)},!1),0!==t.dt)}}class Y extends V{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(t){const e=this._material.parameters.stipplePattern;return this._stipplePattern!==e&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(e,this._stipplePattern)}),this._stipplePattern=e),this.getTechnique(D,t)}}class q extends F{constructor(){super(...arguments),this.width=0,this.color=g,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=0,this.animation=0,this.animationSpeed=1,this.trailLength=1,this.startTime=0,this.endTime=1/0,this.fadeInTime=0,this.fadeOutTime=1/0,this.emissiveStrength=0}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}}class X{constructor(t,e){this.layout=t,this._parameters=e;const i=e.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=i;break;case"round":this.numJoinSubdivisions=N+i}}_isClosed(t){return I(this._parameters,t)}allocate(t){return this.layout.createBuffer(t)}elementCount(t){const e=2,i=t.get("position").indices.length/2+1,r=this._isClosed(t);let s=r?2:2*e;return s+=((r?i:i-1)-(r?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,e,i,r,s,n){const o=this.layout,l=i.get("position"),h=l.indices,m=l.data.length/3,f=i.get("distanceToStart")?.data;h&&h.length!==2*(m-1)&&console.warn("RibbonLineMaterial does not support indices");const g=o.fields.has("sizeFeatureAttribute");let b=1,S=null;if(g){const t=i.get("sizeFeatureAttribute");1===t.data.length?b=t.data[0]:S=t.data}else b=i.get("size")?.data[0]??1;let v=[1,1,1,1],P=0,j=null;const E=o.fields.has("colorFeatureAttribute");if(E){const t=i.get("colorFeatureAttribute");1===t.data.length?P=t.data[0]:j=t.data}else v=i.get("color")?.data??v;const w=i.get("timeStamps")?.data,y=w&&o.fields.has("timeStamps"),T=o.fields.has("opacityFeatureAttribute");let z=0,A=null;if(T){const t=i.get("opacityFeatureAttribute");1===t.data.length?z=t.data[0]:A=t.data}const C=new Float32Array(s.buffer),O=_(s.buffer),L=new Uint8Array(s.buffer),V=o.stride/4;let R=n*V;const x=R;let F=0;const N=f?(t,e,i)=>F=f[i]:(t,e,i)=>F+=p(t,e),U=C.BYTES_PER_ELEMENT/O.BYTES_PER_ELEMENT,D=4/U,B=M(),W=(t,e,i,s,a,n,o,l)=>{C[R++]=e[0],C[R++]=e[1],C[R++]=e[2],k(t,e,O,R*U),R+=D,k(i,e,O,R*U),R+=D,C[R++]=l;let h=R*U;if(O[h++]=a,O[h++]=n,R=Math.ceil(h/U),E)C[R]=j?.[o]??P;else{const t=Math.min(4*o,v.length-4),e=4*R;L[e]=255*v[t],L[e+1]=255*v[t+1],L[e+2]=255*v[t+2],L[e+3]=255*v[t+3]}if(R++,C[R++]=S?.[o]??b,T&&(C[R++]=A?.[o]??z),B){let t=4*R;r?(L[t++]=r[0],L[t++]=r[1],L[t++]=r[2],L[t++]=r[3]):(L[t++]=0,L[t++]=0,L[t++]=0,L[t++]=0),R=Math.ceil(.25*t)}y&&(h=R*U,O[h++]=s[0],O[h++]=s[1],O[h++]=s[2],O[h++]=s[3],R=Math.ceil(h/U))};R+=V,a(lt,l.data[0],l.data[1],l.data[2]),y&&d(ct,w[0],w[1],w[2],w[3]),t&&u(lt,lt,t);const J=this._isClosed(i);if(J){const e=l.data.length-3;a(ot,l.data[e],l.data[e+1],l.data[e+2]),t&&u(ot,ot,t)}else a(ht,l.data[3],l.data[4],l.data[5]),t&&u(ht,ht,t),W(lt,lt,ht,ct,1,-4,0,0),W(lt,lt,ht,ct,1,4,0,0),c(ot,lt),c(lt,ht),y&&d(ct,w[4],w[5],w[6],w[7]);const Y=J?0:1,q=J?m:m-1;for(let p=Y;p<q;p++){const e=(p+1)%m*3;a(ht,l.data[e],l.data[e+1],l.data[e+2]),t&&u(ht,ht,t),N(ot,lt,p),W(ot,lt,ht,ct,0,-1,p,F),W(ot,lt,ht,ct,0,1,p,F);const i=this.numJoinSubdivisions;for(let t=0;t<i;++t){const e=(t+1)/(i+1);W(ot,lt,ht,ct,e,-1,p,F),W(ot,lt,ht,ct,e,1,p,F)}if(W(ot,lt,ht,ct,1,-2,p,F),W(ot,lt,ht,ct,1,2,p,F),c(ot,lt),c(lt,ht),y){const t=(p+1)%m*4;d(ct,w[t],w[t+1],w[t+2],w[t+3])}}J?(a(ht,l.data[3],l.data[4],l.data[5]),t&&u(ht,ht,t),F=N(ot,lt,q),W(ot,lt,ht,ct,0,-1,Y,F),W(ot,lt,ht,ct,0,1,Y,F)):(F=N(ot,lt,q),W(ot,lt,lt,ct,0,-5,q,F),W(ot,lt,lt,ct,0,5,q,F)),G(C,x+V,C,x,V);return R=G(C,R-V,C,R,V),this._parameters.wireframe&&this._addWireframeVertices(s,x,R,V),null}_addWireframeVertices(t,e,i,r){const s=new Float32Array(t.buffer,i*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(t.buffer,e*Float32Array.BYTES_PER_ELEMENT,i-e);let n=0;const o=t=>n=G(a,t,s,n,r);for(let l=0;l<a.length-1;l+=2*r)o(l),o(l+2*r),o(l+1*r),o(l+2*r),o(l+1*r),o(l+3*r)}}function G(t,e,i,r,s){for(let a=0;a<s;a++)i[r++]=t[e++];return r}function I(t,e){if(!t.isClosed)return!1;return e.get("position").indices.length>2}function H(t){return 1===t.anchor&&t.hideOnShortSegments&&"begin-end"===t.placement&&t.worldSpace}const K=f(),Q=f(),Z=f(),$=f(),tt=f(),et=i(),it=i(),rt=f(),st=f(),at=P(),nt=P(),ot=f(),lt=f(),ht=f(),ct=b(),mt=[i(),i(),i(),i()],pt=[f(),f(),f(),f()],ut=w(),ft=w(),dt=w(),gt=w();export{q as Parameters,J as RibbonLineMaterial};
5
+ import t from"../../../../core/Logger.js";import{clamp as e}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as i}from"../../../../core/screenUtils.js";import{secondsFromMilliseconds as r}from"../../../../core/time.js";import{copy as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{h as a,e as n,g as o,j as l,i as h,d as c,b as m,D as p,p as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as d}from"../../../../chunks/vec42.js";import{ONES as g,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{makeFloat16Array as _}from"../../../../geometry/support/float16.js";import{distance2 as S,fromPoints as v,create as P,closestLineSegmentPoint as j}from"../../../../geometry/support/lineSegment.js";import{fromPoints as E,create as w,signedDistance as y,getNormal as T}from"../../../../geometry/support/plane.js";import{isHighlightOrOID as z,isColor as A,isDepth as C,isColorHighlightOIDOrDepth as O,is2DGeometryOutput as L}from"../core/shaderLibrary/ShaderOutput.js";import{olidEnabled as M}from"../effects/geometry/olidUtils.js";import V from"../lib/GLMaterial.js";import{Material as R}from"../lib/Material.js";import{isTranslationMatrix as x}from"../lib/Util.js";import{VisualVariablePassParameters as F}from"./VisualVariablePassParameters.js";import{writeDeltaF16Vector as k}from"./internal/bufferWriterUtils.js";import{r as N}from"../../../../chunks/RibbonLine.glsl.js";import{getLayout as U,RibbonLineTechnique as D}from"../shaders/RibbonLineTechnique.js";import{RibbonLineTechniqueConfiguration as B}from"../shaders/RibbonLineTechniqueConfiguration.js";import{alphaCutoff as W}from"../../../../webscene/support/AlphaCutoff.js";class J extends R{constructor(t,e){super(t,q),this.produces=new Map([[2,t=>z(t)||A(t)&&8===this.parameters.renderOccluded],[3,t=>C(t)],[10,t=>O(t)&&8===this.parameters.renderOccluded],[11,t=>O(t)&&8===this.parameters.renderOccluded],[4,t=>A(t)&&this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[8,t=>A(t)&&!this.parameters.writeDepth&&8!==this.parameters.renderOccluded],[18,t=>L(t)]]),this._configuration=new B(e)}getConfiguration(t,e){super.getConfiguration(t,e,this._configuration),this._configuration.oitPass=e.oitPass,this._configuration.draped=18===e.slot;const i=null!=this.parameters.stipplePattern&&8!==t;return this._configuration.stippleEnabled=i,this._configuration.stippleOffColorEnabled=i&&null!=this.parameters.stippleOffColor,this._configuration.stipplePreferContinuous=i&&this.parameters.stipplePreferContinuous,this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.roundJoins="round"===this.parameters.join,this._configuration.capType=this.parameters.cap,this._configuration.applyMarkerOffset=null!=this.parameters.markerParameters&&H(this.parameters.markerParameters),this._configuration.hasPolygonOffset=this.parameters.hasPolygonOffset,this._configuration.writeDepth=this.parameters.writeDepth,this._configuration.hasVVSize=this.parameters.hasVVSize,this._configuration.hasVVColor=this.parameters.hasVVColor,this._configuration.hasVVOpacity=this.parameters.hasVVOpacity,this._configuration.innerColorEnabled=this.parameters.innerWidth>0&&null!=this.parameters.innerColor,this._configuration.falloffEnabled=this.parameters.falloff>0,this._configuration.hasOccludees=e.hasOccludees,this._configuration.occluder=8===this.parameters.renderOccluded,this._configuration.terrainDepthTest=e.terrainDepthTest&&A(t),this._configuration.cullAboveTerrain=e.cullAboveTerrain,this._configuration.wireframe=this.parameters.wireframe,this._configuration.animation=this.parameters.animation,this._configuration.emissionSource=this.hasEmissions?1:0,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration}get visible(){return this.parameters.color[3]>=W||null!=this.parameters.stipplePattern&&(this.parameters.stippleOffColor?.[3]??0)>W}setParameters(t,e){t.animation=this.parameters.animation,super.setParameters(t,e)}intersectDraped({attributes:t,screenToWorldRatio:i},r,s,a,n){if(!r.options.selectionMode)return;const o=t.get("size");let l=this.parameters.width;if(this.parameters.vvSize){const i=t.get("sizeFeatureAttribute").data[0];Number.isNaN(i)?l*=this.parameters.vvSize.fallback[0]:l*=e(this.parameters.vvSize.offset[0]+i*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0])}else o&&(l*=o.data[0]);const h=s[0],c=s[1],m=(l/2+4)*i;let p=Number.MAX_VALUE,u=0;const f=t.get("position").data,d=I(this.parameters,t)?f.length-2:f.length-5;for(let g=0;g<d;g+=3){const t=f[g],i=f[g+1],r=(g+3)%f.length,s=h-t,a=c-i,n=f[r]-t,o=f[r+1]-i,l=e((n*s+o*a)/(n*n+o*o),0,1),m=n*l-s,d=o*l-a,b=m*m+d*d;b<p&&(p=b,u=g/3)}p<m*m&&a(n.distance,n.normal,u)}intersect(i,r,u,f,d,g){const{options:b,camera:_,rayBegin:P,rayEnd:w}=u;if(!b.selectionMode||!i.visible||!_)return;if(!x(r))return void t.getLogger("esri.views.3d.webgl-engine.materials.RibbonLineMaterial").error("intersection assumes a translation-only matrix");const z=i.attributes,A=z.get("position").data;let C=this.parameters.width;if(this.parameters.vvSize){const t=z.get("sizeFeatureAttribute").data[0];Number.isNaN(t)||(C*=e(this.parameters.vvSize.offset[0]+t*this.parameters.vvSize.factor[0],this.parameters.vvSize.minSize[0],this.parameters.vvSize.maxSize[0]))}else z.has("size")&&(C*=z.get("size").data[0]);const O=tt;s(O,u.point);const L=C*_.pixelRatio/2+4*_.pixelRatio;a(mt[0],O[0]-L,O[1]+L,0),a(mt[1],O[0]+L,O[1]+L,0),a(mt[2],O[0]+L,O[1]-L,0),a(mt[3],O[0]-L,O[1]-L,0);for(let t=0;t<4;t++)if(!_.unprojectFromRenderScreen(mt[t],pt[t]))return;E(_.eye,pt[0],pt[1],ut),E(_.eye,pt[1],pt[2],ft),E(_.eye,pt[2],pt[3],dt),E(_.eye,pt[3],pt[0],gt);let M=Number.MAX_VALUE,V=0;const R=I(this.parameters,z)?A.length-2:A.length-5;for(let t=0;t<R;t+=3){K[0]=A[t]+r[12],K[1]=A[t+1]+r[13],K[2]=A[t+2]+r[14];const e=(t+3)%A.length;if(Q[0]=A[e]+r[12],Q[1]=A[e+1]+r[13],Q[2]=A[e+2]+r[14],y(ut,K)<0&&y(ut,Q)<0||y(ft,K)<0&&y(ft,Q)<0||y(dt,K)<0&&y(dt,Q)<0||y(gt,K)<0&&y(gt,Q)<0)continue;const i=_.projectToRenderScreen(K,et),s=_.projectToRenderScreen(Q,it);if(null==i||null==s)continue;if(i[2]<0&&s[2]>0){n(Z,K,Q);const t=_.frustum,e=-y(t[4],K)/o(Z,T(t[4]));if(l(Z,Z,e),h(K,K,Z),!_.projectToRenderScreen(K,i))continue}else if(i[2]>0&&s[2]<0){n(Z,Q,K);const t=_.frustum,e=-y(t[4],Q)/o(Z,T(t[4]));if(l(Z,Z,e),h(Q,Q,Z),!_.projectToRenderScreen(Q,s))continue}else if(i[2]<0&&s[2]<0)continue;i[2]=0,s[2]=0;const a=S(v(i,s,at),O);a<M&&(M=a,c(rt,K),c(st,Q),V=t/3)}if(M<L*L){let t=Number.MAX_VALUE;if(j(v(rt,st,at),v(P,w,nt),$)){n($,$,P);const e=m($);l($,$,1/e),t=e/p(P,w)}g(t,$,V)}}get hasEmissions(){return this.parameters.emissiveStrength>0}createBufferWriter(){return new X(U(this.parameters),this.parameters)}createGLMaterial(t){return new Y(t)}validateParameters(t){"miter"!==t.join&&(t.miterLimit=0),null!=t.markerParameters&&(t.markerScale=t.markerParameters.width/t.width)}update(t){return!!this.parameters.hasAnimation&&(this.setParameters({timeElapsed:r(t.time)},!1),0!==t.dt)}}class Y extends V{constructor(){super(...arguments),this._stipplePattern=null}dispose(){super.dispose(),this._stippleTextures?.release(this._stipplePattern),this._stipplePattern=null}beginSlot(t){const e=this._material.parameters.stipplePattern;return this._stipplePattern!==e&&(this._material.setParameters({stippleTexture:this._stippleTextures.swap(e,this._stipplePattern)}),this._stipplePattern=e),this.getTechnique(D,t)}}class q extends F{constructor(){super(...arguments),this.width=0,this.color=g,this.join="miter",this.cap=0,this.miterLimit=5,this.writeDepth=!0,this.hasPolygonOffset=!1,this.stippleTexture=null,this.stipplePreferContinuous=!0,this.markerParameters=null,this.markerScale=1,this.hasSlicePlane=!1,this.vvFastUpdate=!1,this.isClosed=!1,this.falloff=0,this.innerWidth=0,this.wireframe=!1,this.timeElapsed=0,this.animation=0,this.animationSpeed=1,this.trailLength=1,this.startTime=0,this.endTime=1/0,this.fadeInTime=0,this.fadeOutTime=1/0,this.emissiveStrength=0}get transparent(){return this.color[3]<1||this.hasAnimation||null!=this.stipplePattern&&(this.stippleOffColor?.[3]??0)<1}get hasAnimation(){return 0!==this.animation}}class X{constructor(t,e){this.layout=t,this._parameters=e;const i=e.stipplePattern?1:0;switch(this._parameters.join){case"miter":case"bevel":this.numJoinSubdivisions=i;break;case"round":this.numJoinSubdivisions=N+i}}_isClosed(t){return I(this._parameters,t)}allocate(t){return this.layout.createBuffer(t)}elementCount(t){const e=2,i=t.get("position").indices.length/2+1,r=this._isClosed(t);let s=r?2:2*e;return s+=((r?i:i-1)-(r?0:1))*(2*this.numJoinSubdivisions+4),s+=2,this._parameters.wireframe&&(s=2+4*(s-2)),s}write(t,e,i,r,s,n){const o=this.layout,l=i.get("position"),h=l.indices,m=l.data.length/3,f=i.get("distanceToStart")?.data;h&&h.length!==2*(m-1)&&console.warn("RibbonLineMaterial does not support indices");const g=o.fields.has("sizeFeatureAttribute");let b=1,S=null;if(g){const t=i.get("sizeFeatureAttribute");1===t.data.length?b=t.data[0]:S=t.data}else b=i.get("size")?.data[0]??1;let v=[1,1,1,1],P=0,j=null;const E=o.fields.has("colorFeatureAttribute");if(E){const t=i.get("colorFeatureAttribute");1===t.data.length?P=t.data[0]:j=t.data}else v=i.get("color")?.data??v;const w=i.get("timeStamps")?.data,y=w&&o.fields.has("timeStamps"),T=o.fields.has("opacityFeatureAttribute");let z=0,A=null;if(T){const t=i.get("opacityFeatureAttribute");1===t.data.length?z=t.data[0]:A=t.data}const C=new Float32Array(s.buffer),O=_(s.buffer),L=new Uint8Array(s.buffer),V=o.stride/4;let R=n*V;const x=R;let F=0;const N=f?(t,e,i)=>F=f[i]:(t,e,i)=>F+=p(t,e),U=C.BYTES_PER_ELEMENT/O.BYTES_PER_ELEMENT,D=4/U,B=M(),W=(t,e,i,s,a,n,o,l)=>{C[R++]=e[0],C[R++]=e[1],C[R++]=e[2],k(t,e,O,R*U),R+=D,k(i,e,O,R*U),R+=D,C[R++]=l;let h=R*U;if(O[h++]=a,O[h++]=n,R=Math.ceil(h/U),E)C[R]=j?.[o]??P;else{const t=Math.min(4*o,v.length-4),e=4*R;L[e]=255*v[t],L[e+1]=255*v[t+1],L[e+2]=255*v[t+2],L[e+3]=255*v[t+3]}if(R++,C[R++]=S?.[o]??b,T&&(C[R++]=A?.[o]??z),B){let t=4*R;r?(L[t++]=r[0],L[t++]=r[1],L[t++]=r[2],L[t++]=r[3]):(L[t++]=0,L[t++]=0,L[t++]=0,L[t++]=0),R=Math.ceil(.25*t)}y&&(h=R*U,O[h++]=s[0],O[h++]=s[1],O[h++]=s[2],O[h++]=s[3],R=Math.ceil(h/U))};R+=V,a(lt,l.data[0],l.data[1],l.data[2]),y&&d(ct,w[0],w[1],w[2],w[3]),t&&u(lt,lt,t);const J=this._isClosed(i);if(J){const e=l.data.length-3;a(ot,l.data[e],l.data[e+1],l.data[e+2]),t&&u(ot,ot,t)}else a(ht,l.data[3],l.data[4],l.data[5]),t&&u(ht,ht,t),W(lt,lt,ht,ct,1,-4,0,0),W(lt,lt,ht,ct,1,4,0,0),c(ot,lt),c(lt,ht),y&&d(ct,w[4],w[5],w[6],w[7]);const Y=J?0:1,q=J?m:m-1;for(let p=Y;p<q;p++){const e=(p+1)%m*3;a(ht,l.data[e],l.data[e+1],l.data[e+2]),t&&u(ht,ht,t),N(ot,lt,p),W(ot,lt,ht,ct,0,-1,p,F),W(ot,lt,ht,ct,0,1,p,F);const i=this.numJoinSubdivisions;for(let t=0;t<i;++t){const e=(t+1)/(i+1);W(ot,lt,ht,ct,e,-1,p,F),W(ot,lt,ht,ct,e,1,p,F)}if(W(ot,lt,ht,ct,1,-2,p,F),W(ot,lt,ht,ct,1,2,p,F),c(ot,lt),c(lt,ht),y){const t=(p+1)%m*4;d(ct,w[t],w[t+1],w[t+2],w[t+3])}}J?(a(ht,l.data[3],l.data[4],l.data[5]),t&&u(ht,ht,t),F=N(ot,lt,q),W(ot,lt,ht,ct,0,-1,Y,F),W(ot,lt,ht,ct,0,1,Y,F)):(F=N(ot,lt,q),W(ot,lt,lt,ct,0,-5,q,F),W(ot,lt,lt,ct,0,5,q,F)),G(C,x+V,C,x,V);return R=G(C,R-V,C,R,V),this._parameters.wireframe&&this._addWireframeVertices(s,x,R,V),null}_addWireframeVertices(t,e,i,r){const s=new Float32Array(t.buffer,i*Float32Array.BYTES_PER_ELEMENT),a=new Float32Array(t.buffer,e*Float32Array.BYTES_PER_ELEMENT,i-e);let n=0;const o=t=>n=G(a,t,s,n,r);for(let l=0;l<a.length-1;l+=2*r)o(l),o(l+2*r),o(l+1*r),o(l+2*r),o(l+1*r),o(l+3*r)}}function G(t,e,i,r,s){for(let a=0;a<s;a++)i[r++]=t[e++];return r}function I(t,e){if(!t.isClosed)return!1;return e.get("position").indices.length>2}function H(t){return 1===t.anchor&&t.hideOnShortSegments&&"begin-end"===t.placement&&t.worldSpace}const K=f(),Q=f(),Z=f(),$=f(),tt=f(),et=i(),it=i(),rt=f(),st=f(),at=P(),nt=P(),ot=f(),lt=f(),ht=f(),ct=b(),mt=[i(),i(),i(),i()],pt=[f(),f(),f(),f()],ut=w(),ft=w(),dt=w(),gt=w();export{q as Parameters,J as RibbonLineMaterial};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as n,filterInPlace as s}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{getOrCreateMapValue as r}from"../../../../../core/MapUtils.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{nullUid as i}from"../../../../../core/uid.js";import{property as l,subclass as c}from"../../../../../core/accessorSupport/decorators.js";import{assert as d}from"../../lib/Util.js";import{BufferRange as u,mergeAdjacentRanges as f}from"./BufferRange.js";import{Instance as h}from"./Instance.js";import{PerBaseInstanceData as m}from"./PerBaseInstanceData.js";import{PerBufferData as p,getTargetBuffer as g,hasVao as y}from"./PerBufferData.js";import{PerOriginData as v}from"./PerOriginData.js";import{VaoWriter as _}from"./VaoWriter.js";let B=class extends t{constructor(e){super(e),this._vaoWriter=null,this._useMetalWorkaround=!1,this._hasOccludees=!1}destroy(){this.uninitializeRenderContext()}initializeRenderContext(e){this._useMetalWorkaround=e.renderContext.rctx.isAssumedMetalDriver,this._vaoWriter=new _(this.material,e.renderContext.rctx)}uninitializeRenderContext(){this._useMetalWorkaround=!1,this._vaoWriter=null}get hasOccludees(){return this._hasOccludees}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())if(t.buffers.some(e=>e.holes.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const s of this.dataByBaseInstance.values())for(const r of s.dataByOrigin.values()){const o=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const s=r.buffers[t];s.holes.length<=1?++t:(s.instances.forEach(({geometry:e})=>o.push(e)),this._vaoWriter?.deleteBuffer(s),n(r.buffers,s,void 0,{last:t}),e.madeProgress())}if(o.length>0){const{baseInstanceData:e}=s;r.buffers.forEach(t=>this._applyAdds(e,t,o));const n=g(null!=e);for(;o.length>0;)r.buffers.push(this._applyAndRebuild(e,new p(n),o,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e;for(const t of this.dataByBaseInstance.values())for(const n of t.dataByOrigin.values())for(const t of n.buffers)t.updateHighlights(e)}_applyUpdates(e,t){const s=this._vaoWriter;if(null==s)return void e.clearUpdates();let r;const o=this._useMetalWorkaround?(e,t)=>{r??=new Map;let n=r.get(t);n||(n=[],r.set(t,n)),n.push(e)}:(e,t)=>s.updateInstance(e,t);for(const a of e.updates){if(t.done)return;const{renderGeometry:s,updateType:r}=a;n(e.pending.updates,a),t.madeProgress();const l=this.dataByBaseInstance.get(s.geometry.baseGeometry?.id??i),c=l?.dataByOrigin.get(s.localOrigin.id)?.findBuffer(s.id);if(null==c)return;const d=c.instances.get(s.id);6&r&&o(d,c),25&r&&(c.drawCommandsDirty=!0)}r&&s.updateInstancesMetal(r)}_computeDeltas(e,t){const n=new Map;for(const s of e){const e=s.localOrigin;if(null==e)continue;const t=s.geometry.baseGeometry,o=r(n,t??null,M);let a=o.get(e,null);null==a&&(a=new b(e.vec3,t),o.set(e,null,a)),a.changes.push(s)}for(const s of t){const e=s.localOrigin;if(null==e)continue;const t=s.geometry.baseGeometry,o=this.dataByBaseInstance.get(t?.id??i),a=o?.dataByOrigin.get(e.id)?.findBuffer(s.id);if(null==a)continue;const l=r(n,t??null,M);let c=l.get(e,a);null==c&&(c=new b(e.vec3,t),l.set(e,a,c)),c.changes.push(s)}return n}_applyAddsAndRemoves(e){const{_vaoWriter:t,dataByBaseInstance:s}=this;if(null==t)return void e.clearAddsAndRemoves();const o=this._computeDeltas(e.adds,e.removes);for(const[a,l]of o){const e=r(s,a?.id??i,()=>new m(t.createBaseInstanceData(a))),o=null!=a;for(const[s,a]of l.outerMap()){const i=a.get(null),c=i?.changes??[];l.delete(s,null);const u=r(e.dataByOrigin,s.id,()=>new v(s.vec3,o));for(const[r,o]of a){if(l.delete(s,r),null==r&&d(!1,"No VAO for removed geometries"),r.instances.size===o.changes.length){t.deleteBuffer(r),n(u.buffers,r),0===u.buffers.length&&0===c.length&&e.dataByOrigin.delete(s.id);continue}const a=r.numElements;switch(t.evaluateBufferAllocation(a,c,o.changes,r)){case 0:o.changes.forEach(({id:e})=>r.deleteInstance(e)),r.instances.forEach(({geometry:e})=>c.push(e)),t.deleteBuffer(r),n(u.buffers,r);break;case 1:this._applyAndRebuild(e.baseInstanceData,r,c,o);break;case 2:this._applyRemoves(r,o)}}if(c.length>0){const{baseInstanceData:t}=e,n=g(o);for(const e of u.buffers)this._applyAdds(t,e,c);for(;c.length>0;)u.buffers.push(this._applyAndRebuild(t,new p(n),c,null))}}0===e.dataByOrigin.size&&(e.dispose(),s.delete(e.id))}e.clearAddsAndRemoves()}_updateDrawCommands(){this._hasOccludees=!1;for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())for(const e of t.buffers)e.updateIfDrawCommandsDirty(this.highlightOrderMap),this._hasOccludees||=e.hasOccludees}_applyAndRebuild(e,t,n,s){if(s)for(const c of s.changes)t.deleteInstance(c.id);const r=this._vaoWriter,o=r.maxElements(t.targetBuffer);let a=t.numElements;for(;n.length>0;){const e=n.pop(),s=r.elementCount(e.geometry);if(a+s>o&&a>0){n.push(e);break}a+=s;const i=new h(e,0,0,this.highlightOrderMap);d(null==t.instances.get(e.id)),t.addInstance(e.id,i)}t.resetInstanceSummary(),t.vao=r.reallocateBuffer(e,t,a),t.vaoEndElement=r.endElement(t);const i=r.rebuildInstances(a,t.writeableInstances.values(),t);t.updateInstances(),t.holes.clear();const l=t.holes.pushNew();return l.from=i,l.to=t.vaoEndElement,t.updateDrawCommands(this.highlightOrderMap),t}_applyRemoves(e,t){const{_vaoWriter:n}=this;if(0===t.changes.length||null==n)return;let s=1/0,r=-1/0;for(const o of t.changes){const t=o.id,n=e.instances.get(t);if(!n)continue;e.deleteInstance(t),this._useMetalWorkaround&&(s=Math.min(s,n.from),r=Math.max(r,n.to));const a=I.back();if(a){if(a.to===n.from){a.to=n.to;continue}if(a.from===n.to){a.from=n.from;continue}}const i=I.pushNew();i.from=n.from,i.to=n.to}f(I),this._useMetalWorkaround?n.clearHolesMetal(e.instances.values(),s,r,e):n.clearHoles(I,e),e.holes.pushArray(I.data,I.length),I.forAll((e,t)=>I.data[t]=null),I.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t,n){if(0===n.length||null==this._vaoWriter)return;if(!y(t))return void this._applyAndRebuild(e,t,n,null);const r=this._vaoWriter,o=t.numElements,a=n.reduce((e,{geometry:t})=>e+r.elementCount(t),0),i=Math.min(o+a,r.maxElements(t.targetBuffer));if(r.canGrow(t,i))return void this._applyAndRebuild(e,t,n,null);f(t.holes);const l=new Array;let c=1/0,d=-1/0;for(const{geometry:s}of n){const e=r.elementCount(s),n=w(t.holes,e);l.push(n),this._useMetalWorkaround&&null!=n&&(c=Math.min(n,c),d=Math.max(n+e,d))}const u=this._addInstances(n,t,l);if(this._useMetalWorkaround){for(const e of u);r.writeInstanceRangeMetal(d,c,t.instances.values(),t)}else r.writeRandomInstances(i,u,t);s(n,(e,t)=>null==l[t])}*_addInstances(e,t,n){const s=e.length,r=this._vaoWriter;for(let o=0;o<s;++o){const s=n[o];if(null==s)continue;const a=e[o],i=r.elementCount(a.geometry),l=new h(a,s,s+i,this.highlightOrderMap);d(null==t.instances.get(a.id)),t.addInstance(a.id,l),t.drawCommandsDirty=!0,yield l}}static prune(){_.prune()}};e([l({constructOnly:!0})],B.prototype,"dataByBaseInstance",void 0),e([l({constructOnly:!0})],B.prototype,"material",void 0),e([l()],B.prototype,"highlightOrderMap",void 0),B=e([c("esri.views.3d.webgl-engine.materials.renderers.MergedBuffer")],B);class b{constructor(e,t){this.origin=e,this.baseInstance=t,this.changes=new Array}}function w(e,t){const n=e.find(e=>e.numElements>=t);if(null==n)return null;const s=n.from;return n.from+=t,n.from>=n.to&&e.removeUnordered(n),s}const I=new a({allocator:e=>e||new u,deallocator:null});function M(){return new o}export{B as MergedBuffer};
5
+ import{__decorate as e}from"tslib";import t from"../../../../../core/Accessor.js";import{removeUnordered as s,filterInPlace as n}from"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{getOrCreateMapValue as r}from"../../../../../core/MapUtils.js";import{NestedMap as o}from"../../../../../core/NestedMap.js";import a from"../../../../../core/PooledArray.js";import{nullUid as i}from"../../../../../core/uid.js";import{property as l,subclass as c}from"../../../../../core/accessorSupport/decorators.js";import{assert as d}from"../../lib/Util.js";import{BufferRange as u,mergeAdjacentRanges as f}from"./BufferRange.js";import{Instance as h}from"./Instance.js";import{PerBaseInstanceData as m}from"./PerBaseInstanceData.js";import{PerBufferData as p,getTargetBuffer as g,hasVao as y}from"./PerBufferData.js";import{PerOriginData as v}from"./PerOriginData.js";import{VaoWriter as _}from"./VaoWriter.js";let B=class extends t{constructor(e){super(e),this._vaoWriter=null,this._useMetalWorkaround=!1,this._hasOccludees=!1}destroy(){this.uninitializeRenderContext()}initializeRenderContext(e){this._useMetalWorkaround=e.renderContext.rctx.isAssumedMetalDriver,this._vaoWriter=new _(this.material,e.renderContext.rctx)}uninitializeRenderContext(){this._useMetalWorkaround=!1,this._vaoWriter=null}get hasOccludees(){return this._hasOccludees}modify(e,t){this._applyUpdates(e,t),this._applyAddsAndRemoves(e),this._updateDrawCommands()}get canCompact(){for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())if(t.buffers.some(e=>e.holes.length>1))return!0;return!1}compact(e){if(!this.canCompact)return!1;let t=!1;for(const n of this.dataByBaseInstance.values())for(const r of n.dataByOrigin.values()){const o=new Array;for(let t=0;t<r.buffers.length&&!e.done;){const n=r.buffers[t];n.holes.length<=1?++t:(n.instances.forEach(({geometry:e})=>o.push(e)),this._vaoWriter?.deleteBuffer(n),s(r.buffers,n,void 0,{last:t}),e.madeProgress())}if(o.length>0){const{baseInstanceData:e}=n;r.buffers.forEach(t=>this._applyAdds(e,t,o));const s=g(null!=e);for(;o.length>0;)r.buffers.push(this._applyAndRebuild(e,new p(s),o,null));t=!0}}return t}updateHighlights(e){this.highlightOrderMap=e;for(const t of this.dataByBaseInstance.values())for(const s of t.dataByOrigin.values())for(const t of s.buffers)t.updateHighlights(e)}_applyUpdates(e,t){const n=this._vaoWriter;if(null==n)return void e.clearUpdates();let r;const o=this._useMetalWorkaround?(e,t)=>{r??=new Map;let s=r.get(t);s||(s=[],r.set(t,s)),s.push(e)}:(e,t)=>n.updateInstance(e,t);for(const a of e.updates){if(t.done)return;const{renderGeometry:n,updateType:r}=a;s(e.pending.updates,a),t.madeProgress();const l=this.dataByBaseInstance.get(n.geometry.baseGeometry?.id??i),c=l?.dataByOrigin.get(n.localOrigin.id)?.findBuffer(n.id);if(null==c)return;const d=c.instances.get(n.id);6&r&&o(d,c),25&r&&(c.drawCommandsDirty=!0)}r&&n.updateInstancesMetal(r)}_computeDeltas(e,t){const s=new Map;for(const n of e){const e=n.localOrigin;if(null==e)continue;const t=n.geometry.baseGeometry,o=r(s,t??null,M);let a=o.get(e,null);null==a&&(a=new b(e.vec3,t),o.set(e,null,a)),a.changes.push(n)}for(const n of t){const e=n.localOrigin;if(null==e)continue;const t=n.geometry.baseGeometry,o=this.dataByBaseInstance.get(t?.id??i),a=o?.dataByOrigin.get(e.id)?.findBuffer(n.id);if(null==a)continue;const l=r(s,t??null,M);let c=l.get(e,a);null==c&&(c=new b(e.vec3,t),l.set(e,a,c)),c.changes.push(n)}return s}_applyAddsAndRemoves(e){const{_vaoWriter:t,dataByBaseInstance:n}=this;if(null==t)return void e.clearAddsAndRemoves();const o=this._computeDeltas(e.adds,e.removes);for(const[a,l]of o){const e=r(n,a?.id??i,()=>new m(t.createBaseInstanceData(a))),o=null!=a;for(const[n,a]of l.outerMap()){const i=a.get(null),c=i?.changes??[];l.delete(n,null);const u=r(e.dataByOrigin,n.id,()=>new v(n.vec3,o));for(const[r,o]of a){if(l.delete(n,r),null==r&&d(!1,"No VAO for removed geometries"),r.instances.size===o.changes.length){t.deleteBuffer(r),s(u.buffers,r),0===u.buffers.length&&0===c.length&&e.dataByOrigin.delete(n.id);continue}const a=r.numElements;switch(t.evaluateBufferAllocation(a,c,o.changes,r)){case 0:o.changes.forEach(({id:e})=>r.deleteInstance(e)),r.instances.forEach(({geometry:e})=>c.push(e)),t.deleteBuffer(r),s(u.buffers,r);break;case 1:this._applyAndRebuild(e.baseInstanceData,r,c,o);break;case 2:this._applyRemoves(r,o)}}if(c.length>0){const{baseInstanceData:t}=e,s=g(o);for(const e of u.buffers)this._applyAdds(t,e,c);for(;c.length>0;)u.buffers.push(this._applyAndRebuild(t,new p(s),c,null))}}0===e.dataByOrigin.size&&(e.dispose(),n.delete(e.id))}e.clearAddsAndRemoves()}_updateDrawCommands(){this._hasOccludees=!1;for(const e of this.dataByBaseInstance.values())for(const t of e.dataByOrigin.values())for(const e of t.buffers)e.updateIfDrawCommandsDirty(this.highlightOrderMap),this._hasOccludees||=e.hasOccludees}_applyAndRebuild(e,t,s,n){if(n)for(const c of n.changes)t.deleteInstance(c.id);const r=this._vaoWriter,o=r.maxElements(t.targetBuffer);let a=t.numElements;for(;s.length>0;){const e=s.pop(),n=r.elementCount(e.geometry);if(a+n>o&&a>0){s.push(e);break}a+=n;const i=new h(e,0,0,this.highlightOrderMap);d(null==t.instances.get(e.id)),t.addInstance(e.id,i)}t.resetInstanceSummary(),t.vao=r.reallocateBuffer(e,t,a),t.vaoEndElement=r.endElement(t);const i=r.rebuildInstances(a,t.writeableInstances.values(),t);t.updateInstances(),t.holes.clear();const l=t.holes.pushNew();return l.from=i,l.to=t.vaoEndElement,t.updateDrawCommands(this.highlightOrderMap),t}_applyRemoves(e,t){const{_vaoWriter:s}=this;if(0===t.changes.length||null==s)return;let n=1/0,r=-1/0;for(const o of t.changes){const t=o.id,s=e.instances.get(t);if(!s)continue;e.deleteInstance(t),this._useMetalWorkaround&&(n=Math.min(n,s.from),r=Math.max(r,s.to));const a=I.back();if(a){if(a.to===s.from){a.to=s.to;continue}if(a.from===s.to){a.from=s.from;continue}}const i=I.pushNew();i.from=s.from,i.to=s.to}f(I),this._useMetalWorkaround?s.clearHolesMetal(e.instances.values(),n,r,e):s.clearHoles(I,e),e.holes.pushArray(I.data,I.length),I.forAll((e,t)=>I.data[t]=null),I.clear(),e.drawCommandsDirty=!0}_applyAdds(e,t,s){if(0===s.length||null==this._vaoWriter)return;if(!y(t))return void this._applyAndRebuild(e,t,s,null);const r=this._vaoWriter,o=t.numElements,a=s.reduce((e,{geometry:t})=>e+r.elementCount(t),0),i=Math.min(o+a,r.maxElements(t.targetBuffer));if(r.canGrow(t,i))return void this._applyAndRebuild(e,t,s,null);f(t.holes);const l=new Array;let c=1/0,d=-1/0;for(const{geometry:n}of s){const e=r.elementCount(n),s=w(t.holes,e);l.push(s),this._useMetalWorkaround&&null!=s&&(c=Math.min(s,c),d=Math.max(s+e,d))}const u=this._addInstances(s,t,l);if(this._useMetalWorkaround){for(const e of u);r.writeInstanceRangeMetal(d,c,t.instances.values(),t)}else r.writeRandomInstances(i,u,t);n(s,(e,t)=>null==l[t])}*_addInstances(e,t,s){const n=e.length,r=this._vaoWriter;for(let o=0;o<n;++o){const n=s[o];if(null==n)continue;const a=e[o],i=r.elementCount(a.geometry),l=new h(a,n,n+i,this.highlightOrderMap);d(null==t.instances.get(a.id)),t.addInstance(a.id,l),t.drawCommandsDirty=!0,yield l}}static prune(){_.prune()}get test(){}};e([l({constructOnly:!0})],B.prototype,"dataByBaseInstance",void 0),e([l({constructOnly:!0})],B.prototype,"material",void 0),e([l()],B.prototype,"highlightOrderMap",void 0),B=e([c("esri.views.3d.webgl-engine.materials.renderers.MergedBuffer")],B);class b{constructor(e,t){this.origin=e,this.baseInstance=t,this.changes=new Array}}function w(e,t){const s=e.find(e=>e.numElements>=t);if(null==s)return null;const n=s.from;return s.from+=t,s.from>=s.to&&e.removeUnordered(s),n}const I=new a({allocator:e=>e||new u,deallocator:null});function M(){return new o}export{B as MergedBuffer};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{toConst as r}from"../../../../core/compilerUtils.js";import{unpackFloatRGBA as i}from"../../../../core/floatRGBA.js";import has from"../../../../core/has.js";import s from"../../../../core/Logger.js";import{removeMaybe as n,destroyMaybe as o}from"../../../../core/maybe.js";import{when as a,watch as h,initial as l,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{addFrameTask as d}from"../../../../core/scheduling.js";import{Milliseconds as c}from"../../../../core/time.js";import{property as m,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{isMoon as f,isMars as _}from"../../../../geometry/support/spatialReferenceUtils.js";import{ChapmanAtmosphere as g}from"../../environment/ChapmanAtmosphere.js";import{CloudsComposition as w}from"../../environment/CloudsComposition.js";import{Fog as x}from"../../environment/Fog.js";import{LocalAtmosphere as v}from"../../environment/LocalAtmosphere.js";import{MarsAtmosphere as y}from"../../environment/MarsAtmosphere.js";import{ComponentObjectCollection as j}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueConstructionContext as R}from"../core/shaderTechnique/ShaderTechniqueConstructionContext.js";import{ShaderTechniqueRepository as b}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{ObjectAndLayerIDRenderNode as C}from"../effects/geometry/ObjectAndLayerIDRenderNode.js";import{olidEnabled as T}from"../effects/geometry/olidUtils.js";import{RenderOccludedRenderNode as A}from"../effects/geometry/RenderOccludedRenderNode.js";import{GlowRenderNode as O}from"../effects/glow/GlowRenderNode.js";import{Haze as S}from"../effects/haze/Haze.js";import{Highlight as q}from"../effects/highlight/Highlight.js";import{ShadowHighlight as U}from"../effects/highlight/ShadowHighlight.js";import{Magnifier as M}from"../effects/magnifier/Magnifier.js";import{SMAA as k}from"../effects/smaa/SMAA.js";import{SSAO as L}from"../effects/ssao/SSAO.js";import{Stars as D}from"../effects/stars/Stars.js";import H from"../lib/CompositingHelper.js";import{GLMaterialRepository as F}from"../lib/GLMaterialRepository.js";import{ObjectAndLayerIdRenderHelper as W}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as B}from"../lib/Renderer.js";import{RenderingContext as E}from"../lib/RenderingContext.js";import{RenderingContextOptions as N}from"../lib/RenderingContextOptions.js";import{TextureRepository as z}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as G}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as P}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as I}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as V}from"./contextCache.js";import{removeLoadedShaderModules as X}from"./renderUtils.js";import{ScreenshotManager as Q,ScreenshotContext as J}from"./ScreenshotManager.js";import{contextCache as K}from"./testUtils.js";import{noBudget as Y}from"../../../support/Scheduler.js";import{checkWebGLError as Z}from"../../../webgl/checkWebGLError.js";let $=class extends t{constructor(e,t){super(e),this._waterTextures=new I,this.olidRenderHelper=T()?new W:null,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this.glow=null,this.fog=null,this.test=null;try{this._initializeContext(t)}catch(n){return void console.error("Failed to initialize context",n)}const{memoryController:r}=t.view.resourceController;this._stippleTextures=P(this._rctx,r),this.notifyChange("stippleTextures"),this._markerTextures=G(this._rctx,r),this.notifyChange("markerTextures"),this._techniques=new b(new R(this._rctx,t.viewingMode,t.sphericalSpatialReference,this.stippleTextures,this.waterTextures,this.markerTextures)),this._textures=new z(t),this.addHandles(this._textures.events.on("changed",e=>this.requestRender(e)));const i=new F(this._textures,this._techniques,()=>this.requestRender(),()=>this.requestRender());this._compositingHelper=new H(this._rctx,this._techniques),this._renderer=new B(t,i,this._techniques,this._rctx,this._compositingHelper,e=>this.requestRender(e)),this.notifyChange("renderer"),this.addHandles([a(()=>t.view.ready,()=>this._createRenderNodes(),l),h(()=>this.waterTextures?.updating,()=>this.requestRender(),l),h(()=>t.view.qualityProfile,e=>this.renderer?.updateRenderFeatures(e),p)]);const s={renderScene:(e,t,r,i)=>this.renderer.render(e,t,r,i),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>t.options.screenshot.prepareOverlay(),renderOverlay:(e,r,i)=>t.options.screenshot.renderOverlay(e,r,i)};this._screenshotManager=new Q(this._rctx,s,e=>t.view.overlayManager.updateOverlays(Y,e.camera,0)),this._registerFrameTask(t)}destroy(){const e=this.stage?.container;e?.contains(this._canvas)&&e.removeChild(this._canvas),this._frameTask=n(this._frameTask),this._techniques=o(this._techniques),this._componentObjectCollection=o(this._componentObjectCollection),this._set("componentObjectCollection",null),this._screenshotManager=o(this._screenshotManager),o(this.renderer),this._textures=o(this._textures),o(this.waterTextures),o(this.markerTextures),o(this.stippleTextures),this._waterTextures=null,this._markerTextures=null,this._stippleTextures=null,this._canvas=null,this._rctx=o(this._rctx),this._compositingHelper=null,this._renderer=null,this._set("renderer",null),this.test?.destroy()}_createRenderNodes(){const{view:e,viewingMode:t}=this.stage;new D({view:e}),f(e.spatialReference)||(2===t?(new v({view:e}),this.glow=new O({view:e})):_(e.spatialReference)?(new y({view:e}),this.glow=new O({view:e})):(new g({view:e}),new w({view:e}),this.glow=new O({view:e}),new S({view:e}),this.fog=new x({view:e}))),new L({view:e,isEnabled:()=>this.renderer.hasSSAO}),new k({view:e,isEnabled:()=>this.renderer.hasSMAA}),new M({view:e}),new q({view:e}),new U({view:e,viewingMode:t}),new A({view:e}),T()&&new C({view:e})}requestRender(e=1){switch(e){case 2:this.view.state.fading=!0;case 1:this._needsUpdate=!0;case 0:this._needsRender=!0}}get updating(){return this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this._textures.updating||this.waterTextures.updating}get textures(){return this._textures}get techniques(){return this._techniques}get compositingHelper(){return this._compositingHelper}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(r(e))}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,s,n,o=n){const a=s.constrainWindowSize(t,r,n*s.pixelRatio,o*s.pixelRatio),h=this._ensureLinearDepthArrayBuffer(a);this.renderer.readMainDepth(a,h);const l=(e,t,r)=>i(t,e)*(r[1]-r[0])+r[0];let p=Number.MAX_VALUE;for(let i=0;i<a[2]*a[3];i++){const e=l(4*i,h,s.nearFar);p>e&&e!==s.nearFar[0]&&e!==s.nearFar[1]&&(p=e)}if(e){const i=e.pickDepth(t*s.pixelRatio,r*s.pixelRatio,s);null!=i&&p>i&&i!==s.nearFar[0]&&i!==s.nearFar[1]&&(p=i)}return p===Number.MAX_VALUE?void 0:p}_ensureLinearDepthArrayBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){X(),await this._techniques.reloadAll(),this.renderer.overlay?.reloadShaders(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,i=0,s=!1;const n={preRender:({time:s})=>{r=this.updating,i=this._needsUpdate?1:0,this._needsRender&&this.renderer.updateSceneDepthRange(t.camera),e.commitSyncLayers(),s=this.test?.time??s;const n=c(s-this._lastAnimationUpdate);this.view.state.animationsEnabled&&(n>this.renderer.animationTimestep||r||this._needsRender)&&(this.renderer.updateAnimation(t,s)&&this.requestRender(0),this._lastAnimationUpdate=s)},render:({time:e})=>{if((this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const r=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,e=this.test?.time??e,this.renderer.render(t,e,0),s=!0,r&&this.renderer.hasReflections&&(this.requestRender(0),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{this.view.state.animationsEnabled&&this._textures.update();const r=new J(t,this.renderer.fboCache);e=this.test?.time??e,this._screenshotManager.update(r,e)},finish:()=>{s&&(this.renderer.finish(2===t.mode?i:1),s=!1)}};this._frameTask=d(n)}_initializeContext(e){const{options:t}=e,r=t.canvas??document.createElement("canvas");r.setAttribute("style","width: 100%; height:100%; display:block;"),this._canvas=r;const i={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},n=r.getContext("webgl2",i);if(null==n)return void s.getLogger(this).error("A WebGL2 context could not be created.");Z(n,!0),this._rctx=ee(n,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&s.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested");const{container:o}=e;!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(o.style.backgroundColor="black"),o.contains(r)||o.appendChild(r)}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloatLinear")}get _viewingMode(){return this.stage.viewingMode}get stage(){return this.view.stage}get stippleTextures(){return this._stippleTextures}get markerTextures(){return this._markerTextures}get waterTextures(){return this._waterTextures}getObjectAndLayerIdColor(e){return this.olidRenderHelper?.getObjectAndLayerIdColor(e)}get renderer(){return this._renderer}get componentObjectCollection(){return null==this._componentObjectCollection&&(this._componentObjectCollection=new j(this.renderer.renderPassManager,this._viewingMode,this.stage.sphericalSpatialReference)),this._componentObjectCollection}set componentObjectCollection(e){this._componentObjectCollection=e}updateQualitySettings(e){null!=this.test?.time&&(this.test.savedFadeDuration=e.fadeDuration,e.fadeDuration=c(0)),this._rctx.updateOptions({maxPreferredTexturePixels:this.view.qualitySettings.maxTexturePixels})}};function ee(e,t){const r=new N(t);if(K.enabled){let t=te.get(e);return 1===t?.refCount?(t.configure(r),t.ref(),t):(t=new E(e,r),te.set(e,t),t.ref(),t)}return new E(e,r)}e([m({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([m({constructOnly:!0})],$.prototype,"view",void 0),e([m({readOnly:!0})],$.prototype,"stippleTextures",null),e([m({readOnly:!0})],$.prototype,"markerTextures",null),e([m({readOnly:!0})],$.prototype,"waterTextures",null),e([m({readOnly:!0})],$.prototype,"olidRenderHelper",void 0),e([m()],$.prototype,"_textures",void 0),e([m({readOnly:!0})],$.prototype,"renderer",null),e([m()],$.prototype,"_screenshotManager",void 0),e([m()],$.prototype,"componentObjectCollection",null),e([m()],$.prototype,"_componentObjectCollection",void 0),e([m()],$.prototype,"_needsUpdate",void 0),e([m()],$.prototype,"_needsWaterReflectionUpdate",void 0),$=e([u("esri.views.3d.webgl-engine.parts.RenderView")],$);const te=V();export{$ as RenderView};
5
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{toConst as r}from"../../../../core/compilerUtils.js";import{unpackFloatRGBA as i}from"../../../../core/floatRGBA.js";import has from"../../../../core/has.js";import s from"../../../../core/Logger.js";import{removeMaybe as n,destroyMaybe as o}from"../../../../core/maybe.js";import{when as a,watch as h,initial as l,syncAndInitial as p}from"../../../../core/reactiveUtils.js";import{addFrameTask as d}from"../../../../core/scheduling.js";import{Milliseconds as c}from"../../../../core/time.js";import{property as m,subclass as u}from"../../../../core/accessorSupport/decorators.js";import{isMoon as f,isMars as _}from"../../../../geometry/support/spatialReferenceUtils.js";import{ChapmanAtmosphere as g}from"../../environment/ChapmanAtmosphere.js";import{CloudsComposition as w}from"../../environment/CloudsComposition.js";import{Fog as x}from"../../environment/Fog.js";import{LocalAtmosphere as v}from"../../environment/LocalAtmosphere.js";import{MarsAtmosphere as y}from"../../environment/MarsAtmosphere.js";import{ComponentObjectCollection as j}from"../collections/Component/ComponentObjectCollection.js";import{ShaderTechniqueConstructionContext as R}from"../core/shaderTechnique/ShaderTechniqueConstructionContext.js";import{ShaderTechniqueRepository as b}from"../core/shaderTechnique/ShaderTechniqueRepository.js";import{ObjectAndLayerIDRenderNode as C}from"../effects/geometry/ObjectAndLayerIDRenderNode.js";import{olidEnabled as T}from"../effects/geometry/olidUtils.js";import{RenderOccludedRenderNode as A}from"../effects/geometry/RenderOccludedRenderNode.js";import{GlowRenderNode as O}from"../effects/glow/GlowRenderNode.js";import{Haze as S}from"../effects/haze/Haze.js";import{Highlight as q}from"../effects/highlight/Highlight.js";import{ShadowHighlight as U}from"../effects/highlight/ShadowHighlight.js";import{Magnifier as M}from"../effects/magnifier/Magnifier.js";import{SMAA as k}from"../effects/smaa/SMAA.js";import{SSAO as L}from"../effects/ssao/SSAO.js";import{Stars as D}from"../effects/stars/Stars.js";import H from"../lib/CompositingHelper.js";import{GLMaterialRepository as F}from"../lib/GLMaterialRepository.js";import{ObjectAndLayerIdRenderHelper as W}from"../lib/ObjectAndLayerIdRenderHelper.js";import{Renderer as B}from"../lib/Renderer.js";import{RenderingContext as E}from"../lib/RenderingContext.js";import{RenderingContextOptions as N}from"../lib/RenderingContextOptions.js";import{TextureRepository as z}from"../lib/TextureRepository.js";import{createMarkerTextureRepository as G}from"../materials/markerTextureRepository.js";import{createStippleTextureRepository as P}from"../materials/stippleTextureRepository.js";import{WaterTextureRepository as I}from"../materials/internal/WaterTextureRepository.js";import{getContextCache as V}from"./contextCache.js";import{removeLoadedShaderModules as X}from"./renderUtils.js";import{ScreenshotManager as Q,ScreenshotContext as J}from"./ScreenshotManager.js";import{contextCache as K}from"./testUtils.js";import{noBudget as Y}from"../../../support/Scheduler.js";import{checkWebGLError as Z}from"../../../webgl/checkWebGLError.js";let $=class extends t{constructor(e,t){super(e),this._waterTextures=new I,this.olidRenderHelper=T()?new W:null,this._needsUpdate=!0,this._needsRender=!0,this._idleSuspend=!0,this._needsWaterReflectionUpdate=!1,this._lastAnimationUpdate=0,this.glow=null,this.fog=null,this.test=null;try{this._initializeContext(t)}catch(n){return void console.error("Failed to initialize context",n)}const{memoryController:r}=t.view.resourceController;this._stippleTextures=P(this._rctx,r),this.notifyChange("stippleTextures"),this._markerTextures=G(this._rctx,r),this.notifyChange("markerTextures"),this._techniques=new b(new R(this._rctx,t.viewingMode,t.sphericalSpatialReference,this.stippleTextures,this.waterTextures,this.markerTextures)),this._textures=new z(t),this.addHandles(this._textures.events.on("changed",e=>this.requestRender(e)));const i=new F(this._textures,this._techniques,()=>this.requestRender(),()=>this.requestRender());this._compositingHelper=new H(this._rctx,this._techniques),this._renderer=new B(t,i,this._techniques,this._rctx,this._compositingHelper,e=>this.requestRender(e)),this.notifyChange("renderer"),this.addHandles([a(()=>t.view.ready,()=>this._createRenderNodes(),l),h(()=>this.waterTextures?.updating,()=>this.requestRender(),l),h(()=>t.view.qualityProfile,e=>this.renderer?.updateRenderFeatures(e),p)]);const s={renderScene:(e,t,r,i)=>this.renderer.render(e,t,r,i),requestRenderScene:e=>this.requestRender(e),prepareOverlay:()=>t.options.screenshot.prepareOverlay(),renderOverlay:(e,r,i)=>t.options.screenshot.renderOverlay(e,r,i)};this._screenshotManager=new Q(this._rctx,s,e=>t.view.overlayManager.updateOverlays(Y,e.camera,0)),this._registerFrameTask(t)}destroy(){const e=this.stage?.container;e?.contains(this._canvas)&&e.removeChild(this._canvas),this._frameTask=n(this._frameTask),this._techniques=o(this._techniques),this._componentObjectCollection=o(this._componentObjectCollection),this._set("componentObjectCollection",null),this._screenshotManager=o(this._screenshotManager),o(this.renderer),this._textures=o(this._textures),o(this.waterTextures),o(this.markerTextures),o(this.stippleTextures),this._waterTextures=null,this._markerTextures=null,this._stippleTextures=null,this._canvas=null,this._rctx=o(this._rctx),this._compositingHelper=null,this._renderer=null,this._set("renderer",null),this.test?.destroy()}_createRenderNodes(){const{view:e,viewingMode:t}=this.stage;new D({view:e}),f(e.spatialReference)||(2===t?(new v({view:e}),this.glow=new O({view:e})):_(e.spatialReference)?(new y({view:e}),this.glow=new O({view:e})):(new g({view:e}),new w({view:e}),this.glow=new O({view:e}),new S({view:e}),this.fog=new x({view:e}))),new L({view:e,isEnabled:()=>this.renderer.hasSSAO}),new k({view:e,isEnabled:()=>this.renderer.hasSMAA}),new M({view:e}),new q({view:e}),new U({view:e,viewingMode:t}),new A({view:e}),T()&&new C({view:e})}requestRender(e=1){switch(e){case 2:this.view.state.fading=!0;case 1:this._needsUpdate=!0;case 0:this._needsRender=!0}}get updating(){return this._needsUpdate||this._needsWaterReflectionUpdate||this.renderer.updating||this._textures.updating||this.waterTextures.updating}get textures(){return this._textures}get techniques(){return this._techniques}get compositingHelper(){return this._compositingHelper}setIdleSuspend(e){this._idleSuspend!==e&&(this._idleSuspend=e,this.requestRender())}get renderingContext(){return this._rctx}get capabilities(){return this._rctx.capabilities}get canvas(){return this._canvas}takeScreenshot(e){return this._screenshotManager.takeScreenshot(r(e))}getAlpha(){return!!this._rctx.contextAttributes.alpha}getMinimalDepthForArea(e,t,r,s,n,o=n){const a=s.constrainWindowSize(t,r,n*s.pixelRatio,o*s.pixelRatio),h=this._ensureLinearDepthArrayBuffer(a);this.renderer.readMainDepth(a,h);const l=(e,t,r)=>i(t,e)*(r[1]-r[0])+r[0];let p=Number.MAX_VALUE;for(let i=0;i<a[2]*a[3];i++){const e=l(4*i,h,s.nearFar);p>e&&e!==s.nearFar[0]&&e!==s.nearFar[1]&&(p=e)}if(e){const i=e.pickDepth(t*s.pixelRatio,r*s.pixelRatio,s);null!=i&&p>i&&i!==s.nearFar[0]&&i!==s.nearFar[1]&&(p=i)}return p===Number.MAX_VALUE?void 0:p}_ensureLinearDepthArrayBuffer(e){const t=4*e[2]*e[3];return(null==this._tmpDepthBuffer||this._tmpDepthBuffer.byteLength<t)&&(this._tmpDepthBuffer=new Uint8Array(t)),this._tmpDepthBuffer}async reloadShaders(){X(),await this._techniques.reloadAll(),this.renderer.overlay?.reloadShaders(),this.requestRender()}_registerFrameTask(e){const t=e.view.state;let r=!1,i=0,s=!1;const n={preRender:({time:s})=>{r=this.updating,i=this._needsUpdate?1:0,this._needsRender&&this.renderer.updateSceneDepthRange(t.camera),e.commitSyncLayers(),s=this.test?.time??s;const n=c(s-this._lastAnimationUpdate);this.view.state.animationsEnabled&&(n>this.renderer.animationTimestep||r||this._needsRender)&&(this.renderer.updateAnimation(t,s)&&this.requestRender(0),this._lastAnimationUpdate=s)},render:({time:e})=>{if((this._needsRender||!this._idleSuspend||!this.renderer.isCameraFinal||this._needsWaterReflectionUpdate)&&t.camera.fullWidth>0&&t.camera.fullHeight>0){const r=this._needsUpdate&&this._idleSuspend&&this.renderer.isCameraFinal;this._needsRender=!1,this._needsUpdate=!1,this._needsWaterReflectionUpdate=!1,e=this.test?.time??e,this.renderer.render(t,e,0),s=!0,r&&this.renderer.hasReflections&&(this.requestRender(0),this._needsWaterReflectionUpdate=!0)}},update:({time:e})=>{this.view.state.animationsEnabled&&this._textures.update();const r=new J(t,this.renderer.fboCache);e=this.test?.time??e,this._screenshotManager.update(r,e)},finish:()=>{s&&(this.renderer.finish(2===t.mode?i:1),s=!1)}};this._frameTask=d(n)}_initializeContext(e){const{options:t}=e,r=t.canvas??document.createElement("canvas");r.setAttribute("style","width: 100%; height:100%; display:block;"),this._canvas=r;const i={alpha:t.alpha||!1,premultipliedAlpha:!0,antialias:!1,depth:!0,stencil:t.stencil??!0,powerPreference:"high-performance",preserveDrawingBuffer:t.preserveDrawingBuffer??!1},n=r.getContext("webgl2",i);if(null==n)return void s.getLogger(this).error("A WebGL2 context could not be created.");Z(n,!0),this._rctx=ee(n,e),this._loadShaderOnlyExtensions(),!t.alpha&&this._rctx.contextAttributes.alpha&&s.getLogger(this).error("WebGL context has alpha channel even though no alpha channel was requested");const{container:o}=e;!this._rctx.contextAttributes.alpha&&has("safari")>=11&&(o.style.backgroundColor="black"),o.contains(r)||o.appendChild(r)}_loadShaderOnlyExtensions(){this._rctx.capabilities.enable("textureFloatLinear")}get _viewingMode(){return this.stage.viewingMode}get stage(){return this.view.stage}get stippleTextures(){return this._stippleTextures}get markerTextures(){return this._markerTextures}get waterTextures(){return this._waterTextures}getObjectAndLayerIdColor(e){return this.olidRenderHelper?.getObjectAndLayerIdColor(e)}get renderer(){return this._renderer}get componentObjectCollection(){return null==this._componentObjectCollection&&(this._componentObjectCollection=new j(this.renderer.renderPassManager,this._viewingMode,this.stage.sphericalSpatialReference)),this._componentObjectCollection}set componentObjectCollection(e){this._componentObjectCollection=e}updateQualitySettings(e){null!=this.test?.time&&null!=e.fadeDuration&&(this.test.savedFadeDuration=e.fadeDuration,e.fadeDuration=c(0)),this._rctx.updateOptions({maxPreferredTexturePixels:this.view.qualitySettings.maxTexturePixels})}};function ee(e,t){const r=new N(t);if(K.enabled){let t=te.get(e);return 1===t?.refCount?(t.configure(r),t.ref(),t):(t=new E(e,r),te.set(e,t),t.ref(),t)}return new E(e,r)}e([m({type:Boolean,readOnly:!0})],$.prototype,"updating",null),e([m({constructOnly:!0})],$.prototype,"view",void 0),e([m({readOnly:!0})],$.prototype,"stippleTextures",null),e([m({readOnly:!0})],$.prototype,"markerTextures",null),e([m({readOnly:!0})],$.prototype,"waterTextures",null),e([m({readOnly:!0})],$.prototype,"olidRenderHelper",void 0),e([m()],$.prototype,"_textures",void 0),e([m({readOnly:!0})],$.prototype,"renderer",null),e([m()],$.prototype,"_screenshotManager",void 0),e([m()],$.prototype,"componentObjectCollection",null),e([m()],$.prototype,"_componentObjectCollection",void 0),e([m()],$.prototype,"_needsUpdate",void 0),e([m()],$.prototype,"_needsWaterReflectionUpdate",void 0),$=e([u("esri.views.3d.webgl-engine.parts.RenderView")],$);const te=V();export{$ as RenderView};
@@ -2,7 +2,7 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{smoothstep as e}from"../../../../core/mathUtils.js";import{E as r}from"../../../../chunks/vec32.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Float3BindUniform as a}from"../core/shaderModules/Float3BindUniform.js";import{Float4BindUniform as o}from"../core/shaderModules/Float4BindUniform.js";import{glsl as s}from"../core/shaderModules/glsl.js";import{SphereIntersect as n}from"./SphereIntersect.glsl.js";function i(i,h){i.fragment.uniforms.add(new o("heightParameters",a=>{const o=a.camera,s=r(o.eye),n=Math.sqrt(s),i=h.radius,l=s-i*i;let m=e(4e6,5e6,n-i);return m=Math.min(m,.98),t(m,l,0,0)}),new a("cameraPosition",e=>e.camera.eye)),i.fragment.include(n),i.fragment.code.add(s`float sphereFade() {return heightParameters[0];}
5
+ import{smoothstep as e}from"../../../../core/mathUtils.js";import{F as r}from"../../../../chunks/vec32.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{Float3BindUniform as a}from"../core/shaderModules/Float3BindUniform.js";import{Float4BindUniform as o}from"../core/shaderModules/Float4BindUniform.js";import{glsl as s}from"../core/shaderModules/glsl.js";import{SphereIntersect as n}from"./SphereIntersect.glsl.js";function i(i,h){i.fragment.uniforms.add(new o("heightParameters",a=>{const o=a.camera,s=r(o.eye),n=Math.sqrt(s),i=h.radius,l=s-i*i;let m=e(4e6,5e6,n-i);return m=Math.min(m,.98),t(m,l,0,0)}),new a("cameraPosition",e=>e.camera.eye)),i.fragment.include(n),i.fragment.code.add(s`float sphereFade() {return heightParameters[0];}
6
6
  float sphereDepthInterpolate(vec3 worldRay, vec3 viewRay, float currentLinearDepth) {
7
7
  vec2 rayPlanetIntersect = sphereIntersect(cameraPosition, worldRay, heightParameters[1]);
8
8
  bool hitsPlanet = (rayPlanetIntersect.x <= rayPlanetIntersect.y) && rayPlanetIntersect.x > 0.0;
@@ -2,7 +2,7 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{TextureBackedBufferModule as o}from"../../../core/shaderLibrary/TextureBackedBuffer.glsl.js";import{NormalAttribute as e}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{DoublePrecision as r}from"../../../core/shaderLibrary/util/DoublePrecision.glsl.js";import{RgbaFloatEncoding as t}from"../../../core/shaderLibrary/util/RgbaFloatEncoding.glsl.js";import{Float3DrawUniform as a}from"../../../core/shaderModules/Float3DrawUniform.js";import{Float3PassUniform as l}from"../../../core/shaderModules/Float3PassUniform.js";import{glsl as n}from"../../../core/shaderModules/glsl.js";import{Matrix3DrawUniform as d}from"../../../core/shaderModules/Matrix3DrawUniform.js";import{Matrix3PassUniform as m}from"../../../core/shaderModules/Matrix3PassUniform.js";import{Matrix4BindUniform as i}from"../../../core/shaderModules/Matrix4BindUniform.js";import{Texture2DDrawUniform as s}from"../../../core/shaderModules/Texture2DDrawUniform.js";import{edgeViewTextureLayout as c}from"../../../lib/edgeRendering/bufferLayouts.js";const f=new o(c,"componentIndex",new s("componentDataTex",o=>o.componentDataTexture));function v(o,s){const{vertex:c}=o;c.include(t),o.include(e,s);const{silhouette:v,legacy:u,spherical:w}=s;o.attributes.add("componentIndex","float");const{getTextureAttribute:p,TextureBackedBufferModule:F}=f;o.include(F);const M=8,h=128;c.constants.add("lineWidthFractionFactor","float",M),c.constants.add("extensionLengthOffset","float",h),c.code.add(n`
5
+ import{TextureBackedBufferModule as o}from"../../../core/shaderLibrary/TextureBackedBuffer.glsl.js";import{NormalAttribute as e}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{DoublePrecision as r}from"../../../core/shaderLibrary/util/DoublePrecision.glsl.js";import{Float3DrawUniform as t}from"../../../core/shaderModules/Float3DrawUniform.js";import{Float3PassUniform as a}from"../../../core/shaderModules/Float3PassUniform.js";import{glsl as l}from"../../../core/shaderModules/glsl.js";import{Matrix3DrawUniform as n}from"../../../core/shaderModules/Matrix3DrawUniform.js";import{Matrix3PassUniform as d}from"../../../core/shaderModules/Matrix3PassUniform.js";import{Matrix4BindUniform as m}from"../../../core/shaderModules/Matrix4BindUniform.js";import{Texture2DUintDrawUniform as s}from"../../../core/shaderModules/Texture2DUintDrawUniform.js";import{edgeViewTextureLayout as i}from"../../../lib/edgeRendering/bufferLayouts.js";const c=new o(i,"componentIndex",new s("componentTextureBuffer",o=>o.componentDataTexture));function f(o,s){const{vertex:i}=o;o.include(e,s);const{silhouette:f,legacy:v,spherical:u}=s;o.attributes.add("componentIndex","float");const{getTextureAttribute:w,TextureBackedBufferModule:p}=c;o.include(p);const F=8,M=128;i.constants.add("lineWidthFractionFactor","float",F),i.constants.add("extensionLengthOffset","float",M),i.code.add(l`
6
6
  struct ComponentData {
7
7
  vec4 color;
8
8
  vec3 normal;
@@ -15,16 +15,16 @@ import{TextureBackedBufferModule as o}from"../../../core/shaderLibrary/TextureBa
15
15
 
16
16
  ComponentData readComponentData() {
17
17
  vec3 normal = normalModel();
18
- vec3 normal2 = ${v?n`decompressNormal(normal2Compressed)`:n`normal`};
18
+ vec3 normal2 = ${f?l`decompressNormal(normal2Compressed)`:l`normal`};
19
19
 
20
- vec4 colorValue = ${p("color")};
21
- float lineWidth = ${p("lineWidth")} * (255.0 / lineWidthFractionFactor);
22
- float extensionLength = ${p("extensionLength")} * 255.0 - extensionLengthOffset;
20
+ vec4 colorValue = ${w("color")};
21
+ float lineWidth = float(${w("lineWidth")}) / lineWidthFractionFactor;
22
+ float extensionLength = float(${w("extensionLength")}) - extensionLengthOffset;
23
23
  // SOLID (=0/255) needs to be > 0.0, SKETCHY (=1/255) needs to be <= 0;
24
- float type = -(${p("materialType")} * 255.0) + 0.5;
25
- float opacity = ${p("opacity")};
24
+ float type = -(float(${w("materialType")})) + 0.5;
25
+ float opacity = ${w("opacity")};
26
26
 
27
- float verticalOffset = ${p("elevationOffset")};
27
+ float verticalOffset = ${w("elevationOffset")};
28
28
 
29
29
  return ComponentData(
30
30
  vec4(colorValue.rgb, colorValue.a * opacity),
@@ -35,21 +35,21 @@ import{TextureBackedBufferModule as o}from"../../../core/shaderLibrary/TextureBa
35
35
  verticalOffset
36
36
  );
37
37
  }
38
- `),u?c.code.add(n`vec3 _modelToWorldNormal(vec3 normal) {
38
+ `),v?i.code.add(l`vec3 _modelToWorldNormal(vec3 normal) {
39
39
  return (model * vec4(normal, 0.0)).xyz;
40
40
  }
41
41
  vec3 _modelToViewNormal(vec3 normal) {
42
42
  return (localView * model * vec4(normal, 0.0)).xyz;
43
- }`):(c.uniforms.add(new d("transformNormalGlobalFromModel",o=>o.transformNormalGlobalFromModel)),c.code.add(n`vec3 _modelToWorldNormal(vec3 normal) {
43
+ }`):(i.uniforms.add(new n("transformNormalGlobalFromModel",o=>o.transformNormalGlobalFromModel)),i.code.add(l`vec3 _modelToWorldNormal(vec3 normal) {
44
44
  return transformNormalGlobalFromModel * normal;
45
- }`)),v?(o.attributes.add("normal2Compressed","vec2"),c.code.add(n`vec3 worldNormal(ComponentData data) {
45
+ }`)),f?(o.attributes.add("normal2Compressed","vec2"),i.code.add(l`vec3 worldNormal(ComponentData data) {
46
46
  return _modelToWorldNormal(normalize(data.normal + data.normal2));
47
- }`)):c.code.add(n`vec3 worldNormal(ComponentData data) {
47
+ }`)):i.code.add(l`vec3 worldNormal(ComponentData data) {
48
48
  return _modelToWorldNormal(data.normal);
49
- }`),u?c.code.add(n`void worldAndViewFromModelPosition(vec3 modelPos, float verticalOffset, out vec3 worldPos, out vec3 viewPos) {
49
+ }`),v?i.code.add(l`void worldAndViewFromModelPosition(vec3 modelPos, float verticalOffset, out vec3 worldPos, out vec3 viewPos) {
50
50
  worldPos = (model * vec4(modelPos, 1.0)).xyz;
51
51
  viewPos = (localView * vec4(worldPos, 1.0)).xyz;
52
- }`):(c.include(r,s),c.uniforms.add(new m("transformViewFromCameraRelativeRS",o=>o.transformViewFromCameraRelativeRS),new d("transformWorldFromModelRS",o=>o.transformWorldFromModelRS),new a("transformWorldFromModelTL",o=>o.transformWorldFromModelTL),new a("transformWorldFromModelTH",o=>o.transformWorldFromModelTH),new l("transformWorldFromViewTL",o=>o.transformWorldFromViewTL),new l("transformWorldFromViewTH",o=>o.transformWorldFromViewTH)),c.code.add(n`
52
+ }`):(i.include(r,s),i.uniforms.add(new d("transformViewFromCameraRelativeRS",o=>o.transformViewFromCameraRelativeRS),new n("transformWorldFromModelRS",o=>o.transformWorldFromModelRS),new t("transformWorldFromModelTL",o=>o.transformWorldFromModelTL),new t("transformWorldFromModelTH",o=>o.transformWorldFromModelTH),new a("transformWorldFromViewTL",o=>o.transformWorldFromViewTL),new a("transformWorldFromViewTH",o=>o.transformWorldFromViewTH)),i.code.add(l`
53
53
  void worldAndViewFromModelPosition(vec3 modelPos, float verticalOffset, out vec3 worldPos, out vec3 viewPos) {
54
54
  vec3 rotatedModelPosition = transformWorldFromModelRS * modelPos;
55
55
 
@@ -63,14 +63,14 @@ viewPos = (localView * vec4(worldPos, 1.0)).xyz;
63
63
  worldPos = transformCameraRelativeFromModel + rotatedModelPosition;
64
64
 
65
65
  if (verticalOffset != 0.0) {
66
- vec3 vUp = ${w?"normalize(transformWorldFromModelTL + rotatedModelPosition);":"vec3(0.0, 0.0, 1.0);"}
66
+ vec3 vUp = ${u?"normalize(transformWorldFromModelTL + rotatedModelPosition);":"vec3(0.0, 0.0, 1.0);"}
67
67
  worldPos += verticalOffset * vUp;
68
68
  }
69
69
 
70
70
  viewPos = transformViewFromCameraRelativeRS * worldPos;
71
71
  }
72
- `)),c.uniforms.add(new i("transformProjFromView",o=>o.camera.projectionMatrix)).code.add(n`vec4 projFromViewPosition(vec3 position) {
72
+ `)),i.uniforms.add(new m("transformProjFromView",o=>o.camera.projectionMatrix)).code.add(l`vec4 projFromViewPosition(vec3 position) {
73
73
  return transformProjFromView * vec4(position, 1.0);
74
- }`),c.code.add(n`float calculateExtensionLength(float extensionLength, float lineLength) {
74
+ }`),i.code.add(l`float calculateExtensionLength(float extensionLength, float lineLength) {
75
75
  return extensionLength / (log2(max(1.0, 256.0 / lineLength)) * 0.2 + 1.0);
76
- }`)}function u(o){return 1===o||2===o}export{v as EdgeUtil,u as usesSketchLogic};
76
+ }`)}function v(o){return 1===o||2===o}export{f as EdgeUtil,v as usesSketchLogic};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../core/Accessor.js";import{makeHandle as s}from"../core/handleUtils.js";import{isActivationKey as i}from"../core/keyboard.js";import{watch as o,initial as r}from"../core/reactiveUtils.js";import{addFrameTask as n}from"../core/scheduling.js";import{property as a,subclass as c}from"../core/accessorSupport/decorators.js";import{setCalciteModeClass as h}from"../support/modeUtils.js";import{globalCss as d}from"../widgets/support/globalCss.js";const l="esri-attribution",u={poweredBy:`${l}__powered-by`,sources:`${l}__sources`,sourcesOpen:`${l}__sources--open`,link:`${l}__link`};let p=class extends t{constructor(e){super(e),this._previousSourceHeight=0,this._opened=!1,this._overflowing=!1,this._changeSet=new Set,this._toggleState=()=>{(this._opened||this._overflowing)&&(this._opened=!this._opened,this._invalidate("opened"))},this.surface=document.createElement("div"),this._task=n({render:()=>{this._update(),this._task.pause(),this._changeSet.clear()}}),this.addHandles(this._task)}initialize(){const e=document.createElement("div");h(e),e.setAttribute("dir","ltr"),e.classList.add("esri-view-attribution"),e.classList.add("esri-attribution"),this._set("surface",e),e.innerHTML=`\n <div class="${u.sources}"></div>\n <div class="${u.poweredBy}">\n Powered by\n <a class="${u.link}" href="https://www.esri.com/" rel="noreferrer" target="_blank">Esri</a>\n </div>`,this.addHandles([this.surface,o(()=>this.attributionItems,()=>this._invalidate("attributionItems"),r)]);const t=e.querySelector(`.${u.sources}`);this._previousSourceHeight=t.clientHeight;const n=new ResizeObserver(()=>{this._invalidate("overflow")});n.observe(t),this.addHandles(s(()=>n.disconnect()));const a=new MutationObserver(()=>{this._invalidate("overflow")});a.observe(t,{childList:!0,subtree:!0,characterData:!0}),this.addHandles(s(()=>a.disconnect())),t.onclick=this._toggleState,t.onkeydown=e=>{i(e.key)&&(e.preventDefault(),this._toggleState())}}_invalidate(e){this._changeSet.add(e),this._task.resume()}_update(){const e=this.surface.querySelector(`.${u.sources}`);if(this._changeSet.has("overflow")){const{clientHeight:t,clientWidth:s,scrollWidth:i}=e,o=t<this._previousSourceHeight;this._previousSourceHeight=t,this._opened?o&&(this._opened=!1):o||(this._overflowing=i>s)}if(this._changeSet.has("overflow")||this._changeSet.has("opened")){const t=this._opened||this._overflowing,s=t?"0":"";e.setAttribute("tabindex",s),e.classList.toggle(d.interactive,t),e.classList.toggle(u.sourcesOpen,this._opened)}this._changeSet.has("attributionItems")&&(e.innerText=this.attributionItems?.map(e=>e.text).join(" | ")??"")}};e([a()],p.prototype,"attributionItems",void 0),e([a({readOnly:!0})],p.prototype,"surface",void 0),p=e([c("esri.views.Attribution")],p);export{p as Attribution};
5
+ import{__decorate as e}from"tslib";import t from"../core/Accessor.js";import{makeHandle as s}from"../core/handleUtils.js";import{isActivationKey as i}from"../core/keyboard.js";import{watch as o,initial as r}from"../core/reactiveUtils.js";import{addFrameTask as n}from"../core/scheduling.js";import{property as a,subclass as c}from"../core/accessorSupport/decorators.js";import{setCalciteModeClass as h}from"../support/modeUtils.js";import{globalCss as d}from"../widgets/support/globalCss.js";const l="esri-attribution",u={poweredBy:`${l}__powered-by`,sources:`${l}__sources`,sourcesOpen:`${l}__sources--open`,link:`${l}__link`};let p=class extends t{constructor(e){super(e),this._previousSourceHeight=0,this._opened=!1,this._overflowing=!1,this._changeSet=new Set,this._toggleState=()=>{(this._opened||this._overflowing)&&(this._opened=!this._opened,this._invalidate("opened"))},this.surface=document.createElement("div"),this._task=n({render:()=>{this._update(),this._task.pause(),this._changeSet.clear()}}),this.addHandles(this._task)}initialize(){const e=document.createElement("div");h(e),e.setAttribute("dir","ltr"),e.classList.add("esri-widget","esri-view-attribution","esri-attribution"),this._set("surface",e),e.innerHTML=`\n <div class="${u.sources}"></div>\n <div class="${u.poweredBy}">\n Powered by\n <a class="${u.link}" href="https://www.esri.com/" rel="noreferrer" target="_blank">Esri</a>\n </div>`,this.addHandles([this.surface,o(()=>this.attributionItems,()=>this._invalidate("attributionItems"),r)]);const t=e.querySelector(`.${u.sources}`);this._previousSourceHeight=t.clientHeight;const n=new ResizeObserver(()=>{this._invalidate("overflow")});n.observe(t),this.addHandles(s(()=>n.disconnect()));const a=new MutationObserver(()=>{this._invalidate("overflow")});a.observe(t,{childList:!0,subtree:!0,characterData:!0}),this.addHandles(s(()=>a.disconnect())),t.onclick=this._toggleState,t.onkeydown=e=>{i(e.key)&&(e.preventDefault(),this._toggleState())}}_invalidate(e){this._changeSet.add(e),this._task.resume()}_update(){const e=this.surface.querySelector(`.${u.sources}`);if(this._changeSet.has("overflow")){const{clientHeight:t,clientWidth:s,scrollWidth:i}=e,o=t<this._previousSourceHeight;this._previousSourceHeight=t,this._opened?o&&(this._opened=!1):o||(this._overflowing=i>s)}if(this._changeSet.has("overflow")||this._changeSet.has("opened")){const t=this._opened||this._overflowing,s=t?"0":"";e.setAttribute("tabindex",s),e.classList.toggle(d.interactive,t),e.classList.toggle(u.sourcesOpen,this._opened)}this._changeSet.has("attributionItems")&&(e.innerText=this.attributionItems?.map(e=>e.text).join(" | ")??"")}};e([a()],p.prototype,"attributionItems",void 0),e([a({readOnly:!0})],p.prototype,"surface",void 0),p=e([c("esri.views.Attribution")],p);export{p as Attribution};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{isSome as t,difference as s}from"../core/arrayUtils.js";import o from"../core/Collection.js";import{referenceSetter as i}from"../core/collectionUtils.js";import{EventedAccessor as n}from"../core/Evented.js";import r from"../core/Logger.js";import{getOrCreateMapValue as l}from"../core/MapUtils.js";import{removeMaybe as c}from"../core/maybe.js";import a from"../core/ReactiveMap.js";import{watch as h,on as u,initial as d}from"../core/reactiveUtils.js";import{symmetricDifference as f}from"../core/SetUtils.js";import{property as p,subclass as g}from"../core/accessorSupport/decorators.js";import{isSubtypeSublayer as y,isSubtypeGroupLayer as m,isKnowledgeGraphLayer as _,isMapImageLayer as v}from"../layers/support/layerUtils.js";import w from"../rest/support/Query.js";import{isSelectableLayer as S}from"./support/selectionUtils.js";let b=class extends n{constructor(e){super(e),this._selectionMap=new a,this._sources=new o,this._trashCan=[],this._layerEditHandles=new o,this._vizTaskId=0,this.view=null,this.showHighlight=!0,this.highlightName="default"}initialize(){this.addHandles([h(()=>[this.view,this.showHighlight],()=>this._refreshVisualization()),h(()=>this.view,e=>{e?.when().then(()=>this.syncSources())},d),u(()=>this.sources,"change",e=>{const t=this._selectionMap,s=[];for(const o of e.removed){const e=t.get(o);e&&(t.delete(o),e.highlightHandle?.remove(),s.push({layer:o,selection:[],added:[],removed:[...e.selection]}))}this._refreshListeners(),s.length&&this._onSelectionChange(s)},{onListenerAdd:()=>this._refreshListeners()})])}destroy(){this.clear(),this._layerEditHandles.drain(c)}get selections(){return Array.from(this._selectionMap.entries()).map(e=>{const[t,s]=e;return{layer:t,selection:[...s.selection]}})}get count(){let e=0;for(const t of this._selectionMap.values())e+=t.selection.length;return e}get hasSelection(){return this.count>0}get sources(){return this._sources}set sources(e){i(e,this._sources)}syncSources(){const e=new Set,t=this.view?.map;if(!t)return;const s=t=>{_(t)?(t.layers?.forEach(s),t.tables?.forEach(s)):v(t)?(t.sublayers?.forEach(s),t.subtables?.forEach(s)):m(t)?t.sublayers?.forEach(s):S(t)&&e.add(t)};t.allLayers.forEach(s),t.allTables.forEach(s),this.sources=[...e]}async getSelectedFeatures(e,s={},o="layerView"){const{view:i,selections:n}=this;if(!i&&"layerView"===o)return r.getLogger(this).warn("Cannot query layer views without a view."),[];const l=(e?.length?n.filter(t=>e.includes(t.layer)):n).map(async e=>{const{layer:t,selection:n}=e;if(!n.length)return;const r=y(t)?t.parent:t;if(null!=r){if(i&&"layerView"===o&&!j(r)&&E(r)){const e=await i.whenLayerView(r).catch(()=>null);if(e)return L(e,n,s)}return L(r,n,s)}}).filter(t);return(await Promise.all(l)).filter(t)}updateSelection(e){const t=new Map;for(const[s,n]of this._selectionMap)t.set(s,[...n.selection]);let o=!1;const i=e.current.concat(e.added);for(const s of i){const e=s.sourceLayer,i=s.getObjectId();if(this.sources.includes(e)&&(S(e)||y(e))&&null!==i){const s=l(t,e,()=>[]);s.includes(i)||(s.push(i),o=!0)}}for(const s of e.removed){const e=s.sourceLayer,i=s.getObjectId();if(this.sources.includes(e)&&(S(e)||y(e))&&null!==i){const s=t.get(e),n=s?.indexOf(i);void 0!==n&&n>=0&&(s?.splice(n,1),o=!0)}}if(o){const{_selectionMap:e,_trashCan:o}=this,i=[];for(const[n,r]of t){const t=e.get(n);void 0!==t&&o.push(t),e.set(n,{selection:r}),i.push({layer:n,selection:r,...s(void 0!==t?t.selection:[],r)})}this._onSelectionChange(i)}}setSelection(e,t){this._setSelection(e,t)}getSelection(e){const t=this._selectionMap.get(e);return t?.selection}appendToSelection(e,t){const s=this._selectionMap.get(e),o=void 0!==s?[...s.selection]:[];for(const i of t)o.includes(i)||o.push(i);this._setSelection(e,o)}removeFromSelection(e,t){const s=this._selectionMap.get(e);if(!s)return;const o=[];for(const i of s.selection)t.includes(i)||o.push(i);this._setSelection(e,o)}toggleInSelection(e,t){const s=this._selectionMap.get(e);if(!s||0===s.selection.length)return void this._setSelection(e,t);const o=new Set(s.selection),i=new Set(t),n=f(o,i);this._setSelection(e,Array.from(n))}clear(){const e=this._selectionMap.values();this._trashCan.push(...e);const t=[];for(const[s,o]of this._selectionMap.entries())t.push({layer:s,added:[],removed:[...o.selection],selection:[]});this._selectionMap.clear(),this._onSelectionChange(t)}_onSelectionChange(e){this._refreshVisualization(),this.emit("selection-change",{view:this.view,changes:e})}_refreshVisualization(){for(this._vizTaskId++;this._trashCan.length>0;){const e=this._trashCan.pop();e?.highlightHandle?.remove()}if(null==this.view)return;const{sources:e,view:t,_selectionMap:s,showHighlight:o}=this,i=this._vizTaskId;for(const n of e){const e=s.get(n),r=y(n)?n.parent:n;if(null!=r&&E(r)){if(j(r))continue;t.whenLayerView(r).then(t=>{e?.highlightHandle?.remove(),null!=e&&o&&i===this._vizTaskId&&"highlight"in t&&"function"==typeof t.highlight&&e.selection.length>0&&(e.highlightHandle=t.highlight(e.selection,this.highlightName))}).catch(()=>{e?.highlightHandle?.remove()})}}}_refreshListeners(){this._layerEditHandles.drain(c);const e=new Set(this.sources.map(e=>y(e)?e.parent:e));for(const t of e)S(t)&&"on"in t&&t.on&&this._layerEditHandles.push(t.on("edits",e=>this._onLayerEdit(e,t)))}_onLayerEdit(e,t){if(m(t))this._onParentLayerEdit(e,t);else if(e.deletedFeatures.length&&this._selectionMap.has(t)){const s=[];e.deletedFeatures.forEach(({error:e,objectId:t})=>{null!=t&&null==e&&s.push(t)}),this.removeFromSelection(t,s)}}_onParentLayerEdit(e,t){const{deletedFeatures:s,edits:o,updatedFeatures:i}=e;if(o?.updateFeatures?.forEach(e=>{const s=e.getObjectId()??e.attributes[t.objectIdField];if(null==s)return;if(i.find(e=>e.objectId===s)?.error)return;const o=t.findSublayerForFeature(e);if(!S(o))return;const n=t.sublayers.find(e=>!(!S(e)||!this.getSelection(e)?.includes(s)));S(n)&&n!==o&&(this.removeFromSelection(n,[s]),this.appendToSelection(o,[s]))}),s.length){const e=[];s.forEach(({error:t,objectId:s})=>{null!=s&&null==t&&e.push(s)}),t.sublayers.forEach(t=>{S(t)&&this._selectionMap.has(t)&&this.removeFromSelection(t,e)})}}_setSelection(e,t){if(!this.sources.includes(e))throw new Error(`Cannot set selection on layer ${e.title} because it is not in 'sources'`);const o=this._selectionMap.get(e);if(void 0===o||!F(o,{selection:t})){void 0!==o&&this._trashCan.push(o),this._selectionMap.set(e,{selection:[...t]});const i={layer:e,selection:[...t],...s(void 0!==o?o.selection:[],t)};this._onSelectionChange([i])}}};e([p()],b.prototype,"_selectionMap",void 0),e([p()],b.prototype,"_sources",void 0),e([p({readOnly:!0,nonNullable:!0})],b.prototype,"selections",null),e([p({readOnly:!0,nonNullable:!0})],b.prototype,"count",null),e([p()],b.prototype,"view",void 0),e([p({readOnly:!0,nonNullable:!0})],b.prototype,"hasSelection",null),e([p()],b.prototype,"showHighlight",void 0),e([p()],b.prototype,"sources",null),e([p()],b.prototype,"highlightName",void 0),b=e([g("esri.views.SelectionManager")],b);const j=e=>y(e)?!0===e.parent?.isTable:e.isTable,M=e=>void 0!==e.layer,E=e=>void 0!==e?.when,F=(e,t)=>{if(null==e&&null==t)return!0;if(null!=e&&null==t||null==e&&null!=t)return!1;if(null!=e&&null!=t&&null!=e.selection&&null!=t.selection){const s=[...e.selection],o=[...t.selection];if(s.length!==o.length)return!1;s.sort(),o.sort();for(let e=0;e<s.length;e++)if(s[e]!==o[e])return!1}return!0},L=async(e,t,s={})=>{let o;if(M(e)){const i=e;o=void 0===i?null:await i.queryFeatures(new w({...s,objectIds:t})).then(t=>({data:t,layer:e.layer}))}else{const i=e;o=void 0===i?null:await i.queryFeatures(new w({...s,objectIds:t})).then(e=>({data:e,layer:i}))}return o},C=b;export{C as default};
5
+ import{__decorate as e}from"tslib";import{isSome as t,difference as s}from"../core/arrayUtils.js";import i from"../core/Collection.js";import{referenceSetter as o}from"../core/collectionUtils.js";import{deprecatedProperty as n}from"../core/deprecate.js";import{EventedAccessor as r}from"../core/Evented.js";import l from"../core/Logger.js";import{getOrCreateMapValue as c}from"../core/MapUtils.js";import{removeMaybe as h}from"../core/maybe.js";import a from"../core/ReactiveMap.js";import{watch as u,on as d,initial as p}from"../core/reactiveUtils.js";import{symmetricDifference as f}from"../core/SetUtils.js";import{property as g,subclass as y}from"../core/accessorSupport/decorators.js";import{isSubtypeSublayer as m,isSubtypeGroupLayer as _,isKnowledgeGraphLayer as v,isMapImageLayer as w}from"../layers/support/layerUtils.js";import S from"../rest/support/Query.js";import{isISelectableLayer as b}from"./support/selectionUtils.js";let E=class extends r{constructor(e){super(e),this._layerEditHandles=new i,this._selectionMap=new a,this._sources=new i,this._trashCan=[],this._vizTaskId=0,this.highlightEnabled=!0,this.highlightName="default",this.view=null}initialize(){this.addHandles([u(()=>[this.view,this.highlightEnabled],()=>this._refreshVisualization()),u(()=>this.view,e=>{e?.when().then(()=>this.syncSources())},p),d(()=>this.sources,"change",e=>{const t=this._selectionMap,s=[];for(const i of e.removed){const e=t.get(i);e&&(t.delete(i),e.highlightHandle?.remove(),s.push({layer:i,selection:[],added:[],removed:[...e.selection]}))}this._refreshListeners(),s.length&&this._onSelectionChange(s)},{onListenerAdd:()=>this._refreshListeners()})])}destroy(){this.clear(),this._layerEditHandles.drain(h)}get count(){let e=0;for(const t of this._selectionMap.values())e+=t.selection.length;return e}get hasSelection(){return this.count>0}get selections(){return Array.from(this._selectionMap.entries()).map(e=>{const[t,s]=e;return{layer:t,selection:[...s.selection]}})}get showHighlight(){return this.highlightEnabled}set showHighlight(e){n(l.getLogger(this),"showHighlight",{replacement:"highlightEnabled"}),this.highlightEnabled=e}get sources(){return this._sources}set sources(e){o(e,this._sources)}clear(){const e=this._selectionMap.values();this._trashCan.push(...e);const t=[];for(const[s,i]of this._selectionMap.entries())t.push({layer:s,added:[],removed:[...i.selection],selection:[]});this._selectionMap.clear(),this._onSelectionChange(t)}getSelection(e){return this._selectionMap.get(e)?.selection}syncSources(){const e=new Set,t=this.view?.map;if(!t)return;const s=t=>{v(t)?(t.layers?.forEach(s),t.tables?.forEach(s)):w(t)?(t.sublayers?.forEach(s),t.subtables?.forEach(s)):_(t)?t.sublayers?.forEach(s):b(t)&&e.add(t)};t.allLayers.forEach(s),t.allTables.forEach(s),this.sources=[...e]}async getSelectedFeatures(e,s={},i="layerView"){const{view:o,selections:n}=this;if(!o&&"layerView"===i)return l.getLogger(this).warn("Cannot query layer views without a view."),[];const r=(e?.length?n.filter(t=>e.includes(t.layer)):n).map(async e=>{const{layer:t,selection:n}=e;if(!n.length)return;const r=m(t)?t.parent:t;if(null!=r){if(o&&"layerView"===i&&!j(r)&&L(r)){const e=await o.whenLayerView(r).catch(()=>null);if(e)return C(e,n,s)}return C(r,n,s)}}).filter(t);return(await Promise.all(r)).filter(t)}updateSelection(e){const t=new Map;for(const[s,n]of this._selectionMap)t.set(s,[...n.selection]);let i=!1;const o=e.current.concat(e.added);for(const s of o){const e=s.sourceLayer,o=s.getObjectId();if(this.sources.includes(e)&&(b(e)||m(e))&&null!==o){const s=c(t,e,()=>[]);s.includes(o)||(s.push(o),i=!0)}}for(const s of e.removed){const e=s.sourceLayer,o=s.getObjectId();if(this.sources.includes(e)&&(b(e)||m(e))&&null!==o){const s=t.get(e),n=s?.indexOf(o);void 0!==n&&n>=0&&(s?.splice(n,1),i=!0)}}if(i){const{_selectionMap:e,_trashCan:i}=this,o=[];for(const[n,r]of t){const t=e.get(n);void 0!==t&&i.push(t),e.set(n,{selection:r}),o.push({layer:n,selection:r,...s(void 0!==t?t.selection:[],r)})}this._onSelectionChange(o)}}setSelection(e,t){this._setSelection(e,t)}appendToSelection(e,t){const s=this._selectionMap.get(e),i=void 0!==s?[...s.selection]:[];for(const o of t)i.includes(o)||i.push(o);this._setSelection(e,i)}removeFromSelection(e,t){const s=this._selectionMap.get(e);if(!s)return;const i=[];for(const o of s.selection)t.includes(o)||i.push(o);this._setSelection(e,i)}toggleInSelection(e,t){const s=this._selectionMap.get(e);if(!s||0===s.selection.length)return void this._setSelection(e,t);const i=new Set(s.selection),o=new Set(t),n=f(i,o);this._setSelection(e,Array.from(n))}_onSelectionChange(e){this._refreshVisualization(),this.emit("selection-change",{view:this.view,changes:e})}_refreshVisualization(){for(this._vizTaskId++;this._trashCan.length>0;){const e=this._trashCan.pop();e?.highlightHandle?.remove()}if(null==this.view)return;const{sources:e,view:t,_selectionMap:s,highlightEnabled:i}=this,o=this._vizTaskId;for(const n of e){const e=s.get(n),r=m(n)?n.parent:n;if(null!=r&&L(r)){if(j(r))continue;t.whenLayerView(r).then(t=>{e?.highlightHandle?.remove(),null!=e&&i&&o===this._vizTaskId&&"highlight"in t&&"function"==typeof t.highlight&&e.selection.length>0&&(e.highlightHandle=t.highlight(e.selection,this.highlightName))}).catch(()=>{e?.highlightHandle?.remove()})}}}_refreshListeners(){this._layerEditHandles.drain(h);const e=new Set(this.sources.map(e=>m(e)?e.parent:e));for(const t of e)b(t)&&"on"in t&&t.on&&this._layerEditHandles.push(t.on("edits",e=>this._onLayerEdit(e,t)))}_onLayerEdit(e,t){if(_(t))this._onParentLayerEdit(e,t);else if(e.deletedFeatures.length&&this._selectionMap.has(t)){const s=[];e.deletedFeatures.forEach(({error:e,objectId:t})=>{null!=t&&null==e&&s.push(t)}),this.removeFromSelection(t,s)}}_onParentLayerEdit(e,t){const{deletedFeatures:s,edits:i,updatedFeatures:o}=e;if(i?.updateFeatures?.forEach(e=>{const s=e.getObjectId()??e.attributes[t.objectIdField];if(null==s)return;if(o.find(e=>e.objectId===s)?.error)return;const i=t.findSublayerForFeature(e);if(!b(i))return;const n=t.sublayers.find(e=>!(!b(e)||!this.getSelection(e)?.includes(s)));b(n)&&n!==i&&(this.removeFromSelection(n,[s]),this.appendToSelection(i,[s]))}),s.length){const e=[];s.forEach(({error:t,objectId:s})=>{null!=s&&null==t&&e.push(s)}),t.sublayers.forEach(t=>{b(t)&&this._selectionMap.has(t)&&this.removeFromSelection(t,e)})}}_setSelection(e,t){if(!this.sources.includes(e))throw new Error(`Cannot set selection on layer ${e.title} because it is not in 'sources'`);const i=this._selectionMap.get(e);if(void 0===i||!F(i,{selection:t})){void 0!==i&&this._trashCan.push(i),this._selectionMap.set(e,{selection:[...t]});const o={layer:e,selection:[...t],...s(void 0!==i?i.selection:[],t)};this._onSelectionChange([o])}}};e([g()],E.prototype,"_selectionMap",void 0),e([g()],E.prototype,"_sources",void 0),e([g({readOnly:!0,nonNullable:!0})],E.prototype,"count",null),e([g({readOnly:!0,nonNullable:!0})],E.prototype,"hasSelection",null),e([g()],E.prototype,"highlightEnabled",void 0),e([g()],E.prototype,"highlightName",void 0),e([g({readOnly:!0,nonNullable:!0})],E.prototype,"selections",null),e([g()],E.prototype,"showHighlight",null),e([g()],E.prototype,"sources",null),e([g()],E.prototype,"view",void 0),E=e([y("esri.views.SelectionManager")],E);const j=e=>m(e)?!0===e.parent?.isTable:e.isTable,M=e=>void 0!==e.layer,L=e=>void 0!==e?.when,F=(e,t)=>{if(null==e&&null==t)return!0;if(null!=e&&null==t||null==e&&null!=t)return!1;if(null!=e&&null!=t&&null!=e.selection&&null!=t.selection){const s=[...e.selection],i=[...t.selection];if(s.length!==i.length)return!1;s.sort(),i.sort();for(let e=0;e<s.length;e++)if(s[e]!==i[e])return!1}return!0},C=async(e,t,s={})=>{let i;if(M(e)){const o=e;i=void 0===o?null:await o.queryFeatures(new S({...s,objectIds:t})).then(t=>({data:t,layer:e.layer}))}else{const o=e;i=void 0===o?null:await o.queryFeatures(new S({...s,objectIds:t})).then(e=>({data:e,layer:o}))}return i},H=E;export{H as default};