@arcgis/core 4.29.0-next.20240222 → 4.29.1
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/arcade/treeAnalysis.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{b43fde3e25d0c3b020b5.js → 039a872509872ce67ba4.js} +1 -1
- package/assets/esri/core/workers/chunks/0bc21d2a0b65bd4e9d76.js +1 -0
- package/assets/esri/core/workers/chunks/{5243f9ff21e768c620c2.js → 23a5d750d93a7829174f.js} +1 -1
- package/assets/esri/core/workers/chunks/{47e6119be4a4a5ed640d.js → 2447a4d5886aeb0ff72a.js} +1 -1
- package/assets/esri/core/workers/chunks/{7f45a9e9bdbcffc2d6e0.js → 348bcc57b99a975902a8.js} +1 -1
- package/assets/esri/core/workers/chunks/{8c9fb2601488998013ba.js → 3523789a2948a4ab8cc8.js} +1 -1
- package/assets/esri/core/workers/chunks/{24649b410b757599a549.js → 48db6e0bbb1a9c043193.js} +1 -1
- package/assets/esri/core/workers/chunks/{752082be991f1cc8558f.js → 4984e2b79d862114d6a6.js} +1 -1
- package/assets/esri/core/workers/chunks/{8d9736fd15cdb54d9855.js → 5227f9eea6988aadad7f.js} +1 -1
- package/assets/esri/core/workers/chunks/58723274ef657fe212eb.js +1 -0
- package/assets/esri/core/workers/chunks/60ab18c6a04d4b2f1d4c.js +1 -0
- package/assets/esri/core/workers/chunks/647515801d94180b8402.js +1 -0
- package/assets/esri/core/workers/chunks/6c3ae96ec90e9ed7dd50.js +1 -0
- package/assets/esri/core/workers/chunks/7a8bba91769ee18cc39f.js +1 -0
- package/assets/esri/core/workers/chunks/7a98d2e026f63a581b1e.js +1 -0
- package/assets/esri/core/workers/chunks/8c360923cd1850767d3e.js +1 -0
- package/assets/esri/core/workers/chunks/{1a25ba411b89e050fbb7.js → a61f337802ae963d7f65.js} +1 -1
- package/assets/esri/core/workers/chunks/{d0c5318d7ef2e923aad0.js → a8ac511280f873960d46.js} +1 -1
- package/assets/esri/core/workers/chunks/b125ab84b7761e761734.js +1 -0
- package/assets/esri/core/workers/chunks/{b34d6e58b125fe111f91.js → b42a83db83851cb57d44.js} +1 -1
- package/assets/esri/core/workers/chunks/{1497dd943df7eede0704.js → b9c55ff1f21db198ce03.js} +1 -1
- package/assets/esri/core/workers/chunks/bb3322ddb89c0bd444f0.js +1 -0
- package/assets/esri/core/workers/chunks/becfdaeeb07f089d8be7.js +1 -0
- package/assets/esri/core/workers/chunks/{b26e39a399963c176d33.js → c527692694688a5b3b07.js} +2 -2
- package/assets/esri/core/workers/chunks/{210a93e0b96c5bff44a3.js → c556644bb0cf88770939.js} +1 -1
- package/assets/esri/core/workers/chunks/{e7b26c7e9e24dc6255be.js → cacf97b0a7a1057b9f79.js} +1 -1
- package/assets/esri/core/workers/chunks/{a5e7b4acae17f88e2208.js → ce93027b6b81428ce9b0.js} +1 -1
- package/assets/esri/core/workers/chunks/{b8ece275abac93f3dccf.js → d14f16bfa6c12909929c.js} +1 -1
- package/assets/esri/core/workers/chunks/{1594f06a2d7d9439c62e.js → e2147c99cc5839654be1.js} +1 -1
- package/assets/esri/core/workers/chunks/{d33ed3a2a0d4b640bd4a.js → e4c7d8c69e4957c9d27c.js} +1 -1
- package/assets/esri/core/workers/chunks/{7709248f59520aee6f51.js → eceaa46f622f6fa31128.js} +1 -1
- package/assets/esri/core/workers/chunks/{2286db4c83ff1b6fb088.js → ef3e6209e6ac6a56960b.js} +1 -1
- package/assets/esri/core/workers/chunks/f59b5ea05caca8a1a398.js +1 -0
- package/chunks/Laserlines.glsl.js +3 -3
- package/chunks/Precipitation.glsl.js +1 -1
- package/chunks/SSAOBlur.glsl.js +2 -2
- package/chunks/boundedPlane.js +1 -1
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/sphere.js +1 -1
- package/chunks/terrainUtilsPlanar.js +1 -1
- package/chunks/vec32.js +1 -1
- package/config.js +1 -1
- package/copyright.txt +56 -28
- package/core/libs/gl-matrix-2/math/quat.js +1 -1
- package/core/libs/gl-matrix-2/math/vec3.js +1 -1
- package/core/libs/gl-matrix-2/vec3.js +1 -1
- package/geometry/support/axisAngleDegrees.js +1 -1
- package/geometry/support/coordinateSystem.js +1 -1
- package/geometry/support/lineSegment.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/georeference.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils/scale.js +1 -1
- package/geometry/support/meshUtils/vertexSpaceConversion.js +5 -0
- package/geometry/support/meshVertexSpaceUtils.js +1 -1
- package/geometry/support/plane.js +1 -1
- package/geometry/support/ray.js +1 -1
- package/geometry/support/triangle.js +1 -1
- package/geometry/support/vector.js +1 -1
- package/interfaces.d.ts +12 -12
- package/kernel.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/mixins/FeatureReductionLayer.js +1 -1
- package/layers/orientedImagery/core/CameraOrientation.js +1 -1
- package/layers/orientedImagery/core/ElevationSourceDefinitions.js +1 -1
- package/layers/orientedImagery/core/coverageUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +5 -0
- package/layers/orientedImagery/transformations/updateElevation.js +5 -0
- package/layers/orientedImagery/transformations/updateElevationUtils.js +5 -0
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/orientedImagery/transformations/worldToImage.js +5 -0
- package/layers/support/EditingCapabilities.js +1 -1
- package/layers/support/editableLayers.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/video/VideoCameraSensorModel.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/layers/voxel/voxelPlaneUtils.js +1 -1
- package/libs/linkchartlayout/LinkChartLayout.js +1 -1
- package/package.json +1 -1
- package/smartMapping/renderers/pieChart.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/views/2d/arcade/callExpressionWithCursor.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/createTestMeshData.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriterInputEvaluator.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/interactive/editingTools/manipulations/ScaleManipulation.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
- package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
- package/views/2d/layers/features/layerAdapters/CatalogFootprintLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/FeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/InMemoryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/KnowledgeGraphSublayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OGCFeatureLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/OrientedImageryLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/StreamLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/SubtypeGroupLayerAdapter.js +1 -1
- package/views/2d/layers/features/processor/BinningStrategy.js +1 -1
- package/views/2d/layers/features/processor/ClusterStrategy.js +1 -1
- package/views/2d/layers/features/processor/FeatureUpdateStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/DrillDownTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/OverrideChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/PagedTileSourceChunk.js +1 -1
- package/views/2d/layers/features/sources/strategies/chunks/StreamSourceChunk.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureMetadata.js +1 -1
- package/views/2d/layers/features/support/GraphicsReader.js +1 -1
- package/views/2d/layers/features/support/Tile.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/2d/tiling/TileKey.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionConstraintUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionUtils.js +1 -1
- package/views/3d/analysis/DirectLineMeasurement/DirectLineMeasurementController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightIntersectionResult.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/analysis/support/measurementUtils.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils/common.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/Fog.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/SceneViewEnvironmentManager.js +1 -1
- package/views/3d/interactive/SnappingVisualizer3D.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/MoveZManipulation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/reshapeGraphic/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentScale.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/extentUtils.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/support/Segment.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudWorker.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LoDUtil.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTileMeasurements3D.js +1 -1
- package/views/3d/layers/support/FeatureTileVisibility3D.js +1 -1
- package/views/3d/layers/support/uvUtils.js +1 -1
- package/views/3d/state/Frustum.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/controllers/GamepadKeyboardController.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/global/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/global/ZoomController.js +1 -1
- package/views/3d/state/controllers/global/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/local/PinchAndPanController.js +1 -1
- package/views/3d/state/controllers/local/ZoomController.js +1 -1
- package/views/3d/state/controllers/local/ZoomStepController.js +1 -1
- package/views/3d/state/controllers/momentum/ZoomPlanarMomentumController.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/state/utils/viewUtils.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/cameraUtilsInternal.js +1 -1
- package/views/3d/support/intersectionUtils.js +1 -1
- package/views/3d/support/mathUtils.js +1 -1
- package/views/3d/support/orientedBoundingBox.js +1 -1
- package/views/3d/support/pointsOfInterest/CameraOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/support/pointsOfInterest/PointsOfInterest.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/support/viewpointUtils.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/SphericalPatch.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/webgl-engine/collections/Component/DepthRange.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/core/util/TwoVectorPosition.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/lib/BoundingInfo.js +1 -1
- package/views/3d/webgl-engine/lib/Camera.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/PathVertex.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgePreprocessing.js +1 -1
- package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
- package/views/3d/webgl-engine/lib/intersectorUtils.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/lighting/SceneLighting.js +1 -1
- package/views/3d/webgl-engine/lighting/SphericalHarmonics.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/MeasurementArrowMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/pbrUtils.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/draw/support/createUtils.js +1 -1
- package/views/draw/support/surfaceCoordinateSystems.js +1 -1
- package/views/interactive/GraphicManipulator.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/coordinateHelper.js +1 -1
- package/views/interactive/editGeometry/operations/OffsetEdgeVertex.js +1 -1
- package/views/interactive/editGeometry/support/editPlaneUtils.js +1 -1
- package/views/interactive/sketch/constraints.js +1 -1
- package/views/interactive/snapping/RightAngleSnapper.js +1 -1
- package/views/interactive/snapping/candidates/ParallelLineSnappingCandidate.js +1 -1
- package/views/interactive/snapping/candidates/RightAngleTriangleSnappingCandidate.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/SceneLayerSnappingSourceWorker.js +1 -1
- package/views/interactive/snapping/featureSources/sceneLayerSource/sceneLayerSnappingUtils.js +1 -1
- package/views/interactive/snapping/hints/IntersectionSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/LineSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/ParallelSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/PointSnappingHint.js +1 -1
- package/views/interactive/snapping/hints/RightAngleSnappingHint.js +1 -1
- package/views/layers/FeatureLayerView.js +1 -1
- package/views/layers/support/editableLayerViews.js +5 -0
- package/views/navigation/PanSphericalMomentumEstimator.js +1 -1
- package/views/support/angularMeasurementUtils.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/support/euclideanLengthMeasurementUtils.js +1 -1
- package/views/support/geometry3dUtils.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/support/EditorEditingCapabilities.js +1 -1
- package/widgets/Editor/support/EditorItem.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/Grid.js +1 -1
- package/widgets/FeatureTable/support/ColumnTemplateBase.js +1 -1
- package/widgets/Features/FeaturesViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/support/Selector2D/SelectionOperation.js +1 -1
- package/widgets/support/Selector2D/selectorUtils.js +1 -1
- package/assets/esri/core/workers/chunks/0e83f3718a0b45652b5e.js +0 -1
- package/assets/esri/core/workers/chunks/1fa5c8af69a09a3730b3.js +0 -1
- package/assets/esri/core/workers/chunks/25f73748df0ee82d06cb.js +0 -1
- package/assets/esri/core/workers/chunks/2d7a18f8c540269ecee9.js +0 -1
- package/assets/esri/core/workers/chunks/4736f79b5c94ce103d43.js +0 -1
- package/assets/esri/core/workers/chunks/65f7adaaf1f535310c11.js +0 -1
- package/assets/esri/core/workers/chunks/79c041b292648c5eaecc.js +0 -1
- package/assets/esri/core/workers/chunks/7c4c2c0beddabac672b6.js +0 -1
- package/assets/esri/core/workers/chunks/9a758de08dfa57735879.js +0 -1
- package/assets/esri/core/workers/chunks/a4c3da057ec2a07bbbe8.js +0 -1
- package/assets/esri/core/workers/chunks/b252270b100351779f1f.js +0 -1
- package/assets/esri/core/workers/chunks/dc57aa9f2fc69e654559.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import has from"../../../core/has.js";import{clamp as i,deg2rad as a}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{watch as o,sync as l}from"../../../core/reactiveUtils.js";import{Milliseconds as h}from"../../../core/time.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{subtract as u}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{g as p,f as m,v as _,c as y,p as g}from"../../../chunks/vec32.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as v,d as R,g as w}from"../../../chunks/vec42.js";import{create as O,fromValues as T}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as x}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as D}from"../../../geometry/projection/projectVectorToVector.js";import{create as S,width as E,copy as P,center as M,height as j,intersection as b,contains as I,intersects as C,offset as U}from"../../../geometry/support/aaBoundingRect.js";import{create as N,wrap as A}from"../../../geometry/support/ray.js";import{j as L,k as G,t as V}from"../../../chunks/sphere.js";import{angleAroundAxis as q}from"../../../geometry/support/vector.js";import{y2lat as F}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as B}from"../state/utils/viewUtils.js";import{debugFlags as k}from"../support/debugFlags.js";import{PointGraphics as H}from"../support/debugUtils.js";import{OverlayIndex as W}from"./interfaces.js";import{OverlayRenderer as Y}from"./OverlayRenderer.js";import{RenderRequestType as z}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as X}from"../webgl-engine/lib/Intersector.js";import{fromValues as K}from"../webgl-engine/lib/LocalOriginFactory.js";import{UpdateParameters as Z}from"../webgl-engine/lib/Material.js";import{SortedRenderGeometryRenderer as J}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{applyTextureResizeModulo as Q}from"../webgl-engine/lib/textureUtils.js";import{removeLoadedShaderModules as $}from"../webgl-engine/parts/requireUtils.js";import{TaskPriority as ee,noBudget as te}from"../../support/Scheduler.js";import{Yield as re}from"../../support/Yield.js";const se=1.3,ie=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let ae,ne=class extends t{constructor(e){super(e),this._spatialReference=null,this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._longitudeCyclical=null,this._latestOriginId=0,this._maxResolution=has("esri-mobile")?2048:4096,this._animationTimeLast=0}initialize(){const e=this.view;this.renderer=new Y({view:e,worldToPCSRatio:this._worldToPCSRatio,spatialReference:this._spatialReference}),e._stage.renderer.plugins.add(this.renderer);const t=()=>this.setDrawTexturesDirty();this._groundIntersector=X(this.view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this.addHandles([o((()=>this.renderer.hasHighlights),t),this.renderer.events.on("has-water",(t=>e._stage?.renderer.setParameters({hasOverlayWater:t}))),this.renderer.events.on("content-changed",t),o((()=>e.state.camera.pixelRatio),t),o((()=>e.state.alignPixelEnabled),t),this.renderer.events.on("textures-disposed",(()=>this.surface.requestRender())),o((()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location]),(()=>this.setPlacementDirty())),o((()=>[e.state?.pixelRatio,e.state?.contentPixelRatio]),(()=>this.setPlacementDirty()),l),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),e.resourceController.scheduler.registerTask(ee.OVERLAY,this),e._stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(te,e.camera,z.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlays(z.BACKGROUND,e)}))]),e._stage.renderer.renderOverlay=e=>this._renderOverlay(e)}destroy(){this.view?._stage&&(this.view._stage.renderer.plugins.remove(this.renderer),this.view._stage.renderer.renderOverlay=()=>{}),ae&&(ae.hide(),ae=null),this.renderer=n(this.renderer)}get running(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||k.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this.view.state.isGlobal}get _worldToPCSRatio(){return null!=this._spatialReference&&this._spatialReference.isGeographic&&!this.view.state.isLocal?x(this._spatialReference).metersPerDegree:1}get _overlayStretch(){return se/this.view.resolutionScale}get suspended(){return this.surface.suspended}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get rendersOccludedDraped(){return this.renderer.rendersOccludedDraped}_renderOverlay(e){if(this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays)return this._dispatchAnimationUpdate(e),this._drawOverlays(z.UPDATE,this.view.state)}get hasOverlays(){return this.renderer.hasOverlays}setSpatialReference(e){this._spatialReference=e,this.renderer.spatialReference=e,this._longitudeCyclical=null;const t=this.view.renderSpatialReference;null!=e&&null!=t?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this._longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180),this.renderer.longitudeCyclical=this._longitudeCyclical),this.renderer&&(this.renderer.worldToPCSRatio=this._worldToPCSRatio)):this.renderer.disposeOverlays()}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,J)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&null!=e.setDrapingExtent&&null!=this._spatialReference&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.setDrawTexturesDirty()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this._updateOverlays(e,this.view.state.contentCamera,z.UPDATE)}_updateOverlays(e,t,r){if(!this._spatialReference)return re;const s=this._computeOverlayResolution(t);this._computeOverlayExtents(t,s,de),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources,de.stretch);const i=this._updateOverlay(W.INNER,de.inner,s,1*de.pixelRatioAdjustment,de.mapUnitsPerPixel),a=E(de.inner)/E(de.outer),n=this._updateOverlay(W.OUTER,de.outer,s,a*de.pixelRatioAdjustment,de.mapUnitsPerPixel);i!==_e.EXTENT&&n!==_e.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.surface.updateTileOverlayParams(r)),i===_e.NONE&&n===_e.NONE||this.setDrawTexturesDirty(),this._placementDirty=!1,e.madeProgress()}_computeOverlayResolution(e){const t=this.view.state.contentPixelRatio*this.view.resolutionScale,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t,i=Math.ceil(1.5*Math.max(r,s));return Math.min(Q(i),this._maxResolution)}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return _e.NONE;const a=this.renderer.overlays[e],n=a.mapUnitsPerPixel;if(a.mapUnitsPerPixel=i,a.pixelRatio=s,oe(t,a.extent)&&r===a.resolution)return n===i?_e.NONE:_e.RERENDER_ONLY;P(a.extent,t),a.resolution=r;const o=M(a.extent);return a.renderLocalOrigin=K(o[0],o[1],0,"OV_"+this._latestOriginId++),_e.EXTENT}setTileParameters(e){const t=e.renderData.overlay;if(this.renderer.overlays.length>0){const r=this.renderer.overlays[W.INNER],s=this.renderer.overlays[W.OUTER],i=e.extent;this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,W.INNER,t),this._setTileOverlayData(i,W.OUTER,t)):(this._clearTileOverlayData(W.INNER,t),this._clearTileOverlayData(W.OUTER,t))}else this._clearTileOverlayData(W.INNER,t),this._clearTileOverlayData(W.OUTER,t)}overlayPixelSizeInMapUnits(e,t){if(0===this.renderer.overlays.length)return t();const r=this.renderer.overlays[W.INNER],s=this.renderer.overlays[W.OUTER],i=this._pointIsInExtent(e,r.extent)?r:s;return(i.extent[2]-i.extent[0])/i.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=E(s),a=j(s);let n=e[0];if(this._longitudeCyclical){n=this._longitudeCyclical.minimalMonotonic(s[0],n);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);n>t&&(n=t-(e[2]-e[0]))}r.setScale(t,E(e)/i,j(e)/a),r.setOffset(t,(n-s[0])/i,(e[1]-s[1])/a)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}async reloadShaders(){$(),await this.renderer.reloadShaders(),this.setDrawTexturesDirty(),this.runTask(te)}_dispatchAnimationUpdate(e){const t=h(e-this._animationTimeLast);if(t>=this.surface.view._stage.renderer.animationTimestep||null!=this.view.state.forcedAnimationTime||this._drawTexturesDirty||this._drawTexturesAnimateDirty){const r=h(t/this.surface.view._stage.renderer.animationTimeDilation),s=new Z(this.view.state.camera,r,this.view.state.forcedAnimationTime);this.renderer.updateAnimation(s)&&(this._drawTexturesAnimateDirty=!0),this._animationTimeLast=e}}setDrawTexturesDirty(){this.renderer.hasOverlays?(this._contentUpdated=!0,this._drawTexturesDirty=!0,this.view._stage.renderView.requestRender()):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s){const i=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,me,t,r);if(null==i)return!1;const a=i.origin,n=p(ce,i.origin,i.direction);return this._groundIntersector.reset(a,n,e),this._groundIntersector.intersect([]),this.view.basemapTerrain.intersect(this._groundIntersector,null,a,n),this._groundIntersector.results.min.getIntersectionPoint(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const a=.55,n=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=i(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:n+l,e.aboveGround?n-l:1/0),c=e.aboveGround;if("global"===this.view.viewingMode){const t=ce;L(G(V,x(this.view.spatialReference).radius+h),A(e.eye,e.viewForward),t),m(t,t,e.eye);const i=s.normalize(q(e.viewForward,t,e.viewRight))/e.fovY+.5,n=i<=0||i>=1?.5:a;r=c?n*i:i+n*(1-i)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),n=T(0,s,1,0),o=v(n,n,e.projectionMatrix)[1],l=i(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*a:1-(1-l)*a}return!!this._intersectGroundFromView(e,.5,r,t)&&_(t,e.eye)<o.distance*o.distance}_computeOverlayExtents(e,t,r){const s=this.view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=f();this._findHorizonBasedPointOfInterest(e,i)||y(i,s),k.OVERLAY_SHOW_CENTER?(null==ae&&(ae=new H(this.view.graphics,"red")),ae.show(i,this._renderSR)):null!=ae&&ae.hide();const n=Math.max(.1,g(e.eye,i)),o=B(this.view.renderCoordsHelper,s,e.eye);this._overlaySREqualsRenderSR||D(i,this._renderSR,i,this._spatialReference);const l=this.surface.extent,h=!this._isSpherical&&this._spatialReference&&this._spatialReference.isGeographic,c=h&&this._spatialReference?1/x(this._spatialReference).metersPerDegree:1,d=this.view.state.contentPixelRatio,p=e.perScreenPixelRatio/d*n*c;r.mapUnitsPerPixel=p/this._worldToPCSRatio,r.stretch=this._overlayStretch;let m=t*p/2*r.stretch,_=!1,v=h?90:1/0;this._isSpherical&&l&&this._spatialReference&&(this._spatialReference.isWebMercator?(m/=Math.cos(F(i[1])),v=l[3]):(_=!0,m/=x(this._spatialReference).metersPerDegree,v=90),m>=v&&(m=v,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let O=1;_&&(O=1/Math.max(.2,Math.cos(Math.abs(a(i[1])))),m*O>180&&(O=180/m),r.mapUnitsPerPixel*=O);const T=Math.log(2)/12;m=Math.exp(Math.round(Math.log(m)/T)*T);const S=m*O,M=32,j=.5*t/(M*S),C=.5*t/(M*m);i[0]=Math.round(i[0]*j)/j,i[1]=Math.round(i[1]*C)/C;const U=r.inner;U[0]=i[0]-S,U[1]=i[1]-m,U[2]=i[0]+S,U[3]=i[1]+m,this._isSpherical&&this._shiftExtentToFitBounds(U,1/0,v);const N=r.outer;if(6*S>E(l))P(N,l);else{if(Math.PI/2-Math.abs(o-Math.PI/2)<=.25*Math.PI)N[0]=U[0]-S,N[1]=U[1]-m,N[2]=U[2]+S,N[3]=U[3]+m;else{D(e.eye,this._renderSR,ce,this._spatialReference),u(he,i,ce);let t=-Math.atan2(he[1],he[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));R(he,ie[r],2*m),he[0]*=O,he[2]*=O,w(N,U,he)}}if(this._isSpherical)N[0]=this._longitudeCyclical.clamp(N[0]),N[2]=this._longitudeCyclical.clamp(N[2]),N[1]=Math.max(N[1],-v),N[3]=Math.min(N[3],v);else{const e=b(U,l,ue),t=b(N,l,pe);I(e,t)&&(N[2]=N[0],N[3]=N[1])}const A=Math.abs(U[2]-U[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,A),r.pixelRatioAdjustment=r.mapUnitsPerPixel/A}_drawOverlays(e,t){if(!this.renderer.hasOverlays)return;if(!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return this.renderer;const r=this._drawTexturesDirty;this._drawTexturesDirty=this._drawTexturesAnimateDirty=!1;const s=this.renderer.computeValidity();this.renderer.releaseRenderTargets(),this.renderer.drawOverlays(t);return s!==this.renderer.computeValidity()&&this.surface.updateTileOverlayParams(z.UPDATE),r?(this.surface.requestRender(e),e===z.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender(z.BACKGROUND),this.renderer}_rectanglesOverlap(e,t){return null!=e&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):C(e,t))}_rectInsideRect(e,t){return null!=t&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:I(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),U(e,s,i)}get test(){return{renderer:this.renderer,update:()=>this.runTask(te)}}};function oe(e,t){const r=1e-5,s=k.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([c()],ne.prototype,"_spatialReference",void 0),e([c({readOnly:!0})],ne.prototype,"running",null),e([c()],ne.prototype,"_placementDirty",void 0),e([c()],ne.prototype,"_contentUpdated",void 0),e([c()],ne.prototype,"_isSpherical",null),e([c()],ne.prototype,"_worldToPCSRatio",null),e([c()],ne.prototype,"renderer",void 0),e([c({constructOnly:!0})],ne.prototype,"view",void 0),e([c({constructOnly:!0})],ne.prototype,"surface",void 0),e([c()],ne.prototype,"suspended",null),e([c()],ne.prototype,"updating",null),e([c({type:Boolean})],ne.prototype,"rendersOccludedDraped",null),ne=e([d("esri.views.3d.terrain.OverlayManager")],ne);class le{constructor(){this.inner=S(),this.outer=S(),this.mapUnitsPerPixel=0,this.pixelRatioAdjustment=1,this.stretch=se}}const he=O(),ce=f(),de=new le,ue=S(),pe=S(),me=N();var _e;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(_e||(_e={}));export{ne as OverlayManager};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../core/Accessor.js";import{Cyclical as r,cyclicalPI as s}from"../../../core/Cyclical.js";import has from"../../../core/has.js";import{clamp as i,deg2rad as a}from"../../../core/mathUtils.js";import{destroyMaybe as n}from"../../../core/maybe.js";import{watch as o,sync as l}from"../../../core/reactiveUtils.js";import{Milliseconds as h}from"../../../core/time.js";import{property as c}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as d}from"../../../core/accessorSupport/decorators/subclass.js";import{subtract as u}from"../../../core/libs/gl-matrix-2/math/vec2.js";import{g as p,f as m,w as _,c as y,q as g}from"../../../chunks/vec32.js";import{create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{t as v,d as R,g as w}from"../../../chunks/vec42.js";import{create as O,fromValues as T}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{getReferenceEllipsoid as x}from"../../../geometry/ellipsoidUtils.js";import{projectVectorToVector as D}from"../../../geometry/projection/projectVectorToVector.js";import{create as S,width as E,copy as P,center as M,height as j,intersection as b,contains as I,intersects as C,offset as U}from"../../../geometry/support/aaBoundingRect.js";import{create as N,wrap as A}from"../../../geometry/support/ray.js";import{j as L,k as G,t as q}from"../../../chunks/sphere.js";import{angleAroundAxis as V}from"../../../geometry/support/vector.js";import{y2lat as F}from"../../../geometry/support/webMercatorUtils.js";import{viewAngle as B}from"../state/utils/viewUtils.js";import{debugFlags as k}from"../support/debugFlags.js";import{PointGraphics as H}from"../support/debugUtils.js";import{OverlayIndex as W}from"./interfaces.js";import{OverlayRenderer as Y}from"./OverlayRenderer.js";import{RenderRequestType as z}from"../webgl-engine/lib/basicInterfaces.js";import{newIntersector as X}from"../webgl-engine/lib/Intersector.js";import{fromValues as K}from"../webgl-engine/lib/LocalOriginFactory.js";import{UpdateParameters as Z}from"../webgl-engine/lib/Material.js";import{SortedRenderGeometryRenderer as J}from"../webgl-engine/lib/SortedRenderGeometryRenderer.js";import{applyTextureResizeModulo as Q}from"../webgl-engine/lib/textureUtils.js";import{removeLoadedShaderModules as $}from"../webgl-engine/parts/requireUtils.js";import{TaskPriority as ee,noBudget as te}from"../../support/Scheduler.js";import{Yield as re}from"../../support/Yield.js";const se=1.3,ie=[[-.1,-2,3.9,2],[-.1,-3.9,3.9,.1],[-2,-3.9,2,.1],[-3.9,-3.9,.1,.1],[-3.9,-2,.1,2],[-3.9,-.1,.1,3.9],[-2,-.1,2,3.9],[-.1,-.1,3.9,3.9]];let ae,ne=class extends t{constructor(e){super(e),this._spatialReference=null,this._renderSR=null,this._overlaySREqualsRenderSR=!0,this._drapeSources=new Set,this._drapeTargets=new Set,this._placementDirty=!1,this._contentUpdated=!1,this._drawTexturesDirty=!1,this._drawTexturesAnimateDirty=!1,this._longitudeCyclical=null,this._latestOriginId=0,this._maxResolution=has("esri-mobile")?2048:4096,this._animationTimeLast=0}initialize(){const e=this.view;this.renderer=new Y({view:e,worldToPCSRatio:this._worldToPCSRatio,spatialReference:this._spatialReference}),e._stage.renderer.plugins.add(this.renderer);const t=()=>this.setDrawTexturesDirty();this._groundIntersector=X(this.view.state.viewingMode),this._groundIntersector.options.backfacesTerrain=!0,this._groundIntersector.options.invisibleTerrain=!0,this._groundIntersector.options.hud=!1,this.addHandles([o((()=>this.renderer.hasHighlights),t),this.renderer.events.on("has-water",(t=>e._stage?.renderer.setParameters({hasOverlayWater:t}))),this.renderer.events.on("content-changed",t),o((()=>e.state.camera.pixelRatio),t),o((()=>e.state.alignPixelEnabled),t),this.renderer.events.on("textures-disposed",(()=>this.surface.requestRender())),o((()=>[e.pointsOfInterest?.renderPointOfView,e.pointsOfInterest?.centerOnSurfaceFrequent?.location]),(()=>this.setPlacementDirty())),o((()=>[e.state?.pixelRatio,e.state?.contentPixelRatio]),(()=>this.setPlacementDirty()),l),this.surface.on("elevation-change",(()=>this.setPlacementDirty())),e.on("resize",(()=>this.setPlacementDirty())),e.resourceController.scheduler.registerTask(ee.OVERLAY,this),e._stage.renderView.events.on("force-camera-for-screenshot",(e=>{this._updateOverlays(te,e.camera,z.BACKGROUND),this.renderer.hasOverlays&&this._drawOverlays(z.BACKGROUND,e)}))]),e._stage.renderer.renderOverlay=e=>this._renderOverlay(e)}destroy(){this.view?._stage&&(this.view._stage.renderer.plugins.remove(this.renderer),this.view._stage.renderer.renderOverlay=()=>{}),ae&&(ae.hide(),ae=null),this.renderer=n(this.renderer)}get running(){return this._placementDirty&&(this._drapeSources.size>0||this.view.graphics.length>0||k.OVERLAY_DRAW_DEBUG_TEXTURE)&&!!this._spatialReference&&!this.suspended&&this.surface.ready}get _isSpherical(){return this.view.state.isGlobal}get _worldToPCSRatio(){return null!=this._spatialReference&&this._spatialReference.isGeographic&&!this.view.state.isLocal?x(this._spatialReference).metersPerDegree:1}get _overlayStretch(){return se/this.view.resolutionScale}get suspended(){return this.surface.suspended}get updating(){return this.running||this.renderer.updating||this._contentUpdated}get rendersOccludedDraped(){return this.renderer.rendersOccludedDraped}_renderOverlay(e){if(this._contentUpdated=!1,this.renderer.processSyncDrapeSources(),this.renderer.hasOverlays)return this._dispatchAnimationUpdate(e),this._drawOverlays(z.UPDATE,this.view.state)}get hasOverlays(){return this.renderer.hasOverlays}setSpatialReference(e){this._spatialReference=e,this.renderer.spatialReference=e,this._longitudeCyclical=null;const t=this.view.renderSpatialReference;null!=e&&null!=t?(this._renderSR=t,this._overlaySREqualsRenderSR=e.equals(this._renderSR),this._isSpherical&&(this._longitudeCyclical=e.isWebMercator?new r(-20037508.342787,20037508.342787):new r(-180,180),this.renderer.longitudeCyclical=this._longitudeCyclical),this.renderer&&(this.renderer.worldToPCSRatio=this._worldToPCSRatio)):this.renderer.disposeOverlays()}registerDrapeSource(e,t,r){this._drapeSources.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources);const s=this.renderer.createDrapeSourceRenderer(e,t,r);return this._updateDrapeSourceExtent(e),this._setContentDirty(),this.notifyChange("running"),s}registerGeometryDrapeSource(e){return this.registerDrapeSource(e,J)}_updateDrapeSourceExtent(e){2===this.renderer.overlays.length&&null!=e.setDrapingExtent&&null!=this._spatialReference&&e.setDrapingExtent(this.renderer.overlays,this._spatialReference)}unregisterDrapeSource(e){this._drapeSources.has(e)&&(this._drapeSources.delete(e),this.renderer.removeDrapeSourceRenderer(e),this.renderer.ensureDrapeSources(this._drapeSources),this._setContentDirty(),this.notifyChange("running"))}registerDrapeTarget(e){this._drapeTargets.add(e),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources)}unregisterDrapeTarget(e){this._drapeTargets.delete(e),this.renderer.ensureDrapeTargets(this._drapeTargets)}_setContentDirty(){this.setPlacementDirty(),this.setDrawTexturesDirty()}setPlacementDirty(){this._placementDirty=!0}runTask(e){return this._updateOverlays(e,this.view.state.contentCamera,z.UPDATE)}_updateOverlays(e,t,r){if(!this._spatialReference)return re;const s=this._computeOverlayResolution(t);this._computeOverlayExtents(t,s,de),this.renderer.ensureOverlays(this._drapeTargets,this._drapeSources,de.stretch);const i=this._updateOverlay(W.INNER,de.inner,s,1*de.pixelRatioAdjustment,de.mapUnitsPerPixel),a=E(de.inner)/E(de.outer),n=this._updateOverlay(W.OUTER,de.outer,s,a*de.pixelRatioAdjustment,de.mapUnitsPerPixel);i!==_e.EXTENT&&n!==_e.EXTENT||(this._drapeSources.forEach((e=>this._updateDrapeSourceExtent(e))),this.surface.updateTileOverlayParams(r)),i===_e.NONE&&n===_e.NONE||this.setDrawTexturesDirty(),this._placementDirty=!1,e.madeProgress()}_computeOverlayResolution(e){const t=this.view.state.contentPixelRatio*this.view.resolutionScale,r=e.fullWidth/e.pixelRatio*t,s=e.fullHeight/e.pixelRatio*t,i=Math.ceil(1.5*Math.max(r,s));return Math.min(Q(i),this._maxResolution)}_updateOverlay(e,t,r,s,i){if(0===this.renderer.overlays.length)return _e.NONE;const a=this.renderer.overlays[e],n=a.mapUnitsPerPixel;if(a.mapUnitsPerPixel=i,a.pixelRatio=s,oe(t,a.extent)&&r===a.resolution)return n===i?_e.NONE:_e.RERENDER_ONLY;P(a.extent,t),a.resolution=r;const o=M(a.extent);return a.renderLocalOrigin=K(o[0],o[1],0,"OV_"+this._latestOriginId++),_e.EXTENT}setTileParameters(e){const t=e.renderData.overlay;if(this.renderer.overlays.length>0){const r=this.renderer.overlays[W.INNER],s=this.renderer.overlays[W.OUTER],i=e.extent;this._rectInsideRect(r.extent,i)||this._rectanglesOverlap(i,r.extent)||this._rectanglesOverlap(i,s.extent)?(this._setTileOverlayData(i,W.INNER,t),this._setTileOverlayData(i,W.OUTER,t)):(this._clearTileOverlayData(W.INNER,t),this._clearTileOverlayData(W.OUTER,t))}else this._clearTileOverlayData(W.INNER,t),this._clearTileOverlayData(W.OUTER,t)}overlayPixelSizeInMapUnits(e,t){if(0===this.renderer.overlays.length)return t();const r=this.renderer.overlays[W.INNER],s=this.renderer.overlays[W.OUTER],i=this._pointIsInExtent(e,r.extent)?r:s;return(i.extent[2]-i.extent[0])/i.resolution}_setTileOverlayData(e,t,r){if(0===this.renderer.overlays.length)return;const s=this.renderer.overlays[t].extent,i=E(s),a=j(s);let n=e[0];if(this._longitudeCyclical){n=this._longitudeCyclical.minimalMonotonic(s[0],n);const t=this._longitudeCyclical.minimalMonotonic(s[0],e[2]);n>t&&(n=t-(e[2]-e[0]))}r.setScale(t,E(e)/i,j(e)/a),r.setOffset(t,(n-s[0])/i,(e[1]-s[1])/a)}_clearTileOverlayData(e,t){t.setScale(e,-1,-1),t.setOffset(e,-1,-1)}async reloadShaders(){$(),await this.renderer.reloadShaders(),this.setDrawTexturesDirty(),this.runTask(te)}_dispatchAnimationUpdate(e){const t=h(e-this._animationTimeLast);if(t>=this.surface.view._stage.renderer.animationTimestep||null!=this.view.state.forcedAnimationTime||this._drawTexturesDirty||this._drawTexturesAnimateDirty){const r=h(t/this.surface.view._stage.renderer.animationTimeDilation),s=new Z(this.view.state.camera,r,this.view.state.forcedAnimationTime);this.renderer.updateAnimation(s)&&(this._drawTexturesAnimateDirty=!0),this._animationTimeLast=e}}setDrawTexturesDirty(){this.renderer.hasOverlays?(this._contentUpdated=!0,this._drawTexturesDirty=!0,this.view._stage.renderView.requestRender()):this.setPlacementDirty()}_intersectGroundFromView(e,t,r,s){const i=this.view.sceneIntersectionHelper.getCenterRayWithSubpixelOffset(e,me,t,r);if(null==i)return!1;const a=i.origin,n=p(ce,i.origin,i.direction);return this._groundIntersector.reset(a,n,e),this._groundIntersector.intersect([]),this.view.basemapTerrain.intersect(this._groundIntersector,null,a,n),this._groundIntersector.results.min.getIntersectionPoint(s)}_findHorizonBasedPointOfInterest(e,t){let r=.5;const a=.55,n=this.view.renderCoordsHelper.getAltitude(e.eye),o=this.view.pointsOfInterest.centerOnSurfaceFrequent,l=1e-5,h=i(o.estimatedSurfaceAltitude,e.aboveGround?-1/0:n+l,e.aboveGround?n-l:1/0),c=e.aboveGround;if("global"===this.view.viewingMode){const t=ce;L(G(q,x(this.view.spatialReference).radius+h),A(e.eye,e.viewForward),t),m(t,t,e.eye);const i=s.normalize(V(e.viewForward,t,e.viewRight))/e.fovY+.5,n=i<=0||i>=1?.5:a;r=c?n*i:i+n*(1-i)}else{const t=.5*Math.PI-Math.acos(-e.viewForward[2]),s=Math.tan(t),n=T(0,s,1,0),o=v(n,n,e.projectionMatrix)[1],l=i(.5+.5*o,0,1);r=1===l||0===l?.5:c?l*a:1-(1-l)*a}return!!this._intersectGroundFromView(e,.5,r,t)&&_(t,e.eye)<o.distance*o.distance}_computeOverlayExtents(e,t,r){const s=this.view.pointsOfInterest.centerOnSurfaceFrequent.renderLocation,i=f();this._findHorizonBasedPointOfInterest(e,i)||y(i,s),k.OVERLAY_SHOW_CENTER?(null==ae&&(ae=new H(this.view.graphics,"red")),ae.show(i,this._renderSR)):null!=ae&&ae.hide();const n=Math.max(.1,g(e.eye,i)),o=B(this.view.renderCoordsHelper,s,e.eye);this._overlaySREqualsRenderSR||D(i,this._renderSR,i,this._spatialReference);const l=this.surface.extent,h=!this._isSpherical&&this._spatialReference&&this._spatialReference.isGeographic,c=h&&this._spatialReference?1/x(this._spatialReference).metersPerDegree:1,d=this.view.state.contentPixelRatio,p=e.perScreenPixelRatio/d*n*c;r.mapUnitsPerPixel=p/this._worldToPCSRatio,r.stretch=this._overlayStretch;let m=t*p/2*r.stretch,_=!1,v=h?90:1/0;this._isSpherical&&l&&this._spatialReference&&(this._spatialReference.isWebMercator?(m/=Math.cos(F(i[1])),v=l[3]):(_=!0,m/=x(this._spatialReference).metersPerDegree,v=90),m>=v&&(m=v,i[1]=0,this._spatialReference.isWebMercator&&(i[0]=0)));let O=1;_&&(O=1/Math.max(.2,Math.cos(Math.abs(a(i[1])))),m*O>180&&(O=180/m),r.mapUnitsPerPixel*=O);const T=Math.log(2)/12;m=Math.exp(Math.round(Math.log(m)/T)*T);const S=m*O,M=32,j=.5*t/(M*S),C=.5*t/(M*m);i[0]=Math.round(i[0]*j)/j,i[1]=Math.round(i[1]*C)/C;const U=r.inner;U[0]=i[0]-S,U[1]=i[1]-m,U[2]=i[0]+S,U[3]=i[1]+m,this._isSpherical&&this._shiftExtentToFitBounds(U,1/0,v);const N=r.outer;if(6*S>E(l))P(N,l);else{if(Math.PI/2-Math.abs(o-Math.PI/2)<=.25*Math.PI)N[0]=U[0]-S,N[1]=U[1]-m,N[2]=U[2]+S,N[3]=U[3]+m;else{D(e.eye,this._renderSR,ce,this._spatialReference),u(he,i,ce);let t=-Math.atan2(he[1],he[0])+.125*Math.PI;t<0&&(t+=2*Math.PI);const r=Math.floor(t/(.25*Math.PI));R(he,ie[r],2*m),he[0]*=O,he[2]*=O,w(N,U,he)}}if(this._isSpherical)N[0]=this._longitudeCyclical.clamp(N[0]),N[2]=this._longitudeCyclical.clamp(N[2]),N[1]=Math.max(N[1],-v),N[3]=Math.min(N[3],v);else{const e=b(U,l,ue),t=b(N,l,pe);I(e,t)&&(N[2]=N[0],N[3]=N[1])}const A=Math.abs(U[2]-U[0])/t;r.mapUnitsPerPixel=Math.max(r.mapUnitsPerPixel,A),r.pixelRatioAdjustment=r.mapUnitsPerPixel/A}_drawOverlays(e,t){if(!this.renderer.hasOverlays)return;if(!this._drawTexturesDirty&&!this._drawTexturesAnimateDirty)return this.renderer;const r=this._drawTexturesDirty;this._drawTexturesDirty=this._drawTexturesAnimateDirty=!1;const s=this.renderer.computeValidity();this.renderer.releaseRenderTargets(),this.renderer.drawOverlays(t);return s!==this.renderer.computeValidity()&&this.surface.updateTileOverlayParams(z.UPDATE),r?(this.surface.requestRender(e),e===z.UPDATE&&this.surface.requestUpdate()):this.surface.requestRender(z.BACKGROUND),this.renderer}_rectanglesOverlap(e,t){return null!=e&&(this._longitudeCyclical?(this._longitudeCyclical.contains(t[0],t[2],e[0])||this._longitudeCyclical.contains(t[0],t[2],e[2])||this._longitudeCyclical.contains(e[0],e[2],t[0]))&&!(e[1]>t[3]||e[3]<t[1]):C(e,t))}_rectInsideRect(e,t){return null!=t&&(this._longitudeCyclical?this._longitudeCyclical.contains(e[0],e[2],t[0])&&this._longitudeCyclical.contains(e[0],e[2],t[2])&&t[1]>e[1]&&t[3]<e[3]:I(e,t))}_pointIsInExtent(e,t){if(this._longitudeCyclical)return this._longitudeCyclical.contains(t[0],t[2],e.x)&&e.y>=t[1]&&e.y<=t[3];const r=e.x,s=e.y;return r>t[0]&&r<t[2]&&s>t[1]&&s<t[3]}_shiftExtentToFitBounds(e,t,r){let s=0,i=0;e[0]<-t?s=e[0]+t:e[2]>t&&(s=t-e[2]),e[1]<-r?i=e[1]+r:e[3]>r&&(i=r-e[3]),U(e,s,i)}get test(){return{renderer:this.renderer,update:()=>this.runTask(te)}}};function oe(e,t){const r=1e-5,s=k.TESTS_DISABLE_OPTIMIZATIONS?0:r*Math.max(e[2]-e[0],e[3]-e[1],t[2]-t[0],t[3]-t[1]);return Math.abs(t[0]-e[0])<=s&&Math.abs(t[1]-e[1])<=s&&Math.abs(t[2]-e[2])<=s&&Math.abs(t[3]-e[3])<=s}e([c()],ne.prototype,"_spatialReference",void 0),e([c({readOnly:!0})],ne.prototype,"running",null),e([c()],ne.prototype,"_placementDirty",void 0),e([c()],ne.prototype,"_contentUpdated",void 0),e([c()],ne.prototype,"_isSpherical",null),e([c()],ne.prototype,"_worldToPCSRatio",null),e([c()],ne.prototype,"renderer",void 0),e([c({constructOnly:!0})],ne.prototype,"view",void 0),e([c({constructOnly:!0})],ne.prototype,"surface",void 0),e([c()],ne.prototype,"suspended",null),e([c()],ne.prototype,"updating",null),e([c({type:Boolean})],ne.prototype,"rendersOccludedDraped",null),ne=e([d("esri.views.3d.terrain.OverlayManager")],ne);class le{constructor(){this.inner=S(),this.outer=S(),this.mapUnitsPerPixel=0,this.pixelRatioAdjustment=1,this.stretch=se}}const he=O(),ce=f(),de=new le,ue=S(),pe=S(),me=N();var _e;!function(e){e[e.NONE=0]="NONE",e[e.EXTENT=1]="EXTENT",e[e.RERENDER_ONLY=2]="RERENDER_ONLY"}(_e||(_e={}));export{ne as OverlayManager};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{p as i,m as s,C as o,f as a,n,j as l,y as g,F as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{NeighborIndex as y}from"./ITile.js";import{LayerClass as _}from"./LayerClass.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as v}from"./TerrainConst.js";import{enableTerrainInternalChecks as E,internalAssert as $,neighborEdgeIndices as C,oppositeEdge as S,neighborCornerIndices as D,v32s as T,lij2s as b}from"./terrainUtils.js";import{TextureFader as j,ActivationTime as A}from"./TextureFader.js";import{isEdgeNeighbor as V}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as P}from"../../webgl/BufferObject.js";import{PixelFormat as F}from"../../webgl/enums.js";class G{constructor(){this.geometry=new x,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureRef=new j((()=>this.tile.surface.fadeDuration)),this.overlay=new R,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),E&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)$(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=C[e];if(!t)return $(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if($(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}$(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide(S(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(C[a],i),l=W(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==W(e,d),m=o[a]!==g;E&&n&&($(e.level>=n.level),$(e.level-n.level<=v)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);$(t(c)),$(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(D[t],i);r.cornerPeerNeighbors[t]=o;const a=W(e,s[t]),n=W(e,s[(t+1)%4]),l=W(e,o);H[t]=l,H[(t+1)%4]=n,H[(t+2)%4]=e,H[(t+3)%4]=a,$(H.some((t=>t?.isLoaded||t===e)));const g=H.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);H.forEach(((e,t)=>{e&&e?.level>g&&(H[t]=null)})),$(H.some((t=>t?.isLoaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=H[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}E&&$(ee.some((r=>d[4*t+r]?.isLoaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)H[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;E&&$(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r){const i=t?F.RGBA:F.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}get numVerticesPerSideChanged(){return 0!=(this._modifiedFlags&q)}get samplerDataChanged(){return 0!=(this._modifiedFlags&z)}get clippingAreaChanged(){return 0!=(this._modifiedFlags&J)}get wireframeChanged(){return 0!=(this._modifiedFlags&K)}get dirtyEdges(){return this._modifiedFlags>>Q&15}get dirtyCorners(){return this._modifiedFlags>>Y&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Z&15}_markCornerDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Y|15<<Q|15<<Z}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,N,{geometry:f(t.layout)},{geometry:P.createVertex(e,i.STATIC_DRAW,t.buffer)},P.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){null!=e&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[_.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g];if(null!=r.upsampleInfo){const t=r.upsampleInfo.tile,n=t.layerInfo[_.ELEVATION][g].data,l=n&&n.samplerData;e&&e[s]===l||(a=!0),i[s++]=l,o=Math.max(o,t.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(g,_.ELEVATION);if(w(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!E)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void $(e?.isLoaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=C.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;$(0===this.dirtyCorners),$(0===this.dirtyEdges),$(0===this.dirtyEdgeResolutions),$(!this.numVerticesPerSideChanged),$(!this.samplerDataChanged),$(!this.clippingAreaChanged),$(!this.wireframeChanged);const _=D.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=_[t];$(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}C.forEach(((r,_)=>{if(f[_])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.isLoaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void $(!t)}$(x.isLoaded||x.level===e.level),$(x===this.geometryState.edgePeerNeighbors[_]);const v=p-x.level;if(!x.isLoaded)return $(!x.isLeaf),void $(0===v);const E=x.renderData;$(V(e,x,r)),$(v>=0);const C=2**v;if(v<0)return void $(!1);const S=e.renderData,D=S.geometry,j=S.localOrigin,A=D.getEdgeCount(_),R=D.numVerticesPerSide-1,w=E.geometry;if(!w)return void $(!1);const L=E.localOrigin,N=this.geometryState.edgePeerNeighbors[_];if(N?.isLoaded){const e=N.renderData;$(S.geometryState.edgePeerNeighborSamplerVersions[_]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[_]===e.geometryState.samplerDataVersion)}const P=(_+2)%4,F=w.getEdgeCount(P),G=A-1,H=F-1;$(G*C===H,`Tile[${e.lij}]:e${_},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${H} (expected:${G*C})`);const W=e.extent,q=r===y.NORTH||r===y.SOUTH,z=F-1,J=z>>v,K=A-1;if(J<1)return void $(1===K);$(J===K),$(t(J));const Q=w.numVerticesPerSide-1;$(v>0||J===Math.max(Q,R));const Y=e.getNeighborEdgeStartVertexIndex(_,x);$(0<=Y&&Y<C);const Z=Y*J;$(0<=Z&&Z<=z-J);let ee=0,te=Z;D.getEdgeVertexPosition(_,O,j,0),D.getEdgeVertexPosition(_,I,j,A-1);const re=i(O,I),ie=Math.max(B,1e-4*re);for(let t=0;t<=J;++t){D.getEdgeVertexPosition(_,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=t/J,f=q?W[0]+i*(W[2]-W[0]):r===y.WEST?W[0]:W[2],p=q?r===y.SOUTH?W[1]:W[3]:W[1]+i*(W[3]-W[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(O,I),r=o(O)-c.radius,i=o(I)-c.radius,u=t<ie;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${_}[${ee}/${A}] and [${x.lij}].edge${P}[${te}/${F}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,S.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${S.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(O),r=m(I);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(_,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=h();g(i,O,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${O} d=${o(i)} [${i}]`),g(i,I,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${I} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(_),l=w.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${_}][${ee}/${n}] vs neighbor [${x.lij}].edge[${P}][${te}/${l}] ${T(O)} vs ${T(I)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(_,M,ee),w.getEdgeNormal(P,U,te),n(k,M),n(X,U);const y=l(k,X),C=1-y<.01||!1||e===x;if(!C){const t=h();g(t,M,U);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${ee}/${A-1}) edge ${_} vs neighbor ${b(x.lij)} (${te}/${F-1}) nedge ${P} :${T(M)} vs ${T(U)} dot = ${y} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(_,t,ee),w.getEdgeNormal(P,r,te),d(M,t)||console.warn("Missing update in tile normal: ",T(M)," => ",T(t)),d(U,r)||console.warn("Missing update in neighbor normal: ",T(U)," => ",T(r))}$(C,r())}}ee+=1,te+=1}}))}}const O=h(),I=h(),M=h(),U=h(),k=h(),X=h(),B=1,H=[null,null,null,null];function W(e,t){return t?.isLoaded||t===e?t:null}const q=1,z=2,J=4,K=8,Q=4,Y=8,Z=12,ee=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,W as neighborTileIfLoadedOrSelf,ee as zeroToFour};
|
|
5
|
+
import{equals as e}from"../../../core/arrayUtils.js";import{isPowerOfTwo as t}from"../../../core/mathUtils.js";import{disposeMaybe as r}from"../../../core/maybe.js";import{q as i,o as s,D as o,f as a,n,k as l,z as g,G as d}from"../../../chunks/vec32.js";import{create as h,clone as m}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{containsXY as u}from"../../../geometry/support/aaBoundingRect.js";import{earth as c}from"../../../geometry/support/Ellipsoid.js";import{glLayout as f}from"../support/buffer/glUtil.js";import{GeometryState as p}from"./GeometryState.js";import{NeighborIndex as y}from"./ITile.js";import{LayerClass as _}from"./LayerClass.js";import{PatchGeometry as x}from"./PatchGeometry.js";import{maxTileNeighborLevelDelta as v}from"./TerrainConst.js";import{enableTerrainInternalChecks as E,internalAssert as $,neighborEdgeIndices as S,oppositeEdge as C,neighborCornerIndices as D,v32s as T,lij2s as b}from"./terrainUtils.js";import{TextureFader as j,ActivationTime as A}from"./TextureFader.js";import{isEdgeNeighbor as V}from"./Tile.js";import R from"./TileOverlayData.js";import{fallsWithinLayer as w}from"./tileUtils.js";import{VertexArrayObject as L}from"../webgl-engine/lib/VertexArrayObject.js";import{terrainVertexAttributeLocations as N}from"../webgl-engine/shaders/TerrainTechnique.js";import{BufferObject as P}from"../../webgl/BufferObject.js";import{PixelFormat as F}from"../../webgl/enums.js";class G{constructor(){this.geometry=new x,this.intersectionData=null,this.geometryState=null,this._vao=null,this._texture=null,this._textureRef=new j((()=>this.tile.surface.fadeDuration)),this.overlay=new R,this._localOrigin=null,this._geometryStateChangedSinceLastUpdate=!0,this._hasGeometry=!1,this._modifiedFlags=0}get tile(){return this._tile}get localOrigin(){return this._localOrigin}init(e,t){this.clear(),this._tile=e,this.geometry.reset(),this.intersectionData=null,this.geometryState=new p,this._localOrigin=t,this.overlay.clear()}clear(){this.releaseGeometry(),this.releaseTexture(),this._textureRef.clear(),this._tile=null,this.intersectionData=null,this.geometryState=null}updateGeometryIfNeeded(e){if((!this._vao||this._geometryStateChangedSinceLastUpdate||this.wireframeChanged||this.clippingAreaChanged||this.samplerDataChanged||this.numVerticesPerSideChanged||this.dirtyCorners||this.dirtyEdgeResolutions||this.dirtyEdges)&&(this._updateGeometry(e),this._geometryStateChangedSinceLastUpdate=!1),E&&this.tile.intersectsClippingArea)for(let t=0;t<4;++t)$(this.geometry.getEdgeCount(t)===this.geometryState.edgeResolutions[t]+1)}_calculateEdgeResolution(e,t){const r=this.tile,i=this.geometryState.numVerticesPerSide-1;if(!r.surface.isGlobal){const t=r.surface.extent;if(null!=t&&(0===e&&r.extent[3]>t[3]||1===e&&r.extent[2]>t[2]||2===e&&r.extent[1]<t[1]||3===e&&r.extent[0]<t[0]))return i}const s=r.level,o=S[e];if(!t)return $(null==r.surface?.rootTiles||r.surface.updatingRootTiles||!r.shouldHaveNeighbor(o)),i;if(t.isLoaded){const r=t,o=r.renderData.geometryState,a=s-r.level;if($(a>=0),0===a){const e=o.numVerticesPerSide-1;return Math.max(e,i)}const n=2**a,l=o.edgeResolutions[(e+2)%4]/n;return Math.max(1,l)}$(!t.isLeaf);let a=i;return t.forAllSubtreeOnSide(C(o),(e=>e===r||(e.isLoaded?(a=Math.max(a,2**(e.level-s)),!0):($(!e.isLeaf),!1)))),a}updateNeighborData(){const e=this.tile;if(!e.intersectsClippingArea)return;const r=e.renderData.geometryState,i=t=>(t.isLoaded||t.level===e.level)&&t?.intersectsClippingArea,s=r.edgePeerNeighbors,o=r.edgePeerNeighborSamplerVersions;for(let a=0;a<4;++a){const n=e.findNeighborTile(S[a],i),l=W(e,n),g=l?.renderData?.geometryState.samplerDataVersion??-1,d=s[a],h=l!==W(e,d),m=o[a]!==g;E&&n&&($(e.level>=n.level),$(e.level-n.level<=v)),s[a]=n,(h||m)&&(o[a]=g,this._markEdgeDirty(a));const u=r.edgeResolutions[a],c=this._calculateEdgeResolution(a,n);$(t(c)),$(c>=1),r.edgeResolutions[a]=c,u!==c&&this._markEdgeResolutionDirty(a)}for(let t=0;t<4;++t){const o=e.findNeighborTile(D[t],i);r.cornerPeerNeighbors[t]=o;const a=W(e,s[t]),n=W(e,s[(t+1)%4]),l=W(e,o);H[t]=l,H[(t+1)%4]=n,H[(t+2)%4]=e,H[(t+3)%4]=a,$(H.some((t=>t?.isLoaded||t===e)));const g=H.reduce(((e,t)=>Math.min(e,t?.level??1/0)),1/0);H.forEach(((e,t)=>{e&&e?.level>g&&(H[t]=null)})),$(H.some((t=>t?.isLoaded||t===e)));const d=r.cornerNeighborCornerTiles,h=r.cornerNeighborCornerTileSamplerVersions;for(let e=0;e<4;++e){const r=H[e],i=r?.renderData.geometryState.samplerDataVersion??-1,s=4*t+e,o=d[s]!==r,a=!o&&h[s]!==i;(o||a)&&(d[s]=r,h[s]=i,this._markCornerDirty(t))}E&&$(ee.some((r=>d[4*t+r]?.isLoaded||d[4*t+r]===e)))}E&&$(this.geometryState.edgeResolutions.every((e=>e>0)));for(let t=0;t<4;++t)H[t]=null}_updateGeometry(e){if(!this.tile.intersectsClippingArea)return;E&&$(!this.tile.intersectsClippingArea||this.geometryState.edgeResolutions.every((e=>e>0))),this.intersectionData=null;const{tile:t,_vao:r,geometry:i,geometryState:s}=this,o=!r||!{geometry:i}||this.wireframeChanged||this.samplerDataChanged||this.clippingAreaChanged||this.numVerticesPerSideChanged,a=0!==this.dirtyEdgeResolutions,n=s.edgeResolutions.reduce(((e,t)=>e+t+1),0),l=o||a&&n>(i?.maxEdgeVertexCount??0),g=!l&&a,d=!g&&(0!==this.dirtyEdges||a),h=!d&&0!==this.dirtyCorners;l?(this.releaseGeometry(),this._createGeometry(e)):g?t.updateEdgeElevationsAndResolutions():d||h?t.updateEdgeElevations():h?t.updateCornerElevations():console.warn("Update for no reason?"),this._modifiedFlags=0}get hasGeometry(){return this._hasGeometry}releaseGeometry(){return this._hasGeometry=!1,this.intersectionData=null,!!this._vao&&(this._vao=r(this._vao),this.geometry.release(),!0)}ensureTexture(e,t,r){const i=t?F.RGBA:F.RGB;return null==this._texture||this._texture.descriptor.width===e&&this._texture.descriptor.pixelFormat===i||this.releaseTexture(),null==this._texture&&(this._texture=r(),this.tile.setMemoryDirty()),this._texture}releaseTexture(){null!=this._texture&&(this._texture.release(),this._texture=null,this.tile.setMemoryDirty())}get numVerticesPerSideChanged(){return 0!=(this._modifiedFlags&q)}get samplerDataChanged(){return 0!=(this._modifiedFlags&z)}get clippingAreaChanged(){return 0!=(this._modifiedFlags&J)}get wireframeChanged(){return 0!=(this._modifiedFlags&K)}get dirtyEdges(){return this._modifiedFlags>>Q&15}get dirtyCorners(){return this._modifiedFlags>>Y&15}get dirtyEdgeResolutions(){return this._modifiedFlags>>Z&15}_markCornerDirty(e){const t=1<<e<<Y;this._modifiedFlags|=t}_markEdgeDirty(e){const t=1<<e<<Q;this._modifiedFlags|=t,this._markCornerDirty((e+0)%4),this._markCornerDirty((e+3)%4)}_markEdgeResolutionDirty(e){const t=1<<e<<Z;this._modifiedFlags|=t,this._markEdgeDirty(e)}_markAllEdgesAndCornersDirty(){this._modifiedFlags|=15<<Y|15<<Q|15<<Z}updateGeometryState(){const t=this._getElevationInfo(),r=this.tile,i=t.samplerData?r.getElevationVerticesPerSide(t.maxTileLevel):r.getDefaultVerticesPerSide(),s=Math.max(i,5);let o=r.clippingArea;r.intersectsClippingArea&&!r.isWithinClippingArea||(o=null);const a=this.geometryState;let n=!1;a.numVerticesPerSide!==s&&(this._modifiedFlags|=1,a.numVerticesPerSide=s,a.samplerDataVersion++,n=!0),t.changed&&(this._modifiedFlags|=2,a.samplerData=t.samplerData,a.samplerDataVersion++,n=!0),e(a.clippingArea,o)||(this._modifiedFlags=4,a.clippingArea=o,n=!0);const l=r.surface.wireframe;return a.wireframe!==l&&(this._modifiedFlags=8,a.wireframe=l,n=!0),this._geometryStateChangedSinceLastUpdate||=n,n&&this._markAllEdgesAndCornersDirty(),this._hasGeometry=!0,this._geometryStateChangedSinceLastUpdate}_createGeometry(e){this.tile.createGeometry();const t=this.geometry.vertexAttributes,r=this.geometry.indices,i=e.gl;this._vao=new L(e,N,{geometry:f(t.layout)},{geometry:P.createVertex(e,i.STATIC_DRAW,t.buffer)},P.createIndex(e,i.STATIC_DRAW,r)),this._hasGeometry=!0}get vao(){return this._vao}setTextureReference(e,t=A.Immediate){null!=e&&e.texture!==this._texture&&this.releaseTexture(),this._textureRef.push(e,t)}get textureReference(){return this._textureRef.current}get nextTextureReference(){return this._textureRef.next}get textureFadeFactor(){return this._textureRef.fadeFactor}get textureIsFading(){return this._textureRef.isFading}_getElevationInfo(){const e=this.geometryState.samplerData,t=this.tile.layerInfo[_.ELEVATION],r=t.length,i=new Array(r);let s=0,o=0,a=!1;for(let g=0;g<r;g++){const r=t[g];if(null!=r.upsampleInfo){const t=r.upsampleInfo.tile,n=t.layerInfo[_.ELEVATION][g].data,l=n&&n.samplerData;e&&e[s]===l||(a=!0),i[s++]=l,o=Math.max(o,t.lij[0])}else if(r.data){const t=this.tile.surface.layerViewByIndex(g,_.ELEVATION);if(w(this.tile,t.layer,!1)){const t=r.data;e&&e[s]===t.samplerData||(a=!0),i[s++]=t.samplerData,o=this.tile.level}}}null!=e&&e.length!==s&&(a=!0);const n=s>0,l=n?i:null;return n&&(i.length=s),{changed:a,samplerData:l,maxTileLevel:o}}get estimatedGeometryMemoryUsage(){const e=this.intersectionData?.estimatedMemoryUsage??0;return(this.geometry.indices?.byteLength??0)+(this.geometry.vertexAttributes?.byteLength??0)+e}get texture(){return this._texture}get test(){return{hasTexture:null!=this._texture}}checkGeometryWaterproofness(){if(!E)return;const e=this.tile;if(!e.isLoaded||!e.intersectsClippingArea||0===e.level)return void $(e?.isLoaded);const r=e.surface.extent;if(null!=r&&!e.intersectsExtent(r))return;const f=S.map(((t,i)=>null!=r&&(i<2?-1:1)*(e.extent[3-i]-r[3-i])<0)),p=e.level;$(0===this.dirtyCorners),$(0===this.dirtyEdges),$(0===this.dirtyEdgeResolutions),$(!this.numVerticesPerSideChanged),$(!this.samplerDataChanged),$(!this.clippingAreaChanged),$(!this.wireframeChanged);const _=D.map((t=>e.findNeighborCornerTileExact(t,(t=>!t.intersectsClippingArea||t.isLoaded||t.level===e.level))??null)).map((e=>e?.intersectsClippingArea?e:null)),x=this.geometryState;for(let t=0;t<4;++t){const r=x.cornerPeerNeighbors[t],i=_[t];$(i===r,`Tile[${e.lij}].corner[${t}] out of date: cur=[${r?.lij}] exp=[${i?.lij}]`)}S.forEach(((r,_)=>{if(f[_])return;const x=e.findNeighborTile(r,(e=>(e.level===p||e?.isLoaded)&&e?.intersectsClippingArea));if(!x){const t=!e.surface.updatingRootTiles&&null!=e.surface.rootTiles&&e.surface.rootTiles.length>0&&e.shouldHaveNeighbor(r);return void $(!t)}$(x.isLoaded||x.level===e.level),$(x===this.geometryState.edgePeerNeighbors[_]);const v=p-x.level;if(!x.isLoaded)return $(!x.isLeaf),void $(0===v);const E=x.renderData;$(V(e,x,r)),$(v>=0);const S=2**v;if(v<0)return void $(!1);const C=e.renderData,D=C.geometry,j=C.localOrigin,A=D.getEdgeCount(_),R=D.numVerticesPerSide-1,w=E.geometry;if(!w)return void $(!1);const L=E.localOrigin,N=this.geometryState.edgePeerNeighbors[_];if(N?.isLoaded){const e=N.renderData;$(C.geometryState.edgePeerNeighborSamplerVersions[_]===e.geometryState.samplerDataVersion),$(this.geometryState.edgePeerNeighborSamplerVersions[_]===e.geometryState.samplerDataVersion)}const P=(_+2)%4,F=w.getEdgeCount(P),G=A-1,H=F-1;$(G*S===H,`Tile[${e.lij}]:e${_},res=${G} edgeRes mismatch with Neighbor[${x.lij}]:e${P},res=${H} (expected:${G*S})`);const W=e.extent,q=r===y.NORTH||r===y.SOUTH,z=F-1,J=z>>v,K=A-1;if(J<1)return void $(1===K);$(J===K),$(t(J));const Q=w.numVerticesPerSide-1;$(v>0||J===Math.max(Q,R));const Y=e.getNeighborEdgeStartVertexIndex(_,x);$(0<=Y&&Y<S);const Z=Y*J;$(0<=Z&&Z<=z-J);let ee=0,te=Z;D.getEdgeVertexPosition(_,O,j,0),D.getEdgeVertexPosition(_,I,j,A-1);const re=i(O,I),ie=Math.max(B,1e-4*re);for(let t=0;t<=J;++t){D.getEdgeVertexPosition(_,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=t/J,f=q?W[0]+i*(W[2]-W[0]):r===y.WEST?W[0]:W[2],p=q?r===y.SOUTH?W[1]:W[3]:W[1]+i*(W[3]-W[1]),v=e.surface.extent;if(null==v||u(v,f,p)){const t=s(O,I),r=o(O)-c.radius,i=o(I)-c.radius,u=t<ie;if(!u){console.warn(`Tile edge vertex position mismatch: between [${e.lij}].edge${_}[${ee}/${A}] and [${x.lij}].edge${P}[${te}/${F}]`),null!=v&&console.warn(" surface extent= ",v," x,y=",f,",",p);const s=h();a(s,C.localOrigin,E.localOrigin),o(s)>0&&console.warn(` localOrigins: ${C.localOrigin} vs ${E.localOrigin} d=${o(s)} [${s}]`);(()=>{const t=m(O),r=m(I);e.updateEdgeElevations(),x.updateEdgeElevations(),D.getEdgeVertexPosition(_,O,j,ee),w.getEdgeVertexPosition(P,I,L,te);const i=h();g(i,O,t),o(i)>0&&console.warn(` XXX Tile[${e.lij}] edge out of date: ${t} vs ${O} d=${o(i)} [${i}]`),g(i,I,r),o(i)>0&&console.warn(` XXX Neighbor[${x.lij}] edge out of date: ${r} vs ${I} d=${o(i)} [${i}]`)})();const n=D.getEdgeCount(_),l=w.getEdgeCount(F);$(u,`Mismatch in tile [${e.lij}].edge[${_}][${ee}/${n}] vs neighbor [${x.lij}].edge[${P}][${te}/${l}] ${T(O)} vs ${T(I)} dist=${t} h(t|n|d)=${r}|${i}|${i-r}`)}D.getEdgeNormal(_,M,ee),w.getEdgeNormal(P,U,te),n(k,M),n(X,U);const y=l(k,X),S=1-y<.01||!1||e===x;if(!S){const t=h();g(t,M,U);const r=()=>`Mismatch in tile edge normal ${b(e.lij)} (${ee}/${A-1}) edge ${_} vs neighbor ${b(x.lij)} (${te}/${F-1}) nedge ${P} :${T(M)} vs ${T(U)} dot = ${y} : ${T(t)}`;console.warn("Mismatch in tile edge normal: ",r());{e.updateEdgeElevations(),x.updateEdgeElevations();const t=h(),r=h();D.getEdgeNormal(_,t,ee),w.getEdgeNormal(P,r,te),d(M,t)||console.warn("Missing update in tile normal: ",T(M)," => ",T(t)),d(U,r)||console.warn("Missing update in neighbor normal: ",T(U)," => ",T(r))}$(S,r())}}ee+=1,te+=1}}))}}const O=h(),I=h(),M=h(),U=h(),k=h(),X=h(),B=1,H=[null,null,null,null];function W(e,t){return t?.isLoaded||t===e?t:null}const q=1,z=2,J=4,K=8,Q=4,Y=8,Z=12,ee=[0,1,2,3];export{A as ActivationTime,G as PatchRenderData,W as neighborTileIfLoadedOrSelf,ee as zeroToFour};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{lerp as t}from"../../../core/mathUtils.js";import{n as e,s as i,g as s,h as o,
|
|
5
|
+
import{lerp as t}from"../../../core/mathUtils.js";import{n as e,s as i,g as s,h as o,D as n,b as r,k as l,o as a,z as h}from"../../../chunks/vec32.js";import{create as u}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{lonLatToSphericalPCPF as d}from"../../../geometry/projection/lonLatToSphericalPCPF.js";import{newDoubleArray as c}from"../../../geometry/support/DoubleArray.js";import{intersectsSphere as p,numPlanes as f,PlaneIndex as m}from"../../../geometry/support/frustum.js";import{d as g,g as x}from"../../../chunks/sphere.js";import{PatchType as $}from"./interfaces.js";import{TileFrustumVisibility as _}from"./ITile.js";import{createSphericalGlobePatch as v,updateCornerSpherical as M,updateEdgesAndCornersSpherical as S,updateEdgeElevationsAndResolutionsSpherical as b}from"./PatchGeometryFactory.js";import{enableTerrainInternalChecks as j,internalAssert as T,almostEquals as E}from"./terrainUtils.js";import{Tile as I,CenterPosition as B}from"./Tile.js";import{compareTilesByLij as D}from"./tileUtils.js";class H extends I{constructor(t,e,i,s,o){super(),this._convexHull=new Array(24),this._boundingSphere=g(),this._baseUsedMemory=1816,this.init(t,e,i,s,o)}init(i,s,o,n,r){super.init(i,s,o,n,r);const l=this.ellipsoid.radius,a=this.extentInRadians[0],h=this.extentInRadians[1],u=this.extentInRadians[2],c=this.extentInRadians[3],p=t(h,c,.5),f=t(a,u,.5),m=0===i?0:Math.min(Math.abs(h),Math.abs(c));this._edgeLen=(u-a)*Math.cos(m)*l,this._edgeLen2=this._edgeLen*this._edgeLen,this._curvatureHeight=l-Math.sqrt(l*l-this._edgeLen2/4),d(this.centerAtSeaLevel,f,p,this.ellipsoid.radius),e(this.up,this.centerAtSeaLevel),this.updateRadiusAndCenter()}updateRadiusAndCenter(){this._updateBoundingVolumes();const t=this._center;if(0===this.lij[0])i(x(t[B.MIDDLE]),0,0,0),i(t[B.TOP],0,0,0),i(t[B.BOTTOM],0,0,0),t[B.MIDDLE][3]=this.ellipsoid.radius+this.elevationBoundsMax;else{this._updateCenter();const e=t[B.MIDDLE],i=this.convexHull;let s=0;for(let t=0;t<8;++t)s=Math.max(s,y(x(e),i,3*t));t[B.MIDDLE][3]=Math.sqrt(s)}}_calculateFrustumVisibilityStatus(t){if(!p(t,this._boundingSphere))return _.OUTSIDE;if(this.lij[0]<10)return _.INTERSECTS;const e=this.convexHull,i=this.surface.view.state.camera.near;let s=!0;for(let o=0;o<f;o++){const n=o===m.NEAR,r=t[o],l=r[0],a=r[1],h=r[2],u=r[3]-(n?i:0);let d=!1;for(let t=0;t<8;++t){const i=3*t;if(l*e[i]+a*e[i+1]+h*e[i+2]+u<0){if(d=!0,!s)break}else s=!1}if(!d)return _.OUTSIDE}return s?_.INSIDE:_.INTERSECTS}computeElevationBounds(){super.computeElevationBounds(),this._updateBoundingVolumes()}createGeometry(){v(this.renderData,this._getPatchType()),this._updateBoundingVolumes(),this.setMemoryDirty()}_updateBoundingVolumes(){this._updateConvexHull(),this._updateBoundingSphere(),j&&this._checkBVs()}_updateBoundingSphere(){const t=this._boundingSphere,e=x(t),r=this.elevationBoundsMin,l=this.elevationBoundsMax,a=this.ellipsoid.radius,h=l;if(0===this.level)i(e,0,0,0),t[3]=a+h;else{const i=this.extentInRadians,h=.5*(i[0]+i[2]),u=i[1],d=i[3];O(A,h,u,a),O(V,h,d,a),s(e,A,V);o(e,e,(a+.5*(r+l))/n(e));const c=this.convexHull;let p=0;const f=(t,e)=>{const i=t[0]-c[3*e],s=t[1]-c[3*e+1],o=t[2]-c[3*e+2];return Math.sqrt(i*i+s*s+o*o)};for(let t=0;t<8;++t){const i=f(e,t);p=Math.max(p,i)}const m=p;t[3]=m+2}}_updateConvexHull(){const t=this.extentInRadians,i=this.ellipsoid.radius;if(0===this.level)return;const a=this.elevationBoundsMin,d=this.elevationBoundsMax,c=this._getPatchType(),p=this.surface.isWebMercator,f=p&&c===$.HAS_NORTH_POLE,m=p&&c===$.HAS_SOUTH_POLE,g=m||f,x=Math.PI/2,_=t[0],v=t[2],M=m?-x:t[1],S=f?x:t[3],b=.5*(_+v),j=a,I=i+(g?Math.min(0,j-1):j),B=(t,e,i)=>O(t,e,i,I),D=u(),H=u(),L=u(),y=u();B(D,_,M),B(H,_,S),B(L,v,S),B(y,v,M);const R=(t,e)=>{for(let i=0;i<3;++i)this._convexHull[3*e+i]=t[i]};R(D,0),R(H,1),R(L,2),R(y,3);const A=d,V=i+(g?Math.max(0,A+1):A),C=u(),N=u(),U=u();O(N,b,S,I),O(U,b,M,I),s(C,N,U),e(C,C);const k=u(),F=u(),w=(t,i)=>{h(F,t,i),e(F,F);const n=-l(t,k)/l(F,k);T(n>=0),o(F,F,n),s(t,t,F)};if(2**this.lij[0]>2*this.lij[1]){const t=U,i=u();r(i,P,t),e(i,i),r(k,t,i),e(k,k),T(E(l(k,t)/n(t),0)),w(D,H),w(y,L),R(D,0),R(y,3)}else if(2**this.lij[0]!==2*this.lij[1]){const t=N,i=u();r(i,P,t),e(i,i),r(k,i,t),e(k,k),w(H,D),w(L,y),R(H,1),R(L,2)}const q=(t,e)=>{const i=V/l(e,C);for(let s=0;s<3;++s)this._convexHull[3*t+s]=e[s]*i};q(4,D),q(5,H),q(6,L),q(7,y)}_getPatchType(){const t=this.lij[1],e=0===t,i=t===(1<<this.level)-1;return e?i?$.HAS_BOTH_POLES:$.HAS_NORTH_POLE:i?$.HAS_SOUTH_POLE:$.REGULAR}intersectsRay(t,e,i,s){const o=this._boundingSphere,n=o[3]+i,r=e[0]*e[0]+e[1]*e[1]+e[2]*e[2],l=o[0]-t[0],a=o[1]-t[1],h=o[2]-t[2],u=(l*e[0]+a*e[1]+h*e[2])/r,d=e[0]*u-l,c=e[1]*u-a,p=e[2]*u-h;return d*d+c*c+p*p<n*n}getDefaultVerticesPerSide(){return this.level<L.length?L[this.level]+1:2}updateCornerElevations(){M(this.renderData),this._updateBoundingVolumes()}updateEdgeElevations(){S(this.renderData),this._updateBoundingVolumes()}updateEdgeElevationsAndResolutions(){b(this.renderData),this._updateBoundingVolumes()}_checkBVs(){if(!j)return;if(this.level<=2)return;const t=this._boundingSphere,i=t[3],o=x(t),d=u(),p=this.ellipsoid.radius,f=this.elevationBoundsMin,m=this.elevationBoundsMax,g=p+f,$=1,_=0,v=this._center[B.MIDDLE][3],M=this.convexHull,S=(t,e)=>{for(let i=0;i<3;++i)t[i]=M[3*e+i]};{const t=u(),i=u(),s=u(),o=u(),n=u(),a=(a,u,d,c)=>{S(i,a),S(s,u),S(o,d),h(i,i,s),h(o,o,s),r(t,i,o),e(t,t);const p=l(t,s);S(n,c);const f=l(t,n),m=Math.abs(f-p);T(E(m,0),`Non coplanar ${a},${u},${d},${c} diff = ${m}`)};a(0,1,2,3),a(4,5,6,7),a(0,1,4,5),a(1,2,5,6),a(2,3,6,7),a(3,0,7,4)}const b=c(24),I=(t,e,i)=>{const s=4*t;for(let o=0;o<3;++o)b[s+o]=e[o];b[s+3]=i},H=u(),L=u(),y=u(),P=u(),A=(t,i,s,o)=>{S(H,i),S(L,s),S(y,o),h(H,H,L),e(H,H),h(y,y,L),e(y,y),r(P,H,y),e(P,P);const n=l(P,L);I(t,P,n)};A(0,0,1,2),A(1,1,0,4),A(2,1,5,2),A(3,3,2,6),A(4,4,0,3),A(5,4,6,5);const V=1,C=(t,e,i,s)=>{const o=4*t;return b[o]*e+b[o+1]*i+b[o+2]*s-b[o+3]},N=(t,e,i,s)=>C(t,e,i,s)>=-V,U=(t,e)=>N(t,e[0],e[1],e[2]),k=2**this.lij[0]>2*this.lij[1],F=(t,e,s)=>Math.sqrt(R(t,e,s,o[0],o[1],o[2]))<i,w=t=>F(t[0],t[1],t[2]),q=(t,e)=>F(t[e],t[e+1],t[e+2]),G=this.extentInRadians,z=.5*(G[0]+G[2]),W=G[1],J=G[3],K=u(),Q=u();O(K,z,J,g),O(Q,z,W,g);const X=k?"Upper":"Lower";let Y=!0;for(let e=0;e<6;++e){for(let t=0;t<8;++t){const i=3*t,s=N(e,M[i],M[i+1],M[i+2]);Y&&=s,T(s,`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}T(U(e,Q),`Tile[${this.lij}] (${X}) bottom mid outside of plane ${e}`),T(U(e,K),`Tile[${this.lij}] (${X}) top mid outside of plane ${e}`)}T(Y,"Not all convex hull points are inside convex hull polyhedron"),T(w(Q),`Tile[${this.lij}] (${X}) bottom mid outside of bounding sphere`),T(w(K),`Tile[${this.lij}] (${X}) top mid outside of bounding sphere`);for(let e=0;e<8;++e){const t=q(M,3*e);T(t,`Tile[${this.lij}] Convex hull point ${e} outside of bounding sphere`)}for(let e=0;e<6;++e)for(let t=0;t<8;++t){const i=3*t;N(e,M[i],M[i+1],M[i+2])||console.error(`Tile[${this.lij}] Convex hull point ${t} outside of plane ${e}`)}const{extentInRadians:Z}=this,tt=Math.max(Z[2]-Z[0],Z[3]-Z[1]),et=Math.round(tt*p),{renderData:it}=this;if(!it)return;const{geometry:st,geometryState:ot,localOrigin:nt}=it,rt=st.vertexAttributes?.position;if(!rt)return;const lt=u(),at=st.numVerticesPerSide-2,{indices:ht,indexCount:ut,edgeVerticesStartIndex:dt,poleVerticesStartIndex:ct}=st;if(!ht)return;const pt=new Set;for(let e=0;e<ut;++e){const t=ht[e];if(pt.has(t))continue;pt.add(t);const r=t<ct,l=t>=dt;let h=!1,u=-1;if(l){let e=dt;for(let i=0;i<4;++i){const s=ot.edgeResolutions[i];if(t===e||t===e+s-1){h=!0;break}if(e+=s,t<e){u=i;break}}}const c=l?ot.edgePeerNeighbors[u]:null,g=l&&c&&D(this,c)>0;rt.getVec(t,d),s(lt,d,nt);const x=n(lt)-p;let M=0,S=!1;const b=f-x,j=x-m,T=b>$,E=j>$,I=T||E,B=()=>{const e=r?"internal":l&&!h?"edge":h?"corner":"pole";return`Tile[${this.lij}].vertex[${t}]:${e}`+(T?"(below)":E?"(above)":"")+(g?"(Neighbor)":"")},H=a(lt,o);if(H>=i+_){const t=H-i;I||(console.error(`${B()} is out of the bounding sphere by ${t.toFixed(0)} / ${i.toFixed(0)}[tol=${_}] h=${x.toFixed(0)} / [${f.toFixed(0)}..${m.toFixed(0)}] (${(t/i).toFixed(0)})`),S=!0)}for(let e=0;e<6;++e)if(!N(e,lt[0],lt[1],lt[2])){const s=C(e,lt[0],lt[1],lt[2]),o=t%at,n=(t-o)/at;0===e&&b||5===e&&j||(console.error(`${B()} (${o},${n})|${at}] is out of the bounding trapezoid plane ${e} h=${Math.round(x)} / [${Math.round(f)}..${Math.round(m)}] dist=${Math.round(s)} radii = ${Math.round(i)}/${Math.round(v)}} : maxL = ${et}`),++M)}if(S||M>0)break}}get convexHull(){return this._convexHull}}const L=[128,64,64,32,16,8,8,4];function y(t,e,i){return R(t[0],t[1],t[2],e[i],e[i+1],e[i+2])}function R(t,e,i,s,o,n){const r=s-t,l=o-e,a=n-i;return r*r+l*l+a*a}const O=(t,e,i,s)=>{const o=Math.cos(e),n=Math.sin(e),r=Math.cos(i),l=Math.sin(i);t[0]=s*r*o,t[1]=s*r*n,t[2]=s*l},P=[0,0,1],A=u(),V=u();export{H as SphericalPatch};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as h}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as c,s as d,j as u}from"../../../chunks/vec32.js";import{ZEROS as p,fromValues as _,create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as C}from"./LayerClass.js";import{OverlayContent as R}from"./OverlayContent.js";import{overlayRenderOccludedFlag as x}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as w}from"./TileRenderer.js";import{TileUpdate as q}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as A,compareTiles as N}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as j,ComponentIntersectionData as B}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as F}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as U,ConsumesDepth as G,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as M}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as z}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as V}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as W,StoreResults as Y}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as Q}from"../webgl-engine/lib/Material.js";import{RenderSlot as X}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as K}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Z}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as J,getVerticalOffsetTerrain as $}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as ee}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as te,intersectTriangles as ie}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as re}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as se}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as ne}from"../../webgl/enums.js";const ae=7,oe=10,le=g();var he;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(he||(he={}));let ce=class extends U{get _isGlobal(){return this._stage.viewingMode===T.Global}get _techniques(){return this._context.techniqueRepository}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=W.TERRAIN,this.isGround=!0,this._tileSize=256,this._techniqueConfiguration=new se,this._passParameters=new L,this._drawParameters=new ee,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._transparencyState=he.Opaque,this._castShadows=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=Q.Occlude,this.produces=new Map([[X.OPAQUE_TERRAIN,()=>this._produces()],[X.TRANSPARENT_TERRAIN,()=>this._produces()],[X.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?x:Q.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?G:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===he.TransparentWithDraped||e===he.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return J}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,q.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===q.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[C.ELEVATION])i.pendingUpdates&=~q.GEOMETRY;e.resetPendingUpdate(q.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=oe-ae,i=Math.max(0,Math.floor((e.level-t)/ae)*ae);if(this._isGlobal&&0===i)return p;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=z.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=z.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=z.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new w(this._rctx,this._tileSize,this._techniques,this._tileTextureCache),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==he.Opaque)return;const s=de,n=ue;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,p=e.options.store===Y.MIN,_=!!e.results.ground.target,f=$(e.verticalOffset),m=e.tolerance;let g,T=p&&null!=a.dist?a.dist:1/0;const O=d=>{const _=d.renderData;if(!_?.vao)return;const O=_.geometry;b(le,O.boundingBox);const C=_.localOrigin;null!=f&&(f.localOrigin=C,f.applyToAabb(le));const R=le;if(pe[0]=i[0]-C[0],pe[1]=i[1]-C[1],pe[2]=i[2]-C[2],!te(R,pe,n,m,T))return;const x=(e,t,i)=>{e.set(this.type,d,t,i,h),T=p&&null!=a.dist?a.dist:1/0},P=(n,h)=>{if(null!=h&&n>=0&&(e.options.backfacesTerrain||u(h,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&x(l,n,h),e.options.isFiltered)return;e.options.store===Y.ALL&&(null==g?(g=V(e.ray),x(g,n,h),e.results.all.push(g)):n<g.dist&&x(g,n,h)),(null==a.dist||n<a.dist)&&x(a,n,h),e.options.store!==Y.MIN&&(null==o.dist||n>o.dist)&&x(o,n,h)}},v=_e;c(v,r,C);const{indices:D,indexCount:S}=O,w=O.vertexAttributes,q=w.getField(Z.POSITION,y),E=new M(q.typedBuffer,3,w.stride/4),A=S/3;if(!f&&A>j){const e=d.renderData;null==e.intersectionData&&(e.intersectionData=new B(D,0,A,E)),e.intersectionData.intersectRay(pe,v,P)}else ie(pe,v,0,A,D,E,null,f,P)},C=this._rootTiles;if(null!=C){(()=>{const t=this._tileIterator;t.reset(C);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==f&&!e.intersectsRay(i,s,m,T)||_&&this._useStencilForTile(e)?t.skipSubtree():O(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;if(t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0),e.bindParameters.slot===X.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&x))return null}else{const t=this.transparency===he.Opaque?X.OPAQUE_TERRAIN:X.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===he.Empty)return null;switch(e.output){case I.Color:return this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._techniqueConfiguration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(I.Color,e.bindParameters.slot===X.OCCLUDED_TERRAIN);case I.Shadow:case I.ShadowExcludeHighlight:return this._castShadows?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Shadow,!1)):null;case I.LinearDepth:return this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.LinearDepth,!1);case I.Normal:return this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Normal,!1);case I.ObjectAndLayerIdColor:return this._updateTechnique(I.ObjectAndLayerIdColor,!1);case I.Highlight:return this._overlayRenderer.hasHighlights?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case I.Color:{const i=e.bindParameters.slot===X.OCCLUDED_TERRAIN?R.Occluded:R.Color;this._renderMaterialPass(e,t,i);break}case I.LinearDepth:case I.Normal:this._renderAuxiliaryPass(e,t,R.Color,this._visiblePatchesByOrigin);break;case I.Highlight:this._renderAuxiliaryPass(e,t,R.Highlight,this._visiblePatchesByOrigin);break;case I.Shadow:case I.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case I.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=_(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,O.FADING))),this._techniqueConfiguration.tileBlendInput=i.backgroundIsGrid?F.GridComposite:null!=i.backgroundColor?F.ColorComposite:F.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)A(this.renderOrder,i,t);e.sort(((e,t)=>N(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.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(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(this._drawParameters,e.bindParameters,this._passParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],ne.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.camera,n=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=K(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===R.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",p),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:p;this._techniqueConfiguration.tileBlendInput===F.ColorComposite&&n.setUniform3fv("backgroundColor",l);const h=this.wireframe?ne.LINES:ne.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const r=d[0].renderData.localOrigin;t.program.bindDraw(new ee(r),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const s of d){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,h,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(S&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const h=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const c=a.geometry.indexCount;e.rctx.bindVAO(o),h.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(re,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([o({readOnly:!0})],ce.prototype,"_isGlobal",null),e([o()],ce.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ce.prototype,"renderingDisabled",null),e([o({value:!0})],ce.prototype,"visible",null),e([o()],ce.prototype,"renderPatchBorders",null),e([o()],ce.prototype,"visualizeNormals",null),e([o()],ce.prototype,"cullBackFaces",null),e([o({value:v.FRONT_TO_BACK})],ce.prototype,"renderOrder",null),e([o()],ce.prototype,"wireframe",null),ce=e([l("esri.views.3d.terrain.TerrainRenderer")],ce);const de=f(),ue=f(),pe=f(),_e=f();export{ce as TerrainRenderer,he as TransparencyMode};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Color.js";import has from"../../../core/has.js";import{disposeMaybe as i}from"../../../core/maybe.js";import{MemCachePool as r}from"../../../core/MemCachePool.js";import s from"../../../core/ObjectPool.js";import{watch as n,sync as a}from"../../../core/reactiveUtils.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as l}from"../../../core/accessorSupport/decorators/subclass.js";import{IDENTITY as h}from"../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{f as c,s as d,k as u}from"../../../chunks/vec32.js";import{ZEROS as p,fromValues as _,create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as m}from"../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as g,set as b}from"../../../geometry/support/aaBoundingBox.js";import{BufferViewVec3f as y}from"../../../geometry/support/buffer/BufferView.js";import{ViewingMode as T}from"../../ViewingMode.js";import{TextureUpdate as O}from"./interfaces.js";import{LayerClass as C}from"./LayerClass.js";import{OverlayContent as R}from"./OverlayContent.js";import{overlayRenderOccludedFlag as x}from"./OverlayRenderer.js";import{PatchRenderData as P}from"./PatchRenderData.js";import{RenderOrder as v}from"./RenderOrder.js";import{TerrainAttributesCache as D}from"./TerrainAttributesCache.js";import{enableTerrainInternalChecks as S}from"./terrainUtils.js";import{TileRenderer as w}from"./TileRenderer.js";import{TileUpdate as q}from"./TileUpdate.js";import{IteratorPreorder as E,sortTiles as A,compareTiles as N}from"./tileUtils.js";import{componentMinimalSizeForIntersectionData as j,ComponentIntersectionData as B}from"../webgl-engine/collections/Component/ComponentIntersectionData.js";import{ShaderOutput as I}from"../webgl-engine/core/shaderLibrary/ShaderOutput.js";import{T as L}from"../../../chunks/Terrain.glsl.js";import{TileBlendInput as F}from"../webgl-engine/core/shaderLibrary/terrain/TileBlendInput.js";import{SyncPrepareRenderPlugin as U,ConsumesDepth as G,ConsumesNone as k}from"../webgl-engine/effects/RenderPlugin.js";import{Vertices as M}from"../webgl-engine/lib/Attribute.js";import{RenderRequestType as z}from"../webgl-engine/lib/basicInterfaces.js";import{createEmptyTexture as H}from"../webgl-engine/lib/glUtil3D.js";import{newIntersectorResult as V}from"../webgl-engine/lib/Intersector.js";import{IntersectorType as W,StoreResults as Y}from"../webgl-engine/lib/IntersectorInterfaces.js";import{RenderOccludedFlag as Q}from"../webgl-engine/lib/Material.js";import{RenderSlot as X}from"../webgl-engine/lib/RenderSlot.js";import{getSettings as K}from"../webgl-engine/lib/screenSizePerspectiveUtils.js";import{VertexAttribute as Z}from"../webgl-engine/lib/VertexAttribute.js";import{terrainId as J,getVerticalOffsetTerrain as $}from"../webgl-engine/lib/verticalOffsetUtils.js";import{DrawParameters as ee}from"../webgl-engine/materials/DrawParameters.js";import{intersectAabbInvDirBefore as te,intersectTriangles as ie}from"../webgl-engine/materials/internal/MaterialUtil.js";import{TerrainTechnique as re}from"../webgl-engine/shaders/TerrainTechnique.js";import{TerrainTechniqueConfiguration as se}from"../webgl-engine/shaders/TerrainTechniqueConfiguration.js";import{PrimitiveType as ne}from"../../webgl/enums.js";const ae=7,oe=10,le=g();var he;!function(e){e[e.Opaque=0]="Opaque",e[e.Semitransparent=1]="Semitransparent",e[e.TransparentWithDraped=2]="TransparentWithDraped",e[e.Empty=3]="Empty"}(he||(he={}));let ce=class extends U{get _isGlobal(){return this._stage.viewingMode===T.Global}get _techniques(){return this._context.techniqueRepository}get _rctx(){return this._context.renderContext.rctx}constructor(e,t,i,n,a){super({}),this._overlayRenderer=e,this._stage=t,this._allTiles=i,this._ellipsoidRadius=n,this.type=W.TERRAIN,this.isGround=!0,this._tileSize=256,this._techniqueConfiguration=new se,this._passParameters=new L,this._drawParameters=new ee,this._renderDataPool=new s(P),this._visiblePatchesByOrigin=new Map,this._allPatchesByOrigin=new Map,this._patchesByOriginDirty=!0,this._patchSortingDirty=!0,this._tileIterator=new E,this._transparencyState=he.Opaque,this._castShadows=!1,this._emptyTex=null,this._tileRenderer=null,this._stencilEnabledLayerExtents=new Array,this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0,this.renderOccludedFlags=Q.Occlude,this.produces=new Map([[X.OPAQUE_TERRAIN,()=>this._produces()],[X.TRANSPARENT_TERRAIN,()=>this._produces()],[X.OCCLUDED_TERRAIN,()=>this._produces()]]),this._tileTextureCache=new r(((e,t)=>a.newCache(e,t)),"TileTexture"),this.tileGeometryCache=new D(a)}normalizeCtorArgs(){return{}}initialize(){this._stage.addRenderPlugin(this),this.addHandles(n((()=>this._overlayRenderer.rendersOccludedDraped),(e=>{this.renderOccludedFlags=e?x:Q.Occlude,this.setNeedsRender()}),a))}destroy(){this._stage.removeRenderPlugin(this),this._tileTextureCache.destroy(),this.tileGeometryCache.destroy()}_produces(){return this.visible&&!!this._rootTiles&&!this.renderingDisabled}consumes(){return this._overlayRenderer.hasWater?G:k}set renderingDisabled(e){this._set("renderingDisabled",!!e),this.setDirty()}set visible(e){this._set("visible",!!e),this.setDirty()}set transparency(e){this._transparencyState!==e&&(this._techniqueConfiguration.invisible=e===he.TransparentWithDraped||e===he.Empty,this._transparencyState=e,this.setNeedsRender())}get transparency(){return this._transparencyState}get renderPatchBorders(){return!!this._techniqueConfiguration.tileBorders}set renderPatchBorders(e){this._techniqueConfiguration.tileBorders!==e&&(this._techniqueConfiguration.tileBorders=e,this.setNeedsRender(),this.notifyChange("renderPatchBorders"))}get visualizeNormals(){return!!this._techniqueConfiguration.visualizeNormals}set visualizeNormals(e){this._techniqueConfiguration.visualizeNormals!==e&&(this._techniqueConfiguration.visualizeNormals=e,this.setNeedsRender(),this.notifyChange("visualizeNormals"))}get cullBackFaces(){return this._techniqueConfiguration.backfaceCullingEnabled}set cullBackFaces(e){this._techniqueConfiguration.backfaceCullingEnabled!==e&&(this._techniqueConfiguration.backfaceCullingEnabled=e,this.notifyChange("cullBackFaces"),this.setNeedsRender())}set renderOrder(e){this._set("renderOrder",e),this._setSortingDirty()}get layerUid(){return J}get slicePlaneEnabled(){return this._techniqueConfiguration.hasSlicePlane}set slicePlaneEnabled(e){this._techniqueConfiguration.hasSlicePlane!==e&&(this._techniqueConfiguration.hasSlicePlane=e,this.setNeedsRender())}set textureFadingEnabled(e){this._techniqueConfiguration.textureFadingEnabled!==e&&(this._techniqueConfiguration.textureFadingEnabled=e,this.setNeedsRender())}set pbrMode(e){this._techniqueConfiguration.pbrMode!==e&&(this._techniqueConfiguration.pbrMode=e,this.setNeedsRender())}setDebugScreenSizePerspective(e){this._techniqueConfiguration.screenSizePerspective!==e&&(this._techniqueConfiguration.screenSizePerspective=e,this.setNeedsRender())}setRootTiles(e){this._rootTiles=e,this.setDirty()}setStencilEnabledLayerExtents(e){this._stencilEnabledLayerExtents=e,this._setSortingDirty()}setTileSize(e){this._tileSize=e,null!=this._tileRenderer&&(this._tileRenderer.tileSize=e),this.setDirty()}_prepareTileForLoading(e){e.renderData||(e.renderData=this._renderDataPool.acquire(),e.renderData.init(e,this._getLocalOriginOfTile(e)))}loadTile(e){this._prepareTileForLoading(e),this.updateTileGeometryState(e),this.updateTileTexture(e,q.TEXTURE_FADING)}updateTileTexture(e,t){null!=this._tileRenderer&&(this._tileRenderer.updateTileTexture(e,t===q.TEXTURE_FADING?O.FADING:O.UNFADED),this.setNeedsRender(),e.resetPendingUpdate(t))}updateTileGeometryState(e){for(const i of e.layerInfo[C.ELEVATION])i.pendingUpdates&=~q.GEOMETRY;e.resetPendingUpdate(q.GEOMETRY);const t=e.renderData.updateGeometryState();return t&&this.setDirty(),t}updateGeometryIfNeeded(e){e.isLoaded&&e.renderData.updateGeometryIfNeeded(this._rctx)}unloadTile(e){const t=e.renderData;t&&(t.releaseGeometry(),this._renderDataPool.release(t),t.clear(),e.renderData=null,e.setMemoryDirty(),this.setDirty())}_getLocalOriginOfTile(e){const t=oe-ae,i=Math.max(0,Math.floor((e.level-t)/ae)*ae);if(this._isGlobal&&0===i)return p;for(;e.parent&&e.level>i;)e=e.parent;return e.centerAtSeaLevel}getStats(){return{numTilesRendered:this._numTilesRendered,numTilesCulled:this._numTilesCulled,numOriginsRendered:this._numOriginsRendered}}set wireframe(e){this._get("wireframe")!==e&&(this._set("wireframe",e),this.setNeedsRender())}setDirty(e=z.UPDATE){this._patchesByOriginDirty=!0,this._context.requestRender(e)}_setSortingDirty(e=z.UPDATE){this._patchSortingDirty=!0,this._context.requestRender(e)}setNeedsRender(e=z.UPDATE){this._context.requestRender(e)}initializeRenderContext(e){this._context=e,this._tileRenderer=new w(this._rctx,this._tileSize,this._techniques,this._tileTextureCache),this.updateTileBackground(),this._emptyTex=H(this._rctx)}uninitializeRenderContext(){this._emptyTex=i(this._emptyTex),this._tileRenderer=i(this._tileRenderer)}intersect(e,t,i,r){if(!this._rootTiles||e.options.selectOpaqueTerrainOnly&&e.options.selectionMode&&this.transparency!==he.Opaque)return;const s=de,n=ue;c(s,r,i),d(n,1/s[0],1/s[1],1/s[2]);const a=e.results.min,o=e.results.max,l=e.results.ground,p=e.options.store===Y.MIN,_=!!e.results.ground.target,f=$(e.verticalOffset),m=e.tolerance;let g,T=p&&null!=a.dist?a.dist:1/0;const O=d=>{const _=d.renderData;if(!_?.vao)return;const O=_.geometry;b(le,O.boundingBox);const C=_.localOrigin;null!=f&&(f.localOrigin=C,f.applyToAabb(le));const R=le;if(pe[0]=i[0]-C[0],pe[1]=i[1]-C[1],pe[2]=i[2]-C[2],!te(R,pe,n,m,T))return;const x=(e,t,i)=>{e.set(this.type,d,t,i,h),T=p&&null!=a.dist?a.dist:1/0},P=(n,h)=>{if(null!=h&&n>=0&&(e.options.backfacesTerrain||u(h,s)<0)&&(e.options.invisibleTerrain||!e.options.selectionMode||null==t||t(i,r,n))){if((null==l.dist||n<l.dist)&&x(l,n,h),e.options.isFiltered)return;e.options.store===Y.ALL&&(null==g?(g=V(e.ray),x(g,n,h),e.results.all.push(g)):n<g.dist&&x(g,n,h)),(null==a.dist||n<a.dist)&&x(a,n,h),e.options.store!==Y.MIN&&(null==o.dist||n>o.dist)&&x(o,n,h)}},v=_e;c(v,r,C);const{indices:D,indexCount:S}=O,w=O.vertexAttributes,q=w.getField(Z.POSITION,y),E=new M(q.typedBuffer,3,w.stride/4),A=S/3;if(!f&&A>j){const e=d.renderData;null==e.intersectionData&&(e.intersectionData=new B(D,0,A,E)),e.intersectionData.intersectRay(pe,v,P)}else ie(pe,v,0,A,D,E,null,f,P)},C=this._rootTiles;if(null!=C){(()=>{const t=this._tileIterator;t.reset(C);const r=e.options.invisibleTerrain;for(let e=t.next();e;e=t.next())!(e.visible||r&&e.intersectsClippingArea)||null==f&&!e.intersectsRay(i,s,m,T)||_&&this._useStencilForTile(e)?t.skipSubtree():O(e)})()}}processScaleRangeQueries(e,t){if(!t.done)for(this._updatePatchGroups();e.updating&&!t.done;){e.prepare();for(const t of this._visiblePatchesByOrigin.values())for(const i of t)null!=i.renderData?.textureReference&&e.queriesForTile(i);e.process(),t.madeProgress()}}prepareTechnique(e){const t=has("enable-feature:terrain-shadows")&&e.bindParameters.shadowMap.enabled;if(t!==this._castShadows&&(this._castShadows=t,this._patchesByOriginDirty=!0),e.bindParameters.slot===X.OCCLUDED_TERRAIN){if(0==(e.renderOccludedMask&x))return null}else{const t=this.transparency===he.Opaque?X.OPAQUE_TERRAIN:X.TRANSPARENT_TERRAIN;if(e.bindParameters.slot!==t)return null}if(this.transparency===he.Empty)return null;switch(e.output){case I.Color:return this._techniqueConfiguration.hasScreenSpaceReflections=null!=e.bindParameters.ssr.lastFrameColor,this._techniqueConfiguration.hasCloudsReflections=null!=e.bindParameters.cloudsFade.data,this._techniqueConfiguration.receiveShadows=e.bindParameters.shadowMap.ready,this._techniqueConfiguration.receiveAmbientOcclusion=null!=e.bindParameters.ssao,this._techniqueConfiguration.overlayMode=this._overlayRenderer.mode,this._updateTechnique(I.Color,e.bindParameters.slot===X.OCCLUDED_TERRAIN);case I.Shadow:case I.ShadowExcludeHighlight:return this._castShadows?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Shadow,!1)):null;case I.LinearDepth:return this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.LinearDepth,!1);case I.Normal:return this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Normal,!1);case I.ObjectAndLayerIdColor:return this._updateTechnique(I.ObjectAndLayerIdColor,!1);case I.Highlight:return this._overlayRenderer.hasHighlights?(this._techniqueConfiguration.receiveShadows=this._techniqueConfiguration.receiveAmbientOcclusion=!1,this._updateTechnique(I.Highlight,!1)):null}return null}renderNode(e,t){switch(this._updatePatchGroups(),t.useStencil=!1,e.output){case I.Color:{const i=e.bindParameters.slot===X.OCCLUDED_TERRAIN?R.Occluded:R.Color;this._renderMaterialPass(e,t,i);break}case I.LinearDepth:case I.Normal:this._renderAuxiliaryPass(e,t,R.Color,this._visiblePatchesByOrigin);break;case I.Highlight:this._renderAuxiliaryPass(e,t,R.Highlight,this._visiblePatchesByOrigin);break;case I.Shadow:case I.ShadowExcludeHighlight:this._renderAuxiliaryPass(e,t,null,this._allPatchesByOrigin);break;case I.ObjectAndLayerIdColor:this._renderAuxiliaryPass(e,t,R.ObjectAndLayerIdColor,this._visiblePatchesByOrigin)}}updateTileBackground(e){if(null==this._tileRenderer)return;const i=this._tileRenderer;let r;if(null!=e){const i=t.toUnitRGBA(e);r=_(i[0]||0,i[1]||0,i[2]||0)}i.setBackground(r),this._allTiles.forAll((e=>i.updateTileTexture(e,O.FADING))),this._techniqueConfiguration.tileBlendInput=i.backgroundIsGrid?F.GridComposite:null!=i.backgroundColor?F.ColorComposite:F.LayerOnly,this.setNeedsRender()}_updatePatchGroups(){if(this._patchesByOriginDirty&&(this._rebuildPatchGroups(),this._patchesByOriginDirty=!1,this._patchSortingDirty=!0),this._patchSortingDirty&&this.renderOrder!==v.NONE){const e=Array.from(this._visiblePatchesByOrigin.values()),t=this._stencilEnabledLayerExtents;for(const i of e)A(this.renderOrder,i,t);e.sort(((e,t)=>N(e[0],t[0],this.renderOrder))),this._visiblePatchesByOrigin=new Map(e.map((e=>[e[0].renderData.localOrigin,e]))),this._patchSortingDirty=!1}}_rebuildPatchGroups(){const e=this._rootTiles;if(null!=e){e[0]?.surface.checkAllTilesWaterproofness(),this._visiblePatchesByOrigin.clear(),this._allPatchesByOrigin.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(),i=e.renderData;if(!i){this._numTilesCulled++;continue}const r=i.localOrigin;if(this._castShadows){let t=this._allPatchesByOrigin.get(r);t||(t=[],this._allPatchesByOrigin.set(r,t)),t.push(e)}if(!e.visible){this._numTilesCulled++,t.skipSubtree();continue}let s=this._visiblePatchesByOrigin.get(r);s||(s=[],this._visiblePatchesByOrigin.set(r,s)),s.push(e),t.skipSubtree()}}_useStencilForTile(e){for(const t of this._stencilEnabledLayerExtents)if(e.intersectsExtent(t))return!0;return!1}_renderAuxiliaryPass(e,t,i,r){const s=e.rctx;this._passParameters.overlayContent=i,s.bindTechnique(t,e.bindParameters,this._passParameters);const n=this._stencilEnabledLayerExtents.length>0;r.forEach((r=>{this._drawParameters.origin=r[0].renderData.localOrigin,t.program.bindDraw(this._drawParameters,e.bindParameters,this._passParameters);for(let s=0;s<r.length;s++)this._renderPatch(e,t,r[s],ne.TRIANGLES,n,i)})),e.rctx.bindVAO(null)}_renderMaterialPass(e,t,i){const{rctx:r}=e;this._passParameters.overlayContent=i,r.bindTechnique(t,e.bindParameters,this._passParameters),this._numTilesRendered=0,this._numTilesCulled=0,this._numOriginsRendered=0;const s=e.bindParameters.camera,n=t.program;if(this._techniqueConfiguration.screenSizePerspective&&this.pointsOfInterest){const e=K(this._stage.viewingMode,this._ellipsoidRadius),t=this.pointsOfInterest.centerOnSurfaceFrequent.distance;e.update({distance:t,fovY:s.fovY})}const a=this._stencilEnabledLayerExtents.length>0,o=i===R.Occluded;o&&(n.bindTexture("tex",this._emptyTex),n.setUniform3fv("textureOpacities",p),n.setUniform4fv("texOffsetAndScale",m));const l=null!=this._tileRenderer?.backgroundColor?this._tileRenderer.backgroundColor:p;this._techniqueConfiguration.tileBlendInput===F.ColorComposite&&n.setUniform3fv("backgroundColor",l);const h=this.wireframe?ne.LINES:ne.TRIANGLES;this._techniqueConfiguration.textureFadingEnabled&&n.bindTexture("texNext",this._emptyTex);const c=this._visiblePatchesByOrigin;for(const d of c.values()){const r=d[0].renderData.localOrigin;t.program.bindDraw(new ee(r),e.bindParameters,this._passParameters),this._numOriginsRendered++;for(const s of d){const r=s.renderData,l=r.textureReference;if(null!=l){if(!o){n.setUniform4fv("texOffsetAndScale",l.offsetAndScale),n.bindTexture("tex",l.texture.texture);const e=r.textureFadeFactor,t=e<1?r.nextTextureReference:null;this._techniqueConfiguration.textureFadingEnabled&&null!=t&&e<1?(n.setUniform1f("fadeFactor",e),n.setUniform4fv("nextTexOffsetAndScale",t.offsetAndScale),n.setUniform3fv("nextTexOpacities",t.opacities),n.bindTexture("texNext",t.texture.texture)):n.setUniform1f("fadeFactor",1),r.textureIsFading&&this.setNeedsRender(),n.setUniform3fv("textureOpacities",l.opacities)}this._renderPatch(e,t,s,h,a,i),s.renderOrder=this._numTilesRendered,this._numTilesRendered++}}}e.rctx.bindVAO(null)}_renderPatch(e,t,i,r,s,n){const a=i.renderData,o=a.vao,l=o?.indexBuffer;if(!o||null==l)return void(S&&console.error("Rendered tile with no indices: ",i.lij," : ",a));const h=t.program;null==n||this._overlayRenderer.isEmpty||this._bindOverlayPatchData(h,a.overlay),s&&(t.useStencil=this._useStencilForTile(i),e.rctx.setPipelineState(t.getPipeline()));const c=a.geometry.indexCount;e.rctx.bindVAO(o),h.assertCompatibleVertexAttributeLocations(o),e.rctx.drawElements(r,c,l.indexType,0)}_bindOverlayPatchData(e,t){e.setUniform4fv("overlayTexOffset",t.offsets),e.setUniform4fv("overlayTexScale",t.scales)}_updateTechnique(e,t){return this._techniqueConfiguration.output=e,this._techniqueConfiguration.renderOccluded=t,this._shaderTechnique=this._techniques.releaseAndAcquire(re,this._techniqueConfiguration,this._shaderTechnique),this._shaderTechnique}get test(){return{tileRenderer:this._tileRenderer}}};e([o({readOnly:!0})],ce.prototype,"_isGlobal",null),e([o()],ce.prototype,"renderOccludedFlags",void 0),e([o({value:!1})],ce.prototype,"renderingDisabled",null),e([o({value:!0})],ce.prototype,"visible",null),e([o()],ce.prototype,"renderPatchBorders",null),e([o()],ce.prototype,"visualizeNormals",null),e([o()],ce.prototype,"cullBackFaces",null),e([o({value:v.FRONT_TO_BACK})],ce.prototype,"renderOrder",null),e([o()],ce.prototype,"wireframe",null),ce=e([l("esri.views.3d.terrain.TerrainRenderer")],ce);const de=f(),ue=f(),pe=f(),_e=f();export{ce as TerrainRenderer,he as TransparencyMode};
|
package/views/3d/terrain/Tile.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{f as s,o as n,j as r,h as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as u,unitZ as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as c}from"../../../core/libs/gl-matrix-2/math/common.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f}from"../../../geometry/support/aaBoundingRect.js";import{d as _,g as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{VectorTile as A}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as M}from"../support/StreamDataLoader.js";import{ElevationBounds as T}from"./ElevationBounds.js";import{ElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as E}from"./interfaces.js";import{TileFrustumVisibility as I,NeighborIndex as D}from"./ITile.js";import{LayerClasses as L,LayerClass as x}from"./LayerClass.js";import{MapTileAgent as S}from"./MapTileAgent.js";import{RasterTile as O}from"./RasterTile.js";import{maxPatchTesselation as N,getElevationDesiredResolutionLevel as b}from"./TerrainConst.js";import{weakAssert as j,getLayerWithExtentRange as U,isBlendableLayerView as C,oppositeCorner as B,internalAssert as P,enableTerrainInternalChecks as R,neighborEdgeIndices as V,oppositeEdge as w,neighborCornerIndices as G,isNorth as W,isSouth as q,isWest as F,isEast as H,enableWaterproofnessTests as k,almostEquals as X,isWestCorner as Y,isNorthCorner as z}from"./terrainUtils.js";import{tileAgentDone as $}from"./TileAgent.js";import{TilePerLayerInfo as J}from"./TilePerLayerInfo.js";import Q from"./TileTexture.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayer as Z}from"./tileUtils.js";const ee=.1;class te{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),_(),u()],this.up=d(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}static prune(){ne.prune(0),re.prune(0),J.prune()}get _isCached(){return!this.isLeaf&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[oe.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??I.INTERSECTS;this._frustumVisibility=t===I.INSIDE?I.INSIDE:t===I.OUTSIDE?I.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==I.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[oe.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.unsetChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of L){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=J.acquire(this._surface.upsampleInfoPool),r===x.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,N)}dispose(){j(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of L){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null;for(let e=0;e<4;++e)this._children[e]=null;this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[x.MAP].reduce(((e,t)=>e+(t instanceof A?t.usedMemory/t.referenced:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(null!=this._usedMemory)return this._usedMemory;this._usedMemory=this._baseUsedMemory,this._mapTileMemoryInternal=0;let e=0;for(const{data:i}of this.layerInfo[x.MAP])i instanceof A?e+=this._getTerrainDataMemory(i):this._mapTileMemoryInternal+=this._getTerrainDataMemory(i);const t=this._cpuImageMemorySize;for(const i of this.layerInfo[x.ELEVATION])this._usedMemory+=i.data?t:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=this.renderData.texture?.usedMemory??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===x.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===x.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof Q?e.texture.usedMemory:e instanceof HTMLImageElement||e instanceof M?this._cpuImageMemorySize:e instanceof O?e.memoryUsage:e instanceof A?e.usedMemory/e.referenced:0}updateScreenDepth(e){const t=this._center[oe.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return K.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===I.OUTSIDE))return K.NONE;const h=this.level;s(pe,m(this._center[oe.MIDDLE]),t);let u=n(pe),d=pe,c=m(this._center[oe.MIDDLE]);s(fe,this._center[oe.TOP],t);const g=n(fe);g<u&&(u=g,d=fe,c=this._center[oe.TOP]),s(_e,this._center[oe.BOTTOM],t);const p=n(_e);if(p<u&&(u=p,d=_e,c=this._center[oe.BOTTOM]),this._edgeLen2>u&&h<e.maxLod)return K.SPLIT;const f=Math.sqrt(u),_=e.fovX*f*2,y=this._edgeLen/_,A=()=>{if(h<e.maxLod)return this.elevationLevel=h,K.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,K.ELEVATION):K.NONE},M=null!=i?i-h:1/0;if(M<=.5)return A();const T=r(this.up,pe),v=this._elevationBoundsMax-this._elevationBoundsMin,E=v/this.edgeLen;if(e.aboveGround&&T>0&&E<.001){if(T/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return K.NONE}const D=null!=i?3-Math.min(M,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return A();if(h<7)return K.SPLIT;a(me,this.up,T),s(me,me,d);const L=n(me);if(L<=this.radius*this.radius)return K.SPLIT;a(me,me,this.radius/Math.sqrt(L)),o(me,me,c),s(me,t,me);const x=Math.min(1,(Math.abs(r(me,this.up))+.5*v+this._curvatureHeight)/l(me)),S=ee/e.angledSplitBias,O=e.fovY*f*2;return x*(this._edgeLen/O*D)<S*e.relativeHeightLimit?K.NONE:K.SPLIT}setChildren(e,t,i,s){j(!!(e&&t&&i&&s),"Null child passed");const n=this._children;return n[0]=e,n[1]=t,n[2]=i,n[3]=s,n}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of L)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){e.unloadTile(this);for(const t of L){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[x.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of L){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==x.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=n.data&&"type"in n.data&&"vector-tile"===n.data.type;return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(me,m(this._center[oe.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);j(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=null!=i&&"type"in i&&"vector-tile"===i.type,n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this._lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case x.MAP:return this._updateTexture(t);case x.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===E.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===E.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[x.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[x.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(me,this.up,i),o(m(s[oe.MIDDLE]),this.centerAtSeaLevel,me),a(me,this.up,e),o(s[oe.TOP],this.centerAtSeaLevel,me),a(me,this.up,t),o(s[oe.BOTTOM],this.centerAtSeaLevel,me)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[x.ELEVATION][e],s=b(this.level),n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,x.ELEVATION),o=U(a);if(!Z(this,o,!1))return;const l=ae;let h=!1;const u=i.data;if(u&&u.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,h=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[x.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,h=!0))}h&&(null==i.elevationBounds&&(i.elevationBounds=new T),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(se(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:J.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,E.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of L){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,E.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(C(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n];let a=!1;const o=this._surface.layerViewByIndex(n,t),l=U(o);if(r.loadingAgent?Z(this,l,!1)?(r.loadingAgent!==$&&r.loadingAgent.setSuspension(s),r.loadingAgent!==$&&(a=r.loadingAgent.update())):r.dispose():Z(this,l,!1)&&(r.loadingAgent=ie(this,n,t,s),a=r.loadingAgent.startLoading(),a?r.loadingAgent===$&&this.setPendingUpdate(K.GEOMETRY):(se(r.loadingAgent),r.loadingAgent=$)),r.loadingAgent===$&&this.updateRenderData(t,E.FADING),!this._hasBlendModes(e,i.length,t)&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,b(this.level)-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this.getNeighborLIJ(i,e);return s?he(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===D.NORTH_EAST?1:e===D.NORTH_WEST?0:e===D.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===D.NORTH?[0,1]:e===D.NORTH_EAST?[1]:e===D.EAST?[1,3]:e===D.SOUTH_EAST?[3]:e===D.SOUTH?[2,3]:e===D.SOUTH_WEST?[2]:e===D.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!R||i>=0),0===i)return 0;const s=2**i,n=1==(1&e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return R&&(P(a<=o&&o<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(w(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));P(!s||de(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=W(t)?-1:q(t)?1:0,s=F(t)?-1:H(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this._lij[2]}get isNorthEnd(){return 0===this._lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+c()>=t}checkGeometryWaterproofness(){k&&(P(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(W(e)&&t[3]+s>=i[3])return!1;if(q(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&H(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[oe.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function ie(e,t,i,s){const n=i===x.ELEVATION?re.acquire():ne.acquire();return n.init(e,t,i,s),n}function se(e){e.dispose(),e instanceof v?re.release(e):e instanceof S&&ne.release(e)}const ne=new i(S),re=new i(v),ae=new T;var oe;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function he(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ue(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===D.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===D.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case D.NORTH:return X(e.extent[3],t.extent[1],s);case D.SOUTH:return X(e.extent[1],t.extent[3],s);case D.EAST:return X(e.extent[2],t.extent[0],s)||X(e.extent[2],-t.extent[0],s);case D.WEST:return X(e.extent[0],t.extent[2],s)||X(e.extent[0],-t.extent[2],s)}}function de(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ce(e,t,i):ce(t,e,B(i)))}function ce(e,t,i){P(e.level>=t.level);const s=Y(i),n=z(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=X(o[0],l[0],h)||e.surface.isGlobal&&X(o[0],-l[0],h),d=X(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return P(!1),!1;if(!u&&!d)return P(!1),!1;const c=u?ge(a[1],a[3],r[1],r[3],h):ge(a[0],a[2],r[0],r[2],h);return P(c),c}function ge(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(oe||(oe={}));const pe=u(),fe=u(),_e=u(),me=u();export{oe as CenterPosition,te as Tile,de as isCornerNeighbor,ue as isEdgeNeighbor,he as lijEquals};
|
|
5
|
+
import{clamp as e}from"../../../core/mathUtils.js";import{abortMaybe as t}from"../../../core/maybe.js";import i from"../../../core/ObjectPool.js";import{f as s,p as n,k as r,h as a,g as o,l,c as h}from"../../../chunks/vec32.js";import{create as u,unitZ as d}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{getEpsilon as c}from"../../../core/libs/gl-matrix-2/math/common.js";import{getReferenceEllipsoid as g}from"../../../geometry/ellipsoidUtils.js";import{create as p,equals as f}from"../../../geometry/support/aaBoundingRect.js";import{d as _,g as m}from"../../../chunks/sphere.js";import{isGroupLayer as y}from"../../../layers/support/layerUtils.js";import{VectorTile as A}from"../../2d/engine/vectorTiles/VectorTile.js";import{ImageWithType as M}from"../support/StreamDataLoader.js";import{ElevationBounds as T}from"./ElevationBounds.js";import{ElevationTileAgent as v}from"./ElevationTileAgent.js";import{TextureUpdate as E}from"./interfaces.js";import{TileFrustumVisibility as I,NeighborIndex as D}from"./ITile.js";import{LayerClasses as L,LayerClass as x}from"./LayerClass.js";import{MapTileAgent as S}from"./MapTileAgent.js";import{RasterTile as O}from"./RasterTile.js";import{maxPatchTesselation as N,getElevationDesiredResolutionLevel as b}from"./TerrainConst.js";import{weakAssert as j,getLayerWithExtentRange as U,isBlendableLayerView as C,oppositeCorner as B,internalAssert as P,enableTerrainInternalChecks as R,neighborEdgeIndices as V,oppositeEdge as w,neighborCornerIndices as G,isNorth as W,isSouth as q,isWest as F,isEast as H,enableWaterproofnessTests as k,almostEquals as X,isWestCorner as Y,isNorthCorner as z}from"./terrainUtils.js";import{tileAgentDone as $}from"./TileAgent.js";import{TilePerLayerInfo as J}from"./TilePerLayerInfo.js";import Q from"./TileTexture.js";import{TileUpdate as K}from"./TileUpdate.js";import{fallsWithinLayer as Z}from"./tileUtils.js";const ee=.1;class te{constructor(){this._lij=[0,0,0],this._children=[null,null,null,null],this._pendingUpdates=0,this.renderData=null,this._dirty=!0,this._previouslyRendered=!1,this.extent=p(),this._elevationBoundsMin=NaN,this._elevationBoundsMax=0,this.layerInfo=[[],[]],this.extentInRadians=p(),this.centerAtSeaLevel=u(),this._center=[u(),_(),u()],this.up=d(),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._maxTesselation=0,this._usedMemory=null,this._mapTileMemoryInternal=0,this._mapDataRefCount=0,this.screenDepth=0,this.renderOrder=0,this._edgeLen=0,this._edgeLen2=0,this._curvatureHeight=0,this.extentMidX=0,this.extentMidY=0,this.distanceToPOI=-1,this._lastPOI=u(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0}get lij(){return this._lij}static prune(){ne.prune(0),re.prune(0),J.prune()}get _isCached(){return!this.isLeaf&&this._mapDataRefCount<=0}get maxTesselation(){return this._maxTesselation}get isWithinClippingArea(){return this._isWithinClippingArea}get intersectsClippingArea(){return this._intersectsClippingArea}get clippingArea(){return this._clippingArea}get parent(){return this._parent}get children(){return this._children}get surface(){return this._surface}get elevationBoundsMin(){return this._elevationBoundsMin}get elevationBoundsMax(){return this._elevationBoundsMax}get level(){return this._lij[0]}get key(){return`${this._lij[0]}/${this._lij[1]}/${this._lij[2]}`}get edgeLen(){return this._edgeLen}get radius(){return this._center[oe.MIDDLE][3]}get visible(){return this._dirty&&this.computeVisibility(),this._visible}get frustumVisibility(){return this._dirty&&this.computeVisibility(),this._frustumVisibility}computeVisibility(){this._dirty=!1;const e=this.parent,t=e?.frustumVisibility??I.INTERSECTS;this._frustumVisibility=t===I.INSIDE?I.INSIDE:t===I.OUTSIDE?I.OUTSIDE:this._calculateFrustumVisibilityStatus(this.surface.frustum);const i=this._frustumVisibility!==I.OUTSIDE&&this._intersectsClippingArea;i!==this._visible&&(this._visible=i,this._surface.emit("tiles-visibility-changed"),this._surface.renderer.setDirty(),this.updateAgentSuspension())}get loadable(){return this.visible||this._surface.view.state.fixedContentCamera}get rendered(){const e=!!this.renderData;return e!==this._previouslyRendered&&(this._surface.emit("tiles-visibility-changed"),this._previouslyRendered=e,this._surface.renderer.setDirty()),e}init(e,t,i,s,n){this._lij[0]=e,this._lij[1]=t,this._lij[2]=i,this.ellipsoid=g(n.tilingScheme.spatialReference),n.tilingScheme.getExtent(e,t,i,this.extent),n.tilingScheme.convertExtentToRadians(this.extent,this.extentInRadians),this.extentMidX=.5*(this.extent[0]+this.extent[2]),this.extentMidY=.5*(this.extent[1]+this.extent[3]),this._isWithinClippingArea=!0,this._intersectsClippingArea=!0,this._clippingArea=null,this._mapDataRefCount=0,n.upsampleMapCache.pop(this.key),this._edgeLen=0,this._edgeLen2=0,this._center[oe.MIDDLE][3]=0,this.elevationLevel=e,s&&!Number.isNaN(s.elevationBoundsMin)?(this._elevationBoundsMin=s.elevationBoundsMin,this._elevationBoundsMax=s.elevationBoundsMax):(this._elevationBoundsMin=0,this._elevationBoundsMax=0),this._pendingUpdates=0,this.renderData=null,this.screenDepth=0,this._visible=!1,this._previouslyRendered=!1,this._parent=s,this.unsetChildren(),this._surface=n,this.updateVisibility(),this.maxLevelDeltaNeighborCount=0,this.unmergableChildCount=0;for(const r of L){const e=n.numLayers(r),t=this.layerInfo[r];for(const i of t)i.release();t.length=e;for(let i=0;i<e;i++)t[i]=J.acquire(this._surface.upsampleInfoPool),r===x.ELEVATION&&this.findElevationBoundsForLayer(i,-1)}this.computeElevationBounds(),this._maxTesselation=Math.min(n.tilingScheme.pixelSize,N)}dispose(){j(!this.renderData,"tile.renderData was not unloaded"),this._surface.upsampleMapCache.pop(this.key);for(const e of L){for(const t of this.layerInfo[e])t.release();this.layerInfo[e].length=0}this._parent=null;for(let e=0;e<4;++e)this._children[e]=null;this._surface=null,this.setMemoryDirty()}refMapData(){++this._mapDataRefCount,this._isCached||this._surface.upsampleMapCache.pop(this.key)}unrefMapData(){if(--this._mapDataRefCount,this._isCached){this.setMemoryDirty();const e=this._cachedMemory;e>0&&this._surface.upsampleMapCache.put(this.key,this,e)}}setMemoryDirty(){this._usedMemory=null}get usedMemory(){return this._ensureUsedMemory()+(this._isCached?0:this._mapTileMemoryInternal)}get _cachedMemory(){return this._isCached?this._mapTileMemory:0}get _mapTileMemory(){return this._ensureUsedMemory(),this.layerInfo[x.MAP].reduce(((e,t)=>e+(t instanceof A?t.usedMemory/t.referenced:0)),this._mapTileMemoryInternal)}get _cpuImageMemorySize(){const e=4,t=this._surface.tilingScheme.pixelSize;return t*t*e}_ensureUsedMemory(){if(null!=this._usedMemory)return this._usedMemory;this._usedMemory=this._baseUsedMemory,this._mapTileMemoryInternal=0;let e=0;for(const{data:i}of this.layerInfo[x.MAP])i instanceof A?e+=this._getTerrainDataMemory(i):this._mapTileMemoryInternal+=this._getTerrainDataMemory(i);const t=this._cpuImageMemorySize;for(const i of this.layerInfo[x.ELEVATION])this._usedMemory+=i.data?t:0;return this.renderData&&(this._usedMemory+=this.renderData.estimatedGeometryMemoryUsage,this._mapTileMemoryInternal+=this.renderData.texture?.usedMemory??0),this._isCached&&this._surface.upsampleMapCache.updateSize(this.key,this,this._mapTileMemoryInternal+e),this._usedMemory}getUsedMemoryForLayer(e,t){const i=this.layerInfo[e][t];return i?.data?e===x.MAP?this._isCached?0:this._getTerrainDataMemory(i.data):e===x.ELEVATION?this._cpuImageMemorySize:0:0}_getTerrainDataMemory(e){return e instanceof Q?e.texture.usedMemory:e instanceof HTMLImageElement||e instanceof M?this._cpuImageMemorySize:e instanceof O?e.memoryUsage:e instanceof A?e.usedMemory/e.referenced:0}updateScreenDepth(e){const t=this._center[oe.MIDDLE],i=e,s=t[0],n=t[1],r=t[2],a=i[2]*s+i[6]*n+i[10]*r+i[14];this.screenDepth=a<0?0:a/(i[3]*s+i[7]*n+i[11]*r+i[15])}shouldSplit(e,t,i){if(!this.visible)return K.NONE;if(e.frustum&&(!this._intersectsClippingArea||this._calculateFrustumVisibilityStatus(e.frustum)===I.OUTSIDE))return K.NONE;const h=this.level;s(pe,m(this._center[oe.MIDDLE]),t);let u=n(pe),d=pe,c=m(this._center[oe.MIDDLE]);s(fe,this._center[oe.TOP],t);const g=n(fe);g<u&&(u=g,d=fe,c=this._center[oe.TOP]),s(_e,this._center[oe.BOTTOM],t);const p=n(_e);if(p<u&&(u=p,d=_e,c=this._center[oe.BOTTOM]),this._edgeLen2>u&&h<e.maxLod)return K.SPLIT;const f=Math.sqrt(u),_=e.fovX*f*2,y=this._edgeLen/_,A=()=>{if(h<e.maxLod)return this.elevationLevel=h,K.NONE;const t=h+Math.ceil(-Math.log2(e.relativeWidthLimit/y));return t!==this.elevationLevel?(this.elevationLevel=t,K.ELEVATION):K.NONE},M=null!=i?i-h:1/0;if(M<=.5)return A();const T=r(this.up,pe),v=this._elevationBoundsMax-this._elevationBoundsMin,E=v/this.edgeLen;if(e.aboveGround&&T>0&&E<.001){if(T/f-Math.sin(this._curvatureHeight/(this.edgeLen*Math.SQRT1_2)*Math.PI)-E>0)return K.NONE}const D=null!=i?3-Math.min(M,2):1;if(y*D<e.relativeWidthLimit||h>=e.maxLod)return A();if(h<7)return K.SPLIT;a(me,this.up,T),s(me,me,d);const L=n(me);if(L<=this.radius*this.radius)return K.SPLIT;a(me,me,this.radius/Math.sqrt(L)),o(me,me,c),s(me,t,me);const x=Math.min(1,(Math.abs(r(me,this.up))+.5*v+this._curvatureHeight)/l(me)),S=ee/e.angledSplitBias,O=e.fovY*f*2;return x*(this._edgeLen/O*D)<S*e.relativeHeightLimit?K.NONE:K.SPLIT}setChildren(e,t,i,s){j(!!(e&&t&&i&&s),"Null child passed");const n=this._children;return n[0]=e,n[1]=t,n[2]=i,n[3]=s,n}unsetChildren(){this._children[0]=null,this._children[1]=null,this._children[2]=null,this._children[3]=null}get isLoaded(){return this.renderData?.hasGeometry??!1}load(){this.refMapData();for(const e of L)this._createOrUpdateAgents(0,e);this.surface.renderer.loadTile(this)}unload(e){e.unloadTile(this);for(const t of L){const e=this.layerInfo[t];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0}this.resetPendingUpdate(K.GEOMETRY),this.resetPendingUpdate(K.TEXTURE_NOFADING),this.resetPendingUpdate(K.TEXTURE_FADING),this.unrefMapData()}unloadMapData(){const e=this.layerInfo[x.MAP];for(const t of e)t.loadingAgent&&t.loadingAgent!==$&&(se(t.loadingAgent),t.loadingAgent=null),t.pendingUpdates=0;this.renderData&&this.renderData.releaseTexture(),this.setMemoryDirty()}updateClippingStatus(e){if(f(e,this._clippingArea))return!1;const t=this._intersectsClippingArea,i=this._isWithinClippingArea;null!=e?(this._intersectsClippingArea=this.intersectsExtent(e),this._isWithinClippingArea=this._isWithinExtent(e)):(this._intersectsClippingArea=!0,this._isWithinClippingArea=!0),this._clippingArea=e,this.updateVisibility();const s=i&&this._isWithinClippingArea,n=!(i||t||this._isWithinClippingArea||this._intersectsClippingArea);return!this.renderData||s||n||this.setPendingUpdate(K.GEOMETRY),!0}updateVisibility(){this._dirty=!0,this._surface.setTileTreeDirty()}getLayerInfo(e,t){return this.layerInfo[t][e]}hasLayerData(e,t){const i=this.layerInfo[t][e];return!(!i?.data||i.dataInvalidated)}get updating(){if(this.hasPendingUpdates)return!0;for(const e of L){const t=this.layerInfo[e];for(const e of t)if(e.loadingAgent&&e.loadingAgent!==$&&e.loadingAgent.updating)return!0}return!1}_isSuspended(e){return!!this.hasPendingUpdate(K.SPLIT)||e!==x.ELEVATION&&!this.loadable}get hasPendingUpdates(){return 0!==this._pendingUpdates}hasPendingUpdate(e){return(this._pendingUpdates&e)===e}setPendingUpdate(e){const t=this._pendingUpdates;return this._pendingUpdates|=e,e===K.SPLIT||e===K.MERGE?this._surface.setTileTreeDirty():this._surface.requestUpdate(),t!==this._pendingUpdates}resetPendingUpdate(e){return!!this.hasPendingUpdate(e)&&(this._pendingUpdates&=~e,!0)}requestLayerData(e,i,s){const n=this.layerInfo[i][e];if(n.waitingAgents.has(s))return console.warn("agent already requested this piece of map data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e),!0;if(n.waitingAgents.push(s),n.data&&!n.dataInvalidated){console.warn("agent requested existing data (tile %s, agent tile %s, layer: %d/%d)",this._lij.toString(),s.tile.lij.toString(),i,e);const t=n.data&&"type"in n.data&&"vector-tile"===n.data.type;return s.dataArrived(this,t),!0}if(n.requestPromise)return!0;t(n.requestAbort),n.requestAbort=new AbortController;const r=this._surface.requestTileData(this,e,i,n.requestAbort);if(!r)return n.requestAbort=null,!1;const a=()=>{n.requestPromise===r&&(n.requestPromise=null,n.requestAbort=null)};return n.requestPromise=r,r.then(a,a),!0}get isLeaf(){return null==this._children[0]}hasLij(e){return this._lij[0]===e[0]&&this._lij[1]===e[1]&&this._lij[2]===e[2]}findByLij(e){if(this.hasLij(e))return this;const t=this._children;if(!t[0])return null;return t[0].findByLij(e)||t[1].findByLij(e)||t[2].findByLij(e)||t[3].findByLij(e)}distanceToSquared(e){return n(s(me,m(this._center[oe.MIDDLE]),e))}containsPoint(e){const t=this.extent;return e[0]>=t[0]&&e[1]>=t[1]&&e[0]<=t[2]&&e[1]<=t[3]}containsPointXY(e,t){const i=this.extent;return e>=i[0]&&t>=i[1]&&e<=i[2]&&t<=i[3]}unrequestLayerData(e,t,i){const s=this.layerInfo[t][e],n=s.waitingAgents,r=null!=n.removeUnordered(i);j(r,"agent has not requested this piece of map data"),n.length<1&&(s.abortRequest(),this.setMemoryDirty())}dataArrived(e,t,i){const s=null!=i&&"type"in i&&"vector-tile"===i.type,n=this.layerInfo[t][e];n.data=i,n.dataInvalidated=!1,n.waitingAgents.forAll((e=>e.dataArrived(this,s))),n.waitingAgents.clear(),this.setMemoryDirty()}dataMissing(e,t,i){i.notInTilemap||console.error(`Tile ${this._lij.toString()} layer ${t}/${e} error ${i}`);const s=this.layerInfo[t][e];s.dataMissing=!0,s.waitingAgents.forAll((e=>e.dataMissing())),s.waitingAgents.clear(),this.setMemoryDirty()}updateRenderData(e,t,i){switch(i&&this.forEachLoadedNeighbor((i=>i.updateRenderData(e,t))),e){case x.MAP:return this._updateTexture(t);case x.ELEVATION:return this._updateGeometry()}}_updateTexture(e){this.renderData&&(this.resetPendingUpdate(e===E.FADING?K.TEXTURE_NOFADING:K.TEXTURE_FADING),this.setPendingUpdate(e===E.FADING?K.TEXTURE_FADING:K.TEXTURE_NOFADING))}_updateGeometry(){this.setPendingUpdate(K.GEOMETRY);for(const e of this.layerInfo[x.ELEVATION])e.pendingUpdates|=K.GEOMETRY}invalidateLayerData(e,t){this.layerInfo[t][e].invalidateSourceData(),this.restartAgents(t)}computeElevationBounds(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax;let i=1/0,s=-1/0;const n=this.layerInfo[x.ELEVATION];let r=!0;for(const a of n)null!=a.elevationBounds&&(i=Math.min(i,a.elevationBounds.min),s=Math.max(s,a.elevationBounds.max),a.elevationBounds.hasNoDataValues||(r=!1));r&&(i=Math.min(i,0),s=Math.max(s,0)),e===i&&t===s||(this._elevationBoundsMin=i,this._elevationBoundsMax=s,this.updateRadiusAndCenter(),this._surface.setTileTreeDirty())}_updateCenter(){const e=this._elevationBoundsMin,t=this._elevationBoundsMax,i=.5*(e+t),s=this._center;a(me,this.up,i),o(m(s[oe.MIDDLE]),this.centerAtSeaLevel,me),a(me,this.up,e),o(s[oe.TOP],this.centerAtSeaLevel,me),a(me,this.up,t),o(s[oe.BOTTOM],this.centerAtSeaLevel,me)}findElevationBoundsForLayer(e,t){const i=this.layerInfo[x.ELEVATION][e],s=b(this.level),n=Math.max(this.elevationLevel-s,0),r=i.elevationBounds;if(null!=r&&r.level>=t&&r.level<=n)return;const a=this._surface.layerViewByIndex(e,x.ELEVATION),o=U(a);if(!Z(this,o,!1))return;const l=ae;let h=!1;const u=i.data;if(u&&u.level<=n){const e=i.data;l.min=e.samplerData.data.minValue,l.max=e.samplerData.data.maxValue,l.hasNoDataValues=e.samplerData.data.hasNoDataValues,l.level=this.level,h=!0}else{let t,i,r=0;for(let a=this._parent;a&&(!i||r<s)&&(r=this.elevationLevel-a.level,t=i||t,i=a.layerInfo[x.ELEVATION][e].data,!(!i&&t&&a.level<=n));a=a.parent);i=i||t,i&&(i.computeMinMaxValue(this._lij[0],this._lij[1],this._lij[2],l),l.min!==1/0&&(l.level=i.level,h=!0))}h&&(null==i.elevationBounds&&(i.elevationBounds=new T),i.elevationBounds.copyFrom(l))}modifyLayers(e,t,i){const s=this.layerInfo[i];for(const a of s)a.loadingAgent&&a.loadingAgent!==$&&(se(a.loadingAgent),a.loadingAgent=null),a.waitingAgents.clear();for(let a=0;a<s.length;++a)void 0===e[a]&&s[a].release();const n=new Array(...s),r=t.length;s.length=r;for(let a=0;a<r;a++){const e=t[a];s[a]=e>-1?n[e]:J.acquire(this._surface.upsampleInfoPool)}this.setMemoryDirty()}restartAgents(e){this.renderData&&(this._createOrUpdateAgents(0,e),this.updateRenderData(e,E.FADING))}updateAgents(e){if(this.renderData){const t=this.layerInfo[e];for(const e of t)e.loadingAgent===$&&(e.loadingAgent=null);this._createOrUpdateAgents(0,e)}}updateAgentSuspension(){for(const e of L){const t=this._isSuspended(e);for(const i of this.layerInfo[e])i.loadingAgent&&i.loadingAgent!==$&&(i.loadingAgent.setSuspension(t),i.loadingAgent===$&&this.updateRenderData(e,E.FADING))}}removeLayerAgent(e,t){const i=this.layerInfo[t][e];i.loadingAgent&&i.loadingAgent!==$&&i.loadingAgent.dispose(),i.loadingAgent=null}agentDone(e,t){const i=this.layerInfo[t][e];i.loadingAgent=$,i.data||null!=i.upsampleInfo||this._createOrUpdateAgents(e+1,t)}_hasBlendableAncestor(e){return"normal"!==e.blendMode||y(e.parent)&&this._hasBlendableAncestor(e.parent)}_hasBlendModes(e,t,i){for(let s=e;s<t;++s){const e=this._surface.layerViewByIndex(s,i);if(C(e)&&"normal"!==e?.layer?.blendMode||y(e?.layer?.parent)&&this._hasBlendableAncestor(e?.layer?.parent))return!0}return!1}_createOrUpdateAgents(e,t){const i=this.layerInfo[t];if(0===i.length)return;const s=this._isSuspended(t);for(let n=e;n<i.length;++n){const r=i[n];let a=!1;const o=this._surface.layerViewByIndex(n,t),l=U(o);if(r.loadingAgent?Z(this,l,!1)?(r.loadingAgent!==$&&r.loadingAgent.setSuspension(s),r.loadingAgent!==$&&(a=r.loadingAgent.update())):r.dispose():Z(this,l,!1)&&(r.loadingAgent=ie(this,n,t,s),a=r.loadingAgent.startLoading(),a?r.loadingAgent===$&&this.setPendingUpdate(K.GEOMETRY):(se(r.loadingAgent),r.loadingAgent=$)),r.loadingAgent===$&&this.updateRenderData(t,E.FADING),!this._hasBlendModes(e,i.length,t)&&a&&o.isOpaque)return}}_isWithinExtent(e){const t=this.extent;return t[0]>=e[0]&&e[2]>=t[2]&&t[1]>=e[1]&&e[3]>=t[3]}intersectsExtent(e){const t=this.extent;return t[2]>=e[0]&&e[2]>=t[0]&&t[3]>=e[1]&&e[3]>=t[1]}getElevationVerticesPerSide(t){const i=this.elevationLevel-this.level,s=Math.max(this.level-t,b(this.level)-i),n=e(1+(this.maxTesselation>>s),2,this.maxTesselation+1),r=this.getDefaultVerticesPerSide();return Math.max(n,r)}get test(){return{cachedMemory:this._cachedMemory}}_findLIJ(e,t){if(!e)return null;const i=this.surface.rootTiles;if(null!=i)for(const s of i)if(le(s,e)){let i=s,n=e[0]-i.level-1;for(;n>=0&&!i.isLeaf&&!t(i);){const t=e[1]>>n&1,s=e[2]>>n&1;i=i.children[2*t+s],n--}return t(i)?i:null}return null}findNeighborTile(e,t){const i=this._lij,s=this.getNeighborLIJ(i,e);return s?he(i,s)?t(this)?this:null:this._findLIJ(s,t):null}findCorner(e,t){const i=e===D.NORTH_EAST?1:e===D.NORTH_WEST?0:e===D.SOUTH_WEST?2:3;let s=this;for(;s.children[0]&&(!t||!t(s));)s=s.children[i];return s}findNeighborCornerTileExact(e,t){return this.findNeighborTile(e,(e=>t(e)||e.level===this.level))?.findCorner(B(e),t)||null}forAllSubtreeOnSide(e,t){const i=e===D.NORTH?[0,1]:e===D.NORTH_EAST?[1]:e===D.EAST?[1,3]:e===D.SOUTH_EAST?[3]:e===D.SOUTH?[2,3]:e===D.SOUTH_WEST?[2]:e===D.WEST?[0,2]:[0],s=e=>{const n=e.children;!t(e)&&n[0]&&i.forEach((e=>s(n[e])))};s(this)}getNeighborEdgeStartVertexIndex(e,t){if(!t)return 0;const i=this.level-t.level;if(P(!R||i>=0),0===i)return 0;const s=2**i,n=1==(1&e),r=n?0:1,a=t.lij[r+1]*s,o=this._lij[r+1],l=o-a,h=n?s-1-l:l;return R&&(P(a<=o&&o<a+s),P(0<=h&&h<s)),h}forEachLoadedNeighbor(e){const t=this.level,i=e=>e.level===t||e.isLoaded;V.forEach((t=>{const s=this.findNeighborTile(t,i);null!=s&&s!==this&&s.forAllSubtreeOnSide(w(t),(i=>!!i.isLoaded&&(e(i,t),!0)))})),G.forEach((t=>{const s=this.findNeighborTile(t,i)?.findCorner(B(t),(e=>e.isLoaded));P(!s||de(this,s,t)),s?.isLoaded&&e(s,t)}))}getNeighborLIJ(e,t){const i=W(t)?-1:q(t)?1:0,s=F(t)?-1:H(t)?1:0,n=[e[0],e[1]+i,e[2]+s];return n[1]<0?null:this.surface.isGlobal?this.wrapLIJ(n):n[2]<0?null:n}wrapLIJ(e){return!e||e[1]<0||e[1]>=2**e[0]?null:this.surface.wrapEastWest(e)}get westNeighborWestExtent(){return this.extent[0]*(this.isWestEnd?-1:1)}get eastNeighborEastExtent(){return this.extent[2]*(this.isEastEnd?-1:1)}get isEastEnd(){return this._lij[2]===this.surface.lijEastEnd(this.level)-1}get isWestEnd(){return 0===this._lij[2]}get isNorthEnd(){return 0===this._lij[1]}get isSouthEnd(){const e=this.surface.extent,t=e?.[1]??null;return null!=t&&this.extent[1]+c()>=t}checkGeometryWaterproofness(){k&&(P(this.isLoaded),this.renderData?.checkGeometryWaterproofness())}shouldHaveNeighbor(e){const t=this.extent,i=this.surface.rootTilesExtent,s=.25*(t[2]-t[0]);if(W(e)&&t[3]+s>=i[3])return!1;if(q(e)&&t[1]-s<=i[1])return!1;const n=this.surface.isGlobal;return!(!n&&F(e)&&t[0]-s<=i[0])&&!(!n&&H(e)&&t[2]+s>=i[2])}updateDistanceToPOI(e){const t=this._lastPOI;if(this.distanceToPOI>=0&&t[0]===e[0]&&t[1]===e[1]&&t[2]===e[2])return;h(this._lastPOI,e);const i=this._center[oe.MIDDLE],s=e[0]-i[0],n=e[1]-i[1],r=e[2]-i[2];this.distanceToPOI=s*s+n*n+r*r}}function ie(e,t,i,s){const n=i===x.ELEVATION?re.acquire():ne.acquire();return n.init(e,t,i,s),n}function se(e){e.dispose(),e instanceof v?re.release(e):e instanceof S&&ne.release(e)}const ne=new i(S),re=new i(v),ae=new T;var oe;function le(e,t){const i=e.lij,s=t[0]-i[0];return!(s<0)&&(t[1]>>s===i[1]&&t[2]>>s===i[2])}function he(e,t){return e[0]===t[0]&&e[1]===t[1]&&e[2]===t[2]}function ue(e,t,i){if(null==e||null==t)return!1;if(0===e.level&&0===t.level){if(e.isEastEnd&&t.isWestEnd&&i===D.EAST)return!0;if(e.isWestEnd&&t.isEastEnd&&i===D.WEST)return!0}const s=Math.max(1e-6*(e.extent[2]-e.extent[0]),1);switch(i){case D.NORTH:return X(e.extent[3],t.extent[1],s);case D.SOUTH:return X(e.extent[1],t.extent[3],s);case D.EAST:return X(e.extent[2],t.extent[0],s)||X(e.extent[2],-t.extent[0],s);case D.WEST:return X(e.extent[0],t.extent[2],s)||X(e.extent[0],-t.extent[2],s)}}function de(e,t,i){return null!=e&&null!=t&&t!==e&&(e.level>=t.level?ce(e,t,i):ce(t,e,B(i)))}function ce(e,t,i){P(e.level>=t.level);const s=Y(i),n=z(i),r=e.extent,a=t.extent,o=[s?r[0]:r[2],n?r[3]:r[1]],l=[s?a[2]:a[0],n?a[1]:a[3]],h=1e-5*(r[2]-r[0]),u=X(o[0],l[0],h)||e.surface.isGlobal&&X(o[0],-l[0],h),d=X(o[1],l[1],h);if(u&&d)return!0;if(e.level===t.level)return P(!1),!1;if(!u&&!d)return P(!1),!1;const c=u?ge(a[1],a[3],r[1],r[3],h):ge(a[0],a[2],r[0],r[2],h);return P(c),c}function ge(e,t,i,s,n){return e-n<=i&&i<=s&&s<=t+n}!function(e){e[e.TOP=0]="TOP",e[e.MIDDLE=1]="MIDDLE",e[e.BOTTOM=2]="BOTTOM"}(oe||(oe={}));const pe=u(),fe=u(),_e=u(),me=u();export{oe as CenterPosition,te as Tile,de as isCornerNeighbor,ue as isEdgeNeighbor,he as lijEquals};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../../../../core/PooledArray.js";import{fromQuat as
|
|
5
|
+
import t from"../../../../../core/PooledArray.js";import{fromQuat as e,scale as r}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{conjugate as n}from"../../../../../core/libs/gl-matrix-2/math/quat.js";import{create as a}from"../../../../../core/libs/gl-matrix-2/factories/quatf64.js";import{k as s,z as c,u as l,s as f,m as i,c as u,t as m,g as b}from"../../../../../chunks/vec32.js";import{create as h}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{signedDistance as p}from"../../../../../geometry/support/plane.js";import{empty as g,within as d,union as j}from"../../lib/depthRange.js";function w(t,e){const r=g(),{eye:o,frustum:n,viewForward:a}=t;e.forAll((t=>{const e=null!=t.offsetObb?t.offsetObb:t.obb,l=s(c(C,e.center,o),a),f=e.projectedRadius(a);if(d(r,l-f)&&d(r,l+f))return;const i=M(e,n);if(-1===i)return;if(0===i)return k.far=l+f,k.near=l-f,void j(r,k);const u=x.pushNew();u.near=l-f,u.far=l+f,u.mask=i,u.object=t}));for(let l=0;l<x.length;l++){const t=x.data[l];if(d(r,t.near)&&d(r,t.far))continue;k.far=t.far,k.near=1/0;const e=R(null!=t.object.offsetObb?t.object.offsetObb:t.object.obb,o,y,(e=>{let r=O;for(let o=0;o<F&&e.length>0;o++){if(0==(t.mask&1<<o))continue;z(n[o],e,r);const a=e;e=r,r=a}for(let t=0;t<e.length;t+=3){f(q,e.data[t],e.data[t+1],e.data[t+2]);const r=s(c(q,q,o),a);k.near=Math.min(k.near,r)}}));0===e&&(k.near=0),j(r,k)}return x.length=0,r}const x=new t({allocator:t=>t||{near:1/0,far:-1/0,mask:0,object:null},deallocator:t=>(t.object=null,t)}),k=g(),q=h(),v=h(),y=new t({deallocator:null}),O=new t({deallocator:null});function z(t,e,r){r.length=0;const o=e.length-3;A(q,e,o);const n=p(t,q);n<=0&&(r.push(q[0]),r.push(q[1]),r.push(q[2]));let a=0,s=n;for(;a<o;a+=3){A(v,e,a);const o=p(t,v);if(s*o<0){i(q,v,q,o/(o-s)),P(r,q)}o<=0&&P(r,v),s=o,u(q,v)}if(s*n<0){A(v,e,o);i(q,v,q,n/(n-s)),P(r,q)}}function A(t,e,r){return f(t,e.data[r],e.data[r+1],e.data[r+2])}function P(t,e){t.push(e[0]),t.push(e[1]),t.push(e[2])}function R(t,o,a,s){n(B,t.quaternion),c(C,o,t.center),l(C,C,B);const i=t.halfSize,u=8*((C[0]<-i[0]?-1:C[0]>i[0]?1:0)+3*(C[1]<-i[1]?-1:C[1]>i[1]?1:0)+9*(C[2]<-i[2]?-1:C[2]>i[2]?1:0)+13),h=S[u];if(0===h)return h;e(N,t.quaternion),r(N,N,t.halfSize);const p=(e,r)=>{const o=S[u+r+1];return f(e,((1&o)<<1)-1,(2&o)-1,((4&o)>>1)-1),m(e,e,N),b(e,t.center,e)};return a.length=0,P(a,p(D,0)),P(a,p(E,1)),P(a,p(C,2)),P(a,p(G,3)),s(a),1===h?h:(a.length=0,P(a,D),P(a,G),P(a,p(C,4)),P(a,p(H,5)),s(a),2===h||(a.length=0,P(a,D),P(a,H),P(a,p(C,6)),P(a,E),s(a)),h)}const S=(()=>{const t=new Array(216);let e=0;const r=r=>{for(let o=0;o<r.length;o++)t[e+o]=r[o];e+=8};return r([3,0,6,2,3,1,5,4]),r([2,0,2,3,1,5,4,0]),r([3,1,0,2,3,7,5,4]),r([2,0,1,3,2,6,4,0]),r([1,0,1,3,2,0,0,0]),r([2,1,5,7,3,2,0,0]),r([3,2,0,1,3,7,6,4]),r([2,2,0,1,3,7,6,0]),r([3,3,0,1,5,7,6,2]),r([2,0,1,5,4,6,2,0]),r([1,0,1,5,4,0,0,0]),r([2,1,3,7,5,4,0,0]),r([1,0,2,6,4,0,0,0]),r([0,0,0,0,0,0,0,0]),r([1,1,3,7,5,0,0,0]),r([2,2,3,7,6,4,0,0]),r([1,2,3,7,6,0,0,0]),r([2,3,1,5,7,6,2,0]),r([3,4,0,1,5,7,6,2]),r([2,5,7,6,4,0,1,0]),r([3,5,0,1,3,7,6,4]),r([2,4,5,7,6,2,0,0]),r([1,4,5,7,6,0,0,0]),r([2,5,1,3,7,6,4,0]),r([3,6,0,2,3,7,5,4]),r([2,6,2,3,7,5,4,0]),r([3,7,6,2,3,1,5,4]),t})(),F=4;function M(t,e){let r=0;for(let o=0;o<F;o++){const n=t.intersectPlane(e[o]);if(n>0)return-1;0===n&&(r|=1<<o)}return r}const N=o(),B=a(),C=h(),D=h(),E=h(),G=h(),H=h();export{w as computeDepthRange};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{invert as t,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as
|
|
5
|
+
import{invert as t,transpose as n}from"../../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as o}from"../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{z as e,t as s,F as i,s as a,n as m,c,k as p,b as r,o as h}from"../../../../../chunks/vec32.js";import{create as d}from"../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{create as l}from"../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{create as x}from"../../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as b}from"../../../../../geometry/support/FloatArray.js";import{compactIndices as _,getContinuousIndexArray as I}from"../../../../../geometry/support/Indices.js";import{ViewingMode as f}from"../../../../ViewingMode.js";import{componentMinimalSizeForIntersectionData as C,ComponentIntersectionData as u}from"./ComponentIntersectionData.js";import{Vertices as M}from"../../lib/Attribute.js";import{getVisibility as g}from"../../lib/ComponentUtils.js";import{computeInvDir as A,intersectAabbInvDir as j,intersectTriangles as y}from"../../materials/internal/MaterialUtil.js";class B{constructor(t,n,o){this.viewingMode=t,this.positionData=n,this._components=o,this._planetCenter=d(),this._planetNorth=d(),this._componentIndicesForBsp=null,this._componentBspNodes=[],this._aabb=[0,0,0,0,0,0],this._indices=n.indices?_(n.indices):I(n.positions.length/3),this._positions=n.positions,this._componentIntersectionData=new Array(o.count)}destroy(){this._positions=null,this._indices=null,this._componentIntersectionData.length=0,this._perComponentAabbs=null}getComponentAabb(t,n){const o=this._ensureComponentAabbs(),e=6*t;return n[0]=o[e],n[1]=o[e+1],n[2]=o[e+2],n[3]=o[e+3],n[4]=o[e+4],n[5]=o[e+5],n}getComponentAabbs(){return this._ensureComponentAabbs()}_ensureComponentAabbs(){return this._perComponentAabbs||(this._perComponentAabbs=this._computePerComponentAabbs()),this._perComponentAabbs}getComponentPositions(t,n){n.indices=this._indices,n.data=this._positions,n.stride=3,n.startIndex=this._components.offsets[t],n.endIndex=this._components.offsets[t+1]}intersect(o,p,r,h,d,l,x,b){const{position:_}=x,I=e(D,o,_),g=e(F,p,_),B=t(P,x.rotationScale);s(I,I,B),s(g,g,B);const v=n(R,B),k=new M(this._positions,3),z=this._indices,E=this._components.offsets,G=A(I,g,w);if(this.viewingMode===f.Global){const t=this._planetCenter;i(t,_),s(t,t,B);const n=this._planetNorth;a(n,0,0,1),s(n,n,B),m(n,n)}const L=c(U,I),O=c(V,g),S=e(q,g,I);m(S,S);const T=t=>{const n=this.getComponentAabb(t,N);if(null!=d){const n=d[t];null==h||b?(I[2]=L[2]-n,g[2]=O[2]-n):h.componentOffset=n}if(null==h||b||h.applyToAabb(n),!j(n,I,G,r))return;const o=E[t]/3,e=E[t+1]/3,i=(n,o,e)=>l(t,n,s(o,o,v),e);(null==h||b)&&e-o>C?(null==this._componentIntersectionData[t]&&(this._componentIntersectionData[t]=new u(this._indices,o,e,k)),this._componentIntersectionData[t].intersectRay(I,g,i)):y(I,g,o,e,z,k,void 0,h,i)};this._intersectComponents(T,b,I,g)}_intersectComponents(t,n,o,s){const i=this._components.pickability,a=this._components.visibility;if(this._components.visibility.componentCount<H){const n=n=>(g(i,n)&&t(n),!0);return void a.forEachComponent(n)}0===this._componentBspNodes.length&&this._generateComponentBspRoot();const c=this._componentIndicesForBsp,r=n=>{g(i,n)&&a.isVisible(n)&&t(n)},h=(t,n)=>{for(let o=t;o<n;++o)r(c[o])};if(n){let t=0;for(;t>=0;){const n=this._componentBspNodes[t],e=n.plane;if(!e||-1===n.child0&&-1===n.child1){h(n.minComponentIndexIndex,n.maxComponentIndexIndex);break}{h(n.minMidComponentIndexIndex,n.maxMidComponentIndexIndex);const s=p(e,o)-e[3];if(s<0){if(-1===n.child0){h(n.minComponentIndexIndex,n.minMidComponentIndexIndex);break}t=n.child0}else{if(!(s>0))break;if(-1===n.child1){h(n.maxMidComponentIndexIndex,n.maxComponentIndexIndex);break}t=n.child1}}}}else{const t=J;e(t,s,o),m(t,t);const n=this._componentBspNodes,i=e=>{const s=n[e],a=s.plane;if(!a||-1===s.child0&&-1===s.child1)h(s.minComponentIndexIndex,s.maxComponentIndexIndex);else{const n=p(a,o)-a[3],e=p(a,t);s.minComponentIndexIndex<s.minMidComponentIndexIndex&&(n<=0||e<0)&&(-1!==s.child0?i(s.child0):h(s.minComponentIndexIndex,s.minMidComponentIndexIndex)),h(s.minMidComponentIndexIndex,s.maxMidComponentIndexIndex),s.maxMidComponentIndexIndex<s.maxComponentIndexIndex&&(n>=0||e>0)&&(-1!==s.child1?i(s.child1):h(s.maxMidComponentIndexIndex,s.maxComponentIndexIndex))}};i(0)}}_generateComponentBspRoot(){const t=this._components.count,n=new Uint16Array(t);this._componentIndicesForBsp=n;for(let e=0;e<t;++e)n[e]=e;const o=this._ensureComponentAabbs(),s=this._planetCenter,d=this._planetNorth,x=G;i(x,s),m(x,x);r(L,d,x);const b=this._aabb,_=b[2],I=[];let C=0;const u=this._componentBspNodes;u.length=0;const M=(t,n)=>{const e=6*t,s=o[e],i=o[e+1],m=o[e+2],c=o[e+3],r=o[e+4],h=o[e+5],d=a(O,.5*(s+c),.5*(i+r),.5*(m+h)),l=.5*(c-s),x=.5*(r-i),b=.5*(h-m),_=Math.sqrt(l*l+x*x+b*b),I=n,f=n[3],C=p(I,d)-f;return Math.abs(C)>_?Math.sign(C):0},g=(t,e,s)=>{let i=1/0,a=1/0,m=1/0,c=-1/0,p=-1/0,r=-1/0;for(let h=e;h<s;++h){const t=6*n[h];i=Math.min(i,o[t]),c=Math.max(c,o[t+3]),a=Math.min(a,o[t+1]),p=Math.max(p,o[t+4]),m=Math.min(m,o[t+2]),r=Math.max(r,o[t+5])}t[0]=i,t[1]=a,t[2]=m,t[3]=c,t[4]=p,t[5]=r},A=this.viewingMode===f.Local;let j=!1;if(!A){const t=a(O,.5*(b[0]+b[3]),.5*(b[1]+b[4]),.5*(b[2]+b[5])),n=h(s,t);j=_>.5*n}const y=(t,o,i,h,x)=>{const b=u.length;let _;if(j||i>=T||o-t<S)_=new v(t,o,o,o,null);else{g(k,t,o);const h=k[0],x=k[1],f=k[2],C=k[3],u=k[4],j=C-h,B=u-x,w=l(),N=w;if(A)j>=B?(a(N,1,0,0),w[3]=-.5*(h+C)):(a(N,0,1,0),w[3]=-.5*(x+u));else{const t=z,n=E;a(t,.5*(h+C),.5*(x+u),f),e(t,t,s),m(t,t),r(n,t,d),m(n,n),j>=B?c(N,n):(r(N,n,t),m(N,N)),w[3]=p(N,s)}let D,F;{let e=t,s=o;for(;e<s;){const t=n[e];M(t,w)<0?++e:(--s,n[e]=n[s],n[s]=t)}D=e;let i=e;for(s=o;i<s;){const t=n[s-1];M(t,w)>0?--s:(n[s-1]=n[i],n[i]=t,++i)}F=s}_=new v(t,D,F,o,w),D>=t+S&&I.push((()=>y(t,D,i+1,b,!0))),o>=F+S&&I.push((()=>y(F,o,i+1,b,!1)))}if(u.push(_),-1!==h){const t=u[h];x?t.child0=b:t.child1=b}};for(I.push((()=>y(0,t,0,-1,!1)));C<I.length;){(0,I[C])(),++C}}_computePerComponentAabbs(){const t=this._components.count,n=b(6*t),o=this._indices,e=this._positions,s=this._components.offsets;let i=0,a=1/0,m=1/0,c=1/0,p=-1/0,r=-1/0,h=-1/0;for(let d=0;d<t;d++){const t=s[d],l=s[d+1];let x=1/0,b=1/0,_=1/0,I=-1/0,f=-1/0,C=-1/0;for(let n=t;n<l;n++){const t=3*o[n],s=e[t],i=e[t+1],a=e[t+2];x=Math.min(x,s),b=Math.min(b,i),_=Math.min(_,a),I=Math.max(I,s),f=Math.max(f,i),C=Math.max(C,a)}n[i++]=x,n[i++]=b,n[i++]=_,n[i++]=I,n[i++]=f,n[i++]=C,a=Math.min(a,x),m=Math.min(m,b),c=Math.min(c,_),p=Math.max(p,I),r=Math.max(r,f),h=Math.max(h,C)}return this._aabb[0]=a,this._aabb[1]=m,this._aabb[2]=c,this._aabb[3]=p,this._aabb[4]=r,this._aabb[5]=h,n}get positions(){return this._positions}get indices(){return this._indices}get aabb(){return this._ensureComponentAabbs(),this._aabb}}class v{constructor(t,n,o,e,s){this.minComponentIndexIndex=t,this.minMidComponentIndexIndex=n,this.maxMidComponentIndexIndex=o,this.maxComponentIndexIndex=e,this.plane=s,this.child0=-1,this.child1=-1}}const w=d(),N=x(),k=[0,0,0,0,0,0],D=d(),F=d(),P=o(),R=o(),U=d(),V=d(),q=d(),z=d(),E=d(),G=d(),L=d(),O=d(),S=5,T=10,H=7,J=d();export{B 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.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import has from"../../../../../../core/has.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{invert as r,transpose as o}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{H as a}from"../../../../../../chunks/vec32.js";import{fromArray as i,fromValues as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as p}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as c}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as d,IntegratedMeshMode as m}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as g}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as y,parameter as f,parameterBlock as b,MaterialParameterBlock as T}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as v}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as M}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as O}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as C}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as w}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as S}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as P}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as q,CullFaceOptions as N}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as A}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as D}from"../../../materials/pbrUtils.js";class R extends y{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=i(D),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new W,this.componentParameters=new _,this.textureAlphaCutoff=S,this.alphaDiscardMode=q.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=P.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new d;const a=new j(e.position),n=s(e.rotationScale);r(n,n),o(n,n),this.transformNormalGlobalFromModel=n,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,o){const s=this._techniqueConfiguration;s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasEmissionTexture=null!=this.emissionTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.transparencyPassType=t.identifier===v.Material&&null!=r.transparencyPassType?r.transparencyPassType:A.NONE,s.multipassEnabled=t.identifier===v.Material&&r.multipassEnabled,s.cullAboveGround=t.identifier===v.Material&&r.multipassTerrain.cullAboveGround,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?C.View:C.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===F.Transparent||a===F.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?L(r)?B(r)?m.ColorOverlayWithWater:m.ColorOverlay:m.NoOverlay:m.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===m.ColorOverlayWithWater?w.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?has("enable-feature:im-shading")&&this.isIntegratedMesh?w.Simplified:w.Schematic:w.Normal:w.Disabled,s.normalType=o.needsNormals?s.hasNormals?O.Compressed:O.ScreenDerivative:O.Ground,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===v.ShadowMap)s.output=M.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===v.Highlight)s.output=M.Highlight,s.vertexDiscardMode=x.None;else{switch(a===F.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=!1,s.receiveShadows=!1,t.output){case M.Color:s.receiveAmbientOcclusion=null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.hasScreenSpaceReflections=null!=r.ssr.lastFrameColor,s.hasCloudsReflections=null!=r.cloudsFade.data;break;case M.Alpha:s.hasOccludees=r.hasOccludees;break;case M.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(c,s,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const o=r.renderable.geometry,s=r.components,a=r.renderable.meta.cameraDepthSquared,i=s.geometryRanges,l=s.highlightRanges,n=s.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case F.Opaque:e.materialOpaque.submitDraw(this,o,i,a);break;case F.Transparent:e.materialTransparent.submitDraw(this,o,i,a);break;case F.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,i,a),e.materialTransparent.submitDraw(this,o,i,a);break;case F.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,i,a),k(t)&&e.highlightIntegratedMesh.submitDraw(this,o,i,a)}const u=this.componentParameters.castShadows!==I.None;u&&e.shadowMap.submitDraw(this,o,i,a),null!=l&&(e.highlight.submitDraw(this,o,l,a),u&&e.highlightShadowMap.submitDraw(this,o,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,o,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?F.IntegratedMesh:this.objectOpacity<1?F.Transparent:this.componentParameters.opaqueOverride===I.All?F.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===q.Blend||this.alphaDiscardMode===q.MaskBlend?F.Transparent:this.componentParameters.transparent===I.None?F.Opaque:this.componentParameters.transparent===I.All?F.Transparent:F.OpaqueAndTransparent}}var F,I;e([f({vectorOps:n})],R.prototype,"baseColor",void 0),e([f()],R.prototype,"usePBR",void 0),e([f()],R.prototype,"hasParametersFromSource",void 0),e([f({vectorOps:a})],R.prototype,"mrrFactors",void 0),e([f({vectorOps:a})],R.prototype,"emissiveFactor",void 0),e([f({dispose:!0})],R.prototype,"baseColorTexture",void 0),e([f({dispose:!0})],R.prototype,"metallicRoughnessTexture",void 0),e([f({dispose:!0})],R.prototype,"emissionTexture",void 0),e([f({dispose:!0})],R.prototype,"occlusionTexture",void 0),e([f({dispose:!0})],R.prototype,"normalTexture",void 0),e([f()],R.prototype,"objectOpacity",void 0),e([b()],R.prototype,"commonMaterialParameters",void 0),e([b()],R.prototype,"componentParameters",void 0),e([f()],R.prototype,"textureAlphaCutoff",void 0),e([f()],R.prototype,"alphaDiscardMode",void 0),e([f()],R.prototype,"isIntegratedMesh",void 0),e([f()],R.prototype,"polygonOffsetEnabled",void 0),e([f()],R.prototype,"ellipsoidMode",void 0),e([f()],R.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(F||(F={}));class W extends T{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=N.Back,this.hasSlicePlane=!0}}e([f()],W.prototype,"doubleSided",void 0),e([f()],W.prototype,"cullFace",void 0),e([f()],W.prototype,"hasSlicePlane",void 0);class _ extends T{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=I.All}get transparent(){return this.externalColor[3]<1?I.All:I.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?I.All:I.None}get visible(){return this.externalColor[3]>0?I.All:I.None}get type(){return g.Uniform}}e([f({vectorOps:n})],_.prototype,"externalColor",void 0),e([f()],_.prototype,"externalColorMixMode",void 0),e([f()],_.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(I||(I={}));class E extends T{constructor(){super(...arguments),this.texture=null,this.transparent=I.None,this.opaqueOverride=I.None,this.castShadows=I.None}get type(){return g.Varying}}function k(e){return null!=e.overlay?.getTexture(p.Highlight)}function B(e){return null!=e.overlay?.getTexture(p.WaterNormal)}function L(e){return null!=e.overlay?.getTexture(p.ColorNoRasterImage)}e([f()],E.prototype,"texture",void 0),e([f()],E.prototype,"transparent",void 0),e([f()],E.prototype,"opaqueOverride",void 0),e([f()],E.prototype,"castShadows",void 0);export{W as CommonMaterialParameters,R as ComponentMaterial,I as ComponentParameterSummary,_ as ComponentParametersUniform,E as ComponentParametersVarying};
|
|
5
|
+
import{_ as e}from"../../../../../../chunks/tslib.es6.js";import has from"../../../../../../core/has.js";import{releaseMaybe as t}from"../../../../../../core/maybe.js";import{invert as r,transpose as o}from"../../../../../../core/libs/gl-matrix-2/math/mat3.js";import{clone as s}from"../../../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{I as a}from"../../../../../../chunks/vec32.js";import{fromArray as i,fromValues as l}from"../../../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{v as n}from"../../../../../../chunks/vec42.js";import{fromValues as u}from"../../../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{ColorMixModeEnum as h}from"../../../../layers/support/symbolColorUtils.js";import{OverlayContent as p}from"../../../../terrain/OverlayContent.js";import{ComponentTechnique as c}from"./ComponentTechnique.js";import{ComponentTechniqueConfiguration as d,IntegratedMeshMode as m}from"./ComponentTechniqueConfiguration.js";import{ComponentDataType as g}from"./shader/ComponentData.glsl.js";import{VertexDiscardMode as x}from"./shader/VertexDiscardByOpacity.glsl.js";import{MaterialBase as y,parameter as f,parameterBlock as b,MaterialParameterBlock as T}from"../../../core/material/MaterialBase.js";import{RenderPassIdentifier as v}from"../../../core/renderPasses/AllRenderPasses.js";import{ShaderOutput as M}from"../../../core/shaderLibrary/ShaderOutput.js";import{NormalType as O}from"../../../core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{NormalsDoubleSidedMode as C}from"../../../core/shaderLibrary/shading/Normals.glsl.js";import{PBRMode as w}from"../../../core/shaderLibrary/shading/PhysicallyBasedRenderingParameters.glsl.js";import{defaultMaskAlphaCutoff as S}from"../../../core/shaderLibrary/util/AlphaCutoff.js";import{EllipsoidMode as P}from"../../../core/shaderLibrary/util/EllipsoidMode.js";import{TwoVectorPosition as j}from"../../../core/util/TwoVectorPosition.js";import{AlphaDiscardMode as q,CullFaceOptions as N}from"../../../lib/basicInterfaces.js";import{TransparencyPassType as A}from"../../../lib/TransparencyPassType.js";import{defaultAdvancedMRRFactors as D}from"../../../materials/pbrUtils.js";class R extends y{constructor(e,t){super(),this.toMapSpace=t,this.baseColor=u(1,1,1,1),this.usePBR=!1,this.hasParametersFromSource=!1,this.mrrFactors=i(D),this.emissiveFactor=l(0,0,0),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null,this.objectOpacity=1,this.commonMaterialParameters=new W,this.componentParameters=new _,this.textureAlphaCutoff=S,this.alphaDiscardMode=q.Opaque,this.isIntegratedMesh=!1,this.polygonOffsetEnabled=!1,this.ellipsoidMode=P.Earth,this.hasOccludees=!1,this._techniqueConfiguration=new d;const a=new j(e.position),n=s(e.rotationScale);r(n,n),o(n,n),this.transformNormalGlobalFromModel=n,this.transformWorldFromModelTL=a.low,this.transformWorldFromModelTH=a.high,this.transformWorldFromModelRS=e.rotationScale}dispose(){this._technique=t(this._technique),this.baseColorTexture=null,this.metallicRoughnessTexture=null,this.emissionTexture=null,this.occlusionTexture=null,this.normalTexture=null}get texture(){return null!=this.baseColorTexture?this.baseColorTexture.glTexture:null}get textureMetallicRoughness(){return null!=this.metallicRoughnessTexture?this.metallicRoughnessTexture.glTexture:null}get textureEmissive(){return null!=this.emissionTexture?this.emissionTexture.glTexture:null}get textureOcclusion(){return null!=this.occlusionTexture?this.occlusionTexture.glTexture:null}get textureNormal(){return null!=this.normalTexture?this.normalTexture.glTexture:null}prepareTechnique(e,t,r,o){const s=this._techniqueConfiguration;s.hasVertexColors=o.colors,s.hasNormals=o.hasNormals,s.textureCoordinateType=o.textureCoordinates,s.hasMetallicRoughnessTexture=null!=this.metallicRoughnessTexture,s.hasEmissionTexture=null!=this.emissionTexture,s.hasOcclusionTexture=null!=this.occlusionTexture,s.hasNormalTexture=null!=this.normalTexture,s.transparencyPassType=t.identifier===v.Material&&null!=r.transparencyPassType?r.transparencyPassType:A.NONE,s.multipassEnabled=t.identifier===v.Material&&r.multipassEnabled,s.cullAboveGround=t.identifier===v.Material&&r.multipassTerrain.cullAboveGround,s.ellipsoidMode=this.ellipsoidMode,s.componentData=this.componentParameters.type,s.cullFace=this.commonMaterialParameters.cullFace,s.doubleSidedMode=this.commonMaterialParameters.doubleSided?C.View:C.None,s.hasColorTexture=null!=this.baseColorTexture;const a=this._computeWhichMaterialPass();if(s.blendingEnabled=a===F.Transparent||a===F.OpaqueAndTransparent,s.alphaDiscardMode=this.alphaDiscardMode,s.integratedMeshMode=this.isIntegratedMesh?L(r)?B(r)?m.ColorOverlayWithWater:m.ColorOverlay:m.NoOverlay:m.None,s.hasPolygonOffset=this.polygonOffsetEnabled,s.pbrMode=s.integratedMeshMode===m.ColorOverlayWithWater?w.WaterOnIntegratedMesh:this.usePBR?this.hasParametersFromSource?has("enable-feature:im-shading")&&this.isIntegratedMesh?w.Simplified:w.Schematic:w.Normal:w.Disabled,s.normalType=o.needsNormals?s.hasNormals?O.Compressed:O.ScreenDerivative:O.Ground,s.hasSlicePlane=null!=r.slicePlane&&this.commonMaterialParameters.hasSlicePlane,t.identifier===v.ShadowMap)s.output=M.Shadow,s.vertexDiscardMode=x.None;else if(t.identifier===v.Highlight)s.output=M.Highlight,s.vertexDiscardMode=x.None;else{switch(a===F.OpaqueAndTransparent?s.vertexDiscardMode=t.transparent?x.Opaque:x.Transparent:s.vertexDiscardMode=x.None,s.output=t.output,s.receiveAmbientOcclusion=!1,s.receiveShadows=!1,t.output){case M.Color:s.receiveAmbientOcclusion=null!=r.ssao,s.hasOccludees=r.hasOccludees,s.receiveShadows=r.shadowMap.ready,s.hasScreenSpaceReflections=null!=r.ssr.lastFrameColor,s.hasCloudsReflections=null!=r.cloudsFade.data;break;case M.Alpha:s.hasOccludees=r.hasOccludees;break;case M.ObjectAndLayerIdColor:s.objectAndLayerIdColor=!0}s.snowCover=this.hasSnowCover(r)}return this._technique=e.releaseAndAcquire(c,s,this._technique),this._setClean(),this._technique}hasSnowCover(e){return null!=e.weather&&e.weatherVisible&&"snowy"===e.weather.type&&"enabled"===e.weather.snowCover}submit(e,t,r){if(0===this.objectOpacity)return;const o=r.renderable.geometry,s=r.components,a=r.renderable.meta.cameraDepthSquared,i=s.geometryRanges,l=s.highlightRanges,n=s.defaultShadowMapRanges;switch(this._computeWhichMaterialPass()){case F.Opaque:e.materialOpaque.submitDraw(this,o,i,a);break;case F.Transparent:e.materialTransparent.submitDraw(this,o,i,a);break;case F.OpaqueAndTransparent:e.materialOpaque.submitDraw(this,o,i,a),e.materialTransparent.submitDraw(this,o,i,a);break;case F.IntegratedMesh:e.materialIntegratedMesh.submitDraw(this,o,i,a),k(t)&&e.highlightIntegratedMesh.submitDraw(this,o,i,a)}const u=this.componentParameters.castShadows!==I.None;u&&e.shadowMap.submitDraw(this,o,i,a),null!=l&&(e.highlight.submitDraw(this,o,l,a),u&&e.highlightShadowMap.submitDraw(this,o,l,a)),u&&null!=n&&e.defaultShadowMap.submitDraw(this,o,n,a)}_computeWhichMaterialPass(){return this.isIntegratedMesh?F.IntegratedMesh:this.objectOpacity<1?F.Transparent:this.componentParameters.opaqueOverride===I.All?F.Opaque:this.baseColor[3]<1||this.alphaDiscardMode===q.Blend||this.alphaDiscardMode===q.MaskBlend?F.Transparent:this.componentParameters.transparent===I.None?F.Opaque:this.componentParameters.transparent===I.All?F.Transparent:F.OpaqueAndTransparent}}var F,I;e([f({vectorOps:n})],R.prototype,"baseColor",void 0),e([f()],R.prototype,"usePBR",void 0),e([f()],R.prototype,"hasParametersFromSource",void 0),e([f({vectorOps:a})],R.prototype,"mrrFactors",void 0),e([f({vectorOps:a})],R.prototype,"emissiveFactor",void 0),e([f({dispose:!0})],R.prototype,"baseColorTexture",void 0),e([f({dispose:!0})],R.prototype,"metallicRoughnessTexture",void 0),e([f({dispose:!0})],R.prototype,"emissionTexture",void 0),e([f({dispose:!0})],R.prototype,"occlusionTexture",void 0),e([f({dispose:!0})],R.prototype,"normalTexture",void 0),e([f()],R.prototype,"objectOpacity",void 0),e([b()],R.prototype,"commonMaterialParameters",void 0),e([b()],R.prototype,"componentParameters",void 0),e([f()],R.prototype,"textureAlphaCutoff",void 0),e([f()],R.prototype,"alphaDiscardMode",void 0),e([f()],R.prototype,"isIntegratedMesh",void 0),e([f()],R.prototype,"polygonOffsetEnabled",void 0),e([f()],R.prototype,"ellipsoidMode",void 0),e([f()],R.prototype,"hasOccludees",void 0),function(e){e[e.Opaque=0]="Opaque",e[e.Transparent=1]="Transparent",e[e.OpaqueAndTransparent=2]="OpaqueAndTransparent",e[e.IntegratedMesh=3]="IntegratedMesh"}(F||(F={}));class W extends T{constructor(){super(...arguments),this.doubleSided=!1,this.cullFace=N.Back,this.hasSlicePlane=!0}}e([f()],W.prototype,"doubleSided",void 0),e([f()],W.prototype,"cullFace",void 0),e([f()],W.prototype,"hasSlicePlane",void 0);class _ extends T{constructor(){super(...arguments),this.externalColor=u(1,1,1,1),this.externalColorMixMode=h.Multiply,this.castShadows=I.All}get transparent(){return this.externalColor[3]<1?I.All:I.None}get opaqueOverride(){return this.externalColorMixMode===h.Replace&&1===this.externalColor[3]?I.All:I.None}get visible(){return this.externalColor[3]>0?I.All:I.None}get type(){return g.Uniform}}e([f({vectorOps:n})],_.prototype,"externalColor",void 0),e([f()],_.prototype,"externalColorMixMode",void 0),e([f()],_.prototype,"castShadows",void 0),function(e){e[e.All=0]="All",e[e.Some=1]="Some",e[e.None=2]="None"}(I||(I={}));class E extends T{constructor(){super(...arguments),this.texture=null,this.transparent=I.None,this.opaqueOverride=I.None,this.castShadows=I.None}get type(){return g.Varying}}function k(e){return null!=e.overlay?.getTexture(p.Highlight)}function B(e){return null!=e.overlay?.getTexture(p.WaterNormal)}function L(e){return null!=e.overlay?.getTexture(p.ColorNoRasterImage)}e([f()],E.prototype,"texture",void 0),e([f()],E.prototype,"transparent",void 0),e([f()],E.prototype,"opaqueOverride",void 0),e([f()],E.prototype,"castShadows",void 0);export{W as CommonMaterialParameters,R as ComponentMaterial,I as ComponentParameterSummary,_ as ComponentParametersUniform,E as ComponentParametersVarying};
|