Qt Quick 3D - XR Freeform Teleportation Example

Demonstrates how to make a simple locomotion in Qt Quick 3D XR.

Overview

This example shows how to move to places in the virtual environment using a simple freeform teleportation system, a non-continuous form of movement.

Controls

When you run the example, use the following controls for navigation.

ActionControl
RotationLeft and Right stick on the right controller
Aim and TeleportForward stick on the right controller

Implementation

You can easily re-use FreeformTeleporter in other projects, as all the logic is contained within that type.

 FreeformTeleporter {
     id: teleporter

     rayPicker: xrView
     cameraOrigin: xrOrigin
     camera: xrOrigin.camera
     beamHandle: xrRightController
     onDoTeleportation: (cameraOriginPosition)=> {
                            xrOrigin.position = cameraOriginPosition
                        }
     onDoRotation: (cameraOriginRotation, cameraOriginPosition)=> {
                       xrOrigin.rotation = cameraOriginRotation
                       xrOrigin.position = cameraOriginPosition
                   }
 }

The FreeformTeleporter component has the following properties that need to be set:

 var rayPicker

The rayPicker property can be any object that implements a rayPick method. In this example, we are using XrView's built-in ray-picking method.

 Node cameraOrigin

The cameraOrigin property is the center of the camera's local reference space. In Xr this will be the location where tracked items, like the camera, will be placed relative to. We will, therefore, use the XrOrigin node as the cameraOrigin.

 Node camera

The camera property contains the camera used to render the scene. In this example, we use the tracked XrCamera we created earlier.

 Node beamHandle

The beamHandle property is the Node used as the teleportation beam's start point. In this example, we use the right controller xrRightController as the beamHandle.

Example project @ code.qt.io

See also Locomotion in Qt Quick 3D Xr.