@arcgis/core 5.2.0-next.6 → 5.2.0-next.7

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 (346) hide show
  1. package/WebLinkChart.d.ts +1 -1
  2. package/WebMap.d.ts +2 -2
  3. package/WebScene.d.ts +3 -3
  4. package/arcade.d.ts +9 -9
  5. package/arcgisGlobal.d.ts +4 -0
  6. package/assets/esri/core/workers/RemoteClient.js +1 -1
  7. package/assets/esri/core/workers/chunks/03354ad3d74d858173b4.js +1 -0
  8. package/assets/esri/core/workers/chunks/{07a242ea908aa8e2ba28.js → 09a4139fc6d069ab6928.js} +1 -1
  9. package/assets/esri/core/workers/chunks/09d0e430c66788a2626f.js +640 -0
  10. package/assets/esri/core/workers/chunks/0a510acf50915e00c62b.js +1 -0
  11. package/assets/esri/core/workers/chunks/{829a0583b8a228c65379.js → 0b169bb1969f86232a1a.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{20e2d11f6de438ee883e.js → 0ded58ccb83f624f1460.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{d1ac98f48bb6d43d97c8.js → 0f3654c8157ec8f22869.js} +3 -3
  14. package/assets/esri/core/workers/chunks/19dcae83be0fc0aced02.js +1 -0
  15. package/assets/esri/core/workers/chunks/1eabe746481e0b228498.js +1 -0
  16. package/assets/esri/core/workers/chunks/{c27cb2a83a1d2e004501.js → 238478cfe493fd4a6100.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{bf706a5d065a357de51b.js → 2413b383b7f2bdcd4ced.js} +1 -1
  18. package/assets/esri/core/workers/chunks/277718031c903da2b3b9.js +1 -0
  19. package/assets/esri/core/workers/chunks/{7ed5b669010db58845f8.js → 294f2803aac000c99693.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{093f27e4e4781870b431.js → 297ae764445e6f73a5ea.js} +1 -1
  21. package/assets/esri/core/workers/chunks/2b36a54927f5a7281da3.js +1 -0
  22. package/assets/esri/core/workers/chunks/{be0eab592db0e651b023.js → 2b814bb51704a5b4fdc2.js} +6 -6
  23. package/assets/esri/core/workers/chunks/3172d7fc23787a287191.js +1 -0
  24. package/assets/esri/core/workers/chunks/{eedee0af459e6b8a6116.js → 33e0130e6a40fc768978.js} +1 -1
  25. package/assets/esri/core/workers/chunks/343ba5ea459e96ba79c6.js +1 -0
  26. package/assets/esri/core/workers/chunks/{a2159df718a7f2f59271.js → 38a2f34661563c7c29c1.js} +1 -1
  27. package/assets/esri/core/workers/chunks/3a5c1c501808352857bd.js +1 -0
  28. package/assets/esri/core/workers/chunks/{a96c7432ca97cbeef4b8.js → 3db898a38a7c5f0efb48.js} +1 -1
  29. package/assets/esri/core/workers/chunks/3fbb6ff940156a981983.js +1 -0
  30. package/assets/esri/core/workers/chunks/{24eaf1349ffe10e616e6.js → 40c4e14e7bb505ef10a3.js} +1 -1
  31. package/assets/esri/core/workers/chunks/4104fa1ede36bcee9be5.js +1 -0
  32. package/assets/esri/core/workers/chunks/{b002304a45856b024b46.js → 4714241189c13d0db897.js} +1 -1
  33. package/assets/esri/core/workers/chunks/485d20152495c27b8074.js +1 -0
  34. package/assets/esri/core/workers/chunks/{16b90d8f628a412ba4ba.js → 4894997bfa438f66da36.js} +1 -1
  35. package/assets/esri/core/workers/chunks/{0e774f14ba274832f390.js → 520e0e5307eef27becc6.js} +1 -1
  36. package/assets/esri/core/workers/chunks/53d165b4f30fd64e5d8a.js +1 -0
  37. package/assets/esri/core/workers/chunks/{c83fea0d0ebd0d8e43fd.js → 542f5469f7b42026b24f.js} +1 -1
  38. package/assets/esri/core/workers/chunks/5553279998ae07b60f5f.js +1 -0
  39. package/assets/esri/core/workers/chunks/{cda99b543a0e1979346c.js → 5cb1b950249d651f3837.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{7601278ebced0c0c31cf.js → 5e3e0d7b85dfd52d1c7d.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{f5a2c28dc26c065ea355.js → 62dfbdc847be4800e833.js} +22 -20
  42. package/assets/esri/core/workers/chunks/{c216cd5d6b5d4fe4bab3.js → 62e77e3c5ca9b4887923.js} +2 -2
  43. package/assets/esri/core/workers/chunks/{cc479daacd2cf715baa8.js → 62fc3c367f736c73b0d7.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{b1f1271434af302938e8.js → 643c33a98f2d30a92001.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{1c1515e020e32e177b54.js → 6a5356ebed70e0f8f979.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{3402fb9c596b582311c7.js → 75839240022b280929f7.js} +1 -1
  47. package/assets/esri/core/workers/chunks/77a4f6f224d7ca4b69f4.js +1 -0
  48. package/assets/esri/core/workers/chunks/{6637f19b82555738a1d5.js → 78aa5bc6af2758da20d0.js} +1 -1
  49. package/assets/esri/core/workers/chunks/7df94cb985db41815fad.js +2 -0
  50. package/assets/esri/core/workers/chunks/{153dc2a0b08a0e44a881.js → 8419934bec7723b0feef.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{50dc9893e13396f5e35d.js → 875cce0be4f6c89f80f3.js} +2 -2
  52. package/assets/esri/core/workers/chunks/{c319c3b85cdec73a9f45.js → 877c848beaf9a939862c.js} +1 -1
  53. package/assets/esri/core/workers/chunks/{ae74f722fb385e45fcf1.js → 893c0d28a5bf3f9f29f1.js} +1 -1
  54. package/assets/esri/core/workers/chunks/{5abe34bb0110694f7b42.js → 90953a827bc89d0e6bd5.js} +1 -1
  55. package/assets/esri/core/workers/chunks/{14c6419568d8a7a15cd6.js → 92ab5886aa2d8b9b179f.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{4e676e888a935c507d90.js → 93d4bda22bde33fafa57.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{fbb23db01f3cf629d32e.js → 992a90ecbab931198fd0.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{1765042635084f75d2b3.js → 9b676606bf839b7aa433.js} +1 -1
  59. package/assets/esri/core/workers/chunks/a261f4c22224511fdfff.js +1 -0
  60. package/assets/esri/core/workers/chunks/{ea8f642b1db933d2c26f.js → a2ac139d0975085279a6.js} +1 -1
  61. package/assets/esri/core/workers/chunks/a4d3cbc02dc1186a9a6d.js +1 -0
  62. package/assets/esri/core/workers/chunks/a8ec5b85c2fa6fb4f391.js +1 -0
  63. package/assets/esri/core/workers/chunks/{6af77529c977d034d287.js → b23009d9f8eb7c20ce45.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{1f55d60d3adc31283296.js → b79428c5093614174e76.js} +1 -1
  65. package/assets/esri/core/workers/chunks/b9bdb1f05e904c3655e4.js +1 -0
  66. package/assets/esri/core/workers/chunks/c4fc85281ca83af7abaf.js +1 -0
  67. package/assets/esri/core/workers/chunks/c983e5ce0ff952b65d7f.js +1 -0
  68. package/assets/esri/core/workers/chunks/{f79bd469b25099a31274.js → ca6907e14b1dde4d5c07.js} +1 -1
  69. package/assets/esri/core/workers/chunks/cbbd94c53e75efc99876.js +1 -0
  70. package/assets/esri/core/workers/chunks/{8f94c90fdb0333da2d0f.js → cfd28eba44cf5a296c6d.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{e9dcc3e9dbafe9bbed84.js → d21480b078ec9680d4c4.js} +1 -1
  72. package/assets/esri/core/workers/chunks/{ace1899a8e5162b4018d.js → d6bb8db22ba85ad05fd7.js} +1 -1
  73. package/assets/esri/core/workers/chunks/{8244b74e9c3a30d8d2f6.js → d9d4754062758789f186.js} +2 -2
  74. package/assets/esri/core/workers/chunks/{d35c475f004367e333eb.js → e094364e54981c91e1b4.js} +1 -1
  75. package/assets/esri/core/workers/chunks/e33d2ede6c9f1527d51b.js +1 -0
  76. package/assets/esri/core/workers/chunks/{3e3134e4bc34d4e07179.js → e545df5ea7c0ced92cee.js} +1 -1
  77. package/assets/esri/core/workers/chunks/{49f6c9e9980b8c624fd7.js → f02fe24177e56a7e42b2.js} +1 -1
  78. package/assets/esri/core/workers/chunks/{d1ccc5f2d8892328ab01.js → f5731ad4cfbbf1cc569a.js} +2 -2
  79. package/assets/esri/themes/base/widgets/_DatePicker.scss +1 -1
  80. package/chunks/RealisticTree.glsl.js +17 -15
  81. package/config.d.ts +2 -2
  82. package/config.js +1 -1
  83. package/core/Collection.d.ts +25 -25
  84. package/core/Error.d.ts +1 -1
  85. package/core/JSONSupport.d.ts +1 -1
  86. package/core/promiseUtils.d.ts +3 -3
  87. package/core/reactiveUtils.d.ts +4 -4
  88. package/core/sql/WhereClause.d.ts +1 -1
  89. package/core/timeUtils.d.ts +1 -1
  90. package/core/workers/Connection.d.ts +9 -9
  91. package/core/workers.d.ts +1 -1
  92. package/editing/types.d.ts +3 -3
  93. package/geometry/Mesh.d.ts +9 -2
  94. package/geometry/Mesh.js +1 -1
  95. package/geometry/support/MeshMaterial.d.ts +5 -5
  96. package/geometry/support/MeshTexture.d.ts +19 -19
  97. package/geometry/support/jsonUtils.d.ts +1 -1
  98. package/geometry/support/meshUtils.d.ts +130 -2
  99. package/geometry/support/meshUtils.js +1 -1
  100. package/identity/Credential.d.ts +1 -1
  101. package/identity/IdentityManager.d.ts +1 -1
  102. package/identity/OAuthInfo.d.ts +1 -1
  103. package/identity/ServerInfo.d.ts +2 -2
  104. package/interfaces.d.ts +13 -0
  105. package/intl/number.d.ts +3 -3
  106. package/intl/substitute.d.ts +2 -2
  107. package/intl.d.ts +28 -28
  108. package/kernel.js +1 -1
  109. package/layers/AnnotationLayer.js +1 -1
  110. package/layers/BaseDynamicLayer.d.ts +5 -5
  111. package/layers/BaseTileLayer.d.ts +4 -4
  112. package/layers/BuildingSceneLayer.d.ts +1 -1
  113. package/layers/CSVLayer.d.ts +7 -1
  114. package/layers/CatalogLayer.d.ts +6 -0
  115. package/layers/DimensionFeatureLayer.js +1 -1
  116. package/layers/FeatureLayer.d.ts +44 -7
  117. package/layers/FeatureLayer.js +1 -1
  118. package/layers/GeoJSONLayer.d.ts +7 -1
  119. package/layers/LinkChartLayer.js +1 -1
  120. package/layers/MapImageLayer.d.ts +5 -5
  121. package/layers/MediaLayer.d.ts +2 -2
  122. package/layers/OrientedImageryLayer.d.ts +29 -2
  123. package/layers/ParquetLayer.d.ts +7 -1
  124. package/layers/SceneLayer.d.ts +1 -1
  125. package/layers/SceneLayer.js +1 -1
  126. package/layers/StreamLayer.d.ts +1 -1
  127. package/layers/SubtypeGroupLayer.d.ts +7 -1
  128. package/layers/TileLayer.d.ts +2 -2
  129. package/layers/VideoLayer.d.ts +1 -1
  130. package/layers/VoxelLayer.d.ts +4 -4
  131. package/layers/WCSLayer.d.ts +2 -2
  132. package/layers/WFSLayer.d.ts +6 -0
  133. package/layers/WebTileLayer.d.ts +1 -1
  134. package/layers/catalog/CatalogFootprintLayer.d.ts +20 -1
  135. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  136. package/layers/knowledgeGraph/KnowledgeGraphSublayer.d.ts +6 -0
  137. package/layers/mixins/ArcGISImageService.d.ts +7 -1
  138. package/layers/mixins/BlendLayer.d.ts +1 -1
  139. package/layers/mixins/DataSeriesLayer.d.ts +161 -0
  140. package/layers/mixins/DataSeriesLayer.js +2 -0
  141. package/layers/mixins/FeatureLayerBase.d.ts +3 -3
  142. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  143. package/layers/support/DateTimeFieldFormat.d.ts +10 -10
  144. package/layers/support/FeatureEffect.d.ts +22 -22
  145. package/layers/support/FeatureReductionBinning.d.ts +12 -0
  146. package/layers/support/FeatureReductionCluster.d.ts +12 -0
  147. package/layers/support/Field.d.ts +2 -2
  148. package/layers/support/ImageElement.d.ts +1 -1
  149. package/layers/support/MosaicRule.d.ts +0 -2
  150. package/layers/support/NumberFieldFormat.d.ts +5 -5
  151. package/layers/support/StreamConnection.d.ts +1 -1
  152. package/layers/support/Sublayer.d.ts +2 -2
  153. package/layers/support/SubtypeSublayer.d.ts +14 -1
  154. package/layers/support/TimeSeriesFieldTimeMapping.d.ts +30 -0
  155. package/layers/support/TimeSeriesFieldTimeMapping.js +2 -0
  156. package/layers/support/TimeSeriesInfo.d.ts +149 -0
  157. package/layers/support/TimeSeriesInfo.js +2 -0
  158. package/layers/support/VideoElement.d.ts +1 -1
  159. package/layers/support/dataSeriesUtils.d.ts +18 -0
  160. package/layers/support/dataSeriesUtils.js +2 -0
  161. package/layers/support/kmlUtils.js +1 -1
  162. package/layers/support/timeSeriesUtils.d.ts +27 -0
  163. package/layers/support/timeSeriesUtils.js +2 -0
  164. package/layers/types.d.ts +1 -1
  165. package/linkChart/ChronologicalLayoutSettings.d.ts +1 -1
  166. package/networks/CircuitManager.d.ts +1 -1
  167. package/networks/Network.d.ts +1 -1
  168. package/networks/UnitIdentifierManager.d.ts +1 -1
  169. package/networks/support/NamedTraceConfiguration.d.ts +1 -1
  170. package/networks/support/TraceConfiguration.d.ts +2 -2
  171. package/networks/support/UNTraceConfiguration.d.ts +3 -3
  172. package/networks/support/jsonTypes.d.ts +7 -1
  173. package/networks/support/utils.js +1 -1
  174. package/package.json +3 -3
  175. package/popup/content/CustomContent.d.ts +1 -1
  176. package/portal/Portal.d.ts +2 -2
  177. package/portal/jsonTypes.d.ts +2 -2
  178. package/renderers/support/AuthoringInfo.d.ts +14 -1
  179. package/renderers/support/AuthoringInfo.js +1 -1
  180. package/renderers/support/AuthoringInfoVisualVariable.d.ts +14 -1
  181. package/renderers/support/AuthoringInfoVisualVariable.js +1 -1
  182. package/renderers/support/jsonUtils.d.ts +1 -1
  183. package/renderers/support/utils.d.ts +1 -1
  184. package/renderers/visualVariables/RotationVariable.d.ts +16 -1
  185. package/renderers/visualVariables/RotationVariable.js +1 -1
  186. package/request/types.d.ts +23 -23
  187. package/rest/geometryService.d.ts +1 -1
  188. package/rest/knowledgeGraph/CreateReplicaResponse.d.ts +1 -1
  189. package/rest/knowledgeGraph/GraphApplyEdits.d.ts +1 -1
  190. package/rest/knowledgeGraph/GraphProperty.d.ts +5 -1
  191. package/rest/knowledgeGraph/GraphQueryStreamingResult.d.ts +2 -2
  192. package/rest/knowledgeGraph/wasmInterface/wasmToDataModelFactories.js +1 -1
  193. package/rest/knowledgeGraph/wasmInterface/wasmToQueryResponseObjFactories.js +1 -1
  194. package/rest/knowledgeGraph/wasmInterface/wasmToReplicaFactories.js +1 -1
  195. package/rest/knowledgeGraphService.d.ts +13 -13
  196. package/rest/layerSources/DynamicDataLayer.d.ts +1 -1
  197. package/rest/print.d.ts +1 -1
  198. package/rest/support/AttributeBinsQuery.d.ts +16 -2
  199. package/rest/support/ClosestFacilityParameters.d.ts +6 -6
  200. package/rest/support/LastMileDeliveryParameters.d.ts +4 -4
  201. package/rest/support/LocationToAddressParameters.d.ts +1 -1
  202. package/rest/support/PrintTemplate.d.ts +5 -5
  203. package/rest/support/Query.d.ts +18 -4
  204. package/rest/support/RouteParameters.d.ts +5 -5
  205. package/rest/support/ServiceAreaParameters.d.ts +6 -6
  206. package/rest/support/TopFeaturesQuery.d.ts +16 -2
  207. package/rest/support/meshFeatureSet.js +1 -1
  208. package/smartMapping/renderers/color.d.ts +40 -0
  209. package/smartMapping/renderers/color.js +1 -1
  210. package/smartMapping/renderers/opacity.d.ts +8 -0
  211. package/smartMapping/renderers/opacity.js +1 -1
  212. package/smartMapping/renderers/size.d.ts +38 -0
  213. package/smartMapping/renderers/size.js +1 -1
  214. package/smartMapping/renderers/support/regenerateUtils.js +1 -1
  215. package/smartMapping/renderers/support/timeSeriesUtils.js +2 -0
  216. package/smartMapping/renderers/type.d.ts +20 -1
  217. package/smartMapping/renderers/type.js +1 -1
  218. package/smartMapping/renderers/univariateColorSize.d.ts +19 -0
  219. package/smartMapping/renderers/univariateColorSize.js +1 -1
  220. package/support/revision.js +1 -1
  221. package/support/tests/setupServiceMocksMesh.js +1 -1
  222. package/support/timeUtils.d.ts +3 -3
  223. package/symbols/Font.d.ts +7 -7
  224. package/symbols/WebStyleSymbol.d.ts +11 -11
  225. package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
  226. package/symbols/support/Symbol3DEmissive.d.ts +8 -2
  227. package/symbols/support/jsonUtils.d.ts +1 -1
  228. package/time/TimeExtent.d.ts +2 -2
  229. package/versionManagement/VersionManagementService.d.ts +8 -8
  230. package/versionManagement/VersionManager.d.ts +13 -3
  231. package/versionManagement/VersioningState.d.ts +4 -4
  232. package/views/2d/MapViewConstraints.d.ts +29 -25
  233. package/views/2d/engine/flow/styles/Imagery.js +1 -1
  234. package/views/2d/engine/flow/styles/Particles.js +1 -1
  235. package/views/2d/engine/flow/styles/Streamlines.js +1 -1
  236. package/views/2d/engine/vectorTiles/VectorTileFeatureIndex.js +1 -1
  237. package/views/2d/engine/vectorTiles/style/StyleLayer.js +1 -1
  238. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  239. package/views/2d/layers/BaseLayerView2D.d.ts +4 -20
  240. package/views/2d/layers/BaseLayerViewGL2D.d.ts +6 -22
  241. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  242. package/views/2d/layers/features/support/FeatureSetReader.js +1 -1
  243. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  244. package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
  245. package/views/3d/analysis/Viewshed/ViewshedPlacementController.js +1 -1
  246. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementError.d.ts +1 -1
  247. package/views/3d/glTF/internal/resourceUtils.js +1 -1
  248. package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
  249. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  250. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  251. package/views/3d/webgl/RenderNode.d.ts +7 -7
  252. package/views/3d/webgl-engine/effects/glow/Glow.js +1 -1
  253. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  254. package/views/3d/webgl-engine/shaders/RealisticTree.glsl.js +1 -1
  255. package/views/BreakpointsOwner.d.ts +1 -1
  256. package/views/DOMContainer.d.ts +6 -6
  257. package/views/Magnifier.d.ts +1 -1
  258. package/views/MapView.d.ts +1 -1
  259. package/views/SceneView.d.ts +2 -2
  260. package/views/View2D.d.ts +62 -54
  261. package/views/Viewport2DMixin.d.ts +1 -1
  262. package/views/analysis/ElevationProfile/ElevationProfileError.d.ts +1 -1
  263. package/views/input/gamepad/GamepadInputDevice.d.ts +1 -1
  264. package/views/input/types.d.ts +15 -15
  265. package/views/layers/FeatureLikeLayerView.d.ts +7 -4
  266. package/views/layers/GraphicsLayerView.d.ts +6 -3
  267. package/views/layers/ImageryLayerView.d.ts +4 -0
  268. package/views/navigation/Navigation.d.ts +1 -1
  269. package/views/support/WebAssemblyRequirements.js +1 -1
  270. package/views/types.d.ts +1 -1
  271. package/webscene/Glow.d.ts +0 -4
  272. package/widgets/BasemapGallery.d.ts +1 -1
  273. package/widgets/BasemapLayerList.d.ts +1 -1
  274. package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
  275. package/widgets/BatchAttributeForm.d.ts +1 -1
  276. package/widgets/BatchAttributeForm.js +1 -1
  277. package/widgets/Bookmarks.d.ts +1 -1
  278. package/widgets/BuildingExplorer.d.ts +1 -1
  279. package/widgets/CoordinateConversion/CoordinateConversionViewModel.d.ts +2 -2
  280. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  281. package/widgets/CoordinateConversion.d.ts +2 -2
  282. package/widgets/Daylight.d.ts +1 -1
  283. package/widgets/Directions.d.ts +1 -1
  284. package/widgets/Editor.d.ts +1 -1
  285. package/widgets/Feature.d.ts +1 -1
  286. package/widgets/FeatureForm.d.ts +1 -1
  287. package/widgets/FeatureTable/FieldColumn.d.ts +1 -14
  288. package/widgets/FeatureTable/Grid/Column.d.ts +1 -1
  289. package/widgets/FeatureTable/support/ColumnTemplateBase.d.ts +1 -1
  290. package/widgets/FeatureTemplates.d.ts +1 -1
  291. package/widgets/FloorFilter.d.ts +1 -1
  292. package/widgets/Fullscreen/FullscreenViewModel.d.ts +3 -3
  293. package/widgets/Fullscreen/FullscreenViewModel.js +1 -1
  294. package/widgets/Fullscreen.d.ts +3 -3
  295. package/widgets/LayerList/ListItemPanel.d.ts +5 -5
  296. package/widgets/Legend.d.ts +1 -1
  297. package/widgets/Locate/LocateViewModel.d.ts +2 -2
  298. package/widgets/Locate.d.ts +1 -1
  299. package/widgets/PanoramicViewer/utils.js +1 -1
  300. package/widgets/Popup.d.ts +1 -1
  301. package/widgets/Print/PrintViewModel.d.ts +2 -2
  302. package/widgets/Print/TemplateOptions.d.ts +4 -4
  303. package/widgets/Print.d.ts +6 -6
  304. package/widgets/Search/SearchViewModel.d.ts +5 -5
  305. package/widgets/Search.d.ts +4 -4
  306. package/widgets/ShadowCast.d.ts +1 -1
  307. package/widgets/Sketch/SketchViewModel.d.ts +1 -1
  308. package/widgets/Slice.d.ts +1 -1
  309. package/widgets/TableList/ListItemPanel.d.ts +5 -5
  310. package/widgets/Track/TrackViewModel.d.ts +3 -3
  311. package/widgets/Track.d.ts +3 -3
  312. package/widgets/UtilityNetworkTrace.d.ts +1 -1
  313. package/widgets/VersionManagement/VersionManagementViewModel.d.ts +2 -2
  314. package/widgets/Weather.d.ts +1 -1
  315. package/widgets/Widget.d.ts +1 -1
  316. package/widgets/support/forms/formUtils.js +1 -1
  317. package/widgets/support/types.d.ts +1 -1
  318. package/widgets/support/widget.d.ts +6 -6
  319. package/assets/esri/core/workers/chunks/1ddbf5f507ac153234be.js +0 -1
  320. package/assets/esri/core/workers/chunks/29615df388a0df022d8c.js +0 -1
  321. package/assets/esri/core/workers/chunks/2bd334f9ab89334df713.js +0 -1
  322. package/assets/esri/core/workers/chunks/319ff04282dc8ae38b56.js +0 -2
  323. package/assets/esri/core/workers/chunks/3a6678ee9990d7e83e15.js +0 -1
  324. package/assets/esri/core/workers/chunks/3b3986276e70297d573b.js +0 -1
  325. package/assets/esri/core/workers/chunks/46fbd519cc1a37923bfc.js +0 -1
  326. package/assets/esri/core/workers/chunks/4ef53455c8bc6efee80e.js +0 -1
  327. package/assets/esri/core/workers/chunks/51ee6102f5f4840a5b47.js +0 -1
  328. package/assets/esri/core/workers/chunks/58994b6bfcda5f2ada80.js +0 -1
  329. package/assets/esri/core/workers/chunks/6db274f6767102a39021.js +0 -1
  330. package/assets/esri/core/workers/chunks/77769663cd712822d33e.js +0 -1
  331. package/assets/esri/core/workers/chunks/8c5a41ae68775bac3446.js +0 -1
  332. package/assets/esri/core/workers/chunks/b08a1255dacf6cfcf139.js +0 -640
  333. package/assets/esri/core/workers/chunks/b098469e0010a6b44df9.js +0 -1
  334. package/assets/esri/core/workers/chunks/ca1b0cb14ea9ae1bf2a3.js +0 -1
  335. package/assets/esri/core/workers/chunks/ca4245414d8ecd217f9d.js +0 -1
  336. package/assets/esri/core/workers/chunks/d3af51a6d9014ff46170.js +0 -1
  337. package/assets/esri/core/workers/chunks/d561dc933d8fe1672d85.js +0 -1
  338. package/assets/esri/core/workers/chunks/e38836bfcc7a15a2fd1f.js +0 -1
  339. package/assets/esri/core/workers/chunks/e645f992ec6f935ee3a5.js +0 -1
  340. package/assets/esri/core/workers/chunks/eabd4a78221b7e733793.js +0 -1
  341. package/assets/esri/core/workers/chunks/f05932aea4eb267cba4d.js +0 -1
  342. /package/assets/esri/core/workers/chunks/{50dc9893e13396f5e35d.js.LICENSE.txt → 62e77e3c5ca9b4887923.js.LICENSE.txt} +0 -0
  343. /package/assets/esri/core/workers/chunks/{319ff04282dc8ae38b56.js.LICENSE.txt → 7df94cb985db41815fad.js.LICENSE.txt} +0 -0
  344. /package/assets/esri/core/workers/chunks/{c216cd5d6b5d4fe4bab3.js.LICENSE.txt → 875cce0be4f6c89f80f3.js.LICENSE.txt} +0 -0
  345. /package/assets/esri/core/workers/chunks/{8244b74e9c3a30d8d2f6.js.LICENSE.txt → d9d4754062758789f186.js.LICENSE.txt} +0 -0
  346. /package/assets/esri/core/workers/chunks/{d1ccc5f2d8892328ab01.js.LICENSE.txt → f5731ad4cfbbf1cc569a.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{clone as t}from"../../../core/lang.js";import i from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{isAbortError as r}from"../../../core/promiseUtils.js";import{createScreenPoint as a,isScreenRect as l,pt2px as n}from"../../../core/screenUtils.js";import{property as o,subclass as h}from"../../../core/accessorSupport/decorators.js";import{diff as y,hasDiff as u}from"../../../core/accessorSupport/diffUtils.js";import c from"../../../geometry/Point.js";import{create as d}from"../../../geometry/support/aaBoundingRect.js";import{equals as p}from"../../../geometry/support/spatialReferenceUtils.js";import{isVectorTileGraphicOrigin as _}from"../../../graphic/isVectorTileGraphicOrigin.js";import{tileSizeInTileUnits as f,tileSizeInPixels as g}from"../engine/vectorTiles/constants.js";import{TileHandler as m}from"../engine/vectorTiles/TileHandler.js";import{TileManager as T}from"../engine/vectorTiles/TileManager.js";import{VectorTile as C}from"../engine/vectorTiles/VectorTile.js";import{VectorTileContainer as v}from"../engine/vectorTiles/VectorTileContainer.js";import w from"../engine/vectorTiles/VectorTileFeatureIndex.js";import R from"../engine/vectorTiles/style/StyleRepository.js";import{LayerView2D as H}from"./LayerView2D.js";import I from"../tiling/TileInfoViewPOT.js";import Q from"../tiling/TileQueue.js";import S from"../../layers/VectorTileLayerView.js";import{TaskPriority as P}from"../../support/Scheduler.js";const b=2.5;let V=class extends(H(S)){constructor(){super(...arguments),this._styleChanges=[],this._fetchQueue=null,this._parseQueue=null,this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._styeChanged=!1,this._spriteSourceChanged=!1}get fading(){return(this._vectorTileContainer?.fading||this._tileManager?.isFading())??!1}get hasVisibleFeatures(){const e=this._vectorTileContainer.children;for(const t of e)if(t.hasFeatures())return!0;return!1}get spriteSourceChanged(){return this._spriteSourceChanged}get styleChanged(){return this._styeChanged}async hitTest(e,t){const i=this._tileHandlerPromise,s=this._vectorTileContainer?.symbolFader;if(!i||!this._isTileHandlerReady||!s)return;await i;let r=[];if(l(t)){const e=t;r=[a(e.x,e.y+e.height),a(e.x+e.width,e.y+e.height),a(e.x+e.width,e.y),a(e.x,e.y)]}else r=[t];const o=has("esri-vtl-search-tolerance")??0,h=o>0?o:b,y=this.view.state,{rotation:u,pixelRatio:c}=this.view.state,d=n(h)*c;let p=null;const _=this._vectorTileContainer?.symbolRepository;_&&(p=_.querySymbols(r[0],d,s.decluttererOffset,{}));const f=this._tileManager.getIntersectingTiles(r[0].x,r[0].y,d,y,p);if(p=p?.filter(e=>this._styleRepository.getStyleLayerVisibility(e.styleLayerUID)),(!f||0===f.length)&&0===p?.length)return null;e=e.clone().normalize();const g=[],m=[];for(const a of f)g.push(this._queryTile(m,e,d,u,a,p?.filter(e=>e.tileKey.id===a.id)));return await Promise.all(g),m}update(e){if(this._tileHandlerPromise&&this._isTileHandlerReady)return e.pixelRatio!==this._tileHandler.devicePixelRatio?(this._tileHandler.devicePixelRatio=e.pixelRatio,void this._loadStyle()):void(this._styleChanges.length>0?this._tileHandlerPromise=this._applyStyleChanges():(this._pauseQueues(),this._fetchQueue.state=e.state,this._parseQueue.state=e.state,this._tileManager.update(e)||this.requestUpdate(),this._resumeQueues()))}attach(){const{style:e}=this.layer.currentStyleInfo;this._styleRepository=new R(e),this._tileInfoView=new I(this.layer.tileInfo,this.layer.fullExtent),this._vectorTileContainer=new v(this._tileInfoView),this._tileHandler=new m(this.layer,this._styleRepository,window.devicePixelRatio||1,this.layer.tileInfo.lods.length-1),this.container.addChild(this._vectorTileContainer),this._start(),this.addAttachHandles([this.layer.on("paint-change",e=>{if(this._styeChanged=!0,e.isDataDriven)this._styleChanges.push({type:0,data:e}),this.requestUpdate();else{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=3===i.type;t.setPaintProperties(e.layer,e.paint),s&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender()}}),this.layer.on("layout-change",e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;this._styeChanged=!0;const s=y(i.layout,e.layout);if(null!=s){if(u(s,"visibility")&&1===D(s))return t.setLayoutProperties(e.layer,e.layout),3===i.type&&this._vectorTileContainer?.restartDeclutter(),void this._vectorTileContainer?.requestRender();this._styleChanges.push({type:1,data:e}),this.requestUpdate()}}),this.layer.on("style-layer-visibility-change",e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);i&&(this._styeChanged=!0,t.setStyleLayerVisibility(e.layer,e.visibility),3===i.type&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender())}),this.layer.on("style-layer-change",e=>{this._styleChanges.push({type:2,data:e}),this._styeChanged=!0,this.requestUpdate()}),this.layer.on("delete-style-layer",e=>{this._styleChanges.push({type:3,data:e}),this._styeChanged=!0,this.requestUpdate()}),this.layer.on("load-style",()=>this._loadStyle()),this.layer.on("spriteSource-change",e=>{this._spriteSourceChanged=!0,this._styleChanges.push({type:4,data:e});const t=this._styleRepository.layers;for(const i of t)switch(i.type){case 3:i.getLayoutProperty("icon-image")&&this._styleChanges.push({type:1,data:{layer:i.id,layout:i.layout}});break;case 2:i.getPaintProperty("line-pattern")&&this._styleChanges.push({type:0,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}});break;case 1:i.getLayoutProperty("fill-pattern")&&this._styleChanges.push({type:0,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}})}this.requestUpdate()})])}detach(){this._stop(),this.container.removeAllChildren(),this._vectorTileContainer=s(this._vectorTileContainer),this._tileHandler=s(this._tileHandler)}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}supportsSpatialReference(e){return p(this.layer.tileInfo?.spatialReference,e)}canResume(){let e=super.canResume();const{currentStyleInfo:t}=this.layer;if(e&&t?.layerDefinition){const i=this.view.scale,{minScale:s,maxScale:r}=t.layerDefinition;t?.layerDefinition&&(s&&s<i&&(e=!1),r&&r>i&&(e=!1))}return e}isUpdating(){return this.fading}acquireTile(e){const t=this._createVectorTile(e);return this._updatingHandles.consumePromise(this._fetchQueue.push(t.key).then(e=>this._parseQueue.push({key:t.key,data:e})).then(e=>{t.once("attach",()=>this.requestUpdate()),t.setData(e),this.requestUpdate()}).catch(e=>{r(e)||i.getLogger(this).error(e)})),t}releaseTile(e){const t=e.key.id;this._fetchQueue.abort(t),this._parseQueue.abort(t),this.requestUpdate()}async doRefresh(){if(!this.attached)return;if(this.suspended)return this._tileManager.clear(),void this.requestUpdate();this._isTileHandlerReady=!1,this._pauseQueues(),this._clearQueues(),this._tileManager.clearCache(),this._resumeQueues();const e=this._vectorTileContainer.children,t=[];try{for(const i of e){const e=this._updatingHandles.addPromise(this._fetchQueue.push(i.key).then(e=>this._parseQueue.push({key:i.key,data:e})).then(e=>i.setData(e)).finally(()=>i.featureIndex=null));t.push(e)}await Promise.all(t)}catch(s){i.getLogger(this).error("error refreshing vector-tiles layer-view",s),this._resumeQueues(),this._isTileHandlerReady=!0}this._isTileHandlerReady=!0,this.requestUpdate()}_start(){if(this._stop(),this._tileManager=new T({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),!this.layer.currentStyleInfo)return;const e=new AbortController,t=this._tileHandler.start({signal:e.signal}).then(()=>{this._fetchQueue=new Q({tileInfoView:this._tileInfoView,process:(e,t)=>this._getTileData(e,t),concurrency:15,scheduler:this.scheduler,priority:P.MAPVIEW_FETCH_QUEUE}),this._parseQueue=new Q({tileInfoView:this._tileInfoView,process:(e,t)=>this._parseTileData(e,t),concurrency:8,scheduler:this.scheduler,priority:P.MAPVIEW_VECTOR_TILE_PARSING_QUEUE}),this.requestUpdate(),this._isTileHandlerReady=!0});this._tileHandler.spriteMosaic.then(e=>{this._vectorTileContainer.setStyleResources(e,this._tileHandler.glyphMosaic,this._styleRepository,this._tileInfoView),this.requestUpdate()}),this._tileHandlerAbortController=e,this._tileHandlerPromise=t}_stop(){if(!this._tileHandlerAbortController||!this._vectorTileContainer)return;const e=this._tileHandlerAbortController;e&&e.abort(),this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._fetchQueue=s(this._fetchQueue),this._parseQueue=s(this._parseQueue),this._tileManager=s(this._tileManager),this._vectorTileContainer.removeAllChildren()}async _getTileData(e,t){return this._tileHandler.fetchTileData(e,t)}async _parseTileData(e,t){return this._tileHandler.parseTileData(e,t)}async _applyStyleChanges(){this._isTileHandlerReady=!1,this._pauseQueues(),this._clearQueues(),this._tileManager.clearCache();const e=this._styleChanges;try{await this._tileHandler.updateStyle(e)}catch(o){i.getLogger(this).error("error applying vector-tiles style update",o.message),this._resumeQueues(),this._isTileHandlerReady=!0}const t=this._styleRepository,s=new Set,r=new Set;for(const i of e){if(3!==i.type&&2!==i.type)continue;const e=2===i.type?i.data.layer.id:i.data.layer,a=t.getLayerById(e);a&&(s.add(a.uid),3===a.type&&r.add(a.uid))}const a=this._vectorTileContainer.children,l=this._vectorTileContainer?.symbolFader?.symbolRepository;l&&r.size>0&&l.deleteStyleLayers(Array.from(r));const n=new Set;if(e.forEach(e=>{let i;switch(e.type){case 0:t.setPaintProperties(e.data.layer,e.data.paint),i=e.data.layer;break;case 1:t.setLayoutProperties(e.data.layer,e.data.layout),i=e.data.layer;break;case 3:return void t.deleteStyleLayer(e.data.layer);case 2:t.setStyleLayer(e.data.layer,e.data.index),i=e.data.layer.id;break;case 4:this._vectorTileContainer.setSpriteMosaic(this._tileHandler.setSpriteSource(e.data.spriteSource))}if(i){const e=t.getLayerById(i);e&&n.add(e.uid)}}),s.size>0){const e=Array.from(s);this._vectorTileContainer.deleteStyleLayers(e);for(const t of a)t.deleteLayerData(e)}if(this._resumeQueues(),n.size>0){const e=Array.from(n),t=[];for(const i of a){const s=this._updatingHandles.addPromise(this._fetchQueue.push(i.key).then(t=>this._parseQueue.push({key:i.key,data:t,styleLayerUIDs:e})).then(e=>i.setData(e)).finally(()=>i.featureIndex=null));t.push(s)}await Promise.all(t)}this._styleChanges=[],this._isTileHandlerReady=!0,this.requestUpdate()}async _loadStyle(){const{style:e}=this.layer.currentStyleInfo,i=t(e);this._isTileHandlerReady=!1,this._pauseQueues(),this._clearQueues(),this._styleRepository=new R(i),this._vectorTileContainer.destroy(),this._tileManager.clear(),this._tileHandlerAbortController.abort(),this._tileHandlerAbortController=new AbortController;const{signal:s}=this._tileHandlerAbortController;try{this._tileHandlerPromise=this._tileHandler.setStyle(this._styleRepository,i,this.layer.tileInfo.lods.length-1),await this._tileHandlerPromise}catch(n){if(!r(n))throw n}if(s.aborted)return this._resumeQueues(),this._isTileHandlerReady=!0,this._styeChanged=!1,this._spriteSourceChanged=!1,void this.requestUpdate();const a=await this._tileHandler.spriteMosaic,l=this._vectorTileContainer;this._tileInfoView=new I(this.layer.tileInfo,this.layer.fullExtent),l.setStyleResources(a,this._tileHandler.glyphMosaic,this._styleRepository,this._tileInfoView),this._tileManager=new T({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),this._resumeQueues(),this._isTileHandlerReady=!0,this.requestUpdate(),this._styeChanged=!1,this._spriteSourceChanged=!1}_createVectorTile(e){const t=this._tileInfoView.getTileBounds(d(),e),i=this._tileInfoView.getTileResolution(e.level);return new C(e,i,t[0],t[3],512,512,this._styleRepository)}async _queryTile(e,t,i,s,r,a){if(0===r.layerData.size)return;const l=this._ensureTileIndex(r),[n,o,h,y]=this._tileInfoView.getTileBounds(d(),r.key,!0),u=f*((t.x-n)/(h-n)),c=f*(1-(t.y-o)/(y-o)),p=i*(f/g),m=await l.queryAttributes(u,c,p,s,a);for(const d of m)d.graphic.geometry=this._tileToMapPoint(d.tilePoint,r.transforms.tileUnitsToPixels),e.push({type:"graphic",layer:this.layer,graphic:d.graphic,mapPoint:t.clone()});e.sort((e,t)=>(_(t.graphic.origin)?t.graphic.origin.layerIndex:0)-(_(e.graphic.origin)?e.graphic.origin.layerIndex:0))}_tileToMapPoint(e,t){if(!e)return null;const i=e[0]*t[0]+e[1]*t[3]+t[6],s=e[0]*t[1]+e[1]*t[4]+t[7],r=this.view.state,a=[0,0];return r.toMap(a,[i,s]),new c({x:a[0],y:a[1],spatialReference:r.spatialReference})}_ensureTileIndex(e){let t=e.featureIndex;return t||(t=w.create(e.key,e.layerData,this._styleRepository,this._tileHandler,this.layer),e.featureIndex=t),t}_pauseQueues(){this._fetchQueue.pause(),this._parseQueue.pause()}_resumeQueues(){this._fetchQueue.resume(),this._parseQueue.resume()}_clearQueues(){this._fetchQueue.clear(),this._parseQueue.clear()}};function D(e){if(null==e)return 0;switch(e.type){case"partial":return Object.keys(e.diff).length;case"complete":return Math.max(Object.keys(e.oldValue).length,Object.keys(e.newValue).length);case"collection":return Object.keys(e.added).length+Object.keys(e.changed).length+Object.keys(e.removed).length}}e([o()],V.prototype,"_isTileHandlerReady",void 0),V=e([h("esri.views.2d.layers.VectorTileLayerView2D")],V);const j=V;export{j as default};
2
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import{clone as t}from"../../../core/lang.js";import i from"../../../core/Logger.js";import{destroyMaybe as s}from"../../../core/maybe.js";import{isAbortError as r}from"../../../core/promiseUtils.js";import{createScreenPoint as a,isScreenRect as l,pt2px as n}from"../../../core/screenUtils.js";import{property as o,subclass as h}from"../../../core/accessorSupport/decorators.js";import{diff as y,hasDiff as u}from"../../../core/accessorSupport/diffUtils.js";import c from"../../../geometry/Point.js";import{create as d}from"../../../geometry/support/aaBoundingRect.js";import{equals as p}from"../../../geometry/support/spatialReferenceUtils.js";import{isVectorTileGraphicOrigin as _}from"../../../graphic/isVectorTileGraphicOrigin.js";import{tileSizeInTileUnits as f,tileSizeInPixels as g}from"../engine/vectorTiles/constants.js";import{TileHandler as m}from"../engine/vectorTiles/TileHandler.js";import{TileManager as T}from"../engine/vectorTiles/TileManager.js";import{VectorTile as C}from"../engine/vectorTiles/VectorTile.js";import{VectorTileContainer as v}from"../engine/vectorTiles/VectorTileContainer.js";import w from"../engine/vectorTiles/VectorTileFeatureIndex.js";import R from"../engine/vectorTiles/style/StyleRepository.js";import{LayerView2D as H}from"./LayerView2D.js";import I from"../tiling/TileInfoViewPOT.js";import Q from"../tiling/TileQueue.js";import S from"../../layers/VectorTileLayerView.js";import{TaskPriority as P}from"../../support/Scheduler.js";const b=2.5;let V=class extends(H(S)){constructor(){super(...arguments),this._styleChanges=[],this._fetchQueue=null,this._parseQueue=null,this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._styeChanged=!1,this._spriteSourceChanged=!1}get fading(){return(this._vectorTileContainer?.fading||this._tileManager?.isFading())??!1}get hasVisibleFeatures(){const e=this._vectorTileContainer.children;for(const t of e)if(t.hasFeatures())return!0;return!1}get spriteSourceChanged(){return this._spriteSourceChanged}get styleChanged(){return this._styeChanged}async hitTest(e,t){const i=this._tileHandlerPromise,s=this._vectorTileContainer?.symbolFader;if(!i||!this._isTileHandlerReady||!s)return;await i;let r=[];if(l(t)){const e=t;r=[a(e.x,e.y+e.height),a(e.x+e.width,e.y+e.height),a(e.x+e.width,e.y),a(e.x,e.y)]}else r=[t];const o=has("esri-vtl-search-tolerance")??0,h=o>0?o:b,y=this.view.state,{rotation:u,pixelRatio:c}=this.view.state,d=n(h)*c;let p=null;const _=this._vectorTileContainer?.symbolRepository;_&&(p=_.querySymbols(r[0],d,s.decluttererOffset,{}));const f=this._tileManager.getIntersectingTiles(r[0].x,r[0].y,d,y,p);if(p=p?.filter(e=>this._styleRepository.getStyleLayerVisibility(e.styleLayerUID)),(!f||0===f.length)&&0===p?.length)return null;e=e.clone().normalize();const g=[],m=[];for(const a of f)g.push(this._queryTile(m,e,d,u,a,p?.filter(e=>e.tileKey.id===a.id)));return await Promise.all(g),m}update(e){if(this._tileHandlerPromise&&this._isTileHandlerReady)return e.pixelRatio!==this._tileHandler.devicePixelRatio?(this._tileHandler.devicePixelRatio=e.pixelRatio,void this._loadStyle()):void(this._styleChanges.length>0?this._tileHandlerPromise=this._applyStyleChanges():(this._pauseQueues(),this._fetchQueue.state=e.state,this._parseQueue.state=e.state,this._tileManager.update(e)||this.requestUpdate(),this._resumeQueues()))}attach(){const{style:e}=this.layer.currentStyleInfo;this._styleRepository=new R(e),this._tileInfoView=new I(this.layer.tileInfo,this.layer.fullExtent),this._vectorTileContainer=new v(this._tileInfoView),this._tileHandler=new m(this.layer,this._styleRepository,window.devicePixelRatio||1,this.layer.tileInfo.lods.length-1),this.container.addChild(this._vectorTileContainer),this._start(),this.addAttachHandles([this.layer.on("paint-change",e=>{if(this._styeChanged=!0,e.isDataDriven)this._styleChanges.push({type:0,data:e}),this.requestUpdate();else{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;const s=3===i.type;t.setPaintProperties(e.layer,e.paint),s&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender()}}),this.layer.on("layout-change",e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);if(!i)return;this._styeChanged=!0;const s=y(i.layout,e.layout);if(null!=s){if(u(s,"visibility")&&1===D(s))return t.setLayoutProperties(e.layer,e.layout),3===i.type&&this._vectorTileContainer?.restartDeclutter(),void this._vectorTileContainer?.requestRender();this._styleChanges.push({type:1,data:e}),this.requestUpdate()}}),this.layer.on("style-layer-visibility-change",e=>{const t=this._styleRepository,i=t.getLayerById(e.layer);i&&(this._styeChanged=!0,t.setStyleLayerVisibility(e.layer,e.visibility),3===i.type&&this._vectorTileContainer?.restartDeclutter(),this._vectorTileContainer?.requestRender())}),this.layer.on("style-layer-change",e=>{this._styleChanges.push({type:2,data:e}),this._styeChanged=!0,this.requestUpdate()}),this.layer.on("delete-style-layer",e=>{this._styleChanges.push({type:3,data:e}),this._styeChanged=!0,this.requestUpdate()}),this.layer.on("load-style",()=>this._loadStyle()),this.layer.on("spriteSource-change",e=>{this._spriteSourceChanged=!0,this._styleChanges.push({type:4,data:e});const t=this._styleRepository.layers;for(const i of t)switch(i.type){case 3:i.getLayoutProperty("icon-image")&&this._styleChanges.push({type:1,data:{layer:i.id,layout:i.layout}});break;case 2:i.getPaintProperty("line-pattern")&&this._styleChanges.push({type:0,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}});break;case 1:i.getLayoutProperty("fill-pattern")&&this._styleChanges.push({type:0,data:{layer:i.id,paint:i.paint,isDataDriven:i.isPainterDataDriven()}})}this.requestUpdate()})])}detach(){this._stop(),this.container.removeAllChildren(),this._vectorTileContainer=s(this._vectorTileContainer),this._tileHandler=s(this._tileHandler)}viewChange(){this.requestUpdate()}moveEnd(){this.requestUpdate()}supportsSpatialReference(e){return p(this.layer.tileInfo?.spatialReference,e)}canResume(){let e=super.canResume();const{currentStyleInfo:t}=this.layer;if(e&&t?.layerDefinition){const i=this.view.scale,{minScale:s,maxScale:r}=t.layerDefinition;t?.layerDefinition&&(s&&s<i&&(e=!1),r&&r>i&&(e=!1))}return e}isUpdating(){return this.fading}acquireTile(e){const t=this._createVectorTile(e);return this._updatingHandles.consumePromise(this._fetchQueue.push(t.key).then(e=>this._parseQueue.push({key:t.key,data:e})).then(e=>{t.once("attach",()=>this.requestUpdate()),t.setData(e),this.requestUpdate()}).catch(e=>{r(e)||i.getLogger(this).error(e)})),t}releaseTile(e){const t=e.key.id;this._fetchQueue.abort(t),this._parseQueue.abort(t),this.requestUpdate()}async doRefresh(){if(!this.attached)return;if(this.suspended)return this._tileManager.clear(),void this.requestUpdate();this._isTileHandlerReady=!1,this._pauseQueues(),this._clearQueues(),this._tileManager.clearCache(),this._resumeQueues();const e=this._vectorTileContainer.children,t=[];try{for(const i of e){const e=this._updatingHandles.addPromise(this._fetchQueue.push(i.key).then(e=>this._parseQueue.push({key:i.key,data:e})).then(e=>i.setData(e)).finally(()=>i.featureIndex=null));t.push(e)}await Promise.all(t)}catch(s){i.getLogger(this).error("error refreshing vector-tiles layer-view",s),this._resumeQueues(),this._isTileHandlerReady=!0}this._isTileHandlerReady=!0,this.requestUpdate()}_start(){if(this._stop(),this._tileManager=new T({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),!this.layer.currentStyleInfo)return;const e=new AbortController,t=this._tileHandler.start({signal:e.signal}).then(()=>{this._fetchQueue=new Q({tileInfoView:this._tileInfoView,process:(e,t)=>this._getTileData(e,t),concurrency:15,scheduler:this.scheduler,priority:P.MAPVIEW_FETCH_QUEUE}),this._parseQueue=new Q({tileInfoView:this._tileInfoView,process:(e,t)=>this._parseTileData(e,t),concurrency:8,scheduler:this.scheduler,priority:P.MAPVIEW_VECTOR_TILE_PARSING_QUEUE}),this.requestUpdate(),this._isTileHandlerReady=!0});this._tileHandler.spriteMosaic.then(e=>{this._vectorTileContainer.setStyleResources(e,this._tileHandler.glyphMosaic,this._styleRepository,this._tileInfoView),this.requestUpdate()}),this._tileHandlerAbortController=e,this._tileHandlerPromise=t}_stop(){if(!this._tileHandlerAbortController||!this._vectorTileContainer)return;const e=this._tileHandlerAbortController;e&&e.abort(),this._tileHandlerPromise=null,this._isTileHandlerReady=!1,this._fetchQueue=s(this._fetchQueue),this._parseQueue=s(this._parseQueue),this._tileManager=s(this._tileManager),this._vectorTileContainer.removeAllChildren()}async _getTileData(e,t){return this._tileHandler.fetchTileData(e,t)}async _parseTileData(e,t){return this._tileHandler.parseTileData(e,t)}async _applyStyleChanges(){this._isTileHandlerReady=!1,this._pauseQueues(),this._clearQueues(),this._tileManager.clearCache();const e=this._styleChanges;try{await this._tileHandler.updateStyle(e)}catch(o){i.getLogger(this).error("error applying vector-tiles style update",o.message),this._resumeQueues(),this._isTileHandlerReady=!0}const t=this._styleRepository,s=new Set,r=new Set;for(const i of e){if(3!==i.type&&2!==i.type)continue;const e=2===i.type?i.data.layer.id:i.data.layer,a=t.getLayerById(e);a&&(s.add(a.uid),3===a.type&&r.add(a.uid))}const a=this._vectorTileContainer.children,l=this._vectorTileContainer?.symbolFader?.symbolRepository;l&&r.size>0&&l.deleteStyleLayers(Array.from(r));const n=new Set;if(e.forEach(e=>{let i;switch(e.type){case 0:t.setPaintProperties(e.data.layer,e.data.paint),i=e.data.layer;break;case 1:t.setLayoutProperties(e.data.layer,e.data.layout),i=e.data.layer;break;case 3:return void t.deleteStyleLayer(e.data.layer);case 2:t.setStyleLayer(e.data.layer,e.data.index),i=e.data.layer.id;break;case 4:this._vectorTileContainer.setSpriteMosaic(this._tileHandler.setSpriteSource(e.data.spriteSource))}if(i){const e=t.getLayerById(i);e&&n.add(e.uid)}}),s.size>0){const e=Array.from(s);this._vectorTileContainer.deleteStyleLayers(e);for(const t of a)t.deleteLayerData(e)}if(this._resumeQueues(),n.size>0){const e=Array.from(n),t=[];for(const i of a){const s=this._updatingHandles.addPromise(this._fetchQueue.push(i.key).then(t=>this._parseQueue.push({key:i.key,data:t,styleLayerUIDs:e})).then(e=>i.setData(e)).finally(()=>i.featureIndex=null));t.push(s)}await Promise.all(t)}this._styleChanges=[],this._isTileHandlerReady=!0,this.requestUpdate()}async _loadStyle(){const{style:e}=this.layer.currentStyleInfo,i=t(e);this._isTileHandlerReady=!1,this._pauseQueues(),this._clearQueues(),this._styleRepository=new R(i),this._vectorTileContainer.destroy(),this._tileManager.clear(),this._tileHandlerAbortController.abort(),this._tileHandlerAbortController=new AbortController;const{signal:s}=this._tileHandlerAbortController;try{this._tileHandlerPromise=this._tileHandler.setStyle(this._styleRepository,i,this.layer.tileInfo.lods.length-1),await this._tileHandlerPromise}catch(n){if(!r(n))throw n}if(s.aborted)return this._resumeQueues(),this._isTileHandlerReady=!0,this._styeChanged=!1,this._spriteSourceChanged=!1,void this.requestUpdate();const a=await this._tileHandler.spriteMosaic,l=this._vectorTileContainer;this._tileInfoView=new I(this.layer.tileInfo,this.layer.fullExtent),l.setStyleResources(a,this._tileHandler.glyphMosaic,this._styleRepository,this._tileInfoView),this._tileManager=new T({acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),tileInfoView:this._tileInfoView},this._vectorTileContainer),this._resumeQueues(),this._isTileHandlerReady=!0,this.requestUpdate(),this._styeChanged=!1,this._spriteSourceChanged=!1}_createVectorTile(e){const t=this._tileInfoView.getTileBounds(d(),e),i=this._tileInfoView.getTileResolution(e.level);return new C(e,i,t[0],t[3],512,512,this._styleRepository)}async _queryTile(e,t,i,s,r,a){if(0===r.layerData.size)return;const l=this._ensureTileIndex(r),[n,o,h,y]=this._tileInfoView.getTileBounds(d(),r.key,!0),u=f*((t.x-n)/(h-n)),c=f*(1-(t.y-o)/(y-o)),p=this.view.featuresTilingScheme.tileInfo.scaleToZoom(this.view.state.scale)-r.key.level,m=p>0?2**p:1,T=i/m*(f/g),C=await l.queryAttributes(u,c,T,s,a,m);for(const d of C)d.graphic.geometry=this._tileToMapPoint(d.tilePoint,r.transforms.tileUnitsToPixels),e.push({type:"graphic",layer:this.layer,graphic:d.graphic,mapPoint:t.clone()});e.sort((e,t)=>(_(t.graphic.origin)?t.graphic.origin.layerIndex:0)-(_(e.graphic.origin)?e.graphic.origin.layerIndex:0))}_tileToMapPoint(e,t){if(!e)return null;const i=e[0]*t[0]+e[1]*t[3]+t[6],s=e[0]*t[1]+e[1]*t[4]+t[7],r=this.view.state,a=[0,0];return r.toMap(a,[i,s]),new c({x:a[0],y:a[1],spatialReference:r.spatialReference})}_ensureTileIndex(e){let t=e.featureIndex;return t||(t=w.create(e.key,e.layerData,this._styleRepository,this._tileHandler,this.layer),e.featureIndex=t),t}_pauseQueues(){this._fetchQueue.pause(),this._parseQueue.pause()}_resumeQueues(){this._fetchQueue.resume(),this._parseQueue.resume()}_clearQueues(){this._fetchQueue.clear(),this._parseQueue.clear()}};function D(e){if(null==e)return 0;switch(e.type){case"partial":return Object.keys(e.diff).length;case"complete":return Math.max(Object.keys(e.oldValue).length,Object.keys(e.newValue).length);case"collection":return Object.keys(e.added).length+Object.keys(e.changed).length+Object.keys(e.removed).length}}e([o()],V.prototype,"_isTileHandlerReady",void 0),V=e([h("esri.views.2d.layers.VectorTileLayerView2D")],V);const j=V;export{j as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import has from"../../../../../core/has.js";import{estimateNumberArrayMemory as t}from"../../../../../core/memoryEstimations.js";import{DateOnly as r}from"../../../../../core/sql/DateOnly.js";import{TimeOnly as s}from"../../../../../core/sql/TimeOnly.js";import{GeometryCursor as i}from"../../../../../geometry/GeometryCursor.js";import{fromRectValues as o}from"../../../../../geometry/support/aaBoundingBox.js";import{fromJSON as a}from"../../../../../geometry/support/jsonUtils.js";import{getLabelPoint as n}from"../../../../../geometry/support/labelPoint.js";import{quantizeX as d,quantizeY as u}from"../../../../../geometry/support/quantizationUtils.js";import{zScale as c}from"../../../../../geometry/support/zscale.js";import{getCentroidOptimizedGeometry as h}from"../../../../../layers/graphics/centroid.js";import{convertToGeometry as l,generalizeOptimizedGeometry as m,quantizeOptimizedGeometry as y,unquantizeOptimizedGeometryInPlace as f}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as p}from"../../../../../layers/graphics/OptimizedFeature.js";import g from"../../../../../layers/graphics/OptimizedGeometry.js";import{system as _,unknown as b}from"../../../../../time/constants.js";import{FeatureSetCache as x}from"./FeatureSetCache.js";const T=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],D=T[0],F=T[1],I=T[2],S=T[3],A=has("featurelayer-simplify-payload-size-factors")??[1,2,4],j=A[0],B=A[1],C=A[2],G=has("featurelayer-simplify-mobile-factor")??2,M=has("esri-mobile"),v=4294967295;function O(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class w{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._overrides=null,this._postQueryFilteredIds=new Set,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._deleted=new Set,this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}destroy(){}[Symbol.dispose](){this.destroy()}getAreaSimplificationThreshold(e,t){let r=1;const s=M?G:1;t>4e6?r=C*s:t>1e6?r=B*s:t>5e5?r=j*s:t>1e5&&(r=s);let i=0;return e>4e3?i=S*r:e>2e3?i=I*r:e>100?i=F:e>15&&(i=D),i}getBounds(e){O(this._boundsBuffer,4*this.getIndex()+4,0);const t=this.getBoundsXMin();if(t===v||!isFinite(t))return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(t?.isPoint&&0===t.coords[0]&&0===t.coords[1])return o(e,0,0,0,0),!0;if(!t)return this.setBoundsXMin(v),!1;let r=1/0,s=1/0,i=-1/0,a=-1/0;return t.forEachVertex((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),i=Math.max(i,e),a=Math.max(a,t)}),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(i),this.setBoundsYMax(a),o(e,r,s,i,a),!0}const r=this.getBoundsXMin(),s=this.getBoundsYMin(),i=this.getBoundsXMax(),a=this.getBoundsYMax();return o(e,r,s,i,a),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}registerOverrides(e){this._overrides=e}withoutOverrides(){const e=this.copy();return e._overrides=null,e}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace();return new p(e,t,r,this.getObjectId(),this.getDisplayId())}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return l(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createDeltaQuantizedGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryForDisplayTransformed(e){let t=this.readGeometryForDisplay();if(t&&"esriGeometryPolyline"===this.metadata.geometryType&&(t=m(t,this.metadata.geometryType,e.scale[0])),t&&(t=y(t,this.metadata.geometryType,e,t.hasZ,t.hasM,!0)),!t){const t=this.readCentroidForDisplay();if(!t)return null;const r=d(e,t.coords[0]),s=u(e,t.coords[1]);return this._createDeltaQuantizedExtrudedGeometry(r,s).deltaDecode()}return t}_transformToWorldSpace(e){if(!e)return null;e=e.clone();const t=this.getInTransform();t&&f(e,t);const r=c(this.metadata.spatialReference,this.metadata.outSpatialReference);if(e.hasZ&&1!==r){const{stride:t,coords:s}=e;for(let e=2;e<s.length;e+=t)s[e]*=r}return e}readGeometryWorldSpace(){let e=this._readGeometry();return e||(e=this._createDeltaQuantizedGeometryFromServerCentroid()),this._transformToWorldSpace(e)}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();return this._transformToWorldSpace(t)}setCache(e){let t=this._caches.get(e);null==t&&(t=new x(this.getSize()),this._caches.set(e,t)),this._activeCache=t}setCachedValue(e){this._activeCache.set(this.getIndex(),e)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}delete(){this._deleted.add(this.getObjectId())}getByReferenceVertexCount(){return null}get underlyingMemory(){let e=0;e+=t(this._boundsBuffer);for(const t of this._caches.values())e+=t.usedMemory;return e}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);if("esriGeometryPoint"===this.geometryType||!t)return t;const r=this.getInTransform();if(!t||!r)return t;const s=r.scale[2]??1,i=r.translate[2]??0,o=r.scale[3]??1,a=r.translate[3]??0,{hasZ:n,hasM:d,stride:u,size:c,coords:h}=t,l=n&&(1!==s||0!==i),m=d&&(1!==o||0!==a);if(l||m){const e=2,t=n?3:2;for(let r=0,n=u*c;r<n;r+=u)l&&(h[r+e]=s*h[r+e]+i),m&&(h[r+t]=o*h[r+t]+a)}return t.deltaDecode()}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)||this._joined.some(t=>t.hasField(e))}geometry(){const e=this.readGeometryWorldSpace(),t=l(e,this.geometryType,this.hasZ,this.hasM),r=a(t);if(r){if(!this.metadata.outSpatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.outSpatialReference}return r}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSAndZoneToArcadeDate(r,this.contextTimeZone??_):r}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===b}field(t){let i=this.fields.get(t);if(i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const o of this._joined)if(o.setIndex(this.getIndex()),i=o.fields.get(t),i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(o._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(o._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(o._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,o._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map(e=>e.name)}isEmpty(){return this.fields.fields.length<=0&&null==this.geometry()}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}applyPostQueryFilter(e){if(this._postQueryFilteredIds.clear(),!e)return;const t=this.getCursor();for(;t.next();){e.check(t,{currentUser:null})||this._postQueryFilteredIds.add(t.getObjectId())}}_getExists(){if(this._overrides){const e=this.getObjectId();return!this._overrides.hasOverride(e)}const e=this.getObjectId();return this._deleted.has(e)||!this._postQueryFilteredIds.has(e)}_computeDisplayCentroid(e){if(null==this.getInTransform())return h(e);const t=i.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=n(t);return r?isNaN(r[0])||isNaN(r[1])?h(e):(r[1]*=-1,new g([],r)):null}copyInto(e){e._joined=this._joined,e._overrides=this._overrides,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer,e._activeCache=this._activeCache,e._caches=this._caches,e._contextTimeZone=this._contextTimeZone,e._postQueryFilteredIds=this._postQueryFilteredIds,e._deleted=this._deleted}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return l(e,this.geometryType,!1,!1)}_createDeltaQuantizedGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createDeltaQuantizedExtrudedGeometry(t,r)}_createDeltaQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createDeltaQuantizedExtrudedLine(e,t):this._createDeltaQuantizedExtrudedQuad(e,t)}_createDeltaQuantizedExtrudedQuad(e,t){return new g([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createDeltaQuantizedExtrudedLine(e,t){return new g([2],[e-1,t+1,1,-1])}}export{w as FeatureSetReader};
2
+ import{ArcadeDate as e}from"../../../../../arcade/ArcadeDate.js";import has from"../../../../../core/has.js";import{estimateNumberArrayMemory as t}from"../../../../../core/memoryEstimations.js";import{DateOnly as r}from"../../../../../core/sql/DateOnly.js";import{TimeOnly as s}from"../../../../../core/sql/TimeOnly.js";import{GeometryCursor as i}from"../../../../../geometry/GeometryCursor.js";import{fromRectValues as o}from"../../../../../geometry/support/aaBoundingBox.js";import{fromJSON as a}from"../../../../../geometry/support/jsonUtils.js";import{getLabelPoint as n}from"../../../../../geometry/support/labelPoint.js";import{quantizeX as d,quantizeY as u}from"../../../../../geometry/support/quantizationUtils.js";import{zScale as c}from"../../../../../geometry/support/zscale.js";import{getCentroidOptimizedGeometry as h}from"../../../../../layers/graphics/centroid.js";import{convertToGeometry as l,generalizeOptimizedGeometry as m,quantizeOptimizedGeometry as y,unquantizeOptimizedGeometryInPlace as f}from"../../../../../layers/graphics/featureConversionUtils.js";import{OptimizedFeature as p}from"../../../../../layers/graphics/OptimizedFeature.js";import g from"../../../../../layers/graphics/OptimizedGeometry.js";import{system as _,unknown as b}from"../../../../../time/constants.js";import{FeatureSetCache as x}from"./FeatureSetCache.js";const D=has("featurelayer-simplify-thresholds")??[.5,.5,.5,.5],T=D[0],F=D[1],I=D[2],S=D[3],A=has("featurelayer-simplify-payload-size-factors")??[1,2,4],j=A[0],B=A[1],C=A[2],G=has("featurelayer-simplify-mobile-factor")??2,M=has("esri-mobile"),v=4294967295;function O(e,t,r){if(!(e.length>t))for(;e.length<=t;)e.push(r)}class w{constructor(e){this.metadata=e,this.type="FeatureSetReader",this._overrides=null,this._postQueryFilteredIds=new Set,this._joined=[],this._objectIdToIndex=null,this._boundsBuffer=[],this._deleted=new Set,this._caches=new Map,this.arcadeDeclaredClass="esri.arcade.Feature",this._contextTimeZone=null}destroy(){}[Symbol.dispose](){this.destroy()}getAreaSimplificationThreshold(e,t){let r=1;const s=M?G:1;t>4e6?r=C*s:t>1e6?r=B*s:t>5e5?r=j*s:t>1e5&&(r=s);let i=0;return e>4e3?i=S*r:e>2e3?i=I*r:e>100?i=F:e>15&&(i=T),i}getBounds(e){O(this._boundsBuffer,4*this.getIndex()+4,0);const t=this.getBoundsXMin();if(t===v||!isFinite(t))return!1;if(0===this.getBoundsXMin()){const t=this.readGeometryWorldSpace();if(t?.isPoint&&0===t.coords[0]&&0===t.coords[1])return o(e,0,0,0,0),!0;if(!t)return this.setBoundsXMin(v),!1;let r=1/0,s=1/0,i=-1/0,a=-1/0;return t.forEachVertex((e,t)=>{r=Math.min(r,e),s=Math.min(s,t),i=Math.max(i,e),a=Math.max(a,t)}),this.setBoundsXMin(r),this.setBoundsYMin(s),this.setBoundsXMax(i),this.setBoundsYMax(a),o(e,r,s,i,a),!0}const r=this.getBoundsXMin(),s=this.getBoundsYMin(),i=this.getBoundsXMax(),a=this.getBoundsYMax();return o(e,r,s,i,a),!0}getBoundsXMin(){return this._boundsBuffer[4*this.getIndex()]}setBoundsXMin(e){this._boundsBuffer[4*this.getIndex()]=e}getBoundsYMin(){return this._boundsBuffer[4*this.getIndex()+1]}setBoundsYMin(e){this._boundsBuffer[4*this.getIndex()+1]=e}getBoundsXMax(){return this._boundsBuffer[4*this.getIndex()+2]}setBoundsXMax(e){this._boundsBuffer[4*this.getIndex()+2]=e}getBoundsYMax(){return this._boundsBuffer[4*this.getIndex()+3]}setBoundsYMax(e){this._boundsBuffer[4*this.getIndex()+3]=e}readAttributeAsTimestamp(e){const t=this.readAttribute(e);return"string"==typeof t?new Date(t).getTime():"number"==typeof t||null==t?t:null}readAttribute(e,t=!1){const r=this._readAttribute(e,t);if(void 0!==r)return r;for(const s of this._joined){s.setIndex(this.getIndex());const r=s._readAttribute(e,t);if(void 0!==r)return r}}readAttributes(){const e=this._readAttributes();for(const t of this._joined){t.setIndex(this.getIndex());const r=t._readAttributes();for(const t of Object.keys(r))e[t]=r[t]}return e}joinAttributes(e){this._joined.push(e)}registerOverrides(e){this._overrides=e}withoutOverrides(){const e=this.copy();return e._overrides=null,e}readOptimizedFeatureWorldSpace(){const e=this.readGeometryWorldSpace(),t=this.readAttributes(),r=this.readCentroidWorldSpace();return new p(e,t,r,this.getObjectId(),this.getDisplayId())}readLegacyFeatureForDisplay(){const e=this.readCentroidForDisplay();return{attributes:this.readAttributes(),geometry:this.readLegacyGeometryForDisplay(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyFeatureWorldSpace(){const e=this.readCentroidWorldSpace();return{attributes:this.readAttributes(),geometry:this._readLegacyGeometryWorldSpace(),centroid:(e&&{x:e.coords[0],y:e.coords[1]})??null}}readLegacyGeometryForDisplay(){const e=this.readGeometryForDisplay();return l(e,this.geometryType,!1,!1)}readXForDisplay(){return this._readX()}readYForDisplay(){return this._readY()}readXWorldSpace(){const e=this._readX(),t=this.getInTransform();return null==t?e:e*t.scale[0]+t.translate[0]}readYWorldSpace(){const e=this._readY(),t=this.getInTransform();return null==t?e:t.translate[1]-e*t.scale[1]}readGeometryForDisplay(){const e=this._readGeometryDeltaDecoded(!0);if(!e){const e=this._createDeltaQuantizedGeometryFromServerCentroid();return e?e.deltaDecode():null}return e}readGeometryForDisplayTransformed(e){let t=this.readGeometryForDisplay();if(t&&"esriGeometryPolyline"===this.metadata.geometryType&&(t=m(t,this.metadata.geometryType,e.scale[0])),t&&(t=y(t,this.metadata.geometryType,e,t.hasZ,t.hasM,!0)),!t){const t=this.readCentroidForDisplay();if(!t)return null;const r=d(e,t.coords[0]),s=u(e,t.coords[1]);return this._createDeltaQuantizedExtrudedGeometry(r,s).deltaDecode()}return t}_transformToWorldSpace(e){if(!e)return null;e=e.clone();const t=this.getInTransform();t&&f(e,t);const r=c(this.metadata.spatialReference,this.metadata.outSpatialReference);if(e.hasZ&&1!==r){const{stride:t,coords:s}=e;for(let e=2;e<s.length;e+=t)s[e]*=r}return e}readGeometryWorldSpace(){let e=this._readGeometry();return e||(e=this._createDeltaQuantizedGeometryFromServerCentroid()),this._transformToWorldSpace(e)}readCentroidForDisplay(){const e=this.readGeometryForDisplay();return e?this._computeDisplayCentroid(e):this._readServerCentroid()}readCentroidWorldSpace(){const e=this.readGeometryForDisplay(),t=e?this._computeDisplayCentroid(e):this._readServerCentroid();return this._transformToWorldSpace(t)}setCache(e){let t=this._caches.get(e);null==t&&(t=new x(this.getSize()),this._caches.set(e,t)),this._activeCache=t}setCachedValue(e){this._activeCache.set(this.getIndex(),e)}hasCachedValue(){return this._activeCache.has(this.getIndex())}getCachedValue(){return this._activeCache.get(this.getIndex())}delete(){this._deleted.add(this.getObjectId())}getByReferenceVertexCount(){return null}get underlyingMemory(){let e=0;e+=t(this._boundsBuffer);for(const t of this._caches.values())e+=t.usedMemory;return e}_readGeometryDeltaDecoded(e){const t=this._readGeometry(e);if("esriGeometryPoint"===this.geometryType||!t)return t;const r=this.getInTransform();if(!t||!r)return t;const s=r.scale[2]??1,i=r.translate[2]??0,o=r.scale[3]??1,a=r.translate[3]??0,{hasZ:n,hasM:d,stride:u,size:c,coords:h}=t,l=n&&(1!==s||0!==i),m=d&&(1!==o||0!==a);if(l||m){const e=2,t=n?3:2;for(let r=0,n=u*c;r<n;r+=u)l&&(h[r+e]=s*h[r+e]+i),m&&(h[r+t]=o*h[r+t]+a)}return this.supportsDeltaEncoding()?t.deltaDecode():t}get contextTimeZone(){return this._contextTimeZone}set contextTimeZone(e){this._contextTimeZone=e}readArcadeFeature(){return this}hasField(e){return this.fields.has(e)||this._joined.some(t=>t.hasField(e))}geometry(){const e=this.readGeometryWorldSpace(),t=l(e,this.geometryType,this.hasZ,this.hasM),r=a(t);if(r){if(!this.metadata.outSpatialReference)throw new Error("InternalError: Expected spatial reference to be defined");r.spatialReference=this.metadata.outSpatialReference}return r}autocastArcadeDate(t,r){return r&&r instanceof Date?this.isUnknownDateTimeField(t)?e.unknownDateJSToArcadeDate(r):e.dateJSAndZoneToArcadeDate(r,this.contextTimeZone??_):r}isUnknownDateTimeField(e){return this.metadata.fieldsIndex.getTimeZone(e)===b}field(t){let i=this.fields.get(t);if(i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(this.readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(this.readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(this.readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,this.readAttribute(t,!0));default:return this.readAttribute(t,!1)}for(const o of this._joined)if(o.setIndex(this.getIndex()),i=o.fields.get(t),i)switch(i.type){case"date-only":case"esriFieldTypeDateOnly":return r.fromReader(o._readAttribute(t,!1));case"time-only":case"esriFieldTypeTimeOnly":return s.fromReader(o._readAttribute(t,!1));case"esriFieldTypeTimestampOffset":case"timestamp-offset":return e.fromReaderAsTimeStampOffset(o._readAttribute(t,!1));case"date":case"esriFieldTypeDate":return this.autocastArcadeDate(t,o._readAttribute(t,!0));default:return this.readAttribute(t,!1)}throw new Error(`Field ${t} does not exist`)}setField(e,t){throw new Error("Unable to update feature attribute values, feature is readonly")}keys(){return this.fields.fields.map(e=>e.name)}isEmpty(){return this.fields.fields.length<=0&&null==this.geometry()}castToText(e=!1){if(!e)return JSON.stringify(this.readLegacyFeatureForDisplay());const t=this.readLegacyFeatureForDisplay();if(!t)return JSON.stringify(null);const r={geometry:t.geometry,attributes:{...t.attributes}};for(const s in r.attributes){const e=r.attributes[s];e instanceof Date&&(r.attributes[s]=e.getTime())}return JSON.stringify(r)}gdbVersion(){return null}fullSchema(){return this.metadata.arcadeSchema}castAsJson(e=null){return{attributes:this._readAttributes(),geometry:!0===e?.keepGeometryType?this.geometry():this.geometry()?.toJSON()??null}}castAsJsonAsync(e=null,t=null){return Promise.resolve(this.castAsJson(t))}applyPostQueryFilter(e){if(this._postQueryFilteredIds.clear(),!e)return;const t=this.getCursor();for(;t.next();){e.check(t,{currentUser:null})||this._postQueryFilteredIds.add(t.getObjectId())}}_getExists(){if(this._overrides){const e=this.getObjectId();return!this._overrides.hasOverride(e)}const e=this.getObjectId();return this._deleted.has(e)||!this._postQueryFilteredIds.has(e)}_computeDisplayCentroid(e){if(null==this.getInTransform())return h(e);const t=i.fromOptimized(e,this.geometryType);t.yFactor*=-1;const r=n(t);return r?isNaN(r[0])||isNaN(r[1])?h(e):(r[1]*=-1,new g([],r)):null}copyInto(e){e._joined=this._joined,e._overrides=this._overrides,e._objectIdToIndex=this._objectIdToIndex,e._boundsBuffer=this._boundsBuffer,e._activeCache=this._activeCache,e._caches=this._caches,e._contextTimeZone=this._contextTimeZone,e._postQueryFilteredIds=this._postQueryFilteredIds,e._deleted=this._deleted}supportsDeltaEncoding(){return!0}_readLegacyGeometryWorldSpace(){const e=this.readGeometryWorldSpace();return l(e,this.geometryType,!1,!1)}_createDeltaQuantizedGeometryFromServerCentroid(){const e=this._readServerCentroid();if(!e)return null;const[t,r]=e.coords;return this._createDeltaQuantizedExtrudedGeometry(t,r)}_createDeltaQuantizedExtrudedGeometry(e,t){return"esriGeometryPolyline"===this.geometryType?this._createDeltaQuantizedExtrudedLine(e,t):this._createDeltaQuantizedExtrudedQuad(e,t)}_createDeltaQuantizedExtrudedQuad(e,t){return new g([5],[e-1,t,1,-1,1,1,-1,1,-1,-1])}_createDeltaQuantizedExtrudedLine(e,t){return new g([2],[e-1,t+1,1,-1])}}export{w as FeatureSetReader};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import"../../../../../core/has.js";import{baseObjectMemory as e}from"../../../../../core/memoryEstimations.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{getParquetObjectId as r}from"../../../../../layers/graphics/sources/support/parquetIdUtils.js";import{QuantizedGeometryBuffer as s}from"../../../../../chunks/bundle2.js";import{FeatureSetReader as n}from"./FeatureSetReader.js";let i;const d=new TextDecoder;class o extends n{constructor(t,r,s,n,i,d=new Uint32Array(s.size())){super(t),this._indexMap=r,this._inner=s,this._fileId=n,this._transform=i,this._displayIds=d,this._index=-1,this.usedMemory=e,this._size=this._inner.size();t.featureIdInfo.type}destroy(){super.destroy(),this._inner.free()}get fields(){return this.metadata.fieldsIndex}get geometryType(){return this.metadata.geometryType}get hasFeatures(){return!0}get hasNext(){throw new Error("Method not implemented.")}get exceededTransferLimit(){return!1}get hasZ(){return!1}get hasM(){return!1}async updateFields(e,t,r,s){const n=this._inner.rowGroup(),i=new Uint32Array(this._inner.readIdsUnsafe()),d=await e.createPatch(t,n,i,r,s);this._inner.insertPatchBytes(new Uint8Array(d))}getInTransform(){return this._transform}getSize(){return this._size}getCursor(){return this.copy()}getAttributeHash(){let e="";for(const t of this.fields.fields)e+=this._readAttribute(t.name,!1)+".";return e}getObjectId(){return r(this._fileId,this._inner.rowId(this._index))}getDisplayId(){return this._displayIds[this._index]}setDisplayId(e){this._displayIds[this._index]=e}setIndex(e){this._index=e}getBoundsXMin(){return this._inner.boundsXMin(this._index)}getBoundsYMin(){return this._inner.boundsYMin(this._index)}getBoundsXMax(){return this._inner.boundsXMax(this._index)}getBoundsYMax(){return this._inner.boundsYMax(this._index)}setBoundsXMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsXMax(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMax(e){throw new Error("InternalError: Setting bounds is unsupported")}getIndex(){return this._index}next(){for(;++this._index<this._size&&!this._getExists(););return this._index<this._size}readGeometryArea(){return this.readGeometryForDisplay()?.area()??0}copy(){const e=new o(this.metadata,this._indexMap,this._inner,this._fileId,this._transform,this._displayIds);return this.copyInto(e),e}copyInto(e){super.copyInto(e),e._index=this._index}readGeometryForDisplayTransformed(e){const[r,n]=e.translate,[d,o]=e.scale;i||(i=s.new());return this._inner.transformGeometry(i,r,n,d,o,this._index)?new t(i.readLengthsUnsafe(),i.readCoordsUnsafe(),this.hasZ,this.hasM):null}_readGeometry(e){const r=this._inner.readCoordsUnsafe(this._index),s=this._inner.readLengthsUnsafe(this._index);return r&&s?new t(s,r,this.hasZ,this.hasM):null}_readX(){return this._inner.readX(this._index)}_readY(){return this._inner.readY(this._index)}_readServerCentroid(){return null}_readAttribute(e,t){const r=this.fields.get(e);if(!r)return;const s=this._indexMap[r.name];if(null==s)return this.getObjectId();const n=this._inner.readAttribute(this._index,s);if(null==n)return n;if("esriFieldTypeString"===r.type||"esriFieldTypeDateOnly"===r.type||"esriFieldTypeTimeOnly"===r.type||"esriFieldTypeTimestampOffset"===r.type){const e=this._inner.readAttribute(this._index,s);return d.decode(e)}const i=this.fields.isDateField(r.name);return t?null==n?n:i?new Date(n):n:n}_readAttributes(){const e={};for(const t of this.metadata.fieldsIndex.fields){if(null==this._indexMap[t.name])continue;const r=this._readAttribute(t.name,!1);void 0!==r&&(e[t.name]=r)}return e.__OBJECTID=this.getObjectId(),e}}export{o as FeatureSetReaderParquet};
2
+ import"../../../../../core/has.js";import{baseObjectMemory as e}from"../../../../../core/memoryEstimations.js";import t from"../../../../../layers/graphics/OptimizedGeometry.js";import{getParquetObjectId as r}from"../../../../../layers/graphics/sources/support/parquetIdUtils.js";import{QuantizedGeometryBuffer as s}from"../../../../../chunks/bundle2.js";import{FeatureSetReader as n}from"./FeatureSetReader.js";let i;const d=new TextDecoder;class o extends n{constructor(t,r,s,n,i,d=new Uint32Array(s.size())){super(t),this._indexMap=r,this._inner=s,this._fileId=n,this._transform=i,this._displayIds=d,this._index=-1,this.usedMemory=e,this._size=this._inner.size();t.featureIdInfo.type}destroy(){super.destroy(),this._inner.free()}get fields(){return this.metadata.fieldsIndex}get geometryType(){return this.metadata.geometryType}get hasFeatures(){return!0}get hasNext(){throw new Error("Method not implemented.")}get exceededTransferLimit(){return!1}get hasZ(){return!1}get hasM(){return!1}async updateFields(e,t,r,s){const n=this._inner.rowGroup(),i=new Uint32Array(this._inner.readIdsUnsafe()),d=await e.createPatch(t,n,i,r,s);this._inner.insertPatchBytes(new Uint8Array(d))}getInTransform(){return this._transform}getSize(){return this._size}getCursor(){return this.copy()}getAttributeHash(){let e="";for(const t of this.fields.fields)e+=this._readAttribute(t.name,!1)+".";return e}getObjectId(){return r(this._fileId,this._inner.rowId(this._index))}getDisplayId(){return this._displayIds[this._index]}setDisplayId(e){this._displayIds[this._index]=e}setIndex(e){this._index=e}getBoundsXMin(){return this._inner.boundsXMin(this._index)}getBoundsYMin(){return this._inner.boundsYMin(this._index)}getBoundsXMax(){return this._inner.boundsXMax(this._index)}getBoundsYMax(){return this._inner.boundsYMax(this._index)}setBoundsXMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMin(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsXMax(e){throw new Error("InternalError: Setting bounds is unsupported")}setBoundsYMax(e){throw new Error("InternalError: Setting bounds is unsupported")}getIndex(){return this._index}next(){for(;++this._index<this._size&&!this._getExists(););return this._index<this._size}readGeometryArea(){return this.readGeometryForDisplay()?.area()??0}copy(){const e=new o(this.metadata,this._indexMap,this._inner,this._fileId,this._transform,this._displayIds);return this.copyInto(e),e}copyInto(e){super.copyInto(e),e._index=this._index}readGeometryForDisplayTransformed(e){const[r,n]=e.translate,[d,o]=e.scale;i||(i=s.new());return this._inner.transformGeometry(i,r,n,d,o,this._index)?new t(i.readLengthsUnsafe(),i.readCoordsUnsafe(),this.hasZ,this.hasM):null}_readGeometry(e){const r=this._inner.readCoordsUnsafe(this._index),s=this._inner.readLengthsUnsafe(this._index);return r&&s?new t(s,r,this.hasZ,this.hasM):null}_readX(){return this._inner.readX(this._index)}_readY(){return this._inner.readY(this._index)}_readServerCentroid(){return null}supportsDeltaEncoding(){return!1}_readAttribute(e,t){const r=this.fields.get(e);if(!r)return;const s=this._indexMap[r.name];if(null==s)return this.getObjectId();const n=this._inner.readAttribute(this._index,s);if(null==n)return n;if("esriFieldTypeString"===r.type||"esriFieldTypeDateOnly"===r.type||"esriFieldTypeTimeOnly"===r.type||"esriFieldTypeTimestampOffset"===r.type){const e=this._inner.readAttribute(this._index,s);return d.decode(e)}const i=this.fields.isDateField(r.name);return t?null==n?n:i?new Date(n):n:n}_readAttributes(){const e={};for(const t of this.metadata.fieldsIndex.fields){if(null==this._indexMap[t.name])continue;const r=this._readAttribute(t.name,!1);void 0!==r&&(e[t.name]=r)}return e.__OBJECTID=this.getObjectId(),e}}export{o as FeatureSetReaderParquet};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../core/Collection.js";import"../../../../core/has.js";import{mapCollection as i}from"../../../../core/mapCollectionUtils.js";import{destroyMaybe as o,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as l,initial as r}from"../../../../core/reactiveUtils.js";import{property as a,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{ViewshedInteractionVisuals as c}from"./ViewshedInteractionVisuals.js";import{ViewshedObserverManipulatedObject3D as d}from"./ViewshedObserverManipulatedObject3D.js";import{ViewshedSnappingController as u}from"./ViewshedSnappingController.js";import{ViewshedSubTool as h}from"./ViewshedSubTool.js";import{findSubTool as b}from"./viewshedSubToolUtils.js";import{connectTooltipToManipulatedObject as v}from"../../interactive/editingTools/tooltipUtils3D.js";import{InteractiveToolBase as T}from"../../../interactive/InteractiveToolBase.js";import{sketchKeys as _}from"../../../interactive/keybindings.js";import g from"../../../interactive/sketch/SketchOptions.js";import{enterInputModeIfAvailable as m,makeTooltip as w}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as V}from"../../../interactive/tooltip/infos/MovePointTooltipInfo.js";let y=class extends T{constructor(e){super(e),this.subToolHandles=new t,this.removeIncompleteOnCancel=!1,this.automaticManipulatorSelection=!1,this.creating=!1,this.isPlacingTarget=!1,this._selectedManipulator=null,this._observerTooltipSketchOptions=new g({tooltips:{enabled:!0}}),this._observerTooltipConnectionHandle=null,this._observerTooltipObject=null}initialize(){const{view:e}=this;this._interactionVisuals=new c({view:e}),this._snappingController=new u({view:e}),this._initializeObserverTooltip(e);const t=this.analysisViewData.viewshedComputedDataHandles;this.subToolHandles=i(()=>t,({viewshedComputedData:e})=>{const t=new h({analysis:this.analysis,analysisViewData:this.analysisViewData,parentTool:this,view:this.view,viewshedComputedData:e});return{subTool:t,remove:()=>{this.selectedViewshed===e.viewshed&&(this.selectedViewshed=null),t.destroy()}}}),this.addHandles([n(()=>this.firstGrabbedManipulator,e=>{if(null!=e){const t=this._findSubTool(e)?.viewshed;this.selectedViewshed=t,this._selectManipulator(e)}else this._selectedSubTool?.onManipulatorSelectionChanged()},l),n(()=>{const e=this.selectedViewshedComputedData;return null==e?null:{subTool:this._selectedSubTool,observer:e.elevationAlignedObserverRenderSpace,target:e.elevationAlignedTargetRenderSpace}},e=>{if(null==e)return;const{subTool:t,observer:i,target:o}=e;t?.moveInteractionState.dragging?this._updateInteractionVisualsLocation(i,!0):t?.scaleOrientInteractionState.dragging&&this._updateInteractionVisualsLocation(o,!1)},r),n(()=>this.analysisViewData.visible,()=>this.updateInteractionVisualsVisibility(),r),n(()=>this.selectedViewshed,e=>{const t=this._selectedManipulator,i=this._selectedSubTool;this._connectObserverTooltip(i),null==e?this._selectManipulator(null):null!=t&&i.hasManipulator(t)||this._selectManipulator(i.discManipulator)},r)])}destroy(){this._selectManipulator(null),this._disconnectObserverTooltip(),o(this.subToolHandles),o(this._interactionVisuals),o(this._snappingController),o(this._observerTooltip)}get updating(){return this.subToolHandles.some(({subTool:e})=>e.updating)||this._snappingController?.updating}get grabbing(){return this.subToolHandles.some(({subTool:e})=>e.grabbing)}get cursor(){return null}get selectedViewshed(){return this.analysisViewData.selectedViewshed}set selectedViewshed(e){this.analysisViewData.selectedViewshed=e}get selectedViewshedComputedData(){return this._selectedSubTool?.viewshedComputedData}onManipulatorSelectionChanged(){this.subToolHandles.forEach(({subTool:e})=>e.onManipulatorSelectionChanged())}updateInteractionVisualsVisibility(e=!1){const t=this._selectedSubTool,i=this.selectedViewshedComputedData;if(null==t||null==i)return void this._interactionVisuals?.setVisibility(!1);const o=t.moveInteractionState,s=e?o.grabbing:o.dragging,n=t.scaleOrientInteractionState,l=e?n.grabbing:n.dragging;if(!(this.analysisViewData.visible&&(s||l)))return void this._interactionVisuals?.setVisibility(!1);const r=s?i.elevationAlignedObserverRenderSpace:i.elevationAlignedTargetRenderSpace;this._interactionVisuals?.update({location:r,laserlineVisible:!0,verticalLineVisible:s,intersectsWorldUp:s})}createObserverMoveSnappingPipeline(e,t,i){return this._snappingController.createObserverMoveSnappingPipeline(e,t,i)}onActivate(){this.updateInteractionVisualsVisibility()}onDeactivate(){this.updateInteractionVisualsVisibility()}onInputEvent(e){if(!this.destroyed&&!m(e,this._observerTooltip))switch(e.type){case"key-down":this._onKeyDown(e);break;case"hold":this.updateInteractionVisualsVisibility(!0)}}_updateInteractionVisualsLocation(e,t){this._interactionVisuals?.updateLocation(e,t)}_initializeObserverTooltip(e){const t=this._observerTooltipSketchOptions;this._observerTooltip=w(()=>({view:e,options:t.tooltips})),this._observerTooltipInfo=new V({sketchOptions:t,viewType:e.type})}_connectObserverTooltip(e){if(this._disconnectObserverTooltip(),null==e)return void this._observerTooltip.clear();const t=new d({view:this.view,subTool:e});this._observerTooltipObject=t,this._observerTooltipConnectionHandle=v(this._observerTooltip,t,()=>({sketchOptions:this._observerTooltipSketchOptions,activeTooltipInfo:this._observerTooltipInfo,callbacks:{onBeforeUpdate:()=>this.updateInteractionVisualsVisibility(),onMoveStart:()=>{},onMove:()=>{},onMoveStop:()=>{},onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}}}))}_disconnectObserverTooltip(){this._observerTooltipConnectionHandle=s(this._observerTooltipConnectionHandle),this._observerTooltipObject=o(this._observerTooltipObject)}_onKeyDown(e){_.cancel===e.key&&(this.grabbing||(this.selectedViewshed=null,e.stopPropagation()))}get _selectedSubTool(){return this._findSubTool(this.selectedViewshed)}_findSubTool(e){return b(this.subToolHandles,e)}_selectManipulator(e){const t=this._selectedManipulator;t!==e&&(this._selectedManipulator=e,null!=t&&(t.selected=!1),null!=e&&(e.selected=!0),this._findSubTool(t)?.onManipulatorSelectionChanged(),this._selectedSubTool?.onManipulatorSelectionChanged())}get test(){}};e([a({constructOnly:!0})],y.prototype,"analysis",void 0),e([a({constructOnly:!0})],y.prototype,"analysisViewData",void 0),e([a({constructOnly:!0})],y.prototype,"view",void 0),e([a()],y.prototype,"subToolHandles",void 0),e([a()],y.prototype,"removeIncompleteOnCancel",void 0),e([a()],y.prototype,"automaticManipulatorSelection",void 0),e([a()],y.prototype,"creating",void 0),e([a()],y.prototype,"isPlacingTarget",void 0),e([a()],y.prototype,"_selectedManipulator",void 0),e([a()],y.prototype,"_interactionVisuals",void 0),e([a()],y.prototype,"_snappingController",void 0),e([a()],y.prototype,"_observerTooltip",void 0),e([a()],y.prototype,"_observerTooltipInfo",void 0),e([a()],y.prototype,"updating",null),e([a()],y.prototype,"grabbing",null),e([a()],y.prototype,"cursor",null),e([a()],y.prototype,"selectedViewshed",null),e([a()],y.prototype,"selectedViewshedComputedData",null),e([a()],y.prototype,"_selectedSubTool",null),y=e([p("esri.views.3d.analysis.Viewshed.ViewshedEditTool")],y);export{y as ViewshedEditTool};
2
+ import{__decorate as e}from"tslib";import t from"../../../../core/Collection.js";import"../../../../core/has.js";import{mapCollection as i}from"../../../../core/mapCollectionUtils.js";import{destroyMaybe as o,removeMaybe as s}from"../../../../core/maybe.js";import{watch as n,sync as l,initial as r}from"../../../../core/reactiveUtils.js";import{property as a,subclass as p}from"../../../../core/accessorSupport/decorators.js";import{ViewshedInteractionVisuals as c}from"./ViewshedInteractionVisuals.js";import{ViewshedObserverManipulatedObject3D as d}from"./ViewshedObserverManipulatedObject3D.js";import{ViewshedSnappingController as u}from"./ViewshedSnappingController.js";import{ViewshedSubTool as h}from"./ViewshedSubTool.js";import{findSubTool as b}from"./viewshedSubToolUtils.js";import{connectTooltipToManipulatedObject as v}from"../../interactive/editingTools/tooltipUtils3D.js";import{InteractiveToolBase as _}from"../../../interactive/InteractiveToolBase.js";import{sketchKeys as T}from"../../../interactive/keybindings.js";import g from"../../../interactive/sketch/SketchOptions.js";import{enterInputModeIfAvailable as m,makeTooltip as w}from"../../../interactive/tooltip/tooltipCommonUtils.js";import{MovePointTooltipInfo as y}from"../../../interactive/tooltip/infos/MovePointTooltipInfo.js";let V=class extends _{constructor(e){super(e),this.subToolHandles=new t,this.removeIncompleteOnCancel=!1,this.automaticManipulatorSelection=!1,this.creating=!1,this.isPlacingTarget=!1,this._selectedManipulator=null,this._observerTooltipSketchOptions=new g({tooltips:{enabled:!0}}),this._observerTooltipConnectionHandle=null,this._observerTooltipObject=null}initialize(){const{view:e}=this;this._interactionVisuals=new c({view:e}),this._snappingController=new u({view:e}),this._initializeObserverTooltip(e);const t=this.analysisViewData.viewshedComputedDataHandles;this.subToolHandles=i(()=>t,({viewshedComputedData:e})=>{const t=new h({analysis:this.analysis,analysisViewData:this.analysisViewData,parentTool:this,view:this.view,viewshedComputedData:e});return{subTool:t,remove:()=>{this.selectedViewshed===e.viewshed&&(this.selectedViewshed=null),t.destroy()}}}),this.addHandles([n(()=>this.firstGrabbedManipulator,e=>{if(null!=e){const t=this._findSubTool(e)?.viewshed;this.selectedViewshed=t,this._selectManipulator(e)}else this._selectedSubTool?.onManipulatorSelectionChanged()},l),n(()=>{const e=this.selectedViewshedComputedData;return null==e?null:{subTool:this._selectedSubTool,observer:e.elevationAlignedObserverRenderSpace,target:e.elevationAlignedTargetRenderSpace}},e=>{if(null==e)return;const{subTool:t,observer:i,target:o}=e;t?.moveInteractionState.dragging?this._updateInteractionVisualsLocation(i,!0):t?.scaleOrientInteractionState.dragging&&this._updateInteractionVisualsLocation(o,!1)},r),n(()=>this.analysisViewData.visible,()=>this.updateInteractionVisualsVisibility(),r),n(()=>this.selectedViewshed,e=>{const t=this._selectedManipulator,i=this._selectedSubTool;this._connectObserverTooltip(i),null==e?this._selectManipulator(null):null!=t&&i.hasManipulator(t)||this._selectManipulator(i.discManipulator)},r)])}destroy(){this._selectManipulator(null),this._disconnectObserverTooltip(),o(this.subToolHandles),o(this._interactionVisuals),o(this._snappingController),o(this._observerTooltip)}get updating(){return this.subToolHandles.some(({subTool:e})=>e.updating)||this._snappingController?.updating}get grabbing(){return this.subToolHandles.some(({subTool:e})=>e.grabbing)}get cursor(){return null}get selectedViewshed(){return this.analysisViewData.selectedViewshed}set selectedViewshed(e){this.analysisViewData.selectedViewshed=e}get selectedViewshedComputedData(){return this._selectedSubTool?.viewshedComputedData}onManipulatorSelectionChanged(){this.subToolHandles.forEach(({subTool:e})=>e.onManipulatorSelectionChanged())}updateInteractionVisualsVisibility(e=!1){const t=this._selectedSubTool,i=this.selectedViewshedComputedData;if(null==t||null==i)return void this._interactionVisuals?.setVisibility(!1);const o=t.moveInteractionState,s=e?o.grabbing:o.dragging,n=t.scaleOrientInteractionState,l=e?n.grabbing:n.dragging;if(!(this.analysisViewData.visible&&(s||l)))return void this._interactionVisuals?.setVisibility(!1);const r=s?i.elevationAlignedObserverRenderSpace:i.elevationAlignedTargetRenderSpace;this._interactionVisuals?.update({location:r,laserlineVisible:!0,verticalLineVisible:s,intersectsWorldUp:s})}createObserverMoveSnappingPipeline(e,t,i){return this._snappingController.createObserverMoveSnappingPipeline(e,t,i)}onActivate(){this.updateInteractionVisualsVisibility()}onDeactivate(){this.updateInteractionVisualsVisibility()}onInputEvent(e){if(!this.destroyed&&!m(e,this._observerTooltip))switch(e.type){case"key-down":T.cancel===e.key?this._cancelKeyHandler(e):T.delete.includes(e.key)&&this._deleteKeyHandler(e);break;case"hold":this.updateInteractionVisualsVisibility(!0)}}_updateInteractionVisualsLocation(e,t){this._interactionVisuals?.updateLocation(e,t)}_initializeObserverTooltip(e){const t=this._observerTooltipSketchOptions;this._observerTooltip=w(()=>({view:e,options:t.tooltips})),this._observerTooltipInfo=new y({sketchOptions:t,viewType:e.type})}_connectObserverTooltip(e){if(this._disconnectObserverTooltip(),null==e)return void this._observerTooltip.clear();const t=new d({view:this.view,subTool:e});this._observerTooltipObject=t,this._observerTooltipConnectionHandle=v(this._observerTooltip,t,()=>({sketchOptions:this._observerTooltipSketchOptions,activeTooltipInfo:this._observerTooltipInfo,callbacks:{onBeforeUpdate:()=>this.updateInteractionVisualsVisibility(),onMoveStart:()=>{},onMove:()=>{},onMoveStop:()=>{},onRotateStart:()=>{},onRotate:()=>{},onRotateStop:()=>{},onScaleStart:()=>{},onScale:()=>{},onScaleStop:()=>{}}}))}_disconnectObserverTooltip(){this._observerTooltipConnectionHandle=s(this._observerTooltipConnectionHandle),this._observerTooltipObject=o(this._observerTooltipObject)}_cancelKeyHandler(e){this.grabbing||(this.selectedViewshed=null,e.stopPropagation())}_deleteKeyHandler(e){const t=this.selectedViewshed;null!=t&&(this.analysis.viewsheds.remove(t),e.stopPropagation())}get _selectedSubTool(){return this._findSubTool(this.selectedViewshed)}_findSubTool(e){return b(this.subToolHandles,e)}_selectManipulator(e){const t=this._selectedManipulator;t!==e&&(this._selectedManipulator=e,null!=t&&(t.selected=!1),null!=e&&(e.selected=!0),this._findSubTool(t)?.onManipulatorSelectionChanged(),this._selectedSubTool?.onManipulatorSelectionChanged())}get test(){}};e([a({constructOnly:!0})],V.prototype,"analysis",void 0),e([a({constructOnly:!0})],V.prototype,"analysisViewData",void 0),e([a({constructOnly:!0})],V.prototype,"view",void 0),e([a()],V.prototype,"subToolHandles",void 0),e([a()],V.prototype,"removeIncompleteOnCancel",void 0),e([a()],V.prototype,"automaticManipulatorSelection",void 0),e([a()],V.prototype,"creating",void 0),e([a()],V.prototype,"isPlacingTarget",void 0),e([a()],V.prototype,"_selectedManipulator",void 0),e([a()],V.prototype,"_interactionVisuals",void 0),e([a()],V.prototype,"_snappingController",void 0),e([a()],V.prototype,"_observerTooltip",void 0),e([a()],V.prototype,"_observerTooltipInfo",void 0),e([a()],V.prototype,"updating",null),e([a()],V.prototype,"grabbing",null),e([a()],V.prototype,"cursor",null),e([a()],V.prototype,"selectedViewshed",null),e([a()],V.prototype,"selectedViewshedComputedData",null),e([a()],V.prototype,"_selectedSubTool",null),V=e([p("esri.views.3d.analysis.Viewshed.ViewshedEditTool")],V);export{V as ViewshedEditTool};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import t from"../../../../analysis/Viewshed.js";import i from"../../../../core/Accessor.js";import"../../../../core/has.js";import{createAbortError as a,throwIfAborted as o,onAbort as s}from"../../../../core/promiseUtils.js";import{watch as n,sync as r}from"../../../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as l}from"../../../../core/units.js";import{property as c,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{createDrawTool as d,createPlacementResult as p}from"./placementUtils.js";import{detachToolFromView as m}from"./toolLifecycleUtils.js";import{creationVerticalOffset as _}from"./ViewshedConfiguration.js";import u from"./ViewshedPlacementOperation.js";import{createViewshedPlacementRootPluginConfiguration as w}from"./ViewshedPlacementRootPlugin.js";import{computeParametersFromTargetPoint as v}from"./viewshedToolUtils.js";import{DrawManipulator3D as P}from"../../../draw/DrawManipulator3D.js";import{ViewEventPriorities as g}from"../../../input/InputManager.js";import{sketchKeys as y}from"../../../interactive/keybindings.js";import O from"../../../interactive/sketch/SketchOptions.js";const b="multiple",C=new O({tooltips:{enabled:!0}}),T=Symbol("hiddenManipulatorHandle");let f=class extends i{constructor(e){super(e),this.placementMode=b,this.creationState=null,this.stagedViewshed=null,this._placeOperation=null,this._drawTool=null,this._renderer=null}initialize(){this.addHandles([this.view.on("key-down",e=>this._handleKeyDown(e),g.DEFAULT),n(()=>{const{stagedViewshed:e}=this;return{stagedViewshed:e,stagedViewshedInAnalysis:null!=e&&this.analysis.viewsheds.includes(e)}},({stagedViewshed:e,stagedViewshedInAnalysis:t})=>{null==e||t||this.analysis.viewsheds.add(e)},r)])}destroy(){this._cancelPlacementOperation()}get updating(){return!!this._drawTool?.updating}get active(){return!!this._drawTool?.active}startPlaceOperation(e,t){this._removeStaged(),this.creationState=null,this._rejectPlaceOperation(a()),o(t);const{resolve:i,reject:n,promise:r}=Promise.withResolvers(),l=s(t,()=>this._cancelPlacementOperation());return this._placeOperation=new u({abortHandle:l,reject:n,resolve:i}),this.place(e),r}place(e){this.callbacks.setSelectedViewshed(null),this.placementMode=e,this._startObserverPlacement()}cancelPlaceOperation(){null==this.creationState&&null==this._placeOperation||(this._cancelPlacementOperation(),this.callbacks.cancelTool())}_handleDeleteDuringCreation(){return null!=this.creationState&&(this._destroyDrawTool(),this._removeStaged(),this.callbacks.setSelectedViewshed(null),this._startObserverPlacement(),!0)}_handleKeyDown(e){null!=this.creationState&&(y.cancel===e.key?(this._handleCancelDuringCreation(),e.stopPropagation(),e.preventDefault()):y.delete.includes(e.key)&&(this._handleDeleteDuringCreation(),e.stopPropagation(),e.preventDefault()))}_handleCancelDuringCreation(){if(this._removeStaged()&&"multiple"===this.placementMode)return this.callbacks.setSelectedViewshed(null),void this._startObserverPlacement();this._destroyDrawTool(),this._abortCreation()}_removeStaged(){const{stagedViewshed:e}=this;return this.stagedViewshed=null,!!e&&(this.analysis.viewsheds.remove(e),!0)}_cancelPlacementOperation(){this._destroyDrawTool(),this._removeStaged(),this.creationState=null,this._finishPlaceOperation()}_abortCreation(){this.callbacks.cancelTool(),this.creationState=null,this._finishPlaceOperation()}_handleObserverPlacementComplete(e){const i=l(e.mapPoint.spatialReference);e.mapPoint.z=(e.mapPoint.z??0)+_/i;const a=new t({observer:e.mapPoint.clone(),feature:e.feature});this.analysis.viewsheds.add(a),this.stagedViewshed=a,this.creationState="placing-target",this._updateStagedViewshed(e.scenePoint),this.callbacks.setSelectedViewshed(null)}_onCancel(e){const t=this._removeStaged();return"placing-observer"===this.creationState?t&&"multiple"===this.placementMode?(this.callbacks.setSelectedViewshed(null),void this._startObserverPlacement()):(this._destroyDrawTool(e),void this._abortCreation()):t?(this.creationState="placing-observer",this.callbacks.setSelectedViewshed(null),void("multiple"!==this.placementMode?(this._destroyDrawTool(e),this._abortCreation()):this._startPointPlacement())):(this._destroyDrawTool(e),void this._abortCreation())}_handleTargetPlacementComplete(e){this._updateStagedViewshed(e.scenePoint);const t=this.stagedViewshed;this._placeOperation?.markPlacedViewshed(),this.stagedViewshed=null,this.callbacks.setSelectedViewshed(t),"multiple"!==this.placementMode||(this.creationState="placing-observer")}_handleTargetPlacementPreview(e){this._updateStagedViewshed(e.scenePoint)}_resolvePlaceOperation(){this._clearPlaceOperationAndRun(e=>e?.resolve())}_finishPlaceOperation(){this._clearPlaceOperationAndRun(e=>e?.finish())}_rejectPlaceOperation(e){this._clearPlaceOperationAndRun(t=>t?.reject(e))}_clearPlaceOperationAndRun(e){const t=this._placeOperation;this._placeOperation=null,e(t)}_startObserverPlacement(){this.creationState="placing-observer",this._startPointPlacement()}_startPointPlacement(){this._drawTool&&this._destroyDrawTool(this._drawTool);const{drawTool:e,intersector:t,renderer:i}=d({analysisViewData:this.analysisViewData,view:this.view,sketchOptions:C,onCancel:e=>this._onCancel(e),onComplete:e=>this._onComplete(e),onManipulatorCountChange:e=>this._onManipulatorCountChange(e),isPlacingObserver:()=>"placing-observer"===this.creationState});this._drawTool=e,this._renderer=i;try{this.view.addAndActivateTool(e),e.begin([w({mode:this.placementMode,onObserverComplete:i=>this._onObserverMapPointComplete(e,t,i),onTargetComplete:i=>this._onTargetMapPointComplete(e,t,i),onTargetPreview:i=>this._onTargetMapPointPreview(e,t,i)})])}catch(a){this._destroyDrawTool(e),this._rejectPlaceOperation(a instanceof Error?a:new Error(String(a)))}}_onComplete(e){this._removeStaged(),this._resolvePlaceOperation(),this._destroyDrawTool(e),this.creationState=null}_onObserverMapPointComplete(e,t,i){const a=p({drawTool:e,intersector:t,mapPoint:i,view:this.view});a?(this._renderer?.updatePlacementLocation(a.scenePoint),this._handleObserverPlacementComplete(a)):this._onCancel(e)}_onTargetMapPointComplete(e,t,i){const a=p({drawTool:e,intersector:t,mapPoint:i,view:this.view});a?(this._renderer?.updatePlacementLocation(a.scenePoint),this._handleTargetPlacementComplete(a),"multiple"===this.placementMode&&this._renderer?.updatePlacementLocation(null)):this._onCancel(e)}_onTargetMapPointPreview(e,t,i){const a=p({drawTool:e,intersector:t,mapPoint:i,view:this.view});a&&(this._renderer?.updatePlacementLocation(a.scenePoint),this._handleTargetPlacementPreview(a))}_onManipulatorCountChange(e){e.removeHandles(T);const t=[];e.manipulators.forEach(({manipulator:e})=>{e instanceof P&&t.push(e.disableDisplay())}),e.addHandles(t,T)}_destroyDrawTool(e=this._drawTool){this._drawTool=null,this._renderer=null,e&&m(this.view,e)}_updateStagedViewshed(e){const t=this.stagedViewshed;if(!t)return;const i=this.callbacks.findViewshedComputedData(t);if(!i)return;const{heading:a,tilt:o,farDistance:s}=v(this.view,i,e);t.farDistance=s,t.tilt=o,t.heading=a}get test(){}};e([c({constructOnly:!0})],f.prototype,"analysis",void 0),e([c({constructOnly:!0})],f.prototype,"analysisViewData",void 0),e([c({constructOnly:!0})],f.prototype,"view",void 0),e([c({constructOnly:!0})],f.prototype,"callbacks",void 0),e([c()],f.prototype,"placementMode",void 0),e([c()],f.prototype,"creationState",void 0),e([c()],f.prototype,"stagedViewshed",void 0),e([c()],f.prototype,"_placeOperation",void 0),e([c()],f.prototype,"_drawTool",void 0),e([c()],f.prototype,"_renderer",void 0),e([c()],f.prototype,"updating",null),e([c()],f.prototype,"active",null),f=e([h("esri.views.3d.analysis.Viewshed.ViewshedPlacementController")],f);export{f as ViewshedPlacementController};
2
+ import{__decorate as e}from"tslib";import t from"../../../../analysis/Viewshed.js";import i from"../../../../core/Accessor.js";import"../../../../core/has.js";import{createAbortError as a,throwIfAborted as s,onAbort as o}from"../../../../core/promiseUtils.js";import{watch as n,sync as r}from"../../../../core/reactiveUtils.js";import{getMetersPerVerticalUnitForSR as l}from"../../../../core/units.js";import{property as c,subclass as h}from"../../../../core/accessorSupport/decorators.js";import{createDrawTool as d,createPlacementResult as p}from"./placementUtils.js";import{detachToolFromView as m}from"./toolLifecycleUtils.js";import{creationVerticalOffset as _}from"./ViewshedConfiguration.js";import u from"./ViewshedPlacementOperation.js";import{createViewshedPlacementRootPluginConfiguration as w}from"./ViewshedPlacementRootPlugin.js";import{computeParametersFromTargetPoint as v}from"./viewshedToolUtils.js";import{DrawManipulator3D as P}from"../../../draw/DrawManipulator3D.js";import{ViewEventPriorities as g}from"../../../input/InputManager.js";import{sketchKeys as y}from"../../../interactive/keybindings.js";import O from"../../../interactive/sketch/SketchOptions.js";const b="multiple",S=Symbol("hiddenManipulatorHandle");let C=class extends i{constructor(e){super(e),this.placementMode=b,this.stagedViewshed=null,this._placeOperation=null,this._drawTool=null,this._renderer=null,this._sketchOptions=new O({tooltips:{enabled:!1}})}initialize(){this.addHandles([this.view.on("key-down",e=>this._handleKeyDown(e),g.DEFAULT),n(()=>{const{stagedViewshed:e}=this;return{stagedViewshed:e,stagedViewshedInAnalysis:null!=e&&this.analysis.viewsheds.includes(e)}},({stagedViewshed:e,stagedViewshedInAnalysis:t})=>{null==e||t||this.analysis.viewsheds.add(e)},r)])}destroy(){this._cancelPlacementOperation()}get updating(){return!!this._drawTool?.updating}get active(){return!!this._drawTool?.active}get creationState(){return this._get("creationState")}set creationState(e){this._set("creationState",e),this._sketchOptions.tooltips.enabled="placing-observer"===e}startPlaceOperation(e,t){this._removeStaged(),this.creationState=null,this._rejectPlaceOperation(a()),s(t);const{resolve:i,reject:n,promise:r}=Promise.withResolvers(),l=o(t,()=>this._cancelPlacementOperation());return this._placeOperation=new u({abortHandle:l,reject:n,resolve:i}),this.place(e),r}place(e){this.callbacks.setSelectedViewshed(null),this.placementMode=e,this._startObserverPlacement()}cancelPlaceOperation(){null==this.creationState&&null==this._placeOperation||(this._cancelPlacementOperation(),this.callbacks.cancelTool())}_handleDeleteDuringCreation(){return null!=this.creationState&&(this._destroyDrawTool(),this._removeStaged(),this.callbacks.setSelectedViewshed(null),this._startObserverPlacement(),!0)}_handleKeyDown(e){null!=this.creationState&&(y.cancel===e.key?(this._handleCancelDuringCreation(),e.stopPropagation(),e.preventDefault()):y.delete.includes(e.key)&&(this._handleDeleteDuringCreation(),e.stopPropagation(),e.preventDefault()))}_handleCancelDuringCreation(){if(this._removeStaged()&&"multiple"===this.placementMode)return this.callbacks.setSelectedViewshed(null),void this._startObserverPlacement();this._destroyDrawTool(),this._abortCreation()}_removeStaged(){const{stagedViewshed:e}=this;return this.stagedViewshed=null,!!e&&(this.analysis.viewsheds.remove(e),!0)}_cancelPlacementOperation(){this._destroyDrawTool(),this._removeStaged(),this.creationState=null,this._finishPlaceOperation()}_abortCreation(){this.callbacks.cancelTool(),this.creationState=null,this._finishPlaceOperation()}_handleObserverPlacementComplete(e){const i=l(e.mapPoint.spatialReference);e.mapPoint.z=(e.mapPoint.z??0)+_/i;const a=new t({observer:e.mapPoint.clone(),feature:e.feature});this.analysis.viewsheds.add(a),this.stagedViewshed=a,this.creationState="placing-target",this._updateStagedViewshed(e.scenePoint),this.callbacks.setSelectedViewshed(null)}_onCancel(e){const t=this._removeStaged();return"placing-observer"===this.creationState?t&&"multiple"===this.placementMode?(this.callbacks.setSelectedViewshed(null),void this._startObserverPlacement()):(this._destroyDrawTool(e),void this._abortCreation()):t?(this.creationState="placing-observer",this.callbacks.setSelectedViewshed(null),void("multiple"!==this.placementMode?(this._destroyDrawTool(e),this._abortCreation()):this._startPointPlacement())):(this._destroyDrawTool(e),void this._abortCreation())}_handleTargetPlacementComplete(e){this._updateStagedViewshed(e.scenePoint);const t=this.stagedViewshed;this._placeOperation?.markPlacedViewshed(),this.stagedViewshed=null,this.callbacks.setSelectedViewshed(t),"multiple"!==this.placementMode||(this.creationState="placing-observer")}_handleTargetPlacementPreview(e){this._updateStagedViewshed(e.scenePoint)}_resolvePlaceOperation(){this._clearPlaceOperationAndRun(e=>e?.resolve())}_finishPlaceOperation(){this._clearPlaceOperationAndRun(e=>e?.finish())}_rejectPlaceOperation(e){this._clearPlaceOperationAndRun(t=>t?.reject(e))}_clearPlaceOperationAndRun(e){const t=this._placeOperation;this._placeOperation=null,e(t)}_startObserverPlacement(){this.creationState="placing-observer",this._startPointPlacement()}_startPointPlacement(){this._drawTool&&this._destroyDrawTool(this._drawTool);const{drawTool:e,intersector:t,renderer:i}=d({analysisViewData:this.analysisViewData,view:this.view,sketchOptions:this._sketchOptions,onCancel:e=>this._onCancel(e),onComplete:e=>this._onComplete(e),onManipulatorCountChange:e=>this._onManipulatorCountChange(e),isPlacingObserver:()=>"placing-observer"===this.creationState});this._drawTool=e,this._renderer=i;try{this.view.addAndActivateTool(e),e.begin([w({mode:this.placementMode,onObserverComplete:i=>this._onObserverMapPointComplete(e,t,i),onTargetComplete:i=>this._onTargetMapPointComplete(e,t,i),onTargetPreview:i=>this._onTargetMapPointPreview(e,t,i)})])}catch(a){this._destroyDrawTool(e),this._rejectPlaceOperation(a instanceof Error?a:new Error(String(a)))}}_onComplete(e){this._removeStaged(),this._resolvePlaceOperation(),this._destroyDrawTool(e),this.creationState=null}_onObserverMapPointComplete(e,t,i){const a=p({drawTool:e,intersector:t,mapPoint:i,view:this.view});a?(this._renderer?.updatePlacementLocation(a.scenePoint),this._handleObserverPlacementComplete(a)):this._onCancel(e)}_onTargetMapPointComplete(e,t,i){const a=p({drawTool:e,intersector:t,mapPoint:i,view:this.view});a?(this._renderer?.updatePlacementLocation(a.scenePoint),this._handleTargetPlacementComplete(a),"multiple"===this.placementMode&&this._renderer?.updatePlacementLocation(null)):this._onCancel(e)}_onTargetMapPointPreview(e,t,i){const a=p({drawTool:e,intersector:t,mapPoint:i,view:this.view});a&&(this._renderer?.updatePlacementLocation(a.scenePoint),this._handleTargetPlacementPreview(a))}_onManipulatorCountChange(e){e.removeHandles(S);const t=[];e.manipulators.forEach(({manipulator:e})=>{e instanceof P&&t.push(e.disableDisplay())}),e.addHandles(t,S)}_destroyDrawTool(e=this._drawTool){this._drawTool=null,this._renderer=null,e&&m(this.view,e)}_updateStagedViewshed(e){const t=this.stagedViewshed;if(!t)return;const i=this.callbacks.findViewshedComputedData(t);if(!i)return;const{heading:a,tilt:s,farDistance:o}=v(this.view,i,e);t.farDistance=o,t.tilt=s,t.heading=a}get test(){}};e([c({constructOnly:!0})],C.prototype,"analysis",void 0),e([c({constructOnly:!0})],C.prototype,"analysisViewData",void 0),e([c({constructOnly:!0})],C.prototype,"view",void 0),e([c({constructOnly:!0})],C.prototype,"callbacks",void 0),e([c()],C.prototype,"placementMode",void 0),e([c()],C.prototype,"stagedViewshed",void 0),e([c()],C.prototype,"_placeOperation",void 0),e([c()],C.prototype,"_drawTool",void 0),e([c()],C.prototype,"_renderer",void 0),e([c()],C.prototype,"_sketchOptions",void 0),e([c()],C.prototype,"updating",null),e([c()],C.prototype,"active",null),e([c({value:null})],C.prototype,"creationState",null),C=e([h("esri.views.3d.analysis.Viewshed.ViewshedPlacementController")],C);export{C as ViewshedPlacementController};
@@ -31,5 +31,5 @@ export default class VolumeMeasurementError<T = any> extends Error {
31
31
  * console.log("Error name: ", error.name);
32
32
  * });
33
33
  */
34
- name: VolumeMeasurementErrorName;
34
+ readonly name: VolumeMeasurementErrorName;
35
35
  }
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import has from"../../../../core/has.js";class e{constructor(e){this.data=e,this.type="encoded-mesh-texture",this.encoding="image/ktx2"}}function t(e){return"encoded-mesh-texture"===e?.type}async function n(e){const t=new Blob([e]),n=await t.text();return JSON.parse(n)}async function r(t,n){if("image/ktx2"===n)return new e(t);const r=new Blob([t],{type:n});let o=URL.createObjectURL(r);switch(n){case"image/jpeg":o+="#.jpg";break;case"image/png":o+="#.png"}const c=new Image;if(has("esri-iPhone"))return new Promise((e,t)=>{const n=()=>{s(),e(c)},r=e=>{s(),t(e)},s=()=>{URL.revokeObjectURL(o),c.removeEventListener("load",n),c.removeEventListener("error",r)};c.addEventListener("load",n),c.addEventListener("error",r),c.src=o});try{c.src=o,await c.decode()}catch(s){console.warn("Failed decoding HTMLImageElement")}return URL.revokeObjectURL(o),c}export{e as EncodedMeshTexture,r as imageFromBinaryData,t as isEncodedMeshTexture,n as jsonFromBinaryData};
2
+ import has from"../../../../core/has.js";class e{constructor(e){this.data=e,this.type="encoded-mesh-texture",this.encoding="image/ktx2"}}function t(e){return"encoded-mesh-texture"===e?.type}async function r(e){const t=new Blob([e]),r=await t.text();return JSON.parse(r)}async function n(t,r){if("image/ktx2"===r)return new e(t);const n=new Blob([t],{type:r});let o=URL.createObjectURL(n);switch(r){case"image/jpeg":o+="#.jpg";break;case"image/png":o+="#.png"}const c=new Image;if(has("esri-iPhone"))return new Promise((e,t)=>{const r=()=>{s(),e(c)},n=e=>{s(),t(e)},s=()=>{URL.revokeObjectURL(o),c.removeEventListener("load",r),c.removeEventListener("error",n)};c.addEventListener("load",r),c.addEventListener("error",n),c.src=o});try{c.src=o,await c.decode()}catch{}return URL.revokeObjectURL(o),c}export{e as EncodedMeshTexture,n as imageFromBinaryData,t as isEncodedMeshTexture,r as jsonFromBinaryData};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{removeMaybe as i,destroyMaybe as s}from"../../../core/maybe.js";import{watch as a,initial as r}from"../../../core/reactiveUtils.js";import{unitFromRESTJSON as n,convertUnit as l}from"../../../core/units.js";import{property as o,subclass as h}from"../../../core/accessorSupport/decorators.js";import{fromValues as d}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as u}from"../../../geometry/ellipsoidUtils.js";import c from"../../../geometry/HeightModelInfo.js";import{create as p}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as m}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as f,isWebMercator as g,equals as _,isGeographic as y}from"../../../geometry/support/spatialReferenceUtils.js";import w from"../../../geometry/support/WKIDUnitConversion.js";import{getHeightModelInfoFromVCS as v}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as b}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as S}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as C}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as M}from"./LayerView3D.js";import{addLayerViewToWasm as x,getLyr3DWasm as H,removeLayerViewFromWasm as I}from"./Lyr3DWasm.js";import{LayerElevationProvider as T}from"./i3s/LayerElevationProvider.js";import{ElevationRange as A}from"../support/ElevationRange.js";import{projectToBoundingBox as P}from"../support/extentUtils.js";import{Obb as F}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as R,packedGaussianSizeInU32 as V,splatPageSizeInU32WithoutHeader as j,gaussiansPerSplatPage as O,elementsPerSplatPage as G,splatAtlasTextureWidth as U}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as E}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as D}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as L}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as B}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as z}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import{GaussianSplatShadowRenderNode as N}from"../webgl-engine/lib/GaussianSplatShadowRenderNode.js";import k from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as q,isInEffectiveScaleRange as W}from"../../support/layerViewUtils.js";import{TaskPriority as $}from"../../support/Scheduler.js";var X;const Z=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D"),J=3,K=J*J,Y=255,Q=(()=>{const e=new Int16Array(Y+1);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/Y));return e})();let ee=class extends(M(k)){static{X=this}static{this.createRenderableBatchSize=64}constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(R),this._tmpTilesWithChangedVisibility=new Array,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Map,this._tileFadeOutsAwaitingInitialSort=new Map,this._fadeDurationPerVisibilityChange=new Map,this._tmpSortedTileHandles=new Set,this._createRenderableAbortController=new AbortController,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask($.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=p();return P(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderNode?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw q("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=x(this).then(e=>{this._wasmLayerId=e,this._renderNode=new z({view:this.view,layerView:this}),this.data=new E(this._renderNode,(e,t)=>this._onSortComplete(e,t)),this._shadowRenderNode=new N({view:this.view,layerView:this}),this.fadeHelper=new D(this),this._intersectionHandler=new L(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new T({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([a(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),r)]),this._suspendedHandle=a(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r),this.addHandles([a(()=>this._clippingBox,e=>this._renderNode.clippingBox=e,r)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians)});this.addHandles([a(()=>this.view.qualitySettings.fadeDuration,e=>{this.fadeHelper.onFadeDurationChanged(e),this.data.fadingTexture.updateTexture(this.data.textureAtlas.pageAllocator.pageCount)}),a(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),a(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return H(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return b(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new A(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return W(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=t.desc.prims[0],s=i.vertexCount;if(0===s)return()=>({memUsageBytes:0,numGaussians:0});const a=i.atrbs[0].view,r=i.atrbs[0].view.byteCount,n=i.atrbs[0].view.byteOffset;let l=null;if("U32"!==a.type)return Z().warnOnce("unexpected meshData.data format"),()=>({memUsageBytes:0,numGaussians:0});l=new Uint32Array(t.data.buffer,n,r/4);const o=this.extractHeader(l),h=2.048,c=o.tileOrigin.x*h,p=o.tileOrigin.y*h,m=o.tileOrigin.z*h;let f=null;if(t.desc.obb){const e=t.desc.obb.quaternion;f=new F(t.desc.obb.center,t.desc.obb.halfSize,d(...e))}f||(Z().warnOnce("encountered tile without a bounding box"),f=new F);const g=this.view.state.isGlobal,_=g?u(this.view.spatialReference).radius:0,y={handle:e.handle,bufferView:l,totalGaussians:s,packedHeader:o.packedHeader,tileOrigin:{x:c,y:p,z:m},invPosScale:o.invPosScale,obb:f,origin:{x:f.centerX,y:f.centerY,z:f.centerZ},isGlobal:g,ellipsoidRadius:_},w=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(y,e),this._createRenderableAbortController.signal);return()=>w}*_createRenderableTask(e,t){const{handle:i,bufferView:s,totalGaussians:a,packedHeader:r,tileOrigin:n,invPosScale:l,obb:o,origin:h,isGlobal:d,ellipsoidRadius:u}=e,c=n.x,p=n.y,m=n.z,f=h.x,g=h.y,_=h.z,y=new Uint32Array(a),w=new Float32Array(3*a),v=new Uint32Array(a),b=new Uint32Array(a),S=new Array,C=Math.ceil(a/O);for(let A=0;A<C;A++){let e=this.data.textureAtlas.requestPage();if(null===e&&(this._freeInvisibleTiles(),e=this.data.textureAtlas.requestPage()),null===e)return Z().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};S.push(e);const i=a-A*O,n=Math.min(i,O),l=A*O,o=G*e;for(let t=0;t<n;t++)y[l+t]=o+t;const h=A*j;this._pageBuffer.set(s.subarray(h,h+n*V)),this._pageBuffer.set(r,j);const d=e*G,u=d%U,c=Math.floor(d/U);this.data.textureAtlas.update(u,c,this._pageBuffer),t.madeProgress()&&(t=yield)}let M=1/0,x=-1/0,H=1/0,I=-1/0,T=0,P=-1,F=0;for(let A=0;A<a;A++){const e=A*V,i=s[e],a=s[e+1],r=s[e+2],n=s[e+3],o=16383&a,h=a>>>14&16383,u=a>>>28&15|(1023&r)<<4,y=Q[n>>>24],S=(r>>>10&255)+y,C=(r>>>18&255)+y,R=(r>>>26&63|(3&n)<<6)+y,j=S>0?S:0,O=C>0?C:0,G=R>0?R:0,U=j|O<<8|G<<16,E=Math.max(j,O,G),D=o*l+c,L=h*l+p,B=u*l+m;if(w[T]=D-f,w[T+1]=L-g,w[T+2]=B-_,d){const e=D*D+L*L+B*B;H=Math.min(H,e),I=Math.max(I,e)}else M=Math.min(M,B),x=Math.max(x,B);v[A]=i,b[A]=U,E>P&&(P=E),T+=3,F++,F===X.createRenderableBatchSize&&(F=0,t.madeProgress()&&(t=yield))}F>0&&t.madeProgress(),d&&(M=Math.sqrt(H)-u,x=Math.sqrt(I)-u);const R=this._extractGaussianSplatMbsRadiusSquared(P),{fullExtent:E}=this.layer;E?.hasZ&&E.zmax&&E.zmin&&(M=Math.max(M,E.zmin),x=Math.min(x,E.zmax));const D=new A(M,x),L=new B(i,o,y,S,w,v,b,a,R,D);return this._memCache.put(`${L.handle}`,L),this._tileHandles.set(i,L),this._cacheTileMemory+=L.usedMemory,{memUsageBytes:L.usedMemory,numGaussians:a}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*K}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._tileFadeOutsAwaitingInitialSort.delete(e);let t=!1;const i=this._tileHandles.get(e);if(i){0!==i.lifecycleState?(t=!0,this.fadeHelper.onTileDiscarded(i),this._usedTileMemory-=i.usedMemory,this._intersectionHandler.removeTile(i)):this._cacheTileMemory-=i.usedMemory,i.pageIds.forEach(e=>this.data.textureAtlas.freePage(e)),this.freeObject(i),this._tileHandles.delete(e)}t&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(t=>{for(const i of e)t(i.obb)})}setRenderableVisibility(e,t,i){const s=this._currentLyr3dVisibilityChange+1,a=this.fadeHelper.updateFadeDuration();this._fadeDurationPerVisibilityChange.set(s,a);let r=!1;for(let n=0;n<i;n++){const i=this._tileHandles.get(e[n]);if(!i)continue;const l=t[n]?this._prepareTileFadeIn(i,s,a):this._prepareTileFadeOut(i,s);r||=l}r?(this._currentLyr3dVisibilityChange=s,this.updateGaussians()):this._fadeDurationPerVisibilityChange.delete(s)}_prepareTileFadeIn(e,t,i){const s=this._tileFadeOutsAwaitingInitialSort.delete(e.handle);return 2===e.lifecycleState?(this.fadeHelper.fadeTile(e,0,i),!1):this._tileFadeInsAwaitingInitialSort.get(e.handle)!==t?(0===e.lifecycleState&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.set(e.handle,t),!0):s}_prepareTileFadeOut(e,t){const i=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return i&&1===e.lifecycleState&&(this.moveTileToCache(e),e.lifecycleState=0),2!==e.lifecycleState?i:this._tileFadeOutsAwaitingInitialSort.get(e.handle)!==t?(this._tileFadeOutsAwaitingInitialSort.set(e.handle,t),!0):i}_onSortComplete(e,t){const i=this._tmpTilesWithChangedVisibility;i.length=0;const s=this._tmpSortedTileHandles;s.clear();for(let r=0;r<e.length;r++){const t=e[r];s.add(t.handle)}this._triggerFadeIns(t,s,i);const a=this._triggerFadeOuts(t,i);s.clear(),i.length>0&&this.notifyTileObbsChanged(i),a&&this.updateGaussians(),this._cleanupVisibilityChangeFadeDurations(t)}_triggerFadeIns(e,t,i){for(const[s,a]of this._tileFadeInsAwaitingInitialSort){if(a>e||!t.has(s))continue;const r=this._tileHandles.get(s);if(!r){this._tileFadeInsAwaitingInitialSort.delete(s);continue}const n=this._getFadeDurationForPendingVisibilityChange(a),l=0===r.lifecycleState;2!==r.lifecycleState&&(r.lifecycleState=2,l&&this._popTileFromCache(r),i.push(r)),this.fadeHelper.fadeTile(r,0,n),this._tileFadeInsAwaitingInitialSort.delete(s)}}_triggerFadeOuts(e,t){let i=!1;for(const[s,a]of this._tileFadeOutsAwaitingInitialSort){if(a>e)continue;const r=this._tileHandles.get(s);if(r){const e=2===r.lifecycleState,s=this._getFadeDurationForPendingVisibilityChange(a);this.fadeHelper.fadeTile(r,1,s),e&&0===r.lifecycleState&&(t.push(r),i=!0)}this._tileFadeOutsAwaitingInitialSort.delete(s)}return i}_getFadeDurationForPendingVisibilityChange(e){return this._fadeDurationPerVisibilityChange.get(e)??this.fadeHelper.baseFadeDuration}_cleanupVisibilityChangeFadeDurations(e){if(0!==this._fadeDurationPerVisibilityChange.size)for(const t of this._fadeDurationPerVisibilityChange.keys())t<=e&&this._fadeDurationPerVisibilityChange.delete(t)}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(`${e.handle}`,e)}destroy(){this._createRenderableAbortController.abort(),I(this),this._suspendedHandle&&(this._suspendedHandle=i(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>{for(const t of this._tileHandles.values())e(t.obb)}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadowRenderNode=s(this._shadowRenderNode),this._renderNode=s(this._renderNode),this.data=s(this.data),this._memCache.destroy()}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(f(this.view.renderSpatialReference)||g(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&_(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=v(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!y(t)&&t.wkid&&-1!==t.wkid&&(i=n(w.units[w[t.wkid]])),i&&(e=new c({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===m(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=l(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=S(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,b(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderNode&&(this._renderNode.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())0!==t.lifecycleState&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange("updating")}setMaximumGaussianCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())0===e.lifecycleState&&this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),a=this.reinterpretU32AsFloat(e[t+2]),r=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:a},invPosScale:r}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;this._tileHandles.forEach(i=>{0===i.lifecycleState?t++:e++});const i=this.data?.textureAtlasMemory??0,s=this.data?.orderTextureMemory??0,a=this.data?.fadingTextureMemory??0,r=this.data?.sortBufferMemory??0;return new C(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,i,s,a,r)}get test(){}};e([o()],ee.prototype,"layer",void 0),e([o({readOnly:!0})],ee.prototype,"_clippingBox",null),e([o()],ee.prototype,"elevationOffset",null),e([o({readOnly:!0})],ee.prototype,"visibleAtCurrentScale",null),e([o()],ee.prototype,"fullExtentInLocalViewSpatialReference",void 0),ee=X=e([h("esri.views.3d.layers.GaussianSplatLayerView3D")],ee);const te=ee;export{te as default};
2
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{removeMaybe as i,destroyMaybe as s}from"../../../core/maybe.js";import{watch as a,initial as r}from"../../../core/reactiveUtils.js";import{unitFromRESTJSON as n,convertUnit as l}from"../../../core/units.js";import{property as o,subclass as h}from"../../../core/accessorSupport/decorators.js";import{fromValues as d}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{getReferenceEllipsoid as u}from"../../../geometry/ellipsoidUtils.js";import c from"../../../geometry/HeightModelInfo.js";import{create as p}from"../../../geometry/support/aaBoundingBox.js";import{isCompatible as m}from"../../../geometry/support/heightModelInfoUtils.js";import{isPlateCarree as f,isWebMercator as g,equals as _,isGeographic as y}from"../../../geometry/support/spatialReferenceUtils.js";import w from"../../../geometry/support/WKIDUnitConversion.js";import{getHeightModelInfoFromVCS as v}from"../../../layers/support/tiles3DUtils.js";import{getElevationOffsetInMeters as b}from"../../../support/elevationInfoUtils.js";import{getMetersPerUnit as S}from"../../../symbols/support/unitConversionUtils.js";import{GaussianSplatLayerViewPerformanceInfo as C}from"./GaussianSplatLayerViewPerformanceInfo.js";import{LayerView3D as M}from"./LayerView3D.js";import{addLayerViewToWasm as x,getLyr3DWasm as H,removeLayerViewFromWasm as I}from"./Lyr3DWasm.js";import{LayerElevationProvider as T}from"./i3s/LayerElevationProvider.js";import{ElevationRange as A}from"../support/ElevationRange.js";import{projectToBoundingBox as P}from"../support/extentUtils.js";import{Obb as F}from"../support/orientedBoundingBox.js";import{splatPageSizeInU32 as R,packedGaussianSizeInU32 as V,splatPageSizeInU32WithoutHeader as j,gaussiansPerSplatPage as O,elementsPerSplatPage as G,splatAtlasTextureWidth as U}from"../support/gaussianSplatting/GaussianSplatAtlasPages.js";import{GaussianSplatDataStore as E}from"../support/gaussianSplatting/GaussianSplatDataStore.js";import{GaussianSplatFadeHelper as D}from"../support/gaussianSplatting/GaussianSplatFadeHelper.js";import{GaussianSplatIntersectionHandler as L}from"../support/gaussianSplatting/GaussianSplatIntersectionHandler.js";import{GaussianTile as B}from"../support/gaussianSplatting/GaussianTile.js";import{GaussianSplatRenderNode as z}from"../webgl-engine/lib/GaussianSplatRenderNode.js";import{GaussianSplatShadowRenderNode as N}from"../webgl-engine/lib/GaussianSplatShadowRenderNode.js";import k from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as q,isInEffectiveScaleRange as W}from"../../support/layerViewUtils.js";import{TaskPriority as $}from"../../support/Scheduler.js";var X;const Z=()=>t.getLogger("esri.views.3d.layers.GaussianSplatLayerView3D"),J=3,K=J*J,Y=255,Q=(()=>{const e=new Int16Array(Y+1);e[0]=-255;for(let t=1;t<e.length;t++)e[t]=Math.round(16*Math.log(t/Y));return e})();let ee=class extends(M(k)){static{X=this}static{this.createRenderableBatchSize=64}constructor(e){super(e),this.type="gaussian-splat-3d",this.ignoresMemoryFactor=!1,this._tileHandles=new Map,this._pageBuffer=new Uint32Array(R),this._tmpTilesWithChangedVisibility=new Array,this._currentLyr3dVisibilityChange=0,this._tileFadeInsAwaitingInitialSort=new Map,this._tileFadeOutsAwaitingInitialSort=new Map,this._fadeDurationPerVisibilityChange=new Map,this._tmpSortedTileHandles=new Set,this._createRenderableAbortController=new AbortController,this._wasmLayerId=-1,this._metersPerVCSUnit=1,this._usedTileMemory=0,this._cacheTileMemory=0,this._useEsriCrs=!1,this.fullExtentInLocalViewSpatialReference=null,this._suspendedHandle=null,this._conversionBuffer=new ArrayBuffer(4),this._u32View=new Uint32Array(this._conversionBuffer),this._f32View=new Float32Array(this._conversionBuffer);const t=e.view.resourceController;this._memCache=t.memoryController.newCache(`GaussianSplat-${this.uid}`,e=>this._deleteTile(e)),this._frameTask=t.scheduler.registerTask($.GAUSSIAN_SPLAT_TEXTURE_ATLAS)}get _clippingBox(){if(!this.view?.clippingArea)return null;const e=p();return P(this.view.clippingArea,e,this.view.renderSpatialReference)?e:null}get clippingBox(){return this._renderNode?.clippingBox??null}initialize(){if(!this._canProjectWithoutEngine())throw q("layer",this.layer.spatialReference.wkid,this.view.renderSpatialReference?.wkid);const e=x(this).then(e=>{this._wasmLayerId=e,this._renderNode=new z({view:this.view,layerView:this}),this.data=new E(this._renderNode,(e,t)=>this._onSortComplete(e,t)),this._shadowRenderNode=new N({view:this.view,layerView:this}),this.fadeHelper=new D(this),this._intersectionHandler=new L(this),this.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._elevationProvider=new T({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this.view.elevationProvider.register(2,this._elevationProvider),this.addHandles([a(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChanged(e),r)]),this._suspendedHandle=a(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),r),this.addHandles([a(()=>this._clippingBox,e=>this._renderNode.clippingBox=e,r)]),this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians)});this.addHandles([a(()=>this.view.qualitySettings.fadeDuration,e=>{const t=this.data;t&&(this.fadeHelper.onFadeDurationChanged(e),t.fadingTexture.updateTexture(t.textureAtlas.pageAllocator.pageCount))}),a(()=>this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians,e=>this.setMaximumGaussianCount(e*this.view.quality)),a(()=>this.view.quality,e=>this.setMaximumGaussianCount(this.view.qualitySettings.gaussianSplat.maximumNumberOfGaussians*e))]),this.addResolvingPromise(e)}get wasmLayerId(){return this._wasmLayerId}get metersPerVCSUnit(){return this._metersPerVCSUnit}get tileHandles(){return this._tileHandles}get _wasm(){return H(this.view)}get usedMemory(){return this._usedTileMemory+(this.data?.usedMemory??0)}get cachedMemory(){return this._cacheTileMemory}get unloadedMemory(){return 0}get useEsriCrs(){return this._useEsriCrs}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return b(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new A(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get fullExtent(){return this.layer.fullExtent}get visibleAtCurrentScale(){return W(this.layer.effectiveScaleRange,this.view.scale)}isUpdating(){const e=this._wasm;return!(this._wasmLayerId<0||null==e)&&(e.isUpdating(this._wasmLayerId)||this.data.updating||this.fadeHelper.updating)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){const t=e.meshData;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=t.desc.prims[0],s=i.vertexCount;if(0===s)return()=>({memUsageBytes:0,numGaussians:0});const a=i.atrbs[0].view,r=i.atrbs[0].view.byteCount,n=i.atrbs[0].view.byteOffset;let l=null;if("U32"!==a.type)return Z().warnOnce("unexpected meshData.data format"),()=>({memUsageBytes:0,numGaussians:0});l=new Uint32Array(t.data.buffer,n,r/4);const o=this.extractHeader(l),h=2.048,c=o.tileOrigin.x*h,p=o.tileOrigin.y*h,m=o.tileOrigin.z*h;let f=null;if(t.desc.obb){const e=t.desc.obb.quaternion;f=new F(t.desc.obb.center,t.desc.obb.halfSize,d(...e))}f||(Z().warnOnce("encountered tile without a bounding box"),f=new F);const g=this.view.state.isGlobal,_=g?u(this.view.spatialReference).radius:0,y={handle:e.handle,bufferView:l,totalGaussians:s,packedHeader:o.packedHeader,tileOrigin:{x:c,y:p,z:m},invPosScale:o.invPosScale,obb:f,origin:{x:f.centerX,y:f.centerY,z:f.centerZ},isGlobal:g,ellipsoidRadius:_},w=await this._frameTask.scheduleGenerator(e=>this._createRenderableTask(y,e),this._createRenderableAbortController.signal);return()=>w}*_createRenderableTask(e,t){const{handle:i,bufferView:s,totalGaussians:a,packedHeader:r,tileOrigin:n,invPosScale:l,obb:o,origin:h,isGlobal:d,ellipsoidRadius:u}=e,c=n.x,p=n.y,m=n.z,f=h.x,g=h.y,_=h.z,y=new Uint32Array(a),w=new Float32Array(3*a),v=new Uint32Array(a),b=new Uint32Array(a),S=new Array,C=Math.ceil(a/O);for(let A=0;A<C;A++){let e=this.data.textureAtlas.requestPage();if(null===e&&(this._freeInvisibleTiles(),e=this.data.textureAtlas.requestPage()),null===e)return Z().warnOnce("ran out of gaussian splat memory"),{memUsageBytes:0,numGaussians:0};S.push(e);const i=a-A*O,n=Math.min(i,O),l=A*O,o=G*e;for(let t=0;t<n;t++)y[l+t]=o+t;const h=A*j;this._pageBuffer.set(s.subarray(h,h+n*V)),this._pageBuffer.set(r,j);const d=e*G,u=d%U,c=Math.floor(d/U);this.data.textureAtlas.update(u,c,this._pageBuffer),t.madeProgress()&&(t=yield)}let M=1/0,x=-1/0,H=1/0,I=-1/0,T=0,P=-1,F=0;for(let A=0;A<a;A++){const e=A*V,i=s[e],a=s[e+1],r=s[e+2],n=s[e+3],o=16383&a,h=a>>>14&16383,u=a>>>28&15|(1023&r)<<4,y=Q[n>>>24],S=(r>>>10&255)+y,C=(r>>>18&255)+y,R=(r>>>26&63|(3&n)<<6)+y,j=S>0?S:0,O=C>0?C:0,G=R>0?R:0,U=j|O<<8|G<<16,E=Math.max(j,O,G),D=o*l+c,L=h*l+p,B=u*l+m;if(w[T]=D-f,w[T+1]=L-g,w[T+2]=B-_,d){const e=D*D+L*L+B*B;H=Math.min(H,e),I=Math.max(I,e)}else M=Math.min(M,B),x=Math.max(x,B);v[A]=i,b[A]=U,E>P&&(P=E),T+=3,F++,F===X.createRenderableBatchSize&&(F=0,t.madeProgress()&&(t=yield))}F>0&&t.madeProgress(),d&&(M=Math.sqrt(H)-u,x=Math.sqrt(I)-u);const R=this._extractGaussianSplatMbsRadiusSquared(P),{fullExtent:E}=this.layer;E?.hasZ&&E.zmax&&E.zmin&&(M=Math.max(M,E.zmin),x=Math.min(x,E.zmax));const D=new A(M,x),L=new B(i,o,y,S,w,v,b,a,R,D);return this._memCache.put(`${L.handle}`,L),this._tileHandles.set(i,L),this._cacheTileMemory+=L.usedMemory,{memUsageBytes:L.usedMemory,numGaussians:a}}_extractGaussianSplatMbsRadiusSquared(e){return Math.exp(e/8-20)*K}freeRenderable(e){this._tileFadeInsAwaitingInitialSort.delete(e),this._tileFadeOutsAwaitingInitialSort.delete(e);const t=this.data?.textureAtlas;let i=!1;const s=this._tileHandles.get(e);if(s){0!==s.lifecycleState?(i=!0,this.fadeHelper.onTileDiscarded(s),this._usedTileMemory-=s.usedMemory,this._intersectionHandler.removeTile(s)):this._cacheTileMemory-=s.usedMemory,t&&s.pageIds.forEach(e=>t.freePage(e)),this.freeObject(s),this._tileHandles.delete(e)}i&&this.updateGaussians()}freeObject(e){this._memCache.pop(`${e.handle}`)}notifyTileObbsChanged(e){this._elevationProvider&&this._elevationProvider.notifyObjectsChangedFunctional(t=>{for(const i of e)t(i.obb)})}setRenderableVisibility(e,t,i){const s=this._currentLyr3dVisibilityChange+1,a=this.fadeHelper.updateFadeDuration();this._fadeDurationPerVisibilityChange.set(s,a);let r=!1;for(let n=0;n<i;n++){const i=this._tileHandles.get(e[n]);if(!i)continue;const l=t[n]?this._prepareTileFadeIn(i,s,a):this._prepareTileFadeOut(i,s);r||=l}r?(this._currentLyr3dVisibilityChange=s,this.updateGaussians()):this._fadeDurationPerVisibilityChange.delete(s)}_prepareTileFadeIn(e,t,i){const s=this._tileFadeOutsAwaitingInitialSort.delete(e.handle);return 2===e.lifecycleState?(this.fadeHelper.fadeTile(e,0,i),!1):this._tileFadeInsAwaitingInitialSort.get(e.handle)!==t?(0===e.lifecycleState&&this._popTileFromCache(e),e.lifecycleState=1,this._tileFadeInsAwaitingInitialSort.set(e.handle,t),!0):s}_prepareTileFadeOut(e,t){const i=this._tileFadeInsAwaitingInitialSort.delete(e.handle);return i&&1===e.lifecycleState&&(this.moveTileToCache(e),e.lifecycleState=0),2!==e.lifecycleState?i:this._tileFadeOutsAwaitingInitialSort.get(e.handle)!==t?(this._tileFadeOutsAwaitingInitialSort.set(e.handle,t),!0):i}_onSortComplete(e,t){const i=this._tmpTilesWithChangedVisibility;i.length=0;const s=this._tmpSortedTileHandles;s.clear();for(let r=0;r<e.length;r++){const t=e[r];s.add(t.handle)}this._triggerFadeIns(t,s,i);const a=this._triggerFadeOuts(t,i);s.clear(),i.length>0&&this.notifyTileObbsChanged(i),a&&this.updateGaussians(),this._cleanupVisibilityChangeFadeDurations(t)}_triggerFadeIns(e,t,i){for(const[s,a]of this._tileFadeInsAwaitingInitialSort){if(a>e||!t.has(s))continue;const r=this._tileHandles.get(s);if(!r){this._tileFadeInsAwaitingInitialSort.delete(s);continue}const n=this._getFadeDurationForPendingVisibilityChange(a),l=0===r.lifecycleState;2!==r.lifecycleState&&(r.lifecycleState=2,l&&this._popTileFromCache(r),i.push(r)),this.fadeHelper.fadeTile(r,0,n),this._tileFadeInsAwaitingInitialSort.delete(s)}}_triggerFadeOuts(e,t){let i=!1;for(const[s,a]of this._tileFadeOutsAwaitingInitialSort){if(a>e)continue;const r=this._tileHandles.get(s);if(r){const e=2===r.lifecycleState,s=this._getFadeDurationForPendingVisibilityChange(a);this.fadeHelper.fadeTile(r,1,s),e&&0===r.lifecycleState&&(t.push(r),i=!0)}this._tileFadeOutsAwaitingInitialSort.delete(s)}return i}_getFadeDurationForPendingVisibilityChange(e){return this._fadeDurationPerVisibilityChange.get(e)??this.fadeHelper.baseFadeDuration}_cleanupVisibilityChangeFadeDurations(e){if(0!==this._fadeDurationPerVisibilityChange.size)for(const t of this._fadeDurationPerVisibilityChange.keys())t<=e&&this._fadeDurationPerVisibilityChange.delete(t)}_popTileFromCache(e){this._usedTileMemory+=e.usedMemory,this._cacheTileMemory-=e.usedMemory,this._intersectionHandler.addTile(e),this._memCache.pop(`${e.handle}`)}moveTileToCache(e){this._usedTileMemory-=e.usedMemory,this._cacheTileMemory+=e.usedMemory,this._intersectionHandler.removeTile(e),this._memCache.put(`${e.handle}`,e)}destroy(){this._createRenderableAbortController.abort(),I(this),this._suspendedHandle&&(this._suspendedHandle=i(this._suspendedHandle)),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&this.view.elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>{for(const t of this._tileHandles.values())e(t.obb)}),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._frameTask.remove(),this._shadowRenderNode=s(this._shadowRenderNode),this._renderNode=s(this._renderNode),this._memCache.destroy(),this.data=s(this.data)}_canProjectWithoutEngine(){if(1===this.view.state.viewingMode)return!0;if(f(this.view.renderSpatialReference)||g(this.view.renderSpatialReference))return!0;if(this.layer.esriCrsSpatialReference&&_(this.layer.esriCrsSpatialReference,this.view.renderSpatialReference)){if(115700===this.layer.esriCrsSpatialReference.vcsWkid)return!1;let e=v(this.layer.esriCrsSpatialReference);if(!e){const t=this.layer.esriCrsSpatialReference;let i="meters";!y(t)&&t.wkid&&-1!==t.wkid&&(i=n(w.units[w[t.wkid]])),i&&(e=new c({heightModel:"gravity-related-height",heightUnit:i}))}const t=this.view.heightModelInfo;return this._useEsriCrs=0===m(e,t,!1),this._useEsriCrs&&(e&&(this._metersPerVCSUnit=l(1,e.heightUnit,"meters")),this.fullExtentInLocalViewSpatialReference=this.layer.esriCrsFullExtent),this._useEsriCrs}return!1}_elevationInfoChanged(e){if(e?.offset)if(this._useEsriCrs){const t=S(e?.unit)/this._metersPerVCSUnit,i=e?.offset??0;this._wasm?.setLayerOffset(this,i*t)}else this._wasm?.setLayerOffset(this,b(e));else this._wasm?.setLayerOffset(this,0)}_slicePlaneEnabledChanged(e){this._renderNode&&(this._renderNode.slicePlaneEnabled=e),this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e)}updateGaussians(){const e=new Array;for(const t of this._tileHandles.values())0!==t.lifecycleState&&e.push(t);this.data.updateGaussianVisibility(e,this._currentLyr3dVisibilityChange),this.notifyChange("updating")}setMaximumGaussianCount(e){this._wasm?.setMaximumGaussianSplatCount(e)}_freeInvisibleTiles(){for(const e of this._tileHandles.values())0===e.lifecycleState&&this._deleteTile(e)}extractHeader(e){const t=e.length-4,i=this.reinterpretU32AsFloat(e[t]),s=this.reinterpretU32AsFloat(e[t+1]),a=this.reinterpretU32AsFloat(e[t+2]),r=1/(1<<(255&e[t+3]));return{packedHeader:e.subarray(t,t+4),tileOrigin:{x:i,y:s,z:a},invPosScale:r}}_deleteTile(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}reinterpretU32AsFloat(e){return this._u32View[0]=e,this._f32View[0]}get performanceInfo(){let e=0,t=0;this._tileHandles.forEach(i=>{0===i.lifecycleState?t++:e++});const i=this.data?.textureAtlasMemory??0,s=this.data?.orderTextureMemory??0,a=this.data?.fadingTextureMemory??0,r=this.data?.sortBufferMemory??0;return new C(this.usedMemory,e,this._usedTileMemory,t,this._cacheTileMemory,i,s,a,r)}get test(){}};e([o()],ee.prototype,"layer",void 0),e([o({readOnly:!0})],ee.prototype,"_clippingBox",null),e([o()],ee.prototype,"elevationOffset",null),e([o({readOnly:!0})],ee.prototype,"visibleAtCurrentScale",null),e([o()],ee.prototype,"fullExtentInLocalViewSpatialReference",void 0),ee=X=e([h("esri.views.3d.layers.GaussianSplatLayerView3D")],ee);const te=ee;export{te as default};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,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{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as g,add as x,scale as _,transformMat4 as y,transformMat3 as T,normalize as b,scaleAndAdd as v,subtract as w,cross as C,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as j,ONES as R,ZEROS as A,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,intersectsClippingArea as O,create as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as ce}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ue}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as me}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as fe,nanFallbackColor as pe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as he,MeshFastUpdateProcessor as de}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as ge}from"./SymbolComplexity.js";import{hasEdges as xe,createMaterial as _e}from"../support/edgeUtils.js";import{debugFlags as ye}from"../../support/debugFlags.js";import{Attribute as Te}from"../../webgl-engine/lib/Attribute.js";import{Geometry as be}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as ve}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as we}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Me}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Re,schematicMRRFactors as Ae}from"../../webgl-engine/materials/pbrUtils.js";const Pe=["mesh"];class Se extends fe{constructor(e,t,r,o){super(e,t,r,o,Ye(t)),this._materialInfoCache=new he,this._fastUpdateProcessor=new de,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ye.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Me({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Me({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Me({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Pe,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=rt,{origin:i,transform:l}=r;if(!B(t,g(Qe,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache)}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=xe(this.symbolLayer)?2:0;return new ge({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ze(n),p=ze(a),h=qe(s),d=ze(i),g=qe(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:p}=t.material,h=ze(n),d=qe(a),g=ze(i),x=ze(u),_=qe(m),y=ze(f),T=qe(p);o.uid=[o.uid,`mrm:${e}`,`mrr:${r}`,`mrt:${h}`,`mrtt:${d}`,`emuid:${g}`,`ems:${c}`,`etmuid:${x}`,`ett:${_}`,`otmuid:${y}`,`ott:${T}`].join(","),o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=Ge(s),o.normalTextureTransform=Ge(l),o.emissiveTextureTransform=Ge(m),o.occlusionTextureTransform=Ge(p),o.metallicRoughnessTextureTransform=Ge(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=ke(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:De(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new ve(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(e,r){if(null!=e.colorTexture){const t=1!==r.textureAlphaMode,o=this._getInternalTexture(e.colorTexture,t,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}if(e.normalTexture&&(r.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){const o=e.emissiveColor?.toUnitRGB();r.emissiveBaseColor=j(t(o[0]),t(o[1]),t(o[2]))}e.emissiveStrength&&(r.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&He(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){const r=this._drivenProperties.color,o=this._drivenProperties.opacity;if(r)e.externalColor=S;else{const r=t??null;if(r){const t=r.toUnitRGBA();o&&(t[3]=1),e.externalColor=t}else e.externalColor=pe}e.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(Ne(e)||null!=r&&r.a<1||o?.transparent||a),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return this._setInternalMaterialTextureParameters(i,l.material.parameters),l.material;const c={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},u=je({normalTexture:i.normalTexture,metallicRoughnessTexture:i.metallicRoughnessTexture,metallicFactor:i.metallic,roughnessFactor:i.roughness,emissiveTexture:i.emissiveTexture,emissiveFactor:i.emissiveColor?.toUnitRGB(),occlusionTexture:i.occlusionTexture}),m={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:A,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||c.isComponentTransparent};m.mrrFactors=u?Ae:[i.metallic,i.roughness,Re[2]],t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?0:2,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTextureAlphaMode(m,c),this._setInternalMaterialParameters(i,m,c);const f=new Ce(m,this._context);return c.material=f,this._materialInfoCache.set(i.uid,c),f}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return ce(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)$e(r,o,t,et),Ve(r,o,t,Qe,Xe,Ze),x(Qe,Qe,Xe),x(Qe,Qe,Ze),_(Qe,Qe,1/3),y(Qe,Qe,c),s.push(...Qe),T(et,et,u),b(et,et),v(Qe,Qe,et,n),s.push(...Qe),l.push(l.length),l.push(l.length)}return s.length?new be(this._debugFaceNormalMaterial,[["position",new Te(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Qe,s[e+0],s[e+1],s[e+2]),y(Qe,Qe,p),m.push(...Qe),g(Xe,l[r+0],l[r+1],l[r+2]),T(Xe,Xe,h),b(Xe,Xe),v(Qe,Qe,Xe,u),m.push(...Qe),f.push(f.length),f.push(f.length)}}return m.length?new be(o,[["position",new Te(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(ye.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new we({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=_e(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new me(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ue(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=P(),r=g(at,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=We(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,s,n),u(tt,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,tt);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&K(r,p,tt),o&&h&&Z(o,h,tt),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,ot),!O(ot,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??nt,h=new Array;let d=!1;const g=m(Qe,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Be(e,m);if(0===t.length)continue;const o=Ue(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new Te(n,t,3,!0)],["normal",new Te(o.normals,o.indices,3,!0)]];s&&u.push(["color",new Te(s,t,4,!0)]),i&&u.push(["symbolColor",new Te(i,G(t.length),4,!0)]),a&&u.push(["uv0",new Te(a,t,2,!0)]),c&&u.push(["tangent",new Te(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new be(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Be(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Ee(e,o);case"smooth":return Oe(e,o)}}function Ee(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=$e(e,t,n,et);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Ee(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){$e(e,o,a,et);for(let e=0;e<3;e++){const r=3*o[a+e];Qe[0]=t[r],Qe[1]=t[r+1],Qe[2]=t[r+2],M(et,Qe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function Oe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=$e(e,t,a,et);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:P(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ve(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function $e(e,t,r,o){return Ve(e,t,r,Qe,Xe,Ze),w(Xe,Xe,Qe),w(Ze,Ze,Qe),C(Qe,Xe,Ze),b(o,Qe),o}function Ge(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function De(e="repeat"){if("string"==typeof e){const t=Le(e);return{s:t,t}}return{s:Le(e.horizontal),t:Le(e.vertical)}}function Le(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Ne(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function He(e,t,r){t.diffuse=e.toUnitRGB(),t.opacity="opaque"===r.alphaMode?1:e.a}function ke(e){return e.data??e.url}function ze(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function qe(e){const{offset:t,scale:r,rotation:o}=e??Ke;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function We(e){return e.vertexAttributes.color}function Ye(e){return 1===(e.material?.color?.a??0)}const Ke=new H,Je=P(),Qe=P(),Xe=P(),Ze=P(),et=P(),tt=f(),rt=f(),ot=V(),nt=[new L],at=P();export{Se as Graphics3DMeshFillSymbolLayer};
2
+ import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,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{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as h,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as g,add as x,scale as _,transformMat4 as y,transformMat3 as T,normalize as b,scaleAndAdd as v,subtract as w,cross as C,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as j,ONES as R,ZEROS as A,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,intersectsClippingArea as O,create as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as ce}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ue}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as me}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as fe,nanFallbackColor as he}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as de}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as ge}from"./SymbolComplexity.js";import{hasEdges as xe,createMaterial as _e}from"../support/edgeUtils.js";import{debugFlags as ye}from"../../support/debugFlags.js";import{Attribute as Te}from"../../webgl-engine/lib/Attribute.js";import{Geometry as be}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as ve}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as we}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Me}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Re,schematicMRRFactors as Ae}from"../../webgl-engine/materials/pbrUtils.js";const Pe=["mesh"];class Se extends fe{constructor(e,t,r,o){super(e,t,r,o,Ye(t)),this._materialInfoCache=new pe,this._fastUpdateProcessor=new de,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ye.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Me({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Me({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Me({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Pe,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=rt,{origin:i,transform:l}=r;if(!B(t,g(Qe,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache)}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=xe(this.symbolLayer)?2:0;return new ge({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ze(n),h=ze(a),p=qe(s),d=ze(i),g=qe(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${h},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:h}=t.material,p=ze(n),d=qe(a),g=ze(i),x=ze(u),_=qe(m),y=ze(f),T=qe(h);o.uid=[o.uid,`mrm:${e}`,`mrr:${r}`,`mrt:${p}`,`mrtt:${d}`,`emuid:${g}`,`ems:${c}`,`etmuid:${x}`,`ett:${_}`,`otmuid:${y}`,`ott:${T}`].join(","),o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=Ge(s),o.normalTextureTransform=Ge(l),o.emissiveTextureTransform=Ge(m),o.occlusionTextureTransform=Ge(h),o.metallicRoughnessTextureTransform=Ge(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=ke(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:De(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new ve(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(e,r){if(null!=e.colorTexture){const t=1!==r.textureAlphaMode,o=this._getInternalTexture(e.colorTexture,t,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}if(e.normalTexture&&(r.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){const o=e.emissiveColor?.toUnitRGB();r.emissiveBaseColor=j(t(o[0]),t(o[1]),t(o[2]))}e.emissiveStrength&&(r.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&He(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){const r=this._drivenProperties.color,o=this._drivenProperties.opacity;if(r)e.externalColor=S;else{const r=t??null;if(r){const t=r.toUnitRGBA();o&&(t[3]=1),e.externalColor=t}else e.externalColor=he}e.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(Ne(e)||null!=r&&r.a<1||o?.transparent||a),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return this._setInternalMaterialTextureParameters(i,l.material.parameters),l.material;const c={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},u=je({normalTexture:i.normalTexture,metallicRoughnessTexture:i.metallicRoughnessTexture,metallicFactor:i.metallic,roughnessFactor:i.roughness,emissiveTexture:i.emissiveTexture,emissiveFactor:i.emissiveColor?.toUnitRGB(),occlusionTexture:i.occlusionTexture}),m={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:A,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||c.isComponentTransparent};m.mrrFactors=u?Ae:[i.metallic,i.roughness,Re[2]],t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?0:2,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTextureAlphaMode(m,c),this._setInternalMaterialParameters(i,m,c);const f=new Ce(m,this._context);return c.material=f,this._materialInfoCache.set(i.uid,c),f}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return ce(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)$e(r,o,t,et),Ve(r,o,t,Qe,Xe,Ze),x(Qe,Qe,Xe),x(Qe,Qe,Ze),_(Qe,Qe,1/3),y(Qe,Qe,c),s.push(...Qe),T(et,et,u),b(et,et),v(Qe,Qe,et,n),s.push(...Qe),l.push(l.length),l.push(l.length)}return s.length?new be(this._debugFaceNormalMaterial,[["position",new Te(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],h=t[0].transformation,p=a(i(),h);"tangent"===r&&s(p,h);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Qe,s[e+0],s[e+1],s[e+2]),y(Qe,Qe,h),m.push(...Qe),g(Xe,l[r+0],l[r+1],l[r+2]),T(Xe,Xe,p),b(Xe,Xe),v(Qe,Qe,Xe,u),m.push(...Qe),f.push(f.length),f.push(f.length)}}return m.length?new be(o,[["position",new Te(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(ye.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new we({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=_e(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new me(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ue(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:h,renderCoordsHelper:p}=this._context,d=(e,t)=>le(e,h,r,p,t);return f.alignedSampledElevation=se(f,r,h.spatialReference,d,p),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=P(),r=g(at,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=We(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),h=this._createTangentBuffer(e,i,l,s),p=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:h}:this._transformOriginLocal(e,i,m,h);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:p,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??h;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:p(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,s,n),u(tt,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,tt);const h=r?r===l?new Float32Array(r.length):r:null,p=o?o===c?new Float32Array(o.length):o:null;return r&&h&&K(r,h,tt),o&&p&&Z(o,p,tt),{transformation:s,position:m,normal:h,tangent:p}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o&&o.length>0){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,ot),!O(ot,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,h=e.components??nt,p=new Array;let d=!1;const g=m(Qe,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of h){if(!this._validateFaces(e,m))return null;const t=Be(e,m);if(0===t.length)continue;const o=Ue(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new Te(n,t,3,!0)],["normal",new Te(o.normals,o.indices,3,!0)]];s&&u.push(["color",new Te(s,t,4,!0)]),i&&u.push(["symbolColor",new Te(i,G(t.length),4,!0)]),a&&u.push(["uv0",new Te(a,t,2,!0)]),c&&u.push(["tangent",new Te(c,t,4,!0)]);const h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new be(g,u,null,0,h);_.transformation=f,_.localOrigin=x,p.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),0===p.length?null:{geometries:p,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Be(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Ee(e,o);case"smooth":return Oe(e,o)}}function Ee(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=$e(e,t,n,et);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Ee(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){$e(e,o,a,et);for(let e=0;e<3;e++){const r=3*o[a+e];Qe[0]=t[r],Qe[1]=t[r+1],Qe[2]=t[r+2],M(et,Qe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function Oe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=$e(e,t,a,et);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:P(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ve(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function $e(e,t,r,o){return Ve(e,t,r,Qe,Xe,Ze),w(Xe,Xe,Qe),w(Ze,Ze,Qe),C(Qe,Xe,Ze),b(o,Qe),o}function Ge(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function De(e="repeat"){if("string"==typeof e){const t=Le(e);return{s:t,t}}return{s:Le(e.horizontal),t:Le(e.vertical)}}function Le(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Ne(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function He(e,t,r){t.diffuse=e.toUnitRGB(),t.opacity="opaque"===r.alphaMode?1:e.a}function ke(e){return e.data??e.url}function ze(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function qe(e){const{offset:t,scale:r,rotation:o}=e??Ke;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function We(e){return e.vertexAttributes.color}function Ye(e){return 1===(e.material?.color?.a??0)}const Ke=new H,Je=P(),Qe=P(),Xe=P(),Ze=P(),et=P(),tt=f(),rt=f(),ot=V(),nt=[new L],at=P();export{Se as Graphics3DMeshFillSymbolLayer};
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import e from"../../../../core/Logger.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as r,scale as i}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ONES as o,ZEROS as n,fromArray as s,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as l}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as p}from"./defaultSymbolComplexity.js";import{ElevationContext as c}from"./ElevationContext.js";import{zeroContext as u}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as d}from"./graphicUtils.js";import{Loadable as h}from"./Loadable.js";import{getSizeAttributeValue as y,getAttributeValue as f}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as g}from"../support/symbolColorUtils.js";const m=()=>e.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class v extends h{constructor(e,t,r,i,o=!0){super(r.schedule),this.symbol=e,this.symbolLayer=t,this._context=r,this._drivenOpacityFallbackAlwaysOpaque=o,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=m(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=i.renderPriority,this._renderPriorityStep=i.renderPriorityStep,this._elevationContext=new c,this.updateComplexity(),this.ignoreDrivers=i.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=_(this._context.renderer,o)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){const{complexity:e}=this;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,r=_(e,this._drivenOpacityFallbackAlwaysOpaque);return r.color!==t.color||r.opacity!==t.opacity||r.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||r.size!==t.size||r.rotation!==t.rotation}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,r,i){const o=`${i} geometry failed to be created`;e.projectionSuccess?this._logGeometryValidationWarnings(t,r,i)||!this._containsRenderableGeometry(e)&&"rings"===r&&t.length>0&&t[0].length>2&&m().warnOncePerTick(`${o} (rings are faulty and failed to triangulate)`):m().warnOncePerTick(`${o} (failed to project geometry to view spatial reference)`)}_containsRenderableGeometry(e){return"polygonIndices"in e?e.polygonIndices.length>0:e.lines.length>0}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,r){const i=`${r} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(m().warnOncePerTick(`${i} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(m().warnOncePerTick(`${i} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,r=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+r+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return m().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":l(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return C}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.setFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.setFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}createElevationContextForGraphic(e){const t=new c;return this.updateElevationContextForGraphic(t,e),t}updateElevationContextForGraphic(e,t){const r=t.geometry,i=this.getDefaultElevationInfo(r);e.unit=null!=this._elevationContext.unit?this._elevationContext.unit:i.unit,e.mode=this.getGeometryElevationMode(r,i),e.offsetMeters=this._elevationContext.meterUnitOffset??i.offset??0;const o=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===e.mode;o&&(e.mode="relative-to-ground",e.offsetMeters=0);const n=o?u:this._elevationContext.featureExpressionInfoContext;n?e.updateFeatureExpressionInfoContextForGraphic(n,t,this._context.layer):e.setFeatureExpressionInfoContext(null)}prepareSymbolLayerPatch(e){}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=b){const r=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?r:e?r*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(e,r=b){const i=this._getCombinedOpacity(e,r);if(this._drivenProperties.color)return d(null,i);const o=e?.toUnitRGB()??t;return d(o,i)}_getDrivenUInt8Color({color:e,opacity:t},r,i){const{color:s,opacity:a}=this._drivenProperties,l=r?.toUnitRGBA()??(i?o:n),p=s?e?.output??l:null,c=e||r||i,u=s?null:l[3];return d(p,a&&c?t?.output??u:null,255)}_getDrivenUInt8ColorWithNaNSupport({color:e,opacity:t},o,n){const l=o?s(o.toUnitRGBA()):a(NaN,NaN,NaN,n?NaN:0);return this._drivenProperties.color&&null!=e&&r(l,e.output),this._drivenProperties.opacity&&null!=t&&(l[3]=t.output),i(l,l,255),g(l,l)}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return p(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,r){switch(e){case"opacity":return this.layerOpacityChanged(t,r),!0;case"screenSizePerspectiveEnabled":return this.layerScreenSizePerspectiveChanged(t,r),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return 2!==this.layerElevationInfoChanged(t,r,e)}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,r);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;case"terrainTransparency":return this.terrainTransparencyChanged();default:return!1}}terrainTransparencyChanged(){return!0}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,r){let i=1;return e?.forEach(e=>{const o=t(e);if(null!=o){const t=e.graphic;this.updateElevationContextForGraphic(o.elevationContext,t),o.needsElevationUpdates=r(o.elevationContext.mode)}else i=2}),i}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,r=y(t.size,e.size),i=f(t.color,e.color),o=f(t.opacity,e.opacity);return a(r,i,o,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&m().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.source??null,color:this._fastUpdates?.visualVariables.color?.source??null,opacity:this._fastUpdates?.visualVariables.opacity?.source??null,rotation:this._fastUpdates?.visualVariables.rotation?.source??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function _(e,t){const r={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case"color":if(r.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const i=e.stops[t].color;i&&i.a<1&&(r.opacityAlwaysOpaque=!1)}break;case"opacity":r.opacity=!0,r.opacityAlwaysOpaque=!1;break;case"size":r.size=!0;break;case"rotation":r.rotation=!0}}),r}const x={mode:"on-the-ground",offset:0,unit:"meters"},C={mode:"absolute-height",offset:0,unit:"meters"},b={hasIntrinsicColor:!1},O=a(NaN,NaN,NaN,NaN);export{v as Graphics3DSymbolLayer,_ as getDrivenProperties,O as nanFallbackColor};
2
+ import e from"../../../../core/Logger.js";import{ONES as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as r,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ONES as i,ZEROS as n,fromArray as s,fromValues as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as l}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as p}from"./defaultSymbolComplexity.js";import{ElevationContext as c}from"./ElevationContext.js";import{zeroContext as u}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as d}from"./graphicUtils.js";import{Loadable as h}from"./Loadable.js";import{getSizeAttributeValue as y,getAttributeValue as f}from"../support/FastSymbolUpdates.js";import{encodeNaNUInt8 as m}from"../support/symbolColorUtils.js";const v=()=>e.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class g extends h{constructor(e,t,r,o,i=!0){super(r.schedule),this.symbol=e,this.symbolLayer=t,this._context=r,this._drivenOpacityFallbackAlwaysOpaque=i,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=v(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=o.renderPriority,this._renderPriorityStep=o.renderPriorityStep,this._elevationContext=new c,this.updateComplexity(),this.ignoreDrivers=o.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=_(this._context.renderer,i)),this._updateElevationContext()}destroy(){this.complexity=null,this._materials.length=0,super.destroy()}get view(){return this._context.stage.view}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get estimatedMemory(){const{complexity:e}=this;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}get usedMemory(){return this.estimatedMemory}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,r=_(e,this._drivenOpacityFallbackAlwaysOpaque);return r.color!==t.color||r.opacity!==t.opacity||r.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||r.size!==t.size||r.rotation!==t.rotation}get needsDrivenTransparentPass(){return this._hasDrivenColorOrOpacity&&!this._drivenProperties.opacityAlwaysOpaque}get _hasDrivenColorOrOpacity(){return this._drivenProperties.color||this._drivenProperties.opacity}_logGeometryCreationWarnings(e,t,r,o){const i=`${o} geometry failed to be created`;e.projectionSuccess?this._logGeometryValidationWarnings(t,r,o):v().warnOncePerTick(`${i} (failed to project geometry to view spatial reference)`)}_containsRenderableGeometry(e){return"polygonIndices"in e?e.polygonIndices.length>0:e.lines.length>0}get needsUpdateFocus(){return!1}_logGeometryValidationWarnings(e,t,r){const o=`${r} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(v().warnOncePerTick(`${o} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(v().warnOncePerTick(`${o} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,r=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+r+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return v().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":l(e)}return!0}_defaultElevationInfoNoZ(){return x}_defaultElevationInfoZ(){return C}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.setFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.setFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}createElevationContextForGraphic(e){const t=new c;return this.updateElevationContextForGraphic(t,e),t}updateElevationContextForGraphic(e,t){const r=t.geometry,o=this.getDefaultElevationInfo(r);e.unit=null!=this._elevationContext.unit?this._elevationContext.unit:o.unit,e.mode=this.getGeometryElevationMode(r,o),e.offsetMeters=this._elevationContext.meterUnitOffset??o.offset??0;const i=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===e.mode;i&&(e.mode="relative-to-ground",e.offsetMeters=0);const n=i?u:this._elevationContext.featureExpressionInfoContext;n?e.updateFeatureExpressionInfoContextForGraphic(n,t,this._context.layer):e.setFeatureExpressionInfoContext(null)}prepareSymbolLayerPatch(e){}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=b){const r=this.draped?1:this._getLayerOpacity();return this._drivenProperties.color?r:e?r*(this._drivenProperties.opacity?1:e.a):t.hasIntrinsicColor?r:0}_getCombinedOpacityAndColor(e,r=b){const o=this._getCombinedOpacity(e,r);if(this._drivenProperties.color)return d(null,o);const i=e?.toUnitRGB()??t;return d(i,o)}_getDrivenUInt8Color({color:e,opacity:t},r,o){const{color:s,opacity:a}=this._drivenProperties,l=r?.toUnitRGBA()??(o?i:n),p=s?e?.output??l:null,c=e||r||o,u=s?null:l[3];return d(p,a&&c?t?.output??u:null,255)}_getDrivenUInt8ColorWithNaNSupport({color:e,opacity:t},i,n){const l=i?s(i.toUnitRGBA()):a(NaN,NaN,NaN,n?NaN:0);return this._drivenProperties.color&&null!=e&&r(l,e.output),this._drivenProperties.opacity&&null!=t&&(l[3]=t.output),o(l,l,255),m(l,l)}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return p(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,r){switch(e){case"opacity":return this.layerOpacityChanged(t,r),!0;case"screenSizePerspectiveEnabled":return this.layerScreenSizePerspectiveChanged(t,r),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return 2!==this.layerElevationInfoChanged(t,r,e)}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,r);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;case"terrainTransparency":return this.terrainTransparencyChanged();default:return!1}}terrainTransparencyChanged(){return!0}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,r){let o=1;return e?.forEach(e=>{const i=t(e);if(null!=i){const t=e.graphic;this.updateElevationContextForGraphic(i.elevationContext,t),i.needsElevationUpdates=r(i.elevationContext.mode)}else o=2}),o}applyRendererDiff(e,t){return 0}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,r=y(t.size,e.size),o=f(t.color,e.color),i=f(t.opacity,e.opacity);return a(r,o,i,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&v().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.source??null,color:this._fastUpdates?.visualVariables.color?.source??null,opacity:this._fastUpdates?.visualVariables.opacity?.source??null,rotation:this._fastUpdates?.visualVariables.rotation?.source??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function _(e,t){const r={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach(e=>{switch(e.type){case"color":if(r.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const o=e.stops[t].color;o&&o.a<1&&(r.opacityAlwaysOpaque=!1)}break;case"opacity":r.opacity=!0,r.opacityAlwaysOpaque=!1;break;case"size":r.size=!0;break;case"rotation":r.rotation=!0}}),r}const x={mode:"on-the-ground",offset:0,unit:"meters"},C={mode:"absolute-height",offset:0,unit:"meters"},b={hasIntrinsicColor:!1},O=a(NaN,NaN,NaN,NaN);export{g as Graphics3DSymbolLayer,_ as getDrivenProperties,O as nanFallbackColor};