@arcgis/core 4.27.0-next.20230321 → 4.27.0-next.20230323
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/analysis/LineOfSightAnalysisObserver.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/02b6227c156ee0d8eb66.js +1 -0
- package/assets/esri/core/workers/chunks/{7e0c65aa61c2ff0c3504.js → 1c98b92933a48cf96c1e.js} +1 -1
- package/assets/esri/core/workers/chunks/{a27951dbe83c63f9d01a.js → 26bc91a9d9d7345a3eba.js} +1 -1
- package/assets/esri/core/workers/chunks/321f272d4c7ed6b0cb46.js +1 -0
- package/assets/esri/core/workers/chunks/{a09cc8e2ff43fe4afa04.js → 375628de4cfc71cb41c1.js} +1 -1
- package/assets/esri/core/workers/chunks/47bd558e2ce89f47f908.js +1 -0
- package/assets/esri/core/workers/chunks/4cb62855bb1ae608bfde.js +1 -0
- package/assets/esri/core/workers/chunks/4f0c2b6b200bf8222fd7.js +1 -0
- package/assets/esri/core/workers/chunks/5252f3cc244204edc299.js +1 -0
- package/assets/esri/core/workers/chunks/6f952a6464cf9e62dbac.js +1098 -0
- package/assets/esri/core/workers/chunks/76d6c1fc25f02bcf258e.js +1 -0
- package/assets/esri/core/workers/chunks/{d6ec7682de8fad9718e9.js → 77dccfaf1f9e778973b3.js} +1 -1
- package/assets/esri/core/workers/chunks/{c5d872adce711ec61ede.js → 8980c5dc389c27368b73.js} +1 -1
- package/assets/esri/core/workers/chunks/{6acaf28cba5d49a98fb6.js → 91b292f310f06a0cbf72.js} +1 -1
- package/assets/esri/core/workers/chunks/9bac27976e7a71268b7b.js +1 -0
- package/assets/esri/core/workers/chunks/{ff9efa829497557ec26a.js → aa4640a0207e0be224e2.js} +1 -1
- package/assets/esri/core/workers/chunks/{81a6f4b43e047c3395c0.js → aebc5091bd4159197ce0.js} +1 -1
- package/assets/esri/core/workers/chunks/{c8cd3fde6d8d43ddb954.js → b6cdf4daf07d9e55f61e.js} +1 -1
- package/assets/esri/core/workers/chunks/{6b14673a4afd6ef81487.js → c76cabd2d2510a653dff.js} +1 -1
- package/assets/esri/core/workers/chunks/{4be7647605300e07e843.js → c90fff7e28ba5b443b11.js} +1 -1
- package/assets/esri/core/workers/chunks/{e637e47000f4dc48054d.js → cc7f4fd20443a2acf0f1.js} +1 -1
- package/assets/esri/core/workers/chunks/d19e9fab4f4fb765c6a3.js +1 -0
- package/assets/esri/core/workers/chunks/d9ef4891c8b0bdd90f5b.js +1 -0
- package/assets/esri/core/workers/chunks/{d92d6a43270fb0d366b4.js → de4f5c48efbcee82c3c1.js} +1 -1
- package/assets/esri/core/workers/chunks/f6e7948075b3742b4ef9.js +1 -0
- package/assets/esri/core/workers/chunks/{32f9b488915a4a8864e5.js → f8b9e0c1671e55b61904.js} +1 -1
- package/assets/esri/views/3d/analysis/Slice/images/heading-rotate.ts.svg +7 -28
- package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.ts.svg +11 -0
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ar.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bg.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_bs.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ca.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_cs.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_da.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_de.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_el.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_en.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_es.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_et.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fi.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_fr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_he.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_hu.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_id.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_it.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ja.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ko.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lt.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_lv.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nb.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_nl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-BR.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_pt-PT.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ro.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_ru.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sk.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sl.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_sv.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_th.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_tr.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_uk.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_vi.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-CN.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-HK.json +1 -1
- package/assets/esri/widgets/BasemapLayerList/t9n/BasemapLayerList_zh-TW.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ar.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bg.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_bs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ca.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_cs.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_da.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_de.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_el.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_es.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_et.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_fr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_he.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_hu.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_id.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_it.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ja.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ko.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lt.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_lv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nb.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_nl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-BR.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_pt-PT.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ro.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_ru.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sl.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_sv.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_th.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_tr.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_uk.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_vi.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-CN.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-HK.json +1 -1
- package/assets/esri/widgets/Editor/t9n/Editor_zh-TW.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ar.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_bg.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_bs.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ca.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_cs.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_da.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_de.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_el.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_en.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_es.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_et.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_fi.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_fr.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_he.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_hr.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_hu.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_id.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_it.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ja.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ko.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_lt.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_lv.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_nb.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_nl.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_pl.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_pt-BR.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_pt-PT.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ro.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_ru.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_sk.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_sl.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_sr.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_sv.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_th.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_tr.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_uk.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_vi.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_zh-CN.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_zh-HK.json +1 -1
- package/assets/esri/widgets/LayerList/t9n/LayerList_zh-TW.json +1 -1
- package/chunks/ComponentShader.glsl.js +1 -1
- package/chunks/DefaultMaterial.glsl.js +4 -4
- package/chunks/vec42.js +1 -1
- package/core/Loadable.js +1 -1
- package/core/accessorSupport/Property.js +1 -1
- package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
- package/core/analysisThemeUtils.js +1 -1
- package/core/maybe.js +1 -1
- package/geometry/support/buffer/math/vec4.js +1 -1
- package/interfaces.d.ts +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/LineOfSightLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/graphics/sources/connections/GeoEventConnection.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/mixins/RefreshableLayer.js +1 -1
- package/layers/support/SceneFilter.js +1 -1
- package/layers/support/SceneModifications.js +1 -1
- package/layers/support/rasterFunctions/clipUtils.js +1 -1
- package/layers/support/rasterFunctions/stretchUtils.js +1 -1
- package/package.json +1 -1
- package/portal/PortalItemResource.js +1 -1
- package/portal/support/resourceUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/support/utils.js +1 -1
- package/views/2d/engine/vectorTiles/TileHandler.js +1 -1
- package/views/2d/viewpointUtils.js +1 -1
- package/views/3d/analysis/Dimension/LengthDimensionSubTool.js +1 -1
- package/views/3d/analysis/Dimension/lengthDimensionManipulatorUtils.js +1 -1
- package/views/3d/analysis/Dimension/settings.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
- package/views/3d/analysis/Slice/images/Factory.js +1 -1
- package/views/3d/analysis/Slice/images/generateTextures.js +1 -1
- package/views/3d/analysis/Slice/images/heading-rotate-svg.js +1 -1
- package/views/3d/analysis/Slice/images/tilt-rotate-svg.js +5 -0
- package/views/3d/analysis/Slice/settings.js +5 -0
- package/views/3d/analysis/Slice/sliceToolConfig.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/environment/Stars.js +1 -1
- package/views/3d/interactive/Manipulator3D.js +1 -1
- package/views/3d/interactive/editingTools/transformGraphic/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/manipulatorUtils.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudLayerView3D.js +1 -1
- package/views/3d/layers/PointCloudWorker.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.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/Graphics3DTextSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SOverrides.js +1 -1
- package/views/3d/layers/i3s/PointCloudRendererUtil.js +1 -1
- package/views/3d/layers/i3s/PointCloudWorkerUtil.js +1 -1
- package/views/3d/layers/i3s/PointGraphic.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/controllers/SurfaceCollisionCorrectionController.js +1 -1
- package/views/3d/terrain/GeometryState.js +1 -1
- package/views/3d/terrain/PatchGeometry.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/TileAgent.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentMaterial.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/NormalAttribute.glsl.js +6 -5
- package/views/3d/webgl-engine/core/shaderLibrary/attributes/VertexNormal.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +11 -11
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ComputeShadingNormal.glsl.js +1 -1
- package/views/3d/webgl-engine/lib/AnimationTimeStep.js +1 -1
- package/views/3d/webgl-engine/lib/AttributeArray.js +1 -1
- package/views/3d/webgl-engine/lib/DefaultVertexAttributeLocations.js +1 -1
- package/views/3d/webgl-engine/lib/Normals.js +5 -0
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/internal/bufferWriterUtils.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/shaders/RealisticTreeTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/TerrainTechniqueConfiguration.js +1 -1
- package/views/LayerViewManager.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/layers/SceneLayerView.js +1 -1
- package/views/support/colorUtils.js +1 -1
- package/views/webgl/ShaderTranspiler.js +1 -1
- package/widgets/BasemapLayerList.js +1 -1
- package/widgets/Daylight/DaylightViewModel.js +1 -1
- package/widgets/Expand.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/LayerList.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0487ab23a20ec356ab4c.js +0 -1
- package/assets/esri/core/workers/chunks/29ee4f14602caf6967e4.js +0 -1
- package/assets/esri/core/workers/chunks/2c0775541cfec9d43acb.js +0 -1
- package/assets/esri/core/workers/chunks/4879164b48da9ad4547a.js +0 -1
- package/assets/esri/core/workers/chunks/69060e5cffc19e76062a.js +0 -1
- package/assets/esri/core/workers/chunks/87edeb09a948122fa030.js +0 -1
- package/assets/esri/core/workers/chunks/92951b85676df776961f.js +0 -1100
- package/assets/esri/core/workers/chunks/a71a5c8a9aa302bf6f01.js +0 -1
- package/assets/esri/core/workers/chunks/ad5c61daaed286c74982.js +0 -1
- package/assets/esri/core/workers/chunks/bc002e4dff8859571a7a.js +0 -1
- package/assets/esri/core/workers/chunks/ef2d3e84cd58df5f80af.js +0 -1
- package/assets/esri/core/workers/chunks/fec5e55e0fbf1710e22d.js +0 -1
- package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.svg +0 -80
- package/assets/esri/views/3d/analysis/Slice/images/tilt-rotate.ts.png +0 -0
- package/views/3d/analysis/Slice/images/tilt-rotate-png.js +0 -5
- package/views/3d/webgl-engine/core/shaderLibrary/util/DecodeNormal.glsl.js +0 -8
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import{get as i,releaseMaybe as s}from"../../../../core/maybe.js";import{throwIfAbortError as a,throwIfAborted as o}from"../../../../core/promiseUtils.js";import{pt2px as n,px2pt as l}from"../../../../core/screenUtils.js";import{dataComponents as c}from"../../../../core/urlUtils.js";import{c as h}from"../../../../chunks/mat4f64.js";import{f as m,a as u}from"../../../../chunks/vec2f64.js";import{f as d}from"../../../../chunks/vec3f64.js";import{f as _,c as p}from"../../../../chunks/vec4f64.js";import{projectPointToVector as f}from"../../../../geometry/projection.js";import{containsPoint as y}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as g}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as x}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as S}from"../../../../symbols/support/utils.js";import b from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as v}from"./constants.js";import{perObjectElevationAligner as z}from"./ElevationAligners.js";import{SymbolUpdateType as P,elevationModeChangeUpdateType as R,needsElevationUpdates2D as C}from"./elevationAlignmentUtils.js";import{ElevationContext as M}from"./ElevationContext.js";import j from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as I}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as w}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as O}from"./graphicUtils.js";import{ApplyRendererDiffResult as T}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as U}from"./placementUtils.js";import{placePointOnGeometry as E,createStageObject as L,extendPointGraphicElevationContext as D}from"./pointUtils.js";import{initFastSymbolUpdatesState as F,updateFastSymbolUpdatesState as A,evaluateModelTransform as G,ConvertOptions as V}from"../support/FastSymbolUpdates.js";import{createTexture as B,DEFAULT_SYMBOL_SIZE_RATIO as N,DEFAULT_TEX_SIZE as q}from"../../support/engineContent/sdfPrimitives.js";import{DRAPED_Z as H}from"../../terrain/OverlayRenderer.js";import{PowerOfTwoResizeMode as k}from"../../webgl-engine/lib/basicInterfaces.js";import{createPointGeometry as W}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as $}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as J}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as Z}from"../../webgl-engine/materials/HUDMaterial.js";import K from"../../../../symbols/CIMSymbol.js";const Q=h(),X=d(0,0,1),Y=16,ee=1.5,te=N,re=[te/2,te/2,1-te/2,1-te/2],ie=[q*te,q*te];class se extends w{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=S(this.symbolLayer),i=c(r);i&&"application/json"===i.mediaType?await this._prepareResourcesCIM(t,JSON.parse(i.data),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=O(this._getIconSize());if(e)throw new r("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?n(e.size):Y);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let r=""===t?null:this._cimSymbolTextures.get(t);if(!r){const i={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol3D(this._cimLayers,e,"esriGeometryPoint",i,void 0,void 0);this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height,powerOfTwoResizeMode:k.PAD};r=new J(s.imageData,a),this._cimSymbolTextures.set(t,r),this._context.stage.add(r)}return r}_computeSize(e,t){const r=e.width/e.height;return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(ae(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:n(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(oe(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>B(t)));this._texture=r.texture,this._releaseTexture=r,e.textureId=this._texture.id}e.textureIsSignedDistanceField=!0,e.distanceFieldBoundingBox=re;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/te,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,i,s){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(i,n,{signal:s}));if(!1===l.ok){a(l.error);throw new r("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${i})`)}this._releaseTexture=l.value;const c=l.value.texture,h=c.params;this._size=this._computeSize(h,o),e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){const i=new K({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;o(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let a,n;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol(i,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:r}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,r=await g(t,this._context.layer.spatialReference,s);n=(e,t,i)=>{const s=b(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}else a=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=a||n||1;const l=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];o(r);const c=this._context.layer.fieldsIndex;this._cimRequiredFields=l.map((e=>c.get(e).name)),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 this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||x}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline&&null!=t.outline.size)return Math.max(n(t.outline.size),0);return e=oe(this._getPrimitive())?ee:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,s=i(r,"outline","color");if(null!=s){const r=e.toUnitRGB(s),i=s.a*t;return[r[0],r[1],r[2],i]}return[0,0,0,0]}_getFillColor(){if(oe(this._getPrimitive()))return v;const e=null==this._getPrimitive(),t=i(this.symbolLayer,"material","color");return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?m((t.x||0)+.5,.5-(t.y||0)):e in U?U[e]:U.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new Z(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=F(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._material=new Z(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=s(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=n(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage),i=[e.params.width,e.params.height]}else i=this._size,r=this._material;const s=E(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,o=this._getVertexOpacityAndColor(a);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(a,e)}n*=this._symbolTextureRatio;const l=m(i[0]*n,i[1]*n),c=this.setGraphicElevationContext(t,new M);return this.ensureDrapedStatus("on-the-ground"===c.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,o,l,e.layer.uid):this._createAs3DShape(t,s,r,o,l,c,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=R(se.elevationModeChangeTypes,r,i);if(s!==P.UPDATE)return s;const a=C(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return T.RecreateSymbol;if(!A(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return T.RecreateSymbol;null!=this._material&&this._material.setParameters(this._fastUpdates.materialParameters)}return T.FastUpdate}_defaultElevationInfoNoZ(){return ne}_createAs3DShape(e,t,r,i,s,a,o){const n=this.getFastUpdateAttrValues(e),l=n&&this._fastUpdates?e=>G(this._fastUpdates.materialParameters,n,e):void 0,c=this._context.layer.uid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:c}),m=W(r,X,null,i,s,le,null,n,h),u=L(this._context,t,m,a,o,l);if(null==u)return null;const d=new I(this,u.object,[m],null,null,z,a);return d.alignedSampledElevation=u.sampledElevation,d.needsElevationUpdates=C(a.mode)||"absolute-height"===a.mode,d.getScreenSize=this._createScreenSizeGetter(s,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),D(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,a){r.renderPriority=this._renderPriority;const o=p();f(t,o,this._context.overlaySR),o[2]=H;const n=this._context.clippingExtent;if(null!=n&&!y(n,o))return null;const l=this.getFastUpdateAttrValues(e),c=l&&this._fastUpdates?e=>G(this._fastUpdates.materialParameters,l,e):void 0,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),m=W(r,X,o,i,s,null,null,l,h),u=new $(m,{layerUid:a,graphicUid:e.uid,shaderTransformer:c}),d=new j(this,[u],null,this._context.drapeSourceRenderer);return d.getScreenSize=this._createScreenSizeGetter(s,c),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),d}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=u())=>{const a=t(Q);return e[0]=a[0]*i+r,e[1]=a[5]*s+r,e}}{const t=e[0]/this._symbolTextureRatio+r,i=e[1]/this._symbolTextureRatio+r;return(e=u())=>(e[0]=t,e[1]=i,e)}}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=d(e,e,e),r=l(1),i=e*r,s=d(i,i,i);return new V({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_getGraphicHash(e){let t="";for(const r of this._cimRequiredFields)t+=r+e.attributes[r];return t}_forEachMaterial(e){null!=this._material&&e(this._material),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._material}}}function ae(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function oe(e){return null!=e&&("cross"===e||"x"===e)}se.PRIMITIVE_SIZE=ie,se.elevationModeChangeTypes={definedChanged:P.UPDATE,staysOnTheGround:P.NONE,onTheGroundChanged:P.RECREATE};const ne={mode:"relative-to-ground",offset:0},le=_(0,0,0,1);export{se as Graphics3DIconSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../symbols.js";import{result as t}from"../../../../core/asyncUtils.js";import r from"../../../../core/Error.js";import{releaseMaybe as i}from"../../../../core/maybe.js";import{throwIfAbortError as s,throwIfAborted as a}from"../../../../core/promiseUtils.js";import{pt2px as o,px2pt as n}from"../../../../core/screenUtils.js";import{dataComponents as l}from"../../../../core/urlUtils.js";import{c}from"../../../../chunks/mat4f64.js";import{f as h,a as m}from"../../../../chunks/vec2f64.js";import{f as u}from"../../../../chunks/vec3f64.js";import{f as d,c as _}from"../../../../chunks/vec4f64.js";import{projectPointToVector as p}from"../../../../geometry/projection.js";import{containsPoint as f}from"../../../../geometry/support/aaBoundingBox.js";import{createRendererExpression as y}from"../../../../support/arcadeOnDemand.js";import{defaultPrimitive as g}from"../../../../symbols/support/IconSymbol3DLayerResource.js";import{getIconHref as x}from"../../../../symbols/support/utils.js";import S from"../../../2d/arcade/callExpressionWithFeature.js";import{TRANSPARENT_UNIT as b}from"./constants.js";import{perObjectElevationAligner as v}from"./ElevationAligners.js";import{SymbolUpdateType as z,elevationModeChangeUpdateType as P,needsElevationUpdates2D as R}from"./elevationAlignmentUtils.js";import{ElevationContext as C}from"./ElevationContext.js";import M from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as j}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as I}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as w}from"./graphicUtils.js";import{ApplyRendererDiffResult as O}from"./interfaces.js";import{namedAnchorToHUDMaterialAnchorPos as T}from"./placementUtils.js";import{placePointOnGeometry as U,createStageObject as E,extendPointGraphicElevationContext as L}from"./pointUtils.js";import{initFastSymbolUpdatesState as D,updateFastSymbolUpdatesState as F,evaluateModelTransform as A,ConvertOptions as G}from"../support/FastSymbolUpdates.js";import{createTexture as V,DEFAULT_SYMBOL_SIZE_RATIO as B,DEFAULT_TEX_SIZE as N}from"../../support/engineContent/sdfPrimitives.js";import{DRAPED_Z as q}from"../../terrain/OverlayRenderer.js";import{PowerOfTwoResizeMode as H}from"../../webgl-engine/lib/basicInterfaces.js";import{createPointGeometry as k}from"../../webgl-engine/lib/GeometryUtil.js";import{RenderGeometry as W}from"../../webgl-engine/lib/RenderGeometry.js";import{Texture as $}from"../../webgl-engine/lib/Texture.js";import{HUDMaterial as J}from"../../webgl-engine/materials/HUDMaterial.js";import Z from"../../../../symbols/CIMSymbol.js";const K=c(),Q=u(0,0,1),X=16,Y=1.5,ee=B,te=[ee/2,ee/2,1-ee/2,1-ee/2],re=[N*ee,N*ee];class ie extends I{getCachedSize(){return{size:this._getIconSize()}}constructor(e,t,r,i){super(e,t,r,i),this._cimLayers=null,this._cimSymbolMaterials=new Map,this._cimSymbolTextures=new Map,this._cimMaterialParametersInfo=null,this._cimRequiredFields=null,this._cimScaleFactorOrFunction=null,this._size=null,this._symbolTextureRatio=1,this._outlineSize=0,this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!0}}async doLoad(e){this._validateOrThrow();const t=this._prepareMaterialParameters(),r=this._getPrimitive();if(null!=r)this._prepareResourcesPrimitive(t,r);else{const r=x(this.symbolLayer),i=l(r);i&&"application/json"===i.mediaType?await this._prepareResourcesCIM(t,JSON.parse(i.data),e):await this._prepareResourcesHref(t,r,e)}}_validateOrThrow(){if(this._drivenProperties.size)return;const e=w(this._getIconSize());if(e)throw new r("graphics3diconsymbollayer:invalid-size",e)}_getIconSize(){const e=this.symbolLayer,t=Math.round(null!=e.size?o(e.size):X);return this._drivenProperties.size?Math.max(t,64):t}_generateTextureCIM(e){const t=this._getGraphicHash(e);let r=""===t?null:this._cimSymbolTextures.get(t);if(!r){const i={scaleFactor:this._cimScaleFactorOrFunction},s=this._context.sharedResources.cimSymbolRasterizer.rasterizeCIMSymbol3D(this._cimLayers,e,"esriGeometryPoint",i,void 0,void 0);this._cimMaterialParametersInfo.anchorPosition=this._getAnchorPos("relative",s.anchorPosition);const a={width:s.imageData.width,height:s.imageData.height,powerOfTwoResizeMode:H.PAD};r=new $(s.imageData,a),this._cimSymbolTextures.set(t,r),this._context.stage.add(r)}return r}_computeSize(e,t){const r=e.width/e.height;return r>1?[t,Math.round(t/r)]:[Math.round(t*r),t]}_prepareMaterialParameters(){const e={anchorPosition:this._getAnchorPos(this.symbolLayer.anchor,this.symbolLayer.anchorPosition)},t=this.symbol;if(se(t)){const{screenLength:r,minWorldLength:i,maxWorldLength:s}=t.verticalOffset;e.verticalOffset={screenLength:o(r),minWorldLength:i||0,maxWorldLength:null!=s?s:1/0}}return this._context.screenSizePerspectiveEnabled&&(e.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),e.occlusionTest=!0,e.hasSlicePlane=this._context.slicePlaneEnabled,e}_prepareResourcesPrimitive(e,t){const r=this._getOutlineSize();if(ae(t)&&0===r)throw new Error("Nothing to render");if(this._outlineSize=r,e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,null!=this._context.sharedResources.textures){const r=this._context.sharedResources.textures.fromData(`${t}-icon`,(()=>V(t)));this._texture=r.texture,this._releaseTexture=r,e.textureId=this._texture.id}e.textureIsSignedDistanceField=!0,e.distanceFieldBoundingBox=te;const i=this._getIconSize();this._size=[i,i],this._symbolTextureRatio=1/ee,this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesHref(e,i,a){this._outlineSize=this._getOutlineSize(),e.color=this._getFillColor(),e.outlineColor=this._getOutlineColor(),e.outlineSize=this._outlineSize,e.textureIsSignedDistanceField=!1;const o=this._getIconSize(),n=o*this._context.graphicsCoreOwner.view.state.rasterPixelRatio;if(null!=this._context.sharedResources.textures){const l=await t(this._context.sharedResources.textures.fromUrl(i,n,{signal:a}));if(!1===l.ok){s(l.error);throw new r("graphics3diconsymbollayer:request-failed",`Failed to load (Request for icon resource failed: ${i})`)}this._releaseTexture=l.value;const c=l.value.texture,h=c.params;this._size=this._computeSize(h,o),e.textureId=c.id}this._createMaterialAndAddToStage(e,this._context.stage)}async _prepareResourcesCIM(e,t,r){const i=new Z({data:t});if(!this._context.sharedResources.cimSymbolRasterizer){const e=(await import("../../../../symbols/cim/CIMSymbolRasterizer.js")).CIMSymbolRasterizer;a(r),this._context.sharedResources.cimSymbolRasterizer||(this._context.sharedResources.cimSymbolRasterizer=new e(this._context.renderCoordsHelper.spatialReference,!0))}const s=this._context.layer.fields?this._context.layer.fields.map((e=>e.toJSON())):null;let o,n;if(this._cimLayers=await this._context.sharedResources.cimSymbolRasterizer.analyzeCIMSymbol(i,s,this._context.renderer&&"dictionary"===this._context.renderer.type?this._context.renderer.fieldMap:null,"esriGeometryPoint",{signal:r}),this._context.renderer&&"dictionary"===this._context.renderer.type&&this._context.renderer.scaleExpression){const e=this._context.renderer;if(isNaN(e.scaleExpression)){const t=e.scaleExpression,r=await y(t,this._context.layer.spatialReference,s);n=(e,t,i)=>{const s=S(r,e,{$view:i},"esriGeometryPoint",t);return null!==s?s:1}}else o=Number(e.scaleExpression)}this._cimScaleFactorOrFunction=o||n||1;const l=this._context.renderer?await this._context.renderer.getRequiredFields(this._context.layer.fieldsIndex):[];a(r);const c=this._context.layer.fieldsIndex;this._cimRequiredFields=l.map((e=>c.get(e).name)),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 this.symbolLayer.resource&&this.symbolLayer.resource.href?null:this.symbolLayer.resource&&this.symbolLayer.resource.primitive||g}_getOutlineSize(){let e=0;const t=this.symbolLayer;if(null!=t.outline&&null!=t.outline.size)return Math.max(o(t.outline.size),0);return e=ae(this._getPrimitive())?Y:0,Math.max(e,0)}_getOutlineColor(){const t=this._getLayerOpacity(),r=this.symbolLayer,i=r?.outline?.color;if(null!=i){const r=e.toUnitRGB(i),s=i.a*t;return[r[0],r[1],r[2],s]}return[0,0,0,0]}_getFillColor(){if(ae(this._getPrimitive()))return b;const e=null==this._getPrimitive(),t=this.symbolLayer?.material?.color;return this._getCombinedOpacityAndColor(t,{hasIntrinsicColor:e})}_getAnchorPos(e,t){return"relative"===e?h((t.x||0)+.5,.5-(t.y||0)):e in T?T[e]:T.center}_createMaterialAndAddToStage(e,t){if(this._cimLayers){this._fastUpdates=null;let r=e.textureId?this._cimSymbolMaterials.get(e.textureId):null;return r||(r=new J(e),this._cimSymbolMaterials.set(e.textureId??0,r),t.add(r)),r}return this._fastUpdates=D(this._context.renderer,this._fastVisualVariableConvertOptions()),this._fastUpdates&&(e={...e,...this._fastUpdates.materialParameters}),this._material=new J(e),t.add(this._material),this._material}_setDrapingDependentMaterialParameters(){this.draped&&(this._forEachMaterial((e=>{e.setParameters({verticalOffset:null,screenSizePerspective:null,occlusionTest:!1,hasSlicePlane:!1,shaderPolygonOffset:0,isDraped:this.draped})})),this.layerOpacityChanged())}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._material=null,this._cimSymbolMaterials.clear(),this._cimSymbolTextures.forEach((e=>this._context.stage.remove(e))),this._cimSymbolTextures.clear(),this._releaseTexture=i(this._releaseTexture)}_getScaleFactor(e,t){if(this._drivenProperties.size&&e.size){for(let t=0;t<3;t++){const r=e.size[t];r&&"symbol-value"!==r&&"proportional"!==r&&(e.size[t]=o(r))}if("symbol-value"===e.size[0])return 1;if(isFinite(+e.size[0]))return+e.size[0]/t;if(isFinite(+e.size[2]))return+e.size[2]/t}return 1}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;let r,i=[0,0];if(this._cimLayers){if(!this._cimLayers.length)return null;const e=this._generateTextureCIM(t),s={textureId:e.id,...this._cimMaterialParametersInfo};r=this._createMaterialAndAddToStage(s,this._context.stage),i=[e.params.width,e.params.height]}else i=this._size,r=this._material;const s=U(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const a=e.renderingInfo,o=this._getVertexOpacityAndColor(a);let n=1;if(!this._fastUpdates?.visualVariables.size){const e=i[0]>i[1]?i[0]:i[1];n=this._getScaleFactor(a,e)}n*=this._symbolTextureRatio;const l=h(i[0]*n,i[1]*n),c=this.setGraphicElevationContext(t,new C);return this.ensureDrapedStatus("on-the-ground"===c.mode)&&this._setDrapingDependentMaterialParameters(),this.draped?this._createAsOverlay(t,s,r,o,l,e.layer.uid):this._createAs3DShape(t,s,r,o,l,c,t.uid)}layerOpacityChanged(){const e=this._getFillColor(),t=this._getOutlineColor();this._forEachMaterial((r=>{r.setParameters({color:e}),r.setParameters({outlineColor:t})}))}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,s=P(ie.elevationModeChangeTypes,r,i);if(s!==z.UPDATE)return s;const a=R(i)||"absolute-height"===i;return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>a))}slicePlaneEnabledChanged(){return this.draped||this._forEachMaterial((e=>{e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return null!=this._getPrimitive()}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return O.RecreateSymbol;if(!F(this._fastUpdates,t,this._fastVisualVariableConvertOptions()))return O.RecreateSymbol;null!=this._material&&this._material.setParameters(this._fastUpdates.materialParameters)}return O.FastUpdate}_defaultElevationInfoNoZ(){return oe}_createAs3DShape(e,t,r,i,s,a,o){const n=this.getFastUpdateAttrValues(e),l=n&&this._fastUpdates?e=>A(this._fastUpdates.materialParameters,n,e):void 0,c=this._context.layer.uid,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:c}),m=k(r,Q,null,i,s,ne,null,n,h),u=E(this._context,t,m,a,o,l);if(null==u)return null;const d=new j(this,u.object,[m],null,null,v,a);return d.alignedSampledElevation=u.sampledElevation,d.needsElevationUpdates=R(a.mode)||"absolute-height"===a.mode,d.getScreenSize=this._createScreenSizeGetter(s,l),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),L(d,t,this._context.elevationProvider),d}_createAsOverlay(e,t,r,i,s,a){r.renderPriority=this._renderPriority;const o=_();p(t,o,this._context.overlaySR),o[2]=q;const n=this._context.clippingExtent;if(null!=n&&!f(n,o))return null;const l=this.getFastUpdateAttrValues(e),c=l&&this._fastUpdates?e=>A(this._fastUpdates.materialParameters,l,e):void 0,h=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:e.uid,layerUid:this._context.layer.uid}),m=k(r,Q,o,i,s,null,null,l,h),u=new W(m,{layerUid:a,graphicUid:e.uid,shaderTransformer:c}),d=new M(this,[u],null,this._context.drapeSourceRenderer);return d.getScreenSize=this._createScreenSizeGetter(s,c),d.calculateRelativeScreenBounds=e=>r.calculateRelativeScreenBounds(d.getScreenSize(),1,e),d}_createScreenSizeGetter(e,t){const r=this._outlineSize+2;if(this._fastUpdates&&t){const i=e[0]/this._symbolTextureRatio,s=e[1]/this._symbolTextureRatio;return(e=m())=>{const a=t(K);return e[0]=a[0]*i+r,e[1]=a[5]*s+r,e}}{const t=e[0]/this._symbolTextureRatio+r,i=e[1]/this._symbolTextureRatio+r;return(e=m())=>(e[0]=t,e[1]=i,e)}}_fastVisualVariableConvertOptions(){const e=Math.max(this._size[0],this._size[1]),t=u(e,e,e),r=n(1),i=e*r,s=u(i,i,i);return new G({size:!0,color:!0,rotation:!0,opacity:!1},t,s,r)}_getGraphicHash(e){let t="";for(const r of this._cimRequiredFields)t+=r+e.attributes[r];return t}_forEachMaterial(e){null!=this._material&&e(this._material),this._cimSymbolMaterials.forEach(e)}test(){return{...super.test(),material:this._material}}}function se(e){return e&&"point-3d"===e.type&&e.hasVisibleVerticalOffset()}function ae(e){return null!=e&&("cross"===e||"x"===e)}ie.PRIMITIVE_SIZE=re,ie.elevationModeChangeTypes={definedChanged:z.UPDATE,staysOnTheGround:z.NONE,onTheGroundChanged:z.RECREATE};const oe={mode:"relative-to-ground",offset:0},ne=d(0,0,0,1);export{ie as Graphics3DIconSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../geometry.js";import e from"../../../../core/Error.js";import{applySome as t,releaseMaybe as r,get as i}from"../../../../core/maybe.js";import{px2pt as a,pt2px as s}from"../../../../core/screenUtils.js";import{f as l,d as o}from"../../../../chunks/vec4f64.js";import{create as n,empty as h,expandWithBuffer as c,intersectsClippingArea as p,expandWithAABB as m}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as d}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as y}from"./ElevationAligners.js";import{SymbolUpdateType as _,elevationModeChangeUpdateType as u,needsElevationUpdates2D as g}from"./elevationAlignmentUtils.js";import{ElevationContext as f}from"./ElevationContext.js";import M from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as C}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as b}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as E}from"./interfaces.js";import{parseLineMarkerStyle as L,parseCapType as P}from"./lineUtils.js";import{ConvertOptions as w,initFastSymbolUpdatesState as x,updateFastSymbolUpdatesState as v,getAttributeValue as k}from"../support/FastSymbolUpdates.js";import R from"../../support/debugFlags.js";import{createGeometry as j}from"../../support/engineContent/line.js";import{prepareMarkerResources as D}from"../../support/engineContent/marker.js";import{geometryToRenderInfo as A,geometryToRenderInfoDraped as S}from"../../support/renderInfoUtils/line.js";import{Object3D as U}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as G}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as z}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as O}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as I}from"../../webgl-engine/materials/RibbonLineMaterial.js";import T from"../../../../geometry/Extent.js";import V from"../../../../geometry/Polygon.js";const W=["polyline","polygon","extent"],F=new w({size:!0,color:!0,rotation:!1,opacity:!0});class H extends b{constructor(e,t,r,i){super(e,t,r,i)}async doLoad(){if(this._fastUpdates=x(this._context.renderer,F),!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:a(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}this._markerTexture=null!=this.symbolLayer.marker&&null!=this._context.sharedResources.textures?D(this._context.sharedResources.textures,L(this.symbolLayer.marker.style)):null}_getMaterialParameters(e,t=!1){const r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);this._patternHidesLine&&!t&&(r[3]=0);const i={width:this._computeMaterialWidth(this.symbolLayer?.size),color:r,hasPolygonOffset:!0,join:this.symbolLayer.join||"miter",cap:P(this.symbolLayer.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:O(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};return this._fastUpdates?.visualVariables?{...i,...this._fastUpdates.materialParameters}:i}get _materialColor(){return t(this.symbolLayer.material,(e=>e.color))}get _markerColor(){return t(this.symbolLayer.marker,(e=>e.color))}get _lineMaterial(){return null==this._lineMaterialCached&&(this._lineMaterialCached=new I(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterialCached)),this._lineMaterialCached}get _ringMaterial(){return null==this._ringMaterialCached&&(this._ringMaterialCached=new I(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterialCached)),this._ringMaterialCached}get _wireframeLineMaterial(){return null==this._wireframeLineMaterialCached&&(this._wireframeLineMaterialCached=new I({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterialCached)),this._wireframeLineMaterialCached}get _wireframeRingMaterial(){return null==this._wireframeRingMaterialCached&&(this._wireframeRingMaterialCached=new I({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterialCached)),this._wireframeRingMaterialCached}get _markerMaterial(){return null==this._markerMaterialCached&&null!=this.symbolLayer.marker&&null!=this._markerTexture&&(this._markerMaterialCached=new z({...this._getMaterialParameters(!1,!0),placement:this.symbolLayer.marker.placement,textureId:this._markerTexture.texture.id}),this._context.stage.add(this._markerMaterialCached)),this._markerMaterialCached}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterialCached=null,this._ringMaterialCached=null,this._wireframeLineMaterialCached=null,this._wireframeRingMaterialCached=null,this._markerMaterialCached=null,this._markerTexture=r(this._markerTexture)}_getDrivenSize(e){return this._drivenProperties.size&&e.size?s(d(e.size)):1}_getDrivenColor(e){const t=l(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,W,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new f);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return E.RecreateSymbol;{const e=this._fastUpdates;if(!v(e,t,F))return E.RecreateSymbol;this._forEachMaterial((t=>t.setParameters(e.materialParameters)))}}return E.FastUpdate}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=P(t.cap.newValue??"butt"),delete t.cap);const i=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,i),e.symbolLayerStatePatches.push((()=>this._forEachMaterial((e=>e.setParameters(r)))))}layerOpacityChanged(){this._forEachMaterial(((e,t)=>this._updateMaterialLayerOpacity(e,t)))}_forEachMaterial(e){null!=this._lineMaterialCached&&e(this._lineMaterialCached),null!=this._ringMaterialCached&&e(this._ringMaterialCached),null!=this._wireframeLineMaterialCached&&e(this._wireframeLineMaterialCached),null!=this._wireframeRingMaterialCached&&e(this._wireframeRingMaterialCached),null!=this._markerMaterialCached&&e(this._markerMaterialCached,!0)}_updateMaterialLayerOpacity(e,t=!1){const r=e.parameters.color,a=i(this.symbolLayer,"material","color"),s=this._patternHidesLine&&!t?0:this._getCombinedOpacity(a),o=l(r[0],r[1],r[2],s);e.setParameters({color:o})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,a=u(H.elevationModeChangeTypes,r,i);if(a!==_.UPDATE)return a;const s=g(i);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>s))}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof T)return V.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,t,r){const i=e.graphic,a=this._getGeometryAsPolygonOrPolyline(i.geometry),s="polygon"===a.type?a.rings:a.paths,l=new Array,o=n(),m=A(a,this._context.elevationProvider,this._context.renderCoordsHelper,t),d="polygon"===a.type?"rings":"paths";this._logGeometryCreationWarnings(m,s,d,"LineSymbol3DLayer");for(let n=0;n<m.lines.length;n++){const t=m.lines[n],i=t.position,s=t.mapPositions;if(null!=this._context.clippingExtent&&(h(o),c(o,s),!p(o,this._context.clippingExtent)))continue;const d=this._createGeometry("polygon"===a.type?this._ringMaterial:this._lineMaterial,e,i,s,a.type,N.ELEVATED,r);l.push(d),R.LINE_WIREFRAMES&&l.push(d.instantiate({material:"polygon"===a.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),null!=this._markerMaterial&&l.push(d.instantiate({material:this._markerMaterial}))}if(0===l.length)return null;const _=new U({geometries:l,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),u=new C(this,_,l,null,null,y,t);return u.alignedSampledElevation=m.sampledElevation,u.needsElevationUpdates=g(t.mode),u}_createGeometry(e,t,r,i,a,s,l){const o=s===N.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,n="polygon"===a,h=this._fastUpdates?.visualVariables.color,c=this._fastUpdates?.visualVariables.size,p=this._fastUpdates?.visualVariables.opacity,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerUid:this._context.layer.uid}),d={position:r,size:c?null:this._getDrivenSize(t.renderingInfo),color:h?null:this._getDrivenColor(t.renderingInfo),sizeFeature:c?k(c.field,t.graphic):null,colorFeature:h?k(h.field,t.graphic):null,opacityFeature:p?k(p.field,t.graphic):null};return j(e,{overlayInfo:o,removeDuplicateStartEnd:n,mapPositions:i,attributeData:d},m)}_createAsOverlay(e,t){const r=e.graphic,i=this._getGeometryAsPolygonOrPolyline(r.geometry),a="polygon"===i.type?i.rings:i.paths,s="polygon"===i.type?this._ringMaterial:this._lineMaterial;s.renderPriority=this._renderPriority;const l=R.LINE_WIREFRAMES?"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,o=this._markerMaterial;null!=l&&(l.renderPriority=this._renderPriority-.001),null!=o&&(o.renderPriority=this._renderPriority-.002);const d=new Array,y=n(),_=h(),u=S(i,this._context.overlaySR),g="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(u,a,g,"LineSymbol3DLayer");for(const n of u.lines){if(h(y),c(y,n.position),!p(y,this._context.clippingExtent))continue;m(_,y);const a=a=>{const s=this._createGeometry(a,e,n.position,void 0,i.type,N.DRAPED,r.uid),l=new G(s,{layerUid:t,graphicUid:r.uid});d.push(l)};if(null!=o){a(o);const e=this.symbolLayer.marker.placement;"begin"!==e&&"begin-end"!==e||c(y,n.position,0,1),"end"!==e&&"begin-end"!==e||c(y,n.position,n.position.length-3,1)}a(s),R.LINE_WIREFRAMES&&a(l)}return new M(this,d,_,this._context.drapeSourceRenderer)}get _patternHidesLine(){const e=this.symbolLayer.pattern;return null!=e&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=e??a(1),this._drivenProperties.size?this._fastUpdates?.visualVariables.size?s(1):1:s(e)}_prepareMaterialPatch(e,r,i){const a=r.material;if(null==a)return void(i.changed&&i.useMaterialColor&&this._patchMaterialColor(this._getCombinedOpacityAndColor(this._materialColor),this._markerMaterialCached,e));if("collection"===a.type)return;const s="complete"===a.type?t(a.newValue,(e=>e.color)):"complete"===a.diff.color?.type?a.diff.color.newValue:null,l=this._getCombinedOpacityAndColor(s);i.useMaterialColor&&this._patchMaterialColor(o(l),this._markerMaterialCached,e),this._patternHidesLine&&(l[3]=0),this._patchMaterialColor(l,this._lineMaterialCached,e),delete r.material}_prepareMarkerPatch(e,t){const r=t.marker;if(null==r||"partial"!==r.type||null!=r.diff.style||null!=r.diff.placement||null!=r.diff.color&&"complete"!==r.diff.color.type)return{changed:!1,useMaterialColor:null==this._markerColor};const i=r.diff.color;if(null==i)return delete t.marker,{changed:!1,useMaterialColor:null==this._markerColor};const a=i.newValue;return null==a?(delete t.marker,{changed:!0,useMaterialColor:!0}):(this._patchMaterialColor(this._getCombinedOpacityAndColor(a),this._markerMaterialCached,e),delete t.marker,{changed:!0,useMaterialColor:!1})}_patchMaterialColor(e,t,r){null!=t&&r.symbolLayerStatePatches.push((()=>t.setParameters({color:e})))}}var N;H.elevationModeChangeTypes={definedChanged:_.RECREATE,staysOnTheGround:_.NONE,onTheGroundChanged:_.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(N||(N={}));export{H as Graphics3DLineSymbolLayer};
|
|
5
|
+
import"../../../../geometry.js";import e from"../../../../core/Error.js";import{applySome as t,releaseMaybe as r}from"../../../../core/maybe.js";import{px2pt as i,pt2px as a}from"../../../../core/screenUtils.js";import{f as s,d as l}from"../../../../chunks/vec4f64.js";import{create as o,empty as n,expandWithBuffer as h,intersectsClippingArea as c,expandWithAABB as p}from"../../../../geometry/support/aaBoundingBox.js";import{getDriverAxisSizeValueAny as m}from"../../../../renderers/support/renderingInfoUtils.js";import{sharedGeometryElevationAligner as d}from"./ElevationAligners.js";import{SymbolUpdateType as y,elevationModeChangeUpdateType as _,needsElevationUpdates2D as u}from"./elevationAlignmentUtils.js";import{ElevationContext as g}from"./ElevationContext.js";import f from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as M}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as C}from"./Graphics3DSymbolLayer.js";import{ApplyRendererDiffResult as b}from"./interfaces.js";import{parseLineMarkerStyle as E,parseCapType as L}from"./lineUtils.js";import{ConvertOptions as P,initFastSymbolUpdatesState as w,updateFastSymbolUpdatesState as x,getAttributeValue as v}from"../support/FastSymbolUpdates.js";import k from"../../support/debugFlags.js";import{createGeometry as R}from"../../support/engineContent/line.js";import{prepareMarkerResources as j}from"../../support/engineContent/marker.js";import{geometryToRenderInfo as D,geometryToRenderInfoDraped as A}from"../../support/renderInfoUtils/line.js";import{Object3D as S}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as U}from"../../webgl-engine/lib/RenderGeometry.js";import{LineMarkerMaterial as G}from"../../webgl-engine/materials/LineMarkerMaterial.js";import{getStipplePatternForLinePattern as z}from"../../webgl-engine/materials/lineStippleUtils.js";import{RibbonLineMaterial as O}from"../../webgl-engine/materials/RibbonLineMaterial.js";import I from"../../../../geometry/Extent.js";import T from"../../../../geometry/Polygon.js";const V=["polyline","polygon","extent"],W=new P({size:!0,color:!0,rotation:!1,opacity:!0});class F extends C{constructor(e,t,r,i){super(e,t,r,i)}async doLoad(){if(this._fastUpdates=w(this._context.renderer,W),!this._drivenProperties.size){if((null!=this.symbolLayer.size?this.symbolLayer.size:i(1))<0)throw new e("graphics3dlinesymbollayer:invalid-size","Symbol sizes may not be negative values")}this._markerTexture=null!=this.symbolLayer.marker&&null!=this._context.sharedResources.textures?j(this._context.sharedResources.textures,E(this.symbolLayer.marker.style)):null}_getMaterialParameters(e,t=!1){const r=this._getCombinedOpacityAndColor(t&&this._markerColor||this._materialColor);this._patternHidesLine&&!t&&(r[3]=0);const i={width:this._computeMaterialWidth(this.symbolLayer?.size),color:r,hasPolygonOffset:!0,join:this.symbolLayer.join||"miter",cap:L(this.symbolLayer.cap||"butt"),hasSlicePlane:this._context.slicePlaneEnabled,isClosed:e,stipplePattern:z(this.symbolLayer.pattern),stippleScaleWithLineWidth:!0};return this._fastUpdates?.visualVariables?{...i,...this._fastUpdates.materialParameters}:i}get _materialColor(){return t(this.symbolLayer.material,(e=>e.color))}get _markerColor(){return t(this.symbolLayer.marker,(e=>e.color))}get _lineMaterial(){return null==this._lineMaterialCached&&(this._lineMaterialCached=new O(this._getMaterialParameters(!1)),this._context.stage.add(this._lineMaterialCached)),this._lineMaterialCached}get _ringMaterial(){return null==this._ringMaterialCached&&(this._ringMaterialCached=new O(this._getMaterialParameters(!0)),this._context.stage.add(this._ringMaterialCached)),this._ringMaterialCached}get _wireframeLineMaterial(){return null==this._wireframeLineMaterialCached&&(this._wireframeLineMaterialCached=new O({...this._getMaterialParameters(!1),wireframe:!0}),this._context.stage.add(this._wireframeLineMaterialCached)),this._wireframeLineMaterialCached}get _wireframeRingMaterial(){return null==this._wireframeRingMaterialCached&&(this._wireframeRingMaterialCached=new O({...this._getMaterialParameters(!0),wireframe:!0}),this._context.stage.add(this._wireframeRingMaterialCached)),this._wireframeRingMaterialCached}get _markerMaterial(){return null==this._markerMaterialCached&&null!=this.symbolLayer.marker&&null!=this._markerTexture&&(this._markerMaterialCached=new G({...this._getMaterialParameters(!1,!0),placement:this.symbolLayer.marker.placement,textureId:this._markerTexture.texture.id}),this._context.stage.add(this._markerMaterialCached)),this._markerMaterialCached}destroy(){super.destroy(),this._forEachMaterial((e=>this._context.stage.remove(e))),this._lineMaterialCached=null,this._ringMaterialCached=null,this._wireframeLineMaterialCached=null,this._wireframeRingMaterialCached=null,this._markerMaterialCached=null,this._markerTexture=r(this._markerTexture)}_getDrivenSize(e){return this._drivenProperties.size&&e.size?a(m(e.size)):1}_getDrivenColor(e){const t=s(1,1,1,1);return this._drivenProperties.color&&e.color&&(t[0]=e.color[0],t[1]=e.color[1],t[2]=e.color[2],e.color.length>0&&(t[3]=e.color[3])),this._drivenProperties.opacity&&e.opacity&&(t[3]=e.opacity),t}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,V,this.symbolLayer.type))return null;const r=this.setGraphicElevationContext(t,new g);return this.ensureDrapedStatus("on-the-ground"===r.mode),this.draped?this._createAsOverlay(e,this._context.layer.uid):this._createAs3DShape(e,r,t.uid)}applyRendererDiff(e,t){for(const r in e.diff){if("visualVariables"!==r)return b.RecreateSymbol;{const e=this._fastUpdates;if(!x(e,t,W))return b.RecreateSymbol;this._forEachMaterial((t=>t.setParameters(e.materialParameters)))}}return b.FastUpdate}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff,r={};"complete"===t.size?.type&&(r.width=this._computeMaterialWidth(t.size.newValue),delete t.size),"complete"===t.cap?.type&&(r.cap=L(t.cap.newValue??"butt"),delete t.cap);const i=this._prepareMarkerPatch(e,t);this._prepareMaterialPatch(e,t,i),e.symbolLayerStatePatches.push((()=>this._forEachMaterial((e=>e.setParameters(r)))))}layerOpacityChanged(){this._forEachMaterial(((e,t)=>this._updateMaterialLayerOpacity(e,t)))}_forEachMaterial(e){null!=this._lineMaterialCached&&e(this._lineMaterialCached),null!=this._ringMaterialCached&&e(this._ringMaterialCached),null!=this._wireframeLineMaterialCached&&e(this._wireframeLineMaterialCached),null!=this._wireframeRingMaterialCached&&e(this._wireframeRingMaterialCached),null!=this._markerMaterialCached&&e(this._markerMaterialCached,!0)}_updateMaterialLayerOpacity(e,t=!1){const r=e.parameters.color,i=this.symbolLayer?.material?.color,a=this._patternHidesLine&&!t?0:this._getCombinedOpacity(i),l=s(r[0],r[1],r[2],a);e.setParameters({color:l})}layerElevationInfoChanged(e,t,r){const i=this._elevationContext.mode,a=_(F.elevationModeChangeTypes,r,i);if(a!==y.UPDATE)return a;const s=u(i);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>s))}slicePlaneEnabledChanged(){const e={hasSlicePlane:this._context.slicePlaneEnabled};return this._forEachMaterial((t=>t.setParameters(e))),!0}physicalBasedRenderingChanged(){return!0}_getGeometryAsPolygonOrPolyline(e){switch(e.type){case"extent":if(e instanceof I)return T.fromExtent(e);break;case"polygon":case"polyline":return e}return null}_createAs3DShape(e,t,r){const i=e.graphic,a=this._getGeometryAsPolygonOrPolyline(i.geometry),s="polygon"===a.type?a.rings:a.paths,l=new Array,p=o(),m=D(a,this._context.elevationProvider,this._context.renderCoordsHelper,t),y="polygon"===a.type?"rings":"paths";this._logGeometryCreationWarnings(m,s,y,"LineSymbol3DLayer");for(let o=0;o<m.lines.length;o++){const t=m.lines[o],i=t.position,s=t.mapPositions;if(null!=this._context.clippingExtent&&(n(p),h(p,s),!c(p,this._context.clippingExtent)))continue;const d=this._createGeometry("polygon"===a.type?this._ringMaterial:this._lineMaterial,e,i,s,a.type,H.ELEVATED,r);l.push(d),k.LINE_WIREFRAMES&&l.push(d.instantiate({material:"polygon"===a.type?this._wireframeRingMaterial:this._wireframeLineMaterial})),null!=this._markerMaterial&&l.push(d.instantiate({material:this._markerMaterial}))}if(0===l.length)return null;const _=new S({geometries:l,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:r}),g=new M(this,_,l,null,null,d,t);return g.alignedSampledElevation=m.sampledElevation,g.needsElevationUpdates=u(t.mode),g}_createGeometry(e,t,r,i,a,s,l){const o=s===H.DRAPED?{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper}:null,n="polygon"===a,h=this._fastUpdates?.visualVariables.color,c=this._fastUpdates?.visualVariables.size,p=this._fastUpdates?.visualVariables.opacity,m=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:l,layerUid:this._context.layer.uid}),d={position:r,size:c?null:this._getDrivenSize(t.renderingInfo),color:h?null:this._getDrivenColor(t.renderingInfo),sizeFeature:c?v(c.field,t.graphic):null,colorFeature:h?v(h.field,t.graphic):null,opacityFeature:p?v(p.field,t.graphic):null};return R(e,{overlayInfo:o,removeDuplicateStartEnd:n,mapPositions:i,attributeData:d},m)}_createAsOverlay(e,t){const r=e.graphic,i=this._getGeometryAsPolygonOrPolyline(r.geometry),a="polygon"===i.type?i.rings:i.paths,s="polygon"===i.type?this._ringMaterial:this._lineMaterial;s.renderPriority=this._renderPriority;const l=k.LINE_WIREFRAMES?"polygon"===i.type?this._wireframeRingMaterial:this._wireframeLineMaterial:null,m=this._markerMaterial;null!=l&&(l.renderPriority=this._renderPriority-.001),null!=m&&(m.renderPriority=this._renderPriority-.002);const d=new Array,y=o(),_=n(),u=A(i,this._context.overlaySR),g="polygon"===i.type?"rings":"paths";this._logGeometryCreationWarnings(u,a,g,"LineSymbol3DLayer");for(const o of u.lines){if(n(y),h(y,o.position),!c(y,this._context.clippingExtent))continue;p(_,y);const a=a=>{const s=this._createGeometry(a,e,o.position,void 0,i.type,H.DRAPED,r.uid),l=new U(s,{layerUid:t,graphicUid:r.uid});d.push(l)};if(null!=m){a(m);const e=this.symbolLayer.marker.placement;"begin"!==e&&"begin-end"!==e||h(y,o.position,0,1),"end"!==e&&"begin-end"!==e||h(y,o.position,o.position.length-3,1)}a(s),k.LINE_WIREFRAMES&&a(l)}return new f(this,d,_,this._context.drapeSourceRenderer)}get _patternHidesLine(){const e=this.symbolLayer.pattern;return null!=e&&"style"===e.type&&"none"===e.style}_computeMaterialWidth(e){return e=e??i(1),this._drivenProperties.size?this._fastUpdates?.visualVariables.size?a(1):1:a(e)}_prepareMaterialPatch(e,r,i){const a=r.material;if(null==a)return void(i.changed&&i.useMaterialColor&&this._patchMaterialColor(this._getCombinedOpacityAndColor(this._materialColor),this._markerMaterialCached,e));if("collection"===a.type)return;const s="complete"===a.type?t(a.newValue,(e=>e.color)):"complete"===a.diff.color?.type?a.diff.color.newValue:null,o=this._getCombinedOpacityAndColor(s);i.useMaterialColor&&this._patchMaterialColor(l(o),this._markerMaterialCached,e),this._patternHidesLine&&(o[3]=0),this._patchMaterialColor(o,this._lineMaterialCached,e),delete r.material}_prepareMarkerPatch(e,t){const r=t.marker;if(null==r||"partial"!==r.type||null!=r.diff.style||null!=r.diff.placement||null!=r.diff.color&&"complete"!==r.diff.color.type)return{changed:!1,useMaterialColor:null==this._markerColor};const i=r.diff.color;if(null==i)return delete t.marker,{changed:!1,useMaterialColor:null==this._markerColor};const a=i.newValue;return null==a?(delete t.marker,{changed:!0,useMaterialColor:!0}):(this._patchMaterialColor(this._getCombinedOpacityAndColor(a),this._markerMaterialCached,e),delete t.marker,{changed:!0,useMaterialColor:!1})}_patchMaterialColor(e,t,r){null!=t&&r.symbolLayerStatePatches.push((()=>t.setParameters({color:e})))}}var H;F.elevationModeChangeTypes={definedChanged:y.RECREATE,staysOnTheGround:y.NONE,onTheGroundChanged:y.RECREATE},function(e){e[e.DRAPED=0]="DRAPED",e[e.ELEVATED=1]="ELEVATED"}(H||(H={}));export{F as Graphics3DLineSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import"../../../../core/has.js";import{get as t}from"../../../../core/maybe.js";import{f as r,t as o}from"../../../../chunks/mat3.js";import{c as n}from"../../../../chunks/mat3f64.js";import{f as a,m as s,a as i}from"../../../../chunks/mat4.js";import{c as l,b as u}from"../../../../chunks/mat4f64.js";import{a as c,g as m,e as h,n as f,b as p,f as g}from"../../../../chunks/vec3.js";import{Z as d,O as x,c as _}from"../../../../chunks/vec3f64.js";import{O as T}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as b,projectBuffer as y,computeTranslationToOriginAndRotation as v,canProjectWithoutEngine as C}from"../../../../geometry/projection.js";import{create as O,empty as w,expandWithBuffer as A,intersectsClippingArea as M}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as j}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as N,getZeroIndexArray as R}from"../../../../geometry/support/Indices.js";import E from"../../../../geometry/support/MeshComponent.js";import P from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{t as I,a as B}from"../../../../chunks/vec32.js";import{transformNormal as S,projectNormalToPCPF as F,transformTangent as L,projectTangentToPCPF as V}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as U}from"../../../../layers/graphics/dehydratedFeatures.js";import{ViewingMode as G}from"../../../ViewingMode.js";import{isEncodedMeshTexture as $}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as D}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as k}from"./ElevationAligners.js";import{needsElevationUpdates3D as q,evaluateElevationInfoAtPoint as H}from"./elevationAlignmentUtils.js";import{ElevationContext as W}from"./ElevationContext.js";import{Object3DEdgeState as z,Graphics3DObject3DGraphicLayer as Y}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Z}from"./Graphics3DSymbolLayer.js";import{createMaterial as J}from"../support/edgeUtils.js";import{parseColorMixMode as K,encodeSymbolColor as Q}from"../support/symbolColorUtils.js";import X from"../../support/debugFlags.js";import{Attribute as ee}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as te,CullFaceOptions as re}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as oe}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as ne}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ae}from"../../webgl-engine/lib/Object3D.js";import{Texture as se}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as ie}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as le}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as ue}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ce}from"../../../webgl/enums.js";const me=["mesh"];class he extends Z{constructor(e,t,r,o){super(e,t,r,o),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){X.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new ue({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new ue({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,me,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new W),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._materials.forEach((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,q)}slicePlaneEnabledChanged(e,t){return this._materials.forEach((e=>{e.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,normalTexture:s,doubleSided:i,alphaCutoff:l,alphaMode:u}=t.material,c=this._colorOrTextureUid(n),m=this._colorOrTextureUid(a),h=this._colorOrTextureUid(s);if(o.color=n,o.colorTexture=a,o.normalTexture=s,o.uid=`${o.uid},cmuid:${c},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${u}`,t.material instanceof P){const{metallic:e,roughness:r,metallicRoughnessTexture:n,emissiveColor:a,emissiveTexture:s,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(n),u=this._colorOrTextureUid(a),c=this._colorOrTextureUid(s),m=this._colorOrTextureUid(i);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=a,o.emissiveTexture=s,o.occlusionTexture=i,o.colorTextureTransform=t.material.colorTextureTransform,o.normalTextureTransform=t.material.normalTextureTransform,o.emissiveTextureTransform=t.material.emissiveTextureTransform,o.occlusionTextureTransform=t.material.occlusionTextureTransform,o.metallicRoughnessTextureTransform=t.material.metallicRoughnessTextureTransform,o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${u},etmuid:${c},otmuid:${m}`}return o}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,te.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let n=this._textures.get(o);return n||(n=new se($(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!$(r)&&t!==te.Opaque,encoding:$(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,n),this._context.stage.add(n),this._context.stage.loadImmediate(n)),n}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ce.CLAMP_TO_EDGE;case"mirror":return ce.MIRRORED_REPEAT;default:return ce.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=D(t.colorTextureTransform),r.normalTextureTransformMatrix=D(t.normalTextureTransform),r.occlusionTextureTransformMatrix=D(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=D(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=D(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=T;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=T)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(this._hasTransparentVertexColors(e)||null!=r&&r.a<1||null!=o&&o.transparent||a),i=this._materialProperties(e,t,s),l=this._materials.get(i.uid);if(l)return l.material;const u={material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},c=null==i.metallicRoughnessTexture&&null==i.metallic&&null==i.roughness,m={usePBR:this._usePBR(),isSchematic:c,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:d,diffuse:x,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:re.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};c||(m.mrrFactors=[null!=i.metallic?i.metallic:1,null!=i.roughness?i.roughness:1,.5]),t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?re.None:re.Back,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTransparentParameter(m,u),this._setInternalMaterialParameters(i,m);const h=new le(m);return u.material=h,this._materials.set(i.uid,u),this._context.stage.add(h),h}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?te.MaskBlend:te.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?te.Opaque:"mask"===t.alphaMode?te.Mask:te.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),a=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(ie.POSITION),o=e.vertexAttributes.get(ie.NORMAL),u=e.indices.get(ie.POSITION),h=e.indices.get(ie.NORMAL),f=r.data,g=o.data;for(let t=0;t<u.length;t++){const e=3*u[t],r=3*h[t];for(let t=0;t<3;t++)a.push(f[e+t]);for(let t=0;t<3;t++)a.push(f[e+t]+g[r+t]*n);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(f,u,t,_e),this._getFaceVertices(f,u,t,ge,de,xe),c(ge,ge,de),c(ge,ge,xe),m(ge,ge,1/3);for(let e=0;e<3;e++)i.push(ge[e]);for(let e=0;e<3;e++)i.push(ge[e]+_e[e]*n);l.push(l.length),l.push(l.length)}}}const u=t[0].transformation,h=new ne(this._debugVertexNormalMaterial,[[ie.POSITION,new ee(a,3,!0)]],[[ie.POSITION,s]],null,oe.Line);t.push(h),h.transformation=u;const f=new ne(this._debugFaceNormalMaterial,[[ie.POSITION,new ee(i,3,!0)]],[[ie.POSITION,l]],null,oe.Line);f.transformation=u,t.push(f)}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;X.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(n,s);const l=new ae({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=J(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new z(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new Y(this,l,s,null,null,k,r,c);m.needsElevationUpdates=q(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>H(e,h,r,f,t);return m.alignedSampledElevation=k(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=U(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return b([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){this._calculateFaceNormal(e,o,a,_e);for(let e=0;e<3;e++){const r=3*o[a+e];ge[0]=t[r],ge[1]=t[r+1],ge[2]=t[r+2],h(_e,ge)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new fe(t,o,n)}_createComponentNormalsFlat(e,t){const r=j(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=this._calculateFaceNormal(e,t,n,_e);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new fe(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=this._calculateFaceNormal(e,t,a,_e);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:_(),count:0},r[n]=s),c(s.normal,s.normal,o),s.count++}}const o=j(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(f(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new fe(o,n,!1)}_getFaceVertices(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,ge,de,xe),p(de,de,ge),p(xe,xe,ge),g(ge,de,xe),f(o,ge),o}_getOrCreateComponents(e){return e.components??ve}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===Ce.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=I(new Float64Array(r.length),r,o)),t.reprojection===Ce.NONE)return t.needsBufferCopy?new Float64Array(r):r;const n=null!=o?r:new Float64Array(r.length);return y(r,e.spatialReference,0,n,this._context.renderCoordsHelper.spatialReference,0,r.length/3),n}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const n=r.reprojection===Ce.ECEF?r.transformBeforeProject:null;null!=n&&(o=S(o,new Float32Array(o.length),n));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ce.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const a=e.vertexAttributes.position,s=null!=n?o:new Float32Array(o.length);return F(o,a,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const n=r.reprojection===Ce.ECEF?r.transformBeforeProject:null;null!=n&&(o=L(o,new Float32Array(o.length),n));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===Ce.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const a=e.vertexAttributes.position,s=null!=n?o:new Float32Array(o.length);return V(o,a,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const r=this._getVertexOpacityAndColor(e),o=K(t(this.symbolLayer,"material","colorMixMode")),n=new Uint8Array(4);return Q(r,o,n),n}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),i=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,i,s),h=this._createTangentBuffer(e,i,s);return{positionBuffer:i,normalBuffer:m,tangentBuffer:h,uvBuffer:n,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===Ce.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,i,m,h),geometryTransformation:s.reprojection===Ce.NONE&&null!=s.geometryTransformation?s.geometryTransformation:l()}}_computeReprojectionInfo(e){const t=null!=e.transform,r=t&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===G.Local?Ce.NONE:Ce.ECEF;if(t){if(r===Ce.NONE){const t=l();v(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:t,geometryTransformation:u(e.transform.localMatrix),needsBufferCopy:!1}}const t=a(l(),e.transform.origin);return s(t,t,e.transform.localMatrix),{reprojection:r,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,t,n,a){const s=this._context.renderCoordsHelper.spatialReference,u=e.anchor;pe[0]=u.x,pe[1]=u.y,pe[2]=u.z;const c=l();return v(e.spatialReference,pe,c,s),i(Te,c),I(t,t,Te),null==n&&null==a||(r(be,c),o(be,be),null!=n&&B(n,n,be),null!=a&&B(a,a,be,4)),c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??N(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const n=t.length/3;return null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),y(e.vertexAttributes.position,e.spatialReference,0,o,r,0,n)),w(ye),A(ye,o,0,n),!M(ye,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!C(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const g of h){if(!this._validateFaces(e,g))return null;const t=this._getOrCreateFaces(e,g);if(0===t.length)continue;const o=this._createComponentNormals(n,l,g,t);o.didFlipNormals&&(p=!0);const c=[[ie.POSITION,new ee(n,3,!0)],[ie.NORMAL,new ee(o.normals,3,!0)]],h=[[ie.POSITION,t],[ie.NORMAL,o.indices]];null!=s&&(c.push([ie.COLOR,new ee(s,4,!0)]),h.push([ie.COLOR,t])),null!=i&&(c.push([ie.SYMBOLCOLOR,new ee(i,4,!0)]),h.push([ie.SYMBOLCOLOR,R(t.length)])),null!=a&&(c.push([ie.UV0,new ee(a,2,!0)]),h.push([ie.UV0,t])),null!=u&&(c.push([ie.TANGENT,new ee(u,4,!0)]),h.push([ie.TANGENT,t]));const d=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,g),_=new ne(x,c,h,null,oe.Mesh,d);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:c}}}class fe{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const pe=_(),ge=_(),de=_(),xe=_(),_e=_(),Te=l(),be=n(),ye=O(),ve=[new E];var Ce;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(Ce||(Ce={}));export{he as Graphics3DMeshFillSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import"../../../../core/has.js";import{f as t,t as r}from"../../../../chunks/mat3.js";import{c as o}from"../../../../chunks/mat3f64.js";import{f as n,m as a,a as s}from"../../../../chunks/mat4.js";import{c as i,b as l}from"../../../../chunks/mat4f64.js";import{a as u,g as c,e as m,n as h,b as f,f as p}from"../../../../chunks/vec3.js";import{Z as g,O as d,c as x}from"../../../../chunks/vec3f64.js";import{O as _}from"../../../../chunks/vec4f64.js";import{projectVectorToDehydratedPoint as T,projectBuffer as b,computeTranslationToOriginAndRotation as y,canProjectWithoutEngine as v}from"../../../../geometry/projection.js";import{create as C,empty as O,expandWithBuffer as w,intersectsClippingArea as A}from"../../../../geometry/support/aaBoundingBox.js";import{newFloatArray as M}from"../../../../geometry/support/FloatArray.js";import{getContinuousIndexArray as j,getZeroIndexArray as N}from"../../../../geometry/support/Indices.js";import R from"../../../../geometry/support/MeshComponent.js";import E from"../../../../geometry/support/MeshMaterialMetallicRoughness.js";import{t as P,a as I}from"../../../../chunks/vec32.js";import{transformNormal as B,projectNormalToPCPF as S,transformTangent as F,projectTangentToPCPF as L}from"../../../../geometry/support/meshUtils/projection.js";import{makeDehydratedPoint as V}from"../../../../layers/graphics/dehydratedFeatures.js";import{ViewingMode as U}from"../../../ViewingMode.js";import{isEncodedMeshTexture as G}from"../../glTF/internal/resourceUtils.js";import{getTransformMatrix as $}from"../../glTF/internal/TextureTransformUtils.js";import{perObjectElevationAligner as D}from"./ElevationAligners.js";import{needsElevationUpdates3D as k,evaluateElevationInfoAtPoint as q}from"./elevationAlignmentUtils.js";import{ElevationContext as H}from"./ElevationContext.js";import{Object3DEdgeState as W,Graphics3DObject3DGraphicLayer as z}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as Y}from"./Graphics3DSymbolLayer.js";import{createMaterial as Z}from"../support/edgeUtils.js";import{parseColorMixMode as J,encodeSymbolColor as K}from"../support/symbolColorUtils.js";import Q from"../../support/debugFlags.js";import{Attribute as X}from"../../webgl-engine/lib/Attribute.js";import{AlphaDiscardMode as ee,CullFaceOptions as te}from"../../webgl-engine/lib/basicInterfaces.js";import{ContentObjectType as re}from"../../webgl-engine/lib/ContentObjectType.js";import{Geometry as oe}from"../../webgl-engine/lib/Geometry.js";import{Object3D as ne}from"../../webgl-engine/lib/Object3D.js";import{Texture as ae}from"../../webgl-engine/lib/Texture.js";import{VertexAttribute as se}from"../../webgl-engine/lib/VertexAttribute.js";import{DefaultMaterial as ie}from"../../webgl-engine/materials/DefaultMaterial.js";import{NativeLineMaterial as le}from"../../webgl-engine/materials/NativeLineMaterial.js";import{TextureWrapMode as ue}from"../../../webgl/enums.js";const ce=["mesh"];class me extends Y{constructor(e,t,r,o){super(e,t,r,o),this._materials=new Map,this._textures=new Map,this.ensureDrapedStatus(!1)}async doLoad(){Q.DRAW_MESH_GEOMETRY_NORMALS&&(this._debugVertexNormalMaterial=new le({color:[1,0,1,1]}),this._debugFaceNormalMaterial=new le({color:[0,1,1,1]}))}destroy(){super.destroy(),this._context.stage.removeMany(Array.from(this._materials.values(),(e=>e.material))),this._context.stage.removeMany(Array.from(this._textures.values())),this._materials.clear(),this._textures.clear()}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ce,"fill on mesh-3d"))return null;const r=this.setGraphicElevationContext(t,new H),o=e.renderingInfo;return this._createAs3DShape(t,o,r,t.uid)}layerOpacityChanged(e,t){const r=this._getLayerOpacity();this._materials.forEach((e=>{e.material.setParameters({layerOpacity:r});const t=e.material.parameters;this._setMaterialTransparentParameter(t,e),e.material.setParameters({transparent:t.transparent})})),e.forEach((e=>{const o=t(e);null!=o&&o.layerOpacityChanged(r,this._context.isAsync)}))}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,k)}slicePlaneEnabledChanged(e,t){return this._materials.forEach((e=>{e.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),e.forEach((e=>{const r=t(e);null!=r&&r.slicePlaneEnabledChanged(this._context.slicePlaneEnabled,this._context.isAsync)})),!0}physicalBasedRenderingChanged(){const e=this._usePBR();return this._materials.forEach((t=>t.material.setParameters({usePBR:e}))),!0}_requiresSymbolVertexColors(){return this._drivenProperties.color||this._drivenProperties.opacity}_colorOrTextureUid(t){return null==t?"-":t instanceof e?t.toHex():t.contentHash}_materialPropertiesDefault(e,t){const r=this._requiresSymbolVertexColors(),o=!!e.vertexAttributes.color,n=!!e.vertexAttributes.tangent;return{hasSymbolVertexColors:r,hasVertexColors:o,hasVertexTangents:n,uid:`vc:${o},vt:${n},vct${t},svc:${r}`}}_materialProperties(e,t,r){const o=this._materialPropertiesDefault(e,r);if(!t.material)return o;const{color:n,colorTexture:a,normalTexture:s,doubleSided:i,alphaCutoff:l,alphaMode:u}=t.material,c=this._colorOrTextureUid(n),m=this._colorOrTextureUid(a),h=this._colorOrTextureUid(s);if(o.color=n,o.colorTexture=a,o.normalTexture=s,o.uid=`${o.uid},cmuid:${c},ctmuid:${m},ntmuid:${h},ds:${i},ac:${l},am:${u}`,t.material instanceof E){const{metallic:e,roughness:r,metallicRoughnessTexture:n,emissiveColor:a,emissiveTexture:s,occlusionTexture:i}=t.material,l=this._colorOrTextureUid(n),u=this._colorOrTextureUid(a),c=this._colorOrTextureUid(s),m=this._colorOrTextureUid(i);o.metallic=e,o.roughness=r,o.metallicRoughnessTexture=n,o.emissiveColor=a,o.emissiveTexture=s,o.occlusionTexture=i,o.colorTextureTransform=t.material.colorTextureTransform,o.normalTextureTransform=t.material.normalTextureTransform,o.emissiveTextureTransform=t.material.emissiveTextureTransform,o.occlusionTextureTransform=t.material.occlusionTextureTransform,o.metallicRoughnessTextureTransform=t.material.metallicRoughnessTextureTransform,o.uid=`${o.uid},mrm:${e},mrr:${r},mrt:${l},emuid:${u},etmuid:${c},otmuid:${m}`}return o}_setInternalColorValueParameters(t,r){r.diffuse=e.toUnitRGB(t),r.opacity=t.a}_getLoadableTextureResource(e){return e.data?e.data:e.url}_getInternalTextureId(e){const t=this._getInternalTexture(e,ee.Opaque);return null!=t?t.id:null}_getInternalTexture(e,t){const r=this._getLoadableTextureResource(e);if(!r)return null;const o=`${e.contentHash}/${t}`;let n=this._textures.get(o);return n||(n=new ae(G(r)?r.data:r,{mipmap:!0,wrap:this._castTextureWrap(e.wrap),noUnpackFlip:!0,preMultiplyAlpha:!G(r)&&t!==ee.Opaque,encoding:G(r)&&null!=r.encoding?r.encoding:void 0}),this._textures.set(o,n),this._context.stage.add(n),this._context.stage.loadImmediate(n)),n}_castTextureWrap(e="repeat"){if("string"==typeof e){const t=this._castTextureWrapIndividual(e);return{s:t,t}}return{s:this._castTextureWrapIndividual(e.horizontal),t:this._castTextureWrapIndividual(e.vertical)}}_castTextureWrapIndividual(e){switch(e){case"clamp":return ue.CLAMP_TO_EDGE;case"mirror":return ue.MIRRORED_REPEAT;default:return ue.REPEAT}}_setInternalMaterialParameters(t,r){if(null!=t.color&&this._setInternalColorValueParameters(t.color,r),null!=t.colorTexture){const e=this._getInternalTexture(t.colorTexture,r.textureAlphaMode);null!=e?(r.textureId=e.id,r.textureAlphaPremultiplied=!!e.params.preMultiplyAlpha):r.textureId=void 0}null!=t.normalTexture&&(r.normalTextureId=this._getInternalTextureId(t.normalTexture)),null!=t.emissiveColor&&(r.emissiveFactor=e.toUnitRGB(t.emissiveColor)),null!=t.emissiveTexture&&(r.emissiveTextureId=this._getInternalTextureId(t.emissiveTexture)),null!=t.occlusionTexture&&(r.occlusionTextureId=this._getInternalTextureId(t.occlusionTexture)),null!=t.metallicRoughnessTexture&&(r.metallicRoughnessTextureId=this._getInternalTextureId(t.metallicRoughnessTexture)),r.colorTextureTransformMatrix=$(t.colorTextureTransform),r.normalTextureTransformMatrix=$(t.normalTextureTransform),r.occlusionTextureTransformMatrix=$(t.occlusionTextureTransform),r.emissiveTextureTransformMatrix=$(t.emissiveTextureTransform),r.metallicRoughnessTextureTransformMatrix=$(t.metallicRoughnessTextureTransform)}_setExternalMaterialParameters(t){const r=this._drivenProperties.color;let o=null!=this.symbolLayer.material?this.symbolLayer.material.colorMixMode:null;if(r)t.externalColor=_;else{const r=null!=this.symbolLayer.material?this.symbolLayer.material.color:null;null!=r?t.externalColor=e.toUnitRGBA(r):(o=null,t.externalColor=_)}o&&(t.colorMixMode=o),t.castShadows=!!this.symbolLayer.castShadows}_hasTransparentVertexColors(e){const t=e.vertexAttributes.color;if(null==t)return!1;for(let r=3;r<t.length;r+=4)if(255!==t[r])return!0;return!1}_getOrCreateMaterial(e,t){const r=t.material?.color,o=t.material?.colorTexture,n=t.material?.alphaMode,a="blend"===n,s=!("opaque"===n)&&(this._hasTransparentVertexColors(e)||null!=r&&r.a<1||null!=o&&o.transparent||a),i=this._materialProperties(e,t,s),l=this._materials.get(i.uid);if(l)return l.material;const u={material:null,isComponentTransparent:s,alphaMode:t.material?t.material.alphaMode:"opaque"},c=null==i.metallicRoughnessTexture&&null==i.metallic&&null==i.roughness,m={usePBR:this._usePBR(),isSchematic:c,hasVertexColors:i.hasVertexColors,hasSymbolColors:i.hasSymbolVertexColors,hasVertexTangents:i.hasVertexTangents,ambient:g,diffuse:d,opacity:1,doubleSided:!0,doubleSidedType:"winding-order",cullFace:te.None,layerOpacity:this._getLayerOpacity(),hasSlicePlane:this._context.slicePlaneEnabled,initTextureTransparent:!0};c||(m.mrrFactors=[null!=i.metallic?i.metallic:1,null!=i.roughness?i.roughness:1,.5]),t.material&&(m.doubleSided=t.material.doubleSided,m.cullFace=t.material.doubleSided?te.None:te.Back,m.textureAlphaCutoff=t.material.alphaCutoff),this._setExternalMaterialParameters(m),this._setMaterialTransparentParameter(m,u),this._setInternalMaterialParameters(i,m);const h=new ie(m);return u.material=h,this._materials.set(i.uid,u),this._context.stage.add(h),h}_usePBR(){return this._context.physicalBasedRenderingEnabled}_setMaterialTransparentParameter(e,t){e.transparent=this.needsDrivenTransparentPass||t.isComponentTransparent||e.layerOpacity<1||e.opacity<1||e.externalColor&&e.externalColor[3]<1,"auto"===t.alphaMode?e.textureAlphaMode=e.transparent?ee.MaskBlend:ee.Opaque:e.textureAlphaMode="opaque"===t.alphaMode?ee.Opaque:"mask"===t.alphaMode?ee.Mask:ee.Blend}_addDebugNormals(e,t){const r=t.length,o=e.spatialReference.isGeographic?20015077/180:1,n=.1*Math.max(e.extent.width*o,e.extent.height*o,e.extent.zmax-e.extent.zmin),a=[],s=[],i=[],l=[];for(let p=0;p<r;p++){const e=t[p],r=e.vertexAttributes.get(se.POSITION),o=e.vertexAttributes.get(se.NORMAL),m=e.indices.get(se.POSITION),h=e.indices.get(se.NORMAL),f=r.data,g=o.data;for(let t=0;t<m.length;t++){const e=3*m[t],r=3*h[t];for(let t=0;t<3;t++)a.push(f[e+t]);for(let t=0;t<3;t++)a.push(f[e+t]+g[r+t]*n);if(s.push(s.length),s.push(s.length),t%3==0){this._calculateFaceNormal(f,m,t,xe),this._getFaceVertices(f,m,t,pe,ge,de),u(pe,pe,ge),u(pe,pe,de),c(pe,pe,1/3);for(let e=0;e<3;e++)i.push(pe[e]);for(let e=0;e<3;e++)i.push(pe[e]+xe[e]*n);l.push(l.length),l.push(l.length)}}}const m=t[0].transformation,h=new oe(this._debugVertexNormalMaterial,[[se.POSITION,new X(a,3,!0)]],[[se.POSITION,s]],null,re.Line);t.push(h),h.transformation=m;const f=new oe(this._debugFaceNormalMaterial,[[se.POSITION,new X(i,3,!0)]],[[se.POSITION,l]],null,re.Line);f.transformation=m,t.push(f)}_createAs3DShape(e,t,r,o){const n=e.geometry;if("mesh"!==n.type)return null;const a=this._createGeometryInfo(n,t,o);if(null==a)return null;const{geometries:s,objectTransformation:i}=a;Q.DRAW_MESH_GEOMETRY_NORMALS&&this._addDebugNormals(n,s);const l=new ne({geometries:s,layerUid:this._context.layer.uid,graphicUid:o});l.transformation=i;const u=Z(this.symbolLayer,{opacity:this._getLayerOpacity()}),c=null!=u?new W(s[0].material,[u],{mergeGeometries:!0,hasSlicePlane:this._context.slicePlaneEnabled}):null,m=new z(this,l,s,null,null,D,r,c);m.needsElevationUpdates=k(r.mode),m.useObjectOriginAsAttachmentOrigin=!0,r.centerPointInElevationSR=this._getCenterPointInElevationSR(l);const{elevationProvider:h,renderCoordsHelper:f}=this._context,p=(e,t)=>q(e,h,r,f,t);return m.alignedSampledElevation=D(m,r,h.spatialReference,p,f),m}_getCenterPointInElevationSR(e){const t=V(0,0,0,null!=this._context.elevationProvider.spatialReference?this._context.elevationProvider.spatialReference:null);return T([e.transformation[12],e.transformation[13],e.transformation[14]],this._context.renderCoordsHelper.spatialReference,t),t}_createComponentNormals(e,t,r,o){switch(r.shading||"flat"){default:case"source":return this._createComponentNormalsSource(e,t,r,o);case"flat":return this._createComponentNormalsFlat(e,o);case"smooth":return this._createComponentNormalsSmooth(e,o)}}_createComponentNormalsSource(e,t,r,o){if(null==t)return this._createComponentNormalsFlat(e,o);let n=!1;if(!r.trustSourceNormals)for(let a=0;a<o.length;a+=3){this._calculateFaceNormal(e,o,a,xe);for(let e=0;e<3;e++){const r=3*o[a+e];pe[0]=t[r],pe[1]=t[r+1],pe[2]=t[r+2],m(xe,pe)<0&&(t[r]=-t[r],t[r+1]=-t[r+1],t[r+2]=-t[r+2],n=!0)}}return new he(t,o,n)}_createComponentNormalsFlat(e,t){const r=M(t.length),o=new Array(3*t.length);for(let n=0;n<t.length;n+=3){const a=this._calculateFaceNormal(e,t,n,xe);for(let e=0;e<3;e++)r[n+e]=a[e],o[n+e]=n/3}return new he(r,o,!1)}_createComponentNormalsSmooth(e,t){const r={};for(let a=0;a<t.length;a+=3){const o=this._calculateFaceNormal(e,t,a,xe);for(let e=0;e<3;e++){const n=t[a+e];let s=r[n];s||(s={normal:x(),count:0},r[n]=s),u(s.normal,s.normal,o),s.count++}}const o=M(3*t.length),n=new Array(3*t.length);for(let a=0;a<t.length;a++){const e=r[t[a]];1!==e.count&&(h(e.normal,e.normal),e.count=1);for(let t=0;t<3;t++)o[3*a+t]=e.normal[t];n[a]=a}return new he(o,n,!1)}_getFaceVertices(e,t,r,o,n,a){const s=3*t[r],i=3*t[r+1],l=3*t[r+2];o[0]=e[s],o[1]=e[s+1],o[2]=e[s+2],n[0]=e[i],n[1]=e[i+1],n[2]=e[i+2],a[0]=e[l],a[1]=e[l+1],a[2]=e[l+2]}_calculateFaceNormal(e,t,r,o){return this._getFaceVertices(e,t,r,pe,ge,de),f(ge,ge,pe),f(de,de,pe),p(pe,ge,de),h(o,pe),o}_getOrCreateComponents(e){return e.components??ye}_createPositionBuffer(e,t){let r=e.vertexAttributes.position;const o=t.reprojection===ve.ECEF?t.transformBeforeProject:null;if(null!=o&&(r=P(new Float64Array(r.length),r,o)),t.reprojection===ve.NONE)return t.needsBufferCopy?new Float64Array(r):r;const n=null!=o?r:new Float64Array(r.length);return b(r,e.spatialReference,0,n,this._context.renderCoordsHelper.spatialReference,0,r.length/3),n}_createNormalBuffer(e,t,r){let o=e.vertexAttributes.normal;if(null==o)return null;const n=r.reprojection===ve.ECEF?r.transformBeforeProject:null;null!=n&&(o=B(o,new Float32Array(o.length),n));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===ve.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const a=e.vertexAttributes.position,s=null!=n?o:new Float32Array(o.length);return S(o,a,t,e.spatialReference,s)}_createTangentBuffer(e,t,r){let o=e.vertexAttributes.tangent;if(null==o)return null;const n=r.reprojection===ve.ECEF?r.transformBeforeProject:null;null!=n&&(o=F(o,new Float32Array(o.length),n));if("local"===this._context.graphicsCoreOwner.view.viewingMode||r.reprojection===ve.NONE)return r.needsBufferCopy&&e.vertexAttributes.normal===o?new Float32Array(o):o;const a=e.vertexAttributes.position,s=null!=n?o:new Float32Array(o.length);return L(o,a,t,e.spatialReference,s)}_createColorBuffer(e){return e.vertexAttributes.color}_createSymbolColorBuffer(e){if(this._requiresSymbolVertexColors()){const t=this._getVertexOpacityAndColor(e),r=J(this.symbolLayer?.material?.colorMixMode),o=new Uint8Array(4);return K(t,r,o),o}return null}_createBuffers(e,t){const r=e.vertexAttributes&&e.vertexAttributes.position;if(!r)return this.logger.warn("Mesh geometry must contain position vertex attributes"),null;const o=e.vertexAttributes.normal,n=e.vertexAttributes.uv,a=e.vertexAttributes.tangent;if(null!=o&&o.length!==r.length)return this.logger.warn("Mesh normal vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=a&&a.length/4!=r.length/3)return this.logger.warn("Mesh tangent vertex buffer must contain the same number of elements as the position buffer"),null;if(null!=n&&n.length/2!=r.length/3)return this.logger.warn("Mesh uv vertex buffer must contain the same number of elements as the position buffer"),null;const s=this._computeReprojectionInfo(e),l=this._createPositionBuffer(e,s),u=this._createColorBuffer(e),c=this._createSymbolColorBuffer(t),m=this._createNormalBuffer(e,l,s),h=this._createTangentBuffer(e,l,s);return{positionBuffer:l,normalBuffer:m,tangentBuffer:h,uvBuffer:n,colorBuffer:u,symbolColorBuffer:c,objectTransformation:s.reprojection===ve.NONE&&null!=s.objectTransformation?s.objectTransformation:this._transformOriginLocal(e,l,m,h),geometryTransformation:s.reprojection===ve.NONE&&null!=s.geometryTransformation?s.geometryTransformation:i()}}_computeReprojectionInfo(e){const t=null!=e.transform,r=t&&e.transform.geographic||this._context.renderCoordsHelper.viewingMode===U.Local?ve.NONE:ve.ECEF;if(t){if(r===ve.NONE){const t=i();y(e.spatialReference,e.transform.origin,t,this._context.renderCoordsHelper.spatialReference);return{reprojection:r,objectTransformation:t,geometryTransformation:l(e.transform.localMatrix),needsBufferCopy:!1}}const t=n(i(),e.transform.origin);return a(t,t,e.transform.localMatrix),{reprojection:r,transformBeforeProject:t,needsBufferCopy:!0}}return{reprojection:r,needsBufferCopy:!0}}_transformOriginLocal(e,o,n,a){const l=this._context.renderCoordsHelper.spatialReference,u=e.anchor;fe[0]=u.x,fe[1]=u.y,fe[2]=u.z;const c=i();return y(e.spatialReference,fe,c,l),s(_e,c),P(o,o,_e),null==n&&null==a||(t(Te,c),r(Te,Te),null!=n&&I(n,n,Te),null!=a&&I(a,a,Te,4)),c}_validateFaces(e,t){const r=e.vertexAttributes.position.length/3,o=t.faces;if(o){let e=-1;for(let t=0;t<o.length;t++){const r=o[t];r>e&&(e=r)}if(r<=e)return this.logger.warn(`Vertex index ${e} is out of bounds of the mesh position buffer`),!1}else if(r%3!=0)return this.logger.warn("Mesh position buffer length must be a multiple of 9 if no component faces are defined (3 values per vertex * 3 vertices per triangle)"),!1;return!0}_getOrCreateFaces(e,t){return t.faces??j(e.vertexAttributes.position.length/3)}_isOutsideClippingArea(e){if(!this._context.clippingExtent)return!1;const t=e.vertexAttributes&&e.vertexAttributes.position;if(!t)return!1;const r=this._context.elevationProvider.spatialReference;let o;const n=t.length/3;return null==r||e.spatialReference.equals(r)?o=t:(o=new Float64Array(t.length),b(e.vertexAttributes.position,e.spatialReference,0,o,r,0,n)),O(be),w(be,o,0,n),!A(be,this._context.clippingExtent)}_createGeometryInfo(e,t,r){if(!v(e.spatialReference,this._context.graphicsCoreOwner.view.spatialReference))return this.logger.warn("Geometry spatial reference is not compatible with the view"),null;if(this._isOutsideClippingArea(e))return null;const o=this._createBuffers(e,t);if(null==o)return null;const{positionBuffer:n,uvBuffer:a,colorBuffer:s,symbolColorBuffer:i,normalBuffer:l,tangentBuffer:u,objectTransformation:c,geometryTransformation:m}=o,h=this._getOrCreateComponents(e),f=new Array;let p=!1;for(const g of h){if(!this._validateFaces(e,g))return null;const t=this._getOrCreateFaces(e,g);if(0===t.length)continue;const o=this._createComponentNormals(n,l,g,t);o.didFlipNormals&&(p=!0);const c=[[se.POSITION,new X(n,3,!0)],[se.NORMAL,new X(o.normals,3,!0)]],h=[[se.POSITION,t],[se.NORMAL,o.indices]];null!=s&&(c.push([se.COLOR,new X(s,4,!0)]),h.push([se.COLOR,t])),null!=i&&(c.push([se.SYMBOLCOLOR,new X(i,4,!0)]),h.push([se.SYMBOLCOLOR,N(t.length)])),null!=a&&(c.push([se.UV0,new X(a,2,!0)]),h.push([se.UV0,t])),null!=u&&(c.push([se.TANGENT,new X(u,4,!0)]),h.push([se.TANGENT,t]));const d=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:r,layerUid:this._context.layer.uid}),x=this._getOrCreateMaterial(e,g),_=new oe(x,c,h,null,re.Mesh,d);_.transformation=m,f.push(_)}return p&&this.logger.warn("Normals have been automatically flipped to be consistent with the counter clock wise face winding order. It is better to generate mesh geometries that have consistent normals."),{geometries:f,objectTransformation:c}}}class he{constructor(e,t,r){this.normals=e,this.indices=t,this.didFlipNormals=r}}const fe=x(),pe=x(),ge=x(),de=x(),xe=x(),_e=i(),Te=o(),be=C(),ye=[new R];var ve;!function(e){e[e.NONE=0]="NONE",e[e.ECEF=1]="ECEF"}(ve||(ve={}));export{me as Graphics3DMeshFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import has from"../../../../core/has.js";import{get as t}from"../../../../core/maybe.js";import{throwIfAborted as s}from"../../../../core/promiseUtils.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{estimateSize as i}from"../../../../core/typedArrayUtil.js";import{i as a,k as o,w as n,c as l}from"../../../../chunks/mat4.js";import{c}from"../../../../chunks/mat4f64.js";import{l as h,o as d,c as m,C as p,a as u,s as y}from"../../../../chunks/vec3.js";import{d as _,O as f,Z as g,f as b,c as P}from"../../../../chunks/vec3f64.js";import{O as x,c as R}from"../../../../chunks/vec4f64.js";import{projectPointToVector as v,computeTranslationToOriginAndRotation as L}from"../../../../geometry/projection.js";import{create as C,size as S,containsPoint as j,center as w}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as E}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as U,objectSymbolLayerSizeWithResourceSize as T}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as I}from"./ElevationAligners.js";import{needsElevationUpdates3D as B,evaluateElevationInfoAtPoint as O,SampleElevationInfo as G}from"./elevationAlignmentUtils.js";import{ElevationContext as A}from"./ElevationContext.js";import D from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as M}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as z,mixinColorAndOpacity as F,computeObjectScale as V,computeObjectRotation as k}from"./graphicUtils.js";import{ApplyRendererDiffResult as H}from"./interfaces.js";import{LoadStatus as W}from"./Loadable.js";import{makeLodResources as q}from"./lodResourceUtils.js";import{fetch as N}from"./objectResourceUtils.js";import{placePointOnGeometry as $,extendPointGraphicElevationContext as Z}from"./pointUtils.js";import{isValidPrimitive as J,primitiveLodResources as K}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as Q}from"./symbolComplexity.js";import{initFastSymbolUpdatesState as X,updateFastSymbolUpdatesState as Y,ConvertOptions as ee,evaluateModelTransform as te,evaluateModelTransformScale as se}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as re}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as ie}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ae}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as oe,texturesFromLodResources as ne,geometriesFromLodResources as le,geometriesFromLodLevelResources as ce}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as he}from"../../webgl-engine/materials/DefaultMaterial.js";class de{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class me extends M{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(z(this.symbolLayer))throw new Error}const t=this.symbolLayer.resource;if(this._isPrimitive){const s=t&&J(t.primitive)?t.primitive:E;this._resources=await this._createResourcesForPrimitive(s,e)}else this._resources=await this._createResourcesForUrl(t.href,e);this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!(this.symbolLayer.resource&&this.symbolLayer.resource.href)}get lodRenderer(){return null!=this._resources?this._resources.lodRenderer:null}_setMaterialTransparencyParams(e,s=t(this.symbolLayer,"material","color")){const r=this._getCombinedOpacity(s),i=r<1||this.needsDrivenTransparentPass;return e.transparent=i,e.opacity=r,e.cullFace=i?re.None:re.Back,e}async _createResourcesForPrimitive(t,s){const i=this.symbolLayer,a=C(U(t)),o=_(S(a)),n=_(T(o,i)),l=h(n),c=!1,d=!1,m={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:f,diffuse:f,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},p=!!m.usePBR;this._setMaterialTransparencyParams(m);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=u.verticalOffset;m.verticalOffset={screenLength:r(e),minWorldLength:t||0,maxWorldLength:null!=s?s:1/0},m.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(m.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)m.externalColor=x;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):x;m.externalColor=s}this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),m.isInstanced=!0,this._fastUpdates?(Object.assign(m,this._fastUpdates.materialParameters),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(m.hasInstancedColor=!0,this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push("objectAndLayerIdColor");const y=new he(m),g=K(t,y);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=oe(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),P=await this._createStageResources(g,p,s),R=await this._createLodRenderer(g,s);return new de(g,R,P,b,o,c,d,a,n,l,p,null)}async _createResourcesForUrl(e,s){const i={materialParamsMixin:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=X(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(i.materialParamsMixin,this._fastUpdates.materialParameters),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(i.materialParamsMixin.hasInstancedColor=!0,this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push("objectAndLayerIdColor");const a=this.symbol;if("point-3d"===a.type&&a.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:s}=a.verticalOffset;i.materialParamsMixin.verticalOffset={screenLength:r(e),minWorldLength:t||0,maxWorldLength:null!=s?s:1/0},i.materialParamsMixin.castShadows=!1}i.signal=s,i.usePBR=this._context.physicalBasedRenderingEnabled,i.skipHighLods=this._context.skipHighSymbolLods;const o=i.usePBR,n=await N(e,i),l=n.isEsriSymbolResource,c=n.isWosr,d=q(n.lods);d.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const m=this._context,p=this.symbolLayer.material,u=this._getExternalColorParameters(p),y=t(this.symbolLayer,"material","color"),f=this._getCombinedOpacity(y,{hasIntrinsicColor:!0}),g=this.needsDrivenTransparentPass,b=oe(d),P=oe(d).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));b.forEach((e=>{const t=e.parameters;e.setParameters(u);const s=t.opacity*f,r=s<1||g||t.transparent;e.setParameters({opacity:s,transparent:r}),m.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:m.sharedResources.screenSizePerspectiveSettings})}));const x=n.referenceBoundingBox,R=_(S(x)),v=_(d.levels[0].pivotOffset),L=_(T(R,this.symbolLayer)),C=h(L),j=this._fastUpdates;Y(j,this._context.renderer,this._fastVisualVariableConvertOptions(x,L,R,v))&&b.forEach((e=>e.setParameters(j.materialParameters)));const w=await this._createStageResources(d,o,s),E=await this._createLodRenderer(d,s);return new de(d,E,w,P,R,l,c,x,L,C,o,v)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,t,r){const i=this._context.stage,a=oe(e);t!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=ne(e);i.addMany(o),this._addDisposeResource((()=>i.removeMany(o))),await i.load(o,r),s(r);const n=le(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,_e),l(s,te(i.materialParameters,_e,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,_e),se(e,i.materialParameters,_e)}}:null,o=new ae({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o.slots,o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=x:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=x,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=$(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new A),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,s=!this._isPrimitive,r=this._resources.stageResources.materials,i=this._resources.originalMaterialParameters;for(let a=0;a<r.length;a++){const o=r[a],n=t(this.symbolLayer,"material","color"),l=i[a],c=this._getCombinedOpacity(n,{hasIntrinsicColor:s})*l.opacity,h=c<1||e||l.transparent;o.setParameters({opacity:c,transparent:h}),this._isPrimitive&&o.setParameters({cullFace:h?re.None:re.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,B)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return H.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return H.RecreateSymbol;if(!Y(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return H.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return H.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=ce(e.levels[0]).reduce(((e,t)=>e+t.indices.get(ie.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+i(t.data)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+i(t)),0),r=ne(e).reduce(((e,t)=>e+(t.params.encoding&&"image/ktx2"===t.params.encoding?t.estimatedTexMemRequired:t.estimatedTexMemRequired/4)),0)+le(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...Q(this.symbol,this.symbolLayer),resourceBytes:r}}}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=null==this._fastUpdates&&this._hasPerInstanceColor()?F(s.color,s.opacity):null,l=this._context.clippingExtent;if(v(t,pe,this._context.elevationProvider.spatialReference),null!=l&&!j(l,pe))return null;const c=this._requiresTerrainElevation(r),h=this._computeGlobalTransform(t,r,ye,fe),d=this._computeLocalTransform(this._resources,this.symbolLayer,s,ue),m=this._resources.lodRenderer.instanceData,p=m.addInstance();this._instanceIndexToGraphicUid.set(p,i),m.setLocalTransform(p,d,!1),m.setGlobalTransform(p,h),o&&m.setFeatureAttribute(p,o),n&&m.setColor(p,n),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&m.setObjectAndLayerIdColor(p,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const u=new D(this,p,I,r);return c&&(u.alignedSampledElevation=fe.sampledElevation),u.needsElevationUpdates=B(r.mode),Z(u,t,this._context.elevationProvider),u}_computeGlobalTransform(e,t,s,r){return O(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),pe[0]=e.x,pe[1]=e.y,pe[2]=r.z,L(e.spatialReference,pe,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return a(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=V(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||o(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=t&&$(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,ye,fe),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=fe.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,ye,!0),Z(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},m=this._resources;this.loadStatus===W.LOADED&&e.symbolLayerStatePatches.push((()=>{m.symbolSize=_(T(m.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(m,d,t,ue),r=e.instanceIndex;m.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):x;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParams({},i)):t=this._setMaterialTransparencyParams({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return k(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=P();switch(s.anchor){case"center":m(r,w(e)),d(r,r);break;case"top":{const t=w(e);y(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=w(e);y(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=w(e),i=S(e),a=s.anchorPosition,o=a?b(a.x,a.y,a.z):g;p(r,i,o),u(r,r,t),d(r,r);break}default:null!=t?d(r,t):m(r,g)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&n(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?_(S(e)):f,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):g,o=this._context.renderCoordsHelper.unitInMeters,n=V(null!=t?t:void 0,t,s,o),l=b(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new ee({size:!0,color:!0,rotation:!0,opacity:!1},i,t??f,o,a,n,l)}}const pe=P(),ue=c(),ye=c(),_e=R(),fe=new G;export{me as Graphics3DObjectSymbolLayer};
|
|
5
|
+
import e from"../../../../Color.js";import has from"../../../../core/has.js";import{throwIfAborted as t}from"../../../../core/promiseUtils.js";import{pt2px as s}from"../../../../core/screenUtils.js";import{estimateSize as r}from"../../../../core/typedArrayUtil.js";import{i,k as a,w as o,c as n}from"../../../../chunks/mat4.js";import{c as l}from"../../../../chunks/mat4f64.js";import{l as c,o as h,c as d,C as p,a as m,s as u}from"../../../../chunks/vec3.js";import{d as y,O as _,Z as f,f as g,c as b}from"../../../../chunks/vec3f64.js";import{O as P,c as x}from"../../../../chunks/vec4f64.js";import{projectPointToVector as R,computeTranslationToOriginAndRotation as v}from"../../../../geometry/projection.js";import{create as L,size as C,containsPoint as S,center as j}from"../../../../geometry/support/aaBoundingBox.js";import{defaultPrimitive as w}from"../../../../symbols/support/ObjectSymbol3DLayerResource.js";import{objectSymbolLayerPrimitiveBoundingBox as E,objectSymbolLayerSizeWithResourceSize as U}from"../../../../symbols/support/symbolLayerUtils3D.js";import{perLodInstanceElevationAligner as T}from"./ElevationAligners.js";import{needsElevationUpdates3D as I,evaluateElevationInfoAtPoint as B,SampleElevationInfo as O}from"./elevationAlignmentUtils.js";import{ElevationContext as G}from"./ElevationContext.js";import A from"./Graphics3DLodInstanceGraphicLayer.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as M,mixinColorAndOpacity as z,computeObjectScale as F,computeObjectRotation as V}from"./graphicUtils.js";import{ApplyRendererDiffResult as k}from"./interfaces.js";import{LoadStatus as H}from"./Loadable.js";import{makeLodResources as W}from"./lodResourceUtils.js";import{fetch as q}from"./objectResourceUtils.js";import{placePointOnGeometry as N,extendPointGraphicElevationContext as $}from"./pointUtils.js";import{isValidPrimitive as Z,primitiveLodResources as J}from"./primitiveObjectSymbolUtils.js";import{defaultSymbolLayerMemoryComplexity as K}from"./symbolComplexity.js";import{initFastSymbolUpdatesState as Q,updateFastSymbolUpdatesState as X,ConvertOptions as Y,evaluateModelTransform as ee,evaluateModelTransformScale as te}from"../support/FastSymbolUpdates.js";import{CullFaceOptions as se}from"../../webgl-engine/lib/basicInterfaces.js";import{VertexAttribute as re}from"../../webgl-engine/lib/VertexAttribute.js";import{LodRenderer as ie}from"../../webgl-engine/lib/lodRendering/LodRenderer.js";import{materialsFromLodResources as ae,texturesFromLodResources as oe,geometriesFromLodResources as ne,geometriesFromLodLevelResources as le}from"../../webgl-engine/lib/lodRendering/LodResources.js";import{DefaultMaterial as ce}from"../../webgl-engine/materials/DefaultMaterial.js";class he{constructor(e,t,s,r,i,a,o,n,l,c,h,d){this.lodResources=e,this.lodRenderer=t,this.stageResources=s,this.originalMaterialParameters=r,this.resourceSize=i,this.isEsriSymbolResource=a,this.isWosr=o,this.resourceBoundingBox=n,this.symbolSize=l,this.extentPadding=c,this.physicalBasedRenderingEnabled=h,this.pivotOffset=d}}class de extends D{getCachedSize(){const[e,t,s]=null!=this._resources?this._resources.symbolSize:[1,1,1];return{width:e,depth:t,height:s}}constructor(e,t,s,r){super(e,t,s,r),this._resources=null,this._optionalFields=new Array,this._instanceIndexToGraphicUid=new Map,this._hasLoadedPBRTextures=!1,this._disposeResourceHandles=new Array,this.skipHighSymbolLodsChanged=!1,this.ensureDrapedStatus(!1),this._hasLoadedPBRTextures=s.physicalBasedRenderingEnabled}async doLoad(e){if(!this._drivenProperties.size){if(M(this.symbolLayer))throw new Error}const t=this.symbolLayer.resource;if(this._isPrimitive){const s=t&&Z(t.primitive)?t.primitive:w;this._resources=await this._createResourcesForPrimitive(s,e)}else this._resources=await this._createResourcesForUrl(t.href,e);this.layerOpacityChanged(),this.slicePlaneEnabledChanged(),this.physicalBasedRenderingChanged(),this.complexity=this.computeComplexity()}get extentPadding(){return null!=this._resources?this._resources.extentPadding:0}get _isPrimitive(){return!(this.symbolLayer.resource&&this.symbolLayer.resource.href)}get lodRenderer(){return null!=this._resources?this._resources.lodRenderer:null}_setMaterialTransparencyParams(e,t=this.symbolLayer?.material?.color){const s=this._getCombinedOpacity(t),r=s<1||this.needsDrivenTransparentPass;return e.transparent=r,e.opacity=s,e.cullFace=r?se.None:se.Back,e}async _createResourcesForPrimitive(t,r){const i=this.symbolLayer,a=L(E(t)),o=y(C(a)),n=y(U(o,i)),l=c(n),h=!1,d=!1,p={usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0,ambient:_,diffuse:_,hasSlicePlane:this._context.slicePlaneEnabled,hasSliceHighlight:!1,castShadows:this.symbolLayer.castShadows,offsetTransparentBackfaces:!this.symbolLayer.isPrimitive},m=!!p.usePBR;this._setMaterialTransparencyParams(p);const u=this.symbol;if("point-3d"===u.type&&u.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:r}=u.verticalOffset;p.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=r?r:1/0},p.castShadows=!1}if(this._context.screenSizePerspectiveEnabled&&(p.screenSizePerspective=this._context.sharedResources.screenSizePerspectiveSettings),this._drivenProperties.color)p.externalColor=P;else{const t=null!=i.material?i.material.color:null,s=null!=t?e.toUnitRGBA(t):P;p.externalColor=s}this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(a,n,o,null)),p.isInstanced=!0,this._fastUpdates?(Object.assign(p,this._fastUpdates.materialParameters),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(p.hasInstancedColor=!0,this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push("objectAndLayerIdColor");const f=new ce(p),g=J(t,f);if(!g)throw new Error(`Unknown object symbol primitive: ${t}`);const b=ae(g).map((e=>({opacity:1,transparent:e.parameters.transparent}))),x=await this._createStageResources(g,m,r),R=await this._createLodRenderer(g,r);return new he(g,R,x,b,o,h,d,a,n,l,m,null)}async _createResourcesForUrl(e,t){const r={materialParamsMixin:{isInstanced:!0,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows},streamDataRequester:this._context.streamDataRequester,cache:this._context.sharedResources.objectResourceCache};this._fastUpdates=Q(this._context.renderer,this._fastVisualVariableConvertOptions(null,null,null,null)),this._fastUpdates?(Object.assign(r.materialParamsMixin,this._fastUpdates.materialParameters),this._optionalFields.push("featureAttribute")):this._hasPerInstanceColor()&&(r.materialParamsMixin.hasInstancedColor=!0,this._optionalFields.push("color")),has("enable-feature:objectAndLayerId-rendering")&&this._optionalFields.push("objectAndLayerIdColor");const i=this.symbol;if("point-3d"===i.type&&i.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:a}=i.verticalOffset;r.materialParamsMixin.verticalOffset={screenLength:s(e),minWorldLength:t||0,maxWorldLength:null!=a?a:1/0},r.materialParamsMixin.castShadows=!1}r.signal=t,r.usePBR=this._context.physicalBasedRenderingEnabled,r.skipHighLods=this._context.skipHighSymbolLods;const a=r.usePBR,o=await q(e,r),n=o.isEsriSymbolResource,l=o.isWosr,h=W(o.lods);h.levels.sort(((e,t)=>e.minScreenSpaceRadius-t.minScreenSpaceRadius));const d=this._context,p=this.symbolLayer.material,m=this._getExternalColorParameters(p),u=this.symbolLayer?.material?.color,_=this._getCombinedOpacity(u,{hasIntrinsicColor:!0}),f=this.needsDrivenTransparentPass,g=ae(h),b=ae(h).map((e=>({opacity:e.parameters.opacity||1,transparent:e.parameters.transparent})));g.forEach((e=>{const t=e.parameters;e.setParameters(m);const s=t.opacity*_,r=s<1||f||t.transparent;e.setParameters({opacity:s,transparent:r}),d.screenSizePerspectiveEnabled&&e.setParameters({screenSizePerspective:d.sharedResources.screenSizePerspectiveSettings})}));const P=o.referenceBoundingBox,x=y(C(P)),R=y(h.levels[0].pivotOffset),v=y(U(x,this.symbolLayer)),L=c(v),S=this._fastUpdates;X(S,this._context.renderer,this._fastVisualVariableConvertOptions(P,v,x,R))&&g.forEach((e=>e.setParameters(S.materialParameters)));const j=await this._createStageResources(h,a,t),w=await this._createLodRenderer(h,t);return new he(h,w,j,b,x,n,l,P,v,L,a,R)}_addDisposeResource(e){this._disposeResourceHandles.push(e)}async _createStageResources(e,s,r){const i=this._context.stage,a=ae(e);s!==this._context.physicalBasedRenderingEnabled&&this.physicalBasedRenderingChanged(),i.addMany(a),this._addDisposeResource((()=>i.removeMany(a)));const o=oe(e);i.addMany(o),this._addDisposeResource((()=>i.removeMany(o))),await i.load(o,r),t(r);const n=ne(e);return i.addMany(n),this._addDisposeResource((()=>i.removeMany(n))),{materials:a,textures:o,geometries:n}}async _createLodRenderer(e,t){const s=this._context.stage,r={layerUid:this._context.layer.uid,graphicUid:e=>this._instanceIndexToGraphicUid.get(e),notifyGraphicGeometryChanged:e=>this._context.notifyGraphicGeometryChanged(this._instanceIndexToGraphicUid.get(e)),notifyGraphicVisibilityChanged:e=>this._context.notifyGraphicVisibilityChanged(this._instanceIndexToGraphicUid.get(e))},i=this._fastUpdates,a=i?{applyTransform:(e,t,s)=>{e.getFeatureAttribute(t,ye),n(s,ee(i.materialParameters,ye,s))},scaleFactor:(e,t,s)=>{t.getFeatureAttribute(s,ye),te(e,i.materialParameters,ye)}}:null,o=new ie({symbol:e,optionalFields:this._optionalFields,metadata:r,shaderTransformation:a},this._context.scheduler);return o.slicePlaneEnabled=this._context.slicePlaneEnabled,this._addDisposeResource((()=>{s.removeRenderPlugin(o),o.destroy()})),await s.addRenderPlugin(o.slots,o,t),o}_getExternalColorParameters(t){const s={};return this._drivenProperties.color?s.externalColor=P:null!=t&&null!=t.color?s.externalColor=e.toUnitRGBA(t.color):(s.externalColor=P,s.colorMixMode="ignore"),s}destroy(){super.destroy(),this._cleanupResources()}_cleanupResources(){this._disposeResourceHandles.forEach((e=>e())),this._disposeResourceHandles.length=0,this._resources=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry))return null;const s=N(t.geometry);if(null==s)return this.logger.warn(`unsupported geometry type for icon symbol: ${t.geometry.type}`),null;const r=this.setGraphicElevationContext(t,new G),i=e.renderingInfo;return this._createAs3DShape(t,s,i,r,t.uid,e.layer.uid)}notifyDestroyGraphicLayer(e){this._instanceIndexToGraphicUid.delete(e.instanceIndex)}graphicLayerToGraphicId(){return 0}layerOpacityChanged(){if(null==this._resources)return;const e=this._drivenProperties.opacity,t=!this._isPrimitive,s=this._resources.stageResources.materials,r=this._resources.originalMaterialParameters;for(let i=0;i<s.length;i++){const a=s[i],o=this.symbolLayer?.material?.color,n=r[i],l=this._getCombinedOpacity(o,{hasIntrinsicColor:t})*n.opacity,c=l<1||e||n.transparent;a.setParameters({opacity:l,transparent:c}),this._isPrimitive&&a.setParameters({cullFace:c?se.None:se.Back})}}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,I)}slicePlaneEnabledChanged(){if(null==this._resources)return!0;this._resources.lodRenderer.slicePlaneEnabled=this._context.slicePlaneEnabled;for(const e of this._resources.stageResources.materials)e.setParameters({hasSlicePlane:this._context.slicePlaneEnabled});return!0}physicalBasedRenderingChanged(){if(null==this._resources)return!0;const{stageResources:e,isWosr:t}=this._resources;for(const s of e.materials)this._isPrimitive?s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}):t||s.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!1});return!1!==this._hasLoadedPBRTextures||!0!==this._context.physicalBasedRenderingEnabled||(this._hasLoadedPBRTextures=!0,!1)}applyRendererDiff(e,t){if(null==this._resources)return k.RecreateSymbol;const{stageResources:{materials:s},lodRenderer:r,resourceBoundingBox:i,symbolSize:a,resourceSize:o,pivotOffset:n}=this._resources;for(const l in e.diff){if("visualVariables"!==l)return k.RecreateSymbol;if(!X(this._fastUpdates,t,this._fastVisualVariableConvertOptions(i,a,o,n)))return k.RecreateSymbol;for(const e of s)e.setParameters(this._fastUpdates.materialParameters);r.notifyShaderTransformationChanged()}return k.FastUpdate}computeComplexity(){if(null==this._resources)return super.computeComplexity();const e=this._resources.lodResources,t=le(e.levels[0]).reduce(((e,t)=>e+t.indices.get(re.POSITION).length),0)/3,s=e=>Array.from(e.vertexAttributes.values()).reduce(((e,t)=>e+r(t.data)),0)+Array.from(e.indices.values()).reduce(((e,t)=>e+r(t)),0),i=oe(e).reduce(((e,t)=>e+(t.params.encoding&&"image/ktx2"===t.params.encoding?t.estimatedTexMemRequired:t.estimatedTexMemRequired/4)),0)+ne(e).reduce(((e,t)=>e+s(t)),0);return{primitivesPerFeature:t,primitivesPerCoordinate:0,drawCallsPerFeature:0,estimated:!1,memory:{...K(this.symbol,this.symbolLayer),resourceBytes:i}}}_hasLodRenderer(){return null!=this._resources}_createAs3DShape(e,t,s,r,i,a){if(!this._hasLodRenderer()||null==this._resources)return null;const o=this.getFastUpdateAttrValues(e),n=null==this._fastUpdates&&this._hasPerInstanceColor()?z(s.color,s.opacity):null,l=this._context.clippingExtent;if(R(t,pe,this._context.elevationProvider.spatialReference),null!=l&&!S(l,pe))return null;const c=this._requiresTerrainElevation(r),h=this._computeGlobalTransform(t,r,ue,_e),d=this._computeLocalTransform(this._resources,this.symbolLayer,s,me),p=this._resources.lodRenderer.instanceData,m=p.addInstance();this._instanceIndexToGraphicUid.set(m,i),p.setLocalTransform(m,d,!1),p.setGlobalTransform(m,h),o&&p.setFeatureAttribute(m,o),n&&p.setColor(m,n),null!=this._context.stage.renderView.objectAndLayerIdRenderHelper&&p.setObjectAndLayerIdColor(m,this._context.stage.renderView.objectAndLayerIdRenderHelper.getObjectAndLayerIdColor({graphicUid:i,layerUid:a}));const u=new A(this,m,T,r);return c&&(u.alignedSampledElevation=_e.sampledElevation),u.needsElevationUpdates=I(r.mode),$(u,t,this._context.elevationProvider),u}_computeGlobalTransform(e,t,s,r){return B(e,this._context.elevationProvider,t,this._context.renderCoordsHelper,r),pe[0]=e.x,pe[1]=e.y,pe[2]=r.z,v(e.spatialReference,pe,s,this._context.renderCoordsHelper.spatialReference),s}_computeLocalTransform(e,t,s,r){return i(r),this._applyObjectRotation(s,!1,r),this._applyObjectRotation(t,!0,r),this._applyObjectScale(e,s,r),this._applyAnchor(e,t,r),r}_applyObjectScale(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._drivenProperties.size&&t.size?t.size:e.symbolSize,i=F(r,e.symbolSize,e.resourceSize,this._context.renderCoordsHelper.unitInMeters);1===i[0]&&1===i[1]&&1===i[2]||a(s,s,i)}prepareSymbolLayerPatch(e){if("partial"!==e.diff.type)return;const t=e.diff.diff;this._preparePatchTransform(e,t),this._preparePatchColor(e,t)}updateGeometry(e,t){if(null==this._resources)return!0;const s=t&&N(t);if(null==s)return!1;const r=this.getGeometryElevationMode(t);return e.elevationContext.mode===r&&(this._computeGlobalTransform(s,e.elevationContext,ue,_e),this._requiresTerrainElevation(e.elevationContext)&&(e.alignedSampledElevation=_e.sampledElevation),this._resources.lodRenderer.instanceData.setGlobalTransform(e.instanceIndex,ue,!0),$(e,s,this._context.elevationProvider),!0)}_preparePatchTransform(e,t){if(!(t.heading||t.tilt||t.roll||t.width||t.height||t.depth||t.anchor||t.anchorPosition))return;if(null==this._resources)return;const s=(e,t,s)=>(null!=e&&"complete"===e.type?e.newValue:t)??s,r=s(t.heading,this.symbolLayer.heading,0),i=s(t.tilt,this.symbolLayer.tilt,0),a=s(t.roll,this.symbolLayer.roll,0),o=s(t.width,this.symbolLayer.width,void 0),n=s(t.height,this.symbolLayer.height,void 0),l=s(t.depth,this.symbolLayer.depth,void 0),c=s(t.anchor,this.symbolLayer.anchor,void 0),h=s(t.anchorPosition,this.symbolLayer.anchorPosition,void 0);delete t.heading,delete t.tilt,delete t.roll,delete t.width,delete t.height,delete t.depth,delete t.anchor,delete t.anchorPosition;const d={heading:r,tilt:i,roll:a,anchor:c,anchorPosition:h},p=this._resources;this.loadStatus===H.LOADED&&e.symbolLayerStatePatches.push((()=>{p.symbolSize=y(U(p.resourceSize,{width:o,height:n,depth:l,isPrimitive:this.symbolLayer.isPrimitive}))})),e.graphics3DGraphicPatches.push(((e,t)=>{const s=this._computeLocalTransform(p,d,t,me),r=e.instanceIndex;p.lodRenderer.instanceData.setLocalTransform(r,s,!0)}))}_preparePatchColor(t,s){if(!s.material||"partial"!==s.material.type)return;const r=s.material.diff;if(!r.color||"complete"!==r.color.type||null==r.color.newValue||null==r.color.oldValue)return;const i=r.color.newValue,a=null!=i?e.toUnitRGBA(i):P;delete r.color;const o=this._resources;null!=o&&t.graphics3DGraphicPatches.push((e=>{let t;this._hasPerInstanceColor()?(o.lodRenderer.instanceData.setColor(e.instanceIndex,a),t=this._setMaterialTransparencyParams({},i)):t=this._setMaterialTransparencyParams({externalColor:a},i);for(const s of o.stageResources.materials)s.setParameters(t)}))}_requiresTerrainElevation(e){return"absolute-height"!==e.mode}_applyObjectRotation(e,t,s){if(!this._fastUpdates?.requiresShaderTransformation||!t)return V(e.heading,e.tilt,e.roll,s)}_computeAnchor(e,t,s){const r=b();switch(s.anchor){case"center":d(r,j(e)),h(r,r);break;case"top":{const t=j(e);u(r,-t[0],-t[1],-e[5]);break}case"bottom":{const t=j(e);u(r,-t[0],-t[1],-e[2]);break}case"relative":{const t=j(e),i=C(e),a=s.anchorPosition,o=a?g(a.x,a.y,a.z):f;p(r,i,o),m(r,r,t),h(r,r);break}default:null!=t?h(r,t):d(r,f)}return r}_applyAnchor(e,t,s){if(this._fastUpdates?.requiresShaderTransformation)return;const r=this._computeAnchor(e.resourceBoundingBox,e.pivotOffset,t);r&&o(s,s,r)}_hasPerInstanceColor(){return this._drivenProperties.color||this._drivenProperties.opacity}_fastVisualVariableConvertOptions(e,t,s,r){const i=null!=e?y(C(e)):_,a=null!=e?this._computeAnchor(e,r,this.symbolLayer):f,o=this._context.renderCoordsHelper.unitInMeters,n=F(null!=t?t:void 0,t,s,o),l=g(this.symbolLayer.tilt||0,this.symbolLayer.roll||0,this.symbolLayer.heading||0);return new Y({size:!0,color:!0,rotation:!0,opacity:!1},i,t??_,o,a,n,l)}}const pe=b(),me=l(),ue=l(),ye=x(),_e=new O;export{de as Graphics3DObjectSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../../core/has.js";import e from"../../../../core/Error.js";import{get as t}from"../../../../core/maybe.js";import{w as i}from"../../../../chunks/mat4.js";import{I as s,c as r}from"../../../../chunks/mat4f64.js";import{s as a,b as o}from"../../../../chunks/vec2.js";import{f as n,b as l}from"../../../../chunks/vec2f64.js";import{s as h}from"../../../../chunks/vec3.js";import{d as c,c as p}from"../../../../chunks/vec3f64.js";import{projectBuffer as m}from"../../../../geometry/projection.js";import{create as f,empty as d,expandWithBuffer as u,intersectsClippingArea as y}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as b,doubleArrayFrom as _}from"../../../../geometry/support/DoubleArray.js";import{needsElevationUpdates3D as g,evaluateElevationAlignmentAtPoint as v,SampleElevationInfo as w}from"./elevationAlignmentUtils.js";import{ElevationContext as x}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as P}from"./Graphics3DObject3DGraphicLayer.js";import{PATH_NUM_CIRCLE_PROFILE_SUBDIVISIONS as j,PATH_NUM_ROUND_JOIN_SUBDIVISIONS as S,PATH_NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS as D}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as C}from"./Graphics3DSymbolLayer.js";import{isValidSize as L}from"./graphicUtils.js";import{ApplyRendererDiffResult as V}from"./interfaces.js";import{ConvertOptions as U,initFastSymbolUpdatesState as E,updateFastSymbolUpdatesState as k,getAttributeValue as R}from"../support/FastSymbolUpdates.js";import{SamplePosition as z}from"../../support/ElevationProvider.js";import{CullFaceOptions as A}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as G}from"../../webgl-engine/lib/Object3D.js";import{Path as I}from"../../webgl-engine/lib/Path.js";import{PathBuilder as B}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as O,TriangulationCapBuilder as q,NoCapBuilder as F}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as H,MiterExtruder as M}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as W,PathGeometry as N,isPathGeometry as T}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as Z,StaticPathGeometry as J}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as K}from"../../webgl-engine/lib/pathGeometryUtils.js";import{creatQuadProfile as Q,createCircleProfile as X}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as Y}from"../../webgl-engine/lib/PathVertex.js";import{DefaultMaterial as $}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as ee}from"../../webgl-engine/materials/PathMaterial.js";const te=["polyline"];class ie extends C{constructor(e,t,i,s){super(e,t,i,s),this._intrinsicSize=n(1,1),this._upVectorAlignment=W.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const i=null!=this.symbolLayer.width?this.symbolLayer.width:this.symbolLayer.height,s=null!=this.symbolLayer.height?this.symbolLayer.height:i;this._vvConvertOptions=new U({size:!0,color:!0,rotation:!1,opacity:!0},[1,1,1],[i,1,s],this._context.renderCoordsHelper.unitInMeters),this._fastUpdates=this._context.renderer?.visualVariables?.length>0?E(this._context.renderer,this._vvConvertOptions):null;const r=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?W.World:W.Path;const n=this.symbolLayer.profile||"circle";switch(n){default:case"circle":this._profile=X(j);break;case"quad":this._profile=Q()}let h=[0,0];switch("center"!==r&&(h={left:[.5,0],right:[-.5,0],top:[0,-.5],bottom:[0,.5]}[r],this._profile.translate(h[0],h[1])),this.symbolLayer.join){case"round":this._extruder=new M(0,S);break;case"bevel":this._extruder=new M(0,1);break;case"miter":this._extruder=new M(.8*Math.PI,1);break;default:this._extruder=new H}const p=this.symbolLayer.cap||"butt";switch(p){case"none":this._startCap=new F,this._endCap=new F;break;case"butt":default:this._startCap=new q(this._profile,0),this._endCap=new q(this._profile,0,!0);break;case"square":this._startCap=new q(this._profile,-.5),this._endCap=new q(this._profile,.5,!0);break;case"round":{const e="quad"===n;this._startCap=new O({profile:this._profile,flip:!1,breakNormals:e,subdivisions:D}),this._endCap=new O({profile:this._profile,flip:!0,breakNormals:e,subdivisions:D});break}}const m=t(this.symbolLayer,"material","color"),f=this._getCombinedOpacityAndColor(m),d=c(f),u=f[3],y=u<1||this.needsDrivenTransparentPass,b={diffuse:d,ambient:d,opacity:u,transparent:y,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:y||"none"===p?A.None:A.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(a(this._intrinsicSize,i,s),!L(this._intrinsicSize[0])||!L(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates&&this._fastUpdates.visualVariables.size||o(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates){const e={...b,...this._fastUpdates.materialParameters,size:l(this._intrinsicSize)};this._material=new ee(e)}else b.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,this._material=new $(b);this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,te,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t,new x),s=e.renderingInfo;return this._createAs3DShape(t,s,i,t.uid)}layerOpacityChanged(){const e=t(this.symbolLayer,"material","color"),i=this._getCombinedOpacity(e),s=i<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:i,transparent:s})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,g)}slicePlaneEnabledChanged(){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return V.RecreateSymbol;if(!k(this._fastUpdates,t,this._vvConvertOptions))return V.RecreateSymbol;this._material.setParameters(this._fastUpdates.materialParameters)}return V.FastUpdate}_getVertexData(e){let t=0;const i=e.paths,s=[],r=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const c of i)t+=c.length;const n=b(3*t);let l,h=0;for(const c of i){s.push({offset:h,numVertices:c.length});for(const t of c)n[h++]=t[0],n[h++]=t[1],n[h++]=e.hasZ?t[2]:0}return null==a||r.equals(a)||m(n,r,0,n,a,0,t)?(null==a||a.equals(o)?l=_(n):(l=b(3*t),m(n,a,0,l,o,0,t)),{pathVertexDataInfos:s,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,t,a,o){const n=e.geometry,l=this._getVertexData(n);if(null==l)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===l.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const c=new Array,p=n.spatialReference,m=f(),b=this._context.renderCoordsHelper,_=new z(l.vertexDataES);for(const f of l.pathVertexDataInfos){const n=f.numVertices;if(n<2)continue;const g=f.offset;if(null!=this._context.clippingExtent&&(d(m),u(m,l.vertexDataES,g,n),!y(m,this._context.clippingExtent)))continue;const w=new Array,x=g+3*n;for(let e=g;e<x;e+=3){_.offset=e;const t=v(_,this._context.elevationProvider,a,b);h(ne,l.vertexDataRS[e],l.vertexDataRS[e+1],l.vertexDataRS[e+2]),b.setAltitude(ne,t),l.vertexDataRS[e]=ne[0],l.vertexDataRS[e+1]=ne[1],l.vertexDataRS[e+2]=ne[2],w.push(Y(this._upVectorAlignment))}const P=new I(w,l.vertexDataES,l.vertexDataRS,g);se(P,this._upVectorAlignment,this._context.renderCoordsHelper);const j=new B(P,this._profile,this._extruder,this._startCap,this._endCap);let S=null;if(this._fastUpdates){const t=this._fastUpdates.visualVariables,i=R(t.size?.field,e)??0,s=R(t.color?.field,e)??0,r=R(t.opacity?.field,e)??0;S=new Z(j,i,s,r)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];if(this._drivenProperties.size){const i=t.size;e[0]*=re(i[0],"symbol-value"===i[2]?this.symbolLayer.height||0:i[2],this.symbolLayer.width||0),e[1]*=re(i[2],"symbol-value"===i[0]?this.symbolLayer.width||0:i[0],this.symbolLayer.height||0)}let i;this._drivenProperties.color&&(i=t.color),this._drivenProperties.opacity&&null!=t.opacity&&(i=i?[i[0],i[1],i[2],t.opacity]:[1,1,1,t.opacity]);const s=new J(j);s.bake(e),i&&s.bakeVertexColors(i),S=s}const{vertexAttributes:D,indices:C}=S.createGeometryData(),L=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid}),V=new N(this._material,D,C,S,p,this._stencilWidth,L);V.transformation=i(r(),s,j.path.origin),c.push(V)}if(0===c.length)return null;const w=new G({geometries:c,layerUid:this._context.layer.uid,graphicUid:o}),x=new P(this,w,c,null,null,((e,t,i,s,r)=>oe(e,t,s,r,this._upVectorAlignment)),a);return x.alignedSampledElevation=0,x.needsElevationUpdates=g(a.mode),x}}function se(e,t,i){const{origin:s,positions:r}=e;let a=e.offset;switch(t){default:case W.World:for(const t of e.vertices)ne[0]=r[a++]+s[0],ne[1]=r[a++]+s[1],ne[2]=r[a++]+s[2],i.worldUpAtPosition(ne,ne),t.setFrameFromUpVector(ne);break;case W.Path:ne[0]=r[a]+s[0],ne[1]=r[a+1]+s[1],ne[2]=r[a+2]+s[2],i.worldUpAtPosition(ne,ne),K(e,ne)}}function re(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function ae(e,t,i,s){let r=0;const{origin:a,vertices:o,positions:n,positionsES:l}=e,c=e.offset+3*o.length;for(let p=e.offset;p<c;p+=3)h(ne,l[p],l[p+1],l[p+2]),i(ne,le),r+=le.sampledElevation,ne[0]=n[p]+a[0],ne[1]=n[p+1]+a[1],ne[2]=n[p+2]+a[2],s.setAltitude(ne,le.z),n[p]=ne[0]-a[0],n[p+1]=ne[1]-a[1],n[p+2]=ne[2]-a[2];return e.updatePathVertexInformation(),r/o.length}function oe(e,t,i,s,r){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!T(l))continue;const e=l.path,o=e.builder.path;n+=ae(o,t,i,s),r!==W.World&&se(o,r,s),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttrsUpdated(l)}return n/o.length}const ne=p(),le=new w;export{ie as Graphics3DPathSymbolLayer};
|
|
5
|
+
import"../../../../core/has.js";import e from"../../../../core/Error.js";import{w as t}from"../../../../chunks/mat4.js";import{I as i,c as s}from"../../../../chunks/mat4f64.js";import{s as r,b as a}from"../../../../chunks/vec2.js";import{f as o,b as n}from"../../../../chunks/vec2f64.js";import{s as l}from"../../../../chunks/vec3.js";import{d as h,c}from"../../../../chunks/vec3f64.js";import{projectBuffer as p}from"../../../../geometry/projection.js";import{create as m,empty as f,expandWithBuffer as d,intersectsClippingArea as u}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as y,doubleArrayFrom as b}from"../../../../geometry/support/DoubleArray.js";import{needsElevationUpdates3D as _,evaluateElevationAlignmentAtPoint as g,SampleElevationInfo as v}from"./elevationAlignmentUtils.js";import{ElevationContext as w}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as x}from"./Graphics3DObject3DGraphicLayer.js";import{PATH_NUM_CIRCLE_PROFILE_SUBDIVISIONS as P,PATH_NUM_ROUND_JOIN_SUBDIVISIONS as j,PATH_NUM_ROUND_CAP_EXTRUSION_SUBDIVISIONS as S}from"./Graphics3DPathSymbolLayerConstants.js";import{Graphics3DSymbolLayer as D}from"./Graphics3DSymbolLayer.js";import{isValidSize as C}from"./graphicUtils.js";import{ApplyRendererDiffResult as L}from"./interfaces.js";import{ConvertOptions as V,initFastSymbolUpdatesState as U,updateFastSymbolUpdatesState as E,getAttributeValue as k}from"../support/FastSymbolUpdates.js";import{SamplePosition as R}from"../../support/ElevationProvider.js";import{CullFaceOptions as z}from"../../webgl-engine/lib/basicInterfaces.js";import{Object3D as A}from"../../webgl-engine/lib/Object3D.js";import{Path as G}from"../../webgl-engine/lib/Path.js";import{PathBuilder as I}from"../../webgl-engine/lib/PathBuilder.js";import{RoundCapBuilder as B,TriangulationCapBuilder as O,NoCapBuilder as q}from"../../webgl-engine/lib/PathCapBuilder.js";import{SimpleExtruder as F,MiterExtruder as H}from"../../webgl-engine/lib/PathExtruder.js";import{UpVectorAlignment as M,PathGeometry as W,isPathGeometry as N}from"../../webgl-engine/lib/PathGeometry.js";import{FastUpdatePathGeometry as T,StaticPathGeometry as Z}from"../../webgl-engine/lib/PathGeometryData.js";import{computeMinimumRotationTangentFrame as J}from"../../webgl-engine/lib/pathGeometryUtils.js";import{creatQuadProfile as K,createCircleProfile as Q}from"../../webgl-engine/lib/PathProfile.js";import{newPathVertex as X}from"../../webgl-engine/lib/PathVertex.js";import{DefaultMaterial as Y}from"../../webgl-engine/materials/DefaultMaterial.js";import{PathMaterial as $}from"../../webgl-engine/materials/PathMaterial.js";const ee=["polyline"];class te extends D{constructor(e,t,i,s){super(e,t,i,s),this._intrinsicSize=o(1,1),this._upVectorAlignment=M.Path,this._stencilWidth=.1,this.ensureDrapedStatus(!1)}async doLoad(){const t=null!=this.symbolLayer.width?this.symbolLayer.width:this.symbolLayer.height,i=null!=this.symbolLayer.height?this.symbolLayer.height:t;this._vvConvertOptions=new V({size:!0,color:!0,rotation:!1,opacity:!0},[1,1,1],[t,1,i],this._context.renderCoordsHelper.unitInMeters),this._fastUpdates=this._context.renderer?.visualVariables?.length>0?U(this._context.renderer,this._vvConvertOptions):null;const s=this.symbolLayer.anchor||"center";this._upVectorAlignment="heading"===this.symbolLayer.profileRotation?M.World:M.Path;const o=this.symbolLayer.profile||"circle";switch(o){default:case"circle":this._profile=Q(P);break;case"quad":this._profile=K()}let l=[0,0];switch("center"!==s&&(l={left:[.5,0],right:[-.5,0],top:[0,-.5],bottom:[0,.5]}[s],this._profile.translate(l[0],l[1])),this.symbolLayer.join){case"round":this._extruder=new H(0,j);break;case"bevel":this._extruder=new H(0,1);break;case"miter":this._extruder=new H(.8*Math.PI,1);break;default:this._extruder=new F}const c=this.symbolLayer.cap||"butt";switch(c){case"none":this._startCap=new q,this._endCap=new q;break;case"butt":default:this._startCap=new O(this._profile,0),this._endCap=new O(this._profile,0,!0);break;case"square":this._startCap=new O(this._profile,-.5),this._endCap=new O(this._profile,.5,!0);break;case"round":{const e="quad"===o;this._startCap=new B({profile:this._profile,flip:!1,breakNormals:e,subdivisions:S}),this._endCap=new B({profile:this._profile,flip:!0,breakNormals:e,subdivisions:S});break}}const p=this.symbolLayer?.material?.color,m=this._getCombinedOpacityAndColor(p),f=h(m),d=m[3],u=d<1||this.needsDrivenTransparentPass,y={diffuse:f,ambient:f,opacity:d,transparent:u,hasVertexColors:!1,hasSlicePlane:this._context.slicePlaneEnabled,castShadows:this.symbolLayer.castShadows,cullFace:u||"none"===c?z.None:z.Back,offsetTransparentBackfaces:!0};if(!this._drivenProperties.size&&(r(this._intrinsicSize,t,i),!C(this._intrinsicSize[0])||!C(this._intrinsicSize[1])))throw new e("graphics3dpathsymbollayer:invalid-size","Symbol sizes may not be negative values");if(this._fastUpdates&&this._fastUpdates.visualVariables.size||a(this._intrinsicSize,this._intrinsicSize,1/this._context.renderCoordsHelper.unitInMeters),this._fastUpdates){const e={...y,...this._fastUpdates.materialParameters,size:n(this._intrinsicSize)};this._material=new $(e)}else y.hasVertexColors=this._drivenProperties.color||this._drivenProperties.opacity,this._material=new Y(y);this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),this._context.stage.add(this._material)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,ee,this.symbolLayer.type))return null;const i=this.setGraphicElevationContext(t,new w),s=e.renderingInfo;return this._createAs3DShape(t,s,i,t.uid)}layerOpacityChanged(){const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacity(e),i=t<1||this.needsDrivenTransparentPass;this._material.setParameters({opacity:t,transparent:i})}layerElevationInfoChanged(e,t){return this.updateGraphics3DGraphicElevationInfo(e,t,_)}slicePlaneEnabledChanged(){return this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),!0}physicalBasedRenderingChanged(){return this._material.setParameters({usePBR:this._context.physicalBasedRenderingEnabled,isSchematic:!0}),!0}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return L.RecreateSymbol;if(!E(this._fastUpdates,t,this._vvConvertOptions))return L.RecreateSymbol;this._material.setParameters(this._fastUpdates.materialParameters)}return L.FastUpdate}_getVertexData(e){let t=0;const i=e.paths,s=[],r=e.spatialReference,a=this._context.elevationProvider.spatialReference,o=this._context.renderCoordsHelper.spatialReference;for(const c of i)t+=c.length;const n=y(3*t);let l,h=0;for(const c of i){s.push({offset:h,numVertices:c.length});for(const t of c)n[h++]=t[0],n[h++]=t[1],n[h++]=e.hasZ?t[2]:0}return null==a||r.equals(a)||p(n,r,0,n,a,0,t)?(null==a||a.equals(o)?l=b(n):(l=y(3*t),p(n,a,0,l,o,0,t)),{pathVertexDataInfos:s,vertexDataES:n,vertexDataRS:l}):null}_createAs3DShape(e,r,a,o){const n=e.geometry,h=this._getVertexData(n);if(null==h)return this.logger.warn("PathSymbol3DLayer geometry failed to be created (failed to project geometry to view spatial reference)"),null;if(0===h.pathVertexDataInfos.length)return 0!==n.paths.length&&n.paths.some((e=>e.length>0))||this.logger.warn("PathSymbol3DLayer geometry failed to be created (no paths were defined)"),null;const c=new Array,p=n.spatialReference,y=m(),b=this._context.renderCoordsHelper,v=new R(h.vertexDataES);for(const m of h.pathVertexDataInfos){const n=m.numVertices;if(n<2)continue;const _=m.offset;if(null!=this._context.clippingExtent&&(f(y),d(y,h.vertexDataES,_,n),!u(y,this._context.clippingExtent)))continue;const w=new Array,x=_+3*n;for(let e=_;e<x;e+=3){v.offset=e;const t=g(v,this._context.elevationProvider,a,b);l(oe,h.vertexDataRS[e],h.vertexDataRS[e+1],h.vertexDataRS[e+2]),b.setAltitude(oe,t),h.vertexDataRS[e]=oe[0],h.vertexDataRS[e+1]=oe[1],h.vertexDataRS[e+2]=oe[2],w.push(X(this._upVectorAlignment))}const P=new G(w,h.vertexDataES,h.vertexDataRS,_);ie(P,this._upVectorAlignment,this._context.renderCoordsHelper);const j=new I(P,this._profile,this._extruder,this._startCap,this._endCap);let S=null;if(this._fastUpdates){const t=this._fastUpdates.visualVariables,i=k(t.size?.field,e)??0,s=k(t.color?.field,e)??0,r=k(t.opacity?.field,e)??0;S=new T(j,i,s,r)}else{const e=[this._intrinsicSize[0],this._intrinsicSize[1]];if(this._drivenProperties.size){const t=r.size;e[0]*=se(t[0],"symbol-value"===t[2]?this.symbolLayer.height||0:t[2],this.symbolLayer.width||0),e[1]*=se(t[2],"symbol-value"===t[0]?this.symbolLayer.width||0:t[0],this.symbolLayer.height||0)}let t;this._drivenProperties.color&&(t=r.color),this._drivenProperties.opacity&&null!=r.opacity&&(t=t?[t[0],t[1],t[2],r.opacity]:[1,1,1,r.opacity]);const i=new Z(j);i.bake(e),t&&i.bakeVertexColors(t),S=i}const{vertexAttributes:D,indices:C}=S.createGeometryData(),L=this._context.stage.renderView.getObjectAndLayerIdColor({graphicUid:o,layerUid:this._context.layer.uid}),V=new W(this._material,D,C,S,p,this._stencilWidth,L);V.transformation=t(s(),i,j.path.origin),c.push(V)}if(0===c.length)return null;const w=new A({geometries:c,layerUid:this._context.layer.uid,graphicUid:o}),P=new x(this,w,c,null,null,((e,t,i,s,r)=>ae(e,t,s,r,this._upVectorAlignment)),a);return P.alignedSampledElevation=0,P.needsElevationUpdates=_(a.mode),P}}function ie(e,t,i){const{origin:s,positions:r}=e;let a=e.offset;switch(t){default:case M.World:for(const t of e.vertices)oe[0]=r[a++]+s[0],oe[1]=r[a++]+s[1],oe[2]=r[a++]+s[2],i.worldUpAtPosition(oe,oe),t.setFrameFromUpVector(oe);break;case M.Path:oe[0]=r[a]+s[0],oe[1]=r[a+1]+s[1],oe[2]=r[a+2]+s[2],i.worldUpAtPosition(oe,oe),J(e,oe)}}function se(e,t,i){switch(e){case"symbol-value":return i;case"proportional":return t;default:return e}}function re(e,t,i,s){let r=0;const{origin:a,vertices:o,positions:n,positionsES:h}=e,c=e.offset+3*o.length;for(let p=e.offset;p<c;p+=3)l(oe,h[p],h[p+1],h[p+2]),i(oe,ne),r+=ne.sampledElevation,oe[0]=n[p]+a[0],oe[1]=n[p+1]+a[1],oe[2]=n[p+2]+a[2],s.setAltitude(oe,ne.z),n[p]=oe[0]-a[0],n[p+1]=oe[1]-a[1],n[p+2]=oe[2]-a[2];return e.updatePathVertexInformation(),r/o.length}function ae(e,t,i,s,r){const a=e.stageObject,o=a.geometries;let n=0;for(const l of o){if(!N(l))continue;const e=l.path,o=e.builder.path;n+=re(o,t,i,s),r!==M.World&&ie(o,r,s),e.onPathChanged(l),l.invalidateBoundingInfo(),a.geometryVertexAttrsUpdated(l)}return n/o.length}const oe=c(),ne=new v;export{te as Graphics3DPathSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../Color.js";import{
|
|
5
|
+
import e from"../../../../Color.js";import{pt2px as t}from"../../../../core/screenUtils.js";import{e as i}from"../../../../chunks/earcut.js";import{create as r,empty as o,expandWithBuffer as n,intersectsClippingArea as s,expandWithAABB as a}from"../../../../geometry/support/aaBoundingBox.js";import{newDoubleArray as l,doubleSubArray as c}from"../../../../geometry/support/DoubleArray.js";import{newFloatArray as h,floatSubArray as p}from"../../../../geometry/support/FloatArray.js";import{SymbolUpdateType as u,elevationModeChangeUpdateType as d,needsElevationUpdates2D as m}from"./elevationAlignmentUtils.js";import{ElevationContext as _}from"./ElevationContext.js";import y from"./Graphics3DDrapedGraphicLayer.js";import{Graphics3DObject3DGraphicLayer as g}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{mixinColorAndOpacity as b}from"./graphicUtils.js";import{ApplyRendererDiffResult as x}from"./interfaces.js";import{parseCapType as v}from"./lineUtils.js";import{geometryAsPolygon as O,createColorGeometry as D,PolygonCreationDataBase as C}from"./polygonUtils.js";import{ConvertOptions as S,initFastSymbolUpdatesState as j,updateFastSymbolUpdatesState as A,getAttributeValue as M}from"../support/FastSymbolUpdates.js";import{createMaterial as P,uvElevationAligner as U}from"../support/patternUtils.js";import{createMapSpaceUVCoords as E,createMapSpaceUVCoordsDraped as L}from"../support/uvUtils.js";import{createGeometry as G}from"../../support/engineContent/line.js";import{geometryToRenderInfo as w,geometryToRenderInfoDraped as R}from"../../support/renderInfoUtils/polygon.js";import{Object3D as I}from"../../webgl-engine/lib/Object3D.js";import{RenderGeometry as V}from"../../webgl-engine/lib/RenderGeometry.js";import{getStipplePatternForLinePattern as F}from"../../webgl-engine/materials/lineStippleUtils.js";import{PatternMaterial as B}from"../../webgl-engine/materials/PatternMaterial.js";import{RibbonLineMaterial as T}from"../../webgl-engine/materials/RibbonLineMaterial.js";const z=["polyline","polygon","extent"],H=new S({size:!1,color:!0,rotation:!1,opacity:!1});class W extends f{constructor(e,t,i,r){super(e,t,i,r),this._needsUV=!1,this._hasOutline=!1}async doLoad(){this._fastUpdates=j(this._context.renderer,H)}_ensureMaterials(){this._ensureFillMaterial(),this._ensureOutlineMaterial()}_ensureFillMaterial(){if(null!=this._material)return;const e=this.symbolLayer?.material?.color,t=this._getCombinedOpacityAndColor(e);this._material=P(this.symbolLayer,{color:t,transparent:t[3]<1||this.needsDrivenTransparentPass,polygonOffset:!1,hasVertexColors:!0,writeLinearDepth:!0,draped:this.draped,hasSlicePlane:this._context.slicePlaneEnabled,...this._fastUpdates?.materialParameters}),this._needsUV=this._material instanceof B,this._context.stage.add(this._material)}_ensureOutlineMaterial(){const e=this.symbolLayer.outline;if(this._outlineMaterial||!this._isValidOutline(e))return;this._hasOutline=!0;const i=t=>{const i=F(e.pattern);return new T({width:t,color:this._getOutlineColor(),hasPolygonOffset:!0,hasSlicePlane:this._context.slicePlaneEnabled,isClosed:!0,stipplePattern:i,stippleScaleWithLineWidth:!0,cap:v(e.patternCap||"butt")})};this._outlineMaterial=i(t(e.size)),this._context.stage.add(this._outlineMaterial)}_isValidOutline(e){return null!=e&&null!=e.size&&e.size>0&&null!=e.color&&(null==e.pattern||"style"!==e.pattern.type||"none"!==e.pattern.style)}destroy(){super.destroy(),this._context.stage.remove(this._material),this._material=null,this._context.stage.remove(this._outlineMaterial),this._outlineMaterial=null}createGraphics3DGraphic(e){const t=e.graphic;if(!this._validateGeometry(t.geometry,z,this.symbolLayer.type))return null;const i=this._getVertexOpacityAndColor(e.renderingInfo,255),r=this.setGraphicElevationContext(t,new _);return this.ensureDrapedStatus("on-the-ground"===r.mode),this._ensureMaterials(),this.draped?this._createAsOverlay(t,i):this._createAs3DShape(t,i,r)}applyRendererDiff(e,t){for(const i in e.diff){if("visualVariables"!==i)return x.RecreateSymbol;if(!A(this._fastUpdates,t,H))return x.RecreateSymbol;this._material&&this._material.setParameters(this._fastUpdates.materialParameters)}return x.FastUpdate}layerOpacityChanged(){if(null!=this._material){const e=this._material.parameters.color,t=this.symbolLayer?.material?.color,i=this._getCombinedOpacity(t);this._material.setParameters({color:[e[0],e[1],e[2],i],transparent:i<1||this.needsDrivenTransparentPass})}if(null!=this._outlineMaterial){const e=this._outlineMaterial.parameters.color;this._outlineMaterial.setParameters({color:[e[0],e[1],e[2],this._getOutlineOpacity()]})}}layerElevationInfoChanged(e,t,i){const r=this._elevationContext.mode,o=d(W.elevationModeChangeTypes,i,r);if(o!==u.UPDATE)return o;const n=m(r);return this.updateGraphics3DGraphicElevationInfo(e,t,(()=>n))}slicePlaneEnabledChanged(){if(this._material&&this._material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled}),this._outlineMaterial){const e={hasSlicePlane:this._context.slicePlaneEnabled};this._outlineMaterial.setParameters(e)}return!0}physicalBasedRenderingChanged(){return!0}_createAs3DShape(e,t,i){const r=O(e.geometry);if(!r)return null;const o=w(r,this._context.elevationProvider,this._context.renderCoordsHelper,i),n=new k(o,t,this._context.layer.uid,e.uid),s=n.renderData.position.length/3;if(this._needsUV&&(n.uvMapSpace=h(4*s,!0),n.boundingRect=l(9*s,!0),E(n.uvMapSpace,n.boundingRect,n.renderData.position,this._context.renderCoordsHelper)),n.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAs3DShapeFill(e,n),this._hasOutline&&this._createAs3DShapeOutline(n),this._logGeometryCreationWarnings(n.renderData,r.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length)return null;const a=new I({geometries:n.outGeometries,castShadow:!1,layerUid:this._context.layer.uid,graphicUid:e.uid}),c=new g(this,a,n.outGeometries,null,null,U,i);return c.alignedSampledElevation=n.renderData.sampledElevation,c.needsElevationUpdates=m(i.mode),c}_createAs3DShapeFill(e,t){const r=t.renderData.polygons;for(const{position:a,mapPositions:l,holeIndices:h,index:u,count:d}of r){if(null!=this._context.clippingExtent&&(o(N),n(N,l),!s(N,this._context.clippingExtent)))continue;const r=i(l,h,3);if(0===r.length)continue;const m=this._fastUpdates?.visualVariables.color,_=D({material:this._material,indices:r,mapPositions:l,attributeData:{position:a,color:m?null:t.color,colorFeature:m?M(m.field,e):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*u,4*d):null,boundingRect:this._needsUV?c(t.boundingRect,9*u,9*d):null,objectAndLayerIdColor:t.objectAndLayerIdColor}});t.outGeometries.push(_)}}_createAs3DShapeOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{mapPositions:r,position:a}=t[i];if(null!=this._context.clippingExtent&&(o(N),n(N,r),!s(N,this._context.clippingExtent)))continue;const l=G(this._outlineMaterial,{overlayInfo:null,removeDuplicateStartEnd:!0,mapPositions:r,attributeData:{position:a}},e.objectAndLayerIdColor);e.outGeometries.push(l)}}_createAsOverlay(e,t){const i=O(e.geometry);if(null==i)return null;this._material.renderPriority=this._renderPriority+this._renderPriorityStep/2,null!=this._outlineMaterial&&(this._outlineMaterial.renderPriority=this._renderPriority);const r=R(i,this._context.overlaySR),n=new q(r,t,this._context.layer.uid,e.uid),s=n.renderData.position.length/3;return this._needsUV&&(n.uvMapSpace=h(4*s,!0),L(n.uvMapSpace,n.renderData.position,this._context.overlaySR,this._context.graphicsCoreOwner.view.state.viewingMode)),n.outBoundingBox=o(),n.objectAndLayerIdColor=this._context.stage.renderView?.getObjectAndLayerIdColor(n),this._createAsOverlayFill(e,n),this._hasOutline&&this._createAsOverlayOutline(n),this._logGeometryCreationWarnings(n.renderData,i.rings,"rings","FillSymbol3DLayer"),0===n.outGeometries.length?null:new y(this,n.outGeometries,n.outBoundingBox,this._context.drapeSourceRenderer)}_createAsOverlayFill(e,t){const r=t.renderData.polygons;for(const{position:l,holeIndices:c,index:h,count:u}of r){const r=o(N);if(n(r,l),!s(r,this._context.clippingExtent))continue;const d=i(l,c,3);if(0===d.length)continue;a(t.outBoundingBox,r);const m=this._fastUpdates?.visualVariables.color,_=D({material:this._material,indices:d,attributeData:{position:l,color:m?null:t.color,colorFeature:m?M(m.field,e):null,uvMapSpace:this._needsUV?p(t.uvMapSpace,4*h,4*u):null,objectAndLayerIdColor:t.objectAndLayerIdColor}});t.outGeometries.push(new V(_,t))}}_createAsOverlayOutline(e){if(!this._hasOutline)return;const t=e.renderData.outlines;for(let i=0;i<t.length;++i){const{position:r}=t[i];if(o(N),n(N,r),!s(N,this._context.clippingExtent))continue;a(e.outBoundingBox,N);const l=G(this._outlineMaterial,{overlayInfo:{spatialReference:this._context.overlaySR,renderCoordsHelper:this._context.renderCoordsHelper},removeDuplicateStartEnd:!0,attributeData:{position:r}},e.objectAndLayerIdColor);e.outGeometries.push(new V(l,e))}}_getOutlineOpacity(){const e=this.symbolLayer?.outline?.color;return(this.draped?1:this._getLayerOpacity())*(null!=e?e.a:0)}_getOutlineColor(){const t=this.symbolLayer?.outline?.color,i=this._getOutlineOpacity();return b(null!=t?e.toUnitRGB(t):null,i)}test(){return{...super.test(),createAsOverlay:(e,t)=>this._createAsOverlay(e,t),createAs3DShape:(e,t,i)=>this._createAs3DShape(e,t,i)}}}W.elevationModeChangeTypes={definedChanged:u.RECREATE,staysOnTheGround:u.NONE,onTheGroundChanged:u.RECREATE};const N=r();class k extends C{constructor(e,t,i,r){super(e,i,r),this.color=t}}class q extends C{constructor(e,t,i,r){super(e,i,r),this.color=t}}export{W as Graphics3DPolygonFillSymbolLayer};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.27/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../../../core/Error.js";import{
|
|
5
|
+
import e from"../../../../core/Error.js";import{isPromiseLike as t}from"../../../../core/promiseUtils.js";import{pt2px as r}from"../../../../core/screenUtils.js";import{f as n,Z as s,a as i}from"../../../../chunks/vec2f64.js";import{hasCalloutSupport as o,textSymbolLayerSupportsVerticalOffset as l}from"../../../../symbols/callouts/calloutUtils.js";import{CreateLabelParameters as a}from"./CreateLabelParameters.js";import{perObjectElevationAligner as c}from"./ElevationAligners.js";import{SymbolUpdateType as m,needsElevationUpdates2D as h}from"./elevationAlignmentUtils.js";import{ElevationContext as u}from"./ElevationContext.js";import{Graphics3DObject3DGraphicLayer as d}from"./Graphics3DObject3DGraphicLayer.js";import{Graphics3DObjectMetadata as p}from"./Graphics3DObjectMetadata.js";import{Graphics3DSymbolLayer as f}from"./Graphics3DSymbolLayer.js";import{validateSymbolLayerSize as g}from"./graphicUtils.js";import{verticalPlacementFromAlignment as y,textRenderAlignmentFromHorizontalPlacement as x,horizontalPlacementToAnchorX as b,anchorFromPlacements as v,namedAnchorToHUDMaterialAnchorPos as P}from"./placementUtils.js";import{placePointOnGeometry as O,createStageObject as j,extendPointGraphicElevationContext as w}from"./pointUtils.js";import{createPointGeometry as S}from"../../webgl-engine/lib/GeometryUtil.js";import{TextRenderParameters as _}from"../../webgl-engine/lib/TextRenderParameters.js";import E from"../../webgl-engine/lib/TextTextureFactory.js";import{HUDMaterial as L}from"../../webgl-engine/materials/HUDMaterial.js";const z=[0,0,1];class C extends f{constructor(e,t,r,n){super(e,t,r,n),this._elevationOptions={supportsOffsetAdjustment:!0,supportsOnTheGround:!1},this.ensureDrapedStatus(!1)}async doLoad(){if(!this._drivenProperties.size){const t=g(this.symbolLayer.size);if(t)throw new e("graphics3dtextsymbollayer:invalid-size",t)}await this._createTextRenderParameters()}async _createTextRenderParameters(){const e=this._context.graphicsCoreOwner.view.state.rasterPixelRatio;this._textRenderParameters=await _.fromSymbol(this.symbolLayer,e)}destroy(){super.destroy()}createGraphics3DGraphic(e){const t=e.graphic,r=O(t.geometry);if(null==r)return this.logger.warn(`unsupported geometry type for text symbol: ${t.geometry.type}`),null;const n=this.symbolLayer.text;if(null==n||""===n)return null;const s=o(this.symbol)&&this.symbol.hasVisibleVerticalOffset()?this.symbol.verticalOffset:null;if(null!=s&&!l(this.symbolLayer))return this.logger.errorOncePerTick(`Callouts and vertical offset on text symbols are currently only supported with 'center' horizontal alignment (not with '${this.symbolLayer.horizontalAlignment}' alignment)`),null;const i=new a(s,this.symbolLayer.horizontalAlignment,y(this.symbolLayer.verticalAlignment));return this._createAs3DShape(t,r,n,i)}createLabel(e,t,r,n){const s=e.graphic,i=O(s.geometry);if(null==i)return this.logger.warn(`unsupported geometry type for label: ${s.geometry.type}`),null;const o=t.text;return!o||/^\s+$/.test(o)?null:this._createAs3DShape(s,i,o,t,r,n)}setGraphicElevationContext(e,t,r=0){const n=super.setGraphicElevationContext(e,t);return n.addOffsetRenderUnits(r),n}layerOpacityChanged(){return this.logger.warn("layer opacity change not yet implemented in Graphics3DTextSymbolLayer"),!1}layerElevationInfoChanged(e,t){return G(e,t,((e,t)=>{this.updateGraphicElevationContext(t,e)})),m.UPDATE}slicePlaneEnabledChanged(e,t){return G(e,t,(e=>{for(const t of e.stageObject.geometries)t.material.setParameters({hasSlicePlane:this._context.slicePlaneEnabled})})),!0}physicalBasedRenderingChanged(){return!0}get pixelRatioChanged(){return!1}updateGraphicElevationContext(e,t){const r=t.elevationContext;this.setGraphicElevationContext(e,r,null!=t.metadata?t.metadata.elevationOffset:0),t.needsElevationUpdates=h(r.mode)||"absolute-height"===r.mode}_defaultElevationInfoNoZ(){return U}_createAs3DShape(e,o,l,a,m,f){const g=this.setGraphicElevationContext(e,new u,a.elevationOffset),y="polyline"===e.geometry?.type,b=e.uid;let v=null,P=null;if(null==f){const e=x(a.horizontalPlacement);v=new E(l,e,this._textRenderParameters);let r=null;if(null!=this._context.sharedResources.textures){P=this._context.sharedResources.textures.fromData(v.key,(()=>v.create()),(()=>{null!=r&&r.release()}));const e=this._context.stage.renderView.textureRepository.acquire(P.texture.id);if(null==e||t(e))return P.release(),null;r=e}}const O=R(v,a),_={occlusionTest:!0,screenOffset:a.screenOffset,anchorPosition:O,polygonOffset:!0,color:[1,1,1,1],centerOffsetUnits:a.centerOffsetUnits,drawInSecondSlot:!0};if(null!=f?_.textureId=f.id:null!=P&&(_.textureId=P.texture.id),null!=a.verticalOffset){const{screenLength:e,minWorldLength:t,maxWorldLength:n}=a.verticalOffset;_.verticalOffset={screenLength:r(e),minWorldLength:t||0,maxWorldLength:null!=n?n:1/0}}if(this._context.screenSizePerspectiveEnabled){const{screenSizePerspectiveSettings:e,screenSizePerspectiveSettingsLabels:t}=this._context.sharedResources;_.screenSizePerspective=t.overridePadding(this._textRenderParameters.haloSize+this._textRenderParameters.definition.background.padding[0]),_.screenSizePerspectiveAlignment=e}let C;if(y&&(_.shaderPolygonOffset=1e-4),_.hasSlicePlane=this._context.slicePlaneEnabled,null!=m){const e=JSON.stringify(_);C=m.get(e),null==C&&(C=new L(_),m.add(e,C))}else C=new L(_);const G=a.translation,U=null!=v?n(v.displayWidth,v.displayHeight):s,D=a.centerOffset,A=S(C,z,G,null,U,D,[0,0],null),T=j(this._context,o,A,g,b);if(null==T)return null;const W=new d(this,T.object,[A],null==m?[C]:null,P,c,g);W.alignedSampledElevation=T.sampledElevation,W.needsElevationUpdates=h(g.mode)||"absolute-height"===g.mode;const{displayWidth:I,displayHeight:k}=null!=v?v:a;W.getScreenSize=(e=i())=>(e[0]=I,e[1]=k,e);const $=new p(a.elevationOffset,l);return W.metadata=$,w(W,o,this._context.elevationProvider),W}}function G(e,t,r){e&&e.forEach((e=>{const n=t(e);null!=n&&r(n,e.graphic)}))}function R(e,t){if("baseline"===t.verticalPlacement){const r=b[t.horizontalPlacement],s=null!=e?e.baselineAnchorY:0;return n(r,s)}const r=v(t.horizontalPlacement,t.verticalPlacement);return P[r]}const U={mode:"relative-to-ground",offset:0};export{C as Graphics3DTextSymbolLayer};
|