@arcgis/core 4.33.0-next.20250427 → 4.33.0-next.20250429

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 (125) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{92836e3a2c5226296fec.js → 12c9dd3932218238033b.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{6d230c55cde66ee905b3.js → 1a0d4b7de2f98ff9cc01.js} +1 -1
  4. package/assets/esri/core/workers/chunks/2433b22749a088735262.js +1 -0
  5. package/assets/esri/core/workers/chunks/278280121528fa1059de.js +1 -0
  6. package/assets/esri/core/workers/chunks/28317c8d7fa2eeeaf997.js +1 -0
  7. package/assets/esri/core/workers/chunks/37619d28b0441199c320.js +1 -0
  8. package/assets/esri/core/workers/chunks/{360c8cff7c3b25d2b2d2.js → 5a821b7bf58eebb9062c.js} +1 -1
  9. package/assets/esri/core/workers/chunks/6b9110ec7da0fef1be31.js +1 -0
  10. package/assets/esri/core/workers/chunks/8c8d812a7f2d29c29676.js +1 -0
  11. package/assets/esri/core/workers/chunks/8fc5b1c17e841362dd15.js +1 -0
  12. package/assets/esri/core/workers/chunks/{5ac3096139e3eafd0e1d.js → 97eedd6b90c6a9c67947.js} +1 -1
  13. package/assets/esri/core/workers/chunks/9cac00d4bfac14aaae12.js +1 -0
  14. package/assets/esri/core/workers/chunks/{9661ee8569ee208e6237.js → ada9694498549f56dff1.js} +1 -1
  15. package/assets/esri/core/workers/chunks/b1473d15c75fc560ea4a.js +1 -0
  16. package/assets/esri/core/workers/chunks/{76575d2c1c56e37c1315.js → b1e420cb425a3625170e.js} +5 -5
  17. package/assets/esri/core/workers/chunks/{87dcfbbcf290e0fa5c0f.js → c3033f148213c960b906.js} +102 -163
  18. package/assets/esri/core/workers/chunks/{b8b8425e8b1246cdc86d.js → c6b0dda0540c9db12d0e.js} +1 -1
  19. package/assets/esri/core/workers/chunks/def182fff5a0244b1c2c.js +1 -0
  20. package/assets/esri/core/workers/chunks/f1222bf7232c4a168312.js +1 -0
  21. package/assets/esri/themes/base/widgets/_Legend.scss +2 -1
  22. package/assets/esri/themes/dark/main.css +1 -1
  23. package/assets/esri/themes/light/main.css +1 -1
  24. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ar.json +1 -1
  25. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bg.json +1 -1
  26. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_bs.json +1 -1
  27. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ca.json +1 -1
  28. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_cs.json +1 -1
  29. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_da.json +1 -1
  30. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_de.json +1 -1
  31. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_el.json +1 -1
  32. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_es.json +1 -1
  33. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_et.json +1 -1
  34. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fi.json +1 -1
  35. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_fr.json +1 -1
  36. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_he.json +1 -1
  37. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hr.json +1 -1
  38. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_hu.json +1 -1
  39. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_id.json +1 -1
  40. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_it.json +1 -1
  41. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ja.json +1 -1
  42. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ko.json +1 -1
  43. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lt.json +1 -1
  44. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_lv.json +1 -1
  45. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_nl.json +1 -1
  46. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_no.json +1 -1
  47. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pl.json +1 -1
  48. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-BR.json +1 -1
  49. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_pt-PT.json +1 -1
  50. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ro.json +1 -1
  51. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_ru.json +1 -1
  52. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sk.json +1 -1
  53. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sl.json +1 -1
  54. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sr.json +1 -1
  55. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_sv.json +1 -1
  56. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_th.json +1 -1
  57. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_tr.json +1 -1
  58. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_uk.json +1 -1
  59. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_vi.json +1 -1
  60. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-CN.json +1 -1
  61. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-HK.json +1 -1
  62. package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_zh-TW.json +1 -1
  63. package/chunks/ComponentShader.glsl.js +43 -39
  64. package/chunks/ShadowCastAccumulate.glsl.js +5 -5
  65. package/chunks/ShadowHighlight.glsl.js +4 -4
  66. package/core/Collection.js +1 -1
  67. package/core/CollectionFlattener.js +1 -1
  68. package/core/MemCache.js +1 -1
  69. package/identity/IdentityManagerBase.js +1 -1
  70. package/interfaces.d.ts +67 -37
  71. package/layers/LinkChartLayer.js +1 -1
  72. package/package.json +3 -3
  73. package/request.js +1 -1
  74. package/rest/networks/circuits/alterCircuit.js +5 -0
  75. package/rest/networks/circuits/createCircuit.js +5 -0
  76. package/rest/networks/circuits/deleteCircuits.js +5 -0
  77. package/rest/networks/circuits/queryCircuits.js +5 -0
  78. package/rest/networks/circuits/support/CircuitVerifyResult.js +5 -0
  79. package/rest/networks/circuits/support/CreateAlterCircuitParameters.js +5 -0
  80. package/rest/networks/circuits/support/DeleteCircuitsParameters.js +5 -0
  81. package/rest/networks/circuits/support/QueryCircuitsParameters.js +5 -0
  82. package/rest/networks/circuits/support/QueryCircuitsResult.js +5 -0
  83. package/rest/networks/circuits/support/VerifyCircuitsParameters.js +5 -0
  84. package/rest/networks/circuits/support/VerifyCircuitsResult.js +5 -0
  85. package/rest/networks/circuits/verifyCircuits.js +5 -0
  86. package/smartMapping/renderers/support/spikeUtils.js +1 -1
  87. package/support/revision.js +1 -1
  88. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  89. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  90. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  91. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  92. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  93. package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateSceneLighting.glsl.js +9 -8
  94. package/views/3d/webgl-engine/core/shaderLibrary/shading/MainLighting.glsl.js +3 -3
  95. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +30 -125
  96. package/views/3d/webgl-engine/core/shaderLibrary/shading/calculateUVZShadow.js +38 -0
  97. package/views/3d/webgl-engine/core/shaderLibrary/shading/calculateUVZShadowFromDepth.js +35 -0
  98. package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
  99. package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
  100. package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
  101. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  102. package/views/3d/webgl-engine/shaders/ReadShadowMapConfiguration.js +1 -1
  103. package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
  104. package/views/3d/webgl-engine/shaders/ShadowHighlight.glsl.js +1 -1
  105. package/views/support/LayerViewManager.js +1 -1
  106. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  107. package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
  108. package/widgets/FeatureForm/EditableInput.js +1 -1
  109. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  110. package/widgets/FeatureForm.js +1 -1
  111. package/widgets/LayerList/LayerListItem.js +1 -1
  112. package/widgets/LayerList/ListItemPanel.js +1 -1
  113. package/widgets/Legend/support/sizeRampUtils.js +1 -1
  114. package/widgets/TableList/ListItemPanel.js +1 -1
  115. package/assets/esri/core/workers/chunks/27482132abb939a1cdb7.js +0 -1
  116. package/assets/esri/core/workers/chunks/335b539893569e3d7b82.js +0 -1
  117. package/assets/esri/core/workers/chunks/53eaad20c4f55dae21e0.js +0 -1
  118. package/assets/esri/core/workers/chunks/7c4746f60332620f75c5.js +0 -1
  119. package/assets/esri/core/workers/chunks/8221f2e540abe1e0f048.js +0 -1
  120. package/assets/esri/core/workers/chunks/ae156b99e60a2bf940e4.js +0 -1
  121. package/assets/esri/core/workers/chunks/c054198c6438cb57f188.js +0 -1
  122. package/assets/esri/core/workers/chunks/c6b08fdc0421258efcf5.js +0 -1
  123. package/assets/esri/core/workers/chunks/d44e99b4bb1cec6a922b.js +0 -1
  124. package/assets/esri/core/workers/chunks/e64bc4533405af8554ae.js +0 -1
  125. package/assets/esri/core/workers/chunks/fd36b7aaf0d8e0c84471.js +0 -1
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import r from"../../../../core/Error.js";import{makeHandle as s}from"../../../../core/handleUtils.js";import a from"../../../../core/Logger.js";import{findInMap as n}from"../../../../core/MapUtils.js";import{abortMaybe as o,removeMaybe as l,destroyMaybe as h,disposeMaybe as d}from"../../../../core/maybe.js";import{MinPriority as p}from"../../../../core/MemCache.js";import c from"../../../../core/PooledArray.js";import{throwIfAborted as y,createResolver as g,isAbortError as u,ignoreAbortErrors as m}from"../../../../core/promiseUtils.js";import{when as b,watch as _,whenOnce as f,on as v,syncAndInitial as C}from"../../../../core/reactiveUtils.js";import{schedule as S}from"../../../../core/scheduling.js";import{property as G}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as x,isEmpty as P}from"../../../../core/accessorSupport/diffUtils.js";import{i as R,g as D,h as E}from"../../../../chunks/vec32.js";import{create as I}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import U from"../../../../geometry/Extent.js";import A from"../../../../geometry/Point.js";import{canProjectWithoutEngine as L}from"../../../../geometry/projection.js";import{projectBuffer as j}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as O}from"../../../../geometry/projection/projectVectorToVector.js";import{projectXYZToVector as V}from"../../../../geometry/projection/projectXYZToVector.js";import{create as F,center as T,fromRect as M,equals as z}from"../../../../geometry/support/aaBoundingBox.js";import{create as k}from"../../../../geometry/support/aaBoundingRect.js";import{equals as H}from"../../../../geometry/support/spatialReferenceUtils.js";import W from"../../../../layers/Layer.js";import{getObjectId as N,computeAABB as B,hasGeometry as q}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as Y}from"../../../../layers/graphics/hydratedFeatures.js";import{PromiseQueue as Q}from"../../../../layers/support/PromiseQueue.js";import $ from"../../../../renderers/UniqueValueRenderer.js";import{isSupportedRenderer3D as Z,validateTo3D as J}from"../../../../renderers/support/rendererConversion.js";import{RenderingInfo as X}from"../../../../renderers/support/RenderingInfo.js";import{isBasemapLayerView as K}from"../../../../support/basemapUtils.js";import{loadArcade as ee}from"../../../../support/loadArcade.js";import te from"../../../../symbols/LabelSymbol3D.js";import ie from"../../../../symbols/TextSymbol.js";import re from"../../../../symbols/WebStyleSymbol.js";import{getDefaultSymbol3D as se}from"../../../../symbols/support/defaults3D.js";import{to3D as ae}from"../../../../symbols/support/symbolConversion.js";import{averageSymbolComplexities as ne,defaultSymbolComplexity as oe}from"./defaultSymbolComplexity.js";import{DisplayFeatureLimit as le}from"./DisplayFeatureLimit.js";import{ViewElevationProvider as he}from"./ElevationQuery.js";import{VisibilityGroup as de,VisibilityFlag as pe}from"./enums.js";import{extractExpressionInfo as ce,createContext as ye}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as ge}from"./Graphics3DFeatureStore.js";import{Graphics3DGraphicCreationContext as ue}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as me}from"./Graphics3DSymbolCreationContext.js";import{make as be}from"./Graphics3DSymbolFactory.js";import{Graphics3DWebStyleSymbol as _e}from"./Graphics3DWebStyleSymbol.js";import{GraphicsCorePerformanceInfo as fe}from"./GraphicsCorePerformanceInfo.js";import{GraphicStateTracking as ve}from"./GraphicStateTracking.js";import{computeCentroid as Ce}from"./graphicUtils.js";import{FastUpdateStatus as Se,ApplyRendererDiffResult as Ge}from"./interfaces.js";import{LoadStatus as we}from"./Loadable.js";import{SpatialIndex2D as xe}from"./SpatialIndex2D.js";import{StageLayerElevationProvider as Pe}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as Re}from"../../support/extentUtils.js";import{GridLocalOriginFactory as De}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{UpdatePolicy as Ee}from"../../webgl-engine/lib/UpdatePolicy.js";import{affectsGeometry as Ie}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as Ue}from"../../webgl-engine/lib/WebGLLayer.js";import{hasPopupTemplate as Ae}from"../../../layers/support/popupUtils.js";import{PropertiesPool as Le}from"../../../support/PropertiesPool.js";import{ImmediateTask as je,TaskPriority as Oe,noBudget as Ve}from"../../../support/Scheduler.js";import{TextureCompressionHandle as Fe}from"../../../support/TextureCompressionHandle.js";import{Yield as Te}from"../../../support/Yield.js";import{alphaCutoff as Me}from"../../../../webscene/support/AlphaCutoff.js";var ze;const ke=I(),He=F();let We=class extends t{static{ze=this}static{this.tmpVec=I()}get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new xe({objectIdField:this.owner.layer?.objectIdField,spatialReference:this._viewSpatialReference,hasZ:!!this.hasZ,hasM:!!this.hasM}),this._spatialIndex.setup(Array.from(this.graphics3DGraphics.values()))),this._spatialIndex.update(),this._spatialIndex}get deconflictor(){return this._deconflictor}get labeler(){return this._labeler}get numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return null!=this.currentRenderer&&"dictionary"===this.currentRenderer.type?Ee.ASYNC:this._forcedUpdatePolicy??this.preferredUpdatePolicy}get featureStore(){return this._featureStore}get initializePromise(){return this._initializePromise}get scaleVisibility(){return this._scaleVisibility}get elevationAlignment(){return this._elevationAlignment}get objectStates(){return this._objectStates}get filterVisibility(){return this._filterVisibility}get updating(){return!!(this.dataUpdating||this._elevationAlignment?.updating||this._scaleVisibility?.updating||this._filterVisibility?.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._frameTaskHandle.updating||this.running)}get dataUpdating(){return!!(this._graphicsWaitingForSymbol.size>0||this._pendingUpdates.size>0||this._spatialIndex?.updating||this._updatingPendingLoadedGraphicsChange||this._dataUpdateQueue.running||this._loadingSymbols>0||this.compressionHandle.compressing)}get running(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating||this._dataUpdateQueue.running||this._updateQueue.running}get suspendedOrOutsideOfView(){return this.owner.suspended||!!this.owner.suspendInfo?.outsideOfView}get updatingRemaining(){return this.updating?this._pendingUpdates.size+.1*(this._spatialIndex?.updatingRemaining||0)+.1*(this._elevationAlignment?.updatingRemaining||0):0}get displayFeatureLimit(){const e=this.owner&&this.owner.view&&this.owner.view.qualitySettings,t=e?.graphics3D.minTotalNumberOfFeatures??0,i=e?.graphics3D.maxTotalNumberOfFeatures??0,r=e?.graphics3D.maxNumberOfDrawCalls??0,s=e?.graphics3D.maxTotalNumberOfVertices??0,a=this.averageSymbolComplexity,n=Math.max(1,a?.verticesPerFeature??1),o=a&&a.drawCallsPerFeature>0&&r>0?r/a.drawCallsPerFeature:i,l=Math.ceil(s/n),h=Math.max(t,Math.min(i,l,o)),d=this._get("displayFeatureLimit");return d&&d.maximumTotalNumberOfVertices===s&&d.averageSymbolComplexity===a&&d.maximumNumberOfFeatures===h?d:new le(s,h,a)}get averageSymbolComplexity(){const e=ne(this._symbolComplexities),t=this._get("averageSymbolComplexity");return 0===e.numComplexities||null!=t&&(e.estimated&&(t.verticesPerFeature>=e.verticesPerFeature||t.verticesPerCoordinate>=e.verticesPerCoordinate||t.drawCallsPerFeature>=e.drawCallsPerFeature)||t.verticesPerFeature===e.verticesPerFeature&&t.verticesPerCoordinate===e.verticesPerCoordinate&&t.drawCallsPerFeature===e.drawCallsPerFeature)?t:e}get usedMemory(){const e=this.labelsEnabled?(this.averageSymbolComplexity?.memory.bytesPerFeatureLabel??0)*this._numberOfGraphics:0,t=this._getSymbolComplexitiesUsed().reduce(((e,t)=>e+t.memory.resourceBytes),0);if(null==this._symbolMaterials){this._symbolMaterials=[];for(const e of this._symbols.values())if(null!=e)for(const t of e.symbolLayers)if(t)for(const e of t.materials)e&&this._symbolMaterials.push(e)}const i=this.owner.view.stage.renderer,r=this.owner.view.basemapTerrain.overlayManager.renderer,s=this._symbolMaterials.reduce(((e,t)=>e+((i.getMaterialRenderer(t)||r.getMaterialRenderer(t))?.usedMemory??0)),0);return this._usedMemory+e+t+s}get usedMemoryPerGraphic(){if(this._usedMemory&&this._numberOfGraphics){const e=this._numberOfGraphics/(this._numberOfGraphics+Math.max(this._pendingAdds,this._pendingRemoves));return this._usedMemory/this._numberOfGraphics*e}if(null!=this.averageSymbolComplexity){const e=this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel:0;return this.averageSymbolComplexity.memory.bytesPerFeature+e}return 0}get unprocessedMemoryEstimate(){return(this._pendingAdds-this._pendingRemoves)*this.usedMemoryPerGraphic}get _symbolComplexities(){return this.currentRenderer?this._getSymbolComplexitiesUsedOrRenderer(this.currentRenderer):this._getSymbolComplexitiesUsed()}get visible(){return this._visible}_getConvertedSymbol(e){const t=e;if("web-style"===t.type)return t.clone();const i=this._symbolConversionCache.get(t.id);if(null!=i)return i;const r=ae(t,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(t),cimFallbackEnabled:!0}),s=r.symbol||null;return null==s&&r.error&&a.getLogger(this).error(r.error.message),this._symbolConversionCache.set(t.id,s),s}_getSymbolComplexitiesUsedOrRenderer(e){if(null==e)return[];const t=e.symbols,i="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!i&&!t.length)return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(i);null!=s&&r.push(s);for(const a of t){const e=this._getSymbolComplexityUsedOrRenderer(a);null!=e&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(null==e)return null;const t=this._symbols.get(e.id);if(null!=t)return t.complexity;const i=this._getConvertedSymbol(e);return null!=i?oe(i):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach((t=>{null!=t&&e.push(t.complexity)})),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new Le({computedExtent:U},this),this.computedExtent=null,this.currentRenderer=null,this.rendererHasGeometryOperations=!1,this._graphicStateTracking=null,this.graphics3DGraphics=new Map,this.stageLayer=null,this.stage=null,this._graphicsDrapedUids=new Set,this._graphicsBySymbol=new Map,this._symbolConversionCache=new Map,this._symbols=new Map,this._graphicsWithoutSymbol=new Map,this._graphicsWaitingForSymbol=new Map,this._graphicsUpdateId=0,this._frameTaskHandle=je,this._dataUpdateQueue=new Q,this._updateQueue=new Q,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=null,this._elevationAlignment=null,this._scaleVisibility=null,this._filterVisibility=null,this._spatialIndex=null,this.extentPadding=0,this._updatingPendingLoadedGraphicsChange=null,this._featureStore=null,this._deconflictor=null,this._labeler=null,this._objectStates=null,this._viewElevationProvider=null,this._stageLayerElevationProvider=null,this._sharedSymbolResourcesOwnerHandle=null,this._whenGraphics3DGraphicRequests={},this._pendingUpdates=new Map,this._numberOfGraphics=0,this._numberOfGraphicsProvidingElevation=0,this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this._loadingSymbols=0,this._pendingUpdatesPool=new c({allocator:e=>e||new Be,deallocator:e=>(e.clear(),e)}),this.compressionHandle=new Fe,this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new c,this.preferredUpdatePolicy=Ee.SYNC,this._forcedUpdatePolicy=null,this.elevationFeatureExpressionEnabled=!0,this.owner=null,this.layer=null,this.graphicSymbolSupported=!0,this.getRenderingInfoWithoutRenderer=!1,this.setUidToIdOnAdd=!0,this.hasZ=null,this.hasM=null,this._usedMemory=0,this._visible=!1,this._startCreateGraphics=!1,this._unusedSymbolsCache=e.owner.view.resourceController.memoryController.newCache("graphics-3d-unused-symbols",(e=>e.destroy())),this.symbolCreationContext=new me(e.owner.view.resourceController.scheduler,((e,t)=>this._updateQueue.push(e,t)),e.owner.layerViewUid,this.compressionHandle)}initialize(){this._featureStore=new ge({objectIdField:this.owner.layer?.objectIdField,hasZ:!!this.hasZ,hasM:!!this.hasM,viewSpatialReference:this._viewSpatialReference,featureSpatialReference:this.owner.featureSpatialReference,getSpatialIndex:()=>this.spatialIndex,forEach:e=>this.graphics3DGraphics.forEach(e)});const e=(e,t,i)=>this.spatialIndex.queryGraphicUIDsInExtent(e,t,i),{componentFactories:t}=this;this._elevationAlignment=t.elevationAlignment?.(this,e),this._scaleVisibility=t.scaleVisibility?.(this,e),this._filterVisibility=t.filterVisibility?.({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities((t=>t.setVisibilityFlag(de.GRAPHIC,pe.FILTER,e(N(t.graphic,this._objectIdField))))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities((t=>t.setVisibilityFlag(de.GRAPHIC,pe.FILTER,e))),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(de.GRAPHIC,pe.FILTER,!0)))}),this._deconflictor=t.deconflictor?.(this),this._labeler=t.labeler?.(this,this._scaleVisibility),this._objectStates=t.objectStates?.(this),this._initializeAbortController=new AbortController,this.addHandles(b((()=>this.owner.view.state.highlights),(()=>{const{highlightOrderMap:e}=this.owner.view.state;this.graphics3DGraphics.forEach((t=>t.updateHighlights(e)))}))),this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,t=this.owner.view;this._viewElevationProvider=new he(this._viewSpatialReference,t),this._initializeStage(t,this.owner.layerViewUid);const i=t.sharedSymbolResources;this.symbolCreationContext.sharedResources=i,this._sharedSymbolResourcesOwnerHandle=i.addGraphicsOwner(this.owner),null!=this.currentRenderer&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=i.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=t.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new De(t.renderSpatialReference),this.symbolCreationContext.elevationProvider=t.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const r=ce(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await ye(r,this._viewSpatialReference,e,a.getLogger(this)),y(e),this.symbolCreationContext.screenSizePerspectiveEnabled=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this.symbolCreationContext.physicalBasedRenderingEnabled=!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,this.symbolCreationContext.skipHighSymbolLods=!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,"drapeSourceType"in this.owner){const{owner:e}=this;this.symbolCreationContext.drapeSourceRenderer=t.basemapTerrain.overlayManager.registerGeometryDrapeSource(e),this.addHandles(s((()=>t.basemapTerrain.overlayManager.unregisterDrapeSource(e))))}this.addHandles([_((()=>this.suspendedOrOutsideOfView),(()=>this._updateQueue.unshift((()=>this._updateLayerVisibility()),null).catch(m))),_((()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view?.screenSizePerspectiveEnabled]),(()=>{const e=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())})),_((()=>this.owner.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(!!e))),_((()=>this.owner.view.state?.rasterPixelRatio),(()=>this._pixelRatioChange())),_((()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._physicalBasedRenderingChange(e))),_((()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods),(e=>this._skipHighSymbolLoDsChange(e))),_((()=>this.owner.view.focusAreas.activePolygons),(()=>this._updateFocusedLabels())),_((()=>this.owner.view.focusAreas.style),(()=>this.recreateAllGraphicsAndSymbols())),b((()=>t.basemapTerrain?.tilingScheme),(e=>{if(e.spatialReference.equals(this.symbolCreationContext.overlaySR)||null==t.basemapTerrain.spatialReference||(this.symbolCreationContext.overlaySR=t.basemapTerrain.spatialReference),this.hasHandles("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this.addHandles([v(e,"change",(e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}),{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}}),{initial:!0}),_((()=>this.effectiveUpdatePolicy),(e=>{null!=this.stageLayer&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=this.effectiveUpdatePolicy===Ee.ASYNC,e===Ee.SYNC&&this.runTask(Ve)}),C)]),this._frameTaskHandle=t.resourceController.scheduler.registerTask(Oe.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this.addHandles(_((()=>this.layer.featureReduction),(()=>this._deconflictor?.featureReductionChange()))),this.notifyChange("averageSymbolComplexity"),this.rendererChange(this.owner.renderer).catch((()=>{})),this._initializeAbortController=null}_abortInitialize(){this._initializeAbortController&&(this._initializeAbortController.abort(),this._initializeAbortController=null)}_updateFocusedLabels(){this.forEachGraphics3DSymbol(((e,t)=>{e.updateFocus((e=>{this.recreateGraphics([e.graphic])}),t)}))}destroy(){this._unusedSymbolsCache.destroy(),this._abortInitialize(),this._rendererChangeAbortController=o(this._rendererChangeAbortController),this._abortElevationInfoChange(),this._frameTaskHandle.remove(),this._frameTaskHandle=je,this._dataUpdateQueue.cancelAll(),this._updateQueue.cancelAll(),this._deconflictor=l(this._deconflictor),this._labeler=l(this._labeler),this._elevationAlignment=h(this._elevationAlignment),this._scaleVisibility=h(this._scaleVisibility),this._filterVisibility=h(this._filterVisibility),this._objectStates=h(this._objectStates),this.clear(),this._featureStore=h(this._featureStore),this._updatingPendingLoadedGraphicsChange=l(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=h(this._graphicStateTracking),this.stage&&(this.stageLayer=h(this.stageLayer),this.stage=null),this._set("owner",null);for(const e in this._whenGraphics3DGraphicRequests)this._whenGraphics3DGraphicRequests[e].reject(new r("graphic:layer-destroyed","Layer has been destroyed"));this._whenGraphics3DGraphicRequests=null,this._sharedSymbolResourcesOwnerHandle=l(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=h(this._propertiesPool),this._pendingUpdatesPool=null,this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=h(this._spatialIndex)}clear(){this._objectStates?.allGraphicsDeleted(),null!=this._graphicStateTracking&&this._graphicStateTracking.allGraphicsDeleted(),this.graphics3DGraphics.forEach((e=>e.destroy())),this._spatialIndex?.clear(),this.graphics3DGraphics.clear(),this._numberOfGraphics=0,this._usedMemory=0,this._updateLayerVisibility(),this._symbols.forEach(h),this._symbols.clear(),this._symbolMaterials=null,this._graphicsBySymbol.clear(),this._graphicsWithoutSymbol.clear(),this._graphicsWaitingForSymbol.clear(),this._pendingUpdates.clear(),this._pendingUpdatesPool.clear(),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this.notifyChange("dataUpdating"),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed")}_initializeStage(e,t){this.stage=e.stage,this.stageLayer=new Ue(this.stage,{visible:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},t);const i=this.stageLayer.events;i.on("transformationChanged",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),i.on("shaderTransformationChanged",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),i.on("visibilityChanged",(e=>this.notifyGraphicVisibilityChanged(e.graphicUid))),i.on("geometryAdded",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),i.on("geometryRemoved",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),i.on("attributesChanged",(e=>Ie(e.attribute)&&this.notifyGraphicGeometryChanged(e.object.graphicUid)))}notifyGraphicGeometryChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicGeometry(t)}notifyGraphicVisibilityChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicVisibility(t)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,t=this._numberOfGraphics>e*qe,i=!this.suspendedOrOutsideOfView&&!t;i!==this._visible&&(this._visible=i,this._updateStageLayerVisibility())}_updateStageLayerVisibility(){const e=this._visible&&(null==this.layer.opacity||this.layer.opacity>=Me);this.stageLayer.visible!==e&&(this.stageLayer.visible=e,e?this.updateGraphicsVisibilities():this._hideAllGraphics())}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,t=this.owner.layer?.objectIdField){return N(e,t)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer?.objectIdField;if(!e)return;const t=new Map;return this.graphics3DGraphics.forEach((i=>{if(!i)return;const r=i.graphic,s=this._getGraphicObjectID(r,e);null!=s&&t.set(s,i)})),t}get labelsEnabled(){return!!this._labeler?.layerLabelsEnabled()}async updateLabelingInfo(e){const t=this._deconflictor?.labelingInfoChange(e),i=this._labeler?.labelingInfoChange(e);await Promise.allSettled([t,i])}updateVisibilityInfo(){this._deconflictor?.labelingInfoChange(),this._labeler?.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=!1,t=!1;for(const[i,r]of this._symbols)if(null!=r){switch(r.getFastUpdateStatus()){case Se.Loading:return"unknown";case Se.Fast:this._graphicsBySymbol.has(i)&&(t=!0);break;case Se.Slow:this._graphicsBySymbol.has(i)&&(e=!0);break;case Se.Mixed:this._graphicsBySymbol.has(i)&&(t=e=!0);case Se.Undefined:}}return t?e?"mixed":"fast":e?"slow":"mixed"}runTask(e){if(this._dataUpdateQueue.runTask(e),this._updateQueue.runTask(e),this._applyPendingUpdates(e),this.notifyChange("running"),this.running||this.notifyChange("dataUpdating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return Te}setObjectIdVisibility(e,t){t?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const i=this._findGraphics3DGraphicByObjectId(e);null!=i&&this._updateUserVisibility(i)}_findGraphics3DGraphicByObjectId(e){return n(this.graphics3DGraphics,(t=>this._getGraphicObjectID(t.graphic)===e))}_updateUserVisibility(e){if(null==e)return!1;const t=e.graphic,i=this._getGraphicObjectID(t),r=t.visible&&!this.owner.suspended&&this.stageLayer.visible&&(null==i||!this._objectIdInvisibleSet.has(i));return e.setVisibilityFlag(de.GRAPHIC,pe.USER,r)}_whenGraphics3DGraphic(e){const t=this.graphics3DGraphics.get(e.uid);if(t)return Promise.resolve(t);const i=this._whenGraphics3DGraphicRequests[e.uid];if(i)return i.promise;const r=g();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,t){const i=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,t,s)=>j(e,r,t,e,i,t,s),n=(e,t,r)=>j(e,s,t,e,i,t,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:null!=t&&!!t.useViewElevation,minDemResolution:null!=t?t.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,t?.signal);if(!l)return null;const h=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){T(h,ke);const t=e.getElevation(ke[0],ke[1],0,i,"ground")??0;h[2]=Math.min(h[2],t),h[5]=Math.max(h[5],t)}}return{boundingBox:h,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,t){await f((()=>this.owner?.loadedGraphics));const i=this.owner.layer?.objectIdField,s=this.owner.loadedGraphics.find((t=>t===e||null!=i&&null!=t.attributes&&e.attributes&&t.attributes[i]===e.attributes[i]));if(!s)throw new r("internal:graphic-not-part-of-view","Graphic is not part of this view");const a=await this._whenGraphics3DGraphic(s);return this._boundsForGraphics3DGraphic(a,t)}computeAttachmentOrigin(e,t){const i=this.graphics3DGraphics.get(e.uid);if(!i)return null;const r=i.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;R(Ye,0,0,0);let s=0;if(r.render.num>0){if(!O(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,Qe,t))return null;D(Ye,Ye,Qe),s++}if(r.draped.num>0){const[e,i]=r.draped.origin,a=this._viewElevationProvider.getElevation(e,i,"ground")??0;if(R(Qe,e,i,a),!O(Qe,this._viewElevationProvider.spatialReference,Qe,t))return null;D(Ye,Ye,Qe),s++}return s>1&&E(Ye,Ye,1/s),new A({x:Ye[0],y:Ye[1],z:Ye[2],spatialReference:t})}getSymbolLayerSize(e,t){const i=this._symbols.get(e.id);if(null==i)throw new r("internal:symbol-not-part-of-view","Symbol is not part of this view");const s=e.symbolLayers.indexOf(t);if(-1===s)throw new r("internal:missing-symbol-layer","Symbol layer is not in symbol");const a=i.getSymbolLayerSize(s);if(null==a)throw new r("internal:missing-size","Symbol layer has no valid size");return a}_graphicsCollectionChanged(e){this._startCreateGraphics&&(this.add(e.added),this.remove(e.removed))}graphicUpdateHandler(e){const t=e.graphic.uid,i=this.graphics3DGraphics.get(t);if(null!=i||null!=this._graphicsWithoutSymbol.get(t))switch(e.property){case"visible":this._graphicUpdateVisibleHandler(i);break;case"geometry":this._graphicUpdateGeometryHandler(i,e);break;case"symbol":this._graphicUpdateSymbolHandler(i,e);break;case"attributes":break;case"origin-transform":this._graphicUpdateTransformHandler(i,e)}}_graphicUpdateGeometryHandler(e,t){this._graphicUpdateGeometryOrTransformHandler(e,t,(()=>!(null==t.newValue||null==e||!e.graphics3DSymbol.updateGeometry(e,t.newValue)||!(this._labeler?.updateGraphicGeometry(e)??1))&&(this._labeler?.setDirty(),!0)));const i=t.graphic.geometry;null!=i&&this._expandComputedExtent(i)}_graphicUpdateTransformHandler(e,t){const i=t.graphic.geometry;this._graphicUpdateGeometryOrTransformHandler(e,t,(()=>null!=t.newValue&&null!=e&&null!=i&&e.graphics3DSymbol.updateTransform(e,i.spatialReference,t.newValue,t.action)))}_graphicUpdateGeometryOrTransformHandler(e,t,i){if(null!=t.graphic.geometry)if(null!=e)i()||this._recreateGraphic(e.graphic);else{const e=t.graphic.symbol?.id;if(e){const t=this._symbols.get(e);if(null!=t&&t.loadStatus===we.LOADING)return}this._recreateGraphic(t.graphic)}else this._recreateGraphic(t.graphic)}_graphicUpdateSymbolHandler(e,t){const i=t.graphic,r=null!=e?e.graphics3DSymbol:null!=t.oldValue?this._symbols.get(t.oldValue.id):null;if(null==r||null==t.newValue)return void this._recreateGraphic(i);const s=r.symbol,a=this._getConvertedSymbol(t.newValue);if(null!=a&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(i);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(i);const o=x(s,a);if(null==o)return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!P(l.diff))return void this._recreateGraphic(i);const h=this._getRenderingInfo(i);if(null==h)return void this._recreateGraphic(i);const d=r.extentPadding;for(const p of l.symbolStatePatches)p();if(d!==r.extentPadding&&this._recomputeExtentPadding(),null!=e)for(const p of l.graphics3DGraphicPatches)p(e,h);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,this.effectiveUpdatePolicy===Ee.SYNC&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const t=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,t),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("dataUpdating"),t}_endGraphicUpdate(e,t){e&&(t&&this._graphicStateTracking?.updateGraphicError(e,t),this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach((t=>{null!=t&&(e=Math.max(e,t.extentPadding))})),this._set("extentPadding",e)}_expandComputedExtent(e){const t=He,i=e.spatialReference;B(e,t);const r=this._viewSpatialReference,s=ze.tmpVec;if(H(i,r)||V(t[0],t[1],0,i,s,r)&&(t[0]=s[0],t[1]=s[1],V(t[3],t[4],0,i,s,r),t[3]=s[0],t[4]=s[1]),!(isFinite(t[0])&&isFinite(t[3])&&isFinite(t[1])&&isFinite(t[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(t[2])&&isFinite(t[5]),l=o&&(null==a?.zmin||t[2]<a.zmin),h=o&&(null==a?.zmax||t[5]>a.zmax);if(a){(t[0]<a.xmin||t[1]<a.ymin||t[3]>a.xmax||t[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(t[0],a.xmin),n.ymin=Math.min(t[1],a.ymin),n.xmax=Math.max(t[3],a.xmax),n.ymax=Math.max(t[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=t[0],n.ymin=t[1],n.xmax=t[3],n.ymax=t[4],n.spatialReference=r;n&&(l&&(n.zmin=t[2]),h&&(n.zmax=t[5]),this._set("computedExtent",n))}_abortElevationInfoChange(){this._elevationInfoChangeAbortController&&(this._elevationInfoChangeAbortController.abort(),this._elevationInfoChangeAbortController=null)}async elevationInfoChange(){this._abortElevationInfoChange();const e=new AbortController;this._elevationInfoChangeAbortController=e;const t=ce(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await ye(t,this._viewSpatialReference,e.signal,a.getLogger(this)),y(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("elevationInfo",t)?t.forEach((e=>{const t=e.graphic,i=e.labelLayers;for(const r of i){r.graphics3DSymbolLayer.updateGraphicElevationContext(t,r)}})):this._recreateSymbol(i)})),this.updateStageLayerElevationProvider(),this._elevationAlignment?.elevationInfoChange()}updateStageLayerElevationProvider(){this._stageLayerElevationProvider?(this.layer.elevationInfo&&"relative-to-scene"===this.layer.elevationInfo.mode||0===this._numberOfGraphicsProvidingElevation)&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=d(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new Pe({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),null!=this._filterVisibility&&this._filterVisibility.clear(),this._labeler?.reset(),this._deconflictor?.clear(),this._elevationAlignment?.clear(),this.stageLayer?.invalidateSpatialQueryAccelerator(),this._stageLayerElevationProvider&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=d(this._stageLayerElevationProvider))}startCreateGraphics(){this._startCreateGraphics=!0,this.recreateAllGraphics()}recreateAllGraphics(){this._recreateAllGraphics(!1)}recreateAllGraphicsAndSymbols(){this._recreateAllGraphics(!0)}_recreateAllGraphics(e=!1){if(!this._startCreateGraphics)return;const{loadedGraphics:t,view:i}=this.owner,r=i.basemapTerrain.tilingScheme&&t?.length?t.toArray():null;!e&&r||this._clearSymbolsAndGraphics(),this.symbolCreationContext.screenSizePerspectiveEnabled=this.owner.view.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this._set("computedExtent",null),r&&(e?this.add(r):this.recreateGraphics(r))}_recreateSymbol(e){const t=this._graphicsBySymbol.get(e),i=[];t&&(t.forEach(((e,t)=>{const r=e.usedMemory;this._conditionalRemove(e,t),this._spatialIndex?.remove(e),i.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(t,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed")})),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);h(r),this._symbols.delete(e),this._symbolMaterials=null,this.add(i)}_recreateGraphicsForSymbol(e){const t=this._graphicsBySymbol.get(e);if(t){const e=[];t.forEach((t=>e.push(t.graphic))),this.recreateGraphics(e)}}_conditionalRemove(e,t){this._graphicsDrapedUids.delete(t),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),null!=this._graphicStateTracking&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain?.tilingScheme?(this._updatePolicyForGraphics(e)===Ee.ASYNC?this._addDelayed(e):this._addImmediate(e),this.notifyChange("dataUpdating")):a.getLogger(this).error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(this.effectiveUpdatePolicy===Ee.SYNC&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const t of e)if(null!=t.geometry&&"mesh"===t.geometry.type&&!t.geometry.loaded)return Ee.ASYNC;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const t of e)this._addGraphic(t,this._getRenderingInfo(t,a.getLogger(this)),Ee.SYNC);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_addDelayed(e){for(const t of e){const e=t.uid;let i=this._pendingUpdates.get(e);i?i.add?i.state!==Ne.NEW&&i.abortController?.abort():this._pendingAdds++:(i=this._pendingUpdatesPool.pushNew(),this._pendingAdds++,this._pendingUpdates.set(e,i)),i.add=t}this.notifyChange("running"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}remove(e){this.effectiveUpdatePolicy===Ee.ASYNC?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("dataUpdating")}_removeImmediate(e){for(const t of e)this._removeGraphic(t);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_removeDelayed(e){for(const t of e){const e=t.uid,i=this._pendingUpdates.get(e);if(i)i.add&&(i.remove?i.add=null:this._pendingUpdates.delete(e),i.state===Ne.LOADING&&i.abortController?.abort(),this._pendingAdds--);else{const i=this._pendingUpdatesPool.pushNew();i.remove=t,this._pendingUpdates.set(e,i),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}_finishPendingUpdates(){this._pendingUpdatesPool.clear(),this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&a.getLogger(this).warn("pendingAdds/Removes in inconsistent state!"),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1}_applyPendingUpdates(e){if(this._geometryWarningLogged=!1,this._symbolWarningLogged=!1,0===this._pendingUpdates.size&&this._spatialIndex?.updating)return this._spatialIndex.update(),void e.madeProgress();if(this._applyPendingRemovesFirst){this._applyPendingRemovesFirst=!1;for(const[t,i]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(i.remove&&!i.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,this._pendingUpdates.delete(t),0===this._pendingRemoves))break}}for(const[t,i]of this._pendingUpdates){if(e.done)break;i.add&&i.state===Ne.NEW&&this._processPendingUpdateNew(i);let r=this.effectiveUpdatePolicy;if(!i.remove||i.add&&i.state!==Ne.READY||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,r=Ee.SYNC),i.add)switch(i.state){case Ne.READY:this._addGraphic(i.add,i.renderingInfo,r),i.add=null,this._pendingAdds--,e.madeProgress();break;case Ne.REJECTED:i.add=null,this._pendingAdds--;case Ne.LOADING:}null==i.remove&&null==i.add&&this._pendingUpdates.delete(t)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("dataUpdating"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=Ne.READY);const t=e.add.geometry;null==t||"mesh"!==t.type||t.loaded?this._processPendingUpdateNewRenderingInfo(e):this._processPendingUpdateNewMesh(e,t)}async _processPendingUpdateNewMesh(e,t){e.state=Ne.LOADING,e.abortController=new AbortController;const i=e.abortController.signal;try{await t.load({signal:i})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,t){e.abortController=null,u(t)?e.state=Ne.NEW:e.state=Ne.REJECTED}async _processPendingUpdateNewRenderingInfo(e){if(null==this.layer.renderer||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add,a.getLogger(this)),void(e.state=Ne.READY);e.state=Ne.LOADING,e.abortController=new AbortController;let t=null;try{t=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(i){return e.abortController=null,void(u(i)?e.state=Ne.NEW:e.state=Ne.REJECTED)}null==t?.symbol?(this._symbolWarningLogged||(this._symbolWarningLogged=!0,a.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=t,e.state=Ne.READY}_addGraphic(e,t,i){if(this._graphicsWithoutSymbol.set(e.uid,e),null==t?.symbol||!q(e))return;const r=this.stage.renderView.olidRenderHelper;if(r&&this.setUidToIdOnAdd){const t=K(this.owner.view,this.owner.layerViewUid);r.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.owner.layerViewUid,!!this.layer.popupEnabled&&!t&&Ae(this.layer,this.owner.view.popup?.defaultPopupTemplateEnabled))}const s=t.symbol,a=this.getOrCreateGraphics3DSymbol(s,t.renderer);if(null==a)return;this._expandComputedExtent(e.geometry);const n=this._beginGraphicUpdate(e),o=new ue(e,t,this.layer);let l=!1;const h=e=>{e===a.symbol.id&&(l=!0)};this._whenSymbolRemoved.push(h);const d=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(h);if(this._graphicsWaitingForSymbol.get(e.uid)!==n||l||a.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==a.symbol.id)--a.referenced,this._cleanupSymbols();else{const t=this._createGraphics3DGraphic(a,o);this._spatialIndex&&null!=t&&this._spatialIndex.add(t),--a.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this._labeler?.setDirty()},p=t=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(h),l||(u(t)?this.add([e]):a.destroyed||this._endGraphicUpdate(e,t)))};++this._loadingSymbols,i===Ee.ASYNC?a.load((()=>this._dataUpdateQueue.push(d,null).catch(m)),(e=>this._dataUpdateQueue.push((()=>p(e)),null).catch(m))):a.load(d,p)}_removeGraphic(e){const t=e.uid,i=this.graphics3DGraphics.get(t);if(i){i.graphics3DSymbol.onRemoveGraphic(i);const e=i.usedMemory,r=i.isElevationSource;this._conditionalRemove(i,t),this._spatialIndex?.remove(i);const s=i.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(t),this._graphicsWithoutSymbol.delete(t),this._removeGraphics3DGraphic(t,e,r),i.destroy(),this._featureStore.events.emit("changed")}else this._graphicsWithoutSymbol.delete(t),this._graphicsWaitingForSymbol.delete(t),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating"))}_hasLabelingContext(e){if(e instanceof te||e instanceof ie){const t=this.symbolCreationContext.layer;return!!t.labelingInfo&&t.labelingInfo.some((t=>t.symbol===e))}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof te&&!this._hasLabelingContext(e))||(a.getLogger(this).error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,t){const i=e.geometry;if(null==i)return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!L(i.spatialReference,this._viewSpatialReference))return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?Y(e,this.layer):e;let s;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||null!=this.currentRenderer))s=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{const e=r.symbol||se(r.geometry);s=new X(null,e)}return null==s?.symbol?(t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):s}_getRenderingInfoAsync(e,t){if(null==e.geometry)return this._geometryWarningLogged||(this._geometryWarningLogged=!0,a.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return this._symbolWarningLogged||(this._symbolWarningLogged=!0,a.getLogger(this).warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const i=this.rendererHasGeometryOperations?Y(e,this.layer):e;return this.owner.getRenderingInfoAsync(i,this.currentRenderer,this._arcadeOnDemand,t)}_createGraphics3DSymbol(e,t){if(!this._hasValidSymbolCreationContext(e))return null;const i=this._getConvertedSymbol(e);if(!i)return null;let r;if(null!=t&&"backgroundFillSymbol"in t&&t.backgroundFillSymbol){const e=ae(t.backgroundFillSymbol,{ignoreDrivers:!0});null!=e.symbol&&(r=e.symbol.symbolLayers)}const s=be(i,this.symbolCreationContext,r);return s.load((()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")}),(()=>{})),s}getOrCreateGraphics3DSymbol(e,t){let i=this._symbols.get(e.id);if(void 0===i){const r=this._unusedSymbolsCache.pop(e.id);i=null!=r?r:e instanceof re?new _e(e,(e=>this._dataUpdateQueue.push(e,null)),(e=>this._createGraphics3DSymbol(e,t))):this._createGraphics3DSymbol(e,t),this._symbols.set(e.id,i),this._symbolMaterials=null}return null!=i&&++i.referenced,i}trackGraphicState(e){return null==this._graphicStateTracking&&(this._graphicStateTracking=new ve(this)),this._graphicStateTracking.add(e)}_addGraphics3DGraphic(e){this._usedMemory+=e.usedMemory,this.graphics3DGraphics.set(e.graphic.uid,e),this._numberOfGraphics++,e.isElevationSource&&(this._numberOfGraphicsProvidingElevation++,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_removeGraphics3DGraphic(e,t,i=!1){this._usedMemory-=t,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,i&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,t){const i=t.graphic;if(this._graphicsWithoutSymbol.delete(i.uid),!this._symbols.has(e.symbol.id))return this.add([i]),null;if(this.graphics3DGraphics.has(i.uid))return null;const r=e.createGraphics3DGraphic(t);if(null==r)return null;this._addGraphics3DGraphic(r);const s=e.symbol.id;this._graphicsBySymbol.has(s)||this._graphicsBySymbol.set(s,new Map),this._graphicsBySymbol.get(s).set(i.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(i.uid),r.centroid=null,null!=i.geometry&&"point"!==i.geometry.type&&(r.centroid=Ce(i.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(r),null!=this._filterVisibility){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(de.GRAPHIC,pe.FILTER,e),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),r.initialize(this.stageLayer),null!=this._graphicStateTracking&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[i.uid];return a&&(delete this._whenGraphics3DGraphicRequests[i.uid],a.resolve(r)),this._symbolMaterials=null,r}async rendererChange(e){if(this._rendererChangeAbortController=o(this._rendererChangeAbortController),e!==this.currentRenderer)if(this._validateRenderer(e),null==e&&this._currentRendererChange(null,!1),Z(e))if(e?.arcadeRequired){const t=new AbortController;this._rendererChangeAbortController=t;const{arcadeUtils:i}=await this._ensureArcade();y(t);const r=i.hasGeometryOperations(e);r&&(await i.enableGeometryOperations(),y(t)),this.effectiveUpdatePolicy===Ee.ASYNC?await this._updateQueue.push((()=>this._currentRendererChange(e,r)),t.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(this.effectiveUpdatePolicy===Ee.ASYNC){const t=new AbortController;this._rendererChangeAbortController=t,await this._updateQueue.push((()=>this._currentRendererChange(e,!1)),t.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return null==this._arcadeOnDemand?(this._arcadeOnDemand=await ee(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,t){this.currentRenderer=e,this.rendererHasGeometryOperations=t,this.symbolCreationContext.arcade=this._arcadeOnDemand;const i=this.symbolCreationContext.renderer;if(e===i)return;if(this._symbolConversionCache.clear(),this._unusedSymbolsCache.clear(),null==e)return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=x(i,e);this._updateUnchangedSymbolMappings(r,e,i),this.symbolCreationContext.renderer=e,null!=r&&("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,i)?this._labeler?.reset():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const t in e.diff)switch(t){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[t];break;default:return!0}return!1}_applySymbolSetDiff(e,t,i){e=e||[],t=t||[];const r=[];for(const s of t){const t=this._graphicsBySymbol.get(s.id);t&&t.forEach(((a,n)=>{const o=a.graphic,l=this.layer instanceof W?this.layer:null,h=this._arcadeOnDemand;if(s===i.defaultSymbol&&i.getSymbol(Y(o,l),{arcade:h})===i.defaultSymbol)return;const d=a.usedMemory;e.length||i.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),t.delete(n),this._removeGraphics3DGraphic(n,d),this._updateLayerVisibility()})),this._whenSymbolRemoved.forAll((e=>e(s.id)))}(e.length||r.length)&&(this._graphicsWithoutSymbol.forEach((e=>r.push(e))),this._graphicsWithoutSymbol.clear(),this.add(r)),this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_applyUniqueValueRendererDiff(e,t,r){const s=e.diff.defaultSymbol,a=e.diff.uniqueValueInfos;if(s||a){const n=a?a.added.map((e=>e.symbol)).filter(i):[],o=a?a.removed.map((e=>e.symbol)).filter(i):[];if(a)for(let e=0;e<a.changed.length;e++)n.push(a.changed[e].newValue.symbol),o.push(a.changed[e].oldValue.symbol);return s?(r.defaultSymbol&&o.push(r.defaultSymbol),t.defaultSymbol&&n.push(t.defaultSymbol)):r.defaultSymbol&&n.length&&o.push(t.defaultSymbol),this._applySymbolSetDiff(n,o,t),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,t,i){if("unique-value"!==t?.type||"unique-value"!==i?.type||null!=e&&"partial"!==e.type)return[];const r=e=>null!=e?e.id:null,s=e&&e.diff,a=s?.defaultSymbol,n=s&&s.uniqueValueInfos;let o;if(n)o=n.unchanged.map((e=>({oldId:r(e.oldValue.symbol),newId:r(e.newValue.symbol)})));else{o=[];for(const e of i.uniqueValueInfos??[]){const i=r(e.symbol),s=t.uniqueValueInfos?.find((t=>t.value===e.value));s&&i!==r(s.symbol)&&o.push({oldId:i,newId:r(s.symbol)})}}return!a&&i.defaultSymbol&&o.push({oldId:r(i.defaultSymbol),newId:r(t.defaultSymbol)}),o}_updateSymbolMapping(e,t){const i=null!=t&&t?"string"==typeof t?t:t.id:null;if(null==e||e===i)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(i,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(i,s),this._symbolMaterials=null,null!=s)){const e="string"==typeof t?null:t;null!=e?s.symbol=e:s.symbol.id=i}}_updateUnchangedSymbolMappings(e,t,i){const r=this._calculateUnchangedSymbolMapping(e,t,i);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,t,i){if(this._diffHasSymbolChange(e))return!1;if(t instanceof $&&i instanceof $&&this._applyUniqueValueRendererDiff(e,t,i)&&0===Object.keys(e.diff).length)return!0;for(const r of this._graphicsBySymbol.keys()){const i=this._symbols.get(r);if(null!=i)switch(i.applyRendererDiff(e,t)){case Ge.RecreateSymbol:this._recreateSymbol(r);break;case Ge.RecreateGraphics:this._recreateGraphicsForSymbol(r);case Ge.FastUpdate:}}return!0}opacityChange(){this._updateStageLayerVisibility(),this.forEachGraphics3DSymbol(((e,t)=>e.globalPropertyChanged("opacity",t)))}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol(((e,t)=>e.globalPropertyChanged("slicePlaneEnabled",t))),this._deconflictor?.slicePlaneEnabledChange(),this._labeler?.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",t)||this._recreateSymbol(i)}))}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("skipHighSymbolLods",t)||this._recreateSymbol(i)}))}_pixelRatioChange(){this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("pixelRatio",t)||this._recreateSymbol(i)}))}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=S((()=>{this._updatingPendingLoadedGraphicsChange=null}))}setClippingExtent(e,t){const i=this.symbolCreationContext.clippingExtent,r=k();return Re(e,r,t)?this.symbolCreationContext.clippingExtent=M(F(),r):this.symbolCreationContext.clippingExtent=null,!z(this.symbolCreationContext.clippingExtent,i)}modifyGraphics3DGraphicVisibilities(e){if(this.destroyed)return;let t=!1;this.graphics3DGraphics.forEach((i=>{e(i)&&(t=!0)})),t&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}forEachGraphics3DSymbol(e){for(const[t,i]of this._symbols){if(null==i)return;e(i,this._graphicsBySymbol.get(t)||$e,t)}}updateGraphicsVisibilities(){null!=this._filterVisibility&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities((e=>{const t=this._updateUserVisibility(e),i=null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(e);return t||i}))}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(de.GRAPHIC,pe.USER,!1)))}_validateRenderer(e){const t=()=>`'${this.layer.title?`${this.layer.title}, `:""}id:${this.layer.id}'`,i=J(e,{geometryType:this.layer?.geometryType,logWarning:(e,i)=>a.getLogger(this).warn(e,`Symbology conversion for layer ${t()}: ${i}`)});if(i){const e=`Renderer for layer ${t} is not supported in a SceneView`;a.getLogger(this).warn(e,i.message)}}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach(((t,i)=>{if(null==t||t.referenced>0)return;const r=this._graphicsBySymbol.get(i);r&&0!==r.size||(this._graphicsBySymbol.delete(i),this._symbols.delete(i),this._symbolMaterials=null,this._unusedSymbolsCache.put(i,t,p),e=!0)})),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){}get performanceInfo(){return new fe(this.graphics3DGraphics.size,Array.from(this.graphics3DGraphics.values()).reduce(((e,t)=>e+(t.isVisible()?1:0)),0),this._graphicsWithoutSymbol.size,this._pendingUpdates.size)}};var Ne;e([G({readOnly:!0})],We.prototype,"computedExtent",void 0),e([G()],We.prototype,"currentRenderer",void 0),e([G()],We.prototype,"rendererHasGeometryOperations",void 0),e([G()],We.prototype,"_frameTaskHandle",void 0),e([G()],We.prototype,"_dataUpdateQueue",void 0),e([G()],We.prototype,"_updateQueue",void 0),e([G({readOnly:!0})],We.prototype,"_viewSpatialReference",null),e([G()],We.prototype,"_rendererChangeAbortController",void 0),e([G()],We.prototype,"_elevationInfoChangeAbortController",void 0),e([G()],We.prototype,"_initializeAbortController",void 0),e([G()],We.prototype,"_elevationAlignment",void 0),e([G()],We.prototype,"_scaleVisibility",void 0),e([G()],We.prototype,"_filterVisibility",void 0),e([G()],We.prototype,"_initializePromise",void 0),e([G()],We.prototype,"_spatialIndex",void 0),e([G({readOnly:!0})],We.prototype,"extentPadding",void 0),e([G()],We.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([G()],We.prototype,"_featureStore",void 0),e([G()],We.prototype,"_objectStates",void 0),e([G()],We.prototype,"_loadingSymbols",void 0),e([G({constructOnly:!0})],We.prototype,"compressionHandle",void 0),e([G()],We.prototype,"preferredUpdatePolicy",void 0),e([G()],We.prototype,"_forcedUpdatePolicy",void 0),e([G({readOnly:!0})],We.prototype,"effectiveUpdatePolicy",null),e([G({constructOnly:!0})],We.prototype,"elevationFeatureExpressionEnabled",void 0),e([G({constructOnly:!0})],We.prototype,"owner",void 0),e([G({constructOnly:!0})],We.prototype,"layer",void 0),e([G({constructOnly:!0})],We.prototype,"graphicSymbolSupported",void 0),e([G({constructOnly:!0})],We.prototype,"getRenderingInfoWithoutRenderer",void 0),e([G({constructOnly:!0})],We.prototype,"componentFactories",void 0),e([G({constructOnly:!0})],We.prototype,"setUidToIdOnAdd",void 0),e([G()],We.prototype,"featureStore",null),e([G()],We.prototype,"initializePromise",null),e([G()],We.prototype,"scaleVisibility",null),e([G()],We.prototype,"elevationAlignment",null),e([G()],We.prototype,"objectStates",null),e([G()],We.prototype,"filterVisibility",null),e([G({readOnly:!0})],We.prototype,"updating",null),e([G({readOnly:!0})],We.prototype,"dataUpdating",null),e([G({readOnly:!0})],We.prototype,"running",null),e([G({readOnly:!0})],We.prototype,"suspendedOrOutsideOfView",null),e([G({readOnly:!0,dependsOn:[]})],We.prototype,"updatingRemaining",null),e([G({readOnly:!0})],We.prototype,"displayFeatureLimit",null),e([G({readOnly:!0,dependsOn:[]})],We.prototype,"averageSymbolComplexity",null),e([G({constructOnly:!0})],We.prototype,"hasZ",void 0),e([G({constructOnly:!0})],We.prototype,"hasM",void 0),e([G()],We.prototype,"_objectIdField",null),We=ze=e([w("esri.views.3d.layers.graphics.Graphics3DCore")],We),function(e){e[e.NEW=0]="NEW",e[e.LOADING=1]="LOADING",e[e.READY=2]="READY",e[e.REJECTED=3]="REJECTED"}(Ne||(Ne={}));class Be{constructor(){this.add=null,this.renderingInfo=null,this.state=Ne.NEW,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=Ne.NEW,this.abortController=null,this.remove=null}}const qe=10,Ye=I(),Qe=I(),$e=new Map;export{We as Graphics3DCore};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../core/Accessor.js";import{isSome as i}from"../../../../core/arrayUtils.js";import"../../../../core/has.js";import r from"../../../../core/Error.js";import{makeHandle as s}from"../../../../core/handleUtils.js";import a from"../../../../core/Logger.js";import{findInMap as n}from"../../../../core/MapUtils.js";import{abortMaybe as o,removeMaybe as l,destroyMaybe as h,disposeMaybe as d}from"../../../../core/maybe.js";import{MinPriority as p}from"../../../../core/MemCache.js";import c from"../../../../core/PooledArray.js";import{throwIfAborted as y,createResolver as g,isAbortError as u,ignoreAbortErrors as m}from"../../../../core/promiseUtils.js";import{when as b,watch as _,whenOnce as f,on as v,syncAndInitial as C}from"../../../../core/reactiveUtils.js";import{schedule as S}from"../../../../core/scheduling.js";import{property as G}from"../../../../core/accessorSupport/decorators/property.js";import{subclass as w}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as x,isEmpty as P}from"../../../../core/accessorSupport/diffUtils.js";import{i as R,g as D,h as E}from"../../../../chunks/vec32.js";import{create as I}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import U from"../../../../geometry/Extent.js";import A from"../../../../geometry/Point.js";import{canProjectWithoutEngine as L}from"../../../../geometry/projection.js";import{projectBuffer as j}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as O}from"../../../../geometry/projection/projectVectorToVector.js";import{projectXYZToVector as V}from"../../../../geometry/projection/projectXYZToVector.js";import{create as F,center as T,fromRect as M,equals as z}from"../../../../geometry/support/aaBoundingBox.js";import{create as k}from"../../../../geometry/support/aaBoundingRect.js";import{equals as H}from"../../../../geometry/support/spatialReferenceUtils.js";import W from"../../../../layers/Layer.js";import{getObjectId as N,computeAABB as B,hasGeometry as q}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as Y}from"../../../../layers/graphics/hydratedFeatures.js";import{PromiseQueue as Q}from"../../../../layers/support/PromiseQueue.js";import $ from"../../../../renderers/UniqueValueRenderer.js";import{isSupportedRenderer3D as Z,validateTo3D as J}from"../../../../renderers/support/rendererConversion.js";import{RenderingInfo as X}from"../../../../renderers/support/RenderingInfo.js";import{isBasemapLayerView as K}from"../../../../support/basemapUtils.js";import{loadArcade as ee}from"../../../../support/loadArcade.js";import te from"../../../../symbols/LabelSymbol3D.js";import ie from"../../../../symbols/TextSymbol.js";import re from"../../../../symbols/WebStyleSymbol.js";import{getDefaultSymbol3D as se}from"../../../../symbols/support/defaults3D.js";import{to3D as ae}from"../../../../symbols/support/symbolConversion.js";import{averageSymbolComplexities as ne,defaultSymbolComplexity as oe}from"./defaultSymbolComplexity.js";import{DisplayFeatureLimit as le}from"./DisplayFeatureLimit.js";import{ViewElevationProvider as he}from"./ElevationQuery.js";import{VisibilityGroup as de,VisibilityFlag as pe}from"./enums.js";import{extractExpressionInfo as ce,createContext as ye}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as ge}from"./Graphics3DFeatureStore.js";import{Graphics3DGraphicCreationContext as ue}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as me}from"./Graphics3DSymbolCreationContext.js";import{make as be}from"./Graphics3DSymbolFactory.js";import{Graphics3DWebStyleSymbol as _e}from"./Graphics3DWebStyleSymbol.js";import{GraphicsCorePerformanceInfo as fe}from"./GraphicsCorePerformanceInfo.js";import{GraphicStateTracking as ve}from"./GraphicStateTracking.js";import{computeCentroid as Ce}from"./graphicUtils.js";import{FastUpdateStatus as Se,ApplyRendererDiffResult as Ge}from"./interfaces.js";import{LoadStatus as we}from"./Loadable.js";import{SpatialIndex2D as xe}from"./SpatialIndex2D.js";import{StageLayerElevationProvider as Pe}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as Re}from"../../support/extentUtils.js";import{GridLocalOriginFactory as De}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{UpdatePolicy as Ee}from"../../webgl-engine/lib/UpdatePolicy.js";import{affectsGeometry as Ie}from"../../webgl-engine/lib/VertexAttribute.js";import{WebGLLayer as Ue}from"../../webgl-engine/lib/WebGLLayer.js";import{hasPopupTemplate as Ae}from"../../../layers/support/popupUtils.js";import{PropertiesPool as Le}from"../../../support/PropertiesPool.js";import{ImmediateTask as je,TaskPriority as Oe,noBudget as Ve}from"../../../support/Scheduler.js";import{TextureCompressionHandle as Fe}from"../../../support/TextureCompressionHandle.js";import{Yield as Te}from"../../../support/Yield.js";import{alphaCutoff as Me}from"../../../../webscene/support/AlphaCutoff.js";var ze;const ke=I(),He=F();let We=class extends t{static{ze=this}static{this.tmpVec=I()}get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new xe({objectIdField:this.owner.layer?.objectIdField,spatialReference:this._viewSpatialReference,hasZ:!!this.hasZ,hasM:!!this.hasM}),this._spatialIndex.setup(Array.from(this.graphics3DGraphics.values()))),this._spatialIndex.update(),this._spatialIndex}get deconflictor(){return this._deconflictor}get labeler(){return this._labeler}get numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return null!=this.currentRenderer&&"dictionary"===this.currentRenderer.type?Ee.ASYNC:this._forcedUpdatePolicy??this.preferredUpdatePolicy}get featureStore(){return this._featureStore}get initializePromise(){return this._initializePromise}get scaleVisibility(){return this._scaleVisibility}get elevationAlignment(){return this._elevationAlignment}get objectStates(){return this._objectStates}get filterVisibility(){return this._filterVisibility}get updating(){return!!(this.dataUpdating||this._elevationAlignment?.updating||this._scaleVisibility?.updating||this._filterVisibility?.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._frameTaskHandle.updating||this.running)}get dataUpdating(){return!!(this._graphicsWaitingForSymbol.size>0||this._pendingUpdates.size>0||this._spatialIndex?.updating||this._updatingPendingLoadedGraphicsChange||this._dataUpdateQueue.running||this._loadingSymbols>0||this.compressionHandle.compressing)}get running(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating||this._dataUpdateQueue.running||this._updateQueue.running}get suspendedOrOutsideOfView(){return this.owner.suspended||!!this.owner.suspendInfo?.outsideOfView}get updatingRemaining(){return this.updating?this._pendingUpdates.size+.1*(this._spatialIndex?.updatingRemaining||0)+.1*(this._elevationAlignment?.updatingRemaining||0):0}get displayFeatureLimit(){const e=this.owner&&this.owner.view&&this.owner.view.qualitySettings,t=e?.graphics3D.minTotalNumberOfFeatures??0,i=e?.graphics3D.maxTotalNumberOfFeatures??0,r=e?.graphics3D.maxNumberOfDrawCalls??0,s=e?.graphics3D.maxTotalNumberOfVertices??0,a=this.averageSymbolComplexity,n=Math.max(1,a?.verticesPerFeature??1),o=a&&a.drawCallsPerFeature>0&&r>0?r/a.drawCallsPerFeature:i,l=Math.ceil(s/n),h=Math.max(t,Math.min(i,l,o)),d=this._get("displayFeatureLimit");return d&&d.maximumTotalNumberOfVertices===s&&d.averageSymbolComplexity===a&&d.maximumNumberOfFeatures===h?d:new le(s,h,a)}get averageSymbolComplexity(){const e=ne(this._symbolComplexities),t=this._get("averageSymbolComplexity");return 0===e.numComplexities||null!=t&&(e.estimated&&(t.verticesPerFeature>=e.verticesPerFeature||t.verticesPerCoordinate>=e.verticesPerCoordinate||t.drawCallsPerFeature>=e.drawCallsPerFeature)||t.verticesPerFeature===e.verticesPerFeature&&t.verticesPerCoordinate===e.verticesPerCoordinate&&t.drawCallsPerFeature===e.drawCallsPerFeature)?t:e}get usedMemory(){const e=this.labelsEnabled?(this.averageSymbolComplexity?.memory.bytesPerFeatureLabel??0)*this._numberOfGraphics:0,t=this._getSymbolComplexitiesUsed().reduce(((e,t)=>e+t.memory.resourceBytes),0);if(null==this._symbolMaterials){this._symbolMaterials=[];for(const e of this._symbols.values())if(null!=e)for(const t of e.symbolLayers)if(t)for(const e of t.materials)e&&this._symbolMaterials.push(e)}const i=this.owner.view.stage.renderer,r=this.owner.view.basemapTerrain.overlayManager.renderer,s=this._symbolMaterials.reduce(((e,t)=>e+((i.getMaterialRenderer(t)||r.getMaterialRenderer(t))?.usedMemory??0)),0);return this._usedMemory+e+t+s}get usedMemoryPerGraphic(){if(this._usedMemory&&this._numberOfGraphics){const e=this._numberOfGraphics/(this._numberOfGraphics+Math.max(this._pendingAdds,this._pendingRemoves));return this._usedMemory/this._numberOfGraphics*e}if(null!=this.averageSymbolComplexity){const e=this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel:0;return this.averageSymbolComplexity.memory.bytesPerFeature+e}return 0}get unprocessedMemoryEstimate(){return(this._pendingAdds-this._pendingRemoves)*this.usedMemoryPerGraphic}get _symbolComplexities(){return this.currentRenderer?this._getSymbolComplexitiesUsedOrRenderer(this.currentRenderer):this._getSymbolComplexitiesUsed()}get visible(){return this._visible}_getConvertedSymbol(e){const t=e;if("web-style"===t.type)return t.clone();const i=this._symbolConversionCache.get(t.id);if(null!=i)return i;const r=ae(t,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(t),cimFallbackEnabled:!0}),s=r.symbol||null;return null==s&&r.error&&a.getLogger(this).error(r.error.message),this._symbolConversionCache.set(t.id,s),s}_getSymbolComplexitiesUsedOrRenderer(e){if(null==e)return[];const t=e.symbols,i="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!i&&!t.length)return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(i);null!=s&&r.push(s);for(const a of t){const e=this._getSymbolComplexityUsedOrRenderer(a);null!=e&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(null==e)return null;const t=this._symbols.get(e.id);if(null!=t)return t.complexity;const i=this._getConvertedSymbol(e);return null!=i?oe(i):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach((t=>{null!=t&&e.push(t.complexity)})),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new Le({computedExtent:U},this),this.computedExtent=null,this.currentRenderer=null,this.rendererHasGeometryOperations=!1,this._graphicStateTracking=null,this.graphics3DGraphics=new Map,this.stageLayer=null,this.stage=null,this._graphicsDrapedUids=new Set,this._graphicsBySymbol=new Map,this._symbolConversionCache=new Map,this._symbols=new Map,this._graphicsWithoutSymbol=new Map,this._graphicsWaitingForSymbol=new Map,this._graphicsUpdateId=0,this._frameTaskHandle=je,this._dataUpdateQueue=new Q,this._updateQueue=new Q,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=null,this._elevationAlignment=null,this._scaleVisibility=null,this._filterVisibility=null,this._spatialIndex=null,this.extentPadding=0,this._updatingPendingLoadedGraphicsChange=null,this._featureStore=null,this._deconflictor=null,this._labeler=null,this._objectStates=null,this._viewElevationProvider=null,this._stageLayerElevationProvider=null,this._sharedSymbolResourcesOwnerHandle=null,this._whenGraphics3DGraphicRequests={},this._pendingUpdates=new Map,this._numberOfGraphics=0,this._numberOfGraphicsProvidingElevation=0,this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this._loadingSymbols=0,this._pendingUpdatesPool=new c({allocator:e=>e||new Be,deallocator:e=>(e.clear(),e)}),this.compressionHandle=new Fe,this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new c,this.preferredUpdatePolicy=Ee.SYNC,this._forcedUpdatePolicy=null,this.elevationFeatureExpressionEnabled=!0,this.owner=null,this.layer=null,this.graphicSymbolSupported=!0,this.getRenderingInfoWithoutRenderer=!1,this.setUidToIdOnAdd=!0,this.hasZ=null,this.hasM=null,this._usedMemory=0,this._visible=!1,this._startCreateGraphics=!1,this._unusedSymbolsCache=e.owner.view.resourceController.memoryController.newCache("graphics-3d-unused-symbols",(e=>e.destroy())),this.symbolCreationContext=new me(e.owner.view.resourceController.scheduler,((e,t)=>this._updateQueue.push(e,t)),e.owner.layerViewUid,this.compressionHandle)}initialize(){this._featureStore=new ge({objectIdField:this.owner.layer?.objectIdField,hasZ:!!this.hasZ,hasM:!!this.hasM,viewSpatialReference:this._viewSpatialReference,featureSpatialReference:this.owner.featureSpatialReference,getSpatialIndex:()=>this.spatialIndex,forEach:e=>this.graphics3DGraphics.forEach(e)});const e=(e,t,i)=>this.spatialIndex.queryGraphicUIDsInExtent(e,t,i),{componentFactories:t}=this;this._elevationAlignment=t.elevationAlignment?.(this,e),this._scaleVisibility=t.scaleVisibility?.(this,e),this._filterVisibility=t.filterVisibility?.({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities((t=>t.setVisibilityFlag(de.GRAPHIC,pe.FILTER,e(N(t.graphic,this._objectIdField))))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities((t=>t.setVisibilityFlag(de.GRAPHIC,pe.FILTER,e))),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(de.GRAPHIC,pe.FILTER,!0)))}),this._deconflictor=t.deconflictor?.(this),this._labeler=t.labeler?.(this,this._scaleVisibility),this._objectStates=t.objectStates?.(this),this._initializeAbortController=new AbortController,this.addHandles(b((()=>this.owner.view.state.highlights),(()=>{const{highlightOrderMap:e}=this.owner.view.state;this.graphics3DGraphics.forEach((t=>t.updateHighlights(e)))}))),this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,t=this.owner.view;this._viewElevationProvider=new he(this._viewSpatialReference,t),this._initializeStage(t,this.owner.layerViewUid);const i=t.sharedSymbolResources;this.symbolCreationContext.sharedResources=i,this._sharedSymbolResourcesOwnerHandle=i.addGraphicsOwner(this.owner),null!=this.currentRenderer&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=i.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=t.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new De(t.renderSpatialReference),this.symbolCreationContext.elevationProvider=t.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const r=ce(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await ye(r,this._viewSpatialReference,e,a.getLogger(this)),y(e),this.symbolCreationContext.screenSizePerspectiveEnabled=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this.symbolCreationContext.physicalBasedRenderingEnabled=!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled,this.symbolCreationContext.skipHighSymbolLods=!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods,"drapeSourceType"in this.owner){const{owner:e}=this;this.symbolCreationContext.drapeSourceRenderer=t.basemapTerrain.overlayManager.registerGeometryDrapeSource(e),this.addHandles(s((()=>t.basemapTerrain.overlayManager.unregisterDrapeSource(e))))}this.addHandles([_((()=>this.suspendedOrOutsideOfView),(()=>this._updateQueue.unshift((()=>this._updateLayerVisibility()),null).catch(m))),_((()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view?.screenSizePerspectiveEnabled]),(()=>{const e=t.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())})),_((()=>this.owner.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(!!e))),_((()=>this.owner.view.state?.rasterPixelRatio),(()=>this._pixelRatioChange())),_((()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._physicalBasedRenderingChange(e))),_((()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods),(e=>this._skipHighSymbolLoDsChange(e))),_((()=>this.owner.view.focusAreas.activePolygons),(()=>this._updateFocusedLabels())),_((()=>this.owner.view.focusAreas.style),(()=>this.recreateAllGraphicsAndSymbols())),b((()=>t.basemapTerrain?.tilingScheme),(e=>{if(e.spatialReference.equals(this.symbolCreationContext.overlaySR)||null==t.basemapTerrain.spatialReference||(this.symbolCreationContext.overlaySR=t.basemapTerrain.spatialReference),this.hasHandles("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this.addHandles([v(e,"change",(e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}),{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}}),{initial:!0}),_((()=>this.effectiveUpdatePolicy),(e=>{null!=this.stageLayer&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=this.effectiveUpdatePolicy===Ee.ASYNC,e===Ee.SYNC&&this.runTask(Ve)}),C)]),this._frameTaskHandle=t.resourceController.scheduler.registerTask(Oe.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this.addHandles(_((()=>this.layer.featureReduction),(()=>this._deconflictor?.featureReductionChange()))),this.notifyChange("averageSymbolComplexity"),this.rendererChange(this.owner.renderer).catch((()=>{})),this._initializeAbortController=null}_abortInitialize(){this._initializeAbortController&&(this._initializeAbortController.abort(),this._initializeAbortController=null)}_updateFocusedLabels(){this.forEachGraphics3DSymbol(((e,t)=>{e.updateFocus((e=>{this.recreateGraphics([e.graphic])}),t)}))}destroy(){this._unusedSymbolsCache.destroy(),this._abortInitialize(),this._rendererChangeAbortController=o(this._rendererChangeAbortController),this._abortElevationInfoChange(),this._frameTaskHandle.remove(),this._frameTaskHandle=je,this._dataUpdateQueue.cancelAll(),this._updateQueue.cancelAll(),this._deconflictor=l(this._deconflictor),this._labeler=l(this._labeler),this._elevationAlignment=h(this._elevationAlignment),this._scaleVisibility=h(this._scaleVisibility),this._filterVisibility=h(this._filterVisibility),this._objectStates=h(this._objectStates),this.clear(),this._featureStore=h(this._featureStore),this._updatingPendingLoadedGraphicsChange=l(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=h(this._graphicStateTracking),this.stage&&(this.stageLayer=h(this.stageLayer),this.stage=null),this._set("owner",null);for(const e in this._whenGraphics3DGraphicRequests)this._whenGraphics3DGraphicRequests[e].reject(new r("graphic:layer-destroyed","Layer has been destroyed"));this._whenGraphics3DGraphicRequests=null,this._sharedSymbolResourcesOwnerHandle=l(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=h(this._propertiesPool),this._pendingUpdatesPool=null,this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=h(this._spatialIndex)}clear(){this._objectStates?.allGraphicsDeleted(),null!=this._graphicStateTracking&&this._graphicStateTracking.allGraphicsDeleted(),this.graphics3DGraphics.forEach((e=>e.destroy())),this._spatialIndex?.clear(),this.graphics3DGraphics.clear(),this._numberOfGraphics=0,this._usedMemory=0,this._updateLayerVisibility(),this._symbols.forEach(h),this._symbols.clear(),this._symbolMaterials=null,this._graphicsBySymbol.clear(),this._graphicsWithoutSymbol.clear(),this._graphicsWaitingForSymbol.clear(),this._pendingUpdates.clear(),this._pendingUpdatesPool.clear(),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1,this.notifyChange("dataUpdating"),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed")}_initializeStage(e,t){this.stage=e.stage,this.stageLayer=new Ue(this.stage,{visible:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},t);const i=this.stageLayer.events;i.on("transformationChanged",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),i.on("shaderTransformationChanged",(e=>this.notifyGraphicGeometryChanged(e.graphicUid))),i.on("visibilityChanged",(e=>this.notifyGraphicVisibilityChanged(e.graphicUid))),i.on("geometryAdded",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),i.on("geometryRemoved",(e=>this.notifyGraphicGeometryChanged(e.object.graphicUid))),i.on("attributesChanged",(e=>Ie(e.attribute)&&this.notifyGraphicGeometryChanged(e.object.graphicUid)))}notifyGraphicGeometryChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicGeometry(t)}notifyGraphicVisibilityChanged(e){if(null==this._graphicStateTracking||null==e)return;const t=this.graphics3DGraphics.get(e);t&&this._graphicStateTracking.updateGraphicVisibility(t)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,t=this._numberOfGraphics>e*qe,i=!this.suspendedOrOutsideOfView&&!t;i!==this._visible&&(this._visible=i,this._updateStageLayerVisibility())}_updateStageLayerVisibility(){const e=this._visible&&(null==this.layer.opacity||this.layer.opacity>=Me);this.stageLayer.visible!==e&&(this.stageLayer.visible=e,e?this.updateGraphicsVisibilities():this._hideAllGraphics())}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,t=this.owner.layer?.objectIdField){return N(e,t)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer?.objectIdField;if(!e)return;const t=new Map;return this.graphics3DGraphics.forEach((i=>{if(!i)return;const r=i.graphic,s=this._getGraphicObjectID(r,e);null!=s&&t.set(s,i)})),t}get labelsEnabled(){return!!this._labeler?.layerLabelsEnabled()}async updateLabelingInfo(e){const t=this._deconflictor?.labelingInfoChange(e),i=this._labeler?.labelingInfoChange(e);await Promise.allSettled([t,i])}updateVisibilityInfo(){this._deconflictor?.labelingInfoChange(),this._labeler?.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=!1,t=!1;for(const[i,r]of this._symbols)if(null!=r){switch(r.getFastUpdateStatus()){case Se.Loading:return"unknown";case Se.Fast:this._graphicsBySymbol.has(i)&&(t=!0);break;case Se.Slow:this._graphicsBySymbol.has(i)&&(e=!0);break;case Se.Mixed:this._graphicsBySymbol.has(i)&&(t=e=!0);case Se.Undefined:}}return t?e?"mixed":"fast":e?"slow":"mixed"}runTask(e){if(this._dataUpdateQueue.runTask(e),this._updateQueue.runTask(e),this._applyPendingUpdates(e),this.notifyChange("running"),this.running||this.notifyChange("dataUpdating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return Te}setObjectIdVisibility(e,t){t?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const i=this._findGraphics3DGraphicByObjectId(e);null!=i&&this._updateUserVisibility(i)}_findGraphics3DGraphicByObjectId(e){return n(this.graphics3DGraphics,(t=>this._getGraphicObjectID(t.graphic)===e))}_updateUserVisibility(e){if(null==e)return!1;const t=e.graphic,i=this._getGraphicObjectID(t),r=t.visible&&!this.owner.suspended&&this.stageLayer.visible&&(null==i||!this._objectIdInvisibleSet.has(i));return e.setVisibilityFlag(de.GRAPHIC,pe.USER,r)}_whenGraphics3DGraphic(e){const t=this.graphics3DGraphics.get(e.uid);if(t)return Promise.resolve(t);const i=this._whenGraphics3DGraphicRequests[e.uid];if(i)return i.promise;const r=g();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,t){const i=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,t,s)=>j(e,r,t,e,i,t,s),n=(e,t,r)=>j(e,s,t,e,i,t,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:null!=t&&!!t.useViewElevation,minDemResolution:null!=t?t.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,t?.signal);if(!l)return null;const h=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){T(h,ke);const t=e.getElevation(ke[0],ke[1],0,i,"ground")??0;h[2]=Math.min(h[2],t),h[5]=Math.max(h[5],t)}}return{boundingBox:h,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,t){await f((()=>this.owner?.loadedGraphics));const i=this.owner.layer?.objectIdField,s=this.owner.loadedGraphics.find((t=>t===e||null!=i&&null!=t.attributes&&e.attributes&&t.attributes[i]===e.attributes[i]));if(!s)throw new r("internal:graphic-not-part-of-view","Graphic is not part of this view");const a=await this._whenGraphics3DGraphic(s);return this._boundsForGraphics3DGraphic(a,t)}computeAttachmentOrigin(e,t){const i=this.graphics3DGraphics.get(e.uid);if(!i)return null;const r=i.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;R(Ye,0,0,0);let s=0;if(r.render.num>0){if(!O(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,Qe,t))return null;D(Ye,Ye,Qe),s++}if(r.draped.num>0){const[e,i]=r.draped.origin,a=this._viewElevationProvider.getElevation(e,i,"ground")??0;if(R(Qe,e,i,a),!O(Qe,this._viewElevationProvider.spatialReference,Qe,t))return null;D(Ye,Ye,Qe),s++}return s>1&&E(Ye,Ye,1/s),new A({x:Ye[0],y:Ye[1],z:Ye[2],spatialReference:t})}getSymbolLayerSize(e,t){const i=this._symbols.get(e.id);if(null==i)throw new r("internal:symbol-not-part-of-view","Symbol is not part of this view");const s=e.symbolLayers.indexOf(t);if(-1===s)throw new r("internal:missing-symbol-layer","Symbol layer is not in symbol");const a=i.getSymbolLayerSize(s);if(null==a)throw new r("internal:missing-size","Symbol layer has no valid size");return a}_graphicsCollectionChanged(e){this._startCreateGraphics&&(this.add(e.added),this.remove(e.removed))}graphicUpdateHandler(e){const t=e.graphic.uid,i=this.graphics3DGraphics.get(t);if(null!=i||null!=this._graphicsWithoutSymbol.get(t))switch(e.property){case"visible":this._graphicUpdateVisibleHandler(i);break;case"geometry":this._graphicUpdateGeometryHandler(i,e);break;case"symbol":this._graphicUpdateSymbolHandler(i,e);break;case"attributes":break;case"origin-transform":this._graphicUpdateTransformHandler(i,e)}}_graphicUpdateGeometryHandler(e,t){this._graphicUpdateGeometryOrTransformHandler(e,t,(()=>!(null==t.newValue||null==e||!e.graphics3DSymbol.updateGeometry(e,t.newValue)||!(this._labeler?.updateGraphicGeometry(e)??1))&&(this._labeler?.setDirty(),!0)));const i=t.graphic.geometry;null!=i&&this._expandComputedExtent(i)}_graphicUpdateTransformHandler(e,t){const i=t.graphic.geometry;this._graphicUpdateGeometryOrTransformHandler(e,t,(()=>null!=t.newValue&&null!=e&&null!=i&&e.graphics3DSymbol.updateTransform(e,i.spatialReference,t.newValue,t.action)))}_graphicUpdateGeometryOrTransformHandler(e,t,i){if(null!=t.graphic.geometry)if(null!=e)i()||this._recreateGraphic(e.graphic);else{const e=t.graphic.symbol?.id;if(e){const t=this._symbols.get(e);if(null!=t&&t.loadStatus===we.LOADING)return}this._recreateGraphic(t.graphic)}else this._recreateGraphic(t.graphic)}_graphicUpdateSymbolHandler(e,t){const i=t.graphic,r=null!=e?e.graphics3DSymbol:null!=t.oldValue?this._symbols.get(t.oldValue.id):null;if(null==r||null==t.newValue)return void this._recreateGraphic(i);const s=r.symbol,a=this._getConvertedSymbol(t.newValue);if(null!=a&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(i);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(i);const o=x(s,a);if(null==o)return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!P(l.diff))return void this._recreateGraphic(i);const h=this._getRenderingInfo(i);if(null==h)return void this._recreateGraphic(i);const d=r.extentPadding;for(const p of l.symbolStatePatches)p();if(d!==r.extentPadding&&this._recomputeExtentPadding(),null!=e)for(const p of l.graphics3DGraphicPatches)p(e,h);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,this.effectiveUpdatePolicy===Ee.SYNC&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const t=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,t),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("dataUpdating"),t}_endGraphicUpdate(e,t){e&&(t&&this._graphicStateTracking?.updateGraphicError(e,t),this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach((t=>{null!=t&&(e=Math.max(e,t.extentPadding))})),this._set("extentPadding",e)}_expandComputedExtent(e){const t=He,i=e.spatialReference;B(e,t);const r=this._viewSpatialReference,s=ze.tmpVec;if(H(i,r)||V(t[0],t[1],0,i,s,r)&&(t[0]=s[0],t[1]=s[1],V(t[3],t[4],0,i,s,r),t[3]=s[0],t[4]=s[1]),!(isFinite(t[0])&&isFinite(t[3])&&isFinite(t[1])&&isFinite(t[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(t[2])&&isFinite(t[5]),l=o&&(null==a?.zmin||t[2]<a.zmin),h=o&&(null==a?.zmax||t[5]>a.zmax);if(a){(t[0]<a.xmin||t[1]<a.ymin||t[3]>a.xmax||t[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(t[0],a.xmin),n.ymin=Math.min(t[1],a.ymin),n.xmax=Math.max(t[3],a.xmax),n.ymax=Math.max(t[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=t[0],n.ymin=t[1],n.xmax=t[3],n.ymax=t[4],n.spatialReference=r;n&&(l&&(n.zmin=t[2]),h&&(n.zmax=t[5]),this._set("computedExtent",n))}_abortElevationInfoChange(){this._elevationInfoChangeAbortController&&(this._elevationInfoChangeAbortController.abort(),this._elevationInfoChangeAbortController=null)}async elevationInfoChange(){this._abortElevationInfoChange();const e=new AbortController;this._elevationInfoChangeAbortController=e;const t=ce(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await ye(t,this._viewSpatialReference,e.signal,a.getLogger(this)),y(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("elevationInfo",t)?t?.forEach((e=>{const t=e.graphic,i=e.labelLayers;for(const r of i){r.graphics3DSymbolLayer.updateGraphicElevationContext(t,r)}})):this._recreateSymbol(i)})),this.updateStageLayerElevationProvider(),this._elevationAlignment?.elevationInfoChange()}updateStageLayerElevationProvider(){this._stageLayerElevationProvider?(this.layer.elevationInfo&&"relative-to-scene"===this.layer.elevationInfo.mode||0===this._numberOfGraphicsProvidingElevation)&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=d(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new Pe({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),null!=this._filterVisibility&&this._filterVisibility.clear(),this._labeler?.reset(),this._deconflictor?.clear(),this._elevationAlignment?.clear(),this.stageLayer?.invalidateSpatialQueryAccelerator(),this._stageLayerElevationProvider&&(this.owner.view.elevationProvider.unregister(this._stageLayerElevationProvider),this._stageLayerElevationProvider=d(this._stageLayerElevationProvider))}startCreateGraphics(){this._startCreateGraphics=!0,this.recreateAllGraphics()}recreateAllGraphics(){this._recreateAllGraphics(!1)}recreateAllGraphicsAndSymbols(){this._recreateAllGraphics(!0)}_recreateAllGraphics(e=!1){if(!this._startCreateGraphics)return;const{loadedGraphics:t,view:i}=this.owner,r=i.basemapTerrain.tilingScheme&&t?.length?t.toArray():null;!e&&r||this._clearSymbolsAndGraphics(),this.symbolCreationContext.screenSizePerspectiveEnabled=this.owner.view.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled,this.symbolCreationContext.slicePlaneEnabled=!!this.owner.slicePlaneEnabled,this._set("computedExtent",null),r&&(e?this.add(r):this.recreateGraphics(r))}_recreateSymbol(e){const t=this._graphicsBySymbol.get(e),i=[];t&&(t.forEach(((e,t)=>{const r=e.usedMemory;this._conditionalRemove(e,t),this._spatialIndex?.remove(e),i.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(t,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed")})),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);h(r),this._symbols.delete(e),this._symbolMaterials=null,h(this._unusedSymbolsCache.pop(e)),this.add(i)}_recreateGraphicsForSymbol(e){const t=this._graphicsBySymbol.get(e);if(t){const e=[];t.forEach((t=>e.push(t.graphic))),this.recreateGraphics(e)}}_conditionalRemove(e,t){this._graphicsDrapedUids.delete(t),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),null!=this._graphicStateTracking&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain?.tilingScheme?(this._updatePolicyForGraphics(e)===Ee.ASYNC?this._addDelayed(e):this._addImmediate(e),this.notifyChange("dataUpdating")):a.getLogger(this).error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(this.effectiveUpdatePolicy===Ee.SYNC&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const t of e)if(null!=t.geometry&&"mesh"===t.geometry.type&&!t.geometry.loaded)return Ee.ASYNC;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const t of e)this._addGraphic(t,this._getRenderingInfo(t,a.getLogger(this)),Ee.SYNC);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_addDelayed(e){for(const t of e){const e=t.uid;let i=this._pendingUpdates.get(e);i?i.add?i.state!==Ne.NEW&&i.abortController?.abort():this._pendingAdds++:(i=this._pendingUpdatesPool.pushNew(),this._pendingAdds++,this._pendingUpdates.set(e,i)),i.add=t}this.notifyChange("running"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}remove(e){this.effectiveUpdatePolicy===Ee.ASYNC?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("dataUpdating")}_removeImmediate(e){for(const t of e)this._removeGraphic(t);this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_removeDelayed(e){for(const t of e){const e=t.uid,i=this._pendingUpdates.get(e);if(i)i.add&&(i.remove?i.add=null:this._pendingUpdates.delete(e),i.state===Ne.LOADING&&i.abortController?.abort(),this._pendingAdds--);else{const i=this._pendingUpdatesPool.pushNew();i.remove=t,this._pendingUpdates.set(e,i),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this.notifyChange("dataUpdating")}_finishPendingUpdates(){this._pendingUpdatesPool.clear(),this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&a.getLogger(this).warn("pendingAdds/Removes in inconsistent state!"),this._pendingAdds=0,this._pendingRemoves=0,this._applyPendingRemovesFirst=!1}_applyPendingUpdates(e){if(this._geometryWarningLogged=!1,this._symbolWarningLogged=!1,0===this._pendingUpdates.size&&this._spatialIndex?.updating)return this._spatialIndex.update(),void e.madeProgress();if(this._applyPendingRemovesFirst){this._applyPendingRemovesFirst=!1;for(const[t,i]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(i.remove&&!i.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,this._pendingUpdates.delete(t),0===this._pendingRemoves))break}}for(const[t,i]of this._pendingUpdates){if(e.done)break;i.add&&i.state===Ne.NEW&&this._processPendingUpdateNew(i);let r=this.effectiveUpdatePolicy;if(!i.remove||i.add&&i.state!==Ne.READY||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(i.remove),i.remove=null,r=Ee.SYNC),i.add)switch(i.state){case Ne.READY:this._addGraphic(i.add,i.renderingInfo,r),i.add=null,this._pendingAdds--,e.madeProgress();break;case Ne.REJECTED:i.add=null,this._pendingAdds--;case Ne.LOADING:}null==i.remove&&null==i.add&&this._pendingUpdates.delete(t)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("dataUpdating"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=Ne.READY);const t=e.add.geometry;null==t||"mesh"!==t.type||t.loaded?this._processPendingUpdateNewRenderingInfo(e):this._processPendingUpdateNewMesh(e,t)}async _processPendingUpdateNewMesh(e,t){e.state=Ne.LOADING,e.abortController=new AbortController;const i=e.abortController.signal;try{await t.load({signal:i})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,t){e.abortController=null,u(t)?e.state=Ne.NEW:e.state=Ne.REJECTED}async _processPendingUpdateNewRenderingInfo(e){if(null==this.layer.renderer||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add,a.getLogger(this)),void(e.state=Ne.READY);e.state=Ne.LOADING,e.abortController=new AbortController;let t=null;try{t=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(i){return e.abortController=null,void(u(i)?e.state=Ne.NEW:e.state=Ne.REJECTED)}null==t?.symbol?(this._symbolWarningLogged||(this._symbolWarningLogged=!0,a.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=t,e.state=Ne.READY}_addGraphic(e,t,i){if(this._graphicsWithoutSymbol.set(e.uid,e),null==t?.symbol||!q(e))return;const r=this.stage.renderView.olidRenderHelper;if(r&&this.setUidToIdOnAdd){const t=K(this.owner.view,this.owner.layerViewUid);r.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.owner.layerViewUid,!!this.layer.popupEnabled&&!t&&Ae(this.layer,this.owner.view.popup?.defaultPopupTemplateEnabled))}const s=t.symbol,a=this.getOrCreateGraphics3DSymbol(s,t.renderer);if(null==a)return;this._expandComputedExtent(e.geometry);const n=this._beginGraphicUpdate(e),o=new ue(e,t,this.layer);let l=!1;const h=e=>{e===a.symbol.id&&(l=!0)};this._whenSymbolRemoved.push(h);const d=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(h);if(this._graphicsWaitingForSymbol.get(e.uid)!==n||l||a.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==a.symbol.id)--a.referenced,this._cleanupSymbols();else{const t=this._createGraphics3DGraphic(a,o);this._spatialIndex&&null!=t&&this._spatialIndex.add(t),--a.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this._labeler?.setDirty()},p=t=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(h),l||(u(t)?this.add([e]):a.destroyed||this._endGraphicUpdate(e,t)))};++this._loadingSymbols,i===Ee.ASYNC?a.load((()=>this._dataUpdateQueue.push(d,null).catch(m)),(e=>this._dataUpdateQueue.push((()=>p(e)),null).catch(m))):a.load(d,p)}_removeGraphic(e){const t=e.uid,i=this.graphics3DGraphics.get(t);if(i){i.graphics3DSymbol.onRemoveGraphic(i);const e=i.usedMemory,r=i.isElevationSource;this._conditionalRemove(i,t),this._spatialIndex?.remove(i);const s=i.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(t),this._graphicsWithoutSymbol.delete(t),this._removeGraphics3DGraphic(t,e,r),i.destroy(),this._featureStore.events.emit("changed")}else this._graphicsWithoutSymbol.delete(t),this._graphicsWaitingForSymbol.delete(t),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("dataUpdating"))}_hasLabelingContext(e){if(e instanceof te||e instanceof ie){const t=this.symbolCreationContext.layer;return!!t.labelingInfo&&t.labelingInfo.some((t=>t.symbol===e))}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof te&&!this._hasLabelingContext(e))||(a.getLogger(this).error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,t){const i=e.geometry;if(null==i)return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!L(i.spatialReference,this._viewSpatialReference))return t&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?Y(e,this.layer):e;let s;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||null!=this.currentRenderer))s=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{const e=r.symbol||se(r.geometry);s=new X(null,e)}return null==s?.symbol?(t&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,t.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):s}_getRenderingInfoAsync(e,t){if(null==e.geometry)return this._geometryWarningLogged||(this._geometryWarningLogged=!0,a.getLogger(this).warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&null!=e.symbol)return this._symbolWarningLogged||(this._symbolWarningLogged=!0,a.getLogger(this).warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const i=this.rendererHasGeometryOperations?Y(e,this.layer):e;return this.owner.getRenderingInfoAsync(i,this.currentRenderer,this._arcadeOnDemand,t)}_createGraphics3DSymbol(e,t){if(!this._hasValidSymbolCreationContext(e))return null;const i=this._getConvertedSymbol(e);if(!i)return null;let r;if(null!=t&&"backgroundFillSymbol"in t&&t.backgroundFillSymbol){const e=ae(t.backgroundFillSymbol,{ignoreDrivers:!0});null!=e.symbol&&(r=e.symbol.symbolLayers)}const s=be(i,this.symbolCreationContext,r);return s.load((()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")}),(()=>{})),s}getOrCreateGraphics3DSymbol(e,t){let i=this._symbols.get(e.id);if(void 0===i){const r=this._unusedSymbolsCache.pop(e.id);i=null!=r?r:e instanceof re?new _e(e,(e=>this._dataUpdateQueue.push(e,null)),(e=>this._createGraphics3DSymbol(e,t))):this._createGraphics3DSymbol(e,t),this._symbols.set(e.id,i),this._symbolMaterials=null}return null!=i&&++i.referenced,i}trackGraphicState(e){return null==this._graphicStateTracking&&(this._graphicStateTracking=new ve(this)),this._graphicStateTracking.add(e)}_addGraphics3DGraphic(e){this._usedMemory+=e.usedMemory,this.graphics3DGraphics.set(e.graphic.uid,e),this._numberOfGraphics++,e.isElevationSource&&(this._numberOfGraphicsProvidingElevation++,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_removeGraphics3DGraphic(e,t,i=!1){this._usedMemory-=t,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,i&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,t){const i=t.graphic;if(this._graphicsWithoutSymbol.delete(i.uid),!this._symbols.has(e.symbol.id))return this.add([i]),null;if(this.graphics3DGraphics.has(i.uid))return null;const r=e.createGraphics3DGraphic(t);if(null==r)return null;this._addGraphics3DGraphic(r);const s=e.symbol.id;this._graphicsBySymbol.has(s)||this._graphicsBySymbol.set(s,new Map),this._graphicsBySymbol.get(s).set(i.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(i.uid),r.centroid=null,null!=i.geometry&&"point"!==i.geometry.type&&(r.centroid=Ce(i.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(r),null!=this._filterVisibility){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(de.GRAPHIC,pe.FILTER,e),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),r.initialize(this.stageLayer),null!=this._graphicStateTracking&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[i.uid];return a&&(delete this._whenGraphics3DGraphicRequests[i.uid],a.resolve(r)),this._symbolMaterials=null,r}async rendererChange(e){if(this._rendererChangeAbortController=o(this._rendererChangeAbortController),e!==this.currentRenderer)if(this._validateRenderer(e),null==e&&this._currentRendererChange(null,!1),Z(e))if(e?.arcadeRequired){const t=new AbortController;this._rendererChangeAbortController=t;const{arcadeUtils:i}=await this._ensureArcade();y(t);const r=i.hasGeometryOperations(e);r&&(await i.enableGeometryOperations(),y(t)),this.effectiveUpdatePolicy===Ee.ASYNC?await this._updateQueue.push((()=>this._currentRendererChange(e,r)),t.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(this.effectiveUpdatePolicy===Ee.ASYNC){const t=new AbortController;this._rendererChangeAbortController=t,await this._updateQueue.push((()=>this._currentRendererChange(e,!1)),t.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return null==this._arcadeOnDemand?(this._arcadeOnDemand=await ee(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,t){this.currentRenderer=e,this.rendererHasGeometryOperations=t,this.symbolCreationContext.arcade=this._arcadeOnDemand;const i=this.symbolCreationContext.renderer;if(e===i)return;if(this._symbolConversionCache.clear(),this._unusedSymbolsCache.clear(),null==e)return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=x(i,e);this._updateUnchangedSymbolMappings(r,e,i),this.symbolCreationContext.renderer=e,null!=r&&("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,i)?this._labeler?.reset():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const t in e.diff)switch(t){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[t];break;default:return!0}return!1}_applySymbolSetDiff(e,t,i){e=e||[],t=t||[];const r=[];for(const s of t){const t=this._graphicsBySymbol.get(s.id);t&&t.forEach(((a,n)=>{const o=a.graphic,l=this.layer instanceof W?this.layer:null,h=this._arcadeOnDemand;if(s===i.defaultSymbol&&i.getSymbol(Y(o,l),{arcade:h})===i.defaultSymbol)return;const d=a.usedMemory;e.length||i.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),t.delete(n),this._removeGraphics3DGraphic(n,d),this._updateLayerVisibility()})),this._whenSymbolRemoved.forAll((e=>e(s.id)))}(e.length||r.length)&&(this._graphicsWithoutSymbol.forEach((e=>r.push(e))),this._graphicsWithoutSymbol.clear(),this.add(r)),this._cleanupSymbols(),this._labeler?.setDirty(),this._deconflictor?.setDirty()}_applyUniqueValueRendererDiff(e,t,r){const s=e.diff.defaultSymbol,a=e.diff.uniqueValueInfos;if(s||a){const n=a?a.added.map((e=>e.symbol)).filter(i):[],o=a?a.removed.map((e=>e.symbol)).filter(i):[];if(a)for(let e=0;e<a.changed.length;e++)n.push(a.changed[e].newValue.symbol),o.push(a.changed[e].oldValue.symbol);return s?(r.defaultSymbol&&o.push(r.defaultSymbol),t.defaultSymbol&&n.push(t.defaultSymbol)):r.defaultSymbol&&n.length&&o.push(t.defaultSymbol),this._applySymbolSetDiff(n,o,t),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,t,i){if("unique-value"!==t?.type||"unique-value"!==i?.type||null!=e&&"partial"!==e.type)return[];const r=e=>null!=e?e.id:null,s=e&&e.diff,a=s?.defaultSymbol,n=s&&s.uniqueValueInfos;let o;if(n)o=n.unchanged.map((e=>({oldId:r(e.oldValue.symbol),newId:r(e.newValue.symbol)})));else{o=[];for(const e of i.uniqueValueInfos??[]){const i=r(e.symbol),s=t.uniqueValueInfos?.find((t=>t.value===e.value));s&&i!==r(s.symbol)&&o.push({oldId:i,newId:r(s.symbol)})}}return!a&&i.defaultSymbol&&o.push({oldId:r(i.defaultSymbol),newId:r(t.defaultSymbol)}),o}_updateSymbolMapping(e,t){const i=null!=t&&t?"string"==typeof t?t:t.id:null;if(null==e||e===i)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(i,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(i,s),this._symbolMaterials=null,null!=s)){const e="string"==typeof t?null:t;null!=e?s.symbol=e:s.symbol.id=i}}_updateUnchangedSymbolMappings(e,t,i){const r=this._calculateUnchangedSymbolMapping(e,t,i);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,t,i){if(this._diffHasSymbolChange(e))return!1;if(t instanceof $&&i instanceof $&&this._applyUniqueValueRendererDiff(e,t,i)&&0===Object.keys(e.diff).length)return!0;for(const r of this._graphicsBySymbol.keys()){const i=this._symbols.get(r);if(null!=i)switch(i.applyRendererDiff(e,t)){case Ge.RecreateSymbol:this._recreateSymbol(r);break;case Ge.RecreateGraphics:this._recreateGraphicsForSymbol(r);case Ge.FastUpdate:}}return!0}opacityChange(){this._updateStageLayerVisibility(),this.forEachGraphics3DSymbol(((e,t)=>e.globalPropertyChanged("opacity",t)))}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol(((e,t)=>e.globalPropertyChanged("slicePlaneEnabled",t))),this._deconflictor?.slicePlaneEnabledChange(),this._labeler?.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",t)||this._recreateSymbol(i)}))}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("skipHighSymbolLods",t)||this._recreateSymbol(i)}))}_pixelRatioChange(){this.forEachGraphics3DSymbol(((e,t,i)=>{e.globalPropertyChanged("pixelRatio",t)||this._recreateSymbol(i)}))}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=S((()=>{this._updatingPendingLoadedGraphicsChange=null}))}setClippingExtent(e,t){const i=this.symbolCreationContext.clippingExtent,r=k();return Re(e,r,t)?this.symbolCreationContext.clippingExtent=M(F(),r):this.symbolCreationContext.clippingExtent=null,!z(this.symbolCreationContext.clippingExtent,i)}modifyGraphics3DGraphicVisibilities(e){if(this.destroyed)return;let t=!1;this.graphics3DGraphics.forEach((i=>{e(i)&&(t=!0)})),t&&(this._labeler?.setDirty(),this._deconflictor?.setDirty())}forEachGraphics3DSymbol(e,t){for(const[i,r]of this._symbols){if(null==r)return;e(r,this._graphicsBySymbol.get(i)||$e,i)}if(!t?.excludeUnused)for(const i of this._unusedSymbolsCache)e(i,void 0,i.symbol.id)}updateGraphicsVisibilities(){null!=this._filterVisibility&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities((e=>{const t=this._updateUserVisibility(e),i=null!=this._scaleVisibility&&this._scaleVisibility.updateVisibility(e);return t||i}))}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(de.GRAPHIC,pe.USER,!1)))}_validateRenderer(e){const t=()=>`'${this.layer.title?`${this.layer.title}, `:""}id:${this.layer.id}'`,i=J(e,{geometryType:this.layer?.geometryType,logWarning:(e,i)=>a.getLogger(this).warn(e,`Symbology conversion for layer ${t()}: ${i}`)});if(i){const e=`Renderer for layer ${t} is not supported in a SceneView`;a.getLogger(this).warn(e,i.message)}}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach(((t,i)=>{if(null==t||t.referenced>0)return;const r=this._graphicsBySymbol.get(i);r&&0!==r.size||(this._graphicsBySymbol.delete(i),this._symbols.delete(i),this._symbolMaterials=null,this._unusedSymbolsCache.put(i,t,p),e=!0)})),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){}get performanceInfo(){return new fe(this.graphics3DGraphics.size,Array.from(this.graphics3DGraphics.values()).reduce(((e,t)=>e+(t.isVisible()?1:0)),0),this._graphicsWithoutSymbol.size,this._pendingUpdates.size)}};var Ne;e([G({readOnly:!0})],We.prototype,"computedExtent",void 0),e([G()],We.prototype,"currentRenderer",void 0),e([G()],We.prototype,"rendererHasGeometryOperations",void 0),e([G()],We.prototype,"_frameTaskHandle",void 0),e([G()],We.prototype,"_dataUpdateQueue",void 0),e([G()],We.prototype,"_updateQueue",void 0),e([G({readOnly:!0})],We.prototype,"_viewSpatialReference",null),e([G()],We.prototype,"_rendererChangeAbortController",void 0),e([G()],We.prototype,"_elevationInfoChangeAbortController",void 0),e([G()],We.prototype,"_initializeAbortController",void 0),e([G()],We.prototype,"_elevationAlignment",void 0),e([G()],We.prototype,"_scaleVisibility",void 0),e([G()],We.prototype,"_filterVisibility",void 0),e([G()],We.prototype,"_initializePromise",void 0),e([G()],We.prototype,"_spatialIndex",void 0),e([G({readOnly:!0})],We.prototype,"extentPadding",void 0),e([G()],We.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([G()],We.prototype,"_featureStore",void 0),e([G()],We.prototype,"_objectStates",void 0),e([G()],We.prototype,"_loadingSymbols",void 0),e([G({constructOnly:!0})],We.prototype,"compressionHandle",void 0),e([G()],We.prototype,"preferredUpdatePolicy",void 0),e([G()],We.prototype,"_forcedUpdatePolicy",void 0),e([G({readOnly:!0})],We.prototype,"effectiveUpdatePolicy",null),e([G({constructOnly:!0})],We.prototype,"elevationFeatureExpressionEnabled",void 0),e([G({constructOnly:!0})],We.prototype,"owner",void 0),e([G({constructOnly:!0})],We.prototype,"layer",void 0),e([G({constructOnly:!0})],We.prototype,"graphicSymbolSupported",void 0),e([G({constructOnly:!0})],We.prototype,"getRenderingInfoWithoutRenderer",void 0),e([G({constructOnly:!0})],We.prototype,"componentFactories",void 0),e([G({constructOnly:!0})],We.prototype,"setUidToIdOnAdd",void 0),e([G()],We.prototype,"featureStore",null),e([G()],We.prototype,"initializePromise",null),e([G()],We.prototype,"scaleVisibility",null),e([G()],We.prototype,"elevationAlignment",null),e([G()],We.prototype,"objectStates",null),e([G()],We.prototype,"filterVisibility",null),e([G({readOnly:!0})],We.prototype,"updating",null),e([G({readOnly:!0})],We.prototype,"dataUpdating",null),e([G({readOnly:!0})],We.prototype,"running",null),e([G({readOnly:!0})],We.prototype,"suspendedOrOutsideOfView",null),e([G({readOnly:!0,dependsOn:[]})],We.prototype,"updatingRemaining",null),e([G({readOnly:!0})],We.prototype,"displayFeatureLimit",null),e([G({readOnly:!0,dependsOn:[]})],We.prototype,"averageSymbolComplexity",null),e([G({constructOnly:!0})],We.prototype,"hasZ",void 0),e([G({constructOnly:!0})],We.prototype,"hasM",void 0),e([G()],We.prototype,"_objectIdField",null),We=ze=e([w("esri.views.3d.layers.graphics.Graphics3DCore")],We),function(e){e[e.NEW=0]="NEW",e[e.LOADING=1]="LOADING",e[e.READY=2]="READY",e[e.REJECTED=3]="REJECTED"}(Ne||(Ne={}));class Be{constructor(){this.add=null,this.renderingInfo=null,this.state=Ne.NEW,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=Ne.NEW,this.abortController=null,this.remove=null}}const qe=10,Ye=I(),Qe=I(),$e=new Map;export{We as Graphics3DCore};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../../Color.js";import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as r}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as o}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as a,invertOrIdentity as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{c as m,n as p,i as h,d as g,e as d,t as u,a as f}from"../../../../chunks/vec32.js";import{fromArray as y,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as _}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as S,fromBuffer as j,intersectsClippingArea as P}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as w}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as O,getZeroIndexArray as C}from"../../../../geometry/support/Indices.js";import{t as E}from"../../../../chunks/vec3.js";import{makeVertexCandidate as v,makeEdgeCandidate as I}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as A}from"../../../../renderers/support/renderingInfoUtils.js";import{EmissiveSourceMode as M}from"../../../../symbols/support/materialUtils.js";import{ViewingMode as L}from"../../../ViewingMode.js";import{needsElevationUpdates3D as B,SampleElevationInfo as z}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as R,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G,computeCentroid as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as T}from"./interfaces.js";import{geometryAsPolygon as N}from"./polygonUtils.js";import{createMaterial as F}from"../support/edgeUtils.js";import{debugFlags as k}from"../../support/debugFlags.js";import{SamplePosition as H}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as W}from"../../support/renderInfoUtils/polygon.js";import{NormalType as q}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as Z}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as J}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as K}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as Q}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as X,compressNormal as Y}from"../../webgl-engine/lib/Normals.js";import{Object3D as $}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as tt}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as et}from"../../webgl-engine/materials/DefaultMaterial.js";import{GeometryType as rt}from"../../webgl-engine/lib/IntersectableGeometry.js";const ot=["polygon","extent"];class st extends D{constructor(t,e,r,o){super(t,e,r,o,xt(e)),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=G(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=this.symbolLayer,r=t?.material,o=r?.color,s=this._getCombinedOpacityAndColor(o),i=y(s),n=s[3],a=this.needsDrivenTransparentPass,l=r?.emissive,c={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:i,ambient:i,opacity:n,drivenOpacity:a,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:t.castShadows,emissiveStrength:l?.strength??0,emissiveSource:M.Color,offsetTransparentBackfaces:!0,normalType:q.Compressed},m=new et(c,this._context);m.setParameters({cullFace:m.transparent?J.None:J.Back});const p=new et({...c,cullFace:J.Back},this._context);this._materials[Mt.Main]=m,this._materials[Mt.Bottom]=p}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,ot,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(t.renderingInfo,this._getFallbackOpacityAndColor(),255),o=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,o,e.uid)}layerOpacityChanged(t,e){const r=this.symbolLayer?.material?.color,o=this._getCombinedOpacity(r);this._materials[Mt.Main]?.setParameters({opacity:o}),this._materials[Mt.Bottom]?.setParameters({opacity:o});const s=this._getLayerOpacity();t.forEach((t=>e(t)?.layerOpacityChanged(s,this._context.isAsync)))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,B)}slicePlaneEnabledChanged(t,e){return this._materials[Mt.Main]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[Mt.Bottom]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t.forEach((t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[Mt.Main]?.setParameters(t),this._materials[Mt.Bottom]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?A(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?T.RecreateSymbol:T.RecreateGraphics}async queryForSnapping(t,e,s,i){const n=this._getExtrusionSize(s)*this._context.renderCoordsHelper.unitInMeters/o(e),{objectId:a,target:l}=t,c=r(l);switch(c.z=(c.z??0)+n,t.type){case"edge":{const{start:e,end:o}=t,s=r(e),i=r(o);return s.z=(s.z??0)+n,i.z=(i.z??0)+n,[I(a,c,1/0,s,i)]}case"vertex":return[v(a,c,1/0),I(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,o,l){const m=N(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=W(m,this._context.elevationProvider,this._context.renderCoordsHelper,o);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=V(m);if(null==h)return null;const g=new Array,d=new Array,u=S(),f=c(),y=b(),_=this._context.renderCoordsHelper.viewingMode===L.Global;_||this._context.renderCoordsHelper.worldUpAtPosition(null,y),x(m.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const C=c();a(C,f);const v=n();i(v,C);const{polygons:I,mapPositions:A,position:M}=p,z=new Map,D=this._materials[Mt.Main];for(const i of I){const t=i.count;if(this._context.clippingExtent&&(j(i.mapPositions,u),!P(u,this._context.clippingExtent)))continue;const o=s(i.mapPositions,i.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,c=O(a+n),m=O(n),p=w(3*a),h=w(3*a),b=w(3*a),x=w(a);nt(M,A,o,i,p,b,h,x,c,m,this._getExtrusionSize(e),y,_),E(p,p,C);const S=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerViewUid:this._context.layerViewUid}),v=new Lt(p,b,X(h),x),I=it(D,c,c.length-m.length,v,r,S),L=t,B=t,R=2*i.count,U=new Bt(L,B,R,n/3);_t(I,U,f),z.set(I,U),g.push(I,it(this._materials[Mt.Bottom],m,0,v,r,S)),d.push(v.heights)}if(0===g.length)return null;const G=new $({geometries:g,layerViewUid:this._context.layerViewUid,graphicUid:l,isElevationSource:!0});G.transformation=f;const T=F(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=T?new R(this._materials[Mt.Main],T,this._context.slicePlaneEnabled):null,H=new U(this,G,null,((t,e,r,o,s)=>bt(t,e,r,o,s,d,z)),o,k);return H.alignedSampledElevation=p.sampledElevation,H.needsElevationUpdates=B(o.mode),H}_getFallbackOpacityAndColor(){const e=this.symbolLayer?.material?.color;return t.toUnitRGBA(e)??_}}function it(t,e,r,o,s,i){const n=C(e.length),a=[[tt.POSITION,new Z(o.positions,e,3,!0)],[tt.NORMALCOMPRESSED,new Z(o.normals,e,2,!0)],[tt.COLOR,new Z(s,n,4,!0)]];return new K(t,a,o.elevation,rt.Mesh,i,r)}function nt(t,e,r,o,s,i,n,a,l,c,m,p,h){{const g=r.length/3,d=2*o.count;at(t,e,o.index,o.count,r,0,g,s,i,n,a,l,c,d,m,p,h)}{let t=0,e=2*o.count,r=0;const c=o.pathLengths[0];mt(s,i,a,n,t,c,o.count,e,l,r,m),e+=4*c,r+=2*c,t+=c;for(let p=1;p<o.pathLengths.length;++p){const c=o.pathLengths[p];mt(s,i,a,n,t,c,o.count,e,l,r,m),e+=4*c,r+=2*c,t+=c}}}function at(t,e,r,o,s,i,n,a,l,c,h,g,d,u,f,y,b){m(jt,y);{const s=f>0?1:-1;let i=3*r,n=0,m=3*n,g=o,d=3*g;for(let r=0;r<o;++r){const r=t[i],o=t[i+1],u=t[i+2];b&&(jt[0]=r,jt[1]=o,jt[2]=u,p(jt,jt)),a[m+0]=r,a[m+1]=o,a[m+2]=u;const y=e[i+0],_=e[i+1],x=e[i+2];l[m+0]=y,l[m+1]=_,l[m+2]=x,c[m+0]=-s*jt[0],c[m+1]=-s*jt[1],c[m+2]=-s*jt[2],h[n]=0,a[d+0]=r+f*jt[0],a[d+1]=o+f*jt[1],a[d+2]=u+f*jt[2],l[d+0]=y,l[d+1]=_,l[d+2]=x,h[g]=f,m+=3,d+=3,i+=3,n+=1,g+=1}}{let t=3*i,e=0,r=3*u;const a=f<0?Ot:wt,l=f<0?wt:Ot;for(let i=0;i<n;++i)d[e]=s[t+a[0]],d[e+1]=s[t+a[1]],d[e+2]=s[t+a[2]],g[r]=s[t+l[0]]+o,g[r+1]=s[t+l[1]]+o,g[r+2]=s[t+l[2]]+o,e+=3,r+=3,t+=3}}function lt(t,e,r,o,s,i,n){o[i]=o[n],n*=3,t[i*=3]=t[n],t[i+1]=t[n+1],t[i+2]=t[n+2],e[i]=e[n],e[i+1]=e[n+1],e[i+2]=e[n+2],r[i]=s[0],r[i+1]=s[1],r[i+2]=s[2]}const ct=b();function mt(t,e,r,o,s,i,n,a,l,c,m){let p=s,h=s+1,g=s+n,d=s+n+1,u=a,f=a+1,y=a+2*i,b=a+2*i+1;m<0&&(p=s+n+1,d=s);let _=3*c;for(let x=0;x<i;++x)x===i-1&&(h=s,m>0?d=s+n:p=s+n),ft(t,p,h,g,ct),lt(t,e,o,r,ct,u,p),lt(t,e,o,r,ct,f,h),lt(t,e,o,r,ct,y,g),lt(t,e,o,r,ct,b,d),l[_]=u,l[_+1]=y,l[_+2]=b,l[_+3]=u,l[_+4]=b,l[_+5]=f,_+=6,p++,h++,g++,d++,u+=2,f+=2,y+=2,b+=2}const pt=b(),ht=b(),gt=b(),dt=b(),ut=b();function ft(t,e,r,o,s){e*=3,r*=3,o*=3,h(pt,t[e++],t[e++],t[e++]),h(ht,t[r++],t[r++],t[r++]),h(gt,t[o++],t[o++],t[o++]),g(dt,ht,pt),g(ut,gt,pt),d(s,ut,dt),p(s,s)}const yt=b();function bt(t,e,r,o,s,i,n){const a=t.stageObject,m=a.geometries,p=m.length,g="absolute-height"!==e.mode;let d=0;const f=a.transformation,y=l(c(),f);for(let l=0;l<p;l+=2){const t=m[l];if(!Q(t))continue;const e=t.getMutableAttribute(tt.POSITION).data,c=i[l/2],p=new H(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let i=0;i<b;i++){yt[0]=e[t],yt[1]=e[t+1],yt[2]=e[t+2],o(p,Pt),g&&(x+=Pt.sampledElevation),k.TESTS_DISABLE_OPTIMIZATIONS?(h(St,p.array[p.offset],p.array[p.offset+1],Pt.z+c[t/3]),null!=r&&s.toRenderCoords(St,r,St),u(St,St,y)):(h(St,e[t],e[t+1],e[t+2]),u(St,St,f),s.setAltitude(St,Pt.z+c[t/3]),u(St,St,y)),e[t]=St[0],e[t+1]=St[1],e[t+2]=St[2];const i=Ct/s.unitInMeters;(Math.abs(yt[0]-e[t])>=i||Math.abs(yt[1]-e[t+1])>=i||Math.abs(yt[2]-e[t+2])>=i)&&(_=!0),p.offset+=3,t+=3}}if(_){const e=n.get(t);e&&_t(t,e,f),a.geometryVertexAttributeUpdated(m[l],tt.NORMALCOMPRESSED),t.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(m[l],tt.POSITION),m[l+1].invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(m[l+1],tt.POSITION)}d+=x/b}return d/p}function _t(t,e,r){const o=t.getMutableAttribute(tt.POSITION),s=t.getMutableAttribute(tt.NORMALCOMPRESSED).data,{topVertexStart:i,topVertexCount:n,topFaceStart:a,topFaceCount:l}=e,c=o.data,m=n,g=t.attributes.get(tt.POSITION).indices,y=a+l,b=i+n,_=w(3*m);for(let p=0;p<m;++p){const t=3*p;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=Et,S=vt,j=It,P=At,O=jt;for(let w=a;w<y;++w){const t=3*w;for(let e=0;e<3;++e){const o=g[t+e];P[e]=o;const s=3*o;h(St,c[s+0],c[s+1],c[s+2]),u(x[e],St,r)}f(S,x[1],x[0]),f(j,x[2],x[0]),d(O,S,j),p(O,O);for(let e=0;e<3;++e){const t=3*(P[e]-i);_[t+0]+=O[0],_[t+1]+=O[1],_[t+2]+=O[2]}}for(let p=i;p<b;++p){const t=3*(p-i),e=_[t+0],r=_[t+1],o=_[t+2],n=Math.sqrt(e*e+r*r+o*o);Y(s,p,e/n,r/n,o/n)}}function xt(t){return 1===(t.material?.color?.a??1)}const St=b(),jt=b(),Pt=new z,wt=[0,2,1],Ot=[0,1,2],Ct=.01,Et=[b(),b(),b()],vt=b(),It=b(),At=[0,0,0];var Mt;!function(t){t[t.Main=0]="Main",t[t.Bottom=1]="Bottom"}(Mt||(Mt={}));class Lt{constructor(t,e,r,o){this.positions=t,this.elevation=e,this.normals=r,this.heights=o}}class Bt{constructor(t,e,r,o){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=o}}export{st as Graphics3DExtrudeSymbolLayer,nt as extrudePolygon};
5
+ import t from"../../../../Color.js";import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as r}from"../../../../core/lang.js";import{getMetersPerVerticalUnitForSR as o}from"../../../../core/unitUtils.js";import{e as s}from"../../../../chunks/earcut.js";import{normalFromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as a,invertOrIdentity as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{c as m,n as p,i as h,d as g,e as d,t as u,a as f}from"../../../../chunks/vec32.js";import{fromArray as y,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as _}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as S,fromBuffer as j,intersectsClippingArea as P}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as w}from"../../../../geometry/support/DoubleArray.js";import{newIndexArray as O,getZeroIndexArray as C}from"../../../../geometry/support/Indices.js";import{t as E}from"../../../../chunks/vec3.js";import{makeVertexCandidate as v,makeEdgeCandidate as I}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as A}from"../../../../renderers/support/renderingInfoUtils.js";import{EmissiveSourceMode as M}from"../../../../symbols/support/materialUtils.js";import{ViewingMode as L}from"../../../ViewingMode.js";import{needsElevationUpdates3D as B,SampleElevationInfo as z}from"./elevationAlignmentUtils.js";import{Object3DEdgeState as R,Graphics3DObject3DGraphicLayer as U}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as G,computeCentroid as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as T}from"./interfaces.js";import{geometryAsPolygon as N}from"./polygonUtils.js";import{createMaterial as F}from"../support/edgeUtils.js";import{debugFlags as k}from"../../support/debugFlags.js";import{SamplePosition as H}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as W}from"../../support/renderInfoUtils/polygon.js";import{NormalType as q}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as Z}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as J}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as K}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as Q}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as X,compressNormal as Y}from"../../webgl-engine/lib/Normals.js";import{Object3D as $}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as tt}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as et}from"../../webgl-engine/materials/DefaultMaterial.js";import{GeometryType as rt}from"../../webgl-engine/lib/IntersectableGeometry.js";const ot=["polygon","extent"];class st extends D{constructor(t,e,r,o){super(t,e,r,o,xt(e)),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=G(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=this.symbolLayer,r=t?.material,o=r?.color,s=this._getCombinedOpacityAndColor(o),i=y(s),n=s[3],a=this.needsDrivenTransparentPass,l=r?.emissive,c={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:i,ambient:i,opacity:n,drivenOpacity:a,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:t.castShadows,emissiveStrength:l?.strength??0,emissiveSource:M.Color,offsetTransparentBackfaces:!0,normalType:q.Compressed},m=new et(c,this._context);m.setParameters({cullFace:m.transparent?J.None:J.Back});const p=new et({...c,cullFace:J.Back},this._context);this._materials[Mt.Main]=m,this._materials[Mt.Bottom]=p}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(t){const e=t.graphic;if(!this._validateGeometry(e.geometry,ot,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(t.renderingInfo,this._getFallbackOpacityAndColor(),255),o=this.setGraphicElevationContext(e);return this._createAs3DShape(e,t.renderingInfo,r,o,e.uid)}layerOpacityChanged(t,e){const r=this.symbolLayer?.material?.color,o=this._getCombinedOpacity(r);this._materials[Mt.Main]?.setParameters({opacity:o}),this._materials[Mt.Bottom]?.setParameters({opacity:o});const s=this._getLayerOpacity();t?.forEach((t=>e(t)?.layerOpacityChanged(s,this._context.isAsync)))}layerElevationInfoChanged(t,e){return this.updateGraphics3DGraphicElevationInfo(t,e,B)}slicePlaneEnabledChanged(t,e){return this._materials[Mt.Main]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[Mt.Bottom]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),t?.forEach((t=>{const r=e(t);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const t={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0};return this._materials[Mt.Main]?.setParameters(t),this._materials[Mt.Bottom]?.setParameters(t),!0}_getExtrusionSize(t){let e;return e=t.size&&this._drivenProperties.size?A(t.size,2)??0:this._getSymbolSize(),e/=this._context.renderCoordsHelper.unitInMeters,e}applyRendererDiff(t,e){return this._drivenPropertiesChanged(e)?T.RecreateSymbol:T.RecreateGraphics}async queryForSnapping(t,e,s,i){const n=this._getExtrusionSize(s)*this._context.renderCoordsHelper.unitInMeters/o(e),{objectId:a,target:l}=t,c=r(l);switch(c.z=(c.z??0)+n,t.type){case"edge":{const{start:e,end:o}=t,s=r(e),i=r(o);return s.z=(s.z??0)+n,i.z=(i.z??0)+n,[I(a,c,1/0,s,i)]}case"vertex":return[v(a,c,1/0),I(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(t,e,r,o,l){const m=N(t.geometry);if(null==m)return null;if(0===m.rings.length||!m.rings.some((t=>t.length>0)))return this._logGeometryValidationWarnings(m.rings,"rings","ExtrudeSymbol3DLayer"),null;const p=W(m,this._context.elevationProvider,this._context.renderCoordsHelper,o);this._logGeometryCreationWarnings(p,m.rings,"rings","ExtrudeSymbol3DLayer");const h=V(m);if(null==h)return null;const g=new Array,d=new Array,u=S(),f=c(),y=b(),_=this._context.renderCoordsHelper.viewingMode===L.Global;_||this._context.renderCoordsHelper.worldUpAtPosition(null,y),x(m.spatialReference,[h.x,h.y,0],f,this._context.renderCoordsHelper.spatialReference);const C=c();a(C,f);const v=n();i(v,C);const{polygons:I,mapPositions:A,position:M}=p,z=new Map,D=this._materials[Mt.Main];for(const i of I){const t=i.count;if(this._context.clippingExtent&&(j(i.mapPositions,u),!P(u,this._context.clippingExtent)))continue;const o=s(i.mapPositions,i.holeIndices,3);if(0===o.length)continue;const n=o.length,a=6*t,c=O(a+n),m=O(n),p=w(3*a),h=w(3*a),b=w(3*a),x=w(a);nt(M,A,o,i,p,b,h,x,c,m,this._getExtrusionSize(e),y,_),E(p,p,C);const S=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerViewUid:this._context.layerViewUid}),v=new Lt(p,b,X(h),x),I=it(D,c,c.length-m.length,v,r,S),L=t,B=t,R=2*i.count,U=new Bt(L,B,R,n/3);_t(I,U,f),z.set(I,U),g.push(I,it(this._materials[Mt.Bottom],m,0,v,r,S)),d.push(v.heights)}if(0===g.length)return null;const G=new $({geometries:g,layerViewUid:this._context.layerViewUid,graphicUid:l,isElevationSource:!0});G.transformation=f;const T=F(this.symbolLayer,{opacity:this._getLayerOpacity()}),k=T?new R(this._materials[Mt.Main],T,this._context.slicePlaneEnabled):null,H=new U(this,G,null,((t,e,r,o,s)=>bt(t,e,r,o,s,d,z)),o,k);return H.alignedSampledElevation=p.sampledElevation,H.needsElevationUpdates=B(o.mode),H}_getFallbackOpacityAndColor(){const e=this.symbolLayer?.material?.color;return t.toUnitRGBA(e)??_}}function it(t,e,r,o,s,i){const n=C(e.length),a=[[tt.POSITION,new Z(o.positions,e,3,!0)],[tt.NORMALCOMPRESSED,new Z(o.normals,e,2,!0)],[tt.COLOR,new Z(s,n,4,!0)]];return new K(t,a,o.elevation,rt.Mesh,i,r)}function nt(t,e,r,o,s,i,n,a,l,c,m,p,h){{const g=r.length/3,d=2*o.count;at(t,e,o.index,o.count,r,0,g,s,i,n,a,l,c,d,m,p,h)}{let t=0,e=2*o.count,r=0;const c=o.pathLengths[0];mt(s,i,a,n,t,c,o.count,e,l,r,m),e+=4*c,r+=2*c,t+=c;for(let p=1;p<o.pathLengths.length;++p){const c=o.pathLengths[p];mt(s,i,a,n,t,c,o.count,e,l,r,m),e+=4*c,r+=2*c,t+=c}}}function at(t,e,r,o,s,i,n,a,l,c,h,g,d,u,f,y,b){m(jt,y);{const s=f>0?1:-1;let i=3*r,n=0,m=3*n,g=o,d=3*g;for(let r=0;r<o;++r){const r=t[i],o=t[i+1],u=t[i+2];b&&(jt[0]=r,jt[1]=o,jt[2]=u,p(jt,jt)),a[m+0]=r,a[m+1]=o,a[m+2]=u;const y=e[i+0],_=e[i+1],x=e[i+2];l[m+0]=y,l[m+1]=_,l[m+2]=x,c[m+0]=-s*jt[0],c[m+1]=-s*jt[1],c[m+2]=-s*jt[2],h[n]=0,a[d+0]=r+f*jt[0],a[d+1]=o+f*jt[1],a[d+2]=u+f*jt[2],l[d+0]=y,l[d+1]=_,l[d+2]=x,h[g]=f,m+=3,d+=3,i+=3,n+=1,g+=1}}{let t=3*i,e=0,r=3*u;const a=f<0?Ot:wt,l=f<0?wt:Ot;for(let i=0;i<n;++i)d[e]=s[t+a[0]],d[e+1]=s[t+a[1]],d[e+2]=s[t+a[2]],g[r]=s[t+l[0]]+o,g[r+1]=s[t+l[1]]+o,g[r+2]=s[t+l[2]]+o,e+=3,r+=3,t+=3}}function lt(t,e,r,o,s,i,n){o[i]=o[n],n*=3,t[i*=3]=t[n],t[i+1]=t[n+1],t[i+2]=t[n+2],e[i]=e[n],e[i+1]=e[n+1],e[i+2]=e[n+2],r[i]=s[0],r[i+1]=s[1],r[i+2]=s[2]}const ct=b();function mt(t,e,r,o,s,i,n,a,l,c,m){let p=s,h=s+1,g=s+n,d=s+n+1,u=a,f=a+1,y=a+2*i,b=a+2*i+1;m<0&&(p=s+n+1,d=s);let _=3*c;for(let x=0;x<i;++x)x===i-1&&(h=s,m>0?d=s+n:p=s+n),ft(t,p,h,g,ct),lt(t,e,o,r,ct,u,p),lt(t,e,o,r,ct,f,h),lt(t,e,o,r,ct,y,g),lt(t,e,o,r,ct,b,d),l[_]=u,l[_+1]=y,l[_+2]=b,l[_+3]=u,l[_+4]=b,l[_+5]=f,_+=6,p++,h++,g++,d++,u+=2,f+=2,y+=2,b+=2}const pt=b(),ht=b(),gt=b(),dt=b(),ut=b();function ft(t,e,r,o,s){e*=3,r*=3,o*=3,h(pt,t[e++],t[e++],t[e++]),h(ht,t[r++],t[r++],t[r++]),h(gt,t[o++],t[o++],t[o++]),g(dt,ht,pt),g(ut,gt,pt),d(s,ut,dt),p(s,s)}const yt=b();function bt(t,e,r,o,s,i,n){const a=t.stageObject,m=a.geometries,p=m.length,g="absolute-height"!==e.mode;let d=0;const f=a.transformation,y=l(c(),f);for(let l=0;l<p;l+=2){const t=m[l];if(!Q(t))continue;const e=t.getMutableAttribute(tt.POSITION).data,c=i[l/2],p=new H(t.mapPositions),b=e.length/3;let _=!1,x=0;{let t=0;for(let i=0;i<b;i++){yt[0]=e[t],yt[1]=e[t+1],yt[2]=e[t+2],o(p,Pt),g&&(x+=Pt.sampledElevation),k.TESTS_DISABLE_OPTIMIZATIONS?(h(St,p.array[p.offset],p.array[p.offset+1],Pt.z+c[t/3]),null!=r&&s.toRenderCoords(St,r,St),u(St,St,y)):(h(St,e[t],e[t+1],e[t+2]),u(St,St,f),s.setAltitude(St,Pt.z+c[t/3]),u(St,St,y)),e[t]=St[0],e[t+1]=St[1],e[t+2]=St[2];const i=Ct/s.unitInMeters;(Math.abs(yt[0]-e[t])>=i||Math.abs(yt[1]-e[t+1])>=i||Math.abs(yt[2]-e[t+2])>=i)&&(_=!0),p.offset+=3,t+=3}}if(_){const e=n.get(t);e&&_t(t,e,f),a.geometryVertexAttributeUpdated(m[l],tt.NORMALCOMPRESSED),t.invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(m[l],tt.POSITION),m[l+1].invalidateBoundingInfo(),a.geometryVertexAttributeUpdated(m[l+1],tt.POSITION)}d+=x/b}return d/p}function _t(t,e,r){const o=t.getMutableAttribute(tt.POSITION),s=t.getMutableAttribute(tt.NORMALCOMPRESSED).data,{topVertexStart:i,topVertexCount:n,topFaceStart:a,topFaceCount:l}=e,c=o.data,m=n,g=t.attributes.get(tt.POSITION).indices,y=a+l,b=i+n,_=w(3*m);for(let p=0;p<m;++p){const t=3*p;_[t+0]=0,_[t+1]=0,_[t+2]=0}const x=Et,S=vt,j=It,P=At,O=jt;for(let w=a;w<y;++w){const t=3*w;for(let e=0;e<3;++e){const o=g[t+e];P[e]=o;const s=3*o;h(St,c[s+0],c[s+1],c[s+2]),u(x[e],St,r)}f(S,x[1],x[0]),f(j,x[2],x[0]),d(O,S,j),p(O,O);for(let e=0;e<3;++e){const t=3*(P[e]-i);_[t+0]+=O[0],_[t+1]+=O[1],_[t+2]+=O[2]}}for(let p=i;p<b;++p){const t=3*(p-i),e=_[t+0],r=_[t+1],o=_[t+2],n=Math.sqrt(e*e+r*r+o*o);Y(s,p,e/n,r/n,o/n)}}function xt(t){return 1===(t.material?.color?.a??1)}const St=b(),jt=b(),Pt=new z,wt=[0,2,1],Ot=[0,1,2],Ct=.01,Et=[b(),b(),b()],vt=b(),It=b(),At=[0,0,0];var Mt;!function(t){t[t.Main=0]="Main",t[t.Bottom=1]="Bottom"}(Mt||(Mt={}));class Lt{constructor(t,e,r,o){this.positions=t,this.elevation=e,this.normals=r,this.heights=o}}class Bt{constructor(t,e,r,o){this.topVertexStart=t,this.topVertexCount=e,this.topFaceStart=r,this.topFaceCount=o}}export{st as Graphics3DExtrudeSymbolLayer,nt as extrudePolygon};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import has from"../../../../core/has.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as n,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderingInfo as s}from"../../../../renderers/support/RenderingInfo.js";import{textSymbolLayerSupportsVerticalOffset as o}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as a}from"./ElevationAligners.js";import{SymbolUpdateType as l,elevationModeChangeUpdateType as c,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import{ElevationContext as h}from"./ElevationContext.js";import{Graphics3DGraphicCreationContext as p}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as f}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as u}from"./Graphics3DSymbolLayer.js";import{computeCentroid as g}from"./graphicUtils.js";import{createStageObject as y,extendPointGraphicElevationContext as v}from"./pointUtils.js";import{SymbolComplexity as b}from"./SymbolComplexity.js";import{Attribute as x}from"../../webgl-engine/lib/Attribute.js";import{Geometry as O}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as C}from"../../webgl-engine/lib/VertexAttribute.js";import{LineCalloutMaterial as _,Parameters as j,uniqueMaterialIdentifier as E}from"../../webgl-engine/materials/LineCalloutMaterial.js";import{GeometryType as P}from"../../webgl-engine/lib/IntersectableGeometry.js";class w extends u{static{this.elevationModeChangeTypes={definedChanged:l.UPDATE,staysOnTheGround:l.UPDATE,onTheGroundChanged:l.RECREATE}}constructor(e,t){super(e,null,t,A),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){this._materials[0]=new _(this._materialParameters,this._context.spherical)}_perInstanceMaterialParameters(e){const t=this._materialParameters;return t.horizontalScreenOffset=e.horizontalScreenOffset??0,t.centerOffsetUnits=e.centerOffsetUnits||"world",t}get _materialParameters(){const r=new j,i=this.symbol,s=i.callout;if(s.color){const t=e.toUnitRGBA(s.color);t[3]*=this._getLayerOpacity(),r.color=t}else r.color=n;if(r.size=t(s.size||0),i.verticalOffset){const{screenLength:e,minWorldLength:n,maxWorldLength:s}=i.verticalOffset;r.verticalOffset={screenLength:t(e),minWorldLength:n||0,maxWorldLength:null!=s?s:1/0}}r.borderColor=null!=s.border?.color?e.toUnitRGBA(s.border.color):null;const o="object"===i.symbolLayers.at(0).type,a="label-3d"===i.type;return r.occlusionTest=!o&&!!has("disable-feature:non-occluded-hud"),o&&(r.shaderPolygonOffset=0),r.hudDepthAlignStart=a,r.hasSlicePlane=this._context.slicePlaneEnabled,r.screenSizePerspective=this._context.screenSizePerspectiveEnabled?this._context.sharedResources.screenSizePerspectiveSettings:null,r}_defaultElevationInfoNoZ(){return U}createGraphics3DGraphic(e,t){const r=e.renderingInfo,n=e.graphic,i=this.setGraphicElevationContext(n,new h,r.elevationOffset||0),s=r.symbol,a="on-the-ground"===this._elevationContext.mode&&("cim"===s.type||!s.symbolLayers.some((e=>"object"===e.type||"text"===e.type)));if("label-3d"!==s.type&&a)return null;if("point-3d"===s.type&&s.symbolLayers.every((e=>"text"===e.type&&!o(e))))return null;const l=g(n.geometry);return null==l?null:this._createAs3DShape(l,i,r,n.uid,t)}layerOpacityChanged(){this._materials[0]?.setParameters(this._materialParameters)}layerElevationInfoChanged(e,t,r){const n=this._elevationContext.mode,i=c(w.elevationModeChangeTypes,r,n);return i!==l.UPDATE||e.forEach((e=>{const r=t(e);null!=r&&this.updateGraphicElevationContext(e.graphic,r)})),i}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}setGraphicElevationContext(e,t,r=0){return super.setGraphicElevationContext(e,t),t.addOffsetRenderUnits(r),t}updateGraphicElevationContext(e,t){const{elevationContext:r,metadata:n}=t;this.setGraphicElevationContext(e,r,n?.elevationOffset??0),t.needsElevationUpdates=m(r.mode)}computeComplexity(){return new b({verticesPerFeature:6})}_getOrCreateMaterial(e,t){const r=this._perInstanceMaterialParameters(e),n=E(r);if(n===this._materials[0]?.uniqueMaterialIdentifier)return this._materials[0];if(t){let e=t.get(n);return null==e&&(e=new _(r,this._context.spherical),t.set(n,e)),e}return new _(r,this._context.spherical)}_createAs3DShape(e,t,r,n,i){const s=this._context.layerViewUid,o=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:s}),l=this._getOrCreateMaterial(r,i),c=new O(l,G(r),null,P.Point,o),h=y(this._context,e,c,t,n);if(null==h)return null;const p=new d(this,h.object,null,a,t);return p.metadata=new f(r.elevationOffset),p.alignedSampledElevation=h.sampledElevation,p.needsElevationUpdates=m(t.mode),v(p,e,this._context.elevationProvider),p}}function G(e){const{translation:t,centerOffset:r}=e,n=new x(t?[t[0],t[1],t[2]]:[0,0,0],S,3,!0),i=new x(r?[r[0],r[1],r[2],r[3]]:[0,0,0,1],S,4,!0);return[[C.POSITION,n],[C.NORMAL,new x([0,0,1],S,3,!0)],[C.CENTEROFFSETANDDISTANCE,i]]}const S=[0],U={mode:"relative-to-ground",offset:0},A={ignoreDrivers:!0,renderPriority:0,renderPriorityStep:1};class D extends s{constructor(e,t,n=r(),s=i(),o=0,a="world",l=0){super(e,t),this.translation=n,this.centerOffset=s,this.horizontalScreenOffset=o,this.centerOffsetUnits=a,this.elevationOffset=l}}class L extends p{}export{w as Graphics3DLineCalloutSymbolLayer,L as LineCalloutCreationContext,D as LineCalloutSymbolLayerRenderingInfo};
5
+ import e from"../../../../Color.js";import has from"../../../../core/has.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as n,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{RenderingInfo as s}from"../../../../renderers/support/RenderingInfo.js";import{textSymbolLayerSupportsVerticalOffset as o}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as a}from"./ElevationAligners.js";import{SymbolUpdateType as l,elevationModeChangeUpdateType as c,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import{ElevationContext as h}from"./ElevationContext.js";import{Graphics3DGraphicCreationContext as p}from"./Graphics3DGraphicCreationContext.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as f}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as u}from"./Graphics3DSymbolLayer.js";import{computeCentroid as g}from"./graphicUtils.js";import{createStageObject as y,extendPointGraphicElevationContext as v}from"./pointUtils.js";import{SymbolComplexity as b}from"./SymbolComplexity.js";import{Attribute as x}from"../../webgl-engine/lib/Attribute.js";import{Geometry as O}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as C}from"../../webgl-engine/lib/VertexAttribute.js";import{LineCalloutMaterial as _,Parameters as j,uniqueMaterialIdentifier as E}from"../../webgl-engine/materials/LineCalloutMaterial.js";import{GeometryType as P}from"../../webgl-engine/lib/IntersectableGeometry.js";class w extends u{static{this.elevationModeChangeTypes={definedChanged:l.UPDATE,staysOnTheGround:l.UPDATE,onTheGroundChanged:l.RECREATE}}constructor(e,t){super(e,null,t,A),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){this._materials[0]=new _(this._materialParameters,this._context.spherical)}_perInstanceMaterialParameters(e){const t=this._materialParameters;return t.horizontalScreenOffset=e.horizontalScreenOffset??0,t.centerOffsetUnits=e.centerOffsetUnits||"world",t}get _materialParameters(){const r=new j,i=this.symbol,s=i.callout;if(s.color){const t=e.toUnitRGBA(s.color);t[3]*=this._getLayerOpacity(),r.color=t}else r.color=n;if(r.size=t(s.size||0),i.verticalOffset){const{screenLength:e,minWorldLength:n,maxWorldLength:s}=i.verticalOffset;r.verticalOffset={screenLength:t(e),minWorldLength:n||0,maxWorldLength:null!=s?s:1/0}}r.borderColor=null!=s.border?.color?e.toUnitRGBA(s.border.color):null;const o="object"===i.symbolLayers.at(0).type,a="label-3d"===i.type;return r.occlusionTest=!o&&!!has("disable-feature:non-occluded-hud"),o&&(r.shaderPolygonOffset=0),r.hudDepthAlignStart=a,r.hasSlicePlane=this._context.slicePlaneEnabled,r.screenSizePerspective=this._context.screenSizePerspectiveEnabled?this._context.sharedResources.screenSizePerspectiveSettings:null,r}_defaultElevationInfoNoZ(){return U}createGraphics3DGraphic(e,t){const r=e.renderingInfo,n=e.graphic,i=this.setGraphicElevationContext(n,new h,r.elevationOffset||0),s=r.symbol,a="on-the-ground"===this._elevationContext.mode&&("cim"===s.type||!s.symbolLayers.some((e=>"object"===e.type||"text"===e.type)));if("label-3d"!==s.type&&a)return null;if("point-3d"===s.type&&s.symbolLayers.every((e=>"text"===e.type&&!o(e))))return null;const l=g(n.geometry);return null==l?null:this._createAs3DShape(l,i,r,n.uid,t)}layerOpacityChanged(){this._materials[0]?.setParameters(this._materialParameters)}layerElevationInfoChanged(e,t,r){const n=this._elevationContext.mode,i=c(w.elevationModeChangeTypes,r,n);return i!==l.UPDATE||e?.forEach((e=>{const r=t(e);null!=r&&this.updateGraphicElevationContext(e.graphic,r)})),i}slicePlaneEnabledChanged(){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}setGraphicElevationContext(e,t,r=0){return super.setGraphicElevationContext(e,t),t.addOffsetRenderUnits(r),t}updateGraphicElevationContext(e,t){const{elevationContext:r,metadata:n}=t;this.setGraphicElevationContext(e,r,n?.elevationOffset??0),t.needsElevationUpdates=m(r.mode)}computeComplexity(){return new b({verticesPerFeature:6})}_getOrCreateMaterial(e,t){const r=this._perInstanceMaterialParameters(e),n=E(r);if(n===this._materials[0]?.uniqueMaterialIdentifier)return this._materials[0];if(t){let e=t.get(n);return null==e&&(e=new _(r,this._context.spherical),t.set(n,e)),e}return new _(r,this._context.spherical)}_createAs3DShape(e,t,r,n,i){const s=this._context.layerViewUid,o=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:s}),l=this._getOrCreateMaterial(r,i),c=new O(l,G(r),null,P.Point,o),h=y(this._context,e,c,t,n);if(null==h)return null;const p=new d(this,h.object,null,a,t);return p.metadata=new f(r.elevationOffset),p.alignedSampledElevation=h.sampledElevation,p.needsElevationUpdates=m(t.mode),v(p,e,this._context.elevationProvider),p}}function G(e){const{translation:t,centerOffset:r}=e,n=new x(t?[t[0],t[1],t[2]]:[0,0,0],S,3,!0),i=new x(r?[r[0],r[1],r[2],r[3]]:[0,0,0,1],S,4,!0);return[[C.POSITION,n],[C.NORMAL,new x([0,0,1],S,3,!0)],[C.CENTEROFFSETANDDISTANCE,i]]}const S=[0],U={mode:"relative-to-ground",offset:0},A={ignoreDrivers:!0,renderPriority:0,renderPriorityStep:1};class D extends s{constructor(e,t,n=r(),s=i(),o=0,a="world",l=0){super(e,t),this.translation=n,this.centerOffset=s,this.horizontalScreenOffset=o,this.centerOffsetUnits=a,this.elevationOffset=l}}class L extends p{}export{w as Graphics3DLineCalloutSymbolLayer,L as LineCalloutCreationContext,D as LineCalloutSymbolLayerRenderingInfo};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{isPromiseLike as o}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as n}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as i,multiply as l,invert as c,getTranslation as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m,IDENTITY as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as d,g,h as x,t as _,q as y,n as b,b as T,f as v,d as w,e as M}from"../../../../chunks/vec32.js";import{ZEROS as R,ONES as C,create as j}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as A,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as O}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as E}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as N}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as I}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as S,fromBuffer as U,intersectsClippingArea as B}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as F}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as V,getContinuousIndexArray as L}from"../../../../geometry/support/Indices.js";import D from"../../../../geometry/support/MeshComponent.js";import G from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import $ from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as H,isAbsoluteVertexSpace as k}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as z}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as W}from"../../../../chunks/vec3.js";import{transformNormal as Y,transformVectorENUPlateCarree as Z,VectorType as J,transformVectorWMPlateCarree as K,projectNormalToPCPF as Q,transformTangent as X,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{makeDehydratedPoint as re}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as oe}from"../../../../layers/graphics/sources/interfaces.js";import{getEmissiveMode as ae}from"../../../../symbols/support/materialUtils.js";import{ViewingMode as ne}from"../../../ViewingMode.js";import{isEncodedMeshTexture as se}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ie}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as le}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as ce}from"./ElevationAligners.js";import{needsElevationUpdates3D as ue,evaluateElevationInfoAtPoint as me}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as fe}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as pe}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as he}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as de,MeshFastUpdateProcessor as ge}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as xe}from"./SymbolComplexity.js";import{hasEdges as _e,createMaterial as ye}from"../support/edgeUtils.js";import{parseColorMixMode as be,encodeSymbolColor as Te}from"../support/symbolColorUtils.js";import{debugFlags as ve}from"../../support/debugFlags.js";import{Attribute as we}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as Me,CullFaceOptions as Re}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as Ce}from"../../webgl-engine/lib/Geometry.js";import{Object3D as je}from"../../webgl-engine/lib/Object3D.js";import{Texture as Ae}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Pe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Oe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ee}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ne,advancedMRRFactors as Ie,schematicMRRFactors as Se}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ue}from"../../../webgl/enums.js";import{GeometryType as Be}from"../../webgl-engine/lib/IntersectableGeometry.js";const Fe=["mesh"];class Ve extends he{constructor(e,t,r,o){super(e,t,r,o,rt(t)),this._materialInfoCache=new de,this._fastUpdateProcessor=new ge,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ve.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Ee({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Ee({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Ee({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(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,Fe,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}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)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ue)}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 a=e.fastTransformUpdatesEnabled;switch(o){case oe.EnableFastUpdates:if(a)return!0;break;case oe.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!!this.updateTransform(e,t,r,oe.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0)}const n=this._context.renderCoordsHelper.spatialReference,s=ut,{origin:i,transform:l}=r;if(!E(t,d(nt,i.x,i.y,i.z??0),s,n))return!1;switch(o){case oe.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case oe.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case oe.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>me(e,u,c,m,t);return e.alignedSampledElevation=ce(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!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={...le(this.symbol,this.symbolLayer),resourceBytes:e},r=_e(this.symbolLayer)?2:0;return new xe({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Xe(a),p=Xe(n),h=et(s),d=Xe(i),g=et(l);if(o.color=a,o.colorTexture=n,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 G){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Xe(a),h=et(n),d=Xe(i),g=Xe(c),x=et(u),_=Xe(m),y=et(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=We(s),o.normalTextureTransform=We(l),o.emissiveTextureTransform=We(u),o.occlusionTextureTransform=We(f),o.metallicRoughnessTextureTransform=We(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${y}`}return o}_getInternalTexture(e,t=!1,a=Me.Opaque){const n=Qe(e);if(!n)return null;const s=`${e.contentHash}/${a}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const a=e.acquire(i.id);return null==a||o(a)||(i.events.on("unloaded",(()=>t=r(t))),t=a),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Ye(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return se(n)?(l=n.data,u.preMultiplyAlpha=!1,u.encoding=n.encoding):(l=n,u.preMultiplyAlpha=a!==Me.Opaque,u.compressionHandle=t?this._context.compressionHandle:void 0,u.compressionCallback=t?()=>this.updateComplexity():void 0),i=new Ae(l,u),this._textures.set(s,i),i.events.on("loaded",(()=>this.updateComplexity())),i.load(this._context.stage.renderView.renderingContext),this._context.stage.add(i),i.events.on("unloaded",(()=>{this._textures.delete(s)})),i}_setInternalMaterialTextureParameters(t,r){if(null!=t.colorTexture){const e=r.textureAlphaMode!==Me.Opaque,o=this._getInternalTexture(t.colorTexture,e,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTexture(t.normalTexture)?.id),t.emissiveColor&&(r.emissiveBaseColor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(t.emissiveTexture)?.id),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(t.occlusionTexture,!0)?.id),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(t.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ke(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ie(e.colorTextureTransform),t.normalTextureTransformMatrix=ie(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:h;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ie(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ie(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ie(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this.symbolLayer?.material?.color){const o=this._drivenProperties.color;let a=this.symbolLayer.material?.colorMixMode??null;if(o)t.externalColor=A;else{const o=r??null;o?t.externalColor=e.toUnitRGBA(o):(a=null,t.externalColor=A)}a&&(t.colorMixMode=a),t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrength=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=ae(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(Je(t)||null!=o&&o.a<1||a?.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=Ne({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:R,diffuse:C,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:Re.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Se:[l.metallic,l.roughness,Ie[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?Re.None:Re.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new Oe(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?Me.MaskBlend:Me.Opaque}else e.textureAlphaMode="opaque"===t.alphaMode?Me.Opaque:"mask"===t.alphaMode?Me.Mask:Me.Blend}_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),i=[],l=[],c=t[0].transformation,u=a(s(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get(Pe.POSITION);if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)ze(r,o,t,lt),qe(r,o,t,nt,st,it),g(nt,nt,st),g(nt,nt,it),x(nt,nt,1/3),_(nt,nt,c),i.push(...nt),y(lt,lt,u),b(lt,lt),T(nt,nt,lt,n),i.push(...nt),l.push(l.length),l.push(l.length)}return i.length?new Ce(this._debugFaceNormalMaterial,[[Pe.POSITION,new we(i,l,3,!0)]],null,Be.Line):null}_createPerVertexDebugVectors(e,t,r,o,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(s(),p);r===Pe.TANGENT&&n(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get(Pe.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;d(nt,s[e+0],s[e+1],s[e+2]),_(nt,nt,p),m.push(...nt),d(st,l[r+0],l[r+1],l[r+2]),y(st,st,h),b(st,st),T(nt,nt,st,u),m.push(...nt),f.push(f.length),f.push(f.length)}}return m.length?new Ce(o,[[Pe.POSITION,new we(m,f,3,!0)]],null,Be.Line):null}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;if(ve.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(a,s,Pe.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(a,s,Pe.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(a,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new je({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=ye(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new pe(s[0].material,u,this._context.slicePlaneEnabled):null,f=new fe(this,c,null,ce,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ue(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(a),r.centerPointInElevationSR=this._getCenterPointInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>me(e,p,r,h,t);return f.alignedSampledElevation=ce(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!H(t))return!1;const{type:o}=t,{view:a}=this._context.graphicsCoreOwner,{viewingMode:n}=a.state,s=a.spatialReference;return n===ne.Global&&"local"===o||n===ne.Local&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=re(0,0,0,this._context.elevationProvider.spatialReference??null);return I([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===pt.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,a=r;if(t.reprojection===pt.NONE)return{position:a,georeferencedPositionBuffer:o};const n=t.reprojection===pt.RENDER?t.transformBeforeProject:null;n&&(a=W(new Float64Array(a.length),a,n));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=a);const l=a===r||a===o?new Float64Array(a.length):a;return N(a,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const a=e.vertexAttributes.normal;if(null==a)return null;let n=a;const s=o.reprojection===pt.RENDER?o.transformBeforeProject:null;s&&(n=Y(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===pt.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.NORMAL,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return Q(n,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const a=e.vertexAttributes.tangent;if(null==a)return null;let n=a;const s=o.reprojection===pt.RENDER?o.transformBeforeProject:null;s&&(n=X(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===pt.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.TANGENT,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return ee(n,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e,this._getFallbackOpacityAndColor()),r=be(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return Te(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=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(n&&n.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(a&&a.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=tt(e),u=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=a,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:s.reprojection===pt.NONE&&s.geometryTransformation?s.geometryTransformation:m()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?pt.NONE:pt.RENDER:pt.NONE;if(k(t))return{reprojection:r};const o=t.origin,a=m(),n=e.transform?.localMatrix??f;if(r===pt.NONE){E(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:p(n)}}const s=i(m(),o);return l(s,s,n),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=e.origin;at[0]=n.x,at[1]=n.y,at[2]=n.z??0;const s=m();E(e.spatialReference,at,s,a),c(ct,s);const{position:i,normal:l,tangent:u}=e.vertexAttributes,f=t===i?new Float64Array(t.length):t;W(f,t,ct);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===u?new Float32Array(o.length):o:null;return r&&p&&Y(r,p,ct),o&&h&&X(o,h,ct),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(U(o,mt),!B(mt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!O(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:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:m,geometryTransformation:f}=o,p=e.components??ft,h=new Array;let d=!1;const g=u(nt,m),x=this._context.localOriginFactory.getOrigin(g);for(const u of p){if(!this._validateFaces(e,u))return null;const t=De(e,u);if(0===t.length)continue;const o=Ge(a,l,u,t);o.didFlipNormals&&(d=!0);const m=[[Pe.POSITION,new we(a,t,3,!0)],[Pe.NORMAL,new we(o.normals,o.indices,3,!0)]];s&&m.push([Pe.COLOR,new we(s,t,4,!0)]),i&&m.push([Pe.SYMBOLCOLOR,new we(i,V(t.length),4,!0)]),n&&m.push([Pe.UV0,new we(n,t,2,!0)]),c&&m.push([Pe.TANGENT,new we(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,u),_=new Ce(g,m,null,Be.Mesh,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:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==ne.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??P}}class Le{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function De(e,t){return t.faces??L(e.vertexAttributes.position.length/3)}function Ge(e,t,r,o){switch(r.shading||"flat"){default:case"source":return He(e,t,r,o);case"flat":return $e(e,o);case"smooth":return ke(e,o)}}function $e(e,t){const r=F(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=ze(e,t,a,lt);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new Le(r,o,!1)}function He(e,t,r,o){if(null==t)return $e(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){ze(e,o,n,lt);for(let e=0;e<3;e++){const r=3*o[n+e];nt[0]=t[r],nt[1]=t[r+1],nt[2]=t[r+2],v(lt,nt)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Le(t,o,a)}function ke(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=ze(e,t,n,lt);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:j(),count:0},r[a]=s),g(s.normal,s.normal,o),s.count++}}const o=F(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new Le(o,a,!1)}function qe(e,t,r,o,a,n){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],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}function ze(e,t,r,o){return qe(e,t,r,nt,st,it),w(st,st,nt),w(it,it,nt),M(nt,st,it),b(o,nt),o}function We(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}function Ye(e="repeat"){if("string"==typeof e){const t=Ze(e);return{s:t,t}}return{s:Ze(e.horizontal),t:Ze(e.vertical)}}function Ze(e){switch(e){case"clamp":return Ue.CLAMP_TO_EDGE;case"mirror":return Ue.MIRRORED_REPEAT;default:return Ue.REPEAT}}function Je(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 Ke(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function Qe(e){return e.data??e.url}function Xe(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function et(e){const{offset:t,scale:r,rotation:o}=e??ot;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function tt(e){return e.vertexAttributes.color}function rt(e){return 1===(e.material?.color?.a??1)}const ot=new $,at=j(),nt=j(),st=j(),it=j(),lt=j(),ct=m(),ut=m(),mt=S(),ft=[new D];var pt;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(pt||(pt={}));export{Ve as Graphics3DMeshFillSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{releaseMaybe as r}from"../../../../core/maybe.js";import{isPromiseLike as o}from"../../../../core/promiseUtils.js";import{normalFromMat4 as a,fromMat4 as n}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as i,multiply as l,invert as c,getTranslation as u}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as m,IDENTITY as f,clone as p}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as d,g,h as x,t as _,q as y,n as b,b as T,f as v,d as w,e as M}from"../../../../chunks/vec32.js";import{ZEROS as R,ONES as C,create as j}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as A,ZEROS as P}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as O}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as E}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as N}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as I}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as S,fromBuffer as U,intersectsClippingArea as B}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as F}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as V,getContinuousIndexArray as L}from"../../../../geometry/support/Indices.js";import D from"../../../../geometry/support/MeshComponent.js";import G from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import $ from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as H,isAbsoluteVertexSpace as k}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as q,isPlateCarree as z}from"../../../../geometry/support/spatialReferenceUtils.js";import{t as W}from"../../../../chunks/vec3.js";import{transformNormal as Y,transformVectorENUPlateCarree as Z,VectorType as J,transformVectorWMPlateCarree as K,projectNormalToPCPF as Q,transformTangent as X,projectTangentToPCPF as ee}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as te}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{makeDehydratedPoint as re}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as oe}from"../../../../layers/graphics/sources/interfaces.js";import{getEmissiveMode as ae}from"../../../../symbols/support/materialUtils.js";import{ViewingMode as ne}from"../../../ViewingMode.js";import{isEncodedMeshTexture as se}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as ie}from"../../glTF/internal/TextureTransformUtils.js";import{defaultSymbolLayerMemoryComplexity as le}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as ce}from"./ElevationAligners.js";import{needsElevationUpdates3D as ue,evaluateElevationInfoAtPoint as me}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as fe}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as pe}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as he}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as de,MeshFastUpdateProcessor as ge}from"./MeshFastUpdateProcessor.js";import{SymbolComplexity as xe}from"./SymbolComplexity.js";import{hasEdges as _e,createMaterial as ye}from"../support/edgeUtils.js";import{parseColorMixMode as be,encodeSymbolColor as Te}from"../support/symbolColorUtils.js";import{debugFlags as ve}from"../../support/debugFlags.js";import{Attribute as we}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as Me,CullFaceOptions as Re}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as Ce}from"../../webgl-engine/lib/Geometry.js";import{Object3D as je}from"../../webgl-engine/lib/Object3D.js";import{Texture as Ae}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as Pe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as Oe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Ee}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as Ne,advancedMRRFactors as Ie,schematicMRRFactors as Se}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ue}from"../../../webgl/enums.js";import{GeometryType as Be}from"../../webgl-engine/lib/IntersectableGeometry.js";const Fe=["mesh"];class Ve extends he{constructor(e,t,r,o){super(e,t,r,o,rt(t)),this._materialInfoCache=new de,this._fastUpdateProcessor=new ge,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ve.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Ee({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new Ee({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new Ee({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(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,Fe,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}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)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,ue)}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 a=e.fastTransformUpdatesEnabled;switch(o){case oe.EnableFastUpdates:if(a)return!0;break;case oe.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!!this.updateTransform(e,t,r,oe.EnableFastUpdates)&&(e.autoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!0)}const n=this._context.renderCoordsHelper.spatialReference,s=ut,{origin:i,transform:l}=r;if(!E(t,d(nt,i.x,i.y,i.z??0),s,n))return!1;switch(o){case oe.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case oe.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache);break;case oe.UpdateFastLocalOrigin:e.updateFastLocalOrigin(s,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(s);const{elevationProvider:u,renderCoordsHelper:m}=this._context,f=(e,t)=>me(e,u,c,m,t);return e.alignedSampledElevation=ce(e,c,u.spatialReference,f,m,s),e.updateTransform(s,l,this._context.isAsync),e.updateAutoDisableFastTransformUpdates((()=>this.updateTransform(e,t,r,oe.DisableFastUpdates))),!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={...le(this.symbol,this.symbolLayer),resourceBytes:e},r=_e(this.symbolLayer)?2:0;return new xe({drawCallsPerFeature:r,memory:t})}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:n,colorTextureTransform:s,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,f=Xe(a),p=Xe(n),h=et(s),d=Xe(i),g=et(l);if(o.color=a,o.colorTexture=n,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 G){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:n,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:f}=t.material,p=Xe(a),h=et(n),d=Xe(i),g=Xe(c),x=et(u),_=Xe(m),y=et(f);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=We(s),o.normalTextureTransform=We(l),o.emissiveTextureTransform=We(u),o.occlusionTextureTransform=We(f),o.metallicRoughnessTextureTransform=We(n),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${p},mrtt:${h},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${y}`}return o}_getInternalTexture(e,t=!1,a=Me.Opaque){const n=Qe(e);if(!n)return null;const s=`${e.contentHash}/${a}`;let i=this._textures.get(s);if(i){const e=this._context.stage.renderView.textures;let t=null;const a=e.acquire(i.id);return null==a||o(a)||(i.events.on("unloaded",(()=>t=r(t))),t=a),i}let l=null;const c=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,u={wrap:Ye(e.wrap),noUnpackFlip:!0,maxAnisotropy:c,mipmap:c>1};return se(n)?(l=n.data,u.preMultiplyAlpha=!1,u.encoding=n.encoding):(l=n,u.preMultiplyAlpha=a!==Me.Opaque,u.compressionHandle=t?this._context.compressionHandle:void 0,u.compressionCallback=t?()=>this.updateComplexity():void 0),i=new Ae(l,u),this._textures.set(s,i),i.events.on("loaded",(()=>this.updateComplexity())),i.load(this._context.stage.renderView.renderingContext),this._context.stage.add(i),i.events.on("unloaded",(()=>{this._textures.delete(s)})),i}_setInternalMaterialTextureParameters(t,r){if(null!=t.colorTexture){const e=r.textureAlphaMode!==Me.Opaque,o=this._getInternalTexture(t.colorTexture,e,r.textureAlphaMode);o?(r.textureId=o.id,r.textureAlphaPremultiplied=!!o.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTexture(t.normalTexture)?.id),t.emissiveColor&&(r.emissiveBaseColor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTexture(t.emissiveTexture)?.id),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTexture(t.occlusionTexture,!0)?.id),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTexture(t.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,r){null!=e.color&&Ke(e.color,t,r),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=ie(e.colorTextureTransform),t.normalTextureTransformMatrix=ie(e.normalTextureTransform);const o=null!=e.normalTextureTransform?.scale?e.normalTextureTransform?.scale:h;t.scale=[o[0],o[1]],t.occlusionTextureTransformMatrix=ie(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=ie(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=ie(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t,r=this.symbolLayer?.material?.color){const o=this._drivenProperties.color;let a=this.symbolLayer.material?.colorMixMode??null;if(o)t.externalColor=A;else{const o=r??null;o?t.externalColor=e.toUnitRGBA(o):(a=null,t.externalColor=A)}a&&(t.colorMixMode=a),t.castShadows=!!this.symbolLayer.castShadows,t.emissiveStrength=this.symbolLayer?.material?.emissive?.strength??1,t.emissiveSource=ae(this.symbolLayer?.material?.emissive?.source??"emissive")}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,n=r.material?.alphaMode,s="blend"===n,i=!("opaque"===n)&&(Je(t)||null!=o&&o.a<1||a?.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=Ne({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:R,diffuse:C,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:Re.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||u.isComponentTransparent};f.mrrFactors=m?Se:[l.metallic,l.roughness,Ie[2]],r.material&&(f.doubleSided=r.material.doubleSided,f.cullFace=r.material.doubleSided?Re.None:Re.Back,f.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(f),this._setMaterialTextureAlphaMode(f,u),this._setInternalMaterialParameters(l,f,u);const p=new Oe(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?Me.MaskBlend:Me.Opaque}else e.textureAlphaMode="opaque"===t.alphaMode?Me.Opaque:"mask"===t.alphaMode?Me.Mask:Me.Blend}_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),i=[],l=[],c=t[0].transformation,u=a(s(),c);for(let a=0;a<r;a++){const e=t[a].attributes.get(Pe.POSITION);if(!e)continue;const r=e.data,o=e.indices;for(let t=0;t<o.length;t+=3)ze(r,o,t,lt),qe(r,o,t,nt,st,it),g(nt,nt,st),g(nt,nt,it),x(nt,nt,1/3),_(nt,nt,c),i.push(...nt),y(lt,lt,u),b(lt,lt),T(nt,nt,lt,n),i.push(...nt),l.push(l.length),l.push(l.length)}return i.length?new Ce(this._debugFaceNormalMaterial,[[Pe.POSITION,new we(i,l,3,!0)]],null,Be.Line):null}_createPerVertexDebugVectors(e,t,r,o,i){const l=t.length,c=e.spatialReference.isGeographic?20015077/180:1,u=.1*i*Math.max(e.extent.width*c,e.extent.height*c,e.extent.zmax-e.extent.zmin),m=[],f=[],p=t[0].transformation,h=a(s(),p);r===Pe.TANGENT&&n(h,p);for(let a=0;a<l;a++){const e=t[a],o=e.attributes.get(Pe.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;d(nt,s[e+0],s[e+1],s[e+2]),_(nt,nt,p),m.push(...nt),d(st,l[r+0],l[r+1],l[r+2]),y(st,st,h),b(st,st),T(nt,nt,st,u),m.push(...nt),f.push(f.length),f.push(f.length)}}return m.length?new Ce(o,[[Pe.POSITION,new we(m,f,3,!0)]],null,Be.Line):null}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const n=this._createGeometryInfo(a,t,o);if(null==n)return null;const{geometries:s,objectTransformation:i}=n;if(ve.DRAW_MESH_GEOMETRY_NORMALS){const e=this._createPerVertexDebugVectors(a,s,Pe.NORMAL,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(a,s,Pe.TANGENT,this._debugTangentNormalMaterial,.5),r=this._createFaceDebugNormals(a,s);e&&s.push(e),t&&s.push(t),r&&s.push(r)}const l=this._context.layerViewUid,c=new je({geometries:s,layerViewUid:l,graphicUid:o,isElevationSource:!0});c.transformation=i;const u=ye(this.symbolLayer,{opacity:this._getLayerOpacity()}),m=u?new pe(s[0].material,u,this._context.slicePlaneEnabled):null,f=new fe(this,c,null,ce,r,m);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=ue(r.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(a),r.centerPointInElevationSR=this._getCenterPointInElevationSR(c.transformation);const{elevationProvider:p,renderCoordsHelper:h}=this._context,d=(e,t)=>me(e,p,r,h,t);return f.alignedSampledElevation=ce(f,r,p.spatialReference,d,h),f}_fastTransformUpdatesAllowed(e){const{vertexSpace:t,spatialReference:r}=e;if(!H(t))return!1;const{type:o}=t,{view:a}=this._context.graphicsCoreOwner,{viewingMode:n}=a.state,s=a.spatialReference;return n===ne.Global&&"local"===o||n===ne.Local&&q(s,r)&&"georeferenced"===o&&!r.isGeographic}_getCenterPointInElevationSR(e){const t=re(0,0,0,this._context.elevationProvider.spatialReference??null);return I([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_passthroughReprojectionInfo(e){return e.reprojection===pt.NONE&&!!e.objectTransformation}_createPositionBuffer(e,t){const r=e.vertexAttributes.position;let o,a=r;if(t.reprojection===pt.NONE)return{position:a,georeferencedPositionBuffer:o};const n=t.reprojection===pt.RENDER?t.transformBeforeProject:null;n&&(a=W(new Float64Array(a.length),a,n));const{normal:s,tangent:i}=e.vertexAttributes;this._passthroughReprojectionInfo(t)||!s&&!i||(o=a);const l=a===r||a===o?new Float64Array(a.length):a;return N(a,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:o}}_createNormalBuffer(e,t,r,o){const a=e.vertexAttributes.normal;if(null==a)return null;let n=a;const s=o.reprojection===pt.RENDER?o.transformBeforeProject:null;s&&(n=Y(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===pt.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.NORMAL,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.NORMAL,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return Q(n,r,e.spatialReference,t,c,l)}_createTangentBuffer(e,t,r,o){const a=e.vertexAttributes.tangent;if(null==a)return null;let n=a;const s=o.reprojection===pt.RENDER?o.transformBeforeProject:null;s&&(n=X(n,new Float32Array(n.length),s));const i=this._context.graphicsCoreOwner.view.viewingMode;if(o.reprojection===pt.NONE)return n;if("local"===i){if(!z(this._context.renderCoordsHelper.spatialReference))return n;if(null==r)return null;if(e.spatialReference.isGeographic){const e=n===a?new Float32Array(n.length):n;return Z(n,J.TANGENT,r,e)}if(e.spatialReference.isWebMercator){const e=n===a?new Float32Array(n.length):n;return K(n,J.TANGENT,r,e)}return n}if(null==r)return null;const l=n===a?new Float32Array(n.length):n,c=this._context.renderCoordsHelper.spatialReference;return ee(n,r,e.spatialReference,t,c,l)}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e,this._getFallbackOpacityAndColor()),r=be(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return Te(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,n=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(n&&n.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(a&&a.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=tt(e),u=this._createSymbolColorBuffer(t),f=this._createNormalBuffer(e,i,l,s),p=this._createTangentBuffer(e,i,l,s),h=a,{transformation:d,position:g,normal:x,tangent:_}=this._passthroughReprojectionInfo(s)?{transformation:s.objectTransformation,position:i,normal:f,tangent:p}:this._transformOriginLocal(e,i,f,p);return{positionBuffer:g,normalBuffer:x,tangentBuffer:_,uvBuffer:h,colorBuffer:c,symbolColorBuffer:u,objectTransformation:d,geometryTransformation:s.reprojection===pt.NONE&&s.geometryTransformation?s.geometryTransformation:m()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?q(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?pt.NONE:pt.RENDER:pt.NONE;if(k(t))return{reprojection:r};const o=t.origin,a=m(),n=e.transform?.localMatrix??f;if(r===pt.NONE){E(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:p(n)}}const s=i(m(),o);return l(s,s,n),{reprojection:r,transformBeforeProject:s}}_transformOriginLocal(e,t,r,o){const a=this._context.renderCoordsHelper.spatialReference,n=e.origin;at[0]=n.x,at[1]=n.y,at[2]=n.z??0;const s=m();E(e.spatialReference,at,s,a),c(ct,s);const{position:i,normal:l,tangent:u}=e.vertexAttributes,f=t===i?new Float64Array(t.length):t;W(f,t,ct);const p=r?r===l?new Float32Array(r.length):r:null,h=o?o===u?new Float32Array(o.length):o:null;return r&&p&&Y(r,p,ct),o&&h&&X(o,h,ct),{transformation:s,position:f,normal:p,tangent:h}}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=te(e,r??e.spatialReference);return!!o&&(U(o,mt),!B(mt,this._context.clippingExtent))}_createGeometryInfo(e,t,r){if(!O(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:a,uvBuffer:n,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:c,objectTransformation:m,geometryTransformation:f}=o,p=e.components??ft,h=new Array;let d=!1;const g=u(nt,m),x=this._context.localOriginFactory.getOrigin(g);for(const u of p){if(!this._validateFaces(e,u))return null;const t=De(e,u);if(0===t.length)continue;const o=Ge(a,l,u,t);o.didFlipNormals&&(d=!0);const m=[[Pe.POSITION,new we(a,t,3,!0)],[Pe.NORMAL,new we(o.normals,o.indices,3,!0)]];s&&m.push([Pe.COLOR,new we(s,t,4,!0)]),i&&m.push([Pe.SYMBOLCOLOR,new we(i,V(t.length),4,!0)]),n&&m.push([Pe.UV0,new we(n,t,2,!0)]),c&&m.push([Pe.TANGENT,new we(c,t,4,!0)]);const p=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid}),g=this._getOrCreateMaterial(e,u),_=new Ce(g,m,null,Be.Mesh,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:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==ne.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}_getFallbackOpacityAndColor(){const t=this.symbolLayer?.material?.color;return e.toUnitRGBA(t)??P}}class Le{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}function De(e,t){return t.faces??L(e.vertexAttributes.position.length/3)}function Ge(e,t,r,o){switch(r.shading||"flat"){default:case"source":return He(e,t,r,o);case"flat":return $e(e,o);case"smooth":return ke(e,o)}}function $e(e,t){const r=F(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const n=ze(e,t,a,lt);for(let e=0;e<3;e++)r[a+e]=n[e],o[a+e]=a/3}return new Le(r,o,!1)}function He(e,t,r,o){if(null==t)return $e(e,o);let a=!1;if(!r.trustSourceNormals)for(let n=0;n<o.length;n+=3){ze(e,o,n,lt);for(let e=0;e<3;e++){const r=3*o[n+e];nt[0]=t[r],nt[1]=t[r+1],nt[2]=t[r+2],v(lt,nt)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Le(t,o,a)}function ke(e,t){const r={};for(let n=0;n<t.length;n+=3){const o=ze(e,t,n,lt);for(let e=0;e<3;e++){const a=t[n+e];let s=r[a];s||(s={normal:j(),count:0},r[a]=s),g(s.normal,s.normal,o),s.count++}}const o=F(3*t.length),a=new Array(3*t.length);for(let n=0;n<t.length;n++){const e=r[t[n]];1!==e.count&&(b(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*n+t]=e.normal[t];a[n]=n}return new Le(o,a,!1)}function qe(e,t,r,o,a,n){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],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],n[0]=e[l],n[1]=e[l+1],n[2]=e[l+2]}function ze(e,t,r,o){return qe(e,t,r,nt,st,it),w(st,st,nt),w(it,it,nt),M(nt,st,it),b(o,nt),o}function We(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}function Ye(e="repeat"){if("string"==typeof e){const t=Ze(e);return{s:t,t}}return{s:Ze(e.horizontal),t:Ze(e.vertical)}}function Ze(e){switch(e){case"clamp":return Ue.CLAMP_TO_EDGE;case"mirror":return Ue.MIRRORED_REPEAT;default:return Ue.REPEAT}}function Je(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 Ke(t,r,o){r.diffuse=e.toUnitRGB(t),r.opacity="opaque"===o.alphaMode?1:t.a}function Qe(e){return e.data??e.url}function Xe(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}function et(e){const{offset:t,scale:r,rotation:o}=e??ot;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}function tt(e){return e.vertexAttributes.color}function rt(e){return 1===(e.material?.color?.a??1)}const ot=new $,at=j(),nt=j(),st=j(),it=j(),lt=j(),ct=m(),ut=m(),mt=S(),ft=[new D];var pt;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(pt||(pt={}));export{Ve as Graphics3DMeshFillSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.33/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Logger.js";import{ONES as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as o}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as n}from"./defaultSymbolComplexity.js";import{SymbolUpdateType as s}from"./elevationAlignmentUtils.js";import{ElevationContext as a}from"./ElevationContext.js";import{zeroContext as l}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as p}from"./graphicUtils.js";import{ApplyRendererDiffResult as c}from"./interfaces.js";import{Loadable as d}from"./Loadable.js";import{getAttributeValue as u}from"../support/FastSymbolUpdates.js";const h=()=>t.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class y extends d{constructor(e,t,i,r,o=!0){super(i.schedule),this.symbol=e,this.symbolLayer=t,this._context=i,this._drivenOpacityFallbackAlwaysOpaque=o,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=h(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=r.renderPriority,this._renderPriorityStep=r.renderPriorityStep,this._elevationContext=new a,this.updateComplexity(),this.ignoreDrivers=r.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=f(this._context.renderer,o)),this._updateElevationContext()}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get usedMemory(){const e=this.complexity;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,i=f(e,this._drivenOpacityFallbackAlwaysOpaque);return i.color!==t.color||i.opacity!==t.opacity||i.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||i.size!==t.size||i.rotation!==t.rotation}get needsDrivenTransparentPass(){return(this._drivenProperties.color||this._drivenProperties.opacity)&&!this._drivenProperties.opacityAlwaysOpaque}_logGeometryCreationWarnings(e,t,i,r){const o=e.projectionSuccess,n="polygons"in e?e.polygons:null,s=`${r} geometry failed to be created`;o?!this._logGeometryValidationWarnings(t,i,r)&&n&&0===n.length&&"rings"===i&&t.length>0&&t[0].length>2&&h().warnOncePerTick(`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):h().warnOncePerTick(`${s} (failed to project geometry to view spatial reference)`)}updateFocus(e,t){}_logGeometryValidationWarnings(e,t,i){const r=`${i} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(h().warnOncePerTick(`${r} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(h().warnOncePerTick(`${r} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,i=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+i+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return h().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":o(e)&&h().warnOnce("Fixed a non-closed polygon ring.")}return!0}_defaultElevationInfoNoZ(){return m}_defaultElevationInfoZ(){return g}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.updateFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.updateFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}setGraphicElevationContext(e,t=new a){const i=e.geometry,r=this.getDefaultElevationInfo(i);t.unit=null!=this._elevationContext.unit?this._elevationContext.unit:r.unit,t.mode=this.getGeometryElevationMode(i,r),t.offsetMeters=this._elevationContext.meterUnitOffset??r.offset??0;const o=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===t.mode;o&&(t.mode="relative-to-ground",t.offsetMeters=0);const n=o?l:this._elevationContext.featureExpressionInfoContext;return t.updateFeatureExpressionInfoContext(n,e,this._context.layer),t}prepareSymbolLayerPatch(e){}updateGeometry(e,t){return!1}updateTransform(e,t,i,r){return!1}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=v){const i=this.draped?1:this._getLayerOpacity();return this._drivenProperties.opacity||this._drivenProperties.color?i:e?i*e.a:t.hasIntrinsicColor?i:0}_getCombinedOpacityAndColor(t,r=v){const o=this._getCombinedOpacity(t,r);if(this._drivenProperties.color)return p(null,o);const n=null!=t?e.toUnitRGB(t):i;return p(n,o)}_getVertexOpacityAndColor(e,t,i=null){const r=this._drivenProperties.color?e.color??t:null,o=this._drivenProperties.opacity?e.opacity??t[3]:null,n=p(r,o);return i&&(n[0]*=i,n[1]*=i,n[2]*=i,n[3]*=i),n}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return n(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,i){switch(e){case"opacity":return this.layerOpacityChanged(t,i),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return this.layerElevationInfoChanged(t,i,e)!==s.RECREATE}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,i);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;default:return!1}}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,i){let r=s.UPDATE;return e.forEach((e=>{const o=t(e);if(null!=o){const t=e.graphic;this.setGraphicElevationContext(t,o.elevationContext),o.needsElevationUpdates=i(o.elevationContext.mode)}else r=s.RECREATE})),r}applyRendererDiff(e,t){return c.RecreateSymbol}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,i=t.size?u(t.size.field,e):0,o=t.color?u(t.color.field,e):0,n=t.opacity?u(t.opacity.field,e):0;return r(i,o,n,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&h().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.field??null,color:this._fastUpdates?.visualVariables.color?.field??null,opacity:this._fastUpdates?.visualVariables.opacity?.field??null,rotation:this._fastUpdates?.visualVariables.rotation?.field??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function f(e,t){const i={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach((e=>{switch(e.type){case"color":if(i.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const r=e.stops[t].color;r&&r.a<1&&(i.opacityAlwaysOpaque=!1)}break;case"opacity":i.opacity=!0,i.opacityAlwaysOpaque=!1;break;case"size":i.size=!0;break;case"rotation":i.rotation=!0}})),i}const m={mode:"on-the-ground",offset:0,unit:"meters"},g={mode:"absolute-height",offset:0,unit:"meters"},v={hasIntrinsicColor:!1};export{y as Graphics3DSymbolLayer,f as getDrivenProperties};
5
+ import e from"../../../../Color.js";import"../../../../core/has.js";import t from"../../../../core/Logger.js";import{ONES as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromValues as r}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{closeRings as o}from"../../../../geometry/support/coordsUtils.js";import{defaultSymbolLayerComplexity as n}from"./defaultSymbolComplexity.js";import{SymbolUpdateType as s}from"./elevationAlignmentUtils.js";import{ElevationContext as a}from"./ElevationContext.js";import{zeroContext as l}from"./featureExpressionInfoUtils.js";import{mixinColorAndOpacity as p}from"./graphicUtils.js";import{ApplyRendererDiffResult as c}from"./interfaces.js";import{Loadable as d}from"./Loadable.js";import{getAttributeValue as u}from"../support/FastSymbolUpdates.js";const h=()=>t.getLogger("esri.views.3d.layers.graphics.Graphics3DSymbolLayer");class y extends d{constructor(e,t,i,r,o=!0){super(i.schedule),this.symbol=e,this.symbolLayer=t,this._context=i,this._drivenOpacityFallbackAlwaysOpaque=o,this.ignoreDrivers=!1,this._drivenProperties={color:!1,opacity:!1,opacityAlwaysOpaque:!0,size:!1,rotation:!1},this._materials=[],this.logger=h(),this._elevationOptions={supportsOffsetAdjustment:!1,supportsOnTheGround:!0},this.skipHighSymbolLodsChanged=!0,this._renderPriority=r.renderPriority,this._renderPriorityStep=r.renderPriorityStep,this._elevationContext=new a,this.updateComplexity(),this.ignoreDrivers=r.ignoreDrivers,this.ignoreDrivers||(this._drivenProperties=f(this._context.renderer,o)),this._updateElevationContext()}getCachedSize(){return null}get extentPadding(){return 0}get materials(){return this._materials}get usedMemory(){const e=this.complexity;if(null==e)return 0;return(this.draped?e.memory.draped:e.memory).bytesPerFeature}_drivenPropertiesChanged(e){if(this.ignoreDrivers)return!1;const t=this._drivenProperties,i=f(e,this._drivenOpacityFallbackAlwaysOpaque);return i.color!==t.color||i.opacity!==t.opacity||i.opacityAlwaysOpaque!==t.opacityAlwaysOpaque||i.size!==t.size||i.rotation!==t.rotation}get needsDrivenTransparentPass(){return(this._drivenProperties.color||this._drivenProperties.opacity)&&!this._drivenProperties.opacityAlwaysOpaque}_logGeometryCreationWarnings(e,t,i,r){const o=e.projectionSuccess,n="polygons"in e?e.polygons:null,s=`${r} geometry failed to be created`;o?!this._logGeometryValidationWarnings(t,i,r)&&n&&0===n.length&&"rings"===i&&t.length>0&&t[0].length>2&&h().warnOncePerTick(`${s} (filled rings should use clockwise winding - try reversing the order of vertices)`):h().warnOncePerTick(`${s} (failed to project geometry to view spatial reference)`)}updateFocus(e,t){}_logGeometryValidationWarnings(e,t,i){const r=`${i} geometry failed to be created`;return!e.length||1===e.length&&!e[0].length?(h().warnOncePerTick(`${r} (no ${t} were defined)`),!0):(!Array.isArray(e)||!Array.isArray(e[0]))&&(h().warnOncePerTick(`${r} (${t} should be defined as a 2D array)`),!0)}_validateGeometry(e,t=null,i=null){if(null!=t&&!t.includes(e.type))return this.logger.warn("unsupported geometry type for "+i+` symbol: ${e.type}`),!1;switch(e.type){case"point":{const t=e;if(!isFinite(t.x)||!isFinite(t.y))return h().warn("point coordinate is not a valid number, graphic skipped"),!1;break}case"polygon":o(e)&&h().warnOnce("Fixed a non-closed polygon ring.")}return!0}_defaultElevationInfoNoZ(){return m}_defaultElevationInfoZ(){return g}_updateElevationContext(){null!=this._elevationInfoOverride?(this._elevationContext.setFromElevationInfo(this._elevationInfoOverride),this._elevationContext.updateFeatureExpressionInfoContext(null)):this._context.layer.elevationInfo?(this._elevationContext.setFromElevationInfo(this._context.layer.elevationInfo),this._elevationContext.updateFeatureExpressionInfoContext(this._context.featureExpressionInfoContext)):this._elevationContext.reset()}getDefaultElevationInfo(e){return e.hasZ?this._defaultElevationInfoZ():this._defaultElevationInfoNoZ()}getGeometryElevationMode(e,t=this.getDefaultElevationInfo(e)){return this._elevationContext.mode||t.mode}setElevationInfoOverride(e){this._elevationInfoOverride=e,this._updateElevationContext()}setGraphicElevationContext(e,t=new a){const i=e.geometry,r=this.getDefaultElevationInfo(i);t.unit=null!=this._elevationContext.unit?this._elevationContext.unit:r.unit,t.mode=this.getGeometryElevationMode(i,r),t.offsetMeters=this._elevationContext.meterUnitOffset??r.offset??0;const o=!this._elevationOptions.supportsOnTheGround&&"on-the-ground"===t.mode;o&&(t.mode="relative-to-ground",t.offsetMeters=0);const n=o?l:this._elevationContext.featureExpressionInfoContext;return t.updateFeatureExpressionInfoContext(n,e,this._context.layer),t}prepareSymbolLayerPatch(e){}updateGeometry(e,t){return!1}updateTransform(e,t,i,r){return!1}onRemoveGraphic(e){}_getLayerOpacity(){if(this._context.graphicsCoreOwner&&"fullOpacity"in this._context.graphicsCoreOwner)return this._context.graphicsCoreOwner.fullOpacity??0;const e=this._context.layer.opacity;return e??1}_getCombinedOpacity(e,t=v){const i=this.draped?1:this._getLayerOpacity();return this._drivenProperties.opacity||this._drivenProperties.color?i:e?i*e.a:t.hasIntrinsicColor?i:0}_getCombinedOpacityAndColor(t,r=v){const o=this._getCombinedOpacity(t,r);if(this._drivenProperties.color)return p(null,o);const n=null!=t?e.toUnitRGB(t):i;return p(n,o)}_getVertexOpacityAndColor(e,t,i=null){const r=this._drivenProperties.color?e.color??t:null,o=this._drivenProperties.opacity?e.opacity??t[3]:null,n=p(r,o);return i&&(n[0]*=i,n[1]*=i,n[2]*=i,n[3]*=i),n}isFastUpdatesEnabled(){return null!=this._fastUpdates}updateComplexity(){this.complexity=this.computeComplexity()}computeComplexity(){return n(this.symbol,this.symbolLayer)}globalPropertyChanged(e,t,i){switch(e){case"opacity":return this.layerOpacityChanged(t,i),!0;case"elevationInfo":{const e=this._elevationContext.mode;this._updateElevationContext();return this.layerElevationInfoChanged(t,i,e)!==s.RECREATE}case"slicePlaneEnabled":return this.slicePlaneEnabledChanged(t,i);case"physicalBasedRenderingEnabled":return this.physicalBasedRenderingChanged();case"pixelRatio":return this.pixelRatioChanged;case"skipHighSymbolLods":return this.skipHighSymbolLodsChanged;default:return!1}}get pixelRatioChanged(){return!0}updateGraphics3DGraphicElevationInfo(e,t,i){let r=s.UPDATE;return e?.forEach((e=>{const o=t(e);if(null!=o){const t=e.graphic;this.setGraphicElevationContext(t,o.elevationContext),o.needsElevationUpdates=i(o.elevationContext.mode)}else r=s.RECREATE})),r}applyRendererDiff(e,t){return c.RecreateSymbol}getFastUpdateAttrValues(e){if(!this._fastUpdates)return null;const t=this._fastUpdates.visualVariables,i=t.size?u(t.size.field,e):0,o=t.color?u(t.color.field,e):0,n=t.opacity?u(t.opacity.field,e):0;return r(i,o,n,0)}get draped(){return this._draped}ensureDrapedStatus(e){return null==this._draped?(this._draped=e,!0):(e!==this.draped&&h().warnOnce("A symbol can only produce either draped or non-draped visualizations. Use two separate symbol instances for draped and non-draped graphics if necessary."),!1)}test(){const e=()=>({size:this._fastUpdates?.visualVariables.size?.field??null,color:this._fastUpdates?.visualVariables.color?.field??null,opacity:this._fastUpdates?.visualVariables.opacity?.field??null,rotation:this._fastUpdates?.visualVariables.rotation?.field??null});return{drivenProperties:this._drivenProperties,getVisVarFields:e}}}function f(e,t){const i={color:!1,opacity:!1,opacityAlwaysOpaque:t,size:!1,rotation:!1};return e&&"visualVariables"in e&&e.visualVariables&&e.visualVariables.forEach((e=>{switch(e.type){case"color":if(i.color=!0,e.stops)for(let t=0;t<e.stops.length;t++){const r=e.stops[t].color;r&&r.a<1&&(i.opacityAlwaysOpaque=!1)}break;case"opacity":i.opacity=!0,i.opacityAlwaysOpaque=!1;break;case"size":i.size=!0;break;case"rotation":i.rotation=!0}})),i}const m={mode:"on-the-ground",offset:0,unit:"meters"},g={mode:"absolute-height",offset:0,unit:"meters"},v={hasIntrinsicColor:!1};export{y as Graphics3DSymbolLayer,f as getDrivenProperties};