@arcgis/core 4.28.0-next.20230819 → 4.28.0-next.20230821
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/003744a45b07865f1be9.js +1 -0
- package/assets/esri/core/workers/chunks/034accc7cab6c88a3b31.js +1 -0
- package/assets/esri/core/workers/chunks/{a67e5b22adc91e850b4e.js → 05ab09713d599687afa3.js} +1 -1
- package/assets/esri/core/workers/chunks/{3724f23b6f5ac8ec2568.js → 12b8fe0374fa9ab4ca09.js} +1 -1
- package/assets/esri/core/workers/chunks/16d1a72014074e87ecb9.js +1 -0
- package/assets/esri/core/workers/chunks/{e4b6565c16430b28ad93.js → 19857e5420cdf23c5f2e.js} +1 -1
- package/assets/esri/core/workers/chunks/{1a804dea42c0fb5e5c07.js → 1bab408eaffd2c18976d.js} +1 -1
- package/assets/esri/core/workers/chunks/201365f53509e3f78e17.js +1 -0
- package/assets/esri/core/workers/chunks/{2031451b82ff70fb201a.js → 2f48f4a9a0a056ac5e1c.js} +1 -1
- package/assets/esri/core/workers/chunks/318b51fdee09c1fd750f.js +1 -0
- package/assets/esri/core/workers/chunks/{5b799dc155adeb728c74.js → 3361e3e8385f8de8820c.js} +1 -1
- package/assets/esri/core/workers/chunks/3ce1870c28ab6ac3648e.js +1 -0
- package/assets/esri/core/workers/chunks/41929e4531787389804b.js +1 -0
- package/assets/esri/core/workers/chunks/{55ac725127c5ea9fb942.js → 4e39252f40bc57be9d12.js} +1 -1
- package/assets/esri/core/workers/chunks/{8ed83426ef88a3eccecd.js → 4e496b03ce24b1206f86.js} +1 -1
- package/assets/esri/core/workers/chunks/54513578f735d274a20e.js +1 -0
- package/assets/esri/core/workers/chunks/{d46f8ef92e79d12384c9.js → 587437526ea77f764986.js} +1 -1
- package/assets/esri/core/workers/chunks/{ab720e2f0a35138564b2.js → 5ffabd1a90c5b08109aa.js} +1 -1
- package/assets/esri/core/workers/chunks/6108d72faf48a592c8ba.js +1 -0
- package/assets/esri/core/workers/chunks/6479439afae01f9bb5e6.js +1 -0
- package/assets/esri/core/workers/chunks/69306dfc89e877539223.js +1 -0
- package/assets/esri/core/workers/chunks/{ed499c328ae3a704791c.js → 6db4a6f9d25691830829.js} +1 -1
- package/assets/esri/core/workers/chunks/{61393fd3376ea599a447.js → 76e27cece1559ae815df.js} +1 -1
- package/assets/esri/core/workers/chunks/81526909c0fa11639038.js +1 -0
- package/assets/esri/core/workers/chunks/873111ddf4813cdd4903.js +1 -0
- package/assets/esri/core/workers/chunks/8d4f1170394a8be15da9.js +1 -0
- package/assets/esri/core/workers/chunks/8d8bdfda09c24e363f78.js +1 -0
- package/assets/esri/core/workers/chunks/9b54b5bdb6367c36f6e9.js +1 -0
- package/assets/esri/core/workers/chunks/{88f0b5c0fe751bf35af2.js → b2752e038c5fa3c21e49.js} +1 -1
- package/assets/esri/core/workers/chunks/{dd3b7cfc6f78552249a4.js → b78dc6cbe14e5817b4d9.js} +1 -1
- package/assets/esri/core/workers/chunks/{e31d0c7363cbceeb5ac9.js → c35b850fbfcb28133235.js} +1 -1
- package/assets/esri/core/workers/chunks/c83e1be4ee64320cf2fe.js +1 -0
- package/assets/esri/core/workers/chunks/c88869d2a647c22dc3e6.js +1 -0
- package/assets/esri/core/workers/chunks/cb0a5bc6deaa98026bb5.js +1 -0
- package/assets/esri/core/workers/chunks/{767467738aeabec14abd.js → d0c4367a197b193e95d4.js} +1 -1
- package/assets/esri/core/workers/chunks/{f113141e254505116b82.js → d1cc2c050423595e54e0.js} +1 -1
- package/assets/esri/core/workers/chunks/{7f34945036495ad7c3f8.js → d2a8bf2d090b94cb294b.js} +1 -1
- package/assets/esri/core/workers/chunks/{08af7f7f1950a59a8e47.js → d6c96a20e9640b433719.js} +4 -4
- package/assets/esri/core/workers/chunks/da5453e67d00ff546640.js +1 -0
- package/assets/esri/core/workers/chunks/daa79c14150c12d8bc3d.js +1 -0
- package/assets/esri/core/workers/chunks/ef03b78659c72de93076.js +1 -0
- package/assets/esri/core/workers/chunks/{c3cace5b25b5170228ba.js → f2fe89b6ac6bf6817e71.js} +1 -1
- package/assets/esri/core/workers/chunks/f3554627664a419e00fa.js +1 -0
- package/assets/esri/themes/base/widgets/_Editor.scss +65 -4
- package/assets/esri/themes/base/widgets/_UtilityNetworkAssociations.scss +97 -39
- 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/assets/esri/widgets/Editor/t9n/Editor.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_en.json +1 -1
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/butt.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/round.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-caps/square.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dash-dot.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dash.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/dot.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash-dot-dot.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash-dot.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/long-dash.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash-dot-dot.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash-dot.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dash.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/short-dot.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/assets/img/line-patterns/solid.png +0 -0
- package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations.json +1 -1
- package/assets/esri/widgets/UtilityNetworkAssociations/t9n/UtilityNetworkAssociations_en.json +1 -1
- package/chunks/HighlightBlur.glsl.js +3 -3
- package/chunks/HighlightDownsample.glsl.js +24 -6
- package/chunks/SSAO.glsl.js +2 -2
- package/core/timeUtils.js +1 -1
- package/intl/date.js +1 -1
- package/layers/FeatureLayer.js +1 -1
- package/layers/ImageryLayer.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/StreamLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/graphics/sources/support/uploads.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/save/streamLayerUtils.js +1 -1
- package/package.json +1 -1
- package/popup/support/FieldInfoFormat.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/support/LaserLineRenderer.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPlugin.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/CheckerBoardMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineCalloutMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/SlicePlaneMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightDownsample.glsl.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/sketch/normalizedPoint.js +1 -1
- package/views/interactive/snapping/SnappingManager.js +1 -1
- package/views/interactive/snapping/candidates/IntersectionSnappingCandidate.js +1 -1
- package/views/interactive/tooltip/TooltipEditableField.js +1 -1
- package/views/interactive/tooltip/TooltipEditableFieldAngle.js +1 -1
- package/views/interactive/tooltip/constraintUtils.js +5 -0
- package/views/support/angularMeasurementUtils.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/Upload.js +1 -1
- package/widgets/Editor/components/CreateFeaturesPanelContent.js +1 -1
- package/widgets/Editor/components/UploadDetails.js +1 -1
- package/widgets/Editor/modelUploadUtils.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Feature/FeatureViewModel.js +1 -1
- package/widgets/Feature/support/featureUtils.js +1 -1
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsLineSymbolPicker.js +5 -0
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations/VisibleElements.js +5 -0
- package/widgets/UtilityNetworkAssociations/VisibleElementsSettingsPane.js +5 -0
- package/widgets/UtilityNetworkAssociations.js +1 -1
- package/assets/esri/core/workers/chunks/11abbbf97093b55e2417.js +0 -1
- package/assets/esri/core/workers/chunks/1b2a081f2c3b97ba7e00.js +0 -1
- package/assets/esri/core/workers/chunks/235f333177ed7ea21e01.js +0 -1
- package/assets/esri/core/workers/chunks/3725dd14c2da0f47198f.js +0 -1
- package/assets/esri/core/workers/chunks/42595c4870c673ed451c.js +0 -1
- package/assets/esri/core/workers/chunks/481cdd2a4bc40c6fef66.js +0 -1
- package/assets/esri/core/workers/chunks/54893132e70c515ea7e3.js +0 -1
- package/assets/esri/core/workers/chunks/6509a4198972b323d9b6.js +0 -1
- package/assets/esri/core/workers/chunks/68598d2806d4aa3d8acc.js +0 -1
- package/assets/esri/core/workers/chunks/718d2e8ea61f3b7b70c5.js +0 -1
- package/assets/esri/core/workers/chunks/7bce4b5eec630ef57f1e.js +0 -1
- package/assets/esri/core/workers/chunks/8706dc9f852df9b2095d.js +0 -1
- package/assets/esri/core/workers/chunks/8ef26aac0fe7feb8c324.js +0 -1
- package/assets/esri/core/workers/chunks/91e61da22f258d9e86c5.js +0 -1
- package/assets/esri/core/workers/chunks/9f039bf79b34d8fd75ae.js +0 -1
- package/assets/esri/core/workers/chunks/a20fd9e7db37b3c3b041.js +0 -1
- package/assets/esri/core/workers/chunks/aa83dce42d64034a0a13.js +0 -1
- package/assets/esri/core/workers/chunks/cdcf0a5e05283d37b3ac.js +0 -1
- package/assets/esri/core/workers/chunks/d4f9106bf2ea5d66d96a.js +0 -1
- package/assets/esri/core/workers/chunks/e6bfbc4347fa13db4df2.js +0 -1
- package/assets/esri/core/workers/chunks/f1d5487f2d828fb142ba.js +0 -1
- package/assets/esri/core/workers/chunks/f97f165d05439e668e05.js +0 -1
- package/assets/esri/core/workers/chunks/fe973d8155c22d73a4f9.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as o}from"../../../core/maybe.js";import a from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as d,on as h}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{x as p,f as m}from"../../../chunks/mat4.js";import{s as _}from"../../../chunks/vec3.js";import{f as g}from"../../../chunks/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as R,DrapeSourceType as f,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as v,RenderTargetType as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayRenderTarget as D}from"./OverlayRenderTarget.js";import{ColorFormat as S}from"../webgl-engine/core/FBOCache.js";import{ShaderOutput as P}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as E}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as j}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as C}from"../webgl-engine/effects/RenderPlugin.js";import{Camera as A}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as M}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as W}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as q}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as L}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as V}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as U}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as H}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as I}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as N}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as B}from"../webgl-engine/lighting/Lightsources.js";import{O as z}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as Y}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{ClearBufferBit as K,TextureSamplingMode as Q}from"../../webgl/enums.js";import{Texture as Z}from"../../webgl/Texture.js";import{TextureDescriptor as $}from"../../webgl/TextureDescriptor.js";let ee=class extends C{get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._overlayParameters=new z,this.hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new a,this._passParameters=new E,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new A,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.renderSlots=[V.DRAPED_MATERIAL,V.DRAPED_WATER]}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextureRepository:t,stippleTextureRepository:s,markerTextureRepository:i}=r;this._shaderTechniqueRepository=new j({rctx:this._rctx,viewingMode:y.Local,stippleTextureRepository:s,markerTextureRepository:i,waterTextureRepository:t}),this._renderContext=new F(this._rctx,new U(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),d),n((()=>this.spatialReference),(e=>this._localOriginFactory=new q(e)),d),h((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new M(r.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&ie)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=V.DRAPED_MATERIAL,this._bindParameters.mainDepth=W(this._rctx),this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=N.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new B(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._bindParameters.mainDepth=i(this._bindParameters.mainDepth),this._shaderTechniqueRepository=o(this._shaderTechniqueRepository),this.disposeOverlays()}canRender(e,r){return!(r===P.Highlight&&!this.hasHighlights)&&(e===V.DRAPED_MATERIAL||e===V.DRAPED_WATER)}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._overlayRenderTarget}get usedMemory(){return Array.from(this._renderers.values()).reduce(((e,r)=>e+r.usedMemory),0)}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,H)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._overlayRenderTarget?.computeValidity()??0}releaseRenderTargets(){this._overlayRenderTarget?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){null!=this._overlays&&this._overlays.forEach((r=>r.hasTargetWithoutRasterImage=l(e,(e=>e.drapeTargetType===R.WithoutRasterImage))))}ensureDrapeSources(e){null!=this._overlays&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),r.hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))}))}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._overlayRenderTarget=new D(this.view._stage.renderer.fboCache),this._overlays=[new x(v.INNER,this._overlayRenderTarget),new x(v.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=i(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this._updateRendersOccluded(),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}get mode(){return this.isEmpty?O.Disabled:this._overlayRenderTarget?.getTexture(w.Water)?O.EnabledWithWater:this._overlayRenderTarget?.getTexture(w.Color)?O.Enabled:O.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return;const{alignPixelEnabled:i,contentPixelRatio:o}=t;this._screenToWorldRatio=o*e.mapUnitsPerPixel/this._bindParameters.overlayStretch;const a=r.output;if(this.isEmpty||a===P.Highlight&&!this.hasHighlights||a===P.Normal&&!this.hasWater||!e.hasSomeSizedView())return;const n=this._rctx;this._camera.pixelRatio=e.pixelRatio*o,this._renderContext.output=a,this._bindParameters.alignPixelEnabled=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=a===P.Normal?V.DRAPED_WATER:V.DRAPED_MATERIAL;const d=b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.type!==w.Occluded;if(!d&&!this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext))))return;e.applyViewport(this._rctx);const h=2*e.resolution,l=e.resolution,c=r.fbo;if(c.bind(n,h,l),e.index===v.INNER&&(n.setClearColor(0,0,0,0),n.clearSafe(K.COLOR_BUFFER_BIT)),r.type===w.Occluded&&(this._renderContext.renderOccludedMask=ie),d)for(let u=0;u<s.numViews;u++)this._setViewParameters(s.extents[u],e),this._ensureDebugPatternResources(e.resolution,te[e.index]),this._rctx.bindTechnique(this._debugTextureTechnique,this._passParameters,null),this._rctx.screen.draw();this._sortedRenderers.forAll((({drapeSource:t,renderer:i})=>{if(r.type===w.ColorNoRasterImage&&t.drapeSourceType===f.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&a===P.Color?this.bindTemporaryFramebuffer(h,l):null;for(let r=0;r<s.numViews;r++)this._setViewParameters(s.extents[r],e),i.render(this._renderContext);if(d){c.bind(n,h,l),this._overlayParameters.texture=d.colorTexture,this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e.index;const r=this.pluginContext.techniqueRepository.acquire(Y);this._rctx.bindTechnique(r,this._overlayParameters,this._renderContext.bindParameters),this._rctx.screen.draw(),r.release(),d.release()}})),n.bindFramebuffer(null),c.generateMipMap(),this._renderContext.resetRenderOccludedMask()}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(S.RGBA,e,r);return t.rctx.bindFramebuffer(s.fbo),t.rctx.clearSafe(K.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){let i=0;for(const o of this._renderers.values())i=o.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers;this._renderers.forEach(((r,t)=>{const s=e.indexOf(t.layer),i=s>=0,o=this._renderers.size*(t.renderGroup??(i?T.MapLayer:T.ViewLayer))+(i?s:0);this._sortedRenderers.push(new re(t,r,o))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateRendersOccluded(){const e=t(this._renderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let a=0;a<e;a++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(a/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&a?0:255:1&i^1&o?0:128)}const i=new $(e);i.samplingMode=Q.NEAREST,this._passParameters.texture=new Z(this._rctx,i,t);const o=new k;o.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(I,o)}get test(){return{drapedRenderers:Array.from(this._renderers.values()),getDrapeSourceRenderer:e=>this._renderers.get(e)}}};e([c()],ee.prototype,"hasHighlights",void 0),e([c()],ee.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c({autoDestroy:!0})],ee.prototype,"_shaderTechniqueRepository",void 0),e([c({constructOnly:!0})],ee.prototype,"view",void 0),e([c()],ee.prototype,"worldToPCSRatio",void 0),e([c()],ee.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],ee.prototype,"updating",null),e([c()],ee.prototype,"isEmpty",null),ee=e([u("esri.views.3d.terrain.OverlayRenderer")],ee);class re{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const te=[[1,.5,.5],[.5,.5,1]],se=-2,ie=L.OccludeAndTransparent;export{se as DRAPED_Z,ee as OverlayRenderer,ie as overlayRenderOccludedFlag};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Evented.js";import{someMap as t}from"../../../core/MapUtils.js";import{releaseMaybe as s,disposeMaybe as i,destroyMaybe as o}from"../../../core/maybe.js";import a from"../../../core/PooledArray.js";import{watch as n,syncAndInitial as d,on as h}from"../../../core/reactiveUtils.js";import{someSet as l}from"../../../core/SetUtils.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as u}from"../../../core/accessorSupport/decorators/subclass.js";import{x as p,f as m}from"../../../chunks/mat4.js";import{s as _}from"../../../chunks/vec3.js";import{f as g}from"../../../chunks/vec3f64.js";import{ViewingMode as y}from"../../ViewingMode.js";import{DrapeTargetType as R,DrapeSourceType as f,DrapedRenderGroup as T}from"../layers/interfaces.js";import{debugFlags as b}from"../support/debugFlags.js";import{OverlayIndex as v,RenderTargetType as w}from"./interfaces.js";import{Overlay as x}from"./Overlay.js";import{OverlayRenderTarget as D}from"./OverlayRenderTarget.js";import{ColorFormat as S}from"../webgl-engine/core/FBOCache.js";import{ShaderOutput as P}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{OverlayMode as O}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{T as E}from"../../../chunks/TextureOnly.glsl.js";import{ShaderTechniqueRepository as j}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{SyncRenderPlugin as C}from"../webgl-engine/effects/RenderPlugin.js";import{Camera as A}from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as M}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as W}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as q}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{RenderOccludedFlag as L}from"../webgl-engine/lib/Material.js";import{OverlayRenderContext as F}from"../webgl-engine/lib/RenderContext.js";import{RenderSlot as V}from"../webgl-engine/lib/RenderSlot.js";import{ShadowMap as U}from"../webgl-engine/lib/ShadowMap.js";import{SortedRenderGeometryRenderer as H}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechnique as I}from"../webgl-engine/lib/TextureTechnique.js";import{TextureTechniqueConfiguration as k}from"../webgl-engine/lib/TextureTechniqueConfiguration.js";import{TransparencyPassType as N}from"../webgl-engine/lib/TransparencyPassType.js";import{UpdatePolicy as G}from"../webgl-engine/lib/UpdatePolicy.js";import{AmbientLight as B}from"../webgl-engine/lighting/Lightsources.js";import{O as z}from"../../../chunks/OverlayCompositing.glsl.js";import{OverlayCompositingTechnique as Y}from"../webgl-engine/shaders/OverlayCompositingTechnique.js";import{TaskPriority as X,noBudget as J}from"../../support/Scheduler.js";import{ClearBufferBit as K,TextureSamplingMode as Q}from"../../webgl/enums.js";import{Texture as Z}from"../../webgl/Texture.js";import{TextureDescriptor as $}from"../../webgl/TextureDescriptor.js";let ee=class extends C{get _bindParameters(){return this._renderContext.bindParameters}get _rctx(){return this.view._stage.renderView.renderingContext}get rctx(){return this._rctx}get materialRepository(){return this._materialRepository}get screenToWorldRatio(){return this._screenToWorldRatio}get localOriginFactory(){return this._localOriginFactory}constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._overlayParameters=new z,this.hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._renderers=new Map,this._sortedDrapeSourceRenderersDirty=!1,this._sortedRenderers=new a,this._passParameters=new E,this._materialRepository=null,this._screenToWorldRatio=1,this._localOriginFactory=null,this.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._camera=new A,this.worldToPCSRatio=1,this.events=new r,this.longitudeCyclical=null,this.renderSlots=[V.DRAPED_MATERIAL,V.DRAPED_WATER]}initialize(){const e=this.view._stage.renderer.fboCache,r=this.view._stage.renderView,{waterTextureRepository:t,stippleTextureRepository:s,markerTextureRepository:i}=r;this._shaderTechniqueRepository=new j({rctx:this._rctx,viewingMode:y.Local,stippleTextureRepository:s,markerTextureRepository:i,waterTextureRepository:t}),this._renderContext=new F(this._rctx,new U(e,this.view.state.viewingMode),null),this.addHandles([n((()=>t.updating),(()=>this.events.emit("content-changed")),d),n((()=>this.spatialReference),(e=>this._localOriginFactory=new q(e)),d),h((()=>this.view.allLayerViews),"after-changes",(()=>this._sortedDrapeSourceRenderersDirty=!0))]),this._materialRepository=new M(r.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&ie)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating"),this.notifyChange("isEmpty")}),(()=>this.events.emit("content-changed"))),this._bindParameters.slot=V.DRAPED_MATERIAL,this._bindParameters.mainDepth=W(this._rctx),this._camera.near=1,this._camera.far=1e4,this._camera.relativeElevation=null,this._bindParameters.camera=this._camera,this._bindParameters.transparencyPassType=N.NONE,this._bindParameters.newLighting.noonFactor=0,this._bindParameters.newLighting.globalFactor=0,this._bindParameters.newLighting.set([new B(g(1,1,1))]),this.addHandles(this.view.resourceController.scheduler.registerTask(X.STAGE,this))}destroy(){this._renderers.forEach((e=>e.destroy())),this._renderers.clear(),this._debugTextureTechnique=s(this._debugTextureTechnique),this._passParameters.texture=i(this._passParameters.texture),this._bindParameters.mainDepth=i(this._bindParameters.mainDepth),this._shaderTechniqueRepository=o(this._shaderTechniqueRepository),this.disposeOverlays()}produces(e,r){return!(r===P.Highlight&&!this.hasHighlights)&&(e===V.DRAPED_MATERIAL||e===V.DRAPED_WATER)}initializeRenderContext(e){this.pluginContext=e}uninitializeRenderContext(){}render(){}get updating(){return this._sortedDrapeSourceRenderersDirty||t(this._renderers,(e=>e.updating))}get hasOverlays(){return null!=this._overlays&&null!=this._overlayRenderTarget}get usedMemory(){return Array.from(this._renderers.values()).reduce(((e,r)=>e+r.usedMemory),0)}createGeometryDrapeSourceRenderer(e){return this.createDrapeSourceRenderer(e,H)}createDrapeSourceRenderer(e,r,t){const s=this._renderers.get(e);null!=s&&s.destroy();const i=new r({...t,rendererContext:this,drapeSource:e});return this._renderers.set(e,i),this._sortedDrapeSourceRenderersDirty=!0,"fullOpacity"in e&&this.addHandles(n((()=>e.fullOpacity),(()=>this.events.emit("content-changed"))),e),i}removeDrapeSourceRenderer(e){if(null==e)return;const r=this._renderers.get(e);null!=r&&(this._sortedDrapeSourceRenderersDirty=!0,this._renderers.delete(e),this.removeHandles(e),r.destroy())}computeValidity(){return this._overlayRenderTarget?.computeValidity()??0}releaseRenderTargets(){this._overlayRenderTarget?.dispose()}get overlays(){return this._overlays??[]}ensureDrapeTargets(e){null!=this._overlays&&this._overlays.forEach((r=>r.hasTargetWithoutRasterImage=l(e,(e=>e.drapeTargetType===R.WithoutRasterImage))))}ensureDrapeSources(e){null!=this._overlays&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=l(e,(e=>e.drapeSourceType===f.Features)),r.hasDrapedRasterSource=l(e,(e=>e.drapeSourceType===f.RasterImage))}))}ensureOverlays(e,r,t=this._bindParameters.overlayStretch){null==this._overlays&&(this._overlayRenderTarget=new D(this.view._stage.renderer.fboCache),this._overlays=[new x(v.INNER,this._overlayRenderTarget),new x(v.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r),this._bindParameters.overlayStretch=t}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=i(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e){this._processDrapeSources(e,(()=>!0))}_processDrapeSources(e,r){let s=!1;for(const[t,i]of this._renderers){if(e.done)break;(t.destroyed||r(t))&&(i.commitChanges()&&(s=!0,e.madeProgress()))}this._sortedDrapeSourceRenderersDirty&&(this._sortedDrapeSourceRenderersDirty=!1,s=!0,this._updateSortedDrapeSourceRenderers()),s&&(null!=this._overlays&&0===this._renderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.notifyChange("isEmpty"),this.events.emit("content-changed"),this.hasHighlights=t(this._renderers,(e=>e.hasHighlights)),this._updateRendersOccluded(),this._updateHasWater())}processSyncDrapeSources(){this._processDrapeSources(J,(e=>e.updatePolicy===G.SYNC))}get isEmpty(){return!b.OVERLAY_DRAW_DEBUG_TEXTURE&&!t(this._renderers,(e=>!e.isEmpty))}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}get mode(){return this.isEmpty?O.Disabled:this._overlayRenderTarget?.getTexture(w.Water)?O.EnabledWithWater:this._overlayRenderTarget?.getTexture(w.Color)?O.Enabled:O.Disabled}updateAnimation(e){let r=!1;return this._renderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateDrapeSourceOrder(){this._sortedDrapeSourceRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return;const{alignPixelEnabled:i,contentPixelRatio:o}=t;this._screenToWorldRatio=o*e.mapUnitsPerPixel/this._bindParameters.overlayStretch;const a=r.output;if(this.isEmpty||a===P.Highlight&&!this.hasHighlights||a===P.Normal&&!this.hasWater||!e.hasSomeSizedView())return;const n=this._rctx;this._camera.pixelRatio=e.pixelRatio*o,this._renderContext.output=a,this._bindParameters.alignPixelEnabled=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=a===P.Normal?V.DRAPED_WATER:V.DRAPED_MATERIAL;const d=b.OVERLAY_DRAW_DEBUG_TEXTURE&&r.type!==w.Occluded;if(!d&&!this._sortedRenderers.some((({renderer:e})=>e.shouldRender(this._renderContext))))return;e.applyViewport(this._rctx);const h=2*e.resolution,l=e.resolution,c=r.fbo;if(c.bind(n,h,l),e.index===v.INNER&&(n.setClearColor(0,0,0,0),n.clearSafe(K.COLOR_BUFFER_BIT)),r.type===w.Occluded&&(this._renderContext.renderOccludedMask=ie),d)for(let u=0;u<s.numViews;u++)this._setViewParameters(s.extents[u],e),this._ensureDebugPatternResources(e.resolution,te[e.index]),this._rctx.bindTechnique(this._debugTextureTechnique,this._passParameters,null),this._rctx.screen.draw();this._sortedRenderers.forAll((({drapeSource:t,renderer:i})=>{if(r.type===w.ColorNoRasterImage&&t.drapeSourceType===f.RasterImage)return;const{fullOpacity:o}=t,d=null!=o&&o<1&&a===P.Color?this.bindTemporaryFramebuffer(h,l):null;for(let r=0;r<s.numViews;r++)this._setViewParameters(s.extents[r],e),i.render(this._renderContext);if(d){c.bind(n,h,l),this._overlayParameters.texture=d.colorTexture,this._overlayParameters.opacity=o,this._overlayParameters.overlayIndex=e.index;const r=this.pluginContext.techniqueRepository.acquire(Y);this._rctx.bindTechnique(r,this._overlayParameters,this._renderContext.bindParameters),this._rctx.screen.draw(),r.release(),d.release()}})),n.bindFramebuffer(null),c.generateMipMap(),this._renderContext.resetRenderOccludedMask()}bindTemporaryFramebuffer(e,r){const t=this.view._stage.renderer.fboCache,s=t.acquire(S.RGBA,e,r);return t.rctx.bindFramebuffer(s.fbo),t.rctx.clearSafe(K.COLOR_BUFFER_BIT),s}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}notifyContentChanged(){this.events.emit("content-changed")}intersect(e,r,t,s){let i=0;for(const o of this._renderers.values())i=o.intersect?.(e,r,t,s,i)??i}_updateSortedDrapeSourceRenderers(){if(this._sortedRenderers.clear(),0===this._renderers.size)return;const e=this.view.map.allLayers;this._renderers.forEach(((r,t)=>{const s=e.indexOf(t.layer),i=s>=0,o=this._renderers.size*(t.renderGroup??(i?T.MapLayer:T.ViewLayer))+(i?s:0);this._sortedRenderers.push(new re(t,r,o))})),this._sortedRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r){const t=this._camera;t.viewport=[0,0,r.resolution,r.resolution],p(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),m(t.viewMatrix,[-e[0],-e[1],0])}_updateHasWater(){const e=t(this._renderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateRendersOccluded(){const e=t(this._renderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_ensureDebugPatternResources(e,r){if(_(this._passParameters.color,r[0],r[1],r[2]),this._passParameters.texture)return;const t=new Uint8Array(e*e*4);let s=0;for(let a=0;a<e;a++)for(let r=0;r<e;r++){const i=Math.floor(r/10),o=Math.floor(a/10);i<2||o<2||10*i>e-20||10*o>e-20?(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=255):(t[s++]=255,t[s++]=255,t[s++]=255,t[s++]=1&i&&1&o?1&r^1&a?0:255:1&i^1&o?0:128)}const i=new $(e);i.samplingMode=Q.NEAREST,this._passParameters.texture=new Z(this._rctx,i,t);const o=new k;o.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(I,o)}get test(){return{drapedRenderers:Array.from(this._renderers.values()),getDrapeSourceRenderer:e=>this._renderers.get(e)}}};e([c()],ee.prototype,"hasHighlights",void 0),e([c()],ee.prototype,"_sortedDrapeSourceRenderersDirty",void 0),e([c({autoDestroy:!0})],ee.prototype,"_shaderTechniqueRepository",void 0),e([c({constructOnly:!0})],ee.prototype,"view",void 0),e([c()],ee.prototype,"worldToPCSRatio",void 0),e([c()],ee.prototype,"spatialReference",void 0),e([c({type:Boolean,readOnly:!0})],ee.prototype,"updating",null),e([c()],ee.prototype,"isEmpty",null),ee=e([u("esri.views.3d.terrain.OverlayRenderer")],ee);class re{constructor(e,r,t){this.drapeSource=e,this.renderer=r,this.index=t}}const te=[[1,.5,.5],[.5,.5,1]],se=-2,ie=L.OccludeAndTransparent;export{se as DRAPED_Z,ee as OverlayRenderer,ie as overlayRenderOccludedFlag};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{disposeMaybe as r}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{I as o}from"../../../chunks/mat4f64.js";import{g as a,s as l,d as u}from"../../../chunks/vec3.js";import{Z as c,f as h,c as d}from"../../../chunks/vec3f64.js";import{Z as p}from"../../../chunks/vec4f64.js";import{create as _,set as f}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as m}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as g}from"../../ViewingMode.js";import{TextureUpdate as b}from"./interfaces.js";import{LayerClass as y}from"./LayerClass.js";import{OverlaySource as T}from"./Overlay.js";import{overlayRenderOccludedFlag as R}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as O}from"./PatchRenderData.js";import{RenderOrder as C}from"./RenderOrder.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as v}from"./terrainUtils.js";import{TileRenderer as D}from"./TileRenderer.js";import{TileUpdate as P}from"./TileUpdate.js";import{IteratorPreorder as S,sortTiles as q,compareTiles as E}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as A,ComponentIntersectionData as w}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as N}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as j}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as I}from"../webgl-engine/effects/RenderPlugin.js";import{Attribute as L}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as F}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as U}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as k}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as B,StoreResults as M}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as z}from"../webgl-engine/lib/Material.js";import{RenderSlot as V}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as H}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as W}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as Y,getVerticalOffsetTerrain as Q}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as X}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as Z,intersectTriangles as K}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as J}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as $}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as ee}from"../../webgl/enums.js";const te=7,re=10,ie=_();var se;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(se||(se={}));let ne=class extends I{get _isGlobal(){return this._stage.viewingMode===g.Global}get _techniques(){return this._context.techniqueRepository}get _rctx(){return this._context.renderContext.rctx}constructor(e){super(e),this.type=B.TERRAIN,this.isGround=!0,this.renderSlots=[V.OPAQUE_TERRAIN,V.TRANSPARENT_TERRAIN,V.OCCLUDED_TERRAIN],this._tileSize=256,this._techniqueConfiguration=new $,this._passParameters=new j,this._renderDataPool=new i(O),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new S,this._highestVisibleLODTile=null,this._transparencyState=se.Opaque,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=z.Occlude}initialize(){this._stage.addRenderPlugin(this)}destroy(){this._stage.removeRenderPlugin(this),x()}canRender(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}requires(e){return e===N.Depth&&this._overlayRenderer.hasWater}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===se.TransparentWithDraped||e===se.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return Y}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?R:z.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,P.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===P.TEXTURE_FADING?b.FADING:b.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const r of e.layerInfo[y.ELEVATION])r.pendingUpdates&=~P.GEOMETRY;e.resetPendingUpdate(P.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=re-te,r=Math.max(0,Math.floor((e.level-t)/te)*te);if(this._isGlobal&&0===r)return c;for(;e.parent&&e.level>r;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=F.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=F.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=F.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new D(this._rctx,this._tileSize,this._techniques,this._cache),this.updateTileBackground(),this._emptyTex=U(this._rctx)}uninitializeRenderContext(){this._emptyTex=r(this._emptyTex),this._tileRenderer=r(this._tileRenderer)}intersect(e,t,r,i){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==se.Opaque)return;const s=oe,n=ae;a(s,i,r),l(n,1/s[0],1/s[1],1/s[2]);const c=e.results.min,h=e.results.max,d=e.results.ground,p=e.options.store===M.MIN,_=!!e.results.ground.target,g=Q(e.verticalOffset),b=e.tolerance;let y,T=p&&null!=c.dist?c.dist:1/0;const R=l=>{const _=l.renderData;if(!_?.vao)return;const R=_.geometry;f(ie,R.boundingBox);const x=_.localOrigin;null!=g&&(g.localOrigin=x,g.applyToAabb(ie));const O=ie;if(le[0]=r[0]-x[0],le[1]=r[1]-x[1],le[2]=r[2]-x[2],!Z(O,le,n,b,T))return;const C=(e,t,r)=>{e.set(this.type,l,t,r,o),T=p&&null!=c.dist?c.dist:1/0},v=(n,o)=>{if(null!=o&&n>=0&&(e.options.backfacesTerrain||u(o,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(r,i,n))){if((null==d.dist||n<d.dist)&&C(d,n,o),e.options.isFiltered)return;e.options.store===M.ALL&&(null==y?(y=k(e.ray),C(y,n,o),e.results.all.push(y)):n<y.dist&&C(y,n,o)),(null==c.dist||n<c.dist)&&C(c,n,o),e.options.store!==M.MIN&&(null==h.dist||n>h.dist)&&C(h,n,o)}},D=ue;a(D,i,x);const P=R.indices,S=R.vertexAttributes,q=S.getField(W.POSITION,m),E=new L(q.typedBuffer,3,!1,S.stride/4),N=R.indexCount/3;if(!g&&N>A){const e=l.renderData;null==e.intersectionData&&(e.intersectionData=new w(P,0,N,E)),e.intersectionData.intersectRay({r0:le,r1:D},v)}else K(le,D,0,N,P,E,null,g,v)},x=this._rootTiles;if(null!=x){(()=>{const t=this._tileIterator;t.reset(x);const i=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||i&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(r,s,b,T)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._patchGroups.values())for(const r of t)null!=r.renderData?.textureReference&&e.queriesForTile(r);e.process(),t.madeProgress()}}prepareTechnique(e){if(e.bindParameters.slot===V.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&R))return null}else{const t=this.transparency===se.Opaque?V.OPAQUE_TERRAIN:V.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case N.Color:return this.transparency===se.Empty?null:(this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._techniqueConfiguration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(N.Color,e.bindParameters.slot===V.OCCLUDED_TERRAIN));case N.Shadow:case N.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(N.Shadow,!1)):null;case N.Depth:return this.transparency===se.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(N.Depth,!1));case N.Normal:return this.transparency===se.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(N.Normal,!1));case N.ObjectAndLayerIdColor:return this.transparency===se.Empty?null:this._updateTechnique(N.ObjectAndLayerIdColor,!1);case N.Highlight:return this.transparency!==se.Empty&&this._overlayRenderer.hasHighlights?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(N.Highlight,!1)):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case N.Color:{const r=e.bindParameters.slot===V.OCCLUDED_TERRAIN?T.Occluded:T.ColorAndWater;this._renderMaterialPass(e,t,r);break}case N.Depth:case N.Normal:this._renderAuxiliaryPass(e,t,T.ColorAndWater);break;case N.Highlight:this._renderAuxiliaryPass(e,t,T.Highlight);break;case N.Shadow:case N.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,T.None);break;case N.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,T.ObjectAndLayerIdColor)}}_renderMaterialPass(e,t,r){const{rctx:i}=e;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._renderPatchGroups(e,t,r)}_renderAuxiliaryPass(e,t,r){const i=e.rctx;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,r)}updateTileBackground(e=null){if(null==this._tileRenderer)return;const r=this._tileRenderer;let i=null;if(null!=e){const r=t.toUnitRGBA(e);i=h(r[0]||0,r[1]||0,r[2]||0)}r.setBackground(i),this._allTiles.forAll((e=>r.updateTileTexture(e,b.FADING))),this._techniqueConfiguration.tileBlendInput=r.backgroundIsGrid?G.GridComposite:null!=r.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==C.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const r of e)q(this.renderOrder,r,t);e.sort(((e,t)=>E(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),r=e.renderData;if(!r){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const i=r.localOrigin;let s=this._patchGroups.get(i);s||(s=new Array,this._patchGroups.set(i,s)),s.push(e),(!this._highestVisibleLODTile||e.elevationLevel>this._highestVisibleLODTile.elevationLevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,r){const i=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new X(n),e.bindParameters,this._passParameters);for(let o=0;o<s.length;o++)this._renderPatch(e,t,s[o],ee.TRIANGLES,i,r)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,r){const i=e.bindParameters.camera,s=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=H(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:i.fovY})}const n=this._stencilEnabledLayerExtents.length>0,o=r===T.Occluded;o&&(s.bindTexture("tex",this._emptyTex),s.setUniform3fv("textureOpacities",c),s.setUniform4fv("texOffsetAndScale",p));const a=null!=this._tileRenderer&&null!=this._tileRenderer.backgroundColor?this._tileRenderer.backgroundColor:c;this._techniqueConfiguration.tileBlendInput===G.ColorComposite&&s.setUniform3fv("backgroundColor",a);const l=this.wireframe?ee.LINES:ee.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&s.bindTexture("texNext",this._emptyTex);const u=this._patchGroups;for(const c of u.values()){const i=c[0].renderData.localOrigin;t.program.bindDraw(new X(i),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const a of c){const i=a.renderData,u=i.textureReference;if(null!=u){if(!o){s.setUniform4fv("texOffsetAndScale",u.offsetAndScale),s.bindTexture("tex",u.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(),s.setUniform3fv("textureOpacities",u.opacities)}this._renderPatch(e,t,a,l,n,r),a.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,r,i,s,n){const o=r.renderData,a=o.vao,l=a.indexBuffer;if(null==l)return void(v&&console.error("Rendered tile with no indices: ",r.lij," : ",o));const u=t.program;n===T.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(u,o.overlay),s&&(t.useStencil=this._useStencilForTile(r),t.bindPipelineState(e.rctx,e.bindParameters.slot));const c=o.geometry.indexCount;e.rctx.bindVAO(a),u.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(i,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(J,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([s({constructOnly:!0})],ne.prototype,"_overlayRenderer",void 0),e([s({constructOnly:!0})],ne.prototype,"_stage",void 0),e([s({readOnly:!0})],ne.prototype,"_isGlobal",null),e([s({constructOnly:!0})],ne.prototype,"_allTiles",void 0),e([s({constructOnly:!0})],ne.prototype,"_cache",void 0),e([s({constructOnly:!0})],ne.prototype,"_ellipsoidRadius",void 0),e([s({value:!1})],ne.prototype,"renderingDisabled",null),e([s({value:!0})],ne.prototype,"visible",null),e([s()],ne.prototype,"renderPatchBorders",null),e([s()],ne.prototype,"visualizeNormals",null),e([s()],ne.prototype,"cullBackFaces",null),e([s({value:C.FRONT_TO_BACK})],ne.prototype,"renderOrder",null),e([s()],ne.prototype,"wireframe",null),ne=e([n("esri.views.3d.terrain.TerrainRenderer")],ne);const oe=d(),ae=d(),le=d(),ue=d();export{ne as TerrainRenderer,se as TransparencyMode};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import{disposeMaybe as r}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{I as o}from"../../../chunks/mat4f64.js";import{g as a,s as l,d as u}from"../../../chunks/vec3.js";import{Z as c,f as h,c as d}from"../../../chunks/vec3f64.js";import{Z as p}from"../../../chunks/vec4f64.js";import{create as _,set as f}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as m}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as g}from"../../ViewingMode.js";import{TextureUpdate as b}from"./interfaces.js";import{LayerClass as y}from"./LayerClass.js";import{OverlaySource as T}from"./Overlay.js";import{overlayRenderOccludedFlag as R}from"./OverlayRenderer.js";import{clearCaches as x}from"./PatchGeometry.js";import{PatchRenderData as O}from"./PatchRenderData.js";import{RenderOrder as C}from"./RenderOrder.js";import{ENABLE_TERRAIN_INTERNAL_CHECKS as v}from"./terrainUtils.js";import{TileRenderer as D}from"./TileRenderer.js";import{TileUpdate as P}from"./TileUpdate.js";import{IteratorPreorder as S,sortTiles as q,compareTiles as E}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as A,ComponentIntersectionData as w}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as N}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as j}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as G}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as I}from"../webgl-engine/effects/RenderPlugin.js";import{Attribute as L}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as F}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as U}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as k}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as B,StoreResults as M}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as z}from"../webgl-engine/lib/Material.js";import{RenderSlot as V}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as H}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as W}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as Y,getVerticalOffsetTerrain as Q}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as X}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as Z,intersectTriangles as K}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as J}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as $}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as ee}from"../../webgl/enums.js";const te=7,re=10,ie=_();var se;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(se||(se={}));let ne=class extends I{get _isGlobal(){return this._stage.viewingMode===g.Global}get _techniques(){return this._context.techniqueRepository}get _rctx(){return this._context.renderContext.rctx}constructor(e){super(e),this.type=B.TERRAIN,this.isGround=!0,this.renderSlots=[V.OPAQUE_TERRAIN,V.TRANSPARENT_TERRAIN,V.OCCLUDED_TERRAIN],this._tileSize=256,this._techniqueConfiguration=new $,this._passParameters=new j,this._renderDataPool=new i(O),this._patchGroups=new Map,this._patchGroupsDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new S,this._highestVisibleLODTile=null,this._transparencyState=se.Opaque,this._castShadows=!0,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=z.Occlude}initialize(){this._stage.addRenderPlugin(this)}destroy(){this._stage.removeRenderPlugin(this),x()}produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(e){return e===N.Depth&&this._overlayRenderer.hasWater}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===se.TransparentWithDraped||e===se.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return Y}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?R:z.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,P.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===P.TEXTURE_FADING?b.FADING:b.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const r of e.layerInfo[y.ELEVATION])r.pendingUpdates&=~P.GEOMETRY;e.resetPendingUpdate(P.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=re-te,r=Math.max(0,Math.floor((e.level-t)/te)*te);if(this._isGlobal&&0===r)return c;for(;e.parent&&e.level>r;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=F.UPDATE){this._patchGroupsDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=F.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=F.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new D(this._rctx,this._tileSize,this._techniques,this._cache),this.updateTileBackground(),this._emptyTex=U(this._rctx)}uninitializeRenderContext(){this._emptyTex=r(this._emptyTex),this._tileRenderer=r(this._tileRenderer)}intersect(e,t,r,i){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==se.Opaque)return;const s=oe,n=ae;a(s,i,r),l(n,1/s[0],1/s[1],1/s[2]);const c=e.results.min,h=e.results.max,d=e.results.ground,p=e.options.store===M.MIN,_=!!e.results.ground.target,g=Q(e.verticalOffset),b=e.tolerance;let y,T=p&&null!=c.dist?c.dist:1/0;const R=l=>{const _=l.renderData;if(!_?.vao)return;const R=_.geometry;f(ie,R.boundingBox);const x=_.localOrigin;null!=g&&(g.localOrigin=x,g.applyToAabb(ie));const O=ie;if(le[0]=r[0]-x[0],le[1]=r[1]-x[1],le[2]=r[2]-x[2],!Z(O,le,n,b,T))return;const C=(e,t,r)=>{e.set(this.type,l,t,r,o),T=p&&null!=c.dist?c.dist:1/0},v=(n,o)=>{if(null!=o&&n>=0&&(e.options.backfacesTerrain||u(o,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(r,i,n))){if((null==d.dist||n<d.dist)&&C(d,n,o),e.options.isFiltered)return;e.options.store===M.ALL&&(null==y?(y=k(e.ray),C(y,n,o),e.results.all.push(y)):n<y.dist&&C(y,n,o)),(null==c.dist||n<c.dist)&&C(c,n,o),e.options.store!==M.MIN&&(null==h.dist||n>h.dist)&&C(h,n,o)}},D=ue;a(D,i,x);const P=R.indices,S=R.vertexAttributes,q=S.getField(W.POSITION,m),E=new L(q.typedBuffer,3,!1,S.stride/4),N=R.indexCount/3;if(!g&&N>A){const e=l.renderData;null==e.intersectionData&&(e.intersectionData=new w(P,0,N,E)),e.intersectionData.intersectRay({r0:le,r1:D},v)}else K(le,D,0,N,P,E,null,g,v)},x=this._rootTiles;if(null!=x){(()=>{const t=this._tileIterator;t.reset(x);const i=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||i&&e.intersectsClippingArea)||null==g&&!e.intersectsRay(r,s,b,T)||_&&this._useStencilForTile(e)?t.skipSubtree():R(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._patchGroups.values())for(const r of t)null!=r.renderData?.textureReference&&e.queriesForTile(r);e.process(),t.madeProgress()}}prepareTechnique(e){if(e.bindParameters.slot===V.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&R))return null}else{const t=this.transparency===se.Opaque?V.OPAQUE_TERRAIN:V.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}switch(e.output){case N.Color:return this.transparency===se.Empty?null:(this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._techniqueConfiguration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(N.Color,e.bindParameters.slot===V.OCCLUDED_TERRAIN));case N.Shadow:case N.ShadowExcludeHighlight:return this._castShadows&&1===e.bindParameters.lighting.globalFactor?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(N.Shadow,!1)):null;case N.Depth:return this.transparency===se.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(N.Depth,!1));case N.Normal:return this.transparency===se.Empty?null:(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(N.Normal,!1));case N.ObjectAndLayerIdColor:return this.transparency===se.Empty?null:this._updateTechnique(N.ObjectAndLayerIdColor,!1);case N.Highlight:return this.transparency!==se.Empty&&this._overlayRenderer.hasHighlights?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(N.Highlight,!1)):null}return null}render(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case N.Color:{const r=e.bindParameters.slot===V.OCCLUDED_TERRAIN?T.Occluded:T.ColorAndWater;this._renderMaterialPass(e,t,r);break}case N.Depth:case N.Normal:this._renderAuxiliaryPass(e,t,T.ColorAndWater);break;case N.Highlight:this._renderAuxiliaryPass(e,t,T.Highlight);break;case N.Shadow:case N.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,T.None);break;case N.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,T.ObjectAndLayerIdColor)}}_renderMaterialPass(e,t,r){const{rctx:i}=e;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this._renderPatchGroups(e,t,r)}_renderAuxiliaryPass(e,t,r){const i=e.rctx;this._passParameters.overlaySource=r,i.bindTechnique(t,this._passParameters,e.bindParameters),this._renderPatchGroupsAuxiliary(e,t,r)}updateTileBackground(e=null){if(null==this._tileRenderer)return;const r=this._tileRenderer;let i=null;if(null!=e){const r=t.toUnitRGBA(e);i=h(r[0]||0,r[1]||0,r[2]||0)}r.setBackground(i),this._allTiles.forAll((e=>r.updateTileTexture(e,b.FADING))),this._techniqueConfiguration.tileBlendInput=r.backgroundIsGrid?G.GridComposite:null!=r.backgroundColor?G.ColorComposite:G.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchGroupsDirty&&(this._highestVisibleLODTile=null,this._rebuildPatchGroups(),this._patchGroupsDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==C.NONE){const e=Array.from(this._patchGroups.values()),t=this._stencilEnabledLayerExtents;for(const r of e)q(this.renderOrder,r,t);e.sort(((e,t)=>E(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._patchGroups.clear();for(const t of e)this._rebuildPatchGroupsForRootTile(t)}}_rebuildPatchGroupsForRootTile(e){const t=this._tileIterator;for(t.resetOne(e);!t.done;){const e=t.next(),r=e.renderData;if(!r){this._numTilesCulled++;continue}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}const i=r.localOrigin;let s=this._patchGroups.get(i);s||(s=new Array,this._patchGroups.set(i,s)),s.push(e),(!this._highestVisibleLODTile||e.elevationLevel>this._highestVisibleLODTile.elevationLevel)&&(this._highestVisibleLODTile=e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,r){const i=this._stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;t.program.bindDraw(new X(n),e.bindParameters,this._passParameters);for(let o=0;o<s.length;o++)this._renderPatch(e,t,s[o],ee.TRIANGLES,i,r)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,r){const i=e.bindParameters.camera,s=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=H(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:i.fovY})}const n=this._stencilEnabledLayerExtents.length>0,o=r===T.Occluded;o&&(s.bindTexture("tex",this._emptyTex),s.setUniform3fv("textureOpacities",c),s.setUniform4fv("texOffsetAndScale",p));const a=null!=this._tileRenderer&&null!=this._tileRenderer.backgroundColor?this._tileRenderer.backgroundColor:c;this._techniqueConfiguration.tileBlendInput===G.ColorComposite&&s.setUniform3fv("backgroundColor",a);const l=this.wireframe?ee.LINES:ee.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&s.bindTexture("texNext",this._emptyTex);const u=this._patchGroups;for(const c of u.values()){const i=c[0].renderData.localOrigin;t.program.bindDraw(new X(i),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const a of c){const i=a.renderData,u=i.textureReference;if(null!=u){if(!o){s.setUniform4fv("texOffsetAndScale",u.offsetAndScale),s.bindTexture("tex",u.texture.texture);const e=i.textureFadeFactor,t=e<1?i.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(s.setUniform1f("fadeFactor",e),s.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),s.setUniform3fv("nextTexOpacities",t.opacities),s.bindTexture("texNext",t.texture.texture)):s.setUniform1f("fadeFactor",1),i.textureIsFading&&this.setNeedsRender(),s.setUniform3fv("textureOpacities",u.opacities)}this._renderPatch(e,t,a,l,n,r),a.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,r,i,s,n){const o=r.renderData,a=o.vao,l=a.indexBuffer;if(null==l)return void(v&&console.error("Rendered tile with no indices: ",r.lij," : ",o));const u=t.program;n===T.None||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(u,o.overlay),s&&(t.useStencil=this._useStencilForTile(r),t.bindPipelineState(e.rctx,e.bindParameters.slot));const c=o.geometry.indexCount;e.rctx.bindVAO(a),u.assertCompatibleVertexAttributeLocations(a),e.rctx.drawElements(i,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(J,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([s({constructOnly:!0})],ne.prototype,"_overlayRenderer",void 0),e([s({constructOnly:!0})],ne.prototype,"_stage",void 0),e([s({readOnly:!0})],ne.prototype,"_isGlobal",null),e([s({constructOnly:!0})],ne.prototype,"_allTiles",void 0),e([s({constructOnly:!0})],ne.prototype,"_cache",void 0),e([s({constructOnly:!0})],ne.prototype,"_ellipsoidRadius",void 0),e([s({value:!1})],ne.prototype,"renderingDisabled",null),e([s({value:!0})],ne.prototype,"visible",null),e([s()],ne.prototype,"renderPatchBorders",null),e([s()],ne.prototype,"visualizeNormals",null),e([s()],ne.prototype,"cullBackFaces",null),e([s({value:C.FRONT_TO_BACK})],ne.prototype,"renderOrder",null),e([s()],ne.prototype,"wireframe",null),ne=e([n("esri.views.3d.terrain.TerrainRenderer")],ne);const oe=d(),ae=d(),le=d(),ue=d();export{ne as TerrainRenderer,se as TransparencyMode};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/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/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as o,destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as _,isAborted as g,createAbortError as m}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as f,initial as v}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as S}from"../../../chunks/mat4.js";import{c as L}from"../../../chunks/mat4f64.js";import{i as D}from"../../../chunks/vec3.js";import{c as P}from"../../../chunks/vec3f64.js";import{c as x}from"../../../chunks/vec4f64.js";import{UpdatingHandles as U}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../geometry/ellipsoidUtils.js";import R from"../../../geometry/SpatialReference.js";import{projectPointToVector as C}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as M}from"../../../geometry/projection/projectVectorToVector.js";import{create as j,equals as A,intersection as I,empty as V,expand as B,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as F}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as W}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as H}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as z}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X}from"../support/cameraUtils.js";import{debugFlags as Y}from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{ElevationData as ee,sampleElevation as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{ScaleRangeQueries as de}from"./ScaleRangeQueries.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{SplitLimits as ue}from"./SplitLimits.js";import{MAX_ROOT_TILES as ce,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as _e,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ge,MAX_MEMORY_LOD_BIAS as me,ELEVATION_NODATA_VALUE as Te}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as fe}from"./TerrainRenderer.js";import ve from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as we,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as Le,isGroupLayerView as De,isMapTileLayerView as Pe,isBlendableLayerView as xe,isElevationLayerView as Ue,isVectorTileLayerView as be,useFetchTileForLayer as Re,isImageryTileLayerView as Ce,isTileLayerView as Me,releaseTileData as je,neighborCornerIndices as Ae,oppositeCorner as Ie,neighborEdgeIndices as Ve,ENABLE_TERRAIN_INTERNAL_CHECKS as Be,ENABLE_WATERPROOFNESS_TESTS as Oe,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Ne}from"./terrainUtils.js";import{Tile as qe}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as We,IteratorPostorder as He,compareTilesByLij as Qe,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Ye}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{UpsampleInfo as Ke}from"./UpsampleInfo.js";import{isCompositeBlendMode as Je,blendModeFromString as Ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as et}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as tt}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as it}from"../../support/RenderState.js";import{ImmediateTask as rt,TaskPriority as st,noBudget as at}from"../../support/Scheduler.js";let nt=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new de,this._iteratorPool=new p(We,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new He,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new ve,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=P(),this._eyePosSurfaceSR=P(),this._splitLimits=new ue,this._frustum=k(),this._viewProjectionMatrix=L(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new U,this._frameTask=rt,this._allTiles=new u,this._upsampleInfoPool=new p(Ke),this._rootTilesExtent=j(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=R.WebMercator,this.visibleElevationBounds=new Z(1/0,-1/0),this.rootTileElevationBounds=new Z(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.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this.overlayManager=new le({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new p(oe):new p(pe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._tileTextureCache=new d(((t,i)=>e.newCache(t,i)),"TileTexture"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:b(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles,_cache:this._tileTextureCache}),this.addHandles([T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),T((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency())),T((()=>this.renderer.visible),(e=>{this.suspended=!e}))],"overlayManager"),this.addHandles([T((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)}),y),T((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)),y),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.snapLevel),(()=>this._viewChanged=!0),f),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),T((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=h(this._treeDebugger))}),v)]);const{spatialReference:t}=this.view;this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:t});const i=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),r=new $e({layers:i,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:t});this._set("tilingSchemeLogic",r),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const a=this.view.resourceController.scheduler;this._frameTask=a.registerTask(st.TERRAIN_SURFACE,this),this.addHandles([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),v),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),T((()=>this.extent),(()=>this._updateRootTiles()),v),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),v),T((()=>this.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?et.Terrain:et.Disabled),v),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._lercDecoder=o(this._lercDecoder),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tilePool=h(this._tilePool),qe.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer=h(this._renderer),this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._tileTextureCache=h(this._tileTextureCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),z(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===re.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(t&&i){const r=e.state.contentCamera;let s=X(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a,l=Math.min(n+e.qualitySettings.tiledSurface.lodBias,this._splitLimits.maxLod||1/0);return l<=0?null:l}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?re.ON:re.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(null==t||null==e)return null;const i=j(),r=$(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=I(this.groundExtent,this._userClippingExtent,j()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.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._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=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}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===fe.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(null==s||!s.length)return null;if(0===s[0].layerInfo[ae.ELEVATION].length)return null;const a=pt;if(a[0]=e,a[1]=t,a[2]=i,!M(a,r,a,this._spatialReference))return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return Tt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[ae.ELEVATION].length:0;if(null!=r&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,Tt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!C(e,pt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(pt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;pt[0]>t[2]&&(i+=1),pt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t){if(pt[0]=e[0],pt[1]=e[1],pt[2]=e[2],pt[3]=e[3],!M(pt,t,pt,this.tilingScheme?.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let i=1/0,r=-1/0;const s=e=>{if(e&&O(e.extent,pt))if(e.isLeaf||e.rendered)i=Math.min(i,e.elevationBounds[0]),r=Math.max(r,e.elevationBounds[1]);else for(const t of e.children)s(t)},a=this._rootTiles;if(null!=a)for(const n of a)s(n);return{min:i,max:r}}getRootElevationBounds(){return{min:this.rootTileElevationBounds.min,max:this.rootTileElevationBounds.max}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,pt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;pt[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,pt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?fe.Empty:fe.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?fe.Opaque:fe.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;we(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??R.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 ct[0]=e,ct[1]=t,ct[2]=i,s.init(ct,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=ut;let s=t.rootTilesInExtent(e,i,5*ce);if(null!=this._rootTiles){if(s.length>ce)return void n.getLogger(this).warn(_e);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,ot);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>ot(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>ce&&(n.getLogger(this).warn(ge),s=t.rootTilesInExtent(e,i,ce)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.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(Qe);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(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==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 Z(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=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 Z(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?(null==this._splitLimits.frustum&&(this._splitLimits.frustum=k()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),S(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(ht(e)?this._loadChildren(e):dt(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=gt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),gt.spatialReference=this.spatialReference,this.emit("elevation-change",gt)}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;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.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.ELEVATION&&e.updateAgents(ae.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){Ee(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(Qe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.isLoaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData.cornerPeerNeighbors,o=e=>{const t=Ae[e];i(r,l[e]?.findCorner(Ie(t),(e=>e.isLoaded)))};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(Se(Ve[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Qe(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),Be&&Oe&&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(tt.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*me}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.renderer.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){we(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){mt.spatialReference=this.spatialReference,mt.extent=e.extent,mt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",mt)}_createTile(e,t,i,r){we(!!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!==it.IDLE}_mergeTile(e){we(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(we(!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){we(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 ee(e.lij,e.extent,i);e.dataArrived(t,ae.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=at){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),Le(s)||De(s))if(this._basemapLayerViewHandles.has(s.uid)&&!De(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);null!=i&&((i<r||null==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)&&!H(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((xe(e)||De(e))&&Je(Ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ue(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[];if((xe(e)||De(e))&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(se.UNFADED)}))),!De(e)){const i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Le(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===ae.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ne){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===ae.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(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(ae.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=tt.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||be(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,c(r),_(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===ae.ELEVATION?Ue(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(g(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{_(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:Te,signal:i.signal}).then((e=>{if(!g(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);n.getLogger(this).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:Te},i.signal))).then((e=>{e?r(new W(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,je(s),g(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),g(i)?je(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),l=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(be(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,l)}if(Ce(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,l);if(Me(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(g(i))return n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void l(m());a(e)}),l);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);F(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,l)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(ae.MAP,t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(je(i),n.getLogger(this).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);null!=s?e.dataMissing(s,t,r):n.getLogger(this).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}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(null==e||null==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 we(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:()=>{null!=e._rootTiles&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){_t.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&_t.push(e)}));const t=_t.toArray();return Ye(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Oe)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.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 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+(null!=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){Ne(e)}};e([w()],nt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],nt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],nt.prototype,"view",void 0),e([w({constructOnly:!0})],nt.prototype,"overlayManager",void 0),e([w()],nt.prototype,"_hasPendingUpdates",void 0),e([w()],nt.prototype,"_asyncWorkItems",void 0),e([w()],nt.prototype,"_allTilesDirty",void 0),e([w()],nt.prototype,"_allTilesSorted",void 0),e([w()],nt.prototype,"_viewChanged",void 0),e([w()],nt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],nt.prototype,"_watchUpdatingTracking",void 0),e([w()],nt.prototype,"_frameTask",void 0),e([w({readOnly:!0})],nt.prototype,"snapLevel",null),e([w({readOnly:!0})],nt.prototype,"lodSnapping",null),e([w()],nt.prototype,"_userClippingExtent",null),e([w()],nt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],nt.prototype,"extent",null),e([w({readOnly:!0})],nt.prototype,"groundExtent",null),e([w({readOnly:!0})],nt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],nt.prototype,"updating",null),e([w({readOnly:!0})],nt.prototype,"running",null),e([w(J)],nt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],nt.prototype,"updatingProgressValue",null),e([w()],nt.prototype,"_maxNumUpdating",void 0),e([w()],nt.prototype,"baseOpacity",null),e([w()],nt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],nt.prototype,"viewingMode",null),e([w()],nt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],nt.prototype,"ready",null),e([w({value:he.FRONT_TO_BACK})],nt.prototype,"renderOrder",null),e([w({readOnly:!0})],nt.prototype,"rootTiles",null),e([w()],nt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],nt.prototype,"spatialReference",null),e([w({type:t})],nt.prototype,"backgroundColor",null),e([w({value:!1})],nt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],nt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLogic",void 0),e([w()],nt.prototype,"wireframe",null),e([w({value:!1})],nt.prototype,"suspended",null),e([w()],nt.prototype,"textureFadeDuration",null),e([w()],nt.prototype,"visibleElevationBounds",void 0),e([w()],nt.prototype,"rootTileElevationBounds",void 0),e([w()],nt.prototype,"_layerViewsDirty",void 0),e([w()],nt.prototype,"renderPatchBorders",null),e([w()],nt.prototype,"visualizeNormals",null),e([w()],nt.prototype,"renderingDisabled",null),nt=e([E("esri.views.3d.terrain.TerrainSurface")],nt);const lt=nt;function ot(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ht(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(ht(i))return!0;return!1}function dt(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const pt=x(),ut=j(),ct=[0,0,0],_t=new u,gt={spatialReference:null,extent:j(),context:"ground"},mt={spatialReference:null,extent:null,scale:0};function Tt(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 te(t,i,s)}return null}export{lt 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/Logger.js";import{clamp as l}from"../../../core/mathUtils.js";import{releaseMaybe as o,destroyMaybe as h}from"../../../core/maybe.js";import{MemCachePool as d}from"../../../core/MemCachePool.js";import p from"../../../core/ObjectPool.js";import u from"../../../core/PooledArray.js";import{throwIfAborted as c,isAbortError as _,isAborted as g,createAbortError as m}from"../../../core/promiseUtils.js";import{watch as T,syncAndInitial as y,sync as f,initial as v}from"../../../core/reactiveUtils.js";import{property as w}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/has.js";import{subclass as E}from"../../../core/accessorSupport/decorators/subclass.js";import{m as S}from"../../../chunks/mat4.js";import{c as L}from"../../../chunks/mat4f64.js";import{i as D}from"../../../chunks/vec3.js";import{c as P}from"../../../chunks/vec3f64.js";import{c as x}from"../../../chunks/vec4f64.js";import{UpdatingHandles as U}from"../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as b}from"../../../geometry/ellipsoidUtils.js";import R from"../../../geometry/SpatialReference.js";import{projectPointToVector as C}from"../../../geometry/projection/projectPointToVector.js";import{projectVectorToVector as M}from"../../../geometry/projection/projectVectorToVector.js";import{create as j,equals as A,intersection as I,empty as V,expand as B,intersectsSphere as O}from"../../../geometry/support/aaBoundingRect.js";import{create as k,copy as N}from"../../../geometry/support/frustum.js";import{isPlateCarree as q}from"../../../geometry/support/spatialReferenceUtils.js";import{isRefreshableLayer as F}from"../../../layers/mixins/RefreshableLayer.js";import{ElevationQueryTileCache as G}from"../../../layers/support/ElevationQueryTileCache.js";import{ElevationTileData as W}from"../../../layers/support/ElevationTileData.js";import{isBaseLayer as H}from"../../../layers/support/layerUtils.js";import{acquireDecoder as Q}from"../../../layers/support/LercDecoder.js";import{printAllocations as z}from"../../2d/engine/vectorTiles/VectorTile.js";import{directionToHeadingTilt as X}from"../support/cameraUtils.js";import{debugFlags as Y}from"../support/debugFlags.js";import{toBoundingRect as $}from"../support/extentUtils.js";import{ClientType as K}from"../support/index.js";import{updatingProgress as J}from"../support/updatingProperties.js";import{ElevationBounds as Z}from"./ElevationBounds.js";import{ElevationData as ee,sampleElevation as te}from"./ElevationData.js";import{create as ie}from"./ExtentHelper.js";import{LODSnapping as re,TextureUpdate as se}from"./interfaces.js";import{LayerClass as ae,LayerClasses as ne}from"./LayerClass.js";import{OverlayManager as le}from"./OverlayManager.js";import{PlanarPatch as oe}from"./PlanarPatch.js";import{RenderOrder as he}from"./RenderOrder.js";import{ScaleRangeQueries as de}from"./ScaleRangeQueries.js";import{SphericalPatch as pe}from"./SphericalPatch.js";import{SplitLimits as ue}from"./SplitLimits.js";import{MAX_ROOT_TILES as ce,TOO_MANY_ROOT_TILES_AFTER_CHANGE_ERROR as _e,TOO_MANY_ROOT_TILES_FOR_LAYER_ERROR as ge,MAX_MEMORY_LOD_BIAS as me,ELEVATION_NODATA_VALUE as Te}from"./TerrainConst.js";import{TerrainRenderer as ye,TransparencyMode as fe}from"./TerrainRenderer.js";import ve from"./TerrainSurfacePerformanceInfo.js";import{weakAssert as we,internalAssert as Ee,oppositeEdge as Se,isSurfaceLayerView as Le,isGroupLayerView as De,isMapTileLayerView as Pe,isBlendableLayerView as xe,isElevationLayerView as Ue,isVectorTileLayerView as be,useFetchTileForLayer as Re,isImageryTileLayerView as Ce,isTileLayerView as Me,releaseTileData as je,neighborCornerIndices as Ae,oppositeCorner as Ie,neighborEdgeIndices as Ve,ENABLE_TERRAIN_INTERNAL_CHECKS as Be,ENABLE_WATERPROOFNESS_TESTS as Oe,enableTerrainInternalChecks as ke,enableTerrainWaterproofnessChecks as Ne}from"./terrainUtils.js";import{Tile as qe}from"./Tile.js";import{printAllocations as Fe}from"./TilePerLayerInfo.js";import{TileUpdate as Ge}from"./TileUpdate.js";import{IteratorPreorder as We,IteratorPostorder as He,compareTilesByLij as Qe,hasLoadableSiblings as ze,sortTilesByPOI as Xe,sortTiles as Ye}from"./tileUtils.js";import{TilingSchemeLogic as $e}from"./TilingSchemeLogic.js";import{UpsampleInfo as Ke}from"./UpsampleInfo.js";import{isCompositeBlendMode as Je,blendModeFromString as Ze}from"../webgl-engine/core/shaderLibrary/output/BlendOptions.js";import{PBRMode as et}from"../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{RenderRequestType as tt}from"../webgl-engine/lib/basicInterfaces.js";import{RenderState as it}from"../../support/RenderState.js";import{ImmediateTask as rt,TaskPriority as st,noBudget as at}from"../../support/Scheduler.js";let nt=class extends(a.EventedMixin(i)){constructor(e){super(e),this._scaleRangeQueries=new de,this._iteratorPool=new p(We,(e=>e.remove=()=>this._iteratorPool.release(e))),this._postorderIterator=new He,this._hasPendingUpdates=!1,this._pendingUpdates=0,this._asyncWorkItems=0,this._allTilesDirty=!0,this._allTilesSorted=!0,this._usedMemory=null,this._performanceInfo=new ve,this._viewChanged=!1,this._inFrameTask=!1,this._viewChangeUpdateDirty=!1,this._eyePosRenderSR=P(),this._eyePosSurfaceSR=P(),this._splitLimits=new ue,this._frustum=k(),this._viewProjectionMatrix=L(),this._layerViews=[new Array,new Array],this._layerIndexByUid=[new Map,new Map],this._basemapLayerViewHandles=new Map,this._watchUpdatingTracking=new U,this._frameTask=rt,this._allTiles=new u,this._upsampleInfoPool=new p(Ke),this._shouldEmitChangeEvent=!1,this._rootTilesExtent=j(),this.updatingProgress=.5,this._maxNumUpdating=1,this.maxTextureScale=1.2,this._spatialReference=R.WebMercator,this.visibleElevationBounds=new Z(1/0,-1/0),this.rootTileElevationBounds=new Z(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.unloadedMemory=0,this.ignoresMemoryFactor=!1,this._isWebMercator=!1,this._isWebMercatorOnPlateeCarree=!1,this.overlayManager=new le({...e,surface:this}),this._isGlobal=!e.view?.state?.isLocal}initialize(){this._lercDecoder=Q(this.view.resourceController),this._tilePool=this.view.state.isLocal?new p(oe):new p(pe);const e=this.view.resourceController.memoryController;this._upsampleMapCache=e.newCache("terrain-upsample",(e=>e.unloadMapData())),this._elevationQueryCache=new G(e.newCache("elevation-query")),this._tileTextureCache=new d(((t,i)=>e.newCache(t,i)),"TileTexture"),this._renderer=new ye({_overlayRenderer:this.overlayManager.renderer,_ellipsoidRadius:b(this.view.spatialReference).radius,_stage:this.view._stage,_allTiles:this._allTiles,_cache:this._tileTextureCache}),this.addHandles([T((()=>this.overlayManager.rendersOccluded),(e=>this._renderer.setRenderOccludedOverlay(e))),T((()=>this.overlayManager.renderer.isEmpty),(()=>this._evaluateTransparency())),T((()=>this.renderer.visible),(e=>{this.suspended=!e}))],"overlayManager"),this.addHandles([T((()=>this.baseOpacity),(()=>{this._handleLayerViewChanges(),this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)}),y),T((()=>this.hasCompositeBlendMode),(()=>this._updateTileTextures(this._evaluateTransparency()?se.UNFADED:se.IMMEDIATE)),y),T((()=>this.backgroundColor),(e=>{this._handleLayerViewChanges(),this._renderer.updateTileBackground(e)}),y),T((()=>this.snapLevel),(()=>this._viewChanged=!0),f),T((()=>this.view.pointsOfInterest),(e=>{this._renderer.pointsOfInterest=e,this._watchUpdatingTracking.removeAll(),e&&this._watchUpdatingTracking.add((()=>e.focus.renderLocation),(()=>this._allTilesSorted=!1))})),T((()=>Y.TERRAIN_TILE_TREE_SHOW_TILES),(e=>{e&&!this._treeDebugger?import("../layers/support/TerrainTileTree3DDebugger.js").then((({TerrainTileTree3DDebugger:e})=>{!this._treeDebugger&&Y.TERRAIN_TILE_TREE_SHOW_TILES&&(this._treeDebugger=new e({view:this.view}))})):e||(this._treeDebugger=h(this._treeDebugger))}),v)]);const{spatialReference:t}=this.view;this._extentHelper=ie(this.viewingMode,{layers:this.view.map.allLayers,layerViews:this.view.allLayerViews,viewSpatialReference:t});const i=new s({getCollections:()=>this.view?.defaultsFromMap?.mapCollections?.map((({layers:e})=>e)),getChildrenFunction:e=>e&&"layers"in e?e.layers:null}),r=new $e({layers:i,extentHelper:this._extentHelper,viewingMode:this.viewingMode,viewSpatialReference:t});this._set("tilingSchemeLogic",r),this._updateTilingScheme(),this._elevationDataRequester=this.view.resourceController.createStreamDataRequester(K.ELEVATION),this._mapDataRequester=this.view.resourceController.createStreamDataRequester(K.BASEMAP);const a=this.view.resourceController.scheduler;this._frameTask=a.registerTask(st.TERRAIN_SURFACE,this),this.addHandles([T((()=>this._extentHelper.stencilEnabledExtents),(e=>this._renderer.setStencilEnabledLayerExtents(e)),v),T((()=>this.tilingSchemeLogic.tilingScheme),(()=>this._updateTilingScheme()),f),T((()=>this.extent),(()=>this._updateRootTiles()),v),this.view.on("resize",(()=>this._viewChangeUpdate())),T((()=>{const e=this.view,t=e.state;return[this._lodBias,this.lodSnapping,e.quality,t.camera,t.contentCamera,t.fixedContentCamera]}),(()=>this._viewChangeUpdate()),y),T((()=>this.view.qualitySettings?.tiledSurface?.textureFadeDuration),(e=>this._renderer.textureFadingEnabled=e>0),v),T((()=>this.view.qualitySettings?.physicallyBasedRenderingEnabled),(e=>this._renderer.pbrMode=e?et.Terrain:et.Disabled),v),T((()=>this._userClippingExtent),(()=>this._updateClippingExtent()),f)]),this.addHandles(this.view.allLayerViews.on("after-changes",(()=>this._layerViewsDirty=!0))),this._layerViewsDirty=!0,this._handleLayerViewChanges()}destroy(){this._frameTask.remove(),this._watchUpdatingTracking.destroy(),this._lercDecoder=o(this._lercDecoder),this._removeAllTiles(),this._set("tilingSchemeLogic",h(this.tilingSchemeLogic)),this._basemapLayerViewHandles.forEach(((e,t)=>this._unregisterTiledLayerView(t))),this._elevationDataRequester=null,this._mapDataRequester=null,this._set("overlayManager",h(this.overlayManager)),this._tilePool=h(this._tilePool),qe.prune(),this._treeDebugger=h(this._treeDebugger),this._renderer=h(this._renderer),this._iteratorPool=h(this._iteratorPool),this._upsampleMapCache=h(this._upsampleMapCache),this._elevationQueryCache=h(this._elevationQueryCache),this._tileTextureCache=h(this._tileTextureCache),this._set("view",null),this._extentHelper=h(this._extentHelper),this._upsampleInfoPool=h(this._upsampleInfoPool),z(),Fe()}get renderer(){return this._renderer}get frustum(){return this._frustum}get snapLevel(){if(this.lodSnapping===re.ON){const e=this.view,t=this.tilingScheme,i=e.pointsOfInterest?.cameraOnSurface?.scale;if(t&&i){const r=e.state.contentCamera;let s=X(e,r.eye,r.viewForward,r.up).tilt;s>90&&(s=180-s);const a=2*(s/90)**2,n=t.levelAtScale(i)-a,l=Math.min(n+e.qualitySettings.tiledSurface.lodBias,this._splitLimits.maxLod||1/0);return l<=0?null:l}}return null}get lodSnapping(){return this.view.qualitySettings.tiledSurface.reduceTileLevelDifferences?re.ON:re.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(null==t||null==e)return null;const i=j(),r=$(t,i,e)?i:null,s=this._get("extent");return A(r,s)?s:r}get rootTilesExtent(){return this._rootTilesExtent}get extent(){const e=I(this.groundExtent,this._userClippingExtent,j()),t=this._get("extent");return A(e,t)?t:e}get groundExtent(){return null!=this._tilingSchemeExtent?this._tilingSchemeExtent:this._rootTilesExtent}get _tilingSchemeExtent(){return this.tilingSchemeLogic?.extent}get updating(){return this._hasPendingUpdates||(this._maxNumUpdating=1),!!((this.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._scaleRangeQueries.updating||this._frameTask.updating)&&this.ready&&!this.suspended}get updatingProgressValue(){return this._maxNumUpdating=Math.max(this._pendingUpdates,this._maxNumUpdating),1-this._pendingUpdates/this._maxNumUpdating}get baseOpacity(){return this.view?.map?.ground?.opacity??1}set baseOpacity(e){this.view.map.ground.opacity=e}get viewingMode(){return this.view.state.viewingMode}get ready(){return null!=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}get wireframe(){return this._renderer?.wireframe}set wireframe(e){e!==this._renderer.wireframe&&(this._renderer.wireframe=e,this._updateAllTileGeometries())}get opaque(){return this._renderer.transparency===fe.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(null==s||!s.length)return null;if(0===s[0].layerInfo[ae.ELEVATION].length)return null;const a=pt;if(a[0]=e,a[1]=t,a[2]=i,!M(a,r,a,this._spatialReference))return n.getLogger(this).error("TerrainSurface.getElevation(): could not project given point to tiling scheme coordinate system"),null;return Tt(s,a[0],a[1])}getElevations(e,t,i){const r=this._rootTiles,s=r?r[0].layerInfo[ae.ELEVATION].length:0;if(null!=r&&r.length&&0!==s)for(let a=0;a<t;++a){const t=3*a;i(a,Tt(r,e[t],e[t+1]))}else for(let a=0;a<t;++a)i(a,null)}getScale(e){if(!this.tilingScheme)return null;if(!C(e,pt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getScale(): could not project given point to tiling scheme coordinate system"),null;const t=this._rootTiles;if(null!=t)for(const i of t)if(i?.containsPoint(pt)){let e=i;for(;e.children[0]&&!e.rendered;){const t=e.children[0].extent;let i=0;pt[0]>t[2]&&(i+=1),pt[1]<t[1]&&(i+=2),e=e.children[i]}return this._getLodBiasCorrectedScale(e.level)}return 1/0}getSphereElevationBounds(e,t){if(pt[0]=e[0],pt[1]=e[1],pt[2]=e[2],pt[3]=e[3],!M(pt,t,pt,this.tilingScheme?.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereElevationBounds(): could not project given point to tiling scheme coordinate system"),null;let i=1/0,r=-1/0;const s=e=>{if(e&&O(e.extent,pt))if(e.isLeaf||e.rendered)i=Math.min(i,e.elevationBounds[0]),r=Math.max(r,e.elevationBounds[1]);else for(const t of e.children)s(t)},a=this._rootTiles;if(null!=a)for(const n of a)s(n);return{min:i,max:r}}getRootElevationBounds(){return{min:this.rootTileElevationBounds.min,max:this.rootTileElevationBounds.max}}getSphereScale(e,t){if(!this.tilingScheme)return null;if(!C(e,pt,this.spatialReference))return n.getLogger(this).error("TerrainSurface.getSphereScale(): could not project given point to tiling scheme coordinate system"),null;pt[3]=t;let i=null;const r=e=>{if(e&&O(e.extent,pt)){const t=e.children;if(t[0]&&!e.rendered)for(const e of t)r(e);else{const t=this._getLodBiasCorrectedScale(e.level);i=null==i?t:Math.min(i,t)}}},s=this._rootTiles;if(null!=s)for(const a of s)r(a);return i}queryVisibleScaleRange(e,t,i,r){const s=t?this.tilingScheme.levelAtScale(t):0,a=i?this.tilingScheme.levelAtScale(i):1/0,n=this._lodBias;this._scaleRangeQueries.queryVisibleLevelRange(e,s+n,a+n,r)}_evaluateTransparency(){const e=this.baseOpacity,t=this.overlayManager.renderer.isEmpty,i=this._renderer.transparency,r=this._allSurfaceLayersTransparent()?t?fe.Empty:fe.TransparentWithDraped:e>=1&&!this.hasCompositeBlendMode&&!this._renderer.slicePlaneEnabled?fe.Opaque:fe.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;we(!!e,"tiling scheme cannot be reset to undefined"),this._isGlobal=!this.view?.state?.isLocal,this.tilingScheme&&this._removeAllTiles();const t=e?.spatialReference??R.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 ct[0]=e,ct[1]=t,ct[2]=i,s.init(ct,r,this),s}get updatingRootTiles(){return this._updatingRootTiles}_updateRootTiles(){const{extent:e,tilingScheme:t}=this;if(!t)return;const i=ut;let s=t.rootTilesInExtent(e,i,5*ce);if(null!=this._rootTiles){if(s.length>ce)return void n.getLogger(this).warn(_e);const e=this._rootTiles.map((e=>e.lij)),t=r(e,s,ot);if(this._updatingRootTiles=!0,t.removed.length>0||t.added.length>0){const e=this._rootTiles.filter((e=>!(t.removed.findIndex((t=>ot(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>ce&&(n.getLogger(this).warn(ge),s=t.rootTilesInExtent(e,i,ce)),this._setRootTiles(s.map((e=>this._newRootTile(e))));A(i,this._rootTilesExtent)||(this._rootTilesExtent=j(i)),this.renderer.visible=!0,this._viewChangeUpdate(),this.overlayManager.setPlacementDirty(),this.notifyChange("ready"),this._updateAllTileGeometries(),this._updatingRootTiles=!1,this.checkAllTilesWaterproofness()}_updateAllTileGeometries(){const e=this._allTiles.filter((e=>e.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(Qe);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(),null!=e){const t=this._iteratorPool.acquire();for(t.reset(e);!t.done;)this._allTiles.push(t.next());t.remove()}this._renderer.setRootTiles(this._rootTiles),this._updateTilesVisibility(e)}_runViewChangeUpdateIfDirty(){this._viewChangeUpdateDirty&&(this._viewChangeUpdateDirty=!1,this._viewChangeUpdate())}_viewChangeUpdate(){this.view&&!this.suspended&&this.tilingScheme&&this.renderer.visible&&(this._inFrameTask?this._viewChangeUpdateDirty=!0:(this._viewChangeUpdateDirty=!1,this._updateViewDependentParameters(),this._updateTilesVisibility(this._rootTiles)))}_updateClippingStatus(e){e.updateClippingStatus(this.extent)&&e.resetPendingUpdate(Ge.GEOMETRY)&&this._updateTileGeometryState(e)}_updateTilesVisibility(e){if(null==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 Z(r,s))}_updateRootTileElevationBounds(){let e=1/0,t=-1/0;const i=this._rootTiles;null!=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 Z(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?(null==this._splitLimits.frustum&&(this._splitLimits.frustum=k()),N(this._splitLimits.frustum,t.frustum)):this._splitLimits.frustum=null,N(this._frustum,e.frustum),S(this._viewProjectionMatrix,t.projectionMatrix,t.viewMatrix),D(this._eyePosRenderSR,t.eye),M(e.eye,this.view.renderSpatialReference,this._eyePosSurfaceSR,this.spatialReference)}_updateRenderData(e){e.rendered&&!e.shouldLoad&&(ht(e)?this._loadChildren(e):dt(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(){if(!this._shouldEmitChangeEvent)return;const e=gt.extent;V(e),this._pendingTilesForElevationUpdateEvent.forEach((t=>B(e,t.extent,e))),this._pendingTilesForElevationUpdateEvent.clear(),gt.spatialReference=this.spatialReference,this.emit("elevation-change",gt),this._shouldEmitChangeEvent=!1}runTask(e){this._handleLayerViewChanges(e),this._frameTask.processQueue(e),this.renderer.processScaleRangeQueries(this._scaleRangeQueries,e),this._inFrameTask=!0,this._pendingUpdates=0,this._hasPendingUpdates=!1,this._updateAllTilesStatus(e),this._sortTiles(e);const t=!this.view.state.fixedContentCamera;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.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.ELEVATION&&e.updateAgents(ae.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){Ee(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(Qe);const r=t.length;for(let s=0;s<r;++s){const r=t[s];Ee(r.isLoaded),Ee(r.intersectsClippingArea);const a=r.renderData;a.updateNeighborData();const n=a._dirtyEdgeResolutions,l=a.geometryState.neighborData.cornerPeerNeighbors,o=e=>{const t=Ae[e];i(r,l[e]?.findCorner(Ie(t),(e=>e.isLoaded)))};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(Se(Ve[t]),(t=>!(!t.isLoaded||!t.intersectsClippingArea)&&(Ee(e.has(t)||Qe(r,t)<0),i(r,t),!0))),o((t+1)%4),o(t)}}e.clear(),this._updateTilesGeometries(t),this._shouldEmitChangeEvent=!0,Be&&Oe&&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(tt.UPDATE),this.overlayManager.setPlacementDirty(),this._updateRootTiles())}get _lodBias(){const e=this.view.quality;return this.view.qualitySettings.tiledSurface.lodBias-(1-e)*me}_getLodBiasCorrectedScale(e){const t=this.tilingScheme.levels,i=l(e-this._lodBias,0,t.length-1),r=i-Math.floor(i);return t[Math.floor(i)].scale*(1-r)+t[Math.ceil(i)].scale*r}_removeAllTiles(){null!=this._rootTiles&&(this._rootTiles.forEach((e=>this._purgeTile(e))),this._setRootTiles(null),this.notifyChange("ready")),this._allTiles.clear(),this.renderer.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){we(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){mt.spatialReference=this.spatialReference,mt.extent=e.extent,mt.scale=this._getLodBiasCorrectedScale(t),this.emit("scale-change",mt)}_createTile(e,t,i,r){we(!!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!==it.IDLE}_mergeTile(e){we(!e.hasPendingUpdate(Ge.SPLIT),"_mergeTile sanity check"),this._purgeDescendantTiles(e)&&(we(!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){we(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 ee(e.lij,e.extent,i);e.dataArrived(t,ae.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=at){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),Le(s)||De(s))if(this._basemapLayerViewHandles.has(s.uid)&&!De(s)){const e=this._layerClassFromLayerView(s),i=this._getLayerIdxByUID(e,s.uid);null!=i&&((i<r||null==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)&&!H(t.layer)&&0!==t.fullOpacity)return e=!1,e;return e}_hasCompositeBlendMode(){for(const e of this.view.allLayerViews.items)if((xe(e)||De(e))&&Je(Ze[e.layer.blendMode]))return!0;return!1}_layerClassFromLayerView(e){return Ue(e)?ae.ELEVATION:ae.MAP}_registerTiledLayerView(e){const t=[];if((xe(e)||De(e))&&t.push(T((()=>e.layer.blendMode),(()=>{this.hasCompositeBlendMode=this._hasCompositeBlendMode(),this._updateTileTextures(se.UNFADED)}))),!De(e)){const i=this._layerClassFromLayerView(e);t.push(T((()=>e.suspended),(()=>this._updateTiledLayers()))),t.push(T((()=>e.fullOpacity),(()=>this._updateTileTextures(se.UNFADED)))),t.push(T((()=>"effectiveScaleRange"in e.layer?e.layer.effectiveScaleRange:null),(()=>this._restartAllAgents(i)))),t.push(e.on("data-changed",(()=>{const t=this._getLayerIdxByUID(i,e.uid);null!=t&&this._invalidateLayerData(t,i)})))}this._unregisterTiledLayerView(e.uid),this._basemapLayerViewHandles.set(e.uid,t)}_unregisterTiledLayerView(e){const t=this._basemapLayerViewHandles.get(e);if(t){for(const e of t)e.remove();this._basemapLayerViewHandles.delete(e)}}_updateTiledLayers(){if(!this.tilingScheme||this.view.suspended)return;const e=this.view.allLayerViews,t=[[],[]];let i=null;e.forEach((e=>{if(!e.layer||e.suspended||!Le(e)||!e.fullExtent)return;const r=this._layerClassFromLayerView(e);if(r===ae.MAP){const t=e.displayLevelRange.maxLevel;t!==1/0&&(null===i||t>i)&&(i=t)}t[r].push(e)}));for(const r of ne){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===ae.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(ae.MAP),e===se.IMMEDIATE?this.renderer.updateTileTexture(t,Ge.TEXTURE_NOFADING):t.updateRenderData(ae.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=tt.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||be(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,c(r),_(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===ae.ELEVATION?Ue(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(g(i))return;const s=this._layerIndexByUid[ae.ELEVATION].get(t.uid);null!=s?(this._usedMemory=null,this.requestUpdate(),this._elevationDataArrived(e,s,r)):n.getLogger(this).warn("TerrainSurface: received data from unknown layer %d %s",ae.ELEVATION,e.lij.toString())},s=i=>{_(i)||(this._dataMissing(e,ae.ELEVATION,t,i),this.requestUpdate())};if(Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],{noDataValue:Te,signal:i.signal}).then((e=>{if(!g(i))return this._frameTask.schedule((()=>r(e)),i.signal,s);n.getLogger(this).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:Te},i.signal))).then((e=>{e?r(new W(e)):s(new Error("LERC decoding failed"))}),s).finally((()=>{--this._asyncWorkItems}))}_requestMapTileData(e,t,i){++this._asyncWorkItems;const r=(r,s)=>{--this._asyncWorkItems,je(s),g(i)||(this._dataMissing(e,ae.MAP,t,r),this.requestUpdate())},s=e=>t=>r(t,e),a=r=>this._frameTask.schedule((()=>{--this._asyncWorkItems,this.requestUpdate(),g(i)?je(r):this._mapTileDataArrived(e,t,r)}),i.signal,s(r)).catch(s(r)),l=(e,t=null)=>this._frameTask.schedule((()=>r(e,t)));if(be(t)){const r=t.schemaHelper.getLevelRowColumn(e.lij);return t.fetchTile(r[0],r[1],r[2],i).then(a,l)}if(Ce(t))return t.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then(a,l);if(Me(t)&&Re(t.layer))return t.layer.fetchTile(e.lij[0],e.lij[1],e.lij[2],i).then((e=>{if(g(i))return n.getLogger(this).warnOnce("A call to fetchTile resolved even though the request was aborted. fetchTile should not resolve if options.signal.aborted is true."),void l(m());a(e)}),l);let o=t.getTileUrl(e.lij[0],e.lij[1],e.lij[2]);F(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,l)}_mapTileDataArrived(e,t,i){const r=this._getLayerIdxByUID(ae.MAP,t.uid);null!=r?e.dataArrived(r,ae.MAP,i):(je(i),n.getLogger(this).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);null!=s?e.dataMissing(s,t,r):n.getLogger(this).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}get usedMemory(){return this.tilingScheme?(null==this._usedMemory&&(this._usedMemory=this._recalculateUsedMemory()),this._usedMemory??0):0}_recalculateUsedMemory(){return this.tilingScheme?Math.round(this._allTiles.reduce(((e,t)=>e+t.usedMemory),0)):null}getUsedMemoryForLayerView(e){let t=0;const i=this._layerClassFromLayerView(e),r=this._getLayerIdxByUID(i,e.uid);return null!=r&&this._allTiles.forAll((e=>t+=e.getUsedMemoryForLayer(i,r))),t}getTile(e){if(null==e||null==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 we(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:()=>{null!=e._rootTiles&&e._rootTiles.length>0&&(e._mergeTile(e._rootTiles[0]),e._viewChangeUpdate())},getTiles:()=>e._allTiles.toArray(),getRenderedTiles(){_t.clear(),e._allTiles.forAll((e=>{e.visible&&e.rendered&&_t.push(e)}));const t=_t.toArray();return Ye(e.renderOrder,t),t},lockTilingScheme(t,i){e._extentHelper.defaultTiledLayersExtent=i,e.tilingSchemeLogic.test.lockTilingScheme(t)}}}checkAllTilesWaterproofness(){if(!Oe)return;const e=this._rootTiles;if(null==e)return;const t=e=>e?.renderData?.geometry?.indices?.length>0,i=(e,i)=>{t(e)&&console.error("Tile[",e.lij,"] has geometry although parent[",i.lij,"] has geom")},r=e=>{if(e.intersectsClippingArea)if(e.renderData&&!e.renderData.geometryState&&console.error("Tile[",e.lij,"] has renderData but not geometryState"),e.renderData&&!e.renderData.geometry&&console.error("Tile[",e.lij,"] has renderData but not geometryInfo"),!e.renderData?.geometry||(e.renderData.geometry.indices?.length??0)>0||console.error("Tile[",e.lij,"] has renderData but no indices - geometryInfo: ",e.renderData.geometry),t(e)){e.checkGeometryWaterproofness();for(const t of e.children)i(t,e)}else if(e.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 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+(null!=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){Ne(e)}};e([w()],nt.prototype,"_renderer",void 0),e([w({constructOnly:!0})],nt.prototype,"_scaleRangeQueries",void 0),e([w({constructOnly:!0})],nt.prototype,"view",void 0),e([w({constructOnly:!0})],nt.prototype,"overlayManager",void 0),e([w()],nt.prototype,"_hasPendingUpdates",void 0),e([w()],nt.prototype,"_asyncWorkItems",void 0),e([w()],nt.prototype,"_allTilesDirty",void 0),e([w()],nt.prototype,"_allTilesSorted",void 0),e([w()],nt.prototype,"_viewChanged",void 0),e([w()],nt.prototype,"_splitLimits",void 0),e([w({readOnly:!0})],nt.prototype,"_watchUpdatingTracking",void 0),e([w()],nt.prototype,"_frameTask",void 0),e([w({readOnly:!0})],nt.prototype,"snapLevel",null),e([w({readOnly:!0})],nt.prototype,"lodSnapping",null),e([w()],nt.prototype,"_userClippingExtent",null),e([w()],nt.prototype,"_rootTilesExtent",void 0),e([w({readOnly:!0})],nt.prototype,"extent",null),e([w({readOnly:!0})],nt.prototype,"groundExtent",null),e([w({readOnly:!0})],nt.prototype,"_tilingSchemeExtent",null),e([w({readOnly:!0})],nt.prototype,"updating",null),e([w({readOnly:!0})],nt.prototype,"running",null),e([w(J)],nt.prototype,"updatingProgress",void 0),e([w({readOnly:!0})],nt.prototype,"updatingProgressValue",null),e([w()],nt.prototype,"_maxNumUpdating",void 0),e([w()],nt.prototype,"baseOpacity",null),e([w()],nt.prototype,"hasCompositeBlendMode",void 0),e([w({readOnly:!0})],nt.prototype,"viewingMode",null),e([w()],nt.prototype,"maxTextureScale",void 0),e([w({readOnly:!0})],nt.prototype,"ready",null),e([w({value:he.FRONT_TO_BACK})],nt.prototype,"renderOrder",null),e([w({readOnly:!0})],nt.prototype,"rootTiles",null),e([w()],nt.prototype,"_rootTiles",void 0),e([w({readOnly:!0})],nt.prototype,"spatialReference",null),e([w({type:t})],nt.prototype,"backgroundColor",null),e([w({value:!1})],nt.prototype,"slicePlaneEnabled",null),e([w({readOnly:!0})],nt.prototype,"tilingScheme",void 0),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLocked",null),e([w({readOnly:!0})],nt.prototype,"tilingSchemeLogic",void 0),e([w()],nt.prototype,"wireframe",null),e([w({value:!1})],nt.prototype,"suspended",null),e([w()],nt.prototype,"textureFadeDuration",null),e([w()],nt.prototype,"visibleElevationBounds",void 0),e([w()],nt.prototype,"rootTileElevationBounds",void 0),e([w()],nt.prototype,"_layerViewsDirty",void 0),e([w()],nt.prototype,"renderPatchBorders",null),e([w()],nt.prototype,"visualizeNormals",null),e([w()],nt.prototype,"renderingDisabled",null),nt=e([E("esri.views.3d.terrain.TerrainSurface")],nt);const lt=nt;function ot(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ht(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(ht(i))return!0;return!1}function dt(e){return e.isLeaf&&(e.parent?.shouldLoad??!1)}const pt=x(),ut=j(),ct=[0,0,0],_t=new u,gt={spatialReference:null,extent:j(),context:"ground"},mt={spatialReference:null,extent:null,scale:0};function Tt(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 te(t,i,s)}return null}export{lt 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.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as s}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/Error.js";import{subclass as e}from"../../../../../core/accessorSupport/decorators/subclass.js";import{f as t,t as r,e as a}from"../../../../../chunks/mat3.js";import{c as i}from"../../../../../chunks/mat3f64.js";import{c as h}from"../../../../../chunks/mat4.js";import{s as o,i as n}from"../../../../../chunks/vec3.js";import{c as m}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as l,ShadowMapPassParameters as c,HighlightPassParameters as p,RenderPassIdentifier as u}from"./AllRenderPasses.js";import{RenderPass as d,RenderPassSorting as _}from"./RenderPass.js";import{ShaderOutput as g}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as P}from"../util/TwoVectorPosition.js";import{SyncPreparesRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f,union as R}from"../../lib/depthRange.js";import{RenderSlot as A}from"../../lib/RenderSlot.js";let T=class extends w{get renderSlots(){return[A.OPAQUE_MATERIAL,A.TRANSPARENT_MATERIAL,A.INTEGRATED_MESH]}constructor(){super({}),this._passes=null,this._materialPassParameters=new l,this._shadowPassParameters=new c,this._highlightPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s;const e=s.renderContext.rctx,t=s.techniqueRepository;this._passes={materialOpaque:new d(e,t),materialTransparent:new d(e,t,_.BackToFront),materialIntegratedMesh:new d(e,t),shadowMap:new d(e,t),highlight:new d(e,t),highlightIntegratedMesh:new d(e,t),highlightShadowMap:new d(e,t),defaultShadowMap:new d(e,t)}}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}
|
|
5
|
+
import{_ as s}from"../../../../../chunks/tslib.es6.js";import"../../../../../core/Logger.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import"../../../../../core/Error.js";import{subclass as e}from"../../../../../core/accessorSupport/decorators/subclass.js";import{f as t,t as r,e as a}from"../../../../../chunks/mat3.js";import{c as i}from"../../../../../chunks/mat3f64.js";import{c as h}from"../../../../../chunks/mat4.js";import{s as o,i as n}from"../../../../../chunks/vec3.js";import{c as m}from"../../../../../chunks/vec3f64.js";import{MaterialPassParameters as l,ShadowMapPassParameters as c,HighlightPassParameters as p,RenderPassIdentifier as u}from"./AllRenderPasses.js";import{RenderPass as d,RenderPassSorting as _}from"./RenderPass.js";import{ShaderOutput as g}from"../shaderLibrary/ShaderOutput.js";import{TwoVectorPosition as P}from"../util/TwoVectorPosition.js";import{SyncPreparesRenderPlugin as w}from"../../effects/RenderPlugin.js";import{DepthRange as f,union as R}from"../../lib/depthRange.js";import{RenderSlot as A}from"../../lib/RenderSlot.js";let T=class extends w{get renderSlots(){return[A.OPAQUE_MATERIAL,A.TRANSPARENT_MATERIAL,A.INTEGRATED_MESH]}constructor(){super({}),this._passes=null,this._materialPassParameters=new l,this._shadowPassParameters=new c,this._highlightPassParameters=new p,this._systems=new Set}initializeRenderContext(s){this._context=s;const e=s.renderContext.rctx,t=s.techniqueRepository;this._passes={materialOpaque:new d(e,t),materialTransparent:new d(e,t,_.BackToFront),materialIntegratedMesh:new d(e,t),shadowMap:new d(e,t),highlight:new d(e,t),highlightIntegratedMesh:new d(e,t),highlightShadowMap:new d(e,t),defaultShadowMap:new d(e,t)}}get rctx(){return this._context.renderContext.rctx}uninitializeRenderContext(){}dispose(){this._context=null,this._systems.clear()}register(s){this._systems.add(s)}produces(s,e){return 0!==this._systems.size&&null!==this._passes&&(e===g.Highlight?this._passes.highlight.count>0||this._passes.highlightIntegratedMesh.count>0:e===g.ShadowHighlight?this._passes.highlight.count>0:s!==A.TRANSPARENT_MATERIAL||this._passes.materialTransparent.count>0)}prepareRender(s){if(0!==this._systems.size&&null!==this._passes){for(const s of Object.values(this._passes))s.prepareSubmit();this._systems.forEach((e=>e.submit(this._passes,s.bindParameters)));for(const s of Object.values(this._passes))s.finishSubmit();this._context.techniqueRepository.frameUpdate()}}prepareTechniques(s){return 0===this._systems.size?null:(this._configure(s),this._materialPassParameters.output=s.output,this._invoke(s,((e,t)=>e.prepare(t,s.bindParameters))))}render(s,e){this._invoke(s,((t,r)=>t.dispatch(r,s.bindParameters,e)))}_invoke(s,e){if(null===this._passes)return null;switch(s.bindParameters.slot){case A.OPAQUE_MATERIAL:switch(s.output){case g.Color:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialOpaque,this._materialPassParameters);case g.Highlight:return e(this._passes.highlight,this._highlightPassParameters);case g.Shadow:return e(this._passes.shadowMap,this._shadowPassParameters);case g.ShadowHighlight:return e(this._passes.highlightShadowMap,this._shadowPassParameters);case g.ShadowExcludeHighlight:return e(this._passes.defaultShadowMap,this._shadowPassParameters)}break;case A.TRANSPARENT_MATERIAL:switch(s.output){case g.Color:case g.Alpha:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialTransparent,this._materialPassParameters)}break;case A.INTEGRATED_MESH:switch(s.output){case g.Color:case g.Depth:case g.Normal:case g.ObjectAndLayerIdColor:return e(this._passes.materialIntegratedMesh,this._materialPassParameters);case g.Highlight:return e(this._passes.highlightIntegratedMesh,this._highlightPassParameters)}}return null}notifyDirty(){this._context.requestRender()}queryDepthRange(s){const e=new f;return this._systems.forEach((t=>R(e,t.queryShadowCasterDepthRange(s)))),e}_configure(s){const e=s.output===g.Shadow||s.output===g.ShadowHighlight||s.output===g.ShadowExcludeHighlight?this._shadowPassParameters:s.output===g.Highlight?this._highlightPassParameters:this._materialPassParameters;this._updateParameters(s,e)}_updateParameters(s,e){const i=s.bindParameters.camera,m=i.viewInverseTransposeMatrix;o(S,m[3],m[7],m[11]),E.set(S),n(e.transformWorldFromViewTH,E.high),n(e.transformWorldFromViewTL,E.low),n(e.slicePlaneLocalOrigin,S),t(e.transformViewFromCameraRelativeRS,i.viewMatrix),h(e.transformProjFromView,i.projectionMatrix),e.identifier===u.Material&&(this._materialPassParameters.transparent=s.bindParameters.slot===A.TRANSPARENT_MATERIAL,this._materialPassParameters.integratedMesh=s.bindParameters.slot===A.INTEGRATED_MESH,r(j,e.transformViewFromCameraRelativeRS),a(e.transformNormalViewFromGlobal,j))}};T=s([e("esri.views.3d.webgl-engine.core.renderPasses.RenderPassManager")],T);const S=m(),j=i(),E=new P;export{T as RenderPassManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Accessor.js";class s extends e{
|
|
5
|
+
import e from"../../../../core/Accessor.js";class s extends e{consumes(e){return!1}get usedMemory(){return 0}get isDecoration(){return!1}get running(){return!1}}class r extends s{}class t extends s{}class n extends s{}class c extends s{}class o extends s{}export{o as ASyncPreparesRenderPlugin,c as AsyncRenderPlugin,t as SyncPrepareRenderPlugin,n as SyncPreparesRenderPlugin,r as SyncRenderPlugin};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{isPromiseLike as n,createAbortError as s}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{ShaderOutput as l}from"../core/shaderLibrary/ShaderOutput.js";import{Decorations as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import r from"../../../../core/Accessor.js";import t from"../../../../core/PooledArray.js";import{isPromiseLike as n,createAbortError as s}from"../../../../core/promiseUtils.js";import{property as o}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/accessorSupport/ensureType.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import{subclass as i}from"../../../../core/accessorSupport/decorators/subclass.js";import{ShaderOutput as l}from"../core/shaderLibrary/ShaderOutput.js";import{Decorations as u}from"../lib/basicInterfaces.js";import{DepthRange as d,union as a}from"../lib/depthRange.js";import{RenderOccludedFlag as c}from"../lib/Material.js";import{RenderSlot as p}from"../lib/RenderSlot.js";let h=class extends r{constructor(e){super({}),this._context=e,this._renderPlugins=new t,this._slots=new Array;for(let r=0;r<p.MAX_SLOTS;++r)this._slots[r]=[]}normalizeCtorArgs(){return{}}add(e,r){const t=()=>{if(r?.aborted)throw e.uninitializeRenderContext(),s();this._renderPlugins.push(e);for(const r of e.renderSlots)this._slots[r].push(e);this._context.requestRender(),this.notifyChange("updating")},o=e.initializeRenderContext(this._context,r);if(n(o))return o.then(t);t()}remove(e){if(null!=this._renderPlugins.removeUnordered(e)){for(let r=0;r<this._slots.length;++r)this._slots[r]=this._slots[r].filter((r=>r!==e));e.uninitializeRenderContext(),this._context.requestRender(),this.notifyChange("updating")}}prepareRender(){this._renderPlugins.forAll((e=>{e.prepareRender&&e.prepareRender(this._context.renderContext)}))}updateAnimation(e){let r=!1;return this._renderPlugins.forAll((t=>{t.updateAnimation&&(r=t.updateAnimation(e)||r)})),r}renderFeatureChanged(){this._renderPlugins.forAll((e=>{e.renderFeatureChanged&&e.renderFeatureChanged()}))}prepareSlots(e){for(const r of e)this._context.renderContext.bindParameters.slot=r,this._slots[r].filter((e=>{e.produces(r,l.Color)&&(m(e)&&e.prepareTechnique(this._context.renderContext),g(e)&&e.prepareTechniques(this._context.renderContext))}))}prepare(e){this._context.renderContext.bindParameters.slot=e;const r=this._slots[e],t=new Map;return r.forEach((r=>{if(r.produces(e,l.Color)&&(!r.isDecoration||this._context.renderContext.bindParameters.decorations!==u.OFF))if(m(r)){const e=r.prepareTechnique(this._context.renderContext);null!=e&&t.set(r,e)}else if(g(r)){const e=r.prepareTechniques(this._context.renderContext);null!=e&&t.set(r,e)}else t.set(r,null)})),t}render(e,r=null,t=null){let n;return e.forEach(((e,s)=>{n=s.render(this._context.renderContext,e,r,t)})),n}queryDepthRange(e){const r=new d;return this._renderPlugins.forAll((t=>{const n=t.queryDepthRange&&t.queryDepthRange(e);a(r,n)})),r}get updating(){return this._renderPlugins.some((e=>e.running))}produces(e,r=l.Color){return this._slots[e].some((t=>t.produces(e,r)))}consumes(e){return this._renderPlugins.some((r=>r.consumes(e)))}get hasDecorations(){return this._renderPlugins.some((e=>e.isDecoration))}get renderOccludedFlags(){return this._renderPlugins.reduce(((e,r)=>e|r.renderOccludedFlags),c.None)}get usedMemory(){return this._renderPlugins.reduce(((e,r)=>e+(r.usedMemory??0)),0)}};function m(e){return"prepareTechnique"in e}function g(e){return"prepareTechniques"in e}e([o({readOnly:!0})],h.prototype,"updating",null),h=e([i("esri.views.3d.webgl-engine.lib.RenderPluginManager")],h);export{h as RenderPluginManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{releaseMaybe as r,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../../chunks/vec2.js";import{ColorFormat as n}from"../../core/FBOCache.js";import{ShaderOutput as c}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as t}from"../../../../../core/colorUtils.js";import{releaseMaybe as r,disposeMaybe as i}from"../../../../../core/maybe.js";import{watch as s,syncAndInitial as o}from"../../../../../core/reactiveUtils.js";import{property as a}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{s as l}from"../../../../../chunks/vec2.js";import{ColorFormat as n}from"../../core/FBOCache.js";import{ShaderOutput as c}from"../../core/shaderLibrary/ShaderOutput.js";import{SyncRenderPlugin as p}from"../RenderPlugin.js";import{HighlightApplyTechnique as u}from"./HighlightApplyTechnique.js";import{HighlightBlurTechnique as m}from"./HighlightBlurTechnique.js";import{defaultColor as _,defaultHaloOpacity as d,defaultFillOpacity as g}from"./HighlightDefaults.js";import{HighlightDownsampleTechnique as b}from"./HighlightDownsampleTechnique.js";import{HighlightPassParameters as f}from"./HighlightPassParameters.js";import{Default3D as w}from"../../lib/DefaultVertexAttributeLocations.js";import{Pos2Tex as T}from"../../lib/DefaultVertexBufferLayouts.js";import{RenderSlot as q}from"../../lib/RenderSlot.js";import{VertexArrayObject as v}from"../../lib/VertexArrayObject.js";import{H as x}from"../../../../../chunks/HighlightBlur.glsl.js";import{H as y,G as P}from"../../../../../chunks/HighlightDownsample.glsl.js";import{BufferObject as j}from"../../../../webgl/BufferObject.js";import{ClearBufferBit as C,Usage as O}from"../../../../webgl/enums.js";import{vertexCount as R}from"../../../../webgl/Util.js";let D=class extends p{constructor(e){super(e),this.renderSlots=[q.HIGHLIGHT],this._context=null,this._passParameters=new f,this._downsampleDrawParameters=new y,this._blurDrawParameters=new x,this._grid={coverage:null,vao:null,verticalCellCount:0,horizontalCellCount:0,viewportWidth:0,viewportHeight:0}}produces(){return!0}consumes(e){return e===c.Highlight}initializeRenderContext(e){this._context=e,null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),null==this._downsampleTechnique&&(this._downsampleTechnique=this._context.techniqueRepository.acquire(b)),null==this._applyTechnique&&(this._applyTechnique=this._context.techniqueRepository.acquire(u)),this.addHandles([s((()=>this.view.highlightOptions.color),(e=>{this._passParameters.color=t(e??_),this.view.highlightOptions.haloColor||(this._passParameters.haloColor=this._passParameters.color),this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloColor),(e=>{this._passParameters.haloColor=null!=e?t(e):this._passParameters.color,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.haloOpacity),(e=>{this._passParameters.haloOpacity=e??d,this._passParameters.haloOpacityOccluded=.25*this._passParameters.haloOpacity,this._context.requestRender()}),o),s((()=>this.view.highlightOptions.fillOpacity),(e=>{this._passParameters.fillOpacity=e??g,this._passParameters.fillOpacityOccluded=.25*this._passParameters.fillOpacity,this._context.requestRender()}),o)])}uninitializeRenderContext(){this._context=null}dispose(){this._blurTechnique=r(this._blurTechnique),this._downsampleTechnique=r(this._downsampleTechnique),this._applyTechnique=r(this._applyTechnique),this._grid.coverage=r(this._grid.coverage),this._grid.vao=i(this._grid.vao)}render(e,t,r,i){const s=r?.highlightTexture;if(!this._context||!s)return;if(!(this._blurTechnique.compiled&&this._downsampleTechnique.compiled&&this._applyTechnique.compiled))return void this._context.requestRender();const o=e.bindParameters.camera,a=o.fullWidth,h=o.fullHeight,c=o.pixelRatio,p=Math.ceil(a/c),u=Math.ceil(h/c),m=this._context.fbos.rctx,_=this._context.fbos;this._gridUpdateResources(s),this._gridComputeCoverage(s,e.bindParameters),this._passParameters.highlightTexture=s,this._passParameters.coverageTexture=this._grid.coverage?.colorTexture;const d=m.bindTechnique(this._blurTechnique,this._passParameters,e.bindParameters),g=this._grid.vao;m.bindVAO(g);const b=_.acquire(n.RGBA4,p,u);m.bindFramebuffer(b.fbo),m.setViewport(0,0,p,u),m.setClearColor(0,0,0,0),m.clear(C.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=s,l(this._blurDrawParameters.blurSize,1/p,0),d.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,R(g,"geometry"));const f=_.acquire(n.RGBA4,p,u);m.bindFramebuffer(f.fbo),m.clear(C.COLOR_BUFFER_BIT),this._blurDrawParameters.blurInputTexture=b.colorTexture,l(this._blurDrawParameters.blurSize,0,1/u),d.bindDraw(this._blurDrawParameters,e.bindParameters,this._passParameters),m.drawArrays(this._blurTechnique.primitiveType,0,R(g,"geometry")),m.bindFramebuffer(i),m.setViewport4fv(o.fullViewport),this._passParameters.blurTexture=f.colorTexture,m.bindTechnique(this._applyTechnique,this._passParameters,e.bindParameters),m.drawArrays(this._applyTechnique.primitiveType,0,R(g,"geometry")),f.release(),b.release()}_gridUpdateResources(e){if(!this._context)return;const t=this._context.fbos.rctx,r=this._grid,s=Math.ceil(e.descriptor.height/P),o=Math.ceil(e.descriptor.width/P);if(!r.vao||r.verticalCellCount!==s||r.horizontalCellCount!==o){r.verticalCellCount=s,r.horizontalCellCount=o;const e=s+1,a=o+1,h=1/s,l=1/o,n=6,c=4,p=new Float32Array(n*c*e*a);let u=0;for(let t=0;t<e;t++)for(let e=0;e<a;e++)p[u]=(e-.5)*l*2-1,p[u+1]=(t-.5)*h*2-1,p[u+2]=e*l,p[u+3]=t*h,p[u+4]=(e+.5)*l*2-1,p[u+5]=(t-.5)*h*2-1,p[u+6]=e*l,p[u+7]=t*h,p[u+8]=(e-.5)*l*2-1,p[u+9]=(t+.5)*h*2-1,p[u+10]=e*l,p[u+11]=t*h,p[u+12]=(e-.5)*l*2-1,p[u+13]=(t+.5)*h*2-1,p[u+14]=e*l,p[u+15]=t*h,p[u+16]=(e+.5)*l*2-1,p[u+17]=(t-.5)*h*2-1,p[u+18]=e*l,p[u+19]=t*h,p[u+20]=(e+.5)*l*2-1,p[u+21]=(t+.5)*h*2-1,p[u+22]=e*l,p[u+23]=t*h,u+=n*c;r.vao=i(r.vao),r.vao=new v(t,w,{geometry:T},{geometry:j.createVertex(t,O.STATIC_DRAW,p)})}}_gridComputeCoverage(e,t){if(!this._context)return;const r=this._context.fbos.rctx,i=this._grid,s=r.bindTechnique(this._downsampleTechnique,this._passParameters,t),o=e.descriptor;i.coverage?.release(),i.coverage=this._context.fbos.acquire(n.RG,Math.ceil(o.width/P),Math.ceil(o.height/P)),r.bindFramebuffer(i.coverage.fbo),this._downsampleDrawParameters.input=e,s.bindDraw(this._downsampleDrawParameters,t,this._passParameters);const{width:a,height:h}=o;r.setViewport(0,0,a,h),r.screen.draw()}get test(){return{coverage:this._grid.coverage}}};e([a()],D.prototype,"_context",void 0),e([a()],D.prototype,"view",void 0),D=e([h("esri.views.3d.webgl-engine.lib.Highlight")],D);export{D as Highlight};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as e}from"../../../../../core/colorUtils.js";import{smoothstep as
|
|
5
|
+
import{_ as t}from"../../../../../chunks/tslib.es6.js";import{unitRGBAFromColor as e}from"../../../../../core/colorUtils.js";import{smoothstep as s,clamp as i}from"../../../../../core/mathUtils.js";import{watch as r,syncAndInitial as a}from"../../../../../core/reactiveUtils.js";import{property as o}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as h}from"../../../../../core/accessorSupport/decorators/subclass.js";import{n as c,s as n,d as p}from"../../../../../chunks/vec3.js";import{c as d}from"../../../../../chunks/vec3f64.js";import{ViewingMode as m}from"../../../../ViewingMode.js";import{ShaderOutput as l}from"../../core/shaderLibrary/ShaderOutput.js";import{ReadShadowMapDrawParameters as u}from"../../core/shaderLibrary/shading/ReadShadowMap.glsl.js";import{SyncRenderPlugin as _}from"../RenderPlugin.js";import{defaultShadowOpacity as w,defaultShadowDifference as g,defaultShadowColor as f}from"./HighlightDefaults.js";import{ShadowHighlightPassParameters as y,ShadowHighlightTechnique as O}from"./ShadowHighlightTechnique.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";const b=.001953125,P=4e4,j=5e4;let v=class extends _{constructor(t){super(t),this.renderSlots=[x.SHADOW_HIGHLIGHT],this._maxOpacity=1,this._passParameters=new y,this._drawParameters=new u,this._shadowDifference=.2,this._context=null}produces(t){return t===x.SHADOW_HIGHLIGHT&&this._isVisible}consumes(t){return t===l.Highlight}initializeRenderContext(t){this._context=t,this.addHandles([r((()=>this.view.highlightOptions.shadowOpacity),(t=>{this._passParameters.shadowOpacity=t??w,this._updateOccludedShadowOpacity(),this._updateMaxOpacity()}),a),r((()=>this.view.highlightOptions.shadowDifference),(t=>{this._shadowDifference=t??g,this._updateOccludedShadowOpacity(),this._updateMaxOpacity()}),a),r((()=>this.view.highlightOptions.shadowColor),(t=>{this._passParameters.shadowColor=e(t??f),this._updateMaxOpacity()}),a)])}_updateOccludedShadowOpacity(){this._passParameters.occludedShadowOpacity=this._passParameters.shadowOpacity*(1-this._shadowDifference)}_updateMaxOpacity(){const t=Math.max(this._passParameters.shadowOpacity,this._passParameters.occludedShadowOpacity);this._maxOpacity=t*this._passParameters.shadowColor[3]}uninitializeRenderContext(){this._context=null}enable(){this._context&&null==this._technique&&(this._technique=this._context.techniqueRepository.acquire(O))}render(t,e,s,i){if(!(this._context&&s&&s.highlightTexture&&this._isVisible))return;if(!this._technique?.compiled)return void this._context.requestRender();const r=t.bindParameters;if(!r.shadowMap.enabled||!r.linearDepth)return;const a=t.rctx,o=this._technique;this._passParameters.highlight=s.highlightTexture,this._drawParameters.origin=r.camera.center,a.bindFramebuffer(i),a.bindTechnique(o,this._passParameters,r).bindDraw(this._drawParameters,r,this._passParameters),a.screen.draw()}updateParameters(t,e){this._passParameters.opacityElevation=1-s(P,j,t.relativeElevation);const r=this.viewingMode===m.Global?c(S,t.center):n(S,0,0,1),a=p(r,e);this._passParameters.dayNightTerminator=s(0,1,i(30*a,0,1)),this._isVisible&&this.enable()}get _isVisible(){const{opacityElevation:t,dayNightTerminator:e}=this._passParameters;return this._maxOpacity*t*e>=b}};t([o()],v.prototype,"_context",void 0),t([o()],v.prototype,"view",void 0),t([o()],v.prototype,"viewingMode",void 0),v=t([h("esri.views.3d.webgl-engine.lib.ShadowHighlight")],v);const S=d();export{v as ShadowHighlight};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t,abortMaybe as r}from"../../../../../core/maybe.js";import{isAbortError as s,throwIfAborted as i,isAborted as o}from"../../../../../core/promiseUtils.js";import{watch as a,syncAndInitial as n}from"../../../../../core/reactiveUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as u}from"../../../../../support/requestImageUtils.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as d}from"../RenderPlugin.js";import{SMAABlendWeightsTechnique as _}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as m}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as p}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as b}from"./SMAAPassParameters.js";import{RenderFeature as T}from"../../lib/RenderFeature.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";import{PixelFormat as f,TextureSamplingMode as q,ClearBufferBit as g,TextureWrapMode as C}from"../../../../webgl/enums.js";import{Texture as j}from"../../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../../webgl/TextureDescriptor.js";let
|
|
5
|
+
import{_ as e}from"../../../../../chunks/tslib.es6.js";import{disposeMaybe as t,abortMaybe as r}from"../../../../../core/maybe.js";import{isAbortError as s,throwIfAborted as i,isAborted as o}from"../../../../../core/promiseUtils.js";import{watch as a,syncAndInitial as n}from"../../../../../core/reactiveUtils.js";import{property as h}from"../../../../../core/accessorSupport/decorators/property.js";import"../../../../../core/accessorSupport/ensureType.js";import"../../../../../core/arrayUtils.js";import"../../../../../core/has.js";import{subclass as l}from"../../../../../core/accessorSupport/decorators/subclass.js";import{requestImage as u}from"../../../../../support/requestImageUtils.js";import{ColorFormat as c}from"../../core/FBOCache.js";import{SyncRenderPlugin as d}from"../RenderPlugin.js";import{SMAABlendWeightsTechnique as _}from"./SMAABlendWeightsTechnique.js";import{SMAABlurTechnique as m}from"./SMAABlurTechnique.js";import{SMAAEdgeDetectTechnique as p}from"./SMAAEdgeDetectTechnique.js";import{SMAAPassParameters as b}from"./SMAAPassParameters.js";import{RenderFeature as T}from"../../lib/RenderFeature.js";import{RenderSlot as x}from"../../lib/RenderSlot.js";import{PixelFormat as f,TextureSamplingMode as q,ClearBufferBit as g,TextureWrapMode as C}from"../../../../webgl/enums.js";import{Texture as j}from"../../../../webgl/Texture.js";import{TextureDescriptor as A}from"../../../../webgl/TextureDescriptor.js";let E=class extends d{constructor(e){super(e),this.renderSlots=[x.ANTIALIASING],this._context=null,this._areaTexture=null,this._searchTexture=null,this._isEnabled=!1,this._smaaParameters=new b}produces(){return this._isEnabled&&null!=this._context}get updating(){return null!=this._abortController}initializeRenderContext(e){this._context=e,this.addHandles([a((()=>this.view.qualitySettings.antialiasingEnabled),(e=>e||this._context?.isFeatureEnabled(T.Antialiasing)?this.enable():this.disable()),n)])}renderFeatureChanged(){this.view.qualitySettings.antialiasingEnabled||this._context?.isFeatureEnabled(T.Antialiasing)?this.enable():this.disable()}uninitializeRenderContext(){this.disable(),this._context=null}enable(){if(this._isEnabled||!this._context||this._abortController)return;if(null==this._edgeTechnique&&(this._edgeTechnique=this._context.techniqueRepository.acquire(p)),null==this._blendTechnique&&(this._blendTechnique=this._context.techniqueRepository.acquire(_)),null==this._blurTechnique&&(this._blurTechnique=this._context.techniqueRepository.acquire(m)),this._areaTexture&&this._searchTexture)return void(this._isEnabled=!0);this._abortController=new AbortController;const e=this._abortController.signal;import("./SMAAData.js").then((t=>this._loadTextures(this._context,t,e))).then((()=>{this._context?.requestRender(),this._abortController=null})).catch((e=>{s(e)||this._disposeTextures()}))}_loadTextures(e,t,r){return i(r),e?Promise.all([u(t.areaTexture).then((t=>R(e.fbos.rctx,q.LINEAR,f.RGB,t))),u(t.searchTexure).then((t=>R(e.fbos.rctx,q.NEAREST,f.LUMINANCE,t)))]).then((([e,t])=>{o(r)?(e.dispose(),t.dispose(),i(r)):(this._areaTexture=e,this._searchTexture=t,this._isEnabled=!0)})):Promise.reject()}_disposeTextures(){this._areaTexture=t(this._areaTexture),this._searchTexture=t(this._searchTexture)}disable(){this._abortController=r(this._abortController),this._isEnabled=!1}destroy(){this.disable(),this._disposeTextures()}render(e,t,r,s){if(!(this._isEnabled&&this._context&&r&&r.compositeTexture))return;if(!(this._edgeTechnique?.compiled&&this._blendTechnique?.compiled&&this._blurTechnique?.compiled))return void this._context.requestRender();const i=r.compositeTexture,o=i.descriptor.width,a=i.descriptor.height,n=this._context.fbos,h=e.rctx;h.setViewport(0,0,o,a);const l=n.acquire(c.RG,o,a);h.bindFramebuffer(l.fbo),h.setClearColor(0,0,0,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.color=i,h.bindTechnique(this._edgeTechnique,this._smaaParameters),h.screen.draw();const u=n.acquire(c.RGBA,o,a);h.bindFramebuffer(u.fbo),h.setClearColor(0,0,1,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=l.colorTexture,this._smaaParameters.areaTexture=this._areaTexture,this._smaaParameters.searchTexture=this._searchTexture,h.bindTechnique(this._blendTechnique,this._smaaParameters),h.screen.draw(),h.bindFramebuffer(s),l.release(),h.setClearColor(0,1,0,1),h.clear(g.COLOR_BUFFER_BIT),this._smaaParameters.inputTexture=u.colorTexture,h.bindTechnique(this._blurTechnique,this._smaaParameters),h.screen.draw(),u.release()}};function R(e,t,r,s){const i=new A;return i.pixelFormat=r,i.wrapMode=C.CLAMP_TO_EDGE,i.width=s.width,i.height=s.height,i.samplingMode=t,new j(e,i,s)}e([h()],E.prototype,"view",void 0),e([h()],E.prototype,"_context",void 0),e([h()],E.prototype,"_abortController",void 0),e([h({readOnly:!0})],E.prototype,"updating",null),E=e([l("esri.views.3d.webgl-engine.lib.SMAA")],E);export{E as SMAA};
|