@arcgis/core 6.0.0-next.54 → 6.0.0-next.56
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/WebScene.js +2 -2
- package/applications/Components/OrientedImageryViewer/shared/constants.js +1 -1
- package/applications/SceneViewer/sceneViewerUtils.js +1 -1
- package/arcade/arcadeAsyncRuntime.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/arcadeRuntime.js +1 -1
- package/arcade/featureset/support/sqlUtils.js +1 -1
- package/arcade/validation/arcadeValidator.js +1 -1
- package/arcgisGlobal.d.ts +1 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0329fa3aa3403f1c243b.js +1 -0
- package/assets/esri/core/workers/chunks/033b9fcd9833db3b6e7d.js +1 -0
- package/assets/esri/core/workers/chunks/{6602310c3fcd91fb6a2f.js → 07c8ac092e4b9e8d5b3c.js} +1 -1
- package/assets/esri/core/workers/chunks/0978e12dd6a1cbc50b80.js +1 -0
- package/assets/esri/core/workers/chunks/0a97b1974367382cfdf5.js +1 -0
- package/assets/esri/core/workers/chunks/{db0a7671ab5cbe8afd72.js → 123661019bb69c53f2d3.js} +1 -1
- package/assets/esri/core/workers/chunks/{e956845255bce0910944.js → 1507297550c3cd1268e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{1b41ba050cde068d2860.js → 193a73a2c7f4f8482c21.js} +1 -1
- package/assets/esri/core/workers/chunks/1c0f5c42331fb6fc26cb.js +1 -0
- package/assets/esri/core/workers/chunks/20acb6f3ed5140b6c6c6.js +1 -0
- package/assets/esri/core/workers/chunks/2cd2fcf4a37d180d5d5c.js +1 -0
- package/assets/esri/core/workers/chunks/2f9adf0b809ce8797ebf.js +1 -0
- package/assets/esri/core/workers/chunks/{afb4dfb89fbc8a342cc5.js → 3354f1fa90f8ce4c8fde.js} +1 -1
- package/assets/esri/core/workers/chunks/3982409149571a827390.js +1 -0
- package/assets/esri/core/workers/chunks/{9b458b0d1627f22fdd93.js → 3b11e4d2e69b7aea1d65.js} +1 -1
- package/assets/esri/core/workers/chunks/3d851710f7fcc27c5b60.js +2 -0
- package/assets/esri/core/workers/chunks/3e8d70039800f2395d66.js +1 -0
- package/assets/esri/core/workers/chunks/41694ee8990e799da225.js +1 -0
- package/assets/esri/core/workers/chunks/4d8539674fc2e4fea03c.js +1 -0
- package/assets/esri/core/workers/chunks/{12add2003631fa314f25.js → 5060be52a380fc4920f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2aa6be0b047a1b25a520.js → 53bbb9aa6e4e4a0a8121.js} +1 -1
- package/assets/esri/core/workers/chunks/{c6d82397044e403a1f61.js → 5954f02c3901b28d8e73.js} +1 -1
- package/assets/esri/core/workers/chunks/5ba6007c3c49a8153256.js +1 -0
- package/assets/esri/core/workers/chunks/5bdd95eeb8f34dbf26f2.js +2 -0
- package/assets/esri/core/workers/chunks/{4707aedcc1b3bdf5e987.js → 5c34d49a6c9cc34b7626.js} +1 -1
- package/assets/esri/core/workers/chunks/{ced5dfb2bf46fc5eac8c.js → 5e47026c681238038955.js} +2 -2
- package/assets/esri/core/workers/chunks/{2baf35b1b19482d603b5.js → 5f7505ada0991cfbdd84.js} +1 -1
- package/assets/esri/core/workers/chunks/{976303f47c342b9d1cc0.js → 62ddd3a82864e26f009a.js} +1 -1
- package/assets/esri/core/workers/chunks/69a09c6acb5ae03c67f6.js +1 -0
- package/assets/esri/core/workers/chunks/{542a9c414c99d84d52ab.js → 6a202ef9ba9b89e09153.js} +1 -1
- package/assets/esri/core/workers/chunks/{0826feebdca8a31eb630.js → 6ba6fece5c11fe2a6ace.js} +1 -1
- package/assets/esri/core/workers/chunks/{5eb69e2895e5aec81051.js → 6fd10891506925560443.js} +1 -1
- package/assets/esri/core/workers/chunks/7b156905d168bf973518.js +1 -0
- package/assets/esri/core/workers/chunks/7b6fd287e7043ad50f4e.js +1 -0
- package/assets/esri/core/workers/chunks/7baa49055bc31618b56e.js +1 -0
- package/assets/esri/core/workers/chunks/8570e3df90fb76a8741a.js +1 -0
- package/assets/esri/core/workers/chunks/{c3c0f24a9e0047232ae1.js → 8679dfc0c53355b6feb0.js} +1 -1
- package/assets/esri/core/workers/chunks/8a636dc51372e14c98f5.js +1 -0
- package/assets/esri/core/workers/chunks/{d14732a57c8e63948c60.js → 9117c9b720c9ba6e7a6e.js} +1 -1
- package/assets/esri/core/workers/chunks/{f7e33d37dd11fb08f3f8.js → 97107e64407fa6825620.js} +1 -1
- package/assets/esri/core/workers/chunks/{5118c7269b706089c88e.js → a05a2c2aaf0c288f9681.js} +1 -1
- package/assets/esri/core/workers/chunks/{944f17e9c9f681b971fb.js → a12e2a345005189c64be.js} +1 -1
- package/assets/esri/core/workers/chunks/a22458e5272332d86cb9.js +1 -0
- package/assets/esri/core/workers/chunks/{15b3386ad92a0b4149b8.js → a24dc5350af001db417a.js} +1 -1
- package/assets/esri/core/workers/chunks/{10967a36c77c5188690d.js → a66d6298236d59a615db.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ea480cebf8ee56228a5.js → a7dfca326883384d2751.js} +1 -1
- package/assets/esri/core/workers/chunks/{723d8316f5d4b6ce2942.js → a9539393e2f1812a973a.js} +1 -1
- package/assets/esri/core/workers/chunks/{ac8d38016e4bee37a77c.js → ab784764ddf9d7f693a1.js} +1 -1
- package/assets/esri/core/workers/chunks/{255f5b45c4d32f97f86c.js → ac0861014b3d2f1a1de2.js} +1 -1
- package/assets/esri/core/workers/chunks/ace210d313ce53f3ae10.js +1 -0
- package/assets/esri/core/workers/chunks/ae48ee283cfa5b3c14b0.js +1 -0
- package/assets/esri/core/workers/chunks/b38b6fe08a367e9de4f5.js +1 -0
- package/assets/esri/core/workers/chunks/{4e651869e9a196494694.js → b6e628b5d2643af4c19b.js} +1 -1
- package/assets/esri/core/workers/chunks/{b37ab6b1cb4cfc85cd9d.js → b7828d7e2c5b75644057.js} +1 -1
- package/assets/esri/core/workers/chunks/bbd8fcb0bbba7bde3d9b.js +1 -0
- package/assets/esri/core/workers/chunks/{ec465abb0344ad719e9d.js → bd8e329ec74d921d311a.js} +1 -1
- package/assets/esri/core/workers/chunks/{56e6e70aa40e51827290.js → c3f94024c6c9eed9f273.js} +1 -1
- package/assets/esri/core/workers/chunks/{6d17b45022dfd2548098.js → c5ddf8b347c31fe772a3.js} +1 -1
- package/assets/esri/core/workers/chunks/{ee9af58ae202b803bba7.js → c7a0c4ca37ebd1d98cf1.js} +1 -1
- package/assets/esri/core/workers/chunks/d0659f1b0495734be4b3.js +1 -0
- package/assets/esri/core/workers/chunks/d7763c42754152510e13.js +2 -0
- package/assets/esri/core/workers/chunks/{b9a2b05ede02c305e865.js → d8ffb1502def5c85740b.js} +1 -1
- package/assets/esri/core/workers/chunks/{7dfe1e78d2e66de6be22.js → d9ef244019954d5a8a27.js} +1 -1
- package/assets/esri/core/workers/chunks/{95403bb27a4ea0a4b7b1.js → ddbfa664e69612295785.js} +1 -1
- package/assets/esri/core/workers/chunks/dfa1b0308e5e82d1ddfe.js +1120 -0
- package/assets/esri/core/workers/chunks/e566102c7ed7a8ebf89e.js +1 -0
- package/assets/esri/core/workers/chunks/e74586b074d0fa6abb4b.js +1 -0
- package/assets/esri/core/workers/chunks/e7dff025780726d5feae.js +1 -0
- package/assets/esri/core/workers/chunks/e96fa029acba59c04e4e.js +2 -0
- package/assets/esri/core/workers/chunks/{55d28d3f5b8ced061e39.js → eaf73ce60f39a48ddd2a.js} +1 -1
- package/assets/esri/core/workers/chunks/ed2f2a5da830d058e339.js +1 -0
- package/assets/esri/core/workers/chunks/{e592f2483db71230e8e5.js → efd6ea0966f60ab19520.js} +1 -1
- package/assets/esri/core/workers/chunks/{944cb751c85d3a127f49.js → f52d081bbde5c95265cf.js} +1 -1
- package/assets/esri/core/workers/chunks/{1de9be7b65109c207bd5.js → fbd5f3b81cd9f061824d.js} +1 -1
- package/assets/esri/core/workers/chunks/fdfbd201be372d3796bf.js +2 -0
- package/assets/esri/core/workers/chunks/ff0a0819bba5e8264c47.js +1 -0
- package/assets/esri/layers/raster/formats/blosc-wasm.wasm +0 -0
- package/assets/esri/libs/librust-parquet/pkg/parquet_bg.wasm +0 -0
- package/basemapGallery/support/basemapCompatibilityUtils.js +1 -1
- package/chunks/BlendLayers.glsl.js +1 -1
- package/chunks/ColorMaterial.glsl.js +14 -14
- package/chunks/Component.glsl.js +37 -37
- package/chunks/CypherParser.js +1 -1
- package/chunks/DefaultMaterial.glsl.js +15 -15
- package/chunks/GeodeticDistanceCalculator-zRp89-dW.js +1 -1
- package/chunks/HUDMaterial.glsl.js +3 -3
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/OperatorGeodesicBuffer.js +1 -1
- package/chunks/Path.glsl.js +15 -15
- package/chunks/Pattern.glsl.js +20 -20
- package/chunks/RasterColorizer.glsl.js +1 -1
- package/chunks/ShadowHighlight.glsl.js +1 -1
- package/chunks/Terrain.glsl.js +24 -24
- package/chunks/UnitFactory.js +1 -1
- package/chunks/Water.glsl.js +29 -20
- package/chunks/blosc-wasm.js +2 -0
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/parquet.js +1 -1
- package/chunks/pdf.js +57 -0
- package/chunks/text.js +1 -1
- package/config.js +1 -1
- package/core/accessorSupport/write.js +1 -1
- package/core/scheduling.js +1 -1
- package/core/sql/SqlInterval.js +1 -1
- package/core/urlUtils.js +1 -1
- package/geometry/geometryEngine.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/support/Ellipsoid.js +1 -1
- package/geometry/support/curves/ellipticArc7Utils.js +1 -1
- package/geometry/support/geodesicConstants.js +1 -1
- package/geometry/support/meshUtils/primitives.js +1 -1
- package/kernel.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/effects/parser.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +1 -56
- package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
- package/layers/geospatialPDF/parserUtils.js +2 -0
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/parquet.js +1 -1
- package/layers/raster/datasets/ZarrRaster.js +1 -1
- package/layers/raster/datasets/wcsCoverageParser.js +1 -1
- package/layers/raster/formats/RasterCodec.js +1 -1
- package/layers/raster/formats/blosc.js +2 -0
- package/layers/support/BuildingFilter.js +1 -1
- package/layers/support/ControlPoint.js +1 -1
- package/layers/support/ControlPointsGeoreference.js +1 -1
- package/layers/support/IntegratedMeshSemantics.js +1 -1
- package/layers/support/commonProperties.js +1 -1
- package/layers/support/fieldUtils.d.ts +23 -87
- package/layers/support/fieldUtils.js +1 -1
- package/layers/support/geospatialPDFUtils.d.ts +63 -0
- package/layers/support/geospatialPDFUtils.js +2 -0
- package/layers/support/layersMapping.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/legend/ActiveLayerInfo.js +1 -1
- package/libs/ajv/ajv.bundle-wrapper.js +1 -1
- package/package.json +6 -6
- package/renderers/types.d.ts +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/query/operations/pbfFeatureServiceParser.js +1 -1
- package/smartMapping/statistics/support/attributeDensity.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/support/tests/serviceMockDependencies.js +1 -1
- package/symbols/CIMSymbol.d.ts +9 -9
- package/symbols/PathSymbol3DLayer.d.ts +1 -1
- package/symbols/WaterSymbol3DLayer.d.ts +13 -1
- package/symbols/WaterSymbol3DLayer.js +1 -1
- package/symbols/cim/CIMEffects.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/symbols/cim/placements/PlacementInsidePolygon.js +1 -1
- package/symbols/cim/rasterizingUtils.js +1 -1
- package/views/2d/PaddedViewState.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/FillBucket.js +1 -1
- package/views/2d/engine/vectorTiles/constants.js +1 -1
- package/views/2d/engine/vectorTiles/style/geoJSONVectorTileUtils.js +1 -1
- package/views/2d/engine/webgl/effects/HighlightEffect.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/segmentUtils.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/constants.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/TransformTool.js +1 -1
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/ParquetLayerView2D.js +1 -1
- package/views/2d/layers/features/Processor.js +1 -1
- package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
- package/views/2d/layers/features/support/AttributeStore.js +1 -1
- package/views/2d/layers/features/support/FeatureSetReaderPBF.js +1 -1
- package/views/2d/layers/graphics/GraphicsView2D.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/AreaMeasurementPathHelper.js +1 -1
- package/views/3d/analysis/Dimension/DimensionTool.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/ElevationProfile/ElevationProfileLineSceneComputation.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemManipulatedObject3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightRayIntersector.js +1 -1
- package/views/3d/analysis/ShadowCastAnalysisView3D.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedObserverManipulatedObject3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSnappingController.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillComputation.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementVisualization.js +1 -1
- package/views/3d/animation/pointToPoint/Camera.js +1 -1
- package/views/3d/camera/constraintUtils/tilt.js +1 -1
- package/views/3d/camera/constraintUtils.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/EnvironmentView.js +1 -1
- package/views/3d/focusAreaUtils.js +1 -1
- package/views/3d/input/handlers/ground/GroundNavigation.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/Manipulator3DBase.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
- package/views/3d/interactive/editingTools/dragEventPipeline3D.js +1 -1
- package/views/3d/interactive/editingTools/manipulations/config.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerControlPoints.js +1 -1
- package/views/3d/interactive/editingTools/media/MediaElementControllerShape.js +1 -1
- package/views/3d/interactive/editingTools/move/MoveTool3D.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateMeshAdapter.js +1 -1
- package/views/3d/interactive/editingTools/transform/TransformTool3D.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/areaMeasurement3D/AreaMeasurement3DView.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DView.js +1 -1
- package/views/3d/interactive/visualElements/Object3DVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/layers/BuildingSceneLayerView3D.js +1 -1
- package/views/3d/layers/DrapedSubView3D.js +1 -1
- package/views/3d/layers/DynamicLayerView3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerViewBase3D.js +1 -1
- package/views/3d/layers/FlowSubView3D.js +1 -1
- package/views/3d/layers/GraphicsLayerView3D.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/RouteLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/VoxelLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFrustumVisibility.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DLineSymbolLayer.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/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPolygonFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DSymbolFactory.js +1 -1
- package/views/3d/layers/graphics/Graphics3DWaterSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/LabelInfo.js +1 -1
- package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/layers/i3s/I3SIntersectionHandler.js +1 -1
- package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
- package/views/3d/layers/i3s/I3SNode.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DContext.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/StageLayerElevationProvider.js +1 -1
- package/views/3d/layers/support/Tiles3DBVH.js +1 -1
- package/views/3d/layers/support/Tiles3DLayerViewRegistration.js +1 -1
- package/views/3d/layers/support/createTileBVHForLayer.js +1 -1
- package/views/3d/layers/support/selectTiles3DSpatialReference.js +1 -1
- package/views/3d/layers/support/uvUtils.js +1 -1
- package/views/3d/state/Constraints.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerGlobal.js +1 -1
- package/views/3d/state/controllers/PinchAndPanControllerLocal.js +1 -1
- package/views/3d/state/controllers/PointToPointAnimationController.js +1 -1
- package/views/3d/state/controllers/RotateController.js +1 -1
- package/views/3d/state/controllers/ZoomControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerGlobal.js +1 -1
- package/views/3d/state/controllers/ZoomStepControllerLocal.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/state/utils/OffsetCorrectionController.js +1 -1
- package/views/3d/state/utils/groundNavigationUtils.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/FrustumExtentIntersection.js +1 -1
- package/views/3d/support/QualityProfile.js +1 -1
- package/views/3d/support/QualitySettings.js +1 -1
- package/views/3d/support/RenderCoordsHelper.js +1 -1
- package/views/3d/support/SweptSphereVolume.js +1 -1
- package/views/3d/support/cameraUtils.js +1 -1
- package/views/3d/support/elevationUpdateExtentUtils.js +1 -1
- package/views/3d/support/engineContent/line.js +1 -1
- package/views/3d/support/engineContent/marker.js +1 -1
- package/views/3d/support/flow/StreamlineResources3DShape.js +1 -1
- package/views/3d/support/hitTest.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/PointsOfInterest.js +1 -1
- package/views/3d/support/pointsOfInterest/SurfaceGeometryUpdates.js +1 -1
- package/views/3d/support/sunUtils.js +1 -1
- package/views/3d/terrain/BlendLayersTechniqueConfiguration.js +1 -1
- package/views/3d/terrain/ExtentHelper.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/RasterColorizerTechniqueConfiguration.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/Tile.js +1 -1
- package/views/3d/terrain/TilingSchemeLogic.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl-engine/Stage.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectElevationAgnosticComponentGeometryBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ElevationAgnosticBVH.js +1 -1
- package/views/3d/webgl-engine/collections/Component/IntersectionGeometry.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/Component.glsl.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterialRepository.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/clampShadowPosition.glsl.js +2 -0
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +14 -14
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUD.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/Overlay.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -3
- package/views/3d/webgl-engine/core/shaderLibrary/util/View.glsl.js +1 -1
- package/views/3d/webgl-engine/effects/atmosphere/MarsAtmosphere.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/ShadowHighlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
- package/views/3d/webgl-engine/effects/shadowAccumulation/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/BufferGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/BufferObject3D.js +1 -1
- package/views/3d/webgl-engine/lib/GridLocalOriginFactory.js +1 -1
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/Object3D.js +1 -1
- package/views/3d/webgl-engine/lib/Program.js +1 -1
- package/views/3d/webgl-engine/lib/RenderGeometry.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/TriangleIntersectionData.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/strokes.js +1 -1
- package/views/3d/webgl-engine/lib/verticalOffsetUtils.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/Path.glsl.js +1 -1
- package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/Water.glsl.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/Model.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/ColorMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Pattern.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Terrain.glsl.js +1 -1
- package/views/Attribution.js +5 -5
- package/views/DOMContainer.d.ts +2 -1
- package/views/MapView.d.ts +1 -0
- package/views/SceneView.js +1 -1
- package/views/View2D.js +1 -1
- package/views/ViewingMode.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileChartBoundsUtils.js +1 -1
- package/views/analysis/ElevationProfile/elevationProfileGeometryUtils.js +1 -1
- package/views/draw/DrawAction.js +1 -1
- package/views/draw/DrawGraphicTool.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/DrawTool.js +1 -1
- package/views/draw/SegmentDrawAction.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/helpMessageUtils.js +1 -1
- package/views/draw/support/managers/EditSessionManager.js +1 -1
- package/views/draw/support/surfaceCoordinateSystems.js +1 -1
- package/views/interactive/dragEventPipeline.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/AddOrUpdatePart.js +1 -1
- package/views/layers/support/editableLayerViews.js +1 -1
- package/views/overlay/TextOverlayItem.js +1 -1
- package/views/support/DefaultsFromMap.js +1 -1
- package/views/support/Scheduler.js +1 -1
- package/views/support/spatialReferenceSupport.js +1 -1
- package/views/webgl/Program.js +3 -3
- package/views/webgl/ShaderBuilder.js +23 -23
- package/views/webgl/ShaderTranspiler.js +2 -2
- package/webscene/Slide.js +1 -1
- package/webscene/VirtualLighting.d.ts +2 -4
- package/widgets/AreaMeasurement2D/AreaMeasurement2DTool.js +1 -1
- package/widgets/BasemapGallery/support/basemapCompatibilityUtils.js +1 -1
- package/widgets/BatchAttributeForm/inputs/FieldInput.d.ts +17 -1
- package/widgets/BatchAttributeForm/inputs/FieldInput.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/inputUtils.d.ts +7 -0
- package/widgets/BatchAttributeForm/inputs/support/inputUtils.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/DistanceMeasurement2D/DistanceMeasurement2DTool.js +1 -1
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileLineView.js +1 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/ElevationProfile/support/geometryUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/Legend/styles/card/ColorRamp.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Measurement.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageLocationWidget.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageMeasurementWidget.js +1 -1
- package/widgets/Search/support/layerSearchUtils.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations/UtilityNetworkAssociationsViewModel.js +1 -1
- package/widgets/UtilityNetworkAssociations.js +1 -1
- package/widgets/Weather/WeatherViewModel.js +1 -1
- package/widgets/Weather/css.js +1 -1
- package/widgets/Weather.js +1 -1
- package/widgets/support/ContingentValuesManager.js +1 -1
- package/widgets/support/forms/types.d.ts +23 -1
- package/assets/esri/core/workers/chunks/021bd07b9a3e70598840.js +0 -1
- package/assets/esri/core/workers/chunks/032733b863426c5bde00.js +0 -1121
- package/assets/esri/core/workers/chunks/144f18a3dd2c8cf07cf7.js +0 -1
- package/assets/esri/core/workers/chunks/170e68624b71ac96de4a.js +0 -1
- package/assets/esri/core/workers/chunks/23fc1c1ed483ed3b2298.js +0 -1
- package/assets/esri/core/workers/chunks/2634927d26cb1139c6d0.js +0 -1
- package/assets/esri/core/workers/chunks/2d1b8154ee40afc9d40b.js +0 -1
- package/assets/esri/core/workers/chunks/2d3e977f3b75474d7ebc.js +0 -1
- package/assets/esri/core/workers/chunks/4a41bf3d1e2e9bb79771.js +0 -2
- package/assets/esri/core/workers/chunks/5f324d88785ffcb73ae0.js +0 -1
- package/assets/esri/core/workers/chunks/70695e0fb53018d48e7b.js +0 -2
- package/assets/esri/core/workers/chunks/723c9ad4c25be2b82476.js +0 -1
- package/assets/esri/core/workers/chunks/766a1357be2ed7f4e125.js +0 -1
- package/assets/esri/core/workers/chunks/817bf487df056da1e6ec.js +0 -1
- package/assets/esri/core/workers/chunks/89e55895683369b5277a.js +0 -1
- package/assets/esri/core/workers/chunks/8a820e303941b351de81.js +0 -1
- package/assets/esri/core/workers/chunks/8c94e987754b3919181e.js +0 -1
- package/assets/esri/core/workers/chunks/90d567e920b6982b402d.js +0 -1
- package/assets/esri/core/workers/chunks/919115788da38049aea7.js +0 -2
- package/assets/esri/core/workers/chunks/97cdcedfe853280f6258.js +0 -1
- package/assets/esri/core/workers/chunks/9ebc6026934400fc1e1f.js +0 -1
- package/assets/esri/core/workers/chunks/b33e7e74cf8fa3926617.js +0 -1
- package/assets/esri/core/workers/chunks/b4a325dcf50e276751d7.js +0 -1
- package/assets/esri/core/workers/chunks/bb2af16e55cb39163827.js +0 -1
- package/assets/esri/core/workers/chunks/be5857b0d1b00faf430b.js +0 -1
- package/assets/esri/core/workers/chunks/cd9100a7c8309dfa7569.js +0 -1
- package/assets/esri/core/workers/chunks/d5bb9f9b7b341c671525.js +0 -1
- package/assets/esri/core/workers/chunks/d96e63d66f7b1f4ea54a.js +0 -2
- package/assets/esri/core/workers/chunks/e3bcd2e356f75afc316a.js +0 -1
- package/assets/esri/core/workers/chunks/e507dfc4788295d9c244.js +0 -1
- package/assets/esri/core/workers/chunks/e58f51618251f74aaafd.js +0 -1
- package/assets/esri/core/workers/chunks/e80526571f1a34de3278.js +0 -1
- package/assets/esri/core/workers/chunks/e83806797979138fd22a.js +0 -1
- package/assets/esri/core/workers/chunks/ea71850ba87ae6038000.js +0 -1
- package/assets/esri/core/workers/chunks/f537a5e808dc546813c7.js +0 -1
- package/assets/esri/core/workers/chunks/fe811d651d201f698b8f.js +0 -2
- package/chunks/NativeLine.glsl.js +0 -8
- package/layers/geospatialPDF/geospatialPDFParserUtils.js +0 -2
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +0 -2
- package/views/3d/webgl-engine/shaders/NativeLine.glsl.js +0 -2
- package/views/3d/webgl-engine/shaders/NativeLineTechnique.js +0 -2
- package/views/3d/webgl-engine/shaders/NativeLineTechniqueConfiguration.js +0 -2
- /package/assets/esri/core/workers/chunks/{919115788da38049aea7.js.LICENSE.txt → 3d851710f7fcc27c5b60.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{fe811d651d201f698b8f.js.LICENSE.txt → 5bdd95eeb8f34dbf26f2.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{ced5dfb2bf46fc5eac8c.js.LICENSE.txt → 5e47026c681238038955.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{4a41bf3d1e2e9bb79771.js.LICENSE.txt → d7763c42754152510e13.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{d96e63d66f7b1f4ea54a.js.LICENSE.txt → e96fa029acba59c04e4e.js.LICENSE.txt} +0 -0
- /package/assets/esri/core/workers/chunks/{70695e0fb53018d48e7b.js.LICENSE.txt → fdfbd201be372d3796bf.js.LICENSE.txt} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{ZEROS as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose 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{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{transformMat4 as l,scale as u,round as d,copy as f,set as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{set as m,transformMat4 as h,scale as g}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{lerp as v}from"../../../../core/mathUtils.js";import{destroyMaybe as y}from"../../../../core/maybe.js";import{UpdatingHandles as b}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as x}from"../../../../geometry/ellipsoidUtils.js";import{create as S,empty as C,copy as w,offset as T,width as E,height as D,expand as ee}from"../../../../geometry/support/aaBoundingRect.js";import{extrusionContainsPoint as te,create as ne,copy as re}from"../../../../geometry/support/boundedPlane.js";import{create as O}from"../../../../geometry/support/ray.js";import{Sphere as k}from"../../../../geometry/support/sphere.js";import{Yield as A}from"../../../support/Yield.js";import{InternalRenderCategory as j}from"../../webgl.js";import{getVec3AttributeView as M,getScalarAttributeView as N}from"../../webgl-engine/lib/attributeViewUtils.js";import{GPUPointOcclusionQuery as P}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as F}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as I}from"../../webgl-engine/materials/HUDMaterial.js";import L from"../../webgl/RenderCamera.js";import{DeconflictAABR as R}from"./DeconflictAABR.js";import{prepare as z,drawPoly as B}from"./deconflictorDebug.js";import{isSymbolLayerWithTransparencyMode as V}from"./transparencyUtils.js";const H=a(),U=a(),ie=a(),W=a(),G=_(),K=_(),q=a(),J=s(),Y=new k,X=O(),ae=a(),oe=S();class se{constructor(e){this.id=e,this.aabr=S(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function ce(e,t){let n=e.distanceToOccluder!==0&&e.distance>e.distanceToOccluder,r=t.distanceToOccluder!==0&&t.distance>t.distanceToOccluder;return n===r?e.priority===t.priority?e.distance===t.distance?e.visible===t.visible?e.id-t.id:+t.visible-e.visible:e.distance-t.distance:t.priority-e.priority:+n-r}class Z{constructor(e,t){this.graphics3DGraphic=e,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(e){let t=this.getInfo(e);return t||(t=new se(this.graphics3DGraphic.graphic.uid),this._setInfo(e,t)),t}getInfo(e){return e===16?this._labelInfo:this._info}removeInfo(e){this._setInfo(e,null)}_setInfo(e,t){e===16?this._labelInfo=t:this._info=t}}class Q{constructor(){this.camera=new L,this.slicePlane=ne(),this.slicePlaneEnabled=!1}copyFrom(e){this.camera.equals(e.camera)||this.camera.copyFrom(e.camera),re(e.slicePlane,this.slicePlane),this.slicePlaneEnabled=e.slicePlaneEnabled}}let $=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(e){super(e),this._dirty=!1,this._viewState=new Q,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=[],this._updatingHandles=new b,this._deconflictor=new R((e,t)=>{e.visible=t,this._setGraphicVisibility(this._active.get(e.id),t)},(e,t)=>e.id!==t.id,ce),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange(`_readyToRun`))}setPriority(e,t){let n=this._active.get(e.graphic.uid)?.getInfo(this.visibilityGroup);n&&(n.priority=t)}get _readyToRun(){return this._state!==0||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;let e=this._state/5;return this._dirty?e*.5:e}get readyToRun(){return this.view.ready&&this.view.state!=null&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+(this._occlusionQueryUids?.length??0)*4}runTask(e){switch(this._state){case 0:this._startUpdate(),e.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(e))return;case 2:if(this._state=2,!(this._occlusionQuery?.done??!0)||!(this._opaqueOcclusionQuery?.done??!0))return A;this._readOcclusionQueryResult(),e.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(e))return;case 4:if(this._state=4,this._deconflictor.run(e),!this._deconflictor.done)return;default:this._state=0,this.notifyChange(`_readyToRun`)}}setGraphicsActive(e,t){t?e.forEach(e=>this.addToActiveGraphics(e)):e.forEach(e=>this.removeFromActiveGraphics(e))}isSupportedLayer(e){if(e==null||e.type!==`buffer`||!e.hiddenIfDeconflicted)return!1;let t=e.stageObject;return(t?.geometries.length??0)===1&&t?.geometries[0]?.material instanceof I}_startUpdate(){z(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);let{fullWidth:e,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(e,t),this._resetIterators(),this._occlusionQueryUids.length=0,this._checkOcclusion.size||(this._occlusionQuery=y(this._occlusionQuery),this._opaqueOcclusionQuery=y(this._opaqueOcclusionQuery))}addToActiveGraphics(e){e.ensureInfo(this.visibilityGroup),this._active.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromActiveGraphics(e){this._active.get(e.graphics3DGraphic.graphic.uid)===e&&(le(e,this.visibilityGroup),e.removeInfo(this.visibilityGroup),this._active.delete(e.graphics3DGraphic.graphic.uid),this.setDirty())}addToCheckOcclusion(e){this._checkOcclusion.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromCheckOcclusion(e){this._checkOcclusion.get(e.graphics3DGraphic.graphic.uid)===e&&this._checkOcclusion.delete(e.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(e){if(this._checkOcclusion.size===0)return!0;let t=this._ensureCheckOcclusionIterator(),n=this._viewState.camera,r=o(J,n.viewInverseTransposeMatrix),a=this.view.map.ground.opacity>0,s=this.view.viewingMode===`global`&&a&&n.relativeElevation>0?Y:null,c=0;s!=null&&(l(s.center,i,n.viewMatrix),s.radius=x(this.view.spatialReference).radius,c=s.distanceToSilhouette(i));let u=S();for(;;){if(e.done)return!1;e.madeProgress();let i=t.next();if(i.done===!0)break;let a=i.value,o=a.graphics3DGraphic;if(o.destroyed||!o.isVisible(1,8))continue;let d=pe(o,this.visibilityGroup),f=null,p=!0,m=!1;for(let e of d){if(!this.isSupportedLayer(e))continue;if(f=me,!this._projectHudLayer(e,n,f)||this._isCulledBySlice(a,f.positionWorld)||s!=null&&fe(f,s,c)){p=!1;break}C(u);let t=e.stageObject.geometries[0].material;this._expandBoundingRect(u,n,e,t,f),f.altitude=this.view.renderCoordsHelper.getAltitude(f.positionWorld);let i=a.ensureInfo(this.visibilityGroup);if(i.altitude=f.altitude,i.distance=f.distance,i.distanceToOccluder=f.distanceToOccluder,i.culled=!1,w(i.aabr,u),!e.occlusionCheck)break;l(U,f.positionView,r);let d=this._ensureOcclusionQuery(),h=this._ensureOpaqueOcclusionQuery();this._occlusionQueryUids.length===0&&(this._initOcclusionQuery(d),this._initOcclusionQuery(h));let g=d.addPosition(U),_=h.addPosition(U);if(g===this._occlusionQueryUids.length&&_===g){let t=e.adaptiveOcclusion;this._occlusionQueryUids.push(t?-o.graphic.uid:o.graphic.uid),m=!0}break}let h=this._active.has(o.graphic.uid);if(!h&&!m)this._setGraphicVisibility(a,p);else if(h&&(!p||!f)){let e=a.ensureInfo(this.visibilityGroup);e.visible=!f,e.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=y(this._occlusionQuery),this._opaqueOcclusionQuery=y(this._opaqueOcclusionQuery)),this._occlusionQuery?.start(),this._opaqueOcclusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;let e=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(e.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){let n=this._occlusionQueryUids[e],r=Math.abs(n),i=n<0,a=this._checkOcclusion.get(r);if(!a)continue;let o=this._occlusionQuery.getOcclusion(e)??-1,s=this._opaqueOcclusionQuery?.getOcclusion(e)??-1,c=a.getInfo(this.visibilityGroup);c&&(c.distanceToOccluder=o>0?c.distance-o:0);let l=s===0||s>0&&this._occludedVisibility(c?c.distance-s:0,c?.distance??s,c?.altitude??0,t,i),u=o===0||o>0&&this._occludedVisibility(c?.distanceToOccluder??0,c?.distance??o,c?.altitude??0,t,i),d=l||u;d&&this._setTransparentMode(a,l&&!u),this._active.has(r)?c&&(c.culled=!d,c.visible=d):this._setGraphicVisibility(a,d)}this._occlusionQueryUids.length=0}_collectActiveGraphics(e){let t=this._ensureActiveGraphicsIterator(),n=this.visibilityGroup===16;for(;!e.done;){e.madeProgress();let r=t.next();if(r.done===!0)return this._activeIterator=null,!0;let i=r.value,a=i.getInfo(this.visibilityGroup);if(!a)continue;let o=!n||i.graphics3DGraphic.isVisible();!o||a.culled?(B(a.aabr,!1,!0),this._setGraphicVisibility(i,o&&a.visible)):this._deconflictor.add(a)}return!1}_occludedVisibility(e,t,n,r,i=!0){let a=Math.max(this._minAltitudeDifference,Math.abs(n-r))-this._minAltitudeDifference,o=i?this._baseOccludedVisibility+this._altitudeFactor*a:0;return e===0||t-e<=o}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_initOcclusionQuery(e){if(!e)return;let{camera:t}=this._viewState,n=Math.max(2,2+Math.round(Math.log2(Math.abs(t.relativeElevation))));u(H,this._viewState.camera.eye,2**-n),u(H,d(H,H),2**n),e.init(this._checkOcclusion.size,H)}_ensureOcclusionQuery(){return this._occlusionQuery??=new P({view:this.view}),this._occlusionQuery}_ensureOpaqueOcclusionQuery(){return this._opaqueOcclusionQuery??=new P({view:this.view,category:j.OPAQUE_OCCLUSION_QUERY}),this._opaqueOcclusionQuery}_getNumVisible(e){return this._checkOcclusion.values().reduce((t,n)=>t+ +!!n.getInfo(e)?.visible,0)}_projectHudLayer(e,t,n){let r=e.stageObject,a=r.geometries[0],o=a.material;f(U,r.boundingVolumeWorldSpace.sphere.center),l(H,U,t.viewMatrix);let s=M(a,`normal`).getVec(0,ie),c=M(a,`centerOffset`)?.getVec(0,W)??i,d=N(a,`groundDistance`).get(0);return o.applyShaderOffsets(U,H,s,r.transformation,c,d,t,n.screenSizePerspectiveEvaluators),m(G,H[0],H[1],H[2],1),h(K,G,t.projectionMatrix),u(n.positionNDC,K,1/K[3]),o.applyShaderOffsetsNDC(n.positionNDC,c,d,t,n.positionNDC,q),!n.isOutsideScreen&&(n.distanceWithoutPolygonOffset=t.depthNDCToWorld(q[2]),n.distance=q[2]===n.positionNDC[2]?n.distanceWithoutPolygonOffset:t.depthNDCToWorld(n.positionNDC[2]),m(K,n.positionNDC[0],n.positionNDC[1],n.positionNDC[2],1),h(G,K,t.inverseProjectionMatrix),g(G,G,1/G[3]),p(n.positionView,G[0],G[1],G[2]),f(n.positionWorld,U),!0)}_isCulledBySlice(e,t){return e.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&te(this._viewState.slicePlane,t)}_expandBoundingRect(e,t,n,r,{positionNDC:i,screenSizePerspectiveEvaluators:a}){let o=n.getScreenSize(ue);a.evaluator.applyVec2(o,o),o[0]*=t.pixelRatio,o[1]*=t.pixelRatio;let s=T(r.calculateRelativeScreenBounds(o,a.alignmentEvaluator.apply(t.pixelRatio),oe),v(0,t.fullWidth,.5+.5*i[0]),v(0,t.fullHeight,.5+.5*i[1])),c=this.marginFactor;if(c!==0){let e=c*Math.min(E(s),D(s));s[0]-=e,s[1]-=e,s[2]+=e,s[3]+=e}ee(e,s,e)}_setGraphicVisibility(e,t){let n=e?.graphics3DGraphic;n&&!n.destroyed&&(n.setVisibilityFlag(this.visibilityGroup,8,t),this.visibilityGroup===16&&this.view.labeler.setLabelGraphicVisibility(n,t))}_setTransparentMode(e,t){let n=e?.graphics3DGraphic;if(n&&!n.destroyed)for(let e of n.layers){if(e?.type!==`object3d`&&e?.type!==`buffer`)continue;let{graphics3DSymbolLayer:n}=e;V(n)&&n.updateTransparentMode(e,t)}}};e([n({constructOnly:!0})],$.prototype,`view`,void 0),e([n({type:Boolean,readOnly:!0})],$.prototype,`_readyToRun`,null),e([n({type:Boolean,readOnly:!0})],$.prototype,`updating`,null),e([n({readOnly:!0})],$.prototype,`_updatingHandles`,void 0),$=e([r(`esri.views.3d.layers.graphics.Deconflictor`)],$);function le(e,t){let n=e.graphics3DGraphic;n.destroyed||n.setVisibilityFlag(t,8,!0)}const ue=c();class de{constructor(){this.positionWorld=a(),this.positionView=a(),this.positionNDC=a(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new F}get isOutsideScreen(){let e=this.positionNDC;return e[0]<-1||e[1]<-1||e[2]<-1||e[0]>=1||e[1]>=1||e[2]>=1}}function fe(e,t,n){return f(X.direction,e.positionView),p(X.origin,0,0,0),t.intersectRay(X,ae)?e.distanceWithoutPolygonOffset>n:!1}function pe(e,t){return t===16?e.labelLayers:e.layers}const me=new de;export{$ as Deconflictor,Z as DeconflictorGraphic,Q as DeconflictorViewState};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{ZEROS as i,create as a}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{transpose 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{create as c}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{transformMat4 as l,scale as u,round as d,copy as f,set as p}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{set as m,transformMat4 as h,scale as g}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{create as _}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{lerp as v}from"../../../../core/mathUtils.js";import{destroyMaybe as y}from"../../../../core/maybe.js";import{UpdatingHandles as b}from"../../../../core/support/UpdatingHandles.js";import{getReferenceEllipsoid as x}from"../../../../geometry/ellipsoidUtils.js";import{create as S,empty as C,copy as w,offset as T,width as E,height as D,expand as ee}from"../../../../geometry/support/aaBoundingRect.js";import{extrusionContainsPoint as te,create as ne,copy as re}from"../../../../geometry/support/boundedPlane.js";import{create as O}from"../../../../geometry/support/ray.js";import{Sphere as k}from"../../../../geometry/support/sphere.js";import{Yield as A}from"../../../support/Yield.js";import{InternalRenderCategory as j}from"../../webgl.js";import{getVec3AttributeView as M,getScalarAttributeView as N}from"../../webgl-engine/lib/attributeViewUtils.js";import{GPUPointOcclusionQuery as P}from"../../webgl-engine/lib/GPUPointOcclusionQuery.js";import{SeparateScreenSizePerspectiveEvaluators as F}from"../../webgl-engine/lib/screenSizePerspectiveUtils.js";import{HUDMaterial as I}from"../../webgl-engine/materials/HUDMaterial.js";import L from"../../webgl/RenderCamera.js";import{DeconflictAABR as R}from"./DeconflictAABR.js";import{prepare as z,drawPoly as B}from"./deconflictorDebug.js";import{isSymbolLayerWithTransparencyMode as V}from"./transparencyUtils.js";const H=a(),U=a(),ie=a(),W=a(),G=_(),K=_(),q=a(),J=s(),Y=new k,X=O(),ae=a(),oe=S();class se{constructor(e){this.id=e,this.aabr=S(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.culled=!1,this.visible=!1,this.priority=0}}function ce(e,t){let n=e.distanceToOccluder!==0&&e.distance>e.distanceToOccluder,r=t.distanceToOccluder!==0&&t.distance>t.distanceToOccluder;return n===r?e.priority===t.priority?e.distance===t.distance?e.visible===t.visible?e.id-t.id:+t.visible-e.visible:e.distance-t.distance:t.priority-e.priority:+n-r}class Z{constructor(e,t){this.graphics3DGraphic=e,this.slicePlaneEnabled=t,this._info=null,this._labelInfo=null}ensureInfo(e){let t=this.getInfo(e);return t||(t=new se(this.graphics3DGraphic.graphic.uid),this._setInfo(e,t)),t}getInfo(e){return e===16?this._labelInfo:this._info}removeInfo(e){this._setInfo(e,null)}_setInfo(e,t){e===16?this._labelInfo=t:this._info=t}}class Q{constructor(){this.camera=new L,this.slicePlane=ne(),this.slicePlaneEnabled=!1}copyFrom(e){this.camera.equals(e.camera)||this.camera.copyFrom(e.camera),re(e.slicePlane,this.slicePlane),this.slicePlaneEnabled=e.slicePlaneEnabled}}let $=class extends t{get dirty(){return this._dirty}get state(){return this._state}constructor(e){super(e),this._dirty=!1,this._viewState=new Q,this._state=0,this._checkOcclusion=new Map,this._active=new Map,this._checkOcclusionIterator=null,this._activeIterator=null,this._occlusionQueryUids=[],this._updatingHandles=new b,this._deconflictor=new R((e,t)=>{e.visible=t,this._setGraphicVisibility(this._active.get(e.id),t)},(e,t)=>e.id!==t.id,ce),this._baseOccludedVisibility=10,this._altitudeFactor=2,this._minAltitudeDifference=100}initialize(){this._updatingHandles.add(()=>(this.view?.map?.ground?.opacity??0)>0,()=>this.setDirty()),this._updatingHandles.add(()=>this.view.ready,()=>{this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this.setDirty()})}destroy(){this._occlusionQuery=null,this._opaqueOcclusionQuery=null,this._updatingHandles.destroy(),this._deconflictor.destroy(),this._checkOcclusion.clear(),this._active.clear()}setDirty(){!this._dirty&&(this._active.size>0||this._checkOcclusion.size>0)&&(this._dirty=!0,this.notifyChange(`_readyToRun`))}setPriority(e,t){let n=this._active.get(e.graphic.uid)?.getInfo(this.visibilityGroup);n&&(n.priority=t)}get _readyToRun(){return this._state!==0||this._dirty}get updating(){return this._readyToRun||this._updatingHandles.updating}get updatingProgress(){if(!this.updating)return 1;let e=this._state/5;return this._dirty?e*.5:e}get readyToRun(){return this.view.ready&&this.view.state!=null&&this._readyToRun}get usedMemory(){return this._occlusionQuery?.usedMemory??0+(this._occlusionQueryUids?.length??0)*4}runTask(e){switch(this._state){case 0:this._startUpdate(),e.madeProgress();case 1:if(this._state=1,!this._processCheckOcclusion(e))return;case 2:if(this._state=2,!(this._occlusionQuery?.done??!0)||!(this._opaqueOcclusionQuery?.done??!0))return A;this._readOcclusionQueryResult(),e.madeProgress();case 3:if(this._state=3,!this._collectActiveGraphics(e))return;case 4:if(this._state=4,this._deconflictor.run(e),!this._deconflictor.done)return;default:this._state=0,this.notifyChange(`_readyToRun`)}}setGraphicsActive(e,t){t?e.forEach(e=>this.addToActiveGraphics(e)):e.forEach(e=>this.removeFromActiveGraphics(e))}isSupportedLayer(e){if(e==null||e.type!==`buffer`||!e.hiddenIfDeconflicted)return!1;let t=e.stageObject;return(t?.geometries.length??0)===1&&t?.geometries[0]?.material instanceof I}_startUpdate(){z(this.view),this._dirty=!1,this._viewState.copyFrom(this.viewState);let{fullWidth:e,fullHeight:t}=this._viewState.camera;this._deconflictor.reset(e,t),this._resetIterators(),this._occlusionQueryUids.length=0,this._checkOcclusion.size||(this._occlusionQuery=y(this._occlusionQuery),this._opaqueOcclusionQuery=y(this._opaqueOcclusionQuery))}addToActiveGraphics(e){e.ensureInfo(this.visibilityGroup),this._active.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromActiveGraphics(e){this._active.get(e.graphics3DGraphic.graphic.uid)===e&&(le(e,this.visibilityGroup),e.removeInfo(this.visibilityGroup),this._active.delete(e.graphics3DGraphic.graphic.uid),this.setDirty())}addToCheckOcclusion(e){this._checkOcclusion.set(e.graphics3DGraphic.graphic.uid,e),this.setDirty()}removeFromCheckOcclusion(e){this._checkOcclusion.get(e.graphics3DGraphic.graphic.uid)===e&&this._checkOcclusion.delete(e.graphics3DGraphic.graphic.uid)}_processCheckOcclusion(e){if(this._checkOcclusion.size===0)return!0;let t=this._ensureCheckOcclusionIterator(),n=this._viewState.camera,r=o(J,n.viewInverseTransposeMatrix),a=this.view.map.ground.opacity>0,s=this.view.state.isGlobal&&a&&n.relativeElevation>0?Y:null,c=0;s!=null&&(l(s.center,i,n.viewMatrix),s.radius=x(this.view.spatialReference).radius,c=s.distanceToSilhouette(i));let u=S();for(;;){if(e.done)return!1;e.madeProgress();let i=t.next();if(i.done===!0)break;let a=i.value,o=a.graphics3DGraphic;if(o.destroyed||!o.isVisible(1,8))continue;let d=pe(o,this.visibilityGroup),f=null,p=!0,m=!1;for(let e of d){if(!this.isSupportedLayer(e))continue;if(f=me,!this._projectHudLayer(e,n,f)||this._isCulledBySlice(a,f.positionWorld)||s!=null&&fe(f,s,c)){p=!1;break}C(u);let t=e.stageObject.geometries[0].material;this._expandBoundingRect(u,n,e,t,f),f.altitude=this.view.renderCoordsHelper.getAltitude(f.positionWorld);let i=a.ensureInfo(this.visibilityGroup);if(i.altitude=f.altitude,i.distance=f.distance,i.distanceToOccluder=f.distanceToOccluder,i.culled=!1,w(i.aabr,u),!e.occlusionCheck)break;l(U,f.positionView,r);let d=this._ensureOcclusionQuery(),h=this._ensureOpaqueOcclusionQuery();this._occlusionQueryUids.length===0&&(this._initOcclusionQuery(d),this._initOcclusionQuery(h));let g=d.addPosition(U),_=h.addPosition(U);if(g===this._occlusionQueryUids.length&&_===g){let t=e.adaptiveOcclusion;this._occlusionQueryUids.push(t?-o.graphic.uid:o.graphic.uid),m=!0}break}let h=this._active.has(o.graphic.uid);if(!h&&!m)this._setGraphicVisibility(a,p);else if(h&&(!p||!f)){let e=a.ensureInfo(this.visibilityGroup);e.visible=!f,e.culled=!0}}return this._checkOcclusionIterator=null,this._occlusionQueryUids.length||(this._occlusionQuery=y(this._occlusionQuery),this._opaqueOcclusionQuery=y(this._opaqueOcclusionQuery)),this._occlusionQuery?.start(),this._opaqueOcclusionQuery?.start(),!0}_readOcclusionQueryResult(){if(!this._occlusionQuery||!this._occlusionQueryUids.length)return;let e=this._viewState.camera,t=this.view.renderCoordsHelper.getAltitude(e.eye);for(let e=0;e<this._occlusionQueryUids.length;e++){let n=this._occlusionQueryUids[e],r=Math.abs(n),i=n<0,a=this._checkOcclusion.get(r);if(!a)continue;let o=this._occlusionQuery.getOcclusion(e)??-1,s=this._opaqueOcclusionQuery?.getOcclusion(e)??-1,c=a.getInfo(this.visibilityGroup);c&&(c.distanceToOccluder=o>0?c.distance-o:0);let l=s===0||s>0&&this._occludedVisibility(c?c.distance-s:0,c?.distance??s,c?.altitude??0,t,i),u=o===0||o>0&&this._occludedVisibility(c?.distanceToOccluder??0,c?.distance??o,c?.altitude??0,t,i),d=l||u;d&&this._setTransparentMode(a,l&&!u),this._active.has(r)?c&&(c.culled=!d,c.visible=d):this._setGraphicVisibility(a,d)}this._occlusionQueryUids.length=0}_collectActiveGraphics(e){let t=this._ensureActiveGraphicsIterator(),n=this.visibilityGroup===16;for(;!e.done;){e.madeProgress();let r=t.next();if(r.done===!0)return this._activeIterator=null,!0;let i=r.value,a=i.getInfo(this.visibilityGroup);if(!a)continue;let o=!n||i.graphics3DGraphic.isVisible();!o||a.culled?(B(a.aabr,!1,!0),this._setGraphicVisibility(i,o&&a.visible)):this._deconflictor.add(a)}return!1}_occludedVisibility(e,t,n,r,i=!0){let a=Math.max(this._minAltitudeDifference,Math.abs(n-r))-this._minAltitudeDifference,o=i?this._baseOccludedVisibility+this._altitudeFactor*a:0;return e===0||t-e<=o}_resetIterators(){this._checkOcclusionIterator=null,this._activeIterator=null}_ensureCheckOcclusionIterator(){return this._checkOcclusionIterator??=this._checkOcclusion.values(),this._checkOcclusionIterator}_ensureActiveGraphicsIterator(){return this._activeIterator??=this._active.values(),this._activeIterator}_initOcclusionQuery(e){if(!e)return;let{camera:t}=this._viewState,n=Math.max(2,2+Math.round(Math.log2(Math.abs(t.relativeElevation))));u(H,this._viewState.camera.eye,2**-n),u(H,d(H,H),2**n),e.init(this._checkOcclusion.size,H)}_ensureOcclusionQuery(){return this._occlusionQuery??=new P({view:this.view}),this._occlusionQuery}_ensureOpaqueOcclusionQuery(){return this._opaqueOcclusionQuery??=new P({view:this.view,category:j.OPAQUE_OCCLUSION_QUERY}),this._opaqueOcclusionQuery}_getNumVisible(e){return this._checkOcclusion.values().reduce((t,n)=>t+ +!!n.getInfo(e)?.visible,0)}_projectHudLayer(e,t,n){let r=e.stageObject,a=r.geometries[0],o=a.material;f(U,r.boundingVolumeWorldSpace.sphere.center),l(H,U,t.viewMatrix);let s=M(a,`normal`).getVec(0,ie),c=M(a,`centerOffset`)?.getVec(0,W)??i,d=N(a,`groundDistance`).get(0);return o.applyShaderOffsets(U,H,s,r.transformation,c,d,t,n.screenSizePerspectiveEvaluators),m(G,H[0],H[1],H[2],1),h(K,G,t.projectionMatrix),u(n.positionNDC,K,1/K[3]),o.applyShaderOffsetsNDC(n.positionNDC,c,d,t,n.positionNDC,q),!n.isOutsideScreen&&(n.distanceWithoutPolygonOffset=t.depthNDCToWorld(q[2]),n.distance=q[2]===n.positionNDC[2]?n.distanceWithoutPolygonOffset:t.depthNDCToWorld(n.positionNDC[2]),m(K,n.positionNDC[0],n.positionNDC[1],n.positionNDC[2],1),h(G,K,t.inverseProjectionMatrix),g(G,G,1/G[3]),p(n.positionView,G[0],G[1],G[2]),f(n.positionWorld,U),!0)}_isCulledBySlice(e,t){return e.slicePlaneEnabled&&this._viewState.slicePlaneEnabled&&te(this._viewState.slicePlane,t)}_expandBoundingRect(e,t,n,r,{positionNDC:i,screenSizePerspectiveEvaluators:a}){let o=n.getScreenSize(ue);a.evaluator.applyVec2(o,o),o[0]*=t.pixelRatio,o[1]*=t.pixelRatio;let s=T(r.calculateRelativeScreenBounds(o,a.alignmentEvaluator.apply(t.pixelRatio),oe),v(0,t.fullWidth,.5+.5*i[0]),v(0,t.fullHeight,.5+.5*i[1])),c=this.marginFactor;if(c!==0){let e=c*Math.min(E(s),D(s));s[0]-=e,s[1]-=e,s[2]+=e,s[3]+=e}ee(e,s,e)}_setGraphicVisibility(e,t){let n=e?.graphics3DGraphic;n&&!n.destroyed&&(n.setVisibilityFlag(this.visibilityGroup,8,t),this.visibilityGroup===16&&this.view.labeler.setLabelGraphicVisibility(n,t))}_setTransparentMode(e,t){let n=e?.graphics3DGraphic;if(n&&!n.destroyed)for(let e of n.layers){if(e?.type!==`object3d`&&e?.type!==`buffer`)continue;let{graphics3DSymbolLayer:n}=e;V(n)&&n.updateTransparentMode(e,t)}}};e([n({constructOnly:!0})],$.prototype,`view`,void 0),e([n({type:Boolean,readOnly:!0})],$.prototype,`_readyToRun`,null),e([n({type:Boolean,readOnly:!0})],$.prototype,`updating`,null),e([n({readOnly:!0})],$.prototype,`_updatingHandles`,void 0),$=e([r(`esri.views.3d.layers.graphics.Deconflictor`)],$);function le(e,t){let n=e.graphics3DGraphic;n.destroyed||n.setVisibilityFlag(t,8,!0)}const ue=c();class de{constructor(){this.positionWorld=a(),this.positionView=a(),this.positionNDC=a(),this.altitude=0,this.distance=0,this.distanceToOccluder=0,this.distanceWithoutPolygonOffset=0,this.screenSizePerspectiveEvaluators=new F}get isOutsideScreen(){let e=this.positionNDC;return e[0]<-1||e[1]<-1||e[2]<-1||e[0]>=1||e[1]>=1||e[2]>=1}}function fe(e,t,n){return f(X.direction,e.positionView),p(X.origin,0,0,0),t.intersectRay(X,ae)?e.distanceWithoutPolygonOffset>n:!1}function pe(e,t){return t===16?e.labelLayers:e.layers}const me=new de;export{$ as Deconflictor,Z as DeconflictorGraphic,Q as DeconflictorViewState};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{clone as e}from"../../../../core/lang.js";import{normalFromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,invertOrIdentity as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as o,transformMat4 as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ONES as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as u,ZEROS as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{estimateArrayMemory as f}from"../../../../core/memoryEstimations.js";import{getMetersPerVerticalUnitForSR as p}from"../../../../core/units.js";import{computeTranslationToOriginAndRotation as m}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as h,fromBuffer as g,intersectsClippingArea as _}from"../../../../geometry/support/aaBoundingBox.js";import{t as v}from"../../../../chunks/vec3.js";import{getZeroIndexArray as y}from"../../../../geometry/support/Indices.js";import{SnappingCandidateVertex as b,SnappingCandidateEdge as x}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as S}from"../../../../renderers/support/renderingInfoUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as C}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{debugFlags as w}from"../../support/debugFlags.js";import{SamplePosition as T}from"../../support/ElevationProvider.js";import{loadTessellationUtils as E,preloadedPolygonToRenderInfoElevationAligned as D}from"../../support/renderInfoUtils/polygon.js";import{Attribute as O}from"../../webgl-engine/lib/Attribute.js";import{Geometry as k}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as A}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as j}from"../../webgl-engine/lib/Normals.js";import{Object3D as M}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as N}from"../../webgl-engine/materials/DefaultMaterial.js";import{createMaterial as P}from"../support/edgeUtils.js";import{encodeNaNUInt8 as F}from"../support/symbolColorUtils.js";import{needsElevationUpdates3D as I,SampleElevationInfo as L}from"./elevationAlignmentUtils.js";import{extrudePolygon as R,updatePlateNormals as z,PlateLayoutInformation as B}from"./extrudePolygon.js";import{Object3DEdgeState as V,Graphics3DObject3DGraphicLayer as H}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as U}from"./Graphics3DSymbolLayer.js";import{computeCentroid as W}from"./graphicUtils.js";import{addOlidAttribute as G}from"./olidUtils.js";import{geometryAsPolygon as ee}from"./polygonUtils.js";const K=[`polygon`,`extent`];class q extends U{constructor(e,t,n,r){super(e,t,n,r,C(t)),this.ensureDrapedStatus(!1)}async doLoad(){let e=this.symbolLayer,t=e?.material,n=this.symbolLayer.material?.color?.a,r=this._hasDrivenColorOrOpacity,i=this.needsDrivenTransparentPass||r&&n!=null&&n<1,a=t?.emissive,o=(a?.source===`color`?a?.strength:void 0)??0,s=!r&&(n==null||n===0),l=r?u:this._materialColor?.toUnitRGBA()??d,f={usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0,useIndexing:!0,ambient:c,diffuse:c,externalColor:l,opacity:+!s,layerOpacity:this._getLayerOpacity(),drivenOpacity:i,hasSymbolColors:r,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:e.castShadows,emissiveStrengthFromSymbol:o,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1,pretransformedNormals:!0},p=new N(f,this._context.spherical),m=new N({...f,cullFace:2},this._context.spherical);this._materials[0]=p,this._materials[1]=m,this._updateTransparentDepedentMaterialParameters(),await E()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,K,this.symbolLayer.type))return null;let n=this._getDrivenUInt8ColorWithNaNSupport(e.renderingInfo,this._materialColor,!1);F(n,n);let r=this.createElevationContextForGraphic(t);return this._createAs3DShape(t,e.renderingInfo,n,r,t.uid)}layerOpacityChanged(e,t){let n=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:n}),this._materials[1]?.setParameters({layerOpacity:n}),this._updateTransparentDepedentMaterialParameters(),e?.forEach(e=>t(e)?.layerOpacityChanged(n,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}slicePlaneEnabledChanged(e,t){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e?.forEach(e=>{t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicallyBasedRenderingChanged(){let e={usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(e),this._materials[1]?.setParameters(e),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?S(e.size.output,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}_containsRenderableGeometry(e){return`polygonIndexCount`in e&&`outlineIndexCount`in e?e.polygonIndexCount>0||e.outlineIndexCount>0:super._containsRenderableGeometry(e)}applyRendererDiff(e,t){return+!this._drivenPropertiesChanged(t)}async queryForSnapping(t,n,r,i){let a=this._getExtrusionSize(r)*this._context.renderCoordsHelper.unitInMeters/p(n),{objectId:o,target:s}=t,c=e(s);switch(c.z=(c.z??0)+a,t.type){case`edge`:{let{start:n,end:r}=t,i=e(n),s=e(r);return i.z=(i.z??0)+a,s.z=(s.z??0)+a,[new x(o,c,1/0,i,s)]}case`vertex`:return[new b(o,c,1/0),new x(o,s,1/0,s,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,i,o,s,c){let u=ee(e.geometry);if(u==null)return null;if(u.rings.length===0||!u.rings.some(e=>e.length>0))return this._logGeometryValidationWarnings(u.rings,`rings`,`ExtrudeSymbol3DLayer`),null;let d=D(u,this._context.elevationProvider,this._context.renderCoordsHelper,s,{outlineOutput:`tessellated-indices`,owner:this._context.layer});if(d==null)return;this._logGeometryCreationWarnings(d,u.rings,`rings`,`ExtrudeSymbol3DLayer`);let p=W(u);if(p==null)return null;let y=[],b=[],x=h(),S=l(),C=this._context.renderCoordsHelper.
|
|
2
|
+
import{clone as e}from"../../../../core/lang.js";import{normalFromMat4 as t}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as n}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{invert as r,invertOrIdentity as i}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as a}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{set as o,transformMat4 as s}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{ONES as c,create as l}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as u,ZEROS as d}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{estimateArrayMemory as f}from"../../../../core/memoryEstimations.js";import{getMetersPerVerticalUnitForSR as p}from"../../../../core/units.js";import{computeTranslationToOriginAndRotation as m}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{create as h,fromBuffer as g,intersectsClippingArea as _}from"../../../../geometry/support/aaBoundingBox.js";import{t as v}from"../../../../chunks/vec3.js";import{getZeroIndexArray as y}from"../../../../geometry/support/Indices.js";import{SnappingCandidateVertex as b,SnappingCandidateEdge as x}from"../../../../layers/graphics/data/SnappingCandidate.js";import{getDriverAxisSizeValue as S}from"../../../../renderers/support/renderingInfoUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as C}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{debugFlags as w}from"../../support/debugFlags.js";import{SamplePosition as T}from"../../support/ElevationProvider.js";import{loadTessellationUtils as E,preloadedPolygonToRenderInfoElevationAligned as D}from"../../support/renderInfoUtils/polygon.js";import{Attribute as O}from"../../webgl-engine/lib/Attribute.js";import{Geometry as k}from"../../webgl-engine/lib/Geometry.js";import{isGeometryWithMapPositions as A}from"../../webgl-engine/lib/GeometryWithMapPositions.js";import{compressNormals as j}from"../../webgl-engine/lib/Normals.js";import{Object3D as M}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as N}from"../../webgl-engine/materials/DefaultMaterial.js";import{createMaterial as P}from"../support/edgeUtils.js";import{encodeNaNUInt8 as F}from"../support/symbolColorUtils.js";import{needsElevationUpdates3D as I,SampleElevationInfo as L}from"./elevationAlignmentUtils.js";import{extrudePolygon as R,updatePlateNormals as z,PlateLayoutInformation as B}from"./extrudePolygon.js";import{Object3DEdgeState as V,Graphics3DObject3DGraphicLayer as H}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as U}from"./Graphics3DSymbolLayer.js";import{computeCentroid as W}from"./graphicUtils.js";import{addOlidAttribute as G}from"./olidUtils.js";import{geometryAsPolygon as ee}from"./polygonUtils.js";const K=[`polygon`,`extent`];class q extends U{constructor(e,t,n,r){super(e,t,n,r,C(t)),this.ensureDrapedStatus(!1)}async doLoad(){let e=this.symbolLayer,t=e?.material,n=this.symbolLayer.material?.color?.a,r=this._hasDrivenColorOrOpacity,i=this.needsDrivenTransparentPass||r&&n!=null&&n<1,a=t?.emissive,o=(a?.source===`color`?a?.strength:void 0)??0,s=!r&&(n==null||n===0),l=r?u:this._materialColor?.toUnitRGBA()??d,f={usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0,useIndexing:!0,ambient:c,diffuse:c,externalColor:l,opacity:+!s,layerOpacity:this._getLayerOpacity(),drivenOpacity:i,hasSymbolColors:r,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:e.castShadows,emissiveStrengthFromSymbol:o,emissiveSource:1,offsetTransparentBackfaces:!0,normalType:1,pretransformedNormals:!0},p=new N(f,this._context.spherical),m=new N({...f,cullFace:2},this._context.spherical);this._materials[0]=p,this._materials[1]=m,this._updateTransparentDepedentMaterialParameters(),await E()}destroy(){super.destroy(),this._materials.length=0}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,K,this.symbolLayer.type))return null;let n=this._getDrivenUInt8ColorWithNaNSupport(e.renderingInfo,this._materialColor,!1);F(n,n);let r=this.createElevationContextForGraphic(t);return this._createAs3DShape(t,e.renderingInfo,n,r,t.uid)}layerOpacityChanged(e,t){let n=this._getLayerOpacity();this._materials[0]?.setParameters({layerOpacity:n}),this._materials[1]?.setParameters({layerOpacity:n}),this._updateTransparentDepedentMaterialParameters(),e?.forEach(e=>t(e)?.layerOpacityChanged(n,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}slicePlaneEnabledChanged(e,t){return this._materials[0]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._materials[1]?.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),e?.forEach(e=>{t(e)?.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)}),!0}physicallyBasedRenderingChanged(){let e={usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0};return this._materials[0]?.setParameters(e),this._materials[1]?.setParameters(e),!0}_getExtrusionSize(e){let t;return t=e.size&&this._drivenProperties.size?S(e.size.output,2)??0:this._getSymbolSize(),t/=this._context.renderCoordsHelper.unitInMeters,t}_containsRenderableGeometry(e){return`polygonIndexCount`in e&&`outlineIndexCount`in e?e.polygonIndexCount>0||e.outlineIndexCount>0:super._containsRenderableGeometry(e)}applyRendererDiff(e,t){return+!this._drivenPropertiesChanged(t)}async queryForSnapping(t,n,r,i){let a=this._getExtrusionSize(r)*this._context.renderCoordsHelper.unitInMeters/p(n),{objectId:o,target:s}=t,c=e(s);switch(c.z=(c.z??0)+a,t.type){case`edge`:{let{start:n,end:r}=t,i=e(n),s=e(r);return i.z=(i.z??0)+a,s.z=(s.z??0)+a,[new x(o,c,1/0,i,s)]}case`vertex`:return[new b(o,c,1/0),new x(o,s,1/0,s,c)];default:return[]}}_getSymbolSize(){return this.symbolLayer.size??1}_createAs3DShape(e,i,o,s,c){let u=ee(e.geometry);if(u==null)return null;if(u.rings.length===0||!u.rings.some(e=>e.length>0))return this._logGeometryValidationWarnings(u.rings,`rings`,`ExtrudeSymbol3DLayer`),null;let d=D(u,this._context.elevationProvider,this._context.renderCoordsHelper,s,{outlineOutput:`tessellated-indices`,owner:this._context.layer});if(d==null)return;this._logGeometryCreationWarnings(d,u.rings,`rings`,`ExtrudeSymbol3DLayer`);let p=W(u);if(p==null)return null;let y=[],b=[],x=h(),S=l(),C=this._context.renderCoordsHelper.isGlobal;C||this._context.renderCoordsHelper.worldUpAtPosition(null,S);let w=a();m(u.spatialReference,[p.x,p.y,0],w,this._context.renderCoordsHelper.spatialReference);let T=a();r(T,w);let E=n();t(E,T);let O=new Map,k=this._materials[0];if(this._context.clippingExtent&&(g(d.mapPositions,x),!_(x,this._context.clippingExtent))||d.polygonIndexCount===0&&d.outlineIndexCount===0)return;let A=this._getExtrusionSize(i),N=R(d,{height:A,worldUp:S,spherical:C,requireElevation:!0,requireNormals:!0,requireSizes:!0});if(N==null)return;v(N.vertices,N.vertices,T);let F=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:c,layerViewUid:this._context.layerViewUid}),L=new ne(N.vertices,N.elevation,j(N.normals),N.sizes),U=J(k,N.indices,N.indices.length-N.bottomIndices.length,L,o,F),G=d.vertexCount,K=d.outlineSegmentCount*2,q=d.polygonIndexCount/3,Y=new B(G,G,0,K,q);if(z(U,Y,w),O.set(U,Y),y.push(U),N.bottomIndices.length>0&&y.push(J(this._materials[1],N.bottomIndices,0,L,o,F)),b.push(L.heights),y.length===0)return null;let X=new M({geometries:y,layerViewUid:this._context.layerViewUid,graphicUid:c,isElevationSource:!0});X.transformation=w;let Z=P(this.symbolLayer,{opacity:this._getLayerOpacity()}),Q=Z?new V(this._materials[0],Z,this._context.slicePlaneEnabled):null,$=new H(this,X,null,(e,t,n,r,i)=>te(e,t,n,r,i,b,O),s,Q,b.reduce((e,t)=>e+f(t,8),0));return $.alignedSampledElevation=d.sampledElevation,$.needsElevationUpdates=I(s.mode),$}get _materialColor(){return this.symbolLayer.material?.color}_updateTransparentDepedentMaterialParameters(){let e=this._materials[0];e?.setParameters({cullFace:e.transparent?0:2})}}function J(e,t,n,r,i,a){let{attributeIndices:o,drawIndices:s}=Y(t),c=[[`position`,new O(r.positions,o,3,!0)],[`normalCompressed`,new O(r.compressedNormals,o,2,!0)]],l=null;return e.parameters.hasSymbolColors&&(l=y(o.length),c.push([`symbolColor`,new O(i,l,4,!0)])),a!=null&&(l??=y(o.length),G(c,a,l)),new k(e,c,r.elevation,n,null,s)}function Y(e){if(e.length===0)return{attributeIndices:[],drawIndices:[]};let t=new Map,n=Array(e.length).fill(0);for(let r=0;r<e.length;++r){let i=e[r],a=t.get(i);a??(a=t.size,t.set(i,a)),n[r]=a}let r=Array(t.size).fill(0);for(let[e,n]of t)r[n]=e;return{attributeIndices:r,drawIndices:n}}const X=l();function te(e,t,n,r,c,l,u){let d=e.stageObject,f=d.geometries,p=f.length,m=t.mode!==`absolute-height`,h=0,g=d.transformation,_=i(a(),g);for(let e=0,t=0;e<p;++e){let i=f[e],a=u.get(i);if(!a||!A(i))continue;let p=i.getMutableAttribute(`position`).data,v=l[t++],y=new T(i.mapPositions),b=p.length/3,x=!1,S=0;{let e=0;for(let t=0;t<b;t++){X[0]=p[e],X[1]=p[e+1],X[2]=p[e+2],r(y,Q),m&&(S+=Q.sampledElevation),w.ENABLE_OPTIMIZATIONS?(o(Z,p[e],p[e+1],p[e+2]),s(Z,Z,g),c.setAltitude(Z,Q.z+v[e/3]),s(Z,Z,_)):(o(Z,y.array[y.offset],y.array[y.offset+1],Q.z+v[e/3]),n!=null&&c.toRenderCoords(Z,n,Z),s(Z,Z,_)),p[e]=Z[0],p[e+1]=Z[1],p[e+2]=Z[2];let t=$/c.unitInMeters;(Math.abs(X[0]-p[e])>=t||Math.abs(X[1]-p[e+1])>=t||Math.abs(X[2]-p[e+2])>=t)&&(x=!0),y.offset+=3,e+=3}}if(x){z(i,a,g),d.geometryVertexAttributeUpdated(f[e],`normalCompressed`),i.invalidateBoundingInfo(),d.geometryVertexAttributeUpdated(f[e],`position`);let t=f[e+1],n=!u.has(t);t&&n&&(t.invalidateBoundingInfo(),d.geometryVertexAttributeUpdated(t,`position`))}h+=S/b}return h/p}const Z=l(),Q=new L,$=.01;class ne{constructor(e,t,n,r){this.positions=e,this.elevation=t,this.compressedNormals=n,this.heights=r}}export{q as Graphics3DExtrudeSymbolLayer,Y as remapIndicesToAttributeSubset};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{watch as i,sync as a,initial as o}from"../../../../core/reactiveUtils.js";import{getReferenceEllipsoid as s}from"../../../../geometry/ellipsoidUtils.js";import{TaskPriority as c}from"../../../support/Scheduler.js";import{Yield as l}from"../../../support/Yield.js";import{FrustumExtentIntersection as u}from"../../support/FrustumExtentIntersection.js";let d=class extends t{constructor(e){super(e),this.suspended=!1,this._extent=null,this._extentIntersectionDirty=!0,this._isVisibleBelowSurfaceInternal=!1,this.graphicsCoreOwner=null,this.updating=!0}initialize(){let{graphicsCoreOwner:e}=this;this._extentIntersection=new u({renderCoordsHelper:e.view.renderCoordsHelper});let{view:t}=e,{groundView:n}=t,{scheduler:r}=t.resourceController;this.addHandles([t.on(`resize`,()=>this._viewChange()),i(()=>t.state.camera,()=>this._viewChange(),a),r.registerTask(c.FRUSTUM_VISIBILITY,this),i(()=>n.visibleElevationRange,()=>this._elevationRangeChange())]),t.
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../../core/Accessor.js";import{property as n,subclass as r}from"../../../../core/accessorSupport/decorators.js";import{watch as i,sync as a,initial as o}from"../../../../core/reactiveUtils.js";import{getReferenceEllipsoid as s}from"../../../../geometry/ellipsoidUtils.js";import{TaskPriority as c}from"../../../support/Scheduler.js";import{Yield as l}from"../../../support/Yield.js";import{FrustumExtentIntersection as u}from"../../support/FrustumExtentIntersection.js";let d=class extends t{constructor(e){super(e),this.suspended=!1,this._extent=null,this._extentIntersectionDirty=!0,this._isVisibleBelowSurfaceInternal=!1,this.graphicsCoreOwner=null,this.updating=!0}initialize(){let{graphicsCoreOwner:e}=this;this._extentIntersection=new u({renderCoordsHelper:e.view.renderCoordsHelper});let{view:t}=e,{groundView:n}=t,{scheduler:r}=t.resourceController;this.addHandles([t.on(`resize`,()=>this._viewChange()),i(()=>t.state.camera,()=>this._viewChange(),a),r.registerTask(c.FRUSTUM_VISIBILITY,this),i(()=>n.visibleElevationRange,()=>this._elevationRangeChange())]),t.state.isGlobal?this.addHandles([i(()=>[n.baseOpacity,n.wireframe,t.map?.ground?.navigationConstraint?.type],()=>this._updateIsVisibleBelowSurface(),o)]):this._isVisibleBelowSurface=!0}destroy(){this._set(`graphicsCoreOwner`,null),this._extent=null,this._extentIntersection=null}_setDirty(){this.updating||this._set(`updating`,!0)}setExtent(e){this._extent=e,this._extentIntersectionDirty=!0,this._setDirty()}_viewChange(){this._setDirty()}_elevationRangeChange(){this._setDirty(),this._extentIntersectionDirty=!0}set _isVisibleBelowSurface(e){this._isVisibleBelowSurfaceInternal=e,this._setDirty(),this._extentIntersectionDirty=!0}_updateIsVisibleBelowSurface(){let e=this.graphicsCoreOwner.view,t=e.state.isLocal,n=e.map.ground?.navigationConstraint?.type===`none`;this._isVisibleBelowSurface=t||!e.groundView.opaque||n}_updateExtentIntersection(){if(!this._extentIntersectionDirty)return;this._extentIntersectionDirty=!1;let e=this.graphicsCoreOwner.view,t;if(this._isVisibleBelowSurfaceInternal)t=-.3*s(e.spatialReference).radius;else{let{minElevation:n,maxElevation:r}=e.groundView.visibleElevationRange;t=n-Math.max(1,(r-n)*(1.2-1))}this._extentIntersection.update(this._extent,e.spatialReference,t)}get readyToRun(){return this.updating}runTask(e){if(this._set(`updating`,!1),!this._extent)return this._set(`suspended`,!1),l;this._updateExtentIntersection();let{frustum:t}=this.graphicsCoreOwner.view,n=s(this.graphicsCoreOwner.view.spatialReference).radius;this._set(`suspended`,!this._extentIntersection.isVisibleInFrustum(t,n)),e.madeProgress()}};e([n({readOnly:!0})],d.prototype,`suspended`,void 0),e([n({constructOnly:!0})],d.prototype,`graphicsCoreOwner`,void 0),e([n({readOnly:!0})],d.prototype,`updating`,void 0),d=e([r(`esri.views.3d.layers.graphics.Graphics3DFrustumVisibility`)],d);export{d as Graphics3DFrustumVisibility};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{result as e,createTask as t}from"../../../../core/asyncUtils.js";import n from"../../../../core/Error.js";import{clone as r}from"../../../../core/lang.js";import{fromValues as i,fromArray as a,create as o,ONES as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as c,create as l,ZEROS as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d,ZEROS as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{abortMaybe as p,releaseMaybe as m}from"../../../../core/maybe.js";import{throwIfAbortError as h,throwIfAborted as g}from"../../../../core/promiseUtils.js";import{pt2px as _,onePixelInPoints as ee}from"../../../../core/screenUtils.js";import{numericHash as v}from"../../../../core/string.js";import{dataComponents as y}from"../../../../core/urlUtils.js";import{projectPointToVector as te}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as ne}from"../../../../geometry/support/aaBoundingBox.js";import b from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as x}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as S,CIMSymbolInflatedSizeHelper as re}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as w}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultIconPrimitive as ie}from"../../../../symbols/support/primitives.js";import ae from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as oe}from"../../../../symbols/support/utils.js";import{createTexture as se,requiresHalfTexelOffset as ce,defaultBoundingBox as le,defaultSymbolSizeRatio as T,defaultTexSize as E}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as D}from"../../terrain/DrapedZ.js";import{VerticalOffsetParameters as O}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointBufferGeometry as k}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as A}from"../../webgl-engine/lib/ManagedTexture.js";import{HUDMaterial as j}from"../../webgl-engine/materials/HUDMaterial.js";import{initFastSymbolUpdatesState as M,updateFastSymbolUpdatesState as N,evaluateModelTransformScale as P,ConvertOptions as F}from"../support/FastSymbolUpdates.js";import{transparentUnit as I}from"./constants.js";import{perBufferPointElevationAligner as L}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as R,needsElevationUpdates2D as z}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as B}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as V}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as ue}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as H}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as U}from"./placementUtils.js";import{placePointOnGeometry as W,updateBufferStageObjectGeometry as de,extendPointGraphicElevationContext as G,createBufferStageObject as fe}from"./pointUtils.js";import{hasTransparencyModeSymbol as pe}from"./transparencyUtils.js";var K;const me=c(0,0,1),he=[E*T,E*T];class q extends ue{static{K=pe}static{this.PRIMITIVE_SIZE=he}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,_e(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=[1,1],this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0},this[K]=!0}async doLoad(e){this._validateOrThrow();let t=this._prepareMaterialParameters(),n=this._getPrimitive();if(n!=null)this._prepareResourcesPrimitive(t,n);else{let n=oe(this.symbolLayer),r=Y(n);r==null?await this._prepareResourcesHref(t,n,e):await this._prepareResourcesCIM(t,JSON.parse(r),e)}}_validateOrThrow(){if(this._drivenProperties.size)return;let e=H(this._getIconSize());if(e)throw new n(`graphics3diconsymbollayer:invalid-size`,e)}_getIconSize(){let e=this.symbolLayer,t=Math.round(e.size==null?16:_(e.size));return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){let n=this._overrideHelperClass,i=this._cimData;if(n&&i&&i.symbol||this.logger.error(`Can't create texture, CIM data is undefined`),i.primitiveOverrides){i=r(i);let a=i.primitiveOverrides;n.evaluateOverrides(a,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),n.applyOverrides(i.symbol,a)}let a=v(JSON.stringify(i)),o=this._cimSymbolTextures.get(a);if(o)return o;let s=this._context.sharedResources.cimSymbolRasterizer,c=this._context.renderer&&this._context.renderer.type===`dictionary`?this._context.renderer.fieldMap:null;c&&n.applyDictionaryTextOverrides(i.symbol,e,c,null);let l=this._cimScaleFactorOrFunction==null?1:C(this._cimScaleFactorOrFunction,e);l!==1&&i.symbol&&w(i.symbol,l,!0);let u=S.getEnvelope(i,null,s.resourceManager);if(u?.width&&u.height){let e=u.x+u.width/2,t=u.y+u.height/2,n=i.symbol?.type===`CIMPointSymbol`?re.getPointSymbolHaloPadding(i.symbol,s.resourceManager):0,r=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,a=n>0?Math.ceil((_(n)+1)*r):0,c=s.rasterize({type:`cim`,data:i},u.width,u.height,e,t,1,`esriGeometryPoint`,a,null,r),l=new ae({x:-u.x/u.width-.5,y:(u.height+u.y)/u.height-.5});this._cimMaterialParametersInfo.anchorPosition=X(`relative`,l),o=new A(c,{width:c?.width??1,height:c?.height??1,reloadable:!0})}else o=new A(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(a,o),this._context.stage.addTexture(o),o}_prepareMaterialParameters(){let{symbolLayer:e,symbol:t,_context:n,_drivenProperties:r,view:i}=this,a=this.symbolLayer.occludedVisibility?.mode??`hidden`;return{anchorPosition:X(e.anchor,e.anchorPosition),rotation:e.angle,hasRotation:e.angle!==0||r.rotation,hasVertexRotation:r.rotation,occludedFragmentOpacity:a===`hidden`?void 0:i.state.ensureOccludedFragmentOpacity(!1,a),hasSlicePlane:n.slicePlaneEnabled,verticalOffset:ge(t)?new O(t.verticalOffset):void 0,screenSizePerspective:n.screenSizePerspectiveEnabled?i.screenSizePerspective.parameters:void 0}}_prepareResourcesPrimitive(e,t){let n=this._getOutlineSize();if(J(t)&&n===0)throw Error(`Nothing to render`);if(this._outlineSize=n,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,this._context.sharedResources.textures!=null){let n=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>se(t));this._textureHandle=n,e.textureId=n.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=ce(t),e.distanceFieldBoundingBox=le;let r=this._getIconSize();this._size=[r,r],this._symbolTextureRatio=1/T,e.size=i(r*this._symbolTextureRatio,r*this._symbolTextureRatio),this._createMaterials(e)}async _prepareResourcesHref(t,r,i){this._outlineSize=this._getOutlineSize(),t.color=this._getFillColor(),t.outlineColor=this._getOutlineColor(),t.outlineSize=this._outlineSize,t.textureIsSignedDistanceField=!1;let o=this._getIconSize(),s=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(this._context.sharedResources.textures!=null){let c=await e(this._context.sharedResources.textures.fromUrl(r,s,{signal:i}));if(c.ok===!1){h(c.error);let e=`Failed to load (Request for icon resource failed: ${r})`;throw new n(`graphics3diconsymbollayer:request-failed`,e)}this._textureHandle=c.value;let l=c.value.managedTexture;this._size=Z(l,o),t.size=a(this._size),t.textureId=l.id}this._createMaterials(t)}async _prepareResourcesCIM(e,t,n){let{OverrideHelper:r}=await import(`../../../../symbols/cim/OverrideHelper.js`);if(this._overrideHelperClass=r,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){let e=(await import(`../../../../symbols/cim/CIMSymbolRasterizer.js`)).CIMSymbolRasterizer;g(n),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}let i=this._context.sharedResources.cimSymbolRasterizer,a=t,o=a?.symbol,s=[S.normalizeSymbolAndFetchResources(o,i.resourceManager,n)],c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],l=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:l,fields:c,geometryType:`esriGeometryPoint`},a?.primitiveOverrides&&s.push(r.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),s.length>0&&(await Promise.all(s),g(n)),this._context.renderer&&this._context.renderer.type===`dictionary`&&this._context.renderer.scaleExpression){let e=this._context.renderer;if(e.scaleExpression){let t=e.scaleExpression,n=await x(t,this._context.layer.spatialReference),{default:r}=await import(`../../../2d/arcade/callExpressionWithFeature.js`),i=new b(c);this._cimScaleFactorOrFunction=(e,t,a)=>{let o=r(n,e,{$view:a},`esriGeometryPoint`,i,t);return o===null?1:o}}}g(n),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return Q(this.symbolLayer)}_getOutlineSize(){let e=0,t=this.symbolLayer;return t.outline?.size==null?(e=J(this._getPrimitive())?1.5:0,Math.max(e,0)):Math.max(_(t.outline.size),0)}_getOutlineColor(){let e=this._getLayerOpacity(),t=this.symbolLayer?.outline?.color;if(t!=null){let n=t.toUnitRGB(),r=t.a*e;return[n[0],n[1],n[2],r]}return[0,0,0,0]}_getFillColor(){if(J(this._getPrimitive()))return I;let e=this._getPrimitive()==null,t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){let e=this._materialColor;return e==null?this._getPrimitive()==null?d:f:e.toUnitRGBA()}_getFallbackSize(){let e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(t==null?16:Math.round(_(t)))/e}_createCimMaterials(e){let t=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;if(t)return t;let n=$([],e,this._context.focusAreaStyle,this._context.spherical);return this._cimSymbolMaterials.set(e.textureId??0,n),n}_createMaterials(e){this._fastUpdates=M(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),e.hasVertexColor=this._drivenProperties.color&&!this._fastUpdates?.visualVariables.color||this._drivenProperties.opacity&&!this._fastUpdates?.visualVariables.opacity,e.hasVertexSize=this._drivenProperties.size&&!this._fastUpdates?.visualVariables.size,$(this._materials,e,this._context.focusAreaStyle,this._context.spherical)}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=p(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=m(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(e==null)return this._getFallbackSize();let[n,r,i]=e.output;return n===`symbol-value`?1:typeof n==`number`&&isFinite(n)?_(n)/t:typeof i==`number`&&isFinite(i)?_(i)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading?.output??0:null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let n=W(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let r=this._materials,a=this.view.focusAreasView?.containsGeometry(n)??!0;if(this._cimData){if(!this._cimData.symbol)return null;let n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,a=this._generateTextureCIM(t,e),o=i(a.parameters.width/n,a.parameters.height/n);r=this._createCimMaterials({textureId:a.id,size:o,...this._cimMaterialParametersInfo})}let o=r[a?0:2];if(n==null)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;let s=this._getPrimitive()==null,c=e.renderingInfo,l=this._hasDrivenColorOrOpacity?this._getDrivenUInt8Color(c,this._materialColor,s):null,u=this._getDrivenRotation(c),d=null;if(!this._fastUpdates?.visualVariables.size){let e=this._size,t=e[0]>e[1]?e[0]:e[1];d=this._getScaleFactor(c,t)}let f=d==null?null:i(d,d),p=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(p.mode===`on-the-ground`)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(c,n,o,l,u,f,t.uid):this._createAs3DShape(c,n,o,l,u,f,p,t.uid)}terrainTransparencyChanged(){return this.draped}layerOpacityChanged(){let e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(n=>{n.setParameters({color:e}),n.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){let e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateTransparentMode(e,t){let n=e.stageObject.geometries[0]?.material,r=this._cimData?n?.parameters.textureId:null,i=r?this._cimSymbolMaterials.get(r):this._materials,a=(i?.indexOf(n)??-1)<2,o=i?.[t?a?1:3:a?0:2];o&&o!==n&&e.updateMaterial(o)}updateGeometry(e,t){let n=e.geometry;if(t.type!==`buffer`||this.draped||!n||!this._validateGeometry(n))return!1;let{elevationContext:r,stageObject:i}=t;if(r.mode!==this.getGeometryElevationMode(n))return!1;let a=W(n);if(!a)return!1;r.updateFeatureExpressionFeature(e,this._context.layer);let o=de(i,this._context,a,r);return o!=null&&(t.alignedSampledElevation=o,G(t,a,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=R(q.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=z(r)||r===`absolute-height`;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicallyBasedRenderingChanged(){return!0}get pixelRatioChanged(){return this._getPrimitive()!=null}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:if(N(this._fastUpdates,t,this._fastVisualVariableConvertOptions())){let e=this._fastUpdates;this._materials.forEach(t=>t?.setParameters(e.materialParameters))}else return 0;break;default:return 0}return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(r,i){if(!i.resource||i.resource.type!==`partial`)return;let a=i.resource.diff;if(a?.href?.type!==`complete`)return;let o=a.href.newValue,{textures:s}=this._context.sharedResources;if(o==null||s==null||Y(o)!=null)return;let c=this._getIconSize(),l=c*this._context.graphicsCoreOwner.view.state.pixelRatio;r.symbolLayerStatePatches.push(()=>{this._patchTask=p(this._patchTask),this._patchTask=t(t=>this._context.schedule(async(t,r)=>{let i=await e(s.fromUrl(o,l,{signal:r}));g(r);let a=!i.ok;if(a&&h(i.error),this._textureHandle=m(this._textureHandle),this._patchTask=null,a){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});let e=`Failed to load (Request for icon resource failed: ${o})`;this.logger.error(new n(`graphics3diconsymbollayer:request-failed`,e));return}this._textureHandle=i.value;let u=i.value.managedTexture;this._size=Z(u,c),this._forEachMaterial(e=>{e.setParameters({textureId:u.id}),e.visible=!0})},t))}),delete a.href}_preparePatchRotation(e,t){if(!t.angle||t.angle.type!==`complete`)return;let n=t.angle.newValue??0,r=n!==0||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:n,hasRotation:r}))}),delete t.angle}_defaultElevationInfoNoZ(){return ve}_createAs3DShape(e,t,n,r,i,a,o,s){let c=this.getFastUpdateAttrValues(e),l=this._context.layerViewUid,d=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerViewUid:l}),f=fe(this._context,t,n,{color:r,rotation:i,size:a,centerOffset:u,featureAttribute:c,olidColor:d},o,s);if(f==null)return null;let p=new B(this,f.object,null,L,o);return p.setOccludedVisibilityMode(this.symbolLayer.occludedVisibility?.mode),p.hiddenIfDeconflicted=!0,p.alignedSampledElevation=f.sampledElevation,p.needsElevationUpdates=z(o.mode)||o.mode===`absolute-height`,p.getScreenSize=this._createScreenSizeGetter(a,c),p.calculateRelativeScreenBounds=e=>n.calculateRelativeScreenBounds(p.getScreenSize(),1,e),G(p,t,this._context.elevationProvider),p}_createAsOverlay(e,t,n,r,i,a,o){n.renderPriority=this._renderPriority;let s=l();te(t,s,this._context.overlaySR),s[2]=D;let c=this._context.clippingExtent;if(c!=null&&!ne(c,s))return null;let u=this.getFastUpdateAttrValues(e),d=this._context.layerViewUid,f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:d}),p=this._context.drapeSourceRenderer.rendererContext.localOriginFactory.getOrigin(s),m=k(n,p,{normal:me,position:s,groundDistance:0,color:r,rotation:i,size:a,featureAttribute:u,olidColor:f});m.layerViewUid=d,m.graphicUid=o;let h=new V(this,[m],null,this._context.drapeSourceRenderer);return h.getScreenSize=this._createScreenSizeGetter(a,u),h.calculateRelativeScreenBounds=e=>n.calculateRelativeScreenBounds(h.getScreenSize(),1,e),h}_createScreenSizeGetter(e,t){e??=s;let n=this._outlineSize+2;if(this._fastUpdates&&t){let r=e[0]*this._size[0],i=e[1]*this._size[1];return(e=o())=>{let[a,s]=P(ye,this._fastUpdates.materialParameters,t);return e[0]=a*r+n,e[1]=s*i+n,e}}let r=e[0]*this._size[0]+n,i=e[1]*this._size[1]+n;return(e=o())=>(e[0]=r,e[1]=i,e)}_fastVisualVariableConvertOptions(){let e=Math.max(this._size[0],this._size[1]),t=c(e,e,e),n=ee,r=e*n,i=c(r,r,r),a=this._getFallbackSize();return new F({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:i,unitInMeters:n,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:c(a,a,a)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(t=>t.forEach(e))}test(){return{...super.test(),material:this._materials[0]}}}function ge(e){return e&&e.type===`point-3d`&&e.hasVisibleVerticalOffset()}function J(e){return e==null?!1:e===`cross`||e===`x`}function Y(e){let t=y(e);return t?.mediaType===`application/json`?t.data:void 0}function X(e,t){return e===`relative`?i((t.x||0)+.5,-(t.y||0)+.5):e in U?U[e]:U.center}function Z({parameters:e},t){let n=(e.width??1)/(e.height??1);return n>1?[t,Math.round(t/n)]:[Math.round(t*n),t]}function Q(e){return e.resource?.href?null:e.resource?.primitive??ie}function _e(e){return(e.material?.color?.a??1)===1&&Q(e)!=null}const ve={mode:`relative-to-ground`,offset:0},ye=l();function $(e,t,n,r){let i={...t,focusAreaStyle:n};return e[0]=new j(t,r),e[1]=new j(t,r,!0),e[2]=new j(i,r),e[3]=new j(i,r,!0),e}export{q as Graphics3DIconSymbolLayer};
|
|
2
|
+
import{result as e,createTask as t}from"../../../../core/asyncUtils.js";import n from"../../../../core/Error.js";import{clone as r}from"../../../../core/lang.js";import{fromValues as i,fromArray as a,create as o,ONES as s}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{fromValues as c,create as l,ZEROS as u}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as d,ZEROS as f}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{abortMaybe as p,releaseMaybe as m}from"../../../../core/maybe.js";import{throwIfAbortError as h,throwIfAborted as g}from"../../../../core/promiseUtils.js";import{pt2px as _,onePixelInPoints as ee}from"../../../../core/screenUtils.js";import{numericHash as v}from"../../../../core/string.js";import{dataComponents as y}from"../../../../core/urlUtils.js";import{projectPointToVector as te}from"../../../../geometry/projection/projectPointToVector.js";import{containsPoint as ne}from"../../../../geometry/support/aaBoundingBox.js";import b from"../../../../layers/support/FieldsIndex.js";import{createRendererExpression as x}from"../../../../support/ArcadeExpression.js";import{CIMSymbolHelper as S,CIMSymbolInflatedSizeHelper as re}from"../../../../symbols/cim/CIMSymbolHelper.js";import{evaluateValueOrFunction as C}from"../../../../symbols/cim/utils.js";import{scaleCIMSymbol as w}from"../../../../symbols/support/cimSymbolUtils.js";import{defaultIconPrimitive as ie}from"../../../../symbols/support/primitives.js";import ae from"../../../../symbols/support/Symbol3DAnchorPosition2D.js";import{getIconHref as oe}from"../../../../symbols/support/utils.js";import{createTexture as se,requiresHalfTexelOffset as ce,defaultBoundingBox as le,defaultSymbolSizeRatio as T,defaultTexSize as E}from"../../support/engineContent/sdfPrimitives.js";import{drapedZ as D}from"../../terrain/DrapedZ.js";import{VerticalOffsetParameters as O}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{createPointBufferGeometry as k}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as A}from"../../webgl-engine/lib/ManagedTexture.js";import{HUDMaterial as j}from"../../webgl-engine/materials/HUDMaterial.js";import{initFastSymbolUpdatesState as M,updateFastSymbolUpdatesState as N,evaluateModelTransformScale as P,ConvertOptions as F}from"../support/FastSymbolUpdates.js";import{transparentUnit as I}from"./constants.js";import{perBufferPointElevationAligner as L}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as R,needsElevationUpdates2D as z}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as B}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as V}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as ue}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as H}from"./graphicUtils.js";import{namedAnchorToHUDMaterialAnchorPos as U}from"./placementUtils.js";import{placePointOnGeometry as W,updateBufferStageObjectGeometry as de,extendPointGraphicElevationContext as G,createBufferStageObject as fe}from"./pointUtils.js";import{hasTransparencyModeSymbol as pe}from"./transparencyUtils.js";var K;const me=c(0,0,1),he=[E*T,E*T];class q extends ue{static{K=pe}static{this.PRIMITIVE_SIZE=he}getCachedSize(){return{size:this._getIconSize()}}static{this.elevationModeChangeTypes={definedChanged:1,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,_e(t)),this._cimData=null,this._overrideHelperClass=null,this._arcadeInfo=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimScaleFactorOrFunction=null,this._size=[1,1],this._symbolTextureRatio=1,this._outlineSize=0,this._textureHandle=null,this._patchTask=null,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0},this[K]=!0}async doLoad(e){this._validateOrThrow();let t=this._prepareMaterialParameters(),n=this._getPrimitive();if(n!=null)this._prepareResourcesPrimitive(t,n);else{let n=oe(this.symbolLayer),r=Y(n);r==null?await this._prepareResourcesHref(t,n,e):await this._prepareResourcesCIM(t,JSON.parse(r),e)}}_validateOrThrow(){if(this._drivenProperties.size)return;let e=H(this._getIconSize());if(e)throw new n(`graphics3diconsymbollayer:invalid-size`,e)}_getIconSize(){let e=this.symbolLayer,t=Math.round(e.size==null?16:_(e.size));return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e,t){let n=this._overrideHelperClass,i=this._cimData;if(n&&i&&i.symbol||this.logger.error(`Can't create texture, CIM data is undefined`),i.primitiveOverrides){i=r(i);let a=i.primitiveOverrides;n.evaluateOverrides(a,e,this._arcadeInfo.geometryType,null,null,t.layer.fieldsIndex),n.applyOverrides(i.symbol,a)}let a=v(JSON.stringify(i)),o=this._cimSymbolTextures.get(a);if(o)return o;let s=this._context.sharedResources.cimSymbolRasterizer,c=this._context.renderer&&this._context.renderer.type===`dictionary`?this._context.renderer.fieldMap:null;c&&n.applyDictionaryTextOverrides(i.symbol,e,c,null);let l=this._cimScaleFactorOrFunction==null?1:C(this._cimScaleFactorOrFunction,e);l!==1&&i.symbol&&w(i.symbol,l,!0);let u=S.getEnvelope(i,null,s.resourceManager);if(u?.width&&u.height){let e=u.x+u.width/2,t=u.y+u.height/2,n=i.symbol?.type===`CIMPointSymbol`?re.getPointSymbolHaloPadding(i.symbol,s.resourceManager):0,r=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,a=n>0?Math.ceil((_(n)+1)*r):0,c=s.rasterize({type:`cim`,data:i},u.width,u.height,e,t,1,`esriGeometryPoint`,a,null,r),l=new ae({x:-u.x/u.width-.5,y:(u.height+u.y)/u.height-.5});this._cimMaterialParametersInfo.anchorPosition=X(`relative`,l),o=new A(c,{width:c?.width??1,height:c?.height??1,reloadable:!0})}else o=new A(new ImageData(1,1),{width:1,height:1,reloadable:!0});return this._cimSymbolTextures.set(a,o),this._context.stage.addTexture(o),o}_prepareMaterialParameters(){let{symbolLayer:e,symbol:t,_context:n,_drivenProperties:r,view:i}=this,a=this.symbolLayer.occludedVisibility?.mode??`hidden`;return{anchorPosition:X(e.anchor,e.anchorPosition),rotation:e.angle,hasRotation:e.angle!==0||r.rotation,hasVertexRotation:r.rotation,occludedFragmentOpacity:a===`hidden`?void 0:i.state.ensureOccludedFragmentOpacity(!1,a),hasSlicePlane:n.slicePlaneEnabled,verticalOffset:ge(t)?new O(t.verticalOffset):void 0,screenSizePerspective:n.screenSizePerspectiveEnabled?i.screenSizePerspective.parameters:void 0}}_prepareResourcesPrimitive(e,t){let n=this._getOutlineSize();if(J(t)&&n===0)throw Error(`Nothing to render`);if(this._outlineSize=n,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,this._context.sharedResources.textures!=null){let n=this._context.sharedResources.textures.fromData(`${t}-icon`,()=>se(t));this._textureHandle=n,e.textureId=n.managedTexture.id}e.textureIsSignedDistanceField=!0,e.sampleSignedDistanceFieldTexelCenter=ce(t),e.distanceFieldBoundingBox=le;let r=this._getIconSize();this._size=[r,r],this._symbolTextureRatio=1/T,e.size=i(r*this._symbolTextureRatio,r*this._symbolTextureRatio),this._createMaterials(e)}async _prepareResourcesHref(t,r,i){this._outlineSize=this._getOutlineSize(),t.color=this._getFillColor(),t.outlineColor=this._getOutlineColor(),t.outlineSize=this._outlineSize,t.textureIsSignedDistanceField=!1;let o=this._getIconSize(),s=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(this._context.sharedResources.textures!=null){let c=await e(this._context.sharedResources.textures.fromUrl(r,s,{signal:i}));if(c.ok===!1){h(c.error);let e=`Failed to load (Request for icon resource failed: ${r})`;throw new n(`graphics3diconsymbollayer:request-failed`,e)}this._textureHandle=c.value;let l=c.value.managedTexture;this._size=Z(l,o),t.size=a(this._size),t.textureId=l.id}this._createMaterials(t)}async _prepareResourcesCIM(e,t,n){let{OverrideHelper:r}=await import(`../../../../symbols/cim/OverrideHelper.js`);if(this._overrideHelperClass=r,this._cimData=t,!this._context.sharedResources.cimSymbolRasterizer){let e=(await import(`../../../../symbols/cim/CIMSymbolRasterizer.js`)).CIMSymbolRasterizer;g(n),this._context.sharedResources.cimSymbolRasterizer??=new e(this._context.renderCoordsHelper.spatialReference)}let i=this._context.sharedResources.cimSymbolRasterizer,a=t,o=a?.symbol,s=[S.normalizeSymbolAndFetchResources(o,i.resourceManager,n)],c=this._context.layer.fields?this._context.layer.fields.map(e=>e.toJSON()):[],l=this._context.renderCoordsHelper.spatialReference;if(this._arcadeInfo={spatialReference:l,fields:c,geometryType:`esriGeometryPoint`},a?.primitiveOverrides&&s.push(r.createRenderExpressions(a.primitiveOverrides,this._arcadeInfo)),s.length>0&&(await Promise.all(s),g(n)),this._context.renderer&&this._context.renderer.type===`dictionary`&&this._context.renderer.scaleExpression){let e=this._context.renderer;if(e.scaleExpression){let t=e.scaleExpression,n=await x(t,this._context.layer.spatialReference),{default:r}=await import(`../../../2d/arcade/callExpressionWithFeature.js`),i=new b(c);this._cimScaleFactorOrFunction=(e,t,a)=>{let o=r(n,e,{$view:a},`esriGeometryPoint`,i,t);return o===null?1:o}}}g(n),this._cimMaterialParametersInfo=e,this._cimMaterialParametersInfo.color=this._getFillColor(),this._cimMaterialParametersInfo.outlineColor=[0,0,0,0],this._cimMaterialParametersInfo.outlineSize=0,this._cimMaterialParametersInfo.textureIsSignedDistanceField=!1}_getPrimitive(){return Q(this.symbolLayer)}_getOutlineSize(){let e=0,t=this.symbolLayer;return t.outline?.size==null?(e=J(this._getPrimitive())?1.5:0,Math.max(e,0)):Math.max(_(t.outline.size),0)}_getOutlineColor(){let e=this._getLayerOpacity(),t=this.symbolLayer?.outline?.color;if(t!=null){let n=t.toUnitRGB(),r=t.a*e;return[n[0],n[1],n[2],r]}return[0,0,0,0]}_getFillColor(){if(J(this._getPrimitive()))return I;let e=this._getPrimitive()==null,t=this._materialColor;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}get _materialColor(){return this.symbolLayer.material?.color}get _fastVisualVariableFallbackColor(){let e=this._materialColor;return e==null?this._getPrimitive()==null?d:f:e.toUnitRGBA()}_getFallbackSize(){let e=this._getIconSize(),{symbolLayer:{size:t}}=this;return(t==null?16:Math.round(_(t)))/e}_createCimMaterials(e){let t=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;if(t)return t;let n=$([],e,this._context.focusAreaStyle,this._context.spherical);return this._cimSymbolMaterials.set(e.textureId??0,n),n}_createMaterials(e){this._fastUpdates=M(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),e.hasVertexColor=this._drivenProperties.color&&!this._fastUpdates?.visualVariables.color||this._drivenProperties.opacity&&!this._fastUpdates?.visualVariables.opacity,e.hasVertexSize=this._drivenProperties.size&&!this._fastUpdates?.visualVariables.size,$(this._materials,e,this._context.focusAreaStyle,this._context.spherical)}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial(e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,hasSlicePlane:!1,shaderPolygonOffset:0,draped:this.draped})}),this.layerOpacityChanged())}destroy(){super.destroy(),this._patchTask=p(this._patchTask),this._materials.length=0,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach(e=>this._context.stage.removeTexture(e)),this._cimSymbolTextures.clear(),this._textureHandle=m(this._textureHandle)}_getScaleFactor({size:e},t){if(!this._drivenProperties.size)return 1;if(e==null)return this._getFallbackSize();let[n,r,i]=e.output;return n===`symbol-value`?1:typeof n==`number`&&isFinite(n)?_(n)/t:typeof i==`number`&&isFinite(i)?_(i)/t:1}_getDrivenRotation(e){return this._drivenProperties.rotation?e.heading?.output??0:null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let n=W(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;let r=this._materials,a=this.view.focusAreasView?.containsGeometry(n)??!0;if(this._cimData){if(!this._cimData.symbol)return null;let n=this._context.graphicsCoreOwner.view.state.rasterPixelRatio,a=this._generateTextureCIM(t,e),o=i(a.parameters.width/n,a.parameters.height/n);r=this._createCimMaterials({textureId:a.id,size:o,...this._cimMaterialParametersInfo})}let o=r[a?0:2];if(n==null)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;let s=this._getPrimitive()==null,c=e.renderingInfo,l=this._hasDrivenColorOrOpacity?this._getDrivenUInt8Color(c,this._materialColor,s):null,u=this._getDrivenRotation(c),d=null;if(!this._fastUpdates?.visualVariables.size){let e=this._size,t=e[0]>e[1]?e[0]:e[1];d=this._getScaleFactor(c,t)}let f=d==null?null:i(d,d),p=this.createElevationContextForGraphic(t);return this.ensureDrapedStatus(p.mode===`on-the-ground`)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(c,n,o,l,u,f,t.uid):this._createAs3DShape(c,n,o,l,u,f,p,t.uid)}terrainTransparencyChanged(){return this.draped}layerOpacityChanged(){let e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial(n=>{n.setParameters({color:e}),n.setParameters({outlineColor:t})})}layerScreenSizePerspectiveChanged(){let e=this._context.screenSizePerspectiveEnabled&&!this.draped?this.view.screenSizePerspective.parameters:null;this._forEachMaterial(t=>{t.setParameters({screenSizePerspective:e})})}updateTransparentMode(e,t){let n=e.stageObject.geometries[0]?.material,r=this._cimData?n?.parameters.textureId:null,i=r?this._cimSymbolMaterials.get(r):this._materials,a=(i?.indexOf(n)??-1)<2,o=i?.[t?a?1:3:a?0:2];o&&o!==n&&e.updateMaterial(o)}updateGeometry(e,t){let n=e.geometry;if(t.type!==`buffer`||this.draped||!n||!this._validateGeometry(n))return!1;let{elevationContext:r,stageObject:i}=t;if(r.mode!==this.getGeometryElevationMode(n))return!1;let a=W(n);if(!a)return!1;r.updateFeatureExpressionFeature(e,this._context.layer);let o=de(i,this._context,a,r);return o!=null&&(t.alignedSampledElevation=o,G(t,a,this._context.elevationProvider),!0)}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=R(q.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=z(r)||r===`absolute-height`;return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial(e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})}),!0}physicallyBasedRenderingChanged(){return!0}get pixelRatioChanged(){return this._getPrimitive()!=null}applyRendererDiff(e,t){for(let n in e.diff)if(n===`visualVariables`){if(N(this._fastUpdates,t,this._fastVisualVariableConvertOptions())){let e=this._fastUpdates;this._materials.forEach(t=>t?.setParameters(e.materialParameters))}else return 0}else return 0;return 2}get needsUpdateFocus(){return!0}prepareSymbolLayerPatch(e){if(this._patchTask?.abort(),e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchResource(e,t),this._preparePatchRotation(e,t)}_preparePatchResource(r,i){if(!i.resource||i.resource.type!==`partial`)return;let a=i.resource.diff;if(a?.href?.type!==`complete`)return;let o=a.href.newValue,{textures:s}=this._context.sharedResources;if(o==null||s==null||Y(o)!=null)return;let c=this._getIconSize(),l=c*this._context.graphicsCoreOwner.view.state.pixelRatio;r.symbolLayerStatePatches.push(()=>{this._patchTask=p(this._patchTask),this._patchTask=t(t=>this._context.schedule(async(t,r)=>{let i=await e(s.fromUrl(o,l,{signal:r}));g(r);let a=!i.ok;if(a&&h(i.error),this._textureHandle=m(this._textureHandle),this._patchTask=null,a){this._forEachMaterial(e=>{e.visible=!1,e.setParameters({textureId:null})});let e=`Failed to load (Request for icon resource failed: ${o})`;this.logger.error(new n(`graphics3diconsymbollayer:request-failed`,e));return}this._textureHandle=i.value;let u=i.value.managedTexture;this._size=Z(u,c),this._forEachMaterial(e=>{e.setParameters({textureId:u.id}),e.visible=!0})},t))}),delete a.href}_preparePatchRotation(e,t){if(!t.angle||t.angle.type!==`complete`)return;let n=t.angle.newValue??0,r=n!==0||this._drivenProperties.rotation;e.symbolLayerStatePatches.push(()=>{this._forEachMaterial(e=>e.setParameters({rotation:n,hasRotation:r}))}),delete t.angle}_defaultElevationInfoNoZ(){return ve}_createAs3DShape(e,t,n,r,i,a,o,s){let c=this.getFastUpdateAttrValues(e),l=this._context.layerViewUid,d=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:s,layerViewUid:l}),f=fe(this._context,t,n,{color:r,rotation:i,size:a,centerOffset:u,featureAttribute:c,olidColor:d},o,s);if(f==null)return null;let p=new B(this,f.object,null,L,o);return p.setOccludedVisibilityMode(this.symbolLayer.occludedVisibility?.mode),p.hiddenIfDeconflicted=!0,p.alignedSampledElevation=f.sampledElevation,p.needsElevationUpdates=z(o.mode)||o.mode===`absolute-height`,p.getScreenSize=this._createScreenSizeGetter(a,c),p.calculateRelativeScreenBounds=e=>n.calculateRelativeScreenBounds(p.getScreenSize(),1,e),G(p,t,this._context.elevationProvider),p}_createAsOverlay(e,t,n,r,i,a,o){n.renderPriority=this._renderPriority;let s=l();te(t,s,this._context.overlaySR),s[2]=D;let c=this._context.clippingExtent;if(c!=null&&!ne(c,s))return null;let u=this.getFastUpdateAttrValues(e),d=this._context.layerViewUid,f=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerViewUid:d}),p=this._context.drapeSourceRenderer.rendererContext.localOriginFactory.getOrigin(s),m=k(n,p,{normal:me,position:s,groundDistance:0,color:r,rotation:i,size:a,featureAttribute:u,olidColor:f});m.layerViewUid=d,m.graphicUid=o;let h=new V(this,[m],null,this._context.drapeSourceRenderer);return h.getScreenSize=this._createScreenSizeGetter(a,u),h.calculateRelativeScreenBounds=e=>n.calculateRelativeScreenBounds(h.getScreenSize(),1,e),h}_createScreenSizeGetter(e,t){e??=s;let n=this._outlineSize+2;if(this._fastUpdates&&t){let r=e[0]*this._size[0],i=e[1]*this._size[1];return(e=o())=>{let[a,s]=P(ye,this._fastUpdates.materialParameters,t);return e[0]=a*r+n,e[1]=s*i+n,e}}let r=e[0]*this._size[0]+n,i=e[1]*this._size[1]+n;return(e=o())=>(e[0]=r,e[1]=i,e)}_fastVisualVariableConvertOptions(){let e=Math.max(this._size[0],this._size[1]),t=c(e,e,e),n=ee,r=e*n,i=c(r,r,r),a=this._getFallbackSize();return new F({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:t,symbolSize:i,unitInMeters:n,fallbackColor:this._fastVisualVariableFallbackColor,fallbackSize:c(a,a,a)})}_forEachMaterial(e){this._materials.forEach(e),this._cimSymbolMaterials.forEach(t=>t.forEach(e))}test(){return{...super.test(),material:this._materials[0]}}}function ge(e){return e&&e.type===`point-3d`&&e.hasVisibleVerticalOffset()}function J(e){return e==null?!1:e===`cross`||e===`x`}function Y(e){let t=y(e);return t?.mediaType===`application/json`?t.data:void 0}function X(e,t){return e===`relative`?i((t.x||0)+.5,-(t.y||0)+.5):e in U?U[e]:U.center}function Z({parameters:e},t){let n=(e.width??1)/(e.height??1);return n>1?[t,Math.round(t/n)]:[Math.round(t*n),t]}function Q(e){return e.resource?.href?null:e.resource?.primitive??ie}function _e(e){return(e.material?.color?.a??1)===1&&Q(e)!=null}const ve={mode:`relative-to-ground`,offset:0},ye=l();function $(e,t,n,r){let i={...t,focusAreaStyle:n};return e[0]=new j(t,r),e[1]=new j(t,r,!0),e[2]=new j(i,r),e[3]=new j(i,r,!0),e}export{q as Graphics3DIconSymbolLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as n}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as r,clone as i,ones as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{onePixelInPoints as o,pt2px as s,onePointInPixels as c}from"../../../../core/screenUtils.js";import{create as l,fromBuffer as u,intersectsClippingArea as d,empty as f,expandWithAABB as p}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as m}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as h}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{debugFlags as g}from"../../support/debugFlags.js";import{selectLocalOrigin as _,createBufferGeometry as v}from"../../support/engineContent/line.js";import{geometryToRenderInfo as y,geometryToRenderInfoDraped as b}from"../../support/renderInfoUtils/line.js";import{BufferObject3D as x}from"../../webgl-engine/lib/BufferObject3D.js";import{createLineMarkerBufferGeometry as S}from"../../webgl-engine/materials/internal/lineMarkerBufferUtils.js";import{LineMarkerMaterial as C}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as w,patternHidesLine as T}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as E}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as O,getAttributeValue as k,getSizeAttributeValue as A,ConvertOptions as j}from"../support/FastSymbolUpdates.js";import{perBufferLineElevationAligner as M}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as N,needsElevationUpdates2D as P}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as F}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as I}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as L,nanFallbackColor as R}from"./Graphics3DSymbolLayer.js";import{parseCapType as z,computeSymbolLayerIndex as B,parseLineMarkerStyle as V}from"./lineUtils.js";const H=[`polyline`];class U extends L{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,K(t))}async doLoad(){if(this._fastUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?o:this.symbolLayer.size)<0)throw new e(`graphics3dlinesymbollayer:invalid-size`,`Symbol sizes may not be negative values`)}_getMaterialParameters(e,t){let n=this._screenSizePerspective,r=!!has(`enable-feature:emissive-on-non-volumetric`)&&!this.draped,{symbolLayer:i}=this,{worldSized:a}=this.symbol,o={...this._getMaterialColorParameters(t),shadingEnabled:r,width:this._computeMaterialWidth(i.size,a),worldSized:a,polygonOffset:3,polygonOffsetIndex:B(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:z(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:w(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:n};if(t===2){if(this._fastMarkerUpdates?.visualVariables)return{...o,...this._fastMarkerUpdates.materialParameters}}else if(o.hasVertexColor=this._hasDrivenColorOrOpacity,o.hasVertexSize=this._drivenProperties.size,o.hasLineDistance=o.stipplePattern!=null,this._fastUpdates?.visualVariables)return{...o,...this._fastUpdates.materialParameters};return o}_getMaterialColorParameters(e){let t=e===2,n=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(n[3]=0),{color:n}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return this._materials[0]??=new E(this._getMaterialParameters(!1,0),this.view),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new E({...this._getMaterialParameters(!1,1),wireframe:!0},this.view),this._materials[1]}get _markerMaterial(){return this._materials[2]==null&&this.symbolLayer.marker!=null&&(this._materials[2]=new C({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:V(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[2]}_getDrivenSize(e){if(this._drivenProperties.size){let t=e.size;if(t==null)return this._getFallbackSize();let n=m(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let i=a();return this._drivenProperties.color&&(n(i,e?.output??this._getFallbackOpacityAndColor(r)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(i[3]=t?.output??this._getFallbackOpacity()),i}_getDrivenMarkerColor({color:e,opacity:t}){let i=a();return this._drivenProperties.color&&(n(i,e?.output??this._getFallbackMarkerOpacityAndColor(r)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(i[3]=t?.output??this._getFallbackMarkerOpacity()),i}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validatePolylineContext(e))return null;this._warnIfVVRequiresWorldSized(e.renderingInfo);let n=this.createElevationContextForGraphic(t),r=n.mode===`on-the-ground`;return this.ensureDrapedStatus(r),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,n,t.uid)}_validatePolylineContext(e){let t=e.graphic.geometry;return this._validateGeometry(t,H,this.symbolLayer.type)&&t.type===`polyline`}applyRendererDiff(e,t){for(let n in e.diff)switch(n){case`visualVariables`:{let e=this._fastUpdates;if(O(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof E&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(O(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof C&&e.setParameters(n.materialParameters);else return 0}break;default:return 0}return`visualVariables`in e.diff&&this._warnIfVVRequiresWorldSized(),2}_warnIfVVRequiresWorldSized(e){if(this.symbol.worldSized||this.ignoreDrivers)return;let t=this._getSizeVariable(e);t==null||t.useSymbolValue||t.target===`outline`||h(t)===`real-world-size`&&this.logger.warnOnce(`SizeVariable uses real-world units, but LineSymbol3D.worldSized is false. Set LineSymbol3D.worldSized to true to render real-world line widths.`)}_getSizeVariable(e){let t=this._fastUpdates?.visualVariables.size;if(t)return t.variables[0];let n=e?.size,r=n?.output.findIndex(e=>typeof e==`number`);return r==null?null:n?.variables[r]}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff,n={};t.size?.type===`complete`&&(n.width=this._computeMaterialWidth(t.size.newValue,this.symbol.worldSized),delete t.size),t.cap?.type===`complete`&&(n.cap=z(t.cap.newValue??`butt`),delete t.cap);let r=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,r),e.symbolLayerStatePatches.push(()=>{for(let e of this._materials)e?.setParameters(n)})}layerOpacityChanged(){for(let e=0;e<3;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){let e=this._screenSizePerspective;for(let t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=N(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=P(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){let e={hasSlicePlane:this._context.slicePlaneEnabled};for(let t of this._materials)t?.setParameters(e);return!0}physicallyBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=W(e.graphic.geometry);if(r==null)return null;let i=[],a=[],o=l(),s=y(r,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,r.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<s.lines.length;t++){let r=s.lines[t],c=r.position,l=r.mapPositions;if(this._context.clippingExtent!=null&&(u(l,o),!d(o,this._context.clippingExtent)))continue;let f=this._createGeometryParts(e,c,l,1,n);a.push(f),i.push(f.line),f.wireframe!=null&&i.push(f.wireframe),f.marker!=null&&i.push(f.marker)}if(i.length===0)return null;let c=this._context.layerViewUid,f=new x({geometries:i,castShadow:!1,layerViewUid:c,graphicUid:n}),p=new F(this,f,null,(e,t,n,r,i)=>M(e,t,n,r,i,a),t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=P(t.mode),p}_createGeometryParts(e,t,n,r,i){let a=r===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o=this._fastUpdates?.visualVariables.color,s=this._fastUpdates?.visualVariables.size,c=this._fastUpdates?.visualVariables.opacity,l=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:l}),{renderingInfo:d}=e,f={position:t,size:s?null:this._getDrivenSize(d),color:o?null:this._getDrivenColor(d),sizeFeature:s?A(s,d.size):null,colorFeature:o?k(o,d.color):null,opacityFeature:c?k(c,d.opacity):null},p=r===0?this._context.drapeSourceRenderer.rendererContext.localOriginFactory:this._context.localOriginFactory,m=_(t,p),h={overlayInfo:a,removeDuplicateStartEnd:!1,mapPositions:n,attributeData:f},y=v(this._lineMaterial,h,m,u),b=g.LINE_WIREFRAMES?v(this._wireframeLineMaterial,h,m,u):null,x=this._markerMaterial,C=null;x!=null&&(h.attributeData={...f,color:o?null:this._getDrivenMarkerColor(d)},C=S(x,h,m));for(let e of[y,C,b])e!=null&&(e.layerViewUid=l,e.graphicUid=i);return{line:y,marker:C,wireframe:b}}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=g.LINE_WIREFRAMES?this._wireframeLineMaterial:null,i=this._markerMaterial;r!=null&&(r.renderPriority=this._renderPriority-.001),i!=null&&(i.renderPriority=this._renderPriority-.002);let a=[],o=l(),s=f(),c=b(n,this._context.overlaySR);this._logGeometryCreationWarnings(c,n.paths,`paths`,`LineSymbol3DLayer`);for(let n of c.lines){if(u(n.position,o),!d(o,this._context.clippingExtent))continue;p(s,o);let r=this._createGeometryParts(e,n.position,void 0,0,t.uid);r.marker!=null&&a.push(r.marker),a.push(r.line),r.wireframe!=null&&a.push(r.wireframe)}return new I(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return T(this.symbolLayer.pattern)}_computeMaterialWidth(e,t){return t?this._drivenProperties.size?1:e??1:(e??=o,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?c:1:s(e))}_prepareMaterialPatch(e,t,n){let r=t.material;if(r==null){n.changed&&n.useMaterialColor&&G(this._getCombinedOpacityAndColor(this._materialColor),this._materials[2],e);return}if(r.type===`collection`)return;let a=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,o=this._getCombinedOpacityAndColor(a);n.useMaterialColor&&G(i(o),this._materials[2],e),this._patternHidesLine&&(o[3]=0),G(o,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){let n=t.marker,r=this._markerMaterial;if(n==null||n.type!==`partial`||n.diff==null||n.diff.placement!=null||n.diff.style!=null&&n.diff.style.type!==`complete`||n.diff.color!=null&&n.diff.color.type!==`complete`||r==null)return{changed:!1,useMaterialColor:this._markerColor==null};let i=n.diff.color,a=i!=null,o=a?i.newValue:null,s=o==null&&this._markerColor==null;o&&G(this._getCombinedOpacityAndColor(o),r,e);let c=n.diff.style?.newValue;return c&&e.symbolLayerStatePatches.push(()=>r.setParameters({markerPrimitive:V(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let n=this._getFallbackSize(),{size:r}=this.symbolLayer;return new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:t(r,r,r),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(R):this._getFallbackOpacityAndColor(R),fallbackSize:t(n,n,n)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer.marker?.color?.a??this._getFallbackOpacity()}_getWorldOrScreenSize(e){return this.symbol.worldSized?e:s(e)}_getFallbackSize(){return this._getWorldOrScreenSize(this.symbolLayer.size)}}function W(e){return e.type===`polyline`?e:null}function G(e,t,n){t!=null&&n.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function K(e){return(e.material?.color?.a??1)===1&&(e.marker?.color?.a??1)===1}export{U as Graphics3DLineSymbolLayer};
|
|
2
|
+
import e from"../../../../core/Error.js";import has from"../../../../core/has.js";import{fromValues as t}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{copy as n}from"../../../../core/libs/gl-matrix-2/math/vec4.js";import{ZEROS as r,clone as i,ones as a}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{onePixelInPoints as o,pt2px as s,onePointInPixels as c}from"../../../../core/screenUtils.js";import{create as l,fromBuffer as u,intersectsClippingArea as d,empty as f,expandWithAABB as p}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as m}from"../../../../renderers/support/renderingInfoUtils.js";import{getTransformationType as h}from"../../../../renderers/visualVariables/support/sizeVariableUtils.js";import{debugFlags as g}from"../../support/debugFlags.js";import{selectLocalOrigin as _,createBufferGeometry as v}from"../../support/engineContent/line.js";import{geometryToRenderInfo as y,geometryToRenderInfoDraped as b}from"../../support/renderInfoUtils/line.js";import{BufferObject3D as x}from"../../webgl-engine/lib/BufferObject3D.js";import{createLineMarkerBufferGeometry as S}from"../../webgl-engine/materials/internal/lineMarkerBufferUtils.js";import{LineMarkerMaterial as C}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as w,patternHidesLine as T}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as E}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as O,getAttributeValue as k,getSizeAttributeValue as A,ConvertOptions as j}from"../support/FastSymbolUpdates.js";import{perBufferLineElevationAligner as M}from"./ElevationAligners.js";import{elevationModeChangeUpdateType as N,needsElevationUpdates2D as P}from"./elevationAlignmentUtils.js";import{Graphics3DBufferGraphicLayer as F}from"./Graphics3DBufferGraphicLayer.js";import{Graphics3DDrapedBufferGraphicLayer as I}from"./Graphics3DDrapedBufferGraphicLayer.js";import{Graphics3DSymbolLayer as L,nanFallbackColor as R}from"./Graphics3DSymbolLayer.js";import{parseCapType as z,computeSymbolLayerIndex as B,parseLineMarkerStyle as V}from"./lineUtils.js";const H=[`polyline`];class U extends L{static{this.elevationModeChangeTypes={definedChanged:2,staysOnTheGround:0,onTheGroundChanged:2}}constructor(e,t,n,r){super(e,t,n,r,K(t))}async doLoad(){if(this._fastUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastMarkerUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions(!0)),!this._drivenProperties.size&&(this.symbolLayer.size==null?o:this.symbolLayer.size)<0)throw new e(`graphics3dlinesymbollayer:invalid-size`,`Symbol sizes may not be negative values`)}_getMaterialParameters(e,t){let n=this._screenSizePerspective,r=!!has(`enable-feature:emissive-on-non-volumetric`)&&!this.draped,{symbolLayer:i}=this,{worldSized:a}=this.symbol,o={...this._getMaterialColorParameters(t),shadingEnabled:r,width:this._computeMaterialWidth(i.size,a),worldSized:a,polygonOffset:3,polygonOffsetIndex:B(this._renderPriority,this._renderPriorityStep),join:i.join||`miter`,cap:z(i.cap||`butt`),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:w(i.pattern??i.imagePattern),emissiveStrength:this._emissiveStrength,screenSizePerspective:n};if(t===2){if(this._fastMarkerUpdates?.visualVariables)return{...o,...this._fastMarkerUpdates.materialParameters}}else if(o.hasVertexColor=this._hasDrivenColorOrOpacity,o.hasVertexSize=this._drivenProperties.size,o.hasLineDistance=o.stipplePattern!=null,this._fastUpdates?.visualVariables)return{...o,...this._fastUpdates.materialParameters};return o}_getMaterialColorParameters(e){let t=e===2,n=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);return this._patternHidesLine&&!t&&(n[3]=0),{color:n}}get _materialColor(){return this.symbolLayer.material?.color}get _emissiveStrength(){let e=this.symbolLayer.material?.emissive;return(e?.source===`color`?e?.strength:void 0)??0}get _markerColor(){return this.symbolLayer.marker?.color}get _lineMaterial(){return this._materials[0]??=new E(this._getMaterialParameters(!1,0),this.view),this._materials[0]}get _wireframeLineMaterial(){return this._materials[1]??=new E({...this._getMaterialParameters(!1,1),wireframe:!0},this.view),this._materials[1]}get _markerMaterial(){return this._materials[2]==null&&this.symbolLayer.marker!=null&&(this._materials[2]=new C({...this._getMaterialParameters(!1,2),placement:this.symbolLayer.marker.placement,markerPrimitive:V(this.symbolLayer.marker.style)},this.view.state.isGlobal)),this._materials[2]}_getDrivenSize(e){if(this._drivenProperties.size){let t=e.size;if(t==null)return this._getFallbackSize();let n=m(t.output);return this._getWorldOrScreenSize(n)}return 1}_getDrivenColor({color:e,opacity:t}){let i=a();return this._drivenProperties.color&&(n(i,e?.output??this._getFallbackOpacityAndColor(r)),t==null)||this._drivenProperties.opacity&&(e||this._materialColor)&&(i[3]=t?.output??this._getFallbackOpacity()),i}_getDrivenMarkerColor({color:e,opacity:t}){let i=a();return this._drivenProperties.color&&(n(i,e?.output??this._getFallbackMarkerOpacityAndColor(r)),t==null)||this._drivenProperties.opacity&&(e||this._markerColor||this._materialColor)&&(i[3]=t?.output??this._getFallbackMarkerOpacity()),i}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validatePolylineContext(e))return null;this._warnIfVVRequiresWorldSized(e.renderingInfo);let n=this.createElevationContextForGraphic(t),r=n.mode===`on-the-ground`;return this.ensureDrapedStatus(r),this.draped?this._createAsOverlay(e):this._createAs3DShape(e,n,t.uid)}_validatePolylineContext(e){let t=e.graphic.geometry;return this._validateGeometry(t,H,this.symbolLayer.type)&&t.type===`polyline`}applyRendererDiff(e,t){for(let n in e.diff)if(n===`visualVariables`){let e=this._fastUpdates;if(O(e,t,this._fastVisualVariableConvertOptions()))for(let t of this._materials)t instanceof E&&t.setParameters(e.materialParameters);else return 0;let n=this._fastMarkerUpdates;if(O(n,t,this._fastVisualVariableConvertOptions(!0)))for(let e of this._materials)e instanceof C&&e.setParameters(n.materialParameters);else return 0}else return 0;return`visualVariables`in e.diff&&this._warnIfVVRequiresWorldSized(),2}_warnIfVVRequiresWorldSized(e){if(this.symbol.worldSized||this.ignoreDrivers)return;let t=this._getSizeVariable(e);t==null||t.useSymbolValue||t.target===`outline`||h(t)===`real-world-size`&&this.logger.warnOnce(`SizeVariable uses real-world units, but LineSymbol3D.worldSized is false. Set LineSymbol3D.worldSized to true to render real-world line widths.`)}_getSizeVariable(e){let t=this._fastUpdates?.visualVariables.size;if(t)return t.variables[0];let n=e?.size,r=n?.output.findIndex(e=>typeof e==`number`);return r==null?null:n?.variables[r]}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff,n={};t.size?.type===`complete`&&(n.width=this._computeMaterialWidth(t.size.newValue,this.symbol.worldSized),delete t.size),t.cap?.type===`complete`&&(n.cap=z(t.cap.newValue??`butt`),delete t.cap);let r=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,r),e.symbolLayerStatePatches.push(()=>{for(let e of this._materials)e?.setParameters(n)})}layerOpacityChanged(){for(let e=0;e<3;e++)this._materials[e]?.setParameters(this._getMaterialColorParameters(e))}get _screenSizePerspective(){return!this.draped&&this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null}layerScreenSizePerspectiveChanged(){let e=this._screenSizePerspective;for(let t of this._materials)t?.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t,n){let r=this._elevationContext.mode,i=N(U.elevationModeChangeTypes,n,r);if(i!==1)return i;let a=P(r);return this.updateGraphics3DGraphicElevationInfo(e,t,()=>a)}slicePlaneEnabledChanged(){let e={hasSlicePlane:this._context.slicePlaneEnabled};for(let t of this._materials)t?.setParameters(e);return!0}physicallyBasedRenderingChanged(){return!0}_createAs3DShape(e,t,n){let r=W(e.graphic.geometry);if(r==null)return null;let i=[],a=[],o=l(),s=y(r,this._context.elevationProvider,this._context.renderCoordsHelper,t);this._logGeometryCreationWarnings(s,r.paths,`paths`,`LineSymbol3DLayer`);for(let t=0;t<s.lines.length;t++){let r=s.lines[t],c=r.position,l=r.mapPositions;if(this._context.clippingExtent!=null&&(u(l,o),!d(o,this._context.clippingExtent)))continue;let f=this._createGeometryParts(e,c,l,1,n);a.push(f),i.push(f.line),f.wireframe!=null&&i.push(f.wireframe),f.marker!=null&&i.push(f.marker)}if(i.length===0)return null;let c=this._context.layerViewUid,f=new x({geometries:i,castShadows:!1,layerViewUid:c,graphicUid:n}),p=new F(this,f,null,(e,t,n,r,i)=>M(e,t,n,r,i,a),t);return p.alignedSampledElevation=s.sampledElevation,p.needsElevationUpdates=P(t.mode),p}_createGeometryParts(e,t,n,r,i){let a=r===0?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,o=this._fastUpdates?.visualVariables.color,s=this._fastUpdates?.visualVariables.size,c=this._fastUpdates?.visualVariables.opacity,l=this._context.layerViewUid,u=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:i,layerViewUid:l}),{renderingInfo:d}=e,f={position:t,size:s?null:this._getDrivenSize(d),color:o?null:this._getDrivenColor(d),sizeFeature:s?A(s,d.size):null,colorFeature:o?k(o,d.color):null,opacityFeature:c?k(c,d.opacity):null},p=r===0?this._context.drapeSourceRenderer.rendererContext.localOriginFactory:this._context.localOriginFactory,m=_(t,p),h={overlayInfo:a,removeDuplicateStartEnd:!1,mapPositions:n,attributeData:f},y=v(this._lineMaterial,h,m,u),b=g.LINE_WIREFRAMES?v(this._wireframeLineMaterial,h,m,u):null,x=this._markerMaterial,C=null;x!=null&&(h.attributeData={...f,color:o?null:this._getDrivenMarkerColor(d)},C=S(x,h,m));for(let e of[y,C,b])e!=null&&(e.layerViewUid=l,e.graphicUid=i);return{line:y,marker:C,wireframe:b}}_createAsOverlay(e){let t=e.graphic,{geometry:n}=t;this._lineMaterial.renderPriority=this._renderPriority;let r=g.LINE_WIREFRAMES?this._wireframeLineMaterial:null,i=this._markerMaterial;r!=null&&(r.renderPriority=this._renderPriority-.001),i!=null&&(i.renderPriority=this._renderPriority-.002);let a=[],o=l(),s=f(),c=b(n,this._context.overlaySR);this._logGeometryCreationWarnings(c,n.paths,`paths`,`LineSymbol3DLayer`);for(let n of c.lines){if(u(n.position,o),!d(o,this._context.clippingExtent))continue;p(s,o);let r=this._createGeometryParts(e,n.position,void 0,0,t.uid);r.marker!=null&&a.push(r.marker),a.push(r.line),r.wireframe!=null&&a.push(r.wireframe)}return new I(this,a,s,this._context.drapeSourceRenderer)}get _patternHidesLine(){return T(this.symbolLayer.pattern)}_computeMaterialWidth(e,t){return t?this._drivenProperties.size?1:e??1:(e??=o,this._drivenProperties.size?this._fastUpdates?.visualVariables.size?c:1:s(e))}_prepareMaterialPatch(e,t,n){let r=t.material;if(r==null){n.changed&&n.useMaterialColor&&G(this._getCombinedOpacityAndColor(this._materialColor),this._materials[2],e);return}if(r.type===`collection`)return;let a=r.type===`complete`?r.newValue?.color:r.diff.color?.type===`complete`?r.diff.color.newValue:null,o=this._getCombinedOpacityAndColor(a);n.useMaterialColor&&G(i(o),this._materials[2],e),this._patternHidesLine&&(o[3]=0),G(o,this._materials[0],e),delete t.material}_prepareMarkerPatch(e,t){let n=t.marker,r=this._markerMaterial;if(n==null||n.type!==`partial`||n.diff==null||n.diff.placement!=null||n.diff.style!=null&&n.diff.style.type!==`complete`||n.diff.color!=null&&n.diff.color.type!==`complete`||r==null)return{changed:!1,useMaterialColor:this._markerColor==null};let i=n.diff.color,a=i!=null,o=a?i.newValue:null,s=o==null&&this._markerColor==null;o&&G(this._getCombinedOpacityAndColor(o),r,e);let c=n.diff.style?.newValue;return c&&e.symbolLayerStatePatches.push(()=>r.setParameters({markerPrimitive:V(c)})),delete t.marker,{changed:a,useMaterialColor:s}}_fastVisualVariableConvertOptions(e=!1){let n=this._getFallbackSize(),{size:r}=this.symbolLayer;return new j({supports:{size:!0,color:!0,rotation:!1,opacity:!0},symbolSize:t(r,r,r),fallbackColor:e?this._getFallbackMarkerOpacityAndColor(R):this._getFallbackOpacityAndColor(R),fallbackSize:t(n,n,n)})}_getFallbackOpacityAndColor(e){return this._materialColor?.toUnitRGBA()??e}_getFallbackOpacity(){return this._materialColor?.a??0}_getFallbackMarkerOpacityAndColor(e){return this.symbolLayer.marker?.color?.toUnitRGBA()??this._getFallbackOpacityAndColor(e)}_getFallbackMarkerOpacity(){return this.symbolLayer.marker?.color?.a??this._getFallbackOpacity()}_getWorldOrScreenSize(e){return this.symbol.worldSized?e:s(e)}_getFallbackSize(){return this._getWorldOrScreenSize(this.symbolLayer.size)}}function W(e){return e.type===`polyline`?e:null}function G(e,t,n){t!=null&&n.symbolLayerStatePatches.push(()=>t.setParameters({color:e}))}function K(e){return(e.material?.color?.a??1)===1&&(e.marker?.color?.a??1)===1}export{U as Graphics3DLineSymbolLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{normalFromMat4 as n,fromMat4 as r}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as o,invert as s,getTranslation as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l,IDENTITY as u,clone as d}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as p,add as m,scale as h,transformMat4 as g,transformMat3 as _,normalize as v,scaleAndAdd as y,subtract as b,cross as x,dot as ee}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as te,ZEROS as ne,ONES as re,create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as ie}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{releaseMaybe as ae}from"../../../../core/maybe.js";import{isPromiseLike as oe}from"../../../../core/promiseUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as se}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as ce}from"../../../../geometry/projection/projectVectorToVector.js";import{canProjectWithoutEngine as le}from"../../../../geometry/projectionUtils.js";import{fromBuffer as ue,intersectsClippingArea as de,create as fe}from"../../../../geometry/support/aaBoundingBox.js";import{t as w}from"../../../../chunks/vec3.js";import{newFloatArray as T}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as E,getContinuousIndexArray as pe}from"../../../../geometry/support/Indices.js";import me from"../../../../geometry/support/MeshComponent.js";import he from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import ge from"../../../../geometry/support/MeshTextureTransform.js";import{transformNormal as D,transformVectorENUPlateCarree as O,transformVectorWMPlateCarree as k,projectNormalToPCPF as _e,transformTangent as A,projectTangentToPCPF as ve}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as ye}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{projectLocalVertexSpaceToPCPF as be}from"../../../../geometry/support/meshUtils/vertexSpaceConversion.js";import{isRelativeVertexSpace as xe,isAbsoluteVertexSpace as Se}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as j,isPlateCarree as M}from"../../../../geometry/support/spatialReferenceUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as Ce}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{getEmissiveMode as we}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as Te}from"../../glTF/internal/resourceUtils.js";import{convertMeshTextureTransformToGLTF as N,getTransformMatrix as P}from"../../glTF/internal/TextureTransformUtils.js";import{debugFlags as F}from"../../support/debugFlags.js";import{Attribute as I}from"../../webgl-engine/lib/Attribute.js";import{Geometry as L}from"../../webgl-engine/lib/Geometry.js";import{ManagedTexture as Ee}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as De}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as Oe}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as R}from"../../webgl-engine/materials/NativeLineMaterial.js";import{useSchematicPBR as ke,advancedMRRFactors as Ae,schematicMRRFactors as je}from"../../webgl-engine/materials/pbrUtils.js";import{hasEdges as Me,createMaterial as Ne}from"../support/edgeUtils.js";import{defaultSymbolLayerMemoryComplexity as Pe}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as B,evaluateElevationInfoAtPoint as V}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as Fe}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as Ie}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Le}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Re,nanFallbackColor as ze}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as Be,MeshFastUpdateProcessor as Ve}from"./MeshFastUpdateProcessor.js";import{addOlidAttribute as He}from"./olidUtils.js";import{SymbolComplexity as Ue}from"./SymbolComplexity.js";const We=[`mesh`];class Ge extends Re{constructor(e,t,n,r){super(e,t,n,r,Ce(t)),this._materialInfoCache=new Be,this._fastUpdateProcessor=new Ve,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){F.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new R({color:[1,0,1,1]}),this._debugTangentNormalMaterial=new R({color:[1,.5,0,1]}),this._debugFaceNormalMaterial=new R({color:[0,1,1,1]})),this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,We,`fill on mesh-3d`))return null;let n=this.createElevationContextForGraphic(t),r=e.renderingInfo;return this._createAs3DShape(t,r,n,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){let n=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:n});let t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(n,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,B)}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}physicallyBasedRenderingChanged(){let e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateMeshTransform(e,t,n,r,i){if(!e.fastTransformUpdatesAllowed)return!1;let a=e.fastTransformUpdatesEnabled;switch(i){case 0:if(a)return!0;break;case 1:if(!a)return!0}let o=this._context.renderCoordsHelper.spatialReference,s=it,{origin:c,transform:l}=n;if(!C(t.spatialReference,p(J,c.x,c.y,c.z??0),s,o))return!1;switch(i){case void 0:a||this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context,!0);break;case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:if(this._fastUpdateProcessor.disable(e,this._materialInfoCache),t.vertexSpace.type===`local`)return!1}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);let{elevationContext:u}=e;u.centerInElevationSR=this._getCenterInElevationSR(s);let{elevationProvider:d,renderCoordsHelper:f}=this._context;return e.alignedSampledElevation=z(e,u,d.spatialReference,(e,t)=>V(e,d,u,f,t),f,s),e.updateTransform(s,l,this._context.isAsync,r),!0}computeComplexity(){if(!this._textures||this._textures.size===0)return super.computeComplexity();let e=0;for(let t of this._textures.values())e+=t.usedMemory;let t={...Pe(this.symbol,this.symbolLayer),resourceBytes:e},n=Me(this.symbolLayer)?2:0;return new Ue({drawCallsPerFeature:n,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){let n=this._requiresSymbolVertexColors(),r=!!e.vertexAttributes.color,i=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:n,hasVertexColors:r,hasVertexTangents:i,unlit:!1,uid:`vc:${r},vt:${i},vct${t},svc:${n}`}}_materialProperties(e,t,n){let r=this._materialPropertiesDefault(e,n);if(!t.material)return r;let{color:i,colorTexture:a,colorTextureTransform:o,normalTexture:s,normalTextureTransform:c,doubleSided:l,alphaCutoff:u,alphaMode:d}=t.material,f=G(i),p=G(a),m=K(o),h=G(s),g=K(c);if(r.color=i,r.colorTexture=a,r.normalTexture=s,r.uid=`${r.uid},cmuid:${f},ctmuid:${p},cttuid:${m},ntmuid:${h},nttuid:${g},ds:${l},ac:${u},am:${d}`,t.material instanceof he){let{metallic:e,roughness:n,metallicRoughnessTexture:i,metallicRoughnessTextureTransform:a,emissiveColor:s,emissiveStrength:l,emissiveTexture:u,emissiveTextureTransform:d,occlusionTexture:f,occlusionTextureTransform:p,unlit:m}=t.material,h=G(i),g=K(a),_=G(s),v=G(u),y=K(d),b=G(f),x=K(p);r.uid=[r.uid,`mrm:${e}`,`mrr:${n}`,`mrt:${h}`,`mrtt:${g}`,`emuid:${_}`,`ems:${l}`,`etmuid:${v}`,`ett:${y}`,`otmuid:${b}`,`ott:${x}`,`unlit:${m}`].join(`,`),r.metallic=e,r.roughness=n,r.metallicRoughnessTexture=i,r.emissiveColor=m?void 0:s,r.emissiveStrength=l,r.emissiveTexture=m?void 0:u,r.occlusionTexture=f,r.unlit=m,r.colorTextureTransform=N(o),r.normalTextureTransform=N(c),r.emissiveTextureTransform=N(d),r.occlusionTextureTransform=N(p),r.metallicRoughnessTextureTransform=N(a)}return r}_getInternalTexture(e,t=!1,n=1){let r=tt(e);if(!r)return null;let i=`${e.contentHash}/${n}`,a=this._textures.get(i);if(a){let e=this._context.stage.renderView.textures,t=null,n=e.acquire(a.id);return n!=null&&!oe(n)&&(a.events.on(`unloaded`,()=>t=ae(t)),t=n),a}let o=null,s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,c={wrap:Qe(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};return Te(r)?(o=r.data,c.preMultiplyAlpha=!1,c.encoding=r.encoding):(o=r,c.preMultiplyAlpha=n!==1,c.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),a=new Ee(o,c),this._textures.set(i,a),a.events.on(`loaded`,()=>this.updateComplexity()),a.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(a),a.events.on(`unloaded`,()=>{this._textures.delete(i)}),a}_setInternalMaterialTextureParameters(e,n){if(e.colorTexture!=null){let t=n.textureAlphaMode!==1,r=this._getInternalTexture(e.colorTexture,t,n.textureAlphaMode);r?(n.textureId=r.id,n.textureAlphaPremultiplied=!!r.parameters.preMultiplyAlpha):n.textureId=void 0}if(e.normalTexture&&(n.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){let r=e.emissiveColor?.toUnitRGB();n.emissiveBaseColor=te(t(r[0]),t(r[1]),t(r[2]))}e.emissiveStrength&&(n.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(n.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(n.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(n.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,n){e.color!=null&&et(e.color,t,n),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=P(e.colorTextureTransform),t.normalTextureTransformMatrix=P(e.normalTextureTransform);let r=e.normalTextureTransform?.scale==null?f:e.normalTextureTransform?.scale;t.normalScale=[r[0],r[1]],t.occlusionTextureTransformMatrix=P(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=P(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=P(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){let n=this._drivenProperties.color,r=this._drivenProperties.opacity;if(n)e.externalColor=ie;else{let n=t??null;if(n){let t=n.toUnitRGBA();r&&(t[3]=1),e.externalColor=t}else e.externalColor=ze}e.colorMixMode=this.symbolLayer.material?.colorMixMode??`multiply`,e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=we(this.symbolLayer?.material?.emissive?.source??`emissive`)}_getOrCreateMaterial(e,t){let n=t.material?.color,r=t.material?.colorTexture,i=t.material?.alphaMode,a=i===`blend`,o=i!==`opaque`&&($e(e)||n!=null&&n.a<1||r?.transparent||a),s=this._materialProperties(e,t,o),c=this._materialInfoCache.byUid(s.uid);if(c)return this._setInternalMaterialTextureParameters(s,c.material.parameters),c.material;let l={uid:s.uid,material:null,isComponentTransparent:o,alphaMode:t.material?t.material.alphaMode:`opaque`},u=ke({normalTexture:s.normalTexture,metallicRoughnessTexture:s.metallicRoughnessTexture,metallicFactor:s.metallic,roughnessFactor:s.roughness,emissiveTexture:s.unlit?void 0:s.emissiveTexture,emissiveFactor:s.unlit?ne:s.emissiveColor?.toUnitRGB(),occlusionTexture:s.occlusionTexture}),d={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:s.hasVertexColors,hasSymbolColors:s.hasSymbolVertexColors,hasVertexTangents:s.hasVertexTangents,ambient:ne,diffuse:re,opacity:1,doubleSided:!0,doubleSidedType:`winding-order`,cullFace:0,unlit:s.unlit,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||l.isComponentTransparent};d.mrrFactors=u?je:[s.metallic,s.roughness,Ae[2]],t.material&&(d.doubleSided=t.material.doubleSided,d.cullFace=t.material.doubleSided?0:2,d.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(d),this._setMaterialTextureAlphaMode(d,l),this._setInternalMaterialParameters(s,d,l);let f=new Oe(d,this._context.spherical);return l.material=f,this._materialInfoCache.set(s.uid,l),f}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue;delete n.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{let t=e.material.parameters;this._setExternalMaterialParameters(t,r),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return Fe(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicallyBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){e.textureAlphaMode=t.alphaMode===`auto`?this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1?3:1:t.alphaMode===`opaque`?1:t.alphaMode===`mask`?2:0}_createFaceDebugNormals(e,t){let r=t.length,a=e.spatialReference.isGeographic?20015077/180:1,o=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),s=[],c=[],l=t[0].transformation,u=n(i(),l);for(let e=0;e<r;e++){let n=t[e].attributes.get(`position`);if(!n)continue;let r=n.data,i=n.indices;for(let e=0;e<i.length;e+=3)U(r,i,e,Z),Ze(r,i,e,J,Y,X),m(J,J,Y),m(J,J,X),h(J,J,1/3),g(J,J,l),s.push(...J),_(Z,Z,u),v(Z,Z),y(J,J,Z,o),s.push(...J),c.push(c.length),c.push(c.length)}return s.length?new L(this._debugFaceNormalMaterial,[[`position`,new I(s,c,3,!0)]],null):null}_createPerVertexDebugVectors(e,t,a,o,s){let c=t.length,l=e.spatialReference.isGeographic?20015077/180:1,u=s*.1*Math.max(e.extent.width*l,e.extent.height*l,e.extent.zmax-e.extent.zmin),d=[],f=[],m=t[0].transformation,h=n(i(),m);a===`tangent`&&r(h,m);for(let e=0;e<c;e++){let n=t[e],r=n.attributes.get(`position`),i=n.attributes.get(a);if(!r||!i)continue;let o=r.data,s=r.indices,c=i.data,l=i.indices;for(let e=0;e<s.length;e++){let t=s[e]*3,n=l[e]*i.stride;p(J,o[t+0],o[t+1],o[t+2]),g(J,J,m),d.push(...J),p(Y,c[n+0],c[n+1],c[n+2]),_(Y,Y,h),v(Y,Y),y(J,J,Y,u),d.push(...J),f.push(f.length),f.push(f.length)}}return d.length?new L(o,[[`position`,new I(d,f,3,!0)]],null):null}_createAs3DShape(e,t,n,r){let i=e.geometry;if(i.type!==`mesh`)return null;let a=this._createGeometryInfo(i,t,r);if(a==null)return null;let{geometries:o,objectTransformation:s}=a;if(F.DRAW_MESH_GEOMETRY_NORMALS){let e=this._createPerVertexDebugVectors(i,o,`normal`,this._debugVertexNormalMaterial,1),t=this._createPerVertexDebugVectors(i,o,`tangent`,this._debugTangentNormalMaterial,.5),n=this._createFaceDebugNormals(i,o);e&&o.push(e),t&&o.push(t),n&&o.push(n)}let c=this._context.layerViewUid,l=new De({geometries:o,layerViewUid:c,graphicUid:r,isElevationSource:!0});l.transformation=s;let u=Ne(this.symbolLayer,{opacity:this._getLayerOpacity()}),d=u?new Le(o[0].material,u,this._context.slicePlaneEnabled):null,f=new Ie(this,l,null,z,n,d);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=B(n.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(i),n.centerInElevationSR=this._getCenterInElevationSR(l.transformation);let{elevationProvider:p,renderCoordsHelper:m}=this._context;return f.alignedSampledElevation=z(f,n,p.spatialReference,(e,t)=>V(e,p,n,m,t),m),f}_fastTransformUpdatesAllowed(e){let{vertexSpace:t,spatialReference:n}=e;if(!xe(t))return!1;let{type:r}=t,{view:i}=this._context.graphicsCoreOwner,{viewingMode:a}=i.state,o=i.spatialReference;return a===1&&r===`local`||a===2&&j(o,n)&&r===`georeferenced`&&!n.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){let t=S(),n=p(ot,e[12],e[13],e[14]);return ce(n,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return e.reprojection===0&&!!e.objectTransformation}_createPositionBuffer(e,t,n){let r=n.position,i=r,a;if(t.reprojection===0)return{position:i,georeferencedPositionBuffer:a};let o=t.reprojection===1?t.transformBeforeProject:null;o&&(i=w(new Float64Array(i.length),i,o));let{normal:s,tangent:c}=n;!this._passthroughReprojectionInfo(t)&&(s||c)&&(a=i);let l=i===r||i===a?new Float64Array(i.length):i;return se(i,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:a}}_createNormalBuffer(e,t,n,r,i){let a=i.normal;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;s&&(o=D(o,new Float32Array(o.length),s));let c=this._context.graphicsCoreOwner.view.viewingMode;if(r.reprojection===0)return o;if(c===`local`){if(!M(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return O(o,0,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return k(o,0,n,e)}return o}if(n==null)return null;let l=o===a?new Float32Array(o.length):o,u=this._context.renderCoordsHelper.spatialReference;return _e(o,n,e.spatialReference,t,u,l)}_createTangentBuffer(e,t,n,r,i){let a=i.tangent;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;s&&(o=A(o,new Float32Array(o.length),s));let c=this._context.graphicsCoreOwner.view.viewingMode;if(r.reprojection===0)return o;if(c===`local`){if(!M(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return O(o,1,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return k(o,1,n,e)}return o}if(n==null)return null;let l=o===a?new Float32Array(o.length):o,u=this._context.renderCoordsHelper.spatialReference;return ve(o,n,e.spatialReference,t,u,l)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){let n=e.vertexAttributes&&e.vertexAttributes.position;if(!n)return this.logger.warn(`Mesh geometry must contain position vertex attributes`),null;let r=e.vertexAttributes.normal,i=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(r&&r.length!==n.length)return this.logger.warn(`Mesh normal vertex buffer must contain the same number of elements as the position buffer`),null;if(a&&a.length/4!=n.length/3)return this.logger.warn(`Mesh tangent vertex buffer must contain the same number of elements as the position buffer`),null;if(i&&i.length/2!=n.length/3)return this.logger.warn(`Mesh uv vertex buffer must contain the same number of elements as the position buffer`),null;let o=this._computeReprojectionInfo(e),s=o.reprojection===1&&o.convertLocalVertexSpace,c=s&&e.vertexSpace.type===`local`?be(e,e.vertexSpace,this._context.renderCoordsHelper.spatialReference):null;if(s&&!c)return this.logger.warn(`Local mesh vertex space could not be converted for rendering`),null;let{position:l,georeferencedPositionBuffer:u}=c?{position:c.position,georeferencedPositionBuffer:null}:this._createPositionBuffer(e,o,e.vertexAttributes),d=nt(e),f=this._createSymbolColorBuffer(t),p=c?c.normal:this._createNormalBuffer(e,l,u,o,e.vertexAttributes),m=c?c.tangent:this._createTangentBuffer(e,l,u,o,e.vertexAttributes),h=i,{geometryTransformation:g}=o,{transformation:_,position:v,normal:y,tangent:b}=this._passthroughReprojectionInfo(o)?{transformation:o.objectTransformation,position:l,normal:p,tangent:m}:this._expressInOriginLocalSpace(e,l,p,m,g);return{positionBuffer:v,normalBuffer:y,tangentBuffer:b,uvBuffer:h,colorBuffer:d,symbolColorBuffer:f,objectTransformation:_,geometryTransformation:g}}_computeReprojectionInfo(e){let{vertexSpace:t}=e,n=t.type===`georeferenced`,r=t.type===`local`&&this._context.graphicsCoreOwner.view.state.isGlobal,i=n?+!j(this._context.renderCoordsHelper.spatialReference,e.spatialReference):+!!r;if(Se(t))return{reprojection:i,geometryTransformation:l()};let s=t.origin,c=e.transform?.localMatrix??u;if(i===0){let t=l();return C(e.spatialReference,s,t,this._context.renderCoordsHelper.spatialReference),{reprojection:i,objectTransformation:t,geometryTransformation:d(c)}}if(r)return{reprojection:i,convertLocalVertexSpace:!0,geometryTransformation:d(c)};let f=a(l(),s);return o(f,f,c),{reprojection:i,transformBeforeProject:f,geometryTransformation:l()}}_expressInOriginLocalSpace(e,t,n,r,i){let a=this._context.renderCoordsHelper.spatialReference,c=e.origin;q[0]=c.x,q[1]=c.y,q[2]=c.z??0;let u=l();C(e.spatialReference,q,u,a),o(Q,u,i),s(Q,Q);let{position:d,normal:f,tangent:p}=e.vertexAttributes,m=t===d?new Float64Array(t.length):t;w(m,t,Q);let h=n?n===f?new Float32Array(n.length):n:null,g=r?r===p?new Float32Array(r.length):r:null;return n&&h&&D(n,h,Q),r&&g&&A(r,g,Q),{transformation:u,position:m,normal:h,tangent:g}}_validateFaces(e,t){let n=e.vertexAttributes.position.length/3,r=t.faces;if(r&&r.length>0){let e=-1;for(let t=0;t<r.length;t++){let n=r[t];n>e&&(e=n)}if(n<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(n%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}_isOutsideClippingArea(e){if(!this._context.clippingExtent||!e.vertexAttributes?.position)return!1;let t=this._context.elevationProvider.spatialReference,n=ye(e,t??e.spatialReference);return n?(ue(n,$),!de($,this._context.clippingExtent)):!1}_createGeometryInfo(e,t,n){if(!le(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn(`Geometry spatial reference is not compatible with the view`),null;if(!this._validateVertexSpace(e)||this._isOutsideClippingArea(e))return null;let r=this._createBuffers(e,t);if(r==null)return null;let{positionBuffer:i,uvBuffer:a,colorBuffer:o,symbolColorBuffer:s,normalBuffer:l,tangentBuffer:u,objectTransformation:d,geometryTransformation:f}=r,p=e.components??at,m=[],h=!1,g=c(J,d),_=this._context.localOriginFactory.getOrigin(g);for(let t of p){if(!this._validateFaces(e,t))return null;let r=Ke(e,t);if(r.length===0)continue;let c=qe(i,l,t,r);c.didFlipNormals&&(h=!0);let d=[[`position`,new I(i,r,3,!0)],[`normal`,new I(c.normals,c.indices,3,!0)]];o&&d.push([`color`,new I(o,r,4,!0)]);let p=null;s&&(p=E(r.length),d.push([`symbolColor`,new I(s,p,4,!0)])),a&&d.push([`uv0`,new I(a,r,2,!0)]),u&&d.push([`tangent`,new I(u,r,4,!0)]);let g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:this._context.layerViewUid});g&&(p??=E(r.length),He(d,g,p));let v=this._getOrCreateMaterial(e,t),y=new L(v,d,null);y.transformation=f,y.localOrigin=_,m.push(y)}return h&&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.`),m.length===0?null:{geometries:m,objectTransformation:d}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){let{_context:{graphicsCoreOwner:{view:{state:{viewingMode:t}}}}}=this,{vertexSpace:n}=e;return t===2&&n.type===`local`?(this.logger.warn(`Displaying a mesh with a local vertex space in a view in local viewing mode is not supported.`),!1):!0}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class H{constructor(e,t,n){this.normals=e,this.indices=t,this.didFlipNormals=n}}function Ke(e,t){return t.faces??pe(e.vertexAttributes.position.length/3)}function qe(e,t,n,r){switch(n.shading||`flat`){default:case`source`:return Ye(e,t,n,r);case`flat`:return Je(e,r);case`smooth`:return Xe(e,r)}}function Je(e,t){let n=T(t.length),r=Array(t.length*3);for(let i=0;i<t.length;i+=3){let a=U(e,t,i,Z);for(let e=0;e<3;e++)n[i+e]=a[e],r[i+e]=i/3}return new H(n,r,!1)}function Ye(e,t,n,r){if(t==null)return Je(e,r);let i=!1;if(!n.trustSourceNormals)for(let n=0;n<r.length;n+=3){U(e,r,n,Z);for(let e=0;e<3;e++){let a=r[n+e]*3;J[0]=t[a],J[1]=t[a+1],J[2]=t[a+2],ee(Z,J)<0&&(t[a]=-t[a],t[a+1]=-t[a+1],t[a+2]=-t[a+2],i=!0)}}return new H(t,r,i)}function Xe(e,t){let n={};for(let r=0;r<t.length;r+=3){let i=U(e,t,r,Z);for(let e=0;e<3;e++){let a=t[r+e],o=n[a];o||(o={normal:S(),count:0},n[a]=o),m(o.normal,o.normal,i),o.count++}}let r=T(t.length*3),i=Array(t.length*3);for(let e=0;e<t.length;e++){let a=n[t[e]];a.count!==1&&(v(a.normal,a.normal),a.count=1);for(let t=0;t<3;t++)r[e*3+t]=a.normal[t];i[e]=e}return new H(r,i,!1)}function Ze(e,t,n,r,i,a){let o=t[n]*3,s=t[n+1]*3,c=t[n+2]*3;r[0]=e[o],r[1]=e[o+1],r[2]=e[o+2],i[0]=e[s],i[1]=e[s+1],i[2]=e[s+2],a[0]=e[c],a[1]=e[c+1],a[2]=e[c+2]}function U(e,t,n,r){return Ze(e,t,n,J,Y,X),b(Y,Y,J),b(X,X,J),x(J,Y,X),v(r,J),r}function Qe(e=`repeat`){if(typeof e==`string`){let t=W(e);return{s:t,t}}return{s:W(e.horizontal),t:W(e.vertical)}}function W(e){switch(e){case`clamp`:return 33071;case`mirror`:return 33648;default:return 10497}}function $e(e){let t=e.vertexAttributes.color;if(t==null)return!1;for(let e=3;e<t.length;e+=4)if(t[e]!==255)return!0;return!1}function et(e,t,n){t.diffuse=e.toUnitRGB(),t.opacity=n.alphaMode===`opaque`?1:e.a}function tt(e){return e.data??e.url}function G(t){return t==null?`-`:t instanceof e?t.toHex():t.contentHash}function K(e){let{offset:t,scale:n,rotation:r}=e??rt;return`${t[0]},${t[1]},${r},${n[0]},${n[1]}`}function nt(e){return e.vertexAttributes.color}const rt=new ge,q=S(),J=S(),Y=S(),X=S(),Z=S(),Q=l(),it=l(),$=fe(),at=[new me],ot=S();export{Ge as Graphics3DMeshFillSymbolLayer};
|
|
2
|
+
import e from"../../../../Color.js";import{linearize as t}from"../../../../colorUtils.js";import{normalFromMat4 as n,fromMat4 as r}from"../../../../core/libs/gl-matrix-2/math/mat3.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat3f64.js";import{fromTranslation as a,multiply as o,invert as s,getTranslation as c}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as l,IDENTITY as u,clone as d}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{ONES as f}from"../../../../core/libs/gl-matrix-2/factories/vec2f64.js";import{set as p,add as m,scale as h,transformMat4 as g,transformMat3 as _,normalize as v,scaleAndAdd as y,subtract as b,cross as ee,dot as te}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromValues as ne,ZEROS as x,ONES as re,create as S}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ONES as ie}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{releaseMaybe as ae}from"../../../../core/maybe.js";import{isPromiseLike as oe}from"../../../../core/promiseUtils.js";import{computeTranslationToOriginAndRotation as C}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectBuffer as se}from"../../../../geometry/projection/projectBuffer.js";import{projectVectorToVector as ce}from"../../../../geometry/projection/projectVectorToVector.js";import{canProjectWithoutEngine as le}from"../../../../geometry/projectionUtils.js";import{fromBuffer as ue,intersectsClippingArea as de,create as fe}from"../../../../geometry/support/aaBoundingBox.js";import{t as w}from"../../../../chunks/vec3.js";import{newFloatArray as T}from"../../../../geometry/support/FloatArray.js";import{getZeroIndexArray as E,getContinuousIndexArray as pe}from"../../../../geometry/support/Indices.js";import me from"../../../../geometry/support/MeshComponent.js";import he from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import ge from"../../../../geometry/support/MeshTextureTransform.js";import{transformNormal as D,transformVectorENUPlateCarree as O,transformVectorWMPlateCarree as k,projectNormalToPCPF as _e,transformTangent as A,projectTangentToPCPF as ve}from"../../../../geometry/support/meshUtils/projection.js";import{projectMeshVertexPositions as ye}from"../../../../geometry/support/meshUtils/projectMeshVertexPositions.js";import{projectLocalVertexSpaceToPCPF as be}from"../../../../geometry/support/meshUtils/vertexSpaceConversion.js";import{isRelativeVertexSpace as xe,isAbsoluteVertexSpace as Se}from"../../../../geometry/support/meshVertexSpaceUtils.js";import{equals as j,isPlateCarree as M}from"../../../../geometry/support/spatialReferenceUtils.js";import{isDrivenOpacityFallbackAlwaysOpaque as Ce}from"../../../../renderers/visualVariables/support/visualVariableUtils.js";import{getEmissiveMode as we}from"../../../../symbols/support/materialUtils.js";import{isEncodedMeshTexture as Te}from"../../glTF/internal/resourceUtils.js";import{convertMeshTextureTransformToGLTF as N,getTransformMatrix as P}from"../../glTF/internal/TextureTransformUtils.js";import{debugFlags as F}from"../../support/debugFlags.js";import{Attribute as I}from"../../webgl-engine/lib/Attribute.js";import{Geometry as Ee}from"../../webgl-engine/lib/Geometry.js";import{createPolylineGeometry as L}from"../../webgl-engine/lib/GeometryUtil.js";import{ManagedTexture as De}from"../../webgl-engine/lib/ManagedTexture.js";import{Object3D as Oe}from"../../webgl-engine/lib/Object3D.js";import{DefaultMaterial as ke}from"../../webgl-engine/materials/DefaultMaterial.js";import{useSchematicPBR as Ae,advancedMRRFactors as je,schematicMRRFactors as Me}from"../../webgl-engine/materials/pbrUtils.js";import{RibbonLineMaterial as R}from"../../webgl-engine/materials/RibbonLineMaterial.js";import{hasEdges as Ne,createMaterial as Pe}from"../support/edgeUtils.js";import{defaultSymbolLayerMemoryComplexity as Fe}from"./defaultSymbolComplexity.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{needsElevationUpdates3D as B,evaluateElevationInfoAtPoint as V}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as Ie}from"./emissiveUtils.js";import{Graphics3DMeshObject3DGraphicLayer as Le}from"./Graphics3DMeshObject3DGraphicLayer.js";import{Object3DEdgeState as Re}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as ze,nanFallbackColor as Be}from"./Graphics3DSymbolLayer.js";import{MaterialInfoCache as Ve,MeshFastUpdateProcessor as He}from"./MeshFastUpdateProcessor.js";import{addOlidAttribute as Ue}from"./olidUtils.js";import{SymbolComplexity as We}from"./SymbolComplexity.js";const Ge=[`mesh`];class Ke extends ze{constructor(e,t,n,r){super(e,t,n,r,Ce(t)),this._materialInfoCache=new Ve,this._fastUpdateProcessor=new He,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){if(F.DRAW_MESH_GEOMETRY_NORMALS){let e=this._context.stage.view;this._debugVertexNormalMaterial=new R({color:[1,0,1,1],width:1},e),this._debugTangentNormalMaterial=new R({color:[1,.5,0,1],width:1},e),this._debugFaceNormalMaterial=new R({color:[0,1,1,1],width:1},e)}this.updateComplexity()}destroy(){super.destroy(),this._textures.forEach(e=>e.unload()),this._context.stage.removeTextures(Array.from(this._textures.values())),this._materialInfoCache.clear(),this._textures.clear(),this._fastUpdateProcessor.destroy()}get materials(){return this._materialInfoCache.materials}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry,Ge,`fill on mesh-3d`))return null;let n=this.createElevationContextForGraphic(t),r=e.renderingInfo;return this._createAs3DShape(t,r,n,t.uid)}onRemoveGraphic(e){this._fastUpdateProcessor.onRemoveGraphic(e,this._materialInfoCache)}layerOpacityChanged(e,t){let n=this._getLayerOpacity();this._updateMaterialParameters(e=>{e.material.setParameters({layerOpacity:n});let t=e.material.parameters;this._setMaterialTextureAlphaMode(t,e)}),e?.forEach(e=>t(e)?.layerOpacityChanged(n,this._context.isAsync))}layerScreenSizePerspectiveChanged(){}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,B)}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}physicallyBasedRenderingChanged(){let e=this._usePBR();return this._updateMaterialParameters(({material:t})=>t.setParameters({usePBR:e})),!0}updateMeshTransform(e,t,n,r,i){if(!e.fastTransformUpdatesAllowed)return!1;let a=e.fastTransformUpdatesEnabled;switch(i){case 0:if(a)return!0;break;case 1:if(!a)return!0}let o=this._context.renderCoordsHelper.spatialReference,s=at,{origin:c,transform:l}=n;if(!C(t.spatialReference,p(J,c.x,c.y,c.z??0),s,o))return!1;switch(i){case void 0:a||this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context,!0);break;case 0:this._fastUpdateProcessor.enable(e,this._materialInfoCache,this._context);break;case 1:if(this._fastUpdateProcessor.disable(e,this._materialInfoCache),t.vertexSpace.type===`local`)return!1}e.updateFastLocalOrigin(s,l,this._context.localOriginFactory,!1);let{elevationContext:u}=e;u.centerInElevationSR=this._getCenterInElevationSR(s);let{elevationProvider:d,renderCoordsHelper:f}=this._context;return e.alignedSampledElevation=z(e,u,d.spatialReference,(e,t)=>V(e,d,u,f,t),f,s),e.updateTransform(s,l,this._context.isAsync,r),!0}computeComplexity(){if(!this._textures||this._textures.size===0)return super.computeComplexity();let e=0;for(let t of this._textures.values())e+=t.usedMemory;let t={...Fe(this.symbol,this.symbolLayer),resourceBytes:e},n=Ne(this.symbolLayer)?2:0;return new We({drawCallsPerFeature:n,memory:t})}_requiresSymbolVertexColors(){return this._hasDrivenColorOrOpacity}_materialPropertiesDefault(e,t){let n=this._requiresSymbolVertexColors(),r=!!e.vertexAttributes.color,i=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:n,hasVertexColors:r,hasVertexTangents:i,unlit:!1,uid:`vc:${r},vt:${i},vct${t},svc:${n}`}}_materialProperties(e,t,n){let r=this._materialPropertiesDefault(e,n);if(!t.material)return r;let{color:i,colorTexture:a,colorTextureTransform:o,normalTexture:s,normalTextureTransform:c,doubleSided:l,alphaCutoff:u,alphaMode:d}=t.material,f=G(i),p=G(a),m=K(o),h=G(s),g=K(c);if(r.color=i,r.colorTexture=a,r.normalTexture=s,r.uid=`${r.uid},cmuid:${f},ctmuid:${p},cttuid:${m},ntmuid:${h},nttuid:${g},ds:${l},ac:${u},am:${d}`,t.material instanceof he){let{metallic:e,roughness:n,metallicRoughnessTexture:i,metallicRoughnessTextureTransform:a,emissiveColor:s,emissiveStrength:l,emissiveTexture:u,emissiveTextureTransform:d,occlusionTexture:f,occlusionTextureTransform:p,unlit:m}=t.material,h=G(i),g=K(a),_=G(s),v=G(u),y=K(d),b=G(f),ee=K(p);r.uid=[r.uid,`mrm:${e}`,`mrr:${n}`,`mrt:${h}`,`mrtt:${g}`,`emuid:${_}`,`ems:${l}`,`etmuid:${v}`,`ett:${y}`,`otmuid:${b}`,`ott:${ee}`,`unlit:${m}`].join(`,`),r.metallic=e,r.roughness=n,r.metallicRoughnessTexture=i,r.emissiveColor=m?void 0:s,r.emissiveStrength=l,r.emissiveTexture=m?void 0:u,r.occlusionTexture=f,r.unlit=m,r.colorTextureTransform=N(o),r.normalTextureTransform=N(c),r.emissiveTextureTransform=N(d),r.occlusionTextureTransform=N(p),r.metallicRoughnessTextureTransform=N(a)}return r}_getInternalTexture(e,t=!1,n=1){let r=nt(e);if(!r)return null;let i=`${e.contentHash}/${n}`,a=this._textures.get(i);if(a){let e=this._context.stage.renderView.textures,t=null,n=e.acquire(a.id);return n!=null&&!oe(n)&&(a.events.on(`unloaded`,()=>t=ae(t)),t=n),a}let o=null,s=this._context.stage.renderView.renderingContext.parameters.maxMaxAnisotropy,c={wrap:$e(e.wrap),noUnpackFlip:!0,maxAnisotropy:s,mipmap:s>1};return Te(r)?(o=r.data,c.preMultiplyAlpha=!1,c.encoding=r.encoding):(o=r,c.preMultiplyAlpha=n!==1,c.compressionOptions=t?{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}:void 0),a=new De(o,c),this._textures.set(i,a),a.events.on(`loaded`,()=>this.updateComplexity()),a.load(this._context.stage.renderView.renderingContext),this._context.stage.addTexture(a),a.events.on(`unloaded`,()=>{this._textures.delete(i)}),a}_setInternalMaterialTextureParameters(e,n){if(e.colorTexture!=null){let t=n.textureAlphaMode!==1,r=this._getInternalTexture(e.colorTexture,t,n.textureAlphaMode);r?(n.textureId=r.id,n.textureAlphaPremultiplied=!!r.parameters.preMultiplyAlpha):n.textureId=void 0}if(e.normalTexture&&(n.normalTextureId=this._getInternalTexture(e.normalTexture)?.id),e.emissiveColor){let r=e.emissiveColor?.toUnitRGB();n.emissiveBaseColor=ne(t(r[0]),t(r[1]),t(r[2]))}e.emissiveStrength&&(n.emissiveStrengthKHR=e.emissiveStrength),e.emissiveTexture&&(n.emissiveTextureId=this._getInternalTexture(e.emissiveTexture)?.id),e.occlusionTexture&&(n.occlusionTextureId=this._getInternalTexture(e.occlusionTexture,!0)?.id),e.metallicRoughnessTexture&&(n.metallicRoughnessTextureId=this._getInternalTexture(e.metallicRoughnessTexture,!0)?.id)}_setInternalMaterialParameters(e,t,n){e.color!=null&&tt(e.color,t,n),this._setInternalMaterialTextureParameters(e,t),t.colorTextureTransformMatrix=P(e.colorTextureTransform),t.normalTextureTransformMatrix=P(e.normalTextureTransform);let r=e.normalTextureTransform?.scale==null?f:e.normalTextureTransform?.scale;t.normalScale=[r[0],r[1]],t.occlusionTextureTransformMatrix=P(e.occlusionTextureTransform),t.emissiveTextureTransformMatrix=P(e.emissiveTextureTransform),t.metallicRoughnessTextureTransformMatrix=P(e.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(e,t=this._materialColor){let n=this._drivenProperties.color,r=this._drivenProperties.opacity;if(n)e.externalColor=ie;else{let n=t??null;if(n){let t=n.toUnitRGBA();r&&(t[3]=1),e.externalColor=t}else e.externalColor=Be}e.colorMixMode=this.symbolLayer.material?.colorMixMode??`multiply`,e.castShadows=!!this.symbolLayer.castShadows,e.emissiveStrengthFromSymbol=this.symbolLayer?.material?.emissive?.strength??1,e.emissiveSource=we(this.symbolLayer?.material?.emissive?.source??`emissive`)}_getOrCreateMaterial(e,t){let n=t.material?.color,r=t.material?.colorTexture,i=t.material?.alphaMode,a=i===`blend`,o=i!==`opaque`&&(et(e)||n!=null&&n.a<1||r?.transparent||a),s=this._materialProperties(e,t,o),c=this._materialInfoCache.byUid(s.uid);if(c)return this._setInternalMaterialTextureParameters(s,c.material.parameters),c.material;let l={uid:s.uid,material:null,isComponentTransparent:o,alphaMode:t.material?t.material.alphaMode:`opaque`},u=Ae({normalTexture:s.normalTexture,metallicRoughnessTexture:s.metallicRoughnessTexture,metallicFactor:s.metallic,roughnessFactor:s.roughness,emissiveTexture:s.unlit?void 0:s.emissiveTexture,emissiveFactor:s.unlit?x:s.emissiveColor?.toUnitRGB(),occlusionTexture:s.occlusionTexture}),d={usePBR:this._usePBR(),isSchematic:u,hasVertexColors:s.hasVertexColors,hasSymbolColors:s.hasSymbolVertexColors,hasVertexTangents:s.hasVertexTangents,ambient:x,diffuse:re,opacity:1,doubleSided:!0,doubleSidedType:`winding-order`,cullFace:0,unlit:s.unlit,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,drivenOpacity:this.needsDrivenTransparentPass||l.isComponentTransparent};d.mrrFactors=u?Me:[s.metallic,s.roughness,je[2]],t.material&&(d.doubleSided=t.material.doubleSided,d.cullFace=t.material.doubleSided?0:2,d.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(d),this._setMaterialTextureAlphaMode(d,l),this._setInternalMaterialParameters(s,d,l);let f=new ke(d,this._context.spherical);return l.material=f,this._materialInfoCache.set(s.uid,l),f}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue;delete n.color,e.symbolLayerStatePatches.push(()=>{this._updateMaterialParameters(e=>{let t=e.material.parameters;this._setExternalMaterialParameters(t,r),this._setMaterialTextureAlphaMode(t,e),e.material.setParameters({externalColor:t.externalColor})})})}_preparePatchEmissive(e,t){return Ie(e,t,e=>{this._updateMaterialParameters(t=>{t.material.setParameters({emissiveStrengthFromSymbol:e??1})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_usePBR(){return this._context.physicallyBasedRenderingEnabled}_setMaterialTextureAlphaMode(e,t){e.textureAlphaMode=t.alphaMode===`auto`?this.needsDrivenTransparentPass||t.isComponentTransparent||(e.layerOpacity??1)<1||(e.opacity??1)<1||(e.externalColor?.[3]??1)<1?3:1:t.alphaMode===`opaque`?1:t.alphaMode===`mask`?2:0}_createFaceDebugNormals(e,t){let r=t.length,a=e.spatialReference.isGeographic?20015077/180:1,o=.1*Math.max(e.extent.width*a,e.extent.height*a,e.extent.zmax-e.extent.zmin),s=[],c=t[0].transformation,l=n(i(),c);for(let e=0;e<r;e++){let n=t[e].attributes.get(`position`);if(!n)continue;let r=n.data,i=n.indices;for(let e=0;e<i.length;e+=3)U(r,i,e,Z),Qe(r,i,e,J,Y,X),m(J,J,Y),m(J,J,X),h(J,J,1/3),g(J,J,c),_(Z,Z,l),v(Z,Z),y(Y,J,Z,o),s.push(L(this._debugFaceNormalMaterial,[J,Y]))}return s}_createPerVertexDebugVectors(e,t,a,o,s){let c=t.length,l=e.spatialReference.isGeographic?20015077/180:1,u=s*.1*Math.max(e.extent.width*l,e.extent.height*l,e.extent.zmax-e.extent.zmin),d=[],f=t[0].transformation,m=n(i(),f);a===`tangent`&&r(m,f);for(let e=0;e<c;e++){let n=t[e],r=n.attributes.get(`position`),i=n.attributes.get(a);if(!r||!i)continue;let s=r.data,c=r.indices,l=i.data,h=i.indices;for(let e=0;e<c.length;e++){let t=c[e]*3,n=h[e]*i.stride;p(J,s[t+0],s[t+1],s[t+2]),g(J,J,f),p(Y,l[n+0],l[n+1],l[n+2]),_(Y,Y,m),v(Y,Y),y(Y,J,Y,u),d.push(L(o,[J,Y]))}}return d}_createAs3DShape(e,t,n,r){let i=e.geometry;if(i.type!==`mesh`)return null;let a=this._createGeometryInfo(i,t,r);if(a==null)return null;let{geometries:o,objectTransformation:s}=a;F.DRAW_MESH_GEOMETRY_NORMALS&&o.push(...this._createPerVertexDebugVectors(i,o,`normal`,this._debugVertexNormalMaterial,1),...this._createPerVertexDebugVectors(i,o,`tangent`,this._debugTangentNormalMaterial,.5),...this._createFaceDebugNormals(i,o));let c=this._context.layerViewUid,l=new Oe({geometries:o,layerViewUid:c,graphicUid:r,isElevationSource:!0});l.transformation=s;let u=Pe(this.symbolLayer,{opacity:this._getLayerOpacity()}),d=u?new Re(o[0].material,u,this._context.slicePlaneEnabled):null,f=new Le(this,l,null,z,n,d);this._fastUpdateProcessor.onAddGraphic(),f.needsElevationUpdates=B(n.mode),f.useObjectOriginAsAttachmentOrigin=!0,f.fastTransformUpdatesAllowed=this._fastTransformUpdatesAllowed(i),n.centerInElevationSR=this._getCenterInElevationSR(l.transformation);let{elevationProvider:p,renderCoordsHelper:m}=this._context;return f.alignedSampledElevation=z(f,n,p.spatialReference,(e,t)=>V(e,p,n,m,t),m),f}_fastTransformUpdatesAllowed(e){let{vertexSpace:t,spatialReference:n}=e;if(!xe(t))return!1;let{type:r}=t,{view:i}=this._context.graphicsCoreOwner,{isGlobal:a,isLocal:o}=i.state,s=i.spatialReference;return a&&r===`local`||o&&j(s,n)&&r===`georeferenced`&&!n.isGeographic}_getElevationSR(){return this._context.elevationProvider.spatialReference??null}_getCenterInElevationSR(e){let t=S(),n=p(st,e[12],e[13],e[14]);return ce(n,this._context.renderCoordsHelper.spatialReference,t,this._getElevationSR()),t}_passthroughReprojectionInfo(e){return e.reprojection===0&&!!e.objectTransformation}_createPositionBuffer(e,t,n){let r=n.position,i=r,a;if(t.reprojection===0)return{position:i,georeferencedPositionBuffer:a};let o=t.reprojection===1?t.transformBeforeProject:null;o&&(i=w(new Float64Array(i.length),i,o));let{normal:s,tangent:c}=n;!this._passthroughReprojectionInfo(t)&&(s||c)&&(a=i);let l=i===r||i===a?new Float64Array(i.length):i;return se(i,e.spatialReference,0,l,this._context.renderCoordsHelper.spatialReference,0),{position:l,georeferencedPositionBuffer:a}}_createNormalBuffer(e,t,n,r,i){let a=i.normal;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;if(s&&(o=D(o,new Float32Array(o.length),s)),r.reprojection===0)return o;if(this._context.graphicsCoreOwner.view.state.isLocal){if(!M(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return O(o,0,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return k(o,0,n,e)}return o}if(n==null)return null;let c=o===a?new Float32Array(o.length):o,l=this._context.renderCoordsHelper.spatialReference;return _e(o,n,e.spatialReference,t,l,c)}_createTangentBuffer(e,t,n,r,i){let a=i.tangent;if(a==null)return null;let o=a,s=r.reprojection===1?r.transformBeforeProject:null;if(s&&(o=A(o,new Float32Array(o.length),s)),r.reprojection===0)return o;if(this._context.graphicsCoreOwner.view.state.isLocal){if(!M(this._context.renderCoordsHelper.spatialReference))return o;if(n==null)return null;if(e.spatialReference.isGeographic){let e=o===a?new Float32Array(o.length):o;return O(o,1,n,e)}if(e.spatialReference.isWebMercator){let e=o===a?new Float32Array(o.length):o;return k(o,1,n,e)}return o}if(n==null)return null;let c=o===a?new Float32Array(o.length):o,l=this._context.renderCoordsHelper.spatialReference;return ve(o,n,e.spatialReference,t,l,c)}_createSymbolColorBuffer(e){return this._requiresSymbolVertexColors()?new Uint8Array(this._getDrivenUInt8ColorWithNaNSupport(e,this._materialColor,!0)):null}_createBuffers(e,t){let n=e.vertexAttributes&&e.vertexAttributes.position;if(!n)return this.logger.warn(`Mesh geometry must contain position vertex attributes`),null;let r=e.vertexAttributes.normal,i=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(r&&r.length!==n.length)return this.logger.warn(`Mesh normal vertex buffer must contain the same number of elements as the position buffer`),null;if(a&&a.length/4!=n.length/3)return this.logger.warn(`Mesh tangent vertex buffer must contain the same number of elements as the position buffer`),null;if(i&&i.length/2!=n.length/3)return this.logger.warn(`Mesh uv vertex buffer must contain the same number of elements as the position buffer`),null;let o=this._computeReprojectionInfo(e),s=o.reprojection===1&&o.convertLocalVertexSpace,c=s&&e.vertexSpace.type===`local`?be(e,e.vertexSpace,this._context.renderCoordsHelper.spatialReference):null;if(s&&!c)return this.logger.warn(`Local mesh vertex space could not be converted for rendering`),null;let{position:l,georeferencedPositionBuffer:u}=c?{position:c.position,georeferencedPositionBuffer:null}:this._createPositionBuffer(e,o,e.vertexAttributes),d=rt(e),f=this._createSymbolColorBuffer(t),p=c?c.normal:this._createNormalBuffer(e,l,u,o,e.vertexAttributes),m=c?c.tangent:this._createTangentBuffer(e,l,u,o,e.vertexAttributes),h=i,{geometryTransformation:g}=o,{transformation:_,position:v,normal:y,tangent:b}=this._passthroughReprojectionInfo(o)?{transformation:o.objectTransformation,position:l,normal:p,tangent:m}:this._expressInOriginLocalSpace(e,l,p,m,g);return{positionBuffer:v,normalBuffer:y,tangentBuffer:b,uvBuffer:h,colorBuffer:d,symbolColorBuffer:f,objectTransformation:_,geometryTransformation:g}}_computeReprojectionInfo(e){let{vertexSpace:t}=e,n=t.type===`georeferenced`,r=t.type===`local`&&this._context.graphicsCoreOwner.view.state.isGlobal,i=n?+!j(this._context.renderCoordsHelper.spatialReference,e.spatialReference):+!!r;if(Se(t))return{reprojection:i,geometryTransformation:l()};let s=t.origin,c=e.transform?.localMatrix??u;if(i===0){let t=l();return C(e.spatialReference,s,t,this._context.renderCoordsHelper.spatialReference),{reprojection:i,objectTransformation:t,geometryTransformation:d(c)}}if(r)return{reprojection:i,convertLocalVertexSpace:!0,geometryTransformation:d(c)};let f=a(l(),s);return o(f,f,c),{reprojection:i,transformBeforeProject:f,geometryTransformation:l()}}_expressInOriginLocalSpace(e,t,n,r,i){let a=this._context.renderCoordsHelper.spatialReference,c=e.origin;q[0]=c.x,q[1]=c.y,q[2]=c.z??0;let u=l();C(e.spatialReference,q,u,a),o(Q,u,i),s(Q,Q);let{position:d,normal:f,tangent:p}=e.vertexAttributes,m=t===d?new Float64Array(t.length):t;w(m,t,Q);let h=n?n===f?new Float32Array(n.length):n:null,g=r?r===p?new Float32Array(r.length):r:null;return n&&h&&D(n,h,Q),r&&g&&A(r,g,Q),{transformation:u,position:m,normal:h,tangent:g}}_validateFaces(e,t){let n=e.vertexAttributes.position.length/3,r=t.faces;if(r&&r.length>0){let e=-1;for(let t=0;t<r.length;t++){let n=r[t];n>e&&(e=n)}if(n<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(n%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}_isOutsideClippingArea(e){if(!this._context.clippingExtent||!e.vertexAttributes?.position)return!1;let t=this._context.elevationProvider.spatialReference,n=ye(e,t??e.spatialReference);return n?(ue(n,$),!de($,this._context.clippingExtent)):!1}_createGeometryInfo(e,t,n){if(!le(e.spatialReference,this._context.renderCoordsHelper.spatialReference))return this.logger.warn(`Geometry spatial reference is not compatible with the view`),null;if(!this._validateVertexSpace(e)||this._isOutsideClippingArea(e))return null;let r=this._createBuffers(e,t);if(r==null)return null;let{positionBuffer:i,uvBuffer:a,colorBuffer:o,symbolColorBuffer:s,normalBuffer:l,tangentBuffer:u,objectTransformation:d,geometryTransformation:f}=r,p=e.components??ot,m=[],h=!1,g=c(J,d),_=this._context.localOriginFactory.getOrigin(g);for(let t of p){if(!this._validateFaces(e,t))return null;let r=qe(e,t);if(r.length===0)continue;let c=Je(i,l,t,r);c.didFlipNormals&&(h=!0);let d=[[`position`,new I(i,r,3,!0)],[`normal`,new I(c.normals,c.indices,3,!0)]];o&&d.push([`color`,new I(o,r,4,!0)]);let p=null;s&&(p=E(r.length),d.push([`symbolColor`,new I(s,p,4,!0)])),a&&d.push([`uv0`,new I(a,r,2,!0)]),u&&d.push([`tangent`,new I(u,r,4,!0)]);let g=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:n,layerViewUid:this._context.layerViewUid});g&&(p??=E(r.length),Ue(d,g,p));let v=this._getOrCreateMaterial(e,t),y=new Ee(v,d,null);y.transformation=f,y.localOrigin=_,m.push(y)}return h&&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.`),m.length===0?null:{geometries:m,objectTransformation:d}}_updateMaterialParameters(e){this._materialInfoCache.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachMaterialInfo(e),this._fastUpdateProcessor.forEachClonedMaterial((e,t)=>{t.setParameters(e.parameters)})}_validateVertexSpace(e){return this._context.graphicsCoreOwner.view.state.isLocal&&e.vertexSpace.type===`local`?(this.logger.warn(`Displaying a mesh with a local vertex space in a view in local viewing mode is not supported.`),!1):!0}test(){return{...super.test(),materials:this._materialInfoCache.materials}}get _materialColor(){return this.symbolLayer.material?.color}}class H{constructor(e,t,n){this.normals=e,this.indices=t,this.didFlipNormals=n}}function qe(e,t){return t.faces??pe(e.vertexAttributes.position.length/3)}function Je(e,t,n,r){switch(n.shading||`flat`){default:case`source`:return Xe(e,t,n,r);case`flat`:return Ye(e,r);case`smooth`:return Ze(e,r)}}function Ye(e,t){let n=T(t.length),r=Array(t.length*3);for(let i=0;i<t.length;i+=3){let a=U(e,t,i,Z);for(let e=0;e<3;e++)n[i+e]=a[e],r[i+e]=i/3}return new H(n,r,!1)}function Xe(e,t,n,r){if(t==null)return Ye(e,r);let i=!1;if(!n.trustSourceNormals)for(let n=0;n<r.length;n+=3){U(e,r,n,Z);for(let e=0;e<3;e++){let a=r[n+e]*3;J[0]=t[a],J[1]=t[a+1],J[2]=t[a+2],te(Z,J)<0&&(t[a]=-t[a],t[a+1]=-t[a+1],t[a+2]=-t[a+2],i=!0)}}return new H(t,r,i)}function Ze(e,t){let n={};for(let r=0;r<t.length;r+=3){let i=U(e,t,r,Z);for(let e=0;e<3;e++){let a=t[r+e],o=n[a];o||(o={normal:S(),count:0},n[a]=o),m(o.normal,o.normal,i),o.count++}}let r=T(t.length*3),i=Array(t.length*3);for(let e=0;e<t.length;e++){let a=n[t[e]];a.count!==1&&(v(a.normal,a.normal),a.count=1);for(let t=0;t<3;t++)r[e*3+t]=a.normal[t];i[e]=e}return new H(r,i,!1)}function Qe(e,t,n,r,i,a){let o=t[n]*3,s=t[n+1]*3,c=t[n+2]*3;r[0]=e[o],r[1]=e[o+1],r[2]=e[o+2],i[0]=e[s],i[1]=e[s+1],i[2]=e[s+2],a[0]=e[c],a[1]=e[c+1],a[2]=e[c+2]}function U(e,t,n,r){return Qe(e,t,n,J,Y,X),b(Y,Y,J),b(X,X,J),ee(J,Y,X),v(r,J),r}function $e(e=`repeat`){if(typeof e==`string`){let t=W(e);return{s:t,t}}return{s:W(e.horizontal),t:W(e.vertical)}}function W(e){switch(e){case`clamp`:return 33071;case`mirror`:return 33648;default:return 10497}}function et(e){let t=e.vertexAttributes.color;if(t==null)return!1;for(let e=3;e<t.length;e+=4)if(t[e]!==255)return!0;return!1}function tt(e,t,n){t.diffuse=e.toUnitRGB(),t.opacity=n.alphaMode===`opaque`?1:e.a}function nt(e){return e.data??e.url}function G(t){return t==null?`-`:t instanceof e?t.toHex():t.contentHash}function K(e){let{offset:t,scale:n,rotation:r}=e??it;return`${t[0]},${t[1]},${r},${n[0]},${n[1]}`}function rt(e){return e.vertexAttributes.color}const it=new ge,q=S(),J=S(),Y=S(),X=S(),Z=S(),Q=l(),at=l(),$=fe(),ot=[new me],st=S();export{Ke as Graphics3DMeshFillSymbolLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{identity as e,scale as t,translate as n,copy as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as a,negate as o,copy as s,multiply as c,add as l,set as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as d,ONES as f,ZEROS as p,fromValues as m,create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as g,ONES as _,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{throwIfAborted as y}from"../../../../core/promiseUtils.js";import{pt2px as b}from"../../../../core/screenUtils.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as S}from"../../../../geometry/projection/projectPointToVector.js";import{create as C,size as w,containsPoint as T,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as ee}from"../../../../symbols/support/materialUtils.js";import{defaultObjectPrimitive as D}from"../../../../symbols/support/primitives.js";import{objectSymbolLayerPrimitiveBoundingBox as te,objectSymbolLayerSizeWithResourceSize as O}from"../../../../symbols/support/symbolLayerUtils3D.js";import{VerticalOffsetParameters as ne}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as re}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ie}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as k}from"../../webgl-engine/materials/pbrUtils.js";import{initFastSymbolUpdatesState as A,updateFastSymbolUpdatesState as j,ConvertOptions as ae,evaluateModelTransformScale as M,evaluateModelTransform as N}from"../support/FastSymbolUpdates.js";import{estimateNumVerticesForLods as P,defaultSymbolLayerMemoryComplexity as oe}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as F,SampleElevationInfo as ce,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as ue}from"./emissiveUtils.js";import{Graphics3DLodInstanceGraphicLayer as I}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as L,nanFallbackColor as R}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as z,computeObjectScale as B,computeObjectRotation as V}from"./graphicUtils.js";import{makeLodResources as H}from"./lodResourceUtils.js";import{fetch as de}from"./objectResourceUtils.js";import{placePointOnGeometry as U,extendPointGraphicElevationContext as W}from"./pointUtils.js";import{isValidPrimitive as fe,primitiveLodResources as pe}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as me}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as he}from"./webStyleUtils.js";class G{constructor(e,t,n,r,i,a,o,s,c,l,u=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=n,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=s,this.extentPadding=c,this.physicallyBasedRenderingEnabled=l,this.pivotOffset=u}}class ge extends L{getCachedSize(){let[e,t,n]=this._resources==null?[1,1,1]:this._resources.symbolSize;return{width:e,depth:t,height:n}}constructor(e,t,n,r){super(e,t,n,r,_e(t)),this._resources=null,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=[],this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=n.physicallyBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){let e=z(this.symbolLayer);if(e)throw Error(e)}if(this._isPrimitive){let t=this.symbolLayer.resource,n=t&&fe(t?.primitive)?t.primitive:D;this._resources=await this._createResourcesForPrimitive(n,e)}else{let t=(await he(this.symbol.styleOrigin))?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(t,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicallyBasedRenderingChanged(),this.updateComplexity()}get extentPadding(){return this._resources==null?0:this._resources.extentPadding}get _isPrimitive(){return this._primitive!=null}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(e,t){let n=this.symbolLayer,r=C(te(e)),i=d(w(r)),o=d(O(i,n)),s=a(o),c=n.material?.emissive,l=(c?.source===`color`?c?.strength:void 0)??0,u={usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0,mrrFactors:k,ambient:f,diffuse:f,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:n.castShadows,emissiveStrengthFromSymbol:l,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass,normalType:1},p=!!u.usePBR,m=this.symbol;m.type===`point-3d`&&m.verticalOffset&&(u.verticalOffset=new ne(m.verticalOffset),u.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(u.screenSizePerspective=this.view.screenSizePerspective.parameters),u.externalColor=this._hasDrivenColorOrOpacity?R:this._materialColor?.toUnitRGBA()??g,this._fastUpdates=A(this._context.renderer,this._fastVisualVariableConvertOptions(r,o,i,null)),u.instanced=!0,this._fastUpdates?(Object.assign(u,this._fastUpdates.materialParameters),u.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(u.instancedColor=!0);let h=new ie(u,this._context.spherical);h.setParameters({cullFace:J(h.transparent)});let _=pe(e,h);if(!_)throw Error(`Unknown object symbol primitive: ${e}`);let v=await this._createStageResources(_,p,t);y(t);let b=await this._createLodRenderer(_,t);return new G(_,b,v,i,!1,!1,r,o,s,p)}async _createResourcesForUrl(e,t){let n={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},r={spherical:this._context.spherical,materialParameters:n,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=A(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParameters,this._fastUpdates.materialParameters),r.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(r.materialParameters.instancedColor=!0);let i=this.symbol;if(i.type===`point-3d`&&i.verticalOffset){let{screenLength:e,minWorldLength:t,maxWorldLength:n}=i.verticalOffset;r.materialParameters.verticalOffset={screenLength:b(e),minWorldLength:t||0,maxWorldLength:n??1/0},r.materialParameters.castShadows=!1}let o=this._context.physicallyBasedRenderingEnabled;r.signal=t,r.usePBR=o,r.useEmissive=this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result,r.skipHighLods=this._context.skipHighSymbolLods;let s=this.symbolLayer.material;r.materialParameters.emissiveStrengthFromSymbol=s?.emissive?.strength??1,r.materialParameters.emissiveSource=ee(s?.emissive?.source??`emissive`);let c=await de(e,r),l=c.isEsriSymbolResource,u=c.isWosr,f=H(c.lods),p=this._context,m=this._getExternalColorParameters(s),h=this.needsDrivenTransparentPass,g=f.getMaterials();g.forEach(e=>{e.setParameters({...m,drivenOpacity:h}),p.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});let _=c.referenceBoundingBox,v=d(w(_)),x=d(f.levels[0].pivotOffset),S=d(O(v,this.symbolLayer)),C=a(S),T=this._fastUpdates;j(T,this._context.renderer,this._fastVisualVariableConvertOptions(_,S,v,x))&&g.forEach(e=>e.setParameters(T.materialParameters));let E=await this._createStageResources(f,o,t);y(t);let D=await this._createLodRenderer(f,t);return new G(f,D,E,v,l,u,_,S,C,o,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,t,n){let r=this._context.stage,i=e.getMaterials();t!==this._context.physicallyBasedRenderingEnabled&&this.physicallyBasedRenderingChanged();let a=e.getTextures();return r.addTextures(a),this._addDisposeResource(()=>{a.forEach(e=>e.unload()),r.removeTextures(a)}),await Promise.all(a.map(e=>this._context.stage.schedule(()=>e.load(r.renderView.renderingContext),n))),y(n),{materials:i,textures:a,geometries:e.getEngineGeometries()}}async _createLodRenderer(e,t){let n=this._context.stage,i={layerViewUid:this._context.layerViewUid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},a=this._fastUpdates,o=new re({symbol:e,metadata:i,shaderTransformation:a?{applyTransform:(e,t,n)=>{e.getFeatureAttribute(t,Q),r(n,N(a.materialParameters,Q,n))},scaleFactor:(e,t,n)=>{t.getFeatureAttribute(n,Q),M(e,a.materialParameters,Q)}}:null},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{n.removeRenderPlugin(o),o.destroy()}),await n.addRenderPlugin(o,t),o}_getExternalColorParameters(e){let t={};if(t.externalColor=R,!this._drivenProperties.color&&e?.color!=null){let n=e.color.toUnitRGBA();this._drivenProperties.opacity&&(n[3]=NaN),t.externalColor=n}return t}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let n=U(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;let r=this.createElevationContextForGraphic(t),i=e.renderingInfo;return this._createAs3DShape(n,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(this._resources==null)return;let e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let n=0;n<t.length;n++){let r=t[n];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:J(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(this._resources==null)return;let e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(let t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,F)}slicePlaneEnabledChanged(){if(this._resources==null)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(let e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicallyBasedRenderingChanged(){if(this._resources==null)return!0;let{stageResources:e,isWosr:t}=this._resources;for(let n of e.materials)this._isPrimitive?n.setParameters({usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0}):t||n.setParameters({usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!1});return this._hasLoadedPBRTextures===!1&&this._context.physicallyBasedRenderingEnabled===!0?(this._hasLoadedPBRTextures=!0,!1):!0}applyRendererDiff(e,t){if(this._resources==null)return 0;let{stageResources:{materials:n},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:s}=this._resources;for(let c in e.diff)switch(c){case`visualVariables`:if(j(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,s))){for(let e of n)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}else return 0;break;default:return 0}return 2}computeComplexity(){if(this._resources==null)return super.computeComplexity();let e=this._resources.lodResources,t=P(e.levels),n=e.computeUsedMemory(),r={...oe(this.symbol,this.symbolLayer),resourceBytes:n};return new me({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return this._resources!=null}_createAs3DShape(e,t,n,r){if(!this._hasLodRenderer()||this._resources==null)return null;let i=this.getFastUpdateAttrValues(t),a=this._context.clippingExtent;if(S(e,Y,this._context.elevationProvider.spatialReference),a!=null&&!T(a,Y))return null;let o=q(n),s=this._computeGlobalTransform(e,n,Z,$),c=this._computeLocalTransform(this._resources,this.symbolLayer,t,X),l=this._resources.lodRenderer.instanceData,u=l.addInstance();this._instanceIndexToGraphicUid.set(u,r),l.setLocalTransform(u,c,!1),l.setGlobalTransform(u,s),i&&l.setFeatureAttribute(u,i),this._fastUpdates==null&&this._hasDrivenColorOrOpacity&&l.setColor(u,this._getDrivenUInt8ColorWithNaNSupport(t,this._materialColor,!this._isPrimitive));let d=this._context.stage.renderView.olidRenderHelper;if(d){let e=d.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid});l.setObjectAndLayerIdColor(u,e)}let f=new I(this,u,se,n,this._context.stage.view.state.highlightOrderMap);return o&&(f.alignedSampledElevation=$.sampledElevation),f.needsElevationUpdates=F(n.mode),W(f,e,this._context.elevationProvider),f}_computeGlobalTransform(e,t,n,r){return le(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),Y[0]=e.x,Y[1]=e.y,Y[2]=r.z,x(e.spatialReference,Y,n,this._context.renderCoordsHelper.spatialReference),n}_computeLocalTransform(t,n,r,i){return e(i),this._applyObjectRotationVisualVariables(r,!1,i),this._applyObjectRotation(n,!0,i),this._applyObjectScale(t,r,i),this._applyAnchor(t,n,i),i}_applyObjectScale(e,n,r){if(this._fastUpdates?.requiresShaderTransformation)return;let i=this._drivenProperties.size&&n.size?n.size.output:e.symbolSize,a=B(i,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);if(a[0]!==1||a[1]!==1||a[2]!==1)t(r,r,a);else return}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}updateGeometry(e,t){if(this._resources==null)return!0;let n=e.geometry;if(!n)return!1;let r=U(n);if(r==null)return!1;let i=this.getGeometryElevationMode(n),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,Z,$),q(a)&&(t.alignedSampledElevation=$.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,Z,!0),W(t,r,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!t.heading&&!t.tilt&&!t.roll&&!t.width&&!t.height&&!t.depth&&!t.anchor&&!t.anchorPosition||this._resources==null)return;let n=(e,t,n)=>(e!=null&&e.type===`complete`?e.newValue:t)??n,r=n(t.heading,this.symbolLayer.heading,0),i=n(t.tilt,this.symbolLayer.tilt,0),a=n(t.roll,this.symbolLayer.roll,0),o=n(t.width,this.symbolLayer.width,void 0),s=n(t.height,this.symbolLayer.height,void 0),c=n(t.depth,this.symbolLayer.depth,void 0),l=n(t.anchor,this.symbolLayer.anchor,void 0),u=n(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;let f={heading:r,tilt:i,roll:a,anchor:l,anchorPosition:u},p=this._resources;this.loadStatus===1&&e.symbolLayerStatePatches.push(()=>{p.symbolSize=d(O(p.resourceSize,{width:o,height:s,depth:c,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{let n=this._computeLocalTransform(p,f,t,X);p.lodRenderer.instanceData.setLocalTransform(e,n,!0)})}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue,i=r==null?_:r.toUnitRGBA();delete n.color;let a=this._resources;if(a==null)return;let o=this._isPrimitive;e.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)a.lodRenderer.instanceData.setColor(e,i);else{let e={externalColor:i};for(let t of a.stageResources.materials)t.setParameters(e),o&&t.setParameters({cullFace:J(t.transparent)})}})}_preparePatchEmissive(e,t){return ue(e,t,e=>{this._resources?.stageResources.materials.forEach(t=>{if(!this._isPrimitive){t.setParameters({emissiveStrengthFromSymbol:e??1});return}let n=this.symbolLayer.material?.emissive?.source===`color`;t.setParameters({emissiveStrengthFromSymbol:n?e??0:0})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_applyObjectRotationVisualVariables(e,t,n){this._fastUpdates?.requiresShaderTransformation&&t||V(e.heading?.output,e.tilt?.output,e.roll?.output,n)}_applyObjectRotation(e,t,n){this._fastUpdates?.requiresShaderTransformation&&t||V(e.heading,e.tilt,e.roll,n)}_applyAnchor(e,t,r){if(this._fastUpdates?.requiresShaderTransformation)return;let i=K(e.resourceBoundingBox,e.pivotOffset,t);i&&n(r,r,i)}_fastVisualVariableConvertOptions(e,t,n,r){let i=e==null?f:d(w(e)),a=e==null?p:K(e,r,this.symbolLayer),o=this._context.renderCoordsHelper.unitInMeters,s=B(t??void 0,t,n,o),c=m(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ae({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??f,unitInMeters:o,anchor:a,scale:s,rotation:c,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:s})}get _primitive(){let{resource:e}=this.symbolLayer;return e?.href==null?e?.primitive??D:null}_getFallbackOpacityAndColor(){return this._materialColor?.toUnitRGBA()??(this._isPrimitive?g:R)}get _materialColor(){return this.symbolLayer.material?.color}}function K(e,t,n){let r=h();switch(n.anchor){case`center`:s(r,E(e)),o(r,r);break;case`top`:{let t=E(e);u(r,-t[0],-t[1],-e[5]);break}case`bottom`:{let t=E(e);u(r,-t[0],-t[1],-e[2]);break}case`relative`:{let t=E(e),i=w(e),a=n.anchorPosition,s=a?m(a.x,a.y,a.z):p;c(r,i,s),l(r,r,t),o(r,r);break}default:t==null?s(r,p):o(r,t)}return r}function q(e){return e.mode!==`absolute-height`}function _e(e){return(e.material?.color?.a??1)===1&&e.resource?.href==null}function J(e){return e?0:2}const Y=h(),X=i(),Z=i(),Q=v(),$=new ce;export{ge as Graphics3DObjectSymbolLayer};
|
|
2
|
+
import{identity as e,scale as t,translate as n,copy as r}from"../../../../core/libs/gl-matrix-2/math/mat4.js";import{create as i}from"../../../../core/libs/gl-matrix-2/factories/mat4f64.js";import{length as a,negate as o,copy as s,multiply as c,add as l,set as u}from"../../../../core/libs/gl-matrix-2/math/vec3.js";import{fromArray as d,ONES as f,ZEROS as p,fromValues as m,create as h}from"../../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{ZEROS as g,ONES as _,create as v}from"../../../../core/libs/gl-matrix-2/factories/vec4f64.js";import{throwIfAborted as y}from"../../../../core/promiseUtils.js";import{pt2px as b}from"../../../../core/screenUtils.js";import{computeTranslationToOriginAndRotation as x}from"../../../../geometry/projection/computeTranslationToOriginAndRotation.js";import{projectPointToVector as S}from"../../../../geometry/projection/projectPointToVector.js";import{create as C,size as w,containsPoint as T,center as E}from"../../../../geometry/support/aaBoundingBox.js";import{getEmissiveMode as ee}from"../../../../symbols/support/materialUtils.js";import{defaultObjectPrimitive as D}from"../../../../symbols/support/primitives.js";import{objectSymbolLayerPrimitiveBoundingBox as te,objectSymbolLayerSizeWithResourceSize as O}from"../../../../symbols/support/symbolLayerUtils3D.js";import{VerticalOffsetParameters as ne}from"../../webgl-engine/core/shaderLibrary/attributes/VerticalOffset.glsl.js";import{LodRenderer as re}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{DefaultMaterial as ie}from"../../webgl-engine/materials/DefaultMaterial.js";import{schematicMRRFactors as k}from"../../webgl-engine/materials/pbrUtils.js";import{initFastSymbolUpdatesState as A,updateFastSymbolUpdatesState as j,ConvertOptions as ae,evaluateModelTransformScale as M,evaluateModelTransform as N}from"../support/FastSymbolUpdates.js";import{estimateNumVerticesForLods as P,defaultSymbolLayerMemoryComplexity as oe}from"./defaultSymbolComplexity.js";import{perLodInstanceElevationAligner as se}from"./ElevationAligners.js";import{needsElevationUpdates3D as F,SampleElevationInfo as ce,evaluateElevationInfoAtPoint as le}from"./elevationAlignmentUtils.js";import{preparePatchEmissiveStrength as ue}from"./emissiveUtils.js";import{Graphics3DLodInstanceGraphicLayer as I}from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as L,nanFallbackColor as R}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as z,computeObjectScale as B,computeObjectRotation as V}from"./graphicUtils.js";import{makeLodResources as H}from"./lodResourceUtils.js";import{fetch as de}from"./objectResourceUtils.js";import{placePointOnGeometry as U,extendPointGraphicElevationContext as W}from"./pointUtils.js";import{isValidPrimitive as fe,primitiveLodResources as pe}from"./primitiveObjectSymbolUtils.js";import{SymbolComplexity as me}from"./SymbolComplexity.js";import{getResourceUrlFromSymbolStyle as he}from"./webStyleUtils.js";class G{constructor(e,t,n,r,i,a,o,s,c,l,u=null){this.lodResources=e,this.lodRenderer=t,this.stageResources=n,this.resourceSize=r,this.isEsriSymbolResource=i,this.isWosr=a,this.resourceBoundingBox=o,this.symbolSize=s,this.extentPadding=c,this.physicallyBasedRenderingEnabled=l,this.pivotOffset=u}}class ge extends L{getCachedSize(){let[e,t,n]=this._resources==null?[1,1,1]:this._resources.symbolSize;return{width:e,depth:t,height:n}}constructor(e,t,n,r){super(e,t,n,r,_e(t)),this._resources=null,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=[],this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=n.physicallyBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){let e=z(this.symbolLayer);if(e)throw Error(e)}if(this._isPrimitive){let t=this.symbolLayer.resource,n=t&&fe(t?.primitive)?t.primitive:D;this._resources=await this._createResourcesForPrimitive(n,e)}else{let t=(await he(this.symbol.styleOrigin))?.href??this.symbolLayer.resource?.href;this._resources=await this._createResourcesForUrl(t,e)}this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicallyBasedRenderingChanged(),this.updateComplexity()}get extentPadding(){return this._resources==null?0:this._resources.extentPadding}get _isPrimitive(){return this._primitive!=null}get lodRenderer(){return this._resources?.lodRenderer}get materials(){return this._resources?.stageResources.materials??[]}async _createResourcesForPrimitive(e,t){let n=this.symbolLayer,r=C(te(e)),i=d(w(r)),o=d(O(i,n)),s=a(o),c=n.material?.emissive,l=(c?.source===`color`?c?.strength:void 0)??0,u={usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0,mrrFactors:k,ambient:f,diffuse:f,opacity:1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:n.castShadows,emissiveStrengthFromSymbol:l,emissiveSource:1,offsetTransparentBackfaces:!1,drivenOpacity:this.needsDrivenTransparentPass,normalType:1},p=!!u.usePBR,m=this.symbol;m.type===`point-3d`&&m.verticalOffset&&(u.verticalOffset=new ne(m.verticalOffset),u.castShadows=!1),this._context.screenSizePerspectiveEnabled&&(u.screenSizePerspective=this.view.screenSizePerspective.parameters),u.externalColor=this._hasDrivenColorOrOpacity?R:this._materialColor?.toUnitRGBA()??g,this._fastUpdates=A(this._context.renderer,this._fastVisualVariableConvertOptions(r,o,i,null)),u.instanced=!0,this._fastUpdates?(Object.assign(u,this._fastUpdates.materialParameters),u.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(u.instancedColor=!0);let h=new ie(u,this._context.spherical);h.setParameters({cullFace:J(h.transparent)});let _=pe(e,h);if(!_)throw Error(`Unknown object symbol primitive: ${e}`);let v=await this._createStageResources(_,p,t);y(t);let b=await this._createLodRenderer(_,t);return new G(_,b,v,i,!1,!1,r,o,s,p)}async _createResourcesForUrl(e,t){let n={instanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},r={spherical:this._context.spherical,materialParameters:n,cache:this._context.sharedResources.objectResourceCache,compressionOptions:{compressionTracker:this._context.compressionTracker,compressionCallback:()=>this.updateComplexity()}};this._fastUpdates=A(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParameters,this._fastUpdates.materialParameters),r.materialParameters.instancedFeatureAttribute=!0):this._hasDrivenColorOrOpacity&&(r.materialParameters.instancedColor=!0);let i=this.symbol;if(i.type===`point-3d`&&i.verticalOffset){let{screenLength:e,minWorldLength:t,maxWorldLength:n}=i.verticalOffset;r.materialParameters.verticalOffset={screenLength:b(e),minWorldLength:t||0,maxWorldLength:n??1/0},r.materialParameters.castShadows=!1}let o=this._context.physicallyBasedRenderingEnabled;r.signal=t,r.usePBR=o,r.useEmissive=this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result,r.skipHighLods=this._context.skipHighSymbolLods;let s=this.symbolLayer.material;r.materialParameters.emissiveStrengthFromSymbol=s?.emissive?.strength??1,r.materialParameters.emissiveSource=ee(s?.emissive?.source??`emissive`);let c=await de(e,r),l=c.isEsriSymbolResource,u=c.isWosr,f=H(c.lods),p=this._context,m=this._getExternalColorParameters(s),h=this.needsDrivenTransparentPass,g=f.getMaterials();g.forEach(e=>{e.setParameters({...m,drivenOpacity:h}),p.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:this.view.screenSizePerspective.parameters})});let _=c.referenceBoundingBox,v=d(w(_)),x=d(f.levels[0].pivotOffset),S=d(O(v,this.symbolLayer)),C=a(S),T=this._fastUpdates;j(T,this._context.renderer,this._fastVisualVariableConvertOptions(_,S,v,x))&&g.forEach(e=>e.setParameters(T.materialParameters));let E=await this._createStageResources(f,o,t);y(t);let D=await this._createLodRenderer(f,t);return new G(f,D,E,v,l,u,_,S,C,o,x)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,t,n){let r=this._context.stage,i=e.getMaterials();t!==this._context.physicallyBasedRenderingEnabled&&this.physicallyBasedRenderingChanged();let a=e.getTextures();return r.addTextures(a),this._addDisposeResource(()=>{a.forEach(e=>e.unload()),r.removeTextures(a)}),await Promise.all(a.map(e=>this._context.stage.schedule(()=>e.load(r.renderView.renderingContext),n))),y(n),{materials:i,textures:a,geometries:e.getEngineGeometries()}}async _createLodRenderer(e,t){let n=this._context.stage,i={layerViewUid:this._context.layerViewUid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},a=this._fastUpdates,o=new re({symbol:e,metadata:i,shaderTransformation:a?{applyTransform:(e,t,n)=>{e.getFeatureAttribute(t,Q),r(n,N(a.materialParameters,Q,n))},scaleFactor:(e,t,n)=>{t.getFeatureAttribute(n,Q),M(e,a.materialParameters,Q)}}:null},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource(()=>{n.removeRenderPlugin(o),o.destroy()}),await n.addRenderPlugin(o,t),o}_getExternalColorParameters(e){let t={};if(t.externalColor=R,!this._drivenProperties.color&&e?.color!=null){let n=e.color.toUnitRGBA();this._drivenProperties.opacity&&(n[3]=NaN),t.externalColor=n}return t}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach(e=>e()),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){let t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let n=U(t.geometry);if(n==null)return this.logger.warn(`unsupported geometry type for object symbol: ${t.geometry.type}`),null;let r=this.createElevationContextForGraphic(t),i=e.renderingInfo;return this._createAs3DShape(n,i,r,t.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(this._resources==null)return;let e=this._getLayerOpacity(),t=this._resources.stageResources.materials;for(let n=0;n<t.length;n++){let r=t[n];r.setParameters({layerOpacity:e}),this._isPrimitive&&r.setParameters({cullFace:J(r.transparent)})}}layerScreenSizePerspectiveChanged(){if(this._resources==null)return;let e=this._context.screenSizePerspectiveEnabled?this.view.screenSizePerspective.parameters:null;for(let t of this._resources.stageResources.materials)t.setParameters({screenSizePerspective:e})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,F)}slicePlaneEnabledChanged(){if(this._resources==null)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(let e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicallyBasedRenderingChanged(){if(this._resources==null)return!0;let{stageResources:e,isWosr:t}=this._resources;for(let n of e.materials)this._isPrimitive?n.setParameters({usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!0}):t||n.setParameters({usePBR:this._context.physicallyBasedRenderingEnabled,isSchematic:!1});return this._hasLoadedPBRTextures===!1&&this._context.physicallyBasedRenderingEnabled===!0?(this._hasLoadedPBRTextures=!0,!1):!0}applyRendererDiff(e,t){if(this._resources==null)return 0;let{stageResources:{materials:n},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:s}=this._resources;for(let c in e.diff)if(c===`visualVariables`){if(j(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,s))){for(let e of n)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}else return 0}else return 0;return 2}computeComplexity(){if(this._resources==null)return super.computeComplexity();let e=this._resources.lodResources,t=P(e.levels),n=e.computeUsedMemory(),r={...oe(this.symbol,this.symbolLayer),resourceBytes:n};return new me({verticesPerFeature:t,memory:r})}_hasLodRenderer(){return this._resources!=null}_createAs3DShape(e,t,n,r){if(!this._hasLodRenderer()||this._resources==null)return null;let i=this.getFastUpdateAttrValues(t),a=this._context.clippingExtent;if(S(e,Y,this._context.elevationProvider.spatialReference),a!=null&&!T(a,Y))return null;let o=q(n),s=this._computeGlobalTransform(e,n,Z,$),c=this._computeLocalTransform(this._resources,this.symbolLayer,t,X),l=this._resources.lodRenderer.instanceData,u=l.addInstance();this._instanceIndexToGraphicUid.set(u,r),l.setLocalTransform(u,c,!1),l.setGlobalTransform(u,s),i&&l.setFeatureAttribute(u,i),this._fastUpdates==null&&this._hasDrivenColorOrOpacity&&l.setColor(u,this._getDrivenUInt8ColorWithNaNSupport(t,this._materialColor,!this._isPrimitive));let d=this._context.stage.renderView.olidRenderHelper;if(d){let e=d.getObjectAndLayerIdColor({graphicUid:r,layerViewUid:this._context.layerViewUid});l.setObjectAndLayerIdColor(u,e)}let f=new I(this,u,se,n,this._context.stage.view.state.highlightOrderMap);return o&&(f.alignedSampledElevation=$.sampledElevation),f.needsElevationUpdates=F(n.mode),W(f,e,this._context.elevationProvider),f}_computeGlobalTransform(e,t,n,r){return le(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),Y[0]=e.x,Y[1]=e.y,Y[2]=r.z,x(e.spatialReference,Y,n,this._context.renderCoordsHelper.spatialReference),n}_computeLocalTransform(t,n,r,i){return e(i),this._applyObjectRotationVisualVariables(r,!1,i),this._applyObjectRotation(n,!0,i),this._applyObjectScale(t,r,i),this._applyAnchor(t,n,i),i}_applyObjectScale(e,n,r){if(this._fastUpdates?.requiresShaderTransformation)return;let i=this._drivenProperties.size&&n.size?n.size.output:e.symbolSize,a=B(i,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);if(a[0]!==1||a[1]!==1||a[2]!==1)t(r,r,a);else return}prepareSymbolLayerPatch(e){if(e.diff.type!==`partial`)return;let t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t),this._preparePatchEmissive(e,t)}updateGeometry(e,t){if(this._resources==null)return!0;let n=e.geometry;if(!n)return!1;let r=U(n);if(r==null)return!1;let i=this.getGeometryElevationMode(n),{elevationContext:a}=t;return a.mode===i&&(a.updateFeatureExpressionFeature(e,this._context.layer),this._computeGlobalTransform(r,a,Z,$),q(a)&&(t.alignedSampledElevation=$.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(t.instanceIndex,Z,!0),W(t,r,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!t.heading&&!t.tilt&&!t.roll&&!t.width&&!t.height&&!t.depth&&!t.anchor&&!t.anchorPosition||this._resources==null)return;let n=(e,t,n)=>(e!=null&&e.type===`complete`?e.newValue:t)??n,r=n(t.heading,this.symbolLayer.heading,0),i=n(t.tilt,this.symbolLayer.tilt,0),a=n(t.roll,this.symbolLayer.roll,0),o=n(t.width,this.symbolLayer.width,void 0),s=n(t.height,this.symbolLayer.height,void 0),c=n(t.depth,this.symbolLayer.depth,void 0),l=n(t.anchor,this.symbolLayer.anchor,void 0),u=n(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;let f={heading:r,tilt:i,roll:a,anchor:l,anchorPosition:u},p=this._resources;this.loadStatus===1&&e.symbolLayerStatePatches.push(()=>{p.symbolSize=d(O(p.resourceSize,{width:o,height:s,depth:c,isPrimitive:this._isPrimitive}))}),e.graphics3DGraphicPatches.push(({instanceIndex:e},t)=>{let n=this._computeLocalTransform(p,f,t,X);p.lodRenderer.instanceData.setLocalTransform(e,n,!0)})}_preparePatchColor(e,t){if(!t.material||t.material.type!==`partial`)return;let n=t.material.diff;if(!n.color||n.color.type!==`complete`||n.color.newValue==null||n.color.oldValue==null)return;let r=n.color.newValue,i=r==null?_:r.toUnitRGBA();delete n.color;let a=this._resources;if(a==null)return;let o=this._isPrimitive;e.graphics3DGraphicPatches.push(({instanceIndex:e})=>{if(this._hasDrivenColorOrOpacity)a.lodRenderer.instanceData.setColor(e,i);else{let e={externalColor:i};for(let t of a.stageResources.materials)t.setParameters(e),o&&t.setParameters({cullFace:J(t.transparent)})}})}_preparePatchEmissive(e,t){return ue(e,t,e=>{this._resources?.stageResources.materials.forEach(t=>{if(!this._isPrimitive){t.setParameters({emissiveStrengthFromSymbol:e??1});return}let n=this.symbolLayer.material?.emissive?.source===`color`;t.setParameters({emissiveStrengthFromSymbol:n?e??0:0})})},this.view.stage.renderView.renderingContext.driverTest.floatBufferBlend.result)}_applyObjectRotationVisualVariables(e,t,n){this._fastUpdates?.requiresShaderTransformation&&t||V(e.heading?.output,e.tilt?.output,e.roll?.output,n)}_applyObjectRotation(e,t,n){this._fastUpdates?.requiresShaderTransformation&&t||V(e.heading,e.tilt,e.roll,n)}_applyAnchor(e,t,r){if(this._fastUpdates?.requiresShaderTransformation)return;let i=K(e.resourceBoundingBox,e.pivotOffset,t);i&&n(r,r,i)}_fastVisualVariableConvertOptions(e,t,n,r){let i=e==null?f:d(w(e)),a=e==null?p:K(e,r,this.symbolLayer),o=this._context.renderCoordsHelper.unitInMeters,s=B(t??void 0,t,n,o),c=m(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ae({supports:{size:!0,color:!0,rotation:!0,opacity:!1},modelSize:i,symbolSize:t??f,unitInMeters:o,anchor:a,scale:s,rotation:c,fallbackColor:this._getFallbackOpacityAndColor(),fallbackSize:s})}get _primitive(){let{resource:e}=this.symbolLayer;return e?.href==null?e?.primitive??D:null}_getFallbackOpacityAndColor(){return this._materialColor?.toUnitRGBA()??(this._isPrimitive?g:R)}get _materialColor(){return this.symbolLayer.material?.color}}function K(e,t,n){let r=h();switch(n.anchor){case`center`:s(r,E(e)),o(r,r);break;case`top`:{let t=E(e);u(r,-t[0],-t[1],-e[5]);break}case`bottom`:{let t=E(e);u(r,-t[0],-t[1],-e[2]);break}case`relative`:{let t=E(e),i=w(e),a=n.anchorPosition,s=a?m(a.x,a.y,a.z):p;c(r,i,s),l(r,r,t),o(r,r);break}default:t==null?s(r,p):o(r,t)}return r}function q(e){return e.mode!==`absolute-height`}function _e(e){return(e.material?.color?.a??1)===1&&e.resource?.href==null}function J(e){return e?0:2}const Y=h(),X=i(),Z=i(),Q=v(),$=new ce;export{ge as Graphics3DObjectSymbolLayer};
|