@arcgis/core 4.28.0-next.20230621 → 4.28.0-next.20230623

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 (249) hide show
  1. package/Basemap.js +1 -1
  2. package/arcade/ArcadeModuleResolver.js +1 -1
  3. package/arcade/Feature.js +1 -1
  4. package/arcade/arcadeCompiler.js +1 -1
  5. package/arcade/arcadeTimeUtils.js +1 -1
  6. package/arcade/featureset/actions/GroupBy.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/support/sqlUtils.js +1 -1
  9. package/arcade/functions/date.js +1 -1
  10. package/arcade/functions/geomasync.js +1 -1
  11. package/arcade/functions/geometry.js +1 -1
  12. package/arcade/functions/geomsync.js +1 -1
  13. package/arcade/functions/string.js +1 -1
  14. package/arcade/languageUtils.js +1 -1
  15. package/assets/esri/core/workers/RemoteClient.js +1 -1
  16. package/assets/esri/core/workers/chunks/0380e9f61b6f3ca85139.js +1 -0
  17. package/assets/esri/core/workers/chunks/0bd95f46a0a9005a19f9.js +1 -0
  18. package/assets/esri/core/workers/chunks/0c621046b7211cdde980.js +1 -0
  19. package/assets/esri/core/workers/chunks/0e0267739728e5413f1d.js +1 -0
  20. package/assets/esri/core/workers/chunks/{39079bcfd35ed73c4e34.js → 156e801a3262f0ac79c0.js} +1 -1
  21. package/assets/esri/core/workers/chunks/19b4f02fb2392d964582.js +1 -0
  22. package/assets/esri/core/workers/chunks/1ae75f5282e983f6d768.js +1 -0
  23. package/assets/esri/core/workers/chunks/2179b3e9e532ca8ef982.js +1 -0
  24. package/assets/esri/core/workers/chunks/21aaa7fa0e5482670010.js +1 -0
  25. package/assets/esri/core/workers/chunks/26212a08ea383547335b.js +1 -0
  26. package/assets/esri/core/workers/chunks/{2420ec029236ab31d908.js → 2882a55a971af1f7858b.js} +1 -1
  27. package/assets/esri/core/workers/chunks/294285f2822c101326ec.js +1 -0
  28. package/assets/esri/core/workers/chunks/29f9a380610e4fd98a7c.js +1 -0
  29. package/assets/esri/core/workers/chunks/303238fc2fcdbb277981.js +1 -0
  30. package/assets/esri/core/workers/chunks/{3db8ae98799c752afe60.js → 34958516e604d487c625.js} +1 -1
  31. package/assets/esri/core/workers/chunks/3bee743f4c9370045a5d.js +1 -0
  32. package/assets/esri/core/workers/chunks/{8e08968505483dc58e00.js → 40ee4e0a5000a08c3abd.js} +1 -1
  33. package/assets/esri/core/workers/chunks/4128e45e17c9e5280e11.js +1 -0
  34. package/assets/esri/core/workers/chunks/4f88c4d1d2103843aca8.js +1 -0
  35. package/assets/esri/core/workers/chunks/505792ce8cbbddd2e815.js +1 -0
  36. package/assets/esri/core/workers/chunks/{3d42fa4ab5f8632d690a.js → 5237b3938be0d4bc6045.js} +1 -1
  37. package/assets/esri/core/workers/chunks/{57077e608f20d3a931e8.js → 570e94f4fbefc856d303.js} +1 -1
  38. package/assets/esri/core/workers/chunks/{4b235d1b6a72773cd4f4.js → 57bb8516fa998a0fba78.js} +1 -1
  39. package/assets/esri/core/workers/chunks/57bf3ff01d738cedc292.js +1 -0
  40. package/assets/esri/core/workers/chunks/{1e9e68312cd865358260.js → 60486acc5dacf73f851a.js} +1 -1
  41. package/assets/esri/core/workers/chunks/6208f2dfa9dfd3bca000.js +1 -0
  42. package/assets/esri/core/workers/chunks/64008bde5d3ffd9f2499.js +1 -0
  43. package/assets/esri/core/workers/chunks/69f51a7768bf51c9e346.js +1 -0
  44. package/assets/esri/core/workers/chunks/719f741a0e45c3e694ba.js +1 -0
  45. package/assets/esri/core/workers/chunks/{cfe379a78a983373b3ac.js → 7304f45f5622a68253e4.js} +1 -1
  46. package/assets/esri/core/workers/chunks/733b70d6e5c466a67e9c.js +1 -0
  47. package/assets/esri/core/workers/chunks/7694521b44681d52b713.js +1 -0
  48. package/assets/esri/core/workers/chunks/840fd05ceaa038c476d6.js +1 -0
  49. package/assets/esri/core/workers/chunks/89f7fd2ab92aa14fe0c0.js +1 -0
  50. package/assets/esri/core/workers/chunks/8a6f29f2ebd59783bb1b.js +1 -0
  51. package/assets/esri/core/workers/chunks/9d487b7817ccf5bceff6.js +1 -0
  52. package/assets/esri/core/workers/chunks/{42b6315e21c4c1345ba5.js → 9f5337a80963e0b3c009.js} +1 -1
  53. package/assets/esri/core/workers/chunks/a0face18b3ea567999ef.js +1 -0
  54. package/assets/esri/core/workers/chunks/b773c8854e98384ac8ac.js +1 -0
  55. package/assets/esri/core/workers/chunks/{fb44d872b9dbadcf8ccf.js → b9ef05c22bc3e395bcb3.js} +1 -1
  56. package/assets/esri/core/workers/chunks/bc5e34200776cfc83d5b.js +1 -0
  57. package/assets/esri/core/workers/chunks/{cfc3dcca2b69d20d5375.js → c0b9cc091efd5db827de.js} +1 -1
  58. package/assets/esri/core/workers/chunks/c9f5e949830196ad9458.js +1 -0
  59. package/assets/esri/core/workers/chunks/{036301f545aba2b8e485.js → cc15e28a99694120556d.js} +1 -1
  60. package/assets/esri/core/workers/chunks/ce7f575a6c2053c7ca17.js +1 -0
  61. package/assets/esri/core/workers/chunks/ce9c99cee3d1a3963e7c.js +1 -0
  62. package/assets/esri/core/workers/chunks/cf9a87b53ea74bae6a37.js +1 -0
  63. package/assets/esri/core/workers/chunks/d16850b98a53ade0de10.js +1 -0
  64. package/assets/esri/core/workers/chunks/d24f7ef6eca8c91b90b4.js +1 -0
  65. package/assets/esri/core/workers/chunks/dbd86e4b7983873cbe7c.js +1 -0
  66. package/assets/esri/core/workers/chunks/{3c3f65913006b84b2289.js → de20572d334abd4a7d82.js} +1 -1
  67. package/assets/esri/core/workers/chunks/e009e7f074a572894f48.js +1 -0
  68. package/assets/esri/core/workers/chunks/{cb004c492e22c50f9bfa.js → f3eb89cff63e00f036c6.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{b2a423d9ce8bb784267c.js → f53f20c7100092823487.js} +1 -1
  70. package/assets/esri/core/workers/chunks/f6040205c50e2795a1a0.js +1 -0
  71. package/assets/esri/core/workers/chunks/{915734255a79bff3ef0f.js → fcd54e9e64c2864f183c.js} +1 -1
  72. package/assets/esri/t9n/common.json +1 -1
  73. package/assets/esri/t9n/common_en.json +1 -1
  74. package/assets/esri/themes/base/_core.scss +6 -2
  75. package/assets/esri/themes/base/_mixins.scss +0 -147
  76. package/assets/esri/themes/base/widgets/_AreaMeasurement2D.scss +0 -8
  77. package/assets/esri/themes/base/widgets/_AreaMeasurement3D.scss +0 -8
  78. package/assets/esri/themes/base/widgets/_DirectLineMeasurement3D.scss +0 -1
  79. package/assets/esri/themes/base/widgets/_DistanceMeasurement2D.scss +0 -1
  80. package/assets/esri/themes/base/widgets/_MeasurementWidgetContent.scss +67 -0
  81. package/assets/esri/themes/base/widgets/_Slice.scss +17 -54
  82. package/assets/esri/themes/base/widgets/_UnitSelect.scss +14 -0
  83. package/assets/esri/themes/dark/main.css +1 -1
  84. package/assets/esri/themes/light/main.css +1 -1
  85. package/assets/esri/themes/light/view.css +1 -1
  86. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D.json +1 -1
  87. package/assets/esri/widgets/AreaMeasurement2D/t9n/AreaMeasurement2D_en.json +1 -1
  88. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D.json +1 -1
  89. package/assets/esri/widgets/AreaMeasurement3D/t9n/AreaMeasurement3D_en.json +1 -1
  90. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D.json +1 -1
  91. package/assets/esri/widgets/DirectLineMeasurement3D/t9n/DirectLineMeasurement3D_en.json +1 -1
  92. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D.json +1 -1
  93. package/assets/esri/widgets/DistanceMeasurement2D/t9n/DistanceMeasurement2D_en.json +1 -1
  94. package/chunks/HUDMaterial.glsl.js +39 -39
  95. package/chunks/HighlightBlur.glsl.js +2 -2
  96. package/chunks/ShadowHighlight.glsl.js +1 -1
  97. package/chunks/arcade.js +1 -1
  98. package/chunks/languageUtils.js +1 -1
  99. package/core/HandleOwner.js +1 -1
  100. package/core/promiseUtils.js +1 -1
  101. package/core/support/{WatchUpdatingTracking.js → UpdatingHandles.js} +1 -1
  102. package/core/workers/workerFactory.js +1 -1
  103. package/geometry/projection.js +1 -1
  104. package/interfaces.d.ts +270 -5
  105. package/kernel.js +1 -1
  106. package/layers/Layer.js +1 -1
  107. package/layers/LinkChartLayer.d.ts +4 -0
  108. package/layers/LinkChartLayer.js +1 -1
  109. package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
  110. package/layers/mixins/PortalLayer.js +1 -1
  111. package/layers/support/TileInfoTilemapCache.js +1 -1
  112. package/package.json +1 -1
  113. package/support/revision.js +1 -1
  114. package/symbols/cim/cimAnalyzer.js +1 -1
  115. package/views/2d/layers/features/controllers/FeatureController2D.js +1 -1
  116. package/views/2d/layers/features/sources/DataTileSource.js +1 -1
  117. package/views/2d/layers/features/support/AttributeStore.js +1 -1
  118. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  119. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  120. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  121. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  122. package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
  123. package/views/3d/analysis/LineOfSight/LineOfSightVisualization.js +1 -1
  124. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  125. package/views/3d/environment/CloudsGenerator.js +1 -1
  126. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  127. package/views/3d/environment/Precipitation.js +1 -1
  128. package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
  129. package/views/3d/environment/Stars.js +1 -1
  130. package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
  131. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  132. package/views/3d/interactive/editingTools/transformGraphic/GraphicTransformTool.js +1 -1
  133. package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
  134. package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
  135. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  136. package/views/3d/layers/I3SMeshView3D.js +1 -1
  137. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  138. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  139. package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
  140. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  141. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  142. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  143. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  144. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  145. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  146. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  147. package/views/3d/layers/graphics/Graphics3DScaleVisibility.js +1 -1
  148. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  149. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  150. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  151. package/views/3d/layers/graphics/GraphicsProcessor.js +1 -1
  152. package/views/3d/layers/graphics/Labeler.js +1 -1
  153. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  154. package/views/3d/layers/support/FeatureTileTree3DDebugger.js +1 -1
  155. package/views/3d/layers/support/FeatureVisibilityFilter.js +1 -1
  156. package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
  157. package/views/3d/state/ViewState.js +1 -1
  158. package/views/3d/state/ViewStateManager.js +1 -1
  159. package/views/3d/support/DisplayQualityProfile.js +1 -1
  160. package/views/3d/support/MemoryController.js +1 -1
  161. package/views/3d/support/SceneViewPerformanceInfo.js +1 -1
  162. package/views/3d/support/cameraUtils.js +1 -1
  163. package/views/3d/support/viewpointUtils.js +1 -1
  164. package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
  165. package/views/3d/terrain/OverlayManager.js +1 -1
  166. package/views/3d/terrain/OverlayRenderer.js +1 -1
  167. package/views/3d/terrain/TerrainSurface.js +1 -1
  168. package/views/3d/webgl-engine/Stage.js +1 -1
  169. package/views/3d/webgl-engine/core/FBOCache.js +1 -1
  170. package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -7
  171. package/views/3d/webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js +1 -1
  172. package/views/3d/webgl-engine/lib/Highlight.js +1 -1
  173. package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
  174. package/views/3d/webgl-engine/lib/RenderPluginManager.js +1 -1
  175. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  176. package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
  177. package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
  178. package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
  179. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  180. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  181. package/views/LayerViewManager.js +1 -1
  182. package/views/ToolViewManager.js +1 -1
  183. package/views/draw/DrawOperation.js +1 -1
  184. package/views/draw/PointDrawAction.js +1 -1
  185. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  186. package/views/interactive/snapping/featureSources/FeatureServiceSnappingSource.js +1 -1
  187. package/views/interactive/snapping/featureSources/GraphicsSnappingSource.js +1 -1
  188. package/views/interactive/snapping/featureSources/I3SSnappingSource.js +1 -1
  189. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorker.js +1 -1
  190. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceSnappingSourceWorkerHandle.js +1 -1
  191. package/views/interactive/snapping/featureSources/featureServiceSource/FeatureServiceTiledFetcher.js +1 -1
  192. package/views/layers/LayerView.js +1 -1
  193. package/views/overlay/ViewOverlay.js +1 -1
  194. package/views/webgl/Texture.js +1 -1
  195. package/widgets/AreaMeasurement2D.js +1 -1
  196. package/widgets/AreaMeasurement3D.js +1 -1
  197. package/widgets/DirectLineMeasurement3D.js +1 -1
  198. package/widgets/DistanceMeasurement2D.js +1 -1
  199. package/widgets/Editor/EditorViewModel.js +1 -1
  200. package/widgets/Editor/Workflow.js +1 -1
  201. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  202. package/widgets/FeatureForm/FieldInput.js +1 -1
  203. package/widgets/FeatureForm/FormExpressionArcadeExecutor.js +1 -1
  204. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  205. package/widgets/OrientedImageryViewer.js +1 -1
  206. package/widgets/Slice.js +1 -1
  207. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  208. package/widgets/support/MeasurementWidgetContent.js +5 -0
  209. package/widgets/support/UnitSelect.js +5 -0
  210. package/assets/esri/core/workers/chunks/0254165377538522c830.js +0 -1
  211. package/assets/esri/core/workers/chunks/07f16ea775b39a1a4a7b.js +0 -1
  212. package/assets/esri/core/workers/chunks/170c72126d10b1fdb2b0.js +0 -1
  213. package/assets/esri/core/workers/chunks/1bbc868d2430103951eb.js +0 -1
  214. package/assets/esri/core/workers/chunks/1d2ef88a8d028adef102.js +0 -1
  215. package/assets/esri/core/workers/chunks/2ef70c9b2484a11b7435.js +0 -1
  216. package/assets/esri/core/workers/chunks/39ae4b9b766f674bc6f2.js +0 -1
  217. package/assets/esri/core/workers/chunks/3b3d676b609c47a77164.js +0 -1
  218. package/assets/esri/core/workers/chunks/3d9a8cb638cf9b8ca4b3.js +0 -1
  219. package/assets/esri/core/workers/chunks/42f3421740a5479559dc.js +0 -1
  220. package/assets/esri/core/workers/chunks/45629ff775e77234b227.js +0 -1
  221. package/assets/esri/core/workers/chunks/52315f93a6f0ad59bd90.js +0 -1
  222. package/assets/esri/core/workers/chunks/5bb96e602d7cecbecf54.js +0 -1
  223. package/assets/esri/core/workers/chunks/63322229183f1d4eaa70.js +0 -1
  224. package/assets/esri/core/workers/chunks/642510b0371311ff8e16.js +0 -1
  225. package/assets/esri/core/workers/chunks/6995ace1d25d67c98d0e.js +0 -1
  226. package/assets/esri/core/workers/chunks/7e4013f8c31c9a9438c6.js +0 -1
  227. package/assets/esri/core/workers/chunks/82939ead43848a13f765.js +0 -1
  228. package/assets/esri/core/workers/chunks/8b6b963230df56850580.js +0 -1
  229. package/assets/esri/core/workers/chunks/95ff92d7caa34664d58f.js +0 -1
  230. package/assets/esri/core/workers/chunks/9e570cd4a48c30c83ae6.js +0 -1
  231. package/assets/esri/core/workers/chunks/a9e9297267614c4c4f3b.js +0 -1
  232. package/assets/esri/core/workers/chunks/b052463ffb7cb32306dc.js +0 -1
  233. package/assets/esri/core/workers/chunks/b31974524932e638df8c.js +0 -1
  234. package/assets/esri/core/workers/chunks/b75b4b132dbd9cb9d372.js +0 -1
  235. package/assets/esri/core/workers/chunks/c1dfbda75abc748a6ca4.js +0 -1
  236. package/assets/esri/core/workers/chunks/c8702e53a8ad6cf6ab85.js +0 -1
  237. package/assets/esri/core/workers/chunks/c90416e7bf29eb1d4536.js +0 -1
  238. package/assets/esri/core/workers/chunks/cad7a2092ea7f51dbd8b.js +0 -1
  239. package/assets/esri/core/workers/chunks/d0e2b42dca51711f2c6f.js +0 -1
  240. package/assets/esri/core/workers/chunks/d2a127f7bb0e2ba14a13.js +0 -1
  241. package/assets/esri/core/workers/chunks/df96824a6f76bad1370c.js +0 -1
  242. package/assets/esri/core/workers/chunks/e097f41bbfac00250477.js +0 -1
  243. package/assets/esri/core/workers/chunks/e3243d120a23a9b48392.js +0 -1
  244. package/assets/esri/core/workers/chunks/e55f80b774e090a0aa04.js +0 -1
  245. package/assets/esri/core/workers/chunks/e668c7e2e61aae6ca6e0.js +0 -1
  246. package/assets/esri/core/workers/chunks/ef900614353505afb210.js +0 -1
  247. package/assets/esri/core/workers/chunks/f0299d93a95f40ea7cf7.js +0 -1
  248. package/assets/esri/core/workers/chunks/f23b95d7e51a144ad065.js +0 -1
  249. package/assets/esri/core/workers/chunks/f263e73a25fae4beffae.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../geometry.js";import e from"../../../../core/Error.js";import{px2pt as t,pt2px as r}from"../../../../core/screenUtils.js";import{f as i,d as a}from"../../../../chunks/vec4f64.js";import{create as l,empty as s,expandWithBuffer as n,intersectsClippingArea as o,expandWithAABB as h}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as c}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as p}from"./ElevationAligners.js";import{SymbolUpdateType as m,elevationModeChangeUpdateType as d,needsElevationUpdates2D as y}from"./elevationAlignmentUtils.js";import{ElevationContext as _}from"./ElevationContext.js";import u from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as g}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as M}from"./interfaces.js";import{parseCapType as C,parseLineMarkerStyle as b}from"./lineUtils.js";import{ConvertOptions as P,initFastSymbolUpdatesState as E,updateFastSymbolUpdatesState as w,getAttributeValue as L}from"../support/FastSymbolUpdates.js";import v from"../../support/debugFlags.js";import{createGeometry as x}from"../../support/engineContent/line.js";import{geometryToRenderInfo as R,geometryToRenderInfoDraped as k}from"../../support/renderInfoUtils/line.js";import{Object3D as D}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as j}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as A}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as S}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as U}from"../../webgl-engine/materials/RibbonLineMaterial.js";import G from"../../../../geometry/Extent.js";import z from"../../../../geometry/Polygon.js";const O=["polyline","polygon","extent"],V=new P({size:!0,color:!0,rotation:!1,opacity:!0});class I extends f{constructor(e,t,r,i){super(e,t,r,i)}async doLoad(){if(this._fastUpdates=E(this._context.renderer,V),!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:t(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}}_getMaterialParameters(e,t=!1){const r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);this._patternHidesLine&&!t&&(r[3]=0);const i={width:this._computeMaterialWidth(this.symbolLayer?.size),color:r,hasPolygonOffset:!0,join:this.symbolLayer.join||"miter",cap:C(this.symbolLayer.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:S(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};return this._fastUpdates?.visualVariables?{...i,...this._fastUpdates.materialParameters}:i}get _materialColor(){return this.symbolLayer.material?.color}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return null==this._lineMaterialCached&&(this._lineMaterialCached=new U(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterialCached)),this._lineMaterialCached}get _ringMaterial(){return null==this._ringMaterialCached&&(this._ringMaterialCached=new U(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterialCached)),this._ringMaterialCached}get _wireframeLineMaterial(){return null==this._wireframeLineMaterialCached&&(this._wireframeLineMaterialCached=new U({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterialCached)),this._wireframeLineMaterialCached}get _wireframeRingMaterial(){return null==this._wireframeRingMaterialCached&&(this._wireframeRingMaterialCached=new U({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterialCached)),this._wireframeRingMaterialCached}get _markerMaterial(){return null==this._markerMaterialCached&&null!=this.symbolLayer.marker&&(this._markerMaterialCached=new A({...this._getMaterialParameters(!1,!0),placement:this.symbolLayer.marker.placement,markerPrimitive:b(this.symbolLayer.marker.style)}),this._context.stage.add(this._markerMaterialCached)),this._markerMaterialCached}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterialCached=null,this._ringMaterialCached=null,this._wireframeLineMaterialCached=null,this._wireframeRingMaterialCached=null,this._markerMaterialCached=null}_getDrivenSize(e){return this._drivenProperties.size&&e.size?r(c(e.size)):1}_getDrivenColor(e){const t=i(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,O,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new _);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return M.RecreateSymbol;{const e=this._fastUpdates;if(!w(e,t,V))return M.RecreateSymbol;this._forEachMaterial((t=>t.setParameters(e.materialParameters)))}}return M.FastUpdate}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=C(t.cap.newValue??"butt"),delete t.cap);const i=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,i),e.symbolLayerStatePatches.push((()=>this._forEachMaterial((e=>e.setParameters(r)))))}layerOpacityChanged(){this._forEachMaterial(((e,t)=>this._updateMaterialLayerOpacity(e,t)))}_forEachMaterial(e){null!=this._lineMaterialCached&&e(this._lineMaterialCached),null!=this._ringMaterialCached&&e(this._ringMaterialCached),null!=this._wireframeLineMaterialCached&&e(this._wireframeLineMaterialCached),null!=this._wireframeRingMaterialCached&&e(this._wireframeRingMaterialCached),null!=this._markerMaterialCached&&e(this._markerMaterialCached,!0)}_updateMaterialLayerOpacity(e,t=!1){const r=e.parameters.color,a=this.symbolLayer?.material?.color,l=this._patternHidesLine&&!t?0:this._getCombinedOpacity(a),s=i(r[0],r[1],r[2],l);e.setParameters({color:s})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,a=d(I.elevationModeChangeTypes,r,i);if(a!==m.UPDATE)return a;const l=y(i);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>l))}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof G)return z.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,t,r){const i=e.graphic,a=this._getGeometryAsPolygonOrPolyline(i.geometry),h="polygon"===a.type?a.rings:a.paths,c=new Array,m=l(),d=R(a,this._context.elevationProvider,this._context.renderCoordsHelper,t),_="polygon"===a.type?"rings":"paths";this._logGeometryCreationWarnings(d,h,_,"LineSymbol3DLayer");for(let l=0;l<d.lines.length;l++){const t=d.lines[l],i=t.position,h=t.mapPositions;if(null!=this._context.clippingExtent&&(s(m),n(m,h),!o(m,this._context.clippingExtent)))continue;const p=this._createGeometry("polygon"===a.type?this._ringMaterial:this._lineMaterial,e,i,h,a.type,T.ELEVATED,r);c.push(p),v.LINE_WIREFRAMES&&c.push(p.instantiate({material:"polygon"===a.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),null!=this._markerMaterial&&c.push(p.instantiate({material:this._markerMaterial}))}if(0===c.length)return null;const u=new D({geometries:c,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),f=new g(this,u,c,null,null,p,t);return f.alignedSampledElevation=d.sampledElevation,f.needsElevationUpdates=y(t.mode),f}_createGeometry(e,t,r,i,a,l,s){const n=l===T.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o="polygon"===a,h=this._fastUpdates?.visualVariables.color,c=this._fastUpdates?.visualVariables.size,p=this._fastUpdates?.visualVariables.opacity,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerUid:this._context.layer.uid}),d={position:r,size:c?null:this._getDrivenSize(t.renderingInfo),color:h?null:this._getDrivenColor(t.renderingInfo),sizeFeature:c?L(c.field,t.graphic):null,colorFeature:h?L(h.field,t.graphic):null,opacityFeature:p?L(p.field,t.graphic):null};return x(e,{overlayInfo:n,removeDuplicateStartEnd:o,mapPositions:i,attributeData:d},m)}_createAsOverlay(e,t){const r=e.graphic,i=this._getGeometryAsPolygonOrPolyline(r.geometry),a="polygon"===i.type?i.rings:i.paths,c="polygon"===i.type?this._ringMaterial:this._lineMaterial;c.renderPriority=this._renderPriority;const p=v.LINE_WIREFRAMES?"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,m=this._markerMaterial;null!=p&&(p.renderPriority=this._renderPriority-.001),null!=m&&(m.renderPriority=this._renderPriority-.002);const d=new Array,y=l(),_=s(),g=k(i,this._context.overlaySR),f="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(g,a,f,"LineSymbol3DLayer");for(const l of g.lines){if(s(y),n(y,l.position),!o(y,this._context.clippingExtent))continue;h(_,y);const a=a=>{const s=this._createGeometry(a,e,l.position,void 0,i.type,T.DRAPED,r.uid),n=new j(s,{layerUid:t,graphicUid:r.uid});d.push(n)};if(null!=m){a(m);const e=this.symbolLayer.marker.placement;"begin"!==e&&"begin-end"!==e||n(y,l.position,0,1),"end"!==e&&"begin-end"!==e||n(y,l.position,l.position.length-3,1)}a(c),v.LINE_WIREFRAMES&&a(p)}return new u(this,d,_,this._context.drapeSourceRenderer)}get _patternHidesLine(){const e=this.symbolLayer.pattern;return null!=e&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=e??t(1),this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r(1):1:r(e)}_prepareMaterialPatch(e,t,r){const i=t.material;if(null==i)return void(r.changed&&r.useMaterialColor&&this._patchMaterialColor(this._getCombinedOpacityAndColor(this._materialColor),this._markerMaterialCached,e));if("collection"===i.type)return;const l="complete"===i.type?i.newValue?.color:"complete"===i.diff.color?.type?i.diff.color.newValue:null,s=this._getCombinedOpacityAndColor(l);r.useMaterialColor&&this._patchMaterialColor(a(s),this._markerMaterialCached,e),this._patternHidesLine&&(s[3]=0),this._patchMaterialColor(s,this._lineMaterialCached,e),delete t.material}_prepareMarkerPatch(e,t){const r=t.marker,i=this._markerMaterial;if(null==r||"partial"!==r.type||null==r.diff||null!=r.diff.placement||null!=r.diff.style&&"complete"!==r.diff.style.type||null!=r.diff.color&&"complete"!==r.diff.color.type||null==i)return{changed:!1,useMaterialColor:null==this._markerColor};const a=r.diff.color,l=null!=a,s=l?a.newValue:null,n=null==s&&null==this._markerColor;s&&this._patchMaterialColor(this._getCombinedOpacityAndColor(s),i,e);const o=r.diff.style?.newValue;return o&&e.symbolLayerStatePatches.push((()=>i.setParameters({markerPrimitive:b(o)}))),delete t.marker,{changed:l,useMaterialColor:n}}_patchMaterialColor(e,t,r){null!=t&&r.symbolLayerStatePatches.push((()=>t.setParameters({color:e})))}}var T;I.elevationModeChangeTypes={definedChanged:m.RECREATE,staysOnTheGround:m.NONE,onTheGroundChanged:m.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(T||(T={}));export{I as Graphics3DLineSymbolLayer};
5
+ import"../../../../geometry.js";import e from"../../../../core/Error.js";import{px2pt as t,pt2px as r}from"../../../../core/screenUtils.js";import{f as i,d as a}from"../../../../chunks/vec4f64.js";import{create as l,empty as s,expandWithBuffer as n,intersectsClippingArea as o,expandWithAABB as h}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as c}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as p}from"./ElevationAligners.js";import{SymbolUpdateType as m,elevationModeChangeUpdateType as d,needsElevationUpdates2D as y}from"./elevationAlignmentUtils.js";import _ from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as u}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as g}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as f}from"./interfaces.js";import{parseCapType as M,parseLineMarkerStyle as C}from"./lineUtils.js";import{ConvertOptions as b,initFastSymbolUpdatesState as P,updateFastSymbolUpdatesState as E,getAttributeValue as L}from"../support/FastSymbolUpdates.js";import w from"../../support/debugFlags.js";import{createGeometry as v}from"../../support/engineContent/line.js";import{geometryToRenderInfo as x,geometryToRenderInfoDraped as R}from"../../support/renderInfoUtils/line.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as D}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as j}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as A}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as S}from"../../webgl-engine/materials/RibbonLineMaterial.js";import U from"../../../../geometry/Extent.js";import G from"../../../../geometry/Polygon.js";const z=["polyline","polygon","extent"],O=new b({size:!0,color:!0,rotation:!1,opacity:!0});class V extends g{constructor(e,t,r,i){super(e,t,r,i)}async doLoad(){if(this._fastUpdates=P(this._context.renderer,O),!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:t(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}}_getMaterialParameters(e,t=!1){const r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);this._patternHidesLine&&!t&&(r[3]=0);const i={width:this._computeMaterialWidth(this.symbolLayer?.size),color:r,hasPolygonOffset:!0,join:this.symbolLayer.join||"miter",cap:M(this.symbolLayer.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:A(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};return this._fastUpdates?.visualVariables?{...i,...this._fastUpdates.materialParameters}:i}get _materialColor(){return this.symbolLayer.material?.color}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return null==this._lineMaterialCached&&(this._lineMaterialCached=new S(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterialCached)),this._lineMaterialCached}get _ringMaterial(){return null==this._ringMaterialCached&&(this._ringMaterialCached=new S(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterialCached)),this._ringMaterialCached}get _wireframeLineMaterial(){return null==this._wireframeLineMaterialCached&&(this._wireframeLineMaterialCached=new S({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterialCached)),this._wireframeLineMaterialCached}get _wireframeRingMaterial(){return null==this._wireframeRingMaterialCached&&(this._wireframeRingMaterialCached=new S({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterialCached)),this._wireframeRingMaterialCached}get _markerMaterial(){return null==this._markerMaterialCached&&null!=this.symbolLayer.marker&&(this._markerMaterialCached=new j({...this._getMaterialParameters(!1,!0),placement:this.symbolLayer.marker.placement,markerPrimitive:C(this.symbolLayer.marker.style)}),this._context.stage.add(this._markerMaterialCached)),this._markerMaterialCached}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterialCached=null,this._ringMaterialCached=null,this._wireframeLineMaterialCached=null,this._wireframeRingMaterialCached=null,this._markerMaterialCached=null}_getDrivenSize(e){return this._drivenProperties.size&&e.size?r(c(e.size)):1}_getDrivenColor(e){const t=i(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,z,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return f.RecreateSymbol;{const e=this._fastUpdates;if(!E(e,t,O))return f.RecreateSymbol;this._forEachMaterial((t=>t.setParameters(e.materialParameters)))}}return f.FastUpdate}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=M(t.cap.newValue??"butt"),delete t.cap);const i=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,i),e.symbolLayerStatePatches.push((()=>this._forEachMaterial((e=>e.setParameters(r)))))}layerOpacityChanged(){this._forEachMaterial(((e,t)=>this._updateMaterialLayerOpacity(e,t)))}_forEachMaterial(e){null!=this._lineMaterialCached&&e(this._lineMaterialCached),null!=this._ringMaterialCached&&e(this._ringMaterialCached),null!=this._wireframeLineMaterialCached&&e(this._wireframeLineMaterialCached),null!=this._wireframeRingMaterialCached&&e(this._wireframeRingMaterialCached),null!=this._markerMaterialCached&&e(this._markerMaterialCached,!0)}_updateMaterialLayerOpacity(e,t=!1){const r=e.parameters.color,a=this.symbolLayer?.material?.color,l=this._patternHidesLine&&!t?0:this._getCombinedOpacity(a),s=i(r[0],r[1],r[2],l);e.setParameters({color:s})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,a=d(V.elevationModeChangeTypes,r,i);if(a!==m.UPDATE)return a;const l=y(i);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>l))}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof U)return G.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,t,r){const i=e.graphic,a=this._getGeometryAsPolygonOrPolyline(i.geometry),h="polygon"===a.type?a.rings:a.paths,c=new Array,m=l(),d=x(a,this._context.elevationProvider,this._context.renderCoordsHelper,t),_="polygon"===a.type?"rings":"paths";this._logGeometryCreationWarnings(d,h,_,"LineSymbol3DLayer");for(let l=0;l<d.lines.length;l++){const t=d.lines[l],i=t.position,h=t.mapPositions;if(null!=this._context.clippingExtent&&(s(m),n(m,h),!o(m,this._context.clippingExtent)))continue;const p=this._createGeometry("polygon"===a.type?this._ringMaterial:this._lineMaterial,e,i,h,a.type,I.ELEVATED,r);c.push(p),w.LINE_WIREFRAMES&&c.push(p.instantiate({material:"polygon"===a.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),null!=this._markerMaterial&&c.push(p.instantiate({material:this._markerMaterial}))}if(0===c.length)return null;const g=new k({geometries:c,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),f=new u(this,g,c,null,null,p,t);return f.alignedSampledElevation=d.sampledElevation,f.needsElevationUpdates=y(t.mode),f}_createGeometry(e,t,r,i,a,l,s){const n=l===I.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o="polygon"===a,h=this._fastUpdates?.visualVariables.color,c=this._fastUpdates?.visualVariables.size,p=this._fastUpdates?.visualVariables.opacity,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerUid:this._context.layer.uid}),d={position:r,size:c?null:this._getDrivenSize(t.renderingInfo),color:h?null:this._getDrivenColor(t.renderingInfo),sizeFeature:c?L(c.field,t.graphic):null,colorFeature:h?L(h.field,t.graphic):null,opacityFeature:p?L(p.field,t.graphic):null};return v(e,{overlayInfo:n,removeDuplicateStartEnd:o,mapPositions:i,attributeData:d},m)}_createAsOverlay(e,t){const r=e.graphic,i=this._getGeometryAsPolygonOrPolyline(r.geometry),a="polygon"===i.type?i.rings:i.paths,c="polygon"===i.type?this._ringMaterial:this._lineMaterial;c.renderPriority=this._renderPriority;const p=w.LINE_WIREFRAMES?"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,m=this._markerMaterial;null!=p&&(p.renderPriority=this._renderPriority-.001),null!=m&&(m.renderPriority=this._renderPriority-.002);const d=new Array,y=l(),u=s(),g=R(i,this._context.overlaySR),f="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(g,a,f,"LineSymbol3DLayer");for(const l of g.lines){if(s(y),n(y,l.position),!o(y,this._context.clippingExtent))continue;h(u,y);const a=a=>{const s=this._createGeometry(a,e,l.position,void 0,i.type,I.DRAPED,r.uid),n=new D(s,{layerUid:t,graphicUid:r.uid});d.push(n)};if(null!=m){a(m);const e=this.symbolLayer.marker.placement;"begin"!==e&&"begin-end"!==e||n(y,l.position,0,1),"end"!==e&&"begin-end"!==e||n(y,l.position,l.position.length-3,1)}a(c),w.LINE_WIREFRAMES&&a(p)}return new _(this,d,u,this._context.drapeSourceRenderer)}get _patternHidesLine(){const e=this.symbolLayer.pattern;return null!=e&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=e??t(1),this._drivenProperties.size?this._fastUpdates?.visualVariables.size?r(1):1:r(e)}_prepareMaterialPatch(e,t,r){const i=t.material;if(null==i)return void(r.changed&&r.useMaterialColor&&this._patchMaterialColor(this._getCombinedOpacityAndColor(this._materialColor),this._markerMaterialCached,e));if("collection"===i.type)return;const l="complete"===i.type?i.newValue?.color:"complete"===i.diff.color?.type?i.diff.color.newValue:null,s=this._getCombinedOpacityAndColor(l);r.useMaterialColor&&this._patchMaterialColor(a(s),this._markerMaterialCached,e),this._patternHidesLine&&(s[3]=0),this._patchMaterialColor(s,this._lineMaterialCached,e),delete t.material}_prepareMarkerPatch(e,t){const r=t.marker,i=this._markerMaterial;if(null==r||"partial"!==r.type||null==r.diff||null!=r.diff.placement||null!=r.diff.style&&"complete"!==r.diff.style.type||null!=r.diff.color&&"complete"!==r.diff.color.type||null==i)return{changed:!1,useMaterialColor:null==this._markerColor};const a=r.diff.color,l=null!=a,s=l?a.newValue:null,n=null==s&&null==this._markerColor;s&&this._patchMaterialColor(this._getCombinedOpacityAndColor(s),i,e);const o=r.diff.style?.newValue;return o&&e.symbolLayerStatePatches.push((()=>i.setParameters({markerPrimitive:C(o)}))),delete t.marker,{changed:l,useMaterialColor:n}}_patchMaterialColor(e,t,r){null!=t&&r.symbolLayerStatePatches.push((()=>t.setParameters({color:e})))}}var I;V.elevationModeChangeTypes={definedChanged:m.RECREATE,staysOnTheGround:m.NONE,onTheGroundChanged:m.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(I||(I={}));export{V as Graphics3DLineSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as n,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,I as u,b as c}from"../../../../chunks/mat4f64.js";import{s as m,a as h,g as f,e as p,n as d,b as g,f as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as b}from"../../../../chunks/vec3f64.js";import{O as y}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as v,projectVectorToDehydratedPoint as C,projectBuffer as O,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as j,expandWithBuffer as P,intersectsClippingArea as A}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as I}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as R,getZeroIndexArray as E}from"../../../../geometry/support/Indices.js";import N from"../../../../geometry/support/MeshComponent.js";import F from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import B from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{transformNormal as L,projectNormalToPCPF as $,transformTangent as G,projectTangentToPCPF as V}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{MeshTransformUpdateAction as k}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as H}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as W}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as Z}from"./elevationAlignmentUtils.js";import{ElevationContext as J}from"./ElevationContext.js";import{Graphics3DMeshObject3DGraphicLayer as K}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Q}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as X}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ee,MeshFastUpdateProcessor as te}from"./MeshFastUpdateProcessor.js";import{createMaterial as re}from"../support/edgeUtils.js";import{parseColorMixMode as oe,encodeSymbolColor as ae}from"../support/symbolColorUtils.js";import ne from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ie,CullFaceOptions as le}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ue}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ce}from"../../webgl-engine/lib/Geometry.js";import{Object3D as me}from"../../webgl-engine/lib/Object3D.js";import{Texture as he}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as fe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as pe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as de}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ge,defaultSchematicMRRFactors as xe,defaultAdvancedMRRFactors as _e}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Te}from"../../../webgl/enums.js";const be=["mesh"];class ye extends X{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ee,this._fastUpdateProcessor=new te,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ne.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new de({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new de({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,be,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new J),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=Ie,{origin:s,transform:i}=r;switch(v(t,m(Oe,s.x,s.y,s.z??0),n,a),o){case k.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case k.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case k.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:c}=this._context,h=(e,t)=>Z(e,u,l,c,t);return e.alignedSampledElevation=z(e,l,u.spatialReference,h,c,n),e.updateTransform(n,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==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}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ne;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:u,alphaCutoff:c,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(n),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${u},ac:${c},am:${m}`,t.material instanceof F){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:u,emissiveTextureTransform:c,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(u),x=this._textureTransformUid(c),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=u,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(s),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(c),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ie.Opaque);return null!=t?t.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 he(q(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(r)&&t!==ie.Opaque,encoding:q(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(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 Te.CLAMP_TO_EDGE;case"mirror":return Te.MIRRORED_REPEAT;default:return Te.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=W(t.colorTextureTransform),r.normalTextureTransformMatrix=W(t.normalTextureTransform),r.occlusionTextureTransformMatrix=W(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=W(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=W(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=y;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=y)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||null!=a&&a.transparent||s),l=this._materialProperties(t,r,i),u=this._materialInfoCache.byUid(l.uid);if(u)return u.material;const c={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=ge({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:le.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...xe]:[l.metallic,l.roughness,_e[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?le.None:le.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,c),this._setInternalMaterialParameters(l,h);const f=new pe(h);return c.material=f,this._materialInfoCache.set(l.uid,c),this._context.stage.add(f),f}_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?ie.MaskBlend:ie.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ie.Opaque:"mask"===t.alphaMode?ie.Mask:ie.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),n=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(fe.POSITION),o=e.vertexAttributes.get(fe.NORMAL),u=e.indices.get(fe.POSITION),c=e.indices.get(fe.NORMAL),m=r.data,d=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*c[t];for(let t=0;t<3;t++)n.push(m[e+t]);for(let t=0;t<3;t++)n.push(m[e+t]+d[r+t]*a);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(m,u,t,je),this._getFaceVertices(m,u,t,Oe,we,Me),h(Oe,Oe,we),h(Oe,Oe,Me),f(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+je[e]*a);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,c=new ce(this._debugVertexNormalMaterial,[[fe.POSITION,new se(n,3,!0)]],[[fe.POSITION,s]],null,ue.Line);t.push(c),c.transformation=u;const m=new ce(this._debugFaceNormalMaterial,[[fe.POSITION,new se(i,3,!0)]],[[fe.POSITION,l]],null,ue.Line);m.transformation=u,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;ne.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,s);const l=new me({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=re(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new Q(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new K(this,l,s,null,null,z,r,c);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Y(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>Z(e,h,r,f,t);return m.alignedSampledElevation=z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=D(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return C([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){this._calculateFaceNormal(e,o,n,je);for(let e=0;e<3;e++){const r=3*o[n+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],p(je,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ve(t,o,a)}_createComponentNormalsFlat(e,t){const r=I(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=this._calculateFaceNormal(e,t,a,je);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new ve(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=this._calculateFaceNormal(e,t,n,je);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:b(),count:0},r[a]=s),h(s.normal,s.normal,o),s.count++}}const o=I(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(d(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new ve(o,a,!1)}_getFaceVertices(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,we,Me),g(we,we,Oe),g(Me,Me,Oe),x(Oe,we,Me),d(o,Oe),o}_getOrCreateComponents(e){return e.components??Ee}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Fe.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Fe.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;null!=a&&(o=L(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return $(o,n,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Fe.ECEF?r.transformBeforeProject:null;null!=a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Fe.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const n=e.vertexAttributes.position,s=null!=a?o:new Float32Array(o.length);return V(o,n,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=oe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ae(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===Fe.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Fe.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===H.Local?Fe.NONE:Fe.ECEF:Fe.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??u;if(o===Fe.NONE){v(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:c(i),needsBufferCopy:!1}}const m=n(l(),r);return s(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,n){const s=this._context.renderCoordsHelper.spatialReference,u=e.anchor;Ce[0]=u.x,Ce[1]=u.y,Ce[2]=u.z??0;const c=l();return v(e.spatialReference,Ce,c,s),i(Pe,c),S(t,t,Pe),null==a&&null==n||(r(Ae,c),o(Ae,Ae),null!=a&&U(a,a,Ae),null!=n&&U(n,n,Ae,4)),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??R(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 null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),O(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),j(Re),P(Re,o,0,a),!A(Re,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const c=[[fe.POSITION,new se(a,3,!0)],[fe.NORMAL,new se(o.normals,3,!0)]],h=[[fe.POSITION,t],[fe.NORMAL,o.indices]];null!=s&&(c.push([fe.COLOR,new se(s,4,!0)]),h.push([fe.COLOR,t])),null!=i&&(c.push([fe.SYMBOLCOLOR,new se(i,4,!0)]),h.push([fe.SYMBOLCOLOR,E(t.length)])),null!=n&&(c.push([fe.UV0,new se(n,2,!0)]),h.push([fe.UV0,t])),null!=u&&(c.push([fe.TANGENT,new se(u,4,!0)]),h.push([fe.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ce(x,c,h,null,ue.Mesh,g);_.transformation=m,f.push(_)}return p&&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,objectTransformation:c}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ve{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Ce=b(),Oe=b(),we=b(),Me=b(),je=b(),Pe=l(),Ae=a(),Ie=l(),Re=M(),Ee=[new N],Ne=new B;var Fe;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Fe||(Fe={}));export{ye as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as a}from"../../../../chunks/mat3f64.js";import{f as s,m as n,a as i}from"../../../../chunks/mat4.js";import{c as l,I as u,b as c}from"../../../../chunks/mat4f64.js";import{s as m,a as h,g as f,e as p,n as d,b as g,f as x}from"../../../../chunks/vec3.js";import{Z as _,O as T,c as b}from"../../../../chunks/vec3f64.js";import{O as y}from"../../../../chunks/vec4f64.js";import{computeTranslationToOriginAndRotation as v,projectVectorToDehydratedPoint as C,projectBuffer as O,canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{create as M,empty as P,expandWithBuffer as j,intersectsClippingArea as A}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as I}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as R,getZeroIndexArray as N}from"../../../../geometry/support/Indices.js";import E from"../../../../geometry/support/MeshComponent.js";import F from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import B from"../../../../geometry/support/MeshTextureTransform.js";import{t as S,a as U}from"../../../../chunks/vec32.js";import{transformNormal as L,projectNormalToPCPF as $,transformTangent as G,projectTangentToPCPF as V}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as D}from"../../../../layers/graphics/dehydratedFeatures.js";import{MeshTransformUpdateAction as k}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as H}from"../../../ViewingMode.js";import{isEncodedMeshTexture as q}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as W}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as Y,evaluateElevationInfoAtPoint as Z}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as J}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as K}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Q}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as X,MeshFastUpdateProcessor as ee}from"./MeshFastUpdateProcessor.js";import{createMaterial as te}from"../support/edgeUtils.js";import{parseColorMixMode as re,encodeSymbolColor as oe}from"../support/symbolColorUtils.js";import ae from"../../support/debugFlags.js";import{Attribute as se}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ne,CullFaceOptions as ie}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as le}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ue}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ce}from"../../webgl-engine/lib/Object3D.js";import{Texture as me}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as he}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as fe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as pe}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as de,defaultSchematicMRRFactors as ge,defaultAdvancedMRRFactors as xe}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as _e}from"../../../webgl/enums.js";const Te=["mesh"];class be extends Q{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new X,this._fastUpdateProcessor=new ee,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ae.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new pe({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new pe({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Te,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Y)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,s=Ae,{origin:n,transform:i}=r;switch(v(t,m(Ce,n.x,n.y,n.z??0),s,a),o){case k.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case k.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case k.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,i,this._context.localOriginFactory)}const{elevationContext:l}=e;l.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:c}=this._context,h=(e,t)=>Z(e,u,l,c,t);return e.alignedSampledElevation=z(e,l,u.spatialReference,h,c,s),e.updateTransform(s,i,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==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}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Ne;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:u,alphaCutoff:c,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${u},ac:${c},am:${m}`,t.material instanceof F){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:u,emissiveTextureTransform:c,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(u),x=this._textureTransformUid(c),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=u,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(c),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ne.Opaque);return null!=t?t.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 me(q(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!q(r)&&t!==ne.Opaque,encoding:q(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,a),this._context.stage.add(a),this._context.stage.loadImmediate(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 _e.CLAMP_TO_EDGE;case"mirror":return _e.MIRRORED_REPEAT;default:return _e.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=W(t.colorTextureTransform),r.normalTextureTransformMatrix=W(t.normalTextureTransform),r.occlusionTextureTransformMatrix=W(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=W(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=W(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=y;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=y)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||null!=a&&a.transparent||n),l=this._materialProperties(t,r,i),u=this._materialInfoCache.byUid(l.uid);if(u)return u.material;const c={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=de({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:_,diffuse:T,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ie.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...ge]:[l.metallic,l.roughness,xe[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?ie.None:ie.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,c),this._setInternalMaterialParameters(l,h);const f=new fe(h);return c.material=f,this._materialInfoCache.set(l.uid,c),this._context.stage.add(f),f}_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?ne.MaskBlend:ne.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ne.Opaque:"mask"===t.alphaMode?ne.Mask:ne.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(he.POSITION),o=e.vertexAttributes.get(he.NORMAL),u=e.indices.get(he.POSITION),c=e.indices.get(he.NORMAL),m=r.data,d=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*c[t];for(let t=0;t<3;t++)s.push(m[e+t]);for(let t=0;t<3;t++)s.push(m[e+t]+d[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(m,u,t,Me),this._getFaceVertices(m,u,t,Ce,Oe,we),h(Ce,Ce,Oe),h(Ce,Ce,we),f(Ce,Ce,1/3);for(let e=0;e<3;e++)i.push(Ce[e]);for(let e=0;e<3;e++)i.push(Ce[e]+Me[e]*a);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,c=new ue(this._debugVertexNormalMaterial,[[he.POSITION,new se(s,3,!0)]],[[he.POSITION,n]],null,le.Line);t.push(c),c.transformation=u;const m=new ue(this._debugFaceNormalMaterial,[[he.POSITION,new se(i,3,!0)]],[[he.POSITION,l]],null,le.Line);m.transformation=u,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;ae.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new ce({geometries:n,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=te(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new K(n[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new J(this,l,n,null,null,z,r,c);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Y(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>Z(e,h,r,f,t);return m.alignedSampledElevation=z(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=D(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return C([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Me);for(let e=0;e<3;e++){const r=3*o[s+e];Ce[0]=t[r],Ce[1]=t[r+1],Ce[2]=t[r+2],p(Me,Ce)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new ye(t,o,a)}_createComponentNormalsFlat(e,t){const r=I(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Me);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new ye(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Me);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=I(3*t.length),a=new Array(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 new ye(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Ce,Oe,we),g(Oe,Oe,Ce),g(we,we,Ce),x(Ce,Oe,we),d(o,Ce),o}_getOrCreateComponents(e){return e.components??Re}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Ee.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=S(new Float64Array(r.length),r,o)),t.reprojection===Ee.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=null!=o?r:new Float64Array(r.length);return O(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===Ee.ECEF?r.transformBeforeProject:null;null!=a&&(o=L(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ee.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=null!=a?o:new Float32Array(o.length);return $(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===Ee.ECEF?r.transformBeforeProject:null;null!=a&&(o=G(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ee.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=null!=a?o:new Float32Array(o.length);return V(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=re(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return oe(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:u,symbolColorBuffer:c,objectTransformation:n.reprojection===Ee.NONE&&null!=n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===Ee.NONE&&null!=n.geometryTransformation?n.geometryTransformation:l()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r=t.isRelative,o=t.isGeoreferenced?this._context.renderCoordsHelper.viewingMode===H.Local?Ee.NONE:Ee.ECEF:Ee.NONE;if(r){const{origin:r}=t,a=l(),i=e.transform?.localMatrix??u;if(o===Ee.NONE){v(e.spatialReference,r,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:o,objectTransformation:a,geometryTransformation:c(i),needsBufferCopy:!1}}const m=s(l(),r);return n(m,m,i),{reprojection:o,transformBeforeProject:m,needsBufferCopy:!0}}return{reprojection:o,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,u=e.anchor;ve[0]=u.x,ve[1]=u.y,ve[2]=u.z??0;const c=l();return v(e.spatialReference,ve,c,n),i(Pe,c),S(t,t,Pe),null==a&&null==s||(r(je,c),o(je,je),null!=a&&U(a,a,je),null!=s&&U(s,s,je,4)),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??R(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 null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),O(e.vertexAttributes.position,e.spatialReference,0,o,r,0,a)),P(Ie),j(Ie,o,0,a),!A(Ie,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const d of h){if(!this._validateFaces(e,d))return null;const t=this._getOrCreateFaces(e,d);if(0===t.length)continue;const o=this._createComponentNormals(a,l,d,t);o.didFlipNormals&&(p=!0);const c=[[he.POSITION,new se(a,3,!0)],[he.NORMAL,new se(o.normals,3,!0)]],h=[[he.POSITION,t],[he.NORMAL,o.indices]];null!=n&&(c.push([he.COLOR,new se(n,4,!0)]),h.push([he.COLOR,t])),null!=i&&(c.push([he.SYMBOLCOLOR,new se(i,4,!0)]),h.push([he.SYMBOLCOLOR,N(t.length)])),null!=s&&(c.push([he.UV0,new se(s,2,!0)]),h.push([he.UV0,t])),null!=u&&(c.push([he.TANGENT,new se(u,4,!0)]),h.push([he.TANGENT,t]));const g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,d),_=new ue(x,c,h,null,le.Mesh,g);_.transformation=m,f.push(_)}return p&&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,objectTransformation:c}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class ye{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const ve=b(),Ce=b(),Oe=b(),we=b(),Me=b(),Pe=l(),je=a(),Ae=l(),Ie=M(),Re=[new E],Ne=new B;var Ee;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Ee||(Ee={}));export{be as Graphics3DMeshFillSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{i,k as a,w as o,c as n}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{l as c,o as h,c as d,C as m,a as p,s as u}from"../../../../chunks/vec3.js";import{g as y,O as f,Z as _,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as R}from"../../../../chunks/vec4f64.js";import{projectPointToVector as x,computeTranslationToOriginAndRotation as v}from"../../../../geometry/projection.js";import{create as L,size as C,containsPoint as S,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as j}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as U}from"./ElevationAligners.js";import{needsElevationUpdates3D as O,evaluateElevationInfoAtPoint as B,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import{ElevationContext as A}from"./ElevationContext.js";import G from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as F,mixinColorAndOpacity as z,computeObjectScale as M,computeObjectRotation as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{LoadStatus as H}from"./Loadable.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as q}from"./objectResourceUtils.js";import{placePointOnGeometry as N,extendPointGraphicElevationContext as J}from"./pointUtils.js";import{isValidPrimitive as Y,primitiveLodResources as $}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as Z}from"./symbolComplexity.js";import{getResourceUrlFromSymbolStyle as K}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as Q,updateFastSymbolUpdatesState as X,ConvertOptions as ee,evaluateModelTransform as te,evaluateModelTransformScale as se}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as re}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ie}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ae}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as oe,texturesFromLodResources as ne,geometriesFromLodResources as le,geometriesFromLodLevelResources as ce}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";import{defaultSchematicMRRFactors as de}from"../../webgl-engine/materials/pbrUtils.js";class me{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class pe extends D{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}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._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(F(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Y(t.primitive)?t.primitive:j;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await K(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!this.symbolLayer.resource?.href}get lodRenderer(){return this._resources?.lodRenderer}_setMaterialTransparencyParams(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?re.None:re.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(w(t)),o=y(C(a)),n=y(T(o,i)),l=c(n),h=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:[...de],ambient:f,diffuse:f,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParams(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;m.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;m.externalColor=s}this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(ie.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(ie.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ie.OBJECTANDLAYERIDCOLOR);const _=new he(m),g=$(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=oe(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(g,p,r),x=await this._createLodRenderer(g,r);return new me(g,x,R,b,o,h,d,a,n,l,p,null)}async _createResourcesForUrl(e,t){const r={materialParamsMixin:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParamsMixin,this._fastUpdates.materialParameters),this._optionalFields.push(ie.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParamsMixin.hasInstancedColor=!0,this._optionalFields.push(ie.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ie.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParamsMixin.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParamsMixin.castShadows=!1}r.signal=t,r.usePBR=this._context.physicalBasedRenderingEnabled,r.skipHighLods=this._context.skipHighSymbolLods;const a=r.usePBR,o=await q(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=W(o.lods);h.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,f=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),_=this.needsDrivenTransparentPass,g=oe(h),b=oe(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(p);const s=t.opacity*f,r=s<1||_||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=y(C(P)),x=y(h.levels[0].pivotOffset),v=y(T(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;X(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const E=await this._createStageResources(h,a,t),j=await this._createLodRenderer(h,t);return new me(h,j,E,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=oe(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=ne(e);i.addMany(o),this._addDisposeResource((()=>i.removeMany(o))),await i.load(o,r),t(r);const n=le(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}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,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),n(s,te(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),se(e,i.materialParameters,_e)}}:null,o=new ae({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o.slots,o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=N(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new A),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?re.None:re.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,O)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==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)}applyRendererDiff(e,t){if(null==this._resources)return k.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return k.RecreateSymbol;if(!X(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return k.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return k.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=ce(e.levels[0]).reduce(((e,t)=>e+t.indices.get(ie.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+r(t.data)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+r(t)),0),i=ne(e).reduce(((e,t)=>e+(t.parameters.encoding&&"image/ktx2"===t.parameters.encoding?t.memoryEstimate:t.memoryEstimate/4)),0)+le(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...Z(this.symbol,this.symbolLayer),resourceBytes:i}}}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(x(t,ue,this._context.elevationProvider.spatialReference),null!=n&&!S(n,ue))return null;const l=this._requiresTerrainElevation(r),c=this._computeGlobalTransform(t,r,fe,ge),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ye),d=this._resources.lodRenderer.instanceData,m=d.addInstance();this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),o&&d.setFeatureAttribute(m,o),null==this._fastUpdates&&this._hasPerInstanceColor()&&d.setColor(m,z(s.color,s.opacity,255)),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&d.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const p=new G(this,m,U,r);return l&&(p.alignedSampledElevation=ge.sampledElevation),p.needsElevationUpdates=O(r.mode),J(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return B(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,v(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(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?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=M(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(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(null==this._resources)return!0;const s=t&&N(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,fe,ge),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=ge.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,fe,!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(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=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 d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===H.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ye),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParams({},i)):t=this._setMaterialTransparencyParams({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return V(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,E(e)),h(r,r);break;case"top":{const t=E(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=E(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=E(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=M(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({size:!0,color:!0,rotation:!0,opacity:!1},i,t??f,o,a,n,l)}}const ue=b(),ye=l(),fe=l(),_e=R(),ge=new I;export{pe as Graphics3DObjectSymbolLayer};
5
+ import e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{i,k as a,w as o,c as n}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{l as c,o as h,c as d,C as m,a as p,s as u}from"../../../../chunks/vec3.js";import{g as y,O as _,Z as f,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as R}from"../../../../chunks/vec4f64.js";import{projectPointToVector as x,computeTranslationToOriginAndRotation as v}from"../../../../geometry/projection.js";import{create as L,size as C,containsPoint as S,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as j}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as U}from"./ElevationAligners.js";import{needsElevationUpdates3D as O,evaluateElevationInfoAtPoint as B,SampleElevationInfo as I}from"./elevationAlignmentUtils.js";import A from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as D,mixinColorAndOpacity as F,computeObjectScale as z,computeObjectRotation as M}from"./graphicUtils.js";import{ApplyRendererDiffResult as V}from"./interfaces.js";import{LoadStatus as k}from"./Loadable.js";import{makeLodResources as H}from"./lodResourceUtils.js";import{fetch as W}from"./objectResourceUtils.js";import{placePointOnGeometry as q,extendPointGraphicElevationContext as N}from"./pointUtils.js";import{isValidPrimitive as J,primitiveLodResources as Y}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as $}from"./symbolComplexity.js";import{getResourceUrlFromSymbolStyle as Z}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as K,updateFastSymbolUpdatesState as Q,ConvertOptions as X,evaluateModelTransform as ee,evaluateModelTransformScale as te}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as se}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as re}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ae,texturesFromLodResources as oe,geometriesFromLodResources as ne,geometriesFromLodLevelResources as le}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{defaultSchematicMRRFactors as he}from"../../webgl-engine/materials/pbrUtils.js";class de{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class me extends G{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}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._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(D(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&J(t.primitive)?t.primitive:j;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Z(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!this.symbolLayer.resource?.href}get lodRenderer(){return this._resources?.lodRenderer}_setMaterialTransparencyParams(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?se.None:se.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(w(t)),o=y(C(a)),n=y(T(o,i)),l=c(n),h=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:[...he],ambient:_,diffuse:_,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParams(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;m.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;m.externalColor=s}this._fastUpdates=K(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(re.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(re.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(re.OBJECTANDLAYERIDCOLOR);const f=new ce(m),g=Y(t,f);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ae(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(g,p,r),x=await this._createLodRenderer(g,r);return new de(g,x,R,b,o,h,d,a,n,l,p,null)}async _createResourcesForUrl(e,t){const r={materialParamsMixin:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=K(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParamsMixin,this._fastUpdates.materialParameters),this._optionalFields.push(re.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParamsMixin.hasInstancedColor=!0,this._optionalFields.push(re.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(re.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParamsMixin.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParamsMixin.castShadows=!1}r.signal=t,r.usePBR=this._context.physicalBasedRenderingEnabled,r.skipHighLods=this._context.skipHighSymbolLods;const a=r.usePBR,o=await W(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=H(o.lods);h.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,_=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),f=this.needsDrivenTransparentPass,g=ae(h),b=ae(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(p);const s=t.opacity*_,r=s<1||f||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=y(C(P)),x=y(h.levels[0].pivotOffset),v=y(T(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;Q(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const E=await this._createStageResources(h,a,t),j=await this._createLodRenderer(h,t);return new de(h,j,E,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=ae(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=oe(e);i.addMany(o),this._addDisposeResource((()=>i.removeMany(o))),await i.load(o,r),t(r);const n=ne(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}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,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),n(s,ee(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),te(e,i.materialParameters,_e)}}:null,o=new ie({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o.slots,o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=q(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?se.None:se.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,O)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==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)}applyRendererDiff(e,t){if(null==this._resources)return V.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return V.RecreateSymbol;if(!Q(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return V.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return V.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=le(e.levels[0]).reduce(((e,t)=>e+t.indices.get(re.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+r(t.data)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+r(t)),0),i=oe(e).reduce(((e,t)=>e+(t.parameters.encoding&&"image/ktx2"===t.parameters.encoding?t.memoryEstimate:t.memoryEstimate/4)),0)+ne(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...$(this.symbol,this.symbolLayer),resourceBytes:i}}}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(x(t,pe,this._context.elevationProvider.spatialReference),null!=n&&!S(n,pe))return null;const l=this._requiresTerrainElevation(r),c=this._computeGlobalTransform(t,r,ye,fe),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ue),d=this._resources.lodRenderer.instanceData,m=d.addInstance();this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),o&&d.setFeatureAttribute(m,o),null==this._fastUpdates&&this._hasPerInstanceColor()&&d.setColor(m,F(s.color,s.opacity,255)),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&d.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const p=new A(this,m,U,r);return l&&(p.alignedSampledElevation=fe.sampledElevation),p.needsElevationUpdates=O(r.mode),N(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return B(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),pe[0]=e.x,pe[1]=e.y,pe[2]=r.z,v(e.spatialReference,pe,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(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?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=z(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(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(null==this._resources)return!0;const s=t&&q(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,ye,fe),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=fe.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,ye,!0),N(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(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=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 d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===k.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ue),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParams({},i)):t=this._setMaterialTransparencyParams({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return M(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,E(e)),h(r,r);break;case"top":{const t=E(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=E(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=E(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):f;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,f)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):_,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):f,o=this._context.renderCoordsHelper.unitInMeters,n=z(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new X({size:!0,color:!0,rotation:!0,opacity:!1},i,t??_,o,a,n,l)}}const pe=b(),ue=l(),ye=l(),_e=R(),fe=new I;export{me 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.28/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Error.js";import{w as t}from"../../../../chunks/mat4.js";import{I as i,c as s}from"../../../../chunks/mat4f64.js";import{s as r,a}from"../../../../chunks/vec2.js";import{f as o,b as n}from"../../../../chunks/vec2f64.js";import{s as l}from"../../../../chunks/vec3.js";import{g as h,c}from"../../../../chunks/vec3f64.js";import{projectBuffer as p}from"../../../../geometry/projection.js";import{create as m,empty as d,expandWithBuffer as f,intersectsClippingArea as u}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as y,doubleArrayFrom as b}from"../../../../geometry/support/DoubleArray.js";import{needsElevationUpdates3D as g,evaluateElevationAlignmentAtPoint as _,SampleElevationInfo as v}from"./elevationAlignmentUtils.js";import{ElevationContext as w}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as x}from"./Graphics3DObject3DGraphicLayer.js";import{PATH_NUM_ROUND_JOIN_SUBDIVISIONS as P,PATH_NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS as j}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as S}from"./Graphics3DSymbolLayer.js";import{isValidSize as D}from"./graphicUtils.js";import{ApplyRendererDiffResult as C}from"./interfaces.js";import{ConvertOptions as L,initFastSymbolUpdatesState as V,updateFastSymbolUpdatesState as U,getAttributeValue as E}from"../support/FastSymbolUpdates.js";import{SamplePosition as k}from"../../support/ElevationProvider.js";import{NormalType as R}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{CullFaceOptions as A}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as z}from"../../webgl-engine/lib/Object3D.js";import{Path as G}from"../../webgl-engine/lib/Path.js";import{PathBuilder as I}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as B,TriangulationCapBuilder as O,NoCapBuilder as q}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as F,MiterExtruder as H}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as M,PathGeometry as W,isPathGeometry as N}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as T,StaticPathGeometry as Z}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as J}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as K,circleProfiles as Q}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as X}from"../../webgl-engine/lib/PathVertex.js";import{DefaultMaterial as Y}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as $}from"../../webgl-engine/materials/PathMaterial.js";const ee=["polyline"];class te extends S{constructor(e,t,i,s){super(e,t,i,s),this._intrinsicSize=o(1,1),this._upVectorAlignment=M.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const t=null!=this.symbolLayer.width?this.symbolLayer.width:this.symbolLayer.height,i=null!=this.symbolLayer.height?this.symbolLayer.height:t;this._vvConvertOptions=new L({size:!0,color:!0,rotation:!1,opacity:!0},[1,1,1],[t,1,i],this._context.renderCoordsHelper.unitInMeters),this._fastUpdates=this._context.renderer?.visualVariables?.length>0?V(this._context.renderer,this._vvConvertOptions):null;const s=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?M.World:M.Path;const o=this.symbolLayer.profile||"circle";switch(o){default:case"circle":this._profile=Q[s];break;case"quad":this._profile=K[s]}switch(this.symbolLayer.join){case"round":this._extruder=new H(0,P);break;case"bevel":this._extruder=new H(0,1);break;case"miter":this._extruder=new H(.8*Math.PI,1);break;default:this._extruder=new F}const l=this.symbolLayer.cap||"butt";switch(l){case"none":this._startCap=new q,this._endCap=new q;break;case"butt":default:this._startCap=new O(this._profile,0),this._endCap=new O(this._profile,0,!0);break;case"square":this._startCap=new O(this._profile,-.5),this._endCap=new O(this._profile,.5,!0);break;case"round":{const e="quad"===o;this._startCap=new B({profile:this._profile,flip:!1,breakNormals:e,subdivisions:j}),this._endCap=new B({profile:this._profile,flip:!0,breakNormals:e,subdivisions:j});break}}const c=this.symbolLayer?.material?.color,p=this._getCombinedOpacityAndColor(c),m=h(p),d=p[3],f=d<1||this.needsDrivenTransparentPass,u={diffuse:m,ambient:m,opacity:d,transparent:f,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:f||"none"===l?A.None:A.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(r(this._intrinsicSize,t,i),!D(this._intrinsicSize[0])||!D(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates&&this._fastUpdates.visualVariables.size||a(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates){const e={...u,...this._fastUpdates.materialParameters,size:n(this._intrinsicSize)};this._material=new $(e)}else u.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,u.normalType=R.Compressed,this._material=new Y(u);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,ee,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t,new w),s=e.renderingInfo;return this._createAs3DShape(t,s,i,t.uid)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e),i=t<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:t,transparent:i})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,g)}slicePlaneEnabledChanged(){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return C.RecreateSymbol;if(!U(this._fastUpdates,t,this._vvConvertOptions))return C.RecreateSymbol;this._material.setParameters(this._fastUpdates.materialParameters)}return C.FastUpdate}_getVertexData(e){let t=0;const i=e.paths,s=[],r=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const c of i)t+=c.length;const n=y(3*t);let l,h=0;for(const c of i){s.push({offset:h,numVertices:c.length});for(const t of c)n[h++]=t[0],n[h++]=t[1],n[h++]=e.hasZ?t[2]:0}return null==a||r.equals(a)||p(n,r,0,n,a,0,t)?(null==a||a.equals(o)?l=b(n):(l=y(3*t),p(n,a,0,l,o,0,t)),{pathVertexDataInfos:s,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,r,a,o){const n=e.geometry,h=this._getVertexData(n);if(null==h)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===h.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const c=new Array,p=n.spatialReference,y=m(),b=this._context.renderCoordsHelper,v=new k(h.vertexDataES);for(const m of h.pathVertexDataInfos){const n=m.numVertices;if(n<2)continue;const g=m.offset;if(null!=this._context.clippingExtent&&(d(y),f(y,h.vertexDataES,g,n),!u(y,this._context.clippingExtent)))continue;const w=new Array,x=g+3*n;for(let e=g;e<x;e+=3){v.offset=e;const t=_(v,this._context.elevationProvider,a,b);l(oe,h.vertexDataRS[e],h.vertexDataRS[e+1],h.vertexDataRS[e+2]),b.setAltitude(oe,t),h.vertexDataRS[e]=oe[0],h.vertexDataRS[e+1]=oe[1],h.vertexDataRS[e+2]=oe[2],w.push(X(this._upVectorAlignment))}const P=new G(w,h.vertexDataES,h.vertexDataRS,g);ie(P,this._upVectorAlignment,this._context.renderCoordsHelper);const j=new I(P,this._profile,this._extruder,this._startCap,this._endCap);let S=null;if(this._fastUpdates){const t=this._fastUpdates.visualVariables,i=E(t.size?.field,e)??0,s=E(t.color?.field,e)??0,r=E(t.opacity?.field,e)??0;S=new T(j,i,s,r)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];if(this._drivenProperties.size){const t=r.size;e[0]*=se(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=se(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}let t;this._drivenProperties.color&&(t=r.color),this._drivenProperties.opacity&&null!=r.opacity&&(t=t?[t[0],t[1],t[2],r.opacity]:[1,1,1,r.opacity]);const i=new Z(j);i.bake(e),t&&i.bakeVertexColors(t),S=i}const{vertexAttributes:D,indices:C}=S.createGeometryData(),L=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid}),V=new W(this._material,D,C,S,p,this._stencilWidth,L);V.transformation=t(s(),i,j.path.origin),c.push(V)}if(0===c.length)return null;const w=new z({geometries:c,layerUid:this._context.layer.uid,graphicUid:o}),P=new x(this,w,c,null,null,((e,t,i,s,r)=>ae(e,t,s,r,this._upVectorAlignment)),a);return P.alignedSampledElevation=0,P.needsElevationUpdates=g(a.mode),P}}function ie(e,t,i){const{origin:s,positions:r}=e;let a=e.offset;switch(t){default:case M.World:for(const t of e.vertices)oe[0]=r[a++]+s[0],oe[1]=r[a++]+s[1],oe[2]=r[a++]+s[2],i.worldUpAtPosition(oe,oe),t.setFrameFromUpVector(oe);break;case M.Path:oe[0]=r[a]+s[0],oe[1]=r[a+1]+s[1],oe[2]=r[a+2]+s[2],i.worldUpAtPosition(oe,oe),J(e,oe)}}function se(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function re(e,t,i,s){let r=0;const{origin:a,vertices:o,positions:n,positionsES:h}=e,c=e.offset+3*o.length;for(let p=e.offset;p<c;p+=3)l(oe,h[p],h[p+1],h[p+2]),i(oe,ne),r+=ne.sampledElevation,oe[0]=n[p]+a[0],oe[1]=n[p+1]+a[1],oe[2]=n[p+2]+a[2],s.setAltitude(oe,ne.z),n[p]=oe[0]-a[0],n[p+1]=oe[1]-a[1],n[p+2]=oe[2]-a[2];return e.updatePathVertexInformation(),r/o.length}function ae(e,t,i,s,r){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!N(l))continue;const e=l.path,o=e.builder.path;n+=re(o,t,i,s),r!==M.World&&ie(o,r,s),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttrsUpdated(l)}return n/o.length}const oe=c(),ne=new v;export{te as Graphics3DPathSymbolLayer};
5
+ import"../../../../core/has.js";import e from"../../../../core/Error.js";import{w as t}from"../../../../chunks/mat4.js";import{I as i,c as s}from"../../../../chunks/mat4f64.js";import{s as r,a}from"../../../../chunks/vec2.js";import{f as o,b as n}from"../../../../chunks/vec2f64.js";import{s as l}from"../../../../chunks/vec3.js";import{g as h,c}from"../../../../chunks/vec3f64.js";import{projectBuffer as p}from"../../../../geometry/projection.js";import{create as m,empty as d,expandWithBuffer as f,intersectsClippingArea as u}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as y,doubleArrayFrom as b}from"../../../../geometry/support/DoubleArray.js";import{needsElevationUpdates3D as g,evaluateElevationAlignmentAtPoint as _,SampleElevationInfo as v}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as w}from"./Graphics3DObject3DGraphicLayer.js";import{PATH_NUM_ROUND_JOIN_SUBDIVISIONS as x,PATH_NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS as P}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{isValidSize as S}from"./graphicUtils.js";import{ApplyRendererDiffResult as D}from"./interfaces.js";import{ConvertOptions as C,initFastSymbolUpdatesState as L,updateFastSymbolUpdatesState as V,getAttributeValue as U}from"../support/FastSymbolUpdates.js";import{SamplePosition as k}from"../../support/ElevationProvider.js";import{NormalType as E}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{CullFaceOptions as R}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as A}from"../../webgl-engine/lib/Object3D.js";import{Path as z}from"../../webgl-engine/lib/Path.js";import{PathBuilder as G}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as I,TriangulationCapBuilder as B,NoCapBuilder as O}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as q,MiterExtruder as F}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as H,PathGeometry as M,isPathGeometry as W}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as N,StaticPathGeometry as T}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as Z}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as J,circleProfiles as K}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as Q}from"../../webgl-engine/lib/PathVertex.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 j{constructor(e,t,i,s){super(e,t,i,s),this._intrinsicSize=o(1,1),this._upVectorAlignment=H.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const t=null!=this.symbolLayer.width?this.symbolLayer.width:this.symbolLayer.height,i=null!=this.symbolLayer.height?this.symbolLayer.height:t;this._vvConvertOptions=new C({size:!0,color:!0,rotation:!1,opacity:!0},[1,1,1],[t,1,i],this._context.renderCoordsHelper.unitInMeters),this._fastUpdates=this._context.renderer?.visualVariables?.length>0?L(this._context.renderer,this._vvConvertOptions):null;const s=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?H.World:H.Path;const o=this.symbolLayer.profile||"circle";switch(o){default:case"circle":this._profile=K[s];break;case"quad":this._profile=J[s]}switch(this.symbolLayer.join){case"round":this._extruder=new F(0,x);break;case"bevel":this._extruder=new F(0,1);break;case"miter":this._extruder=new F(.8*Math.PI,1);break;default:this._extruder=new q}const l=this.symbolLayer.cap||"butt";switch(l){case"none":this._startCap=new O,this._endCap=new O;break;case"butt":default:this._startCap=new B(this._profile,0),this._endCap=new B(this._profile,0,!0);break;case"square":this._startCap=new B(this._profile,-.5),this._endCap=new B(this._profile,.5,!0);break;case"round":{const e="quad"===o;this._startCap=new I({profile:this._profile,flip:!1,breakNormals:e,subdivisions:P}),this._endCap=new I({profile:this._profile,flip:!0,breakNormals:e,subdivisions:P});break}}const c=this.symbolLayer?.material?.color,p=this._getCombinedOpacityAndColor(c),m=h(p),d=p[3],f=d<1||this.needsDrivenTransparentPass,u={diffuse:m,ambient:m,opacity:d,transparent:f,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:f||"none"===l?R.None:R.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(r(this._intrinsicSize,t,i),!S(this._intrinsicSize[0])||!S(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates&&this._fastUpdates.visualVariables.size||a(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates){const e={...u,...this._fastUpdates.materialParameters,size:n(this._intrinsicSize)};this._material=new Y(e)}else u.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,u.normalType=E.Compressed,this._material=new X(u);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,$,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t),s=e.renderingInfo;return this._createAs3DShape(t,s,i,t.uid)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e),i=t<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:t,transparent:i})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,g)}slicePlaneEnabledChanged(){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return D.RecreateSymbol;if(!V(this._fastUpdates,t,this._vvConvertOptions))return D.RecreateSymbol;this._material.setParameters(this._fastUpdates.materialParameters)}return D.FastUpdate}_getVertexData(e){let t=0;const i=e.paths,s=[],r=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const c of i)t+=c.length;const n=y(3*t);let l,h=0;for(const c of i){s.push({offset:h,numVertices:c.length});for(const t of c)n[h++]=t[0],n[h++]=t[1],n[h++]=e.hasZ?t[2]:0}return null==a||r.equals(a)||p(n,r,0,n,a,0,t)?(null==a||a.equals(o)?l=b(n):(l=y(3*t),p(n,a,0,l,o,0,t)),{pathVertexDataInfos:s,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,r,a,o){const n=e.geometry,h=this._getVertexData(n);if(null==h)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===h.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const c=new Array,p=n.spatialReference,y=m(),b=this._context.renderCoordsHelper,v=new k(h.vertexDataES);for(const m of h.pathVertexDataInfos){const n=m.numVertices;if(n<2)continue;const g=m.offset;if(null!=this._context.clippingExtent&&(d(y),f(y,h.vertexDataES,g,n),!u(y,this._context.clippingExtent)))continue;const w=new Array,x=g+3*n;for(let e=g;e<x;e+=3){v.offset=e;const t=_(v,this._context.elevationProvider,a,b);l(ae,h.vertexDataRS[e],h.vertexDataRS[e+1],h.vertexDataRS[e+2]),b.setAltitude(ae,t),h.vertexDataRS[e]=ae[0],h.vertexDataRS[e+1]=ae[1],h.vertexDataRS[e+2]=ae[2],w.push(Q(this._upVectorAlignment))}const P=new z(w,h.vertexDataES,h.vertexDataRS,g);te(P,this._upVectorAlignment,this._context.renderCoordsHelper);const j=new G(P,this._profile,this._extruder,this._startCap,this._endCap);let S=null;if(this._fastUpdates){const t=this._fastUpdates.visualVariables,i=U(t.size?.field,e)??0,s=U(t.color?.field,e)??0,r=U(t.opacity?.field,e)??0;S=new N(j,i,s,r)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];if(this._drivenProperties.size){const t=r.size;e[0]*=ie(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=ie(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}let t;this._drivenProperties.color&&(t=r.color),this._drivenProperties.opacity&&null!=r.opacity&&(t=t?[t[0],t[1],t[2],r.opacity]:[1,1,1,r.opacity]);const i=new T(j);i.bake(e),t&&i.bakeVertexColors(t),S=i}const{vertexAttributes:D,indices:C}=S.createGeometryData(),L=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid}),V=new M(this._material,D,C,S,p,this._stencilWidth,L);V.transformation=t(s(),i,j.path.origin),c.push(V)}if(0===c.length)return null;const x=new A({geometries:c,layerUid:this._context.layer.uid,graphicUid:o}),P=new w(this,x,c,null,null,((e,t,i,s,r)=>re(e,t,s,r,this._upVectorAlignment)),a);return P.alignedSampledElevation=0,P.needsElevationUpdates=g(a.mode),P}}function te(e,t,i){const{origin:s,positions:r}=e;let a=e.offset;switch(t){default:case H.World:for(const t of e.vertices)ae[0]=r[a++]+s[0],ae[1]=r[a++]+s[1],ae[2]=r[a++]+s[2],i.worldUpAtPosition(ae,ae),t.setFrameFromUpVector(ae);break;case H.Path:ae[0]=r[a]+s[0],ae[1]=r[a+1]+s[1],ae[2]=r[a+2]+s[2],i.worldUpAtPosition(ae,ae),Z(e,ae)}}function ie(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function se(e,t,i,s){let r=0;const{origin:a,vertices:o,positions:n,positionsES:h}=e,c=e.offset+3*o.length;for(let p=e.offset;p<c;p+=3)l(ae,h[p],h[p+1],h[p+2]),i(ae,oe),r+=oe.sampledElevation,ae[0]=n[p]+a[0],ae[1]=n[p+1]+a[1],ae[2]=n[p+2]+a[2],s.setAltitude(ae,oe.z),n[p]=ae[0]-a[0],n[p+1]=ae[1]-a[1],n[p+2]=ae[2]-a[2];return e.updatePathVertexInformation(),r/o.length}function re(e,t,i,s,r){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!W(l))continue;const e=l.path,o=e.builder.path;n+=se(o,t,i,s),r!==H.World&&te(o,r,s),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttrsUpdated(l)}return n/o.length}const ae=c(),oe=new v;export{ee as Graphics3DPathSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{e as i}from"../../../../chunks/earcut.js";import{create as r,empty as o,expandWithBuffer as n,intersectsClippingArea as s,expandWithAABB as a}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as l,doubleSubArray as c}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as h,floatSubArray as p}from"../../../../geometry/support/FloatArray.js";import{SymbolUpdateType as u,elevationModeChangeUpdateType as d,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import{ElevationContext as _}from"./ElevationContext.js";import y from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as g}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as b}from"./graphicUtils.js";import{ApplyRendererDiffResult as x}from"./interfaces.js";import{parseCapType as v}from"./lineUtils.js";import{geometryAsPolygon as O,createIndices3D as D,createColorGeometry as C,PolygonCreationDataBase as S}from"./polygonUtils.js";import{ConvertOptions as j,initFastSymbolUpdatesState as A,updateFastSymbolUpdatesState as M,getAttributeValue as P}from"../support/FastSymbolUpdates.js";import{createMaterial as U,uvElevationAligner as E}from"../support/patternUtils.js";import{createMapSpaceUVCoords as L,createMapSpaceUVCoordsDraped as G}from"../support/uvUtils.js";import{createGeometry as w}from"../../support/engineContent/line.js";import{geometryToRenderInfo as R,geometryToRenderInfoDraped as I}from"../../support/renderInfoUtils/polygon.js";import{Object3D as V}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as F}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as B}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as T}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as z}from"../../webgl-engine/materials/RibbonLineMaterial.js";const H=["polyline","polygon","extent"],W=new j({size:!1,color:!0,rotation:!1,opacity:!1});class N extends f{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){this._fastUpdates=A(this._context.renderer,W)}_ensureMaterials(){this._ensureFillMaterial(),this._ensureOutlineMaterial()}_ensureFillMaterial(){if(null!=this._material)return;const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacityAndColor(e);this._material=U(this.symbolLayer,{color:t,transparent:t[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,hasVertexColors:!0,writeLinearDepth:!0,draped:this.draped,hasSlicePlane:this._context.slicePlaneEnabled,...this._fastUpdates?.materialParameters}),this._needsUV=this._material instanceof T,this._context.stage.add(this._material)}_ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(this._outlineMaterial||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=B(e.pattern);return new z({width:t,color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleScaleWithLineWidth:!0,cap:v(e.patternCap||"butt")})};this._outlineMaterial=i(t(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return null!=e&&null!=e.size&&e.size>0&&null!=e.color&&(null==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,H,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new _);return this.ensureDrapedStatus("on-the-ground"===r.mode),this._ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return x.RecreateSymbol;if(!M(this._fastUpdates,t,W))return x.RecreateSymbol;this._material&&this._material.setParameters(this._fastUpdates.materialParameters)}return x.FastUpdate}layerOpacityChanged(){if(null!=this._material){const e=this._material.parameters.color,t=this.symbolLayer?.material?.color,i=this._getCombinedOpacity(t);this._material.setParameters({color:[e[0],e[1],e[2],i],transparent:i<1||this.needsDrivenTransparentPass})}if(null!=this._outlineMaterial){const e=this._outlineMaterial.parameters.color;this._outlineMaterial.setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,o=d(N.elevationModeChangeTypes,i,r);if(o!==u.UPDATE)return o;const n=m(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>n))}slicePlaneEnabledChanged(){if(this._material&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._outlineMaterial){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,i){const r=O(e.geometry);if(!r)return null;const o=R(r,this._context.elevationProvider,this._context.renderCoordsHelper,i),n=new q(o,t,this._context.layer.uid,e.uid),s=n.renderData.position.length/3;if(this._needsUV&&(n.uvMapSpace=h(4*s,!0),n.boundingRect=l(9*s,!0),L(n.uvMapSpace,n.boundingRect,n.renderData.position,this._context.renderCoordsHelper)),n.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAs3DShapeFill(e,n),this._hasOutline&&this._createAs3DShapeOutline(n),this._logGeometryCreationWarnings(n.renderData,r.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length)return null;const a=new V({geometries:n.outGeometries,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:e.uid}),c=new g(this,a,n.outGeometries,null,null,E,i);return c.alignedSampledElevation=n.renderData.sampledElevation,c.needsElevationUpdates=m(i.mode),c}_createAs3DShapeFill(e,t){const i=t.renderData.polygons;for(const{position:r,mapPositions:a,holeIndices:l,index:h,count:u}of i){if(null!=this._context.clippingExtent&&(o(k),n(k,a),!s(k,this._context.clippingExtent)))continue;const i=D(a,l,this._context.elevationProvider.spatialReference);if(0===i.length)continue;const d=this._fastUpdates?.visualVariables.color,m=C({material:this._material,indices:i,mapPositions:a,attributeData:{position:r,color:d?null:t.color,colorFeature:d?P(d.field,e):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*h,4*u):null,boundingRect:this._needsUV?c(t.boundingRect,9*h,9*u):null,objectAndLayerIdColor:t.objectAndLayerIdColor}});t.outGeometries.push(m)}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{mapPositions:r,position:a}=t[i];if(null!=this._context.clippingExtent&&(o(k),n(k,r),!s(k,this._context.clippingExtent)))continue;const l=w(this._outlineMaterial,{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:r,attributeData:{position:a}},e.objectAndLayerIdColor);e.outGeometries.push(l)}}_createAsOverlay(e,t){const i=O(e.geometry);if(null==i)return null;this._material.renderPriority=this._renderPriority+this._renderPriorityStep/2,null!=this._outlineMaterial&&(this._outlineMaterial.renderPriority=this._renderPriority);const r=I(i,this._context.overlaySR),n=new J(r,t,this._context.layer.uid,e.uid),s=n.renderData.position.length/3;return this._needsUV&&(n.uvMapSpace=h(4*s,!0),G(n.uvMapSpace,n.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),n.outBoundingBox=o(),n.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAsOverlayFill(e,n),this._hasOutline&&this._createAsOverlayOutline(n),this._logGeometryCreationWarnings(n.renderData,i.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length?null:new y(this,n.outGeometries,n.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){const r=t.renderData.polygons;for(const{position:l,holeIndices:c,index:h,count:u}of r){const r=o(k);if(n(r,l),!s(r,this._context.clippingExtent))continue;const d=i(l,c,3);if(0===d.length)continue;a(t.outBoundingBox,r);const m=this._fastUpdates?.visualVariables.color,_=C({material:this._material,indices:d,attributeData:{position:l,color:m?null:t.color,colorFeature:m?P(m.field,e):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*h,4*u):null,objectAndLayerIdColor:t.objectAndLayerIdColor}});t.outGeometries.push(new F(_,t))}}_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(o(k),n(k,r),!s(k,this._context.clippingExtent))continue;a(e.outBoundingBox,k);const l=w(this._outlineMaterial,{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:r}},e.objectAndLayerIdColor);e.outGeometries.push(new F(l,e))}}_getOutlineOpacity(){const e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(null!=e?e.a:0)}_getOutlineColor(){const t=this.symbolLayer?.outline?.color,i=this._getOutlineOpacity();return b(null!=t?e.toUnitRGB(t):null,i)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}N.elevationModeChangeTypes={definedChanged:u.RECREATE,staysOnTheGround:u.NONE,onTheGroundChanged:u.RECREATE};const k=r();class q extends S{constructor(e,t,i,r){super(e,i,r),this.color=t}}class J extends S{constructor(e,t,i,r){super(e,i,r),this.color=t}}export{N as Graphics3DPolygonFillSymbolLayer};
5
+ import e from"../../../../Color.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{e as i}from"../../../../chunks/earcut.js";import{create as r,empty as n,expandWithBuffer as o,intersectsClippingArea as s,expandWithAABB as a}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as l,doubleSubArray as c}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as h,floatSubArray as p}from"../../../../geometry/support/FloatArray.js";import{SymbolUpdateType as u,elevationModeChangeUpdateType as d,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import _ from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as y}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as g}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as f}from"./graphicUtils.js";import{ApplyRendererDiffResult as b}from"./interfaces.js";import{parseCapType as x}from"./lineUtils.js";import{geometryAsPolygon as v,createIndices3D as O,createColorGeometry as D,PolygonCreationDataBase as C}from"./polygonUtils.js";import{ConvertOptions as S,initFastSymbolUpdatesState as j,updateFastSymbolUpdatesState as A,getAttributeValue as M}from"../support/FastSymbolUpdates.js";import{createMaterial as P,uvElevationAligner as U}from"../support/patternUtils.js";import{createMapSpaceUVCoords as E,createMapSpaceUVCoordsDraped as L}from"../support/uvUtils.js";import{createGeometry as G}from"../../support/engineContent/line.js";import{geometryToRenderInfo as w,geometryToRenderInfoDraped as R}from"../../support/renderInfoUtils/polygon.js";import{Object3D as I}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as V}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as F}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as B}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as T}from"../../webgl-engine/materials/RibbonLineMaterial.js";const z=["polyline","polygon","extent"],H=new S({size:!1,color:!0,rotation:!1,opacity:!1});class W extends g{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){this._fastUpdates=j(this._context.renderer,H)}_ensureMaterials(){this._ensureFillMaterial(),this._ensureOutlineMaterial()}_ensureFillMaterial(){if(null!=this._material)return;const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacityAndColor(e);this._material=P(this.symbolLayer,{color:t,transparent:t[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,hasVertexColors:!0,writeLinearDepth:!0,draped:this.draped,hasSlicePlane:this._context.slicePlaneEnabled,...this._fastUpdates?.materialParameters}),this._needsUV=this._material instanceof B,this._context.stage.add(this._material)}_ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(this._outlineMaterial||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=F(e.pattern);return new T({width:t,color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleScaleWithLineWidth:!0,cap:x(e.patternCap||"butt")})};this._outlineMaterial=i(t(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return null!=e&&null!=e.size&&e.size>0&&null!=e.color&&(null==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,z,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this._ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return b.RecreateSymbol;if(!A(this._fastUpdates,t,H))return b.RecreateSymbol;this._material&&this._material.setParameters(this._fastUpdates.materialParameters)}return b.FastUpdate}layerOpacityChanged(){if(null!=this._material){const e=this._material.parameters.color,t=this.symbolLayer?.material?.color,i=this._getCombinedOpacity(t);this._material.setParameters({color:[e[0],e[1],e[2],i],transparent:i<1||this.needsDrivenTransparentPass})}if(null!=this._outlineMaterial){const e=this._outlineMaterial.parameters.color;this._outlineMaterial.setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,n=d(W.elevationModeChangeTypes,i,r);if(n!==u.UPDATE)return n;const o=m(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>o))}slicePlaneEnabledChanged(){if(this._material&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._outlineMaterial){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,i){const r=v(e.geometry);if(!r)return null;const n=w(r,this._context.elevationProvider,this._context.renderCoordsHelper,i),o=new k(n,t,this._context.layer.uid,e.uid),s=o.renderData.position.length/3;if(this._needsUV&&(o.uvMapSpace=h(4*s,!0),o.boundingRect=l(9*s,!0),E(o.uvMapSpace,o.boundingRect,o.renderData.position,this._context.renderCoordsHelper)),o.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(o),this._createAs3DShapeFill(e,o),this._hasOutline&&this._createAs3DShapeOutline(o),this._logGeometryCreationWarnings(o.renderData,r.rings,"rings","FillSymbol3DLayer"),0===o.outGeometries.length)return null;const a=new I({geometries:o.outGeometries,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:e.uid}),c=new y(this,a,o.outGeometries,null,null,U,i);return c.alignedSampledElevation=o.renderData.sampledElevation,c.needsElevationUpdates=m(i.mode),c}_createAs3DShapeFill(e,t){const i=t.renderData.polygons;for(const{position:r,mapPositions:a,holeIndices:l,index:h,count:u}of i){if(null!=this._context.clippingExtent&&(n(N),o(N,a),!s(N,this._context.clippingExtent)))continue;const i=O(a,l,this._context.elevationProvider.spatialReference);if(0===i.length)continue;const d=this._fastUpdates?.visualVariables.color,m=D({material:this._material,indices:i,mapPositions:a,attributeData:{position:r,color:d?null:t.color,colorFeature:d?M(d.field,e):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*h,4*u):null,boundingRect:this._needsUV?c(t.boundingRect,9*h,9*u):null,objectAndLayerIdColor:t.objectAndLayerIdColor}});t.outGeometries.push(m)}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{mapPositions:r,position:a}=t[i];if(null!=this._context.clippingExtent&&(n(N),o(N,r),!s(N,this._context.clippingExtent)))continue;const l=G(this._outlineMaterial,{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:r,attributeData:{position:a}},e.objectAndLayerIdColor);e.outGeometries.push(l)}}_createAsOverlay(e,t){const i=v(e.geometry);if(null==i)return null;this._material.renderPriority=this._renderPriority+this._renderPriorityStep/2,null!=this._outlineMaterial&&(this._outlineMaterial.renderPriority=this._renderPriority);const r=R(i,this._context.overlaySR),o=new q(r,t,this._context.layer.uid,e.uid),s=o.renderData.position.length/3;return this._needsUV&&(o.uvMapSpace=h(4*s,!0),L(o.uvMapSpace,o.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),o.outBoundingBox=n(),o.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(o),this._createAsOverlayFill(e,o),this._hasOutline&&this._createAsOverlayOutline(o),this._logGeometryCreationWarnings(o.renderData,i.rings,"rings","FillSymbol3DLayer"),0===o.outGeometries.length?null:new _(this,o.outGeometries,o.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){const r=t.renderData.polygons;for(const{position:l,holeIndices:c,index:h,count:u}of r){const r=n(N);if(o(r,l),!s(r,this._context.clippingExtent))continue;const d=i(l,c,3);if(0===d.length)continue;a(t.outBoundingBox,r);const m=this._fastUpdates?.visualVariables.color,_=D({material:this._material,indices:d,attributeData:{position:l,color:m?null:t.color,colorFeature:m?M(m.field,e):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*h,4*u):null,objectAndLayerIdColor:t.objectAndLayerIdColor}});t.outGeometries.push(new V(_,t))}}_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(n(N),o(N,r),!s(N,this._context.clippingExtent))continue;a(e.outBoundingBox,N);const l=G(this._outlineMaterial,{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:r}},e.objectAndLayerIdColor);e.outGeometries.push(new V(l,e))}}_getOutlineOpacity(){const e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(null!=e?e.a:0)}_getOutlineColor(){const t=this.symbolLayer?.outline?.color,i=this._getOutlineOpacity();return f(null!=t?e.toUnitRGB(t):null,i)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}W.elevationModeChangeTypes={definedChanged:u.RECREATE,staysOnTheGround:u.NONE,onTheGroundChanged:u.RECREATE};const N=r();class k extends C{constructor(e,t,i,r){super(e,i,r),this.color=t}}class q extends C{constructor(e,t,i,r){super(e,i,r),this.color=t}}export{W as Graphics3DPolygonFillSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import t from"../../../../core/Logger.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{WatchUpdatingTracking as a}from"../../../../core/support/WatchUpdatingTracking.js";import{projectBoundingRect as l}from"../../../../geometry/projection.js";import{create as n}from"../../../../geometry/support/aaBoundingRect.js";import{VisibilityGroup as c,VisibilityFlag as o}from"./enums.js";import{scaleBoundsPredicate as h}from"../../../support/layerViewUtils.js";import{TaskPriority as p,Task as d}from"../../../support/Scheduler.js";const u=t.getLogger("esri.views.3d.layers.graphics.Graphics3DScaleVisibility");let y=class extends i{constructor(e){super(e),this._scaleRangeActive=!1,this._layerScaleRangeVisibilityQuery=!1,this._extent=null,this._updatingHandles=new a,this.graphicsCoreOwner=null,this.layer=null,this.queryGraphicUIDsInExtent=null,this.graphicsCore=null,this.basemapTerrain=null,this.layerScaleEnabled=!0,this.suspended=!1,this._dirty=!0}initialize(){this.updateScaleRangeActive();const e=this.graphicsCoreOwner.view.resourceController.scheduler;this.addHandles(e.registerTask(p.SCALE_VISIBILITY,this)),this._updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this.layerMinMaxScaleChangeHandler()))}destroy(){this._updatingHandles.destroy(),this.removeHandles(),this._dirty=!1,this._extent=null,this.graphicsCoreOwner=null,this.layer=null,this.queryGraphicUIDsInExtent=null,this.graphicsCore=null,this.basemapTerrain=null}get updating(){return this._dirty||this._updatingHandles.updating}_setDirty(){this._dirty=!0}setExtent(e){const i=this.graphicsCoreOwner.view.spatialReference,t=this.graphicsCoreOwner.view.basemapTerrain.spatialReference;if(i===t)this._extent=e??null;else{const r=n();l(e,i,r,t)?this._extent=r:this._extent=null}this._setDirty()}scaleRangeActive(){return this._scaleRangeActive}updateScaleRangeActive(){const e=this.layer,i=e.effectiveScaleRange;let t=this.layerScaleEnabled&&null!=i&&g(i.minScale,i.maxScale);e.labelingInfo&&!t&&(t=e.labelingInfo.some((e=>e&&g(e.minScale??0,e.maxScale??0))));const r=this._scaleRangeActive!==t;return this._scaleRangeActive=t,t&&!this.hasHandles(b)&&this.basemapTerrain?(this.addHandles(this.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),b),this.layerScaleEnabled&&this.addHandles(this.basemapTerrain.on("tiles-visibility-changed",(()=>this._setDirty())),b)):!t&&this.hasHandles(b)&&this.removeHandles(b),r}get running(){return!(!this.graphicsCoreOwner.view.basemapTerrain||!this.updating)}runTask(e){const i=this.graphicsCoreOwner.view.basemapTerrain;if(this._extent&&i&&i.ready&&this._scaleRangeActive&&this.layerScaleEnabled){if(this._layerScaleRangeVisibilityQuery)return d.YIELD;{this._layerScaleRangeVisibilityQuery=!0;const{minScale:e,maxScale:t}=this.layer.effectiveScaleRange;i.queryVisibleScaleRange(this._extent,e,t,(e=>this._finishUpdate(e)))}}else this._finishUpdate(!0);e.madeProgress()}_finishUpdate(e){this._layerScaleRangeVisibilityQuery=!1,this._set("suspended",!e),this._dirty=!1}_visibleAtLayerScale(e){const i=this.layer.effectiveScaleRange;return!this.layerScaleEnabled||h(e,i.minScale||0,i.maxScale||0)}_visibleAtLabelScale(e,i){return h(e,i.minScale||0,i.maxScale||0)}_graphicScale(e){let i;if(null!=e.centroid?i=e.centroid:null!=e.graphic.geometry&&"point"===e.graphic.geometry.type&&(i=e.graphic.geometry),i){return this.graphicsCoreOwner.view.basemapTerrain?this.graphicsCoreOwner.view.basemapTerrain.getScale(i):1}return null}_graphicVisible(e){if(!this.layerScaleEnabled)return!0;const i=this._graphicScale(e);return this._visibleAtLayerScale(i)}updateVisibility(e){if(this._scaleRangeActive){const i=this._graphicVisible(e);return e.setVisibilityFlag(c.GRAPHIC,o.SCALE_RANGE,i)}return!1}updateGraphicLabelScaleVisibility(e){if(!this._scaleRangeActive)return!1;if(!e.labelLayers||0===e.labelLayers.length)return!1;const i=this._graphicScale(e),t=this._updateLabelScaleVisibility(e,i);return t&&(this.graphicsCoreOwner.view.deconflictor.setDirty(),this.graphicsCoreOwner.view.labeler.setDirty()),t}_updateLabelScaleVisibility(e,i){if(!e.labelLayers||0===e.labelLayers.length)return!1;const t=e.labelLayers[0]._labelClass;if(t&&null!=t.minScale&&null!=t.maxScale){const r=this._visibleAtLabelScale(i,t);if(e.setVisibilityFlag(c.LABEL,o.SCALE_RANGE,r))return!0}return!1}_scaleUpdateHandler(e){if(this._setDirty(),!this.graphicsCore.visible)return;const i=e.extent,t=e.scale,r=this._visibleAtLayerScale(t);let s=!1;const a=this.graphicsCoreOwner.view.spatialReference,n=e.spatialReference;if(null==n)return void u.error("scaleUpdate: Internal error, no SpatialReference given for tiles");const h=!n.equals(a);if(h){if(!l(i,n,_,a))return void u.error("scaleUpdate: Internal error, cannot project AABR from "+n+" to wkid "+a)}const p=h?_:i;this.queryGraphicUIDsInExtent(p,a,(e=>{const a=this.graphicsCore.getGraphics3DGraphicById(e);if(null==a)return;const l=a.centroid;null!=l&&(i[0]>l.x||i[1]>l.y||i[2]<l.x||i[3]<l.y)||(a.setVisibilityFlag(c.GRAPHIC,o.SCALE_RANGE,r)&&(s=!0),this._updateLabelScaleVisibility(a,t)&&(s=!0))})),s&&(this.graphicsCoreOwner.view.deconflictor.setDirty(),this.graphicsCoreOwner.view.labeler.setDirty())}layerMinMaxScaleChangeHandler(){this.updateScaleRangeActive()&&!this._scaleRangeActive?this.graphicsCore.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(c.GRAPHIC,o.SCALE_RANGE,!0))):this._scaleRangeActive&&this.graphicsCore.updateAllGraphicsVisibility(),this._setDirty()}};function g(e,i){return e>0||i>0}e([r()],y.prototype,"graphicsCoreOwner",void 0),e([r()],y.prototype,"layer",void 0),e([r()],y.prototype,"queryGraphicUIDsInExtent",void 0),e([r()],y.prototype,"graphicsCore",void 0),e([r()],y.prototype,"basemapTerrain",void 0),e([r({constructOnly:!0})],y.prototype,"layerScaleEnabled",void 0),e([r({readOnly:!0})],y.prototype,"suspended",void 0),e([r({readOnly:!0})],y.prototype,"updating",null),e([r()],y.prototype,"_dirty",void 0),y=e([s("esri.views.3d.layers.graphics.Graphics3DScaleVisibility")],y);const b="terrain-events",_=n(),m=y;export{m as default};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import i from"../../../../core/Accessor.js";import t from"../../../../core/Logger.js";import{property as r}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as s}from"../../../../core/accessorSupport/decorators/subclass.js";import{UpdatingHandles as a}from"../../../../core/support/UpdatingHandles.js";import{projectBoundingRect as l}from"../../../../geometry/projection.js";import{create as n}from"../../../../geometry/support/aaBoundingRect.js";import{VisibilityGroup as c,VisibilityFlag as o}from"./enums.js";import{scaleBoundsPredicate as h}from"../../../support/layerViewUtils.js";import{TaskPriority as p,Task as d}from"../../../support/Scheduler.js";const u=t.getLogger("esri.views.3d.layers.graphics.Graphics3DScaleVisibility");let y=class extends i{constructor(e){super(e),this._scaleRangeActive=!1,this._layerScaleRangeVisibilityQuery=!1,this._extent=null,this._updatingHandles=new a,this.graphicsCoreOwner=null,this.layer=null,this.queryGraphicUIDsInExtent=null,this.graphicsCore=null,this.basemapTerrain=null,this.layerScaleEnabled=!0,this.suspended=!1,this._dirty=!0}initialize(){this.updateScaleRangeActive();const e=this.graphicsCoreOwner.view.resourceController.scheduler;this.addHandles(e.registerTask(p.SCALE_VISIBILITY,this)),this._updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this.layerMinMaxScaleChangeHandler()))}destroy(){this._updatingHandles.destroy(),this.removeHandles(),this._dirty=!1,this._extent=null,this.graphicsCoreOwner=null,this.layer=null,this.queryGraphicUIDsInExtent=null,this.graphicsCore=null,this.basemapTerrain=null}get updating(){return this._dirty||this._updatingHandles.updating}_setDirty(){this._dirty=!0}setExtent(e){const i=this.graphicsCoreOwner.view.spatialReference,t=this.graphicsCoreOwner.view.basemapTerrain.spatialReference;if(i===t)this._extent=e??null;else{const r=n();l(e,i,r,t)?this._extent=r:this._extent=null}this._setDirty()}scaleRangeActive(){return this._scaleRangeActive}updateScaleRangeActive(){const e=this.layer,i=e.effectiveScaleRange;let t=this.layerScaleEnabled&&null!=i&&g(i.minScale,i.maxScale);e.labelingInfo&&!t&&(t=e.labelingInfo.some((e=>e&&g(e.minScale??0,e.maxScale??0))));const r=this._scaleRangeActive!==t;return this._scaleRangeActive=t,t&&!this.hasHandles(b)&&this.basemapTerrain?(this.addHandles(this.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),b),this.layerScaleEnabled&&this.addHandles(this.basemapTerrain.on("tiles-visibility-changed",(()=>this._setDirty())),b)):!t&&this.hasHandles(b)&&this.removeHandles(b),r}get running(){return!(!this.graphicsCoreOwner.view.basemapTerrain||!this.updating)}runTask(e){const i=this.graphicsCoreOwner.view.basemapTerrain;if(this._extent&&i&&i.ready&&this._scaleRangeActive&&this.layerScaleEnabled){if(this._layerScaleRangeVisibilityQuery)return d.YIELD;{this._layerScaleRangeVisibilityQuery=!0;const{minScale:e,maxScale:t}=this.layer.effectiveScaleRange;i.queryVisibleScaleRange(this._extent,e,t,(e=>this._finishUpdate(e)))}}else this._finishUpdate(!0);e.madeProgress()}_finishUpdate(e){this._layerScaleRangeVisibilityQuery=!1,this._set("suspended",!e),this._dirty=!1}_visibleAtLayerScale(e){const i=this.layer.effectiveScaleRange;return!this.layerScaleEnabled||h(e,i.minScale||0,i.maxScale||0)}_visibleAtLabelScale(e,i){return h(e,i.minScale||0,i.maxScale||0)}_graphicScale(e){let i;if(null!=e.centroid?i=e.centroid:null!=e.graphic.geometry&&"point"===e.graphic.geometry.type&&(i=e.graphic.geometry),i){return this.graphicsCoreOwner.view.basemapTerrain?this.graphicsCoreOwner.view.basemapTerrain.getScale(i):1}return null}_graphicVisible(e){if(!this.layerScaleEnabled)return!0;const i=this._graphicScale(e);return this._visibleAtLayerScale(i)}updateVisibility(e){if(this._scaleRangeActive){const i=this._graphicVisible(e);return e.setVisibilityFlag(c.GRAPHIC,o.SCALE_RANGE,i)}return!1}updateGraphicLabelScaleVisibility(e){if(!this._scaleRangeActive)return!1;if(!e.labelLayers||0===e.labelLayers.length)return!1;const i=this._graphicScale(e),t=this._updateLabelScaleVisibility(e,i);return t&&(this.graphicsCoreOwner.view.deconflictor.setDirty(),this.graphicsCoreOwner.view.labeler.setDirty()),t}_updateLabelScaleVisibility(e,i){if(!e.labelLayers||0===e.labelLayers.length)return!1;const t=e.labelLayers[0]._labelClass;if(t&&null!=t.minScale&&null!=t.maxScale){const r=this._visibleAtLabelScale(i,t);if(e.setVisibilityFlag(c.LABEL,o.SCALE_RANGE,r))return!0}return!1}_scaleUpdateHandler(e){if(this._setDirty(),!this.graphicsCore.visible)return;const i=e.extent,t=e.scale,r=this._visibleAtLayerScale(t);let s=!1;const a=this.graphicsCoreOwner.view.spatialReference,n=e.spatialReference;if(null==n)return void u.error("scaleUpdate: Internal error, no SpatialReference given for tiles");const h=!n.equals(a);if(h){if(!l(i,n,_,a))return void u.error("scaleUpdate: Internal error, cannot project AABR from "+n+" to wkid "+a)}const p=h?_:i;this.queryGraphicUIDsInExtent(p,a,(e=>{const a=this.graphicsCore.getGraphics3DGraphicById(e);if(null==a)return;const l=a.centroid;null!=l&&(i[0]>l.x||i[1]>l.y||i[2]<l.x||i[3]<l.y)||(a.setVisibilityFlag(c.GRAPHIC,o.SCALE_RANGE,r)&&(s=!0),this._updateLabelScaleVisibility(a,t)&&(s=!0))})),s&&(this.graphicsCoreOwner.view.deconflictor.setDirty(),this.graphicsCoreOwner.view.labeler.setDirty())}layerMinMaxScaleChangeHandler(){this.updateScaleRangeActive()&&!this._scaleRangeActive?this.graphicsCore.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(c.GRAPHIC,o.SCALE_RANGE,!0))):this._scaleRangeActive&&this.graphicsCore.updateAllGraphicsVisibility(),this._setDirty()}};function g(e,i){return e>0||i>0}e([r()],y.prototype,"graphicsCoreOwner",void 0),e([r()],y.prototype,"layer",void 0),e([r()],y.prototype,"queryGraphicUIDsInExtent",void 0),e([r()],y.prototype,"graphicsCore",void 0),e([r()],y.prototype,"basemapTerrain",void 0),e([r({constructOnly:!0})],y.prototype,"layerScaleEnabled",void 0),e([r({readOnly:!0})],y.prototype,"suspended",void 0),e([r({readOnly:!0})],y.prototype,"updating",null),e([r()],y.prototype,"_dirty",void 0),y=e([s("esri.views.3d.layers.graphics.Graphics3DScaleVisibility")],y);const b="terrain-events",_=n(),m=y;export{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.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Logger.js";import{O as i}from"../../../../chunks/vec3f64.js";import{f as o}from"../../../../chunks/vec4f64.js";import{SymbolUpdateType as r}from"./elevationAlignmentUtils.js";import{ElevationContext as n}from"./ElevationContext.js";import{zeroContext as s}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as a}from"./graphicUtils.js";import{ApplyRendererDiffResult as l}from"./interfaces.js";import{Loadable as p}from"./Loadable.js";import{defaultSymbolLayerComplexity as d}from"./symbolComplexity.js";import{getAttributeValue as c}from"../support/FastSymbolUpdates.js";const u=t.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class h extends p{constructor(e,t,i,o){super(i.schedule),this.symbol=e,this.symbolLayer=t,this._context=i,this._elevationInfoOverride=null,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1},this.complexity=null,this.logger=u,this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=o.renderPriority,this._renderPriorityStep=o.renderPriorityStep,this._elevationContext=new n,this.complexity=this.computeComplexity(),this.ignoreDrivers=o.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=f(this._context.renderer)),this._updateElevationContext()}getCachedSize(){return null}get extentPadding(){return 0}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,i=f(e);return i.color!==t.color||i.opacity!==t.opacity||i.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||i.size!==t.size}get needsDrivenTransparentPass(){return this._drivenProperties.opacity&&!this._drivenProperties.opacityAlwaysOpaque}_logGeometryCreationWarnings(e,t,i,o){const r=e.projectionSuccess,n="polygons"in e?e.polygons:null,s=`${o} geometry failed to be created`;let a=null;r?!this._logGeometryValidationWarnings(t,i,o)&&n&&0===n.length&&"rings"===i&&t.length>0&&t[0].length>2&&(a=`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):a=`${s} (failed to project geometry to view spatial reference)`,a&&u.warnOncePerTick(a)}_logGeometryValidationWarnings(e,t,i){const o=`${i} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(u.warnOncePerTick(`${o} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(u.warnOncePerTick(`${o} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,i=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+i+` symbol: ${e.type}`),!1;if("point"===e.type){const t=e;if(!isFinite(t.x)||!isFinite(t.y))return u.warn("point coordinate is not a valid number, graphic skipped"),!1}return!0}_defaultElevationInfoNoZ(){return y}_defaultElevationInfoZ(){return v}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.updateFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.updateFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}setGraphicElevationContext(e,t){const i=e.geometry,o=this.getDefaultElevationInfo(i);t.unit=null!=this._elevationContext.unit?this._elevationContext.unit:o.unit,t.mode=this.getGeometryElevationMode(i,o),t.offsetMeters=this._elevationContext.meterUnitOffset??o.offset??0;const r=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===t.mode;r&&(t.mode="relative-to-ground",t.offsetMeters=0);const n=r?s:this._elevationContext.featureExpressionInfoContext;return t.updateFeatureExpressionInfoContext(n,e,this._context.layer),t}prepareSymbolLayerPatch(e){}updateGeometry(e,t){return!1}updateTransform(e,t,i,o){return!1}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=g){let i=1;return this.draped||(i*=this._getLayerOpacity()),this._drivenProperties.opacity||(null!=e?i*=e.a:t.hasIntrinsicColor||(i=0)),i}_getCombinedOpacityAndColor(t,o=g){const r=this._getCombinedOpacity(t,o);if(this._drivenProperties.color)return a(null,r);const n=null!=t?e.toUnitRGB(t):i;return a(n,r)}_getVertexOpacityAndColor(e,t=null){const i=this._drivenProperties.color?e.color:null,o=this._drivenProperties.opacity?e.opacity:null,r=a(i,o);return t&&(r[0]*=t,r[1]*=t,r[2]*=t,r[3]*=t),r}isFastUpdatesEnabled(){return null!=this._fastUpdates}computeComplexity(){return d(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,i){switch(e){case"opacity":return this.layerOpacityChanged(t,i),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return this.layerElevationInfoChanged(t,i,e)!==r.RECREATE}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,i);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;default:return!1}}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,i){let o=r.UPDATE;return e.forEach((e=>{const n=t(e);if(null!=n){const t=e.graphic;this.setGraphicElevationContext(t,n.elevationContext),n.needsElevationUpdates=i(n.elevationContext.mode)}else o=r.RECREATE})),o}applyRendererDiff(e,t){return l.RecreateSymbol}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,i=t.size?c(t.size.field,e):0,r=t.color?c(t.color.field,e):0,n=t.opacity?c(t.opacity.field,e):0;return o(i,r,n,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&u.warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.field??null,color:this._fastUpdates?.visualVariables.color?.field??null,opacity:this._fastUpdates?.visualVariables.opacity?.field??null,rotation:this._fastUpdates?.visualVariables.rotation?.field??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function f(e){const t={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach((e=>{switch(e.type){case"color":if(t.color=!0,e.stops)for(let i=0;i<e.stops.length;i++){const o=e.stops[i].color;o&&(t.opacity=!0,o.a<1&&(t.opacityAlwaysOpaque=!1))}break;case"opacity":t.opacity=!0,t.opacityAlwaysOpaque=!1;break;case"size":t.size=!0}})),t}const y={mode:"on-the-ground",offset:0,unit:"meters"},v={mode:"absolute-height",offset:0,unit:"meters"},g={hasIntrinsicColor:!1};export{h as Graphics3DSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Logger.js";import{O as i}from"../../../../chunks/vec3f64.js";import{f as o}from"../../../../chunks/vec4f64.js";import{SymbolUpdateType as r}from"./elevationAlignmentUtils.js";import{ElevationContext as n}from"./ElevationContext.js";import{zeroContext as s}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as a}from"./graphicUtils.js";import{ApplyRendererDiffResult as l}from"./interfaces.js";import{Loadable as p}from"./Loadable.js";import{defaultSymbolLayerComplexity as d}from"./symbolComplexity.js";import{getAttributeValue as c}from"../support/FastSymbolUpdates.js";const u=t.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class h extends p{constructor(e,t,i,o){super(i.schedule),this.symbol=e,this.symbolLayer=t,this._context=i,this._elevationInfoOverride=null,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1},this.complexity=null,this.logger=u,this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=o.renderPriority,this._renderPriorityStep=o.renderPriorityStep,this._elevationContext=new n,this.complexity=this.computeComplexity(),this.ignoreDrivers=o.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=f(this._context.renderer)),this._updateElevationContext()}getCachedSize(){return null}get extentPadding(){return 0}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,i=f(e);return i.color!==t.color||i.opacity!==t.opacity||i.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||i.size!==t.size}get needsDrivenTransparentPass(){return this._drivenProperties.opacity&&!this._drivenProperties.opacityAlwaysOpaque}_logGeometryCreationWarnings(e,t,i,o){const r=e.projectionSuccess,n="polygons"in e?e.polygons:null,s=`${o} geometry failed to be created`;let a=null;r?!this._logGeometryValidationWarnings(t,i,o)&&n&&0===n.length&&"rings"===i&&t.length>0&&t[0].length>2&&(a=`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):a=`${s} (failed to project geometry to view spatial reference)`,a&&u.warnOncePerTick(a)}_logGeometryValidationWarnings(e,t,i){const o=`${i} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(u.warnOncePerTick(`${o} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(u.warnOncePerTick(`${o} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,i=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+i+` symbol: ${e.type}`),!1;if("point"===e.type){const t=e;if(!isFinite(t.x)||!isFinite(t.y))return u.warn("point coordinate is not a valid number, graphic skipped"),!1}return!0}_defaultElevationInfoNoZ(){return y}_defaultElevationInfoZ(){return v}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.updateFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.updateFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}setGraphicElevationContext(e,t=new n){const i=e.geometry,o=this.getDefaultElevationInfo(i);t.unit=null!=this._elevationContext.unit?this._elevationContext.unit:o.unit,t.mode=this.getGeometryElevationMode(i,o),t.offsetMeters=this._elevationContext.meterUnitOffset??o.offset??0;const r=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===t.mode;r&&(t.mode="relative-to-ground",t.offsetMeters=0);const a=r?s:this._elevationContext.featureExpressionInfoContext;return t.updateFeatureExpressionInfoContext(a,e,this._context.layer),t}prepareSymbolLayerPatch(e){}updateGeometry(e,t){return!1}updateTransform(e,t,i,o){return!1}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=g){let i=1;return this.draped||(i*=this._getLayerOpacity()),this._drivenProperties.opacity||(null!=e?i*=e.a:t.hasIntrinsicColor||(i=0)),i}_getCombinedOpacityAndColor(t,o=g){const r=this._getCombinedOpacity(t,o);if(this._drivenProperties.color)return a(null,r);const n=null!=t?e.toUnitRGB(t):i;return a(n,r)}_getVertexOpacityAndColor(e,t=null){const i=this._drivenProperties.color?e.color:null,o=this._drivenProperties.opacity?e.opacity:null,r=a(i,o);return t&&(r[0]*=t,r[1]*=t,r[2]*=t,r[3]*=t),r}isFastUpdatesEnabled(){return null!=this._fastUpdates}computeComplexity(){return d(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,i){switch(e){case"opacity":return this.layerOpacityChanged(t,i),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return this.layerElevationInfoChanged(t,i,e)!==r.RECREATE}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,i);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;default:return!1}}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,i){let o=r.UPDATE;return e.forEach((e=>{const n=t(e);if(null!=n){const t=e.graphic;this.setGraphicElevationContext(t,n.elevationContext),n.needsElevationUpdates=i(n.elevationContext.mode)}else o=r.RECREATE})),o}applyRendererDiff(e,t){return l.RecreateSymbol}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,i=t.size?c(t.size.field,e):0,r=t.color?c(t.color.field,e):0,n=t.opacity?c(t.opacity.field,e):0;return o(i,r,n,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&u.warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.field??null,color:this._fastUpdates?.visualVariables.color?.field??null,opacity:this._fastUpdates?.visualVariables.opacity?.field??null,rotation:this._fastUpdates?.visualVariables.rotation?.field??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function f(e){const t={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach((e=>{switch(e.type){case"color":if(t.color=!0,e.stops)for(let i=0;i<e.stops.length;i++){const o=e.stops[i].color;o&&(t.opacity=!0,o.a<1&&(t.opacityAlwaysOpaque=!1))}break;case"opacity":t.opacity=!0,t.opacityAlwaysOpaque=!1;break;case"size":t.size=!0}})),t}const y={mode:"on-the-ground",offset:0,unit:"meters"},v={mode:"absolute-height",offset:0,unit:"meters"},g={hasIntrinsicColor:!1};export{h as Graphics3DSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Error.js";import{isPromiseLike as t}from"../../../../core/promiseUtils.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{f as n,Z as s,a as i}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as o,textSymbolLayerSupportsVerticalOffset as l}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as a}from"./CreateLabelParameters.js";import{perObjectElevationAligner as c}from"./ElevationAligners.js";import{SymbolUpdateType as m,needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{ElevationContext as u}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as p}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as g}from"./graphicUtils.js";import{verticalPlacementFromAlignment as y,textRenderAlignmentFromHorizontalPlacement as x,horizontalPlacementToAnchorX as b,anchorFromPlacements as v,namedAnchorToHUDMaterialAnchorPos as P}from"./placementUtils.js";import{placePointOnGeometry as O,createStageObject as j,extendPointGraphicElevationContext as w}from"./pointUtils.js";import{createPointGeometry as S}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as _}from"../../webgl-engine/lib/TextRenderParameters.js";import E from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as L}from"../../webgl-engine/materials/HUDMaterial.js";const z=[0,0,1];class C 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=g(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await _.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,r=O(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const n=this.symbolLayer.text;if(null==n||""===n)return null;const s=o(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=s&&!l(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const i=new a(s,this.symbolLayer.horizontalAlignment,y(this.symbolLayer.verticalAlignment));return this._createAs3DShape(t,r,n,i)}createLabel(e,t,r,n){const s=e.graphic,i=O(s.geometry);if(null==i)return this.logger.warn(`unsupported geometry type for label: ${s.geometry.type}`),null;const o=t.text;return!o||/^\s+$/.test(o)?null:this._createAs3DShape(s,i,o,t,r,n)}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 G(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),m.UPDATE}slicePlaneEnabledChanged(e,t){return G(e,t,(e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){const r=t.elevationContext;this.setGraphicElevationContext(e,r,null!=t.metadata?t.metadata.elevationOffset:0),t.needsElevationUpdates=h(r.mode)||"absolute-height"===r.mode}_defaultElevationInfoNoZ(){return U}_createAs3DShape(e,o,l,a,m,f){const g=this.setGraphicElevationContext(e,new u,a.elevationOffset),y="polyline"===e.geometry?.type,b=e.uid;let v=null,P=null;if(null==f){const e=x(a.horizontalPlacement);v=new E(l,e,this._textRenderParameters);let r=null;if(null!=this._context.sharedResources.textures){P=this._context.sharedResources.textures.fromData(v.key,(()=>v.create()),(()=>{null!=r&&r.release()}));const e=this._context.stage.renderView.textureRepository.acquire(P.texture.id);if(null==e||t(e))return P.release(),null;r=e}}const O=R(v,a),_={occlusionTest:!0,screenOffset:a.screenOffset,anchorPosition:O,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:a.centerOffsetUnits,drawInSecondSlot:!0};if(null!=f?_.textureId=f.id:null!=P&&(_.textureId=P.texture.id),null!=a.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:n}=a.verticalOffset;_.verticalOffset={screenLength:r(e),minWorldLength:t||0,maxWorldLength:null!=n?n:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources;_.screenSizePerspective=t.overridePadding(this._textRenderParameters.haloSize+this._textRenderParameters.definition.background.padding[0]),_.screenSizePerspectiveAlignment=e}let C;if(y&&(_.shaderPolygonOffset=1e-4),_.hasSlicePlane=this._context.slicePlaneEnabled,null!=m){const e=JSON.stringify(_);C=m.get(e),null==C&&(C=new L(_),m.add(e,C))}else C=new L(_);const G=a.translation,U=v?n(v.displayWidth,v.displayHeight):s,D=a.centerOffset,A=S(C,z,G,null,U,D,[0,0],null),T=j(this._context,o,A,g,b);if(null==T)return null;const W=new d(this,T.object,[A],null==m?[C]:null,P,c,g);W.alignedSampledElevation=T.sampledElevation,W.needsElevationUpdates=h(g.mode)||"absolute-height"===g.mode;const{displayWidth:I,displayHeight:k}=null!=v?v:a;W.getScreenSize=(e=i())=>(e[0]=I,e[1]=k,e);const $=new p(a.elevationOffset,l);return W.metadata=$,w(W,o,this._context.elevationProvider),W}}function G(e,t,r){e&&e.forEach((e=>{const n=t(e);null!=n&&r(n,e.graphic)}))}function R(e,t){if("baseline"===t.verticalPlacement){const r=b[t.horizontalPlacement],s=null!=e?e.baselineAnchorY:0;return n(r,s)}const r=v(t.horizontalPlacement,t.verticalPlacement);return P[r]}const U={mode:"relative-to-ground",offset:0};export{C as Graphics3DTextSymbolLayer};
5
+ import e from"../../../../core/Error.js";import{isPromiseLike as t}from"../../../../core/promiseUtils.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{f as n,Z as s,a as i}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as o,textSymbolLayerSupportsVerticalOffset as l}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as a}from"./CreateLabelParameters.js";import{perObjectElevationAligner as c}from"./ElevationAligners.js";import{SymbolUpdateType as m,needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{ElevationContext as u}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as p}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as g}from"./graphicUtils.js";import{verticalPlacementFromAlignment as y,textRenderAlignmentFromHorizontalPlacement as x,horizontalPlacementToAnchorX as b,anchorFromPlacements as v,namedAnchorToHUDMaterialAnchorPos as P}from"./placementUtils.js";import{placePointOnGeometry as O,createStageObject as j,extendPointGraphicElevationContext as w}from"./pointUtils.js";import{createPointGeometry as S}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as _}from"../../webgl-engine/lib/TextRenderParameters.js";import E from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as L}from"../../webgl-engine/materials/HUDMaterial.js";const z=[0,0,1];class C 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=g(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await _.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,r=O(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const n=this.symbolLayer.text;if(null==n||""===n)return null;const s=o(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=s&&!l(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const i=new a(s,this.symbolLayer.horizontalAlignment,y(this.symbolLayer.verticalAlignment));return this._createAs3DShape(t,r,n,i)}createLabel(e,t,r,n){const s=e.graphic,i=O(s.geometry);if(null==i)return this.logger.warn(`unsupported geometry type for label: ${s.geometry.type}`),null;const o=t.text;return!o||/^\s+$/.test(o)?null:this._createAs3DShape(s,i,o,t,r,n)}setGraphicElevationContext(e,t,r=0){return super.setGraphicElevationContext(e,t),t.addOffsetRenderUnits(r),t}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return G(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),m.UPDATE}slicePlaneEnabledChanged(e,t){return G(e,t,(e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){const r=t.elevationContext;this.setGraphicElevationContext(e,r,null!=t.metadata?t.metadata.elevationOffset:0),t.needsElevationUpdates=h(r.mode)||"absolute-height"===r.mode}_defaultElevationInfoNoZ(){return U}_createAs3DShape(e,o,l,a,m,f){const g=this.setGraphicElevationContext(e,new u,a.elevationOffset),y="polyline"===e.geometry?.type,b=e.uid;let v=null,P=null;if(null==f){const e=x(a.horizontalPlacement);v=new E(l,e,this._textRenderParameters);let r=null;if(null!=this._context.sharedResources.textures){P=this._context.sharedResources.textures.fromData(v.key,(()=>v.create()),(()=>{null!=r&&r.release()}));const e=this._context.stage.renderView.textureRepository.acquire(P.texture.id);if(null==e||t(e))return P.release(),null;r=e}}const O=R(v,a),_={occlusionTest:!0,screenOffset:a.screenOffset,anchorPosition:O,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:a.centerOffsetUnits,drawInSecondSlot:!0};if(null!=f?_.textureId=f.id:null!=P&&(_.textureId=P.texture.id),null!=a.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:n}=a.verticalOffset;_.verticalOffset={screenLength:r(e),minWorldLength:t||0,maxWorldLength:null!=n?n:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources;_.screenSizePerspective=t.overridePadding(this._textRenderParameters.haloSize+this._textRenderParameters.definition.background.padding[0]),_.screenSizePerspectiveAlignment=e}let C;if(y&&(_.shaderPolygonOffset=1e-4),_.hasSlicePlane=this._context.slicePlaneEnabled,null!=m){const e=JSON.stringify(_);C=m.get(e),null==C&&(C=new L(_),m.add(e,C))}else C=new L(_);const G=a.translation,U=v?n(v.displayWidth,v.displayHeight):s,D=a.centerOffset,A=S(C,z,G,null,U,D,[0,0],null),T=j(this._context,o,A,g,b);if(null==T)return null;const W=new d(this,T.object,[A],null==m?[C]:null,P,c,g);W.alignedSampledElevation=T.sampledElevation,W.needsElevationUpdates=h(g.mode)||"absolute-height"===g.mode;const{displayWidth:I,displayHeight:k}=null!=v?v:a;W.getScreenSize=(e=i())=>(e[0]=I,e[1]=k,e);const $=new p(a.elevationOffset,l);return W.metadata=$,w(W,o,this._context.elevationProvider),W}}function G(e,t,r){e&&e.forEach((e=>{const n=t(e);null!=n&&r(n,e.graphic)}))}function R(e,t){if("baseline"===t.verticalPlacement){const r=b[t.horizontalPlacement],s=null!=e?e.baselineAnchorY:0;return n(r,s)}const r=v(t.horizontalPlacement,t.verticalPlacement);return P[r]}const U={mode:"relative-to-ground",offset:0};export{C as Graphics3DTextSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.28/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{getMetersPerUnitForSR as t}from"../../../../core/unitUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{s as o}from"../../../../chunks/vec2.js";import{f as i,a as n}from"../../../../chunks/vec2f64.js";import{b as s}from"../../../../chunks/vec4.js";import{t as a}from"../../../../chunks/common.js";import{create as l,empty as c,expandWithBuffer as h,intersectsClippingArea as m,expandWithAABB as u}from"../../../../geometry/support/aaBoundingBox.js";import{create as d,empty as p,expandPointInPlace as g}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as y,doubleSubArray as f}from"../../../../geometry/support/DoubleArray.js";import{perVertexElevationAligner as _}from"./ElevationAligners.js";import{SymbolUpdateType as v,elevationModeChangeUpdateType as x,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import{ElevationContext as C}from"./ElevationContext.js";import D from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as j}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as w}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as S,createWaterGeometry as G,PolygonCreationDataBase as A}from"./polygonUtils.js";import{geometryToRenderInfo as E,geometryToRenderInfoDraped as L}from"../../support/renderInfoUtils/polygon.js";import{Object3D as O}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as P}from"../../webgl-engine/lib/RenderGeometry.js";import{WaterMaterialParameters as T,WaterMaterial as R}from"../../webgl-engine/materials/WaterMaterial.js";import{wavePresets as U}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const I=["polyline","polygon","extent"];class V extends w{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,I,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new C);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,r,t.uid)}ensureMaterial(){if(null!=this._material)return;const t=new T,r=this.symbolLayer.color;null!=r&&(t.color=e.toUnitRGBA(r));const o=this._getCombinedOpacity(r,{hasIntrinsicColor:!0});t.color=[t.color[0],t.color[1],t.color[2],o],t.transparent=o<1||this.needsDrivenTransparentPass,t.waveDirection=null!=this.symbolLayer.waveDirection?V.headingVectorFromAngle(this.symbolLayer.waveDirection):i(0,0);const n=this.symbolLayer.waveStrength+"-"+this.symbolLayer.waterbodySize,s=U[n];t.waveStrength=s.waveStrength,t.waveTextureRepeat=s.textureRepeat,t.waveVelocity=s.waveVelocity,t.flowStrength=s.perturbationStrength,t.hasSlicePlane=this._context.slicePlaneEnabled,t.isDraped=this.draped,this._material=new R(t),this._context.stage.add(this._material)}layerOpacityChanged(){if(null==this._material)return;const e=this._material.parameters.color,t=this._getCombinedOpacity(this.symbolLayer.color,{hasIntrinsicColor:!0}),r=t<1||this.needsDrivenTransparentPass;this._material.setParameters({color:[e[0],e[1],e[2],t],transparent:r})}layerElevationInfoChanged(e,t,r){const o=this._elevationContext.mode,i=x(V.elevationModeChangeTypes,r,o);if(i!==v.UPDATE)return i;const n=b(o);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>n))}slicePlaneEnabledChanged(){return null!=this._material&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r){const o=S(e.geometry);if(null==o)return null;const i=E(o,this._context.elevationProvider,this._context.renderCoordsHelper,t),n=i.position.length/3,s=y(2*n);this._createUVCoordsFromVertices(s,i.mapPositions,n,this._context.elevationProvider.spatialReference);const a=new k(i,s,this._context.layer.uid,e.uid);if(a.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderData,o.rings,"rings","WaterSymbol3DLayer"),0===a.outGeometries.length)return null;const l=new O({geometries:a.outGeometries,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),c=new j(this,l,a.outGeometries,null,null,_,t);return c.alignedSampledElevation=a.renderData.sampledElevation,c.needsElevationUpdates=b(t.mode),c}_createUVCoordsFromVertices(e,r,i,n){const a=t(n);p(M);for(let t=0;t<i;t++)o(W,r[3*t],r[3*t+1]),g(M,W);s(M,M,a);const l=M[0]%V.unitSizeOfTexture,c=M[1]%V.unitSizeOfTexture;B[0]=M[0]-l,B[1]=M[1]-c;for(let t=0;t<i;t++)e[2*t]=(r[3*t]*a-B[0])/V.unitSizeOfTexture,e[2*t+1]=(r[3*t+1]*a-B[1])/V.unitSizeOfTexture}_create3DShapeGeometries(e){const t=e.renderData.polygons,o=e.uvCoords;for(const{count:i,index:n,position:s,mapPositions:a,holeIndices:l}of t){if(null!=this._context.clippingExtent&&(c(z),h(z,a),!m(z,this._context.clippingExtent)))continue;const t=r(a,l,3);if(0===t.length)continue;const u=f(o,2*n,2*i),d=G({material:this._material,indices:t,mapPositions:a,attributeData:{position:s,uv0:u}},e.objectAndLayerIdColor);e.outGeometries.push(d)}}_createAsOverlay(e){const t=S(e.geometry);if(null==t)return null;this._material.renderPriority=this._renderPriority;const r=L(t,this._context.overlaySR),o=r.position.length/3,i=y(2*o);this._createUVCoordsFromVertices(i,r.position,o,this._context.overlaySR);const n=new F(r,i,this._context.layer.uid,e.uid);return n.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),n.outBoundingBox=c(),this._createAsOverlayWater(n),this._logGeometryCreationWarnings(n.renderData,t.rings,"rings","WaterSymbol3DLayer"),0===n.outGeometries.length?null:new D(this,n.outGeometries,n.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){const t=e.uvCoords,o=e.renderData.polygons;for(const{position:i,holeIndices:n,index:s,count:a}of o){if(c(z),h(z,i),!m(z,this._context.clippingExtent))continue;u(e.outBoundingBox,z);const o=r(i,n,3);if(0===o.length)continue;const l=f(t,2*s,2*a),d=G({material:this._material,indices:o,attributeData:{position:i,uv0:l}},e.objectAndLayerIdColor);e.outGeometries.push(new P(d,e))}}static headingVectorFromAngle(e){const t=n(),r=a(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}V.unitSizeOfTexture=100,V.elevationModeChangeTypes={definedChanged:v.RECREATE,staysOnTheGround:v.NONE,onTheGroundChanged:v.RECREATE};const B=n(),M=d(),W=n(),z=l();class k extends A{constructor(e,t,r,o){super(e,r,o),this.uvCoords=t}}class F extends A{constructor(e,t,r,o){super(e,r,o),this.uvCoords=t}}export{V as Graphics3DWaterSymbolLayer};
5
+ import e from"../../../../Color.js";import{getMetersPerUnitForSR as t}from"../../../../core/unitUtils.js";import{e as r}from"../../../../chunks/earcut.js";import{s as o}from"../../../../chunks/vec2.js";import{f as i,a as n}from"../../../../chunks/vec2f64.js";import{b as s}from"../../../../chunks/vec4.js";import{t as a}from"../../../../chunks/common.js";import{create as l,empty as c,expandWithBuffer as h,intersectsClippingArea as m,expandWithAABB as u}from"../../../../geometry/support/aaBoundingBox.js";import{create as d,empty as p,expandPointInPlace as g}from"../../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as y,doubleSubArray as f}from"../../../../geometry/support/DoubleArray.js";import{perVertexElevationAligner as _}from"./ElevationAligners.js";import{SymbolUpdateType as v,elevationModeChangeUpdateType as x,needsElevationUpdates2D as b}from"./elevationAlignmentUtils.js";import C from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as j}from"./Graphics3DSymbolLayer.js";import{geometryAsPolygon as S,createWaterGeometry as w,PolygonCreationDataBase as G}from"./polygonUtils.js";import{geometryToRenderInfo as A,geometryToRenderInfoDraped as E}from"../../support/renderInfoUtils/polygon.js";import{Object3D as L}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as O}from"../../webgl-engine/lib/RenderGeometry.js";import{WaterMaterialParameters as P,WaterMaterial as T}from"../../webgl-engine/materials/WaterMaterial.js";import{wavePresets as R}from"../../webgl-engine/materials/internal/waterMaterialUtils.js";const U=["polyline","polygon","extent"];class I 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,U,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.ensureMaterial(),this.draped?this._createAsOverlay(t):this._createAs3DShape(t,r,t.uid)}ensureMaterial(){if(null!=this._material)return;const t=new P,r=this.symbolLayer.color;null!=r&&(t.color=e.toUnitRGBA(r));const o=this._getCombinedOpacity(r,{hasIntrinsicColor:!0});t.color=[t.color[0],t.color[1],t.color[2],o],t.transparent=o<1||this.needsDrivenTransparentPass,t.waveDirection=null!=this.symbolLayer.waveDirection?I.headingVectorFromAngle(this.symbolLayer.waveDirection):i(0,0);const n=this.symbolLayer.waveStrength+"-"+this.symbolLayer.waterbodySize,s=R[n];t.waveStrength=s.waveStrength,t.waveTextureRepeat=s.textureRepeat,t.waveVelocity=s.waveVelocity,t.flowStrength=s.perturbationStrength,t.hasSlicePlane=this._context.slicePlaneEnabled,t.isDraped=this.draped,this._material=new T(t),this._context.stage.add(this._material)}layerOpacityChanged(){if(null==this._material)return;const e=this._material.parameters.color,t=this._getCombinedOpacity(this.symbolLayer.color,{hasIntrinsicColor:!0}),r=t<1||this.needsDrivenTransparentPass;this._material.setParameters({color:[e[0],e[1],e[2],t],transparent:r})}layerElevationInfoChanged(e,t,r){const o=this._elevationContext.mode,i=x(I.elevationModeChangeTypes,r,o);if(i!==v.UPDATE)return i;const n=b(o);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>n))}slicePlaneEnabledChanged(){return null!=this._material&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,r){const o=S(e.geometry);if(null==o)return null;const i=A(o,this._context.elevationProvider,this._context.renderCoordsHelper,t),n=i.position.length/3,s=y(2*n);this._createUVCoordsFromVertices(s,i.mapPositions,n,this._context.elevationProvider.spatialReference);const a=new z(i,s,this._context.layer.uid,e.uid);if(a.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(a),this._create3DShapeGeometries(a),this._logGeometryCreationWarnings(a.renderData,o.rings,"rings","WaterSymbol3DLayer"),0===a.outGeometries.length)return null;const l=new L({geometries:a.outGeometries,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),c=new D(this,l,a.outGeometries,null,null,_,t);return c.alignedSampledElevation=a.renderData.sampledElevation,c.needsElevationUpdates=b(t.mode),c}_createUVCoordsFromVertices(e,r,i,n){const a=t(n);p(B);for(let t=0;t<i;t++)o(M,r[3*t],r[3*t+1]),g(B,M);s(B,B,a);const l=B[0]%I.unitSizeOfTexture,c=B[1]%I.unitSizeOfTexture;V[0]=B[0]-l,V[1]=B[1]-c;for(let t=0;t<i;t++)e[2*t]=(r[3*t]*a-V[0])/I.unitSizeOfTexture,e[2*t+1]=(r[3*t+1]*a-V[1])/I.unitSizeOfTexture}_create3DShapeGeometries(e){const t=e.renderData.polygons,o=e.uvCoords;for(const{count:i,index:n,position:s,mapPositions:a,holeIndices:l}of t){if(null!=this._context.clippingExtent&&(c(W),h(W,a),!m(W,this._context.clippingExtent)))continue;const t=r(a,l,3);if(0===t.length)continue;const u=f(o,2*n,2*i),d=w({material:this._material,indices:t,mapPositions:a,attributeData:{position:s,uv0:u}},e.objectAndLayerIdColor);e.outGeometries.push(d)}}_createAsOverlay(e){const t=S(e.geometry);if(null==t)return null;this._material.renderPriority=this._renderPriority;const r=E(t,this._context.overlaySR),o=r.position.length/3,i=y(2*o);this._createUVCoordsFromVertices(i,r.position,o,this._context.overlaySR);const n=new k(r,i,this._context.layer.uid,e.uid);return n.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),n.outBoundingBox=c(),this._createAsOverlayWater(n),this._logGeometryCreationWarnings(n.renderData,t.rings,"rings","WaterSymbol3DLayer"),0===n.outGeometries.length?null:new C(this,n.outGeometries,n.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayWater(e){const t=e.uvCoords,o=e.renderData.polygons;for(const{position:i,holeIndices:n,index:s,count:a}of o){if(c(W),h(W,i),!m(W,this._context.clippingExtent))continue;u(e.outBoundingBox,W);const o=r(i,n,3);if(0===o.length)continue;const l=f(t,2*s,2*a),d=w({material:this._material,indices:o,attributeData:{position:i,uv0:l}},e.objectAndLayerIdColor);e.outGeometries.push(new O(d,e))}}static headingVectorFromAngle(e){const t=n(),r=a(e);return t[0]=Math.sin(r),t[1]=Math.cos(r),t}test(){return{...super.test(),create3DShape:e=>this._createAs3DShape(e.graphic,e.elevationContext,e.graphicUid),ensureMaterial:()=>this.ensureMaterial()}}}I.unitSizeOfTexture=100,I.elevationModeChangeTypes={definedChanged:v.RECREATE,staysOnTheGround:v.NONE,onTheGroundChanged:v.RECREATE};const V=n(),B=d(),M=n(),W=l();class z extends G{constructor(e,t,r,o){super(e,r,o),this.uvCoords=t}}class k extends G{constructor(e,t,r,o){super(e,r,o),this.uvCoords=t}}export{I as Graphics3DWaterSymbolLayer};