PreviewControls.qml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // Copyright (C) 2023 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
  3. import QtQuick
  4. import QtQuick.Window
  5. import QtQuick.Controls
  6. import QtQuick.Layouts
  7. import QtCore
  8. import QtQuick3D
  9. import QtQuick3D.Helpers
  10. Item {
  11. id: previewControls
  12. required property View3D targetView
  13. required property OrbitCameraController orbitCamera
  14. property alias modelSource: modelComboBox.currentValue
  15. property alias enableIBL: iblEnableButton.checked
  16. property alias enableDirectionalLight: directionalLightEnabledButton.checked
  17. Settings {
  18. property alias enableIbl: previewControls.enableIBL
  19. property alias enableDirectionalLight: previewControls.enableDirectionalLight
  20. property alias environmentOrientationSliderValue: environmentOrientationSlider.value
  21. }
  22. FrostedGlass {
  23. width: parent.width
  24. height: layout.implicitHeight
  25. backgroundItem: previewControls.targetView
  26. backgroundRect: Qt.rect(0, 0, width, height)
  27. // range: 0.05
  28. // blur: 0.005
  29. range: 0.05
  30. blur: 0.05
  31. //color: "pink"
  32. }
  33. RowLayout {
  34. id: layout
  35. anchors.left: parent.left
  36. anchors.leftMargin: 10
  37. Label {
  38. text: "Model"
  39. }
  40. ComboBox {
  41. id: modelComboBox
  42. textRole: "text"
  43. valueRole: "value"
  44. model: ListModel {
  45. ListElement {
  46. text: "Sphere"
  47. value: "#Sphere"
  48. }
  49. ListElement {
  50. text: "Cube"
  51. value: "#Cube"
  52. }
  53. ListElement {
  54. text: "Plane"
  55. value: "#Rectangle"
  56. }
  57. ListElement {
  58. text: "Suzanne"
  59. value: "assets/meshes/suzanne.mesh"
  60. }
  61. }
  62. }
  63. Button {
  64. text: "Reset View"
  65. onClicked: {
  66. previewControls.orbitCamera.origin.rotation = Qt.quaternion(1, 0, 0, 0)
  67. previewControls.orbitCamera.camera.rotation = Qt.quaternion(1, 0, 0, 0)
  68. previewControls.orbitCamera.camera.position = Qt.vector3d(0, 0, 300)
  69. environmentOrientationSlider.value = 0
  70. }
  71. }
  72. ToolButton {
  73. id: iblEnableButton
  74. icon.source: "assets/icons/texture.png"
  75. checkable: true
  76. checked: true
  77. hoverEnabled: true
  78. ToolTip.delay: 1000
  79. ToolTip.timeout: 5000
  80. ToolTip.visible: hovered
  81. ToolTip.text: qsTr("Toggle the use of IBL")
  82. }
  83. Label {
  84. visible: previewControls.enableIBL
  85. text: "Environment Orientation"
  86. }
  87. Slider {
  88. visible: previewControls.enableIBL
  89. id: environmentOrientationSlider
  90. Layout.fillWidth: true
  91. from: -180
  92. to: 180
  93. value: 0
  94. onValueChanged: {
  95. previewControls.targetView.environment.probeOrientation = Qt.vector3d(0, value, 0)
  96. }
  97. }
  98. ToolButton {
  99. id: directionalLightEnabledButton
  100. icon.source: "assets/icons/lightdirectional.png"
  101. checkable: true
  102. checked: true
  103. hoverEnabled: true
  104. ToolTip.delay: 1000
  105. ToolTip.timeout: 5000
  106. ToolTip.visible: hovered
  107. ToolTip.text: qsTr("Toggle a Directional Light")
  108. }
  109. }
  110. }