API reference

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

C

classDataTexture

@codexo/exojs / rendering / stable

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

25
props
14
methods
0
events
Import
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

Constructors1
new(options: DataTextureOptionsConstruction options for DataTexture. & { format: F }): DataTexture<F>
Methods14
addDestroyListener(listener: () => void): this
Register a callback to be invoked just before this texture is destroyed. Useful for backends to release their GPU-side texture objects.
commit(): this
Mark the entire buffer for re-upload on next backend sync. Call after mutating buffer contents to flush changes to the GPU.
commitRect(x: number, y: number, width: number, height: number): this
Mark a sub-region of the buffer dirty for partial upload. More efficient than commit for ring-buffer patterns where only one row or column changes per frame. If a region was already pending, the union is uploaded. Coordinates are pixel-space with origin at the top-left. Bounds are clamped to the texture dimensions; out-of-range rectangles throw.
destroy(): void
removeDestroyListener(listener: () => void): this
Install a compressed payload, replacing any pixel source, and resize to its base level. Pass null to drop it. Bumps version, so backends re-create their GPU texture - a format change cannot be patched into an existing one.
setGenerateMipMap(generateMipMap: boolean): this
setPremultiplyAlpha(premultiplyAlpha: boolean): this
setSize(width: number, height: number): this
updateSource(): this
DataTexture has no external image source. Override the base implementation so Sprite/Mesh texture assignment does not collapse dimensions to 0x0.
Create a solid-colour texture of the given square size (default 1×1). Accepts a Color instance or any CSS colour string; a Color with alpha below 1 is rendered with that alpha. Generalizes the fixed Texture.black/Texture.white helpers.
Properties25
format: F
Hardware-compressed payload this texture uploads instead of a pixel source, or null for the ordinary case. Mutually exclusive with source: installing one clears the other, so a texture is never ambiguous about what it uploads. A handle that arrives empty from the loader can become either, which is what lets an asset variant swap a PNG for a KTX2 file without changing what a caller holds.
destroyed: boolean
true once destroy has run - a destroyed texture must not be bound.
error: Error | null
The error the last load failed with, or null outside 'failed'.
flipY: boolean
generateMipMap: boolean
height: number
loaded: Promise<this>
Promise that settles with this texture once its payload has loaded - resolved immediately for 'ready' textures, rejected with the load error for 'failed' ones. Re-materialized when a failed load is retried, so read it fresh from this getter rather than caching it across load cycles.
Load lifecycle of this texture. Directly constructed textures are 'ready'; deferred handles returned by loader.get('hero.png') / loader.get(Asset.type('texture', src)) start 'loading' and become 'ready' once the payload fills in, or 'failed' (showing the Texture.missing checker) when the load errors.
powerOfTwo: boolean
Whether both dimensions are powers of two. Non-power-of-two textures may have limited wrap-mode support on some hardware.
premultiplyAlpha: boolean
ready: boolean
true exactly when state is 'ready'.
version: number
Monotonically increasing version counter. Incremented by any mutation that requires a GPU re-upload: a source, size, or upload-parameter change. Filter and wrap changes do not bump it - backends resolve sampling state separately, so changing it costs no upload.
width: number
Shared 8×8 magenta/black checkerboard shown in place of assets that failed to load - a visible error beats an invisible hole, in production too. Lazily created; every access returns the same instance.
Source