本页内容

TextureData QML Type (Uncreatable)

自定义纹理数据的基类。更多...

Import Statement: import QtQuick3D
In C++: QQuick3DTextureData
Inherits:

Object3D

Inherited By:

ProceduralSkyTextureData and ProceduralTextureData

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

详细描述

自定义纹理数据允许使用应用程序生成的纹理数据,这些数据也可能动态变化。要使用自定义纹理数据,请将Texture 的textureData 属性设置为引用一个TextureData对象。

在 C++ 中,通过创建QQuick3DTextureData 实例(通常是其子类)来实现自定义纹理数据。QQuick3DTextureData 类型以 TextureData 的名称注册到 QML 中。一旦子类在 QML 中注册,Texture 对象即可开始引用它。

此 API 的使用场景示例包括:当需要在运行时程序化地生成纹理,而非从文件中加载静态图像时。

import MyCustomTexture 1.0

Model {
    source: "#Cube"
    materials: [
        DefaultMaterial {
            diffuseMap: diffuseMapCustomTexture
        }
    ]
}

Texture {
    id: diffuseMapCustomTexture
    textureData: MyCustomTextureData {

    }
}

另请参阅 Texture 。

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