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

Qt Quick 3D: Node.right vector flips inconsistently despite stable eulerRotation

    XMLWordPrintable

Details

    • Bug
    • Resolution: Cannot Reproduce
    • Not Evaluated
    • None
    • 6.9.0
    • Quick: 3D
    • None
    • Windows

    Description

      Qt Version: 6.9.0
       
       
      Module: Qt Quick 3D
       
       
      Component: QtQuick3D.Node (specifically its right direction vector property)
       
       
      Observed Behavior:
       
       
      The Node.right vector property can exhibit inconsistent behavior by flipping its direction (e.g., its components change sign, like (x, y, z) becoming (-x, -y, -z)) between consecutive reads. This occurs even when the Node's eulerRotation property (and thus its conceptual forward direction) has remained unchanged between these reads.
       
       
      This issue was identified in a QML context where a Node (representing a camera) had its orientation controlled by eulerRotation. The Node.right vector was used to calculate character strafing movement. When processing distinct input events for "strafe left" and "strafe right" in quick succession (without any change to the camera's eulerRotation between these events), the Node.right vector would sometimes provide a flipped value for the second input. This resulted in both "strafe left" and "strafe right" inputs causing character movement in the same world-space direction, instead of opposite directions.
       
       
      Expected Behavior:
       
       
      If a Node's eulerRotation remains constant between two reads of its direction vector properties, the Node.right (as well as Node.forward and Node.up) vectors should also remain consistent and not spontaneously flip their direction.
       
       
      Steps to Reproduce (Conceptual):
       
        * Create a Node in a Qt Quick 3D scene.

       
        * Set its eulerRotation (e.g., node.eulerRotation = Qt.vector3d(pitch, yaw, 0)).

       
        * In QML JavaScript, read and store node.right (let's call this right_T1).

       
        * Trigger a subsequent event or a very short timer. Ensure node.eulerRotation has not been modified.

       
        * In the handler for this second event/timer, read node.right again (let's call this right_T2).

       
        * Compare right_T1 and right_T2. In problematic cases, right_T2 will be approximately equal to -right_T1.

       
       
      Impact:
       
       
      This inconsistency makes the Node.right property unreliable for calculations that depend on stable and predictable direction vectors, such as character movement or aiming logic, especially when the Node's orientation is managed via eulerRotation.
       
       
      Workaround:
       
       
      The issue was successfully worked around by manually calculating the camera's forward and right vectors directly from its currentPitchDegrees and currentYawDegrees properties (which were used to set the eulerRotation) using standard trigonometric functions within QML JavaScript. This custom calculation provided stable and consistent direction vectors, bypassing the problematic Node.right property.

      Attachments

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

        Activity

          People

            qt.team.graphics.and.multimedia Qt Graphics Team
            jason_qt wang JASON
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes