Attractor3D QML Type

将粒子吸引到某个位置或形状上。更多

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

Affector3D

属性

详细说明

该元素可将粒子吸引到三维视图内的某个位置。要模拟重心较远的大质量物体的重力,请使用Gravity3D

吸引位置可通过positionpositionVariationshape 定义。如果同时定义了这两个元素,则使用shape

属性文档

duration : int

该属性以毫秒为单位定义粒子到达吸引位置的持续时间。当值为 -1 时,将使用粒子的生命周期作为持续时间。

默认值为-1


durationVariation : int

该属性以毫秒为单位定义持续时间的变化。到达吸引子的实际持续时间介于duration -durationVariationduration +durationVariation 之间。

默认值为0 (无变化)。


hideAtEnd : bool

该属性定义粒子到达吸引子时是否应该消失。

默认值为false


positionVariation : vector3d

该属性定义吸引位置的变化。它可以用来避免吸引到一个点上,而是随机吸引到更大的区域。下面是一个示例,说明如何在 2 至 4 秒内将粒子吸引到立方体(50, 50, 50)内位于位置(100, 0, 0)的某个随机点:

Attractor3D {
    position: Qt.vector3d(100, 0, 0)
    positionVariation: Qt.vector3d(50, 50, 50)
    duration: 3000
    durationVariation: 1000
}

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

另请参阅 Node::positionshape


positionsAmount : int

该属性定义了吸引子形状中存储的可能位置数量。默认情况下,数量等于粒子数,但也可以使用较小的数量来获得较小的缓存。较高的数量可用于额外的随机化。


该属性定义了用于吸引粒子的ParticleAbstractShape3D 。每个粒子都将被吸引到该形状内的随机位置。这是定义positionpositionVariation 的替代方法。以下是一个示例,说明如何通过粒子的末端将粒子吸引到球体内部的某个随机点lifeSpan

Attractor3D {
    position: Qt.vector3d(100, 0, 0)
    shape: ParticleShape3D {
        type: ParticleShape3D.Sphere
        fill: true
    }
}

另请参见 Node::positionpositionVariation


useCachedPositions : bool

该属性定义了吸引子是否会缓存其形状内的可能位置。缓存位置的随机结果较少,但性能更好。

默认值为true


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