Create a new ParticleSystemComponent.
The ComponentSystem that created this Component.
The Entity this Component is attached to.
Private
_drawPrivate
_requestedThe Entity that this Component is attached to.
The ComponentSystem used to create this Component.
Orient particles in their direction of motion.
When animNumAnimations is greater than 1, the sprite sheet animation index determines which animation the particle system should play.
Controls whether the sprite sheet animation plays once or loops continuously.
Number of sprite sheet animations contained within the current sprite sheet. The number of animations multiplied by number of frames should be a value less than animTilesX multiplied by animTilesY.
Number of sprite sheet frames in the current sprite sheet animation. The number of animations multiplied by number of frames should be a value less than animTilesX multiplied by animTilesY.
Sprite sheet animation speed. 1 = particle lifetime, 2 = twice during lifetime etc.
The sprite sheet frame that the animation should begin playing from. Indexed from the start of the current animation.
Number of horizontal tiles in the sprite sheet.
Number of vertical tiles in the sprite sheet.
Controls whether the particle system plays automatically on creation. If set to false, it is necessary to call ParticleSystemComponent#play for the particle system to play. Defaults to true.
Controls how particles are blended when being written to the currently active render target. Can be:
Controls fading of particles near their intersections with scene geometry. This effect, when it's non-zero, requires scene depth map to be rendered. Multiple depth-dependent effects can share the same map, but if you only use it for particles, bear in mind that it can double engine draw calls.
If enabled, the particles will write to the depth buffer. If disabled, the depth buffer is left unchanged and particles will be guaranteed to overwrite one another in the order in which they are rendered.
(Only for EMITTERSHAPE_SPHERE) The radius within which particles are spawned at random positions.
(Only for EMITTERSHAPE_SPHERE) The inner radius within which particles are not spawned.
Shape of the emitter. Defines the bounds inside which particles are spawned. Also affects the direction of initial velocity.
Enabling Half Lambert lighting avoids particles looking too flat in shadowed areas. It is a completely non-physical lighting model but can give more pleasing visual results.
Defines magnitude of the initial emitter velocity. Direction is given by emitter shape.
Color multiplier.
An array of layer IDs (Layer#id) to which this particle system should belong. Don't push/pop/splice or modify this array, if you want to change it - set a new one instead.
The length of time in seconds between a particle's birth and its death.
If enabled, particles will be lit by ambient and directional lights.
Binds particles to emitter transformation rather then world space.
Enables or disables respawning of particles.
Disable fogging.
Maximum number of simulated particles.
Sorting mode. Forces CPU simulation, so be careful.
(Only for PARTICLEORIENTATION_WORLD and PARTICLEORIENTATION_EMITTER) The exception of extents of a local space bounding box within which particles are not spawned. Aligned to the center of EmitterExtents.
If enabled, the particle system will be initialized as though it had already completed a full cycle. This only works with looping particle systems.
Each particle emitted by the system will play a random animation from the sprite sheet, up to animNumAnimations.
Minimal interval in seconds between particle births.
Maximal interval in seconds between particle births.
Renders particles in 2D screen space. This needs to be set when particle system is part of hierarchy with ScreenComponent as its ancestor, and allows particle system to integrate with the rendering of ElementComponents. Note that an entity with ParticleSystem component cannot be parented directly to ScreenComponent, but has to be a child of a ElementComponent, for example LayoutGroupComponent.
Sorting mode. Forces CPU simulation, so be careful.
Minimal initial Euler angle of a particle.
Maximal initial Euler angle of a particle.
A value in world units that controls the amount by which particles are stretched based on their velocity. Particles are stretched from their center towards their previous position.
Enable particle wrapping.
Fire an event, all additional arguments are passed on to the event listener.
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
Self for chaining.
obj.fire('test', 'This is the message');
Test if there are any handlers bound to an event name.
The name of the event to test.
True if the object has handlers bound to the specified event name.
obj.on('test', function () { }); // bind an event to 'test'
obj.hasEvent('test'); // returns true
obj.hasEvent('hello'); // returns false
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Self for chaining.
const handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Attach an event handler to an event.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
Can be used for removing event in the future.
obj.on('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
const evt = obj.on('test', function (a, b) {
console.log(a + b);
});
// some time later
evt.off();
Attach an event handler to an event. This handler will be removed after being fired once.
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: object = ...Object to use as 'this' when the event is fired, defaults to current this.
obj.once('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
obj.fire('test', 1, 2); // not going to get handled
Private
rebuild
Used to simulate particles and produce renderable particle mesh on either CPU or GPU. GPU simulation is generally much faster than its CPU counterpart, because it avoids slow CPU-GPU synchronization and takes advantage of many GPU cores. However, it requires client to support reasonable uniform count, reading from multiple textures in vertex shader and OES_texture_float extension, including rendering into float textures. Most mobile devices fail to satisfy these requirements, so it's not recommended to simulate thousands of particles on them. GPU version also can't sort particles, so enabling sorting forces CPU mode too. Particle rotation is specified by a single angle parameter: default billboard particles rotate around camera facing axis, while mesh particles rotate around 2 different view-independent axes. Most of the simulation parameters are specified with Curve or CurveSet. Curves are interpolated based on each particle's lifetime, therefore parameters are able to change over time. Most of the curve parameters can also be specified by 2 minimum/maximum curves, this way each particle will pick a random value in-between.