GPUParticles3D
A 3D particle emitter.
GPUParticles3D.swift:19class GPUParticles3D
3D particle node used to create a variety of particle systems and effects. GPUParticles3D
features an emitter that generates some number of particles at a given rate.
Use processMaterial
to add a ParticleProcessMaterial
to configure particle appearance and behavior. Alternatively, you can add a ShaderMaterial
which will be applied to all particles.
This object emits the following signals:
Superclasses
class GeometryInstance3D
Base node for geometry-based visual instances.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Types
Type members
static let maxDrawPasses: Int
Maximum number of draw passes supported.
class var godotClassName: StringName
Instance members
var amount: Int32
The number of particles to emit in one emission cycle. The effective emission rate is
(amount * amount_ratio) / lifetime
particles per second. Higher values will increase GPU requirements, even if not all particles are visible at a given time or ifamountRatio
is decreased.var amountRatio: Double
The ratio of particles that should actually be emitted. If set to a value lower than
1.0
, this will set the amount of emitted particles throughout the lifetime toamount * amount_ratio
. Unlike changingamount
, changingamountRatio
while emitting does not affect already-emitted particles and doesn’t cause the particle system to restart.amountRatio
can be used to create effects that make the number of emitted particles vary over time.var collisionBaseSize: Double
The base diameter for particle collision in meters. If particles appear to sink into the ground when colliding, increase this value. If particles appear to float when colliding, decrease this value. Only effective if
collisionMode
isParticleProcessMaterial/CollisionMode/collisionRigid
orParticleProcessMaterial/CollisionMode/collisionHideOnContact
.var drawOrder: GPUParticles3D.DrawOrder
Particle draw order. Uses
DrawOrder
values.var drawPass1: Mesh?
Mesh
that is drawn for the first draw pass.var drawPass2: Mesh?
Mesh
that is drawn for the second draw pass.var drawPass3: Mesh?
Mesh
that is drawn for the third draw pass.var drawPass4: Mesh?
Mesh
that is drawn for the fourth draw pass.var drawPasses: Int32
The number of draw passes when rendering particles.
var drawSkin: Skin?
var emitting: Bool
If
true
, particles are being emitted.emitting
can be used to start and stop particles from emitting. However, ifoneShot
istrue
settingemitting
totrue
will not restart the emission cycle until after all active particles finish processing. You can use the [signal finished] signal to be notified once all active particles finish processing.var explosiveness: Double
Time ratio between each emission. If
0
, particles are emitted continuously. If1
, all particles are emitted simultaneously.var finished: SimpleSignal
Emitted when all active particles have finished processing. When
oneShot
is disabled, particles will process continuously, so this is never emitted.var fixedFps: Int32
The particle system’s frame rate is fixed to a value. For example, changing the value to 2 will make the particles render at 2 frames per second. Note this does not slow down the simulation of the particle system itself.
var fractDelta: Bool
If
true
, results in fractional delta calculation which has a smoother particles display effect.var interpToEnd: Double
Causes all the particles in this node to interpolate towards the end of their lifetime.
var interpolate: Bool
Enables particle interpolation, which makes the particle movement smoother when their
fixedFps
is lower than the screen refresh rate.var lifetime: Double
The amount of time each particle will exist (in seconds). The effective emission rate is
(amount * amount_ratio) / lifetime
particles per second.var localCoords: Bool
If
true
, particles use the parent node’s coordinate space (known as local coordinates). This will cause particles to move and rotate along theGPUParticles3D
node (and its parents) when it is moved or rotated. Iffalse
, particles use global coordinates; they will not move or rotate along theGPUParticles3D
node (and its parents) when it is moved or rotated.var oneShot: Bool
If
true
, only the number of particles equal toamount
will be emitted.var preprocess: Double
Amount of time to preprocess the particles before animation starts. Lets you start the animation some time after particles have started emitting.
var processMaterial: Material?
Material
for processing particles. Can be aParticleProcessMaterial
or aShaderMaterial
.var randomness: Double
Emission randomness ratio.
var speedScale: Double
Speed scaling ratio. A value of
0
can be used to pause the particles.var subEmitter: NodePath
Path to another
GPUParticles3D
node that will be used as a subemitter (seesubEmitterMode
). Subemitters can be used to achieve effects such as fireworks, sparks on collision, bubbles popping into water drops, and more.var trailEnabled: Bool
If
true
, enables particle trails using a mesh skinning system. Designed to work withRibbonTrailMesh
andTubeTrailMesh
.var trailLifetime: Double
The amount of time the particle’s trail should represent (in seconds). Only effective if
trailEnabled
istrue
.var transformAlign: GPUParticles3D.TransformAlign
var visibilityAabb: AABB
The
AABB
that determines the node’s region which needs to be visible on screen for the particle system to be active.extraCullMargin
is added on each of the AABB’s axes. Particle collisions and attraction will only occur within this area.func captureAabb(
) -> AABB Returns the axis-aligned bounding box that contains all the particles that are active in the current frame.
func convertFromParticles(Node?
) Sets this node’s properties to match a given
CPUParticles3D
node.func emitParticle(xform: Transform3D, velocity: Vector3, color: Color, custom: Color, flags: UInt32
) Emits a single particle. Whether
xform
,velocity
,color
andcustom
are applied depends on the value offlags
. SeeEmitFlags
.func restart(
) Restarts the particle emission, clearing existing particles.