hytopia
Version:
The HYTOPIA SDK makes it easy for developers to create massively multiplayer games using JavaScript or TypeScript.
1,165 lines (506 loc) • 15 kB
Markdown
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) > [server](./server.md) > [ParticleEmitter](./server.particleemitter.md)
## ParticleEmitter class
Represents a particle emitter in the world. Emit 2D particles that always face the camera.
**Signature:**
```typescript
export default class ParticleEmitter extends EventRouter implements protocol.Serializable
```
**Extends:** [EventRouter](./server.eventrouter.md)
**Implements:** protocol.Serializable
## Remarks
Particle emitters are created directly as instances. They support a variety of configuration options through the [ParticleEmitterOptions](./server.particleemitteroptions.md) constructor argument.
<h2>Events</h2>
This class is an EventRouter, and instance of it emit events with payloads listed under [ParticleEmitterEventPayloads](./server.particleemittereventpayloads.md)<!-- -->.
## Example
```typescript
const particleEmitter = new ParticleEmitter({
textureUri: 'textures/particles/smoke.png',
});
particleEmitter.spawn(world);
```
## Constructors
<table><thead><tr><th>
Constructor
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[(constructor)(options)](./server.particleemitter._constructor_.md)
</td><td>
</td><td>
Constructs a new instance of the `ParticleEmitter` class
</td></tr>
</tbody></table>
## Properties
<table><thead><tr><th>
Property
</th><th>
Modifiers
</th><th>
Type
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[alphaTest](./server.particleemitter.alphatest.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The alpha test value, discards particle texture pixels with alpha opacity less than this value.
</td></tr>
<tr><td>
[attachedToEntity](./server.particleemitter.attachedtoentity.md)
</td><td>
`readonly`
</td><td>
[Entity](./server.entity.md) \| undefined
</td><td>
The entity to which the ParticleEmitter is attached if explicitly set.
</td></tr>
<tr><td>
[attachedToEntityNodeName](./server.particleemitter.attachedtoentitynodename.md)
</td><td>
`readonly`
</td><td>
string \| undefined
</td><td>
The name of the node of the attached entity (if the attached entity is a model entity) to attach the particle emitter to.
</td></tr>
<tr><td>
[colorEnd](./server.particleemitter.colorend.md)
</td><td>
`readonly`
</td><td>
[RgbColor](./server.rgbcolor.md) \| undefined
</td><td>
The color of an emitted particle at the end of its lifetime.
</td></tr>
<tr><td>
[colorEndVariance](./server.particleemitter.colorendvariance.md)
</td><td>
`readonly`
</td><td>
[RgbColor](./server.rgbcolor.md) \| undefined
</td><td>
The color variance of an emitted particle at the end of its lifetime.
</td></tr>
<tr><td>
[colorStart](./server.particleemitter.colorstart.md)
</td><td>
`readonly`
</td><td>
[RgbColor](./server.rgbcolor.md) \| undefined
</td><td>
The color of an emitted particle at the start of its lifetime.
</td></tr>
<tr><td>
[colorStartVariance](./server.particleemitter.colorstartvariance.md)
</td><td>
`readonly`
</td><td>
[RgbColor](./server.rgbcolor.md) \| undefined
</td><td>
The color variance of an emitted particle at the start of its lifetime.
</td></tr>
<tr><td>
[gravity](./server.particleemitter.gravity.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The gravity vector for an emitted particle.
</td></tr>
<tr><td>
[id](./server.particleemitter.id.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The unique identifier for the ParticlEmitter.
</td></tr>
<tr><td>
[isSpawned](./server.particleemitter.isspawned.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the ParticleEmitter is spawned in the world.
</td></tr>
<tr><td>
[isStopped](./server.particleemitter.isstopped.md)
</td><td>
`readonly`
</td><td>
boolean
</td><td>
Whether the ParticleEmitter is stopped.
</td></tr>
<tr><td>
[lifetime](./server.particleemitter.lifetime.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The lifetime of an emitted particle in seconds.
</td></tr>
<tr><td>
[lifetimeVariance](./server.particleemitter.lifetimevariance.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The lifetime variance of an emitted particle in seconds.
</td></tr>
<tr><td>
[maxParticles](./server.particleemitter.maxparticles.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The maximum number of live particles.
</td></tr>
<tr><td>
[offset](./server.particleemitter.offset.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The offset of the particle emitter from the attached entity or position.
</td></tr>
<tr><td>
[opacityEnd](./server.particleemitter.opacityend.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The opacity of an emitted particle at the end of its lifetime.
</td></tr>
<tr><td>
[opacityEndVariance](./server.particleemitter.opacityendvariance.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The opacity variance of an emitted particle at the end of its lifetime.
</td></tr>
<tr><td>
[opacityStart](./server.particleemitter.opacitystart.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The opacity of an emitted particle at the start of its lifetime.
</td></tr>
<tr><td>
[opacityStartVariance](./server.particleemitter.opacitystartvariance.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The opacity variance of an emitted particle at the start of its lifetime.
</td></tr>
<tr><td>
[position](./server.particleemitter.position.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The position of the particle emitter in the world if explicitly set.
</td></tr>
<tr><td>
[positionVariance](./server.particleemitter.positionvariance.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The position variance of an emitted particle.
</td></tr>
<tr><td>
[rate](./server.particleemitter.rate.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The rate per second at which particles are emitted.
</td></tr>
<tr><td>
[rateVariance](./server.particleemitter.ratevariance.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The rate per second variance of the particle emission rate.
</td></tr>
<tr><td>
[size](./server.particleemitter.size.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The size of an emitted particle.
</td></tr>
<tr><td>
[sizeVariance](./server.particleemitter.sizevariance.md)
</td><td>
`readonly`
</td><td>
number \| undefined
</td><td>
The size variance of an emitted particle.
</td></tr>
<tr><td>
[textureUri](./server.particleemitter.textureuri.md)
</td><td>
`readonly`
</td><td>
string
</td><td>
The URI or path to the texture to be used for the particles.
</td></tr>
<tr><td>
[transparent](./server.particleemitter.transparent.md)
</td><td>
`readonly`
</td><td>
boolean \| undefined
</td><td>
Whether an emitted particle is transparent, resulting in smoother transparency blending.
</td></tr>
<tr><td>
[velocity](./server.particleemitter.velocity.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The velocity of an emitted particle.
</td></tr>
<tr><td>
[velocityVariance](./server.particleemitter.velocityvariance.md)
</td><td>
`readonly`
</td><td>
[Vector3Like](./server.vector3like.md) \| undefined
</td><td>
The velocity variance of an emitted particle.
</td></tr>
<tr><td>
[world](./server.particleemitter.world.md)
</td><td>
`readonly`
</td><td>
[World](./server.world.md) \| undefined
</td><td>
The world the ParticleEmitter is in.
</td></tr>
</tbody></table>
## Methods
<table><thead><tr><th>
Method
</th><th>
Modifiers
</th><th>
Description
</th></tr></thead>
<tbody><tr><td>
[despawn()](./server.particleemitter.despawn.md)
</td><td>
</td><td>
Despawns the ParticleEmitter from the world.
</td></tr>
<tr><td>
[restart()](./server.particleemitter.restart.md)
</td><td>
</td><td>
Restarts the particle emission if it was previously stopped. Internally, this sets the rate to the value it was before being stopped.
</td></tr>
<tr><td>
[setAlphaTest(alphaTest)](./server.particleemitter.setalphatest.md)
</td><td>
</td><td>
Sets the alpha test value, discards particle texture pixels with alpha opacity less than this value.
</td></tr>
<tr><td>
[setAttachedToEntity(entity)](./server.particleemitter.setattachedtoentity.md)
</td><td>
</td><td>
Sets the entity to which the ParticleEmitter is attached.
</td></tr>
<tr><td>
[setAttachedToEntityNodeName(attachedToEntityNodeName)](./server.particleemitter.setattachedtoentitynodename.md)
</td><td>
</td><td>
Sets the name of the node of the attached entity (if the attached entity is a model entity) to attach the particle emitter to.
</td></tr>
<tr><td>
[setColorEnd(colorEnd)](./server.particleemitter.setcolorend.md)
</td><td>
</td><td>
Sets the color of an emitted particle at the end of its lifetime.
</td></tr>
<tr><td>
[setColorEndVariance(colorEndVariance)](./server.particleemitter.setcolorendvariance.md)
</td><td>
</td><td>
Sets the color variance of an emitted particle at the end of its lifetime.
</td></tr>
<tr><td>
[setColorStart(colorStart)](./server.particleemitter.setcolorstart.md)
</td><td>
</td><td>
Sets the color of an emitted particle at the start of its lifetime.
</td></tr>
<tr><td>
[setColorStartVariance(colorStartVariance)](./server.particleemitter.setcolorstartvariance.md)
</td><td>
</td><td>
Sets the color variance of an emitted particle at the start of its lifetime.
</td></tr>
<tr><td>
[setGravity(gravity)](./server.particleemitter.setgravity.md)
</td><td>
</td><td>
Sets the gravity vector for an emitted particle.
</td></tr>
<tr><td>
[setLifetime(lifetime)](./server.particleemitter.setlifetime.md)
</td><td>
</td><td>
Sets the lifetime of an emitted particle in seconds.
</td></tr>
<tr><td>
[setLifetimeVariance(lifetimeVariance)](./server.particleemitter.setlifetimevariance.md)
</td><td>
</td><td>
Sets the lifetime variance of an emitted particle in seconds.
</td></tr>
<tr><td>
[setMaxParticles(maxParticles)](./server.particleemitter.setmaxparticles.md)
</td><td>
</td><td>
Sets the maximum number of live particles.
</td></tr>
<tr><td>
[setOffset(offset)](./server.particleemitter.setoffset.md)
</td><td>
</td><td>
Sets the offset of the particle emitter from the attached entity or position.
</td></tr>
<tr><td>
[setOpacityEnd(opacityEnd)](./server.particleemitter.setopacityend.md)
</td><td>
</td><td>
Sets the opacity of an emitted particle at the end of its lifetime.
</td></tr>
<tr><td>
[setOpacityEndVariance(opacityEndVariance)](./server.particleemitter.setopacityendvariance.md)
</td><td>
</td><td>
Sets the opacity variance of an emitted particle at the end of its lifetime.
</td></tr>
<tr><td>
[setOpacityStart(opacityStart)](./server.particleemitter.setopacitystart.md)
</td><td>
</td><td>
Sets the opacity of an emitted particle at the start of its lifetime.
</td></tr>
<tr><td>
[setOpacityStartVariance(opacityStartVariance)](./server.particleemitter.setopacitystartvariance.md)
</td><td>
</td><td>
Sets the opacity variance of an emitted particle at the start of its lifetime.
</td></tr>
<tr><td>
[setPosition(position)](./server.particleemitter.setposition.md)
</td><td>
</td><td>
Sets the position of the particle emitter.
</td></tr>
<tr><td>
[setPositionVariance(positionVariance)](./server.particleemitter.setpositionvariance.md)
</td><td>
</td><td>
Sets the position variance of an emitted particle.
</td></tr>
<tr><td>
[setRate(rate)](./server.particleemitter.setrate.md)
</td><td>
</td><td>
Sets the rate per second at which particles are emitted.
</td></tr>
<tr><td>
[setRateVariance(rateVariance)](./server.particleemitter.setratevariance.md)
</td><td>
</td><td>
Sets the rate variance of the particle emission rate.
</td></tr>
<tr><td>
[setSize(size)](./server.particleemitter.setsize.md)
</td><td>
</td><td>
Sets the size of an emitted particle.
</td></tr>
<tr><td>
[setSizeVariance(sizeVariance)](./server.particleemitter.setsizevariance.md)
</td><td>
</td><td>
Sets the size variance of an emitted particle.
</td></tr>
<tr><td>
[setTextureUri(textureUri)](./server.particleemitter.settextureuri.md)
</td><td>
</td><td>
Sets the texture URI of the particles emitted.
</td></tr>
<tr><td>
[setTransparent(transparent)](./server.particleemitter.settransparent.md)
</td><td>
</td><td>
Sets the transparency of the particle emitter.
</td></tr>
<tr><td>
[setVelocity(velocity)](./server.particleemitter.setvelocity.md)
</td><td>
</td><td>
Sets the velocity of an emitted particle.
</td></tr>
<tr><td>
[setVelocityVariance(velocityVariance)](./server.particleemitter.setvelocityvariance.md)
</td><td>
</td><td>
Sets the velocity variance of an emitted particle.
</td></tr>
<tr><td>
[spawn(world)](./server.particleemitter.spawn.md)
</td><td>
</td><td>
Spawns the ParticleEmitter in the world.
</td></tr>
<tr><td>
[stop()](./server.particleemitter.stop.md)
</td><td>
</td><td>
Stops the particle emission if it was previously started. Internally, this sets the rate to 0.
</td></tr>
</tbody></table>