SpawnBehavior<DataType, ParticleType>
Behavior used to control the spawning shape and initial direction of particles.
Behavior supports four shapes, a point shape where particles spawn from a single point, a line shape where particles spawn along a line, a rectangle shape where particles spawn within a rectangle area, and a circle shape where particles spawn within a circular area.
See
SpawnBehaviorConfig for configuration options.
Examples
// Spawn particles from a point with an initial upward direction.
spawnBehavior.applyConfig({
shape: "point",
direction: { x: 0, y: -1 },
});// Spawn particles along a horizontal line of
// length 200 with no initial direction.
spawnBehavior.applyConfig({
shape: "line",
length: 200,
direction: { x: 0, y: 0 },
});// Spawn particles within a rectangle of width 100 and
// height 50 with an initial rightward direction.
spawnBehavior.applyConfig({
shape: "rectangle",
width: 100,
height: 50,
direction: { x: 1, y: 0 },
});// Spawn particles within a circle of outer radius 75 and
// inner radius 25 with no initial direction.
spawnBehavior.applyConfig({
shape: "circle",
outerRadius: 75,
innerRadius: 25,
direction: { x: 0, y: 0 },
});Extends
EmitterBehavior<SpawnBehaviorConfig,DataType,ParticleType>
Type Parameters
DataType
DataType extends BaseParticleData = BaseParticleData
Type describing the data object stored on particles.
ParticleType
ParticleType extends IEmitterParticle<DataType> = IEmitterParticle<DataType>
Type describing the particle used within the emitter.
Implements
InitBehavior<DataType,ParticleType>
Constructors
Constructor
new SpawnBehavior<DataType, ParticleType>(emitter): SpawnBehavior<DataType, ParticleType>;Creates a new instance of the behavior.
Parameters
emitter
Emitter<DataType, ParticleType>
Emitter instance this behavior belongs to.
Returns
SpawnBehavior<DataType, ParticleType>
Inherited from
Accessors
direction
Get Signature
get direction(): PointData;Initial direction vector for spawned particles.
Returns
PointData
Set Signature
set direction(value): void;Parameters
value
PointData
Returns
void
height
Get Signature
get height(): number;Height of the spawn shape (for rectangle shape).
Returns
number
Set Signature
set height(value): void;Parameters
value
number
Returns
void
innerRadius
Get Signature
get innerRadius(): number;Inner radius of the spawn shape (for circle shape).
Returns
number
Set Signature
set innerRadius(value): void;Parameters
value
number
Returns
void
origin
Get Signature
get origin(): PointData;Origin (parent-local) position used as the center/offset for particle spawning.
This value is added to the shape-generated spawn coordinates in init. For the point shape, particles spawn exactly at this position.
This is relative to the parent transform (not a world-space position).
Returns
PointData
Set Signature
set origin(value): void;Parameters
value
PointData
Returns
void
outerRadius
Get Signature
get outerRadius(): number;Outer radius of the spawn shape (for circle shape).
Returns
number
Set Signature
set outerRadius(value): void;Parameters
value
number
Returns
void
shape
Get Signature
get shape(): SpawnShape;Current spawn shape used by the behavior.
Returns
Set Signature
set shape(value): void;Parameters
value
Returns
void
updateOrder
Get Signature
get updateOrder(): BehaviorOrder;Defines at which step of the update cycle the behavior is applied.
initial: Earliest step, useful when other behaviors depend on this behavior.normal: Default step for most behaviors.late: Latest step, useful for behaviors that should override others or depend on their properties.
Returns
Implementation of
Overrides
width
Get Signature
get width(): number;Width of the spawn shape (for rectangle and line shapes).
Returns
number
Set Signature
set width(value): void;Parameters
value
number
Returns
void
Methods
applyConfig()
applyConfig(config): void;Reset the behavior and apply the provided configuration.
Parameters
config
Behavior configuration.
Returns
void
Implementation of
Overrides
getConfig()
getConfig(): SpawnBehaviorConfig;Retrieve the current behavior properties as a configuration object. If the behavior is inactive, undefined is returned.
Returns
Behavior configuration object or undefined if inactive.
Implementation of
Overrides
init()
init(particle): void;Initialize the particle.
Parameters
particle
ParticleType
Particle to initialize.
Returns
void
Implementation of
reset()
protected reset(): void;Reset the behavior to its default state.
Returns
void