本页内容

Geometry QML Type (Uncreatable)

自定义几何体的基类型。更多...

注意:这是一个不可创建的类型。无法在 QML 中实例化该类型。

详细描述

自定义几何体允许使用应用程序生成的顶点和索引数据,这些数据也可能动态变化。要使用自定义几何体,请勿将.mesh 文件作为source 分配给Model。相反,应将其geometry 属性设置为引用一个Geometry对象。

实现自定义几何体的典型方法是在 C++ 中创建一个 `QQuick3DGeometry ` 的子类,并将新类型注册为 QML 可用的类型。

此外,还可以使用“Helpers ”模块中的内置自定义几何提供程序GridGeometry 。以下是一个GridGeometry 的示例。任何由应用程序提供的 Geometry 子类均可通过相同方式投入使用。

import QtQuick3D.Helpers

Model {
    geometry: GridGeometry {
    }
    materials: [
        DefaultMaterial {
            diffuseColor: "white"
            lighting: DefaultMaterial.NoLighting
        }
    ]
}

另请参阅 Qt Quick 3D - 自定义几何示例、Model 以及QQuick3DGeometry 。

© 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.