Particle3D QML Type

抽象逻辑粒子。更多

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

Object3D

Inherited By:

ModelBlendParticle3D, ModelParticle3D, and SpriteParticle3D

属性

详细说明

该元素定义了逻辑粒子的共同属性。Particle3D 是粒子的抽象基类,请使用ModelParticle3DSpriteParticle3D 代替。

注意: 与模型中使用的材质不同,粒子默认以假设半透明的方式渲染,因此要启用混合效果。由于粒子纹理、颜色(alpha)变化和渐变等原因,这在大多数情况下都是理想的行为。如果不需要混合,可将hasTransparency 设置为false ,这样可能会提高性能。

属性文档

AlignMode : enumeration

定义对齐类型。

常量说明
Particle3D.AlignNone不对齐。粒子旋转可以通过particleRotation 进行定义。
Particle3D.AlignTowardsTarget将粒子朝alignTargetPosition 方向对齐。
Particle3D.AlignTowardsStartVelocity将粒子朝其起始velocity 方向对齐。

FadeType : enumeration

定义渐变效果的类型。

常数说明
Particle3D.FadeNone无渐变。
Particle3D.FadeOpacity将粒子不透明度从 0.0 渐变为 0.0。
Particle3D.FadeScale将粒子缩放比例从 0.0 渐变为 0.0。

SortMode : enumeration

定义粒子的排序模式。排序模式决定了绘制粒子的顺序。

常数说明
Particle3D.SortNone无排序。
Particle3D.SortNewest根据粒子寿命排序,最新的先。
Particle3D.SortOldest根据粒子寿命排序,最老的先。
Particle3D.SortDistance根据与摄像机的距离排序,最远者优先。

alignMode : AlignMode

该属性定义了粒子的对齐模式。粒子对齐是指粒子朝向的方向。

注: SpriteParticle3D billboard 属性设置为true 时,alignMode 没有影响。

默认值为Particle3D.AlignNone

另请参阅 alignTargetPosition


alignTargetPosition : vector3d

该属性定义粒子对齐的位置。该属性只有在alignMode 设置为Particle3D.AlignTowardsTarget 时才有效。

另请参阅 alignMode


color : color

该属性定义用于给粒子着色的基色。

默认值为"#FFFFFF" (白色)。


colorVariation : vector4d

该属性定义用于为粒子着色的颜色变化。数值按 RGBA 顺序排列,每个数值应介于 0.0(无变化)和 1.0(完全变化)之间。

例如,要创建的粒子将具有介于#ff0000#e50000 之间的半透明红色,不透明度为 40% 至 60%:

ModelParticle3D {
    ...
    color: "#7fff0000"
    colorVariation: Qt.vector4d(0.1, 0.0, 0.0, 0.2)
}

默认值为(0, 0, 0, 0) (无变化)。

另请参阅 unifiedColorVariation


fadeInDuration : int

该属性以毫秒为单位定义渐变效果的持续时间。

注: 渐变持续时间是粒子lifeSpan 的一部分。因此,如果lifeSpan 为 3000,fadeInDuration 为 500,fadeOutDuration 为 500,则粒子的完全可见时间为 2000ms。

默认值为250

另请参阅 fadeInEffectfadeOutDuration


fadeInEffect : FadeType

该属性定义了粒子出现时使用的渐变效果。

默认值为Particle3D.FadeOpacity

另请参阅 fadeInDurationfadeOutEffect


fadeOutDuration : int

该属性定义渐变效果的持续时间(毫秒)。

默认值为250

另请参阅 fadeOutEffectfadeInDuration


fadeOutEffect : FadeType

该属性定义粒子到达lifeSpan 并消失时使用的渐变效果。

默认值为Particle3D.FadeOpacity

另请参阅 fadeOutDurationfadeInEffect


hasTransparency : bool

该属性定义粒子是否具有透明度,是否应与背景混合。通常情况下,该值应为 true,例如当粒子颜色不具有完整的 Alpha 值、纹理包含半透明像素或粒子的不透明度被淡入或淡出时。在特定情况下,将此值设为 false 可以起到优化作用。

默认值为true

另请参阅 color,fadeInEffect, 和fadeOutEffect


maxAmount : int

该属性定义了可同时存在的最大粒子数量。您可以使用particlesUsed 来调试已分配粒子的使用效率。如果 maxAmount 太小,则粒子在到达其lifeSpan 的终点之前就会被重复使用。如果 maxAmount 太大,则会为粒子分配不必要的内存。

注意: 更改 maxAmount 会重置粒子系统中的所有粒子。

默认值为100


sortMode : SortMode

此属性定义粒子使用的排序模式。

默认值为Particle3D.SortNone


unifiedColorVariation : bool

该属性定义colorVariation 是否应统一应用于所有颜色通道。这意味着所有变化都会以相同的随机量应用。

例如,创建的粒子将在#ffff00#7f7f00 之间呈现黄色,这样RG 颜色通道的值将始终相同:

ModelParticle3D {
    ...
    color: "#ffff00"
    colorVariation: Qt.vector4d(0.5, 0.5, 0.0, 0.0)
    unifiedColorVariation: true
}

默认值为false

另请参阅 colorVariation


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