ContentLayer QML Type
| Import Statement: | import QtQuick3D |
| Since: | Qt 6.11 |
详细说明
该类用于表示 3D 场景中的内容层。它可用于管理不同的内容层,如背景、前景或 UI 元素。
ContentLayer 枚举定义了可用的图层标志,例如,可用于将场景节点分组或过滤摄像机渲染的节点。
预定义的图层名称并不一定足以描述特定的使用情况,在这种情况下,您可以通过别名ContentLayer 枚举值来定义自己的图层。例如,在一个城市场景中,建筑物、街道和车辆都有不同的图层。您可以通过别名ContentLayer 枚举值为每个图层指定一个特定的标记,如layerBuildings 、layerStreets 和layerVehicles 。定义图层后,您可以将这些标志分配给场景中的节点,并通过在Camera 上设置相同的图层属性,让摄像机过滤要渲染的图层。
readonly property int layerBuildings: ContentLayer.Layer1 readonly property int layerStreets: ContentLayer.Layer2 readonly property int layerVehicles: ContentLayer.Layer3 | ContentLayer.Layer4
注: 某些图层具有特殊含义:
| 图层 | 说明 |
|---|---|
| 无图层 | 未指定图层,用于表示节点不属于任何图层,不应被渲染。 |
| 图层 0 | 主图层,用于显示场景中的主要内容。节点默认分配到该图层。 |
| 图层 1-23 | 可自由分配的图层,用于根据节点的目的或功能将其分组。 |
| 图层 24 及以上 | 保留图层,用于特殊目的或未来扩展。 |
| 全部层 | 表示一个节点属于所有层,用于应在每一层中渲染的节点。 |
注: 层被定义为标志,这意味着您可以组合多个层。
注: 该类不打算直接实例化。相反,它在 QML 中被用作单例来访问层标志。
另请参阅 图层示例。
© 2026 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.