@arcgis/core 4.31.0-next.20240620 → 4.31.0-next.20240621

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 (146) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{3a74d3fc690177a703f5.js → 019ce38b02e3bf517125.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{222807cfaa2e17d0efea.js → 6745cedf6f82c8917904.js} +1 -1
  4. package/assets/esri/core/workers/chunks/7b6cd976367a0dd297d6.js +1 -0
  5. package/assets/esri/core/workers/chunks/{8a948d46d0377a6adb86.js → 9d677af08238d9e09e72.js} +2 -2
  6. package/assets/esri/core/workers/chunks/bedf60888f07b78b314d.js +1 -0
  7. package/assets/esri/core/workers/chunks/c39237c00c1d588dc107.js +1 -0
  8. package/assets/esri/core/workers/chunks/de7fa31d86a65ccdffc1.js +1 -0
  9. package/assets/esri/core/workers/chunks/{8ee8f3c54b2cce217845.js → f13fb6b712e364bbf48c.js} +1 -1
  10. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ar.json +1 -1
  11. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_bg.json +1 -1
  12. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_bs.json +1 -1
  13. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ca.json +1 -1
  14. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_cs.json +1 -1
  15. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_da.json +1 -1
  16. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_de.json +1 -1
  17. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_el.json +1 -1
  18. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_es.json +1 -1
  19. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_et.json +1 -1
  20. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_fi.json +1 -1
  21. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_fr.json +1 -1
  22. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_he.json +1 -1
  23. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_hr.json +1 -1
  24. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_hu.json +1 -1
  25. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_id.json +1 -1
  26. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_it.json +1 -1
  27. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ja.json +1 -1
  28. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ko.json +1 -1
  29. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_lt.json +1 -1
  30. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_lv.json +1 -1
  31. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_nb.json +1 -1
  32. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_nl.json +1 -1
  33. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_pl.json +1 -1
  34. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_pt-BR.json +1 -1
  35. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_pt-PT.json +1 -1
  36. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ro.json +1 -1
  37. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_ru.json +1 -1
  38. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_sk.json +1 -1
  39. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_sl.json +1 -1
  40. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_sr.json +1 -1
  41. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_sv.json +1 -1
  42. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_th.json +1 -1
  43. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_tr.json +1 -1
  44. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_uk.json +1 -1
  45. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_vi.json +1 -1
  46. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_zh-CN.json +1 -1
  47. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_zh-HK.json +1 -1
  48. package/assets/esri/widgets/CatalogLayerList/t9n/CatalogLayerList_zh-TW.json +1 -1
  49. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ar.json +1 -1
  50. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bg.json +1 -1
  51. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_bs.json +1 -1
  52. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ca.json +1 -1
  53. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_cs.json +1 -1
  54. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_da.json +1 -1
  55. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_de.json +1 -1
  56. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_el.json +1 -1
  57. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_es.json +1 -1
  58. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_et.json +1 -1
  59. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fi.json +1 -1
  60. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_fr.json +1 -1
  61. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_he.json +1 -1
  62. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hr.json +1 -1
  63. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_hu.json +1 -1
  64. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_id.json +1 -1
  65. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_it.json +1 -1
  66. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ja.json +1 -1
  67. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ko.json +1 -1
  68. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lt.json +1 -1
  69. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_lv.json +1 -1
  70. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nb.json +1 -1
  71. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_nl.json +1 -1
  72. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pl.json +1 -1
  73. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-BR.json +1 -1
  74. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_pt-PT.json +1 -1
  75. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ro.json +1 -1
  76. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_ru.json +1 -1
  77. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sk.json +1 -1
  78. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sl.json +1 -1
  79. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sr.json +1 -1
  80. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_sv.json +1 -1
  81. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_th.json +1 -1
  82. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_tr.json +1 -1
  83. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_uk.json +1 -1
  84. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_vi.json +1 -1
  85. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-CN.json +1 -1
  86. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-HK.json +1 -1
  87. package/assets/esri/widgets/FeatureTable/t9n/FeatureTable_zh-TW.json +1 -1
  88. package/chunks/CheckerBoard.glsl.js +9 -6
  89. package/chunks/ComponentShader.glsl.js +4 -4
  90. package/chunks/ImageMaterial.glsl.js +1 -2
  91. package/interfaces.d.ts +50 -14
  92. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  93. package/layers/mixins/EditBusLayer.js +1 -1
  94. package/layers/mixins/FeatureLayerBase.js +1 -1
  95. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  96. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  97. package/layers/support/featureLayerUtils.js +1 -1
  98. package/package.json +1 -1
  99. package/portal/schemas/definitions.js +1 -1
  100. package/rest/knowledgeGraph/wasmInterface/WasmDataModelWrapperInterfaces.js +1 -1
  101. package/support/revision.js +1 -1
  102. package/views/2d/layers/support/ExportStrategy.js +1 -1
  103. package/views/3d/layers/I3SMeshView3D.js +1 -1
  104. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  105. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  106. package/views/3d/layers/graphics/Graphics3DObject3DGraphicLayer.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  108. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  109. package/views/3d/webgl-engine/collections/Component/Material/shader/ComponentData.glsl.js +1 -2
  110. package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
  111. package/views/3d/webgl-engine/lib/Material.js +1 -1
  112. package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
  113. package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
  114. package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
  115. package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
  116. package/views/3d/webgl-engine/lib/edgeRendering/interfaces.js +1 -1
  117. package/views/3d/webgl-engine/lib/edgeRendering/util.js +1 -1
  118. package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
  119. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  120. package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
  121. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  122. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  123. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  124. package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
  125. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  126. package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
  127. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  128. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  129. package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
  130. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  131. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  132. package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
  133. package/views/3d/webgl-engine/shaders/CheckerBoard.glsl.js +1 -1
  134. package/views/SelectionManager.js +1 -1
  135. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  136. package/widgets/OrientedImageryViewer/adapters/OrientedImageryViewerViewModelAdapter2D.js +1 -1
  137. package/widgets/OrientedImageryViewer/utils.js +1 -1
  138. package/widgets/OrientedImageryViewer.js +1 -1
  139. package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
  140. package/widgets/PanoramicViewer/constants.js +1 -1
  141. package/widgets/PanoramicViewer/utils.js +1 -1
  142. package/widgets/Print.js +1 -1
  143. package/assets/esri/core/workers/chunks/4f2be9fd4ff5b3ad3110.js +0 -1
  144. package/assets/esri/core/workers/chunks/88c7d84a1fde246ca71f.js +0 -1
  145. package/assets/esri/core/workers/chunks/986520dd0de64105dbff.js +0 -1
  146. package/assets/esri/core/workers/chunks/ad0a87dba95785ad6171.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- var e,r,i,t,o,s,y;!function(e){e[e.Regular=0]="Regular",e[e.Provenance=1]="Provenance",e[e.Document=2]="Document"}(e||(e={})),function(e){e[e.esriFieldTypeSmallInteger=0]="esriFieldTypeSmallInteger",e[e.esriFieldTypeInteger=1]="esriFieldTypeInteger",e[e.esriFieldTypeSingle=2]="esriFieldTypeSingle",e[e.esriFieldTypeDouble=3]="esriFieldTypeDouble",e[e.esriFieldTypeString=4]="esriFieldTypeString",e[e.esriFieldTypeDate=5]="esriFieldTypeDate",e[e.esriFieldTypeOID=6]="esriFieldTypeOID",e[e.esriFieldTypeGeometry=7]="esriFieldTypeGeometry",e[e.esriFieldTypeBlob=8]="esriFieldTypeBlob",e[e.esriFieldTypeRaster=9]="esriFieldTypeRaster",e[e.esriFieldTypeGUID=10]="esriFieldTypeGUID",e[e.esriFieldTypeGlobalID=11]="esriFieldTypeGlobalID",e[e.esriFieldTypeXML=12]="esriFieldTypeXML",e[e.esriFieldTypeBigInteger=13]="esriFieldTypeBigInteger",e[e.esriFieldTypeDateOnly=14]="esriFieldTypeDateOnly",e[e.esriFieldTypeTimeOnly=15]="esriFieldTypeTimeOnly",e[e.esriFieldTypeTimestampOffset=16]="esriFieldTypeTimestampOffset"}(r||(r={})),function(e){e[e.esriGeometryNull=0]="esriGeometryNull",e[e.esriGeometryPoint=1]="esriGeometryPoint",e[e.esriGeometryMultipoint=2]="esriGeometryMultipoint",e[e.esriGeometryPolyline=3]="esriGeometryPolyline",e[e.esriGeometryPolygon=4]="esriGeometryPolygon",e[e.esriGeometryEnvelope=5]="esriGeometryEnvelope",e[e.esriGeometryAny=6]="esriGeometryAny",e[e.esriGeometryMultiPatch=7]="esriGeometryMultiPatch"}(i||(i={})),function(e){e[e.esriMethodHintUNSPECIFIED=0]="esriMethodHintUNSPECIFIED",e[e.esriUUIDESRI=1]="esriUUIDESRI",e[e.esriUUIDRFC4122=2]="esriUUIDRFC4122"}(t||(t={})),function(e){e[e.esriTypeUNSPECIFIED=0]="esriTypeUNSPECIFIED",e[e.esriTypeEntity=1]="esriTypeEntity",e[e.esriTypeRelationship=2]="esriTypeRelationship",e[e.esriTypeBoth=4]="esriTypeBoth"}(o||(o={})),function(e){e[e.esriGraphPropertyUNSPECIFIED=0]="esriGraphPropertyUNSPECIFIED",e[e.esriGraphPropertyRegular=1]="esriGraphPropertyRegular",e[e.esriGraphPropertyDocumentName=2]="esriGraphPropertyDocumentName",e[e.esriGraphPropertyDocumentTitle=3]="esriGraphPropertyDocumentTitle",e[e.esriGraphPropertyDocumentUrl=4]="esriGraphPropertyDocumentUrl",e[e.esriGraphPropertyDocumentText=5]="esriGraphPropertyDocumentText",e[e.esriGraphPropertyDocumentKeywords=6]="esriGraphPropertyDocumentKeywords",e[e.esriGraphPropertyDocumentContentType=7]="esriGraphPropertyDocumentContentType",e[e.esriGraphPropertyDocumentMetadata=8]="esriGraphPropertyDocumentMetadata",e[e.esriGraphPropertyDocumentFileExtension=9]="esriGraphPropertyDocumentFileExtension"}(s||(s={})),function(e){e[e.esriIdentifierInfoTypeUNSPECIFIED=0]="esriIdentifierInfoTypeUNSPECIFIED",e[e.esriIdentifierInfoTypeDatabaseNative=1]="esriIdentifierInfoTypeDatabaseNative",e[e.esriIdentifierInfoTypeUniformProperty=2]="esriIdentifierInfoTypeUniformProperty"}(y||(y={}));export{r as EsriFieldTypes,i as EsriGeometryTypes,s as EsriGraphPropertyRole,y as EsriIdentifierInfoType,o as EsriNamedTypeCategory,t as EsriUuidMethodHintTypes,e as NamedObjectTypes};
5
+ var e,r,i,t,o,p,n;!function(e){e[e.Regular=0]="Regular",e[e.Provenance=1]="Provenance",e[e.Document=2]="Document"}(e||(e={})),function(e){e[e.esriFieldTypeSmallInteger=0]="esriFieldTypeSmallInteger",e[e.esriFieldTypeInteger=1]="esriFieldTypeInteger",e[e.esriFieldTypeSingle=2]="esriFieldTypeSingle",e[e.esriFieldTypeDouble=3]="esriFieldTypeDouble",e[e.esriFieldTypeString=4]="esriFieldTypeString",e[e.esriFieldTypeDate=5]="esriFieldTypeDate",e[e.esriFieldTypeOID=6]="esriFieldTypeOID",e[e.esriFieldTypeGeometry=7]="esriFieldTypeGeometry",e[e.esriFieldTypeBlob=8]="esriFieldTypeBlob",e[e.esriFieldTypeRaster=9]="esriFieldTypeRaster",e[e.esriFieldTypeGUID=10]="esriFieldTypeGUID",e[e.esriFieldTypeGlobalID=11]="esriFieldTypeGlobalID",e[e.esriFieldTypeXML=12]="esriFieldTypeXML",e[e.esriFieldTypeBigInteger=13]="esriFieldTypeBigInteger",e[e.esriFieldTypeDateOnly=14]="esriFieldTypeDateOnly",e[e.esriFieldTypeTimeOnly=15]="esriFieldTypeTimeOnly",e[e.esriFieldTypeTimestampOffset=16]="esriFieldTypeTimestampOffset"}(r||(r={})),function(e){e[e.esriGeometryNull=0]="esriGeometryNull",e[e.esriGeometryPoint=1]="esriGeometryPoint",e[e.esriGeometryMultipoint=2]="esriGeometryMultipoint",e[e.esriGeometryPolyline=3]="esriGeometryPolyline",e[e.esriGeometryPolygon=4]="esriGeometryPolygon",e[e.esriGeometryEnvelope=5]="esriGeometryEnvelope",e[e.esriGeometryAny=6]="esriGeometryAny",e[e.esriGeometryMultiPatch=7]="esriGeometryMultiPatch"}(i||(i={})),function(e){e[e.esriMethodHintUNSPECIFIED=0]="esriMethodHintUNSPECIFIED",e[e.esriUUIDESRI=1]="esriUUIDESRI",e[e.esriUUIDRFC4122=2]="esriUUIDRFC4122"}(t||(t={})),function(e){e[e.esriTypeUNSPECIFIED=0]="esriTypeUNSPECIFIED",e[e.esriTypeEntity=1]="esriTypeEntity",e[e.esriTypeRelationship=2]="esriTypeRelationship",e[e.esriTypeBoth=4]="esriTypeBoth"}(o||(o={})),function(e){e[e.esriGraphPropertyUNSPECIFIED=0]="esriGraphPropertyUNSPECIFIED",e[e.esriGraphPropertyRegular=1]="esriGraphPropertyRegular",e[e.esriGraphPropertyDocumentName=2]="esriGraphPropertyDocumentName",e[e.esriGraphPropertyDocumentTitle=3]="esriGraphPropertyDocumentTitle",e[e.esriGraphPropertyDocumentUrl=4]="esriGraphPropertyDocumentUrl",e[e.esriGraphPropertyDocumentText=5]="esriGraphPropertyDocumentText",e[e.esriGraphPropertyDocumentKeywords=6]="esriGraphPropertyDocumentKeywords",e[e.esriGraphPropertyDocumentContentType=7]="esriGraphPropertyDocumentContentType",e[e.esriGraphPropertyDocumentMetadata=8]="esriGraphPropertyDocumentMetadata",e[e.esriGraphPropertyDocumentFileExtension=9]="esriGraphPropertyDocumentFileExtension",e[e.esriGraphPropertyProvenanceInstanceId=10]="esriGraphPropertyProvenanceInstanceId",e[e.esriGraphPropertyProvenanceSourceType=11]="esriGraphPropertyProvenanceSourceType",e[e.esriGraphPropertyProvenanceSourceName=12]="esriGraphPropertyProvenanceSourceName",e[e.esriGraphPropertyProvenanceSource=13]="esriGraphPropertyProvenanceSource",e[e.esriGraphPropertyProvenanceComment=14]="esriGraphPropertyProvenanceComment",e[e.esriGraphPropertyProvenanceTypeName=15]="esriGraphPropertyProvenanceTypeName",e[e.esriGraphPropertyProvenancePropertyName=16]="esriGraphPropertyProvenancePropertyName"}(p||(p={})),function(e){e[e.esriIdentifierInfoTypeUNSPECIFIED=0]="esriIdentifierInfoTypeUNSPECIFIED",e[e.esriIdentifierInfoTypeDatabaseNative=1]="esriIdentifierInfoTypeDatabaseNative",e[e.esriIdentifierInfoTypeUniformProperty=2]="esriIdentifierInfoTypeUniformProperty"}(n||(n={}));export{r as EsriFieldTypes,i as EsriGeometryTypes,p as EsriGraphPropertyRole,n as EsriIdentifierInfoType,o as EsriNamedTypeCategory,t as EsriUuidMethodHintTypes,e as NamedObjectTypes};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- const e="20240620",a="1e52b1c629a8a1a78773e734fa91ae74b9b2e5ee";export{e as buildDate,a as commitHash};
5
+ const c="20240621",b="34bec609c106be204d2845f20d2636c0881b469c";export{c as buildDate,b as commitHash};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{debounce as i,throwIfAborted as o,throwIfAbortError as r,eachAlways as s}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p,toExtent as m}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as l}from"../../../../geometry/support/spatialReferenceUtils.js";import h from"../../../../layers/support/TileInfo.js";import{getOuterSize as d,getBBox as c}from"../../viewStateUtils.js";import{Bitmap as u}from"../../engine/Bitmap.js";import g from"../../tiling/TileInfoView.js";import f from"../../tiling/TileKey.js";const y=p(),x=[0,0],S=new f(0,0,0,0),_={container:null,fetchSource:null,requestUpdate:null,imageMaxWidth:2048,imageMaxHeight:2048,imageRotationSupported:!1,imageNormalizationSupported:!1,hidpi:!1};let v=class extends e{constructor(t){super(t),this._imagePromise=null,this.bitmaps=[],this.hidpi=_.hidpi,this.imageMaxWidth=_.imageMaxWidth,this.imageMaxHeight=_.imageMaxHeight,this.imageRotationSupported=_.imageRotationSupported,this.imageNormalizationSupported=_.imageNormalizationSupported,this.update=i((async(t,e)=>{if(o(e),!t.stationary||this.destroyed)return;const i=t.state,s=l(i.spatialReference),a=this.hidpi?t.pixelRatio:1,n=this.imageNormalizationSupported&&i.worldScreenWidth&&i.worldScreenWidth<i.size[0],p=Math.round((this.imageMaxWidth??0)/a),m=Math.round((this.imageMaxHeight??0)/a);n?(x[0]=i.worldScreenWidth,x[1]=i.size[1]):this.imageRotationSupported?(x[0]=i.size[0],x[1]=i.size[1]):d(x,i);const h=Math.floor(x[0])>p||Math.floor(x[1])>m,c=s&&(i.extent.xmin<s.valid[0]||i.extent.xmax>s.valid[1]),u=!this.imageNormalizationSupported&&c,g=!h&&!u,f=this.imageRotationSupported?i.rotation:0,y=this.container.children.slice();if(g){const t=n?i.paddedViewState.center:i.center;this._imagePromise=this._singleExport(i,x,t,i.resolution,f,a,e)}else{let t=Math.min(p,m);t=Math.min(i.worldScreenWidth,t),this._imagePromise=this._tiledExport(i,t,a,e)}try{const t=await this._imagePromise??[];o(e);const i=[];if(this._imagePromise=null,this.destroyed)return;this.bitmaps=t;for(const e of y)t.includes(e)||i.push(e.fadeOut().then((()=>{e.remove(),e.destroy()})));for(const e of t)i.push(e.fadeIn());await Promise.all(i)}catch(S){this._imagePromise=null,r(S)}}),5e3),this.updateExports=i((async t=>{const e=[];for(const i of this.container.children){if(!i.visible||!i.stage)return;e.push(t(i).then((()=>{i.invalidateTexture(),i.requestRender()})))}this._imagePromise=s(e).then((()=>this._imagePromise=null)),await this._imagePromise}))}destroy(){this.bitmaps.forEach((t=>t.destroy())),this.bitmaps=[]}get updating(){return!this.destroyed&&null!==this._imagePromise}async _export(t,e,i,r,s,a){const n=await this.fetchSource(t,Math.floor(e*s),Math.floor(i*s),{rotation:r,pixelRatio:s,signal:a});o(a);const p=new u(null,!0);return p.x=t.xmin,p.y=t.ymax,p.resolution=t.width/e,p.rotation=r,p.pixelRatio=s,p.opacity=0,this.container.addChild(p),await p.setSourceAsync(n,a),o(a),p}async _singleExport(t,e,i,o,r,s,a){c(y,i,o,e);const n=m(y,t.spatialReference);return[await this._export(n,e[0],e[1],r,s,a)]}_tiledExport(t,e,i,o){const r=h.create({size:e,spatialReference:t.spatialReference,scales:[t.scale]}),s=new g(r),a=s.getTileCoverage(t);if(!a)return null;const n=[];return a.forEach(((r,a,p,l)=>{S.set(r,a,p,0),s.getTileBounds(y,S);const h=m(y,t.spatialReference);n.push(this._export(h,e,e,0,i,o).then((t=>(0!==l&&(S.set(r,a,p,l),s.getTileBounds(y,S),t.x=y[0],t.y=y[3]),t))))})),Promise.all(n)}};t([a()],v.prototype,"_imagePromise",void 0),t([a()],v.prototype,"bitmaps",void 0),t([a()],v.prototype,"container",void 0),t([a()],v.prototype,"fetchSource",void 0),t([a()],v.prototype,"hidpi",void 0),t([a()],v.prototype,"imageMaxWidth",void 0),t([a()],v.prototype,"imageMaxHeight",void 0),t([a()],v.prototype,"imageRotationSupported",void 0),t([a()],v.prototype,"imageNormalizationSupported",void 0),t([a()],v.prototype,"requestUpdate",void 0),t([a()],v.prototype,"updating",null),v=t([n("esri.views.2d.layers.support.ExportStrategy")],v);const w=v;export{w as default};
5
+ import{_ as t}from"../../../../chunks/tslib.es6.js";import e from"../../../../core/Accessor.js";import"../../../../core/has.js";import{debounce as i,throwIfAborted as o,throwIfAbortError as r,eachAlways as s}from"../../../../core/promiseUtils.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/Logger.js";import"../../../../core/RandomLCG.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{create as p,toExtent as m}from"../../../../geometry/support/aaBoundingRect.js";import{getInfo as h}from"../../../../geometry/support/spatialReferenceUtils.js";import l from"../../../../layers/support/TileInfo.js";import{getOuterSize as d,getBBox as c}from"../../viewStateUtils.js";import{Bitmap as u}from"../../engine/Bitmap.js";import g from"../../tiling/TileInfoView.js";import f from"../../tiling/TileKey.js";const y=p(),x=[0,0],S=new f(0,0,0,0),w={container:null,fetchSource:null,requestUpdate:null,imageMaxWidth:2048,imageMaxHeight:2048,imageRotationSupported:!1,imageNormalizationSupported:!1,hidpi:!1};let M=class extends e{constructor(t){super(t),this._imagePromise=null,this.bitmaps=[],this.hidpi=w.hidpi,this.imageMaxWidth=w.imageMaxWidth,this.imageMaxHeight=w.imageMaxHeight,this.imageRotationSupported=w.imageRotationSupported,this.imageNormalizationSupported=w.imageNormalizationSupported,this.update=i((async(t,e)=>{if(o(e),!t.stationary||this.destroyed)return;const i=t.state,s=h(i.spatialReference),a=this.hidpi?t.pixelRatio:1,n=i.worldScreenWidth>0,p=n&&this.imageNormalizationSupported&&i.worldScreenWidth<i.size[0],m=Math.round((this.imageMaxWidth??0)/a),l=Math.round((this.imageMaxHeight??0)/a);p?(x[0]=i.worldScreenWidth,x[1]=i.size[1]):this.imageRotationSupported?(x[0]=i.size[0],x[1]=i.size[1]):d(x,i);const c=Math.floor(x[0])>m||Math.floor(x[1])>l,u=s&&(i.extent.xmin<s.valid[0]||i.extent.xmax>s.valid[1]),g=!this.imageNormalizationSupported&&u,f=!c&&!g,y=this.imageRotationSupported?i.rotation:0,S=this.container.children.slice();if(f){const t=p?i.paddedViewState.center:i.center;this._imagePromise=this._singleExport(i,x,t,i.resolution,y,a,e)}else{let t=Math.min(m,l);n&&(t=Math.min(i.worldScreenWidth,t),t=Math.round(i.worldScreenWidth/Math.ceil(i.worldScreenWidth/t))),this._imagePromise=this._tiledExport(i,t,a,e)}try{const t=await this._imagePromise??[];o(e);const i=[];if(this._imagePromise=null,this.destroyed)return;this.bitmaps=t;for(const e of S)t.includes(e)||i.push(e.fadeOut().then((()=>{e.remove(),e.destroy()})));for(const e of t)i.push(e.fadeIn());await Promise.all(i)}catch(w){this._imagePromise=null,r(w)}}),5e3),this.updateExports=i((async t=>{const e=[];for(const i of this.container.children){if(!i.visible||!i.stage)return;e.push(t(i).then((()=>{i.invalidateTexture(),i.requestRender()})))}this._imagePromise=s(e).then((()=>this._imagePromise=null)),await this._imagePromise}))}destroy(){this.bitmaps.forEach((t=>t.destroy())),this.bitmaps=[]}get updating(){return!this.destroyed&&null!==this._imagePromise}async _export(t,e,i,r,s,a){const n=await this.fetchSource(t,Math.floor(e*s),Math.floor(i*s),{rotation:r,pixelRatio:s,signal:a});o(a);const p=new u(null,!0);return p.x=t.xmin,p.y=t.ymax,p.resolution=t.width/e,p.rotation=r,p.pixelRatio=s,p.opacity=0,this.container.addChild(p),await p.setSourceAsync(n,a),o(a),p}async _singleExport(t,e,i,o,r,s,a){c(y,i,o,e);const n=m(y,t.spatialReference);return[await this._export(n,e[0],e[1],r,s,a)]}_tiledExport(t,e,i,o){const r=l.create({size:e,spatialReference:t.spatialReference,scales:[t.scale]}),s=new g(r),a=s.getTileCoverage(t);if(!a)return null;const n=[];return a.forEach(((r,a,p,h)=>{S.set(r,a,p,0),s.getTileBounds(y,S);const l=m(y,t.spatialReference);n.push(this._export(l,e,e,0,i,o).then((t=>(0!==h&&(S.set(r,a,p,h),s.getTileBounds(y,S),t.x=y[0],t.y=y[3]),t))))})),Promise.all(n)}};t([a()],M.prototype,"_imagePromise",void 0),t([a()],M.prototype,"bitmaps",void 0),t([a()],M.prototype,"container",void 0),t([a()],M.prototype,"fetchSource",void 0),t([a()],M.prototype,"hidpi",void 0),t([a()],M.prototype,"imageMaxWidth",void 0),t([a()],M.prototype,"imageMaxHeight",void 0),t([a()],M.prototype,"imageRotationSupported",void 0),t([a()],M.prototype,"imageNormalizationSupported",void 0),t([a()],M.prototype,"requestUpdate",void 0),t([a()],M.prototype,"updating",null),M=t([n("esri.views.2d.layers.support.ExportStrategy")],M);const _=M;export{_ as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import"../../../symbols.js";import{isSome as s,removeUnordered as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import n from"../../../core/Collection.js";import{makeHandle as a}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import l from"../../../core/Logger.js";import{destroyMaybe as d}from"../../../core/maybe.js";import h from"../../../core/PooledArray.js";import{ignoreAbortErrors as c,isAbortError as u,throwIfAborted as _,createResolver as g}from"../../../core/promiseUtils.js";import{initial as m,watch as p}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as I,invert as M}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as x,getTranslation as E}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as O,create as j}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as R,h as S,t as A,z as D,g as T,j as N,f as V,H as F}from"../../../chunks/vec32.js";import{create as P}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as H}from"../../../chunks/vec42.js";import{fromValues as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as G}from"../../../core/support/UpdatingHandles.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as k}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as W}from"../../../geometry/projection/projectVectorToVector.js";import{create as z,empty as K,expandWithBuffer as $,toRect as Q}from"../../../geometry/support/aaBoundingBox.js";import{create as X,intersects as Y}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as J}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{g as te,f as ie,b as se}from"../../../chunks/sphere.js";import{newUByteArray as re}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as oe}from"../../../layers/LayerConstants.js";import ne from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ae}from"../../../layers/support/fieldUtils.js";import le from"../../../layers/support/SceneModification.js";import{getColor as de,getOpacity as he}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as ce}from"../../../support/arcadeOnDemand.js";import{isBasemapLayer as ue}from"../../../support/basemapUtils.js";import{getElevationOffset as _e}from"../../../support/elevationInfoUtils.js";import ge from"../../../symbols/Symbol3D.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as pe}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as fe,toWasmModification as be}from"./I3SMeshWorkerHandle.js";import{ElevationMode as ye,ForAllFeaturesReturnType as ve,ForAllFeaturesMode as Ie}from"./II3SMeshView3D.js";import{initialize as Me,setModificationsSync as Ce,filterObbsForModificationsSync as xe,interpretObbModificationResults as Ee}from"./SceneLayerWorker.js";import{overrideColor as Oe}from"./graphics/graphicUtils.js";import{areLabelsVisible as je}from"./graphics/Labeler.js";import{TextureUsage as we,TextureEncoding as Re}from"./i3s/enums.js";import Se from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Ae}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as De,NodeCrossfadeMetaData as Te}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ne}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ve}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Fe,selectEncoding as Pe,defaultMaterial as He,createTexture as Ue,configureMaterial as Ge}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Le,NodeState as ke}from"./i3s/I3SNode.js";import{I3SOverrides as Be}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as qe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as We,checkSceneLayerValid as ze,checkSceneLayerCompatibleWithView as Ke,getCacheKeySuffix as $e,whenGraphicAttributes as Qe,computeVisibilityObb as Xe,filterInPlace as Ye,getCachedAttributeValue as Je,intersectBoundingRectWithMbs as Ze,MbsIntersectResult as et,addWraparound as tt,getSymbolInfo as it,transparentEdgeMaterial as st,getClipRect as rt}from"./i3s/I3SUtil.js";import{IDBCache as ot}from"./i3s/IDBCache.js";import{IDBMockCache as nt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as at}from"./i3s/LayerElevationProvider.js";import{attributeLookup as lt}from"./support/attributeUtils.js";import{makeScheduleFunction as dt}from"./support/makeScheduleFunction.js";import{ColorMixModeEnum as ht}from"./support/symbolColorUtils.js";import{debugFlags as ct}from"../support/debugFlags.js";import{ElevationRange as ut}from"../support/ElevationRange.js";import{toBoundingRect as _t}from"../support/extentUtils.js";import{Obb as gt}from"../support/orientedBoundingBox.js";import{updatingProgress as mt}from"../support/updatingProperties.js";import{glLayout as pt}from"../support/buffer/glUtil.js";import{ObjectParameters as ft}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as bt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as yt}from"../webgl-engine/collections/Component/Transform.js";import{TextureCoordinateAttributeType as vt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as It}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as Mt}from"../webgl-engine/lib/edgeRendering/interfaces.js";import{defaultHighlightName as Ct}from"../../support/HighlightDefaults.js";import xt from"../../../symbols/SimpleFillSymbol.js";const Et="esri.views.3d.layers.I3SMeshView3D",Ot=()=>l.getLogger(Et),jt=[1,1,1,1];class wt extends Te{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var Rt;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(Rt||(Rt={}));const St=24,At=100*o.MEGABYTES,Dt=t=>{let o=class extends t{constructor(){super(...arguments),this._needsNormals=!0,this._updatingHandles=new G,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new De(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return We(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?we.AllTexturesPBR:we.AllTextures:this._usePBR||this._hasLoadedPBRTextures?we.GeometryTexturesPBR:we.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?_e(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new Qt(ye.Absolute,0);const t=_e(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new Qt(ye.Absolute,t);case"relative-to-ground":return new Qt(ye.RelativeToGround,t);case"on-the-ground":return new Qt(ye.OnTheGround,0);default:return new Qt(ye.Absolute,0)}}get supportedTextureEncodings(){return Fe(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=!(this.supportedTextureEncodings&Re.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ut;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[s,r,o,n]=e;t.expandElevationRangeValues(o-n,o+n)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new nt(this.view,e):new ot("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Be({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new fe(dt(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(c)),ze(this.i3slayer),Ke(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ne({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color;const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const n=this._controller,a=this._nodeId2Meta,l=this._nodeId2MetaReloading,h=e=>{const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=a.get(i)||l.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Ve({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:h}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new at({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),this._updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this._updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==ye.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Jt):t&&this.removeHandles(Jt)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const u=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),u),this._updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),u),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([p((()=>ct.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ct.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ct.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),m),p((()=>ct.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=$e(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>Ot().warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:_}=this,{viewingMode:g,renderCoordsHelper:f}=_;this._planetRadiusInGlobalMode="local"===g?0:f.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=d(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=d(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.memoryEstimate;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.memoryEstimate;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(je(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new me({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=Me().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=be(this._layerClippingArea,this._modifications,t);Ce({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new h:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Le.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ct.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new xt({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||Ot().warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>{if(null!=t){const i=this.getNodeComponentObb(t.node);null!=i&&e.push(i)}})),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return null!=t?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&this.supportedTextureEncodings&Re.Basis&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&It()}_getVertexBufferLayout(e,t){const i={hasTexture:kt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return pt(bt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||oe}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=lt(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const n of t){const e=lt(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Ne(t,this._collection,s,J(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;if(!B(r,o,0,r,n,0,8))return null;const a=K();return $(a,r,0,8),a}whenGraphicAttributes(e,t){return Qe(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${St}/${e}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(!(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Pe(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===ye.Absolute&&(e.geometryObbInRenderSR=gt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Wt(s.transformedGeometry,s.textureData),s.textureData.every(qt)&&zt(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>Ot().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Bt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:n,anchorIds:a,anchors:l,transformedGeometry:d,globalTrafo:h}=s,c=R(Xt,r.center.x,r.center.y,r.center.z);S(c,c,h);const u=new gt(c,[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===ye.Absolute&&(e.geometryObbInRenderSR=u),t.geometryData.componentOffsets=o,n&&(t.geometryData.featureIds=Array.from(n)),t.geometryData.anchorIds=a,t.geometryData.anchors=l;const _={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:h,geometryObbData:u.data,byteSize:Wt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&zt(e,_)){const t=null!=_.textureData?_.textureData.map((e=>qt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{..._,textureData:t}).catch((t=>Ot().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,_,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new ut,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e[3],a=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&n>=1*_)return null!=r?ti(t,r,l):null!=d&&d[3]>=0&&ii(t,d,l),!1;const g=ei;if(g.elevationRangeMin=1/0,g.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?ti(g,r,l):null!=d&&ii(g,d,l),g.elevationRangeMin>=t.elevationRangeMin&&g.elevationRangeMax<=t.elevationRangeMax))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return ti(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Xe(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let p=0;p<s.length;++p)r[p]=this._getVertexBufferLayout(s[p],t.geometryDescriptor);const o=this.i3slayer.normalReferenceFrame,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=qe(a,l,n,d,c),_=q(d,h),g=q(h,c);if(null==_||null==g)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:a,obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._needsNormals&&this._controller.isMeshPyramid,normalReferenceFrame:n,indexToVertexProjector:_,vertexToRenderProjector:g};return this._worker.invoke(m,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===ye.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==ye.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter((e=>null!=e&&!!(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&a.some((e=>null!=e&&(e.encoding===Re.Basis||e.encoding===Re.KTX2)))&&await It(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,{material:v,geometryParameters:w}=this._materialParameters(g,m),R=l||new Uint32Array([0,p?p.length:f.byteLength/m[0].stride]),S={vertices:{data:f,count:f.byteLength/m[0].stride,layoutParameters:w},positionData:{positions:Z(b.data),indices:ee(b.indices)},indices:p,componentOffsets:R},T=g.transformation?O(g.transformation):j();x(T,n,T);const N=E(P(),T),V=I(C(),T),F=this.view.renderSpatialReference,H=this.view.basemapTerrain.spatialReference,G=gt.fromData(t.geometryObbData).center,k=[1,1,1];L(G,F,k,H)||Ot().errorOnce("Unsupported coordinate system for IM overlay");const B=P();W(G,F,B,H);const q=C();M(q,V);const z=P();A(z,D(z,G,N),q);const K=B[0]-z[0]*k[0],$=B[1]-z[1]*k[1],Q=_.createObject(new ft(U(K,$,k[0],k[1]),new yt(N,V),gt.fromData(t.geometryObbData),S)),X=w.textureCoordinates===vt.Atlas,{textures:Y,texturePromise:J}=this._initMaterialAndTextures(Q,v,a,X);e.memory+=this._memEstimateGeometryAdded(Q),e.memory+=Y.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const te=!!v.hasParametersFromSource,ie="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,se=new wt(e,h,Q,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:te,isOpaque:ie},Y,c,u);s.meta=se,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>!!(e&we.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const re=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(se),J]).then((([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(se.objectHandle,!1).catch((e=>Tt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,se),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Q,!0),t?.updateObjectVisibility(se.objectHandle,!0).catch((e=>Tt(e,this.i3slayer.title))),se.attributeInfo=i.attributeInfo;const s=se.cachedRendererVersion!==this._rendererVersion,r=re!==this.slicePlaneEnabled;this._updateElevationOffsets(se);const o=se.elevationOffsets;this._updateComponentData(se);const n=this._applyFiltersToNode(se);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(se),null!=this._labeler&&this._addMetaToLabeler(this._labeler,se),this._visibleGeometryChanged(se,Nt.ADD),this._highlights.objectCreated(se),this._updateMaterial(se),this._setNewNodeOpacity(se),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{throw null!=s.meta&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){Ot().error("Removing duplicated node");const t=this._nodeId2Meta.get(e);null!=t&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);null!=t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&$t(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,n=s.mode;if(null==t||null==o||n===ye.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Xt,d=Yt,h=n===ye.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=J(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const n=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(R(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),T(l,l,te(e.node.serviceMbsInIndexSR)),W(l,i,l,o),s[n]=l[0],s[n+1]=l[1],s[n+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),R(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),A(l,l,a.rotationScale),T(l,l,a.position),s[n+2]=c.getAltitude(l),W(l,t,l,o),s[n]=l[0],s[n+1]=l[1])}return s})(),g=s.offset,m=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;m[e]=g+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Ae(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return null!=t?t.filterInPlace((e=>null!=this._nodeId2Meta.get(e))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}),(()=>this.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==ye.Absolute,s=!!t&&t!==e&&t.mode!==ye.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Nt.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:He(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=kt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ue(e,t,s,r)));this._stage.addMany(o);let n=null;return this._collection.updateMaterial(e,(e=>{n=Ge(e,t,o,i,this.view._stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:n}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?vt.Atlas:vt.Default:vt.None,colors:this._hasVertexColors,hasNormals:e.hasNormals&&this._needsNormals,needsNormals:this._needsNormals}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...g(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=X();this._renderClippingArea=_t(this.view.clippingArea,i,e)?i:null;const s=X();this._layerClippingArea=_t(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{null!=e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Nt.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},n=this._createLayerGraphic(o),a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===a||null!=d?.[e]))&&Ye(e,l,(e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Je(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return k(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Lt,this.view.renderSpatialReference),Ze(t,Lt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Vt),Q(Vt,Ft),Y(i,Ft)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===et.INSIDE)return;if(r===et.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Pt,i,t.objectHandle);Ye(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,n)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e),o={hasSlicePlane:this.slicePlaneEnabled};s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const n=this._edgeView;if(!n)return null;const a=n.hasObject(i);if(s){if(a){if(this.nodeCrossfadingEnabled){$t(r,this.getNodeOpacity(e))}return n.updateAllComponentMaterials(i,r,o,t).catch((e=>Tt(e,this.i3slayer.title))),n.updateObjectVisibility(i,!0).catch((e=>Tt(e,this.i3slayer.title))),n.updateAllVerticalOffsets(i,e.elevationOffsets).catch((e=>Tt(e,this.i3slayer.title))),n}const s=await this._collection.addEdges(i,n,r,o,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,n}return a&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,n.removeObject(i)),null}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(null!=this._labeler&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(this._updateCachedFilteredIds(e),s&&e.filteredIds===e.featureIds)return!r;const o=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return null!=i&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=d(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>Tt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Nt.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===ke.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=tt(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return tt(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=tt(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:Ot().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&Ot().error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(H(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),null!=this._stage.renderView.objectAndLayerIdRenderHelper){const t=e.featureIds[i],r=ue(this.view.map,this.layerUid);this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<Rt.CastShadows)-1,s.castShadows=!!(t[r+4]&1<<Rt.CastShadows),s.pickable=!!(t[r+4]&1<<Rt.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=it(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?ae(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=re(5*e.featureIds.length));const d={color:Ut,castShadows:!0,pickable:!0,colorMixMode:ht.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=Mt.OPAQUE,g=st,m=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Je(l[e],p);const r=s?this._getSymbolInfo(s,t):null;let h=null,f=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=de(this._colorVariable,t,{color:Gt,arcade:this._arcade});e&&(h=Ut,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,this._opacityVariable||null===e.a||(f=e.a))}this._opacityVariable&&(f=he(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==f?Oe(h,f,e.color,e.alpha,jt,Ut):Oe(h,f,null,null,jt,Ut)}if(null==h&&(h=Ut,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r?.material?r.material.colorMixMode:ht.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=ht.Replace),null!=d.edgeMaterial){const t=h[3]<=0?Mt.INVISIBLE:h[3]>=1&&(e.material.isOpaque||d.colorMixMode===ht.Replace)?Mt.OPAQUE:Mt.TRANSPARENT;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=g}else e.cachedEdgeMaterials[p]=st;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<Rt.CastShadows|+d.pickable<<Rt.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||$t(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==st)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?st:(r=r||t!==st,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),$t(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Nt.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._needsNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?ve.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values()){if(null==s)continue;if(null!=t){switch(t(s)){case ve.EXIT:return;case ve.SKIP:continue}}let r=ve.CONTINUE;switch(i){case Ie.ALL:r=this._forAllFeaturesOfNode(s,e);break;case Ie.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case Ie.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}if(r===ve.EXIT)return}}_forAllFeaturesOfNode(e,t){let i=ve.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===ve.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=ve.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===ve.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===et.OUTSIDE)return ve.CONTINUE;if(s===et.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=ve.CONTINUE,o=e.featureIds,n=e.objectHandle,a=rt(this._renderClippingArea,this._collection.getObjectTransform(n));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,a))continue;const t=i(o[l],l,e);if(t===ve.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Je(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t=Ct){if("number"==typeof e||e instanceof i?e=[e]:e instanceof n&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>lt(s,e.attributes,r))),{set:n,handle:a}=this._highlights.acquireSet(t);return this._highlights.setFeatureIds(n,o,t),a}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=this._highlights.acquireSet(t);return this._highlights.setFeatureIds(s,i,t),r}}return a()}resetHighlights(){d(this._highlights),this._highlights=new Se({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,Ie.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){if(!this._elevationProvider)return;const i=this.getNodeComponentObb(e.node);i&&this._elevationProvider.objectChanged(i),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t)}get performanceInfo(){return new pe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}get test(){}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;$t(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>Tt(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Kt(e);if(s){const t={context:i,buffer:s.buffer};xe(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Ee(i);e.imModificationImpact=s,s!==Le.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===ye.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=P(),a=P(),l=(e,t)=>{T(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),T(e,e,N(a,a,t)),V(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Nt.REMOVE&&t!==Nt.UPDATE||r.events.remove(i),t!==Nt.ADD&&t!==Nt.UPDATE||r.events.add(i,s)}};return e([y()],o.prototype,"_hasLoadedPBRTextures",void 0),e([y()],o.prototype,"_asyncModuleLoading",void 0),e([y()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],o.prototype,"view",void 0),e([y()],o.prototype,"i3slayer",void 0),e([y()],o.prototype,"_controller",void 0),e([y()],o.prototype,"_labeler",void 0),e([y()],o.prototype,"updating",void 0),e([y()],o.prototype,"suspended",void 0),e([y()],o.prototype,"contentVisible",null),e([y({readOnly:!0})],o.prototype,"legendEnabled",null),e([y()],o.prototype,"holeFilling",void 0),e([y(mt)],o.prototype,"updatingProgress",void 0),e([y()],o.prototype,"updatingProgressValue",null),e([y()],o.prototype,"hasTexturesOrVertexColors",null),e([y()],o.prototype,"rendererTextureUsage",null),e([y()],o.prototype,"elevationOffset",null),e([y()],o.prototype,"elevationInfo",null),e([y({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([y()],o.prototype,"supportedTextureEncodings",null),e([y()],o.prototype,"uncompressedTextureDownsamplingEnabled",null),e([y({type:[le]})],o.prototype,"_modifications",void 0),e([y({readOnly:!0})],o.prototype,"clientGeometry",null),e([y()],o.prototype,"elevationRange",null),e([y()],o.prototype,"fullExtent",null),e([y()],o.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],o.prototype,"_usePBR",null),o=e([v(Et)],o),o};function Tt(e,t){u(e)||Ot().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Nt;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Nt||(Nt={}));const Vt=z(),Ft=X(),Pt=X(),Ht=new gt,Ut=[0,0,0,0],Gt=new t([0,0,0,0]),Lt=ie(0,0,0,0);function kt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Bt(e){return"geometryData"in e}function qt(e){return null!=e&&b(e.data)}function Wt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function zt(e,t){return t.byteSize>At?(Ot().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Kt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Ht,t.center=te(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}function $t(e,t){e.forEach((e=>e.opacity=t))}class Qt{constructor(e,t){this.mode=e,this.offset=t}}const Xt=P(),Yt=z(),Jt="elevation-change",Zt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],ei=new ut;function ti(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(Zt);for(const e of Zt){const t=F(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(Zt);for(const e of Zt){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function ii(e,t,i){const s=te(t),r=i>0?F(s)-i:s[2],o=se(t);e.expandElevationRangeValues(r-o,r+o)}export{Dt as I3SMeshView3D};
5
+ import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../Graphic.js";import"../../../symbols.js";import{isSome as s,removeUnordered as r}from"../../../core/arrayUtils.js";import{ByteSizeUnit as o}from"../../../core/ByteSizeUnit.js";import n from"../../../core/Collection.js";import{makeHandle as a}from"../../../core/handleUtils.js";import has from"../../../core/has.js";import l from"../../../core/Logger.js";import{destroyMaybe as d}from"../../../core/maybe.js";import h from"../../../core/PooledArray.js";import{ignoreAbortErrors as c,isAbortError as u,throwIfAborted as _,createResolver as g}from"../../../core/promiseUtils.js";import{initial as m,watch as p}from"../../../core/reactiveUtils.js";import{schedule as f}from"../../../core/scheduling.js";import{isArrayBuffer as b}from"../../../core/typedArrayUtil.js";import{property as y}from"../../../core/accessorSupport/decorators/property.js";import{subclass as v}from"../../../core/accessorSupport/decorators/subclass.js";import{fromMat4 as I,invert as M}from"../../../core/libs/gl-matrix-2/math/mat3.js";import{create as C}from"../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{multiply as x,getTranslation as E}from"../../../core/libs/gl-matrix-2/math/mat4.js";import{clone as O,create as j}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{fromValues as w}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{s as R,h as S,t as A,z as D,g as T,j as N,f as V,H as F}from"../../../chunks/vec32.js";import{create as P}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{s as H}from"../../../chunks/vec42.js";import{fromValues as U}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{UpdatingHandles as G}from"../../../core/support/UpdatingHandles.js";import{localLinearScaleFactors as L}from"../../../geometry/projection/localLinearScaleFactors.js";import{projectBoundingSphere as k}from"../../../geometry/projection/projectBoundingSphere.js";import{projectBuffer as B}from"../../../geometry/projection/projectBuffer.js";import{getProjectorName as q}from"../../../geometry/projection/projectors.js";import{projectVectorToVector as W}from"../../../geometry/projection/projectVectorToVector.js";import{create as z,empty as K,expandWithBuffer as $,toRect as Q}from"../../../geometry/support/aaBoundingBox.js";import{create as X,intersects as Y}from"../../../geometry/support/aaBoundingRect.js";import{newDoubleArray as J}from"../../../geometry/support/DoubleArray.js";import{compactFloatArray as Z}from"../../../geometry/support/FloatArray.js";import{compactIndices as ee}from"../../../geometry/support/Indices.js";import{g as te,f as ie,b as se}from"../../../chunks/sphere.js";import{newUByteArray as re}from"../../../geometry/support/UByteArray.js";import{fallbackObjectIDAttribute as oe}from"../../../layers/LayerConstants.js";import ne from"../../../layers/graphics/controllers/I3SOnDemandController.js";import{fixFields as ae}from"../../../layers/support/fieldUtils.js";import le from"../../../layers/support/SceneModification.js";import{getColor as de,getOpacity as he}from"../../../renderers/visualVariables/support/visualVariableUtils.js";import{loadArcade as ce}from"../../../support/arcadeOnDemand.js";import{isBasemapLayer as ue}from"../../../support/basemapUtils.js";import{getElevationOffset as _e}from"../../../support/elevationInfoUtils.js";import ge from"../../../symbols/Symbol3D.js";import me from"./I3SMeshViewLabeler.js";import{I3SMeshViewPerformanceInfo as pe}from"./I3SMeshViewPerformanceInfo.js";import{I3SMeshWorkerHandle as fe,toWasmModification as be}from"./I3SMeshWorkerHandle.js";import{ElevationMode as ye,ForAllFeaturesReturnType as ve,ForAllFeaturesMode as Ie}from"./II3SMeshView3D.js";import{initialize as Me,setModificationsSync as Ce,filterObbsForModificationsSync as xe,interpretObbModificationResults as Ee}from"./SceneLayerWorker.js";import{overrideColor as Oe}from"./graphics/graphicUtils.js";import{areLabelsVisible as je}from"./graphics/Labeler.js";import{TextureUsage as we,TextureEncoding as Re}from"./i3s/enums.js";import Se from"./i3s/Highlights.js";import{I3SAsyncElevationUpdater as Ae}from"./i3s/I3SAsyncElevationUpdater.js";import{I3SCrossfadeHelper as De,NodeCrossfadeMetaData as Te}from"./i3s/I3SCrossfadeHelper.js";import{boundingBoxCornerPoints as Ne}from"./i3s/I3SGeometryUtil.js";import{I3SIntersectionHandler as Ve}from"./i3s/I3SIntersectionHandler.js";import{getSupportedEncodings as Fe,selectEncoding as Pe,defaultMaterial as He,createTexture as Ue,configureMaterial as Ge}from"./i3s/I3SMaterialUtil.js";import{NodeIMModificationImpact as Le,NodeState as ke}from"./i3s/I3SNode.js";import{I3SOverrides as Be}from"./i3s/I3SOverrides.js";import{computeGlobalTransformation as qe}from"./i3s/I3SProjectionUtil.js";import{rendererNeedsTextures as We,checkSceneLayerValid as ze,checkSceneLayerCompatibleWithView as Ke,getCacheKeySuffix as $e,whenGraphicAttributes as Qe,computeVisibilityObb as Xe,filterInPlace as Ye,getCachedAttributeValue as Je,intersectBoundingRectWithMbs as Ze,MbsIntersectResult as et,addWraparound as tt,getSymbolInfo as it,transparentEdgeMaterial as st,getClipRect as rt}from"./i3s/I3SUtil.js";import{IDBCache as ot}from"./i3s/IDBCache.js";import{IDBMockCache as nt}from"./i3s/IDBMockCache.js";import{LayerElevationProvider as at}from"./i3s/LayerElevationProvider.js";import{attributeLookup as lt}from"./support/attributeUtils.js";import{makeScheduleFunction as dt}from"./support/makeScheduleFunction.js";import{ColorMixModeEnum as ht}from"./support/symbolColorUtils.js";import{debugFlags as ct}from"../support/debugFlags.js";import{ElevationRange as ut}from"../support/ElevationRange.js";import{toBoundingRect as _t}from"../support/extentUtils.js";import{Obb as gt}from"../support/orientedBoundingBox.js";import{updatingProgress as mt}from"../support/updatingProperties.js";import{glLayout as pt}from"../support/buffer/glUtil.js";import{ObjectParameters as ft}from"../webgl-engine/collections/Component/ObjectParameters.js";import{createVertexBufferLayout as bt}from"../webgl-engine/collections/Component/SourceGeometry.js";import{Transform as yt}from"../webgl-engine/collections/Component/Transform.js";import{TextureCoordinateAttributeType as vt}from"../webgl-engine/core/shaderLibrary/attributes/TextureCoordinateAttribute.glsl.js";import{loadBasis as It}from"../webgl-engine/lib/BasisUtil.js";import{Transparency as Mt}from"../webgl-engine/lib/edgeRendering/interfaces.js";import{defaultHighlightName as Ct}from"../../support/HighlightDefaults.js";import xt from"../../../symbols/SimpleFillSymbol.js";const Et="esri.views.3d.layers.I3SMeshView3D",Ot=()=>l.getLogger(Et),jt=[1,1,1,1];class wt extends Te{constructor(e,t,i,s,r,o,n,a,l){super(),this.node=e,this.featureIds=t,this.objectHandle=i,this.cachedRendererVersion=s,this.attributeInfo=r,this.material=o,this.textures=n,this.anchorIds=a,this.anchors=l,this.cachedElevationAnchors=null,this.cachedEdgeMaterials=new Array,this.edgeMemoryUsage=0}}var Rt;!function(e){e[e.CastShadows=4]="CastShadows",e[e.Pickable=5]="Pickable"}(Rt||(Rt={}));const St=24,At=100*o.MEGABYTES,Dt=t=>{let o=class extends t{constructor(){super(...arguments),this._needsNormals=!0,this._updatingHandles=new G,this._nodeId2Meta=new Map,this._nodeId2MetaReloading=new Map,this._i3sWasmLoaded=!1,this._snappingSourcesTrackers=[],this._hasLoadedPBRTextures=!1,this._asyncModuleLoading=0,this._addTasks=new Map,this._currentRenderer=null,this._rendererVersion=0,this._colorVariable=null,this._opacityVariable=null,this._rendererFields=null,this._symbologyFields=null,this._symbologyOverride=null,this._symbologyOverrideFields=null,this._symbolInfos=new Map,this._visibleGeometryChangedSchedulerHandle=null,this._hasComponentData=!1,this._hasVertexColors=!1,this._nodeColorOverride=null,this.updating=!0,this.holeFilling="auto",this._hasColors=!1,this._hasTextures=!1,this._hasData=!1,this.slicePlaneEnabled=!1,this._modifications=new Array,this.ignoresMemoryFactor=!1,this._layerUrl="",this._cacheKeySuffix=null,this._planetRadiusInGlobalMode=0,this._elevationTask=null,this._filters=[],this._arcade=null,this._tmpAttributeOnlyGraphic=new i,this._crossfadeHelper=new De(this)}get lodCrossfadeoutDuration(){return 0}get lodCrossfadeinDuration(){return 0}get lodCrossfadeUncoveredDuration(){return 0}get layerUid(){return this.i3slayer&&this.i3slayer.uid}get sublayerUid(){return null}get layerId(){return this.i3slayer&&this.i3slayer.id}get sublayerId(){return null}get contentVisible(){return!this.suspended&&this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get updatingProgressValue(){return this._controller?.updatingProgress??0}get hasTexturesOrVertexColors(){return this._hasData?this._hasTextures||this._hasColors?"yes":"probably-not":"unknown"}get rendererTextureUsage(){return We(this._currentRenderer)?this._usePBR||this._hasLoadedPBRTextures?we.AllTexturesPBR:we.AllTextures:this._usePBR||this._hasLoadedPBRTextures?we.GeometryTexturesPBR:we.GeometryTextures}get elevationOffset(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;return null!=e&&"absolute-height"===e.mode?_e(e,this.i3slayer.spatialReference):0}get elevationInfo(){const e=null!=this.i3slayer?this.i3slayer.elevationInfo:null;if(null==e)return new Qt(ye.Absolute,0);const t=_e(e,this.i3slayer.spatialReference);switch(e.mode){case"absolute-height":return new Qt(ye.Absolute,t);case"relative-to-ground":return new Qt(ye.RelativeToGround,t);case"on-the-ground":return new Qt(ye.OnTheGround,0);default:return new Qt(ye.Absolute,0)}}get supportedTextureEncodings(){return Fe(this.view._stage.renderView.capabilities)}get uncompressedTextureDownsamplingEnabled(){const e=this.view?.qualitySettings.sceneService.uncompressedTextureDownsamplingEnabled,t=!(this.supportedTextureEncodings&Re.DDS_S3TC);return e&&t}get clientGeometry(){return this.i3sOverrides.geometryOverrides}get elevationRange(){const e=this._nodeId2Meta,t=new ut;for(const i of e.values()){if(null==i)continue;const{node:{serviceMbsInIndexSR:e}}=i,[s,r,o,n]=e;t.expandElevationRangeValues(o-n,o+n)}return t.elevationRangeValid?t:null}get fullExtent(){return this.i3slayer.fullExtent}initialize(){const e=has("enable-feature:idb-mock-cache");this._idbCache=e?new nt(this.view,e):new ot("esri-scenelayer-cache","geometries"),this._preLoadBasis(),this.addResolvingPromise(this.i3slayer.indexInfo);const t=this.view.resourceController,i=t.memoryController;this.i3sOverrides=new Be({view:this.view,layer:this.i3slayer,memoryController:i}),this._worker=new fe(dt(t)),this.addResolvingPromise(this._worker.promise);const s=this.i3slayer.store;this.addResolvingPromise(this._worker.setLegacySchema(this.uid,s.defaultGeometrySchema).catch(c)),ze(this.i3slayer),Ke(this.i3slayer,this.view),this._layerUrl=this.i3slayer.parsedUrl.path,this._controller=new ne({layerView:this,worker:this._worker}),this._gpuMemoryEstimate=0,this._texMemoryEstimate=0,this._geoMemoryEstimate=0,this._stage=this.view._stage,this._collection=this._stage.renderView.componentObjectCollection,this.resetHighlights();const r=s.defaultGeometrySchema;if(this._isIntegratedMesh||!r)this._hasComponentData=!1;else{const e=r.featureAttributes;this._hasComponentData=!!(e&&e.faceRange&&e.id)}this._hasVertexColors=null!=(r?.vertexAttributes.color??null)&&!this.i3slayer.cachedDrawingInfo?.color;const o=this.view.resourceController.memoryController.newCache(`sl-${this.uid}`,(e=>this._deleteComponentObject(e)));this._memCache=o;const n=this._controller,a=this._nodeId2Meta,l=this._nodeId2MetaReloading,h=e=>{const t=n.index;if(!t)return;const i=t.rootNode;if(!i)return;const s=t=>{const i=t.index,s=a.get(i)||l.get(i);return e(t,s?.objectHandle??null)};t.traverse(i,s)};this._intersectionHandler=new Ve({layerUid:this.layerUid,sublayerUid:this.sublayerUid,collection:this._collection,slicePlaneEnabled:this.slicePlaneEnabled,isGround:this._isIntegratedMesh,traverseNodeHierarchy:h}),this._updatingHandles.add((()=>this.layerUid),(e=>this._intersectionHandler.layerUid=e)),this._updatingHandles.add((()=>this.sublayerUid),(e=>this._intersectionHandler.sublayerUid=e)),this._elevationProvider=new at({view:this.view,layerElevationSource:this,intersectionHandler:this._intersectionHandler}),this._hasLoadedPBRTextures=this._usePBR,this._updatingHandles.add((()=>this.view.clippingArea),(()=>this._clippingAreaChanged()),m),this._updatingHandles.add((()=>this.fullOpacity),(e=>this._opacityChange(e))),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(e))),this._updatingHandles.add((()=>this.elevationOffset),((e,t)=>{this._reloadAll(t),this._controller.invalidateVisibilityObbs()})),this._updatingHandles.add((()=>this.elevationInfo),((e,t)=>this._elevationInfoChanged(e,t)),m),this._updatingHandles.add((()=>!this.suspended&&this.elevationInfo.mode!==ye.Absolute),((e,t)=>{e?this.addHandles(this.view.basemapTerrain.on("elevation-change",(({extent:e})=>this._ensureElevationTask().addExtent(e))),Jt):t&&this.removeHandles(Jt)}),m),this._updatingHandles.add((()=>this._usePBR),(e=>this._updatePBR(e)));const u=()=>{this._reloadAll(),this.clearMemCache()};this._updatingHandles.add((()=>this.rendererTextureUsage),u),this._updatingHandles.add((()=>this.uncompressedTextureDownsamplingEnabled),u),this._updatingHandles.add((()=>this.contentVisible),(e=>this._contentVisibleChanged(e)),m),this._updatingHandles.add((()=>this.i3slayer.labelsVisible),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this.i3slayer.labelingInfo),(()=>this._labelingChanged()),m),this._updatingHandles.add((()=>this._modifications),(()=>this._modificationsChanged()),m),this.addHandles([p((()=>ct.I3S_TREE_SHOW_TILES),(e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then((({I3STreeDebugger:t})=>{!this._treeDebugger&&ct.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))}))}else e||ct.I3S_TREE_SHOW_TILES||(this._treeDebugger=d(this._treeDebugger))}),m),p((()=>ct.I3S_SHOW_MODIFICATIONS),(()=>this._showModifications()),m)]),this._cacheKeySuffix=$e(this.i3slayer.spatialReference,this.view.renderSpatialReference),this._idbCache.init().catch((e=>Ot().warn(`Failed to initialize IndexedDB cache: ${e}`)));const{view:_}=this,{viewingMode:g,renderCoordsHelper:f}=_;this._planetRadiusInGlobalMode="local"===g?0:f.referenceEllipsoid.radius}destroy(){this._clearAddTasks(),this._elevationTask=d(this._elevationTask),this.i3sOverrides=d(this.i3sOverrides),this._elevationProvider&&(this._elevationProvider.objectsChanged(this.getVisibleObbs()),this.view.elevationProvider.unregister(this._elevationProvider),this._elevationProvider=null),this._intersectionHandler&&(this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler),this._intersectionHandler=null);const e=this._worker;e&&(e.destroyContext(this.uid).then((()=>e.destroy())),this._worker=null),this._removeAllNodeDataFromStage(),this._memCache=d(this._memCache),this._collection=null,this._stage=null,this._edgeView=null,this._labeler=d(this._labeler),this._treeDebugger=d(this._treeDebugger),this._controller=d(this._controller),this._highlights.destroy(),this._nodeId2Meta.clear(),this._nodeId2MetaReloading.clear(),this._crossfadeHelper=d(this._crossfadeHelper),this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle.remove(),this._visibleGeometryChangedSchedulerHandle=null),this._updatingHandles=d(this._updatingHandles)}_memEstimateTextureAdded(e){const t=e.memoryEstimate;return this._gpuMemoryEstimate+=t,this._texMemoryEstimate+=t,t}_memEstimateTextureRemoved(e){if(null!=e){const t=e.memoryEstimate;this._gpuMemoryEstimate-=t,this._texMemoryEstimate-=t}}_memEstimateGeometryAdded(e){const t=this._collection.getObjectGPUMemoryUsage(e);return this._gpuMemoryEstimate+=t,this._geoMemoryEstimate+=t,t}_memEstimateGeometryRemoved(e){const t=this._collection.getObjectGPUMemoryUsage(e);this._gpuMemoryEstimate-=t,this._geoMemoryEstimate-=t}isNodeLoaded(e){return this._nodeId2Meta.has(e)}isNodeReloading(e){return this._nodeId2MetaReloading.has(e)}get usedMemory(){let e=null!=this._labeler?this._labeler.usedMemory:0;return this._nodeId2Meta.forEach((t=>e+=null!=t?t.node.memory:0)),this._nodeId2MetaReloading.forEach((t=>e+=null!=t?t.node.memory:0)),e}get unloadedMemory(){return(null!=this._controller?this._controller.unloadedMemoryEstimate:0)+(null!=this._labeler?this._labeler.unloadedMemoryEstimate:0)}_labelingChanged(){if(!(je(this.i3slayer)&&this._supportsLabeling))return void(null!=this._labeler&&(this._labeler.destroy(),this._labeler=null));if(null!=this._labeler)return;const e=new me({view:this.view,layer:this.i3slayer,collection:this._collection,overrides:this.i3sOverrides});this._nodeId2Meta.forEach((t=>null!=t&&this._addMetaToLabeler(e,t))),this._labeler=e}_loadAsyncModule(e){return++this._asyncModuleLoading,e.then((e=>(--this._asyncModuleLoading,e)),(e=>{throw--this._asyncModuleLoading,e}))}_modificationsChanged(){if(!this._i3sWasmLoaded&&this.hasModifications)return this._i3sWasmLoaded=Me().then((()=>{this._i3sWasmLoaded=!0,this._modificationsChanged(),this.notifyUpdate()})),void this.notifyUpdate();if(!0!==this._i3sWasmLoaded)return;const e=this.uid,t=this.i3slayer.spatialReference;this._worker.setModifications(e,this._layerClippingArea,this._modifications,t);const i=be(this._layerClippingArea,this._modifications,t);Ce({context:e,modifications:i,isGeodetic:t.isGeographic}),this._controller.modificationsChanged();const s=this.hasModifications?new h:null;this._nodeId2Meta.forEach(((e,t)=>{null==e?(this._nodeId2Meta.delete(t),this._controller.updateLoadStatus(t,!1)):e.node.hasModifications?(this._nodeId2Meta.delete(t),this._nodeId2MetaReloading.set(t,e)):null!=s&&s.push(e.node)})),this.notifyChange("elevationRange"),null!=s&&this._nodeId2MetaReloading.forEach((e=>s.push(e.node))),null!=s&&s.length>0&&(this.updateNodeModificationStatus(s),s.forAll((e=>{if(e.imModificationImpact!==Le.Culled){const t=this._nodeId2Meta.get(e.index);this._controller.invalidateGeometryVisibility(e.index),null!=t?(this._nodeId2Meta.delete(e.index),this._nodeId2MetaReloading.set(e.index,t),this.notifyChange("elevationRange")):this._nodeId2Meta.has(e.index)&&(this._nodeId2Meta.delete(e.index),this._controller.updateLoadStatus(e.index,!1))}}))),this.clearMemCache(),this._controller.restartNodeLoading(),this._showModifications()}_showModifications(){if(null!=this._modificationGraphics&&(this.view.graphics.removeMany(this._modificationGraphics),this._modificationGraphics=null),!ct.I3S_SHOW_MODIFICATIONS||0===this._modifications.length)return;const e={clip:[227,227,79,.8],mask:[227,139,79,.8],replace:[139,227,79,.8]},t={outline:{color:[255,255,255],width:1}};this._modificationGraphics=new Array;for(const s of this._modifications){const r=s.geometry;r.spatialReference=this.i3slayer.spatialReference;const o=new xt({...t,color:e[s.type]});this._modificationGraphics.push(new i({geometry:r,symbol:o}))}this.view.graphics.addMany(this._modificationGraphics)}_addMetaToLabeler(e,t){e.addNodeMeta(t,((e,t)=>this._createAttributes(e,t)))}_contentVisibleChanged(e){e?(this.view.elevationProvider.register(this._elevationContext,this._elevationProvider),this._stage.view.sceneIntersectionHelper.addIntersectionHandler(this._intersectionHandler)):(this._removeAllNodeDataFromStage(),this.view.elevationProvider&&this.view.elevationProvider.unregister(this._elevationProvider),this._stage.view.sceneIntersectionHelper.removeIntersectionHandler(this._intersectionHandler))}getLoadedAttributes(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this._nodeId2Meta.get(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}setAttributeData(e,t){const i=this._nodeId2Meta.get(e);null!=i?.attributeInfo&&(i.attributeInfo.attributeData=t,this._attributeValuesChanged(i))}async updateAttributes(e,t,i){const s=this._nodeId2Meta.get(e);null!=s&&(await this.i3sOverrides.applyAttributeOverrides(s.featureIds,t,i,this._controller.requiredAttributes),s.attributeInfo=t,this._controller.reschedule((()=>this._attributeValuesChanged(s)),i).catch((e=>{u(e)||Ot().warn("Error while updating attribute values. Layer might not display correctly.",e)})))}_attributeValuesChanged(e){e.cachedRendererVersion=this._getInvalidRendererVersion(),e.filteredIds=null,null!=this._labeler&&this._labeler.setNodeMetaAttributes(e,((e,t)=>this._createAttributes(e,t))),this._updateEngineObject(e)}clearMemCache(){null!=this._memCache&&this._memCache.clear()}getVisibleNodes(){const e=new Array;return this._nodeId2Meta.forEach((t=>null!=t&&e.push(t.node))),e}getVisibleObbs(){const e=new Array;return this._nodeId2Meta.forEach((t=>{if(null!=t){const i=this.getNodeComponentObb(t.node);null!=i&&e.push(i)}})),e}getNodeComponentObb(e){const t=this._nodeId2Meta.get(e.index)??this._nodeId2MetaReloading.get(e.index);return null!=t?this._collection.getComponentObb(t.objectHandle):null}getLoadedNodeIndices(e){this._nodeId2Meta.forEach(((t,i)=>e.push(i))),this._nodeId2MetaReloading.forEach(((t,i)=>e.push(i)))}_preLoadBasis(){!has("disable-feature:i3s-basis")&&this.supportedTextureEncodings&Re.Basis&&this.i3slayer.textureSetDefinitions?.some((e=>e.formats.some((e=>"basis"===e.format||"ktx2"===e.format))))&&It()}_getVertexBufferLayout(e,t){const i={hasTexture:kt(e.params.material),hasNormals:t.normal,hasRegions:t.uvRegion};return pt(bt(this._getGeometryParameters(i)))}_getObjectIdField(){return this.i3slayer.objectIdField||oe}_getGlobalIdField(){return this.i3slayer.associatedLayer?.globalIdField}_findGraphicNodeAndIndex(e){const t=lt(this.i3slayer.fieldsIndex,e.attributes,this._getObjectIdField());for(const i of this._nodeId2Meta.values()){const e=i?.featureIds.indexOf(t);if(null!=e&&e>=0)return{node:i.node,index:e}}return null}_getGraphicIndices(e,t){const i=this._nodeId2Meta.get(e.index);if(null==i)return[];const s=[],r=this._getObjectIdField(),o=this.i3slayer.fieldsIndex;for(const n of t){const e=lt(o,n.attributes,r),t=i.featureIds.indexOf(e);-1!==t&&s.push(t)}return s}whenGraphicBounds(e){const t=this._findGraphicNodeAndIndex(e);if(!t)return Promise.reject();const i=this._getAABB(t.node.index,t.index);return null==i?Promise.reject():Promise.resolve({boundingBox:i,screenSpaceObjects:[]})}getAABBFromIntersectorTarget(e){return null==e.nodeIndex||null==e.componentIndex?null:this._getAABB(e.nodeIndex,e.componentIndex)}_getAABB(e,t){const i=this._nodeId2Meta.get(e);if(null==i?.featureIds||t>=i.featureIds.length)return null;const s=i.objectHandle,r=Ne(t,this._collection,s,J(24),0),o=this.view.renderSpatialReference,n=this.view.spatialReference;if(!B(r,o,0,r,n,0,8))return null;const a=K();return $(a,r,0,8),a}whenGraphicAttributes(e,t){return Qe(this.i3slayer,e,this._getObjectIdField(),t,(()=>[...this._nodeId2Meta.values()].filter(s)))}getGraphicFromIntersectorTarget(e){if(null==e.nodeIndex||null==e.componentIndex)return null;const t=this._nodeId2Meta.get(e.nodeIndex);return null==t?.featureIds||e.componentIndex>=t.featureIds.length?null:this._createGraphic(e.componentIndex,t)}_getCacheKey(e){return`${this._layerUrl}/v${St}/${e}${this._cacheKeySuffix}`}_getMemCacheKey(e,t=this.elevationOffset){return e+"#"+t}get _idbCacheEnabled(){return!this._controller.disableIDBCache&&!this.hasModifications&&0===this.elevationOffset&&null!=this._cacheKeySuffix}loadCachedGPUData(e){return null!=this._memCache?this._memCache.pop(this._getMemCacheKey(e)):null}deleteCachedGPUData(e){null!=e&&this._deleteComponentObject(e)}_cacheGPUData(e,t=this.elevationOffset){if(null==this._memCache)return void this._deleteComponentObject(e);const i=this._controller.indexDepth-e.node.level;this._memCache.put(this._getMemCacheKey(e.node.index,t),e,e.node.memory,i)}loadMissingTextures(e,t,i,s){const r=e?.filter(((e,i)=>{if(!(e.usage&this.rendererTextureUsage))return!1;if(null==t)return!0;const s=Pe(e.encodings,this.supportedTextureEncodings),r=t[i];return!!(null==r?.data||s&&r.encoding!==s.encoding)}))??[];return 0===r.length?Promise.resolve(!1):i(r,s).then((i=>{let s=0;for(let r=0;r<e.length;r++)s<i.length&&i[s].id===e[r].id&&(t[r]=i[s],s++);return!0}))}loadCachedNodeData(e,t,i){return this._idbCacheEnabled?this._idbCache.get(this._getCacheKey(e.id),t).then((s=>null==s?null:s.nodeVersion!==e.version?(this._idbCache.remove(this._getCacheKey(e.id)),null):(this.elevationInfo.mode===ye.Absolute&&(e.geometryObbInRenderSR=gt.fromData(s.geometryObbData)),this.loadMissingTextures(s.requiredTextures,s.textureData,i,t).then((i=>(i&&this._idbCache.initialized&&null!=s.textureData&&(s.byteSize=Wt(s.transformedGeometry,s.textureData),s.textureData.every(qt)&&zt(e,s)&&this._idbCache.put(this._getCacheKey(e.id),s).catch((t=>Ot().warn(`Failed to update node with textures in IndexedDB cache: ${e.id}: ${t}`)))),_(t),s)))))):Promise.resolve(null)}addNode(e,t,i){return Bt(t)?null==t.geometryBuffer?(this._addNodeMeta(e.index,null),Promise.resolve()):this._addData(e,t.attributeDataInfo,(()=>this._transformNode(e,t,i).then((s=>this._safeReschedule((()=>{if(null==s)return e.hasModifications=!1,this._addCachedNodeData(e,null,i);e.hasModifications=s.transformedGeometry.hasModifications;const{obb:r,componentOffsets:o,featureIds:n,anchorIds:a,anchors:l,transformedGeometry:d,globalTrafo:h}=s,c=R(Xt,r.center.x,r.center.y,r.center.z);S(c,c,h);const u=new gt(c,[r.extents.x,r.extents.y,r.extents.z],w(r.orientation.x,r.orientation.y,r.orientation.z,r.orientation.w));this.elevationInfo.mode===ye.Absolute&&(e.geometryObbInRenderSR=u),t.geometryData.componentOffsets=o,n&&(t.geometryData.featureIds=Array.from(n)),t.geometryData.anchorIds=a,t.geometryData.anchors=l;const _={nodeVersion:e.version,geometryData:t.geometryData,requiredTextures:t.requiredTextures,textureData:t.textureData,transformedGeometry:d,globalTrafo:h,geometryObbData:u.data,byteSize:Wt(d,t.textureData)};if(this._idbCacheEnabled&&this._idbCache.initialized&&zt(e,_)){const t=null!=_.textureData?_.textureData.map((e=>qt(e)?e:null)):null;this._idbCache.put(this._getCacheKey(e.id),{..._,textureData:t}).catch((t=>Ot().warn(`Failed to store node in IndexedDB cache: ${e.id}: ${t}`)))}return this._addCachedNodeData(e,_,i)}),i))))):Promise.reject()}getElevationRange(e){const t=new ut,i=this._controller,{index:s}=i;if(!s)return t;const{rootNode:r}=s;if(!r)return t;const o=this._nodeId2Meta,n=e[3],a=i.viewportQueries,l=this._planetRadiusInGlobalMode,{view:d}=this,{renderCoordsHelper:h}=d,c=h.referenceEllipsoid.radius,u=this._collection,_=i=>{const{childrenLoaded:s}=i;if(0===s)return!1;const r=a.getAndUpdateVisibilityObbInRenderSR(i);let d=null,_=-1;if(r){if(_=r.radius,!r.intersectSphereWithMBS(e,_))return!1}else d=a.getServiceMbsInRenderSR(i),d&&(_=d[3]);if(_>=0&&n>=1*_)return null!=r?ti(t,r,l):null!=d&&d[3]>=0&&ii(t,d,l),!1;const g=ei;if(g.elevationRangeMin=1/0,g.elevationRangeMax=-1/0,(null!=r||null!=d)&&(null!=r?ti(g,r,l):null!=d&&ii(g,d,l),g.elevationRangeMin>=t.elevationRangeMin&&g.elevationRangeMax<=t.elevationRangeMax))return!1;const m=o.get(i.index);if(m){const{geometryObbInRenderSR:s}=i;if(!s||s.intersectSphereWithMBS(e)){if(s){if(n>0*s.radius)return ti(t,s,l),!1}const{objectHandle:e}=m,i=u.getObjectTransform(e),r=h.getAltitude(i.position);u.expandRangeWithComponentObjectElevationRange(e,r,c,t)}}return s-(m?1:0)>0};return s.traverse(r,_),t}computeVisibilityObb(e){return Xe(e,this.view.renderSpatialReference,this._controller.crsIndex,this.i3slayer.spatialReference,this.elevationOffset,this._modifications,this.view.renderCoordsHelper.sphericalPCPF)}_transformNode(e,t,i){const s=t.geometryData.geometries??[],r=new Array(s.length);for(let p=0;p<s.length;++p)r[p]=this._getVertexBufferLayout(s[p],t.geometryDescriptor);const o=this.i3slayer.normalReferenceFrame,n=t.normalReferenceFrame??o??"none",a=e.serviceMbsInIndexSR,l=this.elevationOffset,d=this._controller.crsIndex,h=this._controller.crsVertex,c=this.view.renderSpatialReference,u=qe(a,l,n,d,c),_=q(d,h),g=q(h,c);if(null==_||null==g)return Promise.resolve(null);const m={context:this.uid,geometryBuffer:t.geometryBuffer,geometryData:t.geometryData,geometryDescriptor:t.geometryDescriptor,layouts:r,globalTrafo:u,mbs:a,obbData:e.serviceObbInIndexSR?.data,elevationOffset:l,needNormals:this._needsNormals&&this._controller.isMeshPyramid,normalReferenceFrame:n,indexToVertexProjector:_,vertexToRenderProjector:g};return this._worker.invoke(m,i)}get _supportsNodeCrossFading(){return!this.view?._stage?.renderer.shadowsEnabled}get nodeCrossfadingEnabled(){return this._supportsNodeCrossFading&&(this.lodCrossfadeinDuration>0||this.lodCrossfadeoutDuration>0||this.lodCrossfadeUncoveredDuration>0)}get nodeFadeoutEnabled(){return this._supportsNodeCrossFading&&this.lodCrossfadeoutDuration>0}_setNewNodeOpacity(e){const t=this.nodeCrossfadingEnabled?0:this.fullOpacity;this._setNodeOpacity(e,t)}addCachedGPUData(e,t,i){if(this.elevationInfo.mode===ye.Absolute&&(e.geometryObbInRenderSR=this._collection.getComponentObb(t.objectHandle).clone()),!this._controller.isGeometryVisible(e))return void this._cacheGPUData(t);null!=this._labeler&&this._addMetaToLabeler(this._labeler,t);const s=e.index;this._addNodeMeta(s,t),this.updateNodeState(s,i),this._collection.setObjectVisibility(t.objectHandle,!0),this._updateMaterial(t),this._setNewNodeOpacity(t),this.elevationInfo.mode!==ye.Absolute&&this._ensureElevationTask().schedule(s),this._updateEngineObject(t),this._highlights.objectCreated(t),null!=this._treeDebugger&&this._treeDebugger.update()}addCachedNodeData(e,t,i,s){return this._addData(e,i,(()=>this._addCachedNodeData(e,t,s)))}async deleteCachedNodeData(e){if(this._idbCacheEnabled)return this._idbCache.remove(this._getCacheKey(e))}async _addCachedNodeData(e,t,i){if(!this.contentVisible||!this._controller.isGeometryVisible(e))return void this._removeNodeStageData(e.index,this.elevationOffset,this._nodeId2MetaReloading);if(null==t)return void this._addNodeMeta(e.index,null);const s=this._addTasks.get(e.index),{geometryData:r,transformedGeometry:o,globalTrafo:n}=t;await this.i3sOverrides.applyAttributeOverrides(r.featureIds,s.attributeInfo,i,this._controller.requiredAttributes);const a=null!=t.textureData?t.textureData.filter((e=>null!=e&&!!(e.usage&this.rendererTextureUsage))):[];!has("disable-feature:i3s-basis")&&a.some((e=>null!=e&&(e.encoding===Re.Basis||e.encoding===Re.KTX2)))&&await It(),e.memory=0;const{componentOffsets:l,geometries:d,featureIds:h,anchorIds:c,anchors:u}=r,_=this._collection,g=d[0],{layout:m,indices:p,interleavedVertexData:f,positionData:b,hasColors:y}=o,{material:v,geometryParameters:w}=this._materialParameters(g,m),R=l||new Uint32Array([0,p?p.length:f.byteLength/m[0].stride]),S={vertices:{data:f,count:f.byteLength/m[0].stride,layoutParameters:w},positionData:{positions:Z(b.data),indices:ee(b.indices)},indices:p,componentOffsets:R},T=g.transformation?O(g.transformation):j();x(T,n,T);const N=E(P(),T),V=I(C(),T),F=this.view.renderSpatialReference,H=this.view.basemapTerrain.spatialReference,G=gt.fromData(t.geometryObbData).center,k=[1,1,1];L(G,F,k,H)||Ot().errorOnce("Unsupported coordinate system for IM overlay");const B=P();W(G,F,B,H);const q=C();M(q,V);const z=P();A(z,D(z,G,N),q);const K=B[0]-z[0]*k[0],$=B[1]-z[1]*k[1],Q=_.createObject(new ft(U(K,$,k[0],k[1]),new yt(N,V),gt.fromData(t.geometryObbData),S)),X=w.textureCoordinates===vt.Atlas,{textures:Y,texturePromise:J}=this._initMaterialAndTextures(Q,v,a,X);e.memory+=this._memEstimateGeometryAdded(Q),e.memory+=Y.reduce(((e,t)=>e+(null!=t?this._memEstimateTextureAdded(t):0)),0);const te=!!v.hasParametersFromSource,ie="blend"!==v.alphaMode&&v.metallicRoughness.baseColorFactor[3]>=1,se=new wt(e,h,Q,this._getInvalidRendererVersion(),s.attributeInfo,{hasParametersFromSource:te,isOpaque:ie},Y,c,u);s.meta=se,!this._hasTextures&&t.requiredTextures?.some((({usage:e})=>!!(e&we.ColorTextures)))&&(this._hasTextures=!0),this._hasData=!0,this._hasColors=this._hasColors||y,this._hasTextures=this._hasTextures||!!e.resources.texture,this.notifyChange("hasTexturesOrVertexColors");const re=this.slicePlaneEnabled;return Promise.all([this._addOrUpdateEdgeRendering(se),J]).then((([t,s])=>(this._addTasks.has(e.index)&&t?.updateObjectVisibility(se.objectHandle,!1).catch((e=>Tt(e,this.i3slayer.title))),this._safeReschedule((()=>{const i=this._addTasks.get(e.index);if(!i)return;if(this._addNodeMeta(e.index,se),i.meta=null,!this.contentVisible)return void this._removeNodeStageData(e.index,this.elevationOffset);_.setObjectVisibility(Q,!0),t?.updateObjectVisibility(se.objectHandle,!0).catch((e=>Tt(e,this.i3slayer.title))),se.attributeInfo=i.attributeInfo;const s=se.cachedRendererVersion!==this._rendererVersion,r=re!==this.slicePlaneEnabled;this._updateElevationOffsets(se);const o=se.elevationOffsets;this._updateComponentData(se);const n=this._applyFiltersToNode(se);(s||null!=t&&(r||n||o))&&this._addOrUpdateEdgeRendering(se),null!=this._labeler&&this._addMetaToLabeler(this._labeler,se),this._visibleGeometryChanged(se,Nt.ADD),this._highlights.objectCreated(se),this._updateMaterial(se),this._setNewNodeOpacity(se),null!=this._treeDebugger&&this._treeDebugger.update()}),i)))).catch((e=>{throw null!=s.meta&&(this._cacheGPUData(s.meta),s.meta=null),e}))}_addNodeMeta(e,t){if(this._removeNodeStageData(e,this.elevationOffset,this._nodeId2MetaReloading),this._nodeId2Meta.has(e)){Ot().error("Removing duplicated node");const t=this._nodeId2Meta.get(e);null!=t&&this._deleteComponentObject(t)}else this._controller.updateLoadStatus(e,!0);null!=t&&(t.lodCrossfadeProgress=null,this.nodeCrossfadingEnabled&&$t(t.cachedEdgeMaterials,0)),this._nodeId2Meta.set(e,t),this.notifyChange("elevationRange")}_updateElevationOffsets(e){const t=this.view.renderSpatialReference,i=this._controller.crsIndex,s=this.elevationInfo,r=this.view.basemapTerrain,o=r.spatialReference,n=s.mode;if(null==t||null==o||n===ye.Absolute)return void(e.elevationOffsets=null);const a=this._collection.getObjectTransform(e.objectHandle);e.elevationOffsets=e.elevationOffsets??[];const l=Xt,d=Yt,h=n===ye.OnTheGround,c=this.view.renderCoordsHelper,u=e.featureIds.length,_=(()=>{if(e.cachedElevationAnchors)return e.cachedElevationAnchors;const s=J(3*u);e.cachedElevationAnchors=s;for(let r=0;r<u;r++){const n=3*r,h=e.anchorIds?.indexOf(r)??-1;e.anchors&&h>=0?(R(l,e.anchors[3*h],e.anchors[3*h+1],e.anchors[3*h+2]),T(l,l,te(e.node.serviceMbsInIndexSR)),W(l,i,l,o),s[n]=l[0],s[n+1]=l[1],s[n+2]=c.getAltitude(l)):(this._collection.getComponentAabb(e.objectHandle,r,d,!0),R(l,(d[0]+d[3])/2,(d[1]+d[4])/2,d[2]),A(l,l,a.rotationScale),T(l,l,a.position),s[n+2]=c.getAltitude(l),W(l,t,l,o),s[n]=l[0],s[n+1]=l[1])}return s})(),g=s.offset,m=e.elevationOffsets,p=(e,t)=>{const i=h?_[3*e+2]:0;m[e]=g+(null!=t?t-i:0)};r.getElevations(_,u,p)}_ensureElevationTask(){return null!=this._elevationTask||(this._elevationTask=new Ae(this.view.resourceController.scheduler,(e=>{const t=this._controller.updateElevationChanged(e,this.view.basemapTerrain.spatialReference);return null!=t?t.filterInPlace((e=>null!=this._nodeId2Meta.get(e))):null}),(e=>{const t=this._nodeId2Meta.get(e);this._nodeElevationAlignmentChanged(t)}),(()=>this.elevationInfo?.mode))),this._elevationTask}_elevationInfoChanged(e,t){const i=e.mode!==ye.Absolute,s=!!t&&t!==e&&t.mode!==ye.Absolute;this._intersectionHandler.updateElevationAlignState(i,this.view.state.viewingMode),i&&!s&&this._controller.removeAllGeometryObbs(),this._nodeId2Meta.forEach((e=>this._nodeElevationAlignmentChanged(e)))}_nodeElevationAlignmentChanged(e){null!=e&&(this._updateElevationOffsets(e),this._updateComponentData(e),this._updateEdgeRendering(e),null!=this._labeler&&this._labeler.updateLabelPositions(e),this._updateSnappingSources(e,Nt.UPDATE))}_safeReschedule(e,t){return _(t),this._controller.reschedule(e,t)}_materialParameters(e,t){const i=null!=e.params.material?e.params.material:He(),s=t.some((e=>"uvRegion"===e.name)),r=t.some((e=>"normalCompressed"===e.name)),o=kt(i);return{geometryParameters:this._getGeometryParameters({hasTexture:o,hasNormals:r,hasRegions:s}),material:i}}_initMaterialAndTextures(e,t,i,s){const r=this._stage.renderView,o=i.map((e=>Ue(e,t,s,r)));this._stage.addMany(o);let n=null;return this._collection.updateMaterial(e,(e=>{n=Ge(e,t,o,i,this.view._stage.renderView.textures,{rendererTextureUsage:this.rendererTextureUsage,usePBR:this._usePBR,isIntegratedMesh:this._isIntegratedMesh,slicePlaneEnabled:this.slicePlaneEnabled,viewSpatialReference:this.view.spatialReference}),this._updateMaterialOverlay(e)})),{textures:o,texturePromise:n}}_getGeometryParameters(e){return{textureCoordinates:e.hasTexture?e.hasRegions?vt.Atlas:vt.Default:vt.None,colors:this._hasVertexColors,hasNormals:e.hasNormals&&this._needsNormals,needsNormals:this._needsNormals}}_addData(e,t,i){let s=this._addTasks.get(e.index);return s?s.attributeInfo=t:(s={...g(),attributeInfo:t,meta:null},this._addTasks.set(e.index,s),i().then(s.resolve,s.reject).then((()=>this._addTasks.delete(e.index))).catch((t=>{throw this._addTasks.delete(e.index),t}))),s.promise}_clearAddTasks(){this._addTasks.forEach((e=>{null!=e.meta&&(this._cacheGPUData(e.meta),e.meta=null)})),this._addTasks.clear()}_clippingAreaChanged(){const e=this.view.renderSpatialReference,t=this.i3slayer.spatialReference,i=X();this._renderClippingArea=_t(this.view.clippingArea,i,e)?i:null;const s=X();this._layerClippingArea=_t(this.view.clippingArea,s,t)?s:null,this._filterChange(),this._controller&&this._controller.updateClippingArea(this.view.clippingArea),this._isIntegratedMesh&&this._modificationsChanged()}get hasGeometryFilter(){return!1}_geometryFilterChange(){const e=this.hasGeometryFilter;this._controller.geometryFilterChanged(e),this._applyFilters(e)}_filterChange(){this._applyFilters(this.hasGeometryFilter)}_applyFilters(e){this._filters=this.getFilters(),e?this._controller&&this._controller.requestUpdate():this._nodeId2Meta.forEach((e=>{null!=e&&this._applyFiltersToNode(e)&&(this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Nt.UPDATE))}))}getFilters(){const e=[],t=this._renderClippingArea;return null!=t&&e.push(((e,i)=>this._boundingRectFilter(e,i,t))),e}addSqlFilter(e,t,i){if(null!=t){const s=t.fieldNames;e.push(((e,r)=>this._sqlFilter(e,r,t,s,i)))}}_sqlFilter(e,t,i,s,r){const o={},n=this._createLayerGraphic(o),a=this.i3slayer.objectIdField,l=t.featureIds,d=t.attributeInfo?.attributeData;s.every((e=>e===a||null!=d?.[e]))&&Ye(e,l,(e=>{o[a]=l[e];for(const i of s)i!==a&&(o[i]=d?Je(d[i],e):null);try{return i.testFeature(n)}catch(t){return r(t),!1}}))}_boundingRectNodeTest(e,t){return k(e.node.serviceMbsInIndexSR,this._controller.crsIndex,Lt,this.view.renderSpatialReference),Ze(t,Lt)}_boundingRectFeatureTest(e,t,i){return this._collection.getComponentAabb(e.objectHandle,t,Vt),Q(Vt,Ft),Y(i,Ft)}_boundingRectFilter(e,t,i){const s=this._collection,r=this._boundingRectNodeTest(t,i);if(r===et.INSIDE)return;if(r===et.OUTSIDE)return void(e.length=0);const o=s.getComponentCount(t.objectHandle);if(o.invisible+o.visible!==t.featureIds.length)return;const n=this._transformClippingArea(Pt,i,t.objectHandle);Ye(e,t.featureIds,(e=>this._boundingRectFeatureTest(t,e,n)))}_transformClippingArea(e,t,i){const s=this._collection.getObjectTransform(i),r=s.position,o=s.rotationScale;return e[0]=(t[0]-r[0])/o[0],e[1]=(t[1]-r[1])/o[4],e[2]=(t[2]-r[0])/o[0],e[3]=(t[3]-r[1])/o[4],e}async _addOrUpdateEdgeRendering(e,t=!0){const i=e.objectHandle,{hasEdges:s,perFeatureEdgeMaterials:r}=this._getFilteredEdgeMaterials(e);s&&!this._edgeView&&(this._edgeView=await this._stage.renderer.loadEdgeView());const o=this._edgeView;if(!o)return null;const n=o.hasObject(i);if(s){if(n){if(this.nodeCrossfadingEnabled){$t(r,this.getNodeOpacity(e))}return o.updateAllComponentMaterials(i,r,this.slicePlaneEnabled,t).catch((e=>Tt(e,this.i3slayer.title))),o.updateObjectVisibility(i,!0).catch((e=>Tt(e,this.i3slayer.title))),o.updateAllVerticalOffsets(i,e.elevationOffsets).catch((e=>Tt(e,this.i3slayer.title))),o}const s=await this._collection.addEdges(i,o,r,this.slicePlaneEnabled,e.elevationOffsets);return e.edgeMemoryUsage=s,e.node.memory+=s,o}return n&&(e.node.memory-=e.edgeMemoryUsage,e.edgeMemoryUsage=0,o.removeObject(i)),null}_applyFiltersToNode(e){return!!this._applyFiltersToNodeComponents(e)&&(null!=this._labeler&&this._labeler.applyFilterChange(e),!0)}_applyFiltersToNodeComponents(e){const t=this._collection,i=t.getComponentCount(e.objectHandle),s=null!=e.filteredIds,r=0===i.invisible;if(t.setAllComponentVisibilities(e.objectHandle,"all"),0===this._filters.length)return e.filteredIds=null,!r;if(this._updateCachedFilteredIds(e),s&&e.filteredIds===e.featureIds)return!r;const o=this._computeFilteredComponentIndices(e);return t.setAllComponentVisibilities(e.objectHandle,o),!0}_updateCachedFilteredIds(e){null!=e.filteredIds&&e.appliedFilters===this._filters||(e.filteredIds=this._computeFilteredIds(e),e.appliedFilters=this._filters)}_computeFilteredIds(e){const t=e.featureIds.slice();for(const i of this._filters)if(i(t,e),0===t.length)break;return t.length===e.featureIds.length?e.featureIds:t}_computeFilteredComponentIndices(e){const t=new Array,i=e.filteredIds;return null!=i&&e.featureIds.forEach(((e,s)=>{i[t.length]===e&&t.push(s)})),t}_removeAllNodeDataFromStage(e=this.elevationOffset){this._nodeId2Meta.forEach(((t,i)=>this._removeNodeStageData(i,e))),this._nodeId2MetaReloading.forEach(((t,i)=>this._removeNodeStageData(i,e,this._nodeId2MetaReloading))),this._elevationTask=d(this._elevationTask)}removeNode(e){const t=this.elevationOffset;this._removeNodeStageData(e,t),this._removeNodeStageData(e,t,this._nodeId2MetaReloading),null!=this._elevationTask&&this._elevationTask.remove(e)}_removeNodeStageData(e,t,i=this._nodeId2Meta){i.has(e)&&this._controller.updateLoadStatus(e,!1);const s=i.get(e);null!=s?(this._collection.setObjectVisibility(s.objectHandle,!1),null!=this._edgeView&&this._edgeView.hasObject(s.objectHandle)&&this._edgeView.updateObjectVisibility(s.objectHandle,!1).catch((e=>Tt(e,this.i3slayer.title))),this._visibleGeometryChanged(s,Nt.REMOVE),null!=this._labeler&&this._labeler.removeNodeMeta(s),i.delete(e),this._highlights.objectDeleted(s),i===this._nodeId2Meta?(this._cacheGPUData(s,t),this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopNodeFading(s)):this._deleteComponentObject(s),null!=this._treeDebugger&&this._treeDebugger.update()):i.delete(e)}_deleteComponentObject(e){if(null!=this._edgeView&&this._edgeView.removeObject(e.objectHandle),this._memEstimateGeometryRemoved(e.objectHandle),this._collection.destroyObject(e.objectHandle),e.textures)for(const t of e.textures)this._memEstimateTextureRemoved(t),this._stage.remove(t)}updateNodeState(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._collection.updateMaterial(i.objectHandle,(e=>e.polygonOffsetEnabled=t===ke.Hole))}updateNodeIndex(e,t){if(this._nodeId2Meta.has(e)){const i=this._nodeId2Meta.get(e);this._nodeId2Meta.delete(e),this._nodeId2Meta.set(t,i),this.notifyChange("elevationRange")}const i=this._nodeId2MetaReloading.get(e);i&&(this._nodeId2MetaReloading.delete(e),this._nodeId2MetaReloading.set(t,i))}_invalidateAllSymbols(){this._rendererVersion=tt(this._rendererVersion,1),this._controller&&this._controller.requestUpdate()}_getInvalidRendererVersion(){return tt(this._rendererVersion,-1)}async _rendererChange(e){if(this._currentRenderer=e,this.notifyChange("rendererTextureUsage"),this._rendererVersion=tt(this._rendererVersion,1),this._rendererFields=null,this._colorVariable=null,this._opacityVariable=null,this._invalidateAllSymbols(),e&&(this._rendererFields=await e.getRequiredFields(this.i3slayer.fieldsIndex)),this._updateSymbologyFields(),!this._arcade&&e&&"arcadeRequired"in e&&e.arcadeRequired&&(this._arcade=await ce()),e&&"visualVariables"in e&&e.visualVariables)for(const t of e.visualVariables)"color"===t.type?this._colorVariable=t:"opacity"===t.type?this._opacityVariable=t:Ot().warn(`Unsupported visual variable type for 3D Object Scene Services: ${t.type}`);if(e)for(const t of e.getSymbols())"mesh-3d"!==t.type&&Ot().error(`Symbols of type '${t.type}' are not supported for 3D Object Scene Services.`);this._controller&&this._controller.requestUpdate()}_getCachedEdgeMaterials(e){return this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e),e.cachedEdgeMaterials}_getComponentParameters(e){this._hasComponentData&&e.cachedRendererVersion!==this._rendererVersion&&this._updateCachedRendererData(e);const t=e.cachedSymbology;return(i,s)=>{const r=5*i;if(H(s.externalColor,t[r]/255,t[r+1]/255,t[r+2]/255,t[r+3]/255),null!=this._stage.renderView.objectAndLayerIdRenderHelper){const t=e.featureIds[i],r=ue(this.view.map,this.layerUid);this._stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(t,t,this.layerId,this.layerUid+"_"+this.sublayerId,this.layerPopupEnabledAndHasTemplate&&!r,e.node.resources.attributes,i,this.sublayerId),s.objectAndLayerIdColor=this._stage.renderView.getObjectAndLayerIdColor({graphicUid:t,layerUid:this.layerUid+"_"+this.sublayerId})}s.externalColorMixMode=t[r+4]&(1<<Rt.CastShadows)-1,s.castShadows=!!(t[r+4]&1<<Rt.CastShadows),s.pickable=!!(t[r+4]&1<<Rt.Pickable),s.elevationOffset=e.elevationOffsets?.[i]??0}}_getSymbolInfo(e,t){const i=e?.getSymbol(t,{arcade:this._arcade});if(!(i instanceof ge))return null;const s=i.id;if(this._symbolInfos.has(s))return this._symbolInfos.get(s);const r=it(i);return this._symbolInfos.set(s,r),r}_setSymbologyOverride(e,t){this._symbologyOverride!==e&&(this._symbologyOverride=e,this._symbologyOverrideFields=t,this._invalidateAllSymbols(),this._updateSymbologyFields())}_updateSymbologyFields(){this._symbologyFields=null!=this._symbologyOverrideFields&&this._symbologyOverrideFields.length>0?null!=this._rendererFields&&this._rendererFields.length>0?ae(this.i3slayer.fieldsIndex,[...this._rendererFields,...this._symbologyOverrideFields]):this._symbologyOverrideFields:this._rendererFields}_updateCachedRendererData(e){if(e.cachedRendererVersion=this._rendererVersion,!this._hasComponentData)return;const t=this._tmpAttributeOnlyGraphic,i={};t.attributes=i;const s=this._currentRenderer,r=e.attributeInfo?.attributeData,o=null!=e.featureIds?this.i3slayer.objectIdField:null,n=null!=r&&null!=this._symbologyFields&&this._symbologyFields.length>0;let a=null,l=null;if(n&&null!=this._symbologyFields){a=[],l=[];for(const e of this._symbologyFields){const t=r[e];t&&(a.push(e),l.push(t))}}e.cachedSymbology||(e.cachedSymbology=re(5*e.featureIds.length));const d={color:Ut,castShadows:!0,pickable:!0,colorMixMode:ht.Multiply,edgeMaterial:null},h=this.fullOpacity,c=this.nodeCrossfadingEnabled?this.getNodeOpacity(e):h;let u=null,_=Mt.OPAQUE,g=st,m=0;for(let p=0;p<e.featureIds.length;p++){if(null!=o&&(i[o]=e.featureIds[p]),n&&a)for(let e=0;e<a.length;e++)i[a[e]]=Je(l[e],p);const r=s?this._getSymbolInfo(s,t):null;let h=null,f=null;if(s&&"visualVariables"in s){if(this._colorVariable){const e=de(this._colorVariable,t,{color:Gt,arcade:this._arcade});e&&(h=Ut,h[0]=e.r/255,h[1]=e.g/255,h[2]=e.b/255,this._opacityVariable||null===e.a||(f=e.a))}this._opacityVariable&&(f=he(this._opacityVariable,t,{arcade:this._arcade}))}if(r?.material){const e=r.material;h=null==h||null==f?Oe(h,f,e.color,e.alpha,jt,Ut):Oe(h,f,null,null,jt,Ut)}if(null==h&&(h=Ut,h[0]=1,h[1]=1,h[2]=1,h[3]=1),d.pickable=!0,d.castShadows=!r||r.castShadows,d.colorMixMode=r?.material?r.material.colorMixMode:ht.Multiply,d.edgeMaterial=r?r.edgeMaterial:null,null!=this._symbologyOverride&&(d.color=h,this._symbologyOverride(t,d),h=d.color),null!=this._nodeColorOverride&&(this._nodeColorOverride(e.node,h),d.colorMixMode=ht.Replace),null!=d.edgeMaterial){const t=h[3]>=1&&(e.material.isOpaque||d.colorMixMode===ht.Replace)?Mt.OPAQUE:Mt.TRANSPARENT;d.edgeMaterial===u&&t===_||(g={...d.edgeMaterial,opacity:c,objectTransparency:t},u=d.edgeMaterial,_=t),e.cachedEdgeMaterials[p]=g}else e.cachedEdgeMaterials[p]=st;e.cachedSymbology[m++]=Math.round(255*h[0]),e.cachedSymbology[m++]=Math.round(255*h[1]),e.cachedSymbology[m++]=Math.round(255*h[2]),e.cachedSymbology[m++]=Math.round(255*h[3]),e.cachedSymbology[m++]=d.colorMixMode|+d.castShadows<<Rt.CastShadows|+d.pickable<<Rt.Pickable}}_getFilteredEdgeMaterials(e){const t=this._getCachedEdgeMaterials(e);this.nodeCrossfadingEnabled||$t(t,this.fullOpacity);const i=e.filteredIds;if(null==i){return{hasEdges:t.some((e=>e!==st)),perFeatureEdgeMaterials:t}}let s=0,r=!1;const o=t.map(((t,o)=>e.featureIds[o]!==i[s]?st:(r=r||t!==st,s++,t)));return{hasEdges:r,perFeatureEdgeMaterials:o}}_updateComponentData(e){if(!this._hasComponentData)return;const t=e.objectHandle,i=this._getComponentParameters(e);this._collection.setComponentData(t,i),this._stage.renderView.requestRender()}_reloadAll(e=this.elevationOffset){this._removeAllNodeDataFromStage(e),null!=this._controller&&this._controller.restartNodeLoading()}_opacityChange(e){this.nodeCrossfadingEnabled&&this._crossfadeHelper.stopAllNodeFading(),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.objectOpacity=e)),$t(t.cachedEdgeMaterials,e),this._updateEdgeRendering(t))}))}_updateMaterial(e){this._collection.updateMaterial(e.objectHandle,(e=>{e.commonMaterialParameters.hasSlicePlane=this.slicePlaneEnabled,e.usePBR=this._usePBR,this._updateMaterialOverlay(e)}))}_updateMaterialOverlay(e){}_updateEngineObject(e){this._updateComponentData(e),this._applyFiltersToNode(e),this._addOrUpdateEdgeRendering(e),this._visibleGeometryChanged(e,Nt.UPDATE)}_slicePlaneEnabledChange(e){this._intersectionHandler&&(this._intersectionHandler.slicePlaneEnabled=e),null!=this._labeler&&(this._labeler.slicePlaneEnabled=e),this._nodeId2Meta.forEach((t=>{null!=t&&(this._collection.updateMaterial(t.objectHandle,(t=>t.commonMaterialParameters.hasSlicePlane=e)),this._updateEdgeRendering(t,!1))}))}_updatePBR(e){this._nodeId2Meta.forEach((t=>{null!=t&&this._collection.updateMaterial(t.objectHandle,(t=>t.usePBR=e))})),this._hasLoadedPBRTextures=!0}get _usePBR(){return this._needsNormals&&this.view.qualitySettings.physicallyBasedRenderingEnabled}_updateEdgeRendering(e,t=!0){null!=this._edgeView&&this._edgeView.hasObject(e.objectHandle)&&this._addOrUpdateEdgeRendering(e,t)}_forAllNodes(e){this._nodeId2Meta.forEach(e)}_ignoreClientNodeOverriddenFeatures(e){return this.i3sOverrides.hasGeometryChanges?(t,i,s)=>s.node.index>=0&&this.i3sOverrides.featureHasGeometryChanges(t)?ve.CONTINUE:e(t,i,s):e}_forAllFeatures(e,t,i){for(const s of this._nodeId2Meta.values()){if(null==s)continue;if(null!=t){switch(t(s)){case ve.EXIT:return;case ve.SKIP:continue}}let r=ve.CONTINUE;switch(i){case Ie.ALL:r=this._forAllFeaturesOfNode(s,e);break;case Ie.VISIBLE_ONLY:r=this._forAllVisibleFeaturesOfNode(s,e);break;case Ie.QUERYABLE:r=this._forAllQueryableFeaturesOfNode(s,e)}if(r===ve.EXIT)return}}_forAllFeaturesOfNode(e,t){let i=ve.CONTINUE;const s=e.featureIds;for(let r=0;r<s.length;r++)if(i=t(s[r],r,e),i===ve.EXIT)return i;return i}_forAllVisibleFeaturesOfNode(e,t){let i=ve.CONTINUE;const s=e.featureIds;return this._collection.forEachVisibleComponent(e.objectHandle,(r=>(i=t(s[r],r,e),i===ve.CONTINUE))),i}_forAllQueryableFeaturesOfNode(e,t){const i=this._ignoreClientNodeOverriddenFeatures(t);if(null==this._renderClippingArea)return this._forAllFeaturesOfNode(e,i);const s=this._boundingRectNodeTest(e,this._renderClippingArea);if(s===et.OUTSIDE)return ve.CONTINUE;if(s===et.INSIDE)return this._forAllFeaturesOfNode(e,i);const r=ve.CONTINUE,o=e.featureIds,n=e.objectHandle,a=rt(this._renderClippingArea,this._collection.getObjectTransform(n));for(let l=0;l<o.length;l++){if(!this._boundingRectFeatureTest(e,l,a))continue;const t=i(o[l],l,e);if(t===ve.EXIT)return t}return r}_createAttributes(e,t){const i={};null!=t.featureIds&&(i[this._getObjectIdField()]=t.featureIds[e]);const s=t.attributeInfo?.attributeData;if(null!=s)for(const r of Object.keys(s))i[r]=Je(s[r],e);return i}_createGraphic(e,t){return this._createLayerGraphic(this._createAttributes(e,t))}highlight(e,t=Ct){if("number"==typeof e||e instanceof i?e=[e]:e instanceof n&&(e=e.toArray()),Array.isArray(e)&&e.length>0){if(e[0]instanceof i){const i=e,s=this.i3slayer.fieldsIndex,r=this._getObjectIdField(),o=i.map((e=>lt(s,e.attributes,r))),{set:n,handle:a}=this._highlights.acquireSet(t);return this._highlights.setFeatureIds(n,o,t),a}if("number"==typeof e[0]){const i=e,{set:s,handle:r}=this._highlights.acquireSet(t);return this._highlights.setFeatureIds(s,i,t),r}}return a()}resetHighlights(){d(this._highlights),this._highlights=new Se({collection:this._collection,forAllFeatures:e=>this._forAllFeatures(e,null,Ie.ALL),forAllFeaturesOfNode:(e,t)=>this._forAllFeaturesOfNode(e,t)})}_visibleGeometryChanged(e,t){if(!this._elevationProvider)return;const i=this.getNodeComponentObb(e.node);i&&this._elevationProvider.objectChanged(i),null==this._visibleGeometryChangedSchedulerHandle&&(this._visibleGeometryChangedSchedulerHandle=f((()=>{this.emit("visible-geometry-changed"),this._visibleGeometryChangedSchedulerHandle=null}))),this._updateSnappingSources(e,t)}get performanceInfo(){return new pe(this.usedMemory,this._nodeId2Meta.size,Math.round(this._gpuMemoryEstimate/1048576),Math.round(this._geoMemoryEstimate/1048576),Math.round(this._texMemoryEstimate/1048576),Math.round(this.unloadedMemory/1048576),this._idbCacheEnabled?Math.round(100*this._idbCache.getHitRate()):0)}get test(){}getNodeOpacityByIndex(e){const t=this._nodeId2Meta.get(e);return this.getNodeOpacity(t)}getNodeOpacity(e){return null!=e?this._collection.getMaterial(e.objectHandle).objectOpacity:0}isNodeFullyFadedIn(e){return this._crossfadeHelper.isNodeFullyFadedIn(e)}getNodeCrossfadeMetaData(e){return this._nodeId2Meta.get(e)}markNodeToRemove(e){this._controller&&this._controller.markNodeToRemove(e)}removeMarkedNodes(){this._controller&&this._controller.removeMarkedNodes()}foreachCrossfadeNode(e){this._nodeId2Meta.forEach(e)}fadeNode(e,t,i){if(!this.nodeCrossfadingEnabled)return;const s=this._nodeId2Meta.get(e);null!=s&&this._crossfadeHelper.fadeNode(e,s,t,i)}setNodeOpacityByIndex(e,t){const i=this._nodeId2Meta.get(e);null!=i&&this._setNodeOpacity(i,t)}_setNodeOpacity(e,t){this._collection.updateMaterial(e.objectHandle,(e=>e.objectOpacity=t)),this._setNodeEdgeOpacity(e,t)}_setNodeEdgeOpacity(e,t){if(null==this._edgeView||!e.cachedEdgeMaterials)return;$t(e.cachedEdgeMaterials,t);const i=e.objectHandle;this._edgeView.hasObject(i)&&this._edgeView.updateAllComponentOpacities(i,t).catch((e=>Tt(e,this.i3slayer.title)))}get hasModifications(){return this._isIntegratedMesh&&null!=this._layerClippingArea||this._modifications&&this._modifications.length>0}updateNodeModificationStatus(e){const t=e.length;if(!this.hasModifications||t<=0||!0!==this._i3sWasmLoaded)return;const i=this.uid,s=Kt(e);if(s){const t={context:i,buffer:s.buffer};xe(t);const r=new Float64Array(s.buffer);e.forAll(((e,t)=>{const i=r[t],s=Ee(i);e.imModificationImpact=s,s!==Le.Unmodified&&this._controller.invalidateGeometryVisibility(e.index)}))}}notifyUpdate(){this.notifyChange("updating")}notifyLODUpdate(){this._controller.notifyLODUpdate()}isUpdating(){return!(!this._controller||!this._controller.updating)||!!this._visibleGeometryChangedSchedulerHandle||null!=this._labeler&&this._labeler.updating||this._crossfadeHelper?.updating||this._i3sWasmLoaded instanceof Promise||this._asyncModuleLoading>0||null!=this._elevationTask&&this._elevationTask.running}trackSnappingSources(e){const t={events:e,fetchEdgeLocations:async(e,t,i)=>{const s=this._nodeId2Meta.get(e);if(null==s)throw new Error("invalid-node");const{origin:r,buffer:o}=await this._collection.extractEdgeInformation(s.objectHandle,t,i);return this._snappingLocationsApplyElevation(s,o,r),{type:"components",objectIds:s.featureIds,locations:o,origin:r}},remove:()=>r(this._snappingSourcesTrackers,t)};return this._snappingSourcesTrackers.push(t),this._nodeId2Meta.forEach(((t,i)=>{if(null==t)return;const s=this._controller.getRenderMbs(t.node);s&&e.add(i,s)})),t}_snappingLocationsApplyElevation(e,t,i){if(!e.elevationOffsets||this.elevationInfo.mode===ye.Absolute)return;const s=t.position0,r=t.position1,o=t.componentIndex,n=P(),a=P(),l=(e,t)=>{T(e,e,i),this.view.renderCoordsHelper.worldUpAtPosition(e,a),T(e,e,N(a,a,t)),V(e,e,i)};for(let d=0;d<s.count;d++){const t=e.elevationOffsets[o.get(d)];s.getVec(d,n),l(n,t),s.setVec(d,n),r.getVec(d,n),l(n,t),r.setVec(d,n)}}_updateSnappingSources(e,t){const{index:i}=e.node,s=this._controller.getRenderMbs(e.node);if(null!=s)for(const r of this._snappingSourcesTrackers)t!==Nt.REMOVE&&t!==Nt.UPDATE||r.events.remove(i),t!==Nt.ADD&&t!==Nt.UPDATE||r.events.add(i,s)}};return e([y()],o.prototype,"_hasLoadedPBRTextures",void 0),e([y()],o.prototype,"_asyncModuleLoading",void 0),e([y()],o.prototype,"_visibleGeometryChangedSchedulerHandle",void 0),e([y()],o.prototype,"view",void 0),e([y()],o.prototype,"i3slayer",void 0),e([y()],o.prototype,"_controller",void 0),e([y()],o.prototype,"_labeler",void 0),e([y()],o.prototype,"updating",void 0),e([y()],o.prototype,"suspended",void 0),e([y()],o.prototype,"contentVisible",null),e([y({readOnly:!0})],o.prototype,"legendEnabled",null),e([y()],o.prototype,"holeFilling",void 0),e([y(mt)],o.prototype,"updatingProgress",void 0),e([y()],o.prototype,"updatingProgressValue",null),e([y()],o.prototype,"hasTexturesOrVertexColors",null),e([y()],o.prototype,"rendererTextureUsage",null),e([y()],o.prototype,"elevationOffset",null),e([y()],o.prototype,"elevationInfo",null),e([y({type:Boolean})],o.prototype,"slicePlaneEnabled",void 0),e([y()],o.prototype,"supportedTextureEncodings",null),e([y()],o.prototype,"uncompressedTextureDownsamplingEnabled",null),e([y({type:[le]})],o.prototype,"_modifications",void 0),e([y({readOnly:!0})],o.prototype,"clientGeometry",null),e([y()],o.prototype,"elevationRange",null),e([y()],o.prototype,"fullExtent",null),e([y()],o.prototype,"_elevationTask",void 0),e([y({readOnly:!0})],o.prototype,"_usePBR",null),o=e([v(Et)],o),o};function Tt(e,t){u(e)||Ot().warn("Error while processing edges. Edges on this layer might not display correctly",t,e)}var Nt;!function(e){e[e.ADD=0]="ADD",e[e.REMOVE=1]="REMOVE",e[e.UPDATE=2]="UPDATE"}(Nt||(Nt={}));const Vt=z(),Ft=X(),Pt=X(),Ht=new gt,Ut=[0,0,0,0],Gt=new t([0,0,0,0]),Lt=ie(0,0,0,0);function kt(e){if(null==e)return!1;const t=e.metallicRoughness;return t&&t.baseColorTextureId>=0||t&&t.metallicRoughnessTextureId>=0||e.normalTextureId>=0||e.emissiveTextureId>=0||e.occlusionTextureId>=0}function Bt(e){return"geometryData"in e}function qt(e){return null!=e&&b(e.data)}function Wt(e,t){let i=1024+e.interleavedVertexData.byteLength+(e.indices?e.indices.byteLength:0)+e.positionData.data.byteLength+e.positionData.indices.byteLength;if(null!=t)for(const s of t)null!=s&&b(s.data)&&(i+=s.data.byteLength);return i}function zt(e,t){return t.byteSize>At?(Ot().warn(`Node is too big to store in IndexedDB cache: ${e.id} (${t.byteSize} bytes)`),!1):t.byteSize>0}function Kt(e){if(0===e.length)return;const t=10*e.length,i=new Float64Array(t);let s=0;return e.forAll((e=>{let t=e.serviceObbInIndexSR;null==t&&(t=Ht,t.center=te(e.serviceMbsInIndexSR),t.halfSize=[e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3],e.serviceMbsInIndexSR[3]]);const r=t.data;i[s++]=r[0],i[s++]=r[1],i[s++]=r[2],i[s++]=r[3],i[s++]=r[4],i[s++]=r[5],i[s++]=r[6],i[s++]=r[7],i[s++]=r[8],i[s++]=r[9]})),i}function $t(e,t){e.forEach((e=>e.opacity=t))}class Qt{constructor(e,t){this.mode=e,this.offset=t}}const Xt=P(),Yt=z(),Jt="elevation-change",Zt=[[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0],[0,0,0]],ei=new ut;function ti(e,t,i){let s=e.elevationRangeMin,r=e.elevationRangeMax;const o=i;if(o>0){t.getCorners(Zt);for(const e of Zt){const t=F(e)-o;s=Math.min(s,t),r=Math.max(r,t)}}else{t.getCorners(Zt);for(const e of Zt){const t=e[2];s=Math.min(s,t),r=Math.max(r,t)}}e.expandElevationRangeValues(s,r)}function ii(e,t,i){const s=te(t),r=i>0?F(s)-i:s[2],o=se(t);e.expandElevationRangeValues(r-o,r+o)}export{Dt as I3SMeshView3D};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import t from"../../../../core/Error.js";import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as i,invertOrIdentity as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{c,n as m,s as p,f as h,b as g,h as d,z as u}from"../../../../chunks/vec32.js";import{fromArray as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as _,empty as x,expandWithBuffer as S,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as P}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as E,getZeroIndexArray as M}from"../../../../geometry/support/Indices.js";import{a as O}from"../../../../chunks/vec3.js";import{makeVertexCandidate as w,makeEdgeCandidate as C}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as I}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as v}from"../../../ViewingMode.js";import{needsElevationUpdates3D as A,SampleElevationInfo as L}from"./elevationAlignmentUtils.js";import{Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as B}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as D,computeCentroid as R}from"./graphicUtils.js";import{ApplyRendererDiffResult as T}from"./interfaces.js";import{geometryAsPolygon as G}from"./polygonUtils.js";import{createMaterial as U}from"../support/edgeUtils.js";import{debugFlags as N}from"../../support/debugFlags.js";import{SamplePosition as V}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as F}from"../../support/renderInfoUtils/polygon.js";import{NormalType as k}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as H}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as W}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as q}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as Z}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as J}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as K,compressNormal as Q}from"../../webgl-engine/lib/Normals.js";import{Object3D as X}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as Y}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";const tt=["polygon","extent"];class et extends B{constructor(t,e,r,s){super(t,e,r,s),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const e=D(this._getSymbolSize());if(e)throw new t("graphics3dextrudesymbollayer:invalid-size",e)}const e=this.symbolLayer?.material?.color,r=this._getCombinedOpacityAndColor(e),s=f(r),o=r[3],n=o<1||this.needsDrivenTransparentPass,i={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:s,ambient:s,opacity:o,transparent:n,cullFace:n?W.None:W.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0,normalType:k.Compressed};this._materials[wt.Main]=new $(i),this._materials[wt.Bottom]=new $({...i,cullFace:W.Back}),this._context.stage.addMany(this._materials)}destroy(){super.destroy(),this._context.stage.removeMany(this._materials),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,tt,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(t.renderingInfo,255),s=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this.symbolLayer?.material?.color,s=this._getCombinedOpacity(r),o=s<1||this.needsDrivenTransparentPass;this._materials[wt.Main]?.setParameters({opacity:s,transparent:o}),this._materials[wt.Bottom]?.setParameters({opacity:s,transparent:o});const n=this._getLayerOpacity();t.forEach((t=>{const r=e(t);null!=r&&r.layerOpacityChanged(n,this._context.isAsync)}))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,A)}slicePlaneEnabledChanged(t,e){return this._materials[wt.Main]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[wt.Bottom]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t.forEach((t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[wt.Main]?.setParameters(t),this._materials[wt.Bottom]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?I(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?T.RecreateSymbol:T.RecreateGraphics}async queryForSnapping(t,s,o,n){const i=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/r(s),{objectId:a,target:l}=t,c=e(l);switch(c.z=(c.z??0)+i,t.type){case"edge":{const{start:r,end:s}=t,o=e(r),n=e(s);return o.z=(o.z??0)+i,n.z=(n.z??0)+i,[C(a,c,1/0,o,n)]}case"vertex":return[w(a,c,1/0),C(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,a,c){const m=G(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=F(m,this._context.elevationProvider,this._context.renderCoordsHelper,a);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=R(m);if(null==h)return null;const g=new Array,d=new Array,u=_(),f=l(),M=y(),w=this._context.renderCoordsHelper.viewingMode===v.Global;w||this._context.renderCoordsHelper.worldUpAtPosition(null,M),b(m.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const C=l();i(C,f);const I=n();o(I,C);const{polygons:L,mapPositions:B,position:D}=p,T=new Map,N=this._materials[wt.Main];for(const o of L){const t=o.count;if(this._context.clippingExtent&&(x(u),S(u,o.mapPositions),!j(u,this._context.clippingExtent)))continue;const n=s(o.mapPositions,o.holeIndices,3);if(0===n.length)continue;const i=n.length,a=6*t,l=E(a+i),m=E(i),p=P(3*a),h=P(3*a),y=P(3*a),b=P(a);st(D,B,n,o,p,y,h,b,l,m,this._getExtrusionSize(e),M,w),O(p,p,C);const _=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerUid:this._context.layer.uid}),I=new Ct(p,y,K(h),b),v=rt(N,l,l.length-m.length,I,r,_),A=t,L=t,z=2*o.count,R=new It(A,L,z,i/3);ft(v,R,f),T.set(v,R),g.push(v,rt(this._materials[wt.Bottom],m,0,I,r,_)),d.push(I.heights)}if(0===g.length)return null;const V=new X({geometries:g,layerUid:this._context.layer.uid,graphicUid:c,isElevationSource:!0});V.transformation=f;const k=U(this.symbolLayer,{opacity:this._getLayerOpacity()}),H=null!=k?{baseMaterial:this._materials[wt.Main],edgeMaterials:[k],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,W=new z(this,V,g,null,null,((t,e,r,s,o)=>ut(t,e,r,s,o,d,T)),a,H);return W.alignedSampledElevation=p.sampledElevation,W.needsElevationUpdates=A(a.mode),W}}function rt(t,e,r,s,o,n){const i=M(e.length),a=[[Y.POSITION,new H(s.positions,e,3,!0)],[Y.NORMALCOMPRESSED,new H(s.normals,e,2,!0)],[Y.COLOR,new H(o,i,4,!0)]];return new Z(t,a,s.elevation,q.Mesh,n,r)}function st(t,e,r,s,o,n,i,a,l,c,m,p,h){{const g=r.length/3,d=2*s.count;ot(t,e,s.index,s.count,r,0,g,o,n,i,a,l,c,d,m,p,h)}{let t=0,e=2*s.count,r=0;const c=s.pathLengths[0];at(o,n,a,i,t,c,s.count,e,l,r,m),e+=4*c,r+=2*c,t+=c;for(let p=1;p<s.pathLengths.length;++p){const c=s.pathLengths[p];at(o,n,a,i,t,c,s.count,e,l,r,m),e+=4*c,r+=2*c,t+=c}}}function ot(t,e,r,s,o,n,i,a,l,p,h,g,d,u,f,y,b){c(bt,y);{const o=f>0?1:-1;let n=3*r,i=0,c=3*i,g=s,d=3*g;for(let r=0;r<s;++r){const r=t[n],s=t[n+1],u=t[n+2];b&&(bt[0]=r,bt[1]=s,bt[2]=u,m(bt,bt)),a[c+0]=r,a[c+1]=s,a[c+2]=u;const y=e[n+0],_=e[n+1],x=e[n+2];l[c+0]=y,l[c+1]=_,l[c+2]=x,p[c+0]=-o*bt[0],p[c+1]=-o*bt[1],p[c+2]=-o*bt[2],h[i]=0,a[d+0]=r+f*bt[0],a[d+1]=s+f*bt[1],a[d+2]=u+f*bt[2],l[d+0]=y,l[d+1]=_,l[d+2]=x,h[g]=f,c+=3,d+=3,n+=3,i+=1,g+=1}}{let t=3*n,e=0,r=3*u;const a=f<0?St:xt,l=f<0?xt:St;for(let n=0;n<i;++n)d[e]=o[t+a[0]],d[e+1]=o[t+a[1]],d[e+2]=o[t+a[2]],g[r]=o[t+l[0]]+s,g[r+1]=o[t+l[1]]+s,g[r+2]=o[t+l[2]]+s,e+=3,r+=3,t+=3}}function nt(t,e,r,s,o,n,i){s[n]=s[i],i*=3,t[n*=3]=t[i],t[n+1]=t[i+1],t[n+2]=t[i+2],e[n]=e[i],e[n+1]=e[i+1],e[n+2]=e[i+2],r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2]}const it=y();function at(t,e,r,s,o,n,i,a,l,c,m){let p=o,h=o+1,g=o+i,d=o+i+1,u=a,f=a+1,y=a+2*n,b=a+2*n+1;m<0&&(p=o+i+1,d=o);let _=3*c;for(let x=0;x<n;++x)x===n-1&&(h=o,m>0?d=o+i:p=o+i),gt(t,p,h,g,it),nt(t,e,s,r,it,u,p),nt(t,e,s,r,it,f,h),nt(t,e,s,r,it,y,g),nt(t,e,s,r,it,b,d),l[_]=u,l[_+1]=y,l[_+2]=b,l[_+3]=u,l[_+4]=b,l[_+5]=f,_+=6,p++,h++,g++,d++,u+=2,f+=2,y+=2,b+=2}const lt=y(),ct=y(),mt=y(),pt=y(),ht=y();function gt(t,e,r,s,o){e*=3,r*=3,s*=3,p(lt,t[e++],t[e++],t[e++]),p(ct,t[r++],t[r++],t[r++]),p(mt,t[s++],t[s++],t[s++]),h(pt,ct,lt),h(ht,mt,lt),g(o,ht,pt),m(o,o)}const dt=y();function ut(t,e,r,s,o,n,i){const c=t.stageObject,m=c.geometries,h=m.length,g="absolute-height"!==e.mode;let u=0;const f=c.transformation,y=a(l(),f);for(let a=0;a<h;a+=2){const t=m[a];if(!J(t))continue;const e=t.getMutableAttribute(Y.POSITION).data,l=n[a/2],h=new V(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let n=0;n<b;n++){dt[0]=e[t],dt[1]=e[t+1],dt[2]=e[t+2],s(h,_t),g&&(x+=_t.sampledElevation),N.TESTS_DISABLE_OPTIMIZATIONS?(p(yt,h.array[h.offset],h.array[h.offset+1],_t.z+l[t/3]),null!=r&&o.toRenderCoords(yt,r,yt),d(yt,yt,y)):(p(yt,e[t],e[t+1],e[t+2]),d(yt,yt,f),o.setAltitude(yt,_t.z+l[t/3]),d(yt,yt,y)),e[t]=yt[0],e[t+1]=yt[1],e[t+2]=yt[2];const n=jt/o.unitInMeters;(Math.abs(dt[0]-e[t])>=n||Math.abs(dt[1]-e[t+1])>=n||Math.abs(dt[2]-e[t+2])>=n)&&(_=!0),h.offset+=3,t+=3}}if(_){const e=i.get(t);e&&ft(t,e,f),c.geometryVertexAttributeUpdated(m[a],Y.NORMALCOMPRESSED),t.invalidateBoundingInfo(),c.geometryVertexAttributeUpdated(m[a],Y.POSITION),m[a+1].invalidateBoundingInfo(),c.geometryVertexAttributeUpdated(m[a+1],Y.POSITION)}u+=x/b}return u/h}function ft(t,e,r){const s=t.getMutableAttribute(Y.POSITION),o=t.getMutableAttribute(Y.NORMALCOMPRESSED).data,{topVertexStart:n,topVertexCount:i,topFaceStart:a,topFaceCount:l}=e,c=s.data,h=i,f=t.attributes.get(Y.POSITION).indices,y=a+l,b=n+i,_=P(3*h);for(let m=0;m<h;++m){const t=3*m;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=Pt,S=Et,j=Mt,E=Ot,M=bt;for(let P=a;P<y;++P){const t=3*P;for(let e=0;e<3;++e){const s=f[t+e];E[e]=s;const o=3*s;p(yt,c[o+0],c[o+1],c[o+2]),d(x[e],yt,r)}u(S,x[1],x[0]),u(j,x[2],x[0]),g(M,S,j),m(M,M);for(let e=0;e<3;++e){const t=3*(E[e]-n);_[t+0]+=M[0],_[t+1]+=M[1],_[t+2]+=M[2]}}for(let m=n;m<b;++m){const t=3*(m-n),e=_[t+0],r=_[t+1],s=_[t+2],i=Math.sqrt(e*e+r*r+s*s);Q(o,m,e/i,r/i,s/i)}}const yt=y(),bt=y(),_t=new L,xt=[0,2,1],St=[0,1,2],jt=.01,Pt=[y(),y(),y()],Et=y(),Mt=y(),Ot=[0,0,0];var wt;!function(t){t[t.Main=0]="Main",t[t.Bottom=1]="Bottom"}(wt||(wt={}));class Ct{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class It{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{et as Graphics3DExtrudeSymbolLayer};
5
+ import"../../../../core/has.js";import t from"../../../../core/Error.js";import{clone as e}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as r}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as i,invertOrIdentity as a}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{c,n as m,s as p,f as h,b as g,h as d,z as u}from"../../../../chunks/vec32.js";import{fromArray as f,create as y}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{computeTranslationToOriginAndRotation as b}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as _,empty as x,expandWithBuffer as S,intersectsClippingArea as j}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as P}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as E,getZeroIndexArray as w}from"../../../../geometry/support/Indices.js";import{a as O}from"../../../../chunks/vec3.js";import{makeVertexCandidate as C,makeEdgeCandidate as M}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as I}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as v}from"../../../ViewingMode.js";import{needsElevationUpdates3D as A,SampleElevationInfo as L}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as z,Graphics3DObject3DGraphicLayer as B}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as R,computeCentroid as T}from"./graphicUtils.js";import{ApplyRendererDiffResult as U}from"./interfaces.js";import{geometryAsPolygon as G}from"./polygonUtils.js";import{createMaterial as N}from"../support/edgeUtils.js";import{debugFlags as V}from"../../support/debugFlags.js";import{SamplePosition as F}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as k}from"../../support/renderInfoUtils/polygon.js";import{NormalType as H}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as W}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as q}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Z}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as J}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as K}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as Q,compressNormal as X}from"../../webgl-engine/lib/Normals.js";import{Object3D as Y}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as $}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as tt}from"../../webgl-engine/materials/DefaultMaterial.js";const et=["polygon","extent"];class rt extends D{constructor(t,e,r,s){super(t,e,r,s),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const e=R(this._getSymbolSize());if(e)throw new t("graphics3dextrudesymbollayer:invalid-size",e)}const e=this.symbolLayer?.material?.color,r=this._getCombinedOpacityAndColor(e),s=f(r),o=r[3],n=o<1||this.needsDrivenTransparentPass,i={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:s,ambient:s,opacity:o,transparent:n,cullFace:n?q.None:q.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0,normalType:H.Compressed};this._materials[Mt.Main]=new tt(i),this._materials[Mt.Bottom]=new tt({...i,cullFace:q.Back}),this._context.stage.addMany(this._materials)}destroy(){super.destroy(),this._context.stage.removeMany(this._materials),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,et,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(t.renderingInfo,255),s=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,s,e.uid)}layerOpacityChanged(t,e){const r=this.symbolLayer?.material?.color,s=this._getCombinedOpacity(r),o=s<1||this.needsDrivenTransparentPass;this._materials[Mt.Main]?.setParameters({opacity:s,transparent:o}),this._materials[Mt.Bottom]?.setParameters({opacity:s,transparent:o});const n=this._getLayerOpacity();t.forEach((t=>{const r=e(t);null!=r&&r.layerOpacityChanged(n,this._context.isAsync)}))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,A)}slicePlaneEnabledChanged(t,e){return this._materials[Mt.Main]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[Mt.Bottom]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t.forEach((t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[Mt.Main]?.setParameters(t),this._materials[Mt.Bottom]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?I(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?U.RecreateSymbol:U.RecreateGraphics}async queryForSnapping(t,s,o,n){const i=this._getExtrusionSize(o)*this._context.renderCoordsHelper.unitInMeters/r(s),{objectId:a,target:l}=t,c=e(l);switch(c.z=(c.z??0)+i,t.type){case"edge":{const{start:r,end:s}=t,o=e(r),n=e(s);return o.z=(o.z??0)+i,n.z=(n.z??0)+i,[M(a,c,1/0,o,n)]}case"vertex":return[C(a,c,1/0),M(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,a,c){const m=G(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=k(m,this._context.elevationProvider,this._context.renderCoordsHelper,a);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=T(m);if(null==h)return null;const g=new Array,d=new Array,u=_(),f=l(),w=y(),C=this._context.renderCoordsHelper.viewingMode===v.Global;C||this._context.renderCoordsHelper.worldUpAtPosition(null,w),b(m.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const M=l();i(M,f);const I=n();o(I,M);const{polygons:L,mapPositions:D,position:R}=p,U=new Map,V=this._materials[Mt.Main];for(const o of L){const t=o.count;if(this._context.clippingExtent&&(x(u),S(u,o.mapPositions),!j(u,this._context.clippingExtent)))continue;const n=s(o.mapPositions,o.holeIndices,3);if(0===n.length)continue;const i=n.length,a=6*t,l=E(a+i),m=E(i),p=P(3*a),h=P(3*a),y=P(3*a),b=P(a);ot(R,D,n,o,p,y,h,b,l,m,this._getExtrusionSize(e),w,C),O(p,p,M);const _=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerUid:this._context.layer.uid}),I=new It(p,y,Q(h),b),v=st(V,l,l.length-m.length,I,r,_),A=t,L=t,z=2*o.count,B=new vt(A,L,z,i/3);yt(v,B,f),U.set(v,B),g.push(v,st(this._materials[Mt.Bottom],m,0,I,r,_)),d.push(I.heights)}if(0===g.length)return null;const F=new Y({geometries:g,layerUid:this._context.layer.uid,graphicUid:c,isElevationSource:!0});F.transformation=f;const H=N(this.symbolLayer,{opacity:this._getLayerOpacity()}),W=H?new z(this._materials[Mt.Main],H,this._context.slicePlaneEnabled):null,q=new B(this,F,g,null,null,((t,e,r,s,o)=>ft(t,e,r,s,o,d,U)),a,W);return q.alignedSampledElevation=p.sampledElevation,q.needsElevationUpdates=A(a.mode),q}}function st(t,e,r,s,o,n){const i=w(e.length),a=[[$.POSITION,new W(s.positions,e,3,!0)],[$.NORMALCOMPRESSED,new W(s.normals,e,2,!0)],[$.COLOR,new W(o,i,4,!0)]];return new J(t,a,s.elevation,Z.Mesh,n,r)}function ot(t,e,r,s,o,n,i,a,l,c,m,p,h){{const g=r.length/3,d=2*s.count;nt(t,e,s.index,s.count,r,0,g,o,n,i,a,l,c,d,m,p,h)}{let t=0,e=2*s.count,r=0;const c=s.pathLengths[0];lt(o,n,a,i,t,c,s.count,e,l,r,m),e+=4*c,r+=2*c,t+=c;for(let p=1;p<s.pathLengths.length;++p){const c=s.pathLengths[p];lt(o,n,a,i,t,c,s.count,e,l,r,m),e+=4*c,r+=2*c,t+=c}}}function nt(t,e,r,s,o,n,i,a,l,p,h,g,d,u,f,y,b){c(_t,y);{const o=f>0?1:-1;let n=3*r,i=0,c=3*i,g=s,d=3*g;for(let r=0;r<s;++r){const r=t[n],s=t[n+1],u=t[n+2];b&&(_t[0]=r,_t[1]=s,_t[2]=u,m(_t,_t)),a[c+0]=r,a[c+1]=s,a[c+2]=u;const y=e[n+0],_=e[n+1],x=e[n+2];l[c+0]=y,l[c+1]=_,l[c+2]=x,p[c+0]=-o*_t[0],p[c+1]=-o*_t[1],p[c+2]=-o*_t[2],h[i]=0,a[d+0]=r+f*_t[0],a[d+1]=s+f*_t[1],a[d+2]=u+f*_t[2],l[d+0]=y,l[d+1]=_,l[d+2]=x,h[g]=f,c+=3,d+=3,n+=3,i+=1,g+=1}}{let t=3*n,e=0,r=3*u;const a=f<0?jt:St,l=f<0?St:jt;for(let n=0;n<i;++n)d[e]=o[t+a[0]],d[e+1]=o[t+a[1]],d[e+2]=o[t+a[2]],g[r]=o[t+l[0]]+s,g[r+1]=o[t+l[1]]+s,g[r+2]=o[t+l[2]]+s,e+=3,r+=3,t+=3}}function it(t,e,r,s,o,n,i){s[n]=s[i],i*=3,t[n*=3]=t[i],t[n+1]=t[i+1],t[n+2]=t[i+2],e[n]=e[i],e[n+1]=e[i+1],e[n+2]=e[i+2],r[n]=o[0],r[n+1]=o[1],r[n+2]=o[2]}const at=y();function lt(t,e,r,s,o,n,i,a,l,c,m){let p=o,h=o+1,g=o+i,d=o+i+1,u=a,f=a+1,y=a+2*n,b=a+2*n+1;m<0&&(p=o+i+1,d=o);let _=3*c;for(let x=0;x<n;++x)x===n-1&&(h=o,m>0?d=o+i:p=o+i),dt(t,p,h,g,at),it(t,e,s,r,at,u,p),it(t,e,s,r,at,f,h),it(t,e,s,r,at,y,g),it(t,e,s,r,at,b,d),l[_]=u,l[_+1]=y,l[_+2]=b,l[_+3]=u,l[_+4]=b,l[_+5]=f,_+=6,p++,h++,g++,d++,u+=2,f+=2,y+=2,b+=2}const ct=y(),mt=y(),pt=y(),ht=y(),gt=y();function dt(t,e,r,s,o){e*=3,r*=3,s*=3,p(ct,t[e++],t[e++],t[e++]),p(mt,t[r++],t[r++],t[r++]),p(pt,t[s++],t[s++],t[s++]),h(ht,mt,ct),h(gt,pt,ct),g(o,gt,ht),m(o,o)}const ut=y();function ft(t,e,r,s,o,n,i){const c=t.stageObject,m=c.geometries,h=m.length,g="absolute-height"!==e.mode;let u=0;const f=c.transformation,y=a(l(),f);for(let a=0;a<h;a+=2){const t=m[a];if(!K(t))continue;const e=t.getMutableAttribute($.POSITION).data,l=n[a/2],h=new F(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let n=0;n<b;n++){ut[0]=e[t],ut[1]=e[t+1],ut[2]=e[t+2],s(h,xt),g&&(x+=xt.sampledElevation),V.TESTS_DISABLE_OPTIMIZATIONS?(p(bt,h.array[h.offset],h.array[h.offset+1],xt.z+l[t/3]),null!=r&&o.toRenderCoords(bt,r,bt),d(bt,bt,y)):(p(bt,e[t],e[t+1],e[t+2]),d(bt,bt,f),o.setAltitude(bt,xt.z+l[t/3]),d(bt,bt,y)),e[t]=bt[0],e[t+1]=bt[1],e[t+2]=bt[2];const n=Pt/o.unitInMeters;(Math.abs(ut[0]-e[t])>=n||Math.abs(ut[1]-e[t+1])>=n||Math.abs(ut[2]-e[t+2])>=n)&&(_=!0),h.offset+=3,t+=3}}if(_){const e=i.get(t);e&&yt(t,e,f),c.geometryVertexAttributeUpdated(m[a],$.NORMALCOMPRESSED),t.invalidateBoundingInfo(),c.geometryVertexAttributeUpdated(m[a],$.POSITION),m[a+1].invalidateBoundingInfo(),c.geometryVertexAttributeUpdated(m[a+1],$.POSITION)}u+=x/b}return u/h}function yt(t,e,r){const s=t.getMutableAttribute($.POSITION),o=t.getMutableAttribute($.NORMALCOMPRESSED).data,{topVertexStart:n,topVertexCount:i,topFaceStart:a,topFaceCount:l}=e,c=s.data,h=i,f=t.attributes.get($.POSITION).indices,y=a+l,b=n+i,_=P(3*h);for(let m=0;m<h;++m){const t=3*m;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=Et,S=wt,j=Ot,E=Ct,w=_t;for(let P=a;P<y;++P){const t=3*P;for(let e=0;e<3;++e){const s=f[t+e];E[e]=s;const o=3*s;p(bt,c[o+0],c[o+1],c[o+2]),d(x[e],bt,r)}u(S,x[1],x[0]),u(j,x[2],x[0]),g(w,S,j),m(w,w);for(let e=0;e<3;++e){const t=3*(E[e]-n);_[t+0]+=w[0],_[t+1]+=w[1],_[t+2]+=w[2]}}for(let m=n;m<b;++m){const t=3*(m-n),e=_[t+0],r=_[t+1],s=_[t+2],i=Math.sqrt(e*e+r*r+s*s);X(o,m,e/i,r/i,s/i)}}const bt=y(),_t=y(),xt=new L,St=[0,2,1],jt=[0,1,2],Pt=.01,Et=[y(),y(),y()],wt=y(),Ot=y(),Ct=[0,0,0];var Mt;!function(t){t[t.Main=0]="Main",t[t.Bottom=1]="Bottom"}(Mt||(Mt={}));class It{constructor(t,e,r,s){this.positions=t,this.elevation=e,this.normals=r,this.heights=s}}class vt{constructor(t,e,r,s){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=s}}export{rt as Graphics3DExtrudeSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.31/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as r,fromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as s,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as p,g as h,j as g,h as d,t as x,n as _,r as T,m as b,f as y,b as v}from"../../../../chunks/vec32.js";import{ZEROS as w,ONES as R,create as M}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as P}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as E}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as N,expandWithBuffer as I,intersectsClippingArea as S}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as U}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as B,getContinuousIndexArray as F}from"../../../../geometry/support/Indices.js";import D from"../../../../geometry/support/MeshComponent.js";import G from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import L from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as V,isAbsoluteVertexSpace as $}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as H,isPlateCarree as k}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as q}from"../../../../chunks/vec3.js";import{transformNormal as z,transformVectorENUPlateCarree as W,VectorType as Y,transformVectorWMPlateCarree as J,projectNormalToPCPF as K,transformTangent as Q,projectTangentToPCPF as X,project as Z}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as ee}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as te}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as re}from"../../../ViewingMode.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ae}from"./ElevationAligners.js";import{needsElevationUpdates3D as se,evaluateElevationInfoAtPoint as ie}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as le}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ce}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ue}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as me,MeshFastUpdateProcessor as fe}from"./MeshFastUpdateProcessor.js";import{createMaterial as pe}from"../support/edgeUtils.js";import{parseColorMixMode as he,encodeSymbolColor as ge}from"../support/symbolColorUtils.js";import{debugFlags as de}from"../../support/debugFlags.js";import{Attribute as xe}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _e,CullFaceOptions as Te}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as be}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ye}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{Texture as we}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Re}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Me}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as je}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ae,defaultSchematicMRRFactors as Ce,defaultAdvancedMRRFactors as Pe}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ee}from"../../../webgl/enums.js";const Oe=["mesh"];class Ne extends ue{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new me,this._fastUpdateProcessor=new fe,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){de.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new je({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new je({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new je({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Oe,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,se)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case te.EnableFastUpdates:if(n)return!0;break;case te.DisableFastUpdates:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,te.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,te.DisableFastUpdates))),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=nt,{origin:i,transform:l}=r;if(!C(t,p(Ze,i.x,i.y,i.z??0),s,a))return!1;switch(o){case te.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case te.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case te.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>ie(e,u,c,m,t);return e.alignedSampledElevation=ae(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,te.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Ye(n),p=Ye(a),h=Je(s),g=Ye(i),d=Je(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${g},nttuid:${d},ds:${c},ac:${u},am:${m}`,t.material instanceof G){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Ye(n),h=Je(a),g=Ye(i),d=Ye(c),x=Je(u),_=Ye(m),T=Je(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${g},etmuid:${d},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTextureId(e){const t=this._getInternalTexture(e,_e.Opaque);return t?.id}_getInternalTexture(e,t){const r=We(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let n=this._textures.get(o);if(!n){let a=null;const s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:He(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};oe(r)?(a=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(a=r,i.preMultiplyAlpha=t!==_e.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),n=new we(a,i),this._textures.set(o,n),n.load(this._context.stage.renderView.renderingContext),this._context.stage.add(n)}return n}_setInternalMaterialParameters(t,r){if(null!=t.color&&ze(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=ne(t.colorTextureTransform),r.normalTextureTransformMatrix=ne(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:f;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=ne(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=ne(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=ne(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=j;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=j)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(qe(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=Ae({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:w,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:Te.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};f.mrrFactors=m?[...Ce]:[l.metallic,l.roughness,Pe[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?Te.None:Te.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTransparentParameter(f,u),this._setInternalMaterialParameters(l,f);const p=new Me(f);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),p}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?_e.MaskBlend:_e.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?_e.Opaque:"mask"===t.alphaMode?_e.Mask:_e.Blend}_createFaceDebugNormals(e,t){const o=t.length,a=e.spatialReference.isGeographic?20015077/180:1,s=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),i=[],l=[],c=t[0].transformation,u=r(n(),c);for(let r=0;r<o;r++){const e=t[r].attributes.get(Re.POSITION);if(!e)continue;const o=e.data,n=e.indices;for(let t=0;t<n.length;t+=3)Le(o,n,t,rt),Ge(o,n,t,Ze,et,tt),h(Ze,Ze,et),h(Ze,Ze,tt),g(Ze,Ze,1/3),d(Ze,Ze,c),i.push(...Ze),x(rt,rt,u),_(rt,rt),T(Ze,Ze,rt,s),i.push(...Ze),l.push(l.length),l.push(l.length)}return i.length?new ye(this._debugFaceNormalMaterial,[[Re.POSITION,new xe(i,l,3,!0)]],null,be.Line):null}_createPerVertexDebugVectors(e,t,a,s,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],h=t[0].transformation,g=r(n(),h);a===Re.TANGENT&&o(g,h);for(let r=0;r<l;r++){const e=t[r],o=e.attributes.get(Re.POSITION),n=e.attributes.get(a);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;p(Ze,s[e+0],s[e+1],s[e+2]),d(Ze,Ze,h),m.push(...Ze),p(et,l[r+0],l[r+1],l[r+2]),x(et,et,g),_(et,et),T(Ze,Ze,et,u),m.push(...Ze),f.push(f.length),f.push(f.length)}}return m.length?new ye(s,[[Re.POSITION,new xe(m,f,3,!0)]],null,be.Line):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(de.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,Re.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,Re.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=new ve({geometries:s,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=pe(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new ce(s[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new le(this,l,s,null,null,ae,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=se(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,m.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:f,renderCoordsHelper:p}=this._context,h=(e,t)=>ie(e,f,r,p,t);return m.alignedSampledElevation=ae(m,r,f.spatialReference,h,p),m}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!V(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return a===re.Global&&"local"===o||a===re.Local&&H(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=ee(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return E([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===it.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o=r,n=null;if(t.reprojection===it.NONE)return{position:o,georeferencedPositionBuffer:n};const a=t.reprojection===it.RENDER?t.transformBeforeProject:null;a&&(o=q(new Float64Array(o.length),o,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(n=o);const l=o===r||o===n?new Float64Array(o.length):o;return P(o,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0,o.length/3),{position:l,georeferencedPositionBuffer:n}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=o.reprojection===it.RENDER?o.transformBeforeProject:null;s&&(a=z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===it.NONE)return a;if("local"===i){if(!k(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return W(a,Y.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return J(a,Y.NORMAL,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a;return K(a,r,t,e.spatialReference,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=o.reprojection===it.RENDER?o.transformBeforeProject:null;s&&(a=Q(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===it.NONE)return a;if("local"===i){if(!k(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return W(a,Y.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return J(a,Y.TANGENT,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a;return X(a,r,t,e.spatialReference,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=he(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ge(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),u=Ke(e),m=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:g,position:d,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:d,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:u,symbolColorBuffer:m,objectTransformation:g,geometryTransformation:s.reprojection===it.NONE&&s.geometryTransformation?s.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?H(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?it.NONE:it.RENDER:it.NONE;if($(t))return{reprojection:r};const o=t.origin,n=c(),i=e.transform?.localMatrix??u;if(r===it.NONE){C(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:m(i)}}const l=a(c(),o);return s(l,l,i),{reprojection:r,transformBeforeProject:l}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.anchor;Xe[0]=a.x,Xe[1]=a.y,Xe[2]=a.z??0;const s=c();C(e.spatialReference,Xe,s,n),i(ot,s);const{position:l,normal:u,tangent:m}=e.vertexAttributes,f=t===l?new Float64Array(t.length):t;q(f,t,ot);const p=r?r===u?new Float32Array(r.length):r:null,h=o?o===m?new Float32Array(o.length):o:null;return r&&p&&z(r,p,ot),o&&h&&Q(o,h,ot),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=Z({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===re.Local});if(!o)return!1;const n=o.length/3;return N(at),I(at,o,0,n),!S(at,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!A(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:f}=o,p=Ve(e),h=new Array;let g=!1;const d=l(Ze,m),x=this._context.localOriginFactory.getOrigin(d);for(const l of p){if(!this._validateFaces(e,l))return null;const t=Se(e,l);if(0===t.length)continue;const o=Ue(n,c,l,t);o.didFlipNormals&&(g=!0);const m=[[Re.POSITION,new xe(n,t,3,!0)],[Re.NORMAL,new xe(o.normals,o.indices,3,!0)]];s&&m.push([Re.COLOR,new xe(s,t,4,!0)]),i&&m.push([Re.SYMBOLCOLOR,new xe(i,B(t.length),4,!0)]),a&&m.push([Re.UV0,new xe(a,t,2,!0)]),u&&m.push([Re.TANGENT,new xe(u,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),d=this._getOrCreateMaterial(e,l),_=new ye(d,m,null,be.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return g&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==re.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Se(e,t){return t.faces??F(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Be(e,o);case"smooth":return De(e,o)}}function Be(e,t){const r=U(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Le(e,t,n,rt);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Be(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Le(e,o,a,rt);for(let e=0;e<3;e++){const r=3*o[a+e];Ze[0]=t[r],Ze[1]=t[r+1],Ze[2]=t[r+2],b(rt,Ze)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function De(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Le(e,t,a,rt);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),h(s.normal,s.normal,o),s.count++}}const o=U(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(_(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ge(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Le(e,t,r,o){return Ge(e,t,r,Ze,et,tt),y(et,et,Ze),y(tt,tt,Ze),v(Ze,et,tt),_(o,Ze),o}function Ve(e){return e.components??st}function $e(e){if(!e)return null;const{scale:r,offset:o,rotation:n}=e;return{scale:r,offset:o,rotation:t(n)}}function He(e="repeat"){if("string"==typeof e){const t=ke(e);return{s:t,t}}return{s:ke(e.horizontal),t:ke(e.vertical)}}function ke(e){switch(e){case"clamp":return Ee.CLAMP_TO_EDGE;case"mirror":return Ee.MIRRORED_REPEAT;default:return Ee.REPEAT}}function qe(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function ze(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}function We(e){return e.data??e.url}function Ye(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Je(e){const{offset:t,scale:r,rotation:o}=e??Qe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Ke(e){return e.vertexAttributes.color}const Qe=new L,Xe=M(),Ze=M(),et=M(),tt=M(),rt=M(),ot=c(),nt=c(),at=O(),st=[new D];var it;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(it||(it={}));export{Ne as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{normalFromMat4 as r,fromMat4 as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as s,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as p,g as h,j as g,h as d,t as x,n as _,r as T,m as b,f as y,b as v}from"../../../../chunks/vec32.js";import{ZEROS as w,ONES as R,create as M}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as A}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as P}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as E}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as N,expandWithBuffer as I,intersectsClippingArea as S}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as U}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as B,getContinuousIndexArray as F}from"../../../../geometry/support/Indices.js";import D from"../../../../geometry/support/MeshComponent.js";import G from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import L from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as V,isAbsoluteVertexSpace as $}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as H,isPlateCarree as k}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as q}from"../../../../chunks/vec3.js";import{transformNormal as z,transformVectorENUPlateCarree as W,VectorType as Y,transformVectorWMPlateCarree as J,projectNormalToPCPF as K,transformTangent as Q,projectTangentToPCPF as X,project as Z}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as ee}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as te}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as re}from"../../../ViewingMode.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as ae}from"./ElevationAligners.js";import{needsElevationUpdates3D as se,evaluateElevationInfoAtPoint as ie}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as le}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ce}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ue}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as me,MeshFastUpdateProcessor as fe}from"./MeshFastUpdateProcessor.js";import{createMaterial as pe}from"../support/edgeUtils.js";import{parseColorMixMode as he,encodeSymbolColor as ge}from"../support/symbolColorUtils.js";import{debugFlags as de}from"../../support/debugFlags.js";import{Attribute as xe}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _e,CullFaceOptions as Te}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as be}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ye}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{Texture as we}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Re}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Me}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as je}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ae,defaultSchematicMRRFactors as Ce,defaultAdvancedMRRFactors as Pe}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ee}from"../../../webgl/enums.js";const Oe=["mesh"];class Ne extends ue{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new me,this._fastUpdateProcessor=new fe,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){de.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new je({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new je({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new je({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Oe,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,se)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case te.EnableFastUpdates:if(n)return!0;break;case te.DisableFastUpdates:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,te.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,te.DisableFastUpdates))),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=nt,{origin:i,transform:l}=r;if(!C(t,p(Ze,i.x,i.y,i.z??0),s,a))return!1;switch(o){case te.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case te.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case te.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>ie(e,u,c,m,t);return e.alignedSampledElevation=ae(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,te.DisableFastUpdates))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Ye(n),p=Ye(a),h=Je(s),g=Ye(i),d=Je(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${g},nttuid:${d},ds:${c},ac:${u},am:${m}`,t.material instanceof G){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Ye(n),h=Je(a),g=Ye(i),d=Ye(c),x=Je(u),_=Ye(m),T=Je(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${g},etmuid:${d},ett:${x},otmuid:${_},ott:${T}`}return o}_getInternalTextureId(e){const t=this._getInternalTexture(e,_e.Opaque);return t?.id}_getInternalTexture(e,t){const r=We(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let n=this._textures.get(o);if(!n){let a=null;const s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:He(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};oe(r)?(a=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(a=r,i.preMultiplyAlpha=t!==_e.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),n=new we(a,i),this._textures.set(o,n),n.load(this._context.stage.renderView.renderingContext),this._context.stage.add(n)}return n}_setInternalMaterialParameters(t,r){if(null!=t.color&&ze(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=ne(t.colorTextureTransform),r.normalTextureTransformMatrix=ne(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:f;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=ne(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=ne(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=ne(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=j;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=j)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(qe(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=Ae({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:w,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:Te.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};f.mrrFactors=m?[...Ce]:[l.metallic,l.roughness,Pe[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?Te.None:Te.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTransparentParameter(f,u),this._setInternalMaterialParameters(l,f);const p=new Me(f);return u.material=p,this._materialInfoCache.set(l.uid,u),this._context.stage.add(p),p}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?_e.MaskBlend:_e.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?_e.Opaque:"mask"===t.alphaMode?_e.Mask:_e.Blend}_createFaceDebugNormals(e,t){const o=t.length,a=e.spatialReference.isGeographic?20015077/180:1,s=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),i=[],l=[],c=t[0].transformation,u=r(n(),c);for(let r=0;r<o;r++){const e=t[r].attributes.get(Re.POSITION);if(!e)continue;const o=e.data,n=e.indices;for(let t=0;t<n.length;t+=3)Le(o,n,t,rt),Ge(o,n,t,Ze,et,tt),h(Ze,Ze,et),h(Ze,Ze,tt),g(Ze,Ze,1/3),d(Ze,Ze,c),i.push(...Ze),x(rt,rt,u),_(rt,rt),T(Ze,Ze,rt,s),i.push(...Ze),l.push(l.length),l.push(l.length)}return i.length?new ye(this._debugFaceNormalMaterial,[[Re.POSITION,new xe(i,l,3,!0)]],null,be.Line):null}_createPerVertexDebugVectors(e,t,a,s,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],h=t[0].transformation,g=r(n(),h);a===Re.TANGENT&&o(g,h);for(let r=0;r<l;r++){const e=t[r],o=e.attributes.get(Re.POSITION),n=e.attributes.get(a);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;p(Ze,s[e+0],s[e+1],s[e+2]),d(Ze,Ze,h),m.push(...Ze),p(et,l[r+0],l[r+1],l[r+2]),x(et,et,g),_(et,et),T(Ze,Ze,et,u),m.push(...Ze),f.push(f.length),f.push(f.length)}}return m.length?new ye(s,[[Re.POSITION,new xe(m,f,3,!0)]],null,be.Line):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(de.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,Re.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,Re.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=new ve({geometries:s,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=pe(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new ce(s[0].material,c,this._context.slicePlaneEnabled):null,m=new le(this,l,s,null,null,ae,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=se(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,m.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:f,renderCoordsHelper:p}=this._context,h=(e,t)=>ie(e,f,r,p,t);return m.alignedSampledElevation=ae(m,r,f.spatialReference,h,p),m}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!V(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return a===re.Global&&"local"===o||a===re.Local&&H(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=ee(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return E([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===it.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o=r,n=null;if(t.reprojection===it.NONE)return{position:o,georeferencedPositionBuffer:n};const a=t.reprojection===it.RENDER?t.transformBeforeProject:null;a&&(o=q(new Float64Array(o.length),o,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(n=o);const l=o===r||o===n?new Float64Array(o.length):o;return P(o,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0,o.length/3),{position:l,georeferencedPositionBuffer:n}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=o.reprojection===it.RENDER?o.transformBeforeProject:null;s&&(a=z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===it.NONE)return a;if("local"===i){if(!k(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return W(a,Y.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return J(a,Y.NORMAL,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a;return K(a,r,t,e.spatialReference,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=o.reprojection===it.RENDER?o.transformBeforeProject:null;s&&(a=Q(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===it.NONE)return a;if("local"===i){if(!k(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return W(a,Y.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return J(a,Y.TANGENT,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a;return X(a,r,t,e.spatialReference,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=he(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return ge(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),u=Ke(e),m=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:g,position:d,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:d,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:u,symbolColorBuffer:m,objectTransformation:g,geometryTransformation:s.reprojection===it.NONE&&s.geometryTransformation?s.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?H(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?it.NONE:it.RENDER:it.NONE;if($(t))return{reprojection:r};const o=t.origin,n=c(),i=e.transform?.localMatrix??u;if(r===it.NONE){C(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:m(i)}}const l=a(c(),o);return s(l,l,i),{reprojection:r,transformBeforeProject:l}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.anchor;Xe[0]=a.x,Xe[1]=a.y,Xe[2]=a.z??0;const s=c();C(e.spatialReference,Xe,s,n),i(ot,s);const{position:l,normal:u,tangent:m}=e.vertexAttributes,f=t===l?new Float64Array(t.length):t;q(f,t,ot);const p=r?r===u?new Float32Array(r.length):r:null,h=o?o===m?new Float32Array(o.length):o:null;return r&&p&&z(r,p,ot),o&&h&&Q(o,h,ot),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=Z({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===re.Local});if(!o)return!1;const n=o.length/3;return N(at),I(at,o,0,n),!S(at,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!A(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:f}=o,p=Ve(e),h=new Array;let g=!1;const d=l(Ze,m),x=this._context.localOriginFactory.getOrigin(d);for(const l of p){if(!this._validateFaces(e,l))return null;const t=Se(e,l);if(0===t.length)continue;const o=Ue(n,c,l,t);o.didFlipNormals&&(g=!0);const m=[[Re.POSITION,new xe(n,t,3,!0)],[Re.NORMAL,new xe(o.normals,o.indices,3,!0)]];s&&m.push([Re.COLOR,new xe(s,t,4,!0)]),i&&m.push([Re.SYMBOLCOLOR,new xe(i,B(t.length),4,!0)]),a&&m.push([Re.UV0,new xe(a,t,2,!0)]),u&&m.push([Re.TANGENT,new xe(u,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),d=this._getOrCreateMaterial(e,l),_=new ye(d,m,null,be.Mesh,p);_.transformation=f,_.localOrigin=x,h.push(_)}return g&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==re.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Ie{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Se(e,t){return t.faces??F(e.vertexAttributes.position.length/3)}function Ue(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Fe(e,t,r,o);case"flat":return Be(e,o);case"smooth":return De(e,o)}}function Be(e,t){const r=U(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Le(e,t,n,rt);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Ie(r,o,!1)}function Fe(e,t,r,o){if(null==t)return Be(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Le(e,o,a,rt);for(let e=0;e<3;e++){const r=3*o[a+e];Ze[0]=t[r],Ze[1]=t[r+1],Ze[2]=t[r+2],b(rt,Ze)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Ie(t,o,n)}function De(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Le(e,t,a,rt);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),h(s.normal,s.normal,o),s.count++}}const o=U(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(_(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Ie(o,n,!1)}function Ge(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Le(e,t,r,o){return Ge(e,t,r,Ze,et,tt),y(et,et,Ze),y(tt,tt,Ze),v(Ze,et,tt),_(o,Ze),o}function Ve(e){return e.components??st}function $e(e){if(!e)return null;const{scale:r,offset:o,rotation:n}=e;return{scale:r,offset:o,rotation:t(n)}}function He(e="repeat"){if("string"==typeof e){const t=ke(e);return{s:t,t}}return{s:ke(e.horizontal),t:ke(e.vertical)}}function ke(e){switch(e){case"clamp":return Ee.CLAMP_TO_EDGE;case"mirror":return Ee.MIRRORED_REPEAT;default:return Ee.REPEAT}}function qe(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function ze(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}function We(e){return e.data??e.url}function Ye(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function Je(e){const{offset:t,scale:r,rotation:o}=e??Qe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function Ke(e){return e.vertexAttributes.color}const Qe=new L,Xe=M(),Ze=M(),et=M(),tt=M(),rt=M(),ot=c(),nt=c(),at=O(),st=[new D];var it;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(it||(it={}));export{Ne as Graphics3DMeshFillSymbolLayer};