@arcgis/core 4.33.0-next.20250406 → 4.33.0-next.20250408

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 (251) hide show
  1. package/Color.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{69b5d0ef14fb521b0fd7.js → 04008648c59031bca8ea.js} +1 -1
  4. package/assets/esri/core/workers/chunks/07236fe57d76b1134cd4.js +1 -0
  5. package/assets/esri/core/workers/chunks/{6a8cf1f51cc4adc268d3.js → 0747c9542172241b52ab.js} +1 -1
  6. package/assets/esri/core/workers/chunks/083548c5eea5aca6404c.js +1 -0
  7. package/assets/esri/core/workers/chunks/0d37c6aa261c8d5e5b23.js +1 -0
  8. package/assets/esri/core/workers/chunks/0d7c1de47ae006277b76.js +1 -0
  9. package/assets/esri/core/workers/chunks/{9574896c90b39fa7ecb4.js → 10fd52bc5124fced5bcc.js} +1 -1
  10. package/assets/esri/core/workers/chunks/11b725421a823f6183a2.js +1 -0
  11. package/assets/esri/core/workers/chunks/{d9b2263e0a9f9068ab62.js → 14d1a970e927ebfed9c8.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{0eed612e82a279ac8d1e.js → 1595f3def0ba0c4f0fe7.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{1263391920fbb8926ced.js → 19eb465f91d07862926a.js} +1 -1
  14. package/assets/esri/core/workers/chunks/1c8cdae7736b6c907d95.js +1 -0
  15. package/assets/esri/core/workers/chunks/1cc4fc3353d217632a1b.js +1 -0
  16. package/assets/esri/core/workers/chunks/{91439b59260b0fb04be9.js → 238df0aee97315623638.js} +1 -1
  17. package/assets/esri/core/workers/chunks/{7ea5bbb52e84be9a608e.js → 23cc33576da66b3c4366.js} +1 -1
  18. package/assets/esri/core/workers/chunks/{358a3a9326615d5e6d3b.js → 2679da0c93f05ae956c6.js} +1 -1
  19. package/assets/esri/core/workers/chunks/26e0a0a13060cd3e4291.js +1 -0
  20. package/assets/esri/core/workers/chunks/{c2d0fc13f4b746318a38.js → 290f63304a2a81303c06.js} +1 -1
  21. package/assets/esri/core/workers/chunks/{e6544e966f14fb410157.js → 2d5cb817e6e905103068.js} +1 -1
  22. package/assets/esri/core/workers/chunks/345f428dfcaa594ee617.js +1 -0
  23. package/assets/esri/core/workers/chunks/35dccd3883d2e466c42e.js +1 -0
  24. package/assets/esri/core/workers/chunks/{fc5ca7b08915177c5e33.js → 364860a42edc0c3b8d5b.js} +1 -1
  25. package/assets/esri/core/workers/chunks/393fbd296817e813936c.js +1 -0
  26. package/assets/esri/core/workers/chunks/{82a58a405332d43a328f.js → 39fbac918ebd1b0e3a18.js} +1 -1
  27. package/assets/esri/core/workers/chunks/3a649aa78e25e3c8aa8c.js +1 -0
  28. package/assets/esri/core/workers/chunks/{4cc77769009901a112ec.js → 3b2bda2e8c08f486de27.js} +1 -1
  29. package/assets/esri/core/workers/chunks/3e1bb914aceb3a9af898.js +1 -0
  30. package/assets/esri/core/workers/chunks/3ee77b601fb0f3567e87.js +1 -0
  31. package/assets/esri/core/workers/chunks/40945669f5be487b340c.js +1 -0
  32. package/assets/esri/core/workers/chunks/43a3b1b78d214aadaaad.js +1 -0
  33. package/assets/esri/core/workers/chunks/49d03bdaa9c4476b69d6.js +1 -0
  34. package/assets/esri/core/workers/chunks/{1b87fa15470cce26feea.js → 49d6b56e21b1bc0d1948.js} +1 -1
  35. package/assets/esri/core/workers/chunks/4cbd5303f5a5a5fff391.js +1 -0
  36. package/assets/esri/core/workers/chunks/{40b33c9bd271cddbd837.js → 50ffb2620cdbcfd75723.js} +1 -1
  37. package/assets/esri/core/workers/chunks/544771f64a86b541d5bb.js +1 -0
  38. package/assets/esri/core/workers/chunks/55cc40d1b1853f779d82.js +1 -0
  39. package/assets/esri/core/workers/chunks/56e9dfd62102c32b9770.js +1 -0
  40. package/assets/esri/core/workers/chunks/576bed289aa7be03f319.js +1 -0
  41. package/assets/esri/core/workers/chunks/{b7a1185ac49480fc1410.js → 5c80452df87024fdaa75.js} +1 -1
  42. package/assets/esri/core/workers/chunks/5ef6acd36629eae225da.js +1 -0
  43. package/assets/esri/core/workers/chunks/{e592731ac12b9bc646ff.js → 60d3b329e69f3cddb7f4.js} +1 -1
  44. package/assets/esri/core/workers/chunks/{43b19c58b2d16ae8e7cc.js → 6275114e8ed9dd31465d.js} +1 -1
  45. package/assets/esri/core/workers/chunks/63ce66da1a52d6d07ccb.js +1 -0
  46. package/assets/esri/core/workers/chunks/6447d373a43ef6cd46cd.js +1 -0
  47. package/assets/esri/core/workers/chunks/64824ee75c643cee2aa9.js +1 -0
  48. package/assets/esri/core/workers/chunks/{48fbf887da6d19838bf0.js → 6a067a6ce0968d893142.js} +1 -1
  49. package/assets/esri/core/workers/chunks/6a70b858e24d98845041.js +1 -0
  50. package/assets/esri/core/workers/chunks/{c589d32f8efcca6bf712.js → 6c65b966f4c952508fc1.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{cda6ae4c5cb67e22b454.js → 6d15d953baabccbbee01.js} +1 -1
  52. package/assets/esri/core/workers/chunks/6ecf2924f9f6aac61101.js +1 -0
  53. package/assets/esri/core/workers/chunks/{25a686f00479ac12a1ca.js → 6f9a17f62786af04b74e.js} +1 -1
  54. package/assets/esri/core/workers/chunks/77334c3fed1e3a06d307.js +1 -0
  55. package/assets/esri/core/workers/chunks/{7ef9bcd58af499a14a08.js → 79036c5d7569c4e94abe.js} +1 -1
  56. package/assets/esri/core/workers/chunks/{2ab7d36409e9af3ac3da.js → 7b47b08f4a58898273b9.js} +1 -1
  57. package/assets/esri/core/workers/chunks/{90442f47c9f31f26b453.js → 7f961954e59a232bfa88.js} +1 -1
  58. package/assets/esri/core/workers/chunks/{ccb289911e7445b17763.js → 86b4920f5a99576399fb.js} +2 -2
  59. package/assets/esri/core/workers/chunks/877f665c7edb26c147ea.js +1 -0
  60. package/assets/esri/core/workers/chunks/{8aae03e347ab18ae6ee2.js → 89e7cc489156ff0ebdb6.js} +1 -1
  61. package/assets/esri/core/workers/chunks/8c5619fdf125a459281d.js +1 -0
  62. package/assets/esri/core/workers/chunks/8e64687ee76e70deeb29.js +1 -0
  63. package/assets/esri/core/workers/chunks/{400f95295bbfced31076.js → 8ef755e6a7b2b71f46e6.js} +1 -1
  64. package/assets/esri/core/workers/chunks/8fe36b06a7eceeb874e9.js +1 -0
  65. package/assets/esri/core/workers/chunks/{269531e770376ed9e4fd.js → 90874dfe23035d16660c.js} +1 -1
  66. package/assets/esri/core/workers/chunks/91bb715f5ee87e97f162.js +1 -0
  67. package/assets/esri/core/workers/chunks/{5c757e20c0543e6a49b3.js → 948a3c1419ae323cca10.js} +1 -1
  68. package/assets/esri/core/workers/chunks/{7f31dbe0ca8974a10be8.js → 96cddbbeef61a4f33f29.js} +1 -1
  69. package/assets/esri/core/workers/chunks/{27b7ef3442700f6d6123.js → 9a84ff99756c7247dd39.js} +97 -96
  70. package/assets/esri/core/workers/chunks/9fddd759c308d3d5801a.js +1 -0
  71. package/assets/esri/core/workers/chunks/a29e99328d75b6ceb74d.js +1 -0
  72. package/assets/esri/core/workers/chunks/{af9fda47d02c51a2c7da.js → a32e697547f8ac345dd7.js} +1 -1
  73. package/assets/esri/core/workers/chunks/a426152e7eb550b8f15f.js +1 -0
  74. package/assets/esri/core/workers/chunks/a6de903f22f76d875005.js +1 -0
  75. package/assets/esri/core/workers/chunks/{90c893959145827961ac.js → aaf67ec3d580e1fee6c7.js} +1 -1
  76. package/assets/esri/core/workers/chunks/{d2c7067bb6654c0e2793.js → ac91bd1fee9ddadc270b.js} +1 -1
  77. package/assets/esri/core/workers/chunks/ae7c1e34ed1288773ec2.js +1 -0
  78. package/assets/esri/core/workers/chunks/ae9ebc0c0553e57e85ba.js +1 -0
  79. package/assets/esri/core/workers/chunks/{49ed3ab9bd6d7c52e864.js → af41dcc8006cd0f451c2.js} +1 -1
  80. package/assets/esri/core/workers/chunks/b199508eef1eeee72854.js +1 -0
  81. package/assets/esri/core/workers/chunks/b715fa857391931c04b9.js +1 -0
  82. package/assets/esri/core/workers/chunks/c144e00dfe6d63eaa2b1.js +1 -0
  83. package/assets/esri/core/workers/chunks/c150cd2a82260495e9de.js +1 -0
  84. package/assets/esri/core/workers/chunks/{2cbab0c078d0b844934c.js → c3c70dad8c8a93953237.js} +1 -1
  85. package/assets/esri/core/workers/chunks/c4425d5227f7e2379b0f.js +1 -0
  86. package/assets/esri/core/workers/chunks/c837379b36cf716d6215.js +1 -0
  87. package/assets/esri/core/workers/chunks/c849e3e151d78a061bf0.js +1 -0
  88. package/assets/esri/core/workers/chunks/{d2eb3802fa003c2d497e.js → caa5676636b06d743623.js} +1 -1
  89. package/assets/esri/core/workers/chunks/cb83fcfff8731c88c108.js +1 -0
  90. package/assets/esri/core/workers/chunks/cc366e4df91cf516d1b9.js +1 -0
  91. package/assets/esri/core/workers/chunks/ccd3f9b52006cd7dd11e.js +1 -0
  92. package/assets/esri/core/workers/chunks/d59aeb46bf2fb0931a9b.js +1 -0
  93. package/assets/esri/core/workers/chunks/{4ba34124054752b363c0.js → d65c30cd787b287833fb.js} +1 -1
  94. package/assets/esri/core/workers/chunks/d72d44df7e117e26e717.js +1 -0
  95. package/assets/esri/core/workers/chunks/e22cdfce2a0583f3cc50.js +1 -0
  96. package/assets/esri/core/workers/chunks/ee277dd58aa69281163f.js +1 -0
  97. package/assets/esri/core/workers/chunks/f086993f8744209d761f.js +1 -0
  98. package/assets/esri/core/workers/chunks/{8d49c79e549e90371303.js → fa2d836d4a844b26b84e.js} +1 -1
  99. package/assets/esri/core/workers/chunks/fb5b852d0f72df014377.js +1 -0
  100. package/assets/esri/core/workers/chunks/fb65796296b0422cf266.js +1 -0
  101. package/assets/esri/core/workers/chunks/fde544c090cc04581536.js +1 -0
  102. package/assets/esri/core/workers/chunks/fe2c48de24b25c45b3e7.js +1 -0
  103. package/chunks/CheckerBoard.glsl.js +3 -3
  104. package/chunks/ColorMaterial.glsl.js +3 -3
  105. package/chunks/ComponentShader.glsl.js +2 -2
  106. package/chunks/DefaultMaterial.glsl.js +5 -5
  107. package/chunks/ImageMaterial.glsl.js +1 -1
  108. package/chunks/LineMarker.glsl.js +4 -4
  109. package/chunks/Path.glsl.js +2 -2
  110. package/chunks/Pattern.glsl.js +3 -3
  111. package/chunks/Precipitation.glsl.js +1 -1
  112. package/chunks/RealisticTree.glsl.js +6 -6
  113. package/chunks/RibbonLine.glsl.js +1 -1
  114. package/chunks/ShadedColorMaterial.glsl.js +7 -7
  115. package/chunks/WaterSurface.glsl.js +3 -3
  116. package/chunks/vec32.js +1 -1
  117. package/colorUtils.js +1 -1
  118. package/core/libs/gl-matrix-2/math/quat.js +1 -1
  119. package/core/libs/gl-matrix-2/math/vec3.js +1 -1
  120. package/core/libs/gl-matrix-2/vec3.js +1 -1
  121. package/geometry/support/float16.js +1 -1
  122. package/geometry/support/meshUtils/merge.js +1 -1
  123. package/identity/IdentityManagerBase.js +1 -1
  124. package/interfaces.d.ts +13 -6
  125. package/layers/effects/parser.js +1 -1
  126. package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +1 -1
  127. package/package.json +2 -2
  128. package/support/revision.js +1 -1
  129. package/symbols/support/Symbol3DEmissive.js +5 -0
  130. package/symbols/support/Symbol3DFillMaterial.js +1 -1
  131. package/symbols/support/Symbol3DMaterial.js +1 -1
  132. package/symbols/support/materialUtils.js +1 -1
  133. package/views/2d/engine/vectorTiles/style/StyleProperty.js +1 -1
  134. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityMeshWriter.js +1 -1
  135. package/views/2d/engine/webgl/shaderGraph/techniques/fill/AFillMeshWriter.js +1 -1
  136. package/views/2d/engine/webgl/shaderGraph/techniques/fill/FillMeshWriter.js +1 -1
  137. package/views/2d/engine/webgl/shaderGraph/techniques/fill/GradientFillMeshWriter.js +1 -1
  138. package/views/2d/engine/webgl/shaderGraph/techniques/line/GradientStrokeMeshWriter.js +1 -1
  139. package/views/2d/engine/webgl/shaderGraph/techniques/line/LineMeshWriter.js +1 -1
  140. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/GradientStrokeShader.js +1 -1
  141. package/views/2d/layers/MediaLayerView2D.js +1 -1
  142. package/views/2d/layers/TileLayerView2D.js +1 -1
  143. package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
  144. package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
  145. package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
  146. package/views/3d/analysis/Viewshed/ScaleOrientManipulation.js +1 -1
  147. package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
  148. package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
  149. package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
  150. package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
  151. package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
  152. package/views/3d/layers/I3SMeshView3D.js +1 -1
  153. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  154. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  155. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  156. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  157. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  158. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  159. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  160. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  161. package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
  162. package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
  163. package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
  164. package/views/3d/support/cameraUtils.js +1 -1
  165. package/views/3d/support/pointsOfInterest/Focus.js +1 -1
  166. package/views/3d/terrain/PatchRenderData.js +1 -1
  167. package/views/3d/terrain/SphericalPatch.js +1 -1
  168. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  169. package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +6 -5
  170. package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
  171. package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
  172. package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
  173. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  174. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  175. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  176. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  177. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  178. package/views/3d/webgl-engine/shaders/OutputColorHighlightOID.glsl.js +8 -8
  179. package/views/SceneView.js +1 -1
  180. package/views/VideoView.js +1 -1
  181. package/views/interactive/SegmentLabels.js +1 -1
  182. package/views/interactive/coordinateHelper.js +1 -1
  183. package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
  184. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  185. package/views/interactive/sketch/constraints.js +1 -1
  186. package/views/interactive/snapping/GridSnappingEngine.js +1 -1
  187. package/views/interactive/tooltip/tooltipCommonUtils.js +1 -1
  188. package/views/support/geometry3dUtils.js +1 -1
  189. package/views/webgl/FramebufferObject.js +1 -1
  190. package/views/webgl/RenderbufferDescriptor.js +1 -1
  191. package/views/webgl/RenderingContext.js +1 -1
  192. package/views/webgl/TextureDescriptor.js +1 -1
  193. package/assets/esri/core/workers/chunks/066844a51cd22cbef0e6.js +0 -1
  194. package/assets/esri/core/workers/chunks/067dda58592fbf4fb812.js +0 -1
  195. package/assets/esri/core/workers/chunks/0a0e5d699ddb7052c5c0.js +0 -1
  196. package/assets/esri/core/workers/chunks/1014513c0ec85f9414a4.js +0 -1
  197. package/assets/esri/core/workers/chunks/1072b4f37eacbbfda2c8.js +0 -1
  198. package/assets/esri/core/workers/chunks/114599ed0752d9a70eef.js +0 -1
  199. package/assets/esri/core/workers/chunks/19e83b184d8b4d0b3007.js +0 -1
  200. package/assets/esri/core/workers/chunks/23de8aeed5b82c682cbe.js +0 -1
  201. package/assets/esri/core/workers/chunks/25ef080163f3f795911a.js +0 -1
  202. package/assets/esri/core/workers/chunks/277b61af8982092a4c81.js +0 -1
  203. package/assets/esri/core/workers/chunks/37e4f588a6896f98bce3.js +0 -1
  204. package/assets/esri/core/workers/chunks/3b7284516a0e34a9e85e.js +0 -1
  205. package/assets/esri/core/workers/chunks/3f6dc811b5d515c2725c.js +0 -1
  206. package/assets/esri/core/workers/chunks/4275dcec730a11173661.js +0 -1
  207. package/assets/esri/core/workers/chunks/4403b3f08907e88d0d91.js +0 -1
  208. package/assets/esri/core/workers/chunks/4523ba4a3c8987abca56.js +0 -1
  209. package/assets/esri/core/workers/chunks/47bbfc10c2a3b9e4bdd6.js +0 -1
  210. package/assets/esri/core/workers/chunks/4baef5262ce401bf81bb.js +0 -1
  211. package/assets/esri/core/workers/chunks/4e3b60156bee3b8b3367.js +0 -1
  212. package/assets/esri/core/workers/chunks/519028f42b817d3e9933.js +0 -1
  213. package/assets/esri/core/workers/chunks/61737e442b1f8e86164e.js +0 -1
  214. package/assets/esri/core/workers/chunks/705c1ebb327f680f8519.js +0 -1
  215. package/assets/esri/core/workers/chunks/7099564a8853b81ba181.js +0 -1
  216. package/assets/esri/core/workers/chunks/72d7e45e7eb28f2cc0b0.js +0 -1
  217. package/assets/esri/core/workers/chunks/72f4cea853ce9fcf2cb6.js +0 -1
  218. package/assets/esri/core/workers/chunks/759c12b0715279e3c0f6.js +0 -1
  219. package/assets/esri/core/workers/chunks/7655be1470ce39f0e494.js +0 -1
  220. package/assets/esri/core/workers/chunks/796cf1c2ca9955595836.js +0 -1
  221. package/assets/esri/core/workers/chunks/7ccc02a4ec6d3552ecca.js +0 -1
  222. package/assets/esri/core/workers/chunks/80427cd9f0c2e07f21c3.js +0 -1
  223. package/assets/esri/core/workers/chunks/8221f2e540abe1e0f048.js +0 -1
  224. package/assets/esri/core/workers/chunks/82353e59ac6d909dcf41.js +0 -1
  225. package/assets/esri/core/workers/chunks/86931186095c23e47c0c.js +0 -1
  226. package/assets/esri/core/workers/chunks/8f35416a5036897d6289.js +0 -1
  227. package/assets/esri/core/workers/chunks/8fecd1337d84c26c692b.js +0 -1
  228. package/assets/esri/core/workers/chunks/9050dad7e4f093568026.js +0 -1
  229. package/assets/esri/core/workers/chunks/9643a9516783e8c32180.js +0 -1
  230. package/assets/esri/core/workers/chunks/9e156e135f34f9b06032.js +0 -1
  231. package/assets/esri/core/workers/chunks/a3421383e48379012c9c.js +0 -1
  232. package/assets/esri/core/workers/chunks/a91f2d1deb950f46ad09.js +0 -1
  233. package/assets/esri/core/workers/chunks/b4a1f3f3a036226d6810.js +0 -1
  234. package/assets/esri/core/workers/chunks/bd0dbad694ce5531deab.js +0 -1
  235. package/assets/esri/core/workers/chunks/c6580fdcdc33153008b0.js +0 -1
  236. package/assets/esri/core/workers/chunks/c68c68e918c72932b247.js +0 -1
  237. package/assets/esri/core/workers/chunks/cc307d34a68e44e3cbc5.js +0 -1
  238. package/assets/esri/core/workers/chunks/d3b0117ad9232e36f785.js +0 -1
  239. package/assets/esri/core/workers/chunks/d46c82a55219b27c301b.js +0 -1
  240. package/assets/esri/core/workers/chunks/d89f105b8a0b13dd8e5f.js +0 -1
  241. package/assets/esri/core/workers/chunks/daa54c8a317c27881763.js +0 -1
  242. package/assets/esri/core/workers/chunks/e08bff9f8247909776a4.js +0 -1
  243. package/assets/esri/core/workers/chunks/e15c612caadf7bac4ab9.js +0 -1
  244. package/assets/esri/core/workers/chunks/e5aff9b10877fb04d6de.js +0 -1
  245. package/assets/esri/core/workers/chunks/e792603b7cc3ddd133f3.js +0 -1
  246. package/assets/esri/core/workers/chunks/eaead9e927ebadcf2cc3.js +0 -1
  247. package/assets/esri/core/workers/chunks/ed517687b3728fd2eb64.js +0 -1
  248. package/assets/esri/core/workers/chunks/f41a9ceb8e49baafe9fa.js +0 -1
  249. package/assets/esri/core/workers/chunks/f5fcba6ca6f43bf1d65d.js +0 -1
  250. package/assets/esri/core/workers/chunks/f7d33d18bf1bd4db9df8.js +0 -1
  251. package/assets/esri/core/workers/chunks/f9396af9cbfd165e72e2.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/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{releaseMaybe as r}from"../../../../core/maybe.js";import{isPromiseLike as o}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as n}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as i,multiply as l,invert as c,getTranslation as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m,IDENTITY as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as d,g,h as x,t as _,q as T,n as b,b as y,f as v,d as w,e as M}from"../../../../chunks/vec32.js";import{ZEROS as R,ONES as j,create as A}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as O}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as E}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as N}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as I}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as S,fromBuffer as U,intersectsClippingArea as F}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as B}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as V,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import G from"../../../../geometry/support/MeshComponent.js";import L from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import $ from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as H,isAbsoluteVertexSpace as k}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as z}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as W}from"../../../../chunks/vec3.js";import{transformNormal as Y,transformVectorENUPlateCarree as Z,VectorType as J,transformVectorWMPlateCarree as K,projectNormalToPCPF as Q,transformTangent as X,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{makeDehydratedPoint as re}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as oe}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as ae}from"../../../ViewingMode.js";import{isEncodedMeshTexture as ne}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as se}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ie}from"./ElevationAligners.js";import{needsElevationUpdates3D as le,evaluateElevationInfoAtPoint as ce}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ue}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as me}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{createMaterial as de}from"../support/edgeUtils.js";import{parseColorMixMode as ge,encodeSymbolColor as xe}from"../support/symbolColorUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as Te}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as be,CullFaceOptions as ye}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as ve}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as we}from"../../webgl-engine/lib/Geometry.js";import{Object3D as Me}from"../../webgl-engine/lib/Object3D.js";import{Texture as Re}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as je}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Ae}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Pe,advancedMRRFactors as Oe,schematicMRRFactors as Ee}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ne}from"../../../webgl/enums.js";const Ie=["mesh"];class Se extends fe{constructor(e,t,r,o){super(e,t,r,o,Qe(t)),this._materialInfoCache=new pe,this._fastUpdateProcessor=new he,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){_e.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Ce({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Ce({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Ce({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,Ie,"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._setMaterialTextureAlphaMode(t,e)})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,le)}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 a=e.fastTransformUpdatesEnabled;switch(o){case oe.EnableFastUpdates:if(a)return!0;break;case oe.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!!this.updateTransform(e,t,r,oe.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0)}const n=this._context.renderCoordsHelper.spatialReference,s=st,{origin:i,transform:l}=r;if(!E(t,d(tt,i.x,i.y,i.z??0),s,n))return!1;switch(o){case oe.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case oe.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case oe.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)=>ce(e,u,c,m,t);return e.alignedSampledElevation=ie(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Ze(a),p=Ze(n),h=Je(s),d=Ze(i),g=Je(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof L){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Ze(a),h=Je(n),d=Ze(i),g=Ze(c),x=Je(u),_=Ze(m),T=Je(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=He(s),o.normalTextureTransform=He(l),o.emissiveTextureTransform=He(u),o.occlusionTextureTransform=He(f),o.metallicRoughnessTextureTransform=He(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTexture(e,t=be.Opaque){const a=Ye(e);if(!a)return null;const n=`${e.contentHash}/${t}`;let s=this._textures.get(n);if(s){const e=this._context.stage.renderView.textures;let t=null;const a=e.acquire(s.id);return null==a||o(a)||(s.events.on("unloaded",(()=>t=r(t))),t=a),s}let i=null;const l=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,c={wrap:ke(e.wrap),noUnpackFlip:!0,maxAnisotropy:l,mipmap:l>1};return ne(a)?(i=a.data,c.preMultiplyAlpha=!1,c.encoding=a.encoding):(i=a,c.preMultiplyAlpha=t!==be.Opaque),s=new Re(i,c),this._textures.set(n,s),s.load(this._context.stage.renderView.renderingContext),this._context.stage.add(s),s.events.on("unloaded",(()=>{this._textures.delete(n)})),s}_setInternalMaterialTextureParameters(t,r){if(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._getInternalTexture(t.normalTexture)?.id),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(t.emissiveTexture)?.id),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(t.occlusionTexture)?.id),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(t.metallicRoughnessTexture)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&We(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=se(e.colorTextureTransform),t.normalTextureTransformMatrix=se(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:h;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=se(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=se(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=se(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this.symbolLayer?.material?.color){const o=this._drivenProperties.color;let a=this.symbolLayer.material?.colorMixMode??null;if(o)t.externalColor=C;else{const o=r??null;o?t.externalColor=e.toUnitRGBA(o):(a=null,t.externalColor=C)}a&&(t.colorMixMode=a),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(ze(t)||null!=o&&o.a<1||a?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return this._setInternalMaterialTextureParameters(l,c.material.parameters),c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=Pe({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:R,diffuse:j,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ye.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Ee:[l.metallic,l.roughness,Oe[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?ye.None:ye.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new Ae(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),p}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push((()=>{this._updateMaterialParameters((e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})}))}))}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?be.MaskBlend:be.Opaque}else e.textureAlphaMode="opaque"===t.alphaMode?be.Opaque:"mask"===t.alphaMode?be.Mask:be.Blend}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),i=[],l=[],c=t[0].transformation,u=a(s(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get(je.POSITION);if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)$e(r,o,t,at),Le(r,o,t,tt,rt,ot),g(tt,tt,rt),g(tt,tt,ot),x(tt,tt,1/3),_(tt,tt,c),i.push(...tt),T(at,at,u),b(at,at),y(tt,tt,at,n),i.push(...tt),l.push(l.length),l.push(l.length)}return i.length?new we(this._debugFaceNormalMaterial,[[je.POSITION,new Te(i,l,3,!0)]],null,ve.Line):null}_createPerVertexDebugVectors(e,t,r,o,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=[],p=t[0].transformation,h=a(s(),p);r===je.TANGENT&&n(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get(je.POSITION),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;d(tt,s[e+0],s[e+1],s[e+2]),_(tt,tt,p),m.push(...tt),d(rt,l[r+0],l[r+1],l[r+2]),T(rt,rt,h),b(rt,rt),y(tt,tt,rt,u),m.push(...tt),f.push(f.length),f.push(f.length)}}return m.length?new we(o,[[je.POSITION,new Te(m,f,3,!0)]],null,ve.Line):null}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(a,s,je.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(a,s,je.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(a,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new Me({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=de(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new me(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ue(this,c,s,null,null,ie,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=le(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(a),r.centerPointInElevationSR=this._getCenterPointInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>ce(e,p,r,h,t);return f.alignedSampledElevation=ie(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!H(t))return!1;const{type:o}=t,{view:a}=this._context.graphicsCoreOwner,{viewingMode:n}=a.state,s=a.spatialReference;return n===ae.Global&&"local"===o||n===ae.Local&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=re(0,0,0,this._context.elevationProvider.spatialReference??null);return I([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===ct.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,a=r;if(t.reprojection===ct.NONE)return{position:a,georeferencedPositionBuffer:o};const n=t.reprojection===ct.RENDER?t.transformBeforeProject:null;n&&(a=W(new Float64Array(a.length),a,n));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=a);const l=a===r||a===o?new Float64Array(a.length):a;return N(a,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const a=e.vertexAttributes.normal;if(null==a)return null;let n=a;const s=o.reprojection===ct.RENDER?o.transformBeforeProject:null;s&&(n=Y(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===ct.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.NORMAL,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return Q(n,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const a=e.vertexAttributes.tangent;if(null==a)return null;let n=a;const s=o.reprojection===ct.RENDER?o.transformBeforeProject:null;s&&(n=X(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===ct.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.TANGENT,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return ee(n,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e,this._getFallbackOpacityAndColor()),r=ge(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return xe(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(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(n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=Ke(e),u=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=a,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:s.reprojection===ct.NONE&&s.geometryTransformation?s.geometryTransformation:m()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?ct.NONE:ct.RENDER:ct.NONE;if(k(t))return{reprojection:r};const o=t.origin,a=m(),n=e.transform?.localMatrix??f;if(r===ct.NONE){E(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:p(n)}}const s=i(m(),o);return l(s,s,n),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=e.origin;et[0]=n.x,et[1]=n.y,et[2]=n.z??0;const s=m();E(e.spatialReference,et,s,a),c(nt,s);const{position:i,normal:l,tangent:u}=e.vertexAttributes,f=t===i?new Float64Array(t.length):t;W(f,t,nt);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===u?new Float32Array(o.length):o:null;return r&&p&&Y(r,p,nt),o&&h&&X(o,h,nt),{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=te(e,r??e.spatialReference);return!!o&&(U(o,it),!F(it,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!O(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:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:m,geometryTransformation:f}=o,p=e.components??lt,h=new Array;let d=!1;const g=u(tt,m),x=this._context.localOriginFactory.getOrigin(g);for(const u of p){if(!this._validateFaces(e,u))return null;const t=Fe(e,u);if(0===t.length)continue;const o=Be(a,l,u,t);o.didFlipNormals&&(d=!0);const m=[[je.POSITION,new Te(a,t,3,!0)],[je.NORMAL,new Te(o.normals,o.indices,3,!0)]];s&&m.push([je.COLOR,new Te(s,t,4,!0)]),i&&m.push([je.SYMBOLCOLOR,new Te(i,V(t.length),4,!0)]),n&&m.push([je.UV0,new Te(n,t,2,!0)]),c&&m.push([je.TANGENT,new Te(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,u),_=new we(g,m,null,ve.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation: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!==ae.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}}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??P}}class Ue{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Fe(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Be(e,t,r,o){switch(r.shading||"flat"){default:case"source":return De(e,t,r,o);case"flat":return Ve(e,o);case"smooth":return Ge(e,o)}}function Ve(e,t){const r=B(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=$e(e,t,a,at);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new Ue(r,o,!1)}function De(e,t,r,o){if(null==t)return Ve(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){$e(e,o,n,at);for(let e=0;e<3;e++){const r=3*o[n+e];tt[0]=t[r],tt[1]=t[r+1],tt[2]=t[r+2],v(at,tt)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Ue(t,o,a)}function Ge(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=$e(e,t,n,at);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:A(),count:0},r[a]=s),g(s.normal,s.normal,o),s.count++}}const o=B(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new Ue(o,a,!1)}function Le(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}function $e(e,t,r,o){return Le(e,t,r,tt,rt,ot),w(rt,rt,tt),w(ot,ot,tt),M(tt,rt,ot),b(o,tt),o}function He(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}function ke(e="repeat"){if("string"==typeof e){const t=qe(e);return{s:t,t}}return{s:qe(e.horizontal),t:qe(e.vertical)}}function qe(e){switch(e){case"clamp":return Ne.CLAMP_TO_EDGE;case"mirror":return Ne.MIRRORED_REPEAT;default:return Ne.REPEAT}}function ze(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 We(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function Ye(e){return e.data??e.url}function Ze(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Je(e){const{offset:t,scale:r,rotation:o}=e??Xe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Ke(e){return e.vertexAttributes.color}function Qe(e){return 1===(e.material?.color?.a??1)}const Xe=new $,et=A(),tt=A(),rt=A(),ot=A(),at=A(),nt=m(),st=m(),it=S(),lt=[new G];var ct;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(ct||(ct={}));export{Se as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{isPromiseLike as o}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as n}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as i,multiply as l,invert as c,getTranslation as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m,IDENTITY as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as d,g,h as x,t as _,q as T,n as b,b as y,f as v,d as w,e as M}from"../../../../chunks/vec32.js";import{ZEROS as R,ONES as j,create as A}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as O}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as E}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as N}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as I}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as S,fromBuffer as U,intersectsClippingArea as B}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as F}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as V,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import G from"../../../../geometry/support/MeshComponent.js";import L from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import $ from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as H,isAbsoluteVertexSpace as k}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as z}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as W}from"../../../../chunks/vec3.js";import{transformNormal as Y,transformVectorENUPlateCarree as Z,VectorType as J,transformVectorWMPlateCarree as K,projectNormalToPCPF as Q,transformTangent as X,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{makeDehydratedPoint as re}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as oe}from"../../../../layers/graphics/sources/interfaces.js";import{getEmissiveMode as ae}from"../../../../symbols/support/materialUtils.js";import{ViewingMode as ne}from"../../../ViewingMode.js";import{isEncodedMeshTexture as se}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ie}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as le}from"./ElevationAligners.js";import{needsElevationUpdates3D as ce,evaluateElevationInfoAtPoint as ue}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as me}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as fe}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as pe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as he,MeshFastUpdateProcessor as de}from"./MeshFastUpdateProcessor.js";import{createMaterial as ge}from"../support/edgeUtils.js";import{parseColorMixMode as xe,encodeSymbolColor as _e}from"../support/symbolColorUtils.js";import{debugFlags as Te}from"../../support/debugFlags.js";import{Attribute as be}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ye,CullFaceOptions as ve}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as we}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as Me}from"../../webgl-engine/lib/Geometry.js";import{Object3D as Re}from"../../webgl-engine/lib/Object3D.js";import{Texture as je}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Ae}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Pe}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Oe,advancedMRRFactors as Ee,schematicMRRFactors as Ne}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ie}from"../../../webgl/enums.js";const Se=["mesh"];class Ue extends pe{constructor(e,t,r,o){super(e,t,r,o,Xe(t)),this._materialInfoCache=new he,this._fastUpdateProcessor=new de,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){Te.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Pe({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Pe({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Pe({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,Se,"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._setMaterialTextureAlphaMode(t,e)})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ce)}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 a=e.fastTransformUpdatesEnabled;switch(o){case oe.EnableFastUpdates:if(a)return!0;break;case oe.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!!this.updateTransform(e,t,r,oe.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0)}const n=this._context.renderCoordsHelper.spatialReference,s=it,{origin:i,transform:l}=r;if(!E(t,d(rt,i.x,i.y,i.z??0),s,n))return!1;switch(o){case oe.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case oe.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case oe.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)=>ue(e,u,c,m,t);return e.alignedSampledElevation=le(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Je(a),p=Je(n),h=Ke(s),d=Je(i),g=Ke(l);if(o.color=a,o.colorTexture=n,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof L){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Je(a),h=Ke(n),d=Je(i),g=Je(c),x=Ke(u),_=Je(m),T=Ke(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=ke(s),o.normalTextureTransform=ke(l),o.emissiveTextureTransform=ke(u),o.occlusionTextureTransform=ke(f),o.metallicRoughnessTextureTransform=ke(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTexture(e,t=ye.Opaque){const a=Ze(e);if(!a)return null;const n=`${e.contentHash}/${t}`;let s=this._textures.get(n);if(s){const e=this._context.stage.renderView.textures;let t=null;const a=e.acquire(s.id);return null==a||o(a)||(s.events.on("unloaded",(()=>t=r(t))),t=a),s}let i=null;const l=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,c={wrap:qe(e.wrap),noUnpackFlip:!0,maxAnisotropy:l,mipmap:l>1};return se(a)?(i=a.data,c.preMultiplyAlpha=!1,c.encoding=a.encoding):(i=a,c.preMultiplyAlpha=t!==ye.Opaque),s=new je(i,c),this._textures.set(n,s),s.load(this._context.stage.renderView.renderingContext),this._context.stage.add(s),s.events.on("unloaded",(()=>{this._textures.delete(n)})),s}_setInternalMaterialTextureParameters(t,r){if(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._getInternalTexture(t.normalTexture)?.id),t.emissiveColor&&(r.emissiveBaseColor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(t.emissiveTexture)?.id),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(t.occlusionTexture)?.id),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(t.metallicRoughnessTexture)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ye(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ie(e.colorTextureTransform),t.normalTextureTransformMatrix=ie(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:h;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ie(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ie(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ie(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this.symbolLayer?.material?.color){const o=this._drivenProperties.color;let a=this.symbolLayer.material?.colorMixMode??null;if(o)t.externalColor=C;else{const o=r??null;o?t.externalColor=e.toUnitRGBA(o):(a=null,t.externalColor=C)}a&&(t.colorMixMode=a),t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrength=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=ae(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(We(t)||null!=o&&o.a<1||a?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return this._setInternalMaterialTextureParameters(l,c.material.parameters),c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=Oe({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:R,diffuse:j,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:ve.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Ne:[l.metallic,l.roughness,Ee[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?ve.None:ve.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new Ce(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),p}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push((()=>{this._updateMaterialParameters((e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})}))}))}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?ye.MaskBlend:ye.Opaque}else e.textureAlphaMode="opaque"===t.alphaMode?ye.Opaque:"mask"===t.alphaMode?ye.Mask:ye.Blend}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),i=[],l=[],c=t[0].transformation,u=a(s(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get(Ae.POSITION);if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)He(r,o,t,nt),$e(r,o,t,rt,ot,at),g(rt,rt,ot),g(rt,rt,at),x(rt,rt,1/3),_(rt,rt,c),i.push(...rt),T(nt,nt,u),b(nt,nt),y(rt,rt,nt,n),i.push(...rt),l.push(l.length),l.push(l.length)}return i.length?new Me(this._debugFaceNormalMaterial,[[Ae.POSITION,new be(i,l,3,!0)]],null,we.Line):null}_createPerVertexDebugVectors(e,t,r,o,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=[],p=t[0].transformation,h=a(s(),p);r===Ae.TANGENT&&n(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get(Ae.POSITION),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;d(rt,s[e+0],s[e+1],s[e+2]),_(rt,rt,p),m.push(...rt),d(ot,l[r+0],l[r+1],l[r+2]),T(ot,ot,h),b(ot,ot),y(rt,rt,ot,u),m.push(...rt),f.push(f.length),f.push(f.length)}}return m.length?new Me(o,[[Ae.POSITION,new be(m,f,3,!0)]],null,we.Line):null}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;if(Te.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(a,s,Ae.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(a,s,Ae.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(a,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new Re({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=ge(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new fe(s[0].material,u,this._context.slicePlaneEnabled):null,f=new me(this,c,s,null,null,le,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ce(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(a),r.centerPointInElevationSR=this._getCenterPointInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>ue(e,p,r,h,t);return f.alignedSampledElevation=le(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!H(t))return!1;const{type:o}=t,{view:a}=this._context.graphicsCoreOwner,{viewingMode:n}=a.state,s=a.spatialReference;return n===ne.Global&&"local"===o||n===ne.Local&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=re(0,0,0,this._context.elevationProvider.spatialReference??null);return I([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===ut.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,a=r;if(t.reprojection===ut.NONE)return{position:a,georeferencedPositionBuffer:o};const n=t.reprojection===ut.RENDER?t.transformBeforeProject:null;n&&(a=W(new Float64Array(a.length),a,n));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=a);const l=a===r||a===o?new Float64Array(a.length):a;return N(a,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const a=e.vertexAttributes.normal;if(null==a)return null;let n=a;const s=o.reprojection===ut.RENDER?o.transformBeforeProject:null;s&&(n=Y(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===ut.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.NORMAL,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return Q(n,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const a=e.vertexAttributes.tangent;if(null==a)return null;let n=a;const s=o.reprojection===ut.RENDER?o.transformBeforeProject:null;s&&(n=X(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===ut.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.TANGENT,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return ee(n,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e,this._getFallbackOpacityAndColor()),r=xe(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return _e(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=e.vertexAttributes.tangent;if(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(n&&n.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=Qe(e),u=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=a,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:s.reprojection===ut.NONE&&s.geometryTransformation?s.geometryTransformation:m()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?ut.NONE:ut.RENDER:ut.NONE;if(k(t))return{reprojection:r};const o=t.origin,a=m(),n=e.transform?.localMatrix??f;if(r===ut.NONE){E(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:p(n)}}const s=i(m(),o);return l(s,s,n),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=e.origin;tt[0]=n.x,tt[1]=n.y,tt[2]=n.z??0;const s=m();E(e.spatialReference,tt,s,a),c(st,s);const{position:i,normal:l,tangent:u}=e.vertexAttributes,f=t===i?new Float64Array(t.length):t;W(f,t,st);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===u?new Float32Array(o.length):o:null;return r&&p&&Y(r,p,st),o&&h&&X(o,h,st),{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=te(e,r??e.spatialReference);return!!o&&(U(o,lt),!B(lt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!O(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:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:m,geometryTransformation:f}=o,p=e.components??ct,h=new Array;let d=!1;const g=u(rt,m),x=this._context.localOriginFactory.getOrigin(g);for(const u of p){if(!this._validateFaces(e,u))return null;const t=Fe(e,u);if(0===t.length)continue;const o=Ve(a,l,u,t);o.didFlipNormals&&(d=!0);const m=[[Ae.POSITION,new be(a,t,3,!0)],[Ae.NORMAL,new be(o.normals,o.indices,3,!0)]];s&&m.push([Ae.COLOR,new be(s,t,4,!0)]),i&&m.push([Ae.SYMBOLCOLOR,new be(i,V(t.length),4,!0)]),n&&m.push([Ae.UV0,new be(n,t,2,!0)]),c&&m.push([Ae.TANGENT,new be(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,u),_=new Me(g,m,null,we.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation: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!==ne.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}}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??P}}class Be{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Fe(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Ve(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Ge(e,t,r,o);case"flat":return De(e,o);case"smooth":return Le(e,o)}}function De(e,t){const r=F(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=He(e,t,a,nt);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new Be(r,o,!1)}function Ge(e,t,r,o){if(null==t)return De(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){He(e,o,n,nt);for(let e=0;e<3;e++){const r=3*o[n+e];rt[0]=t[r],rt[1]=t[r+1],rt[2]=t[r+2],v(nt,rt)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Be(t,o,a)}function Le(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=He(e,t,n,nt);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:A(),count:0},r[a]=s),g(s.normal,s.normal,o),s.count++}}const o=F(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new Be(o,a,!1)}function $e(e,t,r,o,a,n){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}function He(e,t,r,o){return $e(e,t,r,rt,ot,at),w(ot,ot,rt),w(at,at,rt),M(rt,ot,at),b(o,rt),o}function ke(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}function qe(e="repeat"){if("string"==typeof e){const t=ze(e);return{s:t,t}}return{s:ze(e.horizontal),t:ze(e.vertical)}}function ze(e){switch(e){case"clamp":return Ie.CLAMP_TO_EDGE;case"mirror":return Ie.MIRRORED_REPEAT;default:return Ie.REPEAT}}function We(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 Ye(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function Ze(e){return e.data??e.url}function Je(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Ke(e){const{offset:t,scale:r,rotation:o}=e??et;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Qe(e){return e.vertexAttributes.color}function Xe(e){return 1===(e.material?.color?.a??1)}const et=new $,tt=A(),rt=A(),ot=A(),at=A(),nt=A(),st=m(),it=m(),lt=S(),ct=[new G];var ut;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(ut||(ut={}));export{Ue 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.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{identity as r,scale as i,translate as o,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l,F as c,v as h,c as d,C as m,g as p,i as u}from"../../../../chunks/vec32.js";import{fromArray as f,clone as y,ZEROS as _,ONES as g,fromValues as b,create as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as R,ZEROS 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 w,containsPoint as U,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as O}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as E,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as B,defaultSymbolLayerMemoryComplexity as G}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as I}from"./ElevationAligners.js";import{needsElevationUpdates3D as F,evaluateElevationInfoAtPoint as D,SampleElevationInfo as A}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as z}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as M,computeObjectScale as k,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as W}from"./interfaces.js";import{LoadStatus as q}from"./Loadable.js";import{makeLodResources as N}from"./lodResourceUtils.js";import{fetch as $}from"./objectResourceUtils.js";import{placePointOnGeometry as Z,extendPointGraphicElevationContext as J}from"./pointUtils.js";import{isValidPrimitive as K,primitiveLodResources as Q}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as X}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Y}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as ee,updateFastSymbolUpdatesState as te,ConvertOptions as se,evaluateModelTransform as re,evaluateModelTransformScale as ie}from"../support/FastSymbolUpdates.js";import{olidEnabled as oe}from"../../webgl-engine/effects/geometry/olidUtils.js";import{CullFaceOptions as ae}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{DefaultMaterial as ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as he}from"../../webgl-engine/materials/pbrUtils.js";class de{constructor(e,t,s,r,i,o,a,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=o,this.resourceBoundingBox=a,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class me 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,fe(t)),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&&K(t?.primitive)?t.primitive:O;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Y(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 null!=this._primitive}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,o=S(E(t)),a=f(w(o)),n=f(T(a,i)),h=l(n),d=!1,m=!1,p=i?.material,u=p?.emissiveFactor,b=u?c(y(u)):_,P={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:he,ambient:g,diffuse:g,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:i.castShadows,emissiveFactor:b,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},v=!!P.usePBR,L=p?.color,C=this.symbol;if("point-3d"===C.type&&C.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=C.verticalOffset;P.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},P.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(P.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)P.externalColor=R;else{const t=null!=L?e.toUnitRGBA(L):this._drivenProperties.opacity?R:x;P.externalColor=t}this._fastUpdates=ee(this._context.renderer,this._fastVisualVariableConvertOptions(o,n,a,null)),P.isInstanced=!0,this._fastUpdates?(Object.assign(P,this._fastUpdates.materialParameters),this._optionalFields.push(ne.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(P.hasInstancedColor=!0,this._optionalFields.push(ne.COLOR)),oe()&&this._optionalFields.push(ne.OLIDCOLOR);const U=new ce(P,this._context);U.setParameters({cullFace:ye(U.transparent)});const j=Q(t,U);if(!j)throw new Error(`Unknown object symbol primitive: ${t}`);const O=await this._createStageResources(j,v,r),B=await this._createLodRenderer(j,r);return new de(j,B,O,a,d,m,o,n,h,v)}async _createResourcesForUrl(e,t){const r={isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=ee(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ne.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(i.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ne.COLOR)),oe()&&this._optionalFields.push(ne.OLIDCOLOR);const o=this.symbol;if("point-3d"===o.type&&o.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=o.verticalOffset;i.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},i.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;i.signal=t,i.usePBR=a,i.skipHighLods=this._context.skipHighSymbolLods;const n=await $(e,i),c=n.isEsriSymbolResource,h=n.isWosr,d=N(n.lods),m=this._context,p=this.symbolLayer.material,u=this._getExternalColorParameters(p),y=this.needsDrivenTransparentPass,_=d.getMaterials();_.forEach((e=>{e.setParameters({...u,drivenOpacity:y}),m.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:m.sharedResources.screenSizePerspectiveSettings})}));const g=n.referenceBoundingBox,b=f(w(g)),P=f(d.levels[0].pivotOffset),R=f(T(b,this.symbolLayer)),x=l(R),v=this._fastUpdates;te(v,this._context.renderer,this._fastVisualVariableConvertOptions(g,R,b,P))&&_.forEach((e=>e.setParameters(v.materialParameters)));const L=await this._createStageResources(d,a,t),C=await this._createLodRenderer(d,t);return new de(d,C,L,b,c,h,g,R,x,a,P)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,o=e.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(o),this._addDisposeResource((()=>i.removeMany(o)));const a=e.getTextures();i.addMany(a),this._addDisposeResource((()=>{a.forEach((e=>e.unload())),i.removeMany(a)})),await Promise.all(a.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=e.getEngineGeometries();return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:o,textures:a,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerViewUid:this._context.layerViewUid,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,o=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,Pe),a(s,re(i.materialParameters,Pe,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,Pe),ie(e,i.materialParameters,Pe)}}:null,n=new le({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:o},this._context.scheduler);return n.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(n),n.destroy()})),await s.addRenderPlugin(n,t),n}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=R:null!=t?.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=R,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=Z(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)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let s=0;s<t.length;s++){const r=t[s];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:ye(r.transparent)})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,F)}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 W.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:o,resourceSize:a,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return W.RecreateSymbol;if(!te(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,o,a,n)))return W.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return W.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=B(e.levels),s=e.computeUsedMemory(),r={...G(this.symbol,this.symbolLayer),resourceBytes:s};return new X({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),a=this._context.clippingExtent;if(C(t,_e,this._context.elevationProvider.spatialReference),null!=a&&!U(a,_e))return null;const n=ue(r),l=this._computeGlobalTransform(t,r,be,Re),c=this._computeLocalTransform(this._resources,this.symbolLayer,s,ge),h=this._resources.lodRenderer.instanceData,d=h.addInstance();if(this._instanceIndexToGraphicUid.set(d,i),h.setLocalTransform(d,c,!1),h.setGlobalTransform(d,l),o&&h.setFeatureAttribute(d,o),null==this._fastUpdates&&this._hasPerInstanceColor()){const e=this._getVertexOpacityAndColor(s,this._getFallbackOpacityAndColor(),255);h.setColor(d,e)}const m=this._context.stage.renderView.olidRenderHelper;if(m){const e=m.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:this._context.layerViewUid});h.setObjectAndLayerIdColor(d,e)}const p=new z(this,d,I,r,this._context.stage.view.state.highlightOrderMap);return n&&(p.alignedSampledElevation=Re.sampledElevation),p.needsElevationUpdates=F(r.mode),J(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return D(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),_e[0]=e.x,_e[1]=e.y,_e[2]=r.z,L(e.spatialReference,_e,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,i){return r(i),this._applyObjectRotation(s,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,s,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,o=k(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===o[0]&&1===o[1]&&1===o[2]||i(s,s,o)}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&&Z(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,be,Re),ue(e.elevationContext)&&(e.alignedSampledElevation=Re.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,be,!0),J(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),o=s(t.roll,this.symbolLayer.roll,0),a=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:o,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===q.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=f(T(m.resourceSize,{width:a,height:n,depth:l,isPrimitive:this._isPrimitive}))})),e.graphics3DGraphicPatches.push((({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,ge);m.lodRenderer.instanceData.setLocalTransform(e,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,o=null!=i?e.toUnitRGBA(i):R;delete r.color;const a=this._resources;if(null==a)return;const n=this._isPrimitive;t.graphics3DGraphicPatches.push((({instanceIndex:e})=>{if(this._hasPerInstanceColor())a.lodRenderer.instanceData.setColor(e,o);else{const e={externalColor:o};for(const t of a.stageResources.materials)t.setParameters(e),n&&t.setParameters({cullFace:ye(t.transparent)})}}))}_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=pe(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(w(e)):g,o=null!=e?pe(e,r,this.symbolLayer):_,a=this._context.renderCoordsHelper.unitInMeters,n=k(null!=t?t:void 0,t,s,a),l=b(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new se({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??g,unitInMeters:a,anchor:o,scale:n,rotation:l,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:n})}get _primitive(){const{resource:e}=this.symbolLayer;return null!=e?.href?null:e?.primitive??O}_getFallbackOpacityAndColor(){const t=this.symbolLayer.material?.color;if(null==t){return null==this._primitive?R:x}return e.toUnitRGBA(t)}}function pe(e,t,s){const r=P();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=w(e),o=s.anchorPosition,a=o?b(o.x,o.y,o.z):_;m(r,i,a),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}function ue(e){return"absolute-height"!==e.mode}function fe(e){return 1===(e.material?.color?.a??1)&&null==e.resource?.href}function ye(e){return e?ae.None:ae.Back}const _e=P(),ge=n(),be=n(),Pe=v(),Re=new A;export{me as Graphics3DObjectSymbolLayer};
5
+ import e from"../../../../Color.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{identity as r,scale as i,translate as o,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l,v as c,c as h,C as d,g as m,i as p}from"../../../../chunks/vec32.js";import{fromArray as u,ONES as f,ZEROS as y,fromValues as _,create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as b,ZEROS as P,create as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as v}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as x}from"../../../../geometry/projection/projectPointToVector.js";import{create as L,size as S,containsPoint as C,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{EmissiveSourceMode as U,getEmissiveMode as j}from"../../../../symbols/support/materialUtils.js";import{defaultPrimitive as O}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as E,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as B,defaultSymbolLayerMemoryComplexity as G}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as I}from"./ElevationAligners.js";import{needsElevationUpdates3D as D,evaluateElevationInfoAtPoint as F,SampleElevationInfo as A}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as z}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as V}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as M,computeObjectScale as k,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as W}from"./interfaces.js";import{LoadStatus as q}from"./Loadable.js";import{makeLodResources as N}from"./lodResourceUtils.js";import{fetch as $}from"./objectResourceUtils.js";import{placePointOnGeometry as Z,extendPointGraphicElevationContext as J}from"./pointUtils.js";import{isValidPrimitive as K,primitiveLodResources as Q}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as X}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Y}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as ee,updateFastSymbolUpdatesState as te,ConvertOptions as se,evaluateModelTransform as re,evaluateModelTransformScale as ie}from"../support/FastSymbolUpdates.js";import{olidEnabled as oe}from"../../webgl-engine/effects/geometry/olidUtils.js";import{CullFaceOptions as ae}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{DefaultMaterial as ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as he}from"../../webgl-engine/materials/pbrUtils.js";class de{constructor(e,t,s,r,i,o,a,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=o,this.resourceBoundingBox=a,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class me 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,fe(t)),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&&K(t?.primitive)?t.primitive:O;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Y(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 null!=this._primitive}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,o=L(E(t)),a=u(S(o)),n=u(T(a,i)),c=l(n),h=!1,d=!1,m=i?.material,p={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:he,ambient:f,diffuse:f,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:i.castShadows,emissiveStrength:m?.emissive?.strength??0,emissiveSource:U.Color,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},y=!!p.usePBR,_=m?.color,g=this.symbol;if("point-3d"===g.type&&g.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=g.verticalOffset;p.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},p.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(p.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)p.externalColor=b;else{const t=null!=_?e.toUnitRGBA(_):this._drivenProperties.opacity?b:P;p.externalColor=t}this._fastUpdates=ee(this._context.renderer,this._fastVisualVariableConvertOptions(o,n,a,null)),p.isInstanced=!0,this._fastUpdates?(Object.assign(p,this._fastUpdates.materialParameters),this._optionalFields.push(ne.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(p.hasInstancedColor=!0,this._optionalFields.push(ne.COLOR)),oe()&&this._optionalFields.push(ne.OLIDCOLOR);const R=new ce(p,this._context);R.setParameters({cullFace:ye(R.transparent)});const v=Q(t,R);if(!v)throw new Error(`Unknown object symbol primitive: ${t}`);const x=await this._createStageResources(v,y,r),C=await this._createLodRenderer(v,r);return new de(v,C,x,a,h,d,o,n,c,y)}async _createResourcesForUrl(e,t){const r={isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=ee(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ne.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(i.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ne.COLOR)),oe()&&this._optionalFields.push(ne.OLIDCOLOR);const o=this.symbol;if("point-3d"===o.type&&o.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=o.verticalOffset;i.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},i.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;i.signal=t,i.usePBR=a,i.skipHighLods=this._context.skipHighSymbolLods;const n=await $(e,i),c=n.isEsriSymbolResource,h=n.isWosr,d=N(n.lods),m=this._context,p=this.symbolLayer.material,f=this._getExternalColorParameters(p),y=this.needsDrivenTransparentPass,_=d.getMaterials();_.forEach((e=>{e.setParameters({...f,drivenOpacity:y}),m.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:m.sharedResources.screenSizePerspectiveSettings})}));const g=n.referenceBoundingBox,b=u(S(g)),P=u(d.levels[0].pivotOffset),R=u(T(b,this.symbolLayer)),v=l(R),x=this._fastUpdates;te(x,this._context.renderer,this._fastVisualVariableConvertOptions(g,R,b,P))&&_.forEach((e=>e.setParameters(x.materialParameters)));const L=await this._createStageResources(d,a,t),C=await this._createLodRenderer(d,t);return new de(d,C,L,b,c,h,g,R,v,a,P)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,o=e.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(o),this._addDisposeResource((()=>i.removeMany(o)));const a=e.getTextures();i.addMany(a),this._addDisposeResource((()=>{a.forEach((e=>e.unload())),i.removeMany(a)})),await Promise.all(a.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=e.getEngineGeometries();return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:o,textures:a,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerViewUid:this._context.layerViewUid,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,o=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,Pe),a(s,re(i.materialParameters,Pe,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,Pe),ie(e,i.materialParameters,Pe)}}:null,n=new le({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:o},this._context.scheduler);return n.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(n),n.destroy()})),await s.addRenderPlugin(n,t),n}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=b:null!=t?.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=b,s.colorMixMode="ignore"),s.emissiveStrength=t?.emissive?.strength??1,s.emissiveSource=j(t?.emissive?.source??"emissive"),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=Z(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)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let s=0;s<t.length;s++){const r=t[s];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:ye(r.transparent)})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,D)}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 W.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:o,resourceSize:a,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return W.RecreateSymbol;if(!te(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,o,a,n)))return W.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return W.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=B(e.levels),s=e.computeUsedMemory(),r={...G(this.symbol,this.symbolLayer),resourceBytes:s};return new X({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),a=this._context.clippingExtent;if(x(t,_e,this._context.elevationProvider.spatialReference),null!=a&&!C(a,_e))return null;const n=ue(r),l=this._computeGlobalTransform(t,r,be,Re),c=this._computeLocalTransform(this._resources,this.symbolLayer,s,ge),h=this._resources.lodRenderer.instanceData,d=h.addInstance();if(this._instanceIndexToGraphicUid.set(d,i),h.setLocalTransform(d,c,!1),h.setGlobalTransform(d,l),o&&h.setFeatureAttribute(d,o),null==this._fastUpdates&&this._hasPerInstanceColor()){const e=this._getVertexOpacityAndColor(s,this._getFallbackOpacityAndColor(),255);h.setColor(d,e)}const m=this._context.stage.renderView.olidRenderHelper;if(m){const e=m.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:this._context.layerViewUid});h.setObjectAndLayerIdColor(d,e)}const p=new z(this,d,I,r,this._context.stage.view.state.highlightOrderMap);return n&&(p.alignedSampledElevation=Re.sampledElevation),p.needsElevationUpdates=D(r.mode),J(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return F(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),_e[0]=e.x,_e[1]=e.y,_e[2]=r.z,v(e.spatialReference,_e,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,i){return r(i),this._applyObjectRotation(s,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,s,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,o=k(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===o[0]&&1===o[1]&&1===o[2]||i(s,s,o)}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&&Z(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,be,Re),ue(e.elevationContext)&&(e.alignedSampledElevation=Re.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,be,!0),J(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),o=s(t.roll,this.symbolLayer.roll,0),a=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:o,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===q.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=u(T(m.resourceSize,{width:a,height:n,depth:l,isPrimitive:this._isPrimitive}))})),e.graphics3DGraphicPatches.push((({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,ge);m.lodRenderer.instanceData.setLocalTransform(e,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,o=null!=i?e.toUnitRGBA(i):b;delete r.color;const a=this._resources;if(null==a)return;const n=this._isPrimitive;t.graphics3DGraphicPatches.push((({instanceIndex:e})=>{if(this._hasPerInstanceColor())a.lodRenderer.instanceData.setColor(e,o);else{const e={externalColor:o};for(const t of a.stageResources.materials)t.setParameters(e),n&&t.setParameters({cullFace:ye(t.transparent)})}}))}_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=pe(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?u(S(e)):f,o=null!=e?pe(e,r,this.symbolLayer):y,a=this._context.renderCoordsHelper.unitInMeters,n=k(null!=t?t:void 0,t,s,a),l=_(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new se({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??f,unitInMeters:a,anchor:o,scale:n,rotation:l,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:n})}get _primitive(){const{resource:e}=this.symbolLayer;return null!=e?.href?null:e?.primitive??O}_getFallbackOpacityAndColor(){const t=this.symbolLayer.material?.color;if(null==t){return null==this._primitive?b:P}return e.toUnitRGBA(t)}}function pe(e,t,s){const r=g();switch(s.anchor){case"center":h(r,w(e)),c(r,r);break;case"top":{const t=w(e);p(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);p(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),i=S(e),o=s.anchorPosition,a=o?_(o.x,o.y,o.z):y;d(r,i,a),m(r,r,t),c(r,r);break}default:null!=t?c(r,t):h(r,y)}return r}function ue(e){return"absolute-height"!==e.mode}function fe(e){return 1===(e.material?.color?.a??1)&&null==e.resource?.href}function ye(e){return e?ae.None:ae.Back}const _e=g(),ge=n(),be=n(),Pe=R(),Re=new A;export{me as Graphics3DObjectSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Error.js";import{translate as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as r,create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as a,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as n,fromArray as l,clone as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{F as h,i as m}from"../../../../chunks/vec32.js";import{clone as p,ZEROS as f,fromArray as d,create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as b}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as y}from"../../../../geometry/projection/projectBuffer.js";import{create as g,fromSubBuffer as _,intersectsClippingArea as v}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as w,doubleArrayFrom as x}from"../../../../geometry/support/DoubleArray.js";import{needsElevationUpdates3D as P,evaluateElevationAlignmentAtPoint as j,SampleElevationInfo as S}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as C}from"./Graphics3DObject3DGraphicLayer.js";import{pathNumRoundJoinSubdivisions as D,pathNumRoundCapExtrusionSubdivisions as V}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as L}from"./Graphics3DSymbolLayer.js";import{isValidSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as U}from"./interfaces.js";import{ConvertOptions as R,initFastSymbolUpdatesState as k,updateFastSymbolUpdatesState as E,getAttributeValue as z}from"../support/FastSymbolUpdates.js";import{SamplePosition as O}from"../../support/ElevationProvider.js";import{NormalType as I}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as B}from"../../webgl-engine/lib/Object3D.js";import{Path as F}from"../../webgl-engine/lib/Path.js";import{PathBuilder as M}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as q,TriangulationCapBuilder as H,NoCapBuilder as N}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as W,MiterExtruder as T}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as Z,PathGeometry as J,isPathGeometry as K}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as Q,StaticPathGeometry as X}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as Y}from"../../webgl-engine/lib/pathGeometryUtils.js";import{quadProfiles as $,circleProfiles as ee}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as te}from"../../webgl-engine/lib/PathVertex.js";import{VertexAttribute as ie}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as re}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as se}from"../../webgl-engine/materials/PathMaterial.js";const ae=["polyline"];class oe extends L{constructor(e,t,i,r){super(e,t,i,r,me(t)),this._intrinsicSize=n(1,1),this._upVectorAlignment=Z.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const e=null!=this.symbolLayer.width?this.symbolLayer.width:this.symbolLayer.height,i=null!=this.symbolLayer.height?this.symbolLayer.height:e;this._vvConvertOptions=new R({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[e,1,i],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:[e,1,i]});const r=this._context.renderer?.visualVariables;this._fastUpdates=r?.length?k(this._context.renderer,this._vvConvertOptions):null;const s=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?Z.World:Z.Path;const n=this.symbolLayer.profile||"circle";switch(n){default:case"circle":this._profile=ee[s];break;case"quad":this._profile=$[s]}switch(this.symbolLayer.join){case"round":this._extruder=new T(0,D);break;case"bevel":this._extruder=new T(0,1);break;case"miter":this._extruder=new T(.8*Math.PI,1);break;default:this._extruder=new W}const c=this.symbolLayer.cap||"butt";switch(c){case"none":this._startCap=new N,this._endCap=new N;break;case"butt":default:this._startCap=new H(this._profile,0),this._endCap=new H(this._profile,0,!0);break;case"square":this._startCap=new H(this._profile,-.5),this._endCap=new H(this._profile,.5,!0);break;case"round":{const e="quad"===n;this._startCap=new q({profile:this._profile,flip:!1,breakNormals:e,subdivisions:V}),this._endCap=new q({profile:this._profile,flip:!0,breakNormals:e,subdivisions:V});break}}const m=this.symbolLayer?.material?.emissiveFactor,u=m?h(p(m)):f,b=this.symbolLayer?.material?.color,y=this._getCombinedOpacityAndColor(b),g=d(y),_={diffuse:g,ambient:g,emissiveFactor:u,opacity:y[3],drivenOpacity:this.needsDrivenTransparentPass,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(a(this._intrinsicSize,e,i),!A(this._intrinsicSize[0])||!A(this._intrinsicSize[1])))throw new t("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");let v;this._fastUpdates?.visualVariables.size||o(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates?v=new se({..._,...this._fastUpdates.materialParameters,size:l(this._intrinsicSize)},this._context):(_.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,_.normalType=I.Compressed,v=new re(_,this._context)),v.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,cullFace:v.transparent||"none"===c?G.None:G.Back}),this._materials[0]=v,this._context.stage.add(v)}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,ae,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t);return this._createAs3DShape(e,i)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e);this._materials[0]?.setParameters({opacity:t})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,P)}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 U.RecreateSymbol;if(!E(this._fastUpdates,t,this._vvConvertOptions))return U.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return U.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 h of i)t+=h.length;const n=w(3*t);let l,c=0;for(const h of i){r.push({offset:c,numVertices:h.length});for(const t of h)n[c++]=t[0],n[c++]=t[1],n[c++]=e.hasZ?t[2]:0}return null==a||s.equals(a)||y(n,s,0,n,a,0,t)?(null==a||a.equals(o)?l=x(n):(l=w(3*t),y(n,a,0,l,o,0,t)),{pathVertexDataInfos:r,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,t){const{graphic:a,renderingInfo:o}=e,n=a.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 h=new Array,p=n.spatialReference,f=g(),d=this._context.renderCoordsHelper,u=new O(l.vertexDataES),b=a.uid;let y=0;for(const g of l.pathVertexDataInfos){const e=g.numVertices;if(e<2)continue;const n=g.offset;if(null!=this._context.clippingExtent&&(_(l.vertexDataES,n,e,f),!v(f,this._context.clippingExtent)))continue;const w=new Array,x=n+3*e;for(let i=n;i<x;i+=3){u.offset=i;const e=j(u,this._context.elevationProvider,t,d);m(pe,l.vertexDataRS[i],l.vertexDataRS[i+1],l.vertexDataRS[i+2]),d.setAltitude(pe,e),l.vertexDataRS[i]=pe[0],l.vertexDataRS[i+1]=pe[1],l.vertexDataRS[i+2]=pe[2],w.push(te(this._upVectorAlignment))}const P=new F(w,l.vertexDataES,l.vertexDataRS,n);ne(P,this._upVectorAlignment,this._context.renderCoordsHelper);const S=new M(P,this._profile,this._extruder,this._startCap,this._endCap);let C=null;if(this._fastUpdates){const e=this._fastUpdates.visualVariables,t=z(e.size?.field,a)??0,i=z(e.color?.field,a)??0,r=z(e.opacity?.field,a)??0;C=new Q(S,t,i,r)}else{const e=c(this._intrinsicSize);if(this._drivenProperties.size){const t=o.size??["symbol-value","symbol-value","symbol-value"];e[0]*=le(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=le(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}let t;if(this._drivenProperties.color&&(t=o.color??this._getFallbackOpacityAndColor()),this._drivenProperties.opacity){const e=o.opacity??this._getFallbackOpacityAndColor()[3];t=t?[t[0],t[1],t[2],e]:[1,1,1,e]}const i=new X(S);i.bake(e),t&&i.bakeVertexColors(t),C=i}const D=C.createGeometryData(),V=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:b,layerViewUid:this._context.layerViewUid}),L=new J(this._materials[0],D,C,p,this._stencilWidth,V);L.transformation=i(s(),r,S.path.origin),h.push(L),y+=S.usedMemory}if(0===h.length)return null;const w=new B({geometries:h,layerViewUid:this._context.layerViewUid,graphicUid:b}),x=new C(this,w,h,null,null,((e,t,i,r,s)=>he(e,t,r,s,this._upVectorAlignment)),t,null,y);return x.alignedSampledElevation=0,x.needsElevationUpdates=P(t.mode),x}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??b}}function ne(e,t,i){const{origin:r,positions:s}=e;let a=e.offset;switch(t){default:case Z.World:for(const t of e.vertices)pe[0]=s[a++]+r[0],pe[1]=s[a++]+r[1],pe[2]=s[a++]+r[2],i.worldUpAtPosition(pe,pe),t.setFrameFromUpVector(pe);break;case Z.Path:pe[0]=s[a]+r[0],pe[1]=s[a+1]+r[1],pe[2]=s[a+2]+r[2],i.worldUpAtPosition(pe,pe),Y(e,pe)}}function le(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function ce(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 h=e.offset;h<c;h+=3)m(pe,l[h],l[h+1],l[h+2]),i(pe,fe),s+=fe.sampledElevation,pe[0]=n[h]+a[0],pe[1]=n[h+1]+a[1],pe[2]=n[h+2]+a[2],r.setAltitude(pe,fe.z),n[h]=pe[0]-a[0],n[h+1]=pe[1]-a[1],n[h+2]=pe[2]-a[2];return e.updatePathVertexInformation(),s/o.length}function he(e,t,i,r,s){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!K(l))continue;const e=l.path,o=e.builder.path;n+=ce(o,t,i,r),s!==Z.World&&ne(o,s,r),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(l,ie.POSITION)}return n/o.length}function me(e){return 1===(e.material?.color?.a??1)}const pe=u(),fe=new S;export{oe as Graphics3DPathSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Error.js";import{translate as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{IDENTITY as r,create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as a,scale as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as n,fromArray as l,clone as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as h}from"../../../../chunks/vec32.js";import{fromArray as p,create as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectBuffer as d}from"../../../../geometry/projection/projectBuffer.js";import{create as u,fromSubBuffer as g,intersectsClippingArea as b}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as _,doubleArrayFrom as y}from"../../../../geometry/support/DoubleArray.js";import{EmissiveSourceMode as v}from"../../../../symbols/support/materialUtils.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 C}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{isValidSize as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as A}from"./interfaces.js";import{ConvertOptions as U,initFastSymbolUpdatesState as k,updateFastSymbolUpdatesState as R,getAttributeValue as z}from"../support/FastSymbolUpdates.js";import{SamplePosition as E}from"../../support/ElevationProvider.js";import{NormalType as L}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{CullFaceOptions as O}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as I}from"../../webgl-engine/lib/Object3D.js";import{Path as G}from"../../webgl-engine/lib/Path.js";import{PathBuilder as B}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as F,TriangulationCapBuilder as M,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 W,PathGeometry as T,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 D{constructor(e,t,i,r){super(e,t,i,r,ce(t)),this._intrinsicSize=n(1,1),this._upVectorAlignment=W.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,i=null!=e.width?e.width:e.height,r=null!=e.height?e.height:i;this._vvConvertOptions=new U({supports:{size:!0,color:!0,rotation:!1,opacity:!0},modelSize:[1,1,1],symbolSize:[i,1,r],unitInMeters:this._context.renderCoordsHelper.unitInMeters,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:[i,1,r]});const s=this._context.renderer?.visualVariables;this._fastUpdates=s?.length?k(this._context.renderer,this._vvConvertOptions):null;const n=e.anchor||"center";this._upVectorAlignment="heading"===e.profileRotation?W.World:W.Path;const c=e.profile||"circle";switch(c){default:case"circle":this._profile=Y[n];break;case"quad":this._profile=X[n]}switch(e.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 h=e.cap||"butt";switch(h){case"none":this._startCap=new q,this._endCap=new q;break;case"butt":default:this._startCap=new M(this._profile,0),this._endCap=new M(this._profile,0,!0);break;case"square":this._startCap=new M(this._profile,-.5),this._endCap=new M(this._profile,.5,!0);break;case"round":{const e="quad"===c;this._startCap=new F({profile:this._profile,flip:!1,breakNormals:e,subdivisions:C}),this._endCap=new F({profile:this._profile,flip:!0,breakNormals:e,subdivisions:C});break}}const m=this.symbolLayer?.material?.color,f=this._getCombinedOpacityAndColor(m),d=p(f),u=f[3],g=this.needsDrivenTransparentPass,b=e.material?.emissive,_={diffuse:d,ambient:d,emissiveStrength:b?.strength??0,emissiveSource:v.Color,opacity:u,drivenOpacity:g,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(a(this._intrinsicSize,i,r),!V(this._intrinsicSize[0])||!V(this._intrinsicSize[1])))throw new t("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");let y;this._fastUpdates?.visualVariables.size||o(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates?y=new ie({..._,...this._fastUpdates.materialParameters,size:l(this._intrinsicSize)},this._context):(_.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,_.normalType=L.Compressed,y=new te(_,this._context)),y.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,cullFace:y.transparent||"none"===h?O.None:O.Back}),this._materials[0]=y,this._context.stage.add(y)}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);return this._createAs3DShape(e,i)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e);this._materials[0]?.setParameters({opacity:t})}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 A.RecreateSymbol;if(!R(this._fastUpdates,t,this._vvConvertOptions))return A.RecreateSymbol;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return A.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 h of i)t+=h.length;const n=_(3*t);let l,c=0;for(const h of i){r.push({offset:c,numVertices:h.length});for(const t of h)n[c++]=t[0],n[c++]=t[1],n[c++]=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=y(n):(l=_(3*t),d(n,a,0,l,o,0,t)),{pathVertexDataInfos:r,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,t){const{graphic:a,renderingInfo:o}=e,n=a.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 p=new Array,m=n.spatialReference,f=u(),d=this._context.renderCoordsHelper,_=new E(l.vertexDataES),y=a.uid;let v=0;for(const u of l.pathVertexDataInfos){const e=u.numVertices;if(e<2)continue;const n=u.offset;if(null!=this._context.clippingExtent&&(g(l.vertexDataES,n,e,f),!b(f,this._context.clippingExtent)))continue;const w=new Array,P=n+3*e;for(let i=n;i<P;i+=3){_.offset=i;const e=x(_,this._context.elevationProvider,t,d);h(he,l.vertexDataRS[i],l.vertexDataRS[i+1],l.vertexDataRS[i+2]),d.setAltitude(he,e),l.vertexDataRS[i]=he[0],l.vertexDataRS[i+1]=he[1],l.vertexDataRS[i+2]=he[2],w.push($(this._upVectorAlignment))}const j=new G(w,l.vertexDataES,l.vertexDataRS,n);ae(j,this._upVectorAlignment,this._context.renderCoordsHelper);const S=new B(j,this._profile,this._extruder,this._startCap,this._endCap);let C=null;if(this._fastUpdates){const e=this._fastUpdates.visualVariables,t=z(e.size?.field,a)??0,i=z(e.color?.field,a)??0,r=z(e.opacity?.field,a)??0;C=new J(S,t,i,r)}else{const e=c(this._intrinsicSize);if(this._drivenProperties.size){const t=o.size??["symbol-value","symbol-value","symbol-value"];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;if(this._drivenProperties.color&&(t=o.color??this._getFallbackOpacityAndColor()),this._drivenProperties.opacity){const e=o.opacity??this._getFallbackOpacityAndColor()[3];t=t?[t[0],t[1],t[2],e]:[1,1,1,e]}const i=new K(S);i.bake(e),t&&i.bakeVertexColors(t),C=i}const D=C.createGeometryData(),V=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:y,layerViewUid:this._context.layerViewUid}),A=new T(this._materials[0],D,C,m,this._stencilWidth,V);A.transformation=i(s(),r,S.path.origin),p.push(A),v+=S.usedMemory}if(0===p.length)return null;const P=new I({geometries:p,layerViewUid:this._context.layerViewUid,graphicUid:y}),S=new j(this,P,p,null,null,((e,t,i,r,s)=>le(e,t,r,s,this._upVectorAlignment)),t,null,v);return S.alignedSampledElevation=0,S.needsElevationUpdates=w(t.mode),S}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??f}}function ae(e,t,i){const{origin:r,positions:s}=e;let a=e.offset;switch(t){default:case W.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 W.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,pe),s+=pe.sampledElevation,he[0]=n[p]+a[0],he[1]=n[p+1]+a[1],he[2]=n[p+2]+a[2],r.setAltitude(he,pe.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!==W.World&&ae(o,s,r),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(l,ee.POSITION)}return n/o.length}function ce(e){return 1===(e.material?.color?.a??1)}const he=m(),pe=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.33/esri/copyright.txt for details.
4
4
  */
5
- import{colorGamma as e}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as r}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as o,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as u,d as c,E as m,l as f,n as d,m as p}from"../../../../chunks/vec32.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as x,expandWithVec3 as T}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as h,BufferViewVec4u8 as y,BufferViewVec4u16 as w,BufferViewVec3f as R,BufferViewVec3u8 as v,BufferViewVec3u16 as j}from"../../../../geometry/support/buffer/BufferView.js";import{t as B,b as S,n as M,f as A}from"../../../../chunks/vec3.js";import{t as F,b as E}from"../../../../chunks/vec4.js";import{a as I}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as O}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as C}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as P}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as U}from"./ProcessedObjectResource.js";import{load as k,processLoadResult as N}from"./wosrLoader.js";import{NormalType as V}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _,DepthTestFunction as q,CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as W}from"../../webgl-engine/lib/Geometry.js";import{Texture as H}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{esriSymbologyMRRFactors as z,advancedMRRFactors as K,useSchematicPBR as J,schematicMRRFactors as X}from"../../webgl-engine/materials/pbrUtils.js";async function Y(e,t){const o=Z(r(e));if("wosr"===o.fileType){const e=await(t.cache?t.cache.loadWOSR(o.url,t):k(o.url,t)),{engineResources:r,referenceBoundingBox:s}=N(e,t);return{lods:r,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(t.cache)s=await t.cache.loadGLTF(o.url,t,!!t.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new L(t.streamDataRequester),o.url,t,t.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ie(s,i));const l=!!t.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:z}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:K},u={...t.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=ee(s,a,u,t,o.specifiedLodIndex);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Z(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function ee(e,r,t,o,s){const i=e.model,n=new Array,l=new Map,a=new Map,u=i.lods.length,c=x();return i.lods.forEach(((e,m)=>{const f=!0===o.skipHighLods&&(u>1&&0===m||u>3&&1===m)||!1===o.skipHighLods&&null!=s&&m!==s;if(f&&0!==m)return;const d=new U(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const s=f?new $({},o):re(i,e,d,r,t,l,a,o),{geometry:n,vertexCount:u}=te(e,s??new $({},o)),p=n.boundingInfo;null!=p&&0===m&&(T(c,p.bbMin),T(c,p.bbMax)),null!=s&&(d.stageResources.geometries.push(n),d.numberOfVertices+=u)})),f||n.push(d)})),{engineResources:n,referenceBoundingBox:c}}function re(r,t,o,s,i,n,l,u){const c=r.materials.get(t.material);if(null==c)return null;const{normal:m,color:f,texCoord0:d,tangent:p}=t.attributes,g=t.material+(m?"_normal":"")+(f?"_color":"")+(d?"_texCoord0":"")+(p?"_tangent":""),x=null!=t.attributes.texCoord0,T=null!=t.attributes.normal,b=se(c.alphaMode);if(!n.has(g)){if(x){const e=(e,t=!1)=>{if(null!=e&&!l.has(e)){const o=r.textures.get(e);if(o){const r=o.data;l.set(e,new H(C(r)?r.data:r,{...o.parameters,preMultiplyAlpha:!C(r)&&t,encoding:C(r)?r.encoding:void 0}))}}};e(c.colorTexture,b!==_.Opaque),e(c.normalTexture),e(c.occlusionTexture),e(c.emissiveTexture),e(c.metallicRoughnessTexture)}const o=1/e,m=c.color[0]**o,f=c.color[1]**o,d=c.color[2]**o,p=c.emissiveFactor[0]**o,h=c.emissiveFactor[1]**o,y=c.emissiveFactor[2]**o,w=null!=c.colorTexture&&x?l.get(c.colorTexture):null,R=J(c),v=null!=c.normalTextureTransform?.scale?c.normalTextureTransform?.scale:a;n.set(g,new $({...s,customDepthTest:q.Lequal,textureAlphaMode:b,textureAlphaCutoff:c.alphaCutoff,diffuse:[m,f,d],ambient:[m,f,d],opacity:"OPAQUE"===c.alphaMode?1:c.opacity,doubleSided:c.doubleSided,doubleSidedType:"winding-order",cullFace:c.doubleSided?G.None:G.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:T?V.Attribute:V.ScreenDerivative,castShadows:!0,receiveShadows:c.receiveShadows,receiveAmbientOcclusion:c.receiveAmbientOcclustion,textureId:null!=w?w.id:void 0,colorMixMode:c.colorMixMode,normalTextureId:null!=c.normalTexture&&x?l.get(c.normalTexture).id:void 0,textureAlphaPremultiplied:null!=w&&!!w.parameters.preMultiplyAlpha,occlusionTextureId:null!=c.occlusionTexture&&x?l.get(c.occlusionTexture).id:void 0,emissiveTextureId:null!=c.emissiveTexture&&x?l.get(c.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=c.metallicRoughnessTexture&&x?l.get(c.metallicRoughnessTexture).id:void 0,emissiveFactor:[p,h,y],mrrFactors:R?X:[c.metallicFactor,c.roughnessFactor,s.mrrFactors[2]],isSchematic:R,colorTextureTransformMatrix:P(c.colorTextureTransform),normalTextureTransformMatrix:P(c.normalTextureTransform),scale:[v[0],v[1]],occlusionTextureTransformMatrix:P(c.occlusionTextureTransform),emissiveTextureTransformMatrix:P(c.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:P(c.metallicRoughnessTextureTransform),...i},u))}const h=n.get(g);if(o.stageResources.materials.push(h),x){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(c.colorTexture),e(c.normalTexture),e(c.occlusionTexture),e(c.emissiveTexture),e(c.metallicRoughnessTexture)}return h}function te(e,r){const i=e.attributes.position.count,n=O(e.indices||i,e.primitiveType),l=b(3*i),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;B(l,a,e.transform,3,u);const c=[[Q.POSITION,new D(l,n,3,!0)]];if(null!=e.attributes.normal){const r=b(3*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.normal;o(oe,e.transform),S(r,s,oe,3,l),t(oe)&&M(r,r),c.push([Q.NORMAL,new D(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=b(4*i),{typedBuffer:o,typedBufferStride:l}=e.attributes.tangent;s(oe,e.transform),F(r,o,oe,4,l),t(oe)&&M(r,r,4),c.push([Q.TANGENT,new D(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=b(2*i),{typedBuffer:t,typedBufferStride:o}=e.attributes.texCoord0;I(r,t,2,o),c.push([Q.UV0,new D(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*i);4===m.elementCount?m instanceof h?E(r,m,1,255):(m instanceof y||m instanceof w)&&E(r,m,1/255,255):(r.fill(255),m instanceof R?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof v||e.attributes.color instanceof j)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push([Q.COLOR,new D(r,n,4,!0)])}return{geometry:new W(r,c),vertexCount:i}}const oe=i();function se(e){switch(e){case"BLEND":return _.Blend;case"MASK":return _.Mask;case"OPAQUE":case null:case void 0:return _.Opaque}}function ie(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const a=i.attributes.position,x=a.count,T=g(),b=g(),y=g(),w=new Float32Array(4*x),v=new Float32Array(3*x),j=n(l(),i.transform);let B=0,S=0;for(let n=0;n<x;n++){a.getVec(n,b),s.getVec(n,T),u(b,b,i.transform),c(y,b,t.center),m(y,y,t.radius);const l=y[2],g=f(y),x=Math.min(.45+.55*g*g,1)**e;m(y,y,t.radius),null!==j&&u(y,y,j),d(y,y),o+1!==r.model.lods.length&&r.model.lods.length>1&&p(y,y,T,l>-1?.2:Math.min(-4*l-3.8,1)),v[B]=y[0],v[B+1]=y[1],v[B+2]=y[2],B+=3,w[S]=x,w[S+1]=x,w[S+2]=x,w[S+3]=1,S+=4}i.attributes.normal=new R(v),i.attributes.color=new h(w)}}}export{Y as fetch,Z as parseUrl};
5
+ import{colorGamma as e}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as r}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as o,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as a}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as u,d as c,E as m,l as f,n as d,m as p}from"../../../../chunks/vec32.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as x,expandWithVec3 as T}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as h,BufferViewVec4u8 as y,BufferViewVec4u16 as w,BufferViewVec3f as R,BufferViewVec3u8 as v,BufferViewVec3u16 as j}from"../../../../geometry/support/buffer/BufferView.js";import{t as B,b as S,n as M,f as A}from"../../../../chunks/vec3.js";import{t as F,b as E}from"../../../../chunks/vec4.js";import{a as I}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as C}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as O}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as P}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as U}from"./ProcessedObjectResource.js";import{load as k,processLoadResult as N}from"./wosrLoader.js";import{NormalType as V}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _,DepthTestFunction as q,CullFaceOptions as G}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as W}from"../../webgl-engine/lib/Geometry.js";import{Texture as H}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{esriSymbologyMRRFactors as z,advancedMRRFactors as K,useSchematicPBR as J,schematicMRRFactors as X}from"../../webgl-engine/materials/pbrUtils.js";async function Y(e,t){const o=Z(r(e));if("wosr"===o.fileType){const e=await(t.cache?t.cache.loadWOSR(o.url,t):k(o.url,t)),{engineResources:r,referenceBoundingBox:s}=N(e,t);return{lods:r,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(t.cache)s=await t.cache.loadGLTF(o.url,t,!!t.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new L(t.streamDataRequester),o.url,t,t.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ie(s,i));const l=!!t.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:z}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:K},u={...t.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=ee(s,a,u,t,o.specifiedLodIndex);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Z(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function ee(e,r,t,o,s){const i=e.model,n=new Array,l=new Map,a=new Map,u=i.lods.length,c=x();return i.lods.forEach(((e,m)=>{const f=!0===o.skipHighLods&&(u>1&&0===m||u>3&&1===m)||!1===o.skipHighLods&&null!=s&&m!==s;if(f&&0!==m)return;const d=new U(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const s=f?new $({},o):re(i,e,d,r,t,l,a,o),{geometry:n,vertexCount:u}=te(e,s??new $({},o)),p=n.boundingInfo;null!=p&&0===m&&(T(c,p.bbMin),T(c,p.bbMax)),null!=s&&(d.stageResources.geometries.push(n),d.numberOfVertices+=u)})),f||n.push(d)})),{engineResources:n,referenceBoundingBox:c}}function re(r,t,o,s,i,n,l,u){const c=r.materials.get(t.material);if(null==c)return null;const{normal:m,color:f,texCoord0:d,tangent:p}=t.attributes,g=t.material+(m?"_normal":"")+(f?"_color":"")+(d?"_texCoord0":"")+(p?"_tangent":""),x=null!=t.attributes.texCoord0,T=null!=t.attributes.normal,b=se(c.alphaMode);if(!n.has(g)){if(x){const e=(e,t=!1)=>{if(null!=e&&!l.has(e)){const o=r.textures.get(e);if(o){const r=o.data;l.set(e,new H(O(r)?r.data:r,{...o.parameters,preMultiplyAlpha:!O(r)&&t,encoding:O(r)?r.encoding:void 0}))}}};e(c.colorTexture,b!==_.Opaque),e(c.normalTexture),e(c.occlusionTexture),e(c.emissiveTexture),e(c.metallicRoughnessTexture)}const o=1/e,m=c.color[0]**o,f=c.color[1]**o,d=c.color[2]**o,p=c.emissiveFactor[0]**o,h=c.emissiveFactor[1]**o,y=c.emissiveFactor[2]**o,w=null!=c.colorTexture&&x?l.get(c.colorTexture):null,R=J(c),v=null!=c.normalTextureTransform?.scale?c.normalTextureTransform?.scale:a;n.set(g,new $({...s,customDepthTest:q.Lequal,textureAlphaMode:b,textureAlphaCutoff:c.alphaCutoff,diffuse:[m,f,d],ambient:[m,f,d],opacity:"OPAQUE"===c.alphaMode?1:c.opacity,doubleSided:c.doubleSided,doubleSidedType:"winding-order",cullFace:c.doubleSided?G.None:G.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:T?V.Attribute:V.ScreenDerivative,castShadows:!0,receiveShadows:c.receiveShadows,receiveAmbientOcclusion:c.receiveAmbientOcclustion,textureId:null!=w?w.id:void 0,colorMixMode:c.colorMixMode,normalTextureId:null!=c.normalTexture&&x?l.get(c.normalTexture).id:void 0,textureAlphaPremultiplied:null!=w&&!!w.parameters.preMultiplyAlpha,occlusionTextureId:null!=c.occlusionTexture&&x?l.get(c.occlusionTexture).id:void 0,emissiveTextureId:null!=c.emissiveTexture&&x?l.get(c.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=c.metallicRoughnessTexture&&x?l.get(c.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[p,h,y],mrrFactors:R?X:[c.metallicFactor,c.roughnessFactor,s.mrrFactors[2]],isSchematic:R,colorTextureTransformMatrix:P(c.colorTextureTransform),normalTextureTransformMatrix:P(c.normalTextureTransform),scale:[v[0],v[1]],occlusionTextureTransformMatrix:P(c.occlusionTextureTransform),emissiveTextureTransformMatrix:P(c.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:P(c.metallicRoughnessTextureTransform),...i},u))}const h=n.get(g);if(o.stageResources.materials.push(h),x){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(c.colorTexture),e(c.normalTexture),e(c.occlusionTexture),e(c.emissiveTexture),e(c.metallicRoughnessTexture)}return h}function te(e,r){const i=e.attributes.position.count,n=C(e.indices||i,e.primitiveType),l=b(3*i),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;B(l,a,e.transform,3,u);const c=[[Q.POSITION,new D(l,n,3,!0)]];if(null!=e.attributes.normal){const r=b(3*i),{typedBuffer:s,typedBufferStride:l}=e.attributes.normal;o(oe,e.transform),S(r,s,oe,3,l),t(oe)&&M(r,r),c.push([Q.NORMAL,new D(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=b(4*i),{typedBuffer:o,typedBufferStride:l}=e.attributes.tangent;s(oe,e.transform),F(r,o,oe,4,l),t(oe)&&M(r,r,4),c.push([Q.TANGENT,new D(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=b(2*i),{typedBuffer:t,typedBufferStride:o}=e.attributes.texCoord0;I(r,t,2,o),c.push([Q.UV0,new D(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*i);4===m.elementCount?m instanceof h?E(r,m,1,255):(m instanceof y||m instanceof w)&&E(r,m,1/255,255):(r.fill(255),m instanceof R?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof v||e.attributes.color instanceof j)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push([Q.COLOR,new D(r,n,4,!0)])}return{geometry:new W(r,c),vertexCount:i}}const oe=i();function se(e){switch(e){case"BLEND":return _.Blend;case"MASK":return _.Mask;case"OPAQUE":case null:case void 0:return _.Opaque}}function ie(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const a=i.attributes.position,x=a.count,T=g(),b=g(),y=g(),w=new Float32Array(4*x),v=new Float32Array(3*x),j=n(l(),i.transform);let B=0,S=0;for(let n=0;n<x;n++){a.getVec(n,b),s.getVec(n,T),u(b,b,i.transform),c(y,b,t.center),m(y,y,t.radius);const l=y[2],g=f(y),x=Math.min(.45+.55*g*g,1)**e;m(y,y,t.radius),null!==j&&u(y,y,j),d(y,y),o+1!==r.model.lods.length&&r.model.lods.length>1&&p(y,y,T,l>-1?.2:Math.min(-4*l-3.8,1)),v[B]=y[0],v[B+1]=y[1],v[B+2]=y[2],B+=3,w[S]=x,w[S+1]=x,w[S+2]=x,w[S+3]=1,S+=4}i.attributes.normal=new R(v),i.attributes.color=new h(w)}}}export{Y as fetch,Z as parseUrl};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{validateColorAndOpacity as e,validateColor as o}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as r}from"../../../../core/mathUtils.js";import{TextureEncoding as a,TextureUsage as s}from"./enums.js";import{RenderTexture as t}from"../../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as l}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as n,CullFaceOptions as i,AlphaDiscardMode as u}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as c}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBRI3S as m,useSchematicPBR as d,schematicMRRFactors as p,advancedMRRFactors as g}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as h}from"../../../webgl/enums.js";import{alphaCutoff as f}from"../../../../webscene/support/AlphaCutoff.js";function T(o,r,a){const t=new Map,l=(e,o)=>{if(null==e)return-1;const r=t.get(e.id);if(r)return r.usage|=o,r.id;const a=t.size;return t.set(e.id,{id:a,usage:o}),a},n=r.pbrMetallicRoughness,u=n?.baseColorFactor?e(n.baseColorFactor):null,c=r.emissiveFactor,h=has("disable-feature:diffuse-rendering-i3s")||a?m({normalTexture:r.normalTexture,emissiveTexture:r.emissiveTexture,emissiveFactor:r.emissiveFactor,occlusionTexture:r.occlusionTexture,metallicRoughnessTexture:n?.metallicRoughnessTexture,metallicFactor:n?.metallicFactor,roughnessFactor:n?.roughnessFactor}):d({normalTexture:r.normalTexture,emissiveTexture:r.emissiveTexture,emissiveFactor:r.emissiveFactor,occlusionTexture:r.occlusionTexture,metallicRoughnessTexture:n?.metallicRoughnessTexture,metallicFactor:n?.metallicFactor,roughnessFactor:n?.roughnessFactor}),f=h?p[0]:n?.metallicFactor??g[0],T=h?p[1]:n?.roughnessFactor??g[1],b="mask"===r.alphaMode?s.Color|s.AlphaMask:s.Color,C={baseColorFactor:u?[u[0],u[1],u[2],u[3]]:[1,1,1,1],baseColorTextureId:l(n?.baseColorTexture,b),metallicRoughnessTextureId:l(n?.metallicRoughnessTexture,s.MetallicRoughness),metallicFactor:f,roughnessFactor:T},P={alphaMode:r.alphaMode,alphaCutoff:r.alphaCutoff,doubleSided:r.doubleSided,cullFace:"none"===r.cullFace?i.None:"back"===r.cullFace?i.Back:"front"===r.cullFace?i.Front:i.None,normalTextureId:l(r.normalTexture,s.Normal),emissiveTextureId:l(r.emissiveTexture,s.Emissive),occlusionTextureId:l(r.occlusionTexture,s.Occlusion),emissiveFactor:c?[c[0],c[1],c[2]]:[0,0,0],metallicRoughness:C,wrapTextures:!1,hasParametersFromSource:h},S=[];return t.forEach((({usage:e},r)=>{const a=null!=o&&o[r]&&o[r].formats,s=a?x(a.map((({name:e,format:o})=>({name:e,encoding:F[o]})))):[];S.push({id:r,usage:e,encodings:s})})),{material:P,textures:S}}function x(e){return e.sort(((e,o)=>e.encoding-o.encoding))}const F={ktx2:a.KTX2,basis:a.Basis,dds:a.DDS_S3TC,png:a.PNG,jpg:a.JPG,"ktx-etc2":a.KTX_ETC2},b={[n.KTX2_ENCODING]:a.Basis,[n.BASIS_ENCODING]:a.Basis,[n.DDS_ENCODING]:a.DDS_S3TC,"image/png":a.PNG,"image/jpg":a.JPG,"image/jpeg":a.JPG,"image/ktx":a.KTX_ETC2};function C(e){const a=e?.materialDefinitions?Object.keys(e.materialDefinitions)[0]:null,t=e?.textureDefinitions?Object.keys(e.textureDefinitions)[0]:null,l=a?e.materialDefinitions?.[a]:null,n=t?e.textureDefinitions?.[t]:null,u=P();if(null!=l){const e=l.params;e.diffuse&&(o(e.diffuse),u.metallicRoughness.baseColorFactor=[e.diffuse[0],e.diffuse[1],e.diffuse[2],1]),null!=e.doubleSided&&(u.doubleSided=e.doubleSided,u.cullFace=e.doubleSided?i.None:i.Back),"none"!==e.cullFace&&"front"!==e.cullFace&&"back"!==e.cullFace||(u.cullFace="none"===e.cullFace?i.None:"back"===e.cullFace?i.Back:i.Front),e.transparency&&(u.metallicRoughness.baseColorFactor[3]=r(1-e.transparency,0,1)),(e.useVertexColorAlpha||u.metallicRoughness.baseColorFactor[3]<1)&&(u.alphaMode="blend")}const c=[];if(null!=n){const e=0;!n.wrap||"repeat"!==n.wrap[0]&&"repeat"!==n.wrap[1]||(u.wrapTextures=!0);let o=s.Color;"rgba"===n.channels&&(u.alphaMode="blend",o|=s.AlphaMask);const r=n.images.length-1,a=n.images[r],t=e=>e?.split("/").pop(),l=Array.isArray(n.encoding)?x(n.encoding.map(((e,o)=>({name:t(a.href[o]),encoding:b[e]||0})))):[{name:t(a.href),encoding:b[n.encoding]||0}];c.push({id:e,usage:o,encodings:l}),u.metallicRoughness.baseColorTextureId=e}return{material:u,textures:c}}const P=()=>({alphaMode:"opaque",alphaCutoff:f,doubleSided:!0,cullFace:i.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function S(e,o,r,a){if(null==e?.data)return null;const t=e.data,l=a.renderingContext.parameters.maxMaxAnisotropy,n=l>1,i=r||!o.wrapTextures?M:D,u=I(e.encoding),m=e.usage&s.Color?"opaque"===o.alphaMode?3:4:3;return new c(t,{mipmap:n,maxAnisotropy:l,encoding:u,wrap:i,components:m,noUnpackFlip:!0})}const M={s:h.CLAMP_TO_EDGE,t:h.CLAMP_TO_EDGE},D={s:h.REPEAT,t:h.REPEAT};function R(o,r,a,n,i,c){const m=c.rendererTextureUsage,d=e=>E(n,a,e&m),h=e(r.metallicRoughness.baseColorFactor);o.baseColor=[h[0],h[1],h[2],h[3]],o.hasParametersFromSource=!!r.hasParametersFromSource,o.usePBR=c.usePBR,o.mrrFactors=[r.metallicRoughness.metallicFactor,r.metallicRoughness.roughnessFactor,r.hasParametersFromSource?p[2]:g[2]],o.emissiveFactor=r.emissiveFactor,o.isIntegratedMesh=c.isIntegratedMesh,o.textureAlphaCutoff="mask"===r.alphaMode?r.alphaCutoff:f,o.alphaDiscardMode="opaque"===r.alphaMode?u.Opaque:"mask"===r.alphaMode?u.Mask:u.MaskBlend;const T=[],x=d(s.Color|s.AlphaMask);null!=x&&(o.baseColorTexture=new t(i,x),T.push(o.baseColorTexture.loadPromise));const F=d(s.MetallicRoughness);null!=F&&(o.metallicRoughnessTexture=new t(i,F),T.push(o.metallicRoughnessTexture.loadPromise));const b=d(s.Emissive);null!=b&&(o.emissionTexture=new t(i,b),T.push(o.emissionTexture.loadPromise));const C=d(s.Occlusion);null!=C&&(o.occlusionTexture=new t(i,C),T.push(o.occlusionTexture.loadPromise));const P=d(s.Normal);return null!=P&&(o.normalTexture=new t(i,P),T.push(o.normalTexture.loadPromise)),o.commonMaterialParameters.hasSlicePlane=c.slicePlaneEnabled,o.commonMaterialParameters.doubleSided=r.doubleSided,o.commonMaterialParameters.cullFace=r.cullFace,o.ellipsoidMode=l(c.viewSpatialReference),Promise.all(T)}function w(e){const o=!!e.compressedTextureS3TC,r=!!e.compressedTextureETC,s=has("disable-feature:i3s-basis")?0:a.Basis|a.KTX2,t=a.JPG|a.PNG,l=s|a.DDS_S3TC;return t|(o?l:0)|(r?s:0)}function N(e,o){if(null!=o)return e.find((e=>!!(e.encoding&o)))}function E(e,o,r){if(null==e||r===s.None)return null;for(let a=0;a<e.length;a++){const s=e[a];if(null!=s&&s.usage&r){const e=o[a];return null!=e?e.id:null}}return null}function I(e){switch(e){case a.KTX2:return n.KTX2_ENCODING;case a.Basis:return n.BASIS_ENCODING;case a.DDS_S3TC:return n.DDS_ENCODING;case a.PNG:return"image/png";case a.JPG:return"image/jpeg";case a.KTX_ETC2:return"image/ktx";default:return""}}export{R as configureMaterial,S as createTexture,P as defaultMaterial,T as getMaterialAndTextures,C as getMaterialAndTexturesFromShared,w as getSupportedEncodings,N as selectEncoding};
5
+ import{validateColorAndOpacity as e,validateColor as o}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as r}from"../../../../core/mathUtils.js";import{EmissiveSourceMode as s}from"../../../../symbols/support/materialUtils.js";import{TextureEncoding as a,TextureUsage as t}from"./enums.js";import{RenderTexture as l}from"../../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as n}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{TextureEncodingMimeType as i,CullFaceOptions as u,AlphaDiscardMode as c}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as m}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBRI3S as d,useSchematicPBR as p,schematicMRRFactors as g,advancedMRRFactors as h}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as f}from"../../../webgl/enums.js";import{alphaCutoff as T}from"../../../../webscene/support/AlphaCutoff.js";function x(o,r,s){const a=new Map,l=(e,o)=>{if(null==e)return-1;const r=a.get(e.id);if(r)return r.usage|=o,r.id;const s=a.size;return a.set(e.id,{id:s,usage:o}),s},n=r.pbrMetallicRoughness,i=n?.baseColorFactor?e(n.baseColorFactor):null,c=r.emissiveFactor,m=has("disable-feature:diffuse-rendering-i3s")||s?d({normalTexture:r.normalTexture,emissiveTexture:r.emissiveTexture,emissiveFactor:r.emissiveFactor,occlusionTexture:r.occlusionTexture,metallicRoughnessTexture:n?.metallicRoughnessTexture,metallicFactor:n?.metallicFactor,roughnessFactor:n?.roughnessFactor}):p({normalTexture:r.normalTexture,emissiveTexture:r.emissiveTexture,emissiveFactor:r.emissiveFactor,occlusionTexture:r.occlusionTexture,metallicRoughnessTexture:n?.metallicRoughnessTexture,metallicFactor:n?.metallicFactor,roughnessFactor:n?.roughnessFactor}),f=m?g[0]:n?.metallicFactor??h[0],T=m?g[1]:n?.roughnessFactor??h[1],x="mask"===r.alphaMode?t.Color|t.AlphaMask:t.Color,C={baseColorFactor:i?[i[0],i[1],i[2],i[3]]:[1,1,1,1],baseColorTextureId:l(n?.baseColorTexture,x),metallicRoughnessTextureId:l(n?.metallicRoughnessTexture,t.MetallicRoughness),metallicFactor:f,roughnessFactor:T},S={alphaMode:r.alphaMode,alphaCutoff:r.alphaCutoff,doubleSided:r.doubleSided,cullFace:"none"===r.cullFace?u.None:"back"===r.cullFace?u.Back:"front"===r.cullFace?u.Front:u.None,normalTextureId:l(r.normalTexture,t.Normal),emissiveTextureId:l(r.emissiveTexture,t.Emissive),occlusionTextureId:l(r.occlusionTexture,t.Occlusion),emissiveFactor:c?[c[0],c[1],c[2]]:[0,0,0],metallicRoughness:C,wrapTextures:!1,hasParametersFromSource:m},P=[];return a.forEach((({usage:e},r)=>{const s=null!=o&&o[r]&&o[r].formats,a=s?F(s.map((({name:e,format:o})=>({name:e,encoding:b[o]})))):[];P.push({id:r,usage:e,encodings:a})})),{material:S,textures:P}}function F(e){return e.sort(((e,o)=>e.encoding-o.encoding))}const b={ktx2:a.KTX2,basis:a.Basis,dds:a.DDS_S3TC,png:a.PNG,jpg:a.JPG,"ktx-etc2":a.KTX_ETC2},C={[i.KTX2_ENCODING]:a.Basis,[i.BASIS_ENCODING]:a.Basis,[i.DDS_ENCODING]:a.DDS_S3TC,"image/png":a.PNG,"image/jpg":a.JPG,"image/jpeg":a.JPG,"image/ktx":a.KTX_ETC2};function S(e){const s=e?.materialDefinitions?Object.keys(e.materialDefinitions)[0]:null,a=e?.textureDefinitions?Object.keys(e.textureDefinitions)[0]:null,l=s?e.materialDefinitions?.[s]:null,n=a?e.textureDefinitions?.[a]:null,i=P();if(null!=l){const e=l.params;e.diffuse&&(o(e.diffuse),i.metallicRoughness.baseColorFactor=[e.diffuse[0],e.diffuse[1],e.diffuse[2],1]),null!=e.doubleSided&&(i.doubleSided=e.doubleSided,i.cullFace=e.doubleSided?u.None:u.Back),"none"!==e.cullFace&&"front"!==e.cullFace&&"back"!==e.cullFace||(i.cullFace="none"===e.cullFace?u.None:"back"===e.cullFace?u.Back:u.Front),e.transparency&&(i.metallicRoughness.baseColorFactor[3]=r(1-e.transparency,0,1)),(e.useVertexColorAlpha||i.metallicRoughness.baseColorFactor[3]<1)&&(i.alphaMode="blend")}const c=[];if(null!=n){const e=0;!n.wrap||"repeat"!==n.wrap[0]&&"repeat"!==n.wrap[1]||(i.wrapTextures=!0);let o=t.Color;"rgba"===n.channels&&(i.alphaMode="blend",o|=t.AlphaMask);const r=n.images.length-1,s=n.images[r],a=e=>e?.split("/").pop(),l=Array.isArray(n.encoding)?F(n.encoding.map(((e,o)=>({name:a(s.href[o]),encoding:C[e]||0})))):[{name:a(s.href),encoding:C[n.encoding]||0}];c.push({id:e,usage:o,encodings:l}),i.metallicRoughness.baseColorTextureId=e}return{material:i,textures:c}}const P=()=>({alphaMode:"opaque",alphaCutoff:T,doubleSided:!0,cullFace:u.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function M(e,o,r,s){if(null==e?.data)return null;const a=e.data,l=s.renderingContext.parameters.maxMaxAnisotropy,n=l>1,i=r||!o.wrapTextures?D:R,u=k(e.encoding),c=e.usage&t.Color?"opaque"===o.alphaMode?3:4:3;return new m(a,{mipmap:n,maxAnisotropy:l,encoding:u,wrap:i,components:c,noUnpackFlip:!0})}const D={s:f.CLAMP_TO_EDGE,t:f.CLAMP_TO_EDGE},R={s:f.REPEAT,t:f.REPEAT};function w(o,r,a,i,u,m){const d=m.rendererTextureUsage,p=e=>I(i,a,e&d),f=e(r.metallicRoughness.baseColorFactor);o.baseColor=[f[0],f[1],f[2],f[3]],o.hasParametersFromSource=!!r.hasParametersFromSource,o.usePBR=m.usePBR,o.mrrFactors=[r.metallicRoughness.metallicFactor,r.metallicRoughness.roughnessFactor,r.hasParametersFromSource?g[2]:h[2]],o.emissiveBaseColor=r.emissiveFactor,o.emissiveSource=s.Emissive,o.isIntegratedMesh=m.isIntegratedMesh,o.textureAlphaCutoff="mask"===r.alphaMode?r.alphaCutoff:T,o.alphaDiscardMode="opaque"===r.alphaMode?c.Opaque:"mask"===r.alphaMode?c.Mask:c.MaskBlend;const x=[],F=p(t.Color|t.AlphaMask);null!=F&&(o.baseColorTexture=new l(u,F),x.push(o.baseColorTexture.loadPromise));const b=p(t.MetallicRoughness);null!=b&&(o.metallicRoughnessTexture=new l(u,b),x.push(o.metallicRoughnessTexture.loadPromise));const C=p(t.Emissive);null!=C&&(o.emissionTexture=new l(u,C),x.push(o.emissionTexture.loadPromise));const S=p(t.Occlusion);null!=S&&(o.occlusionTexture=new l(u,S),x.push(o.occlusionTexture.loadPromise));const P=p(t.Normal);return null!=P&&(o.normalTexture=new l(u,P),x.push(o.normalTexture.loadPromise)),o.commonMaterialParameters.hasSlicePlane=m.slicePlaneEnabled,o.commonMaterialParameters.doubleSided=r.doubleSided,o.commonMaterialParameters.cullFace=r.cullFace,o.ellipsoidMode=n(m.viewSpatialReference),Promise.all(x)}function E(e){const o=!!e.compressedTextureS3TC,r=!!e.compressedTextureETC,s=has("disable-feature:i3s-basis")?0:a.Basis|a.KTX2,t=a.JPG|a.PNG,l=s|a.DDS_S3TC;return t|(o?l:0)|(r?s:0)}function N(e,o){if(null!=o)return e.find((e=>!!(e.encoding&o)))}function I(e,o,r){if(null==e||r===t.None)return null;for(let s=0;s<e.length;s++){const a=e[s];if(null!=a&&a.usage&r){const e=o[s];return null!=e?e.id:null}}return null}function k(e){switch(e){case a.KTX2:return i.KTX2_ENCODING;case a.Basis:return i.BASIS_ENCODING;case a.DDS_S3TC:return i.DDS_ENCODING;case a.PNG:return"image/png";case a.JPG:return"image/jpeg";case a.KTX_ETC2:return"image/ktx";default:return""}}export{w as configureMaterial,M as createTexture,P as defaultMaterial,x as getMaterialAndTextures,S as getMaterialAndTexturesFromShared,E as getSupportedEncodings,N as selectEncoding};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{n as e,a as t,f as i,b as s,c as n,I as r,y as o,h as a,G as c,s as u,j as l,l as h,k as d,d as m,g as _}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as f,i as v}from"../../../../chunks/vec42.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as S}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as M}from"../../../../geometry/projection/projectors.js";import{create as x,fromMatrix as C,intersectsSphere as I,createPoints as P}from"../../../../geometry/support/frustum.js";import{signedDistance as E,getNormal as D}from"../../../../geometry/support/plane.js";import{isPlateCarree as F}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as O,w as B}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as V}from"../../../../layers/graphics/dehydratedPoint.js";import{ViewingMode as j}from"../../../ViewingMode.js";import{evaluateElevationAlignmentAtPoint as A}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as L}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as y,extractExpressionInfo as w}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as G}from"./I3SNode.js";import{isValidMbs as N,intersectBoundingRectWithMbs as U,MbsIntersectResult as k}from"./I3SUtil.js";import{Obb as T,computeOffsetObb as q}from"../../support/orientedBoundingBox.js";const z=1e5;class H{get _frustumMbsCenter(){return this._frustumMbs}get _frustumMbsRadius(){return this._frustumMbs[3]}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=x(),this._frustumMbs=g(),this._useFrustumCulling=!1,this._poi=p(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new T,this._tmp1=p(),this._tmp2=p(),this._tmp3=p(),this._tmp0=p(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=R(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=V(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||F(u)),this._indexSREllipsoidRadius=b(this._indexSR).radius,this._indexSRSphericalPCPF=R(e),this._projectorIndexSRToIndexSRSphericalPCPF=M(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=L.fromElevationInfo(e),this._elevationContext.updateFeatureExpressionInfoContext(y(w(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,r){C(n.viewMatrix,n.projectionMatrix,this._frustum,X);{const r=n.eye,o=Z;e(o,n.viewForward);const a=Y;t(a,X[4],r);const c=.5*i(a,a)/i(o,a),u=this._frustumMbs;s(u,r,o,c);const l=1+c;u[3]=l}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);return void(e&&i.expandElevationRange(e))}const r=s[0],o=s[1],a=s[2],c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const u=t?null:this._elevationProvider.getRootElevationBounds?.();u&&i.expandElevationRange(u)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(N(t))return t;e.serviceMbsInIndexSR&&f(t,e.serviceMbsInIndexSR);const i=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(i)){let s=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":s=this._elevationContext.geometryZWithOffset(t[2],this._renderCoordsHelper)+i-t[2],n=r-i;break;case"on-the-ground":s=i-t[2],n=r-i}t[2]+=s+.5*n,t[3]+=.5*n}else this._elevationContext&&t[3]<z&&(this._tmpPoint.x=t[0],this._tmpPoint.y=t[1],this._tmpPoint.z=t[2],t[2]=A(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return S(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new T,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i[3];let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<z){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=A(e,this._elevationProvider,u,c)-a}const l=o>0,h=l?this._tmpObb:t;return s.transform(h,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),l&&q(h,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(ee,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),ee):null}ensureElevationAgnosticBoundingVolume(e){return-1===e.elevationAgnosticBoundingVolume[3]&&e.level>0&&(this._viewingMode===j.Global?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),o=t.elevationAgnosticBoundingVolume;let a,c=-1;if(s){const t=te;s.getCenter(t),e(t,t),a=t,s.getCorners(ie);for(const s of ie){e(s,s);const n=i(s,t);if(n<=0)return void(o[3]=-1);const r=Math.sqrt(1-n*n);c=Math.max(c,r)}}else{const i=t.serviceMbsInRenderSR;if(!N(i))return void(o[3]=-1);{const t=n(te,O(i)),s=i[3],u=r(t);if(u<s)return void(o[3]=-1);c=s/u,e(t,t),a=t}}v(o,a);const u=.001;o[3]=c+u}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(te);e[2]=0,v(t,e);let s=0;const n=se;i.getCorners(ie);for(const t of ie){t[2]=0;const e=o(n,t);s=Math.max(s,e)}t[3]=Math.sqrt(s)}else{const i=e.serviceMbsInRenderSR;if(N(i)){const e=n(te,O(i));e[2]=0,v(t,e),t[3]=i[3]}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):I(this._frustum,B(t))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(-1===e[3]||(this._viewingMode===j.Global?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n[3];if(-1===r||r>.9)return!0;const o=this._frustumPlanes,c=this._frustumMbsCenter,u=n,l=i(u,c),h=this._frustumMbsRadius,d=l-h,m=l+h;if(d<=0)return!0;const _=a(K,u,d),p=a(Q,u,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=D(v),r=e($,n),o=i(r,u);if(Math.abs(1-o)<.01)continue;const c=ne;a(c,u,o),t(c,c,r),e(c,c);const l=re;s(l,_,c,d*f);if(E(v,l)<=0)continue;s(l,p,c,m*f);if(E(v,l)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e[3];if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,o=r(n);if(o<=s)return!0;const u=e,l=i(u,n);{const e=a(J,u,l);if(c(e,n)<s)return!0}const h=l/o;if(l<=0){return-h<s}const d=Math.sqrt(1-h*h);if(d<t)return!0;const m=s/o;return d*Math.sqrt(1-m*m)-m*h<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(-1===e[3])return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=ie;if(t.getCorners(o),this._viewingMode===j.Global){const t=e,c=i(t,n),u=c-s,l=c+s;if(u<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=oe;if(a(o,n,u/r),E(e,o)<=0){s=!1;break}const c=oe;if(a(c,n,l/r),E(e,c)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=D(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=n(J,t);s[2]=0;const r=e[3];return c(s,e)<=r+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||U(this._clippingArea,e)!==k.OUTSIDE}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(u(O(i),this._camPos)),n=s-i[3];return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e)[3]}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=l(O(t),this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t[3],s=(Math.abs(t[0]*(t[0]-this._camPos[0])+t[1]*(t[1]-this._camPos[1])+t[2]*(t[2]-this._camPos[2]))/h(O(t))+i)/l(O(t),this._camPos);return Math.min(1,s)}hasLOD(e){return e.lodMetric!==G.None}_getDistanceGlobeMode(e,t){const s=h(O(t)),n=h(e)-s;a(this._tmp0,e,i(e,O(t))/d(e));const r=u(O(t),this._tmp0),o=t[3];if(r<=o*o)return Math.abs(n);{const r=a(this._tmp0,O(t),1/s),c=s,u=o*o/2/c,d=a(this._tmp1,r,c-u),p=e,f=m(this._tmp2,p,d),v=m(this._tmp2,f,a(this._tmp3,r,i(r,f))),g=_(this._tmp2,d,a(this._tmp2,v,o/h(v)));let b=l(p,g);if(n>=2e5){const e=m(this._tmp1,p,g);let t=i(e,r)/h(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):W(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(e.lodMetric===G.None)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case G.ScreenSpaceRelative:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i[3];return this._updateMinMaxDistance(r),e.maxError*t<=n}case G.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(e,e.serviceMbsInIndexSR[3]*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case G.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case G.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToPOI(e){const t=this.getServiceMbsInRenderSR(e);return l(O(t),this._poi)-t[3]}distCameraToPOI(){return l(this._camPos,this._poi)}}function W(e,t){const i=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],r=i*i+s*s,o=t[3];if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const Z=p(),X=P(),Y=p(),J=p(),K=p(),Q=p(),$=p(),ee=new T,te=p(),ie=[p(),p(),p(),p(),p(),p(),p(),p()],se=p(),ne=p(),re=p(),oe=p();export{H as default};
5
+ import{n as e,a as t,f as i,b as s,c as n,H as r,y as o,h as a,F as c,s as u,j as l,l as h,k as d,d as m,g as _}from"../../../../chunks/vec32.js";import{create as p}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{c as f,i as v}from"../../../../chunks/vec42.js";import{create as g}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as b}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as R}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBoundingSphere as S}from"../../../../geometry/projection/projectBoundingSphere.js";import{getProjector as M}from"../../../../geometry/projection/projectors.js";import{create as x,fromMatrix as C,intersectsSphere as I,createPoints as P}from"../../../../geometry/support/frustum.js";import{signedDistance as E,getNormal as D}from"../../../../geometry/support/plane.js";import{isPlateCarree as F}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as O,w as B}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as V}from"../../../../layers/graphics/dehydratedPoint.js";import{ViewingMode as j}from"../../../ViewingMode.js";import{evaluateElevationAlignmentAtPoint as A}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as L}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as y,extractExpressionInfo as w}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as G}from"./I3SNode.js";import{isValidMbs as N,intersectBoundingRectWithMbs as U,MbsIntersectResult as k}from"./I3SUtil.js";import{Obb as T,computeOffsetObb as q}from"../../support/orientedBoundingBox.js";const z=1e5;class H{get _frustumMbsCenter(){return this._frustumMbs}get _frustumMbsRadius(){return this._frustumMbs[3]}get _frustumPlanes(){return this._frustum}constructor(e,t,i,s,n,r,o,a,c={}){this._indexSR=e,this._renderCoordsHelper=t,this._clippingArea=n,this._elevationProvider=r,this._viewingMode=o,this._options=c,this._frustum=x(),this._frustumMbs=g(),this._useFrustumCulling=!1,this._poi=p(),this._elevationContext=null,this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmpObb=new T,this._tmp1=p(),this._tmp2=p(),this._tmp3=p(),this._tmp0=p(),this._screenspaceErrorBias=c.screenspaceErrorBias||1,this._progressiveLoadFactor=c.progressiveLoadFactor||1,this.updateCamera(i,s);const u=this._renderCoordsHelper.spatialReference;this._renderSR=u,this._renderSRSphericalPCPF=R(u),this._isGlobalMode=u===this._renderSRSphericalPCPF,this.updateElevationInfo(a),this._tmpPoint=V(0,0,0,e),this._isECEFOBBInLocalMode=this._indexSR.isWGS84&&(u.isWebMercator||F(u)),this._indexSREllipsoidRadius=b(this._indexSR).radius,this._indexSRSphericalPCPF=R(e),this._projectorIndexSRToIndexSRSphericalPCPF=M(this._indexSR,this._indexSRSphericalPCPF)}updateElevationInfo(e){null!=e?(this._elevationContext=L.fromElevationInfo(e),this._elevationContext.updateFeatureExpressionInfoContext(y(w(e,!1)))):this._elevationContext=null}updateCamera(n,r){if(this._useFrustumCulling=r,r){C(n.viewMatrix,n.projectionMatrix,this._frustum,X);{const r=n.eye,o=Z;e(o,n.viewForward);const a=Y;t(a,X[4],r);const c=.5*i(a,a)/i(o,a),u=this._frustumMbs;s(u,r,o,c);const l=1+c;u[3]=l}}this._screenSizeFactor=1/(n.perScreenPixelRatio/2),this._camPos=n.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(e){this._poi=e}updateScreenSpaceErrorBias(e){const t=this._screenspaceErrorBias;return this._screenspaceErrorBias=e,t}updateClippingArea(e){this._clippingArea=e}expandElevationRange(e,t,i){if(null==this._elevationContext)return;const s=e.serviceMbsInIndexSR;if(!s)return;const n="relative-to-scene"===this._elevationContext.mode?"scene":"ground";if(this._elevationProvider.getSphereElevationBounds){const e=this._elevationProvider.getSphereElevationBounds(s,this._indexSR,n);return void(e&&i.expandElevationRange(e))}const r=s[0],o=s[1],a=s[2],c=this._elevationProvider.getElevation(r,o,a,this._indexSR,n);c&&i.expandElevationRangeValues(c,c);const u=t?null:this._elevationProvider.getRootElevationBounds?.();u&&i.expandElevationRange(u)}getServiceMbsInRenderSR(e){const t=e.serviceMbsInRenderSR;if(N(t))return t;e.serviceMbsInIndexSR&&f(t,e.serviceMbsInIndexSR);const i=e.elevationRangeMin;if(this._elevationContext&&Number.isFinite(i)){let s=0,n=0;const r=e.elevationRangeMax;switch(this._elevationContext.mode){case"relative-to-ground":case"relative-to-scene":s=this._elevationContext.geometryZWithOffset(t[2],this._renderCoordsHelper)+i-t[2],n=r-i;break;case"on-the-ground":s=i-t[2],n=r-i}t[2]+=s+.5*n,t[3]+=.5*n}else this._elevationContext&&t[3]<z&&(this._tmpPoint.x=t[0],this._tmpPoint.y=t[1],this._tmpPoint.z=t[2],t[2]=A(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper));return S(t,this._indexSR,t,this._renderSR),t}getAndUpdateVisibilityObbInRenderSR(e){{const t=e.visibilityObbInRenderSR;if(t)return t}const t=.01*this._indexSREllipsoidRadius,{serviceMbsInIndexSR:i,serviceObbInIndexSR:s}=e;if(null==s||!i||!s.isValid||this._isECEFOBBInLocalMode&&(s.halfSizeX>t||s.halfSizeY>t||s.halfSizeZ>t))return null;{let t=e.serviceObbInRenderSR;if(null==t)t=new T,e.serviceObbInRenderSR=t;else if(t.isValid)return t;const n=i[3];let r=0,o=0;const a=s.centerZ,c=this._renderCoordsHelper,u=this._elevationContext;if(u&&e.elevationRangeValid){const t=e.elevationRangeMin,i=e.elevationRangeMax;switch(u.mode){case"relative-to-ground":case"relative-to-scene":r=u.geometryZWithOffset(a,c)+t-a,o=i-t;break;case"on-the-ground":r=t-a,o=i-t}}else if(u&&n<z){const e=this._tmpPoint;e.x=s.centerX,e.y=s.centerY,e.z=a,r=A(e,this._elevationProvider,u,c)-a}const l=o>0,h=l?this._tmpObb:t;return s.transform(h,this._indexSR,this._renderSR,r,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),l&&q(h,0,o,this._viewingMode,t),t}}getNodeObbInRenderSRIndependentOfElevationOffset(e){{const t=e.visibilityObbInRenderSR??e.serviceObbInRenderSR??null;if(t?.isValid)return t}const t=e.serviceObbInIndexSR;return t?(t.transform(ee,this._indexSR,this._renderSR,void 0,this._renderSRSphericalPCPF,this._indexSRSphericalPCPF,this._projectorIndexSRToIndexSRSphericalPCPF),ee):null}ensureElevationAgnosticBoundingVolume(e){return-1===e.elevationAgnosticBoundingVolume[3]&&e.level>0&&(this._viewingMode===j.Global?this._updateElevationAgnosticBoundingVolumeGlobal(e):this._updateElevationAgnosticBoundingVolumeLocal(e)),e.elevationAgnosticBoundingVolume}_updateElevationAgnosticBoundingVolumeGlobal(t){const s=this.getNodeObbInRenderSRIndependentOfElevationOffset(t),o=t.elevationAgnosticBoundingVolume;let a,c=-1;if(s){const t=te;s.getCenter(t),e(t,t),a=t,s.getCorners(ie);for(const s of ie){e(s,s);const n=i(s,t);if(n<=0)return void(o[3]=-1);const r=Math.sqrt(1-n*n);c=Math.max(c,r)}}else{const i=t.serviceMbsInRenderSR;if(!N(i))return void(o[3]=-1);{const t=n(te,O(i)),s=i[3],u=r(t);if(u<s)return void(o[3]=-1);c=s/u,e(t,t),a=t}}v(o,a);const u=.001;o[3]=c+u}_updateElevationAgnosticBoundingVolumeLocal(e){const t=e.elevationAgnosticBoundingVolume,i=this.getNodeObbInRenderSRIndependentOfElevationOffset(e);if(i){const e=i.getCenter(te);e[2]=0,v(t,e);let s=0;const n=se;i.getCorners(ie);for(const t of ie){t[2]=0;const e=o(n,t);s=Math.max(s,e)}t[3]=Math.sqrt(s)}else{const i=e.serviceMbsInRenderSR;if(N(i)){const e=n(te,O(i));e[2]=0,v(t,e),t[3]=i[3]}}}isNodeVisible(e){const t=this.getServiceMbsInRenderSR(e);if(!this._isMBSinClippingArea(t))return!1;if(!this._useFrustumCulling)return!0;const i=this.getAndUpdateVisibilityObbInRenderSR(e);return i?i.doesIntersectFrustumConservativeApproximation(this._frustum):I(this._frustum,B(t))}isElevationAgnosticBoundingVolumeVisible(e){return!this._useFrustumCulling||(-1===e[3]||(this._viewingMode===j.Global?this._isConeVisibleInFrustum(e):this._isCylinderVisibleInFrustum(e)))}_isConeVisibleInFrustum(n){if(!this._isConeVisibleInFrustumMbs(n))return!1;const r=n[3];if(-1===r||r>.9)return!0;const o=this._frustumPlanes,c=this._frustumMbsCenter,u=n,l=i(u,c),h=this._frustumMbsRadius,d=l-h,m=l+h;if(d<=0)return!0;const _=a(K,u,d),p=a(Q,u,m),f=r/Math.sqrt(1-r*r);for(const v of o){const n=D(v),r=e($,n),o=i(r,u);if(Math.abs(1-o)<.01)continue;const c=ne;a(c,u,o),t(c,c,r),e(c,c);const l=re;s(l,_,c,d*f);if(E(v,l)<=0)continue;s(l,p,c,m*f);if(E(v,l)<=0)continue;return!1}return!0}_isConeVisibleInFrustumMbs(e){const t=e[3];if(t>.9)return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,o=r(n);if(o<=s)return!0;const u=e,l=i(u,n);{const e=a(J,u,l);if(c(e,n)<s)return!0}const h=l/o;if(l<=0){return-h<s}const d=Math.sqrt(1-h*h);if(d<t)return!0;const m=s/o;return d*Math.sqrt(1-m*m)-m*h<t}isObbVisibleIndependentOfElevation(e,t){if(!this._useFrustumCulling)return!0;if(-1===e[3])return!0;const s=this._frustumMbsRadius,n=this._frustumMbsCenter,r=this._frustumPlanes,o=ie;if(t.getCorners(o),this._viewingMode===j.Global){const t=e,c=i(t,n),u=c-s,l=c+s;if(u<=0)return!0;for(const e of r){let s=!0;for(const n of o){const r=i(n,t),o=oe;if(a(o,n,u/r),E(e,o)<=0){s=!1;break}const c=oe;if(a(c,n,l/r),E(e,c)<=0){s=!1;break}}if(s)return!1}}else{const e=n[2]-s,t=n[2]+s;for(const i of r){let s=!0;const n=D(i),r=n[0],a=n[1],c=n[2],u=i[3];for(const i of o){const n=r*i[0]+a*i[1]+u;if(n+c*e<=0||n+c*t<=0){s=!1;break}}if(s)return!1}}return!0}_isCylinderVisibleInFrustum(e){const t=this._frustumMbsCenter,i=this._frustumMbsRadius,s=n(J,t);s[2]=0;const r=e[3];return c(s,e)<=r+i}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const t=e.geometryObbInRenderSR;return t?.doesIntersectFrustumConservativeApproximation(this._frustum)??this.isNodeVisible(e)}_isMBSinClippingArea(e){return null==this._clippingArea||U(this._clippingArea,e)!==k.OUTSIDE}_screenSpaceDiameterMbs(e,t){const i=this.getServiceMbsInRenderSR(e),s=Math.sqrt(u(O(i),this._camPos)),n=s-i[3];return this._updateMinMaxDistance(s),n<0?.5*Number.MAX_VALUE:t/n*this._screenSizeFactor}calcCameraDistance(e){return this.calcCameraDistanceToCenter(e)-this.getServiceMbsInRenderSR(e)[3]}calcCameraDistanceToCenter(e){const t=this.getServiceMbsInRenderSR(e),i=l(O(t),this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(e){const t=this.getServiceMbsInRenderSR(e),i=t[3],s=(Math.abs(t[0]*(t[0]-this._camPos[0])+t[1]*(t[1]-this._camPos[1])+t[2]*(t[2]-this._camPos[2]))/h(O(t))+i)/l(O(t),this._camPos);return Math.min(1,s)}hasLOD(e){return e.lodMetric!==G.None}_getDistanceGlobeMode(e,t){const s=h(O(t)),n=h(e)-s;a(this._tmp0,e,i(e,O(t))/d(e));const r=u(O(t),this._tmp0),o=t[3];if(r<=o*o)return Math.abs(n);{const r=a(this._tmp0,O(t),1/s),c=s,u=o*o/2/c,d=a(this._tmp1,r,c-u),p=e,f=m(this._tmp2,p,d),v=m(this._tmp2,f,a(this._tmp3,r,i(r,f))),g=_(this._tmp2,d,a(this._tmp2,v,o/h(v)));let b=l(p,g);if(n>=2e5){const e=m(this._tmp1,p,g);let t=i(e,r)/h(e);t<.08&&(t=1e-4),b/=t}return b}}_getDistance(e,t){return this._isGlobalMode?this._getDistanceGlobeMode(e,t):W(e,t)}_updateMinMaxDistance(e){e>0?(this.minDistance=Math.min(this.minDistance,e),this.maxDistance=Math.max(this.maxDistance,e)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-e))}getLodLevel(e){if(e.lodMetric===G.None)return 0;if(0===e.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const t=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(e,t)?this.evaluateLODmetric(e,i)?2:1:0}return this.evaluateLODmetric(e,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(e,t){switch(e.lodMetric){case G.ScreenSpaceRelative:{const i=this.getServiceMbsInRenderSR(e),s=this._getDistance(this._camPos,i),n=2*s/this._screenSizeFactor,r=s+i[3];return this._updateMinMaxDistance(r),e.maxError*t<=n}case G.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(e,e.serviceMbsInIndexSR[3]*t);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(e)),i<e.maxError}case G.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(e,e.maxError)*t<10;case G.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(e)>e.maxError*t}return!1}distToPOI(e){const t=this.getServiceMbsInRenderSR(e);return l(O(t),this._poi)-t[3]}distCameraToPOI(){return l(this._camPos,this._poi)}}function W(e,t){const i=e[0]-t[0],s=e[1]-t[1],n=e[2]-t[2],r=i*i+s*s,o=t[3];if(r<=o*o)return Math.abs(n);const a=Math.sqrt(r)-o;return Math.sqrt(n*n+a*a)}const Z=p(),X=P(),Y=p(),J=p(),K=p(),Q=p(),$=p(),ee=new T,te=p(),ie=[p(),p(),p(),p(),p(),p(),p(),p()],se=p(),ne=p(),re=p(),oe=p();export{H as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{I as e,i as t,n as i,f as s,h as o,c as r,G as a}from"../../../../chunks/vec32.js";import{create as l,freeze as n,ZEROS as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as c}from"../../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as h}from"../../../../geometry/support/frustum.js";import{fromValues as m}from"../../../../geometry/support/ray.js";import{ViewingMode as p}from"../../../ViewingMode.js";import{FeatureTileVisibility3D as u,minTileLOD as _}from"./FeatureTileVisibility3D.js";import f from"../../webgl/RenderCamera.js";class v{constructor(e,t,i){this._renderCoordsHelper=e,this._tilingScheme=t,this._camera=new f,this._surfaceElevation=0,this._focusOnMap=[0,0],this._visibility=new u(e,i)}set opaqueGround(e){this._visibility.opaqueGround=e}setup(e,t,i){this._camera.copyFrom(e),this._surfaceElevation=i,this._focusOnMap[0]=t.x,this._focusOnMap[1]=t.y,this._visibility.setup(this._camera)}done(){this._visibility.done()}update(e){const{measures:t,extent:i,level:s}=e;t.visible=this._visibility.compute(e),t.distance=c(i,this._focusOnMap),t.mergeable=!0,t.lodLevel=_,t.splitPriority=Math.max(0,_-s),t.visible&&(this._isGlobal?this._updateSplitAndLodGlobal(e):this._updateSplitAndLodLocal(e))}_updateSplitAndLodGlobal(r){const a=r.level,l=this._renderCoordsHelper,{eye:n,fov:d}=this._camera,c=l.referenceEllipsoid.radius,h=e(n)-c;if(2*Math.atan(c/h)<d&&h>0)return void(r.measures.lodLevel=Math.max(a,_));const m=M,{extent:p}=r,{_surfaceElevation:u}=this;t(m[0],p[0],p[1],u),t(m[1],p[2],p[1],u),t(m[2],p[2],p[3],u),t(m[3],p[0],p[3],u);const f=t(y,.5*(p[0]+p[2]),.5*(p[1]+p[3]),u),v=this._tilingScheme.spatialReference;for(let e=0;e<4;++e)l.toRenderCoords(m[e],v,m[e]);l.toRenderCoords(f,v,f);const b=i(L.direction,f),x=s(n,b),S=o(g,b,x);this._updateSplitAndLod(r,m,f,S)}_updateSplitAndLodLocal(e){const i=M,{extent:s}=e,{_surfaceElevation:o}=this;t(i[0],s[0],s[1],o),t(i[1],s[2],s[1],o),t(i[2],s[2],s[3],o),t(i[3],s[0],s[3],o);const a=this._tilingScheme.spatialReference;for(let t=0;t<4;++t)this._renderCoordsHelper.toRenderCoords(i[t],a,i[t]);const l=t(y,.5*(i[0][0]+i[2][0]),.5*(i[0][1]+i[2][1]),.25*(i[0][2]+i[1][2]+i[2][2]+i[3][2])),n=t(b,l[0],l[1],0),{eye:d,far:c}=this._camera,h=t(g,n[0],n[1],d[2]);t(L.origin,n[0],n[1],d[2]-2*c),r(L.direction,x),this._updateSplitAndLod(e,i,l,h)}_updateSplitAndLod(e,t,i,o){const r=Math.max(a(t[0],t[2]),a(t[1],t[3]),a(t[0],i)+a(i,t[2]),a(t[1],i)+a(i,t[3])),{eye:l,near:n,fov:d,viewForward:c,width:m,height:p,pixelRatio:u,frustum:_}=this._camera,f=s(l,c),v=s(i,c)-f,M=a(i,l);let y=v,b=v,g=M,x=M;const L=(e,t)=>t<n?1:Math.sqrt(e*e-t*t)/t;let C=L(M,v);for(const h of t){const e=s(h,c)-f;y=Math.min(y,e),b=Math.max(b,e);const t=a(h,l);x=Math.max(x,t),g=Math.min(g,t);const i=L(t,e);C=Math.min(C,i)}if(b<n)return void(e.measures.lodLevel=0);const G=Math.cos(.5*d),R=a(l,o);C>G&&R>j*r&&(b=w*x,y=w*g);const A=.5*Math.sqrt(m*m+p*p)/u,E=2*Math.tan(.5*d),q=e=>Math.max(n,e)*S/A*E,H=e.level,O=r*2**H*Math.max(1,E),P=q(y),F=Math.ceil(Math.log2(Math.max(1,O/P)));if(e.measures.lodLevel=Math.max(F,e.measures.lodLevel),e.measures.splitPriority+=e.measures.lodLevel-H,H<F){const i=+h(_,t[0])+ +h(_,t[1])+ +h(_,t[2])+ +h(_,t[3]);e.measures.splitPriority+=i}const V=q(b)/P;V>2.5&&(e.measures.splitPriority+=V)}get _isGlobal(){return this._renderCoordsHelper.viewingMode===p.Global}}const M=[l(),l(),l(),l()],y=l(),b=l(),g=l(),x=n(0,0,1),L=m(d,x),S=312,j=.5,w=2;export{v as FeatureTileMeasurements3D};
5
+ import{H as e,i as t,n as i,f as s,h as o,c as r,F as a}from"../../../../chunks/vec32.js";import{create as l,freeze as n,ZEROS as d}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{distance as c}from"../../../../geometry/support/aaBoundingRect.js";import{intersectsPoint as h}from"../../../../geometry/support/frustum.js";import{fromValues as m}from"../../../../geometry/support/ray.js";import{ViewingMode as p}from"../../../ViewingMode.js";import{FeatureTileVisibility3D as u,minTileLOD as _}from"./FeatureTileVisibility3D.js";import f from"../../webgl/RenderCamera.js";class v{constructor(e,t,i){this._renderCoordsHelper=e,this._tilingScheme=t,this._camera=new f,this._surfaceElevation=0,this._focusOnMap=[0,0],this._visibility=new u(e,i)}set opaqueGround(e){this._visibility.opaqueGround=e}setup(e,t,i){this._camera.copyFrom(e),this._surfaceElevation=i,this._focusOnMap[0]=t.x,this._focusOnMap[1]=t.y,this._visibility.setup(this._camera)}done(){this._visibility.done()}update(e){const{measures:t,extent:i,level:s}=e;t.visible=this._visibility.compute(e),t.distance=c(i,this._focusOnMap),t.mergeable=!0,t.lodLevel=_,t.splitPriority=Math.max(0,_-s),t.visible&&(this._isGlobal?this._updateSplitAndLodGlobal(e):this._updateSplitAndLodLocal(e))}_updateSplitAndLodGlobal(r){const a=r.level,l=this._renderCoordsHelper,{eye:n,fov:d}=this._camera,c=l.referenceEllipsoid.radius,h=e(n)-c;if(2*Math.atan(c/h)<d&&h>0)return void(r.measures.lodLevel=Math.max(a,_));const m=M,{extent:p}=r,{_surfaceElevation:u}=this;t(m[0],p[0],p[1],u),t(m[1],p[2],p[1],u),t(m[2],p[2],p[3],u),t(m[3],p[0],p[3],u);const f=t(y,.5*(p[0]+p[2]),.5*(p[1]+p[3]),u),v=this._tilingScheme.spatialReference;for(let e=0;e<4;++e)l.toRenderCoords(m[e],v,m[e]);l.toRenderCoords(f,v,f);const b=i(L.direction,f),x=s(n,b),S=o(g,b,x);this._updateSplitAndLod(r,m,f,S)}_updateSplitAndLodLocal(e){const i=M,{extent:s}=e,{_surfaceElevation:o}=this;t(i[0],s[0],s[1],o),t(i[1],s[2],s[1],o),t(i[2],s[2],s[3],o),t(i[3],s[0],s[3],o);const a=this._tilingScheme.spatialReference;for(let t=0;t<4;++t)this._renderCoordsHelper.toRenderCoords(i[t],a,i[t]);const l=t(y,.5*(i[0][0]+i[2][0]),.5*(i[0][1]+i[2][1]),.25*(i[0][2]+i[1][2]+i[2][2]+i[3][2])),n=t(b,l[0],l[1],0),{eye:d,far:c}=this._camera,h=t(g,n[0],n[1],d[2]);t(L.origin,n[0],n[1],d[2]-2*c),r(L.direction,x),this._updateSplitAndLod(e,i,l,h)}_updateSplitAndLod(e,t,i,o){const r=Math.max(a(t[0],t[2]),a(t[1],t[3]),a(t[0],i)+a(i,t[2]),a(t[1],i)+a(i,t[3])),{eye:l,near:n,fov:d,viewForward:c,width:m,height:p,pixelRatio:u,frustum:_}=this._camera,f=s(l,c),v=s(i,c)-f,M=a(i,l);let y=v,b=v,g=M,x=M;const L=(e,t)=>t<n?1:Math.sqrt(e*e-t*t)/t;let C=L(M,v);for(const h of t){const e=s(h,c)-f;y=Math.min(y,e),b=Math.max(b,e);const t=a(h,l);x=Math.max(x,t),g=Math.min(g,t);const i=L(t,e);C=Math.min(C,i)}if(b<n)return void(e.measures.lodLevel=0);const R=Math.cos(.5*d),A=a(l,o);C>R&&A>j*r&&(b=w*x,y=w*g);const G=.5*Math.sqrt(m*m+p*p)/u,E=2*Math.tan(.5*d),H=e=>Math.max(n,e)*S/G*E,q=e.level,F=r*2**q*Math.max(1,E),O=H(y),P=Math.ceil(Math.log2(Math.max(1,F/O)));if(e.measures.lodLevel=Math.max(P,e.measures.lodLevel),e.measures.splitPriority+=e.measures.lodLevel-q,q<P){const i=+h(_,t[0])+ +h(_,t[1])+ +h(_,t[2])+ +h(_,t[3]);e.measures.splitPriority+=i}const V=H(b)/O;V>2.5&&(e.measures.splitPriority+=V)}get _isGlobal(){return this._renderCoordsHelper.viewingMode===p.Global}}const M=[l(),l(),l(),l()],y=l(),b=l(),g=l(),x=n(0,0,1),L=m(d,x),S=312,j=.5,w=2;export{v as FeatureTileMeasurements3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{n as t,c as r,a as n,f as e,b as s,i as o,G as i,e as u,g as c,h as f,I as a}from"../../../../chunks/vec32.js";import{create as h,freeze as l,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as d}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBuffer as _}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as g}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as b}from"../../../../geometry/support/frustum.js";import{fromValues as M,signedDistance as F}from"../../../../geometry/support/plane.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{Frustum as S}from"../../state/Frustum.js";class G{constructor(t,r){this._renderCoordsHelper=t,this.opaqueGround=r,this._cache=new Map,this._cameraForward=h(),this._cameraEye=h(),this._cameraFovY=55*Math.PI/180,this._frustumBoundingSphereCenter=h(),this._frustumBoundingSphereRadius=0,this._frustum=new S(t),this._renderSR=t.spatialReference;const n=d(this._renderSR);this._renderSREllipsoidRadius=p(n).radius}setup(n){this._aboveGround=n.aboveGround,this._frustum.update(n),t(this._cameraForward,n.viewForward),r(this._cameraEye,n.eye),this._cameraFovY=n.fovY,this._updateFrustumBoundingSphere()}done(){this._cache.clear()}compute(t){if(this._cache.has(t.id))return this._cache.get(t.id);const r=this._isVisibleInFrustum(t);return this._cache.set(t.id,r),r}_isVisibleInFrustum(t){return this._renderCoordsHelper.viewingMode===R.Local?this._isTileVisibleInFrustumLocal(t):this._isTileVisibleInFrustumGlobal(t)}_updateFrustumBoundingSphere(){const r=this._frustum,o=r.origin,i=W;t(i,r.direction);const u=r.points,c=z;n(c,u[4],o);const f=.5*e(c,c)/e(i,c),a=this._frustumBoundingSphereCenter;s(a,o,i,f);const h=1+f;this._frustumBoundingSphereRadius=h}_isTileVisibleInFrustumLocal(t){const r=t.spatialReference,u=t.extent,c=this._renderSR;if(C[0]=u[0],C[1]=u[1],C[2]=0,C[3]=u[2],C[4]=u[3],C[5]=0,!_(C,r,0,C,c,0))return!1;o(P[0],C[0],C[1],0),o(P[1],C[3],C[1],0),o(P[2],C[3],C[4],0),o(P[3],C[0],C[4],0),o(k,.5*(C[0]+C[3]),.5*(C[1]+C[4]),.5*(C[2]+C[5]));const f=Gt,a=.5*i(P[0],P[2]),h=this._frustum,l=this._frustumBoundingSphereRadius,m=this._frustumBoundingSphereCenter,p=J;n(p,m,k);const d=e(f,p),g=D;s(g,k,f,d);if(i(g,m)>a+l)return!1;const b=this._cameraForward,M=e(b,Gt),F=this._cameraFovY,R=this._cameraEye;if(Math.abs(M)<Math.abs(Math.cos(.5*F))){let t=!0;const r=o(jt,b[0],b[1],0),n=e(R,r);for(let s=0;s<4;++s){const o=P[s];if(e(o,r)-n>0){t=!1;break}}if(t)return!1}{const t=P[0],r=P[2];if(t[0]<=R[0]&&R[0]<=r[0]&&t[1]<=R[1]&&R[1]<=r[1])return!0}const S=E,G=this.opaqueGround&&this._aboveGround,j=this.opaqueGround&&!this._aboveGround,v=Math.min(j?Mt:1/0,d+l),B=Math.max(G?-430:-1/0,d-l);for(let n=0;n<4;++n)s(S[n],P[n],f,v),s(S[n+4],P[n],f,B);if(w(h.planes,S,8))return!1;if(T(h.planes,S,8))return!0;for(let n=0;n<4;++n){const t=S[n],r=S[n+4];if(vt(h.planes,t,r))return!0;const e=S[(n+1)%4];if(vt(h.planes,t,e))return!0;const s=S[4+(n+1)%4];if(vt(h.planes,r,s))return!0}if(It[0][3]=+P[0][0],It[1][3]=-P[2][0],It[2][3]=+P[0][1],It[3][3]=-P[2][1],It[4][3]=+B,It[5][3]=-v,T(It,h.points))return!0;if(T(It,h.points))return!0;for(let n=0;n<4;++n){const t=R,r=h.points[n+4];if(Bt(It,t,r))return!0;const e=h.points[4+(n+1)%4];if(Bt(It,r,e))return!0}return!1}_isTileVisibleInFrustumGlobal(r){if(r.level<V)return!0;const l=r.spatialReference,m=r.extent,p=this.opaqueGround&&this._aboveGround,d=this.opaqueGround&&!this._aboveGround,_=P,b=.5*(m[0]+m[2]);if(o(_[0],m[0],m[1],0),o(_[1],m[2],m[1],0),o(_[2],m[2],m[3],0),o(_[3],m[0],m[3],0),o(_[4],b,m[1],0),o(_[5],b,m[3],0),!g(_,l,0,_,this._renderSR,0,6))return!1;const M=_[0][2]>0,R=_[3][2]<0,S=M||R,G=this._renderSREllipsoidRadius;if(S){const t=Y;j(t,wt,_[0]);const r=H;if(j(r,wt,_[1]),M){const n=L,e=_[4],s=O;j(s,e,wt),j(n,s,e);const o=_[0];u(o,t,n),B(o,G);const i=_[1];u(i,r,n),B(i,G)}else if(R){const n=L,e=_[5],s=O;j(s,e,wt),j(n,e,s);const o=_[3];u(o,n,t),B(o,G);const i=_[2];u(i,n,r),B(i,G)}}const y=k,I=n(Z,_[3],_[0]);t(I,I);const T=c($,_[0],_[3]);f(T,T,.5);const q=-e(T,I),E=c(tt,_[0],_[1]);f(E,E,.5);const C=c(rt,_[2],_[3]);f(C,C,.5);const W=n(nt,C,E);t(W,W);const z=-(q+e(I,E))/e(I,W);s(y,E,W,z),B(y,G);const D=this._frustumBoundingSphereRadius,J=this._frustumBoundingSphereCenter,ut=this._frustum,dt=ut.planes,_t=A;t(_t,y);const gt=e(_[0],_t)/a(_[0]),Gt=ut.origin,jt=ut.points;let vt=!1;if(p){{vt=!0;const r=t(Ft,Gt);for(let s=0;s<4;++s){const o=jt[4+s],i=n(h(),o,Gt);t(i,i);const c=u(h(),r,i);t(c,c);const f=u(h(),i,c);t(f,f);if(e(Gt,f)>G){vt=!1;break}}}if(vt){if(e(Gt,_t)<G*gt-Mt)return!1}const r=t(Ft,ut.origin);if(e(r,_t)<0)return!1;{const r=t(Rt,ut.direction);if(e(r,_t)>St)return!1}}const Bt=Math.sqrt(1-gt*gt);if(Bt>.9)return!0;let yt=!1;const It=e(_t,J),Tt=a(J);if(Tt<=D&&!dt.some((t=>F(t,K)>0))){if(!p)return!0;yt=!0}const Vt=It/Tt;if(!yt&&It<=0){if(-It>D)return!1}const qt=D/Tt;if(Math.sqrt(1-Vt*Vt)*Math.sqrt(1-qt*qt)-qt*Vt>Bt)return!1;if(!vt){if(_.some((t=>ut.intersectsPoint(t))))return!0;if(ut.intersectsPoint(y))return!0}const xt=N;n(xt,J,K);const Et=e(xt,_t),Ct=U;f(Ct,_t,Et);const Pt=i(Ct,J),kt=l.isWGS84,Lt=r.lij,Yt=kt&&Lt[2]===2**Lt[0]-1,Ht=kt&&0===Lt[2],Ot=Ht?lt:Yt?at:ct,At=Ht?mt:Yt?ht:ft;if(!yt){const t=_,r=pt,n=et,e=st,s=K;for(const o of Ot){const i=t[o];if(v(n,t[(o+1)%4],i),v(e,s,i),j(r,e,n),x(r,jt,1))return!1}}let Ut=null;if(!p&&Et<1.01*D){const t=2.5*D;if(Pt>gt*t+D)return!1;const r=X,n=t/gt;for(let e=0;e<4;++e)f(r[e],_[e],n/G);o(r[4],0,0,0),Ut=r}else{const t=(d?G+Mt:Et+D)/gt,r=p?G-Mt:(Et-D)/gt,n=Q;for(let e=0;e<4;++e){const s=_[e];f(n[e],s,r/G),f(n[e+4],s,t/G)}Ut=n}if(w(dt,Ut,Ut.length))return!1;const Wt=ut.lines,zt=ot,Dt=it;for(const e of Wt){t(Dt,e.direction);for(const r of At){const e=Ut[r];if(t(zt,e),bt(Dt,zt,Ut,jt))return!1;const s=(r+1)%4;if(p){const r=Ut[s];if(n(zt,r,e),t(zt,zt),bt(Dt,zt,Ut,jt))return!1}if(d){const e=Ut[4+r],o=Ut[4+s];if(n(zt,o,e),t(zt,zt),bt(Dt,zt,Ut,jt))return!1}}}return!0}}function j(r,n,e){return u(r,n,e),t(r,r),r}function v(r,e,s){return n(r,e,s),t(r,r),r}function B(t,r){return f(t,t,r/a(t)),t}const y=[b.LEFT,b.RIGHT,b.BOTTOM,b.TOP,b.FAR];function I(t,r,n){for(let e=0;e<n;++e)if(F(t,r[e])<=0)return!1;return!0}function w(t,r,n){for(const e of y)if(I(t[e],r,n))return!0;return!1}function T(t,r,n=r.length){for(let e=0;e<n;++e){const n=r[e];let s=!0;for(const r of t){if(F(r,n)>0){s=!1;break}}if(s)return!0}return!1}const V=2,q=4;function x(t,r,n){for(const s of r)if(e(s,t)<n)return!1;return!0}const E=[h(),h(),h(),h(),h(),h(),h(),h()],C=[0,0,0,0,0,0],P=[h(),h(),h(),h(),h(),h()],k=h(),L=h(),Y=h(),H=h(),O=h(),A=h(),U=h(),W=h(),z=h(),D=h(),J=h(),K=l(0,0,0),N=h(),Q=[h(),h(),h(),h(),h(),h(),h(),h()],X=[h(),h(),h(),h(),h()],Z=h(),$=h(),tt=h(),rt=h(),nt=h(),et=h(),st=h(),ot=h(),it=h(),ut=h(),ct=[0,1,2,3],ft=[0,1,2,3],at=[0,1,3],ht=[0,1,3],lt=[1,2,3],mt=[1,2,3],pt=h();function dt(t,r,n){let s=1/0,o=-1/0;for(const i of n){const t=e(r,i);s=Math.min(s,t),o=Math.max(o,t)}t[0]=s,t[1]=o}function _t(t,r,n,s){let o=1/0,i=-1/0;for(const u of s){const s=e(n,u);if(o=Math.min(o,s),i=Math.max(i,s),o<=r&&i>=t)return!1}return!0}const gt=[0,0];function bt(t,r,n,e){if(0===n.length||0===e.length)return!0;const s=ut;j(s,t,r);const o=e[0]<n[0],i=o?n:e,u=gt;return dt(u,s,o?e:n),_t(u[0],u[1],s,i)}const Mt=430,Ft=h(),Rt=h(),St=Math.cos(.25*Math.PI),Gt=m(0,0,1),jt=h();function vt(t,r,n){const e={t0:0,t1:1};for(const s of y){if(!yt(t[s],r,n,e))return!1}return e.t0<e.t1}function Bt(t,r,n){const e={t0:0,t1:1};for(const s of t){if(!yt(s,r,n,e))return!1}return e.t0<e.t1}function yt(t,r,n,e){let{t0:s,t1:o}=e;const i=F(t,r),u=F(t,n);if(i>=0&&u>=0)return!1;if(i<0&&u>=0){const t=-i/(u-i);if(t<s)return!1;t<o&&(o=t)}else if(i>=0&&u<0){const t=i/(i-u);if(t>o)return!1;t>s&&(s=t)}return e.t0=s,e.t1=o,!0}const It=[M(-1,0,0,1),M(1,0,0,-1),M(0,-1,0,1),M(0,1,0,-1),M(0,0,-1,1),M(0,0,1,-1)],wt=l(0,0,1);export{G as FeatureTileVisibility3D,T as isAnyVertexInPolyhedron,w as isConvexHullOutsideOfFrustum,q as maxLODLevelDelta,V as minTileLOD};
5
+ import{n as t,c as r,a as n,f as e,b as s,i as o,F as i,e as u,g as c,h as f,H as a}from"../../../../chunks/vec32.js";import{create as h,freeze as l,fromValues as m}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getReferenceEllipsoid as p}from"../../../../geometry/ellipsoidUtils.js";import{getSphericalPCPF as d}from"../../../../geometry/spatialReferenceEllipsoidUtils.js";import{projectBuffer as _}from"../../../../geometry/projection/projectBuffer.js";import{projectVec3Array as g}from"../../../../geometry/projection/projectVec3Array.js";import{PlaneIndex as b}from"../../../../geometry/support/frustum.js";import{fromValues as F,signedDistance as M}from"../../../../geometry/support/plane.js";import{ViewingMode as R}from"../../../ViewingMode.js";import{Frustum as S}from"../../state/Frustum.js";class j{constructor(t,r){this._renderCoordsHelper=t,this.opaqueGround=r,this._cache=new Map,this._cameraForward=h(),this._cameraEye=h(),this._cameraFovY=55*Math.PI/180,this._frustumBoundingSphereCenter=h(),this._frustumBoundingSphereRadius=0,this._frustum=new S(t),this._renderSR=t.spatialReference;const n=d(this._renderSR);this._renderSREllipsoidRadius=p(n).radius}setup(n){this._aboveGround=n.aboveGround,this._frustum.update(n),t(this._cameraForward,n.viewForward),r(this._cameraEye,n.eye),this._cameraFovY=n.fovY,this._updateFrustumBoundingSphere()}done(){this._cache.clear()}compute(t){if(this._cache.has(t.id))return this._cache.get(t.id);const r=this._isVisibleInFrustum(t);return this._cache.set(t.id,r),r}_isVisibleInFrustum(t){return this._renderCoordsHelper.viewingMode===R.Local?this._isTileVisibleInFrustumLocal(t):this._isTileVisibleInFrustumGlobal(t)}_updateFrustumBoundingSphere(){const r=this._frustum,o=r.origin,i=W;t(i,r.direction);const u=r.points,c=z;n(c,u[4],o);const f=.5*e(c,c)/e(i,c),a=this._frustumBoundingSphereCenter;s(a,o,i,f);const h=1+f;this._frustumBoundingSphereRadius=h}_isTileVisibleInFrustumLocal(t){const r=t.spatialReference,u=t.extent,c=this._renderSR;if(C[0]=u[0],C[1]=u[1],C[2]=0,C[3]=u[2],C[4]=u[3],C[5]=0,!_(C,r,0,C,c,0))return!1;o(P[0],C[0],C[1],0),o(P[1],C[3],C[1],0),o(P[2],C[3],C[4],0),o(P[3],C[0],C[4],0),o(k,.5*(C[0]+C[3]),.5*(C[1]+C[4]),.5*(C[2]+C[5]));const f=jt,a=.5*i(P[0],P[2]),h=this._frustum,l=this._frustumBoundingSphereRadius,m=this._frustumBoundingSphereCenter,p=J;n(p,m,k);const d=e(f,p),g=D;s(g,k,f,d);if(i(g,m)>a+l)return!1;const b=this._cameraForward,F=e(b,jt),M=this._cameraFovY,R=this._cameraEye;if(Math.abs(F)<Math.abs(Math.cos(.5*M))){let t=!0;const r=o(vt,b[0],b[1],0),n=e(R,r);for(let s=0;s<4;++s){const o=P[s];if(e(o,r)-n>0){t=!1;break}}if(t)return!1}{const t=P[0],r=P[2];if(t[0]<=R[0]&&R[0]<=r[0]&&t[1]<=R[1]&&R[1]<=r[1])return!0}const S=E,j=this.opaqueGround&&this._aboveGround,v=this.opaqueGround&&!this._aboveGround,G=Math.min(v?Ft:1/0,d+l),B=Math.max(j?-430:-1/0,d-l);for(let n=0;n<4;++n)s(S[n],P[n],f,G),s(S[n+4],P[n],f,B);if(I(h.planes,S,8))return!1;if(T(h.planes,S,8))return!0;for(let n=0;n<4;++n){const t=S[n],r=S[n+4];if(Gt(h.planes,t,r))return!0;const e=S[(n+1)%4];if(Gt(h.planes,t,e))return!0;const s=S[4+(n+1)%4];if(Gt(h.planes,r,s))return!0}if(wt[0][3]=+P[0][0],wt[1][3]=-P[2][0],wt[2][3]=+P[0][1],wt[3][3]=-P[2][1],wt[4][3]=+B,wt[5][3]=-G,T(wt,h.points))return!0;if(T(wt,h.points))return!0;for(let n=0;n<4;++n){const t=R,r=h.points[n+4];if(Bt(wt,t,r))return!0;const e=h.points[4+(n+1)%4];if(Bt(wt,r,e))return!0}return!1}_isTileVisibleInFrustumGlobal(r){if(r.level<V)return!0;const l=r.spatialReference,m=r.extent,p=this.opaqueGround&&this._aboveGround,d=this.opaqueGround&&!this._aboveGround,_=P,b=.5*(m[0]+m[2]);if(o(_[0],m[0],m[1],0),o(_[1],m[2],m[1],0),o(_[2],m[2],m[3],0),o(_[3],m[0],m[3],0),o(_[4],b,m[1],0),o(_[5],b,m[3],0),!g(_,l,0,_,this._renderSR,0,6))return!1;const F=_[0][2]>0,R=_[3][2]<0,S=F||R,j=this._renderSREllipsoidRadius;if(S){const t=L;v(t,It,_[0]);const r=Y;if(v(r,It,_[1]),F){const n=H,e=_[4],s=O;v(s,e,It),v(n,s,e);const o=_[0];u(o,t,n),B(o,j);const i=_[1];u(i,r,n),B(i,j)}else if(R){const n=H,e=_[5],s=O;v(s,e,It),v(n,e,s);const o=_[3];u(o,n,t),B(o,j);const i=_[2];u(i,n,r),B(i,j)}}const y=k,w=n(Z,_[3],_[0]);t(w,w);const T=c($,_[0],_[3]);f(T,T,.5);const q=-e(T,w),E=c(tt,_[0],_[1]);f(E,E,.5);const C=c(rt,_[2],_[3]);f(C,C,.5);const W=n(nt,C,E);t(W,W);const z=-(q+e(w,E))/e(w,W);s(y,E,W,z),B(y,j);const D=this._frustumBoundingSphereRadius,J=this._frustumBoundingSphereCenter,ut=this._frustum,dt=ut.planes,_t=A;t(_t,y);const gt=e(_[0],_t)/a(_[0]),jt=ut.origin,vt=ut.points;let Gt=!1;if(p){{Gt=!0;const r=t(Mt,jt);for(let s=0;s<4;++s){const o=vt[4+s],i=n(h(),o,jt);t(i,i);const c=u(h(),r,i);t(c,c);const f=u(h(),i,c);t(f,f);if(e(jt,f)>j){Gt=!1;break}}}if(Gt){if(e(jt,_t)<j*gt-Ft)return!1}const r=t(Mt,ut.origin);if(e(r,_t)<0)return!1;{const r=t(Rt,ut.direction);if(e(r,_t)>St)return!1}}const Bt=Math.sqrt(1-gt*gt);if(Bt>.9)return!0;let yt=!1;const wt=e(_t,J),Tt=a(J);if(Tt<=D&&!dt.some((t=>M(t,K)>0))){if(!p)return!0;yt=!0}const Vt=wt/Tt;if(!yt&&wt<=0){if(-wt>D)return!1}const qt=D/Tt;if(Math.sqrt(1-Vt*Vt)*Math.sqrt(1-qt*qt)-qt*Vt>Bt)return!1;if(!Gt){if(_.some((t=>ut.intersectsPoint(t))))return!0;if(ut.intersectsPoint(y))return!0}const xt=N;n(xt,J,K);const Et=e(xt,_t),Ct=U;f(Ct,_t,Et);const Pt=i(Ct,J),kt=l.isWGS84,Ht=r.lij,Lt=kt&&Ht[2]===2**Ht[0]-1,Yt=kt&&0===Ht[2],Ot=Yt?lt:Lt?at:ct,At=Yt?mt:Lt?ht:ft;if(!yt){const t=_,r=pt,n=et,e=st,s=K;for(const o of Ot){const i=t[o];if(G(n,t[(o+1)%4],i),G(e,s,i),v(r,e,n),x(r,vt,1))return!1}}let Ut=null;if(!p&&Et<1.01*D){const t=2.5*D;if(Pt>gt*t+D)return!1;const r=X,n=t/gt;for(let e=0;e<4;++e)f(r[e],_[e],n/j);o(r[4],0,0,0),Ut=r}else{const t=(d?j+Ft:Et+D)/gt,r=p?j-Ft:(Et-D)/gt,n=Q;for(let e=0;e<4;++e){const s=_[e];f(n[e],s,r/j),f(n[e+4],s,t/j)}Ut=n}if(I(dt,Ut,Ut.length))return!1;const Wt=ut.lines,zt=ot,Dt=it;for(const e of Wt){t(Dt,e.direction);for(const r of At){const e=Ut[r];if(t(zt,e),bt(Dt,zt,Ut,vt))return!1;const s=(r+1)%4;if(p){const r=Ut[s];if(n(zt,r,e),t(zt,zt),bt(Dt,zt,Ut,vt))return!1}if(d){const e=Ut[4+r],o=Ut[4+s];if(n(zt,o,e),t(zt,zt),bt(Dt,zt,Ut,vt))return!1}}}return!0}}function v(r,n,e){return u(r,n,e),t(r,r),r}function G(r,e,s){return n(r,e,s),t(r,r),r}function B(t,r){return f(t,t,r/a(t)),t}const y=[b.LEFT,b.RIGHT,b.BOTTOM,b.TOP,b.FAR];function w(t,r,n){for(let e=0;e<n;++e)if(M(t,r[e])<=0)return!1;return!0}function I(t,r,n){for(const e of y)if(w(t[e],r,n))return!0;return!1}function T(t,r,n=r.length){for(let e=0;e<n;++e){const n=r[e];let s=!0;for(const r of t){if(M(r,n)>0){s=!1;break}}if(s)return!0}return!1}const V=2,q=4;function x(t,r,n){for(const s of r)if(e(s,t)<n)return!1;return!0}const E=[h(),h(),h(),h(),h(),h(),h(),h()],C=[0,0,0,0,0,0],P=[h(),h(),h(),h(),h(),h()],k=h(),H=h(),L=h(),Y=h(),O=h(),A=h(),U=h(),W=h(),z=h(),D=h(),J=h(),K=l(0,0,0),N=h(),Q=[h(),h(),h(),h(),h(),h(),h(),h()],X=[h(),h(),h(),h(),h()],Z=h(),$=h(),tt=h(),rt=h(),nt=h(),et=h(),st=h(),ot=h(),it=h(),ut=h(),ct=[0,1,2,3],ft=[0,1,2,3],at=[0,1,3],ht=[0,1,3],lt=[1,2,3],mt=[1,2,3],pt=h();function dt(t,r,n){let s=1/0,o=-1/0;for(const i of n){const t=e(r,i);s=Math.min(s,t),o=Math.max(o,t)}t[0]=s,t[1]=o}function _t(t,r,n,s){let o=1/0,i=-1/0;for(const u of s){const s=e(n,u);if(o=Math.min(o,s),i=Math.max(i,s),o<=r&&i>=t)return!1}return!0}const gt=[0,0];function bt(t,r,n,e){const s=n.length,o=e.length;if(0===s||0===o)return!0;const i=ut;v(i,t,r);const u=o<s,c=u?n:e,f=gt;return dt(f,i,u?e:n),_t(f[0],f[1],i,c)}const Ft=430,Mt=h(),Rt=h(),St=Math.cos(.25*Math.PI),jt=m(0,0,1),vt=h();function Gt(t,r,n){const e={t0:0,t1:1};for(const s of y){if(!yt(t[s],r,n,e))return!1}return e.t0<e.t1}function Bt(t,r,n){const e={t0:0,t1:1};for(const s of t){if(!yt(s,r,n,e))return!1}return e.t0<e.t1}function yt(t,r,n,e){let{t0:s,t1:o}=e;const i=M(t,r),u=M(t,n);if(i>=0&&u>=0)return!1;if(i<0&&u>=0){const t=-i/(u-i);if(t<s)return!1;t<o&&(o=t)}else if(i>=0&&u<0){const t=i/(i-u);if(t>o)return!1;t>s&&(s=t)}return e.t0=s,e.t1=o,!0}const wt=[F(-1,0,0,1),F(1,0,0,-1),F(0,-1,0,1),F(0,1,0,-1),F(0,0,-1,1),F(0,0,1,-1)],It=l(0,0,1);export{j as FeatureTileVisibility3D,T as isAnyVertexInPolyhedron,I as isConvexHullOutsideOfFrustum,q as maxLODLevelDelta,V as minTileLOD};