Particlize

PropertyManager

Manages particle properties, Frame Buffer Objects (FBOs), and constraints

Constructor

This class is automatically instantiated by the ParticleSystem class as manager and usually is not to be created directly unless you are implementing custom systems or need to manage properties independently.

import { PropertyManager, PropertyManagerParams } from 'particlize-js';
new PropertyManager(params: PropertyManagerParams)

Parameters

ParameterTypeDescriptionDefault
rendererTHREE.WebGLRendererWebGL renderer instance used for FBO operations-
widthnumberWidth of the Frame Buffer Objects in pixels512
heightnumberHeight of the Frame Buffer Objects in pixels512

Properties

PropertyTypeDescription
uuidstringUnique identifier for the property manager
propertiesMap<string, Property>Map of all managed properties
fbosMap<string, FBO>Map of all Frame Buffer Objects
rendererTHREE.WebGLRendererWebGL renderer instance
widthnumberFBO width
heightnumberFBO height
sceneTHREE.SceneThree.js scene for FBO rendering
cameraTHREE.OrthographicCameraOrthographic camera for FBO rendering

Methods

add(name: string, options?: PropertyOptions): Property

Adds a new property to the manager.

get(name: string): Property | undefined

Retrieves a property by name.

update(propertyNames?: string[]): void

Updates FBOs. If no property names are provided, updates all FBOs.

setUniformsAll(uniforms: Record<string, any>): void

Sets uniforms on all FBOs.

addConstraint(propertyName: string, constraint: Constraint): void

Adds a constraint to a specific property.

removeConstraint(propertyName: string, constraintName: string): void

Removes a constraint from a property.

dispose(): void

Disposes of all resources managed by the PropertyManager.

Example Usage

import { PropertyManager, RadialForce } from 'particlize';
import * as THREE from 'three';

// Create property manager
const renderer = new THREE.WebGLRenderer();
const manager = new PropertyManager({
  renderer,
  width: 512,
  height: 512
});

// Add properties
manager.addProperty('position', {
  size: 3,
  defaultValue: new Float32Array([0, 0, 0])
});

manager.addProperty('velocity', {
  size: 3,
  defaultValue: new Float32Array([0, 0, 0])
});

// Add constraints
const radialForce = new RadialForce({
  center: [0, 0, 0],
  strength: 0.1
});
manager.addConstraint('velocity', radialForce);

// Inject initial data
const particleCount = 1000;
const positionData = new Float32Array(particleCount * 4);
// ... fill position data ...

manager.inject('position', positionData);

// Update in animation loop
function animate() {
  manager.setUniformsAll({
    u_time: performance.now() / 1000
  });
  
  manager.update();
  requestAnimationFrame(animate);
}
animate();