@arcgis/core 4.26.0-next.20230112 → 4.26.0-next.20230113
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.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{4abb5627d06d329d2c0d.js → 028f9a133104e78e60d2.js} +1 -1
- package/assets/esri/core/workers/chunks/033e6ae5da6afebd993c.js +1 -0
- package/assets/esri/core/workers/chunks/{c9cc3d601f4a08162b69.js → 05ab092987251d4a1242.js} +1 -1
- package/assets/esri/core/workers/chunks/{6e6c8364baaeca09b501.js → 27ba1889fe9f1812389a.js} +21 -21
- package/assets/esri/core/workers/chunks/{e11e581b626a56adf6c6.js → 3b6748f414437cc6cfde.js} +1 -1
- package/assets/esri/core/workers/chunks/64f137358100a1c818f0.js +1 -0
- package/assets/esri/themes/base/widgets/_Editor.scss +1 -11
- package/assets/esri/themes/base/widgets/_ItemList.scss +0 -13
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/ComponentShader.glsl.js +1 -1
- package/chunks/Path.glsl.js +1 -1
- package/chunks/Terrain.glsl.js +1 -1
- package/interfaces.d.ts +1398 -1313
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/package.json +1 -1
- package/rest/imageService.js +1 -1
- package/rest/support/BaseImageMeasureResult.d.ts +4 -0
- package/rest/support/ImageAreaParameters.d.ts +4 -0
- package/rest/support/{ImageMeasureAreaAndPerimeterParameters.js → ImageAreaParameters.js} +1 -1
- package/rest/support/ImageAreaResult.d.ts +4 -0
- package/rest/support/{ImageMeasureAreaAndPerimeterResult.js → ImageAreaResult.js} +1 -1
- package/rest/support/ImageDistanceParameters.d.ts +4 -0
- package/rest/support/{ImageMeasureDistanceAndAngleParameters.js → ImageDistanceParameters.js} +1 -1
- package/rest/support/ImageDistanceResult.d.ts +4 -0
- package/rest/support/ImageDistanceResult.js +5 -0
- package/rest/support/ImageHeightParameters.d.ts +4 -0
- package/rest/support/{ImageMeasureHeightParameters.js → ImageHeightParameters.js} +1 -1
- package/rest/support/ImageHeightResult.d.ts +4 -0
- package/rest/support/{ImageMeasureHeightResult.js → ImageHeightResult.js} +1 -1
- package/rest/support/ImagePointParameters.d.ts +4 -0
- package/rest/support/{ImageMeasurePointParameters.js → ImagePointParameters.js} +1 -1
- package/rest/support/ImagePointResult.d.ts +4 -0
- package/rest/support/{ImageMeasurePointResult.js → ImagePointResult.js} +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/terrain/Overlay.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ForwardLinearDepth.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/output/OutputDepth.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/AnimationTimeStep.js +5 -0
- package/views/3d/webgl-engine/lib/AnimationTimer.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterial.js +1 -1
- package/views/3d/webgl-engine/lib/Material.js +1 -1
- package/views/3d/webgl-engine/lib/RenderFeature.js +5 -0
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/FeatureTemplates/ItemList.js +1 -1
- package/widgets/FeatureTemplates/TemplateItem.js +1 -1
- package/widgets/FeatureTemplates/TemplateItemGroup.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/support/decorators/accessibleHandler.js +1 -1
- package/assets/esri/core/workers/chunks/080a4be417be4943f6a0.js +0 -1
- package/assets/esri/core/workers/chunks/bf20831b3efe169d4cb8.js +0 -1
- package/rest/support/ImageMeasureDistanceAndAngleResult.js +0 -5
- package/views/3d/support/animationUtils.js +0 -5
- package/views/3d/webgl-engine/lib/RenderStateFeature.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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{throwIfAborted as g,isAbortError as m,isAborted as T,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as y,syncAndInitial as v,sync as w,initial as E}from"../../../core/reactiveUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as L}from"../../../core/accessorSupport/decorators/subclass.js";import{m as D}from"../../../chunks/mat4.js";import{c as C}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as b}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as x}from"../../../core/support/WatchUpdatingTracking.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as M,projectPointToVector as j}from"../../../geometry/projection.js";import A from"../../../geometry/SpatialReference.js";import{create as I,equals as O,intersection as V,empty as k,expand as B,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as F,copy as G}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as W}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as H}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as z}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as X}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as Y}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as $}from"../support/cameraUtils.js";import K from"../support/debugFlags.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{ClientType as Z}from"../support/index.js";import{updatingProgress as ee}from"../support/updatingProperties.js";import{ElevationBounds as te}from"./ElevationBounds.js";import{ElevationData as ie,sampleElevation as re}from"./ElevationData.js";import{create as se}from"./ExtentHelper.js";import{LODSnapping as ae,TextureUpdate as ne}from"./interfaces.js";import{LayerClass as le,LayerClasses as oe}from"./LayerClass.js";import{OverlayManager as he}from"./OverlayManager.js";import{PlanarPatch as de}from"./PlanarPatch.js";import{RenderOrder as pe}from"./RenderOrder.js";import{SphericalPatch as ue}from"./SphericalPatch.js";import{SplitLimits as ce}from"./SplitLimits.js";import{MAX_ROOT_TILES as _e,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ge,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as me,MAX_MEMORY_LOD_BIAS as Te,ELEVATION_NODATA_VALUE as fe}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as ve}from"./TerrainRenderer.js";import we from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Ee,internalAssert as Se,oppositeEdge as Le,isSurfaceLayerView as De,isGroupLayerView as Ce,isMapTileLayerView as Pe,isBlendableLayerView as Ue,isElevationLayerView as be,isVectorTileLayerView as xe,useFetchTileForLayer as Re,isImageryTileLayerView as Me,isTileLayerView as je,releaseTileData as Ae,neighborEdgeIndices as Ie,ENABLE_TERRAIN_INTERNAL_CHECKS as Oe,ENABLE_WATERPROOFNESS_TESTS as Ve,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Be}from"./terrainUtils.js";import{Tile as Ne}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as qe,IteratorPostorder as We,compareTilesByLij as He,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Qe}from"./tileUtils.js";import{TilingSchemeLogic as Ye}from"./TilingSchemeLogic.js";import{UpsampleInfo as $e}from"./UpsampleInfo.js";import{isCompositeBlendMode as Ke,blendModeFromString as Je}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as Ze}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as et}from"../../support/RenderState.js";import{ImmediateTask as tt,TaskPriority as it,noBudget as rt}from"../../support/Scheduler.js";let st=class extends(a.EventedMixin(i)){constructor(e){super(e),this._iteratorPool=new c(qe,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new We,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new we,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new ce,this._frustum=F(),this._viewProjectionMatrix=C(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new x,this._frameTask=tt,this._allTiles=new _,this._upsampleInfoPool=new c($e),this._rootTilesExtent=I(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=A.WebMercator,this.visibleElevationBounds=new te(1/0,-1/0),this.rootTileElevationBounds=new te(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this.oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this._shading=!0,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(de):new c(ue);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new H(e.newCache("elevation-query")),this._set("overlayManager",new he({surface:this})),this._handles.add([y((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),y((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),y((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency()))],"overlayManager"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:R(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([y((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ne.UNFADED:ne.IMMEDIATE)}),v),y((()=>this.hasCompositeBlendMode),(()=>{this._updateTileTextures(this._evaluateTransparency()?ne.UNFADED:ne.IMMEDIATE)}),v),y((()=>this.renderingDisabled),(()=>this.view?._stage?.renderer.setParameters({terrainRenderingEnabled:!this.renderingDisabled})),w),y((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),v),y((()=>this.snapLevel),(()=>this._viewChanged=!0),w),y((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),y((()=>K.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),E)]),this._extentHelper=se(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),i=new Ye({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Z.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Z.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(it.TERRAIN_SURFACE,this),this._handles.add([y((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),E),y((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),w),y((()=>this.extent),(()=>this._updateRootTiles()),E),this.view.on("resize",(()=>this._viewChangeUpdate())),y((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),v),y((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),E),y((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),w)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._handles.add([y((()=>this.view?.map.ground.shading),(()=>{this._updateShadingIfChanged()}))]),this._updateShading(),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache);const e=this.tilingSchemeLogic.layers;this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),e.destroy(),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Ne.prune(),this._treeDebugger=d(this._treeDebugger),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),Y(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===ae.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(i&&t){const r=e.state.contentCamera;let s=$(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a;return Math.round(n)}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ae.ON:ae.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=I(),r=J(t,i,e)?i:null,s=this._get("extent");return O(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,I()),t=this._get("extent");return O(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||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}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this._rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}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}set velvetOverground(e){this._renderer.velvetOverground=e,this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.transparency===ve.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this._rootTiles;if(p(s)||!s.length)return null;if(0===s[0].layerInfo[le.ELEVATION].length)return null;const a=ht;if(a[0]=e,a[1]=t,a[2]=i,!M(a,r,a,this._spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return gt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[le.ELEVATION].length:0;if(!p(r)&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,gt(r,e[t+0],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!j(e,ht,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(u(t))for(const i of t)if(i?.containsPoint(ht)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;ht[0]>t[2]&&(i+=1),ht[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t,i,r,s){if(ht[0]=e,ht[1]=t,ht[2]=i,ht[3]=r,!M(ht,s,ht,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&N(e.extent,ht))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this._rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,ht,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;ht[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,ht)){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(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?ve.Empty:ve.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?ve.Opaque:ve.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;Ee(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??A.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return pt[0]=e,pt[1]=t,pt[2]=i,s.init(pt,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=dt;let s=t.rootTilesInExtent(e,i,5*_e);if(u(this._rootTiles)){if(s.length>_e)return void l.getLogger(this.declaredClass).warn(ge);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,nt);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>nt(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>_e&&(l.getLogger(this.declaredClass).warn(me),s=t.rootTilesInExtent(e,i,_e)),this._setRootTiles(s.map((e=>this._newRootTile(e))));O(i,this._rootTilesExtent)||(this._rootTilesExtent=I(i)),this._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.isLoaded&&e.intersectsClippingArea));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(He);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Ge.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Ge.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),u(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)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(p(e))return;const t=ze(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(Ge.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBounds[0],r),s=Math.max(e.elevationBounds[1],s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._batchUpdatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new te(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;u(i)&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new te(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?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=F()),G(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,G(this._frustum,e.frustum),D(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(lt(e)?this._loadChildren(e):ot(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ge.TEXTURE_FADING)?Ge.TEXTURE_FADING:!!e.resetPendingUpdate(Ge.TEXTURE_NOFADING)&&Ge.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){const e=ct.extent;k(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),ct.spatialReference=this.spatialReference,this.emit("elevation-change",ct)}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._batchUpdatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed?this.requestUpdate():this.getUsedMemory(),this.notifyChange("updatingProgressValue")}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();t.reset(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;for(;!t.done;){const e=t.next(),a=e.shouldSplit(r,s,i);if(a!==Ge.SPLIT){if(e.resetPendingUpdate(Ge.SPLIT)&&e.updateAgentSuspension(),a===Ge.VSPLITMERGE&&e.updateAgents(le.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ge.MERGE),e.resetPendingUpdate(Ge.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);const i=this._viewProjectionMatrix;for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(i);t.remove()}}else e.resetPendingUpdate(Ge.MERGE),e.isLeaf&&(e.setPendingUpdate(Ge.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(Ge.RENDERDATA)}t.remove(),this.requestUpdate(),(this.shortBatches||!this.oneBatchPerFrameTask)&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Xe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Se(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e))}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(He);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Se(r.isLoaded),Se(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData;for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Le(Ie[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Se(e.has(t)||He(r,t)<0),i(r,t),!0))),i(r,l.cornerPeerNeighbors[t]),i(r,l.cornerPeerNeighbors[(t+1)%4])}}e.clear(),this._updateTilesGeometries(t),Oe&&Ve&&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.resetPendingUpdate(Ge.MERGE)){if(!t)return s.setPendingUpdate(Ge.MERGE),e.done;for(;n.parent?.resetPendingUpdate(Ge.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else s.resetPendingUpdate(Ge.SPLIT)&&(this._splitTile(s),a=!0,e.madeProgress());return!e.done&&n===s&&s.resetPendingUpdate(Ge.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Ge.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this.shortBatches&&this._batchUpdatePendingTileGeometries(),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Ze.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*Te}_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(){u(this._rootTiles)&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(!e.children[0])return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){Ee(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ge.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){_t.spatialReference=this.spatialReference,_t.extent=e.extent,_t.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",_t)}_createTile(e,t,i,r){Ee(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Ge.SPLIT),s}get shortBatches(){return this.view.state.mode!==et.IDLE}_mergeTile(e){Ee(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(Ee(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){Ee(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){const t=e.children;if(t[0])for(let i=0;i<4;++i){const e=t[i];this._unloadChildren(e),this._unloadTile(e)}}_loadTile(e){e.load(),e.setPendingUpdate(Ge.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new ie(e.lij,e.extent,i);e.dataArrived(t,le.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=rt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),De(s)||Ce(s))if(this._basemapLayerViewHandles.has(s.uid)&&!Ce(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.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()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Pe(t)&&!X(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ue(e)||Ce(e))&&Ke(Je[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return be(e)?le.ELEVATION:le.MAP}_registerTiledLayerView(e){const t=[];if((Ue(e)||Ce(e))&&t.push(y((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ne.UNFADED)}))),Ce(e))return;const i=this._layerClassFromLayerView(e);t.push(y((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(y((()=>e.fullOpacity),(()=>this._updateTileTextures(ne.UNFADED)))),t.push(y((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)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||!De(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===le.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of oe){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()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===le.ELEVATION&&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(le.MAP),e===ne.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(le.MAP,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=Ze.UPDATE){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||xe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(r),m(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===le.ELEVATION?be(i)?this._requestElevationTileData(e,i,r):Promise.reject():Pe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(T(i))return;const s=this._layerIndexByUid[le.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",le.ELEVATION,e.lij.toString())},s=i=>{m(i)||(this._dataMissing(e,le.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:fe,signal:i.signal}).then((e=>{if(!T(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:fe},i.signal))).then((e=>{e?r(new z(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ae(s),T(i)||(this._dataMissing(e,le.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),T(i)?Ae(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(xe(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Me(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(je(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(T(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);W(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(le.MAP,t.uid);u(r)?e.dataArrived(r,le.MAP,i):(Ae(i),l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}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.isLeaf&&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}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this._rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this._rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return Ee(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}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(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e._rootTiles)&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){ut.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&ut.push(e)}));const t=ut.toArray();return Qe(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Ve)return;const e=this._rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.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.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)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.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shading(){return this._shading}_updateShadingIfChanged(){const e=this.view?.map?.ground?.shading;e!==this._shading&&this._updateShading()}_updateShading(){const e=this.view?.map?.ground?.shading;this._shading=e,this.renderer&&(this.renderer.shading=e,this.renderer.setNeedsRender()),this._updateAllTileGeometries()}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(u(this.spatialReference)&&this.spatialReference.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){ke(e)}enableWaterproofnessChecks(e){Be(e)}};e([S()],st.prototype,"_renderer",void 0),e([S()],st.prototype,"_hasPendingUpdates",void 0),e([S()],st.prototype,"_asyncWorkItems",void 0),e([S()],st.prototype,"_allTilesDirty",void 0),e([S()],st.prototype,"_allTilesSorted",void 0),e([S()],st.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],st.prototype,"_watchUpdatingTracking",void 0),e([S()],st.prototype,"_frameTask",void 0),e([S({readOnly:!0})],st.prototype,"snapLevel",null),e([S({readOnly:!0})],st.prototype,"lodSnapping",null),e([S({constructOnly:!0})],st.prototype,"view",void 0),e([S()],st.prototype,"_userClippingExtent",null),e([S()],st.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],st.prototype,"extent",null),e([S({readOnly:!0})],st.prototype,"groundExtent",null),e([S({readOnly:!0})],st.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],st.prototype,"updating",null),e([S({readOnly:!0})],st.prototype,"running",null),e([S(ee)],st.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],st.prototype,"updatingProgressValue",null),e([S()],st.prototype,"_maxNumUpdating",void 0),e([S()],st.prototype,"baseOpacity",null),e([S()],st.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],st.prototype,"overlayManager",void 0),e([S({readOnly:!0})],st.prototype,"viewingMode",null),e([S()],st.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],st.prototype,"ready",null),e([S({value:pe.FRONT_TO_BACK})],st.prototype,"renderOrder",null),e([S({readOnly:!0})],st.prototype,"rootTiles",null),e([S()],st.prototype,"_rootTiles",void 0),e([S({readOnly:!0})],st.prototype,"spatialReference",null),e([S({type:t})],st.prototype,"backgroundColor",null),e([S({value:!1})],st.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],st.prototype,"tilingScheme",void 0),e([S({readOnly:!0})],st.prototype,"tilingSchemeLocked",null),e([S({readOnly:!0})],st.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],st.prototype,"velvetOverground",null),e([S()],st.prototype,"wireframe",null),e([S({value:!1})],st.prototype,"suspended",null),e([S()],st.prototype,"textureFadeDuration",null),e([S()],st.prototype,"visibleElevationBounds",void 0),e([S()],st.prototype,"rootTileElevationBounds",void 0),e([S()],st.prototype,"_layerViewsDirty",void 0),e([S()],st.prototype,"renderPatchBorders",null),e([S()],st.prototype,"visualizeNormals",null),e([S()],st.prototype,"renderingDisabled",null),st=e([L("esri.views.3d.terrain.TerrainSurface")],st);const at=st;function nt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function lt(e){const t=e.children;if(!t[0])return!1;for(const i of t)if(i.shouldLoad)return!0;for(const i of t)if(lt(i))return!0;return!1}function ot(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const ht=b(),dt=I(),pt=[0,0,0],ut=new _,ct={spatialReference:null,extent:I(),context:"ground"},_t={spatialReference:null,extent:null,scale:0};function gt(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 re(t,i,s)}return null}export{at as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import i from"../../../core/Accessor.js";import{difference as r}from"../../../core/arrayUtils.js";import s from"../../../core/CollectionFlattener.js";import a from"../../../core/Evented.js";import n from"../../../core/Handles.js";import l from"../../../core/Logger.js";import{clamp as o}from"../../../core/mathUtils.js";import{releaseMaybe as h,destroyMaybe as d,isNone as p,isSome as u}from"../../../core/maybe.js";import c from"../../../core/ObjectPool.js";import _ from"../../../core/PooledArray.js";import{throwIfAborted as g,isAbortError as m,isAborted as T,createAbortError as f}from"../../../core/promiseUtils.js";import{watch as y,syncAndInitial as v,sync as w,initial as E}from"../../../core/reactiveUtils.js";import{property as S}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as L}from"../../../core/accessorSupport/decorators/subclass.js";import{m as D}from"../../../chunks/mat4.js";import{c as C}from"../../../chunks/mat4f64.js";import{c as P}from"../../../chunks/vec3.js";import{c as U}from"../../../chunks/vec3f64.js";import{c as b}from"../../../chunks/vec4f64.js";import{WatchUpdatingTracking as x}from"../../../core/support/WatchUpdatingTracking.js";import{getReferenceEllipsoid as R}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as M,projectPointToVector as j}from"../../../geometry/projection.js";import A from"../../../geometry/SpatialReference.js";import{create as I,equals as O,intersection as V,empty as k,expand as B,intersectsSphere as N}from"../../../geometry/support/aaBoundingRect.js";import{create as F,copy as G}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as W}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as H}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as z}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as X}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as Y}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as $}from"../support/cameraUtils.js";import K from"../support/debugFlags.js";import{toBoundingRect as J}from"../support/extentUtils.js";import{ClientType as Z}from"../support/index.js";import{updatingProgress as ee}from"../support/updatingProperties.js";import{ElevationBounds as te}from"./ElevationBounds.js";import{ElevationData as ie,sampleElevation as re}from"./ElevationData.js";import{create as se}from"./ExtentHelper.js";import{LODSnapping as ae,TextureUpdate as ne}from"./interfaces.js";import{LayerClass as le,LayerClasses as oe}from"./LayerClass.js";import{OverlayManager as he}from"./OverlayManager.js";import{PlanarPatch as de}from"./PlanarPatch.js";import{RenderOrder as pe}from"./RenderOrder.js";import{SphericalPatch as ue}from"./SphericalPatch.js";import{SplitLimits as ce}from"./SplitLimits.js";import{MAX_ROOT_TILES as _e,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as ge,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as me,MAX_MEMORY_LOD_BIAS as Te,ELEVATION_NODATA_VALUE as fe}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as ve}from"./TerrainRenderer.js";import we from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as Ee,internalAssert as Se,oppositeEdge as Le,isSurfaceLayerView as De,isGroupLayerView as Ce,isMapTileLayerView as Pe,isBlendableLayerView as Ue,isElevationLayerView as be,isVectorTileLayerView as xe,useFetchTileForLayer as Re,isImageryTileLayerView as Me,isTileLayerView as je,releaseTileData as Ae,neighborEdgeIndices as Ie,ENABLE_TERRAIN_INTERNAL_CHECKS as Oe,ENABLE_WATERPROOFNESS_TESTS as Ve,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Be}from"./terrainUtils.js";import{Tile as Ne}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as qe,IteratorPostorder as We,compareTilesByLij as He,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Qe}from"./tileUtils.js";import{TilingSchemeLogic as Ye}from"./TilingSchemeLogic.js";import{UpsampleInfo as $e}from"./UpsampleInfo.js";import{isCompositeBlendMode as Ke,blendModeFromString as Je}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{RenderRequestType as Ze}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as et}from"../../support/RenderState.js";import{ImmediateTask as tt,TaskPriority as it,noBudget as rt}from"../../support/Scheduler.js";let st=class extends(a.EventedMixin(i)){constructor(e){super(e),this._iteratorPool=new c(qe,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new We,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._visibleCached=!1,this._usedMemory=null,this._performanceInfo=new we,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=U(),this._eyePosSurfaceSR=U(),this._splitLimits=new ce,this._frustum=F(),this._viewProjectionMatrix=C(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._handles=new n,this._watchUpdatingTracking=new x,this._frameTask=tt,this._allTiles=new _,this._upsampleInfoPool=new c($e),this._rootTilesExtent=I(),this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=A.WebMercator,this.visibleElevationBounds=new te(1/0,-1/0),this.rootTileElevationBounds=new te(1/0,-1/0),this._updatingRootTiles=!1,this._pendingTilesForElevationUpdateEvent=new Set,this._pendingTilesToUpdate=new Set,this.totalGeometryUpdates=0,this.totalTileUpdates=0,this.oneBatchPerFrameTask=!0,this._layerViewsDirty=!1,this._shading=!0,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new c(de):new c(ue);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("esri.views.3d.terrain.upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new H(e.newCache("elevation-query")),this._set("overlayManager",new he({surface:this})),this._handles.add([y((()=>this.overlayManager.hasHighlights),(e=>this._renderer.setNeedsHighlight(e))),y((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),y((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency()))],"overlayManager"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:R(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles}),this._handles.add([y((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?ne.UNFADED:ne.IMMEDIATE)}),v),y((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?ne.UNFADED:ne.IMMEDIATE)),v),y((()=>this.renderingDisabled),(()=>this.view?._stage?.renderer.setParameters({terrainRenderingEnabled:!this.renderingDisabled})),w),y((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),v),y((()=>this.snapLevel),(()=>this._viewChanged=!0),w),y((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),y((()=>K.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&K.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=d(this._treeDebugger))}),E)]),this._extentHelper=se(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:this.view.spatialReference});const t=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),i=new Ye({layers:t,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:this.view.spatialReference});this._set("tilingSchemeLogic",i),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(Z.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(Z.BASEMAP);const r=this.view.resourceController.scheduler;this._frameTask=r.registerTask(it.TERRAIN_SURFACE,this),this._handles.add([y((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),E),y((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),w),y((()=>this.extent),(()=>this._updateRootTiles()),E),this.view.on("resize",(()=>this._viewChangeUpdate())),y((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.resourceController?.memoryController?.memoryFactor,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),v),y((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),E),y((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),w)]),this._handles.add(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._handles.add([y((()=>this.view?.map.ground.shading),(()=>{this._updateShadingIfChanged()}))]),this._updateShading(),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._handles.destroy(),this._watchUpdatingTracking.destroy(),this._lercDecoder=h(this._lercDecoder),this._removeAllTiles(),this._upsampleMapCache=d(this._upsampleMapCache),this._elevationQueryCache=d(this._elevationQueryCache);const e=this.tilingSchemeLogic.layers;this._set("tilingSchemeLogic",d(this.tilingSchemeLogic)),e.destroy(),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",d(this.overlayManager)),this._tilePool=d(this._tilePool),Ne.prune(),this._treeDebugger=d(this._treeDebugger),this._renderer=d(this._renderer),this._iteratorPool=d(this._iteratorPool),this._set("view",null),this._upsampleInfoPool=d(this._upsampleInfoPool),Y(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===ae.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(i&&t){const r=e.state.contentCamera;let s=$(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a;return Math.round(n)}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?ae.ON:ae.OFF}get upsampleInfoPool(){return this._upsampleInfoPool}get upsampleMapCache(){return this._upsampleMapCache}get elevationQueryCache(){return this._elevationQueryCache}get mapTileRequester(){return this._mapDataRequester}get _userClippingExtent(){const{spatialReference:e}=this,{clippingArea:t}=this.view;if(p(t)||p(e))return null;const i=I(),r=J(t,i,e)?i:null,s=this._get("extent");return O(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=V(this.groundExtent,this._userClippingExtent,I()),t=this._get("extent");return O(e,t)?t:e}get groundExtent(){return u(this._tilingSchemeExtent)?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.running||this._watchUpdatingTracking.updating||this._asyncWorkItems>0)&&this.ready&&!this.suspended||this.overlayManager.updating)}get running(){return(this._hasPendingUpdates||this._viewChanged||this._allTilesDirty||!this._allTilesSorted||this._layerViewsDirty||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}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return u(this._rootTiles)}set renderOrder(e){this._renderer.renderOrder=e,this._set("renderOrder",e)}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}set velvetOverground(e){this._renderer.velvetOverground=e,this._set("velvetOverground",e)}get wireframe(){return this._renderer.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}set _visible(e){e!==this._visibleCached&&(this._visibleCached=e,this._renderer.setVisibility(e),this.suspended=!e)}get opaque(){return this._renderer.transparency===ve.Opaque}set suspended(e){this._set("suspended",e),this._viewChangeUpdate()}get textureFadeDuration(){return this.view.qualitySettings.tiledSurface.textureFadeDuration??0}intersect(e,t,i,r){this._renderer.intersect(e,t,i,r)}getElevation(e,t,i,r){const s=this._rootTiles;if(p(s)||!s.length)return null;if(0===s[0].layerInfo[le.ELEVATION].length)return null;const a=ht;if(a[0]=e,a[1]=t,a[2]=i,!M(a,r,a,this._spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return gt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[le.ELEVATION].length:0;if(!p(r)&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,gt(r,e[t+0],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!j(e,ht,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(u(t))for(const i of t)if(i?.containsPoint(ht)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;ht[0]>t[2]&&(i+=1),ht[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t,i,r,s){if(ht[0]=e,ht[1]=t,ht[2]=i,ht[3]=r,!M(ht,s,ht,this.tilingScheme?.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let a=1/0,n=-1/0;const o=e=>{if(e&&N(e.extent,ht))if(e.isLeaf||e.rendered)a=Math.min(a,e.elevationBounds[0]),n=Math.max(n,e.elevationBounds[1]);else for(const t of e.children)o(t)},h=this._rootTiles;if(u(h))for(const l of h)o(l);return{min:a,max:n}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!j(e,ht,this.spatialReference))return l.getLogger(this.declaredClass).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;ht[3]=t;let i=null;const r=e=>{if(e&&N(e.extent,ht)){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(u(s))for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._renderer.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?ve.Empty:ve.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?ve.Opaque:ve.Semitransparent,s=i!==r;return s&&(this._renderer.transparency=r,this.view?._stage?.renderer.setParameters({terrainTransparency:this._renderer.transparency})),s}_updateTilingScheme(){const e=this.tilingSchemeLogic.tilingScheme;if(!(e!==this.tilingScheme))return;Ee(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??A.WebMercator;this._spatialReference=t,this._isWebMercator=!!t?.isWebMercator,this._isWebMercatorOnPlateeCarree=this._isWebMercator&&q(this.view?.renderSpatialReference),this._set("tilingScheme",e),this._updateClippingExtent(),e&&(this._updateTiledLayers(),this._renderer.setTileSize(e.pixelSize),this.overlayManager.setSpatialReference(e.spatialReference),this._updateRootTiles())}_acquireTile(e,t,i,r){const s=this._tilePool.acquire();return pt[0]=e,pt[1]=t,pt[2]=i,s.init(pt,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=dt;let s=t.rootTilesInExtent(e,i,5*_e);if(u(this._rootTiles)){if(s.length>_e)return void l.getLogger(this.declaredClass).warn(ge);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,nt);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>nt(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>_e&&(l.getLogger(this.declaredClass).warn(me),s=t.rootTilesInExtent(e,i,_e)),this._setRootTiles(s.map((e=>this._newRootTile(e))));O(i,this._rootTilesExtent)||(this._rootTilesExtent=I(i)),this._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.isLoaded&&e.intersectsClippingArea));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(He);const t=this.renderer;e.forEach((e=>t.updateGeometryIfNeeded(e))),e.forEach((e=>this._pendingTilesForElevationUpdateEvent.add(e)))}_shouldSplit(e){return e.shouldSplit(this._splitLimits,this._eyePosRenderSR,this.snapLevel)===Ge.SPLIT}_newRootTile(e){const t=this._acquireTile(0,e[1],e[2],null);return this._shouldSplit(t)&&t.setPendingUpdate(Ge.SPLIT),this._loadTile(t),this._markTileToUpdate(t),this._updateRootTileElevationBounds(),t}_setRootTiles(e){if(this._rootTiles=e,this._allTiles.clear(),u(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)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this._visibleCached&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(p(e))return;const t=ze(e),i=this.visibleElevationBounds;let r=t?i.min:1/0,s=t?i.max:-1/0;const a=this.extent,n=this._viewProjectionMatrix;this.setTileTreeDirty();const l=this._iteratorPool.acquire();for(l.reset(e);!l.done;){const e=l.next();e.updateClippingStatus(a)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e),e.setPendingUpdate(Ge.RENDERDATA),e.computeVisibility(),e.updateScreenDepth(n),e.renderData&&(r=Math.min(e.elevationBounds[0],r),s=Math.max(e.elevationBounds[1],s))}l.remove(),this._viewChanged=!0,this._allTilesDirty=!0,this._batchUpdatePendingTileGeometries(),isFinite(r)&&isFinite(s)&&(i.min!==r||i.max!==s)&&(this.visibleElevationBounds=new te(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;u(i)&&i.forEach((({elevationBounds:i})=>{e=Math.min(e,i[0]),t=Math.max(t,i[1])}));const r=this.rootTileElevationBounds;r.min===e&&r.max===t||(this.rootTileElevationBounds=new te(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?(p(this._splitLimits.frustum)&&(this._splitLimits.frustum=F()),G(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,G(this._frustum,e.frustum),D(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),P(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(lt(e)?this._loadChildren(e):ot(e)&&this._loadParent(e))}_updateTileGeometryState(e){e.updateVisibility();this._renderer.updateTileGeometryState(e)&&this._markTileToUpdate(e),this._usedMemory=null}_markAllTileNeighborsForGeometryUpdate(e){const t=this._pendingTilesToUpdate;e.forEachLoadedNeighbor((e=>{t.add(e)}))}_updateTileTexture(e,t){const i=e.resetPendingUpdate(Ge.TEXTURE_FADING)?Ge.TEXTURE_FADING:!!e.resetPendingUpdate(Ge.TEXTURE_NOFADING)&&Ge.TEXTURE_NOFADING;i&&(this._renderer.updateTileTexture(e,i),this._usedMemory=null,t.madeProgress())}_emitElevationUpdateEventForTiles(){const e=ct.extent;k(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),ct.spatialReference=this.spatialReference,this.emit("elevation-change",ct)}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;this._mergeAndSplit(e,t),this._updateElevation(e),this._updateTextures(e),t||this._mergeAndSplit(e,!0),this._inFrameTask=!1,this._runViewChangeUpdateIfDirty(),this._batchUpdatePendingTileGeometries(),this._emitElevationUpdateEventForTiles(),e.done&&e.hasProgressed?this.requestUpdate():this.getUsedMemory(),this.notifyChange("updatingProgressValue")}_updateAllTilesStatus(e){if(!this._viewChanged||!this._rootTiles||e.done)return;this._viewChanged=!1;const t=this._iteratorPool.acquire();t.reset(this._rootTiles);const i=this.snapLevel,r=this._splitLimits,s=this._eyePosRenderSR;for(;!t.done;){const e=t.next(),a=e.shouldSplit(r,s,i);if(a!==Ge.SPLIT){if(e.resetPendingUpdate(Ge.SPLIT)&&e.updateAgentSuspension(),a===Ge.VSPLITMERGE&&e.updateAgents(le.ELEVATION),t.skipSubtree(),!e.isLeaf){e.setPendingUpdate(Ge.MERGE),e.resetPendingUpdate(Ge.SPLIT);const t=this._iteratorPool.acquire();t.resetOne(e);const i=this._viewProjectionMatrix;for(let e=t.next();!t.done;e=t.next())this._updateClippingStatus(e),e.updateVisibility(),e.updateScreenDepth(i);t.remove()}}else e.resetPendingUpdate(Ge.MERGE),e.isLeaf&&(e.setPendingUpdate(Ge.SPLIT),t.skipSubtree()),e.rendered&&e.setPendingUpdate(Ge.RENDERDATA)}t.remove(),this.requestUpdate(),(this.shortBatches||!this.oneBatchPerFrameTask)&&this._batchUpdatePendingTileGeometries(),e.madeProgress()}_sortTiles(e){e.done||this._allTilesSorted||(Xe(this._allTiles,this.view.pointsOfInterest.focus.renderLocation),this._allTilesSorted=!0,this._treeDebugger&&this._treeDebugger.update(),e.madeProgress())}_markTileToUpdate(e){Se(e.isLoaded),e.intersectsClippingArea&&(this._pendingTilesToUpdate.add(e),this._markAllTileNeighborsForGeometryUpdate(e))}_batchUpdatePendingTileGeometries(){const e=this._pendingTilesToUpdate;if(0===e.size)return;const t=Array.from(this._pendingTilesToUpdate.keys()).filter((e=>e.isLoaded&&e.intersectsClippingArea)),i=(i,r)=>{!r?.isLoaded||!r.intersectsClippingArea||r.level<i.level||e.has(r)||(e.add(r),t.push(r),r.renderData.updateNeighborData())};t.sort(He);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Se(r.isLoaded),Se(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData;for(let t=0;t<4;++t)if(n&1<<t){const s=a.geometryState.neighborData.edgePeerNeighbors[t];s&&s?.level>=r.level&&s.forAllSubtreeOnSide(Le(Ie[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Se(e.has(t)||He(r,t)<0),i(r,t),!0))),i(r,l.cornerPeerNeighbors[t]),i(r,l.cornerPeerNeighbors[(t+1)%4])}}e.clear(),this._updateTilesGeometries(t),Oe&&Ve&&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.resetPendingUpdate(Ge.MERGE)){if(!t)return s.setPendingUpdate(Ge.MERGE),e.done;for(;n.parent?.resetPendingUpdate(Ge.MERGE);)n=n.parent;this._mergeTile(n),a=!0,e.madeProgress()}else s.resetPendingUpdate(Ge.SPLIT)&&(this._splitTile(s),a=!0,e.madeProgress());return!e.done&&n===s&&s.resetPendingUpdate(Ge.RENDERDATA)&&(this._updateRenderData(s),e.madeProgress()),e.done}));if(a&&(this._allTilesSorted=!1,this._allTilesDirty=!0),n){if(!i){i=!0;continue}if(!a)break}else this._allTilesDirty=!0}s?e.madeProgress():this._allTilesDirty=!0,!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries(),this._sortTiles(e)}_updateElevation(e){e.done||(this._allTiles.some((t=>(t.resetPendingUpdate(Ge.GEOMETRY)&&(this._updateTileGeometryState(t),this._updateTileTexture(t,e),this.shortBatches&&this._batchUpdatePendingTileGeometries(),e.madeProgress()),e.done))),!this.oneBatchPerFrameTask&&this._batchUpdatePendingTileGeometries())}_updateTextures(e){e.done||this._allTiles.some((t=>(this._updateTileTexture(t,e),e.done)))}_updateClippingExtent(){this.spatialReference&&(this.updateTileOverlayParams(Ze.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.resourceController.memoryController.memoryFactor;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*Te}_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(){u(this._rootTiles)&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this._visible=!1}_purgeDescendantTiles(e){if(!e.children[0])return!1;let t=!1;for(let i=0;i<4;++i)t=this._purgeTile(e.children[i])||t;return e.unsetChildren(),t}_purgeTile(e){const t=this._purgeDescendantTiles(e)||e.rendered;return this._allTiles.removeUnordered(e),this._unloadTile(e),this._tilePool.release(e),t}_unloadTile(e){this._pendingTilesToUpdate.delete(e),this._pendingTilesForElevationUpdateEvent.delete(e),e.unload(this._renderer)}_splitTile(e){Ee(e.isLeaf,"tile that is already split should not be split again!");const t=e.level+1,i=2*e.lij[1],r=2*e.lij[2];e.setChildren(this._createTile(t,i,r,e),this._createTile(t,i,r+1,e),this._createTile(t,i+1,r,e),this._createTile(t,i+1,r+1,e)),e.setPendingUpdate(Ge.RENDERDATA),e.updateAgentSuspension(),this._allTiles.pushArray(e.children),this._allTilesDirty=!0,++this._performanceInfo.numSplit}_emitTileScaleChange(e,t=e.level){_t.spatialReference=this.spatialReference,_t.extent=e.extent,_t.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",_t)}_createTile(e,t,i,r){Ee(!!r,"_createTile sanity check");const s=this._acquireTile(e,t,i,r);return s.updateClippingStatus(this.extent),s.updateScreenDepth(this._viewProjectionMatrix),this._shouldSplit(s)&&s.setPendingUpdate(Ge.SPLIT),s}get shortBatches(){return this.view.state.mode!==et.IDLE}_mergeTile(e){Ee(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(Ee(!e.renderData,"_mergeTile sanity check"),this._loadTile(e),this._markTileToUpdate(e),this._emitTileScaleChange(e),this.shortBatches&&this._batchUpdatePendingTileGeometries()),this._allTilesDirty=!0,++this._performanceInfo.numMerged}_loadChildren(e){Ee(e.rendered,"parent should be rendered"),this._unloadTile(e);const t=e.children;t.forEach((e=>this._loadTile(e))),t.forEach((e=>this._pendingTilesToUpdate.add(e))),this._markAllTileNeighborsForGeometryUpdate(e),this._emitTileScaleChange(e,e.level+1),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_loadParent(e){const t=e.parent;this._unloadChildren(t),this._loadTile(t),this._markTileToUpdate(t),this._emitTileScaleChange(t,t.level),this.shortBatches&&this._batchUpdatePendingTileGeometries()}_unloadChildren(e){const t=e.children;if(t[0])for(let i=0;i<4;++i){const e=t[i];this._unloadChildren(e),this._unloadTile(e)}}_loadTile(e){e.load(),e.setPendingUpdate(Ge.RENDERDATA),this.requestUpdate(),this._allTilesDirty=!0,this.overlayManager&&this.overlayManager.hasOverlays&&this.overlayManager.setTileParameters(e)}_elevationDataArrived(e,t,i){const r=new ie(e.lij,e.extent,i);e.dataArrived(t,le.ELEVATION,r);const s=[e],a=e.level,n=this._iteratorPool.acquire();for(n.reset(s);!n.done;){const e=n.next();e.findElevationBoundsForLayer(t,a),e.computeElevationBounds()}0===a&&this._updateRootTileElevationBounds(),n.remove(),this._updateTilesVisibility(s)}_handleLayerViewChanges(e=rt){if(!this._layerViewsDirty)return;this._layerViewsDirty=!1;let t=!1;const i=new Set;let r=-1;for(const s of this.view.allLayerViews.items)if(i.add(s.uid),De(s)||Ce(s))if(this._basemapLayerViewHandles.has(s.uid)&&!Ce(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);u(i)&&((i<r||p(r))&&(t=!0),r=i)}else this._registerTiledLayerView(s),s.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()}_allSurfaceLayersTransparent(){let e=0===this.view.map?.ground?.opacity;for(const t of this.view.allLayerViews.items)if(Pe(t)&&!X(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((Ue(e)||Ce(e))&&Ke(Je[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return be(e)?le.ELEVATION:le.MAP}_registerTiledLayerView(e){const t=[];if((Ue(e)||Ce(e))&&t.push(y((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(ne.UNFADED)}))),Ce(e))return;const i=this._layerClassFromLayerView(e);t.push(y((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(y((()=>e.fullOpacity),(()=>this._updateTileTextures(ne.UNFADED)))),t.push(y((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);u(t)&&this._invalidateLayerData(t,i)})),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(let e=0;e<t.length;e++)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||!De(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===le.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of oe){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()}_restartAllAgents(e){const t=this._postorderIterator;for(t.reset(this._rootTiles);!t.done;){const i=t.next();i.restartAgents(e),e===le.ELEVATION&&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(le.MAP),e===ne.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(le.MAP,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=Ze.UPDATE){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||xe(s)?this._requestTileData(e,i,s,r):(++this._asyncWorkItems,a.tilemapCache.fetchAvailability(e.lij[0],e.lij[1],e.lij[2],{...r,timeout:6e3}).then((()=>--this._asyncWorkItems)).catch((t=>{throw--this._asyncWorkItems,g(r),m(t)||this._dataMissing(e,i,s,{notInTilemap:!0}),t})).then((()=>this._frameTask.schedule((()=>this._requestTileData(e,i,s,r)),r.signal))))}_requestTileData(e,t,i,r){return t===le.ELEVATION?be(i)?this._requestElevationTileData(e,i,r):Promise.reject():Pe(i)?this._requestMapTileData(e,i,r):Promise.reject()}_requestElevationTileData(e,t,i){++this._asyncWorkItems;const r=r=>{if(T(i))return;const s=this._layerIndexByUid[le.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer %d %s",le.ELEVATION,e.lij.toString())},s=i=>{m(i)||(this._dataMissing(e,le.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:fe,signal:i.signal}).then((e=>{if(!T(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true.")}),s).finally((()=>{--this._asyncWorkItems}));const a=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);return this._elevationDataRequester.request(a,"binary",i).then((e=>this._lercDecoder.decode(e,{noDataValue:fe},i.signal))).then((e=>{e?r(new z(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,Ae(s),T(i)||(this._dataMissing(e,le.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),T(i)?Ae(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),n=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(xe(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,n)}if(Me(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,n);if(je(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(T(i))return l.getLogger(this.declaredClass).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void n(f());a(e)}),n);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);W(t.layer)&&t.layer.refreshTimestamp&&(o+=`${o.includes("?")?"&":"?"}_ts=${t.layer.refreshTimestamp}`);const h=t.hasMixedImageFormats?"image+type":"image";return this._mapDataRequester.request(o,h,i).then(a,n)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(le.MAP,t.uid);u(r)?e.dataArrived(r,le.MAP,i):(Ae(i),l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer"))}_getLayerIdxByUID(e,t){return this._layerIndexByUid[e].get(t)}_dataMissing(e,t,i,r){const s=this._getLayerIdxByUID(t,i.uid);u(s)?e.dataMissing(s,t,r):l.getLogger(this.declaredClass).warn("TerrainSurface: received data from unknown layer")}updateTileOverlayParams(e){this._rootTiles&&this.overlayManager&&(this._allTiles.forAll((e=>{e.renderData&&this.overlayManager.setTileParameters(e)})),this._renderer.setNeedsRender(e))}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.isLeaf&&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}getUsedMemory(){return this.tilingScheme?(p(this._usedMemory)&&(this._usedMemory=this._recalculateUsedMemory()),u(this._usedMemory)?this._usedMemory:0):0}_recalculateUsedMemory(){return this.tilingScheme?this._allTiles.reduce(((e,t)=>e+t.usedMemory),0):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return u(r)&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(p(e)||p(this._rootTiles))return null;const t=e.split("/").map((e=>+e));if(0===t[0])return this._rootTiles.find((e=>e.lij[1]===t[1]&&e.lij[2]===t[2]));const i=2**t[0],r=Math.floor(t[1]/i),s=Math.floor(t[2]/i);let a;if(this._rootTiles.some((e=>e.lij[1]===r&&e.lij[2]===s&&(a=e,!0))),a){let e=1<<t[0]-1;for(;a.lij[0]<t[0];){let i=t[1]&e?2:0;if((t[2]&e)>0&&i++,!a.children[i])return null;a=a.children[i],e>>=1}return Ee(a.lij[0]===t[0]&&a.lij[1]===t[1]&&a.lij[2]===t[2],"not the right tile?"),a}return null}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(){const e=this;return{renderer:e._renderer,lercDecoder:e._lercDecoder,forceReload:()=>{u(e._rootTiles)&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){ut.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&ut.push(e)}));const t=ut.toArray();return Qe(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Ve)return;const e=this._rootTiles;if(p(e))return;const t=e=>e?.renderData?.geometryInfo?.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.geometryInfo&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometryInfo||(e.renderData.geometryInfo.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometryInfo),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.isLeaf)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.isLeaf)for(const a of e.children)s(a)};for(const a of e)r(a),s(a)}get isGlobal(){return this._isGlobal}get shading(){return this._shading}_updateShadingIfChanged(){const e=this.view?.map?.ground?.shading;e!==this._shading&&this._updateShading()}_updateShading(){const e=this.view?.map?.ground?.shading;this._shading=e,this.renderer&&(this.renderer.shading=e,this.renderer.setNeedsRender()),this._updateAllTileGeometries()}get isWebMercator(){return this._isWebMercator}get isWebMercatorOnPlateeCarree(){return this._isWebMercatorOnPlateeCarree}isEastEndWrap(e){return this.isGlobal&&e[2]===this.lijEastEnd(e[0])-1}isWestEndWrap(e){return this.isGlobal&&0===e[2]}lijEastEnd(e){return 2**(e+(u(this.spatialReference)&&this.spatialReference.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){ke(e)}enableWaterproofnessChecks(e){Be(e)}};e([S()],st.prototype,"_renderer",void 0),e([S()],st.prototype,"_hasPendingUpdates",void 0),e([S()],st.prototype,"_asyncWorkItems",void 0),e([S()],st.prototype,"_allTilesDirty",void 0),e([S()],st.prototype,"_allTilesSorted",void 0),e([S()],st.prototype,"_viewChanged",void 0),e([S({readOnly:!0})],st.prototype,"_watchUpdatingTracking",void 0),e([S()],st.prototype,"_frameTask",void 0),e([S({readOnly:!0})],st.prototype,"snapLevel",null),e([S({readOnly:!0})],st.prototype,"lodSnapping",null),e([S({constructOnly:!0})],st.prototype,"view",void 0),e([S()],st.prototype,"_userClippingExtent",null),e([S()],st.prototype,"_rootTilesExtent",void 0),e([S({readOnly:!0})],st.prototype,"extent",null),e([S({readOnly:!0})],st.prototype,"groundExtent",null),e([S({readOnly:!0})],st.prototype,"_tilingSchemeExtent",null),e([S({readOnly:!0})],st.prototype,"updating",null),e([S({readOnly:!0})],st.prototype,"running",null),e([S(ee)],st.prototype,"updatingProgress",void 0),e([S({readOnly:!0})],st.prototype,"updatingProgressValue",null),e([S()],st.prototype,"_maxNumUpdating",void 0),e([S()],st.prototype,"baseOpacity",null),e([S()],st.prototype,"hasCompositeBlendMode",void 0),e([S({readOnly:!0})],st.prototype,"overlayManager",void 0),e([S({readOnly:!0})],st.prototype,"viewingMode",null),e([S()],st.prototype,"maxTextureScale",void 0),e([S({readOnly:!0})],st.prototype,"ready",null),e([S({value:pe.FRONT_TO_BACK})],st.prototype,"renderOrder",null),e([S({readOnly:!0})],st.prototype,"rootTiles",null),e([S()],st.prototype,"_rootTiles",void 0),e([S({readOnly:!0})],st.prototype,"spatialReference",null),e([S({type:t})],st.prototype,"backgroundColor",null),e([S({value:!1})],st.prototype,"slicePlaneEnabled",null),e([S({readOnly:!0})],st.prototype,"tilingScheme",void 0),e([S({readOnly:!0})],st.prototype,"tilingSchemeLocked",null),e([S({readOnly:!0})],st.prototype,"tilingSchemeLogic",void 0),e([S({value:!0})],st.prototype,"velvetOverground",null),e([S()],st.prototype,"wireframe",null),e([S({value:!1})],st.prototype,"suspended",null),e([S()],st.prototype,"textureFadeDuration",null),e([S()],st.prototype,"visibleElevationBounds",void 0),e([S()],st.prototype,"rootTileElevationBounds",void 0),e([S()],st.prototype,"_layerViewsDirty",void 0),e([S()],st.prototype,"renderPatchBorders",null),e([S()],st.prototype,"visualizeNormals",null),e([S()],st.prototype,"renderingDisabled",null),st=e([L("esri.views.3d.terrain.TerrainSurface")],st);const at=st;function nt(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function lt(e){const t=e.children;if(!t[0])return!1;for(const i of t)if(i.shouldLoad)return!0;for(const i of t)if(lt(i))return!0;return!1}function ot(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const ht=b(),dt=I(),pt=[0,0,0],ut=new _,ct={spatialReference:null,extent:I(),context:"ground"},_t={spatialReference:null,extent:null,scale:0};function gt(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 re(t,i,s)}return null}export{at 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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{nextHighestPowerOfTwo as e}from"../../../core/mathUtils.js";import{disposeMaybe as t,releaseMaybe as r,isNone as s,isSome as o}from"../../../core/maybe.js";import{s as a,c as i}from"../../../chunks/vec2.js";import{Z as n}from"../../../chunks/vec2f64.js";import{isBaseLayer as c,isGroupLayer as u}from"../../../layers/support/layerUtils.js";import{ImageWithType as
|
|
5
|
+
import{nextHighestPowerOfTwo as e}from"../../../core/mathUtils.js";import{disposeMaybe as t,releaseMaybe as r,isNone as s,isSome as o}from"../../../core/maybe.js";import{s as a,c as i}from"../../../chunks/vec2.js";import{Z as n}from"../../../chunks/vec2f64.js";import{isBaseLayer as c,isGroupLayer as u}from"../../../layers/support/layerUtils.js";import{ImageWithType as l}from"../support/StreamDataLoader.js";import{BlendLayersPassParameters as p}from"./BlendLayersTechnique.js";import{TextureUpdate as h}from"./interfaces.js";import{LayerClass as d}from"./LayerClass.js";import{isBlendableLayerView as m,isVectorTileLayerView as _,isVectorTileRenderInfo as f,isImageryTileRenderInfo as y,isRasterTileRenderInfo as T,isTextureTileRenderInfo as g}from"./terrainUtils.js";import{ActivationTime as x}from"./TextureFader.js";import{TextureReference as b}from"./TextureReference.js";import{TileCompositor as k}from"./TileCompositor.js";import w from"./TileTexture.js";import{TileUpdate as I}from"./TileUpdate.js";import{blendModeFromString as P}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{BaseOpacityMode as A,BlendLayersOutput as D}from"../webgl-engine/core/shaderLibrary/terrain/TileBackground.glsl.js";import{createColorTexture as E,createEmptyTexture as M}from"../webgl-engine/lib/glUtil3D.js";import{ContextType as R}from"../../webgl/context-util.js";import{TextureSamplingMode as L,TextureType as j,PixelFormat as C,PixelType as N,TextureWrapMode as O}from"../../webgl/enums.js";import{Texture as U}from"../../webgl/Texture.js";class B{constructor(e,t,r,s){this.start=e,this.end=t,this.blendMode=r,this.opacity=s}}class G{constructor(e,t,r){this._rctx=e,this.tileSize=t,this._techniqueRepository=r,this._passParameters=new p,this._backgroundTexture=null,this._backgroundColor=null,this._backgroundDirty=!1,this._blackTex=null,this._maxAnisotropy=this._rctx.parameters.maxMaxAnisotropy,this._composition=new k(this._rctx,this._techniqueRepository),this._blackTex=new w(E(this._rctx,[0,0,0,1])),this._ensureBackgroundTexture(this.tileSize)}dispose(){this._composition=t(this._composition),this._backgroundTexture=r(this._backgroundTexture),this._blackTex=r(this._blackTex)}get backgroundIsGrid(){return s(this._backgroundColor)}get backgroundColor(){return this._backgroundColor}updateTileTexture(e,t){if(!e.renderData)return;const r=e.surface,s=r.baseOpacity;let a=0,i=0,n=this.tileSize,l=!1;const p=r.view.state.contentPixelRatio;let h=!1;Y.clear(),Z.length=0;const f=e.layerInfo[d.MAP];let y=f.length,T=0;for(;T<f.length;T++){const t=r.layerViewByIndex(T,d.MAP),g=t.layer.opacity;v[T]=g;const x=t.fullOpacity;if(V[T]=x,c(t.layer)&&y>=f.length&&(y=T),m(t)){W[T]=t.layer.blendMode;let e="normal"!==t.layer.blendMode;if(u(t.layer.parent)){const r=q(t.layer.parent);o(r)&&""!==r&&(e=z(t.layer.parent)||e)}e&&(h=e,l=!1)}if(0===g&&!h){f[T].pendingUpdates&=~(I.TEXTURE_NOFADING&I.TEXTURE_FADING);continue}++i;const b=S(e,T);if(b){if(f[T].pendingUpdates&=~(I.TEXTURE_NOFADING&I.TEXTURE_FADING),u(t.layer.parent)){const e=q(t.layer.parent);o(e)&&""!==e&&X(t.layer.parent,T)}_(t)?n=Math.max(n,this.tileSize*p):1===s&&1===x&&(t.isOpaque||this._dataToTexture(b)&&b.sourceLayerInfo.data.descriptor.isOpaque)&&(l=!0),++a}}this._rctx.type===R.WEBGL1&&(n=F(n));const g=n/this.tileSize,x=T-1;this._ensureBackgroundTexture(this.tileSize),0!==a?1===a&&!h&&this._useLayerTexture(e,x,y,V[x])||this._composeMapLayers(e,t,x,y,v,W,n,g,!l||h,Y,h):this._useBackgroundTexture(e,i)}_ensureBackgroundTexture(e){s(this._backgroundTexture)&&(this._backgroundTexture=this._buildTexture(e),this._backgroundDirty=!0),this._backgroundDirty&&(this._composition.bind(e),this._passParameters.offset=n,this._passParameters.scale=1,this._passParameters.opacity=1,o(this.backgroundColor)&&(this._passParameters.backgroundColor=this.backgroundColor),this._composition.drawBackground(this._passParameters,o(this.backgroundColor)),this._composition.copyFBOToTexture(this._backgroundTexture),this._composition.unbind(),this._backgroundDirty=!1)}_useBackgroundTexture(e,t){let r=x.Immediate;(e.surface.view.layerViewManager.updating||t>0)&&(r=x.Delayed);const a=e.renderData;this._backgroundTexture&&s(a.textureReference)&&(r=x.Immediate),a.setTextureReference(o(this._backgroundTexture)?new b(this._backgroundTexture,h.FADING,J,e.surface.baseOpacity,0,1):null,r)}_useLayerTexture(e,t,r,s){const o=t<r,a=o?1:e.surface.baseOpacity,i=o?e.surface.baseOpacity:1,n=S(e,t);return!!this._dataToTexture(n)&&(e.renderData.setTextureReference(new b(n.sourceLayerInfo.data,h.FADING,n,a,i,s)),!0)}_composeMapLayers(e,t,r,s,o,a,i,c,u,l,p){this._composition.ensureBuffer(i);const h=e.surface.baseOpacity;let d=!1,m=L.LINEAR_MIPMAP_LINEAR,_=!1,T=0;for(let b=r;b>=0;b--){const t=S(e,b);if(!t)continue;if(0===o[b]&&!p)continue;const r=b<s&&h<1&&!d;this._passParameters.baseOpacity=r?h:1;const g=this._passParameters.baseOpacity<1?A.Required:A.NotRequired;r&&(d=!0);let x=!1;l.forEach((e=>{e.start===b&&(Z.push(e),this._composition.openGroup(i),x=!0)}));const k=0===T,w=x?D.GroupBackgroundComposite:u&&k?this.backgroundIsGrid?D.GridComposite:D.ColorComposite:D.Composite,I=P[a[b]];for(f(t)?(this._passParameters.opacity=o[b],_=this._composition.drawVectorData(this._passParameters,w,i,I,g,t,c,this.tileSize,_)):y(t)?(this._passParameters.opacity=o[b],this._composition.drawImageryTileData(this._passParameters,w,i,I,g,t),this._hasNearestInterpolation(t)&&(m=L.NEAREST)):this._dataToTexture(t)&&(this._passParameters.texture=t.sourceLayerInfo.data.texture,this._passParameters.offset=t.offset,this._passParameters.scale=t.scale,this._passParameters.opacity=o[b],this._composition.drawRasterData(this._passParameters,w,i,I,g));Z.length>0&&Z[Z.length-1].end===b;){const e=Z.pop();this._passParameters.opacity=e.opacity,this._passParameters.offset=n,this._passParameters.scale=1;const t=u&&k?this.backgroundIsGrid?D.GridComposite:D.ColorComposite:D.Composite;this._composition.drawGroup(this._passParameters,t,i,P[e.blendMode],g)}T++}const g=e.renderData,x=g.ensureTexture(i,(()=>this._buildTexture(i,m)));this._composition.copyFBOToTexture(x),this._composition.unbind(),g.setTextureReference(new b(x,t,J,d?1:h,0,1))}_hasNearestInterpolation(e){const t=e.sourceLayerInfo.data;return!!t.source&&"nearest"===t.interpolation}_dataToTexture(e){if(T(e)){const t=e.sourceLayerInfo;t.data=this._buildTexture(t.data),e.tile.setMemoryDirty()}return g(e)}setBackground(e){this._backgroundColor!==e&&(this._backgroundColor=e,this._backgroundDirty=!0)}_buildTexture(e,t=L.LINEAR_MIPMAP_LINEAR){if(s(e))return null;const r={target:j.TEXTURE_2D,pixelFormat:C.RGBA,dataType:N.UNSIGNED_BYTE,wrapMode:O.CLAMP_TO_EDGE,samplingMode:t,maxAnisotropy:this._maxAnisotropy,preMultiplyAlpha:!0,flipped:!0,hasMipmap:!0},o=this._rctx;let a;if("number"==typeof e)r.width=r.height=e,a=new w(new U(o,r));else if(e instanceof l)r.isOpaque=e.isOpaque,a=new w(new U(o,r,e.image)),e.release();else try{r.width=e.width,r.height=e.height,a=new w(new U(o,r,e))}catch(n){a=new w(M(o)),console.warn("TileRenderer: failed to execute 'texImage2D', cross-origin image may not be loaded.")}const i=o.bindTexture(a.texture,U.TEXTURE_UNIT_FOR_UPDATES);return a.generateMipmap(),o.bindTexture(i,U.TEXTURE_UNIT_FOR_UPDATES),a}get test(){return{backgroundTexture:this._backgroundTexture}}}function F(t){const r=e(t),s=r*r,o=t*t;if(s===o)return t;const a=r/2;return s-o<o-a*a?r:a}function S(e,t){H.layerIndex=t;const r=e.layerInfo[d.MAP][t];if(o(r.data))return a(H.offset,0,0),H.tile=e,H.scale=1,H.sourceLod=e.lij,H.sourceLayerInfo=r,H;const s=r.upsampleInfo;if(o(s)){const e=s.tile.layerInfo[d.MAP][t];return H.tile=s.tile,i(H.offset,s.offset),H.scale=s.scale,H.sourceLod=s.tile.lij,H.sourceLayerInfo=e,H}return null}function q(e){return e.get("uid")}function z(e){let t="normal"!==e.blendMode;return u(e.parent)&&(t=z(e.parent)||t),t}function X(e,t){u(e.parent)&&X(e.parent,t);const r=q(e);if(o(r)&&""!==r){const s=Y.get(r);s?s.start=t:Y.set(r,new B(t,t,e.blendMode,e.opacity))}}const v=new Array,V=new Array,W=new Array,Y=new Map,Z=new Array,H={tile:null,sourceLayerInfo:null,sourceLod:null,offset:[0,0],scale:1,layerIndex:0},J={offset:[0,0],scale:1};export{B as GroupInfo,G as TileRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as s}from"../../../../../core/maybe.js";import{f as a,t as e,e as t}from"../../../../../chunks/mat3.js";import{c as r}from"../../../../../chunks/mat3f64.js";import{c as i}from"../../../../../chunks/mat4.js";import{s as h,c as m}from"../../../../../chunks/vec3.js";import{c as n}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as o,ShadowMapPassParameters as P,HighlightPassParameters as l,MaterialSubPass as d,RenderPassIdentifier as p}from"./AllRenderPasses.js";import{RenderPass as c,RenderPassSorting as u}from"./RenderPass.js";import{ShaderOutput as _}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as g}from"../util/TwoVectorPosition.js";import{union as b}from"../../lib/depthRange.js";import{RenderSlot as w}from"../../lib/RenderSlot.js";class f{constructor(s,a){this.rctx=s,this.shaderTechniqueRepository=a,this.canRender=!0,this._materialPassParameters=new o,this._shadowPassParameters=new P,this._highlightPassParameters=new l,this._systems=new Set,this._passes={materialOpaque:new c(s,a),materialTransparent:new c(s,a,u.BackToFront),materialIntegratedMesh:new c(s,a),shadowMap:new c(s,a),highlight:new c(s,a),highlightIntegratedMesh:new c(s,a),highlightShadowMap:new c(s,a),defaultShadowMap:new c(s,a)}}register(s){this._systems.add(s)}prepareRender(s){if(0!==this._systems.size){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((a=>a.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this.shaderTechniqueRepository.frameUpdate()}}render(s){if(0!==this._systems.size)switch(this._configure(s),s.bindParameters.slot){case w.OPAQUE_MATERIAL:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Highlight:return this._passes.highlight.dispatch(this._highlightPassParameters,s.bindParameters);case _.Shadow:return this._passes.shadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ShadowHighlight:return this._passes.highlightShadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.
|
|
5
|
+
import{isSome as s}from"../../../../../core/maybe.js";import{f as a,t as e,e as t}from"../../../../../chunks/mat3.js";import{c as r}from"../../../../../chunks/mat3f64.js";import{c as i}from"../../../../../chunks/mat4.js";import{s as h,c as m}from"../../../../../chunks/vec3.js";import{c as n}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as o,ShadowMapPassParameters as P,HighlightPassParameters as l,MaterialSubPass as d,RenderPassIdentifier as p}from"./AllRenderPasses.js";import{RenderPass as c,RenderPassSorting as u}from"./RenderPass.js";import{ShaderOutput as _}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as g}from"../util/TwoVectorPosition.js";import{union as b}from"../../lib/depthRange.js";import{RenderSlot as w}from"../../lib/RenderSlot.js";class f{constructor(s,a){this.rctx=s,this.shaderTechniqueRepository=a,this.canRender=!0,this._materialPassParameters=new o,this._shadowPassParameters=new P,this._highlightPassParameters=new l,this._systems=new Set,this._passes={materialOpaque:new c(s,a),materialTransparent:new c(s,a,u.BackToFront),materialIntegratedMesh:new c(s,a),shadowMap:new c(s,a),highlight:new c(s,a),highlightIntegratedMesh:new c(s,a),highlightShadowMap:new c(s,a),defaultShadowMap:new c(s,a)}}register(s){this._systems.add(s)}prepareRender(s){if(0!==this._systems.size){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((a=>a.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this.shaderTechniqueRepository.frameUpdate()}}render(s){if(0!==this._systems.size)switch(this._configure(s),s.bindParameters.slot){case w.OPAQUE_MATERIAL:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters);case _.Highlight:return this._passes.highlight.dispatch(this._highlightPassParameters,s.bindParameters);case _.Shadow:return this._passes.shadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ShadowHighlight:return this._passes.highlightShadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ShadowExcludeHighlight:return this._passes.defaultShadowMap.dispatch(this._shadowPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialOpaque.dispatch(this._materialPassParameters,s.bindParameters)}return;case w.TRANSPARENT_MATERIAL:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Alpha:return this._materialPassParameters.subPass=d.Alpha,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialTransparent.dispatch(this._materialPassParameters,s.bindParameters)}return;case w.INTEGRATED_MESH:switch(s.output){case _.Color:return this._materialPassParameters.subPass=d.Color,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Depth:return this._materialPassParameters.subPass=d.Depth,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Normal:return this._materialPassParameters.subPass=d.Normal,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters);case _.Highlight:return this._passes.highlightIntegratedMesh.dispatch(this._highlightPassParameters,s.bindParameters);case _.ObjectAndLayerIdColor:return this._materialPassParameters.subPass=d.ObjectAndLayerIdColor,this._passes.materialIntegratedMesh.dispatch(this._materialPassParameters,s.bindParameters)}return}}notifyDirty(){this._context.requestRender()}slots(){return[w.OPAQUE_MATERIAL,w.TRANSPARENT_MATERIAL,w.INTEGRATED_MESH]}initializeRenderContext(s){this._context=s}uninitializeRenderContext(){}queryDepthRange(a){const e={near:1/0,far:-1/0};return this._systems.forEach((t=>{const r=t.queryShadowCasterDepthRange(a);s(r)&&b(e,r,e)})),e}_configure(s){const a=s.output===_.Shadow||s.output===_.ShadowHighlight||s.output===_.ShadowExcludeHighlight?this._shadowPassParameters:s.output===_.Highlight?this._highlightPassParameters:this._materialPassParameters;this._updateParameters(s,a)}_updateParameters(s,r){const n=s.bindParameters.camera,o=n.viewInverseTransposeMatrix;h(T,o[3],o[7],o[11]),A.set(T),m(r.transformWorldFromViewTH,A.high),m(r.transformWorldFromViewTL,A.low),m(r.slicePlaneLocalOrigin,T),a(r.transformViewFromCameraRelativeRS,n.viewMatrix),i(r.transformProjFromView,n.projectionMatrix),r.identifier===p.Material&&(this._materialPassParameters.transparent=s.bindParameters.slot===w.TRANSPARENT_MATERIAL,this._materialPassParameters.integratedMesh=s.bindParameters.slot===w.INTEGRATED_MESH,e(R,r.transformViewFromCameraRelativeRS),t(r.transformNormalViewFromGlobal,R))}get needsHighlight(){return this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0}get needsTransparentPass(){return this._passes.materialTransparent.count>0}}const T=n(),R=r(),A=new g;export{f as RenderPassManager};
|
|
@@ -4,6 +4,6 @@ See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
|
4
4
|
*/
|
|
5
5
|
import{ShaderOutput as e}from"./ShaderOutput.js";import{VertexPosition as r}from"./attributes/VertexPosition.glsl.js";import{Float2PassUniform as a}from"../shaderModules/Float2PassUniform.js";import{glsl as o}from"../shaderModules/interfaces.js";function t(e){e.varyings.add("linearDepth","float")}function i(e){e.vertex.uniforms.add(new a("nearFar",((e,r)=>r.camera.nearFar)))}function n(e){e.vertex.code.add(o`float calculateLinearDepth(vec2 nearFar,float z) {
|
|
6
6
|
return (-z - nearFar[0]) / (nearFar[1] - nearFar[0]);
|
|
7
|
-
}`)}function d(a,d){const{vertex:s}=a;switch(d.output){case e.Color:if(d.receiveShadows)return t(a),void s.code.add(o`void forwardLinearDepth() { linearDepth = gl_Position.w; }`);break;case e.Depth:case e.Shadow:case e.ShadowHighlight:case e.
|
|
7
|
+
}`)}function d(a,d){const{vertex:s}=a;switch(d.output){case e.Color:if(d.receiveShadows)return t(a),void s.code.add(o`void forwardLinearDepth() { linearDepth = gl_Position.w; }`);break;case e.Depth:case e.Shadow:case e.ShadowHighlight:case e.ShadowExcludeHighlight:return a.include(r,d),t(a),i(a),n(a),void s.code.add(o`void forwardLinearDepth() {
|
|
8
8
|
linearDepth = calculateLinearDepth(nearFar, vPosition_view.z);
|
|
9
9
|
}`)}s.code.add(o`void forwardLinearDepth() {}`)}export{d as ForwardLinearDepth,n as addCalculateLinearDepth,t as addLinearDepth,i as addNearFar};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
var h;!function(h){h[h.Color=0]="Color",h[h.Depth=1]="Depth",h[h.Normal=2]="Normal",h[h.Shadow=3]="Shadow",h[h.ShadowHighlight=4]="ShadowHighlight",h[h.
|
|
5
|
+
var h;!function(h){h[h.Color=0]="Color",h[h.Depth=1]="Depth",h[h.Normal=2]="Normal",h[h.Shadow=3]="Shadow",h[h.ShadowHighlight=4]="ShadowHighlight",h[h.ShadowExcludeHighlight=5]="ShadowExcludeHighlight",h[h.Highlight=6]="Highlight",h[h.Alpha=7]="Alpha",h[h.ObjectAndLayerIdColor=8]="ObjectAndLayerIdColor",h[h.COUNT=9]="COUNT"}(h||(h={}));export{h as ShaderOutput};
|
package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as o}from"../../../../../../core/maybe.js";import{I as r}from"../../../../../../chunks/mat4f64.js";import{addNearFar as e}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as t}from"../ShaderOutput.js";import{SliceDraw as i}from"../Slice.glsl.js";import{Transform as a}from"../Transform.glsl.js";import{NormalAttribute as s,NormalAttributeType as l}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as d}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as n}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as c}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as u}from"../output/OutputDepth.glsl.js";import{OutputHighlight as m}from"../output/OutputHighlight.glsl.js";import{VisualVariables as p}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as v}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as f}from"../util/View.glsl.js";import{glsl as g}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as h}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as x}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as j}from"../../../lib/basicInterfaces.js";function b(b,O){const{vertex:w,fragment:C}=b,T=O.hasModelTransformation;T&&w.uniforms.add(new h("model",(e=>o(e.modelTransformation)?e.modelTransformation:r)));const V=O.hasColorTexture&&O.alphaDiscardMode!==j.Opaque;switch(O.output){case t.Depth:case t.Shadow:case t.ShadowHighlight:case t.
|
|
5
|
+
import{isSome as o}from"../../../../../../core/maybe.js";import{I as r}from"../../../../../../chunks/mat4f64.js";import{addNearFar as e}from"../ForwardLinearDepth.glsl.js";import{ShaderOutput as t}from"../ShaderOutput.js";import{SliceDraw as i}from"../Slice.glsl.js";import{Transform as a}from"../Transform.glsl.js";import{NormalAttribute as s,NormalAttributeType as l}from"../attributes/NormalAttribute.glsl.js";import{ObjectAndLayerIdColor as d}from"../attributes/ObjectAndLayerIdColor.glsl.js";import{TextureCoordinateAttribute as n}from"../attributes/TextureCoordinateAttribute.glsl.js";import{VertexNormal as c}from"../attributes/VertexNormal.glsl.js";import{OutputDepth as u}from"../output/OutputDepth.glsl.js";import{OutputHighlight as m}from"../output/OutputHighlight.glsl.js";import{VisualVariables as p}from"../shading/VisualVariables.glsl.js";import{DiscardOrAdjustAlphaPass as v}from"../util/AlphaDiscard.glsl.js";import{addProjViewLocalOrigin as f}from"../util/View.glsl.js";import{glsl as g}from"../../shaderModules/interfaces.js";import{Matrix4PassUniform as h}from"../../shaderModules/Matrix4PassUniform.js";import{Texture2DPassUniform as x}from"../../shaderModules/Texture2DPassUniform.js";import{AlphaDiscardMode as j}from"../../../lib/basicInterfaces.js";function b(b,O){const{vertex:w,fragment:C}=b,T=O.hasModelTransformation;T&&w.uniforms.add(new h("model",(e=>o(e.modelTransformation)?e.modelTransformation:r)));const V=O.hasColorTexture&&O.alphaDiscardMode!==j.Opaque;switch(O.output){case t.Depth:case t.Shadow:case t.ShadowHighlight:case t.ShadowExcludeHighlight:case t.ObjectAndLayerIdColor:f(w,O),b.include(a,O),b.include(n,O),b.include(p,O),b.include(u,O),b.include(i,O),b.include(d,O),e(b),b.varyings.add("depth","float"),V&&C.uniforms.add(new x("tex",(o=>o.texture))),w.code.add(g`
|
|
6
6
|
void main(void) {
|
|
7
7
|
vpos = calculateVPos();
|
|
8
8
|
vpos = subtractOrigin(vpos);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ShaderOutput as t}from"../ShaderOutput.js";import{RgbaFloatEncoding as a}from"../util/RgbaFloatEncoding.glsl.js";import{glsl as e}from"../../shaderModules/interfaces.js";function o(o,l){switch(o.fragment.include(a),l.output){case t.Shadow:case t.ShadowHighlight:case t.
|
|
5
|
+
import{ShaderOutput as t}from"../ShaderOutput.js";import{RgbaFloatEncoding as a}from"../util/RgbaFloatEncoding.glsl.js";import{glsl as e}from"../../shaderModules/interfaces.js";function o(o,l){switch(o.fragment.include(a),l.output){case t.Shadow:case t.ShadowHighlight:case t.ShadowExcludeHighlight:o.extensions.add("GL_OES_standard_derivatives"),o.fragment.code.add(e`float _calculateFragDepth(const in float depth) {
|
|
6
6
|
const float SLOPE_SCALE = 2.0;
|
|
7
7
|
const float BIAS = 20.0 * .000015259;
|
|
8
8
|
float m = max(abs(dFdx(depth)), abs(dFdy(depth)));
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{clamp as t}from"../../../../core/mathUtils.js";import{Milliseconds as i}from"../../../../core/time.js";class e{constructor(){this._step=m,this._dilation=1,this._firstIdleTime=0}frame(e,n){n?0===this._firstIdleTime&&(this._firstIdleTime=performance.now()):this._firstIdleTime=0;const p=n?performance.now()-this._firstIdleTime:0;if(p>=r+o)return this._step=i(1/0),void(this._dilation=1);const a=t(e/s,m,l);this._step===1/0?this._step=i(a):this._step=i(this._step*_+a*(1-_)),this._dilation=p>=r?h:1}get value(){return this._step}get timeDilation(){return this._dilation}clear(){this._step=i(0)}}const s=.5,r=i(6e4),o=i(5e3),h=10,_=.9,n=30,m=i(1e3/1),l=i(1e3/n);export{e as AnimationTimeStep};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{
|
|
5
|
+
import{isSome as t}from"../../../../core/maybe.js";import{Milliseconds as e}from"../../../../core/time.js";class i{constructor(){this.enabled=!0,this._time=e(0)}get time(){return this._time}advance({deltaTime:i,fixedTime:m}){return t(m)?this._time!==m&&(this._time=m,!0):(this._time=e(this._time+i),0!==i)}}class m{constructor(t,e){this.deltaTime=t,this.fixedTime=e}}export{i as AnimationTimer,m 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.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{ResourceState as e}from"./basicInterfaces.js";class t{constructor(e){this._material=e.material,this._techniqueRepository=e.techniqueRep,this._output=e.output}dispose(){this._techniqueRepository.release(this._technique)}get technique(){return this._technique}get _stippleTextureRepository(){return this._techniqueRepository.constructionContext.stippleTextureRepository}ensureTechnique(e,t
|
|
5
|
+
import{ResourceState as e}from"./basicInterfaces.js";class t{constructor(e){this._material=e.material,this._techniqueRepository=e.techniqueRep,this._output=e.output}dispose(){this._techniqueRepository.release(this._technique)}get technique(){return this._technique}get _stippleTextureRepository(){return this._techniqueRepository.constructionContext.stippleTextureRepository}ensureTechnique(e,t){return this._technique=this._techniqueRepository.releaseAndAcquire(e,this._material.getConfiguration(this._output,t),this._technique),this._technique}ensureResources(t){return e.LOADED}}export{t as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e}from"../../../../core/maybe.js";import{f as
|
|
5
|
+
import{isSome as e}from"../../../../core/maybe.js";import{f as r}from"../../../../chunks/vec3f64.js";import{NoParameters as t}from"../core/shaderModules/interfaces.js";import{Parameters as s}from"./AnimationTimer.js";import{ContentObject as i}from"./ContentObject.js";import{ContentObjectType as a}from"./ContentObjectType.js";import{Default3D as n}from"./DefaultVertexAttributeLocations.js";import{copyParameters as p,updateParameters as d}from"../materials/internal/MaterialUtil.js";class h extends i{constructor(e,t){super(),this.type=a.Material,this.supportsEdges=!1,this._visible=!0,this._renderPriority=0,this._insertOrder=0,this._vertexAttributeLocations=n,this._pp0=r(0,0,1),this._pp1=r(0,0,0),this._parameters=p(e,t),this.validateParameters(this._parameters)}dispose(){}get parameters(){return this._parameters}update(e){return!1}setParameters(e,r=!0){d(this._parameters,e)&&(this.validateParameters(this._parameters),r&&this.parametersChanged())}validateParameters(e){}get visible(){return this._visible}set visible(e){e!==this._visible&&(this._visible=e,this.parametersChanged())}shouldRender(e){return this.isVisible()&&this.isVisibleForOutput(e.output)&&0!=(this.renderOccluded&e.renderOccludedMask)}isVisibleForOutput(e){return!0}get renderOccluded(){return this.parameters.renderOccluded}get renderPriority(){return this._renderPriority}set renderPriority(e){e!==this._renderPriority&&(this._renderPriority=e,this.parametersChanged())}get insertOrder(){return this._insertOrder}set insertOrder(e){e!==this._insertOrder&&(this._insertOrder=e,this.parametersChanged())}get vertexAttributeLocations(){return this._vertexAttributeLocations}isVisible(){return this._visible}parametersChanged(){e(this.repository)&&this.repository.materialChanged(this)}intersectDraped(e,r,t,s,i,a){return this._pp0[0]=this._pp1[0]=s[0],this._pp0[1]=this._pp1[1]=s[1],this.intersect(e,r,t,this._pp0,this._pp1,i)}}class o extends s{constructor(e,r,t){super(r,t),this.camera=e}}var c;!function(e){e[e.Occlude=1]="Occlude",e[e.Transparent=2]="Transparent",e[e.OccludeAndTransparent=4]="OccludeAndTransparent",e[e.OccludeAndTransparentStencil=8]="OccludeAndTransparentStencil",e[e.Opaque=16]="Opaque"}(c||(c={}));class u extends t{constructor(){super(...arguments),this.renderOccluded=c.Occlude}}export{h as Material,u as MaterialParameters,c as RenderOccludedFlag,o as UpdateParameters};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import has from"../../../../core/has.js";import{NestedMap as e}from"../../../../core/NestedMap.js";import{RenderState as a}from"../../../support/RenderState.js";var t;function i(i=has("enable-feature:high-quality-idle")){const s=new e;return i&&(s.set(a.INTERACTING,t.Antialiasing,!0),s.set(a.IDLE,t.Antialiasing,!0),s.set(a.INTERACTING,t.HighQualityTransparency,!0),s.set(a.IDLE,t.HighQualityTransparency,!0),s.set(a.INTERACTING,t.RealisticAtmosphere,!0),s.set(a.IDLE,t.RealisticAtmosphere,!0),s.set(a.IDLE,t.SSAO,!0),s.set(a.IDLE,t.WaterReflection,!0),s.set(a.IDLE,t.PhysicalPixelRendering,!0)),s.set(a.ANIMATING,t.ShadowMapUpdate,!0),s.set(a.INTERACTING,t.ShadowMapUpdate,!0),s.set(a.IDLE,t.ShadowMapUpdate,!0),s.set(a.IDLE,t.HighQualityVoxel,!0),s}!function(e){e[e.Antialiasing=0]="Antialiasing",e[e.HighQualityTransparency=1]="HighQualityTransparency",e[e.HighQualityVoxel=2]="HighQualityVoxel",e[e.RealisticAtmosphere=3]="RealisticAtmosphere",e[e.SSAO=4]="SSAO",e[e.WaterReflection=5]="WaterReflection",e[e.ShadowMapUpdate=6]="ShadowMapUpdate",e[e.PhysicalPixelRendering=7]="PhysicalPixelRendering"}(t||(t={})),has.add("enable-feature:high-quality-idle",!0);export{t as RenderFeature,i as setupFeatureDefaults};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.26/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import has from"../../../../core/has.js";import{clamp as n}from"../../../../core/mathUtils.js";import{unwrapOr as i,removeMaybe as a,disposeMaybe as h,isSome as o,isNone as d,applySome as l,unwrap as _}from"../../../../core/maybe.js";import c from"../../../../core/PooledArray.js";import{watch as p,syncAndInitial as m,initial as g,sync as u}from"../../../../core/reactiveUtils.js";import{Milliseconds as f}from"../../../../core/time.js";import{property as T}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as R}from"../../../../core/accessorSupport/decorators/subclass.js";import{h as b,a as E,m as A}from"../../../../chunks/mat4.js";import{I as P,c as S}from"../../../../chunks/mat4f64.js";import{a as y}from"../../../../chunks/boundedPlane.js";import{MINIMUM_IDLE_ANIMATION_FPS_TIME as O,MAXIMUM_IDLE_ANIMATION_FPS_TIME as w,MAXIMUM_ANIMATION_LOAD as C}from"../../support/animationUtils.js";import D from"../../support/debugFlags.js";import{TransparencyMode as x}from"../../terrain/TerrainRenderer.js";import{RenderPassManager as I}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as H}from"../core/shaderLibrary/ShaderOutput.js";import{HUDTransparentRenderStyle as L}from"../core/shaderLibrary/hud/HUDUniforms.js";import{Decorations as v,RenderRequestType as M,StencilBits as N}from"./basicInterfaces.js";import{BoundingInfo as U}from"./BoundingInfo.js";import{ZERO as F,union as j}from"./depthRange.js";import{depthRangeFromScene as q}from"./depthRangeUtils.js";import{createEmptyDepthTexture as G}from"./glUtil3D.js";import{Highlight as V}from"./Highlight.js";import{RenderOccludedFlag as B}from"./Material.js";import{OffscreenRendering as W}from"./OffscreenRendering.js";import{RenderContext as k}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as Q}from"./rendererUtils.js";import{RenderPluginManager as Y}from"./RenderPluginManager.js";import{RenderSlot as X}from"./RenderSlot.js";import{RenderStateFeature as z,setupFeatureDefaults as J}from"./RenderStateFeature.js";import{ShadowAccumulator as K}from"./ShadowAccumulator.js";import{ShadowHighlight as Z}from"./ShadowHighlight.js";import{ShadowMap as $,SnapshotSlot as ee}from"./ShadowMap.js";import re from"./SliceHelper.js";import{SmaaRenderPass as te}from"./SmaaRenderPass.js";import{SSAOHelper as se}from"./SSAOHelper.js";import{TransparencyPassType as ne}from"./TransparencyPassType.js";import{EdgeView as ie}from"./edgeRendering/EdgeView.js";import{Transparency as ae}from"./edgeRendering/interfaces.js";import{MergedRenderer as he}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as oe}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as de,PerformanceCategory as le}from"../statistics/RendererPerformanceInfo.js";import{RenderState as _e}from"../../../support/RenderState.js";import{ClearBufferBit as ce,PixelFormat as pe,PixelType as me}from"../../../webgl/enums.js";const ge=.9;let ue=class extends r{get _bindParameters(){return this._renderContext.bindParameters}isFeatureEnabled(e,r=this._state){return i(this._qualityLevelFeatures.get(r,e),!1)}setFeatureEnabled(e,r,t){this._qualityLevelFeatures.set(r,e,t),this.notifyChange("_qualityLevelFeatures"),this._requestRender()}get _antialiasing(){return this._antialiasingEnabled||this.isFeatureEnabled(z.Antialiasing)}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(z.HighQualityTransparency)}get hasWaterReflection(){return this.hasWater&&(this._waterReflectionEnabled||this.isFeatureEnabled(z.WaterReflection))}get hasWater(){return this._hasWater||this._hasOverlayWater}constructor(e,r,t,n,i,a,h,o){super({}),this._materialRepository=e,this._shaderTechniqueRepository=t,this._rctx=n,this._compositingHelper=i,this._magnifierHelper=a,this._requestRender=h,this._stage=o,this._materialRenderers=new c,this._needsTransparentPass=!1,this._hasHUDElements=!1,this._hasHighlights=!1,this._hasWater=!1,this._hasOverlayWater=!1,this._renderOverlay=e=>{},this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new re,this._state=_e.IDLE,this._qualityLevelFeatures=J(),this._antialiasingEnabled=!0,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=x.Opaque,this._waterReflectionEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=O,this._handles=new s,this._renderHiddenTransparentEdges=()=>{},this._oitUsed=!1,this._smaaPass=new te(this._rctx,t),h(),this._offscreenRendering=new W(this._rctx,this._compositingHelper),this.performanceInfo=new de(this._rctx),this._shadowMap=new $(this._rctx,o.viewingMode),this._ssaoHelper=new se(t,this._rctx,h),this._highlight=new V(t,this._rctx),this._shadowHighlight=new Z(this._rctx,o.viewingMode),this._shadowAccumulator=new K(this._rctx,t,o,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t),this._renderShadowCascades(H.Shadow,e.shadowMap),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),h),this._renderContext=new k(this._rctx,this._offscreenRendering,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new Y({renderContext:this._renderContext,techniqueRepository:t,textureRepository:r,materialRepository:this._materialRepository,requestRender:h,controller:o}),this.renderPassManager=new I(this._rctx,this._shaderTechniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this._handles.add([p((()=>this._stage.state.camera),(()=>h()),m),p((()=>D.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(ae.TRANSPARENT):()=>{},h()}),g),p((()=>this._ssaoEnabled||this.isFeatureEnabled(z.SSAO)),(e=>this._ssaoHelper.enabled=e),m)])}normalizeCtorArgs(){return{}}destroy(){this._handles.destroy(),this._smaaPass.dispose(),this._gpuTimerHandle=a(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreenRendering.dispose(),this._fallbackDepthStencilTexture=h(this._fallbackDepthStencilTexture),this._shadowMap.dispose(),this._ssaoHelper.dispose(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),U.prune()}disposeOffscreenBuffers(){this._offscreenRendering.dispose(),this._shadowMap.dispose(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.updating||o(this._edgeView)&&this._edgeView.updating||this._shadowAccumulator.running||!this.isCameraFinal}ensureEdgeView(){return d(this._edgeView)&&(this._edgeView=new ie({rctx:this._rctx,renderSR:this._stage.renderSR,viewingMode:this._stage.viewingMode,techniqueRepository:this._shaderTechniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:e=>this._stage.resourceController.immediate.schedule(e)}),this._handles.add(p((()=>l(this._edgeView,(e=>e.updating))),(()=>this._requestRender()),u)),this._requestRender()),this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return b(this._bindParameters.ssr.reprojectionMatrix,P)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.screenSpaceReflectionsEnabled&&t.ssr.enabled!==e.screenSpaceReflectionsEnabled&&(t.ssr.enabled=e.screenSpaceReflectionsEnabled,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),o(e.environment)){o(e.environment.weather)&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible),void 0!==e.environment.lighting.ambientOcclusionEnabled&&this._ssaoEnabled!==e.environment.lighting.ambientOcclusionEnabled&&(this._ssaoEnabled=e.environment.lighting.ambientOcclusionEnabled,this._requestRender()),void 0!==e.environment.lighting.waterReflectionEnabled&&this._waterReflectionEnabled!==e.environment.lighting.waterReflectionEnabled&&(this._waterReflectionEnabled=e.environment.lighting.waterReflectionEnabled,this._requestRender());const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}e.background&&this._offscreenRendering.background!==e.background&&(this._offscreenRendering.background=e.background,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasingEnabled!==e.antialiasingEnabled&&(this._antialiasingEnabled=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.renderOverlay&&this._renderOverlay!==e.renderOverlay&&(this._renderOverlay=e.renderOverlay,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=_(e.slicePlane),this._requestRender()),void 0!==e.terrainRenderingEnabled&&this._terrainRenderingEnabled!==e.terrainRenderingEnabled&&(this._terrainRenderingEnabled=e.terrainRenderingEnabled,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:n}=e;if(0===t.length&&0===s.length&&0===n.length)return;const i=Q(e);let a=!1;i.forEach(((t,s)=>{if(r.done)return;let n=this._materialRenderers.find((e=>e.material===s));d(n)&&t.adds.length>0&&(n=new he(this._rctx,this._materialRepository,s),this._materialRenderers.push(n)),n&&(n.modify(t),n.isEmpty&&(a=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),a&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._hasHighlights=this._materialRenderers.some((e=>e.hasHighlights)),this._bindParameters.hasOccludees=this._materialRenderers.some((e=>e.hasOccludees)),this._hasWater=this._materialRenderers.some((e=>e.hasWater)),this._hasHUDElements=this._materialRenderers.some((e=>e.requiresSlot(X.LINE_CALLOUTS_HUD_DEPTH,H.Color)||e.requiresSlot(X.HUD_MATERIAL,H.Color)||e.requiresSlot(X.LABEL_MATERIAL,H.Color))),this._requestRender()}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?a(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep}render(e,r,t,s,n){this._isRendering=!0,this.performanceInfo.startFrame();const{camera:i,contentCamera:a,mode:h}=t;this._state=h,this._renderOverlay(n),this.performanceInfo.advance(le.OVERLAY),this._renderContext.time=n,this._bindParameters.transparencyPassType=ne.NONE;const l=this._offscreenRendering;l.setupRenderTarget(this.hasWaterReflection);const _=y(this._sliceHelper.plane);s===v.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),i.setGLViewport(this._rctx),this._prepare(i,a),this._renderPlugins.prepareRender(),this.performanceInfo.advance(le.PREPARE);const c=this._computeDepthRange(i);this._renderShadowMap(e,i,this._bindParameters.lighting.mainLight.direction,c),this.performanceInfo.advance(le.SHADOW_MAP),l.initializeFrame(i),this._ensureBindParameters(i,a),this._renderLinearDepth(),this.performanceInfo.advance(le.LINEAR_DEPTH),this._accumulateShadows(c,i,a),this.performanceInfo.advance(le.ACCUMULATED_SHADOWS),this._renderNormal(),this.performanceInfo.advance(le.NORMALS),this._ensureBindParametersSSR(),this._renderSSAO(),this.performanceInfo.advance(le.SSAO),this._renderContext.output=H.Color,l.bindFramebuffer(),this._renderOpaqueGeometry(),this.performanceInfo.advance(le.OPAQUE);const p=this._terrainRenderingEnabled&&(this._terrainTransparency===x.Semitransparent||this._terrainTransparency===x.TransparentWithDraped),m=this._highQualityTransparency&&p;this._renderTerrainLinearDepth(m),this._setMultipassEnabled(m),this._setTerrainCulling(m),this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(le.OPAQUE_EDGES),this._offscreenRendering.bindTarget(this._offscreenRendering.currentColorTarget,this._offscreenRendering.mainDepth),this._renderSlot(X.VOXEL),this.performanceInfo.advance(le.VOXEL),this._renderHiddenTransparentEdges();const g=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;g&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(le.TRANSPARENT),this._renderGeometryLinearDepth(m);const u=this._renderHUDVisibility(m);m||this._renderInternalSlot(X.LINE_CALLOUTS),this.performanceInfo.advance(le.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(le.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(ae.TRANSPARENT,m),this.performanceInfo.advance(le.TRANSPARENT_EDGES),this._renderTransparentTerrain(),p&&u&&(m?this._renderLineCallouts(L.Occluded):l.compositeTransparentTerrainOntoHUDVisibility(this._bindParameters),this._renderHUD(L.Occluded,l.framebuffer),this.performanceInfo.advance(le.HUD_OCCLUDED)),this.performanceInfo.advance(le.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),p&&(l.compositeTransparentTerrainOntoMain(this._bindParameters),m&&(this._renderEdges(ae.OPAQUE),this.performanceInfo.advance(le.OPAQUE_EDGES),g&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(le.TRANSPARENT),this._renderEdges(ae.TRANSPARENT),this.performanceInfo.advance(le.TRANSPARENT_EDGES))),m&&this._renderLineCallouts(L.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),l.renderToTargets((()=>{this._renderInternalSlot(X.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(X.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(X.LASERLINES)}),l.currentColorTarget,l.mainDepth),this.performanceInfo.advance(le.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl&&l.renderTmpAndCompositeToMain((()=>this._renderSlot(X.LASERLINES_CONTRAST_CONTROL)),this._bindParameters,oe.PremultipliedAlpha),this.performanceInfo.advance(le.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(le.OCCLUDED);const f=s===v.ON&&this._magnifierHelper.enabled,T=f&&d(e)?this._offscreenRendering.getFramebuffer(this._offscreenRendering.tmpColor,this._offscreenRendering.tmpDepth):e;this._rctx.bindFramebuffer(T);const R=this._offscreenRendering.colorTexture;!this._renderAntiAliasing(R)&&o(R)&&this._compositingHelper.composite(this._bindParameters,R,oe.None),this.performanceInfo.advance(le.ANTIALIASING),this._renderHUD(L.NotOccluded,T),this.performanceInfo.advance(le.HUD),this._renderHighlights(T,this._bindParameters),this.performanceInfo.advance(le.HIGHLIGHTS),f&&this._magnifierHelper.render(this._rctx,this._bindParameters),T!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,this._offscreenRendering.tmpColorTexture,oe.None)),this._disposeOITBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=_,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_renderObjectAndLayerIdColor(e){o(e)&&has("enable-feature:objectAndLayerId-rendering")&&(this._rctx.bindFramebuffer(e),this._offscreenRendering.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(H.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreenRendering.renderToFBO((()=>{this._bindParameters.renderTransparentlyOccludedHUD=L.NotOccluded,this._renderInternalSlot(X.HUD_MATERIAL)}),void 0,!0,!0))}finish(e){this._hasAnimations||(this._animationTimestep=f(0));const r=this.performanceInfo.gpuSamplingEnabled,t=e===M.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),i=Math.max(e,s),a=n(i/C,w,O);this._animationTimestep=f(this._animationTimestep*ge+a*(1-ge))}}readDepthPixels(e,r,t){const s=this._offscreenRendering.bindTarget(this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth);if(!this._needsLinearDepth){this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const r=ce.COLOR_BUFFER_BIT|ce.DEPTH_BUFFER_BIT|ce.STENCIL_BUFFER_BIT;this._rctx.clearSafe(r),this._renderGeometryAndTransparentTerrainPass(H.Depth)}s.readPixels(r[0],r[1],r[2],r[3],pe.RGBA,me.UNSIGNED_BYTE,t)}readHUDVisibility(e,r,t,s,n){this._offscreenRendering.bindTarget(this._offscreenRendering.hudVisibility).readPixels(e,r,t,s,pe.RGBA,me.UNSIGNED_BYTE,n)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassEnabled(e){this._bindParameters.multipassTerrain.enabled=this._bindParameters.multipassGeometry.enabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderSlot(e){this._bindParameters.slot=e,this._renderPlugins.render()}_renderEdges(e,r=!1){const t=this._edgeView;o(t)&&t.shouldRender()&&this._offscreenRendering.renderTmpAndCompositeToMain((()=>t.render(this._bindParameters,e)),this._bindParameters,oe.Alpha,r)}_renderShadowMap(e,r,t,s){const n=this._shadowMap;n.enabled&&this.isFeatureEnabled(z.ShadowMapUpdate)&&(n.start(r,t,s),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(H.ShadowHighlight,this._shadowMap,(e=>n.takeCascadeSnapshotTo(e,ee.Highlight))),n.clear(),this._renderShadowCascades(H.ShadowExludeHighlight,this._shadowMap,(e=>{n.takeCascadeSnapshotTo(e,ee.Default),this._renderGeometryAndTransparentTerrainPass(H.ShadowHighlight)}))):this._renderShadowCascades(H.Shadow),n.finish(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap,t=(e=>{})){for(const s of r.cascades)s.camera.setGLViewport(this._rctx),this._prepare(s.camera,s.camera),this._renderGeometryAndTransparentTerrainPass(e),t(s)}get _needsLinearDepth(){return this._ssaoHelper.enabled||this._renderPlugins.needsLinearDepth||this.hasWaterReflection||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?this._offscreenRendering.renderToTargets((()=>this._renderGeometryAndTransparentTerrainPass(H.Depth)),this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.linearDepth),this._bindParameters.linearDepthTexture=this._offscreenRendering.linearDepthTexture}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=H.Depth,this._offscreenRendering.renderToTargets((()=>this._renderTransparentTerrain()),this._offscreenRendering.terrainLinearDepth,this._offscreenRendering.tmpDepth,[-1e10,-1e10,-1e10,1],!0,!0),this._renderContext.output=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.terrainLinearDepth);this._bindParameters.multipassTerrain.linearDepthTexture=this._offscreenRendering.terrainLinearDepthTexture}_renderGeometryLinearDepth(e){if(e){const e=this._renderContext.output;this._offscreenRendering.renderToTargets((()=>this._renderGeometryPass(H.Depth)),this._offscreenRendering.geometryLinearDepth,this._offscreenRendering.tmpDepth,[1,1,1,1],!0,!0),this._renderContext.output=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.geometryLinearDepth);this._bindParameters.multipassGeometry.linearDepthTexture=this._offscreenRendering.geometryLinearDepthTexture}get _needsNormal(){return this._ssaoHelper.enabled}_renderNormal(){this._needsNormal?this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(H.Normal)}),this._offscreenRendering.normal,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.normal)}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return F;const r=q(e,this._materialRenderers,this._stage.layers);return j(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(){this._ssaoHelper.computeSSAO(this._bindParameters,this._offscreenRendering.linearDepthTexture,this._offscreenRendering.normalTexture)}_renderOpaqueGeometry(){this._renderSlot(X.INTEGRATED_MESH),this._renderSlot(X.OPAQUE_TERRAIN),this._renderInternalSlot(X.OPAQUE_MATERIAL),this._renderSlot(X.OPAQUE_MATERIAL),this._renderSlot(X.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(X.TRANSPARENT_MATERIAL),this._renderSlot(X.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){this._renderSlot(X.TRANSPARENT_TERRAIN)}_renderHUDVisibility(e){let r=!1;return this._renderContext.offscreenRenderingHelper&&this._renderContext.offscreenRenderingHelper.renderHUDVisibility((()=>{this._bindParameters.hudVisibilityTexture=this._renderContext.offscreenRenderingHelper.hudVisibilityTexture,r=this._renderInternalSlot(X.OCCLUSION_PIXELS)}),e),r}_renderLineCallouts(e){this._bindParameters.renderTransparentlyOccludedHUD=e,e===L.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderInternalSlot(X.LINE_CALLOUTS)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderInternalSlot(X.LINE_CALLOUTS)}_renderHUD(e,r){this._hasHUDElements&&(this._oitEnabled?(this._renderOrderIndependentTransparency((()=>this._renderHUDElements(e)),!0),this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,this._offscreenRendering.hudColorTexture,oe.PremultipliedAlpha)):e===L.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderHUDElements(L.Occluded)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderHUDElements(e))}_renderHUDElements(e){this._bindParameters.renderTransparentlyOccludedHUD=e,this._renderInternalSlot(X.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(X.HUD_MATERIAL),this._renderInternalSlot(X.LABEL_MATERIAL)}get _needsHighlight(){return this._hasHighlights||this._renderPlugins.needsHighlight}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this._needsHighlight}_renderHighlights(e,r){if(!this._needsHighlight)return void this._offscreenRendering.disposeTarget(this._offscreenRendering.highlight);const t=this._highlight,s=this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(H.Highlight),this._rctx.clearSafe(ce.DEPTH_BUFFER_BIT),this._renderHUDElements(L.Both)}),this._offscreenRendering.highlight,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0);this._bindParameters.highlightColorTexture=s.colorTexture,this._needsShadowHighlight&&this._shadowHighlight.render(r,e),t.render(this._bindParameters,s,e)}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&o(this._offscreenRendering.linearDepthTexture)&&this._shadowAccumulator.renderAccumulation(this._offscreenRendering.linearDepthTexture,e,r,t)}_renderOrderIndependentTransparency(e,r){const t=t=>{this._bindParameters.transparencyPassType=t,this._offscreenRendering.renderOITPass((()=>e()),t,r)},s=this._renderContext.output;this._renderContext.output=H.Alpha,t(ne.Alpha),this._renderContext.output=H.Color,t(ne.Color),t(ne.FrontFace),this._offscreenRendering.compositeTransparentOntoOpaque(this._bindParameters,r),this._bindParameters.transparencyPassType=ne.NONE,this._renderContext.output=s,this._oitUsed=!0}_disposeOITBuffers(){this._oitUsed||(this._offscreenRendering.disposeTarget(this._offscreenRendering.alphaFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.colorFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.frontFaceTarget)),this._oitUsed=!1}_renderOccluded(){let e=0;this._materialRenderers.forAll((({material:r})=>{r&&r.isVisible()&&r.renderOccluded===B.OccludeAndTransparentStencil&&(e|=r.renderOccluded,Re.push(r))}));const r=this._offscreenRendering,t=(t,s,n,i,a)=>{0!=(e&s)&&(r.renderToTargets(n,r.tmpColor,r.mainDepth,[0,0,0,0],i,a),r.compositeOccludedOntoMain(this._bindParameters,t))};0!==Re.length&&(this._renderInternalSlot(X.OCCLUDER_MATERIAL,Re),t(.5,B.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(X.TRANSPARENT_OCCLUDER_MATERIAL,Re)),!1,!1),Re.length=0),this._materialRenderers.forAll((({material:r})=>{r&&r.isVisible()&&(r.renderOccluded===B.OccludeAndTransparent||r.renderOccluded===B.Transparent||r.renderOccluded===B.Opaque)&&(e|=r.renderOccluded,Te.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const n=e=>{this._renderContext.renderOccludedMask=e,s>B.Occlude&&this._renderSlot(X.OCCLUDED_TERRAIN),this._renderInternalSlot(X.OPAQUE_MATERIAL,Te),this._renderInternalSlot(X.TRANSPARENT_MATERIAL,Te),this._renderInternalSlot(X.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,Te),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=H.Color,t(.5,B.OccludeAndTransparent,(()=>n(B.OccludeAndTransparent)),!0,N.OutlineVisualElementMask),t(.5,B.Transparent,(()=>n(B.Transparent)),!0,N.OutlineVisualElementMask),t(1,B.Opaque,(()=>n(B.Opaque)),!0,N.OutlineVisualElementMask),Te.length=0}_renderAntiAliasing(e){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&o(e))return this._smaaPass.render(e),!0}else this._smaaPass.disable();return!1}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.requiresSlot(X.TRANSPARENT_MATERIAL,H.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibilityTexture=t.hudVisibilityTexture,this._bindParameters.mainColorTexture=t.mainColorTexture,this._bindParameters.highlightDepthTexture=t.depthTexture??this._getFallbackDepthTexture()}_ensureBindParametersSSR(){this.hasWaterReflection?(this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=P:(E(Ee,this._bindParameters.camera.viewMatrix),E(be,this._bindParameters.camera.projectionMatrix),A(Ae,Ee,be),A(Ae,this._renderContext.lastFrameCamera.viewMatrix,Ae),A(Ae,this._renderContext.lastFrameCamera.projectionMatrix,Ae),this._reprojectionMatrix=Ae),this._bindParameters.ssr.lastFrameColorTexture=this._offscreenRendering.lastFrameColorTexture):this._bindParameters.ssr.lastFrameColorTexture=null,this._bindParameters.ssr.enabled=this.hasWaterReflection}_renderInternalSlot(e,r){let t=!1;return this._bindParameters.slot=e,o(r)?r.forEach((e=>{if(!e.shouldRender(this._renderContext))return;const r=this._materialRenderers.find((r=>r.material===e));o(r)&&(t=r.render(this._renderContext.output,this._bindParameters)||t)})):this._materialRenderers.forAll((e=>{e.material.shouldRender(this._renderContext)&&e.render(this._renderContext.output,this._bindParameters)&&(t=!0)})),t}_getFallbackDepthTexture(){return this._fallbackDepthStencilTexture||(this._fallbackDepthStencilTexture=G(this._rctx)),this._fallbackDepthStencilTexture}get gpuMemoryUsage(){return{offscreen:this._offscreenRendering?.gpuMemoryUsage??0,highlights:(this._highlight?.gpuMemoryUsage??0)+(this._shadowHighlight?.gpuMemoryUsage??0),shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get test(){const e=this;return{offscreen:this._offscreenRendering,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,getFramebufferTexture:r=>{switch(r){case fe.Color:return e._offscreenRendering.colorTexture;case fe.LinearDepth:return e._offscreenRendering.linearDepthTexture;case fe.Normals:return e._offscreenRendering.normalTexture;case fe.ShadowMap:return e._shadowMap.depthTexture;case fe.HudVisibility:return e._offscreenRendering.hudVisibilityTexture;case fe.Highlight:return e._offscreenRendering.highlightTexture}}}}};var fe;e([T()],ue.prototype,"_shadowAccumulator",void 0),e([T()],ue.prototype,"_state",void 0),e([T({readOnly:!0})],ue.prototype,"_qualityLevelFeatures",void 0),e([T()],ue.prototype,"_antialiasingEnabled",void 0),e([T({readOnly:!0})],ue.prototype,"_antialiasing",null),e([T()],ue.prototype,"_ssaoEnabled",void 0),e([T()],ue.prototype,"_smaaPass",void 0),e([T({autoDestroy:!0})],ue.prototype,"_edgeView",void 0),e([T()],ue.prototype,"updating",null),e([T()],ue.prototype,"isCameraFinal",null),ue=e([R("esri.views.3d.webgl-engine.lib.Renderer")],ue),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.Normals=2]="Normals",e[e.ShadowMap=3]="ShadowMap",e[e.HudVisibility=4]="HudVisibility",e[e.Highlight=5]="Highlight"}(fe||(fe={}));const Te=[],Re=[],be=S(),Ee=S(),Ae=S();export{fe as FramebufferId,ue as Renderer};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import{update as t}from"../../../../core/arrayUtils.js";import s from"../../../../core/Handles.js";import has from"../../../../core/has.js";import{unwrapOr as n,removeMaybe as i,disposeMaybe as a,isSome as h,isNone as d,applySome as o,unwrap as l}from"../../../../core/maybe.js";import _ from"../../../../core/PooledArray.js";import{watch as c,syncAndInitial as p,initial as m,sync as g}from"../../../../core/reactiveUtils.js";import{property as u}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as f}from"../../../../core/accessorSupport/decorators/subclass.js";import{h as T,a as R,m as b}from"../../../../chunks/mat4.js";import{I as E,c as A}from"../../../../chunks/mat4f64.js";import{a as P}from"../../../../chunks/boundedPlane.js";import S from"../../support/debugFlags.js";import{TransparencyMode as y}from"../../terrain/TerrainRenderer.js";import{RenderPassManager as O}from"../core/renderPasses/RenderPassManager.js";import{ShaderOutput as w}from"../core/shaderLibrary/ShaderOutput.js";import{HUDTransparentRenderStyle as C}from"../core/shaderLibrary/hud/HUDUniforms.js";import{AnimationTimeStep as D}from"./AnimationTimeStep.js";import{Decorations as x,RenderRequestType as I,StencilBits as H}from"./basicInterfaces.js";import{BoundingInfo as L}from"./BoundingInfo.js";import{ZERO as M,union as v}from"./depthRange.js";import{depthRangeFromScene as N}from"./depthRangeUtils.js";import{createEmptyDepthTexture as U}from"./glUtil3D.js";import{Highlight as F}from"./Highlight.js";import{RenderOccludedFlag as j}from"./Material.js";import{OffscreenRendering as G}from"./OffscreenRendering.js";import{RenderContext as V}from"./RenderContext.js";import{splitRenderGeometryChangeSetByMaterial as q}from"./rendererUtils.js";import{RenderFeature as B,setupFeatureDefaults as W}from"./RenderFeature.js";import{RenderPluginManager as k}from"./RenderPluginManager.js";import{RenderSlot as Q}from"./RenderSlot.js";import{ShadowAccumulator as Y}from"./ShadowAccumulator.js";import{ShadowHighlight as X}from"./ShadowHighlight.js";import{ShadowMap as z,SnapshotSlot as J}from"./ShadowMap.js";import K from"./SliceHelper.js";import{SmaaRenderPass as Z}from"./SmaaRenderPass.js";import{SSAOHelper as $}from"./SSAOHelper.js";import{TransparencyPassType as ee}from"./TransparencyPassType.js";import{EdgeView as re}from"./edgeRendering/EdgeView.js";import{Transparency as te}from"./edgeRendering/interfaces.js";import{MergedRenderer as se}from"../materials/renderers/MergedRenderer.js";import{AlphaMode as ne}from"../shaders/CompositingTechniqueConfiguration.js";import{RendererPerformanceInfo as ie,PerformanceCategory as ae}from"../statistics/RendererPerformanceInfo.js";import{RenderState as he}from"../../../support/RenderState.js";import{ClearBufferBit as de,PixelFormat as oe,PixelType as le}from"../../../webgl/enums.js";let _e=class extends r{get _bindParameters(){return this._renderContext.bindParameters}isFeatureEnabled(e,r=this._state){return n(this._renderStateFeatures.get(r,e),!1)}setFeatureEnabled(e,r,t){this._renderStateFeatures.set(r,e,t),this.notifyChange("_renderStateFeatures"),this._requestRender()}get _antialiasing(){return this._antialiasingEnabled||this.isFeatureEnabled(B.Antialiasing)}get _highQualityTransparency(){return this._highQualityTransparencyEnabled||this.isFeatureEnabled(B.HighQualityTransparency)}get hasWaterReflection(){return this.hasWater&&(this._waterReflectionEnabled||this.isFeatureEnabled(B.WaterReflection))}get hasWater(){return this._hasWater||this._hasOverlayWater}constructor(e,r,t,n,i,a,h,d){super({}),this._materialRepository=e,this._shaderTechniqueRepository=t,this._rctx=n,this._compositingHelper=i,this._magnifierHelper=a,this._requestRender=h,this._stage=d,this._materialRenderers=new _,this._needsTransparentPass=!1,this._hasHUDElements=!1,this._hasHighlights=!1,this._hasWater=!1,this._hasOverlayWater=!1,this._renderOverlay=e=>{},this._isRendering=!1,this._fallbackDepthStencilTexture=null,this._sliceHelper=new K,this._state=he.IDLE,this._renderStateFeatures=W(),this._antialiasingEnabled=!0,this._highQualityTransparencyEnabled=!0,this._terrainRenderingEnabled=!0,this._terrainTransparency=y.Opaque,this._waterReflectionEnabled=!1,this._ssaoEnabled=!1,this._hasAnimations=!1,this._animationTimestep=new D,this._handles=new s,this._renderHiddenTransparentEdges=()=>{},this._oitUsed=!1,this._smaaPass=new Z(this._rctx,t),h(),this._offscreenRendering=new G(this._rctx,this._compositingHelper),this.performanceInfo=new ie(this._rctx),this._shadowMap=new z(this._rctx,d.viewingMode),this._ssaoHelper=new $(t,this._rctx,h),this._highlight=new F(t,this._rctx),this._shadowHighlight=new X(this._rctx,d.viewingMode),this._shadowAccumulator=new Y(this._rctx,t,d,(e=>{const r=this.shadowsEnabled;this._shadowMap.enabled=!0,this._prepare(e.camera,e.contentCamera),this._renderPlugins.prepareRender(),this._shadowMap.enabled=r}),((e,r,t)=>{e.shadowMap.start(e.camera,r,t),this._renderShadowCascades(w.Shadow,e.shadowMap),e.camera.setGLViewport(this._rctx),this._prepare(e.camera,e.contentCamera)}),h),this._renderContext=new V(this._rctx,this._offscreenRendering,this._shadowMap,this._ssaoHelper,this._sliceHelper),this._renderPlugins=new k({renderContext:this._renderContext,techniqueRepository:t,textureRepository:r,materialRepository:this._materialRepository,requestRender:h,controller:d}),this.renderPassManager=new O(this._rctx,this._shaderTechniqueRepository),this._renderPlugins.add(this.renderPassManager.slots(),this.renderPassManager),this._handles.add([c((()=>this._stage.state.camera),(()=>h()),p),c((()=>S.EDGES_SHOW_HIDDEN_TRANSPARENT_EDGES),(e=>{this._renderHiddenTransparentEdges=e?()=>this._renderEdges(te.TRANSPARENT):()=>{},h()}),m),c((()=>this._ssaoEnabled||this.isFeatureEnabled(B.SSAO)),(e=>this._ssaoHelper.enabled=e),p)])}normalizeCtorArgs(){return{}}destroy(){this._handles.destroy(),this._smaaPass.dispose(),this._gpuTimerHandle=i(this._gpuTimerHandle),this._materialRenderers.forAll((e=>e.dispose())),this._materialRenderers.clear(),this._offscreenRendering.dispose(),this._fallbackDepthStencilTexture=a(this._fallbackDepthStencilTexture),this._shadowMap.dispose(),this._ssaoHelper.dispose(),this._highlight.dispose(),this._shadowHighlight.dispose(),this._shadowAccumulator.dispose(),L.prune()}disposeOffscreenBuffers(){this._offscreenRendering.dispose(),this._shadowMap.dispose(),this._smaaPass.disable(),this._ssaoHelper.disposeOffscreenBuffers()}get updating(){return this._antialiasing&&this._smaaPass.updating||h(this._edgeView)&&this._edgeView.updating||this._shadowAccumulator.running||!this.isCameraFinal}ensureEdgeView(){return d(this._edgeView)&&(this._edgeView=new re({rctx:this._rctx,renderSR:this._stage.renderSR,viewingMode:this._stage.viewingMode,techniqueRepository:this._shaderTechniqueRepository,setNeedsRender:()=>this._requestRender(),schedule:e=>this._stage.resourceController.immediate.schedule(e)}),this._handles.add(c((()=>o(this._edgeView,(e=>e.updating))),(()=>this._requestRender()),g)),this._requestRender()),this._edgeView}get edgeView(){return this._edgeView}get isCameraFinal(){return T(this._bindParameters.ssr.reprojectionMatrix,E)}set _reprojectionMatrix(e){t(this._bindParameters.ssr.reprojectionMatrix,e)&&this.notifyChange("isCameraFinal")}get shadowsEnabled(){return!!this._shadowMap?.enabled}setParameters(e){const{_shadowMap:r,_bindParameters:t}=this;if(void 0!==e.screenSpaceReflectionsEnabled&&t.ssr.enabled!==e.screenSpaceReflectionsEnabled&&(t.ssr.enabled=e.screenSpaceReflectionsEnabled,this._requestRender()),void 0!==e.shadowMap&&this._shadowMap.enabled!==e.shadowMap&&(this._shadowMap.enabled=e.shadowMap,this._requestRender()),void 0!==e.shadowMapMaxCascades&&r.maxCascades!==e.shadowMapMaxCascades&&(r.maxCascades=e.shadowMapMaxCascades,this._requestRender()),h(e.environment)){h(e.environment.weather)&&(this._bindParameters.weather=e.environment.weather,this._bindParameters.weatherVisible=!!e.weatherVisible),void 0!==e.environment.lighting.ambientOcclusionEnabled&&this._ssaoEnabled!==e.environment.lighting.ambientOcclusionEnabled&&(this._ssaoEnabled=e.environment.lighting.ambientOcclusionEnabled,this._requestRender()),void 0!==e.environment.lighting.waterReflectionEnabled&&this._waterReflectionEnabled!==e.environment.lighting.waterReflectionEnabled&&(this._waterReflectionEnabled=e.environment.lighting.waterReflectionEnabled,this._requestRender());const r="virtual"!==e.environment.lighting.type;t.enableFillLights!==r&&(t.enableFillLights=r,this._requestRender())}e.background&&this._offscreenRendering.background!==e.background&&(this._offscreenRendering.background=e.background,this._requestRender()),void 0!==e.antialiasingEnabled&&this._antialiasingEnabled!==e.antialiasingEnabled&&(this._antialiasingEnabled=e.antialiasingEnabled,this._requestRender()),void 0!==e.highQualityTransparency&&this._highQualityTransparencyEnabled!==e.highQualityTransparency&&(this._highQualityTransparencyEnabled=e.highQualityTransparency,this._requestRender()),void 0!==e.defaultHighlightOptions&&(this._highlight.setDefaultOptions(e.defaultHighlightOptions),this._shadowHighlight.setDefaultOptions(e.defaultHighlightOptions),this._requestRender()),void 0!==e.overlays&&this._bindParameters.overlays!==e.overlays&&(this._bindParameters.overlays=e.overlays,this._requestRender()),void 0!==e.hasOverlayWater&&this._hasOverlayWater!==e.hasOverlayWater&&(this._hasOverlayWater=e.hasOverlayWater,this._requestRender()),void 0!==e.renderOverlay&&this._renderOverlay!==e.renderOverlay&&(this._renderOverlay=e.renderOverlay,this._requestRender()),void 0!==e.slicePlane&&this._sliceHelper.plane!==e.slicePlane&&(this._sliceHelper.plane=l(e.slicePlane),this._requestRender()),void 0!==e.terrainRenderingEnabled&&this._terrainRenderingEnabled!==e.terrainRenderingEnabled&&(this._terrainRenderingEnabled=e.terrainRenderingEnabled,this._requestRender()),void 0!==e.terrainTransparency&&this._terrainTransparency!==e.terrainTransparency&&(this._terrainTransparency=e.terrainTransparency,this._requestRender()),void 0!==e.shadowCastOptions&&this._shadowAccumulator.setOptions(e.shadowCastOptions)}get hasSlicePlane(){return!!this._sliceHelper.plane}get renderPlugins(){return this._renderPlugins}get _hasOITSupport(){return this._rctx.driverTest.floatBufferBlend.result}get _oitEnabled(){return this._highQualityTransparency&&this._hasOITSupport}modify(e,r){this._isRendering&&console.warn("Renderer.modify called while rendering");const{adds:t,removes:s,updates:n}=e;if(0===t.length&&0===s.length&&0===n.length)return;const i=q(e);let a=!1;i.forEach(((t,s)=>{if(r.done)return;let n=this._materialRenderers.find((e=>e.material===s));d(n)&&t.adds.length>0&&(n=new se(this._rctx,this._materialRepository,s),this._materialRenderers.push(n)),n&&(n.modify(t),n.isEmpty&&(a=!0)),t.removes.forEach((r=>e.removes.removeUnordered(r))),t.adds.forEach((r=>e.adds.removeUnordered(r))),t.updates.forEach((r=>e.updates.removeUnordered(r))),r.madeProgress()})),a&&this._materialRenderers.filterInPlace((e=>!e.isEmpty||(e.dispose(),!1))),this._hasHighlights=this._materialRenderers.some((e=>e.hasHighlights)),this._bindParameters.hasOccludees=this._materialRenderers.some((e=>e.hasOccludees)),this._hasWater=this._materialRenderers.some((e=>e.hasWater)),this._hasHUDElements=this._materialRenderers.some((e=>e.requiresSlot(Q.LINE_CALLOUTS_HUD_DEPTH,w.Color)||e.requiresSlot(Q.HUD_MATERIAL,w.Color)||e.requiresSlot(Q.LABEL_MATERIAL,w.Color))),this._requestRender()}updateAnimation(e){const r=this._hasAnimations;return this._hasAnimations=!1,this._materialRenderers.forAll((r=>this._hasAnimations=r.updateAnimation(e)||this._hasAnimations)),this._hasAnimations=this._renderPlugins.updateAnimation(e)||this._hasAnimations,this._hasAnimations!==r&&(this._gpuTimerHandle=r?i(this._gpuTimerHandle):this.performanceInfo.enableGPUPerformanceInfo()),this._hasAnimations}get animationTimestep(){return this._animationTimestep.value}get animationTimeDilation(){return this._animationTimestep.timeDilation}render(e,r,t,s,n){this._isRendering=!0,this.performanceInfo.startFrame();const{camera:i,contentCamera:a,mode:o}=t;this._state=o,this._renderOverlay(n),this.performanceInfo.advance(ae.OVERLAY),this._renderContext.time=n,this._bindParameters.transparencyPassType=ee.NONE;const l=this._offscreenRendering;l.setupRenderTarget(this.hasWaterReflection);const _=P(this._sliceHelper.plane);s===x.OFF&&(this._sliceHelper.plane=null),this._rctx.bindFramebuffer(e),i.setGLViewport(this._rctx),this._prepare(i,a),this._renderPlugins.prepareRender(),this.performanceInfo.advance(ae.PREPARE);const c=this._computeDepthRange(i);this._renderShadowMap(e,i,this._bindParameters.lighting.mainLight.direction,c),this.performanceInfo.advance(ae.SHADOW_MAP),l.initializeFrame(i),this._ensureBindParameters(i,a),this._renderLinearDepth(),this.performanceInfo.advance(ae.LINEAR_DEPTH),this._accumulateShadows(c,i,a),this.performanceInfo.advance(ae.ACCUMULATED_SHADOWS),this._renderNormal(),this.performanceInfo.advance(ae.NORMALS),this._ensureBindParametersSSR(),this._renderSSAO(),this.performanceInfo.advance(ae.SSAO),this._renderContext.output=w.Color,l.bindFramebuffer(),this._renderOpaqueGeometry(),this.performanceInfo.advance(ae.OPAQUE);const p=this._terrainRenderingEnabled&&(this._terrainTransparency===y.Semitransparent||this._terrainTransparency===y.TransparentWithDraped),m=this._highQualityTransparency&&p;this._renderTerrainLinearDepth(m),this._setMultipassEnabled(m),this._setTerrainCulling(m),this._renderEdges(te.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),this._offscreenRendering.bindTarget(this._offscreenRendering.currentColorTarget,this._offscreenRendering.mainDepth),this._renderSlot(Q.VOXEL),this.performanceInfo.advance(ae.VOXEL),this._renderHiddenTransparentEdges();const g=this._needsTransparentPass||this._renderPlugins.needsTransparentPass;g&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderGeometryLinearDepth(m);const u=this._renderHUDVisibility(m);m||this._renderInternalSlot(Q.LINE_CALLOUTS),this.performanceInfo.advance(ae.HUD_VISIBILITY),this._renderObjectAndLayerIdColor(r),this.performanceInfo.advance(ae.OBJECT_AND_LAYER_ID_COLOR),this._renderEdges(te.TRANSPARENT,m),this.performanceInfo.advance(ae.TRANSPARENT_EDGES),this._renderTransparentTerrain(),p&&u&&(m?this._renderLineCallouts(C.Occluded):l.compositeTransparentTerrainOntoHUDVisibility(this._bindParameters),this._renderHUD(C.Occluded,l.framebuffer),this.performanceInfo.advance(ae.HUD_OCCLUDED)),this.performanceInfo.advance(ae.TRANSPARENT_TERRAIN),this._setTerrainCulling(!1),p&&(l.compositeTransparentTerrainOntoMain(this._bindParameters),m&&(this._renderEdges(te.OPAQUE),this.performanceInfo.advance(ae.OPAQUE_EDGES),g&&(this._oitEnabled?this._renderOrderIndependentTransparency((()=>this._renderTransparentGeometry()),!1):this._renderTransparentGeometry()),this.performanceInfo.advance(ae.TRANSPARENT),this._renderEdges(te.TRANSPARENT),this.performanceInfo.advance(ae.TRANSPARENT_EDGES))),m&&this._renderLineCallouts(C.NotOccluded),this._setMultipassEnabled(!1),this._shadowAccumulator.render(this._bindParameters),l.renderToTargets((()=>{this._renderInternalSlot(Q.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL),this._renderSlot(Q.POSTPROCESSING_ENVIRONMENT_TRANSPARENT),this._renderSlot(Q.LASERLINES)}),l.currentColorTarget,l.mainDepth),this.performanceInfo.advance(ae.ENVIRONMENT),this._renderPlugins.needsLaserlineWithContrastControl&&l.renderTmpAndCompositeToMain((()=>this._renderSlot(Q.LASERLINES_CONTRAST_CONTROL)),this._bindParameters,ne.PremultipliedAlpha),this.performanceInfo.advance(ae.LASER_LINE),this._renderOccluded(),this.performanceInfo.advance(ae.OCCLUDED);const f=s===x.ON&&this._magnifierHelper.enabled,T=f&&d(e)?this._offscreenRendering.getFramebuffer(this._offscreenRendering.tmpColor,this._offscreenRendering.tmpDepth):e;this._rctx.bindFramebuffer(T);const R=this._offscreenRendering.colorTexture;!this._renderAntiAliasing(R)&&h(R)&&this._compositingHelper.composite(this._bindParameters,R,ne.None),this.performanceInfo.advance(ae.ANTIALIASING),this._renderHUD(C.NotOccluded,T),this.performanceInfo.advance(ae.HUD),this._renderHighlights(T,this._bindParameters),this.performanceInfo.advance(ae.HIGHLIGHTS),f&&this._magnifierHelper.render(this._rctx,this._bindParameters),T!==e&&(this._rctx.bindFramebuffer(e),this._compositingHelper.composite(this._bindParameters,this._offscreenRendering.tmpColorTexture,ne.None)),this._disposeOITBuffers(),this._renderContext.lastFrameCamera.copyFrom(this._bindParameters.camera),this._sliceHelper.plane=_,this._isRendering=!1,this.onPostRender&&this.onPostRender(),this.performanceInfo.finishFrame()}_renderObjectAndLayerIdColor(e){h(e)&&has("enable-feature:objectAndLayerId-rendering")&&(this._rctx.bindFramebuffer(e),this._offscreenRendering.renderToFBO((()=>this._renderGeometryAndTransparentTerrainPass(w.ObjectAndLayerIdColor)),[0,0,0,0],!0,!0),this._rctx.bindFramebuffer(e),this._offscreenRendering.renderToFBO((()=>{this._bindParameters.renderTransparentlyOccludedHUD=C.NotOccluded,this._renderInternalSlot(Q.HUD_MATERIAL)}),void 0,!0,!0))}finish(e){this._hasAnimations||this._animationTimestep.clear();const r=this.performanceInfo.gpuSamplingEnabled,t=e===I.BACKGROUND;if(t||r){const e=t?this.performanceInfo.elapsedTime:0,s=r?this.performanceInfo.totalGPUTimeSampler.last:this._rctx.gl.getError(),n=Math.max(e,s);this._animationTimestep.frame(n,t)}}readDepthPixels(e,r,t){const s=this._offscreenRendering.bindTarget(this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth);if(!this._needsLinearDepth){this._ensureBindParameters(e,e),this._bindParameters.camera.setGLViewport(this._rctx),this._rctx.setClearColor(0,0,0,0);const r=de.COLOR_BUFFER_BIT|de.DEPTH_BUFFER_BIT|de.STENCIL_BUFFER_BIT;this._rctx.clearSafe(r),this._renderGeometryAndTransparentTerrainPass(w.Depth)}s.readPixels(r[0],r[1],r[2],r[3],oe.RGBA,le.UNSIGNED_BYTE,t)}readHUDVisibility(e,r,t,s,n){this._offscreenRendering.bindTarget(this._offscreenRendering.hudVisibility).readPixels(e,r,t,s,oe.RGBA,le.UNSIGNED_BYTE,n)}readAccumulatedShadow(e){return this._shadowAccumulator.readAccumulatedShadow(e[0],e[1])}_setMultipassEnabled(e){this._bindParameters.multipassTerrain.enabled=this._bindParameters.multipassGeometry.enabled=e}_setTerrainCulling(e){this._bindParameters.multipassTerrain.cullAboveGround=e}_renderSlot(e){this._bindParameters.slot=e,this._renderPlugins.render()}_renderEdges(e,r=!1){const t=this._edgeView;h(t)&&t.shouldRender()&&this._offscreenRendering.renderTmpAndCompositeToMain((()=>t.render(this._bindParameters,e)),this._bindParameters,ne.Alpha,r)}_renderShadowMap(e,r,t,s){const n=this._shadowMap;n.enabled&&this.isFeatureEnabled(B.ShadowMapUpdate)&&(n.start(r,t,s),this._shadowHighlight.updateParameters(r,t),this._needsShadowHighlight?(this._renderShadowCascades(w.ShadowHighlight,this._shadowMap,(e=>n.takeCascadeSnapshotTo(e,J.Highlight))),n.clear(),this._renderShadowCascades(w.ShadowExcludeHighlight,this._shadowMap,(e=>{n.takeCascadeSnapshotTo(e,J.Default),this._renderGeometryAndTransparentTerrainPass(w.ShadowHighlight)}))):this._renderShadowCascades(w.Shadow),n.finish(e),r.setGLViewport(this._rctx))}_renderShadowCascades(e,r=this._shadowMap,t=(e=>{})){for(const s of r.cascades)s.camera.setGLViewport(this._rctx),this._prepare(s.camera,s.camera),this._renderGeometryAndTransparentTerrainPass(e),t(s)}get _needsLinearDepth(){return this._ssaoHelper.enabled||this._renderPlugins.needsLinearDepth||this.hasWaterReflection||this._needsShadowHighlight||this._needsShadowCast}_renderLinearDepth(){this._needsLinearDepth?this._offscreenRendering.renderToTargets((()=>this._renderGeometryAndTransparentTerrainPass(w.Depth)),this._offscreenRendering.linearDepth,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.linearDepth),this._bindParameters.linearDepthTexture=this._offscreenRendering.linearDepthTexture}_renderTerrainLinearDepth(e){if(e){const e=this._renderContext.output;this._renderContext.output=w.Depth,this._offscreenRendering.renderToTargets((()=>this._renderTransparentTerrain()),this._offscreenRendering.terrainLinearDepth,this._offscreenRendering.tmpDepth,[-1e10,-1e10,-1e10,1],!0,!0),this._renderContext.output=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.terrainLinearDepth);this._bindParameters.multipassTerrain.linearDepthTexture=this._offscreenRendering.terrainLinearDepthTexture}_renderGeometryLinearDepth(e){if(e){const e=this._renderContext.output;this._offscreenRendering.renderToTargets((()=>this._renderGeometryPass(w.Depth)),this._offscreenRendering.geometryLinearDepth,this._offscreenRendering.tmpDepth,[1,1,1,1],!0,!0),this._renderContext.output=e}else this._offscreenRendering.disposeTarget(this._offscreenRendering.geometryLinearDepth);this._bindParameters.multipassGeometry.linearDepthTexture=this._offscreenRendering.geometryLinearDepthTexture}get _needsNormal(){return this._ssaoHelper.enabled}_renderNormal(){this._needsNormal?this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(w.Normal)}),this._offscreenRendering.normal,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0):this._offscreenRendering.disposeTarget(this._offscreenRendering.normal)}get _needsDepthRange(){return this._shadowMap.enabled||this._needsShadowCast}_computeDepthRange(e){if(!this._needsDepthRange)return M;const r=N(e,this._materialRenderers,this._stage.layers);return v(r,this.renderPlugins.queryDepthRange(e)),r.near=Math.max(e.near,r.near),r.far=Math.min(e.far,r.far),r}_renderGeometryAndTransparentTerrainPass(e){this._renderContext.output=e,this._renderGeometryPass(e),this._renderTransparentTerrain()}_renderGeometryPass(e){this._renderContext.output=e,this._renderOpaqueGeometry(),this._renderTransparentGeometry()}_renderSSAO(){this._ssaoHelper.computeSSAO(this._bindParameters,this._offscreenRendering.linearDepthTexture,this._offscreenRendering.normalTexture)}_renderOpaqueGeometry(){this._renderSlot(Q.INTEGRATED_MESH),this._renderSlot(Q.OPAQUE_TERRAIN),this._renderInternalSlot(Q.OPAQUE_MATERIAL),this._renderSlot(Q.OPAQUE_MATERIAL),this._renderSlot(Q.POSTPROCESSING_ENVIRONMENT_OPAQUE)}_renderTransparentGeometry(){this._renderInternalSlot(Q.TRANSPARENT_MATERIAL),this._renderSlot(Q.TRANSPARENT_MATERIAL)}_renderTransparentTerrain(){this._renderSlot(Q.TRANSPARENT_TERRAIN)}_renderHUDVisibility(e){let r=!1;return this._renderContext.offscreenRenderingHelper&&this._renderContext.offscreenRenderingHelper.renderHUDVisibility((()=>{this._bindParameters.hudVisibilityTexture=this._renderContext.offscreenRenderingHelper.hudVisibilityTexture,r=this._renderInternalSlot(Q.OCCLUSION_PIXELS)}),e),r}_renderLineCallouts(e){this._bindParameters.renderTransparentlyOccludedHUD=e,e===C.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderInternalSlot(Q.LINE_CALLOUTS)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderInternalSlot(Q.LINE_CALLOUTS)}_renderHUD(e,r){this._hasHUDElements&&(this._oitEnabled?(this._renderOrderIndependentTransparency((()=>this._renderHUDElements(e)),!0),this._rctx.bindFramebuffer(r),this._compositingHelper.composite(this._bindParameters,this._offscreenRendering.hudColorTexture,ne.PremultipliedAlpha)):e===C.Occluded?this._offscreenRendering.renderToTargets((()=>this._renderHUDElements(C.Occluded)),this._offscreenRendering.currentColorTarget,this._offscreenRendering.tmpDepth,void 0,!0,!0):this._renderHUDElements(e))}_renderHUDElements(e){this._bindParameters.renderTransparentlyOccludedHUD=e,this._renderInternalSlot(Q.LINE_CALLOUTS_HUD_DEPTH),this._renderInternalSlot(Q.HUD_MATERIAL),this._renderInternalSlot(Q.LABEL_MATERIAL)}get _needsHighlight(){return this._hasHighlights||this._renderPlugins.needsHighlight}get _needsShadowHighlight(){return this._shadowMap.enabled&&this._shadowHighlight.isVisible&&this._needsHighlight}_renderHighlights(e,r){if(!this._needsHighlight)return void this._offscreenRendering.disposeTarget(this._offscreenRendering.highlight);const t=this._highlight,s=this._offscreenRendering.renderToTargets((()=>{this._renderGeometryAndTransparentTerrainPass(w.Highlight),this._rctx.clearSafe(de.DEPTH_BUFFER_BIT),this._renderHUDElements(C.Both)}),this._offscreenRendering.highlight,this._offscreenRendering.tmpDepth,[0,0,0,0],!0,!0);this._bindParameters.highlightColorTexture=s.colorTexture,this._needsShadowHighlight&&this._shadowHighlight.render(r,e),t.render(this._bindParameters,s,e)}get _needsShadowCast(){return this._shadowAccumulator.isAccumulating}_accumulateShadows(e,r,t){this._needsShadowCast&&h(this._offscreenRendering.linearDepthTexture)&&this._shadowAccumulator.renderAccumulation(this._offscreenRendering.linearDepthTexture,e,r,t)}_renderOrderIndependentTransparency(e,r){const t=t=>{this._bindParameters.transparencyPassType=t,this._offscreenRendering.renderOITPass((()=>e()),t,r)},s=this._renderContext.output;this._renderContext.output=w.Alpha,t(ee.Alpha),this._renderContext.output=w.Color,t(ee.Color),t(ee.FrontFace),this._offscreenRendering.compositeTransparentOntoOpaque(this._bindParameters,r),this._bindParameters.transparencyPassType=ee.NONE,this._renderContext.output=s,this._oitUsed=!0}_disposeOITBuffers(){this._oitUsed||(this._offscreenRendering.disposeTarget(this._offscreenRendering.alphaFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.colorFloatTarget),this._offscreenRendering.disposeTarget(this._offscreenRendering.frontFaceTarget)),this._oitUsed=!1}_renderOccluded(){let e=0;this._materialRenderers.forAll((({material:r})=>{r&&r.isVisible()&&r.renderOccluded===j.OccludeAndTransparentStencil&&(e|=r.renderOccluded,me.push(r))}));const r=this._offscreenRendering,t=(t,s,n,i,a)=>{0!=(e&s)&&(r.renderToTargets(n,r.tmpColor,r.mainDepth,[0,0,0,0],i,a),r.compositeOccludedOntoMain(this._bindParameters,t))};0!==me.length&&(this._renderInternalSlot(Q.OCCLUDER_MATERIAL,me),t(.5,j.OccludeAndTransparentStencil,(()=>this._renderInternalSlot(Q.TRANSPARENT_OCCLUDER_MATERIAL,me)),!1,!1),me.length=0),this._materialRenderers.forAll((({material:r})=>{r&&r.isVisible()&&(r.renderOccluded===j.OccludeAndTransparent||r.renderOccluded===j.Transparent||r.renderOccluded===j.Opaque)&&(e|=r.renderOccluded,pe.push(r))}));const s=this._renderPlugins.renderOccludedFlags;if(e|=s,!e)return;const n=e=>{this._renderContext.renderOccludedMask=e,s>j.Occlude&&this._renderSlot(Q.OCCLUDED_TERRAIN),this._renderInternalSlot(Q.OPAQUE_MATERIAL,pe),this._renderInternalSlot(Q.TRANSPARENT_MATERIAL,pe),this._renderInternalSlot(Q.TRANSPARENT_DEPTH_WRITE_DISABLED_MATERIAL,pe),this._renderContext.resetRenderOccludedMask()};this._renderContext.output=w.Color,t(.5,j.OccludeAndTransparent,(()=>n(j.OccludeAndTransparent)),!0,H.OutlineVisualElementMask),t(.5,j.Transparent,(()=>n(j.Transparent)),!0,H.OutlineVisualElementMask),t(1,j.Opaque,(()=>n(j.Opaque)),!0,H.OutlineVisualElementMask),pe.length=0}_renderAntiAliasing(e){if(this._antialiasing){if(this._smaaPass.enable((()=>this._requestRender()))&&h(e))return this._smaaPass.render(e),!0}else this._smaaPass.disable();return!1}_prepare(e,r){this._needsTransparentPass=this._materialRenderers.some((e=>e.requiresSlot(Q.TRANSPARENT_MATERIAL,w.Color))),this._bindParameters.camera=e,this._bindParameters.contentCamera=r}_ensureBindParameters(e,r){this._bindParameters.camera=e,this._bindParameters.contentCamera=r;const t=this._renderContext.offscreenRenderingHelper;this._bindParameters.hudVisibilityTexture=t.hudVisibilityTexture,this._bindParameters.mainColorTexture=t.mainColorTexture,this._bindParameters.highlightDepthTexture=t.depthTexture??this._getFallbackDepthTexture()}_ensureBindParametersSSR(){this.hasWaterReflection?(this._renderContext.lastFrameCamera.equals(this._bindParameters.camera)?this._reprojectionMatrix=E:(R(ue,this._bindParameters.camera.viewMatrix),R(ge,this._bindParameters.camera.projectionMatrix),b(fe,ue,ge),b(fe,this._renderContext.lastFrameCamera.viewMatrix,fe),b(fe,this._renderContext.lastFrameCamera.projectionMatrix,fe),this._reprojectionMatrix=fe),this._bindParameters.ssr.lastFrameColorTexture=this._offscreenRendering.lastFrameColorTexture):this._bindParameters.ssr.lastFrameColorTexture=null,this._bindParameters.ssr.enabled=this.hasWaterReflection}_renderInternalSlot(e,r){let t=!1;return this._bindParameters.slot=e,h(r)?r.forEach((e=>{if(!e.shouldRender(this._renderContext))return;const r=this._materialRenderers.find((r=>r.material===e));h(r)&&(t=r.render(this._renderContext.output,this._bindParameters)||t)})):this._materialRenderers.forAll((e=>{e.material.shouldRender(this._renderContext)&&e.render(this._renderContext.output,this._bindParameters)&&(t=!0)})),t}_getFallbackDepthTexture(){return this._fallbackDepthStencilTexture||(this._fallbackDepthStencilTexture=U(this._rctx)),this._fallbackDepthStencilTexture}get gpuMemoryUsage(){return{offscreen:this._offscreenRendering?.gpuMemoryUsage??0,highlights:(this._highlight?.gpuMemoryUsage??0)+(this._shadowHighlight?.gpuMemoryUsage??0),shadows:this._shadowMap?.gpuMemoryUsage??0,ssao:this._ssaoHelper?.gpuMemoryUsage??0}}get test(){const e=this;return{offscreen:this._offscreenRendering,shadowMap:this._shadowMap,ssao:this._ssaoHelper,highlight:this._highlight,lighting:this._bindParameters.lighting,materialRenderers:this._materialRenderers,shadowAccumulator:this._shadowAccumulator,weatherIsFading:this._bindParameters.cloudsFade.isFading,getFramebufferTexture:r=>{switch(r){case ce.Color:return e._offscreenRendering.colorTexture;case ce.LinearDepth:return e._offscreenRendering.linearDepthTexture;case ce.Normals:return e._offscreenRendering.normalTexture;case ce.ShadowMap:return e._shadowMap.depthTexture;case ce.HudVisibility:return e._offscreenRendering.hudVisibilityTexture;case ce.Highlight:return e._offscreenRendering.highlightTexture}}}}};var ce;e([u()],_e.prototype,"_shadowAccumulator",void 0),e([u()],_e.prototype,"_state",void 0),e([u({readOnly:!0})],_e.prototype,"_renderStateFeatures",void 0),e([u()],_e.prototype,"_antialiasingEnabled",void 0),e([u({readOnly:!0})],_e.prototype,"_antialiasing",null),e([u()],_e.prototype,"_ssaoEnabled",void 0),e([u()],_e.prototype,"_smaaPass",void 0),e([u({autoDestroy:!0})],_e.prototype,"_edgeView",void 0),e([u()],_e.prototype,"updating",null),e([u()],_e.prototype,"isCameraFinal",null),_e=e([f("esri.views.3d.webgl-engine.lib.Renderer")],_e),function(e){e[e.Color=0]="Color",e[e.LinearDepth=1]="LinearDepth",e[e.Normals=2]="Normals",e[e.ShadowMap=3]="ShadowMap",e[e.HudVisibility=4]="HudVisibility",e[e.Highlight=5]="Highlight"}(ce||(ce={}));const pe=[],me=[],ge=A(),ue=A(),fe=A();export{ce as FramebufferId,_e as Renderer};
|