- Qt 6.11
- Qt Quick 3D
- QML Types
- Model
- Qt Quick 3D | Commercial or GPLv3

# Model QML Type

Lets you load a 3D model data. More...

Import Statement: | `import QtQuick3D`
Inherits: | Node
Inherited By: | XrHandModel

- List of all members, including inherited members
- Deprecated members

## Properties

- bakedLightmap : BakedLightmap
- bounds : Bounds
- castsReflections : bool `(since 6.4)`
- castsShadows : bool
- depthBias : real
- geometry : Geometry
- instanceRoot : QtQuick3D::Node
- instancing : QtQuick3D::Instancing
- instancingLodMax : real
- instancingLodMin : real
- inverseBindPoses : List<matrix4x4>
- levelOfDetailBias : real `(since 6.5)`
- materials : List<QtQuick3D::Material>
- morphTargets : List<QtQuick3D::MorphTarget>
- motionVectorEnabled : bool `(since 6.11)`
- motionVectorScale : real `(since 6.11)`
- pickable : bool
- receivesReflections : bool
- receivesShadows : bool
- skeleton : Skeleton
- skin : Skin
- source : url
- texelsPerUnit : real `(since 6.10)`
- usedInBakedLighting : bool

## Detailed Description

The Model item makes it possible to load a mesh and modify how its shaded, by adding materials to it. For a model to be renderable, it needs at least a mesh and a material.

## Mesh format and built-in primitives

The model can load static meshes from storage or one of the built-in primitive types. The mesh format used is a run-time format that's native to the engine, but additional formats are supported through the asset import tool Balsam.

The built-in primitives can be loaded by setting the `source` property to one of these values: `#Rectangle, #Sphere, #Cube, #Cylinder or #Cone`.

     Model {
         source: "#Sphere"
     }

The table below describes the built-in meshes in more detail.

Name | Description | No. faces
--- | --- | ---
#Cone | A cone with a height and diameter of `100`. The base is at the origin and the cone is pointing upwards in the y direction. | `78`
#Cube | A cube centered at the origin with `100` long sides along x, y and z. | `12`
#Cylinder | A cylinder with `100` height and diameter centered at the origin expanding along the y direction. | `316`
#Rectangle | A rectangle with `100` width and height centered at the origin lying in the xy plane. | `2`
#Sphere | A sphere with `100` diameter centered at the origin. | `4900`

### Custom geometry

In addition to using static meshes, you can implement a custom geometry provider that provides the model with custom vertex data at run-time. See the Custom Geometry Example for an example on how to create and use a custom material with your model.

## Materials

A model can consist of several sub-meshes, each of which can have its own material. The sub-mesh uses a material from the materials list, corresponding to its index. If the number of materials is less than the sub-meshes, the last material in the list is used for subsequent sub-meshes. This is demonstrated in the Sub-mesh example.

You can use the following materials with the model item: PrincipledMaterial, DefaultMaterial, and CustomMaterial.

## Picking

Picking is the process of sending a ray through the scene from some starting position to find which models intersect with the ray. In Qt Quick 3D, the ray is normally sent from the view using 2D coordinates resulting from a touch or mouse event. If a model was hit by the ray, pickResult will be returned with a handle to the model and information about where the ray hit the model. For models that use custom geometry, the picking is less accurate than for static mesh data, as picking is only done against the model's bounding volume. If the ray goes through more than one model, the closest pickable model is selected.

Note that for models to be pickable, their pickable property must be set to `true`. For more information, see Qt Quick 3D - Picking example.

## Property Documentation

### bakedLightmap : BakedLightmap

When this property is set to a valid, enabled BakedLightmap object, the model will get a lightmap generated when baking lighting, the lightmap is then stored persistently. When rendering, the model will load and use the associated lightmap. The default value is null.

Note: When the intention is to generate a persistently stored lightmap for a Model, both bakedLightmap and usedInBakedLighting must be set on it, in order to indicate that the Model not only participates in the lightmapped scene, but also wants a full lightmap to be baked and stored.

For more information on how to bake lightmaps, see the Lightmapper documentation.

This property is relevant both when baking and when using lightmaps. A consistent state between the baking run and the subsequent runs that use the generated data is essential. For example, changing the lightmap key will make it impossible to load the previously generated data. An exception is enabled, which can be used to dynamically toggle the usage of lightmaps (outside of the baking run), but be aware that the rendered results will depend on the Lights' bakeMode settings in the scene.

See also usedInBakedLighting and Lightmapper.

### bounds : Bounds `[read-only]`

The bounds of the model descibes the extents of the bounding volume around the model.

Note: The bounds might not be immediately available if the model needs to be loaded first.

### castsReflections : bool `[since 6.4]`

When this property is set to `true`, the model is rendered by reflection probes and can be seen in the reflections.

This property was introduced in Qt 6.4.

### castsShadows : bool

When this property is `true`, the geometry of this model is used when rendering to the shadow maps, and is also generating shadows in baked lighting.

The default value is `true`.

### depthBias : real

Holds the depth bias of the model. Depth bias is added to the object distance from camera when sorting objects. This can be used to force rendering order between objects close to each other, that might otherwise be rendered in different order in different frames. Negative values cause the sorting value to move closer to the camera while positive values move it further from the camera.

### geometry : Geometry

Specify a custom geometry for the model. The Model::source must be empty when custom geometry is used.

### instanceRoot : QtQuick3D::Node

This property defines the origin of the instance’s coordinate system.

See the overview documentation for a detailed explanation.

See also instancing and Instancing.

### instancing : QtQuick3D::Instancing

If this property is set, the model will not be rendered normally. Instead, a number of instances of the model will be rendered, as defined by the instance table.

See also Instancing.

### instancingLodMax : real

Defines the maximum distance from camera that an instance of this model is shown. Used for a level of detail implementation.

### instancingLodMin : real

Defines the minimum distance from camera that an instance of this model is shown. Used for a level of detail implementation.

### inverseBindPoses : List<matrix4x4>

This property contains a list of Inverse Bind Pose matrixes used for the skeletal animation. Each inverseBindPose matrix means the inverse of the global transform of the repective Joint::index in skeleton, which will be used initially.

Note: This property is only used if the Model::skeleton is valid.

Note: If some of the matrices are not set, identity values will be used.

See also Joint::index.

### levelOfDetailBias : real `[since 6.5]`

This property changes the size the model needs to be when rendered before the automatic level of detail meshes are used. Each generated level of detail mesh contains an ideal size value that each level should be shown, which is a ratio of how much of the rendered scene will be that mesh. A model that represents only a few pixels on screen will not require the full geometry to look correct, so a lower level of detail mesh will be used instead in this case. This value is a bias to the ideal value such that a value smaller than `1.0` will require an even smaller rendered size before switching to a lesser level of detail. Values above `1.0` will lead to lower levels of detail being used sooner. A value of `0.0` will disable the usage of levels of detail completely.

The default value is `1.0`

Note: This property will only have an effect when the Model's geometry contains levels of detail.

This property was introduced in Qt 6.5.

See also Camera::levelOfDetailBias.

### materials : List<QtQuick3D::Material>

This property contains a list of materials used to render the provided geometry. To render anything, there must be at least one material. Normally there should be one material for each sub-mesh included in the source geometry.

See also Qt Quick 3D - Sub-mesh Example.

### morphTargets : List<QtQuick3D::MorphTarget>

This property contains a list of MorphTargets used to render the provided geometry. Meshes should have at least one attribute among positions, normals, tangents, binormals, texture coordinates, and vertex colors for the morph targets.

See also MorphTarget.

### motionVectorEnabled : bool `[default: true, since 6.11]`

Specifies whether the model participates in the motion vector pass.

When this property is set to `true`, the model contributes its motion information to the motion vector buffer. This is used by temporal anti-aliasing (TAA) and other effects that rely on per-pixel motion data.

When set to `false`, the model is excluded from motion vector generation.

This property was introduced in Qt 6.11.

See also Model::motionVectorScale.

### motionVectorScale : real `[default: 1.0, since 6.11]`

Specifies a scaling factor applied to the model's generated motion vectors.

A value of `1.0` preserves the model's actual motion, while values greater than `1.0` exaggerate the motion vectors and values lower than `1.0` reduce them. This can be useful for stylized effects or fine-tuning visual behavior in effects that rely on the motion vector buffer.

This property was introduced in Qt 6.11.

See also Model::motionVectorEnabled.

### pickable : bool

This property controls whether the model is pickable or not. Set this property to `true` to make the model pickable. Models are not pickable by default.

See also View3D::pick.

### receivesReflections : bool

When this property is set to `true`, the model's materials take reflections contribution from a reflection probe. If the model is inside more than one reflection probe at the same time, the nearest reflection probe is taken into account.

### receivesShadows : bool

When this property is set to `true`, the model's materials take shadow contribution from shadow casting lights into account.

Note: When lightmapping is enabled for this model, fully baked lights with Light::bakeMode set to Light.BakeModeAll will always generate (baked) shadows on the model, regardless of the value of this property.

The default value is `true`.

### skeleton : Skeleton

Contains the skeleton for the model. The Skeleton is used together with inverseBindPoses for skinning.

Note: Meshes of the model must have both joints and weights attributes.

Note: If this property is set, skinning animation is enabled. It means that Model is transformed based on Skeleton ignoring Model's global transformation.

See also Model::inverseBindPoses and Qt Quick 3D - Simple Skinning Example.

### skin : Skin

Contains the skeleton for the model. The Skeleton is used for skinning.

Note: Meshes of the model must have both joints and weights attributes.

Note: If this property is set, skinning animation is enabled. This means the Model will be transformed based on Skin::joints and the Model's global transformation will be ignored.

Note: If a model has both a skeleton and a skin, then the skin will be used.

See also Qt Quick 3D - Simple Skinning Example.

### source : url

This property defines the location of the mesh file containing the geometry of this Model or one of the built-in primitive meshes listed below as described in Mesh format and built-in primitives.

- "#Rectangle"
- "#Sphere"
- "#Cube"
- "#Cone"
- "#Cylinder"

### texelsPerUnit : real `[default: 0.0, since 6.10]`

A value greater than zero means this value will override the Lightmapper::texelsPerUnit value for this specific model during lightmap baking.

This property was introduced in Qt 6.10.

See also Lightmapper::texelsPerUnit.

### usedInBakedLighting : bool

When this property is set to `true`, the model contributes to baked lighting, such as lightmaps, for example in form of casting shadows or indirect light. This setting is independent of controlling lightmap generation for the model, use bakedLightmap for that.

The default value is `false`.

Note: The default value is false, because designers and developers must always evaluate on a per-model basis if the object is suitable to take part in baked lighting.

Warning: Models with dynamically changing properties, for example, animated position, rotation, or other properties, are not suitable for participating in baked lighting.

For more information on how to bake lightmaps, see the Lightmapper documentation.

This property is relevant only when baking lightmaps. It has no effect afterwards, when using the generated lightmaps during rendering.

See also Light::bakeMode, bakedLightmap, Lightmapper, and Lightmaps and Global Illumination.