LevelOfDetail QML Type | Qt 3D 5.12.5

Qt 5.12 | Qt 3D | QML Types | LevelOfDetail QML Type

Qt 5.12.5 Reference Documentation

# LevelOfDetail QML Type

LevelOfDetail provides a way of controlling the complexity of rendered entities based on their size on the screen. More...

Import Statement: | import Qt3D.Render 2.12
Since: | Qt 5.9
Instantiates: | QLevelOfDetail
Inherits: | Component3D

- List of all members, including inherited members

## Properties

- ThresholdType : enumeration
- camera : Camera
- currentIndex : int
- thresholdType : int
- thresholds : QVector<qreal>
- volumeOverride : int

## Detailed Description

LevelOfDetail can be used to control the representation of an entity based on distance from the observer or size on the screen.

In order to improve rendering performance, objects that are very small can be rendered using far fewer details, in geometry or texture.

The component is controlled by specifying thresholds of values which are interpreted as either distances from the camera or screen size.

As the point of view changes, the currentIndex property will change to reflect matching value in the range array.

The currentIndex property can then be used, for example, to enable or disable entities, change source in an EntityLoader, or material.

The LevelOfDetail component is not shareable between multiple Entity's.

      import Qt3D.Core 2.0
      import Qt3D.Render 2.0

      Entity {
          id: root

          // Scene
          Camera { id: mainCamera }

          LevelOfDetail {
              id: lod
              camera: mainCamera
              thresholds: [20, 35, 50, 65]
              thresholdType: LevelOfDetail.DistanceToCameraThreshold
          }

          CylinderMesh {
              id: mesh

              property var sliceValues: [20, 10, 6, 4]
              slices: sliceValues[lod.currentIndex]
          }

          Entity {
              id: renderableEntity
              components: [ mesh, lod ]
          }
      }

## Property Documentation

ThresholdType : enumeration

Specifies how the values in the thresholds are interpreted

- DistanceToCameraThreshold Distance from the entity to the selected camera
- ProjectedScreenPixelSizeThreshold Size of the entity when projected on the screen as seen from the selected camera, expressed in number of pixels on the side of the bounding square in screen space.

See also Qt3DRender::QLevelOfDetail::ThresholdType.

camera : Camera

Holds the id of the camera that is used to compute the actual distance or the screen size.

currentIndex : int

The index in the range array which matches the current distance to the camera or screen size.

thresholdType : int

Specifies how range values are interpreted.

thresholds : QVector<qreal>

Array of range values as float point numbers. The value for the most detailed representation should be specified first.

If LevelOfDetail::thresholdType is set to LevelOfDetail.DistanceToCameraThreshold, values should be specified in ascending order, in camera space coordinates

If LevelOfDetail::thresholdType is set to LevelOfDetail.ProjectedScreenPixelSizeThreshold, values should be specified in descending order, in screen space pixels.

volumeOverride : int

Specifies what is used to evaluate the distance or screen size.

The default is a sphere of radius 1 and centered at the local origin of the entity. This proxy volume is used to compute the distance to the camera or the size of the screen projection.

If this value to null, the bounding volume of the entity is used. Care must be taken that this bounding volume never becomes invalid.

See also Qt3DRender::QLevelOfDetailBoundingSphere.