API reference
Every public class, method, and event in @codexo/exojs. Generated from source.
classDepthTexture
The depth attachment of a render target, bindable as a named texture of a custom MeshMaterial or SpriteMaterial. It is created by the target that opted into depth (`{ depth: true }`), owned by it, resized with it and destroyed with it; there is no way to construct one on its own and no source to upload. The value behind each texel is the window-space depth the last draw with a depth-writing material left there, which is the backend's mapping of the clip-space z that draw's vertex stage produced: nearer geometry is always the smaller value, but the absolute numbers differ between backends because WebGL2 maps NDC `[-1, 1]` onto `[0, 1]` where WebGPU's NDC z already is `[0, 1]`. Compare depths, do not hard-code them. That one slot is the whole of where it fits. It is NOT interchangeable with a colour texture: a drawable's own `texture`, a filter input, and every built-in renderer's texture binding expect a filterable colour format, which on WebGPU makes a depth view there a bind-group validation error rather than a wrong picture. Put it in the material's `textures` map and read it from the custom shader. Sampling constraints, both backends alike: - Fixed sampling state: `nearest` filtering, `clamp-to-edge` wrapping. A depth format is not filterable and the attachment's parameters are set once with the attachment, so setScaleMode and setWrapMode are no-ops here rather than changes that would silently fail to take. - One channel. GLSL reads it as `texture(sampler, uv).r`; WGSL declares the binding as `texture_depth_2d` and reads it as `textureSample(t, s, uv)`, which yields the bare `f32`. Comparison sampling (`sampler_comparison`, `sampler2DShadow`) is not used and not available. - Live. The texture is the attachment itself, not a copy, so sampling it in the same pass that writes it is undefined; sample it in a later pass. - Cleared with the colour attachment, to the far plane. A pass that preserves the target's colour preserves its depth too. Reading one before the owning target has ever been rendered into throws a `RenderError` - there is no attachment to sample yet.
import { DepthTexture } from '@codexo/exojs'The depth attachment of a render target, bindable as a named texture of a custom MeshMaterial or SpriteMaterial.
It is created by the target that opted into depth (`{ depth: true }`), owned by it, resized with it and destroyed with it; there is no way to construct one on its own and no source to upload. The value behind each texel is the window-space depth the last draw with a depth-writing material left there, which is the backend's mapping of the clip-space z that draw's vertex stage produced: nearer geometry is always the smaller value, but the absolute numbers differ between backends because WebGL2 maps NDC `[-1, 1]` onto `[0, 1]` where WebGPU's NDC z already is `[0, 1]`. Compare depths, do not hard-code them.
That one slot is the whole of where it fits. It is NOT interchangeable with a colour texture: a drawable's own `texture`, a filter input, and every built-in renderer's texture binding expect a filterable colour format, which on WebGPU makes a depth view there a bind-group validation error rather than a wrong picture. Put it in the material's `textures` map and read it from the custom shader.
Sampling constraints, both backends alike:
- Fixed sampling state: `nearest` filtering, `clamp-to-edge` wrapping. A depth format is not filterable and the attachment's parameters are set once with the attachment, so setScaleMode and setWrapMode are no-ops here rather than changes that would silently fail to take. - One channel. GLSL reads it as `texture(sampler, uv).r`; WGSL declares the binding as `texture_depth_2d` and reads it as `textureSample(t, s, uv)`, which yields the bare `f32`. Comparison sampling (`sampler_comparison`, `sampler2DShadow`) is not used and not available. - Live. The texture is the attachment itself, not a copy, so sampling it in the same pass that writes it is undefined; sample it in a later pass. - Cleared with the colour attachment, to the far plane. A pass that preserves the target's colour preserves its depth too.
Reading one before the owning target has ever been rendered into throws a `RenderError` - there is no attachment to sample yet.
addDestroyListener(listener: () => void): thisdestroy(): voidremoveDestroyListener(listener: () => void): thissetGenerateMipMap(generateMipMap: boolean): thissetPremultiplyAlpha(premultiplyAlpha: boolean): thissetScaleMode(): thissetSize(width: number, height: number): thissetWrapMode(): 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 (…destroyed: booleanerror: Error | nullflipY: booleangenerateMipMap: booleanheight: numberloaded: Promise<this>powerOfTwo: booleanpremultiplyAlpha: booleanready: booleanversion: numberwidth: number