@arcgis/core 4.34.0-next.72 → 4.34.0-next.73

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 (100) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/11acefc48c0354e675df.js +1 -0
  3. package/assets/esri/core/workers/chunks/433c4dc666a6b2c99063.js +353 -0
  4. package/assets/esri/core/workers/chunks/{1f51c94d392826fdbdf4.js → 8ce653c3c5dde10ccbcf.js} +46 -46
  5. package/assets/esri/core/workers/chunks/8d91e2d185be4a4e8598.js +1 -0
  6. package/assets/esri/core/workers/chunks/{bcc233a86e01ff1eac16.js → ae7b86bd08a44e26b339.js} +1 -1
  7. package/assets/esri/core/workers/chunks/be9edd9791a00cab9c2b.js +1 -0
  8. package/assets/esri/core/workers/chunks/e8d25d4ca9b335883f34.js +1 -0
  9. package/assets/esri/widgets/Sketch/t9n/Sketch.json +1 -1
  10. package/assets/esri/widgets/Sketch/t9n/Sketch_en.json +1 -1
  11. package/chunks/Fog.glsl.js +5 -10
  12. package/chunks/GlowComposition.glsl.js +4 -4
  13. package/chunks/Terrain.glsl.js +29 -43
  14. package/chunks/boundedPlane.js +1 -1
  15. package/config.js +1 -1
  16. package/geometry/support/boundedPlane.js +1 -1
  17. package/interfaces.d.ts +26 -3
  18. package/kernel.js +1 -1
  19. package/layers/IntegratedMesh3DTilesLayer.js +1 -1
  20. package/layers/Lyr3DWasmPerSceneView.js +1 -1
  21. package/layers/support/gaussianSplatUtils.js +1 -1
  22. package/package.json +3 -3
  23. package/support/basemapDefinitions.js +1 -1
  24. package/support/revision.js +1 -1
  25. package/views/2d/engine/flow/FlowDisplayData.js +1 -1
  26. package/views/2d/engine/flow/FlowStrategy.js +1 -1
  27. package/views/2d/engine/flow/dataUtils.js +1 -1
  28. package/views/2d/engine/flow/utils.js +1 -1
  29. package/views/2d/interactive/editingTools/TransformTool.js +1 -1
  30. package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
  31. package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementVisualization.js +1 -1
  32. package/views/3d/analysis/Slice/SliceController.js +1 -1
  33. package/views/3d/analysis/Slice/SliceTool.js +1 -1
  34. package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
  35. package/views/3d/environment/Fog.glsl.js +1 -1
  36. package/views/3d/interactive/Manipulator3D.js +1 -1
  37. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentRotate.js +1 -1
  38. package/views/3d/interactive/editingTools/transform/extentTransform/ExtentScale.js +1 -1
  39. package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
  40. package/views/3d/interactive/support/viewUtils.js +1 -1
  41. package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
  42. package/views/3d/layers/FlowSubView3D.js +1 -1
  43. package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
  44. package/views/3d/layers/graphics/Deconflictor.js +1 -1
  45. package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
  46. package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
  47. package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
  48. package/views/3d/layers/graphics/Graphics3DLineCalloutSymbolLayer.js +1 -1
  49. package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.js +1 -1
  50. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  51. package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
  52. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  53. package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
  54. package/views/3d/layers/graphics/Graphics3DSymbolLayer.js +1 -1
  55. package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
  56. package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
  57. package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
  58. package/views/3d/layers/support/Tiles3DIntersectionHandler.js +1 -1
  59. package/views/3d/state/ScreenSizePerspective.js +5 -0
  60. package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
  61. package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
  62. package/views/3d/support/SharedSymbolResources.js +1 -1
  63. package/views/3d/support/ViewSlice.js +1 -1
  64. package/views/3d/support/engineContent/line.js +1 -1
  65. package/views/3d/support/flow/FlowWorker.js +1 -1
  66. package/views/3d/support/flow/geometryUtils.js +1 -1
  67. package/views/3d/support/geometryUtils/ray.js +1 -1
  68. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  69. package/views/3d/terrain/TerrainRenderer.js +1 -1
  70. package/views/3d/terrain/TerrainSurface.js +1 -1
  71. package/views/3d/webgl-engine/core/shaderLibrary/util/ScreenSizePerspective.glsl.js +4 -4
  72. package/views/3d/webgl-engine/effects/glow/GlowComposition.glsl.js +1 -1
  73. package/views/3d/webgl-engine/effects/raymarching/RayDistanceFalloff.glsl.js +10 -0
  74. package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
  75. package/views/3d/webgl-engine/lib/SliceHelper.js +1 -1
  76. package/views/3d/webgl-engine/lib/screenSizePerspectiveUtils.js +1 -1
  77. package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
  78. package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
  79. package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
  80. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  81. package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
  82. package/views/3d/webgl-engine/shaders/AnimatedLine.glsl.js +28 -10
  83. package/views/3d/webgl-engine/shaders/RibbonLineTechnique.js +1 -1
  84. package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
  85. package/views/SceneView.js +1 -1
  86. package/views/draw/support/tooltipUtils.js +1 -1
  87. package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
  88. package/views/interactive/snapping/featureSources/featureServiceSource/tileUtils.js +1 -1
  89. package/views/support/GroundViewElevationSampler.js +1 -1
  90. package/widgets/Sketch/SketchViewModel.js +1 -1
  91. package/widgets/Sketch/VisibleElements.js +1 -1
  92. package/widgets/Sketch/support/OperationHandle.js +1 -1
  93. package/widgets/Sketch/support/sketchUtils.js +1 -1
  94. package/widgets/Sketch.js +1 -1
  95. package/assets/esri/core/workers/chunks/16cfbe7bedf75d3a86e5.js +0 -1
  96. package/assets/esri/core/workers/chunks/226833d408eb1225e168.js +0 -1
  97. package/assets/esri/core/workers/chunks/cf69f6afeaf1229e032c.js +0 -1
  98. package/assets/esri/core/workers/chunks/e21eeb4e78a46fb7e32e.js +0 -1
  99. package/assets/esri/core/workers/chunks/f87a6b32292c1464b7b7.js +0 -353
  100. package/views/3d/webgl-engine/materials/ScaleInfo.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as i,difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import u from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as _}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as f,sync as y,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/unitUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{q as C,i as b,c as x}from"../../../chunks/vec32.js";import{create as E}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P,radiusModifier as U}from"../../../geometry/ellipsoidUtils.js";import D from"../../../geometry/SpatialReference.js";import{getProjector as M}from"../../../geometry/projection/projectors.js";import{projectPointToVector as R}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{create as B,equals as I,intersection as k,intersectsSphere as A,empty as V,expand as q}from"../../../geometry/support/aaBoundingRect.js";import{copy as O,create as G}from"../../../geometry/support/frustum.js";import{isPlateCarree as N}from"../../../geometry/support/spatialReferenceUtils.js";import{m as F,c as W,n as H,o as $,e as Q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as z}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as Y}from"../../../layers/support/layerUtils.js";import{debugFlags as X}from"../support/debugFlags.js";import{ElevationRange as K}from"../support/ElevationRange.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{updatingProgress as Z}from"../support/updatingProperties.js";import{ElevationBounds as ee}from"./ElevationBounds.js";import{ElevationData as te,sampleElevation as ie}from"./ElevationData.js";import{ElevationUpdateEventImplementation as re}from"./ElevationUpdateEvent.js";import{create as se}from"./ExtentHelper.js";import{LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as le}from"./PlanarPatch.js";import{ScaleRangeQueries as oe}from"./ScaleRangeQueries.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{SplitLimits as de}from"./SplitLimits.js";import{maxRootTiles as ue,tooManyRootTilesAfterChangeError as pe,tooManyRootTilesForLayerError as ce,maxTileNeighborLevelDelta as ge,maxMemoryLodBias as _e}from"./TerrainConst.js";import{TerrainRenderer as me}from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ye,isVectorTileLayerView as Te,neighborEdgeIndices as ve,internalAssert as we,oppositeEdge as Se,isSurfaceLayerView as Ce,isGroupLayerView as be,isMapTileLayerView as xe,isBlendableLayerView as Ee,isElevationLayerView as Le,releaseTerrainData as Pe,enableTerrainInternalChecks as Ue,oppositeCorner as De,enableWaterproofTests as Me,enableInternalTerrainChecks as Re,enableTerrainWaterproofChecks as je,neighborCornerIndices as Be}from"./terrainUtils.js";import{Tile as Ie,lijEquals as ke}from"./Tile.js";import{printAllocations as Ae}from"./TilePerLayerInfo.js";import{sortTiles as Ve,IteratorPreorder as qe,IteratorPostorder as Oe,compareTilesByLij as Ge,hasLoadableSiblings as Ne,sortTilesByPOI as Fe}from"./tileUtils.js";import{TilingSchemeLogic as We}from"./TilingSchemeLogic.js";import{UpsampleInfo as He}from"./UpsampleInfo.js";import{isCompositeBlendMode as $e,blendModeFromString as Qe}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as ze}from"../../support/layerViewUtils.js";import{ImmediateTask as Ye,TaskPriority as Xe,noBudget as Ke}from"../../support/Scheduler.js";import{TextureCompressionTracker as Je}from"../../support/TextureCompressionTracker.js";import{Yield as Ze}from"../../support/Yield.js";var et;let tt=class extends n{static{et=this}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Ve(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new Je,this._iteratorPool=new u(()=>new qe,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Oe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new fe,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=E(),this._eyePosSurfaceSR=E(),this._splitLimits=new de,this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Ye,this._allTiles=new p,this._upsampleInfoPool=new u(()=>new He),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=B(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=D.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new ee(1/0,-1/0),this.rootTileElevationBounds=new ee(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;const{view:t}=e;this.overlayManager=new ne({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?he:le,this._ellipsoid=P(t.spatialReference),this._renderer=new me(this.overlayManager.renderer,t.stage,this._allTiles,this._ellipsoid.radius,this.terrainTextureCompressionTracker,t.resourceController.memoryController),ze()||(this._scaleRangeQueries=new oe)}initialize(){const{view:e}=this,{resourceController:t}=e,{memoryController:i}=t;this._tileCache=new d((e,t)=>i.newCache(e,t),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new z(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([m(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),m(()=>this.renderer.visible,e=>this.suspended=!e),m(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)}),m(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(2===t||Math.min(r,360-r)>=30)&&(this.heading=i)})],"overlayManager"),this.addHandles([m(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},f),m(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),f),m(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},y),m(()=>this.snapLevel,()=>this._viewChanged=!0,y),m(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:C})}),m(()=>X.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&X.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=h(this._treeDebugger))},T)]);const{spatialReference:a}=e;this._extentHelper=se(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new We({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(0),this._mapDataRequester=t.createStreamDataRequester(1);const o=t.scheduler;this._frameTask=o.registerTask(Xe.TERRAIN_SURFACE,this),this.addHandles([m(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),T),m(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),y),m(()=>this.extent,()=>this._updateRootTiles(),T),e.on("resize",()=>this._viewChangeUpdate()),m(()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),f),m(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,T),m(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,T),m(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),m(()=>this._userClippingExtent,()=>this._updateClippingExtent(),y)]),this.addHandles(e.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._watchUpdatingTracking?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._frameTask.remove(),this._frameTask=Ye,this._watchUpdatingTracking?.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),this._allTiles.prune(),Ie.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Ae(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,t=this.view?.clippingArea;if(null==t||null==e)return null;const i=B(),r=J(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=k(this.groundExtent,this._userClippingExtent,B()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||null!=this._rootTiles}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return 0===this._renderer.transparency}get invisible(){return 3===this._renderer.transparency}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length||!this.enabled)return null;if(0===s[0].layerInfo[0].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=M(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=b(rt,e,t,i);a(n,0,n,0);return ht(s,n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[0].length:0;if(r?.length&&0!==s&&this.enabled)for(let a=0;a<t;++a){const t=3*a;i(a,ht(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!R(e,rt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(rt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;rt[0]>t[2]&&(i+=1),rt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=M(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){if(!this.enabled||null==this._rootTiles)return null;const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;F(e,st);const r=H(st,E());i(r,0,r,0),$(st,r);const s=new K,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,st))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return this.enabled&&null!=this._rootTiles?new K(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max):null}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*U;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,mt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Q(st,mt,t);let i=null;const r=e=>{if(e&&A(e.extent,st)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?3:2:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const{tilingScheme:e}=this.tilingSchemeLogic;if(!(e!==this.tilingScheme))return;ye(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??D.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&N(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(et._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=at;let s=t.rootTilesInExtent(e,i,5*ue);if(null!=this._rootTiles){if(s.length>ue)return void l.getLogger(this).warn(pe);const e=this._rootTiles.map(e=>e.lij),t=r(e,s,ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter(e=>!(t.removed.findIndex(t=>ke(t,e.lij))>-1)||(this._purgeTile(e),!1));t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ue&&(l.getLogger(this).warn(ce),s=t.rootTilesInExtent(e,i,ue)),this._setRootTiles(s.map(e=>this._newRootTile(e)));I(i,this._rootTilesExtent)||(this._rootTilesExtent=B(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter(e=>e.loaded&&e.intersectsClippingArea);e.sort(Ge),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Ge);const t=this.renderer;e.forEach(e=>t.updateGeometryIfNeeded(e)),e.forEach(e=>this._pendingTilesForElevationUpdateEvent.add(e))}_shouldSplit(e){return 1===e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Ne(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new ee(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach(({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)});const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new ee(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=O(this._splitLimits.frustum??G(),t.frustum):this._splitLimits.frustum=null,x(this._eyePosRenderSR,t.eye),j(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(Te)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){const i=e.resetPendingUpdate(32)?32:!!e.resetPendingUpdate(16)&&16;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=lt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach(t=>q(e,t.extent,e)),this._pendingTilesForElevationUpdateEvent.clear(),lt.spatialReference=this.spatialReference,this.emit("elevation-change",lt),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Ue&&this._checkTileInvariant(),!e.hasProgressed)return Ze}_checkTileInvariant(){const e=new Map;this._allTiles.forAll(t=>e.set(t,new Set)),this._allTiles.forAll(t=>{if(ye(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce((t,i)=>t+(e(i)?0:1),0);if(ye(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(4)){ye(!t.hasPendingUpdate(1),"Tile can be both split and merge at the same time");for(const e of t.children)ye(e.leaf||e.hasPendingUpdate(4),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ge;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ge} (edge[${i}])`),ye(r,`tile level delta [${t.level}] vs [${e.level}] > ${ge}`))}ye(t.level-e.level<=ge,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ge,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ve[i],s);if(null!=a){if(t.leaf&&t.level>=ge){let i=a;for(;t.level-i.level<ge;)i=i.parent;const s=[r,t.lij[1]>>ge,t.lij[2]>>ge];if(!ke(s,i.lij)){const r=e.get(i);ye(!r.has(t),"Cannot already have neighbor"),r.add(t)}}ye(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),ye(t.level-a.level<=ge,`Tile level delta [${t.level}] vs [${a.level}] > ${ge}`)}}}),this._allTiles.forAll(t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);ye(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)})}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new dt(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=n?.hasPendingUpdate(4),o=l?4:e.shouldSplit(r,s,i),h=1===o;e.leaf?ut(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(1),e.leaf||e.setPendingUpdate(4),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),2===o&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||!this.view.pointsOfInterest?.focus||(Fe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){we(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter(e=>e.loaded&&e.intersectsClippingArea);if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];we(r.loaded),we(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=Be[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),e=>e.loaded))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(ve[t]),t=>!(!t.loaded||!t.intersectsClippingArea)&&(we(e.has(t)||Ge(r,t)<0),i(r,t),!0)),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Ue&&Me&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some(s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(4)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(4);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(4);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(1)){let t=!0;const i=s.level;if(i>=ge){const e=e=>e.leaf||i-e.level<ge;for(let r=0;r<4;++r){const a=s.findNeighborTile(ve[r],e);null!=a&&i-a.level===ge&&(t=!1,Ue&&(we(a.leaf),we(a.hasPendingUpdate(1))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done)),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.overlayManager?.updateOverlayParameters(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*_e}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?ct(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(et._tileMemcacheKey,e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){ye(e.leaf,"Tile that is already split should not be split again!"),ye(e.rendered,"Tile marked to split is not rendered"),ct(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),ye(e.rendered,"parent should be rendered"),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>ut(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){ot.spatialReference=this.spatialReference,ot.extent=e.extent,ot.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",ot)}createTile(e,t,i,r){ye(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(1),s}get _shortBatches(){return 2!==this.view.state.mode}_mergeTile(e){ye(!e.hasPendingUpdate(1),"_mergeTile sanity check"),ye(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),ye(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ut(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&this.overlayManager.updateTileOverlayParameters(e)}_handleLayerViewChanges(e=Ke){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),Ce(e)||be(e))if(this._basemapLayerViewHandles.has(e.uid)&&!be(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(xe(e)&&!Y(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ee(e)||be(e))&&$e(Qe[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Le(e)?0:1}_registerTiledLayerView(e){const t=[];if((Ee(e)||be(e))&&t.push(m(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!be(e)){const i=this._layerClassFromLayerView(e);t.push(m(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(m(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));const{layer:r}=e;"effectiveScaleRange"in r&&t.push(m(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(i))),t.push(e.on("data-changed",()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach(e=>{if(!e.layer||e.suspended||!Ce(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(1===r){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)});for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),0===e&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),1===e?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll(i=>i.removeLayerAgent(e,t)),this._allTiles.forAll(i=>i.invalidateLayerData(e,t))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Te(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then(()=>--this._asyncWorkItems).catch(t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,i,s,r),r.signal)))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();const s=0===t;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():xe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!_(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${i}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then(e=>this._frameTask.schedule(()=>r(e)),s).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[0].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",0,e.lij.toString());const s=new te(e.lij,e.extent,i);e.dataArrived(r,0,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:0});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Pe(s),_(i)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule(()=>{this.requestUpdate(),_(i)?Pe(r):this._mapTileDataArrived(e,t,r)},i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule(()=>r(e,t));return t.fetchTile(e.lij,i).then(a,n).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(1,t.uid);if(null==r)return Pe(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,1,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:1})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(i,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Me)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Re(e)}enableWaterproofnessChecks(e){je(e)}static cleanupTerrainSurface(){nt.prune()}enable(e){e!==this.enabled&&(e?(this._updateRootTiles(),this.suspended=!1):(this.suspended=!0,this._removeAllTiles(),this._setRootTiles(null)),this._set("enabled",e),this.notifyChange("ready"))}};e([w()],tt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],tt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],tt.prototype,"view",void 0),e([w({constructOnly:!0})],tt.prototype,"overlayManager",void 0),e([w({constructOnly:!0})],tt.prototype,"terrainTextureCompressionTracker",void 0),e([w()],tt.prototype,"_hasPendingUpdates",void 0),e([w()],tt.prototype,"_asyncWorkItems",void 0),e([w()],tt.prototype,"_allTilesDirty",void 0),e([w()],tt.prototype,"_allTilesSorted",void 0),e([w()],tt.prototype,"_viewChanged",void 0),e([w({type:Number})],tt.prototype,"heading",void 0),e([w()],tt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],tt.prototype,"_watchUpdatingTracking",void 0),e([w()],tt.prototype,"_frameTask",void 0),e([w()],tt.prototype,"demResolution",null),e([w({readOnly:!0})],tt.prototype,"snapLevel",null),e([w({readOnly:!0})],tt.prototype,"lodSnappingEnabled",null),e([w()],tt.prototype,"_userClippingExtent",null),e([w()],tt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],tt.prototype,"extent",null),e([w({readOnly:!0})],tt.prototype,"groundExtent",null),e([w({readOnly:!0})],tt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],tt.prototype,"updating",null),e([w({readOnly:!0})],tt.prototype,"readyToRun",null),e([w(Z)],tt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],tt.prototype,"updatingProgressValue",null),e([w()],tt.prototype,"_maxNumUpdating",void 0),e([w()],tt.prototype,"baseOpacity",null),e([w()],tt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],tt.prototype,"viewingMode",null),e([w()],tt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],tt.prototype,"ready",null),e([w({readOnly:!0})],tt.prototype,"rootTiles",null),e([w()],tt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],tt.prototype,"spatialReference",null),e([w({type:t})],tt.prototype,"backgroundColor",null),e([w({value:!1})],tt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],tt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],tt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],tt.prototype,"tilingSchemeLogic",void 0),e([w()],tt.prototype,"wireframe",null),e([w({value:!1})],tt.prototype,"suspended",null),e([w()],tt.prototype,"fadeDuration",null),e([w()],tt.prototype,"visibleElevationBounds",void 0),e([w()],tt.prototype,"rootTileElevationBounds",void 0),e([w()],tt.prototype,"_layerViewsDirty",void 0),e([w()],tt.prototype,"renderPatchBorders",null),e([w()],tt.prototype,"visualizeNormals",null),e([w()],tt.prototype,"renderingDisabled",null),e([w({readOnly:!0})],tt.prototype,"enabled",void 0),tt=et=e([S("esri.views.3d.terrain.TerrainSurface")],tt);const it=tt,rt=E(),st=W(),at=B(),nt=new p,lt=new re("ground"),ot={spatialReference:null,extent:null,scale:0};function ht(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return ie(t,i,s)}return null}class dt{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function ut(e,t){!e.leaf||e.level<ge||_t(e,e=>{t&&pt(e);const i=gt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=gt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}})}function pt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<ge||_t(e,e=>{pt(e)})}function ct(e){e.level<ge||_t(e,e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,gt(t));)t=t.parent}})}function gt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function _t(e,t){if(e.level<ge)return;const i=e.level-ge,r=e.lij[1]>>ge,s=e.lij[2]>>ge,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ve[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}const mt=E();export{it as default};
5
+ import{__decorate as e}from"tslib";import t from"../../../Color.js";import{filterInPlace as i,difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import{toConst as a}from"../../../core/compilerUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import"../../../core/has.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import u from"../../../core/ObjectPool.js";import p from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as g,isAborted as _}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as f,sync as y,initial as T}from"../../../core/reactiveUtils.js";import{getMetersPerUnitForSR as v}from"../../../core/unitUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import{subclass as S}from"../../../core/accessorSupport/decorators/subclass.js";import{q as C,i as b,c as x}from"../../../chunks/vec32.js";import{create as E}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{UpdatingHandles as L}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as P,radiusModifier as U}from"../../../geometry/ellipsoidUtils.js";import D from"../../../geometry/SpatialReference.js";import{getProjector as M}from"../../../geometry/projection/projectors.js";import{projectPointToVector as R}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as j}from"../../../geometry/projection/projectVectorToVector.js";import{create as B,equals as I,intersection as k,intersectsSphere as A,empty as V,expand as q}from"../../../geometry/support/aaBoundingRect.js";import{copy as O,create as G}from"../../../geometry/support/frustum.js";import{isPlateCarree as N}from"../../../geometry/support/spatialReferenceUtils.js";import{m as F,c as W,n as H,o as $,e as Q}from"../../../chunks/sphere.js";import{ElevationQueryTileCache as z}from"../../../layers/support/ElevationQueryTileCache.js";import{isBaseLayer as Y}from"../../../layers/support/layerUtils.js";import{debugFlags as X}from"../support/debugFlags.js";import{ElevationRange as K}from"../support/ElevationRange.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{updatingProgress as Z}from"../support/updatingProperties.js";import{ElevationBounds as ee}from"./ElevationBounds.js";import{ElevationData as te,sampleElevation as ie}from"./ElevationData.js";import{ElevationUpdateEventImplementation as re}from"./ElevationUpdateEvent.js";import{create as se}from"./ExtentHelper.js";import{LayerClasses as ae}from"./LayerClass.js";import{OverlayManager as ne}from"./OverlayManager.js";import{PlanarPatch as le}from"./PlanarPatch.js";import{ScaleRangeQueries as oe}from"./ScaleRangeQueries.js";import{SphericalPatch as he}from"./SphericalPatch.js";import{SplitLimits as de}from"./SplitLimits.js";import{maxRootTiles as ue,tooManyRootTilesAfterChangeError as pe,tooManyRootTilesForLayerError as ce,maxTileNeighborLevelDelta as ge,maxMemoryLodBias as _e}from"./TerrainConst.js";import{TerrainRenderer as me}from"./TerrainRenderer.js";import fe from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as ye,isVectorTileLayerView as Te,neighborEdgeIndices as ve,internalAssert as we,oppositeEdge as Se,isSurfaceLayerView as Ce,isGroupLayerView as be,isMapTileLayerView as xe,isBlendableLayerView as Ee,isElevationLayerView as Le,releaseTerrainData as Pe,enableTerrainInternalChecks as Ue,oppositeCorner as De,enableWaterproofTests as Me,enableInternalTerrainChecks as Re,enableTerrainWaterproofChecks as je,neighborCornerIndices as Be}from"./terrainUtils.js";import{Tile as Ie,lijEquals as ke}from"./Tile.js";import{printAllocations as Ae}from"./TilePerLayerInfo.js";import{sortTiles as Ve,IteratorPreorder as qe,IteratorPostorder as Oe,compareTilesByLij as Ge,hasLoadableSiblings as Ne,sortTilesByPOI as Fe}from"./tileUtils.js";import{TilingSchemeLogic as We}from"./TilingSchemeLogic.js";import{UpsampleInfo as He}from"./UpsampleInfo.js";import{isCompositeBlendMode as $e,blendModeFromString as Qe}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{hasLayerBasedScaleVisibility as ze}from"../../support/layerViewUtils.js";import{ImmediateTask as Ye,TaskPriority as Xe,noBudget as Ke}from"../../support/Scheduler.js";import{TextureCompressionTracker as Je}from"../../support/TextureCompressionTracker.js";import{Yield as Ze}from"../../support/Yield.js";var et;let tt=class extends n{static{et=this}get allTiles(){return a(this._allTiles)}get renderedTiles(){return Ve(i(this._allTiles.toArray(),e=>e.visible&&e.rendered))}get demResolution(){const{_allTiles:e,tilingScheme:t}=this;if(0===e.length)return{min:1,max:1};const i=v(t.spatialReference);let r=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY;for(const a of e){const e=t.resolutionAtLevel(a.level)*i;r=Math.min(r,e),s=Math.max(s,e)}return{min:r,max:s}}constructor(e){super(e),this.terrainTextureCompressionTracker=new Je,this._iteratorPool=new u(()=>new qe,e=>e.remove=()=>this._iteratorPool.release(e)),this._postorderIterator=new Oe,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new fe,this._viewChanged=!1,this.heading=0,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=E(),this._eyePosSurfaceSR=E(),this._splitLimits=new de,this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new L,this._frameTask=Ye,this._allTiles=new p,this._upsampleInfoPool=new u(()=>new He),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=B(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=D.WebMercator,this._elevationProjectorCache=new Map,this.visibleElevationBounds=new ee(1/0,-1/0),this.rootTileElevationBounds=new ee(1/0,-1/0),this._projectorCache=new Map,this._tilingSchemeSpatialReference=null,this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this._oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateCarree=!1,this.enabled=!0;const{view:t}=e;this.overlayManager=new ne({...e,terrainSurface:this}),this._isGlobal=!t.state?.isLocal,this._isGeographic=this._spatialReference?.isGeographic??!1,this._tileConstructor=this._isGlobal?he:le,this._ellipsoid=P(t.spatialReference),this._renderer=new me(this.overlayManager.renderer,t.stage,this._allTiles,this.terrainTextureCompressionTracker,t.resourceController.memoryController),ze()||(this._scaleRangeQueries=new oe)}initialize(){const{view:e}=this,{resourceController:t}=e,{memoryController:i}=t;this._tileCache=new d((e,t)=>i.newCache(e,t),"terrain-tile"),this._upsampleMapCache=i.newCache("terrain-upsample",({tile:e})=>e.unloadMapData()),this._elevationQueryCache=new z(i.newCache("elevation-query"));const r=this.overlayManager;this.addHandles([m(()=>r.renderer.isEmpty,()=>this._evaluateTransparency()),m(()=>this.renderer.visible,e=>this.suspended=!e),m(()=>this.heading,e=>{this._renderer.updateHeading(e),this._updateTileTextures(0)}),m(()=>({heading:e.camera?.heading,state:e.state?.mode}),({heading:e,state:t})=>{if(null==e)return;if(this.isGlobal&&this.isGeographic||this.isWebMercatorOnPlateCarree)return void(this.heading=90*Math.round(e/90)%360);const i=Math.round(e)%360,r=Math.abs(i-this.heading);(2===t||Math.min(r,360-r)>=30)&&(this.heading=i)})],"overlayManager"),this.addHandles([m(()=>this.baseOpacity,()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?1:2)},f),m(()=>this.hasCompositeBlendMode,()=>this._updateTileTextures(this._evaluateTransparency()?1:2),f),m(()=>this.backgroundColor,(e,t)=>{e?.equals(t)||(this._handleLayerViewChanges(),this._renderer.updateTileBackground(e))},y),m(()=>this.snapLevel,()=>this._viewChanged=!0,y),m(()=>this.view.pointsOfInterest,e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add(()=>e.focus?.renderLocation,()=>this._allTilesSorted=!1,{equals:C})}),m(()=>X.TERRAIN_TILE_TREE_SHOW_TILES,t=>{t&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then(({TerrainTileTree3DDebugger:t})=>{!this._treeDebugger&&X.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new t({view:e}))}):t||(this._treeDebugger=h(this._treeDebugger))},T)]);const{spatialReference:a}=e;this._extentHelper=se(this.viewingMode,{layers:e.map.allLayers,layerViews:e.allLayerViews,viewSpatialReference:a});const n=new s({getCollections:()=>e.defaultsFromMap?.mapCollections?.map(({layers:e})=>e),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),l=new We({layers:n,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:a});this._set("tilingSchemeLogic",l),this._updateTilingScheme(),this._elevationDataRequester=t.createStreamDataRequester(0),this._mapDataRequester=t.createStreamDataRequester(1);const o=t.scheduler;this._frameTask=o.registerTask(Xe.TERRAIN_SURFACE,this),this.addHandles([m(()=>this._extentHelper.stencilEnabledExtents,e=>this._renderer.setStencilEnabledLayerExtents(e),T),m(()=>this.tilingSchemeLogic.tilingScheme,()=>this._updateTilingScheme(),y),m(()=>this.extent,()=>this._updateRootTiles(),T),e.on("resize",()=>this._viewChangeUpdate()),m(()=>{const t=e.state;return[this._lodBias,this.lodSnappingEnabled,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]},()=>this._viewChangeUpdate(),f),m(()=>e.qualitySettings?.fadeDuration,e=>this._renderer.textureFadingEnabled=e>0,T),m(()=>e.qualitySettings?.physicallyBasedRenderingEnabled,e=>this._renderer.pbrMode=e?5:0,T),m(()=>e.qualitySettings?.tiledSurface.elevationLevelDelta,()=>this._updateAllTileGeometries()),m(()=>this._userClippingExtent,()=>this._updateClippingExtent(),y)]),this.addHandles(e.allLayerViews.on("after-changes",()=>this._layerViewsDirty=!0)),this._layerViewsDirty=!0,this._handleLayerViewChanges(),this._renderer.updateTileBackground(this.backgroundColor)}clearHandles(){this._watchUpdatingTracking?.removeAll(),this.removeAllHandles(),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear()}destroy(){this._frameTask.remove(),this._frameTask=Ye,this._watchUpdatingTracking?.destroy(),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach((e,t)=>this._unregisterTiledLayerView(t)),this._basemapLayerViewHandles.clear(),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tileCache=h(this._tileCache),this._allTiles.prune(),Ie.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer.destroyed||this._renderer.destroy(),this._renderer=null,this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),Ae(),this._layerViews.forEach(e=>e.length=0),this._performanceInfo=null}get renderer(){return this._renderer}get frustum(){return this.view.state.camera.frustum}get snapLevel(){if(this.lodSnappingEnabled){const{view:e,tilingScheme:t}=this,i=e.scale;if(t&&i){const r=t.levelAtScale(i)+e.qualitySettings.tiledSurface.lodBias,s=t.getMaxLod();return r<=0?null:Math.min(r,s||1/0)}}return null}get lodSnappingEnabled(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get hasStencilEnabledExtents(){return this._extentHelper.stencilEnabledExtents.length>0}get _userClippingExtent(){const{spatialReference:e}=this,t=this.view?.clippingArea;if(null==t||null==e)return null;const i=B(),r=J(t,i,e)?i:null,s=this._get("extent");return I(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=k(this.groundExtent,this._userClippingExtent,B()),t=this._get("extent");return I(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),this.enabled&&!!((this.readyToRun||this._watchUpdatingTracking?.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager?.updating||this.terrainTextureCompressionTracker.compressing)}get readyToRun(){return this.enabled&&(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||this._scaleRangeQueries?.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return!this.enabled||null!=this._rootTiles}get rootTiles(){return this._rootTiles}get spatialReference(){return this.tilingScheme?.spatialReference??null}get backgroundColor(){return this.view?.map?.ground?.surfaceColor}set backgroundColor(e){this.view.map.ground.surfaceColor=e}set slicePlaneEnabled(e){this._renderer.slicePlaneEnabled=e,this._set("slicePlaneEnabled",e),this._evaluateTransparency()}get tilingSchemeLocked(){return this.tilingSchemeLogic?.tilingSchemeLocked??!1}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return 0===this._renderer.transparency}get invisible(){return 3===this._renderer.transparency}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get fadeDuration(){return this.view.qualitySettings.fadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevationLevelDelta(e){return e<4?3:this.view.qualitySettings.tiledSurface.elevationLevelDelta}getElevation(e,t,i,r){const s=this._rootTiles;if(!s?.length||!this.enabled)return null;if(0===s[0].layerInfo[0].length)return null;let a=this._elevationProjectorCache.get(r);if(void 0===a&&(a=M(r,this._spatialReference)??null,this._elevationProjectorCache.set(r,a)),null==a)return l.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;const n=b(rt,e,t,i);a(n,0,n,0);return ht(s,n[0],n[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[0].length:0;if(r?.length&&0!==s&&this.enabled)for(let a=0;a<t;++a){const t=3*a;i(a,ht(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getLayerIndexByUID(e,t){return this._layerIndexByUid[e].get(t)}getScale(e){if(!this.tilingScheme)return null;if(!R(e,rt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(rt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;rt[0]>t[2]&&(i+=1),rt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}_ensureProjector(e){const t=this._projectorCache.get(e);if(t)return t;const i=M(e,this._tilingSchemeSpatialReference)??null;return this._projectorCache.set(e,i),i}getSphereElevationBounds(e,t){if(!this.enabled||null==this._rootTiles)return null;const i=this._ensureProjector(t);if(null==i)return l.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;F(e,st);const r=H(st,E());i(r,0,r,0),$(st,r);const s=new K,a=this._rootTiles;if(null!=a){const e=[];for(const i of a)e.push(i);let t=0;for(;t<e.length;){const i=e[t];if(++t,!A(i.extent,st))continue;const r=i.children;if(null==r[0]||i.rendered)s.expandElevationRangeValues(i.elevationBoundsMin,i.elevationBoundsMax);else for(const t of r)e.push(t)}}return s}getRootElevationBounds(){return this.enabled&&null!=this._rootTiles?new K(this.rootTileElevationBounds.min,this.rootTileElevationBounds.max):null}getLowerBoundRadius(){const e=(this._ellipsoid.radius+this.visibleElevationBounds.min)*U;return Math.min(e,this._ellipsoid.radius)}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!R(e,mt,this.spatialReference))return l.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;Q(st,mt,t);let i=null;const r=e=>{if(e&&A(e.extent,st)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){if(!this._scaleRangeQueries)return;const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._isFullyTransparent?t?3:2:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?0:1;return this._renderer.transparency=r,i!==r}_updateTilingScheme(){const{tilingScheme:e}=this.tilingSchemeLogic;if(!(e!==this.tilingScheme))return;ye(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??D.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateCarree=this._isWebMercator&&N(this.view?.renderSpatialReference),this._isGeographic=t?.isGeographic??!1,this._set("tilingScheme",e),this._tilingSchemeSpatialReference=this.tilingScheme?.spatialReference,this._projectorCache.clear(),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.tileSize=e.pixelSize,this.overlayManager.spatialReference=e.spatialReference,this._updateRootTiles())}static{this._tileMemcacheKey="TerrainTileMemcache"}_acquireTile(e,t,i,r){const s=this._tileCache.pop(et._tileMemcacheKey);return s?(s.init(e,t,i,r,this),s):new this._tileConstructor(e,t,i,r,this)}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=at;let s=t.rootTilesInExtent(e,i,5*ue);if(null!=this._rootTiles){if(s.length>ue)return void l.getLogger(this).warn(pe);const e=this._rootTiles.map(e=>e.lij),t=r(e,s,ke);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter(e=>!(t.removed.findIndex(t=>ke(t,e.lij))>-1)||(this._purgeTile(e),!1));t.added.forEach(t=>e.push(this._newRootTile(t))),this._setRootTiles(e)}}else this._updatingRootTiles=!0,s.length>ue&&(l.getLogger(this).warn(ce),s=t.rootTilesInExtent(e,i,ue)),this._setRootTiles(s.map(e=>this._newRootTile(e)));I(i,this._rootTilesExtent)||(this._rootTilesExtent=B(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter(e=>e.loaded&&e.intersectsClippingArea);e.sort(Ge),e.forEach(e=>this._renderer.updateTileGeometryState(e)),e.forEach(e=>e.renderData.updateNeighborData()),this._updateTilesGeometries(e),this._pendingTilesToUpdate.clear()}_updateTilesGeometries(e){if(0===e.length)return;e.sort(Ge);const t=this.renderer;e.forEach(e=>t.updateGeometryIfNeeded(e)),e.forEach(e=>this._pendingTilesForElevationUpdateEvent.add(e))}_shouldSplit(e){return 1===e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(1),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==e)return;const t=Ne(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this.view.state.contentCamera.viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(8)&&this._updateTileGeometryState(e),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBoundsMin,r),s=Math.max(e.elevationBoundsMax,s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._updatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new ee(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=i&&i.forEach(({elevationBoundsMin:i,elevationBoundsMax:r})=>{e=Math.min(e,i),t=Math.max(t,r)});const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new ee(e,t))}_updateViewDependentParameters(){const{camera:e,contentCamera:t}=this.view.state,i=Math.tan(.5*t.fovX),r=Math.tan(.5*t.fovY),s=this.tilingScheme.pixelSize,a=2**-this._lodBias*e.pixelRatio;this._splitLimits.aboveGround=e.aboveGround,this._splitLimits.fovX=i,this._splitLimits.fovY=r,this._splitLimits.relativeWidthLimit=s/e.width*this.maxTextureScale*a,this._splitLimits.relativeHeightLimit=s/e.height*this.maxTextureScale*a,this._splitLimits.maxLod=this.tilingScheme.getMaxLod(),this._splitLimits.angledSplitBias=this.view.qualitySettings.tiledSurface.angledSplitBias,this.view.state.fixedContentCamera?this._splitLimits.frustum=O(this._splitLimits.frustum??G(),t.frustum):this._splitLimits.frustum=null,x(this._eyePosRenderSR,t.eye),j(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this.setMemoryDirty()}_markAllTileNeighborsForUpdate(e){e.forEachLoadedNeighbor(e=>{this._layerViews[1].some(Te)&&e.setPendingUpdate(32),this._pendingTilesToUpdate.add(e)})}_updateTileTexture(e,t){const i=e.resetPendingUpdate(32)?32:!!e.resetPendingUpdate(16)&&16;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){if(!this._shouldEmitChangeEvent)return;const e=lt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach(t=>q(e,t.extent,e)),this._pendingTilesForElevationUpdateEvent.clear(),lt.spatialReference=this.spatialReference,this.emit("elevation-change",lt),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;if(this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._updatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed&&this.requestUpdate(),this.notifyChange("updatingProgressValue"),Ue&&this._checkTileInvariant(),!e.hasProgressed)return Ze}_checkTileInvariant(){const e=new Map;this._allTiles.forAll(t=>e.set(t,new Set)),this._allTiles.forAll(t=>{if(ye(t.rendered===t.leaf,` rendered ${t.rendered} != ${t.leaf} leaf`),!t.leaf){const e=e=>0===e.unmergableChildCount&&0===e.maxLevelDeltaNeighborCount,i=t.children.reduce((t,i)=>t+(e(i)?0:1),0);if(ye(t.unmergableChildCount===i,` Tile[${t.lij.toString()}] unmergeable child count mismatch: actual ${t.unmergableChildCount} vs ${i}`),t.hasPendingUpdate(4)){ye(!t.hasPendingUpdate(1),"Tile can be both split and merge at the same time");for(const e of t.children)ye(e.leaf||e.hasPendingUpdate(4),"Child of tile to merge must also merge")}}for(let i=0;i<4;++i){if(t.rendered){const e=t.renderData?.geometryState.edgePeerNeighbors[i];if(null!=e){{const r=t.level-e.level<=ge;r||(console.log(`tile level delta [${t.lij.toString()}] vs [${e.lij.toString()}] > ${ge} (edge[${i}])`),ye(r,`tile level delta [${t.level}] vs [${e.level}] > ${ge}`))}ye(t.level-e.level<=ge,`Max tile lod delta exceeded: [${t.lij.toString()}] vs [${e.lij.toString()}]`)}}const r=t.level-ge,s=e=>e.leaf||e.level===t.level,a=t.findNeighborTile(ve[i],s);if(null!=a){if(t.leaf&&t.level>=ge){let i=a;for(;t.level-i.level<ge;)i=i.parent;const s=[r,t.lij[1]>>ge,t.lij[2]>>ge];if(!ke(s,i.lij)){const r=e.get(i);ye(!r.has(t),"Cannot already have neighbor"),r.add(t)}}ye(a.rendered||a.level===t.level,"Non-same-level-neighbor of rendered must be rendered"),ye(t.level-a.level<=ge,`Tile level delta [${t.level}] vs [${a.level}] > ${ge}`)}}}),this._allTiles.forAll(t=>{const i=t.maxLevelDeltaNeighborCount,r=e.get(t);ye(i===r.size,`Tile[${t.lij.toString()}] merge-blocker mismatch: actual ${i} vs ${r.size}`)})}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=new dt(this._allTiles.length);t.pushAll(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;this._allTiles.forAll(e=>{e.maxLevelDeltaNeighborCount=0,e.unmergableChildCount=0});const a=this.view.state.contentCamera.viewProjectionMatrix;for(;!t.empty;){const e=t.pop(),n=e.parent,l=n?.hasPendingUpdate(4),o=l?4:e.shouldSplit(r,s,i),h=1===o;e.leaf?ut(e,h):t.pushAll(e.children),l?(e.resetPendingUpdate(1),e.leaf||e.setPendingUpdate(4),this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(a)):h?(e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1)):(e.resetPendingUpdate(1)&&e.updateAgentSuspension(),2===o&&e.updateAgents(0),e.leaf||(e.setPendingUpdate(4),e.resetPendingUpdate(1)))}this.requestUpdate(),(this._shortBatches||!this._oneBatchPerFrameTask)&&this._updatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||!this.view.pointsOfInterest?.focus||(Fe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger?.update(),e.madeProgress())}_markTileToUpdate(e){we(e.loaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForUpdate(e))}_updatePendingTileGeometries(){const e=this._pendingTilesToUpdate,t=Array.from(e.keys()).filter(e=>e.loaded&&e.intersectsClippingArea);if(0===t.length)return void e.clear();const i=(i,r)=>{!r?.loaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(Ge);const r=t.length;for(let s=0;s<r;++s){const r=t[s];we(r.loaded),we(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a.dirtyEdgeResolutions,l=a.geometryState,o=e=>{const t=Be[e];i(r,l.cornerPeerNeighbors[e]?.findCorner(De(t),e=>e.loaded))};for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Se(ve[t]),t=>!(!t.loaded||!t.intersectsClippingArea)&&(we(e.has(t)||Ge(r,t)<0),i(r,t),!0)),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Ue&&Me&&this.checkAllTilesWaterproofness()}_mergeAndSplit(e,t){if(this.suspended||e.done||!this._allTilesDirty)return;this._allTilesDirty=!1,this.requestUpdate();let i=!1;const r=this.view.state.fixedContentCamera;let s=!1;for(;!e.done;){s=!0;let a=!1;const n=!this._allTiles.some(s=>{if(!i&&!r&&!s.visible)return e.done;let n=s;if(s.hasPendingUpdate(4)){if(!t||s.unmergableChildCount>0)return e.done;for(s.resetPendingUpdate(4);null!=n.parent&&0===n.parent.unmergableChildCount&&n.parent.resetPendingUpdate(4);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else if(s.resetPendingUpdate(1)){let t=!0;const i=s.level;if(i>=ge){const e=e=>e.leaf||i-e.level<ge;for(let r=0;r<4;++r){const a=s.findNeighborTile(ve[r],e);null!=a&&i-a.level===ge&&(t=!1,Ue&&(we(a.leaf),we(a.hasPendingUpdate(1))))}}t?(this._splitTile(s),e.madeProgress(),a=!0):s.setPendingUpdate(1)}return e.done});if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries()),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some(t=>(t.resetPendingUpdate(8)&&(this._updateTileGeometryState(t),this._shortBatches&&this._updatePendingTileGeometries(),e.madeProgress()),e.done)),!this._oneBatchPerFrameTask&&this._updatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some(t=>(this._updateTileTexture(t,e),e.done))}_updateClippingExtent(){this.spatialReference&&(this.overlayManager?.updateOverlayParameters(1),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*_e}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=o(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach(e=>this._purgeTile(e)),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),this.renderer.visible=!1}_purgeSubtree(e){const t=e.children;t[0]&&(this._purgeTile(t[0]),this._purgeTile(t[1]),this._purgeTile(t[2]),this._purgeTile(t[3]),e.clearChildren())}_purgeTile(e){e.leaf?ct(e):this._purgeSubtree(e),this._allTiles.removeUnordered(e),this._unloadTile(e),e.dispose(),this._tileCache.put(et._tileMemcacheKey,e),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles})}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload()}_splitTile(e){ye(e.leaf,"Tile that is already split should not be split again!"),ye(e.rendered,"Tile marked to split is not rendered"),ct(e);const t=e.createChildren();this._allTiles.pushArray(t),this.notifyChange("demResolution"),this.emit("tiles-changed",{allTiles:this.allTiles}),e.updateAgentSuspension(),ye(e.rendered,"parent should be rendered"),t.forEach(e=>this._loadTile(e)),t.forEach(e=>this._pendingTilesToUpdate.add(e)),this._unloadTile(e),this._markAllTileNeighborsForUpdate(e),this._emitTileScaleChange(e,e.level+1),this._allTilesDirty=!0,this._shortBatches&&this._updatePendingTileGeometries(),t.forEach(e=>ut(e,e.hasPendingUpdate(1))),++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){ot.spatialReference=this.spatialReference,ot.extent=e.extent,ot.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",ot)}createTile(e,t,i,r){ye(!!r,"createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this.view.state.contentCamera.viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(1),s}get _shortBatches(){return 2!==this.view.state.mode}_mergeTile(e){ye(!e.hasPendingUpdate(1),"_mergeTile sanity check"),ye(!e.leaf,"Cannot merge a leaf"),e.leaf||(this._purgeSubtree(e),ye(!e.renderData,"Merging tile with existing render data?"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this._shortBatches&&this._updatePendingTileGeometries(),ut(e,!1),this._allTilesDirty=!0,++this._performanceInfo.numMerged)}_loadTile(e){e.load(),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager?.hasOverlays&&this.overlayManager.updateTileOverlayParameters(e)}_handleLayerViewChanges(e=Ke){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(let s=this.view.allLayerViews.length-1;s>=0;s--){const e=this.view.allLayerViews.items[s];if(i.add(e.uid),Ce(e)||be(e))if(this._basemapLayerViewHandles.has(e.uid)&&!be(e)){const i=this._layerClassFromLayerView(e),s=this.getLayerIndexByUID(i,e.uid);null!=s&&((s<r||null==r)&&(t=!0),r=s)}else this._registerTiledLayerView(e),e.layer.loaded&&(t=!0)}this._basemapLayerViewHandles.forEach((e,r)=>{i.has(r)||(this._unregisterTiledLayerView(r),t=!0)}),t&&this._updateTiledLayers(),this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._evaluateTransparency(),e.madeProgress()}get _isFullyTransparent(){if(this.view.map?.ground?.opacity>0)return!1;for(const e of this.view.allLayerViews.items)if(xe(e)&&!Y(e.layer)&&0!==e.fullOpacity)return!1;return!0}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ee(e)||be(e))&&$e(Qe[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Le(e)?0:1}_registerTiledLayerView(e){const t=[];if((Ee(e)||be(e))&&t.push(m(()=>e.layer.blendMode,()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(2)})),!be(e)){const i=this._layerClassFromLayerView(e);t.push(m(()=>!e.destroyed&&e.suspended,()=>this._updateTiledLayers())),t.push(m(()=>!e.destroyed&&e.fullOpacity,()=>this._updateTileTextures(2)));const{layer:r}=e;"effectiveScaleRange"in r&&t.push(m(()=>!e.destroyed&&r.effectiveScaleRange,()=>this._restartAllAgents(i))),t.push(e.on("data-changed",()=>{const t=this.getLayerIndexByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)}))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach(e=>{if(!e.layer||e.suspended||!Ce(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(1===r){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)});for(const r of ae){const e=this._layerViews[r],i=t[r];i.reverse();const s=i.length;let a=e.length!==s;const n=new Array(s),l=new Array(e.length);this._layerIndexByUid[r].clear();for(let t=0;t<s;t++){const s=i[t].uid;this._layerIndexByUid[r].set(s,t);const o=e.indexOf(i[t]);n[t]=o,t!==o&&(a=!0),o>-1&&(l[o]=t)}if(a){const e=this._postorderIterator;for(e.reset(this._rootTiles);!e.done;)e.next().modifyLayers(l,n,r);this._layerViews[r]=i,this._restartAllAgents(r),this._updateTilesVisibility(this._rootTiles)}}this.tilingScheme.ensureMaxLod(i)&&(this._viewChangeUpdate(),this.notifyChange("tilingScheme"))}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),0===e&&i.computeElevationBounds()}this._updateRootTileElevationBounds()}layerViewByIndex(e,t){return this._layerViews[t][e]}numLayers(e){return this._layerViews[e].length}_updateTileTextures(e){this._allTiles.forAll(t=>{t.updateAgents(1),1===e?this.renderer.updateTileTexture(t,16):t.updateRenderData(1,e)}),this._evaluateTransparency()}_invalidateLayerData(e,t){this._allTiles.forAll(i=>i.removeLayerAgent(e,t)),this._allTiles.forAll(i=>i.invalidateLayerData(e,t))}setTileTreeDirty(){this._allTilesDirty=!0}requestRender(e=1){this.renderer.setNeedsRender(e)}requestUpdate(){1===++this._pendingUpdates&&(this._hasPendingUpdates=!0)}requestTileData(e,t,i,r){const s=this.layerViewByIndex(t,i),a=s.layer;return!a.tilemapCache||Te(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.level,e.lij[1],e.lij[2],{...r,timeout:6e3}).then(()=>--this._asyncWorkItems).catch(t=>{throw--this._asyncWorkItems,c(r),g(t)||this._dataMissing(e,i,s),t}).then(()=>this._frameTask.schedule(()=>this._requestTileData(e,i,s,r),r.signal)))}_requestTileData(e,t,i,r){if(this.destroying)return Promise.resolve();const s=0===t;return r.requester??=s?this._elevationDataRequester:this._mapDataRequester,s?Le(i)?this._requestElevationTileData(e,i,r):Promise.reject():xe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{!_(i)&&r&&(this.setMemoryDirty(),this.requestUpdate(),this._elevationDataArrived(e,t,r))},s=i=>{g(i)||(l.getLogger(this).error(`Tile ${e.lij.toString()} layer 0/${t.uid} error ${i}`),this._dataMissing(e,0,t),this.requestUpdate())};return t.fetchElevationTile(e,i).then(e=>this._frameTask.schedule(()=>r(e)),s).finally(()=>--this._asyncWorkItems)}_elevationDataArrived(e,t,i){const r=this._layerIndexByUid[0].get(t.uid);if(null==r)return void l.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",0,e.lij.toString());const s=new te(e.lij,e.extent,i);e.dataArrived(r,0,s),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:0});const a=[e],n=e.level,o=this._iteratorPool.acquire();for(o.reset(a);!o.done;){const e=o.next();e.findElevationBoundsForLayer(r,n),e.computeElevationBounds()}0===n&&this._updateRootTileElevationBounds(),o.remove(),this._updateTilesVisibility(a)}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{Pe(s),_(i)||(console.error(`Tile ${e.lij.toString()} layer 1/${t.uid} error ${r}`),this._dataMissing(e,1,t),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule(()=>{this.requestUpdate(),_(i)?Pe(r):this._mapTileDataArrived(e,t,r)},i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule(()=>r(e,t));return t.fetchTile(e.lij,i).then(a,n).finally(()=>--this._asyncWorkItems)}_mapTileDataArrived(e,t,i){const r=this.getLayerIndexByUID(1,t.uid);if(null==r)return Pe(i),void l.getLogger(this).warn("TerrainSurface: received data from unknown layer");e.dataArrived(r,1,i),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:1})}_dataMissing(e,t,i){const r=this.getLayerIndexByUID(t,i.uid);null!=r?(e.dataMissing(r,t),this.emit("tile-data-changed",{tile:e,layerIndex:r,layerClass:t})):l.getLogger(this).warn("TerrainSurface: received data from unknown layer")}get performanceInfo(){const e=this._performanceInfo;return e.numNodes=this._allTiles.length,e.numLeaves=e.numVisible=e.numRendered=e.numLoadedPerLevel.length=e.numRenderedPerLevel.length=0,this._allTiles.forAll(t=>{t.leaf&&e.numLeaves++;const i=t.level;t.renderData&&(e.numLoadedPerLevel[i]=(e.numLoadedPerLevel[i]||0)+1),t.visible&&(e.numVisible++,t.rendered&&(e.numRenderedPerLevel[i]=(e.numRenderedPerLevel[i]||0)+1,e.numRendered++))}),e}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce((e,t)=>e+t.usedMemory,0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this.getLayerIndexByUID(i,e.uid);return null!=r&&this._allTiles.forAll(e=>t+=e.getUsedMemoryForLayer(i,r)),t}get renderPatchBorders(){return this._renderer.renderPatchBorders}set renderPatchBorders(e){this._renderer.renderPatchBorders=e}get visualizeNormals(){return this._renderer.visualizeNormals}set visualizeNormals(e){this._renderer.visualizeNormals=e}get renderingDisabled(){return this._renderer.renderingDisabled}set renderingDisabled(e){this._renderer.renderingDisabled=e}get test(){}checkAllTilesWaterproofness(){if(!Me)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.leaf)console.error("Tile[",e.lij,"] has no geometry and no children, from root to leaf");else for(const t of e.children)r(t)},s=e=>{const t=e.parent?.visible??!0,i=e.visible;e.computeVisibility();const r=e.visible;if(i!==r&&t&&console.error(" Tile[",e.lij,"] has out of date visibility: ",i," instead of ",r),!e.leaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get isGeographic(){return this._isGeographic}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateCarree(){return this._isWebMercatorOnPlateCarree}isEastEndWrap(e){return this._isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this._isGlobal&&0===e[2]}lijEastEnd(e){return 1<<e+(this._isGeographic?1:0)}wrapEastWest(e){const t=this.lijEastEnd(e[0]),i=e[2];if(0<=i&&i<t)return e;if(!this._isGlobal)return null;const r=(i+(i<0?t:0))%t;return[e[0],e[1],r]}enableInternalChecks(e){Re(e)}enableWaterproofnessChecks(e){je(e)}static cleanupTerrainSurface(){nt.prune()}enable(e){e!==this.enabled&&(e?(this._updateRootTiles(),this.suspended=!1):(this.suspended=!0,this._removeAllTiles(),this._setRootTiles(null)),this._set("enabled",e),this.notifyChange("ready"))}};e([w()],tt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],tt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],tt.prototype,"view",void 0),e([w({constructOnly:!0})],tt.prototype,"overlayManager",void 0),e([w({constructOnly:!0})],tt.prototype,"terrainTextureCompressionTracker",void 0),e([w()],tt.prototype,"_hasPendingUpdates",void 0),e([w()],tt.prototype,"_asyncWorkItems",void 0),e([w()],tt.prototype,"_allTilesDirty",void 0),e([w()],tt.prototype,"_allTilesSorted",void 0),e([w()],tt.prototype,"_viewChanged",void 0),e([w({type:Number})],tt.prototype,"heading",void 0),e([w()],tt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],tt.prototype,"_watchUpdatingTracking",void 0),e([w()],tt.prototype,"_frameTask",void 0),e([w()],tt.prototype,"demResolution",null),e([w({readOnly:!0})],tt.prototype,"snapLevel",null),e([w({readOnly:!0})],tt.prototype,"lodSnappingEnabled",null),e([w()],tt.prototype,"_userClippingExtent",null),e([w()],tt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],tt.prototype,"extent",null),e([w({readOnly:!0})],tt.prototype,"groundExtent",null),e([w({readOnly:!0})],tt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],tt.prototype,"updating",null),e([w({readOnly:!0})],tt.prototype,"readyToRun",null),e([w(Z)],tt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],tt.prototype,"updatingProgressValue",null),e([w()],tt.prototype,"_maxNumUpdating",void 0),e([w()],tt.prototype,"baseOpacity",null),e([w()],tt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],tt.prototype,"viewingMode",null),e([w()],tt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],tt.prototype,"ready",null),e([w({readOnly:!0})],tt.prototype,"rootTiles",null),e([w()],tt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],tt.prototype,"spatialReference",null),e([w({type:t})],tt.prototype,"backgroundColor",null),e([w({value:!1})],tt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],tt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],tt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],tt.prototype,"tilingSchemeLogic",void 0),e([w()],tt.prototype,"wireframe",null),e([w({value:!1})],tt.prototype,"suspended",null),e([w()],tt.prototype,"fadeDuration",null),e([w()],tt.prototype,"visibleElevationBounds",void 0),e([w()],tt.prototype,"rootTileElevationBounds",void 0),e([w()],tt.prototype,"_layerViewsDirty",void 0),e([w()],tt.prototype,"renderPatchBorders",null),e([w()],tt.prototype,"visualizeNormals",null),e([w()],tt.prototype,"renderingDisabled",null),e([w({readOnly:!0})],tt.prototype,"enabled",void 0),tt=et=e([S("esri.views.3d.terrain.TerrainSurface")],tt);const it=tt,rt=E(),st=W(),at=B(),nt=new p,lt=new re("ground"),ot={spatialReference:null,extent:null,scale:0};function ht(e,t,i){for(const r of e){if(!r.containsPointXY(t,i))continue;let e=r;for(;e&&!e.renderData;){const r=(t>e.extentMidX?1:0)+(i<e.extentMidY?2:0);e=e.children[r]}const s=e?.renderData?.geometryState.samplerData??null;return ie(t,i,s)}return null}class dt{constructor(e){this.capacity=e,this._head=0,this._tail=0,this._data=new Array(e)}push(e){const t=this._tail;if(!(t<this.capacity))throw new Error("Queue full");this._data[t]=e,this._tail=t+1}pushAll(e){const t=e.length;if(0===t)return;const i=this._tail;if(!(i+t<=this.capacity))throw new Error("Queue full");for(let r=0;r<t;++r)this._data[i+r]=e[r];this._tail=i+t}pop(){const e=this._head;if(e<this._tail){const t=this._data[e];return this._head=e+1,t}}get empty(){return this._head>=this._tail}get full(){return this._tail>=this._data.length}}function ut(e,t){!e.leaf||e.level<ge||_t(e,e=>{t&&pt(e);const i=gt(e);if(e.maxLevelDeltaNeighborCount++,i){let t=e.parent;for(;t;){const e=gt(t);if(t.unmergableChildCount++,!e)break;t=t.parent}}})}function pt(e){if(e.hasPendingUpdate(1))return;let t=e.parent;for(;t?.resetPendingUpdate(4);)t=t.parent;e.resetPendingUpdate(4),e.leaf&&e.setPendingUpdate(1),e.level<ge||_t(e,e=>{pt(e)})}function ct(e){e.level<ge||_t(e,e=>{if(e.maxLevelDeltaNeighborCount--,0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount){let t=e.parent;for(;t&&(t.unmergableChildCount--,gt(t));)t=t.parent}})}function gt(e){return 0===e.maxLevelDeltaNeighborCount&&0===e.unmergableChildCount}function _t(e,t){if(e.level<ge)return;const i=e.level-ge,r=e.lij[1]>>ge,s=e.lij[2]>>ge,a=e=>e.leaf||e.level===i;for(let n=0;n<4;++n){const l=e.findNeighborTile(ve[n],a);if(!l||l.level!==i)continue;const o=l.lij;o[1]===r&&o[2]===s||t(l)}}const mt=E();export{it as default};
@@ -2,7 +2,7 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{i as e}from"../../../../../../chunks/vec32.js";import{create as a}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float3PassUniform as r}from"../../shaderModules/Float3PassUniform.js";import{glsl as c}from"../../shaderModules/glsl.js";function s(e){e.vertex.code.add(c`float screenSizePerspectiveViewAngleDependentFactor(float absCosAngle) {
5
+ import{i as e}from"../../../../../../chunks/vec32.js";import{create as r}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{Float3PassUniform as a}from"../../shaderModules/Float3PassUniform.js";import{glsl as c}from"../../shaderModules/glsl.js";function s(e){e.vertex.code.add(c`float screenSizePerspectiveViewAngleDependentFactor(float absCosAngle) {
6
6
  return absCosAngle * absCosAngle * absCosAngle;
7
7
  }`),e.vertex.code.add(c`vec3 screenSizePerspectiveScaleFactor(float absCosAngle, float distanceToCamera, vec3 params) {
8
8
  return vec3(
@@ -11,14 +11,14 @@ screenSizePerspectiveViewAngleDependentFactor(absCosAngle),
11
11
  params.z
12
12
  );
13
13
  }`),e.vertex.code.add(c`float applyScreenSizePerspectiveScaleFactorFloat(float size, vec3 factor) {
14
- return mix(size * clamp(factor.x, factor.z, 1.0), size, factor.y);
14
+ return size * clamp(mix(factor.x, 1.0, factor.y), factor.z, 1.0);
15
15
  }`),e.vertex.code.add(c`float screenSizePerspectiveScaleFloat(float size, float absCosAngle, float distanceToCamera, vec3 params) {
16
16
  return applyScreenSizePerspectiveScaleFactorFloat(
17
17
  size,
18
18
  screenSizePerspectiveScaleFactor(absCosAngle, distanceToCamera, params)
19
19
  );
20
20
  }`),e.vertex.code.add(c`vec2 applyScreenSizePerspectiveScaleFactorVec2(vec2 size, vec3 factor) {
21
- return mix(size * clamp(factor.x, factor.z, 1.0), size, factor.y);
21
+ return size * clamp(mix(factor.x, 1.0, factor.y), factor.z, 1.0);
22
22
  }`),e.vertex.code.add(c`vec2 screenSizePerspectiveScaleVec2(vec2 size, float absCosAngle, float distanceToCamera, vec3 params) {
23
23
  return applyScreenSizePerspectiveScaleFactorVec2(size, screenSizePerspectiveScaleFactor(absCosAngle, distanceToCamera, params));
24
- }`)}function t(e){e.uniforms.add(new r("screenSizePerspective",e=>i(e.screenSizePerspective)))}function o(e){e.uniforms.add(new r("screenSizePerspectiveAlignment",e=>i(e.screenSizePerspectiveAlignment||e.screenSizePerspective)))}function i(a){return e(n,a.parameters.divisor,a.parameters.offset,a.minScaleFactor)}const n=a();export{s as ScreenSizePerspective,t as addScreenSizePerspective,o as addScreenSizePerspectiveAlignment};
24
+ }`)}function t(e){e.uniforms.add(new a("screenSizePerspective",e=>n(e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize)))}function i(e){e.uniforms.add(new a("screenSizePerspectiveAlignment",e=>n(e.screenSizePerspectiveAlignment||e.screenSizePerspective,e.screenSizePerspectiveAlignment?null:e.screenSizePerspectiveMinPixelReferenceSize)))}function n(r,a){const c=null!=a&&null!=r?Math.min(r.minPixelSize/a,1):0;return r?e(o,r.divisor,r.offset,c):e(o,0,0,0)}const o=r();export{s as ScreenSizePerspective,t as addScreenSizePerspective,i as addScreenSizePerspectiveAlignment};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderModules/FloatsPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/IntegerPassUniform.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";export{G as GlowCompositionPassParameters,b as build,d as defaultCompositionParameters}from"../../../../../chunks/GlowComposition.glsl.js";
5
+ import"../../core/shaderLibrary/ScreenSpacePass.glsl.js";import"../../core/shaderLibrary/shading/Gamma.glsl.js";import"../../core/shaderModules/FloatsPassUniform.js";import"../../core/shaderModules/glsl.js";import"../../core/shaderModules/IntegerPassUniform.js";import"../../core/shaderModules/Texture2DPassUniform.js";import"../../shaders/ToneMapping.glsl.js";import"../../../../webgl/NoParameters.js";import"../../../../webgl/ShaderBuilder.js";export{G as GlowCompositionPassParameters,b as build}from"../../../../../chunks/GlowComposition.glsl.js";
@@ -0,0 +1,10 @@
1
+ /*
2
+ All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
+ See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
+ */
5
+ import{Float3BindUniform as e}from"../../core/shaderModules/Float3BindUniform.js";import{FloatPassUniform as r}from"../../core/shaderModules/FloatPassUniform.js";import{glsl as o}from"../../core/shaderModules/glsl.js";import{SphereIntersect as s}from"../../shaders/SphereIntersect.glsl.js";import{NoParameters as t}from"../../../../webgl/NoParameters.js";class a extends t{constructor(){super(...arguments),this.atmosphereC=1}}function i(t){t.include(s),t.uniforms.add(new r("atmosphereC",e=>e.atmosphereC),new e("cameraPosition",e=>e.camera.eye)),t.code.add(o`float getDistanceFalloff(float dist, vec3 rayDir, float weight) {
6
+ if(dist == -1.0){
7
+ dist = 0.055 * sphereIntersect(cameraPosition, rayDir, atmosphereC).y;
8
+ }
9
+ return (1.0 - exp(-dist * weight));
10
+ }`)}export{i as RayDistanceFalloff,a as RayDistanceFalloffPassParameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{i as t,d as n,n as o,c as e,g as s,f as r,h as l,t as h,e as u}from"../../../../chunks/vec32.js";import{fromValues as a,clone as c,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{create as p,clone as f,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newDoubleArray as g}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as m,floatArrayFrom as M}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as A,getZeroIndexArray as y}from"../../../../geometry/support/Indices.js";import{create as b,fromPositionAndNormal as j,intersectRay as d}from"../../../../geometry/support/plane.js";import{wrap as v}from"../../../../geometry/support/ray.js";import{timeStampsToAttribute as I}from"../../support/engineContent/line.js";import{Attribute as P}from"./Attribute.js";import{scale as x,length as z,normalize as D,add as S}from"./bufferVectorMath.js";import{Geometry as q}from"./Geometry.js";import{assert as C}from"./Util.js";const F=[[-.5,-.5,.5],[.5,-.5,.5],[.5,.5,.5],[-.5,.5,.5],[-.5,-.5,-.5],[.5,-.5,-.5],[.5,.5,-.5],[-.5,.5,-.5]],O=[0,0,1,-1,0,0,1,0,0,0,-1,0,0,1,0,0,0,-1],V=[0,0,1,0,1,1,0,1],k=[0,1,2,2,3,0,4,0,3,3,7,4,1,5,6,6,2,1,1,0,4,4,5,1,3,2,6,6,7,3,5,4,7,7,6,5],G=new Array(36);for(let vt=0;vt<6;vt++)for(let t=0;t<6;t++)G[6*vt+t]=vt;const U=new Array(36);for(let vt=0;vt<6;vt++)U[6*vt]=0,U[6*vt+1]=1,U[6*vt+2]=2,U[6*vt+3]=2,U[6*vt+4]=3,U[6*vt+5]=0;function B(t,n){Array.isArray(n)||(n=[n,n,n]);const o=new Array(24);for(let e=0;e<8;e++)o[3*e]=F[e][0]*n[0],o[3*e+1]=F[e][1]*n[1],o[3*e+2]=F[e][2]*n[2];return new q(t,[["position",new P(o,k,3,!0)],["normal",new P(O,G,3)],["uv0",new P(V,U,2)]])}const E=[[-.5,0,-.5],[.5,0,-.5],[.5,0,.5],[-.5,0,.5],[0,-.5,0],[0,.5,0]],H=[0,1,-1,1,1,0,0,1,1,-1,1,0,0,-1,-1,1,-1,0,0,-1,1,-1,-1,0],J=[5,1,0,5,2,1,5,3,2,5,0,3,4,0,1,4,1,2,4,2,3,4,3,0],K=[0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7];function L(t,n){Array.isArray(n)||(n=[n,n,n]);const o=new Array(18);for(let e=0;e<6;e++)o[3*e]=E[e][0]*n[0],o[3*e+1]=E[e][1]*n[1],o[3*e+2]=E[e][2]*n[2];return new q(t,[["position",new P(o,J,3,!0)],["normal",new P(H,K,3)]])}const N=a(-.5,0,-.5),Q=a(.5,0,-.5),R=a(0,0,.5),T=a(0,.5,0),W=i(),X=i(),Y=i(),Z=i(),$=i();n(W,N,T),n(X,N,Q),l(Y,W,X),o(Y,Y),n(W,Q,T),n(X,Q,R),l(Z,W,X),o(Z,Z),n(W,R,T),n(X,R,N),l($,W,X),o($,$);const _=[N,Q,R,T],tt=[0,-1,0,Y[0],Y[1],Y[2],Z[0],Z[1],Z[2],$[0],$[1],$[2]],nt=[0,1,2,3,1,0,3,2,1,3,0,2],ot=[0,0,0,1,1,1,2,2,2,3,3,3];function et(t,n){Array.isArray(n)||(n=[n,n,n]);const o=new Array(12);for(let e=0;e<4;e++)o[3*e]=_[e][0]*n[0],o[3*e+1]=_[e][1]*n[1],o[3*e+2]=_[e][2]*n[2];return new q(t,[["position",new P(o,nt,3,!0)],["normal",new P(tt,ot,3)]])}function st(t,n,o,e,s={uv:!0}){const r=-Math.PI,l=2*Math.PI,h=-Math.PI/2,u=Math.PI,a=Math.max(3,Math.floor(o)),c=Math.max(2,Math.floor(e)),i=(a+1)*(c+1),p=m(3*i),f=m(3*i),w=m(2*i),g=[];let M=0;for(let m=0;m<=c;m++){const t=[],o=m/c,e=h+o*u,s=Math.cos(e);for(let h=0;h<=a;h++){const u=h/a,c=r+u*l,i=Math.cos(c)*s,g=Math.sin(e),m=-Math.sin(c)*s;p[3*M]=i*n,p[3*M+1]=g*n,p[3*M+2]=m*n,f[3*M]=i,f[3*M+1]=g,f[3*M+2]=m,w[2*M]=u,w[2*M+1]=o,t.push(M),++M}g.push(t)}const A=new Array;for(let m=0;m<c;m++)for(let t=0;t<a;t++){const n=g[m][t],o=g[m][t+1],e=g[m+1][t+1],s=g[m+1][t];0===m?(A.push(n),A.push(e),A.push(s)):m===c-1?(A.push(n),A.push(o),A.push(e)):(A.push(n),A.push(o),A.push(e),A.push(e),A.push(s),A.push(n))}const b=[["position",new P(p,A,3,!0)],["normal",new P(f,A,3,!0)]];return s.uv&&b.push(["uv0",new P(w,A,2,!0)]),s.offset&&(b[0][0]="offset",b.push(["position",new P(Float64Array.from(s.offset),y(A.length),3,!0)])),new q(t,b)}function rt(t,n,o,e){const s=lt(n,o,e);return new q(t,s)}function lt(t,n,o){const e=t;let s,r;if(o)s=[0,-1,0,1,0,0,0,0,1,-1,0,0,0,0,-1,0,1,0],r=[0,1,2,0,2,3,0,3,4,0,4,1,1,5,2,2,5,3,3,5,4,4,5,1];else{const t=e*(1+Math.sqrt(5))/2;s=[-e,t,0,e,t,0,-e,-t,0,e,-t,0,0,-e,t,0,e,t,0,-e,-t,0,e,-t,t,0,-e,t,0,e,-t,0,-e,-t,0,e],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1]}for(let a=0;a<s.length;a+=3)x(s,a,t/z(s,a));let l={};function h(n,o){n>o&&([n,o]=[o,n]);const e=n.toString()+"."+o.toString();if(l[e])return l[e];let r=s.length;return s.length+=3,S(s,3*n,s,3*o,s,r),x(s,r,t/z(s,r)),r/=3,l[e]=r,r}for(let a=0;a<n;a++){const t=r.length,n=new Array(4*t);for(let o=0;o<t;o+=3){const t=r[o],e=r[o+1],s=r[o+2],l=h(t,e),u=h(e,s),a=h(s,t),c=4*o;n[c]=t,n[c+1]=l,n[c+2]=a,n[c+3]=e,n[c+4]=u,n[c+5]=l,n[c+6]=s,n[c+7]=a,n[c+8]=u,n[c+9]=l,n[c+10]=u,n[c+11]=a}r=n,l={}}const u=M(s);for(let a=0;a<u.length;a+=3)D(u,a);return[["position",new P(M(s),r,3,!0)],["normal",new P(u,r,3,!0)]]}function ht(t,{normal:n,position:o,color:e,rotation:s,size:r,centerOffsetAndDistance:l,uvi:h,featureAttribute:u,olidColor:a=null}={}){const c=o?f(o):p(),i=n?f(n):w(0,0,1),g=e?[e[0],e[1],e[2],e.length>3?e[3]:255]:[255,255,255,255],m=null!=r&&2===r.length?r:[1,1],M=null!=s?[s]:[0],A=y(1),b=[["position",new P(c,A,3,!0)],["normal",new P(i,A,3,!0)],["color",new P(g,A,4,!0)],["size",new P(m,A,2)],["rotation",new P(M,A,1,!0)]];if(h&&b.push(["uvi",new P(h,A,h.length)]),null!=l){const t=[l[0],l[1],l[2],l[3]];b.push(["centerOffsetAndDistance",new P(t,A,4)])}if(u){const t=[u[0],u[1],u[2],u[3]];b.push(["featureAttribute",new P(t,A,4)])}return new q(t,b,null,1,a)}const ut=[[-1,-1,0],[1,-1,0],[1,1,0],[-1,1,0]];function at(t,n=ut){const o=new Array(12);for(let a=0;a<4;a++)for(let t=0;t<3;t++)o[3*a+t]=n[a][t];const e=[0,1,2,2,3,0],s=[0,0,1],r=[0,0,0,0,0,0],l=[0,0,1,0,1,1,0,1],h=[255,255,255,255],u=[["position",new P(o,e,3,!0)],["normal",new P(s,r,3,!0)],["uv0",new P(l,e,2,!0)],["color",new P(h,r,4,!0)]];return new q(t,u)}function ct(t,n,o,e,s=!0,r=!0){let l=0;const h=n,u=t;let c=a(0,l,0),i=a(0,l+u,0),p=a(0,-1,0),f=a(0,1,0);e&&(l=u,i=a(0,0,0),c=a(0,l,0),p=a(0,1,0),f=a(0,-1,0));const w=[i,c],g=[p,f],M=o+2,A=Math.sqrt(u*u+h*h);if(e)for(let m=o-1;m>=0;m--){const t=m*(2*Math.PI/o),n=a(Math.cos(t)*h,l,Math.sin(t)*h);w.push(n);const e=a(u*Math.cos(t)/A,-h/A,u*Math.sin(t)/A);g.push(e)}else for(let m=0;m<o;m++){const t=m*(2*Math.PI/o),n=a(Math.cos(t)*h,l,Math.sin(t)*h);w.push(n);const e=a(u*Math.cos(t)/A,h/A,u*Math.sin(t)/A);g.push(e)}const y=new Array,b=new Array;if(s){for(let t=3;t<w.length;t++)y.push(1),y.push(t-1),y.push(t),b.push(0),b.push(0),b.push(0);y.push(w.length-1),y.push(2),y.push(1),b.push(0),b.push(0),b.push(0)}if(r){for(let t=3;t<w.length;t++)y.push(t),y.push(t-1),y.push(0),b.push(t),b.push(t-1),b.push(1);y.push(0),y.push(2),y.push(w.length-1),b.push(1),b.push(2),b.push(g.length-1)}const j=m(3*M);for(let a=0;a<M;a++)j[3*a]=w[a][0],j[3*a+1]=w[a][1],j[3*a+2]=w[a][2];const d=m(3*M);for(let a=0;a<M;a++)d[3*a]=g[a][0],d[3*a+1]=g[a][1],d[3*a+2]=g[a][2];return[["position",new P(j,y,3,!0)],["normal",new P(d,b,3,!0)]]}function it(t,n,o,e,s,r=!0,l=!0){return new q(t,ct(n,o,e,s,r,l))}function pt(n,e,h,p,f,w,g){const M=f?c(f):a(1,0,0),A=w?c(w):a(0,0,0);g??=!0;const y=i();o(y,M);const b=i();s(b,y,Math.abs(e));const j=i();s(j,b,-.5),r(j,j,A);const d=a(0,1,0);Math.abs(1-u(y,d))<.2&&t(d,0,0,1);const v=i();l(v,y,d),o(v,v),l(d,v,y);const I=2*p+(g?2:0),x=p+(g?2:0),z=m(3*I),D=m(3*x),S=m(2*I),C=new Array(3*p*(g?4:2)),F=new Array(3*p*(g?4:2));g&&(z[3*(I-2)]=j[0],z[3*(I-2)+1]=j[1],z[3*(I-2)+2]=j[2],S[2*(I-2)]=0,S[2*(I-2)+1]=0,z[3*(I-1)]=z[3*(I-2)]+b[0],z[3*(I-1)+1]=z[3*(I-2)+1]+b[1],z[3*(I-1)+2]=z[3*(I-2)+2]+b[2],S[2*(I-1)]=1,S[2*(I-1)+1]=1,D[3*(x-2)]=-y[0],D[3*(x-2)+1]=-y[1],D[3*(x-2)+2]=-y[2],D[3*(x-1)]=y[0],D[3*(x-1)+1]=y[1],D[3*(x-1)+2]=y[2]);const O=(t,n,o)=>{C[t]=n,F[t]=o};let V=0;const k=i(),G=i();for(let t=0;t<p;t++){const n=t*(2*Math.PI/p);s(k,d,Math.sin(n)),s(G,v,Math.cos(n)),r(k,k,G),D[3*t]=k[0],D[3*t+1]=k[1],D[3*t+2]=k[2],s(k,k,h),r(k,k,j),z[3*t]=k[0],z[3*t+1]=k[1],z[3*t+2]=k[2],S[2*t]=t/p,S[2*t+1]=0,z[3*(t+p)]=z[3*t]+b[0],z[3*(t+p)+1]=z[3*t+1]+b[1],z[3*(t+p)+2]=z[3*t+2]+b[2],S[2*(t+p)]=t/p,S[2*t+1]=1;const o=(t+1)%p;O(V++,t,t),O(V++,t+p,t),O(V++,o,o),O(V++,o,o),O(V++,t+p,t),O(V++,o+p,o)}if(g){for(let t=0;t<p;t++){const n=(t+1)%p;O(V++,I-2,x-2),O(V++,t,x-2),O(V++,n,x-2)}for(let t=0;t<p;t++){const n=(t+1)%p;O(V++,t+p,x-1),O(V++,I-1,x-1),O(V++,n+p,x-1)}}const U=[["position",new P(z,C,3,!0)],["normal",new P(D,F,3,!0)],["uv0",new P(S,C,2,!0)]];return new q(n,U)}function ft(t,n,o,e,s,r){e=e||10,s=null==s||s,C(n.length>1);const l=[[0,0,0]],h=[],u=[];for(let a=0;a<e;a++){h.push([0,-a-1,-(a+1)%e-1]);const t=a/e*2*Math.PI;u.push([Math.cos(t)*o,Math.sin(t)*o])}return wt(t,u,n,l,h,s,r)}function wt(h,u,c,i,f,w,g=a(0,0,0)){const M=u.length,A=m(c.length*M*3+(6*i.length||0)),y=m(c.length*M*3+(i?6:0)),I=new Array,x=new Array;let z=0,D=0;const S=p(),C=p(),F=p(),O=p(),V=p(),k=p(),G=p(),U=p(),B=p(),E=p(),H=p(),J=p(),K=p(),L=b();t(B,0,1,0),n(C,c[1],c[0]),o(C,C),w?(r(U,c[0],g),o(F,U)):t(F,0,0,1),bt(C,F,B,B,V,F,jt),e(O,F),e(J,V);for(let t=0;t<i.length;t++)s(k,V,i[t][0]),s(U,F,i[t][2]),r(k,k,U),r(k,k,c[0]),A[z++]=k[0],A[z++]=k[1],A[z++]=k[2];y[D++]=-C[0],y[D++]=-C[1],y[D++]=-C[2];for(let t=0;t<f.length;t++)I.push(f[t][0]>0?f[t][0]:-f[t][0]-1+i.length),I.push(f[t][1]>0?f[t][1]:-f[t][1]-1+i.length),I.push(f[t][2]>0?f[t][2]:-f[t][2]-1+i.length),x.push(0),x.push(0),x.push(0);let N=i.length;const Q=i.length-1;for(let t=0;t<c.length;t++){let h=!1;if(t>0){e(S,C),t<c.length-1?(n(C,c[t+1],c[t]),o(C,C)):h=!0,r(E,S,C),o(E,E),r(H,c[t-1],O),j(c[t],E,L);d(L,v(H,S),U)?(n(U,U,c[t]),o(F,U),l(V,E,F),o(V,V)):bt(E,O,J,B,V,F,jt),e(O,F),e(J,V)}w&&(r(U,c[t],g),o(K,U));for(let n=0;n<M;n++)if(s(k,V,u[n][0]),s(U,F,u[n][1]),r(k,k,U),o(G,k),y[D++]=G[0],y[D++]=G[1],y[D++]=G[2],r(k,k,c[t]),A[z++]=k[0],A[z++]=k[1],A[z++]=k[2],!h){const t=(n+1)%M;I.push(N+n),I.push(N+M+n),I.push(N+t),I.push(N+t),I.push(N+M+n),I.push(N+M+t);for(let n=0;n<6;n++){const t=I.length-6;x.push(I[t+n]-Q)}}N+=M}const R=c[c.length-1];for(let t=0;t<i.length;t++)s(k,V,i[t][0]),s(U,F,i[t][1]),r(k,k,U),r(k,k,R),A[z++]=k[0],A[z++]=k[1],A[z++]=k[2];const T=D/3;y[D++]=C[0],y[D++]=C[1],y[D++]=C[2];const W=N-M;for(let t=0;t<f.length;t++)I.push(f[t][0]>=0?N+f[t][0]:-f[t][0]-1+W),I.push(f[t][2]>=0?N+f[t][2]:-f[t][2]-1+W),I.push(f[t][1]>=0?N+f[t][1]:-f[t][1]-1+W),x.push(T),x.push(T),x.push(T);const X=[["position",new P(A,I,3,!0)],["normal",new P(y,x,3,!0)]];return new q(h,X)}function gt(t,n,o,e,s){const r=g(3*n.length),l=new Array(2*(n.length-1));let h=0,u=0;for(let c=0;c<n.length;c++){for(let t=0;t<3;t++)r[h++]=n[c][t];c>0&&(l[u++]=c-1,l[u++]=c)}const a=[["position",new P(r,l,3,!0)]];if(o&&o.length===n.length&&3===o[0].length){const t=m(3*o.length);let e=0;for(let s=0;s<n.length;s++)for(let n=0;n<3;n++)t[e++]=o[s][n];a.push(["normal",new P(t,l,3,!0)])}if(e&&a.push(["color",new P(e,A(e.length/4),4)]),s&&s.length===n.length){const t=I(s);a.push(["timeStamps",new P(t,l,3,!0)])}return new q(t,a,null,2)}function mt(t,n,o,e,s,r=0){const l=new Array(18),h=[[-o,r,s/2],[e,r,s/2],[0,n+r,s/2],[-o,r,-s/2],[e,r,-s/2],[0,n+r,-s/2]],u=[0,1,2,3,0,2,2,5,3,1,4,5,5,2,1,1,0,3,3,4,1,4,3,5];for(let a=0;a<6;a++)l[3*a]=h[a][0],l[3*a+1]=h[a][1],l[3*a+2]=h[a][2];return new q(t,[["position",new P(l,u,3,!0)]])}function Mt(n,o){const e=n.getMutableAttribute("position").data;for(let s=0;s<e.length;s+=3){const n=e[s],r=e[s+1],l=e[s+2];t(dt,n,r,l),h(dt,dt,o),e[s]=dt[0],e[s+1]=dt[1],e[s+2]=dt[2]}}function At(t,n=t){const o=t.attributes,e=o.get("position").data,s=o.get("normal").data;if(s){const t=n.getMutableAttribute("normal").data;for(let n=0;n<s.length;n+=3){const o=s[n+1];t[n+1]=-s[n+2],t[n+2]=o}}if(e){const t=n.getMutableAttribute("position").data;for(let n=0;n<e.length;n+=3){const o=e[n+1];t[n+1]=-e[n+2],t[n+2]=o}}}function yt(t,n,e,s,r){return!(Math.abs(u(n,t))>r)&&(l(e,t,n),o(e,e),l(s,e,t),o(s,s),!0)}function bt(t,n,o,e,s,r,l){return yt(t,n,s,r,l)||yt(t,o,s,r,l)||yt(t,e,s,r,l)}const jt=.99619469809,dt=p();export{At as cgToGIS,B as createBoxGeometry,it as createConeGeometry,ct as createConeGeometryData,pt as createCylinderGeometry,L as createDiamondGeometry,mt as createExtrudedTriangle,wt as createPathExtrusionGeometry,ht as createPointGeometry,lt as createPolySphereData,rt as createPolySphereGeometry,gt as createPolylineGeometry,st as createSphereGeometry,at as createSquareGeometry,et as createTetrahedronGeometry,ft as createTubeGeometry,bt as makeOrthoBasisDirUpFallback,Mt as transformInPlace};
5
+ import{i as t,d as n,n as o,c as e,g as s,f as r,h as l,t as h,e as u}from"../../../../chunks/vec32.js";import{fromValues as a,clone as c,create as i}from"../../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{create as p,clone as f,fromValues as w}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{newDoubleArray as g}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as m,floatArrayFrom as M}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as A,getZeroIndexArray as y}from"../../../../geometry/support/Indices.js";import{create as b,fromPositionAndNormal as j,intersectRay as d}from"../../../../geometry/support/plane.js";import{wrap as v}from"../../../../geometry/support/ray.js";import{timeStampsToAttribute as I,numTimeStampValuesPerVertex as P}from"../../support/engineContent/line.js";import{Attribute as x}from"./Attribute.js";import{scale as z,length as D,normalize as S,add as q}from"./bufferVectorMath.js";import{Geometry as C}from"./Geometry.js";import{assert as F}from"./Util.js";const O=[[-.5,-.5,.5],[.5,-.5,.5],[.5,.5,.5],[-.5,.5,.5],[-.5,-.5,-.5],[.5,-.5,-.5],[.5,.5,-.5],[-.5,.5,-.5]],V=[0,0,1,-1,0,0,1,0,0,0,-1,0,0,1,0,0,0,-1],k=[0,0,1,0,1,1,0,1],G=[0,1,2,2,3,0,4,0,3,3,7,4,1,5,6,6,2,1,1,0,4,4,5,1,3,2,6,6,7,3,5,4,7,7,6,5],U=new Array(36);for(let It=0;It<6;It++)for(let t=0;t<6;t++)U[6*It+t]=It;const B=new Array(36);for(let It=0;It<6;It++)B[6*It]=0,B[6*It+1]=1,B[6*It+2]=2,B[6*It+3]=2,B[6*It+4]=3,B[6*It+5]=0;function E(t,n){Array.isArray(n)||(n=[n,n,n]);const o=new Array(24);for(let e=0;e<8;e++)o[3*e]=O[e][0]*n[0],o[3*e+1]=O[e][1]*n[1],o[3*e+2]=O[e][2]*n[2];return new C(t,[["position",new x(o,G,3,!0)],["normal",new x(V,U,3)],["uv0",new x(k,B,2)]])}const H=[[-.5,0,-.5],[.5,0,-.5],[.5,0,.5],[-.5,0,.5],[0,-.5,0],[0,.5,0]],J=[0,1,-1,1,1,0,0,1,1,-1,1,0,0,-1,-1,1,-1,0,0,-1,1,-1,-1,0],K=[5,1,0,5,2,1,5,3,2,5,0,3,4,0,1,4,1,2,4,2,3,4,3,0],L=[0,0,0,1,1,1,2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7];function N(t,n){Array.isArray(n)||(n=[n,n,n]);const o=new Array(18);for(let e=0;e<6;e++)o[3*e]=H[e][0]*n[0],o[3*e+1]=H[e][1]*n[1],o[3*e+2]=H[e][2]*n[2];return new C(t,[["position",new x(o,K,3,!0)],["normal",new x(J,L,3)]])}const Q=a(-.5,0,-.5),R=a(.5,0,-.5),T=a(0,0,.5),W=a(0,.5,0),X=i(),Y=i(),Z=i(),$=i(),_=i();n(X,Q,W),n(Y,Q,R),l(Z,X,Y),o(Z,Z),n(X,R,W),n(Y,R,T),l($,X,Y),o($,$),n(X,T,W),n(Y,T,Q),l(_,X,Y),o(_,_);const tt=[Q,R,T,W],nt=[0,-1,0,Z[0],Z[1],Z[2],$[0],$[1],$[2],_[0],_[1],_[2]],ot=[0,1,2,3,1,0,3,2,1,3,0,2],et=[0,0,0,1,1,1,2,2,2,3,3,3];function st(t,n){Array.isArray(n)||(n=[n,n,n]);const o=new Array(12);for(let e=0;e<4;e++)o[3*e]=tt[e][0]*n[0],o[3*e+1]=tt[e][1]*n[1],o[3*e+2]=tt[e][2]*n[2];return new C(t,[["position",new x(o,ot,3,!0)],["normal",new x(nt,et,3)]])}function rt(t,n,o,e,s={uv:!0}){const r=-Math.PI,l=2*Math.PI,h=-Math.PI/2,u=Math.PI,a=Math.max(3,Math.floor(o)),c=Math.max(2,Math.floor(e)),i=(a+1)*(c+1),p=m(3*i),f=m(3*i),w=m(2*i),g=[];let M=0;for(let m=0;m<=c;m++){const t=[],o=m/c,e=h+o*u,s=Math.cos(e);for(let h=0;h<=a;h++){const u=h/a,c=r+u*l,i=Math.cos(c)*s,g=Math.sin(e),m=-Math.sin(c)*s;p[3*M]=i*n,p[3*M+1]=g*n,p[3*M+2]=m*n,f[3*M]=i,f[3*M+1]=g,f[3*M+2]=m,w[2*M]=u,w[2*M+1]=o,t.push(M),++M}g.push(t)}const A=new Array;for(let m=0;m<c;m++)for(let t=0;t<a;t++){const n=g[m][t],o=g[m][t+1],e=g[m+1][t+1],s=g[m+1][t];0===m?(A.push(n),A.push(e),A.push(s)):m===c-1?(A.push(n),A.push(o),A.push(e)):(A.push(n),A.push(o),A.push(e),A.push(e),A.push(s),A.push(n))}const b=[["position",new x(p,A,3,!0)],["normal",new x(f,A,3,!0)]];return s.uv&&b.push(["uv0",new x(w,A,2,!0)]),s.offset&&(b[0][0]="offset",b.push(["position",new x(Float64Array.from(s.offset),y(A.length),3,!0)])),new C(t,b)}function lt(t,n,o,e){const s=ht(n,o,e);return new C(t,s)}function ht(t,n,o){const e=t;let s,r;if(o)s=[0,-1,0,1,0,0,0,0,1,-1,0,0,0,0,-1,0,1,0],r=[0,1,2,0,2,3,0,3,4,0,4,1,1,5,2,2,5,3,3,5,4,4,5,1];else{const t=e*(1+Math.sqrt(5))/2;s=[-e,t,0,e,t,0,-e,-t,0,e,-t,0,0,-e,t,0,e,t,0,-e,-t,0,e,-t,t,0,-e,t,0,e,-t,0,-e,-t,0,e],r=[0,11,5,0,5,1,0,1,7,0,7,10,0,10,11,1,5,9,5,11,4,11,10,2,10,7,6,7,1,8,3,9,4,3,4,2,3,2,6,3,6,8,3,8,9,4,9,5,2,4,11,6,2,10,8,6,7,9,8,1]}for(let a=0;a<s.length;a+=3)z(s,a,t/D(s,a));let l={};function h(n,o){n>o&&([n,o]=[o,n]);const e=n.toString()+"."+o.toString();if(l[e])return l[e];let r=s.length;return s.length+=3,q(s,3*n,s,3*o,s,r),z(s,r,t/D(s,r)),r/=3,l[e]=r,r}for(let a=0;a<n;a++){const t=r.length,n=new Array(4*t);for(let o=0;o<t;o+=3){const t=r[o],e=r[o+1],s=r[o+2],l=h(t,e),u=h(e,s),a=h(s,t),c=4*o;n[c]=t,n[c+1]=l,n[c+2]=a,n[c+3]=e,n[c+4]=u,n[c+5]=l,n[c+6]=s,n[c+7]=a,n[c+8]=u,n[c+9]=l,n[c+10]=u,n[c+11]=a}r=n,l={}}const u=M(s);for(let a=0;a<u.length;a+=3)S(u,a);return[["position",new x(M(s),r,3,!0)],["normal",new x(u,r,3,!0)]]}function ut(t,{normal:n,position:o,color:e,rotation:s,size:r,centerOffsetAndDistance:l,uvi:h,featureAttribute:u,olidColor:a=null}={}){const c=o?f(o):p(),i=n?f(n):w(0,0,1),g=e?[e[0],e[1],e[2],e.length>3?e[3]:255]:[255,255,255,255],m=null!=r&&2===r.length?r:[1,1],M=null!=s?[s]:[0],A=y(1),b=[["position",new x(c,A,3,!0)],["normal",new x(i,A,3,!0)],["color",new x(g,A,4,!0)],["size",new x(m,A,2)],["rotation",new x(M,A,1,!0)]];if(h&&b.push(["uvi",new x(h,A,h.length)]),null!=l){const t=[l[0],l[1],l[2],l[3]];b.push(["centerOffsetAndDistance",new x(t,A,4)])}if(u){const t=[u[0],u[1],u[2],u[3]];b.push(["featureAttribute",new x(t,A,4)])}return new C(t,b,null,1,a)}const at=[[-1,-1,0],[1,-1,0],[1,1,0],[-1,1,0]];function ct(t,n=at){const o=new Array(12);for(let a=0;a<4;a++)for(let t=0;t<3;t++)o[3*a+t]=n[a][t];const e=[0,1,2,2,3,0],s=[0,0,1],r=[0,0,0,0,0,0],l=[0,0,1,0,1,1,0,1],h=[255,255,255,255],u=[["position",new x(o,e,3,!0)],["normal",new x(s,r,3,!0)],["uv0",new x(l,e,2,!0)],["color",new x(h,r,4,!0)]];return new C(t,u)}function it(t,n,o,e,s=!0,r=!0){let l=0;const h=n,u=t;let c=a(0,l,0),i=a(0,l+u,0),p=a(0,-1,0),f=a(0,1,0);e&&(l=u,i=a(0,0,0),c=a(0,l,0),p=a(0,1,0),f=a(0,-1,0));const w=[i,c],g=[p,f],M=o+2,A=Math.sqrt(u*u+h*h);if(e)for(let m=o-1;m>=0;m--){const t=m*(2*Math.PI/o),n=a(Math.cos(t)*h,l,Math.sin(t)*h);w.push(n);const e=a(u*Math.cos(t)/A,-h/A,u*Math.sin(t)/A);g.push(e)}else for(let m=0;m<o;m++){const t=m*(2*Math.PI/o),n=a(Math.cos(t)*h,l,Math.sin(t)*h);w.push(n);const e=a(u*Math.cos(t)/A,h/A,u*Math.sin(t)/A);g.push(e)}const y=new Array,b=new Array;if(s){for(let t=3;t<w.length;t++)y.push(1),y.push(t-1),y.push(t),b.push(0),b.push(0),b.push(0);y.push(w.length-1),y.push(2),y.push(1),b.push(0),b.push(0),b.push(0)}if(r){for(let t=3;t<w.length;t++)y.push(t),y.push(t-1),y.push(0),b.push(t),b.push(t-1),b.push(1);y.push(0),y.push(2),y.push(w.length-1),b.push(1),b.push(2),b.push(g.length-1)}const j=m(3*M);for(let a=0;a<M;a++)j[3*a]=w[a][0],j[3*a+1]=w[a][1],j[3*a+2]=w[a][2];const d=m(3*M);for(let a=0;a<M;a++)d[3*a]=g[a][0],d[3*a+1]=g[a][1],d[3*a+2]=g[a][2];return[["position",new x(j,y,3,!0)],["normal",new x(d,b,3,!0)]]}function pt(t,n,o,e,s,r=!0,l=!0){return new C(t,it(n,o,e,s,r,l))}function ft(n,e,h,p,f,w,g){const M=f?c(f):a(1,0,0),A=w?c(w):a(0,0,0);g??=!0;const y=i();o(y,M);const b=i();s(b,y,Math.abs(e));const j=i();s(j,b,-.5),r(j,j,A);const d=a(0,1,0);Math.abs(1-u(y,d))<.2&&t(d,0,0,1);const v=i();l(v,y,d),o(v,v),l(d,v,y);const I=2*p+(g?2:0),P=p+(g?2:0),z=m(3*I),D=m(3*P),S=m(2*I),q=new Array(3*p*(g?4:2)),F=new Array(3*p*(g?4:2));g&&(z[3*(I-2)]=j[0],z[3*(I-2)+1]=j[1],z[3*(I-2)+2]=j[2],S[2*(I-2)]=0,S[2*(I-2)+1]=0,z[3*(I-1)]=z[3*(I-2)]+b[0],z[3*(I-1)+1]=z[3*(I-2)+1]+b[1],z[3*(I-1)+2]=z[3*(I-2)+2]+b[2],S[2*(I-1)]=1,S[2*(I-1)+1]=1,D[3*(P-2)]=-y[0],D[3*(P-2)+1]=-y[1],D[3*(P-2)+2]=-y[2],D[3*(P-1)]=y[0],D[3*(P-1)+1]=y[1],D[3*(P-1)+2]=y[2]);const O=(t,n,o)=>{q[t]=n,F[t]=o};let V=0;const k=i(),G=i();for(let t=0;t<p;t++){const n=t*(2*Math.PI/p);s(k,d,Math.sin(n)),s(G,v,Math.cos(n)),r(k,k,G),D[3*t]=k[0],D[3*t+1]=k[1],D[3*t+2]=k[2],s(k,k,h),r(k,k,j),z[3*t]=k[0],z[3*t+1]=k[1],z[3*t+2]=k[2],S[2*t]=t/p,S[2*t+1]=0,z[3*(t+p)]=z[3*t]+b[0],z[3*(t+p)+1]=z[3*t+1]+b[1],z[3*(t+p)+2]=z[3*t+2]+b[2],S[2*(t+p)]=t/p,S[2*t+1]=1;const o=(t+1)%p;O(V++,t,t),O(V++,t+p,t),O(V++,o,o),O(V++,o,o),O(V++,t+p,t),O(V++,o+p,o)}if(g){for(let t=0;t<p;t++){const n=(t+1)%p;O(V++,I-2,P-2),O(V++,t,P-2),O(V++,n,P-2)}for(let t=0;t<p;t++){const n=(t+1)%p;O(V++,t+p,P-1),O(V++,I-1,P-1),O(V++,n+p,P-1)}}const U=[["position",new x(z,q,3,!0)],["normal",new x(D,F,3,!0)],["uv0",new x(S,q,2,!0)]];return new C(n,U)}function wt(t,n,o,e,s,r){e=e||10,s=null==s||s,F(n.length>1);const l=[[0,0,0]],h=[],u=[];for(let a=0;a<e;a++){h.push([0,-a-1,-(a+1)%e-1]);const t=a/e*2*Math.PI;u.push([Math.cos(t)*o,Math.sin(t)*o])}return gt(t,u,n,l,h,s,r)}function gt(h,u,c,i,f,w,g=a(0,0,0)){const M=u.length,A=m(c.length*M*3+(6*i.length||0)),y=m(c.length*M*3+(i?6:0)),I=new Array,P=new Array;let z=0,D=0;const S=p(),q=p(),F=p(),O=p(),V=p(),k=p(),G=p(),U=p(),B=p(),E=p(),H=p(),J=p(),K=p(),L=b();t(B,0,1,0),n(q,c[1],c[0]),o(q,q),w?(r(U,c[0],g),o(F,U)):t(F,0,0,1),jt(q,F,B,B,V,F,dt),e(O,F),e(J,V);for(let t=0;t<i.length;t++)s(k,V,i[t][0]),s(U,F,i[t][2]),r(k,k,U),r(k,k,c[0]),A[z++]=k[0],A[z++]=k[1],A[z++]=k[2];y[D++]=-q[0],y[D++]=-q[1],y[D++]=-q[2];for(let t=0;t<f.length;t++)I.push(f[t][0]>0?f[t][0]:-f[t][0]-1+i.length),I.push(f[t][1]>0?f[t][1]:-f[t][1]-1+i.length),I.push(f[t][2]>0?f[t][2]:-f[t][2]-1+i.length),P.push(0),P.push(0),P.push(0);let N=i.length;const Q=i.length-1;for(let t=0;t<c.length;t++){let h=!1;if(t>0){e(S,q),t<c.length-1?(n(q,c[t+1],c[t]),o(q,q)):h=!0,r(E,S,q),o(E,E),r(H,c[t-1],O),j(c[t],E,L);d(L,v(H,S),U)?(n(U,U,c[t]),o(F,U),l(V,E,F),o(V,V)):jt(E,O,J,B,V,F,dt),e(O,F),e(J,V)}w&&(r(U,c[t],g),o(K,U));for(let n=0;n<M;n++)if(s(k,V,u[n][0]),s(U,F,u[n][1]),r(k,k,U),o(G,k),y[D++]=G[0],y[D++]=G[1],y[D++]=G[2],r(k,k,c[t]),A[z++]=k[0],A[z++]=k[1],A[z++]=k[2],!h){const t=(n+1)%M;I.push(N+n),I.push(N+M+n),I.push(N+t),I.push(N+t),I.push(N+M+n),I.push(N+M+t);for(let n=0;n<6;n++){const t=I.length-6;P.push(I[t+n]-Q)}}N+=M}const R=c[c.length-1];for(let t=0;t<i.length;t++)s(k,V,i[t][0]),s(U,F,i[t][1]),r(k,k,U),r(k,k,R),A[z++]=k[0],A[z++]=k[1],A[z++]=k[2];const T=D/3;y[D++]=q[0],y[D++]=q[1],y[D++]=q[2];const W=N-M;for(let t=0;t<f.length;t++)I.push(f[t][0]>=0?N+f[t][0]:-f[t][0]-1+W),I.push(f[t][2]>=0?N+f[t][2]:-f[t][2]-1+W),I.push(f[t][1]>=0?N+f[t][1]:-f[t][1]-1+W),P.push(T),P.push(T),P.push(T);const X=[["position",new x(A,I,3,!0)],["normal",new x(y,P,3,!0)]];return new C(h,X)}function mt(t,n,o,e,s){const r=g(3*n.length),l=new Array(2*(n.length-1));let h=0,u=0;for(let c=0;c<n.length;c++){for(let t=0;t<3;t++)r[h++]=n[c][t];c>0&&(l[u++]=c-1,l[u++]=c)}const a=[["position",new x(r,l,3,!0)]];if(o&&o.length===n.length&&3===o[0].length){const t=m(3*o.length);let e=0;for(let s=0;s<n.length;s++)for(let n=0;n<3;n++)t[e++]=o[s][n];a.push(["normal",new x(t,l,3,!0)])}if(e&&a.push(["color",new x(e,A(e.length/4),4)]),s&&s.length===n.length){const t=I(s,1);a.push(["timeStamps",new x(t,l,P,!0)])}return new C(t,a,null,2)}function Mt(t,n,o,e,s,r=0){const l=new Array(18),h=[[-o,r,s/2],[e,r,s/2],[0,n+r,s/2],[-o,r,-s/2],[e,r,-s/2],[0,n+r,-s/2]],u=[0,1,2,3,0,2,2,5,3,1,4,5,5,2,1,1,0,3,3,4,1,4,3,5];for(let a=0;a<6;a++)l[3*a]=h[a][0],l[3*a+1]=h[a][1],l[3*a+2]=h[a][2];return new C(t,[["position",new x(l,u,3,!0)]])}function At(n,o){const e=n.getMutableAttribute("position").data;for(let s=0;s<e.length;s+=3){const n=e[s],r=e[s+1],l=e[s+2];t(vt,n,r,l),h(vt,vt,o),e[s]=vt[0],e[s+1]=vt[1],e[s+2]=vt[2]}}function yt(t,n=t){const o=t.attributes,e=o.get("position").data,s=o.get("normal").data;if(s){const t=n.getMutableAttribute("normal").data;for(let n=0;n<s.length;n+=3){const o=s[n+1];t[n+1]=-s[n+2],t[n+2]=o}}if(e){const t=n.getMutableAttribute("position").data;for(let n=0;n<e.length;n+=3){const o=e[n+1];t[n+1]=-e[n+2],t[n+2]=o}}}function bt(t,n,e,s,r){return!(Math.abs(u(n,t))>r)&&(l(e,t,n),o(e,e),l(s,e,t),o(s,s),!0)}function jt(t,n,o,e,s,r,l){return bt(t,n,s,r,l)||bt(t,o,s,r,l)||bt(t,e,s,r,l)}const dt=.99619469809,vt=p();export{yt as cgToGIS,E as createBoxGeometry,pt as createConeGeometry,it as createConeGeometryData,ft as createCylinderGeometry,N as createDiamondGeometry,Mt as createExtrudedTriangle,gt as createPathExtrusionGeometry,ut as createPointGeometry,ht as createPolySphereData,lt as createPolySphereGeometry,mt as createPolylineGeometry,rt as createSphereGeometry,ct as createSquareGeometry,st as createTetrahedronGeometry,wt as createTubeGeometry,jt as makeOrthoBasisDirUpFallback,At as transformInPlace};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{c as t,g as s,a as e}from"../../../../chunks/boundedPlane.js";const a=t();class i{constructor(){this._plane=t(),this._isDecoration=!0}get plane(){return this._plane}get isDecoration(){return this._isDecoration}update({plane:t,isDecoration:i}){let n=!1;return this._isDecoration!==i&&(this._isDecoration=i,n=!0),t??=a,s(t,this._plane)?n:(e(t,this._plane),!0)}}export{i as default};
5
+ import{a as t,g as s,d as e}from"../../../../chunks/boundedPlane.js";const a=t();class i{constructor(){this._plane=t(),this._isDecoration=!0}get plane(){return this._plane}get isDecoration(){return this._isDecoration}update({plane:t,isDecoration:i}){let n=!1;return this._isDecoration!==i&&(this._isDecoration=i,n=!0),t??=a,s(t,this._plane)?n:(e(t,this._plane),!0)}}export{i as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{lerp as e,deg2rad as t,clamp as a}from"../../../../core/mathUtils.js";import{d as r}from"../../../../chunks/boundedPlane.js";import{c as n,b as i,d as c}from"../../../../chunks/sphere.js";function l(e,t){return new v(e,F,t)}function s(e,t){const{curvatureDependent:a,scaleStart:r,scaleFallOffRange:n}=F;return new v(e,{curvatureDependent:{min:{curvature:a.min.curvature,tiltAngle:a.min.tiltAngle,scaleFallOffFactor:g.curvatureDependent.min.scaleFallOffFactor},max:{curvature:a.max.curvature,tiltAngle:a.max.tiltAngle,scaleFallOffFactor:g.curvatureDependent.max.scaleFallOffFactor}},scaleStart:r,scaleFallOffRange:n,minPixelSize:g.minPixelSize},t)}function o(e){return Math.abs(e*e*e)}function u(e,t,a){const r=a.parameters;return O.scale=Math.min(r.divisor/(t-r.offset),1),O.factor=o(e),O}function f(t,a){return e(t*Math.max(a.scale,a.minScaleFactor),t,a.factor)}function m(e,t,a){const r=u(e,t,a);return r.minScaleFactor=0,f(1,r)}function h(e,t,a,r){r.scale=m(e,t,a),r.factor=0,r.minScaleFactor=a.minScaleFactor}function d(e,t,a=[0,0]){const r=Math.min(Math.max(t.scale,t.minScaleFactor),1);return a[0]=e[0]*r,a[1]=e[1]*r,a}function p(e,t,a,r){return f(e,u(t,a,r))}class v{get minScaleFactor(){return null!=this._fontHeight?Math.min(this._description.minPixelSize/this._fontHeight,1):0}constructor(e,t,a,r=_(),n){this._viewingMode=e,this._description=t,this._ellipsoidRadius=a,this.parameters=r,this._fontHeight=n,2===this._viewingMode?(this._coverageCompensation=this._surfaceCoverageCompensationLocal,this._calculateCurvatureDependentParameters=this._calculateCurvatureDependentParametersLocal):(this._coverageCompensation=this._surfaceCoverageCompensationGlobal,this._calculateCurvatureDependentParameters=this._calculateCurvatureDependentParametersGlobal)}update(e){return(!this.parameters||this.parameters.camera.fovY!==e.fovY||this.parameters.camera.distance!==e.distance)&&(this._calculateParameters(e,this._ellipsoidRadius,this.parameters),!0)}overrideFontHeight(e){return e!==this._fontHeight?new v(this._viewingMode,this._description,this._ellipsoidRadius,this.parameters,e):this}_calculateParameters(e,t,a){const{scaleStart:r,scaleFallOffRange:n}=this._description,{fovY:i,distance:c}=e,l=this._calculateCurvatureDependentParameters(e,t),s=this._coverageCompensation(e,t,l),{tiltAngle:o,scaleFallOffFactor:u}=l,f=Math.sin(o)*c,m=.5*Math.PI-o-i*(.5-r*s),h=f/Math.cos(m),d=m+i*n*s,p=(h-u*(f/Math.cos(d)))/(1-u);return a.camera.fovY=e.fovY,a.camera.distance=e.distance,a.offset=p,a.divisor=h-p,a}_calculateCurvatureDependentParametersLocal(e,t,a=C){return a.tiltAngle=this._description.curvatureDependent.min.tiltAngle,a.scaleFallOffFactor=this._description.curvatureDependent.min.scaleFallOffFactor,a}_calculateCurvatureDependentParametersGlobal(t,r,n=C){const i=this._description.curvatureDependent,c=1+t.distance/r,l=Math.sqrt(c*c-1),[s,o]=[i.min.curvature,i.max.curvature],u=a((l-s)/(o-s),0,1),[f,m]=[i.min,i.max];return n.tiltAngle=e(f.tiltAngle,m.tiltAngle,u),n.scaleFallOffFactor=e(f.scaleFallOffFactor,m.scaleFallOffFactor,u),n}_surfaceCoverageCompensationLocal(e,t,a){return r(a.tiltAngle,e.fovY)}_surfaceCoverageCompensationGlobal(e,t,a){return i(x,t),c(x,a.tiltAngle,e.distance,e.fovY)}}const F={curvatureDependent:{min:{curvature:t(10),tiltAngle:t(12),scaleFallOffFactor:.5},max:{curvature:t(70),tiltAngle:t(40),scaleFallOffFactor:.8}},scaleStart:.3,scaleFallOffRange:.65,minPixelSize:0},g={curvatureDependent:{min:{scaleFallOffFactor:.7},max:{scaleFallOffFactor:.95}},minPixelSize:14};function _(){return{camera:{distance:0,fovY:0},divisor:0,offset:0}}const O={scale:0,factor:0,minScaleFactor:0},C={tiltAngle:0,scaleFallOffFactor:0},x=n();export{d as applyPrecomputedScaleFactor,f as applyScaleFactor,s as getLabelSettings,l as getSettings,h as precomputeScaleFactor,p as scale};
5
+ import"../../../../core/has.js";import{clamp as t,lerp as s}from"../../../../core/mathUtils.js";class a{constructor(){this._scale=0,this._angleFactor=0,this._minScale=0}update(t,s,a,i){a?(this._scale=Math.min(a.divisor/(s-a.offset),1),this._angleFactor=e(t),this._minScale=null!=i?Math.min(a.minPixelSize/i,1):0):(this._scale=1,this._minScale=1,this._angleFactor=1)}apply(a){const{_scale:i,_angleFactor:e,_minScale:n}=this;return a*t(s(i,1,e),n,1)}applyVec2(t,s){t[0]=this.apply(s[0]),t[1]=this.apply(s[1])}}class i{constructor(){this.evaluator=new a,this.alignmentEvaluator=new a}update(t,s,a,i,e,n){this.evaluator.update(t,s,a,i),this.alignmentEvaluator.update(t,s,e??a,(e?n:null)??i)}}function e(t){return Math.abs(t)**3}function n(t){return!!t&&!0}class l{constructor(){this.distance=0,this.fovY=0}}class c{constructor(){this.camera=new l,this.offset=0,this.divisor=0,this.minPixelSize=0}}export{l as CameraDefinition,a as ScreenSizePerspectiveEvaluator,c as ScreenSizePerspectiveParameters,i as SeparateScreenSizePerspectiveEvaluators,n as isScreenSizePerspectiveEnabled};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{q as e,i as r,c as t,n as s,d as a,l as i,g as o,e as n,o as l}from"../../../../chunks/vec32.js";import{ZEROS as u,create as c,fromValues as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{is3DGeometryOutputMRT as m,isShadowRelatedOutput as p,isColorOrColorEmission as d,isColorEmission as T}from"../core/shaderLibrary/ShaderOutput.js";import{GLTextureMaterial as f}from"../lib/GLTextureMaterial.js";import{Material as x}from"../lib/Material.js";import{OITPolygonOffsetLimit as g}from"../lib/OrderIndependentTransparency.js";import{intersectTriangleGeometry as v}from"../lib/RayIntersections.js";import{getVerticalOffsetObject3D as S}from"../lib/verticalOffsetUtils.js";import{DefaultBufferWriter as M}from"./DefaultBufferWriter.js";import{verticalOffsetAtDistance as b}from"./internal/MaterialUtil.js";import{getLayout as O,DefaultMaterialPassParameters as w,DefaultMaterialTechnique as C}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as y}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{RealisticTreeTechnique as R}from"../shaders/RealisticTreeTechnique.js";import{alphaCutoff as P}from"../../../../webscene/support/AlphaCutoff.js";class D extends x{constructor(e,r){super(e,A),this.materialType="default",this.supportsEdges=!0,this.intersectDraped=void 0,this.produces=new Map([[2,e=>(m(e)||p(e))&&!this.transparent],[4,e=>(m(e)||p(e))&&this.transparent&&this.parameters.writeDepth],[8,e=>(m(e)||p(e))&&this.transparent&&!this.parameters.writeDepth]]),this._layout=O(this.parameters),this._configuration=new y(r.spherical)}isVisibleForOutput(e){return 4!==e&&6!==e&&5!==e||this.parameters.castShadows}get visible(){const{layerOpacity:e,colorMixMode:r,opacity:t,externalColor:s}=this.parameters;return e*("replace"===r?1:t)*("ignore"===r||isNaN(s[3])?1:s[3])>=P}get _hasEmissiveBase(){return!!this.parameters.emissiveTextureId||!e(this.parameters.emissiveBaseColor,u)}get hasEmissions(){return this.parameters.emissiveStrength>0&&(0===this.parameters.emissiveSource&&this._hasEmissiveBase||1===this.parameters.emissiveSource)}getConfiguration(e,r){const{parameters:t,_configuration:s}=this,{treeRendering:a,doubleSided:i,doubleSidedType:o}=t;return super.getConfiguration(e,r,this._configuration),s.hasNormalTexture=t.hasNormalTexture,s.hasColorTexture=t.hasColorTexture,s.hasMetallicRoughnessTexture=t.hasMetallicRoughnessTexture,s.hasOcclusionTexture=t.hasOcclusionTexture,s.hasVertexTangents=!a&&t.hasVertexTangents,s.instanced=t.instanced,s.instancedDoublePrecision=t.instancedDoublePrecision,s.hasVVColor=!!t.vvColor,s.hasVVSize=!!t.vvSize,s.hasVerticalOffset=null!=t.verticalOffset,s.hasScreenSizePerspective=null!=t.screenSizePerspective,s.hasSlicePlane=t.hasSlicePlane,s.alphaDiscardMode=t.textureAlphaMode,s.normalType=a?0:t.normalType,s.transparent=this.transparent,s.writeDepth=t.writeDepth,s.customDepthTest=t.customDepthTest??0,s.hasOccludees=r.hasOccludees,s.cullFace=t.hasSlicePlane?0:t.cullFace,s.cullAboveTerrain=r.cullAboveTerrain,s.hasModelTransformation=!a&&null!=t.modelTransformation,s.hasVertexColors=t.hasVertexColors,s.hasSymbolColors=t.hasSymbolColors,s.doubleSidedMode=a?2:i&&"normal"===o?1:i&&"winding-order"===o?2:0,s.instancedFeatureAttribute=t.instancedFeatureAttribute,s.instancedColor=t.instancedColor,d(e)?(s.terrainDepthTest=r.terrainDepthTest,s.receiveShadows=t.receiveShadows,s.receiveAmbientOcclusion=t.receiveAmbientOcclusion&&null!=r.ssao):(s.terrainDepthTest=!1,s.receiveShadows=s.receiveAmbientOcclusion=!1),s.textureAlphaPremultiplied=!!t.textureAlphaPremultiplied,s.pbrMode=t.usePBR?t.isSchematic?2:1:0,s.emissionSource=t.emissionSource,s.offsetBackfaces=!(!this.transparent||!t.offsetTransparentBackfaces),s.oitPass=r.oitPass,s.enableOffset=r.camera.relativeElevation<g,s.snowCover=r.snowCover>0,s.hasGlow=T(e),s.hasColorTextureTransform=!!t.colorTextureTransformMatrix,s.hasNormalTextureTransform=!!t.normalTextureTransformMatrix,s.hasEmissionTextureTransform=!!t.emissiveTextureTransformMatrix,s.hasOcclusionTextureTransform=!!t.occlusionTextureTransformMatrix,s.hasMetallicRoughnessTextureTransform=!!t.metallicRoughnessTextureTransformMatrix,s}intersect(e,u,c,h,m,p){if(null!=this.parameters.verticalOffset){const e=c.camera;r(E,u[12],u[13],u[14]);let p=null;switch(c.viewingMode){case 1:p=s(N,E);break;case 2:p=t(N,_)}let d=0;const T=a(q,E,e.eye),f=i(T),x=o(T,T,1/f);let g=null;this.parameters.screenSizePerspective&&(g=n(p,x)),d+=b(e,f,this.parameters.verticalOffset,g??0,this.parameters.screenSizePerspective),o(p,p,d),l(z,p,c.transform.inverseRotation),h=a(V,h,z),m=a(B,m,z)}v(e,c,h,m,S(c.verticalOffset),p)}createGLMaterial(e){return new j(e)}createBufferWriter(){return new M(this._layout)}get transparent(){return I(this.parameters)}}class j extends f{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){this._material.setParameters({receiveShadows:e.shadowMap.enabled});const t=this._material.parameters;this.updateTexture(t.textureId);const s=e.camera.viewInverseTransposeMatrix;return r(t.origin,s[3],s[7],s[11]),this._material.setParameters(this.textureBindParameters),this.getTechnique(t.treeRendering?R:C,e)}}class A extends w{constructor(){super(...arguments),this.treeRendering=!1,this.hasVertexTangents=!1}get hasNormalTexture(){return!this.treeRendering&&!!this.normalTextureId}get hasColorTexture(){return!!this.textureId}get hasMetallicRoughnessTexture(){return!this.treeRendering&&!!this.metallicRoughnessTextureId}get hasOcclusionTexture(){return!this.treeRendering&&!!this.occlusionTextureId}get emissionSource(){return this.treeRendering?0:null!=this.emissiveTextureId&&0===this.emissiveSource?3:this.usePBR?0===this.emissiveSource?2:1:0}get hasTextures(){return this.hasColorTexture||this.hasNormalTexture||this.hasMetallicRoughnessTexture||3===this.emissionSource||this.hasOcclusionTexture}}function I(e){const{drivenOpacity:r,opacity:t,externalColor:s,layerOpacity:a,texture:i,textureId:o,textureAlphaMode:n,colorMixMode:l}=e,u=s[3];return r||t<1&&"replace"!==l||u<1&&"ignore"!==l||a<1||(null!=i||null!=o)&&1!==n&&2!==n&&"replace"!==l}const V=c(),B=c(),_=h(0,0,1),N=c(),z=c(),E=c(),q=c();export{j as DefaultGLMaterial,D as DefaultMaterial,A as DefaultMaterialParameters,I as isTransparent};
5
+ import{q as e,i as r,c as t,n as s,d as a,l as i,g as o,e as n,o as l}from"../../../../chunks/vec32.js";import{ZEROS as u,create as c,fromValues as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{is3DGeometryOutputMRT as m,isShadowRelatedOutput as p,isColorOrColorEmission as d,isColorEmission as T}from"../core/shaderLibrary/ShaderOutput.js";import{GLTextureMaterial as f}from"../lib/GLTextureMaterial.js";import{Material as x}from"../lib/Material.js";import{OITPolygonOffsetLimit as g}from"../lib/OrderIndependentTransparency.js";import{intersectTriangleGeometry as v}from"../lib/RayIntersections.js";import{getVerticalOffsetObject3D as S}from"../lib/verticalOffsetUtils.js";import{DefaultBufferWriter as M}from"./DefaultBufferWriter.js";import{verticalOffsetAtDistance as b}from"./internal/MaterialUtil.js";import{getLayout as O,DefaultMaterialPassParameters as w,DefaultMaterialTechnique as C}from"../shaders/DefaultMaterialTechnique.js";import{DefaultMaterialTechniqueConfiguration as y}from"../shaders/DefaultMaterialTechniqueConfiguration.js";import{RealisticTreeTechnique as R}from"../shaders/RealisticTreeTechnique.js";import{alphaCutoff as P}from"../../../../webscene/support/AlphaCutoff.js";class D extends x{constructor(e,r){super(e,A),this.materialType="default",this.supportsEdges=!0,this.intersectDraped=void 0,this.produces=new Map([[2,e=>(m(e)||p(e))&&!this.transparent],[4,e=>(m(e)||p(e))&&this.transparent&&this.parameters.writeDepth],[8,e=>(m(e)||p(e))&&this.transparent&&!this.parameters.writeDepth]]),this._layout=O(this.parameters),this._configuration=new y(r.spherical)}isVisibleForOutput(e){return 4!==e&&6!==e&&5!==e||this.parameters.castShadows}get visible(){const{layerOpacity:e,colorMixMode:r,opacity:t,externalColor:s}=this.parameters;return e*("replace"===r?1:t)*("ignore"===r||isNaN(s[3])?1:s[3])>=P}get _hasEmissiveBase(){return!!this.parameters.emissiveTextureId||!e(this.parameters.emissiveBaseColor,u)}get hasEmissions(){return this.parameters.emissiveStrength>0&&(0===this.parameters.emissiveSource&&this._hasEmissiveBase||1===this.parameters.emissiveSource)}getConfiguration(e,r){const{parameters:t,_configuration:s}=this,{treeRendering:a,doubleSided:i,doubleSidedType:o}=t;return super.getConfiguration(e,r,this._configuration),s.hasNormalTexture=t.hasNormalTexture,s.hasColorTexture=t.hasColorTexture,s.hasMetallicRoughnessTexture=t.hasMetallicRoughnessTexture,s.hasOcclusionTexture=t.hasOcclusionTexture,s.hasVertexTangents=!a&&t.hasVertexTangents,s.instanced=t.instanced,s.instancedDoublePrecision=t.instancedDoublePrecision,s.hasVVColor=!!t.vvColor,s.hasVVSize=!!t.vvSize,s.hasVerticalOffset=null!=t.verticalOffset,s.hasScreenSizePerspective=null!=t.screenSizePerspective,s.hasSlicePlane=t.hasSlicePlane,s.alphaDiscardMode=t.textureAlphaMode,s.normalType=a?0:t.normalType,s.transparent=this.transparent,s.writeDepth=t.writeDepth,s.customDepthTest=t.customDepthTest??0,s.hasOccludees=r.hasOccludees,s.cullFace=t.hasSlicePlane?0:t.cullFace,s.cullAboveTerrain=r.cullAboveTerrain,s.hasModelTransformation=!a&&null!=t.modelTransformation,s.hasVertexColors=t.hasVertexColors,s.hasSymbolColors=t.hasSymbolColors,s.doubleSidedMode=a?2:i&&"normal"===o?1:i&&"winding-order"===o?2:0,s.instancedFeatureAttribute=t.instancedFeatureAttribute,s.instancedColor=t.instancedColor,d(e)?(s.terrainDepthTest=r.terrainDepthTest,s.receiveShadows=t.receiveShadows,s.receiveAmbientOcclusion=t.receiveAmbientOcclusion&&null!=r.ssao):(s.terrainDepthTest=!1,s.receiveShadows=s.receiveAmbientOcclusion=!1),s.textureAlphaPremultiplied=!!t.textureAlphaPremultiplied,s.pbrMode=t.usePBR?t.isSchematic?2:1:0,s.emissionSource=t.emissionSource,s.offsetBackfaces=!(!this.transparent||!t.offsetTransparentBackfaces),s.oitPass=r.oitPass,s.enableOffset=r.camera.relativeElevation<g,s.snowCover=r.snowCover>0,s.hasGlow=T(e),s.hasColorTextureTransform=!!t.colorTextureTransformMatrix,s.hasNormalTextureTransform=!!t.normalTextureTransformMatrix,s.hasEmissionTextureTransform=!!t.emissiveTextureTransformMatrix,s.hasOcclusionTextureTransform=!!t.occlusionTextureTransformMatrix,s.hasMetallicRoughnessTextureTransform=!!t.metallicRoughnessTextureTransformMatrix,s}intersect(e,u,c,h,m,p){if(null!=this.parameters.verticalOffset){const e=c.camera;r(E,u[12],u[13],u[14]);let p=null;switch(c.viewingMode){case 1:p=s(N,E);break;case 2:p=t(N,_)}let d=0;const T=a(q,E,e.eye),f=i(T),x=o(T,T,1/f);let g=null;this.parameters.screenSizePerspective&&(g=n(p,x)),d+=b(e,f,this.parameters.verticalOffset,g??0,this.parameters.screenSizePerspective,null),o(p,p,d),l(z,p,c.transform.inverseRotation),h=a(V,h,z),m=a(B,m,z)}v(e,c,h,m,S(c.verticalOffset),p)}createGLMaterial(e){return new j(e)}createBufferWriter(){return new M(this._layout)}get transparent(){return I(this.parameters)}}class j extends f{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){this._material.setParameters({receiveShadows:e.shadowMap.enabled});const t=this._material.parameters;this.updateTexture(t.textureId);const s=e.camera.viewInverseTransposeMatrix;return r(t.origin,s[3],s[7],s[11]),this._material.setParameters(this.textureBindParameters),this.getTechnique(t.treeRendering?R:C,e)}}class A extends w{constructor(){super(...arguments),this.treeRendering=!1,this.hasVertexTangents=!1}get hasNormalTexture(){return!this.treeRendering&&!!this.normalTextureId}get hasColorTexture(){return!!this.textureId}get hasMetallicRoughnessTexture(){return!this.treeRendering&&!!this.metallicRoughnessTextureId}get hasOcclusionTexture(){return!this.treeRendering&&!!this.occlusionTextureId}get emissionSource(){return this.treeRendering?0:null!=this.emissiveTextureId&&0===this.emissiveSource?3:this.usePBR?0===this.emissiveSource?2:1:0}get hasTextures(){return this.hasColorTexture||this.hasNormalTexture||this.hasMetallicRoughnessTexture||3===this.emissionSource||this.hasOcclusionTexture}}function I(e){const{drivenOpacity:r,opacity:t,externalColor:s,layerOpacity:a,texture:i,textureId:o,textureAlphaMode:n,colorMixMode:l}=e,u=s[3];return r||t<1&&"replace"!==l||u<1&&"ignore"!==l||a<1||(null!=i||null!=o)&&1!==n&&2!==n&&"replace"!==l}const V=c(),B=c(),_=h(0,0,1),N=c(),z=c(),E=c(),q=c();export{j as DefaultGLMaterial,D as DefaultMaterial,A as DefaultMaterialParameters,I as isTransparent};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import{clamp as e,deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,rotate as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as f,t as u,n as p,d as h,g as m,c as d,l as g,j as b,f as v,a as S,o as x,e as O}from"../../../../chunks/vec32.js";import{create as y,fromValues as z}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as _,create as A,freeze as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as P}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as F}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as D,BufferViewVec3f as M,BufferViewFloat as C,BufferViewVec2f as V,BufferViewVec4f as R}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as w}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as T}from"../../support/debugFlags.js";import{isColorEmissionHighlightOrOID as U,isColorOrColorEmission as L}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as E}from"../core/shaderLibrary/hud/HUD.glsl.js";import{olidEnabled as B}from"../effects/geometry/olidUtils.js";import{GLTextureMaterialBindParameters as I,GLTextureMaterial as q}from"../lib/GLTextureMaterial.js";import{Material as G}from"../lib/Material.js";import{applyScaleFactor as W,applyPrecomputedScaleFactor as H,precomputeScaleFactor as N}from"../lib/screenSizePerspectiveUtils.js";import{assert as X}from"../lib/Util.js";import{ScaleInfo as Y}from"./ScaleInfo.js";import{writePosition as k,writeNormal as J,writeColor as K,writeBufferFloat as Q,writeBufferVec4 as Z,writeBufferVec4Zeros as $,writeOlidColor as ee}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as te}from"./internal/MaterialUtil.js";import{c as ie,f as se}from"../../../../chunks/HUDMaterial.glsl.js";import{olidLayout as re,layout as ae,HUDMaterialTechnique as ne}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as oe}from"../shaders/HUDMaterialTechniqueConfiguration.js";import{alphaCutoff as le}from"../../../../webscene/support/AlphaCutoff.js";class ce extends G{constructor(e,t){super(e,Ue),this.produces=new Map([[13,e=>U(e)&&!this.parameters.drawAsLabel],[14,e=>U(e)&&this.parameters.drawAsLabel],[12,()=>this.parameters.occlusionTest],[18,e=>this.parameters.draped&&U(e)]]),this._visible=!0,this._configuration=new oe(t)}getConfiguration(e,t){const i=this.parameters.draped;return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=i,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.hasRotation=this.parameters.hasRotation,this._configuration.hasVVSize=!!this.parameters.vvSize,this._configuration.hasVVColor=!!this.parameters.vvColor,this._configuration.occlusionPass=12===t.slot,this._configuration.occludedFragmentFade=!i&&this.parameters.occludedFragmentFade,this._configuration.horizonCullingEnabled=this.parameters.horizonCullingEnabled,this._configuration.isFocused=this.parameters.isFocused,this._configuration.depthTestEnabled=this.parameters.depthEnabled||12===t.slot,L(e)&&(this._configuration.debugDrawLabelBorder=!!T.LABELS_SHOW_BORDER),this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}intersect(e,t,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:v},point:S,camera:x}=s,{parameters:O}=this;if(!l||!c||v&&O.isLabel||!e.visible||!S||!x)return;const z=e.attributes.get("featureAttribute"),A=null==z?null:_(z.data,De),{scaleX:j,scaleY:P}=Ee(A,O,x.pixelRatio);i(ze,t),e.attributes.has("featureAttribute")&&he(ze);const F=e.attributes.get("position"),D=e.attributes.get("size"),M=e.attributes.get("normal"),C=e.attributes.get("rotation"),V=e.attributes.get("centerOffsetAndDistance");X(F.size>=3);const R=ie(O),w="screen"===this.parameters.centerOffsetUnits;for(let i=0;i<F.data.length/F.size;i++){const e=i*F.size;f(ge,F.data[e],F.data[e+1],F.data[e+2]),u(ge,ge,t),u(ge,ge,x.viewMatrix);const a=i*V.size;if(f(Pe,V.data[a],V.data[a+1],V.data[a+2]),!w&&(ge[0]+=Pe[0],ge[1]+=Pe[1],0!==Pe[2])){const e=Pe[2];p(Pe,ge),h(ge,ge,m(Pe,Pe,e))}const n=i*M.size;if(f(be,M.data[n],M.data[n+1],M.data[n+2]),pe(be,ze,x,Me),Be(this.parameters,ge,Me,x,de),x.applyProjection(ge,ve),ve[0]>-1){w&&(Pe[0]||Pe[1])&&(ve[0]+=Pe[0]*x.pixelRatio,0!==Pe[1]&&(ve[1]+=W(Pe[1],de.factorAlignment)*x.pixelRatio),x.unapplyProjection(ve,ge)),ve[0]+=this.parameters.screenOffset[0]*x.pixelRatio,ve[1]+=this.parameters.screenOffset[1]*x.pixelRatio,ve[0]=Math.floor(ve[0]),ve[1]=Math.floor(ve[1]);const e=i*D.size;Re[0]=D.data[e],Re[1]=D.data[e+1],H(Re,de.factor,Re);const t=Ce*x.pixelRatio;let a=0;if(O.textureIsSignedDistanceField){a=Math.min(O.outlineSize,.5*Re[0])*x.pixelRatio/2}Re[0]*=j,Re[1]*=P;const n=i*C.size,l=O.rotation+C.data[n];if(me(S,ve[0],ve[1],Re,t,a,l,O,R)){const e=s.ray;if(u(xe,ge,r(Ae,x.viewMatrix)),ve[0]=S[0],ve[1]=S[1],x.unprojectFromRenderScreen(ve,ge)){const t=y();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ge)*i,t,-1,xe)}}}}}intersectDraped(e,t,i,s,r){const a=e.attributes.get("position"),n=e.attributes.get("size"),o=e.attributes.get("rotation"),l=this.parameters,c=ie(l),f=e.attributes.get("featureAttribute"),u=null==f?null:_(f.data,De),{scaleX:p,scaleY:h}=Ee(u,l,e.screenToWorldRatio),m=Ve*e.screenToWorldRatio;for(let d=0;d<a.data.length/a.size;d++){const t=d*a.size,f=a.data[t],u=a.data[t+1],g=d*n.size;Re[0]=n.data[g],Re[1]=n.data[g+1];let b=0;if(l.textureIsSignedDistanceField){b=Math.min(l.outlineSize,.5*Re[0])*e.screenToWorldRatio/2}Re[0]*=p,Re[1]*=h;const v=d*o.size,S=l.rotation+o.data[v];me(i,f,u,Re,m,b,S,l,c)&&s(r.distance,r.normal,-1)}}createBufferWriter(){return new Le}applyShaderOffsetsView(e,t,i,s,r,a,n){const o=pe(t,i,r,Me);return this._applyVerticalGroundOffsetView(e,o,r,n),Be(this.parameters,n,o,r,a),this._applyPolygonOffsetView(n,o,s[3],r,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,i,s,r){return this._applyCenterOffsetNDC(e,t,i,s),null!=r&&d(r,s),this._applyPolygonOffsetNDC(s,t,i,s),s}_applyPolygonOffsetView(t,i,s,r,a){const n=r.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return d(a,t);const c=e(Math.abs(i.cosAngle),.01,1),f=1-Math.sqrt(1-c*c)/c/r.viewport[2];return m(a,t,l>0?f:1/f),a}_applyVerticalGroundOffsetView(e,t,i,s){const r=g(e),a=i.aboveGround?1:-1,n=i.computeRenderPixelSizeAtDist(r)*E,o=m(ge,t.normal,a*n);return v(s,e,o),s}_applyCenterOffsetView(e,t,i){const s="screen"!==this.parameters.centerOffsetUnits;return i!==e&&d(i,e),s&&(i[0]+=t[0],i[1]+=t[1],t[2]&&(p(be,i),S(i,i,m(be,be,t[2])))),i}_applyCenterOffsetNDC(e,t,i,s){const r="screen"!==this.parameters.centerOffsetUnits;return s!==e&&d(s,e),r||(s[0]+=t[0]/i.fullWidth*2,s[1]+=t[1]/i.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,i,s){const r=this.parameters.shaderPolygonOffset;if(e!==s&&d(s,e),r){const e=i.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*r}return s}set visible(e){this._visible=e}get visible(){const{color:e,outlineSize:t,outlineColor:i}=this.parameters,s=e[3]>=le||t>=le&&i[3]>=le;return this._visible&&s}createGLMaterial(e){return new fe(e)}calculateRelativeScreenBounds(e,t,i=F()){return ue(this.parameters,e,t,i),i[2]=i[0]+e[0],i[3]=i[1]+e[1],i}}class fe extends q{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.getTechnique(ne,e)}}function ue(e,t,i,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*i,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*i}function pe(e,t,s,r){return P(t)&&(t=i(_e,t)),x(r.normal,e,t),u(r.normal,r.normal,s.viewInverseTransposeMatrix),r.cosAngle=O(Se,Te),r}function he(e){const t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],f=1/Math.sqrt(t*t+i*i+s*s),u=1/Math.sqrt(r*r+a*a+n*n),p=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*f,e[1]=i*f,e[2]=s*f,e[3]=r*u,e[4]=a*u,e[5]=n*u,e[6]=o*p,e[7]=l*p,e[8]=c*p,e}function me(e,i,s,r,a,l,c,f,u){let p=i-a-r[0]*u[0],h=p+r[0]+2*a,m=s-a-r[1]*u[1],d=m+r[1]+2*a;const g=f.distanceFieldBoundingBox;return f.textureIsSignedDistanceField&&null!=g&&(p+=r[0]*g[0],m+=r[1]*g[1],h-=r[0]*(1-g[2]),d-=r[1]*(1-g[3]),p-=l,h+=l,m-=l,d+=l),n(ye,i,s),o(Oe,e,ye,t(c)),Oe[0]>p&&Oe[0]<h&&Oe[1]>m&&Oe[1]<d}const de=new Y,ge=y(),be=y(),ve=A(),Se=y(),xe=y(),Oe=c(),ye=c(),ze=s(),_e=s(),Ae=a(),je=A(),Pe=y(),Fe=y(),De=A(),Me={normal:Se,cosAngle:0},Ce=1,Ve=2,Re=l(0,0),we=6,Te=z(0,0,1);class Ue extends I{constructor(){super(...arguments),this.renderOccluded=1,this.isDecoration=!1,this.color=j(1,1,1,1),this.polygonOffset=!1,this.anchorPosition=l(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=j(1,1,1,1),this.outlineSize=0,this.distanceFieldBoundingBox=A(),this.rotation=0,this.hasRotation=!1,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.occludedFragmentFade=!1,this.horizonCullingEnabled=!1,this.centerOffsetUnits="world",this.drawAsLabel=!1,this.depthEnabled=!0,this.isFocused=!0,this.focusStyle="bright",this.draped=!1,this.isLabel=!1}get hasVVSize(){return!!this.vvSize}get hasVVColor(){return!!this.vvColor}get hasVVOpacity(){return!!this.vvOpacity}}class Le{constructor(){this.layout=B()?re:ae}elementCount(e){return e.get("position").indices.length*we}write(e,t,i,s,r,a){const{position:n,normal:o,uvi:l,color:c,size:f,rotation:u,centerOffsetAndDistance:p,featureAttribute:h}=r;k(i.get("position"),e,n,a,we),J(i.get("normal"),t,o,a,we);const m=i.get("uvi")?.data;let d=0,g=0,b=-1-se,v=-1-se;m&&m.length>=4&&(d=m[0],g=m[1],b=-1-m[2],v=-1-m[3]);let S=i.get("position").indices.length,x=a;for(let z=0;z<S;++z)l.set(x,0,d),l.set(x,1,g),x++,l.set(x,0,b),l.set(x,1,g),x++,l.set(x,0,b),l.set(x,1,v),x++,l.set(x,0,b),l.set(x,1,v),x++,l.set(x,0,d),l.set(x,1,v),x++,l.set(x,0,d),l.set(x,1,g),x++;K(i.get("color"),4,c,a,we);const{data:O,indices:y}=i.get("size");S=y.length,x=a;for(let z=0;z<S;++z){const e=O[2*y[z]],t=O[2*y[z]+1];for(let i=0;i<we;++i)f.set(x,0,e),f.set(x,1,t),x++}if(Q(i.get("rotation"),u,a,we),i.get("centerOffsetAndDistance")?Z(i.get("centerOffsetAndDistance"),p,a,we):$(p,a,S*we),i.get("featureAttribute")?Z(i.get("featureAttribute"),h,a,we):$(h,a,S*we),null!=s){const e=i.get("position")?.indices;if(e){const t=e.length,i=r.getField("olidColor",D);ee(s,i,t,a,we)}}return{numVerticesPerItem:we,numItems:S}}intersect(e,t,i,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:S},point:x,camera:O}=s;if(!l||!c||S&&t.isLabel||!x)return;const z=this.layout.createView(e),_=z.getField("position",M),A=z.getField("normal",M),j=z.getField("rotation",C),P=z.getField("size",V),F=z.getField("featureAttribute",R),D=z.getField("centerOffsetAndDistance",R),w="screen"===t.centerOffsetUnits,T=ie(t);if(null==_||null==A||null==j||null==P||null==D||null==O)return;const U=null==F?null:F.getVec(0,De),{scaleX:L,scaleY:E}=Ee(U,t,O.pixelRatio),B=_.count/we;for(let M=0;M<B;M++){const e=M*we;if(_.getVec(e,ge),null!=i&&v(ge,ge,i),u(ge,ge,O.viewMatrix),D.getVec(e,je),f(Pe,je[0],je[1],je[2]),!w&&(ge[0]+=Pe[0],ge[1]+=Pe[1],0!==Pe[2])){const e=Pe[2];p(Pe,ge),h(ge,ge,m(Pe,Pe,e))}if(A.getVec(e,be),pe(be,ze,O,Me),Be(t,ge,Me,O,de),O.applyProjection(ge,ve),ve[0]>-1){w&&(Pe[0]||Pe[1])&&(ve[0]+=Pe[0]*O.pixelRatio,0!==Pe[1]&&(ve[1]+=W(Pe[1],de.factorAlignment)*O.pixelRatio),O.unapplyProjection(ve,ge)),ve[0]+=t.screenOffset[0]*O.pixelRatio,ve[1]+=t.screenOffset[1]*O.pixelRatio,ve[0]=Math.floor(ve[0]),ve[1]=Math.floor(ve[1]),P.getVec(e,Re),H(Re,de.factor,Re);const i=Ce*O.pixelRatio;let a=0;if(t.textureIsSignedDistanceField){a=Math.min(t.outlineSize,.5*Re[0])*O.pixelRatio/2}Re[0]*=L,Re[1]*=E;const n=j.get(e),l=t.rotation+n;if(me(x,ve[0],ve[1],Re,i,a,l,t,T)){const e=s.ray;if(u(xe,ge,r(Ae,O.viewMatrix)),ve[0]=x[0],ve[1]=x[1],O.unprojectFromRenderScreen(ve,ge)){const t=y();d(t,e.direction);const i=1/g(t);m(t,t,i);o(b(e.origin,ge)*i,t,M,xe)}}}}}}function Ee(e,t,i){return null==e||null==t.vvSize?{scaleX:i,scaleY:i}:(w(Fe,t,e),{scaleX:Fe[0]*i,scaleY:Fe[1]*i})}function Be(e,t,i,s,r){if(!e.verticalOffset?.screenLength){if(e.screenSizePerspective||e.screenSizePerspectiveAlignment){Ie(e,r,g(t),i.cosAngle)}else r.factor.scale=1,r.factorAlignment.scale=1;return t}const a=g(t),n=e.screenSizePerspectiveAlignment??e.screenSizePerspective,o=te(s,a,e.verticalOffset,i.cosAngle,n);return Ie(e,r,a,i.cosAngle),m(i.normal,i.normal,o),v(t,t,i.normal)}function Ie(e,t,i,s){null!=e.screenSizePerspective?N(s,i,e.screenSizePerspective,t.factor):(t.factor.scale=1,t.factor.factor=0,t.factor.minScaleFactor=0),null!=e.screenSizePerspectiveAlignment?N(s,i,e.screenSizePerspectiveAlignment,t.factorAlignment):(t.factorAlignment.factor=t.factor.factor,t.factorAlignment.scale=t.factor.scale,t.factorAlignment.minScaleFactor=t.factor.minScaleFactor)}export{ce as HUDMaterial,Ue as Parameters};
5
+ import{clamp as e,deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as i}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as n,rotate as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{fromValues as l,create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{i as u,t as f,n as p,d as h,g as d,c as m,l as g,j as b,f as v,a as x,o as S,e as y}from"../../../../chunks/vec32.js";import{create as O,fromValues as z}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{fromArray as _,create as P,freeze as j}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{isMat4 as M}from"../../../../core/libs/gl-matrix-2/types/mat4.js";import{create as F}from"../../../../geometry/support/aaBoundingRect.js";import{BufferViewVec4u8 as D,BufferViewVec3f as R,BufferViewFloat as V,BufferViewVec2f as A,BufferViewVec4f as C}from"../../../../geometry/support/buffer/BufferView.js";import{evaluateModelTransformScale as w}from"../../layers/support/FastSymbolUpdates.js";import{debugFlags as T}from"../../support/debugFlags.js";import{isColorEmissionHighlightOrOID as U,isColorOrColorEmission as E}from"../core/shaderLibrary/ShaderOutput.js";import{HUDVerticalPixelOffset as L}from"../core/shaderLibrary/hud/HUD.glsl.js";import{olidEnabled as B}from"../effects/geometry/olidUtils.js";import{GLTextureMaterialBindParameters as I,GLTextureMaterial as q}from"../lib/GLTextureMaterial.js";import{Material as G}from"../lib/Material.js";import{SeparateScreenSizePerspectiveEvaluators as W}from"../lib/screenSizePerspectiveUtils.js";import{assert as H}from"../lib/Util.js";import{writePosition as N,writeNormal as X,writeColor as Y,writeBufferFloat as k,writeBufferVec4 as J,writeBufferVec4Zeros as K,writeOlidColor as Q}from"./internal/bufferWriterUtils.js";import{verticalOffsetAtDistance as Z}from"./internal/MaterialUtil.js";import{c as $,f as ee}from"../../../../chunks/HUDMaterial.glsl.js";import{olidLayout as te,layout as ie,HUDMaterialTechnique as se}from"../shaders/HUDMaterialTechnique.js";import{HUDMaterialTechniqueConfiguration as re}from"../shaders/HUDMaterialTechniqueConfiguration.js";import{alphaCutoff as ae}from"../../../../webscene/support/AlphaCutoff.js";class ne extends G{constructor(e,t){super(e,Ce),this.produces=new Map([[13,e=>U(e)&&!this.parameters.drawAsLabel],[14,e=>U(e)&&this.parameters.drawAsLabel],[12,()=>this.parameters.occlusionTest],[18,e=>this.parameters.draped&&U(e)]]),this._visible=!0,this._configuration=new re(t)}getConfiguration(e,t){const i=this.parameters.draped;return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVerticalOffset=!!this.parameters.verticalOffset,this._configuration.hasScreenSizePerspective=!!this.parameters.screenSizePerspective,this._configuration.screenCenterOffsetUnitsEnabled="screen"===this.parameters.centerOffsetUnits,this._configuration.hasPolygonOffset=this.parameters.polygonOffset,this._configuration.draped=i,this._configuration.occlusionTestEnabled=this.parameters.occlusionTest,this._configuration.pixelSnappingEnabled=this.parameters.pixelSnappingEnabled,this._configuration.signedDistanceFieldEnabled=this.parameters.textureIsSignedDistanceField,this._configuration.sampleSignedDistanceFieldTexelCenter=this.parameters.sampleSignedDistanceFieldTexelCenter,this._configuration.hasRotation=this.parameters.hasRotation,this._configuration.hasVVSize=!!this.parameters.vvSize,this._configuration.hasVVColor=!!this.parameters.vvColor,this._configuration.occlusionPass=12===t.slot,this._configuration.occludedFragmentFade=!i&&this.parameters.occludedFragmentFade,this._configuration.horizonCullingEnabled=this.parameters.horizonCullingEnabled,this._configuration.isFocused=this.parameters.isFocused,this._configuration.depthTestEnabled=this.parameters.depthEnabled||12===t.slot,E(e)&&(this._configuration.debugDrawLabelBorder=!!T.LABELS_SHOW_BORDER),this._configuration.oitPass=t.oitPass,this._configuration.terrainDepthTest=t.terrainDepthTest,this._configuration.cullAboveTerrain=t.cullAboveTerrain,this._configuration}intersect(e,t,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:v},point:x,camera:S}=s,{parameters:y}=this;if(!l||!c||v&&y.isLabel||!e.visible||!x||!S)return;const z=e.attributes.get("featureAttribute"),P=null==z?null:_(z.data,je),{scaleX:j,scaleY:M}=Te(P,y,S.pixelRatio);i(Se,t),e.attributes.has("featureAttribute")&&ue(Se);const F=e.attributes.get("position"),D=e.attributes.get("size"),R=e.attributes.get("normal"),V=e.attributes.get("rotation"),A=e.attributes.get("centerOffsetAndDistance");H(F.size>=3);const C=$(y),w="screen"===this.parameters.centerOffsetUnits;for(let i=0;i<F.data.length/F.size;i++){const e=i*F.size;u(he,F.data[e],F.data[e+1],F.data[e+2]),f(he,he,t),f(he,he,S.viewMatrix);const a=i*A.size;if(u(_e,A.data[a],A.data[a+1],A.data[a+2]),!w&&(he[0]+=_e[0],he[1]+=_e[1],0!==_e[2])){const e=_e[2];p(_e,he),h(he,he,d(_e,_e,e))}const n=i*R.size;if(u(de,R.data[n],R.data[n+1],R.data[n+2]),ce(de,Se,S,Me),Ue(this.parameters,he,Me,S,pe),S.applyProjection(he,me),me[0]>-1){w&&(_e[0]||_e[1])&&(me[0]+=_e[0]*S.pixelRatio,0!==_e[1]&&(me[1]+=pe.alignmentEvaluator.apply(_e[1])*S.pixelRatio),S.unapplyProjection(me,he)),me[0]+=this.parameters.screenOffset[0]*S.pixelRatio,me[1]+=this.parameters.screenOffset[1]*S.pixelRatio,me[0]=Math.floor(me[0]),me[1]=Math.floor(me[1]);const e=i*D.size;Re[0]=D.data[e],Re[1]=D.data[e+1],pe.evaluator.applyVec2(Re,Re);const t=Fe*S.pixelRatio;let a=0;if(y.textureIsSignedDistanceField){a=Math.min(y.outlineSize,.5*Re[0])*S.pixelRatio/2}Re[0]*=j,Re[1]*=M;const n=i*V.size,l=y.rotation+V.data[n];if(fe(x,me[0],me[1],Re,t,a,l,y,C)){const e=s.ray;if(f(be,he,r(Oe,S.viewMatrix)),me[0]=x[0],me[1]=x[1],S.unprojectFromRenderScreen(me,he)){const t=O();m(t,e.direction);const i=1/g(t);d(t,t,i);o(b(e.origin,he)*i,t,-1,be)}}}}}intersectDraped(e,t,i,s,r){const a=e.attributes.get("position"),n=e.attributes.get("size"),o=e.attributes.get("rotation"),l=this.parameters,c=$(l),u=e.attributes.get("featureAttribute"),f=null==u?null:_(u.data,je),{scaleX:p,scaleY:h}=Te(f,l,e.screenToWorldRatio),d=De*e.screenToWorldRatio;for(let m=0;m<a.data.length/a.size;m++){const t=m*a.size,u=a.data[t],f=a.data[t+1],g=m*n.size;Re[0]=n.data[g],Re[1]=n.data[g+1];let b=0;if(l.textureIsSignedDistanceField){b=Math.min(l.outlineSize,.5*Re[0])*e.screenToWorldRatio/2}Re[0]*=p,Re[1]*=h;const v=m*o.size,x=l.rotation+o.data[v];fe(i,u,f,Re,d,b,x,l,c)&&s(r.distance,r.normal,-1)}}createBufferWriter(){return new we}applyShaderOffsetsView(e,t,i,s,r,a,n){const o=ce(t,i,r,Me);return this._applyVerticalGroundOffsetView(e,o,r,n),Ue(this.parameters,n,o,r,a),this._applyPolygonOffsetView(n,o,s[3],r,n),this._applyCenterOffsetView(n,s,n),n}applyShaderOffsetsNDC(e,t,i,s,r){return this._applyCenterOffsetNDC(e,t,i,s),null!=r&&m(r,s),this._applyPolygonOffsetNDC(s,t,i,s),s}_applyPolygonOffsetView(t,i,s,r,a){const n=r.aboveGround?1:-1;let o=Math.sign(s);0===o&&(o=n);const l=n*o;if(this.parameters.shaderPolygonOffset<=0)return m(a,t);const c=e(Math.abs(i.cosAngle),.01,1),u=1-Math.sqrt(1-c*c)/c/r.viewport[2];return d(a,t,l>0?u:1/u),a}_applyVerticalGroundOffsetView(e,t,i,s){const r=g(e),a=i.aboveGround?1:-1,n=i.computeRenderPixelSizeAtDist(r)*L,o=d(he,t.normal,a*n);return v(s,e,o),s}_applyCenterOffsetView(e,t,i){const s="screen"!==this.parameters.centerOffsetUnits;return i!==e&&m(i,e),s&&(i[0]+=t[0],i[1]+=t[1],t[2]&&(p(de,i),x(i,i,d(de,de,t[2])))),i}_applyCenterOffsetNDC(e,t,i,s){const r="screen"!==this.parameters.centerOffsetUnits;return s!==e&&m(s,e),r||(s[0]+=t[0]/i.fullWidth*2,s[1]+=t[1]/i.fullHeight*2),s}_applyPolygonOffsetNDC(e,t,i,s){const r=this.parameters.shaderPolygonOffset;if(e!==s&&m(s,e),r){const e=i.aboveGround?1:-1,a=e*Math.sign(t[3]);s[2]-=(a||e)*r}return s}set visible(e){this._visible=e}get visible(){const{color:e,outlineSize:t,outlineColor:i}=this.parameters,s=e[3]>=ae||t>=ae&&i[3]>=ae;return this._visible&&s}createGLMaterial(e){return new oe(e)}calculateRelativeScreenBounds(e,t,i=F()){return le(this.parameters,e,t,i),i[2]=i[0]+e[0],i[3]=i[1]+e[1],i}}class oe extends q{constructor(e){super({...e,...e.material.parameters})}beginSlot(e){return this.updateTexture(this._material.parameters.textureId),this._material.setParameters(this.textureBindParameters),this.getTechnique(se,e)}}function le(e,t,i,s){s[0]=e.anchorPosition[0]*-t[0]+e.screenOffset[0]*i,s[1]=e.anchorPosition[1]*-t[1]+e.screenOffset[1]*i}function ce(e,t,s,r){return M(t)&&(t=i(ye,t)),S(r.normal,e,t),f(r.normal,r.normal,s.viewInverseTransposeMatrix),r.cosAngle=y(ge,Ae),r}function ue(e){const t=e[0],i=e[1],s=e[2],r=e[3],a=e[4],n=e[5],o=e[6],l=e[7],c=e[8],u=1/Math.sqrt(t*t+i*i+s*s),f=1/Math.sqrt(r*r+a*a+n*n),p=1/Math.sqrt(o*o+l*l+c*c);return e[0]=t*u,e[1]=i*u,e[2]=s*u,e[3]=r*f,e[4]=a*f,e[5]=n*f,e[6]=o*p,e[7]=l*p,e[8]=c*p,e}function fe(e,i,s,r,a,l,c,u,f){let p=i-a-r[0]*f[0],h=p+r[0]+2*a,d=s-a-r[1]*f[1],m=d+r[1]+2*a;const g=u.distanceFieldBoundingBox;return u.textureIsSignedDistanceField&&null!=g&&(p+=r[0]*g[0],d+=r[1]*g[1],h-=r[0]*(1-g[2]),m-=r[1]*(1-g[3]),p-=l,h+=l,d-=l,m+=l),n(xe,i,s),o(ve,e,xe,t(c)),ve[0]>p&&ve[0]<h&&ve[1]>d&&ve[1]<m}const pe=new W,he=O(),de=O(),me=P(),ge=O(),be=O(),ve=c(),xe=c(),Se=s(),ye=s(),Oe=a(),ze=P(),_e=O(),Pe=O(),je=P(),Me={normal:ge,cosAngle:0},Fe=1,De=2,Re=l(0,0),Ve=6,Ae=z(0,0,1);class Ce extends I{constructor(){super(...arguments),this.renderOccluded=1,this.isDecoration=!1,this.color=j(1,1,1,1),this.polygonOffset=!1,this.anchorPosition=l(.5,.5),this.screenOffset=[0,0],this.shaderPolygonOffset=1e-5,this.textureIsSignedDistanceField=!1,this.sampleSignedDistanceFieldTexelCenter=!1,this.outlineColor=j(1,1,1,1),this.outlineSize=0,this.distanceFieldBoundingBox=P(),this.rotation=0,this.hasRotation=!1,this.vvSizeEnabled=!1,this.vvSize=null,this.vvColor=null,this.vvOpacity=null,this.vvSymbolAnchor=null,this.vvSymbolRotationMatrix=null,this.hasSlicePlane=!1,this.pixelSnappingEnabled=!0,this.occlusionTest=!0,this.occludedFragmentFade=!1,this.horizonCullingEnabled=!1,this.centerOffsetUnits="world",this.drawAsLabel=!1,this.depthEnabled=!0,this.isFocused=!0,this.focusStyle="bright",this.draped=!1,this.isLabel=!1}get hasVVSize(){return!!this.vvSize}get hasVVColor(){return!!this.vvColor}get hasVVOpacity(){return!!this.vvOpacity}}class we{constructor(){this.layout=B()?te:ie}elementCount(e){return e.get("position").indices.length*Ve}write(e,t,i,s,r,a){const{position:n,normal:o,uvi:l,color:c,size:u,rotation:f,centerOffsetAndDistance:p,featureAttribute:h}=r;N(i.get("position"),e,n,a,Ve),X(i.get("normal"),t,o,a,Ve);const d=i.get("uvi")?.data;let m=0,g=0,b=-1-ee,v=-1-ee;d&&d.length>=4&&(m=d[0],g=d[1],b=-1-d[2],v=-1-d[3]);let x=i.get("position").indices.length,S=a;for(let z=0;z<x;++z)l.set(S,0,m),l.set(S,1,g),S++,l.set(S,0,b),l.set(S,1,g),S++,l.set(S,0,b),l.set(S,1,v),S++,l.set(S,0,b),l.set(S,1,v),S++,l.set(S,0,m),l.set(S,1,v),S++,l.set(S,0,m),l.set(S,1,g),S++;Y(i.get("color"),4,c,a,Ve);const{data:y,indices:O}=i.get("size");x=O.length,S=a;for(let z=0;z<x;++z){const e=y[2*O[z]],t=y[2*O[z]+1];for(let i=0;i<Ve;++i)u.set(S,0,e),u.set(S,1,t),S++}if(k(i.get("rotation"),f,a,Ve),i.get("centerOffsetAndDistance")?J(i.get("centerOffsetAndDistance"),p,a,Ve):K(p,a,x*Ve),i.get("featureAttribute")?J(i.get("featureAttribute"),h,a,Ve):K(h,a,x*Ve),null!=s){const e=i.get("position")?.indices;if(e){const t=e.length,i=r.getField("olidColor",D);Q(s,i,t,a,Ve)}}return{numVerticesPerItem:Ve,numItems:x}}intersect(e,t,i,s,a,n,o){const{options:{selectionMode:l,hud:c,excludeLabels:x},point:S,camera:y}=s;if(!l||!c||x&&t.isLabel||!S)return;const z=this.layout.createView(e),_=z.getField("position",R),P=z.getField("normal",R),j=z.getField("rotation",V),M=z.getField("size",A),F=z.getField("featureAttribute",C),D=z.getField("centerOffsetAndDistance",C),w="screen"===t.centerOffsetUnits,T=$(t);if(null==_||null==P||null==j||null==M||null==D||null==y)return;const U=null==F?null:F.getVec(0,je),{scaleX:E,scaleY:L}=Te(U,t,y.pixelRatio),B=_.count/Ve;for(let R=0;R<B;R++){const e=R*Ve;if(_.getVec(e,he),null!=i&&v(he,he,i),f(he,he,y.viewMatrix),D.getVec(e,ze),u(_e,ze[0],ze[1],ze[2]),!w&&(he[0]+=_e[0],he[1]+=_e[1],0!==_e[2])){const e=_e[2];p(_e,he),h(he,he,d(_e,_e,e))}if(P.getVec(e,de),ce(de,Se,y,Me),Ue(t,he,Me,y,pe),y.applyProjection(he,me),me[0]>-1){w&&(_e[0]||_e[1])&&(me[0]+=_e[0]*y.pixelRatio,0!==_e[1]&&(me[1]+=pe.alignmentEvaluator.apply(_e[1])*y.pixelRatio),y.unapplyProjection(me,he)),me[0]+=t.screenOffset[0]*y.pixelRatio,me[1]+=t.screenOffset[1]*y.pixelRatio,me[0]=Math.floor(me[0]),me[1]=Math.floor(me[1]),M.getVec(e,Re),pe.evaluator.applyVec2(Re,Re);const i=Fe*y.pixelRatio;let a=0;if(t.textureIsSignedDistanceField){a=Math.min(t.outlineSize,.5*Re[0])*y.pixelRatio/2}Re[0]*=E,Re[1]*=L;const n=j.get(e),l=t.rotation+n;if(fe(S,me[0],me[1],Re,i,a,l,t,T)){const e=s.ray;if(f(be,he,r(Oe,y.viewMatrix)),me[0]=S[0],me[1]=S[1],y.unprojectFromRenderScreen(me,he)){const t=O();m(t,e.direction);const i=1/g(t);d(t,t,i);o(b(e.origin,he)*i,t,R,be)}}}}}}function Te(e,t,i){return null==e||null==t.vvSize?{scaleX:i,scaleY:i}:(w(Pe,t,e),{scaleX:Pe[0]*i,scaleY:Pe[1]*i})}function Ue(e,t,i,s,r){if(!e.verticalOffset?.screenLength){const s=g(t);return r.update(i.cosAngle,s,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),t}const a=g(t),n=e.screenSizePerspectiveAlignment??e.screenSizePerspective,o=Z(s,a,e.verticalOffset,i.cosAngle,n,e.screenSizePerspectiveMinPixelReferenceSize);return r.update(i.cosAngle,a,e.screenSizePerspective,e.screenSizePerspectiveMinPixelReferenceSize,e.screenSizePerspectiveAlignment,null),d(i.normal,i.normal,o),v(t,t,i.normal)}export{ne as HUDMaterial,Ce as Parameters};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.34/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../../core/Logger.js";import{clamp as r}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as t}from"../../../../core/screenUtils.js";import{copy as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i as s,d as i,e as a,g as n,f as c,c as m,l,j as f}from"../../../../chunks/vec32.js";import{create as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as p}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{distance2 as h,fromPoints as g,create as d,closestLineSegmentPoint as j}from"../../../../geometry/support/lineSegment.js";import{fromPoints as b,create as x,signedDistance as L,getNormal as v}from"../../../../geometry/support/plane.js";import{isColorEmissionHighlightOrOID as y}from"../core/shaderLibrary/ShaderOutput.js";import S from"../lib/GLMaterial.js";import{Material as M,MaterialParameters as _}from"../lib/Material.js";import{isTranslationMatrix as w}from"../lib/Util.js";import{DefaultBufferWriter as C}from"./DefaultBufferWriter.js";import{PositionColorLayout as T,PositionLayout as A}from"./DefaultLayouts.js";import{NativeLineTechnique as V}from"../shaders/NativeLineTechnique.js";import{NativeLineTechniqueConfiguration as N}from"../shaders/NativeLineTechniqueConfiguration.js";import{alphaCutoff as R}from"../../../../webscene/support/AlphaCutoff.js";class U extends M{constructor(e){super(e,P),this._configuration=new N,this.produces=new Map([[2,e=>y(e)]])}getConfiguration(e,r){return super.getConfiguration(e,r,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVertexColors=this.parameters.hasVertexColors,this._configuration.transparent=this.parameters.color[3]<1||this.parameters.width<1,this._configuration.hasOccludees=r.hasOccludees,this._configuration}get visible(){return this.parameters.color[3]>=R}intersect(r,t,u,p,d,x){const y=u.camera;if(!u.options.selectionMode||!r.visible||!y)return;if(!w(t))return void e.getLogger("esri.views.3d.webgl-engine.materials.NativeLineMaterial").error("intersection assumes a translation-only matrix");const S=r.attributes.get("position").data,M=H;o(M,u.point);const _=2;s(I[0],M[0]-_,M[1]+_,0),s(I[1],M[0]+_,M[1]+_,0),s(I[2],M[0]+_,M[1]-_,0),s(I[3],M[0]-_,M[1]-_,0);for(let e=0;e<4;e++)if(!y.unprojectFromRenderScreen(I[e],J[e]))return;b(y.eye,J[0],J[1],K),b(y.eye,J[1],J[2],Q),b(y.eye,J[2],J[3],Y),b(y.eye,J[3],J[0],Z);let C=Number.MAX_VALUE,T=0;for(let e=0;e<S.length-5;e+=3){if(q[0]=S[e]+t[12],q[1]=S[e+1]+t[13],q[2]=S[e+2]+t[14],B[0]=S[e+3]+t[12],B[1]=S[e+4]+t[13],B[2]=S[e+5]+t[14],L(K,q)<0&&L(K,B)<0||L(Q,q)<0&&L(Q,B)<0||L(Y,q)<0&&L(Y,B)<0||L(Z,q)<0&&L(Z,B)<0)continue;if(y.projectToRenderScreen(q,W),y.projectToRenderScreen(B,X),W[2]<0&&X[2]>0){i(D,q,B);const e=y.frustum,r=-L(e[4],q)/a(D,v(e[4]));n(D,D,r),c(q,q,D),y.projectToRenderScreen(q,W)}else if(W[2]>0&&X[2]<0){i(D,B,q);const e=y.frustum,r=-L(e[4],B)/a(D,v(e[4]));n(D,D,r),c(B,B,D),y.projectToRenderScreen(B,X)}else if(W[2]<0&&X[2]<0)continue;W[2]=0,X[2]=0;const r=h(g(W,X,z),M);r<C&&(C=r,m(G,q),m(k,B),T=e/3)}const A=u.rayBegin,V=u.rayEnd;if(C<_*_){let e=Number.MAX_VALUE;if(j(g(G,k,z),g(A,V,F),O)){i(O,O,A);const r=l(O);n(O,O,1/r),e=r/f(A,V)}x(e,O,T)}}intersectDraped(e,t,o,s,i){if(!t.options.selectionMode)return;const a=e.attributes.get("position").data,n=e.attributes.get("size"),c=n?n.data[0]:0,m=o[0],l=o[1],f=((c+1)/2+4)*e.screenToWorldRatio;let u=Number.MAX_VALUE,p=0;for(let h=0;h<a.length-5;h+=3){const e=a[h],t=a[h+1],o=m-e,s=l-t,i=a[h+3]-e,n=a[h+4]-t,c=r((i*o+n*s)/(i*i+n*n),0,1),f=i*c-o,g=n*c-s,d=f*f+g*g;d<u&&(u=d,p=h/3)}u<f*f&&s(i.distance,i.normal,p)}createGLMaterial(e){return new E(e)}createBufferWriter(){const e=this.parameters.hasVertexColors?T:A;return new C(e)}}class E extends S{beginSlot(e){return this.getTechnique(V,e)}}class P extends _{constructor(){super(...arguments),this.color=p,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.width=1}}const q=u(),B=u(),D=u(),O=u(),W=t(),X=t(),G=u(),k=u(),z=d(),F=d(),H=u(),I=[t(),t(),t(),t()],J=[u(),u(),u(),u()],K=x(),Q=x(),Y=x(),Z=x();export{U as NativeLineMaterial,P as Parameters};
5
+ import e from"../../../../core/Logger.js";import{clamp as t}from"../../../../core/mathUtils.js";import{createRenderScreenPointArray3 as r}from"../../../../core/screenUtils.js";import{copy as o}from"../../../../core/libs/gl-matrix-2/math/vec2.js";import{i,d as s,e as n,g as a,f as c,c as l,l as m,j as u}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as p}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{distance2 as h,fromPoints as g,create as d,closestLineSegmentPoint as j}from"../../../../geometry/support/lineSegment.js";import{fromPoints as b,create as x,signedDistance as L,getNormal as v}from"../../../../geometry/support/plane.js";import{isColorEmissionHighlightOrOID as y}from"../core/shaderLibrary/ShaderOutput.js";import S from"../lib/GLMaterial.js";import{Material as M,MaterialParameters as _}from"../lib/Material.js";import{isTranslationMatrix as w}from"../lib/Util.js";import{DefaultBufferWriter as C}from"./DefaultBufferWriter.js";import{PositionColorLayout as T,PositionLayout as A}from"./DefaultLayouts.js";import{NativeLineTechnique as V}from"../shaders/NativeLineTechnique.js";import{NativeLineTechniqueConfiguration as N}from"../shaders/NativeLineTechniqueConfiguration.js";import{alphaCutoff as R}from"../../../../webscene/support/AlphaCutoff.js";class U extends M{constructor(e){super(e,P),this._configuration=new N,this.produces=new Map([[2,e=>y(e)]])}getConfiguration(e,t){return super.getConfiguration(e,t,this._configuration),this._configuration.hasSlicePlane=this.parameters.hasSlicePlane,this._configuration.hasVertexColors=this.parameters.hasVertexColors,this._configuration.transparent=this.parameters.color[3]<1||this.parameters.width<1,this._configuration.hasOccludees=t.hasOccludees,this._configuration}get visible(){return this.parameters.color[3]>=R}intersect(t,r,f,p,d,x){const{options:y,camera:S,rayBegin:M,rayEnd:_}=f;if(!y.selectionMode||!t.visible||!S)return;if(!w(r))return void e.getLogger("esri.views.3d.webgl-engine.materials.NativeLineMaterial").error("intersection assumes a translation-only matrix");const C=t.attributes.get("position").data,T=H;o(T,f.point);const A=2;i(I[0],T[0]-A,T[1]+A,0),i(I[1],T[0]+A,T[1]+A,0),i(I[2],T[0]+A,T[1]-A,0),i(I[3],T[0]-A,T[1]-A,0);for(let e=0;e<4;e++)if(!S.unprojectFromRenderScreen(I[e],J[e]))return;b(S.eye,J[0],J[1],K),b(S.eye,J[1],J[2],Q),b(S.eye,J[2],J[3],Y),b(S.eye,J[3],J[0],Z);let V=Number.MAX_VALUE,N=0;for(let e=0;e<C.length-5;e+=3){if(q[0]=C[e]+r[12],q[1]=C[e+1]+r[13],q[2]=C[e+2]+r[14],B[0]=C[e+3]+r[12],B[1]=C[e+4]+r[13],B[2]=C[e+5]+r[14],L(K,q)<0&&L(K,B)<0||L(Q,q)<0&&L(Q,B)<0||L(Y,q)<0&&L(Y,B)<0||L(Z,q)<0&&L(Z,B)<0)continue;const t=S.projectToRenderScreen(q,W),o=S.projectToRenderScreen(B,X);if(null==t||null==o)continue;if(t[2]<0&&o[2]>0){s(D,q,B);const e=S.frustum,r=-L(e[4],q)/n(D,v(e[4]));if(a(D,D,r),c(q,q,D),!S.projectToRenderScreen(q,t))continue}else if(t[2]>0&&o[2]<0){s(D,B,q);const e=S.frustum,t=-L(e[4],B)/n(D,v(e[4]));if(a(D,D,t),c(B,B,D),!S.projectToRenderScreen(B,o))continue}else if(t[2]<0&&o[2]<0)continue;t[2]=0,o[2]=0;const i=h(g(t,o,z),T);i<V&&(V=i,l(G,q),l(k,B),N=e/3)}if(V<A*A){let e=Number.MAX_VALUE;if(j(g(G,k,z),g(M,_,F),O)){s(O,O,M);const t=m(O);a(O,O,1/t),e=t/u(M,_)}x(e,O,N)}}intersectDraped(e,r,o,i,s){if(!r.options.selectionMode)return;const n=e.attributes.get("position").data,a=e.attributes.get("size"),c=a?a.data[0]:0,l=o[0],m=o[1],u=((c+1)/2+4)*e.screenToWorldRatio;let f=Number.MAX_VALUE,p=0;for(let h=0;h<n.length-5;h+=3){const e=n[h],r=n[h+1],o=l-e,i=m-r,s=n[h+3]-e,a=n[h+4]-r,c=t((s*o+a*i)/(s*s+a*a),0,1),u=s*c-o,g=a*c-i,d=u*u+g*g;d<f&&(f=d,p=h/3)}f<u*u&&i(s.distance,s.normal,p)}createGLMaterial(e){return new E(e)}createBufferWriter(){const e=this.parameters.hasVertexColors?T:A;return new C(e)}}class E extends S{beginSlot(e){return this.getTechnique(V,e)}}class P extends _{constructor(){super(...arguments),this.color=p,this.hasVertexColors=!1,this.hasSlicePlane=!1,this.width=1}}const q=f(),B=f(),D=f(),O=f(),W=r(),X=r(),G=f(),k=f(),z=d(),F=d(),H=f(),I=[r(),r(),r(),r()],J=[f(),f(),f(),f()],K=x(),Q=x(),Y=x(),Z=x();export{U as NativeLineMaterial,P as Parameters};