ContentLayer QML Type
Singleton 提供用于对场景节点进行分组和过滤的图层标志常量。更多内容...
| Import Statement: | import QtQuick3D |
| Since: | Qt 6.11 |
详细描述
ContentLayer 是一个单例,它公开了 `LayerFlag ` 枚举,该枚举提供了用于将节点分配到命名内容图层的位标志常量。图层可用于将场景节点分组,或过滤摄像机渲染的节点。
预定义的图层名称未必能准确描述具体用例。您可以通过为ContentLayer 值设置别名,来定义具有语义含义的自定义图层名称。例如,在一个包含建筑物、街道和车辆的城市场景中:
readonly property int layerBuildings: ContentLayer.Layer1
readonly property int layerStreets: ContentLayer.Layer2
readonly property int layerVehicles: ContentLayer.Layer3 | ContentLayer.Layer4定义完成后,可通过 `Node.layers ` 将这些标志分配给节点,并在 `Camera ` 上设置相应的标志,以控制其渲染哪些图层。
注意:某些 图层具有特殊含义:
| 图层 | 描述 |
|---|---|
| LayerNone | 未分配图层。具有此值的节点不属于任何图层,且不会被渲染。 |
| Layer0 | 默认的主图层。节点默认被分配到此图层。 |
| 图层1–图层23 | 可自由分配的用户图层,用于按用途或功能对节点进行分组。 |
| Layer24及以上 | 保留供Qt Quick 3D 内部使用。 |
| LayerAll | 匹配所有图层;具有此值的节点将由每台摄像机渲染。 |
注意:图层 是位标志,可与| 运算符结合使用。
注意:图层 分配不会被继承;在节点上设置Node.layers 不会将该值从父节点传播到子节点。每个节点都保留自己的图层分配,必须单独设置。
注意:ContentLayer 是单例,不应直接实例化。
另请参阅 “图层示例”。
© 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.