party

Programmatic guide for the @cazala/party library: engine setup, modules, particles, and performance across CPU + WebGPU.

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "party" with this command: npx skills add cazala/party/cazala-party-party

Party

Reusable guidance for using the @cazala/party library programmatically: engine setup, runtime selection, particles, modules, and performance constraints across CPU + WebGPU.

When to use this skill

  • You need to instantiate the Party engine in a custom app (not the playground).
  • You want examples for adding particles, configuring modules, or using oscillators.
  • You need performance-safe patterns for WebGPU (avoiding full readbacks).

Quick start (minimal)

import {
  Engine,
  Environment,
  Boundary,
  Collisions,
  Particles,
  Trails,
} from "@cazala/party";

const canvas = document.querySelector("canvas")!;

const forces = [
  new Environment({ gravityStrength: 600, gravityDirection: "down" }),
  new Boundary({ mode: "bounce", restitution: 0.9, friction: 0.1 }),
  new Collisions({ restitution: 0.85 }),
];

const render = [
  new Trails({ trailDecay: 10, trailDiffuse: 4 }),
  new Particles({ colorType: 2, hue: 0.55 }),
];

const engine = new Engine({ canvas, forces, render, runtime: "auto" });

await engine.initialize();
engine.play();

Core concepts

Particle shape

type IParticle = {
  position: { x: number; y: number };
  velocity: { x: number; y: number };
  size: number;
  mass: number;
  color: { r: number; g: number; b: number; a: number }; // 0..1 floats
};
  • Pinned particles: mass < 0
  • Removed particles: mass === 0

Runtime selection

  • "auto" tries WebGPU first, then falls back to CPU on initialize().
  • WebGPU has higher throughput but GPU → CPU readbacks are expensive.

Engine lifecycle

await engine.initialize();
engine.play();   // start loop
engine.pause();  // pause loop
engine.stop();   // cancel loop
engine.destroy(); // clean up

Module system

Modules are typed force or render units:

  • Force: apply acceleration/velocity changes or constraints.
  • Render: draw particles/lines or post-process scene texture.

Each module exposes inputs and helpers, and can be toggled:

const boundary = new Boundary();
boundary.setEnabled(false);
boundary.setRestitution(0.8);

Common tasks

Add particles

for (let i = 0; i < 200; i++) {
  engine.addParticle({
    position: { x: Math.random() * 500, y: Math.random() * 500 },
    velocity: { x: (Math.random() - 0.5) * 6, y: (Math.random() - 0.5) * 6 },
    mass: 1,
    size: 3,
    color: { r: 1, g: 1, b: 1, a: 1 },
  });
}

Bulk set particles

engine.setParticles(particlesArray);

Use the Spawner utility

import { Spawner } from "@cazala/party";

const spawner = new Spawner();
const particles = spawner.initParticles({
  count: 5000,
  shape: "text",
  text: "Party",
  center: { x: 0, y: 0 },
  position: { x: 0, y: 0 },
  align: { horizontal: "center", vertical: "center" },
  textSize: 80,
  size: 3,
  mass: 1,
  colors: ["#ffffff"],
});

engine.setParticles(particles);

Local queries without full readback (WebGPU-safe)

const { particles, truncated } = engine.getParticlesInRadius(
  { x: 0, y: 0 },
  120,
  { maxResults: 200 }
);

Export + import module settings

const settings = engine.export();
engine.import(settings);

Oscillate a module input

engine.addOscillator({
  moduleName: "boundary",
  inputName: "restitution",
  min: 0.4,
  max: 0.95,
  speedHz: 0.2,
});

Performance notes

  • WebGPU getParticles() performs a full GPU → CPU readback; avoid in hot paths.
  • Prefer getParticlesInRadius(...), setParticle(...), or setParticleMass(...).
  • Tune cellSize, maxNeighbors, and constrainIterations for performance.
  • For large scenes, limit processing with setMaxParticles(value).

API quick map

  • Engine: initialize(), play(), pause(), stop(), destroy()
  • View: setSize(w,h), setCamera(x,y), setZoom(z)
  • Particles: addParticle, setParticles, setParticle, setParticleMass, getParticle
  • Queries: getParticlesInRadius, getCount, getFPS
  • Modules: getModule(name), module setters, setEnabled(bool)
  • Serialization: export(), import(settings)
  • Oscillators: addOscillator, removeOscillator, clearOscillators

Sources

  • Core library user guide: docs/user-guide.md

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

Science Sim Author

Generate self-contained interactive science simulations as a single index.html from a SimSpec YAML or JSON. Use when the user asks for physics, chemistry, bi...

Registry SourceRecently Updated
2190Profile unavailable
Automation

Game

The instant game design engine for AI agents. Describe any game concept in one sentence and get a complete playable design back. Board games, card games, par...

Registry SourceRecently Updated
2200Profile unavailable
General

webgpu

No summary provided by upstream source.

Repository SourceNeeds Review
419-cazala
Coding

TypeScript Config Generator

生成专业的 TypeScript 配置,支持严格模式、React、Node.js、Webpack 等多种场景,一键生成最佳实践配置。

Registry SourceRecently Updated
2100Profile unavailable