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

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

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P2: Important
    • 6.2
    • 6.1.0, 6.2.0 Beta1, 5.14.0 RC2
    • Quick: 3D
    • None
    • Linux/X11, macOS, Windows
    • 1
    • abf40a252182192f34820050c810875be0d10732
    • 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

            kagro Kaj Grönholm
            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