AxisHelper.qml 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Copyright (C) 2019 The Qt Company Ltd.
  2. // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
  3. import QtQuick
  4. import QtQuick3D
  5. Node {
  6. id: axisGrid_obj
  7. property alias gridColor: gridMaterial.diffuseColor
  8. property alias gridOpacity: gridMaterial.opacity
  9. property alias enableXZGrid: gridXZ.visible
  10. property alias enableXYGrid: gridXY.visible
  11. property alias enableYZGrid: gridYZ.visible
  12. property bool enableAxisLines: true
  13. // Axis Lines
  14. Model {
  15. id: xAxis
  16. source: "#Cube"
  17. position: Qt.vector3d(5000, 0, 0)
  18. scale: Qt.vector3d(100, .05, .05)
  19. visible: axisGrid_obj.enableAxisLines
  20. materials: DefaultMaterial {
  21. lighting: DefaultMaterial.NoLighting
  22. diffuseColor: "red"
  23. }
  24. }
  25. Model {
  26. id: yAxis
  27. source: "#Cube"
  28. position: Qt.vector3d(0, 5000, 0)
  29. scale: Qt.vector3d(0.05, 100, 0.05)
  30. visible: axisGrid_obj.enableAxisLines
  31. materials: DefaultMaterial {
  32. lighting: DefaultMaterial.NoLighting
  33. diffuseColor: "green"
  34. }
  35. }
  36. Model {
  37. id: zAxis
  38. source: "#Cube"
  39. position: Qt.vector3d(0, 0, 5000)
  40. scale: Qt.vector3d(0.05, 0.05, 100)
  41. visible: axisGrid_obj.enableAxisLines
  42. materials: DefaultMaterial {
  43. lighting: DefaultMaterial.NoLighting
  44. diffuseColor: "blue"
  45. }
  46. }
  47. // Grid Lines
  48. DefaultMaterial {
  49. id: gridMaterial
  50. lighting: DefaultMaterial.NoLighting
  51. opacity: 0.5
  52. diffuseColor: Qt.rgba(0.8, 0.8, 0.8, 1)
  53. }
  54. Model {
  55. id: gridXZ
  56. source: "meshes/axisGrid.mesh"
  57. scale: Qt.vector3d(100, 100, 100)
  58. materials: [
  59. gridMaterial
  60. ]
  61. }
  62. Model {
  63. id: gridXY
  64. visible: false
  65. source: "meshes/axisGrid.mesh"
  66. scale: Qt.vector3d(100, 100, 100)
  67. eulerRotation: Qt.vector3d(90, 0, 0)
  68. materials: [
  69. gridMaterial
  70. ]
  71. }
  72. Model {
  73. id: gridYZ
  74. visible: false
  75. source: "meshes/axisGrid.mesh"
  76. scale: Qt.vector3d(100, 100, 100)
  77. eulerRotation: Qt.vector3d(0, 0, 90)
  78. materials: [
  79. gridMaterial
  80. ]
  81. }
  82. }