API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classDataTexture
A 2D texture whose pixels live in a CPU-side typed array. Mutate the `buffer` directly and call commit to upload the whole array, or commitRect to upload a sub-region (cheaper for ring-buffer patterns like spectrograms). `DataTexture` extends Texture, so any API that accepts a `Texture` (filter uniforms, mesh textures, custom shader uniforms) accepts a `DataTexture` unchanged. # Default sampler `DataTexture` defaults to nearest filtering, clamp-to-edge wrap, no mip generation, and no premultiply. These match the typical "raw data lookup" use case where bilinear filtering would corrupt sampled values (e.g. spectrum bins sampled by index). # Bring-your-own buffer Pass `data` in options to share an external buffer. Useful for: - SharedArrayBuffer + Worker pipelines (audio DSP off the main thread) - Buffer pooling across many small textures - Interop with WebAssembly memory or other APIs that produce typed-array views The buffer reference is fixed for the lifetime of the texture (the `buffer` property is `readonly`); only its contents may be mutated. # Format / buffer correspondence The TypeScript type system narrows `buffer` based on `format`: const r8 = new DataTexture({ width: 256, height: 1, format: TextureFormat.R8 }); r8.buffer // Uint8Array const r32f = new DataTexture({ width: 256, height: 1, format: TextureFormat.R32F }); r32f.buffer // Float32Array
import { DataTexture } from '@codexo/exojs'A 2D texture whose pixels live in a CPU-side typed array. Mutate the `buffer` directly and call commit to upload the whole array, or commitRect to upload a sub-region (cheaper for ring-buffer patterns like spectrograms).
`DataTexture` extends Texture, so any API that accepts a `Texture` (filter uniforms, mesh textures, custom shader uniforms) accepts a `DataTexture` unchanged.
# Default sampler
`DataTexture` defaults to nearest filtering, clamp-to-edge wrap, no mip generation, and no premultiply. These match the typical "raw data lookup" use case where bilinear filtering would corrupt sampled values (e.g. spectrum bins sampled by index).
# Bring-your-own buffer
Pass `data` in options to share an external buffer. Useful for: - SharedArrayBuffer + Worker pipelines (audio DSP off the main thread) - Buffer pooling across many small textures - Interop with WebAssembly memory or other APIs that produce typed-array views
The buffer reference is fixed for the lifetime of the texture (the `buffer` property is `readonly`); only its contents may be mutated.
# Format / buffer correspondence
The TypeScript type system narrows `buffer` based on `format`:
const r8 = new DataTexture({ width: 256, height: 1, format: TextureFormat.R8 }); r8.buffer // Uint8Array
const r32f = new DataTexture({ width: 256, height: 1, format: TextureFormat.R32F }); r32f.buffer // Float32Array
new(options: DataTextureOptionsConstruction options for DataTexture. & { format: F }): DataTexture<F>addDestroyListener(listener: () => void): thiscommit(): thiscommitRect(x: number, y: number, width: number, height: number): thisdestroy(): voidremoveDestroyListener(listener: () => void): thissetGenerateMipMap(generateMipMap: boolean): thissetPremultiplyAlpha(premultiplyAlpha: boolean): thissetSize(width: number, height: number): thisupdateSource(): thisfromColor(color: Color32-bit RGBA color value with channel-wise accessors. Red, green, and blue are integers in 0..255; alpha is a float in 0..1. Out-of-range values are saturated o… | string, size: number): TextureA static GPU texture sourced from an image, canvas, or video element. Holds the pixel source, its sampling state (ScaleModes, WrapModes) and its upload state (…format: Fdestroyed: booleanerror: Error | nullflipY: booleangenerateMipMap: booleanheight: numberloaded: Promise<this>powerOfTwo: booleanpremultiplyAlpha: booleanready: booleanversion: numberwidth: number