View3D QML Type | Runtime 2.1

Qt 3D Studio | Runtime | QML Types | View3D QML Type

Qt 3D Studio Runtime 2.1 Manual

# View3D QML Type

An item rendering the contents of a single layer from a Qt 3D Studio presentation. More...

Import Statement: | import .
Since: | Qt 3D Studio 2.2
Inherits: | Item

- List of all members, including inherited members

## Properties

- engine : Object
- source : string

## Detailed Description

View3D items display the contents of a single Qt 3D Studio layer. This allows taking full control over layer composition and moving it into the domain of Qt Quick and QML.

When there is at least one View3D in the scene, the Studio3D item will no longer display any content, and its size is not relevant anymore. The final composition by the Qt 3D Studio engine is disabled in the mode since composition is done by the means of Qt Quick, by positioning, sizing and blending the View3D items.

Note: View3D can improve performance significantly (the gain depends on the size of the item) for Qt 3D Studio presentations with a single layer in the scene. This is because the unnecessary - but with Studio3D implicit - composition step (rendering the layer into a texture and then blending it with the output from other layers) is avoided. This can be especially important on devices with mobile/embedded GPUs that have more limited fragment processing power.

Note: Views are also useful to avoid the resource and performance implications of having multiple Studio3D items in a scene: Instead of multiple Studio3D items (and thus running multiple instances of 3D engines in parallel), have only one presentation, represented by a Studio3D item, and display and compose the contents of the layers via separate View3D items. This way there is only one 3D engine running under the hood, taking care of the contents of all the View3D items.

### Example usage

Let's assume `presentation.uip` has two layers, named `LayerA` and `LayerB`, with LayerA being on top.

The following snippet defines a Studio3D item that displays the composed contents of the two layers inside its bounds:

      Studio3D {
          anchors.fill: parent
          Presentation {
              source: "qrc:///presentation.uip"
          }
      }

The following changes to the separate engine - views model. The Studio3D item no longer displays anything. It is now up to the application to control the position and other settings of the View3D items:

      Studio3D {
          id: s3d
          Presentation {
              source: "qrc:///presentation.uip"
          }
      }

      View3D {
          engine: s3d
          source: "LayerB"
          anchors.fill: parent

          View3D {
              engine: s3d
              source: "LayerA"
              anchors.fill: parent
          }
      }

Under the hood the Qt 3D Studio presentation is constructed as usual, with one OpenGL texture for each layer. This also means that when multiple View3D items refer to the same layer, they reuse the same texture and the content of each layer is rendered only once.

### Interaction with additional features

The debug and profiling views, that are normally rendered on top of the 3D content, are managed differently when View3D instances are present. Instead of using ViewerSettings::showRenderStats or Presentation::profileUiVisible, applications are expected to add a Studio3DProfiler item to their Qt Quick scene. When this item is made visible, the debug and profiling views will appear. In most cases the item will be on top everything else, filling the viewport:

      Studio3DProfiler {
          anchors.fill: parent
          visible: true
      }

Adding this snippet to the above example would make the application start with the debug views shown.

Check out the Layers in Qt Quick example for a fully featured example application.

## Property Documentation

engine : Object

Reference to a Studio3D item. This must always be set in order for the View3D to display something.

source : string

Specifies a layer in the `.uip` presentation that is loaded by associated the Studio3D item. This must always be set in order for the View3D to display something.

The syntax of the value is the same as in Q3DSPresentation::setAttribute(). In most cases this will be a single name that is specified in the Qt 3D Studio application by renaming the Layer node in the Timeline view.