本页内容

ModelParticle3D QML Type

使用Qt Quick 3D 模型的粒子。更多内容...

Import Statement: import QtQuick3D.Particles3D
Since: Qt 6.2
Inherits:

Particle3D

属性

详细说明

ModelParticle3D 是一个逻辑粒子元素,它通过Qt Quick 3D (Model )组件生成粒子。

属性文档

delegate : Component

该委托提供了一个模板,用于定义由粒子实例化的每个对象。

例如,要分配 200 个红色立方体粒子:

Component {
    id: particleComponent
    Model {
        source: "#Cube"
        scale: Qt.vector3d(0.2, 0.2, 0.2)
        materials: DefaultMaterial { }
    }
}

ModelParticle3D {
    id: particleRed
    delegate: particleComponent
    maxAmount: 200
    color: "#ff0000"
}

注意: 从委托实例化出的内容 会保留其自身的layers 分配;ParticleSystem3D 的layers值不会应用于它。若要在特定的内容层上渲染粒子,请在委托中的节点上设置layers属性。

instanceTable : Instancing

instanceTable 提供对模型粒子Instancing 表的访问。ModelParticle3D 使用内部实例表来实现高效的渲染。该表可应用于不属于粒子系统的模型的instancing 属性。

此外,还可以利用此功能提供实例化表而不显示任何粒子。方法是省略delegate 属性。例如:

ParticleSystem3D {
    id: psystem
    ModelParticle3D {
        id: particleRed
        maxAmount: 200
        color: "#ff0000"
        colorVariation: Qt.vector4d(0.5,0.5,0.5,0.5)
    }

    ParticleEmitter3D {
        particle: particleRed
        velocity: VectorDirection3D {
            direction: Qt.vector3d(-20, 200, 0)
            directionVariation: Qt.vector3d(20, 20, 20)
        }
        particleScale: 0.2
        emitRate: 20
        lifeSpan: 2000
    }
}

Model {
    source: "#Sphere"
    instancing: particleRed.instanceTable
    materials: PrincipledMaterial {
        baseColor: "yellow"
    }
}

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