import type Container from "../renderable/container.js"; import type ParticleEmitter from "./emitter.ts"; /** * Configuration shape for {@link ParticleEmitter}. * Every field has a sensible default; users typically pass a `Partial` * to the constructor or {@link ParticleEmitter#reset}. * @category Particles * @see {@link ParticleEmitter} */ export interface ParticleEmitterSettings { /** * Width of the particle spawn area. * @default 1 */ width: number; /** * Height of the particle spawn area. * @default 1 */ height: number; /** * Image used for particles texture (by default melonJS will create a white * 8x8 texture image). * @default undefined * @see {@link textureSize} */ image: HTMLCanvasElement | HTMLImageElement | undefined; /** * Default texture size used for particles if no image is specified * (by default melonJS will create a white 8x8 texture image). * @default 8 * @see {@link image} */ textureSize: number; /** * Tint to be applied to particles. * @default "#fff" */ tint: string; /** * Total number of particles in the emitter. * @default 50 */ totalParticles: number; /** * Start angle for particle launch in Radians. * @default Math.PI / 2 */ angle: number; /** * Variation in the start angle for particle launch in Radians. * @default 0 */ angleVariation: number; /** * Minimum time each particle lives once it is emitted in ms. * If greater than `maxLife`, it is clamped to `maxLife` at reset. * @default 1000 */ minLife: number; /** * Maximum time each particle lives once it is emitted in ms. * @default 3000 */ maxLife: number; /** * Start speed of particles. * @default 2 */ speed: number; /** * Variation in the start speed of particles. * @default 1 */ speedVariation: number; /** * Minimum start rotation for particle sprites in Radians. * @default 0 */ minRotation: number; /** * Maximum start rotation for particle sprites in Radians. * @default 0 */ maxRotation: number; /** * Minimum start scale ratio for particles (1 = no scaling). * @default 1 */ minStartScale: number; /** * Maximum start scale ratio for particles (1 = no scaling). * @default 1 */ maxStartScale: number; /** * Minimum end scale ratio for particles. * @default 0 */ minEndScale: number; /** * Maximum end scale ratio for particles. * @default 0 */ maxEndScale: number; /** * Vertical force (Gravity) for each particle. * @default 0 * @see {@link World.gravity} */ gravity: number; /** * Horizontal force (like a Wind) for each particle. * @default 0 */ wind: number; /** * Update the rotation of particle in accordance with the particle trajectory. * The particle sprite should aim at zero angle (draw from left to right). * Overrides the particle `minRotation` and `maxRotation`. * @default false */ followTrajectory: boolean; /** * Enable the Texture Additive by composite operation ("additive" blendMode). * @default false * @see {@link blendMode} */ textureAdditive: boolean; /** * Blend mode applied when rendering particles. If different than "normal", * supersedes the `textureAdditive` setting. * * Each particle copies this when it is BORN, so changing it here affects * particles emitted from that point on. To change the mode of particles * already alive as well, assign {@link ParticleEmitter#blendMode} instead — * it updates this setting and every live particle together. * @default "normal" * @see {@link CanvasRenderer#setBlendMode} for the full list of modes */ blendMode: string; /** * Only repaint particles while they are inside the viewport (off-screen * particles keep simulating and living out their lifetime, but do not * mark the scene dirty). * @default true */ onlyInViewport: boolean; /** * Render particles in screen space. * @default false */ floating: boolean; /** * What a particle's position is measured against. * * A particle stores a position, and this decides what that position is * relative to. The difference is whether an effect is *attached* to the * emitter or *emitted and abandoned* by it. * * | value | measured from | use | * | --- | --- | --- | * | `"local"` | the emitter | a flame, an aura, anything welded on | * | `"world"` | the container the emitter sits in | trails, smoke, exhaust, dust | * | a {@link Container} | that container | a moving frame of reference | * * With `"local"` a moving emitter drags its whole cloud along, because a * particle's stored position never named a place in the level — it meant * "this far from my emitter". With `"world"` the position is a place, so * the emitter moves away and leaves the particles behind; only newly * emitted ones appear at the new location. Passing a `Container` measures * from that instead, for the case where the right frame is neither: snow * drifting inside a moving carriage travels with the carriage without * being welded to the vent that emits it. * * `"world"` resolves to the emitter's parent container rather than the * root, so a level that moves carries its own trails with it. Pass the * container explicitly if you want a different one. * * Changing this at runtime re-bases the particles already alive, so * nothing jumps — only their subsequent motion differs. * @default "local" * @example * // exhaust that stays where it was emitted * const emitter = new ParticleEmitter(x, y, { referenceSpace: "world" }); */ referenceSpace: "local" | "world" | Container; /** * Maximum number of particles launched each tick (stream mode only). * @default 10 */ maxParticles: number; /** * How often a particle is emitted in ms (stream mode only). * @default 100 */ frequency: number; /** * Duration that the emitter releases particles in ms (stream mode only). * After this period, the emitter stops launching particles. * @default Infinity */ duration: number; /** * Skip n frames after updating the particle system once. * Reduces the performance impact of emitters with many particles. * @default 0 */ framesToSkip: number; /** * No longer has any effect, and kept only so existing configurations keep * working. * * It used to trade hitbox accuracy for speed, because bounds were * recomputed eagerly on every position write — twice per particle per * frame, from a transform that had not been rebuilt yet. Particles now * invalidate on write and recompute once on read, so the bounds a reader * gets are always current. * @default false * @deprecated since 20.2.0 — bounds are always up to date; remove it */ accurateBounds: boolean; /** * When `true`, the emitter automatically removes itself from its parent * container once all particles have died. Useful for fire-and-forget * `burstParticles()` use cases (explosions, pickups, impact effects) where * there is no natural cleanup hook. * @default false */ autoDestroyOnComplete: boolean; /** * Optional callback fired when the emitter completes (all particles dead * after at least one particle has been spawned, and — for stream mode — * the duration has elapsed). Fires regardless of `autoDestroyOnComplete`, * and runs *before* the emitter is removed from its parent. The callback * is invoked with the emitter as its `this` context. * @default undefined */ onComplete: ((this: ParticleEmitter) => void) | undefined; } /** * Default values for every {@link ParticleEmitterSettings} field. * @category Particles */ declare const defaultParticleEmitterSettings: ParticleEmitterSettings; export default defaultParticleEmitterSettings; //# sourceMappingURL=settings.d.ts.map