@arcgis/core 5.0.0-next.86 → 5.0.0-next.87

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 (290) hide show
  1. package/Ground.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/analysis/VolumeMeasurement/VolumeMeasurementDisplayUnits.d.ts +14 -2
  4. package/analysis/VolumeMeasurement/VolumeMeasurementDisplayUnits.js +1 -1
  5. package/applications/Components/OrientedImageryViewer/galleryUtils.d.ts +80 -0
  6. package/applications/Components/OrientedImageryViewer/galleryUtils.js +5 -0
  7. package/applications/Components/clipboard.d.ts +106 -0
  8. package/applications/Components/clipboard.js +5 -0
  9. package/assets/esri/core/libs/libtess/libtess-f32.wasm +0 -0
  10. package/assets/esri/core/libs/libtess/libtess-f64.wasm +0 -0
  11. package/assets/esri/core/t9n/Units.json +1 -1
  12. package/assets/esri/core/workers/RemoteClient.js +1 -1
  13. package/assets/esri/core/workers/chunks/{6298e71e6c480d6f46e3.js → 0276e689e1371b40cff3.js} +1 -1
  14. package/assets/esri/core/workers/chunks/045a9cc900bb4ac8afde.js +1 -0
  15. package/assets/esri/core/workers/chunks/048173088bbeb1f6b8b6.js +1 -0
  16. package/assets/esri/core/workers/chunks/0be8b9d9ef56c37e74c3.js +1 -0
  17. package/assets/esri/core/workers/chunks/0bef671165e64f90ac86.js +1 -0
  18. package/assets/esri/core/workers/chunks/0c025d2b0d3162b07feb.js +1 -0
  19. package/assets/esri/core/workers/chunks/0c4ed18d67dea0c99f01.js +1 -0
  20. package/assets/esri/core/workers/chunks/0e0208b87566f4470f1d.js +1 -0
  21. package/assets/esri/core/workers/chunks/{981f05b5ef6f9c3f7e8a.js → 0fc0fd7618ef25dd6b67.js} +1 -1
  22. package/assets/esri/core/workers/chunks/{f1e1666bede364c069fc.js → 15c180deb8d09127ad31.js} +1 -1
  23. package/assets/esri/core/workers/chunks/1616ee2f6dce0203f1d5.js +1 -0
  24. package/assets/esri/core/workers/chunks/21bb414cb0623ffad577.js +1 -0
  25. package/assets/esri/core/workers/chunks/21c84e014c73bd85f4a3.js +1 -0
  26. package/assets/esri/core/workers/chunks/262677294d8c653e2b0b.js +1 -0
  27. package/assets/esri/core/workers/chunks/{5139bbe8f94df01467c7.js → 28a6a59033baa44bafab.js} +1 -1
  28. package/assets/esri/core/workers/chunks/{c5d56b85d34026507902.js → 28c273f34ffde25cebc6.js} +1 -1
  29. package/assets/esri/core/workers/chunks/{b7e40118b4d645e9f8e1.js → 2a12026f1ca9e8900a8b.js} +1 -1
  30. package/assets/esri/core/workers/chunks/2bc9f407f89d554a43ce.js +1 -0
  31. package/assets/esri/core/workers/chunks/2f21c5ae4fbe85c2792b.js +1 -0
  32. package/assets/esri/core/workers/chunks/3332ee9727874953523c.js +1 -0
  33. package/assets/esri/core/workers/chunks/{c477b0ce55211339c4cb.js → 33f44cc192c72064b5b6.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{1cf27708d17a4de75b68.js → 3672125daca3df24c8ab.js} +1 -1
  35. package/assets/esri/core/workers/chunks/37a607f3835ec6f60834.js +1 -0
  36. package/assets/esri/core/workers/chunks/{3ebd4cdafa7682062447.js → 39dd80c184ac48f877f1.js} +1 -1
  37. package/assets/esri/core/workers/chunks/3a3adf9b6502ad698aea.js +1 -0
  38. package/assets/esri/core/workers/chunks/3b5f24bb824c95996308.js +1 -0
  39. package/assets/esri/core/workers/chunks/{4a857a7f5e00dfab2b44.js → 3c663035cf872b66cb98.js} +1 -1
  40. package/assets/esri/core/workers/chunks/{32b09ca094377a305881.js → 3d924488471601a17915.js} +1 -1
  41. package/assets/esri/core/workers/chunks/{743165f9bc4d85748a0d.js → 42b56932340b6d0bc712.js} +1 -1
  42. package/assets/esri/core/workers/chunks/4de93e9f91fd891ed96f.js +1 -0
  43. package/assets/esri/core/workers/chunks/4eb02a03956d1c9c77ee.js +1 -0
  44. package/assets/esri/core/workers/chunks/{15132d36e7ccbb3c009e.js → 555a252bdb87e340bd02.js} +1 -1
  45. package/assets/esri/core/workers/chunks/{5d791bfca20791d8e0af.js → 5670e430584f020a3530.js} +1 -1
  46. package/assets/esri/core/workers/chunks/{70df4331ed29d823bf38.js → 5b297353b058323f8080.js} +1 -1
  47. package/assets/esri/core/workers/chunks/5ef5dcca7c9b376f7f77.js +1 -0
  48. package/assets/esri/core/workers/chunks/{c12c095937b21e39ad3c.js → 614c63dae0158da0ed3d.js} +1 -1
  49. package/assets/esri/core/workers/chunks/{8f3abaabc61858e929a5.js → 641450da2680ae09b8e7.js} +1 -1
  50. package/assets/esri/core/workers/chunks/{8b575ac55bc396c0c477.js → 687677acc05b5e87effe.js} +1 -1
  51. package/assets/esri/core/workers/chunks/{1aee859eaffa54ef2515.js → 727321c615f35d708d46.js} +1 -1
  52. package/assets/esri/core/workers/chunks/782c24211daacb47b0b2.js +1 -0
  53. package/assets/esri/core/workers/chunks/79067e7d1ebc46afd775.js +1 -0
  54. package/assets/esri/core/workers/chunks/7a454e4d6df3360e0ab9.js +1 -0
  55. package/assets/esri/core/workers/chunks/7da56ba34c81d2bbaf25.js +1 -0
  56. package/assets/esri/core/workers/chunks/{d8b72c6f5f9b2d013b7f.js → 824b45b04b4f4f91dbce.js} +1 -1
  57. package/assets/esri/core/workers/chunks/836d10ceb93ed19f0aa6.js +1 -0
  58. package/assets/esri/core/workers/chunks/{68d0bae1816061d96307.js → 837d39e70880e4310bda.js} +1 -1
  59. package/assets/esri/core/workers/chunks/8bcb2180ecc88a39b317.js +1 -0
  60. package/assets/esri/core/workers/chunks/{e95f90d59041640727da.js → 8c5d827cbf8869defb87.js} +1 -1
  61. package/assets/esri/core/workers/chunks/{7449af8f3637c1694660.js → 97155c8ac832d7c46f24.js} +1 -1
  62. package/assets/esri/core/workers/chunks/{fbf21fda283836e8633c.js → 98cb131b62e30aee35e1.js} +1 -1
  63. package/assets/esri/core/workers/chunks/{e067bbf12f711fd5b9a6.js → 9b3b9df0aa0fdcc77aa2.js} +1 -1
  64. package/assets/esri/core/workers/chunks/{5852d291ef41201030d5.js → 9fa1512baa6e95d3f878.js} +21 -21
  65. package/assets/esri/core/workers/chunks/{96616126aaf319cd1c6f.js → a5ed35f53769feb751db.js} +1 -1
  66. package/assets/esri/core/workers/chunks/{b6530c66804bede649d7.js → aa09e261d1f7dffaad8c.js} +1 -1
  67. package/assets/esri/core/workers/chunks/b268b4cbf5b0c856f88e.js +1 -0
  68. package/assets/esri/core/workers/chunks/b2f6cee006788ce3bd16.js +1 -0
  69. package/assets/esri/core/workers/chunks/{198ae9e02366870d3ec8.js → b46e772e415e2cfca896.js} +1 -1
  70. package/assets/esri/core/workers/chunks/{cee29c3a94376f6740d7.js → b4ab715a3c506e122f35.js} +1 -1
  71. package/assets/esri/core/workers/chunks/{b5ca894a6cb1a19676d5.js → b9756dce0b3af1a9dc54.js} +1 -1
  72. package/assets/esri/core/workers/chunks/baa7e90ec5259057d86b.js +1 -0
  73. package/assets/esri/core/workers/chunks/{52ae2073604deef63ea2.js → c083045d21636b95f26f.js} +1 -1
  74. package/assets/esri/core/workers/chunks/{5a0c5271304189a2401d.js → c38098f7073a10efdb1e.js} +1 -1
  75. package/assets/esri/core/workers/chunks/{adecd31fd64d6753682d.js → c7c865dc1a93e781a3e3.js} +1 -1
  76. package/assets/esri/core/workers/chunks/c8e56dc1239118ac2a60.js +1 -0
  77. package/assets/esri/core/workers/chunks/{e7e508258ad27468a6a5.js → cc6d9b2062b9de629111.js} +1 -1
  78. package/assets/esri/core/workers/chunks/d5386c0e77063c87fddd.js +1 -0
  79. package/assets/esri/core/workers/chunks/d782671235af2db1c458.js +1 -0
  80. package/assets/esri/core/workers/chunks/de33ce9b6f4e6c0e1389.js +1 -0
  81. package/assets/esri/core/workers/chunks/{0abb084b8a137f4fcdfc.js → e1c5773c12d9947bdc5f.js} +1 -1
  82. package/assets/esri/core/workers/chunks/e55ce8466aa979ac1e6b.js +1 -0
  83. package/assets/esri/core/workers/chunks/{21739c37160061f229ef.js → e585883d0036aa866420.js} +1 -1
  84. package/assets/esri/core/workers/chunks/e6d6d664fc9f2cd6a042.js +1 -0
  85. package/assets/esri/core/workers/chunks/e7cdc2a21104d84aec4a.js +1 -0
  86. package/assets/esri/core/workers/chunks/e9edf3987039def65859.js +1 -0
  87. package/assets/esri/core/workers/chunks/{3b434f318fdbbe4111e3.js → edbe52c2848486d64b16.js} +1 -1
  88. package/assets/esri/core/workers/chunks/{4f8895eb57ec6ab4b318.js → f5a61fa75ac877b5bb74.js} +1 -1
  89. package/assets/esri/core/workers/chunks/f9bc4edfdb1590be2d92.js +1 -0
  90. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  91. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  92. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  93. package/assets/esri/themes/base/widgets/_FeatureTable.scss +9 -1
  94. package/assets/esri/themes/dark/main.css +1 -1
  95. package/assets/esri/themes/light/main.css +1 -1
  96. package/assets/esri/themes/light/view.css +1 -1
  97. package/chunks/bundle.js +1 -1
  98. package/chunks/libtess-f32.js +1 -1
  99. package/chunks/libtess-f64.js +1 -1
  100. package/config.js +1 -1
  101. package/copyright.txt +84 -0
  102. package/core/Promise.d.ts +1 -1
  103. package/core/quantity.js +1 -1
  104. package/core/quantityFormatUtils.js +1 -1
  105. package/core/units.d.ts +1 -1
  106. package/core/units.js +1 -1
  107. package/core/workers/WorkerHandle.js +1 -1
  108. package/editing/Clipboard.js +5 -0
  109. package/geometry/ellipsoidUtils.js +1 -1
  110. package/geometry/libtess.js +1 -1
  111. package/geometry/projection/projectors.js +1 -1
  112. package/geometry/projectionUtils.js +1 -1
  113. package/geometry/support/meshUtils/projection.js +1 -1
  114. package/geometry/support/meshUtils/vertexSpaceConversion.js +1 -1
  115. package/geometry/support/planetGCSUtils.js +1 -1
  116. package/geometry/support/spatialReferenceUtils.js +1 -1
  117. package/identity/IdentityModal.js +1 -1
  118. package/kernel.js +1 -1
  119. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  120. package/layers/mixins/ArcGISImageService.d.ts +30 -16
  121. package/layers/mixins/ImageryTileMixin.d.ts +2 -1
  122. package/layers/mixins/ImageryTileMixin.js +1 -1
  123. package/layers/orientedImagery/transformations/utils.js +1 -1
  124. package/layers/raster/functions/SpectralConversionFunction.js +5 -0
  125. package/layers/raster/functions/SpectralConversionFunctionArguments.js +5 -0
  126. package/layers/raster/functions/conversionUtils.js +1 -1
  127. package/layers/raster/functions/rasterFunctionHelper.js +1 -1
  128. package/layers/raster/functions/vectorFieldUtils.js +1 -1
  129. package/layers/support/rasterFunctionUtils.d.ts +0 -4
  130. package/package.json +1 -1
  131. package/rest/imageService.d.ts +36 -19
  132. package/rest/imageService.js +1 -1
  133. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  134. package/smartMapping/support/adapters/FeatureLayerAdapter.js +1 -1
  135. package/support/revision.js +1 -1
  136. package/views/2d/engine/imagery/RasterVFContainer.js +1 -1
  137. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  138. package/views/2d/engine/imagery/RasterVFTileContainer.js +1 -1
  139. package/views/2d/engine/rasterBrushes.js +1 -1
  140. package/views/2d/engine/webgl/shaderGraph/techniques/raster/VectorFieldTechnique.js +5 -0
  141. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/AspectTechnique.js +1 -1
  142. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/BandArithmeticTechnique.js +1 -1
  143. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ColormapToRGBTechnique.js +1 -1
  144. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/CompositeBandTechnique.js +1 -1
  145. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ComputeChangeTechnique.js +1 -1
  146. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ContrastBrightnessTechnique.js +1 -1
  147. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ConvolutionTechnique.js +1 -1
  148. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/CurvatureTechnique.js +1 -1
  149. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ExtractBandTechnique.js +1 -1
  150. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/FocalStatisticsTechnique.js +1 -1
  151. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/GrayscaleTechnique.js +1 -1
  152. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/HillshadeTechnique.js +1 -1
  153. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/LocalTechnique.js +1 -1
  154. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/MaskTechnique.js +1 -1
  155. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/NDVITechnique.js +1 -1
  156. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/RemapTechnique.js +1 -1
  157. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ReprojectTechnique.js +1 -1
  158. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/ShadedReliefTechnique.js +1 -1
  159. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/SlopeTechnique.js +1 -1
  160. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/StretchTechnique.js +1 -1
  161. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/MagDirShader.js +5 -0
  162. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/ScalarShader.js +5 -0
  163. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  164. package/views/2d/layers/MediaLayerView2D.js +1 -1
  165. package/views/2d/layers/TileLayerView2D.js +1 -1
  166. package/views/2d/layers/imagery/ImageryVFStrategy.js +1 -1
  167. package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
  168. package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementVisualization.js +1 -1
  169. package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
  170. package/views/3d/analysis/AreaMeasurementAnalysisView3D.js +1 -1
  171. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
  172. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementRawResult.js +5 -0
  173. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementResult.d.ts +5 -1
  174. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementResult.js +1 -1
  175. package/views/3d/analysis/VolumeMeasurementAnalysisView3D.js +1 -1
  176. package/views/3d/environment/EnvironmentManager.js +1 -1
  177. package/views/3d/layers/FlowSubView3D.js +1 -1
  178. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  179. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  180. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  181. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  182. package/views/3d/layers/graphics/emissiveUtils.js +5 -0
  183. package/views/3d/layers/support/layerUtils.js +1 -1
  184. package/views/3d/support/mathUtils.js +1 -1
  185. package/views/3d/support/pointsOfInterest/StableSurfaceCenter.js +1 -1
  186. package/views/3d/support/supportedSpatialReference.js +1 -1
  187. package/views/3d/terrain/terrainUtils.js +1 -1
  188. package/views/3d/webgl-engine/core/shaderLibrary/util/EllipsoidMode.js +1 -1
  189. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  190. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +31 -23
  191. package/views/VideoView.js +1 -1
  192. package/views/input/ViewEvents.js +1 -1
  193. package/views/input/recognizers/VerticalTwoFingerDrag.js +1 -1
  194. package/views/input/types.d.ts +94 -0
  195. package/views/interactive/tooltip/components/DrawHeaderActions.js +1 -1
  196. package/views/support/MeasurementWorker.js +1 -1
  197. package/views/support/MeasurementWorkerHandle.js +1 -1
  198. package/views/support/measurementUtils.js +1 -1
  199. package/views/support/screenUtils.js +1 -1
  200. package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
  201. package/widgets/AreaMeasurement2D.d.ts +1 -0
  202. package/widgets/AreaMeasurement2D.js +1 -1
  203. package/widgets/BasemapLayerList.d.ts +1 -0
  204. package/widgets/BasemapLayerList.js +1 -1
  205. package/widgets/CatalogLayerList.d.ts +1 -0
  206. package/widgets/CatalogLayerList.js +1 -1
  207. package/widgets/Directions.d.ts +1 -0
  208. package/widgets/Directions.js +1 -1
  209. package/widgets/DistanceMeasurement2D.d.ts +1 -0
  210. package/widgets/DistanceMeasurement2D.js +1 -1
  211. package/widgets/Editor.d.ts +1 -0
  212. package/widgets/Editor.js +1 -1
  213. package/widgets/FeatureForm.d.ts +1 -0
  214. package/widgets/FeatureForm.js +1 -1
  215. package/widgets/FeatureTable.d.ts +1 -0
  216. package/widgets/FeatureTable.js +1 -1
  217. package/widgets/FloorFilter.d.ts +1 -0
  218. package/widgets/FloorFilter.js +1 -1
  219. package/widgets/LayerList.d.ts +1 -0
  220. package/widgets/LayerList.js +1 -1
  221. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  222. package/widgets/OrientedImageryViewer/adapters/sketch/DataCaptureAdapter.js +1 -1
  223. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  224. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  225. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  226. package/widgets/OrientedImageryViewer/components/ImageOverlays.js +1 -1
  227. package/widgets/OrientedImageryViewer/components/OverlayLayersListViewModel.js +1 -1
  228. package/widgets/OrientedImageryViewer/services/TransformationService.js +5 -0
  229. package/widgets/OrientedImageryViewer/support/dataCaptureUtils.js +5 -0
  230. package/widgets/OrientedImageryViewer/support/geometryUtils.js +5 -0
  231. package/widgets/OrientedImageryViewer/support/typeUtils.js +5 -0
  232. package/widgets/ScaleRangeSlider.d.ts +1 -0
  233. package/widgets/ScaleRangeSlider.js +1 -1
  234. package/widgets/Sketch.d.ts +1 -0
  235. package/widgets/Sketch.js +1 -1
  236. package/widgets/TableList.d.ts +1 -0
  237. package/widgets/TableList.js +1 -1
  238. package/widgets/TimeSlider.d.ts +1 -0
  239. package/widgets/TimeSlider.js +1 -1
  240. package/widgets/UtilityNetworkAssociations.d.ts +1 -0
  241. package/widgets/UtilityNetworkAssociations.js +1 -1
  242. package/widgets/UtilityNetworkTrace.d.ts +1 -0
  243. package/widgets/UtilityNetworkTrace.js +1 -1
  244. package/widgets/UtilityNetworkValidateTopology.d.ts +1 -0
  245. package/widgets/UtilityNetworkValidateTopology.js +1 -1
  246. package/widgets/ValuePicker.d.ts +1 -0
  247. package/widgets/ValuePicker.js +1 -1
  248. package/assets/esri/core/workers/chunks/00e135dc1b4cb024973d.js +0 -1
  249. package/assets/esri/core/workers/chunks/03d037f9f04f165aac63.js +0 -1
  250. package/assets/esri/core/workers/chunks/03da31c7635d077e8d99.js +0 -1
  251. package/assets/esri/core/workers/chunks/0dcf1f3b6aa84cbe03a9.js +0 -1
  252. package/assets/esri/core/workers/chunks/185c97bc63ce546995ce.js +0 -1
  253. package/assets/esri/core/workers/chunks/1a62c456e791c82050fe.js +0 -1
  254. package/assets/esri/core/workers/chunks/21163137e345badb1aaf.js +0 -1
  255. package/assets/esri/core/workers/chunks/25dead73dfc5a4c19285.js +0 -1
  256. package/assets/esri/core/workers/chunks/2767b69085c9f7a1e1af.js +0 -1
  257. package/assets/esri/core/workers/chunks/43e9eaedf65921b58eb2.js +0 -1
  258. package/assets/esri/core/workers/chunks/4caec60ac0a5851730c6.js +0 -1
  259. package/assets/esri/core/workers/chunks/5119e3159617b8e1ea13.js +0 -1
  260. package/assets/esri/core/workers/chunks/59d3f3fbae775fd7686e.js +0 -1
  261. package/assets/esri/core/workers/chunks/5a706eecd8a988fae6b7.js +0 -1
  262. package/assets/esri/core/workers/chunks/5ba2bbbb42ef1920579d.js +0 -1
  263. package/assets/esri/core/workers/chunks/5cc731f161012b63c77a.js +0 -1
  264. package/assets/esri/core/workers/chunks/5fa8fe6353dbdda0b06a.js +0 -1
  265. package/assets/esri/core/workers/chunks/6107b58457a70c8de9da.js +0 -1
  266. package/assets/esri/core/workers/chunks/654eef3ad30f34c42e12.js +0 -1
  267. package/assets/esri/core/workers/chunks/6d9e92d9c2503d5dc8dd.js +0 -1
  268. package/assets/esri/core/workers/chunks/7130b09300032d3a5925.js +0 -1
  269. package/assets/esri/core/workers/chunks/7f7c4ffbdf7b20dc7a54.js +0 -1
  270. package/assets/esri/core/workers/chunks/804c9666d0dc548b9f79.js +0 -1
  271. package/assets/esri/core/workers/chunks/8258b1c8ba6d44ba19c3.js +0 -1
  272. package/assets/esri/core/workers/chunks/8f2fc50eb988c0228b05.js +0 -1
  273. package/assets/esri/core/workers/chunks/97ad3eb25ad003c16148.js +0 -1
  274. package/assets/esri/core/workers/chunks/a270e34bb248114ec280.js +0 -1
  275. package/assets/esri/core/workers/chunks/a56a5e00964d4cd59a66.js +0 -1
  276. package/assets/esri/core/workers/chunks/a774b4fc7df801503bea.js +0 -1
  277. package/assets/esri/core/workers/chunks/b1015e1f25b60c08d2cf.js +0 -1
  278. package/assets/esri/core/workers/chunks/c18a2948ae3cb527d8bb.js +0 -1
  279. package/assets/esri/core/workers/chunks/d4f4c0201d8b641709c0.js +0 -1
  280. package/assets/esri/core/workers/chunks/d6d9d56b3733622deab6.js +0 -1
  281. package/assets/esri/core/workers/chunks/dedd9d47ccc019ffc484.js +0 -1
  282. package/assets/esri/core/workers/chunks/e271065410ba5c872f53.js +0 -1
  283. package/assets/esri/core/workers/chunks/e8a0654cebafa22b5b56.js +0 -1
  284. package/assets/esri/core/workers/chunks/ecf7d34b37ce6f0877af.js +0 -1
  285. package/assets/esri/core/workers/chunks/f25eb512592a84a508c1.js +0 -1
  286. package/assets/esri/core/workers/chunks/f64ec13167eb51da2f9b.js +0 -1
  287. package/views/2d/engine/imagery/BrushVectorField.js +0 -5
  288. package/views/3d/analysis/AreaMeasurement/support/utils.js +0 -5
  289. package/views/3d/analysis/VolumeMeasurement/volumeMeasurementUtils.js +0 -5
  290. package/widgets/OrientedImageryViewer/dataCaptureUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as y,sub as g,dot as _,add as v,length as w,transformMat3 as j,set as x}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,freeze as O,fromValues as M,clone as E,ZEROS as T}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as R,clone as U,fromValues as V}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as H,SphericalECEFSpatialReferenceLike as S}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as A}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as P}from"../../../geometry/projection/projectVectorToVector.js";import{create as k}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as I}from"../../../geometry/support/Indices.js";import{isCGCS2000 as F,isMoon as D,isMars as G}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec2f as B,BufferViewVec4f as z,BufferViewVec4u8 as N,BufferViewVec4u16 as W,BufferViewVec3f as $,BufferViewVec3u8 as q,BufferViewVec3u16 as Z,BufferViewInt16 as J,BufferViewUint32 as X,BufferViewUint16 as Y}from"../../../geometry/support/buffer/BufferView.js";import K from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as Q}from"../../../support/elevationInfoUtils.js";import{LayerView3D as ee}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as te}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ie,removeLayerViewFromWasm as se,getLyr3DWasm as re}from"./Lyr3DWasm.js";import{toWasmModification as oe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ne}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ae,alphaModeConversion as le,faceCullingConversion as de,wrapModeConversion as ce,lyr3DTypeToByteSize as he}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ue}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as me}from"../state/Frustum.js";import{ElevationRange as pe}from"../support/ElevationRange.js";import{toBoundingRect as be}from"../support/extentUtils.js";import{compute as fe,Obb as ye}from"../support/orientedBoundingBox.js";import{glLayout as ge}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as _e,createVertexBufferLayout as ve,ComponentGeometryParameters as we,SourceGeometry as je}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as xe}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ce}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as Oe}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ee}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Te}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as Re,writeBufferVec2 as Ue}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ve from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as He,isInEffectiveScaleRange as Se,validateScaleRange as Ae}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Le}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Pe}from"../../../webscene/support/AlphaCutoff.js";class ke{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=C();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this.obb?.center??T}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ie(e){return Math.round(e/1048.576)/1e3}let Fe=class extends(ee(Ve)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Le,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new me(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw He("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=ie(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ue(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new ne({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),se(this),this.layer.queryElevationCallback=null,this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=oe(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=k();this._layerClippingArea=be(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,Q(e))}get _wasm(){return re(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Se(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ae(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new te(this.usedMemory,r,o,Ie(t),Ie(e),Ie(s),Ie(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return Q(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new pe(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new pe;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantvisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantvisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||F(i)||D(i)||G(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=H(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=y(C(),n),d=500,c=Math.max(o[2],d),h=c+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=c>.5*r?.5*Math.PI*r:m,b=C();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;g(b,s,o);const r=_(b,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=O(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=p;if(this.view.state.isGlobal){const e=b();A(S,i,e,s),r=h(m(),e)}const o=C(),n=ze(t.desc.obb);let a=0;const l={textureMemoryUsage:0},d=new Array,c=new Map,f=t.desc.prims.length,y=new Array,g=new pe;try{const e=this.view.state.isGlobal,h=e?H(this.view.spatialReference).radius:0;for(let b=0;b<f;b++){const f=t.desc.prims[b];this._dbg(2,JSON.stringify(f));if(null==ae[f.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+f.ptype+"). Skipping primitive.");continue}const y=t.desc?.materials&&null!=f.materialId?t.desc.materials[f.materialId]:null,_=null!=y?y.lightingModel:"Unlit",{positionView:O,positionAttr:T,normalsView:H,normalsAttr:S,colorAttr:A,texCoord0Attr:k,indicesView:I}=this.getBufferViews(f,t.data.buffer,r);if(null==T||null==O||null==I)continue;const F=O.count,D=(e,t)=>!e||e.data.length/e.size===F||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(k,"numTexcoord")||!D(A,"numColors")||!D(S,"normals"))continue;const G=new _e(null!=A,null!=H,k?1:0),z=ve(G);for(let t=0;t<O.count;t++){O.getVec(t,o),v(o,o,i);const s=e?w(o)-h:o[2];g.expandElevationRangeValues(s,s)}const N=n?.clone()??Be(T,i);if(r!==p)for(let e=0;e<O.count;e++)O.getVec(e,o),j(o,o,r),O.setVec(e,o);const W=z.createBuffer(F);if(Re("position",T,null,null,W,0),null!=k){const e=W.getField("uv0",B);Ue(k,e,0)}null!=A&&Re("color",A,null,null,W,0),null!=S&&Re("normalCompressed",S,null,null,W,0);const $=new Uint32Array([0,I.typedBuffer.length]),q=new we(ge(z),this._shadeNormals||this.layer.replacesTerrain,G.textureCoordinateType),Z=new je({data:W.buffer,count:W.byteLength/z.stride},{positions:O.typedBuffer,indices:I.typedBuffer},I.typedBuffer,$,q),J=this.view.renderSpatialReference,X=C(),Y=[1,1,1];L(i,J,Y,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),P(i,J,X,s);let K=Promise.resolve(We),Q=R,ee=Pe,te=null,ie=null,se=null,re=null,oe=null,ne=1,ce=!1,he=2,ue=!1,me=M(0,0,0);const pe=E(Te),be="Pbr"===_;if(y){const e=e=>this._getTexture(e,t,c,l);te=e(y.baseColorTex),oe=be?e(y.metalTex):null,ie=be?e(y.emissiveTex):null,re=be?e(y.occlusionTex):null,se=be?e(y.normalTex):null;const i=[te,oe,ie,re,se].map(e=>e?.loadPromise??null);K=Promise.all(i),Q=U(y.baseColorFactor),ee=y.alphaCutoff??Pe,be&&(x(pe,y.metallicFactor,y.roughnessFactor,0),y.emissiveFactor&&(me=y.emissiveFactor)),ne=le[y.alphaMode],ce=y.isDoubleSided,he=de[y.faceCulling??"NotSet"],ue=this.layer.replacesTerrain}const fe=K.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}te||console.error("No colour texture 1");const e=r===p?p:u(m(),r)??p,t=this._collection.createObject({toMapSpace:V(X[0],X[1],Y[0],Y[1]),transform:new xe(i,e),obb:N,geometry:Z,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:Q,textureAlphaCutoff:ee,mrrFactors:pe,baseColorTexture:te,metallicRoughnessTexture:oe,normalTexture:se,occlusionTexture:re,emissionTexture:ie,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:ne,doubleSided:ce,cullFace:he,isGround:ue,emissiveBaseColor:me,usePBR:be,slicePlaneEnabled:this.slicePlaneEnabled,objectOpacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1,applySSAO:this._applySSAO});return l.textureMemoryUsage+=te?.texture?.usedMemory??0,be&&(l.textureMemoryUsage+=(oe?.texture?.usedMemory??0)+(ie?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(se?.texture?.usedMemory??0)),a+=this._collection.getObjectGPUMemoryUsage(t),t});d.push(fe)}if(y.push(...await Promise.all(d)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(G){throw c.forEach(e=>this._stage.removeTexture(e)),G}const _=y.map(e=>e()),T=new Array;c.forEach(e=>T.push(e));const{fullExtent:k}=this.layer;k?.hasZ&&k.zmax&&k.zmin&&(g.minElevation=Math.max(g.minElevation,k.zmin),g.maxElevation=Math.min(g.maxElevation,k.zmax));const I=_.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),F=new ke(e.handle,_,T,I,a,l.textureMemoryUsage,n,e.stableNodeId,e.nodeDepth,g);this._lyrHandleToObjects.set(e.handle,F),this._memCache.put(Ne(F.handle),F);const{usedMemory:D}=F;return this._cacheMemory+=D,{memUsageBytes:D}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ne(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ne(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ne(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=ce[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Me(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,b=m.byteOffset+m.byteCount,f=m.byteCount/he[m.type],y=I(f);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new $(t,m.byteOffset,p,b),r=new Oe(s.typedBuffer,y,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new $(t,m.byteOffset,p,b),s=Ee(e.typedBuffer,i);a=new J(s.buffer),l=new Oe(a.typedBuffer,y,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new Oe(new B(t,m.byteOffset,p,b).typedBuffer,y,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new z(t,m.byteOffset,p,b)),"U8"===m.type&&(c=new N(t,m.byteOffset,p,b)),"U16"===m.type&&(c=new W(t,m.byteOffset,p,b))):3===m.ncomp&&("F32"===m.type&&(c=new $(t,m.byteOffset,p,b)),"U8"===m.type&&(c=new q(t,m.byteOffset,p,b)),"U16"===m.type&&(c=new Z(t,m.byteOffset,p,b))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new Oe(c.typedBuffer,y,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new Y(t,i.byteOffset,s,r);break;case"U32":d=new X(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new Y(new Uint16Array(e).buffer):new X(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Fe.prototype,"fullOpacity",null),e([d({readOnly:!0})],Fe.prototype,"ready",null),e([d({type:[K]})],Fe.prototype,"_modifications",void 0),e([d()],Fe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Fe.prototype,"layer",void 0),e([d({readOnly:!0})],Fe.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Fe.prototype,"_collection",null),e([d()],Fe.prototype,"elevationOffset",null),e([d({readOnly:!0})],Fe.prototype,"visibleElevationRange",null),Fe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Fe);const De=Fe,Ge=C();function Be(e,t){const i=fe(e);return v(Ge,i.center,t),i.center=Ge,i}function ze(e){return e?new ye(e.center,e.halfSize,f(...e.quaternion)):null}function Ne(e){return`${e}`}const We=new Array;export{De as default};
5
+ import{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as s}from"../../../core/maybe.js";import{throwIfAborted as r}from"../../../core/promiseUtils.js";import{initial as o,watch as n,when as a}from"../../../core/reactiveUtils.js";import{schedule as l}from"../../../core/scheduling.js";import{property as d,subclass as c}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as u}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as m,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as b}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as f}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{normalize as y,sub as g,dot as _,add as v,length as w,transformMat3 as j,set as x}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as C,freeze as O,fromValues as M,clone as E,ZEROS as T}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as R,clone as U,fromValues as V}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMoon as H,isMars as S,getReferenceEllipsoid as A,SphericalECEFSpatialReferenceLike as L}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as P}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as k}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as I}from"../../../geometry/projection/projectVectorToVector.js";import{create as F}from"../../../geometry/support/aaBoundingRect.js";import{getContinuousIndexArray as D}from"../../../geometry/support/Indices.js";import{isCGCS2000 as G}from"../../../geometry/support/spatialReferenceUtils.js";import{BufferViewVec2f as B,BufferViewVec4f as z,BufferViewVec4u8 as N,BufferViewVec4u16 as W,BufferViewVec3f as $,BufferViewVec3u8 as q,BufferViewVec3u16 as Z,BufferViewInt16 as J,BufferViewUint32 as X,BufferViewUint16 as Y}from"../../../geometry/support/buffer/BufferView.js";import K from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as Q}from"../../../support/elevationInfoUtils.js";import{LayerView3D as ee}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as te}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as ie,removeLayerViewFromWasm as se,getLyr3DWasm as re}from"./Lyr3DWasm.js";import{toWasmModification as oe}from"./SceneLayerWorkerHandle.js";import{LayerElevationProvider as ne}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as ae,alphaModeConversion as le,faceCullingConversion as de,wrapModeConversion as ce,lyr3DTypeToByteSize as he}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as ue}from"./support/Tiles3DIntersectionHandler.js";import{Frustum as me}from"../state/Frustum.js";import{ElevationRange as pe}from"../support/ElevationRange.js";import{toBoundingRect as be}from"../support/extentUtils.js";import{compute as fe,Obb as ye}from"../support/orientedBoundingBox.js";import{glLayout as ge}from"../support/buffer/glUtil.js";import{VertexBufferLayoutCreationParameters as _e,createVertexBufferLayout as ve,ComponentGeometryParameters as we,SourceGeometry as je}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as xe}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as Ce}from"../webgl-engine/core/material/RenderTexture.js";import{Attribute as Oe}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as Me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as Ee}from"../webgl-engine/lib/Normals.js";import{advancedMRRFactors as Te}from"../webgl-engine/materials/pbrUtils.js";import{writeAttribute as Re,writeBufferVec2 as Ue}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import Ve from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as He,isInEffectiveScaleRange as Se,validateScaleRange as Ae}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as Le}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as Pe}from"../../../webscene/support/AlphaCutoff.js";class ke{constructor(e,t,i,s,r,o,n,a,l,d){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=s,this.vboMemoryUsage=r,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.nodeDepth=l,this.elevationRange=d,this.isLoaded=!1,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=C();n?.getCenter(c),this._obbCenterX=c[0],this._obbCenterY=c[1],this._obbCenterZ=c[2];const h=n?.radius??-1;this._obbRadius=h,this._obbRadiusSquared=h*h;const u=n?.halfSize;this._obbShortestHalfsize=u?Math.min(u[0],u[1],u[2]):0}get mbsRadius(){return this._obbRadius}get mbsCenter(){return this.obb?.center??T}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const{_obbCenterX:i,_obbCenterY:s,_obbCenterZ:r}=this,o=i-e[0],n=s-e[1],a=r-e[2],l=o*t[0]+n*t[1]+a*t[2];return o*o+n*n+a*a-l*l<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){const t=this._obbRadius;if(t<0)return!0;const i=e.center,s=e.radius,r=t+s,o=this._obbCenterX-i[0];if(o>r)return!1;const n=this._obbCenterY-i[1];if(n>r)return!1;const a=this._obbCenterZ-i[2];if(a>r)return!1;const l=o*o+n*n+a*a;if(l>r*r)return!1;if(l<=(this._obbShortestHalfsize+s)**2)return!0;return Math.sqrt(l)+t<=s||(this.obb?.intersectSphere(e)??!0)}}function Ie(e){return Math.round(e/1048.576)/1e3}let Fe=class extends(ee(Ve)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new Le,this._replacesTerrain=!1,this._isUsedAsGroundLayer=!1,this._modifications=new Array,this._visibleGeometryChangedSchedulerHandle=null,this._wasmLayerId=-1,this.ignoresMemoryFactor=!1,this._usedMemory=0,this._cacheMemory=0,this.drapeTargetType=1,this._applySSAO=!has("disable-feature:im-ssao"),this._shadeNormals=!!has("enable-feature:im-shading"),this._lyrHandleToObjects=new Map,this._visibleObjects=new Set,this._loadedObjects=new Set,this._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e)),this._frustum=new me(e.view.renderCoordsHelper)}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{r(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type&&e.replacesTerrain===this._replacesTerrain&&e.isUsedAsGroundLayer===this._isUsedAsGroundLayer}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._replacesTerrain=this.layer.replacesTerrain,this._isUsedAsGroundLayer=this.layer.isUsedAsGroundLayer,this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw He("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=ie(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new ue(this),e.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._slicePlaneEnabledChange(e)),this._updatingHandles.add(()=>this._modifications,()=>this._modificationsChanged(),o),this._updatingHandles.add(()=>this.fullOpacity,()=>this._opacityChange()),this._updatingHandles.add(()=>e.clippingArea,()=>this._clippingAreaChanged(),o),this._updatingHandles.add(()=>e.state.contentCamera,()=>this._cameraChanged(),o),this._elevationProvider=new ne({view:e,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),e.elevationProvider.register(1,this._elevationProvider),e.overlayManager.registerDrapeTarget(this),this.addHandles([n(()=>this.layer.elevationInfo,e=>this._elevationInfoChanged(e)),a(()=>this.fullOpacity,()=>this._opacityChange())]),this._suspendedHandle=n(()=>this.suspended,e=>this._wasm?.setEnabled(this,!e),o)});this.layer.queryElevationCallback=(e,t)=>this._wasm.queryElevation(this,e,t),this.addResolvingPromise(t)}get fullOpacity(){return this.layer.replacesTerrain&&has("enable-feature:oit-ground")?this.view.map.ground.opacity:1}_opacityChange(){const{fullOpacity:e}=this;this.forEachComponentObject(t=>this._collection.updateObjectOpacity(t,e))}_cameraChanged(){const e=this._frustum;e.update(this.view.state.contentCamera);const t=this._visibleObjects;let i=!1;this._loadedObjects.forEach(s=>{const r=s.obb?.intersectsFrustum(e)??!1;r!==s.isVisible&&(s.isVisible=r,r?t.add(s):t.delete(s),s.componentObjects.forEach(e=>this._collection.setObjectVisibility(e,r)),i||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(r,s.elevationRange))}),i&&this._setVisibleElevationRangeDirty()}intersect(e,t,i,s){this._intersectionHandler.intersect(e,t,i,s,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),se(this),this.layer.queryElevationCallback=null,this._suspendedHandle&&(this._suspendedHandle.remove(),this._suspendedHandle=null),this._intersectionHandler&&(this.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null),this._elevationProvider&&(this._elevationProvider.notifyObjectsChangedFunctional(e=>this.forEachComponentObject(t=>e(t.obb))),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this.view.overlayManager.unregisterDrapeTarget(this),this._lyrHandleToObjects.forEach(e=>this.freeObject(e)),this._lyrHandleToObjects.clear(),this._visibleObjects.clear(),this._loadedObjects.clear(),this._usedMemory=0,this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=s(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=oe(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=F();this._layerClippingArea=be(this.view.clippingArea,t,e)?t:null,this._modificationsChanged()}_visibleGeometryChanged(){this._visibleGeometryChangedSchedulerHandle??=l(()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null})}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e&&!this.layer.replacesTerrain),this.forEachComponentObject(t=>this._collection.updateMaterial(t,{slicePlaneEnabled:e}))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,Q(e))}get _wasm(){return re(this.view)}get wasmLayerId(){return this._wasmLayerId}get usedMemory(){return this._usedMemory}get unloadedMemory(){return 0}get cachedMemory(){return this._cacheMemory}get visibleAtCurrentScale(){return this.layer.isUsedAsGroundLayer||Se(this.layer.effectiveScaleRange,this.view.scale)}canResume(){const e=this.layer&&"effectiveScaleRange"in this.layer?this.layer.effectiveScaleRange:null;return this.visible&&this.layer?.loaded&&this.parent&&!this.parent.suspended&&this.view?.ready&&(this.layer.isUsedAsGroundLayer||Ae(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,s=0,r=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isLoaded?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,r++):(i+=n.textureMemoryUsage,s+=n.vboMemoryUsage,o++)}),new te(this.usedMemory,r,o,Ie(t),Ie(e),Ie(s),Ie(i))}_canProjectWithoutEngine(){if(this.view.state.isLocal){const e=this.view.renderSpatialReference?.isWebMercator?3857:this.view.renderSpatialReference?.wkid??-1;if(3857!==e&&32662!==e)return!1}return!0}get _stage(){return this.view.stage}get _collection(){return this._stage.renderView.componentObjectCollection}get elevationProvider(){return this._elevationProvider}get elevationOffset(){return Q(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new pe(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new pe;0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this._forEachRelevantvisibleTile(t=>e.expandElevationRange(t.elevationRange)),e.minElevation===1/0&&e.setElevationRangeValues(0,0));const t=this._get("visibleElevationRange");return t&&t.minElevation===e.minElevation&&t.maxElevation===e.maxElevation?t:e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}_forEachRelevantvisibleTile(e){const{view:t}=this,{spatialReference:i}=t,s=i.isWGS84||i.isWebMercator||G(i)||H(i)||S(i);if(this.view.state.isGlobal||!s)return this.forEachVisibleTile(e);const r=A(i).radius,{eye:o,viewForward:n,near:a}=t.state.camera,l=y(C(),n),d=500,c=Math.max(o[2],d),h=c+r,u=Math.sqrt(h**2-r**2),m=Math.abs(Math.atan2(u,r))*r,p=c>.5*r?.5*Math.PI*r:m,b=C();this.forEachVisibleTile(t=>{const{mbsRadius:i,mbsCenter:s}=t;if(i<0)return;g(b,s,o);const r=_(b,l);Math.abs(r)<p&&r+i>a&&r-i<p&&e(t)})}get fullExtent(){return this.layer.fullExtent}forEachComponentObject(e){this._forEachObject(this._lyrHandleToObjects.values(),e)}forEachVisibleTile(e){for(const t of this._visibleObjects)e(t)}forEachVisibleComponentObject(e){this._forEachObject(this._visibleObjects,e)}_forEachObject(e,t){for(const i of e)for(const e of i.componentObjects)t(e)}isUpdating(){const e=this._wasm;return this._wasmLayerId>=0&&null!=e&&(e.isUpdating(this._wasmLayerId)||this._compressionTracker.compressing)}updatingFlagChanged(){this.notifyChange("updating")}async createRenderable(e){if(this.destroyed){const e=`IntegratedMesh3DTilesLayerView3D[${this.layer?.title}]: createRenderable called on destroyed instance`;throw new Error(e)}const{meshData:t}=e;if(null==t.data)throw new Error("meshData.data undefined");if(t.desc=JSON.parse(t.desc),null==t.desc)throw new Error("meshData.desc undefined");const i=O(...t.desc.origin),s=this.view.basemapTerrain.spatialReference;let r=p;if(this.view.state.isGlobal){const e=b();P(L,i,e,s),r=h(m(),e)}const o=C(),n=ze(t.desc.obb);let a=0;const l={textureMemoryUsage:0},d=new Array,c=new Map,f=t.desc.prims.length,y=new Array,g=new pe;try{const e=this.view.state.isGlobal,h=e?A(this.view.spatialReference).radius:0;for(let b=0;b<f;b++){const f=t.desc.prims[b];this._dbg(2,JSON.stringify(f));if(null==ae[f.ptype]||null==t.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+f.ptype+"). Skipping primitive.");continue}const y=t.desc?.materials&&null!=f.materialId?t.desc.materials[f.materialId]:null,_=null!=y?y.lightingModel:"Unlit",{positionView:O,positionAttr:T,normalsView:H,normalsAttr:S,colorAttr:A,texCoord0Attr:L,indicesView:P}=this.getBufferViews(f,t.data.buffer,r);if(null==T||null==O||null==P)continue;const F=O.count,D=(e,t)=>!e||e.data.length/e.size===F||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!D(L,"numTexcoord")||!D(A,"numColors")||!D(S,"normals"))continue;const G=new _e(null!=A,null!=H,L?1:0),z=ve(G);for(let t=0;t<O.count;t++){O.getVec(t,o),v(o,o,i);const s=e?w(o)-h:o[2];g.expandElevationRangeValues(s,s)}const N=n?.clone()??Be(T,i);if(r!==p)for(let e=0;e<O.count;e++)O.getVec(e,o),j(o,o,r),O.setVec(e,o);const W=z.createBuffer(F);if(Re("position",T,null,null,W,0),null!=L){const e=W.getField("uv0",B);Ue(L,e,0)}null!=A&&Re("color",A,null,null,W,0),null!=S&&Re("normalCompressed",S,null,null,W,0);const $=new Uint32Array([0,P.typedBuffer.length]),q=new we(ge(z),this._shadeNormals||this.layer.replacesTerrain,G.textureCoordinateType),Z=new je({data:W.buffer,count:W.byteLength/z.stride},{positions:O.typedBuffer,indices:P.typedBuffer},P.typedBuffer,$,q),J=this.view.renderSpatialReference,X=C(),Y=[1,1,1];k(i,J,Y,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),I(i,J,X,s);let K=Promise.resolve(We),Q=R,ee=Pe,te=null,ie=null,se=null,re=null,oe=null,ne=1,ce=!1,he=2,ue=!1,me=M(0,0,0);const pe=E(Te),be="Pbr"===_;if(y){const e=e=>this._getTexture(e,t,c,l);te=e(y.baseColorTex),oe=be?e(y.metalTex):null,ie=be?e(y.emissiveTex):null,re=be?e(y.occlusionTex):null,se=be?e(y.normalTex):null;const i=[te,oe,ie,re,se].map(e=>e?.loadPromise??null);K=Promise.all(i),Q=U(y.baseColorFactor),ee=y.alphaCutoff??Pe,be&&(x(pe,y.metallicFactor,y.roughnessFactor,0),y.emissiveFactor&&(me=y.emissiveFactor)),ne=le[y.alphaMode],ce=y.isDoubleSided,he=de[y.faceCulling??"NotSet"],ue=this.layer.replacesTerrain}const fe=K.then(()=>()=>{if(this.destroyed){const e="Trying to add object to destroyed layer view";throw this._dbg(3,`${e} !== numPos. Skipping primitive.`),new Error(e)}te||console.error("No colour texture 1");const e=r===p?p:u(m(),r)??p,t=this._collection.createObject({toMapSpace:V(X[0],X[1],Y[0],Y[1]),transform:new xe(i,e),obb:N,geometry:Z,elevationAlignable:!1},{isIntegratedMesh:!0,baseColor:Q,textureAlphaCutoff:ee,mrrFactors:pe,baseColorTexture:te,metallicRoughnessTexture:oe,normalTexture:se,occlusionTexture:re,emissionTexture:ie,hasParametersFromSource:!1,sphereDepthInterpolate:this.layer.hasGoogleUrl,alphaDiscardMode:ne,doubleSided:ce,cullFace:he,isGround:ue,emissiveBaseColor:me,usePBR:be,slicePlaneEnabled:this.slicePlaneEnabled,objectOpacity:this.fullOpacity,polygonOffsetEnabled:!1,ellipsoidMode:1,applySSAO:this._applySSAO});return l.textureMemoryUsage+=te?.texture?.usedMemory??0,be&&(l.textureMemoryUsage+=(oe?.texture?.usedMemory??0)+(ie?.texture?.usedMemory??0)+(re?.texture?.usedMemory??0)+(se?.texture?.usedMemory??0)),a+=this._collection.getObjectGPUMemoryUsage(t),t});d.push(fe)}if(y.push(...await Promise.all(d)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(G){throw c.forEach(e=>this._stage.removeTexture(e)),G}const _=y.map(e=>e()),T=new Array;c.forEach(e=>T.push(e));const{fullExtent:H}=this.layer;H?.hasZ&&H.zmax&&H.zmin&&(g.minElevation=Math.max(g.minElevation,H.zmin),g.maxElevation=Math.min(g.maxElevation,H.zmax));const S=_.reduceRight((e,t)=>e+t.intersectionGeometry.usedMemory,0),F=new ke(e.handle,_,T,S,a,l.textureMemoryUsage,n,e.stableNodeId,e.nodeDepth,g);this._lyrHandleToObjects.set(e.handle,F),this._memCache.put(Ne(F.handle),F);const{usedMemory:D}=F;return this._cacheMemory+=D,{memUsageBytes:D}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t?(t.isLoaded?(this._loadedObjects.delete(t),this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e)):this._dbg(3,`freeRendedrable on non-existent renderable ${e}`)}freeObject(e){const t=Ne(e.handle);this._memCache.pop(t),e.textures.forEach(e=>this._stage.removeTexture(e)),e.componentObjects.forEach(e=>this._collection.destroyObject(e))}setRenderableVisibility(e,t,i){if(this.destroyed||this.destroying)return;const s=this._frustum,r=new Array;let o=!1,n=!1;for(let a=0;a<i;++a){if(!t[a])continue;const i=e[a],l=this._lyrHandleToObjects.get(i);if(l){if(l.isLoaded){this._dbg(3,`Already loaded object marked loaded again ${l.stableNodeId}`);continue}o=!0,l.isLoaded=!0,this._loadedObjects.add(l),this._usedMemory+=l.usedMemory,this._cacheMemory-=l.usedMemory;const e=l.obb?.intersectsFrustum(s)??!0;l.isVisible=e,e&&(this._visibleObjects.add(l),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(e,l.elevationRange)),e&&l.obb&&r.push(l.obb),l.componentObjects.forEach(t=>{this._collection.setObjectVisibility(t,e)}),this._memCache.pop(Ne(i))}else this._dbg(3,`Tried to mark Non existent object ${i} as loaded`)}for(let a=0;a<i;++a){const i=e[a];if(t[a])continue;const s=this._lyrHandleToObjects.get(i);if(s){if(!s.isLoaded){this._dbg(3,`Tried to unload not-loaded object ${s.stableNodeId}`);continue}const e=this._visibleObjects.delete(s);s.isVisible=!1,s.isLoaded=!1,this._loadedObjects.delete(s),e&&(this._visibleGeometryChanged(),n||=this._isVisibileElevationRangeModifiedByChangedTileVisbility(!1,s.elevationRange)),this._usedMemory-=s.usedMemory,this._cacheMemory+=s.usedMemory,e&&s.obb&&r.push(s.obb),s.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,!1)}),this._memCache.put(Ne(i),s)}else this._dbg(3,`Tried to mark Non existent object ${i} as not loaded`)}o&&this._visibleGeometryChanged(),this._elevationProvider.notifyObjectsChanged(r),n&&this._setVisibleElevationRangeDirty()}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_isVisibileElevationRangeModifiedByChangedTileVisbility(e,t){const{visibleElevationRange:i}=this,{minElevation:s,maxElevation:r}=t;return e?s<i.minElevation||r>i.maxElevation:s===i.minElevation||r===i.maxElevation}_getTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=i.get(r)??this._createTexture(e,t,i,s);return o?new Ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,s){const r=e&&t.desc?.images?.[e.imageId];if(!r||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!r.mipCount||a>1,d=ce[e.wrapMode??"None"];let c=r.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,r.data.byteOffset,r.data.byteCount);let u=null,m=null,p=null;switch(r.format){case"Raw":"R8"===r.pixelFormat?(u=h,c=6403,m=""):"Rgb8"===r.pixelFormat?(u=h,c=6407,m=""):"Rgba8"===r.pixelFormat&&(u=h,c=6408,m="");break;case"Dxt1":u=h,c=6407,m="image/vnd-ms.dds";break;case"Dxt5":u=h,c=6408,m="image/vnd-ms.dds";break;case"Basis":u=h,c=6407,m="image/ktx2";break;case"Png":m="image/png",p=document.createElement("img");break;case"Jpeg":m="image/jpeg",p=document.createElement("img");break;case"Etc2":m="image/ktx",p=document.createElement("img");break;case"Astc":this._dbg(3,"Astc texture not supported");break;case"Pvrtc":this._dbg(3,"Pvrtc texture not supported")}if(p&&m){const e=new Blob([h],{type:m});p.src=URL.createObjectURL(e),u=p}if(u&&null!=m){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(s.textureMemoryUsage-=e)}}:void 0,t=new Me(u,{mipmap:l,maxAnisotropy:a,encoding:m,wrap:d,pixelFormat:c,compressionOptions:e,noUnpackFlip:!0,width:r.mip0Width,height:r.mip0Height});return this._stage.addTexture(t),i.set(r,t),t}return null}getBufferViews(e,t,i){let s,r,o,n,a,l,d,c=null;for(let u=0;u<e.atrbs.length;u++){const d=e.atrbs[u],{view:m}=d,p=void 0,b=m.byteOffset+m.byteCount,f=m.byteCount/he[m.type],y=D(f);try{switch(d.sem){case"Position":3!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+m+")"):(s=new $(t,m.byteOffset,p,b),r=new Oe(s.typedBuffer,y,3));break;case"Normal":if(3!==m.ncomp||"F32"!==m.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+m+")");else{const e=new $(t,m.byteOffset,p,b),s=Ee(e.typedBuffer,i);a=new J(s.buffer),l=new Oe(a.typedBuffer,y,2)}break;case"TexCoord":2!==m.ncomp||"F32"!==m.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+m+")"):void 0===n&&(n=new Oe(new B(t,m.byteOffset,p,b).typedBuffer,y,2));break;case"Color":4===m.ncomp?("F32"===m.type&&(c=new z(t,m.byteOffset,p,b)),"U8"===m.type&&(c=new N(t,m.byteOffset,p,b)),"U16"===m.type&&(c=new W(t,m.byteOffset,p,b))):3===m.ncomp&&("F32"===m.type&&(c=new $(t,m.byteOffset,p,b)),"U8"===m.type&&(c=new q(t,m.byteOffset,p,b)),"U16"===m.type&&(c=new Z(t,m.byteOffset,p,b))),null==c?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+m+")"):o=new Oe(c.typedBuffer,y,m.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+d.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,s=void 0,r=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":d=new Y(t,i.byteOffset,s,r);break;case"U32":d=new X(t,i.byteOffset,s,r);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==d&&null!=s){const e=s.count;d=d=e<65535?new Y(new Uint16Array(e).buffer):new X(new Uint32Array(e).buffer);for(let t=0;t<e;t++)d.set(t,t)}return{positionView:s,positionAttr:r,colorAttr:o,texCoord0Attr:n,indicesView:d,normalsView:a,normalsAttr:l}}_loadModifications(){if(this.removeHandles("modifications"),null==this.layer.modifications)return void(this._modifications=[]);const e=this.layer.modifications;this.addHandles(this._updatingHandles.addOnCollectionChange(()=>e,()=>{this._modifications=e.filter(e=>!(this.layer.isUsedAsGroundLayer&&"replace"!==e.type)).toArray(),this._modifications.length<e.length&&t.getLogger(this).info("Ground layers only support replace modifications. Other modification types have been ignored.")},o),"modifications")}_deletePerObjectData(e){this._wasm?.onRenderableEvicted(this,e.handle,e.usedMemory),this.freeRenderable(e.handle)}_dbg(e,i){this._dbgFlags.has(e)&&(3===e?t.getLogger(this).error(i):t.getLogger(this).warn(i))}};e([d()],Fe.prototype,"fullOpacity",null),e([d({readOnly:!0})],Fe.prototype,"ready",null),e([d({type:[K]})],Fe.prototype,"_modifications",void 0),e([d()],Fe.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([d()],Fe.prototype,"layer",void 0),e([d({readOnly:!0})],Fe.prototype,"visibleAtCurrentScale",null),e([d({readOnly:!0})],Fe.prototype,"_collection",null),e([d()],Fe.prototype,"elevationOffset",null),e([d({readOnly:!0})],Fe.prototype,"visibleElevationRange",null),Fe=e([c("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Fe);const De=Fe,Ge=C();function Be(e,t){const i=fe(e);return v(Ge,i.center,t),i.center=Ge,i}function ze(e){return e?new ye(e.center,e.halfSize,f(...e.quaternion)):null}function Ne(e){return`${e}`}const We=new Array;export{De 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{clone as t}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as e}from"../../../../core/units.js";import{e as r}from"../../../../chunks/earcut.js";import{normalFromMat4 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 o,invertOrIdentity as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as l,sub as c,cross as m,add as p,normalize as h,transformMat4 as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ONES as g,create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as y}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as f,fromBuffer as b,intersectsClippingArea as _}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as x}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as j,getZeroIndexArray as S}from"../../../../geometry/support/Indices.js";import{t as w}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as P,SnappingCandidateEdge as v}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as C}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as E,SampleElevationInfo as A}from"./elevationAlignmentUtils.js";import{extrudePolygon as D}from"./extrudeUtils.js";import{Object3DEdgeState as I,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as z}from"./Graphics3DSymbolLayer.js";import{computeCentroid as M}from"./graphicUtils.js";import{geometryAsPolygon as O}from"./polygonUtils.js";import{createMaterial as L}from"../support/edgeUtils.js";import{encodeNaNUInt8 as G}from"../support/symbolColorUtils.js";import{debugFlags as V}from"../../support/debugFlags.js";import{SamplePosition as T}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as B}from"../../support/renderInfoUtils/polygon.js";import{Attribute as F}from"../../webgl-engine/lib/Attribute.js";import{Geometry as R}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as H}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as N,compressNormal as W}from"../../webgl-engine/lib/Normals.js";import{Object3D as k}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as q}from"../../webgl-engine/materials/DefaultMaterial.js";const Z=["polygon","extent"];class J extends z{constructor(t,e,r,s){super(t,e,r,s,$(e)),this.ensureDrapedStatus(!1)}async doLoad(){const t=this.symbolLayer,e=t?.material,r=this.symbolLayer.material?.color?.a,s=this.needsDrivenTransparentPass||null!=r&&1!==r,i=e?.emissive,o=!this._hasDrivenColorOrOpacity&&(null==r||0===r),n={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:g,diffuse:g,opacity:o?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:t.castShadows,emissiveStrengthFromSymbol:i?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},a=new q(n,this._context),l=new q({...n,cullFace:2},this._context);this._materials[0]=a,this._materials[1]=l,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,Z,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(t.renderingInfo,this._materialColor,!1);G(r,r);const s=this.createElevationContextForGraphic(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),t?.forEach(t=>e(t)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,E)}slicePlaneEnabledChanged(t,e){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t?.forEach(t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(t),this._materials[1]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?C(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?0:1}async queryForSnapping(r,s,i,o){const n=this._getExtrusionSize(i)*this._context.renderCoordsHelper.unitInMeters/e(s),{objectId:a,target:l}=r,c=t(l);switch(c.z=(c.z??0)+n,r.type){case"edge":{const{start:e,end:s}=r,i=t(e),o=t(s);return i.z=(i.z??0)+n,o.z=(o.z??0)+n,[new v(a,c,1/0,i,o)]}case"vertex":return[new P(a,c,1/0),new v(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,n,l,c){const m=O(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some(t=>t.length>0))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=B(m,this._context.elevationProvider,this._context.renderCoordsHelper,l);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=M(m);if(null==h)return null;const d=new Array,g=new Array,S=f(),P=a(),v=u(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,v),y(m.spatialReference,[h.x,h.y,0],P,this._context.renderCoordsHelper.spatialReference);const A=a();o(A,P);const z=i();s(z,A);const{polygons:G,mapPositions:V,position:T}=p,F=new Map,R=this._materials[0];for(const s of G){const t=s.count;if(this._context.clippingExtent&&(b(s.mapPositions,S),!_(S,this._context.clippingExtent)))continue;const i=r(s.mapPositions,s.holeIndices,3);if(0===i.length)continue;const o=i.length,a=6*t,l=j(a+o),m=j(o),p=x(3*a),h=x(3*a),u=x(3*a),y=x(a),f=this._getExtrusionSize(e);D(T,V,i,s,p,u,h,y,l,m,f,v,C),w(p,p,A);const E=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),I=new at(p,u,N(h),y),U=K(R,l,l.length-m.length,I,n,E),z=t,M=t,O=2*s.count,L=new lt(z,M,O,o/3);Y(U,L,P),F.set(U,L),d.push(U,K(this._materials[1],m,0,I,n,E)),g.push(I.heights)}if(0===d.length)return null;const H=new k({geometries:d,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});H.transformation=P;const W=L(this.symbolLayer,{opacity:this._getLayerOpacity()}),q=W?new I(this._materials[0],W,this._context.slicePlaneEnabled):null,Z=new U(this,H,null,(t,e,r,s,i)=>X(t,e,r,s,i,g,F),l,q);return Z.alignedSampledElevation=p.sampledElevation,Z.needsElevationUpdates=E(l.mode),Z}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){const t=this._materials[0];t&&t.setParameters({cullFace:t.transparent?0:2})}}function K(t,e,r,s,i,o){const n=S(e.length),a=[["position",new F(s.positions,e,3,!0)],["normalCompressed",new F(s.normals,e,2,!0)],["symbolColor",new F(i,n,4,!0)]];return new R(t,a,s.elevation,0,o,r)}const Q=u();function X(t,e,r,s,i,o,c){const m=t.stageObject,p=m.geometries,h=p.length,g="absolute-height"!==e.mode;let u=0;const y=m.transformation,f=n(a(),y);for(let n=0;n<h;n+=2){const t=p[n];if(!H(t))continue;const e=t.getMutableAttribute("position").data,a=o[n/2],h=new T(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let o=0;o<b;o++){Q[0]=e[t],Q[1]=e[t+1],Q[2]=e[t+2],s(h,rt),g&&(x+=rt.sampledElevation),V.TESTS_DISABLE_OPTIMIZATIONS?(l(tt,h.array[h.offset],h.array[h.offset+1],rt.z+a[t/3]),null!=r&&i.toRenderCoords(tt,r,tt),d(tt,tt,f)):(l(tt,e[t],e[t+1],e[t+2]),d(tt,tt,y),i.setAltitude(tt,rt.z+a[t/3]),d(tt,tt,f)),e[t]=tt[0],e[t+1]=tt[1],e[t+2]=tt[2];const o=st/i.unitInMeters;(Math.abs(Q[0]-e[t])>=o||Math.abs(Q[1]-e[t+1])>=o||Math.abs(Q[2]-e[t+2])>=o)&&(_=!0),h.offset+=3,t+=3}}if(_){const e=c.get(t);e&&Y(t,e,y),m.geometryVertexAttributeUpdated(p[n],"normalCompressed"),t.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(p[n],"position"),p[n+1].invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(p[n+1],"position")}u+=x/b}return u/h}function Y(t,e,r){const s=t.getMutableAttribute("position"),i=t.getMutableAttribute("normalCompressed").data,o=s.data,n=t.attributes.get("position").indices,{topVertexStart:a,topVertexCount:g,topFaceStart:u,topFaceCount:y}=e,f=u+y,b=a+g,_=it,x=ot,j=nt,S=et,w=tt;l(w,0,0,0);const P=(t,e)=>{const s=3*t;l(e,o[s+0],o[s+1],o[s+2]),d(e,e,r)};for(let l=u;l<f;++l){const t=3*l;P(n[t+0],_[0]),P(n[t+1],_[1]),P(n[t+2],_[2]),c(x,_[1],_[0]),c(j,_[2],_[0]),m(S,x,j),p(w,w,S)}h(w,w);for(let l=a;l<b;++l){const t=w[0],e=w[1],r=w[2];W(i,l,t,e,r)}}function $(t){return 1===(t.material?.color?.a??0)}const tt=u(),et=u(),rt=new A,st=.01,it=[u(),u(),u()],ot=u(),nt=u();class at{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class lt{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{J as Graphics3DExtrudeSymbolLayer};
5
+ import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as t}from"../../../../core/units.js";import{e as r}from"../../../../chunks/earcut.js";import{normalFromMat4 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 o,invertOrIdentity as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as l,sub as c,cross as m,add as p,normalize as h,transformMat4 as d}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ONES as u,create as g}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as f}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as y,fromBuffer as b,intersectsClippingArea as _}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as x}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as S,getZeroIndexArray as j}from"../../../../geometry/support/Indices.js";import{t as v}from"../../../../chunks/vec3.js";import{SnappingCandidateVertex as P,SnappingCandidateEdge as w}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as C}from"../../../../renderers/support/renderingInfoUtils.js";import{needsElevationUpdates3D as E,SampleElevationInfo as A}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as D}from"./emissiveUtils.js";import{extrudePolygon as U}from"./extrudeUtils.js";import{Object3DEdgeState as I,Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as M}from"./Graphics3DSymbolLayer.js";import{computeCentroid as O}from"./graphicUtils.js";import{geometryAsPolygon as L}from"./polygonUtils.js";import{createMaterial as V}from"../support/edgeUtils.js";import{encodeNaNUInt8 as B}from"../support/symbolColorUtils.js";import{debugFlags as G}from"../../support/debugFlags.js";import{SamplePosition as T}from"../../support/ElevationProvider.js";import{polygonToRenderInfo as F}from"../../support/renderInfoUtils/polygon.js";import{Attribute as R}from"../../webgl-engine/lib/Attribute.js";import{Geometry as H}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as N}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as W,compressNormal as k}from"../../webgl-engine/lib/Normals.js";import{Object3D as q}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Z}from"../../webgl-engine/materials/DefaultMaterial.js";const J=["polygon","extent"];class K extends M{constructor(e,t,r,s){super(e,t,r,s,ee(t)),this.ensureDrapedStatus(!1)}async doLoad(){const e=this.symbolLayer,t=e?.material,r=this.symbolLayer.material?.color?.a,s=this.needsDrivenTransparentPass||null!=r&&1!==r,i=t?.emissive,o=!this._hasDrivenColorOrOpacity&&(null==r||0===r),n={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:u,diffuse:u,opacity:o?0:1,layerOpacity:this._getLayerOpacity(),drivenOpacity:s,hasSymbolColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:e.castShadows,emissiveStrengthFromSymbol:i?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1},a=new Z(n,this._context),l=new Z({...n,cullFace:2},this._context);this._materials[0]=a,this._materials[1]=l,this._updateTransparentDepedentMaterialParameters()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,J,this.symbolLayer.type))return null;const r=this._getDrivenUInt8ColorWithNaNSupport(e.renderingInfo,this._materialColor,!1);B(r,r);const s=this.createElevationContextForGraphic(t);return this._createAs3DShape(t,e.renderingInfo,r,s,t.uid)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:r}),this._materials[1]?.setParameters({layerOpacity:r}),this._updateTransparentDepedentMaterialParameters(),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,E)}slicePlaneEnabledChanged(e,t){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e?.forEach(e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicalBasedRenderingChanged(){const e={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(e),this._materials[1]?.setParameters(e),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?C(e.size,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?0:1}async queryForSnapping(r,s,i,o){const n=this._getExtrusionSize(i)*this._context.renderCoordsHelper.unitInMeters/t(s),{objectId:a,target:l}=r,c=e(l);switch(c.z=(c.z??0)+n,r.type){case"edge":{const{start:t,end:s}=r,i=e(t),o=e(s);return i.z=(i.z??0)+n,o.z=(o.z??0)+n,[new w(a,c,1/0,i,o)]}case"vertex":return[new P(a,c,1/0),new w(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,n,l,c){const m=L(e.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some(e=>e.length>0))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=F(m,this._context.elevationProvider,this._context.renderCoordsHelper,l);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=O(m);if(null==h)return null;const d=new Array,u=new Array,j=y(),P=a(),w=g(),C=1===this._context.renderCoordsHelper.viewingMode;C||this._context.renderCoordsHelper.worldUpAtPosition(null,w),f(m.spatialReference,[h.x,h.y,0],P,this._context.renderCoordsHelper.spatialReference);const A=a();o(A,P);const D=i();s(D,A);const{polygons:M,mapPositions:B,position:G}=p,T=new Map,R=this._materials[0];for(const s of M){const e=s.count;if(this._context.clippingExtent&&(b(s.mapPositions,j),!_(j,this._context.clippingExtent)))continue;const i=r(s.mapPositions,s.holeIndices,3);if(0===i.length)continue;const o=i.length,a=6*e,l=S(a+o),m=S(o),p=x(3*a),h=x(3*a),g=x(3*a),f=x(a),y=this._getExtrusionSize(t);U(G,B,i,s,p,g,h,f,l,m,y,w,C),v(p,p,A);const E=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),D=new le(p,g,W(h),f),I=Q(R,l,l.length-m.length,D,n,E),z=e,M=e,O=2*s.count,L=new ce(z,M,O,o/3);$(I,L,P),T.set(I,L),d.push(I,Q(this._materials[1],m,0,D,n,E)),u.push(D.heights)}if(0===d.length)return null;const H=new q({geometries:d,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});H.transformation=P;const N=V(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=N?new I(this._materials[0],N,this._context.slicePlaneEnabled):null,Z=new z(this,H,null,(e,t,r,s,i)=>Y(e,t,r,s,i,u,T),l,k);return Z.alignedSampledElevation=p.sampledElevation,Z.needsElevationUpdates=E(l.mode),Z}get _materialColor(){return this.symbolLayer.material?.color}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchEmissive(e,t)}_preparePatchEmissive(e,t){return D(e,t,e=>{this._materials.forEach(t=>t?.setParameters({emissiveStrengthFromSymbol:e??0}))},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_updateTransparentDepedentMaterialParameters(){const e=this._materials[0];e&&e.setParameters({cullFace:e.transparent?0:2})}}function Q(e,t,r,s,i,o){const n=j(t.length),a=[["position",new R(s.positions,t,3,!0)],["normalCompressed",new R(s.normals,t,2,!0)],["symbolColor",new R(i,n,4,!0)]];return new H(e,a,s.elevation,0,o,r)}const X=g();function Y(e,t,r,s,i,o,c){const m=e.stageObject,p=m.geometries,h=p.length,u="absolute-height"!==t.mode;let g=0;const f=m.transformation,y=n(a(),f);for(let n=0;n<h;n+=2){const e=p[n];if(!N(e))continue;const t=e.getMutableAttribute("position").data,a=o[n/2],h=new T(e.mapPositions),b=t.length/3;let _=!1,x=0;{let e=0;for(let o=0;o<b;o++){X[0]=t[e],X[1]=t[e+1],X[2]=t[e+2],s(h,se),u&&(x+=se.sampledElevation),G.TESTS_DISABLE_OPTIMIZATIONS?(l(te,h.array[h.offset],h.array[h.offset+1],se.z+a[e/3]),null!=r&&i.toRenderCoords(te,r,te),d(te,te,y)):(l(te,t[e],t[e+1],t[e+2]),d(te,te,f),i.setAltitude(te,se.z+a[e/3]),d(te,te,y)),t[e]=te[0],t[e+1]=te[1],t[e+2]=te[2];const o=ie/i.unitInMeters;(Math.abs(X[0]-t[e])>=o||Math.abs(X[1]-t[e+1])>=o||Math.abs(X[2]-t[e+2])>=o)&&(_=!0),h.offset+=3,e+=3}}if(_){const t=c.get(e);t&&$(e,t,f),m.geometryVertexAttributeUpdated(p[n],"normalCompressed"),e.invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(p[n],"position"),p[n+1].invalidateBoundingInfo(),m.geometryVertexAttributeUpdated(p[n+1],"position")}g+=x/b}return g/h}function $(e,t,r){const s=e.getMutableAttribute("position"),i=e.getMutableAttribute("normalCompressed").data,o=s.data,n=e.attributes.get("position").indices,{topVertexStart:a,topVertexCount:u,topFaceStart:g,topFaceCount:f}=t,y=g+f,b=a+u,_=oe,x=ne,S=ae,j=re,v=te;l(v,0,0,0);const P=(e,t)=>{const s=3*e;l(t,o[s+0],o[s+1],o[s+2]),d(t,t,r)};for(let l=g;l<y;++l){const e=3*l;P(n[e+0],_[0]),P(n[e+1],_[1]),P(n[e+2],_[2]),c(x,_[1],_[0]),c(S,_[2],_[0]),m(j,x,S),p(v,v,j)}h(v,v);for(let l=a;l<b;++l){const e=v[0],t=v[1],r=v[2];k(i,l,e,t,r)}}function ee(e){return 1===(e.material?.color?.a??0)}const te=g(),re=g(),se=new A,ie=.01,oe=[g(),g(),g()],ne=g(),ae=g();class le{constructor(e,t,r,s){this.positions=e,this.elevation=t,this.normals=r,this.heights=s}}class ce{constructor(e,t,r,s){this.topVertexStart=e,this.topVertexCount=t,this.topFaceStart=r,this.topFaceCount=s}}export{K as Graphics3DExtrudeSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as g,add as x,scale as _,transformMat4 as y,transformMat3 as T,normalize as b,scaleAndAdd as v,subtract as w,cross as C,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,fromValues as R,ONES as A,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,create as O,intersectsClippingArea as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ce}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ue}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as me,nanFallbackColor as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as de}from"./SymbolComplexity.js";import{hasEdges as ge,createMaterial as xe}from"../support/edgeUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as ye}from"../../webgl-engine/lib/Attribute.js";import{Geometry as Te}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as be}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as we}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Me,advancedMRRFactors as je,schematicMRRFactors as Re}from"../../webgl-engine/materials/pbrUtils.js";const Ae=["mesh"];class Pe extends me{constructor(e,t,r,o){super(e,t,r,o,We(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]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Ae,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=tt,{origin:i,transform:l}=r;if(!B(t,g(Je,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case 2:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=ge(this.symbolLayer)?2:0;return new de({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ke(n),p=ke(a),h=ze(s),d=ke(i),g=ze(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:p}=t.material,h=ke(n),d=ze(a),g=ke(i),x=ke(u),_=ze(m),y=ke(f),T=ze(p);o.uid=[o.uid,`mrm:${e}`,`mrr:${r}`,`mrt:${h}`,`mrtt:${d}`,`emuid:${g}`,`ems:${c}`,`etmuid:${x}`,`ett:${_}`,`otmuid:${y}`,`ott:${T}`].join(","),o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(m),o.occlusionTextureTransform=$e(p),o.metallicRoughnessTextureTransform=$e(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=He(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Ge(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new be(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(e,r){if(null!=e.colorTexture){const t=1!==r.textureAlphaMode,o=this._getInternalTexture(e.colorTexture,t,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}if(e.normalTexture&&(r.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){const o=e.emissiveColor?.toUnitRGB();r.emissiveBaseColor=R(t(o[0]),t(o[1]),t(o[2]))}e.emissiveStrength&&(r.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ne(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){const r=this._drivenProperties.color,o=this._drivenProperties.opacity;if(r)e.externalColor=S;else{const r=t??null;if(r){const t=r.toUnitRGBA();o&&(t[3]=1),e.externalColor=t}else e.externalColor=fe}e.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(Le(e)||null!=r&&r.a<1||o?.transparent||a),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return this._setInternalMaterialTextureParameters(i,l.material.parameters),l.material;const c={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},u=Me({normalTexture:i.normalTexture,metallicRoughnessTexture:i.metallicRoughnessTexture,metallicFactor:i.metallic,roughnessFactor:i.roughness,emissiveTexture:i.emissiveTexture,emissiveFactor:i.emissiveColor?.toUnitRGB(),occlusionTexture:i.occlusionTexture}),m={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:P,diffuse:A,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||c.isComponentTransparent};m.mrrFactors=u?Re:[i.metallic,i.roughness,je[2]],t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?0:2,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTextureAlphaMode(m,c),this._setInternalMaterialParameters(i,m,c);const f=new we(m,this._context);return c.material=f,this._materialInfoCache.set(i.uid,c),f}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_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?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)Ve(r,o,t,Ze),Oe(r,o,t,Je,Qe,Xe),x(Je,Je,Qe),x(Je,Je,Xe),_(Je,Je,1/3),y(Je,Je,c),s.push(...Je),T(Ze,Ze,u),b(Ze,Ze),v(Je,Je,Ze,n),s.push(...Je),l.push(l.length),l.push(l.length)}return s.length?new Te(this._debugFaceNormalMaterial,[["position",new ye(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Je,s[e+0],s[e+1],s[e+2]),y(Je,Je,p),m.push(...Je),g(Qe,l[r+0],l[r+1],l[r+2]),T(Qe,Qe,h),b(Qe,Qe),v(Je,Je,Qe,u),m.push(...Je),f.push(f.length),f.push(f.length)}}return m.length?new Te(o,[["position",new ye(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new ve({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=xe(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new ue(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ce(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=j(),r=g(nt,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=qe(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Ke[0]=a.x,Ke[1]=a.y,Ke[2]=a.z??0;const s=f();B(e.spatialReference,Ke,s,n),u(et,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,et);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&K(r,p,et),o&&h&&Z(o,h,et),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,rt),!V(rt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??ot,h=new Array;let d=!1;const g=m(Je,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Ie(e,m);if(0===t.length)continue;const o=Be(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new ye(n,t,3,!0)],["normal",new ye(o.normals,o.indices,3,!0)]];s&&u.push(["color",new ye(s,t,4,!0)]),i&&u.push(["symbolColor",new ye(i,G(t.length),4,!0)]),a&&u.push(["uv0",new ye(a,t,2,!0)]),c&&u.push(["tangent",new ye(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new Te(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Se{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ie(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 Ee(e,t,r,o);case"flat":return Ue(e,o);case"smooth":return Fe(e,o)}}function Ue(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Ve(e,t,n,Ze);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Se(r,o,!1)}function Ee(e,t,r,o){if(null==t)return Ue(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Ve(e,o,a,Ze);for(let e=0;e<3;e++){const r=3*o[a+e];Je[0]=t[r],Je[1]=t[r+1],Je[2]=t[r+2],M(Ze,Je)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Se(t,o,n)}function Fe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Ve(e,t,a,Ze);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:j(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Se(o,n,!1)}function Oe(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Ve(e,t,r,o){return Oe(e,t,r,Je,Qe,Xe),w(Qe,Qe,Je),w(Xe,Xe,Je),C(Je,Qe,Xe),b(o,Je),o}function $e(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function Ge(e="repeat"){if("string"==typeof e){const t=De(e);return{s:t,t}}return{s:De(e.horizontal),t:De(e.vertical)}}function De(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Le(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 Ne(e,t,r){t.diffuse=e.toUnitRGB(),t.opacity="opaque"===r.alphaMode?1:e.a}function He(e){return e.data??e.url}function ke(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function ze(e){const{offset:t,scale:r,rotation:o}=e??Ye;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function qe(e){return e.vertexAttributes.color}function We(e){return 1===(e.material?.color?.a??0)}const Ye=new H,Ke=j(),Je=j(),Qe=j(),Xe=j(),Ze=j(),et=f(),tt=f(),rt=O(),ot=[new L],nt=j();export{Pe as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as g,add as x,scale as _,transformMat4 as y,transformMat3 as T,normalize as b,scaleAndAdd as v,subtract as w,cross as C,dot as M}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{create as j,fromValues as R,ONES as A,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as F,create as O,intersectsClippingArea as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as Y}from"../../../../chunks/vec3.js";import{transformNormal as K,transformVectorENUPlateCarree as J,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as ce}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ue}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as me}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as fe,nanFallbackColor as pe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as he,MeshFastUpdateProcessor as de}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as ge}from"./SymbolComplexity.js";import{hasEdges as xe,createMaterial as _e}from"../support/edgeUtils.js";import{debugFlags as ye}from"../../support/debugFlags.js";import{Attribute as Te}from"../../webgl-engine/lib/Attribute.js";import{Geometry as be}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as ve}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as we}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Ce}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Me}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Re,schematicMRRFactors as Ae}from"../../webgl-engine/materials/pbrUtils.js";const Pe=["mesh"];class Se extends fe{constructor(e,t,r,o){super(e,t,r,o,Ye(t)),this._materialInfoCache=new he,this._fastUpdateProcessor=new de,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ye.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Me({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Me({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Me({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Pe,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=rt,{origin:i,transform:l}=r;if(!B(t,g(Qe,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case 2:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=xe(this.symbolLayer)?2:0;return new ge({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ze(n),p=ze(a),h=qe(s),d=ze(i),g=qe(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveStrength:c,emissiveTexture:u,emissiveTextureTransform:m,occlusionTexture:f,occlusionTextureTransform:p}=t.material,h=ze(n),d=qe(a),g=ze(i),x=ze(u),_=qe(m),y=ze(f),T=qe(p);o.uid=[o.uid,`mrm:${e}`,`mrr:${r}`,`mrt:${h}`,`mrtt:${d}`,`emuid:${g}`,`ems:${c}`,`etmuid:${x}`,`ett:${_}`,`otmuid:${y}`,`ott:${T}`].join(","),o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveStrength=c,o.emissiveTexture=u,o.occlusionTexture=f,o.colorTextureTransform=Ge(s),o.normalTextureTransform=Ge(l),o.emissiveTextureTransform=Ge(m),o.occlusionTextureTransform=Ge(p),o.metallicRoughnessTextureTransform=Ge(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=ke(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:De(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new ve(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(e,r){if(null!=e.colorTexture){const t=1!==r.textureAlphaMode,o=this._getInternalTexture(e.colorTexture,t,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}if(e.normalTexture&&(r.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){const o=e.emissiveColor?.toUnitRGB();r.emissiveBaseColor=R(t(o[0]),t(o[1]),t(o[2]))}e.emissiveStrength&&(r.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&He(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){const r=this._drivenProperties.color,o=this._drivenProperties.opacity;if(r)e.externalColor=S;else{const r=t??null;if(r){const t=r.toUnitRGBA();o&&(t[3]=1),e.externalColor=t}else e.externalColor=pe}e.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(Ne(e)||null!=r&&r.a<1||o?.transparent||a),i=this._materialProperties(e,t,s),l=this._materialInfoCache.byUid(i.uid);if(l)return this._setInternalMaterialTextureParameters(i,l.material.parameters),l.material;const c={uid:i.uid,material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},u=je({normalTexture:i.normalTexture,metallicRoughnessTexture:i.metallicRoughnessTexture,metallicFactor:i.metallic,roughnessFactor:i.roughness,emissiveTexture:i.emissiveTexture,emissiveFactor:i.emissiveColor?.toUnitRGB(),occlusionTexture:i.occlusionTexture}),m={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:P,diffuse:A,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||c.isComponentTransparent};m.mrrFactors=u?Ae:[i.metallic,i.roughness,Re[2]],t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?0:2,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTextureAlphaMode(m,c),this._setInternalMaterialParameters(i,m,c);const f=new Ce(m,this._context);return c.material=f,this._materialInfoCache.set(i.uid,c),f}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return ce(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)$e(r,o,t,et),Ve(r,o,t,Qe,Xe,Ze),x(Qe,Qe,Xe),x(Qe,Qe,Ze),_(Qe,Qe,1/3),y(Qe,Qe,c),s.push(...Qe),T(et,et,u),b(et,et),v(Qe,Qe,et,n),s.push(...Qe),l.push(l.length),l.push(l.length)}return s.length?new be(this._debugFaceNormalMaterial,[["position",new Te(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Qe,s[e+0],s[e+1],s[e+2]),y(Qe,Qe,p),m.push(...Qe),g(Xe,l[r+0],l[r+1],l[r+2]),T(Xe,Xe,h),b(Xe,Xe),v(Qe,Qe,Xe,u),m.push(...Qe),f.push(f.length),f.push(f.length)}}return m.length?new be(o,[["position",new Te(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(ye.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new we({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=_e(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new me(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ue(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=j(),r=g(at,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=K(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return J(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=We(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,s,n),u(tt,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,tt);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&K(r,p,tt),o&&h&&Z(o,h,tt),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(F(o,ot),!V(ot,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??nt,h=new Array;let d=!1;const g=m(Qe,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Be(e,m);if(0===t.length)continue;const o=Ue(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new Te(n,t,3,!0)],["normal",new Te(o.normals,o.indices,3,!0)]];s&&u.push(["color",new Te(s,t,4,!0)]),i&&u.push(["symbolColor",new Te(i,G(t.length),4,!0)]),a&&u.push(["uv0",new Te(a,t,2,!0)]),c&&u.push(["tangent",new Te(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new be(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Be(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Ee(e,o);case"smooth":return Oe(e,o)}}function Ee(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=$e(e,t,n,et);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Ee(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){$e(e,o,a,et);for(let e=0;e<3;e++){const r=3*o[a+e];Qe[0]=t[r],Qe[1]=t[r+1],Qe[2]=t[r+2],M(et,Qe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function Oe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=$e(e,t,a,et);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:j(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ve(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function $e(e,t,r,o){return Ve(e,t,r,Qe,Xe,Ze),w(Xe,Xe,Qe),w(Ze,Ze,Qe),C(Qe,Xe,Ze),b(o,Qe),o}function Ge(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function De(e="repeat"){if("string"==typeof e){const t=Le(e);return{s:t,t}}return{s:Le(e.horizontal),t:Le(e.vertical)}}function Le(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Ne(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function He(e,t,r){t.diffuse=e.toUnitRGB(),t.opacity="opaque"===r.alphaMode?1:e.a}function ke(e){return e.data??e.url}function ze(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function qe(e){const{offset:t,scale:r,rotation:o}=e??Ke;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function We(e){return e.vertexAttributes.color}function Ye(e){return 1===(e.material?.color?.a??0)}const Ke=new H,Je=j(),Qe=j(),Xe=j(),Ze=j(),et=j(),tt=f(),rt=f(),ot=O(),nt=[new L],at=j();export{Se 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/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{identity as s,scale as r,translate as i,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as n,negate as l,copy as c,multiply as h,add as d,set as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as p,ONES as u,create as f,ZEROS as y,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as g,ONES as b,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as x}from"../../../../geometry/projection/projectPointToVector.js";import{create as R,size as S,containsPoint as C,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as L}from"../../../../symbols/support/materialUtils.js";import{defaultObjectPrimitive as O}from"../../../../symbols/support/primitives.js";import{objectSymbolLayerPrimitiveBoundingBox as U,objectSymbolLayerSizeWithResourceSize as E}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as j,defaultSymbolLayerMemoryComplexity as T}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as G,SampleElevationInfo as z,evaluateElevationInfoAtPoint as D}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as V}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F,nanFallbackColor as A}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as I,computeObjectScale as k,computeObjectRotation as H}from"./graphicUtils.js";import{makeLodResources as M}from"./lodResourceUtils.js";import{fetch as W}from"./objectResourceUtils.js";import{placePointOnGeometry as N,extendPointGraphicElevationContext as q}from"./pointUtils.js";import{isValidPrimitive as $,primitiveLodResources as Z}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as J}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as K}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as Q,updateFastSymbolUpdatesState as X,ConvertOptions as Y,evaluateModelTransformScale as ee,evaluateModelTransform as te}from"../support/FastSymbolUpdates.js";import{VerticalOffsetParameters as se}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as re}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ie}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as ae}from"../../webgl-engine/materials/pbrUtils.js";class oe{constructor(e,t,s,r,i,a,o,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class ne extends F{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r,he(t)),this._resources=null,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=I(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&$(t?.primitive)?t.primitive:O;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await K(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.updateComplexity()}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(e,t){const s=this.symbolLayer,r=R(U(e)),i=p(S(r)),a=p(E(i,s)),o=n(a),l=!1,c=!1,h=s?.material,d={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:ae,ambient:u,diffuse:u,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:s.castShadows,emissiveStrengthFromSymbol:h?.emissive?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},m=!!d.usePBR,f=this.symbol;"point-3d"===f.type&&f.verticalOffset&&(d.verticalOffset=new se(f.verticalOffset),d.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(d.screenSizePerspective=this.view.screenSizePerspective.parameters),this._hasDrivenColorOrOpacity?d.externalColor=A:d.externalColor=this._materialColor?.toUnitRGBA()??g,this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(r,a,i,null)),d.instanced=!0,this._fastUpdates?(Object.assign(d,this._fastUpdates.materialParameters),d.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(d.instancedColor=!0);const y=new ie(d,this._context);y.setParameters({cullFace:de(y.transparent)});const _=Z(e,y);if(!_)throw new Error(`Unknown object symbol primitive: ${e}`);const b=await this._createStageResources(_,m,t),v=await this._createLodRenderer(_,t);return new oe(_,v,b,i,l,c,r,a,o,m)}async _createResourcesForUrl(e,s){const r={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),i.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(i.materialParameters.instancedColor=!0);const a=this.symbol;if("point-3d"===a.type&&a.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=a.verticalOffset;i.materialParameters.verticalOffset={screenLength:t(e),minWorldLength:s||0,maxWorldLength:null!=r?r:1/0},i.materialParameters.castShadows=!1}const o=this._context.physicalBasedRenderingEnabled;i.signal=s,i.usePBR=o,i.useEmissive=this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result,i.skipHighLods=this._context.skipHighSymbolLods;const l=this.symbolLayer.material;i.materialParameters.emissiveStrengthFromSymbol=l?.emissive?.strength??1,i.materialParameters.emissiveSource=L(l?.emissive?.source??"emissive");const c=await W(e,i),h=c.isEsriSymbolResource,d=c.isWosr,m=M(c.lods),u=this._context,f=this._getExternalColorParameters(l),y=this.needsDrivenTransparentPass,_=m.getMaterials();_.forEach(e=>{e.setParameters({...f,drivenOpacity:y}),u.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});const g=c.referenceBoundingBox,b=p(S(g)),v=p(m.levels[0].pivotOffset),P=p(E(b,this.symbolLayer)),x=n(P),R=this._fastUpdates;X(R,this._context.renderer,this._fastVisualVariableConvertOptions(g,P,b,v))&&_.forEach(e=>e.setParameters(R.materialParameters));const C=await this._createStageResources(m,o,s),w=await this._createLodRenderer(m,s);return new oe(m,w,C,b,h,d,g,P,x,o,v)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(t,s,r){const i=this._context.stage,a=t.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged();const o=t.getTextures();i.addTextures(o),this._addDisposeResource(()=>{o.forEach(e=>e.unload()),i.removeTextures(o)}),await Promise.all(o.map(e=>this._context.stage.schedule(()=>e.load(i.renderView.renderingContext),r))),e(r);const n=t.getEngineGeometries();return{materials:a,textures:o,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=new re({symbol:e,metadata:r,shaderTransformation:i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,fe),a(s,te(i.materialParameters,fe,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,fe),ee(e,i.materialParameters,fe)}}:null},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{s.removeRenderPlugin(o),o.destroy()}),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(e){const t={};if(t.externalColor=A,!this._drivenProperties.color&&null!=e?.color){const s=e.color.toUnitRGBA();this._drivenProperties.opacity&&(s[3]=NaN),t.externalColor=s}return t}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=N(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;const r=this.createElevationContextForGraphic(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:de(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(null==this._resources)return;const e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(const t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,G)}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 0;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return 0;if(!X(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return 0;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return 2}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=j(e.levels),s=e.computeUsedMemory(),r={...T(this.symbol,this.symbolLayer),resourceBytes:s};return new J({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i){if(!this._hasLodRenderer()||null==this._resources)return null;const a=this.getFastUpdateAttrValues(e),o=this._context.clippingExtent;if(x(t,me,this._context.elevationProvider.spatialReference),null!=o&&!C(o,me))return null;const n=ce(r),l=this._computeGlobalTransform(t,r,ue,ye),c=this._computeLocalTransform(this._resources,this.symbolLayer,s,pe),h=this._resources.lodRenderer.instanceData,d=h.addInstance();this._instanceIndexToGraphicUid.set(d,i),h.setLocalTransform(d,c,!1),h.setGlobalTransform(d,l),a&&h.setFeatureAttribute(d,a),null==this._fastUpdates&&this._hasDrivenColorOrOpacity&&h.setColor(d,this._getDrivenUInt8ColorWithNaNSupport(s,this._materialColor,!this._isPrimitive));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 V(this,d,B,r,this._context.stage.view.state.highlightOrderMap);return n&&(p.alignedSampledElevation=ye.sampledElevation),p.needsElevationUpdates=G(r.mode),q(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return D(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),me[0]=e.x,me[1]=e.y,me[2]=r.z,P(e.spatialReference,me,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,r,i){return s(i),this._applyObjectRotation(r,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,r,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const i=this._drivenProperties.size&&t.size?t.size:e.symbolSize,a=k(i,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===a[0]&&1===a[1]&&1===a[2]||r(s,s,a)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=e.geometry;if(!s)return!1;const r=N(s);if(null==r)return!1;const i=this.getGeometryElevationMode(s),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,ue,ye),ce(a)&&(t.alignedSampledElevation=ye.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,ue,!0),q(t,r,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;1===this.loadStatus&&e.symbolLayerStatePatches.push(()=>{m.symbolSize=p(E(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,pe);m.lodRenderer.instanceData.setLocalTransform(e,s,!0)})}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const s=t.material.diff;if(!s.color||"complete"!==s.color.type||null==s.color.newValue||null==s.color.oldValue)return;const r=s.color.newValue,i=null!=r?r.toUnitRGBA():b;delete s.color;const a=this._resources;if(null==a)return;const o=this._isPrimitive;e.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)a.lodRenderer.instanceData.setColor(e,i);else{const e={externalColor:i};for(const t of a.stageResources.materials)t.setParameters(e),o&&t.setParameters({cullFace:de(t.transparent)})}})}_preparePatchEmissive(e,t){if(!this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result||!t.material||"partial"!==t.material.type||!t.material.diff)return;const s=t.material.diff;if(!s.emissive)return;const r=s.emissive.type;if("collection"===r||"complete"===r)return;const i=s.emissive.diff,a=i?.strength,o=i?.source;if(!i||o||!a||"complete"!==a.type)return;const n={emissiveStrengthFromSymbol:a.newValue??(this._isPrimitive?0:1)};e.graphics3DGraphicPatches.push(()=>{this._resources?.stageResources.materials.forEach(e=>e.setParameters(n))}),delete s.emissive}_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=le(e.resourceBoundingBox,e.pivotOffset,t);r&&i(s,s,r)}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?p(S(e)):u,a=null!=e?le(e,r,this.symbolLayer):y,o=this._context.renderCoordsHelper.unitInMeters,n=k(null!=t?t:void 0,t,s,o),l=_(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new Y({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??u,unitInMeters:o,anchor:a,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(){return this._materialColor?.toUnitRGBA()??(this._isPrimitive?g:A)}get _materialColor(){return this.symbolLayer.material?.color}}function le(e,t,s){const r=f();switch(s.anchor){case"center":c(r,w(e)),l(r,r);break;case"top":{const t=w(e);m(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);m(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),i=S(e),a=s.anchorPosition,o=a?_(a.x,a.y,a.z):y;h(r,i,o),d(r,r,t),l(r,r);break}default:null!=t?l(r,t):c(r,y)}return r}function ce(e){return"absolute-height"!==e.mode}function he(e){return 1===(e.material?.color?.a??0)&&null==e.resource?.href}function de(e){return e?0:2}const me=f(),pe=o(),ue=o(),fe=v(),ye=new z;export{ne as Graphics3DObjectSymbolLayer};
5
+ import{throwIfAborted as e}from"../../../../core/promiseUtils.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{identity as s,scale as r,translate as i,copy as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as o}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as n,negate as l,copy as c,multiply as h,add as d,set as m}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as u,ONES as p,create as f,ZEROS as y,fromValues as _}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as g,ONES as b,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as P}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as x}from"../../../../geometry/projection/projectPointToVector.js";import{create as R,size as S,containsPoint as C,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as L}from"../../../../symbols/support/materialUtils.js";import{defaultObjectPrimitive as U}from"../../../../symbols/support/primitives.js";import{objectSymbolLayerPrimitiveBoundingBox as O,objectSymbolLayerSizeWithResourceSize as E}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as j,defaultSymbolLayerMemoryComplexity as T}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as G,SampleElevationInfo as z,evaluateElevationInfoAtPoint as D}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as V}from"./emissiveUtils.js";import{Graphics3DLodInstanceGraphicLayer as F}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as A,nanFallbackColor as I}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as k,computeObjectScale as H,computeObjectRotation as M}from"./graphicUtils.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as q,extendPointGraphicElevationContext as $}from"./pointUtils.js";import{isValidPrimitive as Z,primitiveLodResources as J}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as K}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as Q}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as Y,ConvertOptions as ee,evaluateModelTransformScale as te,evaluateModelTransform as se}from"../support/FastSymbolUpdates.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ae}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as oe}from"../../webgl-engine/materials/pbrUtils.js";class ne{constructor(e,t,s,r,i,a,o,n,l,c,h=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=n,this.extentPadding=l,this.physicalBasedRenderingEnabled=c,this.pivotOffset=h}}class le extends A{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,de(t)),this._resources=null,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=k(this.symbolLayer);if(e)throw new Error(e)}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&Z(t?.primitive)?t.primitive:U;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await Q(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.updateComplexity()}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(e,t){const s=this.symbolLayer,r=R(O(e)),i=u(S(r)),a=u(E(i,s)),o=n(a),l=!1,c=!1,h=s?.material,d={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:oe,ambient:p,diffuse:p,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:s.castShadows,emissiveStrengthFromSymbol:h?.emissive?.strength??0,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass},m=!!d.usePBR,f=this.symbol;"point-3d"===f.type&&f.verticalOffset&&(d.verticalOffset=new re(f.verticalOffset),d.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(d.screenSizePerspective=this.view.screenSizePerspective.parameters),this._hasDrivenColorOrOpacity?d.externalColor=I:d.externalColor=this._materialColor?.toUnitRGBA()??g,this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(r,a,i,null)),d.instanced=!0,this._fastUpdates?(Object.assign(d,this._fastUpdates.materialParameters),d.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(d.instancedColor=!0);const y=new ae(d,this._context);y.setParameters({cullFace:me(y.transparent)});const _=J(e,y);if(!_)throw new Error(`Unknown object symbol primitive: ${e}`);const b=await this._createStageResources(_,m,t),v=await this._createLodRenderer(_,t);return new ne(_,v,b,i,l,c,r,a,o,m)}async _createResourcesForUrl(e,s){const r={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},i={spherical:this._context.spherical,materialParameters:r,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParameters,this._fastUpdates.materialParameters),i.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(i.materialParameters.instancedColor=!0);const a=this.symbol;if("point-3d"===a.type&&a.verticalOffset){const{screenLength:e,minWorldLength:s,maxWorldLength:r}=a.verticalOffset;i.materialParameters.verticalOffset={screenLength:t(e),minWorldLength:s||0,maxWorldLength:null!=r?r:1/0},i.materialParameters.castShadows=!1}const o=this._context.physicalBasedRenderingEnabled;i.signal=s,i.usePBR=o,i.useEmissive=this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result,i.skipHighLods=this._context.skipHighSymbolLods;const l=this.symbolLayer.material;i.materialParameters.emissiveStrengthFromSymbol=l?.emissive?.strength??1,i.materialParameters.emissiveSource=L(l?.emissive?.source??"emissive");const c=await N(e,i),h=c.isEsriSymbolResource,d=c.isWosr,m=W(c.lods),p=this._context,f=this._getExternalColorParameters(l),y=this.needsDrivenTransparentPass,_=m.getMaterials();_.forEach(e=>{e.setParameters({...f,drivenOpacity:y}),p.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});const g=c.referenceBoundingBox,b=u(S(g)),v=u(m.levels[0].pivotOffset),P=u(E(b,this.symbolLayer)),x=n(P),R=this._fastUpdates;Y(R,this._context.renderer,this._fastVisualVariableConvertOptions(g,P,b,v))&&_.forEach(e=>e.setParameters(R.materialParameters));const C=await this._createStageResources(m,o,s),w=await this._createLodRenderer(m,s);return new ne(m,w,C,b,h,d,g,P,x,o,v)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(t,s,r){const i=this._context.stage,a=t.getMaterials();s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged();const o=t.getTextures();i.addTextures(o),this._addDisposeResource(()=>{o.forEach(e=>e.unload()),i.removeTextures(o)}),await Promise.all(o.map(e=>this._context.stage.schedule(()=>e.load(i.renderView.renderingContext),r))),e(r);const n=t.getEngineGeometries();return{materials:a,textures:o,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=new ie({symbol:e,metadata:r,shaderTransformation:i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,ye),a(s,se(i.materialParameters,ye,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,ye),te(e,i.materialParameters,ye)}}:null},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{s.removeRenderPlugin(o),o.destroy()}),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(e){const t={};if(t.externalColor=I,!this._drivenProperties.color&&null!=e?.color){const s=e.color.toUnitRGBA();this._drivenProperties.opacity&&(s[3]=NaN),t.externalColor=s}return t}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=q(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;const r=this.createElevationContextForGraphic(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:me(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(null==this._resources)return;const e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(const t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,G)}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 0;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return 0;if(!Y(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return 0;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return 2}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=j(e.levels),s=e.computeUsedMemory(),r={...T(this.symbol,this.symbolLayer),resourceBytes:s};return new K({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i){if(!this._hasLodRenderer()||null==this._resources)return null;const a=this.getFastUpdateAttrValues(e),o=this._context.clippingExtent;if(x(t,ue,this._context.elevationProvider.spatialReference),null!=o&&!C(o,ue))return null;const n=he(r),l=this._computeGlobalTransform(t,r,fe,_e),c=this._computeLocalTransform(this._resources,this.symbolLayer,s,pe),h=this._resources.lodRenderer.instanceData,d=h.addInstance();this._instanceIndexToGraphicUid.set(d,i),h.setLocalTransform(d,c,!1),h.setGlobalTransform(d,l),a&&h.setFeatureAttribute(d,a),null==this._fastUpdates&&this._hasDrivenColorOrOpacity&&h.setColor(d,this._getDrivenUInt8ColorWithNaNSupport(s,this._materialColor,!this._isPrimitive));const m=this._context.stage.renderView.olidRenderHelper;if(m){const e=m.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:this._context.layerViewUid});h.setObjectAndLayerIdColor(d,e)}const u=new F(this,d,B,r,this._context.stage.view.state.highlightOrderMap);return n&&(u.alignedSampledElevation=_e.sampledElevation),u.needsElevationUpdates=G(r.mode),$(u,t,this._context.elevationProvider),u}_computeGlobalTransform(e,t,s,r){return D(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,P(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,r,i){return s(i),this._applyObjectRotation(r,!1,i),this._applyObjectRotation(t,!0,i),this._applyObjectScale(e,r,i),this._applyAnchor(e,t,i),i}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const i=this._drivenProperties.size&&t.size?t.size:e.symbolSize,a=H(i,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===a[0]&&1===a[1]&&1===a[2]||r(s,s,a)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=e.geometry;if(!s)return!1;const r=q(s);if(null==r)return!1;const i=this.getGeometryElevationMode(s),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,fe,_e),he(a)&&(t.alignedSampledElevation=_e.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,fe,!0),$(t,r,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;1===this.loadStatus&&e.symbolLayerStatePatches.push(()=>{m.symbolSize=u(E(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{const s=this._computeLocalTransform(m,d,t,pe);m.lodRenderer.instanceData.setLocalTransform(e,s,!0)})}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const s=t.material.diff;if(!s.color||"complete"!==s.color.type||null==s.color.newValue||null==s.color.oldValue)return;const r=s.color.newValue,i=null!=r?r.toUnitRGBA():b;delete s.color;const a=this._resources;if(null==a)return;const o=this._isPrimitive;e.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)a.lodRenderer.instanceData.setColor(e,i);else{const e={externalColor:i};for(const t of a.stageResources.materials)t.setParameters(e),o&&t.setParameters({cullFace:me(t.transparent)})}})}_preparePatchEmissive(e,t){return V(e,t,e=>{this._resources?.stageResources.materials.forEach(t=>t.setParameters({emissiveStrengthFromSymbol:e??(this._isPrimitive?0:1)}))},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return M(e.heading,e.tilt,e.roll,s)}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=ce(e.resourceBoundingBox,e.pivotOffset,t);r&&i(s,s,r)}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?u(S(e)):p,a=null!=e?ce(e,r,this.symbolLayer):y,o=this._context.renderCoordsHelper.unitInMeters,n=H(null!=t?t:void 0,t,s,o),l=_(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??p,unitInMeters:o,anchor:a,scale:n,rotation:l,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:n})}get _primitive(){const{resource:e}=this.symbolLayer;return null!=e?.href?null:e?.primitive??U}_getFallbackOpacityAndColor(){return this._materialColor?.toUnitRGBA()??(this._isPrimitive?g:I)}get _materialColor(){return this.symbolLayer.material?.color}}function ce(e,t,s){const r=f();switch(s.anchor){case"center":c(r,w(e)),l(r,r);break;case"top":{const t=w(e);m(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);m(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),i=S(e),a=s.anchorPosition,o=a?_(a.x,a.y,a.z):y;h(r,i,o),d(r,r,t),l(r,r);break}default:null!=t?l(r,t):c(r,y)}return r}function he(e){return"absolute-height"!==e.mode}function de(e){return 1===(e.material?.color?.a??0)&&null==e.resource?.href}function me(e){return e?0:2}const ue=f(),pe=o(),fe=o(),ye=v(),_e=new z;export{le as Graphics3DObjectSymbolLayer};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
+ */
5
+ function e(e,t,i,s){if(!s||!t.material||"partial"!==t.material.type||!t.material.diff)return;const r=t.material.diff;if(!r.emissive)return;const a=r.emissive.type;if("collection"===a||"complete"===a)return;const l=r.emissive.diff,m=l?.strength,n=l?.source;l&&!n&&m&&"complete"===m.type&&(e.symbolLayerStatePatches.push(()=>{i(m.newValue)}),delete r.emissive)}export{e as preparePatchEmissiveStrength};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- function t(t){return"fill"===t.type}function e(t){return"extrude"===t.type}export{e as isExtrudeSymbol3DLayer,t as isFillSymbol3DLayer};
5
+ function t(t){return"fill"===t?.type}function n(t){return"extrude"===t?.type}function e(t){return"object"===t?.type}function r(r){return e(r)||n(r)||t(r)}export{n as isExtrudeSymbol3DLayer,t as isFillSymbol3DLayer,e as isObjectSymbol3DLayer,r as supportsEmissive};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{acosClamped as t}from"../../../core/mathUtils.js";import{length as n,dot as r,scale as o,add as c,lerp as s,set as a,cross as i,normalize as u,subtract as e}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";function f(t,n){return t>n?Math.cos(n):Math.cos(t)}function M(t,n,r){return 2*Math.atan(r*Math.tan(.5*t)/n)}function l(t,n,r){return 2*Math.atan(n*Math.tan(.5*t)/r)}function m(t){const n=t[0]*t[0]+t[4]*t[4]+t[8]*t[8],r=t[1]*t[1]+t[5]*t[5]+t[9]*t[9],o=t[2]*t[2]+t[6]*t[6]+t[10]*t[10];return Math.sqrt(Math.max(n,r,o))}function g(t,n){const r=Math.sqrt(n[0]*n[0]+n[4]*n[4]+n[8]*n[8]),o=Math.sqrt(n[1]*n[1]+n[5]*n[5]+n[9]*n[9]),c=Math.sqrt(n[2]*n[2]+n[6]*n[6]+n[10]*n[10]);return a(t,r,o,c),t}function b(t,n,o){o=o||t;const c=r(t,n);a(o,t[0]-c*n[0],t[1]-c*n[1],t[2]-c*n[2]),u(o,o)}function p(t,n,r){Math.abs(t[0])>Math.abs(t[1])?a(n,0,1,0):a(n,1,0,0),i(r,t,n),i(n,r,t),u(r,r),u(n,n)}function q(t,n,r,o,c,s){const a=t+(n-t)*c;return a+(r+(o-r)*c-a)*s}function x(t,a,i,u=h()){const e=n(t),f=n(a),M=r(t,a)/(e*f);if(M<.9999999999999999){const n=Math.acos(M),r=((1-i)*e+i*f)/Math.sin(n),s=r/e*Math.sin((1-i)*n),h=r/f*Math.sin(i*n);return o(A,t,s),o(B,a,h),c(u,A,B)}return s(u,t,a,i)}function j(t,a,i,f=h(),M=h()){const l=n(t),m=n(a),g=r(t,a)/(l*m);if(g<.9999999999999999){const n=Math.acos(g),r=Math.sin(n),s=Math.sin(i*n),u=Math.sin((1-i)*n),e=(1-i)*l+i*m;{const n=e/r,i=n/m*s;o(A,t,n/l*u),o(B,a,i),c(f,A,B)}{const h=1/l*(-Math.cos((1-i)*n)*n*e+u*(-l+m));o(A,t,h);const f=1/m*(Math.cos(i*n)*n*e+s*(-l+m));o(B,a,f),c(M,A,B),o(M,M,1/r)}return M}return s(f,t,a,i),e(M,a,t),u(M,M),M}function v(n,o,c){n=u(A,n),o=u(B,o);const s=t(r(n,o));if(c){const t=i(z,n,o);if(r(t,c)<0)return-s}return s}function U(t){const n=t.length;return r=>{if(r<=t[0][0])return t[0][1];if(r>=t[n-1][0])return t[n-1][1];let o=1;for(;r>t[o][0];)o++;const c=t[o-1][0],s=t[o][0],a=(s-r)/(s-c);return a*t[o-1][1]+(1-a)*t[o][1]}}function d(t,n,o,c){e(w,n,t),e(y,o,t),i(c,w,y),u(c,c),c[3]=-r(t,c)}function k(t,n){if(a(n,0,0,0),t.length>0){for(let r=0;r<t.length;++r)c(n,n,t[r]);o(n,n,1/t.length)}}const w=h(),y=h(),z=h(),A=h(),B=h();export{v as angle,q as bilerp,f as cosCapped,M as fovx2fovy,l as fovy2fovx,b as makeOrthonormal,U as makePiecewiseLinearFunction,m as maxScale,k as midpoint3d,d as planeFromPoints,g as scaleFromMatrix,x as slerp,j as slerpTangent,p as tangentFrame};
5
+ import{acosClamped as t}from"../../../core/mathUtils.js";import{dot as n,set as r,normalize as o,length as c,scale as s,add as a,lerp as i,cross as u,subtract as e}from"../../../core/libs/gl-matrix-2/math/vec3.js";import{create as h}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";function f(t,n){return t>n?Math.cos(n):Math.cos(t)}function M(t,n,r){return 2*Math.atan(r*Math.tan(.5*t)/n)}function l(t,n,r){return 2*Math.atan(n*Math.tan(.5*t)/r)}function m(t){const n=t[0]*t[0]+t[4]*t[4]+t[8]*t[8],r=t[1]*t[1]+t[5]*t[5]+t[9]*t[9],o=t[2]*t[2]+t[6]*t[6]+t[10]*t[10];return Math.sqrt(Math.max(n,r,o))}function g(t,n){const o=Math.sqrt(n[0]*n[0]+n[4]*n[4]+n[8]*n[8]),c=Math.sqrt(n[1]*n[1]+n[5]*n[5]+n[9]*n[9]),s=Math.sqrt(n[2]*n[2]+n[6]*n[6]+n[10]*n[10]);return r(t,o,c,s),t}function b(t,c,s){s=s||t;const a=n(t,c);r(s,t[0]-a*c[0],t[1]-a*c[1],t[2]-a*c[2]),o(s,s)}function p(t,n,c){Math.abs(t[0])>Math.abs(t[1])?r(n,0,1,0):r(n,1,0,0),u(c,t,n),u(n,c,t),o(c,c),o(n,n)}function q(t,n,r,o,c,s){const a=t+(n-t)*c;return a+(r+(o-r)*c-a)*s}function x(t,r,o,u=h()){const e=c(t),f=c(r),M=n(t,r)/(e*f);if(M<.9999999999999999){const n=Math.acos(M),c=((1-o)*e+o*f)/Math.sin(n),i=c/e*Math.sin((1-o)*n),h=c/f*Math.sin(o*n);return s(A,t,i),s(B,r,h),a(u,A,B)}return i(u,t,r,o)}function j(t,r,u,f=h(),M=h()){const l=c(t),m=c(r),g=n(t,r)/(l*m);if(g<.9999999999999999){const n=Math.acos(g),o=Math.sin(n),c=Math.sin(u*n),i=Math.sin((1-u)*n),e=(1-u)*l+u*m;{const n=e/o,u=n/m*c;s(A,t,n/l*i),s(B,r,u),a(f,A,B)}{const h=1/l*(-Math.cos((1-u)*n)*n*e+i*(-l+m));s(A,t,h);const f=1/m*(Math.cos(u*n)*n*e+c*(-l+m));s(B,r,f),a(M,A,B),s(M,M,1/o)}return M}return i(f,t,r,u),e(M,r,t),o(M,M),M}function v(r,c,s){r=o(A,r),c=o(B,c);const a=t(n(r,c));if(s){const t=u(z,r,c);if(n(t,s)<0)return-a}return a}function U(t){const n=t.length;return r=>{if(r<=t[0][0])return t[0][1];if(r>=t[n-1][0])return t[n-1][1];let o=1;for(;r>t[o][0];)o++;const c=t[o-1][0],s=t[o][0],a=(s-r)/(s-c);return a*t[o-1][1]+(1-a)*t[o][1]}}function d(t,r,c,s){e(w,r,t),e(y,c,t),u(s,w,y),o(s,s),s[3]=-n(t,s)}function k(t,n){if(r(n,0,0,0),t.length>0){for(let r=0;r<t.length;++r)a(n,n,t[r]);s(n,n,1/t.length)}}const w=h(),y=h(),z=h(),A=h(),B=h();export{v as angle,q as bilerp,f as cosCapped,M as fovx2fovy,l as fovy2fovx,b as makeOrthonormal,U as makePiecewiseLinearFunction,m as maxScale,k as midpoint3d,d as planeFromPoints,g as scaleFromMatrix,x as slerp,j as slerpTangent,p as tangentFrame};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{abortMaybe as o}from"../../../../core/maybe.js";import"../../../../core/RandomLCG.js";import"../../../../core/Logger.js";import{watch as r,on as i}from"../../../../core/reactiveUtils.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import p from"../../../../geometry/Point.js";import{center as a}from"../../../../geometry/support/aaBoundingRect.js";import"../../../../core/asyncUtils.js";import"../../../../core/units.js";import"../../../../geometry/ellipsoidUtils.js";import"../../../../geometry/Extent.js";import"../../../../geometry/Geometry.js";import"../../../../geometry/Multipoint.js";import"../../../../geometry/Polygon.js";import"../../../../geometry/Polyline.js";import"../../../../geometry/SpatialReference.js";import"../../../../geometry/operators/support/GeographicTransformation.js";import"../../../../geometry/projection/projectors.js";import"../../../../geometry/support/spatialReferenceUtils.js";import"../../../../layers/support/ElevationTileData.js";import"../../../../layers/support/TileElevationSampler.js";let u=class extends e{constructor(t){super(t),this.location=null,this._updateController=null}initialize(){this.view.state.isLocal&&(this.addHandles([r(()=>[this._groundView?.spatialReference,this._groundView?.groundExtent],()=>this._update()),i(()=>this._ground?.layers,"change",()=>this._update())]),this._update())}destroy(){this._updateController=o(this._updateController)}get renderLocation(){if(!this.location)return null;const t=l();return this.view.renderCoordsHelper.toRenderCoords(this.location,t),t}get _ground(){return this.view.map?.ground}get _groundView(){return this.view.groundView}_update(){if(this._updateController=o(this._updateController),null==this._groundView?.groundExtent||null==this._groundView?.spatialReference)return void this._set("location",null);const t=a(this._groundView.groundExtent),e=new p({x:t[0],y:t[1],z:0,spatialReference:this._groundView.spatialReference});this._ground&&this._ground.layers.length>0?(this._set("location",null),this._updateController=new AbortController,this._ground.queryElevation(e,{noDataValue:0,signal:this._updateController.signal,cache:this.cache}).then(t=>{this._updateController=null,this._set("location",t.geometry)}).catch(t=>{})):this._set("location",e)}};t([s({constructOnly:!0})],u.prototype,"view",void 0),t([s({constructOnly:!0})],u.prototype,"cache",void 0),t([s({readOnly:!0})],u.prototype,"location",void 0),t([s({readOnly:!0})],u.prototype,"renderLocation",null),t([s()],u.prototype,"_ground",null),t([s()],u.prototype,"_groundView",null),u=t([n("esri.views.3d.support.pointsOfInterest.StableSurfaceCenter")],u);export{u as StableSurfaceCenter};
5
+ import{__decorate as t}from"tslib";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{abortMaybe as o}from"../../../../core/maybe.js";import"../../../../core/RandomLCG.js";import"../../../../core/Logger.js";import{watch as r,on as i}from"../../../../core/reactiveUtils.js";import{property as s,subclass as n}from"../../../../core/accessorSupport/decorators.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import p from"../../../../geometry/Point.js";import{center as a}from"../../../../geometry/support/aaBoundingRect.js";import"../../../../core/asyncUtils.js";import"../../../../core/units.js";import"../../../../geometry/ellipsoidUtils.js";import"../../../../geometry/Extent.js";import"../../../../geometry/Geometry.js";import"../../../../geometry/Multipoint.js";import"../../../../geometry/Polygon.js";import"../../../../geometry/Polyline.js";import"../../../../geometry/SpatialReference.js";import"../../../../geometry/spatialReferenceEllipsoidUtils.js";import"../../../../geometry/operators/support/GeographicTransformation.js";import"../../../../geometry/projection/projectors.js";import"../../../../geometry/support/spatialReferenceUtils.js";import"../../../../layers/support/ElevationTileData.js";import"../../../../layers/support/TileElevationSampler.js";let u=class extends e{constructor(t){super(t),this.location=null,this._updateController=null}initialize(){this.view.state.isLocal&&(this.addHandles([r(()=>[this._groundView?.spatialReference,this._groundView?.groundExtent],()=>this._update()),i(()=>this._ground?.layers,"change",()=>this._update())]),this._update())}destroy(){this._updateController=o(this._updateController)}get renderLocation(){if(!this.location)return null;const t=l();return this.view.renderCoordsHelper.toRenderCoords(this.location,t),t}get _ground(){return this.view.map?.ground}get _groundView(){return this.view.groundView}_update(){if(this._updateController=o(this._updateController),null==this._groundView?.groundExtent||null==this._groundView?.spatialReference)return void this._set("location",null);const t=a(this._groundView.groundExtent),e=new p({x:t[0],y:t[1],z:0,spatialReference:this._groundView.spatialReference});this._ground&&this._ground.layers.length>0?(this._set("location",null),this._updateController=new AbortController,this._ground.queryElevation(e,{noDataValue:0,signal:this._updateController.signal,cache:this.cache}).then(t=>{this._updateController=null,this._set("location",t.geometry)}).catch(t=>{})):this._set("location",e)}};t([s({constructOnly:!0})],u.prototype,"view",void 0),t([s({constructOnly:!0})],u.prototype,"cache",void 0),t([s({readOnly:!0})],u.prototype,"location",void 0),t([s({readOnly:!0})],u.prototype,"renderLocation",null),t([s()],u.prototype,"_ground",null),t([s()],u.prototype,"_groundView",null),u=t([n("esri.views.3d.support.pointsOfInterest.StableSurfaceCenter")],u);export{u as StableSurfaceCenter};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{isWGS84 as r,isCGCS2000 as t,isMars as e,isMoon as n}from"../../../geometry/support/spatialReferenceUtils.js";function o(r){return i(r)||e(r)||n(r)}function i(e){return r(e)||t(e)}export{i as isSupportedEarthGCS,o as isSupportedGCSOnGlobe};
5
+ import{isMars as r,isMoon as t}from"../../../geometry/ellipsoidUtils.js";import{isWGS84 as e,isCGCS2000 as o}from"../../../geometry/support/spatialReferenceUtils.js";function i(e){return n(e)||r(e)||t(e)}function n(r){return e(r)||o(r)}export{n as isSupportedEarthGCS,i as isSupportedGCSOnGlobe};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import n from"../../../core/Collection.js";import{isCGCS2000 as t,isEarth as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{isRasterTile as o,isImageWithType as i,isTileTexture as u,isVectorTile as l}from"./TerrainData.js";import{t as f}from"../../../chunks/terrainUtilsPlanar.js";import{t as c}from"../../../chunks/terrainUtilsSpherical.js";const a={1:c,2:f};function s(n,t){n||console.warn("Terrain: "+t)}let p=!1,m=!1;function I(n){m=n,p=p||n}function y(n){p=n}function d(n,t){if(p&&!n){const n=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(t??"")+" at "+n),new Error("Assertion failed"+(t?": "+t:""))}}function E(n){return"imagery-tile"===n?.type||"wcs"===n?.type}function T(n){return"imagery-tile-3d"===n?.type}function x(n){return"tile-3d"===n?.type}function h(n){return"vector-tile-3d"===n?.type}function L(n){return"wmts-3d"===n?.type}function g(n){return"elevation-3d"===n?.type}function w(n){return"group"===n?.type}function C(n){return n&&(x(n)||L(n)||T(n)||h(n))}function v(n){return n&&(x(n)||T(n)||h(n)||L(n))}function j(n){return v(n)||g(n)}function b(n){return o(n?.sourceLayerInfo?.data)}function k(n){return F(n?.sourceLayerInfo)||!!n?.isVTLBackground}function M(n){return u(n?.sourceLayerInfo?.data)}function V(n){const t=n?.sourceLayerInfo?.data;return i(t)||t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageData}function F(n){return l(n?.data)}function S(n){return null!=n&&"release"in n&&n.release(),null}function U(n){return n.fetchTile&&!1!==n.hasOverriddenFetchTile}function D(n,t,e,r,o){return a[r].checkIfTileInfoSupportedForViewSR(n,e,t,o)}function H(n,t,e){let r=null,o=null;if("wmts"===n?.type){const i=O(n,t,e);r=i.tileInfo,o=i.fullExtent}else{o=E(n)?n.getCompatibleFullExtent(t):n.fullExtent;const i=2===e;if(E(n))r=n.getCompatibleTileInfo(t,o,i);else if("vector-tile"===n?.type){r=i&&!R(t)||W.force512VTL?n.tileInfo:n.tileInfo.getCompatibleForVTL(256)}else r=n.tileInfo}const i="tilemapCache"in n?n.tilemapCache?.effectiveMaxLOD:void 0;return null!=r&&null!=o&&null==D(r,o,t,e,i)?{tileInfo:r,fullExtent:o}:null}function O(t,e,o){const i=r(t);if(null!=i){if(!n.isCollection(i))return{tileInfo:i.tileInfo,fullExtent:i.fullExtent};{const n=i.find(n=>null==D(n.tileInfo,n.fullExtent,e,o));if(n)return{tileInfo:n.tileInfo,fullExtent:n.fullExtent}}}return{tileInfo:null,fullExtent:null}}function R(n){return n.isWGS84||n.isWebMercator||t(n)||!e(n)}const W={force512VTL:!1};function A(n){return"["+n[0]+","+n[1]+","+n[2]+"]"}function B(n){return"("+n[0]+","+n[1]+","+n[2]+")"}function G(n,t,e=$){return Math.abs(n-t)<e}function P(n){return 1===n?5:7===n?3:5===n?1:7}function q(n){return 0===n?4:2===n?6:4===n?0:2}function z(n){return 7===n||5===n}function J(n){return 7===n||1===n}function K(n){return 7===n||6===n||5===n}function N(n){return 1===n||2===n||3===n}function Q(n){return 3===n||4===n||5===n}function X(n){return 1===n||0===n||7===n}const Y=[0,2,4,6],Z=[1,3,5,7],$=1e-5;export{G as almostEquals,D as checkIfTileInfoSupportedForView,y as enableInternalTerrainChecks,p as enableTerrainInternalChecks,I as enableTerrainWaterproofChecks,m as enableWaterproofTests,$ as eps,O as getTileInfoAndExtentFromWMTSLayer,H as getTiledLayerInfo,d as internalAssert,C as isBlendableLayerView,N as isEast,g as isElevationLayerView,w as isGroupLayerView,V as isImageSourceRenderInfo,T as isImageryTileLayerView,b as isImageryTileRenderInfo,v as isMapTileLayerView,X as isNorth,J as isNorthCorner,E as isProjectableRasterLayer,Q as isSouth,j as isSurfaceLayerView,M as isTextureTileRenderInfo,x as isTileLayerView,h as isVectorTileLayerView,F as isVectorTilePerLayerInfo,k as isVectorTileRenderInfo,L as isWMTSLayerView,K as isWest,z as isWestCorner,A as lij2s,Z as neighborCornerIndices,Y as neighborEdgeIndices,P as oppositeCorner,q as oppositeEdge,S as releaseTerrainData,W as test,U as useFetchTileForLayer,B as v32s,R as vtlAssumes256PixelSizeAsDefault,s as weakAssert};
5
+ import n from"../../../core/Collection.js";import{isEarth as t}from"../../../geometry/ellipsoidUtils.js";import{isCGCS2000 as e}from"../../../geometry/support/spatialReferenceUtils.js";import{getTileMaxtrixSetFromActiveLayer as r}from"../../../layers/support/layerUtils.js";import{isRasterTile as o,isImageWithType as i,isTileTexture as u,isVectorTile as l}from"./TerrainData.js";import{t as f}from"../../../chunks/terrainUtilsPlanar.js";import{t as c}from"../../../chunks/terrainUtilsSpherical.js";const a={1:c,2:f};function s(n,t){n||console.warn("Terrain: "+t)}let p=!1,m=!1;function y(n){m=n,p=p||n}function I(n){p=n}function d(n,t){if(p&&!n){const n=(new Error).stack?.slice(5);throw console.warn("Terrain internal: "+(t??"")+" at "+n),new Error("Assertion failed"+(t?": "+t:""))}}function E(n){return"imagery-tile"===n?.type||"wcs"===n?.type}function T(n){return"imagery-tile-3d"===n?.type}function x(n){return"tile-3d"===n?.type}function g(n){return"vector-tile-3d"===n?.type}function h(n){return"wmts-3d"===n?.type}function L(n){return"elevation-3d"===n?.type}function w(n){return"group"===n?.type}function C(n){return n&&(x(n)||h(n)||T(n)||g(n))}function j(n){return n&&(x(n)||T(n)||g(n)||h(n))}function v(n){return j(n)||L(n)}function b(n){return o(n?.sourceLayerInfo?.data)}function k(n){return V(n?.sourceLayerInfo)||!!n?.isVTLBackground}function M(n){return u(n?.sourceLayerInfo?.data)}function U(n){const t=n?.sourceLayerInfo?.data;return i(t)||t instanceof HTMLImageElement||t instanceof HTMLCanvasElement||t instanceof ImageData}function V(n){return l(n?.data)}function F(n){return null!=n&&"release"in n&&n.release(),null}function S(n){return n.fetchTile&&!1!==n.hasOverriddenFetchTile}function D(n,t,e,r,o){return a[r].checkIfTileInfoSupportedForViewSR(n,e,t,o)}function H(n,t,e){let r=null,o=null;if("wmts"===n?.type){const i=O(n,t,e);r=i.tileInfo,o=i.fullExtent}else{o=E(n)?n.getCompatibleFullExtent(t):n.fullExtent;const i=2===e;if(E(n))r=n.getCompatibleTileInfo(t,o,i);else if("vector-tile"===n?.type){r=i&&!R(t)||W.force512VTL?n.tileInfo:n.tileInfo.getCompatibleForVTL(256)}else r=n.tileInfo}const i="tilemapCache"in n?n.tilemapCache?.effectiveMaxLOD:void 0;return null!=r&&null!=o&&null==D(r,o,t,e,i)?{tileInfo:r,fullExtent:o}:null}function O(t,e,o){const i=r(t);if(null!=i){if(!n.isCollection(i))return{tileInfo:i.tileInfo,fullExtent:i.fullExtent};{const n=i.find(n=>null==D(n.tileInfo,n.fullExtent,e,o));if(n)return{tileInfo:n.tileInfo,fullExtent:n.fullExtent}}}return{tileInfo:null,fullExtent:null}}function R(n){return n.isWGS84||n.isWebMercator||e(n)||!t(n)}const W={force512VTL:!1};function A(n){return"["+n[0]+","+n[1]+","+n[2]+"]"}function B(n){return"("+n[0]+","+n[1]+","+n[2]+")"}function G(n,t,e=$){return Math.abs(n-t)<e}function P(n){return 1===n?5:7===n?3:5===n?1:7}function q(n){return 0===n?4:2===n?6:4===n?0:2}function z(n){return 7===n||5===n}function J(n){return 7===n||1===n}function K(n){return 7===n||6===n||5===n}function N(n){return 1===n||2===n||3===n}function Q(n){return 3===n||4===n||5===n}function X(n){return 1===n||0===n||7===n}const Y=[0,2,4,6],Z=[1,3,5,7],$=1e-5;export{G as almostEquals,D as checkIfTileInfoSupportedForView,I as enableInternalTerrainChecks,p as enableTerrainInternalChecks,y as enableTerrainWaterproofChecks,m as enableWaterproofTests,$ as eps,O as getTileInfoAndExtentFromWMTSLayer,H as getTiledLayerInfo,d as internalAssert,C as isBlendableLayerView,N as isEast,L as isElevationLayerView,w as isGroupLayerView,U as isImageSourceRenderInfo,T as isImageryTileLayerView,b as isImageryTileRenderInfo,j as isMapTileLayerView,X as isNorth,J as isNorthCorner,E as isProjectableRasterLayer,Q as isSouth,v as isSurfaceLayerView,M as isTextureTileRenderInfo,x as isTileLayerView,g as isVectorTileLayerView,V as isVectorTilePerLayerInfo,k as isVectorTileRenderInfo,h as isWMTSLayerView,K as isWest,z as isWestCorner,A as lij2s,Z as neighborCornerIndices,Y as neighborEdgeIndices,P as oppositeCorner,q as oppositeEdge,F as releaseTerrainData,W as test,S as useFetchTileForLayer,B as v32s,R as vtlAssumes256PixelSizeAsDefault,s as weakAssert};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{isMars as e,isMoon as r}from"../../../../../../geometry/support/spatialReferenceUtils.js";function t(t){return t&&e(t)?2:t&&r(t)?3:1}export{t as getEllipsoidMode};
5
+ import{isMars as o,isMoon as r}from"../../../../../../geometry/ellipsoidUtils.js";function t(t){return t&&o(t)?2:t&&r(t)?3:1}export{t as getEllipsoidMode};