Object3D QML Type

Abstract base type of all 3D nodes and resources. 更多...

import 语句: import QtQuick3D
实例化: QQuick3DObject
继承: QtObject
继承者: Effect , 几何体 , InstanceListEntry , InstanceRange , Instancing , Material , Node , Particle3D , SceneEnvironment , Texture ,和 TextureData

特性

详细描述

Object3D is the base class for all Qt Quick 3D types. This includes:

  • Spatial types that represent objects in the 3D scene, these will normally have a position and/or a direction. For example, Model , Camera ,或 Light . Such types inherit from Node , which in turn inherits from Object3D.
  • Resource types that do not themselves represent an object in the 3D world, but rather serve as components to Node subclasses, providing data of some kind. This includes, among others, Material , 几何体 ,和 Texture .

In addition to the above types, Object3D can also serve as the parent for Qt Quick items , as well as arbitrary QObject instances. For more information on adding 2D items to the 3D scene, refer to 带有 2D 内容的 Qt Quick 3D 场景 .

另请参阅 Node .

特性文档编制

children : list < Object3D >
resources : list < 对象 >

The children property contains the list of visual children of this object. The resources property contains non-visual resources that you want to reference by name.

It is not generally necessary to refer to these properties when adding child objects or resources, as the default data property will automatically assign child objects to the children and resources properties as appropriate. See the QtQuick3D::Object3D::data 文档编制了解细节。

注意: QtQuick3D::Object3D::resources does not return a list of 3D resources despite the name. The name comes from the semantics of QQuickItem . 3D resources are subclasses of QQuickObjec3D and thus will be returned in the list of QtQuick3D::Objec3D::children.

[default] data : list < 对象 >

The data property allows you to freely mix Object3D children and resources in an object. If you assign a Object3D to the data list it becomes a child and if you assign any other object type, it is added as a resource.

So you can write:

Object3D {
    Node {}
    DirectionalLight {}
    Timer {}
}
					

instead of:

Item {
    children: [
        Node {},
        DirectionalLight {}
    ]
    resources: [
        Timer {}
    ]
}
					

It should not generally be necessary to refer to the data property, as it is the default property for Object3D and thus all child objects are automatically assigned to this property.

parent : Object3D

This property holds the parent of the Object3D in a 3D scene.

注意: An Object3D 's parent may not necessarily be the same as its object parent. This is necessary because the object parent may be an item that is not of type Object3D , for example the root object in a scene.

state : string

This property holds the name of the current state of the object.

If the item is in its default state, that is, no explicit state has been set, then this property holds an empty string. Likewise, you can return an item to its default state by setting this property to an empty string.

另请参阅 Qt Quick 状态 .

状态 : list < State >

This property holds the list of possible states for this object. To change the state of this object, set the state property to one of these states, or set the state property to an empty string to revert the object to its default state.

This property is specified as a list of State objects. For example, below is an QtQuick3D::Node with "above_state" and "below_state" states:

import QtQuick
import QtQuick3D
Node {
    id: root
    y: 0
    states: [
        State {
            name: "above_state"
            PropertyChanges { target: root; y: 100 }
        },
        State {
            name: "below_state"
            PropertyChanges { target: root; y: -100 }
        }
    ]
}
					

Qt Quick 状态 and Qt Quick 中的动画和过渡 for more details on using states and transitions.

注意: This property works the same as QtQuick::Item::states but is necessary because QtQuick3D::Object3D is not a QtQuick::Item subclass.

另请参阅 QtQuick3D::Object3D::transitions .

过渡 : list < Transition >

This property holds the list of transitions for this object. These define the transitions to be applied to the object whenever it changes its state .

This property is specified as a list of Transition objects. For example:

import QtQuick
import QtQuick3D
Node {
    transitions: [
        Transition {
            //...
        },
        Transition {
            //...
        }
    ]
}
					

Qt Quick 状态 and Qt Quick 中的动画和过渡 for more details on using states and transitions.

注意: This property works the same as QtQuick::Item::transitions but is necessary because QtQuick3D::Object3D is not a QtQuick::Item subclass.

另请参阅 QtQuick3D::Object3D::states .