Hi,

I've been having trouble showing the same Entity (say a Mesh) in two Scene3Ds. I think the problem I don't know how to get around is that an Entity's parent has to be the Entity that that is being shown by the Scene3D. This is different than in the Multi Viewport QML Example where all the viewports are in one Scene3D.

For example, in the code below, how can I show the SphereMesh torusMesh2 in both Scene3Ds?
Right now I'm setting its parent to insert it into scene3dRight, but I can't seem to set multiple parents on an object, and I'm not sure how to manipulate scene3dLeft's and scene3dRight data/children

Qt Code:
  1. import QtQuick 2.0
  2. import Qt3D.Core 2.0
  3. import Qt3D.Render 2.0
  4. import Qt3D.Input 2.0
  5. import QtQuick.Layouts 1.3
  6. import QtQuick.Controls 1.3
  7. import QtQuick.Scene3D 2.0
  8.  
  9. import Qt3D.Extras 2.0
  10.  
  11. Item {
  12.  
  13. SphereMesh {
  14. id: torusMesh2; radius: 5
  15. parent: scene3DRightEntity
  16. }
  17. PhongMaterial {
  18. id: material2; parent: scene3DRightEntity
  19. }
  20. Transform {
  21. id: torusTransform2; scale3D: Qt.vector3d(1.5, 1, 0.5); rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45); parent: scene3DRightEntity
  22. }
  23.  
  24.  
  25. Rectangle {
  26. id: topRect
  27. anchors.fill: parent; anchors.margins: 50
  28.  
  29. color: 'green'
  30.  
  31. SplitView {
  32. anchors.fill: parent; orientation: Qt.Horizontal
  33.  
  34. Rectangle {
  35. id: scene
  36. anchors.margins: 50; width: 200; Layout.minimumWidth: 100; Layout.maximumWidth: 500
  37. color: "darkRed"
  38.  
  39. Text { text: "View 1"; anchors.centerIn: parent }
  40.  
  41. Scene3D {
  42. id: scene3dLeft
  43. anchors.fill: parent; anchors.margins: 10; focus: true
  44. aspects: ["input", "logic"]
  45. cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
  46.  
  47. Entity {
  48.  
  49. SimpleCamera {
  50. id: camera1; fieldOfView: 45; position: Qt.vector3d( 0.0, 0.0, 40.0 )
  51. }
  52.  
  53. components: [
  54. RenderSettings {
  55. activeFrameGraph: ForwardRenderer {
  56. camera: camera1.camera
  57. clearColor: "transparent"
  58. }
  59. }
  60. , InputSettings { }
  61. ]
  62.  
  63. TorusMesh {
  64. id: torusMesh1; radius: 5; minorRadius: 1; rings: 100; slices: 20
  65. }
  66. PhongMaterial { id: material1 }
  67. Transform { id: torusTransform1; scale3D: Qt.vector3d(1.5, 1, 0.5); rotation: fromAxisAndAngle(Qt.vector3d(1, 0, 0), 45) }
  68.  
  69. Entity {
  70. id: torusEntity1
  71. components: [ torusMesh1, material1, torusTransform1 ]
  72. }
  73. }
  74.  
  75. }
  76. }
  77.  
  78.  
  79. Rectangle {
  80. id: scene2
  81. Layout.fillWidth: true; Layout.minimumWidth: 50; Layout.maximumWidth: 400; height: 300
  82. color: "darkBlue"
  83.  
  84. Scene3D {
  85. id: scene3dRight
  86. anchors.fill: parent; anchors.margins: 50; focus: true;
  87. aspects: ["input", "logic"]
  88. cameraAspectRatioMode: Scene3D.AutomaticAspectRatio
  89.  
  90. Entity {
  91. id: scene3DRightEntity
  92. SimpleCamera {
  93. id: camera2
  94. position: Qt.vector3d( 0.0, 0.0, 40.0 )
  95. }
  96.  
  97. components: [
  98. RenderSettings {
  99. activeFrameGraph: ForwardRenderer {
  100. camera: camera2.camera
  101. clearColor: "transparent"
  102. }
  103. }
  104. , InputSettings { }
  105. ]
  106.  
  107. Entity {
  108. id: torusEntity2
  109. components: [ torusMesh2, material2, torusTransform2 ]
  110. }
  111. }
  112.  
  113. }
  114. }
  115. }
  116. }
  117.  
  118. } // Item
To copy to clipboard, switch view to plain text mode 

(sorry it's not shorter..)

Also fully open to the idea that I'm going about this the wrong way. I suppose ultimately I would just like to know how to have my data only defined once, but shown anywhere/multiple times.

Thanks!