Skip to content

VolumeLayer ​

A layer that renders a chunked multi-channel image source as a 3D volume.

Volume layer ray marches the loaded chunks with premultiplied blending and composites all visible channels in a single pass. The volume renders at a single level of detail taken from the policy's lod.min, so pin one with the policy when constructing the layer. While the camera moves the ray march step size is doubled to keep interaction responsive.

ts
const source = await OmeZarrImageSource.fromHttp({ url });

const layer = new VolumeLayer({
  source,
  sliceCoords: { t: 0, c: undefined },
  policy: createExplorationPolicy({ lod: { min: 2, max: 2 } }),
  channelProps: [
    { color: "#00ffff", contrastLimits: [300, 1500] },
    { color: "#ff00ff", contrastLimits: [75, 500] },
  ],
});

viewport.addLayer(layer);

Extends Layer and inherits all public properties and methods.

Constructor ​

Creates a volume layer for the given source.

ts
new VolumeLayer(props): VolumeLayer;
ParameterDescription
props: VolumeLayerPropsInitialization properties.

Types ​

VolumeLayerProps ​

Initialization properties for constructing a volume layer.

PropertyDescription
source: ChunkSourceThe chunked image source to stream from.
sliceCoords: SliceCoordinatesSelects t and c. Spatial axes are ignored.
policy?: ImageSourcePolicyStreaming policy. Defaults to the exploration policy.
channelProps?: ChannelProps[]Per-channel appearance. Length must match the source.

Properties ​

type overrides ​

Identifies the layer type as VolumeLayer.

ts
readonly type: "VolumeLayer" = "VolumeLayer";

debugShowDegenerateRays ​

Highlights rays of zero length for debugging. Defaults to false.

ts
debugShowDegenerateRays: boolean = false;

relativeStepSize ​

Ray march step size relative to voxel size. Defaults to 1.

ts
relativeStepSize: number = 1.0;

opacityMultiplier ​

Scales sample opacity during compositing. Defaults to 1.

ts
opacityMultiplier: number = 1.0;

earlyTerminationAlpha ​

Alpha where a ray stops early. Defaults to 0.99.

ts
earlyTerminationAlpha: number = 0.99;

requiresSceneDepth_ overrides ​

Volume ray marching reads scene depth to composite with occluding layers.

ts
protected requiresSceneDepth_: boolean = true;

Accessors ​

debugShowWireframes boolean ​

Whether chunk bounding wireframes are drawn for debugging.

ts
get debugShowWireframes(): boolean;
ts
set debugShowWireframes(value): void;
ParameterDescription
value: booleanWhether to draw chunk wireframes.

imageSourcePolicy ​

Sets the streaming policy at runtime and reschedules loading. The volume renders the level of detail given by the policy's lod.min.

ts
set imageSourcePolicy(newPolicy): void;
ParameterDescription
newPolicy: ImageSourcePolicyThe policy to apply.

channelProps ChannelProps[] | undefined ​

The current per-channel appearance settings.

ts
get channelProps(): ChannelProps[] | undefined;

Methods ​

setChannelProps() void ​

Applies new per-channel appearance settings to all visible volumes and notifies channel change callbacks.

ts
setChannelProps(channelProps): void;
ParameterDescription
channelProps: ChannelProps[]One entry per source channel.

resetChannelProps() void ​

Restores the channel settings passed at construction.

ts
resetChannelProps(): void;

addChannelChangeCallback() void ​

Registers a callback invoked after every channel settings change.

ts
addChannelChangeCallback(callback): void;
ParameterDescription
callback: () => voidThe callback to add.

removeChannelChangeCallback() void ​

Removes a previously registered channel change callback.

ts
removeChannelChangeCallback(callback): void;
ParameterDescription
callback: () => voidThe callback to remove.

update() void overrides ​

Streams chunks for the current view and rebuilds the volume set sorted front to back. Called automatically once per frame.

ts
update(viewport?): void;
ParameterDescription
viewport?: ViewportThe viewport being rendered.

getUniforms() Record<string, unknown> overrides ​

Returns the ray marching uniforms for this layer.

ts
getUniforms(): Record<string, unknown>;

Released under the MIT License