API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classTurbulence

@codexo/exojs-particles / particles / stable

Adds a smooth pseudo-random force field that animates over time. Implemented as 2D value noise with cubic Hermite smoothing - sampled twice per particle (offset to decorrelate x and y components) and scaled by `strength`. The field evolves at `timeScale` units per second; lower values produce slow-moving currents, higher values produce buzzy chaos. `frequency` controls the spatial granularity: small values (≈ 0.005) yield broad swirls across the playfield, large values (≈ 0.1) produce tight per-particle jitter. Use cases: smoke turbulence, organic swirls, wind eddies, dust haze. Pair with Drag to keep particle velocities bounded. GPU-eligible. The noise function is identical on CPU and GPU so visual results match across backends (modulo float precision).

3
props
5
methods
0
events
Import
import { Turbulence } from '@codexo/exojs-particles'

Adds a smooth pseudo-random force field that animates over time. Implemented as 2D value noise with cubic Hermite smoothing - sampled twice per particle (offset to decorrelate x and y components) and scaled by `strength`. The field evolves at `timeScale` units per second; lower values produce slow-moving currents, higher values produce buzzy chaos.

`frequency` controls the spatial granularity: small values (≈ 0.005) yield broad swirls across the playfield, large values (≈ 0.1) produce tight per-particle jitter.

Use cases: smoke turbulence, organic swirls, wind eddies, dust haze. Pair with Drag to keep particle velocities bounded.

GPU-eligible. The noise function is identical on CPU and GPU so visual results match across backends (modulo float precision).

Constructors1
new(strength: number, frequency: number, timeScale: number): Turbulence
Methods5
Mutates the live particles for one frame. Runs only on the CPU path: a system whose modules are all GPU-eligible executes wgsl bodies inside its compute shader instead, and never calls this.
destroy(): void
Optional cleanup hook called from ParticleSystem.destroy.
uploadTextures?(device: GPUDevice, textures: ReadonlyMap<string, GPUTexture>): void
Upload texture data (Curve/ColorGradient lookup tables) to the GPU at compile time. Receives the GPUDevice and a map of texture bindings keyed by the name in WgslContribution.textures. Called once after pipeline creation. Required when wgsl declares textures.
Override to declare a GPU contribution. Returning a WgslContribution makes this module GPU-eligible; omitting (or returning undefined) forces CPU mode for any system that uses this module.
writeUniforms(view: DataView, offset: number, dt: number): void
Write this module's current uniform values into the shared uniform buffer at byteOffset. Layout must match the field declarations returned by wgsl (in the same order). Receives the current frame dt (seconds). Modules tracking accumulated time (e.g. noise/turbulence) should advance their internal counter here to stay in sync when running in GPU mode (where apply is not called). Required when wgsl declares uniforms. Called every frame by the system before dispatching compute.
Properties3
frequency: number
strength: number
timeScale: number
Source