Skip to content

Layer

Abstract base class for everything that can be added to a viewport.

A Layer owns a set of renderable objects and contributes them to the scene each frame. Subclasses (e.g. ImageLayer, VolumeLayer, LabelLayer) implement Layer.update to build or refresh those objects for the current view, and may override the attach/detach hooks to acquire and release resources when the layer joins or leaves a viewport.

Layers carry shared presentation state — Layer.opacity and blend mode — and expose a lifecycle LayerState (initializedloadingready) that observers can subscribe to. A layer instance may be attached to only one viewport at a time.

Extended by

Constructor

ts
new Layer(__namedParameters?): Layer;
ParameterType
__namedParametersLayerProps

Types

LayerState

ts
type LayerState = "initialized" | "loading" | "ready";

Properties

type

ts
abstract readonly type: string;

blendMode

ts
blendMode: BlendMode;

Accessors

opacity number

ts
get opacity(): number;
ts
set opacity(value): void;
ParameterType
valuenumber

coverageGroups ReadonlyMap<number | null, readonly RenderableObject[]>

ts
get coverageGroups(): ReadonlyMap<number | null, readonly RenderableObject[]>;

state LayerState

ts
get state(): LayerState;

Methods

update() void

ts
abstract update(viewport?): void;
ParameterType
viewport?Viewport

onEvent() void

ts
onEvent(_): void;
ParameterType
_EventContext

onAttached() void

ts
onAttached(context): void;
ParameterType
contextIdetikContext

onDetached() void

ts
onDetached(context): void;
ParameterType
contextIdetikContext

attach() void

ts
protected attach(_context): void;
ParameterType
_contextIdetikContext

detach() void

ts
protected detach(_context): void;
ParameterType
_contextIdetikContext

addStateChangeCallback() void

ts
addStateChangeCallback(callback): void;
ParameterType
callbackStateChangeCallback

removeStateChangeCallback() void

ts
removeStateChangeCallback(callback): void;
ParameterType
callbackStateChangeCallback

setState() void

ts
protected setState(newState): void;
ParameterType
newStateLayerState

addObject() void

ts
protected addObject(object, coverageGroup?): void;
ParameterTypeDefault value
objectRenderableObjectundefined
coverageGroupnumber | nullnull

clearObjects() void

ts
protected clearObjects(): void;

getUniforms() Record<string, unknown>

Get uniforms for shader program. Override in derived classes that need custom uniforms.

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

Released under the MIT License