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.
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.
new ImageLayer(props): ImageLayer;| Parameter | Description |
|---|---|
props: ImageLayerProps | Initialization properties. |
Types
ImageLayerProps
Initialization properties for constructing an image layer.
| Property | Description |
|---|---|
source: ChunkSource | The chunked image source to stream from. |
sliceCoords: SliceCoordinates | The slice to display in world units. |
policy?: ImageSourcePolicy | Streaming policy. Defaults to the exploration policy. |
orientation?: SliceOrientation | Slice plane orientation. Defaults to "XY". |
channelProps?: ChannelProps[] | Per-channel appearance. Length must match the source. |
onPickValue?: (info) => void | Called with the picked value when the layer is clicked. |
opacity?: number | Layer opacity in [0, 1]. Defaults to 1. |
blendMode?: BlendMode | How the layer blends. Defaults to "additive". |
occludes?: boolean | Hides content behind. Defaults to true. |
Properties
type overrides
Identifies the layer type as ImageLayer.
readonly type: "ImageLayer" = "ImageLayer";Accessors
orientation SliceOrientation
The slice plane the layer displays.
get orientation(): SliceOrientation;lastPresentationTimeCoord number | undefined
The t coordinate of the most recently presented slice.
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.
get sliceCoords(): SliceCoordinates;source ChunkSource
The chunked image source the layer streams from.
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.
get imageSourcePolicy(): Readonly<ImageSourcePolicy>;set imageSourcePolicy(newPolicy): void;| Parameter | Description |
|---|---|
newPolicy: ImageSourcePolicy | The policy to apply. |
debugMode boolean
Whether chunk wireframes are drawn colored by level of detail.
get debugMode(): boolean;set debugMode(debug): void;| Parameter | Description |
|---|---|
debug: boolean | Whether to draw chunk wireframes. |
channelProps ChannelProps[] | undefined
The current per-channel appearance settings.
get channelProps(): ChannelProps[] | undefined;Methods
update() void overrides
Streams chunks for the current view and refreshes the visible slice.
update(viewport?): void;| Parameter | Description |
|---|---|
viewport?: Viewport | The 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.
setOrientation(orientation): void;| Parameter | Description |
|---|---|
orientation: SliceOrientation | The new slice plane. |
onEvent() void overrides
Handles click picking for onPickValue. Called automatically for each pointer event.
onEvent(event): void;| Parameter | Description |
|---|---|
event: EventContext | The 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.
getValueAtWorld(world): Promise<number | null>;| Parameter | Description |
|---|---|
world: vec3 | The world-space position to sample. |
setChannelProps() void
Applies new per-channel appearance settings to all visible chunks 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. |