Particlize

Particle

Represents an individual particle with custom properties

Constructor

new Particle(properties: { [key: string]: Float32Array })

Parameters

ParameterTypeDescription
properties{ [key: string]: Float32Array }Object containing particle properties as Float32Array values

Properties

PropertyTypeDescription
[key: string]Float32ArrayDynamic properties stored as Float32Array instances

Example Usage

import { Particle, Frame } from 'particlize';

// Create a particle with custom properties
const particle = new Particle({
  position: new Float32Array([0.5, 0.5, 0.5]),
  velocity: new Float32Array([0.1, 0.0, 0.0]),
  color: new Float32Array([1.0, 0.5, 0.0, 1.0]),
  size: new Float32Array([1.0])
});

// Create particles from data
const particles = Array.from({ length: 1000 }, (_, i) => {
  return new Particle({
    position: new Float32Array([
      Math.random() * 2 - 1,
      Math.random() * 2 - 1,
      Math.random() * 2 - 1
    ]),
    velocity: new Float32Array([0, 0, 0]),
    color: new Float32Array([1, 1, 1, 1])
  });
});

// Use particles in a frame
const frame = new Frame({ particles });