ModelParticle3D QML Type

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

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

Particle3D

属性

详细说明

ModelParticle3D 是一种逻辑粒子元素,可从Qt Quick 3DModel 组件创建粒子。

属性文档

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"
}

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"
    }
}

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