@arcgis/core 4.34.0-next.54 → 4.34.0-next.55

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 (289) hide show
  1. package/analysis/ElevationProfile/ElevationProfileGroundLine.d.ts +4 -0
  2. package/analysis/ElevationProfile/ElevationProfileGroundLine.js +5 -0
  3. package/analysis/ElevationProfile/ElevationProfileInputLine.d.ts +4 -0
  4. package/analysis/ElevationProfile/ElevationProfileInputLine.js +5 -0
  5. package/analysis/ElevationProfile/ElevationProfileLine.d.ts +4 -0
  6. package/analysis/ElevationProfile/ElevationProfileLine.js +5 -0
  7. package/analysis/ElevationProfile/ElevationProfileLineChartOptions.d.ts +4 -0
  8. package/analysis/ElevationProfile/{LineChartOptions.js → ElevationProfileLineChartOptions.js} +1 -1
  9. package/analysis/ElevationProfile/ElevationProfileLineViewOptions.d.ts +4 -0
  10. package/analysis/ElevationProfile/{LineViewOptions.js → ElevationProfileLineViewOptions.js} +1 -1
  11. package/analysis/ElevationProfile/ElevationProfileQueryLine.d.ts +4 -0
  12. package/analysis/ElevationProfile/ElevationProfileQueryLine.js +5 -0
  13. package/analysis/ElevationProfile/ElevationProfileSceneLine.d.ts +4 -0
  14. package/analysis/ElevationProfile/ElevationProfileSceneLine.js +5 -0
  15. package/analysis/ElevationProfile/ElevationProfileUnits.d.ts +4 -0
  16. package/analysis/ElevationProfile/{Units.js → ElevationProfileUnits.js} +1 -1
  17. package/analysis/ElevationProfile/ElevationProfileViewOptions.d.ts +4 -0
  18. package/analysis/ElevationProfile/{ViewOptions.js → ElevationProfileViewOptions.js} +1 -1
  19. package/analysis/ElevationProfile/elevationProfileLineTypes.js +1 -1
  20. package/analysis/ElevationProfileAnalysis.js +1 -1
  21. package/applications/KnowledgeStudio/resourceSerializationUtils.js +1 -1
  22. package/assets/esri/core/workers/RemoteClient.js +1 -1
  23. package/assets/esri/core/workers/chunks/01e8b9dc77a57d1c2a52.js +1 -0
  24. package/assets/esri/core/workers/chunks/027cfcde29fe87aa2ffe.js +1 -0
  25. package/assets/esri/core/workers/chunks/18ceea59e469a0f2721b.js +1 -0
  26. package/assets/esri/core/workers/chunks/199a17b0a0f75cbaed16.js +1 -0
  27. package/assets/esri/core/workers/chunks/1eee7cf11df01a52c1bf.js +1 -0
  28. package/assets/esri/core/workers/chunks/{ac41b882f9cbf8d56f0c.js → 222f981e876f60ae282f.js} +1 -1
  29. package/assets/esri/core/workers/chunks/22334a464f798b5279b2.js +1 -0
  30. package/assets/esri/core/workers/chunks/{99b9392946d776a62997.js → 23e600e368ac829680b5.js} +1 -1
  31. package/assets/esri/core/workers/chunks/24ac204d8a045aa821be.js +1 -0
  32. package/assets/esri/core/workers/chunks/252ee00fd6c4ae0ee7fa.js +1 -0
  33. package/assets/esri/core/workers/chunks/27197b0a2ffb2b6104ea.js +1 -0
  34. package/assets/esri/core/workers/chunks/{93af38d29d066f27ed28.js → 2cb14d040e67a261b31c.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{0021118bafefd1e47ff7.js → 31c088966ccfff2ea1db.js} +1 -1
  36. package/assets/esri/core/workers/chunks/3b51b61a7b8a1ef87c9b.js +1 -0
  37. package/assets/esri/core/workers/chunks/3d800fbc449bea18b1cd.js +1 -0
  38. package/assets/esri/core/workers/chunks/4874aabdb5c60ca66216.js +1 -0
  39. package/assets/esri/core/workers/chunks/4d2473e680324dc17cfa.js +1 -0
  40. package/assets/esri/core/workers/chunks/{2da12a64d3baef4aaaa1.js → 4f8dab492331c9a2d67a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/527557b603400189d49a.js +1 -0
  42. package/assets/esri/core/workers/chunks/{4bd92232928b832dea76.js → 5900dde7a201a7d47469.js} +1 -1
  43. package/assets/esri/core/workers/chunks/62ade6f18b375795ddfd.js +1 -0
  44. package/assets/esri/core/workers/chunks/63f3e46bfa820436161c.js +1 -0
  45. package/assets/esri/core/workers/chunks/{b0ee061747bef6729bb9.js → 6801b92bce7a918fda6f.js} +1 -1
  46. package/assets/esri/core/workers/chunks/6940bb6524938894a246.js +1 -0
  47. package/assets/esri/core/workers/chunks/6b11476b2004b4db576e.js +1 -0
  48. package/assets/esri/core/workers/chunks/71cac356874b36f9a383.js +1 -0
  49. package/assets/esri/core/workers/chunks/{69dc5a7abc1fda2474ad.js → 722931d1a60be461e521.js} +1 -1
  50. package/assets/esri/core/workers/chunks/79ab06fb4c91ac8da323.js +1 -0
  51. package/assets/esri/core/workers/chunks/{0a4357af5b8c0532b439.js → 7bdfc7c7ce1d94c00745.js} +1 -1
  52. package/assets/esri/core/workers/chunks/{0ce671588de2858516d2.js → 83737d86584bf1b32368.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{98ea12c7a000a30f3dc0.js → 87f68c2b9361bd3f8cac.js} +1 -1
  54. package/assets/esri/core/workers/chunks/97ae2fdb6cb98249f5fa.js +1 -0
  55. package/assets/esri/core/workers/chunks/9a20390602126995f831.js +1 -0
  56. package/assets/esri/core/workers/chunks/9cdeead9d444e8d95477.js +1 -0
  57. package/assets/esri/core/workers/chunks/a778a72456fefdf40115.js +1 -0
  58. package/assets/esri/core/workers/chunks/a999f804fc2f00b2e7ae.js +1 -0
  59. package/assets/esri/core/workers/chunks/ae73ac81bd10614c2b53.js +1 -0
  60. package/assets/esri/core/workers/chunks/c7d4c296011c5393bcaa.js +1 -0
  61. package/assets/esri/core/workers/chunks/c86e339e45900c54c9f5.js +1 -0
  62. package/assets/esri/core/workers/chunks/{a1d3f1c221389eb6090c.js → c95e6bef8c97cf647869.js} +1 -1
  63. package/assets/esri/core/workers/chunks/cbec768cd98caff212f2.js +1 -0
  64. package/assets/esri/core/workers/chunks/d81c4afad4abe2d1d0b9.js +1 -0
  65. package/assets/esri/core/workers/chunks/dfb12f42b8d319ffa5fc.js +1 -0
  66. package/assets/esri/core/workers/chunks/e04951ee32f041faaeca.js +1 -0
  67. package/assets/esri/core/workers/chunks/e982cf44906eb26164f2.js +1 -0
  68. package/assets/esri/core/workers/chunks/{081b22fa73ef7b696409.js → ead1acf95c3385630da8.js} +2 -2
  69. package/assets/esri/core/workers/chunks/f1c50f37a81c672263a1.js +1 -0
  70. package/assets/esri/core/workers/chunks/fe5c37c69da3ec1e56ac.js +1 -0
  71. package/assets/esri/core/workers/chunks/ff323db554c9e09749e8.js +1 -0
  72. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  73. package/chunks/Laserlines.glsl.js +1 -1
  74. package/chunks/LineSeries.js +1 -1
  75. package/chunks/Theme.js +1 -1
  76. package/chunks/boundedPlane.js +1 -1
  77. package/chunks/bundle.js +1 -1
  78. package/chunks/chartUtilsAm5.js +1 -1
  79. package/chunks/sphere.js +1 -1
  80. package/chunks/vec42.js +1 -1
  81. package/config.js +1 -1
  82. package/core/ArrayPool.js +1 -1
  83. package/core/Collection.js +1 -1
  84. package/core/ObjectPool.js +1 -1
  85. package/core/accessorSupport/Properties.js +1 -1
  86. package/core/accessorSupport/watch.js +1 -1
  87. package/core/arrayUtils.js +1 -1
  88. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  89. package/core/libs/gl-matrix-2/math/vec4.js +1 -1
  90. package/core/pbf.js +1 -1
  91. package/core/typedArrayUtil.js +1 -1
  92. package/geohash/GeohashCell.js +1 -1
  93. package/geohash/GeohashTree.js +1 -1
  94. package/geometry/support/DoubleArray.js +1 -1
  95. package/geometry/support/boundedPlane.js +1 -1
  96. package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
  97. package/geometry/support/sphere.js +1 -1
  98. package/interfaces.d.ts +141 -139
  99. package/kernel.js +1 -1
  100. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  101. package/layers/graphics/sources/ParquetSource.js +1 -1
  102. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  103. package/package.json +1 -1
  104. package/rest/knowledgeGraphService.js +1 -1
  105. package/support/revision.js +1 -1
  106. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  107. package/views/2d/engine/Container.js +1 -1
  108. package/views/2d/engine/DisplayObject.js +1 -1
  109. package/views/2d/engine/flow/dataUtils.js +1 -1
  110. package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
  111. package/views/2d/engine/webgl/DisplayEntity.js +1 -1
  112. package/views/2d/engine/webgl/DisplayRecord.js +1 -1
  113. package/views/2d/engine/webgl/FeatureDisplayList.js +1 -1
  114. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  115. package/views/2d/engine/webgl/PooledUint32Array.js +1 -1
  116. package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
  117. package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
  118. package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
  119. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  120. package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
  121. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  122. package/views/2d/layers/features/FeatureContainer.js +1 -1
  123. package/views/2d/layers/features/FeaturePipelineWorker.js +1 -1
  124. package/views/2d/layers/features/FeatureSourceEventLog.js +1 -1
  125. package/views/2d/layers/features/FeatureSpatialIndex.js +1 -1
  126. package/views/2d/layers/features/Processor.js +1 -1
  127. package/views/2d/layers/features/RenderState.js +1 -1
  128. package/views/2d/layers/features/aggregation/AccumulatedStatistics.js +1 -1
  129. package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
  130. package/views/2d/layers/features/aggregation/GridCell.js +1 -1
  131. package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
  132. package/views/2d/layers/features/processor/AProcessorStrategy.js +1 -1
  133. package/views/2d/layers/features/schema/processor/LabelMatcherSchema.js +1 -1
  134. package/views/2d/layers/features/schema/processor/symbols/ComplexSymbolSchema.js +1 -1
  135. package/views/2d/layers/features/schema/processor/symbols/SymbolSchema.js +1 -1
  136. package/views/2d/layers/features/sources/FeatureSource.js +1 -1
  137. package/views/2d/layers/features/sources/strategies/chunks/ASourceChunk.js +1 -1
  138. package/views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js +1 -1
  139. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  140. package/views/2d/layers/features/support/DisplayIdGenerator.js +1 -1
  141. package/views/2d/layers/features/support/FeatureSetCache.js +1 -1
  142. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  143. package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
  144. package/views/2d/layers/features/support/FeatureSetReaderPBFHeader.js +1 -1
  145. package/views/2d/layers/features/support/StaticBitSet.js +1 -1
  146. package/views/2d/tiling/TileCoverage.js +1 -1
  147. package/views/2d/tiling/TileKey.js +1 -1
  148. package/views/3d/FocusAreasView.js +1 -1
  149. package/views/3d/analysis/ElevationProfile/{HoveredPointVisualization.js → ElevationProfileHoveredPointVisualization.js} +1 -1
  150. package/views/3d/analysis/ElevationProfile/ElevationProfileHoveredPointsVisualization.js +5 -0
  151. package/views/3d/analysis/ElevationProfile/ElevationProfileInputVisualization.js +5 -0
  152. package/views/3d/analysis/ElevationProfile/ElevationProfileLinesVisualization.js +5 -0
  153. package/views/3d/analysis/ElevationProfile/ElevationProfileSceneLineComputation.js +5 -0
  154. package/views/3d/analysis/ElevationProfile/ElevationProfileVisualization.js +5 -0
  155. package/views/3d/analysis/ElevationProfileAnalysisView3D.js +1 -1
  156. package/views/3d/analysis/Slice/SliceController.js +1 -1
  157. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  158. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  159. package/views/3d/camera/constraintUtils/distance.js +1 -1
  160. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
  161. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  162. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  163. package/views/3d/layers/I3SMeshView3D.js +1 -1
  164. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  165. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  166. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  167. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  168. package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
  169. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  170. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  171. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +1 -1
  172. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  173. package/views/3d/layers/i3s/I3SIndex.js +1 -1
  174. package/views/3d/layers/i3s/I3SNode.js +1 -1
  175. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  176. package/views/3d/state/ViewState.js +1 -1
  177. package/views/3d/state/ViewStateManager.js +1 -1
  178. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  179. package/views/3d/support/ViewSlice.js +1 -1
  180. package/views/3d/support/orientedBoundingBox.js +1 -1
  181. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  182. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  183. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  184. package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
  185. package/views/3d/terrain/ScaleRangeQueries.js +1 -1
  186. package/views/3d/terrain/SphericalPatch.js +1 -1
  187. package/views/3d/terrain/TerrainRenderer.js +1 -1
  188. package/views/3d/terrain/TerrainSurface.js +1 -1
  189. package/views/3d/terrain/Tile.js +1 -1
  190. package/views/3d/terrain/TilePerLayerInfo.js +1 -1
  191. package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
  192. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  193. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  194. package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
  195. package/views/3d/webgl-engine/lib/SliceHelper.js +1 -1
  196. package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
  197. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  198. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  199. package/views/3d/webgl-engine/lib/lodRendering/InstanceOctree.js +1 -1
  200. package/views/3d/webgl-engine/lib/octreeUtils.js +1 -1
  201. package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
  202. package/views/analysis/ElevationProfile/ElevationProfileController.js +5 -0
  203. package/views/analysis/ElevationProfile/{ProfileGenerationError.js → ElevationProfileGenerationError.js} +1 -1
  204. package/views/analysis/ElevationProfile/ElevationProfileGroundLineComputation.js +5 -0
  205. package/views/analysis/ElevationProfile/ElevationProfileInputLineComputation.js +5 -0
  206. package/views/analysis/ElevationProfile/ElevationProfileLineComputation.js +5 -0
  207. package/views/analysis/ElevationProfile/ElevationProfileQueryLineComputation.js +5 -0
  208. package/views/analysis/ElevationProfile/ElevationProfileResult.d.ts +4 -0
  209. package/views/analysis/ElevationProfile/ElevationProfileResult.js +5 -0
  210. package/views/analysis/ElevationProfile/elevationProfileGenerationUtils.js +5 -0
  211. package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +5 -0
  212. package/views/input/InputManager.js +1 -1
  213. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  214. package/views/interactive/sketch/constraints.js +1 -1
  215. package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
  216. package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
  217. package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
  218. package/views/layers/FeatureLayerView.js +1 -1
  219. package/views/support/PropertiesPool.js +1 -1
  220. package/widgets/ElevationProfile/ElevationProfileLine.d.ts +2 -2
  221. package/analysis/ElevationProfile/GroundLine.d.ts +0 -4
  222. package/analysis/ElevationProfile/GroundLine.js +0 -5
  223. package/analysis/ElevationProfile/InputLine.d.ts +0 -4
  224. package/analysis/ElevationProfile/InputLine.js +0 -5
  225. package/analysis/ElevationProfile/Line.d.ts +0 -4
  226. package/analysis/ElevationProfile/Line.js +0 -5
  227. package/analysis/ElevationProfile/LineChartOptions.d.ts +0 -4
  228. package/analysis/ElevationProfile/LineViewOptions.d.ts +0 -4
  229. package/analysis/ElevationProfile/QueryLine.d.ts +0 -4
  230. package/analysis/ElevationProfile/QueryLine.js +0 -5
  231. package/analysis/ElevationProfile/SceneLine.d.ts +0 -4
  232. package/analysis/ElevationProfile/SceneLine.js +0 -5
  233. package/analysis/ElevationProfile/Units.d.ts +0 -4
  234. package/analysis/ElevationProfile/ViewOptions.d.ts +0 -4
  235. package/assets/esri/core/workers/chunks/14c6ae4feb4859cfa7c5.js +0 -1
  236. package/assets/esri/core/workers/chunks/20a2b3d1f826e9059884.js +0 -1
  237. package/assets/esri/core/workers/chunks/250b1629becca0410f2a.js +0 -1
  238. package/assets/esri/core/workers/chunks/2efa4d8fe5454f8b2a05.js +0 -1
  239. package/assets/esri/core/workers/chunks/3149a86cd25684dcb0b3.js +0 -1
  240. package/assets/esri/core/workers/chunks/38f84294fb2fb4663ba5.js +0 -1
  241. package/assets/esri/core/workers/chunks/3eb3af0b6cf3c2f28131.js +0 -1
  242. package/assets/esri/core/workers/chunks/43bd338bb0de375b9bb7.js +0 -1
  243. package/assets/esri/core/workers/chunks/4622a3e64d3c4aafa56b.js +0 -1
  244. package/assets/esri/core/workers/chunks/47f2e905ef42e36897aa.js +0 -1
  245. package/assets/esri/core/workers/chunks/50e9eafb118d2a221f10.js +0 -1
  246. package/assets/esri/core/workers/chunks/55588e668b6acb6aa390.js +0 -1
  247. package/assets/esri/core/workers/chunks/5b112471dca94b2e8462.js +0 -1
  248. package/assets/esri/core/workers/chunks/5dfe1aed10095385c066.js +0 -1
  249. package/assets/esri/core/workers/chunks/5fc414fc2cfc68828c5b.js +0 -1
  250. package/assets/esri/core/workers/chunks/7389841fabe0f319f1e5.js +0 -1
  251. package/assets/esri/core/workers/chunks/8e0559cc6295008fcdf7.js +0 -1
  252. package/assets/esri/core/workers/chunks/944fa8261aad94ae0542.js +0 -1
  253. package/assets/esri/core/workers/chunks/9639a6f6fab52a501bf7.js +0 -1
  254. package/assets/esri/core/workers/chunks/9e479e7e2e51476c3d27.js +0 -1
  255. package/assets/esri/core/workers/chunks/a1e179dd6de9c8769b02.js +0 -1
  256. package/assets/esri/core/workers/chunks/a6493607b98783bf1ef2.js +0 -1
  257. package/assets/esri/core/workers/chunks/a829969ed44cdb814f27.js +0 -1
  258. package/assets/esri/core/workers/chunks/b2a035befeeff1a55ad8.js +0 -1
  259. package/assets/esri/core/workers/chunks/b4251e10621fb3ad03a3.js +0 -1
  260. package/assets/esri/core/workers/chunks/b9f5672093727c6f92c9.js +0 -1
  261. package/assets/esri/core/workers/chunks/ba45dccb4dab5a74d224.js +0 -1
  262. package/assets/esri/core/workers/chunks/cda27c0fafd687dfa72e.js +0 -1
  263. package/assets/esri/core/workers/chunks/ddd6597a66ec6b972f9c.js +0 -1
  264. package/assets/esri/core/workers/chunks/e28d3ed65c3a76a044c8.js +0 -1
  265. package/assets/esri/core/workers/chunks/e3f68f7b408a08d7cd5d.js +0 -1
  266. package/assets/esri/core/workers/chunks/e9716995ce0c3683eafc.js +0 -1
  267. package/assets/esri/core/workers/chunks/ed25bf087f52e5d3e71b.js +0 -1
  268. package/assets/esri/core/workers/chunks/ee0286b5f5475f2d853f.js +0 -1
  269. package/assets/esri/core/workers/chunks/f8505bf69795f5293a79.js +0 -1
  270. package/assets/esri/core/workers/chunks/f92e608931b1c168cb45.js +0 -1
  271. package/views/3d/analysis/ElevationProfile/HoveredPointsVisualization.js +0 -5
  272. package/views/3d/analysis/ElevationProfile/InputVisualization.js +0 -5
  273. package/views/3d/analysis/ElevationProfile/ProfileLinesVisualization.js +0 -5
  274. package/views/3d/analysis/ElevationProfile/SceneLineComputation.js +0 -5
  275. package/views/3d/analysis/ElevationProfile/Visualization.js +0 -5
  276. package/views/analysis/ElevationProfile/Controller.js +0 -5
  277. package/views/analysis/ElevationProfile/GroundLineComputation.js +0 -5
  278. package/views/analysis/ElevationProfile/InputLineComputation.js +0 -5
  279. package/views/analysis/ElevationProfile/LineComputation.js +0 -5
  280. package/views/analysis/ElevationProfile/QueryLineComputation.js +0 -5
  281. package/views/analysis/ElevationProfile/Result.d.ts +0 -4
  282. package/views/analysis/ElevationProfile/Result.js +0 -5
  283. package/views/analysis/ElevationProfile/geometryUtils.js +0 -5
  284. package/views/analysis/ElevationProfile/profileGenerationUtils.js +0 -5
  285. /package/views/analysis/ElevationProfile/{elevationQuerySourceUtils.js → elevationProfileQuerySourceUtils.js} +0 -0
  286. /package/views/analysis/ElevationProfile/{statisticsUtils.js → elevationProfileStatisticsUtils.js} +0 -0
  287. /package/views/analysis/ElevationProfile/{traversalUtils.js → elevationProfileTraversalUtils.js} +0 -0
  288. /package/views/analysis/ElevationProfile/{unitUtils.js → elevationProfileUnitUtils.js} +0 -0
  289. /package/views/analysis/ElevationProfile/{visualizationUtils.js → elevationProfileVisualizationUtils.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{isSome as i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import r from"../../../../core/Error.js";import s from"../../../../core/Logger.js";import{findInMap as a}from"../../../../core/MapUtils.js";import{abortMaybe as n,removeMaybe as o,destroyMaybe as l,disposeMaybe as h}from"../../../../core/maybe.js";import{MinPriority as d}from"../../../../core/MemCache.js";import p from"../../../../core/PooledArray.js";import{throwIfAborted as c,ignoreAbortErrors as y,createResolver as u,isAbortError as g}from"../../../../core/promiseUtils.js";import{when as m,watch as b,on as _,syncAndInitial as f,whenOnce as v}from"../../../../core/reactiveUtils.js";import{schedule as C}from"../../../../core/scheduling.js";import{property as S}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as G,isEmpty as x}from"../../../../core/accessorSupport/diffUtils.js";import{i as P,f as R,g as U}from"../../../../chunks/vec32.js";import{create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import I from"../../../../geometry/Extent.js";import E from"../../../../geometry/Point.js";import{canProjectWithoutEngine as L}from"../../../../geometry/projectionUtils.js";import{projectBuffer as V}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as j}from"../../../../geometry/projection/projectVectorToVector.js";import{projectXYZToVector as O}from"../../../../geometry/projection/projectXYZToVector.js";import{center as A,create as F,fromRect as T,equals as M}from"../../../../geometry/support/aaBoundingBox.js";import{create as k}from"../../../../geometry/support/aaBoundingRect.js";import{equals as z}from"../../../../geometry/support/spatialReferenceUtils.js";import W from"../../../../layers/Layer.js";import{getObjectId as H,computeAABB as B,hasGeometry as q}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as Q}from"../../../../layers/graphics/hydratedFeatures.js";import N from"../../../../renderers/UniqueValueRenderer.js";import{isSupportedRenderer3D as $,validateTo3D as Z}from"../../../../renderers/support/rendererConversion.js";import{RenderingInfo as Y}from"../../../../renderers/support/RenderingInfo.js";import{isBasemapLayerView as X}from"../../../../support/basemapUtils.js";import{loadArcade as J}from"../../../../support/loadArcade.js";import K from"../../../../symbols/LabelSymbol3D.js";import ee from"../../../../symbols/TextSymbol.js";import te from"../../../../symbols/WebStyleSymbol.js";import{getDefaultSymbol3D as ie}from"../../../../symbols/support/defaults3D.js";import{to3D as re}from"../../../../symbols/support/symbolConversion.js";import{averageSymbolComplexities as se,defaultSymbolComplexity as ae}from"./defaultSymbolComplexity.js";import{DisplayFeatureLimit as ne}from"./DisplayFeatureLimit.js";import{ViewElevationProvider as oe}from"./ElevationQuery.js";import{extractExpressionInfo as le,createContext as he}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as de}from"./Graphics3DFeatureStore.js";import{Graphics3DGraphicCreationContext as pe}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as ce}from"./Graphics3DSymbolCreationContext.js";import{make as ye}from"./Graphics3DSymbolFactory.js";import{Graphics3DWebStyleSymbol as ue}from"./Graphics3DWebStyleSymbol.js";import{GraphicsCorePerformanceInfo as ge}from"./GraphicsCorePerformanceInfo.js";import{GraphicStateTracking as me}from"./GraphicStateTracking.js";import{computeCentroid as be}from"./graphicUtils.js";import{SpatialIndex2D as _e}from"./SpatialIndex2D.js";import{StageLayerElevationProvider as fe}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as ve}from"../../support/extentUtils.js";import{GridLocalOriginFactory as Ce}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{affectsGeometry as Se}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as we}from"../../webgl-engine/lib/WebGLLayer.js";import{hasPopupTemplate as Ge}from"../../../layers/support/popupUtils.js";import{PromiseQueue as xe}from"../../../support/PromiseQueue.js";import{PropertiesPool as Pe}from"../../../support/PropertiesPool.js";import{ImmediateTask as Re,noBudget as Ue,TaskPriority as De}from"../../../support/Scheduler.js";import{TextureCompressionTracker as Ie}from"../../../support/TextureCompressionTracker.js";import{Yield as Ee}from"../../../support/Yield.js";import{alphaCutoff as Le}from"../../../../webscene/support/AlphaCutoff.js";var Ve;const je=D(),Oe=F();let Ae=class extends t{static{Ve=this}static{this.tmpVec=D()}get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new _e({objectIdField:this.owner.layer?.objectIdField,spatialReference:this._viewSpatialReference,hasZ:!!this.hasZ,hasM:!!this.hasM}),this._spatialIndex.setup(Array.from(this.graphics3DGraphics.values()))),this._spatialIndex.update(),this._spatialIndex}get deconflictor(){return this._deconflictor}get labeler(){return this._labeler}get numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return null!=this.currentRenderer&&"dictionary"===this.currentRenderer.type?0:this._forcedUpdatePolicy??this.preferredUpdatePolicy}get featureStore(){return this._featureStore}get initializePromise(){return this._initializePromise}get scaleVisibility(){return this._scaleVisibility}get elevationAlignment(){return this._elevationAlignment}get objectStates(){return this._objectStates}get filterVisibility(){return this._filterVisibility}get updating(){return!!(this.dataUpdating||this._elevationAlignment?.updating||this._scaleVisibility?.updating||this._filterVisibility?.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._frameTaskHandle.updating||this._updateQueue.updating||this.readyToRun)}get dataUpdating(){return!!(this._graphicsWaitingForSymbol.size>0||this._pendingUpdates.size>0||this._spatialIndex?.updating||this._updatingPendingLoadedGraphicsChange||this._dataUpdateQueue.updating||this._loadingSymbols>0||this.compressionTracker.compressing)}get readyToRun(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating||this._dataUpdateQueue.readyToRun||this._updateQueue.readyToRun}get suspendedOrOutsideOfView(){return this.owner.suspended||!!this.owner.suspendInfo?.outsideOfView}get updatingRemaining(){return this.updating?this._pendingUpdates.size+.1*(this._spatialIndex?.updatingRemaining||0)+.1*(this._elevationAlignment?.updatingRemaining||0):0}get displayFeatureLimit(){const e=this.owner&&this.owner.view&&this.owner.view.qualitySettings,t=e?.graphics3D.minTotalNumberOfFeatures??0,i=e?.graphics3D.maxTotalNumberOfFeatures??0,r=e?.graphics3D.maxNumberOfDrawCalls??0,s=e?.graphics3D.maxTotalNumberOfVertices??0,a=this.averageSymbolComplexity,n=Math.max(1,a?.verticesPerFeature??1),o=a&&a.drawCallsPerFeature>0&&r>0?r/a.drawCallsPerFeature:i,l=Math.ceil(s/n),h=Math.max(t,Math.min(i,l,o)),d=this._get("displayFeatureLimit");return d&&d.maximumTotalNumberOfVertices===s&&d.averageSymbolComplexity===a&&d.maximumNumberOfFeatures===h?d:new ne(s,h,a)}get averageSymbolComplexity(){const e=se(this._symbolComplexities),t=this._get("averageSymbolComplexity");return 0===e.numComplexities||null!=t&&(e.estimated&&(t.verticesPerFeature>=e.verticesPerFeature||t.verticesPerCoordinate>=e.verticesPerCoordinate||t.drawCallsPerFeature>=e.drawCallsPerFeature)||t.verticesPerFeature===e.verticesPerFeature&&t.verticesPerCoordinate===e.verticesPerCoordinate&&t.drawCallsPerFeature===e.drawCallsPerFeature)?t:e}get usedMemory(){const e=this.labelsEnabled?(this.averageSymbolComplexity?.memory.bytesPerFeatureLabel??0)*this._numberOfGraphics:0,t=this._getSymbolComplexitiesUsed().reduce((e,t)=>e+t.memory.resourceBytes,0);if(null==this._symbolMaterials){this._symbolMaterials=[];for(const e of this._symbols.values())if(null!=e)for(const t of e.symbolLayers)if(t)for(const e of t.materials)e&&this._symbolMaterials.push(e)}const i=this.owner.view.stage.renderer,r=this.owner.view.basemapTerrain.overlayManager.renderer,s=this._symbolMaterials.reduce((e,t)=>e+((i.getMaterialRenderer(t)||r.getMaterialRenderer(t))?.usedMemory??0),0);return this._usedMemory+e+t+s}get usedMemoryPerGraphic(){if(this._usedMemory&&this._numberOfGraphics){const e=this._numberOfGraphics/(this._numberOfGraphics+Math.max(this._pendingAdds,this._pendingRemoves));return this._usedMemory/this._numberOfGraphics*e}if(null!=this.averageSymbolComplexity){const e=this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel:0;return this.averageSymbolComplexity.memory.bytesPerFeature+e}return 0}get unprocessedMemoryEstimate(){return(this._pendingAdds-this._pendingRemoves)*this.usedMemoryPerGraphic}get _symbolComplexities(){return this.currentRenderer?this._getSymbolComplexitiesUsedOrRenderer(this.currentRenderer):this._getSymbolComplexitiesUsed()}get visible(){return this._visible}_getConvertedSymbol(e){const t=e;if("web-style"===t.type)return t.clone();const i=this._symbolConversionCache.get(t.id);if(null!=i)return i;const r=re(t,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(t),cimFallbackEnabled:!0}),a=r.symbol||null;return null==a&&r.error&&s.getLogger(this).error(r.error.message),this._symbolConversionCache.set(t.id,a),a}_getSymbolComplexitiesUsedOrRenderer(e){if(null==e)return[];const t=e.symbols,i="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!i&&!t.length)return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(i);null!=s&&r.push(s);for(const a of t){const e=this._getSymbolComplexityUsedOrRenderer(a);null!=e&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(null==e)return null;const t=this._symbols.get(e.id);if(null!=t)return t.complexity;const i=this._getConvertedSymbol(e);return null!=i?ae(i):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach(t=>{null!=t&&e.push(t.complexity)}),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new Pe({computedExtent:I},this),this.computedExtent=null,this.currentRenderer=null,this.rendererHasGeometryOperations=!1,this._graphicStateTracking=null,this.graphics3DGraphics=new Map,this.stageLayer=null,this.stage=null,this._graphicsDrapedUids=new Set,this._graphicsBySymbol=new Map,this._symbolConversionCache=new Map,this._symbols=new Map,this._graphicsWithoutSymbol=new Map,this._graphicsWaitingForSymbol=new Map,this._graphicsUpdateId=0,this._frameTaskHandle=Re,this._dataUpdateQueue=new xe,this._updateQueue=new xe,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=null,this._elevationAlignment=null,this._scaleVisibility=null,this._filterVisibility=null,this._spatialIndex=null,this.extentPadding=0,this._updatingPendingLoadedGraphicsChange=null,this._featureStore=null,this._deconflictor=null,this._labeler=null,this._objectStates=null,this._viewElevationProvider=null,this._stageLayerElevationProvider=null,this._sharedSymbolResourcesOwnerHandle=null,this._whenGraphics3DGraphicRequests={},this._pendingUpdates=new Map,this._numberOfGraphics=0,this._numberOfGraphicsProvidingElevation=0,this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this._loadingSymbols=0,this.compressionTracker=new Ie,this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new p,this.preferredUpdatePolicy=1,this._forcedUpdatePolicy=null,this.elevationFeatureExpressionEnabled=!0,this.owner=null,this.layer=null,this.graphicSymbolSupported=!0,this.getRenderingInfoWithoutRenderer=!1,this.setUidToIdOnAdd=!0,this.hasZ=null,this.hasM=null,this._usedMemory=0,this._visible=!1,this._startCreateGraphics=!1,this._unusedSymbolsCache=e.owner.view.resourceController.memoryController.newCache("graphics-3d-unused-symbols",e=>e.destroy()),this.symbolCreationContext=new ce(e.owner.view.resourceController.scheduler,(e,t)=>this._updateQueue.push(e,t),e.owner.layerViewUid,this.compressionTracker)}initialize(){this._featureStore=new de({objectIdField:this.owner.layer?.objectIdField,hasZ:!!this.hasZ,hasM:!!this.hasM,viewSpatialReference:this._viewSpatialReference,featureSpatialReference:this.owner.featureSpatialReference,getSpatialIndex:()=>this.spatialIndex,forEach:e=>this.graphics3DGraphics.forEach(e)});const e=(e,t,i)=>this.spatialIndex.queryGraphicUIDsInExtent(e,t,i),{componentFactories:t}=this;this._elevationAlignment=t.elevationAlignment?.(this,e),this._scaleVisibility=t.scaleVisibility?.(this,e),this._filterVisibility=t.filterVisibility?.({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities(t=>t.setVisibilityFlag(1,4,e(H(t.graphic,this._objectIdField)))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities(t=>t.setVisibilityFlag(1,4,e)),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities(e=>e.setVisibilityFlag(1,4,!0))}),this._deconflictor=t.deconflictor?.(this),this._labeler=t.labeler?.(this,this._scaleVisibility),this._objectStates=t.objectStates?.(this),this._initializeAbortController=new AbortController,this.addHandles(m(()=>this.owner.view.state.highlights,()=>{const{highlightOrderMap:e}=this.owner.view.state;this.graphics3DGraphics.forEach(t=>t.updateHighlights(e))})),this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,t=this.owner.view;this._viewElevationProvider=new oe(this._viewSpatialReference,t),this._initializeStage(t,this.owner.layerViewUid);const i=t.sharedSymbolResources;this.symbolCreationContext.sharedResources=i,this._sharedSymbolResourcesOwnerHandle=i.addGraphicsOwner(this.owner),null!=this.currentRenderer&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=i.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=t.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new Ce(t.renderSpatialReference),this.symbolCreationContext.elevationProvider=t.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const r=le(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await he(r,this._viewSpatialReference,e,s.getLogger(this)),c(e),this.symbolCreationContext.screenSizePerspectiveEnabled=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this.symbolCreationContext.physicalBasedRenderingEnabled=!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,this.symbolCreationContext.skipHighSymbolLods=!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,"drapeSourceType"in this.owner){const{owner:e}=this;this.symbolCreationContext.drapeSourceRenderer=t.basemapTerrain.overlayManager.registerGeometryDrapeSource(e)}this.addHandles([b(()=>this.suspendedOrOutsideOfView,()=>this._updateQueue.unshift(()=>this._updateLayerVisibility(),null).catch(y)),b(()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view?.screenSizePerspectiveEnabled],()=>{const e=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())}),b(()=>this.owner.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(!!e)),b(()=>this.owner.view.state?.rasterPixelRatio,()=>this._pixelRatioChange()),b(()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._physicalBasedRenderingChange(e)),b(()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,e=>this._skipHighSymbolLoDsChange(e)),b(()=>this.owner.view.focusAreasView?.polygons,()=>this._updateFocusedLabels()),b(()=>this.owner.view.map?.focusAreas.style,()=>this.recreateAllGraphicsAndSymbols()),m(()=>t.basemapTerrain?.tilingScheme,e=>{if(e.spatialReference.equals(this.symbolCreationContext.overlaySR)||null==t.basemapTerrain.spatialReference||(this.symbolCreationContext.overlaySR=t.basemapTerrain.spatialReference),this.hasHandles("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this.addHandles([_(e,"change",e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()},{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}},{initial:!0}),b(()=>this.effectiveUpdatePolicy,e=>{null!=this.stageLayer&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=0===this.effectiveUpdatePolicy,1===e&&this.runTask(Ue)},f)]),this._frameTaskHandle=t.resourceController.scheduler.registerTask(De.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this.addHandles(b(()=>this.layer.featureReduction,()=>this._deconflictor?.featureReductionChange())),this.notifyChange("averageSymbolComplexity"),this.rendererChange(this.owner.renderer).catch(()=>{}),this._initializeAbortController=null}_abortInitialize(){this._initializeAbortController=n(this._initializeAbortController)}_updateFocusedLabels(){this.forEachGraphics3DSymbol((e,t)=>{t&&e.updateFocus(({graphic:e})=>this.recreateGraphics([e]),t)})}destroy(){if(this._unusedSymbolsCache.destroy(),this._abortInitialize(),this._rendererChangeAbortController=n(this._rendererChangeAbortController),this._abortElevationInfoChange(),this._frameTaskHandle.remove(),this._frameTaskHandle=Re,this._dataUpdateQueue.cancelAll(),this._updateQueue.cancelAll(),this._deconflictor=o(this._deconflictor),this._labeler=o(this._labeler),this._elevationAlignment=l(this._elevationAlignment),this._scaleVisibility=l(this._scaleVisibility),this._filterVisibility=l(this._filterVisibility),this._objectStates=l(this._objectStates),this.clear(),"drapeSourceType"in this.owner){const{owner:e}=this;this.stage.view.basemapTerrain.overlayManager.unregisterDrapeSource(e)}this._featureStore=l(this._featureStore),this._updatingPendingLoadedGraphicsChange=o(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=l(this._graphicStateTracking),this.stage&&(this.stageLayer=l(this.stageLayer),this.stage=null),this._set("owner",null);for(const e in this._whenGraphics3DGraphicRequests)this._whenGraphics3DGraphicRequests[e].reject(new r("graphic:layer-destroyed","Layer has been destroyed"));this._whenGraphics3DGraphicRequests=null,this._sharedSymbolResourcesOwnerHandle=o(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=l(this._propertiesPool),this._whenSymbolRemoved.prune(),this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=l(this._spatialIndex),this._symbolMaterials=null}clear(){this._objectStates?.allGraphicsDeleted(),null!=this._graphicStateTracking&&this._graphicStateTracking.allGraphicsDeleted(),this.graphics3DGraphics.forEach(e=>e.destroy()),this._spatialIndex?.clear(),this.graphics3DGraphics.clear(),this._numberOfGraphics=0,this._usedMemory=0,this._updateLayerVisibility(),this._symbols.forEach(l),this._symbols.clear(),this._symbolMaterials&&(this._symbolMaterials.length=0,this._symbolMaterials=null),this._graphicsBySymbol.clear(),this._graphicsWithoutSymbol.clear(),this._graphicsWaitingForSymbol.clear(),this._pendingUpdates.clear(),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this.notifyChange("dataUpdating"),this.notifyChange("readyToRun"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed"),this.owner.notifyContentGeometryUpdate?.()}_initializeStage(e,t){this.stage=e.stage,this.stageLayer=new we(this.stage,{visible:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},t);const i=this.stageLayer.events;i.on("transformationChanged",e=>this.notifyGraphicGeometryChanged(e.graphicUid)),i.on("shaderTransformationChanged",e=>this.notifyGraphicGeometryChanged(e.graphicUid)),i.on("visibilityChanged",e=>this.notifyGraphicVisibilityChanged(e.graphicUid)),i.on("geometryAdded",e=>this.notifyGraphicGeometryChanged(e.object.graphicUid)),i.on("geometryRemoved",e=>this.notifyGraphicGeometryChanged(e.object.graphicUid)),i.on("attributesChanged",e=>Se(e.attribute)&&this.notifyGraphicGeometryChanged(e.object.graphicUid))}notifyGraphicGeometryChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicGeometry(t)}notifyGraphicVisibilityChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicVisibility(t)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,t=this._numberOfGraphics>e*Te,i=!this.suspendedOrOutsideOfView&&!t;i!==this._visible&&(this._visible=i,this._updateStageLayerVisibility())}_updateStageLayerVisibility(){const e=this._visible&&(null==this.layer.opacity||this.layer.opacity>=Le);this.stageLayer.visible!==e&&(this.stageLayer.visible=e,e?this.updateGraphicsVisibilities():this._hideAllGraphics(),this.owner.notifyContentGeometryUpdate?.())}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,t=this.owner.layer?.objectIdField){return H(e,t)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer?.objectIdField;if(!e)return;const t=new Map;return this.graphics3DGraphics.forEach(i=>{if(!i)return;const r=i.graphic,s=this._getGraphicObjectID(r,e);null!=s&&t.set(s,i)}),t}get labelsEnabled(){return!!this._labeler?.layerLabelsEnabled()}async updateLabelingInfo(e){const t=this._deconflictor?.labelingInfoChange(e),i=this._labeler?.labelingInfoChange(e);await Promise.allSettled([t,i])}updateVisibilityInfo(){this._deconflictor?.labelingInfoChange(),this._labeler?.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=!1,t=!1;for(const[i,r]of this._symbols)if(null!=r){switch(r.getFastUpdateStatus()){case 3:return"unknown";case 1:this._graphicsBySymbol.has(i)&&(t=!0);break;case 0:this._graphicsBySymbol.has(i)&&(e=!0);break;case 2:this._graphicsBySymbol.has(i)&&(t=e=!0)}}return t?e?"mixed":"fast":e?"slow":"mixed"}runTask(e){if(this._dataUpdateQueue.runTask(e),this._updateQueue.runTask(e),this._applyPendingUpdates(e),this.notifyChange("readyToRun"),this.readyToRun||this.notifyChange("dataUpdating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return Ee}setObjectIdVisibility(e,t){t?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const i=this._findGraphics3DGraphicByObjectId(e);null!=i&&this._updateUserVisibility(i)}_findGraphics3DGraphicByObjectId(e){return a(this.graphics3DGraphics,t=>this._getGraphicObjectID(t.graphic)===e)}_updateUserVisibility(e){if(null==e)return!1;const t=e.graphic,i=this._getGraphicObjectID(t),r=t.visible&&!this.owner.suspended&&this.stageLayer.visible&&(null==i||!this._objectIdInvisibleSet.has(i));return e.setVisibilityFlag(1,1,r)}_whenGraphics3DGraphic(e){const t=this.graphics3DGraphics.get(e.uid);if(t)return Promise.resolve(t);const i=this._whenGraphics3DGraphicRequests[e.uid];if(i)return i.promise;const r=u();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,t){const i=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,t,s)=>V(e,r,t,e,i,t,s),n=(e,t,r)=>V(e,s,t,e,i,t,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:null!=t&&!!t.useViewElevation,minDemResolution:null!=t?t.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,t?.signal);if(!l)return null;const h=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){A(h,je);const t=e.getElevation(je[0],je[1],0,i,"ground")??0;h[2]=Math.min(h[2],t),h[5]=Math.max(h[5],t)}}return{boundingBox:h,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,t){await v(()=>this.owner?.loadedGraphics);const i=this.owner.layer?.objectIdField,s=this.owner.loadedGraphics.find(t=>t===e||null!=i&&null!=t.attributes&&e.attributes&&t.attributes[i]===e.attributes[i]);if(!s)throw new r("internal:graphic-not-part-of-view","Graphic is not part of this view");const a=await this._whenGraphics3DGraphic(s);return this._boundsForGraphics3DGraphic(a,t)}computeAttachmentOrigin(e,t){const i=this.graphics3DGraphics.get(e.uid);if(!i)return null;const r=i.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;P(Me,0,0,0);let s=0;if(r.render.num>0){if(!j(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,ke,t))return null;R(Me,Me,ke),s++}if(r.draped.num>0){const[e,i]=r.draped.origin,a=this._viewElevationProvider.getElevation(e,i,"ground")??0;if(P(ke,e,i,a),!j(ke,this._viewElevationProvider.spatialReference,ke,t))return null;R(Me,Me,ke),s++}return s>1&&U(Me,Me,1/s),new E({x:Me[0],y:Me[1],z:Me[2],spatialReference:t})}getSymbolLayerSize(e,t){const i=this._symbols.get(e.id);if(null==i)throw new r("internal:symbol-not-part-of-view","Symbol is not part of this view");const s=e.symbolLayers.indexOf(t);if(-1===s)throw new r("internal:missing-symbol-layer","Symbol layer is not in symbol");const a=i.getSymbolLayerSize(s);if(null==a)throw new r("internal:missing-size","Symbol layer has no valid size");return a}_graphicsCollectionChanged(e){this._startCreateGraphics&&(this.add(e.added),this.remove(e.removed))}graphicUpdateHandler(e){const t=e.graphic.uid,i=this.graphics3DGraphics.get(t);if(null!=i||null!=this._graphicsWithoutSymbol.get(t)){switch(e.property){case"visible":this._graphicUpdateVisibleHandler(i);break;case"geometry":this._graphicUpdateGeometryHandler(i,e);break;case"symbol":this._graphicUpdateSymbolHandler(i,e);break;case"attributes":case"popupTemplate":break;case"origin-transform":this._graphicUpdateTransformHandler(i,e)}this.owner.notifyContentGeometryUpdate?.()}}_graphicUpdateGeometryHandler(e,t){this._graphicUpdateGeometryOrTransformHandler(e,t,()=>!(null==t.newValue||null==e||!e.graphics3DSymbol.updateGeometry(e,t.newValue)||!(this._labeler?.updateGraphicGeometry(e)??1))&&(this._labeler?.setDirty(),!0));const i=t.graphic.geometry;null!=i&&this._expandComputedExtent(i)}_graphicUpdateTransformHandler(e,t){const i=t.graphic.geometry;this._graphicUpdateGeometryOrTransformHandler(e,t,()=>null!=t.newValue&&null!=e&&null!=i&&e.graphics3DSymbol.updateTransform(e,i.spatialReference,t.newValue,t.action))}_graphicUpdateGeometryOrTransformHandler(e,t,i){if(null!=t.graphic.geometry){if(null==e){const e=t.graphic.symbol?.id;if(e){const t=this._symbols.get(e);if(null!=t&&0===t.loadStatus)return}return void this._recreateGraphic(t.graphic)}i()||this._recreateGraphic(e.graphic)}else this._recreateGraphic(t.graphic)}_graphicUpdateSymbolHandler(e,t){const i=t.graphic,r=null!=e?e.graphics3DSymbol:null!=t.oldValue?this._symbols.get(t.oldValue.id):null;if(null==r||null==t.newValue)return void this._recreateGraphic(i);const s=r.symbol,a=this._getConvertedSymbol(t.newValue);if(null!=a&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(i);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(i);const o=G(s,a);if(null==o)return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!x(l.diff))return void this._recreateGraphic(i);const h=this._getRenderingInfo(i,!1);if(null==h)return void this._recreateGraphic(i);const d=r.extentPadding;for(const p of l.symbolStatePatches)p();if(d!==r.extentPadding&&this._recomputeExtentPadding(),null!=e)for(const p of l.graphics3DGraphicPatches)p(e,h);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,1===this.effectiveUpdatePolicy&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const t=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,t),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("dataUpdating"),t}_endGraphicUpdate(e,t){e&&(t&&this._graphicStateTracking?.updateGraphicError(e,t),this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach(t=>{null!=t&&(e=Math.max(e,t.extentPadding))}),this._set("extentPadding",e)}_expandComputedExtent(e){const t=Oe,i=e.spatialReference;B(e,t);const r=this._viewSpatialReference,s=Ve.tmpVec;if(z(i,r)||O(t[0],t[1],0,i,s,r)&&(t[0]=s[0],t[1]=s[1],O(t[3],t[4],0,i,s,r),t[3]=s[0],t[4]=s[1]),!(isFinite(t[0])&&isFinite(t[3])&&isFinite(t[1])&&isFinite(t[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(t[2])&&isFinite(t[5]),l=o&&(null==a?.zmin||t[2]<a.zmin),h=o&&(null==a?.zmax||t[5]>a.zmax);if(a){(t[0]<a.xmin||t[1]<a.ymin||t[3]>a.xmax||t[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(t[0],a.xmin),n.ymin=Math.min(t[1],a.ymin),n.xmax=Math.max(t[3],a.xmax),n.ymax=Math.max(t[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=t[0],n.ymin=t[1],n.xmax=t[3],n.ymax=t[4],n.spatialReference=r;n&&(l&&(n.zmin=t[2]),h&&(n.zmax=t[5]),this._set("computedExtent",n))}_abortElevationInfoChange(){this._elevationInfoChangeAbortController&&(this._elevationInfoChangeAbortController.abort(),this._elevationInfoChangeAbortController=null)}async elevationInfoChange(){this._abortElevationInfoChange();const e=new AbortController;this._elevationInfoChangeAbortController=e;const t=le(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await he(t,this._viewSpatialReference,e.signal,s.getLogger(this)),c(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol((e,t,i)=>{e.globalPropertyChanged("elevationInfo",t)?t?.forEach(e=>{const t=e.graphic,i=e.labelLayers;for(const r of i){r.graphics3DSymbolLayer.updateGraphicElevationContext(t,r)}}):this._recreateSymbol(i)}),this.updateStageLayerElevationProvider(),this._elevationAlignment?.elevationInfoChange()}updateStageLayerElevationProvider(){this._stageLayerElevationProvider?(this.layer.elevationInfo&&"relative-to-scene"===this.layer.elevationInfo.mode||0===this._numberOfGraphicsProvidingElevation)&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=h(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new fe({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),null!=this._filterVisibility&&this._filterVisibility.clear(),this._labeler?.reset(),this._deconflictor?.clear(),this._elevationAlignment?.clear(),this.stageLayer?.invalidateSpatialQueryAccelerator(),this._stageLayerElevationProvider&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=h(this._stageLayerElevationProvider))}startCreateGraphics(){this._startCreateGraphics=!0,this.recreateAllGraphics()}recreateAllGraphics(){this._recreateAllGraphics(!1)}recreateAllGraphicsAndSymbols(){this._recreateAllGraphics(!0)}_recreateAllGraphics(e=!1){if(!this._startCreateGraphics)return;const{loadedGraphics:t,view:i}=this.owner,r=i.basemapTerrain?.tilingScheme&&t?.length?t.toArray():null;!e&&r||this._clearSymbolsAndGraphics(),this.symbolCreationContext.screenSizePerspectiveEnabled=this.owner.view.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this._set("computedExtent",null),r&&(e?this.add(r):this.recreateGraphics(r))}_recreateSymbol(e){const t=this._graphicsBySymbol.get(e),i=[];t&&(t.forEach((e,t)=>{const r=e.usedMemory;this._conditionalRemove(e,t),this._spatialIndex?.remove(e),i.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(t,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed"),this.owner.notifyContentGeometryUpdate?.()}),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);l(r),this._symbols.delete(e),this._symbolMaterials=null,l(this._unusedSymbolsCache.pop(e)),this.add(i)}_recreateGraphicsForSymbol(e){const t=this._graphicsBySymbol.get(e);if(t){const e=[];t.forEach(t=>e.push(t.graphic)),this.recreateGraphics(e)}}_conditionalRemove(e,t){this._graphicsDrapedUids.delete(t),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),null!=this._graphicStateTracking&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain?.tilingScheme?(0===this._updatePolicyForGraphics(e)?this._addDelayed(e):this._addImmediate(e),this.notifyChange("dataUpdating")):s.getLogger(this).error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(1===this.effectiveUpdatePolicy&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const t of e)if(null!=t.geometry&&"mesh"===t.geometry.type&&!t.geometry.loaded)return 0;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const t of e)this._addGraphic(t,this._getRenderingInfo(t),1);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_addDelayed(e){for(const t of e){const e=t.uid;let i=this._pendingUpdates.get(e);i?i.add?0!==i.state&&i.abortController?.abort():this._pendingAdds++:(i=new Fe,this._pendingAdds++,this._pendingUpdates.set(e,i)),i.add=t}this.notifyChange("readyToRun"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}remove(e){0===this.effectiveUpdatePolicy?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("dataUpdating")}_removeImmediate(e){for(const t of e)this._removeGraphic(t);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_removeDelayed(e){for(const t of e){const e=t.uid,i=this._pendingUpdates.get(e);if(i)i.add&&(i.remove?i.add=null:this._pendingUpdates.delete(e),1===i.state&&i.abortController?.abort(),this._pendingAdds--);else{const i=new Fe;i.remove=t,this._pendingUpdates.set(e,i),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("readyToRun"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}_finishPendingUpdates(){this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&s.getLogger(this).warn("pendingAdds/Removes in inconsistent state!"),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1}_applyPendingUpdates(e){if(this._geometryWarningLogged=!1,this._symbolWarningLogged=!1,0===this._pendingUpdates.size&&this._spatialIndex?.updating)return this._spatialIndex.update(),void e.madeProgress();if(this._applyPendingRemovesFirst){this._applyPendingRemovesFirst=!1;for(const[t,i]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(i.remove&&!i.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,this._pendingUpdates.delete(t),0===this._pendingRemoves))break}}for(const[t,i]of this._pendingUpdates){if(e.done)break;i.add&&0===i.state&&this._processPendingUpdateNew(i);let r=this.effectiveUpdatePolicy;if(!i.remove||i.add&&2!==i.state||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,r=1),i.add)switch(i.state){case 2:this._addGraphic(i.add,i.renderingInfo,r),i.add=null,this._pendingAdds--,e.madeProgress();break;case 3:i.add=null,this._pendingAdds--}null==i.remove&&null==i.add&&this._pendingUpdates.delete(t)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("readyToRun"),this.notifyChange("dataUpdating"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=2);const t=e.add.geometry;null==t||"mesh"!==t.type||t.loaded?this._processPendingUpdateNewRenderingInfo(e):this._processPendingUpdateNewMesh(e,t)}async _processPendingUpdateNewMesh(e,t){e.state=1,e.abortController=new AbortController;const i=e.abortController.signal;try{await t.load({signal:i})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,t){e.abortController=null,g(t)?e.state=0:e.state=3}async _processPendingUpdateNewRenderingInfo(e){if(null==this.layer.renderer||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add),void(e.state=2);e.state=1,e.abortController=new AbortController;let t=null;try{t=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(i){return e.abortController=null,void(g(i)?e.state=0:e.state=3)}null==t?.symbol?(this._symbolWarningLogged||(this._symbolWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=t,e.state=2}_addGraphic(e,t,i){if(this._graphicsWithoutSymbol.set(e.uid,e),null==t?.symbol||!q(e))return;const r=this.stage.renderView.olidRenderHelper;if(r&&this.setUidToIdOnAdd){const t=X(this.owner.view,this.owner.layerViewUid);r.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.owner.layerViewUid,!!this.layer.popupEnabled&&!t&&Ge(this.layer,this.owner.view.popup?.defaultPopupTemplateEnabled))}const s=t.symbol,a=this.getOrCreateGraphics3DSymbol(s,t.renderer);if(null==a)return;this._expandComputedExtent(e.geometry);const n=this._beginGraphicUpdate(e),o=new pe(e,t,this.layer);let l=!1;const h=e=>{e===a.symbol.id&&(l=!0)};this._whenSymbolRemoved.push(h);const d=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(h);if(this._graphicsWaitingForSymbol.get(e.uid)!==n||l||a.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==a.symbol.id)--a.referenced,this._cleanupSymbols();else{const t=this._createGraphics3DGraphic(a,o);this._spatialIndex&&null!=t&&this._spatialIndex.add(t),--a.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this.owner.notifyContentGeometryUpdate?.(),this._labeler?.setDirty()},p=t=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(h),l||(g(t)?this.add([e]):a.destroyed||this._endGraphicUpdate(e,t)))};++this._loadingSymbols,0===i?a.load(()=>this._dataUpdateQueue.push(d,null).catch(y),e=>this._dataUpdateQueue.push(()=>p(e),null).catch(y)):a.load(d,p)}_removeGraphic(e){const t=e.uid,i=this.graphics3DGraphics.get(t);if(i){i.graphics3DSymbol.onRemoveGraphic(i);const e=i.usedMemory,r=i.isElevationSource;this._conditionalRemove(i,t),this._spatialIndex?.remove(i);const s=i.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(t),this._graphicsWithoutSymbol.delete(t),this._removeGraphics3DGraphic(t,e,r),i.destroy(),this._featureStore.events.emit("changed"),this.owner.notifyContentGeometryUpdate?.()}else this._graphicsWithoutSymbol.delete(t),this._graphicsWaitingForSymbol.delete(t),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating"))}_hasLabelingContext(e){if(e instanceof K||e instanceof ee){const t=this.symbolCreationContext.layer;return!!t.labelingInfo&&t.labelingInfo.some(t=>t.symbol===e)}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof K&&!this._hasLabelingContext(e))||(s.getLogger(this).error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,t=!0){const i=e.geometry;if(null==i)return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!L(i.spatialReference,this._viewSpatialReference))return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?Q(e,this.layer):e;let a;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||null!=this.currentRenderer))a=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{const e=r.symbol||ie(r.geometry);a=new Y(null,e)}return null==a?.symbol?(t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):a}_getRenderingInfoAsync(e,t){if(null==e.geometry)return this._geometryWarningLogged||(this._geometryWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return this._symbolWarningLogged||(this._symbolWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const i=this.rendererHasGeometryOperations?Q(e,this.layer):e;return this.owner.getRenderingInfoAsync(i,this.currentRenderer,this._arcadeOnDemand,t)}_createGraphics3DSymbol(e,t){if(!this._hasValidSymbolCreationContext(e))return null;const i=this._getConvertedSymbol(e);if(!i)return null;let r;if(null!=t&&"backgroundFillSymbol"in t&&t.backgroundFillSymbol){const e=re(t.backgroundFillSymbol,{ignoreDrivers:!0});null!=e.symbol&&(r=e.symbol.symbolLayers)}const s=ye(i,this.symbolCreationContext,r);return s.load(()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")},()=>{}),s}getOrCreateGraphics3DSymbol(e,t){let i=this._symbols.get(e.id);if(void 0===i){const r=this._unusedSymbolsCache.pop(e.id);i=null!=r?r:e instanceof te?new ue(e,e=>this._dataUpdateQueue.push(e,null),e=>this._createGraphics3DSymbol(e,t)):this._createGraphics3DSymbol(e,t),this._symbols.set(e.id,i),this._symbolMaterials=null}return null!=i&&++i.referenced,i}trackGraphicState(e){return null==this._graphicStateTracking&&(this._graphicStateTracking=new me(this)),this._graphicStateTracking.add(e)}_addGraphics3DGraphic(e){this._usedMemory+=e.usedMemory,this.graphics3DGraphics.set(e.graphic.uid,e),this._numberOfGraphics++,e.isElevationSource&&(this._numberOfGraphicsProvidingElevation++,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_removeGraphics3DGraphic(e,t,i=!1){this._usedMemory-=t,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,i&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,t){const{graphic:i}=t;if(this._graphicsWithoutSymbol.delete(i.uid),!this._symbols.has(e.symbol.id))return this.add([i]),null;if(this.graphics3DGraphics.has(i.uid))return null;const r=e.createGraphics3DGraphic(t);if(null==r)return null;this._addGraphics3DGraphic(r);const s=e.symbol.id;this._graphicsBySymbol.has(s)||this._graphicsBySymbol.set(s,new Map),this._graphicsBySymbol.get(s).set(i.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(i.uid),r.centroid=null,null!=i.geometry&&"point"!==i.geometry.type&&(r.centroid=be(i.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(r),null!=this._filterVisibility){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(1,4,e),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),r.initialize(this.stageLayer),null!=this._graphicStateTracking&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[i.uid];return a&&(delete this._whenGraphics3DGraphicRequests[i.uid],a.resolve(r)),this._symbolMaterials=null,r}async rendererChange(e){if(this._rendererChangeAbortController=n(this._rendererChangeAbortController),e!==this.currentRenderer)if(this._validateRenderer(e),null==e&&this._currentRendererChange(null,!1),$(e))if(e?.arcadeRequired){const t=new AbortController;this._rendererChangeAbortController=t;const{arcadeUtils:i}=await this._ensureArcade();c(t);const r=i.hasGeometryOperations(e);r&&(await i.enableGeometryOperations(),c(t)),0===this.effectiveUpdatePolicy?await this._updateQueue.push(()=>this._currentRendererChange(e,r),t.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(0===this.effectiveUpdatePolicy){const t=new AbortController;this._rendererChangeAbortController=t,await this._updateQueue.push(()=>this._currentRendererChange(e,!1),t.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return null==this._arcadeOnDemand?(this._arcadeOnDemand=await J(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,t){this.currentRenderer=e,this.rendererHasGeometryOperations=t,this.symbolCreationContext.arcade=this._arcadeOnDemand;const i=this.symbolCreationContext.renderer;if(e===i)return;if(this._symbolConversionCache.clear(),this._unusedSymbolsCache.clear(),null==e)return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=G(i,e);this._updateUnchangedSymbolMappings(r,e,i),this.symbolCreationContext.renderer=e,null!=r&&("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,i)?this._labeler?.reset():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const t in e.diff)switch(t){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[t];break;default:return!0}return!1}_applySymbolSetDiff(e,t,i){e=e||[],t=t||[];const r=[];for(const s of t){const t=this._graphicsBySymbol.get(s.id);t&&t.forEach((a,n)=>{const o=a.graphic,l=this.layer instanceof W?this.layer:null,h=this._arcadeOnDemand;if(s===i.defaultSymbol&&i.getSymbol(Q(o,l),{arcade:h})===i.defaultSymbol)return;const d=a.usedMemory;e.length||i.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),t.delete(n),this._removeGraphics3DGraphic(n,d),this._updateLayerVisibility()}),this._whenSymbolRemoved.forAll(e=>e(s.id))}(e.length||r.length)&&(this._graphicsWithoutSymbol.forEach(e=>r.push(e)),this._graphicsWithoutSymbol.clear(),this.add(r)),this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_applyUniqueValueRendererDiff(e,t,r){const s=e.diff.defaultSymbol,a=e.diff.uniqueValueInfos;if(s||a){const n=a?.changed,o=a?.unchanged;if(n&&o&&n.some(e=>o.some(t=>t.oldValue.symbol?.id===e.oldValue.symbol?.id)))return!1;const l=a?a.added.map(e=>e.symbol).filter(i):[],h=a?a.removed.map(e=>e.symbol).filter(i):[];if(n)for(let e=0;e<n.length;e++)l.push(n[e].newValue.symbol),h.push(n[e].oldValue.symbol);return s?(r.defaultSymbol&&h.push(r.defaultSymbol),t.defaultSymbol&&l.push(t.defaultSymbol)):r.defaultSymbol&&l.length&&h.push(t.defaultSymbol),this._applySymbolSetDiff(l,h,t),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,t,i){if("unique-value"!==t?.type||"unique-value"!==i?.type||null!=e&&"partial"!==e.type)return[];const r=e=>null!=e?e.id:null,s=e&&e.diff,a=s?.defaultSymbol,n=s&&s.uniqueValueInfos;let o;if(n)o=n.unchanged.map(e=>({oldId:r(e.oldValue.symbol),newId:r(e.newValue.symbol)}));else{o=[];for(const e of i.uniqueValueInfos??[]){const i=r(e.symbol),s=t.uniqueValueInfos?.find(t=>t.value===e.value);s&&i!==r(s.symbol)&&o.push({oldId:i,newId:r(s.symbol)})}}return!a&&i.defaultSymbol&&o.push({oldId:r(i.defaultSymbol),newId:r(t.defaultSymbol)}),o}_updateSymbolMapping(e,t){const i=null!=t&&t?"string"==typeof t?t:t.id:null;if(null==e||e===i)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(i,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(i,s),this._symbolMaterials=null,null!=s)){const e="string"==typeof t?null:t;null!=e?s.symbol=e:s.symbol.id=i}}_updateUnchangedSymbolMappings(e,t,i){const r=this._calculateUnchangedSymbolMapping(e,t,i);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,t,i){if(this._diffHasSymbolChange(e))return!1;if(t instanceof N&&i instanceof N&&this._applyUniqueValueRendererDiff(e,t,i)&&0===Object.keys(e.diff).length)return!0;for(const r of this._graphicsBySymbol.keys()){const i=this._symbols.get(r);if(null!=i)switch(i.applyRendererDiff(e,t)){case 0:this._recreateSymbol(r);break;case 1:this._recreateGraphicsForSymbol(r)}}return!0}opacityChange(){this._updateStageLayerVisibility(),this.forEachGraphics3DSymbol((e,t)=>e.globalPropertyChanged("opacity",t))}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol((e,t)=>e.globalPropertyChanged("slicePlaneEnabled",t)),this._deconflictor?.slicePlaneEnabledChange(),this._labeler?.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol((e,t,i)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",t)||this._recreateSymbol(i)})}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol((e,t,i)=>{e.globalPropertyChanged("skipHighSymbolLods",t)||this._recreateSymbol(i)})}_pixelRatioChange(){this.forEachGraphics3DSymbol((e,t,i)=>{e.globalPropertyChanged("pixelRatio",t)||this._recreateSymbol(i)})}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=C(()=>{this._updatingPendingLoadedGraphicsChange=null})}setClippingExtent(e,t){const i=this.symbolCreationContext.clippingExtent,r=k();return ve(e,r,t)?this.symbolCreationContext.clippingExtent=T(F(),r):this.symbolCreationContext.clippingExtent=null,!M(this.symbolCreationContext.clippingExtent,i)}modifyGraphics3DGraphicVisibilities(e){if(this.destroyed)return;let t=!1;this.graphics3DGraphics.forEach(i=>{e(i)&&(t=!0)}),t&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}forEachGraphics3DSymbol(e,t){for(const[i,r]of this._symbols){if(null==r)return;e(r,this._graphicsBySymbol.get(i)||ze,i)}if(!t?.excludeUnused)for(const i of this._unusedSymbolsCache)e(i,void 0,i.symbol.id)}updateGraphicsVisibilities(){null!=this._filterVisibility&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities(e=>{const t=this._updateUserVisibility(e),i=!!this._scaleVisibility?.updateVisibility(e);return t||i})}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities(e=>e.setVisibilityFlag(1,1,!1))}_validateRenderer(e){const t=()=>`'${this.layer.title?`${this.layer.title}, `:""}id:${this.layer.id}'`,i=Z(e,{geometryType:this.layer?.geometryType,logWarning:(e,i)=>s.getLogger(this).warn(e,`Symbology conversion for layer ${t()}: ${i}`)});if(i){const e=`Renderer for layer ${t} is not supported in a SceneView`;s.getLogger(this).warn(e,i.message)}}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach((t,i)=>{if(null==t||t.referenced>0)return;const r=this._graphicsBySymbol.get(i);r&&0!==r.size||(this._graphicsBySymbol.delete(i),this._symbols.delete(i),this._symbolMaterials=null,this._unusedSymbolsCache.put(i,t,d),e=!0)}),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){}get performanceInfo(){return new ge(this.graphics3DGraphics.size,Array.from(this.graphics3DGraphics.values()).reduce((e,t)=>e+(t.isVisible()?1:0),0),this._graphicsWithoutSymbol.size,this._pendingUpdates.size)}};e([S({readOnly:!0})],Ae.prototype,"computedExtent",void 0),e([S()],Ae.prototype,"currentRenderer",void 0),e([S()],Ae.prototype,"rendererHasGeometryOperations",void 0),e([S()],Ae.prototype,"_frameTaskHandle",void 0),e([S()],Ae.prototype,"_dataUpdateQueue",void 0),e([S()],Ae.prototype,"_updateQueue",void 0),e([S({readOnly:!0})],Ae.prototype,"_viewSpatialReference",null),e([S()],Ae.prototype,"_rendererChangeAbortController",void 0),e([S()],Ae.prototype,"_elevationInfoChangeAbortController",void 0),e([S()],Ae.prototype,"_initializeAbortController",void 0),e([S()],Ae.prototype,"_elevationAlignment",void 0),e([S()],Ae.prototype,"_scaleVisibility",void 0),e([S()],Ae.prototype,"_filterVisibility",void 0),e([S()],Ae.prototype,"_initializePromise",void 0),e([S()],Ae.prototype,"_spatialIndex",void 0),e([S({readOnly:!0})],Ae.prototype,"extentPadding",void 0),e([S()],Ae.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([S()],Ae.prototype,"_featureStore",void 0),e([S()],Ae.prototype,"_objectStates",void 0),e([S()],Ae.prototype,"_loadingSymbols",void 0),e([S({constructOnly:!0})],Ae.prototype,"compressionTracker",void 0),e([S()],Ae.prototype,"preferredUpdatePolicy",void 0),e([S()],Ae.prototype,"_forcedUpdatePolicy",void 0),e([S({readOnly:!0})],Ae.prototype,"effectiveUpdatePolicy",null),e([S({constructOnly:!0})],Ae.prototype,"elevationFeatureExpressionEnabled",void 0),e([S({constructOnly:!0})],Ae.prototype,"owner",void 0),e([S({constructOnly:!0})],Ae.prototype,"layer",void 0),e([S({constructOnly:!0})],Ae.prototype,"graphicSymbolSupported",void 0),e([S({constructOnly:!0})],Ae.prototype,"getRenderingInfoWithoutRenderer",void 0),e([S({constructOnly:!0})],Ae.prototype,"componentFactories",void 0),e([S({constructOnly:!0})],Ae.prototype,"setUidToIdOnAdd",void 0),e([S()],Ae.prototype,"featureStore",null),e([S()],Ae.prototype,"initializePromise",null),e([S()],Ae.prototype,"scaleVisibility",null),e([S()],Ae.prototype,"elevationAlignment",null),e([S()],Ae.prototype,"objectStates",null),e([S()],Ae.prototype,"filterVisibility",null),e([S({readOnly:!0})],Ae.prototype,"updating",null),e([S({readOnly:!0})],Ae.prototype,"dataUpdating",null),e([S({readOnly:!0})],Ae.prototype,"readyToRun",null),e([S({readOnly:!0})],Ae.prototype,"suspendedOrOutsideOfView",null),e([S({readOnly:!0,dependsOn:[]})],Ae.prototype,"updatingRemaining",null),e([S({readOnly:!0})],Ae.prototype,"displayFeatureLimit",null),e([S({readOnly:!0,dependsOn:[]})],Ae.prototype,"averageSymbolComplexity",null),e([S({constructOnly:!0})],Ae.prototype,"hasZ",void 0),e([S({constructOnly:!0})],Ae.prototype,"hasM",void 0),e([S()],Ae.prototype,"_objectIdField",null),Ae=Ve=e([w("esri.views.3d.layers.graphics.Graphics3DCore")],Ae);class Fe{constructor(){this.add=null,this.renderingInfo=null,this.state=0,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=0,this.abortController=null,this.remove=null}}const Te=10,Me=D(),ke=D(),ze=new Map;export{Ae as Graphics3DCore};
5
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{isSome as i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import r from"../../../../core/Error.js";import s from"../../../../core/Logger.js";import{findInMap as a}from"../../../../core/MapUtils.js";import{abortMaybe as n,removeMaybe as o,destroyMaybe as l,disposeMaybe as h}from"../../../../core/maybe.js";import{MinPriority as d}from"../../../../core/MemCache.js";import p from"../../../../core/PooledArray.js";import{throwIfAborted as c,ignoreAbortErrors as y,createResolver as u,isAbortError as g}from"../../../../core/promiseUtils.js";import{when as m,watch as b,on as _,syncAndInitial as f,whenOnce as v}from"../../../../core/reactiveUtils.js";import{schedule as C}from"../../../../core/scheduling.js";import{property as S}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as G,isEmpty as x}from"../../../../core/accessorSupport/diffUtils.js";import{i as P,f as R,g as U}from"../../../../chunks/vec32.js";import{create as D}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import I from"../../../../geometry/Extent.js";import E from"../../../../geometry/Point.js";import{canProjectWithoutEngine as L}from"../../../../geometry/projectionUtils.js";import{projectBuffer as V}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as j}from"../../../../geometry/projection/projectVectorToVector.js";import{projectXYZToVector as O}from"../../../../geometry/projection/projectXYZToVector.js";import{center as A,create as F,fromRect as T,equals as M}from"../../../../geometry/support/aaBoundingBox.js";import{create as k}from"../../../../geometry/support/aaBoundingRect.js";import{equals as z}from"../../../../geometry/support/spatialReferenceUtils.js";import W from"../../../../layers/Layer.js";import{getObjectId as H,computeAABB as B,hasGeometry as q}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as Q}from"../../../../layers/graphics/hydratedFeatures.js";import N from"../../../../renderers/UniqueValueRenderer.js";import{isSupportedRenderer3D as $,validateTo3D as Z}from"../../../../renderers/support/rendererConversion.js";import{RenderingInfo as Y}from"../../../../renderers/support/RenderingInfo.js";import{isBasemapLayerView as X}from"../../../../support/basemapUtils.js";import{loadArcade as J}from"../../../../support/loadArcade.js";import K from"../../../../symbols/LabelSymbol3D.js";import ee from"../../../../symbols/TextSymbol.js";import te from"../../../../symbols/WebStyleSymbol.js";import{getDefaultSymbol3D as ie}from"../../../../symbols/support/defaults3D.js";import{to3D as re}from"../../../../symbols/support/symbolConversion.js";import{averageSymbolComplexities as se,defaultSymbolComplexity as ae}from"./defaultSymbolComplexity.js";import{DisplayFeatureLimit as ne}from"./DisplayFeatureLimit.js";import{ViewElevationProvider as oe}from"./ElevationQuery.js";import{extractExpressionInfo as le,createContext as he}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as de}from"./Graphics3DFeatureStore.js";import{Graphics3DGraphicCreationContext as pe}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as ce}from"./Graphics3DSymbolCreationContext.js";import{make as ye}from"./Graphics3DSymbolFactory.js";import{Graphics3DWebStyleSymbol as ue}from"./Graphics3DWebStyleSymbol.js";import{GraphicsCorePerformanceInfo as ge}from"./GraphicsCorePerformanceInfo.js";import{GraphicStateTracking as me}from"./GraphicStateTracking.js";import{computeCentroid as be}from"./graphicUtils.js";import{SpatialIndex2D as _e}from"./SpatialIndex2D.js";import{StageLayerElevationProvider as fe}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as ve}from"../../support/extentUtils.js";import{GridLocalOriginFactory as Ce}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{affectsGeometry as Se}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as we}from"../../webgl-engine/lib/WebGLLayer.js";import{hasPopupTemplate as Ge}from"../../../layers/support/popupUtils.js";import{PromiseQueue as xe}from"../../../support/PromiseQueue.js";import{PropertiesPool as Pe}from"../../../support/PropertiesPool.js";import{ImmediateTask as Re,noBudget as Ue,TaskPriority as De}from"../../../support/Scheduler.js";import{TextureCompressionTracker as Ie}from"../../../support/TextureCompressionTracker.js";import{Yield as Ee}from"../../../support/Yield.js";import{alphaCutoff as Le}from"../../../../webscene/support/AlphaCutoff.js";var Ve;const je=D(),Oe=F();let Ae=class extends t{static{Ve=this}static{this.tmpVec=D()}get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new _e({objectIdField:this.owner.layer?.objectIdField,spatialReference:this._viewSpatialReference,hasZ:!!this.hasZ,hasM:!!this.hasM}),this._spatialIndex.setup(Array.from(this.graphics3DGraphics.values()))),this._spatialIndex.update(),this._spatialIndex}get deconflictor(){return this._deconflictor}get labeler(){return this._labeler}get numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return null!=this.currentRenderer&&"dictionary"===this.currentRenderer.type?0:this._forcedUpdatePolicy??this.preferredUpdatePolicy}get featureStore(){return this._featureStore}get initializePromise(){return this._initializePromise}get scaleVisibility(){return this._scaleVisibility}get elevationAlignment(){return this._elevationAlignment}get objectStates(){return this._objectStates}get filterVisibility(){return this._filterVisibility}get updating(){return!!(this.dataUpdating||this._elevationAlignment?.updating||this._scaleVisibility?.updating||this._filterVisibility?.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._frameTaskHandle.updating||this._updateQueue.updating||this.readyToRun)}get dataUpdating(){return!!(this._graphicsWaitingForSymbol.size>0||this._pendingUpdates.size>0||this._spatialIndex?.updating||this._updatingPendingLoadedGraphicsChange||this._dataUpdateQueue.updating||this._loadingSymbols>0||this.compressionTracker.compressing)}get readyToRun(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating||this._dataUpdateQueue.readyToRun||this._updateQueue.readyToRun}get suspendedOrOutsideOfView(){return this.owner.suspended||!!this.owner.suspendInfo?.outsideOfView}get updatingRemaining(){return this.updating?this._pendingUpdates.size+.1*(this._spatialIndex?.updatingRemaining||0)+.1*(this._elevationAlignment?.updatingRemaining||0):0}get displayFeatureLimit(){const e=this.owner&&this.owner.view&&this.owner.view.qualitySettings,t=e?.graphics3D.minTotalNumberOfFeatures??0,i=e?.graphics3D.maxTotalNumberOfFeatures??0,r=e?.graphics3D.maxNumberOfDrawCalls??0,s=e?.graphics3D.maxTotalNumberOfVertices??0,a=this.averageSymbolComplexity,n=Math.max(1,a?.verticesPerFeature??1),o=a&&a.drawCallsPerFeature>0&&r>0?r/a.drawCallsPerFeature:i,l=Math.ceil(s/n),h=Math.max(t,Math.min(i,l,o)),d=this._get("displayFeatureLimit");return d&&d.maximumTotalNumberOfVertices===s&&d.averageSymbolComplexity===a&&d.maximumNumberOfFeatures===h?d:new ne(s,h,a)}get averageSymbolComplexity(){const e=se(this._symbolComplexities),t=this._get("averageSymbolComplexity");return 0===e.numComplexities||null!=t&&(e.estimated&&(t.verticesPerFeature>=e.verticesPerFeature||t.verticesPerCoordinate>=e.verticesPerCoordinate||t.drawCallsPerFeature>=e.drawCallsPerFeature)||t.verticesPerFeature===e.verticesPerFeature&&t.verticesPerCoordinate===e.verticesPerCoordinate&&t.drawCallsPerFeature===e.drawCallsPerFeature)?t:e}get usedMemory(){const e=this.labelsEnabled?(this.averageSymbolComplexity?.memory.bytesPerFeatureLabel??0)*this._numberOfGraphics:0,t=this._getSymbolComplexitiesUsed().reduce((e,t)=>e+t.memory.resourceBytes,0);if(null==this._symbolMaterials){this._symbolMaterials=[];for(const e of this._symbols.values())if(null!=e)for(const t of e.symbolLayers)if(t)for(const e of t.materials)e&&this._symbolMaterials.push(e)}const i=this.owner.view.stage.renderer,r=this.owner.view.basemapTerrain.overlayManager.renderer,s=this._symbolMaterials.reduce((e,t)=>e+((i.getMaterialRenderer(t)||r.getMaterialRenderer(t))?.usedMemory??0),0);return this._usedMemory+e+t+s}get usedMemoryPerGraphic(){if(this._usedMemory&&this._numberOfGraphics){const e=this._numberOfGraphics/(this._numberOfGraphics+Math.max(this._pendingAdds,this._pendingRemoves));return this._usedMemory/this._numberOfGraphics*e}if(null!=this.averageSymbolComplexity){const e=this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel:0;return this.averageSymbolComplexity.memory.bytesPerFeature+e}return 0}get unprocessedMemoryEstimate(){return(this._pendingAdds-this._pendingRemoves)*this.usedMemoryPerGraphic}get _symbolComplexities(){return this.currentRenderer?this._getSymbolComplexitiesUsedOrRenderer(this.currentRenderer):this._getSymbolComplexitiesUsed()}get visible(){return this._visible}_getConvertedSymbol(e){const t=e;if("web-style"===t.type)return t.clone();const i=this._symbolConversionCache.get(t.id);if(null!=i)return i;const r=re(t,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(t),cimFallbackEnabled:!0}),a=r.symbol||null;return null==a&&r.error&&s.getLogger(this).error(r.error.message),this._symbolConversionCache.set(t.id,a),a}_getSymbolComplexitiesUsedOrRenderer(e){if(null==e)return[];const t=e.symbols,i="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!i&&!t.length)return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(i);null!=s&&r.push(s);for(const a of t){const e=this._getSymbolComplexityUsedOrRenderer(a);null!=e&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(null==e)return null;const t=this._symbols.get(e.id);if(null!=t)return t.complexity;const i=this._getConvertedSymbol(e);return null!=i?ae(i):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach(t=>{null!=t&&e.push(t.complexity)}),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new Pe({computedExtent:()=>new I},this),this.computedExtent=null,this.currentRenderer=null,this.rendererHasGeometryOperations=!1,this._graphicStateTracking=null,this.graphics3DGraphics=new Map,this.stageLayer=null,this.stage=null,this._graphicsDrapedUids=new Set,this._graphicsBySymbol=new Map,this._symbolConversionCache=new Map,this._symbols=new Map,this._graphicsWithoutSymbol=new Map,this._graphicsWaitingForSymbol=new Map,this._graphicsUpdateId=0,this._frameTaskHandle=Re,this._dataUpdateQueue=new xe,this._updateQueue=new xe,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=null,this._elevationAlignment=null,this._scaleVisibility=null,this._filterVisibility=null,this._spatialIndex=null,this.extentPadding=0,this._updatingPendingLoadedGraphicsChange=null,this._featureStore=null,this._deconflictor=null,this._labeler=null,this._objectStates=null,this._viewElevationProvider=null,this._stageLayerElevationProvider=null,this._sharedSymbolResourcesOwnerHandle=null,this._whenGraphics3DGraphicRequests={},this._pendingUpdates=new Map,this._numberOfGraphics=0,this._numberOfGraphicsProvidingElevation=0,this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this._loadingSymbols=0,this.compressionTracker=new Ie,this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new p,this.preferredUpdatePolicy=1,this._forcedUpdatePolicy=null,this.elevationFeatureExpressionEnabled=!0,this.owner=null,this.layer=null,this.graphicSymbolSupported=!0,this.getRenderingInfoWithoutRenderer=!1,this.setUidToIdOnAdd=!0,this.hasZ=null,this.hasM=null,this._usedMemory=0,this._visible=!1,this._startCreateGraphics=!1,this._unusedSymbolsCache=e.owner.view.resourceController.memoryController.newCache("graphics-3d-unused-symbols",e=>e.destroy()),this.symbolCreationContext=new ce(e.owner.view.resourceController.scheduler,(e,t)=>this._updateQueue.push(e,t),e.owner.layerViewUid,this.compressionTracker)}initialize(){this._featureStore=new de({objectIdField:this.owner.layer?.objectIdField,hasZ:!!this.hasZ,hasM:!!this.hasM,viewSpatialReference:this._viewSpatialReference,featureSpatialReference:this.owner.featureSpatialReference,getSpatialIndex:()=>this.spatialIndex,forEach:e=>this.graphics3DGraphics.forEach(e)});const e=(e,t,i)=>this.spatialIndex.queryGraphicUIDsInExtent(e,t,i),{componentFactories:t}=this;this._elevationAlignment=t.elevationAlignment?.(this,e),this._scaleVisibility=t.scaleVisibility?.(this,e),this._filterVisibility=t.filterVisibility?.({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities(t=>t.setVisibilityFlag(1,4,e(H(t.graphic,this._objectIdField)))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities(t=>t.setVisibilityFlag(1,4,e)),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities(e=>e.setVisibilityFlag(1,4,!0))}),this._deconflictor=t.deconflictor?.(this),this._labeler=t.labeler?.(this,this._scaleVisibility),this._objectStates=t.objectStates?.(this),this._initializeAbortController=new AbortController,this.addHandles(m(()=>this.owner.view.state.highlights,()=>{const{highlightOrderMap:e}=this.owner.view.state;this.graphics3DGraphics.forEach(t=>t.updateHighlights(e))})),this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,t=this.owner.view;this._viewElevationProvider=new oe(this._viewSpatialReference,t),this._initializeStage(t,this.owner.layerViewUid);const i=t.sharedSymbolResources;this.symbolCreationContext.sharedResources=i,this._sharedSymbolResourcesOwnerHandle=i.addGraphicsOwner(this.owner),null!=this.currentRenderer&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=i.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=t.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new Ce(t.renderSpatialReference),this.symbolCreationContext.elevationProvider=t.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const r=le(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await he(r,this._viewSpatialReference,e,s.getLogger(this)),c(e),this.symbolCreationContext.screenSizePerspectiveEnabled=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this.symbolCreationContext.physicalBasedRenderingEnabled=!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,this.symbolCreationContext.skipHighSymbolLods=!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,"drapeSourceType"in this.owner){const{owner:e}=this;this.symbolCreationContext.drapeSourceRenderer=t.basemapTerrain.overlayManager.registerGeometryDrapeSource(e)}this.addHandles([b(()=>this.suspendedOrOutsideOfView,()=>this._updateQueue.unshift(()=>this._updateLayerVisibility(),null).catch(y)),b(()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view?.screenSizePerspectiveEnabled],()=>{const e=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())}),b(()=>this.owner.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(!!e)),b(()=>this.owner.view.state?.rasterPixelRatio,()=>this._pixelRatioChange()),b(()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._physicalBasedRenderingChange(e)),b(()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,e=>this._skipHighSymbolLoDsChange(e)),b(()=>this.owner.view.focusAreasView?.polygons,()=>this._updateFocusedLabels()),b(()=>this.owner.view.map?.focusAreas.style,()=>this.recreateAllGraphicsAndSymbols()),m(()=>t.basemapTerrain?.tilingScheme,e=>{if(e.spatialReference.equals(this.symbolCreationContext.overlaySR)||null==t.basemapTerrain.spatialReference||(this.symbolCreationContext.overlaySR=t.basemapTerrain.spatialReference),this.hasHandles("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this.addHandles([_(e,"change",e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()},{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}},{initial:!0}),b(()=>this.effectiveUpdatePolicy,e=>{null!=this.stageLayer&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=0===this.effectiveUpdatePolicy,1===e&&this.runTask(Ue)},f)]),this._frameTaskHandle=t.resourceController.scheduler.registerTask(De.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this.addHandles(b(()=>this.layer.featureReduction,()=>this._deconflictor?.featureReductionChange())),this.notifyChange("averageSymbolComplexity"),this.rendererChange(this.owner.renderer).catch(()=>{}),this._initializeAbortController=null}_abortInitialize(){this._initializeAbortController=n(this._initializeAbortController)}_updateFocusedLabels(){this.forEachGraphics3DSymbol((e,t)=>{t&&e.updateFocus(({graphic:e})=>this.recreateGraphics([e]),t)})}destroy(){if(this._unusedSymbolsCache.destroy(),this._abortInitialize(),this._rendererChangeAbortController=n(this._rendererChangeAbortController),this._abortElevationInfoChange(),this._frameTaskHandle.remove(),this._frameTaskHandle=Re,this._dataUpdateQueue.cancelAll(),this._updateQueue.cancelAll(),this._deconflictor=o(this._deconflictor),this._labeler=o(this._labeler),this._elevationAlignment=l(this._elevationAlignment),this._scaleVisibility=l(this._scaleVisibility),this._filterVisibility=l(this._filterVisibility),this._objectStates=l(this._objectStates),this.clear(),"drapeSourceType"in this.owner){const{owner:e}=this;this.stage.view.basemapTerrain.overlayManager.unregisterDrapeSource(e)}this._featureStore=l(this._featureStore),this._updatingPendingLoadedGraphicsChange=o(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=l(this._graphicStateTracking),this.stage&&(this.stageLayer=l(this.stageLayer),this.stage=null),this._set("owner",null);for(const e in this._whenGraphics3DGraphicRequests)this._whenGraphics3DGraphicRequests[e].reject(new r("graphic:layer-destroyed","Layer has been destroyed"));this._whenGraphics3DGraphicRequests=null,this._sharedSymbolResourcesOwnerHandle=o(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=l(this._propertiesPool),this._whenSymbolRemoved.prune(),this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=l(this._spatialIndex),this._symbolMaterials=null}clear(){this._objectStates?.allGraphicsDeleted(),null!=this._graphicStateTracking&&this._graphicStateTracking.allGraphicsDeleted(),this.graphics3DGraphics.forEach(e=>e.destroy()),this._spatialIndex?.clear(),this.graphics3DGraphics.clear(),this._numberOfGraphics=0,this._usedMemory=0,this._updateLayerVisibility(),this._symbols.forEach(l),this._symbols.clear(),this._symbolMaterials&&(this._symbolMaterials.length=0,this._symbolMaterials=null),this._graphicsBySymbol.clear(),this._graphicsWithoutSymbol.clear(),this._graphicsWaitingForSymbol.clear(),this._pendingUpdates.clear(),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this.notifyChange("dataUpdating"),this.notifyChange("readyToRun"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed"),this.owner.notifyContentGeometryUpdate?.()}_initializeStage(e,t){this.stage=e.stage,this.stageLayer=new we(this.stage,{visible:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},t);const i=this.stageLayer.events;i.on("transformationChanged",e=>this.notifyGraphicGeometryChanged(e.graphicUid)),i.on("shaderTransformationChanged",e=>this.notifyGraphicGeometryChanged(e.graphicUid)),i.on("visibilityChanged",e=>this.notifyGraphicVisibilityChanged(e.graphicUid)),i.on("geometryAdded",e=>this.notifyGraphicGeometryChanged(e.object.graphicUid)),i.on("geometryRemoved",e=>this.notifyGraphicGeometryChanged(e.object.graphicUid)),i.on("attributesChanged",e=>Se(e.attribute)&&this.notifyGraphicGeometryChanged(e.object.graphicUid))}notifyGraphicGeometryChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicGeometry(t)}notifyGraphicVisibilityChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicVisibility(t)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,t=this._numberOfGraphics>e*Te,i=!this.suspendedOrOutsideOfView&&!t;i!==this._visible&&(this._visible=i,this._updateStageLayerVisibility())}_updateStageLayerVisibility(){const e=this._visible&&(null==this.layer.opacity||this.layer.opacity>=Le);this.stageLayer.visible!==e&&(this.stageLayer.visible=e,e?this.updateGraphicsVisibilities():this._hideAllGraphics(),this.owner.notifyContentGeometryUpdate?.())}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,t=this.owner.layer?.objectIdField){return H(e,t)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer?.objectIdField;if(!e)return;const t=new Map;return this.graphics3DGraphics.forEach(i=>{if(!i)return;const r=i.graphic,s=this._getGraphicObjectID(r,e);null!=s&&t.set(s,i)}),t}get labelsEnabled(){return!!this._labeler?.layerLabelsEnabled()}async updateLabelingInfo(e){const t=this._deconflictor?.labelingInfoChange(e),i=this._labeler?.labelingInfoChange(e);await Promise.allSettled([t,i])}updateVisibilityInfo(){this._deconflictor?.labelingInfoChange(),this._labeler?.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=!1,t=!1;for(const[i,r]of this._symbols)if(null!=r){switch(r.getFastUpdateStatus()){case 3:return"unknown";case 1:this._graphicsBySymbol.has(i)&&(t=!0);break;case 0:this._graphicsBySymbol.has(i)&&(e=!0);break;case 2:this._graphicsBySymbol.has(i)&&(t=e=!0)}}return t?e?"mixed":"fast":e?"slow":"mixed"}runTask(e){if(this._dataUpdateQueue.runTask(e),this._updateQueue.runTask(e),this._applyPendingUpdates(e),this.notifyChange("readyToRun"),this.readyToRun||this.notifyChange("dataUpdating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return Ee}setObjectIdVisibility(e,t){t?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const i=this._findGraphics3DGraphicByObjectId(e);null!=i&&this._updateUserVisibility(i)}_findGraphics3DGraphicByObjectId(e){return a(this.graphics3DGraphics,t=>this._getGraphicObjectID(t.graphic)===e)}_updateUserVisibility(e){if(null==e)return!1;const t=e.graphic,i=this._getGraphicObjectID(t),r=t.visible&&!this.owner.suspended&&this.stageLayer.visible&&(null==i||!this._objectIdInvisibleSet.has(i));return e.setVisibilityFlag(1,1,r)}_whenGraphics3DGraphic(e){const t=this.graphics3DGraphics.get(e.uid);if(t)return Promise.resolve(t);const i=this._whenGraphics3DGraphicRequests[e.uid];if(i)return i.promise;const r=u();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,t){const i=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,t,s)=>V(e,r,t,e,i,t,s),n=(e,t,r)=>V(e,s,t,e,i,t,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:null!=t&&!!t.useViewElevation,minDemResolution:null!=t?t.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,t?.signal);if(!l)return null;const h=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){A(h,je);const t=e.getElevation(je[0],je[1],0,i,"ground")??0;h[2]=Math.min(h[2],t),h[5]=Math.max(h[5],t)}}return{boundingBox:h,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,t){await v(()=>this.owner?.loadedGraphics);const i=this.owner.layer?.objectIdField,s=this.owner.loadedGraphics.find(t=>t===e||null!=i&&null!=t.attributes&&e.attributes&&t.attributes[i]===e.attributes[i]);if(!s)throw new r("internal:graphic-not-part-of-view","Graphic is not part of this view");const a=await this._whenGraphics3DGraphic(s);return this._boundsForGraphics3DGraphic(a,t)}computeAttachmentOrigin(e,t){const i=this.graphics3DGraphics.get(e.uid);if(!i)return null;const r=i.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;P(Me,0,0,0);let s=0;if(r.render.num>0){if(!j(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,ke,t))return null;R(Me,Me,ke),s++}if(r.draped.num>0){const[e,i]=r.draped.origin,a=this._viewElevationProvider.getElevation(e,i,"ground")??0;if(P(ke,e,i,a),!j(ke,this._viewElevationProvider.spatialReference,ke,t))return null;R(Me,Me,ke),s++}return s>1&&U(Me,Me,1/s),new E({x:Me[0],y:Me[1],z:Me[2],spatialReference:t})}getSymbolLayerSize(e,t){const i=this._symbols.get(e.id);if(null==i)throw new r("internal:symbol-not-part-of-view","Symbol is not part of this view");const s=e.symbolLayers.indexOf(t);if(-1===s)throw new r("internal:missing-symbol-layer","Symbol layer is not in symbol");const a=i.getSymbolLayerSize(s);if(null==a)throw new r("internal:missing-size","Symbol layer has no valid size");return a}_graphicsCollectionChanged(e){this._startCreateGraphics&&(this.add(e.added),this.remove(e.removed))}graphicUpdateHandler(e){const t=e.graphic.uid,i=this.graphics3DGraphics.get(t);if(null!=i||null!=this._graphicsWithoutSymbol.get(t)){switch(e.property){case"visible":this._graphicUpdateVisibleHandler(i);break;case"geometry":this._graphicUpdateGeometryHandler(i,e);break;case"symbol":this._graphicUpdateSymbolHandler(i,e);break;case"attributes":case"popupTemplate":break;case"origin-transform":this._graphicUpdateTransformHandler(i,e)}this.owner.notifyContentGeometryUpdate?.()}}_graphicUpdateGeometryHandler(e,t){this._graphicUpdateGeometryOrTransformHandler(e,t,()=>!(null==t.newValue||null==e||!e.graphics3DSymbol.updateGeometry(e,t.newValue)||!(this._labeler?.updateGraphicGeometry(e)??1))&&(this._labeler?.setDirty(),!0));const i=t.graphic.geometry;null!=i&&this._expandComputedExtent(i)}_graphicUpdateTransformHandler(e,t){const i=t.graphic.geometry;this._graphicUpdateGeometryOrTransformHandler(e,t,()=>null!=t.newValue&&null!=e&&null!=i&&e.graphics3DSymbol.updateTransform(e,i.spatialReference,t.newValue,t.action))}_graphicUpdateGeometryOrTransformHandler(e,t,i){if(null!=t.graphic.geometry){if(null==e){const e=t.graphic.symbol?.id;if(e){const t=this._symbols.get(e);if(null!=t&&0===t.loadStatus)return}return void this._recreateGraphic(t.graphic)}i()||this._recreateGraphic(e.graphic)}else this._recreateGraphic(t.graphic)}_graphicUpdateSymbolHandler(e,t){const i=t.graphic,r=null!=e?e.graphics3DSymbol:null!=t.oldValue?this._symbols.get(t.oldValue.id):null;if(null==r||null==t.newValue)return void this._recreateGraphic(i);const s=r.symbol,a=this._getConvertedSymbol(t.newValue);if(null!=a&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(i);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(i);const o=G(s,a);if(null==o)return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!x(l.diff))return void this._recreateGraphic(i);const h=this._getRenderingInfo(i,!1);if(null==h)return void this._recreateGraphic(i);const d=r.extentPadding;for(const p of l.symbolStatePatches)p();if(d!==r.extentPadding&&this._recomputeExtentPadding(),null!=e)for(const p of l.graphics3DGraphicPatches)p(e,h);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,1===this.effectiveUpdatePolicy&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const t=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,t),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("dataUpdating"),t}_endGraphicUpdate(e,t){e&&(t&&this._graphicStateTracking?.updateGraphicError(e,t),this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach(t=>{null!=t&&(e=Math.max(e,t.extentPadding))}),this._set("extentPadding",e)}_expandComputedExtent(e){const t=Oe,i=e.spatialReference;B(e,t);const r=this._viewSpatialReference,s=Ve.tmpVec;if(z(i,r)||O(t[0],t[1],0,i,s,r)&&(t[0]=s[0],t[1]=s[1],O(t[3],t[4],0,i,s,r),t[3]=s[0],t[4]=s[1]),!(isFinite(t[0])&&isFinite(t[3])&&isFinite(t[1])&&isFinite(t[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(t[2])&&isFinite(t[5]),l=o&&(null==a?.zmin||t[2]<a.zmin),h=o&&(null==a?.zmax||t[5]>a.zmax);if(a){(t[0]<a.xmin||t[1]<a.ymin||t[3]>a.xmax||t[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(t[0],a.xmin),n.ymin=Math.min(t[1],a.ymin),n.xmax=Math.max(t[3],a.xmax),n.ymax=Math.max(t[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=t[0],n.ymin=t[1],n.xmax=t[3],n.ymax=t[4],n.spatialReference=r;n&&(l&&(n.zmin=t[2]),h&&(n.zmax=t[5]),this._set("computedExtent",n))}_abortElevationInfoChange(){this._elevationInfoChangeAbortController&&(this._elevationInfoChangeAbortController.abort(),this._elevationInfoChangeAbortController=null)}async elevationInfoChange(){this._abortElevationInfoChange();const e=new AbortController;this._elevationInfoChangeAbortController=e;const t=le(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await he(t,this._viewSpatialReference,e.signal,s.getLogger(this)),c(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol((e,t,i)=>{e.globalPropertyChanged("elevationInfo",t)?t?.forEach(e=>{const t=e.graphic,i=e.labelLayers;for(const r of i){r.graphics3DSymbolLayer.updateGraphicElevationContext(t,r)}}):this._recreateSymbol(i)}),this.updateStageLayerElevationProvider(),this._elevationAlignment?.elevationInfoChange()}updateStageLayerElevationProvider(){this._stageLayerElevationProvider?(this.layer.elevationInfo&&"relative-to-scene"===this.layer.elevationInfo.mode||0===this._numberOfGraphicsProvidingElevation)&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=h(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new fe({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),null!=this._filterVisibility&&this._filterVisibility.clear(),this._labeler?.reset(),this._deconflictor?.clear(),this._elevationAlignment?.clear(),this.stageLayer?.invalidateSpatialQueryAccelerator(),this._stageLayerElevationProvider&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=h(this._stageLayerElevationProvider))}startCreateGraphics(){this._startCreateGraphics=!0,this.recreateAllGraphics()}recreateAllGraphics(){this._recreateAllGraphics(!1)}recreateAllGraphicsAndSymbols(){this._recreateAllGraphics(!0)}_recreateAllGraphics(e=!1){if(!this._startCreateGraphics)return;const{loadedGraphics:t,view:i}=this.owner,r=i.basemapTerrain?.tilingScheme&&t?.length?t.toArray():null;!e&&r||this._clearSymbolsAndGraphics(),this.symbolCreationContext.screenSizePerspectiveEnabled=this.owner.view.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this._set("computedExtent",null),r&&(e?this.add(r):this.recreateGraphics(r))}_recreateSymbol(e){const t=this._graphicsBySymbol.get(e),i=[];t&&(t.forEach((e,t)=>{const r=e.usedMemory;this._conditionalRemove(e,t),this._spatialIndex?.remove(e),i.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(t,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed"),this.owner.notifyContentGeometryUpdate?.()}),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);l(r),this._symbols.delete(e),this._symbolMaterials=null,l(this._unusedSymbolsCache.pop(e)),this.add(i)}_recreateGraphicsForSymbol(e){const t=this._graphicsBySymbol.get(e);if(t){const e=[];t.forEach(t=>e.push(t.graphic)),this.recreateGraphics(e)}}_conditionalRemove(e,t){this._graphicsDrapedUids.delete(t),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),null!=this._graphicStateTracking&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain?.tilingScheme?(0===this._updatePolicyForGraphics(e)?this._addDelayed(e):this._addImmediate(e),this.notifyChange("dataUpdating")):s.getLogger(this).error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(1===this.effectiveUpdatePolicy&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const t of e)if(null!=t.geometry&&"mesh"===t.geometry.type&&!t.geometry.loaded)return 0;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const t of e)this._addGraphic(t,this._getRenderingInfo(t),1);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_addDelayed(e){for(const t of e){const e=t.uid;let i=this._pendingUpdates.get(e);i?i.add?0!==i.state&&i.abortController?.abort():this._pendingAdds++:(i=new Fe,this._pendingAdds++,this._pendingUpdates.set(e,i)),i.add=t}this.notifyChange("readyToRun"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}remove(e){0===this.effectiveUpdatePolicy?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("dataUpdating")}_removeImmediate(e){for(const t of e)this._removeGraphic(t);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_removeDelayed(e){for(const t of e){const e=t.uid,i=this._pendingUpdates.get(e);if(i)i.add&&(i.remove?i.add=null:this._pendingUpdates.delete(e),1===i.state&&i.abortController?.abort(),this._pendingAdds--);else{const i=new Fe;i.remove=t,this._pendingUpdates.set(e,i),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("readyToRun"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}_finishPendingUpdates(){this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&s.getLogger(this).warn("pendingAdds/Removes in inconsistent state!"),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1}_applyPendingUpdates(e){if(this._geometryWarningLogged=!1,this._symbolWarningLogged=!1,0===this._pendingUpdates.size&&this._spatialIndex?.updating)return this._spatialIndex.update(),void e.madeProgress();if(this._applyPendingRemovesFirst){this._applyPendingRemovesFirst=!1;for(const[t,i]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(i.remove&&!i.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,this._pendingUpdates.delete(t),0===this._pendingRemoves))break}}for(const[t,i]of this._pendingUpdates){if(e.done)break;i.add&&0===i.state&&this._processPendingUpdateNew(i);let r=this.effectiveUpdatePolicy;if(!i.remove||i.add&&2!==i.state||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,r=1),i.add)switch(i.state){case 2:this._addGraphic(i.add,i.renderingInfo,r),i.add=null,this._pendingAdds--,e.madeProgress();break;case 3:i.add=null,this._pendingAdds--}null==i.remove&&null==i.add&&this._pendingUpdates.delete(t)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("readyToRun"),this.notifyChange("dataUpdating"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=2);const t=e.add.geometry;null==t||"mesh"!==t.type||t.loaded?this._processPendingUpdateNewRenderingInfo(e):this._processPendingUpdateNewMesh(e,t)}async _processPendingUpdateNewMesh(e,t){e.state=1,e.abortController=new AbortController;const i=e.abortController.signal;try{await t.load({signal:i})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,t){e.abortController=null,g(t)?e.state=0:e.state=3}async _processPendingUpdateNewRenderingInfo(e){if(null==this.layer.renderer||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add),void(e.state=2);e.state=1,e.abortController=new AbortController;let t=null;try{t=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(i){return e.abortController=null,void(g(i)?e.state=0:e.state=3)}null==t?.symbol?(this._symbolWarningLogged||(this._symbolWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=t,e.state=2}_addGraphic(e,t,i){if(this._graphicsWithoutSymbol.set(e.uid,e),null==t?.symbol||!q(e))return;const r=this.stage.renderView.olidRenderHelper;if(r&&this.setUidToIdOnAdd){const t=X(this.owner.view,this.owner.layerViewUid);r.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.owner.layerViewUid,!!this.layer.popupEnabled&&!t&&Ge(this.layer,this.owner.view.popup?.defaultPopupTemplateEnabled))}const s=t.symbol,a=this.getOrCreateGraphics3DSymbol(s,t.renderer);if(null==a)return;this._expandComputedExtent(e.geometry);const n=this._beginGraphicUpdate(e),o=new pe(e,t,this.layer);let l=!1;const h=e=>{e===a.symbol.id&&(l=!0)};this._whenSymbolRemoved.push(h);const d=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(h);if(this._graphicsWaitingForSymbol.get(e.uid)!==n||l||a.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==a.symbol.id)--a.referenced,this._cleanupSymbols();else{const t=this._createGraphics3DGraphic(a,o);this._spatialIndex&&null!=t&&this._spatialIndex.add(t),--a.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this.owner.notifyContentGeometryUpdate?.(),this._labeler?.setDirty()},p=t=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(h),l||(g(t)?this.add([e]):a.destroyed||this._endGraphicUpdate(e,t)))};++this._loadingSymbols,0===i?a.load(()=>this._dataUpdateQueue.push(d,null).catch(y),e=>this._dataUpdateQueue.push(()=>p(e),null).catch(y)):a.load(d,p)}_removeGraphic(e){const t=e.uid,i=this.graphics3DGraphics.get(t);if(i){i.graphics3DSymbol.onRemoveGraphic(i);const e=i.usedMemory,r=i.isElevationSource;this._conditionalRemove(i,t),this._spatialIndex?.remove(i);const s=i.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(t),this._graphicsWithoutSymbol.delete(t),this._removeGraphics3DGraphic(t,e,r),i.destroy(),this._featureStore.events.emit("changed"),this.owner.notifyContentGeometryUpdate?.()}else this._graphicsWithoutSymbol.delete(t),this._graphicsWaitingForSymbol.delete(t),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating"))}_hasLabelingContext(e){if(e instanceof K||e instanceof ee){const t=this.symbolCreationContext.layer;return!!t.labelingInfo&&t.labelingInfo.some(t=>t.symbol===e)}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof K&&!this._hasLabelingContext(e))||(s.getLogger(this).error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,t=!0){const i=e.geometry;if(null==i)return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!L(i.spatialReference,this._viewSpatialReference))return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?Q(e,this.layer):e;let a;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||null!=this.currentRenderer))a=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{const e=r.symbol||ie(r.geometry);a=new Y(null,e)}return null==a?.symbol?(t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):a}_getRenderingInfoAsync(e,t){if(null==e.geometry)return this._geometryWarningLogged||(this._geometryWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return this._symbolWarningLogged||(this._symbolWarningLogged=!0,s.getLogger(this).warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const i=this.rendererHasGeometryOperations?Q(e,this.layer):e;return this.owner.getRenderingInfoAsync(i,this.currentRenderer,this._arcadeOnDemand,t)}_createGraphics3DSymbol(e,t){if(!this._hasValidSymbolCreationContext(e))return null;const i=this._getConvertedSymbol(e);if(!i)return null;let r;if(null!=t&&"backgroundFillSymbol"in t&&t.backgroundFillSymbol){const e=re(t.backgroundFillSymbol,{ignoreDrivers:!0});null!=e.symbol&&(r=e.symbol.symbolLayers)}const s=ye(i,this.symbolCreationContext,r);return s.load(()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")},()=>{}),s}getOrCreateGraphics3DSymbol(e,t){let i=this._symbols.get(e.id);if(void 0===i){const r=this._unusedSymbolsCache.pop(e.id);i=null!=r?r:e instanceof te?new ue(e,e=>this._dataUpdateQueue.push(e,null),e=>this._createGraphics3DSymbol(e,t)):this._createGraphics3DSymbol(e,t),this._symbols.set(e.id,i),this._symbolMaterials=null}return null!=i&&++i.referenced,i}trackGraphicState(e){return null==this._graphicStateTracking&&(this._graphicStateTracking=new me(this)),this._graphicStateTracking.add(e)}_addGraphics3DGraphic(e){this._usedMemory+=e.usedMemory,this.graphics3DGraphics.set(e.graphic.uid,e),this._numberOfGraphics++,e.isElevationSource&&(this._numberOfGraphicsProvidingElevation++,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_removeGraphics3DGraphic(e,t,i=!1){this._usedMemory-=t,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,i&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,t){const{graphic:i}=t;if(this._graphicsWithoutSymbol.delete(i.uid),!this._symbols.has(e.symbol.id))return this.add([i]),null;if(this.graphics3DGraphics.has(i.uid))return null;const r=e.createGraphics3DGraphic(t);if(null==r)return null;this._addGraphics3DGraphic(r);const s=e.symbol.id;this._graphicsBySymbol.has(s)||this._graphicsBySymbol.set(s,new Map),this._graphicsBySymbol.get(s).set(i.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(i.uid),r.centroid=null,null!=i.geometry&&"point"!==i.geometry.type&&(r.centroid=be(i.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(r),null!=this._filterVisibility){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(1,4,e),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),r.initialize(this.stageLayer),null!=this._graphicStateTracking&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[i.uid];return a&&(delete this._whenGraphics3DGraphicRequests[i.uid],a.resolve(r)),this._symbolMaterials=null,r}async rendererChange(e){if(this._rendererChangeAbortController=n(this._rendererChangeAbortController),e!==this.currentRenderer)if(this._validateRenderer(e),null==e&&this._currentRendererChange(null,!1),$(e))if(e?.arcadeRequired){const t=new AbortController;this._rendererChangeAbortController=t;const{arcadeUtils:i}=await this._ensureArcade();c(t);const r=i.hasGeometryOperations(e);r&&(await i.enableGeometryOperations(),c(t)),0===this.effectiveUpdatePolicy?await this._updateQueue.push(()=>this._currentRendererChange(e,r),t.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(0===this.effectiveUpdatePolicy){const t=new AbortController;this._rendererChangeAbortController=t,await this._updateQueue.push(()=>this._currentRendererChange(e,!1),t.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return null==this._arcadeOnDemand?(this._arcadeOnDemand=await J(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,t){this.currentRenderer=e,this.rendererHasGeometryOperations=t,this.symbolCreationContext.arcade=this._arcadeOnDemand;const i=this.symbolCreationContext.renderer;if(e===i)return;if(this._symbolConversionCache.clear(),this._unusedSymbolsCache.clear(),null==e)return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=G(i,e);this._updateUnchangedSymbolMappings(r,e,i),this.symbolCreationContext.renderer=e,null!=r&&("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,i)?this._labeler?.reset():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const t in e.diff)switch(t){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[t];break;default:return!0}return!1}_applySymbolSetDiff(e,t,i){e=e||[],t=t||[];const r=[];for(const s of t){const t=this._graphicsBySymbol.get(s.id);t&&t.forEach((a,n)=>{const o=a.graphic,l=this.layer instanceof W?this.layer:null,h=this._arcadeOnDemand;if(s===i.defaultSymbol&&i.getSymbol(Q(o,l),{arcade:h})===i.defaultSymbol)return;const d=a.usedMemory;e.length||i.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),t.delete(n),this._removeGraphics3DGraphic(n,d),this._updateLayerVisibility()}),this._whenSymbolRemoved.forAll(e=>e(s.id))}(e.length||r.length)&&(this._graphicsWithoutSymbol.forEach(e=>r.push(e)),this._graphicsWithoutSymbol.clear(),this.add(r)),this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_applyUniqueValueRendererDiff(e,t,r){const s=e.diff.defaultSymbol,a=e.diff.uniqueValueInfos;if(s||a){const n=a?.changed,o=a?.unchanged;if(n&&o&&n.some(e=>o.some(t=>t.oldValue.symbol?.id===e.oldValue.symbol?.id)))return!1;const l=a?a.added.map(e=>e.symbol).filter(i):[],h=a?a.removed.map(e=>e.symbol).filter(i):[];if(n)for(let e=0;e<n.length;e++)l.push(n[e].newValue.symbol),h.push(n[e].oldValue.symbol);return s?(r.defaultSymbol&&h.push(r.defaultSymbol),t.defaultSymbol&&l.push(t.defaultSymbol)):r.defaultSymbol&&l.length&&h.push(t.defaultSymbol),this._applySymbolSetDiff(l,h,t),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,t,i){if("unique-value"!==t?.type||"unique-value"!==i?.type||null!=e&&"partial"!==e.type)return[];const r=e=>null!=e?e.id:null,s=e&&e.diff,a=s?.defaultSymbol,n=s&&s.uniqueValueInfos;let o;if(n)o=n.unchanged.map(e=>({oldId:r(e.oldValue.symbol),newId:r(e.newValue.symbol)}));else{o=[];for(const e of i.uniqueValueInfos??[]){const i=r(e.symbol),s=t.uniqueValueInfos?.find(t=>t.value===e.value);s&&i!==r(s.symbol)&&o.push({oldId:i,newId:r(s.symbol)})}}return!a&&i.defaultSymbol&&o.push({oldId:r(i.defaultSymbol),newId:r(t.defaultSymbol)}),o}_updateSymbolMapping(e,t){const i=null!=t&&t?"string"==typeof t?t:t.id:null;if(null==e||e===i)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(i,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(i,s),this._symbolMaterials=null,null!=s)){const e="string"==typeof t?null:t;null!=e?s.symbol=e:s.symbol.id=i}}_updateUnchangedSymbolMappings(e,t,i){const r=this._calculateUnchangedSymbolMapping(e,t,i);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,t,i){if(this._diffHasSymbolChange(e))return!1;if(t instanceof N&&i instanceof N&&this._applyUniqueValueRendererDiff(e,t,i)&&0===Object.keys(e.diff).length)return!0;for(const r of this._graphicsBySymbol.keys()){const i=this._symbols.get(r);if(null!=i)switch(i.applyRendererDiff(e,t)){case 0:this._recreateSymbol(r);break;case 1:this._recreateGraphicsForSymbol(r)}}return!0}opacityChange(){this._updateStageLayerVisibility(),this.forEachGraphics3DSymbol((e,t)=>e.globalPropertyChanged("opacity",t))}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol((e,t)=>e.globalPropertyChanged("slicePlaneEnabled",t)),this._deconflictor?.slicePlaneEnabledChange(),this._labeler?.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol((e,t,i)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",t)||this._recreateSymbol(i)})}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol((e,t,i)=>{e.globalPropertyChanged("skipHighSymbolLods",t)||this._recreateSymbol(i)})}_pixelRatioChange(){this.forEachGraphics3DSymbol((e,t,i)=>{e.globalPropertyChanged("pixelRatio",t)||this._recreateSymbol(i)})}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=C(()=>{this._updatingPendingLoadedGraphicsChange=null})}setClippingExtent(e,t){const i=this.symbolCreationContext.clippingExtent,r=k();return ve(e,r,t)?this.symbolCreationContext.clippingExtent=T(F(),r):this.symbolCreationContext.clippingExtent=null,!M(this.symbolCreationContext.clippingExtent,i)}modifyGraphics3DGraphicVisibilities(e){if(this.destroyed)return;let t=!1;this.graphics3DGraphics.forEach(i=>{e(i)&&(t=!0)}),t&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}forEachGraphics3DSymbol(e,t){for(const[i,r]of this._symbols){if(null==r)return;e(r,this._graphicsBySymbol.get(i)||ze,i)}if(!t?.excludeUnused)for(const i of this._unusedSymbolsCache)e(i,void 0,i.symbol.id)}updateGraphicsVisibilities(){null!=this._filterVisibility&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities(e=>{const t=this._updateUserVisibility(e),i=!!this._scaleVisibility?.updateVisibility(e);return t||i})}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities(e=>e.setVisibilityFlag(1,1,!1))}_validateRenderer(e){const t=()=>`'${this.layer.title?`${this.layer.title}, `:""}id:${this.layer.id}'`,i=Z(e,{geometryType:this.layer?.geometryType,logWarning:(e,i)=>s.getLogger(this).warn(e,`Symbology conversion for layer ${t()}: ${i}`)});if(i){const e=`Renderer for layer ${t} is not supported in a SceneView`;s.getLogger(this).warn(e,i.message)}}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach((t,i)=>{if(null==t||t.referenced>0)return;const r=this._graphicsBySymbol.get(i);r&&0!==r.size||(this._graphicsBySymbol.delete(i),this._symbols.delete(i),this._symbolMaterials=null,this._unusedSymbolsCache.put(i,t,d),e=!0)}),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){}get performanceInfo(){return new ge(this.graphics3DGraphics.size,Array.from(this.graphics3DGraphics.values()).reduce((e,t)=>e+(t.isVisible()?1:0),0),this._graphicsWithoutSymbol.size,this._pendingUpdates.size)}};e([S({readOnly:!0})],Ae.prototype,"computedExtent",void 0),e([S()],Ae.prototype,"currentRenderer",void 0),e([S()],Ae.prototype,"rendererHasGeometryOperations",void 0),e([S()],Ae.prototype,"_frameTaskHandle",void 0),e([S()],Ae.prototype,"_dataUpdateQueue",void 0),e([S()],Ae.prototype,"_updateQueue",void 0),e([S({readOnly:!0})],Ae.prototype,"_viewSpatialReference",null),e([S()],Ae.prototype,"_rendererChangeAbortController",void 0),e([S()],Ae.prototype,"_elevationInfoChangeAbortController",void 0),e([S()],Ae.prototype,"_initializeAbortController",void 0),e([S()],Ae.prototype,"_elevationAlignment",void 0),e([S()],Ae.prototype,"_scaleVisibility",void 0),e([S()],Ae.prototype,"_filterVisibility",void 0),e([S()],Ae.prototype,"_initializePromise",void 0),e([S()],Ae.prototype,"_spatialIndex",void 0),e([S({readOnly:!0})],Ae.prototype,"extentPadding",void 0),e([S()],Ae.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([S()],Ae.prototype,"_featureStore",void 0),e([S()],Ae.prototype,"_objectStates",void 0),e([S()],Ae.prototype,"_loadingSymbols",void 0),e([S({constructOnly:!0})],Ae.prototype,"compressionTracker",void 0),e([S()],Ae.prototype,"preferredUpdatePolicy",void 0),e([S()],Ae.prototype,"_forcedUpdatePolicy",void 0),e([S({readOnly:!0})],Ae.prototype,"effectiveUpdatePolicy",null),e([S({constructOnly:!0})],Ae.prototype,"elevationFeatureExpressionEnabled",void 0),e([S({constructOnly:!0})],Ae.prototype,"owner",void 0),e([S({constructOnly:!0})],Ae.prototype,"layer",void 0),e([S({constructOnly:!0})],Ae.prototype,"graphicSymbolSupported",void 0),e([S({constructOnly:!0})],Ae.prototype,"getRenderingInfoWithoutRenderer",void 0),e([S({constructOnly:!0})],Ae.prototype,"componentFactories",void 0),e([S({constructOnly:!0})],Ae.prototype,"setUidToIdOnAdd",void 0),e([S()],Ae.prototype,"featureStore",null),e([S()],Ae.prototype,"initializePromise",null),e([S()],Ae.prototype,"scaleVisibility",null),e([S()],Ae.prototype,"elevationAlignment",null),e([S()],Ae.prototype,"objectStates",null),e([S()],Ae.prototype,"filterVisibility",null),e([S({readOnly:!0})],Ae.prototype,"updating",null),e([S({readOnly:!0})],Ae.prototype,"dataUpdating",null),e([S({readOnly:!0})],Ae.prototype,"readyToRun",null),e([S({readOnly:!0})],Ae.prototype,"suspendedOrOutsideOfView",null),e([S({readOnly:!0,dependsOn:[]})],Ae.prototype,"updatingRemaining",null),e([S({readOnly:!0})],Ae.prototype,"displayFeatureLimit",null),e([S({readOnly:!0,dependsOn:[]})],Ae.prototype,"averageSymbolComplexity",null),e([S({constructOnly:!0})],Ae.prototype,"hasZ",void 0),e([S({constructOnly:!0})],Ae.prototype,"hasM",void 0),e([S()],Ae.prototype,"_objectIdField",null),Ae=Ve=e([w("esri.views.3d.layers.graphics.Graphics3DCore")],Ae);class Fe{constructor(){this.add=null,this.renderingInfo=null,this.state=0,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=0,this.abortController=null,this.remove=null}}const Te=10,Me=D(),ke=D(),ze=new Map;export{Ae as Graphics3DCore};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import t from"../../../../core/Error.js";import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n,invertOrIdentity as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as c,t as p,a as m,h,n as d,c as u,d as g}from"../../../../chunks/vec32.js";import{ONES as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as _,fromBuffer as x,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as S}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as P,getZeroIndexArray as v}from"../../../../geometry/support/Indices.js";import{t as w}from"../../../../chunks/vec3.js";import{makeVertexCandidate as C,makeEdgeCandidate as E}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as A}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as D,SampleElevationInfo as z}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as I,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as L}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as M,computeCentroid as O}from"./graphicUtils.js";import{geometryAsPolygon as G}from"./polygonUtils.js";import{createMaterial as V}from"../support/edgeUtils.js";import{encodeNaNUInt8 as T}from"../support/symbolColorUtils.js";import{debugFlags as B}from"../../support/debugFlags.js";import{SamplePosition as R}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as F}from"../../support/renderInfoUtils/polygon.js";import{Attribute as H}from"../../webgl-engine/lib/Attribute.js";import{Geometry as k}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as N}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as W,compressNormal as q}from"../../webgl-engine/lib/Normals.js";import{Object3D as Z}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as J}from"../../webgl-engine/materials/DefaultMaterial.js";const K=["polygon","extent"];class Q extends L{constructor(t,e,r,s){super(t,e,r,s,ht(e)),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const e=M(this._getSymbolSize());if(e)throw new t("graphics3dextrudesymbollayer:invalid-size",e)}const e=this.symbolLayer,r=e?.material,s=this.symbolLayer.material?.color?.a,o=this.needsDrivenTransparentPass||null!=s&&1!==s,i=r?.emissive,n=!this._hasDrivenColorOrOpacity&&(null==s||0===s),a={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:f,diffuse:f,opacity:n?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:o,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:e.castShadows,emissiveStrength:i?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},l=new J(a,this._context),c=new J({...a,cullFace:2},this._context);this._materials[0]=l,this._materials[1]=c,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,K,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(t.renderingInfo,this._materialColor,!1);T(r,r);const s=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),t?.forEach(t=>e(t)?.layerOpacityChanged(r,this._context.isAsync))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,D)}slicePlaneEnabledChanged(t,e){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t?.forEach(t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(t),this._materials[1]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?A(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?0:1}async queryForSnapping(t,s,o,i){const n=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/r(s),{objectId:a,target:l}=t,c=e(l);switch(c.z=(c.z??0)+n,t.type){case"edge":{const{start:r,end:s}=t,o=e(r),i=e(s);return o.z=(o.z??0)+n,i.z=(i.z??0)+n,[E(a,c,1/0,o,i)]}case"vertex":return[C(a,c,1/0),E(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,a,c){const p=G(t.geometry);if(null==p)return null;if(0===p.rings.length||!p.rings.some(t=>t.length>0))return this._logGeometryValidationWarnings(p.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=F(p,this._context.elevationProvider,this._context.renderCoordsHelper,a);this._logGeometryCreationWarnings(m,p.rings,"rings","ExtrudeSymbol3DLayer");const h=O(p);if(null==h)return null;const d=new Array,u=new Array,g=_(),f=l(),v=y(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,v),b(p.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const E=l();n(E,f);const A=i();o(A,E);const{polygons:z,mapPositions:L,position:M}=m,T=new Map,B=this._materials[0];for(const o of z){const t=o.count;if(this._context.clippingExtent&&(x(o.mapPositions,g),!j(g,this._context.clippingExtent)))continue;const i=s(o.mapPositions,o.holeIndices,3);if(0===i.length)continue;const n=i.length,a=6*t,l=P(a+n),p=P(n),m=S(3*a),h=S(3*a),y=S(3*a),b=S(a);Y(M,L,i,o,m,y,h,b,l,p,this._getExtrusionSize(e),v,C),w(m,m,E);const _=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),A=new Pt(m,y,W(h),b),D=X(B,l,l.length-p.length,A,r,_),z=t,I=t,U=2*o.count,O=new vt(z,I,U,n/3);mt(D,O,f),T.set(D,O),d.push(D,X(this._materials[1],p,0,A,r,_)),u.push(A.heights)}if(0===d.length)return null;const R=new Z({geometries:d,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});R.transformation=f;const H=V(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=H?new I(this._materials[0],H,this._context.slicePlaneEnabled):null,N=new U(this,R,null,(t,e,r,s,o)=>pt(t,e,r,s,o,u,T),a,k);return N.alignedSampledElevation=m.sampledElevation,N.needsElevationUpdates=D(a.mode),N}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const t=this._materials[0];t&&t.setParameters({cullFace:t.transparent?0:2})}}function X(t,e,r,s,o,i){const n=v(e.length),a=[["position",new H(s.positions,e,3,!0)],["normalCompressed",new H(s.normals,e,2,!0)],["symbolColor",new H(o,n,4,!0)]];return new k(t,a,s.elevation,0,i,r)}function Y(t,e,r,s,o,i,n,a,l,c,p,m,h){const d=r.length/3;let u=2*s.count;$(t,e,s.index,s.count,r,0,d,o,i,n,a,l,c,u,p,m,h);let g=0,f=2*s.count;u=0;const y=s.pathLengths[0];rt(o,i,a,n,g,y,s.count,f,l,u,p),f+=4*y,u+=2*y,g+=y;for(let b=1;b<s.pathLengths.length;++b){const t=s.pathLengths[b];rt(o,i,a,n,g,t,s.count,f,l,u,p),f+=4*t,u+=2*t,g+=t}}function $(t,e,r,s,o,i,n,a,l,c,p,m,h,g,f,y,b){u(ut,y),l??=[],c??=[],p??=[];const _=f>0?1:-1;let x=3*r,j=0,S=3*j,P=s,v=3*P;for(let u=0;u<s;++u){const r=t[x],s=t[x+1],o=t[x+2];b&&(ut[0]=r,ut[1]=s,ut[2]=o,d(ut,ut)),a[S+0]=r,a[S+1]=s,a[S+2]=o;const i=e[x+0],n=e[x+1],m=e[x+2];l[S+0]=i,l[S+1]=n,l[S+2]=m,c[S+0]=-_*ut[0],c[S+1]=-_*ut[1],c[S+2]=-_*ut[2],p[j]=0,a[v+0]=r+f*ut[0],a[v+1]=s+f*ut[1],a[v+2]=o+f*ut[2],l[v+0]=i,l[v+1]=n,l[v+2]=m,p[P]=f,S+=3,v+=3,x+=3,j+=1,P+=1}x=3*i,S=0,v=3*g;const w=f<0?yt:ft,C=f<0?ft:yt;for(let d=0;d<n;++d)h[S]=o[x+w[0]],h[S+1]=o[x+w[1]],h[S+2]=o[x+w[2]],m[v]=o[x+C[0]]+s,m[v+1]=o[x+C[1]]+s,m[v+2]=o[x+C[2]]+s,S+=3,v+=3,x+=3}function tt(t,e,r,s,o,i,n){s[i]=s[n],n*=3,t[i*=3]=t[n],t[i+1]=t[n+1],t[i+2]=t[n+2],e[i]=e[n],e[i+1]=e[n+1],e[i+2]=e[n+2],r[i]=o[0],r[i+1]=o[1],r[i+2]=o[2]}const et=y();function rt(t,e,r,s,o,i,n,a,l,c,p){e??=[],r??=[],s??=[];let m=o,h=o+1,d=o+n,u=o+n+1,g=a,f=a+1,y=a+2*i,b=a+2*i+1;p<0&&(m=o+n+1,u=o);let _=3*c;for(let x=0;x<i;++x)x===i-1&&(h=o,p>0?u=o+n:m=o+n),lt(t,m,h,d,et),tt(t,e,s,r,et,g,m),tt(t,e,s,r,et,f,h),tt(t,e,s,r,et,y,d),tt(t,e,s,r,et,b,u),l[_]=g,l[_+1]=y,l[_+2]=b,l[_+3]=g,l[_+4]=b,l[_+5]=f,_+=6,m++,h++,d++,u++,g+=2,f+=2,y+=2,b+=2}const st=y(),ot=y(),it=y(),nt=y(),at=y();function lt(t,e,r,s,o){e*=3,r*=3,s*=3,c(st,t[e++],t[e++],t[e++]),c(ot,t[r++],t[r++],t[r++]),c(it,t[s++],t[s++],t[s++]),g(nt,ot,st),g(at,it,st),h(o,at,nt),d(o,o)}const ct=y();function pt(t,e,r,s,o,i,n){const m=t.stageObject,h=m.geometries,d=h.length,u="absolute-height"!==e.mode;let g=0;const f=m.transformation,y=a(l(),f);for(let a=0;a<d;a+=2){const t=h[a];if(!N(t))continue;const e=t.getMutableAttribute("position").data,l=i[a/2],d=new R(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let i=0;i<b;i++){ct[0]=e[t],ct[1]=e[t+1],ct[2]=e[t+2],s(d,gt),u&&(x+=gt.sampledElevation),B.TESTS_DISABLE_OPTIMIZATIONS?(c(dt,d.array[d.offset],d.array[d.offset+1],gt.z+l[t/3]),null!=r&&o.toRenderCoords(dt,r,dt),p(dt,dt,y)):(c(dt,e[t],e[t+1],e[t+2]),p(dt,dt,f),o.setAltitude(dt,gt.z+l[t/3]),p(dt,dt,y)),e[t]=dt[0],e[t+1]=dt[1],e[t+2]=dt[2];const i=bt/o.unitInMeters;(Math.abs(ct[0]-e[t])>=i||Math.abs(ct[1]-e[t+1])>=i||Math.abs(ct[2]-e[t+2])>=i)&&(_=!0),d.offset+=3,t+=3}}if(_){const e=n.get(t);e&&mt(t,e,f),m.geometryVertexAttributeUpdated(h[a],"normalCompressed"),t.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(h[a],"position"),h[a+1].invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(h[a+1],"position")}g+=x/b}return g/d}function mt(t,e,r){const s=t.getMutableAttribute("position"),o=t.getMutableAttribute("normalCompressed").data,{topVertexStart:i,topVertexCount:n,topFaceStart:a,topFaceCount:l}=e,u=s.data,g=n,f=t.attributes.get("position").indices,y=a+l,b=i+n,_=S(3*g);for(let c=0;c<g;++c){const t=3*c;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=_t,j=xt,P=jt,v=St,w=ut;for(let S=a;S<y;++S){const t=3*S;for(let e=0;e<3;++e){const s=f[t+e];v[e]=s;const o=3*s;c(dt,u[o+0],u[o+1],u[o+2]),p(x[e],dt,r)}m(j,x[1],x[0]),m(P,x[2],x[0]),h(w,j,P),d(w,w);for(let e=0;e<3;++e){const t=3*(v[e]-i);_[t+0]+=w[0],_[t+1]+=w[1],_[t+2]+=w[2]}}for(let c=i;c<b;++c){const t=3*(c-i),e=_[t+0],r=_[t+1],s=_[t+2],n=Math.sqrt(e*e+r*r+s*s);q(o,c,e/n,r/n,s/n)}}function ht(t){return 1===(t.material?.color?.a??0)}const dt=y(),ut=y(),gt=new z,ft=[0,2,1],yt=[0,1,2],bt=.01,_t=[y(),y(),y()],xt=y(),jt=y(),St=[0,0,0];class Pt{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class vt{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{Q as Graphics3DExtrudeSymbolLayer,Y as extrudePolygon};
5
+ import"../../../../core/has.js";import{clone as t}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as e}from"../../../../core/unitUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n,invertOrIdentity as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{i as l,t as c,a as p,h as m,n as h,c as u,d}from"../../../../chunks/vec32.js";import{ONES as g,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as y}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as b,fromBuffer as _,intersectsClippingArea as x}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as j}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as S,getZeroIndexArray as P}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec3.js";import{makeVertexCandidate as w,makeEdgeCandidate as C}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as E}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as A,SampleElevationInfo as D}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as I,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as L}from"./Graphics3DSymbolLayer.js";import{computeCentroid as M}from"./graphicUtils.js";import{geometryAsPolygon as O}from"./polygonUtils.js";import{createMaterial as z}from"../support/edgeUtils.js";import{encodeNaNUInt8 as G}from"../support/symbolColorUtils.js";import{debugFlags as V}from"../../support/debugFlags.js";import{SamplePosition as T}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as B}from"../../support/renderInfoUtils/polygon.js";import{Attribute as R}from"../../webgl-engine/lib/Attribute.js";import{Geometry as F}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as H}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as k,compressNormal as N}from"../../webgl-engine/lib/Normals.js";import{Object3D as W}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as q}from"../../webgl-engine/materials/DefaultMaterial.js";const Z=["polygon","extent"];class J extends L{constructor(t,e,r,s){super(t,e,r,s,pt(e)),this.ensureDrapedStatus(!1)}async doLoad(){const t=this.symbolLayer,e=t?.material,r=this.symbolLayer.material?.color?.a,s=this.needsDrivenTransparentPass||null!=r&&1!==r,o=e?.emissive,n=!this._hasDrivenColorOrOpacity&&(null==r||0===r),i={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:g,diffuse:g,opacity:n?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:t.castShadows,emissiveStrength:o?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},a=new q(i,this._context),l=new q({...i,cullFace:2},this._context);this._materials[0]=a,this._materials[1]=l,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,Z,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(t.renderingInfo,this._materialColor,!1);G(r,r);const s=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),t?.forEach(t=>e(t)?.layerOpacityChanged(r,this._context.isAsync))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,A)}slicePlaneEnabledChanged(t,e){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t?.forEach(t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(t),this._materials[1]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?E(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?0:1}async queryForSnapping(r,s,o,n){const i=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/e(s),{objectId:a,target:l}=r,c=t(l);switch(c.z=(c.z??0)+i,r.type){case"edge":{const{start:e,end:s}=r,o=t(e),n=t(s);return o.z=(o.z??0)+i,n.z=(n.z??0)+i,[C(a,c,1/0,o,n)]}case"vertex":return[w(a,c,1/0),C(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,i,l,c){const p=O(t.geometry);if(null==p)return null;if(0===p.rings.length||!p.rings.some(t=>t.length>0))return this._logGeometryValidationWarnings(p.rings,"rings","ExtrudeSymbol3DLayer"),null;const m=B(p,this._context.elevationProvider,this._context.renderCoordsHelper,l);this._logGeometryCreationWarnings(m,p.rings,"rings","ExtrudeSymbol3DLayer");const h=M(p);if(null==h)return null;const u=new Array,d=new Array,g=b(),P=a(),w=f(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,w),y(p.spatialReference,[h.x,h.y,0],P,this._context.renderCoordsHelper.spatialReference);const E=a();n(E,P);const D=o();s(D,E);const{polygons:L,mapPositions:G,position:V}=m,T=new Map,R=this._materials[0];for(const s of L){const t=s.count;if(this._context.clippingExtent&&(_(s.mapPositions,g),!x(g,this._context.clippingExtent)))continue;const o=r(s.mapPositions,s.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,l=S(a+n),p=S(n),m=j(3*a),h=j(3*a),f=j(3*a),y=j(a);Q(V,G,o,s,m,f,h,y,l,p,this._getExtrusionSize(e),w,C),v(m,m,E);const b=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),A=new jt(m,f,k(h),y),D=K(R,l,l.length-p.length,A,i,b),I=t,U=t,L=2*s.count,M=new St(I,U,L,n/3);ct(D,M,P),T.set(D,M),u.push(D,K(this._materials[1],p,0,A,i,b)),d.push(A.heights)}if(0===u.length)return null;const F=new W({geometries:u,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});F.transformation=P;const H=z(this.symbolLayer,{opacity:this._getLayerOpacity()}),N=H?new I(this._materials[0],H,this._context.slicePlaneEnabled):null,q=new U(this,F,null,(t,e,r,s,o)=>lt(t,e,r,s,o,d,T),l,N);return q.alignedSampledElevation=m.sampledElevation,q.needsElevationUpdates=A(l.mode),q}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const t=this._materials[0];t&&t.setParameters({cullFace:t.transparent?0:2})}}function K(t,e,r,s,o,n){const i=P(e.length),a=[["position",new R(s.positions,e,3,!0)],["normalCompressed",new R(s.normals,e,2,!0)],["symbolColor",new R(o,i,4,!0)]];return new F(t,a,s.elevation,0,n,r)}function Q(t,e,r,s,o,n,i,a,l,c,p,m,h){const u=r.length/3;let d=2*s.count;X(t,e,s.index,s.count,r,0,u,o,n,i,a,l,c,d,p,m,h);let g=0,f=2*s.count;d=0;const y=s.pathLengths[0];tt(o,n,a,i,g,y,s.count,f,l,d,p),f+=4*y,d+=2*y,g+=y;for(let b=1;b<s.pathLengths.length;++b){const t=s.pathLengths[b];tt(o,n,a,i,g,t,s.count,f,l,d,p),f+=4*t,d+=2*t,g+=t}}function X(t,e,r,s,o,n,i,a,l,c,p,m,d,g,f,y,b){u(ht,y),l??=[],c??=[],p??=[];const _=f>0?1:-1;let x=3*r,j=0,S=3*j,P=s,v=3*P;for(let u=0;u<s;++u){const r=t[x],s=t[x+1],o=t[x+2];b&&(ht[0]=r,ht[1]=s,ht[2]=o,h(ht,ht)),a[S+0]=r,a[S+1]=s,a[S+2]=o;const n=e[x+0],i=e[x+1],m=e[x+2];l[S+0]=n,l[S+1]=i,l[S+2]=m,c[S+0]=-_*ht[0],c[S+1]=-_*ht[1],c[S+2]=-_*ht[2],p[j]=0,a[v+0]=r+f*ht[0],a[v+1]=s+f*ht[1],a[v+2]=o+f*ht[2],l[v+0]=n,l[v+1]=i,l[v+2]=m,p[P]=f,S+=3,v+=3,x+=3,j+=1,P+=1}x=3*n,S=0,v=3*g;const w=f<0?gt:dt,C=f<0?dt:gt;for(let h=0;h<i;++h)d[S]=o[x+w[0]],d[S+1]=o[x+w[1]],d[S+2]=o[x+w[2]],m[v]=o[x+C[0]]+s,m[v+1]=o[x+C[1]]+s,m[v+2]=o[x+C[2]]+s,S+=3,v+=3,x+=3}function Y(t,e,r,s,o,n,i){s[n]=s[i],i*=3,t[n*=3]=t[i],t[n+1]=t[i+1],t[n+2]=t[i+2],e[n]=e[i],e[n+1]=e[i+1],e[n+2]=e[i+2],r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2]}const $=f();function tt(t,e,r,s,o,n,i,a,l,c,p){e??=[],r??=[],s??=[];let m=o,h=o+1,u=o+i,d=o+i+1,g=a,f=a+1,y=a+2*n,b=a+2*n+1;p<0&&(m=o+i+1,d=o);let _=3*c;for(let x=0;x<n;++x)x===n-1&&(h=o,p>0?d=o+i:m=o+i),it(t,m,h,u,$),Y(t,e,s,r,$,g,m),Y(t,e,s,r,$,f,h),Y(t,e,s,r,$,y,u),Y(t,e,s,r,$,b,d),l[_]=g,l[_+1]=y,l[_+2]=b,l[_+3]=g,l[_+4]=b,l[_+5]=f,_+=6,m++,h++,u++,d++,g+=2,f+=2,y+=2,b+=2}const et=f(),rt=f(),st=f(),ot=f(),nt=f();function it(t,e,r,s,o){e*=3,r*=3,s*=3,l(et,t[e++],t[e++],t[e++]),l(rt,t[r++],t[r++],t[r++]),l(st,t[s++],t[s++],t[s++]),d(ot,rt,et),d(nt,st,et),m(o,nt,ot),h(o,o)}const at=f();function lt(t,e,r,s,o,n,p){const m=t.stageObject,h=m.geometries,u=h.length,d="absolute-height"!==e.mode;let g=0;const f=m.transformation,y=i(a(),f);for(let i=0;i<u;i+=2){const t=h[i];if(!H(t))continue;const e=t.getMutableAttribute("position").data,a=n[i/2],u=new T(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let n=0;n<b;n++){at[0]=e[t],at[1]=e[t+1],at[2]=e[t+2],s(u,ut),d&&(x+=ut.sampledElevation),V.TESTS_DISABLE_OPTIMIZATIONS?(l(mt,u.array[u.offset],u.array[u.offset+1],ut.z+a[t/3]),null!=r&&o.toRenderCoords(mt,r,mt),c(mt,mt,y)):(l(mt,e[t],e[t+1],e[t+2]),c(mt,mt,f),o.setAltitude(mt,ut.z+a[t/3]),c(mt,mt,y)),e[t]=mt[0],e[t+1]=mt[1],e[t+2]=mt[2];const n=ft/o.unitInMeters;(Math.abs(at[0]-e[t])>=n||Math.abs(at[1]-e[t+1])>=n||Math.abs(at[2]-e[t+2])>=n)&&(_=!0),u.offset+=3,t+=3}}if(_){const e=p.get(t);e&&ct(t,e,f),m.geometryVertexAttributeUpdated(h[i],"normalCompressed"),t.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(h[i],"position"),h[i+1].invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(h[i+1],"position")}g+=x/b}return g/u}function ct(t,e,r){const s=t.getMutableAttribute("position"),o=t.getMutableAttribute("normalCompressed").data,{topVertexStart:n,topVertexCount:i,topFaceStart:a,topFaceCount:u}=e,d=s.data,g=i,f=t.attributes.get("position").indices,y=a+u,b=n+i,_=j(3*g);for(let l=0;l<g;++l){const t=3*l;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=yt,S=bt,P=_t,v=xt,w=ht;for(let j=a;j<y;++j){const t=3*j;for(let e=0;e<3;++e){const s=f[t+e];v[e]=s;const o=3*s;l(mt,d[o+0],d[o+1],d[o+2]),c(x[e],mt,r)}p(S,x[1],x[0]),p(P,x[2],x[0]),m(w,S,P),h(w,w);for(let e=0;e<3;++e){const t=3*(v[e]-n);_[t+0]+=w[0],_[t+1]+=w[1],_[t+2]+=w[2]}}for(let l=n;l<b;++l){const t=3*(l-n),e=_[t+0],r=_[t+1],s=_[t+2],i=Math.sqrt(e*e+r*r+s*s);N(o,l,e/i,r/i,s/i)}}function pt(t){return 1===(t.material?.color?.a??0)}const mt=f(),ht=f(),ut=new D,dt=[0,2,1],gt=[0,1,2],ft=.01,yt=[f(),f(),f()],bt=f(),_t=f(),xt=[0,0,0];class jt{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class St{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{J as Graphics3DExtrudeSymbolLayer,Q as extrudePolygon};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{emptyArray as e}from"../../../../core/arrayUtils.js";import{forEach as t}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{estimateAttributesMemory as i}from"../../../../core/memoryEstimations.js";import r from"../../../../core/ObjectPool.js";import{scale as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{g as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import n from"../../../../geometry/Polygon.js";import{projectBoundingRect as h}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as c,expandWithAABB as p,allFinite as y,toRect as m,set as u,zero as d}from"../../../../geometry/support/aaBoundingBox.js";import{create as b,allFinite as g}from"../../../../geometry/support/aaBoundingRect.js";import{equals as f}from"../../../../geometry/support/spatialReferenceUtils.js";import{computeAABR as _}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromGeometry as E}from"../../../../layers/graphics/featureConversionUtils.js";import{createFeature as L}from"./featureExpressionInfoUtils.js";const G=new r(Array,e=>u(e,d),null,10,5),j=b();class x{get labelLayers(){return this._labelLayers||e}get extent(){return this._extent}get isElevationSource(){return this.layers.some(e=>e?.isElevationSource)}constructor(e,t,i,r,s){this.graphic=e,this.graphics3DSymbol=t,this.layers=i,this._visibleFlags=255,++t.referenced,this._featureExpressionFeature=s?L(s,e,r):null}initialize(e){this._layer=e,this._forEachSymbolLayerGraphic(t=>{t.initialize(e),t.setVisibility(this.isVisible())})}destroy(){this._forEachSymbolLayerGraphic(e=>e.destroy()),this._calloutLayer=null,--this.graphics3DSymbol.referenced,this.graphics3DSymbol=null}get destroyed(){return null==this.layers}clearLabelGraphics(){this._forEachLabelGraphic(e=>e.destroy()),this._labelLayers=null}addLabelGraphic(e,t){this._labelLayers||(this._labelLayers=new Array),this._labelLayers.push(e),e.initialize(t),e.setVisibility(this.isVisible(16))}setCalloutGraphic(e){this._calloutLayer=e,this._layer&&(e.initialize(this._layer),e.setVisibility(this.isVisible()))}get calloutLayer(){return this._calloutLayer}get isDraped(){let e=!1;return this._forEachSymbolLayerGraphic(t=>{"draped"===t.type&&(e=!0)}),e}isVisible(e=1,t){const i=t?this._visibleFlags|t|16*t:this._visibleFlags;return 1===e?!(15&~i):!(255&~i)}setVisibilityFlag(e,t,i){const r=this.isVisible(e);i?this._visibleFlags|=e*t:this._visibleFlags&=~(e*t);const s=this.isVisible(e);if(r===s)return!1;if(16===e)this._forEachLabelGraphic(e=>e.setVisibility(s));else{this._forEachSymbolLayerGraphic(e=>e.setVisibility(s));const e=this.isVisible(16);this._forEachLabelGraphic(t=>t.setVisibility(e))}return!0}getVisibilityFlag(e,t){return 0!==(this._visibleFlags&e*t)}computeExtent(e){if(!this._extent){const t=this.graphic.geometry;if(null==t)return!1;this._extent=b(),_(t,this._extent);const i=t.spatialReference;if(!f(i,e)&&!h(this._extent,i,this._extent,e))return this._extent=null,!1}return!0}getAsOptimizedGeometry(e,t){return this._optimizedGeometry||(this._optimizedGeometry=this._convertGraphicToOptimizedGeometry(this.graphic,e,t)),this._optimizedGeometry}_convertGraphicToOptimizedGeometry(e,t,i){let r=e.geometry;return"mesh"!==r.type&&"extent"!==r.type||(r=n.fromExtent("mesh"===r.type?r.extent:r)),E(r,t,i)}get usedMemory(){let e=i(this.graphic.attributes);return this._forEachSymbolLayerGraphic(t=>e+=t.usedMemory),e}computeAttachmentOrigin(){const e={render:{origin:l(),num:0},draped:{origin:a(),num:0}};for(const t of this.layers)null!=t&&t.computeAttachmentOrigin(e);return e.render.num>1&&o(e.render.origin,e.render.origin,1/e.render.num),e.draped.num>1&&s(e.draped.origin,e.draped.origin,1/e.draped.num),e}async getProjectedBoundingBox(e,i,r,s,a){return a||(a={boundingBox:null,requiresDrapedElevation:!1,screenSpaceObjects:[]}),a.boundingBox?c(a.boundingBox):a.boundingBox=c(),a.requiresDrapedElevation=!1,await t(this.layers,async t=>{if(null==t)return;const o="draped"===t.type?i:e,l=G.acquire(),n=await t.getProjectedBoundingBox(o,r,a.screenSpaceObjects,s,l);isFinite(n[2])&&isFinite(n[5])||(a.requiresDrapedElevation=!0),n&&p(a.boundingBox,l),G.release(l)}),y(a.boundingBox)||g(m(a.boundingBox,j))?a:null}needsElevationUpdates(){for(const e of this.layers)if(null!=e&&("object3d"===e.type||"lod-instance"===e.type)&&e.needsElevationUpdates)return!0;return this._labelLayers?.some(e=>e?.needsElevationUpdates??!1)??!1}alignWithElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"!==r.type&&"lod-instance"!==r.type||r.alignWithElevation(e,t,this._featureExpressionFeature,i)})}alignWithAbsoluteElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"===r.type&&r.alignWithAbsoluteElevation(e,t,i)})}addObjectStateSet(e){this._forEachSymbolLayerGraphic(t=>t.addObjectState(e))}removeObjectState(e){this._forEachSymbolLayerGraphic(t=>t.removeObjectState(e))}updateHighlights(e){this._forEachSymbolLayerGraphic(t=>t.updateHighlights(e))}_forEachGraphicList(e,t){e?.forEach(e=>e&&t(e))}_forEachSymbolLayerGraphic(e){this._forEachGraphicList(this.layers,e),this._calloutLayer&&e(this._calloutLayer)}_forEachLabelGraphic(e){this._forEachGraphicList(this.labelLayers,e)}_forEachRenderedGraphic(e){this._forEachSymbolLayerGraphic(e),this._forEachLabelGraphic(e)}get test(){}}export{x as Graphics3DGraphic};
5
+ import{emptyArray as e}from"../../../../core/arrayUtils.js";import{forEach as t}from"../../../../core/asyncUtils.js";import"../../../../core/has.js";import{estimateAttributesMemory as i}from"../../../../core/memoryEstimations.js";import r from"../../../../core/ObjectPool.js";import{scale as s}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{g as o}from"../../../../chunks/vec32.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import n from"../../../../geometry/Polygon.js";import{projectBoundingRect as h}from"../../../../geometry/projection/projectBoundingRect.js";import{empty as c,expandWithAABB as p,allFinite as y,toRect as m,create as u,set as d,zero as b}from"../../../../geometry/support/aaBoundingBox.js";import{create as g,allFinite as f}from"../../../../geometry/support/aaBoundingRect.js";import{equals as _}from"../../../../geometry/support/spatialReferenceUtils.js";import{computeAABR as E}from"../../../../layers/graphics/dehydratedFeatures.js";import{convertFromGeometry as L}from"../../../../layers/graphics/featureConversionUtils.js";import{createFeature as G}from"./featureExpressionInfoUtils.js";const j=new r(()=>u(),e=>d(e,b),null,10,5),x=g();class v{get labelLayers(){return this._labelLayers||e}get extent(){return this._extent}get isElevationSource(){return this.layers.some(e=>e?.isElevationSource)}constructor(e,t,i,r,s){this.graphic=e,this.graphics3DSymbol=t,this.layers=i,this._visibleFlags=255,++t.referenced,this._featureExpressionFeature=s?G(s,e,r):null}initialize(e){this._layer=e,this._forEachSymbolLayerGraphic(t=>{t.initialize(e),t.setVisibility(this.isVisible())})}destroy(){this._forEachSymbolLayerGraphic(e=>e.destroy()),this._calloutLayer=null,--this.graphics3DSymbol.referenced,this.graphics3DSymbol=null}get destroyed(){return null==this.layers}clearLabelGraphics(){this._forEachLabelGraphic(e=>e.destroy()),this._labelLayers=null}addLabelGraphic(e,t){this._labelLayers||(this._labelLayers=new Array),this._labelLayers.push(e),e.initialize(t),e.setVisibility(this.isVisible(16))}setCalloutGraphic(e){this._calloutLayer=e,this._layer&&(e.initialize(this._layer),e.setVisibility(this.isVisible()))}get calloutLayer(){return this._calloutLayer}get isDraped(){let e=!1;return this._forEachSymbolLayerGraphic(t=>{"draped"===t.type&&(e=!0)}),e}isVisible(e=1,t){const i=t?this._visibleFlags|t|16*t:this._visibleFlags;return 1===e?!(15&~i):!(255&~i)}setVisibilityFlag(e,t,i){const r=this.isVisible(e);i?this._visibleFlags|=e*t:this._visibleFlags&=~(e*t);const s=this.isVisible(e);if(r===s)return!1;if(16===e)this._forEachLabelGraphic(e=>e.setVisibility(s));else{this._forEachSymbolLayerGraphic(e=>e.setVisibility(s));const e=this.isVisible(16);this._forEachLabelGraphic(t=>t.setVisibility(e))}return!0}getVisibilityFlag(e,t){return 0!==(this._visibleFlags&e*t)}computeExtent(e){if(!this._extent){const t=this.graphic.geometry;if(null==t)return!1;this._extent=g(),E(t,this._extent);const i=t.spatialReference;if(!_(i,e)&&!h(this._extent,i,this._extent,e))return this._extent=null,!1}return!0}getAsOptimizedGeometry(e,t){return this._optimizedGeometry||(this._optimizedGeometry=this._convertGraphicToOptimizedGeometry(this.graphic,e,t)),this._optimizedGeometry}_convertGraphicToOptimizedGeometry(e,t,i){let r=e.geometry;return"mesh"!==r.type&&"extent"!==r.type||(r=n.fromExtent("mesh"===r.type?r.extent:r)),L(r,t,i)}get usedMemory(){let e=i(this.graphic.attributes);return this._forEachSymbolLayerGraphic(t=>e+=t.usedMemory),e}computeAttachmentOrigin(){const e={render:{origin:l(),num:0},draped:{origin:a(),num:0}};for(const t of this.layers)null!=t&&t.computeAttachmentOrigin(e);return e.render.num>1&&o(e.render.origin,e.render.origin,1/e.render.num),e.draped.num>1&&s(e.draped.origin,e.draped.origin,1/e.draped.num),e}async getProjectedBoundingBox(e,i,r,s,a){return a||(a={boundingBox:null,requiresDrapedElevation:!1,screenSpaceObjects:[]}),a.boundingBox?c(a.boundingBox):a.boundingBox=c(),a.requiresDrapedElevation=!1,await t(this.layers,async t=>{if(null==t)return;const o="draped"===t.type?i:e,l=j.acquire(),n=await t.getProjectedBoundingBox(o,r,a.screenSpaceObjects,s,l);isFinite(n[2])&&isFinite(n[5])||(a.requiresDrapedElevation=!0),n&&p(a.boundingBox,l),j.release(l)}),y(a.boundingBox)||f(m(a.boundingBox,x))?a:null}needsElevationUpdates(){for(const e of this.layers)if(null!=e&&("object3d"===e.type||"lod-instance"===e.type)&&e.needsElevationUpdates)return!0;return this._labelLayers?.some(e=>e?.needsElevationUpdates??!1)??!1}alignWithElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"!==r.type&&"lod-instance"!==r.type||r.alignWithElevation(e,t,this._featureExpressionFeature,i)})}alignWithAbsoluteElevation(e,t,i){this._forEachRenderedGraphic(r=>{"object3d"===r.type&&r.alignWithAbsoluteElevation(e,t,i)})}addObjectStateSet(e){this._forEachSymbolLayerGraphic(t=>t.addObjectState(e))}removeObjectState(e){this._forEachSymbolLayerGraphic(t=>t.removeObjectState(e))}updateHighlights(e){this._forEachSymbolLayerGraphic(t=>t.updateHighlights(e))}_forEachGraphicList(e,t){e?.forEach(e=>e&&t(e))}_forEachSymbolLayerGraphic(e){this._forEachGraphicList(this.layers,e),this._calloutLayer&&e(this._calloutLayer)}_forEachLabelGraphic(e){this._forEachGraphicList(this.labelLayers,e)}_forEachRenderedGraphic(e){this._forEachSymbolLayerGraphic(e),this._forEachLabelGraphic(e)}get test(){}}export{v as Graphics3DGraphic};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromBuffer as o,create as s,intersectsClippingArea as n,empty as a,expandWithAABB as l}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as c,doubleSubArray as p}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as h,floatSubArray as u}from"../../../../geometry/support/FloatArray.js";import{elevationModeChangeUpdateType as d,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as _}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as g}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as y}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as f}from"./graphicUtils.js";import{parseCapType as v}from"./lineUtils.js";import{geometryAsPolygon as x,createIndices3D as C,createColorGeometry as b,PolygonCreationDataBase as D}from"./polygonUtils.js";import{initFastSymbolUpdatesState as O,updateFastSymbolUpdatesState as S,getAttributeValue as P,ConvertOptions as U}from"../support/FastSymbolUpdates.js";import{createMaterial as j,uvElevationAligner as G}from"../support/patternUtils.js";import{createMapSpaceUVCoords as w,createMapSpaceUVCoordsDraped as A}from"../support/uvUtils.js";import{createGeometry as E}from"../../support/engineContent/line.js";import{geometryToRenderInfo as M,geometryToRenderInfoDraped as V}from"../../support/renderInfoUtils/polygon.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as R}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as I}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as F}from"../../webgl-engine/materials/RibbonLineMaterial.js";const T=["polyline","polygon","extent"];class z extends y{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,J(t)),this._needsUV=!1,this._materials=[]}async doLoad(){this._fastUpdates=O(this._context.renderer,this._vvConvertOptions)}get _materialColor(){return this.symbolLayer.material?.color}_createMaterials(){if(this._materials.length>0)return;const e=this._materialColor,r=this._getCombinedOpacityAndColor(e);this._materials[0]=j(this.symbolLayer,{color:r,forceTransparentMode:this.needsDrivenTransparentPass,discardInvisibleFragments:!0,polygonOffset:!1,hasVertexColors:!0,draped:this.draped,hasSlicePlane:this._context.slicePlaneEnabled,...this._fastUpdates?.materialParameters}),this._needsUV=this._materials[0]instanceof I;const i=this.symbolLayer.outline;if(q(i)){const e=B(i.pattern);this._materials[1]=new F({width:t(i.size),color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:e,cap:v(i.patternCap||"butt")})}}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,T,this.symbolLayer.type))return null;const r=this._getDrivenUInt8Color(e.renderingInfo,this._materialColor,!1),i=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===i.mode),this._createMaterials(),this.draped?this._createAsOverlay(t,r):this._createAs3DShape(t,r,i)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!S(this._fastUpdates,t,this._vvConvertOptions))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}layerOpacityChanged(){if(null!=this._materials[0]){const e=this._materials[0].parameters.color,t=this._materialColor,r=this._getCombinedOpacity(t);this._materials[0].setParameters({color:[e[0],e[1],e[2],r],forceTransparentMode:this.needsDrivenTransparentPass})}if(null!=this._materials[1]){const e=this._materials[1].parameters.color;this._materials[1].setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,o=d(z.elevationModeChangeTypes,r,i);if(1!==o)return o;const s=m(i);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>s)}slicePlaneEnabledChanged(){if(this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._materials[1].setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r){const i=x(e.geometry);if(!i)return null;const o=M(i,this._context.elevationProvider,this._context.renderCoordsHelper,r),s=new k(o,t,this._context.layerViewUid,e.uid),n=s.renderData.position.length/3;if(this._needsUV&&(s.uvMapSpace=h(4*n,!0),s.boundingRect=c(9*n,!0),w(s.uvMapSpace,s.boundingRect,s.renderData.position,this._context.renderCoordsHelper)),s.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(s),this._createAs3DShapeFill(e,s),this._materials[1]&&this._createAs3DShapeOutline(s),this._logGeometryCreationWarnings(s.renderData,i.rings,"rings","FillSymbol3DLayer"),0===s.outGeometries.length)return null;const a=new L({geometries:s.outGeometries,castShadow:!1,layerViewUid:this._context.layerViewUid,graphicUid:e.uid}),l=new g(this,a,null,G,r);return l.alignedSampledElevation=s.renderData.sampledElevation,l.needsElevationUpdates=m(r.mode),l}_createAs3DShapeFill(e,t){const r=t.renderData.polygons;for(const{position:i,mapPositions:s,holeIndices:a,index:l,count:c}of r){if(null!=this._context.clippingExtent&&(o(s,H),!n(H,this._context.clippingExtent)))continue;const r=C(s,a,this._context.elevationProvider.spatialReference);if(0===r.length)continue;const h=this._fastUpdates?.visualVariables.color,d=b({material:this._materials[0],indices:r,mapPositions:s,attributeData:{position:i,color:h?null:t.color,colorFeature:h?P(h.field,e):null,uvMapSpace:this._needsUV?u(t.uvMapSpace,4*l,4*c):null,boundingRect:this._needsUV?p(t.boundingRect,9*l,9*c):null,olidColor:t.olidColor}});t.outGeometries.push(d)}}_createAs3DShapeOutline(e){if(null==this._materials[1])return;const t=e.renderData.outlines;for(const{mapPositions:r,position:i}of t){if(null!=this._context.clippingExtent&&(o(r,H),!n(H,this._context.clippingExtent)))continue;const t=E(this._materials[1],{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:r,attributeData:{position:i}},e.olidColor);e.outGeometries.push(t)}}_createAsOverlay(e,t){const r=x(e.geometry);if(null==r)return null;this._materials[0].renderPriority=this._renderPriority+this._renderPriorityStep/2,null!=this._materials[1]&&(this._materials[1].renderPriority=this._renderPriority);const i=V(r,this._context.overlaySR),o=new W(i,t,this._context.layerViewUid,e.uid),s=o.renderData.position.length/3;return this._needsUV&&(o.uvMapSpace=h(4*s,!0),A(o.uvMapSpace,o.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),o.outBoundingBox=a(),o.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(o),this._createAsOverlayFill(e,o),this._materials[1]&&this._createAsOverlayOutline(o),this._logGeometryCreationWarnings(o.renderData,r.rings,"rings","FillSymbol3DLayer"),0===o.outGeometries.length?null:new _(this,o.outGeometries,o.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){const i=t.renderData.polygons;for(const{position:s,holeIndices:a,index:c,count:p}of i){const i=o(s,H);if(!n(i,this._context.clippingExtent))continue;const h=r(s,a,3);if(0===h.length)continue;l(t.outBoundingBox,i);const d=this._fastUpdates?.visualVariables.color,m=b({material:this._materials[0],indices:h,attributeData:{position:s,color:d?null:t.color,colorFeature:d?P(d.field,e):null,uvMapSpace:this._needsUV?u(t.uvMapSpace,4*c,4*p):null,olidColor:t.olidColor}});t.outGeometries.push(new R(m,t))}}_createAsOverlayOutline(e){if(null==this._materials[1])return;const t=e.renderData.outlines;for(let r=0;r<t.length;++r){const{position:i}=t[r];if(o(i,H),!n(H,this._context.clippingExtent))continue;l(e.outBoundingBox,H);const s=E(this._materials[1],{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:i}},e.olidColor);e.outGeometries.push(new R(s,e))}}_getOutlineOpacity(){const e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(null!=e?e.a:0)}_getOutlineColor(){const t=this.symbolLayer?.outline?.color,r=this._getOutlineOpacity();return f(null!=t?e.toUnitRGB(t):null,r)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,r)=>this._createAs3DShape(e,t,r)}}get _vvConvertOptions(){return new U({supports:{size:!1,color:!0,rotation:!1,opacity:!1},fallbackColor:e.toUnitRGBA(this._materialColor)??i})}}const H=s();class k extends D{constructor(e,t,r,i){super(e,r,i),this.color=t}}class W extends D{constructor(e,t,r,i){super(e,r,i),this.color=t}}function q(e){return null!=e?.size&&e.size>0&&null!=e.color&&(null==e.pattern||"style"!==e.pattern.type||"none"!==e.pattern.style)}function J(e){return 1===(e.material?.color?.a??0)}export{z as Graphics3DPolygonFillSymbolLayer};
5
+ import e from"../../../../Color.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{ZEROS as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{fromBuffer as o,create as s,intersectsClippingArea as n,empty as a,expandWithAABB as l}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as c,doubleSubArray as p}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as h,floatSubArray as u}from"../../../../geometry/support/FloatArray.js";import{elevationModeChangeUpdateType as d,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import{Graphics3DDrapedGraphicLayer as _}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as g}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as y}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as f}from"./graphicUtils.js";import{parseCapType as v}from"./lineUtils.js";import{geometryAsPolygon as x,createIndices3D as C,createColorGeometry as b,PolygonCreationDataBase as D}from"./polygonUtils.js";import{initFastSymbolUpdatesState as O,updateFastSymbolUpdatesState as S,getAttributeValue as P,ConvertOptions as U}from"../support/FastSymbolUpdates.js";import{createMaterial as j,uvElevationAligner as G}from"../support/patternUtils.js";import{createMapSpaceUVCoords as w,createMapSpaceUVCoordsDraped as A}from"../support/uvUtils.js";import{createGeometry as E}from"../../support/engineContent/line.js";import{geometryToRenderInfo as M,geometryToRenderInfoDraped as V}from"../../support/renderInfoUtils/polygon.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as R}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as I}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as F}from"../../webgl-engine/materials/RibbonLineMaterial.js";const T=["polyline","polygon","extent"];class z extends y{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,J(t)),this._needsUV=!1,this._materials=[]}async doLoad(){this._fastUpdates=O(this._context.renderer,this._vvConvertOptions)}get _materialColor(){return this.symbolLayer.material?.color}_createMaterials(){if(this._materials.length>0)return;const e=this._materialColor,r=this._getCombinedOpacityAndColor(e);this._materials[0]=j(this.symbolLayer,{color:r,forceTransparentMode:this.needsDrivenTransparentPass,discardInvisibleFragments:!0,polygonOffset:!1,hasVertexColors:!0,draped:this.draped,hasSlicePlane:this._context.slicePlaneEnabled,...this._fastUpdates?.materialParameters}),this._needsUV=this._materials[0]instanceof I;const i=this.symbolLayer.outline;if(q(i)){const e=B(i.pattern);this._materials[1]=new F({width:t(i.size),color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:e,cap:v(i.patternCap||"butt")})}}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,T,this.symbolLayer.type))return null;const r=this._getDrivenUInt8Color(e.renderingInfo,this._materialColor,!1),i=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===i.mode),this._createMaterials(),this.draped?this._createAsOverlay(t,r):this._createAs3DShape(t,r,i)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!S(this._fastUpdates,t,this._vvConvertOptions))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}layerOpacityChanged(){if(null!=this._materials[0]){const e=this._materials[0].parameters.color,t=this._materialColor,r=this._getCombinedOpacity(t);this._materials[0].setParameters({color:[e[0],e[1],e[2],r],forceTransparentMode:this.needsDrivenTransparentPass})}if(null!=this._materials[1]){const e=this._materials[1].parameters.color;this._materials[1].setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,o=d(z.elevationModeChangeTypes,r,i);if(1!==o)return o;const s=m(i);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>s)}slicePlaneEnabledChanged(){if(this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._materials[1].setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r){const i=x(e.geometry);if(!i)return null;const o=M(i,this._context.elevationProvider,this._context.renderCoordsHelper,r),s=new k(o,t,this._context.layerViewUid,e.uid),n=s.renderData.position.length/3;if(this._needsUV&&(s.uvMapSpace=h(4*n,!0),s.boundingRect=c(9*n),w(s.uvMapSpace,s.boundingRect,s.renderData.position,this._context.renderCoordsHelper)),s.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(s),this._createAs3DShapeFill(e,s),this._materials[1]&&this._createAs3DShapeOutline(s),this._logGeometryCreationWarnings(s.renderData,i.rings,"rings","FillSymbol3DLayer"),0===s.outGeometries.length)return null;const a=new L({geometries:s.outGeometries,castShadow:!1,layerViewUid:this._context.layerViewUid,graphicUid:e.uid}),l=new g(this,a,null,G,r);return l.alignedSampledElevation=s.renderData.sampledElevation,l.needsElevationUpdates=m(r.mode),l}_createAs3DShapeFill(e,t){const r=t.renderData.polygons;for(const{position:i,mapPositions:s,holeIndices:a,index:l,count:c}of r){if(null!=this._context.clippingExtent&&(o(s,H),!n(H,this._context.clippingExtent)))continue;const r=C(s,a,this._context.elevationProvider.spatialReference);if(0===r.length)continue;const h=this._fastUpdates?.visualVariables.color,d=b({material:this._materials[0],indices:r,mapPositions:s,attributeData:{position:i,color:h?null:t.color,colorFeature:h?P(h.field,e):null,uvMapSpace:this._needsUV?u(t.uvMapSpace,4*l,4*c):null,boundingRect:this._needsUV?p(t.boundingRect,9*l,9*c):null,olidColor:t.olidColor}});t.outGeometries.push(d)}}_createAs3DShapeOutline(e){if(null==this._materials[1])return;const t=e.renderData.outlines;for(const{mapPositions:r,position:i}of t){if(null!=this._context.clippingExtent&&(o(r,H),!n(H,this._context.clippingExtent)))continue;const t=E(this._materials[1],{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:r,attributeData:{position:i}},e.olidColor);e.outGeometries.push(t)}}_createAsOverlay(e,t){const r=x(e.geometry);if(null==r)return null;this._materials[0].renderPriority=this._renderPriority+this._renderPriorityStep/2,null!=this._materials[1]&&(this._materials[1].renderPriority=this._renderPriority);const i=V(r,this._context.overlaySR),o=new W(i,t,this._context.layerViewUid,e.uid),s=o.renderData.position.length/3;return this._needsUV&&(o.uvMapSpace=h(4*s,!0),A(o.uvMapSpace,o.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),o.outBoundingBox=a(),o.olidColor=this._context.stage.renderView?.getObjectAndLayerIdColor(o),this._createAsOverlayFill(e,o),this._materials[1]&&this._createAsOverlayOutline(o),this._logGeometryCreationWarnings(o.renderData,r.rings,"rings","FillSymbol3DLayer"),0===o.outGeometries.length?null:new _(this,o.outGeometries,o.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){const i=t.renderData.polygons;for(const{position:s,holeIndices:a,index:c,count:p}of i){const i=o(s,H);if(!n(i,this._context.clippingExtent))continue;const h=r(s,a,3);if(0===h.length)continue;l(t.outBoundingBox,i);const d=this._fastUpdates?.visualVariables.color,m=b({material:this._materials[0],indices:h,attributeData:{position:s,color:d?null:t.color,colorFeature:d?P(d.field,e):null,uvMapSpace:this._needsUV?u(t.uvMapSpace,4*c,4*p):null,olidColor:t.olidColor}});t.outGeometries.push(new R(m,t))}}_createAsOverlayOutline(e){if(null==this._materials[1])return;const t=e.renderData.outlines;for(let r=0;r<t.length;++r){const{position:i}=t[r];if(o(i,H),!n(H,this._context.clippingExtent))continue;l(e.outBoundingBox,H);const s=E(this._materials[1],{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:i}},e.olidColor);e.outGeometries.push(new R(s,e))}}_getOutlineOpacity(){const e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(null!=e?e.a:0)}_getOutlineColor(){const t=this.symbolLayer?.outline?.color,r=this._getOutlineOpacity();return f(null!=t?e.toUnitRGB(t):null,r)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,r)=>this._createAs3DShape(e,t,r)}}get _vvConvertOptions(){return new U({supports:{size:!1,color:!0,rotation:!1,opacity:!1},fallbackColor:e.toUnitRGBA(this._materialColor)??i})}}const H=s();class k extends D{constructor(e,t,r,i){super(e,r,i),this.color=t}}class W extends D{constructor(e,t,r,i){super(e,r,i),this.color=t}}function q(e){return null!=e?.size&&e.size>0&&null!=e.color&&(null==e.pattern||"style"!==e.pattern.type||"none"!==e.pattern.style)}function J(e){return 1===(e.material?.color?.a??0)}export{z as Graphics3DPolygonFillSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{colorGamma as e}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as r}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as o,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as u,d as c,D as m,l as f,n as d,m as p}from"../../../../chunks/vec32.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as x,expandWithVec3 as T}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec3f as h,BufferViewVec4f as y,BufferViewVec4u8 as w,BufferViewVec4u16 as v,BufferViewVec3u8 as R,BufferViewVec3u16 as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as j,b as S,n as M,f as F}from"../../../../chunks/vec3.js";import{t as A,b as E}from"../../../../chunks/vec4.js";import{a as C}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as I}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as L}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as P}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as U}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as O}from"./ProcessedObjectResource.js";import{load as k,processLoadResult as D}from"./wosrLoader.js";import{Attribute as V}from"../../webgl-engine/lib/Attribute.js";import{Geometry as _}from"../../webgl-engine/lib/Geometry.js";import{Texture as G}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as W}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as H,schematicMRRFactors as N,esriSymbologyMRRFactors as Q,advancedMRRFactors as $}from"../../webgl-engine/materials/pbrUtils.js";async function q(e,t){const o=z(r(e));if("wosr"===o.fileType){const e=await(t.cache?t.cache.loadWOSR(o.url,t):k(o.url,t)),{engineResources:r,referenceBoundingBox:s}=D(e,t);return{lods:r,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(t.cache)s=await t.cache.loadGLTF(o.url,t,!!t.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new I(t.streamDataRequester),o.url,t,t.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ee(s,i));const l=!!t.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:Q}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:$},u={...t.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=K(s,a,u,t,o.specifiedLodIndex,n);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function z(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function K(e,r,t,o,s,i){const n=e.model,l=new Array,a=new Map,u=new Map,c=n.lods.length,m=x();return n.lods.forEach((e,f)=>{const d=!0===o.skipHighLods&&(c>1&&0===f||c>3&&1===f)||!1===o.skipHighLods&&null!=s&&f!==s;if(d&&0!==f)return;const p=new O(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach(e=>{const s=d?new W({},o):J(n,e,p,r,t,a,u,o,i),{geometry:l,vertexCount:c}=X(e,s??new W({},o)),g=l.boundingInfo;null!=g&&0===f&&(T(m,g.bbMin),T(m,g.bbMax)),null!=s&&(p.stageResources.geometries.push(l),p.numberOfVertices+=c)}),d||l.push(p)}),{engineResources:l,referenceBoundingBox:m}}function J(r,t,o,s,i,n,l,u,c){const m=r.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),T=null!=t.attributes.texCoord0,b=null!=t.attributes.normal,h=Z(m.alphaMode);if(!n.has(x)){if(T){const e=(e,t=!1,o=!1)=>{if(null!=e&&!l.has(e)){const s=r.textures.get(e);if(s){const r=s.data,i=t&&!P(r)?u.compressionOptions:void 0;l.set(e,new G(P(r)?r.data:r,{...s.parameters,preMultiplyAlpha:!P(r)&&o,encoding:P(r)?r.encoding:void 0,compressionOptions:i}))}}},t=1!==h&&!c;e(m.colorTexture,t,1!==h),e(m.normalTexture),e(m.occlusionTexture,!0),e(m.emissiveTexture),e(m.metallicRoughnessTexture,!0)}const o=1/e,f=m.color[0]**o,d=m.color[1]**o,p=m.color[2]**o,g=m.emissiveFactor[0]**o,y=m.emissiveFactor[1]**o,w=m.emissiveFactor[2]**o,v=null!=m.colorTexture&&T?l.get(m.colorTexture):null,R=H(m),B=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:a;n.set(x,new W({...s,customDepthTest:1,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[f,d,p],ambient:[f,d,p],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?0:2,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:b?0:2,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclusion,textureId:null!=v?v.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&T?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=v&&!!v.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&T?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&T?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&T?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[g,y,w],mrrFactors:R?N:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:R,colorTextureTransformMatrix:U(m.colorTextureTransform),normalTextureTransformMatrix:U(m.normalTextureTransform),scale:[B[0],B[1]],occlusionTextureTransformMatrix:U(m.occlusionTextureTransform),emissiveTextureTransformMatrix:U(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:U(m.metallicRoughnessTextureTransform),...i},u))}const y=n.get(x);if(o.stageResources.materials.push(y),T){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function X(e,r){const i=e.attributes.position.count,n=L(e.indices||i,e.primitiveType),l=b(3*i),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;j(l,a,e.transform,3,u);const c=[["position",new V(l,n,3,!0)]];if(null!=e.attributes.normal){const r=b(3*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.normal;o(Y,e.transform),S(r,s,Y,3,l),t(Y)&&M(r,r),c.push(["normal",new V(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=b(4*i),{typedBuffer:o,typedBufferStride:l}=e.attributes.tangent;s(Y,e.transform),A(r,o,Y,4,l),t(Y)&&M(r,r,4),c.push(["tangent",new V(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=b(2*i),{typedBuffer:t,typedBufferStride:o}=e.attributes.texCoord0;C(r,t,2,o),c.push(["uv0",new V(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*i);4===m.elementCount?m instanceof y?E(r,m,1,255):(m instanceof w||m instanceof v)&&E(r,m,1/255,255):(r.fill(255),m instanceof h?F(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof R||e.attributes.color instanceof B)&&F(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push(["color",new V(r,n,4,!0)])}return{geometry:new _(r,c),vertexCount:i}}const Y=i();function Z(e){switch(e){case"BLEND":return 0;case"MASK":return 2;case"OPAQUE":case null:case void 0:return 1}}function ee(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const a=i.attributes.position,x=a.count,T=g(),b=g(),w=g(),v=new Float32Array(4*x),R=new Float32Array(3*x),B=n(l(),i.transform);let j=0,S=0;for(let n=0;n<x;n++){a.getVec(n,b),s.getVec(n,T),u(b,b,i.transform),c(w,b,t.center),m(w,w,t.radius);const l=w[2],g=f(w),x=Math.min(.45+.55*g*g,1)**e;m(w,w,t.radius),null!==B&&u(w,w,B),d(w,w),o+1!==r.model.lods.length&&r.model.lods.length>1&&p(w,w,T,l>-1?.2:Math.min(-4*l-3.8,1)),R[j]=w[0],R[j+1]=w[1],R[j+2]=w[2],j+=3,v[S]=x,v[S+1]=x,v[S+2]=x,v[S+3]=1,S+=4}i.attributes.normal=new h(R),i.attributes.color=new y(v)}}}export{q as fetch,z as parseUrl};
5
+ import{colorGamma as e}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as r}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as o,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as u,d as c,D as m,l as f,n as d,m as p}from"../../../../chunks/vec32.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as x,expandWithVec3 as T}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec3f as h,BufferViewVec4f as y,BufferViewVec4u8 as w,BufferViewVec4u16 as v,BufferViewVec3u8 as R,BufferViewVec3u16 as B}from"../../../../geometry/support/buffer/BufferView.js";import{t as j,b as S,n as M,f as F}from"../../../../chunks/vec3.js";import{t as A,b as E}from"../../../../chunks/vec4.js";import{a as C}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as I}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as L}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as P}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as U}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as O}from"./ProcessedObjectResource.js";import{load as k,processLoadResult as D}from"./wosrLoader.js";import{Attribute as V}from"../../webgl-engine/lib/Attribute.js";import{Geometry as _}from"../../webgl-engine/lib/Geometry.js";import{Texture as G}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as W}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as H,schematicMRRFactors as N,esriSymbologyMRRFactors as Q,advancedMRRFactors as $}from"../../webgl-engine/materials/pbrUtils.js";async function q(e,t){const o=z(r(e));if("wosr"===o.fileType){const e=await(t.cache?t.cache.loadWOSR(o.url,t):k(o.url,t)),{engineResources:r,referenceBoundingBox:s}=D(e,t);return{lods:r,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(t.cache)s=await t.cache.loadGLTF(o.url,t,!!t.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new I(t.streamDataRequester),o.url,t,t.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ee(s,i));const l=!!t.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:Q}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:$},u={...t.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=K(s,a,u,t,o.specifiedLodIndex,n);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function z(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function K(e,r,t,o,s,i){const n=e.model,l=new Array,a=new Map,u=new Map,c=n.lods.length,m=x();return n.lods.forEach((e,f)=>{const d=!0===o.skipHighLods&&(c>1&&0===f||c>3&&1===f)||!1===o.skipHighLods&&null!=s&&f!==s;if(d&&0!==f)return;const p=new O(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach(e=>{const s=d?new W({},o):J(n,e,p,r,t,a,u,o,i),{geometry:l,vertexCount:c}=X(e,s??new W({},o)),g=l.boundingInfo;null!=g&&0===f&&(T(m,g.bbMin),T(m,g.bbMax)),null!=s&&(p.stageResources.geometries.push(l),p.numberOfVertices+=c)}),d||l.push(p)}),{engineResources:l,referenceBoundingBox:m}}function J(r,t,o,s,i,n,l,u,c){const m=r.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),T=null!=t.attributes.texCoord0,b=null!=t.attributes.normal,h=Z(m.alphaMode);if(!n.has(x)){if(T){const e=(e,t=!1,o=!1)=>{if(null!=e&&!l.has(e)){const s=r.textures.get(e);if(s){const r=s.data,i=t&&!P(r)?u.compressionOptions:void 0;l.set(e,new G(P(r)?r.data:r,{...s.parameters,preMultiplyAlpha:!P(r)&&o,encoding:P(r)?r.encoding:void 0,compressionOptions:i}))}}},t=1!==h&&!c;e(m.colorTexture,t,1!==h),e(m.normalTexture),e(m.occlusionTexture,!0),e(m.emissiveTexture),e(m.metallicRoughnessTexture,!0)}const o=1/e,f=m.color[0]**o,d=m.color[1]**o,p=m.color[2]**o,g=m.emissiveFactor[0]**o,y=m.emissiveFactor[1]**o,w=m.emissiveFactor[2]**o,v=null!=m.colorTexture&&T?l.get(m.colorTexture):null,R=H(m),B=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:a;n.set(x,new W({...s,customDepthTest:1,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[f,d,p],ambient:[f,d,p],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?0:2,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:b?0:2,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclusion,textureId:null!=v?v.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&T?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=v&&!!v.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&T?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&T?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&T?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[g,y,w],mrrFactors:R?N:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:R,colorTextureTransformMatrix:U(m.colorTextureTransform),normalTextureTransformMatrix:U(m.normalTextureTransform),scale:[B[0],B[1]],occlusionTextureTransformMatrix:U(m.occlusionTextureTransform),emissiveTextureTransformMatrix:U(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:U(m.metallicRoughnessTextureTransform),...i},u))}const y=n.get(x);if(o.stageResources.materials.push(y),T){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function X(e,r){const i=e.attributes.position.count,n=L(e.indices||i,e.primitiveType),l=b(3*i),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;j(l,a,e.transform,3,u);const c=[["position",new V(l,n,3,!0)]];if(null!=e.attributes.normal){const r=b(3*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.normal;o(Y,e.transform),S(r,s,Y,3,l),t(Y)&&M(r,r),c.push(["normal",new V(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=b(4*i),{typedBuffer:o,typedBufferStride:l}=e.attributes.tangent;s(Y,e.transform),A(r,o,Y,4,l),t(Y)&&M(r,r,4),c.push(["tangent",new V(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=b(2*i),{typedBuffer:t,typedBufferStride:o}=e.attributes.texCoord0;C(r,t,2,o),c.push(["uv0",new V(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*i);4===m.elementCount?m instanceof y?E(r,m,1,255):(m instanceof w||m instanceof v)&&E(r,m,1/255,255):(r.fill(255),m instanceof h?F(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof R||e.attributes.color instanceof B)&&F(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push(["color",new V(r,n,4,!0)])}return{geometry:new _(r,c),vertexCount:i}}const Y=i();function Z(e){switch(e){case"BLEND":return 0;case"MASK":return 2;case"OPAQUE":case null:case void 0:return 1}}function ee(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const a=i.attributes.position,x=a.count,T=g(),b=g(),w=g(),v=new Float32Array(4*x),R=new Float32Array(3*x),B=n(l(),i.transform);let j=0,S=0;for(let n=0;n<x;n++){a.getVec(n,b),s.getVec(n,T),u(b,b,i.transform),c(w,b,t.center),m(w,w,t.radius);const l=w[2],g=f(w),x=Math.min(.45+.55*g*g,1)**e;m(w,w,t.radius),null!==B&&u(w,w,B),d(w,w),o+1!==r.model.lods.length&&r.model.lods.length>1&&p(w,w,T,l>-1?.2:Math.min(-4*l-3.8,1)),R[j]=w[0],R[j+1]=w[1],R[j+2]=w[2],j+=3,v[S]=x,v[S+1]=x,v[S+2]=x,v[S+3]=1,S+=4}i.attributes.normal=new h(R.buffer),i.attributes.color=new y(v.buffer)}}}export{q as fetch,z as parseUrl};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import o from"../../../../core/Error.js";import{loadImageAsync as t}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as r}from"../../glTF/internal/resourceUtils.js";import{useSchematicPBR as a,schematicMRRFactors as s}from"../../webgl-engine/materials/pbrUtils.js";import{alphaCutoff as n}from"../../../../webscene/support/AlphaCutoff.js";async function l(o){const t=[],r=[];if(null==o){return{material:{alphaMode:"opaque",alphaCutoff:n,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:t,textureData:r}}const l=i(o);"auto"===o.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');const c=a({normalTexture:o.normalTexture,emissiveTexture:l?o.emissiveTexture:null,emissiveFactor:l?e.toUnitRGB(o.emissiveColor):null,occlusionTexture:l?o.occlusionTexture:null,metallicRoughnessTexture:l?o.metallicRoughnessTexture:null,metallicFactor:l?o.metallic:null,roughnessFactor:l?o.roughness:null}),d=c?s[0]:l?o.metallic:0,m=c?s[1]:l?o.roughness:0;return{material:{alphaMode:"auto"===o.alphaMode?"blend":o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:o.doubleSided?0:2,normalTextureId:await u(o.normalTexture,t,r,4),emissiveTextureId:l?await u(o.emissiveTexture,t,r,16):-1,occlusionTextureId:l?await u(o.occlusionTexture,t,r,8):-1,emissiveFactor:l&&null!=o.emissiveColor?e.toUnitRGB(o.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=o.color?e.toUnitRGBA(o.color):[1,1,1,1],baseColorTextureId:await u(o.colorTexture,t,r,1),metallicRoughnessTextureId:l?await u(o.metallicRoughnessTexture,t,r,2):-1,metallicFactor:d,roughnessFactor:m},wrapTextures:!0,hasParametersFromSource:c},requiredTextures:t,textureData:r}}async function u(e,a,s,n){if(null==e)return-1;const l=s.length,u=e.data,i=e.url;if(null!=u){if(u instanceof HTMLImageElement||u instanceof HTMLCanvasElement)return s.push({id:l,usage:n,data:u,encoding:8}),a.push({id:l,usage:n,encodings:[{name:void 0,encoding:8}]}),l;if(u instanceof HTMLVideoElement)return-1;if(u instanceof ImageData)throw new o("scenelayer","ImageData textures not supported yet for client side I3S nodes");if(u instanceof r)return s.push({id:l,usage:n,data:u.data,encoding:1}),a.push({id:l,usage:n,encodings:[{name:void 0,encoding:1}]}),l}else if(null!=i){const e=new Image;e.src=i;const o=await t(e,e.src,!1,void 0);return s.push({id:l,usage:n,data:o,encoding:8}),a.push({id:l,usage:n,encodings:[{name:void 0,encoding:8}]}),l}return-1}function i(e){return e.hasOwnProperty("metallicRoughnessTexture")}export{l as convertMeshMaterialToPBRMaterial};
5
+ import e from"../../../../Color.js";import o from"../../../../core/Error.js";import{loadImageAsync as t}from"../../../../support/requestUtils.js";import{EncodedMeshTexture as r}from"../../glTF/internal/resourceUtils.js";import{useSchematicPBR as a,schematicMRRFactors as s}from"../../webgl-engine/materials/pbrUtils.js";import{alphaCutoff as n}from"../../../../webscene/support/AlphaCutoff.js";async function u(o){const t=[],r=[];if(null==o){return{material:{alphaMode:"opaque",alphaCutoff:n,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[1,1,1,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6000000238418579},wrapTextures:!1,hasParametersFromSource:!0},requiredTextures:t,textureData:r}}const u=i(o);"auto"===o.alphaMode&&console.warn('alphaMode "auto" not supported by I3S PBRMaterial - defaulting to "blend".');const c=a({normalTexture:o.normalTexture,emissiveTexture:u?o.emissiveTexture:null,emissiveFactor:u?e.toUnitRGB(o.emissiveColor):null,occlusionTexture:u?o.occlusionTexture:null,metallicRoughnessTexture:u?o.metallicRoughnessTexture:null,metallicFactor:u?o.metallic:null,roughnessFactor:u?o.roughness:null}),d=c?s[0]:u?o.metallic:0,m=c?s[1]:u?o.roughness:0;return{material:{alphaMode:"auto"===o.alphaMode?"blend":o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:o.doubleSided?0:2,normalTextureId:await l(o.normalTexture,t,r,4),emissiveTextureId:u?await l(o.emissiveTexture,t,r,16):-1,occlusionTextureId:u?await l(o.occlusionTexture,t,r,8):-1,emissiveFactor:u&&null!=o.emissiveColor?e.toUnitRGB(o.emissiveColor):[0,0,0],metallicRoughness:{baseColorFactor:null!=o.color?e.toUnitRGBA(o.color):[1,1,1,1],baseColorTextureId:await l(o.colorTexture,t,r,1),metallicRoughnessTextureId:u?await l(o.metallicRoughnessTexture,t,r,2):-1,metallicFactor:d,roughnessFactor:m},wrapTextures:!0,hasParametersFromSource:c},requiredTextures:t,textureData:r}}async function l(e,a,s,n){if(null==e)return-1;const u=s.length,l=e.data,i=e.url;if(null!=l){if(l instanceof HTMLImageElement||l instanceof HTMLCanvasElement)return s.push({id:u,usage:n,data:l,encoding:8}),a.push({id:u,usage:n,encodings:[{name:void 0,encoding:8}]}),u;if(l instanceof HTMLVideoElement)return-1;if(l instanceof ImageData)throw new o("scenelayer","ImageData textures not supported yet for client side I3S nodes");if(l instanceof r)return s.push({id:u,usage:n,data:l.data.buffer,encoding:1}),a.push({id:u,usage:n,encodings:[{name:void 0,encoding:1}]}),u}else if(null!=i){const e=new Image;e.src=i;const o=await t(e,e.src,!1,void 0);return s.push({id:u,usage:n,data:o,encoding:8}),a.push({id:u,usage:n,encodings:[{name:void 0,encoding:8}]}),u}return-1}function i(e){return e.hasOwnProperty("metallicRoughnessTexture")}export{u as convertMeshMaterialToPBRMaterial};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MinPriority as r}from"../../../../core/MemCache.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{generateUUID as n}from"../../../../core/uuid.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{q as i}from"../../../../chunks/vec32.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{ensurePackedArray as c}from"../../../../geometry/support/DoubleArray.js";import{isRelativeVertexSpace as u}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{r as m}from"../../../../chunks/sphere.js";import{CachedMeshData as h}from"./CachedMeshData.js";import{convertMeshMaterialToPBRMaterial as f}from"./I3SClientMaterialUtil.js";class p{constructor(e,t,r,o){this._uid=e,this._worker=o,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._memCache=r.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const r=`mesh${t}`,o=e.extent,n=o.spatialReference,s=this._indexSR,a=x(o,e.origin);d(a,n,a,s);return{type:"mesh",id:r,version:S(e),oid:t,mbs:a,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(t,r){if(null!=this.getMeshNodeIndex(r.oid))throw new e("scenelayer",`I3SClientNodeLoader: client side mesh for feature oid=${r.oid} already exists`);r.nodeIndex=t,this._id2Meta.set(r.id,r),this._oid2Meta.set(r.oid,r)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}getMeshNodeInfo(e){const t=this._oid2Meta.values();for(const r of t)if("mesh"===r.type&&r.id===e)return r;return null}removeNode(e){const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){const r=this._id2Meta.get(t);if(null==r)throw new e("scenelayer",`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(r.type){case"mesh":return this._loadMeshNodeJSON(r);case"mesh-component":return y(r);default:throw new e("scenelayer",`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){const t=e.id,r=(await this._getMeshData(e)).loadedMesh;if(null==r.components||0===r.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const o=[],n=r.components;for(let s=0;s<n.length;++s){const r=`${t}-component${s}`,n={type:"mesh-component",id:r,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(n.id,n),e.componentNodeIds.push(r),o.push({id:n.id,href:null,mbs:n.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:o}}updateNodeIndex(e,t,r){const o=this._id2Meta.get(e);o&&"mesh"===o.type&&(o.nodeIndex=r)}async loadNodeData(r,n){const s=this._id2Meta.get(r);if(null==s||"mesh-component"!==s.type)throw new e("scenelayer",`Failed to load client node data for node ${r} (unexpected node info)`);const a=s.meshNodeInfo,i=await this._getMeshData(a),l=i.loadedMesh,d=a.oid;if(null==l.components)throw new e("scenelayer",`Failed to load client node data for node ${r} (unexpected null reference)`);const u=l.components[s.componentIndex],{material:m,requiredTextures:h,textureData:p}=await f(u.material);if(null!=p)for(const e of p)null!=e&&s.textureData.set(e.id,e);const y={params:{material:m},type:"ArrayBufferView"},{vertexSpace:x,origin:w,transform:S}=l,b=[w.x,w.y,w.z??0];i.projectionPromise||(t(this._worker,"SceneLayerWorker is needed to project mesh"),i.projectionPromise=this._worker.project({positions:l.vertexAttributes.position,localMatrix:S?.localMatrix,vertexSpace:x.toJSON(),origin:b,inSpatialReference:l.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON()},n));const{projected:_,original:N,projectedOrigin:v}=await i.projectionPromise,D=c(v);l.vertexAttributes.position=N;const{transformed:j,original:R}=await g(u,i,this._worker,n);l.vertexAttributes.normal=R,o(n);const{geometryBuffer:I,geometryDescriptor:A}=M(_,u.faces,j,l.vertexAttributes.uv,l.vertexAttributes.color,d);return{geometryData:{featureDataPosition:D,featureIds:[],geometries:[y]},attributeDataInfo:{attributeData:{},loadedAttributes:[]},geometryBuffer:I,geometryDescriptor:A,requiredTextures:h,textureData:p,normalReferenceFrame:this._vertexSR.isGeographic?"east-north-up":"vertex-reference-frame"}}async loadAttributes(e,t,r){const o=e.numFeatures,n={};for(const{field:{name:s}}of t)n[s]=new Array(o);return n}async loadTextures(e,t,r){const o=e.id,n=this._id2Meta.get(o);if(null==n||"mesh-component"!==n.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(n.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,o=this._memCache.get(t);if(null==o){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const o=async(o,n)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(i){n(i)}const a=new h(s);this._memCache.put(t,a,r),e.loadMeshPromise=null,o(a)};return e.loadMeshPromise=new Promise((e,t)=>o(e,t)),e.loadMeshPromise}return o}}async function y(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}function x(e,t){const{spatialReference:r}=e,o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],s=r.isGeographic?r.metersPerUnit:1,a=e.center;let i=0;if(e.hasZ)for(let l=0;l<2;++l)for(let e=0;e<2;++e)for(let r=0;r<2;++r){const d=(a.x+o[l]*n[0]-t.x)*s,c=(a.y+o[e]*n[1]-t.y)*s,u=a.z+o[r]*n[2]-t.z;i=Math.max(d*d+c*c+u*u,i)}else for(let l=0;l<2;++l)for(let e=0;e<2;++e){const r=(a.x+o[l]*n[0]-t.x)*s,d=(a.y+o[e]*n[1]-t.y)*s;i=Math.max(r*r+d*d,i)}return m([t.x,t.y,t.z],Math.sqrt(i))}async function g(e,r,o,n){const{transform:d,vertexAttributes:c}=r.loadedMesh,u="source"===e.shading?c.normal:null;if(!(null!=u&&null!=d&&(0!==d.rotationAngle||!i(d.scale,l))))return{transformed:u,original:c.normal};if(!r.normalsTransformPromise){t(o,"SceneLayerWorker is needed to transform mesh normals");const e=a();s(e,d.localMatrix),r.normalsTransformPromise=o.transformNormals({normalMatrix:e,normals:u},n)}return r.normalsTransformPromise}function M(e,t,r,o,n,s){const a=1,i=(t?.length??0)/3,l=3*i;let d=0,c=0,u=!1,m=0,h=!1,f=0,p=!1,y=0,x=0,g=0;d+=b,d+=b,c=d,d+=3*l*_,null!=r&&(u=!0,m=d,d+=3*l*_),null!=o&&(h=!0,f=d,d+=2*l*_),null!=n&&(p=!0,y=d,d+=4*l*N),x=d,d+=a*v,g=d,d+=2*a*b;const M=new ArrayBuffer(d),S=new Uint8Array(M);w(S,0,l),w(S,b,a);const D=new Float32Array(M,c),j=null!=r?new Float32Array(M,m):null,R=null!=o?new Float32Array(M,f):null,I=null!=n?new Uint8Array(M,y):null;for(let w=0;w<i;++w){const s=3*w;for(let a=0;a<3;++a){const i=t[s+a],l=3*i,d=9*w+3*a;if(D[d]=e[l],D[d+1]=e[l+1],D[d+2]=e[l+2],j&&(j[d]=r[l],j[d+1]=r[l+1],j[d+2]=r[l+2]),R){const e=2*i,t=6*w+2*a;R[t]=o[e],R[t+1]=o[e+1]}if(I){const e=4*i,t=12*w+4*a;I[t]=n[e],I[t+1]=n[e+1],I[t+2]=n[e+2],I[t+3]=n[e+3]}}}w(S,x,s),w(S,x+b,s/2**32),w(S,g,0),w(S,g+b,i-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:u,uv0:h,uvRegion:!1,featureIndex:!0}}}function w(e,t,r){e[t]=255&r,e[t+1]=255&r>>8,e[t+2]=255&r>>16,e[t+3]=255&r>>24}function S(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const r=t;let o="";for(const n of r)o+=n.makeHash();return o+JSON.stringify(e.transform?.toJSON()??"")+(u(e.vertexSpace)?JSON.stringify(e.vertexSpace.origin):"")+JSON.stringify(e.spatialReference)}const b=4,_=4,N=1,v=8;export{p as I3SClientNodeLoader,x as createSphereFromExtent,_ as sizeOfFloat32,b as sizeOfInt32,v as sizeOfUInt64,N as sizeOfUInt8,g as transformNormals};
5
+ import e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MinPriority as r}from"../../../../core/MemCache.js";import{throwIfAborted as o}from"../../../../core/promiseUtils.js";import{generateUUID as n}from"../../../../core/uuid.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{q as i}from"../../../../chunks/vec32.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{ensurePackedArray as c}from"../../../../geometry/support/DoubleArray.js";import{isRelativeVertexSpace as u}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{u as m}from"../../../../chunks/sphere.js";import{CachedMeshData as h}from"./CachedMeshData.js";import{convertMeshMaterialToPBRMaterial as f}from"./I3SClientMaterialUtil.js";class p{constructor(e,t,r,o){this._uid=e,this._worker=o,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._memCache=r.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const r=`mesh${t}`,o=e.extent,n=o.spatialReference,s=this._indexSR,a=x(o,e.origin);d(a,n,a,s);return{type:"mesh",id:r,version:S(e),oid:t,mbs:a,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(t,r){if(null!=this.getMeshNodeIndex(r.oid))throw new e("scenelayer",`I3SClientNodeLoader: client side mesh for feature oid=${r.oid} already exists`);r.nodeIndex=t,this._id2Meta.set(r.id,r),this._oid2Meta.set(r.oid,r)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}getMeshNodeInfo(e){const t=this._oid2Meta.values();for(const r of t)if("mesh"===r.type&&r.id===e)return r;return null}removeNode(e){const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){const r=this._id2Meta.get(t);if(null==r)throw new e("scenelayer",`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(r.type){case"mesh":return this._loadMeshNodeJSON(r);case"mesh-component":return y(r);default:throw new e("scenelayer",`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){const t=e.id,r=(await this._getMeshData(e)).loadedMesh;if(null==r.components||0===r.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const o=[],n=r.components;for(let s=0;s<n.length;++s){const r=`${t}-component${s}`,n={type:"mesh-component",id:r,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(n.id,n),e.componentNodeIds.push(r),o.push({id:n.id,href:null,mbs:n.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:o}}updateNodeIndex(e,t,r){const o=this._id2Meta.get(e);o&&"mesh"===o.type&&(o.nodeIndex=r)}async loadNodeData(r,n){const s=this._id2Meta.get(r);if(null==s||"mesh-component"!==s.type)throw new e("scenelayer",`Failed to load client node data for node ${r} (unexpected node info)`);const a=s.meshNodeInfo,i=await this._getMeshData(a),l=i.loadedMesh,d=a.oid;if(null==l.components)throw new e("scenelayer",`Failed to load client node data for node ${r} (unexpected null reference)`);const u=l.components[s.componentIndex],{material:m,requiredTextures:h,textureData:p}=await f(u.material);if(null!=p)for(const e of p)null!=e&&s.textureData.set(e.id,e);const y={params:{material:m},type:"ArrayBufferView"},{vertexSpace:x,origin:w,transform:S}=l,b=[w.x,w.y,w.z??0];i.projectionPromise||(t(this._worker,"SceneLayerWorker is needed to project mesh"),i.projectionPromise=this._worker.project({positions:l.vertexAttributes.position,localMatrix:S?.localMatrix,vertexSpace:x.toJSON(),origin:b,inSpatialReference:l.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON()},n));const{projected:_,original:N,projectedOrigin:v}=await i.projectionPromise,D=c(v);l.vertexAttributes.position=N;const{transformed:j,original:R}=await g(u,i,this._worker,n);l.vertexAttributes.normal=R,o(n);const{geometryBuffer:I,geometryDescriptor:A}=M(_,u.faces,j,l.vertexAttributes.uv,l.vertexAttributes.color,d);return{geometryData:{featureDataPosition:D,featureIds:[],geometries:[y]},attributeDataInfo:{attributeData:{},loadedAttributes:[]},geometryBuffer:I,geometryDescriptor:A,requiredTextures:h,textureData:p,normalReferenceFrame:this._vertexSR.isGeographic?"east-north-up":"vertex-reference-frame"}}async loadAttributes(e,t,r){const o=e.numFeatures,n={};for(const{field:{name:s}}of t)n[s]=new Array(o);return n}async loadTextures(e,t,r){const o=e.id,n=this._id2Meta.get(o);if(null==n||"mesh-component"!==n.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(n.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,o=this._memCache.get(t);if(null==o){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const o=async(o,n)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(i){n(i)}const a=new h(s);this._memCache.put(t,a,r),e.loadMeshPromise=null,o(a)};return e.loadMeshPromise=new Promise((e,t)=>o(e,t)),e.loadMeshPromise}return o}}async function y(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}function x(e,t){const{spatialReference:r}=e,o=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],s=r.isGeographic?r.metersPerUnit:1,a=e.center;let i=0;if(e.hasZ)for(let l=0;l<2;++l)for(let e=0;e<2;++e)for(let r=0;r<2;++r){const d=(a.x+o[l]*n[0]-t.x)*s,c=(a.y+o[e]*n[1]-t.y)*s,u=a.z+o[r]*n[2]-t.z;i=Math.max(d*d+c*c+u*u,i)}else for(let l=0;l<2;++l)for(let e=0;e<2;++e){const r=(a.x+o[l]*n[0]-t.x)*s,d=(a.y+o[e]*n[1]-t.y)*s;i=Math.max(r*r+d*d,i)}return m([t.x,t.y,t.z],Math.sqrt(i))}async function g(e,r,o,n){const{transform:d,vertexAttributes:c}=r.loadedMesh,u="source"===e.shading?c.normal:null;if(!(null!=u&&null!=d&&(0!==d.rotationAngle||!i(d.scale,l))))return{transformed:u,original:c.normal};if(!r.normalsTransformPromise){t(o,"SceneLayerWorker is needed to transform mesh normals");const e=a();s(e,d.localMatrix),r.normalsTransformPromise=o.transformNormals({normalMatrix:e,normals:u},n)}return r.normalsTransformPromise}function M(e,t,r,o,n,s){const a=1,i=(t?.length??0)/3,l=3*i;let d=0,c=0,u=!1,m=0,h=!1,f=0,p=!1,y=0,x=0,g=0;d+=b,d+=b,c=d,d+=3*l*_,null!=r&&(u=!0,m=d,d+=3*l*_),null!=o&&(h=!0,f=d,d+=2*l*_),null!=n&&(p=!0,y=d,d+=4*l*N),x=d,d+=a*v,g=d,d+=2*a*b;const M=new ArrayBuffer(d),S=new Uint8Array(M);w(S,0,l),w(S,b,a);const D=new Float32Array(M,c),j=null!=r?new Float32Array(M,m):null,R=null!=o?new Float32Array(M,f):null,I=null!=n?new Uint8Array(M,y):null;for(let w=0;w<i;++w){const s=3*w;for(let a=0;a<3;++a){const i=t[s+a],l=3*i,d=9*w+3*a;if(D[d]=e[l],D[d+1]=e[l+1],D[d+2]=e[l+2],j&&(j[d]=r[l],j[d+1]=r[l+1],j[d+2]=r[l+2]),R){const e=2*i,t=6*w+2*a;R[t]=o[e],R[t+1]=o[e+1]}if(I){const e=4*i,t=12*w+4*a;I[t]=n[e],I[t+1]=n[e+1],I[t+2]=n[e+2],I[t+3]=n[e+3]}}}w(S,x,s),w(S,x+b,s/2**32),w(S,g,0),w(S,g+b,i-1);return{geometryBuffer:M,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:u,uv0:h,uvRegion:!1,featureIndex:!0}}}function w(e,t,r){e[t]=255&r,e[t+1]=255&r>>8,e[t+2]=255&r>>16,e[t+3]=255&r>>24}function S(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const r=t;let o="";for(const n of r)o+=n.makeHash();return o+JSON.stringify(e.transform?.toJSON()??"")+(u(e.vertexSpace)?JSON.stringify(e.vertexSpace.origin):"")+JSON.stringify(e.spatialReference)}const b=4,_=4,N=1,v=8;export{p as I3SClientNodeLoader,x as createSphereFromExtent,_ as sizeOfFloat32,b as sizeOfInt32,v as sizeOfUInt64,N as sizeOfUInt8,g as transformNormals};