[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.
This commit is contained in:
Grégoire De Lillo 2024-06-14 20:59:50 +02:00 committed by Candice Bentéjac
parent 9df260ac6c
commit bfda6f66ac
4 changed files with 27 additions and 18 deletions

View file

@ -70,6 +70,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

View file

@ -107,15 +107,6 @@ FocusScope {
upVector: defaultCamUpVector
viewCenter: defaultCamViewCenter
aspectRatio: width/height
// Scene light, attached to the camera
Entity {
components: [
PointLight {
color: "white"
}
]
}
}
ViewpointCamera {
@ -125,6 +116,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
@ -318,6 +318,17 @@ FocusScope {
}
}
// Directional light controller
DirectionalLightPane {
id: directionalLightPane
anchors {
bottom: parent.bottom
right: parent.right
margins: 2
}
visible: Viewer3DSettings.displayLightController
}
// Menu
Menu {
id: contextMenu

View file

@ -51,6 +51,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

View file

@ -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: [