Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-94539

mapTo3DScene() will fail when a camera is not explicit assigned

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Fixed
    • Affects Version/s: 6.1.0, 6.2.0 Beta1, 5.14.0 RC2
    • Fix Version/s: 6.2
    • Component/s: Quick: 3D
    • Labels:
      None
    • Platform/s:
      Linux/X11, macOS, Windows
    • Commits:
      abf40a252182192f34820050c810875be0d10732
    • Story Points:
      1
    • Sprint:
      Qt Quick 3D - 2021 Week 31/32

      Description

       

      In the following code, mapTo3DScene() will fail with the error:

      QML View3D: Cannot resolve scene position without a camera assigned!
      qml: pos3D: QVector3D(0, 0, 0)

       

      View3D {
      
          id: view
          OrthographicCamera{ 
              id: mainCamera 
              z: 200 
          }
          Node {
              .....
          }
          MouseArea { 
              anchors.fill: view  
              onMouseXChanged: { 
                  var pos3D = view.mapTo3DScene(Qt.vector3d(mouseX, mouseY, 0))
                  console.log("pos3D: "+pos3D) 
              }
      }
      

       

      Note that explicit setting the camera in View3D like this:

       

      camera: OrthographicCamera{
      
                  id: mainCamera
      
                  z: 200
      
              }
       
      

      will make mapTo3DScene() work properly, but then View3D content will fail to be displayed.

       

      I notice that adding view.update() to onMouseXChanged will make View3D content to be display, but this is ugly since it will only show content on mouse move. I tried calling view.update() on Component.complet but this fails.

       

      The attached example shows a red Sphere Model, be sure to compile commenting / uncommentig line 27 in main.qml, where the OrtographicCamera is explicitly set.

      • camera explicit set: mapTo3DScene() works but View3D content display fails
      • camera not explicit set: mapTo3DScene() fails, but View3D content display works

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            kagro Kaj Grönholm
            Reporter:
            johngod Joao de Deus Sena Morgado
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes