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.
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.
new VolumeLayer(props): VolumeLayer;| Parameter | Description |
|---|---|
props: VolumeLayerProps | Initialization properties. |
Types
VolumeLayerProps
Initialization properties for constructing a volume layer.
| Property | Description |
|---|---|
source: ChunkSource | The chunked image source to stream from. |
sliceCoords: SliceCoordinates | Selects t and c. Spatial axes are ignored. |
policy?: ImageSourcePolicy | Streaming 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.
readonly type: "VolumeLayer" = "VolumeLayer";debugShowDegenerateRays
Highlights rays of zero length for debugging. Defaults to false.
debugShowDegenerateRays: boolean = false;relativeStepSize
Ray march step size relative to voxel size. Defaults to 1.
relativeStepSize: number = 1.0;opacityMultiplier
Scales sample opacity during compositing. Defaults to 1.
opacityMultiplier: number = 1.0;earlyTerminationAlpha
Alpha where a ray stops early. Defaults to 0.99.
earlyTerminationAlpha: number = 0.99;requiresSceneDepth_ overrides
Volume ray marching reads scene depth to composite with occluding layers.
protected requiresSceneDepth_: boolean = true;Accessors
debugShowWireframes boolean
Whether chunk bounding wireframes are drawn for debugging.
get debugShowWireframes(): boolean;set debugShowWireframes(value): void;| Parameter | Description |
|---|---|
value: boolean | Whether 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.
set imageSourcePolicy(newPolicy): void;| Parameter | Description |
|---|---|
newPolicy: ImageSourcePolicy | The policy to apply. |
channelProps ChannelProps[] | undefined
The current per-channel appearance settings.
get channelProps(): ChannelProps[] | undefined;Methods
setChannelProps() void
Applies new per-channel appearance settings to all visible volumes and notifies channel change callbacks.
setChannelProps(channelProps): void;| Parameter | Description |
|---|---|
channelProps: ChannelProps[] | One entry per source channel. |
resetChannelProps() void
Restores the channel settings passed at construction.
resetChannelProps(): void;addChannelChangeCallback() void
Registers a callback invoked after every channel settings change.
addChannelChangeCallback(callback): void;| Parameter | Description |
|---|---|
callback: () => void | The callback to add. |
removeChannelChangeCallback() void
Removes a previously registered channel change callback.
removeChannelChangeCallback(callback): void;| Parameter | Description |
|---|---|
callback: () => void | The 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.
update(viewport?): void;| Parameter | Description |
|---|---|
viewport?: Viewport | The viewport being rendered. |
getUniforms() Record<string, unknown> overrides
Returns the ray marching uniforms for this layer.
getUniforms(): Record<string, unknown>;