@arcgis/core 4.22.0-next.20211021 → 4.22.0-next.20211025

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 (440) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/00ac1ce56f9885a8be83.js +1 -0
  3. package/assets/esri/core/workers/chunks/01c9afe41ab4ccc597c9.js +1 -0
  4. package/assets/esri/core/workers/chunks/02a3d14adc504a51fa24.js +1 -0
  5. package/assets/esri/core/workers/chunks/035a9ab0202d5386b782.js +1 -0
  6. package/assets/esri/core/workers/chunks/062bace5505f13689c7d.js +1 -0
  7. package/assets/esri/core/workers/chunks/06c7745d813bcb540ce8.js +1 -0
  8. package/assets/esri/core/workers/chunks/0950b488a60b2abc21fc.js +1 -0
  9. package/assets/esri/core/workers/chunks/0af396f2e0de681113ef.js +1 -0
  10. package/assets/esri/core/workers/chunks/131838059f0f81d8eaee.js +1 -0
  11. package/assets/esri/core/workers/chunks/146cba0d172ec2f4eba2.js +1 -0
  12. package/assets/esri/core/workers/chunks/17e49c0dfa5a5a6213e2.js +1 -0
  13. package/assets/esri/core/workers/chunks/1a0b08190274725dc956.js +1 -0
  14. package/assets/esri/core/workers/chunks/1add7f0779accdf8d204.js +1 -0
  15. package/assets/esri/core/workers/chunks/20b81d11e6286d347bfc.js +1 -0
  16. package/assets/esri/core/workers/chunks/{e596bd3de960d1dc1c57.js → 2207580a78ee292ed9b8.js} +1 -1
  17. package/assets/esri/core/workers/chunks/2d3646a83465c75986f9.js +1 -0
  18. package/assets/esri/core/workers/chunks/2d38ee3ef3ebe32a1194.js +1 -0
  19. package/assets/esri/core/workers/chunks/3737dcc3c0dea3ca05d5.js +1 -0
  20. package/assets/esri/core/workers/chunks/3e2042e70647c1afa6aa.js +1 -0
  21. package/assets/esri/core/workers/chunks/3ebfaab2855a2236a95d.js +1 -0
  22. package/assets/esri/core/workers/chunks/{d6fe616192a8efbfbc3e.js → 440f8101402a4c0d7019.js} +1 -1
  23. package/assets/esri/core/workers/chunks/4587d770767966985e22.js +1 -0
  24. package/assets/esri/core/workers/chunks/487b8892fae85810a8c0.js +1 -0
  25. package/assets/esri/core/workers/chunks/4901a78f32c3ea6b823b.js +1 -0
  26. package/assets/esri/core/workers/chunks/496fe47fc4d28e1a716d.js +1 -0
  27. package/assets/esri/core/workers/chunks/{9f22f47d4b2e72d7bdcf.js → 4c010119c24510ea31bb.js} +2 -2
  28. package/assets/esri/core/workers/chunks/{9f22f47d4b2e72d7bdcf.js.LICENSE.txt → 4c010119c24510ea31bb.js.LICENSE.txt} +0 -0
  29. package/assets/esri/core/workers/chunks/4f5076e1f2b18ce8156d.js +1 -0
  30. package/assets/esri/core/workers/chunks/{f291ebc4b089bd1f0a3f.js → 50e86a6bb13042b1dbac.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{64d9a062c1f1ac08a3ac.js → 565020b1c02a8cb33c2b.js} +1 -1
  32. package/assets/esri/core/workers/chunks/{d78c60a22f76df7c48c7.js → 59640d78295e2e363f18.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{a0356f320a1b2fbd03f0.js → 5ac2b2598245aa17cdbd.js} +1 -1
  34. package/assets/esri/core/workers/chunks/5b4a8cce5601cc92c8a3.js +1 -0
  35. package/assets/esri/core/workers/chunks/5b92d5d4049622531109.js +1 -0
  36. package/assets/esri/core/workers/chunks/{751c1a2838b54a74a9a6.js → 5f3caa0ddb215342c728.js} +2 -2
  37. package/assets/esri/core/workers/chunks/615e995d5ce8fa044b09.js +1 -0
  38. package/assets/esri/core/workers/chunks/62a2453699e0dd2393b9.js +1 -0
  39. package/assets/esri/core/workers/chunks/67013547be1a7ae1670a.js +1 -0
  40. package/assets/esri/core/workers/chunks/67eddf4808f8888faeb4.js +1 -0
  41. package/assets/esri/core/workers/chunks/695dbedff2340aa019ba.js +1 -0
  42. package/assets/esri/core/workers/chunks/6a7e388c94206d2f61ff.js +1 -0
  43. package/assets/esri/core/workers/chunks/6e22b69d55e791ab3d9a.js +1 -0
  44. package/assets/esri/core/workers/chunks/71e6c0c5ef0aa7eb1703.js +1 -0
  45. package/assets/esri/core/workers/chunks/7a74e230439c5111f852.js +1 -0
  46. package/assets/esri/core/workers/chunks/7e76a8e6fa67e607d09e.js +1 -0
  47. package/assets/esri/core/workers/chunks/7fe4985ca0cb3e6d35c6.js +1 -0
  48. package/assets/esri/core/workers/chunks/8027330714ff5ffb020e.js +1 -0
  49. package/assets/esri/core/workers/chunks/844b564d1a422a17f6ac.js +1 -0
  50. package/assets/esri/core/workers/chunks/856f9281a08cb032238e.js +1 -0
  51. package/assets/esri/core/workers/chunks/89b4983de872780e9aa1.js +1 -0
  52. package/assets/esri/core/workers/chunks/8f3bc0cd2c2b01ab80cd.js +1 -0
  53. package/assets/esri/core/workers/chunks/8fd912e325ccd48b98a9.js +1 -0
  54. package/assets/esri/core/workers/chunks/901907a5c01f0fd1478f.js +1 -0
  55. package/assets/esri/core/workers/chunks/92a0b88a14c92239df8a.js +1 -0
  56. package/assets/esri/core/workers/chunks/972e9aeb3c29c9bf441a.js +1 -0
  57. package/assets/esri/core/workers/chunks/9758c34ce61c3714515a.js +1 -0
  58. package/assets/esri/core/workers/chunks/{457ea4feaa006d60c6b1.js → 9a04d087a29f0f3937a3.js} +1 -1
  59. package/assets/esri/core/workers/chunks/9b0bb171224b35ce2031.js +1 -0
  60. package/assets/esri/core/workers/chunks/9cbe7afdaef8720dfc8d.js +1 -0
  61. package/assets/esri/core/workers/chunks/9ccde5b6562f0007fe45.js +1 -0
  62. package/assets/esri/core/workers/chunks/9d320bbeedeea15522ab.js +1 -0
  63. package/assets/esri/core/workers/chunks/a001b3b4527817548094.js +1 -0
  64. package/assets/esri/core/workers/chunks/{197b72bca45065e0eb4a.js → a0c580d4a1915ddd3fe4.js} +1 -1
  65. package/assets/esri/core/workers/chunks/a4a9c15929b43d83701f.js +1 -0
  66. package/assets/esri/core/workers/chunks/a54d11f44721f808b82f.js +1 -0
  67. package/assets/esri/core/workers/chunks/a646a11673d513c00e7a.js +1 -0
  68. package/assets/esri/core/workers/chunks/a792e2bc7cafdc29f05e.js +1 -0
  69. package/assets/esri/core/workers/chunks/acae1771697034f265b1.js +1 -0
  70. package/assets/esri/core/workers/chunks/af2ee804a9c63eea610c.js +1 -0
  71. package/assets/esri/core/workers/chunks/b28b487047da3aeef3fd.js +1 -0
  72. package/assets/esri/core/workers/chunks/b3e57824a5855cb37a96.js +1 -0
  73. package/assets/esri/core/workers/chunks/b89449ead32e4cd21edd.js +1 -0
  74. package/assets/esri/core/workers/chunks/b99891ed5a02cab02173.js +1 -0
  75. package/assets/esri/core/workers/chunks/bac84bc621be73a7a4bc.js +1 -0
  76. package/assets/esri/core/workers/chunks/{25037dcf8a0c72b7b647.js → bbe068388167e9dd0c11.js} +1 -1
  77. package/assets/esri/core/workers/chunks/c271a1857bcc4e9a36dd.js +1 -0
  78. package/assets/esri/core/workers/chunks/{eb3035e49a45ecc82575.js → c5030664720fcdc6d85e.js} +1 -1
  79. package/assets/esri/core/workers/chunks/c534ed122f8a1202d3a3.js +1 -0
  80. package/assets/esri/core/workers/chunks/c5ef2e28b0c539ddb6a7.js +1 -0
  81. package/assets/esri/core/workers/chunks/c65e5ccfae03d148d82b.js +1 -0
  82. package/assets/esri/core/workers/chunks/c91660f3982be4e03705.js +1 -0
  83. package/assets/esri/core/workers/chunks/ce93113b99bdbeddd07b.js +1 -0
  84. package/assets/esri/core/workers/chunks/cf2d408e669cfa2c65be.js +1 -0
  85. package/assets/esri/core/workers/chunks/d08f63ffeecefa02ad91.js +1 -0
  86. package/assets/esri/core/workers/chunks/{8d33644192c01e5416b4.js → d1a71b58ef62e71979c5.js} +1 -1
  87. package/assets/esri/core/workers/chunks/d30eade5afecd334f6cb.js +1 -0
  88. package/assets/esri/core/workers/chunks/d8782d0856b9d815cb6c.js +1 -0
  89. package/assets/esri/core/workers/chunks/db16c21b650001502e6c.js +1 -0
  90. package/assets/esri/core/workers/chunks/db18110c57253a31ac96.js +1 -0
  91. package/assets/esri/core/workers/chunks/dbaa5fb466d6c0214f24.js +1 -0
  92. package/assets/esri/core/workers/chunks/deae370788a7aacf4dd5.js +1 -0
  93. package/assets/esri/core/workers/chunks/e6ca132e1eeea3aa174e.js +1 -0
  94. package/assets/esri/core/workers/chunks/e878ccc431729ef3360f.js +1 -0
  95. package/assets/esri/core/workers/chunks/eb124f15ad4b9193f00a.js +1 -0
  96. package/assets/esri/core/workers/chunks/ebc71c06c1c22aaef54e.js +1 -0
  97. package/assets/esri/core/workers/chunks/f183da283af0836421ab.js +1 -0
  98. package/assets/esri/core/workers/chunks/f42bdc2a134833d33b4e.js +1 -0
  99. package/assets/esri/core/workers/chunks/{736d628cda4e02d40337.js → f8612c2fc5739e98be58.js} +1 -1
  100. package/assets/esri/core/workers/chunks/f965e3e5f6f4f9ba54ac.js +1 -0
  101. package/assets/esri/core/workers/chunks/fa4089640f480b69962e.js +1 -0
  102. package/assets/esri/core/workers/chunks/fb219563e5169ea67d68.js +1 -0
  103. package/assets/esri/libs/i3s/i3s.wasm +0 -0
  104. package/chunks/ChapmanAtmosphere.glsl.js +56 -77
  105. package/chunks/Clouds.glsl.js +1 -1
  106. package/chunks/Pattern.glsl.js +9 -11
  107. package/chunks/RibbonLine.glsl.js +60 -68
  108. package/chunks/i3s.js +1 -1
  109. package/chunks/mat4.js +1 -1
  110. package/chunks/vec3.js +1 -1
  111. package/core/Collection.js +1 -1
  112. package/core/Loadable.js +1 -1
  113. package/core/accessorSupport/ensureType.js +1 -1
  114. package/core/promiseUtils.js +1 -1
  115. package/core/support/OwningCollection.js +1 -1
  116. package/core/workers/RemoteClient.js +1 -1
  117. package/core/workers/WorkerOwner.js +1 -1
  118. package/core/workers/workers.js +2 -2
  119. package/geometry/projection.js +1 -1
  120. package/identity/IdentityManagerBase.js +1 -1
  121. package/interfaces.d.ts +205 -497
  122. package/layers/ElevationLayer.js +1 -1
  123. package/layers/GeoJSONLayer.js +1 -1
  124. package/layers/ImageryTileLayer.js +1 -1
  125. package/layers/VectorTileLayer.js +1 -1
  126. package/layers/VoxelWasmPerScene.js +1 -1
  127. package/layers/WCSLayer.js +1 -1
  128. package/layers/analyses/AreaMeasurement3D.js +1 -1
  129. package/layers/analyses/DirectLineMeasurement3D.js +1 -1
  130. package/layers/analyses/Slice.js +1 -1
  131. package/layers/effects/EffectList.js +1 -1
  132. package/layers/effects/effects.js +1 -1
  133. package/layers/effects/jsonUtils.js +1 -1
  134. package/layers/effects/parser.js +1 -1
  135. package/layers/effects/utils.js +5 -0
  136. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  137. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  138. package/layers/graphics/data/QueryEngine.js +1 -1
  139. package/layers/graphics/data/QueryEngineResult.js +1 -1
  140. package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
  141. package/layers/mixins/ImageryTileMixin.js +1 -1
  142. package/layers/support/RasterWorker.js +1 -1
  143. package/layers/support/TilemapCache.js +1 -1
  144. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  145. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  146. package/layers/support/rasterDatasets/WCSRaster.js +1 -1
  147. package/layers/support/rasterFunctions/pixelUtils.js +1 -1
  148. package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
  149. package/package.json +2 -2
  150. package/portal/support/portalLayers.js +1 -1
  151. package/request.js +1 -1
  152. package/smartMapping/renderers/support/utils.js +1 -1
  153. package/smartMapping/statistics/support/WorkerClient.js +1 -1
  154. package/smartMapping/statistics/support/statsWorker.js +1 -1
  155. package/smartMapping/statistics/support/utils.js +1 -1
  156. package/smartMapping/support/adapters/CSVLayerAdapter.js +1 -1
  157. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  158. package/smartMapping/support/adapters/SceneLayerAdapter.js +1 -1
  159. package/smartMapping/support/adapters/support/utils.js +1 -1
  160. package/statistics/utils.js +1 -1
  161. package/support/GraphicsCollection.js +1 -1
  162. package/support/revision.js +1 -1
  163. package/symbols/FillSymbol3DLayer.js +1 -1
  164. package/symbols/IconSymbol3DLayer.js +1 -1
  165. package/symbols/LineSymbol3DLayer.js +1 -1
  166. package/symbols/patterns/LinePattern3D.js +5 -0
  167. package/symbols/patterns/LineStylePattern3D.d.ts +4 -0
  168. package/symbols/patterns/LineStylePattern3D.js +5 -0
  169. package/symbols/patterns/StylePattern3D.js +1 -1
  170. package/symbols/patterns/lineStyles.js +5 -0
  171. package/symbols/patterns/utils.js +1 -1
  172. package/symbols/support/Symbol3DFillMaterial.js +1 -1
  173. package/symbols/support/Symbol3DIconOutline.js +5 -0
  174. package/symbols/support/Symbol3DMaterial.js +1 -1
  175. package/symbols/support/Symbol3DOutline.js +1 -1
  176. package/symbols/support/defaults3D.js +1 -1
  177. package/symbols/support/previewSymbol3D.js +1 -1
  178. package/symbols/support/symbolLayerUtils3D.js +1 -1
  179. package/views/2d/engine/vectorTiles/TileParser.js +1 -1
  180. package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
  181. package/views/2d/engine/vectorTiles/style/StyleRepository.js +1 -1
  182. package/views/2d/engine/webgl/effects/HittestEffect.js +1 -1
  183. package/views/2d/layers/FeatureLayerView2D.js +1 -1
  184. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  185. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  186. package/views/2d/layers/VectorTileLayerView2D.js +1 -1
  187. package/views/2d/layers/features/controllers/EditsQueue.js +1 -1
  188. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  189. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  190. package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
  191. package/views/2d/layers/support/FeatureLayerProxy.js +1 -1
  192. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  193. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  194. package/views/3d/environment/CloudsGenerator.js +1 -1
  195. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  196. package/views/3d/environment/PanoramicAtmosphere.js +1 -1
  197. package/views/3d/environment/SimpleAtmosphere.js +1 -1
  198. package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
  199. package/views/3d/externalRenderers.js +1 -1
  200. package/views/3d/interactive/Manipulator3D.js +1 -1
  201. package/views/3d/interactive/analysisTools/slice/SliceTool.js +1 -1
  202. package/views/3d/interactive/analysisTools/slice/images/Factory.js +5 -0
  203. package/views/3d/interactive/analysisTools/slice/sliceToolConfig.js +1 -1
  204. package/views/3d/interactive/analysisTools/slice/sliceToolUtils.js +1 -1
  205. package/views/3d/interactive/editingTools/settings.js +1 -1
  206. package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
  207. package/views/3d/interactive/graphics/Slice/SliceController.js +1 -1
  208. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  209. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
  210. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
  211. package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
  212. package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
  213. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  214. package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
  215. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  216. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  217. package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
  218. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  219. package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
  220. package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
  221. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  222. package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
  223. package/views/3d/layers/DynamicLayerView3D.js +1 -1
  224. package/views/3d/layers/I3SMeshView3D.js +1 -1
  225. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  226. package/views/3d/layers/VectorTileLayerView3D.js +1 -1
  227. package/views/3d/layers/analyses/AreaMeasurement3D/AreaMeasurementView3D.js +1 -1
  228. package/views/3d/layers/analyses/AreaMeasurement3D/support/AreaMeasurementPathHelper.js +1 -1
  229. package/views/3d/layers/analyses/AreaMeasurement3D/support/AreaMeasurementVisualization.js +1 -1
  230. package/views/3d/layers/analyses/DirectLineMeasurement3D/DirectLineMeasurementView3D.js +1 -1
  231. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  232. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  233. package/views/3d/layers/graphics/ElevationQuery.js +1 -1
  234. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  235. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  236. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  237. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  238. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  239. package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
  240. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  241. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  242. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  243. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  244. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  245. package/views/3d/layers/graphics/Graphics3DSymbol.js +1 -1
  246. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  247. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  248. package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
  249. package/views/3d/layers/graphics/Labeler.js +1 -1
  250. package/views/3d/layers/graphics/Loadable.js +1 -1
  251. package/views/3d/layers/graphics/ObjectResourceCache.js +1 -1
  252. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  253. package/views/3d/layers/graphics/graphicUtils.js +1 -1
  254. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  255. package/views/3d/layers/graphics/pointUtils.js +1 -1
  256. package/views/3d/layers/i3s/I3SAttributeOverrides.js +1 -1
  257. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  258. package/views/3d/layers/i3s/I3SStreamDataController.js +1 -1
  259. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  260. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  261. package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
  262. package/views/3d/layers/support/patternUtils.js +1 -1
  263. package/views/3d/state/GoToOperation.js +1 -1
  264. package/views/3d/state/ViewStateManager.js +1 -1
  265. package/views/3d/support/LaserLineRenderer.js +1 -1
  266. package/views/3d/support/SharedSymbolResources.js +1 -1
  267. package/views/3d/support/StreamDataLoader.js +1 -1
  268. package/views/3d/support/StreamTextureCollection.js +5 -0
  269. package/views/3d/support/TextureCollection.js +1 -1
  270. package/views/3d/support/debugFlags.js +1 -1
  271. package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
  272. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  273. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  274. package/views/3d/terrain/OverlayManager.js +1 -1
  275. package/views/3d/terrain/OverlayRenderTarget.js +1 -1
  276. package/views/3d/terrain/OverlayRenderer.js +1 -1
  277. package/views/3d/terrain/Tile.js +1 -1
  278. package/views/3d/webgl-engine/Stage.js +1 -1
  279. package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
  280. package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +13 -12
  281. package/views/3d/webgl-engine/core/shaderLibrary/shading/Reprojection.glsl.js +1 -1
  282. package/views/3d/webgl-engine/core/shaderLibrary/util/CloudsParallaxShading.glsl.js +10 -3
  283. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js +1 -1
  284. package/views/3d/webgl-engine/lib/Camera.js +1 -1
  285. package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
  286. package/views/3d/webgl-engine/lib/GLMaterialTexture.js +1 -1
  287. package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
  288. package/views/3d/webgl-engine/lib/Material.js +1 -1
  289. package/views/3d/webgl-engine/lib/ModelDirtySet.js +1 -1
  290. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  291. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  292. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  293. package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
  294. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  295. package/views/3d/webgl-engine/lib/TextTexture.js +1 -1
  296. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  297. package/views/3d/webgl-engine/lib/Texture.js +1 -1
  298. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  299. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  300. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  301. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  302. package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
  303. package/views/3d/webgl-engine/lib/lodRendering/LodLevel.js +1 -1
  304. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  305. package/views/3d/webgl-engine/lib/lodRendering/LodResources.js +1 -1
  306. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  307. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  308. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  309. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  310. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  311. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  312. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  313. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  314. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  315. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  316. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  317. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  318. package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
  319. package/views/3d/webgl-engine/materials/WaterGLMaterial.js +1 -1
  320. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  321. package/views/3d/webgl-engine/materials/lineStippleUtils.js +1 -1
  322. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  323. package/views/3d/webgl-engine/parts/Model.js +1 -1
  324. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  325. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  326. package/views/LayerViewManager.js +1 -1
  327. package/views/SceneView.js +1 -1
  328. package/views/ToolViewManager.js +1 -1
  329. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  330. package/views/support/AllocationTracer.js +1 -1
  331. package/views/support/DefaultsFromMap.js +1 -1
  332. package/views/support/QueueProcessor.js +1 -1
  333. package/views/webgl/capabilities/load.js +1 -1
  334. package/webscene/Slide.js +1 -1
  335. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  336. package/widgets/AreaMeasurement3D/AreaMeasurement3DViewModel.js +1 -1
  337. package/widgets/BuildingExplorer/support/layerUtils.js +1 -1
  338. package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
  339. package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
  340. package/widgets/Editor/UpdateWorkflow.js +1 -1
  341. package/widgets/Feature/FeatureViewModel.js +1 -1
  342. package/widgets/Home/HomeViewModel.js +1 -1
  343. package/widgets/Locate/LocateViewModel.js +1 -1
  344. package/widgets/Popup/PopupViewModel.js +1 -1
  345. package/widgets/Search/SearchViewModel.js +1 -1
  346. package/widgets/Search.js +1 -1
  347. package/widgets/Sketch/SketchViewModel.js +1 -1
  348. package/widgets/Slice/SliceViewModel.js +1 -1
  349. package/widgets/TimeSlider/TimeSliderViewModel.js +1 -1
  350. package/assets/esri/core/workers/chunks/0283801d442984997abe.js +0 -1
  351. package/assets/esri/core/workers/chunks/0419e14a520b8fcf3e7a.js +0 -1
  352. package/assets/esri/core/workers/chunks/05318446b6a40caea361.js +0 -1
  353. package/assets/esri/core/workers/chunks/09e714d4381649348ac9.js +0 -1
  354. package/assets/esri/core/workers/chunks/0cecd668b9d5d3f83293.js +0 -1
  355. package/assets/esri/core/workers/chunks/13a73a88efd4f464173e.js +0 -1
  356. package/assets/esri/core/workers/chunks/1576727e8174d672555b.js +0 -1
  357. package/assets/esri/core/workers/chunks/1a3cbeb0a53d03a51dad.js +0 -1
  358. package/assets/esri/core/workers/chunks/1b8524b617bfc6fe422c.js +0 -1
  359. package/assets/esri/core/workers/chunks/1dc1d750046912ff6cef.js +0 -1
  360. package/assets/esri/core/workers/chunks/21fa174c114640be5e40.js +0 -1
  361. package/assets/esri/core/workers/chunks/2a3f6e56079620421a02.js +0 -1
  362. package/assets/esri/core/workers/chunks/2a5bcc73e55986ad93fe.js +0 -1
  363. package/assets/esri/core/workers/chunks/2a6f2e3d639aae491171.js +0 -1
  364. package/assets/esri/core/workers/chunks/2c17d1bad17bcee53f7d.js +0 -1
  365. package/assets/esri/core/workers/chunks/2cea27a0d07aa9a88ad4.js +0 -1
  366. package/assets/esri/core/workers/chunks/2e193d97d199b29b00c2.js +0 -1
  367. package/assets/esri/core/workers/chunks/2eb41fdf0d0a3b0c3232.js +0 -1
  368. package/assets/esri/core/workers/chunks/2f09ea639ca5d1d6ca7e.js +0 -1
  369. package/assets/esri/core/workers/chunks/2fb847ab1440bd1bdf15.js +0 -1
  370. package/assets/esri/core/workers/chunks/402d22ebbae608760b4f.js +0 -1
  371. package/assets/esri/core/workers/chunks/44daef7f0cbc6f6af09f.js +0 -1
  372. package/assets/esri/core/workers/chunks/46899156159e398c693f.js +0 -1
  373. package/assets/esri/core/workers/chunks/46bf8921db25845c63c0.js +0 -1
  374. package/assets/esri/core/workers/chunks/4eb23554e375350f73b5.js +0 -1
  375. package/assets/esri/core/workers/chunks/551917be63a513dfa4de.js +0 -1
  376. package/assets/esri/core/workers/chunks/564f6f5484bcb13ebb2b.js +0 -1
  377. package/assets/esri/core/workers/chunks/61df67ae47b7fb5875d9.js +0 -1
  378. package/assets/esri/core/workers/chunks/62642a8fc7bafe339984.js +0 -1
  379. package/assets/esri/core/workers/chunks/6304f4e53027df04eb8f.js +0 -1
  380. package/assets/esri/core/workers/chunks/6331987617ad166ea098.js +0 -1
  381. package/assets/esri/core/workers/chunks/6b13fcbc71c0088d317e.js +0 -1
  382. package/assets/esri/core/workers/chunks/6f7a6841e7269d2764ad.js +0 -1
  383. package/assets/esri/core/workers/chunks/70110efd2de23d9a5263.js +0 -1
  384. package/assets/esri/core/workers/chunks/7eae3f0588cde44fce39.js +0 -1
  385. package/assets/esri/core/workers/chunks/80d3c7a429c6412f1a8d.js +0 -1
  386. package/assets/esri/core/workers/chunks/80deebdf54bea04a0889.js +0 -1
  387. package/assets/esri/core/workers/chunks/81aa5fe7dcb4fdeb0974.js +0 -1
  388. package/assets/esri/core/workers/chunks/840d08b41913cad4df89.js +0 -1
  389. package/assets/esri/core/workers/chunks/85d154aeb511c5d70bb1.js +0 -1
  390. package/assets/esri/core/workers/chunks/8681e99e2bc9ece61c43.js +0 -1
  391. package/assets/esri/core/workers/chunks/8e5ef967f6518f4c93b1.js +0 -1
  392. package/assets/esri/core/workers/chunks/8edd7f70c8b95c34125c.js +0 -1
  393. package/assets/esri/core/workers/chunks/9044a7b90a53312b6392.js +0 -1
  394. package/assets/esri/core/workers/chunks/905b4dfc1ce57a225fa4.js +0 -1
  395. package/assets/esri/core/workers/chunks/945f90b31ebfae623ea0.js +0 -1
  396. package/assets/esri/core/workers/chunks/9943fd69b67cd1871d68.js +0 -1
  397. package/assets/esri/core/workers/chunks/9ad91c23480ffb656030.js +0 -1
  398. package/assets/esri/core/workers/chunks/9d103681372ab01a4147.js +0 -1
  399. package/assets/esri/core/workers/chunks/9d3230f59b4c4d1b2713.js +0 -1
  400. package/assets/esri/core/workers/chunks/9db75bc0980d16b730a1.js +0 -1
  401. package/assets/esri/core/workers/chunks/a0659b8bdc067da7badd.js +0 -1
  402. package/assets/esri/core/workers/chunks/a480ee9a994410177961.js +0 -1
  403. package/assets/esri/core/workers/chunks/a9b279975d7df0f295d7.js +0 -1
  404. package/assets/esri/core/workers/chunks/aa3abaa5ad4a5a3bcb84.js +0 -1
  405. package/assets/esri/core/workers/chunks/aa8e607f908297786675.js +0 -1
  406. package/assets/esri/core/workers/chunks/ab5a302b5f62d38293f9.js +0 -1
  407. package/assets/esri/core/workers/chunks/abd6a84396e0eb3f01ad.js +0 -1
  408. package/assets/esri/core/workers/chunks/abe9f8516b03a3fb0477.js +0 -1
  409. package/assets/esri/core/workers/chunks/aff6aa5c7f75f8e052d9.js +0 -1
  410. package/assets/esri/core/workers/chunks/b601cc5304b132536239.js +0 -1
  411. package/assets/esri/core/workers/chunks/b85f614ddbddd3c3007e.js +0 -1
  412. package/assets/esri/core/workers/chunks/b944f4ab25a691b3e611.js +0 -1
  413. package/assets/esri/core/workers/chunks/bbdacddb61e651ca0098.js +0 -1
  414. package/assets/esri/core/workers/chunks/c2fa728e805637a1783e.js +0 -1
  415. package/assets/esri/core/workers/chunks/c901f5f85d962254fc2c.js +0 -1
  416. package/assets/esri/core/workers/chunks/ca173b908d89a4e334f6.js +0 -1
  417. package/assets/esri/core/workers/chunks/cc2ef3bfa1f614d7452c.js +0 -1
  418. package/assets/esri/core/workers/chunks/cdb32a9ac9f5804c4212.js +0 -1
  419. package/assets/esri/core/workers/chunks/ce9a4997973da80141a5.js +0 -1
  420. package/assets/esri/core/workers/chunks/d0674b50a358d3bb9db2.js +0 -1
  421. package/assets/esri/core/workers/chunks/d18b7b4b3b9bea7204b0.js +0 -1
  422. package/assets/esri/core/workers/chunks/d2ce983f7babdf18a0ed.js +0 -1
  423. package/assets/esri/core/workers/chunks/d38a0d867dc6cecdc551.js +0 -1
  424. package/assets/esri/core/workers/chunks/e39ca33e9e463c1d6060.js +0 -1
  425. package/assets/esri/core/workers/chunks/e471d103205018a5cf7f.js +0 -1
  426. package/assets/esri/core/workers/chunks/e542fb044fc96f7e8af2.js +0 -1
  427. package/assets/esri/core/workers/chunks/e94e00a28591337b2def.js +0 -1
  428. package/assets/esri/core/workers/chunks/eb2709ccbc001f42ac1b.js +0 -1
  429. package/assets/esri/core/workers/chunks/f905511ca5f9b59fc17f.js +0 -1
  430. package/assets/esri/core/workers/chunks/f910e80dd87727af5184.js +0 -1
  431. package/assets/esri/core/workers/chunks/f9300a24305b0af1d227.js +0 -1
  432. package/assets/esri/core/workers/chunks/fa1e1ac5b3ef7bdf8a78.js +0 -1
  433. package/assets/esri/core/workers/chunks/fce76a84c7d25d8d47e8.js +0 -1
  434. package/assets/esri/core/workers/chunks/fef4f97fbe861a1b60e8.js +0 -1
  435. package/layers/AreaMeasurementLayer.d.ts +0 -4
  436. package/layers/DirectLineMeasurementLayer.d.ts +0 -4
  437. package/symbols/support/symbolPreview.d.ts +0 -4
  438. package/symbols/support/symbolPreview.js +0 -5
  439. package/views/3d/layers/AreaMeasurementLayerView3D.d.ts +0 -4
  440. package/views/3d/layers/DirectLineMeasurementLayerView3D.d.ts +0 -4
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import{isSome as t,isNone as r,get as o}from"../../../../core/maybe.js";import{f as a,t as s}from"../../../../chunks/mat3.js";import{c as n}from"../../../../chunks/mat3f64.js";import{u as i,m as l,b as u}from"../../../../chunks/mat4.js";import{b as c,c as m}from"../../../../chunks/mat4f64.js";import{b as h,a as p,d as f,n as d,f as g,c as x}from"../../../../chunks/vec3.js";import{Z as _,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as T,projectBuffer as C,computeTranslationToOriginAndRotation as A,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as P,intersectsClippingArea as B}from"../../../../geometry/support/aaBoundingBox.js";import R from"../../../../geometry/support/MeshComponent.js";import E from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{BufferViewVec3f64 as F,BufferViewVec3f as I}from"../../../../geometry/support/buffer/BufferView.js";import{t as O,a as S}from"../../../../chunks/vec32.js";import{transformPosition as N,transformNormal as V,projectNormalToPCPF as U,transformTangent as L,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as G}from"../../../../layers/graphics/dehydratedFeatures.js";import{perObjectElevationAligner as D}from"./ElevationAligners.js";import{needsElevationUpdates3D as z}from"./elevationAlignmentUtils.js";import{ElevationContext as k}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as H}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as W}from"./Graphics3DSymbolLayer.js";import{createMaterial as q}from"../support/edgeUtils.js";import{parseColorMixMode as Y,encodeSymbolColor as Z}from"../support/symbolColorUtils.js";import J from"../../support/debugFlags.js";import{Geometry as K}from"../../webgl-engine/lib/Geometry.js";import{generateDefaultIndexArray as Q}from"../../webgl-engine/lib/geometryDataUtils.js";import{Object3D as X}from"../../webgl-engine/lib/Object3D.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as te}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as re}from"../../webgl-engine/materials/NativeLineMaterial.js";const oe=["mesh"];class ae extends W{constructor(e,t,r,o){super(e,t,r,o),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){J.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new re({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new re({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,oe,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new k),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}layerOpacityChanged(e,r){const o=this._getLayerOpacity();return this._materials.forEach((e=>{e.material.setParameterValues({layerOpacity:o});const t=e.material.params;this._setMaterialTransparentParameter(t,e),e.material.setParameterValues({transparent:t.transparent})})),e.forEach((e=>{const a=r(e);t(a)&&a.layerOpacityChanged(o,this._context.isAsync)})),!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,z)}slicePlaneEnabledChanged(e,r){return this._materials.forEach((e=>{e.material.setParameterValues({slicePlaneEnabled:this._context.slicePlaneEnabled})})),e.forEach((e=>{const o=r(e);t(o)&&o.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameterValues({usePBR:e}))),!0}pixelRatioChanged(){return!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return r(t)?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,normalTexture:n,doubleSided:i,alphaCutoff:l,alphaMode:u}=t.material,c=this._colorOrTextureUid(a),m=this._colorOrTextureUid(s),h=this._colorOrTextureUid(n);if(o.color=a,o.colorTexture=s,o.normalTexture=n,o.uid=`${o.uid},cmuid:${c},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${u}`,t.material instanceof E){const{metallic:e,roughness:r,metallicRoughnessTexture:a,emissiveColor:s,emissiveTexture:n,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(a),u=this._colorOrTextureUid(s),c=this._colorOrTextureUid(n),m=this._colorOrTextureUid(i);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=s,o.emissiveTexture=n,o.occlusionTexture=i,o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${u},etmuid:${c},otmuid:${m}`}return o}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const r=this._getInternalTexture(e,1);return t(r)?r.id:void 0}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new ee(r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:1!==t}),this._textures.set(o,a),this._context.stage.add(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}_setInternalMaterialParameters(r,o){if(t(r.color)&&this._setInternalColorValueParameters(r.color,o),t(r.colorTexture)){const e=this._getInternalTexture(r.colorTexture,o.textureAlphaMode);t(e)?(o.textureId=e.id,o.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):o.textureId=void 0}t(r.normalTexture)&&(o.normalTextureId=this._getInternalTextureId(r.normalTexture)),t(r.emissiveColor)&&(o.emissiveFactor=e.toUnitRGB(r.emissiveColor)),t(r.emissiveTexture)&&(o.emissiveTextureId=this._getInternalTextureId(r.emissiveTexture)),t(r.occlusionTexture)&&(o.occlusionTextureId=this._getInternalTextureId(r.occlusionTexture)),t(r.metallicRoughnessTexture)&&(o.metallicRoughnessTextureId=this._getInternalTextureId(r.metallicRoughnessTexture))}_setExternalMaterialParameters(r){const o=this._drivenProperties.color;let a=t(this.symbolLayer.material)?this.symbolLayer.material.colorMixMode:null;if(o)r.externalColor=v;else{const o=t(this.symbolLayer.material)?this.symbolLayer.material.color:null;t(o)?r.externalColor=e.toUnitRGBA(o):(a=null,r.externalColor=v)}a&&(r.colorMixMode=a),r.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(r(t))return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,r){var o,a,s;const n=null==(o=r.material)?void 0:o.color,i=null==(a=r.material)?void 0:a.colorTexture,l=null==(s=r.material)?void 0:s.alphaMode,u="blend"===l,c=!("opaque"===l)&&(this._hasTransparentVertexColors(e)||t(n)&&n.a<1||t(i)&&i.transparent||u),m=this._materialProperties(e,r,c),h=this._materials.get(m.uid);if(h)return h.material;const p={material:null,isComponentTransparent:c,alphaMode:r.material?r.material.alphaMode:"opaque"},f=null==m.metallicRoughnessTexture&&null==m.metallic&&null==m.roughness,d={usePBR:this._usePBR(),isSchematic:f,vertexColors:m.hasVertexColors,symbolColors:m.hasSymbolVertexColors,vertexTangents:m.hasVertexTangents,ambient:_,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),slicePlaneEnabled:this._context.slicePlaneEnabled,initTextureTransparent:!0};f||(d.mrrFactors=[null!=m.metallic?m.metallic:1,null!=m.roughness?m.roughness:1,.5]),r.material&&(d.doubleSided=r.material.doubleSided,d.cullFace=r.material.doubleSided?0:2,d.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(d),this._setMaterialTransparentParameter(d,p),this._setInternalMaterialParameters(m,d);const g=new te(d);return p.material=g,this._materials.set(m.uid,p),this._context.stage.add(g),g}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?3:1:e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_addDebugNormals(e,t,r,o){const a=t.length,s=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*s,e.extent.height*s,e.extent.zmax-e.extent.zmin),i=[],l=[],u=[],m=[];for(let c=0;c<a;c++){const e=t[c],r=e.vertexAttributes.get("position"),o=e.vertexAttributes.get("normal"),a=e.indices.get("position"),s=e.indices.get("normal"),f=r.data,d=o.data;for(let t=0;t<a.length;t++){const e=3*a[t],r=3*s[t];for(let t=0;t<3;t++)i.push(f[e+t]);for(let t=0;t<3;t++)i.push(f[e+t]+d[r+t]*n);if(l.push(l.length),l.push(l.length),t%3==0){this._calculateFaceNormal(f,a,t,ue),this._getFaceVertices(f,a,t,ne,ie,le),h(ne,ne,ie),h(ne,ne,le),p(ne,ne,1/3);for(let e=0;e<3;e++)u.push(ne[e]);for(let e=0;e<3;e++)u.push(ne[e]+ue[e]*n);m.push(m.length),m.push(m.length)}}}const f=new K([["position",{data:i,size:3,exclusive:!0}]],[["position",new Uint32Array(l)]],2);t.push(f),r.push(this._debugVertexNormalMaterial),o.push(c(o[0]));const d=new K([["position",{data:u,size:3,exclusive:!0}]],[["position",new Uint32Array(m)]],2);t.push(d),r.push(this._debugFaceNormalMaterial),o.push(c(o[0]))}_createAs3DShape(e,r,o,a){const s=e.geometry;if("mesh"!==s.type)return null;const n=this._createGeometryInfo(s,r);if(!n)return null;const{geometries:i,materials:l,transformations:u,objectTransformation:c}=n;J.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(s,i,l,u);const m=new X({geometries:i,materials:l,transformations:u,metadata:{layerUid:this._context.layer.uid,graphicUid:a}});m.transformation=c;const h=D,p=this._createEdgeMaterial(),f=t(p)?{baseMaterial:l[0],edgeMaterials:[p],properties:{mergeGeometries:!0,slicePlaneEnabled:this._context.slicePlaneEnabled}}:null,d=new H(this,m,i,null,null,h,o,f);return d.needsElevationUpdates=z(o.mode),d.useObjectOriginAsAttachmentOrigin=!0,d.elevationContext.centerPointInElevationSR=this.getCenterPointInElevationSR(m),d.alignedSampledElevation=h(d,d.elevationContext,this._context.elevationProvider,this._context.renderCoordsHelper),d}getCenterPointInElevationSR(e){const t=G(0,0,0,this._context.elevationProvider.spatialReference);return T([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o);default:return}}_createComponentNormalsSource(e,t,o,a){if(r(t))return this._createComponentNormalsFlat(e,a);let s=!1;if(!o.trustSourceNormals)for(let r=0;r<a.length;r+=3){this._calculateFaceNormal(e,a,r,ue);for(let e=0;e<3;e++){const o=3*a[r+e];ne[0]=t[o+0],ne[1]=t[o+1],ne[2]=t[o+2],f(ue,ne)<0&&(t[o+0]=-t[o+0],t[o+1]=-t[o+1],t[o+2]=-t[o+2],s=!0)}}return{normals:t,indices:a,didFlipNormals:s}}_createComponentNormalsFlat(e,t){const r=new Float32Array(t.length),o=new Uint32Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,ue);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return{normals:r,indices:o,didFlipNormals:!1}}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,ue);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:b(),count:0},r[a]=n),h(n.normal,n.normal,o),n.count++}}const o=new Float32Array(3*t.length),a=new Uint32Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return{normals:o,indices:a,didFlipNormals:!1}}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r+0],i=3*t[r+1],l=3*t[r+2];o[0]=e[n+0],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i+0],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l+0],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ne,ie,le),g(ie,ie,ne),g(le,le,ne),x(ne,ie,le),d(o,ne),o}_getOrCreateComponents(e){return e.components?e.components:pe}_createPositionBuffer(e,r){let o=e.vertexAttributes.position;const a=1===r.reprojection?r.transformBeforeProject:null;if(t(a)&&(o=N(o,new Float64Array(o.length),a)),0===r.reprojection)return r.needsBufferCopy?new Float64Array(o):o;const s=t(a)?o:new Float64Array(o.length);return C(o,e.spatialReference,0,s,this._context.renderCoordsHelper.spatialReference,0,o.length/3),s}_createNormalBuffer(e,o,a){let s=e.vertexAttributes.normal;if(r(s))return null;const n=1===a.reprojection?a.transformBeforeProject:null;t(n)&&(s=V(s,new Float32Array(s.length),n));if("local"===this._context.layerView.view.viewingMode||0===a.reprojection)return a.needsBufferCopy&&e.vertexAttributes.normal===s?new Float32Array(s):s;const i=e.vertexAttributes.position,l=t(n)?s:new Float32Array(s.length);return U(s,i,o,e.spatialReference,l)}_createTangentBuffer(e,o,a){let s=e.vertexAttributes.tangent;if(r(s))return null;const n=1===a.reprojection?a.transformBeforeProject:null;t(n)&&(s=L(s,new Float32Array(s.length),n));if("local"===this._context.layerView.view.viewingMode||0===a.reprojection)return a.needsBufferCopy&&e.vertexAttributes.normal===s?new Float32Array(s):s;const i=e.vertexAttributes.position,l=t(n)?s:new Float32Array(s.length);return $(s,i,o,e.spatialReference,l)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=Y(o(this.symbolLayer,"material","colorMixMode")),a=new Uint8Array(4);return Z(t,r,a),a}return null}_createBuffers(e,r){const o=e.vertexAttributes&&e.vertexAttributes.position;if(!o)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const a=e.vertexAttributes.normal,s=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(t(a)&&a.length!==o.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(t(n)&&n.length/4!=o.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(t(s)&&s.length/2!=o.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const i=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,i),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(r),h=this._createNormalBuffer(e,l,i),p=this._createTangentBuffer(e,l,i);return{positionBuffer:l,normalBuffer:h,tangentBuffer:p,uvBuffer:s,colorBuffer:u,symbolColorBuffer:c,objectTransformation:0===i.reprojection&&t(i.objectTransformation)?i.objectTransformation:this._transformOriginLocal(e,l,h,p),geometryTransformation:0===i.reprojection&&t(i.geometryTransformation)?i.geometryTransformation:m()}}_computeReprojectionInfo(e){const r=t(e.transform)&&e.transform.geographic||2===this._context.renderCoordsHelper.viewingMode?0:1;let o=null;if(t(e.transform)){if(0===r){const t=m();A(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:t,geometryTransformation:c(e.transform.localMatrix),needsBufferCopy:!1}}return o=i(m(),e.transform.origin),l(o,o,e.transform.localMatrix),{reprojection:r,transformBeforeProject:o,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,r,o,n){const i=this._context.renderCoordsHelper.spatialReference,l=e.anchor;se[0]=l.x,se[1]=l.y,se[2]=l.z;const c=m();A(e.spatialReference,se,c,i);const h=F.fromTypedArray(r);if(u(ce,c),O(h,h,ce),t(o)||t(n)){if(a(me,c),s(me,me),t(o)){const e=I.fromTypedArray(o);S(e,e,me)}if(t(n)){const e=I.fromTypedArray(n,4*n.BYTES_PER_ELEMENT);S(e,e,me)}}return c}_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}_getOrCreateFaces(e,t){return t.faces?t.faces:Q(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const a=t.length/3;return e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),C(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),j(he),P(he,o,0,a),!B(he,this._context.clippingExtent)}_createGeometryInfo(e,o){if(!w(e.spatialReference,this._context.layerView.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const a=this._createBuffers(e,o);if(r(a))return null;const{positionBuffer:s,uvBuffer:n,colorBuffer:i,symbolColorBuffer:l,normalBuffer:u,tangentBuffer:c,objectTransformation:m,geometryTransformation:h}=a,p=this._getOrCreateComponents(e),f=[],d=[],g=[];let x=!1;for(const r of p){if(!this._validateFaces(e,r))return null;const o=this._getOrCreateFaces(e,r);if(0===o.length)continue;const a=this._createComponentNormals(s,u,r,o);a.didFlipNormals&&(x=!0);const m=[["position",{size:3,data:s,exclusive:!0}],["normal",{size:3,data:a.normals,exclusive:!0}]],p=[["position",o],["normal",a.indices]];t(i)&&(m.push(["color",{size:4,data:i,exclusive:!0}]),p.push(["color",o])),t(l)&&(m.push(["symbolColor",{size:4,data:l,exclusive:!0}]),p.push(["symbolColor",new Uint16Array(o.length)])),t(n)&&(m.push(["uv0",{size:2,data:n,exclusive:!0}]),p.push(["uv0",o])),t(c)&&(m.push(["tangent",{size:4,data:c,exclusive:!0}]),p.push(["tangent",o]));const _=new K(m,p);f.push(_),d.push(h),g.push(this._getOrCreateMaterial(e,r))}return x&&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:f,transformations:d,materials:g,objectTransformation:m}}_createEdgeMaterial(){const e={opacity:this._getLayerOpacity()};return q(this.symbolLayer,e)}}const se=b(),ne=b(),ie=b(),le=b(),ue=b(),ce=m(),me=n(),he=M(),pe=[new R];export{ae as Graphics3DMeshFillSymbolLayer,ae as default};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{isSome as t,isNone as r,get as o}from"../../../../core/maybe.js";import{f as a,t as s}from"../../../../chunks/mat3.js";import{c as n}from"../../../../chunks/mat3f64.js";import{u as i,m as l,b as c}from"../../../../chunks/mat4.js";import{b as u,c as m}from"../../../../chunks/mat4f64.js";import{b as h,a as p,d as f,n as d,f as g,c as x}from"../../../../chunks/vec3.js";import{Z as _,O as y,c as b}from"../../../../chunks/vec3f64.js";import{O as v}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as T,projectBuffer as C,computeTranslationToOriginAndRotation as A,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as P,intersectsClippingArea as B}from"../../../../geometry/support/aaBoundingBox.js";import R from"../../../../geometry/support/MeshComponent.js";import E from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{BufferViewVec3f64 as F,BufferViewVec3f as I}from"../../../../geometry/support/buffer/BufferView.js";import{t as O,a as S}from"../../../../chunks/vec32.js";import{transformPosition as N,transformNormal as U,projectNormalToPCPF as V,transformTangent as L,projectTangentToPCPF as $}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as G}from"../../../../layers/graphics/dehydratedFeatures.js";import{perObjectElevationAligner as D}from"./ElevationAligners.js";import{needsElevationUpdates3D as z}from"./elevationAlignmentUtils.js";import{ElevationContext as k}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as H}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as W}from"./Graphics3DSymbolLayer.js";import{createMaterial as q}from"../support/edgeUtils.js";import{parseColorMixMode as Y,encodeSymbolColor as Z}from"../support/symbolColorUtils.js";import J from"../../support/debugFlags.js";import{Geometry as K}from"../../webgl-engine/lib/Geometry.js";import{generateDefaultIndexArray as Q}from"../../webgl-engine/lib/geometryDataUtils.js";import{Object3D as X}from"../../webgl-engine/lib/Object3D.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as te}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as re}from"../../webgl-engine/materials/NativeLineMaterial.js";const oe=["mesh"];class ae extends W{constructor(e,t,r,o){super(e,t,r,o),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){J.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new re({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new re({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,oe,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new k),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}layerOpacityChanged(e,r){const o=this._getLayerOpacity();return this._materials.forEach((e=>{e.material.setParameters({layerOpacity:o});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const a=r(e);t(a)&&a.layerOpacityChanged(o,this._context.isAsync)})),!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,z)}slicePlaneEnabledChanged(e,r){return this._materials.forEach((e=>{e.material.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled})})),e.forEach((e=>{const o=r(e);t(o)&&o.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}pixelRatioChanged(){return!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return r(t)?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,normalTexture:n,doubleSided:i,alphaCutoff:l,alphaMode:c}=t.material,u=this._colorOrTextureUid(a),m=this._colorOrTextureUid(s),h=this._colorOrTextureUid(n);if(o.color=a,o.colorTexture=s,o.normalTexture=n,o.uid=`${o.uid},cmuid:${u},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${c}`,t.material instanceof E){const{metallic:e,roughness:r,metallicRoughnessTexture:a,emissiveColor:s,emissiveTexture:n,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(a),c=this._colorOrTextureUid(s),u=this._colorOrTextureUid(n),m=this._colorOrTextureUid(i);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=s,o.emissiveTexture=n,o.occlusionTexture=i,o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${c},etmuid:${u},otmuid:${m}`}return o}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const r=this._getInternalTexture(e,1);return t(r)?r.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);return a||(a=new ee(r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:1!==t}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadSynchronous(a)),a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}_setInternalMaterialParameters(r,o){if(t(r.color)&&this._setInternalColorValueParameters(r.color,o),t(r.colorTexture)){const e=this._getInternalTexture(r.colorTexture,o.textureAlphaMode);t(e)?(o.textureId=e.id,o.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):o.textureId=void 0}t(r.normalTexture)&&(o.normalTextureId=this._getInternalTextureId(r.normalTexture)),t(r.emissiveColor)&&(o.emissiveFactor=e.toUnitRGB(r.emissiveColor)),t(r.emissiveTexture)&&(o.emissiveTextureId=this._getInternalTextureId(r.emissiveTexture)),t(r.occlusionTexture)&&(o.occlusionTextureId=this._getInternalTextureId(r.occlusionTexture)),t(r.metallicRoughnessTexture)&&(o.metallicRoughnessTextureId=this._getInternalTextureId(r.metallicRoughnessTexture))}_setExternalMaterialParameters(r){const o=this._drivenProperties.color;let a=t(this.symbolLayer.material)?this.symbolLayer.material.colorMixMode:null;if(o)r.externalColor=v;else{const o=t(this.symbolLayer.material)?this.symbolLayer.material.color:null;t(o)?r.externalColor=e.toUnitRGBA(o):(a=null,r.externalColor=v)}a&&(r.colorMixMode=a),r.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(r(t))return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,r){var o,a,s;const n=null==(o=r.material)?void 0:o.color,i=null==(a=r.material)?void 0:a.colorTexture,l=null==(s=r.material)?void 0:s.alphaMode,c="blend"===l,u=!("opaque"===l)&&(this._hasTransparentVertexColors(e)||t(n)&&n.a<1||t(i)&&i.transparent||c),m=this._materialProperties(e,r,u),h=this._materials.get(m.uid);if(h)return h.material;const p={material:null,isComponentTransparent:u,alphaMode:r.material?r.material.alphaMode:"opaque"},f=null==m.metallicRoughnessTexture&&null==m.metallic&&null==m.roughness,d={usePBR:this._usePBR(),isSchematic:f,vertexColors:m.hasVertexColors,symbolColors:m.hasSymbolVertexColors,vertexTangents:m.hasVertexTangents,ambient:_,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),slicePlaneEnabled:this._context.slicePlaneEnabled,initTextureTransparent:!0};f||(d.mrrFactors=[null!=m.metallic?m.metallic:1,null!=m.roughness?m.roughness:1,.5]),r.material&&(d.doubleSided=r.material.doubleSided,d.cullFace=r.material.doubleSided?0:2,d.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(d),this._setMaterialTransparentParameter(d,p),this._setInternalMaterialParameters(m,d);const g=new te(d);return p.material=g,this._materials.set(m.uid,p),this._context.stage.add(g),g}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?3:1:e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_addDebugNormals(e,t,r,o){const a=t.length,s=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*s,e.extent.height*s,e.extent.zmax-e.extent.zmin),i=[],l=[],c=[],m=[];for(let u=0;u<a;u++){const e=t[u],r=e.vertexAttributes.get("position"),o=e.vertexAttributes.get("normal"),a=e.indices.get("position"),s=e.indices.get("normal"),f=r.data,d=o.data;for(let t=0;t<a.length;t++){const e=3*a[t],r=3*s[t];for(let t=0;t<3;t++)i.push(f[e+t]);for(let t=0;t<3;t++)i.push(f[e+t]+d[r+t]*n);if(l.push(l.length),l.push(l.length),t%3==0){this._calculateFaceNormal(f,a,t,ce),this._getFaceVertices(f,a,t,ne,ie,le),h(ne,ne,ie),h(ne,ne,le),p(ne,ne,1/3);for(let e=0;e<3;e++)c.push(ne[e]);for(let e=0;e<3;e++)c.push(ne[e]+ce[e]*n);m.push(m.length),m.push(m.length)}}}const f=new K([["position",{data:i,size:3,exclusive:!0}]],[["position",new Uint32Array(l)]],2);t.push(f),r.push(this._debugVertexNormalMaterial),o.push(u(o[0]));const d=new K([["position",{data:c,size:3,exclusive:!0}]],[["position",new Uint32Array(m)]],2);t.push(d),r.push(this._debugFaceNormalMaterial),o.push(u(o[0]))}_createAs3DShape(e,r,o,a){const s=e.geometry;if("mesh"!==s.type)return null;const n=this._createGeometryInfo(s,r);if(!n)return null;const{geometries:i,materials:l,transformations:c,objectTransformation:u}=n;J.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(s,i,l,c);const m=new X({geometries:i,materials:l,transformations:c,metadata:{layerUid:this._context.layer.uid,graphicUid:a}});m.transformation=u;const h=this._createEdgeMaterial(),p=t(h)?{baseMaterial:l[0],edgeMaterials:[h],properties:{mergeGeometries:!0,slicePlaneEnabled:this._context.slicePlaneEnabled}}:null,f=new H(this,m,i,null,null,D,o,p);return f.needsElevationUpdates=z(o.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.elevationContext.centerPointInElevationSR=this.getCenterPointInElevationSR(m),f.alignedSampledElevation=D(f,f.elevationContext,this._context.elevationProvider,this._context.renderCoordsHelper),f}getCenterPointInElevationSR(e){const t=G(0,0,0,this._context.elevationProvider.spatialReference);return T([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o);default:return}}_createComponentNormalsSource(e,t,o,a){if(r(t))return this._createComponentNormalsFlat(e,a);let s=!1;if(!o.trustSourceNormals)for(let r=0;r<a.length;r+=3){this._calculateFaceNormal(e,a,r,ce);for(let e=0;e<3;e++){const o=3*a[r+e];ne[0]=t[o+0],ne[1]=t[o+1],ne[2]=t[o+2],f(ce,ne)<0&&(t[o+0]=-t[o+0],t[o+1]=-t[o+1],t[o+2]=-t[o+2],s=!0)}}return{normals:t,indices:a,didFlipNormals:s}}_createComponentNormalsFlat(e,t){const r=new Float32Array(t.length),o=new Uint32Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,ce);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return{normals:r,indices:o,didFlipNormals:!1}}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,ce);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:b(),count:0},r[a]=n),h(n.normal,n.normal,o),n.count++}}const o=new Float32Array(3*t.length),a=new Uint32Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return{normals:o,indices:a,didFlipNormals:!1}}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r+0],i=3*t[r+1],l=3*t[r+2];o[0]=e[n+0],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i+0],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l+0],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ne,ie,le),g(ie,ie,ne),g(le,le,ne),x(ne,ie,le),d(o,ne),o}_getOrCreateComponents(e){return e.components?e.components:pe}_createPositionBuffer(e,r){let o=e.vertexAttributes.position;const a=1===r.reprojection?r.transformBeforeProject:null;if(t(a)&&(o=N(o,new Float64Array(o.length),a)),0===r.reprojection)return r.needsBufferCopy?new Float64Array(o):o;const s=t(a)?o:new Float64Array(o.length);return C(o,e.spatialReference,0,s,this._context.renderCoordsHelper.spatialReference,0,o.length/3),s}_createNormalBuffer(e,o,a){let s=e.vertexAttributes.normal;if(r(s))return null;const n=1===a.reprojection?a.transformBeforeProject:null;t(n)&&(s=U(s,new Float32Array(s.length),n));if("local"===this._context.layerView.view.viewingMode||0===a.reprojection)return a.needsBufferCopy&&e.vertexAttributes.normal===s?new Float32Array(s):s;const i=e.vertexAttributes.position,l=t(n)?s:new Float32Array(s.length);return V(s,i,o,e.spatialReference,l)}_createTangentBuffer(e,o,a){let s=e.vertexAttributes.tangent;if(r(s))return null;const n=1===a.reprojection?a.transformBeforeProject:null;t(n)&&(s=L(s,new Float32Array(s.length),n));if("local"===this._context.layerView.view.viewingMode||0===a.reprojection)return a.needsBufferCopy&&e.vertexAttributes.normal===s?new Float32Array(s):s;const i=e.vertexAttributes.position,l=t(n)?s:new Float32Array(s.length);return $(s,i,o,e.spatialReference,l)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=Y(o(this.symbolLayer,"material","colorMixMode")),a=new Uint8Array(4);return Z(t,r,a),a}return null}_createBuffers(e,r){const o=e.vertexAttributes&&e.vertexAttributes.position;if(!o)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const a=e.vertexAttributes.normal,s=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(t(a)&&a.length!==o.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(t(n)&&n.length/4!=o.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(t(s)&&s.length/2!=o.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const i=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,i),c=this._createColorBuffer(e),u=this._createSymbolColorBuffer(r),h=this._createNormalBuffer(e,l,i),p=this._createTangentBuffer(e,l,i);return{positionBuffer:l,normalBuffer:h,tangentBuffer:p,uvBuffer:s,colorBuffer:c,symbolColorBuffer:u,objectTransformation:0===i.reprojection&&t(i.objectTransformation)?i.objectTransformation:this._transformOriginLocal(e,l,h,p),geometryTransformation:0===i.reprojection&&t(i.geometryTransformation)?i.geometryTransformation:m()}}_computeReprojectionInfo(e){const r=t(e.transform)&&e.transform.geographic||2===this._context.renderCoordsHelper.viewingMode?0:1;let o=null;if(t(e.transform)){if(0===r){const t=m();A(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:t,geometryTransformation:u(e.transform.localMatrix),needsBufferCopy:!1}}return o=i(m(),e.transform.origin),l(o,o,e.transform.localMatrix),{reprojection:r,transformBeforeProject:o,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,r,o,n){const i=this._context.renderCoordsHelper.spatialReference,l=e.anchor;se[0]=l.x,se[1]=l.y,se[2]=l.z;const u=m();A(e.spatialReference,se,u,i);const h=F.fromTypedArray(r);if(c(ue,u),O(h,h,ue),t(o)||t(n)){if(a(me,u),s(me,me),t(o)){const e=I.fromTypedArray(o);S(e,e,me)}if(t(n)){const e=I.fromTypedArray(n,4*n.BYTES_PER_ELEMENT);S(e,e,me)}}return u}_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}_getOrCreateFaces(e,t){return t.faces?t.faces:Q(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const a=t.length/3;return e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),C(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),j(he),P(he,o,0,a),!B(he,this._context.clippingExtent)}_createGeometryInfo(e,o){if(!w(e.spatialReference,this._context.layerView.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const a=this._createBuffers(e,o);if(r(a))return null;const{positionBuffer:s,uvBuffer:n,colorBuffer:i,symbolColorBuffer:l,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:h}=a,p=this._getOrCreateComponents(e),f=[],d=[],g=[];let x=!1;for(const r of p){if(!this._validateFaces(e,r))return null;const o=this._getOrCreateFaces(e,r);if(0===o.length)continue;const a=this._createComponentNormals(s,c,r,o);a.didFlipNormals&&(x=!0);const m=[["position",{size:3,data:s,exclusive:!0}],["normal",{size:3,data:a.normals,exclusive:!0}]],p=[["position",o],["normal",a.indices]];t(i)&&(m.push(["color",{size:4,data:i,exclusive:!0}]),p.push(["color",o])),t(l)&&(m.push(["symbolColor",{size:4,data:l,exclusive:!0}]),p.push(["symbolColor",new Uint16Array(o.length)])),t(n)&&(m.push(["uv0",{size:2,data:n,exclusive:!0}]),p.push(["uv0",o])),t(u)&&(m.push(["tangent",{size:4,data:u,exclusive:!0}]),p.push(["tangent",o]));const _=new K(m,p);f.push(_),d.push(h),g.push(this._getOrCreateMaterial(e,r))}return x&&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:f,transformations:d,materials:g,objectTransformation:m}}_createEdgeMaterial(){const e={opacity:this._getLayerOpacity()};return q(this.symbolLayer,e)}}const se=b(),ne=b(),ie=b(),le=b(),ce=b(),ue=m(),me=n(),he=M(),pe=[new R];export{ae as Graphics3DMeshFillSymbolLayer,ae as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{isNone as e,isSome as t,unwrapOr as s}from"../../../../core/maybe.js";import{g as i,m as a,b as n}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{create as o,setMin as c,setMax as h,isPoint as g,empty as d,center as l,offset as u}from"../../../../geometry/support/aaBoundingBox.js";import{g as b}from"../../../../chunks/sphere.js";import{setContextFeature as O}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as j}from"./graphicUtils.js";class m{constructor(e,t,s,i,a,n,r,o=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._uniqueGeometries=s,this._uniqueMaterials=i,this._uniqueTextures=a,this.elevationAligner=n,this.elevationContext=r,this._edgeState=o,this.type="object3d",this.stageLayer=null,this.stage=null,this._visible=!1,this._addedToStage=!1,this.alignedSampledElevation=0,this.needsElevationUpdates=!1,this.useObjectOriginAsAttachmentOrigin=!1,this.graphics3DSymbolLayer=e,this.stageObject=t}get isElevationSource(){return!(!this.stageObject.metadata||!this.stageObject.metadata.isElevationSource)}initialize(e,t){this.stageLayer=t,this.stage=e,e.addMany(this._uniqueMaterials),e.addMany(this._uniqueGeometries),e.addMany(this._uniqueTextures),e.add(this.stageObject)}destroy(){const e=this.stage;this.stageLayer&&(e.removeMany(this._uniqueMaterials),e.removeMany(this._uniqueGeometries),e.removeMany(this._uniqueTextures)),e.remove(this.stageObject),this._addedToStage&&(this.stageLayer.remove(this.stageObject),this._addedToStage=!1);const t=this.stage.renderView.ensureEdgeView();t.hasObject(this.stageObject)&&t.removeObject(this.stageObject),this.stageObject.dispose(),this._visible=!1,this.stageLayer=null,this.stage=null}layerOpacityChanged(t,s){if(e(this._edgeState))return;const i=p(this._edgeState.baseMaterial);let a=!1;for(const e of this._edgeState.edgeMaterials)e.objectTransparency!==i&&(e.objectTransparency=i,a=!0);a&&this.resetEdgeObject(s);this.stage.renderView.ensureEdgeView().updateAllComponentOpacities(this.stageObject,[t])}slicePlaneEnabledChanged(t,s){if(e(this._edgeState))return;this.stage.renderView.ensureEdgeView().updateAllComponentMaterials(this.stageObject,this._edgeState.edgeMaterials,{slicePlaneEnabled:t},!s),this._edgeState.properties.slicePlaneEnabled=t}setVisibility(e){if(null!=this.stage&&this._visible!==e&&(this._visible=e,this._visible?this._addedToStage?this.stageObject.setVisible(!0):(this.stageLayer.add(this.stageObject),this._addedToStage=!0):this.stageObject.setVisible(!1),t(this._edgeState))){const t=this.stage.renderView.ensureEdgeView();t.hasObject(this.stageObject)?t.updateObjectVisibility(this.stageObject,e):e&&this.addOrUpdateEdgeObject(t,!1)}}get visible(){return this._visible}alignWithElevation(e,s,i,a){if(null==this.elevationAligner)return;t(i)&&O(this.elevationContext.featureExpressionInfoContext,i);const n=this.elevationAligner(this,this.elevationContext,e,s);null!=n&&(this.alignedSampledElevation=n),this.resetEdgeObject(a)}getCenterObjectSpace(e=r()){return i(e,b(this.stageObject.boundingVolumeObjectSpace.bounds))}getBoundingBoxObjectSpace(e=o()){const t=this.stageObject.boundingVolumeObjectSpace;return c(e,t.min),h(e,t.max),e}computeAttachmentOrigin(e){if(this.useObjectOriginAsAttachmentOrigin){const t=this.stageObject.transformation;e.render.origin[0]+=t[12],e.render.origin[1]+=t[13],e.render.origin[2]+=t[14],e.render.num++}else for(const t of this.stageObject.geometryRecords)t.computeAttachmentOrigin(y)&&(a(y,y,this.stageObject.transformation),n(e.render.origin,e.render.origin,y),e.render.num++)}async getProjectedBoundingBox(e,t,i,n,r){const o=this.getBoundingBoxObjectSpace(r),c=S,h=g(o)?1:c.length;for(let s=0;s<h;s++){const e=c[s];f[0]=o[e[0]],f[1]=o[e[1]],f[2]=o[e[2]],a(f,f,this.stageObject.transformation),v[3*s+0]=f[0],v[3*s+1]=f[1],v[3*s+2]=f[2]}if(!e(v,0,h))return null;d(o);let b=null;this.calculateRelativeScreenBounds&&(b=this.calculateRelativeScreenBounds());for(let s=0;s<3*h;s+=3){for(let e=0;e<3;e++)o[e]=Math.min(o[e],v[s+e]),o[e+3]=Math.max(o[e+3],v[s+e]);b&&i.push({location:v.slice(s,s+3),screenSpaceBoundingRect:b})}if(t&&t.service&&"absolute-height"!==this.elevationContext.mode){l(o,y);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let i=0;if(t.useViewElevation)i=s(t.service.getElevation(y[0],y[1],e),0);else try{const a=j(o,t);i=s(await t.service.queryElevation(y[0],y[1],n,a,e),0)}catch(O){}u(o,0,0,-this.alignedSampledElevation+i)}return o}addObjectState(e,t){0===e&&t.addObject(this.stageObject,this.stageObject.highlight()),1===e&&t.addObject(this.stageObject,this.stageObject.maskOccludee())}removeObjectState(e){e.removeObject(this.stageObject)}resetEdgeObject(t){if(e(this._edgeState))return;const s=this.stage.renderView.ensureEdgeView();this._visible?this.addOrUpdateEdgeObject(s,t):s.removeObject(this.stageObject)}addOrUpdateEdgeObject(t,s){const i=this._edgeState;if(e(i))return;const a=p(i.baseMaterial);for(const e of i.edgeMaterials)e.objectTransparency=a;t.addOrUpdateObject3D(this.stageObject,i.edgeMaterials,i.properties,!s).then((()=>{var e;return null==(e=this.stageLayer)?void 0:e.sync()}))}}function p(e){return e.isVisible?e.params.transparent?1:2:0}const v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=r(),y=r(),S=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];export{m as Graphics3DObject3DGraphicLayer,m as default};
5
+ import{isNone as e,isSome as t,unwrapOr as s}from"../../../../core/maybe.js";import{g as i,m as a,b as n}from"../../../../chunks/vec3.js";import{c as r}from"../../../../chunks/vec3f64.js";import{create as o,setMin as c,setMax as h,isPoint as g,empty as d,center as l,offset as u}from"../../../../geometry/support/aaBoundingBox.js";import{g as b}from"../../../../chunks/sphere.js";import{setContextFeature as O}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as j}from"./graphicUtils.js";class m{constructor(e,t,s,i,a,n,r,o=null){this.graphics3DSymbolLayer=e,this.stageObject=t,this._uniqueGeometries=s,this._uniqueMaterials=i,this._uniqueTextures=a,this.elevationAligner=n,this.elevationContext=r,this._edgeState=o,this.type="object3d",this.stageLayer=null,this.stage=null,this._visible=!1,this._addedToStage=!1,this.alignedSampledElevation=0,this.needsElevationUpdates=!1,this.useObjectOriginAsAttachmentOrigin=!1,this.graphics3DSymbolLayer=e,this.stageObject=t}get isElevationSource(){return!(!this.stageObject.metadata||!this.stageObject.metadata.isElevationSource)}initialize(e,t){this.stageLayer=t,this.stage=e,e.addMany(this._uniqueMaterials),e.addMany(this._uniqueGeometries),e.addMany(this._uniqueTextures),e.load(this._uniqueTextures),e.add(this.stageObject)}destroy(){const e=this.stage;this.stageLayer&&(e.removeMany(this._uniqueMaterials),e.removeMany(this._uniqueGeometries),e.removeMany(this._uniqueTextures)),e.remove(this.stageObject),this._addedToStage&&(this.stageLayer.remove(this.stageObject),this._addedToStage=!1);const t=this.stage.renderView.ensureEdgeView();t.hasObject(this.stageObject)&&t.removeObject(this.stageObject),this.stageObject.dispose(),this._visible=!1,this.stageLayer=null,this.stage=null}layerOpacityChanged(t,s){if(e(this._edgeState))return;const i=p(this._edgeState.baseMaterial);let a=!1;for(const e of this._edgeState.edgeMaterials)e.objectTransparency!==i&&(e.objectTransparency=i,a=!0);a&&this.resetEdgeObject(s);this.stage.renderView.ensureEdgeView().updateAllComponentOpacities(this.stageObject,[t])}slicePlaneEnabledChanged(t,s){if(e(this._edgeState))return;this.stage.renderView.ensureEdgeView().updateAllComponentMaterials(this.stageObject,this._edgeState.edgeMaterials,{slicePlaneEnabled:t},!s),this._edgeState.properties.slicePlaneEnabled=t}setVisibility(e){if(null!=this.stage&&this._visible!==e&&(this._visible=e,this._visible?this._addedToStage?this.stageObject.setVisible(!0):(this.stageLayer.add(this.stageObject),this._addedToStage=!0):this.stageObject.setVisible(!1),t(this._edgeState))){const t=this.stage.renderView.ensureEdgeView();t.hasObject(this.stageObject)?t.updateObjectVisibility(this.stageObject,e):e&&this.addOrUpdateEdgeObject(t,!1)}}get visible(){return this._visible}alignWithElevation(e,s,i,a){null!=this.elevationAligner&&(t(i)&&O(this.elevationContext.featureExpressionInfoContext,i),this.alignedSampledElevation=this.elevationAligner(this,this.elevationContext,e,s),this.resetEdgeObject(a))}getCenterObjectSpace(e=r()){return i(e,b(this.stageObject.boundingVolumeObjectSpace.bounds))}getBoundingBoxObjectSpace(e=o()){const t=this.stageObject.boundingVolumeObjectSpace;return c(e,t.min),h(e,t.max),e}computeAttachmentOrigin(e){if(this.useObjectOriginAsAttachmentOrigin){const t=this.stageObject.transformation;e.render.origin[0]+=t[12],e.render.origin[1]+=t[13],e.render.origin[2]+=t[14],e.render.num++}else for(const t of this.stageObject.geometryRecords)t.computeAttachmentOrigin(y)&&(a(y,y,this.stageObject.transformation),n(e.render.origin,e.render.origin,y),e.render.num++)}async getProjectedBoundingBox(e,t,i,n,r){const o=this.getBoundingBoxObjectSpace(r),c=S,h=g(o)?1:c.length;for(let s=0;s<h;s++){const e=c[s];f[0]=o[e[0]],f[1]=o[e[1]],f[2]=o[e[2]],a(f,f,this.stageObject.transformation),v[3*s+0]=f[0],v[3*s+1]=f[1],v[3*s+2]=f[2]}if(!e(v,0,h))return null;d(o);let b=null;this.calculateRelativeScreenBounds&&(b=this.calculateRelativeScreenBounds());for(let s=0;s<3*h;s+=3){for(let e=0;e<3;e++)o[e]=Math.min(o[e],v[s+e]),o[e+3]=Math.max(o[e+3],v[s+e]);b&&i.push({location:v.slice(s,s+3),screenSpaceBoundingRect:b})}if(t&&t.service&&"absolute-height"!==this.elevationContext.mode){l(o,y);const e="relative-to-scene"===this.elevationContext.mode?"scene":"ground";let i=0;if(t.useViewElevation)i=s(t.service.getElevation(y[0],y[1],e),0);else try{const a=j(o,t);i=s(await t.service.queryElevation(y[0],y[1],n,a,e),0)}catch(O){}u(o,0,0,-this.alignedSampledElevation+i)}return o}addObjectState(e,t){0===e&&t.addObject(this.stageObject,this.stageObject.highlight()),1===e&&t.addObject(this.stageObject,this.stageObject.maskOccludee())}removeObjectState(e){e.removeObject(this.stageObject)}resetEdgeObject(t){if(e(this._edgeState))return;const s=this.stage.renderView.ensureEdgeView();this._visible?this.addOrUpdateEdgeObject(s,t):s.removeObject(this.stageObject)}addOrUpdateEdgeObject(t,s){const i=this._edgeState;if(e(i))return;const a=p(i.baseMaterial);for(const e of i.edgeMaterials)e.objectTransparency=a;t.addOrUpdateObject3D(this.stageObject,i.edgeMaterials,i.properties,!s).then((()=>{var e;return null==(e=this.stageLayer)?void 0:e.sync()}))}}function p(e){return e.isVisible?e.parameters.transparent?1:2:0}const v=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],f=r(),y=r(),S=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]];export{m as Graphics3DObject3DGraphicLayer,m as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{isSome as t,get as s,none as r,isNone as i,unwrapOr as a}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{e as n,i as l,f as c,t as h}from"../../../../chunks/mat4.js";import{c as d}from"../../../../chunks/mat4f64.js";import{l as p,o as m,g as u,D as y,b as f,s as _}from"../../../../chunks/vec3.js";import{d as g,O as b,Z as P,f as v,c as x}from"../../../../chunks/vec3f64.js";import{O as R,c as L}from"../../../../chunks/vec4f64.js";import{projectPointToVector as S,computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection.js";import{create as E,size as U,containsPoint as j,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as T}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as B,objectSymbolLayerSizeWithResourceSize as G}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as O}from"./ElevationAligners.js";import{needsElevationUpdates3D as V,evaluateElevationAlignmentAtPoint as z}from"./elevationAlignmentUtils.js";import{ElevationContext as I}from"./ElevationContext.js";import M from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A,mixinColorAndOpacity as F,computeObjectScale as k,computeObjectRotation as W}from"./graphicUtils.js";import{makeLodResources as q,fillEstimatedMinScreenSpaceRadius as H}from"./lodResourceUtils.js";import{fetch as $}from"./objectResourceUtils.js";import{placePointOnGeometry as Z,extendPointGraphicElevationContext as J}from"./pointUtils.js";import{isValidPrimitive as K,primitiveLodResources as N}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as Q}from"./symbolComplexity.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as Y,evaluateModelTransform as ee,evaluateModelTransformScale as te}from"../support/FastSymbolUpdates.js";import{LodRenderer as se}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as re,texturesFromLodResources as ie,geometriesFromLodResources as ae,geometriesFromLodLevelResources as oe}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as ne}from"../../webgl-engine/materials/DefaultMaterial.js";class le extends D{constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this.hasLoadedPBRTextures=!1,this.ensureDrapedStatus(!1),this.hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}getCachedSize(){const[e,s,r]=t(this._resources)?this._resources.symbolSize:[1,1,1];return{width:e,depth:s,height:r}}async doLoad(e){if(!this._drivenProperties.size){if(A(this.symbolLayer))throw new Error}const t=this.symbolLayer;if(this.isPrimitive){const s=t.resource?t.resource.primitive:T;this._resources=await this._createResourcesForPrimitive(s,e)}else this._resources=await this._createResourcesForUrl(t.resource.href,e);this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return t(this._resources)?this._resources.extentPadding:0}get isPrimitive(){return!(this.symbolLayer.resource&&this.symbolLayer.resource.href)}get lodRenderer(){return s(this._resources,"lodRenderer")}setMaterialTransparencyParams(e,t=s(this.symbolLayer,"material","color")){const r=this._getCombinedOpacity(t),i=r<1||this.needsDrivenTransparentPass;return e.transparent=i,e.opacity=r,e.cullFace=i?0:2,e}async _createResourcesForPrimitive(s,i){if(!K(s))throw new Error(`Unknown object symbol primitive: ${s}`);const a=this.symbolLayer,n=E(B(s)),l=g(U(n)),c=g(G(l,a)),h=p(c),d=!1,m=!1,u={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,instanced:["transformation"],ambient:b,diffuse:b,slicePlaneEnabled:this._context.slicePlaneEnabled,sliceHighlightDisabled:!0,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},y=u.usePBR;this.setMaterialTransparencyParams(u);const f=this.symbol;if("point-3d"===f.type&&f.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=f.verticalOffset;u.verticalOffset={screenLength:o(e),minWorldLength:t||0,maxWorldLength:null!=s?s:1/0},u.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(u.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)u.externalColor=R;else{const s=t(a.material)&&a.material.color,r=t(s)?e.toUnitRGBA(s):R;u.externalColor=r}this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(n,c,l,r)),this._fastUpdates.enabled?(Object.assign(u,this._fastUpdates.materialParameters),u.instanced.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(u.instanced.push("color"),this._optionalFields.push("color"));const _=new ne(u),P=N(s,_);if(!P)throw new Error(`Unknown object symbol primitive: ${s}`);const v=re(P).map((e=>({opacity:1,transparent:e.params.transparent}))),x=this._createStageResources(P,y);return{lodResources:P,lodRenderer:await this._createLodRenderer(P,i),stageResources:x,symbolSize:c,extentPadding:h,isEsriSymbolResource:d,isWosr:m,originalMaterialParameters:v,physicalBasedRenderingEnabled:y,resourceBoundingBox:n,resourceSize:l,dispose:r,pivotOffset:r}}async _createResourcesForUrl(e,t){const i=["transformation"],a={materialParamsMixin:{instanced:i,slicePlaneEnabled:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(r,r,r,r)),this._fastUpdates.enabled?(Object.assign(a.materialParamsMixin,this._fastUpdates.materialParameters),i.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(i.push("color"),this._optionalFields.push("color"));const n=this.symbol;if("point-3d"===n.type&&n.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=n.verticalOffset;a.materialParamsMixin.verticalOffset={screenLength:o(e),minWorldLength:t||0,maxWorldLength:null!=s?s:1/0},a.materialParamsMixin.castShadows=!1}a.signal=t,a.usePBR=this._context.physicalBasedRenderingEnabled;const l=a.usePBR,c=await $(e,a),h=c.isEsriSymbolResource,d=c.isWosr,m=c.remove,u=q(c.lods);H(u),u.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius)),u.levels[0].minScreenSpaceRadius=Math.min(2,u.levels[0].minScreenSpaceRadius);const y=this._context,f=this.symbolLayer.material,_=this._getExternalColorParameters(f),b=s(this.symbolLayer,"material","color"),P=this._getCombinedOpacity(b,{hasIntrinsicColor:!0}),v=this.needsDrivenTransparentPass,x=re(u),R=re(u).map((e=>({opacity:e.params.opacity||1,transparent:e.params.transparent})));x.forEach((e=>{const t=e.params;e.setParameterValues(_);const s=t.opacity*P,r=s<1||v||t.transparent;e.setParameterValues({opacity:s,transparent:r}),y.screenSizePerspectiveEnabled&&e.setParameterValues({screenSizePerspective:y.sharedResources.screenSizePerspectiveSettings})}));const L=c.referenceBoundingBox,S=g(U(L)),C=g(u.levels[0].pivotOffset),E=g(G(S,this.symbolLayer)),j=p(E);Y(this._fastUpdates,this._context.renderer,this._fastVisualVariableConvertOptions(L,E,S,C))&&x.forEach((e=>e.setParameterValues(this._fastUpdates.materialParameters)));const w=this._createStageResources(u,l);return{lodResources:u,lodRenderer:await this._createLodRenderer(u,t),stageResources:w,symbolSize:E,extentPadding:j,isEsriSymbolResource:h,isWosr:d,originalMaterialParameters:R,physicalBasedRenderingEnabled:l,resourceBoundingBox:L,resourceSize:S,dispose:m,pivotOffset:C}}_createStageResources(e,t){const s=this._context.stage,r=re(e);t!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),s.addMany(r);const i=ie(e);s.addMany(i);const a=ae(e);return s.addMany(a),{materials:r,textures:i,geometries:a}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates.enabled?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,pe),n(s,ee(this._fastUpdates.materialParameters,pe,s))},scaleFactor:(e,t,s)=>(t.getFeatureAttribute(s,pe),te(e,this._fastUpdates.materialParameters,pe))}:null,a=new se(e,this._optionalFields,r,i);return a.slicePlane=this._context.slicePlaneEnabled,await s.addRenderPlugin(a.slots,a,t),a}_getExternalColorParameters(s){const r={};return this._drivenProperties.color?r.externalColor=R:t(s)&&t(s.color)?r.externalColor=e.toUnitRGBA(s.color):(r.externalColor=R,r.colorMixMode="ignore"),r}destroy(){super.destroy();const e=this._context.stage;if(t(this._resources)){e.removeRenderPlugin(this._resources.lodRenderer);const s=this._resources.stageResources;e.removeMany(s.materials),e.removeMany(s.textures),e.removeMany(s.geometries),t(this._resources.dispose)&&this._resources.dispose()}this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=Z(t.geometry);if(i(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new I),a=e.renderingInfo;return this._createAs3DShape(t,s,a,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(i(this._resources))return!0;const e=this._drivenProperties.opacity,t=!this.isPrimitive,r=this._resources.stageResources.materials,a=this._resources.originalMaterialParameters;for(let i=0;i<r.length;i++){const o=r[i],n=s(this.symbolLayer,"material","color"),l=a[i],c=this._getCombinedOpacity(n,{hasIntrinsicColor:t})*l.opacity,h=c<1||e||l.transparent;o.setParameterValues({opacity:c,transparent:h}),this.isPrimitive&&o.setParameterValues({cullFace:h?0:2})}return!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,V)}slicePlaneEnabledChanged(){if(i(this._resources))return!0;this._resources.lodRenderer.slicePlane=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameterValues({slicePlaneEnabled:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(i(this._resources))return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this.isPrimitive?s.setParameterValues({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameterValues({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this.hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this.hasLoadedPBRTextures=!0,!1)}pixelRatioChanged(){return!0}applyRendererDiff(e,t){if(i(this._resources))return!0;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:a,symbolSize:o,resourceSize:n,pivotOffset:l}=this._resources;for(const i in e.diff){if("visualVariables"!==i)return!1;if(!Y(this._fastUpdates,t,this._fastVisualVariableConvertOptions(a,o,n,l)))return!1;for(const e of s)e.setParameterValues(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return!0}computeComplexity(){if(i(this._resources))return super.computeComplexity();return{primitivesPerFeature:oe(this._resources.lodResources.levels[0]).reduce(((e,t)=>e+t.indices.get("position").length),0)/3,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:Q(this.symbol,this.symbolLayer)}}hasLodRenderer(){return t(this._resources)}_createAs3DShape(e,s,r,a,o){if(!this.hasLodRenderer()||i(this._resources))return null;const n=this.getFastUpdateAttrValues(e),l=!this._fastUpdates.enabled&&this._hasPerInstanceColor()?F(r.color,r.opacity):null,c=this._context.clippingExtent;if(S(s,ce,this._context.elevationProvider.spatialReference),t(c)&&!j(c,ce))return null;const h=this._requiresTerrainElevation(a),d=this._computeGlobalTransform(s,a,de,h?me:null),p=this._computeLocalTransform(this._resources,this.symbolLayer,r,he),m=this._resources.lodRenderer.instanceData,u=m.addInstance();this._instanceIndexToGraphicUid.set(u,o),m.setLocalTransform(u,p,!1),m.setGlobalTransform(u,d),n&&m.setFeatureAttribute(u,n),l&&m.setColor(u,l);const y=new M(this,u,O,a);return h&&(y.alignedSampledElevation=me.sampledElevation),y.needsElevationUpdates=V(a.mode),J(y,s,this._context.elevationProvider),y}_computeGlobalTransform(e,t,s,r){const i=z(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r);return ce[0]=e.x,ce[1]=e.y,ce[2]=i,C(e.spatialReference,ce,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return l(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=k(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||c(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(i(this._resources))return!0;const s=t&&Z(t);if(i(s))return!1;const r=this.getGeometryElevationMode(t);if(e.elevationContext.mode!==r)return!1;const a=this._requiresTerrainElevation(e.elevationContext);return this._computeGlobalTransform(s,e.elevationContext,de,a?me:null),a&&(e.alignedSampledElevation=me.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,de,!0),J(e,s,this._context.elevationProvider),!0}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(i(this._resources))return;const s=(e,t,s)=>a(null!=e&&"complete"===e.type?e.newValue:t,s),r=s(t.heading,this.symbolLayer.heading,0),o=s(t.tilt,this.symbolLayer.tilt,0),n=s(t.roll,this.symbolLayer.roll,0),l=s(t.width,this.symbolLayer.width,void 0),c=s(t.height,this.symbolLayer.height,void 0),h=s(t.depth,this.symbolLayer.depth,void 0),d=s(t.anchor,this.symbolLayer.anchor,void 0),p=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const m={heading:r,tilt:o,roll:n,anchor:d,anchorPosition:p},u=this._resources;1===this.loadStatus&&e.symbolLayerStatePatches.push((()=>{u.symbolSize=g(G(u.resourceSize,{width:l,height:c,depth:h,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(u,m,t,he),r=e.instanceIndex;u.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(s,r){if(!r.material||"partial"!==r.material.type)return;const a=r.material.diff;if(!a.color||"complete"!==a.color.type||null==a.color.newValue||null==a.color.oldValue)return;const o=a.color.newValue,n=t(o)?e.toUnitRGBA(o):R;delete a.color;const l=this._resources;i(l)||s.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(l.lodRenderer.instanceData.setColor(e.instanceIndex,n),t=this.setMaterialTransparencyParams({},o)):t=this.setMaterialTransparencyParams({externalColor:n},o);for(const s of l.stageResources.materials)s.setParameterValues(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation&&t))return W(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,s,r){const i=x();switch(r.anchor){case"center":u(i,w(e)),m(i,i);break;case"top":{const t=w(e);_(i,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);_(i,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),s=U(e),a=r.anchorPosition,o=a?v(a.x,a.y,a.z):P;y(i,s,o),f(i,i,t),m(i,i);break}default:t(s)?m(i,s):u(i,P)}return i}_applyAnchor(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&h(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,s,r,i){const a=t(e)?g(U(e)):b,o=t(e)?this._computeAnchor(e,i,this.symbolLayer):P,n=this._context.renderCoordsHelper.unitInMeters,l=k(t(s)?s:void 0,s,r,n),c=v(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return{modelSize:a,symbolSize:t(s)?s:b,unitInMeters:n,transformation:{anchor:o,scale:l,rotation:c}}}}const ce=x(),he=d(),de=d(),pe=L(),me={verticalDistanceToGround:0,sampledElevation:0};export{le as Graphics3DObjectSymbolLayer,le as default};
5
+ import e from"../../../../Color.js";import{isSome as t,get as s,none as r,isNone as i,unwrapOr as a}from"../../../../core/maybe.js";import{pt2px as o}from"../../../../core/screenUtils.js";import{e as n,i as l,f as c,t as h}from"../../../../chunks/mat4.js";import{c as d}from"../../../../chunks/mat4f64.js";import{l as p,o as m,g as u,D as y,b as f,s as _}from"../../../../chunks/vec3.js";import{d as g,O as b,Z as P,f as v,c as x}from"../../../../chunks/vec3f64.js";import{O as R,c as L}from"../../../../chunks/vec4f64.js";import{projectPointToVector as S,computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection.js";import{create as E,size as U,containsPoint as w,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as B}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as T,objectSymbolLayerSizeWithResourceSize as G}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as O}from"./ElevationAligners.js";import{needsElevationUpdates3D as z,evaluateElevationInfoAtPoint as I,SampleElevationInfo as M}from"./elevationAlignmentUtils.js";import{ElevationContext as D}from"./ElevationContext.js";import A from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as V,mixinColorAndOpacity as k,computeObjectScale as W,computeObjectRotation as q}from"./graphicUtils.js";import{makeLodResources as H,fillEstimatedMinScreenSpaceRadius as $}from"./lodResourceUtils.js";import{fetch as Z}from"./objectResourceUtils.js";import{placePointOnGeometry as J,extendPointGraphicElevationContext as K}from"./pointUtils.js";import{isValidPrimitive as N,primitiveLodResources as Q}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as X}from"./symbolComplexity.js";import{initFastSymbolUpdatesState as Y,updateFastSymbolUpdatesState as ee,evaluateModelTransform as te,evaluateModelTransformScale as se}from"../support/FastSymbolUpdates.js";import{LodRenderer as re}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ie,texturesFromLodResources as ae,geometriesFromLodResources as oe,geometriesFromLodLevelResources as ne}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as le}from"../../webgl-engine/materials/DefaultMaterial.js";class ce extends F{constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this.hasLoadedPBRTextures=!1,this.ensureDrapedStatus(!1),this.hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}getCachedSize(){const[e,s,r]=t(this._resources)?this._resources.symbolSize:[1,1,1];return{width:e,depth:s,height:r}}async doLoad(e){if(!this._drivenProperties.size){if(V(this.symbolLayer))throw new Error}const t=this.symbolLayer;if(this.isPrimitive){const s=t.resource?t.resource.primitive:B;this._resources=await this._createResourcesForPrimitive(s,e)}else this._resources=await this._createResourcesForUrl(t.resource.href,e);this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return t(this._resources)?this._resources.extentPadding:0}get isPrimitive(){return!(this.symbolLayer.resource&&this.symbolLayer.resource.href)}get lodRenderer(){return s(this._resources,"lodRenderer")}setMaterialTransparencyParams(e,t=s(this.symbolLayer,"material","color")){const r=this._getCombinedOpacity(t),i=r<1||this.needsDrivenTransparentPass;return e.transparent=i,e.opacity=r,e.cullFace=i?0:2,e}async _createResourcesForPrimitive(s,i){if(!N(s))throw new Error(`Unknown object symbol primitive: ${s}`);const a=this.symbolLayer,n=E(T(s)),l=g(U(n)),c=g(G(l,a)),h=p(c),d=!1,m=!1,u={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,instanced:["transformation"],ambient:b,diffuse:b,slicePlaneEnabled:this._context.slicePlaneEnabled,sliceHighlightDisabled:!0,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},y=u.usePBR;this.setMaterialTransparencyParams(u);const f=this.symbol;if("point-3d"===f.type&&f.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=f.verticalOffset;u.verticalOffset={screenLength:o(e),minWorldLength:t||0,maxWorldLength:null!=s?s:1/0},u.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(u.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)u.externalColor=R;else{const s=t(a.material)&&a.material.color,r=t(s)?e.toUnitRGBA(s):R;u.externalColor=r}this._fastUpdates=Y(this._context.renderer,this._fastVisualVariableConvertOptions(n,c,l,r)),this._fastUpdates.enabled?(Object.assign(u,this._fastUpdates.materialParameters),u.instanced.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(u.instanced.push("color"),this._optionalFields.push("color"));const _=new le(u),P=Q(s,_);if(!P)throw new Error(`Unknown object symbol primitive: ${s}`);const v=ie(P).map((e=>({opacity:1,transparent:e.parameters.transparent}))),x=await this._createStageResources(P,y);return{lodResources:P,lodRenderer:await this._createLodRenderer(P,i),stageResources:x,symbolSize:c,extentPadding:h,isEsriSymbolResource:d,isWosr:m,originalMaterialParameters:v,physicalBasedRenderingEnabled:y,resourceBoundingBox:n,resourceSize:l,dispose:r,pivotOffset:r}}async _createResourcesForUrl(e,t){const i=["transformation"],a={materialParamsMixin:{instanced:i,slicePlaneEnabled:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=Y(this._context.renderer,this._fastVisualVariableConvertOptions(r,r,r,r)),this._fastUpdates.enabled?(Object.assign(a.materialParamsMixin,this._fastUpdates.materialParameters),i.push("featureAttribute"),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(i.push("color"),this._optionalFields.push("color"));const n=this.symbol;if("point-3d"===n.type&&n.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=n.verticalOffset;a.materialParamsMixin.verticalOffset={screenLength:o(e),minWorldLength:t||0,maxWorldLength:null!=s?s:1/0},a.materialParamsMixin.castShadows=!1}a.signal=t,a.usePBR=this._context.physicalBasedRenderingEnabled;const l=a.usePBR,c=await Z(e,a),h=c.isEsriSymbolResource,d=c.isWosr,m=c.remove,u=H(c.lods);$(u),u.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius)),u.levels[0].minScreenSpaceRadius=Math.min(2,u.levels[0].minScreenSpaceRadius);const y=this._context,f=this.symbolLayer.material,_=this._getExternalColorParameters(f),b=s(this.symbolLayer,"material","color"),P=this._getCombinedOpacity(b,{hasIntrinsicColor:!0}),v=this.needsDrivenTransparentPass,x=ie(u),R=ie(u).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));x.forEach((e=>{const t=e.parameters;e.setParameters(_);const s=t.opacity*P,r=s<1||v||t.transparent;e.setParameters({opacity:s,transparent:r}),y.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:y.sharedResources.screenSizePerspectiveSettings})}));const L=c.referenceBoundingBox,S=g(U(L)),C=g(u.levels[0].pivotOffset),E=g(G(S,this.symbolLayer)),w=p(E);ee(this._fastUpdates,this._context.renderer,this._fastVisualVariableConvertOptions(L,E,S,C))&&x.forEach((e=>e.setParameters(this._fastUpdates.materialParameters)));const j=await this._createStageResources(u,l);return{lodResources:u,lodRenderer:await this._createLodRenderer(u,t),stageResources:j,symbolSize:E,extentPadding:w,isEsriSymbolResource:h,isWosr:d,originalMaterialParameters:R,physicalBasedRenderingEnabled:l,resourceBoundingBox:L,resourceSize:S,dispose:m,pivotOffset:C}}async _createStageResources(e,t){const s=this._context.stage,r=ie(e);t!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),s.addMany(r);const i=ae(e);s.addMany(i),await s.load(i);const a=oe(e);return s.addMany(a),{materials:r,textures:i,geometries:a}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates.enabled?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,me),n(s,te(this._fastUpdates.materialParameters,me,s))},scaleFactor:(e,t,s)=>(t.getFeatureAttribute(s,me),se(e,this._fastUpdates.materialParameters,me))}:null,a=new re(e,this._optionalFields,r,i);return a.slicePlane=this._context.slicePlaneEnabled,await s.addRenderPlugin(a.slots,a,t),a}_getExternalColorParameters(s){const r={};return this._drivenProperties.color?r.externalColor=R:t(s)&&t(s.color)?r.externalColor=e.toUnitRGBA(s.color):(r.externalColor=R,r.colorMixMode="ignore"),r}destroy(){super.destroy();const e=this._context.stage;if(t(this._resources)){e.removeRenderPlugin(this._resources.lodRenderer);const s=this._resources.stageResources;e.removeMany(s.materials),e.removeMany(s.textures),e.removeMany(s.geometries),t(this._resources.dispose)&&this._resources.dispose()}this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=J(t.geometry);if(i(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new D),a=e.renderingInfo;return this._createAs3DShape(t,s,a,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(i(this._resources))return!0;const e=this._drivenProperties.opacity,t=!this.isPrimitive,r=this._resources.stageResources.materials,a=this._resources.originalMaterialParameters;for(let i=0;i<r.length;i++){const o=r[i],n=s(this.symbolLayer,"material","color"),l=a[i],c=this._getCombinedOpacity(n,{hasIntrinsicColor:t})*l.opacity,h=c<1||e||l.transparent;o.setParameters({opacity:c,transparent:h}),this.isPrimitive&&o.setParameters({cullFace:h?0:2})}return!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,z)}slicePlaneEnabledChanged(){if(i(this._resources))return!0;this._resources.lodRenderer.slicePlane=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(i(this._resources))return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this.isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this.hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this.hasLoadedPBRTextures=!0,!1)}pixelRatioChanged(){return!0}applyRendererDiff(e,t){if(i(this._resources))return!0;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:a,symbolSize:o,resourceSize:n,pivotOffset:l}=this._resources;for(const i in e.diff){if("visualVariables"!==i)return!1;if(!ee(this._fastUpdates,t,this._fastVisualVariableConvertOptions(a,o,n,l)))return!1;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return!0}computeComplexity(){if(i(this._resources))return super.computeComplexity();return{primitivesPerFeature:ne(this._resources.lodResources.levels[0]).reduce(((e,t)=>e+t.indices.get("position").length),0)/3,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:X(this.symbol,this.symbolLayer)}}hasLodRenderer(){return t(this._resources)}_createAs3DShape(e,s,r,a,o){if(!this.hasLodRenderer()||i(this._resources))return null;const n=this.getFastUpdateAttrValues(e),l=!this._fastUpdates.enabled&&this._hasPerInstanceColor()?k(r.color,r.opacity):null,c=this._context.clippingExtent;if(S(s,he,this._context.elevationProvider.spatialReference),t(c)&&!w(c,he))return null;const h=this._requiresTerrainElevation(a),d=this._computeGlobalTransform(s,a,pe,ue),p=this._computeLocalTransform(this._resources,this.symbolLayer,r,de),m=this._resources.lodRenderer.instanceData,u=m.addInstance();this._instanceIndexToGraphicUid.set(u,o),m.setLocalTransform(u,p,!1),m.setGlobalTransform(u,d),n&&m.setFeatureAttribute(u,n),l&&m.setColor(u,l);const y=new A(this,u,O,a);return h&&(y.alignedSampledElevation=ue.sampledElevation),y.needsElevationUpdates=z(a.mode),K(y,s,this._context.elevationProvider),y}_computeGlobalTransform(e,t,s,r){return I(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),he[0]=e.x,he[1]=e.y,he[2]=r.z,C(e.spatialReference,he,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return l(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=W(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||c(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(i(this._resources))return!0;const s=t&&J(t);if(i(s))return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,pe,ue),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=ue.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,pe,!0),K(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(i(this._resources))return;const s=(e,t,s)=>a(null!=e&&"complete"===e.type?e.newValue:t,s),r=s(t.heading,this.symbolLayer.heading,0),o=s(t.tilt,this.symbolLayer.tilt,0),n=s(t.roll,this.symbolLayer.roll,0),l=s(t.width,this.symbolLayer.width,void 0),c=s(t.height,this.symbolLayer.height,void 0),h=s(t.depth,this.symbolLayer.depth,void 0),d=s(t.anchor,this.symbolLayer.anchor,void 0),p=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const m={heading:r,tilt:o,roll:n,anchor:d,anchorPosition:p},u=this._resources;1===this.loadStatus&&e.symbolLayerStatePatches.push((()=>{u.symbolSize=g(G(u.resourceSize,{width:l,height:c,depth:h,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(u,m,t,de),r=e.instanceIndex;u.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(s,r){if(!r.material||"partial"!==r.material.type)return;const a=r.material.diff;if(!a.color||"complete"!==a.color.type||null==a.color.newValue||null==a.color.oldValue)return;const o=a.color.newValue,n=t(o)?e.toUnitRGBA(o):R;delete a.color;const l=this._resources;i(l)||s.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(l.lodRenderer.instanceData.setColor(e.instanceIndex,n),t=this.setMaterialTransparencyParams({},o)):t=this.setMaterialTransparencyParams({externalColor:n},o);for(const s of l.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation&&t))return q(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,s,r){const i=x();switch(r.anchor){case"center":u(i,j(e)),m(i,i);break;case"top":{const t=j(e);_(i,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);_(i,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),s=U(e),a=r.anchorPosition,o=a?v(a.x,a.y,a.z):P;y(i,s,o),f(i,i,t),m(i,i);break}default:t(s)?m(i,s):u(i,P)}return i}_applyAnchor(e,t,s){if(this._fastUpdates.enabled&&this._fastUpdates.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&h(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,s,r,i){const a=t(e)?g(U(e)):b,o=t(e)?this._computeAnchor(e,i,this.symbolLayer):P,n=this._context.renderCoordsHelper.unitInMeters,l=W(t(s)?s:void 0,s,r,n),c=v(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return{modelSize:a,symbolSize:t(s)?s:b,unitInMeters:n,transformation:{anchor:o,scale:l,rotation:c}}}}const he=x(),de=d(),pe=d(),me=L(),ue=new M;export{ce as Graphics3DObjectSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{acosClamped as t,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{isSome as r,get as s}from"../../../../core/maybe.js";import{s as a}from"../../../../chunks/mat2.js";import{s as o,b as n}from"../../../../chunks/vec2.js";import{f as l}from"../../../../chunks/vec2f64.js";import{s as h,b as c,d as p,c as m,a as d,n as f,o as u,f as g}from"../../../../chunks/vec3.js";import{c as y}from"../../../../chunks/vec3f32.js";import{d as _,c as b}from"../../../../chunks/vec3f64.js";import{projectBuffer as v}from"../../../../geometry/projection.js";import{create as x,empty as w,expandWithBuffer as S,intersectsClippingArea as D}from"../../../../geometry/support/aaBoundingBox.js";import{makeDehydratedPoint as R}from"../../../../layers/graphics/dehydratedFeatures.js";import{needsElevationUpdates3D as P,evaluateElevationAlignmentAtPoint as V}from"./elevationAlignmentUtils.js";import{ElevationContext as j}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as C}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as A,getAttributeValue as E}from"./Graphics3DSymbolLayer.js";import{isValidSize as L}from"./graphicUtils.js";import{initFastSymbolUpdatesState as z,updateFastSymbolUpdatesState as U}from"../support/FastSymbolUpdates.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{PathGeometry as F,isPathGeometry as G}from"../../webgl-engine/lib/PathGeometry.js";import{Profile as I,SimpleExtruder as M,MiterExtruder as O,RoundCapBuilder as B,TriangulationCapBuilder as q,NoCapBuilder as H,PathVertex as T,Path as N,Builder as W,FastUpdatePathGeometry as Z,StaticPathGeometry as J,computeMinimumRotationTangentFrame as K,vertexSpaceToProfileSpace as Q}from"../../webgl-engine/lib/pathGeometryUtils.js";import{DefaultMaterial as X}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as Y}from"../../webgl-engine/materials/PathMaterial.js";const $=["polyline"];class ee extends A{constructor(e,t,i,r){super(e,t,i,r),this._intrinsicSize=l(1,1),this.upVectorAlignment="path",this.stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const t=r(this.symbolLayer.width)?this.symbolLayer.width:this.symbolLayer.height,i=r(this.symbolLayer.height)?this.symbolLayer.height:t;this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[t,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,transformation:{anchor:[0,0,0],scale:[1,1,1],rotation:[0,0,0]},supportedTypes:{size:!0,color:!0,opacity:!0,rotation:!1}},this._context.renderer&&this._context.renderer.visualVariables&&this._context.renderer.visualVariables.length>0?this._fastUpdates=z(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1};const a=this.symbolLayer.anchor||"center";this.upVectorAlignment="path","heading"===this.symbolLayer.profileRotation&&(this.upVectorAlignment="world");const l=this.symbolLayer.profile||"circle";if("quad"===l)this._profile=I.rect();else this._profile=I.circle(me);let h=[0,0];"center"!==a&&(h={left:[.5,0],right:[-.5,0],top:[0,-.5],bottom:[0,.5]}[a],this._profile.translate(h[0],h[1]));switch(this.symbolLayer.join||"simple"){case"round":this._extruder=new O(0,ce);break;case"bevel":this._extruder=new O(0,1);break;case"miter":this._extruder=new O(.8*Math.PI,1);break;default:this._extruder=new M}const c=this.symbolLayer.cap||"butt";switch(c){case"none":this._startCap=new H,this._endCap=new H;break;default:this._startCap=new q(this._profile,0),this._endCap=new q(this._profile,0,!0);break;case"square":this._startCap=new q(this._profile,-.5),this._endCap=new q(this._profile,.5,!0);break;case"round":{const e="quad"===l;this._startCap=new B({profile:this._profile,flip:!1,breakNormals:e,subdivisions:pe}),this._endCap=new B({profile:this._profile,flip:!0,breakNormals:e,subdivisions:pe});break}}const p=s(this.symbolLayer,"material","color"),m=this._getCombinedOpacityAndColor(p),d=_(m),f=m[3],u=f<1||this.needsDrivenTransparentPass,g={diffuse:d,ambient:d,opacity:f,transparent:u,vertexColors:!1,slicePlaneEnabled:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:u||"none"===c?0:2,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(o(this._intrinsicSize,t,i),!L(this._intrinsicSize[0])||!L(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size||n(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates.enabled?(Object.assign(g,this._fastUpdates.materialParameters,{size:[this._intrinsicSize[0],this._intrinsicSize[1],0]}),this._material=new Y(g)):(g.vertexColors=this._drivenProperties.color||this._drivenProperties.opacity,this._material=new X(g)),this._material.setParameterValues({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,$,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t,new j),r=e.renderingInfo;return this._createAs3DShape(t,r,i,t.uid)}layerOpacityChanged(){const e=s(this.symbolLayer,"material","color"),t=this._getCombinedOpacity(e),i=t<1||this.needsDrivenTransparentPass;return this._material.setParameterValues({opacity:t,transparent:i}),!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,P)}slicePlaneEnabledChanged(){return this._material.setParameterValues({slicePlaneEnabled:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameterValues({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}pixelRatioChanged(){return!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return!1;if(!U(this._fastUpdates,t,this._vvConvertOptions))return!1;this._material.setParameterValues(this._fastUpdates.materialParameters)}return!0}getVertexData(e){let t=0;const i=e.paths,r=[],s=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const m of i)t+=m.length;const n=new Float64Array(3*t),l=new Float64Array(3*t),h=new Float64Array(3*t);let c=0;for(const m of i){r.push({index:c,numVertices:m.length});for(const t of m)n[c++]=t[0],n[c++]=t[1],n[c++]=e.hasZ?t[2]:0}let p=!0;return s.equals(a)?this._copyVertices(n,0,l,0,t):p=v(n,s,0,l,a,0,t),a.equals(o)?this._copyVertices(l,0,h,0,t):v(l,a,0,h,o,0,t),{pathVertexDataInfos:r,vertexDataGS:n,vertexDataES:l,vertexDataRS:h,projectionSuccess:p,terrainElevation:0}}_copyVertices(e,t,i,r,s){t*=3,r*=3;for(let a=0;a<s;++a)i[r++]=e[t++],i[r++]=e[t++],i[r++]=e[t++]}_createAs3DShape(e,t,i,s){const a=e.geometry,o=new Array,n=new Array,l=new Array,c=a.spatialReference,p=x(),m=this._context.renderCoordsHelper;oe.spatialReference=c;const d=this.getVertexData(a);if(!d.projectionSuccess)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(d.pathVertexDataInfos.length>0){for(let s=0;s<d.pathVertexDataInfos.length;++s){const a=d.pathVertexDataInfos[s],f=a.index,u=a.numVertices;if(u<2)continue;if(r(this._context.clippingExtent)&&(w(p),S(p,d.vertexDataES,3*f,u),!D(p,this._context.clippingExtent)))continue;const g=[];for(let e=f;e<f+3*u;){const t=e++,r=e++,s=e++,a=new T;h(a.posGS,d.vertexDataGS[t],d.vertexDataGS[r],d.vertexDataGS[s]),h(a.posES,d.vertexDataES[t],d.vertexDataES[r],d.vertexDataES[s]);const o=V(a.posES,this._context.elevationProvider,i,m,null);h(ne,d.vertexDataRS[t],d.vertexDataRS[r],d.vertexDataRS[s]),m.setAltitude(ne,o),h(a.pos,ne[0],ne[1],ne[2]),g.push(a)}const y=new N(g);te(y,this.upVectorAlignment,this._context.renderCoordsHelper);const _=new W(y,this._profile,this._extruder,this._startCap,this._endCap);let b=null;if(this._fastUpdates.enabled){const t=this._fastUpdates.visualVariables,i=t.size?E(t.size.field,e):0,r=t.color?E(t.color.field,e):0,s=t.opacity?E(t.opacity.field,e):0;b=new Z(_,i,r,s)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];this._drivenProperties.size&&(e[0]*=ie(t.size[0],"symbol-value"===t.size[2]?this.symbolLayer.height||0:t.size[2],this.symbolLayer.width||0),e[1]*=ie(t.size[2],"symbol-value"===t.size[0]?this.symbolLayer.width||0:t.size[0],this.symbolLayer.height||0));let i=null;this._drivenProperties.color&&(i=t.color),this._drivenProperties.opacity&&null!=t.opacity&&(i=i?[i[0],i[1],i[2],t.opacity]:[1,1,1,t.opacity]);const r=new J(_);r.bake(e),i&&r.bakeVertexColors(i),b=r}const{vertexAttributes:v,indices:x}=b.createGeometryData(),R=new F(v,x,b,c,this.upVectorAlignment,this.stencilWidth);o.push(R),n.push(this._material),l.push(b.xform)}if(o.length>0){const e={layerUid:this._context.layer.uid,graphicUid:s},t=new k({geometries:o,materials:n,transformations:l,metadata:e}),r=new C(this,t,o,null,null,se,i);return r.alignedSampledElevation=d.terrainElevation,r.needsElevationUpdates=P(i.mode),r}}else 0!==a.paths.length&&a.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)");return null}}function te(e,r,s){switch(r){case"world":for(const t of e.vertices)c(le,t.pos,e.offset),s.worldUpAtPosition(le,ne),t.setFrameFromUpVector(ne),t.computeRotationAxisAndAngleFromUpVector();break;case"path":c(le,e.vertices[0].pos,e.offset),s.worldUpAtPosition(le,ne),K(e,ne);for(const r of e.vertices){const e=Math.sign(p(r.frame.right,r.vRight));m(r.rotationFrame.up,r.vRight,r.vLeft),d(r.rotationFrame.up,r.rotationFrame.up,e),f(r.rotationFrame.up,r.rotationFrame.up);const s=p(r.rotationFrame.up,r.frame.up),o=p(r.rotationFrame.up,r.frame.right);if(d(le,r.frame.up,-o),d(he,r.frame.right,s),c(le,le,he),f(r.rotationFrame.right,le),Q(r.rotationRight,r.frame,r.rotationFrame.right),u(le,r.vLeft),r.rotationAngle=-e*(Math.PI-t(p(le,r.vRight))),Math.abs(r.rotationAngle)>0){const e=i(Math.cos(.5*r.rotationAngle));a(r.miterStretch,1+(e-1)*r.rotationRight[0]*r.rotationRight[0],(e-1)*r.rotationRight[0]*r.rotationRight[1],(e-1)*r.rotationRight[0]*r.rotationRight[1],1+(e-1)*r.rotationRight[1]*r.rotationRight[1])}const n=Math.PI-r.rotationAngle;r.maxStretchDistance=Math.abs(Math.min(r.vLeftLength,r.vRightLength)*i(Math.cos(.5*n)))}}}function ie(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function re(e,t,i,r){let s=0;for(const a of e.vertices){const o=V(a.posES,i,t,r,de);s+=de.sampledElevation,c(ne,a.pos,e.offset),r.setAltitude(ne,o),g(a.pos,ne,e.offset)}return e.updatePathVertexInformation(),s/e.vertices.length}function se(e,t,i,r){const s=e.stageObject,a=s.geometryRecords,o=a.length;let n=0;ae.spatialReference=r.spatialReference;for(let l=0;l<o;l++){const e=a[l].geometry;if(!G(e))continue;const o=e.path,h=o.builder.path,c=e.geometrySR;oe.spatialReference=c,n+=re(h,t,i,r),"world"!==e.upVectorAlignment&&te(h,e.upVectorAlignment,r),o.onPathChanged(),e.invalidateBoundingInfo(),s.geometryVertexAttrsUpdated(l)}return n/o}const ae=R(0,0,0,null),oe=R(0,0,0,null),ne=b(),le=y(),he=y(),ce=3,pe=3,me=10,de={verticalDistanceToGround:0,sampledElevation:0};export{ee as Graphics3DPathSymbolLayer,me as NUM_CIRCLE_PROFILE_SUBDIVISIONS,pe as NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS,ce as NUM_ROUND_JOIN_SUBDIVISIONS,ee as default};
5
+ import e from"../../../../core/Error.js";import{acosClamped as t,reciprocalClamped as i}from"../../../../core/mathUtils.js";import{isSome as r,get as s}from"../../../../core/maybe.js";import{s as a}from"../../../../chunks/mat2.js";import{s as o,b as n}from"../../../../chunks/vec2.js";import{f as l}from"../../../../chunks/vec2f64.js";import{s as h,b as c,d as p,c as m,a as d,n as f,o as u,f as g}from"../../../../chunks/vec3.js";import{c as y}from"../../../../chunks/vec3f32.js";import{d as _,c as b}from"../../../../chunks/vec3f64.js";import{projectBuffer as v}from"../../../../geometry/projection.js";import{create as x,empty as w,expandWithBuffer as S,intersectsClippingArea as D}from"../../../../geometry/support/aaBoundingBox.js";import{makeDehydratedPoint as R}from"../../../../layers/graphics/dehydratedFeatures.js";import{needsElevationUpdates3D as P,evaluateElevationAlignmentAtPoint as j,SampleElevationInfo as C,evaluateElevationInfoAtPoint as A}from"./elevationAlignmentUtils.js";import{ElevationContext as z}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as L}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as V,getAttributeValue as E}from"./Graphics3DSymbolLayer.js";import{isValidSize as U}from"./graphicUtils.js";import{initFastSymbolUpdatesState as k,updateFastSymbolUpdatesState as F}from"../support/FastSymbolUpdates.js";import{Object3D as G}from"../../webgl-engine/lib/Object3D.js";import{PathGeometry as I,isPathGeometry as M}from"../../webgl-engine/lib/PathGeometry.js";import{Profile as O,SimpleExtruder as B,MiterExtruder as q,RoundCapBuilder as H,TriangulationCapBuilder as T,NoCapBuilder as N,PathVertex as W,Path as Z,Builder as J,FastUpdatePathGeometry as K,StaticPathGeometry as Q,computeMinimumRotationTangentFrame as X,vertexSpaceToProfileSpace as Y}from"../../webgl-engine/lib/pathGeometryUtils.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as ee}from"../../webgl-engine/materials/PathMaterial.js";const te=["polyline"];class ie extends V{constructor(e,t,i,r){super(e,t,i,r),this._intrinsicSize=l(1,1),this.upVectorAlignment="path",this.stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const t=r(this.symbolLayer.width)?this.symbolLayer.width:this.symbolLayer.height,i=r(this.symbolLayer.height)?this.symbolLayer.height:t;this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[t,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,transformation:{anchor:[0,0,0],scale:[1,1,1],rotation:[0,0,0]},supportedTypes:{size:!0,color:!0,opacity:!0,rotation:!1}},this._context.renderer&&this._context.renderer.visualVariables&&this._context.renderer.visualVariables.length>0?this._fastUpdates=k(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1};const a=this.symbolLayer.anchor||"center";this.upVectorAlignment="path","heading"===this.symbolLayer.profileRotation&&(this.upVectorAlignment="world");const l=this.symbolLayer.profile||"circle";if("quad"===l)this._profile=O.rect();else this._profile=O.circle(ue);let h=[0,0];"center"!==a&&(h={left:[.5,0],right:[-.5,0],top:[0,-.5],bottom:[0,.5]}[a],this._profile.translate(h[0],h[1]));switch(this.symbolLayer.join||"simple"){case"round":this._extruder=new q(0,de);break;case"bevel":this._extruder=new q(0,1);break;case"miter":this._extruder=new q(.8*Math.PI,1);break;default:this._extruder=new B}const c=this.symbolLayer.cap||"butt";switch(c){case"none":this._startCap=new N,this._endCap=new N;break;default:this._startCap=new T(this._profile,0),this._endCap=new T(this._profile,0,!0);break;case"square":this._startCap=new T(this._profile,-.5),this._endCap=new T(this._profile,.5,!0);break;case"round":{const e="quad"===l;this._startCap=new H({profile:this._profile,flip:!1,breakNormals:e,subdivisions:fe}),this._endCap=new H({profile:this._profile,flip:!0,breakNormals:e,subdivisions:fe});break}}const p=s(this.symbolLayer,"material","color"),m=this._getCombinedOpacityAndColor(p),d=_(m),f=m[3],u=f<1||this.needsDrivenTransparentPass,g={diffuse:d,ambient:d,opacity:f,transparent:u,vertexColors:!1,slicePlaneEnabled:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:u||"none"===c?0:2,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(o(this._intrinsicSize,t,i),!U(this._intrinsicSize[0])||!U(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size||n(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates.enabled?(Object.assign(g,this._fastUpdates.materialParameters,{size:[this._intrinsicSize[0],this._intrinsicSize[1],0]}),this._material=new ee(g)):(g.vertexColors=this._drivenProperties.color||this._drivenProperties.opacity,this._material=new $(g)),this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,te,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t,new z),r=e.renderingInfo;return this._createAs3DShape(t,r,i,t.uid)}layerOpacityChanged(){const e=s(this.symbolLayer,"material","color"),t=this._getCombinedOpacity(e),i=t<1||this.needsDrivenTransparentPass;return this._material.setParameters({opacity:t,transparent:i}),!0}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,P)}slicePlaneEnabledChanged(){return this._material.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}pixelRatioChanged(){return!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return!1;if(!F(this._fastUpdates,t,this._vvConvertOptions))return!1;this._material.setParameters(this._fastUpdates.materialParameters)}return!0}getVertexData(e){let t=0;const i=e.paths,r=[],s=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const m of i)t+=m.length;const n=new Float64Array(3*t),l=new Float64Array(3*t),h=new Float64Array(3*t);let c=0;for(const m of i){r.push({index:c,numVertices:m.length});for(const t of m)n[c++]=t[0],n[c++]=t[1],n[c++]=e.hasZ?t[2]:0}let p=!0;return s.equals(a)?this._copyVertices(n,0,l,0,t):p=v(n,s,0,l,a,0,t),a.equals(o)?this._copyVertices(l,0,h,0,t):v(l,a,0,h,o,0,t),{pathVertexDataInfos:r,vertexDataGS:n,vertexDataES:l,vertexDataRS:h,projectionSuccess:p,terrainElevation:0}}_copyVertices(e,t,i,r,s){t*=3,r*=3;for(let a=0;a<s;++a)i[r++]=e[t++],i[r++]=e[t++],i[r++]=e[t++]}_createAs3DShape(e,t,i,s){const a=e.geometry,o=new Array,n=new Array,l=new Array,c=a.spatialReference,p=x(),m=this._context.renderCoordsHelper;le.spatialReference=c;const d=this.getVertexData(a);if(!d.projectionSuccess)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(d.pathVertexDataInfos.length>0){for(let s=0;s<d.pathVertexDataInfos.length;++s){const a=d.pathVertexDataInfos[s],f=a.index,u=a.numVertices;if(u<2)continue;if(r(this._context.clippingExtent)&&(w(p),S(p,d.vertexDataES,3*f,u),!D(p,this._context.clippingExtent)))continue;const g=[];for(let e=f;e<f+3*u;){const t=e++,r=e++,s=e++,a=new W;h(a.posGS,d.vertexDataGS[t],d.vertexDataGS[r],d.vertexDataGS[s]),h(a.posES,d.vertexDataES[t],d.vertexDataES[r],d.vertexDataES[s]);const o=j(a.posES,this._context.elevationProvider,i,m);h(he,d.vertexDataRS[t],d.vertexDataRS[r],d.vertexDataRS[s]),m.setAltitude(he,o),h(a.pos,he[0],he[1],he[2]),g.push(a)}const y=new Z(g);re(y,this.upVectorAlignment,this._context.renderCoordsHelper);const _=new J(y,this._profile,this._extruder,this._startCap,this._endCap);let b=null;if(this._fastUpdates.enabled){const t=this._fastUpdates.visualVariables,i=t.size?E(t.size.field,e):0,r=t.color?E(t.color.field,e):0,s=t.opacity?E(t.opacity.field,e):0;b=new K(_,i,r,s)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];this._drivenProperties.size&&(e[0]*=se(t.size[0],"symbol-value"===t.size[2]?this.symbolLayer.height||0:t.size[2],this.symbolLayer.width||0),e[1]*=se(t.size[2],"symbol-value"===t.size[0]?this.symbolLayer.width||0:t.size[0],this.symbolLayer.height||0));let i=null;this._drivenProperties.color&&(i=t.color),this._drivenProperties.opacity&&null!=t.opacity&&(i=i?[i[0],i[1],i[2],t.opacity]:[1,1,1,t.opacity]);const r=new Q(_);r.bake(e),i&&r.bakeVertexColors(i),b=r}const{vertexAttributes:v,indices:x}=b.createGeometryData(),R=new I(v,x,b,c,this.upVectorAlignment,this.stencilWidth);o.push(R),n.push(this._material),l.push(b.xform)}if(o.length>0){const e={layerUid:this._context.layer.uid,graphicUid:s},t=new G({geometries:o,materials:n,transformations:l,metadata:e}),r=new L(this,t,o,null,null,oe,i);return r.alignedSampledElevation=d.terrainElevation,r.needsElevationUpdates=P(i.mode),r}}else 0!==a.paths.length&&a.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)");return null}}function re(e,r,s){switch(r){case"world":for(const t of e.vertices)c(ce,t.pos,e.offset),s.worldUpAtPosition(ce,he),t.setFrameFromUpVector(he),t.computeRotationAxisAndAngleFromUpVector();break;case"path":c(ce,e.vertices[0].pos,e.offset),s.worldUpAtPosition(ce,he),X(e,he);for(const r of e.vertices){const e=Math.sign(p(r.frame.right,r.vRight));m(r.rotationFrame.up,r.vRight,r.vLeft),d(r.rotationFrame.up,r.rotationFrame.up,e),f(r.rotationFrame.up,r.rotationFrame.up);const s=p(r.rotationFrame.up,r.frame.up),o=p(r.rotationFrame.up,r.frame.right);if(d(ce,r.frame.up,-o),d(pe,r.frame.right,s),c(ce,ce,pe),f(r.rotationFrame.right,ce),Y(r.rotationRight,r.frame,r.rotationFrame.right),u(ce,r.vLeft),r.rotationAngle=-e*(Math.PI-t(p(ce,r.vRight))),Math.abs(r.rotationAngle)>0){const e=i(Math.cos(.5*r.rotationAngle));a(r.miterStretch,1+(e-1)*r.rotationRight[0]*r.rotationRight[0],(e-1)*r.rotationRight[0]*r.rotationRight[1],(e-1)*r.rotationRight[0]*r.rotationRight[1],1+(e-1)*r.rotationRight[1]*r.rotationRight[1])}const n=Math.PI-r.rotationAngle;r.maxStretchDistance=Math.abs(Math.min(r.vLeftLength,r.vRightLength)*i(Math.cos(.5*n)))}}}function se(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function ae(e,t,i,r){let s=0;for(const a of e.vertices)A(a.posES,i,t,r,me),s+=me.sampledElevation,c(he,a.pos,e.offset),r.setAltitude(he,me.z),g(a.pos,he,e.offset);return e.updatePathVertexInformation(),s/e.vertices.length}function oe(e,t,i,r){const s=e.stageObject,a=s.geometryRecords;let o=0;ne.spatialReference=r.spatialReference;for(const n of a){const e=n.geometry;if(!M(e))continue;const a=e.path,l=a.builder.path,h=e.geometrySR;le.spatialReference=h,o+=ae(l,t,i,r),"world"!==e.upVectorAlignment&&re(l,e.upVectorAlignment,r),a.onPathChanged(),e.invalidateBoundingInfo(),s.geometryVertexAttrsUpdated(n)}return o/a.length}const ne=R(0,0,0,null),le=R(0,0,0,null),he=b(),ce=y(),pe=y(),me=new C,de=3,fe=3,ue=10;export{ie as Graphics3DPathSymbolLayer,ue as NUM_CIRCLE_PROFILE_SUBDIVISIONS,fe as NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS,de as NUM_ROUND_JOIN_SUBDIVISIONS};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{isSome as t,get as i,isNone as r,unwrap as n}from"../../../../core/maybe.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{e as o}from"../../../../chunks/earcut.js";import{I as s}from"../../../../chunks/mat4f64.js";import{s as l}from"../../../../chunks/vec4.js";import{create as u,empty as p,expandWithBuffer as c,intersectsClippingArea as h,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewMat3f64 as m,BufferViewVec3f64 as _,BufferViewVec4f as y}from"../../../../geometry/support/buffer/BufferView.js";import{SymbolUpdateType as g,elevationModeChangeUpdateType as f,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{ElevationContext as M}from"./ElevationContext.js";import v from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as E}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as x}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as D}from"./graphicUtils.js";import{createGeometry as O,parseCapType as S}from"./lineUtils.js";import{geometryAsPolygon as A,geometryToRenderInfo as P,createColorGeometry as w,geometryToRenderInfoDraped as U}from"./polygonUtils.js";import{createMaterial as C,uvElevationAligner as G}from"../support/patternUtils.js";import{createMapSpaceUVCoords as j,createMapSpaceUVCoordsDraped as T}from"../support/uvUtils.js";import{Object3D as R}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as L}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{NativeLineMaterial as V}from"../../webgl-engine/materials/NativeLineMaterial.js";import{PatternMaterial as N}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as F}from"../../webgl-engine/materials/RibbonLineMaterial.js";const I=["polyline","polygon","extent"];class W extends x{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){}ensureMaterials(){this.ensureFillMaterial(),this.ensureOutlineMaterial()}ensureFillMaterial(){if(t(this._material))return;const e=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(e);this._material=C(this.symbolLayer,{color:r,transparent:r[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,vertexColors:!0,writeLinearDepth:!0,slicePlaneEnabled:this._context.slicePlaneEnabled},{isDraped:this.draped}),this._needsUV=this._material instanceof N,this._context.stage.add(this._material)}ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(t(this._outlineMaterial)||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=B(e.pattern);return t>1.5?new F({width:t,color:this._getOutlineColor(),polygonOffset:!0,slicePlaneEnabled:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleIntegerRepeats:!0,scaleStippleWithLineWidth:!0,cap:S(e.patternCap||"butt")}):new V({color:this._getOutlineColor(),slicePlaneEnabled:this._context.slicePlaneEnabled,width:t,stipplePattern:i,stippleIntegerRepeats:!0})};this._outlineMaterial=i(a(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return t(e)&&e.size&&e.size>0&&t(e.color)&&"none"!==e.pattern}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null,this._context.stage.remove(this._outlineMaterial),this._outlineMaterial=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new M);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}layerOpacityChanged(){if(t(this._material)){const e=this._material.params.color,t=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacity(t);this._material.setParameterValues({color:[e[0],e[1],e[2],r],transparent:r<1||this.needsDrivenTransparentPass})}if(t(this._outlineMaterial)){const e=this._outlineMaterial.params.color;this._outlineMaterial.setParameterValues({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}return!0}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,n=f(W.elevationModeChangeTypes,i,r);if(n!==g.UPDATE)return n;const a=b(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){if(t(this._material)&&this._material.setParameterValues({slicePlaneEnabled:this._context.slicePlaneEnabled}),t(this._outlineMaterial)){const e={slicePlaneEnabled:this._context.slicePlaneEnabled};this._outlineMaterial.setParameterValues(e)}return!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_createAs3DShape(e,t,i){const n=A(e.geometry);if(r(n))return null;z.renderData=P(n,this._context.elevationProvider,this._context.renderCoordsHelper,i),z.color=t;const a=z.renderData.position.length/3;if(this._needsUV&&(z.uvMapSpace=new Float32Array(4*a),z.boundingRect=new Float64Array(9*a)),z.outNum=0,z.outGeometries=[],z.outTransforms=[],z.outMaterials=[],this._createAs3DShapeFill(z),this._hasOutline&&this._createAs3DShapeOutline(z),this._logGeometryCreationWarnings(z.renderData,n.rings,"rings","FillSymbol3DLayer"),0===z.outNum)return null;this._needsUV&&j(y.fromTypedArray(z.uvMapSpace),_.fromTypedArray(z.renderData.position),this._context.renderCoordsHelper,m.fromTypedArray(z.boundingRect));const o=new R({geometries:z.outGeometries,materials:z.outMaterials,transformations:z.outTransforms,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:e.uid}}),s=G,l=new E(this,o,z.outGeometries,null,null,s,i);return l.alignedSampledElevation=z.renderData.sampledElevation,l.needsElevationUpdates=b(i.mode),l}_createAs3DShapeFill(e){const i=e.renderData.polygons;for(const{position:r,mapPosition:a,holeIndices:l,index:u,count:d}of i){if(t(this._context.clippingExtent)&&(p(k),c(k,a),!h(k,this._context.clippingExtent)))continue;const i=o(a,l,3);if(0===i.length)continue;const m=new Uint32Array(i),_=w({indices:m,attributeData:{position:r,color:e.color,mapPosition:a,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*u*e.uvMapSpace.BYTES_PER_ELEMENT,4*d):null,boundingRect:this._needsUV?new Float64Array(e.boundingRect.buffer,9*u*e.boundingRect.BYTES_PER_ELEMENT,9*d):null}});e.outGeometries.push(_),e.outMaterials.push(n(this._material)),e.outTransforms.push(s),e.outNum++}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const i=e.renderData.outlines,r=this._outlineMaterial instanceof V;for(let a=0;a<i.length;++a){const{mapPosition:o,position:l}=i[a];if(t(this._context.clippingExtent)&&(p(k),c(k,o),!h(k,this._context.clippingExtent)))continue;const u=O({removeDuplicateStartEnd:r?0:1,attributeData:{position:l,mapPosition:o}}),d=u.vertexAttributes.get("position");d.data===l&&(d.data=new Float64Array(l)),e.outGeometries.push(u),e.outMaterials.push(n(this._outlineMaterial)),e.outTransforms.push(s),e.outNum++}}_createAsOverlay(e,i){const a=A(e.geometry);if(r(a))return null;n(this._material).renderPriority=this._renderPriority+this._renderPriorityStep/2,t(this._outlineMaterial)&&(this._outlineMaterial.renderPriority=this._renderPriority),Y.renderData=U(a,this._context.overlaySR),Y.color=i;const o=Y.renderData.position.length/3;return this._needsUV&&(Y.uvMapSpace=new Float32Array(4*o)),Y.outNum=0,Y.outGeometries=[],Y.outBoundingBox=p(),Y.layerUid=this._context.layer.uid,Y.graphicsUid=e.uid,this._createAsOverlayFill(Y),this._hasOutline&&this._createAsOverlayOutline(Y),this._logGeometryCreationWarnings(Y.renderData,a.rings,"rings","FillSymbol3DLayer"),0===Y.outNum?null:(this._needsUV&&T(y.fromTypedArray(Y.uvMapSpace),_.fromTypedArray(Y.renderData.position),this._context.overlaySR,this._context.layerView.view.state.viewingMode),Y.outNum>0?new v(this,Y.outGeometries,Y.outBoundingBox):null)}_createAsOverlayFill(e){const t=e.renderData.polygons;for(const{position:i,holeIndices:r,index:a,count:s}of t){if(p(k),c(k,i),!h(k,this._context.clippingExtent))continue;const t=o(i,r,3);if(0===t.length)continue;d(e.outBoundingBox,k);const u=new Uint32Array(t),m=w({indices:u,attributeData:{position:i,color:e.color,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*a*e.uvMapSpace.BYTES_PER_ELEMENT,4*s):null}}),_=new L(m,n(this._material),e.layerUid,e.graphicsUid),y=k;l(_.boundingSphere,.5*(y[0]+y[3]),.5*(y[1]+y[4]),0,.5*Math.sqrt((y[3]-y[0])*(y[3]-y[0])+(y[4]-y[1])*(y[4]-y[1]))),e.outGeometries.push(_),e.outNum++}}_createAsOverlayOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{position:r}=t[i];if(p(k),c(k,r),!h(k,this._context.clippingExtent))continue;d(e.outBoundingBox,k);const a=this._outlineMaterial instanceof V,o=O({removeDuplicateStartEnd:a?0:1,attributeData:{position:r}}),s=new L(o,n(this._outlineMaterial),e.layerUid,e.graphicsUid),u=k;l(s.boundingSphere,.5*(u[0]+u[3]),.5*(u[1]+u[4]),0,.5*Math.sqrt((u[3]-u[0])*(u[3]-u[0])+(u[4]-u[1])*(u[4]-u[1]))),e.outGeometries.push(s),e.outNum++}}_getOutlineOpacity(){const e=i(this.symbolLayer,"outline","color");return(this.draped?1:this._getLayerOpacity())*(t(e)?e.a:0)}_getOutlineColor(){const r=i(this.symbolLayer,"outline","color"),n=this._getOutlineOpacity();return D(t(r)?e.toUnitRGB(r):null,n)}get test(){return{createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}W.elevationModeChangeTypes={definedChanged:g.RECREATE,staysOnTheGround:g.NONE,onTheGroundChanged:g.RECREATE};const k=u(),z={renderData:null,color:null,uvMapSpace:null,boundingRect:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null},Y={renderData:null,color:null,uvMapSpace:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null};export{W as Graphics3DPolygonFillSymbolLayer,W as default};
5
+ import e from"../../../../Color.js";import{isSome as t,get as i,isNone as r,unwrap as n}from"../../../../core/maybe.js";import{pt2px as a}from"../../../../core/screenUtils.js";import{e as o}from"../../../../chunks/earcut.js";import{I as s}from"../../../../chunks/mat4f64.js";import{s as l}from"../../../../chunks/vec4.js";import{create as u,empty as p,expandWithBuffer as c,intersectsClippingArea as h,expandWithAABB as d}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewMat3f64 as m,BufferViewVec3f64 as _,BufferViewVec4f as y}from"../../../../geometry/support/buffer/BufferView.js";import{SymbolUpdateType as g,elevationModeChangeUpdateType as f,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{ElevationContext as M}from"./ElevationContext.js";import v from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as E}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as x}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as D}from"./graphicUtils.js";import{createGeometry as O,parseCapType as S}from"./lineUtils.js";import{geometryAsPolygon as A,geometryToRenderInfo as P,createColorGeometry as w,geometryToRenderInfoDraped as U}from"./polygonUtils.js";import{createMaterial as C,uvElevationAligner as G}from"../support/patternUtils.js";import{createMapSpaceUVCoords as j,createMapSpaceUVCoordsDraped as T}from"../support/uvUtils.js";import{Object3D as R}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as L}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{NativeLineMaterial as N}from"../../webgl-engine/materials/NativeLineMaterial.js";import{PatternMaterial as F}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as V}from"../../webgl-engine/materials/RibbonLineMaterial.js";const I=["polyline","polygon","extent"];class W extends x{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){}ensureMaterials(){this.ensureFillMaterial(),this.ensureOutlineMaterial()}ensureFillMaterial(){if(t(this._material))return;const e=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacityAndColor(e);this._material=C(this.symbolLayer,{color:r,transparent:r[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,vertexColors:!0,writeLinearDepth:!0,slicePlaneEnabled:this._context.slicePlaneEnabled},{isDraped:this.draped}),this._needsUV=this._material instanceof F,this._context.stage.add(this._material)}ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(t(this._outlineMaterial)||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=B(e.pattern);return t>1.5?new V({width:t,color:this._getOutlineColor(),polygonOffset:!0,slicePlaneEnabled:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleIntegerRepeats:!0,scaleStippleWithLineWidth:!0,cap:S(e.patternCap||"butt")}):new N({color:this._getOutlineColor(),slicePlaneEnabled:this._context.slicePlaneEnabled,width:t,stipplePattern:i,stippleIntegerRepeats:!0})};this._outlineMaterial=i(a(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return t(e)&&e.size&&e.size>0&&t(e.color)&&(r(e.pattern)||"style"!==e.pattern.type||"none"!==e.pattern.style)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null,this._context.stage.remove(this._outlineMaterial),this._outlineMaterial=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,I,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new M);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}layerOpacityChanged(){if(t(this._material)){const e=this._material.parameters.color,t=i(this.symbolLayer,"material","color"),r=this._getCombinedOpacity(t);this._material.setParameters({color:[e[0],e[1],e[2],r],transparent:r<1||this.needsDrivenTransparentPass})}if(t(this._outlineMaterial)){const e=this._outlineMaterial.parameters.color;this._outlineMaterial.setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}return!0}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,n=f(W.elevationModeChangeTypes,i,r);if(n!==g.UPDATE)return n;const a=b(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){if(t(this._material)&&this._material.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled}),t(this._outlineMaterial)){const e={slicePlaneEnabled:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_createAs3DShape(e,t,i){const n=A(e.geometry);if(r(n))return null;z.renderData=P(n,this._context.elevationProvider,this._context.renderCoordsHelper,i),z.color=t;const a=z.renderData.position.length/3;if(this._needsUV&&(z.uvMapSpace=new Float32Array(4*a),z.boundingRect=new Float64Array(9*a)),z.outNum=0,z.outGeometries=[],z.outTransforms=[],z.outMaterials=[],this._createAs3DShapeFill(z),this._hasOutline&&this._createAs3DShapeOutline(z),this._logGeometryCreationWarnings(z.renderData,n.rings,"rings","FillSymbol3DLayer"),0===z.outNum)return null;this._needsUV&&j(y.fromTypedArray(z.uvMapSpace),_.fromTypedArray(z.renderData.position),this._context.renderCoordsHelper,m.fromTypedArray(z.boundingRect));const o=new R({geometries:z.outGeometries,materials:z.outMaterials,transformations:z.outTransforms,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:e.uid}}),s=new E(this,o,z.outGeometries,null,null,G,i);return s.alignedSampledElevation=z.renderData.sampledElevation,s.needsElevationUpdates=b(i.mode),s}_createAs3DShapeFill(e){const i=e.renderData.polygons;for(const{position:r,mapPosition:a,holeIndices:l,index:u,count:d}of i){if(t(this._context.clippingExtent)&&(p(k),c(k,a),!h(k,this._context.clippingExtent)))continue;const i=o(a,l,3);if(0===i.length)continue;const m=new Uint32Array(i),_=w({indices:m,attributeData:{position:r,color:e.color,mapPosition:a,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*u*e.uvMapSpace.BYTES_PER_ELEMENT,4*d):null,boundingRect:this._needsUV?new Float64Array(e.boundingRect.buffer,9*u*e.boundingRect.BYTES_PER_ELEMENT,9*d):null}});e.outGeometries.push(_),e.outMaterials.push(n(this._material)),e.outTransforms.push(s),e.outNum++}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const i=e.renderData.outlines,r=this._outlineMaterial instanceof N;for(let a=0;a<i.length;++a){const{mapPosition:o,position:l}=i[a];if(t(this._context.clippingExtent)&&(p(k),c(k,o),!h(k,this._context.clippingExtent)))continue;const u=O({removeDuplicateStartEnd:r?0:1,attributeData:{position:l,mapPosition:o}}),d=u.vertexAttributes.get("position");d.data===l&&(d.data=new Float64Array(l)),e.outGeometries.push(u),e.outMaterials.push(n(this._outlineMaterial)),e.outTransforms.push(s),e.outNum++}}_createAsOverlay(e,i){const a=A(e.geometry);if(r(a))return null;n(this._material).renderPriority=this._renderPriority+this._renderPriorityStep/2,t(this._outlineMaterial)&&(this._outlineMaterial.renderPriority=this._renderPriority),Y.renderData=U(a,this._context.overlaySR),Y.color=i;const o=Y.renderData.position.length/3;return this._needsUV&&(Y.uvMapSpace=new Float32Array(4*o)),Y.outNum=0,Y.outGeometries=[],Y.outBoundingBox=p(),Y.layerUid=this._context.layer.uid,Y.graphicsUid=e.uid,this._createAsOverlayFill(Y),this._hasOutline&&this._createAsOverlayOutline(Y),this._logGeometryCreationWarnings(Y.renderData,a.rings,"rings","FillSymbol3DLayer"),0===Y.outNum?null:(this._needsUV&&T(y.fromTypedArray(Y.uvMapSpace),_.fromTypedArray(Y.renderData.position),this._context.overlaySR,this._context.layerView.view.state.viewingMode),Y.outNum>0?new v(this,Y.outGeometries,Y.outBoundingBox):null)}_createAsOverlayFill(e){const t=e.renderData.polygons;for(const{position:i,holeIndices:r,index:a,count:s}of t){if(p(k),c(k,i),!h(k,this._context.clippingExtent))continue;const t=o(i,r,3);if(0===t.length)continue;d(e.outBoundingBox,k);const u=new Uint32Array(t),m=w({indices:u,attributeData:{position:i,color:e.color,uvMapSpace:this._needsUV?new Float32Array(e.uvMapSpace.buffer,4*a*e.uvMapSpace.BYTES_PER_ELEMENT,4*s):null}}),_=new L(m,n(this._material),e.layerUid,e.graphicsUid),y=k;l(_.boundingSphere,.5*(y[0]+y[3]),.5*(y[1]+y[4]),0,.5*Math.sqrt((y[3]-y[0])*(y[3]-y[0])+(y[4]-y[1])*(y[4]-y[1]))),e.outGeometries.push(_),e.outNum++}}_createAsOverlayOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{position:r}=t[i];if(p(k),c(k,r),!h(k,this._context.clippingExtent))continue;d(e.outBoundingBox,k);const a=this._outlineMaterial instanceof N,o=O({removeDuplicateStartEnd:a?0:1,attributeData:{position:r}}),s=new L(o,n(this._outlineMaterial),e.layerUid,e.graphicsUid),u=k;l(s.boundingSphere,.5*(u[0]+u[3]),.5*(u[1]+u[4]),0,.5*Math.sqrt((u[3]-u[0])*(u[3]-u[0])+(u[4]-u[1])*(u[4]-u[1]))),e.outGeometries.push(s),e.outNum++}}_getOutlineOpacity(){const e=i(this.symbolLayer,"outline","color");return(this.draped?1:this._getLayerOpacity())*(t(e)?e.a:0)}_getOutlineColor(){const r=i(this.symbolLayer,"outline","color"),n=this._getOutlineOpacity();return D(t(r)?e.toUnitRGB(r):null,n)}get test(){return{createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}W.elevationModeChangeTypes={definedChanged:g.RECREATE,staysOnTheGround:g.NONE,onTheGroundChanged:g.RECREATE};const k=u(),z={renderData:null,color:null,uvMapSpace:null,boundingRect:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null},Y={renderData:null,color:null,uvMapSpace:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null};export{W as Graphics3DPolygonFillSymbolLayer,W as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{forEach as t}from"../../../../core/asyncUtils.js";import{isNone as e,isSome as s,get as r}from"../../../../core/maybe.js";import{onAbortOrThrow as o,throwIfAborted as a}from"../../../../core/promiseUtils.js";import i from"./Graphics3DGraphic.js";import{Graphics3DObject3DGraphicLayer as n}from"./Graphics3DObject3DGraphicLayer.js";import{make as y}from"./Graphics3DSymbolLayerFactory.js";import{Loadable as l}from"./Loadable.js";import{totalSymbolComplexities as h}from"./symbolComplexity.js";class c extends l{constructor(t,e,s){super(e.schedule),this._symbol=t,this._context=e,this._backgroundLayers=s,this._destroyed=!1,this.symbolLayers=[],this.referenced=0,this._extentPadding=0}set symbol(t){if(this._symbol=t,this.symbolLayers)for(let s=0;s<t.symbolLayers.length;s++){const r=this.symbolLayers[s];e(r)||(r.symbol=t,r.symbolLayer=t.symbolLayers.items[s])}}get symbol(){return this._symbol}async doLoad(e){let r=this._symbol.symbolLayers;this._extentPadding=0,this._backgroundLayers&&(r=this._backgroundLayers.concat(r));const i=r.length;for(;this.symbolLayers.length<r.length;)this.symbolLayers.push(null);this.symbolLayers.length=r.length;const n=[];for(let t=0;t<i;t++){const s=r.getItemAt(t);if(!1===s.enabled)continue;m.renderPriority=1-(1+t)/i,m.renderPriorityStep=1/i,m.ignoreDrivers=s._ignoreDrivers;const a=y(this.symbol,s,this._context,m);n.push(o(e,(()=>{this.symbolLayers[t]=null,a.destroy()}))),this.symbolLayers[t]=a}await t(this.symbolLayers,(async(t,e)=>{if(s(t))try{await t.load(),this._extentPadding+=Math.max(this._extentPadding,t.extentPadding)}catch{this.symbolLayers[e]=null}}));for(const t of n)null==t||t.remove();if(n.length=0,a(e),this.symbolLayers.length&&!this.symbolLayers.some((t=>!!t)))throw new Error}getSymbolLayerSize(t){const e=this.symbolLayers[t];return s(e)?e.getCachedSize():null}get extentPadding(){return this._extentPadding}createGraphics3DGraphic(t,e){const r=t.graphic,o=new Array(this.symbolLayers.length);for(let i=0;i<this.symbolLayers.length;i++){const e=this.symbolLayers[i];o[i]=s(e)?e.createGraphics3DGraphic(t):null}const a=this._context.arcade||this._context.featureExpressionInfoContext&&this._context.featureExpressionInfoContext.arcade&&this._context.featureExpressionInfoContext.arcade.modules||null;return new i(r,e||this,o,t.layer,a)}get complexity(){return h(this.symbolLayers.map((t=>r(t,"complexity"))))}globalPropertyChanged(t,e){const r=this.symbolLayers.length;for(let o=0;o<r;o++){const r=this.symbolLayers[o],a=t=>{const e=t.graphics[o];return e instanceof n?e:null};if(s(r)&&!r.globalPropertyChanged(t,e,a))return!1}return!0}applyRendererDiff(t,s){return 1===this.loadStatus&&this.symbolLayers.reduce(((r,o)=>r&&(e(o)||o.applyRendererDiff(t,s))),!0)}prepareSymbolPatch(t){if(2===this.loadStatus)return;if("partial"!==t.diff.type)return;const r=t.diff.diff;if(!r.symbolLayers||"partial"!==r.symbolLayers.type)return;const o=r.symbolLayers.diff;this.symbolLayers.forEach(((r,a)=>{if(e(r))return;const i=o[a];if(i){const e={diff:i,graphics3DGraphicPatches:[],symbolLayerStatePatches:[]};r.prepareSymbolLayerPatch(e),t.symbolStatePatches.push(...e.symbolLayerStatePatches),e.graphics3DGraphicPatches.length&&t.graphics3DGraphicPatches.push(((t,r)=>{const o=t.graphics[a];s(o)&&e.graphics3DGraphicPatches.forEach((t=>t(o,r)))}))}}))}updateGeometry(t,s){for(let r=0;r<this.symbolLayers.length;r++){const o=this.symbolLayers[r];if(e(o))continue;const a=t.graphics[r];if(e(a)||!o.updateGeometry(a,s))return!1}return!0}onRemoveGraphic(t){for(let r=0;r<this.symbolLayers.length;r++){const o=this.symbolLayers[r];if(e(o))continue;const a=t.graphics[r];s(a)&&o.onRemoveGraphic(a)}}getFastUpdateStatus(){let t=0,s=0,r=0;return this.symbolLayers.forEach((o=>{e(o)||(0===o.loadStatus?t++:o.isFastUpdatesEnabled()?r++:s++)})),{loading:t,slow:s,fast:r}}destroy(){if(this.destroyed)console.error("Graphics3DSymbol.destroy called when already destroyed!");else{this.abortLoad();for(const t of this.symbolLayers)s(t)&&t.destroy();this.symbolLayers.length=0,this._destroyed=!0}}get destroyed(){return this._destroyed}}const m={renderPriority:0,renderPriorityStep:1,ignoreDrivers:!1};export{c as default};
5
+ import{forEach as t}from"../../../../core/asyncUtils.js";import{isNone as e,isSome as s,get as r}from"../../../../core/maybe.js";import{onAbortOrThrow as o,throwIfAborted as a}from"../../../../core/promiseUtils.js";import i from"./Graphics3DGraphic.js";import{Graphics3DObject3DGraphicLayer as n}from"./Graphics3DObject3DGraphicLayer.js";import{make as y}from"./Graphics3DSymbolLayerFactory.js";import{Loadable as l}from"./Loadable.js";import{totalSymbolComplexities as h}from"./symbolComplexity.js";class c extends l{constructor(t,e,s){super(e.schedule),this._symbol=t,this._context=e,this._backgroundLayers=s,this._destroyed=!1,this.symbolLayers=new Array,this.referenced=0,this._extentPadding=0}set symbol(t){this._symbol=t;for(let s=0;s<t.symbolLayers.length;s++){const r=this.symbolLayers[s];e(r)||(r.symbol=t,r.symbolLayer=t.symbolLayers.items[s])}}get symbol(){return this._symbol}async doLoad(e){let r=this._symbol.symbolLayers;this._extentPadding=0,this._backgroundLayers&&(r=this._backgroundLayers.concat(r));const i=r.length;for(;this.symbolLayers.length<r.length;)this.symbolLayers.push(null);this.symbolLayers.length=r.length;const n=[];for(let t=0;t<i;t++){const s=r.getItemAt(t);if(!1===s.enabled)continue;m.renderPriority=1-(1+t)/i,m.renderPriorityStep=1/i,m.ignoreDrivers=s._ignoreDrivers;const a=y(this.symbol,s,this._context,m);n.push(o(e,(()=>{this.symbolLayers[t]=null,a.destroy()}))),this.symbolLayers[t]=a}await t(this.symbolLayers,(async(t,e)=>{if(s(t))try{await t.load(),this._extentPadding+=Math.max(this._extentPadding,t.extentPadding)}catch{this.symbolLayers[e]=null}}));for(const t of n)null==t||t.remove();if(n.length=0,a(e),this.symbolLayers.length&&!this.symbolLayers.some((t=>!!t)))throw new Error}getSymbolLayerSize(t){const e=this.symbolLayers[t];return s(e)?e.getCachedSize():null}get extentPadding(){return this._extentPadding}createGraphics3DGraphic(t,e){const r=t.graphic,o=new Array(this.symbolLayers.length);for(let i=0;i<this.symbolLayers.length;i++){const e=this.symbolLayers[i];o[i]=s(e)?e.createGraphics3DGraphic(t):null}const a=this._context.arcade||this._context.featureExpressionInfoContext&&this._context.featureExpressionInfoContext.arcade&&this._context.featureExpressionInfoContext.arcade.modules||null;return new i(r,e||this,o,t.layer,a)}get complexity(){return h(this.symbolLayers.map((t=>r(t,"complexity"))))}globalPropertyChanged(t,e){const r=this.symbolLayers.length;for(let o=0;o<r;o++){const r=this.symbolLayers[o],a=t=>{const e=t.graphics[o];return e instanceof n?e:null};if(s(r)&&!r.globalPropertyChanged(t,e,a))return!1}return!0}applyRendererDiff(t,s){return 1===this.loadStatus&&this.symbolLayers.reduce(((r,o)=>r&&(e(o)||o.applyRendererDiff(t,s))),!0)}prepareSymbolPatch(t){if(2===this.loadStatus)return;if("partial"!==t.diff.type)return;const r=t.diff.diff;if(!r.symbolLayers||"partial"!==r.symbolLayers.type)return;const o=r.symbolLayers.diff;this.symbolLayers.forEach(((r,a)=>{if(e(r))return;const i=o[a];if(i){const e={diff:i,graphics3DGraphicPatches:[],symbolLayerStatePatches:[]};r.prepareSymbolLayerPatch(e),t.symbolStatePatches.push(...e.symbolLayerStatePatches),e.graphics3DGraphicPatches.length&&t.graphics3DGraphicPatches.push(((t,r)=>{const o=t.graphics[a];s(o)&&e.graphics3DGraphicPatches.forEach((t=>t(o,r)))}))}}))}updateGeometry(t,s){for(let r=0;r<this.symbolLayers.length;r++){const o=this.symbolLayers[r];if(e(o))continue;const a=t.graphics[r];if(e(a)||!o.updateGeometry(a,s))return!1}return!0}onRemoveGraphic(t){for(let r=0;r<this.symbolLayers.length;r++){const o=this.symbolLayers[r];if(e(o))continue;const a=t.graphics[r];s(a)&&o.onRemoveGraphic(a)}}getFastUpdateStatus(){let t=0,s=0,r=0;return this.symbolLayers.forEach((o=>{e(o)||(0===o.loadStatus?t++:o.isFastUpdatesEnabled()?r++:s++)})),{loading:t,slow:s,fast:r}}destroy(){if(this.destroyed)console.error("Graphics3DSymbol.destroy called when already destroyed!");else{this.abortLoad();for(const t of this.symbolLayers)s(t)&&t.destroy();this.symbolLayers.length=0,this._destroyed=!0}}get destroyed(){return this._destroyed}}const m={renderPriority:0,renderPriorityStep:1,ignoreDrivers:!1};export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{isNone as t,get as r,isSome as n}from"../../../../core/maybe.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{a as i}from"../../../../chunks/vec2f64.js";import{isCalloutSupport as o}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as a}from"./ElevationAligners.js";import{SymbolUpdateType as l,needsElevationUpdates2D as c}from"./elevationAlignmentUtils.js";import{ElevationContext as d}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as h}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as m,namedAnchorToHUDMaterialAnchorPos as p}from"./graphicUtils.js";import{placePointOnGeometry as u,createStageObjectForHUD as g,extendPointGraphicElevationContext as y}from"./pointUtils.js";import x from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as v}from"../../webgl-engine/lib/TextRenderParameters.js";import b from"../../webgl-engine/lib/TextTexture.js";import{HUDMaterial as O}from"../../webgl-engine/materials/HUDMaterial.js";const P=[0,0,1];class E extends f{constructor(e,t,r,n){super(e,t,r,n),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=m(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}this._createTextRenderParameters()}_createTextRenderParameters(){const e=this._context.layerView.view.pixelRatio;this._textRenderParameters=v.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const r=e.graphic,n=u(r.geometry);if(t(n))return this.logger.warn(`unsupported geometry type for text symbol: ${r.geometry.type}`),null;const s=this.symbolLayer.text;if(!s)return null;const i=o(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol:null;return this._createAs3DShape(r,n,s,i)}createLabel(e,r,n,s){const i=e.graphic,o=u(i.geometry);if(t(o))return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const a=r.text;return!a||/^\s+$/.test(a)?null:this._createAs3DShape(i,o,a,r,r,n,s)}setGraphicElevationContext(e,t,r=0){const n=super.setGraphicElevationContext(e,t);return n.addOffsetRenderUnits(r),n}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return S(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),l.UPDATE}slicePlaneEnabledChanged(e,t){return S(e,t,(e=>{for(const t of e.stageObject.geometryRecords)t.material.setParameterValues({slicePlaneEnabled:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){this.setGraphicElevationContext(e,t.elevationContext,t.metadata.elevationOffset),t.needsElevationUpdates=c(t.elevationContext.mode)||"absolute-height"===t.elevationContext.mode}_defaultElevationInfoNoZ(){return w}_createAs3DShape(e,o,l,f,m=j,u,v){const E=this.setGraphicElevationContext(e,new d,m.elevationOffset),S="polyline"===r(e.geometry,"type"),w=e.uid,_=this._context.stage.renderView.renderingContext,C=m.anchor in p?m.anchor:"center",G=p[C],L=t(v)?new b(_,l,this._textRenderParameters):null,D={occlusionTest:!0,screenOffset:m.screenOffset,anchorPos:G,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:m.centerOffsetUnits,debugDrawBorder:m.debugDrawBorder,drawInSecondSlot:!0};if(n(L)&&(D.textureId=L.id,D.texCoordScale=L.texcoordScale),n(v)&&(D.textureId=v.id),n(f)&&n(f.verticalOffset)){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=f.verticalOffset;D.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources;D.screenSizePerspective=t.overridePadding(this._textRenderParameters.haloSize),D.screenSizePerspectiveAlignment=e}let U;if(S&&(D.shaderPolygonOffset=1e-4),D.slicePlaneEnabled=this._context.slicePlaneEnabled,n(u)){const e=JSON.stringify(D);U=u.get(e),t(U)&&(U=new O(D),u.add(e,U))}else U=new O(D);const R=[U],z=m.translation,T=n(L)?[L.displayWidth,L.displayHeight]:[0,0],A=m.centerOffset,W=P,I=[0,0],V=[x.createPointGeometry(W,z,null,T,A,I,null)],B=this._context.layer.uid,H=g(this._context,o,V,R,null,null,E,B,w);if(null===H)return null;const $=a,N=new h(this,H.object,V,t(u)?R:null,n(L)?[L]:null,$,E);N.alignedSampledElevation=H.sampledElevation,N.needsElevationUpdates=c(E.mode)||"absolute-height"===E.mode;const{displayWidth:k,displayHeight:J}=n(L)?L:m;N.getScreenSize=(e=i())=>(e[0]=k,e[1]=J,e);const M={labelText:l,elevationOffset:m.elevationOffset};return N.metadata=M,y(N,o,this._context.elevationProvider),N}}function S(e,t,r){e&&e.forEach((e=>{const s=t(e);n(s)&&r(s,e.graphic)}))}const w={mode:"relative-to-ground",offset:0},j={text:null,translation:[0,0,0],elevationOffset:0,centerOffset:[0,0,0,1],screenOffset:[0,0],anchor:"center",verticalOffset:null,centerOffsetUnits:null,debugDrawBorder:!1,displayWidth:0,displayHeight:0};export{E as Graphics3DTextSymbolLayer,E as default};
5
+ import e from"../../../../core/Error.js";import{isNone as t,get as r,isSome as n}from"../../../../core/maybe.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{a as i}from"../../../../chunks/vec2f64.js";import{isCalloutSupport as o}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as a}from"./ElevationAligners.js";import{SymbolUpdateType as l,needsElevationUpdates2D as c}from"./elevationAlignmentUtils.js";import{ElevationContext as d}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as h}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as m,namedAnchorToHUDMaterialAnchorPos as p}from"./graphicUtils.js";import{placePointOnGeometry as u,createStageObjectForHUD as g,extendPointGraphicElevationContext as y}from"./pointUtils.js";import x from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as v}from"../../webgl-engine/lib/TextRenderParameters.js";import b from"../../webgl-engine/lib/TextTexture.js";import{HUDMaterial as O}from"../../webgl-engine/materials/HUDMaterial.js";const P=[0,0,1];class E extends f{constructor(e,t,r,n){super(e,t,r,n),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=m(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}this._createTextRenderParameters()}_createTextRenderParameters(){const e=this._context.layerView.view.pixelRatio;this._textRenderParameters=v.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const r=e.graphic,n=u(r.geometry);if(t(n))return this.logger.warn(`unsupported geometry type for text symbol: ${r.geometry.type}`),null;const s=this.symbolLayer.text;if(!s)return null;const i=o(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol:null;return this._createAs3DShape(r,n,s,i)}createLabel(e,r,n,s){const i=e.graphic,o=u(i.geometry);if(t(o))return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const a=r.text;return!a||/^\s+$/.test(a)?null:this._createAs3DShape(i,o,a,r,r,n,s)}setGraphicElevationContext(e,t,r=0){const n=super.setGraphicElevationContext(e,t);return n.addOffsetRenderUnits(r),n}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return S(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),l.UPDATE}slicePlaneEnabledChanged(e,t){return S(e,t,(e=>{for(const t of e.stageObject.geometryRecords)t.material.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){this.setGraphicElevationContext(e,t.elevationContext,t.metadata.elevationOffset),t.needsElevationUpdates=c(t.elevationContext.mode)||"absolute-height"===t.elevationContext.mode}_defaultElevationInfoNoZ(){return w}_createAs3DShape(e,o,l,f,m=j,u,v){const E=this.setGraphicElevationContext(e,new d,m.elevationOffset),S="polyline"===r(e.geometry,"type"),w=e.uid,_=this._context.stage.renderView.renderingContext,C=m.anchor in p?m.anchor:"center",G=p[C],L=t(v)?new b(_,l,this._textRenderParameters):null,D={occlusionTest:!0,screenOffset:m.screenOffset,anchorPos:G,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:m.centerOffsetUnits,debugDrawBorder:m.debugDrawBorder,drawInSecondSlot:!0};if(n(L)&&(D.textureId=L.id,D.texCoordScale=L.texcoordScale),n(v)&&(D.textureId=v.id),n(f)&&n(f.verticalOffset)){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=f.verticalOffset;D.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources;D.screenSizePerspective=t.overridePadding(this._textRenderParameters.haloSize),D.screenSizePerspectiveAlignment=e}let U;if(S&&(D.shaderPolygonOffset=1e-4),D.slicePlaneEnabled=this._context.slicePlaneEnabled,n(u)){const e=JSON.stringify(D);U=u.get(e),t(U)&&(U=new O(D),u.add(e,U))}else U=new O(D);const R=[U],z=m.translation,T=n(L)?[L.displayWidth,L.displayHeight]:[0,0],A=m.centerOffset,W=P,I=[0,0],B=[x.createPointGeometry(W,z,null,T,A,I,null)],H=this._context.layer.uid,V=g(this._context,o,B,R,E,H,w);if(null===V)return null;const $=new h(this,V.object,B,t(u)?R:null,n(L)?[L]:null,a,E);$.alignedSampledElevation=V.sampledElevation,$.needsElevationUpdates=c(E.mode)||"absolute-height"===E.mode;const{displayWidth:N,displayHeight:k}=n(L)?L:m;$.getScreenSize=(e=i())=>(e[0]=N,e[1]=k,e);const J={labelText:l,elevationOffset:m.elevationOffset};return $.metadata=J,y($,o,this._context.elevationProvider),$}}function S(e,t,r){e&&e.forEach((e=>{const s=t(e);n(s)&&r(s,e.graphic)}))}const w={mode:"relative-to-ground",offset:0},j={text:null,translation:[0,0,0],elevationOffset:0,centerOffset:[0,0,0,1],screenOffset:[0,0],anchor:"center",verticalOffset:null,centerOffsetUnits:null,debugDrawBorder:!1,displayWidth:0,displayHeight:0};export{E as Graphics3DTextSymbolLayer,E as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{isSome as t,isNone as r,unwrap as o}from"../../../../core/maybe.js";import{getMetersPerUnitForSR as i}from"../../../../core/unitUtils.js";import{e as a}from"../../../../chunks/earcut.js";import{I as n}from"../../../../chunks/mat4f64.js";import{s}from"../../../../chunks/vec2.js";import{f as l,a as u}from"../../../../chunks/vec2f64.js";import{b as c,s as m}from"../../../../chunks/vec4.js";import{t as h}from"../../../../chunks/common.js";import{create as d,empty as p,expandWithBuffer as g,intersectsClippingArea as y,expandWithAABB as f}from"../../../../geometry/support/aaBoundingBox.js";import{create as _,empty as v,expandPointInPlace as x}from"../../../../geometry/support/aaBoundingRect.js";import{perVertexElevationAligner as D}from"./ElevationAligners.js";import{SymbolUpdateType as b,elevationModeChangeUpdateType as C,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{ElevationContext as w}from"./ElevationContext.js";import G from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as S}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as T,geometryToRenderInfo as A,createWaterGeometry as P,geometryToRenderInfoDraped as U}from"./polygonUtils.js";import{Object3D as M}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as B}from"../../webgl-engine/lib/RenderGeometry.js";import{WaterMaterial as O}from"../../webgl-engine/materials/WaterMaterial.js";import{defaultWaterMaterialParameters as R,wavePresets as L}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const N=["polyline","polygon","extent"];class V extends j{constructor(e,t,r,o){super(e,t,r,o)}async doLoad(){}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,N,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new w);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,r,t.uid)}ensureMaterial(){if(t(this._material))return;const r={...R},o=this.symbolLayer.color;t(o)&&(r.color=e.toUnitRGBA(o));const i=this._getCombinedOpacity(o,{hasIntrinsicColor:!0});r.color=[r.color[0],r.color[1],r.color[2],i],r.transparent=i<1||this.needsDrivenTransparentPass,r.waveDirection=t(this.symbolLayer.waveDirection)?V.headingVectorFromAngle(this.symbolLayer.waveDirection):l(0,0);const a=this.symbolLayer.waveStrength+"-"+this.symbolLayer.waterbodySize,n=L[a];r.waveStrength=n.waveStrength,r.waveTextureRepeat=n.textureRepeat,r.waveVelocity=n.waveVelocity,r.flowStrength=n.perturbationStrength,r.slicePlaneEnabled=this._context.slicePlaneEnabled,r.isDraped=this.draped,this._material=new O(r),this._context.stage.add(this._material)}layerOpacityChanged(){if(r(this._material))return!0;const e=this._material.params.color,t=this._getCombinedOpacity(this.symbolLayer.color,{hasIntrinsicColor:!0}),o=t<1||this.needsDrivenTransparentPass;return this._material.setParameterValues({color:[e[0],e[1],e[2],t],transparent:o}),!0}layerElevationInfoChanged(e,t,r){const o=this._elevationContext.mode,i=C(V.elevationModeChangeTypes,r,o);if(i!==b.UPDATE)return i;const a=E(o);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return t(this._material)&&this._material.setParameterValues({slicePlaneEnabled:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_createAs3DShape(e,t,o){const i=T(e.geometry);if(r(i))return null;z.renderData=A(i,this._context.elevationProvider,this._context.renderCoordsHelper,t);const a=z.renderData.position.length/3;if(z.uvCoords=new Float64Array(2*a),z.outNum=0,z.outGeometries=[],z.outTransforms=[],z.outMaterials=[],this._create3DShapeGeometries(z),this._logGeometryCreationWarnings(z.renderData,i.rings,"rings","WaterSymbol3DLayer"),0===z.outNum)return null;this._createUVCoordsFromVertices(z.uvCoords,z.renderData.mapPosition,a,this._context.elevationProvider.spatialReference);const n=new M({geometries:z.outGeometries,materials:z.outMaterials,transformations:z.outTransforms,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:o}}),s=D,l=new S(this,n,z.outGeometries,null,null,s,t);return l.alignedSampledElevation=z.renderData.sampledElevation,l.needsElevationUpdates=E(t.mode),l}_createUVCoordsFromVertices(e,t,r,o){const a=i(o);v(I);for(let i=0;i<r;i++)s(W,t[3*i+0],t[3*i+1]),x(I,W);c(I,I,a);const n=I[0]%V.unitSizeOfTexture,l=I[1]%V.unitSizeOfTexture;F[0]=I[0]-n,F[1]=I[1]-l;for(let i=0;i<r;i++)e[2*i+0]=(t[3*i+0]*a-F[0])/V.unitSizeOfTexture,e[2*i+1]=(t[3*i+1]*a-F[1])/V.unitSizeOfTexture}_create3DShapeGeometries(e){const r=e.renderData.polygons,i=e.uvCoords;for(const{count:s,index:l,position:u,mapPosition:c,holeIndices:m}of r){if(t(this._context.clippingExtent)&&(p(k),g(k,c),!y(k,this._context.clippingExtent)))continue;const r=a(c,m,3);if(0===r.length)continue;const h=new Uint32Array(r),d=new Float64Array(i.buffer,2*l*i.BYTES_PER_ELEMENT,2*s),f=P({indices:h,attributeData:{position:u,uv0:d,mapPosition:c}});e.outGeometries.push(f),e.outMaterials.push(o(this._material)),e.outTransforms.push(n),e.outNum++}}_createAsOverlay(e){const t=T(e.geometry);if(r(t))return null;o(this._material).renderPriority=this._renderPriority,Y.renderData=U(t,this._context.overlaySR);const i=Y.renderData.position.length/3;return Y.uvCoords=new Float64Array(2*i),Y.outNum=0,Y.outGeometries=[],Y.outBoundingBox=p(),Y.layerUid=this._context.layer.uid,Y.graphicsUid=e.uid,this._createAsOverlayWater(Y),this._logGeometryCreationWarnings(Y.renderData,t.rings,"rings","WaterSymbol3DLayer"),0===Y.outNum?null:(this._createUVCoordsFromVertices(Y.uvCoords,Y.renderData.position,i,this._context.overlaySR),Y.outNum>0?new G(this,Y.outGeometries,Y.outBoundingBox):null)}_createAsOverlayWater(e){const t=e.uvCoords,r=e.renderData.polygons;for(const{position:i,holeIndices:n,index:s,count:l}of r){if(p(k),g(k,i),!y(k,this._context.clippingExtent))continue;f(e.outBoundingBox,k);const r=a(i,n,3);if(0===r.length)continue;const u=new Uint32Array(r),c=new Float64Array(t.buffer,2*s*t.BYTES_PER_ELEMENT,2*l),h=P({indices:u,attributeData:{position:i,uv0:c}}),d=new B(h,o(this._material),e.layerUid,e.graphicsUid),_=k;m(d.boundingSphere,.5*(_[0]+_[3]),.5*(_[1]+_[4]),0,.5*Math.sqrt((_[3]-_[0])*(_[3]-_[0])+(_[4]-_[1])*(_[4]-_[1]))),e.outGeometries.push(d),e.outNum++}}static headingVectorFromAngle(e){const t=u(),r=h(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}get test(){return{create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}V.unitSizeOfTexture=100,V.elevationModeChangeTypes={definedChanged:b.RECREATE,staysOnTheGround:b.NONE,onTheGroundChanged:b.RECREATE};const F=u(),I=_(),W=u(),k=d(),z={renderData:null,uvCoords:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null},Y={renderData:null,uvCoords:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null};export{V as Graphics3DWaterSymbolLayer,V as default};
5
+ import e from"../../../../Color.js";import{isSome as t,isNone as r,unwrap as o}from"../../../../core/maybe.js";import{getMetersPerUnitForSR as i}from"../../../../core/unitUtils.js";import{e as a}from"../../../../chunks/earcut.js";import{I as n}from"../../../../chunks/mat4f64.js";import{s}from"../../../../chunks/vec2.js";import{f as l,a as u}from"../../../../chunks/vec2f64.js";import{b as c,s as m}from"../../../../chunks/vec4.js";import{t as h}from"../../../../chunks/common.js";import{create as d,empty as p,expandWithBuffer as g,intersectsClippingArea as y,expandWithAABB as f}from"../../../../geometry/support/aaBoundingBox.js";import{create as _,empty as v,expandPointInPlace as x}from"../../../../geometry/support/aaBoundingRect.js";import{perVertexElevationAligner as D}from"./ElevationAligners.js";import{SymbolUpdateType as b,elevationModeChangeUpdateType as C,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{ElevationContext as w}from"./ElevationContext.js";import G from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as S}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as T,geometryToRenderInfo as A,createWaterGeometry as P,geometryToRenderInfoDraped as U}from"./polygonUtils.js";import{Object3D as M}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as B}from"../../webgl-engine/lib/RenderGeometry.js";import{WaterMaterial as O}from"../../webgl-engine/materials/WaterMaterial.js";import{defaultWaterMaterialParameters as R,wavePresets as L}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const N=["polyline","polygon","extent"];class V extends j{constructor(e,t,r,o){super(e,t,r,o)}async doLoad(){}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,N,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new w);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,r,t.uid)}ensureMaterial(){if(t(this._material))return;const r={...R},o=this.symbolLayer.color;t(o)&&(r.color=e.toUnitRGBA(o));const i=this._getCombinedOpacity(o,{hasIntrinsicColor:!0});r.color=[r.color[0],r.color[1],r.color[2],i],r.transparent=i<1||this.needsDrivenTransparentPass,r.waveDirection=t(this.symbolLayer.waveDirection)?V.headingVectorFromAngle(this.symbolLayer.waveDirection):l(0,0);const a=this.symbolLayer.waveStrength+"-"+this.symbolLayer.waterbodySize,n=L[a];r.waveStrength=n.waveStrength,r.waveTextureRepeat=n.textureRepeat,r.waveVelocity=n.waveVelocity,r.flowStrength=n.perturbationStrength,r.slicePlaneEnabled=this._context.slicePlaneEnabled,r.isDraped=this.draped,this._material=new O(r),this._context.stage.add(this._material)}layerOpacityChanged(){if(r(this._material))return!0;const e=this._material.parameters.color,t=this._getCombinedOpacity(this.symbolLayer.color,{hasIntrinsicColor:!0}),o=t<1||this.needsDrivenTransparentPass;return this._material.setParameters({color:[e[0],e[1],e[2],t],transparent:o}),!0}layerElevationInfoChanged(e,t,r){const o=this._elevationContext.mode,i=C(V.elevationModeChangeTypes,r,o);if(i!==b.UPDATE)return i;const a=E(o);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return t(this._material)&&this._material.setParameters({slicePlaneEnabled:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_createAs3DShape(e,t,o){const i=T(e.geometry);if(r(i))return null;z.renderData=A(i,this._context.elevationProvider,this._context.renderCoordsHelper,t);const a=z.renderData.position.length/3;if(z.uvCoords=new Float64Array(2*a),z.outNum=0,z.outGeometries=[],z.outTransforms=[],z.outMaterials=[],this._create3DShapeGeometries(z),this._logGeometryCreationWarnings(z.renderData,i.rings,"rings","WaterSymbol3DLayer"),0===z.outNum)return null;this._createUVCoordsFromVertices(z.uvCoords,z.renderData.mapPosition,a,this._context.elevationProvider.spatialReference);const n=new M({geometries:z.outGeometries,materials:z.outMaterials,transformations:z.outTransforms,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:o}}),s=new S(this,n,z.outGeometries,null,null,D,t);return s.alignedSampledElevation=z.renderData.sampledElevation,s.needsElevationUpdates=E(t.mode),s}_createUVCoordsFromVertices(e,t,r,o){const a=i(o);v(I);for(let i=0;i<r;i++)s(W,t[3*i+0],t[3*i+1]),x(I,W);c(I,I,a);const n=I[0]%V.unitSizeOfTexture,l=I[1]%V.unitSizeOfTexture;F[0]=I[0]-n,F[1]=I[1]-l;for(let i=0;i<r;i++)e[2*i+0]=(t[3*i+0]*a-F[0])/V.unitSizeOfTexture,e[2*i+1]=(t[3*i+1]*a-F[1])/V.unitSizeOfTexture}_create3DShapeGeometries(e){const r=e.renderData.polygons,i=e.uvCoords;for(const{count:s,index:l,position:u,mapPosition:c,holeIndices:m}of r){if(t(this._context.clippingExtent)&&(p(k),g(k,c),!y(k,this._context.clippingExtent)))continue;const r=a(c,m,3);if(0===r.length)continue;const h=new Uint32Array(r),d=new Float64Array(i.buffer,2*l*i.BYTES_PER_ELEMENT,2*s),f=P({indices:h,attributeData:{position:u,uv0:d,mapPosition:c}});e.outGeometries.push(f),e.outMaterials.push(o(this._material)),e.outTransforms.push(n),e.outNum++}}_createAsOverlay(e){const t=T(e.geometry);if(r(t))return null;o(this._material).renderPriority=this._renderPriority,Y.renderData=U(t,this._context.overlaySR);const i=Y.renderData.position.length/3;return Y.uvCoords=new Float64Array(2*i),Y.outNum=0,Y.outGeometries=[],Y.outBoundingBox=p(),Y.layerUid=this._context.layer.uid,Y.graphicsUid=e.uid,this._createAsOverlayWater(Y),this._logGeometryCreationWarnings(Y.renderData,t.rings,"rings","WaterSymbol3DLayer"),0===Y.outNum?null:(this._createUVCoordsFromVertices(Y.uvCoords,Y.renderData.position,i,this._context.overlaySR),Y.outNum>0?new G(this,Y.outGeometries,Y.outBoundingBox):null)}_createAsOverlayWater(e){const t=e.uvCoords,r=e.renderData.polygons;for(const{position:i,holeIndices:n,index:s,count:l}of r){if(p(k),g(k,i),!y(k,this._context.clippingExtent))continue;f(e.outBoundingBox,k);const r=a(i,n,3);if(0===r.length)continue;const u=new Uint32Array(r),c=new Float64Array(t.buffer,2*s*t.BYTES_PER_ELEMENT,2*l),h=P({indices:u,attributeData:{position:i,uv0:c}}),d=new B(h,o(this._material),e.layerUid,e.graphicsUid),_=k;m(d.boundingSphere,.5*(_[0]+_[3]),.5*(_[1]+_[4]),0,.5*Math.sqrt((_[3]-_[0])*(_[3]-_[0])+(_[4]-_[1])*(_[4]-_[1]))),e.outGeometries.push(d),e.outNum++}}static headingVectorFromAngle(e){const t=u(),r=h(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}get test(){return{create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}V.unitSizeOfTexture=100,V.elevationModeChangeTypes={definedChanged:b.RECREATE,staysOnTheGround:b.NONE,onTheGroundChanged:b.RECREATE};const F=u(),I=_(),W=u(),k=d(),z={renderData:null,uvCoords:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null},Y={renderData:null,uvCoords:null,outNum:0,outBoundingBox:null,outGeometries:null,outMaterials:null,outTransforms:null};export{V as Graphics3DWaterSymbolLayer,V as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{isSome as t}from"../../../../core/maybe.js";import{Loadable as r}from"./Loadable.js";import{emptySymbolComplexity as s}from"./symbolComplexity.js";class i extends r{constructor(t,r,s){super(r),this.symbol=t,this.convert=s,this.graphics3DSymbol=null,this.referenced=0}getSymbolLayerSize(r){return t(this.graphics3DSymbol)?this.graphics3DSymbol.getSymbolLayerSize(r):null}get extentPadding(){return t(this.graphics3DSymbol)?this.graphics3DSymbol.extentPadding:0}async doLoad(t){const r=await this.symbol.fetchSymbol({signal:t});r.id=this.symbol.id,this.graphics3DSymbol=this.convert(r),await this.graphics3DSymbol.load()}createGraphics3DGraphic(r){return t(this.graphics3DSymbol)?this.graphics3DSymbol.createGraphics3DGraphic(r,this):null}get complexity(){return t(this.graphics3DSymbol)?this.graphics3DSymbol.complexity:s}globalPropertyChanged(r,s){return!!t(this.graphics3DSymbol)&&this.graphics3DSymbol.globalPropertyChanged(r,s)}applyRendererDiff(r,s){return!!t(this.graphics3DSymbol)&&this.graphics3DSymbol.applyRendererDiff(r,s)}prepareSymbolPatch(r){t(this.graphics3DSymbol)&&this.graphics3DSymbol.prepareSymbolPatch(r)}updateGeometry(r,s){return!!t(this.graphics3DSymbol)&&this.graphics3DSymbol.updateGeometry(r,s)}onRemoveGraphic(){}getFastUpdateStatus(){return t(this.graphics3DSymbol)?this.graphics3DSymbol.getFastUpdateStatus():{loading:1,fast:0,slow:0}}destroy(){t(this.graphics3DSymbol)&&this.graphics3DSymbol.destroy(),this.graphics3DSymbol=void 0,this.abortLoad()}get destroyed(){return void 0===this.graphics3DSymbol}}export{i as default};
5
+ import{isSome as t}from"../../../../core/maybe.js";import{Loadable as s}from"./Loadable.js";import{emptySymbolComplexity as r}from"./symbolComplexity.js";class i extends s{constructor(t,s,r){super(s),this.symbol=t,this.convert=r,this.graphics3DSymbol=null,this.referenced=0}getSymbolLayerSize(s){return t(this.graphics3DSymbol)?this.graphics3DSymbol.getSymbolLayerSize(s):null}get symbolLayers(){return t(this.graphics3DSymbol)?this.graphics3DSymbol.symbolLayers:[]}get extentPadding(){return t(this.graphics3DSymbol)?this.graphics3DSymbol.extentPadding:0}async doLoad(t){const s=await this.symbol.fetchSymbol({signal:t});s.id=this.symbol.id,this.graphics3DSymbol=this.convert(s),await this.graphics3DSymbol.load()}createGraphics3DGraphic(s){return t(this.graphics3DSymbol)?this.graphics3DSymbol.createGraphics3DGraphic(s,this):null}get complexity(){return t(this.graphics3DSymbol)?this.graphics3DSymbol.complexity:r}globalPropertyChanged(s,r){return!!t(this.graphics3DSymbol)&&this.graphics3DSymbol.globalPropertyChanged(s,r)}applyRendererDiff(s,r){return!!t(this.graphics3DSymbol)&&this.graphics3DSymbol.applyRendererDiff(s,r)}prepareSymbolPatch(s){t(this.graphics3DSymbol)&&this.graphics3DSymbol.prepareSymbolPatch(s)}updateGeometry(s,r){return!!t(this.graphics3DSymbol)&&this.graphics3DSymbol.updateGeometry(s,r)}onRemoveGraphic(){}getFastUpdateStatus(){return t(this.graphics3DSymbol)?this.graphics3DSymbol.getFastUpdateStatus():{loading:1,fast:0,slow:0}}destroy(){t(this.graphics3DSymbol)&&this.graphics3DSymbol.destroy(),this.graphics3DSymbol=void 0,this.abortLoad()}get destroyed(){return void 0===this.graphics3DSymbol}}export{i as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as l}from"../../../../core/asyncUtils.js";import a from"../../../../core/Handles.js";import i from"../../../../core/Logger.js";import{someMap as r}from"../../../../core/MapUtils.js";import{destroyMaybe as o,disposeMaybe as n,isNone as c,unwrap as h}from"../../../../core/maybe.js";import{throwIfAborted as b,isAbortError as d,createAbortController as p}from"../../../../core/promiseUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as g}from"../../../../core/accessorSupport/decorators/subclass.js";import{hydrateGraphic as y}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as f}from"../../../../layers/support/labelFormatUtils.js";import{areLabelsVisible as _}from"../../../../layers/support/layerUtils.js";import{isCalloutSupport as m}from"../../../../symbols/callouts/calloutUtils.js";import{make as x}from"./Graphics3DCalloutSymbolLayerFactory.js";import C from"./Graphics3DGraphicCreationContext.js";import{getGraphics3DSymbol as v}from"./graphicSymbolUtils.js";import{get as T}from"./labelPlacement.js";import L from"../../support/debugFlags.js";import{MaterialCollection as G}from"../../webgl-engine/lib/MaterialCollection.js";import{TextRenderer as D}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as R}from"../../webgl-engine/lib/TextRenderParameters.js";import w from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as A}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as O}from"../../../support/Scheduler.js";const I=i.getLogger("esri.views.3d.layers.graphics.Labeler");let S=class extends t{constructor(){super(...arguments),this._dirty=!1,this._labels=new Map,this._labelsToAdd=new Map,this._labelsToRemove=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this._handles=new a,this._handles.add([this.view.watch("state.camera",(()=>this.setDirty())),this.view.watch("pixelRatio",(()=>this._resetAllLabels())),this.view.resourceController.scheduler.registerTask(O.LABELER,this)]),this._textTextureAtlas=new w({view:this.view}),this._hudMaterialCollection=new G(this.view._stage),this._calloutMaterialCollection=new G(this.view._stage)}dispose(){this._handles=o(this._handles),this._textTextureAtlas=n(this._textTextureAtlas),this._hudMaterialCollection=n(this._hudMaterialCollection),this._calloutMaterialCollection=n(this._calloutMaterialCollection),this._labelingContexts.length=0,this._labels.clear(),this._labelsToAdd.clear(),this._labelsToRemove.clear()}_activateLabelingContext(e){e.labels.forEach(((e,t)=>{this._labels.set(t,e),e.graphics3DGraphic.setVisibilityFlag(0,!0,1)})),e.active=!0}_deactivateLabelingContext(e){e.labels.forEach(((e,t)=>{e.graphics3DGraphic.setVisibilityFlag(0,!1,1),this.setLabelGraphicVisibility(e.graphics3DGraphic,!1),this._labels.delete(t)})),e.active=!1}_addLabelTextureToAtlas(e){for(const t of e.graphics3DGraphic.labelGraphics){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];s&&this._textTextureAtlas.addTextTexture(s,t.stageObject)}e.rendered=!0}_removeLabelTextureFromAtlas(e){for(const t of e.graphics3DGraphic.labelGraphics){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];s&&this._textTextureAtlas.removeTextTexture(s,t.stageObject)}e.rendered=!1}get running(){var e;return!!this.view.ready&&(this._dirty||(null==(e=this._textTextureAtlas)?void 0:e.updating)||this.deconflictor.running)}runTask(e){this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e)}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(j(t)){if(!E(t)){if(V(t)){this._deactivateLabelingContext(t);continue}if(this._createLabelClassContext(t),P(t)){this._dirty=!0;continue}if(!E(t))continue}r(t.labelsToInitialize,((s,l)=>(this._ensureGraphics3DResources(s)&&(this._labels.set(l,s),this.deconflictor.setDirty(),e.madeProgress()),(s.visible&&s.hasTextTextureResources||!s.visible&&s.hasGraphics3DResources)&&(t.labelsToInitialize.delete(l),e.madeProgress()),e.done)))&&(this._dirty=!0)}this._labelsToRemove.forEach((e=>this._removeLabelTextureFromAtlas(e))),this._labelsToAdd.forEach((e=>this._addLabelTextureToAtlas(e))),this._labelsToRemove.clear(),this._labelsToAdd.clear(),this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController.signal;await e.layer.when(),b(t),e.scaleVisibility&&e.scaleVisibility.updateScaleRangeActive();const a=e.graphics3DCore,i=a.layer,r=i.labelingInfo&&i.labelingInfo.filter((e=>!!e.symbol));if(!r||0===r.length)return;const o=new Array(r.length);let n=!1;await s(r,(async(s,i)=>{const r=s.symbol,h=v(a.getOrCreateGraphics3DSymbol(r));if(c(h))return void I.error("Failed to create Graphics3DSymbol for label");await h.load(),b(t);let d=null;m(r)&&r.hasVisibleCallout()&&(d=x(r,a.symbolCreationContext),await d.load(),b(t));const p=await l(f(s,e.layer.fieldsIndex,this.view.spatialReference));b(t),!0===p.ok?o[i]={labelClass:s,labelFunction:p.value,graphics3DSymbol:h,graphics3DCalloutSymbolLayer:d,calloutSymbolLayerIndex:0,textRenderParameters:this._createTextRenderParameters(h.symbol)}:(I.error(`Label expression failed to evaluate: ${p.error}`),n=!0)})),b(t),n||(e.labelClassContexts=o)}async _createLabelClassContext(e){return e.labelClassPromise||(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(d(t))throw t;e.labelClassContexts=null})).then((()=>{e.labelClassAbortController=null,this.notifyChange("updating")})).catch((()=>{})),this.notifyChange("updating")),e.labelClassPromise}_createTextRenderParameters(e){const t=e.symbolLayers.getItemAt(0);return t&&"text"===t.type?R.fromSymbol(t,this.view.pixelRatio):null}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced,s.graphics3DSymbol=null;const t=e.labelClassAbortController;e.labelClassAbortController=p(),t&&t.abort(),e.labelClassContexts=[],e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,l,a){const i={text:e.text,centerOffset:s.centerOffset,translation:s.translation,elevationOffset:s.elevationOffset,screenOffset:s.screenOffset,anchor:s.anchor,centerOffsetUnits:s.centerOffsetUnits,verticalOffset:s.verticalOffset,debugDrawBorder:L.LABELS_SHOW_BORDER,displayWidth:e.displayWidth,displayHeight:e.displayHeight};return M.graphic=t,M.renderingInfo=null,M.layer=l,a.createLabel(M,i,this._hudMaterialCollection,this._textTextureAtlas)}_createLineCalloutGraphic(e,t,s,l,a){const i={symbol:t,translation:l.translation,elevationOffset:l.elevationOffset,screenOffset:l.screenOffset,centerOffset:l.centerOffset,centerOffsetUnits:l.centerOffsetUnits,materialCollection:this._calloutMaterialCollection};return M.graphic=e,M.renderingInfo=i,M.layer=a,s.createGraphics3DGraphic(M)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,l=s.labelClassContexts;if(!l||0===l.length||!s.emptySymbolLabelSupported&&0===t.graphics.length)return!1;let a=!1;const i=t.graphic,r=s.layer,o=_(s.layer),n=this.view._stage;for(let h=0;h<l.length;h++){const b=e.textRenderers[h];if(!b)continue;const d=l[h],p=d.graphics3DSymbol;let u=null;p.symbol&&"label-3d"===p.symbol.type&&(u=p.symbol);const g=p.symbolLayers[0];if(!g)continue;const y=d.labelClass,f=s.disablePlacement,_=T({graphics3DGraphic:t,labelSymbol:u,labelClass:y,disablePlacement:f});if(c(_))continue;g.setElevationInfoOverride(s.elevationInfoOverride);const m=this._createTextSymbolGraphic(b,i,_,r,g);if(!m)return!1;m._labelClass=y,m._labelIndex=h,t.addLabelGraphic(m,n,s.stageLayer),t.setVisibilityFlag(0,o,1),t.clearVisibilityFlag(1,1),t.setVisibilityFlag(3,!1,1),a=!0;const x=d.graphics3DCalloutSymbolLayer;if(x&&_.hasLabelVerticalOffset){x.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(i,u,x,_,r);e&&(d.calloutSymbolLayerIndex=t.labelGraphics.length,t.addLabelGraphic(e,n,s.stageLayer))}break}return s.scaleVisibility&&a&&s.scaleVisibility.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelGraphics){if(null==s._labelClass)continue;const e=t[s._labelIndex].graphics3DSymbol.symbolLayers[0];null!=e&&e.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.hasTextTextureResources)return;const t=e.labelingContext,s=t.labelClassContexts;if(!s||0===s.length)return;const l=e.graphics3DGraphic.graphic;for(let i=0;i<s.length;i++){const r=s[i];if(e.textRenderers[i]=null,!r.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?y(l,t.layer):l;n=o.evaluate(e)}catch(a){n=null}else n=o.evaluate(l);c(n)||""===n||/^\s+$/.test(n)||(e.textRenderers[i]=new D(n,r.textRenderParameters))}e.hasTextTextureResources=!0}_destroyTextTextureResources(e){e.textRenderers=[],e.hasTextTextureResources=!1}_addGraphic(e,t){const s={hasGraphics3DResources:!1,hasTextTextureResources:!1,visible:!1,rendered:!1,labelingContext:e,graphics3DGraphic:t,textRenderers:[]},l=t.graphic.uid;e.labels.set(l,s),e.labelsToInitialize.set(l,s),this.setDirty(),this.deconflictor.setDirty()}_removeGraphic(e,t){const s=t.graphic.uid,l=e.labels.get(s);l&&(this._destroyGraphic(l,s),e.labels.delete(s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.has(t)&&(this._labels.delete(t),this._labelsToAdd.delete(t),this._labelsToRemove.delete(t)),e.hasTextTextureResources&&(this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e)),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.labels.get(s);t&&(this._removeGraphic(e,t.graphics3DGraphic),this._addGraphic(e,t.graphics3DGraphic))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const l=new Map;t.labels.forEach((e=>{const t=e.graphics3DGraphic;l.set(t.graphic.uid,t)}));const a=e=>e.labelGraphics[0];if(h(s.graphics3DSymbol.symbolLayers[0]).globalPropertyChanged(e,l,a),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelGraphics[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,l,t)}}}_visibilityInfoChange(e){const t=e.layer.labelsVisible;t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.labels.forEach(((t,s)=>{this._destroyGraphic(t,s),t.visible=!1,t.rendered=!1,e.labelsToInitialize.set(s,t)})),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const l=s&&s.emptySymbolLabelSupported||!1,a=s&&s.elevationInfoOverride||null,i=s&&s.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o={graphics3DCore:e,layer:r,scaleVisibility:t,emptySymbolLabelSupported:l,elevationInfoOverride:a,disablePlacement:i,active:r.labelsVisible,labelClassPromise:null,labelClassAbortController:p(),labelClassContexts:[],labels:new Map,labelsToInitialize:new Map,stageLayer:new A({isPickable:!0},r.uid)};return this.view._stage.add(o.stageLayer),this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),featureReductionChange:()=>{},layerLabelsEnabled:()=>_(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),clear:()=>{}}}removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.labels.forEach((e=>this._removeGraphic(t,e.graphics3DGraphic))),this.view._stage.remove(t.stageLayer),t.stageLayer=null,this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,l=this._labels.get(s);l&&l.visible!==t&&(t&&!l.rendered?(this._labelsToAdd.set(s,l),this._labelsToRemove.delete(s),l.hasTextTextureResources||l.labelingContext.labelsToInitialize.set(s,l)):!t&&l.rendered&&(this._labelsToRemove.set(s,l),this._labelsToAdd.delete(s)),l.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){var e;return this._dirty||(null==(e=this._textTextureAtlas)?void 0:e.updating)||this.deconflictor.updating||this._labelingContexts.some((e=>P(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(P(t)?0:1)),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get test(){return{textTextureAtlas:this._textTextureAtlas,resetAllLabels:()=>this._resetAllLabels()}}};function j(e){return e.active&&_(e.layer)}function P(e){return e.labelClassPromise&&!!e.labelClassAbortController}function E(e){return e.labelClassContexts&&e.labelClassContexts.length}function V(e){return null===e.labelClassContexts}e([u({constructOnly:!0})],S.prototype,"view",void 0),e([u({constructOnly:!0})],S.prototype,"deconflictor",void 0),e([u()],S.prototype,"_textTextureAtlas",void 0),e([u({type:Boolean,readOnly:!0})],S.prototype,"updating",null),S=e([g("esri.views.3d.layers.graphics.Labeler")],S);const M=new C(null,null,null);export{S as Labeler};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{forEach as s,result as l}from"../../../../core/asyncUtils.js";import a from"../../../../core/Handles.js";import i from"../../../../core/Logger.js";import{someMap as r}from"../../../../core/MapUtils.js";import{destroyMaybe as o,disposeMaybe as n,isNone as c,unwrap as h}from"../../../../core/maybe.js";import{throwIfAborted as b,isAbortError as d}from"../../../../core/promiseUtils.js";import{property as p}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as u}from"../../../../core/accessorSupport/decorators/subclass.js";import{hydrateGraphic as g}from"../../../../layers/graphics/hydratedFeatures.js";import{createLabelFunction as y}from"../../../../layers/support/labelFormatUtils.js";import{areLabelsVisible as f}from"../../../../layers/support/layerUtils.js";import{isCalloutSupport as _}from"../../../../symbols/callouts/calloutUtils.js";import{make as m}from"./Graphics3DCalloutSymbolLayerFactory.js";import x from"./Graphics3DGraphicCreationContext.js";import{getGraphics3DSymbol as C}from"./graphicSymbolUtils.js";import{get as v}from"./labelPlacement.js";import T from"../../support/debugFlags.js";import{MaterialCollection as L}from"../../webgl-engine/lib/MaterialCollection.js";import{TextRenderer as G}from"../../webgl-engine/lib/TextRenderer.js";import{TextRenderParameters as D}from"../../webgl-engine/lib/TextRenderParameters.js";import R from"../../webgl-engine/lib/TextTextureAtlas.js";import{WebGLLayer as w}from"../../webgl-engine/lib/WebGLLayer.js";import{TaskPriority as A}from"../../../support/Scheduler.js";const O=i.getLogger("esri.views.3d.layers.graphics.Labeler");let I=class extends t{constructor(){super(...arguments),this._dirty=!1,this._labels=new Map,this._labelsToAdd=new Map,this._labelsToRemove=new Map,this._labelingContexts=new Array}setup(){this.dispose(),this._handles=new a,this._handles.add([this.view.watch("state.camera",(()=>this.setDirty())),this.view.watch("pixelRatio",(()=>this._resetAllLabels())),this.view.resourceController.scheduler.registerTask(A.LABELER,this)]),this._textTextureAtlas=new R({view:this.view}),this._hudMaterialCollection=new L(this.view._stage),this._calloutMaterialCollection=new L(this.view._stage)}dispose(){this._handles=o(this._handles),this._textTextureAtlas=n(this._textTextureAtlas),this._hudMaterialCollection=n(this._hudMaterialCollection),this._calloutMaterialCollection=n(this._calloutMaterialCollection),this._labelingContexts.length=0,this._labels.clear(),this._labelsToAdd.clear(),this._labelsToRemove.clear()}_activateLabelingContext(e){e.labels.forEach(((e,t)=>{this._labels.set(t,e),e.graphics3DGraphic.setVisibilityFlag(0,!0,1)})),e.active=!0}_deactivateLabelingContext(e){e.labels.forEach(((e,t)=>{e.graphics3DGraphic.setVisibilityFlag(0,!1,1),this.setLabelGraphicVisibility(e.graphics3DGraphic,!1),this._labels.delete(t)})),e.active=!1}_addLabelTextureToAtlas(e){for(const t of e.graphics3DGraphic.labelGraphics){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];s&&this._textTextureAtlas.addTextTexture(s,t.stageObject)}e.rendered=!0}_removeLabelTextureFromAtlas(e){for(const t of e.graphics3DGraphic.labelGraphics){if(!t._labelClass)continue;const s=e.textRenderers[t._labelIndex];s&&this._textTextureAtlas.removeTextTexture(s,t.stageObject)}e.rendered=!1}get running(){var e;return!!this.view.ready&&(this._dirty||(null==(e=this._textTextureAtlas)?void 0:e.updating)||this.deconflictor.running)}runTask(e){this._updateLabels(e),!this._dirty&&this.deconflictor.running&&this.deconflictor.runTask(e)}_updateLabels(e){if(this._dirty){this._dirty=!1;for(const t of this._labelingContexts)if(S(t)){if(!P(t)){if(E(t)){this._deactivateLabelingContext(t);continue}if(this._createLabelClassContext(t),j(t)){this._dirty=!0;continue}if(!P(t))continue}r(t.labelsToInitialize,((s,l)=>(this._ensureGraphics3DResources(s)&&(this._labels.set(l,s),this.deconflictor.setDirty(),e.madeProgress()),(s.visible&&s.hasTextTextureResources||!s.visible&&s.hasGraphics3DResources)&&(t.labelsToInitialize.delete(l),e.madeProgress()),e.done)))&&(this._dirty=!0)}this._labelsToRemove.forEach((e=>this._removeLabelTextureFromAtlas(e))),this._labelsToAdd.forEach((e=>this._addLabelTextureToAtlas(e))),this._labelsToRemove.clear(),this._labelsToAdd.clear(),this._dirty||this.notifyChange("updating")}}async _createLabelClassContextAsync(e){const t=e.labelClassAbortController.signal;await e.layer.when(),b(t),e.scaleVisibility&&e.scaleVisibility.updateScaleRangeActive();const a=e.graphics3DCore,i=a.layer,r=i.labelingInfo&&i.labelingInfo.filter((e=>!!e.symbol));if(!r||0===r.length)return;const o=new Array(r.length);let n=!1;await s(r,(async(s,i)=>{const r=s.symbol,h=C(a.getOrCreateGraphics3DSymbol(r));if(c(h))return void O.error("Failed to create Graphics3DSymbol for label");await h.load(),b(t);let d=null;_(r)&&r.hasVisibleCallout()&&(d=m(r,a.symbolCreationContext),await d.load(),b(t));const p=await l(y(s,e.layer.fieldsIndex,this.view.spatialReference));b(t),!0===p.ok?o[i]={labelClass:s,labelFunction:p.value,graphics3DSymbol:h,graphics3DCalloutSymbolLayer:d,calloutSymbolLayerIndex:0,textRenderParameters:this._createTextRenderParameters(h.symbol)}:(O.error(`Label expression failed to evaluate: ${p.error}`),n=!0)})),b(t),n||(e.labelClassContexts=o)}async _createLabelClassContext(e){return e.labelClassPromise||(e.labelClassPromise=this._createLabelClassContextAsync(e).catch((t=>{if(d(t))throw t;e.labelClassContexts=null})).then((()=>{e.labelClassAbortController=null,this.notifyChange("updating")})).catch((()=>{})),this.notifyChange("updating")),e.labelClassPromise}_createTextRenderParameters(e){const t=e.symbolLayers.getItemAt(0);return t&&"text"===t.type?D.fromSymbol(t,this.view.pixelRatio):null}_destroyLabelClassContext(e){for(const s of e.labelClassContexts)--s.graphics3DSymbol.referenced,s.graphics3DSymbol=null;const t=e.labelClassAbortController;e.labelClassAbortController=new AbortController,t&&t.abort(),e.labelClassContexts=[],e.labelClassPromise=null,this.notifyChange("updating")}_createTextSymbolGraphic(e,t,s,l,a){const i={text:e.text,centerOffset:s.centerOffset,translation:s.translation,elevationOffset:s.elevationOffset,screenOffset:s.screenOffset,anchor:s.anchor,centerOffsetUnits:s.centerOffsetUnits,verticalOffset:s.verticalOffset,debugDrawBorder:T.LABELS_SHOW_BORDER,displayWidth:e.displayWidth,displayHeight:e.displayHeight};return V.graphic=t,V.renderingInfo=null,V.layer=l,a.createLabel(V,i,this._hudMaterialCollection,this._textTextureAtlas)}_createLineCalloutGraphic(e,t,s,l,a){const i={symbol:t,translation:l.translation,elevationOffset:l.elevationOffset,screenOffset:l.screenOffset,centerOffset:l.centerOffset,centerOffsetUnits:l.centerOffsetUnits,materialCollection:this._calloutMaterialCollection};return V.graphic=e,V.renderingInfo=i,V.layer=a,s.createGraphics3DGraphic(V)}_ensureGraphics3DResources(e){if(e.hasGraphics3DResources)return!1;const t=e.graphics3DGraphic;if(t.destroyed)return!1;this._ensureTextTextureResources(e);const s=e.labelingContext,l=s.labelClassContexts;if(!l||0===l.length||!s.emptySymbolLabelSupported&&0===t.graphics.length)return!1;let a=!1;const i=t.graphic,r=s.layer,o=f(s.layer),n=this.view._stage;for(let h=0;h<l.length;h++){const b=e.textRenderers[h];if(!b)continue;const d=l[h],p=d.graphics3DSymbol;let u=null;p.symbol&&"label-3d"===p.symbol.type&&(u=p.symbol);const g=p.symbolLayers[0];if(!g)continue;const y=d.labelClass,f=s.disablePlacement,_=v({graphics3DGraphic:t,labelSymbol:u,labelClass:y,disablePlacement:f});if(c(_))continue;g.setElevationInfoOverride(s.elevationInfoOverride);const m=this._createTextSymbolGraphic(b,i,_,r,g);if(!m)return!1;m._labelClass=y,m._labelIndex=h,t.addLabelGraphic(m,n,s.stageLayer),t.setVisibilityFlag(0,o,1),t.clearVisibilityFlag(1,1),t.setVisibilityFlag(3,!1,1),a=!0;const x=d.graphics3DCalloutSymbolLayer;if(x&&_.hasLabelVerticalOffset){x.setElevationInfoOverride(s.elevationInfoOverride);const e=this._createLineCalloutGraphic(i,u,x,_,r);e&&(d.calloutSymbolLayerIndex=t.labelGraphics.length,t.addLabelGraphic(e,n,s.stageLayer))}break}return s.scaleVisibility&&a&&s.scaleVisibility.updateGraphicLabelScaleVisibility(t),e.hasGraphics3DResources=!0,!0}_destroyGraphics3DResources(e){const t=e.labelingContext.labelClassContexts;for(const s of e.graphics3DGraphic.labelGraphics){if(null==s._labelClass)continue;const e=t[s._labelIndex].graphics3DSymbol.symbolLayers[0];null!=e&&e.onRemoveGraphic(s)}e.graphics3DGraphic.clearLabelGraphics(),e.hasGraphics3DResources=!1}_ensureTextTextureResources(e){if(e.hasTextTextureResources)return;const t=e.labelingContext,s=t.labelClassContexts;if(!s||0===s.length)return;const l=e.graphics3DGraphic.graphic;for(let i=0;i<s.length;i++){const r=s[i];if(e.textRenderers[i]=null,!r.textRenderParameters)continue;const o=r.labelFunction;let n;if("arcade"===o.type)try{const e=o.needsHydrationToEvaluate()?g(l,t.layer):l;n=o.evaluate(e)}catch(a){n=null}else n=o.evaluate(l);c(n)||""===n||/^\s+$/.test(n)||(e.textRenderers[i]=new G(n,r.textRenderParameters))}e.hasTextTextureResources=!0}_destroyTextTextureResources(e){e.textRenderers=[],e.hasTextTextureResources=!1}_addGraphic(e,t){const s={hasGraphics3DResources:!1,hasTextTextureResources:!1,visible:!1,rendered:!1,labelingContext:e,graphics3DGraphic:t,textRenderers:[]},l=t.graphic.uid;e.labels.set(l,s),e.labelsToInitialize.set(l,s),this.setDirty(),this.deconflictor.setDirty()}_removeGraphic(e,t){const s=t.graphic.uid,l=e.labels.get(s);l&&(this._destroyGraphic(l,s),e.labels.delete(s),e.labelsToInitialize.delete(s),this.setDirty(),this.deconflictor.setDirty())}_destroyGraphic(e,t){this._labels.has(t)&&(this._labels.delete(t),this._labelsToAdd.delete(t),this._labelsToRemove.delete(t)),e.hasTextTextureResources&&(this._removeLabelTextureFromAtlas(e),this._destroyTextTextureResources(e)),e.hasGraphics3DResources&&this._destroyGraphics3DResources(e)}async _labelingInfoChange(e,t){if(!t)return this._visibilityInfoChange(e),this._resetLabels(e),this._createLabelClassContext(e);for(const s of t){const t=e.labels.get(s);t&&(this._removeGraphic(e,t.graphics3DGraphic),this._addGraphic(e,t.graphics3DGraphic))}}_globalPropertyChanged(e,t){for(const s of t.labelClassContexts){const l=new Map;t.labels.forEach((e=>{const t=e.graphics3DGraphic;l.set(t.graphic.uid,t)}));const a=e=>e.labelGraphics[0];if(h(s.graphics3DSymbol.symbolLayers[0]).globalPropertyChanged(e,l,a),s.graphics3DCalloutSymbolLayer){const t=e=>e.labelGraphics[s.calloutSymbolLayerIndex];s.graphics3DCalloutSymbolLayer.globalPropertyChanged(e,l,t)}}}_visibilityInfoChange(e){const t=e.layer.labelsVisible;t&&!e.active&&this._activateLabelingContext(e),!t&&e.active&&this._deactivateLabelingContext(e),this.setDirty()}_resetAllLabels(){for(const e of this._labelingContexts)this._resetLabels(e)}_resetLabels(e){e.labels.forEach(((t,s)=>{this._destroyGraphic(t,s),t.visible=!1,t.rendered=!1,e.labelsToInitialize.set(s,t)})),this._destroyLabelClassContext(e),this.setDirty(),this.deconflictor.setDirty()}_findLabelingContext(e){for(const t of this._labelingContexts)if(t.graphics3DCore===e)return t;return null}addGraphicsOwner(e,t,s){const l=s&&s.emptySymbolLabelSupported||!1,a=s&&s.elevationInfoOverride||null,i=s&&s.disablePlacement||null;if(this._findLabelingContext(e))return;const r=e.layer,o={graphics3DCore:e,layer:r,scaleVisibility:t,emptySymbolLabelSupported:l,elevationInfoOverride:a,disablePlacement:i,active:r.labelsVisible,labelClassPromise:null,labelClassAbortController:new AbortController,labelClassContexts:[],labels:new Map,labelsToInitialize:new Map,stageLayer:new w({isPickable:!0},r.uid)};return this.view._stage.add(o.stageLayer),this._labelingContexts.push(o),this.setDirty(),{addGraphic:e=>this._addGraphic(o,e),removeGraphic:e=>this._removeGraphic(o,e),featureReductionChange:()=>{},layerLabelsEnabled:()=>f(o.layer),labelingInfoChange:e=>this._labelingInfoChange(o,e),elevationInfoChange:()=>this._globalPropertyChanged("elevationInfo",o),slicePlaneEnabledChange:()=>this._globalPropertyChanged("slicePlaneEnabled",o),visibilityInfoChange:()=>this._visibilityInfoChange(o),reset:()=>this._resetLabels(o),clear:()=>{}}}removeGraphicsOwner(e){const t=this._findLabelingContext(e);if(!t)return;const s=this._labelingContexts.indexOf(t);this._labelingContexts.splice(s,1),t.labels.forEach((e=>this._removeGraphic(t,e.graphics3DGraphic))),this.view._stage.remove(t.stageLayer),t.stageLayer=null,this.setDirty()}setLabelGraphicVisibility(e,t){const s=e.graphic.uid,l=this._labels.get(s);l&&l.visible!==t&&(t&&!l.rendered?(this._labelsToAdd.set(s,l),this._labelsToRemove.delete(s),l.hasTextTextureResources||l.labelingContext.labelsToInitialize.set(s,l)):!t&&l.rendered&&(this._labelsToRemove.set(s,l),this._labelsToAdd.delete(s)),l.visible=t,this.setDirty())}setDirty(){!this._dirty&&this._labelingContexts.length>0&&(this._dirty=!0,this.notifyChange("updating"))}get updating(){var e;return this._dirty||(null==(e=this._textTextureAtlas)?void 0:e.updating)||this.deconflictor.updating||this._labelingContexts.some((e=>j(e)))}get updatingProgress(){if(!this.updating||!this._textTextureAtlas)return 1;const e=this._labelingContexts.length>0?this._labelingContexts.reduce(((e,t)=>e+(j(t)?0:1)),0)/this._labelingContexts.length:1;return(this._dirty?0:.3)+(this._textTextureAtlas.updating?0:.1)+.1*e+.5*this.deconflictor.updatingProgress}get test(){return{textTextureAtlas:this._textTextureAtlas,resetAllLabels:()=>this._resetAllLabels()}}};function S(e){return e.active&&f(e.layer)}function j(e){return e.labelClassPromise&&!!e.labelClassAbortController}function P(e){return e.labelClassContexts&&e.labelClassContexts.length}function E(e){return null===e.labelClassContexts}e([p({constructOnly:!0})],I.prototype,"view",void 0),e([p({constructOnly:!0})],I.prototype,"deconflictor",void 0),e([p()],I.prototype,"_textTextureAtlas",void 0),e([p({type:Boolean,readOnly:!0})],I.prototype,"updating",null),I=e([u("esri.views.3d.layers.graphics.Labeler")],I);const V=new x(null,null,null);export{I as Labeler};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import{createAbortController as t,isAbortError as o}from"../../../../core/promiseUtils.js";class l{constructor(t){this.schedule=t,this._abortController=null,this._loadStatus=0,this._loadError=null,this._loader=null,this.logger=null}get loadStatus(){return this._loadStatus}load(l,r){return 1===this._loadStatus?(l&&l(),this._loader):2===this._loadStatus?(r&&r(this._loadError),this._loader):(this._loader||(this._abortController=t(),this._loader=this.doLoad(this._abortController.signal).then((()=>{this._abortController=null,this._loadStatus=1}),(t=>{throw this._loadError=t,this._abortController=null,this._loadStatus=2,!o(t)&&this.logger&&t.message&&this.logger.warn(t.message),t}))),this._loader.then(l,r).catch((()=>{})),this._loader)}abortLoad(){this._abortController?(this._abortController.abort(),this._abortController=null):0===this._loadStatus&&(this._loadStatus=2),this._loader=null}}export{l as Loadable};
5
+ import{isAbortError as t}from"../../../../core/promiseUtils.js";class o{constructor(t){this.schedule=t,this._abortController=null,this._loadStatus=0,this._loadError=null,this._loader=null,this.logger=null}get loadStatus(){return this._loadStatus}load(o,l){return 1===this._loadStatus?(o&&o(),this._loader):2===this._loadStatus?(l&&l(this._loadError),this._loader):(this._loader||(this._abortController=new AbortController,this._loader=this.doLoad(this._abortController.signal).then((()=>{this._abortController=null,this._loadStatus=1}),(o=>{throw this._loadError=o,this._abortController=null,this._loadStatus=2,!t(o)&&this.logger&&o.message&&this.logger.warn(o.message),o}))),this._loader.then(o,l).catch((()=>{})),this._loader)}abortLoad(){this._abortController?(this._abortController.abort(),this._abortController=null):0===this._loadStatus&&(this._loadStatus=2),this._loader=null}}export{o as Loadable};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.22/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Handles.js";import{timeoutHandle as t}from"../../../../core/handleUtils.js";import{isSome as r}from"../../../../core/maybe.js";import{isAborted as o,createAbortError as s,onAbort as i,createAbortController as a}from"../../../../core/promiseUtils.js";import{DefaultLoadingContext as n}from"../../glTF/DefaultLoadingContext.js";import{load as l}from"../../glTF/loader.js";import{load as c}from"./wosrLoader.js";class m{constructor(){this.gltfCache=new Map,this.wosrCache=new Map,this.evictHandles=new e}loadGLTF(e,t,r){const o=r?`gltfPBR:${e}`:`gltf:${e}`;return this.fromCache(this.gltfCache,o,(t=>l(new n(t.streamDataRequester),e,t,r)),t)}loadWOSR(e,t){const r=`wosr:${e}:${t.disableTextures}`;return this.fromCache(this.wosrCache,r,(t=>c(e,t)),t)}destroy(){this.evictHandles.destroy(),this.gltfCache.clear(),this.wosrCache.clear()}get size(){return this.wosrCache.size+this.gltfCache.size}fromCache(e,t,n,l){return new Promise(((c,m)=>{if(o(l))return void m(s());const h=i(l,(()=>{this.remove(e,t),m(s())})),f=e.get(t);if(f)return this.evictHandles.remove(t),f.refCount++,void f.item.then(c,m);const d=a(),C={...l,signal:d.signal},v={refCount:1,abortController:d,item:n(C).then((r=>(v.abortController=null,r.remove=()=>this.remove(e,t),r)))};e.set(t,v),v.item.then((e=>{r(h)&&h.remove(),c(e)}),(e=>{r(h)&&h.remove(),m(e)}))}))}remove(e,o){const s=e.get(o);s&&(s.refCount--,0===s.refCount&&this.evictHandles.add(t((()=>{e.delete(o),r(s.abortController)&&s.abortController.abort()}),f),o))}}const h=1e4;let f=h;const d={overrideEvictDelay:e=>(f=e,{remove(){f=h}})};export{m as ObjectResourceCache,d as test};
5
+ import e from"../../../../core/Handles.js";import{timeoutHandle as t}from"../../../../core/handleUtils.js";import{isSome as r}from"../../../../core/maybe.js";import{isAborted as o,createAbortError as s,onAbort as i}from"../../../../core/promiseUtils.js";import{DefaultLoadingContext as a}from"../../glTF/DefaultLoadingContext.js";import{load as n}from"../../glTF/loader.js";import{load as l}from"./wosrLoader.js";class c{constructor(){this.gltfCache=new Map,this.wosrCache=new Map,this.evictHandles=new e}loadGLTF(e,t,r){const o=r?`gltfPBR:${e}`:`gltf:${e}`;return this.fromCache(this.gltfCache,o,(t=>n(new a(t.streamDataRequester),e,t,r)),t)}loadWOSR(e,t){const r=`wosr:${e}:${t.disableTextures}`;return this.fromCache(this.wosrCache,r,(t=>l(e,t)),t)}destroy(){this.evictHandles.destroy(),this.gltfCache.clear(),this.wosrCache.clear()}get size(){return this.wosrCache.size+this.gltfCache.size}fromCache(e,t,a,n){return new Promise(((l,c)=>{if(o(n))return void c(s());const m=i(n,(()=>{this.remove(e,t),c(s())})),h=e.get(t);if(h)return this.evictHandles.remove(t),h.refCount++,void h.item.then(l,c);const f=new AbortController,d={...n,signal:f.signal},C={refCount:1,abortController:f,item:a(d).then((r=>(C.abortController=null,r.remove=()=>this.remove(e,t),r)))};e.set(t,C),C.item.then((e=>{r(m)&&m.remove(),l(e)}),(e=>{r(m)&&m.remove(),c(e)}))}))}remove(e,o){const s=e.get(o);s&&(s.refCount--,0===s.refCount&&this.evictHandles.add(t((()=>{e.delete(o),r(s.abortController)&&s.abortController.abort()}),h),o))}}const m=1e4;let h=m;const f={overrideEvictDelay:e=>(h=e,{remove(){h=m}})};export{c as ObjectResourceCache,f as test};