@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{isSome as t}from"../../../core/arrayUtils.js";import{result as i,forEach as r}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import{makeHandle as o}from"../../../core/handleUtils.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as d}from"../../../core/maybe.js";import{isAbortError as l,allSettledValues as h,throwIfAborted as u}from"../../../core/promiseUtils.js";import{initial as p,watch as c,sync as _}from"../../../core/reactiveUtils.js";import{pt2px as m}from"../../../core/screenUtils.js";import{estimateSize as g,isArrayBuffer as f}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import{j as P,c as N}from"../../../chunks/vec32.js";import{clone as x}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{projectBoundingRect as v}from"../../../geometry/projection/projectBoundingRect.js";import{create as C}from"../../../geometry/support/aaBoundingBox.js";import{containsPoint as S,create as I}from"../../../geometry/support/aaBoundingRect.js";import{create as A,fromNormalAndOffset as k}from"../../../geometry/support/plane.js";import{makeDehydratedPoint as V}from"../../../layers/graphics/dehydratedPoint.js";import{CodedValue as R}from"../../../layers/support/CodedValue.js";import j from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as D}from"../../../layers/support/fieldUtils.js";import{PromiseQueue as L}from"../../../layers/support/PromiseQueue.js";import{getMetersPerUnit as U}from"../../../symbols/support/unitConversionUtils.js";import{LayerView3D as Q}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as W,QueuePerformanceInfo as M}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as z}from"./PointCloudWorkerHandle.js";import{checkPointCloudLayerValid as E,checkPointCloudLayerCompatibleWithView as F}from"./i3s/I3SUtil.js";import{nodeDiff as H,sortFrontToBack as B,splitWorkEntries as O}from"./i3s/LoDUtil.js";import{PagedNodeIndex as q}from"./i3s/PagedNodeIndex.js";import{getSplatSizeAlgorithm as G,getFixedSizeAlgorithm as T,getRendererInfo as $,getFilterInfo as J,rendererUsesFixedSizes as K,getAttributeInfo as X}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as Y,readGeometry as Z,elevationFromPositions as ee}from"./i3s/PointCloudWorkerUtil.js";import{PointGraphic as te}from"./i3s/PointGraphic.js";import{PointRenderer as ie,isPointRendererNode as re,PointRendererNode as se}from"./i3s/PointRenderer.js";import{PopupSceneLayerView as oe}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as ne}from"../support/extentUtils.js";import{computeMapPointFromVec3d as ae}from"../support/hitTest.js";import{ClientType as de}from"../support/index.js";import{Obb as le}from"../support/orientedBoundingBox.js";import{updatingProgress as he}from"../support/updatingProperties.js";import ue from"../../layers/LayerView.js";import{isScaleRangeActive as pe,extractSafeScaleBounds as ce,scaleBoundsPredicate as _e}from"../../support/layerViewUtils.js";import{TaskPriority as me}from"../../support/Scheduler.js";const ge=8,fe=A();let ye=class extends(oe(Q(ue))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._nodeScales=new Map,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new L,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl.path}get pointScale(){const e=G(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=T(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=T(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=$(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=J(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of D(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=C(),t=this.view.renderSpatialReference;return ne(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;if(e&&"absolute-height"===e.mode){const t=y(this.layer.spatialReference),i=U(e.unit);return(e.offset??0)*i/t}return 0}initialize(){const e=this.view.resourceController,t=xe(e);this._worker=new z(t),this.addResolvingPromise(this._worker.promise),this._tmpPoint=V(0,0,0,this.layer.spatialReference),E(this.layer),F(this.layer,this.view),this._indexRequester=e.createStreamDataRequester(de.I3S_INDEX),this._dataRequester=e.createStreamDataRequester(de.I3S_DATA),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._updatingHandles.add((()=>this._clippingBox),(()=>this._setUpdateViewNeeded()),p),this._updatingHandles.add((()=>this._elevationOffset),(()=>this._elevationOffsetChanged()),p),this._updatingHandles.add((()=>this.layer.renderer),(()=>this._rendererChanged()),p),this._updatingHandles.add((()=>this.layer.filters),(()=>this._reload()),p),this._updatingHandles.add((()=>this.layer.outFields),(()=>this._reload()),p),this._updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this._setUpdateViewNeeded())),this._updatingHandles.add((()=>this.view.state.contentCamera),(()=>this._setUpdateViewNeeded())),this.addHandles([this.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),c((()=>this.view.quality),(()=>this._setUpdateViewNeeded()),_)]),this.addResolvingPromise(i),this.when((()=>{this.addHandles([e.scheduler.registerTask(me.POINT_CLOUD_LAYER,this),e.scheduler.registerIdleStateCallbacks((()=>this._idleBegin()),(()=>this._idleEnd())),this._updatingHandles.add((()=>this.suspended),(e=>{e?this._clearNodeState():this._setUpdateViewNeeded()}),p)])}),(()=>{this._updatingHandles.removeAll(),this.removeAllHandles()}))}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=a(this._worker),this._destroyRenderer(),this._memCache=a(this._memCache),this._codedDomainPopulationAbortController=d(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ie({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerUid=this.layer.uid,this._updatingHandles.add((()=>this._clippingBox),(e=>this._renderer.clippingBox=e),p),this._updatingHandles.add((()=>this.suspended),(e=>this._setPointsVisible(!e)),p),this._updatingHandles.add((()=>this.pointScale),(e=>this._renderer.scaleFactor=e),p),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add((()=>this.useRealWorldSymbolSizes),(e=>this._renderer.useRealWorldSymbolSizes=e),p),this._updatingHandles.add((()=>this.pointSize),(e=>{const t=m(e);this._renderer.size=e,this._renderer.sizePx=t}),p),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._renderer.slicePlaneEnabled=e),p),this._updatingHandles.add((()=>this.inverseDensity),(()=>this._setUpdateViewNeeded()),p),this._updatingHandles.add((()=>this.maximumPointCount),(()=>this._setUpdateViewNeeded()),p),this._updatingHandles.add((()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor),(e=>{this._lodFactor=e,this._setUpdateViewNeeded()}),p)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i){const r=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,s=ae(this.view,i),o=this._createGraphicAttributes(e,r);return new te({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:r,epoch:this._nodeLoadEpoch},geometry:s,attributes:o,layer:this.layer,sourceLayer:this.layer})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_encodeGraphicAttribute(e,t,i,r){const s=e.storageInfo?.attributeValues,o=s?.valuesPerElement??1;if(1===o)r[e.name]=t[i];else if("UInt8"===s?.valueType&&o<=4){let s=0;const n=i*o;for(let e=n;e<n+o;e++)s=(s<<8)+t[e];r[e.name]=s}else r[e.name]=void 0}_setPointsVisible(e){e&&!this._rendererAdded?(this.view._stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view._stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=K(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_scaleUpdateHandler(e){const t=this.layer.effectiveScaleRange;pe(t.minScale,t.maxScale)?v(e.extent,e.spatialReference,Pe,this.layer.spatialReference)&&(this._nodeScales.forEach(((t,i)=>{if(!this._renderedNodes.has(i))return void this._nodeScales.delete(i);const r=this._index.getNode(i);S(Pe,r.obb.center)&&this._nodeScales.set(i,e.scale)})),this._setUpdateViewNeeded()):this._nodeScales.clear()}_displayNodes(e){this._workQueue=H([...this._renderedNodes],e,this._index),B(this._workQueue,this.view.state.contentCamera.viewForward,this._index),O(this._workQueue,ge,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach((({abortController:t})=>e.push(t))),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach((t=>t.load.forEach((t=>e.add(t)))));const t=new Array,i=new Map;this._loadingNodes.forEach(((r,s)=>{e.has(s)?i.set(s,r):t.push(r)})),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter((e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0})),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach((({abortController:e})=>e.abort())),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach((e=>this._removeFromRenderer(e))),this._cancelNodeLoading()}_idleBegin(){this._setUpdateViewNeeded()}_idleEnd(){this._setUpdateViewNeeded()}get running(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.running}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run((()=>this._updateWorkQueues()));this._indexQueue.length>0&&e.run((()=>this._processIndexQueue())););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then((t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()})).then((()=>{this._indexPagesLoading.delete(e)}),(()=>{this._indexPagesLoading.delete(e)})),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find((e=>!this._renderedNodes.has(e))))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map((e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return null!=i?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise}))).then((t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)})).catch((()=>{})).then((()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.running&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())})),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,t){const r="CLASS_CODE",s=this.layer.fieldsIndex.get(r);if(!s||s.domain)return;if(!e.includes(s.name))return;const o=await i(this.layer.queryCachedStatistics(r,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(s.domain=new j({name:"CLASS_CODE",codedValues:n.map((e=>new R({code:e.value,name:e.label})))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then((()=>{this._codedDomainPopulationAbortController=null}))),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,i){const s=this._splitGraphicsPerNode(e),o=this.layer.attributeStorageInfo,n=i.map((e=>X(o,e))).filter(t),a=async(e,t)=>{const i=this._index.getNode(t);await r(n,(async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}}))},d=[];return s.forEach(((e,t)=>{d.push(a(e,t))})),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof te&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return null!=i?Y({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=Z(t,await this._loadGeometry(e,null));return ee(i,i.length/3)}highlight(e){if(!e)return o();const t=s.isCollection(e)?e.toArray():Array.isArray(e)?e:[e];return this._renderer.highlight(t.map((e=>this._graphicToPointDefinition(e))))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new q(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then((e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()}))}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then((t=>t.nodes.map(((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:le.fromJSON(t.obb),obbInRenderSR:new le,firstChild:t.firstChild,childCount:t.childCount,vertexCount:t.vertexCount??t.pointCount,lodThreshold:t.lodThreshold??t.effectiveArea}))))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=P(s,t.eye),n=k(s,-o,fe),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const{minScale:h,maxScale:u}=ce(this.layer),p=0===h&&0===u?e=>l.push(e):e=>{const t=this._getScale(e);_e(t,h,u)&&l.push(e)};return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return p(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(p(e),!1)},pageMiss:(e,t)=>{p(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_getScale(e){let t=this._nodeScales.get(e);if(null==t){const i=this._index.getNode(e).obb.center;this._tmpPoint.x=i[0],this._tmpPoint.y=i[1],this._tmpPoint.z=i[2],t=this.view.basemapTerrain.getScale(this._tmpPoint),this._nodeScales.set(e,t)}return t}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw l(i)||n.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,i,r){const s=this.layer.outFields;if(!s)return[];const o=D(this.layer.fieldsIndex,s),n=new Set(e.map((e=>null!=e?e.name:null))),a=this.layer.attributeStorageInfo,d=[];for(const t of o){if(n.has(t))continue;const e=X(a,t);e&&d.push(i(e))}const l=await h(d);return u(r),l.filter(t)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=$(this.layer),s=J(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push((async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),h=n(d),p=s.map((e=>e.attributeInfo)),c=p.map((e=>n(e))),_=this._loadAdditionalUserAttributes([a,d,...p],n,t),[m,g,f,y,b]=await Promise.all([i,l,h,Promise.all(c),_]);u(t);const w={geometryBuffer:m,primaryAttributeData:g,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)}),t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}_requestNodePage(e,t){const i={f:"json",...this.layer.customParameters,token:this.layer.apiKey};return this._indexRequester.request(e,"json",{query:i,signal:t})}_requestData(e,t){return this._dataRequester.request(e,"binary",{query:{...this.layer.customParameters,token:this.layer.apiKey},signal:t})}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._nodeScales.delete(e),this._memCache.put(t.id.toString(),t,we(t))}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(re(t))return t.splatSize=r,t.obb=s,N(t.origin,t.obb.center),t;const o=le.fromData(t.obbData),a=o.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;n.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(o)}`),0==--this._maxLoggedBoxWarnings&&n.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,o)}return new se(e,r,x(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode((t=>{e+=Ne,e+=g(t.coordinates);for(const i of t.attributes){const t=i.values;f(t.buffer)&&(e+=g(t))}})),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount));let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Ne)/t)+i*Ne}get performanceInfo(){return new W(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount),0),this.maximumPointCount,new M(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){return{index:this._index,visibleNodes:this._renderedNodes}}};e([b()],ye.prototype,"layer",void 0),e([b()],ye.prototype,"baseUrl",null),e([b()],ye.prototype,"pointScale",null),e([b()],ye.prototype,"useRealWorldSymbolSizes",null),e([b()],ye.prototype,"pointSize",null),e([b()],ye.prototype,"inverseDensity",null),e([b()],ye.prototype,"maximumPointCount",void 0),e([b({readOnly:!0})],ye.prototype,"availableFields",null),e([b({readOnly:!0})],ye.prototype,"_clippingBox",null),e([b({readOnly:!0})],ye.prototype,"_elevationOffset",null),e([b({type:Boolean})],ye.prototype,"slicePlaneEnabled",void 0),e([b()],ye.prototype,"updating",void 0),e([b(he)],ye.prototype,"updatingProgress",void 0),e([b({readOnly:!0})],ye.prototype,"updatingProgressValue",null),ye=e([w("esri.views.3d.layers.PointCloudLayerView3D")],ye);const be=ye;function we(e){return 5*e.coordinates.length+128}const Pe=I(),Ne=160;function xe(e){return t=>e.immediate.schedule(t)}export{be as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import{isSome as t}from"../../../core/arrayUtils.js";import{result as i,forEach as r}from"../../../core/asyncUtils.js";import s from"../../../core/Collection.js";import{makeHandle as o}from"../../../core/handleUtils.js";import n from"../../../core/Logger.js";import{destroyMaybe as a,abortMaybe as d}from"../../../core/maybe.js";import{isAbortError as l,allSettledValues as h,throwIfAborted as u}from"../../../core/promiseUtils.js";import{initial as p,watch as c,sync as _}from"../../../core/reactiveUtils.js";import{pt2px as m}from"../../../core/screenUtils.js";import{estimateSize as g,isArrayBuffer as f}from"../../../core/typedArrayUtil.js";import{getMetersPerVerticalUnitForSR as y}from"../../../core/unitUtils.js";import{property as b}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as w}from"../../../core/accessorSupport/decorators/subclass.js";import{k as P,c as N}from"../../../chunks/vec32.js";import{clone as x}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import{projectBoundingRect as v}from"../../../geometry/projection/projectBoundingRect.js";import{create as C}from"../../../geometry/support/aaBoundingBox.js";import{containsPoint as S,create as I}from"../../../geometry/support/aaBoundingRect.js";import{create as A,fromNormalAndOffset as k}from"../../../geometry/support/plane.js";import{makeDehydratedPoint as V}from"../../../layers/graphics/dehydratedPoint.js";import{CodedValue as R}from"../../../layers/support/CodedValue.js";import j from"../../../layers/support/CodedValueDomain.js";import"../../../layers/support/Domain.js";import"../../../layers/support/InheritedDomain.js";import"../../../layers/support/RangeDomain.js";import{unpackFieldNames as D}from"../../../layers/support/fieldUtils.js";import{PromiseQueue as L}from"../../../layers/support/PromiseQueue.js";import{getMetersPerUnit as U}from"../../../symbols/support/unitConversionUtils.js";import{LayerView3D as Q}from"./LayerView3D.js";import{PointCloudLayerViewPerformanceInfo as W,QueuePerformanceInfo as M}from"./PointCloudLayerViewPerformanceInfo.js";import{PointCloudWorkerHandle as z}from"./PointCloudWorkerHandle.js";import{checkPointCloudLayerValid as E,checkPointCloudLayerCompatibleWithView as F}from"./i3s/I3SUtil.js";import{nodeDiff as H,sortFrontToBack as B,splitWorkEntries as O}from"./i3s/LoDUtil.js";import{PagedNodeIndex as q}from"./i3s/PagedNodeIndex.js";import{getSplatSizeAlgorithm as G,getFixedSizeAlgorithm as T,getRendererInfo as $,getFilterInfo as J,rendererUsesFixedSizes as K,getAttributeInfo as X}from"./i3s/PointCloudRendererUtil.js";import{getAttributeValues as Y,readGeometry as Z,elevationFromPositions as ee}from"./i3s/PointCloudWorkerUtil.js";import{PointGraphic as te}from"./i3s/PointGraphic.js";import{PointRenderer as ie,isPointRendererNode as re,PointRendererNode as se}from"./i3s/PointRenderer.js";import{PopupSceneLayerView as oe}from"./support/PopupSceneLayerView.js";import{projectToBoundingBox as ne}from"../support/extentUtils.js";import{computeMapPointFromVec3d as ae}from"../support/hitTest.js";import{ClientType as de}from"../support/index.js";import{Obb as le}from"../support/orientedBoundingBox.js";import{updatingProgress as he}from"../support/updatingProperties.js";import ue from"../../layers/LayerView.js";import{isScaleRangeActive as pe,extractSafeScaleBounds as ce,scaleBoundsPredicate as _e}from"../../support/layerViewUtils.js";import{TaskPriority as me}from"../../support/Scheduler.js";const ge=8,fe=A();let ye=class extends(oe(Q(ue))){constructor(){super(...arguments),this.type="point-cloud-3d",this.maximumPointCount=4e6,this.slicePlaneEnabled=!1,this._renderer=null,this._rendererAdded=!1,this._renderedNodes=new Set,this._nodeScales=new Map,this._updateViewNeeded=!0,this._lodFactor=1,this._maxLoggedBoxWarnings=5,this._pageMultiplier=1,this._nodeLoadEpoch=0,this._indexQueue=[],this._workQueue=new Array,this._idleQueue=new L,this._indexPagesLoading=new Map,this._loadingNodes=new Map,this._recalcWork=!0,this._layerIsVisible=!1,this._codedDomainPopulationPromise=null,this._codedDomainPopulationAbortController=null,this._totalWork=0,this._index=null,this._loadingInitNodePage=!1,this._nodeIdArray=[],this.ignoresMemoryFactor=!1}get baseUrl(){return this.layer.parsedUrl.path}get pointScale(){const e=G(this.layer?.renderer),t=1;return null!=e?.scaleFactor?e.scaleFactor:t}get useRealWorldSymbolSizes(){const e=T(this.layer?.renderer),t=!1;return null!=e?.useRealWorldSymbolSizes?e.useRealWorldSymbolSizes:t}get pointSize(){const e=T(this.layer?.renderer),t=0;return null!=e?.size?e.size:t}get inverseDensity(){const e=96;return this.layer?.renderer?1*e/this.layer.renderer.pointsPerInch:5}get availableFields(){const e=$(this.layer),t=new Set;e.primaryAttribute&&t.add(e.primaryAttribute.name),e.modulationAttribute&&t.add(e.modulationAttribute.name);const i=J(this.layer);if(i)for(const r of i)r.attributeInfo&&t.add(r.attributeInfo.name);if(this.layer.outFields)for(const r of D(this.layer.fieldsIndex,this.layer.outFields))t.add(r);return Array.from(t)}get _clippingBox(){if(!this.view||!this.view.clippingArea)return null;const e=C(),t=this.view.renderSpatialReference;return ne(this.view.clippingArea,e,t)?e:null}get _elevationOffset(){const e=this.layer&&this.layer.elevationInfo;if(e&&"absolute-height"===e.mode){const t=y(this.layer.spatialReference),i=U(e.unit);return(e.offset??0)*i/t}return 0}initialize(){const e=this.view.resourceController,t=xe(e);this._worker=new z(t),this.addResolvingPromise(this._worker.promise),this._tmpPoint=V(0,0,0,this.layer.spatialReference),E(this.layer),F(this.layer,this.view),this._indexRequester=e.createStreamDataRequester(de.I3S_INDEX),this._dataRequester=e.createStreamDataRequester(de.I3S_DATA),this._initRenderer();const i=this._initNodePages(),r=this.view.resourceController.memoryController;this._memCache=r.newCache(`pcl-${this.layer.uid}`),this._updatingHandles.add((()=>this._clippingBox),(()=>this._setUpdateViewNeeded()),p),this._updatingHandles.add((()=>this._elevationOffset),(()=>this._elevationOffsetChanged()),p),this._updatingHandles.add((()=>this.layer.renderer),(()=>this._rendererChanged()),p),this._updatingHandles.add((()=>this.layer.filters),(()=>this._reload()),p),this._updatingHandles.add((()=>this.layer.outFields),(()=>this._reload()),p),this._updatingHandles.add((()=>this.layer.effectiveScaleRange),(()=>this._setUpdateViewNeeded())),this._updatingHandles.add((()=>this.view.state.contentCamera),(()=>this._setUpdateViewNeeded())),this.addHandles([this.view.basemapTerrain.on("scale-change",(e=>this._scaleUpdateHandler(e))),c((()=>this.view.quality),(()=>this._setUpdateViewNeeded()),_)]),this.addResolvingPromise(i),this.when((()=>{this.addHandles([e.scheduler.registerTask(me.POINT_CLOUD_LAYER,this),e.scheduler.registerIdleStateCallbacks((()=>this._idleBegin()),(()=>this._idleEnd())),this._updatingHandles.add((()=>this.suspended),(e=>{e?this._clearNodeState():this._setUpdateViewNeeded()}),p)])}),(()=>{this._updatingHandles.removeAll(),this.removeAllHandles()}))}_setUpdateViewNeeded(){this._updateViewNeeded=!0,this._updateLoading()}destroy(){this.cancelLoading(),this._worker=a(this._worker),this._destroyRenderer(),this._memCache=a(this._memCache),this._codedDomainPopulationAbortController=d(this._codedDomainPopulationAbortController),this._codedDomainPopulationPromise=null}_initRenderer(){this._renderer=new ie({createGraphic:(e,t,i)=>this._createGraphic(e,t,i)}),this._renderer.layerUid=this.layer.uid,this._updatingHandles.add((()=>this._clippingBox),(e=>this._renderer.clippingBox=e),p),this._updatingHandles.add((()=>this.suspended),(e=>this._setPointsVisible(!e)),p),this._updatingHandles.add((()=>this.pointScale),(e=>this._renderer.scaleFactor=e),p),this._renderer.minSizePx=Math.sqrt(2),this._updatingHandles.add((()=>this.useRealWorldSymbolSizes),(e=>this._renderer.useRealWorldSymbolSizes=e),p),this._updatingHandles.add((()=>this.pointSize),(e=>{const t=m(e);this._renderer.size=e,this._renderer.sizePx=t}),p),this._updatingHandles.add((()=>this.slicePlaneEnabled),(e=>this._renderer.slicePlaneEnabled=e),p),this._updatingHandles.add((()=>this.inverseDensity),(()=>this._setUpdateViewNeeded()),p),this._updatingHandles.add((()=>this.maximumPointCount),(()=>this._setUpdateViewNeeded()),p),this._updatingHandles.add((()=>this.view.qualitySettings.sceneService.pointCloud.lodFactor),(e=>{this._lodFactor=e,this._setUpdateViewNeeded()}),p)}_destroyRenderer(){this._renderer.removeAll(),this._setPointsVisible(!1)}_createGraphic(e,t,i){const r=null!=e.pointIdFilterMap?e.pointIdFilterMap[t]:t,s=ae(this.view,i),o=this._createGraphicAttributes(e,r);return new te({pointCloudMetadata:{nodeId:e.id,pointIndexInNode:t,attributePointIndexInNode:r,epoch:this._nodeLoadEpoch},geometry:s,attributes:o,layer:this.layer,sourceLayer:this.layer})}_createGraphicAttributes(e,t){const i={};for(const r of e.attributes)this._encodeGraphicAttribute(r.attributeInfo,r.values,t,i);return i}_encodeGraphicAttribute(e,t,i,r){const s=e.storageInfo?.attributeValues,o=s?.valuesPerElement??1;if(1===o)r[e.name]=t[i];else if("UInt8"===s?.valueType&&o<=4){let s=0;const n=i*o;for(let e=n;e<n+o;e++)s=(s<<8)+t[e];r[e.name]=s}else r[e.name]=void 0}_setPointsVisible(e){e&&!this._rendererAdded?(this.view._stage.addRenderPlugin(this._renderer),this._rendererAdded=!0):!e&&this._rendererAdded&&(this.view._stage.removeRenderPlugin(this._renderer),this._rendererAdded=!1)}_rendererChanged(){this._renderer.useFixedSizes=K(this.layer.renderer),this._reload()}_reload(){this._clearNodeState(),this._memCache.clear(),this._setUpdateViewNeeded()}_elevationOffsetChanged(){this._clearNodeState(),this._memCache.clear(),this._initNodePages()}_scaleUpdateHandler(e){const t=this.layer.effectiveScaleRange;pe(t.minScale,t.maxScale)?v(e.extent,e.spatialReference,Pe,this.layer.spatialReference)&&(this._nodeScales.forEach(((t,i)=>{if(!this._renderedNodes.has(i))return void this._nodeScales.delete(i);const r=this._index.getNode(i);S(Pe,r.obb.center)&&this._nodeScales.set(i,e.scale)})),this._setUpdateViewNeeded()):this._nodeScales.clear()}_displayNodes(e){this._workQueue=H([...this._renderedNodes],e,this._index),B(this._workQueue,this.view.state.contentCamera.viewForward,this._index),O(this._workQueue,ge,this._index),this._updateQueues(),this._totalWork=this._computeWork(),this._updateLoading(),this._layerIsVisible=e.length>0||this._loadingInitNodePage,this.notifyChange("suspended")}cancelLoading(){this._cancelNodeLoading(),this._cancelIndexLoading()}_cancelNodeLoading(){const e=new Array;this._loadingNodes.forEach((({abortController:t})=>e.push(t))),this._loadingNodes.clear();for(const t of e)t.abort();this._workQueue=[],this._idleQueue.cancelAll(),this._totalWork=this._computeWork(),this._updateLoading()}_updateQueues(){const e=new Set;this._workQueue.forEach((t=>t.load.forEach((t=>e.add(t)))));const t=new Array,i=new Map;this._loadingNodes.forEach(((r,s)=>{e.has(s)?i.set(s,r):t.push(r)})),this._loadingNodes=i;for(const{abortController:r}of t)r.abort();this._workQueue=this._workQueue.filter((e=>{for(const t of e.load)if(this._loadingNodes.has(t))return this._recalcWork=!0,!1;return!0})),this._totalWork=this._computeWork(),this._updateLoading()}_cancelIndexLoading(){this._indexQueue=[],this._indexPagesLoading.forEach((({abortController:e})=>e.abort())),this._indexPagesLoading.clear(),this._totalWork=this._computeWork(),this._updateLoading()}_clearNodeState(){this._nodeLoadEpoch++,this._renderedNodes.forEach((e=>this._removeFromRenderer(e))),this._cancelNodeLoading()}_idleBegin(){this._setUpdateViewNeeded()}_idleEnd(){this._setUpdateViewNeeded()}get running(){return this.suspended?this._updateViewNeeded:this._updateViewNeeded||this._indexQueue.length>0||this._workQueue.length>0||this._idleQueue.running}runTask(e){if(this.suspended){if(this._updateViewNeeded){this._updateViewNeeded=!1;const e=this._isRootNodeVisible();e!==this._layerIsVisible&&(this._layerIsVisible=e,this.notifyChange("suspended")),this._updateLoading()}}else{for(e.run((()=>this._updateWorkQueues()));this._indexQueue.length>0&&e.run((()=>this._processIndexQueue())););this._processWorkQueue(e),this._idleQueue.runTask(e)}}_processIndexQueue(){const e=this._indexQueue.shift(),t=this._loadNodePage(e);return this._indexPagesLoading.set(e,t),t.promise.then((t=>{this._index.addPage(e,t,this._elevationOffset),this._setUpdateViewNeeded()})).then((()=>{this._indexPagesLoading.delete(e)}),(()=>{this._indexPagesLoading.delete(e)})),!0}_processWorkQueue(e){for(;!e.done;){const t=this._scheduleWorkEntry();if(null==t)return void e.madeProgress();this._processWorkEntry(t),e.madeProgress()}}_scheduleWorkEntry(){let e=this._workQueue.length;for(;e--;){const e=this._workQueue.shift();if(!e.remove.find((e=>!this._renderedNodes.has(e))))return e;this._workQueue.push(e)}return null}_processWorkEntry(e){if(0!==e.load.length)Promise.all(e.load.map((e=>{const t=new AbortController,i=this._memCache.pop(e.toString());return null!=i?this._loadingNodes.set(e,{abortController:t,promise:Promise.resolve(i)}):this._loadingNodes.has(e)||this._loadingNodes.set(e,{abortController:t,promise:this._loadNode(e,t.signal)}),this._loadingNodes.get(e).promise}))).then((t=>{for(let i=0;i<e.load.length;i++)if(t[i]){const r=this._setupRendererData(e.load[i],t[i]);this._addToRenderer(r)}for(const i of e.remove)this._removeFromRenderer(i)})).catch((()=>{})).then((()=>{for(const t of e.load)this._loadingNodes.delete(t);this._updateLoading(),this._recalcWork&&!this._idleQueue.running&&0===this._indexQueue.length&&0===this._loadingNodes.size&&(this._recalcWork=!1,this._setUpdateViewNeeded())})),this._updateLoading();else for(const t of e.remove)this._removeFromRenderer(t)}async _populateClassCodeCodedDomain(e,t){const r="CLASS_CODE",s=this.layer.fieldsIndex.get(r);if(!s||s.domain)return;if(!e.includes(s.name))return;const o=await i(this.layer.queryCachedStatistics(r,{signal:t}));if(!1===o.ok)return;const n=o.value?.stats?.labels?.labels;n&&Array.isArray(n)&&(s.domain=new j({name:"CLASS_CODE",codedValues:n.map((e=>new R({code:e.value,name:e.label})))}))}async prepareFetchPopupFeatures(e){return this._codedDomainPopulationPromise||(this._codedDomainPopulationAbortController=new AbortController,this._codedDomainPopulationPromise=this._populateClassCodeCodedDomain(e,this._codedDomainPopulationAbortController.signal).then((()=>{this._codedDomainPopulationAbortController=null}))),this._codedDomainPopulationPromise}async whenGraphicAttributes(e,i){const s=this._splitGraphicsPerNode(e),o=this.layer.attributeStorageInfo,n=i.map((e=>X(o,e))).filter(t),a=async(e,t)=>{const i=this._index.getNode(t);await r(n,(async t=>{const r=t.useElevation?await this._loadElevationAttributeFromGeometry(i.resourceId):await this._loadAndParseAttribute(i,t);if(r)for(const i of e)if(this._isValidPointGraphic(i)){const e=i.pointCloudMetadata.attributePointIndexInNode;this._encodeGraphicAttribute(t,r,e,i.attributes)}}))},d=[];return s.forEach(((e,t)=>{d.push(a(e,t))})),await Promise.allSettled(d),e}_isValidPointGraphic(e){return e instanceof te&&e.pointCloudMetadata?.epoch===this._nodeLoadEpoch}_splitGraphicsPerNode(e){const t=new Map;for(const i of e){if(!this._isValidPointGraphic(i))continue;const e=i.pointCloudMetadata,r=t.get(e.nodeId);r?r.push(i):t.set(e.nodeId,[i])}return t}async _loadAndParseAttribute(e,t){const i=await this._loadAttribute(e.resourceId,t,null);return null!=i?Y({attributeInfo:t,buffer:i},null,e.vertexCount):null}async _loadElevationAttributeFromGeometry(e){const t=this.layer.store.defaultGeometrySchema,i=Z(t,await this._loadGeometry(e,null));return ee(i,i.length/3)}highlight(e){if(!e)return o();const t=s.isCollection(e)?e.toArray():Array.isArray(e)?e:[e];return this._renderer.highlight(t.map((e=>this._graphicToPointDefinition(e))))}_graphicToPointDefinition(e){if(!this._isValidPointGraphic(e))return null;const{nodeId:t,pointIndexInNode:i}=e.pointCloudMetadata;return null!=t&&null!=i?{nodeId:t,pointId:i}:null}_computeWork(){let e=0;for(const t of this._workQueue)e+=t.load.length+t.remove.length;return e+=this._loadingNodes.size,e+=(this._indexQueue.length+this._indexPagesLoading.size)*this._index.pageSize,e+=this._loadingInitNodePage?100:0,e+=this._updateViewNeeded?100:0,e}get updatingProgressValue(){if(this.suspended)return this._updateViewNeeded?0:1;const e=this._computeWork();return 1-Math.min(this._totalWork,e)/this._totalWork}_updateLoading(){this.notifyChange("updating"),this.notifyChange("updatingProgressValue")}canResume(){return super.canResume()&&this._layerIsVisible}isUpdating(){return this.suspended?this._updateViewNeeded:this._computeWork()>0}_initNodePages(){const e=this.layer.store.index,t=e.nodesPerPage||e.nodePerIndexBlock;return this._index=new q(this.layer.spatialReference,this.view.renderCoordsHelper.spatialReference,t),this._cancelIndexLoading(),this._traverseVisible=this._index.createVisibilityTraverse(),this._loadingInitNodePage=!0,this._layerIsVisible=!0,this.notifyChange("suspended"),this._updateLoading(),this._pageMultiplier=null!=e.nodesPerPage?1:e.nodePerIndexBlock,this._loadNodePage(0).promise.then((e=>{this._index.addPage(0,e,this._elevationOffset),this._loadingInitNodePage=!1,this._setUpdateViewNeeded()}))}_loadNodePage(e){const t=new AbortController,i=`${this.baseUrl}/nodepages/${e*this._pageMultiplier}`;return{promise:this._requestNodePage(i,t.signal).then((t=>t.nodes.map(((t,i)=>({resourceId:null!=t.resourceId?t.resourceId:e*this._index.pageSize+i,obb:le.fromJSON(t.obb),obbInRenderSR:new le,firstChild:t.firstChild,childCount:t.childCount,vertexCount:t.vertexCount??t.pointCount,lodThreshold:t.lodThreshold??t.effectiveArea}))))),abortController:t}}_updateWorkQueues(){if(!this._updateViewNeeded)return!1;const e=this.view.quality;let t=this.inverseDensity/this._lodFactor*e;const i=this.maximumPointCount*this._lodFactor*e;let r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(s/(.75*i));for(;s>i;)t*=o,r=this._computeNodesForMinimumDensity(t),s=this._computePointCount(r),o=Math.sqrt(2);return this._displayNodes(r),this._updateViewNeeded=!1,this._updateLoading(),!0}_computePointCount(e){let t=0;for(let i=0;i<e.length;i++){const r=this._index.getNode(e[i]);r&&(t+=r.vertexCount)}return t}_isRootNodeVisible(){let e=!1;return this._traverseVisible({frustum:this.view.state.contentCamera.frustum,clippingBox:this._clippingBox},{predicate:(t,i,r)=>(e=r,!1),pageMiss:()=>{}}),e}_computeNodesForMinimumDensity(e){const t=this.view.state.contentCamera,i=t.frustum,r=this._clippingBox,s=t.viewForward,o=P(s,t.eye),n=k(s,-o,fe),a=t.perScreenPixelRatio/2,d=e*e,l=this._nodeIdArray;l.length=0;const{minScale:h,maxScale:u}=ce(this.layer),p=0===h&&0===u?e=>l.push(e):e=>{const t=this._getScale(e);_e(t,h,u)&&l.push(e)};return this._traverseVisible({frustum:i,clippingBox:r},{predicate:(e,t,i)=>{if(!i)return!1;if(0===t.childCount)return p(e),!1;const r=this._index.getRenderObb(e);return!(this._computeAveragePixelArea(r,t.lodThreshold,t.vertexCount,n,a)<=d)||(p(e),!1)},pageMiss:(e,t)=>{p(e),this._indexQueue.includes(t)||this._indexQueue.push(t)}}),l}_getScale(e){let t=this._nodeScales.get(e);if(null==t){const i=this._index.getNode(e).obb.center;this._tmpPoint.x=i[0],this._tmpPoint.y=i[1],this._tmpPoint.z=i[2],t=this.view.basemapTerrain.getScale(this._tmpPoint),this._nodeScales.set(e,t)}return t}_computeAveragePixelArea(e,t,i,r,s){const o=1e-7,n=Math.max(o,e.minimumDistancePlane(r));return t/(n*n)/(4*s*s)/i}_loadNode(e,t){try{return this._loadNodeAsync(e,t)}catch(i){throw l(i)||n.getLogger(this).error(i),i}}async _loadAdditionalUserAttributes(e,i,r){const s=this.layer.outFields;if(!s)return[];const o=D(this.layer.fieldsIndex,s),n=new Set(e.map((e=>null!=e?e.name:null))),a=this.layer.attributeStorageInfo,d=[];for(const t of o){if(n.has(t))continue;const e=X(a,t);e&&d.push(i(e))}const l=await h(d);return u(r),l.filter(t)}async _loadNodeAsync(e,t){const i=this._index.getNode(e),r=$(this.layer),s=J(this.layer),o=i.resourceId,n=async e=>{if(!e)return null;if(e.useElevation)return{attributeInfo:e,buffer:null};const i=await this._loadAttribute(o,e,t);return null!=i?{attributeInfo:e,buffer:i}:null};return this._idleQueue.push((async()=>{const i=this._loadGeometry(o,t),{primaryAttribute:a,modulationAttribute:d}=r,l=n(a),h=n(d),p=s.map((e=>e.attributeInfo)),c=p.map((e=>n(e))),_=this._loadAdditionalUserAttributes([a,d,...p],n,t),[m,g,f,y,b]=await Promise.all([i,l,h,Promise.all(c),_]);u(t);const w={geometryBuffer:m,primaryAttributeData:g,modulationAttributeData:f,filterAttributesData:y,userAttributesData:b,schema:this.layer.store.defaultGeometrySchema,rendererInfo:r,filterInfo:s,obbData:this._index.getRenderObb(e).data,elevationOffset:this._elevationOffset,inSR:this.layer.spatialReference.toJSON(),outSR:this.view.renderCoordsHelper.spatialReference.toJSON()};return this._worker.invoke(w,t)}),t)}async _loadGeometry(e,t){return this._requestData(`${this.baseUrl}/nodes/${e}/geometries/0`,t)}async _loadAttribute(e,t,i){if(!t?.storageInfo)return null;const r=t.storageInfo.key;return this._requestData(`${this.baseUrl}/nodes/${e}/attributes/${r}`,i)}_requestNodePage(e,t){const i={f:"json",...this.layer.customParameters,token:this.layer.apiKey};return this._indexRequester.request(e,"json",{query:i,signal:t})}_requestData(e,t){return this._dataRequester.request(e,"binary",{query:{...this.layer.customParameters,token:this.layer.apiKey},signal:t})}_removeFromRenderer(e){if(this._renderedNodes.has(e)){const t=this._renderer.removeNode(e);this._renderedNodes.delete(e),this._nodeScales.delete(e),this._memCache.put(t.id.toString(),t,we(t))}}_addToRenderer(e){this._renderedNodes.has(e.id)||(this._renderedNodes.add(e.id),this._renderer.addNode(e))}_setupRendererData(e,t){const i=this._index.getNode(e),r=Math.sqrt(i.lodThreshold/i.vertexCount),s=this._index.getRenderObb(e);if(re(t))return t.splatSize=r,t.obb=s,N(t.origin,t.obb.center),t;const o=le.fromData(t.obbData),a=o.halfSize,d=s.halfSize,l=.01*Math.max(d[0],d[1],d[2]);if(a[0]>d[0]+l||a[1]>d[1]+l||a[2]>d[2]+l){if(this._maxLoggedBoxWarnings>0){const t=e=>`[${e.halfSize[0]}, ${e.halfSize[1]}, ${e.halfSize[2]}]`;n.getLogger(this).warn(`Node ${e} reported bounding box too small. got ${t(s)} but points cover ${t(o)}`),0==--this._maxLoggedBoxWarnings&&n.getLogger(this).warn(" Too many bounding box errors, stopping reporting for this layer.")}this._index.setRenderObb(e,o)}return new se(e,r,x(s.center),s,0===i.childCount,t.points,t.rgb,t.attributes,t.pointIdFilterMap)}get usedMemory(){let e=0;return this._renderer.forEachNode((t=>{e+=Ne,e+=g(t.coordinates);for(const i of t.attributes){const t=i.values;f(t.buffer)&&(e+=g(t))}})),e}get unloadedMemory(){const e=this._renderedNodes.size;if(e<4)return 0;const t=[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount));let i=this._loadingNodes.size;for(let r=0;r<this._workQueue.length;r++)i+=this._workQueue[r].load.length,i-=this._workQueue[r].remove.length;if(i<0)return 0;return i*t/e*((this.usedMemory-e*Ne)/t)+i*Ne}get performanceInfo(){return new W(this.usedMemory,this._renderedNodes.size,[...this._renderedNodes].reduce(((e,t)=>e+this._index.getNode(t).vertexCount),0),this.maximumPointCount,new M(this._loadingNodes.size,this._indexQueue.length,this._workQueue.length,this._idleQueue.length))}get test(){return{index:this._index,visibleNodes:this._renderedNodes}}};e([b()],ye.prototype,"layer",void 0),e([b()],ye.prototype,"baseUrl",null),e([b()],ye.prototype,"pointScale",null),e([b()],ye.prototype,"useRealWorldSymbolSizes",null),e([b()],ye.prototype,"pointSize",null),e([b()],ye.prototype,"inverseDensity",null),e([b()],ye.prototype,"maximumPointCount",void 0),e([b({readOnly:!0})],ye.prototype,"availableFields",null),e([b({readOnly:!0})],ye.prototype,"_clippingBox",null),e([b({readOnly:!0})],ye.prototype,"_elevationOffset",null),e([b({type:Boolean})],ye.prototype,"slicePlaneEnabled",void 0),e([b()],ye.prototype,"updating",void 0),e([b(he)],ye.prototype,"updatingProgress",void 0),e([b({readOnly:!0})],ye.prototype,"updatingProgressValue",null),ye=e([w("esri.views.3d.layers.PointCloudLayerView3D")],ye);const be=ye;function we(e){return 5*e.coordinates.length+128}const Pe=I(),Ne=160;function xe(e){return t=>e.immediate.schedule(t)}export{be 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{isSome as t}from"../../../core/arrayUtils.js";import{isArrayBuffer as r}from"../../../core/typedArrayUtil.js";import{conjugate as e}from"../../../core/libs/gl-matrix-2/math/quat.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{
|
|
5
|
+
import{isSome as t}from"../../../core/arrayUtils.js";import{isArrayBuffer as r}from"../../../core/typedArrayUtil.js";import{conjugate as e}from"../../../core/libs/gl-matrix-2/math/quat.js";import{create as a}from"../../../core/libs/gl-matrix-2/factories/quatf64.js";import{u as o}from"../../../chunks/vec32.js";import{clone as i,create as f}from"../../../core/libs/gl-matrix-2/factories/vec3f32.js";import n from"../../../geometry/SpatialReference.js";import{projectBuffer as s}from"../../../geometry/projection/projectBuffer.js";import{readGeometry as u,getAttributeValues as l,evaluateRenderer as m,filterInPlace as b}from"./i3s/PointCloudWorkerUtil.js";import{Obb as p}from"../support/orientedBoundingBox.js";class c{transform(t){const e=this._transform(t),a=[e.points.buffer,e.rgb.buffer];null!=e.pointIdFilterMap&&a.push(e.pointIdFilterMap.buffer);for(const o of e.attributes)"buffer"in o.values&&r(o.values.buffer)&&o.values.buffer!==e.rgb.buffer&&a.push(o.values.buffer);return Promise.resolve({result:e,transferList:a})}_transform(r){const e=u(r.schema,r.geometryBuffer);let a=e.length/3,o=null;const i=new Array,f=l(r.primaryAttributeData,e,a);null!=r.primaryAttributeData&&f&&i.push({attributeInfo:r.primaryAttributeData.attributeInfo,values:f});const s=l(r.modulationAttributeData,e,a);null!=r.modulationAttributeData&&s&&i.push({attributeInfo:r.modulationAttributeData.attributeInfo,values:s});let c=m(r.rendererInfo,f,s,a);if(r.filterInfo&&r.filterInfo.length>0&&null!=r.filterAttributesData){const f=r.filterAttributesData.filter(t).map((t=>{const r=l(t,e,a),o={attributeInfo:t.attributeInfo,values:r};return i.push(o),o}));o=new Uint32Array(a),a=b(e,c,o,r.filterInfo,f)}for(const t of r.userAttributesData){const r=l(t,e,a);i.push({attributeInfo:t.attributeInfo,values:r})}3*a<c.length&&(c=new Uint8Array(c.buffer.slice(0,3*a))),this._applyElevationOffsetInPlace(e,a,r.elevationOffset);const h=this._transformCoordinates(e,a,p.fromData(r.obbData),n.fromJSON(r.inSR),n.fromJSON(r.outSR));return{obbData:r.obbData,points:h,rgb:c,attributes:i,pointIdFilterMap:o}}_transformCoordinates(t,r,a,n,u){if(!s(t,n,0,t,u,0,r))throw new Error("Can't reproject");const l=i(a.center),m=f(),b=f(),p=i(a.halfSize);e(h,a.quaternion);const c=new Float32Array(3*r);for(let e=0;e<r;e++){let r=3*e;m[0]=t[r]-l[0],m[1]=t[r+1]-l[1],m[2]=t[r+2]-l[2],o(b,m,h),p[0]=Math.max(p[0],Math.abs(b[0])),p[1]=Math.max(p[1],Math.abs(b[1])),p[2]=Math.max(p[2],Math.abs(b[2])),c[r++]=m[0],c[r++]=m[1],c[r]=m[2]}return a.halfSize=p,c}_applyElevationOffsetInPlace(t,r,e){if(0!==e)for(let a=0;a<r;a++)t[3*a+2]+=e}}const h=a();function I(){return new c}export{I as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.29/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as r,transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as s,multiply as n,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as f,g as p,h as d,j as g,n as x,f as _,b as T}from"../../../../chunks/vec32.js";import{ZEROS as b,ONES as y,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as j}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as w}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as R}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as M}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as P,expandWithBuffer as A,intersectsClippingArea as E}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as N}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as S}from"../../../../geometry/support/Indices.js";import U from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as D}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as L}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as $,b as V}from"../../../../chunks/vec3.js";import{project as G}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as H,projectNormalToPCPF as k,transformTangent as q,projectTangentToPCPF as W}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as z}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as Y}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as J}from"../../../ViewingMode.js";import{isEncodedMeshTexture as K}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as Q}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as X}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as ee}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as te}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as re}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as oe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ae,MeshFastUpdateProcessor as se}from"./MeshFastUpdateProcessor.js";import{createMaterial as ne}from"../support/edgeUtils.js";import{parseColorMixMode as ie,encodeSymbolColor as le}from"../support/symbolColorUtils.js";import{debugFlags as ce}from"../../support/debugFlags.js";import{Attribute as ue}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as me,CullFaceOptions as he}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as fe}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as pe}from"../../webgl-engine/lib/Geometry.js";import{Object3D as de}from"../../webgl-engine/lib/Object3D.js";import{Texture as ge}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as xe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as _e}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Te}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as be,defaultSchematicMRRFactors as ye,defaultAdvancedMRRFactors as ve}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ce}from"../../../webgl/enums.js";const je=["mesh"];class we extends oe{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ae,this._fastUpdateProcessor=new se,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ce.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Te({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new Te({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,je,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=e.fastTransformUpdatesEnabled;switch(o){case Y.EnableFastUpdates:if(a)return!0;break;case Y.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!1}const s=this._context.renderCoordsHelper.spatialReference,n=Se,{origin:i,transform:l}=r;if(!w(t,f(Oe,i.x,i.y,i.z??0),n,s))return!1;switch(o){case Y.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case Y.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case Y.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:m}=this._context,h=(e,t)=>ee(e,u,c,m,t);return e.alignedSampledElevation=X(e,c,u.spatialReference,h,m,n),e.updateTransform(n,l,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Fe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data??e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,me.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);if(!a){let s=null;const n=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,maxAnisotropy:n,mipmap:n>1};K(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==me.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new ge(s,i),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)}return a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Ce.CLAMP_TO_EDGE;case"mirror":return Ce.MIRRORED_REPEAT;default:return Ce.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=Q(t.colorTextureTransform),r.normalTextureTransformMatrix=Q(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:h;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=Q(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=Q(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=Q(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=C;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=C)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=be({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:b,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:he.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...ye]:[l.metallic,l.roughness,ve[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?he.None:he.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new _e(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?me.MaskBlend:me.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?me.Opaque:"mask"===t.alphaMode?me.Mask:me.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.attributes.get(xe.POSITION),o=e.attributes.get(xe.NORMAL),c=r.data,u=r.indices,m=o.data,f=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*f[t];for(let t=0;t<3;t++)s.push(c[e+t]);for(let t=0;t<3;t++)s.push(c[e+t]+m[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(c,u,t,Ee),this._getFaceVertices(c,u,t,Oe,Pe,Ae),p(Oe,Oe,Pe),p(Oe,Oe,Ae),d(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+Ee[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new pe(this._debugVertexNormalMaterial,[[xe.POSITION,new ue(s,n,3,!0)]],null,fe.Line);t.push(u),u.transformation=c;const m=new pe(this._debugFaceNormalMaterial,[[xe.POSITION,new ue(i,l,3,!0)]],null,fe.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;ce.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new de({geometries:n,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=ne(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new re(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new te(this,l,n,null,null,X,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>ee(e,h,r,f,t);return m.alignedSampledElevation=X(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=z(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return M([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Ee);for(let e=0;e<3;e++){const r=3*o[s+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],g(Ee,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Re(t,o,a)}_createComponentNormalsFlat(e,t){const r=N(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Ee);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new Re(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Ee);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:v(),count:0},r[a]=n),p(n.normal,n.normal,o),n.count++}}const o=N(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(x(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new Re(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,Pe,Ae),_(Pe,Pe,Oe),_(Ae,Ae,Oe),T(Oe,Pe,Ae),x(o,Oe),o}_getOrCreateComponents(e){return e.components??Be}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===De.RENDER?t.transformBeforeProject:null;if(o&&(r=$(new Float64Array(r.length),r,o)),t.reprojection===De.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return R(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===De.RENDER?r.transformBeforeProject:null;a&&(o=H(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===De.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return k(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===De.RENDER?r.transformBeforeProject:null;a&&(o=q(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===De.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return W(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ie(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return le(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),l=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:l,symbolColorBuffer:u,objectTransformation:n.reprojection===De.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===De.NONE&&n.geometryTransformation?n.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?L(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?De.NONE:De.RENDER:De.NONE;if(D(t)){const o=t.origin,a=c(),i=e.transform?.localMatrix??u;if(r===De.NONE){w(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:m(i),needsBufferCopy:!1}}const l=s(c(),o);return n(l,l,i),{reprojection:r,transformBeforeProject:l,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,l=e.anchor;Me[0]=l.x,Me[1]=l.y,Me[2]=l.z??0;const u=c();return w(e.spatialReference,Me,u,n),i(Ne,u),$(t,t,Ne),(a||s)&&(r(Ie,u),o(Ie,Ie),a&&V(a,a,Ie),s&&V(s,s,Ie,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??I(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=G({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===J.Local}),a=o.length/3;return P(Ue),A(Ue,o,0,a),!E(Ue,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!j(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:h}=o,f=this._getOrCreateComponents(e),p=new Array;let d=!1;const g=l(Oe,m),x=this._context.localOriginFactory.getOrigin(g);for(const l of f){if(!this._validateFaces(e,l))return null;const t=this._getOrCreateFaces(e,l);if(0===t.length)continue;const o=this._createComponentNormals(a,c,l,t);o.didFlipNormals&&(d=!0);const m=[[xe.POSITION,new ue(a,t,3,!0)],[xe.NORMAL,new ue(o.normals,o.indices,3,!0)]];n&&m.push([xe.COLOR,new ue(n,t,4,!0)]),i&&m.push([xe.SYMBOLCOLOR,new ue(i,S(t.length),4,!0)]),s&&m.push([xe.UV0,new ue(s,t,2,!0)]),u&&m.push([xe.TANGENT,new ue(u,t,4,!0)]);const f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new pe(g,m,null,fe.Mesh,f);_.transformation=h,_.localOrigin=x,p.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:p,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Re{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Me=v(),Oe=v(),Pe=v(),Ae=v(),Ee=v(),Ne=c(),Ie=a(),Se=c(),Ue=O(),Be=[new U],Fe=new F;var De;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(De||(De={}));export{we as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{deg2rad as t}from"../../../../core/mathUtils.js";import{fromMat4 as r,transpose as o}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as s,multiply as n,invert as i,getTranslation as l}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as c,IDENTITY as u,clone as m}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as h}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{s as f,g as p,h as d,k as g,n as x,f as _,b as T}from"../../../../chunks/vec32.js";import{ZEROS as b,ONES as y,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as C}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{canProjectWithoutEngine as w}from"../../../../geometry/projection.js";import{computeTranslationToOriginAndRotation as j}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as R}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToPoint as M}from"../../../../geometry/projection/projectVectorToPoint.js";import{create as O,empty as P,expandWithBuffer as A,intersectsClippingArea as E}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as N}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as I,getZeroIndexArray as S}from"../../../../geometry/support/Indices.js";import U from"../../../../geometry/support/MeshComponent.js";import B from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import F from"../../../../geometry/support/MeshTextureTransform.js";import{isRelativeVertexSpace as D}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as L}from"../../../../geometry/support/spatialReferenceUtils.js";import{a as V,b as $}from"../../../../chunks/vec3.js";import{project as G}from"../../../../geometry/support/meshUtils/georeference.js";import{transformNormal as H,projectNormalToPCPF as k,transformTangent as q,projectTangentToPCPF as W}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as z}from"../../../../layers/graphics/dehydratedPoint.js";import{MeshTransformUpdateAction as Y}from"../../../../layers/graphics/sources/interfaces.js";import{ViewingMode as J}from"../../../ViewingMode.js";import{isEncodedMeshTexture as K}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as Q}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as X}from"./ElevationAligners.js";import{needsElevationUpdates3D as Z,evaluateElevationInfoAtPoint as ee}from"./elevationAlignmentUtils.js";import{Graphics3DMeshObject3DGraphicLayer as te}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as re}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as oe}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as ae,MeshFastUpdateProcessor as se}from"./MeshFastUpdateProcessor.js";import{createMaterial as ne}from"../support/edgeUtils.js";import{parseColorMixMode as ie,encodeSymbolColor as le}from"../support/symbolColorUtils.js";import{debugFlags as ce}from"../../support/debugFlags.js";import{Attribute as ue}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as me,CullFaceOptions as he}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as fe}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as pe}from"../../webgl-engine/lib/Geometry.js";import{Object3D as de}from"../../webgl-engine/lib/Object3D.js";import{Texture as ge}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as xe}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as _e}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as Te}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as be,defaultSchematicMRRFactors as ye,defaultAdvancedMRRFactors as ve}from"../../webgl-engine/materials/pbrUtils.js";import{TextureWrapMode as Ce}from"../../../webgl/enums.js";const we=["mesh"];class je extends oe{constructor(e,t,r,o){super(e,t,r,o),this._materialInfoCache=new ae,this._fastUpdateProcessor=new se,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){ce.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new Te({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new Te({color:[0,1,1,1]}))}destroy(){super.destroy(),this._textures.forEach((e=>e.unload())),this._context.stage.removeMany(this._materialInfoCache.materials),this._context.stage.removeMany(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy(this._context.stage)}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,we,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache,this._context)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._updateMaterialParameters((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>t(e)?.layerOpacityChanged(r,this._context.isAsync)))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,Z)}slicePlaneEnabledChanged(e,t){return this._updateMaterialParameters((({material:e})=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync))),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._updateMaterialParameters((({material:t})=>t.setParameters({usePBR:e}))),!0}updateTransform(e,t,r,o){const a=e.fastTransformUpdatesEnabled;switch(o){case Y.EnableFastUpdates:if(a)return!0;break;case Y.DisableFastUpdates:if(!a)return!0;break;default:if(!a)return!1}const s=this._context.renderCoordsHelper.spatialReference,n=Se,{origin:i,transform:l}=r;if(!j(t,f(Oe,i.x,i.y,i.z??0),n,s))return!1;switch(o){case Y.EnableFastUpdates:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case Y.DisableFastUpdates:this._fastUpdateProcessor.disable(e,this._materialInfoCache,this._context);break;case Y.UpdateFastLocalOrigin:e.updateFastLocalOrigin(n,l,this._context.localOriginFactory)}const{elevationContext:c}=e;c.centerPointInElevationSR=this._getCenterPointInElevationSR(n);const{elevationProvider:u,renderCoordsHelper:m}=this._context,h=(e,t)=>ee(e,u,c,m,t);return e.alignedSampledElevation=X(e,c,u.spatialReference,h,m,n),e.updateTransform(n,l,this._context.isAsync),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,a=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:a,uid:`vc:${o},vt:${a},vct${t},svc:${r}`}}_textureTransformUid(e){const{offset:t,scale:r,rotation:o}=e??Fe;return`${t[0]},${t[1]},${o},${r[0]},${r[1]}`}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:a,colorTexture:s,colorTextureTransform:n,normalTexture:i,normalTextureTransform:l,doubleSided:c,alphaCutoff:u,alphaMode:m}=t.material,h=this._colorOrTextureUid(a),f=this._colorOrTextureUid(s),p=this._textureTransformUid(n),d=this._colorOrTextureUid(i),g=this._textureTransformUid(l);if(o.color=a,o.colorTexture=s,o.normalTexture=i,o.uid=`${o.uid},cmuid:${h},ctmuid:${f},cttuid:${p},ntmuid:${d},nttuid:${g},ds:${c},ac:${u},am:${m}`,t.material instanceof B){const{metallic:e,roughness:r,metallicRoughnessTexture:a,metallicRoughnessTextureTransform:s,emissiveColor:i,emissiveTexture:c,emissiveTextureTransform:u,occlusionTexture:m,occlusionTextureTransform:h}=t.material,f=this._colorOrTextureUid(a),p=this._textureTransformUid(s),d=this._colorOrTextureUid(i),g=this._colorOrTextureUid(c),x=this._textureTransformUid(u),_=this._colorOrTextureUid(m),T=this._textureTransformUid(h);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=a,o.emissiveColor=i,o.emissiveTexture=c,o.occlusionTexture=m,o.colorTextureTransform=this._convertTextureTransform(n),o.normalTextureTransform=this._convertTextureTransform(l),o.emissiveTextureTransform=this._convertTextureTransform(u),o.occlusionTextureTransform=this._convertTextureTransform(h),o.metallicRoughnessTextureTransform=this._convertTextureTransform(s),o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${f},mrtt:${p},emuid:${d},etmuid:${g},ett:${x},otmuid:${_},ott:${T}`}return o}_convertTextureTransform(e){if(!e)return null;const{scale:r,offset:o,rotation:a}=e;return{scale:r,offset:o,rotation:t(a)}}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data??e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,me.Opaque);return t?.id}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let a=this._textures.get(o);if(!a){let s=null;const n=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,i={wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,maxAnisotropy:n,mipmap:n>1};K(r)?(s=r.data,i.preMultiplyAlpha=!1,i.encoding=r.encoding):(s=r,i.preMultiplyAlpha=t!==me.Opaque,i.downsampleUncompressed=this._context.graphicsCoreOwner.view.qualitySettings.graphics3D.uncompressedTextureDownsamplingEnabled),a=new ge(s,i),this._textures.set(o,a),a.load(this._context.stage.renderView.renderingContext),this._context.stage.add(a)}return a}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return Ce.CLAMP_TO_EDGE;case"mirror":return Ce.MIRRORED_REPEAT;default:return Ce.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.parameters.preMultiplyAlpha):r.textureId=void 0}t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=Q(t.colorTextureTransform),r.normalTextureTransformMatrix=Q(t.normalTextureTransform);const o=null!=t.normalTextureTransform?.scale?t.normalTextureTransform?.scale:h;r.scale=[o[0],o[1]],r.occlusionTextureTransformMatrix=Q(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=Q(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=Q(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=this.symbolLayer.material?.colorMixMode??null;if(r)t.externalColor=C;else{const r=this.symbolLayer.material?.color??null;r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=C)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(t,r){const o=r.material?.color,a=r.material?.colorTexture,s=r.material?.alphaMode,n="blend"===s,i=!("opaque"===s)&&(this._hasTransparentVertexColors(t)||null!=o&&o.a<1||a?.transparent||n),l=this._materialProperties(t,r,i),c=this._materialInfoCache.byUid(l.uid);if(c)return c.material;const u={uid:l.uid,material:null,isComponentTransparent:i,alphaMode:r.material?r.material.alphaMode:"opaque"},m=be({normalTexture:l.normalTexture,metallicRoughnessTexture:l.metallicRoughnessTexture,metallicFactor:l.metallic,roughnessFactor:l.roughness,emissiveTexture:l.emissiveTexture,emissiveFactor:e.toUnitRGB(l.emissiveColor),occlusionTexture:l.occlusionTexture}),h={usePBR:this._usePBR(),isSchematic:m,hasVertexColors:l.hasVertexColors,hasSymbolColors:l.hasSymbolVertexColors,hasVertexTangents:l.hasVertexTangents,ambient:b,diffuse:y,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:he.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};h.mrrFactors=m?[...ye]:[l.metallic,l.roughness,ve[2]],r.material&&(h.doubleSided=r.material.doubleSided,h.cullFace=r.material.doubleSided?he.None:he.Back,h.textureAlphaCutoff=r.material.alphaCutoff),this._setExternalMaterialParameters(h),this._setMaterialTransparentParameter(h,u),this._setInternalMaterialParameters(l,h);const f=new _e(h);return u.material=f,this._materialInfoCache.set(l.uid,u),this._context.stage.add(f),f}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?me.MaskBlend:me.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?me.Opaque:"mask"===t.alphaMode?me.Mask:me.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,a=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),s=[],n=[],i=[],l=[];for(let h=0;h<r;h++){const e=t[h],r=e.attributes.get(xe.POSITION),o=e.attributes.get(xe.NORMAL),c=r.data,u=r.indices,m=o.data,f=o.indices;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*f[t];for(let t=0;t<3;t++)s.push(c[e+t]);for(let t=0;t<3;t++)s.push(c[e+t]+m[r+t]*a);if(n.push(n.length),n.push(n.length),t%3==0){this._calculateFaceNormal(c,u,t,Ee),this._getFaceVertices(c,u,t,Oe,Pe,Ae),p(Oe,Oe,Pe),p(Oe,Oe,Ae),d(Oe,Oe,1/3);for(let e=0;e<3;e++)i.push(Oe[e]);for(let e=0;e<3;e++)i.push(Oe[e]+Ee[e]*a);l.push(l.length),l.push(l.length)}}}const c=t[0].transformation,u=new pe(this._debugVertexNormalMaterial,[[xe.POSITION,new ue(s,n,3,!0)]],null,fe.Line);t.push(u),u.transformation=c;const m=new pe(this._debugFaceNormalMaterial,[[xe.POSITION,new ue(i,l,3,!0)]],null,fe.Line);m.transformation=c,t.push(m)}_createAs3DShape(e,t,r,o){const a=e.geometry;if("mesh"!==a.type)return null;const s=this._createGeometryInfo(a,t,o);if(null==s)return null;const{geometries:n,objectTransformation:i}=s;ce.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(a,n);const l=new de({geometries:n,layerUid:this._context.layer.uid,graphicUid:o,isElevationSource:!0});l.transformation=i;const c=ne(this.symbolLayer,{opacity:this._getLayerOpacity()}),u=c?new re(n[0].material,[c],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new te(this,l,n,null,null,X,r,u);this._fastUpdateProcessor.onAddGraphic(),m.needsElevationUpdates=Z(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l.transformation);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>ee(e,h,r,f,t);return m.alignedSampledElevation=X(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=z(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return M([e[12],e[13],e[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let a=!1;if(!r.trustSourceNormals)for(let s=0;s<o.length;s+=3){this._calculateFaceNormal(e,o,s,Ee);for(let e=0;e<3;e++){const r=3*o[s+e];Oe[0]=t[r],Oe[1]=t[r+1],Oe[2]=t[r+2],g(Ee,Oe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],a=!0)}}return new Re(t,o,a)}_createComponentNormalsFlat(e,t){const r=N(t.length),o=new Array(3*t.length);for(let a=0;a<t.length;a+=3){const s=this._calculateFaceNormal(e,t,a,Ee);for(let e=0;e<3;e++)r[a+e]=s[e],o[a+e]=a/3}return new Re(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let s=0;s<t.length;s+=3){const o=this._calculateFaceNormal(e,t,s,Ee);for(let e=0;e<3;e++){const a=t[s+e];let n=r[a];n||(n={normal:v(),count:0},r[a]=n),p(n.normal,n.normal,o),n.count++}}const o=N(3*t.length),a=new Array(3*t.length);for(let s=0;s<t.length;s++){const e=r[t[s]];1!==e.count&&(x(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*s+t]=e.normal[t];a[s]=s}return new Re(o,a,!1)}_getFaceVertices(e,t,r,o,a,s){const n=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[n],o[1]=e[n+1],o[2]=e[n+2],a[0]=e[i],a[1]=e[i+1],a[2]=e[i+2],s[0]=e[l],s[1]=e[l+1],s[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,Oe,Pe,Ae),_(Pe,Pe,Oe),_(Ae,Ae,Oe),T(Oe,Pe,Ae),x(o,Oe),o}_getOrCreateComponents(e){return e.components??Be}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===De.RENDER?t.transformBeforeProject:null;if(o&&(r=V(new Float64Array(r.length),r,o)),t.reprojection===De.NONE)return t.needsBufferCopy?new Float64Array(r):r;const a=o?r:new Float64Array(r.length);return R(r,e.spatialReference,0,a,this._context.renderCoordsHelper.spatialReference,0,r.length/3),a}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const a=r.reprojection===De.RENDER?r.transformBeforeProject:null;a&&(o=H(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===De.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return k(o,s,t,e.spatialReference,n)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const a=r.reprojection===De.RENDER?r.transformBeforeProject:null;a&&(o=q(o,new Float32Array(o.length),a));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===De.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const s=e.vertexAttributes.position,n=a?o:new Float32Array(o.length);return W(o,s,t,e.spatialReference,n)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=ie(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return le(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,a=e.vertexAttributes.uv,s=e.vertexAttributes.tangent;if(o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(s&&s.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(a&&a.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const n=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,n),l=this._createColorBuffer(e),u=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,n),h=this._createTangentBuffer(e,i,n);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:a,colorBuffer:l,symbolColorBuffer:u,objectTransformation:n.reprojection===De.NONE&&n.objectTransformation?n.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:n.reprojection===De.NONE&&n.geometryTransformation?n.geometryTransformation:c()}}_computeReprojectionInfo(e){const{vertexSpace:t}=e,r="georeferenced"===t.type?L(this._context.renderCoordsHelper.spatialReference,e.spatialReference)?De.NONE:De.RENDER:De.NONE;if(D(t)){const o=t.origin,a=c(),i=e.transform?.localMatrix??u;if(r===De.NONE){j(e.spatialReference,o,a,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:a,geometryTransformation:m(i),needsBufferCopy:!1}}const l=s(c(),o);return n(l,l,i),{reprojection:r,transformBeforeProject:l,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,t,a,s){const n=this._context.renderCoordsHelper.spatialReference,l=e.anchor;Me[0]=l.x,Me[1]=l.y,Me[2]=l.z??0;const u=c();return j(e.spatialReference,Me,u,n),i(Ne,u),V(t,t,Ne),(a||s)&&(r(Ie,u),o(Ie,Ie),a&&$(a,a,Ie),s&&$(s,s,Ie,4)),u}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??I(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes?.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference,o=G({positions:t,transform:e.transform,vertexSpace:e.vertexSpace,inSpatialReference:e.spatialReference,outSpatialReference:r??e.spatialReference,localMode:this._context.stage.viewingMode===J.Local}),a=o.length/3;return P(Ue),A(Ue,o,0,a),!E(Ue,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!w(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(!this._validateVertexSpace(e))return null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:a,uvBuffer:s,colorBuffer:n,symbolColorBuffer:i,normalBuffer:c,tangentBuffer:u,objectTransformation:m,geometryTransformation:h}=o,f=this._getOrCreateComponents(e),p=new Array;let d=!1;const g=l(Oe,m),x=this._context.localOriginFactory.getOrigin(g);for(const l of f){if(!this._validateFaces(e,l))return null;const t=this._getOrCreateFaces(e,l);if(0===t.length)continue;const o=this._createComponentNormals(a,c,l,t);o.didFlipNormals&&(d=!0);const m=[[xe.POSITION,new ue(a,t,3,!0)],[xe.NORMAL,new ue(o.normals,o.indices,3,!0)]];n&&m.push([xe.COLOR,new ue(n,t,4,!0)]),i&&m.push([xe.SYMBOLCOLOR,new ue(i,S(t.length),4,!0)]),s&&m.push([xe.UV0,new ue(s,t,2,!0)]),u&&m.push([xe.TANGENT,new ue(u,t,4,!0)]);const f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),g=this._getOrCreateMaterial(e,l),_=new pe(g,m,null,fe.Mesh,f);_.transformation=h,_.localOrigin=x,p.push(_)}return d&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:p,objectTransformation:m}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial(((e,t)=>{t.setParameters(e.parameters)}))}_validateVertexSpace(e){const{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:r}=e;return t!==J.Local||"local"!==r.type||(this.logger.warn("Displaying a mesh with a local vertex space in a view in local viewing mode is not supported."),!1)}test(){return{...super.test(),materials:this._materialInfoCache.materials}}}class Re{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const Me=v(),Oe=v(),Pe=v(),Ae=v(),Ee=v(),Ne=c(),Ie=a(),Se=c(),Ue=O(),Be=[new U],Fe=new F;var De;!function(e){e[e.NONE=0]="NONE",e[e.RENDER=1]="RENDER"}(De||(De={}));export{je as Graphics3DMeshFillSymbolLayer};
|
|
@@ -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 e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{identity as i,scale as a,translate as o,copy as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l as c,E as h,c as d,A as m,g as p,s as u}from"../../../../chunks/vec32.js";import{fromArray as y,ONES as f,ZEROS as _,fromValues as g,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as P,create as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as v}from"../../../../geometry/projection/projectPointToVector.js";import{create as L,size as C,containsPoint as S,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as E}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as U,defaultSymbolLayerMemoryComplexity as O}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as I,evaluateElevationInfoAtPoint as A,SampleElevationInfo as G}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as D}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as z,mixinColorAndOpacity as V,computeObjectScale as M,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{LoadStatus as W}from"./Loadable.js";import{makeLodResources as q}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as J,extendPointGraphicElevationContext as Y}from"./pointUtils.js";import{isValidPrimitive as $,primitiveLodResources as K}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as Q}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as X}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as Z,updateFastSymbolUpdatesState as ee,ConvertOptions as te,evaluateModelTransform as se,evaluateModelTransformScale as re}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ie}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ae}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as oe}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ne,texturesFromLodResources as le,geometriesFromLodResources as ce}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";import{defaultSchematicMRRFactors as de}from"../../webgl-engine/materials/pbrUtils.js";class me{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class pe extends F{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(z(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&$(t.primitive)?t.primitive:E;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await X(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!this.symbolLayer.resource?.href}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}_setMaterialTransparencyParameters(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?ie.None:ie.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(w(t)),o=y(C(a)),n=y(T(o,i)),l=c(n),h=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:[...de],ambient:f,diffuse:f,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParameters(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;m.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;m.externalColor=s}this._fastUpdates=Z(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const _=new he(m),g=K(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ne(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(g,p,r),x=await this._createLodRenderer(g,r);return new me(g,x,R,b,o,h,d,a,n,l,p,null)}async _createResourcesForUrl(e,t){const r={materialParameters:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=Z(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;r.signal=t,r.usePBR=a,r.skipHighLods=this._context.skipHighSymbolLods;const o=await N(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=q(o.lods),d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,f=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),_=this.needsDrivenTransparentPass,g=ne(h),b=ne(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(p);const s=t.opacity*f,r=s<1||_||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=y(C(P)),x=y(h.levels[0].pivotOffset),v=y(T(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;ee(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const j=await this._createStageResources(h,a,t),E=await this._createLodRenderer(h,t);return new me(h,E,j,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=ne(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=le(e);i.addMany(o),this._addDisposeResource((()=>{o.forEach((e=>e.unload())),i.removeMany(o)})),await Promise.all(o.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=ce(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),n(s,se(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),re(e,i.materialParameters,_e)}}:null,o=new oe({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t?.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=J(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?ie.None:ie.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return k.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return k.RecreateSymbol;if(!ee(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return k.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return k.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=U(e.levels),s=e=>Array.from(e.attributes.values()).reduce(((e,t)=>e+r(t.data,t.indices)),0),i=ce(e).reduce(((e,t)=>e+s(t)),0),a=le(e).reduce(((e,t)=>e+t.memoryEstimate),0)+i,o={...O(this.symbol,this.symbolLayer),resourceBytes:a};return new Q({verticesPerFeature:t,memory:o})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(v(t,ue,this._context.elevationProvider.spatialReference),null!=n&&!S(n,ue))return null;const l=this._requiresTerrainElevation(r),c=this._computeGlobalTransform(t,r,fe,ge),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ye),d=this._resources.lodRenderer.instanceData,m=d.addInstance();this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),o&&d.setFeatureAttribute(m,o),null==this._fastUpdates&&this._hasPerInstanceColor()&&d.setColor(m,V(s.color,s.opacity,255)),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&d.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const p=new D(this,m,B,r);return l&&(p.alignedSampledElevation=ge.sampledElevation),p.needsElevationUpdates=I(r.mode),Y(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return A(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,x(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=M(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=t&&J(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,fe,ge),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=ge.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,fe,!0),Y(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===W.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ye),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParameters({},i)):t=this._setMaterialTransparencyParameters({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return H(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=M(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new te({size:!0,color:!0,rotation:!0,opacity:!1},i,t??f,o,a,n,l)}}const ue=b(),ye=l(),fe=l(),_e=R(),ge=new G;export{pe as Graphics3DObjectSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{identity as i,scale as a,translate as o,copy as n}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{l as c,F as h,c as d,B as m,g as p,s as u}from"../../../../chunks/vec32.js";import{fromArray as y,ONES as f,ZEROS as _,fromValues as g,create as b}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as P,create as R}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as v}from"../../../../geometry/projection/projectPointToVector.js";import{create as L,size as C,containsPoint as S,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as E}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as w,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{estimateNumVerticesForLods as U,defaultSymbolLayerMemoryComplexity as O}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as B}from"./ElevationAligners.js";import{needsElevationUpdates3D as I,evaluateElevationInfoAtPoint as A,SampleElevationInfo as G}from"./elevationAlignmentUtils.js";import{Graphics3DLodInstanceGraphicLayer as D}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as F}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as z,mixinColorAndOpacity as V,computeObjectScale as M,computeObjectRotation as H}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{LoadStatus as W}from"./Loadable.js";import{makeLodResources as q}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as J,extendPointGraphicElevationContext as Y}from"./pointUtils.js";import{isValidPrimitive as $,primitiveLodResources as K}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as Q}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as X}from"./webStyleUtils.js";import{initFastSymbolUpdatesState as Z,updateFastSymbolUpdatesState as ee,ConvertOptions as te,evaluateModelTransform as se,evaluateModelTransformScale as re}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as ie}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ae}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as oe}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ne,texturesFromLodResources as le,geometriesFromLodResources as ce}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";import{defaultSchematicMRRFactors as de}from"../../webgl-engine/materials/pbrUtils.js";class me{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class pe extends F{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(z(this.symbolLayer))throw new Error}if(this._isPrimitive){const t=this.symbolLayer.resource,s=t&&$(t.primitive)?t.primitive:E;this._resources=await this._createResourcesForPrimitive(s,e)}else{const t=await X(this.symbol.styleOrigin),s=t?.href??this.symbolLayer.resource.href;this._resources=await this._createResourcesForUrl(s,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!this.symbolLayer.resource?.href}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}_setMaterialTransparencyParameters(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?ie.None:ie.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(w(t)),o=y(C(a)),n=y(T(o,i)),l=c(n),h=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,mrrFactors:[...de],ambient:f,diffuse:f,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParameters(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;m.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;m.externalColor=s}this._fastUpdates=Z(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const _=new he(m),g=K(t,_);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ne(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),R=await this._createStageResources(g,p,r),x=await this._createLodRenderer(g,r);return new me(g,x,R,b,o,h,d,a,n,l,p,null)}async _createResourcesForUrl(e,t){const r={materialParameters:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=Z(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParameters,this._fastUpdates.materialParameters),this._optionalFields.push(ae.FEATUREATTRIBUTE)):this._hasPerInstanceColor()&&(r.materialParameters.hasInstancedColor=!0,this._optionalFields.push(ae.COLOR)),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push(ae.OBJECTANDLAYERIDCOLOR);const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParameters.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParameters.castShadows=!1}const a=this._context.physicalBasedRenderingEnabled;r.signal=t,r.usePBR=a,r.skipHighLods=this._context.skipHighSymbolLods;const o=await N(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=q(o.lods),d=this._context,m=this.symbolLayer.material,p=this._getExternalColorParameters(m),u=this.symbolLayer?.material?.color,f=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),_=this.needsDrivenTransparentPass,g=ne(h),b=ne(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(p);const s=t.opacity*f,r=s<1||_||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,R=y(C(P)),x=y(h.levels[0].pivotOffset),v=y(T(R,this.symbolLayer)),L=c(v),S=this._fastUpdates;ee(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,R,x))&&g.forEach((e=>e.setParameters(S.materialParameters)));const j=await this._createStageResources(h,a,t),E=await this._createLodRenderer(h,t);return new me(h,E,j,b,R,n,l,P,v,L,a,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=ne(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=le(e);i.addMany(o),this._addDisposeResource((()=>{o.forEach((e=>e.unload())),i.removeMany(o)})),await Promise.all(o.map((e=>this._context.stage.schedule((()=>e.load(i.renderView.renderingContext)),r)))),t(r);const n=ce(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),n(s,se(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),re(e,i.materialParameters,_e)}}:null,o=new oe({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t?.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=J(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?ie.None:ie.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return k.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return k.RecreateSymbol;if(!ee(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return k.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return k.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=U(e.levels),s=e=>Array.from(e.attributes.values()).reduce(((e,t)=>e+r(t.data,t.indices)),0),i=ce(e).reduce(((e,t)=>e+s(t)),0),a=le(e).reduce(((e,t)=>e+t.memoryEstimate),0)+i,o={...O(this.symbol,this.symbolLayer),resourceBytes:a};return new Q({verticesPerFeature:t,memory:o})}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=this._context.clippingExtent;if(v(t,ue,this._context.elevationProvider.spatialReference),null!=n&&!S(n,ue))return null;const l=this._requiresTerrainElevation(r),c=this._computeGlobalTransform(t,r,fe,ge),h=this._computeLocalTransform(this._resources,this.symbolLayer,s,ye),d=this._resources.lodRenderer.instanceData,m=d.addInstance();this._instanceIndexToGraphicUid.set(m,i),d.setLocalTransform(m,h,!1),d.setGlobalTransform(m,c),o&&d.setFeatureAttribute(m,o),null==this._fastUpdates&&this._hasPerInstanceColor()&&d.setColor(m,V(s.color,s.opacity,255)),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&d.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const p=new D(this,m,B,r);return l&&(p.alignedSampledElevation=ge.sampledElevation),p.needsElevationUpdates=I(r.mode),Y(p,t,this._context.elevationProvider),p}_computeGlobalTransform(e,t,s,r){return A(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),ue[0]=e.x,ue[1]=e.y,ue[2]=r.z,x(e.spatialReference,ue,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=M(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=t&&J(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,fe,ge),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=ge.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,fe,!0),Y(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===W.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=y(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ye),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParameters({},i)):t=this._setMaterialTransparencyParameters({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return H(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):_;m(r,i,o),p(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,_)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):_,o=this._context.renderCoordsHelper.unitInMeters,n=M(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new te({size:!0,color:!0,rotation:!0,opacity:!1},i,t??f,o,a,n,l)}}const ue=b(),ye=l(),fe=l(),_e=R(),ge=new G;export{pe as Graphics3DObjectSymbolLayer};
|
|
@@ -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{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{normalFromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as n,f as l,
|
|
5
|
+
import{adjustStaticAGOUrl as e}from"../../../../core/devEnvironmentUtils.js";import{normalFromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as r}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as o}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as s}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as i}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{e as n,f as l,H as a,l as u,n as c,m}from"../../../../chunks/vec32.js";import{create as f}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{empty as d,expandWithVec3 as p}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as g}from"../../../../geometry/support/FloatArray.js";import{BufferViewVec4f as x,BufferViewVec4u8 as b,BufferViewVec4u16 as h,BufferViewVec3f as T,BufferViewVec3u8 as w,BufferViewVec3u16 as y}from"../../../../geometry/support/buffer/BufferView.js";import{a as v,b as R,s as j}from"../../../../chunks/vec3.js";import{t as M,s as B}from"../../../../chunks/vec4.js";import{n as S}from"../../../../chunks/vec2.js";import{c as F}from"../../../../chunks/vec33.js";import{c as A}from"../../../../chunks/vec43.js";import{DefaultLoadingContext as L}from"../../glTF/DefaultLoadingContext.js";import{loadGLTF as E}from"../../glTF/loader.js";import{convertPrimitiveToTriangles as O}from"../../glTF/internal/indexUtils.js";import{isEncodedMeshTexture as I}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as C}from"../../glTF/internal/TextureTransformUtils.js";import{ProcessedObjectResource as k}from"./ProcessedObjectResource.js";import{load as N,processLoadResult as P}from"./wosrLoader.js";import{NormalType as U}from"../../webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js";import{Attribute as V}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as _,DepthTestFunction as D,CullFaceOptions as H}from"../../webgl-engine/lib/basicInterfaces.js";import{Geometry as q}from"../../webgl-engine/lib/Geometry.js";import{Texture as G}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as W}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{colorGamma as z}from"../../webgl-engine/materials/DefaultMaterial_COLOR_GAMMA.js";import{defaultEsriSymbologyMRRFactors as K,defaultAdvancedMRRFactors as Q,useSchematicPBR as J,defaultSchematicMRRFactors as X}from"../../webgl-engine/materials/pbrUtils.js";async function Y(t,r){const o=Z(e(t));if("wosr"===o.fileType){const e=await(r.cache?r.cache.loadWOSR(o.url,r):N(o.url,r)),{engineResources:t,referenceBoundingBox:s}=P(e,r);return{lods:t,referenceBoundingBox:s,isEsriSymbolResource:!1,isWosr:!0}}const s=await(r.cache?r.cache.loadGLTF(o.url,r,!!r.usePBR):E(new L(r.streamDataRequester),o.url,r,r.usePBR)),i=s.model.meta?.ESRI_proxyEllipsoid,n=s.meta.isEsriSymbolResource&&null!=i&&"EsriRealisticTreesStyle"===s.meta.ESRI_webstyle;n&&!s.customMeta.esriTreeRendering&&(s.customMeta.esriTreeRendering=!0,ie(s,i));const l=!!r.usePBR,a=s.meta.isEsriSymbolResource?{usePBR:l,isSchematic:!1,treeRendering:n,mrrFactors:[...K]}:{usePBR:l,isSchematic:!1,treeRendering:!1,mrrFactors:[...Q]},u={...r.materialParameters,treeRendering:n},{engineResources:c,referenceBoundingBox:m}=ee(s,a,u,r.skipHighLods&&null==o.specifiedLodIndex?{skipHighLods:!0}:{skipHighLods:!1,singleLodIndex:o.specifiedLodIndex});return{lods:c,referenceBoundingBox:m,isEsriSymbolResource:s.meta.isEsriSymbolResource,isWosr:!1}}function Z(e){const t=e.match(/(.*\.(gltf|glb))(\?lod=([0-9]+))?$/);if(t)return{fileType:"gltf",url:t[1],specifiedLodIndex:null!=t[4]?Number(t[4]):null};return e.match(/(.*\.(json|json\.gz))$/)?{fileType:"wosr",url:e,specifiedLodIndex:null}:{fileType:"unknown",url:e,specifiedLodIndex:null}}function ee(e,t,r,o){const s=e.model,i=new Array,n=new Map,l=new Map,a=s.lods.length,u=d();return s.lods.forEach(((e,c)=>{const m=!0===o.skipHighLods&&(a>1&&0===c||a>3&&1===c)||!1===o.skipHighLods&&null!=o.singleLodIndex&&c!==o.singleLodIndex;if(m&&0!==c)return;const f=new k(e.name,e.lodThreshold,[0,0,0]);e.parts.forEach((e=>{const o=m?new $({}):te(s,e,f,t,r,n,l),{geometry:i,vertexCount:a}=re(e,null!=o?o:new $({})),d=i.boundingInfo;null!=d&&0===c&&(p(u,d.bbMin),p(u,d.bbMax)),null!=o&&(f.stageResources.geometries.push(i),f.numberOfVertices+=a)})),m||i.push(f)})),{engineResources:i,referenceBoundingBox:u}}function te(e,t,r,o,s,n,l){const a=t.material+(t.attributes.normal?"_normal":"")+(t.attributes.color?"_color":"")+(t.attributes.texCoord0?"_texCoord0":"")+(t.attributes.tangent?"_tangent":""),u=e.materials.get(t.material),c=null!=t.attributes.texCoord0,m=null!=t.attributes.normal;if(null==u)return null;const f=se(u.alphaMode);if(!n.has(a)){if(c){const t=(t,r=!1)=>{if(null!=t&&!l.has(t)){const o=e.textures.get(t);if(null!=o){const e=o.data;l.set(t,new G(I(e)?e.data:e,{...o.parameters,preMultiplyAlpha:!I(e)&&r,encoding:I(e)&&null!=e.encoding?e.encoding:void 0}))}}};t(u.textureColor,f!==_.Opaque),t(u.textureNormal),t(u.textureOcclusion),t(u.textureEmissive),t(u.textureMetallicRoughness)}const r=u.color[0]**(1/z),d=u.color[1]**(1/z),p=u.color[2]**(1/z),g=u.emissiveFactor[0]**(1/z),x=u.emissiveFactor[1]**(1/z),b=u.emissiveFactor[2]**(1/z),h=null!=u.textureColor&&c?l.get(u.textureColor):null,T=J({normalTexture:u.textureNormal,metallicRoughnessTexture:u.textureMetallicRoughness,metallicFactor:u.metallicFactor,roughnessFactor:u.roughnessFactor,emissiveTexture:u.textureEmissive,emissiveFactor:u.emissiveFactor,occlusionTexture:u.textureOcclusion}),w=null!=u.normalTextureTransform?.scale?u.normalTextureTransform?.scale:i;n.set(a,new $({...o,transparent:f===_.Blend,customDepthTest:D.Lequal,textureAlphaMode:f,textureAlphaCutoff:u.alphaCutoff,diffuse:[r,d,p],ambient:[r,d,p],opacity:u.opacity,doubleSided:u.doubleSided,doubleSidedType:"winding-order",cullFace:u.doubleSided?H.None:H.Back,hasVertexColors:!!t.attributes.color,hasVertexTangents:!!t.attributes.tangent,normalType:m?U.Attribute:U.ScreenDerivative,castShadows:!0,receiveShadows:u.receiveShadows,receiveAmbientOcclusion:u.receiveAmbientOcclustion,textureId:null!=h?h.id:void 0,colorMixMode:u.colorMixMode,normalTextureId:null!=u.textureNormal&&c?l.get(u.textureNormal).id:void 0,textureAlphaPremultiplied:null!=h&&!!h.parameters.preMultiplyAlpha,occlusionTextureId:null!=u.textureOcclusion&&c?l.get(u.textureOcclusion).id:void 0,emissiveTextureId:null!=u.textureEmissive&&c?l.get(u.textureEmissive).id:void 0,metallicRoughnessTextureId:null!=u.textureMetallicRoughness&&c?l.get(u.textureMetallicRoughness).id:void 0,emissiveFactor:[g,x,b],mrrFactors:T?[...X]:[u.metallicFactor,u.roughnessFactor,o.mrrFactors[2]],isSchematic:T,colorTextureTransformMatrix:C(u.colorTextureTransform),normalTextureTransformMatrix:C(u.normalTextureTransform),scale:[w[0],w[1]],occlusionTextureTransformMatrix:C(u.occlusionTextureTransform),emissiveTextureTransformMatrix:C(u.emissiveTextureTransform),metallicRoughnessTextureTransformMatrix:C(u.metallicRoughnessTextureTransform),...s}))}const d=n.get(a);if(r.stageResources.materials.push(d),c){const e=e=>{null!=e&&r.stageResources.textures.push(l.get(e))};e(u.textureColor),e(u.textureNormal),e(u.textureOcclusion),e(u.textureEmissive),e(u.textureMetallicRoughness)}return d}function re(e,r){const o=e.attributes.position.count,s=O(e.indices||o,e.primitiveType),i=g(3*o),{typedBuffer:n,typedBufferStride:l}=e.attributes.position;v(i,n,e.transform,3,l);const a=[[W.POSITION,new V(i,s,3,!0)]];if(null!=e.attributes.normal){const r=g(3*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.normal;t(oe,e.transform),R(r,i,oe,3,n),a.push([W.NORMAL,new V(r,s,3,!0)])}if(null!=e.attributes.tangent){const r=g(4*o),{typedBuffer:i,typedBufferStride:n}=e.attributes.tangent;t(oe,e.transform),M(r,i,oe,4,n),a.push([W.TANGENT,new V(r,s,4,!0)])}if(null!=e.attributes.texCoord0){const t=g(2*o),{typedBuffer:r,typedBufferStride:i}=e.attributes.texCoord0;S(t,r,2,i),a.push([W.UV0,new V(t,s,2,!0)])}if(null!=e.attributes.color){const t=new Uint8Array(4*o);4===e.attributes.color.elementCount?e.attributes.color instanceof x?B(t,e.attributes.color,255):e.attributes.color instanceof b?A(t,e.attributes.color):e.attributes.color instanceof h&&B(t,e.attributes.color,1/256):(t.fill(255),e.attributes.color instanceof T?j(t,e.attributes.color,255,4):e.attributes.color instanceof w?F(t,e.attributes.color.typedBuffer,4,e.attributes.color.typedBufferStride):e.attributes.color instanceof y&&j(t,e.attributes.color,1/256,4)),a.push([W.COLOR,new V(t,s,4,!0)])}return{geometry:new q(r,a),vertexCount:o}}const oe=r();function se(e){switch(e){case"BLEND":return _.Blend;case"MASK":return _.Mask;case"OPAQUE":case null:case void 0:return _.Opaque}}function ie(e,t){for(let r=0;r<e.model.lods.length;++r){const i=e.model.lods[r];for(const d of i.parts){const i=d.attributes.normal;if(null==i)return;const p=d.attributes.position,g=p.count,x=f(),h=f(),w=f(),y=new Uint8Array(4*g),v=new Float64Array(3*g),R=o(s(),d.transform);let j=0,M=0;for(let o=0;o<g;o++){p.getVec(o,h),i.getVec(o,x),n(h,h,d.transform),l(w,h,t.center),a(w,w,t.radius);const s=w[2],f=u(w),g=Math.min(.45+.55*f*f,1);a(w,w,t.radius),null!==R&&n(w,w,R),c(w,w),r+1!==e.model.lods.length&&e.model.lods.length>1&&m(w,w,x,s>-1?.2:Math.min(-4*s-3.8,1)),v[j]=w[0],v[j+1]=w[1],v[j+2]=w[2],j+=3,y[M]=255*g,y[M+1]=255*g,y[M+2]=255*g,y[M+3]=255,M+=4}d.attributes.normal=new T(v),d.attributes.color=new b(y)}}}export{Y as fetch,ee as gltfToEngineResources,Z as parseUrl};
|
|
@@ -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 e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MinPriority as o}from"../../../../core/MemCache.js";import{throwIfAborted as r}from"../../../../core/promiseUtils.js";import{generateUUID as n}from"../../../../core/uuid.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{i}from"../../../../chunks/vec32.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{isRelativeVertexSpace as u}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{b as m}from"../../../../chunks/sphere.js";import{convertMeshMaterialToPBRMaterial as c}from"./I3SClientMaterialUtil.js";class h{constructor(e,t,o,r){this._uid=e,this._worker=r,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._localMode=t.localMode,this._memCache=o.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o=`mesh${t}`,r=e.extent,n=r.spatialReference,s=this._indexSR,a=f(r,e.origin);d(a,n,a,s);return{type:"mesh",id:o,version:g(e),oid:t,mbs:a,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(t,o){if(null!=this.getMeshNodeIndex(o.oid))throw new e(`I3SClientNodeLoader: client side mesh for feature oid=${o.oid} already exists`);o.nodeIndex=t,this._id2Meta.set(o.id,o),this._oid2Meta.set(o.oid,o)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){const o=this._id2Meta.get(t);if(null==o)throw new e(`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new e(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const r=[],n=o.components;for(let s=0;s<n.length;++s){const o=`${t}-component${s}`,n={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(n.id,n),e.componentNodeIds.push(o),r.push({id:n.id,href:null,mbs:n.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:r}}updateNodeIndex(e,t,o){const r=this._id2Meta.get(e);r&&"mesh"===r.type&&(r.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(o,n){const s=this._id2Meta.get(o);if(null==s||"mesh-component"!==s.type)throw new e(`Failed to load client node data for node ${o} (unexpected node info)`);const a=s.meshNodeInfo,i=await this._getMeshData(a),l=i.loadedMesh,d=a.oid;if(null==l.components)throw new e(`Failed to load client node data for node ${o} (unexpected null reference)`);const u=l.components[s.componentIndex],{material:m,requiredTextures:h,textureData:f}=await c(u.material);if(null!=f)for(const e of f)null!=e&&s.textureData.set(e.id,e);const y={params:{material:m},type:"ArrayBufferView"},{vertexSpace:g,origin:M,transform:S}=l,_=[M.x,M.y,M.z??0],b={featureDataPosition:_,featureIds:[],geometries:[y]},w={attributeData:{},loadedAttributes:[]};i.projectionPromise||(t(this._worker,"SceneLayerWorker is needed to project mesh"),i.projectionPromise=this._worker.project({positions:l.vertexAttributes.position,localMatrix:S?.localMatrix,vertexSpace:g.toJSON(),origin:_,inSpatialReference:l.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON(),localMode:this._localMode},n));const{projected:N,original:v}=await i.projectionPromise;l.vertexAttributes.position=v;const{transformed:D,original:
|
|
5
|
+
import e from"../../../../core/Error.js";import{assertIsSome as t}from"../../../../core/maybe.js";import{MinPriority as o}from"../../../../core/MemCache.js";import{throwIfAborted as r}from"../../../../core/promiseUtils.js";import{generateUUID as n}from"../../../../core/uuid.js";import{normalFromMat4 as s}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{j as i}from"../../../../chunks/vec32.js";import{ONES as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{projectBoundingSphere as d}from"../../../../geometry/projection/projectBoundingSphere.js";import{isRelativeVertexSpace as u}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{b as m}from"../../../../chunks/sphere.js";import{convertMeshMaterialToPBRMaterial as c}from"./I3SClientMaterialUtil.js";class h{constructor(e,t,o,r){this._uid=e,this._worker=r,this._id2Meta=new Map,this._oid2Meta=new Map,this._indexSR=t.indexSR,this._vertexSR=t.vertexSR,this._renderSR=t.renderSR,this._localMode=t.localMode,this._memCache=o.newCache(`sl-client-mesh-data-${this._uid}`)}get uid(){return this._uid}get worker(){return this._worker}get indexSR(){return this._indexSR}get renderSR(){return this._renderSR}createMeshNodeInfo(e,t){const o=`mesh${t}`,r=e.extent,n=r.spatialReference,s=this._indexSR,a=f(r,e.origin);d(a,n,a,s);return{type:"mesh",id:o,version:g(e),oid:t,mbs:a,componentNodeIds:[],unloadedMesh:e,nodeIndex:null,loadMeshPromise:null}}addMeshNode(t,o){if(null!=this.getMeshNodeIndex(o.oid))throw new e(`I3SClientNodeLoader: client side mesh for feature oid=${o.oid} already exists`);o.nodeIndex=t,this._id2Meta.set(o.id,o),this._oid2Meta.set(o.oid,o)}getMeshNodeIndex(e){const t=this._oid2Meta.get(e);return null==t||"mesh"!==t.type?null:t.nodeIndex}removeNode(e){const t=this._id2Meta.get(e);null!=t&&(this._id2Meta.delete(e),"mesh"===t.type&&this._oid2Meta.delete(t.oid))}async loadNodeJSON(t){const o=this._id2Meta.get(t);if(null==o)throw new e(`I3SClientNodeLoader::loadNodeJSON unable to find node ${t}`);switch(o.type){case"mesh":return this._loadMeshNodeJSON(o);case"mesh-component":return this._loadMeshComponentNodeJSON(o);default:throw new e(`I3SClientNodeLoader::loadNodeJSON unable to handle node ${t}`)}}async _loadMeshNodeJSON(e){const t=e.id,o=(await this._getMeshData(e)).loadedMesh;if(null==o.components||0===o.components.length)return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null};const r=[],n=o.components;for(let s=0;s<n.length;++s){const o=`${t}-component${s}`,n={type:"mesh-component",id:o,mbs:e.mbs,componentIndex:s,meshNodeInfo:e,textureData:new Map};this._id2Meta.set(n.id,n),e.componentNodeIds.push(o),r.push({id:n.id,href:null,mbs:n.mbs,obb:null})}return{id:t,version:null,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:r}}updateNodeIndex(e,t,o){const r=this._id2Meta.get(e);r&&"mesh"===r.type&&(r.nodeIndex=o)}async _loadMeshComponentNodeJSON(e){return{id:e.id,version:e.meshNodeInfo.version,mbs:e.mbs,obb:null,sharedResource:null,geometryData:null,attributeData:null,featureData:null,children:null,isEmpty:!1}}async loadNodeData(o,n){const s=this._id2Meta.get(o);if(null==s||"mesh-component"!==s.type)throw new e(`Failed to load client node data for node ${o} (unexpected node info)`);const a=s.meshNodeInfo,i=await this._getMeshData(a),l=i.loadedMesh,d=a.oid;if(null==l.components)throw new e(`Failed to load client node data for node ${o} (unexpected null reference)`);const u=l.components[s.componentIndex],{material:m,requiredTextures:h,textureData:f}=await c(u.material);if(null!=f)for(const e of f)null!=e&&s.textureData.set(e.id,e);const y={params:{material:m},type:"ArrayBufferView"},{vertexSpace:g,origin:M,transform:S}=l,_=[M.x,M.y,M.z??0],b={featureDataPosition:_,featureIds:[],geometries:[y]},w={attributeData:{},loadedAttributes:[]};i.projectionPromise||(t(this._worker,"SceneLayerWorker is needed to project mesh"),i.projectionPromise=this._worker.project({positions:l.vertexAttributes.position,localMatrix:S?.localMatrix,vertexSpace:g.toJSON(),origin:_,inSpatialReference:l.spatialReference.toJSON(),outSpatialReference:this._vertexSR.toJSON(),localMode:this._localMode},n));const{projected:N,original:v}=await i.projectionPromise;l.vertexAttributes.position=v;const{transformed:D,original:j}=await p(u,i,this._worker,n);l.vertexAttributes.normal=j,r(n);const{geometryBuffer:I,geometryDescriptor:R}=x(N,u.faces,D,l.vertexAttributes.uv,l.vertexAttributes.color,d);return{geometryData:b,attributeDataInfo:w,geometryBuffer:I,geometryDescriptor:R,requiredTextures:h,textureData:f,normalReferenceFrame:this._vertexSR.isGeographic?"east-north-up":"vertex-reference-frame"}}async loadAttributes(e,t,o){const r=e.numFeatures,n={};for(const{field:{name:s}}of t)n[s]=new Array(r);return n}async loadTextures(e,t,o){const r=e.id,n=this._id2Meta.get(r);if(null==n||"mesh-component"!==n.type)throw new Error(`Failed to load textures for node ${e.id} (unexpected node info)`);const s=[];for(const a of t)s.push(n.textureData.get(a.id)||null);return s}async _getMeshData(e){const t=e.version,r=this._memCache.get(t);if(null==r){if(null!=e.loadMeshPromise)return e.loadMeshPromise;const r=async(r,n)=>{const s=e.unloadedMesh.clone();try{await s.load()}catch(l){n(l)}const a=s.memoryUsage,i={loadedMesh:s,projectionPromise:null,normalsTransformPromise:null,usedMemoryInBytes:a};this._memCache.put(t,i,a,o),e.loadMeshPromise=null,r(i)};return e.loadMeshPromise=new Promise(((e,t)=>r(e,t))),e.loadMeshPromise}return r}}function f(e,t){const{spatialReference:o}=e,r=[1,-1],n=[.5*e.width,.5*e.height,e.hasZ?.5*(e.zmax-e.zmin):0],s=o.isGeographic?o.metersPerUnit:1,a=e.center;let i=0;if(e.hasZ)for(let l=0;l<2;++l)for(let e=0;e<2;++e)for(let o=0;o<2;++o){const d=(a.x+r[l]*n[0]-t.x)*s,u=(a.y+r[e]*n[1]-t.y)*s,m=a.z+r[o]*n[2]-t.z;i=Math.max(d*d+u*u+m*m,i)}else for(let l=0;l<2;++l)for(let e=0;e<2;++e){const o=(a.x+r[l]*n[0]-t.x)*s,d=(a.y+r[e]*n[1]-t.y)*s;i=Math.max(o*o+d*d,i)}return m([t.x,t.y,t.z],Math.sqrt(i))}async function p(e,o,r,n){const{transform:d,vertexAttributes:u}=o.loadedMesh,m="source"===e.shading?u.normal:null;if(!(null!=m&&null!=d&&(0!==d.rotationAngle||!i(d.scale,l))))return{transformed:m,original:u.normal};if(!o.normalsTransformPromise){t(r,"SceneLayerWorker is needed to transform mesh normals");const e=a();s(e,d.localMatrix),o.normalsTransformPromise=r.transformNormals({normalMatrix:e,normals:m},n)}return o.normalsTransformPromise}function x(e,t,o,r,n,s){const a=1,i=t.length/3,l=3*i;let d=0,u=0,m=!1,c=0,h=!1,f=0,p=!1,x=0,g=0,w=0;d+=M,d+=M,u=d,d+=3*l*S,null!=o&&(m=!0,c=d,d+=3*l*S),null!=r&&(h=!0,f=d,d+=2*l*S),null!=n&&(p=!0,x=d,d+=4*l*_),g=d,d+=a*b,w=d,d+=2*a*M;const N=new ArrayBuffer(d),v=new Uint8Array(N);y(v,0,l),y(v,M,a);const D=new Float32Array(N,u),j=null!=o?new Float32Array(N,c):null,I=null!=r?new Float32Array(N,f):null,R=null!=n?new Uint8Array(N,x):null;for(let y=0;y<i;++y){const s=3*y;for(let a=0;a<3;++a){const i=t[s+a],l=3*i,d=9*y+3*a;if(D[d]=e[l],D[d+1]=e[l+1],D[d+2]=e[l+2],null!=j&&(j[d]=o[l],j[d+1]=o[l+1],j[d+2]=o[l+2]),null!=I){const e=2*i,t=6*y+2*a;I[t]=r[e],I[t+1]=r[e+1]}if(null!=R){const e=4*i,t=12*y+4*a;R[t]=n[e],R[t+1]=n[e+1],R[t+2]=n[e+2],R[t+3]=n[e+3]}}}y(v,g,s),y(v,g+M,s/2**32),y(v,w,0),y(v,w+M,i-1);return{geometryBuffer:N,geometryDescriptor:{isDraco:!1,isLegacy:!0,color:p,normal:m,uv0:h,uvRegion:!1,featureIndex:!0}}}function y(e,t,o){e[t]=255&o,e[t+1]=255&o>>8,e[t+2]=255&o>>16,e[t+3]=255&o>>24}function g(e){const t=e.metadata.displaySource?.source;if(null==t||!Array.isArray(t)||!t.length||t[0]instanceof File)return n();const o=t;let r="";for(const n of o)r+=n.makeHash();return r+JSON.stringify(null!=e.transform?e.transform.toJSON():"")+(u(e.vertexSpace)?JSON.stringify(e.vertexSpace.origin):"")}const M=4,S=4,_=1,b=8;export{h as I3SClientNodeLoader,f as createSphereFromExtent,S as sizeOfFloat32,M as sizeOfInt32,b as sizeOfUInt64,_ as sizeOfUInt8,p as transformNormals};
|
|
@@ -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"../../../../request.js";import i from"../../../../core/Accessor.js";import{splitIntoChunks as r}from"../../../../core/arrayUtils.js";import{resultOrAbort as s,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import{makeHandle as c}from"../../../../core/handleUtils.js";import h from"../../../../core/Logger.js";import{destroyMaybe as l,abortMaybe as u}from"../../../../core/maybe.js";import{whenOrAbort as m,createResolver as g}from"../../../../core/promiseUtils.js";import p from"../../../../core/ReactiveSet.js";import{watch as y,initial as f}from"../../../../core/reactiveUtils.js";import{property as b}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as O}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as v}from"../../../../intl/number.js";import{getMaximumQuerySize as j,queryAllJSON as C}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as w,extractMesh as I}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as F,i3sPatchingEnabled as A,sceneLayerEditingEnabled as L}from"../../../../support/featureFlags.js";import{isTimeoutError as x}from"../../../../support/requestUtils.js";import{ViewingMode as E}from"../../../ViewingMode.js";import S from"../FeatureLayerView3D.js";const D="esri.views.3d.layers.i3s.I3SOverrides";let G=class extends i{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=$,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new p,this._geometryChangedObjectIds=new p,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._featureIdLocks=new Map}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(F()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(y((()=>this._definitionExpression),(t=>e.definitionExpression=t),f)),this._associatedLayerView=new S({layer:this._associatedLayer,view:this.view}))})):A())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(F()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):A()),this._set("layer",null),this._memCache=l(this._memCache),this._pendingFetchAbortController=u(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return L()&&null!=this._associatedLayer?.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(this._pendingFetchChangedObjectIds)return!0;if(F()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=this._interactiveEditingSessions,i=new M(e,(()=>{t.remove(i)}));return t.unshift(i),i}async applyAttributeOverrides(e,t,i,r=[]){if(this._pendingFetchChangedObjectIds&&await m(this._pendingFetchChangedObjectIds,i),null==t)return;const{attributeData:s,loadedAttributes:o}=t;if(null==o||null==s||0===this._attributeChangedObjectIds.size)return;const n=new Set;for(const d of o)n.add(d.index);for(const d of r)n.has(d.index)||(o.push(d),s[d.name]=new Array(e.length));const a=await this._lockFeatureIds(e);try{const t={attributeData:s,loadedAttributes:o},r=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds),{objectIds:n,fieldNames:a}=r;if(0===n.length||0===a.length)return;const d=await this._queryAttributeOverridesFromAssociatedLayer(n,a,i);if(null==d)return;this._processOverridesFromAssociatedLayer(e,d,a,t)}finally{a.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const i=this._clientGeometryCache.get(e);if(null!=i&&(this.geometryOverrides.remove(i),this._clientGeometryCache.delete(e)),null!=t){const i={oid:e,mesh:t};this.geometryOverrides.add(i),this._clientGeometryCache.set(e,i)}}updateAttributeValue(e,t,i){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,i)}featureAdded(e){this.is3DOFL&&A()&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,i){this._memCache.put(this._getAttributeCacheKey(e,t),i,this._memCacheAttributeValueSize(i))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:i},r){const s=new Set,o=new Array;for(const a of t)o[a.index]=i[a.name];const n=new Set;for(let a=0;a<e.length;a++){const i=e[a];if(r.has(i))for(const e of t){const t=this._attributeFromCache(i,e.index);void 0===t?(s.add(i),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(s),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const i=this._fromInteractiveEditingSession(e,t);if(void 0!==i)return i;const r=this._getAttributeCacheKey(e,t);return this._memCache.get(r)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const i of this._interactiveEditingSessions){if(i.objectId!==e)continue;const r=i.getAttribute(t);if(void 0!==r)return r}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryAttributeOverridesFromAssociatedLayer(e,t,i){if(0===e.length)return null;this._logWarningIfMaximumObjectsExceeded();const{associatedLayer:r}=this.layer;if(null==r)return null;const s=r.createQuery(),{objectIdField:o}=r,n=[o,...t];s.where="1=1",s.returnGeometry=!1,s.outFields=n,s.cacheHint=!0;const a=await this._executeBatchQuery(r,e,s,i),d=[];for(const c of a)if(c.ok)for(const e of c.value.features)d.push(e);return d}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(0===e.length||!this.is3DOFL||!A())return null;const i=this.layer.associatedLayer,r=i.infoFor3D,{spatialReference:s}=i,{state:{viewingMode:o},spatialReference:n}=this.view,a=o===E.Global,d=s.isGeographic;if(a&&!d)return h.getLogger(D).warn("unsupported-pcs-edits-in-global-view",this.layer.title,N(s,n,this.view.viewingMode,k.Mode)),null;if(!a){if(d)return h.getLogger(D).warn("unsupported-gcs-edits-in-local-view",this.layer.title,N(s,n,this.view.viewingMode,k.Mode)),null;if(!O(n,s))return h.getLogger(D).warn("unsupported-mismatched-spatial-reference-edits-in-local-view",this.layer.title,N(s,n,this.view.viewingMode,k.SpatialReference)),null}this._logWarningIfMaximumObjectsExceeded();const{objectIdField:c,globalIdField:l}=i,u=[c,...null!=l?[l]:[]],m=i.createQuery();m.where="1=1",m.returnGeometry=!0,m.outFields=u,m.cacheHint=!0,m.returnZ=i.hasZ,m.returnM=i.hasM;const g=await this._executeBatchQuery(i,e,m,t),p=[];for(const h of g){if(!h.ok)continue;const e=h.value,{assetMaps:t,features:i,globalIdFieldName:o}=e;if(null==t)continue;const n=w(r,t);for(const a of i){const e=I(a,o,s,r,n),t=a;null!=e?(t.geometry=e,p.push(t)):t.geometry=null}}return p}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${v(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,h.getLogger(D).warn("#queryOverrides()",this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,i,o){if(0===t.length)return[];const n=j(e);t=[...t].sort(((e,t)=>e-t));const a=r(t,n).map((t=>{const r=i.clone();return r.objectIds=t,s(C(e,r,{signal:o}))}));return Promise.all(a)}_processOverridesFromAssociatedLayer(e,t,i,{loadedAttributes:r,attributeData:s}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=i.map((t=>(t in s||(s[t]=new Array(e.length)),s[t]))),d=new Map(r.map((e=>[e.name,e.index]))),c=i.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<i.length;t++){const r=c[t],s=h.get(e),o=l.attributes[i[t]];a[t][s]=o,this._cacheAttributeValue(e,r,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}async _fetchChangedObjectIds(e){const i=this.layer;await i.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:r}=i;if(null==r||!r.capabilities?.operations?.supportsChangeTracking)return;const s=this._getFetchChangedObjectIdsServerGen();if(null==s)return;const n=r.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:s}])};if(a){const e=r.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${r.url}/extractChanges`,{method:"post",query:d,timeout:V,signal:e}));if(!c.ok&&x(c.error)){const e=this.layer.title;h.getLogger(D).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],i=t?.objectIds,s=t?.fieldUpdates,o=i?.adds??[],n=i?.updates??[],d=i?.deletes??[],h=[...o,...n,...d],l=a?[...o,...s??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,h.length);u<h.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=h.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&A()&&this._geometryChangedObjectIds.size>0){const t=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[r.objectIdField],e.geometry)}}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp?.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t?.serverGens?.minServerGen?t.serverGens.minServerGen:null}async _lockFeatureIds(e){const t=this._featureIdLocks;let i=!0;for(;i;){const r=new Array;for(const i of e){const e=t.get(i);e&&r.push(e)}0===r.length?i=!1:await Promise.all(r)}const r=g(),s=r.promise;for(const o of e)t.set(o,s);return c((()=>{for(const i of e)t.delete(i);r.resolve()}))}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,i=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return i._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){i._maximumNumberOfEditOVerrides=e}}}};e([b({constructOnly:!0})],G.prototype,"view",void 0),e([b({constructOnly:!0})],G.prototype,"layer",void 0),e([b({readOnly:!0})],G.prototype,"is3DOFL",null),e([b()],G.prototype,"_interactiveEditingSessions",void 0),e([b({readOnly:!0})],G.prototype,"sortedGeometryChangedObjectIds",null),e([b({readOnly:!0})],G.prototype,"geometryOverrides",void 0),e([b()],G.prototype,"_clientGeometryCache",void 0),e([b()],G.prototype,"_associatedLayer",null),e([b()],G.prototype,"_associatedLayerView",void 0),e([b({constructOnly:!0})],G.prototype,"memoryController",void 0),e([b()],G.prototype,"_attributeChangedObjectIds",void 0),e([b()],G.prototype,"_geometryChangedObjectIds",void 0),e([b()],G.prototype,"hasGeometryChanges",null),e([b()],G.prototype,"_pendingFetchChangedObjectIds",void 0),e([b()],G.prototype,"_pendingFetchAbortController",void 0),e([b()],G.prototype,"_definitionExpression",null),e([b()],G.prototype,"updating",null),e([b()],G.prototype,"isEmpty",null),G=e([_(D)],G);class M{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}const V=1e4,$=5e4;var k;function N(e,t,i,r){return`Displaying the edits of a SceneLayer with a${r===k.Mode?e.isGeographic?" geographic ":" projected ":" "}spatial reference (wkid:${e.wkid}) in ${i} viewing mode${r===k.SpatialReference?` with spatial reference (wkid:${t.wkid}) `:" "}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${r===k.Mode?"viewing mode":"view spatial reference"} to display edits.`}!function(e){e[e.Mode=0]="Mode",e[e.SpatialReference=1]="SpatialReference"}(k||(k={}));export{G as I3SOverrides};
|
|
5
|
+
import{_ as e}from"../../../../chunks/tslib.es6.js";import t from"../../../../request.js";import i from"../../../../core/Accessor.js";import{splitIntoChunks as r}from"../../../../core/arrayUtils.js";import{resultOrAbort as s,result as o}from"../../../../core/asyncUtils.js";import{estimateStringByteSize as n,estimateNumberByteSize as a}from"../../../../core/byteSizeEstimations.js";import d from"../../../../core/Collection.js";import{makeHandle as c}from"../../../../core/handleUtils.js";import h from"../../../../core/Logger.js";import{destroyMaybe as l,abortMaybe as u}from"../../../../core/maybe.js";import{whenOrAbort as m,createResolver as g}from"../../../../core/promiseUtils.js";import p from"../../../../core/ReactiveSet.js";import{watch as y,initial as f}from"../../../../core/reactiveUtils.js";import{property as b}from"../../../../core/accessorSupport/decorators/property.js";import"../../../../core/has.js";import{subclass as _}from"../../../../core/accessorSupport/decorators/subclass.js";import{equals as O}from"../../../../geometry/support/spatialReferenceUtils.js";import{formatNumber as v}from"../../../../intl/number.js";import{getMaximumQuerySize as j,queryAllJSON as C}from"../../../../layers/support/featureQueryAll.js";import{assetMapFromAssetMapsJSON as w,extractMesh as I}from"../../../../rest/support/meshFeatureSet.js";import{direct3DObjectFeatureLayerDisplayEnabled as F,i3sPatchingEnabled as A,sceneLayerEditingEnabled as L}from"../../../../support/featureFlags.js";import{isTimeoutError as x}from"../../../../support/requestUtils.js";import{ViewingMode as E}from"../../../ViewingMode.js";import S from"../FeatureLayerView3D.js";const G="esri.views.3d.layers.i3s.I3SOverrides";let D=class extends i{constructor(e){super(e),this._warnMaximumChangedObjectsExceeded=!1,this._maximumNumberOfEditOVerrides=$,this._original3DOFLDefinitionExpression=null,this._interactiveEditingSessions=new d,this.geometryOverrides=new d,this._clientGeometryCache=new Map,this._associatedLayerView=null,this._attributeChangedObjectIds=new p,this._geometryChangedObjectIds=new p,this._pendingFetchChangedObjectIds=null,this._pendingFetchAbortController=new AbortController,this._featureIdLocks=new Map}initialize(){this._memCache=this.memoryController.newCache(`i3s-attribute-overrides-${this.layer.uid}`),this._pendingFetchChangedObjectIds=this._fetchChangedObjectIds(this._pendingFetchAbortController?.signal),this._pendingFetchChangedObjectIds.finally((()=>{this._pendingFetchAbortController=null,this._pendingFetchChangedObjectIds=null})),this.is3DOFL&&null!=this._associatedLayer&&(F()?this._associatedLayer.load().then((e=>{this.destroyed||(this._original3DOFLDefinitionExpression=e.definitionExpression,this.addHandles(y((()=>this._definitionExpression),(t=>e.definitionExpression=t),f)),this._associatedLayerView=new S({layer:this._associatedLayer,view:this.view}))})):A())}destroy(){this.is3DOFL&&null!=this._associatedLayer&&(F()?null!=this._associatedLayerView&&(this._associatedLayer.definitionExpression=this._original3DOFLDefinitionExpression):A()),this._set("layer",null),this._memCache=l(this._memCache),this._pendingFetchAbortController=u(this._pendingFetchAbortController),this._pendingFetchChangedObjectIds=null,this._featureIdLocks.clear()}get is3DOFL(){return L()&&null!=this._associatedLayer?.infoFor3D}get sortedGeometryChangedObjectIds(){return this.is3DOFL?[...this._geometryChangedObjectIds].sort(((e,t)=>e-t)):[]}get _associatedLayer(){return null==this.layer?null:this.layer.associatedLayer}get hasGeometryChanges(){return this._geometryChangedObjectIds.size>0}get _definitionExpression(){const e=this.sortedGeometryChangedObjectIds;return 0===e.length?"1 = 0":`OBJECTID IN (${e.join(",")})`}get updating(){if(!this.is3DOFL)return!1;if(this._pendingFetchChangedObjectIds)return!0;if(F()){return!(null!=this._associatedLayerView)||null!=this._associatedLayerView&&this._associatedLayerView.updating}return!1}get isEmpty(){return null==this._pendingFetchChangedObjectIds&&0===this._attributeChangedObjectIds.size&&0===this._geometryChangedObjectIds.size}featureHasGeometryChanges(e){return this._geometryChangedObjectIds.has(e)}featureHasAttributeChanges(e){return this._attributeChangedObjectIds.has(e)}createInteractiveEditSession(e){this._attributeChangedObjectIds.add(e);const t=this._interactiveEditingSessions,i=new M(e,(()=>{t.remove(i)}));return t.unshift(i),i}async applyAttributeOverrides(e,t,i,r=[]){if(this._pendingFetchChangedObjectIds&&await m(this._pendingFetchChangedObjectIds,i),null==t)return;const{attributeData:s,loadedAttributes:o}=t;if(null==o||null==s||0===this._attributeChangedObjectIds.size)return;const n=new Set;for(const d of o)n.add(d.index);for(const d of r)n.has(d.index)||(o.push(d),s[d.name]=new Array(e.length));const a=await this._lockFeatureIds(e);try{const t={attributeData:s,loadedAttributes:o},r=this._getOverridesFromCache(e,t,this._attributeChangedObjectIds),{objectIds:n,fieldNames:a}=r;if(0===n.length||0===a.length)return;const d=await this._queryAttributeOverridesFromAssociatedLayer(n,a,i);if(null==d)return;this._processOverridesFromAssociatedLayer(e,d,a,t)}finally{a.remove()}}updateGeometry(e,t){this._geometryChangedObjectIds.add(e);const i=this._clientGeometryCache.get(e);if(null!=i&&(this.geometryOverrides.remove(i),this._clientGeometryCache.delete(e)),null!=t){const i={oid:e,mesh:t};this.geometryOverrides.add(i),this._clientGeometryCache.set(e,i)}}updateAttributeValue(e,t,i){this._attributeChangedObjectIds.add(e),this._cacheAttributeValue(e,t,i)}featureAdded(e){this.is3DOFL&&A()&&this._geometryChangedObjectIds.add(e),this._attributeChangedObjectIds.add(e)}_cacheAttributeValue(e,t,i){this._memCache.put(this._getAttributeCacheKey(e,t),i,this._memCacheAttributeValueSize(i))}_getOverridesFromCache(e,{loadedAttributes:t,attributeData:i},r){const s=new Set,o=new Array;for(const a of t)o[a.index]=i[a.name];const n=new Set;for(let a=0;a<e.length;a++){const i=e[a];if(r.has(i))for(const e of t){const t=this._attributeFromCache(i,e.index);void 0===t?(s.add(i),n.add(e.name)):o[e.index][a]=t}}return{objectIds:Array.from(s),fieldNames:Array.from(n)}}_attributeFromCache(e,t){const i=this._fromInteractiveEditingSession(e,t);if(void 0!==i)return i;const r=this._getAttributeCacheKey(e,t);return this._memCache.get(r)}_fromInteractiveEditingSession(e,t){if(null!=this._interactiveEditingSessions)for(const i of this._interactiveEditingSessions){if(i.objectId!==e)continue;const r=i.getAttribute(t);if(void 0!==r)return r}}_getAttributeCacheKey(e,t){return`${e}-${t}`}async _queryAttributeOverridesFromAssociatedLayer(e,t,i){if(0===e.length)return null;this._logWarningIfMaximumObjectsExceeded();const{associatedLayer:r}=this.layer;if(null==r)return null;const s=r.createQuery(),{objectIdField:o}=r,n=[o,...t];s.where="1=1",s.returnGeometry=!1,s.outFields=n,s.cacheHint=!0;const a=await this._executeBatchQuery(r,e,s,i),d=[];for(const c of a)if(c.ok)for(const e of c.value.features)d.push(e);return d}async _queryGeometryOverridesFromAssociatedLayer(e,t){if(0===e.length||!this.is3DOFL||!A())return null;const i=this.layer.associatedLayer,r=i.infoFor3D,{spatialReference:s}=i,{state:{viewingMode:o},spatialReference:n}=this.view,a=o===E.Global,d=s.isGeographic;if(a&&!d)return h.getLogger(G).warn("unsupported-pcs-edits-in-global-view",this.layer.title,N(s,n,this.view.viewingMode,k.Mode)),null;if(!a&&d)return h.getLogger(G).warn("unsupported-gcs-edits-in-local-view",this.layer.title,N(s,n,this.view.viewingMode,k.Mode)),null;if(!(O(s,n)||a&&n.isWebMercator&&s.isWGS84))return h.getLogger(G).warn("unsupported-mismatched-spatial-reference-edits",this.layer.title,N(s,n,this.view.viewingMode,k.SpatialReference)),null;this._logWarningIfMaximumObjectsExceeded();const{objectIdField:c,globalIdField:l}=i,u=[c,...null!=l?[l]:[]],m=i.createQuery();m.where="1=1",m.returnGeometry=!0,m.outFields=u,m.cacheHint=!0,m.returnZ=i.hasZ,m.returnM=i.hasM;const g=await this._executeBatchQuery(i,e,m,t),p=[];for(const h of g){if(!h.ok)continue;const e=h.value,{assetMaps:t,features:i,globalIdFieldName:o}=e;if(null==t)continue;const n=w(r,t);for(const a of i){const e=I(a,o,s,r,n),t=a;null!=e?(t.geometry=e,p.push(t)):t.geometry=null}}return p}_logWarningIfMaximumObjectsExceeded(){if(!this._warnMaximumChangedObjectsExceeded)return;this._warnMaximumChangedObjectsExceeded=!1;let e=`The number of edited objects that are not yet cached in the scene service exceeds the maximum limit. Attribute changes will only be available for the first ${v(this._maximumNumberOfEditOVerrides)} objects. Please consider re-caching the scene service`;const t=this.layer.portalItem;t&&t.loaded?e+=` (${t.portal.url}/home/item.html?id=${t.id}#settings)`:e+=` (${this.layer.parsedUrl.path})`,h.getLogger(G).warn("#queryOverrides()",this.layer.title,`${e}.`)}async _executeBatchQuery(e,t,i,o){if(0===t.length)return[];const n=j(e);t=[...t].sort(((e,t)=>e-t));const a=r(t,n).map((t=>{const r=i.clone();return r.objectIds=t,s(C(e,r,{signal:o}))}));return Promise.all(a)}_processOverridesFromAssociatedLayer(e,t,i,{loadedAttributes:r,attributeData:s}){const o=this._associatedLayer;if(null==o)return;const n=o.objectIdField,a=i.map((t=>(t in s||(s[t]=new Array(e.length)),s[t]))),d=new Map(r.map((e=>[e.name,e.index]))),c=i.map((e=>d.get(e))),h=new Map(Array.from(e,((e,t)=>[e,t])));for(const l of t){const e=l.attributes[n];for(let t=0;t<i.length;t++){const r=c[t],s=h.get(e),o=l.attributes[i[t]];a[t][s]=o,this._cacheAttributeValue(e,r,o)}}}_memCacheAttributeValueSize(e){return"string"==typeof e?n(e):a()}async _fetchChangedObjectIds(e){const i=this.layer;await i.load({signal:e}),this._geometryChangedObjectIds.clear(),this._attributeChangedObjectIds.clear();const{associatedLayer:r}=i;if(null==r||!r.capabilities?.operations?.supportsChangeTracking)return;const s=this._getFetchChangedObjectIdsServerGen();if(null==s)return;const n=r.layerId,a=this.is3DOFL,d={f:"json",returnIdsOnly:!0,layers:`[${n}]`,returnUpdates:!0,returnDeletes:a,returnInserts:a,layerServerGens:JSON.stringify([{id:n,serverGen:s}])};if(a){const e=r.infoFor3D;d.fieldsToCompare=JSON.stringify({fields:[...Object.values(e.transformFieldRoles),e.sourceHashField]})}const c=await o(t(`${r.url}/extractChanges`,{method:"post",query:d,timeout:V,signal:e}));if(!c.ok&&x(c.error)){const e=this.layer.title;h.getLogger(G).warn("extractChanges:timeout",e,`${e} could not obtain edited features that are not cached in the scene service. Display of features may not be up to date with the latest edits. Consider re-caching the scene service.`)}if(c.ok&&1===c.value.data?.edits?.length){const t=c.value.data.edits[0],i=t?.objectIds,s=t?.fieldUpdates,o=i?.adds??[],n=i?.updates??[],d=i?.deletes??[],h=[...o,...n,...d],l=a?[...o,...s??n,...d]:[],u=Math.min(this._maximumNumberOfEditOVerrides,h.length);u<h.length&&(this._warnMaximumChangedObjectsExceeded=!0);const m=h.sort(((e,t)=>e-t));for(let e=0;e<u;++e){const t=m[e];this._attributeChangedObjectIds.add(t)}for(const e of l)this._geometryChangedObjectIds.add(e);if(this.is3DOFL&&A()&&this._geometryChangedObjectIds.size>0){const t=await this._queryGeometryOverridesFromAssociatedLayer(Array.from(this._geometryChangedObjectIds),e);if(null!=t)for(const e of t)null!=e.geometry&&this.updateGeometry(e.attributes[r.objectIdField],e.geometry)}}}_getFetchChangedObjectIdsServerGen(){const e=this.layer;if(null!=e.serviceUpdateTimeStamp?.lastUpdate)return e.serviceUpdateTimeStamp.lastUpdate;const t=e.associatedLayer;return null!=t?.serverGens?.minServerGen?t.serverGens.minServerGen:null}async _lockFeatureIds(e){const t=this._featureIdLocks;let i=!0;for(;i;){const r=new Array;for(const i of e){const e=t.get(i);e&&r.push(e)}0===r.length?i=!1:await Promise.all(r)}const r=g(),s=r.promise;for(const o of e)t.set(o,s);return c((()=>{for(const i of e)t.delete(i);r.resolve()}))}get test(){const e=Array.from(this._attributeChangedObjectIds),t=this._pendingFetchChangedObjectIds,i=this;return{changedObjectIds:e,pendingFetchChangedObjectIds:t,get maximumNumberOfEditOVerrides(){return i._maximumNumberOfEditOVerrides},set maximumNumberOfEditOVerrides(e){i._maximumNumberOfEditOVerrides=e}}}};e([b({constructOnly:!0})],D.prototype,"view",void 0),e([b({constructOnly:!0})],D.prototype,"layer",void 0),e([b({readOnly:!0})],D.prototype,"is3DOFL",null),e([b()],D.prototype,"_interactiveEditingSessions",void 0),e([b({readOnly:!0})],D.prototype,"sortedGeometryChangedObjectIds",null),e([b({readOnly:!0})],D.prototype,"geometryOverrides",void 0),e([b()],D.prototype,"_clientGeometryCache",void 0),e([b()],D.prototype,"_associatedLayer",null),e([b()],D.prototype,"_associatedLayerView",void 0),e([b({constructOnly:!0})],D.prototype,"memoryController",void 0),e([b()],D.prototype,"_attributeChangedObjectIds",void 0),e([b()],D.prototype,"_geometryChangedObjectIds",void 0),e([b()],D.prototype,"hasGeometryChanges",null),e([b()],D.prototype,"_pendingFetchChangedObjectIds",void 0),e([b()],D.prototype,"_pendingFetchAbortController",void 0),e([b()],D.prototype,"_definitionExpression",null),e([b()],D.prototype,"updating",null),e([b()],D.prototype,"isEmpty",null),D=e([_(G)],D);class M{constructor(e,t){this.objectId=e,this._remove=t,this._updates=new Map,this._isActive=!0}getAttribute(e){return this._updates.get(e)}setAttribute(e,t){this.isActive&&this._updates.set(e,t)}remove(){this.isActive&&(this._isActive=!1,this._remove())}get isActive(){return this._isActive}}const V=1e4,$=5e4;var k;function N(e,t,i,r){return`Displaying the edits of a SceneLayer with a${r===k.Mode?e.isGeographic?" geographic ":" projected ":" "}spatial reference (wkid:${e.wkid}) in ${i} viewing mode${r===k.SpatialReference?` with spatial reference (wkid:${t.wkid}) `:" "}is not supported. No geometry edits will be displayed for this layer.\nPlease consider re-caching the scene service or changing the ${r===k.Mode?"viewing mode":"view spatial reference"} to display edits.`}!function(e){e[e.Mode=0]="Mode",e[e.SpatialReference=1]="SpatialReference"}(k||(k={}));export{D as I3SOverrides};
|