@arcgis/core 5.0.0-next.16 → 5.0.0-next.18

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 (262) hide show
  1. package/analysis/ElevationProfile/ElevationProfileLineInput.js +1 -1
  2. package/assets/esri/core/workers/RemoteClient.js +1 -1
  3. package/assets/esri/core/workers/chunks/{adf7ccf4ef629211c7ee.js → 08aacbfb651cc2e1c054.js} +1 -1
  4. package/assets/esri/core/workers/chunks/234b52b2a391631ceff6.js +1 -0
  5. package/assets/esri/core/workers/chunks/{658cd45b5fb304fd840a.js → 3aa77696c5ea54a238da.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{8f3503b2fb6cd38757b9.js → 458e87902abc24b375da.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{57b410198d83bf0ab708.js → 4a89e120be142ab58a27.js} +1 -1
  8. package/assets/esri/core/workers/chunks/{49571d6875de1f2e7e25.js → 4b9dfdc23ba3d6ebcc1b.js} +2 -2
  9. package/assets/esri/core/workers/chunks/{a410dcf80d17a2383337.js → 65a4099bdbe31834d0cc.js} +1 -1
  10. package/assets/esri/core/workers/chunks/722da7a39a0ad9300752.js +1 -0
  11. package/assets/esri/core/workers/chunks/{cdb4664fd59860ddeb5a.js → 72f1c3d97e7b9546c113.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{bc318b6fef192cee2a72.js → 76e945da8f30d8641c3d.js} +20 -20
  13. package/assets/esri/core/workers/chunks/{319c3f46f2afb8f3e5a9.js → 89c9cf7f799858d14c76.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{e19cd07df8ce87e18832.js → 8b33732e3c2924c1f60d.js} +1 -1
  15. package/assets/esri/core/workers/chunks/98739414c107ad78e4d8.js +1 -0
  16. package/assets/esri/core/workers/chunks/{8b73db0f4d6714396eb0.js → a6fa90eab77ac0e1cdfc.js} +1 -1
  17. package/assets/esri/core/workers/chunks/ac366221e8636b60aee5.js +1 -0
  18. package/assets/esri/core/workers/chunks/{23e17b745adf71a5efc7.js → aca72ca7f43f70eb8077.js} +1 -1
  19. package/assets/esri/core/workers/chunks/ad0c7225941437d18408.js +1 -0
  20. package/assets/esri/core/workers/chunks/b30897952494a3e5b9fe.js +1 -0
  21. package/assets/esri/core/workers/chunks/bfd3d81e8e148be99686.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/assets/esri/themes/base/widgets/_Editor.scss +2 -1
  25. package/assets/esri/themes/base/widgets/_FeatureForm.scss +1 -1
  26. package/assets/esri/themes/dark/main.css +1 -1
  27. package/assets/esri/themes/light/main.css +1 -1
  28. package/assets/esri/themes/light/view.css +1 -1
  29. package/chunks/GaussianSplat.glsl.js +2 -2
  30. package/chunks/ImageMaterial.glsl.js +1 -1
  31. package/chunks/lyr3DMain.js +1 -1
  32. package/config.js +1 -1
  33. package/graphic/graphicOriginUtils.js +1 -1
  34. package/interfaces.d.ts +113 -54
  35. package/intl/locale.js +1 -1
  36. package/kernel.js +1 -1
  37. package/layers/BingMapsLayer.js +1 -1
  38. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  39. package/layers/support/attributionUtils.js +5 -0
  40. package/layers/support/fieldConfigUtils.js +1 -1
  41. package/layers/support/fieldFormatUtils.js +1 -1
  42. package/layers/video/VideoController.js +1 -1
  43. package/libs/parquet/parquet.js +1 -1
  44. package/package.json +1 -1
  45. package/support/revision.js +1 -1
  46. package/symbols/cim/SDFHelper.js +1 -1
  47. package/symbols/cim/cimAnalyzer.js +1 -1
  48. package/views/2d/LabelManager.js +1 -1
  49. package/views/2d/analysis/ElevationProfile/ElevationProfileLineVisualization2D.js +1 -1
  50. package/views/2d/engine/flow/dataUtils.js +1 -1
  51. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  52. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  53. package/views/2d/engine/webgl/TextureManager.js +1 -1
  54. package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
  55. package/views/2d/engine/webgl/animations/store/AnimationStore.js +1 -1
  56. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AAnimatedPolyShader.js +1 -1
  57. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedFillShader.js +1 -1
  58. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedLineShader.js +1 -1
  59. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedPolyMeshWriters.js +1 -1
  60. package/views/2d/engine/webgl/shaderGraph/techniques/animated/AnimatedTechnique.js +1 -1
  61. package/views/2d/engine/webgl/shaderGraph/techniques/colorize/ColorizeTechnique.js +1 -1
  62. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
  63. package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
  64. package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
  65. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  66. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  67. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  68. package/views/2d/engine/webgl/textureUtils.js +1 -1
  69. package/views/2d/layers/features/FeatureContainer.js +1 -1
  70. package/views/2d/layers/features/Processor.js +1 -1
  71. package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
  72. package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
  73. package/views/2d/layers/features/processor/TrackStrategy.js +1 -1
  74. package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
  75. package/views/3d/GroundView3D.js +1 -1
  76. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  77. package/views/3d/analysis/ElevationProfile/ElevationProfileGeometryVisualization3D.js +1 -1
  78. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  79. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
  80. package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementTool.js +1 -1
  81. package/views/3d/analysis/images/Factory.js +1 -1
  82. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  83. package/views/3d/environment/ChapmanAtmosphereTechnique.js +1 -1
  84. package/views/3d/environment/CloudsCompositionTechnique.js +1 -1
  85. package/views/3d/environment/CloudsTechnique.js +1 -1
  86. package/views/3d/environment/EnvironmentManager.js +1 -1
  87. package/views/3d/environment/FogTechnique.js +1 -1
  88. package/views/3d/environment/NoiseTextureAtlasTechnique.js +1 -1
  89. package/views/3d/environment/PrecipitationTechnique.js +1 -1
  90. package/views/3d/environment/SimpleAtmosphereTechnique.js +1 -1
  91. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  92. package/views/3d/layers/DrapedSubView3D.js +1 -1
  93. package/views/3d/layers/FlowSubView3D.js +1 -1
  94. package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
  95. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  96. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  97. package/views/3d/layers/MediaLayerView3D.js +1 -1
  98. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  99. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  100. package/views/3d/layers/SceneLayerView3D.js +1 -1
  101. package/views/3d/layers/TiledLayerView3D.js +1 -1
  102. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  103. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  104. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  105. package/views/3d/layers/graphics/defaultSymbolComplexity.js +1 -1
  106. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  107. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  108. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  109. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  110. package/views/3d/support/QualityProfile.js +5 -0
  111. package/views/3d/support/QualitySettings.js +1 -1
  112. package/views/3d/support/StreamTextureCollection.js +1 -1
  113. package/views/3d/support/TextureCollection.js +1 -1
  114. package/views/3d/support/engineContent/marker.js +1 -1
  115. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  116. package/views/3d/support/flow/FlowSubViewTiles3D.js +1 -1
  117. package/views/3d/support/flow/FlowWorker.js +1 -1
  118. package/views/3d/support/flow/FlowWorkerHandle.js +1 -1
  119. package/views/3d/support/flow/StreamlineResources3D.js +1 -1
  120. package/views/3d/support/flow/StreamlineResources3DOverlay.js +1 -1
  121. package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
  122. package/views/3d/support/flow/constants.js +1 -1
  123. package/views/3d/support/flow/loadUtils.js +1 -1
  124. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  125. package/views/3d/support/popupHitTest.js +1 -1
  126. package/views/3d/terrain/BlendLayersTechnique.js +1 -1
  127. package/views/3d/terrain/OverlayRenderer.js +1 -1
  128. package/views/3d/terrain/RasterColorizerTechnique.js +1 -1
  129. package/views/3d/terrain/TerrainSurface.js +1 -1
  130. package/views/3d/terrain/TileAgent.js +1 -1
  131. package/views/3d/terrain/TileCompositor.js +1 -1
  132. package/views/3d/webgl-engine/Stage.js +1 -1
  133. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  134. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  135. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechnique.js +1 -1
  136. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  137. package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
  138. package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
  139. package/views/3d/webgl-engine/core/shaderTechnique/{ReloadableShaderModule.js → ReloadableShader.js} +1 -1
  140. package/views/3d/webgl-engine/core/shaderTechnique/ShaderTechnique.js +1 -1
  141. package/views/3d/webgl-engine/effects/focusArea/FocusAreaColorTechnique.js +1 -1
  142. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskTechnique.js +1 -1
  143. package/views/3d/webgl-engine/effects/glow/GlowBlurTechnique.js +1 -1
  144. package/views/3d/webgl-engine/effects/glow/GlowCompositionTechnique.js +1 -1
  145. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  146. package/views/3d/webgl-engine/effects/haze/HazeCompositingTechnique.js +1 -1
  147. package/views/3d/webgl-engine/effects/haze/HazeTechnique.js +1 -1
  148. package/views/3d/webgl-engine/effects/highlight/HighlightApplyTechnique.js +1 -1
  149. package/views/3d/webgl-engine/effects/highlight/HighlightBlurTechnique.js +1 -1
  150. package/views/3d/webgl-engine/effects/highlight/HighlightDownsampleTechnique.js +1 -1
  151. package/views/3d/webgl-engine/effects/highlight/HighlightToSingleTechnique.js +1 -1
  152. package/views/3d/webgl-engine/effects/highlight/ShadowHighlightTechnique.js +1 -1
  153. package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechnique.js +1 -1
  154. package/views/3d/webgl-engine/effects/laserlines/LaserlineTechnique.js +1 -1
  155. package/views/3d/webgl-engine/effects/magnifier/MagnifierTechnique.js +1 -1
  156. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  157. package/views/3d/webgl-engine/effects/smaa/SMAABlendWeightsTechnique.js +1 -1
  158. package/views/3d/webgl-engine/effects/smaa/SMAABlurTechnique.js +1 -1
  159. package/views/3d/webgl-engine/effects/smaa/SMAAEdgeDetectTechnique.js +1 -1
  160. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  161. package/views/3d/webgl-engine/effects/ssao/SSAOBlurTechnique.js +1 -1
  162. package/views/3d/webgl-engine/effects/ssao/SSAOTechnique.js +1 -1
  163. package/views/3d/webgl-engine/effects/stars/StarsTechnique.js +1 -1
  164. package/views/3d/webgl-engine/effects/transparency/OITBlendTechnique.js +1 -1
  165. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
  166. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  167. package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
  168. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  169. package/views/3d/webgl-engine/lib/GaussianSplatRenderNode.js +1 -1
  170. package/views/3d/webgl-engine/lib/ManagedTexture.js +5 -0
  171. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  172. package/views/3d/webgl-engine/lib/Program.js +1 -1
  173. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  174. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  175. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  176. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  177. package/views/3d/webgl-engine/lib/TextTextureFactory.js +1 -1
  178. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  179. package/views/3d/webgl-engine/lib/TextureTechnique.js +1 -1
  180. package/views/3d/webgl-engine/lib/edgeRendering/EdgeShaderTechnique.js +1 -1
  181. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  182. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  183. package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
  184. package/views/3d/webgl-engine/materials/WaterTechnique.js +1 -1
  185. package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
  186. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  187. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  188. package/views/3d/webgl-engine/shaders/AtmosphereCompositingTechnique.js +1 -1
  189. package/views/3d/webgl-engine/shaders/CheckerBoardTechnique.js +1 -1
  190. package/views/3d/webgl-engine/shaders/ColorMaterialTechnique.js +1 -1
  191. package/views/3d/webgl-engine/shaders/CompositingTechnique.js +1 -1
  192. package/views/3d/webgl-engine/shaders/CutFillCompositionTechnique.js +1 -1
  193. package/views/3d/webgl-engine/shaders/CutFillDepthTechnique.js +1 -1
  194. package/views/3d/webgl-engine/shaders/CutFillMaskTechnique.js +1 -1
  195. package/views/3d/webgl-engine/shaders/CutFillReductionTechnique.js +1 -1
  196. package/views/3d/webgl-engine/shaders/CutFillTargetDepthTechnique.js +1 -1
  197. package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
  198. package/views/3d/webgl-engine/shaders/GaussianSplat.glsl.js +1 -1
  199. package/views/3d/webgl-engine/shaders/GaussianSplatCompositionTechnique.js +1 -1
  200. package/views/3d/webgl-engine/shaders/GaussianSplatDepthCompositionTechnique.js +1 -1
  201. package/views/3d/webgl-engine/shaders/GaussianSplatDepthTechnique.js +1 -1
  202. package/views/3d/webgl-engine/shaders/GaussianSplatTechnique.js +1 -1
  203. package/views/3d/webgl-engine/shaders/GaussianSplatTechniqueConfiguration.js +1 -1
  204. package/views/3d/webgl-engine/shaders/HUDCompositingTechnique.js +1 -1
  205. package/views/3d/webgl-engine/shaders/HUDMaterialTechnique.js +1 -1
  206. package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +1 -1
  207. package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +1 -1
  208. package/views/3d/webgl-engine/shaders/ImageMaterialTechnique.js +1 -1
  209. package/views/3d/webgl-engine/shaders/LineCalloutTechnique.js +1 -1
  210. package/views/3d/webgl-engine/shaders/LineMarkerTechnique.js +1 -1
  211. package/views/3d/webgl-engine/shaders/MeasurementArrowTechnique.js +1 -1
  212. package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +1 -1
  213. package/views/3d/webgl-engine/shaders/OverlayCompositingTechnique.js +1 -1
  214. package/views/3d/webgl-engine/shaders/PatternTechnique.js +1 -1
  215. package/views/3d/webgl-engine/shaders/PointRendererTechnique.js +1 -1
  216. package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
  217. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  218. package/views/3d/webgl-engine/shaders/ShadedColorMaterialTechnique.js +1 -1
  219. package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
  220. package/views/3d/webgl-engine/shaders/ShadowCastClearTechnique.js +1 -1
  221. package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
  222. package/views/3d/webgl-engine/shaders/SlicePlaneMaterialTechnique.js +1 -1
  223. package/views/3d/webgl-engine/shaders/TerrainTechnique.js +1 -1
  224. package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
  225. package/views/GroundView.js +1 -1
  226. package/views/SceneView.js +1 -1
  227. package/views/analysis/ElevationProfile/ElevationProfileTool.js +1 -1
  228. package/views/analysis/ElevationProfile/types.d.ts +5 -0
  229. package/views/analysis/ElevationProfile/types.js +5 -0
  230. package/views/support/layerViewUtils.js +1 -1
  231. package/views/webgl/Texture.js +1 -1
  232. package/views/webgl/VertexAttributeLocations.js +1 -1
  233. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  234. package/widgets/Attribution/AttributionViewModel.js +1 -1
  235. package/widgets/Editor/MergeFeaturesWorkflow.js +1 -1
  236. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  237. package/widgets/Editor/UpdateWorkflow.js +1 -1
  238. package/widgets/Editor/Workflow.js +1 -1
  239. package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
  240. package/widgets/Editor/components/PendingFeatureList.js +1 -1
  241. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  242. package/widgets/Editor.js +1 -1
  243. package/widgets/Feature/support/featureUtils.js +1 -1
  244. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  245. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  246. package/widgets/FeatureTable/FieldColumn.js +1 -1
  247. package/widgets/FeatureTable/Grid/Column.js +1 -1
  248. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  249. package/widgets/OrientedImageryViewer/adapters/view/MapViewAdapter.js +1 -1
  250. package/widgets/OrientedImageryViewer/adapters/view/SceneViewAdapter.js +1 -1
  251. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  252. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  253. package/assets/esri/core/workers/chunks/38ee69125da60464d5a1.js +0 -1
  254. package/assets/esri/core/workers/chunks/4f0016111fd84c612f41.js +0 -1
  255. package/assets/esri/core/workers/chunks/8208dfa8f7fae7e616b9.js +0 -1
  256. package/assets/esri/core/workers/chunks/847f4fc39100fac1df01.js +0 -1
  257. package/assets/esri/core/workers/chunks/ab005fe84952f0676020.js +0 -1
  258. package/assets/esri/core/workers/chunks/bc19a232076d98825eef.js +0 -1
  259. package/assets/esri/core/workers/chunks/c3dcfe26c2c3c829762d.js +0 -1
  260. package/views/3d/support/DisplayQualityProfile.js +0 -5
  261. package/views/3d/webgl-engine/lib/Texture.js +0 -5
  262. /package/views/3d/webgl-engine/lib/{ITexture.js → IManagedTexture.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 e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as p,create as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w,forEachSymbolLayer as z}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as R}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as M}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as I}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as O}from"../../../../symbols/support/utils.js";import{transparentUnit as j}from"./constants.js";import{perObjectElevationAligner as F}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as U}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as D}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as L}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as A}from"./placementUtils.js";import{placePointOnGeometry as H,updateStageObjectGeometry as k,getLocalOriginForPoint as B,extendPointGraphicElevationContext as $,createStageObject as N}from"./pointUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as J,evaluateModelTransformScale as Z,ConvertOptions as W}from"../support/FastSymbolUpdates.js";import{createTexture as K,requiresHalfTexelOffset as Q,defaultBoundingBox as X,defaultSymbolSizeRatio as Y,defaultTexSize as ee}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as te}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as ie}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as se}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as oe}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as ae}from"../../webgl-engine/materials/HUDMaterial.js";const ne=_(0,0,1),le=16,ce=1.5,he=[ee*Y,ee*Y];class ue extends G{static{this.PRIMITIVE_SIZE=he}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ge(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=O(this.symbolLayer),i=de(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=L(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):le);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&R(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new I({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=_e("relative",s),a=new oe(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new oe(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:_e(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;me(t)&&(e.verticalOffset=new re(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this.view.screenSizePerspective.parameters),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!!has("enable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(pe(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>K(t));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=Q(t),e.distanceFieldBoundingBox=X;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/Y,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=fe(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return ye(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=pe(this._getPrimitive())?ce:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(pe(this._getPrimitive()))return j;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):le)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new ae(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new ae(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=U(e.color,r),e.outlineColor=U(e.outlineColor,r),this._materials[1]=new ae(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=H(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;let a=!1;if(this._cimData){if(!this._cimData.symbol)return null;z(this._cimData.symbol,e=>{e.colorLocked&&(a=!0)});const r=this._generateTextureCIM(t,e),n={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(n);const l=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/l,r.parameters.height/l]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const n=e.renderingInfo,l=a?x(255,255,255,255):this._getDrivenUInt8Color(n,this._materialColor,null==this._getPrimitive()),c=this._getDrivenRotation(n);let h=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];h=this._getScaleFactor(n,e)}h*=this._symbolTextureRatio;const u=p(s[0]*h,s[1]*h),m=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,l,c,u):this._createAs3DShape(t,r,i,l,c,u,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const o=H(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const a=k(s,this._context,o,i);if(null==a)return!1;const n=B(this._context,o);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=a,$(t,o,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(ue.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!J(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=de(h))return;const m=this._getIconSize(),p=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,p,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=fe(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return xe}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=ie(r,{normal:ne,color:i,rotation:s,size:o,centerOffsetAndDistance:be,featureAttribute:l,olidColor:h}),m=N(this._context,t,u,a,n);if(null==m)return null;const p=new V(this,m.object,null,F,a);return p.alignedSampledElevation=m.sampledElevation,p.needsElevationUpdates=E(a.mode)||"absolute-height"===a.mode,p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),$(p,t,this._context.elevationProvider),p}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=te;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=ie(r,{normal:ne,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),p=new se(m,{layerViewUid:h,graphicUid:c}),d=new D(this,[p],null,this._context.drapeSourceRenderer);return d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),d}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=d())=>{const[o,a]=Z(ve,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=d())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new W({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function pe(e){return null!=e&&("cross"===e||"x"===e)}function de(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function _e(e,t){return"relative"===e?p((t.x||0)+.5,.5-(t.y||0)):e in A?A[e]:A.center}function fe({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function ye(e){return e.resource?.href?null:e.resource?.primitive??M}function ge(e){return 1===(e.material?.color?.a??0)&&null!=ye(e)}const xe={mode:"relative-to-ground",offset:0},be=x(0,0,0,1),ve=f();export{ue as Graphics3DIconSymbolLayer};
5
+ import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w,forEachSymbolLayer as z}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as R}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as M}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as I}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as O}from"../../../../symbols/support/utils.js";import{transparentUnit as j}from"./constants.js";import{perObjectElevationAligner as T}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as F,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as U}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as D}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as L}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as A}from"./placementUtils.js";import{placePointOnGeometry as H,updateStageObjectGeometry as k,getLocalOriginForPoint as B,extendPointGraphicElevationContext as $,createStageObject as N}from"./pointUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as J,evaluateModelTransformScale as Z,ConvertOptions as W}from"../support/FastSymbolUpdates.js";import{createTexture as K,requiresHalfTexelOffset as Q,defaultBoundingBox as X,defaultSymbolSizeRatio as Y,defaultTexSize as ee}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as te}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as ie}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as se}from"../../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as oe}from"../../webgl-engine/lib/RenderGeometry.js";import{HUDMaterial as ae}from"../../webgl-engine/materials/HUDMaterial.js";const ne=_(0,0,1),le=16,ce=1.5,he=[ee*Y,ee*Y];class ue extends G{static{this.PRIMITIVE_SIZE=he}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ge(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=O(this.symbolLayer),i=pe(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=L(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):le);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&R(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new I({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=_e("relative",s),a=new se(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new se(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:_e(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;me(t)&&(e.verticalOffset=new re(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this.view.screenSizePerspective.parameters),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!!has("enable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(de(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>K(t));this._textureHandle=r,e.textureId=r.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=Q(t),e.distanceFieldBoundingBox=X;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/Y,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.managedTexture;this._size=fe(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return ye(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=de(this._getPrimitive())?ce:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(de(this._getPrimitive()))return j;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):le)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new ae(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new ae(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=U(e.color,r),e.outlineColor=U(e.outlineColor,r),this._materials[1]=new ae(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=H(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;let a=!1;if(this._cimData){if(!this._cimData.symbol)return null;z(this._cimData.symbol,e=>{e.colorLocked&&(a=!0)});const r=this._generateTextureCIM(t,e),n={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(n);const l=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/l,r.parameters.height/l]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const n=e.renderingInfo,l=a?x(255,255,255,255):this._getDrivenUInt8Color(n,this._materialColor,null==this._getPrimitive()),c=this._getDrivenRotation(n);let h=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];h=this._getScaleFactor(n,e)}h*=this._symbolTextureRatio;const u=d(s[0]*h,s[1]*h),m=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,l,c,u):this._createAs3DShape(t,r,i,l,c,u,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const o=H(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const a=k(s,this._context,o,i);if(null==a)return!1;const n=B(this._context,o);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=a,$(t,o,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=F(ue.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!J(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=pe(h))return;const m=this._getIconSize(),d=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.managedTexture;this._size=fe(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return xe}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=ie(r,{normal:ne,color:i,rotation:s,size:o,centerOffsetAndDistance:be,featureAttribute:l,olidColor:h}),m=N(this._context,t,u,a,n);if(null==m)return null;const d=new V(this,m.object,null,T,a);return d.alignedSampledElevation=m.sampledElevation,d.needsElevationUpdates=E(a.mode)||"absolute-height"===a.mode,d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),$(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=te;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=ie(r,{normal:ne,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),d=new oe(m,{layerViewUid:h,graphicUid:c}),p=new D(this,[d],null,this._context.drapeSourceRenderer);return p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),p}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=Z(ve,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new W({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function de(e){return null!=e&&("cross"===e||"x"===e)}function pe(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function _e(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in A?A[e]:A.center}function fe({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function ye(e){return e.resource?.href?null:e.resource?.primitive??M}function ge(e){return 1===(e.material?.color?.a??0)&&null!=ye(e)}const xe={mode:"relative-to-ground",offset:0},be=x(0,0,0,1),ve=f();export{ue as Graphics3DIconSymbolLayer};
@@ -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{j as g,g as x,h as _,t as y,o as T,n as b,c as v,e as w,i as C,f as j}from"../../../../chunks/vec32.js";import{create as M,fromValues as A,ONES as R,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 O,create as F,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 J,transformVectorENUPlateCarree as K,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{Object3D as be}from"../../webgl-engine/lib/Object3D.js";import{Texture as ve}from"../../webgl-engine/lib/Texture.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 Ae}from"../../webgl-engine/materials/pbrUtils.js";const Re=["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,Re,"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(Ke,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,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=ke(n),h=ze(a),d=ke(i),g=ke(c),x=ze(u),_=ke(m),y=ze(f);o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${y}`,o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a)}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 ve(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(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=A(t(n[0]),t(n[1]),t(n[2]))}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.emissiveStrength=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:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Ae:[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),Fe(r,o,t,Ke,Qe,Xe),x(Ke,Ke,Qe),x(Ke,Ke,Xe),_(Ke,Ke,1/3),y(Ke,Ke,c),s.push(...Ke),T(Ze,Ze,u),b(Ze,Ze),v(Ke,Ke,Ze,n),s.push(...Ke),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(Ke,s[e+0],s[e+1],s[e+2]),y(Ke,Ke,p),m.push(...Ke),g(Qe,l[r+0],l[r+1],l[r+2]),T(Qe,Qe,h),b(Qe,Qe),v(Ke,Ke,Qe,u),m.push(...Ke),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 be({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=J(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 K(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 K(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;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,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&&J(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&&(O(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(Ke,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 Oe(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];Ke[0]=t[r],Ke[1]=t[r+1],Ke[2]=t[r+2],j(Ze,Ke)<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 Oe(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 Fe(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 Fe(e,t,r,Ke,Qe,Xe),w(Qe,Qe,Ke),w(Xe,Xe,Ke),C(Ke,Qe,Xe),b(o,Ke),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,Je=M(),Ke=M(),Qe=M(),Xe=M(),Ze=M(),et=f(),tt=f(),rt=F(),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{j as g,g as x,h as _,t as y,o as T,n as b,c as v,e as w,i as C,f as j}from"../../../../chunks/vec32.js";import{create as M,fromValues as A,ONES as R,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 O,create as F,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 J,transformVectorENUPlateCarree as K,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 Ae}from"../../webgl-engine/materials/pbrUtils.js";const Re=["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,Re,"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(Ke,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,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=ke(n),h=ze(a),d=ke(i),g=ke(c),x=ze(u),_=ke(m),y=ze(f);o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${y}`,o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a)}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=A(t(n[0]),t(n[1]),t(n[2]))}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.emissiveStrength=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:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Ae:[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),Fe(r,o,t,Ke,Qe,Xe),x(Ke,Ke,Qe),x(Ke,Ke,Xe),_(Ke,Ke,1/3),y(Ke,Ke,c),s.push(...Ke),T(Ze,Ze,u),b(Ze,Ze),v(Ke,Ke,Ze,n),s.push(...Ke),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(Ke,s[e+0],s[e+1],s[e+2]),y(Ke,Ke,p),m.push(...Ke),g(Qe,l[r+0],l[r+1],l[r+2]),T(Qe,Qe,h),b(Qe,Qe),v(Ke,Ke,Qe,u),m.push(...Ke),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=J(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 K(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 K(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;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,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&&J(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&&(O(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(Ke,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 Oe(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];Ke[0]=t[r],Ke[1]=t[r+1],Ke[2]=t[r+2],j(Ze,Ke)<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 Oe(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 Fe(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 Fe(e,t,r,Ke,Qe,Xe),w(Qe,Qe,Ke),w(Xe,Xe,Ke),C(Ke,Qe,Xe),b(o,Ke),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,Je=M(),Ke=M(),Qe=M(),Xe=M(),Ze=M(),et=f(),tt=f(),rt=F(),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 e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as r}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{fromValues as n,ZEROS as i,create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{freeze as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasCalloutSupport as c,textSymbolLayerSupportsVerticalOffset as m}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as p}from"./focusAreaStyle.js";import{Graphics3DObject3DGraphicLayer as u}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as d}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as g}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as y}from"./graphicUtils.js";import{LabelPlacement as v,LabelParameters as x}from"./LabelParameters.js";import{verticalScreenOffsetFromAlignment as b,verticalPlacementFromAlignment as O,textRenderAlignmentFromHorizontalPlacement as P,horizontalPlacementToAnchorX as w,anchorFromPlacements as j,namedAnchorToHUDMaterialAnchorPos as S}from"./placementUtils.js";import{placePointOnGeometry as _,updateStageObjectGeometry as E,getLocalOriginForPoint as z,extendPointGraphicElevationContext as C,createStageObject as F}from"./pointUtils.js";import{getFontMetrics as G}from"../../webgl-engine/lib/FontMetrics.js";import{createPointGeometry as L}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as A}from"../../webgl-engine/lib/TextRenderParameters.js";import U from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as D}from"../../webgl-engine/materials/HUDMaterial.js";const R=a(0,0,1);class T extends g{constructor(e,t,r,s){super(e,t,r,s),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=y(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await A.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,r=_(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const s=this.view.focusAreasView?.containsGeometry(r)??!0,n=this.symbolLayer.text;if(null==n||""===n)return null;const i=c(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=i&&!m(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const{verticalAlignment:o}=this.symbolLayer,a=new v(i);b(o,a.screenOffset);const l=new x(a,this.symbolLayer.horizontalAlignment,O(o));return l.isFocused=s??l.isFocused,this._createAs3DShape(t,r,n,l)}get needsUpdateFocus(){return!0}createLabel(e,t,r,s,n){const i=e.graphic,o=_(i.geometry);if(null==o)return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const a=this.view.focusAreasView?.containsGeometry(o)??!0,l=t.text;return!l||/^\s+$/.test(l)?null:(t.isFocused=a??t.isFocused,this._createAs3DShape(i,o,l,t,r,s,n))}createElevationContextForGraphic(e,t=0){const r=super.createElevationContextForGraphic(e);return r.addOffsetRenderUnits(t),r}updateElevationContextForGraphic(e,t,r=0){super.updateElevationContextForGraphic(e,t),e.addOffsetRenderUnits(r)}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerScreenSizePerspectiveChanged(e,t){const r=!this.draped&&this._context.screenSizePerspectiveEnabled,s=r?this.view.screenSizePerspective.labelParameters:null,n=r?this.view.screenSizePerspective.parameters:null;V(e,t,e=>{for(const t of e.stageObject.geometries)t.material.setParameters({screenSizePerspective:s,screenSizePerspectiveAlignment:n})})}layerElevationInfoChanged(e,t){return V(e,t,(e,t)=>{this.graphics3DGraphicLayerElevationInfoChanged(t,e)}),1}slicePlaneEnabledChanged(e,t){return V(e,t,e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}graphics3DGraphicLayerElevationInfoChanged(e,t){const{elevationContext:r,metadata:s}=t;this.updateElevationContextForGraphic(r,e,s?.elevationOffset??0),t.needsElevationUpdates=h(r.mode)||"absolute-height"===r.mode}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:s,stageObject:n}=t;if(s.mode!==this.getGeometryElevationMode(r))return!1;const i=_(r);if(!i)return!1;s.updateFeatureExpressionFeature(e,this._context.layer);const o=E(n,this._context,i,s);if(null==o)return!1;const a=z(this._context,i);return n.geometries[0].localOrigin===a&&(t.alignedSampledElevation=o,C(t,i,this._context.elevationProvider),!0)}_defaultElevationInfoNoZ(){return I}_createAs3DShape(e,a,c,m,g,y=null,v=()=>m.placement.elevationOffset){const x=this.createElevationContextForGraphic(e,m.placement.elevationOffset),b=e.uid;let O=null,w=null;if(null==y){const e=P(m.horizontalPlacement);O=new U(c,e,this._textRenderParameters);let s=null;if(null!=this._context.sharedResources.textures){w=this._context.sharedResources.textures.fromData(O.key,()=>O.create()),w.texture.events.on("unloaded",()=>s=t(s));const e=this._context.stage.renderView.textures.acquire(w.texture.id);if(null==e||r(e))return w.release(),null;s=e}}const j=!!has("enable-feature:non-occluded-hud"),S=H(O,m),_={occlusionTest:!j,occludedFragmentFade:j,horizonCullingEnabled:j&&this._context.spherical,screenOffset:m.placement.screenOffset,anchorPosition:S,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:m.placement.centerOffsetUnits,depthEnabled:!1,drawAsLabel:!0,isLabel:!0,isFocused:m.isFocused};if("polyline"===e.geometry?.type&&(_.shaderPolygonOffset=1e-4),y?_.textureId=y.id:w&&(_.textureId=w.texture.id),null!=m.placement.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=m.placement.verticalOffset;_.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0}}const E=this._context.graphicsCoreOwner.view.focusAreasView?.polygons.length,z={screenOffset:_.screenOffset,anchorPosition:S,centerOffsetUnits:_.centerOffsetUnits,verticalOffset:_.verticalOffset,shaderPolygonOffset:_.shaderPolygonOffset,occlusionTest:_.occlusionTest,isFocused:m.isFocused,focusStyle:this.view.map?.focusAreas.style??"none"};if(this._context.screenSizePerspectiveEnabled){const{parameters:e,labelParameters:t}=this.view.screenSizePerspective,r=G(this._textRenderParameters);_.screenSizePerspective=t,_.screenSizePerspectiveMinPixelReferenceSize=r.maxHeight,_.screenSizePerspectiveAlignment=e,z.fontHeight=r.maxHeight}_.hasSlicePlane=this._context.slicePlaneEnabled;const A=this._context.spherical,T=g?JSON.stringify(z):"";let V=g?.get(T);if(null==V){if(!m.isFocused&&E){const e=this.view.map?.focusAreas.style;_.color=p(_.color,e),_.outlineColor=p(_.outlineColor,e)}V=new D(_,A),g?.set(T,V)}const I=m.placement.translation,W=O?n(O.displayWidth,O.displayHeight):i,M=m.placement.centerOffset,$=R,k=y?l(0,0,0,0):null,N=L(V,{normal:$,position:I,size:W,centerOffsetAndDistance:M,uvi:k}),q=F(this._context,a,N,x,b);if(null==q)return null;const B=(t,r,s,n,i,o)=>{const a=v()||m.placement.elevationOffset;return this.updateElevationContextForGraphic(r,e,a),f(t,r,s,n,i,o)},J=new u(this,q.object,w,B,x);J.alignedSampledElevation=q.sampledElevation,J.needsElevationUpdates=h(x.mode)||"absolute-height"===x.mode,J.getScreenSize=(e=o())=>(e[0]=O?O.displayWidth:m.displaySize[0],e[1]=O?O.displayHeight:m.displaySize[1],e);const Y=new d(m.placement.elevationOffset,c);return J.metadata=Y,C(J,a,this._context.elevationProvider),J}}function V(e,t,r){e?.forEach(e=>{const s=t(e);null!=s&&r(s,e.graphic)})}function H(e,t){if("baseline"===t.verticalPlacement){const r=w[t.horizontalPlacement],s=null!=e?e.baselineAnchorY:0;return n(r,s)}const r=j(t.horizontalPlacement,t.verticalPlacement);return S[r]}const I={mode:"relative-to-ground",offset:0};export{T as Graphics3DTextSymbolLayer};
5
+ import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{releaseMaybe as t}from"../../../../core/maybe.js";import{isPromiseLike as r}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{fromValues as n,ZEROS as i,create as o}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{freeze as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as l}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{hasCalloutSupport as c,textSymbolLayerSupportsVerticalOffset as m}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as f}from"./ElevationAligners.js";import{needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as p}from"./focusAreaStyle.js";import{Graphics3DObject3DGraphicLayer as u}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as d}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as g}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as y}from"./graphicUtils.js";import{LabelPlacement as v,LabelParameters as x}from"./LabelParameters.js";import{verticalScreenOffsetFromAlignment as b,verticalPlacementFromAlignment as O,textRenderAlignmentFromHorizontalPlacement as P,horizontalPlacementToAnchorX as w,anchorFromPlacements as j,namedAnchorToHUDMaterialAnchorPos as S}from"./placementUtils.js";import{placePointOnGeometry as _,updateStageObjectGeometry as E,getLocalOriginForPoint as z,extendPointGraphicElevationContext as C,createStageObject as F}from"./pointUtils.js";import{getFontMetrics as G}from"../../webgl-engine/lib/FontMetrics.js";import{createPointGeometry as L}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as A}from"../../webgl-engine/lib/TextRenderParameters.js";import U from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as D}from"../../webgl-engine/materials/HUDMaterial.js";const R=a(0,0,1);class T extends g{constructor(e,t,r,s){super(e,t,r,s),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=y(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await A.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,r=_(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const s=this.view.focusAreasView?.containsGeometry(r)??!0,n=this.symbolLayer.text;if(null==n||""===n)return null;const i=c(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=i&&!m(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const{verticalAlignment:o}=this.symbolLayer,a=new v(i);b(o,a.screenOffset);const l=new x(a,this.symbolLayer.horizontalAlignment,O(o));return l.isFocused=s??l.isFocused,this._createAs3DShape(t,r,n,l)}get needsUpdateFocus(){return!0}createLabel(e,t,r,s,n){const i=e.graphic,o=_(i.geometry);if(null==o)return this.logger.warn(`unsupported geometry type for label: ${i.geometry.type}`),null;const a=this.view.focusAreasView?.containsGeometry(o)??!0,l=t.text;return!l||/^\s+$/.test(l)?null:(t.isFocused=a??t.isFocused,this._createAs3DShape(i,o,l,t,r,s,n))}createElevationContextForGraphic(e,t=0){const r=super.createElevationContextForGraphic(e);return r.addOffsetRenderUnits(t),r}updateElevationContextForGraphic(e,t,r=0){super.updateElevationContextForGraphic(e,t),e.addOffsetRenderUnits(r)}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerScreenSizePerspectiveChanged(e,t){const r=!this.draped&&this._context.screenSizePerspectiveEnabled,s=r?this.view.screenSizePerspective.labelParameters:null,n=r?this.view.screenSizePerspective.parameters:null;V(e,t,e=>{for(const t of e.stageObject.geometries)t.material.setParameters({screenSizePerspective:s,screenSizePerspectiveAlignment:n})})}layerElevationInfoChanged(e,t){return V(e,t,(e,t)=>{this.graphics3DGraphicLayerElevationInfoChanged(t,e)}),1}slicePlaneEnabledChanged(e,t){return V(e,t,e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}graphics3DGraphicLayerElevationInfoChanged(e,t){const{elevationContext:r,metadata:s}=t;this.updateElevationContextForGraphic(r,e,s?.elevationOffset??0),t.needsElevationUpdates=h(r.mode)||"absolute-height"===r.mode}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:s,stageObject:n}=t;if(s.mode!==this.getGeometryElevationMode(r))return!1;const i=_(r);if(!i)return!1;s.updateFeatureExpressionFeature(e,this._context.layer);const o=E(n,this._context,i,s);if(null==o)return!1;const a=z(this._context,i);return n.geometries[0].localOrigin===a&&(t.alignedSampledElevation=o,C(t,i,this._context.elevationProvider),!0)}_defaultElevationInfoNoZ(){return I}_createAs3DShape(e,a,c,m,g,y=null,v=()=>m.placement.elevationOffset){const x=this.createElevationContextForGraphic(e,m.placement.elevationOffset),b=e.uid;let O=null,w=null;if(null==y){const e=P(m.horizontalPlacement);O=new U(c,e,this._textRenderParameters);let s=null;if(null!=this._context.sharedResources.textures){w=this._context.sharedResources.textures.fromData(O.key,()=>O.create()),w.managedTexture.events.on("unloaded",()=>s=t(s));const e=this._context.stage.renderView.textures.acquire(w.managedTexture.id);if(null==e||r(e))return w.release(),null;s=e}}const j=!!has("enable-feature:non-occluded-hud"),S=H(O,m),_={occlusionTest:!j,occludedFragmentFade:j,horizonCullingEnabled:j&&this._context.spherical,screenOffset:m.placement.screenOffset,anchorPosition:S,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:m.placement.centerOffsetUnits,depthEnabled:!1,drawAsLabel:!0,isLabel:!0,isFocused:m.isFocused};if("polyline"===e.geometry?.type&&(_.shaderPolygonOffset=1e-4),y?_.textureId=y.id:w&&(_.textureId=w.managedTexture.id),null!=m.placement.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=m.placement.verticalOffset;_.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0}}const E=this._context.graphicsCoreOwner.view.focusAreasView?.polygons.length,z={screenOffset:_.screenOffset,anchorPosition:S,centerOffsetUnits:_.centerOffsetUnits,verticalOffset:_.verticalOffset,shaderPolygonOffset:_.shaderPolygonOffset,occlusionTest:_.occlusionTest,isFocused:m.isFocused,focusStyle:this.view.map?.focusAreas.style??"none"};if(this._context.screenSizePerspectiveEnabled){const{parameters:e,labelParameters:t}=this.view.screenSizePerspective,r=G(this._textRenderParameters);_.screenSizePerspective=t,_.screenSizePerspectiveMinPixelReferenceSize=r.maxHeight,_.screenSizePerspectiveAlignment=e,z.fontHeight=r.maxHeight}_.hasSlicePlane=this._context.slicePlaneEnabled;const A=this._context.spherical,T=g?JSON.stringify(z):"";let V=g?.get(T);if(null==V){if(!m.isFocused&&E){const e=this.view.map?.focusAreas.style;_.color=p(_.color,e),_.outlineColor=p(_.outlineColor,e)}V=new D(_,A),g?.set(T,V)}const I=m.placement.translation,W=O?n(O.displayWidth,O.displayHeight):i,M=m.placement.centerOffset,$=R,k=y?l(0,0,0,0):null,N=L(V,{normal:$,position:I,size:W,centerOffsetAndDistance:M,uvi:k}),q=F(this._context,a,N,x,b);if(null==q)return null;const B=(t,r,s,n,i,o)=>{const a=v()||m.placement.elevationOffset;return this.updateElevationContextForGraphic(r,e,a),f(t,r,s,n,i,o)},J=new u(this,q.object,w,B,x);J.alignedSampledElevation=q.sampledElevation,J.needsElevationUpdates=h(x.mode)||"absolute-height"===x.mode,J.getScreenSize=(e=o())=>(e[0]=O?O.displayWidth:m.displaySize[0],e[1]=O?O.displayHeight:m.displaySize[1],e);const Y=new d(m.placement.elevationOffset,c);return J.metadata=Y,C(J,a,this._context.elevationProvider),J}}function V(e,t,r){e?.forEach(e=>{const s=t(e);null!=s&&r(s,e.graphic)})}function H(e,t){if("baseline"===t.verticalPlacement){const r=w[t.horizontalPlacement],s=null!=e?e.baselineAnchorY:0;return n(r,s)}const r=j(t.horizontalPlacement,t.verticalPlacement);return S[r]}const I={mode:"relative-to-ground",offset:0};export{T as Graphics3DTextSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{neverReached as e}from"../../../../core/compilerUtils.js";import has from"../../../../core/has.js";import{defaultPrimitive as r}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{pathNumCircleProfileSubdivisions as t,pathNumRoundJoinSubdivisions as a,pathNumRoundCapExtrusionSubdivisions as s}from"./Graphics3DPathSymbolLayerConstants.js";import{primitiveLodResources as u}from"./primitiveObjectSymbolUtils.js";import{EstimatedSymbolComplexity as o,SymbolComplexityMemory as b,EstimatedAggregateSymbolComplexity as y,AggregateSymbolComplexity as i,SymbolComplexity as c}from"./SymbolComplexity.js";import{hasEdges as n}from"../support/edgeUtils.js";import{DefaultMaterial as l}from"../../webgl-engine/materials/DefaultMaterial.js";const P=new o({});function m(e){if("web-style"===e.type)return P;return F(e.symbolLayers.toArray().map(r=>L(e,r)))}function F(e){let r=0,t=0,a=0,s=!1,u=0;const o=new b;for(const b of e)null!=b&&(r+=b.verticesPerFeature,t+=b.verticesPerCoordinate,a+=b.drawCallsPerFeature,o.bytesPerFeature+=b.memory.bytesPerFeature,o.bytesPerFeatureLabel+=b.memory.bytesPerFeatureLabel,o.resourceBytes+=b.memory.resourceBytes,o.draped.bytesPerFeature+=b.memory.bytesPerFeature,o.draped.bytesPerFeatureLabel+=b.memory.bytesPerFeatureLabel,s=s||b.estimated,++u);return s?new y(u,{verticesPerFeature:r,verticesPerCoordinate:t,drawCallsPerFeature:a,memory:o}):new i(u,{verticesPerFeature:r,verticesPerCoordinate:t,drawCallsPerFeature:a,memory:o})}function d(e){const r=F(e);return r.numComplexities>0&&(r.verticesPerFeature/=r.numComplexities,r.verticesPerCoordinate/=r.numComplexities,r.drawCallsPerFeature/=r.numComplexities,r.memory.bytesPerFeature/=r.numComplexities,r.memory.bytesPerFeatureLabel/=r.numComplexities,r.memory.resourceBytes/=r.numComplexities,r.memory.draped.bytesPerFeature/=r.numComplexities,r.memory.draped.bytesPerFeatureLabel/=r.numComplexities),r}const p={};function L(u,b){const y=C(u,b),i=n(b)?2:0;switch(b.type){case"extrude":return new c({verticesPerFeature:-12,verticesPerCoordinate:12,drawCallsPerFeature:i,memory:y});case"fill":if("mesh-3d"===u.type)return new c({drawCallsPerFeature:i,memory:y});if(null!=b.outline&&b.outline.size>0)return new c({verticesPerFeature:-12,verticesPerCoordinate:9,memory:y});case"water":return new c({verticesPerFeature:-6,verticesPerCoordinate:3,memory:y});case"line":return new c({verticesPerFeature:-6,verticesPerCoordinate:6,memory:y});case"object":return b.resource?.href?new o({verticesPerFeature:100,memory:y}):{...f(b.resource?.primitive??r),memory:y};case"path":{let r=0,u=0;switch(b.profile){case"circle":r=t;break;case"quad":r=4;break;default:return void e(b.profile)}switch(b.join){case"round":u=a;break;case"miter":case"bevel":u=1;break;default:return}const o=2*r,i=r*u*2,n=i+o;let l=-2*i-o;switch(b.cap){case"none":break;case"butt":case"square":l+=2*(r-1);break;case"round":l+=2*(r*(s-1)*2+r);break;default:return}return new c({verticesPerFeature:l,verticesPerCoordinate:n,memory:y})}case"text":{const e="label-3d"===u.type?0:2;return new c({verticesPerFeature:6,memory:y,drawCallsPerFeature:e})}case"icon":return new c({verticesPerFeature:6,memory:y});default:return}}function C(r,t){const a="point-3d"===r.type;switch(t.type){case"extrude":return t.edges&&t.edges.size>0?E.EXTRUDE_EDGES:E.EXTRUDE;case"fill":return null!=t.outline&&t.outline.size>0?E.FILL_OUTLINE:E.FILL;case"water":return E.FILL;case"line":return"round"===t.join?E.LINE_ROUND:E.LINE_MITER;case"path":switch(t.join){case"round":switch(t.profile){case"circle":return E.PATH_ROUND_CIRCLE;case"quad":return E.PATH_ROUND_QUAD;default:return void e(t.profile)}case"miter":case"bevel":switch(t.profile){case"circle":return E.PATH_MITER_CIRCLE;case"quad":return E.PATH_MITER_QUAD;default:return void e(t.profile)}default:return}case"object":return a?E.OBJECT_POINT:E.OBJECT_POLYGON;case"icon":case"text":return a?E.ICON_POINT:E.ICON_POLYGON;default:return}}function f(e){const r=p[e];if(r)return r;const t=w(u(e,new l({},{spherical:!0})).levels);return p[e]=new c({verticesPerFeature:t}),p[e]}function w(e){return e.reduce((e,r,t)=>e+r.numVertices*(1/10**t),0)/e.reduce((e,r,t)=>e+1/10**t,0)}const E={ICON_POINT:{bytesPerFeature:2658,bytesPerFeatureLabel:3484,resourceBytes:0,draped:{bytesPerFeature:1845,bytesPerFeatureLabel:3498}},ICON_POLYGON:{bytesPerFeature:3086,bytesPerFeatureLabel:2996,resourceBytes:0,draped:{bytesPerFeature:2694,bytesPerFeatureLabel:3014}},OBJECT_POINT:{bytesPerFeature:497,bytesPerFeatureLabel:2933,resourceBytes:0,draped:{bytesPerFeature:497,bytesPerFeatureLabel:2933}},OBJECT_POLYGON:{bytesPerFeature:867,bytesPerFeatureLabel:2491,resourceBytes:0,draped:{bytesPerFeature:867,bytesPerFeatureLabel:2491}},LINE_MITER:{bytesPerFeature:2337,bytesPerFeatureLabel:2658,resourceBytes:0,draped:{bytesPerFeature:1864,bytesPerFeatureLabel:2656}},LINE_ROUND:{bytesPerFeature:2341,bytesPerFeatureLabel:2672,resourceBytes:0,draped:{bytesPerFeature:1873,bytesPerFeatureLabel:2643}},PATH_MITER_CIRCLE:{bytesPerFeature:22374,bytesPerFeatureLabel:2558,resourceBytes:0,draped:{bytesPerFeature:22374,bytesPerFeatureLabel:2558}},PATH_ROUND_CIRCLE:{bytesPerFeature:24004,bytesPerFeatureLabel:2598,resourceBytes:0,draped:{bytesPerFeature:24004,bytesPerFeatureLabel:2598}},PATH_MITER_QUAD:{bytesPerFeature:24040,bytesPerFeatureLabel:2940,resourceBytes:0,draped:{bytesPerFeature:24040,bytesPerFeatureLabel:2940}},PATH_ROUND_QUAD:{bytesPerFeature:23088,bytesPerFeatureLabel:2886,resourceBytes:0,draped:{bytesPerFeature:23088,bytesPerFeatureLabel:2886}},FILL:{bytesPerFeature:3059,bytesPerFeatureLabel:2838,resourceBytes:0,draped:{bytesPerFeature:2352,bytesPerFeatureLabel:2808}},FILL_OUTLINE:{bytesPerFeature:3093,bytesPerFeatureLabel:2632,resourceBytes:0,draped:{bytesPerFeature:2480,bytesPerFeatureLabel:2601}},EXTRUDE:{bytesPerFeature:5075,bytesPerFeatureLabel:2559,resourceBytes:0,draped:{bytesPerFeature:5075,bytesPerFeatureLabel:2559}},EXTRUDE_EDGES:{bytesPerFeature:2843,bytesPerFeatureLabel:2139,resourceBytes:0,draped:{bytesPerFeature:2843,bytesPerFeatureLabel:2139}}};if(has("esri-tests-disable-symbol-memory-estimators"))for(const _ in E){const e=E[_];e.bytesPerFeature=0,e.bytesPerFeatureLabel=0,e.draped.bytesPerFeature=0,e.draped.bytesPerFeatureLabel=0}export{d as averageSymbolComplexities,m as defaultSymbolComplexity,L as defaultSymbolLayerComplexity,C as defaultSymbolLayerMemoryComplexity,P as emptySymbolComplexity,w as estimateNumVerticesForLods,F as totalSymbolComplexities};
5
+ import{neverReached as e}from"../../../../core/compilerUtils.js";import has from"../../../../core/has.js";import{defaultPrimitive as r}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{pathNumCircleProfileSubdivisions as t,pathNumRoundJoinSubdivisions as a,pathNumRoundCapExtrusionSubdivisions as s}from"./Graphics3DPathSymbolLayerConstants.js";import{primitiveLodResources as u}from"./primitiveObjectSymbolUtils.js";import{EstimatedSymbolComplexity as o,SymbolComplexityMemory as b,EstimatedAggregateSymbolComplexity as y,AggregateSymbolComplexity as i,SymbolComplexity as c}from"./SymbolComplexity.js";import{hasEdges as n}from"../support/edgeUtils.js";import{DefaultMaterial as l}from"../../webgl-engine/materials/DefaultMaterial.js";const P=new o({});function m(e){if("web-style"===e.type)return P;return F(e.symbolLayers.toArray().map(r=>L(e,r)))}function F(e){let r=0,t=0,a=0,s=!1,u=0;const o=new b;for(const b of e)null!=b&&(r+=b.verticesPerFeature,t+=b.verticesPerCoordinate,a+=b.drawCallsPerFeature,o.bytesPerFeature+=b.memory.bytesPerFeature,o.bytesPerFeatureLabel+=b.memory.bytesPerFeatureLabel,o.resourceBytes+=b.memory.resourceBytes,o.draped.bytesPerFeature+=b.memory.bytesPerFeature,o.draped.bytesPerFeatureLabel+=b.memory.bytesPerFeatureLabel,s=s||b.estimated,++u);return s?new y(u,{verticesPerFeature:r,verticesPerCoordinate:t,drawCallsPerFeature:a,memory:o}):new i(u,{verticesPerFeature:r,verticesPerCoordinate:t,drawCallsPerFeature:a,memory:o})}function d(e){const r=F(e);return r.numComplexities>0&&(r.verticesPerFeature/=r.numComplexities,r.verticesPerCoordinate/=r.numComplexities,r.drawCallsPerFeature/=r.numComplexities,r.memory.bytesPerFeature/=r.numComplexities,r.memory.bytesPerFeatureLabel/=r.numComplexities,r.memory.resourceBytes/=r.numComplexities,r.memory.draped.bytesPerFeature/=r.numComplexities,r.memory.draped.bytesPerFeatureLabel/=r.numComplexities),r}const p={};function L(u,b){const y=C(u,b),i=n(b)?2:0;switch(b.type){case"extrude":return new c({verticesPerFeature:-12,verticesPerCoordinate:12,drawCallsPerFeature:i,memory:y});case"fill":if("mesh-3d"===u.type)return new c({drawCallsPerFeature:i,memory:y});if(null!=b.outline&&b.outline.size>0)return new c({verticesPerFeature:-12,verticesPerCoordinate:9,memory:y});case"water":return new c({verticesPerFeature:-6,verticesPerCoordinate:3,memory:y});case"line":return new c({verticesPerFeature:-6,verticesPerCoordinate:6,memory:y});case"object":return b.resource?.href?new o({verticesPerFeature:100,memory:y}):{...f(b.resource?.primitive??r),memory:y};case"path":{let r=0,u=0;switch(b.profile){case"circle":r=t;break;case"quad":r=4;break;default:return void e(b.profile)}switch(b.join){case"round":u=a;break;case"miter":case"bevel":u=1;break;default:return}const o=2*r,i=r*u*2,n=i+o;let l=-2*i-o;switch(b.cap){case"none":break;case"butt":case"square":l+=2*(r-1);break;case"round":l+=2*(r*(s-1)*2+r);break;default:return}return new c({verticesPerFeature:l,verticesPerCoordinate:n,memory:y})}case"text":{const e="label-3d"===u.type?0:2;return new c({verticesPerFeature:6,memory:y,drawCallsPerFeature:e})}case"icon":return new c({verticesPerFeature:6,memory:y});default:return}}function C(r,t){const a="point-3d"===r.type;switch(t.type){case"extrude":return t.edges&&t.edges.size>0?E.EXTRUDE_EDGES:E.EXTRUDE;case"fill":return null!=t.outline&&t.outline.size>0?E.FILL_OUTLINE:E.FILL;case"water":return E.FILL;case"line":return"round"===t.join?E.LINE_ROUND:E.LINE_MITER;case"path":switch(t.join){case"round":switch(t.profile){case"circle":return E.PATH_ROUND_CIRCLE;case"quad":return E.PATH_ROUND_QUAD;default:return void e(t.profile)}case"miter":case"bevel":switch(t.profile){case"circle":return E.PATH_MITER_CIRCLE;case"quad":return E.PATH_MITER_QUAD;default:return void e(t.profile)}default:return}case"object":return a?E.OBJECT_POINT:E.OBJECT_POLYGON;case"icon":case"text":return a?E.ICON_POINT:E.ICON_POLYGON;default:return}}function f(e){const r=p[e];if(r)return r;const t=w(u(e,new l({},{spherical:!0})).levels);return p[e]=new c({verticesPerFeature:t}),p[e]}function w(e){return e.reduce((e,r,t)=>e+r.numVertices*(1/10**t),0)/e.reduce((e,r,t)=>e+1/10**t,0)}const E={ICON_POINT:{bytesPerFeature:2658,bytesPerFeatureLabel:3484,resourceBytes:0,draped:{bytesPerFeature:1845,bytesPerFeatureLabel:3498}},ICON_POLYGON:{bytesPerFeature:3086,bytesPerFeatureLabel:2996,resourceBytes:0,draped:{bytesPerFeature:2694,bytesPerFeatureLabel:3014}},OBJECT_POINT:{bytesPerFeature:497,bytesPerFeatureLabel:2933,resourceBytes:0,draped:{bytesPerFeature:497,bytesPerFeatureLabel:2933}},OBJECT_POLYGON:{bytesPerFeature:867,bytesPerFeatureLabel:2491,resourceBytes:0,draped:{bytesPerFeature:867,bytesPerFeatureLabel:2491}},LINE_MITER:{bytesPerFeature:2337,bytesPerFeatureLabel:2658,resourceBytes:0,draped:{bytesPerFeature:1864,bytesPerFeatureLabel:2656}},LINE_ROUND:{bytesPerFeature:2341,bytesPerFeatureLabel:2672,resourceBytes:0,draped:{bytesPerFeature:1873,bytesPerFeatureLabel:2643}},PATH_MITER_CIRCLE:{bytesPerFeature:22374,bytesPerFeatureLabel:2558,resourceBytes:0,draped:{bytesPerFeature:22374,bytesPerFeatureLabel:2558}},PATH_ROUND_CIRCLE:{bytesPerFeature:24004,bytesPerFeatureLabel:2598,resourceBytes:0,draped:{bytesPerFeature:24004,bytesPerFeatureLabel:2598}},PATH_MITER_QUAD:{bytesPerFeature:24040,bytesPerFeatureLabel:2940,resourceBytes:0,draped:{bytesPerFeature:24040,bytesPerFeatureLabel:2940}},PATH_ROUND_QUAD:{bytesPerFeature:23088,bytesPerFeatureLabel:2886,resourceBytes:0,draped:{bytesPerFeature:23088,bytesPerFeatureLabel:2886}},FILL:{bytesPerFeature:3059,bytesPerFeatureLabel:2838,resourceBytes:0,draped:{bytesPerFeature:2352,bytesPerFeatureLabel:2808}},FILL_OUTLINE:{bytesPerFeature:3093,bytesPerFeatureLabel:2632,resourceBytes:0,draped:{bytesPerFeature:2480,bytesPerFeatureLabel:2601}},EXTRUDE:{bytesPerFeature:5075,bytesPerFeatureLabel:2559,resourceBytes:0,draped:{bytesPerFeature:5075,bytesPerFeatureLabel:2559}},EXTRUDE_EDGES:{bytesPerFeature:2843,bytesPerFeatureLabel:2139,resourceBytes:0,draped:{bytesPerFeature:2843,bytesPerFeatureLabel:2139}}};if(has("esri-tests-disable-symbol-memory-estimators"))for(const _ in E){const e=E[_];e.bytesPerFeature=0,e.bytesPerFeatureLabel=0,e.draped.bytesPerFeature=0,e.draped.bytesPerFeatureLabel=0}export{d as averageSymbolComplexities,m as defaultSymbolComplexity,L as defaultSymbolLayerComplexity,C as defaultSymbolLayerMemoryComplexity,P as emptySymbolComplexity,w as estimateNumVerticesForLods,E as memoryEstimators,F as totalSymbolComplexities};
@@ -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{colorGamma as e,delinearize as r}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as t}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as o}from"../../../../core/mathUtils.js";import{normalFromMat4 as s,fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as c,e as m,D as f,b as d,n as p,l as g}from"../../../../chunks/vec32.js";import{create as x}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as T,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as h}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec3f as y,BufferViewVec4f as w,BufferViewVec4u8 as v,BufferViewVec4u16 as R,BufferViewVec3u8 as B,BufferViewVec3u16 as j}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,b as M,n as F,f as A}from"../../../../chunks/vec3.js";import{t as E,b as C}from"../../../../chunks/vec4.js";import{a as I}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as P}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as U}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as O}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as k}from"./ProcessedObjectResource.js";import{load as V,processLoadResult as _}from"./wosrLoader.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{Geometry as G}from"../../webgl-engine/lib/Geometry.js";import{Texture as W}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as H}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as N,schematicMRRFactors as Q,esriSymbologyMRRFactors as $,advancedMRRFactors as z}from"../../webgl-engine/materials/pbrUtils.js";async function K(e,r){const o=q(t(e));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):V(o.url,r)),{engineResources:t,referenceBoundingBox:s}=_(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(r.cache)s=await r.cache.loadGLTF(o.url,r,!!r.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new L,o.url,r,r.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,re(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:$}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:z},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=J(s,a,u,r,o.specifiedLodIndex,n);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function q(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function J(e,r,t,o,s,i){const n=e.model,l=new Array,a=new Map,u=new Map,c=n.lods.length,m=T();return n.lods.forEach((e,f)=>{const d=!0===o.skipHighLods&&(c>1&&0===f||c>3&&1===f)||!1===o.skipHighLods&&null!=s&&f!==s;if(d&&0!==f)return;const p=new k(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach(e=>{const s=d?new H({},o):X(n,e,p,r,t,a,u,o,i),{geometry:l,vertexCount:c}=Y(e,s??new H({},o)),g=l.boundingInfo;null!=g&&0===f&&(b(m,g.bbMin),b(m,g.bbMax)),null!=s&&(p.stageResources.geometries.push(l),p.numberOfVertices+=c)}),d||l.push(p)}),{engineResources:l,referenceBoundingBox:m}}function X(e,t,o,s,i,n,l,a,c){const m=e.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),T=null!=t.attributes.texCoord0,b=null!=t.attributes.normal,h=ee(m.alphaMode);if(!n.has(x)){if(T){const r=(r,t=!1,o=!1)=>{if(null!=r&&!l.has(r)){const s=e.textures.get(r);if(s){const e=s.data,i=t&&!U(e)?a.compressionOptions:void 0;l.set(r,new W(U(e)?e.data:e,{...s.parameters,preMultiplyAlpha:!U(e)&&o,encoding:U(e)?e.encoding:void 0,compressionOptions:i}))}}},t=1!==h&&!c;r(m.colorTexture,t,1!==h),r(m.normalTexture),r(m.occlusionTexture,!0),r(m.emissiveTexture),r(m.metallicRoughnessTexture,!0)}const o=r(m.color[0]),f=r(m.color[1]),d=r(m.color[2]),p=null!=m.colorTexture&&T?l.get(m.colorTexture):null,g=N(m),y=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:u;n.set(x,new H({...s,customDepthTest:1,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[o,f,d],ambient:[o,f,d],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?0:2,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:b?0:2,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclusion,textureId:null!=p?p.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&T?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=p&&!!p.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&T?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&T?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&T?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[m.emissiveFactor[0],m.emissiveFactor[1],m.emissiveFactor[2]],mrrFactors:g?Q:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:g,colorTextureTransformMatrix:O(m.colorTextureTransform),normalTextureTransformMatrix:O(m.normalTextureTransform),scale:[y[0],y[1]],occlusionTextureTransformMatrix:O(m.occlusionTextureTransform),emissiveTextureTransformMatrix:O(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:O(m.metallicRoughnessTextureTransform),...i},a))}const y=n.get(x);if(o.stageResources.materials.push(y),T){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function Y(e,r){const t=e.attributes.position.count,n=P(e.indices||t,e.primitiveType),l=h(3*t),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;S(l,a,e.transform,3,u);const c=[["position",new D(l,n,3,!0)]];if(null!=e.attributes.normal){const r=h(3*t),{typedBuffer:i,typedBufferStride:l}=e.attributes.normal;s(Z,e.transform),M(r,i,Z,3,l),o(Z)&&F(r,r),c.push(["normal",new D(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=h(4*t),{typedBuffer:s,typedBufferStride:l}=e.attributes.tangent;i(Z,e.transform),E(r,s,Z,4,l),o(Z)&&F(r,r,4),c.push(["tangent",new D(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=h(2*t),{typedBuffer:o,typedBufferStride:s}=e.attributes.texCoord0;I(r,o,2,s),c.push(["uv0",new D(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*t);4===m.elementCount?m instanceof w?C(r,m,1,255):(m instanceof v||m instanceof R)&&C(r,m,1/255,255):(r.fill(255),m instanceof y?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof B||e.attributes.color instanceof j)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push(["color",new D(r,n,4,!0)])}return{geometry:new G(r,c),vertexCount:t}}const Z=n();function ee(e){switch(e){case"BLEND":return 0;case"MASK":return 2;case"OPAQUE":case null:case void 0:return 1}}function re(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const n=i.attributes.position,u=n.count,T=x(),b=x(),h=x(),v=new Float32Array(4*u),R=new Float32Array(3*u),B=l(a(),i.transform);let j=0,S=0;for(let l=0;l<u;l++){n.getVec(l,b),s.getVec(l,T),c(b,b,i.transform),m(h,b,t.center),f(h,h,t.radius);const a=h[2],u=d(h),x=Math.min(.45+.55*u*u,1)**e;f(h,h,t.radius),null!==B&&c(h,h,B),p(h,h),o+1!==r.model.lods.length&&r.model.lods.length>1&&g(h,h,T,a>-1?.2:Math.min(-4*a-3.8,1)),R[j]=h[0],R[j+1]=h[1],R[j+2]=h[2],j+=3,v[S]=x,v[S+1]=x,v[S+2]=x,v[S+3]=1,S+=4}i.attributes.normal=new y(R.buffer),i.attributes.color=new w(v.buffer)}}}export{K as fetch,q as parseUrl};
5
+ import{colorGamma as e,delinearize as r}from"../../../../colorUtils.js";import{adjustStaticAGOUrl as t}from"../../../../core/devEnvironmentUtils.js";import{hasScaling as o}from"../../../../core/mathUtils.js";import{normalFromMat4 as s,fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as u}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{t as c,e as m,D as f,b as d,n as p,l as g}from"../../../../chunks/vec32.js";import{create as x}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as T,expandWithVec3 as b}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as h}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec3f as y,BufferViewVec4f as w,BufferViewVec4u8 as v,BufferViewVec4u16 as R,BufferViewVec3u8 as B,BufferViewVec3u16 as j}from"../../../../geometry/support/buffer/BufferView.js";import{t as S,b as M,n as F,f as A}from"../../../../chunks/vec3.js";import{t as E,b as C}from"../../../../chunks/vec4.js";import{a as I}from"../../../../chunks/vec2.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{convertPrimitiveToTriangles as P}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as U}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as O}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as k}from"./ProcessedObjectResource.js";import{load as V,processLoadResult as _}from"./wosrLoader.js";import{Attribute as D}from"../../webgl-engine/lib/Attribute.js";import{Geometry as G}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as W}from"../../webgl-engine/lib/ManagedTexture.js";import{DefaultMaterial as H}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as N,schematicMRRFactors as Q,esriSymbologyMRRFactors as $,advancedMRRFactors as z}from"../../webgl-engine/materials/pbrUtils.js";async function K(e,r){const o=q(t(e));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):V(o.url,r)),{engineResources:t,referenceBoundingBox:s}=_(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}let s;if(r.cache)s=await r.cache.loadGLTF(o.url,r,!!r.usePBR);else{const{loadGLTF:e}=await import("../../glTF/loader.js");s=await e(new L,o.url,r,r.usePBR)}const i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,re(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:$}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:z},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=J(s,a,u,r,o.specifiedLodIndex,n);return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function q(e){const r=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(r)return{fileType:"gltf",url:r[1],specifiedLodIndex:null!=r[4]?Number(r[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function J(e,r,t,o,s,i){const n=e.model,l=new Array,a=new Map,u=new Map,c=n.lods.length,m=T();return n.lods.forEach((e,f)=>{const d=!0===o.skipHighLods&&(c>1&&0===f||c>3&&1===f)||!1===o.skipHighLods&&null!=s&&f!==s;if(d&&0!==f)return;const p=new k(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach(e=>{const s=d?new H({},o):X(n,e,p,r,t,a,u,o,i),{geometry:l,vertexCount:c}=Y(e,s??new H({},o)),g=l.boundingInfo;null!=g&&0===f&&(b(m,g.bbMin),b(m,g.bbMax)),null!=s&&(p.stageResources.geometries.push(l),p.numberOfVertices+=c)}),d||l.push(p)}),{engineResources:l,referenceBoundingBox:m}}function X(e,t,o,s,i,n,l,a,c){const m=e.materials.get(t.material);if(null==m)return null;const{normal:f,color:d,texCoord0:p,tangent:g}=t.attributes,x=t.material+(f?"_normal":"")+(d?"_color":"")+(p?"_texCoord0":"")+(g?"_tangent":""),T=null!=t.attributes.texCoord0,b=null!=t.attributes.normal,h=ee(m.alphaMode);if(!n.has(x)){if(T){const r=(r,t=!1,o=!1)=>{if(null!=r&&!l.has(r)){const s=e.textures.get(r);if(s){const e=s.data,i=t&&!U(e)?a.compressionOptions:void 0;l.set(r,new W(U(e)?e.data:e,{...s.parameters,preMultiplyAlpha:!U(e)&&o,encoding:U(e)?e.encoding:void 0,compressionOptions:i}))}}},t=1!==h&&!c;r(m.colorTexture,t,1!==h),r(m.normalTexture),r(m.occlusionTexture,!0),r(m.emissiveTexture),r(m.metallicRoughnessTexture,!0)}const o=r(m.color[0]),f=r(m.color[1]),d=r(m.color[2]),p=null!=m.colorTexture&&T?l.get(m.colorTexture):null,g=N(m),y=null!=m.normalTextureTransform?.scale?m.normalTextureTransform?.scale:u;n.set(x,new H({...s,customDepthTest:1,textureAlphaMode:h,textureAlphaCutoff:m.alphaCutoff,diffuse:[o,f,d],ambient:[o,f,d],opacity:"OPAQUE"===m.alphaMode?1:m.opacity,doubleSided:m.doubleSided,doubleSidedType:"winding-order",cullFace:m.doubleSided?0:2,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:b?0:2,castShadows:!0,receiveShadows:m.receiveShadows,receiveAmbientOcclusion:m.receiveAmbientOcclusion,textureId:null!=p?p.id:void 0,colorMixMode:m.colorMixMode,normalTextureId:null!=m.normalTexture&&T?l.get(m.normalTexture).id:void 0,textureAlphaPremultiplied:null!=p&&!!p.parameters.preMultiplyAlpha,occlusionTextureId:null!=m.occlusionTexture&&T?l.get(m.occlusionTexture).id:void 0,emissiveTextureId:null!=m.emissiveTexture&&T?l.get(m.emissiveTexture).id:void 0,metallicRoughnessTextureId:null!=m.metallicRoughnessTexture&&T?l.get(m.metallicRoughnessTexture).id:void 0,emissiveBaseColor:[m.emissiveFactor[0],m.emissiveFactor[1],m.emissiveFactor[2]],mrrFactors:g?Q:[m.metallicFactor,m.roughnessFactor,s.mrrFactors[2]],isSchematic:g,colorTextureTransformMatrix:O(m.colorTextureTransform),normalTextureTransformMatrix:O(m.normalTextureTransform),scale:[y[0],y[1]],occlusionTextureTransformMatrix:O(m.occlusionTextureTransform),emissiveTextureTransformMatrix:O(m.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:O(m.metallicRoughnessTextureTransform),...i},a))}const y=n.get(x);if(o.stageResources.materials.push(y),T){const e=e=>{null!=e&&o.stageResources.textures.push(l.get(e))};e(m.colorTexture),e(m.normalTexture),e(m.occlusionTexture),e(m.emissiveTexture),e(m.metallicRoughnessTexture)}return y}function Y(e,r){const t=e.attributes.position.count,n=P(e.indices||t,e.primitiveType),l=h(3*t),{typedBuffer:a,typedBufferStride:u}=e.attributes.position;S(l,a,e.transform,3,u);const c=[["position",new D(l,n,3,!0)]];if(null!=e.attributes.normal){const r=h(3*t),{typedBuffer:i,typedBufferStride:l}=e.attributes.normal;s(Z,e.transform),M(r,i,Z,3,l),o(Z)&&F(r,r),c.push(["normal",new D(r,n,3,!0)])}if(null!=e.attributes.tangent){const r=h(4*t),{typedBuffer:s,typedBufferStride:l}=e.attributes.tangent;i(Z,e.transform),E(r,s,Z,4,l),o(Z)&&F(r,r,4),c.push(["tangent",new D(r,n,4,!0)])}if(null!=e.attributes.texCoord0){const r=h(2*t),{typedBuffer:o,typedBufferStride:s}=e.attributes.texCoord0;I(r,o,2,s),c.push(["uv0",new D(r,n,2,!0)])}const m=e.attributes.color;if(null!=m){const r=new Uint8Array(4*t);4===m.elementCount?m instanceof w?C(r,m,1,255):(m instanceof v||m instanceof R)&&C(r,m,1/255,255):(r.fill(255),m instanceof y?A(r,m.typedBuffer,1,255,4,m.typedBufferStride):(e.attributes.color instanceof B||e.attributes.color instanceof j)&&A(r,m.typedBuffer,1/255,255,4,e.attributes.color.typedBufferStride)),c.push(["color",new D(r,n,4,!0)])}return{geometry:new G(r,c),vertexCount:t}}const Z=n();function ee(e){switch(e){case"BLEND":return 0;case"MASK":return 2;case"OPAQUE":case null:case void 0:return 1}}function re(r,t){for(let o=0;o<r.model.lods.length;++o){const s=r.model.lods[o];for(const i of s.parts){const s=i.attributes.normal;if(null==s)return;const n=i.attributes.position,u=n.count,T=x(),b=x(),h=x(),v=new Float32Array(4*u),R=new Float32Array(3*u),B=l(a(),i.transform);let j=0,S=0;for(let l=0;l<u;l++){n.getVec(l,b),s.getVec(l,T),c(b,b,i.transform),m(h,b,t.center),f(h,h,t.radius);const a=h[2],u=d(h),x=Math.min(.45+.55*u*u,1)**e;f(h,h,t.radius),null!==B&&c(h,h,B),p(h,h),o+1!==r.model.lods.length&&r.model.lods.length>1&&g(h,h,T,a>-1?.2:Math.min(-4*a-3.8,1)),R[j]=h[0],R[j+1]=h[1],R[j+2]=h[2],j+=3,v[S]=x,v[S+1]=x,v[S+2]=x,v[S+3]=1,S+=4}i.attributes.normal=new y(R.buffer),i.attributes.color=new w(v.buffer)}}}export{K as fetch,q as parseUrl};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import r from"../../../../../../core/Accessor.js";import"../../../../../../core/has.js";import{createAbortError as t}from"../../../../../../core/promiseUtils.js";import{property as s}from"../../../../../../core/accessorSupport/decorators/property.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import{subclass as i}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{ONES as d}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{DirectRenderer as n}from"./DirectRenderer.js";import{LodRenderer as o}from"./LodRenderer.js";import{Texture as l}from"../../../../webgl-engine/lib/Texture.js";import{DefaultMaterial as c}from"../../../../webgl-engine/materials/DefaultMaterial.js";import{HUDMaterial as u}from"../../../../webgl-engine/materials/HUDMaterial.js";import{schematicMRRFactors as m}from"../../../../webgl-engine/materials/pbrUtils.js";let h=class extends r{constructor(e){super(),this.view=null,this.layerViewUid=null,this._stage=null,this._materials=new Map,this._textures=new Map,this._directRenderers=new Map,this._lodRenderers=new Map,this.totalFeatures=0,this.view=e.view,this.layerViewUid=e.layerViewUid}initialize(){this._stage=this.view.stage}destroy(){this.removeAllHandles(),this._lodRenderers.forEach(e=>e.destroy())}async createTexture(e,r){const{_textures:t,_stage:s}=this,i=new l(e,r);return t.set(i.id,i),s&&(i.load(s.renderView.renderingContext),s.addTexture(i)),i.id}async releaseTexture(e){const{_textures:r,_stage:t}=this,s=r.get(e);s&&(t&&(s.unload(),t.removeTexture(s)),r.delete(e))}_destroyTexture(e){const{_textures:r,_stage:t}=this,s=r.get(e);s&&(t&&(s.unload(),t.removeTexture(s)),r.delete(e))}async createMaterial(e){const{view:r}=this,t=1===r.state.viewingMode;let s=null;switch(e.type){case"default":{const r=e.parameters,i=new c(r,{spherical:t});i.setParameters({cullFace:i.transparent?0:2}),s=i;break}case"hud":{const r=e.parameters;s=new u(r,t)}}this._materials.set(e.materialId,s)}async destroyMaterial(e){this._materials.delete(e)}async updateMaterial(e){}async createDirectRenderer(e){if(this._directRenderers.has(e))return;const r=this._materials.get(e);if(null==r)throw new Error(`material not found ${e}`);const{view:t}=this,s=new n({material:r,layerViewUid:this.layerViewUid});this._directRenderers.set(e,s),t.stage.addRenderPlugin(s),t.stage.renderView.renderer.updateHasFlags()}setBaseInstance(e,r){const t=this._directRenderers.get(e);if(null==t)throw new Error(`renderer not found ${e}`);t.setBaseInstance(r)}async destroyDirectRenderer(e){const r=this._directRenderers.get(e);if(null==r)return;const t=this.view;t.stage.removeRenderPlugin(r),this._directRenderers.delete(e),t.stage.renderView.renderer.updateHasFlags()}async createLoDRenderer(e,r,s){const i=new o({view:this.view,layerViewUid:this.layerViewUid}),d=e=>this._materials.get(e);if(await i.doLoad(r,d,s),s?.aborted)throw i.destroy(),t();this._lodRenderers.set(e,i)}async destroyLoDRenderer(e,r){const t=this._lodRenderers.get(e);null!=t&&(t.destroy(),this._lodRenderers.delete(e))}_destroyLodRenderer({rendererId:e}){const r=this._lodRenderers.get(e);null!=r&&(r.destroy(),this._lodRenderers.delete(e))}async executeRenderCommands(e){for(const r of e)switch(r.id){case"destroy-texture":this._destroyTexture(r.textureId);break;case"update-material":this._updateMaterial(r);break;case"destroy-material":this._destroyMaterial(r);break;case"add-direct-renderer-geometry-buffer":this._addDirectRendererGeometryBuffer(r);break;case"update-direct-renderer-geometry-buffer":this._updateDirectRendererGeometryBuffer(r);break;case"remove-direct-renderer-geometry-buffer":this._removeDirectRendererGeometryBuffer(r);break;case"destroy-lod-renderer":this._destroyLodRenderer(r);break;case"add-lod-instances":this._addLodInstances(r);break;case"remove-lod-instances":this._removeLodInstances(r);break;case"update-lod-instance-data":this._updateLodInstanceData(r);break;case"update-visibility":this._updateVisibility(r)}e.length>0&&this._updateFeatureCount()}_updateFeatureCount(){let e=0;for(const r of this._directRenderers.values())e+=r.numFeatures;for(const r of this._lodRenderers.values())e+=r.numFeatures;this._set("totalFeatures",e)}get usedMemory(){let e=0;for(const r of this._directRenderers.values())e+=r.usedMemory;for(const r of this._lodRenderers.values())e+=r.usedMemory;return e}_updateMaterial({materialId:e,parameters:r}){const t=this._materials.get(e);null!=t?t.setParameters(r):console.error("material not found")}_destroyMaterial({materialId:e}){null!=this._materials.get(e)?this._materials.delete(e):console.error("material not found")}_addDirectRendererGeometryBuffer({groupId:e,rendererId:r,renderGeometryBuffer:t,renderGeometryBufferItems:s,localOrigin:i}){const d=this._directRenderers.get(r);null!=d?(d.addRenderGeometryBuffer(e,t,s,i),this.view.stage.renderView.requestRender()):console.error("no renderer assigned to provided material")}_updateDirectRendererGeometryBuffer({groupId:e,rendererId:r,renderGeometryBuffer:t,renderGeometryBufferItems:s,localOrigin:i}){const d=this._directRenderers.get(r);null!=d?(d.updateRenderGeometryBuffer(e,t,s,i),this.view.stage.renderView.requestRender()):console.error("no renderer assigned to provided material")}_removeDirectRendererGeometryBuffer({groupId:e,rendererId:r}){const t=this._directRenderers.get(r);null!=t?(t.removeRenderGeometryBuffer(e),this.view.stage.renderView.requestRender()):console.error("no renderer assigned to provided material")}_addLodInstances({rendererId:e,groupId:r,data:t}){const s=this._lodRenderers.get(e);if(null==s)throw new Error("no lod renderer assigned to provided lod renderer Id");s.addInstances(r,t),this.view.stage.renderView.requestRender()}_removeLodInstances({rendererId:e,groupId:r}){const t=this._lodRenderers.get(e);if(null==t)throw new Error("no lod renderer assigned to provided lod renderer Id");t.removeInstances(r),this.view.stage.renderView.requestRender()}_updateLodInstanceData({rendererId:e,groupId:r,globalTransforms:t}){const s=this._lodRenderers.get(e);if(null==s)throw new Error("No renderer found with the provided id");null!=t&&s.updateGlobalTransforms(r,t),this.view.stage.renderView.requestRender()}_updateVisibility({rendererId:e,groupId:r,visibility:t}){const s=this._directRenderers.get(e)??this._lodRenderers.get(e);if(null==s)throw new Error("No renderer found with the provided id");s.updateVisibility(r,t),this.view.stage.renderView.requestRender()}};function f(e,r,t){const s={usePBR:r.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:m,ambient:d,diffuse:d,hasSlicePlane:r.slicePlaneEnabled,castShadows:r.castShadows,offsetTransparentBackfaces:!r.isPrimitive};r.screenSizePerspectiveEnabled&&(s.screenSizePerspective=e.screenSizePerspective.parameters),s.externalColor=a,s.instanced=!0;const i=new c(s,{spherical:t});return i.setParameters({cullFace:i.transparent?0:2}),i}e([s({readOnly:!0})],h.prototype,"totalFeatures",void 0),h=e([i("esri.views.3d.layers.graphics.pipeline.rendering.FeaturePipelineRenderManager")],h);export{h as FeaturePipelineRenderManager,f as createDefaultMaterial};
5
+ import{__decorate as e}from"tslib";import r from"../../../../../../core/Accessor.js";import"../../../../../../core/has.js";import{createAbortError as t}from"../../../../../../core/promiseUtils.js";import{property as s}from"../../../../../../core/accessorSupport/decorators/property.js";import"../../../../../../core/Logger.js";import"../../../../../../core/RandomLCG.js";import{subclass as i}from"../../../../../../core/accessorSupport/decorators/subclass.js";import{ONES as d}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{DirectRenderer as n}from"./DirectRenderer.js";import{LodRenderer as o}from"./LodRenderer.js";import{ManagedTexture as l}from"../../../../webgl-engine/lib/ManagedTexture.js";import{DefaultMaterial as c}from"../../../../webgl-engine/materials/DefaultMaterial.js";import{HUDMaterial as u}from"../../../../webgl-engine/materials/HUDMaterial.js";import{schematicMRRFactors as m}from"../../../../webgl-engine/materials/pbrUtils.js";let h=class extends r{constructor(e){super(),this.view=null,this.layerViewUid=null,this._stage=null,this._materials=new Map,this._textures=new Map,this._directRenderers=new Map,this._lodRenderers=new Map,this.totalFeatures=0,this.view=e.view,this.layerViewUid=e.layerViewUid}initialize(){this._stage=this.view.stage}destroy(){this.removeAllHandles(),this._lodRenderers.forEach(e=>e.destroy())}async createTexture(e,r){const{_textures:t,_stage:s}=this,i=new l(e,r);return t.set(i.id,i),s&&(i.load(s.renderView.renderingContext),s.addTexture(i)),i.id}async releaseTexture(e){const{_textures:r,_stage:t}=this,s=r.get(e);s&&(t&&(s.unload(),t.removeTexture(s)),r.delete(e))}_destroyTexture(e){const{_textures:r,_stage:t}=this,s=r.get(e);s&&(t&&(s.unload(),t.removeTexture(s)),r.delete(e))}async createMaterial(e){const{view:r}=this,t=1===r.state.viewingMode;let s=null;switch(e.type){case"default":{const r=e.parameters,i=new c(r,{spherical:t});i.setParameters({cullFace:i.transparent?0:2}),s=i;break}case"hud":{const r=e.parameters;s=new u(r,t)}}this._materials.set(e.materialId,s)}async destroyMaterial(e){this._materials.delete(e)}async updateMaterial(e){}async createDirectRenderer(e){if(this._directRenderers.has(e))return;const r=this._materials.get(e);if(null==r)throw new Error(`material not found ${e}`);const{view:t}=this,s=new n({material:r,layerViewUid:this.layerViewUid});this._directRenderers.set(e,s),t.stage.addRenderPlugin(s),t.stage.renderView.renderer.updateHasFlags()}setBaseInstance(e,r){const t=this._directRenderers.get(e);if(null==t)throw new Error(`renderer not found ${e}`);t.setBaseInstance(r)}async destroyDirectRenderer(e){const r=this._directRenderers.get(e);if(null==r)return;const t=this.view;t.stage.removeRenderPlugin(r),this._directRenderers.delete(e),t.stage.renderView.renderer.updateHasFlags()}async createLoDRenderer(e,r,s){const i=new o({view:this.view,layerViewUid:this.layerViewUid}),d=e=>this._materials.get(e);if(await i.doLoad(r,d,s),s?.aborted)throw i.destroy(),t();this._lodRenderers.set(e,i)}async destroyLoDRenderer(e,r){const t=this._lodRenderers.get(e);null!=t&&(t.destroy(),this._lodRenderers.delete(e))}_destroyLodRenderer({rendererId:e}){const r=this._lodRenderers.get(e);null!=r&&(r.destroy(),this._lodRenderers.delete(e))}async executeRenderCommands(e){for(const r of e)switch(r.id){case"destroy-texture":this._destroyTexture(r.textureId);break;case"update-material":this._updateMaterial(r);break;case"destroy-material":this._destroyMaterial(r);break;case"add-direct-renderer-geometry-buffer":this._addDirectRendererGeometryBuffer(r);break;case"update-direct-renderer-geometry-buffer":this._updateDirectRendererGeometryBuffer(r);break;case"remove-direct-renderer-geometry-buffer":this._removeDirectRendererGeometryBuffer(r);break;case"destroy-lod-renderer":this._destroyLodRenderer(r);break;case"add-lod-instances":this._addLodInstances(r);break;case"remove-lod-instances":this._removeLodInstances(r);break;case"update-lod-instance-data":this._updateLodInstanceData(r);break;case"update-visibility":this._updateVisibility(r)}e.length>0&&this._updateFeatureCount()}_updateFeatureCount(){let e=0;for(const r of this._directRenderers.values())e+=r.numFeatures;for(const r of this._lodRenderers.values())e+=r.numFeatures;this._set("totalFeatures",e)}get usedMemory(){let e=0;for(const r of this._directRenderers.values())e+=r.usedMemory;for(const r of this._lodRenderers.values())e+=r.usedMemory;return e}_updateMaterial({materialId:e,parameters:r}){const t=this._materials.get(e);null!=t?t.setParameters(r):console.error("material not found")}_destroyMaterial({materialId:e}){null!=this._materials.get(e)?this._materials.delete(e):console.error("material not found")}_addDirectRendererGeometryBuffer({groupId:e,rendererId:r,renderGeometryBuffer:t,renderGeometryBufferItems:s,localOrigin:i}){const d=this._directRenderers.get(r);null!=d?(d.addRenderGeometryBuffer(e,t,s,i),this.view.stage.renderView.requestRender()):console.error("no renderer assigned to provided material")}_updateDirectRendererGeometryBuffer({groupId:e,rendererId:r,renderGeometryBuffer:t,renderGeometryBufferItems:s,localOrigin:i}){const d=this._directRenderers.get(r);null!=d?(d.updateRenderGeometryBuffer(e,t,s,i),this.view.stage.renderView.requestRender()):console.error("no renderer assigned to provided material")}_removeDirectRendererGeometryBuffer({groupId:e,rendererId:r}){const t=this._directRenderers.get(r);null!=t?(t.removeRenderGeometryBuffer(e),this.view.stage.renderView.requestRender()):console.error("no renderer assigned to provided material")}_addLodInstances({rendererId:e,groupId:r,data:t}){const s=this._lodRenderers.get(e);if(null==s)throw new Error("no lod renderer assigned to provided lod renderer Id");s.addInstances(r,t),this.view.stage.renderView.requestRender()}_removeLodInstances({rendererId:e,groupId:r}){const t=this._lodRenderers.get(e);if(null==t)throw new Error("no lod renderer assigned to provided lod renderer Id");t.removeInstances(r),this.view.stage.renderView.requestRender()}_updateLodInstanceData({rendererId:e,groupId:r,globalTransforms:t}){const s=this._lodRenderers.get(e);if(null==s)throw new Error("No renderer found with the provided id");null!=t&&s.updateGlobalTransforms(r,t),this.view.stage.renderView.requestRender()}_updateVisibility({rendererId:e,groupId:r,visibility:t}){const s=this._directRenderers.get(e)??this._lodRenderers.get(e);if(null==s)throw new Error("No renderer found with the provided id");s.updateVisibility(r,t),this.view.stage.renderView.requestRender()}};function f(e,r,t){const s={usePBR:r.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:m,ambient:d,diffuse:d,hasSlicePlane:r.slicePlaneEnabled,castShadows:r.castShadows,offsetTransparentBackfaces:!r.isPrimitive};r.screenSizePerspectiveEnabled&&(s.screenSizePerspective=e.screenSizePerspective.parameters),s.externalColor=a,s.instanced=!0;const i=new c(s,{spherical:t});return i.setParameters({cullFace:i.transparent?0:2}),i}e([s({readOnly:!0})],h.prototype,"totalFeatures",void 0),h=e([i("esri.views.3d.layers.graphics.pipeline.rendering.FeaturePipelineRenderManager")],h);export{h as FeaturePipelineRenderManager,f as createDefaultMaterial};
@@ -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"../../../../request.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import n from"../../../../core/Logger.js";import{estimateNestedObjectMemory as s}from"../../../../core/memoryEstimations.js";import{NestedMap as o}from"../../../../core/NestedMap.js";import{throwIfAbortError as a}from"../../../../core/promiseUtils.js";import{Version as i}from"../../../../core/Version.js";import{fromArray as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as u,expandWithVec3 as c}from"../../../../geometry/support/aaBoundingBox.js";import{getContinuousIndexArray as m}from"../../../../geometry/support/Indices.js";import{requestImage as p}from"../../../../request/image.js";import{Attribute as f}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{Texture as g}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as y}from"../../webgl-engine/materials/DefaultMaterial.js";const w=()=>n.getLogger("esri.views.3d.layers.graphics.objectResourceUtils");class x{constructor(e,t,r){this.resource=e,this.textures=t,this.usedMemory=r}}async function h(e,t){const r=await b(e,t),n=await P(r.textureDefinitions??{},t);let o=0;for(const s in n)if(n.hasOwnProperty(s)){const e=n[s];o+=e?.image?e.image.width*e.image.height*4:0}return new x(r,n,o+s(r))}async function b(r,n){const s=await t(e(r,n));if(s.ok)return s.value.data;a(s.error),v(s.error)}function v(e){throw new r("",`Request for object resource failed: ${e}`)}function A(e){const t=e.params,r=t.topology;let n=!0;switch(t.vertexAttributes||(w().warn("Geometry must specify vertex attributes"),n=!1),t.topology){case"PerAttributeArray":break;case"Indexed":case null:case void 0:{const e=t.faces;if(e){if(t.vertexAttributes)for(const r in t.vertexAttributes){const t=e[r];t?.values?(null!=t.valueType&&"UInt32"!==t.valueType&&(w().warn(`Unsupported indexed geometry indices type '${t.valueType}', only UInt32 is currently supported`),n=!1),null!=t.valuesPerElement&&1!==t.valuesPerElement&&(w().warn(`Unsupported indexed geometry values per element '${t.valuesPerElement}', only 1 is currently supported`),n=!1)):(w().warn(`Indexed geometry does not specify face indices for '${r}' attribute`),n=!1)}}else w().warn("Indexed geometries must specify faces"),n=!1;break}default:w().warn(`Unsupported topology '${r}'`),n=!1}e.params.material||(w().warn("Geometry requires material"),n=!1);const s=e.params.vertexAttributes;for(const o in s){s[o].values||(w().warn("Geometries with externally defined attributes are not yet supported"),n=!1)}return n}function j(e,t){const r=new Array,n=new Array,s=new Array,a=new o,u=e.resource,c=i.parse(u.version||"1.0","wosr");E.validate(c);const p=u.model.name,w=u.model.geometries,x=u.materialDefinitions??{},h=e.textures;let b=0;const v=new Map;for(let o=0;o<w.length;o++){const e=w[o];if(!A(e))continue;const i=I(e),u=e.params.vertexAttributes,c=[],p=t=>{if("PerAttributeArray"===e.params.topology)return null;const r=e.params.faces;for(const e in r)if(e===t)return r[e].values;return null},j=u.position,M=j.values.length/j.valuesPerElement;for(const t in u){const e=u[t],r=e.values,n=p(t)??m(M);c.push([t,new f(r,n,e.valuesPerElement,!0)])}const P=i.texture,E=h&&h[P];if(E&&!v.has(P)){const{image:e,parameters:t}=E,r=new g(e,t);n.push(r),v.set(P,r)}const T=v.get(P),k=T?T.id:void 0,O=i.material;let C=a.get(O,P);if(null==C){const e=x[O.slice(O.lastIndexOf("/")+1)].params;1===e.transparency&&(e.transparency=0);const r=E?U(E.alphaChannelUsage):void 0,n={ambient:l(e.diffuse),diffuse:l(e.diffuse),opacity:1-(e.transparency||0),textureAlphaMode:r,textureAlphaCutoff:.33,textureId:k,doubleSided:!0,cullFace:0,colorMixMode:e.externalColorMixMode||"tint",textureAlphaPremultiplied:E?.parameters.preMultiplyAlpha??!1};t?.materialParameters&&Object.assign(n,t.materialParameters),C=new y(n,t),a.set(O,P,C)}s.push(C);const $=new d(C,c);b+=c.find(e=>"position"===e[0])?.[1]?.indices.length??0,r.push($)}return{engineResources:[{name:p,stageResources:{textures:n,materials:s,geometries:r},pivotOffset:u.model.pivotOffset,numberOfVertices:b,lodThreshold:null}],referenceBoundingBox:M(r)}}function M(e){const t=u();return e.forEach(e=>{const r=e.boundingInfo;null!=r&&(c(t,r.bbMin),c(t,r.bbMax))}),t}async function P(e,t){const r=new Array;for(const o in e){const n=e[o],s=n.images[0].data;if(!s){w().warn("Externally referenced texture data is not yet supported");continue}const a=n.encoding+";base64,"+s,i="/textureDefinitions/"+o,l="rgba"===n.channels?n.alphaChannelUsage||"transparency":"none",u={noUnpackFlip:!0,wrap:{s:10497,t:10497},preMultiplyAlpha:1!==U(l)},c=t?.disableTextures?Promise.resolve(null):p(a,t);r.push(c.then(e=>({refId:i,image:e,parameters:u,alphaChannelUsage:l})))}const n=await Promise.all(r),s={};for(const o of n)s[o.refId]=o;return s}function U(e){switch(e){case"mask":return 2;case"maskAndTransparency":return 3;case"none":return 1;default:return 0}}function I(e){const t=e.params;return{id:1,material:t.material,texture:t.texture,region:t.texture}}const E=new i(1,2,"wosr");export{x as LoaderResultWOSR,P as createTextureResources,h as load,j as processLoadResult};
5
+ import e from"../../../../request.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import n from"../../../../core/Logger.js";import{estimateNestedObjectMemory as s}from"../../../../core/memoryEstimations.js";import{NestedMap as o}from"../../../../core/NestedMap.js";import{throwIfAbortError as a}from"../../../../core/promiseUtils.js";import{Version as i}from"../../../../core/Version.js";import{fromArray as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as u,expandWithVec3 as c}from"../../../../geometry/support/aaBoundingBox.js";import{getContinuousIndexArray as m}from"../../../../geometry/support/Indices.js";import{requestImage as p}from"../../../../request/image.js";import{Attribute as f}from"../../webgl-engine/lib/Attribute.js";import{Geometry as d}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as g}from"../../webgl-engine/lib/ManagedTexture.js";import{DefaultMaterial as y}from"../../webgl-engine/materials/DefaultMaterial.js";const w=()=>n.getLogger("esri.views.3d.layers.graphics.objectResourceUtils");class x{constructor(e,t,r){this.resource=e,this.textures=t,this.usedMemory=r}}async function h(e,t){const r=await b(e,t),n=await P(r.textureDefinitions??{},t);let o=0;for(const s in n)if(n.hasOwnProperty(s)){const e=n[s];o+=e?.image?e.image.width*e.image.height*4:0}return new x(r,n,o+s(r))}async function b(r,n){const s=await t(e(r,n));if(s.ok)return s.value.data;a(s.error),v(s.error)}function v(e){throw new r("",`Request for object resource failed: ${e}`)}function A(e){const t=e.params,r=t.topology;let n=!0;switch(t.vertexAttributes||(w().warn("Geometry must specify vertex attributes"),n=!1),t.topology){case"PerAttributeArray":break;case"Indexed":case null:case void 0:{const e=t.faces;if(e){if(t.vertexAttributes)for(const r in t.vertexAttributes){const t=e[r];t?.values?(null!=t.valueType&&"UInt32"!==t.valueType&&(w().warn(`Unsupported indexed geometry indices type '${t.valueType}', only UInt32 is currently supported`),n=!1),null!=t.valuesPerElement&&1!==t.valuesPerElement&&(w().warn(`Unsupported indexed geometry values per element '${t.valuesPerElement}', only 1 is currently supported`),n=!1)):(w().warn(`Indexed geometry does not specify face indices for '${r}' attribute`),n=!1)}}else w().warn("Indexed geometries must specify faces"),n=!1;break}default:w().warn(`Unsupported topology '${r}'`),n=!1}e.params.material||(w().warn("Geometry requires material"),n=!1);const s=e.params.vertexAttributes;for(const o in s){s[o].values||(w().warn("Geometries with externally defined attributes are not yet supported"),n=!1)}return n}function j(e,t){const r=new Array,n=new Array,s=new Array,a=new o,u=e.resource,c=i.parse(u.version||"1.0","wosr");E.validate(c);const p=u.model.name,w=u.model.geometries,x=u.materialDefinitions??{},h=e.textures;let b=0;const v=new Map;for(let o=0;o<w.length;o++){const e=w[o];if(!A(e))continue;const i=I(e),u=e.params.vertexAttributes,c=[],p=t=>{if("PerAttributeArray"===e.params.topology)return null;const r=e.params.faces;for(const e in r)if(e===t)return r[e].values;return null},j=u.position,M=j.values.length/j.valuesPerElement;for(const t in u){const e=u[t],r=e.values,n=p(t)??m(M);c.push([t,new f(r,n,e.valuesPerElement,!0)])}const P=i.texture,E=h&&h[P];if(E&&!v.has(P)){const{image:e,parameters:t}=E,r=new g(e,t);n.push(r),v.set(P,r)}const T=v.get(P),k=T?T.id:void 0,O=i.material;let C=a.get(O,P);if(null==C){const e=x[O.slice(O.lastIndexOf("/")+1)].params;1===e.transparency&&(e.transparency=0);const r=E?U(E.alphaChannelUsage):void 0,n={ambient:l(e.diffuse),diffuse:l(e.diffuse),opacity:1-(e.transparency||0),textureAlphaMode:r,textureAlphaCutoff:.33,textureId:k,doubleSided:!0,cullFace:0,colorMixMode:e.externalColorMixMode||"tint",textureAlphaPremultiplied:E?.parameters.preMultiplyAlpha??!1};t?.materialParameters&&Object.assign(n,t.materialParameters),C=new y(n,t),a.set(O,P,C)}s.push(C);const $=new d(C,c);b+=c.find(e=>"position"===e[0])?.[1]?.indices.length??0,r.push($)}return{engineResources:[{name:p,stageResources:{textures:n,materials:s,geometries:r},pivotOffset:u.model.pivotOffset,numberOfVertices:b,lodThreshold:null}],referenceBoundingBox:M(r)}}function M(e){const t=u();return e.forEach(e=>{const r=e.boundingInfo;null!=r&&(c(t,r.bbMin),c(t,r.bbMax))}),t}async function P(e,t){const r=new Array;for(const o in e){const n=e[o],s=n.images[0].data;if(!s){w().warn("Externally referenced texture data is not yet supported");continue}const a=n.encoding+";base64,"+s,i="/textureDefinitions/"+o,l="rgba"===n.channels?n.alphaChannelUsage||"transparency":"none",u={noUnpackFlip:!0,wrap:{s:10497,t:10497},preMultiplyAlpha:1!==U(l)},c=t?.disableTextures?Promise.resolve(null):p(a,t);r.push(c.then(e=>({refId:i,image:e,parameters:u,alphaChannelUsage:l})))}const n=await Promise.all(r),s={};for(const o of n)s[o.refId]=o;return s}function U(e){switch(e){case"mask":return 2;case"maskAndTransparency":return 3;case"none":return 1;default:return 0}}function I(e){const t=e.params;return{id:1,material:t.material,texture:t.texture,region:t.texture}}const E=new i(1,2,"wosr");export{x as LoaderResultWOSR,P as createTextureResources,h as load,j as processLoadResult};
@@ -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{validateColorAndOpacity as e,validateColor as r}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as o}from"../../../../core/mathUtils.js";import{uncompressedFormats as a,compressibleUsages as s}from"./enums.js";import{RenderTexture as t}from"../../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as l}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{Texture as n}from"../../webgl-engine/lib/Texture.js";import{useSchematicPBRI3S as i,useSchematicPBR as u,schematicMRRFactors as c,advancedMRRFactors as m}from"../../webgl-engine/materials/pbrUtils.js";import{alphaCutoff as d}from"../../../../webscene/support/AlphaCutoff.js";function g(r,o,a){const s=new Map,t=(e,r)=>{if(null==e)return-1;const o=s.get(e.id);if(o)return o.usage|=r,o.id;const a=s.size;return s.set(e.id,{id:a,usage:r}),a},l=o.pbrMetallicRoughness,n=l?.baseColorFactor?e(l.baseColorFactor):null,d=o.emissiveFactor,g=has("disable-feature:diffuse-rendering-i3s")||a?i({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}):u({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:l?.metallicRoughnessTexture,metallicFactor:l?.metallicFactor,roughnessFactor:l?.roughnessFactor}),f=g?c[0]:l?.metallicFactor??m[0],h=g?c[1]:l?.roughnessFactor??m[1],F="mask"===o.alphaMode?33:1,T={baseColorFactor:n?[n[0],n[1],n[2],n[3]]:[1,1,1,1],baseColorTextureId:t(l?.baseColorTexture,F),metallicRoughnessTextureId:t(l?.metallicRoughnessTexture,2),metallicFactor:f,roughnessFactor:h},b={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?0:"back"===o.cullFace?2:"front"===o.cullFace?1:0,normalTextureId:t(o.normalTexture,4),emissiveTextureId:t(o.emissiveTexture,16),occlusionTextureId:t(o.occlusionTexture,8),emissiveFactor:d?[d[0],d[1],d[2]]:[0,0,0],metallicRoughness:T,wrapTextures:!1,hasParametersFromSource:g},C=[];return s.forEach(({usage:e},o)=>{const a=null!=r&&r[o]&&r[o].formats,s=a?p(a.map(({name:e,format:r})=>({name:e,encoding:x[r]}))):[];C.push({id:o,usage:e,encodings:s})}),{material:b,textures:C}}function p(e){return e.sort((e,r)=>e.encoding-r.encoding)}const x={ktx2:1,basis:2,dds:4,png:8,jpg:16,"ktx-etc2":32},f={"image/ktx2":2,"image/x.basis":2,"image/vnd-ms.dds":4,"image/png":8,"image/jpg":16,"image/jpeg":16,"image/ktx":32};function h(e){const a=e?.materialDefinitions?Object.keys(e.materialDefinitions)[0]:null,s=e?.textureDefinitions?Object.keys(e.textureDefinitions)[0]:null,t=a?e.materialDefinitions?.[a]:null,l=s?e.textureDefinitions?.[s]:null,n=F();if(null!=t){const e=t.params;e.diffuse&&(r(e.diffuse),n.metallicRoughness.baseColorFactor=[e.diffuse[0],e.diffuse[1],e.diffuse[2],1]),null!=e.doubleSided&&(n.doubleSided=e.doubleSided,n.cullFace=e.doubleSided?0:2),"none"!==e.cullFace&&"front"!==e.cullFace&&"back"!==e.cullFace||(n.cullFace="none"===e.cullFace?0:"back"===e.cullFace?2:1),e.transparency&&(n.metallicRoughness.baseColorFactor[3]=o(1-e.transparency,0,1)),(e.useVertexColorAlpha||n.metallicRoughness.baseColorFactor[3]<1)&&(n.alphaMode="blend")}const i=[];if(null!=l){const e=0;!l.wrap||"repeat"!==l.wrap[0]&&"repeat"!==l.wrap[1]||(n.wrapTextures=!0);let r=1;"rgba"===l.channels&&(n.alphaMode="blend",r|=32);const o=l.images.length-1,a=l.images[o],s=e=>e?.split("/").pop(),t=Array.isArray(l.encoding)?p(l.encoding.map((e,r)=>({name:s(a.href[r]),encoding:f[e]||0}))):[{name:s(a.href),encoding:f[l.encoding]||0}];i.push({id:e,usage:r,encodings:t}),n.metallicRoughness.baseColorTextureId=e}return{material:n,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:d,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function T(e,r,o,a,s,t){if(null==e?.data)return null;const l=e.data,i=a.renderingContext.parameters.maxMaxAnisotropy,u=i>1,c=o||!r.wrapTextures?b:C,m=k(e.encoding),d=1&e.usage?"opaque"===r.alphaMode?6407:6408:6407,g=P(e.encoding,e.usage)?{compressionTracker:s,compressionCallback:t}:void 0;return new n(l,{mipmap:u,maxAnisotropy:i,encoding:m,wrap:c,pixelFormat:d,compressionOptions:g,noUnpackFlip:!0})}const b={s:33071,t:33071},C={s:10497,t:10497};function R(r,o,a,s,n,i){const u=i.rendererTextureUsage,g=e=>v(s,a,e&u),p=e(o.metallicRoughness.baseColorFactor);r.baseColor=[p[0],p[1],p[2],p[3]],r.hasParametersFromSource=!!o.hasParametersFromSource,r.usePBR=i.usePBR,r.mrrFactors=[o.metallicRoughness.metallicFactor,o.metallicRoughness.roughnessFactor,o.hasParametersFromSource?c[2]:m[2]],r.emissiveBaseColor=o.emissiveFactor,r.isIntegratedMesh=i.isIntegratedMesh,r.textureAlphaCutoff="mask"===o.alphaMode?o.alphaCutoff:d,r.alphaDiscardMode="opaque"===o.alphaMode?1:"mask"===o.alphaMode?2:3;const x=[],f=g(33);null!=f&&(r.baseColorTexture=new t(n,f),x.push(r.baseColorTexture.loadPromise));const h=g(2);null!=h&&(r.metallicRoughnessTexture=new t(n,h),x.push(r.metallicRoughnessTexture.loadPromise));const F=g(16);null!=F&&(r.emissionTexture=new t(n,F),x.push(r.emissionTexture.loadPromise));const T=g(8);null!=T&&(r.occlusionTexture=new t(n,T),x.push(r.occlusionTexture.loadPromise));const b=g(4);return null!=b&&(r.normalTexture=new t(n,b),x.push(r.normalTexture.loadPromise)),r.commonMaterialParameters.hasSlicePlane=i.slicePlaneEnabled,r.commonMaterialParameters.doubleSided=o.doubleSided,r.commonMaterialParameters.cullFace=o.cullFace,r.ellipsoidMode=l(i.viewSpatialReference),Promise.all(x)}function w(e){const r=!!e.compressedTextureS3TC,o=!!e.compressedTextureETC,a=has("disable-feature:i3s-basis")?0:3;return 24|(r?4|a:0)|(o?a:0)}function M(e,r){if(null!=r)return e.find(e=>0!==(e.encoding&r))}function v(e,r,o){if(null==e||0===o)return null;for(let a=0;a<e.length;a++){const s=e[a];if(null!=s&&0!==(s.usage&o)){const e=r[a];return null!=e?e.id:null}}return null}function P(e,r){return!!has("enable-feature:esri-compress-IM-textures")&&(0!==(e&a)&&!(r&~s))}function k(e){switch(e){case 1:return"image/ktx2";case 2:return"image/x.basis";case 4:return"image/vnd-ms.dds";case 8:return"image/png";case 16:return"image/jpeg";case 32:return"image/ktx";default:return""}}export{R as configureMaterial,T as createTexture,F as defaultMaterial,g as getMaterialAndTextures,h as getMaterialAndTexturesFromShared,w as getSupportedEncodings,M as selectEncoding};
5
+ import{validateColorAndOpacity as e,validateColor as r}from"../../../../core/colorUtils.js";import has from"../../../../core/has.js";import{clamp as o}from"../../../../core/mathUtils.js";import{uncompressedFormats as a,compressibleUsages as s}from"./enums.js";import{RenderTexture as t}from"../../webgl-engine/core/material/RenderTexture.js";import{getEllipsoidMode as n}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{ManagedTexture as l}from"../../webgl-engine/lib/ManagedTexture.js";import{useSchematicPBRI3S as i,useSchematicPBR as u,schematicMRRFactors as c,advancedMRRFactors as m}from"../../webgl-engine/materials/pbrUtils.js";import{alphaCutoff as d}from"../../../../webscene/support/AlphaCutoff.js";function g(r,o,a){const s=new Map,t=(e,r)=>{if(null==e)return-1;const o=s.get(e.id);if(o)return o.usage|=r,o.id;const a=s.size;return s.set(e.id,{id:a,usage:r}),a},n=o.pbrMetallicRoughness,l=n?.baseColorFactor?e(n.baseColorFactor):null,d=o.emissiveFactor,g=has("disable-feature:diffuse-rendering-i3s")||a?i({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:n?.metallicRoughnessTexture,metallicFactor:n?.metallicFactor,roughnessFactor:n?.roughnessFactor}):u({normalTexture:o.normalTexture,emissiveTexture:o.emissiveTexture,emissiveFactor:o.emissiveFactor,occlusionTexture:o.occlusionTexture,metallicRoughnessTexture:n?.metallicRoughnessTexture,metallicFactor:n?.metallicFactor,roughnessFactor:n?.roughnessFactor}),f=g?c[0]:n?.metallicFactor??m[0],h=g?c[1]:n?.roughnessFactor??m[1],F="mask"===o.alphaMode?33:1,T={baseColorFactor:l?[l[0],l[1],l[2],l[3]]:[1,1,1,1],baseColorTextureId:t(n?.baseColorTexture,F),metallicRoughnessTextureId:t(n?.metallicRoughnessTexture,2),metallicFactor:f,roughnessFactor:h},b={alphaMode:o.alphaMode,alphaCutoff:o.alphaCutoff,doubleSided:o.doubleSided,cullFace:"none"===o.cullFace?0:"back"===o.cullFace?2:"front"===o.cullFace?1:0,normalTextureId:t(o.normalTexture,4),emissiveTextureId:t(o.emissiveTexture,16),occlusionTextureId:t(o.occlusionTexture,8),emissiveFactor:d?[d[0],d[1],d[2]]:[0,0,0],metallicRoughness:T,wrapTextures:!1,hasParametersFromSource:g},C=[];return s.forEach(({usage:e},o)=>{const a=null!=r&&r[o]&&r[o].formats,s=a?p(a.map(({name:e,format:r})=>({name:e,encoding:x[r]}))):[];C.push({id:o,usage:e,encodings:s})}),{material:b,textures:C}}function p(e){return e.sort((e,r)=>e.encoding-r.encoding)}const x={ktx2:1,basis:2,dds:4,png:8,jpg:16,"ktx-etc2":32},f={"image/ktx2":2,"image/x.basis":2,"image/vnd-ms.dds":4,"image/png":8,"image/jpg":16,"image/jpeg":16,"image/ktx":32};function h(e){const a=e?.materialDefinitions?Object.keys(e.materialDefinitions)[0]:null,s=e?.textureDefinitions?Object.keys(e.textureDefinitions)[0]:null,t=a?e.materialDefinitions?.[a]:null,n=s?e.textureDefinitions?.[s]:null,l=F();if(null!=t){const e=t.params;e.diffuse&&(r(e.diffuse),l.metallicRoughness.baseColorFactor=[e.diffuse[0],e.diffuse[1],e.diffuse[2],1]),null!=e.doubleSided&&(l.doubleSided=e.doubleSided,l.cullFace=e.doubleSided?0:2),"none"!==e.cullFace&&"front"!==e.cullFace&&"back"!==e.cullFace||(l.cullFace="none"===e.cullFace?0:"back"===e.cullFace?2:1),e.transparency&&(l.metallicRoughness.baseColorFactor[3]=o(1-e.transparency,0,1)),(e.useVertexColorAlpha||l.metallicRoughness.baseColorFactor[3]<1)&&(l.alphaMode="blend")}const i=[];if(null!=n){const e=0;!n.wrap||"repeat"!==n.wrap[0]&&"repeat"!==n.wrap[1]||(l.wrapTextures=!0);let r=1;"rgba"===n.channels&&(l.alphaMode="blend",r|=32);const o=n.images.length-1,a=n.images[o],s=e=>e?.split("/").pop(),t=Array.isArray(n.encoding)?p(n.encoding.map((e,r)=>({name:s(a.href[r]),encoding:f[e]||0}))):[{name:s(a.href),encoding:f[n.encoding]||0}];i.push({id:e,usage:r,encodings:t}),l.metallicRoughness.baseColorTextureId=e}return{material:l,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:d,doubleSided:!0,cullFace:0,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function T(e,r,o,a,s,t){if(null==e?.data)return null;const n=e.data,i=a.renderingContext.parameters.maxMaxAnisotropy,u=i>1,c=o||!r.wrapTextures?b:C,m=k(e.encoding),d=1&e.usage?"opaque"===r.alphaMode?6407:6408:6407,g=P(e.encoding,e.usage)?{compressionTracker:s,compressionCallback:t}:void 0;return new l(n,{mipmap:u,maxAnisotropy:i,encoding:m,wrap:c,pixelFormat:d,compressionOptions:g,noUnpackFlip:!0})}const b={s:33071,t:33071},C={s:10497,t:10497};function M(r,o,a,s,l,i){const u=i.rendererTextureUsage,g=e=>v(s,a,e&u),p=e(o.metallicRoughness.baseColorFactor);r.baseColor=[p[0],p[1],p[2],p[3]],r.hasParametersFromSource=!!o.hasParametersFromSource,r.usePBR=i.usePBR,r.mrrFactors=[o.metallicRoughness.metallicFactor,o.metallicRoughness.roughnessFactor,o.hasParametersFromSource?c[2]:m[2]],r.emissiveBaseColor=o.emissiveFactor,r.isIntegratedMesh=i.isIntegratedMesh,r.textureAlphaCutoff="mask"===o.alphaMode?o.alphaCutoff:d,r.alphaDiscardMode="opaque"===o.alphaMode?1:"mask"===o.alphaMode?2:3;const x=[],f=g(33);null!=f&&(r.baseColorTexture=new t(l,f),x.push(r.baseColorTexture.loadPromise));const h=g(2);null!=h&&(r.metallicRoughnessTexture=new t(l,h),x.push(r.metallicRoughnessTexture.loadPromise));const F=g(16);null!=F&&(r.emissionTexture=new t(l,F),x.push(r.emissionTexture.loadPromise));const T=g(8);null!=T&&(r.occlusionTexture=new t(l,T),x.push(r.occlusionTexture.loadPromise));const b=g(4);return null!=b&&(r.normalTexture=new t(l,b),x.push(r.normalTexture.loadPromise)),r.commonMaterialParameters.hasSlicePlane=i.slicePlaneEnabled,r.commonMaterialParameters.doubleSided=o.doubleSided,r.commonMaterialParameters.cullFace=o.cullFace,r.ellipsoidMode=n(i.viewSpatialReference),Promise.all(x)}function R(e){const r=!!e.compressedTextureS3TC,o=!!e.compressedTextureETC,a=has("disable-feature:i3s-basis")?0:3;return 24|(r?4|a:0)|(o?a:0)}function w(e,r){if(null!=r)return e.find(e=>0!==(e.encoding&r))}function v(e,r,o){if(null==e||0===o)return null;for(let a=0;a<e.length;a++){const s=e[a];if(null!=s&&0!==(s.usage&o)){const e=r[a];return null!=e?e.id:null}}return null}function P(e,r){return!!has("enable-feature:esri-compress-IM-textures")&&(0!==(e&a)&&!(r&~s))}function k(e){switch(e){case 1:return"image/ktx2";case 2:return"image/x.basis";case 4:return"image/vnd-ms.dds";case 8:return"image/png";case 16:return"image/jpeg";case 32:return"image/ktx";default:return""}}export{M as configureMaterial,T as createTexture,F as defaultMaterial,g as getMaterialAndTextures,h as getMaterialAndTexturesFromShared,R as getSupportedEncodings,w as selectEncoding};
@@ -0,0 +1,5 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
+ */
5
+ import has from"../../../core/has.js";import{Milliseconds as e}from"../../../core/time.js";function a(e){return t[e]}function i(){return has("esri-iPhone")?"low":"medium"}const o={reset(){const e=r();for(const a of Object.keys(e))t[a]=e[a]}},l={IPhone12Pro:120,GalaxyS20:200,FullHD:240,SurfacePro7:300,FullHDRetina:430},t=r();function r(){const a=!!has("esri-mobile"),i=!!has("ios"),o=e(400);return{low:{graphics3D:{maxTotalNumberOfFeatures:5e4,maxNumberOfDrawCalls:8e3,maxTotalNumberOfVertices:255e4,polygonLodFactor:.5,polylineLodFactor:1,snapshotAvailable:!1,skipHighSymbolLods:!0},heatmap:{pixelRatio:.125},sceneService:{objectLoDFactor:.2,pointLoDFactor:1,meshLoDFactor:.6,pointCloudLoDFactor:.5},gaussianSplat:{minimumSplatPixelRadius:2,minimumOpacity:0,maxAllowedVisibleGaussians:4e6},flow:{maxTotalNumberOfStreamlines:25e3,maxTracingResolution:1024},tiledSurface:{lodBias:-1,angledSplitBias:.5,vtlContentZoom:.75,elevationLevelDelta:3,reduceTileLevelDifferences:!0},fadeDuration:e(0),physicallyBasedRenderingEnabled:!1,maxTexturePixels:a?1048576:4194304,memoryLimit:200+l.IPhone12Pro,additionalCacheMemory:0,frameRate:0,maximumPixelRatio:1},medium:{graphics3D:{maxTotalNumberOfFeatures:15e4,maxNumberOfDrawCalls:17e3,maxTotalNumberOfVertices:625e4,polygonLodFactor:a?.8:1,polylineLodFactor:a?1.2:1.5,snapshotAvailable:!i,skipHighSymbolLods:!1},heatmap:{pixelRatio:.25},sceneService:{objectLoDFactor:1,pointLoDFactor:1,meshLoDFactor:1,pointCloudLoDFactor:1},gaussianSplat:{minimumSplatPixelRadius:1,minimumOpacity:1,maxAllowedVisibleGaussians:8e6},flow:{maxTotalNumberOfStreamlines:1e5,maxTracingResolution:2048},tiledSurface:{lodBias:0,angledSplitBias:1,vtlContentZoom:1.5,elevationLevelDelta:3,reduceTileLevelDifferences:!has("disable-feature:reduce-map-tile-levels")},fadeDuration:o,physicallyBasedRenderingEnabled:!0,maxTexturePixels:a?4194304:4096**2,memoryLimit:a?600+l.GalaxyS20:750+l.FullHD,additionalCacheMemory:a?-100:150,frameRate:0,maximumPixelRatio:1},high:{graphics3D:{maxTotalNumberOfFeatures:3e5,maxNumberOfDrawCalls:17e3,maxTotalNumberOfVertices:125e5,polygonLodFactor:a?1.2:2,polylineLodFactor:a?1.2:2,snapshotAvailable:!i,skipHighSymbolLods:!1},heatmap:{pixelRatio:.5},sceneService:{objectLoDFactor:1,pointLoDFactor:1,meshLoDFactor:1,pointCloudLoDFactor:1},gaussianSplat:{minimumSplatPixelRadius:.5,minimumOpacity:2,maxAllowedVisibleGaussians:16e6},flow:{maxTotalNumberOfStreamlines:1e5,maxTracingResolution:2048},tiledSurface:{lodBias:0,angledSplitBias:1,vtlContentZoom:1.5,elevationLevelDelta:2,reduceTileLevelDifferences:!has("disable-feature:reduce-map-tile-levels")},fadeDuration:o,physicallyBasedRenderingEnabled:!0,maxTexturePixels:a?4096**2:1/0,memoryLimit:a?900+l.SurfacePro7:1500+l.FullHDRetina,additionalCacheMemory:a?-150:0,frameRate:0,maximumPixelRatio:a?1:1/0}}}export{o as QualityProfileTest,i as getDefaultQualityProfileName,a as getQualityProfileSettings};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as t}from"tslib";import e from"../../../core/Accessor.js";import{Milliseconds as o}from"../../../core/time.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let r=class extends e{constructor(){super(...arguments),this.minTotalNumberOfFeatures=2e3,this.maxTotalNumberOfFeatures=5e4,this.maxNumberOfDrawCalls=17e3,this.maxTotalNumberOfVertices=17e5,this.snapshotAvailable=!0,this.polygonLodFactor=1,this.polylineLodFactor=1,this.skipHighSymbolLods=!1}};t([i()],r.prototype,"minTotalNumberOfFeatures",void 0),t([i()],r.prototype,"maxTotalNumberOfFeatures",void 0),t([i()],r.prototype,"maxNumberOfDrawCalls",void 0),t([i()],r.prototype,"maxTotalNumberOfVertices",void 0),t([i()],r.prototype,"snapshotAvailable",void 0),t([i()],r.prototype,"polygonLodFactor",void 0),t([i()],r.prototype,"polylineLodFactor",void 0),t([i()],r.prototype,"skipHighSymbolLods",void 0),r=t([s("esri.views.3d.support.QualitySettings.Graphics3DSettings")],r);let p=class{constructor(){this.minimumSplatPixelRadius=1,this.minimumOpacity=.05,this.maxAllowedVisibleGaussians=8e6}};t([i()],p.prototype,"minimumSplatPixelRadius",void 0),t([i()],p.prototype,"minimumOpacity",void 0),t([i()],p.prototype,"maxAllowedVisibleGaussians",void 0),p=t([s("esri.views.3d.support.QualitySettings.GaussianSplatSettings")],p);let a=class extends e{constructor(){super(...arguments),this.lodFactor=1}};t([i()],a.prototype,"lodFactor",void 0),a=t([s("esri.views.3d.support.QualitySettings.LoDFactorSettings")],a);let l=class extends e{constructor(){super(...arguments),this.object=new a,this.point=new a,this.integratedMesh=new a,this.pointCloud=new a}};t([i({type:a})],l.prototype,"object",void 0),t([i({type:a})],l.prototype,"point",void 0),t([i({type:a})],l.prototype,"integratedMesh",void 0),t([i({type:a})],l.prototype,"pointCloud",void 0),l=t([s("esri.views.3d.support.QualitySettings.SceneServiceSettings")],l);let n=class extends e{constructor(){super(...arguments),this.lodBias=0,this.angledSplitBias=1,this.vtlContentZoom=1,this.elevationLevelDelta=3,this.reduceTileLevelDifferences=!0}};t([i()],n.prototype,"lodBias",void 0),t([i()],n.prototype,"angledSplitBias",void 0),t([i()],n.prototype,"vtlContentZoom",void 0),t([i()],n.prototype,"elevationLevelDelta",void 0),t([i()],n.prototype,"reduceTileLevelDifferences",void 0),n=t([s("esri.views.3d.support.QualitySettings.TiledSurfaceSettings")],n);let d=class extends e{constructor(){super(...arguments),this.pixelRatio=1}};t([i()],d.prototype,"pixelRatio",void 0),d=t([s("esri.views.3d.support.QualitySettings.HeatmapSettings")],d);let c=class extends e{constructor(){super(...arguments),this.graphics3D=new r,this.sceneService=new l,this.tiledSurface=new n,this.gaussianSplat=new p,this.heatmap=new d,this.fadeDuration=o(400),this.antialiasingEnabled=!0,this.physicallyBasedRenderingEnabled=!1,this.highQualityTransparency=!0,this.highResolutionAtmosphere=!1,this.reflections=!1,this.ambientOcclusion=!1,this.glow=!1,this.maxTexturePixels=1/0,this.memoryLimit=750,this.additionalCacheMemory=0,this.frameRate=void 0,this.maximumPixelRatio=1/0}};t([i({type:r})],c.prototype,"graphics3D",void 0),t([i({type:l})],c.prototype,"sceneService",void 0),t([i({type:n})],c.prototype,"tiledSurface",void 0),t([i({type:p})],c.prototype,"gaussianSplat",void 0),t([i({type:d})],c.prototype,"heatmap",void 0),t([i()],c.prototype,"fadeDuration",void 0),t([i()],c.prototype,"antialiasingEnabled",void 0),t([i()],c.prototype,"physicallyBasedRenderingEnabled",void 0),t([i()],c.prototype,"highQualityTransparency",void 0),t([i()],c.prototype,"highResolutionAtmosphere",void 0),t([i()],c.prototype,"reflections",void 0),t([i()],c.prototype,"ambientOcclusion",void 0),t([i()],c.prototype,"glow",void 0),t([i()],c.prototype,"maxTexturePixels",void 0),t([i()],c.prototype,"memoryLimit",void 0),t([i()],c.prototype,"additionalCacheMemory",void 0),t([i()],c.prototype,"frameRate",void 0),t([i()],c.prototype,"maximumPixelRatio",void 0),c=t([s("esri.views.3d.support.QualitySettings")],c);const y=c;export{y as default};
5
+ import{__decorate as t}from"tslib";import o from"../../../core/Accessor.js";import{Milliseconds as e}from"../../../core/time.js";import{property as i}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";let r=class extends o{constructor(t={}){super(t),this.minTotalNumberOfFeatures=2e3,this.maxTotalNumberOfFeatures=5e4,this.maxNumberOfDrawCalls=17e3,this.maxTotalNumberOfVertices=17e5,this.snapshotAvailable=!0,this.polygonLodFactor=1,this.polylineLodFactor=1,this.skipHighSymbolLods=!1}};t([i()],r.prototype,"maxTotalNumberOfFeatures",void 0),t([i()],r.prototype,"maxNumberOfDrawCalls",void 0),t([i()],r.prototype,"maxTotalNumberOfVertices",void 0),t([i()],r.prototype,"snapshotAvailable",void 0),t([i()],r.prototype,"polygonLodFactor",void 0),t([i()],r.prototype,"polylineLodFactor",void 0),t([i()],r.prototype,"skipHighSymbolLods",void 0),r=t([s("esri.views.3d.support.QualitySettings.Graphics3DSettings")],r);let p=class extends o{constructor(t={}){super(t),this.objectLoDFactor=1,this.pointLoDFactor=1,this.meshLoDFactor=1,this.pointCloudLoDFactor=1}};t([i()],p.prototype,"objectLoDFactor",void 0),t([i()],p.prototype,"pointLoDFactor",void 0),t([i()],p.prototype,"meshLoDFactor",void 0),t([i()],p.prototype,"pointCloudLoDFactor",void 0),p=t([s("esri.views.3d.support.QualitySettings.SceneServiceSettings")],p);let a=class extends o{constructor(t={}){super(t),this.lodBias=0,this.angledSplitBias=1,this.vtlContentZoom=1,this.elevationLevelDelta=3,this.reduceTileLevelDifferences=!0}};t([i()],a.prototype,"lodBias",void 0),t([i()],a.prototype,"angledSplitBias",void 0),t([i()],a.prototype,"vtlContentZoom",void 0),t([i()],a.prototype,"elevationLevelDelta",void 0),t([i()],a.prototype,"reduceTileLevelDifferences",void 0),a=t([s("esri.views.3d.support.QualitySettings.TiledSurfaceSettings")],a);let l=class extends o{constructor(t={}){super(t),this.minimumSplatPixelRadius=1,this.minimumOpacity=1,this.maxAllowedVisibleGaussians=8e6}};t([i()],l.prototype,"minimumSplatPixelRadius",void 0),t([i()],l.prototype,"minimumOpacity",void 0),t([i()],l.prototype,"maxAllowedVisibleGaussians",void 0),l=t([s("esri.views.3d.support.QualitySettings.GaussianSplatSettings")],l);let d=class extends o{constructor(t={}){super(t),this.pixelRatio=1}};t([i()],d.prototype,"pixelRatio",void 0),d=t([s("esri.views.3d.support.QualitySettings.HeatmapSettings")],d);let n=class extends o{constructor(){super(...arguments),this.maxTotalNumberOfStreamlines=1e5,this.maxTracingResolution=2048}};t([i()],n.prototype,"maxTotalNumberOfStreamlines",void 0),t([i()],n.prototype,"maxTracingResolution",void 0),n=t([s("esri.views.3d.support.QualitySettings.FlowSettings")],n);let c=class extends o{constructor(t){super(t),this.graphics3D=new r,this.sceneService=new p,this.tiledSurface=new a,this.gaussianSplat=new l,this.heatmap=new d,this.flow=new n,this.fadeDuration=e(400),this.physicallyBasedRenderingEnabled=!1,this.glow=!1,this.maxTexturePixels=1/0,this.memoryLimit=750,this.additionalCacheMemory=0,this.frameRate=0,this.maximumPixelRatio=1/0}};t([i({type:r})],c.prototype,"graphics3D",void 0),t([i({type:p})],c.prototype,"sceneService",void 0),t([i({type:a})],c.prototype,"tiledSurface",void 0),t([i({type:l})],c.prototype,"gaussianSplat",void 0),t([i({type:d})],c.prototype,"heatmap",void 0),t([i({type:n})],c.prototype,"flow",void 0),t([i()],c.prototype,"fadeDuration",void 0),t([i()],c.prototype,"physicallyBasedRenderingEnabled",void 0),t([i()],c.prototype,"glow",void 0),t([i()],c.prototype,"maxTexturePixels",void 0),t([i()],c.prototype,"memoryLimit",void 0),t([i()],c.prototype,"additionalCacheMemory",void 0),t([i()],c.prototype,"frameRate",void 0),t([i()],c.prototype,"maximumPixelRatio",void 0),c=t([s("esri.views.3d.support.QualitySettings")],c);const m=c;export{m as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../request.js";import{throwIfAborted as t,whenOrAbort as r}from"../../../core/promiseUtils.js";import{isSVG as s}from"../../../core/urlUtils.js";import{queueAutoPriority as i}from"../../../request/queue.js";import{TextureCollection as o,TextureRequest as n,TextureHandle as l}from"./TextureCollection.js";import{Texture as h}from"../webgl-engine/lib/Texture.js";class a extends o{constructor(e,t){super(e,t)}async fromUrl(s,o,h){t(h);const a=h?.signal,u=this.makeUid(s,o);let c=this._textureRequests.get(u);if(!c){const t=new AbortController,r={...i,responseType:"image",signal:t.signal},h=e(s,r);c=new n,c.abortController=t;const a=c;this._textureRequests.set(u,c),c.textureAsync=h.then(async({data:e})=>{const t=this._createTexture(s,e,o);return a.texture=t,a.abortController=null,await t.load(this._stage.renderView.renderingContext),this._stage.addTexture(t),new l(u,t,()=>this._release(u))},e=>{throw a.abortController=null,e})}c.referenceCount++;try{return await r(c.textureAsync,a)}catch(d){throw this._release(u),d}}_createTexture(e,t,r){const i={width:t.width,height:t.height,wrap:{s:33071,t:33071},preMultiplyAlpha:!0,reloadable:!0};if(s(e)){if(r||0===t.width&&0===t.height){const e=t.width?t.height/t.width:1;r=r||64,e>1?(t.width=Math.round(r/e),t.height=r):(t.width=r,t.height=Math.round(r*e))}this._stage.renderView?.renderingContext.driverTest.svgPremultipliesAlpha.result&&(i.preMultiplyAlpha=!1)}return new h(t,i)}}export{a as StreamTextureCollection};
5
+ import e from"../../../request.js";import{throwIfAborted as t,whenOrAbort as r}from"../../../core/promiseUtils.js";import{isSVG as s}from"../../../core/urlUtils.js";import{queueAutoPriority as i}from"../../../request/queue.js";import{TextureCollection as o,TextureRequest as n,TextureHandle as l}from"./TextureCollection.js";import{ManagedTexture as a}from"../webgl-engine/lib/ManagedTexture.js";class h extends o{constructor(e,t){super(e,t)}async fromUrl(s,o,a){t(a);const h=a?.signal,u=this.makeUid(s,o);let d=this._textureRequests.get(u);if(!d){const t=new AbortController,r={...i,responseType:"image",signal:t.signal},a=e(s,r);d=new n,d.abortController=t;const h=d;this._textureRequests.set(u,d),d.textureAsync=a.then(async({data:e})=>{const t=this._createTexture(s,e,o);return h.texture=t,h.abortController=null,await t.load(this._stage.renderView.renderingContext),this._stage.addTexture(t),new l(u,t,()=>this._release(u))},e=>{throw h.abortController=null,e})}d.referenceCount++;try{return await r(d.textureAsync,h)}catch(c){throw this._release(u),c}}_createTexture(e,t,r){const i={width:t.width,height:t.height,wrap:{s:33071,t:33071},preMultiplyAlpha:!0,reloadable:!0};if(s(e)){if(r||0===t.width&&0===t.height){const e=t.width?t.height/t.width:1;r=r||64,e>1?(t.width=Math.round(r/e),t.height=r):(t.width=r,t.height=Math.round(r*e))}this._stage.renderView?.renderingContext.driverTest.svgPremultipliesAlpha.result&&(i.preMultiplyAlpha=!1)}return new a(t,i)}}export{h as StreamTextureCollection};
@@ -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"../../../core/has.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{ImmediateTask as o,TaskPriority as u}from"../../support/Scheduler.js";let i=class extends t{constructor(e,t){super({}),this._stage=e,this._textureRequests=new Map,this._frameTask=t?.registerTask(u.TEXTURE_UNLOAD)??o}normalizeCtorArgs(){return{}}destroy(){super.destroy(),this._frameTask?.remove(),this._textureRequests?.forEach(e=>this._releaseTextureRequest(e)),this._textureRequests?.clear()}get updating(){return this._frameTask.updating}fromData(e,t){const r=this.makeUid(e);let s=this._textureRequests.get(r);if(!s){const e=new a;e.texture=t(),this._stage&&(e.texture.load(this._stage.renderView.renderingContext),this._stage.addTexture(e.texture)),this._textureRequests.set(r,e),s=e}return s.referenceCount++,new n(r,s.texture,()=>this._release(r))}_release(e){const t=this._textureRequests.get(e);t?(t.referenceCount<1&&console.warn("TextureCollection: reference count is < 1 for "+e),t.referenceCount--,t.referenceCount<1&&this._frameTask.schedule(()=>this._releaseNow(e))):console.warn(`TextureCollection: texture doesn't exist: '${e}'`)}get test(){}_releaseNow(e){if(!this._textureRequests)return;const t=this._textureRequests.get(e);!t||t.referenceCount>0||(t.texture?.unload(),this._releaseTextureRequest(t),this._textureRequests.delete(e))}_releaseTextureRequest(e){e.texture?this._stage?.removeTexture(e.texture):e.abortController&&(e.abortController.abort(),e.abortController=null)}makeUid(e,t=null){return null!=t?`${e}.${t}px`:e}};e([r()],i.prototype,"_frameTask",void 0),e([r()],i.prototype,"updating",null),i=e([s("esri.views.3d.support.TextureCollection")],i);class n{constructor(e,t,r){this.uid=e,this.texture=t,this.release=r}}class a{constructor(){this.referenceCount=0}}export{i as TextureCollection,n as TextureHandle,a as TextureRequest};
5
+ import{__decorate as e}from"tslib";import t from"../../../core/Accessor.js";import"../../../core/has.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import{ImmediateTask as o,TaskPriority as u}from"../../support/Scheduler.js";let a=class extends t{constructor(e,t){super({}),this._stage=e,this._textureRequests=new Map,this._frameTask=t?.registerTask(u.TEXTURE_UNLOAD)??o}normalizeCtorArgs(){return{}}destroy(){super.destroy(),this._frameTask?.remove(),this._textureRequests?.forEach(e=>this._releaseTextureRequest(e)),this._textureRequests?.clear()}get updating(){return this._frameTask.updating}fromData(e,t){const r=this.makeUid(e);let s=this._textureRequests.get(r);if(!s){const e=new n;e.texture=t(),this._stage&&(e.texture.load(this._stage.renderView.renderingContext),this._stage.addTexture(e.texture)),this._textureRequests.set(r,e),s=e}return s.referenceCount++,new i(r,s.texture,()=>this._release(r))}_release(e){const t=this._textureRequests.get(e);t?(t.referenceCount<1&&console.warn("TextureCollection: reference count is < 1 for "+e),t.referenceCount--,t.referenceCount<1&&this._frameTask.schedule(()=>this._releaseNow(e))):console.warn(`TextureCollection: texture doesn't exist: '${e}'`)}get test(){}_releaseNow(e){if(!this._textureRequests)return;const t=this._textureRequests.get(e);!t||t.referenceCount>0||(t.texture?.unload(),this._releaseTextureRequest(t),this._textureRequests.delete(e))}_releaseTextureRequest(e){e.texture?this._stage?.removeTexture(e.texture):e.abortController&&(e.abortController.abort(),e.abortController=null)}makeUid(e,t=null){return null!=t?`${e}.${t}px`:e}};e([r()],a.prototype,"_frameTask",void 0),e([r()],a.prototype,"updating",null),a=e([s("esri.views.3d.support.TextureCollection")],a);class i{constructor(e,t,r){this.uid=e,this.managedTexture=t,this.release=r}}class n{constructor(){this.referenceCount=0}}export{a as TextureCollection,i as TextureHandle,n as TextureRequest};