Skip to content

VolumeRenderable ​

A ray-marched box that draws multi-channel volumetric data.

The renderable draws a unit box and ray marches through 3D chunk textures in the fragment shader. Up to 4 channels blend in a single pass and all loaded channels must share one texture data type. Front faces are culled and depth testing is off by default. VolumeLayer constructs and pools one instance per spatial chunk group, streams chunk textures in with updateVolumeWithChunk, and sizes the box through the transform.

Extends RenderableObject and inherits all public properties and methods.

Constructor ​

Creates an empty volume renderable.

ts
new VolumeRenderable(props?): VolumeRenderable;
ParameterDescription
props: VolumeRenderablePropsInitialization properties. Defaults to {}.

Types ​

VolumeRenderableProps ​

Initialization properties for constructing a volume renderable.

PropertyDescription
channelProps?: ChannelProps[]Channel appearance settings. Defaults to [].

Properties ​

voxelScale ​

World size of a voxel along each axis. Layers set it from the chunk scale so ray march steps account for anisotropic voxels. Defaults to [1, 1, 1].

ts
voxelScale: vec3;

Accessors ​

type string overrides ​

Identifies the renderable type as VolumeRenderable.

ts
get type(): string;

Methods ​

updateVolumeWithChunk() void ​

Loads or refreshes the texture for the chunk's channel. The channel index comes from the chunk and the texture's data type selects the volume shader, so every channel must share one data type. Chunks without a texture are ignored.

ts
updateVolumeWithChunk(chunk): void;
ParameterDescription
chunk: ChunkThe chunk holding the channel texture.

clearLoadedChannels() void ​

Marks all channels as not loaded so they stop rendering until the next chunk update. The textures themselves are kept.

ts
clearLoadedChannels(): void;

reset() void ​

Clears all textures and channel state so the renderable can be pooled and reused for another chunk.

ts
reset(): void;

getUniforms() Record<string, number[] | number> overrides ​

Returns per-channel sampler, color, contrast, opacity, and visibility uniforms for up to 4 loaded channels plus the voxel scale.

ts
getUniforms(): Record<string, number[] | number>;

setChannelProps() void ​

Replaces the appearance settings for all channels.

ts
setChannelProps(channels): void;
ParameterDescription
channels: ChannelProps[]The new channel settings.

setChannelProperty() void ​

Updates one property of the channel at the given index and revalidates it against the channel's texture when available.

ts
setChannelProperty<K>(channelIndex, property, value): void;

Type Parameters ​

Type Parameter
K extends keyof ChannelProps
ParameterDescription
channelIndex: numberThe channel to update.
property: KThe property name to set.
value: Required<ChannelProps>[K]The new value.

Released under the MIT License