Skip to content

ImageLayer ​

A layer that renders a 2D slice of a chunked multi-channel image source.

Image layer streams chunks from a source such as OmeZarrImageSource according to its streaming policy, which decides which resolution levels and chunks to load for the current view. Per-channel appearance is controlled with ChannelProps and the visible slice is selected with SliceCoordinates. The layer holds sliceCoords by reference, so mutating the object it was constructed with moves through the data.

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

const layer = new ImageLayer({
  source,
  sliceCoords: { t: 0, z: 0, c: [0, 1] },
  channelProps: [
    { color: Color.GREEN, contrastLimits: [0, 1024] },
    { color: Color.MAGENTA, contrastLimits: [0, 1024] },
  ],
});

viewport.addLayer(layer);

Extends Layer and inherits all public properties and methods.

Constructor ​

Creates an image layer for the given source and slice.

ts
new ImageLayer(props): ImageLayer;
ParameterDescription
props: ImageLayerPropsInitialization properties.

Types ​

ImageLayerProps ​

Initialization properties for constructing an image layer.

PropertyDescription
source: ChunkSourceThe chunked image source to stream from.
sliceCoords: SliceCoordinatesThe slice to display in world units.
policy?: ImageSourcePolicyStreaming policy. Defaults to the exploration policy.
orientation?: SliceOrientationSlice plane orientation. Defaults to "XY".
channelProps?: ChannelProps[]Per-channel appearance. Length must match the source.
onPickValue?: (info) => voidCalled with the picked value when the layer is clicked.
opacity?: numberLayer opacity in [0, 1]. Defaults to 1.
blendMode?: BlendModeHow the layer blends. Defaults to "additive".
occludes?: booleanHides content behind. Defaults to true.

Properties ​

type overrides ​

Identifies the layer type as ImageLayer.

ts
readonly type: "ImageLayer" = "ImageLayer";

Accessors ​

orientation SliceOrientation ​

The slice plane the layer displays.

ts
get orientation(): SliceOrientation;

lastPresentationTimeCoord number | undefined ​

The t coordinate of the most recently presented slice.

ts
get lastPresentationTimeCoord(): number | undefined;

sliceCoords SliceCoordinates ​

The slice coordinates the layer displays. This is the object passed at construction and may be mutated to move through the data.

ts
get sliceCoords(): SliceCoordinates;

source ChunkSource ​

The chunked image source the layer streams from.

ts
get source(): ChunkSource;

imageSourcePolicy Readonly<ImageSourcePolicy> ​

The streaming policy in effect. Assign a new policy to reschedule loading at runtime, for example when switching between exploration and playback.

ts
get imageSourcePolicy(): Readonly<ImageSourcePolicy>;
ts
set imageSourcePolicy(newPolicy): void;
ParameterDescription
newPolicy: ImageSourcePolicyThe policy to apply.

debugMode boolean ​

Whether chunk wireframes are drawn colored by level of detail.

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

channelProps ChannelProps[] | undefined ​

The current per-channel appearance settings.

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

Methods ​

update() void overrides ​

Streams chunks for the current view and refreshes the visible slice.

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

setOrientation() void ​

Changes the slice orientation at runtime. Visible renderables are rebuilt for the new plane and chunks already resident in the shared cache are reused.

ts
setOrientation(orientation): void;
ParameterDescription
orientation: SliceOrientationThe new slice plane.

onEvent() void overrides ​

Handles click picking for onPickValue. Called automatically for each pointer event.

ts
onEvent(event): void;
ParameterDescription
event: EventContextThe event with clip and world coordinates attached.

getValueAtWorld() Promise<number | null> ​

Reads the data value at a world position from the resident chunks. Prefers the current level of detail and falls back to other resident levels.

ts
getValueAtWorld(world): Promise<number | null>;
ParameterDescription
world: vec3The world-space position to sample.

setChannelProps() void ​

Applies new per-channel appearance settings to all visible chunks 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.

Released under the MIT License