@arcgis/core 4.26.0-next.20230213 → 4.26.0-next.20230214

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 (46) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{4b41a08d603e846306da.js → 1faf0e2aeabe003e2f64.js} +1 -1
  3. package/assets/esri/core/workers/chunks/8111fc49f8e8f260981d.js +1 -0
  4. package/assets/esri/core/workers/chunks/979d5e22dbdcec90029f.js +1 -0
  5. package/assets/esri/core/workers/chunks/9f8aad19c5973e201604.js +1 -0
  6. package/assets/esri/core/workers/chunks/{21f1d91121d95ef21604.js → bb6e4affafef9855b8fd.js} +1 -1
  7. package/layers/graphics/sources/support/QueryTask.js +1 -1
  8. package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
  9. package/layers/support/rasterFunctions/LocalFunction.js +1 -1
  10. package/layers/support/rasterFunctions/LocalFunctionArguments.js +1 -1
  11. package/layers/support/rasterFunctions/localUtils.js +1 -1
  12. package/package.json +1 -1
  13. package/portal/PortalItem.js +1 -1
  14. package/rest/query/executeQuery.js +1 -1
  15. package/support/revision.js +1 -1
  16. package/views/2d/layers/MediaLayerView2D.js +1 -1
  17. package/views/3d/environment/EnvironmentRenderer.js +1 -1
  18. package/views/3d/interactive/Manipulator3D.js +1 -1
  19. package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
  20. package/views/3d/interactive/editingTools/manipulations/MoveXYAxisManipulation.js +1 -1
  21. package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
  22. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  23. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  24. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  25. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  26. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  27. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  28. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  29. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  30. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  31. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  32. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  33. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  34. package/views/interactive/snapping/FeatureSnappingEngine.js +1 -1
  35. package/views/interactive/snapping/ParallelLineSnapper.js +1 -1
  36. package/views/interactive/snapping/RightAngleSnapper.js +1 -1
  37. package/views/interactive/snapping/RightAngleTriangleSnapper.js +1 -1
  38. package/views/interactive/snapping/Settings.js +1 -1
  39. package/views/interactive/snapping/SnappingAlgorithm.js +1 -1
  40. package/widgets/Editor/EditorViewModel.js +1 -1
  41. package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
  42. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  43. package/widgets/FeatureForm/InputField.js +1 -1
  44. package/assets/esri/core/workers/chunks/52e40e348c27a0e66f9a.js +0 -1
  45. package/assets/esri/core/workers/chunks/8be68f08c270c62e38bb.js +0 -1
  46. package/assets/esri/core/workers/chunks/978220022a8c9a3e9261.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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/PieChartRenderer.js";import"../../../../renderers/Renderer.js";import"../../../../renderers/SimpleRenderer.js";import i from"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import"../../../../symbols.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import r from"../../../../core/Error.js";import s from"../../../../core/Handles.js";import{makeHandle as a}from"../../../../core/handleUtils.js";import n from"../../../../core/Logger.js";import{someMap as o,findInMap as l}from"../../../../core/MapUtils.js";import{isSome as h,unwrapOr as d,isNone as p,destroyMaybe as c,removeMaybe as y,get as m,disposeMaybe as g,unwrap as u}from"../../../../core/maybe.js";import b from"../../../../core/PooledArray.js";import{throwIfAborted as _,eachAlways as f,createDeferred as v,isAbortError as C}from"../../../../core/promiseUtils.js";import{watch as S,when as w,on as G,syncAndInitial as x,whenOnce as R}from"../../../../core/reactiveUtils.js";import{schedule as P}from"../../../../core/scheduling.js";import{property as D}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as E}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as I,isEmpty as U}from"../../../../core/accessorSupport/diffUtils.js";import{s as A,a as O,g as L}from"../../../../chunks/vec3.js";import{c as j}from"../../../../chunks/vec3f64.js";import{projectVectorToVector as V,projectXYZToVector as F,canProjectWithoutEngine as T,projectBuffer as k}from"../../../../geometry/projection.js";import{create as z,center as W,fromRect as M,equals as N}from"../../../../geometry/support/aaBoundingBox.js";import{create as B}from"../../../../geometry/support/aaBoundingRect.js";import{equals as H}from"../../../../geometry/support/spatialReferenceUtils.js";import q from"../../../../layers/Layer.js";import{getObjectId as Y,computeAABB as $,hasGeometry as Z}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as J}from"../../../../layers/graphics/hydratedFeatures.js";import{isSupportedRenderer3D as Q,validateTo3D as K}from"../../../../renderers/support/rendererConversion.js";import{loadArcade as X}from"../../../../support/arcadeOnDemand.js";import{getDefaultSymbol3D as ee}from"../../../../symbols/support/defaults3D.js";import{to3D as ie}from"../../../../symbols/support/symbolConversion.js";import{ViewElevationProvider as te}from"./ElevationQuery.js";import{VisibilityFlag as re,VisibilityGroup as se}from"./enums.js";import{extractExpressionInfo as ae,createContext as ne}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as oe}from"./Graphics3DFeatureStore.js";import le from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as he}from"./Graphics3DSymbolCreationContext.js";import{make as de}from"./Graphics3DSymbolFactory.js";import pe from"./Graphics3DWebStyleSymbol.js";import{GraphicStateTracking as ce}from"./GraphicStateTracking.js";import{computeCentroid as ye}from"./graphicUtils.js";import{ApplyRendererDiffResult as me}from"./interfaces.js";import{LoadStatus as ge}from"./Loadable.js";import{SpatialIndex2D as ue}from"./SpatialIndex2D.js";import{averageSymbolComplexities as be,defaultSymbolComplexity as _e}from"./symbolComplexity.js";import{StageLayerElevationProvider as fe}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as ve}from"../../support/extentUtils.js";import{PropertiesPool as Ce}from"../../support/PropertiesPool.js";import{GridLocalOriginFactory as Se}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{UpdatePolicy as we}from"../../webgl-engine/lib/UpdatePolicy.js";import{WebGLLayer as Ge}from"../../webgl-engine/lib/WebGLLayer.js";import{ImmediateTask as xe,noBudget as Re,TaskPriority as Pe,Task as De}from"../../../support/Scheduler.js";import Ee from"../../../../geometry/Extent.js";import Ie from"../../../../geometry/Point.js";import Ue from"../../../../symbols/LabelSymbol3D.js";import Ae from"../../../../symbols/TextSymbol.js";import Oe from"../../../../symbols/WebStyleSymbol.js";var Le;const je=j(),Ve=z(),Fe="esri.views.3d.layers.graphics.Graphics3DCore",Te=n.getLogger(Fe);let ke=Le=class extends t{get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new ue({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 numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return h(this.currentRenderer)&&"dictionary"===this.currentRenderer.type?we.ASYNC:d(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._graphicsWaitingForSymbol.size>0||this.running||this._elevationAlignment?.updating||h(this._scaleVisibility)&&this._scaleVisibility.updating||h(this._filterVisibility)&&this._filterVisibility.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._updatingPendingLoadedGraphicsChange||this._frameTask.updating||this._loadingSymbols>0)}get running(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating}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,i=e?e.graphics3D.minTotalNumberOfFeatures:0,t=e?e.graphics3D.maxTotalNumberOfFeatures:0,r=e?e.graphics3D.maxTotalNumberOfPrimitives:0,s=this.averageSymbolComplexity,a=Math.max(1,h(s)?s.primitivesPerFeature:1),n=h(s)&&s.drawCallsPerFeature>0?t/s.drawCallsPerFeature*.3:t,o=Math.ceil(r/a),l=Math.max(i,Math.min(t,o,n)),d=this._get("displayFeatureLimit");return d&&d.minimumTotalNumberOfFeatures===i&&d.maximumTotalNumberOfFeatures===t&&d.maximumTotalNumberOfPrimitives===r&&d.averageSymbolComplexity===s&&d.maximumNumberOfFeatures===l?d:{minimumTotalNumberOfFeatures:i,maximumTotalNumberOfFeatures:t,maximumTotalNumberOfPrimitives:r,averageSymbolComplexity:s,maximumNumberOfFeatures:l}}get averageSymbolComplexity(){const e=be(this._symbolComplexities),i=this._get("averageSymbolComplexity");return 0===e.numComplexities||h(i)&&(e.estimated&&(i.primitivesPerFeature>=e.primitivesPerFeature||i.primitivesPerCoordinate>=e.primitivesPerCoordinate||i.drawCallsPerFeature>=e.drawCallsPerFeature)||i.primitivesPerFeature===e.primitivesPerFeature&&i.primitivesPerCoordinate===e.primitivesPerCoordinate&&i.drawCallsPerFeature===e.drawCallsPerFeature)?i:e}get usedMemory(){const e=h(this.averageSymbolComplexity)&&this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel*this._numberOfGraphics:0,i=this._getSymbolComplexitiesUsed().reduce(((e,i)=>e+i.memory.resourceBytes),0);return this._usedMemory+e+i}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(h(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){if("web-style"===e.type)return e.clone();const i=this._symbolConversionCache.get(e.id);if(h(i))return i;const t=ie(e,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(e)}),r=t.symbol||null;return p(r)&&t.error&&Te.error(t.error.message),this._symbolConversionCache.set(e.id,r),r}_getSymbolComplexitiesUsedOrRenderer(e){if(p(e))return[];const i=e.getSymbols(),t="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!(t||i&&i.length))return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(t);h(s)&&r.push(s);for(const a of i){const e=this._getSymbolComplexityUsedOrRenderer(a);h(e)&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(p(e))return null;const i=this._symbols.get(e.id);if(h(i))return i.complexity;const t=this._getConvertedSymbol(e);return h(t)?_e(t):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach((i=>{h(i)&&e.push(i.complexity)})),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new Ce({computedExtent:Ee},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._handles=new s,this._frameTask=xe,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=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 b({allocator:e=>e||new We,deallocator:e=>(e.clear(),e)}),this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new b,this.preferredUpdatePolicy=we.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.symbolCreationContext=new he(e.owner.view.resourceController.scheduler,((e,i)=>this._frameTask.schedule(e,i)))}initialize(){this._featureStore=new oe({objectIdField:this.owner.layer&&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,i,t)=>this.spatialIndex.queryGraphicUIDsInExtent(e,i,t),{componentFactories:i}=this;if(h(i.elevationAlignment)){const t=i.elevationAlignment(this,e);this._elevationAlignment=t}if(h(i.scaleVisibility)){const t=i.scaleVisibility(this,e);this._scaleVisibility=t}if(h(i.filterVisibility)){const e=i.filterVisibility({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities((i=>i.setVisibilityFlag(re.FILTER,e(Y(i.graphic,this._objectIdField)),se.GRAPHIC))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities((i=>i.setVisibilityFlag(re.FILTER,e,se.GRAPHIC))),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities((e=>e.clearVisibilityFlag(re.FILTER)))});this._filterVisibility=e}if(h(i.deconflictor)){const e=i.deconflictor(this);this._deconflictor=e}if(h(i.labeler)&&h(this._scaleVisibility)){const e=i.labeler(this,this._scaleVisibility);this._labeler=e}if(h(i.objectStates)){const e=i.objectStates(this);this._objectStates=e}this._initializeAbortController=new AbortController,this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,i=this.owner.view;this._viewElevationProvider=new te(this._viewSpatialReference,i),this._initializeStage(i,this.layer.uid);const t=i.sharedSymbolResources;this.symbolCreationContext.sharedResources=t,this._sharedSymbolResourcesOwnerHandle=t.addGraphicsOwner(this.owner),h(this.currentRenderer)&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=t.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=i.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new Se(i.renderSpatialReference),this.symbolCreationContext.elevationProvider=i.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const r=ae(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await ne(r,this._viewSpatialReference,e,Te),_(e),this.symbolCreationContext.screenSizePerspectiveEnabled=i.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=i.basemapTerrain.overlayManager.registerGeometryDrapeSource(e),this._handles.add(a((()=>i.basemapTerrain.overlayManager.unregisterDrapeSource(e))))}this._handles.add([S((()=>this.suspendedOrOutsideOfView),(()=>this._frameTask.reschedule((()=>this._updateLayerVisibility())))),S((()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view.screenSizePerspectiveEnabled]),(()=>{const e=i.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())})),S((()=>this.owner.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(!!e))),S((()=>this.owner.view.state?.rasterPixelRatio),(()=>this._pixelRatioChange())),S((()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._physicalBasedRenderingChange(e))),S((()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods),(e=>this._skipHighSymbolLoDsChange(e))),w((()=>i.basemapTerrain?.tilingScheme),(e=>{if(!e.spatialReference.equals(this.symbolCreationContext.overlaySR)&&h(i.basemapTerrain.spatialReference)&&(this.symbolCreationContext.overlaySR=i.basemapTerrain.spatialReference),this._handles.has("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this._handles.add([G(e,"change",(e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}),{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}}),{initial:!0}),S((()=>this.effectiveUpdatePolicy),(e=>{h(this.stageLayer)&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=this.effectiveUpdatePolicy===we.ASYNC,e===we.SYNC&&this.runTask(Re)}),x)]),this._frameTask=i.resourceController.scheduler.registerTask(Pe.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this._handles.add(S((()=>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)}destroy(){this._abortInitialize(),this._abortRendererChange(),this._abortElevationInfoChange(),this._frameTask.remove(),this._frameTask=xe,this.owner.view.deconflictor.removeGraphicsOwner(this),this.owner.view.labeler.removeGraphicsOwner(this),this._elevationAlignment=c(this._elevationAlignment),this._scaleVisibility=c(this._scaleVisibility),this._filterVisibility=c(this._filterVisibility),this._deconflictor=null,this._labeler=null,this._objectStates=c(this._objectStates),this.clear(),this._featureStore=c(this._featureStore),this._updatingPendingLoadedGraphicsChange=y(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=c(this._graphicStateTracking),this.stage&&(this.stage.remove(this.stageLayer),this.stageLayer=null,this.stage=null),this._handles=c(this._handles),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=y(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=c(this._propertiesPool),this._pendingUpdatesPool=null,this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=c(this._spatialIndex)}clear(){this._objectStates?.allGraphicsDeleted(),h(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(c),this._symbols.clear(),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("updating"),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed")}_initializeStage(e,i){this.stage=e._stage,this.stageLayer=new Ge({pickable:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},i),this.stage.add(this.stageLayer);const t=this.stageLayer.events;t.on("objectTransformation",(e=>this.notifyGraphicGeometryChanged(e.metadata.graphicUid))),t.on("visibilityChanged",(e=>this.notifyGraphicVisibilityChanged(e.metadata.graphicUid))),t.on("objectGeometryAdded",(e=>this.notifyGraphicGeometryChanged(e.object.metadata.graphicUid))),t.on("objectGeometryRemoved",(e=>this.notifyGraphicGeometryChanged(e.object.metadata.graphicUid))),t.on("objectGeometryUpdated",(e=>this.notifyGraphicGeometryChanged(e.object.metadata.graphicUid)))}notifyGraphicGeometryChanged(e){if(p(this._graphicStateTracking)||p(e))return;const i=this.graphics3DGraphics.get(e);i&&this._graphicStateTracking.updateGraphicGeometry(i)}notifyGraphicVisibilityChanged(e){if(p(this._graphicStateTracking)||p(e))return;const i=this.graphics3DGraphics.get(e);i&&this._graphicStateTracking.updateGraphicVisibility(i)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,i=this._numberOfGraphics>e*Me,t=!this.suspendedOrOutsideOfView&&!i;t!==this._visible&&(this._visible=t,t?(this.stageLayer.pickable=!0,this.updateAllGraphicsVisibility()):(this.stageLayer.pickable=!1,this._hideAllGraphics()),this._updateStageLayerVisibility())}_updateStageLayerVisibility(){this.stageLayer.visible=this._visible&&(null==this.layer.opacity||this.layer.opacity>0)}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,i=this.owner.layer&&this.owner.layer.objectIdField){return Y(e,i)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer&&this.owner.layer.objectIdField;if(!e)return;const i=new Map;return this.graphics3DGraphics.forEach((t=>{if(!t)return;const r=t.graphic,s=this._getGraphicObjectID(r,e);h(s)&&i.set(s,t)})),i}get labelsEnabled(){return!(!this._labeler||!this._labeler.layerLabelsEnabled())}async updateLabelingInfo(e){const i=this._deconflictor&&this._deconflictor.labelingInfoChange(e),t=this._labeler&&this._labeler.labelingInfoChange(e);await f([i,t])}updateVisibilityInfo(){this._deconflictor&&this._deconflictor.labelingInfoChange(),this._labeler&&this._labeler.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=0,i=0;return o(this._symbols,((t,r)=>{if(h(t)){const s=t.getFastUpdateStatus();if(s.loading>0)return!0;this._graphicsBySymbol.has(r)&&(i+=s.fast,e+=s.slow)}return!1}))?"unknown":i>=0&&0===e?"fast":e>=0&&0===i?"slow":"mixed"}runTask(e){if(this._frameTask.processQueue(e),this._applyPendingUpdates(e),this.notifyChange("running"),this.running||this.notifyChange("updating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return De.YIELD}setObjectIdVisibility(e,i){i?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const t=this._findGraphics3DGraphicByObjectId(e);h(t)&&this._updateUserVisibility(t)}_findGraphics3DGraphicByObjectId(e){return l(this.graphics3DGraphics,(i=>this._getGraphicObjectID(i.graphic)===e))}_updateUserVisibility(e){if(p(e))return!1;const i=e.graphic,t=this._getGraphicObjectID(i),r=i.visible&&!this.owner.suspended&&(p(t)||!this._objectIdInvisibleSet.has(t));return e.setVisibilityFlag(re.USER_SETTING,r,se.GRAPHIC)}_whenGraphics3DGraphic(e){const i=this.graphics3DGraphics.get(e.uid);if(i)return Promise.resolve(i);const t=this._whenGraphics3DGraphicRequests[e.uid];if(t)return t.promise;const r=v();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,i){const t=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,i,s)=>k(e,r,i,e,t,i,s),n=(e,i,r)=>k(e,s,i,e,t,i,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:!!h(i)&&!!i.useViewElevation,minDemResolution:h(i)?i.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,m(i,"signal"));if(!l)return null;const p=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){W(p,je);const i=d(e.getElevation(je[0],je[1],0,t,"ground"),0);p[2]=Math.min(p[2],i),p[5]=Math.max(p[5],i)}}return{boundingBox:p,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,i){await R((()=>this.owner?.loadedGraphics));const t=this.owner.layer&&this.owner.layer.objectIdField,s=this.owner.loadedGraphics.find((i=>i===e||null!=t&&null!=i.attributes&&e.attributes&&i.attributes[t]===e.attributes[t]));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,i)}computeAttachmentOrigin(e,i){const t=this.graphics3DGraphics.get(e.uid);if(!t)return null;const r=t.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;A(Ne,0,0,0);let s=0;if(r.render.num>0){if(!V(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,Be,i))return null;O(Ne,Ne,Be),s++}if(r.draped.num>0){const[e,t]=r.draped.origin,a=d(this._viewElevationProvider.getElevation(e,t,"ground"),0);if(A(Be,e,t,a),!V(Be,this._viewElevationProvider.spatialReference,Be,i))return null;O(Ne,Ne,Be),s++}return s>1&&L(Ne,Ne,1/s),new Ie({x:Ne[0],y:Ne[1],z:Ne[2],spatialReference:i})}getSymbolLayerSize(e,i){const t=this._symbols.get(e.id);if(p(t))throw new r("internal:symbol-not-part-of-view","Symbol is not part of this view");const s=e.symbolLayers.indexOf(i);if(-1===s)throw new r("internal:missing-symbol-layer","Symbol layer is not in symbol");const a=t.getSymbolLayerSize(s);if(p(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 i=e.graphic.uid,t=this.graphics3DGraphics.get(i);if(!p(t)||!p(this._graphicsWithoutSymbol.get(i)))switch(e.property){case"visible":this._graphicUpdateVisibleHandler(t);break;case"geometry":this._graphicUpdateGeometryHandler(t,e);break;case"symbol":this._graphicUpdateSymbolHandler(t,e);break;case"attributes":break;case"transform":this._graphicUpdateTransformHandler(t,e)}}_graphicUpdateGeometryHandler(e,i){const t=i.graphic.geometry;if(p(t))return void this._recreateGraphic(i.graphic);if(p(e)){const e=i.graphic.symbol&&i.graphic.symbol.id;if(e){const i=this._symbols.get(e);if(h(i)&&i.loadStatus===ge.LOADING)return}return void this._recreateGraphic(i.graphic)}const r=e.graphics3DSymbol;!p(i.newValue)&&r.updateGeometry(e,i.newValue)||this._recreateGraphic(e.graphic),this._expandComputedExtent(t)}_graphicUpdateSymbolHandler(e,i){const t=i.graphic,r=h(e)?e.graphics3DSymbol:h(i.oldValue)?this._symbols.get(i.oldValue.id):null;if(p(r)||p(i.newValue))return void this._recreateGraphic(t);const s=r.symbol,a=this._getConvertedSymbol(i.newValue);if(h(a)&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(t);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(t);const o=I(s,a);if(p(o))return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!U(l.diff))return void this._recreateGraphic(t);const d=this._getRenderingInfo(t);if(p(d))return void this._recreateGraphic(t);const c=r.extentPadding;for(const h of l.symbolStatePatches)h();if(c!==r.extentPadding&&this._recomputeExtentPadding(),h(e))for(const h of l.graphics3DGraphicPatches)h(e,d);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty())}_graphicUpdateTransformHandler(e,i){}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,this.effectiveUpdatePolicy===we.SYNC&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const i=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,i),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("updating"),i}_endGraphicUpdate(e){e&&(this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("updating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach((i=>{h(i)&&(e=Math.max(e,i.extentPadding))})),this._set("extentPadding",e)}_expandComputedExtent(e){const i=Ve,t=e.spatialReference;$(e,i);const r=this._viewSpatialReference,s=Le.tmpVec;if(H(t,r)||F(i[0],i[1],0,t,s,r)&&(i[0]=s[0],i[1]=s[1],F(i[3],i[4],0,t,s,r),i[3]=s[0],i[4]=s[1]),!(isFinite(i[0])&&isFinite(i[3])&&isFinite(i[1])&&isFinite(i[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(i[2])&&isFinite(i[5]),l=o&&(!a||null==a.zmin||i[2]<a.zmin),h=o&&(!a||null==a.zmax||i[5]>a.zmax);if(a){(i[0]<a.xmin||i[1]<a.ymin||i[3]>a.xmax||i[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(i[0],a.xmin),n.ymin=Math.min(i[1],a.ymin),n.xmax=Math.max(i[3],a.xmax),n.ymax=Math.max(i[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=i[0],n.ymin=i[1],n.xmax=i[3],n.ymax=i[4],n.spatialReference=r;n&&(l&&(n.zmin=i[2]),h&&(n.zmax=i[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 i=ae(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await ne(i,this._viewSpatialReference,e.signal,Te),_(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("elevationInfo",i)?i.forEach((e=>{const i=e.graphic,t=e.labelLayers;for(const r of t){r.graphics3DSymbolLayer.updateGraphicElevationContext(i,r)}})):this._recreateSymbol(t)})),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=g(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new fe({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),h(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=g(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:i,view:t}=this.owner,r=t.basemapTerrain.tilingScheme&&i&&i.length?i.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 i=this._graphicsBySymbol.get(e),t=[];i&&(i.forEach(((e,i)=>{const r=e.usedMemory;this._conditionalRemove(e,i),this._spatialIndex?.remove(e),t.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(i,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed")})),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);c(r),this._symbols.delete(e),this.add(t)}_recreateGraphicsForSymbol(e){const i=this._graphicsBySymbol.get(e);if(i){const e=[];i.forEach((i=>e.push(i.graphic))),this.recreateGraphics(e)}}_conditionalRemove(e,i){this._graphicsDrapedUids.delete(i),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),h(this._graphicStateTracking)&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain&&this.owner.view.basemapTerrain.tilingScheme?(this._updatePolicyForGraphics(e)===we.ASYNC?this._addDelayed(e):this._addImmediate(e),this.notifyChange("updating")):Te.error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(this.effectiveUpdatePolicy===we.SYNC&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const i of e)if(h(i.geometry)&&"mesh"===i.geometry.type&&!i.geometry.loaded)return we.ASYNC;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const i of e)this._addGraphic(i,this._getRenderingInfo(i,Te),we.SYNC);this._cleanupSymbols(),this._labeler&&(this.owner.view.labeler.setDirty(),this._cleanupSymbols()),this.owner.view.deconflictor.setDirty()}_addDelayed(e){for(const i of e){const e=i.uid;let t=this._pendingUpdates.get(e);t?t.add?t.state!==ze.NEW&&t.abortController?.abort():this._pendingAdds++:(t=this._pendingUpdatesPool.pushNew(),this._pendingAdds++,this._pendingUpdates.set(e,t)),t.add=i}this.notifyChange("running"),this.notifyChange("updatingRemaining")}remove(e){this.effectiveUpdatePolicy===we.ASYNC?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("updating")}_removeImmediate(e){for(const i of e)this._removeGraphic(i);this._cleanupSymbols(),this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty()}_removeDelayed(e){for(const i of e){const e=i.uid,t=this._pendingUpdates.get(e);if(t)t.add&&(t.remove?t.add=null:this._pendingUpdates.delete(e),t.state===ze.LOADING&&t.abortController?.abort(),this._pendingAdds--);else{const t=this._pendingUpdatesPool.pushNew();t.remove=i,this._pendingUpdates.set(e,t),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("updatingRemaining")}_finishPendingUpdates(){this._pendingUpdatesPool.clear(),this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&Te.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[i,t]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(t.remove&&!t.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(t.remove),t.remove=null,this._pendingUpdates.delete(i),0===this._pendingRemoves))break}}for(const[i,t]of this._pendingUpdates){if(e.done)break;t.add&&t.state===ze.NEW&&this._processPendingUpdateNew(t);let r=this.effectiveUpdatePolicy;if(!t.remove||t.add&&t.state!==ze.READY||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(t.remove),t.remove=null,r=we.SYNC),t.add)switch(t.state){case ze.READY:this._addGraphic(t.add,t.renderingInfo,r),t.add=null,this._pendingAdds--,e.madeProgress();break;case ze.REJECTED:t.add=null,this._pendingAdds--;case ze.LOADING:}null==t.remove&&null==t.add&&this._pendingUpdates.delete(i)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("running"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=ze.READY);const i=e.add.geometry;h(i)&&"mesh"===i.type&&!i.loaded?this._processPendingUpdateNewMesh(e,i):this._processPendingUpdateNewRenderingInfo(e)}async _processPendingUpdateNewMesh(e,i){e.state=ze.LOADING,e.abortController=new AbortController;const t=e.abortController.signal;try{await i.load({signal:t})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,i){e.abortController=null,C(i)?e.state=ze.NEW:e.state=ze.REJECTED}async _processPendingUpdateNewRenderingInfo(e){if(p(this.layer.renderer)||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add,Te),void(e.state=ze.READY);e.state=ze.LOADING,e.abortController=new AbortController;let i=null;try{i=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(t){return e.abortController=null,void(C(t)?e.state=ze.NEW:e.state=ze.REJECTED)}p(i)||p(i.symbol)?(Te&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,Te.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=i,e.state=ze.READY}_addGraphic(e,i,t){if(this._graphicsWithoutSymbol.set(e.uid,e),p(i)||p(i.symbol)||!Z(e))return;h(this.stage.renderView.objectAndLayerIdRenderHelper)&&this.setUidToIdOnAdd&&this.stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.layer.uid,!!this.layer.popupEnabled);const r=i.symbol,s=this.getOrCreateGraphics3DSymbol(r,i.renderer);if(p(s))return;this._expandComputedExtent(e.geometry);const a=this._beginGraphicUpdate(e),n=new le(e,i,this.layer);let o=!1;const l=e=>{e===s.symbol.id&&(o=!0)};this._whenSymbolRemoved.push(l);const d=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(l);if(this._graphicsWaitingForSymbol.get(e.uid)!==a||o||s.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==s.symbol.id)--s.referenced,this._cleanupSymbols();else{const i=this._createGraphics3DGraphic(s,n);this._spatialIndex&&h(i)&&this._spatialIndex.add(i),--s.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this._labeler&&this.owner.view.labeler.setDirty()},c=i=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(l),o||(C(i)?this.add([e]):s.destroyed||this._endGraphicUpdate(e)))};++this._loadingSymbols,t===we.ASYNC?s.load((()=>this._frameTask.schedule(d)),(e=>this._frameTask.schedule((()=>c(e))))):s.load(d,c)}_removeGraphic(e){const i=e.uid,t=this.graphics3DGraphics.get(i);if(t){t.graphics3DSymbol.onRemoveGraphic(t);const e=t.usedMemory,r=t.isElevationSource;this._conditionalRemove(t,i),this._spatialIndex?.remove(t);const s=t.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(i),this._graphicsWithoutSymbol.delete(i),this._removeGraphics3DGraphic(i,e,r),t.destroy(),this._featureStore.events.emit("changed")}else this._graphicsWithoutSymbol.delete(i),this._graphicsWaitingForSymbol.delete(i),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("updating"))}_hasLabelingContext(e){if(e instanceof Ue||e instanceof Ae){const i=this.symbolCreationContext.layer;return!!i.labelingInfo&&i.labelingInfo.some((i=>i.symbol===e))}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof Ue&&!this._hasLabelingContext(e))||(Te.error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,i){const t=e.geometry;if(p(t))return i&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!T(t.spatialReference,this._viewSpatialReference))return i&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&h(e.symbol))return i&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?J(e,this.layer):e;let s;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||h(this.currentRenderer)))s=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{s={symbol:r.symbol||ee(r.geometry)}}return p(s)||p(s.symbol)?(i&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):s}_getRenderingInfoAsync(e,i){const t=e.geometry;if(p(t))return Te&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,Te.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&h(e.symbol))return Te&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,Te.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?J(e,this.layer):e;return this.owner.getRenderingInfoAsync(r,this.currentRenderer,this._arcadeOnDemand,i)}_createGraphics3DSymbol(e,i){if(!this._hasValidSymbolCreationContext(e))return null;const t=this._getConvertedSymbol(e);if(!t)return null;let r;if(h(i)&&"backgroundFillSymbol"in i&&i.backgroundFillSymbol){const e=ie(i.backgroundFillSymbol,{ignoreDrivers:!0});h(e.symbol)&&"web-style"!==e.symbol.type&&"cim"!==e.symbol.type&&(r=e.symbol.symbolLayers)}const s=de(t,this.symbolCreationContext,r);return s.load((()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")}),(()=>{})),s}getOrCreateGraphics3DSymbol(e,i){let t=this._symbols.get(e.id);return void 0===t&&(t=e instanceof Oe?new pe(e,(e=>this._frameTask.schedule(e)),(e=>this._createGraphics3DSymbol(e,i))):this._createGraphics3DSymbol(e,i),this._symbols.set(e.id,t)),h(t)&&++t.referenced,t}trackGraphicState(e){return p(this._graphicStateTracking)&&(this._graphicStateTracking=new ce(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,i,t=!1){this._usedMemory-=i,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,t&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,i){const t=i.graphic;if(this._graphicsWithoutSymbol.delete(t.uid),!this._symbols.has(e.symbol.id))return this.add([t]),null;if(this.graphics3DGraphics.has(t.uid))return null;const r=e.createGraphics3DGraphic(i);if(p(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(t.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(t.uid),r.centroid=null,h(t.geometry)&&"point"!==t.geometry.type&&(r.centroid=ye(t.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),h(this._scaleVisibility)&&this._scaleVisibility.updateVisibility(r),h(this._filterVisibility)){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(re.FILTER,e,se.GRAPHIC),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),this._deconflictor&&this.owner.view.deconflictor.setInitialIconVisibilityFlag(this,r),r.initialize(this.stage,this.stageLayer,this.owner),h(this._graphicStateTracking)&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[t.uid];return a&&(delete this._whenGraphics3DGraphicRequests[t.uid],a.resolve(r)),r}_abortRendererChange(){this._rendererChangeAbortController&&(this._rendererChangeAbortController.abort(),this._rendererChangeAbortController=null)}async rendererChange(e){if(this._abortRendererChange(),e!==this.currentRenderer)if(this._validateRenderer(e),p(e)&&this._currentRendererChange(null,!1),Q(e))if(h(e)&&e.arcadeRequired){const i=new AbortController;this._rendererChangeAbortController=i;const{arcadeUtils:t}=await this._ensureArcade();_(i);const r=t.hasGeometryOperations(e);r&&(await t.enableGeometryOperations(),_(i)),this.effectiveUpdatePolicy===we.ASYNC?await this._frameTask.schedule((()=>this._currentRendererChange(e,r)),i.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(this.effectiveUpdatePolicy===we.ASYNC){const i=new AbortController;this._rendererChangeAbortController=i,await this._frameTask.schedule((()=>this._currentRendererChange(e,!1)),i.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return p(this._arcadeOnDemand)?(this._arcadeOnDemand=await X(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,i){this.currentRenderer=e,this.rendererHasGeometryOperations=i,this.symbolCreationContext.arcade=u(this._arcadeOnDemand);const t=this.symbolCreationContext.renderer;if(e===t)return;if(this._symbolConversionCache.clear(),p(e))return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=I(t,e);this._updateUnchangedSymbolMappings(r,e,t),this.symbolCreationContext.renderer=e,p(r)||("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,t)?this._volatileGraphicsUpdated():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const i in e.diff)switch(i){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[i];break;default:return!0}return!1}_applySymbolSetDiff(e,i,t){e=e||[],i=i||[];const r=[];for(const s of i){const i=this._graphicsBySymbol.get(s.id);i&&i.forEach(((a,n)=>{const o=a.graphic,l=this.layer instanceof q?this.layer:null,h=u(this._arcadeOnDemand);if(s===t.defaultSymbol&&t.getSymbol(J(o,l),{arcade:h})===t.defaultSymbol)return;const d=a.usedMemory;e.length||t.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),i.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&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty()}_applyUniqueValueRendererDiff(e,i,t){const r=e.diff.defaultSymbol,s=e.diff.uniqueValueInfos;if(r||s){const a=s?s.added.map((e=>e.symbol)).filter(h):[],n=s?s.removed.map((e=>e.symbol)).filter(h):[];if(s)for(let e=0;e<s.changed.length;e++)a.push(s.changed[e].newValue.symbol),n.push(s.changed[e].oldValue.symbol);return r?(t.defaultSymbol&&n.push(t.defaultSymbol),i.defaultSymbol&&a.push(i.defaultSymbol)):t.defaultSymbol&&a.length&&n.push(i.defaultSymbol),this._applySymbolSetDiff(a,n,i),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,i,t){if("unique-value"!==i?.type||"unique-value"!==t?.type||h(e)&&"partial"!==e.type)return[];const r=e=>h(e)?e.id:null,s=e&&e.diff,a=s&&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 t.uniqueValueInfos??[]){const t=r(e.symbol),s=i.uniqueValueInfos?.find((i=>i.value===e.value));s&&t!==r(s.symbol)&&o.push({oldId:t,newId:r(s.symbol)})}}return!a&&t.defaultSymbol&&o.push({oldId:r(t.defaultSymbol),newId:r(i.defaultSymbol)}),o}_updateSymbolMapping(e,i){const t=h(i)&&i?"string"==typeof i?i:i.id:null;if(p(e)||e===t)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(t,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(t,s),h(s))){const e="string"==typeof i?null:i;h(e)?s.symbol=e:s.symbol.id=t}}_updateUnchangedSymbolMappings(e,i,t){const r=this._calculateUnchangedSymbolMapping(e,i,t);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,t,r){if(this._diffHasSymbolChange(e))return!1;if(t instanceof i&&r instanceof i&&this._applyUniqueValueRendererDiff(e,t,r)&&0===Object.keys(e.diff).length)return!0;for(const[i]of this._graphicsBySymbol){const r=this._symbols.get(i);if(h(r))switch(r.applyRendererDiff(e,t)){case me.Recreate_Symbol:this._recreateSymbol(i);break;case me.Recreate_Graphics:this._recreateGraphicsForSymbol(i);case me.Fast_Update:}}return!0}opacityChange(){this.forEachGraphics3DSymbol(((e,i)=>e.globalPropertyChanged("opacity",i))),this._updateStageLayerVisibility()}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol(((e,i)=>e.globalPropertyChanged("slicePlaneEnabled",i))),this._deconflictor&&this._deconflictor.slicePlaneEnabledChange(),this._labeler&&this._labeler.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",i)||this._recreateSymbol(t)}))}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol(((e,i,t)=>this._recreateSymbol(t)))}_pixelRatioChange(){this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("pixelRatio",i)||this._recreateSymbol(t)}))}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=P((()=>{this._updatingPendingLoadedGraphicsChange=null}))}setClippingExtent(e,i){const t=this.symbolCreationContext.clippingExtent,r=B();return ve(e,r,i)?this.symbolCreationContext.clippingExtent=M(z(),r):this.symbolCreationContext.clippingExtent=null,!N(this.symbolCreationContext.clippingExtent,t)}modifyGraphics3DGraphicVisibilities(e){let i=!1;this.graphics3DGraphics.forEach((t=>{e(t)&&(i=!0)})),i&&(this.owner.view.labeler?.setDirty(),this.owner.view.deconflictor.setDirty())}forEachGraphics3DSymbol(e){for(const[i,t]of this._symbols){if(p(t))return;e(t,this._graphicsBySymbol.get(i)||He,i)}}updateAllGraphicsVisibility(){h(this._filterVisibility)&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities((e=>{const i=this._updateUserVisibility(e),t=h(this._scaleVisibility)&&this._scaleVisibility.updateVisibility(e);return i||t}))}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(re.USER_SETTING,!1,se.GRAPHIC)))}_validateRenderer(e){const i=K(e,{geometryType:this.layer?.geometryType});if(i){const e=`Renderer for layer '${this.layer.title?`${this.layer.title}, `:""}, id:${this.layer.id}' is not supported in a SceneView`;Te.warn(e,i.message)}}_volatileGraphicsUpdated(){this._labeler?.reset(),this.stageLayer.shaderTransformationChanged(),this.notifyChange("updating")}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach(((i,t)=>{if(p(i)||i.referenced>0)return;const r=this._graphicsBySymbol.get(t);r&&0!==r.size||(this._graphicsBySymbol.delete(t),this._symbols.delete(t),c(i),e=!0)})),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){return{snapshotInternals:()=>({graphics:[...this.graphics3DGraphics.keys()].sort(),symbols:[...this._symbols.keys()].sort(),graphicsBySymbol:[...this._graphicsBySymbol.keys()].sort().map((e=>({symbolId:e,graphics:[...this._graphicsBySymbol.get(e).keys()].sort()}))),graphicsWithoutSymbol:[...this._graphicsWithoutSymbol.keys()].sort(),graphicsDrapedUids:[...this._graphicsDrapedUids].sort(),pendingUpdates:this._pendingUpdates}),symbols:this._symbols,filterVisibility:this._filterVisibility,numPending:this._pendingUpdates.size,forceUpdatePolicy:e=>{this._forcedUpdatePolicy=e}}}get performanceInfo(){return{visible:this.graphics3DGraphics.size,missing:this._graphicsWithoutSymbol.size,pending:this._pendingUpdates.size}}};var ze;ke.tmpVec=j(),e([D({readOnly:!0})],ke.prototype,"computedExtent",void 0),e([D()],ke.prototype,"currentRenderer",void 0),e([D()],ke.prototype,"rendererHasGeometryOperations",void 0),e([D()],ke.prototype,"_frameTask",void 0),e([D({readOnly:!0})],ke.prototype,"_viewSpatialReference",null),e([D()],ke.prototype,"_rendererChangeAbortController",void 0),e([D()],ke.prototype,"_elevationInfoChangeAbortController",void 0),e([D()],ke.prototype,"_initializeAbortController",void 0),e([D()],ke.prototype,"_elevationAlignment",void 0),e([D()],ke.prototype,"_scaleVisibility",void 0),e([D()],ke.prototype,"_filterVisibility",void 0),e([D()],ke.prototype,"_initializePromise",void 0),e([D()],ke.prototype,"_spatialIndex",void 0),e([D({readOnly:!0})],ke.prototype,"extentPadding",void 0),e([D()],ke.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([D()],ke.prototype,"_featureStore",void 0),e([D()],ke.prototype,"_deconflictor",void 0),e([D()],ke.prototype,"_labeler",void 0),e([D()],ke.prototype,"_objectStates",void 0),e([D()],ke.prototype,"_loadingSymbols",void 0),e([D()],ke.prototype,"preferredUpdatePolicy",void 0),e([D()],ke.prototype,"_forcedUpdatePolicy",void 0),e([D({readOnly:!0})],ke.prototype,"effectiveUpdatePolicy",null),e([D({constructOnly:!0})],ke.prototype,"elevationFeatureExpressionEnabled",void 0),e([D({constructOnly:!0})],ke.prototype,"owner",void 0),e([D({constructOnly:!0})],ke.prototype,"layer",void 0),e([D({constructOnly:!0})],ke.prototype,"graphicSymbolSupported",void 0),e([D({constructOnly:!0})],ke.prototype,"getRenderingInfoWithoutRenderer",void 0),e([D({constructOnly:!0})],ke.prototype,"componentFactories",void 0),e([D({constructOnly:!0})],ke.prototype,"setUidToIdOnAdd",void 0),e([D()],ke.prototype,"featureStore",null),e([D()],ke.prototype,"initializePromise",null),e([D()],ke.prototype,"scaleVisibility",null),e([D()],ke.prototype,"elevationAlignment",null),e([D()],ke.prototype,"objectStates",null),e([D()],ke.prototype,"filterVisibility",null),e([D({readOnly:!0})],ke.prototype,"updating",null),e([D({readOnly:!0})],ke.prototype,"running",null),e([D({readOnly:!0})],ke.prototype,"suspendedOrOutsideOfView",null),e([D({readOnly:!0,dependsOn:[]})],ke.prototype,"updatingRemaining",null),e([D({readOnly:!0,dependsOn:["owner.view.qualitySettings.graphics3D.maxTotalNumberOfPrimitives","owner.view.qualitySettings.graphics3D.maxTotalNumberOfFeatures","averageSymbolComplexity"]})],ke.prototype,"displayFeatureLimit",null),e([D({readOnly:!0,dependsOn:[]})],ke.prototype,"averageSymbolComplexity",null),e([D({constructOnly:!0})],ke.prototype,"hasZ",void 0),e([D({constructOnly:!0})],ke.prototype,"hasM",void 0),e([D()],ke.prototype,"_objectIdField",null),ke=Le=e([E(Fe)],ke),function(e){e[e.NEW=0]="NEW",e[e.LOADING=1]="LOADING",e[e.READY=2]="READY",e[e.REJECTED=3]="REJECTED"}(ze||(ze={}));class We{constructor(){this.add=null,this.renderingInfo=null,this.state=ze.NEW,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=ze.NEW,this.abortController=null,this.remove=null}}const Me=10,Ne=j(),Be=j(),He=new Map;export{ke as Graphics3DCore};
5
+ import{_ as e}from"../../../../chunks/tslib.es6.js";import"../../../../geometry.js";import"../../../../renderers/ClassBreaksRenderer.js";import"../../../../renderers/DictionaryRenderer.js";import"../../../../renderers/DotDensityRenderer.js";import"../../../../renderers/HeatmapRenderer.js";import"../../../../renderers/PieChartRenderer.js";import"../../../../renderers/Renderer.js";import"../../../../renderers/SimpleRenderer.js";import i from"../../../../renderers/UniqueValueRenderer.js";import"../../../../renderers/support/jsonUtils.js";import"../../../../symbols.js";import t from"../../../../core/Accessor.js";import"../../../../core/has.js";import r from"../../../../core/Error.js";import s from"../../../../core/Handles.js";import{makeHandle as a}from"../../../../core/handleUtils.js";import n from"../../../../core/Logger.js";import{someMap as o,findInMap as l}from"../../../../core/MapUtils.js";import{isSome as h,unwrapOr as d,isNone as p,destroyMaybe as c,removeMaybe as y,get as m,disposeMaybe as g,unwrap as u}from"../../../../core/maybe.js";import b from"../../../../core/PooledArray.js";import{throwIfAborted as _,eachAlways as f,createDeferred as v,isAbortError as C}from"../../../../core/promiseUtils.js";import{watch as S,when as w,on as G,syncAndInitial as x,whenOnce as P}from"../../../../core/reactiveUtils.js";import{schedule as R}from"../../../../core/scheduling.js";import{property as D}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import{subclass as E}from"../../../../core/accessorSupport/decorators/subclass.js";import{diff as I,isEmpty as U}from"../../../../core/accessorSupport/diffUtils.js";import{s as A,a as O,g as L}from"../../../../chunks/vec3.js";import{c as j}from"../../../../chunks/vec3f64.js";import{projectVectorToVector as V,projectXYZToVector as F,canProjectWithoutEngine as T,projectBuffer as k}from"../../../../geometry/projection.js";import{create as z,center as W,fromRect as M,equals as N}from"../../../../geometry/support/aaBoundingBox.js";import{create as B}from"../../../../geometry/support/aaBoundingRect.js";import{equals as H}from"../../../../geometry/support/spatialReferenceUtils.js";import q from"../../../../layers/Layer.js";import{getObjectId as Y,computeAABB as $,hasGeometry as Z}from"../../../../layers/graphics/dehydratedFeatures.js";import{hydrateGraphic as J}from"../../../../layers/graphics/hydratedFeatures.js";import{isSupportedRenderer3D as Q,validateTo3D as K}from"../../../../renderers/support/rendererConversion.js";import{loadArcade as X}from"../../../../support/arcadeOnDemand.js";import{getDefaultSymbol3D as ee}from"../../../../symbols/support/defaults3D.js";import{to3D as ie}from"../../../../symbols/support/symbolConversion.js";import{ViewElevationProvider as te}from"./ElevationQuery.js";import{VisibilityFlag as re,VisibilityGroup as se}from"./enums.js";import{extractExpressionInfo as ae,createContext as ne}from"./featureExpressionInfoUtils.js";import{Graphics3DFeatureStore as oe}from"./Graphics3DFeatureStore.js";import le from"./Graphics3DGraphicCreationContext.js";import{Graphics3DSymbolCreationContext as he}from"./Graphics3DSymbolCreationContext.js";import{make as de}from"./Graphics3DSymbolFactory.js";import pe from"./Graphics3DWebStyleSymbol.js";import{GraphicStateTracking as ce}from"./GraphicStateTracking.js";import{computeCentroid as ye}from"./graphicUtils.js";import{ApplyRendererDiffResult as me}from"./interfaces.js";import{LoadStatus as ge}from"./Loadable.js";import{SpatialIndex2D as ue}from"./SpatialIndex2D.js";import{averageSymbolComplexities as be,defaultSymbolComplexity as _e}from"./symbolComplexity.js";import{StageLayerElevationProvider as fe}from"../support/StageLayerElevationProvider.js";import{toBoundingRect as ve}from"../../support/extentUtils.js";import{PropertiesPool as Ce}from"../../support/PropertiesPool.js";import{GridLocalOriginFactory as Se}from"../../webgl-engine/lib/GridLocalOriginFactory.js";import{UpdatePolicy as we}from"../../webgl-engine/lib/UpdatePolicy.js";import{WebGLLayer as Ge}from"../../webgl-engine/lib/WebGLLayer.js";import{ImmediateTask as xe,noBudget as Pe,TaskPriority as Re,Task as De}from"../../../support/Scheduler.js";import Ee from"../../../../geometry/Extent.js";import Ie from"../../../../geometry/Point.js";import Ue from"../../../../symbols/LabelSymbol3D.js";import Ae from"../../../../symbols/TextSymbol.js";import Oe from"../../../../symbols/WebStyleSymbol.js";var Le;const je=j(),Ve=z(),Fe="esri.views.3d.layers.graphics.Graphics3DCore",Te=n.getLogger(Fe);let ke=Le=class extends t{get _viewSpatialReference(){return this.owner.view.spatialReference}get spatialIndex(){return this._spatialIndex||(this._spatialIndex=new ue({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 numberOfGraphics(){return this._numberOfGraphics}get effectiveUpdatePolicy(){return h(this.currentRenderer)&&"dictionary"===this.currentRenderer.type?we.ASYNC:d(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._graphicsWaitingForSymbol.size>0||this.running||this._elevationAlignment?.updating||h(this._scaleVisibility)&&this._scaleVisibility.updating||h(this._filterVisibility)&&this._filterVisibility.updating||this._rendererChangeAbortController||this._elevationInfoChangeAbortController||this._updatingPendingLoadedGraphicsChange||this._frameTask.updating||this._loadingSymbols>0)}get running(){return this._pendingUpdates.size>0||!!this._spatialIndex?.updating}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,i=e?e.graphics3D.minTotalNumberOfFeatures:0,t=e?e.graphics3D.maxTotalNumberOfFeatures:0,r=e?e.graphics3D.maxTotalNumberOfPrimitives:0,s=this.averageSymbolComplexity,a=Math.max(1,h(s)?s.primitivesPerFeature:1),n=h(s)&&s.drawCallsPerFeature>0?t/s.drawCallsPerFeature*.3:t,o=Math.ceil(r/a),l=Math.max(i,Math.min(t,o,n)),d=this._get("displayFeatureLimit");return d&&d.minimumTotalNumberOfFeatures===i&&d.maximumTotalNumberOfFeatures===t&&d.maximumTotalNumberOfPrimitives===r&&d.averageSymbolComplexity===s&&d.maximumNumberOfFeatures===l?d:{minimumTotalNumberOfFeatures:i,maximumTotalNumberOfFeatures:t,maximumTotalNumberOfPrimitives:r,averageSymbolComplexity:s,maximumNumberOfFeatures:l}}get averageSymbolComplexity(){const e=be(this._symbolComplexities),i=this._get("averageSymbolComplexity");return 0===e.numComplexities||h(i)&&(e.estimated&&(i.primitivesPerFeature>=e.primitivesPerFeature||i.primitivesPerCoordinate>=e.primitivesPerCoordinate||i.drawCallsPerFeature>=e.drawCallsPerFeature)||i.primitivesPerFeature===e.primitivesPerFeature&&i.primitivesPerCoordinate===e.primitivesPerCoordinate&&i.drawCallsPerFeature===e.drawCallsPerFeature)?i:e}get usedMemory(){const e=h(this.averageSymbolComplexity)&&this.labelsEnabled?this.averageSymbolComplexity.memory.bytesPerFeatureLabel*this._numberOfGraphics:0,i=this._getSymbolComplexitiesUsed().reduce(((e,i)=>e+i.memory.resourceBytes),0);return this._usedMemory+e+i}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(h(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){if("web-style"===e.type)return e.clone();const i=this._symbolConversionCache.get(e.id);if(h(i))return i;const t=ie(e,{geometryType:this.layer?.geometryType??void 0,retainId:!0,hasLabelingContext:this._hasLabelingContext(e)}),r=t.symbol||null;return p(r)&&t.error&&Te.error(t.error.message),this._symbolConversionCache.set(e.id,r),r}_getSymbolComplexitiesUsedOrRenderer(e){if(p(e))return[];const i=e.getSymbols(),t="backgroundFillSymbol"in e?e.backgroundFillSymbol:null;if(!(t||i&&i.length))return[];const r=[],s=this._getSymbolComplexityUsedOrRenderer(t);h(s)&&r.push(s);for(const a of i){const e=this._getSymbolComplexityUsedOrRenderer(a);h(e)&&r.push(e)}return r}_getSymbolComplexityUsedOrRenderer(e){if(p(e))return null;const i=this._symbols.get(e.id);if(h(i))return i.complexity;const t=this._getConvertedSymbol(e);return h(t)?_e(t):null}_getSymbolComplexitiesUsed(){const e=[];return this._symbols.forEach((i=>{h(i)&&e.push(i.complexity)})),e}get _objectIdField(){return this.layer.objectIdField}constructor(e){super(e),this._propertiesPool=new Ce({computedExtent:Ee},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._handles=new s,this._frameTask=xe,this._suspendSymbolCleanup=!1,this._arcadeOnDemand=null,this._rendererChangeAbortController=null,this._elevationInfoChangeAbortController=null,this._initializeAbortController=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 b({allocator:e=>e||new We,deallocator:e=>(e.clear(),e)}),this._symbolWarningLogged=!1,this._geometryWarningLogged=!1,this._objectIdInvisibleSet=new Set,this._whenSymbolRemoved=new b,this.preferredUpdatePolicy=we.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.symbolCreationContext=new he(e.owner.view.resourceController.scheduler,((e,i)=>this._frameTask.schedule(e,i)))}initialize(){this._featureStore=new oe({objectIdField:this.owner.layer&&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,i,t)=>this.spatialIndex.queryGraphicUIDsInExtent(e,i,t),{componentFactories:i}=this;if(h(i.elevationAlignment)){const t=i.elevationAlignment(this,e);this._elevationAlignment=t}if(h(i.scaleVisibility)){const t=i.scaleVisibility(this,e);this._scaleVisibility=t}if(h(i.filterVisibility)){const e=i.filterVisibility({featureStore:this._featureStore,getFeatureCount:()=>this.graphics3DGraphics.size,updateFeatureVisibilities:e=>this.modifyGraphics3DGraphicVisibilities((i=>i.setVisibilityFlag(re.FILTER,e(Y(i.graphic,this._objectIdField)),se.GRAPHIC))),setAllFeaturesVisibility:e=>this.modifyGraphics3DGraphicVisibilities((i=>i.setVisibilityFlag(re.FILTER,e,se.GRAPHIC))),clearFeaturesVisibility:()=>this.modifyGraphics3DGraphicVisibilities((e=>e.clearVisibilityFlag(re.FILTER)))});this._filterVisibility=e}if(h(i.deconflictor)){const e=i.deconflictor(this);this._deconflictor=e}if(h(i.labeler)&&h(this._scaleVisibility)){const e=i.labeler(this,this._scaleVisibility);this._labeler=e}if(h(i.objectStates)){const e=i.objectStates(this);this._objectStates=e}this._initializeAbortController=new AbortController,this._initializePromise=this._initializeAsync()}async _initializeAsync(){const e=this._initializeAbortController?.signal,i=this.owner.view;this._viewElevationProvider=new te(this._viewSpatialReference,i),this._initializeStage(i,this.layer.uid);const t=i.sharedSymbolResources;this.symbolCreationContext.sharedResources=t,this._sharedSymbolResourcesOwnerHandle=t.addGraphicsOwner(this.owner),h(this.currentRenderer)&&(this.symbolCreationContext.renderer=this.currentRenderer),this.symbolCreationContext.stage=this.stage,this.symbolCreationContext.streamDataRequester=t.streamDataRequester,this.symbolCreationContext.renderCoordsHelper=i.renderCoordsHelper,this.symbolCreationContext.layer=this.layer,this.symbolCreationContext.graphicsCoreOwner=this.owner,this.symbolCreationContext.localOriginFactory=new Se(i.renderSpatialReference),this.symbolCreationContext.elevationProvider=i.elevationProvider,this.symbolCreationContext.notifyGraphicGeometryChanged=e=>this.notifyGraphicGeometryChanged(e),this.symbolCreationContext.notifyGraphicVisibilityChanged=e=>this.notifyGraphicVisibilityChanged(e);const r=ae(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);if(this.symbolCreationContext.featureExpressionInfoContext=await ne(r,this._viewSpatialReference,e,Te),_(e),this.symbolCreationContext.screenSizePerspectiveEnabled=i.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=i.basemapTerrain.overlayManager.registerGeometryDrapeSource(e),this._handles.add(a((()=>i.basemapTerrain.overlayManager.unregisterDrapeSource(e))))}this._handles.add([S((()=>this.suspendedOrOutsideOfView),(()=>this._frameTask.reschedule((()=>this._updateLayerVisibility())))),S((()=>[this.layer?.screenSizePerspectiveEnabled,this.owner.view.screenSizePerspectiveEnabled]),(()=>{const e=i.screenSizePerspectiveEnabled&&!!this.layer.screenSizePerspectiveEnabled;e!==this.symbolCreationContext.screenSizePerspectiveEnabled&&(this.symbolCreationContext.screenSizePerspectiveEnabled=e,this._labeler?.reset(),this.recreateAllGraphicsAndSymbols())})),S((()=>this.owner.slicePlaneEnabled),(e=>this._slicePlaneEnabledChange(!!e))),S((()=>this.owner.view.state?.rasterPixelRatio),(()=>this._pixelRatioChange())),S((()=>!!this.owner.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._physicalBasedRenderingChange(e))),S((()=>!!this.owner.view.qualitySettings?.graphics3D?.skipHighSymbolLods),(e=>this._skipHighSymbolLoDsChange(e))),w((()=>i.basemapTerrain?.tilingScheme),(e=>{if(!e.spatialReference.equals(this.symbolCreationContext.overlaySR)&&h(i.basemapTerrain.spatialReference)&&(this.symbolCreationContext.overlaySR=i.basemapTerrain.spatialReference),this._handles.has("loaded-graphics"))this.recreateAllGraphics();else{const e=()=>this.owner?.loadedGraphics;this._handles.add([G(e,"change",(e=>{this._graphicsCollectionChanged(e),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}),{onListenerAdd:()=>{this.recreateAllGraphics(),this._signalUpdatingDuringAsyncLoadedGraphicsChange()}})],"loaded-graphics")}}),{initial:!0}),S((()=>this.effectiveUpdatePolicy),(e=>{h(this.stageLayer)&&(this.stageLayer.updatePolicy=e),this.symbolCreationContext.isAsync=this.effectiveUpdatePolicy===we.ASYNC,e===we.SYNC&&this.runTask(Pe)}),x)]),this._frameTask=i.resourceController.scheduler.registerTask(Re.GRAPHICS_CORE,this),this.layer&&"featureReduction"in this.layer&&this._handles.add(S((()=>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)}destroy(){this._abortInitialize(),this._abortRendererChange(),this._abortElevationInfoChange(),this._frameTask.remove(),this._frameTask=xe,this.owner.view.deconflictor.removeGraphicsOwner(this),this.owner.view.labeler.removeGraphicsOwner(this),this._elevationAlignment=c(this._elevationAlignment),this._scaleVisibility=c(this._scaleVisibility),this._filterVisibility=c(this._filterVisibility),this._deconflictor=null,this._labeler=null,this._objectStates=c(this._objectStates),this.clear(),this._featureStore=c(this._featureStore),this._updatingPendingLoadedGraphicsChange=y(this._updatingPendingLoadedGraphicsChange),this._graphicStateTracking=c(this._graphicStateTracking),this.stage&&(this.stage.remove(this.stageLayer),this.stageLayer=null,this.stage=null),this._handles=c(this._handles),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=y(this._sharedSymbolResourcesOwnerHandle),this._propertiesPool=c(this._propertiesPool),this._pendingUpdatesPool=null,this._symbolConversionCache.clear(),this._objectIdInvisibleSet.clear(),this._spatialIndex=c(this._spatialIndex)}clear(){this._objectStates?.allGraphicsDeleted(),h(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(c),this._symbols.clear(),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("updating"),this.notifyChange("running"),this.notifyChange("updatingRemaining"),this._featureStore.events.emit("changed")}_initializeStage(e,i){this.stage=e._stage,this.stageLayer=new Ge({pickable:!this.suspendedOrOutsideOfView,updatePolicy:this.effectiveUpdatePolicy},i),this.stage.add(this.stageLayer);const t=this.stageLayer.events;t.on("objectTransformation",(e=>this.notifyGraphicGeometryChanged(e.metadata.graphicUid))),t.on("visibilityChanged",(e=>this.notifyGraphicVisibilityChanged(e.metadata.graphicUid))),t.on("objectGeometryAdded",(e=>this.notifyGraphicGeometryChanged(e.object.metadata.graphicUid))),t.on("objectGeometryRemoved",(e=>this.notifyGraphicGeometryChanged(e.object.metadata.graphicUid))),t.on("objectGeometryUpdated",(e=>this.notifyGraphicGeometryChanged(e.object.metadata.graphicUid)))}notifyGraphicGeometryChanged(e){if(p(this._graphicStateTracking)||p(e))return;const i=this.graphics3DGraphics.get(e);i&&this._graphicStateTracking.updateGraphicGeometry(i)}notifyGraphicVisibilityChanged(e){if(p(this._graphicStateTracking)||p(e))return;const i=this.graphics3DGraphics.get(e);i&&this._graphicStateTracking.updateGraphicVisibility(i)}_updateLayerVisibility(){const e=this.displayFeatureLimit.maximumNumberOfFeatures,i=this._numberOfGraphics>e*Me,t=!this.suspendedOrOutsideOfView&&!i;t!==this._visible&&(this._visible=t,t?(this.stageLayer.pickable=!0,this.updateAllGraphicsVisibility()):(this.stageLayer.pickable=!1,this._hideAllGraphics()),this._updateStageLayerVisibility())}_updateStageLayerVisibility(){this.stageLayer.visible=this._visible&&(null==this.layer.opacity||this.layer.opacity>0)}getGraphics3DGraphicById(e){return null!=e?this.graphics3DGraphics.get(e):void 0}getGraphics3DGraphicByObjectId(e){return this.owner.layer?.objectIdField?this._findGraphics3DGraphicByObjectId(e):null}_getGraphicObjectID(e,i=this.owner.layer&&this.owner.layer.objectIdField){return Y(e,i)}get graphics3DGraphicsByObjectID(){const e=this.owner.layer&&this.owner.layer.objectIdField;if(!e)return;const i=new Map;return this.graphics3DGraphics.forEach((t=>{if(!t)return;const r=t.graphic,s=this._getGraphicObjectID(r,e);h(s)&&i.set(s,t)})),i}get labelsEnabled(){return!(!this._labeler||!this._labeler.layerLabelsEnabled())}async updateLabelingInfo(e){const i=this._deconflictor&&this._deconflictor.labelingInfoChange(e),t=this._labeler&&this._labeler.labelingInfoChange(e);await f([i,t])}updateVisibilityInfo(){this._deconflictor&&this._deconflictor.labelingInfoChange(),this._labeler&&this._labeler.visibilityInfoChange()}get symbolUpdateType(){if(this._pendingUpdates.size>0)return"unknown";let e=0,i=0;return o(this._symbols,((t,r)=>{if(h(t)){const s=t.getFastUpdateStatus();if(s.loading>0)return!0;this._graphicsBySymbol.has(r)&&(i+=s.fast,e+=s.slow)}return!1}))?"unknown":i>=0&&0===e?"fast":e>=0&&0===i?"slow":"mixed"}runTask(e){if(this._frameTask.processQueue(e),this._applyPendingUpdates(e),this.notifyChange("running"),this.running||this.notifyChange("updating"),this.notifyChange("updatingRemaining"),!e.hasProgressed)return De.YIELD}setObjectIdVisibility(e,i){i?this._objectIdInvisibleSet.delete(e):this._objectIdInvisibleSet.add(e);const t=this._findGraphics3DGraphicByObjectId(e);h(t)&&this._updateUserVisibility(t)}_findGraphics3DGraphicByObjectId(e){return l(this.graphics3DGraphics,(i=>this._getGraphicObjectID(i.graphic)===e))}_updateUserVisibility(e){if(p(e))return!1;const i=e.graphic,t=this._getGraphicObjectID(i),r=i.visible&&!this.owner.suspended&&(p(t)||!this._objectIdInvisibleSet.has(t));return e.setVisibilityFlag(re.USER_SETTING,r,se.GRAPHIC)}_whenGraphics3DGraphic(e){const i=this.graphics3DGraphics.get(e.uid);if(i)return Promise.resolve(i);const t=this._whenGraphics3DGraphicRequests[e.uid];if(t)return t.promise;const r=v();return this._whenGraphics3DGraphicRequests[e.uid]=r,r.promise}async _boundsForGraphics3DGraphic(e,i){const t=this._viewSpatialReference,r=this.owner.view.renderSpatialReference,s=this.owner.view.basemapTerrain.spatialReference,a=(e,i,s)=>k(e,r,i,e,t,i,s),n=(e,i,r)=>k(e,s,i,e,t,i,r),o=this._viewElevationProvider?{service:this._viewElevationProvider,useViewElevation:!!h(i)&&!!i.useViewElevation,minDemResolution:h(i)?i.minDemResolution:null,minDemResolutionForPoints:this.owner.view.resolution}:null,l=await e.getProjectedBoundingBox(a,n,o,m(i,"signal"));if(!l)return null;const p=l.boundingBox;if(l.requiresDrapedElevation){const e=this.symbolCreationContext.elevationProvider;if(e){W(p,je);const i=d(e.getElevation(je[0],je[1],0,t,"ground"),0);p[2]=Math.min(p[2],i),p[5]=Math.max(p[5],i)}}return{boundingBox:p,screenSpaceObjects:l.screenSpaceObjects}}async whenGraphicBounds(e,i){await P((()=>this.owner?.loadedGraphics));const t=this.owner.layer&&this.owner.layer.objectIdField,s=this.owner.loadedGraphics.find((i=>i===e||null!=t&&null!=i.attributes&&e.attributes&&i.attributes[t]===e.attributes[t]));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,i)}computeAttachmentOrigin(e,i){const t=this.graphics3DGraphics.get(e.uid);if(!t)return null;const r=t.computeAttachmentOrigin();if(0===r.render.num&&0===r.draped.num)return null;A(Ne,0,0,0);let s=0;if(r.render.num>0){if(!V(r.render.origin,this.symbolCreationContext.renderCoordsHelper.spatialReference,Be,i))return null;O(Ne,Ne,Be),s++}if(r.draped.num>0){const[e,t]=r.draped.origin,a=d(this._viewElevationProvider.getElevation(e,t,"ground"),0);if(A(Be,e,t,a),!V(Be,this._viewElevationProvider.spatialReference,Be,i))return null;O(Ne,Ne,Be),s++}return s>1&&L(Ne,Ne,1/s),new Ie({x:Ne[0],y:Ne[1],z:Ne[2],spatialReference:i})}getSymbolLayerSize(e,i){const t=this._symbols.get(e.id);if(p(t))throw new r("internal:symbol-not-part-of-view","Symbol is not part of this view");const s=e.symbolLayers.indexOf(i);if(-1===s)throw new r("internal:missing-symbol-layer","Symbol layer is not in symbol");const a=t.getSymbolLayerSize(s);if(p(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 i=e.graphic.uid,t=this.graphics3DGraphics.get(i);if(!p(t)||!p(this._graphicsWithoutSymbol.get(i)))switch(e.property){case"visible":this._graphicUpdateVisibleHandler(t);break;case"geometry":this._graphicUpdateGeometryHandler(t,e);break;case"symbol":this._graphicUpdateSymbolHandler(t,e);break;case"attributes":break;case"transform":this._graphicUpdateTransformHandler(t,e)}}_graphicUpdateGeometryHandler(e,i){const t=i.graphic.geometry;if(p(t))return void this._recreateGraphic(i.graphic);if(p(e)){const e=i.graphic.symbol&&i.graphic.symbol.id;if(e){const i=this._symbols.get(e);if(h(i)&&i.loadStatus===ge.LOADING)return}return void this._recreateGraphic(i.graphic)}const r=e.graphics3DSymbol;!p(i.newValue)&&r.updateGeometry(e,i.newValue)||this._recreateGraphic(e.graphic),this._expandComputedExtent(t)}_graphicUpdateSymbolHandler(e,i){const t=i.graphic,r=h(e)?e.graphics3DSymbol:h(i.oldValue)?this._symbols.get(i.oldValue.id):null;if(p(r)||p(i.newValue))return void this._recreateGraphic(t);const s=r.symbol,a=this._getConvertedSymbol(i.newValue);if(h(a)&&(a.type!==s.type||"web-style"===a.type)||"web-style"===s.type)return void this._recreateGraphic(t);const n=this._graphicsBySymbol.get(s.id);if(n&&1!==n.size)return void this._recreateGraphic(t);const o=I(s,a);if(p(o))return void this._updateSymbolMapping(s.id,a);const l={diff:o,graphics3DGraphicPatches:[],symbolStatePatches:[]};if(r.prepareSymbolPatch(l),!U(l.diff))return void this._recreateGraphic(t);const d=this._getRenderingInfo(t);if(p(d))return void this._recreateGraphic(t);const c=r.extentPadding;for(const h of l.symbolStatePatches)h();if(c!==r.extentPadding&&this._recomputeExtentPadding(),h(e))for(const h of l.graphics3DGraphicPatches)h(e,d);this._updateSymbolMapping(s.id,a)}_graphicUpdateVisibleHandler(e){this._updateUserVisibility(e)&&(this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty())}_graphicUpdateTransformHandler(e,i){}recreateGraphics(e){this._suspendSymbolCleanup=!0,this.remove(e),this.add(e),this._suspendSymbolCleanup=!1,this.effectiveUpdatePolicy===we.SYNC&&this._cleanupSymbols()}_recreateGraphic(e){this.recreateGraphics([e])}_beginGraphicUpdate(e){const i=this._graphicsUpdateId;return this._graphicsUpdateId++,this._graphicsWaitingForSymbol.set(e.uid,i),1===this._graphicsWaitingForSymbol.size&&this.notifyChange("updating"),i}_endGraphicUpdate(e){e&&(this._graphicsWaitingForSymbol.delete(e.uid),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("updating")))}_recomputeExtentPadding(){let e=0;this._symbols.forEach((i=>{h(i)&&(e=Math.max(e,i.extentPadding))})),this._set("extentPadding",e)}_expandComputedExtent(e){const i=Ve,t=e.spatialReference;$(e,i);const r=this._viewSpatialReference,s=Le.tmpVec;if(H(t,r)||F(i[0],i[1],0,t,s,r)&&(i[0]=s[0],i[1]=s[1],F(i[3],i[4],0,t,s,r),i[3]=s[0],i[4]=s[1]),!(isFinite(i[0])&&isFinite(i[3])&&isFinite(i[1])&&isFinite(i[4])))return;const a=this.computedExtent;let n=null;const o=isFinite(i[2])&&isFinite(i[5]),l=o&&(!a||null==a.zmin||i[2]<a.zmin),h=o&&(!a||null==a.zmax||i[5]>a.zmax);if(a){(i[0]<a.xmin||i[1]<a.ymin||i[3]>a.xmax||i[4]>a.ymax||l||h)&&(n=this._propertiesPool.get("computedExtent"),n.xmin=Math.min(i[0],a.xmin),n.ymin=Math.min(i[1],a.ymin),n.xmax=Math.max(i[3],a.xmax),n.ymax=Math.max(i[4],a.ymax),n.spatialReference=r)}else n=this._propertiesPool.get("computedExtent"),n.xmin=i[0],n.ymin=i[1],n.xmax=i[3],n.ymax=i[4],n.spatialReference=r;n&&(l&&(n.zmin=i[2]),h&&(n.zmax=i[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 i=ae(this.layer.elevationInfo,this.elevationFeatureExpressionEnabled);this.symbolCreationContext.featureExpressionInfoContext=await ne(i,this._viewSpatialReference,e.signal,Te),_(e.signal),this._elevationInfoChangeAbortController=null,this._labeler?.elevationInfoChange(),this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("elevationInfo",i)?i.forEach((e=>{const i=e.graphic,t=e.labelLayers;for(const r of t){r.graphics3DSymbolLayer.updateGraphicElevationContext(i,r)}})):this._recreateSymbol(t)})),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=g(this._stageLayerElevationProvider)):(!this.layer.elevationInfo||this.layer.elevationInfo&&"relative-to-scene"!==this.layer.elevationInfo.mode)&&this._numberOfGraphicsProvidingElevation>0&&(this._stageLayerElevationProvider=new fe({layer:this.layer,stageLayer:this.stageLayer,view:this.owner.view}),this.owner.view.elevationProvider.register("scene",this._stageLayerElevationProvider))}_clearSymbolsAndGraphics(){this.clear(),h(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=g(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:i,view:t}=this.owner,r=t.basemapTerrain.tilingScheme&&i&&i.length?i.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 i=this._graphicsBySymbol.get(e),t=[];i&&(i.forEach(((e,i)=>{const r=e.usedMemory;this._conditionalRemove(e,i),this._spatialIndex?.remove(e),t.push(e.graphic),e.destroy(),this._removeGraphics3DGraphic(i,r),this._updateLayerVisibility(),this._featureStore.events.emit("changed")})),this._graphicsBySymbol.set(e,new Map));const r=this._symbols.get(e);c(r),this._symbols.delete(e),this.add(t)}_recreateGraphicsForSymbol(e){const i=this._graphicsBySymbol.get(e);if(i){const e=[];i.forEach((i=>e.push(i.graphic))),this.recreateGraphics(e)}}_conditionalRemove(e,i){this._graphicsDrapedUids.delete(i),this._objectStates?.removeGraphic(e),this._labeler?.removeGraphic(e),this._deconflictor?.removeGraphic(e),h(this._graphicStateTracking)&&this._graphicStateTracking.removeGraphic(e)}add(e){e&&0!==e.length&&(this.owner.view.basemapTerrain&&this.owner.view.basemapTerrain.tilingScheme?(this._updatePolicyForGraphics(e)===we.ASYNC?this._addDelayed(e):this._addImmediate(e),this.notifyChange("updating")):Te.error("#add()","Cannot add graphics before terrain surface has been initialized"))}_updatePolicyForGraphics(e){if(this.effectiveUpdatePolicy===we.SYNC&&("mesh"===this.layer.geometryType||null==this.layer.geometryType))for(const i of e)if(h(i.geometry)&&"mesh"===i.geometry.type&&!i.geometry.loaded)return we.ASYNC;return this.effectiveUpdatePolicy}_addImmediate(e){this._geometryWarningLogged=!1,this._symbolWarningLogged=!1;for(const i of e)this._addGraphic(i,this._getRenderingInfo(i,Te),we.SYNC);this._cleanupSymbols(),this._labeler&&(this.owner.view.labeler.setDirty(),this._cleanupSymbols()),this.owner.view.deconflictor.setDirty()}_addDelayed(e){for(const i of e){const e=i.uid;let t=this._pendingUpdates.get(e);t?t.add?t.state!==ze.NEW&&t.abortController?.abort():this._pendingAdds++:(t=this._pendingUpdatesPool.pushNew(),this._pendingAdds++,this._pendingUpdates.set(e,t)),t.add=i}this.notifyChange("running"),this.notifyChange("updatingRemaining")}remove(e){this.effectiveUpdatePolicy===we.ASYNC?this._removeDelayed(e):this._removeImmediate(e),this.notifyChange("updating")}_removeImmediate(e){for(const i of e)this._removeGraphic(i);this._cleanupSymbols(),this._labeler&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty()}_removeDelayed(e){for(const i of e){const e=i.uid,t=this._pendingUpdates.get(e);if(t)t.add&&(t.remove?t.add=null:this._pendingUpdates.delete(e),t.state===ze.LOADING&&t.abortController?.abort(),this._pendingAdds--);else{const t=this._pendingUpdatesPool.pushNew();t.remove=i,this._pendingUpdates.set(e,t),this._pendingRemoves++,this._applyPendingRemovesFirst=!0}}0===this._pendingUpdates.size&&this._finishPendingUpdates(),this.notifyChange("running"),this.notifyChange("updatingRemaining")}_finishPendingUpdates(){this._pendingUpdatesPool.clear(),this._cleanupSymbols(),(this._pendingAdds||this._pendingRemoves)&&Te.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[i,t]of this._pendingUpdates){if(e.done){this._applyPendingRemovesFirst=!0;break}if(t.remove&&!t.add&&(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(t.remove),t.remove=null,this._pendingUpdates.delete(i),0===this._pendingRemoves))break}}for(const[i,t]of this._pendingUpdates){if(e.done)break;t.add&&t.state===ze.NEW&&this._processPendingUpdateNew(t);let r=this.effectiveUpdatePolicy;if(!t.remove||t.add&&t.state!==ze.READY||(this._pendingRemoves--,e.madeProgress(),this._removeGraphic(t.remove),t.remove=null,r=we.SYNC),t.add)switch(t.state){case ze.READY:this._addGraphic(t.add,t.renderingInfo,r),t.add=null,this._pendingAdds--,e.madeProgress();break;case ze.REJECTED:t.add=null,this._pendingAdds--;case ze.LOADING:}null==t.remove&&null==t.add&&this._pendingUpdates.delete(i)}0===this._pendingUpdates.size&&(this._finishPendingUpdates(),this.notifyChange("running"))}_processPendingUpdateNew(e){if(!e.add)return void(e.state=ze.READY);const i=e.add.geometry;h(i)&&"mesh"===i.type&&!i.loaded?this._processPendingUpdateNewMesh(e,i):this._processPendingUpdateNewRenderingInfo(e)}async _processPendingUpdateNewMesh(e,i){e.state=ze.LOADING,e.abortController=new AbortController;const t=e.abortController.signal;try{await i.load({signal:t})}catch(r){return this._processPendingUpdateNewError(e,r)}e.abortController=null,this._processPendingUpdateNewRenderingInfo(e)}_processPendingUpdateNewError(e,i){e.abortController=null,C(i)?e.state=ze.NEW:e.state=ze.REJECTED}async _processPendingUpdateNewRenderingInfo(e){if(p(this.layer.renderer)||"dictionary"!==this.layer.renderer.type)return e.renderingInfo=this._getRenderingInfo(e.add,Te),void(e.state=ze.READY);e.state=ze.LOADING,e.abortController=new AbortController;let i=null;try{i=await this._getRenderingInfoAsync(e.add,{signal:e.abortController.signal})}catch(t){return e.abortController=null,void(C(t)?e.state=ze.NEW:e.state=ze.REJECTED)}p(i)||p(i.symbol)?(Te&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,Te.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),e.renderingInfo=null):e.renderingInfo=i,e.state=ze.READY}_addGraphic(e,i,t){if(this._graphicsWithoutSymbol.set(e.uid,e),p(i)||p(i.symbol)||!Z(e))return;h(this.stage.renderView.objectAndLayerIdRenderHelper)&&this.setUidToIdOnAdd&&this.stage.renderView.objectAndLayerIdRenderHelper.setUidToObjectAndLayerId(e.objectId,e.uid,this.layer.id,this.layer.uid,!!this.layer.popupEnabled);const r=i.symbol,s=this.getOrCreateGraphics3DSymbol(r,i.renderer);if(p(s))return;this._expandComputedExtent(e.geometry);const a=this._beginGraphicUpdate(e),n=new le(e,i,this.layer);let o=!1;const l=e=>{e===s.symbol.id&&(o=!0)};this._whenSymbolRemoved.push(l);const d=()=>{if(--this._loadingSymbols,this.destroyed)return;this._whenSymbolRemoved.removeUnordered(l);if(this._graphicsWaitingForSymbol.get(e.uid)!==a||o||s.destroyed||this.graphicSymbolSupported&&e.symbol&&e.symbol.id!==s.symbol.id)--s.referenced,this._cleanupSymbols();else{const i=this._createGraphics3DGraphic(s,n);this._spatialIndex&&h(i)&&this._spatialIndex.add(i),--s.referenced,this._endGraphicUpdate(e)}this._featureStore.events.emit("changed"),this._labeler&&this.owner.view.labeler.setDirty()},c=i=>{--this._loadingSymbols,this.destroyed||(this._whenSymbolRemoved.removeUnordered(l),o||(C(i)?this.add([e]):s.destroyed||this._endGraphicUpdate(e)))};++this._loadingSymbols,t===we.ASYNC?s.load((()=>this._frameTask.schedule(d)),(e=>this._frameTask.schedule((()=>c(e))))):s.load(d,c)}_removeGraphic(e){const i=e.uid,t=this.graphics3DGraphics.get(i);if(t){t.graphics3DSymbol.onRemoveGraphic(t);const e=t.usedMemory,r=t.isElevationSource;this._conditionalRemove(t,i),this._spatialIndex?.remove(t);const s=t.graphics3DSymbol.symbol.id;this._graphicsBySymbol.get(s)?.delete(i),this._graphicsWithoutSymbol.delete(i),this._removeGraphics3DGraphic(i,e,r),t.destroy(),this._featureStore.events.emit("changed")}else this._graphicsWithoutSymbol.delete(i),this._graphicsWaitingForSymbol.delete(i),0===this._graphicsWaitingForSymbol.size&&(this._cleanupSymbols(),this.notifyChange("updating"))}_hasLabelingContext(e){if(e instanceof Ue||e instanceof Ae){const i=this.symbolCreationContext.layer;return!!i.labelingInfo&&i.labelingInfo.some((i=>i.symbol===e))}return!1}_hasValidSymbolCreationContext(e){return!(e instanceof Ue&&!this._hasLabelingContext(e))||(Te.error("LabelSymbol3D is only valid as part of a LabelClass. Using LabelSymbol3D as a renderer symbol is not supported."),!1)}_getRenderingInfo(e,i){const t=e.geometry;if(p(t))return i&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!T(t.spatialReference,this._viewSpatialReference))return i&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has incompatible spatial reference and will not render`)),null;if(!this.graphicSymbolSupported&&h(e.symbol))return i&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?J(e,this.layer):e;let s;if(this.owner.getRenderingInfo&&(this.getRenderingInfoWithoutRenderer||h(this.currentRenderer)))s=this.owner.getRenderingInfo(r,this.currentRenderer,this._arcadeOnDemand);else{s={symbol:r.symbol||ee(r.geometry)}}return p(s)||p(s.symbol)?(i&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,i.warn(`Graphic in layer ${this.layer.id} has no symbol and will not render`)),null):s}_getRenderingInfoAsync(e,i){const t=e.geometry;if(p(t))return Te&&!this._geometryWarningLogged&&(this._geometryWarningLogged=!0,Te.warn(`Graphic in layer ${this.layer.id} has no geometry and will not render`)),null;if(!this.graphicSymbolSupported&&h(e.symbol))return Te&&!this._symbolWarningLogged&&(this._symbolWarningLogged=!0,Te.warn(`Graphic in layer ${this.layer.id} is not allowed to have a symbol, use a renderer instead`)),null;const r=this.rendererHasGeometryOperations?J(e,this.layer):e;return this.owner.getRenderingInfoAsync(r,this.currentRenderer,this._arcadeOnDemand,i)}_createGraphics3DSymbol(e,i){if(!this._hasValidSymbolCreationContext(e))return null;const t=this._getConvertedSymbol(e);if(!t)return null;let r;if(h(i)&&"backgroundFillSymbol"in i&&i.backgroundFillSymbol){const e=ie(i.backgroundFillSymbol,{ignoreDrivers:!0});h(e.symbol)&&"web-style"!==e.symbol.type&&"cim"!==e.symbol.type&&(r=e.symbol.symbolLayers)}const s=de(t,this.symbolCreationContext,r);return s.load((()=>{const e=s.extentPadding;e>this.extentPadding&&this._set("extentPadding",e),this.notifyChange("averageSymbolComplexity")}),(()=>{})),s}getOrCreateGraphics3DSymbol(e,i){let t=this._symbols.get(e.id);return void 0===t&&(t=e instanceof Oe?new pe(e,(e=>this._frameTask.schedule(e)),(e=>this._createGraphics3DSymbol(e,i))):this._createGraphics3DSymbol(e,i),this._symbols.set(e.id,t)),h(t)&&++t.referenced,t}trackGraphicState(e){return p(this._graphicStateTracking)&&(this._graphicStateTracking=new ce(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,i,t=!1){this._usedMemory-=i,this.graphics3DGraphics.delete(e),this._numberOfGraphics--,t&&(this._numberOfGraphicsProvidingElevation--,this.updateStageLayerElevationProvider()),this._updateLayerVisibility()}_createGraphics3DGraphic(e,i){const t=i.graphic;if(this._graphicsWithoutSymbol.delete(t.uid),!this._symbols.has(e.symbol.id))return this.add([t]),null;if(this.graphics3DGraphics.has(t.uid))return null;const r=e.createGraphics3DGraphic(i);if(p(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(t.uid,r);if(r.isDraped&&this._graphicsDrapedUids.add(t.uid),r.centroid=null,h(t.geometry)&&"point"!==t.geometry.type&&(r.centroid=ye(t.geometry,this._viewSpatialReference)),this._updateUserVisibility(r),h(this._scaleVisibility)&&this._scaleVisibility.updateVisibility(r),h(this._filterVisibility)){const{defaultVisibility:e}=this._filterVisibility;r.setVisibilityFlag(re.FILTER,e,se.GRAPHIC),e||this._filterVisibility.reapply()}this._deconflictor?.addGraphic(r),this._labeler?.addGraphic(r),this._objectStates?.addGraphic(r),this._deconflictor&&this.owner.view.deconflictor.setInitialIconVisibilityFlag(this,r),r.initialize(this.stage,this.stageLayer,this.owner),h(this._graphicStateTracking)&&this._graphicStateTracking.addGraphic(r);const a=this._whenGraphics3DGraphicRequests[t.uid];return a&&(delete this._whenGraphics3DGraphicRequests[t.uid],a.resolve(r)),r}_abortRendererChange(){this._rendererChangeAbortController&&(this._rendererChangeAbortController.abort(),this._rendererChangeAbortController=null)}async rendererChange(e){if(this._abortRendererChange(),e!==this.currentRenderer)if(this._validateRenderer(e),p(e)&&this._currentRendererChange(null,!1),Q(e))if(h(e)&&e.arcadeRequired){const i=new AbortController;this._rendererChangeAbortController=i;const{arcadeUtils:t}=await this._ensureArcade();_(i);const r=t.hasGeometryOperations(e);r&&(await t.enableGeometryOperations(),_(i)),this.effectiveUpdatePolicy===we.ASYNC?await this._frameTask.schedule((()=>this._currentRendererChange(e,r)),i.signal):this._currentRendererChange(e,r),this._rendererChangeAbortController=null}else if(this.effectiveUpdatePolicy===we.ASYNC){const i=new AbortController;this._rendererChangeAbortController=i,await this._frameTask.schedule((()=>this._currentRendererChange(e,!1)),i.signal),this._rendererChangeAbortController=null}else this._currentRendererChange(e,!1);else this._currentRendererChange(e,!1)}async _ensureArcade(){return p(this._arcadeOnDemand)?(this._arcadeOnDemand=await X(),this._arcadeOnDemand):this._arcadeOnDemand}_currentRendererChange(e,i){this.currentRenderer=e,this.rendererHasGeometryOperations=i,this.symbolCreationContext.arcade=u(this._arcadeOnDemand);const t=this.symbolCreationContext.renderer;if(e===t)return;if(this._symbolConversionCache.clear(),p(e))return this.symbolCreationContext.renderer=null,void this.recreateAllGraphicsAndSymbols();const r=I(t,e);this._updateUnchangedSymbolMappings(r,e,t),this.symbolCreationContext.renderer=e,p(r)||("complete"===r.type?this.recreateAllGraphicsAndSymbols():"partial"===r.type&&(this._applyRendererDiff(r,e,t)?this._volatileGraphicsUpdated():this.recreateAllGraphicsAndSymbols()),this.notifyChange("averageSymbolComplexity"))}_diffHasSymbolChange(e){for(const i in e.diff)switch(i){case"visualVariables":case"defaultSymbol":case"uniqueValueInfos":break;case"uniqueValueGroups":case"authoringInfo":case"fieldDelimiter":delete e.diff[i];break;default:return!0}return!1}_applySymbolSetDiff(e,i,t){e=e||[],i=i||[];const r=[];for(const s of i){const i=this._graphicsBySymbol.get(s.id);i&&i.forEach(((a,n)=>{const o=a.graphic,l=this.layer instanceof q?this.layer:null,h=u(this._arcadeOnDemand);if(s===t.defaultSymbol&&t.getSymbol(J(o,l),{arcade:h})===t.defaultSymbol)return;const d=a.usedMemory;e.length||t.defaultSymbol?r.push(o):this._graphicsWithoutSymbol.set(n,o);const p=this.graphics3DGraphics.get(n);this._conditionalRemove(p,n),a.destroy(),i.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&&this.owner.view.labeler.setDirty(),this.owner.view.deconflictor.setDirty()}_applyUniqueValueRendererDiff(e,i,t){const r=e.diff.defaultSymbol,s=e.diff.uniqueValueInfos;if(r||s){const a=s?s.added.map((e=>e.symbol)).filter(h):[],n=s?s.removed.map((e=>e.symbol)).filter(h):[];if(s)for(let e=0;e<s.changed.length;e++)a.push(s.changed[e].newValue.symbol),n.push(s.changed[e].oldValue.symbol);return r?(t.defaultSymbol&&n.push(t.defaultSymbol),i.defaultSymbol&&a.push(i.defaultSymbol)):t.defaultSymbol&&a.length&&n.push(i.defaultSymbol),this._applySymbolSetDiff(a,n,i),delete e.diff.defaultSymbol,delete e.diff.uniqueValueInfos,!0}return!1}_calculateUnchangedSymbolMapping(e,i,t){if("unique-value"!==i?.type||"unique-value"!==t?.type||h(e)&&"partial"!==e.type)return[];const r=e=>h(e)?e.id:null,s=e&&e.diff,a=s&&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 t.uniqueValueInfos??[]){const t=r(e.symbol),s=i.uniqueValueInfos?.find((i=>i.value===e.value));s&&t!==r(s.symbol)&&o.push({oldId:t,newId:r(s.symbol)})}}return!a&&t.defaultSymbol&&o.push({oldId:r(t.defaultSymbol),newId:r(i.defaultSymbol)}),o}_updateSymbolMapping(e,i){const t=h(i)&&i?"string"==typeof i?i:i.id:null;if(p(e)||e===t)return;const r=this._graphicsBySymbol.get(e);this._graphicsBySymbol.delete(e),void 0!==r&&this._graphicsBySymbol.set(t,r);const s=this._symbols.get(e);if(void 0!==s&&(this._symbols.delete(e),this._symbols.set(t,s),h(s))){const e="string"==typeof i?null:i;h(e)?s.symbol=e:s.symbol.id=t}}_updateUnchangedSymbolMappings(e,i,t){const r=this._calculateUnchangedSymbolMapping(e,i,t);for(const{oldId:s,newId:a}of r)this._updateSymbolMapping(s,a)}_applyRendererDiff(e,t,r){if(this._diffHasSymbolChange(e))return!1;if(t instanceof i&&r instanceof i&&this._applyUniqueValueRendererDiff(e,t,r)&&0===Object.keys(e.diff).length)return!0;for(const[i]of this._graphicsBySymbol){const r=this._symbols.get(i);if(h(r))switch(r.applyRendererDiff(e,t)){case me.Recreate_Symbol:this._recreateSymbol(i);break;case me.Recreate_Graphics:this._recreateGraphicsForSymbol(i);case me.Fast_Update:}}return!0}opacityChange(){this.forEachGraphics3DSymbol(((e,i)=>e.globalPropertyChanged("opacity",i))),this._updateStageLayerVisibility()}_slicePlaneEnabledChange(e){e!==this.symbolCreationContext.slicePlaneEnabled&&(this.symbolCreationContext.slicePlaneEnabled=e,this.stageLayer.sliceable=e,this.forEachGraphics3DSymbol(((e,i)=>e.globalPropertyChanged("slicePlaneEnabled",i))),this._deconflictor&&this._deconflictor.slicePlaneEnabledChange(),this._labeler&&this._labeler.slicePlaneEnabledChange())}_physicalBasedRenderingChange(e){this.symbolCreationContext.physicalBasedRenderingEnabled=e,this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("physicalBasedRenderingEnabled",i)||this._recreateSymbol(t)}))}_skipHighSymbolLoDsChange(e){this.symbolCreationContext.skipHighSymbolLods=e,this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("skipHighSymbolLods",i)||this._recreateSymbol(t)}))}_pixelRatioChange(){this.forEachGraphics3DSymbol(((e,i,t)=>{e.globalPropertyChanged("pixelRatio",i)||this._recreateSymbol(t)}))}_signalUpdatingDuringAsyncLoadedGraphicsChange(){this._updatingPendingLoadedGraphicsChange&&this._updatingPendingLoadedGraphicsChange.remove(),this._updatingPendingLoadedGraphicsChange=R((()=>{this._updatingPendingLoadedGraphicsChange=null}))}setClippingExtent(e,i){const t=this.symbolCreationContext.clippingExtent,r=B();return ve(e,r,i)?this.symbolCreationContext.clippingExtent=M(z(),r):this.symbolCreationContext.clippingExtent=null,!N(this.symbolCreationContext.clippingExtent,t)}modifyGraphics3DGraphicVisibilities(e){let i=!1;this.graphics3DGraphics.forEach((t=>{e(t)&&(i=!0)})),i&&(this.owner.view.labeler?.setDirty(),this.owner.view.deconflictor.setDirty())}forEachGraphics3DSymbol(e){for(const[i,t]of this._symbols){if(p(t))return;e(t,this._graphicsBySymbol.get(i)||He,i)}}updateAllGraphicsVisibility(){h(this._filterVisibility)&&this._filterVisibility.reapply(),this.modifyGraphics3DGraphicVisibilities((e=>{const i=this._updateUserVisibility(e),t=h(this._scaleVisibility)&&this._scaleVisibility.updateVisibility(e);return i||t}))}_hideAllGraphics(){this.modifyGraphics3DGraphicVisibilities((e=>e.setVisibilityFlag(re.USER_SETTING,!1,se.GRAPHIC)))}_validateRenderer(e){const i=K(e,{geometryType:this.layer?.geometryType});if(i){const e=`Renderer for layer '${this.layer.title?`${this.layer.title}, `:""}, id:${this.layer.id}' is not supported in a SceneView`;Te.warn(e,i.message)}}_volatileGraphicsUpdated(){this._labeler?.reset(),this.stageLayer.shaderTransformationChanged(),this.notifyChange("updating")}_cleanupSymbols(){if(this._graphicsWaitingForSymbol.size>0||this._suspendSymbolCleanup)return;let e=!1;this._symbols.forEach(((i,t)=>{if(p(i)||i.referenced>0)return;const r=this._graphicsBySymbol.get(t);r&&0!==r.size||(this._graphicsBySymbol.delete(t),this._symbols.delete(t),c(i),e=!0)})),e&&(this._recomputeExtentPadding(),this.notifyChange("averageSymbolComplexity"))}get test(){return{snapshotInternals:()=>({graphics:[...this.graphics3DGraphics.keys()].sort(),symbols:[...this._symbols.keys()].sort(),graphicsBySymbol:[...this._graphicsBySymbol.keys()].sort().map((e=>({symbolId:e,graphics:[...this._graphicsBySymbol.get(e).keys()].sort()}))),graphicsWithoutSymbol:[...this._graphicsWithoutSymbol.keys()].sort(),graphicsDrapedUids:[...this._graphicsDrapedUids].sort(),pendingUpdates:this._pendingUpdates}),symbols:this._symbols,filterVisibility:this._filterVisibility,numPending:this._pendingUpdates.size,forceUpdatePolicy:e=>{this._forcedUpdatePolicy=e}}}get performanceInfo(){return{visible:this.graphics3DGraphics.size,missing:this._graphicsWithoutSymbol.size,pending:this._pendingUpdates.size}}};var ze;ke.tmpVec=j(),e([D({readOnly:!0})],ke.prototype,"computedExtent",void 0),e([D()],ke.prototype,"currentRenderer",void 0),e([D()],ke.prototype,"rendererHasGeometryOperations",void 0),e([D()],ke.prototype,"_frameTask",void 0),e([D({readOnly:!0})],ke.prototype,"_viewSpatialReference",null),e([D()],ke.prototype,"_rendererChangeAbortController",void 0),e([D()],ke.prototype,"_elevationInfoChangeAbortController",void 0),e([D()],ke.prototype,"_initializeAbortController",void 0),e([D()],ke.prototype,"_elevationAlignment",void 0),e([D()],ke.prototype,"_scaleVisibility",void 0),e([D()],ke.prototype,"_filterVisibility",void 0),e([D()],ke.prototype,"_initializePromise",void 0),e([D()],ke.prototype,"_spatialIndex",void 0),e([D({readOnly:!0})],ke.prototype,"extentPadding",void 0),e([D()],ke.prototype,"_updatingPendingLoadedGraphicsChange",void 0),e([D()],ke.prototype,"_featureStore",void 0),e([D()],ke.prototype,"_deconflictor",void 0),e([D()],ke.prototype,"_labeler",void 0),e([D()],ke.prototype,"_objectStates",void 0),e([D()],ke.prototype,"_loadingSymbols",void 0),e([D()],ke.prototype,"preferredUpdatePolicy",void 0),e([D()],ke.prototype,"_forcedUpdatePolicy",void 0),e([D({readOnly:!0})],ke.prototype,"effectiveUpdatePolicy",null),e([D({constructOnly:!0})],ke.prototype,"elevationFeatureExpressionEnabled",void 0),e([D({constructOnly:!0})],ke.prototype,"owner",void 0),e([D({constructOnly:!0})],ke.prototype,"layer",void 0),e([D({constructOnly:!0})],ke.prototype,"graphicSymbolSupported",void 0),e([D({constructOnly:!0})],ke.prototype,"getRenderingInfoWithoutRenderer",void 0),e([D({constructOnly:!0})],ke.prototype,"componentFactories",void 0),e([D({constructOnly:!0})],ke.prototype,"setUidToIdOnAdd",void 0),e([D()],ke.prototype,"featureStore",null),e([D()],ke.prototype,"initializePromise",null),e([D()],ke.prototype,"scaleVisibility",null),e([D()],ke.prototype,"elevationAlignment",null),e([D()],ke.prototype,"objectStates",null),e([D()],ke.prototype,"filterVisibility",null),e([D({readOnly:!0})],ke.prototype,"updating",null),e([D({readOnly:!0})],ke.prototype,"running",null),e([D({readOnly:!0})],ke.prototype,"suspendedOrOutsideOfView",null),e([D({readOnly:!0,dependsOn:[]})],ke.prototype,"updatingRemaining",null),e([D({readOnly:!0,dependsOn:["owner.view.qualitySettings.graphics3D.maxTotalNumberOfPrimitives","owner.view.qualitySettings.graphics3D.maxTotalNumberOfFeatures","averageSymbolComplexity"]})],ke.prototype,"displayFeatureLimit",null),e([D({readOnly:!0,dependsOn:[]})],ke.prototype,"averageSymbolComplexity",null),e([D({constructOnly:!0})],ke.prototype,"hasZ",void 0),e([D({constructOnly:!0})],ke.prototype,"hasM",void 0),e([D()],ke.prototype,"_objectIdField",null),ke=Le=e([E(Fe)],ke),function(e){e[e.NEW=0]="NEW",e[e.LOADING=1]="LOADING",e[e.READY=2]="READY",e[e.REJECTED=3]="REJECTED"}(ze||(ze={}));class We{constructor(){this.add=null,this.renderingInfo=null,this.state=ze.NEW,this.abortController=null,this.remove=null}clear(){this.add=null,this.renderingInfo=null,this.state=ze.NEW,this.abortController=null,this.remove=null}}const Me=10,Ne=j(),Be=j(),He=new Map;export{ke 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.26/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as t}from"../../../../core/lang.js";import{get as r,isSome as s,isNone as n}from"../../../../core/maybe.js";import{getMetersPerVerticalUnitForSR as i}from"../../../../core/unitUtils.js";import{e as o}from"../../../../chunks/earcut.js";import{b as a}from"../../../../chunks/mat3.js";import{c as l}from"../../../../chunks/mat3f64.js";import{a as c,p as h}from"../../../../chunks/mat4.js";import{c as m}from"../../../../chunks/mat4f64.js";import{c as p,n as d,s as g,b as f,f as u,m as y}from"../../../../chunks/vec3.js";import{d as b,c as _}from"../../../../chunks/vec3f64.js";import{computeTranslationToOriginAndRotation as E}from"../../../../geometry/projection.js";import{create as x,empty as j,expandWithBuffer as w,intersectsClippingArea as S}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f64 as P}from"../../../../geometry/support/buffer/BufferView.js";import{t as v,a as L}from"../../../../chunks/vec32.js";import{makeVertexCandidate as A,makeEdgeCandidate as C}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as M}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as I}from"../../../ViewingMode.js";import{needsElevationUpdates3D as O,SampleElevationInfo as B}from"./elevationAlignmentUtils.js";import{ElevationContext as R}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as T}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as D,computeCentroid as G}from"./graphicUtils.js";import{ApplyRendererDiffResult as U}from"./interfaces.js";import{geometryAsPolygon as k}from"./polygonUtils.js";import{createMaterial as N}from"../support/edgeUtils.js";import F from"../../support/debugFlags.js";import{SamplePosition as V}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as H}from"../../support/renderInfoUtils/polygon.js";import{Attribute as Y}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as W}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Z}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as q}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as J}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{Object3D as K}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as Q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as X}from"../../webgl-engine/materials/DefaultMaterial.js";const $=["polygon","extent"];class ee extends T{constructor(e,t,r,s){super(e,t,r,s),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=D(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=r(this.symbolLayer,"material","color"),s=this._getCombinedOpacityAndColor(t),n=b(s),i=s[3],o=i<1||this.needsDrivenTransparentPass,a={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:n,ambient:n,opacity:i,transparent:o,cullFace:o?W.None:W.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};this._material=new X(a),this._bottomMaterial=new X({...a,cullFace:W.Back}),this._context.stage.add(this._material),this._context.stage.add(this._bottomMaterial)}destroy(){super.destroy(),this._material&&(this._context.stage.remove(this._material),this._context.stage.remove(this._bottomMaterial))}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,$,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(e.renderingInfo,255),s=this.setGraphicElevationContext(t,new R);return this._createAs3DShape(t,e.renderingInfo,r,s,t.uid)}layerOpacityChanged(e,t){const n=r(this.symbolLayer,"material","color"),i=this._getCombinedOpacity(n),o=i<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:i,transparent:o}),this._bottomMaterial.setParameters({opacity:i,transparent:o});const a=this._getLayerOpacity();e.forEach((e=>{const r=t(e);s(r)&&r.layerOpacityChanged(a,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,O)}slicePlaneEnabledChanged(e,t){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._bottomMaterial.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e.forEach((e=>{const r=t(e);s(r)&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._bottomMaterial.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}pixelRatioChanged(){return!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?M(e.size,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?U.Recreate_Symbol:U.Recreate_Graphics}async queryForSnapping(e,r,s,n){const o=this._getExtrusionSize(s)*this._context.renderCoordsHelper.unitInMeters/i(r),{objectId:a,target:l}=e,c=t(l);switch(c.z=(c.z??0)+o,e.type){case"edge":{const{start:r,end:s}=e,n=t(r),i=t(s);return n.z=(n.z??0)+o,i.z=(i.z??0)+o,[C(a,c,1/0,n,i)]}case"vertex":return[A(a,c,1/0),C(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,r,i,h){const p=k(e.geometry);if(n(p))return null;if(0===p.rings.length||!p.rings.some((e=>e.length>0)))return this._logGeometryValidationWarnings(p.rings,"rings","ExtrudeSymbol3DLayer"),null;const d=H(p,this._context.elevationProvider,this._context.renderCoordsHelper,i);this._logGeometryCreationWarnings(d,p.rings,"rings","ExtrudeSymbol3DLayer");const g=G(p);if(n(g))return null;const f=new Array,u=x(),y=m(),b=_(),A=this._context.renderCoordsHelper.viewingMode===I.Global;A||this._context.renderCoordsHelper.worldUpAtPosition(null,b),E(p.spatialReference,[g.x,g.y,0],y,this._context.renderCoordsHelper.spatialReference);const C=m();c(C,y);const M=l();a(M,C);const{polygons:B,mapPositions:R,position:T}=d,D=T.length/3,U=new Float64Array(3*D*6),F=new Float64Array(3*D*6),V=new Float64Array(3*D*6),Y=new Float64Array(1*D*6);let W=0;for(let s=0;s<B.length;++s){const e=B[s],n=e.count;if(this._context.clippingExtent&&(j(u),w(u,e.mapPositions),!S(u,this._context.clippingExtent)))continue;const i=o(e.mapPositions,e.holeIndices,3);if(0===i.length)continue;const a=3*n*2+i.length,l=new Array(a),c=new Array(i.length),m=6*n,p=3*U.BYTES_PER_ELEMENT,d=new P(U.buffer,W*p,p,(W+m)*p),g=3*F.BYTES_PER_ELEMENT,y=new P(F.buffer,W*g,g,(W+m)*g),_=new Float64Array(V.buffer,3*W*V.BYTES_PER_ELEMENT,3*m),E=new Float64Array(Y.buffer,1*W*Y.BYTES_PER_ELEMENT,1*m),x=this._getExtrusionSize(t);re(T,R,i,e,d.typedBuffer,_,y.typedBuffer,E,l,c,x,b,A),v(d,d,C),L(y,y,M),W+=6*n;const I=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:h,layerUid:this._context.layer.uid}),O=new xe(d.typedBuffer,_,y.typedBuffer,E);f.push(te(this._material,l,l.length-c.length,O,r,I)),f.push(te(this._bottomMaterial,c,0,O,r,I))}if(0===f.length)return null;const Z=new K({geometries:f,metadata:{layerUid:this._context.layer.uid,graphicUid:h,isElevationSource:!0}});Z.transformation=y;const q=N(this.symbolLayer,{opacity:this._getLayerOpacity()}),J=s(q)?{baseMaterial:this._material,edgeMaterials:[q],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,Q=new z(this,Z,f,null,null,ge,i,J);return Q.alignedSampledElevation=d.sampledElevation,Q.needsElevationUpdates=O(i.mode),Q}}function te(e,t,r,s,n,i){const o=new Array(t.length).fill(0),a=[[Q.POSITION,new Y(s.positions,3,!0)],[Q.NORMAL,new Y(s.normals,3,!0)],[Q.COLOR,new Y(n,4,!0)],[Q.SIZE,new Y(s.heights,1,!0)]],l=[[Q.POSITION,t],[Q.NORMAL,t],[Q.COLOR,o]];return new q(e,a,l,s.elevation,Z.Mesh,i,r)}function re(e,t,r,s,n,i,o,a,l,c,h,m,p){const d=r.length/3;let g=0,f=2*s.count;se(e,t,s.index,s.count,r,0,d,n,i,o,a,l,c,f,h,m,p);let u=2*s.count;f=0,oe(n,i,a,o,g,s.pathLengths[0],s.count,u,l,f,h),u+=4*s.pathLengths[0],f+=2*s.pathLengths[0],g+=s.pathLengths[0];for(let y=1;y<s.pathLengths.length;++y)oe(n,i,a,o,g,s.pathLengths[y],s.count,u,l,f,h),u+=4*s.pathLengths[y],f+=2*s.pathLengths[y],g+=s.pathLengths[y]}function se(e,t,r,s,n,i,o,a,l,c,h,m,g,f,u,y,b){p(ue,y);const _=u>0?1:-1;let E=3*r,x=0,j=3*x,w=s,S=3*w;for(let p=0;p<s;++p)b&&(ue[0]=e[E+0],ue[1]=e[E+1],ue[2]=e[E+2],d(ue,ue)),a[j+0]=e[E+0],a[j+1]=e[E+1],a[j+2]=e[E+2],l[j+0]=t[E+0],l[j+1]=t[E+1],l[j+2]=t[E+2],c[j+0]=-_*ue[0],c[j+1]=-_*ue[1],c[j+2]=-_*ue[2],h[x]=0,a[S+0]=e[E+0]+u*ue[0],a[S+1]=e[E+1]+u*ue[1],a[S+2]=e[E+2]+u*ue[2],l[S+0]=t[E+0],l[S+1]=t[E+1],l[S+2]=t[E+2],c[S+0]=_*ue[0],c[S+1]=_*ue[1],c[S+2]=_*ue[2],h[w]=u,j+=3,S+=3,E+=3,x+=1,w+=1;E=3*i,j=0,S=3*f;const P=u<0?_e:be,v=u<0?be:_e;for(let p=0;p<o;++p)g[j+0]=n[E+P[0]],g[j+1]=n[E+P[1]],g[j+2]=n[E+P[2]],m[S+0]=n[E+v[0]]+s,m[S+1]=n[E+v[1]]+s,m[S+2]=n[E+v[2]]+s,j+=3,S+=3,E+=3}function ne(e,t,r,s,n,i,o){s[i]=s[o],o*=3,e[(i*=3)+0]=e[o+0],e[i+1]=e[o+1],e[i+2]=e[o+2],t[i+0]=t[o+0],t[i+1]=t[o+1],t[i+2]=t[o+2],r[i+0]=n[0],r[i+1]=n[1],r[i+2]=n[2]}const ie=_();function oe(e,t,r,s,n,i,o,a,l,c,h){let m=n,p=n+1,d=n+o,g=n+o+1,f=a,u=a+1,y=a+2*i,b=a+2*i+1;h<0&&(m=n+o+1,g=n),c*=3;for(let _=0;_<i;++_)_===i-1&&(h>0?(p=n,g=n+o):(p=n,m=n+o)),pe(e,m,p,d,ie),ne(e,t,s,r,ie,f,m),ne(e,t,s,r,ie,u,p),ne(e,t,s,r,ie,y,d),ne(e,t,s,r,ie,b,g),l[c++]=f,l[c++]=y,l[c++]=b,l[c++]=f,l[c++]=b,l[c++]=u,m++,p++,d++,g++,f+=2,u+=2,y+=2,b+=2}const ae=_(),le=_(),ce=_(),he=_(),me=_();function pe(e,t,r,s,n){t*=3,r*=3,s*=3,g(ae,e[t++],e[t++],e[t++]),g(le,e[r++],e[r++],e[r++]),g(ce,e[s++],e[s++],e[s++]),f(he,le,ae),f(me,ce,ae),u(n,me,he),d(n,n)}const de=_();function ge(e,t,r,n,i){const o=e.stageObject,a=o.geometries,l=a.length,c="absolute-height"!==t.mode;let p=0;const d=o.transformation,f=h(m(),d);for(let h=0;h<l;h+=2){const e=a[h];if(!J(e))continue;const t=e.getMutableAttribute(Q.POSITION).data,l=e.vertexAttributes.get(Q.SIZE).data,m=new V(e.mapPositions),u=t.length/3;let b=0,_=!1,E=0;for(let o=0;o<u;o++){de[0]=t[b],de[1]=t[b+1],de[2]=t[b+2],n(m,ye),c&&(E+=ye.sampledElevation),F.TESTS_DISABLE_OPTIMIZATIONS?(g(fe,m.array[m.offset+0],m.array[m.offset+1],ye.z+l[b/3]),s(r)&&i.toRenderCoords(fe,r,fe),y(fe,fe,f)):(g(fe,t[b+0],t[b+1],t[b+2]),y(fe,fe,d),i.setAltitude(fe,ye.z+l[b/3]),y(fe,fe,f)),t[b]=fe[0],t[b+1]=fe[1],t[b+2]=fe[2];const e=Ee/i.unitInMeters;(Math.abs(de[0]-t[b])>=e||Math.abs(de[1]-t[b+1])>=e||Math.abs(de[2]-t[b+2])>=e)&&(_=!0),m.offset+=3,b+=3}_&&(e.invalidateBoundingInfo(),o.geometryVertexAttrsUpdated(a[h]),a[h+1].invalidateBoundingInfo(),o.geometryVertexAttrsUpdated(a[h+1])),p+=E/u}return p/l}const fe=_(),ue=_(),ye=new B,be=[0,2,1],_e=[0,1,2],Ee=.01;class xe{constructor(e,t,r,s){this.positions=e,this.elevation=t,this.normals=r,this.heights=s}}export{ee as Graphics3DExtrudeSymbolLayer};
5
+ import"../../../../core/has.js";import e from"../../../../core/Error.js";import{clone as t}from"../../../../core/lang.js";import{get as r,isSome as s,isNone as n}from"../../../../core/maybe.js";import{getMetersPerVerticalUnitForSR as i}from"../../../../core/unitUtils.js";import{e as o}from"../../../../chunks/earcut.js";import{b as a}from"../../../../chunks/mat3.js";import{c as l}from"../../../../chunks/mat3f64.js";import{a as c,p as h}from"../../../../chunks/mat4.js";import{c as m}from"../../../../chunks/mat4f64.js";import{c as p,n as d,s as g,b as f,f as u,m as y}from"../../../../chunks/vec3.js";import{d as b,c as _}from"../../../../chunks/vec3f64.js";import{computeTranslationToOriginAndRotation as E}from"../../../../geometry/projection.js";import{create as x,empty as j,expandWithBuffer as w,intersectsClippingArea as S}from"../../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f64 as P}from"../../../../geometry/support/buffer/BufferView.js";import{t as v,a as L}from"../../../../chunks/vec32.js";import{makeVertexCandidate as A,makeEdgeCandidate as C}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as M}from"../../../../renderers/support/renderingInfoUtils.js";import{ViewingMode as I}from"../../../ViewingMode.js";import{needsElevationUpdates3D as O,SampleElevationInfo as B}from"./elevationAlignmentUtils.js";import{ElevationContext as R}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as T}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as D,computeCentroid as G}from"./graphicUtils.js";import{ApplyRendererDiffResult as U}from"./interfaces.js";import{geometryAsPolygon as k}from"./polygonUtils.js";import{createMaterial as N}from"../support/edgeUtils.js";import F from"../../support/debugFlags.js";import{SamplePosition as V}from"../../support/ElevationProvider.js";import{geometryToRenderInfo as H}from"../../support/renderInfoUtils/polygon.js";import{Attribute as Y}from"../../webgl-engine/lib/Attribute.js";import{CullFaceOptions as W}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as Z}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as q}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as J}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{Object3D as K}from"../../webgl-engine/lib/Object3D.js";import{VertexAttribute as Q}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as X}from"../../webgl-engine/materials/DefaultMaterial.js";const $=["polygon","extent"];class ee extends T{constructor(e,t,r,s){super(e,t,r,s),this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=D(this._getSymbolSize());if(t)throw new e("graphics3dextrudesymbollayer:invalid-size",t)}const t=r(this.symbolLayer,"material","color"),s=this._getCombinedOpacityAndColor(t),n=b(s),i=s[3],o=i<1||this.needsDrivenTransparentPass,a={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,diffuse:n,ambient:n,opacity:i,transparent:o,cullFace:o?W.None:W.Back,hasVertexColors:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!0};this._material=new X(a),this._bottomMaterial=new X({...a,cullFace:W.Back}),this._context.stage.add(this._material),this._context.stage.add(this._bottomMaterial)}destroy(){super.destroy(),this._material&&(this._context.stage.remove(this._material),this._context.stage.remove(this._bottomMaterial))}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,$,this.symbolLayer.type))return null;const r=this._getVertexOpacityAndColor(e.renderingInfo,255),s=this.setGraphicElevationContext(t,new R);return this._createAs3DShape(t,e.renderingInfo,r,s,t.uid)}layerOpacityChanged(e,t){const n=r(this.symbolLayer,"material","color"),i=this._getCombinedOpacity(n),o=i<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:i,transparent:o}),this._bottomMaterial.setParameters({opacity:i,transparent:o});const a=this._getLayerOpacity();e.forEach((e=>{const r=t(e);s(r)&&r.layerOpacityChanged(a,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,O)}slicePlaneEnabledChanged(e,t){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._bottomMaterial.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e.forEach((e=>{const r=t(e);s(r)&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._bottomMaterial.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}pixelRatioChanged(){return!0}skipHighSymbolLodsChanged(){return!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?M(e.size,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}applyRendererDiff(e,t){return this._drivenPropertiesChanged(t)?U.Recreate_Symbol:U.Recreate_Graphics}async queryForSnapping(e,r,s,n){const o=this._getExtrusionSize(s)*this._context.renderCoordsHelper.unitInMeters/i(r),{objectId:a,target:l}=e,c=t(l);switch(c.z=(c.z??0)+o,e.type){case"edge":{const{start:r,end:s}=e,n=t(r),i=t(s);return n.z=(n.z??0)+o,i.z=(i.z??0)+o,[C(a,c,1/0,n,i)]}case"vertex":return[A(a,c,1/0),C(a,l,1/0,l,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,t,r,i,h){const p=k(e.geometry);if(n(p))return null;if(0===p.rings.length||!p.rings.some((e=>e.length>0)))return this._logGeometryValidationWarnings(p.rings,"rings","ExtrudeSymbol3DLayer"),null;const d=H(p,this._context.elevationProvider,this._context.renderCoordsHelper,i);this._logGeometryCreationWarnings(d,p.rings,"rings","ExtrudeSymbol3DLayer");const g=G(p);if(n(g))return null;const f=new Array,u=x(),y=m(),b=_(),A=this._context.renderCoordsHelper.viewingMode===I.Global;A||this._context.renderCoordsHelper.worldUpAtPosition(null,b),E(p.spatialReference,[g.x,g.y,0],y,this._context.renderCoordsHelper.spatialReference);const C=m();c(C,y);const M=l();a(M,C);const{polygons:B,mapPositions:R,position:T}=d,D=T.length/3,U=new Float64Array(3*D*6),F=new Float64Array(3*D*6),V=new Float64Array(3*D*6),Y=new Float64Array(1*D*6);let W=0;for(let s=0;s<B.length;++s){const e=B[s],n=e.count;if(this._context.clippingExtent&&(j(u),w(u,e.mapPositions),!S(u,this._context.clippingExtent)))continue;const i=o(e.mapPositions,e.holeIndices,3);if(0===i.length)continue;const a=3*n*2+i.length,l=new Array(a),c=new Array(i.length),m=6*n,p=3*U.BYTES_PER_ELEMENT,d=new P(U.buffer,W*p,p,(W+m)*p),g=3*F.BYTES_PER_ELEMENT,y=new P(F.buffer,W*g,g,(W+m)*g),_=new Float64Array(V.buffer,3*W*V.BYTES_PER_ELEMENT,3*m),E=new Float64Array(Y.buffer,1*W*Y.BYTES_PER_ELEMENT,1*m),x=this._getExtrusionSize(t);re(T,R,i,e,d.typedBuffer,_,y.typedBuffer,E,l,c,x,b,A),v(d,d,C),L(y,y,M),W+=6*n;const I=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:h,layerUid:this._context.layer.uid}),O=new xe(d.typedBuffer,_,y.typedBuffer,E);f.push(te(this._material,l,l.length-c.length,O,r,I)),f.push(te(this._bottomMaterial,c,0,O,r,I))}if(0===f.length)return null;const Z=new K({geometries:f,metadata:{layerUid:this._context.layer.uid,graphicUid:h,isElevationSource:!0}});Z.transformation=y;const q=N(this.symbolLayer,{opacity:this._getLayerOpacity()}),J=s(q)?{baseMaterial:this._material,edgeMaterials:[q],properties:{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}}:null,Q=new z(this,Z,f,null,null,ge,i,J);return Q.alignedSampledElevation=d.sampledElevation,Q.needsElevationUpdates=O(i.mode),Q}}function te(e,t,r,s,n,i){const o=new Array(t.length).fill(0),a=[[Q.POSITION,new Y(s.positions,3,!0)],[Q.NORMAL,new Y(s.normals,3,!0)],[Q.COLOR,new Y(n,4,!0)],[Q.SIZE,new Y(s.heights,1,!0)]],l=[[Q.POSITION,t],[Q.NORMAL,t],[Q.COLOR,o]];return new q(e,a,l,s.elevation,Z.Mesh,i,r)}function re(e,t,r,s,n,i,o,a,l,c,h,m,p){const d=r.length/3;let g=0,f=2*s.count;se(e,t,s.index,s.count,r,0,d,n,i,o,a,l,c,f,h,m,p);let u=2*s.count;f=0,oe(n,i,a,o,g,s.pathLengths[0],s.count,u,l,f,h),u+=4*s.pathLengths[0],f+=2*s.pathLengths[0],g+=s.pathLengths[0];for(let y=1;y<s.pathLengths.length;++y)oe(n,i,a,o,g,s.pathLengths[y],s.count,u,l,f,h),u+=4*s.pathLengths[y],f+=2*s.pathLengths[y],g+=s.pathLengths[y]}function se(e,t,r,s,n,i,o,a,l,c,h,m,g,f,u,y,b){p(ue,y);const _=u>0?1:-1;let E=3*r,x=0,j=3*x,w=s,S=3*w;for(let p=0;p<s;++p)b&&(ue[0]=e[E+0],ue[1]=e[E+1],ue[2]=e[E+2],d(ue,ue)),a[j+0]=e[E+0],a[j+1]=e[E+1],a[j+2]=e[E+2],l[j+0]=t[E+0],l[j+1]=t[E+1],l[j+2]=t[E+2],c[j+0]=-_*ue[0],c[j+1]=-_*ue[1],c[j+2]=-_*ue[2],h[x]=0,a[S+0]=e[E+0]+u*ue[0],a[S+1]=e[E+1]+u*ue[1],a[S+2]=e[E+2]+u*ue[2],l[S+0]=t[E+0],l[S+1]=t[E+1],l[S+2]=t[E+2],c[S+0]=_*ue[0],c[S+1]=_*ue[1],c[S+2]=_*ue[2],h[w]=u,j+=3,S+=3,E+=3,x+=1,w+=1;E=3*i,j=0,S=3*f;const P=u<0?_e:be,v=u<0?be:_e;for(let p=0;p<o;++p)g[j+0]=n[E+P[0]],g[j+1]=n[E+P[1]],g[j+2]=n[E+P[2]],m[S+0]=n[E+v[0]]+s,m[S+1]=n[E+v[1]]+s,m[S+2]=n[E+v[2]]+s,j+=3,S+=3,E+=3}function ne(e,t,r,s,n,i,o){s[i]=s[o],o*=3,e[(i*=3)+0]=e[o+0],e[i+1]=e[o+1],e[i+2]=e[o+2],t[i+0]=t[o+0],t[i+1]=t[o+1],t[i+2]=t[o+2],r[i+0]=n[0],r[i+1]=n[1],r[i+2]=n[2]}const ie=_();function oe(e,t,r,s,n,i,o,a,l,c,h){let m=n,p=n+1,d=n+o,g=n+o+1,f=a,u=a+1,y=a+2*i,b=a+2*i+1;h<0&&(m=n+o+1,g=n),c*=3;for(let _=0;_<i;++_)_===i-1&&(h>0?(p=n,g=n+o):(p=n,m=n+o)),pe(e,m,p,d,ie),ne(e,t,s,r,ie,f,m),ne(e,t,s,r,ie,u,p),ne(e,t,s,r,ie,y,d),ne(e,t,s,r,ie,b,g),l[c++]=f,l[c++]=y,l[c++]=b,l[c++]=f,l[c++]=b,l[c++]=u,m++,p++,d++,g++,f+=2,u+=2,y+=2,b+=2}const ae=_(),le=_(),ce=_(),he=_(),me=_();function pe(e,t,r,s,n){t*=3,r*=3,s*=3,g(ae,e[t++],e[t++],e[t++]),g(le,e[r++],e[r++],e[r++]),g(ce,e[s++],e[s++],e[s++]),f(he,le,ae),f(me,ce,ae),u(n,me,he),d(n,n)}const de=_();function ge(e,t,r,n,i){const o=e.stageObject,a=o.geometries,l=a.length,c="absolute-height"!==t.mode;let p=0;const d=o.transformation,f=h(m(),d);for(let h=0;h<l;h+=2){const e=a[h];if(!J(e))continue;const t=e.getMutableAttribute(Q.POSITION).data,l=e.vertexAttributes.get(Q.SIZE).data,m=new V(e.mapPositions),u=t.length/3;let b=0,_=!1,E=0;for(let o=0;o<u;o++){de[0]=t[b],de[1]=t[b+1],de[2]=t[b+2],n(m,ye),c&&(E+=ye.sampledElevation),F.TESTS_DISABLE_OPTIMIZATIONS?(g(fe,m.array[m.offset+0],m.array[m.offset+1],ye.z+l[b/3]),s(r)&&i.toRenderCoords(fe,r,fe),y(fe,fe,f)):(g(fe,t[b+0],t[b+1],t[b+2]),y(fe,fe,d),i.setAltitude(fe,ye.z+l[b/3]),y(fe,fe,f)),t[b]=fe[0],t[b+1]=fe[1],t[b+2]=fe[2];const e=Ee/i.unitInMeters;(Math.abs(de[0]-t[b])>=e||Math.abs(de[1]-t[b+1])>=e||Math.abs(de[2]-t[b+2])>=e)&&(_=!0),m.offset+=3,b+=3}_&&(e.invalidateBoundingInfo(),o.geometryVertexAttrsUpdated(a[h]),a[h+1].invalidateBoundingInfo(),o.geometryVertexAttrsUpdated(a[h+1])),p+=E/u}return p/l}const fe=_(),ue=_(),ye=new B,be=[0,2,1],_e=[0,1,2],Ee=.01;class xe{constructor(e,t,r,s){this.positions=e,this.elevation=t,this.normals=r,this.heights=s}}export{ee as Graphics3DExtrudeSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{isSome as r,get as s,isNone as a,unwrapOr as o,releaseMaybe as n,unwrap as l}from"../../../../core/maybe.js";import{throwIfAbortError as c,throwIfAborted as h}from"../../../../core/promiseUtils.js";import{pt2px as m,px2pt as u}from"../../../../core/screenUtils.js";import{dataComponents as d}from"../../../../core/urlUtils.js";import{c as _}from"../../../../chunks/mat4f64.js";import{f as p,a as f}from"../../../../chunks/vec2f64.js";import{Z as y,O as g,f as x}from"../../../../chunks/vec3f64.js";import{c as S}from"../../../../chunks/vec4.js";import{f as b,c as v}from"../../../../chunks/vec4f64.js";import{projectPointToVector as z}from"../../../../geometry/projection.js";import{containsPoint as P}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as R}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as C}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as M}from"../../../../symbols/support/utils.js";import j from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as I}from"./constants.js";import{perObjectElevationAligner as w}from"./ElevationAligners.js";import{SymbolUpdateType as O,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{ElevationContext as U}from"./ElevationContext.js";import L from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as G}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as V}from"./placementUtils.js";import{placePointOnGeometry as B,createStageObject as N,extendPointGraphicElevationContext as k}from"./pointUtils.js";import{initFastSymbolUpdatesState as q,updateFastSymbolUpdatesState as H,evaluateModelTransform as W}from"../support/FastSymbolUpdates.js";import{createTexture as $,DEFAULT_SYMBOL_SIZE_RATIO as Z,DEFAULT_TEX_SIZE as J}from"../../support/engineContent/sdfPrimitives.js";import{DRAPED_Z as K}from"../../terrain/OverlayRenderer.js";import{PowerOfTwoResizeMode as Q}from"../../webgl-engine/lib/basicInterfaces.js";import{createPointGeometry as X}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as Y}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as te}from"../../webgl-engine/materials/HUDMaterial.js";import ie from"../../../../symbols/CIMSymbol.js";const re=_(),se=x(0,0,1),ae=16,oe=1.5,ne=Z,le=[ne/2,ne/2,1-ne/2,1-ne/2],ce=[J*ne,J*ne];class he extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,i,r){super(e,t,i,r),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),i=this._getPrimitive();if(r(i))this._prepareResourcesPrimitive(t,i);else{const i=M(this.symbolLayer),r=d(i);r&&"application/json"===r.mediaType?await this._prepareResourcesCIM(t,JSON.parse(r.data),e):await this._prepareResourcesHref(t,i,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?m(e.size):ae);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let i=""===t?null:this._cimSymbolTextures.get(t);if(!i){const r={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol3D(this._cimLayers,e,"esriGeometryPoint",r,void 0,void 0);this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height,powerOfTwoResizeMode:Q.PAD};i=new ee(s.imageData,a),this._cimSymbolTextures.set(t,i),this._context.stage.add(i)}return i}_computeSize(e,t){const i=e.width/e.height;return i>1?[t,Math.round(t/i)]:[Math.round(t*i),t]}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(me(t)){const{screenLength:i,minWorldLength:s,maxWorldLength:a}=t.verticalOffset;e.verticalOffset={screenLength:m(i),minWorldLength:s||0,maxWorldLength:r(a)?a:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const i=this._getOutlineSize();if(ue(t)&&0===i)throw new Error("Nothing to render");if(this._outlineSize=i,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,r(this._context.sharedResources.textures)){const i=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>$(t)));this._texture=i.texture,this._releaseTexture=i,e.textureId=this._texture.id}e.textureIsSignedDistanceField=!0,e.distanceFieldBoundingBox=le;const s=this._getIconSize();this._size=[s,s],this._symbolTextureRatio=1/ne,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,s,a){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(r(this._context.sharedResources.textures)){const r=await t(this._context.sharedResources.textures.fromUrl(s,n,{signal:a}));if(!1===r.ok){c(r.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${s})`)}this._releaseTexture=r.value;const l=r.value.texture,h=l.params;this._size=this._computeSize(h,o),e.textureId=l.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,i){const r=new ie({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;h(i),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let a,o;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol(r,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:i}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,i=await R(t,this._context.layer.spatialReference,s);o=(e,t,r)=>{const s=j(i,e,{$view:r},"esriGeometryPoint",t);return null!==s?s:1}}else a=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=a||o||1;const n=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];h(i);const l=this._context.layer.fieldsIndex;this._cimRequiredFields=n.map((e=>l.get(e).name)),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||C}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(r(t.outline)&&null!=t.outline.size)return Math.max(m(t.outline.size),0);return e=ue(this._getPrimitive())?oe:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),i=this.symbolLayer,a=s(i,"outline","color");if(r(a)){const i=e.toUnitRGB(a),r=a.a*t;return[i[0],i[1],i[2],r]}return[0,0,0,0]}_getFillColor(){if(ue(this._getPrimitive()))return I;const e=a(this._getPrimitive()),t=s(this.symbolLayer,"material","color");return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?p((t.x||0)+.5,.5-(t.y||0)):e in V?V[e]:V.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers?this._fastUpdates={enabled:!1}:this._fastUpdates=q(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates.enabled&&Object.assign(e,this._fastUpdates.materialParameters),this._cimLayers){let i=r(e.textureId)?this._cimSymbolMaterials.get(e.textureId):null;return i||(i=new te(e),this._cimSymbolMaterials.set(o(e.textureId,0),i),t.add(i)),i}return this._material=new te(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=n(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const i=e.size[t];i&&"symbol-value"!==i&&"proportional"!==i&&(e.size[t]=m(i))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let i,r=[0,0];if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};i=this._createMaterialAndAddToStage(s,this._context.stage),r=[e.params.width,e.params.height]}else r=this._size,i=l(this._material);const s=B(t.geometry);if(a(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,n=this._getVertexOpacityAndColor(o);let c=1;if(!this._fastUpdates.enabled||!this._fastUpdates.visualVariables.size){const e=r[0]>r[1]?r[0]:r[1];c=this._getScaleFactor(o,e)}c*=this._symbolTextureRatio;const h=p(r[0]*c,r[1]*c),m=this.setGraphicElevationContext(t,new U);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,i,n,h,e.layer.uid):this._createAs3DShape(t,s,i,n,h,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((i=>{i.setParameters({color:e}),i.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,i,r);if(s!==O.UPDATE)return s;const a=E(r)||"absolute-height"===r;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!!this._getPrimitive()}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return G.Recreate_Symbol;if(!H(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return G.Recreate_Symbol;r(this._material)&&this._material.setParameters(this._fastUpdates.materialParameters)}return G.Fast_Update}_defaultElevationInfoNoZ(){return de}_createAs3DShape(e,t,i,r,s,o,n){const l=this.getFastUpdateAttrValues(e),c=l?e=>W(this._fastUpdates.materialParameters,l,e):void 0,h=this._context.layer.uid,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerUid:h}),u=X(i,se,null,r,s,_e,null,l,m),d=N(this._context,t,u,o,n,c);if(a(d))return null;const _=new D(this,d.object,[u],null,null,w,o);return _.alignedSampledElevation=d.sampledElevation,_.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,_.getScreenSize=this._createScreenSizeGetter(s,c),_.calculateRelativeScreenBounds=e=>i.calculateRelativeScreenBounds(_.getScreenSize(),1,e),k(_,t,this._context.elevationProvider),_}_createAsOverlay(e,t,i,s,a,o){i.renderPriority=this._renderPriority;const n=v();z(t,n,this._context.overlaySR),n[2]=K;const l=this._context.clippingExtent;if(r(l)&&!P(l,n))return null;const c=this.getFastUpdateAttrValues(e),h=c?e=>W(this._fastUpdates.materialParameters,c,e):void 0,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),u=X(i,se,n,s,a,null,null,c,m),d=new Y(u,{layerUid:o,graphicUid:e.uid,shaderTransformer:h});n[3]=0,S(d.boundingSphere,n);const _=new L(this,[d],null,this._context.drapeSourceRenderer);return _.getScreenSize=this._createScreenSizeGetter(a,h),_.calculateRelativeScreenBounds=e=>i.calculateRelativeScreenBounds(_.getScreenSize(),1,e),_}_createScreenSizeGetter(e,t){const i=this._outlineSize+2;if(this._fastUpdates.enabled){const r=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=f())=>{const a=t(re);return e[0]=a[0]*r+i,e[1]=a[5]*s+i,e}}{const t=e[0]/this._symbolTextureRatio+i,r=e[1]/this._symbolTextureRatio+i;return(e=f())=>(e[0]=t,e[1]=r,e)}}_fastVisualVariableConvertOptions(){const e=this._size[0]>this._size[1]?this._size[0]:this._size[1],t=x(e,e,e),i=u(1),r=e*i;return{modelSize:t,symbolSize:x(r,r,r),unitInMeters:i,transformation:{anchor:y,scale:g,rotation:y}}}_getGraphicHash(e){let t="";for(const i of this._cimRequiredFields)t+=i+e.attributes[i];return t}_forEachMaterial(e){r(this._material)&&e(this._material),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._material}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ue(e){return!a(e)&&("cross"===e||"x"===e)}he.PRIMITIVE_SIZE=ce,he.elevationModeChangeTypes={definedChanged:O.UPDATE,staysOnTheGround:O.NONE,onTheGroundChanged:O.RECREATE};const de={mode:"relative-to-ground",offset:0},_e=b(0,0,0,1);export{he as Graphics3DIconSymbolLayer};
5
+ import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import i from"../../../../core/Error.js";import{isSome as r,get as s,isNone as a,unwrapOr as o,releaseMaybe as n,unwrap as l}from"../../../../core/maybe.js";import{throwIfAbortError as c,throwIfAborted as h}from"../../../../core/promiseUtils.js";import{pt2px as m,px2pt as u}from"../../../../core/screenUtils.js";import{dataComponents as d}from"../../../../core/urlUtils.js";import{c as _}from"../../../../chunks/mat4f64.js";import{f as p,a as f}from"../../../../chunks/vec2f64.js";import{Z as y,O as g,f as x}from"../../../../chunks/vec3f64.js";import{c as S}from"../../../../chunks/vec4.js";import{f as b,c as v}from"../../../../chunks/vec4f64.js";import{projectPointToVector as z}from"../../../../geometry/projection.js";import{containsPoint as P}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as R}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as C}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as M}from"../../../../symbols/support/utils.js";import j from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as I}from"./constants.js";import{perObjectElevationAligner as w}from"./ElevationAligners.js";import{SymbolUpdateType as O,elevationModeChangeUpdateType as T,needsElevationUpdates2D as E}from"./elevationAlignmentUtils.js";import{ElevationContext as U}from"./ElevationContext.js";import L from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as D}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as A}from"./graphicUtils.js";import{ApplyRendererDiffResult as G}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as V}from"./placementUtils.js";import{placePointOnGeometry as B,createStageObject as N,extendPointGraphicElevationContext as k}from"./pointUtils.js";import{initFastSymbolUpdatesState as H,updateFastSymbolUpdatesState as q,evaluateModelTransform as W}from"../support/FastSymbolUpdates.js";import{createTexture as $,DEFAULT_SYMBOL_SIZE_RATIO as Z,DEFAULT_TEX_SIZE as J}from"../../support/engineContent/sdfPrimitives.js";import{DRAPED_Z as K}from"../../terrain/OverlayRenderer.js";import{PowerOfTwoResizeMode as Q}from"../../webgl-engine/lib/basicInterfaces.js";import{createPointGeometry as X}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as Y}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as ee}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as te}from"../../webgl-engine/materials/HUDMaterial.js";import ie from"../../../../symbols/CIMSymbol.js";const re=_(),se=x(0,0,1),ae=16,oe=1.5,ne=Z,le=[ne/2,ne/2,1-ne/2,1-ne/2],ce=[J*ne,J*ne];class he extends F{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,i,r){super(e,t,i,r),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),i=this._getPrimitive();if(r(i))this._prepareResourcesPrimitive(t,i);else{const i=M(this.symbolLayer),r=d(i);r&&"application/json"===r.mediaType?await this._prepareResourcesCIM(t,JSON.parse(r.data),e):await this._prepareResourcesHref(t,i,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=A(this._getIconSize());if(e)throw new i("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?m(e.size):ae);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let i=""===t?null:this._cimSymbolTextures.get(t);if(!i){const r={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol3D(this._cimLayers,e,"esriGeometryPoint",r,void 0,void 0);this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height,powerOfTwoResizeMode:Q.PAD};i=new ee(s.imageData,a),this._cimSymbolTextures.set(t,i),this._context.stage.add(i)}return i}_computeSize(e,t){const i=e.width/e.height;return i>1?[t,Math.round(t/i)]:[Math.round(t*i),t]}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(me(t)){const{screenLength:i,minWorldLength:s,maxWorldLength:a}=t.verticalOffset;e.verticalOffset={screenLength:m(i),minWorldLength:s||0,maxWorldLength:r(a)?a:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const i=this._getOutlineSize();if(ue(t)&&0===i)throw new Error("Nothing to render");if(this._outlineSize=i,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,r(this._context.sharedResources.textures)){const i=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>$(t)));this._texture=i.texture,this._releaseTexture=i,e.textureId=this._texture.id}e.textureIsSignedDistanceField=!0,e.distanceFieldBoundingBox=le;const s=this._getIconSize();this._size=[s,s],this._symbolTextureRatio=1/ne,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,s,a){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(r(this._context.sharedResources.textures)){const r=await t(this._context.sharedResources.textures.fromUrl(s,n,{signal:a}));if(!1===r.ok){c(r.error);throw new i("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${s})`)}this._releaseTexture=r.value;const l=r.value.texture,h=l.params;this._size=this._computeSize(h,o),e.textureId=l.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,i){const r=new ie({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;h(i),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let a,o;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol(r,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:i}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,i=await R(t,this._context.layer.spatialReference,s);o=(e,t,r)=>{const s=j(i,e,{$view:r},"esriGeometryPoint",t);return null!==s?s:1}}else a=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=a||o||1;const n=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];h(i);const l=this._context.layer.fieldsIndex;this._cimRequiredFields=n.map((e=>l.get(e).name)),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||C}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(r(t.outline)&&null!=t.outline.size)return Math.max(m(t.outline.size),0);return e=ue(this._getPrimitive())?oe:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),i=this.symbolLayer,a=s(i,"outline","color");if(r(a)){const i=e.toUnitRGB(a),r=a.a*t;return[i[0],i[1],i[2],r]}return[0,0,0,0]}_getFillColor(){if(ue(this._getPrimitive()))return I;const e=a(this._getPrimitive()),t=s(this.symbolLayer,"material","color");return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?p((t.x||0)+.5,.5-(t.y||0)):e in V?V[e]:V.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers?this._fastUpdates={enabled:!1}:this._fastUpdates=H(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates.enabled&&Object.assign(e,this._fastUpdates.materialParameters),this._cimLayers){let i=r(e.textureId)?this._cimSymbolMaterials.get(e.textureId):null;return i||(i=new te(e),this._cimSymbolMaterials.set(o(e.textureId,0),i),t.add(i)),i}return this._material=new te(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=n(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const i=e.size[t];i&&"symbol-value"!==i&&"proportional"!==i&&(e.size[t]=m(i))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let i,r=[0,0];if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};i=this._createMaterialAndAddToStage(s,this._context.stage),r=[e.params.width,e.params.height]}else r=this._size,i=l(this._material);const s=B(t.geometry);if(a(s))return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const o=e.renderingInfo,n=this._getVertexOpacityAndColor(o);let c=1;if(!this._fastUpdates.enabled||!this._fastUpdates.visualVariables.size){const e=r[0]>r[1]?r[0]:r[1];c=this._getScaleFactor(o,e)}c*=this._symbolTextureRatio;const h=p(r[0]*c,r[1]*c),m=this.setGraphicElevationContext(t,new U);return this.ensureDrapedStatus("on-the-ground"===m.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,i,n,h,e.layer.uid):this._createAs3DShape(t,s,i,n,h,m,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((i=>{i.setParameters({color:e}),i.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,s=T(he.elevationModeChangeTypes,i,r);if(s!==O.UPDATE)return s;const a=E(r)||"absolute-height"===r;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!!this._getPrimitive()}skipHighSymbolLodsChanged(){return!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return G.Recreate_Symbol;if(!q(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return G.Recreate_Symbol;r(this._material)&&this._material.setParameters(this._fastUpdates.materialParameters)}return G.Fast_Update}_defaultElevationInfoNoZ(){return de}_createAs3DShape(e,t,i,r,s,o,n){const l=this.getFastUpdateAttrValues(e),c=l?e=>W(this._fastUpdates.materialParameters,l,e):void 0,h=this._context.layer.uid,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerUid:h}),u=X(i,se,null,r,s,_e,null,l,m),d=N(this._context,t,u,o,n,c);if(a(d))return null;const _=new D(this,d.object,[u],null,null,w,o);return _.alignedSampledElevation=d.sampledElevation,_.needsElevationUpdates=E(o.mode)||"absolute-height"===o.mode,_.getScreenSize=this._createScreenSizeGetter(s,c),_.calculateRelativeScreenBounds=e=>i.calculateRelativeScreenBounds(_.getScreenSize(),1,e),k(_,t,this._context.elevationProvider),_}_createAsOverlay(e,t,i,s,a,o){i.renderPriority=this._renderPriority;const n=v();z(t,n,this._context.overlaySR),n[2]=K;const l=this._context.clippingExtent;if(r(l)&&!P(l,n))return null;const c=this.getFastUpdateAttrValues(e),h=c?e=>W(this._fastUpdates.materialParameters,c,e):void 0,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),u=X(i,se,n,s,a,null,null,c,m),d=new Y(u,{layerUid:o,graphicUid:e.uid,shaderTransformer:h});n[3]=0,S(d.boundingSphere,n);const _=new L(this,[d],null,this._context.drapeSourceRenderer);return _.getScreenSize=this._createScreenSizeGetter(a,h),_.calculateRelativeScreenBounds=e=>i.calculateRelativeScreenBounds(_.getScreenSize(),1,e),_}_createScreenSizeGetter(e,t){const i=this._outlineSize+2;if(this._fastUpdates.enabled){const r=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=f())=>{const a=t(re);return e[0]=a[0]*r+i,e[1]=a[5]*s+i,e}}{const t=e[0]/this._symbolTextureRatio+i,r=e[1]/this._symbolTextureRatio+i;return(e=f())=>(e[0]=t,e[1]=r,e)}}_fastVisualVariableConvertOptions(){const e=this._size[0]>this._size[1]?this._size[0]:this._size[1],t=x(e,e,e),i=u(1),r=e*i;return{modelSize:t,symbolSize:x(r,r,r),unitInMeters:i,transformation:{anchor:y,scale:g,rotation:y}}}_getGraphicHash(e){let t="";for(const i of this._cimRequiredFields)t+=i+e.attributes[i];return t}_forEachMaterial(e){r(this._material)&&e(this._material),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._material}}}function me(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ue(e){return!a(e)&&("cross"===e||"x"===e)}he.PRIMITIVE_SIZE=ce,he.elevationModeChangeTypes={definedChanged:O.UPDATE,staysOnTheGround:O.NONE,onTheGroundChanged:O.RECREATE};const de={mode:"relative-to-ground",offset:0},_e=b(0,0,0,1);export{he as Graphics3DIconSymbolLayer};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../Color.js";import{isSome as t,isNone as r}from"../../../../core/maybe.js";import{pt2px as i}from"../../../../core/screenUtils.js";import{Z as a,a as n}from"../../../../chunks/vec2f64.js";import{c as s}from"../../../../chunks/vec3f64.js";import{c as o}from"../../../../chunks/vec4f64.js";import{textSymbolLayerSupportsVerticalOffset as l}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as c}from"./ElevationAligners.js";import{SymbolUpdateType as m,elevationModeChangeUpdateType as h,needsElevationUpdates2D as d}from"./elevationAlignmentUtils.js";import{ElevationContext as p}from"./ElevationContext.js";import f from"./Graphics3DGraphicCreationContext.js";import{Graphics3DObject3DGraphicLayer as u}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as g}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as y}from"./Graphics3DSymbolLayer.js";import{computeCentroid as v}from"./graphicUtils.js";import{createStageObject as b,extendPointGraphicElevationContext as C}from"./pointUtils.js";import{emptySymbolComplexity as _}from"./symbolComplexity.js";import{Attribute as O}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as x}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as P}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as j}from"../../webgl-engine/lib/VertexAttribute.js";import{LineCalloutMaterial as E,Parameters as U}from"../../webgl-engine/materials/LineCalloutMaterial.js";class w extends y{constructor(e,t){super(e,null,t,S),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){this._material=new E(this._materialParameters),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}_perInstanceMaterialParameters(e){const t=this._materialParameters;return t.screenOffset=e.screenOffset||a,t.centerOffsetUnits=e.centerOffsetUnits||"world",t}get _materialParameters(){const r=new U,a=this.symbol,n=a.callout;if(r.color=t(n.color)?e.toUnitRGBA(n.color):[0,0,0,0],r.color[3]*=this._getLayerOpacity(),r.size=i(n.size||0),a.verticalOffset){const{screenLength:e,minWorldLength:n,maxWorldLength:s}=a.verticalOffset;r.verticalOffset={screenLength:i(e),minWorldLength:n||0,maxWorldLength:t(s)?s:1/0}}r.borderColor=t(n.border)&&t(n.border.color)?e.toUnitRGBA(n.border.color):null;const s="object"===a.symbolLayers.getItemAt(0).type,o="label-3d"===a.type;return r.occlusionTest=!s,r.shaderPolygonOffset=s?0:void 0,r.depthHUDAlignStart=o,r.hasSlicePlane=this._context.slicePlaneEnabled,r.screenSizePerspective=this._context.screenSizePerspectiveEnabled?this._context.sharedResources.screenSizePerspectiveSettings:null,r}_defaultElevationInfoNoZ(){return L}createGraphics3DGraphic(e){const t=e.renderingInfo,i=e.graphic,a=this.setGraphicElevationContext(i,new p,t.elevationOffset||0),n=t.symbol,s="on-the-ground"===this._elevationContext.mode&&("cim"===n.type||!n.symbolLayers.some((e=>"object"===e.type||"text"===e.type)));if("label-3d"!==n.type&&s)return null;if("point-3d"===n.type&&n.symbolLayers.every((e=>"text"===e.type&&!l(e))))return null;const o=v(i.geometry);return r(o)?null:this._createAs3DShape(o,a,t,i.uid)}layerOpacityChanged(){t(this._material)&&this._material.setParameters(this._materialParameters)}layerElevationInfoChanged(e,r,i){const a=this._elevationContext.mode,n=h(w.elevationModeChangeTypes,i,a);return n!==m.UPDATE||e.forEach((e=>{const i=r(e);t(i)&&this.updateGraphicElevationContext(e.graphic,i)})),n}slicePlaneEnabledChanged(){return r(this._material)||this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}setGraphicElevationContext(e,t,r=0){const i=super.setGraphicElevationContext(e,t);return i.addOffsetRenderUnits(r),i}updateGraphicElevationContext(e,r){this.setGraphicElevationContext(e,r.elevationContext,t(r.metadata)?r.metadata.elevationOffset:0),r.needsElevationUpdates=d(r.elevationContext.mode)}computeComplexity(){return{primitivesPerFeature:2,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:_.memory}}_createVertexData(e){const{translation:t,centerOffset:r}=e,i=new O(t?[t[0],t[1],t[2]]:[0,0,0],3,!0),a=new O(r?[r[0],r[1],r[2],r[3]]:[0,0,0,1],4,!0);return[[j.POSITION,i],[j.NORMAL,new O([0,0,1],3,!0)],[j.AUXPOS1,a]]}_getOrCreateMaterial(e){const i=this._perInstanceMaterialParameters(e),a=E.uniqueMaterialIdentifier(i);if(t(this._material)&&a===this._material.uniqueMaterialIdentifier)return{material:this._material,isUnique:!1};if(t(e.materialCollection)){let t=e.materialCollection.get(a);return r(t)&&(t=new E(i),e.materialCollection.add(a,t)),{material:t,isUnique:!1}}return{material:new E(i),isUnique:!0}}_createAs3DShape(e,t,i,a){const n=this._context.layer.uid,s=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:n}),o=this._getOrCreateMaterial(i),l=new P(o.material,this._createVertexData(i),G,null,x.Point,s),m=b(this._context,e,l,t,a);if(r(m))return null;const h=new u(this,m.object,[l],o.isUnique?[o.material]:null,null,c,t);return h.metadata=new g(i.elevationOffset),h.alignedSampledElevation=m.sampledElevation,h.needsElevationUpdates=d(t.mode),C(h,e,this._context.elevationProvider),h}}w.elevationModeChangeTypes={definedChanged:m.UPDATE,staysOnTheGround:m.UPDATE,onTheGroundChanged:m.RECREATE};const A=[0],G=[[j.POSITION,A],[j.NORMAL,A],[j.AUXPOS1,A]],L={mode:"relative-to-ground",offset:0},S={ignoreDrivers:!0,renderPriority:0,renderPriorityStep:1};class D{constructor(e,t,r=s(),i=o(),a=n(),l="world",c=0,m=null){this.renderer=e,this.symbol=t,this.translation=r,this.centerOffset=i,this.screenOffset=a,this.centerOffsetUnits=l,this.elevationOffset=c,this.materialCollection=m}}class I extends f{}export{w as Graphics3DLineCalloutSymbolLayer,I as LineCalloutCreationContext,D as LineCalloutSymbolLayerRenderingInfo};
5
+ import e from"../../../../Color.js";import{isSome as t,isNone as r}from"../../../../core/maybe.js";import{pt2px as i}from"../../../../core/screenUtils.js";import{Z as a,a as n}from"../../../../chunks/vec2f64.js";import{c as s}from"../../../../chunks/vec3f64.js";import{c as o}from"../../../../chunks/vec4f64.js";import{textSymbolLayerSupportsVerticalOffset as l}from"../../../../symbols/callouts/calloutUtils.js";import{perObjectElevationAligner as c}from"./ElevationAligners.js";import{SymbolUpdateType as m,elevationModeChangeUpdateType as h,needsElevationUpdates2D as d}from"./elevationAlignmentUtils.js";import{ElevationContext as p}from"./ElevationContext.js";import f from"./Graphics3DGraphicCreationContext.js";import{Graphics3DObject3DGraphicLayer as u}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as g}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as y}from"./Graphics3DSymbolLayer.js";import{computeCentroid as v}from"./graphicUtils.js";import{createStageObject as b,extendPointGraphicElevationContext as C}from"./pointUtils.js";import{emptySymbolComplexity as _}from"./symbolComplexity.js";import{Attribute as O}from"../../webgl-engine/lib/Attribute.js";import{ContentObjectType as x}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as P}from"../../webgl-engine/lib/Geometry.js";import{VertexAttribute as j}from"../../webgl-engine/lib/VertexAttribute.js";import{LineCalloutMaterial as E,Parameters as U}from"../../webgl-engine/materials/LineCalloutMaterial.js";class w extends y{constructor(e,t){super(e,null,t,S),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){this._material=new E(this._materialParameters),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}_perInstanceMaterialParameters(e){const t=this._materialParameters;return t.screenOffset=e.screenOffset||a,t.centerOffsetUnits=e.centerOffsetUnits||"world",t}get _materialParameters(){const r=new U,a=this.symbol,n=a.callout;if(r.color=t(n.color)?e.toUnitRGBA(n.color):[0,0,0,0],r.color[3]*=this._getLayerOpacity(),r.size=i(n.size||0),a.verticalOffset){const{screenLength:e,minWorldLength:n,maxWorldLength:s}=a.verticalOffset;r.verticalOffset={screenLength:i(e),minWorldLength:n||0,maxWorldLength:t(s)?s:1/0}}r.borderColor=t(n.border)&&t(n.border.color)?e.toUnitRGBA(n.border.color):null;const s="object"===a.symbolLayers.getItemAt(0).type,o="label-3d"===a.type;return r.occlusionTest=!s,r.shaderPolygonOffset=s?0:void 0,r.depthHUDAlignStart=o,r.hasSlicePlane=this._context.slicePlaneEnabled,r.screenSizePerspective=this._context.screenSizePerspectiveEnabled?this._context.sharedResources.screenSizePerspectiveSettings:null,r}_defaultElevationInfoNoZ(){return L}createGraphics3DGraphic(e){const t=e.renderingInfo,i=e.graphic,a=this.setGraphicElevationContext(i,new p,t.elevationOffset||0),n=t.symbol,s="on-the-ground"===this._elevationContext.mode&&("cim"===n.type||!n.symbolLayers.some((e=>"object"===e.type||"text"===e.type)));if("label-3d"!==n.type&&s)return null;if("point-3d"===n.type&&n.symbolLayers.every((e=>"text"===e.type&&!l(e))))return null;const o=v(i.geometry);return r(o)?null:this._createAs3DShape(o,a,t,i.uid)}layerOpacityChanged(){t(this._material)&&this._material.setParameters(this._materialParameters)}layerElevationInfoChanged(e,r,i){const a=this._elevationContext.mode,n=h(w.elevationModeChangeTypes,i,a);return n!==m.UPDATE||e.forEach((e=>{const i=r(e);t(i)&&this.updateGraphicElevationContext(e.graphic,i)})),n}slicePlaneEnabledChanged(){return r(this._material)||this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}skipHighSymbolLodsChanged(){return!0}setGraphicElevationContext(e,t,r=0){const i=super.setGraphicElevationContext(e,t);return i.addOffsetRenderUnits(r),i}updateGraphicElevationContext(e,r){this.setGraphicElevationContext(e,r.elevationContext,t(r.metadata)?r.metadata.elevationOffset:0),r.needsElevationUpdates=d(r.elevationContext.mode)}computeComplexity(){return{primitivesPerFeature:2,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:_.memory}}_createVertexData(e){const{translation:t,centerOffset:r}=e,i=new O(t?[t[0],t[1],t[2]]:[0,0,0],3,!0),a=new O(r?[r[0],r[1],r[2],r[3]]:[0,0,0,1],4,!0);return[[j.POSITION,i],[j.NORMAL,new O([0,0,1],3,!0)],[j.AUXPOS1,a]]}_getOrCreateMaterial(e){const i=this._perInstanceMaterialParameters(e),a=E.uniqueMaterialIdentifier(i);if(t(this._material)&&a===this._material.uniqueMaterialIdentifier)return{material:this._material,isUnique:!1};if(t(e.materialCollection)){let t=e.materialCollection.get(a);return r(t)&&(t=new E(i),e.materialCollection.add(a,t)),{material:t,isUnique:!1}}return{material:new E(i),isUnique:!0}}_createAs3DShape(e,t,i,a){const n=this._context.layer.uid,s=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:a,layerUid:n}),o=this._getOrCreateMaterial(i),l=new P(o.material,this._createVertexData(i),G,null,x.Point,s),m=b(this._context,e,l,t,a);if(r(m))return null;const h=new u(this,m.object,[l],o.isUnique?[o.material]:null,null,c,t);return h.metadata=new g(i.elevationOffset),h.alignedSampledElevation=m.sampledElevation,h.needsElevationUpdates=d(t.mode),C(h,e,this._context.elevationProvider),h}}w.elevationModeChangeTypes={definedChanged:m.UPDATE,staysOnTheGround:m.UPDATE,onTheGroundChanged:m.RECREATE};const A=[0],G=[[j.POSITION,A],[j.NORMAL,A],[j.AUXPOS1,A]],L={mode:"relative-to-ground",offset:0},S={ignoreDrivers:!0,renderPriority:0,renderPriorityStep:1};class D{constructor(e,t,r=s(),i=o(),a=n(),l="world",c=0,m=null){this.renderer=e,this.symbol=t,this.translation=r,this.centerOffset=i,this.screenOffset=a,this.centerOffsetUnits=l,this.elevationOffset=c,this.materialCollection=m}}class I extends f{}export{w as Graphics3DLineCalloutSymbolLayer,I 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.26/esri/copyright.txt for details.
4
4
  */
5
- import"../../../../geometry.js";import e from"../../../../core/Error.js";import{isSome as t,applySome as r,isNone as a,releaseMaybe as i,unwrapOr as s,get as o,unwrap as n}from"../../../../core/maybe.js";import{px2pt as l,pt2px as h}from"../../../../core/screenUtils.js";import{s as c}from"../../../../chunks/vec4.js";import{f as p,d}from"../../../../chunks/vec4f64.js";import{create as m,empty as _,expandWithBuffer as y,intersectsClippingArea as u,expandWithAABB as g}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as f}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as M}from"./ElevationAligners.js";import{SymbolUpdateType as C,elevationModeChangeUpdateType as b,needsElevationUpdates2D as v}from"./elevationAlignmentUtils.js";import{ElevationContext as E}from"./ElevationContext.js";import L from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as P}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as w,getAttributeValue as x}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{parseLineMarkerStyle as D,parseCapType as U}from"./lineUtils.js";import{initFastSymbolUpdatesState as R,updateFastSymbolUpdatesState as S}from"../support/FastSymbolUpdates.js";import A from"../../support/debugFlags.js";import{createGeometry as j}from"../../support/engineContent/line.js";import{prepareMarkerResources as z}from"../../support/engineContent/marker.js";import{geometryToRenderInfo as O,geometryToRenderInfoDraped as G}from"../../support/renderInfoUtils/line.js";import{Object3D as V}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as I}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as T}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as F}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as W}from"../../webgl-engine/materials/RibbonLineMaterial.js";import B from"../../../../geometry/Extent.js";import H from"../../../../geometry/Polygon.js";const N=["polyline","polygon","extent"];class q extends w{constructor(e,t,r,a){super(e,t,r,a)}async doLoad(){if(this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[1,1,1],unitInMeters:1,transformation:{anchor:[0,0,0],scale:[1,1,1],rotation:[0,0,0]},supportedTypes:{size:!0,color:!0,opacity:!0,rotation:!1}},this._context.renderer&&this._context.renderer.visualVariables&&this._context.renderer.visualVariables.length>0?this._fastUpdates=R(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1},!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:l(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}this._markerTexture=t(this.symbolLayer.marker)&&t(this._context.sharedResources.textures)?z(this._context.sharedResources.textures,D(this.symbolLayer.marker.style)):null}_getMaterialParameters(e,t=!1){const r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);this._patternHidesLine&&!t&&(r[3]=0);const a={width:this._computeMaterialWidth(this.symbolLayer?.size),color:r,hasPolygonOffset:!0,join:this.symbolLayer.join||"miter",cap:U(this.symbolLayer.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:F(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};return this._fastUpdates&&this._fastUpdates.visualVariables?{...a,...this._fastUpdates.materialParameters}:a}get _materialColor(){return r(this.symbolLayer.material,(e=>e.color))}get _markerColor(){return r(this.symbolLayer.marker,(e=>e.color))}get _lineMaterial(){return a(this._lineMaterialCached)&&(this._lineMaterialCached=new W(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterialCached)),this._lineMaterialCached}get _ringMaterial(){return a(this._ringMaterialCached)&&(this._ringMaterialCached=new W(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterialCached)),this._ringMaterialCached}get _wireframeLineMaterial(){return a(this._wireframeLineMaterialCached)&&(this._wireframeLineMaterialCached=new W({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterialCached)),this._wireframeLineMaterialCached}get _wireframeRingMaterial(){return a(this._wireframeRingMaterialCached)&&(this._wireframeRingMaterialCached=new W({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterialCached)),this._wireframeRingMaterialCached}get _markerMaterial(){return a(this._markerMaterialCached)&&t(this.symbolLayer.marker)&&t(this._markerTexture)&&(this._markerMaterialCached=new T({...this._getMaterialParameters(!1,!0),placement:this.symbolLayer.marker.placement,textureId:this._markerTexture.texture.id}),this._context.stage.add(this._markerMaterialCached)),this._markerMaterialCached}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterialCached=null,this._ringMaterialCached=null,this._wireframeLineMaterialCached=null,this._wireframeRingMaterialCached=null,this._markerMaterialCached=null,this._markerTexture=i(this._markerTexture)}_getDrivenSize(e){return this._drivenProperties.size&&e.size?h(f(e.size)):1}_getSizeFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size?x(this._fastUpdates.visualVariables.size.field,e):null}_getDrivenColor(e){const t=p(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}_getColorFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.color?x(this._fastUpdates.visualVariables.color.field,e):null}_getOpacityFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.opacity?x(this._fastUpdates.visualVariables.opacity.field,e):null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,N,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new E);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return k.Recreate_Symbol;if(!S(this._fastUpdates,t,this._vvConvertOptions))return k.Recreate_Symbol;this._forEachMaterial((e=>e.setParameters(this._fastUpdates.materialParameters)))}return k.Fast_Update}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=U(s(t.cap.newValue,"butt")),delete t.cap);const a=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,a),e.symbolLayerStatePatches.push((()=>this._forEachMaterial((e=>e.setParameters(r)))))}layerOpacityChanged(){this._forEachMaterial(((e,t)=>this._updateMaterialLayerOpacity(e,t)))}_forEachMaterial(e){t(this._lineMaterialCached)&&e(this._lineMaterialCached),t(this._ringMaterialCached)&&e(this._ringMaterialCached),t(this._wireframeLineMaterialCached)&&e(this._wireframeLineMaterialCached),t(this._wireframeRingMaterialCached)&&e(this._wireframeRingMaterialCached),t(this._markerMaterialCached)&&e(this._markerMaterialCached,!0)}_updateMaterialLayerOpacity(e,t=!1){const r=e.parameters.color,a=o(this.symbolLayer,"material","color"),i=this._patternHidesLine&&!t?0:this._getCombinedOpacity(a),s=p(r[0],r[1],r[2],i);e.setParameters({color:s})}layerElevationInfoChanged(e,t,r){const a=this._elevationContext.mode,i=b(q.elevationModeChangeTypes,r,a);if(i!==C.UPDATE)return i;const s=v(a);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>s))}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof B)return H.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,r,a){const i=e.graphic,s=this._getGeometryAsPolygonOrPolyline(i.geometry),o="polygon"===s.type?s.rings:s.paths,n=new Array,l=m(),h=O(s,this._context.elevationProvider,this._context.renderCoordsHelper,r),c="polygon"===s.type?"rings":"paths";this._logGeometryCreationWarnings(h,o,c,"LineSymbol3DLayer");for(let m=0;m<h.lines.length;m++){const r=h.lines[m],i=r.position,o=r.mapPositions;if(t(this._context.clippingExtent)&&(_(l),y(l,o),!u(l,this._context.clippingExtent)))continue;const c=this._createGeometry("polygon"===s.type?this._ringMaterial:this._lineMaterial,e,i,o,s.type,J.ELEVATED,a);n.push(c),A.LINE_WIREFRAMES&&n.push(c.instantiate({material:"polygon"===s.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),t(this._markerMaterial)&&n.push(c.instantiate({material:this._markerMaterial}))}if(0===n.length)return null;const p=new V({geometries:n,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:a}}),d=new P(this,p,n,null,null,M,r);return d.alignedSampledElevation=h.sampledElevation,d.needsElevationUpdates=v(r.mode),d}_createGeometry(e,t,r,a,i,s,o){const n="polygon"===i,l=this._fastUpdates.enabled&&this._fastUpdates.visualVariables.color,h=this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid});return j(e,{overlayInfo:s===J.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,removeDuplicateStartEnd:n,mapPositions:a,attributeData:{position:r,size:h?null:this._getDrivenSize(t.renderingInfo),color:l?null:this._getDrivenColor(t.renderingInfo),sizeFeature:this._getSizeFeatureAttributeData(t.graphic),colorFeature:this._getColorFeatureAttributeData(t.graphic),opacityFeature:this._getOpacityFeatureAttributeData(t.graphic)}},c)}_createAsOverlay(e,r){const a=e.graphic,i=this._getGeometryAsPolygonOrPolyline(a.geometry),s="polygon"===i.type?i.rings:i.paths,o="polygon"===i.type?this._ringMaterial:this._lineMaterial;o.renderPriority=this._renderPriority;const l=A.LINE_WIREFRAMES?"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,h=this._markerMaterial;t(l)&&(l.renderPriority=this._renderPriority-.001),t(h)&&(h.renderPriority=this._renderPriority-.002);const c=new Array,p=m(),d=_(),f=G(i,this._context.overlaySR),M="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(f,s,M,"LineSymbol3DLayer");for(const m of f.lines){if(_(p),y(p,m.position),!u(p,this._context.clippingExtent))continue;g(d,p);const s=t=>{const s=this._createGeometry(t,e,m.position,void 0,i.type,J.DRAPED,a.uid),o=new I(s,{layerUid:r,graphicUid:a.uid});return c.push(o),o};if(t(h)){const e=s(h),t=n(this.symbolLayer.marker).placement;"begin"!==t&&"begin-end"!==t||y(p,m.position,0,1),"end"!==t&&"begin-end"!==t||y(p,m.position,m.position.length-3,1),this._updateBoundingSphere(e,p)}const f=s(o);if(this._updateBoundingSphere(f,p),A.LINE_WIREFRAMES){const e=s(l);this._updateBoundingSphere(e,p)}}return new L(this,c,d,this._context.drapeSourceRenderer)}_updateBoundingSphere(e,t){c(e.boundingSphere,.5*(t[0]+t[3]),.5*(t[1]+t[4]),0,.5*Math.sqrt((t[3]-t[0])*(t[3]-t[0])+(t[4]-t[1])*(t[4]-t[1])))}get _patternHidesLine(){const e=this.symbolLayer.pattern;return t(e)&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=s(e,l(1)),this._drivenProperties.size?this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size?h(1):1:h(e)}_prepareMaterialPatch(e,t,i){const s=t.material;if(a(s))return void(i.changed&&i.useMaterialColor&&this._patchMaterialColor(this._getCombinedOpacityAndColor(this._materialColor),this._markerMaterialCached,e));if("collection"===s.type)return;const o="complete"===s.type?r(s.newValue,(e=>e.color)):"complete"===s.diff.color?.type?s.diff.color.newValue:null,n=this._getCombinedOpacityAndColor(o);i.useMaterialColor&&this._patchMaterialColor(d(n),this._markerMaterialCached,e),this._patternHidesLine&&(n[3]=0),this._patchMaterialColor(n,this._lineMaterialCached,e),delete t.material}_prepareMarkerPatch(e,r){const i=r.marker;if(a(i)||"partial"!==i.type||t(i.diff.style)||t(i.diff.placement)||t(i.diff.color)&&"complete"!==i.diff.color.type)return{changed:!1,useMaterialColor:a(this._markerColor)};const s=i.diff.color;if(a(s))return delete r.marker,{changed:!1,useMaterialColor:a(this._markerColor)};const o=n(s.newValue);return a(o)?(delete r.marker,{changed:!0,useMaterialColor:!0}):(this._patchMaterialColor(this._getCombinedOpacityAndColor(o),this._markerMaterialCached,e),delete r.marker,{changed:!0,useMaterialColor:!1})}_patchMaterialColor(e,t,r){a(t)||r.symbolLayerStatePatches.push((()=>t.setParameters({color:e})))}}var J;q.elevationModeChangeTypes={definedChanged:C.RECREATE,staysOnTheGround:C.NONE,onTheGroundChanged:C.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(J||(J={}));export{q as Graphics3DLineSymbolLayer};
5
+ import"../../../../geometry.js";import e from"../../../../core/Error.js";import{isSome as t,applySome as r,isNone as a,releaseMaybe as i,unwrapOr as s,get as o,unwrap as n}from"../../../../core/maybe.js";import{px2pt as l,pt2px as h}from"../../../../core/screenUtils.js";import{s as c}from"../../../../chunks/vec4.js";import{f as p,d}from"../../../../chunks/vec4f64.js";import{create as m,empty as _,expandWithBuffer as y,intersectsClippingArea as u,expandWithAABB as g}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as f}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as C}from"./ElevationAligners.js";import{SymbolUpdateType as M,elevationModeChangeUpdateType as b,needsElevationUpdates2D as v}from"./elevationAlignmentUtils.js";import{ElevationContext as E}from"./ElevationContext.js";import L from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as P}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as w,getAttributeValue as x}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{parseLineMarkerStyle as D,parseCapType as S}from"./lineUtils.js";import{initFastSymbolUpdatesState as U,updateFastSymbolUpdatesState as R}from"../support/FastSymbolUpdates.js";import A from"../../support/debugFlags.js";import{createGeometry as j}from"../../support/engineContent/line.js";import{prepareMarkerResources as z}from"../../support/engineContent/marker.js";import{geometryToRenderInfo as O,geometryToRenderInfoDraped as G}from"../../support/renderInfoUtils/line.js";import{Object3D as V}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as I}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as T}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as F}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as W}from"../../webgl-engine/materials/RibbonLineMaterial.js";import H from"../../../../geometry/Extent.js";import B from"../../../../geometry/Polygon.js";const N=["polyline","polygon","extent"];class q extends w{constructor(e,t,r,a){super(e,t,r,a)}async doLoad(){if(this._vvConvertOptions={modelSize:[1,1,1],symbolSize:[1,1,1],unitInMeters:1,transformation:{anchor:[0,0,0],scale:[1,1,1],rotation:[0,0,0]},supportedTypes:{size:!0,color:!0,opacity:!0,rotation:!1}},this._context.renderer&&this._context.renderer.visualVariables&&this._context.renderer.visualVariables.length>0?this._fastUpdates=U(this._context.renderer,this._vvConvertOptions):this._fastUpdates={enabled:!1},!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:l(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}this._markerTexture=t(this.symbolLayer.marker)&&t(this._context.sharedResources.textures)?z(this._context.sharedResources.textures,D(this.symbolLayer.marker.style)):null}_getMaterialParameters(e,t=!1){const r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);this._patternHidesLine&&!t&&(r[3]=0);const a={width:this._computeMaterialWidth(this.symbolLayer?.size),color:r,hasPolygonOffset:!0,join:this.symbolLayer.join||"miter",cap:S(this.symbolLayer.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:F(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};return this._fastUpdates&&this._fastUpdates.visualVariables?{...a,...this._fastUpdates.materialParameters}:a}get _materialColor(){return r(this.symbolLayer.material,(e=>e.color))}get _markerColor(){return r(this.symbolLayer.marker,(e=>e.color))}get _lineMaterial(){return a(this._lineMaterialCached)&&(this._lineMaterialCached=new W(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterialCached)),this._lineMaterialCached}get _ringMaterial(){return a(this._ringMaterialCached)&&(this._ringMaterialCached=new W(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterialCached)),this._ringMaterialCached}get _wireframeLineMaterial(){return a(this._wireframeLineMaterialCached)&&(this._wireframeLineMaterialCached=new W({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterialCached)),this._wireframeLineMaterialCached}get _wireframeRingMaterial(){return a(this._wireframeRingMaterialCached)&&(this._wireframeRingMaterialCached=new W({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterialCached)),this._wireframeRingMaterialCached}get _markerMaterial(){return a(this._markerMaterialCached)&&t(this.symbolLayer.marker)&&t(this._markerTexture)&&(this._markerMaterialCached=new T({...this._getMaterialParameters(!1,!0),placement:this.symbolLayer.marker.placement,textureId:this._markerTexture.texture.id}),this._context.stage.add(this._markerMaterialCached)),this._markerMaterialCached}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterialCached=null,this._ringMaterialCached=null,this._wireframeLineMaterialCached=null,this._wireframeRingMaterialCached=null,this._markerMaterialCached=null,this._markerTexture=i(this._markerTexture)}_getDrivenSize(e){return this._drivenProperties.size&&e.size?h(f(e.size)):1}_getSizeFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size?x(this._fastUpdates.visualVariables.size.field,e):null}_getDrivenColor(e){const t=p(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}_getColorFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.color?x(this._fastUpdates.visualVariables.color.field,e):null}_getOpacityFeatureAttributeData(e){return this._fastUpdates.enabled&&this._fastUpdates.visualVariables.opacity?x(this._fastUpdates.visualVariables.opacity.field,e):null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,N,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new E);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return k.Recreate_Symbol;if(!R(this._fastUpdates,t,this._vvConvertOptions))return k.Recreate_Symbol;this._forEachMaterial((e=>e.setParameters(this._fastUpdates.materialParameters)))}return k.Fast_Update}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=S(s(t.cap.newValue,"butt")),delete t.cap);const a=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,a),e.symbolLayerStatePatches.push((()=>this._forEachMaterial((e=>e.setParameters(r)))))}layerOpacityChanged(){this._forEachMaterial(((e,t)=>this._updateMaterialLayerOpacity(e,t)))}_forEachMaterial(e){t(this._lineMaterialCached)&&e(this._lineMaterialCached),t(this._ringMaterialCached)&&e(this._ringMaterialCached),t(this._wireframeLineMaterialCached)&&e(this._wireframeLineMaterialCached),t(this._wireframeRingMaterialCached)&&e(this._wireframeRingMaterialCached),t(this._markerMaterialCached)&&e(this._markerMaterialCached,!0)}_updateMaterialLayerOpacity(e,t=!1){const r=e.parameters.color,a=o(this.symbolLayer,"material","color"),i=this._patternHidesLine&&!t?0:this._getCombinedOpacity(a),s=p(r[0],r[1],r[2],i);e.setParameters({color:s})}layerElevationInfoChanged(e,t,r){const a=this._elevationContext.mode,i=b(q.elevationModeChangeTypes,r,a);if(i!==M.UPDATE)return i;const s=v(a);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>s))}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}pixelRatioChanged(){return!0}skipHighSymbolLodsChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof H)return B.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,r,a){const i=e.graphic,s=this._getGeometryAsPolygonOrPolyline(i.geometry),o="polygon"===s.type?s.rings:s.paths,n=new Array,l=m(),h=O(s,this._context.elevationProvider,this._context.renderCoordsHelper,r),c="polygon"===s.type?"rings":"paths";this._logGeometryCreationWarnings(h,o,c,"LineSymbol3DLayer");for(let m=0;m<h.lines.length;m++){const r=h.lines[m],i=r.position,o=r.mapPositions;if(t(this._context.clippingExtent)&&(_(l),y(l,o),!u(l,this._context.clippingExtent)))continue;const c=this._createGeometry("polygon"===s.type?this._ringMaterial:this._lineMaterial,e,i,o,s.type,J.ELEVATED,a);n.push(c),A.LINE_WIREFRAMES&&n.push(c.instantiate({material:"polygon"===s.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),t(this._markerMaterial)&&n.push(c.instantiate({material:this._markerMaterial}))}if(0===n.length)return null;const p=new V({geometries:n,castShadow:!1,metadata:{layerUid:this._context.layer.uid,graphicUid:a}}),d=new P(this,p,n,null,null,C,r);return d.alignedSampledElevation=h.sampledElevation,d.needsElevationUpdates=v(r.mode),d}_createGeometry(e,t,r,a,i,s,o){const n="polygon"===i,l=this._fastUpdates.enabled&&this._fastUpdates.visualVariables.color,h=this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size,c=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid});return j(e,{overlayInfo:s===J.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,removeDuplicateStartEnd:n,mapPositions:a,attributeData:{position:r,size:h?null:this._getDrivenSize(t.renderingInfo),color:l?null:this._getDrivenColor(t.renderingInfo),sizeFeature:this._getSizeFeatureAttributeData(t.graphic),colorFeature:this._getColorFeatureAttributeData(t.graphic),opacityFeature:this._getOpacityFeatureAttributeData(t.graphic)}},c)}_createAsOverlay(e,r){const a=e.graphic,i=this._getGeometryAsPolygonOrPolyline(a.geometry),s="polygon"===i.type?i.rings:i.paths,o="polygon"===i.type?this._ringMaterial:this._lineMaterial;o.renderPriority=this._renderPriority;const l=A.LINE_WIREFRAMES?"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,h=this._markerMaterial;t(l)&&(l.renderPriority=this._renderPriority-.001),t(h)&&(h.renderPriority=this._renderPriority-.002);const c=new Array,p=m(),d=_(),f=G(i,this._context.overlaySR),C="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(f,s,C,"LineSymbol3DLayer");for(const m of f.lines){if(_(p),y(p,m.position),!u(p,this._context.clippingExtent))continue;g(d,p);const s=t=>{const s=this._createGeometry(t,e,m.position,void 0,i.type,J.DRAPED,a.uid),o=new I(s,{layerUid:r,graphicUid:a.uid});return c.push(o),o};if(t(h)){const e=s(h),t=n(this.symbolLayer.marker).placement;"begin"!==t&&"begin-end"!==t||y(p,m.position,0,1),"end"!==t&&"begin-end"!==t||y(p,m.position,m.position.length-3,1),this._updateBoundingSphere(e,p)}const f=s(o);if(this._updateBoundingSphere(f,p),A.LINE_WIREFRAMES){const e=s(l);this._updateBoundingSphere(e,p)}}return new L(this,c,d,this._context.drapeSourceRenderer)}_updateBoundingSphere(e,t){c(e.boundingSphere,.5*(t[0]+t[3]),.5*(t[1]+t[4]),0,.5*Math.sqrt((t[3]-t[0])*(t[3]-t[0])+(t[4]-t[1])*(t[4]-t[1])))}get _patternHidesLine(){const e=this.symbolLayer.pattern;return t(e)&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=s(e,l(1)),this._drivenProperties.size?this._fastUpdates.enabled&&this._fastUpdates.visualVariables.size?h(1):1:h(e)}_prepareMaterialPatch(e,t,i){const s=t.material;if(a(s))return void(i.changed&&i.useMaterialColor&&this._patchMaterialColor(this._getCombinedOpacityAndColor(this._materialColor),this._markerMaterialCached,e));if("collection"===s.type)return;const o="complete"===s.type?r(s.newValue,(e=>e.color)):"complete"===s.diff.color?.type?s.diff.color.newValue:null,n=this._getCombinedOpacityAndColor(o);i.useMaterialColor&&this._patchMaterialColor(d(n),this._markerMaterialCached,e),this._patternHidesLine&&(n[3]=0),this._patchMaterialColor(n,this._lineMaterialCached,e),delete t.material}_prepareMarkerPatch(e,r){const i=r.marker;if(a(i)||"partial"!==i.type||t(i.diff.style)||t(i.diff.placement)||t(i.diff.color)&&"complete"!==i.diff.color.type)return{changed:!1,useMaterialColor:a(this._markerColor)};const s=i.diff.color;if(a(s))return delete r.marker,{changed:!1,useMaterialColor:a(this._markerColor)};const o=n(s.newValue);return a(o)?(delete r.marker,{changed:!0,useMaterialColor:!0}):(this._patchMaterialColor(this._getCombinedOpacityAndColor(o),this._markerMaterialCached,e),delete r.marker,{changed:!0,useMaterialColor:!1})}_patchMaterialColor(e,t,r){a(t)||r.symbolLayerStatePatches.push((()=>t.setParameters({color:e})))}}var J;q.elevationModeChangeTypes={definedChanged:M.RECREATE,staysOnTheGround:M.NONE,onTheGroundChanged:M.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(J||(J={}));export{q as Graphics3DLineSymbolLayer};