@arcgis/core 4.23.0-next.20220128 → 4.23.0-next.20220202
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/Graphic.js +1 -1
- package/TimeExtent.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/01a10fe5ad6941b0ee8c.js +1 -0
- package/assets/esri/core/workers/chunks/{7a5f5acfbd4ca1a5c1f3.js → 06116433eb6e669f146b.js} +1 -1
- package/assets/esri/core/workers/chunks/09a05d778b6fac710828.js +1 -0
- package/assets/esri/core/workers/chunks/{83d00afae4406ec78bc9.js → 0c6be307709523eb8a05.js} +1 -1
- package/assets/esri/core/workers/chunks/0e215fa28a0448169132.js +1 -0
- package/assets/esri/core/workers/chunks/{391e96192d1ec4e55ce2.js → 101b4f02f0572afb666f.js} +1 -1
- package/assets/esri/core/workers/chunks/11750e96065b4d7b926b.js +1 -0
- package/assets/esri/core/workers/chunks/{929c9b7cdab7c4ca3d87.js → 17c51f5a13f471e6656a.js} +1 -1
- package/assets/esri/core/workers/chunks/{ed0bcc66fb1e0ee75a4b.js → 1f34957ef42e5b5977d0.js} +1 -1
- package/assets/esri/core/workers/chunks/2f4e425be3a3bdfd8d29.js +1 -0
- package/assets/esri/core/workers/chunks/34bed896b68993cabaa1.js +1 -0
- package/assets/esri/core/workers/chunks/3e1679b01429fd73cffe.js +1 -0
- package/assets/esri/core/workers/chunks/{99619fcb772807c74f3b.js → 444829a840b8ded16fd7.js} +1 -1
- package/assets/esri/core/workers/chunks/467b5faa1c90d9821609.js +1 -0
- package/assets/esri/core/workers/chunks/49353182a16218a84251.js +1 -0
- package/assets/esri/core/workers/chunks/4bfc2eeb0738c393d8ec.js +1 -0
- package/assets/esri/core/workers/chunks/4de996ebc432f5e149bc.js +1 -0
- package/assets/esri/core/workers/chunks/{422537fc3df707bb62c9.js → 5038935db9b1ebe61d02.js} +1 -1
- package/assets/esri/core/workers/chunks/50976921acf7bd636123.js +1 -0
- package/assets/esri/core/workers/chunks/50ef2622fd0d9a241979.js +1 -0
- package/assets/esri/core/workers/chunks/{5790d171072b3c7d108f.js → 53aa2ab4e569c994a32d.js} +1 -1
- package/assets/esri/core/workers/chunks/{7903a3e2e0faff0f86c0.js → 56657f890e0f79f5d2ad.js} +1 -1
- package/assets/esri/core/workers/chunks/{db3c729ce0c0b2690dc9.js → 574e33f28c106d607fe3.js} +1 -1
- package/assets/esri/core/workers/chunks/{952980635afc7ec81804.js → 5b02ba8ed152dba53155.js} +1 -1
- package/assets/esri/core/workers/chunks/60c06d1bb3f8a26cb5ac.js +1 -0
- package/assets/esri/core/workers/chunks/{c2253a9f29c1aabb2b75.js → 66c47983e93071de28b1.js} +1 -1
- package/assets/esri/core/workers/chunks/6be326edd9829781d926.js +1 -0
- package/assets/esri/core/workers/chunks/70d6bb3c7112cb702389.js +1 -0
- package/assets/esri/core/workers/chunks/{5bcb3240b3c005e5fe72.js → 7215af7810d15e89aa5a.js} +1 -1
- package/assets/esri/core/workers/chunks/7509c1693ffedc0fa018.js +1 -0
- package/assets/esri/core/workers/chunks/76c1d663f6d3f935c87f.js +1 -0
- package/assets/esri/core/workers/chunks/7ccbb923f113b3e21545.js +1 -0
- package/assets/esri/core/workers/chunks/810a763373d7f78ae398.js +1 -0
- package/assets/esri/core/workers/chunks/82194fec53054c37061f.js +1 -0
- package/assets/esri/core/workers/chunks/82c59a71b7f087148089.js +1 -0
- package/assets/esri/core/workers/chunks/84eee02122b56a22d49e.js +1 -0
- package/assets/esri/core/workers/chunks/{dd13772a5e2eccc6a2bc.js → 8598f762f15ca68d52b7.js} +1 -1
- package/assets/esri/core/workers/chunks/{3c673495e5f507c4a9e5.js → 88458dcaff8edc50620c.js} +1 -1
- package/assets/esri/core/workers/chunks/{5ec98f4ddac707d0fbd1.js → 88815d533808aabb1fa9.js} +1 -1
- package/assets/esri/core/workers/chunks/{0463ba46df855a92b9c0.js → 8941f09329d9d39fb2fe.js} +1 -1
- package/assets/esri/core/workers/chunks/{655b55ac0cd533d7e9d7.js → 8ad5dc818dc73f4b9a76.js} +1 -1
- package/assets/esri/core/workers/chunks/8e96cddb069b643d864a.js +1 -0
- package/assets/esri/core/workers/chunks/{f2124f4d0f2b8a91f0ea.js → 90c5edcd8a609224ce55.js} +1 -1
- package/assets/esri/core/workers/chunks/9230b20eba4304d421b4.js +1 -0
- package/assets/esri/core/workers/chunks/{bac9fc90e6756e211160.js → 94d9951509c0db09547a.js} +1 -1
- package/assets/esri/core/workers/chunks/996d6ae7f2e2273f9bce.js +1 -0
- package/assets/esri/core/workers/chunks/{37c03cfc19086ce631c6.js → 9bd603ec98d24cd918e9.js} +1 -1
- package/assets/esri/core/workers/chunks/{c1135cb02ec46c491459.js → 9ce961bc390202c87941.js} +1 -1
- package/assets/esri/core/workers/chunks/9d4a35d4a85db80c4071.js +1 -0
- package/assets/esri/core/workers/chunks/9f0ad28e66862ba971a3.js +1 -0
- package/assets/esri/core/workers/chunks/{b3f5e91116112b0b612a.js → 9fd47b8fe25657ac0237.js} +1 -1
- package/assets/esri/core/workers/chunks/{b9e9cb354822c6d995a4.js → a276e60209f3d877a8d0.js} +1 -1
- package/assets/esri/core/workers/chunks/{aeaa1667c2d9f1b3366b.js → a85ed251d3d3668e474f.js} +1 -1
- package/assets/esri/core/workers/chunks/{44f0c3663b293afbd172.js → acf10f747215e9ff54dc.js} +1 -1
- package/assets/esri/core/workers/chunks/{69fd99b7c76e9992ccf3.js → b32bf9808cb4be3a6bd0.js} +1 -1
- package/assets/esri/core/workers/chunks/b3dc80ddbfa81026e937.js +1 -0
- package/assets/esri/core/workers/chunks/b548e6b3add4154ac4e6.js +1 -0
- package/assets/esri/core/workers/chunks/b6c55bdd8c957b062bc1.js +1 -0
- package/assets/esri/core/workers/chunks/{9d77467aa71d345fc1b6.js → bcc01bbffaa3bb5f60a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{1f8c6a179e39fd4c5e6f.js → bd152e8b43cc4a6844dd.js} +1 -1
- package/assets/esri/core/workers/chunks/{0d02c6ad1f4688bfa374.js → bf7c44644fe7b0aa60cf.js} +1 -1
- package/assets/esri/core/workers/chunks/c0dc5882362479794224.js +1 -0
- package/assets/esri/core/workers/chunks/c8b574a76807f4ea7a70.js +1 -0
- package/assets/esri/core/workers/chunks/d09a0b2dc3a6fc10fa41.js +1 -0
- package/assets/esri/core/workers/chunks/{ec10151a2a95e95a0bb5.js → d304fe0ac836afd46e3d.js} +1 -1
- package/assets/esri/core/workers/chunks/{37a7bd30352b1309b8f8.js → d3f05b8e4bd53eb1eb9d.js} +1 -1
- package/assets/esri/core/workers/chunks/{be588873c16770ceb9ef.js → d46b511bbb83e68f1ece.js} +1 -1
- package/assets/esri/core/workers/chunks/{17de7a324dfa7f57ad5d.js → d780e946149b1c3d1246.js} +1 -1
- package/assets/esri/core/workers/chunks/d80bcf5ed1f54e0c4f5a.js +1 -0
- package/assets/esri/core/workers/chunks/{8cbb04a9065aa3756638.js → dc04a8ba6c770bdc2bd4.js} +1 -1
- package/assets/esri/core/workers/chunks/{89820b200ee44e678af5.js → dd891a98105904f8a06b.js} +1 -1
- package/assets/esri/core/workers/chunks/e5ab037c2a90411c453b.js +1 -0
- package/assets/esri/core/workers/chunks/ef2df21e1af3aa7ced29.js +1 -0
- package/assets/esri/core/workers/chunks/f5a7281ae24e837efc61.js +1 -0
- package/assets/esri/core/workers/chunks/{ff6abdc72076f3994659.js → f7150547d7e3259a0f29.js} +1 -1
- package/assets/esri/core/workers/chunks/{2c607d30ff8ca1b61286.js → fe0c3b7c9b428d9c3f25.js} +1 -1
- package/assets/esri/images/portal/mediaservice16.png +0 -0
- package/assets/esri/libs/vxl/vxlLayer.wasm +0 -0
- package/assets/esri/widgets/Directions/t9n/Directions.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ar.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_bg.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_bs.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ca.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_cs.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_da.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_de.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_el.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_en.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_es.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_et.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_fi.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_fr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_he.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_hr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_hu.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_id.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_it.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ja.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ko.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_lt.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_lv.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_nb.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_nl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pt-BR.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_pt-PT.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ro.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_ru.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sk.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sl.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_sv.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_th.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_tr.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_uk.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_vi.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-CN.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-HK.json +1 -1
- package/assets/esri/widgets/Directions/t9n/Directions_zh-TW.json +1 -1
- package/chunks/Heatmap.glsl.js +10 -0
- package/chunks/HeatmapDensity.glsl.js +21 -0
- package/core/maybe.js +1 -1
- package/core/promiseUtils.js +1 -1
- package/interfaces.d.ts +455 -45
- package/layers/RouteLayer.d.ts +4 -0
- package/layers/RouteLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/optimizedFeatureQueryEngineAdapter.js +1 -1
- package/layers/graphics/featureConversionUtils.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/support/rasterFunctions/vectorFieldUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItem.js +1 -1
- package/renderers/support/rendererConversion.js +1 -1
- package/rest/support/DirectionLine.d.ts +4 -0
- package/rest/support/DirectionPoint.d.ts +4 -0
- package/rest/support/FeatureSet.js +1 -1
- package/rest/support/RouteInfo.d.ts +4 -0
- package/rest/support/RouteInfo.js +1 -1
- package/rest/support/RouteSolveResult.d.ts +4 -0
- package/support/featureFlags.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/TextSymbol3DLayer.js +1 -1
- package/symbols/support/Symbol3DHalo.js +1 -1
- package/symbols/support/Symbol3DTextBackground.js +5 -0
- package/views/2d/engine/RasterVFContainer.js +5 -0
- package/views/2d/engine/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/flow/AnimatedFlowView2D.js +1 -1
- package/views/2d/engine/webgl/AttributeStoreView.js +1 -1
- package/views/2d/engine/webgl/brushes/raster/BrushVectorField.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/Buffer.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/WGLBaseTextTemplate.js +1 -1
- package/views/2d/layers/FeatureLayerView2D.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/RouteLayerView2D.js +1 -1
- package/views/2d/layers/features/processors/HeatmapProcessor.js +1 -1
- package/views/2d/layers/features/processors/SymbolProcessor.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/ClusterStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderJSON.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryVFStrategy.js +5 -0
- package/views/2d/layers/imagery/ImageryView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldView2D.js +5 -0
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/CloudsComposition.js +1 -1
- package/views/3d/environment/CloudsGenerator.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/NoiseTextureAtlas.js +1 -1
- package/views/3d/environment/PanoramicAtmosphere.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/environment/SimpleAtmosphere.js +1 -1
- package/views/3d/environment/Stars.js +1 -1
- package/views/3d/interactive/analysisTools/lineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWebStyleSymbol.js +1 -1
- package/views/3d/layers/graphics/labelPlacement.js +1 -1
- package/views/3d/layers/i3s/I3SCrossfadeHelper.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SMaterialUtil.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.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/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
- package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +5 -0
- package/views/3d/webgl-engine/lib/HighlightHelper.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowHighlightHelper.js +1 -1
- package/views/3d/webgl-engine/lib/SmaaRenderPass.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/HeatmapDensityMaterial.js +5 -0
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/HeatmapDensity.glsl.js +5 -0
- package/views/3d/webgl-engine/shaders/HeatmapDensityTechnique.js +5 -0
- package/views/3d/webgl-engine/shaders/HeatmapTechnique.js +5 -0
- package/views/draw/support/Box.js +1 -1
- package/views/draw/support/GraphicMover.js +1 -1
- package/views/draw/support/HighlightHelper.js +5 -0
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/layerUtils.js +1 -1
- package/webdoc/support/{Thumbnail.js → SlideThumbnail.js} +1 -1
- package/webmap/Bookmark.js +1 -1
- package/webmap/Version.js +1 -1
- package/webscene/Slide.js +1 -1
- package/webscene/Version.js +1 -1
- package/webscene/support/SlideVisibleLayer.js +1 -1
- package/widgets/Bookmarks/BookmarksViewModel.js +1 -1
- package/widgets/Bookmarks.js +1 -1
- package/widgets/Directions/DirectionsViewModel.js +1 -1
- package/widgets/Directions/support/directionsUtils.js +1 -1
- package/widgets/Directions/support/resources.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/TimeSlider.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/support/vnodeCache.js +5 -0
- package/widgets/support/widgetUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0453fad5cb819797b4f6.js +0 -1
- package/assets/esri/core/workers/chunks/0cd0a6eef51fc5b9ea61.js +0 -1
- package/assets/esri/core/workers/chunks/0d684f16f37d5dc385dd.js +0 -1
- package/assets/esri/core/workers/chunks/16b6d0f8378582c051c3.js +0 -1
- package/assets/esri/core/workers/chunks/1877ab1b6a115dbba1c5.js +0 -1
- package/assets/esri/core/workers/chunks/1b2a961f776a0b57e57a.js +0 -1
- package/assets/esri/core/workers/chunks/1b3fd66577b19aa5f2b6.js +0 -1
- package/assets/esri/core/workers/chunks/1c733b7db092a2a88ef3.js +0 -1
- package/assets/esri/core/workers/chunks/27474b007988855bea9d.js +0 -1
- package/assets/esri/core/workers/chunks/357033117dfe61eb81ea.js +0 -1
- package/assets/esri/core/workers/chunks/483d5d8593d96d0f0b15.js +0 -1
- package/assets/esri/core/workers/chunks/4ba6de8aa7e2960bad49.js +0 -1
- package/assets/esri/core/workers/chunks/4be35af7d6babbfe9d84.js +0 -1
- package/assets/esri/core/workers/chunks/5457962a70bd3c557a75.js +0 -1
- package/assets/esri/core/workers/chunks/57856b4a9b8784a69844.js +0 -1
- package/assets/esri/core/workers/chunks/57b349d1dbc0bed75b79.js +0 -1
- package/assets/esri/core/workers/chunks/5d11b97b667921d67ae7.js +0 -1
- package/assets/esri/core/workers/chunks/5dbe555a5a662ff3d9ce.js +0 -1
- package/assets/esri/core/workers/chunks/64b7e8d812ea8fcf269e.js +0 -1
- package/assets/esri/core/workers/chunks/75d812955a473d0e8960.js +0 -1
- package/assets/esri/core/workers/chunks/96f148a556a2418038de.js +0 -1
- package/assets/esri/core/workers/chunks/9876a1bae350795fab36.js +0 -1
- package/assets/esri/core/workers/chunks/a8692bffb76444c34760.js +0 -1
- package/assets/esri/core/workers/chunks/ba762bcfd74af0bb8218.js +0 -1
- package/assets/esri/core/workers/chunks/c093dff4592832ac0973.js +0 -1
- package/assets/esri/core/workers/chunks/c984b3040e120e502b11.js +0 -1
- package/assets/esri/core/workers/chunks/cdbc005eebec1503b99d.js +0 -1
- package/assets/esri/core/workers/chunks/d1fe53b597351dc58305.js +0 -1
- package/assets/esri/core/workers/chunks/e218bde41ffbcc5194f5.js +0 -1
- package/assets/esri/core/workers/chunks/e287f49184d076af17e2.js +0 -1
- package/assets/esri/core/workers/chunks/e93dfdede0532a89ffa5.js +0 -1
- package/assets/esri/core/workers/chunks/e9e5196b44b6923be1a3.js +0 -1
- package/assets/esri/core/workers/chunks/ea595b0df5050eda2a13.js +0 -1
- package/assets/esri/core/workers/chunks/eb82ff10cef2bde6e57f.js +0 -1
- package/assets/esri/core/workers/chunks/ee6e0db58dc64410e687.js +0 -1
- package/assets/esri/core/workers/chunks/f0a9f161805fc7a30fc5.js +0 -1
- package/assets/esri/core/workers/chunks/fc7e31d87555beb63291.js +0 -1
- package/assets/esri/core/workers/chunks/fff6b0338f06dad0c45d.js +0 -1
- package/views/2d/layers/imagery/ImageryGraphicsView2D.js +0 -5
- package/widgets/Directions/support/CostSummary.js +0 -5
- package/widgets/Directions/support/RouteSection.js +0 -5
- package/widgets/Directions/support/RouteSections.js +0 -5
- package/widgets/Directions/support/maneuverUtils.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{removeMaybe as e,isSome as s}from"../../../../core/maybe.js";import{addFrameTask as
|
|
5
|
+
import{removeMaybe as e,isSome as s,isNone as o}from"../../../../core/maybe.js";import{addFrameTask as d}from"../../../../core/scheduling.js";import{FadeDirection as i}from"../support/I3SLayerView.js";class t{constructor(){this.lodCrossfadeSignedDuration=0}}class a{constructor(e){this.view=e,this._preRenderFrameTaskHandle=null,this._currentFrameStartTime=null,this._numFadingNodes=0}get updating(){return this._numFadingNodes>0}stopNodeFading(s){null!=s.lodCrossfadeProgress&&(this._numFadingNodes--,s.lodCrossfadeProgress=null,0===this._numFadingNodes&&(null!=this._preRenderFrameTaskHandle&&(this._preRenderFrameTaskHandle=e(this._preRenderFrameTaskHandle)),this.view.notifyLODUpdate(),this.view.notifyUpdate()))}_startNodeFading(e,s,o){0===this._numFadingNodes&&(this._preRenderFrameTaskHandle=d({preRender:e=>this._updateAllNodeFading(e)}),this.view.notifyLODUpdate()),null==e.lodCrossfadeProgress&&(this._numFadingNodes++,this.view.notifyUpdate()),e.lodCrossfadeSignedDuration=o,e.lodCrossfadeProgress=s}_updateAllNodeFading(e){const o=this.view.nodeCrossfadingEnabled;this.view.foreachCrossfadeNode(((d,i)=>{if(s(i)&&s(i.lodCrossfadeProgress)){const s=i.lodCrossfadeSignedDuration,t=s>0?this.view.fullOpacity:0,a=e.deltaTime/s,r=i.lodCrossfadeProgress+Math.abs(a),n=!o||r>=1||0===s,l=t-(n?0:s>0?1:-1)*(1-r);n?(this.stopNodeFading(i),s<0&&this.view.markNodeToRemove(d)):i.lodCrossfadeProgress=r,this.view.setNodeOpacityByIndex(d,l)}})),this.view.removeMarkedNodes()}stopAllNodeFading(){this.view.foreachCrossfadeNode(((e,o)=>{if(s(o)&&s(o.lodCrossfadeProgress)){this.stopNodeFading(o);const s=o.lodCrossfadeSignedDuration;s<0&&this.view.markNodeToRemove(e);const d=s>0?this.view.fullOpacity:0;this.view.setNodeOpacityByIndex(e,d)}})),this.view.removeMarkedNodes()}fadeNode(e,s,o,d){null==this._currentFrameStartTime&&(this._currentFrameStartTime=Date.now());const t=this.view,a=t.nodeCrossfadingEnabled,n=o===i.FadeIn?t.fullOpacity:0,l=a?d?o===i.FadeIn?t.lodCrossfadeinDuration:t.lodCrossfadeoutDuration:t.lodCrossfadeUncoveredDuration:0,h=this.view.getNodeOpacityByIndex(e);if(a&&h!==n&&l>0){const e=1-Math.abs(n-h);this._startNodeFading(s,e,r(o)*l)}else this.stopNodeFading(s),this.view.setNodeOpacityByIndex(e,n),o===i.FadeOut&&this.view.removeNode(e)}isNodeFullyFadedIn(e){const s=this.view.getNodeCrossfadeMetaData(e);return o(s)||null==s.lodCrossfadeProgress&&this.view.getNodeOpacityByIndex(e)===this.view.fullOpacity}}function r(e){return e===i.FadeIn?1:-1}export{a as I3SCrossfadeHelper,t as NodeCrossfadeMetaData};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e,isNone as t,unwrap as i}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{l as n}from"../../../../chunks/vec3.js";import{d as o}from"../../../../chunks/vec4f64.js";import{LodMetric as a,NodeBase as d,Node as l,NodeFilterImpact as h,NodeIMModificationImpact as u,NodeTraversalState as c}from"./I3SNode.js";import{addWraparound as g}from"./I3SUtil.js";import{clone as _}from"../../support/orientedBoundingBox.js";class m{constructor(e,t,i,s,r){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=r,this.useAsHole=0,this.filterImpact=h.NotChecked}}class f{constructor(e,t,i,r,n,o,d,l,h,u,c,g,_,m){this.streamDataController=i,this.viewportQueries=r,this.logger=n,this.holeFilling=o,this._isLoaded=d,this._isReloading=l,this._isSelected=h,this._enable=u,this._needsUpdate=c,this._canRequest=g,this._computeVisibilityObb=_,this._computeNodeFiltering=m,this._dirty=!0,this._nodePages=[],this.nodeCount=0,this.nodesPerPage=0,this.rootIndex=0,this.lodMetric=a.None,this._lodConversion=e=>e,this.urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=P(0),this._visibilityCacheVersion=P(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new s({deallocator:null}),this._prefetch=new s({deallocator:null}),this._updates=new b(this._missing),this._imModificationUncategorized=new s({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this.layerHasModifications=!1,this._layerHasFilter=!1,this.logLayer=e,e.serviceUpdateTimeStamp&&e.serviceUpdateTimeStamp.lastUpdate&&(this.lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this.viewportQueries?this.viewportQueries.maxLodLevel:1,this._init(t)}_init(e){if("page"===e.type){switch(this.urlPrefix=e.urlPrefix,this.nodesPerPage=e.pageSize,this.rootIndex=e.rootIndex,e.lodMetric){case"maxScreenThreshold":this.lodMetric=a.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this.lodMetric=a.MaxScreenThreshold,this._lodConversion=V}this._addPage(C(this.rootIndex,this.nodesPerPage),e.rootPage)}else if("node"===e.type){this.urlPrefix=e.urlPrefix,this._nodePages.push({nodes:[],children:[],parents:[]}),this._makeRefNode(new d(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}_loadPage(e){this._loading.add(e);const t=this.urlPrefix+e;this.streamDataController.request(t,"json").then((t=>{this._loading.delete(e),this._addPage(e,t)})).catch((t=>{this._loading.delete(e),r(t)||(this._failedPages.add(e),this.logger.error("#loadPage()",this.logLayer,`Error when loading page ${e}`,t))}))}_addPage(e,t){for(let n=this._nodePages.length;n<e;n++)this._nodePages[n]=null;const i=[],s=[],r=t.nodes.map(((t,r)=>{const a=i.length,d=t.children?t.children.length:0;s.push(-1);for(let e=0;e<d;e++)i.push(t.children[e]);const h=`${t.index}`,u=_(t.obb),c=o([u.center[0],u.center[1],u.center[2],n(u.halfSize)]),g=t.mesh&&t.mesh.attribute,f=t.mesh&&t.mesh.geometry,v=t.mesh&&t.mesh.material,b={hasSharedResource:!1,hasFeatureData:!!f,attributes:g&&null!=g.resource?`${g.resource}`:null,geometry:f&&null!=f.resource?`${f.resource}`:null,texture:v&&null!=v.resource?`${v.resource}`:null,geometryDefinition:f?f.definition:-1,materialDefinition:v?v.definition:-1},p=new l(h,e*this.nodesPerPage+r,c,d,0,b,this.lastUpdate,this.lodMetric,this._lodConversion(t.lodThreshold),f?f.featureCount:null);return p.serviceObb=u,p.visibilityObb=this._computeVisibilityObb(p),p.vertexCount=f?f.vertexCount:0,new m(a,d,y(this._visibilityCacheVersion),null,p)}));this._nodePages[e]={nodes:r,children:i,parents:s},this.nodeCount+=r.length,this._updateParentsAndLevel()}_updateParentsAndLevel(){const t=new Array,i=(i,s,r)=>{const n=this._getPage(i);if(e(n)){const o=w(i,this.nodesPerPage);n.parents[o]=s;const a=n.nodes[o].node;e(a)&&(a.level=r,t.push(i))}};for(i(this.rootIndex,-1,0);t.length;){const s=t.pop(),r=this.getNode(s);if(e(r))for(let e=0;e<r.childCount;e++){i(this.getChildIndex(r,e),s,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}}_getPage(e){return this._nodePages[C(e,this.nodesPerPage)]}_getNodeInternal(e){const i=this._getPage(e);return t(i)?null:i.nodes[w(e,this.nodesPerPage)]}_addNode(t,s){null!=t.children&&this.populateChildren(s,t.children);const r=this.getParent(s),n=e(r)?r.level+1:0;this._maxLevel=Math.max(this._maxLevel,t.children?n+1:n);const{lodMetric:a,maxError:d}=S(t.lodSelection),h=i(this._getNodeInternal(s));return h.node=new l(t.id,s,o(t.mbs),h.childCount,n,t.resources,t.version,a,d,t.numFeatures),t.obb&&(h.node.serviceObb=_(t.obb)),h.node.visibilityObb=this._computeVisibilityObb(h.node),e(h.ref)&&(null==h.ref.mbs&&(h.ref.mbs=t.mbs),h.node.renderMbs=h.ref.renderMbs,h.node.serviceObbInRenderSR=h.ref.serviceObbInRenderSR,h.ref.visibilityObb=h.node.visibilityObb),h.node}_makeRefNode(t,i){const s=this._nodePages[0],r=s.nodes.length;return s.nodes.push(new m(0,0,y(this._visibilityCacheVersion),t,null)),this.nodeCount++,s.parents.push(i),t.renderMbs[3]=-1,e(t.serviceObbInRenderSR)&&(t.serviceObbInRenderSR.halfSize[0]=-1),r}populateChildren(e,t){const s=i(this._getNodeInternal(e)),r=i(this._getPage(e));s.childOffset=r.children.length,s.childCount=t.length;for(let i=0;i<t.length;i++){const s=this._makeRefNode(t[i],e);r.children.push(s)}}getNode(t){const i=this._getNodeInternal(t);return e(i)?i.node:null}getIndexById(t){let i;return this._forAllNodes(((s,r)=>{(e(s.node)&&s.node.id===t||e(s.ref)&&s.ref.id===t)&&(i=r)})),i}getNodeById(e){const t=this.getIndexById(e);return t>=0?this.getNode(t):null}getChildIndex(e,i){const s=this._getPage(e.index);if(t(s))return-1;const r=s.nodes[w(e.index,this.nodesPerPage)];return s.children[r.childOffset+i]}getParentIndex(t){const i=this._getPage(t);return e(i)?i.parents[w(t,this.nodesPerPage)]:-1}getParent(e){return(e=this.getParentIndex(e))>=0?this.getNode(e):null}isLeaf(t){const i=this._getNodeInternal(t);return e(i)&&0===i.childCount}get rootNode(){return this.getNode(this.rootIndex)}get size(){return this.nodeCount}invalidateVisibilityCache(){this._visibilityCacheVersion=P(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(t){const i=this._getNodeInternal(t);e(i)&&this.invalidateNodeVisibilityCacheInternal(i)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=y(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(t){const i=this._getNodeInternal(t);e(i)&&(p(i),this.invalidateNodeVisibilityCacheInternal(i))}invalidateGeometryVisibility(t){const i=this._getNodeInternal(t);e(i)&&e(i.node)&&(i.node.geometryObb=null,i.node.renderMbs[3]=-1,e(i.node.serviceObbInRenderSR)&&(i.node.serviceObbInRenderSR.halfSize[0]=-1))}invalidateVisibilityObbs(){t(this.rootNode)||this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}isNodeVisible(i){const s=this._getNodeInternal(i);if(t(s)||e(s.ref)&&!s.ref.mbs)return!0;if(!x(s.visibilityCache,this._visibilityCacheVersion)){const i=s.node,r=e(i)&&(t(s.ref)||e(i.visibilityObb))?i:e(s.ref)?s.ref:null;if(this._layerHasFilter&&this._computeNodeFiltering&&(e(i)||e(s.ref))&&s.filterImpact===h.NotChecked){const t=e(i)?i.mbs:e(s.ref)?s.ref.mbs:null;s.filterImpact=null!=t?this._computeNodeFiltering(t):h.Unmodified}const n=e(i)&&s.filterImpact===h.Culled,o=!(e(i)&&i.imModificationImpact===u.Culled)&&(!r||this.viewportQueries.isNodeVisible(r))&&!n;return s.visibilityCache=N(o,this._visibilityCacheVersion),o}return I(s.visibilityCache)}isGeometryVisible(t){if(!this.isNodeVisible(t))return!1;const i=this._getNodeInternal(t);return!(e(i)&&e(i.node)&&e(i.node.geometryObb)&&(!this.layerHasModifications||i.node.imModificationImpact!==u.NotChecked))||this.viewportQueries.isGeometryVisible(i.node)}_traverseCoverage(s,r,n,o,a){const d=this._getPage(s);if(t(d)||0===r.childCount)return;const l=r.childOffset+r.childCount,h=new Array;for(let t=r.childOffset;t<l;++t){const i=d.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&this.isGeometryVisible(i)&&h.push(s)}o/=h.length;for(const e of h){const t=i(e.node).index;this._isLoaded(t)||this._isReloading(t)?(a.delta=Math.max(a.delta,n),a.coverage+=o):this._traverseCoverage(t,e,n+1,o,a)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const i=this._getNodeInternal(e);if(t(i))return!1;if("always"===this.holeFilling)return!0;if(x(i.useAsHole,this._version))return I(i.useAsHole);const s={delta:0,coverage:0};this._traverseCoverage(e,i,0,1,s);const r=s.delta*s.coverage<=.5;return i.useAsHole=N(r,this._version),r}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=P(this._version)}imModificationsChanged(t){this.layerHasModifications=t,this._forAllNodes((({node:t})=>{e(t)&&(t.imModificationImpact=u.NotChecked,t.visibilityObb=this._computeVisibilityObb(t),t.hasModifications&&this.invalidateGeometryVisibility(t.index))})),this.invalidateVisibilityCache()}layerFilterChanged(t){this._layerHasFilter=t,this._forAllNodes((t=>{if(e(t)){t.filterImpact=h.NotChecked;const i=t.node;e(i)&&this.invalidateNodeVisibilityCache(i.index)}})),this.invalidateVisibilityCache()}update(s,r,n){if(!this._dirty)return;this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(s),v.clear();let o=!0;const a=new O,d=new O,l=this._imModificationUncategorized;l.clear();const h=new Set,c=(c,g,_)=>{if(t(g)){let e=this._entryPriority(c);e===1/0&&(e=this._entryPriority(_));const t=C(c,this.nodesPerPage);return v.set(t,Math.max(e,v.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const m=g.node;if(this._updateNodeFeatureEstimate(m,d),t(m)){const e=this._entryPriority(c);return this._loading.has(c)||this._failedNodes.has(c)||(this._missing.push(c),v.set(c,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=i(this._getPage(c));if(0===this._missing.length&&0===this.nodesPerPage)for(let t=0;t<g.childCount;t++){const i=f.children[g.childOffset+t],s=this._getNodeInternal(i);!e(s)||s.node||this._loading.has(i)||this._failedNodes.has(i)||(v.set(i,this._entryPriority(i)),this._prefetch.push(i))}if(m.failed||!m.resources.hasFeatureData)return;if(h.add(m.id),this._isLoaded(c)){if(a.known+=m.memory,++a.knownNodes,this._isSelected(m)?g.childCount>0&&(o=!1):(a.unremoved+=m.memory,o=!1),this._needsUpdate(m)){const e=this._entryPriority(c);v.set(c,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(c)}return}if(m.memory&&(a.known+=m.memory,++a.knownNodes),!this._isSelected(m))return void(this._isReloading(c)&&this._updates.remove.push(c));if(g.childCount>0&&(o=!1),m.memory?(a.missing+=m.memory,a.known+=m.memory,++a.knownNodes):++a.missingNodes,s.indexOf(m.index)>=0)return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(c)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==m.index)));if(!r.done&&this._enable(m))return void r.madeProgress();const b=this._entryPriority(c);v.set(c,b),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,b),this._updates.add.push(c),this.layerHasModifications&&n&&e(m)&&m.imModificationImpact===u.NotChecked&&l.push(c)};this.traverseVisible(c);const g=this._updates.add;g.length>0&&this.layerHasModifications&&(l.length>0&&n(l),g.filterInPlace((e=>{const i=this._getNodeInternal(e),s=t(i)||t(i.node)||i.node.imModificationImpact!==u.Culled;return s||this.invalidateNodeVisibilityCache(e),s}))),this._unloadedMemoryEstimate=a.missing-a.unremoved,a.knownNodes>3&&a.missingNodes>0&&(this._unloadedMemoryEstimate+=a.known/a.knownNodes*a.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(d),this._featureEstimate.leavesReached=o,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>v.get(e)-v.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=v.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>v.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>v.get(e)-v.get(t))),this._updates.update.sort(((e,t)=>v.get(e)-v.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,v.clear()}checkFeatureTarget(e,t){const i=this.viewportQueries.updateScreenSpaceErrorBias(t);let s=t,r=t,n=i,o=10;for(;o--;){const i=new O;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===o)break;n=s,s=.5*(s+r)}else r=s,s=.5*(s+n)}return this._version=P(this._version),this.viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(t,i){this._version=P(this._version),this.viewportQueries.updateScreenSpaceErrorBias(t),this.traverseVisible(((t,s)=>this._updateNodeFeatureEstimate(e(s)&&s.node,i)))}_updateNodeFeatureEstimate(i,s){if(!(t(i)||i.failed||t(i.numFeatures)))return this._isLoaded(i.index)?(s.known+=i.numFeatures,++s.knownNodes,void(this._isSelected(i)||(s.unremoved+=i.numFeatures))):void(this._isSelected(i)&&(e(i.numFeatures)?(s.missing+=i.numFeatures,s.known+=i.numFeatures,++s.knownNodes):++s.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>v.get(e)-v.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)0===this.nodesPerPage?this._loadNode(e.pop()):this._loadPage(e.pop());return!0}isLoading(){return this._indexMissing>0}getIndexLoading(){return this._loading.size}getIndexMissing(){return this._indexMissing}getUnloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}nodeTraversalState(e){if(t(e))return null;let i=this._nodeTraversalState.get(e.index);if(i&&x(i.version,this._version))return i;const s=this.viewportQueries.getLodLevel(e),r=this.viewportQueries.hasLOD(e);let n=!0;if(r){const t=this.getParentIndex(e.index);if(t>=0){const e=this._nodeTraversalState.get(t);n=e&&s>e.lodLevel}else n=s>0}else n=0===e.childCount;return i?(i.lodLevel=s,i.isChosen=n,i.version=N(!0,this._version),i):(i=new c(r,n,s,N(!0,this._version)),this._nodeTraversalState.set(e.index,i),i)}_loadNode(e){this._loading.add(e);const s=i(this._getNodeInternal(e)).ref;if(t(s))return void this._failedNodes.add(e);const n=s.id,o=this.urlPrefix+n,a=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};this.streamDataController.request(o,"json").then((t=>{a();const i=this._validateNode(n,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)}),(t=>{a(),r(t)||(this.logger.error("#loadNode()",this.logLayer,"Error loading node: "+o),this._failedNodes.add(e))}))}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this.logger.error("#validateNode()",this.logLayer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this.logger.error("#validateNode()",this.logLayer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this.logger.warn("#validateNode()",this.logLayer,`Invalid shared resource href on node "${e}"`),null==t.geometryData||Array.isArray(t.geometryData)&&1===t.geometryData.length&&"./geometries/0"===t.geometryData[0].href||this.logger.warn("#validateNode()",this.logLayer,`Invalid geometry data on node "${e}"`),null==t.attributeData||Array.isArray(t.attributeData)&&!t.attributeData.some(((e,t)=>e.href!==`./attributes/f_${t}/0`))||this.logger.warn("#validateNode()",this.logLayer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this.logger.warn("#validateNode()",this.logLayer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const i=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:null,r=t=>{if(null==t)return null;const i=t=>this.logger.error("#validateNode()",this.logLayer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this.logger.error("#validateNode()",this.logLayer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=new d(`${t.id}`,t.mbs);return r.serviceObb=s,r.visibilityObb=this._computeVisibilityObb(r),r},n=Array.isArray(t.children)?t.children.map(r).filter((e=>null!=e)):null;return{id:e,mbs:t.mbs,obb:i,children:n,resources:{hasFeatureData:t.featureData&&t.featureData.length>0,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:null,texture:t.textureData&&t.textureData.length>0?e:null,geometry:null!=t.geometryData?e:null},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:s}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((t=>{e(t.node)&&(t.node.failed=!1)}))}_entryPriority(i){const s=this._getNodeInternal(i),r=this.getParentIndex(i);if(t(s)||r<0&&null==s.node)return r<0?1/0:this._entryPriority(r);let n=0;if(s.node&&r>=0){const e=this._nodeTraversalState.get(r);null!=e&&(n=e.lodLevel)}let o=this.progressiveLoadPenalty;for(let e=i;e>=0;e=this.getParentIndex(e))if(this._isLoaded(e)){o=0;break}const a=e(s.ref)?this.viewportQueries.distToPOI(s.ref):e(s.node)?this.viewportQueries.distToPOI(s.node):0;return-a-n*(a+this.progressiveLoadPenalty)+o}traverseVisible(e){const i=this._getNodeInternal(this.rootIndex);t(i)?e(this.rootIndex,null,null):this._traverseVisible(this.rootIndex,-1,i,e)}_traverseVisible(t,s,r,n){if(r.node&&0===r.childCount)return void(this.isGeometryVisible(t)&&n(t,r,s));if(!this.isNodeVisible(t))return;if(n(t,r,s),null==r.node)return;const o=this.nodeTraversalState(r.node);if(o.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;const a=i(this._getPage(t));for(let i=0;i<r.childCount;i++){const s=a.children[r.childOffset+i],o=this._getNodeInternal(s);e(o)?this._traverseVisible(s,t,o,n):n(s,null,t)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(t,i){const s=t.index,r=this._getNodeInternal(s);e(r)&&this._traverseChildren(s,r,i)}_traverseChildren(i,s,r){const n=this._getPage(i);if(t(n))return;const o=s.childOffset+s.childCount;for(let t=s.childOffset;t<o;++t){const i=n.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&r(s.node)&&this._traverseChildren(i,s,r)}}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}getPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}updateElevationInfo(e){this._forAllNodes(p),this.viewportQueries.updateElevationInfo(e)}_forAllNodes(e){for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const s=t*this.nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const v=new Map;class b{constructor(e){this.missing=e,this.update=new s({deallocator:null}),this.add=new s({deallocator:null}),this.remove=new s({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function p(t){e(t.node)&&(t.node.renderMbs[3]=-1,e(t.node.serviceObbInRenderSR)&&(t.node.serviceObbInRenderSR.halfSize[0]=-1)),e(t.ref)&&(t.ref.renderMbs[3]=-1,e(t.ref.serviceObbInRenderSR)&&(t.ref.serviceObbInRenderSR.halfSize[0]=-1))}function y(e){return g(e,-2)}function P(e){return g(e,2)}function N(e,t){return t+(e?1:0)}function x(e,t){return(-2&e)===t}function I(e){return 1==(1&e)}function C(e,t){return 0===t?0:e/t|0}function w(e,t){return 0===t?e:e%t}const M=[["maxScreenThreshold",a.MaxScreenThreshold],["screenSpaceRelative",a.ScreenSpaceRelative],["removedFeatureDiameter",a.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",a.DistanceRangeFromDefaultCamera]];function S(e){if(e)for(let t=0;t<e.length;t++)for(const i of M)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:a.None,maxError:0}}class O{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function V(e){return Math.sqrt(e*(4/Math.PI))}export{f as I3SIndex,S as selectErrorMetric};
|
|
5
|
+
import{isSome as e,isNone as t,unwrap as i}from"../../../../core/maybe.js";import s from"../../../../core/PooledArray.js";import{isAbortError as r}from"../../../../core/promiseUtils.js";import{l as n}from"../../../../chunks/vec3.js";import{d as o}from"../../../../chunks/vec4f64.js";import{LodMetric as a,NodeBase as d,Node as l,NodeFilterImpact as h,NodeIMModificationImpact as u,NodeTraversalState as c}from"./I3SNode.js";import{addWraparound as g}from"./I3SUtil.js";import{clone as _}from"../../support/orientedBoundingBox.js";class m{constructor(e,t,i,s,r){this.childOffset=e,this.childCount=t,this.visibilityCache=i,this.ref=s,this.node=r,this.useAsHole=0,this.filterImpact=h.NotChecked}}class f{constructor(e,t,i,r,n,o,d,l,h,u,c,g,_,m){this.streamDataController=i,this.viewportQueries=r,this.logger=n,this.holeFilling=o,this._isLoaded=d,this._isReloading=l,this._isSelected=h,this._enable=u,this._needsUpdate=c,this._canRequest=g,this._computeVisibilityObb=_,this._computeNodeFiltering=m,this._dirty=!0,this._nodePages=[],this.nodeCount=0,this.nodesPerPage=0,this.rootIndex=0,this.lodMetric=a.None,this._lodConversion=e=>e,this.urlPrefix="",this._loading=new Set,this._failedNodes=new Set,this._failedPages=new Set,this._indexMissing=1,this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.POSITIVE_INFINITY,this._nodeTraversalState=new Map,this._version=P(0),this._visibilityCacheVersion=P(0),this._maxLevel=1,this._featureEstimate={estimate:0,leavesReached:!1},this._unloadedMemoryEstimate=0,this._missing=new s({deallocator:null}),this._prefetch=new s({deallocator:null}),this._updates=new b(this._missing),this._imModificationUncategorized=new s({deallocator:null}),this.ignoreServiceObb=!1,this.progressiveLoadPenalty=0,this._pageQueue=[],this.layerHasModifications=!1,this._layerHasFilter=!1,this.logLayer=e,e.serviceUpdateTimeStamp&&e.serviceUpdateTimeStamp.lastUpdate&&(this.lastUpdate=`${e.serviceUpdateTimeStamp.lastUpdate}`),this._maxLodLevel=this.viewportQueries?this.viewportQueries.maxLodLevel:1,this._init(t)}_init(e){if("page"===e.type){switch(this.urlPrefix=e.urlPrefix,this.nodesPerPage=e.pageSize,this.rootIndex=e.rootIndex,e.lodMetric){case"maxScreenThreshold":this.lodMetric=a.MaxScreenThreshold;break;case"maxScreenThresholdSQ":this.lodMetric=a.MaxScreenThreshold,this._lodConversion=L}this._addPage(C(this.rootIndex,this.nodesPerPage),e.rootPage),this._updateParentsAndLevel()}else if("node"===e.type){this.urlPrefix=e.urlPrefix,this._nodePages.push({nodes:[],children:[],parents:[]}),this._makeRefNode(new d(e.rootNode.id,null),-1);const t=this._validateNode(e.rootNode.id,e.rootNode);t&&this._addNode(t,0)}}_loadPage(e){this._loading.add(e);const t=this.urlPrefix+e;this.streamDataController.request(t,"json").then((t=>{this._pageQueue.push({pageIndex:e,page:t})})).catch((t=>{this._loading.delete(e),r(t)||(this._failedPages.add(e),this.logger.error("#loadPage()",this.logLayer,`Error when loading page ${e}`,t))}))}_addQueuedPages(e){for(;this._pageQueue.length>0&&!e.done;){const{pageIndex:t,page:i}=this._pageQueue.shift();this._addPage(t,i),this._loading.delete(t),e.madeProgress()}this._updateParentsAndLevel()}_addPage(e,t){for(let n=this._nodePages.length;n<e;n++)this._nodePages[n]=null;const i=[],s=[],r=t.nodes.map(((t,r)=>{const a=i.length,d=t.children?t.children.length:0;s.push(-1);for(let e=0;e<d;e++)i.push(t.children[e]);const h=`${t.index}`,u=_(t.obb),c=o([u.center[0],u.center[1],u.center[2],n(u.halfSize)]),g=t.mesh&&t.mesh.attribute,f=t.mesh&&t.mesh.geometry,v=t.mesh&&t.mesh.material,b={hasSharedResource:!1,hasFeatureData:!!f,attributes:g&&null!=g.resource?`${g.resource}`:null,geometry:f&&null!=f.resource?`${f.resource}`:null,texture:v&&null!=v.resource?`${v.resource}`:null,geometryDefinition:f?f.definition:-1,materialDefinition:v?v.definition:-1},p=new l(h,e*this.nodesPerPage+r,c,d,0,b,this.lastUpdate,this.lodMetric,this._lodConversion(t.lodThreshold),f?f.featureCount:null);return p.serviceObb=u,p.visibilityObb=this._computeVisibilityObb(p),p.vertexCount=f?f.vertexCount:0,new m(a,d,y(this._visibilityCacheVersion),null,p)}));this._nodePages[e]={nodes:r,children:i,parents:s},this.nodeCount+=r.length}_updateParentsAndLevel(){const t=new Array,i=(i,s,r)=>{const n=this._getPage(i);if(e(n)){const o=w(i,this.nodesPerPage);n.parents[o]=s;const a=n.nodes[o].node;e(a)&&(a.level=r,t.push(i))}};for(i(this.rootIndex,-1,0);t.length;){const s=t.pop(),r=this.getNode(s);if(e(r))for(let e=0;e<r.childCount;e++){i(this.getChildIndex(r,e),s,r.level+1),this._maxLevel=Math.max(this._maxLevel,r.level+1)}}}_getPage(e){return this._nodePages[C(e,this.nodesPerPage)]}_getNodeInternal(e){const i=this._getPage(e);return t(i)?null:i.nodes[w(e,this.nodesPerPage)]}_addNode(t,s){null!=t.children&&this.populateChildren(s,t.children);const r=this.getParent(s),n=e(r)?r.level+1:0;this._maxLevel=Math.max(this._maxLevel,t.children?n+1:n);const{lodMetric:a,maxError:d}=S(t.lodSelection),h=i(this._getNodeInternal(s));return h.node=new l(t.id,s,o(t.mbs),h.childCount,n,t.resources,t.version,a,d,t.numFeatures),t.obb&&(h.node.serviceObb=_(t.obb)),h.node.visibilityObb=this._computeVisibilityObb(h.node),e(h.ref)&&(null==h.ref.mbs&&(h.ref.mbs=t.mbs),h.node.renderMbs=h.ref.renderMbs,h.node.serviceObbInRenderSR=h.ref.serviceObbInRenderSR,h.ref.visibilityObb=h.node.visibilityObb),h.node}_makeRefNode(t,i){const s=this._nodePages[0],r=s.nodes.length;return s.nodes.push(new m(0,0,y(this._visibilityCacheVersion),t,null)),this.nodeCount++,s.parents.push(i),t.renderMbs[3]=-1,e(t.serviceObbInRenderSR)&&(t.serviceObbInRenderSR.halfSize[0]=-1),r}populateChildren(e,t){const s=i(this._getNodeInternal(e)),r=i(this._getPage(e));s.childOffset=r.children.length,s.childCount=t.length;for(let i=0;i<t.length;i++){const s=this._makeRefNode(t[i],e);r.children.push(s)}}getNode(t){const i=this._getNodeInternal(t);return e(i)?i.node:null}getIndexById(t){let i;return this._forAllNodes(((s,r)=>{(e(s.node)&&s.node.id===t||e(s.ref)&&s.ref.id===t)&&(i=r)})),i}getNodeById(e){const t=this.getIndexById(e);return t>=0?this.getNode(t):null}getChildIndex(e,i){const s=this._getPage(e.index);if(t(s))return-1;const r=s.nodes[w(e.index,this.nodesPerPage)];return s.children[r.childOffset+i]}getParentIndex(t){const i=this._getPage(t);return e(i)?i.parents[w(t,this.nodesPerPage)]:-1}getParent(e){return(e=this.getParentIndex(e))>=0?this.getNode(e):null}isLeaf(t){const i=this._getNodeInternal(t);return e(i)&&0===i.childCount}get rootNode(){return this.getNode(this.rootIndex)}get size(){return this.nodeCount}invalidateVisibilityCache(){this._visibilityCacheVersion=P(this._visibilityCacheVersion)}invalidateNodeVisibilityCache(t){const i=this._getNodeInternal(t);e(i)&&this.invalidateNodeVisibilityCacheInternal(i)}invalidateNodeVisibilityCacheInternal(e){e.visibilityCache=y(this._visibilityCacheVersion)}invalidateBoundingVolumeCache(t){const i=this._getNodeInternal(t);e(i)&&(p(i),this.invalidateNodeVisibilityCacheInternal(i))}invalidateGeometryVisibility(t){const i=this._getNodeInternal(t);e(i)&&e(i.node)&&(i.node.geometryObb=null,i.node.renderMbs[3]=-1,e(i.node.serviceObbInRenderSR)&&(i.node.serviceObbInRenderSR.halfSize[0]=-1))}invalidateVisibilityObbs(){t(this.rootNode)||this.traverse(this.rootNode,(e=>(e.visibilityObb=this._computeVisibilityObb(e),e.geometryObb=null,!0)))}isNodeVisible(i){const s=this._getNodeInternal(i);if(t(s)||e(s.ref)&&!s.ref.mbs)return!0;if(!x(s.visibilityCache,this._visibilityCacheVersion)){const i=s.node,r=e(i)&&(t(s.ref)||e(i.visibilityObb))?i:e(s.ref)?s.ref:null;if(this._layerHasFilter&&this._computeNodeFiltering&&(e(i)||e(s.ref))&&s.filterImpact===h.NotChecked){const t=e(i)?i.mbs:e(s.ref)?s.ref.mbs:null;s.filterImpact=null!=t?this._computeNodeFiltering(t):h.Unmodified}const n=e(i)&&s.filterImpact===h.Culled,o=!(e(i)&&i.imModificationImpact===u.Culled)&&(!r||this.viewportQueries.isNodeVisible(r))&&!n;return s.visibilityCache=N(o,this._visibilityCacheVersion),o}return I(s.visibilityCache)}isGeometryVisible(t){if(!this.isNodeVisible(t))return!1;const i=this._getNodeInternal(t);return!(e(i)&&e(i.node)&&e(i.node.geometryObb)&&(!this.layerHasModifications||i.node.imModificationImpact!==u.NotChecked))||this.viewportQueries.isGeometryVisible(i.node)}_traverseCoverage(s,r,n,o,a){const d=this._getPage(s);if(t(d)||0===r.childCount)return;const l=r.childOffset+r.childCount,h=new Array;for(let t=r.childOffset;t<l;++t){const i=d.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&this.isGeometryVisible(i)&&h.push(s)}o/=h.length;for(const e of h){const t=i(e.node).index;this._isLoaded(t)||this._isReloading(t)?(a.delta=Math.max(a.delta,n),a.coverage+=o):this._traverseCoverage(t,e,n+1,o,a)}}useNodeAsHole(e){if("off"===this.holeFilling)return!1;const i=this._getNodeInternal(e);if(t(i))return!1;if("always"===this.holeFilling)return!0;if(x(i.useAsHole,this._version))return I(i.useAsHole);const s={delta:0,coverage:0};this._traverseCoverage(e,i,0,1,s);const r=s.delta*s.coverage<=.5;return i.useAsHole=N(r,this._version),r}get maxLevel(){return this._maxLevel}get dirty(){return this._dirty}destroy(){this._updates.add.prune(),this._updates.update.prune()}requestUpdate(){this._dirty=!0,this._indexMissing=1,this._version=P(this._version)}imModificationsChanged(t){this.layerHasModifications=t,this._forAllNodes((({node:t})=>{e(t)&&(t.imModificationImpact=u.NotChecked,t.visibilityObb=this._computeVisibilityObb(t),t.hasModifications&&this.invalidateGeometryVisibility(t.index))})),this.invalidateVisibilityCache()}layerFilterChanged(t){this._layerHasFilter=t,this._forAllNodes((t=>{if(e(t)){t.filterImpact=h.NotChecked;const i=t.node;e(i)&&this.invalidateNodeVisibilityCache(i.index)}})),this.invalidateVisibilityCache()}update(s,r,n){if(!this._dirty)return;this._pageQueue.length>0&&this._addQueuedPages(r),this._maxUnloadedPrio=Number.NEGATIVE_INFINITY,this._maxProcessingPrio=Number.NEGATIVE_INFINITY,this._missing.clear(),this._prefetch.clear(),this._updates.reset(s),v.clear();let o=!0;const a=new O,d=new O,l=this._imModificationUncategorized;l.clear();const h=new Set,c=(c,g,_)=>{if(t(g)){let e=this._entryPriority(c);e===1/0&&(e=this._entryPriority(_));const t=C(c,this.nodesPerPage);return v.set(t,Math.max(e,v.get(t)||0)),this._loading.has(t)||this._failedPages.has(t)||this._missing.push(t),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const m=g.node;if(this._updateNodeFeatureEstimate(m,d),t(m)){const e=this._entryPriority(c);return this._loading.has(c)||this._failedNodes.has(c)||(this._missing.push(c),v.set(c,e)),void(this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e))}const f=i(this._getPage(c));if(0===this._missing.length&&0===this.nodesPerPage)for(let t=0;t<g.childCount;t++){const i=f.children[g.childOffset+t],s=this._getNodeInternal(i);!e(s)||s.node||this._loading.has(i)||this._failedNodes.has(i)||(v.set(i,this._entryPriority(i)),this._prefetch.push(i))}if(m.failed)return;if(h.add(m.id),this._isLoaded(c)){if(a.known+=m.memory,++a.knownNodes,this._isSelected(m)?g.childCount>0&&(o=!1):(a.unremoved+=m.memory,o=!1),this._needsUpdate(m)){const e=this._entryPriority(c);v.set(c,e),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,e),this._updates.update.push(c)}return}if(m.memory&&(a.known+=m.memory,++a.knownNodes),!this._isSelected(m))return void(this._isReloading(c)&&this._updates.remove.push(c));if(g.childCount>0&&(o=!1),m.memory?(a.missing+=m.memory,a.known+=m.memory,++a.knownNodes):++a.missingNodes,s.indexOf(m.index)>=0)return this._maxProcessingPrio=Math.max(this._maxProcessingPrio,this._entryPriority(c)),void(this._updates.cancel=this._updates.cancel.filter((e=>e!==m.index)));if(!r.done&&this._enable(m))return void r.madeProgress();const b=this._entryPriority(c);v.set(c,b),this._maxProcessingPrio=Math.max(this._maxProcessingPrio,b),this._updates.add.push(c),this.layerHasModifications&&n&&e(m)&&m.imModificationImpact===u.NotChecked&&l.push(c)};this.traverseVisible(c);const g=this._updates.add;g.length>0&&this.layerHasModifications&&(l.length>0&&n(l),g.filterInPlace((e=>{const i=this._getNodeInternal(e),s=t(i)||t(i.node)||i.node.imModificationImpact!==u.Culled;return s||this.invalidateNodeVisibilityCache(e),s}))),this._unloadedMemoryEstimate=a.missing-a.unremoved,a.knownNodes>3&&a.missingNodes>0&&(this._unloadedMemoryEstimate+=a.known/a.knownNodes*a.missingNodes),this._unloadedMemoryEstimate=.8*Math.max(0,this._unloadedMemoryEstimate),this._featureEstimate.estimate=this._computeFeatureEstimate(d),this._featureEstimate.leavesReached=o,this._missing.sort(((e,t)=>e-t)),this._missing.filterInPlace(((e,t)=>t<1||this._missing.data[t-1]!==e)),this._missing.sort(((e,t)=>v.get(e)-v.get(t))),this._missing.length>0&&(this._maxUnloadedPrio=v.get(this._missing.back()),this._prefetch.clear()),this._updates.add.filterInPlace((e=>v.get(e)>=this._maxUnloadedPrio)).sort(((e,t)=>v.get(e)-v.get(t))),this._updates.update.sort(((e,t)=>v.get(e)-v.get(t))),this._indexMissing=this._loading.size+this._missing.length,this._dirty=this._indexMissing>0,v.clear()}checkFeatureTarget(e,t){const i=this.viewportQueries.updateScreenSpaceErrorBias(t);let s=t,r=t,n=i,o=10;for(;o--;){const i=new O;this._updateFeatureEstimate(s,i);if(this._computeFeatureEstimate(i)<=e){if(s>=t||i.missingNodes>0||0===o)break;n=s,s=.5*(s+r)}else r=s,s=.5*(s+n)}return this._version=P(this._version),this.viewportQueries.updateScreenSpaceErrorBias(i),Math.min(t,s)}_updateFeatureEstimate(t,i){this._version=P(this._version),this.viewportQueries.updateScreenSpaceErrorBias(t),this.traverseVisible(((t,s)=>this._updateNodeFeatureEstimate(e(s)&&s.node,i)))}_updateNodeFeatureEstimate(i,s){if(!(t(i)||i.failed||t(i.numFeatures)))return this._isLoaded(i.index)?(s.known+=i.numFeatures,++s.knownNodes,void(this._isSelected(i)||(s.unremoved+=i.numFeatures))):void(this._isSelected(i)&&(e(i.numFeatures)?(s.missing+=i.numFeatures,s.known+=i.numFeatures,++s.knownNodes):++s.missingNodes))}_computeFeatureEstimate(e){let t=e.known-e.unremoved;return e.knownNodes>3&&e.missingNodes>0&&(t+=e.known/e.knownNodes*e.missingNodes),Math.max(0,t)}load(){return this._load(this._missing)}prefetch(){return this._prefetch.sort(((e,t)=>v.get(e)-v.get(t))),this._load(this._prefetch)}_load(e){if(0===e.length||!this._canRequest())return!1;for(;e.length>0&&this._canRequest();)0===this.nodesPerPage?this._loadNode(e.pop()):this._loadPage(e.pop());return!0}isLoading(){return this._indexMissing>0}getIndexLoading(){return this._loading.size}getIndexMissing(){return this._indexMissing}getUnloadedMemoryEstimate(){return this._unloadedMemoryEstimate}get updates(){return this._updates}get featureEstimate(){return this._featureEstimate}nodeTraversalState(e){if(t(e))return null;let i=this._nodeTraversalState.get(e.index);if(i&&x(i.version,this._version))return i;const s=this.viewportQueries.getLodLevel(e),r=this.viewportQueries.hasLOD(e);let n=!0;if(r){const t=this.getParentIndex(e.index);if(t>=0){const e=this._nodeTraversalState.get(t);n=e&&s>e.lodLevel}else n=s>0}else n=0===e.childCount;return i?(i.lodLevel=s,i.isChosen=n,i.version=N(!0,this._version),i):(i=new c(r,n,s,N(!0,this._version)),this._nodeTraversalState.set(e.index,i),i)}_loadNode(e){this._loading.add(e);const s=i(this._getNodeInternal(e)).ref;if(t(s))return void this._failedNodes.add(e);const n=s.id,o=this.urlPrefix+n,a=()=>{this._loading.delete(e),0===this._missing.length&&0===this._loading.size&&this.requestUpdate()};this.streamDataController.request(o,"json").then((t=>{a();const i=this._validateNode(n,t);if(null==i)return;i.obb&&this.invalidateNodeVisibilityCache(e);const s=this._addNode(i,e);this.nodeTraversalState(s)}),(t=>{a(),r(t)||(this.logger.error("#loadNode()",this.logLayer,"Error loading node: "+o),this._failedNodes.add(e))}))}_validateNode(e,t){if(null==t||"object"!=typeof t||t.id!==e)return this.logger.error("#validateNode()",this.logLayer,`Invalid node. Wrong type or wrong id "${e}"`),null;if(!Array.isArray(t.mbs))return this.logger.error("#validateNode()",this.logLayer,`Invalid bounding volume on node ${e}.`),null;t.sharedResource&&"./shared"!==t.sharedResource.href&&"./shared/"!==t.sharedResource.href&&this.logger.warn("#validateNode()",this.logLayer,`Invalid shared resource href on node "${e}"`),null==t.geometryData||Array.isArray(t.geometryData)&&1===t.geometryData.length&&"./geometries/0"===t.geometryData[0].href||this.logger.warn("#validateNode()",this.logLayer,`Invalid geometry data on node "${e}"`),null==t.attributeData||Array.isArray(t.attributeData)&&!t.attributeData.some(((e,t)=>e.href!==`./attributes/f_${t}/0`))||this.logger.warn("#validateNode()",this.logLayer,`Invalid attribute data on node "${e}"`),t.featureData&&t.featureData.length>1&&this.logger.warn("#validateNode()",this.logLayer,`Node ${e} has ${t.featureData.length} bundles. Only the first bundle will be loaded.`);const i=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,s=t.featureData&&1===t.featureData.length&&t.featureData[0].featureRange?t.featureData[0].featureRange[1]-t.featureData[0].featureRange[0]+1:null,r=t=>{if(null==t)return null;const i=t=>this.logger.error("#validateNode()",this.logLayer,`Invalid node reference on node ${e}: ${t}`);if("number"==typeof t.id)i(`id ${t.id} is a number instead of a string.`);else if("string"!=typeof t.id||!Array.isArray(t.mbs))return i("Missing or invalid id."),null;if(!Array.isArray(t.mbs))return i(`Invalid bounding volume on reference ${t.id}.`),null;t.href&&t.href!=="../"+t.id&&this.logger.error("#validateNode()",this.logLayer,`Invalid node href on node "${e}"`);const s=t.hasOwnProperty("obb")&&!this.ignoreServiceObb?t.obb:null,r=new d(`${t.id}`,t.mbs);return r.serviceObb=s,r.visibilityObb=this._computeVisibilityObb(r),r},n=Array.isArray(t.children)?t.children.map(r).filter((e=>null!=e)):null;return{id:e,mbs:t.mbs,obb:i,children:n,resources:{hasFeatureData:t.featureData&&t.featureData.length>0,hasSharedResource:null!=t.sharedResource,attributes:t.attributeData?e:null,texture:t.textureData&&t.textureData.length>0?e:null,geometry:null!=t.geometryData?e:null},version:"string"==typeof t.version?t.version:null,lodSelection:Array.isArray(t.lodSelection)?t.lodSelection:null,numFeatures:s}}resetFailedNodes(){this._failedNodes.clear(),this._failedPages.clear(),this._forAllNodes((t=>{e(t.node)&&(t.node.failed=!1)}))}_entryPriority(i){const s=this._getNodeInternal(i),r=this.getParentIndex(i);if(t(s)||r<0&&null==s.node)return r<0?1/0:this._entryPriority(r);let n=0;if(s.node&&r>=0){const e=this._nodeTraversalState.get(r);null!=e&&(n=e.lodLevel)}let o=this.progressiveLoadPenalty;for(let e=i;e>=0;e=this.getParentIndex(e))if(this._isLoaded(e)){o=0;break}const a=e(s.ref)?this.viewportQueries.distToPOI(s.ref):e(s.node)?this.viewportQueries.distToPOI(s.node):0;return-a-n*(a+this.progressiveLoadPenalty)+o}traverseVisible(e){const i=this._getNodeInternal(this.rootIndex);t(i)?e(this.rootIndex,null,null):this._traverseVisible(this.rootIndex,-1,i,e)}_traverseVisible(t,s,r,n){if(r.node&&0===r.childCount)return void(this.isGeometryVisible(t)&&n(t,r,s));if(!this.isNodeVisible(t))return;if(n(t,r,s),null==r.node)return;const o=this.nodeTraversalState(r.node);if(o.nodeHasLOD&&o.lodLevel===this._maxLodLevel)return;const a=i(this._getPage(t));for(let i=0;i<r.childCount;i++){const s=a.children[r.childOffset+i],o=this._getNodeInternal(s);e(o)?this._traverseVisible(s,t,o,n):n(s,null,t)}}traverse(e,t){t(e)&&this.traverseChildren(e,t)}traverseChildren(t,i){const s=t.index,r=this._getNodeInternal(s);e(r)&&this._traverseChildren(s,r,i)}_traverseChildren(i,s,r){const n=this._getPage(i);if(t(n))return;const o=s.childOffset+s.childCount;for(let t=s.childOffset;t<o;++t){const i=n.children[t],s=this._getNodeInternal(i);e(s)&&e(s.node)&&r(s.node)&&this._traverseChildren(i,s,r)}}updateStats(e){if(this._updates.add.length>0&&(e.nodes+=" + "+this._updates.add.length),(this._indexMissing||this._prefetch.length>0)&&(e.index+=" + "+this._indexMissing||this._prefetch.length),e.prio=this._maxProcessingPrio,this._featureEstimate.estimate){const t=this._featureEstimate.estimate-e.features;t>0?e.features+=" + "+t:t<0&&(e.features+=" - "+-t)}}getPriority(){return Math.max(this._maxProcessingPrio,this._maxUnloadedPrio)}updateElevationInfo(e){this._forAllNodes(p),this.viewportQueries.updateElevationInfo(e)}_forAllNodes(e){for(let t=0;t<this._nodePages.length;t++){const i=this._nodePages[t];if(i){const s=t*this.nodesPerPage;for(let t=0;t<i.nodes.length;t++)e(i.nodes[t],s+t)}}}get test(){return{addNode:(e,t)=>this._addNode(e,t)}}}const v=new Map;class b{constructor(e){this.missing=e,this.update=new s({deallocator:null}),this.add=new s({deallocator:null}),this.remove=new s({deallocator:null}),this.cancel=[]}reset(e){this.add.clear(),this.update.clear(),this.cancel=e}}function p(t){e(t.node)&&(t.node.renderMbs[3]=-1,e(t.node.serviceObbInRenderSR)&&(t.node.serviceObbInRenderSR.halfSize[0]=-1)),e(t.ref)&&(t.ref.renderMbs[3]=-1,e(t.ref.serviceObbInRenderSR)&&(t.ref.serviceObbInRenderSR.halfSize[0]=-1))}function y(e){return g(e,-2)}function P(e){return g(e,2)}function N(e,t){return t+(e?1:0)}function x(e,t){return(-2&e)===t}function I(e){return 1==(1&e)}function C(e,t){return 0===t?0:e/t|0}function w(e,t){return 0===t?e:e%t}const M=[["maxScreenThreshold",a.MaxScreenThreshold],["screenSpaceRelative",a.ScreenSpaceRelative],["removedFeatureDiameter",a.RemovedFeatureDiameter],["distanceRangeFromDefaultCamera",a.DistanceRangeFromDefaultCamera]];function S(e){if(e)for(let t=0;t<e.length;t++)for(const i of M)if(i[0]===e[t].metricType)return{lodMetric:i[1],maxError:e[t].maxError};return{lodMetric:a.None,maxError:0}}class O{constructor(){this.known=0,this.knownNodes=0,this.missing=0,this.missingNodes=0,this.unremoved=0}}function L(e){return Math.sqrt(e*(4/Math.PI))}export{f as I3SIndex,S as selectErrorMetric};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/has.js";import{clamp as a,isPowerOfTwo as o}from"../../../../core/mathUtils.js";import{isSome as r,isNone as s}from"../../../../core/maybe.js";import{TextureEncoding as t,TextureUsage as n}from"./enums.js";import{RenderTexture as l}from"../../webgl-engine/core/material/RenderTexture.js";import{PBRSchematicMRRValues as i}from"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as c}from"../../webgl-engine/core/shaderLibrary/util/AlphaDiscard.glsl.js";import{getEllipsoidMode as u}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{CullFaceOptions as m,AlphaDiscardMode as d}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as g}from"../../webgl-engine/lib/Texture.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function h(e,a){const o=new Map,t=(e,a)=>{if(s(e))return-1;if(o.has(e.id)){const r=o.get(e.id);return r.usage|=a,r.id}const r=o.size;return o.set(e.id,{id:r,usage:a}),r},l=a.pbrMetallicRoughness,c=l&&l.baseColorFactor,u=a.emissiveFactor,d=null==a.normalTexture&&null==a.emissiveTexture&&null==a.occlusionTexture&&(!l||null==l.metallicRoughnessTexture&&1===l.roughnessFactor&&(1===l.metallicFactor||0===l.metallicFactor)),g=d?i[0]:l?l.metallicFactor:1,p=d?i[1]:l?l.roughnessFactor:1,h="mask"===a.alphaMode?n.Color|n.AlphaMask:n.Color,x={baseColorFactor:c?[c[0],c[1],c[2],c[3]]:[1,1,1,1],baseColorTextureId:t(l&&l.baseColorTexture,h),metallicRoughnessTextureId:t(l&&l.metallicRoughnessTexture,n.MetallicRoughness),metallicFactor:g,roughnessFactor:p},b={alphaMode:a.alphaMode,alphaCutoff:a.alphaCutoff,doubleSided:a.doubleSided,cullFace:"none"===a.cullFace?m.None:"back"===a.cullFace?m.Back:"front"===a.cullFace?m.Front:void 0,normalTextureId:t(a.normalTexture,n.Normal),emissiveTextureId:t(a.emissiveTexture,n.Emissive),occlusionTextureId:t(a.occlusionTexture,n.Occlusion),emissiveFactor:u?[u[0],u[1],u[2]]:[0,0,0],metallicRoughness:x,wrapTextures:!1,hasParametersFromSource:d},F=[];return o.forEach((({usage:a},o)=>{const s=r(e)&&e[o]&&e[o].formats,t=s?f(s.map((({name:e,format:a})=>({name:e,encoding:T[a]})))):[];F.push({id:o,usage:a,encodings:t})})),{material:b,textures:F}}function f(e){return e.sort(((e,a)=>e.encoding-a.encoding))}const T={ktx2:t.KTX2,basis:t.Basis,dds:t.DDS_S3TC,png:t.PNG,jpg:t.JPG,"ktx-etc2":t.KTX_ETC2},x={[g.KTX2_ENCODING]:t.Basis,[g.BASIS_ENCODING]:t.Basis,[g.DDS_ENCODING]:t.DDS_S3TC,"image/png":t.PNG,"image/jpg":t.JPG,"image/jpeg":t.JPG,"image/ktx":t.KTX_ETC2};function b(e){const o=e&&e.materialDefinitions?Object.keys(e.materialDefinitions)[0]:null,r=e&&e.textureDefinitions?Object.keys(e.textureDefinitions)[0]:null,s=o&&e.materialDefinitions[o],t=r&&e.textureDefinitions[r],l=F();if(null!=s){const e=s.params;e.diffuse&&(l.metallicRoughness.baseColorFactor=[e.diffuse[0],e.diffuse[1],e.diffuse[2],1]),null!=e.doubleSided&&(l.doubleSided=e.doubleSided,l.cullFace=e.doubleSided?m.None:m.Back),"none"!==e.cullFace&&"front"!==e.cullFace&&"back"!==e.cullFace||(l.cullFace="none"===e.cullFace?m.None:"back"===e.cullFace?m.Back:m.Front),e.transparency&&(l.metallicRoughness.baseColorFactor[3]=a(1-e.transparency,0,1)),(e.useVertexColorAlpha||l.metallicRoughness.baseColorFactor[3]<1)&&(l.alphaMode="blend")}const i=[];if(null!=t){const e=0;!t.wrap||"repeat"!==t.wrap[0]&&"repeat"!==t.wrap[1]||(l.wrapTextures=!0);let a=n.Color;"rgba"===t.channels&&(l.alphaMode="blend",a|=n.AlphaMask);const o=t.images.length-1,r=t.images[o],s=e=>e&&e.split("/").pop(),c=Array.isArray(t.encoding)?f(t.encoding.map(((e,a)=>({name:s(r.href[a]),encoding:x[e]||0})))):[{name:s(r.href),encoding:x[t.encoding]||0}];i.push({id:e,usage:a,encodings:c}),l.metallicRoughness.baseColorTextureId=e}return{material:l,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:c,doubleSided:!0,cullFace:m.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function C(e,a,r,t){if(s(e)||null==e.data)return null;const l=e.data,i=!(l instanceof HTMLImageElement)||o(l.width)&&o(l.height),c=t.renderingContext.parameters.maxMaxAnisotropy,u=r&&!t.capabilities.shaderTextureLOD?1:c,m=i&&!e.downsampled&&u>1,d=r||!a.wrapTextures?P:M,p=E(e.encoding),h=e.usage&n.Color?"opaque"===a.alphaMode?3:4:3;return new g(l,{mipmap:m,maxAnisotropy:u,encoding:p,wrap:d,components:h,noUnpackFlip:!0})}const P={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},M={s:p.REPEAT,t:p.REPEAT};function S(e,o,s,t,i,m){const g=m.rendererTextureUsage,p=e=>R(t,s,e&g),h=o.metallicRoughness.baseColorFactor,f=a(o.metallicRoughness.baseColorFactor[3],0,1);e.baseColor=[h[0],h[1],h[2],f],e.hasParametersFromSource=!!o.hasParametersFromSource,e.usePBR=m.usePBR,e.mrrFactors=[o.metallicRoughness.metallicFactor,o.metallicRoughness.roughnessFactor,o.hasParametersFromSource?.2:.5],e.emissiveFactor=o.emissiveFactor,e.isIntegratedMesh=m.isIntegratedMesh,e.alphaCutoff="mask"===o.alphaMode?o.alphaCutoff:c,e.alphaDiscardMode="opaque"===o.alphaMode?d.Opaque:"mask"===o.alphaMode?d.Mask:d.MaskBlend;const T=[],x=p(n.Color|n.AlphaMask);r(x)&&(e.baseColorTexture=new l(i,x),T.push(e.baseColorTexture.loadPromise));const b=p(n.MetallicRoughness);r(b)&&(e.metallicRoughnessTexture=new l(i,b),T.push(e.metallicRoughnessTexture.loadPromise));const F=p(n.Emissive);r(F)&&(e.emissionTexture=new l(i,F),T.push(e.emissionTexture.loadPromise));const C=p(n.Occlusion);r(C)&&(e.occlusionTexture=new l(i,C),T.push(e.occlusionTexture.loadPromise));const P=p(n.Normal);return r(P)&&(e.normalTexture=new l(i,P),T.push(e.normalTexture.loadPromise)),e.commonMaterialParameters.slicePlaneEnabled=m.slicePlaneEnabled,e.commonMaterialParameters.doubleSided=o.doubleSided,e.commonMaterialParameters.cullFace=o.cullFace,e.ellipsoidMode=u(m.viewSpatialReference),Promise.all(T)}function D(a){const o=!!a.compressedTextureS3TC,r=!!a.compressedTextureETC,s=e("disable-feature:i3s-basis")?0:t.Basis|t.KTX2,n=t.JPG|t.PNG,l=s|t.DDS_S3TC;return n|(o?l:0)|(r?s:0)}function w(e,a){return e.find((e=>0!=(e.encoding&a)))}function R(e,a,o){if(s(e)||o===n.None)return null;for(let s=0;s<e.length;s++){const t=e[s];if(r(t)&&0!=(t.usage&o)){const e=a[s];return r(e)?e.id:null}}return null}function E(e){switch(e){case t.KTX2:return g.KTX2_ENCODING;case t.Basis:return g.BASIS_ENCODING;case t.DDS_S3TC:return g.DDS_ENCODING;case t.PNG:return"image/png";case t.JPG:return"image/jpeg";case t.KTX_ETC2:return"image/ktx";default:return""}}export{S as configureMaterial,C as createTexture,h as getMaterialAndTextures,b as getMaterialAndTexturesFromShared,D as getSupportedEncodings,w as selectEncoding};
|
|
5
|
+
import e from"../../../../core/has.js";import{clamp as a,isPowerOfTwo as o}from"../../../../core/mathUtils.js";import{isSome as r,isNone as s}from"../../../../core/maybe.js";import{TextureEncoding as t,TextureUsage as n}from"./enums.js";import{RenderTexture as l}from"../../webgl-engine/core/material/RenderTexture.js";import{PBRSchematicMRRValues as i}from"../../webgl-engine/core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as c}from"../../webgl-engine/core/shaderLibrary/util/AlphaDiscard.glsl.js";import{getEllipsoidMode as u}from"../../webgl-engine/core/shaderLibrary/util/EllipsoidMode.js";import{CullFaceOptions as m,AlphaDiscardMode as d}from"../../webgl-engine/lib/basicInterfaces.js";import{Texture as g}from"../../webgl-engine/lib/Texture.js";import{TextureWrapMode as p}from"../../../webgl/enums.js";function h(e,a){const o=new Map,t=(e,a)=>{if(s(e))return-1;if(o.has(e.id)){const r=o.get(e.id);return r.usage|=a,r.id}const r=o.size;return o.set(e.id,{id:r,usage:a}),r},l=a.pbrMetallicRoughness,c=l&&l.baseColorFactor,u=a.emissiveFactor,d=null==a.normalTexture&&null==a.emissiveTexture&&null==a.occlusionTexture&&(!l||null==l.metallicRoughnessTexture&&1===l.roughnessFactor&&(1===l.metallicFactor||0===l.metallicFactor)),g=d?i[0]:l?l.metallicFactor:1,p=d?i[1]:l?l.roughnessFactor:1,h="mask"===a.alphaMode?n.Color|n.AlphaMask:n.Color,x={baseColorFactor:c?[c[0],c[1],c[2],c[3]]:[1,1,1,1],baseColorTextureId:t(l&&l.baseColorTexture,h),metallicRoughnessTextureId:t(l&&l.metallicRoughnessTexture,n.MetallicRoughness),metallicFactor:g,roughnessFactor:p},b={alphaMode:a.alphaMode,alphaCutoff:a.alphaCutoff,doubleSided:a.doubleSided,cullFace:"none"===a.cullFace?m.None:"back"===a.cullFace?m.Back:"front"===a.cullFace?m.Front:void 0,normalTextureId:t(a.normalTexture,n.Normal),emissiveTextureId:t(a.emissiveTexture,n.Emissive),occlusionTextureId:t(a.occlusionTexture,n.Occlusion),emissiveFactor:u?[u[0],u[1],u[2]]:[0,0,0],metallicRoughness:x,wrapTextures:!1,hasParametersFromSource:d},F=[];return o.forEach((({usage:a},o)=>{const s=r(e)&&e[o]&&e[o].formats,t=s?f(s.map((({name:e,format:a})=>({name:e,encoding:T[a]})))):[];F.push({id:o,usage:a,encodings:t})})),{material:b,textures:F}}function f(e){return e.sort(((e,a)=>e.encoding-a.encoding))}const T={ktx2:t.KTX2,basis:t.Basis,dds:t.DDS_S3TC,png:t.PNG,jpg:t.JPG,"ktx-etc2":t.KTX_ETC2},x={[g.KTX2_ENCODING]:t.Basis,[g.BASIS_ENCODING]:t.Basis,[g.DDS_ENCODING]:t.DDS_S3TC,"image/png":t.PNG,"image/jpg":t.JPG,"image/jpeg":t.JPG,"image/ktx":t.KTX_ETC2};function b(e){const o=e&&e.materialDefinitions?Object.keys(e.materialDefinitions)[0]:null,r=e&&e.textureDefinitions?Object.keys(e.textureDefinitions)[0]:null,s=o&&e.materialDefinitions[o],t=r&&e.textureDefinitions[r],l=F();if(null!=s){const e=s.params;e.diffuse&&(l.metallicRoughness.baseColorFactor=[e.diffuse[0],e.diffuse[1],e.diffuse[2],1]),null!=e.doubleSided&&(l.doubleSided=e.doubleSided,l.cullFace=e.doubleSided?m.None:m.Back),"none"!==e.cullFace&&"front"!==e.cullFace&&"back"!==e.cullFace||(l.cullFace="none"===e.cullFace?m.None:"back"===e.cullFace?m.Back:m.Front),e.transparency&&(l.metallicRoughness.baseColorFactor[3]=a(1-e.transparency,0,1)),(e.useVertexColorAlpha||l.metallicRoughness.baseColorFactor[3]<1)&&(l.alphaMode="blend")}const i=[];if(null!=t){const e=0;!t.wrap||"repeat"!==t.wrap[0]&&"repeat"!==t.wrap[1]||(l.wrapTextures=!0);let a=n.Color;"rgba"===t.channels&&(l.alphaMode="blend",a|=n.AlphaMask);const o=t.images.length-1,r=t.images[o],s=e=>e&&e.split("/").pop(),c=Array.isArray(t.encoding)?f(t.encoding.map(((e,a)=>({name:s(r.href[a]),encoding:x[e]||0})))):[{name:s(r.href),encoding:x[t.encoding]||0}];i.push({id:e,usage:a,encodings:c}),l.metallicRoughness.baseColorTextureId=e}return{material:l,textures:i}}const F=()=>({alphaMode:"opaque",alphaCutoff:c,doubleSided:!0,cullFace:m.None,normalTextureId:-1,emissiveTextureId:-1,occlusionTextureId:-1,emissiveFactor:[0,0,0],metallicRoughness:{baseColorFactor:[.8,.8,.8,1],baseColorTextureId:-1,metallicRoughnessTextureId:-1,metallicFactor:0,roughnessFactor:.6},wrapTextures:!1,hasParametersFromSource:!0});function C(e,a,r,t){if(s(e)||null==e.data)return null;const l=e.data,i=!(l instanceof HTMLImageElement)||o(l.width)&&o(l.height),c=t.renderingContext.parameters.maxMaxAnisotropy,u=r&&!t.capabilities.shaderTextureLOD?1:c,m=i&&!e.downsampled&&u>1,d=r||!a.wrapTextures?P:M,p=E(e.encoding),h=e.usage&n.Color?"opaque"===a.alphaMode?3:4:3;return new g(l,{mipmap:m,maxAnisotropy:u,encoding:p,wrap:d,components:h,noUnpackFlip:!0})}const P={s:p.CLAMP_TO_EDGE,t:p.CLAMP_TO_EDGE},M={s:p.REPEAT,t:p.REPEAT};function S(e,o,s,t,i,m){const g=m.rendererTextureUsage,p=e=>R(t,s,e&g),h=o.metallicRoughness.baseColorFactor,f=a(o.metallicRoughness.baseColorFactor[3],0,1);e.baseColor=[h[0],h[1],h[2],f],e.hasParametersFromSource=!!o.hasParametersFromSource,e.usePBR=m.usePBR,e.mrrFactors=[o.metallicRoughness.metallicFactor,o.metallicRoughness.roughnessFactor,o.hasParametersFromSource?.2:.5],e.emissiveFactor=o.emissiveFactor,e.isIntegratedMesh=m.isIntegratedMesh,e.alphaCutoff="mask"===o.alphaMode?o.alphaCutoff:c,e.alphaDiscardMode="opaque"===o.alphaMode?d.Opaque:"mask"===o.alphaMode?d.Mask:d.MaskBlend;const T=[],x=p(n.Color|n.AlphaMask);r(x)&&(e.baseColorTexture=new l(i,x),T.push(e.baseColorTexture.loadPromise));const b=p(n.MetallicRoughness);r(b)&&(e.metallicRoughnessTexture=new l(i,b),T.push(e.metallicRoughnessTexture.loadPromise));const F=p(n.Emissive);r(F)&&(e.emissionTexture=new l(i,F),T.push(e.emissionTexture.loadPromise));const C=p(n.Occlusion);r(C)&&(e.occlusionTexture=new l(i,C),T.push(e.occlusionTexture.loadPromise));const P=p(n.Normal);return r(P)&&(e.normalTexture=new l(i,P),T.push(e.normalTexture.loadPromise)),e.commonMaterialParameters.slicePlaneEnabled=m.slicePlaneEnabled,e.commonMaterialParameters.doubleSided=o.doubleSided,e.commonMaterialParameters.cullFace=o.cullFace,e.ellipsoidMode=u(m.viewSpatialReference),Promise.all(T)}function D(a){const o=!!a.compressedTextureS3TC,r=!!a.compressedTextureETC,s=e("disable-feature:i3s-basis")?0:t.Basis|t.KTX2,n=t.JPG|t.PNG,l=s|t.DDS_S3TC;return n|(o?l:0)|(r?s:0)}function w(e,a){return e.find((e=>0!=(e.encoding&a)))}function R(e,a,o){if(s(e)||o===n.None)return null;for(let s=0;s<e.length;s++){const t=e[s];if(r(t)&&0!=(t.usage&o)){const e=a[s];return r(e)?e.id:null}}return null}function E(e){switch(e){case t.KTX2:return g.KTX2_ENCODING;case t.Basis:return g.BASIS_ENCODING;case t.DDS_S3TC:return g.DDS_ENCODING;case t.PNG:return"image/png";case t.JPG:return"image/jpeg";case t.KTX_ETC2:return"image/ktx";default:return""}}export{S as configureMaterial,C as createTexture,F as defaultMaterial,h as getMaterialAndTextures,b as getMaterialAndTexturesFromShared,D as getSupportedEncodings,w as selectEncoding};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as t,isNone as e}from"../../../../core/maybe.js";import{h as i,i as s,l as r,a as n,d as a,p as o,f as h,b as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{c as p}from"../../../../chunks/vec4.js";import{projectBoundingSphere as u}from"../../../../geometry/projection.js";import{getSphericalPCPF as _}from"../../../../geometry/projectionEllipsoid.js";import{create as l,fromMatrix as d,intersectsSphere as b}from"../../../../geometry/support/frustum.js";import{w as g}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as f}from"../../../../layers/graphics/dehydratedFeatures.js";import{evaluateElevationAlignmentAtPoint as
|
|
5
|
+
import{isSome as t,isNone as e}from"../../../../core/maybe.js";import{h as i,i as s,l as r,a as n,d as a,p as o,f as h,b as c}from"../../../../chunks/vec3.js";import{c as m}from"../../../../chunks/vec3f64.js";import{c as p}from"../../../../chunks/vec4.js";import{projectBoundingSphere as u}from"../../../../geometry/projection.js";import{getSphericalPCPF as _}from"../../../../geometry/projectionEllipsoid.js";import{create as l,fromMatrix as d,intersectsSphere as b}from"../../../../geometry/support/frustum.js";import{w as g}from"../../../../chunks/sphere.js";import{makeDehydratedPoint as f}from"../../../../layers/graphics/dehydratedFeatures.js";import{evaluateElevationAlignmentAtPoint as v}from"../graphics/elevationAlignmentUtils.js";import{ElevationContext as D}from"../graphics/ElevationContext.js";import{createContextWithoutExpressionSupport as M,extractExpressionInfo as x}from"../graphics/featureExpressionInfoUtils.js";import{LodMetric as C}from"./I3SNode.js";import{transformObb as S,intersectBoundingRectWithMbs as R,MbsIntersectResult as P}from"./I3SUtil.js";import{create as E,isVisible as L}from"../../support/orientedBoundingBox.js";const O=1e5;class j{constructor(t,e,i,s,r,n,a,o={}){this._indexSR=t,this._renderCoordsHelper=e,this.clippingArea=r,this._elevationProvider=n,this._options=o,this._frustum=l(),this._useFrustumCulling=!1,this._poi=m(),this.minDistance=1/0,this.maxDistance=0,this.maxLodLevel=2,this._tmp1=m(),this._tmp2=m(),this._tmp3=m(),this._tmp0=m(),this._screenspaceErrorBias=o.screenspaceErrorBias||1,this._progressiveLoadFactor=o.progressiveLoadFactor||1,this.updateCamera(i,s),this.engineSR=this._renderCoordsHelper.spatialReference,this.updateElevationInfo(a),this._tmpPoint=f(0,0,0,t)}updateElevationInfo(t){null!=t?(this._elevationContext=D.fromElevationInfo(t),this._elevationContext.updateFeatureExpressionInfoContext(M(x(t,!1)))):this._elevationContext=null}updateCamera(t,e){this._useFrustumCulling=e,e&&d(t.viewMatrix,t.projectionMatrix,this._frustum),this._screenSizeFactor=1/(t.perScreenPixelRatio/2),this._camPos=t.eye,this.minDistance=1/0,this.maxDistance=0}setPointOfInterest(t){this._poi=t}updateScreenSpaceErrorBias(t){const e=this._screenspaceErrorBias;return this._screenspaceErrorBias=t,e}updateClippingArea(t){this.clippingArea=t}getRenderMbs(t){const e=t.renderMbs;return e[3]<0&&(p(e,t.mbs),this._elevationContext&&e[3]<O&&(this._tmpPoint.x=e[0],this._tmpPoint.y=e[1],this._tmpPoint.z=e[2],e[2]=v(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)),u(e,this._indexSR,e,this.engineSR)),e}getVisibilityObb(i){if(t(i.visibilityObb))return i.visibilityObb;const s=i.serviceObb;return e(s)||s.halfSize[0]<0?void 0:(i.serviceObbInRenderSR=this._computeRenderObb(s,i.serviceObbInRenderSR,i.mbs[3]),i.serviceObbInRenderSR)}_computeRenderObb(t,i,s){if(e(i)&&(i=E()),i.halfSize[0]<0){let e=0;this._elevationContext&&s<O&&(this._tmpPoint.x=t.center[0],this._tmpPoint.y=t.center[1],this._tmpPoint.z=t.center[2],e=v(this._tmpPoint,this._elevationProvider,this._elevationContext,this._renderCoordsHelper)-t.center[2]),S(t,this._indexSR,i,this.engineSR,e)}return i}isNodeVisible(e){const i=this.getRenderMbs(e);if(!this._isMBSinClippingArea(i))return!1;if(!this._useFrustumCulling)return!0;const s=this.getVisibilityObb(e);return t(s)?L(s,this._frustum):b(this._frustum,g(i))}isGeometryVisible(e){if(!this._useFrustumCulling)return!0;const i=e.geometryObb;return t(i)?L(i,this._frustum):this.isNodeVisible(e)}_isMBSinClippingArea(t){return!!e(this.clippingArea)||R(this.clippingArea,t)!==P.OUTSIDE}_screenSpaceDiameterMbs(t,e){const s=this.getRenderMbs(t),r=Math.sqrt(i(s,this._camPos)),n=r-s[3];return this._updateMinMaxDistance(r),n<0?.5*Number.MAX_VALUE:e/n*this._screenSizeFactor}calcCameraDistance(t){return this.calcCameraDistanceToCenter(t)-this.getRenderMbs(t)[3]}calcCameraDistanceToCenter(t){const e=this.getRenderMbs(t),i=s(e,this._camPos);return this._updateMinMaxDistance(i),i}calcAngleDependentLoD(t){const e=this.getRenderMbs(t),i=e[3],n=(Math.abs(e[0]*(e[0]-this._camPos[0])+e[1]*(e[1]-this._camPos[1])+e[2]*(e[2]-this._camPos[2]))/r(e)+i)/s(e,this._camPos);return Math.min(1,n)}hasLOD(t){return t.lodMetric!==C.None}_getDistancePlanarMode(t,e){const i=t[0]-e[0],s=t[1]-e[1],r=t[2]-e[2],n=i*i+s*s,a=e[3];if(n<=a*a)return Math.abs(r);const o=Math.sqrt(n)-a;return Math.sqrt(r*r+o*o)}_getDistanceGlobeMode(t,e){const m=r(e),p=r(t)-m;n(this._tmp0,t,a(t,e)/o(t));const u=i(e,this._tmp0),_=e[3];if(u<=_*_)return Math.abs(p);{const i=n(this._tmp0,e,1/m),o=m,u=_*_/2/o,l=n(this._tmp1,i,o-u),d=t,b=h(this._tmp2,d,l),g=h(this._tmp2,b,n(this._tmp3,i,a(i,b))),f=c(this._tmp2,l,n(this._tmp2,g,_/r(g)));let v=s(d,f);if(p>=2e5){const t=h(this._tmp1,d,f);let e=a(t,i)/r(t);e<.08&&(e=1e-4),v/=e}return v}}_getDistance(t,e){return this.engineSR===_(this.engineSR)?this._getDistanceGlobeMode(t,e):this._getDistancePlanarMode(t,e)}_updateMinMaxDistance(t){t>0?(this.minDistance=Math.min(this.minDistance,t),this.maxDistance=Math.max(this.maxDistance,t)):(this.minDistance=0,this.maxDistance=Math.max(this.maxDistance,-t))}getLodLevel(t){if(t.lodMetric===C.None)return 0;if(0===t.childCount)return this.maxLodLevel;if(this._useFrustumCulling&&this._progressiveLoadFactor<1){const e=this._progressiveLoadFactor*this._screenspaceErrorBias,i=this._screenspaceErrorBias;return this.evaluateLODmetric(t,e)?this.evaluateLODmetric(t,i)?2:1:0}return this.evaluateLODmetric(t,this._screenspaceErrorBias)?this.maxLodLevel:0}evaluateLODmetric(t,e){switch(t.lodMetric){case C.ScreenSpaceRelative:{const i=this.getRenderMbs(t),s=this._getDistance(this._camPos,i),r=2*s/this._screenSizeFactor,n=s+i[3];return this._updateMinMaxDistance(n),t.maxError*e<=r}case C.MaxScreenThreshold:{let i=this._screenSpaceDiameterMbs(t,t.mbs[3]*e);return this._options.angleDependentLoD&&(i*=this.calcAngleDependentLoD(t)),i<t.maxError}case C.RemovedFeatureDiameter:return this._screenSpaceDiameterMbs(t,t.maxError)*e<10;case C.DistanceRangeFromDefaultCamera:return this.calcCameraDistance(t)>t.maxError*e}return!1}distToPOI(t){const e=this.getRenderMbs(t);return s(e,this._poi)-e[3]}distCameraToPOI(){return s(this._camPos,this._poi)}}export{j 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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e,isNone as i,unwrap as t,disposeMaybe as s}from"../../../../core/maybe.js";import r from"../../../../core/PooledArray.js";import{f as n,m as o}from"../../../../chunks/mat4.js";import{c as h}from"../../../../chunks/mat4f32.js";import{f as a,l,a as c,o as d,d as u,p as m,s as p}from"../../../../chunks/vec3.js";import{c as g}from"../../../../chunks/vec3f32.js";import{c as f}from"../../../../chunks/vec3f64.js";import{s as _}from"../../../../chunks/vec4.js";import{create as S,POSITIVE_INFINITY as x,offset as b,contains as z,containsPoint as P,equals as w,set as R}from"../../../../geometry/support/aaBoundingBox.js";import{create as A}from"../../../../geometry/support/plane.js";import{fromPoints as M}from"../../../../geometry/support/ray.js";import{PointHighlights as j}from"./PointHighlights.js";import{minimumDistancePlane as y,maximumDistancePlane as H,intersectLine as v,toAaBoundingBox as q}from"../../support/orientedBoundingBox.js";import{ShaderOutput as I}from"../../webgl-engine/core/shaderLibrary/ShaderOutputOptions.js";import{bindSliceUniforms as T}from"../../webgl-engine/core/shaderLibrary/Slice.glsl.js";import{bindOutputHighlight as L}from"../../webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{Default3D as E}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as F}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as V,StoreResults as U}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{RenderPass as O}from"../../webgl-engine/lib/RenderPass.js";import{VertexAttribute as N}from"../../webgl-engine/lib/VertexAttribute.js";import{PointRendererTechniqueConfiguration as C,PointRendererTechnique as D}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{BufferObject as B}from"../../../webgl/BufferObject.js";import{DataType as W,PrimitiveType as G,Usage as k}from"../../../webgl/enums.js";import{VertexArrayObject as Y}from"../../../webgl/VertexArrayObject.js";import{VertexElementDescriptor as J}from"../../../webgl/VertexElementDescriptor.js";const K={positions:[new J(N.POSITION,3,W.FLOAT,0,12)],colors:[new J(N.COLOR,3,W.UNSIGNED_BYTE,0,3,!0)]};class Q{constructor(e){this._params=e,this.type=V.PCL,this.isGround=!1,this._bindParameters={inverseViewport:[0,0],highlightDepthTexture:null},this._highlights=new j({forEachNode:e=>this.forEachNode(e),addHighlight:(e,i,t)=>this._addHighlight(e,i,t),removeHighlight:(e,i)=>this._removeHighlight(e,i)}),this.canRender=!0,this.layerUid="",this._useFixedSizes=!1,this._scaleFactor=1,this._minSizePx=0,this._useRealWorldSymbolSizes=!1,this._size=0,this._sizePx=0,this._slicePlaneEnabled=!1,this._clipBox=S(x),this._techniqueConfig=new C,this.tempMatrix4=h(),this.tempVec3=g(),this.nodes=new r}get needsHighlight(){return this._highlights.hasHighlights}initializeRenderContext(e){this._context=e,this._techniqueRep=this._context.shaderTechniqueRep,e.requestRender()}uninitializeRenderContext(){}intersect(e,i,t,s){const r=f(),n=f(),o=f(),h=f(),p=A(),g=e.camera.perScreenPixelRatio/2,x=e.camera.near,w=this._getSizeParams();a(n,s,t);const R=1/l(n);c(n,n,R),d(o,n),_(p,n[0],n[1],n[2],-u(n,t));const j=new ne,I=new ne,T=new Array,L=S(),E=S(this._clipBox);b(E,-t[0],-t[1],-t[2],E),this.nodes.forAll((l=>{const c=l.splatSize*this._scaleFactor;let d=y(l.obb,p),f=H(l.obb,p);d-=ee(c,d+x,w,g,l.isLeaf),f-=ee(c,f+x,w,g,l.isLeaf);const _=f<0,S=null!=j.dist&&null!=I.dist&&j.dist<d*R&&I.dist>f*R;if(_||S)return;const A=$(c,f+x,w,g,l.isLeaf);if(!v(l.obb,t,n,A))return;const M=A*A;q(l.obb,L),b(L,-t[0],-t[1],-t[2],L);const F=!z(E,L);a(h,l.origin,t);const V=l.coordinates.length/3;for(let a=0;a<V;a++){if(r[0]=h[0]+l.coordinates[3*a],r[1]=h[1]+l.coordinates[3*a+1],r[2]=h[2]+l.coordinates[3*a+2],F&&!P(E,r))continue;const d=u(r,n),p=m(r)-d*d;if(p>M)continue;let f=d+x;const _=ee(c,f,w,g,l.isLeaf);if(d-_<0)continue;f-=_;const S=$(c,f,w,g,l.isLeaf);if(p>S*S)continue;const b=(d-_)*R,z=e=>(e.point=ie(l,a,e.point),e.dist=b,e.normal=o,e.node=l,e.pointId=a,e.layerUid=this.layerUid,e);if((null==j.dist||b<j.dist)&&(null==i||i(t,s,b))&&z(j),e.options.store!==U.MIN&&(null==I.dist||b>I.dist)&&(null==i||i(t,s,b))&&z(I),e.options.store===U.ALL&&(null==i||i(t,s,b))){const e=new ne;T.push(z(e))}}}));const V=e=>{const{layerUid:i,node:t,pointId:s}=e;return{point:e.point,layerUid:i,graphicUid:s,createGraphic:()=>this._params.createGraphic(t,s,e.point)}},O=(e,i)=>{const t=V(i);e.set(this.type,t,i.dist,i.normal)};if(oe(j)){const i=e.results.min;(null==i.dist||j.dist<i.dist)&&O(i,j)}if(oe(I)&&e.options.store!==U.MIN){const i=e.results.max;(null==i.dist||I.dist>i.dist)&&O(i,I)}if(e.options.store===U.ALL){const i=M(t,s);for(const t of T){const s=F(i);O(s,t),e.results.all.push(s)}}}prepareTechnique(e){if(0===this.nodes.length||e.pass!==O.MATERIAL&&e.pass!==O.MATERIAL_DEPTH&&e.pass!==O.MATERIAL_HIGHLIGHT)return null;this.nodes.forAll((i=>{null==i.vao&&this._initNode(e,i)}));const i=this._getSizeParams();return this._techniqueConfig.drawScreenSize=i.drawScreenSpace,this._techniqueConfig.slicePlaneEnabled=this._slicePlaneEnabled,this._techniqueConfig.sceneHasOcludees=e.hasOccludees,this._techniqueConfig.output=e.pass===O.MATERIAL_DEPTH?I.Depth:e.pass===O.MATERIAL_HIGHLIGHT?I.Highlight:I.Color,this._techniqueRep.releaseAndAcquire(D,this._techniqueConfig,this._technique)}render(e,i){const t=e.rctx,s=this._getSizeParams(),r=i.program;t.useProgram(r),i.bindPipelineState(t);const h=this._clipBox,a=!w(h,x,((e,i)=>e===i));a||(p(this.tempVec3,-1/0,-1/0,-1/0),r.setUniform3fv("clipMin",this.tempVec3),p(this.tempVec3,1/0,1/0,1/0),r.setUniform3fv("clipMax",this.tempVec3)),r.setUniformMatrix4fv("proj",e.camera.projectionMatrix);e.pass===O.MATERIAL_DEPTH&&r.setUniform2fv("nearFar",e.camera.nearFar),e.isHighlightPass&&(this._bindParameters.inverseViewport[0]=1/e.camera.fullViewport[2],this._bindParameters.inverseViewport[1]=1/e.camera.fullViewport[3],this._bindParameters.highlightDepthTexture=e.highlightDepthTexture,L(r,this._bindParameters));const l=e.camera.pixelRatio;s.drawFixedSize&&r.setUniform2f("pointScale",s.fixedSize*l,e.camera.fullHeight);const c=this._slicePlaneEnabled?e.sliceHelper&&e.sliceHelper.plane:null;this.nodes.forAll((d=>{if(0===d.coordinates.length||e.isHighlightPass&&!d.highlights)return;if(r.setUniform2f("screenMinMaxSize",s.screenMinSize*l,Z(d.isLeaf)*l),!s.drawFixedSize){const i=d.splatSize*this._scaleFactor;r.setUniform2f("pointScale",i*l,e.camera.fullHeight/l)}const u=d.origin;a&&(p(this.tempVec3,h[0]-u[0],h[1]-u[1],h[2]-u[2]),r.setUniform3fv("clipMin",this.tempVec3),p(this.tempVec3,h[3]-u[0],h[4]-u[1],h[5]-u[2]),r.setUniform3fv("clipMax",this.tempVec3)),n(this.tempMatrix4,u),o(this.tempMatrix4,e.camera.viewMatrix,this.tempMatrix4),r.setUniformMatrix4fv("modelView",this.tempMatrix4),T(r,i.configuration,c,u),t.bindVAO(d.vao),e.isHighlightPass?this._renderHighlightFragments(t,d):t.drawArrays(G.POINTS,0,d.coordinates.length/3)}))}_renderHighlightFragments(e,s){const r=s.highlights;if(i(r))return;let n=t(r[0].component),o=n+1;for(let i=1;i<r.length;i++){const s=t(r[i].component);if(s!==o){const i=o-n;i>0&&e.drawArrays(G.POINTS,n,i),n=s}o=s+1}const h=o-n;h>0&&e.drawArrays(G.POINTS,n,h)}set useFixedSizes(e){this._useFixedSizes!==e&&(this._useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._useFixedSizes}set scaleFactor(e){this._scaleFactor!==e&&(this._scaleFactor=e,this._requestRender())}get scaleFactor(){return this._scaleFactor}set minSizePx(e){this._minSizePx!==e&&(this._minSizePx=e,this._requestRender())}get minSizePx(){return this._minSizePx}set useRealWorldSymbolSizes(e){this._useRealWorldSymbolSizes!==e&&(this._useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._useRealWorldSymbolSizes}set size(e){this._size!==e&&(this._size=e,this._requestRender())}get size(){return this._size}set sizePx(e){this._sizePx!==e&&(this._sizePx=e,this._requestRender())}get sizePx(){return this._sizePx}set clippingBox(e){R(this._clipBox,e||x)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this.nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let i=null;return this.nodes.filterInPlace((t=>t.id!==e||(i=t,t.vao=s(t.vao),this._highlights.nodeRemoved(t),!1))),this._requestRender(),i}forEachNode(e){this.nodes.forAll(e)}removeAll(){this.nodes.forAll((e=>e.vao=s(e.vao))),this._highlights.removeAll(),this.nodes.clear(),this._requestRender()}highlight(e){return this._highlights.add(e)}_addHighlight(e,i,t){e.highlights=se(e.highlights,i,t),this._requestRender()}_removeHighlight(e,i){e.highlights=re(e.highlights,i),this._requestRender()}_initNode(e,i){const t=e.rctx;i.vao=new Y(t,E,K,{positions:B.createVertex(t,k.STATIC_DRAW,i.coordinates),colors:B.createVertex(t,k.STATIC_DRAW,i.rgb)})}_requestRender(){this._context&&this._context.requestRender()}_getSizeParams(){const e=this._useFixedSizes,i=e&&!this._useRealWorldSymbolSizes;return{drawScreenSpace:i,drawFixedSize:e,fixedSize:i?this._sizePx:this._size,screenMinSize:e?0:this._minSizePx}}}function X(e){return e.hasOwnProperty("splatSize")}function Z(e){return e?256:64}function $(e,i,t,s,r){if(t.drawScreenSpace)return t.fixedSize*i*s;const n=Z(r)*i*s;return t.drawFixedSize?Math.min(t.fixedSize/2,n):t.screenMinSize>0?Math.min(Math.max(t.screenMinSize*i*s,e/2),n):Math.min(e/2,n)}function ee(e,i,t,s,r){return t.drawScreenSpace?0:$(e,i,t,s,r)}function ie(e,t,s){return i(s)&&(s=f()),s[0]=e.origin[0]+e.coordinates[3*t],s[1]=e.origin[1]+e.coordinates[3*t+1],s[2]=e.origin[2]+e.coordinates[3*t+2],s}function te(i){return e(i.component)?i.component:-1}function se(e,t,s){i(e)&&(e=[]);const r={component:t,id:s};e.push(r);const n=te(r);let o=e.length-1;for(;o>0&&n<te(e[o-1]);)[e[o-1],e[o]]=[e[o],e[o-1]],--o;return e}function re(e,t){if(i(e))return e;const s=e.filter((e=>e.id!==t));return 0===s.length?null:s}class ne{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerUid=""}}function oe(i){return e(i.dist)&&e(i.point)&&e(i.pointId)&&e(i.node)}export{Q as PointRenderer,X as isInstanceOfNode};
|
|
5
|
+
import{isSome as e,isNone as i,unwrap as t,disposeMaybe as s}from"../../../../core/maybe.js";import r from"../../../../core/PooledArray.js";import{f as n,m as o}from"../../../../chunks/mat4.js";import{c as h}from"../../../../chunks/mat4f32.js";import{f as a,l,a as c,o as d,d as u,p as m,s as p}from"../../../../chunks/vec3.js";import{c as g}from"../../../../chunks/vec3f32.js";import{c as f}from"../../../../chunks/vec3f64.js";import{s as _}from"../../../../chunks/vec4.js";import{create as x,POSITIVE_INFINITY as S,offset as z,contains as b,containsPoint as P,equals as w,set as R}from"../../../../geometry/support/aaBoundingBox.js";import{create as A}from"../../../../geometry/support/plane.js";import{fromPoints as M}from"../../../../geometry/support/ray.js";import{PointHighlights as j}from"./PointHighlights.js";import{minimumDistancePlane as y,maximumDistancePlane as H,intersectLine as q,toAaBoundingBox as v}from"../../support/orientedBoundingBox.js";import{ShaderOutput as I}from"../../webgl-engine/core/shaderLibrary/ShaderOutputOptions.js";import{bindSliceUniforms as T}from"../../webgl-engine/core/shaderLibrary/Slice.glsl.js";import{bindOutputHighlight as L}from"../../webgl-engine/core/shaderLibrary/output/OutputHighlight.glsl.js";import{Default3D as E}from"../../webgl-engine/lib/DefaultVertexAttributeLocations.js";import{newIntersectorResult as F}from"../../webgl-engine/lib/Intersector.js";import{IntersectorType as V,StoreResults as U}from"../../webgl-engine/lib/IntersectorInterfaces.js";import{RenderPass as O}from"../../webgl-engine/lib/RenderPass.js";import{VertexAttribute as N}from"../../webgl-engine/lib/VertexAttribute.js";import{PointRendererTechniqueConfiguration as C,PointRendererTechnique as D}from"../../webgl-engine/shaders/PointRendererTechnique.js";import{BufferObject as B}from"../../../webgl/BufferObject.js";import{DataType as W,PrimitiveType as G,Usage as k}from"../../../webgl/enums.js";import{VertexArrayObject as Y}from"../../../webgl/VertexArrayObject.js";import{VertexElementDescriptor as J}from"../../../webgl/VertexElementDescriptor.js";const K={positions:[new J(N.POSITION,3,W.FLOAT,0,12)],colors:[new J(N.COLOR,3,W.UNSIGNED_BYTE,0,3,!0)]};class Q{constructor(e){this._params=e,this.type=V.PCL,this.isGround=!1,this._bindParameters={inverseViewport:[0,0],highlightDepthTexture:null},this._highlights=new j({forEachNode:e=>this.forEachNode(e),addHighlight:(e,i,t)=>this._addHighlight(e,i,t),removeHighlight:(e,i)=>this._removeHighlight(e,i)}),this.canRender=!0,this.layerUid="",this._useFixedSizes=!1,this._scaleFactor=1,this._minSizePx=0,this._useRealWorldSymbolSizes=!1,this._size=0,this._sizePx=0,this._slicePlaneEnabled=!1,this._clipBox=x(S),this._techniqueConfig=new C,this.tempMatrix4=h(),this.tempVec3=g(),this.nodes=new r}get needsHighlight(){return this._highlights.hasHighlights}initializeRenderContext(e){this._context=e,this._techniqueRep=this._context.shaderTechniqueRep,e.requestRender()}uninitializeRenderContext(){}intersect(e,i,t,s){const r=f(),n=f(),o=f(),h=f(),p=A(),g=e.camera.perScreenPixelRatio/2,S=e.camera.near,w=this._getSizeParams();a(n,s,t);const R=1/l(n);c(n,n,R),d(o,n),_(p,n[0],n[1],n[2],-u(n,t));const j=new ne,I=new ne,T=new Array,L=x(),E=x(this._clipBox);z(E,-t[0],-t[1],-t[2],E),this.nodes.forAll((l=>{const c=l.splatSize*this._scaleFactor;let d=y(l.obb,p),f=H(l.obb,p);d-=ee(c,d+S,w,g,l.isLeaf),f-=ee(c,f+S,w,g,l.isLeaf);const _=f<0,x=null!=j.dist&&null!=I.dist&&j.dist<d*R&&I.dist>f*R;if(_||x)return;const A=$(c,f+S,w,g,l.isLeaf);if(!q(l.obb,t,n,A))return;const M=A*A;v(l.obb,L),z(L,-t[0],-t[1],-t[2],L);const F=!b(E,L);a(h,l.origin,t);const V=l.coordinates.length/3;for(let a=0;a<V;a++){if(r[0]=h[0]+l.coordinates[3*a],r[1]=h[1]+l.coordinates[3*a+1],r[2]=h[2]+l.coordinates[3*a+2],F&&!P(E,r))continue;const d=u(r,n),p=m(r)-d*d;if(p>M)continue;let f=d+S;const _=ee(c,f,w,g,l.isLeaf);if(d-_<0)continue;f-=_;const x=$(c,f,w,g,l.isLeaf);if(p>x*x)continue;const z=(d-_)*R,b=e=>(e.point=ie(l,a,e.point),e.dist=z,e.normal=o,e.node=l,e.pointId=a,e.layerUid=this.layerUid,e);if((null==j.dist||z<j.dist)&&(null==i||i(t,s,z))&&b(j),e.options.store!==U.MIN&&(null==I.dist||z>I.dist)&&(null==i||i(t,s,z))&&b(I),e.options.store===U.ALL&&(null==i||i(t,s,z))){const e=new ne;T.push(b(e))}}}));const V=e=>{const{layerUid:i,node:t,pointId:s}=e;return{point:e.point,layerUid:i,graphicUid:s,createGraphic:()=>this._params.createGraphic(t,s,e.point)}},O=(e,i)=>{const t=V(i);e.set(this.type,t,i.dist,i.normal)};if(oe(j)){const i=e.results.min;(null==i.dist||j.dist<i.dist)&&O(i,j)}if(oe(I)&&e.options.store!==U.MIN){const i=e.results.max;(null==i.dist||I.dist>i.dist)&&O(i,I)}if(e.options.store===U.ALL){const i=M(t,s);for(const t of T){const s=F(i);O(s,t),e.results.all.push(s)}}}prepareTechnique(e){if(0===this.nodes.length||e.pass!==O.MATERIAL&&e.pass!==O.MATERIAL_DEPTH&&e.pass!==O.MATERIAL_HIGHLIGHT)return null;this.nodes.forAll((i=>{null==i.vao&&this._initNode(e,i)}));const i=this._getSizeParams();return this._techniqueConfig.drawScreenSize=i.drawScreenSpace,this._techniqueConfig.slicePlaneEnabled=this._slicePlaneEnabled,this._techniqueConfig.sceneHasOcludees=e.hasOccludees,this._techniqueConfig.output=e.pass===O.MATERIAL_DEPTH?I.Depth:e.pass===O.MATERIAL_HIGHLIGHT?I.Highlight:I.Color,this._techniqueRep.releaseAndAcquire(D,this._techniqueConfig,this._technique)}render(e,i){const t=e.rctx,s=t.useTechnique(i),r=this._clipBox,h=!w(r,S,((e,i)=>e===i));h||(p(this.tempVec3,-1/0,-1/0,-1/0),s.setUniform3fv("clipMin",this.tempVec3),p(this.tempVec3,1/0,1/0,1/0),s.setUniform3fv("clipMax",this.tempVec3)),s.setUniformMatrix4fv("proj",e.camera.projectionMatrix);e.pass===O.MATERIAL_DEPTH&&s.setUniform2fv("nearFar",e.camera.nearFar),e.isHighlightPass&&(this._bindParameters.inverseViewport[0]=1/e.camera.fullViewport[2],this._bindParameters.inverseViewport[1]=1/e.camera.fullViewport[3],this._bindParameters.highlightDepthTexture=e.highlightDepthTexture,L(s,this._bindParameters));const a=this._getSizeParams(),l=e.camera.pixelRatio;a.drawFixedSize&&s.setUniform2f("pointScale",a.fixedSize*l,e.camera.fullHeight);const c=this._slicePlaneEnabled?e.sliceHelper&&e.sliceHelper.plane:null;this.nodes.forAll((d=>{if(0===d.coordinates.length||e.isHighlightPass&&!d.highlights)return;if(s.setUniform2f("screenMinMaxSize",a.screenMinSize*l,Z(d.isLeaf)*l),!a.drawFixedSize){const i=d.splatSize*this._scaleFactor;s.setUniform2f("pointScale",i*l,e.camera.fullHeight/l)}const u=d.origin;h&&(p(this.tempVec3,r[0]-u[0],r[1]-u[1],r[2]-u[2]),s.setUniform3fv("clipMin",this.tempVec3),p(this.tempVec3,r[3]-u[0],r[4]-u[1],r[5]-u[2]),s.setUniform3fv("clipMax",this.tempVec3)),n(this.tempMatrix4,u),o(this.tempMatrix4,e.camera.viewMatrix,this.tempMatrix4),s.setUniformMatrix4fv("modelView",this.tempMatrix4),T(s,i.configuration,c,u),t.bindVAO(d.vao),e.isHighlightPass?this._renderHighlightFragments(t,d):t.drawArrays(G.POINTS,0,d.coordinates.length/3)}))}_renderHighlightFragments(e,s){const r=s.highlights;if(i(r))return;let n=t(r[0].component),o=n+1;for(let i=1;i<r.length;i++){const s=t(r[i].component);if(s!==o){const i=o-n;i>0&&e.drawArrays(G.POINTS,n,i),n=s}o=s+1}const h=o-n;h>0&&e.drawArrays(G.POINTS,n,h)}set useFixedSizes(e){this._useFixedSizes!==e&&(this._useFixedSizes=e,this._requestRender())}get useFixedSizes(){return this._useFixedSizes}set scaleFactor(e){this._scaleFactor!==e&&(this._scaleFactor=e,this._requestRender())}get scaleFactor(){return this._scaleFactor}set minSizePx(e){this._minSizePx!==e&&(this._minSizePx=e,this._requestRender())}get minSizePx(){return this._minSizePx}set useRealWorldSymbolSizes(e){this._useRealWorldSymbolSizes!==e&&(this._useRealWorldSymbolSizes=e,this._requestRender())}get useRealWorldSymbolSizes(){return this._useRealWorldSymbolSizes}set size(e){this._size!==e&&(this._size=e,this._requestRender())}get size(){return this._size}set sizePx(e){this._sizePx!==e&&(this._sizePx=e,this._requestRender())}get sizePx(){return this._sizePx}set clippingBox(e){R(this._clipBox,e||S)}get slicePlaneEnabled(){return this._slicePlaneEnabled}set slicePlaneEnabled(e){this._slicePlaneEnabled!==e&&(this._slicePlaneEnabled=e,this._requestRender())}addNode(e){this.nodes.push(e),this._highlights.nodeAdded(e),this._requestRender()}removeNode(e){let i=null;return this.nodes.filterInPlace((t=>t.id!==e||(i=t,t.vao=s(t.vao),this._highlights.nodeRemoved(t),!1))),this._requestRender(),i}forEachNode(e){this.nodes.forAll(e)}removeAll(){this.nodes.forAll((e=>e.vao=s(e.vao))),this._highlights.removeAll(),this.nodes.clear(),this._requestRender()}highlight(e){return this._highlights.add(e)}_addHighlight(e,i,t){e.highlights=se(e.highlights,i,t),this._requestRender()}_removeHighlight(e,i){e.highlights=re(e.highlights,i),this._requestRender()}_initNode(e,i){const t=e.rctx;i.vao=new Y(t,E,K,{positions:B.createVertex(t,k.STATIC_DRAW,i.coordinates),colors:B.createVertex(t,k.STATIC_DRAW,i.rgb)})}_requestRender(){this._context&&this._context.requestRender()}_getSizeParams(){const e=this._useFixedSizes,i=e&&!this._useRealWorldSymbolSizes;return{drawScreenSpace:i,drawFixedSize:e,fixedSize:i?this._sizePx:this._size,screenMinSize:e?0:this._minSizePx}}}function X(e){return e.hasOwnProperty("splatSize")}function Z(e){return e?256:64}function $(e,i,t,s,r){if(t.drawScreenSpace)return t.fixedSize*i*s;const n=Z(r)*i*s;return t.drawFixedSize?Math.min(t.fixedSize/2,n):t.screenMinSize>0?Math.min(Math.max(t.screenMinSize*i*s,e/2),n):Math.min(e/2,n)}function ee(e,i,t,s,r){return t.drawScreenSpace?0:$(e,i,t,s,r)}function ie(e,t,s){return i(s)&&(s=f()),s[0]=e.origin[0]+e.coordinates[3*t],s[1]=e.origin[1]+e.coordinates[3*t+1],s[2]=e.origin[2]+e.coordinates[3*t+2],s}function te(i){return e(i.component)?i.component:-1}function se(e,t,s){i(e)&&(e=[]);const r={component:t,id:s};e.push(r);const n=te(r);let o=e.length-1;for(;o>0&&n<te(e[o-1]);)[e[o-1],e[o]]=[e[o],e[o-1]],--o;return e}function re(e,t){if(i(e))return e;const s=e.filter((e=>e.id!==t));return 0===s.length?null:s}class ne{constructor(){this.node=null,this.pointId=null,this.point=null,this.dist=null,this.normal=null,this.layerUid=""}}function oe(i){return e(i.dist)&&e(i.point)&&e(i.pointId)&&e(i.node)}export{Q as PointRenderer,X as isInstanceOfNode};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../chunks/tslib.es6.js";import{HandleOwner as
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import{HandleOwner as r}from"../../../../core/HandleOwner.js";import{makeHandle as t}from"../../../../core/handleUtils.js";import{disposeMaybe as i,unwrap as o,applySome as s}from"../../../../core/maybe.js";import{property as a}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/arrayUtils.js";import"../../../../core/has.js";import"../../../../core/accessorSupport/ensureType.js";import{subclass as n}from"../../../../core/accessorSupport/decorators/subclass.js";import{c as l}from"../../../../chunks/vec3f64.js";import{projectPointToVector as p}from"../../../../geometry/projection.js";import{convertFromPoint as m}from"../../../../layers/graphics/featureConversionUtils.js";import u from"../../../../layers/graphics/OptimizedFeature.js";import d from"../../../../layers/graphics/OptimizedGeometry.js";import y from"../../../../layers/graphics/data/FeatureStore.js";import{DRAPED_Z as h}from"../../terrain/OverlayRenderer.js";import{UpdatePolicy as c,PrimitiveType as g}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as f}from"../../webgl-engine/lib/Geometry.js";import{ModelDirty as _}from"../../webgl-engine/lib/ModelDirtyTypes.js";import{RenderGeometry as v}from"../../webgl-engine/lib/RenderGeometry.js";import{VertexAttribute as b}from"../../webgl-engine/lib/VertexAttribute.js";import{HeatmapDensityMaterial as w}from"../../webgl-engine/materials/HeatmapDensityMaterial.js";let j=class extends r{constructor(e){super(e),this.type="heatmap",this.filterVisibility={filterChanged(){},dirty:!1},this.preferredUpdatePolicy=c.ASYNC,this.dataExtent=null,this._renderGeometries=new Map,this._material=new w({})}initialize(){this._featureStore=new y({geometryType:"esriGeometryPoint",hasZ:this.hasZ,hasM:this.hasM}),this.updatingHandles.addOnCollectionChange((()=>this._loadedPointGraphics),(e=>this._onLoadedFeaturesChange(e)))}destroy(){this._overlayRenderer.removeGeometries(Array.from(this._renderGeometries.values()),this.owner,_.Geometry.REMOVE),this._renderGeometries.clear(),this._material=i(this._material),this._featureStore.clear(),this._featureStore=null}get layer(){return this.owner.layer}get featureStore(){return this._featureStore}get updating(){return this.updatingHandles.updating}get updatingRemaining(){return 0}get suspendInfo(){return{}}get legendEnabled(){return!0}get displayFeatureLimit(){return{minimumTotalNumberOfFeatures:0,maximumTotalNumberOfFeatures:1e10,maximumTotalNumberOfPrimitives:1e10,maximumNumberOfFeatures:1e10}}get hasZ(){return"hasZ"in this.layer&&this.layer.hasZ}get hasM(){return"hasM"in this.layer&&this.layer.hasM}get scaleVisibilitySuspended(){return!1}get usedMemory(){return 0}get usedMemoryPerFeature(){return 0}get unprocessedMemoryEstimate(){return 0}get performanceInfo(){return{core:{visible:0,missing:0,pending:0},elevationUpdating:!1,visibilityFrustum:!0,visibilityScale:!0}}get _overlayRenderer(){return this.owner.view.basemapTerrain.overlayManager.renderer}get _overlaySpatialReference(){return o(this._overlayRenderer.spatialReference)}get _renderView(){return this.owner.view._stage.renderView}get _featuresArePoints(){return"point"===this.layer.geometryType}get _loadedPointGraphics(){return this.owner.loadedGraphics}async whenGraphicBounds(){return null}computeAttachmentOrigin(){return null}highlight(){return G}maskOccludee(){return G}setObjectIdVisibility(){}async setup(){}_onLoadedFeaturesChange(e){if(!this._featuresArePoints)return;this._featureStore.addMany(e.added.map((e=>new u(m(new d,e.geometry),e.attributes,s(e.centroid,(e=>m(new d,e))),e.objectId)))),this._featureStore.removeManyById(e.removed.map((({objectId:e})=>e)));const r=e.added,t=e.removed.map((({uid:e})=>{const r=this._renderGeometries.get(e);return this._renderGeometries.delete(e),r})),i=r.map((e=>{const r=this._pointGraphicToRenderGeometry(e);return this._renderGeometries.set(e.uid,r),r}));i.length>0&&this._overlayRenderer.addGeometries(i,this.owner,_.Geometry.ADD,!0),t.length>0&&this._overlayRenderer.removeGeometries(t,this.owner,_.Geometry.REMOVE),(i.length>0||t.length>0)&&this._renderView.requestRender()}_pointGraphicToRenderGeometry(e){const r=this._material,t=l();p(e.geometry,t,this._overlaySpatialReference,h);return new v(new f([[b.POSITION,{data:t,size:t.length}]],null,g.Point),r,{layerUid:this.layer.uid,graphicUid:e.uid})}};e([a()],j.prototype,"type",void 0),e([a({constructOnly:!0})],j.prototype,"owner",void 0),e([a()],j.prototype,"layer",null),e([a()],j.prototype,"featureStore",null),e([a()],j.prototype,"updating",null),e([a()],j.prototype,"updatingRemaining",null),e([a()],j.prototype,"suspendInfo",null),e([a()],j.prototype,"legendEnabled",null),e([a()],j.prototype,"filterVisibility",void 0),e([a()],j.prototype,"displayFeatureLimit",null),e([a()],j.prototype,"preferredUpdatePolicy",void 0),e([a()],j.prototype,"hasZ",null),e([a()],j.prototype,"hasM",null),e([a()],j.prototype,"dataExtent",void 0),e([a()],j.prototype,"_featureStore",void 0),e([a()],j.prototype,"_overlayRenderer",null),e([a()],j.prototype,"_overlaySpatialReference",null),e([a()],j.prototype,"_renderGeometries",void 0),e([a()],j.prototype,"_material",void 0),e([a()],j.prototype,"_renderView",null),e([a()],j.prototype,"_featuresArePoints",null),e([a()],j.prototype,"_loadedPointGraphics",null),j=e([n("esri.views.3d.layers.support.HeatmapFeatureProcessor")],j);const G=t();export{j as HeatmapFeatureProcessor};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{deg2rad as e}from"../../../core/mathUtils.js";import{isSome as t,isNone as i,disposeMaybe as n,releaseMaybe as s}from"../../../core/maybe.js";import{a as r}from"../../../chunks/vec2f64.js";import{g as a,m as h,i as l,n as o,c,b as _}from"../../../chunks/vec3.js";import{c as d}from"../../../chunks/vec3f64.js";import{t as m}from"../../../chunks/vec4.js";import{c as p}from"../../../chunks/vec4f64.js";import{create as g,fromRay as f,getStart as u,getEnd as b}from"../../../geometry/support/clipRay.js";import{intersectClipRay as P}from"../../../geometry/support/frustum.js";import{create as V,copy as E,pointAt as L}from"../../../geometry/support/lineSegment.js";import{create as D,fromPositionAndNormal as S}from"../../../geometry/support/plane.js";import{wrap as q}from"../../../geometry/support/ray.js";import{c as R}from"../../../chunks/sphere.js";import{LaserlinePathData as U}from"./LaserlinePathData.js";import{createQuadVAO as T}from"../webgl-engine/lib/glUtil3D.js";import{RenderSlot as M}from"../webgl-engine/lib/RenderSlot.js";import{inverseProjectionInfo as x}from"../webgl-engine/lib/Util.js";import{copyParameters as C,updateParameters as v}from"../webgl-engine/materials/internal/MaterialUtil.js";import{LaserlinePathTechniqueConfiguration as A,LaserlinePathTechnique as j}from"../webgl-engine/shaders/LaserlinePathTechnique.js";import{LaserlineTechniqueConfiguration as w,LaserlineTechnique as I}from"../webgl-engine/shaders/LaserlineTechnique.js";import{PrimitiveType as O}from"../../webgl/enums.js";const y=d(),H=p(),z={glowColor:[1,.5,0],glowWidth:8,glowFalloff:8,innerColor:[1,1,1],innerWidth:1,globalAlpha:.75,angleCutoff:e(6),globalAlphaContrastBoost:2};function N(e,t,i,n){const s=y,r=H;h(s,t,n),a(r,i),r[3]=0,m(r,r,n),S(s,r,e)}class k{constructor(e,t={},i={contrastControlEnabled:!1}){this._renderCoordsHelper=e,this._config=i,this._technique=null,this._projInfo=p(),this._zScale=r(),this._heightManifoldEnabled=!1,this._heightManifoldTarget=d(),this._pointDistanceEnabled=!1,this._pointDistanceOrigin=d(),this._pointDistanceTarget=d(),this._lineVerticalPlaneEnabled=!1,this._lineVerticalPlaneSegment=V(),this._intersectsLineEnabled=!1,this._intersectsLineSegment=V(),this._intersectsLineRadius=3,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._pathVerticalPlaneData=null,this._pathTechnique=null,this.canRender=!0,this._tempNormal=d(),this._tempDir=d(),this._tempUp=d(),this._tempVec3A=d(),this._tempVec3B=d(),this._tempVec4=p(),this._tempPlane=D(),this._tempSphere=R(),this._params=C(t,z)}get renderSlots(){return[this._config.contrastControlEnabled?M.LASERLINES_CONTRAST_CONTROL:M.LASERLINES]}get needsLinearDepth(){return!0}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this._requestRender())}get heightManifoldTarget(){return this._heightManifoldTarget}set heightManifoldTarget(e){a(this._heightManifoldTarget,e),this._requestRender()}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this._requestRender())}get pointDistanceTarget(){return this._pointDistanceTarget}set pointDistanceTarget(e){a(this._pointDistanceTarget,e),this._requestRender()}get pointDistanceOrigin(){return this._pointDistanceOrigin}set pointDistanceOrigin(e){a(this._pointDistanceOrigin,e),this._requestRender()}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this._requestRender())}get lineVerticalPlaneSegment(){return this._lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){E(e,this._lineVerticalPlaneSegment),this._requestRender()}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this._requestRender())}get intersectsLineSegment(){return this._intersectsLineSegment}set intersectsLineSegment(e){E(e,this._intersectsLineSegment),this._requestRender()}get intersectsLineRadius(){return this._intersectsLineRadius}set intersectsLineRadius(e){e!==this._intersectsLineRadius&&(this._intersectsLineRadius=e,this._requestRender())}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this._requestRender())}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,t(this._pathVerticalPlaneData)&&this._requestRender())}set pathVerticalPlaneVertices(e){i(this._pathVerticalPlaneData)&&(this._pathVerticalPlaneData=new U(this._renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this._requestRender()}set pathVerticalPlaneBuffers(e){i(this._pathVerticalPlaneData)&&(this._pathVerticalPlaneData=new U(this._renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this._requestRender()}setParameters(e){v(this._params,e)&&this._requestRender()}initializeRenderContext(e){this._context=e;const t=e.renderContext.rctx;this._quadVAO=T(t),this._techniqueRepository=e.shaderTechniqueRep,this._techniqueConfig=new w;const i=new A;i.contrastControlEnabled=this._config.contrastControlEnabled,this._pathTechnique=this._techniqueRepository.acquire(j,i)}uninitializeRenderContext(){this._quadVAO=n(this._quadVAO),this._technique=s(this._technique),this._pathVerticalPlaneData=n(this._pathVerticalPlaneData),this._pathTechnique=s(this._pathTechnique)}prepareTechnique(){return this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled?(this._techniqueConfig.heightManifoldEnabled=this.heightManifoldEnabled,this._techniqueConfig.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._techniqueConfig.pointDistanceEnabled=this.pointDistanceEnabled,this._techniqueConfig.intersectsLineEnabled=this.intersectsLineEnabled,this._techniqueConfig.contrastControlEnabled=this._config.contrastControlEnabled,this._technique=this._techniqueRepository.releaseAndAcquire(I,this._techniqueConfig,this._technique),this._technique):this._pathTechnique}render(e,t){const i=e.camera;x(i.projectionMatrix,i.fullWidth,i.fullHeight,this._projInfo,this._zScale),(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(e,t),this.pathVerticalPlaneEnabled&&this._renderPath(e)}_renderUnified(e,t){const i=e.rctx,n=t.program;i.useProgram(n),t.bindPipelineState(i),this._bindGlobalUniforms(e,n),this._bindHeightManifoldUniforms(e,n),this._bindPointDistanceUniforms(e,n),this._bindLineVerticalPlaneUniforms(e,n),this._bindIntersectsLineUniforms(e,n),t.bind(this._params,e.camera),i.bindVAO(this._quadVAO),i.drawArrays(O.TRIANGLE_STRIP,0,4)}_renderPath(e){if(i(this._pathVerticalPlaneData)||i(this._pathTechnique))return;const t=e.rctx,n=this._pathTechnique,s=n.program;t.useProgram(s),n.bindPipelineState(t),this._bindGlobalUniforms(e,s),n.bind(this._params,this._pathVerticalPlaneData.origin,e.camera),this._pathVerticalPlaneData.draw(e.rctx)}_bindHeightManifoldUniforms(e,t){if(!this.heightManifoldEnabled)return;const i=this._tempVec3A,n=this._tempPlane;this._renderCoordsHelper.worldUpAtPosition(this._heightManifoldTarget,i),N(n,this._heightManifoldTarget,i,e.camera.viewMatrix),t.setUniform4fv("heightPlane",n)}_bindPointDistanceUniforms(e,t){if(!this._pointDistanceEnabled)return;const i=e.camera,n=this._tempSphere;a(n,this._pointDistanceOrigin),h(n,n,i.viewMatrix),n[3]=l(this._pointDistanceOrigin,this._pointDistanceTarget),t.setUniform4f("pointDistanceSphere",n[0],n[1],n[2],n[3])}_bindLineVerticalPlaneUniforms(e,t){if(!this._lineVerticalPlaneEnabled)return;const i=this._renderCoordsHelper,n=e.camera,s=this._tempPlane,r=this._tempVec3A,l=this._tempUp,d=this._tempDir,m=this._tempNormal;L(this._lineVerticalPlaneSegment,.5,r),i.worldUpAtPosition(r,l),o(d,this._lineVerticalPlaneSegment.vector),c(m,l,d),o(m,m),N(s,this._lineVerticalPlaneSegment.origin,m,n.viewMatrix),t.setUniform4fv("lineVerticalPlane",s);const p=this._tempVec3A;a(p,this._lineVerticalPlaneSegment.origin),i.setAltitude(p,0),h(p,p,n.viewMatrix),t.setUniform3fv("lineVerticalStart",p);const g=this._tempVec3B;_(g,this._lineVerticalPlaneSegment.origin,this._lineVerticalPlaneSegment.vector),i.setAltitude(g,0),h(g,g,n.viewMatrix),t.setUniform3fv("lineVerticalEnd",g)}_bindIntersectsLineUniforms(e,t){if(!this._intersectsLineEnabled)return;const i=G,n=F;if(this._intersectsLineInfinite){const t=e.camera;if(f(q(this._intersectsLineSegment.origin,this._intersectsLineSegment.vector),B),B.c0=-Number.MAX_VALUE,!P(t.frustum,B))return;u(B,i),b(B,n)}else a(i,this._intersectsLineSegment.origin),_(n,this._intersectsLineSegment.origin,this._intersectsLineSegment.vector);const s=this._tempVec3A;h(s,i,e.camera.viewMatrix),t.setUniform3fv("intersectsLineStart",s);const r=this._tempVec4;a(r,this._intersectsLineSegment.vector),this._tempVec4[3]=0,m(this._tempVec4,this._tempVec4,e.camera.viewMatrix),h(n,n,e.camera.viewMatrix),t.setUniform3fv("intersectsLineEnd",n),o(r,r),t.setUniform3f("intersectsLineDirection",r[0],r[1],r[2]),t.setUniform1f("intersectsLineRadius",this._intersectsLineRadius)}_bindGlobalUniforms(e,t){const i=e.camera;t.setUniform4fv("projInfo",this._projInfo),t.setUniform2fv("zScale",this._zScale),t.setUniform2fv("nearFar",i.nearFar),this._heightManifoldEnabled?t.setUniform1f("maxPixelDistance",2*i.computeScreenPixelSizeAt(this._heightManifoldTarget)):this._pointDistanceEnabled?t.setUniform1f("maxPixelDistance",2*i.computeScreenPixelSizeAt(this._pointDistanceTarget)):this._lineVerticalPlaneEnabled&&t.setUniform1f("maxPixelDistance",2*i.computeScreenPixelSizeAt(this._lineVerticalPlaneSegment.origin)),t.bindTexture(e.offscreenRenderingHelper.linearDepthTexture,"depthMap"),t.bindTexture(e.offscreenRenderingHelper.mainColorTexture,"frameColor")}_requestRender(){this._context&&this._context.requestRender()}}const B=g(),G=d(),F=d();export{k as LaserLineRenderer};
|
|
5
|
+
import{deg2rad as e}from"../../../core/mathUtils.js";import{isSome as t,isNone as i,disposeMaybe as n,releaseMaybe as s}from"../../../core/maybe.js";import{a as r}from"../../../chunks/vec2f64.js";import{g as a,m as h,i as l,n as o,c,b as _}from"../../../chunks/vec3.js";import{c as d}from"../../../chunks/vec3f64.js";import{t as m}from"../../../chunks/vec4.js";import{c as p}from"../../../chunks/vec4f64.js";import{create as f,fromRay as g,getStart as u,getEnd as b}from"../../../geometry/support/clipRay.js";import{intersectClipRay as V}from"../../../geometry/support/frustum.js";import{create as P,copy as E,pointAt as L}from"../../../geometry/support/lineSegment.js";import{create as q,fromPositionAndNormal as D}from"../../../geometry/support/plane.js";import{wrap as S}from"../../../geometry/support/ray.js";import{c as R}from"../../../chunks/sphere.js";import{LaserlinePathData as T}from"./LaserlinePathData.js";import{createQuadVAO as U}from"../webgl-engine/lib/glUtil3D.js";import{RenderSlot as M}from"../webgl-engine/lib/RenderSlot.js";import{inverseProjectionInfo as x}from"../webgl-engine/lib/Util.js";import{copyParameters as C,updateParameters as v}from"../webgl-engine/materials/internal/MaterialUtil.js";import{LaserlinePathTechniqueConfiguration as A,LaserlinePathTechnique as j}from"../webgl-engine/shaders/LaserlinePathTechnique.js";import{LaserlineTechniqueConfiguration as w,LaserlineTechnique as I}from"../webgl-engine/shaders/LaserlineTechnique.js";import{PrimitiveType as O}from"../../webgl/enums.js";const y=d(),H=p(),z={glowColor:[1,.5,0],glowWidth:8,glowFalloff:8,innerColor:[1,1,1],innerWidth:1,globalAlpha:.75,angleCutoff:e(6),globalAlphaContrastBoost:2};function N(e,t,i,n){const s=y,r=H;h(s,t,n),a(r,i),r[3]=0,m(r,r,n),D(s,r,e)}class k{constructor(e,t={},i={contrastControlEnabled:!1}){this._renderCoordsHelper=e,this._config=i,this._technique=null,this._projInfo=p(),this._zScale=r(),this._heightManifoldEnabled=!1,this._heightManifoldTarget=d(),this._pointDistanceEnabled=!1,this._pointDistanceOrigin=d(),this._pointDistanceTarget=d(),this._lineVerticalPlaneEnabled=!1,this._lineVerticalPlaneSegment=P(),this._intersectsLineEnabled=!1,this._intersectsLineSegment=P(),this._intersectsLineRadius=3,this._intersectsLineInfinite=!1,this._pathVerticalPlaneEnabled=!1,this._pathVerticalPlaneData=null,this._pathTechnique=null,this.canRender=!0,this._tempNormal=d(),this._tempDir=d(),this._tempUp=d(),this._tempVec3A=d(),this._tempVec3B=d(),this._tempVec4=p(),this._tempPlane=q(),this._tempSphere=R(),this._params=C(t,z)}get renderSlots(){return[this._config.contrastControlEnabled?M.LASERLINES_CONTRAST_CONTROL:M.LASERLINES]}get needsLinearDepth(){return!0}get heightManifoldEnabled(){return this._heightManifoldEnabled}set heightManifoldEnabled(e){this._heightManifoldEnabled!==e&&(this._heightManifoldEnabled=e,this._requestRender())}get heightManifoldTarget(){return this._heightManifoldTarget}set heightManifoldTarget(e){a(this._heightManifoldTarget,e),this._requestRender()}get pointDistanceEnabled(){return this._pointDistanceEnabled}set pointDistanceEnabled(e){e!==this._pointDistanceEnabled&&(this._pointDistanceEnabled=e,this._requestRender())}get pointDistanceTarget(){return this._pointDistanceTarget}set pointDistanceTarget(e){a(this._pointDistanceTarget,e),this._requestRender()}get pointDistanceOrigin(){return this._pointDistanceOrigin}set pointDistanceOrigin(e){a(this._pointDistanceOrigin,e),this._requestRender()}get lineVerticalPlaneEnabled(){return this._lineVerticalPlaneEnabled}set lineVerticalPlaneEnabled(e){e!==this._lineVerticalPlaneEnabled&&(this._lineVerticalPlaneEnabled=e,this._requestRender())}get lineVerticalPlaneSegment(){return this._lineVerticalPlaneSegment}set lineVerticalPlaneSegment(e){E(e,this._lineVerticalPlaneSegment),this._requestRender()}get intersectsLineEnabled(){return this._intersectsLineEnabled}set intersectsLineEnabled(e){e!==this._intersectsLineEnabled&&(this._intersectsLineEnabled=e,this._requestRender())}get intersectsLineSegment(){return this._intersectsLineSegment}set intersectsLineSegment(e){E(e,this._intersectsLineSegment),this._requestRender()}get intersectsLineRadius(){return this._intersectsLineRadius}set intersectsLineRadius(e){e!==this._intersectsLineRadius&&(this._intersectsLineRadius=e,this._requestRender())}get intersectsLineInfinite(){return this._intersectsLineInfinite}set intersectsLineInfinite(e){e!==this._intersectsLineInfinite&&(this._intersectsLineInfinite=e,this._requestRender())}get pathVerticalPlaneEnabled(){return this._pathVerticalPlaneEnabled}set pathVerticalPlaneEnabled(e){e!==this._pathVerticalPlaneEnabled&&(this._pathVerticalPlaneEnabled=e,t(this._pathVerticalPlaneData)&&this._requestRender())}set pathVerticalPlaneVertices(e){i(this._pathVerticalPlaneData)&&(this._pathVerticalPlaneData=new T(this._renderCoordsHelper)),this._pathVerticalPlaneData.vertices=e,this.pathVerticalPlaneEnabled&&this._requestRender()}set pathVerticalPlaneBuffers(e){i(this._pathVerticalPlaneData)&&(this._pathVerticalPlaneData=new T(this._renderCoordsHelper)),this._pathVerticalPlaneData.buffers=e,this.pathVerticalPlaneEnabled&&this._requestRender()}setParameters(e){v(this._params,e)&&this._requestRender()}initializeRenderContext(e){this._context=e;const t=e.renderContext.rctx;this._quadVAO=U(t),this._techniqueRepository=e.shaderTechniqueRep,this._techniqueConfig=new w;const i=new A;i.contrastControlEnabled=this._config.contrastControlEnabled,this._pathTechnique=this._techniqueRepository.acquire(j,i)}uninitializeRenderContext(){this._quadVAO=n(this._quadVAO),this._technique=s(this._technique),this._pathVerticalPlaneData=n(this._pathVerticalPlaneData),this._pathTechnique=s(this._pathTechnique)}prepareTechnique(){return this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled?(this._techniqueConfig.heightManifoldEnabled=this.heightManifoldEnabled,this._techniqueConfig.lineVerticalPlaneEnabled=this.lineVerticalPlaneEnabled,this._techniqueConfig.pointDistanceEnabled=this.pointDistanceEnabled,this._techniqueConfig.intersectsLineEnabled=this.intersectsLineEnabled,this._techniqueConfig.contrastControlEnabled=this._config.contrastControlEnabled,this._technique=this._techniqueRepository.releaseAndAcquire(I,this._techniqueConfig,this._technique),this._technique):this._pathTechnique}render(e,t){const i=e.camera;x(i.projectionMatrix,i.fullWidth,i.fullHeight,this._projInfo,this._zScale),(this.heightManifoldEnabled||this.pointDistanceEnabled||this.lineVerticalPlaneSegment||this.intersectsLineEnabled)&&this._renderUnified(e,t),this.pathVerticalPlaneEnabled&&this._renderPath(e)}_renderUnified(e,t){const i=e.rctx,n=i.useTechnique(t);this._bindGlobalUniforms(e,n),this._bindHeightManifoldUniforms(e,n),this._bindPointDistanceUniforms(e,n),this._bindLineVerticalPlaneUniforms(e,n),this._bindIntersectsLineUniforms(e,n),t.bind(this._params,e.camera),i.bindVAO(this._quadVAO),i.drawArrays(O.TRIANGLE_STRIP,0,4)}_renderPath(e){if(i(this._pathVerticalPlaneData)||i(this._pathTechnique))return;const t=e.rctx,n=this._pathTechnique,s=t.useTechnique(n);this._bindGlobalUniforms(e,s),n.bind(this._params,this._pathVerticalPlaneData.origin,e.camera),this._pathVerticalPlaneData.draw(e.rctx)}_bindHeightManifoldUniforms(e,t){if(!this.heightManifoldEnabled)return;const i=this._tempVec3A,n=this._tempPlane;this._renderCoordsHelper.worldUpAtPosition(this._heightManifoldTarget,i),N(n,this._heightManifoldTarget,i,e.camera.viewMatrix),t.setUniform4fv("heightPlane",n)}_bindPointDistanceUniforms(e,t){if(!this._pointDistanceEnabled)return;const i=e.camera,n=this._tempSphere;a(n,this._pointDistanceOrigin),h(n,n,i.viewMatrix),n[3]=l(this._pointDistanceOrigin,this._pointDistanceTarget),t.setUniform4f("pointDistanceSphere",n[0],n[1],n[2],n[3])}_bindLineVerticalPlaneUniforms(e,t){if(!this._lineVerticalPlaneEnabled)return;const i=this._renderCoordsHelper,n=e.camera,s=this._tempPlane,r=this._tempVec3A,l=this._tempUp,d=this._tempDir,m=this._tempNormal;L(this._lineVerticalPlaneSegment,.5,r),i.worldUpAtPosition(r,l),o(d,this._lineVerticalPlaneSegment.vector),c(m,l,d),o(m,m),N(s,this._lineVerticalPlaneSegment.origin,m,n.viewMatrix),t.setUniform4fv("lineVerticalPlane",s);const p=this._tempVec3A;a(p,this._lineVerticalPlaneSegment.origin),i.setAltitude(p,0),h(p,p,n.viewMatrix),t.setUniform3fv("lineVerticalStart",p);const f=this._tempVec3B;_(f,this._lineVerticalPlaneSegment.origin,this._lineVerticalPlaneSegment.vector),i.setAltitude(f,0),h(f,f,n.viewMatrix),t.setUniform3fv("lineVerticalEnd",f)}_bindIntersectsLineUniforms(e,t){if(!this._intersectsLineEnabled)return;const i=G,n=F;if(this._intersectsLineInfinite){const t=e.camera;if(g(S(this._intersectsLineSegment.origin,this._intersectsLineSegment.vector),B),B.c0=-Number.MAX_VALUE,!V(t.frustum,B))return;u(B,i),b(B,n)}else a(i,this._intersectsLineSegment.origin),_(n,this._intersectsLineSegment.origin,this._intersectsLineSegment.vector);const s=this._tempVec3A;h(s,i,e.camera.viewMatrix),t.setUniform3fv("intersectsLineStart",s);const r=this._tempVec4;a(r,this._intersectsLineSegment.vector),this._tempVec4[3]=0,m(this._tempVec4,this._tempVec4,e.camera.viewMatrix),h(n,n,e.camera.viewMatrix),t.setUniform3fv("intersectsLineEnd",n),o(r,r),t.setUniform3f("intersectsLineDirection",r[0],r[1],r[2]),t.setUniform1f("intersectsLineRadius",this._intersectsLineRadius)}_bindGlobalUniforms(e,t){const i=e.camera;t.setUniform4fv("projInfo",this._projInfo),t.setUniform2fv("zScale",this._zScale),t.setUniform2fv("nearFar",i.nearFar),this._heightManifoldEnabled?t.setUniform1f("maxPixelDistance",2*i.computeScreenPixelSizeAt(this._heightManifoldTarget)):this._pointDistanceEnabled?t.setUniform1f("maxPixelDistance",2*i.computeScreenPixelSizeAt(this._pointDistanceTarget)):this._lineVerticalPlaneEnabled&&t.setUniform1f("maxPixelDistance",2*i.computeScreenPixelSizeAt(this._lineVerticalPlaneSegment.origin)),t.bindTexture(e.offscreenRenderingHelper.linearDepthTexture,"depthMap"),t.bindTexture(e.offscreenRenderingHelper.mainColorTexture,"frameColor")}_requestRender(){this._context&&this._context.requestRender()}}const B=f(),G=d(),F=d();export{k as LaserLineRenderer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.23/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/Evented.js";import s from"../../../core/Handles.js";import i from"../../../core/Logger.js";import{someMap as a}from"../../../core/MapUtils.js";import{releaseMaybe as o,disposeMaybe as n,isSome as h,unwrapOr as l,isNone as d,unwrap as c}from"../../../core/maybe.js";import u from"../../../core/PooledArray.js";import{someSet as p}from"../../../core/SetUtils.js";import{init as g}from"../../../core/watchUtils.js";import{property as m}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import{q as _,f}from"../../../chunks/mat4.js";import{a as R}from"../../../chunks/vec2f64.js";import{f as T,c as b}from"../../../chunks/vec3f64.js";import{I as w}from"../../../chunks/mat4f64.js";import{ViewingMode as v}from"../../ViewingMode.js";import{DrapeTargetType as x,DrapeSourceType as O}from"../layers/interfaces.js";import E from"../support/debugFlags.js";import{OverlayIndex as L,RenderTargetType as j}from"./interfaces.js";import{Overlay as A}from"./Overlay.js";import{OverlayFramebufferObject as S}from"./OverlayFramebufferObject.js";import{OverlayRenderTarget as P}from"./OverlayRenderTarget.js";import{ShaderTechniqueRepository as C}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{autoDispose as D,AutoDisposableMixin as G}from"../webgl-engine/lib/AutoDisposable.js";import{TransparencyPassType as I,UpdatePolicy as M}from"../webgl-engine/lib/basicInterfaces.js";import V from"../webgl-engine/lib/Camera.js";import{GLMaterialRepository as U}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as F,createQuadVAO as q}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as H}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{newIntersectorResult as W}from"../webgl-engine/lib/Intersector.js";import{StoreResults as N,IntersectorType as B}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as k}from"../webgl-engine/lib/Material.js";import{ModelDirty as z}from"../webgl-engine/lib/ModelDirtyTypes.js";import{OverlayRenderContext as Y}from"../webgl-engine/lib/RenderContext.js";import{RenderPass as X}from"../webgl-engine/lib/RenderPass.js";import{RenderSlot as Q}from"../webgl-engine/lib/RenderSlot.js";import{SortedRenderGeometryRenderer as J}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechniqueConfiguration as K,TextureTechnique as Z}from"../webgl-engine/lib/TextureTechnique.js";import{AmbientLight as $}from"../webgl-engine/lighting/Lightsources.js";import{SceneLighting as ee}from"../webgl-engine/lighting/SceneLighting.js";import{StippleTextureRepository as re}from"../webgl-engine/materials/StippleTextureRepository.js";import{C as te}from"../../../chunks/Compositing.glsl.js";import{AlphaMode as se}from"../webgl-engine/shaders/CompositingTechnique.js";import{ImmediateTask as ie,TaskPriority as ae,noBudget as oe}from"../../support/Scheduler.js";import{ClearBufferBit as ne,PrimitiveType as he,TextureType as le,PixelFormat as de,PixelType as ce,TextureSamplingMode as ue}from"../../webgl/enums.js";import{Texture as pe}from"../../webgl/Texture.js";import{vertexCount as ge}from"../../webgl/Util.js";const me=i.getLogger("esri.views.3d.webgl-engine.lib.OverlayRenderer");let ye=class extends(G(r)){constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._lighting=new ee,this._handles=new s,this._frameTask=ie,this._layerRenderers=new Map,this._sortedLayerRenderersDirty=!1,this._sortedLayerRenderers=new u,this._geometries=new Map,this.worldToPCSRatio=1,this.events=new t,this.longitudeCyclical=null}initialize(){const e=this.view._stage.renderView;this._rctx=e.renderingContext,this._renderContext=new Y(this._rctx);const r=e.waterTextureRepository;this._stippleTextureRepository=new re(e.renderingContext),this._shaderTechniqueRepository=new C({rctx:this._rctx,viewingMode:v.Local,stippleTextureRepository:this._stippleTextureRepository,waterTextureRepository:r}),this._handles.add([g(r,"loadingState",(()=>this.events.emit("content-changed"))),g(this,"spatialReference",(e=>this._localOrigins=new H(e)))]),this._materialRepository=new U(e.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&Oe)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating")}),(()=>this.events.emit("content-changed"))),this._lighting.groundLightingFactor=1,this._lighting.globalFactor=0,this._lighting.set([new $(T(1,1,1))]),this._bindParameters={slot:Q.DRAPED_MATERIAL,highlightDepthTexture:F(this._rctx),camera:be,inverseViewport:R(),origin:null,screenToWorldRatio:null,screenToPCSRatio:null,shadowMappingEnabled:!1,slicePlane:null,ssaoEnabled:!1,hasOccludees:!1,linearDepthTexture:null,lastFrameColorTexture:null,reprojectionMatrix:w,ssrEnabled:!1,lighting:this._lighting,transparencyPassType:I.NONE,terrainLinearDepthTexture:null,geometryLinearDepthTexture:null,multipassTerrainEnabled:!1,cullAboveGround:!1,multipassGeometryEnabled:!1,highlightColorTexture:null,cloudsCompositionParams:null},this._frameTask=this.view.resourceController.scheduler.registerTask(ae.STAGE,this),this._handles.add(this._frameTask)}dispose(){this._handles.destroy(),this._layerRenderers.forEach((e=>e.dispose())),this._layerRenderers.clear(),this._debugTextureTechnique=o(this._debugTextureTechnique),this._debugPatternTexture=n(this._debugPatternTexture),this._bindParameters.highlightDepthTexture=n(this._bindParameters.highlightDepthTexture),this._shaderTechniqueRepository=n(this._shaderTechniqueRepository),this._temporaryFBO=n(this._temporaryFBO),this._quadVAO=n(this._quadVAO),this.disposeOverlays()}get updating(){return this._sortedLayerRenderersDirty||this._frameTask.updating||a(this._layerRenderers,(e=>e.updating))}get hasOverlays(){return h(this._overlays)&&h(this._overlayRenderTarget)}get gpuMemoryUsage(){return h(this._overlayRenderTarget)?this._overlayRenderTarget.gpuMemoryUsage:0}collectUnusedRenderTargetMemory(e){let r=!1;if(h(this._overlayRenderTarget))for(const t of this._overlayRenderTarget.renderTargets){const s=this.overlays[0].validTargets[t.type]||!this.overlays[1].validTargets[t.type];r=this._overlayRenderTarget.validateUsageForTarget(s,t,e)||r}return r}get overlays(){return l(this._overlays,[])}ensureDrapeTargets(e){h(this._overlays)&&this._overlays.forEach((r=>{r.hasTargetWithoutRasterImage=p(e,(e=>e.drapeTargetType===x.WithoutRasterImage))}))}ensureDrapeSources(e){h(this._overlays)&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=a(e,((e,r)=>r.drapeSourceType===O.Features)),r.hasDrapedRasterSource=a(e,((e,r)=>r.drapeSourceType===O.RasterImage))}))}ensureOverlays(e,r){d(this._overlays)&&(this._overlayRenderTarget=new P(this._rctx),this._overlays=[new A(L.INNER,this._overlayRenderTarget),new A(L.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r)}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=n(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e,r=(()=>!0)){this._frameTask.processQueue(e),e.done||this._processLayers(e,r)}_processLayers(e,r){let t=!1;for(const[s,i]of this._layerRenderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()),i.isEmpty&&(t=!0,this._sortedLayerRenderersDirty=!0,this._layerRenderers.delete(s),this._handles.remove(s)))}this._updateSortedLayerRenderers(),t&&(h(this._overlays)&&0===this._layerRenderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.events.emit("content-changed"),this._updateHasHighlights(),this._updateRendersOccluded(),this._updateHasWater())}processSyncLayers(){this._processLayers(oe,(e=>e.updatePolicy===M.SYNC))}addGeometries(e,r,t){for(const s of e)d(s.origin)&&(s.origin=this._localOrigins.getOrigin(s.boundingSphere)),this._geometries.set(s.id,s);this._ensureLayerRenderer(r).add(e),t===z.Geometry.UPDATE&&this._notifyGraphicGeometryChanged(e,r)}removeGeometries(e,r,t){for(const i of e)this._geometries.delete(c(i.id));const s=this._layerRenderers.get(r);s&&(s.remove(e),t===z.Geometry.UPDATE&&this._notifyGraphicGeometryChanged(e,r))}updateGeometries(e,r,t){const s=this._layerRenderers.get(r);if(s)switch(s.modify(e,t),t){case z.State.TRANSFORMATION:case z.State.VERTEXATTRS:return this._notifyGraphicGeometryChanged(e,r);case z.State.VISIBILITIES:return this._notifyGraphicVisibilityChanged(e,r)}else me.warn("Attempted to update geometry for nonexistent layer")}_notifyGraphicGeometryChanged(e,r){if(d(r.notifyGraphicGeometryChanged))return;let t;for(const s of e){const e=s.graphicUid;h(e)&&e!==t&&(r.notifyGraphicGeometryChanged(e),t=e)}}_notifyGraphicVisibilityChanged(e,r){if(d(r.notifyGraphicVisibilityChanged))return;let t;for(const s of e){const e=s.graphicUid;h(e)&&e!==t&&(r.notifyGraphicVisibilityChanged(e),t=e)}}updateHighlights(e,r){const t=this._layerRenderers.get(r);t?t.modify(e,z.State.HIGHLIGHTS):me.warn("Attempted to update highlights for nonexistent layer")}isEmpty(){return 0===this._geometries.size&&!E.OVERLAY_DRAW_DEBUG_TEXTURE}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}updateAnimation(e){let r=!1;return this._layerRenderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateLayerOrder(){this._sortedLayerRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return!1;this._screenToWorldRatio=t*e.mapUnitsPerPixel;const i=r.renderPass;if(this.isEmpty()||i===X.MATERIAL_HIGHLIGHT&&!this.hasHighlights||i===X.MATERIAL_NORMAL&&!this.hasWater||!e.hasSomeSizedView())return!1;const a=r.fbo;if(!a.isValid())return!1;const o=2*e.resolution,n=e.resolution;a.resize(o,n);const l=this._rctx;be.pixelRatio=e.pixelRatio*t,this._renderContext.pass=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=i===X.MATERIAL_NORMAL?Q.DRAPED_WATER:Q.DRAPED_MATERIAL,e.applyViewport(this._rctx),a.bind(l),e.index===L.INNER&&(l.setClearColor(0,0,0,0),l.clearSafe(ne.COLOR_BUFFER_BIT));const d=r.type===j.ColorNoRasterImage?_e.ExcludeRasterImage:r.type===j.Occluded?_e.OccludedOnly:_e.Normal;if(d===_e.OccludedOnly&&(this._renderContext.renderOccludedMask=Oe),E.OVERLAY_DRAW_DEBUG_TEXTURE&&d!==_e.OccludedOnly)for(let h=0;h<s.numViews;h++)this._setViewParameters(s.extents[h],e,be),this._drawDebugTexture(e.resolution,Re[e.index]);return this._layerRenderers.size>0&&this._sortedLayerRenderers.forAll((({overlayLayer:r,renderer:t})=>{if(d===_e.ExcludeRasterImage&&r.drapeSourceType===O.RasterImage)return;const{fullOpacity:c}=r,u=h(c)&&c<1&&i===X.MATERIAL;u&&(this.bindTemporaryFramebuffer(this._rctx,o,n),l.clearSafe(ne.COLOR_BUFFER_BIT));for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],e,be),t.render(this._renderContext,this._bindParameters);u&&h(this._temporaryFBO)&&(a.bind(l),this.view._stage.renderView.compositingHelper.composite(this._temporaryFBO.getTexture(),se.PremultipliedAlpha,c,te.OverlayWithTransparency,e.index))})),l.bindFramebuffer(null),a.generateMipMap(),this._renderContext.resetRenderOccludedMask(),!0}bindTemporaryFramebuffer(e,r,t){d(this._temporaryFBO)&&(this._temporaryFBO=new S(e,!1)),this._temporaryFBO.resize(r,t),this._temporaryFBO.bind(e)}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}intersect(e,r,t,s){let i=0;this._geometries.forEach((a=>{if(s&&!s(a))return;this._intersectRenderGeometry(a,t,r,0,e,i);const o=this.longitudeCyclical;o&&(a.boundingSphere[0]-a.boundingSphere[3]<o.min&&this._intersectRenderGeometry(a,t,r,o.range,e,i),a.boundingSphere[0]+a.boundingSphere[3]>o.max&&this._intersectRenderGeometry(a,t,r,-o.range,e,i)),i++}))}_intersectRenderGeometry(e,r,t,s,i,a){if(!e.instanceParameters.visible)return;let o=0;h(e.transformation)&&(s+=e.transformation[12],o=e.transformation[13]),we[0]=t[0]-s,we[1]=t[1]-o,we[2]=1,ve[0]=t[0]-s,ve[1]=t[1]-o,ve[2]=0,e.screenToWorldRatio=this._screenToWorldRatio,e.material.intersect(e,null,e.getShaderTransformation(),i,we,ve,((t,s,o)=>{Te(r,o,e.material.renderPriority,a,i,e.layerUid,e.graphicUid)}),e.calculateShaderTransformation,r)}_ensureLayerRenderer(e){let r=this._layerRenderers.get(e);return r||(r=new J({rctx:this._rctx,materialRepository:this._materialRepository}),this._layerRenderers.set(e,r),this._sortedLayerRenderersDirty=!0,"fullOpacity"in e&&this._handles.add(e.watch("fullOpacity",(()=>this.events.emit("content-changed"))),e),this._handles.add(g(r,"updating",(()=>this.notifyChange("updating"))),e)),r}_updateSortedLayerRenderers(){if(!this._sortedLayerRenderersDirty)return;if(this._sortedLayerRenderersDirty=!1,this._sortedLayerRenderers.clear(),0===this._layerRenderers.size)return;const e=this.view.map.allLayers;this._layerRenderers.forEach(((r,t)=>{const s=e.indexOf(t.layer);this._sortedLayerRenderers.push(new fe(t,r,s<0?1/0:s))})),this._sortedLayerRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r,t){t.viewport[0]=t.viewport[1]=0,t.viewport[2]=t.viewport[3]=r.resolution,_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),f(t.viewMatrix,[-e[0],-e[1],0]),this._renderContext.camera=t,this._bindParameters.camera=t,this._bindParameters.inverseViewport[0]=1/t.fullViewport[2],this._bindParameters.inverseViewport[1]=1/t.fullViewport[3]}_updateHasWater(){const e=a(this._layerRenderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateHasHighlights(){const e=a(this._layerRenderers,(e=>e.hasHighlights));e!==this._hasHighlights&&(this._hasHighlights=e,this.events.emit("has-highlights",e))}_updateRendersOccluded(){const e=a(this._layerRenderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_drawDebugTexture(e,r){const t=this._rctx;this._ensureDebugPatternResources(e,e);const s=this._debugTextureTechnique.program;t.useProgram(s),this._debugTextureTechnique.bindPipelineState(t),s.setUniform4f("uColor",r[0],r[1],r[2],1),s.bindTexture(this._debugPatternTexture,"tex"),t.bindVAO(this._quadVAO),t.drawArrays(he.TRIANGLE_STRIP,0,ge(this._quadVAO,"geometry"))}_ensureDebugPatternResources(e,r){if(this._debugPatternTexture)return;const t=new Uint8Array(e*r*4);let s=0;for(let a=0;a<r;a++)for(let i=0;i<e;i++){const o=Math.floor(i/10),n=Math.floor(a/10);o<2||n<2||10*o>e-20||10*n>r-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&o&&1&n?1&i^1&a?0:255:1&o^1&n?0:128)}this._debugPatternTexture=new pe(this._rctx,{target:le.TEXTURE_2D,pixelFormat:de.RGBA,dataType:ce.UNSIGNED_BYTE,samplingMode:ue.NEAREST,width:e,height:r},t);const i=new K;i.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire(Z,i),this._quadVAO=q(this._rctx)}get test(){return{layerRenderers:this._layerRenderers}}};var _e;e([m()],ye.prototype,"_frameTask",void 0),e([m()],ye.prototype,"_sortedLayerRenderersDirty",void 0),e([D()],ye.prototype,"_shaderTechniqueRepository",void 0),e([D()],ye.prototype,"_stippleTextureRepository",void 0),e([m({constructOnly:!0})],ye.prototype,"view",void 0),e([m()],ye.prototype,"worldToPCSRatio",void 0),e([m()],ye.prototype,"spatialReference",void 0),e([m({type:Boolean,readOnly:!0})],ye.prototype,"updating",null),ye=e([y("esri.views.3d.terrain.OverlayRenderer")],ye),function(e){e[e.Normal=0]="Normal",e[e.OccludedOnly=1]="OccludedOnly",e[e.ExcludeRasterImage=2]="ExcludeRasterImage"}(_e||(_e={}));class fe{constructor(e,r,t){this.overlayLayer=e,this.renderer=r,this.index=t}}const Re=[[1,.5,.5],[.5,.5,1]];function Te(e,r,t,s,i,a,o){const n={layerUid:a,graphicUid:o,triangleNr:r},h=r=>{r.set(B.OVERLAY,n,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&h(i.results.min),i.options.store!==N.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&h(i.results.max),i.options.store===N.ALL){const e=W(i.ray);h(e),i.results.all.push(e)}}const be=new V;be.near=1,be.far=1e4,be.relativeElevation=null;const we=b(),ve=b(),xe=-2,Oe=k.OccludeAndTransparent;export{xe as DRAPED_Z,_e as DrawPassOption,ye as OverlayRenderer,Oe as overlayRenderOccludedFlag};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import r from"../../../core/Accessor.js";import t from"../../../core/Evented.js";import s from"../../../core/Handles.js";import i from"../../../core/Logger.js";import{someMap as a}from"../../../core/MapUtils.js";import{releaseMaybe as o,disposeMaybe as n,isSome as h,unwrapOr as l,isNone as d,unwrap as c}from"../../../core/maybe.js";import p from"../../../core/PooledArray.js";import{someSet as u}from"../../../core/SetUtils.js";import{init as m}from"../../../core/watchUtils.js";import{property as g}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as y}from"../../../core/accessorSupport/decorators/subclass.js";import{q as _,f}from"../../../chunks/mat4.js";import{a as R}from"../../../chunks/vec2f64.js";import{f as T,c as b}from"../../../chunks/vec3f64.js";import{I as w}from"../../../chunks/mat4f64.js";import{ViewingMode as x}from"../../ViewingMode.js";import{DrapeTargetType as v,DrapeSourceType as O}from"../layers/interfaces.js";import E from"../support/debugFlags.js";import{OverlayIndex as L,RenderTargetType as j}from"./interfaces.js";import{Overlay as A}from"./Overlay.js";import{OverlayFramebufferObject as S}from"./OverlayFramebufferObject.js";import{OverlayRenderTarget as C}from"./OverlayRenderTarget.js";import{ShaderTechniqueRepository as P}from"../webgl-engine/core/shaderTechnique/ShaderTechniqueRepository.js";import{autoDispose as D,AutoDisposableMixin as G}from"../webgl-engine/lib/AutoDisposable.js";import{TransparencyPassType as I,UpdatePolicy as M}from"../webgl-engine/lib/basicInterfaces.js";import V from"../webgl-engine/lib/Camera.js";import{DrapedHeatmapRenderer as U}from"../webgl-engine/lib/DrapedHeatmapRenderer.js";import{GLMaterialRepository as F}from"../webgl-engine/lib/GLMaterialRepository.js";import{createEmptyDepthTexture as q,createQuadVAO as H}from"../webgl-engine/lib/glUtil3D.js";import{GridLocalOriginFactory as W}from"../webgl-engine/lib/GridLocalOriginFactory.js";import{newIntersectorResult as N}from"../webgl-engine/lib/Intersector.js";import{StoreResults as B,IntersectorType as k}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as z}from"../webgl-engine/lib/Material.js";import{ModelDirty as Y}from"../webgl-engine/lib/ModelDirtyTypes.js";import{OverlayRenderContext as X}from"../webgl-engine/lib/RenderContext.js";import{RenderPass as Q}from"../webgl-engine/lib/RenderPass.js";import{RenderSlot as J}from"../webgl-engine/lib/RenderSlot.js";import{SortedRenderGeometryRenderer as K}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{TextureTechniqueConfiguration as Z,TextureTechnique as $}from"../webgl-engine/lib/TextureTechnique.js";import{AmbientLight as ee}from"../webgl-engine/lighting/Lightsources.js";import{SceneLighting as re}from"../webgl-engine/lighting/SceneLighting.js";import{StippleTextureRepository as te}from"../webgl-engine/materials/StippleTextureRepository.js";import{C as se}from"../../../chunks/Compositing.glsl.js";import{AlphaMode as ie}from"../webgl-engine/shaders/CompositingTechnique.js";import{ImmediateTask as ae,TaskPriority as oe,noBudget as ne}from"../../support/Scheduler.js";import{ClearBufferBit as he,PrimitiveType as le,TextureType as de,PixelFormat as ce,PixelType as pe,TextureSamplingMode as ue}from"../../webgl/enums.js";import{Texture as me}from"../../webgl/Texture.js";import{vertexCount as ge}from"../../webgl/Util.js";const ye=i.getLogger("esri.views.3d.webgl-engine.lib.OverlayRenderer");let _e=class extends(G(r)){constructor(e){super(e),this._overlays=null,this._overlayRenderTarget=null,this._hasHighlights=!1,this._rendersOccluded=!1,this._hasWater=!1,this._lighting=new re,this._handles=new s,this._frameTask=ae,this._layerRenderers=new Map,this._sortedLayerRenderersDirty=!1,this._sortedLayerRenderers=new p,this._geometries=new Map,this.worldToPCSRatio=1,this.events=new t,this.longitudeCyclical=null}initialize(){const e=this.view._stage.renderView;this._rctx=e.renderingContext,this._renderContext=new X(this._rctx);const r=e.waterTextureRepository;this._stippleTextureRepository=new te(e.renderingContext),this._shaderTechniqueRepository=new P({rctx:this._rctx,viewingMode:x.Local,stippleTextureRepository:this._stippleTextureRepository,waterTextureRepository:r}),this._handles.add([m(r,"loadingState",(()=>this.events.emit("content-changed"))),m(this,"spatialReference",(e=>this._localOrigins=new W(e)))]),this._materialRepository=new F(e.textureRepository,this._shaderTechniqueRepository,(e=>{(e.renderOccluded&Ee)>0!==this._rendersOccluded&&this._updateRendersOccluded(),this.events.emit("content-changed"),this.notifyChange("updating")}),(()=>this.events.emit("content-changed"))),this._lighting.groundLightingFactor=1,this._lighting.globalFactor=0,this._lighting.set([new ee(T(1,1,1))]),this._bindParameters={slot:J.DRAPED_MATERIAL,highlightDepthTexture:q(this._rctx),camera:we,inverseViewport:R(),origin:null,screenToWorldRatio:null,screenToPCSRatio:null,shadowMappingEnabled:!1,slicePlane:null,ssaoEnabled:!1,hasOccludees:!1,linearDepthTexture:null,lastFrameColorTexture:null,reprojectionMatrix:w,ssrEnabled:!1,lighting:this._lighting,transparencyPassType:I.NONE,terrainLinearDepthTexture:null,geometryLinearDepthTexture:null,multipassTerrainEnabled:!1,cullAboveGround:!1,multipassGeometryEnabled:!1,highlightColorTexture:null,cloudsCompositionParams:null},this._frameTask=this.view.resourceController.scheduler.registerTask(oe.STAGE,this),this._handles.add(this._frameTask)}dispose(){this._handles.destroy(),this._layerRenderers.forEach((e=>e.dispose())),this._layerRenderers.clear(),this._debugTextureTechnique=o(this._debugTextureTechnique),this._debugPatternTexture=n(this._debugPatternTexture),this._bindParameters.highlightDepthTexture=n(this._bindParameters.highlightDepthTexture),this._shaderTechniqueRepository=n(this._shaderTechniqueRepository),this._temporaryFBO=n(this._temporaryFBO),this._quadVAO=n(this._quadVAO),this.disposeOverlays()}get updating(){return this._sortedLayerRenderersDirty||this._frameTask.updating||a(this._layerRenderers,(e=>e.updating))}get hasOverlays(){return h(this._overlays)&&h(this._overlayRenderTarget)}get gpuMemoryUsage(){return h(this._overlayRenderTarget)?this._overlayRenderTarget.gpuMemoryUsage:0}collectUnusedRenderTargetMemory(e){let r=!1;if(h(this._overlayRenderTarget))for(const t of this._overlayRenderTarget.renderTargets){const s=this.overlays[0].validTargets[t.type]||!this.overlays[1].validTargets[t.type];r=this._overlayRenderTarget.validateUsageForTarget(s,t,e)||r}return r}get overlays(){return l(this._overlays,[])}ensureDrapeTargets(e){h(this._overlays)&&this._overlays.forEach((r=>{r.hasTargetWithoutRasterImage=u(e,(e=>e.drapeTargetType===v.WithoutRasterImage))}))}ensureDrapeSources(e){h(this._overlays)&&this._overlays.forEach((r=>{r.hasDrapedFeatureSource=a(e,((e,r)=>r.drapeSourceType===O.Features)),r.hasDrapedRasterSource=a(e,((e,r)=>r.drapeSourceType===O.RasterImage))}))}ensureOverlays(e,r){d(this._overlays)&&(this._overlayRenderTarget=new C(this._rctx),this._overlays=[new A(L.INNER,this._overlayRenderTarget),new A(L.OUTER,this._overlayRenderTarget)]),this.ensureDrapeTargets(e),this.ensureDrapeSources(r)}disposeOverlays(){this._overlays=null,this._overlayRenderTarget=n(this._overlayRenderTarget),this.events.emit("textures-disposed")}get running(){return this.updating}runTask(e,r=(()=>!0)){this._frameTask.processQueue(e),e.done||this._processLayers(e,r)}_processLayers(e,r){let t=!1;for(const[s,i]of this._layerRenderers){if(e.done)break;(s.destroyed||r(s))&&(i.commitChanges()&&(t=!0,e.madeProgress()),i.isEmpty&&(t=!0,this._sortedLayerRenderersDirty=!0,this._layerRenderers.delete(s),this._handles.remove(s)))}this._updateSortedLayerRenderers(),t&&(h(this._overlays)&&0===this._layerRenderers.size&&this.disposeOverlays(),this.notifyChange("updating"),this.events.emit("content-changed"),this._updateHasHighlights(),this._updateRendersOccluded(),this._updateHasWater())}processSyncLayers(){this._processLayers(ne,(e=>e.updatePolicy===M.SYNC))}addGeometries(e,r,t,s=!1){for(const i of e)d(i.origin)&&(i.origin=this._localOrigins.getOrigin(i.boundingSphere)),this._geometries.set(i.id,i);this._ensureLayerRenderer(r,s).add(e),t===Y.Geometry.UPDATE&&this._notifyGraphicGeometryChanged(e,r)}removeGeometries(e,r,t){for(const i of e)this._geometries.delete(c(i.id));const s=this._layerRenderers.get(r);s&&(s.remove(e),t===Y.Geometry.UPDATE&&this._notifyGraphicGeometryChanged(e,r))}updateGeometries(e,r,t){const s=this._layerRenderers.get(r);if(s)switch(s.modify(e,t),t){case Y.State.TRANSFORMATION:case Y.State.VERTEXATTRS:return this._notifyGraphicGeometryChanged(e,r);case Y.State.VISIBILITIES:return this._notifyGraphicVisibilityChanged(e,r)}else ye.warn("Attempted to update geometry for nonexistent layer")}_notifyGraphicGeometryChanged(e,r){if(d(r.notifyGraphicGeometryChanged))return;let t;for(const s of e){const e=s.graphicUid;h(e)&&e!==t&&(r.notifyGraphicGeometryChanged(e),t=e)}}_notifyGraphicVisibilityChanged(e,r){if(d(r.notifyGraphicVisibilityChanged))return;let t;for(const s of e){const e=s.graphicUid;h(e)&&e!==t&&(r.notifyGraphicVisibilityChanged(e),t=e)}}updateHighlights(e,r){const t=this._layerRenderers.get(r);t?t.modify(e,Y.State.HIGHLIGHTS):ye.warn("Attempted to update highlights for nonexistent layer")}isEmpty(){return 0===this._geometries.size&&!E.OVERLAY_DRAW_DEBUG_TEXTURE}get hasHighlights(){return this._hasHighlights}get hasWater(){return this._hasWater}get rendersOccluded(){return this._rendersOccluded}updateAnimation(e){let r=!1;return this._layerRenderers.forEach((t=>r=t.updateAnimation(e)||r)),r}updateLayerOrder(){this._sortedLayerRenderersDirty=!0}drawTarget(e,r,t){const s=e.canvasGeometries;if(0===s.numViews)return!1;this._screenToWorldRatio=t*e.mapUnitsPerPixel;const i=r.renderPass;if(this.isEmpty()||i===Q.MATERIAL_HIGHLIGHT&&!this.hasHighlights||i===Q.MATERIAL_NORMAL&&!this.hasWater||!e.hasSomeSizedView())return!1;const a=r.fbo;if(!a.isValid())return!1;const o=2*e.resolution,n=e.resolution;a.resize(o,n);const l=this._rctx;we.pixelRatio=e.pixelRatio*t,this._renderContext.pass=i,this._bindParameters.screenToWorldRatio=this._screenToWorldRatio,this._bindParameters.screenToPCSRatio=this._screenToWorldRatio*this.worldToPCSRatio,this._bindParameters.slot=i===Q.MATERIAL_NORMAL?J.DRAPED_WATER:J.DRAPED_MATERIAL,e.applyViewport(this._rctx),a.bind(l),e.index===L.INNER&&(l.setClearColor(0,0,0,0),l.clearSafe(he.COLOR_BUFFER_BIT));const d=r.type===j.ColorNoRasterImage?fe.ExcludeRasterImage:r.type===j.Occluded?fe.OccludedOnly:fe.Normal;if(d===fe.OccludedOnly&&(this._renderContext.renderOccludedMask=Ee),E.OVERLAY_DRAW_DEBUG_TEXTURE&&d!==fe.OccludedOnly)for(let h=0;h<s.numViews;h++)this._setViewParameters(s.extents[h],e,we),this._drawDebugTexture(e.resolution,Te[e.index]);return this._layerRenderers.size>0&&this._sortedLayerRenderers.forAll((({overlayLayer:r,renderer:t})=>{if(d===fe.ExcludeRasterImage&&r.drapeSourceType===O.RasterImage)return;const{fullOpacity:c}=r,p=h(c)&&c<1&&i===Q.MATERIAL;p&&(this.bindTemporaryFramebuffer(this._rctx,o,n),l.clearSafe(he.COLOR_BUFFER_BIT));for(let i=0;i<s.numViews;i++)this._setViewParameters(s.extents[i],e,we),t.render(this._renderContext,this._bindParameters);p&&h(this._temporaryFBO)&&(a.bind(l),this.view._stage.renderView.compositingHelper.composite(this._temporaryFBO.getTexture(),ie.PremultipliedAlpha,c,se.OverlayWithTransparency,e.index))})),l.bindFramebuffer(null),a.generateMipMap(),this._renderContext.resetRenderOccludedMask(),!0}bindTemporaryFramebuffer(e,r,t){d(this._temporaryFBO)&&(this._temporaryFBO=new S(e,!1)),this._temporaryFBO.resize(r,t),this._temporaryFBO.bind(e)}async reloadShaders(){await this._shaderTechniqueRepository.reloadAll()}intersect(e,r,t,s){let i=0;this._geometries.forEach((a=>{if(s&&!s(a))return;this._intersectRenderGeometry(a,t,r,0,e,i);const o=this.longitudeCyclical;o&&(a.boundingSphere[0]-a.boundingSphere[3]<o.min&&this._intersectRenderGeometry(a,t,r,o.range,e,i),a.boundingSphere[0]+a.boundingSphere[3]>o.max&&this._intersectRenderGeometry(a,t,r,-o.range,e,i)),i++}))}_intersectRenderGeometry(e,r,t,s,i,a){if(!e.instanceParameters.visible)return;let o=0;h(e.transformation)&&(s+=e.transformation[12],o=e.transformation[13]),xe[0]=t[0]-s,xe[1]=t[1]-o,xe[2]=1,ve[0]=t[0]-s,ve[1]=t[1]-o,ve[2]=0,e.screenToWorldRatio=this._screenToWorldRatio,e.material.intersect(e,null,e.getShaderTransformation(),i,xe,ve,((t,s,o)=>{be(r,o,e.material.renderPriority,a,i,e.layerUid,e.graphicUid)}),e.calculateShaderTransformation,r)}_ensureLayerRenderer(e,r){let t=this._layerRenderers.get(e);return t&&r===t instanceof U||(t=r?new U({rctx:this._rctx,materialRepository:this._materialRepository}):new K({rctx:this._rctx,materialRepository:this._materialRepository}),this._layerRenderers.set(e,t),this._sortedLayerRenderersDirty=!0,"fullOpacity"in e&&this._handles.add(e.watch("fullOpacity",(()=>this.events.emit("content-changed"))),e),this._handles.add(m(t,"updating",(()=>this.notifyChange("updating"))),e)),t}_updateSortedLayerRenderers(){if(!this._sortedLayerRenderersDirty)return;if(this._sortedLayerRenderersDirty=!1,this._sortedLayerRenderers.clear(),0===this._layerRenderers.size)return;const e=this.view.map.allLayers;this._layerRenderers.forEach(((r,t)=>{const s=e.indexOf(t.layer);this._sortedLayerRenderers.push(new Re(t,r,s<0?1/0:s))})),this._sortedLayerRenderers.sort(((e,r)=>e.index-r.index))}_setViewParameters(e,r,t){t.viewport[0]=t.viewport[1]=0,t.viewport[2]=t.viewport[3]=r.resolution,_(t.projectionMatrix,0,e[2]-e[0],0,e[3]-e[1],t.near,t.far),f(t.viewMatrix,[-e[0],-e[1],0]),this._renderContext.camera=t,this._bindParameters.camera=t,this._bindParameters.inverseViewport[0]=1/t.fullViewport[2],this._bindParameters.inverseViewport[1]=1/t.fullViewport[3]}_updateHasWater(){const e=a(this._layerRenderers,(e=>e.hasWater));e!==this._hasWater&&(this._hasWater=e,this.events.emit("has-water",e))}_updateHasHighlights(){const e=a(this._layerRenderers,(e=>e.hasHighlights));e!==this._hasHighlights&&(this._hasHighlights=e,this.events.emit("has-highlights",e))}_updateRendersOccluded(){const e=a(this._layerRenderers,(e=>e.rendersOccluded));e!==this._rendersOccluded&&(this._rendersOccluded=e,this.events.emit("renders-occluded",e))}_drawDebugTexture(e,r){this._ensureDebugPatternResources(e,e);const t=this._rctx,s=t.useTechnique(this._debugTextureTechnique);s.setUniform4f("uColor",r[0],r[1],r[2],1),s.bindTexture(this._debugPatternTexture,"tex"),t.bindVAO(this._quadVAO),t.drawArrays(le.TRIANGLE_STRIP,0,ge(this._quadVAO,"geometry"))}_ensureDebugPatternResources(e,r){if(this._debugPatternTexture)return;const t=new Uint8Array(e*r*4);let s=0;for(let a=0;a<r;a++)for(let i=0;i<e;i++){const o=Math.floor(i/10),n=Math.floor(a/10);o<2||n<2||10*o>e-20||10*n>r-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&o&&1&n?1&i^1&a?0:255:1&o^1&n?0:128)}this._debugPatternTexture=new me(this._rctx,{target:de.TEXTURE_2D,pixelFormat:ce.RGBA,dataType:pe.UNSIGNED_BYTE,samplingMode:ue.NEAREST,width:e,height:r},t);const i=new Z;i.hasAlpha=!0,this._debugTextureTechnique=this._shaderTechniqueRepository.acquire($,i),this._quadVAO=H(this._rctx)}get test(){return{layerRenderers:this._layerRenderers}}};var fe;e([g()],_e.prototype,"_frameTask",void 0),e([g()],_e.prototype,"_sortedLayerRenderersDirty",void 0),e([D()],_e.prototype,"_shaderTechniqueRepository",void 0),e([D()],_e.prototype,"_stippleTextureRepository",void 0),e([g({constructOnly:!0})],_e.prototype,"view",void 0),e([g()],_e.prototype,"worldToPCSRatio",void 0),e([g()],_e.prototype,"spatialReference",void 0),e([g({type:Boolean,readOnly:!0})],_e.prototype,"updating",null),_e=e([y("esri.views.3d.terrain.OverlayRenderer")],_e),function(e){e[e.Normal=0]="Normal",e[e.OccludedOnly=1]="OccludedOnly",e[e.ExcludeRasterImage=2]="ExcludeRasterImage"}(fe||(fe={}));class Re{constructor(e,r,t){this.overlayLayer=e,this.renderer=r,this.index=t}}const Te=[[1,.5,.5],[.5,.5,1]];function be(e,r,t,s,i,a,o){const n={layerUid:a,graphicUid:o,triangleNr:r},h=r=>{r.set(k.OVERLAY,n,e.dist,e.normal,e.transformation,t,s)};if((null==i.results.min.drapedLayerOrder||t>=i.results.min.drapedLayerOrder)&&(null==i.results.min.dist||i.results.ground.dist<=i.results.min.dist)&&h(i.results.min),i.options.store!==B.MIN&&(null==i.results.max.drapedLayerOrder||t<i.results.max.drapedLayerOrder)&&(null==i.results.max.dist||i.results.ground.dist>i.results.max.dist)&&h(i.results.max),i.options.store===B.ALL){const e=N(i.ray);h(e),i.results.all.push(e)}}const we=new V;we.near=1,we.far=1e4,we.relativeElevation=null;const xe=b(),ve=b(),Oe=-2,Ee=z.OccludeAndTransparent;export{Oe as DRAPED_Z,fe as DrawPassOption,_e as OverlayRenderer,Ee 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.23/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Accessor.js";import{isSome as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{j as l}from"../../../chunks/mat4.js";import{c as d,I as h}from"../../../chunks/mat4f64.js";import{f as c,s as u,n as p,d as g}from"../../../chunks/vec3.js";import{Z as f,c as m}from"../../../chunks/vec3f64.js";import{Z as T,c as R}from"../../../chunks/vec4f64.js";import{create as b,set as _,expandWithOffset as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{requestImage as x}from"../../../support/requestImageUtils.js";import{ViewingMode as A}from"../../ViewingMode.js";import{TextureUpdate as D,OverlayIndex as E}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlaySource as P}from"./Overlay.js";import{overlayRenderOccludedFlag as I}from"./OverlayRenderer.js";import{clearCaches as S,getGlobalSkirtGeometry as C,intersectSkirtsGlobal as k,intersectSkirtsLocal as N}from"./PatchGeometryFactory.js";import{PatchRenderData as w}from"./PatchRenderData.js";import{RenderOrder as q}from"./RenderOrder.js";import{ScaleRangeQueries as L}from"./ScaleRangeQueries.js";import{DEFAULT_TILE_BACKGROUND as M}from"./TerrainConst.js";import{TileRenderer as G}from"./TileRenderer.js";import{TileUpdate as U}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as B,compareTiles as F}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as H,ComponentIntersectionData as z}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as V}from"../webgl-engine/core/shaderLibrary/ShaderOutputOptions.js";import{bindSliceUniforms as W}from"../webgl-engine/core/shaderLibrary/Slice.glsl.js";import{bindSSRUniforms as Q}from"../webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js";import{OverlayMode as Y}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{bindProjectionMatrix as X}from"../webgl-engine/core/shaderLibrary/util/View.glsl.js";import{RenderRequestType as Z}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as K}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as J}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as $,StoreResults as ee}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as te}from"../webgl-engine/lib/Material.js";import{RenderPass as re}from"../webgl-engine/lib/RenderPass.js";import{RenderSlot as ie}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as se}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as ne}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as ae,getVerticalOffsetTerrain as oe}from"../webgl-engine/lib/verticalOffsetUtils.js";import{bindScreenSizePerspective as le,intersectAabbInvDirBefore as de,intersectTriangles as he}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechniqueConfiguration as ce,TerrainTechnique as ue}from"../webgl-engine/shaders/TerrainTechnique.js";import{ClearBufferBit as pe,PrimitiveType as ge}from"../../webgl/enums.js";const fe=7,me=10,Te=b(),Re=R();let be=class extends r{constructor(e){super(e),this.type=$.TERRAIN,this.isGround=!0,this.tileSize=256,this.rctx=null,this._isTransparent=!1,this._scaleRangeQueries=new L,this.renderDataPool=new n(w),this._patchGroups=new Map,this.patchGroupsDirty=!0,this.tileIterator=new j,this.highestVisibleLODTile=null,this.visible=!0,this._opaque=!0,this._skirtScale=1,this._velvetOverground=!0,this.castShadows=!0,this._ssrEnabled=!1,this.emptyTex=null,this.tileRenderer=null,this.tileBackgroundInitialized=!1,this.tileBackgroundUpdating=!1,this.stencilEnabledLayerExtents=[],this.numTilesRendered=0,this.numTilesCulled=0,this.numOriginsRendered=0,this.overlayOpacity=1,this.needsHighlight=!1,this.renderOccludedFlags=te.Occlude}get isGlobal(){return this.stage.viewingMode===A.Global}initialize(){const e=[ie.OPAQUE_TERRAIN,ie.TRANSPARENT_TERRAIN,ie.OCCLUDED_TERRAIN];this.stage.addRenderPlugin(e,this)}destroy(){this.stage.removeRenderPlugin(this),S()}get updating(){return!this.tileBackgroundInitialized||this.tileBackgroundUpdating}get canRender(){return this.visible&&!!this._rootTiles&&this.tileBackgroundInitialized&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setNeedsRender()}set opaque(e){this._opaque!==e&&(this._opaque=e,this.setNeedsRender())}get opaque(){return this._opaque&&!this.shaderTechniqueConfig.slicePlaneEnabled}get needsLinearDepth(){return this.overlayRenderer.hasWater}set isTransparent(e){this._isTransparent!==e&&(this._isTransparent=e,this.setNeedsRender())}get isTransparent(){return this._isTransparent}set skirtScale(e){e!==this._skirtScale&&(this._skirtScale=e,this.setNeedsRender())}get skirtScale(){return this._skirtScale}get renderPatchBorders(){return!!this.shaderTechniqueConfig.tileBorders}set renderPatchBorders(e){this.shaderTechniqueConfig.tileBorders!==e&&(this.shaderTechniqueConfig.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get cullBackFaces(){return this.shaderTechniqueConfig.backfaceCullingEnabled}set cullBackFaces(e){this.shaderTechniqueConfig.backfaceCullingEnabled!==e&&(this.shaderTechniqueConfig.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this.setNeedsRender()}set velvetOverground(e){this._velvetOverground!==e&&(this._velvetOverground=e,this.setNeedsRender())}get layerUid(){return ae}get slicePlaneEnabled(){return this.shaderTechniqueConfig.slicePlaneEnabled}set slicePlaneEnabled(e){this.shaderTechniqueConfig.slicePlaneEnabled!==e&&(this.shaderTechniqueConfig.slicePlaneEnabled=e,this.setNeedsRender())}set textureFadingEnabled(e){this.shaderTechniqueConfig.textureFadingEnabled!==e&&(this.shaderTechniqueConfig.textureFadingEnabled=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this.shaderTechniqueConfig.screenSizePerspective!==e&&(this.shaderTechniqueConfig.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setNeedsRender()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?I:te.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this.stencilEnabledLayerExtents=e,this.setNeedsRender()}setTileSize(e){this.tileSize=e,this.tileRenderer&&(this.tileRenderer.tileSize=e),this.setNeedsRender()}loadTile(e){e.renderData||(e.renderData=this.renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e)),this.updateTileGeometry(e),this.updateTileTexture(e,U.TEXTURE_FADING)}queryVisibleLevelRange(e,t,r,i){this._scaleRangeQueries.queryVisibleLevelRange(e,t,r,i),this.setNeedsRender()}updateTileTexture(e,t){this.tileRenderer&&this.tileBackgroundInitialized&&(this.tileRenderer.updateTileTexture(e,t===U.TEXTURE_FADING?D.FADING:D.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometry(e){for(const t of e.layerInfo[O.ELEVATION])t.pendingUpdates&=~U.GEOMETRY;e.resetPendingUpdate(U.GEOMETRY),e.renderData.updateGeometry(this.rctx,this.wireframe)&&this.setNeedsRender()}unloadTile(e){e.renderData&&(e.renderData.releaseGeometry()&&this.setNeedsRender(),this.renderDataPool.release(e.renderData),e.renderData.clear(),e.renderData=null,e.setMemoryDirty(),this.setNeedsRender())}_getLocalOriginOfTile(e){const t=me-fe,r=Math.max(0,Math.floor((e.level-t)/fe)*fe);if(this.isGlobal&&0===r)return f;for(;e.parent&&e.level>r;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this.visible=e,this.setNeedsRender()}getStats(){return{numTilesRendered:this.numTilesRendered,numTilesCulled:this.numTilesCulled,numOriginsRendered:this.numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.allTiles.forAll((t=>{var r;return null==(r=t.renderData)?void 0:r.updateGeometry(this.rctx,e)})),this.setNeedsRender())}setNeedsRender(e=Z.UPDATE){this.patchGroupsDirty=!0,this.context.requestRender(e)}setTileBackground(e){this.tileBackground=e,this._updateTileBackground()}initializeRenderContext(e){this.context=e,this.rctx=e.renderContext.rctx,this.shaderTechniques=e.shaderTechniqueRep,this.shaderTechniqueConfig=new ce,this.tileRenderer=new G(this.rctx,this.tileSize,this.shaderTechniques),this.tileBackground&&this._updateTileBackground(),this.emptyTex=K(this.rctx)}uninitializeRenderContext(){null!=this.emptyTex&&(this.emptyTex.dispose(),this.emptyTex=null),this.tileRenderer&&(this.tileRenderer.dispose(),this.tileRenderer=null)}intersect(e,t,r,n){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&!this._opaque)return;const a=Ae,o=De;c(a,n,r),u(o,1/a[0],1/a[1],1/a[2]);const l=e.results.min,d=e.results.max,p=e.results.ground,f=e.options.store===ee.MIN,m=!!e.results.ground.target,T=oe(e.verticalOffset),R=this._skirtScale,b=e.tolerance;let x,A=f&&i(l.dist)?l.dist:1/0;const D=u=>{const m=u.renderData;if(null==m)return;const D=m.geometryInfo;_(Te,D.boundingBox);const E=m.localOrigin;i(T)&&(T.localOrigin=E,T.applyToAabb(Te));const O=-R*D.skirtLength;if(0!==O){const e=u.up;y(Te,O*e[0],O*e[1],O*e[2])}const P=Te;if(Ee[0]=r[0]-E[0],Ee[1]=r[1]-E[1],Ee[2]=r[2]-E[2],!de(P,Ee,o,b,A))return;const I=(e,t,r)=>{e.set(this.type,u,t,r,h),A=f&&i(l.dist)?l.dist:1/0},S=(o,h)=>{if(i(h)&&o>=0&&(e.options.backfacesTerrain||g(h,a)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(r,n,o))){if((null==p.dist||o<p.dist)&&I(p,o,h),e.options.isFiltered)return;e.options.store===ee.ALL&&(s(x)?(x=J(e.ray),I(x,o,h),e.results.all.push(x)):o<x.dist&&I(x,o,h)),(null==l.dist||o<l.dist)&&I(l,o,h),e.options.store!==ee.MIN&&(null==d.dist||o>d.dist)&&I(d,o,h)}},w=Oe;c(w,n,E);const q=D.indices,L=D.vertexAttributes,M={data:L.getField(ne.POSITION,v).typedBuffer,size:3,stride:L.stride/4},G=D.numWithoutSkirtIndices/3;if(!i(T)&&G>H){const e=u.renderData;i(e.intersectionData)||(e.intersectionData=new z(q,0,G,M)),e.intersectionData.intersectRay({r0:Ee,r1:w},S)}else he(Ee,w,0,G,q,M,null,T,S);if(0!==O){const e=q.length/3;if(this.isGlobal){const t=e-G;if(!i(T)&&t>H){const r=u.renderData;if(!i(r.skirtIntersectionData)){const i=C(q,G,e,L,O,E);r.skirtIntersectionData=new z(i.indices,0,t,{data:i.vertices,stride:3})}r.skirtIntersectionData.intersectRay({r0:Ee,r1:w},S)}else k(Ee,w,G,e,q,L,O,E,T,S)}else N(Ee,w,G,e,q,L,O,T,S)}},E=this._rootTiles;if(i(E)){(()=>{const t=this.tileIterator;t.reset(E);const s=e.options.invisibleTerrain;for(;!t.done;){const e=t.next();!(e.visible||s&&e.intersectsClippingArea)||!i(T)&&!e.intersectsRay(r,a,b,A,R)||m&&this._useStencilForTile(e)?t.skipSubtree():D(e)}})()}}prepareTechnique(e){if(e.slot===ie.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&I))return null}else{const t=this.opaque?ie.OPAQUE_TERRAIN:ie.TRANSPARENT_TERRAIN;if(e.slot!==t)return null}switch(e.pass){case re.MATERIAL:{const t=e.shadowMap&&e.shadowMap.enabled;this.shaderTechniqueConfig.receiveShadows!==t&&(this.shaderTechniqueConfig.receiveShadows=t);const r=this.overlayRenderer.isEmpty()?Y.Disabled:this.overlayRenderer.hasWater?Y.EnabledWithWater:Y.Enabled;this.shaderTechniqueConfig.overlayMode!==r&&(this.shaderTechniqueConfig.overlayMode=r);const i=e.slot===ie.OCCLUDED_TERRAIN?P.Occluded:P.ColorAndWater;return this._updateTechnique(V.Color,i===P.Occluded)}case re.MATERIAL_DEPTH_SHADOWMAP_ALL:case re.MATERIAL_DEPTH_SHADOWMAP_DEFAULT:return this.castShadows&&1===e.scenelightingData.globalFactor?this._updateTechnique(V.Shadow,!1):null;case re.MATERIAL_DEPTH:return this.isTransparent&&this.overlayRenderer.isEmpty()?null:this._updateTechnique(V.Depth,!1);case re.MATERIAL_NORMAL:return this._updateTechnique(V.Normal,!1);case re.MATERIAL_HIGHLIGHT:return this.needsHighlight?this._updateTechnique(V.Highlight,!1):null}return null}render(e,t){const r=e.pass,i=1===e.scenelightingData.globalFactor;switch(this._updatePatchGroups(),r){case re.MATERIAL:{const r=e.slot===ie.OCCLUDED_TERRAIN?P.Occluded:P.ColorAndWater;this._renderMaterialPass(e,t,r);break}case re.MATERIAL_DEPTH_SHADOWMAP_ALL:case re.MATERIAL_DEPTH_SHADOWMAP_DEFAULT:this.castShadows&&i&&this._renderAuxiliaryPass(e,t,P.None);break;case re.MATERIAL_DEPTH:this.isTransparent&&this.overlayRenderer.isEmpty()||this._renderAuxiliaryPass(e,t,P.None);break;case re.MATERIAL_NORMAL:this._renderAuxiliaryPass(e,t,P.None);break;case re.MATERIAL_HIGHLIGHT:this.needsHighlight&&(this._renderAuxiliaryPass(e,t,P.Highlight),e.rctx.clearSafe(pe.DEPTH_BUFFER_BIT))}this._scaleRangeQueries.hasPendingQueries()&&this.setNeedsRender()}_renderMaterialPass(e,t,r){const{rctx:i,camera:s}=e;this._ssrEnabled=e.ssrParams.ssrEnabled;const n=t.program;i.useProgram(n),this.shaderTechniqueConfig.overlayMode!==Y.Disabled&&r===P.ColorAndWater&&e.ssrParams&&Q(n,e.ssrParams),e.shadowMap.bind(n),e.ssaoHelper.bind(n,e.camera),this._bindOverlayData(n,r),n.setUniformMatrix4fv("viewNormal",s.viewInverseTransposeMatrix),X(n,s.projectionMatrix),e.scenelightingData.setUniforms(n,!0);const a=s.viewMatrix;u(xe,a[12],a[13],a[14]),p(xe,xe),n.setUniform3fv("viewDirection",xe),this.numTilesRendered=0,this.numTilesCulled=0,this.numOriginsRendered=0,this._scaleRangeQueries.prepareQueries(),this.opaque?this._renderPatchGroups(e,t,r):e.offscreenRenderingHelper.renderToTargets((()=>this._renderPatchGroups(e,t,r)),e.offscreenRenderingHelper.tmpColor,e.offscreenRenderingHelper.mainDepth,[0,0,0,0]),this._scaleRangeQueries.processQueries()}_renderAuxiliaryPass(e,t,r){const i=t.program;if(e.rctx.useProgram(i),e.pass===re.MATERIAL_HIGHLIGHT){const t=e.offscreenRenderingHelper;i.bindTexture(t.depthTexture,"depthTex"),i.setUniform4f("highlightViewportPixelSz",0,0,1/t.width,1/t.height)}else i.setUniformMatrix4fv("viewNormal",e.camera.viewInverseTransposeMatrix),e.pass!==re.MATERIAL_DEPTH&&e.pass!==re.MATERIAL_DEPTH_SHADOWMAP_ALL&&e.pass!==re.MATERIAL_DEPTH_SHADOWMAP_DEFAULT||i.setUniform2fv("nearFar",e.camera.nearFar);this._renderPatchGroupsAuxiliary(e,t,r)}_updateTileBackground(){if(!this.tileRenderer)return;this.tileBackgroundUpdating=!0;const e=()=>{this.tileBackgroundInitialized=!0,this.tileBackgroundUpdating=!1,this.shaderTechniqueConfig.useGrid=this.tileRenderer.backgroundIsGrid,this.shaderTechniqueConfig.hasBackgroundColor=!this.tileRenderer.backgroundIsGrid&&!!i(this.tileRenderer.backgroundColor),this.allTiles.forAll((e=>this.tileRenderer.updateTileTexture(e,D.FADING))),this.setNeedsRender()};if("string"==typeof this.tileBackground){const t=this.tileBackground;x(t).then((r=>{t===this.tileBackground&&this.tileRenderer&&(this.tileRenderer.setBackground(r,this.tileBackground===M),e())}))}else{const r=this.tileBackground?t.toUnitRGBA(this.tileBackground):[0,0,0,0];this.tileRenderer.setBackground(r,!1),e()}}_updatePatchGroups(){if(this.patchGroupsDirty){if(this.highestVisibleLODTile=null,this._rebuildPatchGroups(),this.renderOrder!==q.NONE){const e=Array.from(this._patchGroups.values());e.forEach((e=>B(this.renderOrder,e))),e.sort(((e,t)=>F(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e])))}this.patchGroupsDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(!s(e)){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||e.visible)if(e.rendered){if(r){const i=this._patchGroups.get(r.localOrigin)||new Array;this._patchGroups.set(r.localOrigin,i),i.push(e),(!this.highestVisibleLODTile||e.vlevel>this.highestVisibleLODTile.vlevel)&&(this.highestVisibleLODTile=e),t.skipSubtree()}}else this.numTilesCulled++;else this.numTilesCulled++,t.skipSubtree()}}_useStencilForTile(e){for(const t of this.stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,r){const i=e.rctx;t.useStencil=!1,t.bindPipelineState(i,e.slot);const s=this.stencilEnabledLayerExtents.length>0,n=t.program;n.setUniformMatrix4fv("proj",e.camera.projectionMatrix),n.setUniform1f("skirtScale",this._skirtScale),r!==P.None&&this._bindOverlayData(n,r),this._patchGroups.forEach((i=>{const a=i[0].renderData.localOrigin;this._bindPatchGroupData(n,a,e.camera.eye,e.camera.viewMatrix);for(let n=0;n<i.length;n++)this._renderPatch(e,t,i[n],ge.TRIANGLES,s,r)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,r){const n=e.rctx,a=e.camera,o=a.viewMatrix,l=t.program;if(t.useStencil=!1,t.bindPipelineState(n,e.slot),this.shaderTechniqueConfig.screenSizePerspective&&this.pointsOfInterest){const e=se(this.stage.viewingMode,this.ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:a.fovY}),le(e,l,"screenSizePerspective")}const d=this.stencilEnabledLayerExtents.length>0,h=r===P.Occluded;h&&(l.bindTexture(this.emptyTex,"tex"),l.setUniform1f("blend",1),l.setUniform4fv("texOffsetAndScale",T));const c=i(this.tileRenderer.backgroundColor)?this.tileRenderer.backgroundColor:f;this.shaderTechniqueConfig.hasBackgroundColor&&l.setUniform3fv("backgroundColor",c);const u=h?0:this._skirtScale;l.setUniform1f("skirtScale",u);const p=this.wireframe?ge.LINES:ge.TRIANGLES;this.shaderTechniqueConfig.textureFadingEnabled&&l.bindTexture(this.emptyTex,"texNext"),this._patchGroups.forEach((n=>{const c=n[0].renderData.localOrigin;this._bindPatchGroupData(l,c,a.eye,o);const u=e.sliceHelper&&e.sliceHelper.plane;W(l,t.configuration,u,c),e.shadowMap&&e.shadowMap.bindView(l,c),this.numOriginsRendered++;for(let a=0;a<n.length;a++){const o=n[a],c=o.renderData.textureReference;if(!s(c)){if(!h){this._scaleRangeQueries.scaleQueriesForTile(o),ye(o.renderData.geometryInfo.uvOffsetAndScale,c.offsetAndScale,Re),l.setUniform4fv("texOffsetAndScale",Re),l.bindTexture(c.texture.texture,"tex");const e=o.renderData.textureFadeFactor,t=e<1?o.renderData.nextTextureReference:null;this.shaderTechniqueConfig.textureFadingEnabled&&i(t)&&e<1?(ye(o.renderData.geometryInfo.uvOffsetAndScale,t.offsetAndScale,Re),l.setUniform1f("fadeFactor",e),l.setUniform4fv("nextTexOffsetAndScale",Re),l.setUniform3fv("nextTexOpacities",t.opacities),l.bindTexture(t.texture.texture,"texNext")):l.setUniform1f("fadeFactor",1),o.renderData.textureIsFading&&this.setNeedsRender(),l.setUniform3fv("textureOpacities",c.opacities)}this._renderPatch(e,t,o,p,d,r),o.renderOrder=this.numTilesRendered,this.numTilesRendered++}}})),n.bindVAO(null)}_renderPatch(e,t,r,i,n,a){if(s(r.renderData.vao.indexBuffer))return;const o=t.program;a!==P.None&&this._bindOverlayPatchData(o,r.renderData.overlay),n&&(t.useStencil=this._useStencilForTile(r),t.bindPipelineState(e.rctx,e.slot));const l=0===this._skirtScale?r.renderData.geometryInfo.numWithoutSkirtIndices:r.renderData.vao.indexBuffer.size;e.rctx.bindVAO(r.renderData.vao),o.assertCompatibleVertexAttributeLocations(r.renderData.vao),e.rctx.drawElements(i,l,r.renderData.vao.indexBuffer.indexType,0)}_bindPatchGroupData(e,t,r,i){e.setUniform3fv("origin",t),l(ve,i,t),e.setUniformMatrix4fv("view",ve),e.setUniform3f("cameraPosition",r[0]-t[0],r[1]-t[1],r[2]-t[2])}_bindOverlayData(e,t){if(this.shaderTechniqueConfig.overlayMode===Y.Disabled)return;e.setUniform1f("overlayOpacity",this.overlayOpacity);const r=this.overlayRenderer.overlays;if(r.length>E.INNER){const s=r[E.INNER],n=s.getColorTexture(t);if(e.bindTexture(i(n)?n:this.emptyTex,"ovColorTex"),this.shaderTechniqueConfig.overlayMode===Y.EnabledWithWater){const r=s.getNormalTexture(t);e.bindTexture(i(r)?r:this.emptyTex,"ovWaterTex")}}}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this.shaderTechniqueConfig.output=e,e===V.Color&&(this.shaderTechniqueConfig.atmosphere=this.isGlobal&&this._velvetOverground,this.shaderTechniqueConfig.ssrEnabled=this._ssrEnabled),this.shaderTechniqueConfig.renderOccluded=t,this.shaderTechniqueConfig.stencilEnabled=!1,this._shaderTechnique=this.shaderTechniques.releaseAndAcquire(ue,this.shaderTechniqueConfig,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this.tileRenderer}}};e([a()],be.prototype,"tileBackgroundInitialized",void 0),e([a()],be.prototype,"tileBackgroundUpdating",void 0),e([a({constructOnly:!0})],be.prototype,"overlayRenderer",void 0),e([a({constructOnly:!0})],be.prototype,"stage",void 0),e([a({readOnly:!0})],be.prototype,"isGlobal",null),e([a({constructOnly:!0})],be.prototype,"allTiles",void 0),e([a({constructOnly:!0})],be.prototype,"ellipsoidRadius",void 0),e([a({readOnly:!0})],be.prototype,"updating",null),e([a({value:!1})],be.prototype,"renderingDisabled",null),e([a()],be.prototype,"renderPatchBorders",null),e([a()],be.prototype,"cullBackFaces",null),e([a({value:q.FRONT_TO_BACK})],be.prototype,"renderOrder",null),e([a()],be.prototype,"wireframe",null),be=e([o("esri.views.3d.terrain.TerrainRenderer")],be);const _e=be;function ye(e,t,r){r[0]=e[0]*t[2]+t[0],r[1]=e[1]*t[3]+t[1],r[2]=e[2]*t[2],r[3]=e[3]*t[3]}const ve=d(),xe=m(),Ae=m(),De=m(),Ee=m(),Oe=m();export{_e as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import r from"../../../core/Accessor.js";import{isSome as i,isNone as s}from"../../../core/maybe.js";import n from"../../../core/ObjectPool.js";import{property as a}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import"../../../core/accessorSupport/ensureType.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{j as l}from"../../../chunks/mat4.js";import{c as d,I as h}from"../../../chunks/mat4f64.js";import{f as c,s as u,n as p,d as f}from"../../../chunks/vec3.js";import{Z as g,c as m}from"../../../chunks/vec3f64.js";import{Z as T,c as R}from"../../../chunks/vec4f64.js";import{create as b,set as _,expandWithOffset as y}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as v}from"../../../geometry/support/buffer/BufferView.js";import{requestImage as x}from"../../../support/requestImageUtils.js";import{ViewingMode as A}from"../../ViewingMode.js";import{TextureUpdate as D,OverlayIndex as E}from"./interfaces.js";import{LayerClass as O}from"./LayerClass.js";import{OverlaySource as P}from"./Overlay.js";import{overlayRenderOccludedFlag as I}from"./OverlayRenderer.js";import{clearCaches as C,getGlobalSkirtGeometry as S,intersectSkirtsGlobal as k,intersectSkirtsLocal as N}from"./PatchGeometryFactory.js";import{PatchRenderData as q}from"./PatchRenderData.js";import{RenderOrder as w}from"./RenderOrder.js";import{ScaleRangeQueries as L}from"./ScaleRangeQueries.js";import{DEFAULT_TILE_BACKGROUND as M}from"./TerrainConst.js";import{TileRenderer as G}from"./TileRenderer.js";import{TileUpdate as U}from"./TileUpdate.js";import{IteratorPreorder as j,sortTiles as B,compareTiles as F}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as H,ComponentIntersectionData as z}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as V}from"../webgl-engine/core/shaderLibrary/ShaderOutputOptions.js";import{bindSliceUniforms as W}from"../webgl-engine/core/shaderLibrary/Slice.glsl.js";import{bindSSRUniforms as Q}from"../webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js";import{OverlayMode as Y}from"../webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js";import{bindProjectionMatrix as X}from"../webgl-engine/core/shaderLibrary/util/View.glsl.js";import{RenderRequestType as Z}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as K}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as J}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as $,StoreResults as ee}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as te}from"../webgl-engine/lib/Material.js";import{RenderPass as re}from"../webgl-engine/lib/RenderPass.js";import{RenderSlot as ie}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as se}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as ne}from"../webgl-engine/lib/VertexAttribute.js";import{TERRAIN_ID as ae,getVerticalOffsetTerrain as oe}from"../webgl-engine/lib/verticalOffsetUtils.js";import{bindScreenSizePerspective as le,intersectAabbInvDirBefore as de,intersectTriangles as he}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechniqueConfiguration as ce,TerrainTechnique as ue}from"../webgl-engine/shaders/TerrainTechnique.js";import{ClearBufferBit as pe,PrimitiveType as fe}from"../../webgl/enums.js";const ge=7,me=10,Te=b(),Re=R();let be=class extends r{constructor(e){super(e),this.type=$.TERRAIN,this.isGround=!0,this.tileSize=256,this.rctx=null,this._isTransparent=!1,this._scaleRangeQueries=new L,this.renderDataPool=new n(q),this._patchGroups=new Map,this.patchGroupsDirty=!0,this.tileIterator=new j,this.highestVisibleLODTile=null,this.visible=!0,this._opaque=!0,this._skirtScale=1,this._velvetOverground=!0,this.castShadows=!0,this._ssrEnabled=!1,this.emptyTex=null,this.tileRenderer=null,this.tileBackgroundInitialized=!1,this.tileBackgroundUpdating=!1,this.stencilEnabledLayerExtents=[],this.numTilesRendered=0,this.numTilesCulled=0,this.numOriginsRendered=0,this.overlayOpacity=1,this.needsHighlight=!1,this.renderOccludedFlags=te.Occlude}get isGlobal(){return this.stage.viewingMode===A.Global}initialize(){const e=[ie.OPAQUE_TERRAIN,ie.TRANSPARENT_TERRAIN,ie.OCCLUDED_TERRAIN];this.stage.addRenderPlugin(e,this)}destroy(){this.stage.removeRenderPlugin(this),C()}get updating(){return!this.tileBackgroundInitialized||this.tileBackgroundUpdating}get canRender(){return this.visible&&!!this._rootTiles&&this.tileBackgroundInitialized&&!this.renderingDisabled}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setNeedsRender()}set opaque(e){this._opaque!==e&&(this._opaque=e,this.setNeedsRender())}get opaque(){return this._opaque&&!this.shaderTechniqueConfig.slicePlaneEnabled}get needsLinearDepth(){return this.overlayRenderer.hasWater}set isTransparent(e){this._isTransparent!==e&&(this._isTransparent=e,this.setNeedsRender())}get isTransparent(){return this._isTransparent}set skirtScale(e){e!==this._skirtScale&&(this._skirtScale=e,this.setNeedsRender())}get skirtScale(){return this._skirtScale}get renderPatchBorders(){return!!this.shaderTechniqueConfig.tileBorders}set renderPatchBorders(e){this.shaderTechniqueConfig.tileBorders!==e&&(this.shaderTechniqueConfig.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get cullBackFaces(){return this.shaderTechniqueConfig.backfaceCullingEnabled}set cullBackFaces(e){this.shaderTechniqueConfig.backfaceCullingEnabled!==e&&(this.shaderTechniqueConfig.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this.setNeedsRender()}set velvetOverground(e){this._velvetOverground!==e&&(this._velvetOverground=e,this.setNeedsRender())}get layerUid(){return ae}get slicePlaneEnabled(){return this.shaderTechniqueConfig.slicePlaneEnabled}set slicePlaneEnabled(e){this.shaderTechniqueConfig.slicePlaneEnabled!==e&&(this.shaderTechniqueConfig.slicePlaneEnabled=e,this.setNeedsRender())}set textureFadingEnabled(e){this.shaderTechniqueConfig.textureFadingEnabled!==e&&(this.shaderTechniqueConfig.textureFadingEnabled=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this.shaderTechniqueConfig.screenSizePerspective!==e&&(this.shaderTechniqueConfig.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setNeedsRender()}setNeedsHighlight(e){this.needsHighlight=e,this.setNeedsRender()}setRenderOccludedOverlay(e){this.renderOccludedFlags=e?I:te.Occlude,this.setNeedsRender()}setStencilEnabledLayerExtents(e){this.stencilEnabledLayerExtents=e,this.setNeedsRender()}setTileSize(e){this.tileSize=e,this.tileRenderer&&(this.tileRenderer.tileSize=e),this.setNeedsRender()}loadTile(e){e.renderData||(e.renderData=this.renderDataPool.acquire(),e.renderData.init(e),e.renderData.localOrigin=this._getLocalOriginOfTile(e)),this.updateTileGeometry(e),this.updateTileTexture(e,U.TEXTURE_FADING)}queryVisibleLevelRange(e,t,r,i){this._scaleRangeQueries.queryVisibleLevelRange(e,t,r,i),this.setNeedsRender()}updateTileTexture(e,t){this.tileRenderer&&this.tileBackgroundInitialized&&(this.tileRenderer.updateTileTexture(e,t===U.TEXTURE_FADING?D.FADING:D.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometry(e){for(const t of e.layerInfo[O.ELEVATION])t.pendingUpdates&=~U.GEOMETRY;e.resetPendingUpdate(U.GEOMETRY),e.renderData.updateGeometry(this.rctx,this.wireframe)&&this.setNeedsRender()}unloadTile(e){e.renderData&&(e.renderData.releaseGeometry()&&this.setNeedsRender(),this.renderDataPool.release(e.renderData),e.renderData.clear(),e.renderData=null,e.setMemoryDirty(),this.setNeedsRender())}_getLocalOriginOfTile(e){const t=me-ge,r=Math.max(0,Math.floor((e.level-t)/ge)*ge);if(this.isGlobal&&0===r)return g;for(;e.parent&&e.level>r;)e=e.parent;return e.centerAtSeaLevel}setVisibility(e){this.visible=e,this.setNeedsRender()}getStats(){return{numTilesRendered:this.numTilesRendered,numTilesCulled:this.numTilesCulled,numOriginsRendered:this.numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.allTiles.forAll((t=>{var r;return null==(r=t.renderData)?void 0:r.updateGeometry(this.rctx,e)})),this.setNeedsRender())}setNeedsRender(e=Z.UPDATE){this.patchGroupsDirty=!0,this.context.requestRender(e)}setTileBackground(e){this.tileBackground=e,this._updateTileBackground()}initializeRenderContext(e){this.context=e,this.rctx=e.renderContext.rctx,this.shaderTechniques=e.shaderTechniqueRep,this.shaderTechniqueConfig=new ce,this.tileRenderer=new G(this.rctx,this.tileSize,this.shaderTechniques),this.tileBackground&&this._updateTileBackground(),this.emptyTex=K(this.rctx)}uninitializeRenderContext(){null!=this.emptyTex&&(this.emptyTex.dispose(),this.emptyTex=null),this.tileRenderer&&(this.tileRenderer.dispose(),this.tileRenderer=null)}intersect(e,t,r,n){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&!this._opaque)return;const a=Ae,o=De;c(a,n,r),u(o,1/a[0],1/a[1],1/a[2]);const l=e.results.min,d=e.results.max,p=e.results.ground,g=e.options.store===ee.MIN,m=!!e.results.ground.target,T=oe(e.verticalOffset),R=this._skirtScale,b=e.tolerance;let x,A=g&&i(l.dist)?l.dist:1/0;const D=u=>{const m=u.renderData;if(null==m)return;const D=m.geometryInfo;_(Te,D.boundingBox);const E=m.localOrigin;i(T)&&(T.localOrigin=E,T.applyToAabb(Te));const O=-R*D.skirtLength;if(0!==O){const e=u.up;y(Te,O*e[0],O*e[1],O*e[2])}const P=Te;if(Ee[0]=r[0]-E[0],Ee[1]=r[1]-E[1],Ee[2]=r[2]-E[2],!de(P,Ee,o,b,A))return;const I=(e,t,r)=>{e.set(this.type,u,t,r,h),A=g&&i(l.dist)?l.dist:1/0},C=(o,h)=>{if(i(h)&&o>=0&&(e.options.backfacesTerrain||f(h,a)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(r,n,o))){if((null==p.dist||o<p.dist)&&I(p,o,h),e.options.isFiltered)return;e.options.store===ee.ALL&&(s(x)?(x=J(e.ray),I(x,o,h),e.results.all.push(x)):o<x.dist&&I(x,o,h)),(null==l.dist||o<l.dist)&&I(l,o,h),e.options.store!==ee.MIN&&(null==d.dist||o>d.dist)&&I(d,o,h)}},q=Oe;c(q,n,E);const w=D.indices,L=D.vertexAttributes,M={data:L.getField(ne.POSITION,v).typedBuffer,size:3,stride:L.stride/4},G=D.numWithoutSkirtIndices/3;if(!i(T)&&G>H){const e=u.renderData;i(e.intersectionData)||(e.intersectionData=new z(w,0,G,M)),e.intersectionData.intersectRay({r0:Ee,r1:q},C)}else he(Ee,q,0,G,w,M,null,T,C);if(0!==O){const e=w.length/3;if(this.isGlobal){const t=e-G;if(!i(T)&&t>H){const r=u.renderData;if(!i(r.skirtIntersectionData)){const i=S(w,G,e,L,O,E);r.skirtIntersectionData=new z(i.indices,0,t,{data:i.vertices,stride:3})}r.skirtIntersectionData.intersectRay({r0:Ee,r1:q},C)}else k(Ee,q,G,e,w,L,O,E,T,C)}else N(Ee,q,G,e,w,L,O,T,C)}},E=this._rootTiles;if(i(E)){(()=>{const t=this.tileIterator;t.reset(E);const s=e.options.invisibleTerrain;for(;!t.done;){const e=t.next();!(e.visible||s&&e.intersectsClippingArea)||!i(T)&&!e.intersectsRay(r,a,b,A,R)||m&&this._useStencilForTile(e)?t.skipSubtree():D(e)}})()}}prepareTechnique(e){if(e.slot===ie.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&I))return null}else{const t=this.opaque?ie.OPAQUE_TERRAIN:ie.TRANSPARENT_TERRAIN;if(e.slot!==t)return null}switch(e.pass){case re.MATERIAL:{const t=e.shadowMap&&e.shadowMap.enabled;this.shaderTechniqueConfig.receiveShadows!==t&&(this.shaderTechniqueConfig.receiveShadows=t);const r=this.overlayRenderer.isEmpty()?Y.Disabled:this.overlayRenderer.hasWater?Y.EnabledWithWater:Y.Enabled;this.shaderTechniqueConfig.overlayMode!==r&&(this.shaderTechniqueConfig.overlayMode=r);const i=e.slot===ie.OCCLUDED_TERRAIN?P.Occluded:P.ColorAndWater;return this._updateTechnique(V.Color,i===P.Occluded)}case re.MATERIAL_DEPTH_SHADOWMAP_ALL:case re.MATERIAL_DEPTH_SHADOWMAP_DEFAULT:return this.castShadows&&1===e.scenelightingData.globalFactor?this._updateTechnique(V.Shadow,!1):null;case re.MATERIAL_DEPTH:return this.isTransparent&&this.overlayRenderer.isEmpty()?null:this._updateTechnique(V.Depth,!1);case re.MATERIAL_NORMAL:return this._updateTechnique(V.Normal,!1);case re.MATERIAL_HIGHLIGHT:return this.needsHighlight?this._updateTechnique(V.Highlight,!1):null}return null}render(e,t){const r=e.pass,i=1===e.scenelightingData.globalFactor;switch(this._updatePatchGroups(),t.useStencil=!1,r){case re.MATERIAL:{const r=e.slot===ie.OCCLUDED_TERRAIN?P.Occluded:P.ColorAndWater;this._renderMaterialPass(e,t,r);break}case re.MATERIAL_DEPTH_SHADOWMAP_ALL:case re.MATERIAL_DEPTH_SHADOWMAP_DEFAULT:this.castShadows&&i&&this._renderAuxiliaryPass(e,t,P.None);break;case re.MATERIAL_DEPTH:this.isTransparent&&this.overlayRenderer.isEmpty()||this._renderAuxiliaryPass(e,t,P.None);break;case re.MATERIAL_NORMAL:this._renderAuxiliaryPass(e,t,P.None);break;case re.MATERIAL_HIGHLIGHT:this.needsHighlight&&(this._renderAuxiliaryPass(e,t,P.Highlight),e.rctx.clearSafe(pe.DEPTH_BUFFER_BIT))}this._scaleRangeQueries.hasPendingQueries()&&this.setNeedsRender()}_renderMaterialPass(e,t,r){const{rctx:i,camera:s}=e;this._ssrEnabled=e.ssrParams.ssrEnabled;const n=i.useTechnique(t,e.slot);this.shaderTechniqueConfig.overlayMode!==Y.Disabled&&r===P.ColorAndWater&&e.ssrParams&&Q(n,e.ssrParams),e.shadowMap.bind(n),e.ssaoHelper.bind(n,e.camera),this._bindOverlayData(n,r),n.setUniformMatrix4fv("viewNormal",s.viewInverseTransposeMatrix),X(n,s.projectionMatrix),e.scenelightingData.setUniforms(n,!0);const a=s.viewMatrix;u(xe,a[12],a[13],a[14]),p(xe,xe),n.setUniform3fv("viewDirection",xe),this.numTilesRendered=0,this.numTilesCulled=0,this.numOriginsRendered=0,this._scaleRangeQueries.prepareQueries(),this.opaque?this._renderPatchGroups(e,t,r):e.offscreenRenderingHelper.renderToTargets((()=>this._renderPatchGroups(e,t,r)),e.offscreenRenderingHelper.tmpColor,e.offscreenRenderingHelper.mainDepth,[0,0,0,0]),this._scaleRangeQueries.processQueries()}_renderAuxiliaryPass(e,t,r){const i=e.rctx.useTechnique(t,e.slot);if(e.pass===re.MATERIAL_HIGHLIGHT){const t=e.offscreenRenderingHelper;i.bindTexture(t.depthTexture,"depthTex"),i.setUniform4f("highlightViewportPixelSz",0,0,1/t.width,1/t.height)}else i.setUniformMatrix4fv("viewNormal",e.camera.viewInverseTransposeMatrix),e.pass!==re.MATERIAL_DEPTH&&e.pass!==re.MATERIAL_DEPTH_SHADOWMAP_ALL&&e.pass!==re.MATERIAL_DEPTH_SHADOWMAP_DEFAULT||i.setUniform2fv("nearFar",e.camera.nearFar);this._renderPatchGroupsAuxiliary(e,t,r)}_updateTileBackground(){if(!this.tileRenderer)return;this.tileBackgroundUpdating=!0;const e=()=>{this.tileBackgroundInitialized=!0,this.tileBackgroundUpdating=!1,this.shaderTechniqueConfig.useGrid=this.tileRenderer.backgroundIsGrid,this.shaderTechniqueConfig.hasBackgroundColor=!this.tileRenderer.backgroundIsGrid&&!!i(this.tileRenderer.backgroundColor),this.allTiles.forAll((e=>this.tileRenderer.updateTileTexture(e,D.FADING))),this.setNeedsRender()};if("string"==typeof this.tileBackground){const t=this.tileBackground;x(t).then((r=>{t===this.tileBackground&&this.tileRenderer&&(this.tileRenderer.setBackground(r,this.tileBackground===M),e())}))}else{const r=this.tileBackground?t.toUnitRGBA(this.tileBackground):[0,0,0,0];this.tileRenderer.setBackground(r,!1),e()}}_updatePatchGroups(){if(this.patchGroupsDirty){if(this.highestVisibleLODTile=null,this._rebuildPatchGroups(),this.renderOrder!==w.NONE){const e=Array.from(this._patchGroups.values());e.forEach((e=>B(this.renderOrder,e))),e.sort(((e,t)=>F(e[0],t[0],this.renderOrder))),this._patchGroups=new Map(e.map((e=>[e[0].renderData.localOrigin,e])))}this.patchGroupsDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(!s(e)){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||e.visible)if(e.rendered){if(r){const i=this._patchGroups.get(r.localOrigin)||new Array;this._patchGroups.set(r.localOrigin,i),i.push(e),(!this.highestVisibleLODTile||e.vlevel>this.highestVisibleLODTile.vlevel)&&(this.highestVisibleLODTile=e),t.skipSubtree()}}else this.numTilesCulled++;else this.numTilesCulled++,t.skipSubtree()}}_useStencilForTile(e){for(const t of this.stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderPatchGroupsAuxiliary(e,t,r){t.program.setUniformMatrix4fv("proj",e.camera.projectionMatrix),t.program.setUniform1f("skirtScale",this._skirtScale),r!==P.None&&this._bindOverlayData(t.program,r);const i=this.stencilEnabledLayerExtents.length>0;this._patchGroups.forEach((s=>{const n=s[0].renderData.localOrigin;this._bindPatchGroupData(t.program,n,e.camera.eye,e.camera.viewMatrix);for(let a=0;a<s.length;a++)this._renderPatch(e,t,s[a],fe.TRIANGLES,i,r)})),e.rctx.bindVAO(null)}_renderPatchGroups(e,t,r){const n=e.rctx,a=e.camera,o=a.viewMatrix,l=t.program;if(this.shaderTechniqueConfig.screenSizePerspective&&this.pointsOfInterest){const e=se(this.stage.viewingMode,this.ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:a.fovY}),le(e,l,"screenSizePerspective")}const d=this.stencilEnabledLayerExtents.length>0,h=r===P.Occluded;h&&(l.bindTexture(this.emptyTex,"tex"),l.setUniform1f("blend",1),l.setUniform4fv("texOffsetAndScale",T));const c=i(this.tileRenderer.backgroundColor)?this.tileRenderer.backgroundColor:g;this.shaderTechniqueConfig.hasBackgroundColor&&l.setUniform3fv("backgroundColor",c);const u=h?0:this._skirtScale;l.setUniform1f("skirtScale",u);const p=this.wireframe?fe.LINES:fe.TRIANGLES;this.shaderTechniqueConfig.textureFadingEnabled&&l.bindTexture(this.emptyTex,"texNext"),this._patchGroups.forEach((n=>{const c=n[0].renderData.localOrigin;this._bindPatchGroupData(l,c,a.eye,o);const u=e.sliceHelper&&e.sliceHelper.plane;W(l,t.configuration,u,c),e.shadowMap&&e.shadowMap.bindView(l,c),this.numOriginsRendered++;for(let a=0;a<n.length;a++){const o=n[a],c=o.renderData.textureReference;if(!s(c)){if(!h){this._scaleRangeQueries.scaleQueriesForTile(o),ye(o.renderData.geometryInfo.uvOffsetAndScale,c.offsetAndScale,Re),l.setUniform4fv("texOffsetAndScale",Re),l.bindTexture(c.texture.texture,"tex");const e=o.renderData.textureFadeFactor,t=e<1?o.renderData.nextTextureReference:null;this.shaderTechniqueConfig.textureFadingEnabled&&i(t)&&e<1?(ye(o.renderData.geometryInfo.uvOffsetAndScale,t.offsetAndScale,Re),l.setUniform1f("fadeFactor",e),l.setUniform4fv("nextTexOffsetAndScale",Re),l.setUniform3fv("nextTexOpacities",t.opacities),l.bindTexture(t.texture.texture,"texNext")):l.setUniform1f("fadeFactor",1),o.renderData.textureIsFading&&this.setNeedsRender(),l.setUniform3fv("textureOpacities",c.opacities)}this._renderPatch(e,t,o,p,d,r),o.renderOrder=this.numTilesRendered,this.numTilesRendered++}}})),n.bindVAO(null)}_renderPatch(e,t,r,i,n,a){if(s(r.renderData.vao.indexBuffer))return;const o=t.program;a!==P.None&&this._bindOverlayPatchData(o,r.renderData.overlay),n&&(t.useStencil=this._useStencilForTile(r),t.bindPipelineState(e.rctx,e.slot));const l=0===this._skirtScale?r.renderData.geometryInfo.numWithoutSkirtIndices:r.renderData.vao.indexBuffer.size;e.rctx.bindVAO(r.renderData.vao),o.assertCompatibleVertexAttributeLocations(r.renderData.vao),e.rctx.drawElements(i,l,r.renderData.vao.indexBuffer.indexType,0)}_bindPatchGroupData(e,t,r,i){e.setUniform3fv("origin",t),l(ve,i,t),e.setUniformMatrix4fv("view",ve),e.setUniform3f("cameraPosition",r[0]-t[0],r[1]-t[1],r[2]-t[2])}_bindOverlayData(e,t){if(this.shaderTechniqueConfig.overlayMode===Y.Disabled)return;e.setUniform1f("overlayOpacity",this.overlayOpacity);const r=this.overlayRenderer.overlays;if(r.length>E.INNER){const s=r[E.INNER],n=s.getColorTexture(t);if(e.bindTexture(i(n)?n:this.emptyTex,"ovColorTex"),this.shaderTechniqueConfig.overlayMode===Y.EnabledWithWater){const r=s.getNormalTexture(t);e.bindTexture(i(r)?r:this.emptyTex,"ovWaterTex")}}}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this.shaderTechniqueConfig.output=e,e===V.Color&&(this.shaderTechniqueConfig.atmosphere=this.isGlobal&&this._velvetOverground,this.shaderTechniqueConfig.ssrEnabled=this._ssrEnabled),this.shaderTechniqueConfig.renderOccluded=t,this.shaderTechniqueConfig.stencilEnabled=!1,this._shaderTechnique=this.shaderTechniques.releaseAndAcquire(ue,this.shaderTechniqueConfig,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this.tileRenderer}}};e([a()],be.prototype,"tileBackgroundInitialized",void 0),e([a()],be.prototype,"tileBackgroundUpdating",void 0),e([a({constructOnly:!0})],be.prototype,"overlayRenderer",void 0),e([a({constructOnly:!0})],be.prototype,"stage",void 0),e([a({readOnly:!0})],be.prototype,"isGlobal",null),e([a({constructOnly:!0})],be.prototype,"allTiles",void 0),e([a({constructOnly:!0})],be.prototype,"ellipsoidRadius",void 0),e([a({readOnly:!0})],be.prototype,"updating",null),e([a({value:!1})],be.prototype,"renderingDisabled",null),e([a()],be.prototype,"renderPatchBorders",null),e([a()],be.prototype,"cullBackFaces",null),e([a({value:w.FRONT_TO_BACK})],be.prototype,"renderOrder",null),e([a()],be.prototype,"wireframe",null),be=e([o("esri.views.3d.terrain.TerrainRenderer")],be);const _e=be;function ye(e,t,r){r[0]=e[0]*t[2]+t[0],r[1]=e[1]*t[3]+t[1],r[2]=e[2]*t[2],r[3]=e[3]*t[3]}const ve=d(),xe=m(),Ae=m(),De=m(),Ee=m(),Oe=m();export{_e as default};
|