@arcgis/core 5.0.0-next.43 → 5.0.0-next.45

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 (329) hide show
  1. package/applications/Components/imageryUtils.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{f97a7cb367634353177d.js → 001a7a4cf6fe74432ed6.js} +1 -1
  4. package/assets/esri/core/workers/chunks/{324d66962aeec17d3e28.js → 1e0e7cef7ef947894bbe.js} +1 -1
  5. package/assets/esri/core/workers/chunks/20ad34f9d45c64392022.js +1 -0
  6. package/assets/esri/core/workers/chunks/23396a6318edf9264c1f.js +1 -0
  7. package/assets/esri/core/workers/chunks/{ad891ac388fa6c1c9b94.js → 2b34a010f76e5f289868.js} +1 -1
  8. package/assets/esri/core/workers/chunks/2ef4c0092c59a98a5532.js +1 -0
  9. package/assets/esri/core/workers/chunks/35272810c2ed04eb403d.js +1 -0
  10. package/assets/esri/core/workers/chunks/{d1f4152b2b8d47cbf586.js → 72fbee59d5d909615408.js} +1 -1
  11. package/assets/esri/core/workers/chunks/75c66e38bdc1c786c599.js +1 -0
  12. package/assets/esri/core/workers/chunks/7d3c2a063598bdd015e2.js +1 -0
  13. package/assets/esri/core/workers/chunks/897ce6fc9cefb1e14a64.js +1 -0
  14. package/assets/esri/core/workers/chunks/992e9bbdf9d3787ddb0e.js +1 -0
  15. package/assets/esri/core/workers/chunks/a2442549c5daf3653eb4.js +1 -0
  16. package/assets/esri/core/workers/chunks/a7cd795042ebb8585906.js +1 -0
  17. package/assets/esri/core/workers/chunks/bf5f9da0837ed09729c6.js +316 -0
  18. package/assets/esri/core/workers/chunks/{385cfd3087f00dbd1146.js → ca1c65eb7f5900c60170.js} +1 -1
  19. package/assets/esri/core/workers/chunks/cddce67919e13e2f365e.js +1 -0
  20. package/assets/esri/core/workers/chunks/{7c08c0824ad354177787.js → d7878fba02814adaf19f.js} +1 -1
  21. package/assets/esri/core/workers/chunks/e6784251bbb8b71ead93.js +1 -0
  22. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  23. package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
  24. package/chunks/GaussianSplat.glsl.js +2 -2
  25. package/config.js +1 -1
  26. package/core/urlUtils.d.ts +1 -0
  27. package/core/workers/workerFactory.js +1 -1
  28. package/interfaces.d.ts +104 -9
  29. package/kernel.js +1 -1
  30. package/layers/ImageryTileLayer.js +1 -1
  31. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  32. package/layers/WCSLayer.js +1 -1
  33. package/layers/mixins/ArcGISImageService.js +1 -1
  34. package/layers/mixins/ImageryTileMixin.js +1 -1
  35. package/layers/mixins/RasterJobHandlerMixin.js +1 -1
  36. package/layers/ogc/wcsUtils.js +1 -1
  37. package/layers/raster/datasets/BaseRaster.js +5 -0
  38. package/layers/raster/datasets/CovJSONRaster.js +5 -0
  39. package/layers/raster/datasets/FunctionRaster.js +5 -0
  40. package/layers/raster/datasets/ImageAuxRaster.js +5 -0
  41. package/layers/raster/datasets/ImageServerRaster.js +5 -0
  42. package/layers/raster/datasets/InMemoryRaster.js +5 -0
  43. package/layers/raster/datasets/MRFRaster.js +5 -0
  44. package/layers/raster/datasets/RawBlockCache.js +5 -0
  45. package/layers/raster/datasets/TIFFRaster.js +5 -0
  46. package/layers/raster/datasets/WCSRaster.js +5 -0
  47. package/layers/raster/datasets/covJSONParser.js +5 -0
  48. package/layers/raster/datasets/multidimensionalUtils.js +5 -0
  49. package/layers/raster/datasets/pamParser.js +5 -0
  50. package/layers/raster/datasets/pixelReader.js +5 -0
  51. package/layers/raster/datasets/wcsCoverageParser.js +5 -0
  52. package/layers/raster/formats/Lerc.js +5 -0
  53. package/layers/raster/formats/Qb3.js +5 -0
  54. package/layers/raster/formats/RasterCodec.js +5 -0
  55. package/layers/raster/formats/TiffDecoder.js +5 -0
  56. package/layers/raster/functions/ArithmeticFunction.js +5 -0
  57. package/layers/{support/rasterFunctions → raster/functions}/ArithmeticFunctionArguments.js +1 -1
  58. package/layers/{support/rasterFunctions → raster/functions}/AspectFunction.js +1 -1
  59. package/layers/{support/rasterFunctions → raster/functions}/AspectFunctionArguments.js +1 -1
  60. package/layers/raster/functions/BandArithmeticFunction.js +5 -0
  61. package/layers/{support/rasterFunctions → raster/functions}/BandArithmeticFunctionArguments.js +1 -1
  62. package/layers/{support/rasterFunctions → raster/functions}/BaseFunctionArguments.js +1 -1
  63. package/layers/raster/functions/BaseRasterFunction.js +5 -0
  64. package/layers/{support/rasterFunctions → raster/functions}/ClipFunction.js +1 -1
  65. package/layers/{support/rasterFunctions → raster/functions}/ClipFunctionArguments.js +1 -1
  66. package/layers/raster/functions/ColormapFunction.js +5 -0
  67. package/layers/{support/rasterFunctions → raster/functions}/ColormapFunctionArguments.js +1 -1
  68. package/layers/raster/functions/ColormapToRGBFunction.js +5 -0
  69. package/layers/{support/rasterFunctions → raster/functions}/ColormapToRGBFunctionArguments.js +1 -1
  70. package/layers/raster/functions/CompositeBandFunction.js +5 -0
  71. package/layers/raster/functions/CompositeBandFunctionArguments.js +5 -0
  72. package/layers/raster/functions/ComputeChangeFunction.js +5 -0
  73. package/layers/{support/rasterFunctions → raster/functions}/ComputeChangeFunctionArguments.js +1 -1
  74. package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunction.js +1 -1
  75. package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunctionArguments.js +1 -1
  76. package/layers/raster/functions/ConvolutionFunction.js +5 -0
  77. package/layers/raster/functions/ConvolutionFunctionArguments.js +5 -0
  78. package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunction.js +1 -1
  79. package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunctionArguments.js +1 -1
  80. package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunction.js +1 -1
  81. package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunctionArguments.js +1 -1
  82. package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunction.js +1 -1
  83. package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunctionArguments.js +1 -1
  84. package/layers/raster/functions/HillshadeFunction.js +5 -0
  85. package/layers/{support/rasterFunctions → raster/functions}/HillshadeFunctionArguments.js +1 -1
  86. package/layers/raster/functions/LocalFunction.js +5 -0
  87. package/layers/{support/rasterFunctions → raster/functions}/LocalFunctionArguments.js +1 -1
  88. package/layers/{support/rasterFunctions → raster/functions}/MaskFunction.js +1 -1
  89. package/layers/{support/rasterFunctions → raster/functions}/MaskFunctionArguments.js +1 -1
  90. package/layers/{support/rasterFunctions → raster/functions}/NDVIFunction.js +1 -1
  91. package/layers/{support/rasterFunctions → raster/functions}/NDVIFunctionArguments.js +1 -1
  92. package/layers/raster/functions/RemapFunction.js +5 -0
  93. package/layers/{support/rasterFunctions → raster/functions}/RemapFunctionArguments.js +1 -1
  94. package/layers/raster/functions/ShadedReliefFunction.js +5 -0
  95. package/layers/{support/rasterFunctions → raster/functions}/ShadedReliefFunctionArguments.js +1 -1
  96. package/layers/raster/functions/SlopeFunction.js +5 -0
  97. package/layers/{support/rasterFunctions → raster/functions}/SlopeFunctionArguments.js +1 -1
  98. package/layers/raster/functions/StatisticsFunction.js +5 -0
  99. package/layers/{support/rasterFunctions → raster/functions}/StatisticsFunctionArguments.js +1 -1
  100. package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunction.js +1 -1
  101. package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunctionArguments.js +1 -1
  102. package/layers/raster/functions/StretchFunction.js +5 -0
  103. package/layers/{support/rasterFunctions → raster/functions}/StretchFunctionArguments.js +1 -1
  104. package/layers/{support/rasterFunctions → raster/functions}/TableFunction.js +1 -1
  105. package/layers/{support/rasterFunctions → raster/functions}/TableFunctionArguments.js +1 -1
  106. package/layers/raster/functions/bandIndexUtils.js +5 -0
  107. package/layers/raster/functions/changeDetectionUtils.js +5 -0
  108. package/layers/raster/functions/clipUtils.js +5 -0
  109. package/layers/raster/functions/conversionUtils.js +5 -0
  110. package/layers/raster/functions/convolutionUtils.js +5 -0
  111. package/layers/raster/functions/creators/createDataManagementFunctions.js +5 -0
  112. package/layers/raster/functions/creators/utils.js +5 -0
  113. package/layers/raster/functions/focalStatUtils.js +5 -0
  114. package/layers/raster/functions/localUtils.js +5 -0
  115. package/layers/raster/functions/pixelTransformUtils.js +5 -0
  116. package/layers/raster/functions/pixelUtils.js +5 -0
  117. package/layers/raster/functions/stretchUtils.js +5 -0
  118. package/layers/raster/functions/surfaceUtils.js +5 -0
  119. package/layers/raster/functions/vectorFieldUtils.js +5 -0
  120. package/layers/raster/transforms/BaseRasterTransform.js +5 -0
  121. package/layers/{support/rasterTransforms → raster/transforms}/GCSShiftTransform.js +1 -1
  122. package/layers/{support/rasterTransforms → raster/transforms}/IdentityTransform.js +1 -1
  123. package/layers/{support/rasterTransforms → raster/transforms}/PolynomialTransform.js +1 -1
  124. package/layers/save/imageryUtils.js +1 -1
  125. package/layers/support/PixelBlock.js +1 -1
  126. package/layers/support/RasterWorker.js +1 -1
  127. package/layers/support/imageryRendererUtils.js +1 -1
  128. package/layers/support/rasterFunctionUtils.js +1 -1
  129. package/package.json +2 -2
  130. package/renderers/VectorFieldRenderer.js +1 -1
  131. package/renderers/support/RasterSymbolizer.js +1 -1
  132. package/renderers/support/rasterRendererHelper.js +1 -1
  133. package/rest/locator/addressToLocations.js +1 -1
  134. package/rest/locator/addressesToLocations.js +1 -1
  135. package/rest/locator/suggestLocations.js +1 -1
  136. package/rest/networks/support/Association.js +1 -1
  137. package/rest/print.js +1 -1
  138. package/rest/support/LegendLayer.js +1 -1
  139. package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
  140. package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
  141. package/support/revision.js +1 -1
  142. package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
  143. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
  144. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/MaskShader.js +1 -1
  145. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
  146. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  147. package/views/2d/layers/ImageryLayerView2D.js +1 -1
  148. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  149. package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
  150. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  151. package/views/2d/layers/imagery/ImageryView2D.js +1 -1
  152. package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
  153. package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
  154. package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
  155. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  156. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  157. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  158. package/views/3d/layers/graphics/pipeline/rendering/DirectRenderer.js +1 -1
  159. package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
  160. package/views/3d/layers/graphics/pipeline/symbolization/IconSymbolLayerRenderer.js +1 -1
  161. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  162. package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
  163. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  164. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
  165. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
  166. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  167. package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
  168. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  169. package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
  170. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  171. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  172. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  173. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  174. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  175. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  176. package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
  177. package/views/3d/webgl-engine/materials/renderers/Instance.js +1 -1
  178. package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
  179. package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
  180. package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
  181. package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
  182. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  183. package/views/3d/webgl-engine/shaders/GaussianSplatColorTechnique.js +5 -0
  184. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +5 -0
  185. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  186. package/views/DOMContainer.js +1 -1
  187. package/views/GroundView.js +1 -1
  188. package/views/layers/ImageryLayerViewMixin.js +1 -1
  189. package/views/layers/ImageryTileLayerViewMixin.js +1 -1
  190. package/views/support/imageReprojection.js +1 -1
  191. package/widgets/BatchAttributeForm.js +1 -1
  192. package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
  193. package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
  194. package/widgets/CoordinateConversion.js +1 -1
  195. package/widgets/DirectLineMeasurement3D.js +1 -1
  196. package/widgets/DistanceMeasurement2D.js +1 -1
  197. package/widgets/Editor/EditorViewModel.js +1 -1
  198. package/widgets/Editor.js +1 -1
  199. package/widgets/ElevationProfile.js +1 -1
  200. package/widgets/Feature.js +1 -1
  201. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  202. package/widgets/FeatureForm.js +1 -1
  203. package/widgets/FeatureTable/AttachmentsColumn.js +1 -1
  204. package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
  205. package/widgets/FeatureTable/Grid/Column.js +1 -1
  206. package/widgets/FeatureTable/Grid/EditorColumn.js +1 -1
  207. package/widgets/FeatureTable/Grid/Grid.js +1 -1
  208. package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
  209. package/widgets/FeatureTable/support/FeatureStore.js +1 -1
  210. package/widgets/FeatureTable/support/GroupColumnTemplate.js +1 -1
  211. package/widgets/FeatureTable/support/TableTemplate.js +1 -1
  212. package/widgets/FeatureTable.js +1 -1
  213. package/widgets/FeatureTemplates.js +1 -1
  214. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  215. package/widgets/Legend.js +1 -1
  216. package/widgets/LineOfSight.js +1 -1
  217. package/widgets/Locate.js +1 -1
  218. package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
  219. package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
  220. package/widgets/PanoramicViewer/support/importUtils.js +1 -1
  221. package/widgets/Print/CustomTemplate.js +1 -1
  222. package/widgets/Print/PrintViewModel.js +1 -1
  223. package/widgets/Print/TemplateOptions.js +1 -1
  224. package/widgets/Print.js +1 -1
  225. package/widgets/ScaleBar.js +1 -1
  226. package/widgets/ScaleRangeSlider.js +1 -1
  227. package/widgets/Search/SearchResultRenderer.js +1 -1
  228. package/widgets/Search/SearchViewModel.js +1 -1
  229. package/widgets/Search/types.js +1 -1
  230. package/widgets/Search.js +1 -1
  231. package/widgets/ShadowCast.js +1 -1
  232. package/widgets/Sketch/SketchViewModel.js +1 -1
  233. package/widgets/Sketch.js +1 -1
  234. package/assets/esri/core/workers/chunks/1f6ead46b723630db897.js +0 -1
  235. package/assets/esri/core/workers/chunks/3a16347e17312556e02c.js +0 -1
  236. package/assets/esri/core/workers/chunks/478def691ae6763686f3.js +0 -1
  237. package/assets/esri/core/workers/chunks/4c4a55be41ba105c091c.js +0 -1
  238. package/assets/esri/core/workers/chunks/4cbf5a97b2b3c6553f6f.js +0 -1
  239. package/assets/esri/core/workers/chunks/646f58b69d2354f1ef27.js +0 -1
  240. package/assets/esri/core/workers/chunks/93d11075f65a5b6625ea.js +0 -1
  241. package/assets/esri/core/workers/chunks/96f798ee286b59396131.js +0 -316
  242. package/assets/esri/core/workers/chunks/9f2a8445a5848502c7e7.js +0 -1
  243. package/assets/esri/core/workers/chunks/a1b08aab73747f4e7e25.js +0 -1
  244. package/assets/esri/core/workers/chunks/ba59568e748f0ba53b78.js +0 -1
  245. package/assets/esri/core/workers/chunks/f21cb5b34d4d1e3af1a9.js +0 -1
  246. package/assets/esri/core/workers/chunks/f93f0586ce10cb5d98b3.js +0 -1
  247. package/layers/support/rasterDatasets/BaseRaster.js +0 -5
  248. package/layers/support/rasterDatasets/CovJSONRaster.js +0 -5
  249. package/layers/support/rasterDatasets/FunctionRaster.js +0 -5
  250. package/layers/support/rasterDatasets/ImageAuxRaster.js +0 -5
  251. package/layers/support/rasterDatasets/ImageServerRaster.js +0 -5
  252. package/layers/support/rasterDatasets/InMemoryRaster.js +0 -5
  253. package/layers/support/rasterDatasets/MRFRaster.js +0 -5
  254. package/layers/support/rasterDatasets/RawBlockCache.js +0 -5
  255. package/layers/support/rasterDatasets/TIFFRaster.js +0 -5
  256. package/layers/support/rasterDatasets/WCSRaster.js +0 -5
  257. package/layers/support/rasterDatasets/covJSONParser.js +0 -5
  258. package/layers/support/rasterDatasets/multidimensionalUtils.js +0 -5
  259. package/layers/support/rasterDatasets/pamParser.js +0 -5
  260. package/layers/support/rasterDatasets/pixelReader.js +0 -5
  261. package/layers/support/rasterDatasets/wcsCoverageParser.js +0 -5
  262. package/layers/support/rasterFormats/Lerc.js +0 -5
  263. package/layers/support/rasterFormats/Qb3.js +0 -5
  264. package/layers/support/rasterFormats/RasterCodec.js +0 -5
  265. package/layers/support/rasterFormats/TiffDecoder.js +0 -5
  266. package/layers/support/rasterFunctions/ArithmeticFunction.js +0 -5
  267. package/layers/support/rasterFunctions/BandArithmeticFunction.js +0 -5
  268. package/layers/support/rasterFunctions/BaseRasterFunction.js +0 -5
  269. package/layers/support/rasterFunctions/ColormapFunction.js +0 -5
  270. package/layers/support/rasterFunctions/ColormapToRGBFunction.js +0 -5
  271. package/layers/support/rasterFunctions/CompositeBandFunction.js +0 -5
  272. package/layers/support/rasterFunctions/CompositeBandFunctionArguments.js +0 -5
  273. package/layers/support/rasterFunctions/ComputeChangeFunction.js +0 -5
  274. package/layers/support/rasterFunctions/ConvolutionFunction.js +0 -5
  275. package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +0 -5
  276. package/layers/support/rasterFunctions/HillshadeFunction.js +0 -5
  277. package/layers/support/rasterFunctions/LocalFunction.js +0 -5
  278. package/layers/support/rasterFunctions/RemapFunction.js +0 -5
  279. package/layers/support/rasterFunctions/ShadedReliefFunction.js +0 -5
  280. package/layers/support/rasterFunctions/SlopeFunction.js +0 -5
  281. package/layers/support/rasterFunctions/StatisticsFunction.js +0 -5
  282. package/layers/support/rasterFunctions/StretchFunction.js +0 -5
  283. package/layers/support/rasterFunctions/bandIndexUtils.js +0 -5
  284. package/layers/support/rasterFunctions/changeDetectionUtils.js +0 -5
  285. package/layers/support/rasterFunctions/clipUtils.js +0 -5
  286. package/layers/support/rasterFunctions/conversionUtils.js +0 -5
  287. package/layers/support/rasterFunctions/convolutionUtils.js +0 -5
  288. package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +0 -5
  289. package/layers/support/rasterFunctions/creators/utils.js +0 -5
  290. package/layers/support/rasterFunctions/focalStatUtils.js +0 -5
  291. package/layers/support/rasterFunctions/localUtils.js +0 -5
  292. package/layers/support/rasterFunctions/pixelTransformUtils.js +0 -5
  293. package/layers/support/rasterFunctions/pixelUtils.js +0 -5
  294. package/layers/support/rasterFunctions/stretchUtils.js +0 -5
  295. package/layers/support/rasterFunctions/surfaceUtils.js +0 -5
  296. package/layers/support/rasterFunctions/vectorFieldUtils.js +0 -5
  297. package/layers/support/rasterTransforms/BaseRasterTransform.js +0 -5
  298. /package/assets/esri/layers/{support/rasterFormats → raster/formats}/lerc-wasm.wasm +0 -0
  299. /package/assets/esri/layers/{support/rasterFormats → raster/formats}/qb3-wasm.wasm +0 -0
  300. /package/layers/{support/rasterDatasets → raster/datasets}/DBFParser.js +0 -0
  301. /package/layers/{support/rasterDatasets → raster/datasets}/EphemeralBlockCache.js +0 -0
  302. /package/layers/{support/rasterDatasets → raster/datasets}/RasterFactory.js +0 -0
  303. /package/layers/{support/rasterDatasets → raster/datasets}/byteStreamUtils.js +0 -0
  304. /package/layers/{support/rasterDatasets → raster/datasets}/datasetUtils.js +0 -0
  305. /package/layers/{support/rasterDatasets → raster/datasets}/multipartParser.js +0 -0
  306. /package/layers/{support/rasterDatasets → raster/datasets}/wcsCapabilitiesParser.js +0 -0
  307. /package/layers/{support/rasterDatasets → raster/datasets}/xmlUtilities.js +0 -0
  308. /package/layers/{support/rasterFormats → raster/formats}/ImageCanvasDecoder.js +0 -0
  309. /package/layers/{support/rasterFormats → raster/formats}/JpgPlus.js +0 -0
  310. /package/layers/{support/rasterFormats → raster/formats}/Lzw.js +0 -0
  311. /package/layers/{support/rasterFormats → raster/formats}/Raw.js +0 -0
  312. /package/layers/{support/rasterFormats → raster/formats}/pixelRangeUtils.js +0 -0
  313. /package/layers/{support/rasterFormats → raster/formats}/tiffTag.js +0 -0
  314. /package/layers/{support/rasterFormats → raster/formats}/utils.js +0 -0
  315. /package/layers/{support/rasterFunctions → raster/functions}/colormaps.js +0 -0
  316. /package/layers/{support/rasterFunctions → raster/functions}/creators/createAppearenceFunctions.js +0 -0
  317. /package/layers/{support/rasterFunctions → raster/functions}/creators/createBandIndexFunctions.js +0 -0
  318. /package/layers/{support/rasterFunctions → raster/functions}/creators/createChangeFunctions.js +0 -0
  319. /package/layers/{support/rasterFunctions → raster/functions}/creators/createConversionFunctions.js +0 -0
  320. /package/layers/{support/rasterFunctions → raster/functions}/creators/createLocalFunctions.js +0 -0
  321. /package/layers/{support/rasterFunctions → raster/functions}/creators/createMultiRasterAnalysisFunctions.js +0 -0
  322. /package/layers/{support/rasterFunctions → raster/functions}/creators/createStatisticsFunctions.js +0 -0
  323. /package/layers/{support/rasterFunctions → raster/functions}/creators/createSurfaceFunctions.js +0 -0
  324. /package/layers/{support/rasterFunctions → raster/functions}/customBandIndexUtils.js +0 -0
  325. /package/layers/{support/rasterFunctions → raster/functions}/mirror.js +0 -0
  326. /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionHelper.js +0 -0
  327. /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionSchema.js +0 -0
  328. /package/layers/{support/rasterFunctions → raster/functions}/rasterProjectionHelper.js +0 -0
  329. /package/layers/{support/rasterTransforms → raster/transforms}/utils.js +0 -0
@@ -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 t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{assertIsSome as s}from"../../../../core/maybe.js";import{debounce as r,isAbortError as a}from"../../../../core/promiseUtils.js";import{property as o,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as n}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../geometry/Extent.js";import c from"../../../../geometry/Point.js";import u from"../../../../layers/support/PixelBlock.js";import d from"../../../../layers/support/TileInfo.js";import{update as p,unregister as y,getRasterId as m,register as g}from"../../../../layers/support/rasterDatasets/RawBlockCache.js";import{getWorldWidth as _,computeProjectedScales as f}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import b from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import w from"../../tiling/TileQueue.js";import P from"../../tiling/TileStrategy.js";import{tileSize as I}from"../../engine/webgl/definitions.js";import{TaskPriority as R}from"../../../support/Scheduler.js";import{getWebGLCapabilities as U}from"../../../webgl/capabilities.js";const C=[0,0];let S=class extends t{constructor(){super(...arguments),this._updatingHandles=new n,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=r(async(e={})=>{const t=this._rasterFunctionState,i=e.reprocess||"gpu"===t&&!this.canUseWebGLForProcessing||"cpu"===t&&this.canUseWebGLForProcessing;if(i&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters()),!this.previousLOD||this.layerView.suspended)return;const s=this._rasterFunctionState,{type:r}=this;return e.refetch||"raster"!==r&&!!i||"cpu"===s||"cpu"===t?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(e.signal))})}destroy(){this._updatingHandles.destroy()}get canUseWebGLForProcessing(){return!1}get canUseLocalSymbolizerParams(){return(this.canUseWebGLForProcessing||"rasterVF"===this.type)&&!this.layerView.hasTilingEffects}get isCPUBasedDRA(){const{renderer:e}=this.layer;return"raster-stretch"===e?.type&&e.dynamicRangeAdjustment&&(!this.canUseWebGLForProcessing||!("min-max"===e.stretchType||"standard-deviation"===e.stretchType))}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new P({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s="toJSON"in t?t:h.fromJSON(t);p(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null!=this._symbolizerParams&&this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.isCPUBasedDRA&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then(()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()}));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._globalUpdateRequested||this._updatingHandles?.updating}attach(){const e=U();this._maxIndexedColormapSize=4*(e.maxTextureSize||4096),this._initializeTileInfo(),this._tileInfoView=new b(this.layerView.tileInfo,this.layerView.fullExtent);const t=this._computeFetchConcurrency();this._fetchQueue=new w({tileInfoView:this._tileInfoView,concurrency:t,process:(e,t)=>this._fetchTile(e,t),priority:R.MAPVIEW_FETCH_QUEUE,scheduler:this.scheduler});const i=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new P({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:i,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,y(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._updatingHandles.addPromise(this._enqueueTileFetch(t)),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.isCPUBasedDRA||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",()=>{e.destroy(),this.layerView.requestUpdate()}),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&null!=this._emptyTilePixelBlock)return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,s]=e,r=new u({width:i,height:s,pixels:[new Uint8Array(i*s)],mask:new Uint8Array(i*s),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=r),r}_getBandIds(){if(this.container&&(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain))return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map(e=>i[Math.min(e,i.length-1)]):"rasterFunction"in t?i:e}updateRasterFunctionParameters(){}_fetchTile(e,t){const i=this._getFetchOptions(e.level,t.signal);return this.fetchTile(e,i)}_getFetchOptions(e,t){const{canUseWebGLForProcessing:i}=this,{layerView:s}=this,{tileInfo:r}=s,a=!r.isWrappable&&null!=_(s.view.spatialReference),o=i&&this.layer.raster.hasUniqueSourceStorageInfo,{layer:l}=this.layerView,n=l.serviceRasterInfo?.storageInfo.isBsqTile?l.getRawDisplayBandIds():void 0;return{allowPartialFill:!0,datumTransformation:s.datumTransformation,interpolation:i?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:o,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:t,srcResolution:this._srcResolutions[e],timeExtent:s.timeExtent,tileInfo:r,bandIds:n,disableWrapAround:a}}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference;if(this._canUseLayerLODs()){const{origin:i,lods:s}=this.layer.tileInfo,r=s.map(({scale:e})=>e),a=d.create({spatialReference:t,size:I,scales:r,origin:i});return e.set("tileInfo",a),void(this._srcResolutions=s.map(({resolution:e})=>({x:e,y:e})))}const{scales:i,srcResolutions:r,isCustomTilingScheme:a}=f(this.layer.serviceRasterInfo,t,{tileSize:I,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:!1}),o=d.create({spatialReference:t,size:I,scales:i}),l=0===o.origin.x;s(e.fullExtent);const{xmin:n,ymax:h}=e.fullExtent;(l||a&&o.origin.x>n)&&(o.origin=new c({x:n,y:h,spatialReference:t})),this._isCustomTilingScheme=a,e.set("tileInfo",o),this._srcResolutions=r??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;return s?.length===i.length&&s.every(({scale:e},t)=>Math.abs(e-i[t].scale)<.001)}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.serviceRasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){if(!this._fetchQueue.has(e.key.id)){try{let t=e.once("detach",()=>t=void 0);const r=await this._fetchQueue.push(e.key),o=this._getBandIds();let l=!this.useProgressiveUpdate||this.isCPUBasedDRA&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){l=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){a(s)&&i.getLogger(this).error(s)}this._globalUpdateRequested=!1}if(!t)return;this.canUseLocalSymbolizerParams&&null==this._symbolizerParams&&this._updateSymbolizerParams();const n=this._tileInfoView.getTileCoords(C,e.key),h=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:r,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:l,bandIds:o,coords:n,resolution:h}),t&&(e.once("attach",()=>this.layerView.requestUpdate()),this.container.addChild(e),t.remove())}catch(s){a(s)||i.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(!this.attached||0===this.container.children.length)return;if(await this.layer.updateRenderer(),this.isCPUBasedDRA?await this._updateGlobalSymbolizerParams(e):(this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._globalSymbolizerParams=null),!this.attached||e?.aborted)return;const t=this.container.children.map(async t=>this.updateTileSymbolizerParameters(t,{local:this._symbolizerParams,global:this._globalSymbolizerParams},e));await Promise.allSettled(t),this.attached&&!e?.aborted&&this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t=this._getFetchOptions(this.previousLOD.level,e),i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,{...t,interpolation:"nearest",requestRawData:!1,skipRasterFunction:!1});if(!i?.pixelBlock)return;const{resolution:s}=this.previousLOD,{isBsqTile:r}=this.layer.raster.rasterInfo.storageInfo,a=r?null:this._getBandIds(),o=this.layer.symbolizer.generateWebGLParameters({pixelBlock:i.pixelBlock.extractBands(a),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:a});!this.canUseWebGLForProcessing&&o&&"stretch"===o.type&&"raster-stretch"===this.layer.renderer?.type&&(o.factor=o.factor.map(e=>255*e),o.minOutput=Math.round(255*o.minOutput),o.maxOutput=Math.round(255*o.maxOutput)),this._globalSymbolizerParams=o}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{raster:s}=t,{multidimensionalDefinition:r}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),a=s.rasterInfo.multidimensionalInfo?s.getSliceIndex(r):null,o=s.rasterInfo.storageInfo.isBsqTile?t.getRawDisplayBandIds():null,l=m(s.rasterId,a,o);if(l!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&y(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=g(l,s.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),r=this._srcResolutions[t.level];p(l,this._blockCacheRegistryId,e.extent,e.resolution,r,s.ioConfig.sampling)}this._blockCacheRegistryUrl=l}}async doRefresh(){if(!this.attached||!this.previousLOD||this.layerView.suspended)return;await this.layer.updateRenderer(),this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.isCPUBasedDRA||!this.useProgressiveUpdate,this._tileStrategy.refresh(t=>e.push(this._enqueueTileFetch(t))),await this._updatingHandles.addPromise(Promise.allSettled(e))}};e([o()],S.prototype,"_globalUpdateRequested",void 0),e([o()],S.prototype,"attached",void 0),e([o()],S.prototype,"canUseWebGLForProcessing",null),e([o()],S.prototype,"canUseLocalSymbolizerParams",null),e([o()],S.prototype,"isCPUBasedDRA",null),e([o()],S.prototype,"container",void 0),e([o()],S.prototype,"layer",void 0),e([o()],S.prototype,"layerView",void 0),e([o()],S.prototype,"scheduler",void 0),e([o()],S.prototype,"type",void 0),e([o()],S.prototype,"useWebGLForProcessing",null),e([o()],S.prototype,"useProgressiveUpdate",null),e([o()],S.prototype,"timeExtent",void 0),e([o()],S.prototype,"updating",null),S=e([l("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],S);export{S as BaseImageryTileSubView2D};
5
+ import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import i from"../../../../core/Logger.js";import{assertIsSome as s}from"../../../../core/maybe.js";import{debounce as r,isAbortError as a}from"../../../../core/promiseUtils.js";import{property as o,subclass as l}from"../../../../core/accessorSupport/decorators.js";import{UpdatingHandles as n}from"../../../../core/support/UpdatingHandles.js";import h from"../../../../geometry/Extent.js";import c from"../../../../geometry/Point.js";import{update as u,unregister as d,getRasterId as p,register as y}from"../../../../layers/raster/datasets/RawBlockCache.js";import{getWorldWidth as m,computeProjectedScales as g}from"../../../../layers/raster/functions/rasterProjectionHelper.js";import _ from"../../../../layers/support/PixelBlock.js";import f from"../../../../layers/support/TileInfo.js";import b from"../../tiling/TileInfoView.js";import"../../tiling/TileKey.js";import w from"../../tiling/TileQueue.js";import P from"../../tiling/TileStrategy.js";import{tileSize as I}from"../../engine/webgl/definitions.js";import{TaskPriority as R}from"../../../support/Scheduler.js";import{getWebGLCapabilities as U}from"../../../webgl/capabilities.js";const C=[0,0];let S=class extends t{constructor(){super(...arguments),this._updatingHandles=new n,this._emptyTilePixelBlock=null,this._tileStrategy=null,this._tileInfoView=null,this._fetchQueue=null,this._blockCacheRegistryUrl=null,this._blockCacheRegistryId=null,this._srcResolutions=[],this.previousLOD=null,this._needBlockCacheUpdate=!1,this._globalSymbolizerParams=null,this._symbolizerParams=null,this._abortController=null,this._isCustomTilingScheme=!1,this._maxIndexedColormapSize=0,this._rasterFunctionState="na",this._globalUpdateRequested=!1,this.attached=!1,this.timeExtent=null,this.redrawOrRefetch=r(async(e={})=>{const t=this._rasterFunctionState,i=e.reprocess||"gpu"===t&&!this.canUseWebGLForProcessing||"cpu"===t&&this.canUseWebGLForProcessing;if(i&&(await this._updatingHandles.addPromise(this.layer.updateRasterFunction()),this.updateRasterFunctionParameters()),!this.previousLOD||this.layerView.suspended)return;const s=this._rasterFunctionState,{type:r}=this;return e.refetch||"raster"!==r&&!!i||"cpu"===s||"cpu"===t?this._updatingHandles.addPromise(this.doRefresh()):this._updatingHandles.addPromise(this._redrawImage(e.signal))})}destroy(){this._updatingHandles.destroy()}get canUseWebGLForProcessing(){return!1}get canUseLocalSymbolizerParams(){return(this.canUseWebGLForProcessing||"rasterVF"===this.type)&&!this.layerView.hasTilingEffects}get isCPUBasedDRA(){const{renderer:e}=this.layer;return"raster-stretch"===e?.type&&e.dynamicRangeAdjustment&&(!this.canUseWebGLForProcessing||!("min-max"===e.stretchType||"standard-deviation"===e.stretchType))}get useWebGLForProcessing(){return this._get("useWebGLForProcessing")??!0}set useWebGLForProcessing(e){this._set("useWebGLForProcessing",e)}get useProgressiveUpdate(){return this._get("useProgressiveUpdate")??!0}set useProgressiveUpdate(e){if(this._tileStrategy&&this.useProgressiveUpdate!==e){this._tileStrategy.destroy(),this.container.removeAllChildren();const t=this._getCacheSize(e);this._tileStrategy=new P({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:t,tileInfoView:this._tileInfoView}),this._set("useProgressiveUpdate",e),this.layerView.requestUpdate()}}update(e){this._fetchQueue.pause(),this._fetchQueue.state=e.state,this._tileStrategy.update(e),this._fetchQueue.resume();const{extent:t,resolution:i,scale:s}=e.state,r=this._tileInfoView.getClosestInfoForScale(s);if(this.layer.raster){if(!this.useProgressiveUpdate||this._needBlockCacheUpdate){const e=this._srcResolutions[r.level],s="toJSON"in t?t:h.fromJSON(t);u(this._blockCacheRegistryUrl,this._blockCacheRegistryId,s,i,e,this.layer.raster.ioConfig.sampling)}this._needBlockCacheUpdate=!1,this.previousLOD?.level!==r.level&&(this.previousLOD=r,null!=this._symbolizerParams&&this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._tileStrategy.updateCacheSize(0))}}moveEnd(){!this.isCPUBasedDRA&&this.useProgressiveUpdate||(this._abortController&&this._abortController.abort(),this._abortController=new AbortController,0===this._fetchQueue.length&&this._redrawImage(this._abortController.signal).then(()=>{this._globalUpdateRequested=!1,this.layerView.requestUpdate()}));const e=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy.updateCacheSize(e),this.layerView.requestUpdate()}get updating(){return this._globalUpdateRequested||this._updatingHandles?.updating}attach(){const e=U();this._maxIndexedColormapSize=4*(e.maxTextureSize||4096),this._initializeTileInfo(),this._tileInfoView=new b(this.layerView.tileInfo,this.layerView.fullExtent);const t=this._computeFetchConcurrency();this._fetchQueue=new w({tileInfoView:this._tileInfoView,concurrency:t,process:(e,t)=>this._fetchTile(e,t),priority:R.MAPVIEW_FETCH_QUEUE,scheduler:this.scheduler});const i=this._getCacheSize(this.useProgressiveUpdate);this._tileStrategy=new P({cachePolicy:"purge",acquireTile:e=>this.acquireTile(e),releaseTile:e=>this.releaseTile(e),cacheSize:i,tileInfoView:this._tileInfoView}),this._updateBlockCacheRegistry()}detach(){this._tileStrategy.destroy(),this._fetchQueue.clear(),this.container.removeAllChildren(),this._fetchQueue=this._tileStrategy=this._tileInfoView=null,d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryUrl=this._blockCacheRegistryId=null}acquireTile(e){const t=this.container.createTile(e);return this._updatingHandles.addPromise(this._enqueueTileFetch(t)),this.layerView.requestUpdate(),this._needBlockCacheUpdate=!0,this._globalUpdateRequested=this.isCPUBasedDRA||!this.useProgressiveUpdate,t}releaseTile(e){this._fetchQueue.abort(e.key.id),this.container.removeChild(e),e.once("detach",()=>{e.destroy(),this.layerView.requestUpdate()}),this.layerView.requestUpdate()}createEmptyTilePixelBlock(e=null){const t=null==e||e.join(",")===this._tileInfoView.tileInfo.size.join(",");if(t&&null!=this._emptyTilePixelBlock)return this._emptyTilePixelBlock;e=e||this._tileInfoView.tileInfo.size;const[i,s]=e,r=new _({width:i,height:s,pixels:[new Uint8Array(i*s)],mask:new Uint8Array(i*s),pixelType:"u8"});return t&&(this._emptyTilePixelBlock=r),r}_getBandIds(){if(this.container&&(!("rasterFunctionChain"in this.container)||!this.container.rasterFunctionChain))return this.layer.bandIds;const{bandIds:e,raster:t}=this.layer,i="rasterFunction"in t?t.rasterFunction.rawInputBandIds:null;return e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map(e=>i[Math.min(e,i.length-1)]):"rasterFunction"in t?i:e}updateRasterFunctionParameters(){}_fetchTile(e,t){const i=this._getFetchOptions(e.level,t.signal);return this.fetchTile(e,i)}_getFetchOptions(e,t){const{canUseWebGLForProcessing:i}=this,{layerView:s}=this,{tileInfo:r}=s,a=!r.isWrappable&&null!=m(s.view.spatialReference),o=i&&this.layer.raster.hasUniqueSourceStorageInfo,{layer:l}=this.layerView,n=l.serviceRasterInfo?.storageInfo.isBsqTile?l.getRawDisplayBandIds():void 0;return{allowPartialFill:!0,datumTransformation:s.datumTransformation,interpolation:i?"nearest":this.layer.interpolation,registryId:this._blockCacheRegistryId,requestRawData:o,skipRasterFunction:"raster"===this.type&&null!=this.container.rasterFunctionChain,signal:t,srcResolution:this._srcResolutions[e],timeExtent:s.timeExtent,tileInfo:r,bandIds:n,disableWrapAround:a}}_getCacheSize(e){return e?40:0}_initializeTileInfo(){const{layerView:e}=this,t=e.view.spatialReference;if(this._canUseLayerLODs()){const{origin:i,lods:s}=this.layer.tileInfo,r=s.map(({scale:e})=>e),a=f.create({spatialReference:t,size:I,scales:r,origin:i});return e.set("tileInfo",a),void(this._srcResolutions=s.map(({resolution:e})=>({x:e,y:e})))}const{scales:i,srcResolutions:r,isCustomTilingScheme:a}=g(this.layer.serviceRasterInfo,t,{tileSize:I,alignGlobalDatasetWithAGOL:!0,limitToSrcResolution:!1}),o=f.create({spatialReference:t,size:I,scales:i}),l=0===o.origin.x;s(e.fullExtent);const{xmin:n,ymax:h}=e.fullExtent;(l||a&&o.origin.x>n)&&(o.origin=new c({x:n,y:h,spatialReference:t})),this._isCustomTilingScheme=a,e.set("tileInfo",o),this._srcResolutions=r??[]}_canUseLayerLODs(){const{layer:e,layerView:t}=this;if("Map"!==e.raster.tileType)return!1;const{lods:i}=e.tileInfo,s=t.view.constraints?.effectiveLODs;return s?.length===i.length&&s.every(({scale:e},t)=>Math.abs(e-i[t].scale)<.001)}_computeFetchConcurrency(){const{blockBoundary:e}=this.layer.serviceRasterInfo.storageInfo,t=e[e.length-1];return(t.maxCol-t.minCol+1)*(t.maxRow-t.minRow+1)>64?2:10}async _enqueueTileFetch(e,t){if(!this._fetchQueue.has(e.key.id)){try{let t=e.once("detach",()=>t=void 0);const r=await this._fetchQueue.push(e.key),o=this._getBandIds();let l=!this.useProgressiveUpdate||this.isCPUBasedDRA&&!this._globalSymbolizerParams;if(this._globalUpdateRequested&&!this.layerView.moving&&0===this._fetchQueue.length){l=!1;try{await this._redrawImage(this._abortController?.signal)}catch(s){a(s)&&i.getLogger(this).error(s)}this._globalUpdateRequested=!1}if(!t)return;this.canUseLocalSymbolizerParams&&null==this._symbolizerParams&&this._updateSymbolizerParams();const n=this._tileInfoView.getTileCoords(C,e.key),h=this._tileInfoView.getTileResolution(e.key);await this.updateTileSource(e,{source:r,symbolizerParams:this._symbolizerParams,globalSymbolizerParams:this._globalSymbolizerParams,suspended:l,bandIds:o,coords:n,resolution:h}),t&&(e.once("attach",()=>this.layerView.requestUpdate()),this.container.addChild(e),t.remove())}catch(s){a(s)||i.getLogger(this).error(s)}this.layerView.requestUpdate()}}async _redrawImage(e){if(!this.attached||0===this.container.children.length)return;if(await this.layer.updateRenderer(),this.isCPUBasedDRA?await this._updateGlobalSymbolizerParams(e):(this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._globalSymbolizerParams=null),!this.attached||e?.aborted)return;const t=this.container.children.map(async t=>this.updateTileSymbolizerParameters(t,{local:this._symbolizerParams,global:this._globalSymbolizerParams},e));await Promise.allSettled(t),this.attached&&!e?.aborted&&this.container.requestRender()}async _updateGlobalSymbolizerParams(e){const t=this._getFetchOptions(this.previousLOD.level,e),i=await this.layer.fetchPixels(this.layerView.view.extent,this.layerView.view.width,this.layerView.view.height,{...t,interpolation:"nearest",requestRawData:!1,skipRasterFunction:!1});if(!i?.pixelBlock)return;const{resolution:s}=this.previousLOD,{isBsqTile:r}=this.layer.raster.rasterInfo.storageInfo,a=r?null:this._getBandIds(),o=this.layer.symbolizer.generateWebGLParameters({pixelBlock:i.pixelBlock.extractBands(a),isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:s,y:s},bandIds:a});!this.canUseWebGLForProcessing&&o&&"stretch"===o.type&&"raster-stretch"===this.layer.renderer?.type&&(o.factor=o.factor.map(e=>255*e),o.minOutput=Math.round(255*o.minOutput),o.maxOutput=Math.round(255*o.maxOutput)),this._globalSymbolizerParams=o}_updateSymbolizerParams(){const{resolution:e}=this.previousLOD,t=this._getBandIds();this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null,isGCS:this.layerView.view.spatialReference.isGeographic,resolution:{x:e,y:e},bandIds:t})}_updateBlockCacheRegistry(e=!1){const{layer:t,layerView:i}=this,{raster:s}=t,{multidimensionalDefinition:r}=t.normalizeRasterFetchOptions({multidimensionalDefinition:t.multidimensionalDefinition,timeExtent:i.timeExtent}),a=s.rasterInfo.multidimensionalInfo?s.getSliceIndex(r):null,o=s.rasterInfo.storageInfo.isBsqTile?t.getRawDisplayBandIds():null,l=p(s.rasterId,a,o);if(l!==this._blockCacheRegistryUrl){if(null!=this._blockCacheRegistryUrl&&d(this._blockCacheRegistryUrl,this._blockCacheRegistryId),this._blockCacheRegistryId=y(l,s.rasterInfo),e){const{view:e}=i,t=this._tileInfoView.getClosestInfoForScale(e.scale),r=this._srcResolutions[t.level];u(l,this._blockCacheRegistryId,e.extent,e.resolution,r,s.ioConfig.sampling)}this._blockCacheRegistryUrl=l}}async doRefresh(){if(!this.attached||!this.previousLOD||this.layerView.suspended)return;await this.layer.updateRenderer(),this.canUseLocalSymbolizerParams&&this._updateSymbolizerParams(),this._updateBlockCacheRegistry(!0),this._fetchQueue.reset();const e=[];this._globalUpdateRequested=this.isCPUBasedDRA||!this.useProgressiveUpdate,this._tileStrategy.refresh(t=>e.push(this._enqueueTileFetch(t))),await this._updatingHandles.addPromise(Promise.allSettled(e))}};e([o()],S.prototype,"_globalUpdateRequested",void 0),e([o()],S.prototype,"attached",void 0),e([o()],S.prototype,"canUseWebGLForProcessing",null),e([o()],S.prototype,"canUseLocalSymbolizerParams",null),e([o()],S.prototype,"isCPUBasedDRA",null),e([o()],S.prototype,"container",void 0),e([o()],S.prototype,"layer",void 0),e([o()],S.prototype,"layerView",void 0),e([o()],S.prototype,"scheduler",void 0),e([o()],S.prototype,"type",void 0),e([o()],S.prototype,"useWebGLForProcessing",null),e([o()],S.prototype,"useProgressiveUpdate",null),e([o()],S.prototype,"timeExtent",void 0),e([o()],S.prototype,"updating",null),S=e([l("esri.views.2d.layers.imagery.BaseImageryTileSubView2D")],S);export{S as BaseImageryTileSubView2D};
@@ -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 t from"../../../../Color.js";import has from"../../../../core/has.js";import{numberMaxFloat32 as r}from"../../../../core/mathUtils.js";import{property as s,subclass as i}from"../../../../core/accessorSupport/decorators.js";import{isFunctionRaster as o}from"../../../../layers/support/rasterDatasets/datasetUtils.js";import{getBytesPerPixel as n}from"../../../../layers/support/rasterFormats/pixelRangeUtils.js";import{convertGeometryToMask as a}from"../../../../layers/support/rasterFunctions/clipUtils.js";import{maxMapSizeGpu as l}from"../../../../layers/support/rasterFunctions/pixelUtils.js";import{RasterTileContainer as c}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as p}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as u}from"../support/util.js";import{defaultColor as h}from"../../../support/HighlightDefaults.js";import{getHighlightName as d}from"../../../support/highlightOptionsUtils.js";const m=[1024,1024];let y=class extends p{constructor(){super(...arguments),this.type="raster"}get canUseWebGLForProcessing(){const{loaded:e,symbolizer:t}=this.layer;if(!e||!t)return!1;const r=t.lookup.colormapLut?.indexedColormap,s=r&&r.length>this._maxIndexedColormapSize,i=n(this.layer.serviceRasterInfo);return!(has("ios")&&i>4)&&this.useWebGLForProcessing&&t.canRenderInWebGL&&!s&&!("majority"===this.layer.interpolation&&u(this.layer))}attach(){super.attach(),this.container=new c(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}fetchTile(e,t){return this.layer.fetchTile(e.level,e.row,e.col,t)}updateRasterFunctionParameters(){const{raster:e,type:t}=this.layer,{container:r}=this;if("Function"!==e.datasetFormat||"wcs"===t)return r.rasterFunctionChain=null,r.children.forEach(e=>{const{bitmap:t}=e;t&&(t.suspended=!0,t.processed=!1,t.projected&&(t.invalidateTexture(),t.rasterTexture=null))}),void(this._rasterFunctionState="na");const s=this._rasterFunctionState,{rasterFunction:i,primaryRasters:o}=e,n=i.supportsGPU&&(!o||o.rasters.length<=1),a=n?i.flatWebGLFunctionChain:null,{renderer:l}=this.layer,c=!n||!a?.functions.length||"raster-stretch"===l?.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing;r.rasterFunctionChain=c?null:this._addProjection(a);const p=null==i?"na":r.rasterFunctionChain?"gpu":"cpu",u=s===p||"na"===s&&"cpu"===p&&0===a?.functions?.length;r.children.forEach(e=>{const{bitmap:t}=e;t&&(t.suspended=!u,t.processed=!1,t.processedTexture=null)}),this._rasterFunctionState=p}async updateTileSource(e,t){const r=this._getBandIds(),s=this._getLayerInterpolation(),{canUseWebGLForProcessing:i}=this,{source:n,globalSymbolizerParams:l,suspended:c,coords:p,resolution:u}=t,h=this.isCPUBasedDRA?l:t.symbolizerParams,{bitmap:d}=e;if([d.x,d.y]=p,d.resolution=u,null!=n?.pixelBlock){const e={extent:n.extent,pixelBlock:n.pixelBlock,srcPixelSize:n.srcTilePixelSize};if(d.rawPixelData=e,i)d.source=n.pixelBlock,d.isRendereredSource=!1;else{const t=await this.layer.applyRenderer(e,"stretch"===l?.type?l:void 0);d.source=t,d.isRendereredSource=!0}d.symbolizerParameters=i?h:null,d.transformGrid=i?n.transformGrid:null}else{const e=this.createEmptyTilePixelBlock();d.source=e,d.symbolizerParameters=i?h:null,d.transformGrid=null}const{isBsqTile:m}=this.layer.raster.rasterInfo.storageInfo;d.bandIds=i&&!m?r:null,d.width=this._tileInfoView.tileInfo.size[0],d.height=this._tileInfoView.tileInfo.size[1],d.interpolation=s,d.suspended=c;const{raster:y}=this.layer;if(o(y)){const t=y.getClippingGeometry(this.layerView.view.spatialReference);if(t){const r=y.getTileExtentFromTileInfo(e.key.level,e.key.row,e.key.col,this._tileInfoView.tileInfo);r&&(d.mask=a({srcExtent:r,geometry:t,size:[d.width,d.height]}))}}d.invalidateTexture()}async updateTileSymbolizerParameters(e,t,r){const{local:s,global:i}=t,o=this._getBandIds(),n=this._getLayerInterpolation(),{canUseWebGLForProcessing:a}=this,{bitmap:l}=e,{rawPixelData:c}=l;a||null==c?(l.isRendereredSource&&null!=c&&(l.source=c.pixelBlock),l.isRendereredSource=!1):(l.source=await this.layer.applyRenderer(c,"stretch"===i?.type?i:void 0,{signal:r}),l.isRendereredSource=!0),l.symbolizerParameters=a?this.layerView.hasTilingEffects?i:s:null;const{isBsqTile:p}=this.layer.raster.rasterInfo.storageInfo;l.bandIds=a&&!p?o:null,l.interpolation=n,l.suspended=!1}updateHighlightOptions(e){if(!e.length)return void(this.container.pixelHighlights=void 0);const s=[],{highlights:i}=this.layerView.view;e.sort((e,t)=>i.findIndex(({name:e})=>e===d(t.options))-i.findIndex(({name:t})=>t===d(e.options)));for(const{target:o,options:n}of e){const{pixelRanges:e}=o,c=d(n),p=i.find(e=>e.name===c)?.color??h,u=t.toUnitRGBA(p);if(Array.isArray(e)){const t=Array.from({length:2*l},()=>0);for(let r=0;r<e.length;r++)t[2*r]=e[r][0],t[2*r+1]=e[r][1];for(let s=e.length;s<l;s++)t[2*s]=r,t[2*s+1]=-r;const i=o.bandId??0;s.push({ranges:t,bandId:i,color:u,type:"single-band"})}else{const t="extent"===e.type?e:e.extent;if(!t)continue;const r=[t.xmin,t.xmax],i=[t.ymin,t.ymax],{xBandId:n,yBandId:l}=o,c={xRange:r,yRange:i,bandIds:[n,l],color:u,type:"xy-band"};"polygon"===e.type&&(c.maskSize=m,c.mask=a({srcExtent:t,geometry:e,size:m})),s.push(c)}}this.container.pixelHighlights=s}_getLayerInterpolation(){const{interpolation:e,renderer:t}=this.layer;if(!t)return e;const r=t.type;return"raster-colormap"===r||"unique-value"===r?"nearest":"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}_addProjection(e){return e?.functions?.length&&!e.hasFocalFunction&&e.functions.unshift({name:"Reproject",parameters:{targetImageSize:this._tileInfoView.tileInfo.size,requireNNEdge:e.isSourceSingleBand},pixelType:"f32",id:0,isNoopProcess:!1}),e}};e([s()],y.prototype,"canUseWebGLForProcessing",null),e([s()],y.prototype,"container",void 0),e([s()],y.prototype,"layer",void 0),e([s()],y.prototype,"type",void 0),y=e([i("esri.views.2d.layers.imagery.ImageryTileView2D")],y);export{y as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../../Color.js";import has from"../../../../core/has.js";import{numberMaxFloat32 as r}from"../../../../core/mathUtils.js";import{property as i,subclass as s}from"../../../../core/accessorSupport/decorators.js";import{isFunctionRaster as n}from"../../../../layers/raster/datasets/datasetUtils.js";import{getBytesPerPixel as o}from"../../../../layers/raster/formats/pixelRangeUtils.js";import{convertGeometryToMask as a}from"../../../../layers/raster/functions/clipUtils.js";import{maxMapSizeGpu as l}from"../../../../layers/raster/functions/pixelUtils.js";import{RasterTileContainer as c}from"../../engine/imagery/RasterTileContainer.js";import{BaseImageryTileSubView2D as p}from"./BaseImageryTileSubView2D.js";import{canUseMajorityInterpolationOnDataSource as u}from"../support/util.js";import{defaultColor as d}from"../../../support/HighlightDefaults.js";import{getHighlightName as h}from"../../../support/highlightOptionsUtils.js";const m=[1024,1024];let y=class extends p{constructor(){super(...arguments),this.type="raster"}get canUseWebGLForProcessing(){const{loaded:e,symbolizer:t}=this.layer;if(!e||!t)return!1;const r=t.lookup.colormapLut?.indexedColormap,i=r&&r.length>this._maxIndexedColormapSize,s=o(this.layer.serviceRasterInfo);return!(has("ios")&&s>4)&&this.useWebGLForProcessing&&t.canRenderInWebGL&&!i&&!("majority"===this.layer.interpolation&&u(this.layer))}attach(){super.attach(),this.container=new c(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this.updateRasterFunctionParameters()}detach(){super.detach(),this.container.removeAllChildren(),this.container=null}fetchTile(e,t){return this.layer.fetchTile(e.level,e.row,e.col,t)}updateRasterFunctionParameters(){const{raster:e,type:t}=this.layer,{container:r}=this;if("Function"!==e.datasetFormat||"wcs"===t)return r.rasterFunctionChain=null,r.children.forEach(e=>{const{bitmap:t}=e;t&&(t.suspended=!0,t.processed=!1,t.projected&&(t.invalidateTexture(),t.rasterTexture=null))}),void(this._rasterFunctionState="na");const i=this._rasterFunctionState,{rasterFunction:s,primaryRasters:n}=e,o=s.supportsGPU&&(!n||n.rasters.length<=1),a=o?s.flatWebGLFunctionChain:null,{renderer:l}=this.layer,c=!o||!a?.functions.length||"raster-stretch"===l?.type&&l.dynamicRangeAdjustment||!this.canUseWebGLForProcessing;r.rasterFunctionChain=c?null:this._addProjection(a);const p=null==s?"na":r.rasterFunctionChain?"gpu":"cpu",u=i===p||"na"===i&&"cpu"===p&&0===a?.functions?.length;r.children.forEach(e=>{const{bitmap:t}=e;t&&(t.suspended=!u,t.processed=!1,t.processedTexture=null)}),this._rasterFunctionState=p}async updateTileSource(e,t){const r=this._getBandIds(),i=this._getLayerInterpolation(),{canUseWebGLForProcessing:s}=this,{source:o,globalSymbolizerParams:l,suspended:c,coords:p,resolution:u}=t,d=this.isCPUBasedDRA?l:t.symbolizerParams,{bitmap:h}=e;if([h.x,h.y]=p,h.resolution=u,null!=o?.pixelBlock){const e={extent:o.extent,pixelBlock:o.pixelBlock,srcPixelSize:o.srcTilePixelSize};if(h.rawPixelData=e,s)h.source=o.pixelBlock,h.isRendereredSource=!1;else{const t=await this.layer.applyRenderer(e,"stretch"===l?.type?l:void 0);h.source=t,h.isRendereredSource=!0}h.symbolizerParameters=s?d:null,h.transformGrid=s?o.transformGrid:null}else{const e=this.createEmptyTilePixelBlock();h.source=e,h.symbolizerParameters=s?d:null,h.transformGrid=null}const{isBsqTile:m}=this.layer.raster.rasterInfo.storageInfo;h.bandIds=s&&!m?r:null,h.width=this._tileInfoView.tileInfo.size[0],h.height=this._tileInfoView.tileInfo.size[1],h.interpolation=i,h.suspended=c;const{raster:y}=this.layer;if(n(y)){const t=y.getClippingGeometry(this.layerView.view.spatialReference);if(t){const r=y.getTileExtentFromTileInfo(e.key.level,e.key.row,e.key.col,this._tileInfoView.tileInfo);r&&(h.mask=a({srcExtent:r,geometry:t,size:[h.width,h.height]}))}}h.invalidateTexture()}async updateTileSymbolizerParameters(e,t,r){const{local:i,global:s}=t,n=this._getBandIds(),o=this._getLayerInterpolation(),{canUseWebGLForProcessing:a}=this,{bitmap:l}=e,{rawPixelData:c}=l;a||null==c?(l.isRendereredSource&&null!=c&&(l.source=c.pixelBlock),l.isRendereredSource=!1):(l.source=await this.layer.applyRenderer(c,"stretch"===s?.type?s:void 0,{signal:r}),l.isRendereredSource=!0),l.symbolizerParameters=a?this.layerView.hasTilingEffects?s:i:null;const{isBsqTile:p}=this.layer.raster.rasterInfo.storageInfo;l.bandIds=a&&!p?n:null,l.interpolation=o,l.suspended=!1}updateHighlightOptions(e){if(!e.length)return void(this.container.pixelHighlights=void 0);const i=[],{highlights:s}=this.layerView.view;e.sort((e,t)=>s.findIndex(({name:e})=>e===h(t.options))-s.findIndex(({name:t})=>t===h(e.options)));for(const{target:n,options:o}of e){const{pixelRanges:e}=n,c=h(o),p=s.find(e=>e.name===c)?.color??d,u=t.toUnitRGBA(p);if(Array.isArray(e)){const t=Array.from({length:2*l},()=>0);for(let r=0;r<e.length;r++)t[2*r]=e[r][0],t[2*r+1]=e[r][1];for(let i=e.length;i<l;i++)t[2*i]=r,t[2*i+1]=-r;const s=n.bandId??0;i.push({ranges:t,bandId:s,color:u,type:"single-band"})}else{const t="extent"===e.type?e:e.extent;if(!t)continue;const r=[t.xmin,t.xmax],s=[t.ymin,t.ymax],{xBandId:o,yBandId:l}=n,c={xRange:r,yRange:s,bandIds:[o,l],color:u,type:"xy-band"};"polygon"===e.type&&(c.maskSize=m,c.mask=a({srcExtent:t,geometry:e,size:m})),i.push(c)}}this.container.pixelHighlights=i}_getLayerInterpolation(){const{interpolation:e,renderer:t}=this.layer;if(!t)return e;const r=t.type;return"raster-colormap"===r||"unique-value"===r?"nearest":"raster-stretch"===t.type&&null!=t.colorRamp?"bilinear"===e||"cubic"===e?"bilinear":"nearest":e}_addProjection(e){return e?.functions?.length&&!e.hasFocalFunction&&e.functions.unshift({name:"Reproject",parameters:{targetImageSize:this._tileInfoView.tileInfo.size,requireNNEdge:e.isSourceSingleBand},pixelType:"f32",id:0,isNoopProcess:!1}),e}};e([i()],y.prototype,"canUseWebGLForProcessing",null),e([i()],y.prototype,"container",void 0),e([i()],y.prototype,"layer",void 0),e([i()],y.prototype,"type",void 0),y=e([s("esri.views.2d.layers.imagery.ImageryTileView2D")],y);export{y 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{__decorate as t}from"tslib";import e from"../../../../Graphic.js";import i from"../../../../core/Accessor.js";import r from"../../../../core/Logger.js";import{isAbortError as a}from"../../../../core/promiseUtils.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{mosaicPixelData as l}from"../../../../layers/support/rasterFunctions/pixelUtils.js";import{BitmapContainer as p}from"../../engine/BitmapContainer.js";import{Container as n}from"../../engine/Container.js";import h from"../../engine/ImageryBitmapSource.js";import g from"../support/ExportStrategy.js";let c=class extends i{constructor(){super(...arguments),this.attached=!1,this.container=new n,this.updateRequested=!1,this.pixelHighlights=[],this.type="imagery",this._bitmapView=new p}destroy(){this.attached&&(this.detach(),this.attached=!1),this.updateRequested=!1}get updating(){return!this.attached||this.isUpdating()}update(t){this.strategy.update(t).catch(t=>{a(t)||r.getLogger(this).error(t)})}hitTest(t){return new e({attributes:{},geometry:t.clone(),layer:this.layer})}attach(){this.container.addChild(this._bitmapView);const t=this.layer.version>=10,e=this.layer.version>=10.1?this.layer.imageMaxHeight:2048,i=this.layer.version>=10.1?this.layer.imageMaxWidth:2048;this.strategy=new g({container:this._bitmapView,imageNormalizationSupported:t,imageMaxHeight:e,imageMaxWidth:i,fetchSource:this._fetchImage.bind(this),requestUpdate:()=>this.requestUpdate()})}detach(){this.strategy.destroy(),this._bitmapView.removeAllChildren(),this.container.removeAllChildren(),this.updateRequested=!1}redraw(){this.strategy.updateExports(async t=>{const{source:e}=t;if(!e||e instanceof ImageBitmap)return;const i=e.originalPixelBlock??e.pixelBlock,{pixelHighlights:r}=this,a=r.length>0,s=await this.layer.applyRenderer({extent:e.extent,pixelBlock:i,isRawData:a}),o=s.pixelBlock;a&&i&&o&&await this.layer.highlightPixels({pixelBlock:i,renderedPixelBlock:o,highlightOptions:r}),e.filter=t=>this.layer.pixelFilter?this.layer.applyFilter(t):{...s,extent:e.extent}}).catch(t=>{a(t)||r.getLogger(this).error(t)})}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.view.requestUpdate())}isUpdating(){return this.strategy.updating||this.updateRequested}getPixelData(){if(this.updating)return null;const t=this.strategy.bitmaps;if(1===t.length&&t[0].source)return{extent:t[0].source.extent,pixelBlock:t[0].source.originalPixelBlock};if(t.length>1){const e=this.view.extent,i=t.map(t=>t.source).filter(t=>t.extent&&t.extent.intersects(e)).map(t=>({extent:t.extent,pixelBlock:t.originalPixelBlock})),r=l(i,e);return null!=r?{extent:r.extent,pixelBlock:r.pixelBlock}:null}return null}async _fetchImage(t,e,i,r){(r=r||{}).timeExtent=this.timeExtent;const a=this.pixelHighlights.length>0;r.requestAsImageElement=!a,r.returnImageBitmap=!a,r.requestRawData=a;const s=await this.layer.internalFetchImage(t,e,i,r);if(s.imageBitmap)return s.imageBitmap;const o=await this.layer.applyRenderer({...s.pixelData,isRawData:a},{signal:r.signal}),l=s.pixelData.pixelBlock,p=o.pixelBlock;a&&l&&p&&await this.layer.highlightPixels({pixelBlock:l,renderedPixelBlock:p,highlightOptions:this.pixelHighlights});const n=new h(p,o.extent?.clone(),l);return n.filter=t=>this.layer.applyFilter(t),n}};t([s()],c.prototype,"attached",void 0),t([s()],c.prototype,"container",void 0),t([s()],c.prototype,"layer",void 0),t([s()],c.prototype,"strategy",void 0),t([s()],c.prototype,"timeExtent",void 0),t([s()],c.prototype,"view",void 0),t([s()],c.prototype,"updateRequested",void 0),t([s()],c.prototype,"updating",null),t([s()],c.prototype,"pixelHighlights",void 0),t([s()],c.prototype,"type",void 0),c=t([o("esri.views.2d.layers.imagery.ImageryView2D")],c);export{c as default};
5
+ import{__decorate as t}from"tslib";import e from"../../../../Graphic.js";import i from"../../../../core/Accessor.js";import r from"../../../../core/Logger.js";import{isAbortError as a}from"../../../../core/promiseUtils.js";import{property as s,subclass as o}from"../../../../core/accessorSupport/decorators.js";import{mosaicPixelData as l}from"../../../../layers/raster/functions/pixelUtils.js";import{BitmapContainer as n}from"../../engine/BitmapContainer.js";import{Container as p}from"../../engine/Container.js";import h from"../../engine/ImageryBitmapSource.js";import g from"../support/ExportStrategy.js";let c=class extends i{constructor(){super(...arguments),this.attached=!1,this.container=new p,this.updateRequested=!1,this.pixelHighlights=[],this.type="imagery",this._bitmapView=new n}destroy(){this.attached&&(this.detach(),this.attached=!1),this.updateRequested=!1}get updating(){return!this.attached||this.isUpdating()}update(t){this.strategy.update(t).catch(t=>{a(t)||r.getLogger(this).error(t)})}hitTest(t){return new e({attributes:{},geometry:t.clone(),layer:this.layer})}attach(){this.container.addChild(this._bitmapView);const t=this.layer.version>=10,e=this.layer.version>=10.1?this.layer.imageMaxHeight:2048,i=this.layer.version>=10.1?this.layer.imageMaxWidth:2048;this.strategy=new g({container:this._bitmapView,imageNormalizationSupported:t,imageMaxHeight:e,imageMaxWidth:i,fetchSource:this._fetchImage.bind(this),requestUpdate:()=>this.requestUpdate()})}detach(){this.strategy.destroy(),this._bitmapView.removeAllChildren(),this.container.removeAllChildren(),this.updateRequested=!1}redraw(){this.strategy.updateExports(async t=>{const{source:e}=t;if(!e||e instanceof ImageBitmap)return;const i=e.originalPixelBlock??e.pixelBlock,{pixelHighlights:r}=this,a=r.length>0,s=await this.layer.applyRenderer({extent:e.extent,pixelBlock:i,isRawData:a}),o=s.pixelBlock;a&&i&&o&&await this.layer.highlightPixels({pixelBlock:i,renderedPixelBlock:o,highlightOptions:r}),e.filter=t=>this.layer.pixelFilter?this.layer.applyFilter(t):{...s,extent:e.extent}}).catch(t=>{a(t)||r.getLogger(this).error(t)})}requestUpdate(){this.updateRequested||(this.updateRequested=!0,this.view.requestUpdate())}isUpdating(){return this.strategy.updating||this.updateRequested}getPixelData(){if(this.updating)return null;const t=this.strategy.bitmaps;if(1===t.length&&t[0].source)return{extent:t[0].source.extent,pixelBlock:t[0].source.originalPixelBlock};if(t.length>1){const e=this.view.extent,i=t.map(t=>t.source).filter(t=>t.extent&&t.extent.intersects(e)).map(t=>({extent:t.extent,pixelBlock:t.originalPixelBlock})),r=l(i,e);return null!=r?{extent:r.extent,pixelBlock:r.pixelBlock}:null}return null}async _fetchImage(t,e,i,r){(r=r||{}).timeExtent=this.timeExtent;const a=this.pixelHighlights.length>0;r.requestAsImageElement=!a,r.returnImageBitmap=!a,r.requestRawData=a;const s=await this.layer.internalFetchImage(t,e,i,r);if(s.imageBitmap)return s.imageBitmap;const o=await this.layer.applyRenderer({...s.pixelData,isRawData:a},{signal:r.signal}),l=s.pixelData.pixelBlock,n=o.pixelBlock;a&&l&&n&&await this.layer.highlightPixels({pixelBlock:l,renderedPixelBlock:n,highlightOptions:this.pixelHighlights});const p=new h(n,o.extent?.clone(),l);return p.filter=t=>this.layer.applyFilter(t),p}};t([s()],c.prototype,"attached",void 0),t([s()],c.prototype,"container",void 0),t([s()],c.prototype,"layer",void 0),t([s()],c.prototype,"strategy",void 0),t([s()],c.prototype,"timeExtent",void 0),t([s()],c.prototype,"view",void 0),t([s()],c.prototype,"updateRequested",void 0),t([s()],c.prototype,"updating",null),t([s()],c.prototype,"pixelHighlights",void 0),t([s()],c.prototype,"type",void 0),c=t([o("esri.views.2d.layers.imagery.ImageryView2D")],c);export{c as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright Esri, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{sampleVectorField as o}from"../../../../layers/support/rasterFunctions/vectorFieldUtils.js";import{RasterVFTileContainer as l}from"../../engine/imagery/RasterVFTileContainer.js";import{BaseImageryTileSubView2D as s}from"./BaseImageryTileSubView2D.js";let a=class extends s{constructor(){super(...arguments),this._handle=null,this.type="rasterVF"}async fetchTile(e,t){t={...t,interpolation:"nearest",requestProjectedLocalDirections:!0};const i=await this.layer.fetchTile(e.level,e.row,e.col,t);return"vector-magdir"===this.layer.serviceRasterInfo?.dataType&&i?.pixelBlock&&(i.pixelBlock=await this.layer.convertVectorFieldData(i.pixelBlock,"vector-magdir",t)),i}updateTileSource(e,t){const i=t.symbolizerParams,{tileData:r}=e;r.key=e.key,r.width=this._tileInfoView.tileInfo.size[0],r.height=this._tileInfoView.tileInfo.size[1];const{symbolTileSize:o}=i,{source:l}=t;if(r.offset=this._getTileSymbolOffset(r.key,o),null!=l?.pixelBlock){const e={extent:l.extent,pixelBlock:l.pixelBlock};r.rawPixelData=e,r.symbolizerParameters=i,r.source=this._sampleVectorFieldData(l.pixelBlock,i,r.offset)}else{const e=[Math.round((this._tileInfoView.tileInfo.size[0]-r.offset[0])/o),Math.round((this._tileInfoView.tileInfo.size[1]-r.offset[1])/o)],t=this.createEmptyTilePixelBlock(e);r.source=t,r.symbolizerParameters=i}return r.invalidateVAO(),Promise.resolve()}updateTileSymbolizerParameters(e,t){const i=t.local,{symbolTileSize:r}=i,{tileData:o}=e;o.offset=this._getTileSymbolOffset(o.key,r);const l=o.symbolizerParameters.symbolTileSize;o.symbolizerParameters=i;const s=o.rawPixelData?.pixelBlock;return null!=s&&l!==r&&(o.source=this._sampleVectorFieldData(s,o.symbolizerParameters,o.offset)),Promise.resolve()}attach(){super.attach(),this.container=new l(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this._updateSymbolType(this.layer.renderer),this._handle=t(()=>this.layer.renderer,e=>this._updateSymbolType(e))}detach(){super.detach(),this.container.removeAllChildren(),this._handle?.remove(),this._handle=null,this.container=null}_getTileSymbolOffset(e,t){const i=e.col*this._tileInfoView.tileInfo.size[0]%t,r=e.row*this._tileInfoView.tileInfo.size[1]%t;return[i>t/2?t-i:-i,r>t/2?t-r:-r]}_sampleVectorFieldData(e,t,i){const{symbolTileSize:r}=t;return o(e,"vector-uv",r,i)}_updateSymbolType(e){"vector-field"===e?.type&&(this.container.symbolTypes="wind-barb"===e.style?["scalar","triangle"]:"simple-scalar"===e.style?["scalar"]:["triangle"])}};e([i()],a.prototype,"container",void 0),e([i()],a.prototype,"layer",void 0),e([i()],a.prototype,"type",void 0),a=e([r("esri.views.2d.layers.imagery.VectorFieldTileView2D")],a);export{a as default};
5
+ import{__decorate as e}from"tslib";import{watch as t}from"../../../../core/reactiveUtils.js";import{property as i,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{sampleVectorField as l}from"../../../../layers/raster/functions/vectorFieldUtils.js";import{RasterVFTileContainer as o}from"../../engine/imagery/RasterVFTileContainer.js";import{BaseImageryTileSubView2D as s}from"./BaseImageryTileSubView2D.js";let a=class extends s{constructor(){super(...arguments),this._handle=null,this.type="rasterVF"}async fetchTile(e,t){t={...t,interpolation:"nearest",requestProjectedLocalDirections:!0};const i=await this.layer.fetchTile(e.level,e.row,e.col,t);return"vector-magdir"===this.layer.serviceRasterInfo?.dataType&&i?.pixelBlock&&(i.pixelBlock=await this.layer.convertVectorFieldData(i.pixelBlock,"vector-magdir",t)),i}updateTileSource(e,t){const i=t.symbolizerParams,{tileData:r}=e;r.key=e.key,r.width=this._tileInfoView.tileInfo.size[0],r.height=this._tileInfoView.tileInfo.size[1];const{symbolTileSize:l}=i,{source:o}=t;if(r.offset=this._getTileSymbolOffset(r.key,l),null!=o?.pixelBlock){const e={extent:o.extent,pixelBlock:o.pixelBlock};r.rawPixelData=e,r.symbolizerParameters=i,r.source=this._sampleVectorFieldData(o.pixelBlock,i,r.offset)}else{const e=[Math.round((this._tileInfoView.tileInfo.size[0]-r.offset[0])/l),Math.round((this._tileInfoView.tileInfo.size[1]-r.offset[1])/l)],t=this.createEmptyTilePixelBlock(e);r.source=t,r.symbolizerParameters=i}return r.invalidateVAO(),Promise.resolve()}updateTileSymbolizerParameters(e,t){const i=t.local,{symbolTileSize:r}=i,{tileData:l}=e;l.offset=this._getTileSymbolOffset(l.key,r);const o=l.symbolizerParameters.symbolTileSize;l.symbolizerParameters=i;const s=l.rawPixelData?.pixelBlock;return null!=s&&o!==r&&(l.source=this._sampleVectorFieldData(s,l.symbolizerParameters,l.offset)),Promise.resolve()}attach(){super.attach(),this.container=new o(this._tileInfoView),this.container.isCustomTilingScheme=this._isCustomTilingScheme,this._updateSymbolType(this.layer.renderer),this._handle=t(()=>this.layer.renderer,e=>this._updateSymbolType(e))}detach(){super.detach(),this.container.removeAllChildren(),this._handle?.remove(),this._handle=null,this.container=null}_getTileSymbolOffset(e,t){const i=e.col*this._tileInfoView.tileInfo.size[0]%t,r=e.row*this._tileInfoView.tileInfo.size[1]%t;return[i>t/2?t-i:-i,r>t/2?t-r:-r]}_sampleVectorFieldData(e,t,i){const{symbolTileSize:r}=t;return l(e,"vector-uv",r,i)}_updateSymbolType(e){"vector-field"===e?.type&&(this.container.symbolTypes="wind-barb"===e.style?["scalar","triangle"]:"simple-scalar"===e.style?["scalar"]:["triangle"])}};e([i()],a.prototype,"container",void 0),e([i()],a.prototype,"layer",void 0),e([i()],a.prototype,"type",void 0),a=e([r("esri.views.2d.layers.imagery.VectorFieldTileView2D")],a);export{a 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{__decorate as t}from"tslib";import e from"../../../../Graphic.js";import r from"../../../../request.js";import i from"../../../../core/Accessor.js";import a from"../../../../core/Logger.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as l,subclass as m}from"../../../../core/accessorSupport/decorators.js";import c from"../../../../geometry/Extent.js";import{srToRESTValue as p}from"../../../../geometry/support/spatialReferenceUtils.js";import{projectExtent as h}from"../../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{snapImageToSymbolTile as y}from"../../../../layers/support/rasterFunctions/vectorFieldUtils.js";import{RasterVFContainer as u}from"../../engine/imagery/RasterVFContainer.js";import x from"./ImageryVFStrategy.js";let d=class extends i{constructor(){super(...arguments),this.attached=!1,this.container=new u,this.type="imageryVF",this._dataParameters={exportParametersVersion:0,bbox:"",symbolTileSize:0,time:""},this._fetchpixels=async(t,e,r,i)=>{const a=await this._projectFullExtentPromise,{layer:s}=this,{symbolTileSize:o}=s.renderer,{extent:n,width:l,height:m}=y(t,e,r,o,a);if(null!=a&&!a.intersects(t))return{extent:n,pixelBlock:null};const c={bbox:`${n.xmin}, ${n.ymin}, ${n.xmax}, ${n.ymax}`,exportParametersVersion:s.exportImageServiceParameters.version,symbolTileSize:o,time:JSON.stringify(this.timeExtent||"")};if(this._canReuseVectorFieldData(c)){const t=this.getPixelData();if(null!=t){if(`${t.extent.xmin}, ${t.extent.ymin}, ${t.extent.xmax}, ${t.extent.ymax}`===c.bbox)return t}}const{pixelBlock:p}=await s.fetchPixels(n,l,m,{timeExtent:this.timeExtent,interpolation:s.interpolation,signal:i});if(this._dataParameters=c,null==p)return{extent:n,pixelBlock:null};const{dataType:h}=s.rasterInfo;return{extent:n,pixelBlock:"vector-uv"===h&&p?await s.convertVectorFieldData(p,"vector-uv",{signal:i}):p}}}get updating(){return!this.attached||this._strategy.updating}attach(){this._projectFullExtentPromise=this._getProjectedFullExtent(this.view.spatialReference),this._strategy=new x({container:this.container,fetchPixels:this._fetchpixels}),this.addHandles(o(()=>this.layer.renderer,t=>this._updateSymbolizerParams(t),n),"attach")}detach(){this._strategy.destroy(),this.container.children.forEach(t=>t.destroy()),this.container.removeAllChildren(),this.removeHandles("attach"),this._strategy=this.container=this._projectFullExtentPromise=null}getPixelData(){const t=this.container.children[0]?.rawPixelData;if(this.updating||!t)return null;const{extent:e,pixelBlock:r}=t;return{extent:e,pixelBlock:r}}hitTest(t){return new e({attributes:{},geometry:t.clone(),layer:this.layer})}update(t){this._strategy.update(t,this._symbolizerParams).catch(t=>{s(t)||a.getLogger(this).error(t)})}redraw(){const{renderer:t}=this.layer;t&&(this._updateSymbolizerParams(t),this._strategy.redraw(this._symbolizerParams))}_canReuseVectorFieldData(t){const e=this._dataParameters.exportParametersVersion===t.exportParametersVersion,r=this._dataParameters.time===t.time,i=this._dataParameters.symbolTileSize===t.symbolTileSize,a=this._dataParameters.bbox===t.bbox;return e&&r&&i&&a}async _getProjectedFullExtent(t){try{return h(this.layer.fullExtent,t)}catch(e){try{const e=(await r(this.layer.url,{query:{option:"footprints",outSR:p(t),f:"json"}})).data.featureCollection.layers[0].layerDefinition.extent;return e?c.fromJSON(e):null}catch{return null}}}_updateSymbolizerParams(t){"vector-field"===t?.type&&(this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null}))}};t([l()],d.prototype,"attached",void 0),t([l()],d.prototype,"container",void 0),t([l()],d.prototype,"layer",void 0),t([l()],d.prototype,"timeExtent",void 0),t([l()],d.prototype,"type",void 0),t([l()],d.prototype,"view",void 0),t([l()],d.prototype,"updating",null),d=t([m("esri.views.2d.layers.imagery.VectorFieldView2D")],d);export{d as default};
5
+ import{__decorate as t}from"tslib";import e from"../../../../Graphic.js";import r from"../../../../request.js";import i from"../../../../core/Accessor.js";import a from"../../../../core/Logger.js";import{isAbortError as s}from"../../../../core/promiseUtils.js";import{watch as o,syncAndInitial as n}from"../../../../core/reactiveUtils.js";import{property as l,subclass as m}from"../../../../core/accessorSupport/decorators.js";import c from"../../../../geometry/Extent.js";import{srToRESTValue as p}from"../../../../geometry/support/spatialReferenceUtils.js";import{projectExtent as h}from"../../../../layers/raster/functions/rasterProjectionHelper.js";import{snapImageToSymbolTile as y}from"../../../../layers/raster/functions/vectorFieldUtils.js";import{RasterVFContainer as x}from"../../engine/imagery/RasterVFContainer.js";import u from"./ImageryVFStrategy.js";let d=class extends i{constructor(){super(...arguments),this.attached=!1,this.container=new x,this.type="imageryVF",this._dataParameters={exportParametersVersion:0,bbox:"",symbolTileSize:0,time:""},this._fetchpixels=async(t,e,r,i)=>{const a=await this._projectFullExtentPromise,{layer:s}=this,{symbolTileSize:o}=s.renderer,{extent:n,width:l,height:m}=y(t,e,r,o,a);if(null!=a&&!a.intersects(t))return{extent:n,pixelBlock:null};const c={bbox:`${n.xmin}, ${n.ymin}, ${n.xmax}, ${n.ymax}`,exportParametersVersion:s.exportImageServiceParameters.version,symbolTileSize:o,time:JSON.stringify(this.timeExtent||"")};if(this._canReuseVectorFieldData(c)){const t=this.getPixelData();if(null!=t){if(`${t.extent.xmin}, ${t.extent.ymin}, ${t.extent.xmax}, ${t.extent.ymax}`===c.bbox)return t}}const{pixelBlock:p}=await s.fetchPixels(n,l,m,{timeExtent:this.timeExtent,interpolation:s.interpolation,signal:i});if(this._dataParameters=c,null==p)return{extent:n,pixelBlock:null};const{dataType:h}=s.rasterInfo;return{extent:n,pixelBlock:"vector-uv"===h&&p?await s.convertVectorFieldData(p,"vector-uv",{signal:i}):p}}}get updating(){return!this.attached||this._strategy.updating}attach(){this._projectFullExtentPromise=this._getProjectedFullExtent(this.view.spatialReference),this._strategy=new u({container:this.container,fetchPixels:this._fetchpixels}),this.addHandles(o(()=>this.layer.renderer,t=>this._updateSymbolizerParams(t),n),"attach")}detach(){this._strategy.destroy(),this.container.children.forEach(t=>t.destroy()),this.container.removeAllChildren(),this.removeHandles("attach"),this._strategy=this.container=this._projectFullExtentPromise=null}getPixelData(){const t=this.container.children[0]?.rawPixelData;if(this.updating||!t)return null;const{extent:e,pixelBlock:r}=t;return{extent:e,pixelBlock:r}}hitTest(t){return new e({attributes:{},geometry:t.clone(),layer:this.layer})}update(t){this._strategy.update(t,this._symbolizerParams).catch(t=>{s(t)||a.getLogger(this).error(t)})}redraw(){const{renderer:t}=this.layer;t&&(this._updateSymbolizerParams(t),this._strategy.redraw(this._symbolizerParams))}_canReuseVectorFieldData(t){const e=this._dataParameters.exportParametersVersion===t.exportParametersVersion,r=this._dataParameters.time===t.time,i=this._dataParameters.symbolTileSize===t.symbolTileSize,a=this._dataParameters.bbox===t.bbox;return e&&r&&i&&a}async _getProjectedFullExtent(t){try{return h(this.layer.fullExtent,t)}catch(e){try{const e=(await r(this.layer.url,{query:{option:"footprints",outSR:p(t),f:"json"}})).data.featureCollection.layers[0].layerDefinition.extent;return e?c.fromJSON(e):null}catch{return null}}}_updateSymbolizerParams(t){"vector-field"===t?.type&&(this._symbolizerParams=this.layer.symbolizer.generateWebGLParameters({pixelBlock:null}))}};t([l()],d.prototype,"attached",void 0),t([l()],d.prototype,"container",void 0),t([l()],d.prototype,"layer",void 0),t([l()],d.prototype,"timeExtent",void 0),t([l()],d.prototype,"type",void 0),t([l()],d.prototype,"view",void 0),t([l()],d.prototype,"updating",null),d=t([m("esri.views.2d.layers.imagery.VectorFieldView2D")],d);export{d 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{__decorate as e}from"tslib";import t from"../../../Color.js";import{isSome as i}from"../../../core/arrayUtils.js";import{createTask as r}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{abortMaybe as s}from"../../../core/maybe.js";import{after as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{watch as a,syncAndInitial as l}from"../../../core/reactiveUtils.js";import{createScreenPointArray as c,createRenderScreenPointArray as d}from"../../../core/screenUtils.js";import{offsetDateUTC as u,convertTime as h}from"../../../core/timeUtils.js";import{property as p,subclass as _}from"../../../core/accessorSupport/decorators.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{AnalysisView3D as f}from"./AnalysisView3D.js";import{longitudeToTimezone as g}from"../support/earthUtils.js";import{computeDirectionsOverTime as y}from"../support/sunUtils.js";import{breadthFirstBinaryPartitioning as v}from"../../../widgets/support/traversalUtils.js";let w=class extends f{constructor(e){super(e),this.type="shadow-cast-view-3d",this.analysis=null,this._stopPreviewingTask=null,this._forcePreview=!1,this._autoRestoreForcePreviewEnabled=!0}initialize(){this.addHandles([a(()=>this._forcePreviewDependencies,()=>{s(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=r(async e=>{await n(U,e),o(e),this._forcePreview=!1}))},l),a(()=>({renderer:this._renderer,parameters:this._visualizationParameters}),({renderer:e,parameters:t})=>P(e,t),l),a(()=>({renderer:this._renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext}),({renderer:e,lightDirections:t,lightDirectionsContext:i})=>P(e,{lightDirections:t,lightDirectionsContext:i}),l),a(()=>({renderer:this._renderer,enabled:this.visible}),({renderer:e,enabled:t})=>P(e,{enabled:t}),l),a(()=>({renderer:this._renderer,previewing:this._previewing}),({renderer:e,previewing:t})=>P(e,{previewing:t}),l)])}destroy(){P(this._renderer,{enabled:!1})}get interactive(){return!1}set interactive(e){}get updating(){return!1}get visible(){return super.visible}set visible(e){super.visible=e}get _previewing(){const{view:e}=this;if(null==e?.allLayerViews)return!0;const{stationary:t,allLayerViews:i,graphicsView:r}=e;return this._forcePreview||!t||i.some(e=>C(e)&&e.updating)||!r?.suspended&&!!r?.updating}get _effectiveUtcOffset(){return this.analysis.utcOffset??this._utcOffsetAuto}get _utcOffsetAuto(){const e=this._referencePosition;return null!=e?g(e[0],!1):0}get _dateUTCOffset(){let e=this.analysis.date;return e=u(e,-e.getTimezoneOffset(),"minutes"),e=u(e,-this._effectiveUtcOffset,"hours"),e}get _startDateTimeUTC(){return u(this._dateUTCOffset,this.analysis.startTimeOfDay)}get _endDateTimeUTC(){return u(this._dateUTCOffset,this.analysis.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _durationInterval(){return this._duration>0?Math.floor(this._duration/(O-1)):O}get _interval(){const e=this._durationInterval;switch(this.analysis.mode){case"threshold":case"duration":return e;case"discrete":return this.analysis.discreteOptions.interval||e}}get _intervalContext(){const{mode:e,thresholdOptions:t}=this.analysis;return"threshold"===e&&t.contextEnabled?t.contextOptions.interval||this._durationInterval:-1}get _durationSampleCount(){return this._lightDirections.length}get _duration(){const{startTimeOfDay:e,endTimeOfDay:t}=this.analysis;return t-e}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(e){const{view:t}=this;if(e<=0)return[];const i="global"===t.viewingMode?b:this._referencePosition;if(null==i)return[];const r=y(this._startDateTimeUTC,this._endDateTimeUTC,e,i,t.state.viewingMode,O),s=r.length;z.length=0;const n=v(0,s,z),o=new Array(s);for(let a=0;a<s;++a)o[a]=r[n[a]];return o}get _visualizationParameters(){if(!this.visible)return null;switch(this.analysis.mode){case"threshold":return this._thresholdVisualizationParameters;case"duration":return this._durationVisualizationParameters;case"discrete":return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{threshold:e,color:i}=this.analysis.thresholdOptions,r=this._duration;return{visualization:2,thresholdColor:t.toUnitRGBA(i),threshold:r>0?e/this._duration:0,...this._thresholdDiscreteVisualizationParameters}}get _thresholdDiscreteVisualizationParameters(){const{thresholdOptions:e}=this.analysis;return e.contextEnabled?{visualization:3,gradientColor:t.toUnitRGBA(e.color)}:{}}get _durationVisualizationParameters(){const{color:e,mode:i}=this.analysis.durationOptions,r=this._duration,s=r>0&&"hourly"===i?T/r:0,n=t.toUnitRGBA(e);return 0===s?{...this._discreteVisualizationParameters,gradientColor:n}:{bandedGradientColor:n,visualization:1,bandSize:s}}get _discreteVisualizationParameters(){return{gradientColor:t.toUnitRGBA(this.analysis.discreteOptions.color),visualization:0}}get _forcePreviewDependencies(){const{view:e}=this,t=e.slice.plane,r=e.allLayerViews.toArray().filter(C),s=r.map(e=>e.layer).filter(i),n=r.map(e=>e.suspended),o=s.map(e=>e.visible),a=s.map(e=>e.opacity),l=!!e.graphicsView?.suspended,c=s.filter(e=>"definitionExpression"in e).map(e=>e.definitionExpression),d=r.filter(e=>"filter"in e).map(e=>e.filter);return{slicePlane:t,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewSuspended:n,graphicsViewSuspended:l,layerVisibilities:o,layerOpacities:a,filters:d,definitionExpressions:c}}get _renderer(){return this.view?.stage?.renderer}get testData(){}async getDurationAtScreen(e){const{_renderer:t,_durationSampleCount:i}=this;if(null==t||0===i)return 0;const r=this.view.state.camera.screenToRender(c(e.x,e.y),d());return t.readAccumulatedShadow(r)*this._duration}};e([p({readOnly:!0,type:["shadow-cast-view-3d"]})],w.prototype,"type",void 0),e([p({constructOnly:!0,nonNullable:!0})],w.prototype,"analysis",void 0),e([p({readOnly:!0})],w.prototype,"updating",null),e([p()],w.prototype,"_stopPreviewingTask",void 0),e([p()],w.prototype,"_forcePreview",void 0),e([p()],w.prototype,"_autoRestoreForcePreviewEnabled",void 0),e([p()],w.prototype,"_previewing",null),e([p()],w.prototype,"_effectiveUtcOffset",null),e([p()],w.prototype,"_utcOffsetAuto",null),e([p()],w.prototype,"_dateUTCOffset",null),e([p()],w.prototype,"_startDateTimeUTC",null),e([p()],w.prototype,"_endDateTimeUTC",null),e([p()],w.prototype,"_referencePosition",null),e([p()],w.prototype,"_interval",null),e([p()],w.prototype,"_intervalContext",null),e([p()],w.prototype,"_durationSampleCount",null),e([p()],w.prototype,"_duration",null),e([p()],w.prototype,"_lightDirections",null),e([p()],w.prototype,"_lightDirectionsContext",null),e([p()],w.prototype,"_visualizationParameters",null),e([p()],w.prototype,"_thresholdVisualizationParameters",null),e([p()],w.prototype,"_thresholdDiscreteVisualizationParameters",null),e([p()],w.prototype,"_durationVisualizationParameters",null),e([p()],w.prototype,"_discreteVisualizationParameters",null),e([p()],w.prototype,"_forcePreviewDependencies",null),e([p()],w.prototype,"_renderer",null),w=e([_("esri.views.3d.analysis.ShadowCastAnalysisView3D")],w);const D=w;function P(e,t){null!=t&&e?.setParameters({shadowCast:t})}function C(e){if(e.suspended)return!1;switch(e.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":case"catalog-footprint-3d":return!0;default:return!1}}const T=h(1,"hours","milliseconds"),U=500,O=255,b=m(),z=[];export{D as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{isSome as i}from"../../../core/arrayUtils.js";import{createTask as r}from"../../../core/asyncUtils.js";import"../../../core/has.js";import{abortMaybe as s}from"../../../core/maybe.js";import{after as n,throwIfAborted as o}from"../../../core/promiseUtils.js";import{watch as a,syncAndInitial as l}from"../../../core/reactiveUtils.js";import{createScreenPointArray as c,createRenderScreenPointArray as d}from"../../../core/screenUtils.js";import{offsetDateUTC as u,convertTime as h}from"../../../core/timeUtils.js";import{property as p,subclass as _}from"../../../core/accessorSupport/decorators.js";import{create as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{AnalysisView3D as f}from"./AnalysisView3D.js";import{longitudeToTimezone as g}from"../support/earthUtils.js";import{computeDirectionsOverTime as y}from"../support/sunUtils.js";import{breadthFirstBinaryPartitioning as v}from"../../../widgets/support/traversalUtils.js";let w=class extends f{constructor(e){super(e),this.type="shadow-cast-view-3d",this.analysis=null,this._stopPreviewingTask=null,this._forcePreview=!1,this._autoRestoreForcePreviewEnabled=!0}initialize(){this.addHandles([a(()=>this._forcePreviewDependencies,()=>{s(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=r(async e=>{await n(U,e),o(e),this._forcePreview=!1}))},l),a(()=>({renderer:this._renderer,parameters:this._visualizationParameters}),({renderer:e,parameters:t})=>P(e,t),l),a(()=>({renderer:this._renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext}),({renderer:e,lightDirections:t,lightDirectionsContext:i})=>P(e,{lightDirections:t,lightDirectionsContext:i}),l),a(()=>({renderer:this._renderer,enabled:this.visible}),({renderer:e,enabled:t})=>P(e,{enabled:t}),l),a(()=>({renderer:this._renderer,previewing:this._previewing}),({renderer:e,previewing:t})=>P(e,{previewing:t}),l)])}destroy(){P(this._renderer,{enabled:!1})}get interactive(){return!1}set interactive(e){}get updating(){return!1}get visible(){return super.visible}set visible(e){super.visible=e}get _previewing(){const{view:e}=this;if(null==e?.allLayerViews)return!0;const{stationary:t,allLayerViews:i,graphicsView:r}=e;return this._forcePreview||!t||i.some(e=>C(e)&&e.updating)||!r?.suspended&&!!r?.updating}get _effectiveUtcOffset(){return this.analysis.utcOffset??this._utcOffsetAuto}get _utcOffsetAuto(){const e=this._referencePosition;return null!=e?g(e[0],!1):0}get _dateUTCOffset(){let e=this.analysis.date;return e=u(e,-e.getTimezoneOffset(),"minutes"),e=u(e,-this._effectiveUtcOffset,"hours"),e}get _startDateTimeUTC(){return u(this._dateUTCOffset,this.analysis.startTimeOfDay)}get _endDateTimeUTC(){return u(this._dateUTCOffset,this.analysis.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _durationInterval(){return this._duration>0?Math.floor(this._duration/(O-1)):O}get _interval(){const e=this._durationInterval;switch(this.analysis.mode){case"threshold":case"duration":return e;case"discrete":return this.analysis.discreteOptions.interval||e}}get _intervalContext(){const{mode:e,thresholdOptions:t}=this.analysis;return"threshold"===e&&t.contextEnabled?t.contextOptions.interval||this._durationInterval:-1}get _durationSampleCount(){return this._lightDirections.length}get _duration(){const{startTimeOfDay:e,endTimeOfDay:t}=this.analysis;return t-e}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(e){const{view:t}=this;if(e<=0)return[];const i="global"===t.viewingMode?b:this._referencePosition;if(null==i)return[];const r=y(this._startDateTimeUTC,this._endDateTimeUTC,e,i,t.state.viewingMode,O),s=r.length;z.length=0;const n=v(0,s,z),o=new Array(s);for(let a=0;a<s;++a)o[a]=r[n[a]];return o}get _visualizationParameters(){if(!this.visible)return null;switch(this.analysis.mode){case"threshold":return this._thresholdVisualizationParameters;case"duration":return this._durationVisualizationParameters;case"discrete":return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{threshold:e,color:i}=this.analysis.thresholdOptions,r=this._duration;return{visualization:2,thresholdColor:t.toUnitRGBA(i),threshold:r>0?e/this._duration:0,...this._thresholdDiscreteVisualizationParameters}}get _thresholdDiscreteVisualizationParameters(){const{thresholdOptions:e}=this.analysis;return e.contextEnabled?{visualization:3,gradientColor:t.toUnitRGBA(e.contextOptions.color)}:{}}get _durationVisualizationParameters(){const{color:e,mode:i}=this.analysis.durationOptions,r=this._duration,s=r>0&&"hourly"===i?T/r:0,n=t.toUnitRGBA(e);return 0===s?{...this._discreteVisualizationParameters,gradientColor:n}:{bandedGradientColor:n,visualization:1,bandSize:s}}get _discreteVisualizationParameters(){return{gradientColor:t.toUnitRGBA(this.analysis.discreteOptions.color),visualization:0}}get _forcePreviewDependencies(){const{view:e}=this,t=e.slice.plane,r=e.allLayerViews.toArray().filter(C),s=r.map(e=>e.layer).filter(i),n=r.map(e=>e.suspended),o=s.map(e=>e.visible),a=s.map(e=>e.opacity),l=!!e.graphicsView?.suspended,c=s.filter(e=>"definitionExpression"in e).map(e=>e.definitionExpression),d=r.filter(e=>"filter"in e).map(e=>e.filter);return{slicePlane:t,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewSuspended:n,graphicsViewSuspended:l,layerVisibilities:o,layerOpacities:a,filters:d,definitionExpressions:c}}get _renderer(){return this.view?.stage?.renderer}get testData(){}async getDurationAtScreen(e){const{_renderer:t,_durationSampleCount:i}=this;if(null==t||0===i)return 0;const r=this.view.state.camera.screenToRender(c(e.x,e.y),d());return t.readAccumulatedShadow(r)*this._duration}};e([p({readOnly:!0,type:["shadow-cast-view-3d"]})],w.prototype,"type",void 0),e([p({constructOnly:!0,nonNullable:!0})],w.prototype,"analysis",void 0),e([p({readOnly:!0})],w.prototype,"updating",null),e([p()],w.prototype,"_stopPreviewingTask",void 0),e([p()],w.prototype,"_forcePreview",void 0),e([p()],w.prototype,"_autoRestoreForcePreviewEnabled",void 0),e([p()],w.prototype,"_previewing",null),e([p()],w.prototype,"_effectiveUtcOffset",null),e([p()],w.prototype,"_utcOffsetAuto",null),e([p()],w.prototype,"_dateUTCOffset",null),e([p()],w.prototype,"_startDateTimeUTC",null),e([p()],w.prototype,"_endDateTimeUTC",null),e([p()],w.prototype,"_referencePosition",null),e([p()],w.prototype,"_interval",null),e([p()],w.prototype,"_intervalContext",null),e([p()],w.prototype,"_durationSampleCount",null),e([p()],w.prototype,"_duration",null),e([p()],w.prototype,"_lightDirections",null),e([p()],w.prototype,"_lightDirectionsContext",null),e([p()],w.prototype,"_visualizationParameters",null),e([p()],w.prototype,"_thresholdVisualizationParameters",null),e([p()],w.prototype,"_thresholdDiscreteVisualizationParameters",null),e([p()],w.prototype,"_durationVisualizationParameters",null),e([p()],w.prototype,"_discreteVisualizationParameters",null),e([p()],w.prototype,"_forcePreviewDependencies",null),e([p()],w.prototype,"_renderer",null),w=e([_("esri.views.3d.analysis.ShadowCastAnalysisView3D")],w);const D=w;function P(e,t){null!=t&&e?.setParameters({shadowCast:t})}function C(e){if(e.suspended)return!1;switch(e.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":case"catalog-footprint-3d":return!0;default:return!1}}const T=h(1,"hours","milliseconds"),U=500,O=255,b=m(),z=[];export{D 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{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import{whenOnce as i,watch as r,sync as s}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{projectDatasetExtent as n}from"../../../layers/support/rasterFunctions/rasterProjectionHelper.js";import{LayerView3D as o}from"./LayerView3D.js";import{TiledLayerView3D as h}from"./TiledLayerView3D.js";import m from"../support/flow/FlowSubViewTiles3D.js";import{RasterTile as d}from"../terrain/RasterTile.js";import{ImageryTileLayerViewMixin as p}from"../../layers/ImageryTileLayerViewMixin.js";import u from"../../layers/LayerView.js";import{RefreshableLayerView as y}from"../../layers/RefreshableLayerView.js";import{createQueryGeometry as c}from"../../support/drapedUtils.js";import{getWebGLCapabilities as f}from"../../webgl/capabilities.js";let b=class extends(p(y(h(o(u))))){constructor(){super(...arguments),this.type="imagery-tile-3d",this._isAlignedMapTile=!0,this._flowSubView=null,this.ignoresMemoryFactor=!1,this.unloadedMemory=0}initialize(){this.layer.increaseRasterJobHandlerUsage(),null==this.fullExtent&&this.addResolvingPromise(Promise.reject(new t("layerview:spatial-reference-incompatible","The layer extent cannot be projected to the view's spatial reference",{layer:this.layer})));const e=i(()=>this.view?.basemapTerrain?.tilingSchemeLocked).then(()=>{const e=this.view.basemapTerrain.tilingScheme,t=this.layer.tileInfo;this._isAlignedMapTile=["png","png24","png32","jpg","mixed"].includes(t.format)&&e.compatibleWith(t),this.tileInfo=this._isAlignedMapTile?t:e.toTileInfo(),this.addHandles([r(()=>this.layer.renderer,e=>{this._setSubView(e),this._updatingHandles.addPromise(this.doRefresh())},s),r(()=>[this.layer.interpolation,this.layer.bandIds,this.layer.multidimensionalDefinition,this.layer.multidimensionalSubset,this.layer.rasterFunction,this.timeExtent],()=>this._updatingHandles.addPromise(this.doRefresh()),s)])});this._setSubView(this.layer.renderer),this.addResolvingPromise(e)}destroy(){this.layer.decreaseRasterJobHandlerUsage(),this._flowSubView?.destroy()}_setSubView(e){if("wcs"===this.layer.type)return;const t="flow"===e?.type,i=this._flowSubView;t&&null!=i||(i?.destroy(),this._flowSubView=t?new m({layerView:this}):null)}get _blankTile(){const e=document.createElement("canvas"),t=e.getContext("2d"),[i,r]=this.tileInfo.size;return e.width=i,e.height=r,t.clearRect(0,0,i,r),t.getImageData(0,0,i,r)}get _hasFlow(){return null!=this._flowSubView}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get dataLevelRange(){const e=this.layer.tileInfo,t=this.tileInfo.lodAt(0)?.scale,i=e.lodAt(e.lods.length-1)?.scale;return this.levelRangeFromScaleRange(t,i)}get visibleAtCurrentScale(){return this._flowSubView?.visibleAtCurrentScale??this.tilesVisibleAtCurrentScale()}_getFullExtent(){return n(this.layer.serviceRasterInfo,this.view.basemapTerrain?.spatialReference??this.view.spatialReference)}async fetchTile(e,t){const i=this.tileInfo,r=this._canSymbolizeInWebGL(),s={tileInfo:i,requestRawData:r&&!this._hasFlow,signal:t.signal,timeExtent:this.timeExtent,requestAsImageElement:this._isAlignedMapTile,requestProjectedLocalDirections:this._hasFlow,noClip:!1},{layer:a}=this,[l,n,o]=e,h=await a.fetchTile(l,n,o,s);if(h instanceof HTMLImageElement)return h;let m=h?.pixelBlock;if(null==m)return this._blankTile;if(!r&&!this._hasFlow&&(m=await a.applyRenderer(h),null==m))return this._blankTile;const p=new d([l,n,o],m,i.size[0],i.size[1]);return r?(p.symbolizerRenderer=a.symbolizer.rendererJSON,p.symbolizerParameters=a.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(l)),p.transformGrid=h.transformGrid,p.bandIds=a.bandIds):(p.isRendereredSource=!0,p.bandIds=null),p.interpolation=a.interpolation,p}_getSymbolizerOptions(e){const t=this.tileInfo.lodAt(e).resolution;return{pixelBlock:null,isGCS:null!=this.view.basemapTerrain?.spatialReference?this.view.basemapTerrain.spatialReference.isGeographic:this.view.spatialReference.isGeographic,resolution:{x:t,y:t},bandIds:this.layer.bandIds}}ensureSymbolizerParameters(e){this._canSymbolizeInWebGL()&&JSON.stringify(e.symbolizerRenderer)!==JSON.stringify(this.layer.symbolizer.rendererJSON)&&(e.symbolizerParameters=this.layer.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(e.lij[0])))}createFetchPopupFeaturesQueryGeometry(e,t){return c(e,t,this.view)}async doRefresh(){this.suspended||(this._flowSubView?.doRefresh(),this.emit("data-changed"))}isUpdating(){return this._flowSubView?.updating??!1}_canSymbolizeInWebGL(){const e=f(),{symbolizer:t}=this.layer,i=t.lookup.colormapLut?.indexedColormap,r=!!this.layer.rasterFunction?.hasClipFunction,s=i&&i.length>4*(e.maxTextureSize||4096);return t.canRenderInWebGL&&!s&&!r}get usedMemory(){return this._flowSubView?.usedMemory??0}get test(){}};e([a({readOnly:!0})],b.prototype,"_blankTile",null),e([a()],b.prototype,"_hasFlow",null),e([a({readOnly:!0})],b.prototype,"imageFormatIsOpaque",null),e([a({readOnly:!0})],b.prototype,"hasMixedImageFormats",null),e([a()],b.prototype,"_flowSubView",void 0),e([a({readOnly:!0})],b.prototype,"dataLevelRange",null),e([a({readOnly:!0})],b.prototype,"visibleAtCurrentScale",null),b=e([l("esri.views.3d.layers.ImageryTileLayerView3D")],b);const g=b;export{g as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import{whenOnce as i,watch as r,sync as s}from"../../../core/reactiveUtils.js";import{property as a,subclass as l}from"../../../core/accessorSupport/decorators.js";import{projectDatasetExtent as n}from"../../../layers/raster/functions/rasterProjectionHelper.js";import{LayerView3D as o}from"./LayerView3D.js";import{TiledLayerView3D as h}from"./TiledLayerView3D.js";import m from"../support/flow/FlowSubViewTiles3D.js";import{RasterTile as d}from"../terrain/RasterTile.js";import{ImageryTileLayerViewMixin as p}from"../../layers/ImageryTileLayerViewMixin.js";import u from"../../layers/LayerView.js";import{RefreshableLayerView as y}from"../../layers/RefreshableLayerView.js";import{createQueryGeometry as c}from"../../support/drapedUtils.js";import{getWebGLCapabilities as f}from"../../webgl/capabilities.js";let b=class extends(p(y(h(o(u))))){constructor(){super(...arguments),this.type="imagery-tile-3d",this._isAlignedMapTile=!0,this._flowSubView=null,this.ignoresMemoryFactor=!1,this.unloadedMemory=0}initialize(){this.layer.increaseRasterJobHandlerUsage(),null==this.fullExtent&&this.addResolvingPromise(Promise.reject(new t("layerview:spatial-reference-incompatible","The layer extent cannot be projected to the view's spatial reference",{layer:this.layer})));const e=i(()=>this.view?.basemapTerrain?.tilingSchemeLocked).then(()=>{const e=this.view.basemapTerrain.tilingScheme,t=this.layer.tileInfo;this._isAlignedMapTile=["png","png24","png32","jpg","mixed"].includes(t.format)&&e.compatibleWith(t),this.tileInfo=this._isAlignedMapTile?t:e.toTileInfo(),this.addHandles([r(()=>this.layer.renderer,e=>{this._setSubView(e),this._updatingHandles.addPromise(this.doRefresh())},s),r(()=>[this.layer.interpolation,this.layer.bandIds,this.layer.multidimensionalDefinition,this.layer.multidimensionalSubset,this.layer.rasterFunction,this.timeExtent],()=>this._updatingHandles.addPromise(this.doRefresh()),s)])});this._setSubView(this.layer.renderer),this.addResolvingPromise(e)}destroy(){this.layer.decreaseRasterJobHandlerUsage(),this._flowSubView?.destroy()}_setSubView(e){if("wcs"===this.layer.type)return;const t="flow"===e?.type,i=this._flowSubView;t&&null!=i||(i?.destroy(),this._flowSubView=t?new m({layerView:this}):null)}get _blankTile(){const e=document.createElement("canvas"),t=e.getContext("2d"),[i,r]=this.tileInfo.size;return e.width=i,e.height=r,t.clearRect(0,0,i,r),t.getImageData(0,0,i,r)}get _hasFlow(){return null!=this._flowSubView}get imageFormatIsOpaque(){return"jpg"===this.layer.tileInfo.format}get hasMixedImageFormats(){return"mixed"===this.layer.tileInfo.format}get dataLevelRange(){const e=this.layer.tileInfo,t=this.tileInfo.lodAt(0)?.scale,i=e.lodAt(e.lods.length-1)?.scale;return this.levelRangeFromScaleRange(t,i)}get visibleAtCurrentScale(){return this._flowSubView?.visibleAtCurrentScale??this.tilesVisibleAtCurrentScale()}_getFullExtent(){return n(this.layer.serviceRasterInfo,this.view.basemapTerrain?.spatialReference??this.view.spatialReference)}async fetchTile(e,t){const i=this.tileInfo,r=this._canSymbolizeInWebGL(),s={tileInfo:i,requestRawData:r&&!this._hasFlow,signal:t.signal,timeExtent:this.timeExtent,requestAsImageElement:this._isAlignedMapTile,requestProjectedLocalDirections:this._hasFlow,noClip:!1},{layer:a}=this,[l,n,o]=e,h=await a.fetchTile(l,n,o,s);if(h instanceof HTMLImageElement)return h;let m=h?.pixelBlock;if(null==m)return this._blankTile;if(!r&&!this._hasFlow&&(m=await a.applyRenderer(h),null==m))return this._blankTile;const p=new d([l,n,o],m,i.size[0],i.size[1]);return r?(p.symbolizerRenderer=a.symbolizer.rendererJSON,p.symbolizerParameters=a.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(l)),p.transformGrid=h.transformGrid,p.bandIds=a.bandIds):(p.isRendereredSource=!0,p.bandIds=null),p.interpolation=a.interpolation,p}_getSymbolizerOptions(e){const t=this.tileInfo.lodAt(e).resolution;return{pixelBlock:null,isGCS:null!=this.view.basemapTerrain?.spatialReference?this.view.basemapTerrain.spatialReference.isGeographic:this.view.spatialReference.isGeographic,resolution:{x:t,y:t},bandIds:this.layer.bandIds}}ensureSymbolizerParameters(e){this._canSymbolizeInWebGL()&&JSON.stringify(e.symbolizerRenderer)!==JSON.stringify(this.layer.symbolizer.rendererJSON)&&(e.symbolizerParameters=this.layer.symbolizer.generateWebGLParameters(this._getSymbolizerOptions(e.lij[0])))}createFetchPopupFeaturesQueryGeometry(e,t){return c(e,t,this.view)}async doRefresh(){this.suspended||(this._flowSubView?.doRefresh(),this.emit("data-changed"))}isUpdating(){return this._flowSubView?.updating??!1}_canSymbolizeInWebGL(){const e=f(),{symbolizer:t}=this.layer,i=t.lookup.colormapLut?.indexedColormap,r=!!this.layer.rasterFunction?.hasClipFunction,s=i&&i.length>4*(e.maxTextureSize||4096);return t.canRenderInWebGL&&!s&&!r}get usedMemory(){return this._flowSubView?.usedMemory??0}get test(){}};e([a({readOnly:!0})],b.prototype,"_blankTile",null),e([a()],b.prototype,"_hasFlow",null),e([a({readOnly:!0})],b.prototype,"imageFormatIsOpaque",null),e([a({readOnly:!0})],b.prototype,"hasMixedImageFormats",null),e([a()],b.prototype,"_flowSubView",void 0),e([a({readOnly:!0})],b.prototype,"dataLevelRange",null),e([a({readOnly:!0})],b.prototype,"visibleAtCurrentScale",null),b=e([l("esri.views.3d.layers.ImageryTileLayerView3D")],b);const g=b;export{g 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{__decorate as e}from"tslib";import has from"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as i,removeMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}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 c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as u,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as y,b,t as _}from"../../../chunks/vec32.js";import{freeze as v,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x,getReferenceEllipsoid as M}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as O}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as E}from"../../../geometry/projection/projectVectorToVector.js";import{create as T}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as R,BufferViewVec4f as U,BufferViewVec4u8 as P,BufferViewVec4u16 as H,BufferViewVec3f as V,BufferViewVec3u8 as S,BufferViewVec3u16 as A,BufferViewInt16 as I,BufferViewUint32 as k,BufferViewUint16 as F}from"../../../geometry/support/buffer/BufferView.js";import D from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as L}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as N}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as z,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Z}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ee}from"../support/ElevationRange.js";import{toBoundingRect as te}from"../support/extentUtils.js";import{compute as ie,Obb as re}from"../support/orientedBoundingBox.js";import{ObjectParameters as se}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as oe,createVertexBufferLayout as ne,SourceGeometry as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as le}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as he}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ue}from"../webgl-engine/lib/Normals.js";import{writeAttribute as pe,writeBufferVec2 as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ye,isInEffectiveScaleRange as be,validateScaleRange as _e}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as ve}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";class je{constructor(e,t,i,r,s,o,n,a,l){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.elevationRange=l,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=w();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,r=i[0]-e[0],s=i[1]-e[1],o=i[2]-e[2],n=r*t[0]+s*t[1]+o*t[2];return r*r+s*s+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){if(!this.obb)return!0;const t=e.center,i=this._obbCenter,r=i[0]-t[0],s=i[1]-t[1],o=i[2]-t[2];return r*r+s*s+o*o<=(this._obbRadius+e.radius)**2}}function xe(e){return Math.round(e/1048.576)/1e3}let Me=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new ve,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._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{s(t),this.layer=e}):null}canRecycleWith(e){return e.url===this.layer.url&&"integrated-mesh-3dtiles"===e.type}initialize(){this._dbgFlags.add(3),this._dbg(2,"Tiles3DLayerView3D initialize() called");const{view:e}=this;if(this._updatingHandles.add(()=>this.layer.modifications,()=>this._loadModifications(),o),!this._canProjectWithoutEngine())throw ye("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=z(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Z(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._elevationProvider=new q({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.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.updateMaterial(t,t=>t.objectOpacity=e))}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!0}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),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._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=T();this._layerClippingArea=te(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,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,L(e))}get _wasm(){return $(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||be(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||_e(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new N(this.usedMemory,s,o,xe(t),xe(e),xe(r),xe(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){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 L(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ee(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ee;return 0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this.forEachVisibleTile(t=>e.expandElevationRange(t.elevationRange))),e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}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)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=v(...i.desc.origin),s=this.view.basemapTerrain.spatialReference;let o,n;if("global"===this.view.viewingMode){const e=f();O(x,r,e,s),o=h(u(),e),n=m(u(),o)}else o=p,n=p;const a=w(),l=Te(i.desc.obb);let c=0,d=0;const g={textureMemoryUsage:0},T=new Array,U=new Map,P=i.desc.prims.length,H=new Array,V=new ee;try{const e="global"===this.view.viewingMode,t=e?M(this.view.spatialReference).radius:0;for(let h=0;h<P;h++){const m=i.desc.prims[h];this._dbg(2,JSON.stringify(m));if(null==J[m.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const u=i.desc?.materials&&null!=m.materialId?i.desc.materials[m.materialId]:null,f=null!=u?u.lightingModel:"Unlit",{positionView:v,positionAttr:x,normalsView:M,normalsAttr:O,colorAttr:P,texCoord0Attr:H,indicesView:S}=this.getBufferViews(m,i.data.buffer,o);if(null==x||null==v||null==S)continue;const A=new oe(null!=P,H?1:0,null!=M,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),I=x.data.length/x.size,k=(e,t)=>!e||e.data.length/e.size===I||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!k(H,"numTexcoord")||!k(P,"numColors")||!k(O,"normals"))continue;const F=ne(A);for(let i=0;i<v.count;i++){v.getVec(i,a),y(a,a,r);const s=e?b(a)-t:a[2];V.expandElevationRangeValues(s,s)}const D=l?.clone()??Ee(x,r);if(o!==p)for(let e=0;e<v.count;e++)v.getVec(e,a),_(a,a,o),v.setVec(e,a);const L=F.createBuffer(x.data.length);if(pe("position",x,null,null,L,0),null!=H){const e=L.getField("uv0",R);fe(H,e,0)}null!=P&&pe("color",P,null,null,L,0),null!=O&&pe("normalCompressed",O,null,null,L,0);const B=new Uint32Array([0,S.typedBuffer.length]),G=new ae({data:L.buffer,count:L.byteLength/F.stride,layoutParameters:A},{positions:v.typedBuffer,indices:S.typedBuffer},S.typedBuffer,B);c+=v.count+S.count;const N=this.view.renderSpatialReference,z=w(),W=[1,1,1];C(r,N,W,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),E(r,N,z,s);let $=()=>{},q=Promise.resolve(Ue);if(u){const e=e=>this._getTexture(e,i,U,g),t=e(u.baseColorTex),r="Pbr"===f,s=r?e(u.metalTex):null,o=r?e(u.emissiveTex):null,n=r?e(u.occlusionTex):null,a=r?e(u.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);q=Promise.all(l),$=e=>{e.baseColor=u.baseColorFactor,e.usePBR="Pbr"===f,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[u.metallicFactor,u.roughnessFactor,0],e.emissiveBaseColor=u.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[u.alphaMode],e.objectOpacity=this.fullOpacity,g.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(g.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=u.isDoubleSided,e.commonMaterialParameters.cullFace=Q[u.faceCulling??"NotSet"],e.commonMaterialParameters.isGround=this.layer.replacesTerrain,e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=u.alphaCutoff??we,e.alphaDiscardMode=K[u.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)}}const X=q.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)}const e=this._collection.createObject(new se(j(z[0],z[1],W[0],W[1]),new le(r,n),D,G,!1));return this._collection.updateMaterial(e,$),d+=this._collection.getObjectGPUMemoryUsage(e),e});T.push(X)}if(H.push(...await Promise.all(T)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(k){throw U.forEach(e=>this._stage.removeTexture(e)),k}const S=H.map(e=>e()),A=new Array;U.forEach(e=>A.push(e));const I=new je(e.handle,S,A,c,d,g.textureMemoryUsage,l,e.stableNodeId,V);return this._lyrHandleToObjects.set(e.handle,I),this._memCache.put(Re(I.handle),I),t=I.usedMemory,this._cacheMemory+=t,{memUsageBytes:I.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=Re(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){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory;const{minElevation:e,maxElevation:t}=o.elevationRange;(e<this.visibleElevationRange.minElevation||t>this.visibleElevationRange.maxElevation)&&this._setVisibleElevationRangeDirty(),o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(Re(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory;const{minElevation:e,maxElevation:t}=o.elevationRange;e!==this.visibleElevationRange.minElevation&&t!==this.visibleElevationRange.maxElevation||this._setVisibleElevationRangeDirty(),o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(Re(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=X[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="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&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new me(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Y[u.type],y=new(Pe(g))(g);for(let e=0;e<g;++e)y[e]=e;try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new V(t,u.byteOffset,p,f),s=new he(r.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new V(t,u.byteOffset,p,f),r=ue(e.typedBuffer,i);a=new I(r.buffer),l=new he(a.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new he(new R(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new U(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new P(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new H(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new S(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new A(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new he(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new F(t,i.byteOffset,r,s);break;case"U32":c=new k(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;c=c=e<65535?new F(new Uint16Array(e).buffer):new k(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,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([c()],Me.prototype,"fullOpacity",null),e([c({type:[D]})],Me.prototype,"_modifications",void 0),e([c()],Me.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],Me.prototype,"layer",void 0),e([c({readOnly:!0})],Me.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],Me.prototype,"_collection",null),e([c()],Me.prototype,"elevationOffset",null),e([c({readOnly:!0})],Me.prototype,"visibleElevationRange",null),Me=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Me);const Oe=Me,Ce=w();function Ee(e,t){const i=ie(e);return y(Ce,i.center,t),i.center=Ce,i}function Te(e){return e?new re(e.center,e.halfSize,g(...e.quaternion)):null}function Re(e){return`${e}`}const Ue=new Array;function Pe(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Oe 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 r}from"../../../core/maybe.js";import{throwIfAborted as s}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 c,subclass as d}from"../../../core/accessorSupport/decorators.js";import{fromMat4 as h,invert as m}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as u,IDENTITY as p}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as g}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{i as y,b,t as _}from"../../../chunks/vec32.js";import{freeze as v,create as w}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as j}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{SphericalECEFSpatialReferenceLike as x,getReferenceEllipsoid as M}from"../../../geometry/ellipsoidUtils.js";import{computeTranslationToOriginAndRotation as O}from"../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{localLinearScaleFactors as C}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectVectorToVector as T}from"../../../geometry/projection/projectVectorToVector.js";import{create as E}from"../../../geometry/support/aaBoundingRect.js";import{BufferViewVec2f as R,BufferViewVec4f as U,BufferViewVec4u8 as P,BufferViewVec4u16 as H,BufferViewVec3f as A,BufferViewVec3u8 as V,BufferViewVec3u16 as S,BufferViewInt16 as I,BufferViewUint32 as L,BufferViewUint16 as k}from"../../../geometry/support/buffer/BufferView.js";import F from"../../../layers/support/SceneModification.js";import{getElevationOffsetInMeters as D}from"../../../support/elevationInfoUtils.js";import{toWasmModification as B}from"./I3SMeshWorkerHandle.js";import{LayerView3D as G}from"./LayerView3D.js";import{Lyr3DViewPerformanceInfo as N}from"./Lyr3DViewPerformanceInfo.js";import{addLayerViewToWasm as z,removeLayerViewFromWasm as W,getLyr3DWasm as $}from"./Lyr3DWasm.js";import{LayerElevationProvider as q}from"./i3s/LayerElevationProvider.js";import{primTypeConversion as J,alphaModeConversion as K,faceCullingConversion as Q,wrapModeConversion as X,lyr3DTypeToByteSize as Y}from"./support/lyr3dTypeConversions.js";import{Tiles3DIntersectionHandler as Z}from"./support/Tiles3DIntersectionHandler.js";import{ElevationRange as ee}from"../support/ElevationRange.js";import{toBoundingRect as te}from"../support/extentUtils.js";import{compute as ie,Obb as re}from"../support/orientedBoundingBox.js";import{ObjectParameters as se}from"../webgl-engine/collections/Component/ObjectParameters.js";import{GeometryParameters as oe,createVertexBufferLayout as ne,SourceGeometry as ae}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as le}from"../webgl-engine/collections/Component/Transform.js";import{RenderTexture as ce}from"../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as de}from"../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Attribute as he}from"../webgl-engine/lib/Attribute.js";import{ManagedTexture as me}from"../webgl-engine/lib/ManagedTexture.js";import{compressAndTransformNormals as ue}from"../webgl-engine/lib/Normals.js";import{writeAttribute as pe,writeBufferVec2 as fe}from"../webgl-engine/materials/internal/bufferWriterUtils.js";import ge from"../../layers/LayerView.js";import{spatialReferenceIncompatibleError as ye,isInEffectiveScaleRange as be,validateScaleRange as _e}from"../../support/layerViewUtils.js";import{TextureCompressionTracker as ve}from"../../support/TextureCompressionTracker.js";import{alphaCutoff as we}from"../../../webscene/support/AlphaCutoff.js";class je{constructor(e,t,i,r,s,o,n,a,l){this.handle=e,this.componentObjects=t,this.textures=i,this.cpuMemoryUsage=r,this.vboMemoryUsage=s,this.textureMemoryUsage=o,this.obb=n,this.stableNodeId=a,this.elevationRange=l,this.isVisible=!1,this.usedMemory=this.textureMemoryUsage+this.vboMemoryUsage+this.cpuMemoryUsage;const c=w();n?.getCenter(c),this._obbCenter=c,this._obbRadius=n?.radius??0,this._obbRadiusSquared=this._obbRadius**2}boundingVolumeIntersectsRay(e,t){if(!this.obb)return!0;const i=this._obbCenter,r=i[0]-e[0],s=i[1]-e[1],o=i[2]-e[2],n=r*t[0]+s*t[1]+o*t[2];return r*r+s*s+o*o-n*n<=this._obbRadiusSquared&&this.obb.intersectRay(e,t)}boundingVolumeIntersectsSphere(e){if(!this.obb)return!0;const t=e.center,i=this._obbCenter,r=i[0]-t[0],s=i[1]-t[1],o=i[2]-t[2];return r*r+s*s+o*o<=(this._obbRadius+e.radius)**2}}function xe(e){return Math.round(e/1048.576)/1e3}let Me=class extends(G(ge)){get hasModifications(){return this._modifications&&this._modifications.length>0}constructor(e){super(e),this.type="integrated-mesh-3dtiles",this._compressionTracker=new ve,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._suspendedHandle=null,this._dbgFlags=new Set,this._memCache=e.view.resourceController.memoryController.newCache(`IM3DTiles-${this.uid}`,e=>this._deletePerObjectData(e))}tryRecycleWith(e,t){return this.canRecycleWith(e)?e.load(t).then(()=>{s(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 ye("layer",this.layer.spatialReference.wkid,e.renderSpatialReference?.wkid);const t=z(this).then(t=>{this._wasmLayerId=t,this._intersectionHandler=new Z(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._elevationProvider=new q({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.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.updateMaterial(t,t=>t.objectOpacity=e))}intersect(e,t,i,r){this._intersectionHandler.intersect(e,t,i,r,null,!1)}get ready(){return!this.layer.replacesTerrain||!!this._wasm?.isTerrainReady}destroy(){this._dbg(2,"Tiles3DLayerView3D destroy() called"),W(this),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._usedMemory=this._cacheMemory=0,this._memCache.destroy(),this._updatingHandles=i(this._updatingHandles),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=r(this._visibleGeometryChangedSchedulerHandle)}_modificationsChanged(){const e=this.layer.spatialReference,t=B(this._layerClippingArea,this._modifications,e);this._wasm?.setMeshModifications(this,t,e.wkid)}_clippingAreaChanged(){const e=this.layer.spatialReference,t=E();this._layerClippingArea=te(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,t=>t.commonMaterialParameters.hasSlicePlane=e))}_elevationInfoChanged(e){this._wasm?.setLayerOffset(this,D(e))}get _wasm(){return $(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||be(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||_e(e)&&this.visibleAtCurrentScale)&&this.visibleAtCurrentTimeExtent||!1}get performanceInfo(){let e=0,t=0,i=0,r=0,s=0,o=0;return this._lyrHandleToObjects.forEach(n=>{n.isVisible?(e+=n.textureMemoryUsage,t+=n.vboMemoryUsage,s++):(i+=n.textureMemoryUsage,r+=n.vboMemoryUsage,o++)}),new N(this.usedMemory,s,o,xe(t),xe(e),xe(r),xe(i))}_canProjectWithoutEngine(){if(2===this.view.state.viewingMode){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 D(this.layer.elevationInfo)}get elevationRange(){const e=this.fullExtent;return e?.zmin&&e?.zmax?new ee(e.zmin,e.zmax):null}getElevationRange(e){return this._intersectionHandler.getElevationRange(e)}get visibleElevationRange(){const e=new ee;return 0===this._visibleObjects.size?e.setElevationRangeValues(0,0):(e.setElevationRangeValues(1/0,-1/0),this.forEachVisibleTile(t=>e.expandElevationRange(t.elevationRange))),e}_setVisibleElevationRangeDirty(){this.notifyChange("visibleElevationRange")}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)}let t=0;const{meshData:i}=e;if(null==i.data)throw new Error("meshData.data undefined");if(i.desc=JSON.parse(i.desc),null==i.desc)throw new Error("meshData.desc undefined");const r=v(...i.desc.origin),s=this.view.basemapTerrain.spatialReference;let o,n;if("global"===this.view.viewingMode){const e=f();O(x,r,e,s),o=h(u(),e),n=m(u(),o)}else o=p,n=p;const a=w(),l=Ee(i.desc.obb);let c=0,d=0;const g={textureMemoryUsage:0},E=new Array,U=new Map,P=i.desc.prims.length,H=new Array,A=new ee;try{const e="global"===this.view.viewingMode,t=e?M(this.view.spatialReference).radius:0;for(let h=0;h<P;h++){const m=i.desc.prims[h];this._dbg(2,JSON.stringify(m));if(null==J[m.ptype]||null==i.data){this._dbg(2,"[Unsupported Feature] Unsupported primitive mode ("+m.ptype+"). Skipping primitive.");continue}const u=i.desc?.materials&&null!=m.materialId?i.desc.materials[m.materialId]:null,f=null!=u?u.lightingModel:"Unlit",{positionView:v,positionAttr:x,normalsView:M,normalsAttr:O,colorAttr:P,texCoord0Attr:H,indicesView:V}=this.getBufferViews(m,i.data.buffer,o);if(null==x||null==v||null==V)continue;const S=new oe(null!=P,H?1:0,null!=M,this._shadeNormals||this.layer.replacesTerrain,this._applySSAO),I=x.data.length/x.size,L=(e,t)=>!e||e.data.length/e.size===I||(this._dbg(3,`${t} !== numPos. Skipping primitive.`),!1);if(!L(H,"numTexcoord")||!L(P,"numColors")||!L(O,"normals"))continue;const k=ne(S);for(let i=0;i<v.count;i++){v.getVec(i,a),y(a,a,r);const s=e?b(a)-t:a[2];A.expandElevationRangeValues(s,s)}const F=l?.clone()??Te(x,r);if(o!==p)for(let e=0;e<v.count;e++)v.getVec(e,a),_(a,a,o),v.setVec(e,a);const D=k.createBuffer(x.data.length);if(pe("position",x,null,null,D,0),null!=H){const e=D.getField("uv0",R);fe(H,e,0)}null!=P&&pe("color",P,null,null,D,0),null!=O&&pe("normalCompressed",O,null,null,D,0);const B=new Uint32Array([0,V.typedBuffer.length]),G=new ae({data:D.buffer,count:D.byteLength/k.stride,layoutParameters:S},{positions:v.typedBuffer,indices:V.typedBuffer},V.typedBuffer,B);c+=v.count+V.count;const N=this.view.renderSpatialReference,z=w(),W=[1,1,1];C(r,N,W,s)||this._dbg(3,"Unsupported coordinate system for IM overlay"),T(r,N,z,s);let $=()=>{},q=Promise.resolve(Ue);if(u){const e=e=>this._getTexture(e,i,U,g),t=e(u.baseColorTex),r="Pbr"===f,s=r?e(u.metalTex):null,o=r?e(u.emissiveTex):null,n=r?e(u.occlusionTex):null,a=r?e(u.normalTex):null,l=[t,s,o,n,a].map(e=>e?.loadPromise??null);q=Promise.all(l),$=e=>{e.baseColor=u.baseColorFactor,e.usePBR="Pbr"===f,e.hasParametersFromSource=!1,e.baseColorTexture=t,e.usePBR&&(e.mrrFactors=[u.metallicFactor,u.roughnessFactor,0],e.emissiveBaseColor=u.emissiveFactor??[0,0,0],e.metallicRoughnessTexture=s,e.emissionTexture=o,e.occlusionTexture=n,e.normalTexture=a),e.alphaDiscardMode=K[u.alphaMode],e.objectOpacity=this.fullOpacity,g.textureMemoryUsage+=e.baseColorTexture?.texture?.usedMemory??0,e.usePBR&&(g.textureMemoryUsage+=(e.metallicRoughnessTexture?.texture?.usedMemory??0)+(e.emissionTexture?.texture?.usedMemory??0)+(e.occlusionTexture?.texture?.usedMemory??0)+(e.normalTexture?.texture?.usedMemory??0)),e.commonMaterialParameters.doubleSided=u.isDoubleSided,e.commonMaterialParameters.cullFace=Q[u.faceCulling??"NotSet"],e.commonMaterialParameters.isGround=this.layer.replacesTerrain,e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.componentParameters.castShadows=0,e.textureAlphaCutoff=u.alphaCutoff??we,e.alphaDiscardMode=K[u.alphaMode],e.isIntegratedMesh=!0,e.sphereDepthInterpolate=this.layer.hasGoogleUrl,e.polygonOffsetEnabled=!1,e.hasOccludees=!1,e.ellipsoidMode=de(this.view.spatialReference)}}const X=q.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)}const e=this._collection.createObject(new se(j(z[0],z[1],W[0],W[1]),new le(r,n),F,G,!1));return this._collection.updateMaterial(e,$),d+=this._collection.getObjectGPUMemoryUsage(e),e});E.push(X)}if(H.push(...await Promise.all(E)),this.destroyed){throw new Error("IntegratedMesh3DTilesLayerView3D: createRenderable object destroyed during call")}}catch(L){throw U.forEach(e=>this._stage.removeTexture(e)),L}const V=H.map(e=>e()),S=new Array;U.forEach(e=>S.push(e));const I=new je(e.handle,V,S,c,d,g.textureMemoryUsage,l,e.stableNodeId,A);return this._lyrHandleToObjects.set(e.handle,I),this._memCache.put(Re(I.handle),I),t=I.usedMemory,this._cacheMemory+=t,{memUsageBytes:I.usedMemory}}freeRenderable(e){const t=this._lyrHandleToObjects.get(e);t&&(t.isVisible?(this._visibleObjects.delete(t),this._usedMemory-=t.usedMemory):this._cacheMemory-=t.usedMemory,this.freeObject(t),this._lyrHandleToObjects.delete(e))}freeObject(e){const t=Re(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){for(let r=0;r<i;++r){const i=t[r];if(!i)continue;const s=e[r],o=this._lyrHandleToObjects.get(s);if(o){if(o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!0,this._visibleObjects.add(o),this._usedMemory+=o.usedMemory,this._cacheMemory-=o.usedMemory;const{minElevation:e,maxElevation:t}=o.elevationRange;(e<this.visibleElevationRange.minElevation||t>this.visibleElevationRange.maxElevation)&&this._setVisibleElevationRangeDirty(),o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,i),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.pop(Re(s))}}for(let r=0;r<i;++r){const i=e[r],s=t[r];if(s)continue;const o=this._lyrHandleToObjects.get(i);if(o){if(!o.isVisible)continue;this._visibleGeometryChanged(),o.isVisible=!1,this._visibleObjects.delete(o),this._usedMemory-=o.usedMemory,this._cacheMemory+=o.usedMemory;const{minElevation:e,maxElevation:t}=o.elevationRange;e!==this.visibleElevationRange.minElevation&&t!==this.visibleElevationRange.maxElevation||this._setVisibleElevationRangeDirty(),o.componentObjects.forEach(e=>{this._collection.setObjectVisibility(e,s),this._elevationProvider.notifyObjectChanged(this._collection.getComponentObb(e))}),this._memCache.put(Re(i),o)}}}setLodPixelThreshold(e){this._wasm?.setLodPixelThreshold(this,e)}_getTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=i.get(s)??this._createTexture(e,t,i,r);return o?new ce(this._stage.renderView.textures,o.id):null}_createTexture(e,t,i,r){const s=e&&t.desc?.images?.[e.imageId];if(!s||!t.data?.buffer)return null;const o=this._stage,{renderView:n}=o,a=n.renderingContext.parameters.maxMaxAnisotropy,l=!!s.mipCount||a>1,c=X[e.wrapMode??"None"];let d=s.alpha?6408:6407;const h=new Uint8Array(t.data.buffer,s.data.byteOffset,s.data.byteCount);let m=null,u=null,p=null;switch(s.format){case"Raw":"R8"===s.pixelFormat?(m=h,d=6403,u=""):"Rgb8"===s.pixelFormat?(m=h,d=6407,u=""):"Rgba8"===s.pixelFormat&&(m=h,d=6408,u="");break;case"Dxt1":m=h,d=6407,u="image/vnd-ms.dds";break;case"Dxt5":m=h,d=6408,u="image/vnd-ms.dds";break;case"Basis":m=h,d=6407,u="image/ktx2";break;case"Png":u="image/png",p=document.createElement("img");break;case"Jpeg":u="image/jpeg",p=document.createElement("img");break;case"Etc2":u="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&&u){const e=new Blob([h],{type:u});p.src=URL.createObjectURL(e),m=p}if(m&&null!=u){const e=has("enable-feature:esri-compress-IM-textures")?{compressionTracker:this._compressionTracker,compressionCallback:e=>{e&&e>0&&(r.textureMemoryUsage-=e)}}:void 0,t=new me(m,{mipmap:l,maxAnisotropy:a,encoding:u,wrap:c,pixelFormat:d,compressionOptions:e,noUnpackFlip:!0,width:s.mip0Width,height:s.mip0Height});return this._stage.addTexture(t),i.set(s,t),t}return null}getBufferViews(e,t,i){let r,s,o,n,a,l,c,d=null;for(let m=0;m<e.atrbs.length;m++){const c=e.atrbs[m],{view:u}=c,p=void 0,f=u.byteOffset+u.byteCount,g=u.byteCount/Y[u.type],y=new(Pe(g))(g);for(let e=0;e<g;++e)y[e]=e;try{switch(c.sem){case"Position":3!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Position ("+u+")"):(r=new A(t,u.byteOffset,p,f),s=new he(r.typedBuffer,y,3));break;case"Normal":if(3!==u.ncomp||"F32"!==u.type)this._dbg(3,"[Unsupported Feature] Unsupported view for Normal ("+u+")");else{const e=new A(t,u.byteOffset,p,f),r=ue(e.typedBuffer,i);a=new I(r.buffer),l=new he(a.typedBuffer,y,2)}break;case"TexCoord":2!==u.ncomp||"F32"!==u.type?this._dbg(3,"[Unsupported Feature] Unsupported view for Texcoord ("+u+")"):void 0===n&&(n=new he(new R(t,u.byteOffset,p,f).typedBuffer,y,2));break;case"Color":4===u.ncomp?("F32"===u.type&&(d=new U(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new P(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new H(t,u.byteOffset,p,f))):3===u.ncomp&&("F32"===u.type&&(d=new A(t,u.byteOffset,p,f)),"U8"===u.type&&(d=new V(t,u.byteOffset,p,f)),"U16"===u.type&&(d=new S(t,u.byteOffset,p,f))),null==d?this._dbg(2,"[Unsupported Feature] Unsupported view for Color ("+u+")"):o=new he(d.typedBuffer,y,u.ncomp);break;case"FeatureIndex":break;default:this._dbg(2,"[Unsupported Feature] Unsupported semantic ("+c.sem+"). Skipping vertex attribute.")}}catch(h){this._dbg(2,"Error Creating buffer ("+h+"). Skipping vertex attribute.")}}if(e.index){const i=e.index.view,r=void 0,s=i.byteOffset+i.byteCount;switch(e.index.view.type){case"U16":c=new k(t,i.byteOffset,r,s);break;case"U32":c=new L(t,i.byteOffset,r,s);break;default:this._dbg(3,"[Unsupported Feature] index type not supported ("+i.type+").")}}if(null==c&&null!=r){const e=r.count;c=c=e<65535?new k(new Uint16Array(e).buffer):new L(new Uint32Array(e).buffer);for(let t=0;t<e;t++)c.set(t,t)}return{positionView:r,positionAttr:s,colorAttr:o,texCoord0Attr:n,indicesView:c,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([c()],Me.prototype,"fullOpacity",null),e([c({readOnly:!0})],Me.prototype,"ready",null),e([c({type:[F]})],Me.prototype,"_modifications",void 0),e([c()],Me.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([c()],Me.prototype,"layer",void 0),e([c({readOnly:!0})],Me.prototype,"visibleAtCurrentScale",null),e([c({readOnly:!0})],Me.prototype,"_collection",null),e([c()],Me.prototype,"elevationOffset",null),e([c({readOnly:!0})],Me.prototype,"visibleElevationRange",null),Me=e([d("esri.views.3d.layers.IntegratedMesh3DTilesLayerView3D")],Me);const Oe=Me,Ce=w();function Te(e,t){const i=ie(e);return y(Ce,i.center,t),i.center=Ce,i}function Ee(e){return e?new re(e.center,e.halfSize,g(...e.quaternion)):null}function Re(e){return`${e}`}const Ue=new Array;function Pe(e){return e<256?Uint8Array:e<65536?Uint16Array:Uint32Array}export{Oe 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 e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import"../../../../core/has.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{h as g,i as x,j as _,p as y,t as T,n as b,c as v,e as w,f as C,g as j}from"../../../../chunks/vec32.js";import{create as M,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 je,advancedMRRFactors as Me,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}`,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(r,o){if(null!=r.colorTexture){const e=1!==o.textureAlphaMode,t=this._getInternalTexture(r.colorTexture,e,o.textureAlphaMode);t?(o.textureId=t.id,o.textureAlphaPremultiplied=!!t.parameters.preMultiplyAlpha):o.textureId=void 0}if(r.normalTexture&&(o.normalTextureId=this._getInternalTexture(r.normalTexture)?.id),r.emissiveColor){const n=e.toUnitRGB(r.emissiveColor);o.emissiveBaseColor=R(t(n[0]),t(n[1]),t(n[2]))}r.emissiveStrength&&(o.emissiveStrengthKHR=r.emissiveStrength),r.emissiveTexture&&(o.emissiveTextureId=this._getInternalTexture(r.emissiveTexture)?.id),r.occlusionTexture&&(o.occlusionTextureId=this._getInternalTexture(r.occlusionTexture,!0)?.id),r.metallicRoughnessTexture&&(o.metallicRoughnessTextureId=this._getInternalTexture(r.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(t,r=this._materialColor){const o=this._drivenProperties.color,n=this._drivenProperties.opacity;if(o)t.externalColor=S;else{const o=r??null;if(o){const r=e.toUnitRGBA(o);n&&(r[3]=1),t.externalColor=r}else t.externalColor=fe}t.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(Le(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return this._setInternalMaterialTextureParameters(l,c.material.parameters),c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=je({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:P,diffuse:A,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Re:[l.metallic,l.roughness,Me[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?0:2,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new we(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),p}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?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=M(),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],j(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:M(),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(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.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=M(),Je=M(),Qe=M(),Xe=M(),Ze=M(),et=f(),tt=f(),rt=O(),ot=[new L],nt=M();export{Pe as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import"../../../../core/has.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{h as g,i as x,j as _,p as y,t as T,n as b,c as v,e as w,f as C,g as j}from"../../../../chunks/vec32.js";import{create as M,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 je,advancedMRRFactors as Me,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(r,o){if(null!=r.colorTexture){const e=1!==o.textureAlphaMode,t=this._getInternalTexture(r.colorTexture,e,o.textureAlphaMode);t?(o.textureId=t.id,o.textureAlphaPremultiplied=!!t.parameters.preMultiplyAlpha):o.textureId=void 0}if(r.normalTexture&&(o.normalTextureId=this._getInternalTexture(r.normalTexture)?.id),r.emissiveColor){const n=e.toUnitRGB(r.emissiveColor);o.emissiveBaseColor=R(t(n[0]),t(n[1]),t(n[2]))}r.emissiveStrength&&(o.emissiveStrengthKHR=r.emissiveStrength),r.emissiveTexture&&(o.emissiveTextureId=this._getInternalTexture(r.emissiveTexture)?.id),r.occlusionTexture&&(o.occlusionTextureId=this._getInternalTexture(r.occlusionTexture,!0)?.id),r.metallicRoughnessTexture&&(o.metallicRoughnessTextureId=this._getInternalTexture(r.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(t,r=this._materialColor){const o=this._drivenProperties.color,n=this._drivenProperties.opacity;if(o)t.externalColor=S;else{const o=r??null;if(o){const r=e.toUnitRGBA(o);n&&(r[3]=1),t.externalColor=r}else t.externalColor=fe}t.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(Le(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return this._setInternalMaterialTextureParameters(l,c.material.parameters),c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=je({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:P,diffuse:A,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Re:[l.metallic,l.roughness,Me[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?0:2,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new we(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),p}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?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=M(),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],j(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:M(),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(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.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=M(),Je=M(),Qe=M(),Xe=M(),Ze=M(),et=f(),tt=f(),rt=O(),ot=[new L],nt=M();export{Pe 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{__decorate as e}from"tslib";import{nullUid as t}from"../../../../../../core/uid.js";import{property as r,subclass as i}from"../../../../../../core/accessorSupport/decorators.js";import{glLayout as n}from"../../../../support/buffer/glUtil.js";import{SyncRenderPlugin as s}from"../../../../webgl-engine/effects/RenderPlugin.js";import{GLMaterials as o}from"../../../../webgl-engine/lib/GLMaterials.js";import{BoundingVolume as a}from"../../../../webgl-engine/lib/Object3D.js";import{VertexArrayObject as l}from"../../../../webgl-engine/lib/VertexArrayObject.js";import{DrawParameters as u}from"../../../../webgl-engine/materials/DrawParameters.js";import{HUDMaterial as c}from"../../../../webgl-engine/materials/HUDMaterial.js";import{bindVertexBufferLayout as m}from"../../../../../webgl/Util.js";import{VertexBuffer as d}from"../../../../../webgl/VertexBuffer.js";let f=class extends s{constructor(e){super(e),this._glMaterials=null,this._produces=new Map,this._renderGeometries=new Map,this._renderContext=null,this._drawParameters=new u,this._bufferWriter=null,this._baseInstance=null,this.slicePlaneEnabled=!1,this.isGround=!1,this.type=e.material instanceof c?1:4,this.layerViewUid=e.layerViewUid}get produces(){return this._produces}get numFeatures(){let e=0;return this._renderGeometries.forEach(t=>e+=t.numElements),e}get usedMemory(){let e=0;return this._renderGeometries.forEach(t=>{e+=t.vao.usedMemory}),e}intersect(e,r,i,n){const{material:s,_bufferWriter:o,layerViewUid:l,_renderGeometries:u}=this;null!=o.intersect&&u.forEach(({buffer:r,localOrigin:u,items:c})=>o.intersect(r.data,s.parameters,u,e,i,n,(r,i,n,o)=>{if(!c.visibilities[n])return;const u=c.objectIds[n];e.handleObjectIntersection({object:{id:t,graphicUid:u,layerViewUid:l,boundingVolumeWorldSpace:new a,geometries:[{material:s}]},geometryId:0,primitiveIndex:n},r,i,null,o)}))}initialize(){this._bufferWriter=this.material.createBufferWriter(),this.material.produces.forEach((e,t)=>{this._produces.set(t,t=>8!==t&&4!==t&&e(t))})}destroy(){this._glMaterials.dispose();const e=this._renderGeometries.keys();for(const t of e)this.removeRenderGeometryBuffer(t);this._baseInstance?.vbo.dispose(),this._baseInstance=null}acquireTechniques(e){const t=this.material;if(!t.shouldRender(e))return null;const{output:r,bind:i}=e,n=t.produces.get(i.slot);if(!n?.(r))return null;if(8===r||4===r)return null;const s=this._glMaterials.load(e.rctx,i.slot,r);return s?.beginSlot(i)}render(e,t){const r=this._renderGeometries;if(0===r.size)return;const{bind:i}=e,n=e.rctx;n.runAppleAmdDriverHelper(),n.bindTechnique(t,i,this.material.parameters);const s=t.program,{_baseInstance:o}=this,a=null==o?e=>{n.drawArrays(t.primitiveType,e.start,e.count)}:(e,r)=>{m(n,r.locations,r.buffer("instances"),e.start),n.drawArraysInstanced(t.primitiveType,0,o.buffer.elementCount,e.count)};for(const[l,u]of r){const{vao:e,localOrigin:r,drawCalls:o}=u;this._drawParameters.origin=r,s.bindDraw(i,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e),n.bindVAO(e),n.setPipelineState(t.getPipeline(i,!1));for(const t of o)a(t,e)}}initializeRenderContext(e){this._glMaterials=new o(this.material,e.materials),this._renderContext=e.renderContext}uninitializeRenderContext(){}addRenderGeometryBuffer(e,t,r,i){this.removeRenderGeometryBuffer(e);const{data:s,elementCount:o}=t,{_baseInstance:a,_bufferWriter:u,_renderContext:{rctx:c}}=this,m=null==a?u.layout:u.instanceLayout;if(!m)throw new Error("Cannot create instance buffer for non-instanced material");const f=new d(c,n(m,null==a?0:1),s);let h;h=new l(c,null==a?new Map([["geometry",f]]):new Map([["geometry",a.vbo],["instances",f]]));const b={localOrigin:i,numElements:o,buffer:t,items:r,vao:h,drawCalls:this._produceDrawCalls(r)};this._renderGeometries.set(e,b)}updateRenderGeometryBuffer(e,t,r,i){const{data:n,elementCount:s}=t,o=this._renderGeometries.get(e);if(null==o)return;const a=o.vao.buffer(null==this._baseInstance?"geometry":"instances");a?.setSize(n.byteLength),a?.setSubData(new Uint8Array(n),0,0,n.byteLength),o.localOrigin=i,o.numElements=s,o.buffer=t,o.items=r,o.drawCalls=this._produceDrawCalls(r)}removeRenderGeometryBuffer(e){const t=this._renderGeometries.get(e);null!=t&&(this._baseInstance?(t.vao.buffer("instances")?.dispose(),t.vao.disposeVAOOnly()):t.vao.dispose(),this._renderGeometries.delete(e))}updateVisibility(e,t){const r=this._renderGeometries.get(e);if(null==r)return;const{items:i}=r;if(i.visibilities.length!==t.length)throw new Error("Unexpected mismatch between old and new visibility flag buffer length.");i.visibilities=t,r.drawCalls=this._produceDrawCalls(i)}setBaseInstance(e){if(this._baseInstance?.vbo.dispose(),null==e)return void(this._baseInstance=null);const{data:t}=e,r=new d(this._renderContext.rctx,n(this._bufferWriter.layout),t);this._baseInstance={buffer:e,vbo:r}}hasHighlight(){return!1}_produceDrawCalls(e){const{visibilities:t,ranges:r}=e,i=[];if(h(r)){if(0===r.numItems)return[];const e=r.numVertices;let n=null;for(let s=0;s<r.numItems;++s){t[s]?null==n?(n={start:s*e,count:e},i.push(n)):n.count+=e:n=null}}else{const e=r.counts,n=e.length;if(0===n)return[];let s=null,o=0;for(let r=0;r<n;++r){const n=t[r],a=e[r];n?null==s?(s={start:o,count:a},i.push(s)):s.count+=a:s=null,o+=a}}return i}};function h(e){return"numItems"in e}e([r({constructOnly:!0})],f.prototype,"material",void 0),f=e([i("esri.views.3d.layers.graphics.pipeline.rendering.DirectRenderer")],f);export{f as DirectRenderer};
5
+ import{__decorate as e}from"tslib";import{nullUid as t}from"../../../../../../core/uid.js";import{property as r,subclass as i}from"../../../../../../core/accessorSupport/decorators.js";import{glLayout as s}from"../../../../support/buffer/glUtil.js";import{SyncRenderPlugin as n}from"../../../../webgl-engine/effects/RenderPlugin.js";import{GLMaterials as o}from"../../../../webgl-engine/lib/GLMaterials.js";import{BoundingVolume as a}from"../../../../webgl-engine/lib/Object3D.js";import{VertexArrayObject as l}from"../../../../webgl-engine/lib/VertexArrayObject.js";import{DrawParameters as u}from"../../../../webgl-engine/materials/DrawParameters.js";import{HUDMaterial as c}from"../../../../webgl-engine/materials/HUDMaterial.js";import{bindVertexBufferLayout as m}from"../../../../../webgl/Util.js";import{VertexBuffer as d}from"../../../../../webgl/VertexBuffer.js";let f=class extends n{constructor(e){super(e),this._glMaterials=null,this._produces=new Map,this._renderGeometries=new Map,this._renderContext=null,this._drawParameters=new u,this._bufferWriter=null,this._baseInstance=null,this.slicePlaneEnabled=!1,this.isGround=!1,this.type=e.material instanceof c?1:4,this.layerViewUid=e.layerViewUid}get produces(){return this._produces}get numFeatures(){let e=0;return this._renderGeometries.forEach(t=>e+=t.numElements),e}get usedMemory(){let e=0;return this._renderGeometries.forEach(t=>{e+=t.vao.usedMemory}),e}intersect(e,r,i,s){const{material:n,_bufferWriter:o,layerViewUid:l,_renderGeometries:u}=this;null!=o.intersect&&u.forEach(({buffer:r,localOrigin:u,items:c})=>o.intersect(r.data,n.parameters,u,e,i,s,(r,i,s,o)=>{if(!c.visibilities[s])return;const u=c.objectIds[s];e.handleObjectIntersection({object:{id:t,graphicUid:u,layerViewUid:l,boundingVolumeWorldSpace:new a,geometries:[{material:n}]},geometryId:0,primitiveIndex:s},r,i,null,o)}))}initialize(){this._bufferWriter=this.material.createBufferWriter(),this.material.produces.forEach((e,t)=>{this._produces.set(t,t=>8!==t&&4!==t&&e(t))})}destroy(){this._glMaterials.dispose();const e=this._renderGeometries.keys();for(const t of e)this.removeRenderGeometryBuffer(t);this._baseInstance?.vbo.dispose(),this._baseInstance=null}acquireTechniques(e){const t=this.material;if(!t.shouldRender(e))return null;const{output:r,bind:i}=e,s=t.produces.get(i.slot);if(!s?.(r))return null;if(8===r||4===r)return null;const n=this._glMaterials.load(e.rctx,i.slot,r);return n?.beginSlot(i)}render(e,t){const r=this._renderGeometries;if(0===r.size)return;const{bind:i}=e,s=e.rctx;s.runAppleAmdDriverHelper(),s.bindTechnique(t,i,this.material.parameters);const n=t.program,{_baseInstance:o}=this,a=null==o?e=>{s.drawArrays(t.primitiveType,e.start,e.count)}:(e,r)=>{m(s,r.locations,r.buffer("instances"),e.start),s.drawArraysInstanced(t.primitiveType,0,o.buffer.elementCount,e.count)};for(const[l,u]of r){const{vao:e,localOrigin:r,drawCalls:o}=u;this._drawParameters.origin=r,n.bindDraw(i,this.material.parameters,this._drawParameters),t.ensureAttributeLocations(e),s.bindVAO(e),s.setPipelineState(t.getPipeline(i,!1));for(const t of o)a(t,e)}}initializeRenderContext(e){this._glMaterials=new o(this.material,e.materials),this._renderContext=e.renderContext}uninitializeRenderContext(){}addRenderGeometryBuffer(e,t,r,i){this.removeRenderGeometryBuffer(e);const{data:n,elementCount:o}=t,{_baseInstance:a,_bufferWriter:u,_renderContext:{rctx:c}}=this,m=u.layout,f=new d(c,s(m,null==a?0:1),n);let h;h=new l(c,null==a?new Map([["geometry",f]]):new Map([["geometry",a.vbo],["instances",f]]));const b={localOrigin:i,numElements:o,buffer:t,items:r,vao:h,drawCalls:this._produceDrawCalls(r)};this._renderGeometries.set(e,b)}updateRenderGeometryBuffer(e,t,r,i){const{data:s,elementCount:n}=t,o=this._renderGeometries.get(e);if(null==o)return;const a=o.vao.buffer(null==this._baseInstance?"geometry":"instances");a?.setSize(s.byteLength),a?.setSubData(new Uint8Array(s),0,0,s.byteLength),o.localOrigin=i,o.numElements=n,o.buffer=t,o.items=r,o.drawCalls=this._produceDrawCalls(r)}removeRenderGeometryBuffer(e){const t=this._renderGeometries.get(e);null!=t&&(this._baseInstance?(t.vao.buffer("instances")?.dispose(),t.vao.disposeVAOOnly()):t.vao.dispose(),this._renderGeometries.delete(e))}updateVisibility(e,t){const r=this._renderGeometries.get(e);if(null==r)return;const{items:i}=r;if(i.visibilities.length!==t.length)throw new Error("Unexpected mismatch between old and new visibility flag buffer length.");i.visibilities=t,r.drawCalls=this._produceDrawCalls(i)}setBaseInstance(e){this._baseInstance?.vbo.dispose();const t=this._bufferWriter.baseInstanceLayout;if(null==e||null==t)return void(this._baseInstance=null);const{data:r}=e,i=new d(this._renderContext.rctx,s(t),r);this._baseInstance={buffer:e,vbo:i}}hasHighlight(){return!1}_produceDrawCalls(e){const{visibilities:t,ranges:r}=e,i=[];if(h(r)){if(0===r.numItems)return[];const e=r.numVertices;let s=null;for(let n=0;n<r.numItems;++n){t[n]?null==s?(s={start:n*e,count:e},i.push(s)):s.count+=e:s=null}}else{const e=r.counts,s=e.length;if(0===s)return[];let n=null,o=0;for(let r=0;r<s;++r){const s=t[r],a=e[r];s?null==n?(n={start:o,count:a},i.push(n)):n.count+=a:n=null,o+=a}}return i}};function h(e){return"numItems"in e}e([r({constructOnly:!0})],f.prototype,"material",void 0),f=e([i("esri.views.3d.layers.graphics.pipeline.rendering.DirectRenderer")],f);export{f as DirectRenderer};