@arcgis/core 4.31.0-next.20240821 → 4.31.0-next.20240823

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 (376) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{24e38b7d1e9984a1472e.js → 033032715c3b04e0fc7d.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{cfc93bbd35cc4bfde7c0.js → 045336db17aae6eef68f.js} +1 -1
  4. package/assets/esri/core/workers/chunks/04de7b2937d5ca7c23e2.js +1 -0
  5. package/assets/esri/core/workers/chunks/12a4b3706162872c2b41.js +769 -0
  6. package/assets/esri/core/workers/chunks/142b1336533fa2ac470b.js +47 -0
  7. package/assets/esri/core/workers/chunks/185e596f86767c22f951.js +1 -0
  8. package/assets/esri/core/workers/chunks/{cd8d595d577b74817623.js → 1a4b3820136fb615b730.js} +1 -1
  9. package/assets/esri/core/workers/chunks/29b157b41dfa16da886b.js +1 -0
  10. package/assets/esri/core/workers/chunks/300b57846114fedd12be.js +1 -0
  11. package/assets/esri/core/workers/chunks/{3f75b7ed24b440b4508a.js → 3d5f37c2f355260e6dc6.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{a9eba26d62b62592cee1.js → 42861d54a336146753d8.js} +1 -1
  13. package/assets/esri/core/workers/chunks/4c8deac4bf72a5e2597a.js +1 -0
  14. package/assets/esri/core/workers/chunks/52107d450c55450f5c04.js +274 -0
  15. package/assets/esri/core/workers/chunks/6d54222301b6d819c904.js +1 -0
  16. package/assets/esri/core/workers/chunks/{eb0f180ed20af220a82e.js → 6ddece9cd94b60efe3d7.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{566844774388a031fd74.js → 7125cff7fd288ff7bd5f.js} +1 -1
  18. package/assets/esri/core/workers/chunks/74de734a20b4cd2d7efb.js +1 -0
  19. package/assets/esri/core/workers/chunks/7712a23dc68220edaa64.js +1 -0
  20. package/assets/esri/core/workers/chunks/{ea561b2460e634a643fc.js → 7f35380809e7de99c302.js} +1 -1
  21. package/assets/esri/core/workers/chunks/7f3d49b667e9b46449e7.js +1 -0
  22. package/assets/esri/core/workers/chunks/8a2faf12938e811a9fc9.js +1 -0
  23. package/assets/esri/core/workers/chunks/{796c64b9caa1303e26ed.js → 8af503fa88c1668872eb.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{e2a6f77c05d0818e3f74.js → 8e42ce8305cefba5debc.js} +1 -1
  25. package/assets/esri/core/workers/chunks/93169e55e472fec4bc50.js +1 -0
  26. package/assets/esri/core/workers/chunks/985c1f42aab564008c0d.js +1 -0
  27. package/assets/esri/core/workers/chunks/9a32d9d720cb81abfba2.js +1 -0
  28. package/assets/esri/core/workers/chunks/b171d57b4d0142f687d0.js +1 -0
  29. package/assets/esri/core/workers/chunks/d5e376893cd47605a438.js +1 -0
  30. package/assets/esri/core/workers/chunks/df9daac7ea581e9e5ca4.js +1 -0
  31. package/assets/esri/core/workers/chunks/f11ae249cc8e995bbccc.js +1 -0
  32. package/assets/esri/core/workers/chunks/{65d8011cf756b066cade.js → f218316de8b4635653b2.js} +1 -1
  33. package/assets/esri/libs/linkchartlayout/lclayout.wasm +0 -0
  34. package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
  35. package/assets/esri/themes/base/_core.scss +2 -0
  36. package/assets/esri/themes/base/widgets/_Grid.scss +0 -8
  37. package/assets/esri/themes/base/widgets/_GridControls.scss +86 -0
  38. package/assets/esri/themes/base/widgets/_Print.scss +13 -15
  39. package/assets/esri/themes/dark/main.css +1 -1
  40. package/assets/esri/themes/light/main.css +1 -1
  41. package/assets/esri/themes/light/view.css +1 -1
  42. package/assets/esri/widgets/Print/t9n/Print.json +1 -1
  43. package/assets/esri/widgets/Print/t9n/Print_ar.json +1 -1
  44. package/assets/esri/widgets/Print/t9n/Print_bg.json +1 -1
  45. package/assets/esri/widgets/Print/t9n/Print_bs.json +1 -1
  46. package/assets/esri/widgets/Print/t9n/Print_ca.json +1 -1
  47. package/assets/esri/widgets/Print/t9n/Print_cs.json +1 -1
  48. package/assets/esri/widgets/Print/t9n/Print_da.json +1 -1
  49. package/assets/esri/widgets/Print/t9n/Print_de.json +1 -1
  50. package/assets/esri/widgets/Print/t9n/Print_el.json +1 -1
  51. package/assets/esri/widgets/Print/t9n/Print_en.json +1 -1
  52. package/assets/esri/widgets/Print/t9n/Print_es.json +1 -1
  53. package/assets/esri/widgets/Print/t9n/Print_et.json +1 -1
  54. package/assets/esri/widgets/Print/t9n/Print_fi.json +1 -1
  55. package/assets/esri/widgets/Print/t9n/Print_fr.json +1 -1
  56. package/assets/esri/widgets/Print/t9n/Print_he.json +1 -1
  57. package/assets/esri/widgets/Print/t9n/Print_hr.json +1 -1
  58. package/assets/esri/widgets/Print/t9n/Print_hu.json +1 -1
  59. package/assets/esri/widgets/Print/t9n/Print_id.json +1 -1
  60. package/assets/esri/widgets/Print/t9n/Print_it.json +1 -1
  61. package/assets/esri/widgets/Print/t9n/Print_ja.json +1 -1
  62. package/assets/esri/widgets/Print/t9n/Print_ko.json +1 -1
  63. package/assets/esri/widgets/Print/t9n/Print_lt.json +1 -1
  64. package/assets/esri/widgets/Print/t9n/Print_lv.json +1 -1
  65. package/assets/esri/widgets/Print/t9n/Print_nb.json +1 -1
  66. package/assets/esri/widgets/Print/t9n/Print_nl.json +1 -1
  67. package/assets/esri/widgets/Print/t9n/Print_pl.json +1 -1
  68. package/assets/esri/widgets/Print/t9n/Print_pt-BR.json +1 -1
  69. package/assets/esri/widgets/Print/t9n/Print_pt-PT.json +1 -1
  70. package/assets/esri/widgets/Print/t9n/Print_ro.json +1 -1
  71. package/assets/esri/widgets/Print/t9n/Print_ru.json +1 -1
  72. package/assets/esri/widgets/Print/t9n/Print_sk.json +1 -1
  73. package/assets/esri/widgets/Print/t9n/Print_sl.json +1 -1
  74. package/assets/esri/widgets/Print/t9n/Print_sr.json +1 -1
  75. package/assets/esri/widgets/Print/t9n/Print_sv.json +1 -1
  76. package/assets/esri/widgets/Print/t9n/Print_th.json +1 -1
  77. package/assets/esri/widgets/Print/t9n/Print_tr.json +1 -1
  78. package/assets/esri/widgets/Print/t9n/Print_uk.json +1 -1
  79. package/assets/esri/widgets/Print/t9n/Print_vi.json +1 -1
  80. package/assets/esri/widgets/Print/t9n/Print_zh-CN.json +1 -1
  81. package/assets/esri/widgets/Print/t9n/Print_zh-HK.json +1 -1
  82. package/assets/esri/widgets/Print/t9n/Print_zh-TW.json +1 -1
  83. package/assets/esri/widgets/support/GridControls/t9n/GridControls.json +1 -0
  84. package/assets/esri/widgets/support/GridControls/t9n/GridControls_en.json +1 -0
  85. package/chunks/CloudsComposition.glsl.js +3 -3
  86. package/chunks/ComponentShader.glsl.js +53 -61
  87. package/chunks/DefaultMaterial.glsl.js +1 -1
  88. package/chunks/FocusAreaColor.glsl.js +12 -0
  89. package/chunks/FocusAreaMask.glsl.js +5 -0
  90. package/chunks/Laserlines.glsl.js +1 -1
  91. package/chunks/Path.glsl.js +22 -17
  92. package/chunks/PointRenderer.glsl.js +3 -3
  93. package/chunks/Precipitation.glsl.js +1 -1
  94. package/chunks/Terrain.glsl.js +1 -1
  95. package/chunks/WaterSurface.glsl.js +18 -18
  96. package/chunks/boundedPlane.js +1 -1
  97. package/chunks/cameraUtilsPlanar.js +1 -1
  98. package/chunks/cameraUtilsSpherical.js +1 -1
  99. package/chunks/sphere.js +1 -1
  100. package/chunks/terrainUtilsPlanar.js +1 -1
  101. package/chunks/vec32.js +1 -1
  102. package/chunks/vxlLayer.js +1 -1
  103. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  104. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  105. package/core/mathUtils.js +1 -1
  106. package/core/perspectiveUtils.js +1 -1
  107. package/exports/csv.js +1 -1
  108. package/geometry/operators/support/converterAPI.js +1 -1
  109. package/geometry/projection/localLinearScaleFactors.js +1 -1
  110. package/geometry/support/buffer/internals/Vec3.js +1 -1
  111. package/geometry/support/clipRay.js +1 -1
  112. package/geometry/support/coordinateSystem.js +1 -1
  113. package/geometry/support/frustum.js +1 -1
  114. package/geometry/support/heightModelInfoUtils.js +1 -1
  115. package/geometry/support/lineSegment.js +1 -1
  116. package/geometry/support/meshUtils/exporters/gltf/geometry.js +1 -1
  117. package/geometry/support/meshUtils/rotate.js +1 -1
  118. package/geometry/support/meshUtils/scale.js +1 -1
  119. package/geometry/support/plane.js +1 -1
  120. package/geometry/support/polygonUtils.js +1 -1
  121. package/geometry/support/ray.js +1 -1
  122. package/geometry/support/sphere.js +1 -1
  123. package/geometry/support/sphereUtils.js +5 -0
  124. package/geometry/support/triangle.js +1 -1
  125. package/geometry/support/vector.js +1 -1
  126. package/interfaces.d.ts +68 -9
  127. package/layers/FocusAreaLayer.js +5 -0
  128. package/layers/VoxelLayer.js +1 -1
  129. package/layers/VoxelWasmPerSceneView.js +1 -1
  130. package/layers/mixins/operationalLayerModuleMap.js +1 -1
  131. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  132. package/layers/video/VideoCameraSensorModel.js +1 -1
  133. package/package.json +1 -1
  134. package/support/revision.js +1 -1
  135. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  136. package/symbols/support/Symbol3DFillMaterial.js +1 -1
  137. package/symbols/support/Symbol3DMaterial.js +1 -1
  138. package/views/2d/engine/webgl/AFeatureTile.js +1 -1
  139. package/views/2d/engine/webgl/WorldExtentClipRenderer.js +1 -1
  140. package/views/2d/grid/GridView2D.js +1 -1
  141. package/views/2d/grid/constants.js +5 -0
  142. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  143. package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
  144. package/views/2d/layerViewModuleImportUtils.js +1 -1
  145. package/views/2d/support/highlightGroupUtils.js +1 -1
  146. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  147. package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
  148. package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
  149. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  150. package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
  151. package/views/3d/analysis/Slice/ShiftManipulator.js +1 -1
  152. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  153. package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
  154. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  155. package/views/3d/analysis/Viewshed/FieldOfViewManipulation.js +1 -1
  156. package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
  157. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  158. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  159. package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
  160. package/views/3d/analysis/Viewshed/viewshedToolUtils.js +1 -1
  161. package/views/3d/analysis/support/measurementUtils.js +1 -1
  162. package/views/3d/animation/pointToPoint/Animation.js +1 -1
  163. package/views/3d/animation/pointToPoint/Camera.js +1 -1
  164. package/views/3d/camera/constraintUtils/common.js +1 -1
  165. package/views/3d/camera/constraintUtils/surfaceCollision.js +1 -1
  166. package/views/3d/camera/constraintUtils/tilt.js +1 -1
  167. package/views/3d/camera/intersectionUtils.js +1 -1
  168. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  169. package/views/3d/environment/CloudsComposition.glsl.js +1 -1
  170. package/views/3d/environment/CloudsParameters.js +1 -1
  171. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  172. package/views/3d/environment/Fog.js +1 -1
  173. package/views/3d/environment/MarsAtmosphere.js +1 -1
  174. package/views/3d/interactive/Manipulator3D.js +1 -1
  175. package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
  176. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  177. package/views/3d/interactive/editingTools/lineObjectVisualElementUtils.js +1 -1
  178. package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
  179. package/views/3d/interactive/editingTools/manipulations/MoveXYDiscManipulation.js +1 -1
  180. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  181. package/views/3d/interactive/editingTools/originGeometryVisualElementUtils.js +1 -1
  182. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  183. package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
  184. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  185. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  186. package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
  187. package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
  188. package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
  189. package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
  190. package/views/3d/layerViewModuleImportUtils.js +1 -1
  191. package/views/3d/layers/FocusAreaLayerView3D.js +5 -0
  192. package/views/3d/layers/I3SMeshView3D.js +1 -1
  193. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  194. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  195. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  196. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  197. package/views/3d/layers/VoxelGraphic.js +5 -0
  198. package/views/3d/layers/VoxelLayerView3D.js +1 -1
  199. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  200. package/views/3d/layers/graphics/ElevationAligners.js +1 -1
  201. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  202. package/views/3d/layers/graphics/Graphics3DDrapedGraphicLayer.js +1 -1
  203. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  204. package/views/3d/layers/graphics/Graphics3DLodInstanceGraphicLayer.js +1 -1
  205. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  206. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  207. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  208. package/views/3d/layers/graphics/elevationAlignmentUtils.js +1 -1
  209. package/views/3d/layers/graphics/labelPlacement.js +1 -1
  210. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  211. package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
  212. package/views/3d/layers/i3s/I3SUtil.js +1 -1
  213. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  214. package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
  215. package/views/3d/layers/i3s/LoDUtil.js +1 -1
  216. package/views/3d/layers/i3s/PointRenderer.js +1 -1
  217. package/views/3d/layers/support/FastSymbolUpdates.js +1 -1
  218. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  219. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  220. package/views/3d/layers/support/uvUtils.js +1 -1
  221. package/views/3d/state/NearFarHeuristic.js +1 -1
  222. package/views/3d/state/ViewStateManager.js +1 -1
  223. package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
  224. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  225. package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
  226. package/views/3d/state/controllers/RotateController.js +1 -1
  227. package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
  228. package/views/3d/state/controllers/ZoomControllerLocal.js +1 -1
  229. package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
  230. package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
  231. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  232. package/views/3d/state/utils/navigationUtils.js +1 -1
  233. package/views/3d/state/utils/viewUtils.js +1 -1
  234. package/views/3d/support/FrustumExtentIntersection.js +1 -1
  235. package/views/3d/support/cameraUtilsInternal.js +1 -1
  236. package/views/3d/support/geometryUtils/ray.js +1 -1
  237. package/views/3d/support/intersectionUtils.js +1 -1
  238. package/views/3d/support/mathUtils.js +1 -1
  239. package/views/3d/support/orientedBoundingBox.js +1 -1
  240. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  241. package/views/3d/support/sunUtils.js +1 -1
  242. package/views/3d/support/viewpointUtils.js +1 -1
  243. package/views/3d/terrain/OverlayRenderer.js +1 -1
  244. package/views/3d/terrain/PatchRenderData.js +1 -1
  245. package/views/3d/terrain/SphericalPatch.js +1 -1
  246. package/views/3d/terrain/TerrainRenderer.js +1 -1
  247. package/views/3d/terrain/TerrainSurface.js +1 -1
  248. package/views/3d/terrain/Tile.js +1 -1
  249. package/views/3d/terrain/isTerrainSurfaceLayer.js +1 -1
  250. package/views/3d/webgl/RenderCamera.js +1 -1
  251. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  252. package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
  253. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  254. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  255. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  256. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentShader.glsl.js +1 -1
  257. package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
  258. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  259. package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +1 -1
  260. package/views/3d/webgl-engine/core/shaderLibrary/attributes/InstancedDoublePrecision.glsl.js +1 -1
  261. package/views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js +1 -1
  262. package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +2 -6
  263. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +2 -2
  264. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeFragmentNormals.glsl.js +13 -0
  265. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientLighting.glsl.js +1 -1
  266. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +11 -13
  267. package/views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js +4 -4
  268. package/views/3d/webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRendering.glsl.js +1 -4
  269. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadBaseColorTexture.glsl.js +3 -3
  270. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +1 -1
  271. package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +2 -2
  272. package/views/3d/webgl-engine/core/shaderLibrary/util/ScreenSizePerspective.glsl.js +1 -1
  273. package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
  274. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorRenderNodeTechnique.js +5 -0
  275. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskRenderNodeTechnique.js +5 -0
  276. package/views/3d/webgl-engine/effects/focusArea/FocusAreaParameters.js +5 -0
  277. package/views/3d/webgl-engine/effects/focusArea/FocusAreaRenderNode.js +5 -0
  278. package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
  279. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
  280. package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
  281. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  282. package/views/3d/webgl-engine/lib/Intersector.js +1 -1
  283. package/views/3d/webgl-engine/lib/Object3D.js +1 -1
  284. package/views/3d/webgl-engine/lib/Octree.js +1 -1
  285. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  286. package/views/3d/webgl-engine/lib/Path.js +1 -1
  287. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  288. package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
  289. package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
  290. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  291. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  292. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  293. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  294. package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
  295. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  296. package/views/3d/webgl-engine/lib/lodRendering/InstanceData.js +1 -1
  297. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  298. package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
  299. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  300. package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
  301. package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
  302. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  303. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  304. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  305. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  306. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  307. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  308. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  309. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  310. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  311. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  312. package/views/3d/webgl-engine/shaders/FocusAreaColor.glsl.js +5 -0
  313. package/views/3d/webgl-engine/shaders/FocusAreaMask.glsl.js +5 -0
  314. package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +8 -8
  315. package/views/3d/webgl-engine/shaders/Path.glsl.js +1 -1
  316. package/views/draw/support/helpMessageUtils3d.js +1 -1
  317. package/views/draw/support/surfaceCoordinateSystems.js +1 -1
  318. package/views/input/gamepad/GamepadSource.js +1 -1
  319. package/views/interactive/coordinateHelper.js +1 -1
  320. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  321. package/views/interactive/sketch/constraints.js +1 -1
  322. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  323. package/views/interactive/snapping/GridSnappingEngine.js +5 -0
  324. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  325. package/views/interactive/snapping/SnappingOptions.js +1 -1
  326. package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
  327. package/views/interactive/snapping/snappingUtils.js +1 -1
  328. package/views/navigation/PanPlanarMomentumEstimator.js +1 -1
  329. package/views/support/angularMeasurementUtils.js +1 -1
  330. package/views/support/euclideanAreaMeasurementUtils.js +1 -1
  331. package/views/support/euclideanLengthMeasurementUtils.js +1 -1
  332. package/views/support/geometry3dUtils.js +1 -1
  333. package/webscene/Slide.js +1 -1
  334. package/widgets/CoordinateConversion/support/formatUtils.js +1 -1
  335. package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
  336. package/widgets/Feature/FeatureMedia.js +1 -1
  337. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  338. package/widgets/FeatureTable/Grid/Column.js +1 -1
  339. package/widgets/FeatureTable.js +1 -1
  340. package/widgets/GridControls/GridControlsViewModel.d.ts +4 -0
  341. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  342. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  343. package/widgets/Print/CustomTemplate.js +1 -1
  344. package/widgets/Print/PrintViewModel.js +1 -1
  345. package/widgets/Print/TemplateOptions.js +1 -1
  346. package/widgets/Print/utils.js +5 -0
  347. package/widgets/Print.js +1 -1
  348. package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
  349. package/widgets/support/GridControls/GridControlsViewModel.d.ts +4 -0
  350. package/widgets/support/GridControls/GridControlsViewModel.js +5 -0
  351. package/widgets/support/GridControls/VisibleElements.js +5 -0
  352. package/widgets/support/GridControls/gridUtils.js +5 -0
  353. package/widgets/support/GridControls.d.ts +4 -0
  354. package/widgets/support/GridControls.js +5 -0
  355. package/widgets/support/exportUtils.js +1 -1
  356. package/assets/esri/core/workers/chunks/14dc47896456e3c66b24.js +0 -1
  357. package/assets/esri/core/workers/chunks/2e88af8ab1e2713e7655.js +0 -1
  358. package/assets/esri/core/workers/chunks/3b204e75b613bcfbc8b9.js +0 -1
  359. package/assets/esri/core/workers/chunks/3e57f493d5a9d7aa7a48.js +0 -1
  360. package/assets/esri/core/workers/chunks/4e5ae81c612543130d9a.js +0 -1
  361. package/assets/esri/core/workers/chunks/4e746f8fca1d932dd684.js +0 -1
  362. package/assets/esri/core/workers/chunks/544eec13338b2d71680f.js +0 -1
  363. package/assets/esri/core/workers/chunks/5e7e12863cbed07451d0.js +0 -1
  364. package/assets/esri/core/workers/chunks/6c129767cda74aa672e0.js +0 -1
  365. package/assets/esri/core/workers/chunks/6f7c2d02fbd29870f6ee.js +0 -1
  366. package/assets/esri/core/workers/chunks/7802e70422f4151b95bc.js +0 -1
  367. package/assets/esri/core/workers/chunks/920557db2bd107a3c579.js +0 -1
  368. package/assets/esri/core/workers/chunks/9443b9ec03f25c723c2c.js +0 -47
  369. package/assets/esri/core/workers/chunks/991295637f51e8207efe.js +0 -1
  370. package/assets/esri/core/workers/chunks/ace8b6351ed35b03499b.js +0 -1
  371. package/assets/esri/core/workers/chunks/b1e4896acfae0bf9a9a8.js +0 -1
  372. package/assets/esri/core/workers/chunks/ca12b1c470e67ca7b30e.js +0 -1
  373. package/assets/esri/core/workers/chunks/cd9f48dcee2a1fc261ed.js +0 -774
  374. package/assets/esri/core/workers/chunks/d3626c01d2569d84e01e.js +0 -1
  375. package/assets/esri/core/workers/chunks/e5474bcde5b8fa037b56.js +0 -278
  376. package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js +0 -31
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import t from"../../../../core/Error.js";import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as i,invertOrIdentity as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{c,n as m,s as p,f as h,b as g,h as d,z as u}from"../../../../chunks/vec32.js";import{fromArray as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as _,empty as x,expandWithBuffer as S,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as P}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as E,getZeroIndexArray as w}from"../../../../geometry/support/Indices.js";import{a as O}from"../../../../chunks/vec3.js";import{makeVertexCandidate as C,makeEdgeCandidate as M}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as I}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as v}from"../../../ViewingMode.js";import{needsElevationUpdates3D as A,SampleElevationInfo as L}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as z,Graphics3DObject3DGraphicLayer as B}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as R,computeCentroid as T}from"./graphicUtils.js";import{ApplyRendererDiffResult as U}from"./interfaces.js";import{geometryAsPolygon as G}from"./polygonUtils.js";import{createMaterial as N}from"../support/edgeUtils.js";import{debugFlags as V}from"../../support/debugFlags.js";import{SamplePosition as F}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as k}from"../../support/renderInfoUtils/polygon.js";import{NormalType as H}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as W}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as q}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Z}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as J}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as K}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as Q,compressNormal as X}from"../../webgl-engine/lib/Normals.js";import{Object3D as Y}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as $}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as tt}from"../../webgl-engine/materials/DefaultMaterial.js";const et=["polygon","extent"];class rt extends D{constructor(t,e,r,s){super(t,e,r,s),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const e=R(this._getSymbolSize());if(e)throw new t("graphics3dextrudesymbollayer:invalid-size",e)}const e=this.symbolLayer?.material?.color,r=this._getCombinedOpacityAndColor(e),s=f(r),o=r[3],n=o<1||this.needsDrivenTransparentPass,i={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:s,ambient:s,opacity:o,transparent:n,cullFace:n?q.None:q.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0,normalType:H.Compressed};this._materials[Mt.Main]=new tt(i),this._materials[Mt.Bottom]=new tt({...i,cullFace:q.Back}),this._context.stage.addMany(this._materials)}destroy(){super.destroy(),this._context.stage.removeMany(this._materials),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,et,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(t.renderingInfo,255),s=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this.symbolLayer?.material?.color,s=this._getCombinedOpacity(r),o=s<1||this.needsDrivenTransparentPass;this._materials[Mt.Main]?.setParameters({opacity:s,transparent:o}),this._materials[Mt.Bottom]?.setParameters({opacity:s,transparent:o});const n=this._getLayerOpacity();t.forEach((t=>e(t)?.layerOpacityChanged(n,this._context.isAsync)))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,A)}slicePlaneEnabledChanged(t,e){return this._materials[Mt.Main]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[Mt.Bottom]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t.forEach((t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[Mt.Main]?.setParameters(t),this._materials[Mt.Bottom]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?I(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?U.RecreateSymbol:U.RecreateGraphics}async queryForSnapping(t,s,o,n){const i=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/r(s),{objectId:a,target:l}=t,c=e(l);switch(c.z=(c.z??0)+i,t.type){case"edge":{const{start:r,end:s}=t,o=e(r),n=e(s);return o.z=(o.z??0)+i,n.z=(n.z??0)+i,[M(a,c,1/0,o,n)]}case"vertex":return[C(a,c,1/0),M(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,a,c){const m=G(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=k(m,this._context.elevationProvider,this._context.renderCoordsHelper,a);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=T(m);if(null==h)return null;const g=new Array,d=new Array,u=_(),f=l(),w=y(),C=this._context.renderCoordsHelper.viewingMode===v.Global;C||this._context.renderCoordsHelper.worldUpAtPosition(null,w),b(m.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const M=l();i(M,f);const I=n();o(I,M);const{polygons:L,mapPositions:D,position:R}=p,U=new Map,V=this._materials[Mt.Main];for(const o of L){const t=o.count;if(this._context.clippingExtent&&(x(u),S(u,o.mapPositions),!j(u,this._context.clippingExtent)))continue;const n=s(o.mapPositions,o.holeIndices,3);if(0===n.length)continue;const i=n.length,a=6*t,l=E(a+i),m=E(i),p=P(3*a),h=P(3*a),y=P(3*a),b=P(a);ot(R,D,n,o,p,y,h,b,l,m,this._getExtrusionSize(e),w,C),O(p,p,M);const _=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerUid:this._context.layer.uid}),I=new It(p,y,Q(h),b),v=st(V,l,l.length-m.length,I,r,_),A=t,L=t,z=2*o.count,B=new vt(A,L,z,i/3);yt(v,B,f),U.set(v,B),g.push(v,st(this._materials[Mt.Bottom],m,0,I,r,_)),d.push(I.heights)}if(0===g.length)return null;const F=new Y({geometries:g,layerUid:this._context.layer.uid,graphicUid:c,isElevationSource:!0});F.transformation=f;const H=N(this.symbolLayer,{opacity:this._getLayerOpacity()}),W=H?new z(this._materials[Mt.Main],H,this._context.slicePlaneEnabled):null,q=new B(this,F,g,null,null,((t,e,r,s,o)=>ft(t,e,r,s,o,d,U)),a,W);return q.alignedSampledElevation=p.sampledElevation,q.needsElevationUpdates=A(a.mode),q}}function st(t,e,r,s,o,n){const i=w(e.length),a=[[$.POSITION,new W(s.positions,e,3,!0)],[$.NORMALCOMPRESSED,new W(s.normals,e,2,!0)],[$.COLOR,new W(o,i,4,!0)]];return new J(t,a,s.elevation,Z.Mesh,n,r)}function ot(t,e,r,s,o,n,i,a,l,c,m,p,h){{const g=r.length/3,d=2*s.count;nt(t,e,s.index,s.count,r,0,g,o,n,i,a,l,c,d,m,p,h)}{let t=0,e=2*s.count,r=0;const c=s.pathLengths[0];lt(o,n,a,i,t,c,s.count,e,l,r,m),e+=4*c,r+=2*c,t+=c;for(let p=1;p<s.pathLengths.length;++p){const c=s.pathLengths[p];lt(o,n,a,i,t,c,s.count,e,l,r,m),e+=4*c,r+=2*c,t+=c}}}function nt(t,e,r,s,o,n,i,a,l,p,h,g,d,u,f,y,b){c(_t,y);{const o=f>0?1:-1;let n=3*r,i=0,c=3*i,g=s,d=3*g;for(let r=0;r<s;++r){const r=t[n],s=t[n+1],u=t[n+2];b&&(_t[0]=r,_t[1]=s,_t[2]=u,m(_t,_t)),a[c+0]=r,a[c+1]=s,a[c+2]=u;const y=e[n+0],_=e[n+1],x=e[n+2];l[c+0]=y,l[c+1]=_,l[c+2]=x,p[c+0]=-o*_t[0],p[c+1]=-o*_t[1],p[c+2]=-o*_t[2],h[i]=0,a[d+0]=r+f*_t[0],a[d+1]=s+f*_t[1],a[d+2]=u+f*_t[2],l[d+0]=y,l[d+1]=_,l[d+2]=x,h[g]=f,c+=3,d+=3,n+=3,i+=1,g+=1}}{let t=3*n,e=0,r=3*u;const a=f<0?jt:St,l=f<0?St:jt;for(let n=0;n<i;++n)d[e]=o[t+a[0]],d[e+1]=o[t+a[1]],d[e+2]=o[t+a[2]],g[r]=o[t+l[0]]+s,g[r+1]=o[t+l[1]]+s,g[r+2]=o[t+l[2]]+s,e+=3,r+=3,t+=3}}function it(t,e,r,s,o,n,i){s[n]=s[i],i*=3,t[n*=3]=t[i],t[n+1]=t[i+1],t[n+2]=t[i+2],e[n]=e[i],e[n+1]=e[i+1],e[n+2]=e[i+2],r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2]}const at=y();function lt(t,e,r,s,o,n,i,a,l,c,m){let p=o,h=o+1,g=o+i,d=o+i+1,u=a,f=a+1,y=a+2*n,b=a+2*n+1;m<0&&(p=o+i+1,d=o);let _=3*c;for(let x=0;x<n;++x)x===n-1&&(h=o,m>0?d=o+i:p=o+i),dt(t,p,h,g,at),it(t,e,s,r,at,u,p),it(t,e,s,r,at,f,h),it(t,e,s,r,at,y,g),it(t,e,s,r,at,b,d),l[_]=u,l[_+1]=y,l[_+2]=b,l[_+3]=u,l[_+4]=b,l[_+5]=f,_+=6,p++,h++,g++,d++,u+=2,f+=2,y+=2,b+=2}const ct=y(),mt=y(),pt=y(),ht=y(),gt=y();function dt(t,e,r,s,o){e*=3,r*=3,s*=3,p(ct,t[e++],t[e++],t[e++]),p(mt,t[r++],t[r++],t[r++]),p(pt,t[s++],t[s++],t[s++]),h(ht,mt,ct),h(gt,pt,ct),g(o,gt,ht),m(o,o)}const ut=y();function ft(t,e,r,s,o,n,i){const c=t.stageObject,m=c.geometries,h=m.length,g="absolute-height"!==e.mode;let u=0;const f=c.transformation,y=a(l(),f);for(let a=0;a<h;a+=2){const t=m[a];if(!K(t))continue;const e=t.getMutableAttribute($.POSITION).data,l=n[a/2],h=new F(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let n=0;n<b;n++){ut[0]=e[t],ut[1]=e[t+1],ut[2]=e[t+2],s(h,xt),g&&(x+=xt.sampledElevation),V.TESTS_DISABLE_OPTIMIZATIONS?(p(bt,h.array[h.offset],h.array[h.offset+1],xt.z+l[t/3]),null!=r&&o.toRenderCoords(bt,r,bt),d(bt,bt,y)):(p(bt,e[t],e[t+1],e[t+2]),d(bt,bt,f),o.setAltitude(bt,xt.z+l[t/3]),d(bt,bt,y)),e[t]=bt[0],e[t+1]=bt[1],e[t+2]=bt[2];const n=Pt/o.unitInMeters;(Math.abs(ut[0]-e[t])>=n||Math.abs(ut[1]-e[t+1])>=n||Math.abs(ut[2]-e[t+2])>=n)&&(_=!0),h.offset+=3,t+=3}}if(_){const e=i.get(t);e&&yt(t,e,f),c.geometryVertexAttributeUpdated(m[a],$.NORMALCOMPRESSED),t.invalidateBoundingInfo(),c.geometryVertexAttributeUpdated(m[a],$.POSITION),m[a+1].invalidateBoundingInfo(),c.geometryVertexAttributeUpdated(m[a+1],$.POSITION)}u+=x/b}return u/h}function yt(t,e,r){const s=t.getMutableAttribute($.POSITION),o=t.getMutableAttribute($.NORMALCOMPRESSED).data,{topVertexStart:n,topVertexCount:i,topFaceStart:a,topFaceCount:l}=e,c=s.data,h=i,f=t.attributes.get($.POSITION).indices,y=a+l,b=n+i,_=P(3*h);for(let m=0;m<h;++m){const t=3*m;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=Et,S=wt,j=Ot,E=Ct,w=_t;for(let P=a;P<y;++P){const t=3*P;for(let e=0;e<3;++e){const s=f[t+e];E[e]=s;const o=3*s;p(bt,c[o+0],c[o+1],c[o+2]),d(x[e],bt,r)}u(S,x[1],x[0]),u(j,x[2],x[0]),g(w,S,j),m(w,w);for(let e=0;e<3;++e){const t=3*(E[e]-n);_[t+0]+=w[0],_[t+1]+=w[1],_[t+2]+=w[2]}}for(let m=n;m<b;++m){const t=3*(m-n),e=_[t+0],r=_[t+1],s=_[t+2],i=Math.sqrt(e*e+r*r+s*s);X(o,m,e/i,r/i,s/i)}}const bt=y(),_t=y(),xt=new L,St=[0,2,1],jt=[0,1,2],Pt=.01,Et=[y(),y(),y()],wt=y(),Ot=y(),Ct=[0,0,0];var Mt;!function(t){t[t.Main=0]="Main",t[t.Bottom=1]="Bottom"}(Mt||(Mt={}));class It{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class vt{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{rt as Graphics3DExtrudeSymbolLayer};
5
+ import"../../../../core/has.js";import t from"../../../../core/Error.js";import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n,invertOrIdentity as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{L as c,c as m,n as p,a as h,f as g,b as d,h as u,z as f}from"../../../../chunks/vec32.js";import{fromArray as y,clone as b,ZEROS as _,create as x}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as S}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as j,empty as P,expandWithBuffer as E,intersectsClippingArea as w}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as O}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as v,getZeroIndexArray as C}from"../../../../geometry/support/Indices.js";import{a as M}from"../../../../chunks/vec3.js";import{makeVertexCandidate as I,makeEdgeCandidate as A}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as L}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as z}from"../../../ViewingMode.js";import{needsElevationUpdates3D as B,SampleElevationInfo as D}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as R,Graphics3DObject3DGraphicLayer as T}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as U}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G,computeCentroid as N}from"./graphicUtils.js";import{ApplyRendererDiffResult as V}from"./interfaces.js";import{geometryAsPolygon as F}from"./polygonUtils.js";import{createMaterial as k}from"../support/edgeUtils.js";import{debugFlags as H}from"../../support/debugFlags.js";import{SamplePosition as W}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as q}from"../../support/renderInfoUtils/polygon.js";import{NormalType as Z}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as J}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as K}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Q}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as X}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as Y}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as $,compressNormal as tt}from"../../webgl-engine/lib/Normals.js";import{Object3D as et}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as rt}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as st}from"../../webgl-engine/materials/DefaultMaterial.js";const ot=["polygon","extent"];class it extends U{constructor(t,e,r,s){super(t,e,r,s),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const e=G(this._getSymbolSize());if(e)throw new t("graphics3dextrudesymbollayer:invalid-size",e)}const e=this.symbolLayer?.material?.color,r=this._getCombinedOpacityAndColor(e),s=y(r),o=r[3],i=o<1||this.needsDrivenTransparentPass,n=this.symbolLayer?.material?.emissiveFactor,a=n?c(b(n)):_,l={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:s,ambient:s,opacity:o,transparent:i,cullFace:i?K.None:K.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,emissiveFactor:a,offsetTransparentBackfaces:!0,normalType:Z.Compressed};this._materials[At.Main]=new st(l),this._materials[At.Bottom]=new st({...l,cullFace:K.Back}),this._context.stage.addMany(this._materials)}destroy(){super.destroy(),this._context.stage.removeMany(this._materials),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,ot,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(t.renderingInfo,255),s=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this.symbolLayer?.material?.color,s=this._getCombinedOpacity(r),o=s<1||this.needsDrivenTransparentPass;this._materials[At.Main]?.setParameters({opacity:s,transparent:o}),this._materials[At.Bottom]?.setParameters({opacity:s,transparent:o});const i=this._getLayerOpacity();t.forEach((t=>e(t)?.layerOpacityChanged(i,this._context.isAsync)))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,B)}slicePlaneEnabledChanged(t,e){return this._materials[At.Main]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[At.Bottom]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t.forEach((t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[At.Main]?.setParameters(t),this._materials[At.Bottom]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?L(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?V.RecreateSymbol:V.RecreateGraphics}async queryForSnapping(t,s,o,i){const n=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/r(s),{objectId:a,target:l}=t,c=e(l);switch(c.z=(c.z??0)+n,t.type){case"edge":{const{start:r,end:s}=t,o=e(r),i=e(s);return o.z=(o.z??0)+n,i.z=(i.z??0)+n,[A(a,c,1/0,o,i)]}case"vertex":return[I(a,c,1/0),A(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,a,c){const m=F(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=q(m,this._context.elevationProvider,this._context.renderCoordsHelper,a);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=N(m);if(null==h)return null;const g=new Array,d=new Array,u=j(),f=l(),y=x(),b=this._context.renderCoordsHelper.viewingMode===z.Global;b||this._context.renderCoordsHelper.worldUpAtPosition(null,y),S(m.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const _=l();n(_,f);const C=i();o(C,_);const{polygons:I,mapPositions:A,position:L}=p,D=new Map,U=this._materials[At.Main];for(const o of I){const t=o.count;if(this._context.clippingExtent&&(P(u),E(u,o.mapPositions),!w(u,this._context.clippingExtent)))continue;const i=s(o.mapPositions,o.holeIndices,3);if(0===i.length)continue;const n=i.length,a=6*t,l=v(a+n),m=v(n),p=O(3*a),h=O(3*a),x=O(3*a),S=O(a);at(L,A,i,o,p,x,h,S,l,m,this._getExtrusionSize(e),y,b),M(p,p,_);const j=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerUid:this._context.layer.uid}),C=new Lt(p,x,$(h),S),I=nt(U,l,l.length-m.length,C,r,j),z=t,B=t,R=2*o.count,T=new zt(z,B,R,n/3);xt(I,T,f),D.set(I,T),g.push(I,nt(this._materials[At.Bottom],m,0,C,r,j)),d.push(C.heights)}if(0===g.length)return null;const G=new et({geometries:g,layerUid:this._context.layer.uid,graphicUid:c,isElevationSource:!0});G.transformation=f;const V=k(this.symbolLayer,{opacity:this._getLayerOpacity()}),H=V?new R(this._materials[At.Main],V,this._context.slicePlaneEnabled):null,W=new T(this,G,g,null,null,((t,e,r,s,o)=>_t(t,e,r,s,o,d,D)),a,H);return W.alignedSampledElevation=p.sampledElevation,W.needsElevationUpdates=B(a.mode),W}}function nt(t,e,r,s,o,i){const n=C(e.length),a=[[rt.POSITION,new J(s.positions,e,3,!0)],[rt.NORMALCOMPRESSED,new J(s.normals,e,2,!0)],[rt.COLOR,new J(o,n,4,!0)]];return new X(t,a,s.elevation,Q.Mesh,i,r)}function at(t,e,r,s,o,i,n,a,l,c,m,p,h){{const g=r.length/3,d=2*s.count;lt(t,e,s.index,s.count,r,0,g,o,i,n,a,l,c,d,m,p,h)}{let t=0,e=2*s.count,r=0;const c=s.pathLengths[0];pt(o,i,a,n,t,c,s.count,e,l,r,m),e+=4*c,r+=2*c,t+=c;for(let p=1;p<s.pathLengths.length;++p){const c=s.pathLengths[p];pt(o,i,a,n,t,c,s.count,e,l,r,m),e+=4*c,r+=2*c,t+=c}}}function lt(t,e,r,s,o,i,n,a,l,c,h,g,d,u,f,y,b){m(jt,y);{const o=f>0?1:-1;let i=3*r,n=0,m=3*n,g=s,d=3*g;for(let r=0;r<s;++r){const r=t[i],s=t[i+1],u=t[i+2];b&&(jt[0]=r,jt[1]=s,jt[2]=u,p(jt,jt)),a[m+0]=r,a[m+1]=s,a[m+2]=u;const y=e[i+0],_=e[i+1],x=e[i+2];l[m+0]=y,l[m+1]=_,l[m+2]=x,c[m+0]=-o*jt[0],c[m+1]=-o*jt[1],c[m+2]=-o*jt[2],h[n]=0,a[d+0]=r+f*jt[0],a[d+1]=s+f*jt[1],a[d+2]=u+f*jt[2],l[d+0]=y,l[d+1]=_,l[d+2]=x,h[g]=f,m+=3,d+=3,i+=3,n+=1,g+=1}}{let t=3*i,e=0,r=3*u;const a=f<0?wt:Et,l=f<0?Et:wt;for(let i=0;i<n;++i)d[e]=o[t+a[0]],d[e+1]=o[t+a[1]],d[e+2]=o[t+a[2]],g[r]=o[t+l[0]]+s,g[r+1]=o[t+l[1]]+s,g[r+2]=o[t+l[2]]+s,e+=3,r+=3,t+=3}}function ct(t,e,r,s,o,i,n){s[i]=s[n],n*=3,t[i*=3]=t[n],t[i+1]=t[n+1],t[i+2]=t[n+2],e[i]=e[n],e[i+1]=e[n+1],e[i+2]=e[n+2],r[i]=o[0],r[i+1]=o[1],r[i+2]=o[2]}const mt=x();function pt(t,e,r,s,o,i,n,a,l,c,m){let p=o,h=o+1,g=o+n,d=o+n+1,u=a,f=a+1,y=a+2*i,b=a+2*i+1;m<0&&(p=o+n+1,d=o);let _=3*c;for(let x=0;x<i;++x)x===i-1&&(h=o,m>0?d=o+n:p=o+n),yt(t,p,h,g,mt),ct(t,e,s,r,mt,u,p),ct(t,e,s,r,mt,f,h),ct(t,e,s,r,mt,y,g),ct(t,e,s,r,mt,b,d),l[_]=u,l[_+1]=y,l[_+2]=b,l[_+3]=u,l[_+4]=b,l[_+5]=f,_+=6,p++,h++,g++,d++,u+=2,f+=2,y+=2,b+=2}const ht=x(),gt=x(),dt=x(),ut=x(),ft=x();function yt(t,e,r,s,o){e*=3,r*=3,s*=3,h(ht,t[e++],t[e++],t[e++]),h(gt,t[r++],t[r++],t[r++]),h(dt,t[s++],t[s++],t[s++]),g(ut,gt,ht),g(ft,dt,ht),d(o,ft,ut),p(o,o)}const bt=x();function _t(t,e,r,s,o,i,n){const c=t.stageObject,m=c.geometries,p=m.length,g="absolute-height"!==e.mode;let d=0;const f=c.transformation,y=a(l(),f);for(let a=0;a<p;a+=2){const t=m[a];if(!Y(t))continue;const e=t.getMutableAttribute(rt.POSITION).data,l=i[a/2],p=new W(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let i=0;i<b;i++){bt[0]=e[t],bt[1]=e[t+1],bt[2]=e[t+2],s(p,Pt),g&&(x+=Pt.sampledElevation),H.TESTS_DISABLE_OPTIMIZATIONS?(h(St,p.array[p.offset],p.array[p.offset+1],Pt.z+l[t/3]),null!=r&&o.toRenderCoords(St,r,St),u(St,St,y)):(h(St,e[t],e[t+1],e[t+2]),u(St,St,f),o.setAltitude(St,Pt.z+l[t/3]),u(St,St,y)),e[t]=St[0],e[t+1]=St[1],e[t+2]=St[2];const i=Ot/o.unitInMeters;(Math.abs(bt[0]-e[t])>=i||Math.abs(bt[1]-e[t+1])>=i||Math.abs(bt[2]-e[t+2])>=i)&&(_=!0),p.offset+=3,t+=3}}if(_){const e=n.get(t);e&&xt(t,e,f),c.geometryVertexAttributeUpdated(m[a],rt.NORMALCOMPRESSED),t.invalidateBoundingInfo(),c.geometryVertexAttributeUpdated(m[a],rt.POSITION),m[a+1].invalidateBoundingInfo(),c.geometryVertexAttributeUpdated(m[a+1],rt.POSITION)}d+=x/b}return d/p}function xt(t,e,r){const s=t.getMutableAttribute(rt.POSITION),o=t.getMutableAttribute(rt.NORMALCOMPRESSED).data,{topVertexStart:i,topVertexCount:n,topFaceStart:a,topFaceCount:l}=e,c=s.data,m=n,g=t.attributes.get(rt.POSITION).indices,y=a+l,b=i+n,_=O(3*m);for(let p=0;p<m;++p){const t=3*p;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=vt,S=Ct,j=Mt,P=It,E=jt;for(let w=a;w<y;++w){const t=3*w;for(let e=0;e<3;++e){const s=g[t+e];P[e]=s;const o=3*s;h(St,c[o+0],c[o+1],c[o+2]),u(x[e],St,r)}f(S,x[1],x[0]),f(j,x[2],x[0]),d(E,S,j),p(E,E);for(let e=0;e<3;++e){const t=3*(P[e]-i);_[t+0]+=E[0],_[t+1]+=E[1],_[t+2]+=E[2]}}for(let p=i;p<b;++p){const t=3*(p-i),e=_[t+0],r=_[t+1],s=_[t+2],n=Math.sqrt(e*e+r*r+s*s);tt(o,p,e/n,r/n,s/n)}}const St=x(),jt=x(),Pt=new D,Et=[0,2,1],wt=[0,1,2],Ot=.01,vt=[x(),x(),x()],Ct=x(),Mt=x(),It=[0,0,0];var At;!function(t){t[t.Main=0]="Main",t[t.Bottom=1]="Bottom"}(At||(At={}));class Lt{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class zt{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{it as Graphics3DExtrudeSymbolLayer,at as extrudePolygon};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{create as e}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as t,s as i}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as s,expandWithVec3 as a,create as r,isPoint as o,center as l,offset as h}from"../../../../geometry/support/aaBoundingBox.js";import{evaluateElevationInfoAtPoint as c}from"./elevationAlignmentUtils.js";import{setContextFeature as d}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as g}from"./graphicUtils.js";import{Object3DState as m}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3DStateID as f}from"../../webgl-engine/lib/Object3DStateID.js";class p{constructor(e,t,i,n){this.graphics3DSymbolLayer=e,this.instanceIndex=t,this.elevationAligner=i,this.elevationContext=n,this.type="lod-instance",this._highlights=new Set,this.alignedSampledElevation=0,this.isElevationSource=!1,this.needsElevationUpdates=!1}initialize(){}setVisibility(e){const t=this._lodRenderer.instanceData;e!==t.getVisible(this.instanceIndex)&&t.setVisible(this.instanceIndex,e)}destroy(){null!=this.instanceIndex&&(this._lodRenderer.instanceData.removeInstance(this.instanceIndex),this.graphics3DSymbolLayer.notifyDestroyGraphicLayer(this))}alignWithElevation(e,t,i){if(this.elevationAligner){d(this.elevationContext.featureExpressionInfoContext,i);const n=(i,n)=>c(i,e,this.elevationContext,t,n),s=this.elevationAligner(this,this.elevationContext,e.spatialReference,n,t);null!=s&&(this.alignedSampledElevation=s)}}getCenterObjectSpace(e=n()){return this._lodRenderer.instanceData.getCombinedLocalTransform(this.instanceIndex,I),t(e,this._lodRenderer.baseBoundingSphere.center,I)}getBoundingBoxObjectSpace(e=r()){this._lodRenderer.instanceData.getCombinedLocalTransform(this.instanceIndex,I);const n=this._lodRenderer.baseBoundingBox;s(e);for(let s=0;s<8;++s)i(x,1&s?n[3]:n[0],2&s?n[4]:n[1],4&s?n[5]:n[2]),t(x,x,I),a(e,x);return e}computeAttachmentOrigin(e){this._lodRenderer.instanceData.getGlobalTransform(this.instanceIndex,I),e.render.origin[0]+=I[12],e.render.origin[1]+=I[13],e.render.origin[2]+=I[14],e.render.num++}async getProjectedBoundingBox(e,i,n,a,r){const c=this.getBoundingBoxObjectSpace(r),d=b,m=o(c)?1:d.length;this._lodRenderer.instanceData.getGlobalTransform(this.instanceIndex,I);for(let s=0;s<m;s++){const e=d[s];x[0]=c[e[0]],x[1]=c[e[1]],x[2]=c[e[2]],t(x,x,I),u[3*s]=x[0],u[3*s+1]=x[1],u[3*s+2]=x[2]}if(!e(u,0,m))return null;s(c);let f=null;this.calculateRelativeScreenBounds&&(f=this.calculateRelativeScreenBounds());for(let t=0;t<3*m;t+=3){for(let e=0;e<3;e++)c[e]=Math.min(c[e],u[t+e]),c[e+3]=Math.max(c[e+3],u[t+e]);f&&n.push({location:u.slice(t,t+3),screenSpaceBoundingRect:f})}if(i&&(l(c,v),"absolute-height"!==this.elevationContext.mode)){let e;const t=g(c,i.service.spatialReference,i);try{e=await i.service.queryElevation(v[0],v[1],a,t,"ground")}catch(p){}null!=e&&h(c,0,0,-this.alignedSampledElevation+e)}return c}addObjectState(e,t){if(e===m.Highlight){const i=new f(e);this._addHighlightId(i),t.addExternal((e=>{this._removeHighlightId(e)}),i)}}removeObjectState(e){this._highlights.forEach((t=>e.remove(t)))}_addHighlightId(e){this._highlights.add(e),this._lodRenderer.instanceData.setHighlight(this.instanceIndex,!0)}_removeHighlightId(e){this._highlights.delete(e),this._lodRenderer.instanceData.setHighlight(this.instanceIndex,this._highlights.size>0)}get _lodRenderer(){return this.graphics3DSymbolLayer.lodRenderer}}const u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x=n(),v=n(),b=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]],I=e();export{p as Graphics3DLodInstanceGraphicLayer};
5
+ import{create as e}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{h as t,a as i}from"../../../../chunks/vec32.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as s,expandWithVec3 as a,create as r,isPoint as o,center as l,offset as h}from"../../../../geometry/support/aaBoundingBox.js";import{evaluateElevationInfoAtPoint as c}from"./elevationAlignmentUtils.js";import{setContextFeature as d}from"./featureExpressionInfoUtils.js";import{demResolutionForBoundingBox as g}from"./graphicUtils.js";import{Object3DState as m}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3DStateID as f}from"../../webgl-engine/lib/Object3DStateID.js";class p{constructor(e,t,i,n){this.graphics3DSymbolLayer=e,this.instanceIndex=t,this.elevationAligner=i,this.elevationContext=n,this.type="lod-instance",this._highlights=new Set,this.alignedSampledElevation=0,this.isElevationSource=!1,this.needsElevationUpdates=!1}initialize(){}setVisibility(e){const t=this._lodRenderer.instanceData;e!==t.getVisible(this.instanceIndex)&&t.setVisible(this.instanceIndex,e)}destroy(){null!=this.instanceIndex&&(this._lodRenderer.instanceData.removeInstance(this.instanceIndex),this.graphics3DSymbolLayer.notifyDestroyGraphicLayer(this))}alignWithElevation(e,t,i){if(this.elevationAligner){d(this.elevationContext.featureExpressionInfoContext,i);const n=(i,n)=>c(i,e,this.elevationContext,t,n),s=this.elevationAligner(this,this.elevationContext,e.spatialReference,n,t);null!=s&&(this.alignedSampledElevation=s)}}getCenterObjectSpace(e=n()){return this._lodRenderer.instanceData.getCombinedLocalTransform(this.instanceIndex,I),t(e,this._lodRenderer.baseBoundingSphere.center,I)}getBoundingBoxObjectSpace(e=r()){this._lodRenderer.instanceData.getCombinedLocalTransform(this.instanceIndex,I);const n=this._lodRenderer.baseBoundingBox;s(e);for(let s=0;s<8;++s)i(x,1&s?n[3]:n[0],2&s?n[4]:n[1],4&s?n[5]:n[2]),t(x,x,I),a(e,x);return e}computeAttachmentOrigin(e){this._lodRenderer.instanceData.getGlobalTransform(this.instanceIndex,I),e.render.origin[0]+=I[12],e.render.origin[1]+=I[13],e.render.origin[2]+=I[14],e.render.num++}async getProjectedBoundingBox(e,i,n,a,r){const c=this.getBoundingBoxObjectSpace(r),d=b,m=o(c)?1:d.length;this._lodRenderer.instanceData.getGlobalTransform(this.instanceIndex,I);for(let s=0;s<m;s++){const e=d[s];x[0]=c[e[0]],x[1]=c[e[1]],x[2]=c[e[2]],t(x,x,I),u[3*s]=x[0],u[3*s+1]=x[1],u[3*s+2]=x[2]}if(!e(u,0,m))return null;s(c);let f=null;this.calculateRelativeScreenBounds&&(f=this.calculateRelativeScreenBounds());for(let t=0;t<3*m;t+=3){for(let e=0;e<3;e++)c[e]=Math.min(c[e],u[t+e]),c[e+3]=Math.max(c[e+3],u[t+e]);f&&n.push({location:u.slice(t,t+3),screenSpaceBoundingRect:f})}if(i&&(l(c,v),"absolute-height"!==this.elevationContext.mode)){let e;const t=g(c,i.service.spatialReference,i);try{e=await i.service.queryElevation(v[0],v[1],a,t,"ground")}catch(p){}null!=e&&h(c,0,0,-this.alignedSampledElevation+e)}return c}addObjectState(e,t){if(e===m.Highlight){const i=new f(e);this._addHighlightId(i),t.addExternal((e=>{this._removeHighlightId(e)}),i)}}removeObjectState(e){this._highlights.forEach((t=>e.remove(t)))}_addHighlightId(e){this._highlights.add(e),this._lodRenderer.instanceData.setHighlight(this.instanceIndex,!0)}_removeHighlightId(e){this._highlights.delete(e),this._lodRenderer.instanceData.setHighlight(this.instanceIndex,this._highlights.size>0)}get _lodRenderer(){return this.graphics3DSymbolLayer.lodRenderer}}const u=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],x=n(),v=n(),b=[[0,1,2],[3,1,2],[0,4,2],[3,4,2],[0,1,5],[3,1,5],[0,4,5],[3,4,5]],I=e();export{p as Graphics3DLodInstanceGraphicLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/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{normalFromMat4 as r,fromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as s,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as p,g as h,j as g,h as d,t as x,n as _,r as T,m as b,f as y,b as v}from"../../../../chunks/vec32.js";import{ZEROS as w,ONES as R,create as M}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as P}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as E}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as N,expandWithBuffer as I,intersectsClippingArea as S}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as U}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as B,getContinuousIndexArray as F}from"../../../../geometry/support/Indices.js";import D from"../../../../geometry/support/MeshComponent.js";import G from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import L from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as V,isAbsoluteVertexSpace as $}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as H,isPlateCarree as k}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as q}from"../../../../chunks/vec3.js";import{transformNormal as z,transformVectorENUPlateCarree as W,VectorType as Y,transformVectorWMPlateCarree as J,projectNormalToPCPF as K,transformTangent as Q,projectTangentToPCPF as X,project as Z}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as ee}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as te}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as re}from"../../../ViewingMode.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ae}from"./ElevationAligners.js";import{needsElevationUpdates3D as se,evaluateElevationInfoAtPoint as ie}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as le}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ce}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ue}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as me,MeshFastUpdateProcessor as fe}from"./MeshFastUpdateProcessor.js";import{createMaterial as pe}from"../support/edgeUtils.js";import{parseColorMixMode as he,encodeSymbolColor as ge}from"../support/symbolColorUtils.js";import{debugFlags as de}from"../../support/debugFlags.js";import{Attribute as xe}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _e,CullFaceOptions as Te}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as be}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ye}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{Texture as we}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Re}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Me}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as je}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ae,defaultSchematicMRRFactors as Ce,defaultAdvancedMRRFactors as Pe}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ee}from"../../../webgl/enums.js";const Oe=["mesh"];class Ne extends ue{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new me,this._fastUpdateProcessor=new fe,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){de.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new je({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new je({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new je({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),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)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Oe,"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=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,se)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case te.EnableFastUpdates:if(n)return!0;break;case te.DisableFastUpdates:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,te.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,te.DisableFastUpdates))),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=nt,{origin:i,transform:l}=r;if(!C(t,p(Ze,i.x,i.y,i.z??0),s,a))return!1;switch(o){case te.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case te.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case te.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>ie(e,u,c,m,t);return e.alignedSampledElevation=ae(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,te.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Ye(n),p=Ye(a),h=Je(s),g=Ye(i),d=Je(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${g},nttuid:${d},ds:${c},ac:${u},am:${m}`,t.material instanceof G){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Ye(n),h=Je(a),g=Ye(i),d=Ye(c),x=Je(u),_=Ye(m),T=Je(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${g},etmuid:${d},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTextureId(e){const t=this._getInternalTexture(e,_e.Opaque);return t?.id}_getInternalTexture(e,t){const r=We(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let n=this._textures.get(o);if(!n){let a=null;const s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:He(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};oe(r)?(a=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(a=r,i.preMultiplyAlpha=t!==_e.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),n=new we(a,i),this._textures.set(o,n),n.load(this._context.stage.renderView.renderingContext),this._context.stage.add(n)}return n}_setInternalMaterialParameters(t,r){if(null!=t.color&&ze(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=ne(t.colorTextureTransform),r.normalTextureTransformMatrix=ne(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:f;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=ne(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=ne(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=ne(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=j;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=j)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(qe(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=Ae({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:w,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:Te.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};f.mrrFactors=m?[...Ce]:[l.metallic,l.roughness,Pe[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?Te.None:Te.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTransparentParameter(f,u),this._setInternalMaterialParameters(l,f);const p=new Me(f);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),p}_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?_e.MaskBlend:_e.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?_e.Opaque:"mask"===t.alphaMode?_e.Mask:_e.Blend}_createFaceDebugNormals(e,t){const o=t.length,a=e.spatialReference.isGeographic?20015077/180:1,s=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),i=[],l=[],c=t[0].transformation,u=r(n(),c);for(let r=0;r<o;r++){const e=t[r].attributes.get(Re.POSITION);if(!e)continue;const o=e.data,n=e.indices;for(let t=0;t<n.length;t+=3)Le(o,n,t,rt),Ge(o,n,t,Ze,et,tt),h(Ze,Ze,et),h(Ze,Ze,tt),g(Ze,Ze,1/3),d(Ze,Ze,c),i.push(...Ze),x(rt,rt,u),_(rt,rt),T(Ze,Ze,rt,s),i.push(...Ze),l.push(l.length),l.push(l.length)}return i.length?new ye(this._debugFaceNormalMaterial,[[Re.POSITION,new xe(i,l,3,!0)]],null,be.Line):null}_createPerVertexDebugVectors(e,t,a,s,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],h=t[0].transformation,g=r(n(),h);a===Re.TANGENT&&o(g,h);for(let r=0;r<l;r++){const e=t[r],o=e.attributes.get(Re.POSITION),n=e.attributes.get(a);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;p(Ze,s[e+0],s[e+1],s[e+2]),d(Ze,Ze,h),m.push(...Ze),p(et,l[r+0],l[r+1],l[r+2]),x(et,et,g),_(et,et),T(Ze,Ze,et,u),m.push(...Ze),f.push(f.length),f.push(f.length)}}return m.length?new ye(s,[[Re.POSITION,new xe(m,f,3,!0)]],null,be.Line):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(de.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,Re.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,Re.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=new ve({geometries:s,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=pe(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new ce(s[0].material,c,this._context.slicePlaneEnabled):null,m=new le(this,l,s,null,null,ae,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=se(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,m.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:f,renderCoordsHelper:p}=this._context,h=(e,t)=>ie(e,f,r,p,t);return m.alignedSampledElevation=ae(m,r,f.spatialReference,h,p),m}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!V(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return a===re.Global&&"local"===o||a===re.Local&&H(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=ee(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return E([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===it.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o=r,n=null;if(t.reprojection===it.NONE)return{position:o,georeferencedPositionBuffer:n};const a=t.reprojection===it.RENDER?t.transformBeforeProject:null;a&&(o=q(new Float64Array(o.length),o,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(n=o);const l=o===r||o===n?new Float64Array(o.length):o;return P(o,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0,o.length/3),{position:l,georeferencedPositionBuffer:n}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=o.reprojection===it.RENDER?o.transformBeforeProject:null;s&&(a=z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===it.NONE)return a;if("local"===i){if(!k(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return W(a,Y.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return J(a,Y.NORMAL,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a;return K(a,r,t,e.spatialReference,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=o.reprojection===it.RENDER?o.transformBeforeProject:null;s&&(a=Q(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===it.NONE)return a;if("local"===i){if(!k(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return W(a,Y.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return J(a,Y.TANGENT,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a;return X(a,r,t,e.spatialReference,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=he(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ge(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,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),u=Ke(e),m=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:g,position:d,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:d,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:u,symbolColorBuffer:m,objectTransformation:g,geometryTransformation:s.reprojection===it.NONE&&s.geometryTransformation?s.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?H(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?it.NONE:it.RENDER:it.NONE;if($(t))return{reprojection:r};const o=t.origin,n=c(),i=e.transform?.localMatrix??u;if(r===it.NONE){C(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:m(i)}}const l=a(c(),o);return s(l,l,i),{reprojection:r,transformBeforeProject:l}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Xe[0]=a.x,Xe[1]=a.y,Xe[2]=a.z??0;const s=c();C(e.spatialReference,Xe,s,n),i(ot,s);const{position:l,normal:u,tangent:m}=e.vertexAttributes,f=t===l?new Float64Array(t.length):t;q(f,t,ot);const p=r?r===u?new Float32Array(r.length):r:null,h=o?o===m?new Float32Array(o.length):o:null;return r&&p&&z(r,p,ot),o&&h&&Q(o,h,ot),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=Z({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===re.Local});if(!o)return!1;const n=o.length/3;return N(at),I(at,o,0,n),!S(at,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!A(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:f}=o,p=Ve(e),h=new Array;let g=!1;const d=l(Ze,m),x=this._context.localOriginFactory.getOrigin(d);for(const l of p){if(!this._validateFaces(e,l))return null;const t=Se(e,l);if(0===t.length)continue;const o=Ue(n,c,l,t);o.didFlipNormals&&(g=!0);const m=[[Re.POSITION,new xe(n,t,3,!0)],[Re.NORMAL,new xe(o.normals,o.indices,3,!0)]];s&&m.push([Re.COLOR,new xe(s,t,4,!0)]),i&&m.push([Re.SYMBOLCOLOR,new xe(i,B(t.length),4,!0)]),a&&m.push([Re.UV0,new xe(a,t,2,!0)]),u&&m.push([Re.TANGENT,new xe(u,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),d=this._getOrCreateMaterial(e,l),_=new ye(d,m,null,be.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return g&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==re.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Se(e,t){return t.faces??F(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Be(e,o);case"smooth":return De(e,o)}}function Be(e,t){const r=U(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Le(e,t,n,rt);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Be(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Le(e,o,a,rt);for(let e=0;e<3;e++){const r=3*o[a+e];Ze[0]=t[r],Ze[1]=t[r+1],Ze[2]=t[r+2],b(rt,Ze)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function De(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Le(e,t,a,rt);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),h(s.normal,s.normal,o),s.count++}}const o=U(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(_(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ge(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Le(e,t,r,o){return Ge(e,t,r,Ze,et,tt),y(et,et,Ze),y(tt,tt,Ze),v(Ze,et,tt),_(o,Ze),o}function Ve(e){return e.components??st}function $e(e){if(!e)return null;const{scale:r,offset:o,rotation:n}=e;return{scale:r,offset:o,rotation:t(n)}}function He(e="repeat"){if("string"==typeof e){const t=ke(e);return{s:t,t}}return{s:ke(e.horizontal),t:ke(e.vertical)}}function ke(e){switch(e){case"clamp":return Ee.CLAMP_TO_EDGE;case"mirror":return Ee.MIRRORED_REPEAT;default:return Ee.REPEAT}}function qe(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function ze(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}function We(e){return e.data??e.url}function Ye(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Je(e){const{offset:t,scale:r,rotation:o}=e??Qe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Ke(e){return e.vertexAttributes.color}const Qe=new L,Xe=M(),Ze=M(),et=M(),tt=M(),rt=M(),ot=c(),nt=c(),at=O(),st=[new D];var it;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(it||(it={}));export{Ne as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as r,fromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as s,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{a as p,g as h,j as g,h as d,t as x,n as _,r as T,l as b,f as y,b as v}from"../../../../chunks/vec32.js";import{ZEROS as w,ONES as R,create as M}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as P}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as E}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as N,expandWithBuffer as I,intersectsClippingArea as S}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as U}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as B,getContinuousIndexArray as F}from"../../../../geometry/support/Indices.js";import D from"../../../../geometry/support/MeshComponent.js";import G from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import L from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as V,isAbsoluteVertexSpace as $}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as H,isPlateCarree as k}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as q}from"../../../../chunks/vec3.js";import{transformNormal as z,transformVectorENUPlateCarree as W,VectorType as Y,transformVectorWMPlateCarree as J,projectNormalToPCPF as K,transformTangent as Q,projectTangentToPCPF as X,project as Z}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as ee}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as te}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as re}from"../../../ViewingMode.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ae}from"./ElevationAligners.js";import{needsElevationUpdates3D as se,evaluateElevationInfoAtPoint as ie}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as le}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ce}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ue}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as me,MeshFastUpdateProcessor as fe}from"./MeshFastUpdateProcessor.js";import{createMaterial as pe}from"../support/edgeUtils.js";import{parseColorMixMode as he,encodeSymbolColor as ge}from"../support/symbolColorUtils.js";import{debugFlags as de}from"../../support/debugFlags.js";import{Attribute as xe}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _e,CullFaceOptions as Te}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as be}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ye}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{Texture as we}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Re}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Me}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as je}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ae,defaultSchematicMRRFactors as Ce,defaultAdvancedMRRFactors as Pe}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ee}from"../../../webgl/enums.js";const Oe=["mesh"];class Ne extends ue{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new me,this._fastUpdateProcessor=new fe,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){de.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new je({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new je({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new je({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),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)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Oe,"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=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,se)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case te.EnableFastUpdates:if(n)return!0;break;case te.DisableFastUpdates:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,te.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,te.DisableFastUpdates))),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=nt,{origin:i,transform:l}=r;if(!C(t,p(Ze,i.x,i.y,i.z??0),s,a))return!1;switch(o){case te.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case te.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case te.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>ie(e,u,c,m,t);return e.alignedSampledElevation=ae(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,te.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Ye(n),p=Ye(a),h=Je(s),g=Ye(i),d=Je(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${g},nttuid:${d},ds:${c},ac:${u},am:${m}`,t.material instanceof G){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Ye(n),h=Je(a),g=Ye(i),d=Ye(c),x=Je(u),_=Ye(m),T=Je(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${g},etmuid:${d},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTextureId(e){const t=this._getInternalTexture(e,_e.Opaque);return t?.id}_getInternalTexture(e,t){const r=We(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let n=this._textures.get(o);if(!n){let a=null;const s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:He(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};oe(r)?(a=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(a=r,i.preMultiplyAlpha=t!==_e.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),n=new we(a,i),this._textures.set(o,n),n.load(this._context.stage.renderView.renderingContext),this._context.stage.add(n)}return n}_setInternalMaterialParameters(t,r){if(null!=t.color&&ze(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=ne(t.colorTextureTransform),r.normalTextureTransformMatrix=ne(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:f;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=ne(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=ne(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=ne(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=j;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=j)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(qe(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=Ae({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:w,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:Te.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};f.mrrFactors=m?[...Ce]:[l.metallic,l.roughness,Pe[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?Te.None:Te.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTransparentParameter(f,u),this._setInternalMaterialParameters(l,f);const p=new Me(f);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),p}_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?_e.MaskBlend:_e.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?_e.Opaque:"mask"===t.alphaMode?_e.Mask:_e.Blend}_createFaceDebugNormals(e,t){const o=t.length,a=e.spatialReference.isGeographic?20015077/180:1,s=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),i=[],l=[],c=t[0].transformation,u=r(n(),c);for(let r=0;r<o;r++){const e=t[r].attributes.get(Re.POSITION);if(!e)continue;const o=e.data,n=e.indices;for(let t=0;t<n.length;t+=3)Le(o,n,t,rt),Ge(o,n,t,Ze,et,tt),h(Ze,Ze,et),h(Ze,Ze,tt),g(Ze,Ze,1/3),d(Ze,Ze,c),i.push(...Ze),x(rt,rt,u),_(rt,rt),T(Ze,Ze,rt,s),i.push(...Ze),l.push(l.length),l.push(l.length)}return i.length?new ye(this._debugFaceNormalMaterial,[[Re.POSITION,new xe(i,l,3,!0)]],null,be.Line):null}_createPerVertexDebugVectors(e,t,a,s,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],h=t[0].transformation,g=r(n(),h);a===Re.TANGENT&&o(g,h);for(let r=0;r<l;r++){const e=t[r],o=e.attributes.get(Re.POSITION),n=e.attributes.get(a);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;p(Ze,s[e+0],s[e+1],s[e+2]),d(Ze,Ze,h),m.push(...Ze),p(et,l[r+0],l[r+1],l[r+2]),x(et,et,g),_(et,et),T(Ze,Ze,et,u),m.push(...Ze),f.push(f.length),f.push(f.length)}}return m.length?new ye(s,[[Re.POSITION,new xe(m,f,3,!0)]],null,be.Line):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(de.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,Re.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,Re.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=new ve({geometries:s,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=pe(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new ce(s[0].material,c,this._context.slicePlaneEnabled):null,m=new le(this,l,s,null,null,ae,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=se(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,m.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:f,renderCoordsHelper:p}=this._context,h=(e,t)=>ie(e,f,r,p,t);return m.alignedSampledElevation=ae(m,r,f.spatialReference,h,p),m}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!V(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return a===re.Global&&"local"===o||a===re.Local&&H(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=ee(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return E([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===it.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o=r,n=null;if(t.reprojection===it.NONE)return{position:o,georeferencedPositionBuffer:n};const a=t.reprojection===it.RENDER?t.transformBeforeProject:null;a&&(o=q(new Float64Array(o.length),o,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(n=o);const l=o===r||o===n?new Float64Array(o.length):o;return P(o,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0,o.length/3),{position:l,georeferencedPositionBuffer:n}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=o.reprojection===it.RENDER?o.transformBeforeProject:null;s&&(a=z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===it.NONE)return a;if("local"===i){if(!k(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return W(a,Y.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return J(a,Y.NORMAL,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a;return K(a,r,t,e.spatialReference,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=o.reprojection===it.RENDER?o.transformBeforeProject:null;s&&(a=Q(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===it.NONE)return a;if("local"===i){if(!k(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return W(a,Y.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return J(a,Y.TANGENT,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a;return X(a,r,t,e.spatialReference,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=he(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ge(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,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),u=Ke(e),m=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:g,position:d,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:d,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:u,symbolColorBuffer:m,objectTransformation:g,geometryTransformation:s.reprojection===it.NONE&&s.geometryTransformation?s.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?H(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?it.NONE:it.RENDER:it.NONE;if($(t))return{reprojection:r};const o=t.origin,n=c(),i=e.transform?.localMatrix??u;if(r===it.NONE){C(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:m(i)}}const l=a(c(),o);return s(l,l,i),{reprojection:r,transformBeforeProject:l}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Xe[0]=a.x,Xe[1]=a.y,Xe[2]=a.z??0;const s=c();C(e.spatialReference,Xe,s,n),i(ot,s);const{position:l,normal:u,tangent:m}=e.vertexAttributes,f=t===l?new Float64Array(t.length):t;q(f,t,ot);const p=r?r===u?new Float32Array(r.length):r:null,h=o?o===m?new Float32Array(o.length):o:null;return r&&p&&z(r,p,ot),o&&h&&Q(o,h,ot),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=Z({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===re.Local});if(!o)return!1;const n=o.length/3;return N(at),I(at,o,0,n),!S(at,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!A(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:f}=o,p=Ve(e),h=new Array;let g=!1;const d=l(Ze,m),x=this._context.localOriginFactory.getOrigin(d);for(const l of p){if(!this._validateFaces(e,l))return null;const t=Se(e,l);if(0===t.length)continue;const o=Ue(n,c,l,t);o.didFlipNormals&&(g=!0);const m=[[Re.POSITION,new xe(n,t,3,!0)],[Re.NORMAL,new xe(o.normals,o.indices,3,!0)]];s&&m.push([Re.COLOR,new xe(s,t,4,!0)]),i&&m.push([Re.SYMBOLCOLOR,new xe(i,B(t.length),4,!0)]),a&&m.push([Re.UV0,new xe(a,t,2,!0)]),u&&m.push([Re.TANGENT,new xe(u,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),d=this._getOrCreateMaterial(e,l),_=new ye(d,m,null,be.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return g&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==re.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Se(e,t){return t.faces??F(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Be(e,o);case"smooth":return De(e,o)}}function Be(e,t){const r=U(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Le(e,t,n,rt);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Be(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Le(e,o,a,rt);for(let e=0;e<3;e++){const r=3*o[a+e];Ze[0]=t[r],Ze[1]=t[r+1],Ze[2]=t[r+2],b(rt,Ze)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function De(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Le(e,t,a,rt);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),h(s.normal,s.normal,o),s.count++}}const o=U(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(_(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ge(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Le(e,t,r,o){return Ge(e,t,r,Ze,et,tt),y(et,et,Ze),y(tt,tt,Ze),v(Ze,et,tt),_(o,Ze),o}function Ve(e){return e.components??st}function $e(e){if(!e)return null;const{scale:r,offset:o,rotation:n}=e;return{scale:r,offset:o,rotation:t(n)}}function He(e="repeat"){if("string"==typeof e){const t=ke(e);return{s:t,t}}return{s:ke(e.horizontal),t:ke(e.vertical)}}function ke(e){switch(e){case"clamp":return Ee.CLAMP_TO_EDGE;case"mirror":return Ee.MIRRORED_REPEAT;default:return Ee.REPEAT}}function qe(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function ze(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}function We(e){return e.data??e.url}function Ye(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Je(e){const{offset:t,scale:r,rotation:o}=e??Qe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Ke(e){return e.vertexAttributes.color}const Qe=new L,Xe=M(),Ze=M(),et=M(),tt=M(),rt=M(),ot=c(),nt=c(),at=O(),st=[new D];var it;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(it||(it={}));export{Ne 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.31/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{identity as i,scale as a,translate as o,copy as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l as c,k as h,c as d,B as m,g as p,s as u}from"../../../../chunks/vec32.js";import{fromArray as y,ONES as f,ZEROS as _,fromValues as g,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as P,create as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as v}from"../../../../geometry/projection/projectPointToVector.js";import{create as L,size as C,containsPoint as S,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as w}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as E,objectSymbolLayerSizeWithResourceSize as U}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as T,defaultSymbolLayerMemoryComplexity as O}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as I,evaluateElevationInfoAtPoint as G,SampleElevationInfo as A}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as D}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as z,mixinColorAndOpacity as V,computeObjectScale as M,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{LoadStatus as W}from"./Loadable.js";import{makeLodResources as q}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as J,extendPointGraphicElevationContext as Y}from"./pointUtils.js";import{isValidPrimitive as $,primitiveLodResources as K}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as Q}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as X}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as Z,updateFastSymbolUpdatesState as ee,ConvertOptions as te,evaluateModelTransform as se,evaluateModelTransformScale as re}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ie}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ae}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as oe}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ne,texturesFromLodResources as le,geometriesFromLodResources 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 F{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){const e=z(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&$(t?.primitive)?t.primitive:w;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await X(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}get materials(){return this._resources?.stageResources.materials??[]}_setMaterialTransparencyParameters(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?ie.None:ie.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(E(t)),o=y(C(a)),n=y(U(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._setMaterialTransparencyParameters(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=Z(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const _=new he(m),g=K(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ne(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={materialParameters:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=Z(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;r.signal=t,r.usePBR=a,r.skipHighLods=this._context.skipHighSymbolLods;const o=await N(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=q(o.lods),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=ne(h),b=ne(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(U(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;ee(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const j=await this._createStageResources(h,a,t),w=await this._createLodRenderer(h,t);return new me(h,w,j,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=ne(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=le(e);i.addMany(o),this._addDisposeResource((()=>{o.forEach((e=>e.unload())),i.removeMany(o)})),await Promise.all(o.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=ce(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,be),n(s,se(i.materialParameters,be,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,be),re(e,i.materialParameters,be)}}:null,o=new oe({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,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P: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=J(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object 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?ie.None:ie.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}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(!ee(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=T(e.levels),s=e=>Array.from(e.attributes.values()).reduce(((e,t)=>e+r(t.data,t.indices)),0),i=ce(e).reduce(((e,t)=>e+s(t)),0),a=le(e).reduce(((e,t)=>e+t.memoryEstimate),0)+i,o={...O(this.symbol,this.symbolLayer),resourceBytes:a};return new Q({verticesPerFeature:t,memory:o})}_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(v(t,fe,this._context.elevationProvider.spatialReference),null!=n&&!S(n,fe))return null;const l=ye(r),c=this._computeGlobalTransform(t,r,ge,Pe),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,_e),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,V(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 D(this,m,B,r);return l&&(p.alignedSampledElevation=Pe.sampledElevation),p.needsElevationUpdates=I(r.mode),Y(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return G(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),fe[0]=e.x,fe[1]=e.y,fe[2]=r.z,x(e.spatialReference,fe,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&&J(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,ge,Pe),ye(e.elevationContext)&&(e.alignedSampledElevation=Pe.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,ge,!0),Y(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===W.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(U(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,_e),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._setMaterialTransparencyParameters({},i)):t=this._setMaterialTransparencyParameters({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return H(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=ue(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?ue(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 te({size:!0,color:!0,rotation:!0,opacity:!1},i,t??f,o,a,n,l)}}function ue(e,t,s){const r=b();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(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}function ye(e){return"absolute-height"!==e.mode}const fe=b(),_e=l(),ge=l(),be=R(),Pe=new A;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{identity as i,scale as a,translate as o,copy as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{m as c,L as h,k as d,c as m,B as p,g as u,a as y}from"../../../../chunks/vec32.js";import{fromArray as f,clone as _,ZEROS as g,ONES as b,fromValues as P,create as R}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as x,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as L}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as C}from"../../../../geometry/projection/projectPointToVector.js";import{create as S,size as j,containsPoint as w,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as U}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as T,objectSymbolLayerSizeWithResourceSize as O}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as B,defaultSymbolLayerMemoryComplexity as I}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as G}from"./ElevationAligners.js";import{needsElevationUpdates3D as A,evaluateElevationInfoAtPoint as D,SampleElevationInfo as F}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as z}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as M,mixinColorAndOpacity as H,computeObjectScale as k,computeObjectRotation as W}from"./graphicUtils.js";import{ApplyRendererDiffResult as q}from"./interfaces.js";import{LoadStatus as N}from"./Loadable.js";import{makeLodResources as J}from"./lodResourceUtils.js";import{fetch as Y}from"./objectResourceUtils.js";import{placePointOnGeometry as $,extendPointGraphicElevationContext as K}from"./pointUtils.js";import{isValidPrimitive as Q,primitiveLodResources as X}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as Z}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as ee}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as te,updateFastSymbolUpdatesState as se,ConvertOptions as re,evaluateModelTransform as ie,evaluateModelTransformScale as ae}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as oe}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ne}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as le}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ce,texturesFromLodResources as he,geometriesFromLodResources as de}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as me}from"../../webgl-engine/materials/DefaultMaterial.js";import{defaultSchematicMRRFactors as pe}from"../../webgl-engine/materials/pbrUtils.js";class ue{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 ye extends V{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){const e=M(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Q(t?.primitive)?t.primitive:U;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await ee(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}get materials(){return this._resources?.stageResources.materials??[]}_setMaterialTransparencyParameters(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?oe.None:oe.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=S(T(t)),o=f(j(a)),n=f(O(o,i)),l=c(n),d=!1,m=!1,p=this.symbolLayer?.material?.emissiveFactor,u=p?h(_(p)):g,y={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:[...pe],ambient:b,diffuse:b,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,emissiveFactor:u,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},P=!!y.usePBR;this._setMaterialTransparencyParameters(y);const R=this.symbol;if("point-3d"===R.type&&R.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=R.verticalOffset;y.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},y.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(y.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)y.externalColor=x;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):x;y.externalColor=s}this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),y.isInstanced=!0,this._fastUpdates?(Object.assign(y,this._fastUpdates.materialParameters),this._optionalFields.push(ne.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(y.hasInstancedColor=!0,this._optionalFields.push(ne.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ne.OBJECTANDLAYERIDCOLOR);const v=new me(y),L=X(t,v);if(!L)throw new Error(`Unknown object symbol primitive: ${t}`);const C=ce(L).map((e=>({opacity:1,transparent:e.parameters.transparent}))),w=await this._createStageResources(L,P,r),E=await this._createLodRenderer(L,r);return new ue(L,E,w,C,o,d,m,a,n,l,P,null)}async _createResourcesForUrl(e,t){const r={materialParameters:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=te(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ne.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ne.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ne.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;r.signal=t,r.usePBR=a,r.skipHighLods=this._context.skipHighSymbolLods;const o=await Y(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=J(o.lods),d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,y=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),_=this.needsDrivenTransparentPass,g=ce(h),b=ce(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*y,r=s<1||_||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=f(j(P)),x=f(h.levels[0].pivotOffset),v=f(O(R,this.symbolLayer)),L=c(v),C=this._fastUpdates;se(C,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(C.materialParameters)));const S=await this._createStageResources(h,a,t),w=await this._createLodRenderer(h,t);return new ue(h,w,S,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=ce(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=he(e);i.addMany(o),this._addDisposeResource((()=>{o.forEach((e=>e.unload())),i.removeMany(o)})),await Promise.all(o.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=de(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,Re),n(s,ie(i.materialParameters,Re,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,Re),ae(e,i.materialParameters,Re)}}:null,o=new le({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,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=x:null!=t?.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=x,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=$(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object 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?oe.None:oe.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,A)}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 q.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 q.RecreateSymbol;if(!se(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return q.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return q.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=B(e.levels),s=e=>Array.from(e.attributes.values()).reduce(((e,t)=>e+r(t.data,t.indices)),0),i=de(e).reduce(((e,t)=>e+s(t)),0),a=he(e).reduce(((e,t)=>e+t.memoryEstimate),0)+i,o={...I(this.symbol,this.symbolLayer),resourceBytes:a};return new Z({verticesPerFeature:t,memory:o})}_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(C(t,ge,this._context.elevationProvider.spatialReference),null!=n&&!w(n,ge))return null;const l=_e(r),c=this._computeGlobalTransform(t,r,Pe,xe),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,be),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,H(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 z(this,m,G,r);return l&&(p.alignedSampledElevation=xe.sampledElevation),p.needsElevationUpdates=A(r.mode),K(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return D(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ge[0]=e.x,ge[1]=e.y,ge[2]=r.z,L(e.spatialReference,ge,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=k(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&&$(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,Pe,xe),_e(e.elevationContext)&&(e.alignedSampledElevation=xe.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,Pe,!0),K(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(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===N.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=f(O(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,be),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):x;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._setMaterialTransparencyParameters({},i)):t=this._setMaterialTransparencyParameters({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return W(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=fe(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?f(j(e)):b,a=null!=e?fe(e,r,this.symbolLayer):g,o=this._context.renderCoordsHelper.unitInMeters,n=k(null!=t?t:void 0,t,s,o),l=P(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new re({size:!0,color:!0,rotation:!0,opacity:!1},i,t??b,o,a,n,l)}}function fe(e,t,s){const r=R();switch(s.anchor){case"center":m(r,E(e)),d(r,r);break;case"top":{const t=E(e);y(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=E(e);y(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=E(e),i=j(e),a=s.anchorPosition,o=a?P(a.x,a.y,a.z):g;p(r,i,o),u(r,r,t),d(r,r);break}default:null!=t?d(r,t):m(r,g)}return r}function _e(e){return"absolute-height"!==e.mode}const ge=R(),be=l(),Pe=l(),Re=v(),xe=new F;export{ye 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.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Error.js";import{translate as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as s,scale as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as o,fromArray as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as l}from"../../../../chunks/vec32.js";import{fromArray as h,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as p}from"../../../../geometry/projection/projectBuffer.js";import{create as m,empty as f,expandWithBuffer as d,intersectsClippingArea as u}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as b,doubleArrayFrom as y}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{pathNumRoundJoinSubdivisions as x,pathNumRoundCapExtrusionSubdivisions 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 A}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 z}from"../../webgl-engine/lib/Object3D.js";import{Path as k}from"../../webgl-engine/lib/Path.js";import{PathBuilder as I}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as G,TriangulationCapBuilder as B,NoCapBuilder as O}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as M,MiterExtruder as q}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as F,PathGeometry as H,isPathGeometry as N}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as T,StaticPathGeometry as W}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{VertexAttribute as X}from"../../webgl-engine/lib/VertexAttribute.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 j{constructor(e,t,i,r){super(e,t,i,r),this._intrinsicSize=o(1,1),this._upVectorAlignment=F.Path,this._stencilWidth=.1,this.usedMemory=0,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);const r=this._context.renderer?.visualVariables;this._fastUpdates=r?.length?L(this._context.renderer,this._vvConvertOptions):null;const o=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?F.World:F.Path;const l=this.symbolLayer.profile||"circle";switch(l){default:case"circle":this._profile=K[o];break;case"quad":this._profile=J[o]}switch(this.symbolLayer.join){case"round":this._extruder=new q(0,x);break;case"bevel":this._extruder=new q(0,1);break;case"miter":this._extruder=new q(.8*Math.PI,1);break;default:this._extruder=new M}const c=this.symbolLayer.cap||"butt";switch(c){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"===l;this._startCap=new G({profile:this._profile,flip:!1,breakNormals:e,subdivisions:P}),this._endCap=new G({profile:this._profile,flip:!0,breakNormals:e,subdivisions:P});break}}const p=this.symbolLayer?.material?.color,m=this._getCombinedOpacityAndColor(p),f=h(m),d=m[3],u=d<1||this.needsDrivenTransparentPass,b={diffuse:f,ambient:f,opacity:d,transparent:u,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:u||"none"===c?R.None:R.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(s(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?.visualVariables.size||a(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates){const e={...b,...this._fastUpdates.materialParameters,size:n(this._intrinsicSize)};this._materials[0]=new $(e)}else b.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,b.normalType=E.Compressed,this._materials[0]=new Y(b);this._materials[0].setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._materials[0])}destroy(){super.destroy(),this._context.stage.remove(this._materials[0]),this._materials.length=0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ee,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t),r=e.renderingInfo;return this._createAs3DShape(t,r,i,t.uid)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e),i=t<1||this.needsDrivenTransparentPass;this._materials[0]?.setParameters({opacity:t,transparent:i})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,g)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.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._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return D.FastUpdate}_getVertexData(e){let t=0;const i=e.paths,r=[],s=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const c of i)t+=c.length;const n=b(3*t);let l,h=0;for(const c of i){r.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||s.equals(a)||p(n,s,0,n,a,0,t)?(null==a||a.equals(o)?l=y(n):(l=b(3*t),p(n,a,0,l,o,0,t)),{pathVertexDataInfos:r,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,s,a,o){this.usedMemory=0;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,b=m(),y=this._context.renderCoordsHelper,v=new A(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&&(f(b),d(b,h.vertexDataES,g,n),!u(b,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,y);l(oe,h.vertexDataRS[e],h.vertexDataRS[e+1],h.vertexDataRS[e+2]),y.setAltitude(oe,t),h.vertexDataRS[e]=oe[0],h.vertexDataRS[e+1]=oe[1],h.vertexDataRS[e+2]=oe[2],w.push(Q(this._upVectorAlignment))}const P=new k(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=U(t.size?.field,e)??0,r=U(t.color?.field,e)??0,s=U(t.opacity?.field,e)??0;S=new T(j,i,r,s)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];if(this._drivenProperties.size){const t=s.size;e[0]*=re(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=re(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}let t;this._drivenProperties.color&&(t=s.color),this._drivenProperties.opacity&&null!=s.opacity&&(t=t?[t[0],t[1],t[2],s.opacity]:[1,1,1,s.opacity]);const i=new W(j);i.bake(e),t&&i.bakeVertexColors(t),S=i}const D=S.createGeometryData(),C=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid}),L=new H(this._materials[0],D,S,p,this._stencilWidth,C);L.transformation=t(r(),i,j.path.origin),c.push(L),this.usedMemory+=j.usedMemory}if(0===c.length)return null;const x=new z({geometries:c,layerUid:this._context.layer.uid,graphicUid:o}),P=new w(this,x,c,null,null,((e,t,i,r,s)=>ae(e,t,r,s,this._upVectorAlignment)),a);return P.alignedSampledElevation=0,P.needsElevationUpdates=g(a.mode),P}}function ie(e,t,i){const{origin:r,positions:s}=e;let a=e.offset;switch(t){default:case F.World:for(const t of e.vertices)oe[0]=s[a++]+r[0],oe[1]=s[a++]+r[1],oe[2]=s[a++]+r[2],i.worldUpAtPosition(oe,oe),t.setFrameFromUpVector(oe);break;case F.Path:oe[0]=s[a]+r[0],oe[1]=s[a+1]+r[1],oe[2]=s[a+2]+r[2],i.worldUpAtPosition(oe,oe),Z(e,oe)}}function re(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function se(e,t,i,r){let s=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),s+=ne.sampledElevation,oe[0]=n[p]+a[0],oe[1]=n[p+1]+a[1],oe[2]=n[p+2]+a[2],r.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(),s/o.length}function ae(e,t,i,r,s){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+=se(o,t,i,r),s!==F.World&&ie(o,s,r),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(l,X.POSITION)}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{translate as t}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as i,create as r}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as s,scale as a}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as o,fromArray as n}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{L as l,a as h}from"../../../../chunks/vec32.js";import{clone as c,ZEROS as p,fromArray as m,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as d}from"../../../../geometry/projection/projectBuffer.js";import{create as u,empty as y,expandWithBuffer as b,intersectsClippingArea as g}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as _,doubleArrayFrom as v}from"../../../../geometry/support/DoubleArray.js";import{needsElevationUpdates3D as w,evaluateElevationAlignmentAtPoint as x,SampleElevationInfo as P}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as j}from"./Graphics3DObject3DGraphicLayer.js";import{pathNumRoundJoinSubdivisions as S,pathNumRoundCapExtrusionSubdivisions as D}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as C}from"./Graphics3DSymbolLayer.js";import{isValidSize as L}from"./graphicUtils.js";import{ApplyRendererDiffResult as V}from"./interfaces.js";import{ConvertOptions as U,initFastSymbolUpdatesState as A,updateFastSymbolUpdatesState as E,getAttributeValue as R}from"../support/FastSymbolUpdates.js";import{SamplePosition as z}from"../../support/ElevationProvider.js";import{NormalType as k}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{CullFaceOptions as I}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as G}from"../../webgl-engine/lib/Object3D.js";import{Path as B}from"../../webgl-engine/lib/Path.js";import{PathBuilder as O}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as M,TriangulationCapBuilder as F,NoCapBuilder as q}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as H,MiterExtruder as N}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as T,PathGeometry as W,isPathGeometry as Z}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as J,StaticPathGeometry as K}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as Q}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as X,circleProfiles as Y}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as $}from"../../webgl-engine/lib/PathVertex.js";import{VertexAttribute as ee}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as te}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as ie}from"../../webgl-engine/materials/PathMaterial.js";const re=["polyline"];class se extends C{constructor(e,t,i,r){super(e,t,i,r),this._intrinsicSize=o(1,1),this._upVectorAlignment=T.Path,this._stencilWidth=.1,this.usedMemory=0,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 U({size:!0,color:!0,rotation:!1,opacity:!0},[1,1,1],[t,1,i],this._context.renderCoordsHelper.unitInMeters);const r=this._context.renderer?.visualVariables;this._fastUpdates=r?.length?A(this._context.renderer,this._vvConvertOptions):null;const o=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?T.World:T.Path;const h=this.symbolLayer.profile||"circle";switch(h){default:case"circle":this._profile=Y[o];break;case"quad":this._profile=X[o]}switch(this.symbolLayer.join){case"round":this._extruder=new N(0,S);break;case"bevel":this._extruder=new N(0,1);break;case"miter":this._extruder=new N(.8*Math.PI,1);break;default:this._extruder=new H}const f=this.symbolLayer.cap||"butt";switch(f){case"none":this._startCap=new q,this._endCap=new q;break;case"butt":default:this._startCap=new F(this._profile,0),this._endCap=new F(this._profile,0,!0);break;case"square":this._startCap=new F(this._profile,-.5),this._endCap=new F(this._profile,.5,!0);break;case"round":{const e="quad"===h;this._startCap=new M({profile:this._profile,flip:!1,breakNormals:e,subdivisions:D}),this._endCap=new M({profile:this._profile,flip:!0,breakNormals:e,subdivisions:D});break}}const d=this.symbolLayer?.material?.emissiveFactor,u=d?l(c(d)):p,y=this.symbolLayer?.material?.color,b=this._getCombinedOpacityAndColor(y),g=m(b),_=b[3],v=_<1||this.needsDrivenTransparentPass,w={diffuse:g,ambient:g,emissiveFactor:u,opacity:_,transparent:v,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:v||"none"===f?I.None:I.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(s(this._intrinsicSize,t,i),!L(this._intrinsicSize[0])||!L(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates?.visualVariables.size||a(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates){const e={...w,...this._fastUpdates.materialParameters,size:n(this._intrinsicSize)};this._materials[0]=new ie(e)}else w.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,w.normalType=k.Compressed,this._materials[0]=new te(w);this._materials[0].setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._materials[0])}destroy(){super.destroy(),this._context.stage.remove(this._materials[0]),this._materials.length=0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,re,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t),r=e.renderingInfo;return this._createAs3DShape(t,r,i,t.uid)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e),i=t<1||this.needsDrivenTransparentPass;this._materials[0]?.setParameters({opacity:t,transparent:i})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,w)}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._materials[0]?.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return V.RecreateSymbol;if(!E(this._fastUpdates,t,this._vvConvertOptions))return V.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return V.FastUpdate}_getVertexData(e){let t=0;const i=e.paths,r=[],s=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const c of i)t+=c.length;const n=_(3*t);let l,h=0;for(const c of i){r.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||s.equals(a)||d(n,s,0,n,a,0,t)?(null==a||a.equals(o)?l=v(n):(l=_(3*t),d(n,a,0,l,o,0,t)),{pathVertexDataInfos:r,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,s,a,o){this.usedMemory=0;const n=e.geometry,l=this._getVertexData(n);if(null==l)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===l.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,m=u(),f=this._context.renderCoordsHelper,d=new z(l.vertexDataES);for(const u of l.pathVertexDataInfos){const n=u.numVertices;if(n<2)continue;const _=u.offset;if(null!=this._context.clippingExtent&&(y(m),b(m,l.vertexDataES,_,n),!g(m,this._context.clippingExtent)))continue;const v=new Array,w=_+3*n;for(let e=_;e<w;e+=3){d.offset=e;const t=x(d,this._context.elevationProvider,a,f);h(he,l.vertexDataRS[e],l.vertexDataRS[e+1],l.vertexDataRS[e+2]),f.setAltitude(he,t),l.vertexDataRS[e]=he[0],l.vertexDataRS[e+1]=he[1],l.vertexDataRS[e+2]=he[2],v.push($(this._upVectorAlignment))}const P=new B(v,l.vertexDataES,l.vertexDataRS,_);ae(P,this._upVectorAlignment,this._context.renderCoordsHelper);const j=new O(P,this._profile,this._extruder,this._startCap,this._endCap);let S=null;if(this._fastUpdates){const t=this._fastUpdates.visualVariables,i=R(t.size?.field,e)??0,r=R(t.color?.field,e)??0,s=R(t.opacity?.field,e)??0;S=new J(j,i,r,s)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];if(this._drivenProperties.size){const t=s.size;e[0]*=oe(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=oe(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}let t;this._drivenProperties.color&&(t=s.color),this._drivenProperties.opacity&&null!=s.opacity&&(t=t?[t[0],t[1],t[2],s.opacity]:[1,1,1,s.opacity]);const i=new K(j);i.bake(e),t&&i.bakeVertexColors(t),S=i}const D=S.createGeometryData(),C=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid}),L=new W(this._materials[0],D,S,p,this._stencilWidth,C);L.transformation=t(r(),i,j.path.origin),c.push(L),this.usedMemory+=j.usedMemory}if(0===c.length)return null;const _=new G({geometries:c,layerUid:this._context.layer.uid,graphicUid:o}),v=new j(this,_,c,null,null,((e,t,i,r,s)=>le(e,t,r,s,this._upVectorAlignment)),a);return v.alignedSampledElevation=0,v.needsElevationUpdates=w(a.mode),v}}function ae(e,t,i){const{origin:r,positions:s}=e;let a=e.offset;switch(t){default:case T.World:for(const t of e.vertices)he[0]=s[a++]+r[0],he[1]=s[a++]+r[1],he[2]=s[a++]+r[2],i.worldUpAtPosition(he,he),t.setFrameFromUpVector(he);break;case T.Path:he[0]=s[a]+r[0],he[1]=s[a+1]+r[1],he[2]=s[a+2]+r[2],i.worldUpAtPosition(he,he),Q(e,he)}}function oe(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function ne(e,t,i,r){let s=0;const{origin:a,vertices:o,positions:n,positionsES:l}=e,c=e.offset+3*o.length;for(let p=e.offset;p<c;p+=3)h(he,l[p],l[p+1],l[p+2]),i(he,ce),s+=ce.sampledElevation,he[0]=n[p]+a[0],he[1]=n[p+1]+a[1],he[2]=n[p+2]+a[2],r.setAltitude(he,ce.z),n[p]=he[0]-a[0],n[p+1]=he[1]-a[1],n[p+2]=he[2]-a[2];return e.updatePathVertexInformation(),s/o.length}function le(e,t,i,r,s){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!Z(l))continue;const e=l.path,o=e.builder.path;n+=ne(o,t,i,r),s!==T.World&&ae(o,s,r),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(l,ee.POSITION)}return n/o.length}const he=f(),ce=new P;export{se 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.31/esri/copyright.txt for details.
4
4
  */
5
- import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as o}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as r}from"../../../../geometry/projection/projectBuffer.js";import{isDehydratedPoint as i}from"../../../../layers/graphics/dehydratedFeatureUtils.js";import{isSamplePosition as a,getElevationAtPoint as s}from"../../support/ElevationProvider.js";import{VertexAttribute as l}from"../../webgl-engine/lib/VertexAttribute.js";function u(e,t,n,o,i,a,s,l,u,c,f){const m=x[f.mode];let d,g,p=0;if(r(e,t,n,o,u.spatialReference,i,l))return m.requiresAlignment(f)?(p=m.applyElevationAlignmentBuffer(o,i,a,s,l,u,c,f),d=a,g=s):(d=o,g=i),r(d,u.spatialReference,g,a,c.spatialReference,s,l)?p:void 0}function c(e,t,n,o,r){const l=(i(e)?e.z:a(e)?e.array[e.offset+2]:e[2])||0;switch(n.mode){case"on-the-ground":{const n=s(t,e,"ground")??0;return r.verticalDistanceToGround=0,r.sampledElevation=n,void(r.z=n)}case"relative-to-ground":{const i=s(t,e,"ground")??0,a=n.geometryZWithOffset(l,o);return r.verticalDistanceToGround=a,r.sampledElevation=i,void(r.z=a+i)}case"relative-to-scene":{const i=s(t,e,"scene")??0,a=n.geometryZWithOffset(l,o);return r.verticalDistanceToGround=a,r.sampledElevation=i,void(r.z=a+i)}case"absolute-height":{const i=n.geometryZWithOffset(l,o),a=s(t,e,"ground")??0;return r.verticalDistanceToGround=i-a,r.sampledElevation=a,void(r.z=i)}default:return void(r.z=0)}}function f(e,t,n,o){return c(e,t,n,o,D),D.z}function m(e,t,n){return"on-the-ground"===t&&"on-the-ground"===n?e.staysOnTheGround:t===n||"on-the-ground"!==t&&"on-the-ground"!==n?null==t||null==n?e.definedChanged:b.UPDATE:e.onTheGroundChanged}function d(e){return"relative-to-ground"===e||"relative-to-scene"===e}function g(e){return"absolute-height"!==e}function p(t,n,r,i,a){c(n,r,a,i,D),E(t,D.verticalDistanceToGround);const s=D.sampledElevation,l=e(C,t.transformation);O[0]=n.x,O[1]=n.y,O[2]=D.z;return o(n.spatialReference,O,l,i.spatialReference)?t.transformation=l:console.warn("Could not locate symbol object properly, it might be misplaced"),s}function E(e,t){for(let n=0;n<e.geometries.length;++n){const o=e.geometries[n].getMutableAttribute(l.CENTEROFFSETANDDISTANCE);o&&o.data[3]!==t&&(o.data[3]=t,e.geometryVertexAttributeUpdated(e.geometries[n],l.CENTEROFFSETANDDISTANCE))}}function v(e,t,n,o,r,i){let a=0;const s=i.spatialReference;t*=3,o*=3;for(let l=0;l<r;++l){const r=e[t],l=e[t+1],u=e[t+2],c=i.getElevation(r,l,u,s,"ground")??0;a+=c,n[o]=r,n[o+1]=l,n[o+2]=c,t+=3,o+=3}return a/r}function h(e,t,n,o,r,i,a,s){let l=0;const u=s.calculateOffsetRenderUnits(a),c=s.featureExpressionInfoContext,f=i.spatialReference;t*=3,o*=3;for(let m=0;m<r;++m){const r=e[t],a=e[t+1],s=e[t+2],m=i.getElevation(r,a,s,f,"ground")??0;l+=m,n[o]=r,n[o+1]=a,n[o+2]=null==c?s+m+u:m+u,t+=3,o+=3}return l/r}function A(e,t,n,o,r,i,a,s){let l=0;const u=s.calculateOffsetRenderUnits(a),c=s.featureExpressionInfoContext,f=i.spatialReference;t*=3,o*=3;for(let m=0;m<r;++m){const r=e[t],a=e[t+1],s=e[t+2],m=i.getElevation(r,a,s,f,"scene")??0;l+=m,n[o]=r,n[o+1]=a,n[o+2]=null==c?s+m+u:m+u,t+=3,o+=3}return l/r}function T(e){const t=e.meterUnitOffset,n=e.featureExpressionInfoContext;return 0!==t||null!=n}function y(e,t,n,o,r,i,a,s){const l=s.calculateOffsetRenderUnits(a),u=s.featureExpressionInfoContext;t*=3,o*=3;for(let c=0;c<r;++c){const r=e[t],i=e[t+1],a=e[t+2];n[o]=r,n[o+1]=i,n[o+2]=null==u?a+l:l,t+=3,o+=3}return 0}class R{constructor(){this.verticalDistanceToGround=0,this.sampledElevation=0,this.z=0}}var b;!function(e){e[e.NONE=0]="NONE",e[e.UPDATE=1]="UPDATE",e[e.RECREATE=2]="RECREATE"}(b||(b={}));const x={"absolute-height":{applyElevationAlignmentBuffer:y,requiresAlignment:T},"on-the-ground":{applyElevationAlignmentBuffer:v,requiresAlignment:()=>!0},"relative-to-ground":{applyElevationAlignmentBuffer:h,requiresAlignment:()=>!0},"relative-to-scene":{applyElevationAlignmentBuffer:A,requiresAlignment:()=>!0}},C=t(),D=new R,O=n();export{R as SampleElevationInfo,b as SymbolUpdateType,p as applyElevationAlignmentForHUD,u as applyPerVertexElevationAlignment,m as elevationModeChangeUpdateType,f as evaluateElevationAlignmentAtPoint,c as evaluateElevationInfoAtPoint,d as needsElevationUpdates2D,g as needsElevationUpdates3D,E as updateVertexPointGroundDistance};
5
+ import{copy as e}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as t}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as o}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as r}from"../../../../geometry/projection/projectBuffer.js";import{isDehydratedPoint as i}from"../../../../layers/graphics/dehydratedFeatureUtils.js";import{isSamplePosition as a,getElevationAtPoint as s}from"../../support/ElevationProvider.js";import{VertexAttribute as l}from"../../webgl-engine/lib/VertexAttribute.js";function u(e,t,n,o,i,a,s,l,u,c,f){const m=x[f.mode];let d,g,p=0;if(r(e,t,n,o,u.spatialReference,i,l))return m?.requiresAlignment(f)?(p=m.applyElevationAlignmentBuffer(o,i,a,s,l,u,c,f),d=a,g=s):(d=o,g=i),r(d,u.spatialReference,g,a,c.spatialReference,s,l)?p:void 0}function c(e,t,n,o,r){const l=(i(e)?e.z:a(e)?e.array[e.offset+2]:e[2])||0;switch(n.mode){case"on-the-ground":{const n=s(t,e,"ground")??0;return r.verticalDistanceToGround=0,r.sampledElevation=n,void(r.z=n)}case"relative-to-ground":{const i=s(t,e,"ground")??0,a=n.geometryZWithOffset(l,o);return r.verticalDistanceToGround=a,r.sampledElevation=i,void(r.z=a+i)}case"relative-to-scene":{const i=s(t,e,"scene")??0,a=n.geometryZWithOffset(l,o);return r.verticalDistanceToGround=a,r.sampledElevation=i,void(r.z=a+i)}case"absolute-height":{const i=n.geometryZWithOffset(l,o),a=s(t,e,"ground")??0;return r.verticalDistanceToGround=i-a,r.sampledElevation=a,void(r.z=i)}default:return void(r.z=0)}}function f(e,t,n,o){return c(e,t,n,o,D),D.z}function m(e,t,n){return"on-the-ground"===t&&"on-the-ground"===n?e.staysOnTheGround:t===n||"on-the-ground"!==t&&"on-the-ground"!==n?null==t||null==n?e.definedChanged:b.UPDATE:e.onTheGroundChanged}function d(e){return"relative-to-ground"===e||"relative-to-scene"===e}function g(e){return"absolute-height"!==e}function p(t,n,r,i,a){c(n,r,a,i,D),E(t,D.verticalDistanceToGround);const s=D.sampledElevation,l=e(C,t.transformation);O[0]=n.x,O[1]=n.y,O[2]=D.z;return o(n.spatialReference,O,l,i.spatialReference)?t.transformation=l:console.warn("Could not locate symbol object properly, it might be misplaced"),s}function E(e,t){for(let n=0;n<e.geometries.length;++n){const o=e.geometries[n].getMutableAttribute(l.CENTEROFFSETANDDISTANCE);o&&o.data[3]!==t&&(o.data[3]=t,e.geometryVertexAttributeUpdated(e.geometries[n],l.CENTEROFFSETANDDISTANCE))}}function v(e,t,n,o,r,i){let a=0;const s=i.spatialReference;t*=3,o*=3;for(let l=0;l<r;++l){const r=e[t],l=e[t+1],u=e[t+2],c=i.getElevation(r,l,u,s,"ground")??0;a+=c,n[o]=r,n[o+1]=l,n[o+2]=c,t+=3,o+=3}return a/r}function h(e,t,n,o,r,i,a,s){let l=0;const u=s.calculateOffsetRenderUnits(a),c=s.featureExpressionInfoContext,f=i.spatialReference;t*=3,o*=3;for(let m=0;m<r;++m){const r=e[t],a=e[t+1],s=e[t+2],m=i.getElevation(r,a,s,f,"ground")??0;l+=m,n[o]=r,n[o+1]=a,n[o+2]=null==c?s+m+u:m+u,t+=3,o+=3}return l/r}function A(e,t,n,o,r,i,a,s){let l=0;const u=s.calculateOffsetRenderUnits(a),c=s.featureExpressionInfoContext,f=i.spatialReference;t*=3,o*=3;for(let m=0;m<r;++m){const r=e[t],a=e[t+1],s=e[t+2],m=i.getElevation(r,a,s,f,"scene")??0;l+=m,n[o]=r,n[o+1]=a,n[o+2]=null==c?s+m+u:m+u,t+=3,o+=3}return l/r}function T(e){const t=e.meterUnitOffset,n=e.featureExpressionInfoContext;return 0!==t||null!=n}function y(e,t,n,o,r,i,a,s){const l=s.calculateOffsetRenderUnits(a),u=s.featureExpressionInfoContext;t*=3,o*=3;for(let c=0;c<r;++c){const r=e[t],i=e[t+1],a=e[t+2];n[o]=r,n[o+1]=i,n[o+2]=null==u?a+l:l,t+=3,o+=3}return 0}class R{constructor(){this.verticalDistanceToGround=0,this.sampledElevation=0,this.z=0}}var b;!function(e){e[e.NONE=0]="NONE",e[e.UPDATE=1]="UPDATE",e[e.RECREATE=2]="RECREATE"}(b||(b={}));const x={"absolute-height":{applyElevationAlignmentBuffer:y,requiresAlignment:T},"on-the-ground":{applyElevationAlignmentBuffer:v,requiresAlignment:()=>!0},"relative-to-ground":{applyElevationAlignmentBuffer:h,requiresAlignment:()=>!0},"relative-to-scene":{applyElevationAlignmentBuffer:A,requiresAlignment:()=>!0}},C=t(),D=new R,O=n();export{R as SampleElevationInfo,b as SymbolUpdateType,p as applyElevationAlignmentForHUD,u as applyPerVertexElevationAlignment,m as elevationModeChangeUpdateType,f as evaluateElevationAlignmentAtPoint,c as evaluateElevationInfoAtPoint,d as needsElevationUpdates2D,g as needsElevationUpdates3D,E as updateVertexPointGroundDistance};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Logger.js";import{s as t,l as n}from"../../../../chunks/vec32.js";import{ZEROS as r,fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,center as c,height as s}from"../../../../geometry/support/aaBoundingBox.js";import{labelMarginPx as o}from"./constants.js";import{getGraphics3DSymbol as i}from"./graphicSymbolUtils.js";import{LabelPlacement as f}from"./LabelParameters.js";import{textVerticalPaddingPx as m}from"../../webgl-engine/lib/TextRenderer.js";import{HUDMaterial as p}from"../../webgl-engine/materials/HUDMaterial.js";const u=()=>e.getLogger("esri.views.3d.layers.graphics.labelPlacement");class b{constructor(e,t,n,r=null){this.graphics3DGraphic=e,this.labelSymbol=t,this.labelClass=n,this.disablePlacement=r}}function h(e){const t=k(e);if(null==t)return null;const n=g(e,t);if(null==n)return null;const r=n.anchor,l=!!t.hasLabelVerticalOffset,a=t.verticalOffset;return P(new f(a,r,l),n,e)}function g(e,t){if(t.anchor)return t;const n=e.labelClass.labelPlacement,r=V[n],l=r||v(e);return n&&!r&&u().warnOncePerTick(`the requested label placement '${n}' is currently unsupported in SceneView.`),d(l,e)}function O(e){const t=e.graphics3DGraphic.graphics3DSymbol,n=i(t);return null!=n?n.symbol.symbolLayers.at(0):null}function d(e,t){const n=t.graphics3DGraphic.graphic.geometry;if(null==n)return null;if(null!=t.disablePlacement){return t.labelClass.labelPlacement?(u().warnOncePerTick(y(e?.placement,t.disablePlacement.logEntityDescription)),v(t)):e}const r=n.type;switch(r){case"polyline":case"polygon":case"extent":case"multipoint":if(t.labelClass.labelPlacement)return u().warnOncePerTick(y(e?.placement,`'${r}' geometries`)),v(t);break;case"point":case"mesh":return e}return e}function y(e,t){return`the requested label placement '${e}' is currently unsupported for ${t} in SceneView.`}function v(e){const t=e.graphics3DGraphic.graphic.geometry;if(null==t)return null;switch(t.type){case"polyline":case"extent":case"multipoint":return{placement:"center-center",normalizedOffset:r,anchor:"center"};case"polygon":{const t=O(e);return null!=t&&"extrude"===t.type?V["above-center"]:{placement:"center-center",normalizedOffset:r,anchor:"center"}}case"point":case"mesh":return V["above-center"];default:return}}function P(e,t,n){const r=n.graphics3DGraphic.graphic.geometry;if(null==r)return null;switch(r.type){case"point":z(e,t,n);break;case"mesh":L(e,t,n);break;case"polygon":w(e,t,n)}const l=o-m;return e.screenOffset[0]+=l*t.normalizedOffset[0],e.screenOffset[1]+=l*t.normalizedOffset[1],e}function w(e,n,r){const l=O(r);if(null!=l)switch(l.type){case"extrude":{const l=r.graphics3DGraphic.layers[0];null!=l?(l.getBoundingBoxObjectSpace(B),c(B,e.translation),e.translation[2]=s(B)/2):t(e.translation,0,0,0),D(e,n,l);break}}}function z(e,n,r){const l=O(r);if(null==l)return;const a=r.graphics3DGraphic.layers[0];switch(null!=a?a.getCenterObjectSpace(e.translation):t(e.translation,0,0,0),l.type){case"icon":case"text":S(e,n,r,a);break;case"object":D(e,n,a)}}function L(e,t,n){const r=O(n);if(null==r)return;const l=n.graphics3DGraphic.layers[0];if("fill"===r.type)D(e,t,l)}function S(e,t,n,r){const{graphics3DGraphic:l}=n,a=null!=r?r.getScreenSize():null;if(l.isDraped||null==a)e.hasLabelVerticalOffset||"center"===e.anchor||(V[n.labelClass.labelPlacement]&&u().warnOncePerTick(`the requested placement '${t.placement}' is currently unsupported for draped graphics`),e.anchor="center");else{const r=j(n);e.screenOffset[0]=a[0]/2*(t.normalizedOffset[0]-r[0]);const l=a[1]/2*(t.normalizedOffset[1]-r[1]);e.hasLabelVerticalOffset?(e.centerOffset[1]=l,e.centerOffsetUnits="screen"):e.screenOffset[1]=l}}function j(e,t=G){const{graphics3DGraphic:n}=e,r=n.layers[0],l=r?.stageObject.geometries[0].material??null;if(l&&l instanceof p){const e=l.parameters.anchorPosition;t[0]=2*(e[0]-.5),t[1]=2*(e[1]-.5)}else t[0]=0,t[1]=0;return t}function D(e,t,r){const a=null!=r?r.getBoundingBoxObjectSpace(B):B,c=l(a[3]-a[0],a[4]-a[1],a[5]-a[2]),s=Math.sqrt(c[0]*c[0]+c[1]*c[1]);e.centerOffset[0]=s/2*t.normalizedOffset[0];const o=e.translation[2],i=c[2]/2*t.normalizedOffset[1];e.translation[2]=0,e.elevationOffset=o+i;const f=n(c);e.centerOffset[2]=f/2*t.normalizedOffset[2]}function C(e){return"above-center"===e}function k(e){const t=e.labelClass.labelPlacement,{labelSymbol:n,graphics3DGraphic:r}=e,l=i(r.graphics3DSymbol),a="point-3d"===l?.symbol.type?l.symbol:null,c=V[t]||v(e);return null!=a&&a.supportsCallout()&&a.hasVisibleVerticalOffset()&&!r.isDraped?{placement:null,hasLabelVerticalOffset:!1,verticalOffset:a.verticalOffset.clone(),anchor:null,normalizedOffset:null}:!n||!n.hasVisibleVerticalOffset()||null!=a&&a.supportsCallout()&&a.verticalOffset&&!r.isDraped?{placement:null,verticalOffset:null,anchor:null,normalizedOffset:null,hasLabelVerticalOffset:!1}:c&&C(c.placement)?{placement:"above-center",verticalOffset:n.verticalOffset.clone(),anchor:"bottom",normalizedOffset:[0,c.normalizedOffset[1],0],hasLabelVerticalOffset:!0}:(u().errorOncePerTick("Callouts and vertical offset on labels are currently only supported with 'above-center' label placement (not with "+t+" placement)"),null)}const V={"above-center":{placement:"above-center",normalizedOffset:[0,1,0],anchor:"bottom"},"above-left":{placement:"above-left",normalizedOffset:[-1,1,0],anchor:"bottom-right"},"above-right":{placement:"above-right",normalizedOffset:[1,1,0],anchor:"bottom-left"},"below-center":{placement:"below-center",normalizedOffset:[0,-1,2],anchor:"top"},"below-left":{placement:"below-left",normalizedOffset:[-1,-1,0],anchor:"top-right"},"below-right":{placement:"below-right",normalizedOffset:[1,-1,0],anchor:"top-left"},"center-center":{placement:"center-center",normalizedOffset:[0,0,1],anchor:"center"},"center-left":{placement:"center-left",normalizedOffset:[-1,0,0],anchor:"right"},"center-right":{placement:"center-right",normalizedOffset:[1,0,0],anchor:"left"}},x={"above-center":["default","esriServerPointLabelPlacementAboveCenter"],"above-left":["esriServerPointLabelPlacementAboveLeft"],"above-right":["esriServerPointLabelPlacementAboveRight"],"below-center":["esriServerPointLabelPlacementBelowCenter"],"below-left":["esriServerPointLabelPlacementBelowLeft"],"below-right":["esriServerPointLabelPlacementBelowRight"],"center-center":["esriServerPointLabelPlacementCenterCenter"],"center-left":["esriServerPointLabelPlacementCenterLeft"],"center-right":["esriServerPointLabelPlacementCenterRight"]};for(const T in x){const e=x[T],t=V[T];e.forEach((e=>{V[e]=t}))}Object.freeze&&(Object.freeze(V),Object.keys(V).forEach((e=>{Object.freeze(V[e]),Object.freeze(V[e]?.normalizedOffset)})));const G=[0,0],B=a();export{b as LabelInfo,h as getLabelPlacement};
5
+ import"../../../../core/has.js";import e from"../../../../core/Logger.js";import{a as t,m as n}from"../../../../chunks/vec32.js";import{ZEROS as r,fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as a,center as c,height as s}from"../../../../geometry/support/aaBoundingBox.js";import{labelMarginPx as o}from"./constants.js";import{getGraphics3DSymbol as i}from"./graphicSymbolUtils.js";import{LabelPlacement as f}from"./LabelParameters.js";import{textVerticalPaddingPx as m}from"../../webgl-engine/lib/TextRenderer.js";import{HUDMaterial as p}from"../../webgl-engine/materials/HUDMaterial.js";const u=()=>e.getLogger("esri.views.3d.layers.graphics.labelPlacement");class b{constructor(e,t,n,r=null){this.graphics3DGraphic=e,this.labelSymbol=t,this.labelClass=n,this.disablePlacement=r}}function h(e){const t=k(e);if(null==t)return null;const n=g(e,t);if(null==n)return null;const r=n.anchor,l=!!t.hasLabelVerticalOffset,a=t.verticalOffset;return P(new f(a,r,l),n,e)}function g(e,t){if(t.anchor)return t;const n=e.labelClass.labelPlacement,r=V[n],l=r||v(e);return n&&!r&&u().warnOncePerTick(`the requested label placement '${n}' is currently unsupported in SceneView.`),d(l,e)}function O(e){const t=e.graphics3DGraphic.graphics3DSymbol,n=i(t);return null!=n?n.symbol.symbolLayers.at(0):null}function d(e,t){const n=t.graphics3DGraphic.graphic.geometry;if(null==n)return null;if(null!=t.disablePlacement){return t.labelClass.labelPlacement?(u().warnOncePerTick(y(e?.placement,t.disablePlacement.logEntityDescription)),v(t)):e}const r=n.type;switch(r){case"polyline":case"polygon":case"extent":case"multipoint":if(t.labelClass.labelPlacement)return u().warnOncePerTick(y(e?.placement,`'${r}' geometries`)),v(t);break;case"point":case"mesh":return e}return e}function y(e,t){return`the requested label placement '${e}' is currently unsupported for ${t} in SceneView.`}function v(e){const t=e.graphics3DGraphic.graphic.geometry;if(null==t)return null;switch(t.type){case"polyline":case"extent":case"multipoint":return{placement:"center-center",normalizedOffset:r,anchor:"center"};case"polygon":{const t=O(e);return null!=t&&"extrude"===t.type?V["above-center"]:{placement:"center-center",normalizedOffset:r,anchor:"center"}}case"point":case"mesh":return V["above-center"];default:return}}function P(e,t,n){const r=n.graphics3DGraphic.graphic.geometry;if(null==r)return null;switch(r.type){case"point":z(e,t,n);break;case"mesh":L(e,t,n);break;case"polygon":w(e,t,n)}const l=o-m;return e.screenOffset[0]+=l*t.normalizedOffset[0],e.screenOffset[1]+=l*t.normalizedOffset[1],e}function w(e,n,r){const l=O(r);if(null!=l)switch(l.type){case"extrude":{const l=r.graphics3DGraphic.layers[0];null!=l?(l.getBoundingBoxObjectSpace(B),c(B,e.translation),e.translation[2]=s(B)/2):t(e.translation,0,0,0),D(e,n,l);break}}}function z(e,n,r){const l=O(r);if(null==l)return;const a=r.graphics3DGraphic.layers[0];switch(null!=a?a.getCenterObjectSpace(e.translation):t(e.translation,0,0,0),l.type){case"icon":case"text":S(e,n,r,a);break;case"object":D(e,n,a)}}function L(e,t,n){const r=O(n);if(null==r)return;const l=n.graphics3DGraphic.layers[0];if("fill"===r.type)D(e,t,l)}function S(e,t,n,r){const{graphics3DGraphic:l}=n,a=null!=r?r.getScreenSize():null;if(l.isDraped||null==a)e.hasLabelVerticalOffset||"center"===e.anchor||(V[n.labelClass.labelPlacement]&&u().warnOncePerTick(`the requested placement '${t.placement}' is currently unsupported for draped graphics`),e.anchor="center");else{const r=j(n);e.screenOffset[0]=a[0]/2*(t.normalizedOffset[0]-r[0]);const l=a[1]/2*(t.normalizedOffset[1]-r[1]);e.hasLabelVerticalOffset?(e.centerOffset[1]=l,e.centerOffsetUnits="screen"):e.screenOffset[1]=l}}function j(e,t=G){const{graphics3DGraphic:n}=e,r=n.layers[0],l=r?.stageObject.geometries[0].material??null;if(l&&l instanceof p){const e=l.parameters.anchorPosition;t[0]=2*(e[0]-.5),t[1]=2*(e[1]-.5)}else t[0]=0,t[1]=0;return t}function D(e,t,r){const a=null!=r?r.getBoundingBoxObjectSpace(B):B,c=l(a[3]-a[0],a[4]-a[1],a[5]-a[2]),s=Math.sqrt(c[0]*c[0]+c[1]*c[1]);e.centerOffset[0]=s/2*t.normalizedOffset[0];const o=e.translation[2],i=c[2]/2*t.normalizedOffset[1];e.translation[2]=0,e.elevationOffset=o+i;const f=n(c);e.centerOffset[2]=f/2*t.normalizedOffset[2]}function C(e){return"above-center"===e}function k(e){const t=e.labelClass.labelPlacement,{labelSymbol:n,graphics3DGraphic:r}=e,l=i(r.graphics3DSymbol),a="point-3d"===l?.symbol.type?l.symbol:null,c=V[t]||v(e);return null!=a&&a.supportsCallout()&&a.hasVisibleVerticalOffset()&&!r.isDraped?{placement:null,hasLabelVerticalOffset:!1,verticalOffset:a.verticalOffset.clone(),anchor:null,normalizedOffset:null}:!n||!n.hasVisibleVerticalOffset()||null!=a&&a.supportsCallout()&&a.verticalOffset&&!r.isDraped?{placement:null,verticalOffset:null,anchor:null,normalizedOffset:null,hasLabelVerticalOffset:!1}:c&&C(c.placement)?{placement:"above-center",verticalOffset:n.verticalOffset.clone(),anchor:"bottom",normalizedOffset:[0,c.normalizedOffset[1],0],hasLabelVerticalOffset:!0}:(u().errorOncePerTick("Callouts and vertical offset on labels are currently only supported with 'above-center' label placement (not with "+t+" placement)"),null)}const V={"above-center":{placement:"above-center",normalizedOffset:[0,1,0],anchor:"bottom"},"above-left":{placement:"above-left",normalizedOffset:[-1,1,0],anchor:"bottom-right"},"above-right":{placement:"above-right",normalizedOffset:[1,1,0],anchor:"bottom-left"},"below-center":{placement:"below-center",normalizedOffset:[0,-1,2],anchor:"top"},"below-left":{placement:"below-left",normalizedOffset:[-1,-1,0],anchor:"top-right"},"below-right":{placement:"below-right",normalizedOffset:[1,-1,0],anchor:"top-left"},"center-center":{placement:"center-center",normalizedOffset:[0,0,1],anchor:"center"},"center-left":{placement:"center-left",normalizedOffset:[-1,0,0],anchor:"right"},"center-right":{placement:"center-right",normalizedOffset:[1,0,0],anchor:"left"}},x={"above-center":["default","esriServerPointLabelPlacementAboveCenter"],"above-left":["esriServerPointLabelPlacementAboveLeft"],"above-right":["esriServerPointLabelPlacementAboveRight"],"below-center":["esriServerPointLabelPlacementBelowCenter"],"below-left":["esriServerPointLabelPlacementBelowLeft"],"below-right":["esriServerPointLabelPlacementBelowRight"],"center-center":["esriServerPointLabelPlacementCenterCenter"],"center-left":["esriServerPointLabelPlacementCenterLeft"],"center-right":["esriServerPointLabelPlacementCenterRight"]};for(const T in x){const e=x[T],t=V[T];e.forEach((e=>{V[e]=t}))}Object.freeze&&(Object.freeze(V),Object.keys(V).forEach((e=>{Object.freeze(V[e]),Object.freeze(V[e]?.normalizedOffset)})));const G=[0,0],B=a();export{b as LabelInfo,h as getLabelPlacement};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as r,fromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as a,f as u,D as c,l as m,n as f,o as d}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as g,expandWithVec3 as x}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as h,BufferViewVec4u8 as T,BufferViewVec4u16 as y,BufferViewVec3f as w,BufferViewVec3u8 as v,BufferViewVec3u16 as R}from"../../../../geometry/support/buffer/BufferView.js";import{a as j,t as B,n as M,f as S}from"../../../../chunks/vec3.js";import{t as F,b as L}from"../../../../chunks/vec4.js";import{a as A}from"../../../../chunks/vec2.js";import{c as E}from"../../../../chunks/vec33.js";import{a as O}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as I}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as C}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as k}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as N}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as P}from"./ProcessedObjectResource.js";import{load as U,processLoadResult as D}from"./wosrLoader.js";import{NormalType as V}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as _}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as G,DepthTestFunction as H,CullFaceOptions as q}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as W}from"../../webgl-engine/lib/Geometry.js";import{Texture as $}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as z}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as K}from"../../webgl-engine/materials/DefaultMaterial.js";import{colorGamma as Q}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as J,defaultAdvancedMRRFactors as X,useSchematicPBR as Y,defaultSchematicMRRFactors as Z}from"../../webgl-engine/materials/pbrUtils.js";async function ee(t,r){const o=te(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):U(o.url,r)),{engineResources:t,referenceBoundingBox:s}=D(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(r.cache)s=await r.cache.loadGLTF(o.url,r,!!r.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new I(r.streamDataRequester),o.url,r,r.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,le(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...J]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...X]},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=re(s,a,u,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function te(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function re(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,a=s.lods.length,u=g();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new P(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new K({}):oe(s,e,f,t,r,n,l),{geometry:i,vertexCount:a}=se(e,null!=o?o:new K({})),d=i.boundingInfo;null!=d&&0===c&&(x(u,d.bbMin),x(u,d.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=a)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:u}}function oe(e,t,r,o,s,i,n){const a=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),u=e.materials.get(t.material),c=null!=t.attributes.texCoord0,m=null!=t.attributes.normal;if(null==u)return null;const f=ne(u.alphaMode);if(!i.has(a)){if(c){const t=(t,r=!1)=>{if(null!=t&&!n.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;n.set(t,new $(k(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!k(e)&&r,encoding:k(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(u.textureColor,f!==G.Opaque),t(u.textureNormal),t(u.textureOcclusion),t(u.textureEmissive),t(u.textureMetallicRoughness)}const r=u.color[0]**(1/Q),d=u.color[1]**(1/Q),p=u.color[2]**(1/Q),g=u.emissiveFactor[0]**(1/Q),x=u.emissiveFactor[1]**(1/Q),b=u.emissiveFactor[2]**(1/Q),h=null!=u.textureColor&&c?n.get(u.textureColor):null,T=Y({normalTexture:u.textureNormal,metallicRoughnessTexture:u.textureMetallicRoughness,metallicFactor:u.metallicFactor,roughnessFactor:u.roughnessFactor,emissiveTexture:u.textureEmissive,emissiveFactor:u.emissiveFactor,occlusionTexture:u.textureOcclusion}),y=null!=u.normalTextureTransform?.scale?u.normalTextureTransform?.scale:l;i.set(a,new K({...o,transparent:f===G.Blend,customDepthTest:H.Lequal,textureAlphaMode:f,textureAlphaCutoff:u.alphaCutoff,diffuse:[r,d,p],ambient:[r,d,p],opacity:u.opacity,doubleSided:u.doubleSided,doubleSidedType:"winding-order",cullFace:u.doubleSided?q.None:q.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:m?V.Attribute:V.ScreenDerivative,castShadows:!0,receiveShadows:u.receiveShadows,receiveAmbientOcclusion:u.receiveAmbientOcclustion,textureId:null!=h?h.id:void 0,colorMixMode:u.colorMixMode,normalTextureId:null!=u.textureNormal&&c?n.get(u.textureNormal).id:void 0,textureAlphaPremultiplied:null!=h&&!!h.parameters.preMultiplyAlpha,occlusionTextureId:null!=u.textureOcclusion&&c?n.get(u.textureOcclusion).id:void 0,emissiveTextureId:null!=u.textureEmissive&&c?n.get(u.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=u.textureMetallicRoughness&&c?n.get(u.textureMetallicRoughness).id:void 0,emissiveFactor:[g,x,b],mrrFactors:T?[...Z]:[u.metallicFactor,u.roughnessFactor,o.mrrFactors[2]],isSchematic:T,colorTextureTransformMatrix:N(u.colorTextureTransform),normalTextureTransformMatrix:N(u.normalTextureTransform),scale:[y[0],y[1]],occlusionTextureTransformMatrix:N(u.occlusionTextureTransform),emissiveTextureTransformMatrix:N(u.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:N(u.metallicRoughnessTextureTransform),...s}))}const d=i.get(a);if(r.stageResources.materials.push(d),c){const e=e=>{null!=e&&r.stageResources.textures.push(n.get(e))};e(u.textureColor),e(u.textureNormal),e(u.textureOcclusion),e(u.textureEmissive),e(u.textureMetallicRoughness)}return d}function se(e,s){const i=e.attributes.position.count,n=C(e.indices||i,e.primitiveType),l=b(3*i),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;j(l,a,e.transform,3,u);const c=[[z.POSITION,new _(l,n,3,!0)]];if(null!=e.attributes.normal){const o=b(3*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.normal;r(ie,e.transform),B(o,s,ie,3,l),t(ie)&&M(o,o),c.push([z.NORMAL,new _(o,n,3,!0)])}if(null!=e.attributes.tangent){const r=b(4*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.tangent;o(ie,e.transform),F(r,s,ie,4,l),t(ie)&&M(r,r,4),c.push([z.TANGENT,new _(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const t=b(2*i),{typedBuffer:r,typedBufferStride:o}=e.attributes.texCoord0;A(t,r,2,o),c.push([z.UV0,new _(t,n,2,!0)])}const m=e.attributes.color;if(null!=m){const t=new Uint8Array(4*i);4===m.elementCount?m instanceof h?L(t,m,255):m instanceof T?O(t,m):m instanceof y&&L(t,m,1/256):(t.fill(255),m instanceof w?S(t,m.typedBuffer,255,4,m.typedBufferStride):e.attributes.color instanceof v?E(t,m.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof R&&S(t,m.typedBuffer,1/256,4,m.typedBufferStride)),c.push([z.COLOR,new _(t,n,4,!0)])}return{geometry:new W(s,c),vertexCount:i}}const ie=s();function ne(e){switch(e){case"BLEND":return G.Blend;case"MASK":return G.Mask;case"OPAQUE":case null:case void 0:return G.Opaque}}function le(e,t){for(let r=0;r<e.model.lods.length;++r){const o=e.model.lods[r];for(const s of o.parts){const o=s.attributes.normal;if(null==o)return;const l=s.attributes.position,g=l.count,x=p(),b=p(),h=p(),y=new Uint8Array(4*g),v=new Float64Array(3*g),R=i(n(),s.transform);let j=0,B=0;for(let i=0;i<g;i++){l.getVec(i,b),o.getVec(i,x),a(b,b,s.transform),u(h,b,t.center),c(h,h,t.radius);const n=h[2],p=m(h),g=Math.min(.45+.55*p*p,1);c(h,h,t.radius),null!==R&&a(h,h,R),f(h,h),r+1!==e.model.lods.length&&e.model.lods.length>1&&d(h,h,x,n>-1?.2:Math.min(-4*n-3.8,1)),v[j]=h[0],v[j+1]=h[1],v[j+2]=h[2],j+=3,y[B]=255*g,y[B+1]=255*g,y[B+2]=255*g,y[B+3]=255,B+=4}s.attributes.normal=new w(v),s.attributes.color=new T(y)}}}export{ee as fetch,re as gltfToEngineResources,te as parseUrl};
5
+ import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as r,fromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{h as a,f as u,D as c,m,n as f,o as d}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as g,expandWithVec3 as x}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as h,BufferViewVec4u8 as T,BufferViewVec4u16 as y,BufferViewVec3f as w,BufferViewVec3u8 as v,BufferViewVec3u16 as R}from"../../../../geometry/support/buffer/BufferView.js";import{a as j,t as B,n as M,f as S}from"../../../../chunks/vec3.js";import{t as F,b as L}from"../../../../chunks/vec4.js";import{a as A}from"../../../../chunks/vec2.js";import{c as E}from"../../../../chunks/vec33.js";import{a as O}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as I}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as C}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as k}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as N}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as P}from"./ProcessedObjectResource.js";import{load as U,processLoadResult as D}from"./wosrLoader.js";import{NormalType as V}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as _}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as G,DepthTestFunction as H,CullFaceOptions as q}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as W}from"../../webgl-engine/lib/Geometry.js";import{Texture as $}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as z}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as K}from"../../webgl-engine/materials/DefaultMaterial.js";import{colorGamma as Q}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as J,defaultAdvancedMRRFactors as X,useSchematicPBR as Y,defaultSchematicMRRFactors as Z}from"../../webgl-engine/materials/pbrUtils.js";async function ee(t,r){const o=te(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):U(o.url,r)),{engineResources:t,referenceBoundingBox:s}=D(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(r.cache)s=await r.cache.loadGLTF(o.url,r,!!r.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new I(r.streamDataRequester),o.url,r,r.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,le(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...J]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...X]},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=re(s,a,u,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function te(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function re(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,a=s.lods.length,u=g();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new P(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new K({}):oe(s,e,f,t,r,n,l),{geometry:i,vertexCount:a}=se(e,null!=o?o:new K({})),d=i.boundingInfo;null!=d&&0===c&&(x(u,d.bbMin),x(u,d.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=a)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:u}}function oe(e,t,r,o,s,i,n){const a=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),u=e.materials.get(t.material),c=null!=t.attributes.texCoord0,m=null!=t.attributes.normal;if(null==u)return null;const f=ne(u.alphaMode);if(!i.has(a)){if(c){const t=(t,r=!1)=>{if(null!=t&&!n.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;n.set(t,new $(k(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!k(e)&&r,encoding:k(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(u.textureColor,f!==G.Opaque),t(u.textureNormal),t(u.textureOcclusion),t(u.textureEmissive),t(u.textureMetallicRoughness)}const r=u.color[0]**(1/Q),d=u.color[1]**(1/Q),p=u.color[2]**(1/Q),g=u.emissiveFactor[0]**(1/Q),x=u.emissiveFactor[1]**(1/Q),b=u.emissiveFactor[2]**(1/Q),h=null!=u.textureColor&&c?n.get(u.textureColor):null,T=Y({normalTexture:u.textureNormal,metallicRoughnessTexture:u.textureMetallicRoughness,metallicFactor:u.metallicFactor,roughnessFactor:u.roughnessFactor,emissiveTexture:u.textureEmissive,emissiveFactor:u.emissiveFactor,occlusionTexture:u.textureOcclusion}),y=null!=u.normalTextureTransform?.scale?u.normalTextureTransform?.scale:l;i.set(a,new K({...o,transparent:f===G.Blend,customDepthTest:H.Lequal,textureAlphaMode:f,textureAlphaCutoff:u.alphaCutoff,diffuse:[r,d,p],ambient:[r,d,p],opacity:u.opacity,doubleSided:u.doubleSided,doubleSidedType:"winding-order",cullFace:u.doubleSided?q.None:q.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:m?V.Attribute:V.ScreenDerivative,castShadows:!0,receiveShadows:u.receiveShadows,receiveAmbientOcclusion:u.receiveAmbientOcclustion,textureId:null!=h?h.id:void 0,colorMixMode:u.colorMixMode,normalTextureId:null!=u.textureNormal&&c?n.get(u.textureNormal).id:void 0,textureAlphaPremultiplied:null!=h&&!!h.parameters.preMultiplyAlpha,occlusionTextureId:null!=u.textureOcclusion&&c?n.get(u.textureOcclusion).id:void 0,emissiveTextureId:null!=u.textureEmissive&&c?n.get(u.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=u.textureMetallicRoughness&&c?n.get(u.textureMetallicRoughness).id:void 0,emissiveFactor:[g,x,b],mrrFactors:T?[...Z]:[u.metallicFactor,u.roughnessFactor,o.mrrFactors[2]],isSchematic:T,colorTextureTransformMatrix:N(u.colorTextureTransform),normalTextureTransformMatrix:N(u.normalTextureTransform),scale:[y[0],y[1]],occlusionTextureTransformMatrix:N(u.occlusionTextureTransform),emissiveTextureTransformMatrix:N(u.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:N(u.metallicRoughnessTextureTransform),...s}))}const d=i.get(a);if(r.stageResources.materials.push(d),c){const e=e=>{null!=e&&r.stageResources.textures.push(n.get(e))};e(u.textureColor),e(u.textureNormal),e(u.textureOcclusion),e(u.textureEmissive),e(u.textureMetallicRoughness)}return d}function se(e,s){const i=e.attributes.position.count,n=C(e.indices||i,e.primitiveType),l=b(3*i),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;j(l,a,e.transform,3,u);const c=[[z.POSITION,new _(l,n,3,!0)]];if(null!=e.attributes.normal){const o=b(3*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.normal;r(ie,e.transform),B(o,s,ie,3,l),t(ie)&&M(o,o),c.push([z.NORMAL,new _(o,n,3,!0)])}if(null!=e.attributes.tangent){const r=b(4*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.tangent;o(ie,e.transform),F(r,s,ie,4,l),t(ie)&&M(r,r,4),c.push([z.TANGENT,new _(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const t=b(2*i),{typedBuffer:r,typedBufferStride:o}=e.attributes.texCoord0;A(t,r,2,o),c.push([z.UV0,new _(t,n,2,!0)])}const m=e.attributes.color;if(null!=m){const t=new Uint8Array(4*i);4===m.elementCount?m instanceof h?L(t,m,255):m instanceof T?O(t,m):m instanceof y&&L(t,m,1/256):(t.fill(255),m instanceof w?S(t,m.typedBuffer,255,4,m.typedBufferStride):e.attributes.color instanceof v?E(t,m.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof R&&S(t,m.typedBuffer,1/256,4,m.typedBufferStride)),c.push([z.COLOR,new _(t,n,4,!0)])}return{geometry:new W(s,c),vertexCount:i}}const ie=s();function ne(e){switch(e){case"BLEND":return G.Blend;case"MASK":return G.Mask;case"OPAQUE":case null:case void 0:return G.Opaque}}function le(e,t){for(let r=0;r<e.model.lods.length;++r){const o=e.model.lods[r];for(const s of o.parts){const o=s.attributes.normal;if(null==o)return;const l=s.attributes.position,g=l.count,x=p(),b=p(),h=p(),y=new Uint8Array(4*g),v=new Float64Array(3*g),R=i(n(),s.transform);let j=0,B=0;for(let i=0;i<g;i++){l.getVec(i,b),o.getVec(i,x),a(b,b,s.transform),u(h,b,t.center),c(h,h,t.radius);const n=h[2],p=m(h),g=Math.min(.45+.55*p*p,1);c(h,h,t.radius),null!==R&&a(h,h,R),f(h,h),r+1!==e.model.lods.length&&e.model.lods.length>1&&d(h,h,x,n>-1?.2:Math.min(-4*n-3.8,1)),v[j]=h[0],v[j+1]=h[1],v[j+2]=h[2],j+=3,y[B]=255*g,y[B+1]=255*g,y[B+2]=255*g,y[B+3]=255,B+=4}s.attributes.normal=new w(v),s.attributes.color=new T(y)}}}export{ee as fetch,re as gltfToEngineResources,te as parseUrl};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import{indexOf as r,PositionHint as i}from"../../../../core/arrayUtils.js";import s from"../../../../core/Logger.js";import{clamp as n}from"../../../../core/mathUtils.js";import{unwrapUpdating as o,updating as a,isUpdating as l}from"../../../../core/maybeUpdating.js";import{whenOnce as c}from"../../../../core/reactiveUtils.js";import{getUnitString as p}from"../../../../core/unitUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import{subclass as g}from"../../../../core/accessorSupport/decorators/subclass.js";import{t as m,g as f,s as d}from"../../../../chunks/vec32.js";import{fromValues as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{WhereClause as h}from"../../../../core/sql/WhereClause.js";import{getReferenceEllipsoid as j}from"../../../../geometry/ellipsoidUtils.js";import{load as S,project as R}from"../../../../geometry/projection.js";import{projectBoundingSphere as E}from"../../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as b}from"../../../../geometry/projection/projectVectorToVector.js";import{create as w}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as v,expandWithNestedArray as F,expand as _}from"../../../../geometry/support/aaBoundingRect.js";import{doubleArrayFrom as I}from"../../../../geometry/support/DoubleArray.js";import{earth as k}from"../../../../geometry/support/Ellipsoid.js";import{isWGS84 as M,isWebMercator as T}from"../../../../geometry/support/spatialReferenceUtils.js";import{f as D}from"../../../../chunks/sphere.js";import{project as G}from"../../../../geometry/support/webMercatorUtils.js";import C from"../../../../layers/support/FeatureFilter.js";import{objectIdFilter as A,filterInPlace as x}from"./I3SUtil.js";import O from"../../../../geometry/SpatialReference.js";const B="esri.views.3d.layers.i3s.I3SMeshViewFilter",L=()=>s.getLogger(B);let P=class extends t{constructor(e){super(e),this._projectionEngineLoaded=!1}initialize(){c((()=>this.viewFilter?.geometry||null!=this.layerFilter)).then((()=>this.loadAsyncModule(import("../../../../geometry/geometryEngine.js").then((e=>{this.destroyed||(this._geometryEngine=e)})))))}get sortedObjectIds(){if(null==this.viewFilter?.objectIds)return null;const e=I(this.viewFilter.objectIds);return e.sort(),e}get parsedWhereClause(){const e=this.viewFilter?.where;if(null==e||!e)return null;try{return h.create(e,this.layerFieldsIndex)}catch(t){L().error(`Failed to parse filter where clause: ${t}`)}return null}addFilters(e,t,r,i){const s=this.sortedObjectIds;null!=s&&e.push((e=>A(s,!0,e))),this.addSqlFilter(e,this.parsedWhereClause),this.addTimeFilter(e,this.viewFilter?.timeExtent);const n=o(this._layerMaskGeometries),a=this._geometryEngine;if(null!=n&&null!=this.layerFilter&&null!=a){const s=this.layerFilter.spatialRelationship;e.push(((e,o)=>N(a,e,o,i,t,r,n,s)))}const l=o(this._viewMaskGeometries);if(null!=l&&null!=this.viewFilter&&null!=a){const s=this.viewFilter.spatialRelationship;e.push(((e,n)=>N(a,e,n,i,t,r,l,s)))}}isMBSGeometryVisible(e,t,r){const i=o(this._layerMaskGeometries),s=this._geometryEngine;if(null!=i&&null!=this.layerFilter&&null!=s){const n=this.layerFilter.spatialRelationship,o=i[0].spatialReference||t;if(!E(e,r,$,o))return L().warnOnce("SceneLayer.mask geometry is using unsupported SpatialReference, skipping geometry filter for MBS"),!0;return q(s,$,i,o,n)}const n=o(this._viewMaskGeometries);if(null!=n&&null!=this.viewFilter&&null!=s){const i=this.viewFilter.spatialRelationship,o=n[0].spatialReference||t;if(!E(e,r,$,o))return L().warnOnce("SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter for MBS"),!0;return q(s,$,n,o,i)}return!0}get parsedGeometry(){const e=o(this._viewMaskGeometries),t=o(this._layerMaskGeometries);return null==e||null==t?e||t:t.concat(e)}get _layerMaskGeometries(){const e=this.layerFilter;return null==e?null:null==this._geometryEngine?a:"disjoint"===e.spatialRelationship?e.geometries.map((e=>({type:"polygon",rings:e.rings,spatialReference:e.spatialReference,cache:{}}))):[e.geometries.reduce(((e,t)=>(e.rings=[...e.rings,...t.rings],e)),{type:"polygon",rings:[],spatialReference:e.geometries[0].spatialReference,cache:{}})]}get _viewMaskGeometries(){if(null==this.viewFilter)return null;const{geometry:e}=this.viewFilter;if(null==e)return null;if(null==this.viewFilter||null==this._geometryEngine)return a;const{distance:t,units:r}=this.viewFilter,i=this.viewFilter.spatialRelationship,s="mesh"===e.type?e.extent:e;if(null==t||0===t)return V(this._geometryEngine,s,i);const n=r||p(s.spatialReference);if(s.spatialReference.isWGS84){const e=this._geometryEngine.geodesicBuffer(s,t,n);return V(this._geometryEngine,e,i)}const o=G(s,O.WGS84);if(null!=o){const e=G(this._geometryEngine.geodesicBuffer(o,t,n),s.spatialReference);return V(this._geometryEngine,e,i)}if(!this._projectionEngineLoaded&&(this.loadAsyncModule(S().then((()=>this._projectionEngineLoaded=!0))),!this._projectionEngineLoaded))return null;let l=null;try{l=R(s,O.WGS84)}catch(c){}if(l)try{l=R(this._geometryEngine.geodesicBuffer(l,t,n),s.spatialReference)}catch(c){l=null}return l||L().error(`Filter by geodesic buffer (distance) unsupported, failed to project input geometry (${s.spatialReference.wkid}) to WGS84.`),V(this._geometryEngine,l,i)}get updating(){return l(this._layerMaskGeometries)||l(this._viewMaskGeometries)}static checkSupport(e){return null!=e&&(!!K(e.spatialRelationship)||(L().warn(`Filters with spatialRelationship other than ${U.join(", ")} are not supported for mesh scene layers`),!1))}};e([u()],P.prototype,"layerFilter",void 0),e([u({type:C})],P.prototype,"viewFilter",void 0),e([u()],P.prototype,"layerFieldsIndex",void 0),e([u()],P.prototype,"loadAsyncModule",void 0),e([u()],P.prototype,"addSqlFilter",void 0),e([u()],P.prototype,"addTimeFilter",void 0),e([u({readOnly:!0})],P.prototype,"sortedObjectIds",null),e([u({readOnly:!0})],P.prototype,"parsedWhereClause",null),e([u({readOnly:!0})],P.prototype,"parsedGeometry",null),e([u({readOnly:!0})],P.prototype,"_layerMaskGeometries",null),e([u({readOnly:!0})],P.prototype,"_viewMaskGeometries",null),e([u()],P.prototype,"updating",null),e([u()],P.prototype,"_projectionEngineLoaded",void 0),e([u()],P.prototype,"_geometryEngine",void 0),P=e([g(B)],P);const U=(e=>e)(["contains","intersects","disjoint"]);function K(e){return null!=e&&U.includes(e)}var W;function V(e,t,s){if(null==t)return null;if("disjoint"===s&&"polygon"===t.type){const s=t.rings.length,n=t.spatialReference,o=new Array(s);for(let e=0;e<s;++e){const r=v(1/0,1/0,-1/0,-1/0);F(r,t.rings[e]),o[e]={type:"polygon",rings:[t.rings[e]],spatialReference:n,cache:{},aabr:r}}o.sort(((e,t)=>e.aabr[0]-t.aabr[0]));const a=new Set,l=new i;for(let t=0;t<o.length;++t){const i=o[t],s=i.aabr[0];a.forEach((t=>{if(s>=t.aabr[2])return void a.delete(t);if(i.aabr[1]>t.aabr[3]||i.aabr[3]<t.aabr[1]||!e.intersects(i,t))return;i.rings=i.rings.concat(t.rings),_(i.aabr,t.aabr,i.aabr),i.cache={},a.delete(t);const n=r(o,t,o.length,l);o.splice(n,1)})),a.add(i)}for(const e of o)e.aabr=void 0;return o}return[t]}function q(e,t,r,i,s){if(t[3]>=.5*(t[2]+j(i).radius))return!0;const n=H(e,t,i);return r.every((t=>Z(e,t,n,s)!==W.DISCARD))}function N(e,t,r,i,s,n,o,a){const l=o[0].spatialReference||s.spatialReference;if(!E(r.node.serviceMbsInIndexSR,n,$,l))return void L().warnOnce("SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter");const c=H(e,$,l),p=z(a,s,l,i,r.objectHandle);for(const u of o){if(0===t.length)return;switch(Z(e,u,c,a)){case W.DISCARD:return void(t.length=0);case W.KEEP:continue}x(t,r.featureIds,(t=>X(e,u,t,p)))}}!function(e){e[e.KEEP=0]="KEEP",e[e.DISCARD=1]="DISCARD",e[e.TEST=2]="TEST"}(W||(W={}));const $=D(0,0,0,0);function z(e,t,r,i,s){const n=t.renderSpatialReference,o=new Map,a={type:"polygon",rings:[[[0,0,0],[0,0,0],[0,0,0],[0,0,0]]],spatialReference:r};a.rings[0][3]=a.rings[0][0];const l={indices:null,data:null,stride:0,startIndex:0,endIndex:0};let c,p;switch(e){case"intersects":c=(e,t,r)=>e.intersects(t,r)?W.KEEP:W.TEST,p=J;break;case"contains":c=(e,t,r)=>e.contains(t,r)?W.TEST:W.DISCARD,p=J;break;default:c=(e,t,r)=>e.disjoint(t,r)?W.TEST:W.DISCARD,p=Q}return{collection:i,object:s,type:e,maskSR:r,renderSR:n,aabbCache:o,triangle:a,positions:l,triangleTest:c,geometryTest:p}}function H(e,t,r){const i={type:"point",x:t[0],y:t[1],hasZ:!1,hasM:!1,spatialReference:r},s=!M(r)&&!T(r),o=Number.isNaN(t[3])?0:n(t[3],0,2*k.radius),a=s?e.buffer(i,o,1):e.geodesicBuffer(i,o,1);return a.type="polygon",a}function Z(e,t,r,i){switch(i){case"intersects":case"contains":return J(e,t,r);case"disjoint":return Q(e,t,r)}}function J(e,t,r){return e.intersects(t,r)?e.contains(t,r)?W.KEEP:W.TEST:W.DISCARD}function Q(e,t,r){return e.intersects(t,r)?e.contains(t,r)?W.DISCARD:W.TEST:W.KEEP}function X(e,t,r,i){const{collection:s,object:n,renderSR:o,maskSR:a,geometryTest:l,aabbCache:c}=i;let p=c.get(r);if(!p){const e=s.getObjectTransform(n);s.getComponentAabb(n,r,Y);const t=[y(Y[0],Y[1],0),y(Y[0],Y[4],0),y(Y[3],Y[4],0),y(Y[3],Y[1],0)];for(let r=0;r<4;++r)m(t[r],t[r],e.rotationScale),f(t[r],t[r],e.position),b(t[r],o,t[r],a);p={type:"polygon",rings:[t],spatialReference:a,cache:{}},p.rings[0][4]=p.rings[0][0],c.set(r,p)}switch(l(e,t,p)){case W.DISCARD:return!1;case W.KEEP:return!0}const{triangle:u,triangleTest:g,positions:h}=i,j=u.rings[0][0],S=u.rings[0][1],R=u.rings[0][2],E=s.getObjectTransform(n);s.getComponentPositions(n,r,h);const{indices:w,data:v,stride:F,startIndex:_,endIndex:I}=h;for(let y=_;y<I;y+=3){const r=F*w[y],i=F*w[y+1],s=F*w[y+2];switch(d(j,v[r],v[r+1],v[r+2]),d(S,v[i],v[i+1],v[i+2]),d(R,v[s],v[s+1],v[s+2]),m(j,j,E.rotationScale),m(S,S,E.rotationScale),m(R,R,E.rotationScale),f(j,j,E.position),f(S,S,E.position),f(R,R,E.position),b(j,o,j,a),b(S,o,S,a),b(R,o,R,a),g(e,t,u)){case W.DISCARD:return!1;case W.KEEP:return!0}}return"intersects"!==i.type}const Y=w();export{P as I3SMeshViewFilter};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import t from"../../../../core/Accessor.js";import{indexOf as r,PositionHint as i}from"../../../../core/arrayUtils.js";import s from"../../../../core/Logger.js";import{clamp as n}from"../../../../core/mathUtils.js";import{unwrapUpdating as o,updating as a,isUpdating as l}from"../../../../core/maybeUpdating.js";import{whenOnce as c}from"../../../../core/reactiveUtils.js";import{getUnitString as p}from"../../../../core/unitUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import{subclass as g}from"../../../../core/accessorSupport/decorators/subclass.js";import{t as m,g as f,a as d}from"../../../../chunks/vec32.js";import{fromValues as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{WhereClause as h}from"../../../../core/sql/WhereClause.js";import{getReferenceEllipsoid as j}from"../../../../geometry/ellipsoidUtils.js";import{load as S,project as R}from"../../../../geometry/projection.js";import{projectBoundingSphere as E}from"../../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as b}from"../../../../geometry/projection/projectVectorToVector.js";import{create as w}from"../../../../geometry/support/aaBoundingBox.js";import{fromValues as v,expandWithNestedArray as F,expand as _}from"../../../../geometry/support/aaBoundingRect.js";import{doubleArrayFrom as I}from"../../../../geometry/support/DoubleArray.js";import{earth as k}from"../../../../geometry/support/Ellipsoid.js";import{isWGS84 as M,isWebMercator as T}from"../../../../geometry/support/spatialReferenceUtils.js";import{f as D}from"../../../../chunks/sphere.js";import{project as G}from"../../../../geometry/support/webMercatorUtils.js";import C from"../../../../layers/support/FeatureFilter.js";import{objectIdFilter as A,filterInPlace as x}from"./I3SUtil.js";import O from"../../../../geometry/SpatialReference.js";const B="esri.views.3d.layers.i3s.I3SMeshViewFilter",L=()=>s.getLogger(B);let P=class extends t{constructor(e){super(e),this._projectionEngineLoaded=!1}initialize(){c((()=>this.viewFilter?.geometry||null!=this.layerFilter)).then((()=>this.loadAsyncModule(import("../../../../geometry/geometryEngine.js").then((e=>{this.destroyed||(this._geometryEngine=e)})))))}get sortedObjectIds(){if(null==this.viewFilter?.objectIds)return null;const e=I(this.viewFilter.objectIds);return e.sort(),e}get parsedWhereClause(){const e=this.viewFilter?.where;if(null==e||!e)return null;try{return h.create(e,this.layerFieldsIndex)}catch(t){L().error(`Failed to parse filter where clause: ${t}`)}return null}addFilters(e,t,r,i){const s=this.sortedObjectIds;null!=s&&e.push((e=>A(s,!0,e))),this.addSqlFilter(e,this.parsedWhereClause),this.addTimeFilter(e,this.viewFilter?.timeExtent);const n=o(this._layerMaskGeometries),a=this._geometryEngine;if(null!=n&&null!=this.layerFilter&&null!=a){const s=this.layerFilter.spatialRelationship;e.push(((e,o)=>N(a,e,o,i,t,r,n,s)))}const l=o(this._viewMaskGeometries);if(null!=l&&null!=this.viewFilter&&null!=a){const s=this.viewFilter.spatialRelationship;e.push(((e,n)=>N(a,e,n,i,t,r,l,s)))}}isMBSGeometryVisible(e,t,r){const i=o(this._layerMaskGeometries),s=this._geometryEngine;if(null!=i&&null!=this.layerFilter&&null!=s){const n=this.layerFilter.spatialRelationship,o=i[0].spatialReference||t;if(!E(e,r,$,o))return L().warnOnce("SceneLayer.mask geometry is using unsupported SpatialReference, skipping geometry filter for MBS"),!0;return q(s,$,i,o,n)}const n=o(this._viewMaskGeometries);if(null!=n&&null!=this.viewFilter&&null!=s){const i=this.viewFilter.spatialRelationship,o=n[0].spatialReference||t;if(!E(e,r,$,o))return L().warnOnce("SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter for MBS"),!0;return q(s,$,n,o,i)}return!0}get parsedGeometry(){const e=o(this._viewMaskGeometries),t=o(this._layerMaskGeometries);return null==e||null==t?e||t:t.concat(e)}get _layerMaskGeometries(){const e=this.layerFilter;return null==e?null:null==this._geometryEngine?a:"disjoint"===e.spatialRelationship?e.geometries.map((e=>({type:"polygon",rings:e.rings,spatialReference:e.spatialReference,cache:{}}))):[e.geometries.reduce(((e,t)=>(e.rings=[...e.rings,...t.rings],e)),{type:"polygon",rings:[],spatialReference:e.geometries[0].spatialReference,cache:{}})]}get _viewMaskGeometries(){if(null==this.viewFilter)return null;const{geometry:e}=this.viewFilter;if(null==e)return null;if(null==this.viewFilter||null==this._geometryEngine)return a;const{distance:t,units:r}=this.viewFilter,i=this.viewFilter.spatialRelationship,s="mesh"===e.type?e.extent:e;if(null==t||0===t)return V(this._geometryEngine,s,i);const n=r||p(s.spatialReference);if(s.spatialReference.isWGS84){const e=this._geometryEngine.geodesicBuffer(s,t,n);return V(this._geometryEngine,e,i)}const o=G(s,O.WGS84);if(null!=o){const e=G(this._geometryEngine.geodesicBuffer(o,t,n),s.spatialReference);return V(this._geometryEngine,e,i)}if(!this._projectionEngineLoaded&&(this.loadAsyncModule(S().then((()=>this._projectionEngineLoaded=!0))),!this._projectionEngineLoaded))return null;let l=null;try{l=R(s,O.WGS84)}catch(c){}if(l)try{l=R(this._geometryEngine.geodesicBuffer(l,t,n),s.spatialReference)}catch(c){l=null}return l||L().error(`Filter by geodesic buffer (distance) unsupported, failed to project input geometry (${s.spatialReference.wkid}) to WGS84.`),V(this._geometryEngine,l,i)}get updating(){return l(this._layerMaskGeometries)||l(this._viewMaskGeometries)}static checkSupport(e){return null!=e&&(!!K(e.spatialRelationship)||(L().warn(`Filters with spatialRelationship other than ${U.join(", ")} are not supported for mesh scene layers`),!1))}};e([u()],P.prototype,"layerFilter",void 0),e([u({type:C})],P.prototype,"viewFilter",void 0),e([u()],P.prototype,"layerFieldsIndex",void 0),e([u()],P.prototype,"loadAsyncModule",void 0),e([u()],P.prototype,"addSqlFilter",void 0),e([u()],P.prototype,"addTimeFilter",void 0),e([u({readOnly:!0})],P.prototype,"sortedObjectIds",null),e([u({readOnly:!0})],P.prototype,"parsedWhereClause",null),e([u({readOnly:!0})],P.prototype,"parsedGeometry",null),e([u({readOnly:!0})],P.prototype,"_layerMaskGeometries",null),e([u({readOnly:!0})],P.prototype,"_viewMaskGeometries",null),e([u()],P.prototype,"updating",null),e([u()],P.prototype,"_projectionEngineLoaded",void 0),e([u()],P.prototype,"_geometryEngine",void 0),P=e([g(B)],P);const U=(e=>e)(["contains","intersects","disjoint"]);function K(e){return null!=e&&U.includes(e)}var W;function V(e,t,s){if(null==t)return null;if("disjoint"===s&&"polygon"===t.type){const s=t.rings.length,n=t.spatialReference,o=new Array(s);for(let e=0;e<s;++e){const r=v(1/0,1/0,-1/0,-1/0);F(r,t.rings[e]),o[e]={type:"polygon",rings:[t.rings[e]],spatialReference:n,cache:{},aabr:r}}o.sort(((e,t)=>e.aabr[0]-t.aabr[0]));const a=new Set,l=new i;for(let t=0;t<o.length;++t){const i=o[t],s=i.aabr[0];a.forEach((t=>{if(s>=t.aabr[2])return void a.delete(t);if(i.aabr[1]>t.aabr[3]||i.aabr[3]<t.aabr[1]||!e.intersects(i,t))return;i.rings=i.rings.concat(t.rings),_(i.aabr,t.aabr,i.aabr),i.cache={},a.delete(t);const n=r(o,t,o.length,l);o.splice(n,1)})),a.add(i)}for(const e of o)e.aabr=void 0;return o}return[t]}function q(e,t,r,i,s){if(t[3]>=.5*(t[2]+j(i).radius))return!0;const n=H(e,t,i);return r.every((t=>Z(e,t,n,s)!==W.DISCARD))}function N(e,t,r,i,s,n,o,a){const l=o[0].spatialReference||s.spatialReference;if(!E(r.node.serviceMbsInIndexSR,n,$,l))return void L().warnOnce("SceneLayerView.filter.geometry is using unsupported SpatialReference, skipping geometry filter");const c=H(e,$,l),p=z(a,s,l,i,r.objectHandle);for(const u of o){if(0===t.length)return;switch(Z(e,u,c,a)){case W.DISCARD:return void(t.length=0);case W.KEEP:continue}x(t,r.featureIds,(t=>X(e,u,t,p)))}}!function(e){e[e.KEEP=0]="KEEP",e[e.DISCARD=1]="DISCARD",e[e.TEST=2]="TEST"}(W||(W={}));const $=D(0,0,0,0);function z(e,t,r,i,s){const n=t.renderSpatialReference,o=new Map,a={type:"polygon",rings:[[[0,0,0],[0,0,0],[0,0,0],[0,0,0]]],spatialReference:r};a.rings[0][3]=a.rings[0][0];const l={indices:null,data:null,stride:0,startIndex:0,endIndex:0};let c,p;switch(e){case"intersects":c=(e,t,r)=>e.intersects(t,r)?W.KEEP:W.TEST,p=J;break;case"contains":c=(e,t,r)=>e.contains(t,r)?W.TEST:W.DISCARD,p=J;break;default:c=(e,t,r)=>e.disjoint(t,r)?W.TEST:W.DISCARD,p=Q}return{collection:i,object:s,type:e,maskSR:r,renderSR:n,aabbCache:o,triangle:a,positions:l,triangleTest:c,geometryTest:p}}function H(e,t,r){const i={type:"point",x:t[0],y:t[1],hasZ:!1,hasM:!1,spatialReference:r},s=!M(r)&&!T(r),o=Number.isNaN(t[3])?0:n(t[3],0,2*k.radius),a=s?e.buffer(i,o,1):e.geodesicBuffer(i,o,1);return a.type="polygon",a}function Z(e,t,r,i){switch(i){case"intersects":case"contains":return J(e,t,r);case"disjoint":return Q(e,t,r)}}function J(e,t,r){return e.intersects(t,r)?e.contains(t,r)?W.KEEP:W.TEST:W.DISCARD}function Q(e,t,r){return e.intersects(t,r)?e.contains(t,r)?W.DISCARD:W.TEST:W.KEEP}function X(e,t,r,i){const{collection:s,object:n,renderSR:o,maskSR:a,geometryTest:l,aabbCache:c}=i;let p=c.get(r);if(!p){const e=s.getObjectTransform(n);s.getComponentAabb(n,r,Y);const t=[y(Y[0],Y[1],0),y(Y[0],Y[4],0),y(Y[3],Y[4],0),y(Y[3],Y[1],0)];for(let r=0;r<4;++r)m(t[r],t[r],e.rotationScale),f(t[r],t[r],e.position),b(t[r],o,t[r],a);p={type:"polygon",rings:[t],spatialReference:a,cache:{}},p.rings[0][4]=p.rings[0][0],c.set(r,p)}switch(l(e,t,p)){case W.DISCARD:return!1;case W.KEEP:return!0}const{triangle:u,triangleTest:g,positions:h}=i,j=u.rings[0][0],S=u.rings[0][1],R=u.rings[0][2],E=s.getObjectTransform(n);s.getComponentPositions(n,r,h);const{indices:w,data:v,stride:F,startIndex:_,endIndex:I}=h;for(let y=_;y<I;y+=3){const r=F*w[y],i=F*w[y+1],s=F*w[y+2];switch(d(j,v[r],v[r+1],v[r+2]),d(S,v[i],v[i+1],v[i+2]),d(R,v[s],v[s+1],v[s+2]),m(j,j,E.rotationScale),m(S,S,E.rotationScale),m(R,R,E.rotationScale),f(j,j,E.position),f(S,S,E.position),f(R,R,E.position),b(j,o,j,a),b(S,o,S,a),b(R,o,R,a),g(e,t,u)){case W.DISCARD:return!1;case W.KEEP:return!0}}return"intersects"!==i.type}const Y=w();export{P as I3SMeshViewFilter};