From 25c1fefcc4df12e5cf1dd8b53bc2b42214355d2c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gr=C3=A9goire=20De=20Lillo?= Date: Fri, 14 Jun 2024 20:59:50 +0200 Subject: [PATCH] [ui] Viewer3D: Use directional light & add light controller Use a single light entity instead of one per camera. Use directional light instead of point light. Add camera relative directional light controller. --- meshroom/ui/qml/Viewer3D/Inspector3D.qml | 6 ++++ meshroom/ui/qml/Viewer3D/Viewer3D.qml | 29 +++++++++++++------ meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml | 1 + meshroom/ui/qml/Viewer3D/ViewpointCamera.qml | 9 ------ 4 files changed, 27 insertions(+), 18 deletions(-) diff --git a/meshroom/ui/qml/Viewer3D/Inspector3D.qml b/meshroom/ui/qml/Viewer3D/Inspector3D.qml index e0783f03a4..f4cf3a851f 100644 --- a/meshroom/ui/qml/Viewer3D/Inspector3D.qml +++ b/meshroom/ui/qml/Viewer3D/Inspector3D.qml @@ -69,6 +69,12 @@ FloatingPane { checked: Viewer3DSettings.displayOrigin onClicked: Viewer3DSettings.displayOrigin = !Viewer3DSettings.displayOrigin } + MaterialToolButton { + text: MaterialIcons.light_mode + ToolTip.text: "Display Light Controller" + checked: Viewer3DSettings.displayLightController + onClicked: Viewer3DSettings.displayLightController = !Viewer3DSettings.displayLightController + } } MaterialLabel { text: MaterialIcons.grain diff --git a/meshroom/ui/qml/Viewer3D/Viewer3D.qml b/meshroom/ui/qml/Viewer3D/Viewer3D.qml index 17ca458f08..dd3fc872ab 100644 --- a/meshroom/ui/qml/Viewer3D/Viewer3D.qml +++ b/meshroom/ui/qml/Viewer3D/Viewer3D.qml @@ -109,15 +109,6 @@ FocusScope { upVector: defaultCamUpVector viewCenter: defaultCamViewCenter aspectRatio: width/height - - // Scene light, attached to the camera - Entity { - components: [ - PointLight { - color: "white" - } - ] - } } ViewpointCamera { @@ -127,6 +118,15 @@ FocusScope { camera.aspectRatio: width/height } + Entity { + components: [ + DirectionalLight{ + color: "white" + worldDirection: Transformations3DHelper.getRotatedCameraViewVector(cameraSelector.camera.viewVector, cameraSelector.camera.upVector, directionalLightPane.lightPitchValue, directionalLightPane.lightYawValue).normalized() + } + ] + } + TrackballGizmo { beamRadius: 4.0/root.height alpha: cameraController.moving ? 1.0 : 0.7 @@ -330,6 +330,17 @@ FocusScope { } } + // Directional light controller + DirectionalLightPane { + id: directionalLightPane + anchors { + bottom: parent.bottom + right: parent.right + margins: 2 + } + visible: Viewer3DSettings.displayLightController + } + // Menu Menu { id: contextMenu diff --git a/meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml b/meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml index 7963f836a8..d4a102a21c 100644 --- a/meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml +++ b/meshroom/ui/qml/Viewer3D/Viewer3DSettings.qml @@ -49,6 +49,7 @@ Item { property bool displayGrid: true property bool displayGizmo: true property bool displayOrigin: false + property bool displayLightController: false // Camera property bool syncViewpointCamera: false property bool syncWithPickedViewId: false // Sync active camera with picked view ID from sequence player if the setting is enabled diff --git a/meshroom/ui/qml/Viewer3D/ViewpointCamera.qml b/meshroom/ui/qml/Viewer3D/ViewpointCamera.qml index df1328c4e9..7d1e1f8757 100644 --- a/meshroom/ui/qml/Viewer3D/ViewpointCamera.qml +++ b/meshroom/ui/qml/Viewer3D/ViewpointCamera.qml @@ -16,15 +16,6 @@ Entity { nearPlane : 0.1 farPlane : 10000.0 viewCenter: Qt.vector3d(0.0, 0.0, -1.0) - - // Scene light, attached to the camera - Entity { - components: [ - PointLight { - color: "white" - } - ] - } } components: [