Phenomenon is written in TypeScript and exports several interfaces for type-safe usage. This page documents all available types.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/vaneenige/phenomenon/llms.txt
Use this file to discover all available pages before exploring further.
RendererProps
Configuration options for creating a Renderer instance.The canvas element to render to. Defaults to
document.querySelector('canvas').WebGL context attributes passed to
canvas.getContext(). Common attributes include alpha, antialias, depth, stencil, etc.WebGL context type. Defaults to
'experimental-webgl'. Use 'webgl' or 'webgl2' for other contexts.Additional renderer settings including
devicePixelRatio, clearColor, position, clip, onSetup, and onRender.Enable shader compilation error logging. Defaults to
false.InstanceProps
Configuration options for creating a particle instance viarenderer.add().
Custom vertex attributes for per-particle data. See AttributeProps.
GLSL vertex shader source code.
GLSL fragment shader source code.
Base geometry for each particle. See GeometryProps.
WebGL drawing mode.
0 for POINTS, 4 for TRIANGLES, etc. Defaults to 0.Functions that modify attribute values. Keys are attribute names, values are modifier functions.
Number of times to repeat the geometry (i.e., number of particles). Defaults to
1.Shader uniforms. Defaults to an empty object if not provided. See UniformProps.
Optional callback invoked after each frame. Use this to update uniforms or perform instance-specific calculations.
AttributeProps
Defines a custom vertex attribute.Attribute name as used in the vertex shader (e.g.,
aOffset, aVelocity).Number of components per attribute. Use
1 for float, 2 for vec2, 3 for vec3, 4 for vec4.Optional function that returns attribute data for each particle. Called once per particle with the particle index and total count.
Usage
UniformProps
Defines a shader uniform.Uniform type. Supported types:
'float', 'vec2', 'vec3', 'vec4', 'mat2', 'mat3', 'mat4'.Uniform value as an array of numbers. Length must match the type (1 for float, 2 for vec2, 3 for vec3, etc.).
WebGL uniform location. This is set automatically by Phenomenon—you don’t need to provide it.
Usage
GeometryProps
Defines the base geometry for particles.Array of vertex positions. Each object must have
x, y, and z properties. If provided, an aPosition attribute is automatically created.Array of vertex normals. Each object must have
x, y, and z properties. If provided, an aNormal attribute is automatically created.Usage
BufferProps
Internal type representing a WebGL buffer. You typically don’t create these directly.The attribute location in the shader program.
The WebGL buffer object.
Number of components per vertex (1, 2, 3, or 4).