npm.io
0.8.0 • Published yesterday

@yagejs/effects

Licence
MIT
Version
0.8.0
Deps
1
Size
1.4 MB
Vulns
0
Weekly
18

@yagejs/effects

Built-in visual-effect presets for YAGE — wraps pixi-filters and the built-in ColorMatrixFilter behind the engine's handle-based .fx.addEffect API.

import { hitFlash, bloom, crt } from "@yagejs/effects";

// Component scope — flashes when the entity takes damage.
const flash = sprite.fx.addEffect(hitFlash({ color: 0xffffff, duration: 100 }));
flash.trigger();

// Layer scope — bloom on the gameplay layer only.
const tree = this.use(SceneRenderTreeKey);
tree.get("world").fx.addEffect(bloom({ threshold: 0.8, bloomScale: 1.4 }));

// Scene scope — CRT scanlines for the whole scene.
tree.fx.addEffect(crt({ scanlines: true }));

Every preset is registered through defineEffect (see @yagejs/renderer), so attached effects survive SaveService snapshot round-trips: their name + options are recorded, and on load the preset's factory is re-invoked to rebuild the filter.

See yage.dev/guides/rendering/effects for the full list and option reference.

Keywords