Particles
Volver a la referencia

Particles

Emitters, their curves over a particle lifetime, and the document they serialize to.

18 símbolos

useParticleCollider2dfunctionhooknacatamalon

useParticleCollider2d(options: { shape, enabled }) => TParticleCollider2d

Makes this object solid to particles in a flat scene: sparks bounce off it and rain ends on it.

The shape is measured on the object, so it moves, turns and stretches with it. It only stops the effects whose file says how they collide; every other effect goes straight through, which is what smoke and glows want.

One per object. A staircase is one object per step, each with its own.

Parámetros

options{ shape, enabled }

The shape, and whether it starts on.

Ejemplo

const Ledge = () => {
    useTransform({ x: 200, y: 300 });
    useParticleCollider2d({ shape: { kind: 'rect', width: 120, height: 16 } });
};
Ver el código · hooks/particles/use_particle_collider.ts:47

useParticleCollider3dfunctionhooknacatamalon

useParticleCollider3d(options: { shape, enabled }) => TParticleCollider3d

Makes this object solid to particles in three dimensions. The same thing as the flat one, with a box, a ball or an endless floor.

Parámetros

options{ shape, enabled }

The shape, and whether it starts on.

Ejemplo

const Step = (y: number, z: number) => {
    useTransform({ y, z });
    createMesh({ geometry: useCubeGeometry() });
    useParticleCollider3d({ shape: { kind: 'box', size: [1, 1, 1] } });
};
Ver el código · hooks/particles/use_particle_collider.ts:73

TEmitShape2dtypenacatamalon

TEmitShape2d: { kind } | { kind, radius, edge } | { kind, width, height } | { kind, length, angle }

Where a particle is born, in the emitter's own space.

Deliberately apart from which way it then moves, which is direction and spread below. A ring of sparks flying outwards and a ring of rain falling straight down are the same birth area with different velocities, and folding the two together makes the second one impossible to say.

Ver el código · loaders/particles/types/t_particles_doc.ts:72

TEmitShape3dtypenacatamalon

TEmitShape3d: { kind } | { kind, radius, edge } | { kind, size } | { kind, radius, angle }

Where a particle is born in three dimensions, in the emitter's own space.

The same split as the flat shapes, position only, with one exception: a cone also aims what it emits, along its own wall, because a cone whose particles ignored it would be a disc.

Ver el código · loaders/particles/types/t_particles_doc.ts:100

TParticleAnimPacetypenacatamalon

TParticleAnimPace: 'life' | 'clip'

How a particle's run of frames is paced.

'life', the default, stretches the run over each particle's own life: a spark that lives half as long plays it twice as fast, and every particle shows the last frame as it dies, which is what an explosion that ends in smoke wants. The run's fps and loop mean nothing there, since a life always ends; a repeat and a yoyo say how many times it goes and which way, counted the way a sprite counts them, and one that goes round for ever plays it once.

'clip' plays it at its own fps, exactly as useSpriteAnimation would, from the moment the particle is born: for a fire that flickers or a coin that spins as it falls. One that does not loop rests on its last frame until the particle dies; a particle that dies first cuts it short.

Neither tells anybody anything: a run's events and next belong to sprites.

Ver el código · loaders/particles/types/t_particles_doc.ts:48

TParticleBlendtypenacatamalon

TParticleBlend: 'alpha' | 'additive'

How a particle is laid over what is already there.

alpha covers, which is what smoke and dust want. additive adds light, which is the only way fire, sparks and anything glowing read as bright: two overlapping embers should be brighter than one, and under alpha they are merely nearer.

Ver el código · loaders/particles/types/t_particles_doc.ts:27

TParticleCollider2dtypenacatamalon

Something solid in a flat scene, as far as particles are concerned.

It belongs to the scene and not to any effect: every effect that says how it collides runs into it. It is placed by the object it is on, so a moving platform takes its collider with it.

Propiedades

type'particle-collider-2d'
idstring
enabledboolean

Whether particles run into it. Turning it off keeps it, ready to turn on again.

Ver el código · gameobjects/particles/colliders/t_particle_collider.ts:42

TParticleColliderShape2dtypenacatamalon

TParticleColliderShape2d: { kind, width, height } | { kind, radius } | { kind }

The shapes a flat collider can take, measured on its object: the object's placement moves, turns and stretches it.

plane is an endless floor along the object's own y = 0, solid below it on screen, which with y growing downwards is the side where y is larger.

Ver el código · gameobjects/particles/colliders/t_particle_collider.ts:12

TParticleColliderShape3dtypenacatamalon

TParticleColliderShape3d: { kind, size } | { kind, radius } | { kind }

The shapes a collider in three dimensions can take, measured on its object.

plane is an endless floor through the object's own origin, solid below it, with +y up. Turn the object and it becomes a slope or a wall.

Ver el código · gameobjects/particles/colliders/t_particle_collider.ts:27

TParticleCollisiontypenacatamalon

What a particle does when it runs into something solid in the scene.

Only how it reacts, never what it runs into: the file is shared by every room that uses the effect, so where the floor is belongs to the scene, which says it with colliders on its objects. Sparks bounce and rain is gone, in any room.

Propiedades

mode'bounce' | 'die'

bounce sends it back off the surface; die ends it there, which is what rain wants.

bouncenumber

How much of its speed into the surface it keeps on the way back, 0 to 1.

frictionnumber

How much of its speed along the surface it loses at each touch, 0 to 1.

Ver el código · loaders/particles/types/t_particles_doc.ts:183

TParticleOverridestypenacatamalon

What a scene may turn up or down about an effect without writing a second file.

The file says what the effect is, and it is shared: three torches are one document. These are the handful of things one of those torches may disagree with it about.

It exists because every game eventually wants "the same explosion, half the size", and making that a second file is what forks an effect into six near-copies nobody can keep in step.

Propiedades

rateScaleopcionalnumber

Multiplies how many come out a second.

sizeScaleopcionalnumber

Multiplies how big they are born.

speedScaleopcionalnumber

Multiplies how fast they set off.

lifeScaleopcionalnumber

Multiplies how long they live.

Ver el código · gameobjects/particles/types/t_particles.ts:18

TParticles3dtypenacatamalon

TParticles3d: Omit<TParticles, 'type' | 'transform' | 'worldTransform'> & { type, transform, worldMatrix }

An emitter in three dimensions: particles in world units, drawn as squares that always face the camera.

Everything but its placement is the flat emitter's, field for field, and means the same thing: the same file on the same terms, the same tint, the same verbs. What it does not share is where it is, which here is a place in space with a turn of three angles, and the answer to where it ended up is a matrix rather than a flat placement, exactly as it is for a model.

Propiedades

type'particles-3d'
transformTTransform3d

Where the emitter is on its box. Particles are born here, turned and scaled by everything above it.

worldMatrixopcionalFloat32Array

Where it ended up once everything above it has moved it, or where it is when nothing does. Set by the engine each frame it is drawn; undefined before its first. Never authored.

Ver el código · gameobjects/particles/types/t_particles_3d.ts:17

nacatamalon/files

TEmissionDoctypenacatamalon/files

When and how many appear.

rate and burst are both here and they mean different things: rate is a fountain, so many a second for as long as it runs, and burst is an explosion, all of them the moment the cycle starts. An effect usually wants one and occasionally wants both, so neither can be said with the other.

Both at zero is a perfectly good effect, not a mistake: it is one that something else fires with emitParticles.

Propiedades

ratenumber

Per second, for as long as the cycle runs. 0 for an effect that only bursts.

burstnumber

How many appear at once when the cycle starts. 0 for one that only pours.

durationnumber

How long one cycle emits for, in seconds. 0 is forever: a torch rather than an explosion. Particles already alive when a cycle ends still live out their own lives.

loopboolean

Start the cycle again when duration runs out. Means nothing when duration is 0.

Ver el código · loaders/particles/types/t_particles_doc.ts:134