本页内容

Attractor3D QML Type

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

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

Affector3D

属性

详细说明

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

引力位置可通过position 和positionVariation ,或通过shape 来定义。如果两者都已定义,则使用shape 。

属性文档

duration : int

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

默认值为-1 。

durationVariation : int

该属性定义了持续时间的变化量(单位为毫秒)。达到吸引子所需的实际持续时间介于duration -durationVariation 与duration +durationVariation 之间。

默认值为0 (无变化)。

hideAtEnd : bool

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

默认值为false 。

positionVariation : vector3d

此属性定义了吸引位置的变化方式。它可用于避免将粒子吸引到单一点,而是随机吸引至更广阔的区域。 以下是一个示例,演示如何在2到4秒内将粒子吸引到位于(100, 0, 0)处、(50, 50, 50)立方体内部的某个随机点:

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

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

另请参阅 Node::position 和shape 。

positionsAmount : int

该属性定义了吸引子形状中可存储的可能位置数量。默认情况下,该数量等于粒子数量,但若需减小缓存大小,可使用较小的数值;若需增加随机性,则可使用较大的数值。

shape : ParticleAbstractShape3D

该属性定义了一个用于粒子吸引的ParticleAbstractShape3D 。每个粒子都会被吸引到该形状内部的某个随机位置。这是定义position 和positionVariation 的另一种方法。以下是一个示例,展示如何通过粒子的末端将粒子吸引到球体内部的某个随机点:lifeSpan :

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

另请参阅 Node::position 和positionVariation 。

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.