@arcgis/core 5.0.0-next.17 → 5.0.0-next.19

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 (192) hide show
  1. package/AttributeBinsGraphic.js +1 -1
  2. package/analysis/ElevationProfile/ElevationProfileLineGround.js +1 -1
  3. package/analysis/ElevationProfile/ElevationProfileLineInput.js +1 -1
  4. package/analysis/ElevationProfile/ElevationProfileLineQuery.js +1 -1
  5. package/analysis/ElevationProfile/ElevationProfileLineScene.js +1 -1
  6. package/arcade/featureSetUtils.js +1 -1
  7. package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
  8. package/arcade/featureset/sources/FeatureLayerMemory.js +1 -1
  9. package/arcade/featureset/sources/FeatureLayerOGC.js +5 -0
  10. package/arcade/featureset/sources/FeatureLayerRelated.js +1 -1
  11. package/arcade/featureset/support/FeatureSet.js +1 -1
  12. package/arcade/featureset/support/shared.js +1 -1
  13. package/assets/esri/core/workers/RemoteClient.js +1 -1
  14. package/assets/esri/core/workers/chunks/057d59ee6144e5890780.js +1 -0
  15. package/assets/esri/core/workers/chunks/{adf7ccf4ef629211c7ee.js → 08aacbfb651cc2e1c054.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{31b5900119dd7cd9e7d3.js → 0a6ad58ca4ca0cba2fa0.js} +1 -1
  17. package/assets/esri/core/workers/chunks/0d8d3d0de49064971874.js +1 -0
  18. package/assets/esri/core/workers/chunks/{b87bc987983b31c13f64.js → 0f1b9d69961dad0b922f.js} +1 -1
  19. package/assets/esri/core/workers/chunks/110cc01dd6af7ee125d4.js +1 -0
  20. package/assets/esri/core/workers/chunks/11687718c8635eb7bf37.js +1 -0
  21. package/assets/esri/core/workers/chunks/{5f6df4a3376b52ead53f.js → 14f994b1dd682bf2d61a.js} +1 -1
  22. package/assets/esri/core/workers/chunks/3538eb39ebb58acedd67.js +1 -0
  23. package/assets/esri/core/workers/chunks/{658cd45b5fb304fd840a.js → 3aa77696c5ea54a238da.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{49571d6875de1f2e7e25.js → 4b9dfdc23ba3d6ebcc1b.js} +2 -2
  25. package/assets/esri/core/workers/chunks/{02a22dd6d208a925cc5a.js → 52cf643621662712dc85.js} +1 -1
  26. package/assets/esri/core/workers/chunks/5755b11272b777507612.js +1 -0
  27. package/assets/esri/core/workers/chunks/{d69265ceabfa92b40bb7.js → 58969dde8c3d0b2a9829.js} +1 -1
  28. package/assets/esri/core/workers/chunks/6e4829b52ade3e41ccc4.js +1 -0
  29. package/assets/esri/core/workers/chunks/{4a89e120be142ab58a27.js → 7224b321606116fd691c.js} +1 -1
  30. package/assets/esri/core/workers/chunks/{888f188541f8bd68e33e.js → 72f1c3d97e7b9546c113.js} +1 -1
  31. package/assets/esri/core/workers/chunks/{a4518f25b9f8fe704286.js → 76e945da8f30d8641c3d.js} +4 -4
  32. package/assets/esri/core/workers/chunks/{257f17b3836a623a9dbe.js → 795b09ff7a8f4e91f4dc.js} +1 -1
  33. package/assets/esri/core/workers/chunks/{3ac7562ea90f91a9f30c.js → 82b2741e75c2e9b88252.js} +1 -1
  34. package/assets/esri/core/workers/chunks/{5d2e5774768d8f290343.js → b656e8fd374113523404.js} +1 -1
  35. package/assets/esri/core/workers/chunks/bccb9ac572bc093fb177.js +1 -0
  36. package/assets/esri/core/workers/chunks/{79dbfa2b9b332ca0002f.js → c52161b94c0fb071747e.js} +1 -1
  37. package/assets/esri/core/workers/chunks/db76958fd9f54b6bd324.js +1 -0
  38. package/assets/esri/core/workers/chunks/e61d7762b56e36dc7e8a.js +1 -0
  39. package/assets/esri/core/workers/chunks/{b30897952494a3e5b9fe.js → e69c2b613bd0210e25ba.js} +1 -1
  40. package/assets/esri/core/workers/chunks/f43e1e1a1b2eb737e00c.js +1 -0
  41. package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
  42. package/chunks/GlowComposition.glsl.js +46 -46
  43. package/chunks/ImageMaterial.glsl.js +1 -1
  44. package/chunks/ShadedColorMaterial.glsl.js +10 -10
  45. package/config.js +1 -1
  46. package/editing/templateUtils.js +1 -1
  47. package/interfaces.d.ts +167 -51
  48. package/intl/locale.js +1 -1
  49. package/kernel.js +1 -1
  50. package/layers/BingMapsLayer.js +1 -1
  51. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  52. package/layers/PointCloudLayer.js +1 -1
  53. package/layers/SceneLayer.js +1 -1
  54. package/layers/VideoLayer.js +1 -1
  55. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  56. package/layers/mixins/SceneService.js +1 -1
  57. package/layers/ogc/ogcFeatureUtils.js +1 -1
  58. package/libs/parquet/parquet.js +1 -1
  59. package/package.json +1 -1
  60. package/renderers/support/RasterSymbolizer.js +1 -1
  61. package/rest/support/QueryMixin.js +1 -1
  62. package/support/revision.js +1 -1
  63. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  64. package/symbols/cim/cimAnalyzer.js +1 -1
  65. package/undoredo/support/ServiceVersionInfo.js +1 -1
  66. package/undoredo/support/Services.js +1 -1
  67. package/views/2d/LabelManager.js +1 -1
  68. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  69. package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
  70. package/views/2d/engine/webgl/VideoScreenRenderer.js +1 -1
  71. package/views/2d/engine/webgl/animations/store/AnimationStore.js +1 -1
  72. package/views/2d/engine/webgl/shaderGraph/techniques/colorize/ColorizeTechnique.js +1 -1
  73. package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityResources.js +1 -1
  74. package/views/2d/engine/webgl/shaderGraph/techniques/drop-shadow/DropShadowTechnique.js +1 -1
  75. package/views/2d/engine/webgl/shaderGraph/techniques/opacity/OpacityTechnique.js +1 -1
  76. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterColorizerTechnique.js +1 -1
  77. package/views/2d/engine/webgl/shaderGraph/techniques/raster/RasterHighlightTechnique.js +1 -1
  78. package/views/2d/engine/webgl/shaderGraph/techniques/raster/processor/textureUtils.js +1 -1
  79. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/BaseRasterHighlightShader.js +5 -0
  80. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
  81. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterXYBandHighlightShader.js +5 -0
  82. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
  83. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/stretch.js +1 -1
  84. package/views/2d/engine/webgl/textureUtils.js +1 -1
  85. package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
  86. package/views/2d/layers/features/FeatureContainer.js +1 -1
  87. package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
  88. package/views/3d/GroundView3D.js +1 -1
  89. package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
  90. package/views/3d/analysis/Slice/RotateManipulator.js +1 -1
  91. package/views/3d/analysis/images/Factory.js +1 -1
  92. package/views/3d/environment/ChapmanAtmosphere.js +1 -1
  93. package/views/3d/environment/EnvironmentManager.js +1 -1
  94. package/views/3d/environment/SceneViewEnvironment.js +1 -1
  95. package/views/3d/environment/SunLighting.js +1 -1
  96. package/views/3d/environment/VirtualLighting.js +1 -1
  97. package/views/3d/layers/BuildingComponentSublayerView3D.js +1 -1
  98. package/views/3d/layers/DrapedSubView3D.js +1 -1
  99. package/views/3d/layers/FlowSubView3D.js +1 -1
  100. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  101. package/views/3d/layers/IntegratedMeshLayerView3D.js +1 -1
  102. package/views/3d/layers/MediaLayerView3D.js +1 -1
  103. package/views/3d/layers/PointCloudLayerView3D.js +1 -1
  104. package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
  105. package/views/3d/layers/SceneLayerView3D.js +1 -1
  106. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  107. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  108. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  109. package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
  110. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  111. package/views/3d/layers/graphics/wosrLoader.js +1 -1
  112. package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
  113. package/views/3d/support/QualityProfile.js +5 -0
  114. package/views/3d/support/QualitySettings.js +1 -1
  115. package/views/3d/support/StreamTextureCollection.js +1 -1
  116. package/views/3d/support/TextureCollection.js +1 -1
  117. package/views/3d/support/engineContent/marker.js +1 -1
  118. package/views/3d/support/engineContent/sdfPrimitives.js +1 -1
  119. package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
  120. package/views/3d/terrain/OverlayRenderer.js +1 -1
  121. package/views/3d/terrain/TerrainSurface.js +1 -1
  122. package/views/3d/terrain/TileCompositor.js +1 -1
  123. package/views/3d/webgl-engine/Stage.js +1 -1
  124. package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
  125. package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
  126. package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
  127. package/views/3d/webgl-engine/core/material/MaterialBase.js +1 -1
  128. package/views/3d/webgl-engine/core/material/RenderTexture.js +1 -1
  129. package/views/3d/webgl-engine/effects/glow/GlowRenderNode.js +1 -1
  130. package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
  131. package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
  132. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  133. package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
  134. package/views/3d/webgl-engine/lib/BasisUtil.js +1 -1
  135. package/views/3d/webgl-engine/lib/DDSUtil.js +1 -1
  136. package/views/3d/webgl-engine/lib/GLTextureMaterial.js +1 -1
  137. package/views/3d/webgl-engine/lib/ManagedTexture.js +5 -0
  138. package/views/3d/webgl-engine/lib/OrderIndependentTransparency.js +1 -1
  139. package/views/3d/webgl-engine/lib/RenderFeature.js +1 -1
  140. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  141. package/views/3d/webgl-engine/lib/TextTextureAtlas.js +1 -1
  142. package/views/3d/webgl-engine/lib/TextTextureFactory.js +1 -1
  143. package/views/3d/webgl-engine/lib/TextureRepository.js +1 -1
  144. package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
  145. package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
  146. package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
  147. package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
  148. package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
  149. package/views/3d/webgl-engine/materials/internal/WaterTextureRepository.js +1 -1
  150. package/views/3d/webgl-engine/materials/stippleTextureRepository.js +1 -1
  151. package/views/3d/webgl-engine/parts/RenderView.js +1 -1
  152. package/views/GroundView.js +1 -1
  153. package/views/SceneView.js +1 -1
  154. package/views/support/layerViewUtils.js +1 -1
  155. package/views/webgl/Texture.js +1 -1
  156. package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
  157. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  158. package/widgets/Editor/SplitFeatureWorkflow.js +1 -1
  159. package/widgets/Editor/UpdateFeatureWorkflow.js +1 -1
  160. package/widgets/Editor/VisibleElements.js +1 -1
  161. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  162. package/widgets/Editor/workflowUtils.js +1 -1
  163. package/widgets/Editor.js +1 -1
  164. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
  165. package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/UtilityNetworkAssociationSettings.js +1 -1
  166. package/widgets/FeatureTable/FieldColumn.js +1 -1
  167. package/widgets/FeatureTable/Grid/Column.js +1 -1
  168. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  169. package/widgets/OrientedImageryViewer/adapters/sketch/MeasurementAdapter.js +1 -1
  170. package/widgets/OrientedImageryViewer/adapters/sketch/TriangulatedMeasurementAdapter.js +1 -1
  171. package/widgets/OrientedImageryViewer/imageMeasurementUtils.js +1 -1
  172. package/widgets/OrientedImageryViewer/services/ImageMeasurementService.js +1 -1
  173. package/widgets/OrientedImageryViewer.js +1 -1
  174. package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
  175. package/widgets/smartMapping/SizeSlider.js +1 -1
  176. package/widgets/support/SelectionList/VisibleElements.js +1 -1
  177. package/widgets/support/SelectionList.js +1 -1
  178. package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
  179. package/assets/esri/core/workers/chunks/080268f78436a2f0d996.js +0 -1
  180. package/assets/esri/core/workers/chunks/18474c017ddacd1d3d2c.js +0 -1
  181. package/assets/esri/core/workers/chunks/27e6a6c5610007ac6a54.js +0 -1
  182. package/assets/esri/core/workers/chunks/5415fbcc7ed203fc5575.js +0 -1
  183. package/assets/esri/core/workers/chunks/631fb2e62e48f8be4051.js +0 -1
  184. package/assets/esri/core/workers/chunks/722da7a39a0ad9300752.js +0 -1
  185. package/assets/esri/core/workers/chunks/9595aabbaf411eceea1e.js +0 -1
  186. package/assets/esri/core/workers/chunks/a470f662d73aa8d5d90f.js +0 -1
  187. package/assets/esri/core/workers/chunks/a57751f3d78524c876cd.js +0 -1
  188. package/assets/esri/core/workers/chunks/ac366221e8636b60aee5.js +0 -1
  189. package/assets/esri/core/workers/chunks/dec336700cfb83abbbeb.js +0 -1
  190. package/views/3d/support/DisplayQualityProfile.js +0 -5
  191. package/views/3d/webgl-engine/lib/Texture.js +0 -5
  192. /package/views/3d/webgl-engine/lib/{ITexture.js → IManagedTexture.js} +0 -0
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../request.js";import{isSome as r}from"../../../core/arrayUtils.js";import{result as s,forEach as o}from"../../../core/asyncUtils.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as d}from"../../../core/maybe.js";import{estimateNumberArrayMemory as l,baseObjectMemory as u,estimateNumberMemory as h,estimateFixedArrayMemory as p,baseArrayMemory as c}from"../../../core/memoryEstimations.js";import{isAbortError as _,allSettledValues as m,throwIfAborted as g}from"../../../core/promiseUtils.js";import{initial as f,watch as y,sync as b,syncAndInitial as w}from"../../../core/reactiveUtils.js";import{pt2px as P}from"../../../core/screenUtils.js";import{isArrayBuffer as N}from"../../../core/typedArrayUtil.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import{subclass as x}from"../../../core/accessorSupport/decorators/subclass.js";import{b as C,g as S,f as I,d as A}from"../../../chunks/vec32.js";import{clone as j}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{fromValues as R}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import k from"../../../geometry/Extent.js";import V from"../../../geometry/Point.js";import{projectBoundingSphere as Q}from"../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as F}from"../../../geometry/projection/projectVectorToVector.js";import{create as L,fromMinMax as E}from"../../../geometry/support/aaBoundingBox.js";import{fromNormalAndOffset as D,create as O}from"../../../geometry/support/plane.js";import{f as U}from"../../../chunks/sphere.js";import M from"../../../layers/graphics/OptimizedGeometry.js";import{QueryEngine as W}from"../../../layers/graphics/data/QueryEngine.js";import{CodedValue as G}from"../../../layers/support/CodedValue.js";import q from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as z}from"../../../layers/support/fieldUtils.js";import{queueAutoPriority as H}from"../../../request/queue.js";import T from"../../../rest/support/FeatureSet.js";import B from"../../../rest/support/Query.js";import{getElevationOffset as $}from"../../../support/elevationInfoUtils.js";import{LayerView3D as J}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as K,QueuePerformanceInfo as Z}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as Y}from"./PointCloudWorkerHandle.js";import{I3SQueryFeatureStore as X}from"./i3s/I3SQueryFeatureStore.js";import{checkPointCloudLayerValid as ee,checkPointCloudLayerCompatibleWithView as te}from"./i3s/I3SUtil.js";import{nodeDiff as ie,sortFrontToBack as re,splitWorkEntries as se}from"./i3s/LoDUtil.js";import{PagedNodeIndex as oe}from"./i3s/PagedNodeIndex.js";import{PointCloudGraphic as ne}from"./i3s/PointCloudGraphic.js";import{PointCloudRenderer as ae}from"./i3s/PointCloudRenderer.js";import{isPointRendererNode as de,PointCloudRendererNode as le}from"./i3s/PointCloudRendererNode.js";import{getSplatSizeAlgorithm as ue,getFixedSizeAlgorithm as he,getRendererInfo as pe,getFilterInfo as ce,rendererUsesFixedSizes as _e,getAttributeInfo as me}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as ge,readGeometry as fe,elevationFromPositions as ye}from"./i3s/PointCloudWorkerUtil.js";import{normalizeHighlightTarget as be,emptyHighlightHandle as we}from"./support/highlightUtils.js";import{PopupSceneLayerView as Pe}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as Ne}from"../support/extentUtils.js";import{computeMapPointFromVec3d as ve}from"../support/hitTest.js";import{Obb as xe}from"../support/orientedBoundingBox.js";import{updatingProgress as Ce}from"../support/updatingProperties.js";import Se from"../../layers/LayerView.js";import{PointCloudLayerView as Ie}from"../../layers/PointCloudLayerView.js";import{getHighlightName as Ae}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as je}from"../../support/layerViewUtils.js";import{PromiseQueue as Re}from"../../support/PromiseQueue.js";import{TaskPriority as ke}from"../../support/Scheduler.js";const Ve=8,Qe=O();let Fe=class extends(Ie(Pe(J(Se)))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new Re,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl?.path??""}get pointScale(){const e=ue(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=he(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=he(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=pe(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=ce(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of z(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=L(),t=this.view.renderSpatialReference;return Ne(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;return e&&"absolute-height"===e.mode?$(e,this.layer.spatialReference):0}get _graphicOrigin(){return this.layer.graphicOrigin}initialize(){const e=this.view.resourceController,t=Ue(e);this._worker=new Y(t),this.addResolvingPromise(this._worker.promise),ee(this.layer),te(this.layer,this.view),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._queryFeaturesCache=r.newCache(`pcl-query-features-${this.layer.uid};`),this._updatingHandles.add(()=>this._clippingBox,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this._elevationOffset,()=>this._elevationOffsetChanged(),f),this._updatingHandles.add(()=>this.layer.renderer,()=>this._rendererChanged(),f),this._updatingHandles.add(()=>this.layer.filters,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.outFields,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.effectiveScaleRange,()=>this._setUpdateViewNeeded()),this._updatingHandles.add(()=>this.view.state.contentCamera,()=>this._setUpdateViewNeeded()),this.addHandles([y(()=>this.view.quality,()=>this._setUpdateViewNeeded(),b)]),this.addResolvingPromise(i),this.when(()=>{this.addHandles([e.scheduler.registerTask(ke.POINT_CLOUD_LAYER,this),y(()=>2===this.view.state.mode,()=>this._setUpdateViewNeeded(),w),this._updatingHandles.add(()=>this.suspended,e=>{e?this._clearNodeState():this._setUpdateViewNeeded()},f)])},()=>{this._updatingHandles.removeAll(),this.removeAllHandles()})}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=a(this._worker),this._destroyRenderer(),this._memCache=a(this._memCache),this._queryFeaturesCache=a(this._queryFeaturesCache),this._queryEngine=a(this._queryEngine),this._codedDomainPopulationAbortController=d(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ae({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerViewUid=this.uid,this._updatingHandles.add(()=>this._clippingBox,e=>this._renderer.clippingBox=e,f),this._updatingHandles.add(()=>this.suspended,e=>this._setPointsVisible(!e),f),this._updatingHandles.add(()=>this.pointScale,e=>this._renderer.scaleFactor=e,f),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add(()=>this.useRealWorldSymbolSizes,e=>this._renderer.useRealWorldSymbolSizes=e,f),this._updatingHandles.add(()=>this.pointSize,e=>{const t=P(e);this._renderer.size=e,this._renderer.sizePx=t},f),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._renderer.slicePlaneEnabled=e,f),this._updatingHandles.add(()=>this.inverseDensity,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.maximumPointCount,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor,e=>{this._lodFactor=e,this._setUpdateViewNeeded()},f)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i,r){const s=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,o=i?"declaredClass"in i?i:ve(this.view,i):null;return r??=this._createGraphicAttributes(e,s),new ne({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:s,epoch:this._nodeLoadEpoch},geometry:o,attributes:r,layer:this.layer,sourceLayer:this.layer,origin:this._graphicOrigin})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_getGraphicAttribute(e,t,i){const r=e.storageInfo?.attributeValues,s=r?.valuesPerElement??1;if(1===s)return t[i];if("UInt8"===r?.valueType&&s<=4){let e=0;const r=i*s;for(let i=r;i<r+s;i++)e=(e<<8)+t[i];return e}}_encodeGraphicAttribute(e,t,i,r){r[e.name]=this._getGraphicAttribute(e,t,i)}_setPointsVisible(e){e&&!this._rendererAdded?(this.view.stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view.stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=_e(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_displayNodes(e){this._workQueue=ie([...this._renderedNodes],e,this._index),re(this._workQueue,this.view.state.contentCamera.viewForward,this._index),se(this._workQueue,Ve,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach(({abortController:t})=>e.push(t)),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach(t=>t.load.forEach(t=>e.add(t)));const t=new Array,i=new Map;this._loadingNodes.forEach((r,s)=>{e.has(s)?i.set(s,r):t.push(r)}),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter(e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0}),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach(({abortController:e})=>e.abort()),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach(e=>this._removeFromRenderer(e)),this._cancelNodeLoading()}get readyToRun(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.readyToRun}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run(()=>this._updateWorkQueues());this._indexQueue.length>0&&e.run(()=>this._processIndexQueue()););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then(t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()}).then(()=>{this._indexPagesLoading.delete(e)},()=>{this._indexPagesLoading.delete(e)}),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find(e=>!this._renderedNodes.has(e)))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map(e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return null!=i?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise})).then(t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)}).catch(()=>{}).then(()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.updating&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())}),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,t){const i="CLASS_CODE",r=this.layer.fieldsIndex.get(i);if(!r||r.domain)return;if(!e.includes(r.name))return;const o=await s(this.layer.queryCachedStatistics(i,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(r.domain=new q({name:"CLASS_CODE",codedValues:n.map(e=>new G({code:e.value,name:e.label}))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then(()=>{this._codedDomainPopulationAbortController=null})),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const i=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,n=t.map(e=>me(s,e)).filter(r),a=async(e,t)=>{const i=this._index.getNode(t);await o(n,async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}})},d=[];return i.forEach((e,t)=>{d.push(a(e,t))}),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof ne&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return i?ge({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=fe(t,await this._loadGeometry(e,null));return ye(i,i.length/3)}highlight(e,i){const r=be(e);if(0===r.length)return we;if(!(r[0]instanceof t))return we;const s=r;return this._renderer.highlight(s.map(e=>this._graphicToPointDefinition(e)),Ae(i))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}get visibleAtCurrentScale(){return je(this.layer.effectiveScaleRange,this.view.scale)}async queryFeatures(e,i){const r=await this._ensureQueryEngine().executeQuery(this._ensureQueryJSON(e),i?.signal),s=r.features;r.features=[];const o=T.fromJSON(r),n=this.view.spatialReference;return o.features=s.map(e=>{const{attributes:i,metadata:r}=e;if(!r){const i=t.fromJSON(e);return i.geometry&&(i.geometry.spatialReference=o.spatialReference??n),i.layer=this.layer,i.sourceLayer=this.layer,i.origin=this._graphicOrigin,i}const s=e.geometry?V.fromJSON(e.geometry):void 0;return s&&(s.spatialReference=o.spatialReference??n),this._createGraphic(r.node,r.pointId,s,i)}),o}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference,returnZ:!0};return new B(e)}async queryFeatureCount(e,t){return await this._ensureQueryEngine().executeQueryForCount(this._ensureQueryJSON(e),t?.signal)}async queryExtent(e,t){const{count:i,extent:r}=await this._ensureQueryEngine().executeQueryForExtent(this._ensureQueryJSON(e),t?.signal);return{count:i,extent:k.fromJSON(r)}}_ensureQueryJSON(e){return null==e?new B({outSpatialReference:this.view.spatialReference}).toJSON():B.from(e).toJSON()}_ensureQueryEngine(){if(this._queryEngine)return this._queryEngine;const{spatialReference:e}=this.view;return this._queryEngine=new W({fieldsIndex:this.layer.fieldsIndex.toJSON(),geometryType:"esriGeometryPoint",spatialReference:e,featureIdInfo:{type:"object-id",fieldName:"objectId"},hasZ:!0,featureStore:new X({sourceSpatialReference:e,viewSpatialReference:e,forAllFeatures:(e,t)=>{let i=!1;this._renderer.forEachNode(r=>{if(i)return;if(t){const e=r.obb,s=U(e.center[0],e.center[1],e.center[2],C(e.halfSize));Q(s,this.view.renderSpatialReference,s,this.view.spatialReference);const o=t(s);if(2===o)return;if(i=0===o,i)return}let s=this._queryFeaturesCache.get(`${r.id}`);s||(s=this._createQueryPointFeatures(r),this._queryFeaturesCache.put(`${r.id}`,s)),s.features.forEach(e)})},getFeatureExtent:({point:e},t)=>E(e,e,t),featureAdapter:{cloneWithGeometry:(e,t)=>new Ee(e.node,e.pointId,t.coords),getAttribute:({node:e,attributePointId:t},i)=>{for(const r of e.attributes)if(r.attributeInfo.name===i)return this._getGraphicAttribute(r.attributeInfo,r.values,t)},getAttributes:({node:e,attributePointId:t})=>this._createGraphicAttributes(e,t),getCentroid:e=>e.getGeometry(),getGeometry:e=>e.getGeometry(),getObjectId:()=>{},getMetadata:e=>e}})}),this._queryEngine}_createQueryPointFeatures(e){const t=e.coordinates,i=new Array;for(let r=0;r<t.length/3;r++){const s=3*r,o=R(t[s+0],t[s+1],t[s+2]);S(o,o,e.origin),F(o,this.view.renderSpatialReference,o,this.view.spatialReference);const n=new Ee(e,r,o);i.push(n)}return new De(i)}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new oe(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then(e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()})}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then(t=>t.nodes.map((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:xe.fromJSON(t.obb),obbInRenderSR:new xe,firstChild:t.firstChild,childCount:t.childCount,vertexCount:t.vertexCount??t.pointCount,lodThreshold:t.lodThreshold??t.effectiveArea}))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=I(s,t.eye),n=D(s,-o,Qe),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const u=e=>l.push(e);return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return u(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(u(e),!1)},pageMiss:(e,t)=>{u(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw _(i)||n.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const s=this.layer.outFields;if(!s)return[];const o=z(this.layer.fieldsIndex,s),n=new Set(e.map(e=>null!=e?e.name:null)),a=this.layer.attributeStorageInfo,d=[];for(const r of o){if(n.has(r))continue;const e=me(a,r);e&&d.push(t(e))}const l=await m(d);return g(i),l.filter(r)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=pe(this.layer),s=ce(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push(async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),u=n(d),h=s.map(e=>e.attributeInfo),p=h.map(e=>n(e)),c=this._loadAdditionalUserAttributes([a,d,...h],n,t),[_,m,f,y,b]=await Promise.all([i,l,u,Promise.all(p),c]);g(t);const w={geometryBuffer:_,primaryAttributeData:m,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)},t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}async _requestNodePage(e,t){const r={f:"json",...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"json",signal:t};return(await i(e,s)).data}async _requestData(e,t){const r={...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"array-buffer",signal:t};return(await i(e,s)).data}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._memCache.put(t.id.toString(),t)}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(de(t))return t.splatSize=r,t.obb=s,A(t.origin,t.obb.center),t;const o=xe.fromData(t.obbData),a=o.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;n.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(o)}`),0===--this._maxLoggedBoxWarnings&&n.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,o)}return new le(e,r,j(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode(t=>{e+=Oe,e+=l(t.coordinates);for(const i of t.attributes){const t=i.values;N(t.buffer)&&(e+=l(t))}}),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount);let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Oe)/t)+i*Oe}get performanceInfo(){return new K(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount,0),this.maximumPointCount,new Z(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){}};e([v()],Fe.prototype,"layer",void 0),e([v()],Fe.prototype,"baseUrl",null),e([v()],Fe.prototype,"pointScale",null),e([v()],Fe.prototype,"useRealWorldSymbolSizes",null),e([v()],Fe.prototype,"pointSize",null),e([v()],Fe.prototype,"inverseDensity",null),e([v()],Fe.prototype,"maximumPointCount",void 0),e([v({readOnly:!0})],Fe.prototype,"availableFields",null),e([v({readOnly:!0})],Fe.prototype,"_clippingBox",null),e([v({readOnly:!0})],Fe.prototype,"_elevationOffset",null),e([v({type:Boolean})],Fe.prototype,"slicePlaneEnabled",void 0),e([v()],Fe.prototype,"_graphicOrigin",null),e([v()],Fe.prototype,"updating",void 0),e([v(Ce)],Fe.prototype,"updatingProgress",void 0),e([v({readOnly:!0})],Fe.prototype,"updatingProgressValue",null),e([v({readOnly:!0})],Fe.prototype,"visibleAtCurrentScale",null),Fe=e([x("esri.views.3d.layers.PointCloudLayerView3D")],Fe);const Le=Fe;class Ee{constructor(e,t,i){this.node=e,this.pointId=t,this.point=i}getGeometry(){return new M([],Array.from(this.point),!0,!1)}get attributePointId(){const{node:e,pointId:t}=this;return null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t}get usedMemory(){return u+u+h+p(this.point,h)}}class De{constructor(e){this.features=e}get usedMemory(){return this.features.reduce((e,t)=>e+t.usedMemory,u+c)}}const Oe=160;function Ue(e){return t=>e.immediate.schedule(t)}export{Le as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../request.js";import{isSome as r}from"../../../core/arrayUtils.js";import{result as s,forEach as o}from"../../../core/asyncUtils.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as d}from"../../../core/maybe.js";import{estimateNumberArrayMemory as l,baseObjectMemory as u,estimateNumberMemory as h,estimateFixedArrayMemory as p,baseArrayMemory as c}from"../../../core/memoryEstimations.js";import{isAbortError as _,allSettledValues as m,throwIfAborted as g}from"../../../core/promiseUtils.js";import{initial as f,watch as y,sync as b,syncAndInitial as w}from"../../../core/reactiveUtils.js";import{pt2px as P}from"../../../core/screenUtils.js";import{isArrayBuffer as N}from"../../../core/typedArrayUtil.js";import{property as v}from"../../../core/accessorSupport/decorators/property.js";import{subclass as x}from"../../../core/accessorSupport/decorators/subclass.js";import{b as C,g as S,f as I,d as A}from"../../../chunks/vec32.js";import{clone as j}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{fromValues as R}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import k from"../../../geometry/Extent.js";import V from"../../../geometry/Point.js";import{projectBoundingSphere as Q}from"../../../geometry/projection/projectBoundingSphere.js";import{projectVectorToVector as L}from"../../../geometry/projection/projectVectorToVector.js";import{create as F,fromMinMax as O}from"../../../geometry/support/aaBoundingBox.js";import{fromNormalAndOffset as D,create as E}from"../../../geometry/support/plane.js";import{f as U}from"../../../chunks/sphere.js";import M from"../../../layers/graphics/OptimizedGeometry.js";import{QueryEngine as W}from"../../../layers/graphics/data/QueryEngine.js";import{CodedValue as G}from"../../../layers/support/CodedValue.js";import q from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as z}from"../../../layers/support/fieldUtils.js";import{queueAutoPriority as H}from"../../../request/queue.js";import T from"../../../rest/support/FeatureSet.js";import B from"../../../rest/support/Query.js";import{getElevationOffset as J}from"../../../support/elevationInfoUtils.js";import{LayerView3D as $}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as K,QueuePerformanceInfo as Z}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as Y}from"./PointCloudWorkerHandle.js";import{I3SQueryFeatureStore as X}from"./i3s/I3SQueryFeatureStore.js";import{checkPointCloudLayerValid as ee,checkPointCloudLayerCompatibleWithView as te}from"./i3s/I3SUtil.js";import{nodeDiff as ie,sortFrontToBack as re,splitWorkEntries as se}from"./i3s/LoDUtil.js";import{PagedNodeIndex as oe}from"./i3s/PagedNodeIndex.js";import{PointCloudGraphic as ne}from"./i3s/PointCloudGraphic.js";import{PointCloudRenderer as ae}from"./i3s/PointCloudRenderer.js";import{isPointRendererNode as de,PointCloudRendererNode as le}from"./i3s/PointCloudRendererNode.js";import{getSplatSizeAlgorithm as ue,getFixedSizeAlgorithm as he,getRendererInfo as pe,getFilterInfo as ce,rendererUsesFixedSizes as _e,getAttributeInfo as me}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as ge,readGeometry as fe,elevationFromPositions as ye}from"./i3s/PointCloudWorkerUtil.js";import{normalizeHighlightTarget as be,emptyHighlightHandle as we}from"./support/highlightUtils.js";import{PopupSceneLayerView as Pe}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as Ne}from"../support/extentUtils.js";import{computeMapPointFromVec3d as ve}from"../support/hitTest.js";import{Obb as xe}from"../support/orientedBoundingBox.js";import{updatingProgress as Ce}from"../support/updatingProperties.js";import Se from"../../layers/LayerView.js";import{PointCloudLayerView as Ie}from"../../layers/PointCloudLayerView.js";import{getHighlightName as Ae}from"../../support/highlightOptionsUtils.js";import{isInEffectiveScaleRange as je}from"../../support/layerViewUtils.js";import{PromiseQueue as Re}from"../../support/PromiseQueue.js";import{TaskPriority as ke}from"../../support/Scheduler.js";const Ve=8,Qe=E();let Le=class extends(Ie(Pe($(Se)))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new Re,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl?.path??""}get pointScale(){const e=ue(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=he(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=he(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=pe(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=ce(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of z(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=F(),t=this.view.renderSpatialReference;return Ne(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;return e&&"absolute-height"===e.mode?J(e,this.layer.spatialReference):0}get _graphicOrigin(){return this.layer.graphicOrigin}initialize(){const e=this.view.resourceController,t=Ue(e);this._worker=new Y(t),this.addResolvingPromise(this._worker.promise),this.addResolvingPromise(this.layer.rootPagePromise),ee(this.layer),te(this.layer,this.view),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._queryFeaturesCache=r.newCache(`pcl-query-features-${this.layer.uid};`),this._updatingHandles.add(()=>this._clippingBox,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this._elevationOffset,()=>this._elevationOffsetChanged(),f),this._updatingHandles.add(()=>this.layer.renderer,()=>this._rendererChanged(),f),this._updatingHandles.add(()=>this.layer.filters,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.outFields,()=>this._reload(),f),this._updatingHandles.add(()=>this.layer.effectiveScaleRange,()=>this._setUpdateViewNeeded()),this._updatingHandles.add(()=>this.view.state.contentCamera,()=>this._setUpdateViewNeeded()),this.addHandles([y(()=>this.view.quality,()=>this._setUpdateViewNeeded(),b)]),this.addResolvingPromise(i),this.when(()=>{this.addHandles([e.scheduler.registerTask(ke.POINT_CLOUD_LAYER,this),y(()=>2===this.view.state.mode,()=>this._setUpdateViewNeeded(),w),this._updatingHandles.add(()=>this.suspended,e=>{e?this._clearNodeState():this._setUpdateViewNeeded()},f)])},()=>{this._updatingHandles.removeAll(),this.removeAllHandles()})}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=a(this._worker),this._destroyRenderer(),this._memCache=a(this._memCache),this._queryFeaturesCache=a(this._queryFeaturesCache),this._queryEngine=a(this._queryEngine),this._codedDomainPopulationAbortController=d(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ae({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerViewUid=this.uid,this._updatingHandles.add(()=>this._clippingBox,e=>this._renderer.clippingBox=e,f),this._updatingHandles.add(()=>this.suspended,e=>this._setPointsVisible(!e),f),this._updatingHandles.add(()=>this.pointScale,e=>this._renderer.scaleFactor=e,f),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add(()=>this.useRealWorldSymbolSizes,e=>this._renderer.useRealWorldSymbolSizes=e,f),this._updatingHandles.add(()=>this.pointSize,e=>{const t=P(e);this._renderer.size=e,this._renderer.sizePx=t},f),this._updatingHandles.add(()=>this.slicePlaneEnabled,e=>this._renderer.slicePlaneEnabled=e,f),this._updatingHandles.add(()=>this.inverseDensity,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.maximumPointCount,()=>this._setUpdateViewNeeded(),f),this._updatingHandles.add(()=>this.view.qualitySettings.sceneService.pointCloudLoDFactor,e=>{this._lodFactor=e,this._setUpdateViewNeeded()},f)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i,r){const s=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,o=i?"declaredClass"in i?i:ve(this.view,i):null;return r??=this._createGraphicAttributes(e,s),new ne({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:s,epoch:this._nodeLoadEpoch},geometry:o,attributes:r,layer:this.layer,sourceLayer:this.layer,origin:this._graphicOrigin})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_getGraphicAttribute(e,t,i){const r=e.storageInfo?.attributeValues,s=r?.valuesPerElement??1;if(1===s)return t[i];if("UInt8"===r?.valueType&&s<=4){let e=0;const r=i*s;for(let i=r;i<r+s;i++)e=(e<<8)+t[i];return e}}_encodeGraphicAttribute(e,t,i,r){r[e.name]=this._getGraphicAttribute(e,t,i)}_setPointsVisible(e){e&&!this._rendererAdded?(this.view.stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view.stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=_e(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_displayNodes(e){this._workQueue=ie([...this._renderedNodes],e,this._index),re(this._workQueue,this.view.state.contentCamera.viewForward,this._index),se(this._workQueue,Ve,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach(({abortController:t})=>e.push(t)),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach(t=>t.load.forEach(t=>e.add(t)));const t=new Array,i=new Map;this._loadingNodes.forEach((r,s)=>{e.has(s)?i.set(s,r):t.push(r)}),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter(e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0}),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach(({abortController:e})=>e.abort()),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach(e=>this._removeFromRenderer(e)),this._cancelNodeLoading()}get readyToRun(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.readyToRun}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run(()=>this._updateWorkQueues());this._indexQueue.length>0&&e.run(()=>this._processIndexQueue()););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then(t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()}).then(()=>{this._indexPagesLoading.delete(e)},()=>{this._indexPagesLoading.delete(e)}),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find(e=>!this._renderedNodes.has(e)))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map(e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return null!=i?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise})).then(t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)}).catch(()=>{}).then(()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.updating&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())}),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,t){const i="CLASS_CODE",r=this.layer.fieldsIndex.get(i);if(!r||r.domain)return;if(!e.includes(r.name))return;const o=await s(this.layer.queryCachedStatistics(i,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(r.domain=new q({name:"CLASS_CODE",codedValues:n.map(e=>new G({code:e.value,name:e.label}))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then(()=>{this._codedDomainPopulationAbortController=null})),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,t){const i=this._splitGraphicsPerNode(e),s=this.layer.attributeStorageInfo,n=t.map(e=>me(s,e)).filter(r),a=async(e,t)=>{const i=this._index.getNode(t);await o(n,async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}})},d=[];return i.forEach((e,t)=>{d.push(a(e,t))}),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof ne&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return i?ge({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=fe(t,await this._loadGeometry(e,null));return ye(i,i.length/3)}highlight(e,i){const r=be(e);if(0===r.length)return we;if(!(r[0]instanceof t))return we;const s=r;return this._renderer.highlight(s.map(e=>this._graphicToPointDefinition(e)),Ae(i))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}get visibleAtCurrentScale(){return je(this.layer.effectiveScaleRange,this.view.scale)}async queryFeatures(e,i){const r=await this._ensureQueryEngine().executeQuery(this._ensureQueryJSON(e),i?.signal),s=r.features;r.features=[];const o=T.fromJSON(r),n=this.view.spatialReference;return o.features=s.map(e=>{const{attributes:i,metadata:r}=e;if(!r){const i=t.fromJSON(e);return i.geometry&&(i.geometry.spatialReference=o.spatialReference??n),i.layer=this.layer,i.sourceLayer=this.layer,i.origin=this._graphicOrigin,i}const s=e.geometry?V.fromJSON(e.geometry):void 0;return s&&(s.spatialReference=o.spatialReference??n),this._createGraphic(r.node,r.pointId,s,i)}),o}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference,returnZ:!0};return new B(e)}async queryFeatureCount(e,t){return await this._ensureQueryEngine().executeQueryForCount(this._ensureQueryJSON(e),t?.signal)}async queryExtent(e,t){const{count:i,extent:r}=await this._ensureQueryEngine().executeQueryForExtent(this._ensureQueryJSON(e),t?.signal);return{count:i,extent:k.fromJSON(r)}}_ensureQueryJSON(e){return null==e?new B({outSpatialReference:this.view.spatialReference}).toJSON():B.from(e).toJSON()}_ensureQueryEngine(){if(this._queryEngine)return this._queryEngine;const{spatialReference:e}=this.view;return this._queryEngine=new W({fieldsIndex:this.layer.fieldsIndex.toJSON(),geometryType:"esriGeometryPoint",spatialReference:e,featureIdInfo:{type:"object-id",fieldName:"objectId"},hasZ:!0,featureStore:new X({sourceSpatialReference:e,viewSpatialReference:e,forAllFeatures:(e,t)=>{let i=!1;this._renderer.forEachNode(r=>{if(i)return;if(t){const e=r.obb,s=U(e.center[0],e.center[1],e.center[2],C(e.halfSize));Q(s,this.view.renderSpatialReference,s,this.view.spatialReference);const o=t(s);if(2===o)return;if(i=0===o,i)return}let s=this._queryFeaturesCache.get(`${r.id}`);s||(s=this._createQueryPointFeatures(r),this._queryFeaturesCache.put(`${r.id}`,s)),s.features.forEach(e)})},getFeatureExtent:({point:e},t)=>O(e,e,t),featureAdapter:{cloneWithGeometry:(e,t)=>new Oe(e.node,e.pointId,t.coords),getAttribute:({node:e,attributePointId:t},i)=>{for(const r of e.attributes)if(r.attributeInfo.name===i)return this._getGraphicAttribute(r.attributeInfo,r.values,t)},getAttributes:({node:e,attributePointId:t})=>this._createGraphicAttributes(e,t),getCentroid:e=>e.getGeometry(),getGeometry:e=>e.getGeometry(),getObjectId:()=>{},getMetadata:e=>e}})}),this._queryEngine}_createQueryPointFeatures(e){const t=e.coordinates,i=new Array;for(let r=0;r<t.length/3;r++){const s=3*r,o=R(t[s+0],t[s+1],t[s+2]);S(o,o,e.origin),L(o,this.view.renderSpatialReference,o,this.view.spatialReference);const n=new Oe(e,r,o);i.push(n)}return new De(i)}async _initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;this._index=new oe(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock;const i=await this.layer.rootPagePromise;this._loadingInitNodePage=!1,i?(this._index.addPage(0,this._processJSONNodes(i,0),this._elevationOffset),this._setUpdateViewNeeded()):n.getLogger(this).error("Point cloud layer root page not loaded")}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then(t=>this._processJSONNodes(t,e)),abortController:t}}_processJSONNodes(e,t){const i=t*this._index.pageSize;return e.nodes.map((e,t)=>({resourceId:e.resourceId??i+t,obb:xe.fromJSON(e.obb),obbInRenderSR:new xe,firstChild:e.firstChild,childCount:e.childCount,vertexCount:e.vertexCount??e.pointCount,lodThreshold:e.lodThreshold??e.effectiveArea}))}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=I(s,t.eye),n=D(s,-o,Qe),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const u=e=>l.push(e);return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return u(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(u(e),!1)},pageMiss:(e,t)=>{u(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw _(i)||n.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,t,i){const s=this.layer.outFields;if(!s)return[];const o=z(this.layer.fieldsIndex,s),n=new Set(e.map(e=>null!=e?e.name:null)),a=this.layer.attributeStorageInfo,d=[];for(const r of o){if(n.has(r))continue;const e=me(a,r);e&&d.push(t(e))}const l=await m(d);return g(i),l.filter(r)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=pe(this.layer),s=ce(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push(async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),u=n(d),h=s.map(e=>e.attributeInfo),p=h.map(e=>n(e)),c=this._loadAdditionalUserAttributes([a,d,...h],n,t),[_,m,f,y,b]=await Promise.all([i,l,u,Promise.all(p),c]);g(t);const w={geometryBuffer:_,primaryAttributeData:m,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)},t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}async _requestNodePage(e,t){const r={f:"json",...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"json",signal:t};return(await i(e,s)).data}async _requestData(e,t){const r={...this.layer.customParameters,token:this.layer.apiKey},s={...H,query:r,responseType:"array-buffer",signal:t};return(await i(e,s)).data}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._memCache.put(t.id.toString(),t)}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(de(t))return t.splatSize=r,t.obb=s,A(t.origin,t.obb.center),t;const o=xe.fromData(t.obbData),a=o.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;n.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(o)}`),0===--this._maxLoggedBoxWarnings&&n.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,o)}return new le(e,r,j(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode(t=>{e+=Ee,e+=l(t.coordinates);for(const i of t.attributes){const t=i.values;N(t.buffer)&&(e+=l(t))}}),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount);let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Ee)/t)+i*Ee}get performanceInfo(){return new K(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce((e,t)=>e+this._index.getNode(t).vertexCount,0),this.maximumPointCount,new Z(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){}};e([v()],Le.prototype,"layer",void 0),e([v()],Le.prototype,"baseUrl",null),e([v()],Le.prototype,"pointScale",null),e([v()],Le.prototype,"useRealWorldSymbolSizes",null),e([v()],Le.prototype,"pointSize",null),e([v()],Le.prototype,"inverseDensity",null),e([v()],Le.prototype,"maximumPointCount",void 0),e([v({readOnly:!0})],Le.prototype,"availableFields",null),e([v({readOnly:!0})],Le.prototype,"_clippingBox",null),e([v({readOnly:!0})],Le.prototype,"_elevationOffset",null),e([v({type:Boolean})],Le.prototype,"slicePlaneEnabled",void 0),e([v()],Le.prototype,"_graphicOrigin",null),e([v()],Le.prototype,"updating",void 0),e([v(Ce)],Le.prototype,"updatingProgress",void 0),e([v({readOnly:!0})],Le.prototype,"updatingProgressValue",null),e([v({readOnly:!0})],Le.prototype,"visibleAtCurrentScale",null),Le=e([x("esri.views.3d.layers.PointCloudLayerView3D")],Le);const Fe=Le;class Oe{constructor(e,t,i){this.node=e,this.pointId=t,this.point=i}getGeometry(){return new M([],Array.from(this.point),!0,!1)}get attributePointId(){const{node:e,pointId:t}=this;return null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t}get usedMemory(){return u+u+h+p(this.point,h)}}class De{constructor(e){this.features=e}get usedMemory(){return this.features.reduce((e,t)=>e+t.usedMemory,u+c)}}const Ee=160;function Ue(e){return t=>e.immediate.schedule(t)}export{Fe as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{estimateNumberArrayMemory as i}from"../../../core/memoryEstimations.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{j as u}from"../../../chunks/vec32.js";import{create as h,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as c}from"../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as g}from"../../../geometry/projection/projectVectorToVector.js";import{extentContainsCoords3D as m,extentContainsCoords2D as y}from"../../../geometry/support/contains.js";import{newDoubleArray as f,doubleArrayFrom as _}from"../../../geometry/support/DoubleArray.js";import{getGeometryZScaler as b}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as v}from"../../../layers/LayerConstants.js";import{estimateSize as I}from"../../../layers/graphics/dehydratedFeatures.js";import{ImmutableDehydratedPoint as x}from"../../../layers/graphics/dehydratedPoint.js";import{hydrateGraphic as E}from"../../../layers/graphics/hydratedFeatures.js";import w from"../../../layers/graphics/controllers/I3SOnDemandController.js";import j from"../../../layers/support/FeatureFilter.js";import O from"../../../rest/support/Query.js";import{isBasemapLayerView as N}from"../../../support/basemapUtils.js";import{isGraphic as C}from"../../../support/guards.js";import{I3SPointsWorkerHandle as D}from"./I3SPointsWorkerHandle.js";import{LayerView3D as S}from"./LayerView3D.js";import{Graphics3DFeatureProcessor as F}from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as G}from"./graphics/QueryEngine.js";import{QueryEngineContext as A}from"./graphics/QueryEngineContext.js";import{createInteractiveEditSession as V,normalizeEditResultsEvent as P,processAttributeEdits as L}from"./i3s/featureEditing.js";import{getCachedAttributeValue as R}from"./i3s/I3SBinaryReader.js";import{I3SGraphicsMap as H}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as M}from"./i3s/I3SOverrides.js";import{checkRecyclable as U,checkSpatialReferences as Q,containsDraco as q,whenGraphicAttributes as T}from"./i3s/I3SUtil.js";import{attributeLookup as B}from"./support/attributeUtils.js";import{DefinitionExpressionSceneLayerView as k}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{normalizeHighlightTarget as W,emptyHighlightHandle as K,isObjectId as Z}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as $}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as Y}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as J}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as X}from"./support/TemporalSceneLayerView.js";import{debugFlags as ee}from"../support/debugFlags.js";import{compute as te}from"../support/orientedBoundingBox.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{Vertices as ie}from"../webgl-engine/lib/Attribute.js";import se from"../../layers/SceneLayerView.js";import{hasPopupTemplate as oe}from"../../layers/support/popupUtils.js";import{getHighlightName as ae}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as ne,isInEffectiveScaleRange as le}from"../../support/layerViewUtils.js";import{TaskPriority as de}from"../../support/Scheduler.js";const ue=z();class he{constructor(e,t,r,i){this.graphics=e,this.featureIds=t,this.attributeInfo=r,this.node=i}get usedMemory(){return this.graphics.reduce((e,t)=>I(t)+e,i(this.featureIds)+1024)}}let pe=class extends(X(k(Y(S(se))))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this._pendingEditsQueue=Promise.resolve(),this.loadedGraphics=new H((e,t,r)=>ye(e,t,r),e=>this.processor.graphicsCore.recreateGraphics(e)),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(e,t){return e.url===this.layer.url&&this._i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),U(this.layer,e,this._i3sOverrides),this.layer=e,this._i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:e,memoryController:i}),r(this._queryEngine),this._setupQueryEngine(),this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);const e=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:this.layer,memoryController:e}),Q(this.layer,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new J({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),o),this._updatingHandles.add(()=>this.layer.renderer,(e,t)=>this._rendererChange(e,t)),this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this.layer.excludeObjectIds],()=>this._filterChange()),this._set("processor",new F({owner:this,preferredUpdatePolicy:0,scaleVisibilityEnabled:!ne(),filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:e,spatialReference:t})=>this._controller.updateElevationChanged(e,t)),this.supportsHeightUnitConversion&&(this._verticalScale=b("point",this.layer.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.when()),this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`),this._controller=new w({layerView:this}),q(this.layer.geometryDefinitions)&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e))),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles([this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}),a(()=>ee.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ee.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||!this._treeDebugger||ee.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},o)]),this.when(()=>{this._setupQueryEngine(),this._updatingHandles.add(()=>this.maximumNumberOfFeatures,e=>this._controller.featureTarget=e,o),this._updatingHandles.add(()=>this.suspended,e=>{e&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=r(this._treeDebugger),this._i3sOverrides=r(this._i3sOverrides),this._set("processor",r(this.processor)),this._controller=r(this._controller),this._queryEngine=r(this._queryEngine),this._workerHandle=r(this._workerHandle),this._memCache=r(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=r(this._fieldsHelper)}get i3slayer(){return this.layer}get layerViewUid(){return this.uid}get updatingProgressValue(){return this._controller?.updatingProgress??1}get visibleAtCurrentScale(){return ne()?le(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIds(){return new Set(this.layer.excludeObjectIds)}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.point.lodFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get _graphicOrigin(){return this.layer.graphicOrigin}async whenGraphicAttributes(e,t){return T(this.layer,e,this._getObjectIdField(),t,()=>[...this.loadedGraphics.nodes()])}getHit(e){if(!this.loadedGraphics)return null;const t=E(this.loadedGraphics.find(t=>t.uid===e),this.layer,this._graphicOrigin),r=this._getObjectIdField();return null==t?.attributes?.[r]?null:{type:"graphic",graphic:t,layer:t.layer}}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e,t){const r=ae(t),i=this.layer.objectIdField,s=W(e);if(0===s.length)return K;if(C(s[0])){const e=s;if(null!=B(this.layer.fieldsIndex,e[0].attributes,i)){const t=e.map(e=>B(this.layer.fieldsIndex,e.attributes,i));return this.processor.highlightByObjectIds(t,i,r)}return this.processor.highlightByGraphics(e,r)}return Z(s[0])?this.processor.highlightByObjectIds(s,i,r):K}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return V(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};null==this._workerHandle&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e)));const i=await this._workerHandle.invoke(r,t);if(null==i)throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,r,i){if(!me(r)&&!ge(r))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void t.getLogger(this).error("I3S node "+e.id+" already added");const s=null!=this.layer.fullExtent?_e(this.layer.fullExtent.clone(),.5):null,{featureIds:o,pointPositions:a}=me(r)?await this._extractBinaryPointPositions(e,r,i):this._extractLegacyPointPositions(r),n=new Array;this._validatePositions(e,o,a,s,n);const l=this._controller.crsVertex,d=this.view.spatialReference;c(a,l,0,a,d,0,o.length);const u=me(r)?e.level:0,h=this._createGraphics(o,a,e.index,u),p=new he(h,o,r.attributeDataInfo,e);if(await this._i3sOverrides.applyAttributeOverrides(p.featureIds,r.attributeDataInfo,i),e.numFeatures=p.graphics.length,this._updateNodeMemory(e),fe(p),n.length>0&&(this._computeObb(e,n,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(p);if(null!=this._verticalScale)for(const t of p.graphics)this._verticalScale(t.geometry);const g=this.view.stage.renderView.olidRenderHelper;if(g){const e=N(this.view,this.uid);for(let t=0;t<p.featureIds.length;t++){const r=p.featureIds[t];g.setUidToObjectAndLayerId(r,p.graphics[t].uid,this.layer.id,this.uid,this.layer.popupEnabled&&!e&&oe(this.layer,this.view.popup?.defaultPopupTemplateEnabled),p.node.resources.attributes,t)}}this.loadedGraphics.addNode(e.index,p),this._controller.updateLoadStatus(e.index,!0),this._filterNode(p),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;c(t,r,0,t,s,0),e.serviceObbInIndexSR=te(new ie(t,3)),i.isGeographic&&(g(e.serviceObbInIndexSR.center,s,ve,i),e.serviceObbInIndexSR.center=ve)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}getNodeComponentHandle(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,a=s.length/o,n=f(3*a),l=null!=e.serviceObbInIndexSR?e.serviceObbInIndexSR.center:p,d=Math.abs(l[2])*2**-20;for(let u=0;u<a;u++){const e=u*o;n[e]=s[e]+l[0],n[e+1]=s[e+1]+l[1],n[e+2]=s[e+2]+l[2],Math.abs(n[e+2])<d&&(n[e+2]=0)}return{featureIds:i.featureIds?_(i.featureIds):[],pointPositions:n}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=f(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??be[a],l=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const d=n.params.vertexAttributes?.position??[0,0,0],u=3*i.length;r[u]=o[0]+d[0],r[u+1]=o[1]+d[1],r[u+2]=3===a?o[2]+d[2]:NaN,i.push(l)}return{featureIds:i,pointPositions:r}}_validatePositions(e,r,i,s,o){if(null==s&&e.serviceObbInIndexSR)return;const a=r.length,n=3;for(let l=0;l<a;l++){const r=l*n;u(ve,i[r],i[r+1],i[r+2]);const a=!Number.isNaN(i[2]);null==s||(a?m(s,ve):y(s,ve))||(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObbInIndexSR||o.push(ve[0],ve[1],ve[2])}}_createGraphics(e,t,r,i){const s=e.length,o=3,a=this._getObjectIdField(),l=this.processor.graphicsCore,d=new Array,u=this.view.spatialReference;for(let h=0;h<s;h++){const s=e[h],p={};null!=s&&(p[a]=s);const c=s??n(),g=h*o,m=isNaN(t[g+2])?void 0:t[g+2],y=new x(u,t[g],t[g+1],m),f=this.loadedGraphics.get(c);if(null!=f)(null==f.level||f.level<i)&&(Ie.property="geometry",Ie.graphic=f,Ie.oldValue=f.geometry,Ie.newValue=y,f.geometry=y,f.level=i,l.graphicUpdateHandler(Ie),xe()),d.push(f);else{const e=n();d.push({objectId:c,uid:e,geometry:y,attributes:p,visible:!0,nodeIndex:r,level:i})}}return d}_updateNodeMemory(e){e.memory=4096+(e.numFeatures??0)*this.processor.graphicsCore.usedMemoryPerGraphic}_cacheNodeData(e){this._memCache.put(this._getMemCacheKey(e.node),e)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)}),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return null==t?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,r,i,s){this.loadedGraphics.hasNode(e.index)?t.getLogger(this).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(r.featureIds,i,s),r.attributeInfo=i,this.loadedGraphics.addNode(e.index,r),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),fe(r),this._filterNode(r),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode(t=>e.push(t.node.id)),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode(t=>e.push(t.node)),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode((t,r)=>e.push(r))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);null!=r?.attributeInfo&&(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);null!=i&&(await this._i3sOverrides.applyAttributeOverrides(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){fe(e),this._filterNode(e);const{processor:t}=this,{graphicsCore:r}=t;if(r.labelsEnabled){const t=e.node.index,i=new Array;e.graphics.forEach(e=>e.nodeIndex===t&&i.push(e.uid)),r.updateLabelingInfo(i)}t.refreshFilter()}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||v}_getGlobalIdField(){return this.layer.globalIdField}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every((e,t)=>s[t]===o[t])||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&t.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode(e=>this._filterNode(e))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,r=this._excludeObjectIds,i=this._getObjectIdField();for(const s of e.graphics){const e=s.visible,o=this._evaluateClause(t,s),a=!r.has(s.attributes[i]);s.visible=o&&a,e!==s.visible&&(Ie.graphic=s,Ie.property="visible",Ie.oldValue=e,Ie.newValue=s.visible,this.processor.graphicsCore.graphicUpdateHandler(Ie),xe())}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return this.filter?.createQuery(e)??new O(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():O.from(e))}_setupQueryEngine(){const{layer:e,view:t,hasM:r,hasZ:i}=this,{spatialReference:s,resourceController:o}=t,a=new A(s,e,o,()=>this.processor.featureStore,i,r);this._queryEngine=new G({context:a,priority:de.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory??0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(e){const t=this._attributeEditingContext,r=await P(t,e);L(t,r)}get _attributeEditingContext(){const e=this._getObjectIdField(),t=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,globalIdField:t,forEachNode:e=>this.loadedGraphics.forEachNode(t=>e(t.node,t.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(null!=i){const t=this.loadedGraphics.get(i.attributes[e]);null!=t&&this.processor.graphicsCore.recreateGraphics([t])}else null!=s&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){return new $(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};e([l()],pe.prototype,"processor",void 0),e([l({type:j})],pe.prototype,"filter",void 0),e([l()],pe.prototype,"loadedGraphics",void 0),e([l()],pe.prototype,"i3slayer",null),e([l()],pe.prototype,"layerViewUid",null),e([l()],pe.prototype,"_controller",void 0),e([l()],pe.prototype,"updating",void 0),e([l()],pe.prototype,"suspended",void 0),e([l(re)],pe.prototype,"updatingProgress",void 0),e([l()],pe.prototype,"updatingProgressValue",null),e([l({readOnly:!0})],pe.prototype,"visibleAtCurrentScale",null),e([l(ue.requiredFields)],pe.prototype,"requiredFields",null),e([l(ue.availableFields)],pe.prototype,"availableFields",void 0),e([l()],pe.prototype,"_fieldsHelper",void 0),e([l({type:Number})],pe.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0})],pe.prototype,"maximumNumberOfFeaturesExceeded",null),e([l()],pe.prototype,"_excludeObjectIds",null),e([l({readOnly:!0})],pe.prototype,"lodFactor",null),e([l({readOnly:!0})],pe.prototype,"hasM",null),e([l({readOnly:!0})],pe.prototype,"hasZ",null),e([l()],pe.prototype,"contentVisible",null),e([l({readOnly:!0})],pe.prototype,"legendEnabled",null),e([l()],pe.prototype,"_graphicOrigin",null),pe=e([d("esri.views.3d.layers.SceneLayerGraphicsView3D")],pe);const ce=pe;function ge(e){return"pointData"in e}function me(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ye(e,t,r){const i=t.attributeInfo;if(null==i?.loadedAttributes||null==i.attributeData)return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=R(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function fe(e){const t=e.attributeInfo;if(null==t?.loadedAttributes||null==t.attributeData)return;const r=e.node.index;for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=R(t.attributeData[e],i))}}}function _e(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const be={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},ve=h(),Ie={graphic:null,property:null,oldValue:null,newValue:null};function xe(){Ie.graphic=null,Ie.property=null,Ie.oldValue=null,Ie.newValue=null}export{ce as default};
5
+ import{__decorate as e}from"tslib";import"../../../core/has.js";import t from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{estimateNumberArrayMemory as i}from"../../../core/memoryEstimations.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import{initial as o,watch as a}from"../../../core/reactiveUtils.js";import{generateUID as n}from"../../../core/uid.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{j as u}from"../../../chunks/vec32.js";import{create as h,ZEROS as p}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBuffer as c}from"../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as g}from"../../../geometry/projection/projectVectorToVector.js";import{extentContainsCoords3D as m,extentContainsCoords2D as y}from"../../../geometry/support/contains.js";import{newDoubleArray as f,doubleArrayFrom as _}from"../../../geometry/support/DoubleArray.js";import{getGeometryZScaler as b}from"../../../geometry/support/zscale.js";import{fallbackObjectIDAttribute as v}from"../../../layers/LayerConstants.js";import{estimateSize as I}from"../../../layers/graphics/dehydratedFeatures.js";import{ImmutableDehydratedPoint as x}from"../../../layers/graphics/dehydratedPoint.js";import{hydrateGraphic as E}from"../../../layers/graphics/hydratedFeatures.js";import w from"../../../layers/graphics/controllers/I3SOnDemandController.js";import j from"../../../layers/support/FeatureFilter.js";import O from"../../../rest/support/Query.js";import{isBasemapLayerView as N}from"../../../support/basemapUtils.js";import{isGraphic as C}from"../../../support/guards.js";import{I3SPointsWorkerHandle as D}from"./I3SPointsWorkerHandle.js";import{LayerView3D as S}from"./LayerView3D.js";import{Graphics3DFeatureProcessor as F}from"./graphics/Graphics3DFeatureProcessor.js";import{QueryEngine as G}from"./graphics/QueryEngine.js";import{QueryEngineContext as A}from"./graphics/QueryEngineContext.js";import{createInteractiveEditSession as V,normalizeEditResultsEvent as P,processAttributeEdits as L}from"./i3s/featureEditing.js";import{getCachedAttributeValue as R}from"./i3s/I3SBinaryReader.js";import{I3SGraphicsMap as H}from"./i3s/I3SGraphicsMap.js";import{I3SOverrides as M}from"./i3s/I3SOverrides.js";import{checkRecyclable as U,checkSpatialReferences as Q,containsDraco as q,whenGraphicAttributes as T}from"./i3s/I3SUtil.js";import{attributeLookup as B}from"./support/attributeUtils.js";import{DefinitionExpressionSceneLayerView as k}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as z}from"./support/fieldProperties.js";import{normalizeHighlightTarget as W,emptyHighlightHandle as K,isObjectId as Z}from"./support/highlightUtils.js";import{LayerViewPerformanceInfo as $}from"./support/LayerViewPerformanceInfo.js";import{PopupSceneLayerView as Y}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as J}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as X}from"./support/TemporalSceneLayerView.js";import{debugFlags as ee}from"../support/debugFlags.js";import{compute as te}from"../support/orientedBoundingBox.js";import{updatingProgress as re}from"../support/updatingProperties.js";import{Vertices as ie}from"../webgl-engine/lib/Attribute.js";import se from"../../layers/SceneLayerView.js";import{hasPopupTemplate as oe}from"../../layers/support/popupUtils.js";import{getHighlightName as ae}from"../../support/highlightOptionsUtils.js";import{hasLayerBasedScaleVisibility as ne,isInEffectiveScaleRange as le}from"../../support/layerViewUtils.js";import{TaskPriority as de}from"../../support/Scheduler.js";const ue=z();class he{constructor(e,t,r,i){this.graphics=e,this.featureIds=t,this.attributeInfo=r,this.node=i}get usedMemory(){return this.graphics.reduce((e,t)=>I(t)+e,i(this.featureIds)+1024)}}let pe=class extends(X(k(Y(S(se))))){constructor(){super(...arguments),this.type="scene-layer-graphics-3d",this._queryEngine=null,this._memCache=null,this._interactiveEditingSessions=new Map,this._pendingEditsQueue=Promise.resolve(),this.loadedGraphics=new H((e,t,r)=>ye(e,t,r),e=>this.processor.graphicsCore.recreateGraphics(e)),this.holeFilling="always",this.progressiveLoadFactor=1,this.supportsHeightUnitConversion=!0,this._coordinatesOutsideExtentErrors=0,this._maxCoordinatesOutsideExtentErrors=20}tryRecycleWith(e,t){return e.url===this.layer.url&&this._i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),U(this.layer,e,this._i3sOverrides),this.layer=e,this._i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:e,memoryController:i}),r(this._queryEngine),this._setupQueryEngine(),this.processor.resetObjectStates()}):null}initialize(){this.addResolvingPromise(this.layer.indexInfo);const e=this.view.resourceController?.memoryController;this._i3sOverrides=new M({view:this.view,layer:this.layer,memoryController:e}),Q(this.layer,this.view.spatialReference,this.view.viewingMode),this._fieldsHelper=new J({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),o),this._updatingHandles.add(()=>this.layer.renderer,(e,t)=>this._rendererChange(e,t)),this._updatingHandles.add(()=>[this.parsedDefinitionExpression,this.layer.excludeObjectIds],()=>this._filterChange()),this._set("processor",new F({owner:this,preferredUpdatePolicy:0,scaleVisibilityEnabled:!ne(),filterVisibilityEnabled:!0,timeExtentEnabled:!1,frustumVisibilityEnabled:!1,elevationAlignmentEnabled:!0,elevationFeatureExpressionEnabled:!1,setUidToIdOnAdd:!1,dataExtent:this.layer.fullExtent,updateClippingExtent:e=>this._updateClippingExtent(e)})),this.processor.elevationAlignment?.events.on("invalidate-elevation",({extent:e,spatialReference:t})=>this._controller.updateElevationChanged(e,t)),this.supportsHeightUnitConversion&&(this._verticalScale=b("point",this.layer.spatialReference,this.view.spatialReference)),this.addResolvingPromise(this.processor.when()),this._memCache=this.view.resourceController.memoryController.newCache(`psl-${this.uid}`),this._controller=new w({layerView:this}),q(this.layer.geometryDefinitions)&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e))),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles([this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}),a(()=>ee.I3S_TREE_SHOW_TILES,e=>{if(e&&!this._treeDebugger){const e=this._controller.crsIndex;import("./support/I3STreeDebugger.js").then(({I3STreeDebugger:t})=>{!this._treeDebugger&&ee.I3S_TREE_SHOW_TILES&&(this._treeDebugger=new t({lv:this,view:this.view,nodeSR:e}))})}else e||!this._treeDebugger||ee.I3S_TREE_SHOW_TILES||(this._treeDebugger.destroy(),this._treeDebugger=null)},o)]),this.when(()=>{this._setupQueryEngine(),this._updatingHandles.add(()=>this.maximumNumberOfFeatures,e=>this._controller.featureTarget=e,o),this._updatingHandles.add(()=>this.suspended,e=>{e&&this._removeAllNodeData()})})}destroy(){this._treeDebugger=r(this._treeDebugger),this._i3sOverrides=r(this._i3sOverrides),this._set("processor",r(this.processor)),this._controller=r(this._controller),this._queryEngine=r(this._queryEngine),this._workerHandle=r(this._workerHandle),this._memCache=r(this._memCache),this.loadedGraphics.clear(),this._fieldsHelper=r(this._fieldsHelper)}get i3slayer(){return this.layer}get layerViewUid(){return this.uid}get updatingProgressValue(){return this._controller?.updatingProgress??1}get visibleAtCurrentScale(){return ne()?le(this.layer.effectiveScaleRange,this.view.scale):!this.processor?.scaleVisibilitySuspended}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get maximumNumberOfFeatures(){const e=this.processor?.graphicsCore?.displayFeatureLimit;return e?.maximumNumberOfFeatures??0}set maximumNumberOfFeatures(e){null!=e?(this._override("maximumNumberOfFeatures",e),this._controller.fixedFeatureTarget=!0):(this._clearOverride("maximumNumberOfFeatures"),this._controller.fixedFeatureTarget=!1)}get maximumNumberOfFeaturesExceeded(){return!this.suspended&&(!!this._controller?.useMaximumNumberOfFeatures&&!this._controller.leavesReached)}get _excludeObjectIds(){return new Set(this.layer.excludeObjectIds)}get lodFactor(){return"Labels"===this.layer.semantic?1:this.view.qualitySettings.sceneService.pointLoDFactor}get hasM(){return!1}get hasZ(){return!0}get contentVisible(){return!this.suspended&&!!this._controller?.rootNodeVisible}get legendEnabled(){return this.contentVisible&&!0===this.i3slayer?.legendEnabled}get _graphicOrigin(){return this.layer.graphicOrigin}async whenGraphicAttributes(e,t){return T(this.layer,e,this._getObjectIdField(),t,()=>[...this.loadedGraphics.nodes()])}getHit(e){if(!this.loadedGraphics)return null;const t=E(this.loadedGraphics.find(t=>t.uid===e),this.layer,this._graphicOrigin),r=this._getObjectIdField();return null==t?.attributes?.[r]?null:{type:"graphic",graphic:t,layer:t.layer}}whenGraphicBounds(e,t){return this.processor.whenGraphicBounds(e,t)}computeAttachmentOrigin(e,t){return this.processor.computeAttachmentOrigin(e,t)}isUpdating(){return!!(this._controller?.updating||this.processor?.updating||this._fieldsHelper?.updating||this.layerFilterUpdating)}highlight(e,t){const r=ae(t),i=this.layer.objectIdField,s=W(e);if(0===s.length)return K;if(C(s[0])){const e=s;if(null!=B(this.layer.fieldsIndex,e[0].attributes,i)){const t=e.map(e=>B(this.layer.fieldsIndex,e.attributes,i));return this.processor.highlightByObjectIds(t,i,r)}return this.processor.highlightByGraphics(e,r)}return Z(s[0])?this.processor.highlightByObjectIds(s,i,r):K}get updatePolicy(){return this.processor.graphicsCore.effectiveUpdatePolicy}createInteractiveEditSession(e){return V(this._attributeEditingContext,e)}async _decompressBinaryPointData(e,t){const r={geometryBuffer:e.geometryBuffer};null==this._workerHandle&&(this._workerHandle=new D(e=>this.view.resourceController.immediate.schedule(e)));const i=await this._workerHandle.invoke(r,t);if(null==i)throw new Error("Failed to decompress Draco point data");return{positionData:i.positions,featureIds:i.featureIds}}async addNode(e,r,i){if(!me(r)&&!ge(r))throw new Error;if(this.loadedGraphics.hasNode(e.index))return void t.getLogger(this).error("I3S node "+e.id+" already added");const s=null!=this.layer.fullExtent?_e(this.layer.fullExtent.clone(),.5):null,{featureIds:o,pointPositions:a}=me(r)?await this._extractBinaryPointPositions(e,r,i):this._extractLegacyPointPositions(r),n=new Array;this._validatePositions(e,o,a,s,n);const l=this._controller.crsVertex,d=this.view.spatialReference;c(a,l,0,a,d,0,o.length);const u=me(r)?e.level:0,h=this._createGraphics(o,a,e.index,u),p=new he(h,o,r.attributeDataInfo,e);if(await this._i3sOverrides.applyAttributeOverrides(p.featureIds,r.attributeDataInfo,i),e.numFeatures=p.graphics.length,this._updateNodeMemory(e),fe(p),n.length>0&&(this._computeObb(e,n,l),this._controller.updateVisibility(e.index)),!this._controller.isGeometryVisible(e))return void this._cacheNodeData(p);if(null!=this._verticalScale)for(const t of p.graphics)this._verticalScale(t.geometry);const g=this.view.stage.renderView.olidRenderHelper;if(g){const e=N(this.view,this.uid);for(let t=0;t<p.featureIds.length;t++){const r=p.featureIds[t];g.setUidToObjectAndLayerId(r,p.graphics[t].uid,this.layer.id,this.uid,this.layer.popupEnabled&&!e&&oe(this.layer,this.view.popup?.defaultPopupTemplateEnabled),p.node.resources.attributes,t)}}this.loadedGraphics.addNode(e.index,p),this._controller.updateLoadStatus(e.index,!0),this._filterNode(p),this._treeDebugger&&this._treeDebugger.update()}_computeObb(e,t,r){const i=this._controller.crsIndex,s=i.isGeographic?this.view.renderSpatialReference:i;c(t,r,0,t,s,0),e.serviceObbInIndexSR=te(new ie(t,3)),i.isGeographic&&(g(e.serviceObbInIndexSR.center,s,ve,i),e.serviceObbInIndexSR.center=ve)}isNodeLoaded(e){return this.loadedGraphics.hasNode(e)}isNodeReloading(){return!1}updateNodeState(){}getNodeComponentHandle(){}async _extractBinaryPointPositions(e,t,r){const i=await this._decompressBinaryPointData(t,r),s=i.positionData,o=3,a=s.length/o,n=f(3*a),l=null!=e.serviceObbInIndexSR?e.serviceObbInIndexSR.center:p,d=Math.abs(l[2])*2**-20;for(let u=0;u<a;u++){const e=u*o;n[e]=s[e]+l[0],n[e+1]=s[e+1]+l[1],n[e+2]=s[e+2]+l[2],Math.abs(n[e+2])<d&&(n[e+2]=0)}return{featureIds:i.featureIds?_(i.featureIds):[],pointPositions:n}}_extractLegacyPointPositions(e){const t=e.pointData.length,r=f(3*t),i=new Array;for(let s=0;s<t;s++){const t=e.pointData[s],o=t.featureDataPosition,a=o.length,n=t.geometries?.[0]??be[a],l=t.featureIds[0];if("Embedded"!==n.type||"points"!==n.params.type||a<2||a>3)continue;const d=n.params.vertexAttributes?.position??[0,0,0],u=3*i.length;r[u]=o[0]+d[0],r[u+1]=o[1]+d[1],r[u+2]=3===a?o[2]+d[2]:NaN,i.push(l)}return{featureIds:i,pointPositions:r}}_validatePositions(e,r,i,s,o){if(null==s&&e.serviceObbInIndexSR)return;const a=r.length,n=3;for(let l=0;l<a;l++){const r=l*n;u(ve,i[r],i[r+1],i[r+2]);const a=!Number.isNaN(i[2]);null==s||(a?m(s,ve):y(s,ve))||(this._coordinatesOutsideExtentErrors<this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Service Error: Coordinates outside of layer extent"),this._coordinatesOutsideExtentErrors+1===this._maxCoordinatesOutsideExtentErrors&&t.getLogger(this).error("Maximum number of errors reached. Further errors are ignored."),this._coordinatesOutsideExtentErrors++),e.serviceObbInIndexSR||o.push(ve[0],ve[1],ve[2])}}_createGraphics(e,t,r,i){const s=e.length,o=3,a=this._getObjectIdField(),l=this.processor.graphicsCore,d=new Array,u=this.view.spatialReference;for(let h=0;h<s;h++){const s=e[h],p={};null!=s&&(p[a]=s);const c=s??n(),g=h*o,m=isNaN(t[g+2])?void 0:t[g+2],y=new x(u,t[g],t[g+1],m),f=this.loadedGraphics.get(c);if(null!=f)(null==f.level||f.level<i)&&(Ie.property="geometry",Ie.graphic=f,Ie.oldValue=f.geometry,Ie.newValue=y,f.geometry=y,f.level=i,l.graphicUpdateHandler(Ie),xe()),d.push(f);else{const e=n();d.push({objectId:c,uid:e,geometry:y,attributes:p,visible:!0,nodeIndex:r,level:i})}}return d}_updateNodeMemory(e){e.memory=4096+(e.numFeatures??0)*this.processor.graphicsCore.usedMemoryPerGraphic}_cacheNodeData(e){this._memCache.put(this._getMemCacheKey(e.node),e)}_getMemCacheKey(e){return`${e.index}`}_removeAllNodeData(){this.loadedGraphics.forEachNode((e,t)=>{if(e){const t=e.node;this._updateNodeMemory(t),this._cacheNodeData(e)}this._controller.updateLoadStatus(t,!1)}),this._treeDebugger&&this._treeDebugger.update(),this.loadedGraphics.clear()}removeNode(e){const t=this._removeNodeStageData(e);t&&(this._updateNodeMemory(t.node),this._cacheNodeData(t))}_removeNodeStageData(e){const t=this.loadedGraphics.getNode(e);return null==t?null:(this._controller.updateLoadStatus(e,!1),this.loadedGraphics.removeNode(e),this._treeDebugger&&this._treeDebugger.update(),t)}async loadCachedNodeData(e){return this._memCache?.pop(this._getMemCacheKey(e))}async addCachedNodeData(e,r,i,s){this.loadedGraphics.hasNode(e.index)?t.getLogger(this).error("I3S node "+e.id+" already added"):(await this._i3sOverrides.applyAttributeOverrides(r.featureIds,i,s),r.attributeInfo=i,this.loadedGraphics.addNode(e.index,r),this._controller.updateLoadStatus(e.index,!0),this._updateNodeMemory(e),fe(r),this._filterNode(r),this._treeDebugger&&this._treeDebugger.update())}getLoadedNodeIds(){const e=[];return this.loadedGraphics.forEachNode(t=>e.push(t.node.id)),e.sort()}getVisibleNodes(){const e=new Array;return this.loadedGraphics.forEachNode(t=>e.push(t.node)),e}getLoadedNodeIndices(e){this.loadedGraphics.forEachNode((t,r)=>e.push(r))}getLoadedAttributes(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.loadedAttributes}getAttributeData(e){const t=this.loadedGraphics.getNode(e);if(null!=t?.attributeInfo)return t.attributeInfo.attributeData}_setAttributeData(e,t){const r=this.loadedGraphics.getNode(e);null!=r?.attributeInfo&&(r.attributeInfo.attributeData=t,this._attributeValuesChanged(r))}async updateAttributes(e,t,r){const i=this.loadedGraphics.getNode(e);null!=i&&(await this._i3sOverrides.applyAttributeOverrides(i.featureIds,t,r),i.attributeInfo=t,this._attributeValuesChanged(i))}_attributeValuesChanged(e){fe(e),this._filterNode(e);const{processor:t}=this,{graphicsCore:r}=t;if(r.labelsEnabled){const t=e.node.index,i=new Array;e.graphics.forEach(e=>e.nodeIndex===t&&i.push(e.uid)),r.updateLabelingInfo(i)}t.refreshFilter()}_updateClippingExtent(e){return this._controller&&this._controller.updateClippingArea(e),!1}_getObjectIdField(){return this.layer.objectIdField||v}_getGlobalIdField(){return this.layer.globalIdField}async _rendererChange(e,t){const{layer:{fieldsIndex:r}}=this,i=new Set;let s,o;e?(await e.collectRequiredFields(i,r),s=Array.from(i).sort()):s=[],i.clear(),t?(await t.collectRequiredFields(i,r),o=Array.from(i).sort()):o=[],s.length===o.length&&s.every((e,t)=>s[t]===o[t])||this._reloadAllNodes()}_rangeInfosChanged(e){null!=e&&e.length>0&&t.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}_filterChange(){this.loadedGraphics.forEachNode(e=>this._filterNode(e))}_reloadAllNodes(){this._removeAllNodeData(),this._controller&&this._controller.restartNodeLoading()}_filterNode(e){const t=this.parsedDefinitionExpression,r=this._excludeObjectIds,i=this._getObjectIdField();for(const s of e.graphics){const e=s.visible,o=this._evaluateClause(t,s),a=!r.has(s.attributes[i]);s.visible=o&&a,e!==s.visible&&(Ie.graphic=s,Ie.property="visible",Ie.oldValue=e,Ie.newValue=s.visible,this.processor.graphicsCore.graphicUpdateHandler(Ie),xe())}}createQuery(){const e={outFields:["*"],returnGeometry:!0,outSpatialReference:this.view.spatialReference};return this.filter?.createQuery(e)??new O(e)}queryFeatures(e,t){return this._queryEngine.executeQuery(this._ensureQuery(e),t?.signal)}queryObjectIds(e,t){return this._queryEngine.executeQueryForIds(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._queryEngine.executeQueryForCount(this._ensureQuery(e),t?.signal)}queryExtent(e,t){return this._queryEngine.executeQueryForExtent(this._ensureQuery(e),t?.signal)}_ensureQuery(e){return this._addDefinitionExpressionToQuery(null==e?this.createQuery():O.from(e))}_setupQueryEngine(){const{layer:e,view:t,hasM:r,hasZ:i}=this,{spatialReference:s,resourceController:o}=t,a=new A(s,e,o,()=>this.processor.featureStore,i,r);this._queryEngine=new G({context:a,priority:de.FEATURE_QUERY_ENGINE})}get usedMemory(){return this.processor?.graphicsCore?.usedMemory??0}get unloadedMemory(){return.8*((this._controller?.unloadedMemoryEstimate??0)+(this.processor?.graphicsCore?.unprocessedMemoryEstimate??0))}get ignoresMemoryFactor(){return this._controller&&this._controller.fixedFeatureTarget}async _handleEdits(e){const t=this._attributeEditingContext,r=await P(t,e);L(t,r)}get _attributeEditingContext(){const e=this._getObjectIdField(),t=this._getGlobalIdField();return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:e,globalIdField:t,forEachNode:e=>this.loadedGraphics.forEachNode(t=>e(t.node,t.featureIds)),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this._i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(t,r,i)=>{this._setAttributeData(t,r);const s=this.loadedGraphics.getNode(t);if(null!=i){const t=this.loadedGraphics.get(i.attributes[e]);null!=t&&this.processor.graphicsCore.recreateGraphics([t])}else null!=s&&this.processor.graphicsCore.recreateGraphics(s.graphics)},clearMemCache:()=>{}}}get performanceInfo(){return new $(this.usedMemory,this.loadedGraphics.length,-1,this.maximumNumberOfFeatures,this.loadedGraphics.nodeCount,this.processor.graphicsCore.performanceInfo)}get test(){}};e([l()],pe.prototype,"processor",void 0),e([l({type:j})],pe.prototype,"filter",void 0),e([l()],pe.prototype,"loadedGraphics",void 0),e([l()],pe.prototype,"i3slayer",null),e([l()],pe.prototype,"layerViewUid",null),e([l()],pe.prototype,"_controller",void 0),e([l()],pe.prototype,"updating",void 0),e([l()],pe.prototype,"suspended",void 0),e([l(re)],pe.prototype,"updatingProgress",void 0),e([l()],pe.prototype,"updatingProgressValue",null),e([l({readOnly:!0})],pe.prototype,"visibleAtCurrentScale",null),e([l(ue.requiredFields)],pe.prototype,"requiredFields",null),e([l(ue.availableFields)],pe.prototype,"availableFields",void 0),e([l()],pe.prototype,"_fieldsHelper",void 0),e([l({type:Number})],pe.prototype,"maximumNumberOfFeatures",null),e([l({readOnly:!0})],pe.prototype,"maximumNumberOfFeaturesExceeded",null),e([l()],pe.prototype,"_excludeObjectIds",null),e([l({readOnly:!0})],pe.prototype,"lodFactor",null),e([l({readOnly:!0})],pe.prototype,"hasM",null),e([l({readOnly:!0})],pe.prototype,"hasZ",null),e([l()],pe.prototype,"contentVisible",null),e([l({readOnly:!0})],pe.prototype,"legendEnabled",null),e([l()],pe.prototype,"_graphicOrigin",null),pe=e([d("esri.views.3d.layers.SceneLayerGraphicsView3D")],pe);const ce=pe;function ge(e){return"pointData"in e}function me(e){return"geometryBuffer"in e&&null!==e.geometryBuffer}function ye(e,t,r){const i=t.attributeInfo;if(null==i?.loadedAttributes||null==i.attributeData)return!1;let s=!1;for(const{name:o}of i.loadedAttributes)if(i.attributeData[o]){const t=R(i.attributeData[o],r);t!==e.attributes[o]&&(e.attributes[o]=t,s=!0)}return s}function fe(e){const t=e.attributeInfo;if(null==t?.loadedAttributes||null==t.attributeData)return;const r=e.node.index;for(let i=0;i<e.graphics.length;i++){const s=e.graphics[i];if(s.nodeIndex===r){s.attributes||(s.attributes={});for(const{name:e}of t.loadedAttributes)t.attributeData[e]&&(s.attributes[e]=R(t.attributeData[e],i))}}}function _e(e,t){return e.xmin-=t,e.ymin-=t,e.xmax+=t,e.ymax+=t,null!=e.zmin&&null!=e.zmax&&(e.zmin-=t,e.zmax+=t),null!=e.mmin&&null!=e.mmax&&(e.mmin-=t,e.mmax+=t),e}const be={2:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0]}}},3:{type:"Embedded",params:{type:"points",vertexAttributes:{position:[0,0,0]}}}},ve=h(),Ie={graphic:null,property:null,oldValue:null,newValue:null};function xe(){Ie.graphic=null,Ie.property=null,Ie.oldValue=null,Ie.newValue=null}export{ce as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import l from"../../../core/ReactiveSet.js";import{initial as n}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import d from"../../../core/sql/WhereClause.js";import u from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as p}from"../../../layers/support/floorFilterUtils.js";import h from"../../../rest/support/Query.js";import{isNumber as c}from"../../../support/guards.js";import{I3SMeshView3D as y}from"./I3SMeshView3D.js";import{LayerView3D as g}from"./LayerView3D.js";import{createInteractiveEditSession as f,normalizeEditResultsEvent as m,processGeometryEdits as _,processAttributeEdits as F}from"./i3s/featureEditing.js";import{createGetFeatureExtent as v}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as w}from"./i3s/I3SMeshViewFilter.js";import{I3SOverrides as b}from"./i3s/I3SOverrides.js";import{I3SQueryEngine as j}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as I,I3SQueryFeature as S}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as E}from"./i3s/I3SQueryFeatureStore.js";import{checkRecyclable as O,getIndexCrs as H,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as V}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as R}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as q}from"./support/TemporalSceneLayerView.js";import{updatingProgress as L}from"../support/updatingProperties.js";import A from"../../layers/SceneLayerView.js";import{hasPopupTemplate as D}from"../../layers/support/popupUtils.js";import{isInEffectiveScaleRange as G}from"../../support/layerViewUtils.js";import{TaskPriority as U}from"../../support/Scheduler.js";const P=Q();let M=class extends(y(q(C(V(g(A)))))){constructor(){super(...arguments),this.type="scene-layer-3d",this.viewFilter=null,this._setVisibilityHiddenObjectIds=new l,this.progressiveLoadFactor=1,this._elevationContext=2,this._supportsLabeling=!0,this._pendingEditsQueue=Promise.resolve(),this._interactiveEditingSessions=new Map,this._queryEngine=null}get i3slayer(){return this.layer}tryRecycleWith(e,t){return e.url===this.layer.url&&this.i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),O(this.layer,e,this.i3sOverrides),this.layer=e,this.i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this.i3sOverrides=new b({view:this.view,layer:e,memoryController:i}),this.resetHighlights()}):null}get layerPopupEnabledAndHasTemplate(){return this.layer.popupEnabled&&D(this.layer,this.view.popup?.defaultPopupTemplateEnabled)}get filter(){return this._get("filter")}set filter(e){this._set("filter",w.checkSupport(e)?e:null)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=p(this);return null!=e?d.create(e,{fieldsIndex:this.layer.fieldsIndex}):null}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds.toArray();return e.length?e.sort((e,t)=>e-t):null}get _setVisibilityHiddenObjectIdsSorted(){return this._setVisibilityHiddenObjectIds.size?Array.from(this._setVisibilityHiddenObjectIds).sort((e,t)=>e-t):null}get lodFactor(){return this.view?.qualitySettings?.sceneService?.object?.lodFactor??1}get lodCrossfadeUncoveredDuration(){return this.view?.qualitySettings?.fadeDuration??0}get updatingProgressValue(){return this._controller?.updatingProgress??0}get visibleAtCurrentScale(){return G(this.i3slayer.effectiveScaleRange,this.view.scale)}get _graphicOrigin(){return this.layer.graphicOrigin}initialize(){this._fieldsHelper=new R({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),n),this._updatingHandles.add(()=>this.layer.renderer,e=>this._updatingHandles.addPromise(this._rendererChange(e)),n);const e=()=>this._filterChange();this._updatingHandles.add(()=>this.parsedDefinitionExpression,e),this._updatingHandles.add(()=>this.mergedFilter,e),this._updatingHandles.add(()=>this._floorFilterClause,e),this._updatingHandles.add(()=>this._excludeObjectIdsSorted,e),this._updatingHandles.add(()=>this._setVisibilityHiddenObjectIdsSorted,e),this._updatingHandles.add(()=>this.viewFilter?.sortedObjectIds,e),this._updatingHandles.add(()=>this.viewFilter?.parsedWhereClause,e),this._updatingHandles.add(()=>this.getTimeFilterDependencies(),e),this._updatingHandles.add(()=>[this.viewFilter?.parsedGeometry,this.mergedFilter?.spatialRelationship,this.layer.filter?.spatialRelationship],()=>this._geometryFilterChange()),this._updatingHandles.add(()=>({layerViewFilter:this.mergedFilter,layerFilter:this.layerFilter}),({layerViewFilter:e,layerFilter:t})=>{if(null==e&&null==t)return void this._set("viewFilter",null);const i=this.viewFilter;if(i)return i.viewFilter=e,i.layerFilter=t,void this._filterChange();this._set("viewFilter",new w({layerFilter:t,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError),addTimeFilter:(e,t)=>this.addTimeFilter(e,t)}))},n),this.i3sOverrides.is3DOFL&&this._updatingHandles.add(()=>this.i3sOverrides.sortedGeometryChangedObjectIds,e),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles(this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}))}destroy(){this._fieldsHelper=r(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&i.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!0,returnZ:!0,outSpatialReference:this.view.spatialReference};return this.mergedFilter?.createQuery(e)??new h(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then(e=>{if(!e?.features)return e;const t=this.layer,i=this._graphicOrigin;for(const r of e.features)r.layer=t,r.sourceLayer=t,r.origin=i;return e})}async queryObjectIds(e,t){return(await this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)).filter(c)}_ensureQueryEngine(){return this._queryEngine??=this._createQueryEngine(),this._queryEngine}_createQueryEngine(){const e=v(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new j({layerView:this,priority:U.FEATURE_QUERY_ENGINE,spatialIndex:new E({featureAdapter:new I({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo??[],getFeatureExtent:e}),forAllFeatures:(e,t)=>this._forAllFeatures((t,i,r)=>e(new S(t,i,r)),t,2),getFeatureExtent:e,sourceSpatialReference:H(this.layer),viewSpatialReference:this.view.spatialReference})})}createInteractiveEditSession(e){return f(this._attributeEditingContext,e)}_createLayerGraphic(e){return new t({attributes:e,layer:this.layer,sourceLayer:this.layer,origin:this._graphicOrigin})}getFilters(){const e=super.getFilters();this.i3sOverrides.is3DOFL&&this.i3sOverrides.sortedGeometryChangedObjectIds.length>0&&e.push((e,t)=>{t.node.index>=0&&x(this.i3sOverrides.sortedGeometryChangedObjectIds,!1,e)});const t=this._setVisibilityHiddenObjectIdsSorted;null!=t&&e.push(e=>x(t,!1,e));const i=this._excludeObjectIdsSorted;return null!=i&&e.push(e=>x(i,!1,e)),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),null!=this.viewFilter&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}setVisibility(e,t){t?this._setVisibilityHiddenObjectIds.delete(e):this._setVisibilityHiddenObjectIds.add(e)}isUpdating(){return super.isUpdating()||!!this._fieldsHelper?.updating||this.layerFilterUpdating||null!=this.viewFilter&&this.viewFilter.updating||null!=this.i3sOverrides&&this.i3sOverrides.updating}_ensureQuery(e){return this._validateQuery(this._addDefinitionExpressionToQuery(null==e?this.createQuery():h.from(e)))}_validateQuery(e){return e.outSpatialReference&&!e.outSpatialReference.equals(this.view.spatialReference)&&(i.getLogger(this).warn("query: outSpatialReference different from the view's spatial reference is not supported"),e.outSpatialReference=this.view.spatialReference),e.returnGeometry&&(e.returnZ=!0),e.returnCentroid=!1,e}get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),globalIdField:this._getGlobalIdField(),forEachNode:e=>this._forAllNodes(t=>null!=t?e(t.node,t.featureIds):null),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this.i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}async _handleEdits(e){const t=this._attributeEditingContext,i=await m(t,e);_(t,i),F(t,i)}get hasGeometryFilter(){return null!=this.viewFilter?.parsedGeometry}computeNodeFiltering(e){const t=this.viewFilter;return null==t||!this.view.spatialReference||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?0:1}};e([o()],M.prototype,"i3slayer",null),e([o(L)],M.prototype,"updatingProgress",void 0),e([o({type:u})],M.prototype,"filter",null),e([o({readOnly:!0})],M.prototype,"viewFilter",void 0),e([o(P.requiredFields)],M.prototype,"requiredFields",null),e([o(P.availableFields)],M.prototype,"availableFields",void 0),e([o()],M.prototype,"_fieldsHelper",void 0),e([o()],M.prototype,"_floorFilterClause",null),e([o()],M.prototype,"_excludeObjectIdsSorted",null),e([o()],M.prototype,"_setVisibilityHiddenObjectIds",void 0),e([o()],M.prototype,"_setVisibilityHiddenObjectIdsSorted",null),e([o()],M.prototype,"lodFactor",null),e([o()],M.prototype,"updatingProgressValue",null),e([o({readOnly:!0})],M.prototype,"visibleAtCurrentScale",null),e([o()],M.prototype,"_graphicOrigin",null),M=e([a("esri.views.3d.layers.SceneLayerView3D")],M);const T=M;export{T as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Graphic.js";import i from"../../../core/Logger.js";import{destroyMaybe as r}from"../../../core/maybe.js";import{throwIfAborted as s}from"../../../core/promiseUtils.js";import l from"../../../core/ReactiveSet.js";import{initial as n}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import d from"../../../core/sql/WhereClause.js";import u from"../../../layers/support/FeatureFilter.js";import{getFloorFilterClause as p}from"../../../layers/support/floorFilterUtils.js";import h from"../../../rest/support/Query.js";import{isNumber as c}from"../../../support/guards.js";import{I3SMeshView3D as y}from"./I3SMeshView3D.js";import{LayerView3D as g}from"./LayerView3D.js";import{createInteractiveEditSession as f,normalizeEditResultsEvent as m,processGeometryEdits as _,processAttributeEdits as F}from"./i3s/featureEditing.js";import{createGetFeatureExtent as v}from"./i3s/I3SGeometryUtil.js";import{I3SMeshViewFilter as w}from"./i3s/I3SMeshViewFilter.js";import{I3SOverrides as b}from"./i3s/I3SOverrides.js";import{I3SQueryEngine as j}from"./i3s/I3SQueryEngine.js";import{I3SQueryFeatureAdapter as I,I3SQueryFeature as S}from"./i3s/I3SQueryFeatureAdapter.js";import{I3SQueryFeatureStore as E}from"./i3s/I3SQueryFeatureStore.js";import{checkRecyclable as O,getIndexCrs as H,objectIdFilter as x}from"./i3s/I3SUtil.js";import{DefinitionExpressionSceneLayerView as C}from"./support/DefinitionExpressionSceneLayerView.js";import{defineFieldProperties as Q}from"./support/fieldProperties.js";import{PopupSceneLayerView as V}from"./support/PopupSceneLayerView.js";import{SceneLayerViewRequiredFields as R}from"./support/SceneLayerViewRequiredFields.js";import{TemporalSceneLayerView as q}from"./support/TemporalSceneLayerView.js";import{updatingProgress as L}from"../support/updatingProperties.js";import A from"../../layers/SceneLayerView.js";import{hasPopupTemplate as D}from"../../layers/support/popupUtils.js";import{isInEffectiveScaleRange as G}from"../../support/layerViewUtils.js";import{TaskPriority as U}from"../../support/Scheduler.js";const P=Q();let M=class extends(y(q(C(V(g(A)))))){constructor(){super(...arguments),this.type="scene-layer-3d",this.viewFilter=null,this._setVisibilityHiddenObjectIds=new l,this.progressiveLoadFactor=1,this._elevationContext=2,this._supportsLabeling=!0,this._pendingEditsQueue=Promise.resolve(),this._interactiveEditingSessions=new Map,this._queryEngine=null}get i3slayer(){return this.layer}tryRecycleWith(e,t){return e.url===this.layer.url&&this.i3sOverrides.isEmpty?e.load(t).then(()=>{s(t),O(this.layer,e,this.i3sOverrides),this.layer=e,this.i3sOverrides.destroy();const i=this.view.resourceController?.memoryController;this.i3sOverrides=new b({view:this.view,layer:e,memoryController:i}),this.resetHighlights()}):null}get layerPopupEnabledAndHasTemplate(){return this.layer.popupEnabled&&D(this.layer,this.view.popup?.defaultPopupTemplateEnabled)}get filter(){return this._get("filter")}set filter(e){this._set("filter",w.checkSupport(e)?e:null)}get requiredFields(){return this._fieldsHelper?.requiredFields??[]}get _floorFilterClause(){const e=p(this);return null!=e?d.create(e,{fieldsIndex:this.layer.fieldsIndex}):null}get _excludeObjectIdsSorted(){const e=this.layer.excludeObjectIds.toArray();return e.length?e.sort((e,t)=>e-t):null}get _setVisibilityHiddenObjectIdsSorted(){return this._setVisibilityHiddenObjectIds.size?Array.from(this._setVisibilityHiddenObjectIds).sort((e,t)=>e-t):null}get lodFactor(){return this.view?.qualitySettings?.sceneService?.objectLoDFactor??1}get lodCrossfadeUncoveredDuration(){return this.view?.qualitySettings?.fadeDuration??0}get updatingProgressValue(){return this._controller?.updatingProgress??0}get visibleAtCurrentScale(){return G(this.i3slayer.effectiveScaleRange,this.view.scale)}get _graphicOrigin(){return this.layer.graphicOrigin}initialize(){this._fieldsHelper=new R({layerView:this}),this._updatingHandles.add(()=>this.layer.rangeInfos,e=>this._rangeInfosChanged(e),n),this._updatingHandles.add(()=>this.layer.renderer,e=>this._updatingHandles.addPromise(this._rendererChange(e)),n);const e=()=>this._filterChange();this._updatingHandles.add(()=>this.parsedDefinitionExpression,e),this._updatingHandles.add(()=>this.mergedFilter,e),this._updatingHandles.add(()=>this._floorFilterClause,e),this._updatingHandles.add(()=>this._excludeObjectIdsSorted,e),this._updatingHandles.add(()=>this._setVisibilityHiddenObjectIdsSorted,e),this._updatingHandles.add(()=>this.viewFilter?.sortedObjectIds,e),this._updatingHandles.add(()=>this.viewFilter?.parsedWhereClause,e),this._updatingHandles.add(()=>this.getTimeFilterDependencies(),e),this._updatingHandles.add(()=>[this.viewFilter?.parsedGeometry,this.mergedFilter?.spatialRelationship,this.layer.filter?.spatialRelationship],()=>this._geometryFilterChange()),this._updatingHandles.add(()=>({layerViewFilter:this.mergedFilter,layerFilter:this.layerFilter}),({layerViewFilter:e,layerFilter:t})=>{if(null==e&&null==t)return void this._set("viewFilter",null);const i=this.viewFilter;if(i)return i.viewFilter=e,i.layerFilter=t,void this._filterChange();this._set("viewFilter",new w({layerFilter:t,viewFilter:e,layerFieldsIndex:this.layer.fieldsIndex,loadAsyncModule:e=>this._loadAsyncModule(e),addSqlFilter:(e,t)=>this.addSqlFilter(e,t,this.logError),addTimeFilter:(e,t)=>this.addTimeFilter(e,t)}))},n),this.i3sOverrides.is3DOFL&&this._updatingHandles.add(()=>this.i3sOverrides.sortedGeometryChangedObjectIds,e),this.addHandles(this.layer.on("apply-edits",e=>this._updatingHandles.addPromise(e.result))),this.addHandles(this.layer.on("edits",e=>{const t=this._pendingEditsQueue.then(()=>this._handleEdits(e)).then();this._pendingEditsQueue=t,this._updatingHandles.addPromise(t)}))}destroy(){this._fieldsHelper=r(this._fieldsHelper)}_rangeInfosChanged(e){null!=e&&e.length>0&&i.getLogger(this).warn("Unsupported property: rangeInfos are currently only serialized to and from web scenes but do not affect rendering.")}createQuery(){const e={outFields:["*"],returnGeometry:!0,returnZ:!0,outSpatialReference:this.view.spatialReference};return this.mergedFilter?.createQuery(e)??new h(e)}queryExtent(e,t){return this._ensureQueryEngine().executeQueryForExtent(this._ensureQuery(e),t?.signal)}queryFeatureCount(e,t){return this._ensureQueryEngine().executeQueryForCount(this._ensureQuery(e),t?.signal)}queryFeatures(e,t){return this._ensureQueryEngine().executeQuery(this._ensureQuery(e),t?.signal).then(e=>{if(!e?.features)return e;const t=this.layer,i=this._graphicOrigin;for(const r of e.features)r.layer=t,r.sourceLayer=t,r.origin=i;return e})}async queryObjectIds(e,t){return(await this._ensureQueryEngine().executeQueryForIds(this._ensureQuery(e),t?.signal)).filter(c)}_ensureQueryEngine(){return this._queryEngine??=this._createQueryEngine(),this._queryEngine}_createQueryEngine(){const e=v(this.view.spatialReference,this.view.renderSpatialReference,this._collection);return new j({layerView:this,priority:U.FEATURE_QUERY_ENGINE,spatialIndex:new E({featureAdapter:new I({objectIdField:this.layer.objectIdField,attributeStorageInfo:this.layer.attributeStorageInfo??[],getFeatureExtent:e}),forAllFeatures:(e,t)=>this._forAllFeatures((t,i,r)=>e(new S(t,i,r)),t,2),getFeatureExtent:e,sourceSpatialReference:H(this.layer),viewSpatialReference:this.view.spatialReference})})}createInteractiveEditSession(e){return f(this._attributeEditingContext,e)}_createLayerGraphic(e){return new t({attributes:e,layer:this.layer,sourceLayer:this.layer,origin:this._graphicOrigin})}getFilters(){const e=super.getFilters();this.i3sOverrides.is3DOFL&&this.i3sOverrides.sortedGeometryChangedObjectIds.length>0&&e.push((e,t)=>{t.node.index>=0&&x(this.i3sOverrides.sortedGeometryChangedObjectIds,!1,e)});const t=this._setVisibilityHiddenObjectIdsSorted;null!=t&&e.push(e=>x(t,!1,e));const i=this._excludeObjectIdsSorted;return null!=i&&e.push(e=>x(i,!1,e)),this._floorFilterClause&&this.addSqlFilter(e,this._floorFilterClause,this.logError),this.addSqlFilter(e,this.parsedDefinitionExpression,this.logError),null!=this.viewFilter&&this.viewFilter.addFilters(e,this.view,this._controller.crsIndex,this._collection),e}setVisibility(e,t){t?this._setVisibilityHiddenObjectIds.delete(e):this._setVisibilityHiddenObjectIds.add(e)}isUpdating(){return super.isUpdating()||!!this._fieldsHelper?.updating||this.layerFilterUpdating||null!=this.viewFilter&&this.viewFilter.updating||null!=this.i3sOverrides&&this.i3sOverrides.updating}_ensureQuery(e){return this._validateQuery(this._addDefinitionExpressionToQuery(null==e?this.createQuery():h.from(e)))}_validateQuery(e){return e.outSpatialReference&&!e.outSpatialReference.equals(this.view.spatialReference)&&(i.getLogger(this).warn("query: outSpatialReference different from the view's spatial reference is not supported"),e.outSpatialReference=this.view.spatialReference),e.returnGeometry&&(e.returnZ=!0),e.returnCentroid=!1,e}get _attributeEditingContext(){return{sessions:this._interactiveEditingSessions,fieldsIndex:this.layer.fieldsIndex,objectIdField:this._getObjectIdField(),globalIdField:this._getGlobalIdField(),forEachNode:e=>this._forAllNodes(t=>null!=t?e(t.node,t.featureIds):null),attributeStorageInfo:this.i3slayer.attributeStorageInfo??[],i3sOverrides:this.i3sOverrides,getAttributeData:e=>this.getAttributeData(e),setAttributeData:(e,t)=>this.setAttributeData(e,t),clearMemCache:()=>this.clearMemCache()}}async _handleEdits(e){const t=this._attributeEditingContext,i=await m(t,e);_(t,i),F(t,i)}get hasGeometryFilter(){return null!=this.viewFilter?.parsedGeometry}computeNodeFiltering(e){const t=this.viewFilter;return null==t||!this.view.spatialReference||t.isMBSGeometryVisible(e,this.view.spatialReference,this._controller.crsIndex)?0:1}};e([o()],M.prototype,"i3slayer",null),e([o(L)],M.prototype,"updatingProgress",void 0),e([o({type:u})],M.prototype,"filter",null),e([o({readOnly:!0})],M.prototype,"viewFilter",void 0),e([o(P.requiredFields)],M.prototype,"requiredFields",null),e([o(P.availableFields)],M.prototype,"availableFields",void 0),e([o()],M.prototype,"_fieldsHelper",void 0),e([o()],M.prototype,"_floorFilterClause",null),e([o()],M.prototype,"_excludeObjectIdsSorted",null),e([o()],M.prototype,"_setVisibilityHiddenObjectIds",void 0),e([o()],M.prototype,"_setVisibilityHiddenObjectIdsSorted",null),e([o()],M.prototype,"lodFactor",null),e([o()],M.prototype,"updatingProgressValue",null),e([o({readOnly:!0})],M.prototype,"visibleAtCurrentScale",null),e([o()],M.prototype,"_graphicOrigin",null),M=e([a("esri.views.3d.layers.SceneLayerView3D")],M);const T=M;export{T as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as p,create as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w,forEachSymbolLayer as z}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as R}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as M}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as I}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as O}from"../../../../symbols/support/utils.js";import{transparentUnit as j}from"./constants.js";import{perObjectElevationAligner as F}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as U}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as D}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as L}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as A}from"./placementUtils.js";import{placePointOnGeometry as H,updateStageObjectGeometry as k,getLocalOriginForPoint as B,extendPointGraphicElevationContext as $,createStageObject as N}from"./pointUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as J,evaluateModelTransformScale as Z,ConvertOptions as W}from"../support/FastSymbolUpdates.js";import{createTexture as K,requiresHalfTexelOffset as Q,defaultBoundingBox as X,defaultSymbolSizeRatio as Y,defaultTexSize as ee}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as te}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as ie}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as se}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as oe}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as ae}from"../../webgl-engine/materials/HUDMaterial.js";const ne=_(0,0,1),le=16,ce=1.5,he=[ee*Y,ee*Y];class ue extends G{static{this.PRIMITIVE_SIZE=he}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ge(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=O(this.symbolLayer),i=de(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=L(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):le);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&R(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new I({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=_e("relative",s),a=new oe(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new oe(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:_e(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;me(t)&&(e.verticalOffset=new re(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this.view.screenSizePerspective.parameters),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!!has("enable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(pe(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>K(t));this._textureHandle=r,e.textureId=r.texture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=Q(t),e.distanceFieldBoundingBox=X;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/Y,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.texture;this._size=fe(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return ye(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=pe(this._getPrimitive())?ce:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(pe(this._getPrimitive()))return j;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):le)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new ae(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new ae(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=U(e.color,r),e.outlineColor=U(e.outlineColor,r),this._materials[1]=new ae(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=H(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;let a=!1;if(this._cimData){if(!this._cimData.symbol)return null;z(this._cimData.symbol,e=>{e.colorLocked&&(a=!0)});const r=this._generateTextureCIM(t,e),n={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(n);const l=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/l,r.parameters.height/l]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const n=e.renderingInfo,l=a?x(255,255,255,255):this._getDrivenUInt8Color(n,this._materialColor,null==this._getPrimitive()),c=this._getDrivenRotation(n);let h=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];h=this._getScaleFactor(n,e)}h*=this._symbolTextureRatio;const u=p(s[0]*h,s[1]*h),m=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,l,c,u):this._createAs3DShape(t,r,i,l,c,u,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const o=H(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const a=k(s,this._context,o,i);if(null==a)return!1;const n=B(this._context,o);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=a,$(t,o,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=T(ue.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!J(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=de(h))return;const m=this._getIconSize(),p=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,p,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.texture;this._size=fe(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return xe}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=ie(r,{normal:ne,color:i,rotation:s,size:o,centerOffsetAndDistance:be,featureAttribute:l,olidColor:h}),m=N(this._context,t,u,a,n);if(null==m)return null;const p=new V(this,m.object,null,F,a);return p.alignedSampledElevation=m.sampledElevation,p.needsElevationUpdates=E(a.mode)||"absolute-height"===a.mode,p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),$(p,t,this._context.elevationProvider),p}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=te;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=ie(r,{normal:ne,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),p=new se(m,{layerViewUid:h,graphicUid:c}),d=new D(this,[p],null,this._context.drapeSourceRenderer);return d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),d}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=d())=>{const[o,a]=Z(ve,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=d())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new W({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function pe(e){return null!=e&&("cross"===e||"x"===e)}function de(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function _e(e,t){return"relative"===e?p((t.x||0)+.5,.5-(t.y||0)):e in A?A[e]:A.center}function fe({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function ye(e){return e.resource?.href?null:e.resource?.primitive??M}function ge(e){return 1===(e.material?.color?.a??0)&&null!=ye(e)}const xe={mode:"relative-to-ground",offset:0},be=x(0,0,0,1),ve=f();export{ue as Graphics3DIconSymbolLayer};
5
+ import e from"../../../../Color.js";import{result as t,createTask as r}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import has from"../../../../core/has.js";import{clone as s}from"../../../../core/lang.js";import{abortMaybe as o,releaseMaybe as a}from"../../../../core/maybe.js";import{throwIfAbortError as n,throwIfAborted as l}from"../../../../core/promiseUtils.js";import{pt2px as c,px2pt as h}from"../../../../core/screenUtils.js";import{numericHash as u}from"../../../../core/string.js";import{dataComponents as m}from"../../../../core/urlUtils.js";import{fromValues as d,create as p}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as _,create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as y,ZEROS as g,fromValues as x}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{projectPointToVector as b}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as v}from"../../../../geometry/support/aaBoundingBox.js";import S from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as P}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as w,forEachSymbolLayer as z}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as R}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultPrimitive as M}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{Symbol3DAnchorPosition2D as I}from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as O}from"../../../../symbols/support/utils.js";import{transparentUnit as j}from"./constants.js";import{perObjectElevationAligner as T}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as F,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{focusAreaHUDColor as U}from"./focusAreaStyle.js";import{Graphics3DDrapedGraphicLayer as D}from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as V}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as G}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as L}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as A}from"./placementUtils.js";import{placePointOnGeometry as H,updateStageObjectGeometry as k,getLocalOriginForPoint as B,extendPointGraphicElevationContext as $,createStageObject as N}from"./pointUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as J,evaluateModelTransformScale as Z,ConvertOptions as W}from"../support/FastSymbolUpdates.js";import{createTexture as K,requiresHalfTexelOffset as Q,defaultBoundingBox as X,defaultSymbolSizeRatio as Y,defaultTexSize as ee}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as te}from"../../terrain/OverlayRenderer.js";import{VerticalOffsetParameters as re}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointGeometry as ie}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as se}from"../../webgl-engine/lib/ManagedTexture.js";import{RenderGeometry as oe}from"../../webgl-engine/lib/RenderGeometry.js";import{HUDMaterial as ae}from"../../webgl-engine/materials/HUDMaterial.js";const ne=_(0,0,1),le=16,ce=1.5,he=[ee*Y,ee*Y];class ue extends G{static{this.PRIMITIVE_SIZE=he}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,r,i){super(e,t,r,i,ge(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=O(this.symbolLayer),i=pe(r);null!=i?await this._prepareResourcesCIM(t,JSON.parse(i),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=L(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?c(e.size):le);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){const r=this._overrideHelperClass;let i=this._cimData;if(r&&i&&i.symbol||this.logger.error("Can't create texture, CIM data is undefined"),i.primitiveOverrides){i=s(i);const o=i.primitiveOverrides;r.evaluateOverrides(o,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),r.applyOverrides(i.symbol,o)}const o=u(JSON.stringify(i));let a=this._cimSymbolTextures.get(o);if(a)return a;const n=this._context.sharedResources.cimSymbolRasterizer,l=this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null;l&&r.applyDictionaryTextOverrides(i.symbol,e,l,null);const c=null!=this._cimScaleFactorOrFunction?C(this._cimScaleFactorOrFunction,e):1;1!==c&&i.symbol&&R(i.symbol,c,!0);const h=w.getEnvelope(i,null,n.resourceManager);if(h?.width&&h.height){const e=h.x+h.width/2,t=h.y+h.height/2,r=n.rasterize({type:"cim",data:i},h.width,h.height,e,t,1,"esriGeometryPoint",0,null,this._context.graphicsCoreOwner.view.state.rasterPixelRatio),s=new I({x:-h.x/h.width-.5,y:(h.height+h.y)/h.height-.5});this._cimMaterialParametersInfo.anchorPosition=_e("relative",s),a=new se(r,{width:r?.width??1,height:r?.height??1,reloadable:!0})}else a=new se(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(o,a),this._context.stage.addTexture(a),a}_prepareMaterialParameters(){const e={anchorPosition:_e(this.symbolLayer.anchor,this.symbolLayer.anchorPosition),rotation:this.symbolLayer.angle},t=this.symbol;me(t)&&(e.verticalOffset=new re(t.verticalOffset)),this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this.view.screenSizePerspective.parameters),(0!==e.rotation||this._drivenProperties.rotation)&&(e.hasRotation=!0);const r=!!has("enable-feature:non-occluded-hud");return e.occlusionTest=!r,e.occludedFragmentFade=r,e.horizonCullingEnabled=r&&this._context.spherical,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(de(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>K(t));this._textureHandle=r,e.textureId=r.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=Q(t),e.distanceFieldBoundingBox=X;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/Y,this._createMaterial(e)}async _prepareResourcesHref(e,r,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),a=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(r,a,{signal:s}));if(!1===l.ok){n(l.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${r})`)}this._textureHandle=l.value;const c=l.value.managedTexture;this._size=fe(c,o),e.textureId=c.id}this._createMaterial(e)}async _prepareResourcesCIM(e,t,r){const{OverrideHelper:i}=await import("../../../../symbols/cim/OverrideHelper.js");if(this._overrideHelperClass=i,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;l(r),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}const s=this._context.sharedResources.cimSymbolRasterizer,o=[],a=t,n=a?.symbol;w.fetchResources(n,s.resourceManager,o,r),w.fetchFonts(n,s.resourceManager,o);const c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],h=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:h,fields:c,geometryType:"esriGeometryPoint"},a?.primitiveOverrides&&o.push(i.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),o.length>0&&(await Promise.all(o),l(r)),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(e.scaleExpression){const t=e.scaleExpression,r=await P(t,this._context.layer.spatialReference),{default:i}=await import("../../../2d/arcade/callExpressionWithFeature.js"),s=new S(c);this._cimScaleFactorOrFunction=(e,t,o)=>{const a=i(r,e,{$view:o},"esriGeometryPoint",s,t);return null!==a?a:1}}}l(r),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return ye(this.symbolLayer)}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline?.size)return Math.max(c(t.outline.size),0);return e=de(this._getPrimitive())?ce:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(de(this._getPrimitive()))return j;const e=null==this._getPrimitive(),t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){const t=this._materialColor;if(null==t){return null==this._getPrimitive()?y:g}return e.toUnitRGBA(t)}_getFallbackSize(){const e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(null!=t?Math.round(c(t)):le)/e}_createMaterial(e){const t=this._context.spherical;if(this._cimData){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new ae(e,t),this._cimSymbolMaterials.set(e.textureId??0,r)),r}this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._materials[0]=new ae(e,t),e.isFocused=!1;const r=this.view.map?.focusAreas.style;return e.color=U(e.color,r),e.outlineColor=U(e.outlineColor,r),this._materials[1]=new ae(e,t),this._materials[0]}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=o(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=a(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(null==e)return this._getFallbackSize();const[r,i,s]=e;return"symbol-value"===r?1:"number"==typeof r&&isFinite(r)?c(r)/t:"number"==typeof s&&isFinite(s)?c(s)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading??0:0}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const r=H(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let i,s=[0,0];const o=this.view.focusAreasView?.containsGeometry(r)??!0;let a=!1;if(this._cimData){if(!this._cimData.symbol)return null;z(this._cimData.symbol,e=>{e.colorLocked&&(a=!0)});const r=this._generateTextureCIM(t,e),n={textureId:r.id,isFocused:o,...this._cimMaterialParametersInfo};i=this._createMaterial(n);const l=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;s=[r.parameters.width/l,r.parameters.height/l]}else s=this._size,i=o?this._materials[0]:this._materials[1];if(null==r)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const n=e.renderingInfo,l=a?x(255,255,255,255):this._getDrivenUInt8Color(n,this._materialColor,null==this._getPrimitive()),c=this._getDrivenRotation(n);let h=1;if(!this._fastUpdates?.visualVariables.size){const e=s[0]>s[1]?s[0]:s[1];h=this._getScaleFactor(n,e)}h*=this._symbolTextureRatio;const u=d(s[0]*h,s[1]*h),m=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,r,i,l,c,u):this._createAs3DShape(t,r,i,l,c,u,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){const e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateGeometry(e,t){const r=e.geometry;if(this.draped||!r||!this._validateGeometry(r))return!1;const{elevationContext:i,stageObject:s}=t;if(i.mode!==this.getGeometryElevationMode(r))return!1;const o=H(r);if(!o)return!1;i.updateFeatureExpressionFeature(e,this._context.layer);const a=k(s,this._context,o,i);if(null==a)return!1;const n=B(this._context,o);return s.geometries[0].localOrigin===n&&(t.alignedSampledElevation=a,$(t,o,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=F(ue.elevationModeChangeTypes,r,i);if(1!==s)return s;const o=E(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>o)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return 0;if(!J(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return 0;this._materials[0]?.setParameters(this._fastUpdates.materialParameters)}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),"partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(e,s){if(!s.resource||"partial"!==s.resource.type)return;const c=s.resource.diff;if("complete"!==c?.href?.type)return;const h=c.href.newValue,{textures:u}=this._context.sharedResources;if(null==h||null==u||null!=pe(h))return;const m=this._getIconSize(),d=m*this._context.graphicsCoreOwner.view.state.pixelRatio;e.symbolLayerStatePatches.push(()=>{this._patchTask=o(this._patchTask),this._patchTask=r(e=>this._context.schedule(async(e,r)=>{const s=await t(u.fromUrl(h,d,{signal:r}));l(r);const o=!s.ok;if(o&&n(s.error),this._textureHandle=a(this._textureHandle),this._patchTask=null,o){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});const e=`Failed to load (Request for icon resource failed: ${h})`;return void this.logger.error(new i("graphics3diconsymbollayer:request-failed",e))}this._textureHandle=s.value;const c=s.value.managedTexture;this._size=fe(c,m),this._forEachMaterial(e=>{e.setParameters({textureId:c.id}),e.visible=!0})},e))}),delete c.href}_preparePatchRotation(e,t){if(!t.angle||"complete"!==t.angle.type)return;const r=t.angle.newValue??0,i=0!==r||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:r,hasRotation:i}))}),delete t.angle}_defaultElevationInfoNoZ(){return xe}_createAs3DShape(e,t,r,i,s,o,a,n){const l=this.getFastUpdateAttrValues(e),c=this._context.layerViewUid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:c}),u=ie(r,{normal:ne,color:i,rotation:s,size:o,centerOffsetAndDistance:be,featureAttribute:l,olidColor:h}),m=N(this._context,t,u,a,n);if(null==m)return null;const d=new V(this,m.object,null,T,a);return d.alignedSampledElevation=m.sampledElevation,d.needsElevationUpdates=E(a.mode)||"absolute-height"===a.mode,d.getScreenSize=this._createScreenSizeGetter(o,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),$(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,o){r.renderPriority=this._renderPriority;const a=f();b(t,a,this._context.overlaySR),a[2]=te;const n=this._context.clippingExtent;if(null!=n&&!v(n,a))return null;const l=this.getFastUpdateAttrValues(e),c=e.uid,h=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:h}),m=ie(r,{normal:ne,position:a,color:i,rotation:s,size:o,featureAttribute:l,olidColor:u}),d=new oe(m,{layerViewUid:h,graphicUid:c}),p=new D(this,[d],null,this._context.drapeSourceRenderer);return p.getScreenSize=this._createScreenSizeGetter(o,l),p.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(p.getScreenSize(),1,e),p}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=p())=>{const[o,a]=Z(ve,this._fastUpdates.materialParameters,t);return e[0]=o*i+r,e[1]=a*s+r,e}}const i=e[0]/this._symbolTextureRatio+r,s=e[1]/this._symbolTextureRatio+r;return(e=p())=>(e[0]=i,e[1]=s,e)}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=_(e,e,e),r=h(1),i=e*r,s=_(i,i,i),o=this._getFallbackSize();return new W({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:s,unitInMeters:r,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:_(o,o,o)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._materials[0]}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function de(e){return null!=e&&("cross"===e||"x"===e)}function pe(e){const t=m(e);return"application/json"===t?.mediaType?t.data:void 0}function _e(e,t){return"relative"===e?d((t.x||0)+.5,.5-(t.y||0)):e in A?A[e]:A.center}function fe({parameters:e},t){const r=(e.width??1)/(e.height??1);return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}function ye(e){return e.resource?.href?null:e.resource?.primitive??M}function ge(e){return 1===(e.material?.color?.a??0)&&null!=ye(e)}const xe={mode:"relative-to-ground",offset:0},be=x(0,0,0,1),ve=f();export{ue as Graphics3DIconSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/5.0/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import"../../../../core/has.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as g,g as x,h as _,t as y,o as T,n as b,c as v,e as w,i as C,f as j}from"../../../../chunks/vec32.js";import{create as M,fromValues as A,ONES as R,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as O,create as F,intersectsClippingArea as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as Y}from"../../../../chunks/vec3.js";import{transformNormal as J,transformVectorENUPlateCarree as K,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ce}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ue}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as me,nanFallbackColor as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as de}from"./SymbolComplexity.js";import{hasEdges as ge,createMaterial as xe}from"../support/edgeUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as ye}from"../../webgl-engine/lib/Attribute.js";import{Geometry as Te}from"../../webgl-engine/lib/Geometry.js";import{Object3D as be}from"../../webgl-engine/lib/Object3D.js";import{Texture as ve}from"../../webgl-engine/lib/Texture.js";import{DefaultMaterial as we}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Me,schematicMRRFactors as Ae}from"../../webgl-engine/materials/pbrUtils.js";const Re=["mesh"];class Pe extends me{constructor(e,t,r,o){super(e,t,r,o,We(t)),this._materialInfoCache=new pe,this._fastUpdateProcessor=new he,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){_e.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Ce({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Ce({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Ce({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Re,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=tt,{origin:i,transform:l}=r;if(!B(t,g(Ke,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case 2:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=ge(this.symbolLayer)?2:0;return new de({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ke(n),p=ke(a),h=ze(s),d=ke(i),g=ze(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=ke(n),h=ze(a),d=ke(i),g=ke(c),x=ze(u),_=ke(m),y=ze(f);o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${y}`,o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=He(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Ge(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new ve(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(r,o){if(null!=r.colorTexture){const e=1!==o.textureAlphaMode,t=this._getInternalTexture(r.colorTexture,e,o.textureAlphaMode);t?(o.textureId=t.id,o.textureAlphaPremultiplied=!!t.parameters.preMultiplyAlpha):o.textureId=void 0}if(r.normalTexture&&(o.normalTextureId=this._getInternalTexture(r.normalTexture)?.id),r.emissiveColor){const n=e.toUnitRGB(r.emissiveColor);o.emissiveBaseColor=A(t(n[0]),t(n[1]),t(n[2]))}r.emissiveTexture&&(o.emissiveTextureId=this._getInternalTexture(r.emissiveTexture)?.id),r.occlusionTexture&&(o.occlusionTextureId=this._getInternalTexture(r.occlusionTexture,!0)?.id),r.metallicRoughnessTexture&&(o.metallicRoughnessTextureId=this._getInternalTexture(r.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ne(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this._materialColor){const o=this._drivenProperties.color,n=this._drivenProperties.opacity;if(o)t.externalColor=S;else{const o=r??null;if(o){const r=e.toUnitRGBA(o);n&&(r[3]=1),t.externalColor=r}else t.externalColor=fe}t.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrength=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(Le(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return this._setInternalMaterialTextureParameters(l,c.material.parameters),c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=je({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:P,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Ae:[l.metallic,l.roughness,Me[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?0:2,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new we(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),p}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)Ve(r,o,t,Ze),Fe(r,o,t,Ke,Qe,Xe),x(Ke,Ke,Qe),x(Ke,Ke,Xe),_(Ke,Ke,1/3),y(Ke,Ke,c),s.push(...Ke),T(Ze,Ze,u),b(Ze,Ze),v(Ke,Ke,Ze,n),s.push(...Ke),l.push(l.length),l.push(l.length)}return s.length?new Te(this._debugFaceNormalMaterial,[["position",new ye(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Ke,s[e+0],s[e+1],s[e+2]),y(Ke,Ke,p),m.push(...Ke),g(Qe,l[r+0],l[r+1],l[r+2]),T(Qe,Qe,h),b(Qe,Qe),v(Ke,Ke,Qe,u),m.push(...Ke),f.push(f.length),f.push(f.length)}}return m.length?new Te(o,[["position",new ye(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new be({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=xe(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new ue(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ce(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=M(),r=g(nt,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=J(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return K(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return K(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=qe(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,s,n),u(et,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,et);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&J(r,p,et),o&&h&&Z(o,h,et),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(O(o,rt),!V(rt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??ot,h=new Array;let d=!1;const g=m(Ke,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Ie(e,m);if(0===t.length)continue;const o=Be(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new ye(n,t,3,!0)],["normal",new ye(o.normals,o.indices,3,!0)]];s&&u.push(["color",new ye(s,t,4,!0)]),i&&u.push(["symbolColor",new ye(i,G(t.length),4,!0)]),a&&u.push(["uv0",new ye(a,t,2,!0)]),c&&u.push(["tangent",new ye(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new Te(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Se{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ie(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Be(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Ee(e,t,r,o);case"flat":return Ue(e,o);case"smooth":return Oe(e,o)}}function Ue(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Ve(e,t,n,Ze);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Se(r,o,!1)}function Ee(e,t,r,o){if(null==t)return Ue(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Ve(e,o,a,Ze);for(let e=0;e<3;e++){const r=3*o[a+e];Ke[0]=t[r],Ke[1]=t[r+1],Ke[2]=t[r+2],j(Ze,Ke)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Se(t,o,n)}function Oe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Ve(e,t,a,Ze);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Se(o,n,!1)}function Fe(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Ve(e,t,r,o){return Fe(e,t,r,Ke,Qe,Xe),w(Qe,Qe,Ke),w(Xe,Xe,Ke),C(Ke,Qe,Xe),b(o,Ke),o}function $e(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function Ge(e="repeat"){if("string"==typeof e){const t=De(e);return{s:t,t}}return{s:De(e.horizontal),t:De(e.vertical)}}function De(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Le(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function Ne(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function He(e){return e.data??e.url}function ke(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function ze(e){const{offset:t,scale:r,rotation:o}=e??Ye;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function qe(e){return e.vertexAttributes.color}function We(e){return 1===(e.material?.color?.a??0)}const Ye=new H,Je=M(),Ke=M(),Qe=M(),Xe=M(),Ze=M(),et=f(),tt=f(),rt=F(),ot=[new L],nt=M();export{Pe as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import"../../../../core/has.js";import{deg2rad as r}from"../../../../core/mathUtils.js";import{releaseMaybe as o}from"../../../../core/maybe.js";import{isPromiseLike as n}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as l,multiply as c,invert as u,getTranslation as m}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as f,IDENTITY as p,clone as h}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as d}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{j as g,g as x,h as _,t as y,o as T,n as b,c as v,e as w,i as C,f as j}from"../../../../chunks/vec32.js";import{create as M,fromValues as A,ONES as R,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as S}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as I}from"../../../../geometry/projectionUtils.js";import{computeTranslationToOriginAndRotation as B}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as U}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as E}from"../../../../geometry/projection/projectVectorToVector.js";import{fromBuffer as O,create as F,intersectsClippingArea as V}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as $}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as G,getContinuousIndexArray as D}from"../../../../geometry/support/Indices.js";import L from"../../../../geometry/support/MeshComponent.js";import N from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import H from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as k,isAbsoluteVertexSpace as z}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as W}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as Y}from"../../../../chunks/vec3.js";import{transformNormal as J,transformVectorENUPlateCarree as K,transformVectorWMPlateCarree as Q,projectNormalToPCPF as X,transformTangent as Z,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{getEmissiveMode as re}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as oe}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ne}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as ae}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as ie,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as ce}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as ue}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as me,nanFallbackColor as fe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as pe,MeshFastUpdateProcessor as he}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as de}from"./SymbolComplexity.js";import{hasEdges as ge,createMaterial as xe}from"../support/edgeUtils.js";import{debugFlags as _e}from"../../support/debugFlags.js";import{Attribute as ye}from"../../webgl-engine/lib/Attribute.js";import{Geometry as Te}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as be}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as ve}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as we}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ce}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as je,advancedMRRFactors as Me,schematicMRRFactors as Ae}from"../../webgl-engine/materials/pbrUtils.js";const Re=["mesh"];class Pe extends me{constructor(e,t,r,o){super(e,t,r,o,We(t)),this._materialInfoCache=new pe,this._fastUpdateProcessor=new he,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){_e.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Ce({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Ce({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Ce({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,Re,"fill on mesh-3d"))return null;const r=this.createElevationContextForGraphic(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(r,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ie)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters(({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),e?.forEach(e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateTransform(e,t,r,o){if(!e.fastTransformUpdatesAllowed)return!1;const n=e.fastTransformUpdatesEnabled;switch(o){case 0:if(n)return!0;break;case 1:if(!n)return!0;break;default:if(!n)return!!this.updateTransform(e,t,r,0)&&(e.autoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0)}const a=this._context.renderCoordsHelper.spatialReference,s=tt,{origin:i,transform:l}=r;if(!B(t,g(Ke,i.x,i.y,i.z??0),s,a))return!1;switch(o){case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case 2:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerInElevationSR=this._getCenterInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>le(e,u,c,m,t);return e.alignedSampledElevation=se(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates(()=>this.updateTransform(e,t,r,1)),!0}computeComplexity(){if(!this._textures||0===this._textures.size)return super.computeComplexity();let e=0;for(const o of this._textures.values())e+=o.usedMemory;const t={...ae(this.symbol,this.symbolLayer),resourceBytes:e},r=ge(this.symbolLayer)?2:0;return new de({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=ke(n),p=ke(a),h=ze(s),d=ke(i),g=ze(l);if(o.color=n,o.colorTexture=a,o.normalTexture=i,o.uid=`${o.uid},cmuid:${f},ctmuid:${p},cttuid:${h},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof N){const{metallic:e,roughness:r,metallicRoughnessTexture:n,metallicRoughnessTextureTransform:a,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=ke(n),h=ze(a),d=ke(i),g=ke(c),x=ze(u),_=ke(m),y=ze(f);o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${y}`,o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=$e(s),o.normalTextureTransform=$e(l),o.emissiveTextureTransform=$e(u),o.occlusionTextureTransform=$e(f),o.metallicRoughnessTextureTransform=$e(a)}return o}_getInternalTexture(e,t=!1,r=1){const a=He(e);if(!a)return null;const s=`${e.contentHash}/${r}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const r=e.acquire(i.id);return null==r||n(r)||(i.events.on("unloaded",()=>t=o(t)),t=r),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Ge(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return oe(a)?(l=a.data,u.preMultiplyAlpha=!1,u.encoding=a.encoding):(l=a,u.preMultiplyAlpha=1!==r,u.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),i=new be(l,u),this._textures.set(s,i),i.events.on("loaded",()=>this.updateComplexity()),i.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(i),i.events.on("unloaded",()=>{this._textures.delete(s)}),i}_setInternalMaterialTextureParameters(r,o){if(null!=r.colorTexture){const e=1!==o.textureAlphaMode,t=this._getInternalTexture(r.colorTexture,e,o.textureAlphaMode);t?(o.textureId=t.id,o.textureAlphaPremultiplied=!!t.parameters.preMultiplyAlpha):o.textureId=void 0}if(r.normalTexture&&(o.normalTextureId=this._getInternalTexture(r.normalTexture)?.id),r.emissiveColor){const n=e.toUnitRGB(r.emissiveColor);o.emissiveBaseColor=A(t(n[0]),t(n[1]),t(n[2]))}r.emissiveTexture&&(o.emissiveTextureId=this._getInternalTexture(r.emissiveTexture)?.id),r.occlusionTexture&&(o.occlusionTextureId=this._getInternalTexture(r.occlusionTexture,!0)?.id),r.metallicRoughnessTexture&&(o.metallicRoughnessTextureId=this._getInternalTexture(r.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ne(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ne(e.colorTextureTransform),t.normalTextureTransformMatrix=ne(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:d;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ne(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ne(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ne(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this._materialColor){const o=this._drivenProperties.color,n=this._drivenProperties.opacity;if(o)t.externalColor=S;else{const o=r??null;if(o){const r=e.toUnitRGBA(o);n&&(r[3]=1),t.externalColor=r}else t.externalColor=fe}t.colorMixMode=this.symbolLayer.material?.colorMixMode??"multiply",t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrength=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=re(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,n=r.material?.colorTexture,a=r.material?.alphaMode,s="blend"===a,i=!("opaque"===a)&&(Le(t)||null!=o&&o.a<1||n?.transparent||s),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return this._setInternalMaterialTextureParameters(l,c.material.parameters),c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=je({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),f={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:P,diffuse:R,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:0,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Ae:[l.metallic,l.roughness,Me[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?0:2,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new we(f,this._context);return u.material=p,this._materialInfoCache.set(l.uid,u),p}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchColor(e,t)}_preparePatchColor(e,t){if(!t.material||"partial"!==t.material.type)return;const r=t.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const o=r.color.newValue;delete r.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{const t=e.material.parameters;this._setExternalMaterialParameters(t,o),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){if("auto"===t.alphaMode){const r=this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1;e.textureAlphaMode=r?3:1}else e.textureAlphaMode="opaque"===t.alphaMode?1:"mask"===t.alphaMode?2:0}_createFaceDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],l=[],c=t[0].transformation,u=a(i(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get("position");if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)Ve(r,o,t,Ze),Fe(r,o,t,Ke,Qe,Xe),x(Ke,Ke,Qe),x(Ke,Ke,Xe),_(Ke,Ke,1/3),y(Ke,Ke,c),s.push(...Ke),T(Ze,Ze,u),b(Ze,Ze),v(Ke,Ke,Ze,n),s.push(...Ke),l.push(l.length),l.push(l.length)}return s.length?new Te(this._debugFaceNormalMaterial,[["position",new ye(s,l,3,!0)]],null,2):null}_createPerVertexDebugVectors(e,t,r,o,n){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*n*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(i(),p);"tangent"===r&&s(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get("position"),n=e.attributes.get(r);if(!o||!n)continue;const s=o.data,i=o.indices,l=n.data,c=n.indices;for(let t=0;t<i.length;t++){const e=3*i[t],r=c[t]*n.stride;g(Ke,s[e+0],s[e+1],s[e+2]),y(Ke,Ke,p),m.push(...Ke),g(Qe,l[r+0],l[r+1],l[r+2]),T(Qe,Qe,h),b(Qe,Qe),v(Ke,Ke,Qe,u),m.push(...Ke),f.push(f.length),f.push(f.length)}}return m.length?new Te(o,[["position",new ye(m,f,3,!0)]],null,2):null}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;if(_e.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(n,s,"normal",this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(n,s,"tangent",this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(n,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new ve({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=xe(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new ue(s[0].material,u,this._context.slicePlaneEnabled):null,f=new ce(this,c,null,se,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ie(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(n),r.centerInElevationSR=this._getCenterInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>le(e,p,r,h,t);return f.alignedSampledElevation=se(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!k(t))return!1;const{type:o}=t,{view:n}=this._context.graphicsCoreOwner,{viewingMode:a}=n.state,s=n.spatialReference;return 1===a&&"local"===o||2===a&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){const t=M(),r=g(nt,e[12],e[13],e[14]);return E(r,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return 0===e.reprojection&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,n=r;if(0===t.reprojection)return{position:n,georeferencedPositionBuffer:o};const a=1===t.reprojection?t.transformBeforeProject:null;a&&(n=Y(new Float64Array(n.length),n,a));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=n);const l=n===r||n===o?new Float64Array(n.length):n;return U(n,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const n=e.vertexAttributes.normal;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=J(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return K(a,0,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,0,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return X(a,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const n=e.vertexAttributes.tangent;if(null==n)return null;let a=n;const s=1===o.reprojection?o.transformBeforeProject:null;s&&(a=Z(a,new Float32Array(a.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(0===o.reprojection)return a;if("local"===i){if(!W(this._context.renderCoordsHelper.spatialReference))return a;if(null==r)return null;if(e.spatialReference.isGeographic){const e=a===n?new Float32Array(a.length):a;return K(a,1,r,e)}if(e.spatialReference.isWebMercator){const e=a===n?new Float32Array(a.length):a;return Q(a,1,r,e)}return a}if(null==r)return null;const l=a===n?new Float32Array(a.length):a,c=this._context.renderCoordsHelper.spatialReference;return ee(a,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),{position:i,georeferencedPositionBuffer:l}=this._createPositionBuffer(e,s),c=qe(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=n,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:m,tangent:p}:this._transformOriginLocal(e,i,m,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:0===s.reprojection&&s.geometryTransformation?s.geometryTransformation:f()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?0:1:0;if(z(t))return{reprojection:r};const o=t.origin,n=f(),a=e.transform?.localMatrix??p;if(0===r){B(e.spatialReference,o,n,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:n,geometryTransformation:h(a)}}const s=l(f(),o);return c(s,s,a),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const n=this._context.renderCoordsHelper.spatialReference,a=e.origin;Je[0]=a.x,Je[1]=a.y,Je[2]=a.z??0;const s=f();B(e.spatialReference,Je,s,n),u(et,s);const{position:i,normal:l,tangent:c}=e.vertexAttributes,m=t===i?new Float64Array(t.length):t;Y(m,t,et);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===c?new Float32Array(o.length):o:null;return r&&p&&J(r,p,et),o&&h&&Z(o,h,et),{transformation:s,position:m,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(O(o,rt),!V(rt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!I(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:u,geometryTransformation:f}=o,p=e.components??ot,h=new Array;let d=!1;const g=m(Ke,u),x=this._context.localOriginFactory.getOrigin(g);for(const m of p){if(!this._validateFaces(e,m))return null;const t=Ie(e,m);if(0===t.length)continue;const o=Be(n,l,m,t);o.didFlipNormals&&(d=!0);const u=[["position",new ye(n,t,3,!0)],["normal",new ye(o.normals,o.indices,3,!0)]];s&&u.push(["color",new ye(s,t,4,!0)]),i&&u.push(["symbolColor",new ye(i,G(t.length),4,!0)]),a&&u.push(["uv0",new ye(a,t,2,!0)]),c&&u.push(["tangent",new ye(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,m),_=new Te(g,u,null,0,p);_.transformation=f,_.localOrigin=x,h.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:h,objectTransformation:u}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return 2!==t||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class Se{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function Ie(e,t){return t.faces??D(e.vertexAttributes.position.length/3)}function Be(e,t,r,o){switch(r.shading||"flat"){default:case"source":return Ee(e,t,r,o);case"flat":return Ue(e,o);case"smooth":return Oe(e,o)}}function Ue(e,t){const r=$(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=Ve(e,t,n,Ze);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new Se(r,o,!1)}function Ee(e,t,r,o){if(null==t)return Ue(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){Ve(e,o,a,Ze);for(let e=0;e<3;e++){const r=3*o[a+e];Ke[0]=t[r],Ke[1]=t[r+1],Ke[2]=t[r+2],j(Ze,Ke)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new Se(t,o,n)}function Oe(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=Ve(e,t,a,Ze);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:M(),count:0},r[n]=s),x(s.normal,s.normal,o),s.count++}}const o=$(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new Se(o,n,!1)}function Fe(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}function Ve(e,t,r,o){return Fe(e,t,r,Ke,Qe,Xe),w(Qe,Qe,Ke),w(Xe,Xe,Ke),C(Ke,Qe,Xe),b(o,Ke),o}function $e(e){if(!e)return null;const{scale:t,offset:o,rotation:n}=e;return{scale:t,offset:o,rotation:r(n)}}function Ge(e="repeat"){if("string"==typeof e){const t=De(e);return{s:t,t}}return{s:De(e.horizontal),t:De(e.vertical)}}function De(e){switch(e){case"clamp":return 33071;case"mirror":return 33648;default:return 10497}}function Le(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}function Ne(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function He(e){return e.data??e.url}function ke(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function ze(e){const{offset:t,scale:r,rotation:o}=e??Ye;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function qe(e){return e.vertexAttributes.color}function We(e){return 1===(e.material?.color?.a??0)}const Ye=new H,Je=M(),Ke=M(),Qe=M(),Xe=M(),Ze=M(),et=f(),tt=f(),rt=F(),ot=[new L],nt=M();export{Pe as Graphics3DMeshFillSymbolLayer};