Overview
The event system enables particles to respond dynamically to simulation conditions. Events monitor particle state (position, velocity, time) and trigger actions when specified conditions are met.Event Interfaces
ParticleEvent
Unique identifier for the event within the particle’s event array.
Human-readable name describing the event’s purpose.
Array of conditions that must be satisfied for the event to trigger. See EventCondition below.
Logic operator for combining multiple conditions:
"AND"- All conditions must be true"OR"- At least one condition must be true
Array of actions to execute when conditions are met. See EventAction below.
Internal flag indicating whether the event has already fired. Events only trigger once unless reset.
Controls whether the event is active. Set to
false to temporarily disable without removing the event.EventCondition
The particle state variable to monitor:
"x","y","z"- Position components"vx","vy","vz"- Velocity components"v"- Total velocity magnitude (speed)"t"- Elapsed simulation time
Comparison operator:
"=="- Equal to (with floating-point tolerance)">"- Greater than"<"- Less than">="- Greater than or equal to"<="- Less than or equal to"!="- Not equal to
The threshold value for comparison.
EventAction
The action to perform when the event triggers:
"pause"- Pause the entire simulation"changeColor"- Change the particle’s color (requirespayload)
Additional data for the action. Required for
changeColor, contains the new hex color code.How Events Work
Evaluation Order
Each simulation step:- Particle state is updated (position, velocity)
- Each enabled event is checked:
- If
triggered === true, skip - Evaluate all conditions
- Combine using
conditionLogic(AND/OR) - If conditions pass, execute all actions
- Set
triggered = true
- If
- Continue to next particle
One-Shot Behavior
Events trigger only once per particle. Oncetriggered is set to true, the event won’t fire again unless manually reset.
To create repeating events, you would need to programmatically reset
triggered to false or create multiple events.Examples
Ground Impact Detection
Time-Based Event
Velocity Threshold
Boundary Detection
Multiple Conditions (AND)
Multiple Conditions (OR)
Multiple Actions
Use Cases
Collision Detection
Detect when particles reach specific positions:Debug Markers
Visually highlight specific simulation states:Performance Analysis
Pause at critical moments for inspection:Phase Visualization
Change colors to represent different motion phases:Limitations
One-Shot Only
Events trigger once and remain triggered. No built-in support for repeating events or resetting conditions.Limited Actions
Currently onlypause and changeColor actions are supported. Cannot modify forces, mass, or other particle properties.
No Particle Interaction
Events cannot trigger based on other particles’ states or inter-particle distances.Floating-Point Precision
For equality checks (==, !=), be aware of floating-point precision issues. Use range checks instead:
Related
- PData Interface - Complete particle structure
- Force System - Define forces for particles
- Scene Configuration - Configure events in scene files