Skip to content

@emile/engine


@emile/engine / rendering/particles/emitter / ParticleEmitter

Class: ParticleEmitter ​

Defined in: src/rendering/particles/emitter.ts:51

A component that represents a particle emitter.

This component is used to emit particles from an entity, using the particle system.

Extends ​

Constructors ​

new ParticleEmitter() ​

new ParticleEmitter(): ParticleEmitter

Defined in: src/rendering/particles/emitter.ts:387

Returns ​

ParticleEmitter

Overrides ​

Component.constructor

Properties ​

$callbacks ​

protected $callbacks: object

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:35

Index Signature ​

[op: number]: Function[]

Inherited from ​

Component.$callbacks


$changes ​

protected $changes: ChangeTree

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:34

Inherited from ​

Component.$changes


componentId ​

readonly componentId: number

Defined in: src/ecs/component.ts:26

Inherited from ​

Component.componentId


enabled ​

enabled: boolean = true

Defined in: src/rendering/particles/emitter.ts:63

Whether the particle emitter is enabled.

When disabled, the particle emitter will not emit any particles.

When enabled, the particle emitter will emit particles based on the settings.

Default ​

ts
true

enabledLifetimeMs ​

enabledLifetimeMs: number = -1

Defined in: src/rendering/particles/emitter.ts:74

The lifetime of the particle emitter in milliseconds.

Once enabled, this is the time that the emitter will be enabled for. After this time, the emitter will be disabled automatically.

You can set this to -1 to have the emitter enabled indefinitely.

Default ​

ts
-1

gravityScale ​

gravityScale: number = 0

Defined in: src/rendering/particles/emitter.ts:83

The scale factor of the gravity applied to the particles.

Set to 0 to disable gravity.

Default ​

ts
0

maxParticles ​

maxParticles: number = 1000

Defined in: src/rendering/particles/emitter.ts:90

The maximum number of particles that can be alive at once. After this is reached no more particles will be emitted until some die.

Default ​

ts
1000

particleAcceleration ​

particleAcceleration: number = 0

Defined in: src/rendering/particles/emitter.ts:283

This is the rate at which the particle will accelerate in meters per second squared.

Default ​

ts
0

particleAccelerationVariance ​

particleAccelerationVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:292

The variance in the acceleration rate of an emitted particle in meters per second squared. This will be used to randomly vary the acceleration rate of the particle.

This is the maximum acceleration rate that can be added or subtracted from the initial acceleration rate. This will be chosen per particle when emitted and remain constant for the lifetime of the particle.

Default ​

ts
0

particleColorStops ​

particleColorStops: ArraySchema<ParticleEmitterColorStop>

Defined in: src/rendering/particles/emitter.ts:384

The color stops for the particle.

This is used to have fine grained control of the particle's color and alpha over its lifetime.

Default ​

ts
[]

particleEmitRatePerSecond ​

particleEmitRatePerSecond: number = 10

Defined in: src/rendering/particles/emitter.ts:129

This is the number of particles that will be emitted per second.

Default ​

ts
10

particleEmitRatePerSecondVariance ​

particleEmitRatePerSecondVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:136

The variance in the number of particles that will be emitted per second. This will be used to randomly vary the number of particles emitted per second.

Default ​

ts
0

particleEnableExponentialScaleRate ​

particleEnableExponentialScaleRate: boolean = false

Defined in: src/rendering/particles/emitter.ts:357

If this is true, the particle scale rate will be exponential. i.e. the particle will scale by a factor of the scale rate each second.

If this is false, the particle scale rate will be additive. i.e. the particle will scale by the scale rate each second.

Default ​

ts
false

particleEndSize ​

particleEndSize: number = -1

Defined in: src/rendering/particles/emitter.ts:223

The end size of an emitted particle.

This is the size that the particle will reach at the end of its lifetime.

Set this to a value >= 0 to enable particle size interpolation.

Default ​

ts
-1

particleEndSizeVariance ​

particleEndSizeVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:232

The variance in the end size of an emitted particle. This will be used to randomly vary the size of the particle.

This is the maximum size that can be added or subtracted from the end size.

Default ​

ts
0

particleLifetimeMs ​

particleLifetimeMs: number = 1000

Defined in: src/rendering/particles/emitter.ts:115

The lifetime of each particle in milliseconds.

After this time the particle will be removed from the system.

Default ​

ts
1000

particleLifetimeVarianceMs ​

particleLifetimeVarianceMs: number = 0

Defined in: src/rendering/particles/emitter.ts:122

The variance in the lifetime of each particle in milliseconds. This will be used to randomly vary the lifetime of the particle.

Default ​

ts
0

particleRotateAcceleration ​

particleRotateAcceleration: number = 0

Defined in: src/rendering/particles/emitter.ts:299

This is the rate at which the particle's rotation will increase in radians per second squared.

Default ​

ts
0

particleRotateAccelerationVariance ​

particleRotateAccelerationVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:308

This is the variance in the rotation acceleration rate of an emitted particle in radians per second squared. This will be used to randomly vary the rotation acceleration rate of the particle.

This is the maximum rotation acceleration rate that can be added or subtracted from the initial rotation acceleration rate. This will be chosen per particle when emitted and remain constant for the lifetime of the particle.

Default ​

ts
0

particleRotateSpeed ​

particleRotateSpeed: number = 0

Defined in: src/rendering/particles/emitter.ts:267

This is the speed at which the particle will rotate in radians per second.

Default ​

ts
0

particleRotateSpeedVariance ​

particleRotateSpeedVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:276

The variance in the rotation speed of an emitted particle in radians per second. This will be used to randomly vary the rotation rate of the particle.

This is the maximum rotation speed that can be added or subtracted from the initial rotation speed. This will be chosen per particle when emitted and remain constant for the lifetime of the particle.

Default ​

ts
0

particleScaleXRate ​

particleScaleXRate: number = 0

Defined in: src/rendering/particles/emitter.ts:319

This is the rate at which the particle will scale on the x-axis.

If particleEnableExponentialScaleRate is false, the particle will scale by the scale rate each second. i.e. additive

If particleEnableExponentialScaleRate is true, the particle will scale by a factor of the scale rate each second. i.e. multiplicative

Default ​

ts
0

particleScaleXRateVariance ​

particleScaleXRateVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:328

The variance in the x scale rate of an emitted particle in meters per second. This will be used to randomly vary the scale rate of the particle.

This is the maximum scale rate that can be added or subtracted from the initial scale rate. This will be chosen per particle when emitted and remain constant for the lifetime of the particle.

Default ​

ts
0

particleScaleYRate ​

particleScaleYRate: number = 0

Defined in: src/rendering/particles/emitter.ts:339

This is the rate at which the particle will scale on the y-axis.

If particleEnableExponentialScaleRate is false, the particle will scale by the scale rate each second. i.e. additive

If particleEnableExponentialScaleRate is true, the particle will scale by a factor of the scale rate each second. i.e. multiplicative

Default ​

ts
0

particleScaleYRateVariance ​

particleScaleYRateVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:348

The variance in the y scale rate of an emitted particle in meters per second. This will be used to randomly vary the scale rate of the particle.

This is the maximum scale rate that can be added or subtracted from the initial scale rate. This will be chosen per particle when emitted and remain constant for the lifetime of the particle.

Default ​

ts
0

particleSpriteType ​

particleSpriteType: number = -1

Defined in: src/rendering/particles/emitter.ts:106

The sprite type of the particle to emit.

This is only used if the particle type is set to ParticleType.SPRITE.

Default ​

ts
-1

particleStartAlpha ​

particleStartAlpha: number = 1

Defined in: src/rendering/particles/emitter.ts:375

The start alpha of the particle.

This should be a value between 0 and 1 (inclusive).

Default ​

ts
1

particleStartColor ​

particleStartColor: number = 0xffffff

Defined in: src/rendering/particles/emitter.ts:366

The start color of the particle.

This is a hex color value.

Default ​

ts
0xffffff

particleStartDirAngle ​

particleStartDirAngle: number

Defined in: src/rendering/particles/emitter.ts:180

The initial direction of an emitted particle in radians.

  • 0 is right
  • Math.PI is left
  • -Math.PI / 2 is up
  • Math.PI / 2 is down

Default ​

ts
-Math.PI / 2

particleStartDirVariance ​

particleStartDirVariance: number

Defined in: src/rendering/particles/emitter.ts:189

The variance in the initial direction of an emitted particle in radians. This will be used to randomly vary the direction of the particle.

This is the maximum direction that can be added or subtracted from the initial direction.

Default ​

ts
Math.PI / 4

particleStartOffsetX ​

particleStartOffsetX: number = 0

Defined in: src/rendering/particles/emitter.ts:239

The initial offset of an emitted particle on the x-axis, from the emitter's position.

Default ​

ts
0

particleStartOffsetXVariance ​

particleStartOffsetXVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:253

The variance in the initial offset of an emitted particle on the x-axis. This will be used to randomly vary the offset of the particle.

Default ​

ts
0

particleStartOffsetY ​

particleStartOffsetY: number = 0

Defined in: src/rendering/particles/emitter.ts:246

The initial offset of an emitted particle on the y-axis, from the emitter's position.

Default ​

ts
0

particleStartOffsetYVariance ​

particleStartOffsetYVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:260

The variance in the initial offset of an emitted particle on the y-axis. This will be used to randomly vary the offset of the particle.

Default ​

ts
0

particleStartRotation ​

particleStartRotation: number = 0

Defined in: src/rendering/particles/emitter.ts:143

The initial rotation of an emitted particle in radians.

Default ​

ts
0

particleStartRotationVariance ​

particleStartRotationVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:152

The variance in the initial rotation of an emitted particle in radians. This will be used to randomly vary the rotation of the particle.

This is the maximum rotation that can be added or subtracted from the initial rotation.

Default ​

ts
0

particleStartSize ​

particleStartSize: number = 0.2

Defined in: src/rendering/particles/emitter.ts:196

The initial size of an emitted particle.

Default ​

ts
0.2

particleStartSizeInterpolationT ​

particleStartSizeInterpolationT: number = 0

Defined in: src/rendering/particles/emitter.ts:212

A value between 0 and 1 that represents the percentage of the particle's lifetime at which the particle size interpolation should start, between the start and end size.

Default ​

ts
0

particleStartSizeVariance ​

particleStartSizeVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:205

The variance in the initial size of an emitted particle. This will be used to randomly vary the size of the particle.

This is the maximum size that can be added or subtracted from the initial size.

Default ​

ts
0

particleStartSpeed ​

particleStartSpeed: number = 3

Defined in: src/rendering/particles/emitter.ts:159

The initial speed of an emitted particle.

Default ​

ts
3

particleStartSpeedVariance ​

particleStartSpeedVariance: number = 0

Defined in: src/rendering/particles/emitter.ts:168

The variance in the initial speed of an emitted particle. This will be used to randomly vary the speed of the particle.

This is the maximum speed that can be added or subtracted from the initial speed.

Default ​

ts
0

particleType ​

particleType: ParticleType = ParticleType.SQUARE

Defined in: src/rendering/particles/emitter.ts:97

The type of particle to emit.

Default ​

ts
ParticleType.SQUARE

_context ​

static _context: Context

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:30

Inherited from ​

Component._context


_definition ​

static _definition: SchemaDefinition

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:31

Inherited from ​

Component._definition


_typeid ​

static _typeid: number

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:29

Inherited from ​

Component._typeid


COMPONENT_ID ​

readonly static COMPONENT_ID: number = 200

Defined in: src/rendering/particles/emitter.ts:52

The unique identifier of the component.

You must set this value to the unique identifier of the component.

This is required to identify the component on an entity, between the client and server.

This should be the same on the client and server across all instances of the same component.

Note ​

The id must be between 0 and 190 (inclusive), 191 - 255 are reserved for the engine.

Overrides ​

Component.COMPONENT_ID

Accessors ​

_definition ​

Get Signature ​

get protected _definition(): SchemaDefinition

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:44

Returns ​

SchemaDefinition

Inherited from ​

Component._definition

Methods ​

applyFilters() ​

applyFilters(client, encodeAll?): number[]

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:62

Parameters ​

client ​

any

encodeAll? ​

boolean

Returns ​

number[]

Inherited from ​

Component.applyFilters


assign() ​

assign(props): this

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:41

Parameters ​

props ​

{ componentId: number; enabled: boolean; enabledLifetimeMs: number; gravityScale: number; maxParticles: number; particleAcceleration: number; particleAccelerationVariance: number; particleColorStops: ArraySchema<ParticleEmitterColorStop>; particleEmitRatePerSecond: number; particleEmitRatePerSecondVariance: number; particleEnableExponentialScaleRate: boolean; particleEndSize: number; particleEndSizeVariance: number; particleLifetimeMs: number; particleLifetimeVarianceMs: number; particleRotateAcceleration: number; particleRotateAccelerationVariance: number; particleRotateSpeed: number; particleRotateSpeedVariance: number; particleScaleXRate: number; particleScaleXRateVariance: number; particleScaleYRate: number; particleScaleYRateVariance: number; particleSpriteType: number; particleStartAlpha: number; particleStartColor: number; particleStartDirAngle: number; particleStartDirVariance: number; particleStartOffsetX: number; particleStartOffsetXVariance: number; particleStartOffsetY: number; particleStartOffsetYVariance: number; particleStartRotation: number; particleStartRotationVariance: number; particleStartSize: number; particleStartSizeInterpolationT: number; particleStartSizeVariance: number; particleStartSpeed: number; particleStartSpeedVariance: number; particleType: ParticleType; } | ToJSON<ParticleEmitter>

Returns ​

this

Inherited from ​

Component.assign


clone() ​

clone(): this

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:63

Returns ​

this

Inherited from ​

Component.clone


decode() ​

decode(bytes, it?, ref?): DataChange<any, string>[]

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:59

Parameters ​

bytes ​

number[]

it? ​

Iterator

ref? ​

Ref

Returns ​

DataChange<any, string>[]

Inherited from ​

Component.decode


deleteByIndex() ​

protected deleteByIndex(index): void

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:67

Parameters ​

index ​

number

Returns ​

void

Inherited from ​

Component.deleteByIndex


discardAllChanges() ​

discardAllChanges(): void

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:65

Returns ​

void

Inherited from ​

Component.discardAllChanges


encode() ​

encode(encodeAll?, bytes?, useFilters?): number[]

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:60

Parameters ​

encodeAll? ​

boolean

bytes? ​

number[]

useFilters? ​

boolean

Returns ​

number[]

Inherited from ​

Component.encode


encodeAll() ​

encodeAll(useFilters?): number[]

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:61

Parameters ​

useFilters? ​

boolean

Returns ​

number[]

Inherited from ​

Component.encodeAll


getByIndex() ​

protected getByIndex(index): any

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:66

Parameters ​

index ​

number

Returns ​

any

Inherited from ​

Component.getByIndex


listen() ​

listen<K>(prop, callback, immediate?): () => boolean

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:58

Client-side: listen for changes on property.

Type Parameters ​

K ​

K extends NonFunctionPropNames<ParticleEmitter>

Parameters ​

prop ​

K

the property name

callback ​

(value, previousValue) => void

callback to be triggered on property change

immediate? ​

boolean

trigger immediatelly if property has been already set.

Returns ​

Function

Returns ​

boolean

Inherited from ​

Component.listen


onChange() ​

onChange(callback): () => void

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:38

Parameters ​

callback ​

() => void

Returns ​

Function

Returns ​

void

Inherited from ​

Component.onChange


onRemove() ​

onRemove(callback): () => void

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:39

Parameters ​

callback ​

() => void

Returns ​

Function

Returns ​

void

Inherited from ​

Component.onRemove


setDirty() ​

setDirty<K>(property, operation?): void

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:51

(Server-side): Flag a property to be encoded for the next patch.

Type Parameters ​

K ​

K extends NonFunctionPropNames<ParticleEmitter>

Parameters ​

property ​

string representing the property name, or number representing the index of the property.

number | K

operation? ​

OPERATION

OPERATION to perform (detected automatically)

Returns ​

void

Inherited from ​

Component.setDirty


toJSON() ​

toJSON(): ToJSON<ParticleEmitter>

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:64

Returns ​

ToJSON<ParticleEmitter>

Inherited from ​

Component.toJSON


is() ​

static is(type): boolean

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:33

Parameters ​

type ​

DefinitionType

Returns ​

boolean

Inherited from ​

Component.is


onError() ​

static onError(e): void

Defined in: node_modules/.pnpm/@colyseus+schema@2.0.35/node_modules/@colyseus/schema/lib/Schema.d.ts:32

Parameters ​

e ​

any

Returns ​

void

Inherited from ​

Component.onError