在本页

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

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

shape : ParticleAbstractShape3D

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

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

另请参见 Node::positionpositionVariation

useCachedPositions : bool

该属性定义了吸引子是否会缓存其形状中的可能位置。缓存位置会减少结果的随机性,但更有利于提高性能。

默认值为true

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