Particles
A visual container that manages a particle emitter with convenient automatic emission modes.
Particles extends Visual to provide a high-level wrapper around ParticleEmitter, adding features like automatic continuous emission and timed burst intervals. This makes it easier to create self-contained particle effects that can be added to the scene and configured with minimal code.
The class is generic, allowing use of custom ParticleEmitter subclasses for specialized particle behaviors.
Key features:
- Automatic continuous emission with
autoEmit - Automatic burst intervals with
autoExplodeInterval - Forwards all emitter properties with
emitter*prefix - Lifecycle management - destroying particles destroys the emitter
// Create auto-emitting smoke
var smoke = new Particles();
smoke.autoEmit = true;
smoke.emitterInterval = 0.05;
smoke.emitterLifespan(0.5, 1.0);
smoke.emitterSpeedStart(50, 100);
smoke.emitterAlphaEnd(0);
scene.add(smoke);
// Create periodic explosions
var explosions = new Particles();
explosions.autoExplodeInterval = 2.0; // Every 2 seconds
explosions.autoExplodeQuantity = 50;
explosions.emitterSpeedStart(100, 300);
scene.add(explosions);
// Use custom emitter
var custom = new Particles(new MyCustomEmitter());
Instance Members
The particle emitter managed by this visual.
Can be accessed directly for advanced configuration or
to call methods like explode() and emitParticle().
Most common properties are also exposed with emitter* prefix.
autoEmit: BoolWhether to automatically emit particles continuously.
When set to true, starts continuous emission using emitterInterval.
When set to false, stops emission (existing particles continue).
Default: false
particles.emitterInterval = 0.1; // Configure interval first
particles.autoEmit = true; // Start emitting
autoExplodeInterval: FloatInterval in seconds between automatic burst emissions.
When set to a positive value, triggers burst emissions of
autoExplodeQuantity particles at regular intervals.
Set to -1 to disable automatic bursts.
Default: -1 (disabled)
// Burst 30 particles every 1.5 seconds
particles.autoExplodeQuantity = 30;
particles.autoExplodeInterval = 1.5;
autoExplodeQuantity: IntNumber of particles to emit in each automatic burst.
Used with autoExplodeInterval to create periodic bursts.
Only takes effect when autoExplodeInterval is positive.
Default: 64
emitterPaused: BoolDetermines whether the emitter is currently paused. It is totally safe to directly toggle this.
emitterInterval: FloatHow often a particle is emitted, if currently emitting. Can be modified at the middle of an emission safely;
How particles should be launched. If CIRCLE (default), particles will use launchAngle and speed.
Otherwise, particles will just use velocityX and velocityY.
emitterVisualScaleActive: BoolApply particle scale to underlying visual or not.
emitterKeepScaleRatio: BoolKeep the scale ratio of the particle. Uses the scaleX value for reference.
emitterVisualColorActive: BoolApply particle color to underlying visual or not.
emitterVisualAlphaActive: BoolApply particle alpha to underlying visual or not.
emitterVisualPositionActive: BoolApply particle position (x & y) to underlying visual or not.
emitterVisualRotationActive: BoolApply particle angle to underlying visual rotation or not.
emitterWidth: FloatThe width of the emission area.
If not defined (-1), will use visual's width bound to this ParticleEmitter object, if any
emitterHeight: FloatThe height of the emission area.
If not defined (-1), will use visual's height bound to this ParticleEmitter object, if any
emitterX: FloatThe x position of the emission, relative to particles parent (if any)
emitterY: FloatThe y position of the emission, relative to particles parent (if any)
emitterVelocityActive: BoolEnable or disable the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterMaxVelocityX: FloatIf you are using acceleration, you can use maxVelocity with it
to cap the speed automatically (very useful!).
emitterMaxVelocityY: FloatIf you are using acceleration, you can use maxVelocity with it
to cap the speed automatically (very useful!).
emitterVelocityStartMinX: FloatSets the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterVelocityStartMinY: FloatSets the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterVelocityStartMaxX: FloatSets the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterVelocityStartMaxY: FloatSets the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterVelocityEndMinX: FloatSets the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterVelocityEndMinY: FloatSets the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterVelocityEndMaxX: FloatSets the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterVelocityEndMaxY: FloatSets the velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
emitterSpeedStartMin: FloatSet the speed range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with CIRCLE.
emitterSpeedStartMax: FloatSet the speed range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with CIRCLE.
emitterSpeedEndMin: FloatSet the speed range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with CIRCLE.
emitterSpeedEndMax: FloatSet the speed range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with CIRCLE.
emitterMaxAngularVelocity: FloatUse in conjunction with angularAcceleration for fluid spin speed control.
emitterAngularAccelerationActive: BoolEnable or disable the angular acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularAccelerationStartMin: FloatSet the angular acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularAccelerationStartMax: FloatSet the angular acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularDragActive: BoolEnable or disable the angular drag range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularDragStartMin: FloatSet the angular drag range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularDragStartMax: FloatSet the angular drag range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularVelocityActive: BoolEnable or disable the angular velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularVelocityStartMin: FloatThe angular velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularVelocityStartMax: FloatThe angular velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularVelocityEndMin: FloatThe angular velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngularVelocityEndMax: FloatThe angular velocity range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAngleActive: BoolEnable or disable the angle range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
angleEndMin and angleEndMax are ignored unless ignoreAngularVelocity is set to true.
emitterAngleStartMin: FloatThe angle range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
angleEndMin and angleEndMax are ignored unless ignoreAngularVelocity is set to true.
emitterAngleStartMax: FloatThe angle range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
angleEndMin and angleEndMax are ignored unless ignoreAngularVelocity is set to true.
emitterAngleEndMin: FloatThe angle range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
angleEndMin and angleEndMax are ignored unless ignoreAngularVelocity is set to true.
emitterAngleEndMax: FloatThe angle range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
angleEndMin and angleEndMax are ignored unless ignoreAngularVelocity is set to true.
emitterIgnoreAngularVelocity: BoolSet this if you want to specify the beginning and ending value of angle,
instead of using angularVelocity (or angularAcceleration).
emitterLaunchAngleActive: BoolEnable or disable the angle range at which particles will be launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Ignored unless launchMode is set to CIRCLE.
emitterLaunchAngleMin: FloatThe angle range at which particles will be launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Ignored unless launchMode is set to CIRCLE.
emitterLaunchAngleMax: FloatThe angle range at which particles will be launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Ignored unless launchMode is set to CIRCLE.
emitterLifespanActive: BoolEnable or disable the life, or duration, range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterLifespanMin: FloatThe life, or duration, range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterLifespanMax: FloatThe life, or duration, range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleActive: BoolEnable or disable scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleStartMinX: FloatSets scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleStartMinY: FloatSets scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleStartMaxX: FloatSets scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleStartMaxY: FloatSets scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleEndMinX: FloatSets scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleEndMinY: FloatSets scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleEndMaxX: FloatSets scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterScaleEndMaxY: FloatSets scale range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAlphaActive: BoolEnable or disable alpha range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAlphaStartMin: FloatSets alpha range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAlphaStartMax: FloatSets alpha range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAlphaEndMin: FloatSets alpha range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAlphaEndMax: FloatSets alpha range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterColorActive: BoolEnable or disable color range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterColorStartMin: ColorSets color range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterColorStartMax: ColorSets color range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterColorEndMin: ColorSets color range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterColorEndMax: ColorSets color range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragActive: BoolEnable or disable X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragStartMinX: FloatSets X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragStartMinY: FloatSets X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragStartMaxX: FloatSets X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragStartMaxY: FloatSets X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragEndMinX: FloatSets X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragEndMinY: FloatSets X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragEndMaxX: FloatSets X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterDragEndMaxY: FloatSets X and Y drag component of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
emitterAccelerationActive: BoolEnable or disable the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
emitterAccelerationStartMinX: FloatSets the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
emitterAccelerationStartMinY: FloatSets the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
emitterAccelerationStartMaxX: FloatSets the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
emitterAccelerationStartMaxY: FloatSets the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
emitterAccelerationEndMinX: FloatSets the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
emitterAccelerationEndMinY: FloatSets the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
emitterAccelerationEndMaxX: FloatSets the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
emitterAccelerationEndMaxY: FloatSets the acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Set acceleration y-values to give particles gravity.
The width and height of the emission area.
If not defined (-1), will use visual's width and height bound to this ParticleEmitter object, if any
| Name | Type |
|---|---|
width |
Float |
height |
Float |
The x and y position of the emission, relative to particles parent (if any)
| Name | Type |
|---|---|
x |
Float |
y |
Float |
If you are using acceleration, you can use maxVelocity with it
to cap the speed automatically (very useful!).
| Name | Type |
|---|---|
maxVelocityX |
Float |
maxVelocityY |
Float |
emitterVelocityStart(startMinX: Float, startMinY: Float, ?startMaxX: Float, ?startMaxY: Float): VoidSets the velocity starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
| Name | Type | Default |
|---|---|---|
startMinX |
Float | |
startMinY |
Float | |
startMaxX |
Float | (optional) |
startMaxY |
Float | (optional) |
Sets the velocity ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with SQUARE.
| Name | Type | Default |
|---|---|---|
endMinX |
Float | |
endMinY |
Float | |
endMaxX |
Float | (optional) |
endMaxY |
Float | (optional) |
Set the speed starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with CIRCLE.
| Name | Type | Default |
|---|---|---|
startMin |
Float | |
startMax |
Float | (optional) |
Set the speed ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end. Only used with CIRCLE.
| Name | Type | Default |
|---|---|---|
endMin |
Float | |
endMax |
Float | (optional) |
Set the angular acceleration range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type |
|---|---|
startMin |
Float |
startMax |
Float |
Set the angular drag range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type |
|---|---|
startMin |
Float |
startMax |
Float |
The angular velocity starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
startMin |
Float | |
startMax |
Float | (optional) |
The angular velocity ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
endMin |
Float | |
endMax |
Float | (optional) |
The angle starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
angleEndMin and angleEndMax are ignored unless ignoreAngularVelocity is set to true.
| Name | Type | Default |
|---|---|---|
startMin |
Float | |
startMax |
Float | (optional) |
The angle ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
angleEndMin and angleEndMax are ignored unless ignoreAngularVelocity is set to true.
| Name | Type | Default |
|---|---|---|
endMin |
Float | |
endMax |
Float | (optional) |
The angle range at which particles will be launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
Ignored unless launchMode is set to CIRCLE.
| Name | Type |
|---|---|
min |
Float |
max |
Float |
The life, or duration, range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type |
|---|---|
min |
Float |
max |
Float |
Sets scale starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
startMinX |
Float | |
startMinY |
Float | |
startMaxX |
Float | (optional) |
startMaxY |
Float | (optional) |
Sets scale ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
endMinX |
Float | |
endMinY |
Float | |
endMaxX |
Float | (optional) |
endMaxY |
Float | (optional) |
emitterAccelerationStart(startMinX: Float, startMinY: Float, ?startMaxX: Float, ?startMaxY: Float): VoidSets acceleration starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
startMinX |
Float | |
startMinY |
Float | |
startMaxX |
Float | (optional) |
startMaxY |
Float | (optional) |
Sets acceleration ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
endMinX |
Float | |
endMinY |
Float | |
endMaxX |
Float | (optional) |
endMaxY |
Float | (optional) |
Sets drag starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
startMinX |
Float | |
startMinY |
Float | |
startMaxX |
Float | (optional) |
startMaxY |
Float | (optional) |
Sets drag ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
endMinX |
Float | |
endMinY |
Float | |
endMaxX |
Float | (optional) |
endMaxY |
Float | (optional) |
Sets color starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
startMin |
Color | |
startMax |
Color | (optional) |
Sets color ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
endMin |
Color | |
endMax |
Color | (optional) |
Sets alpha starting range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
startMin |
Float | |
startMax |
Float | (optional) |
Sets alpha ending range of particles launched from this #if cs (cast emitter:ParticleEmitter) #else emitter #end.
| Name | Type | Default |
|---|---|---|
endMin |
Float | |
endMax |
Float | (optional) |
new(?emitter: ceramic.Particles.T): VoidCreates a new Particles visual with an optional custom emitter.
| Name | Type | Default | Description |
|---|---|---|---|
emitter |
ceramic.Particles.T | (optional) | Optional custom ParticleEmitter instance or subclass. If not provided, creates a standard ParticleEmitter. |
Private Members
init(): VoidInitializes the particles system.
Sets up lifecycle binding so that destroying the emitter also destroys this visual container.
clearExplodeInterval(): VoidTimer cleanup function for auto-explode intervals.
computeAutoExplode(): VoidUpdates the automatic explosion timer based on current settings.
Clears any existing timer and creates a new one if both interval and quantity are positive.
doAutoExplode(): VoidExecutes an automatic burst emission.
Called by the interval timer to emit the configured quantity of particles.
Metadata
| Name | Parameters |
|---|---|
:build |
tracker.macros.EventsMacro.build() |
:autoBuild |
tracker.macros.EventsMacro.build() |
:build |
ceramic.macros.EntityMacro.buildForCompletion() |
:autoBuild |
ceramic.macros.EntityMacro.buildForCompletion() |