Skip to content

LoadingPolicies ​

Factory functions for creating chunk loading policies.

A loading policy controls how layers load image data: how far to prefetch beyond the visible region, the order in which chunk requests are served, and which levels of detail can load. Every image, label, and volume layer takes an optional policy at construction and defaults to an exploration policy.

ts
const layer = new ImageLayer({
  source,
  sliceCoords: { z: 0, t: 0, c: undefined },
  policy: createPlaybackPolicy(),
});

Types ​

PriorityCategory ​

A category of chunk request ordered by a loading policy.

ts
type PriorityCategory = 
  | "fallbackVisible"
  | "prefetchTime"
  | "visibleCurrent"
  | "fallbackBackground"
  | "prefetchSpace";

ImageSourcePolicy ​

A resolved and frozen loading policy consumed by layers.

Create instances with createExplorationPolicy, createPlaybackPolicy, createNoPrefetchPolicy, or createImageSourcePolicy rather than by hand.

ts
type ImageSourcePolicy = Readonly<{
  profile: string;
  prefetch: {
     x: number;
     y: number;
     z: number;
     t: number;
  };
  priorityOrder: readonly PriorityCategory[];
  priorityMap: Readonly<Record<PriorityCategory, number>>;
  lod: {
     min: number;
     max: number;
     bias: number;
  };
}>;

Functions ​

createExplorationPolicy() ImageSourcePolicy ​

Creates a loading policy tuned for interactively browsing a scene.

Prefetches one chunk beyond the view along each spatial axis and fills the visible region before prefetching. This is the default policy for layers constructed without one.

ts
function createExplorationPolicy(overrides?): ImageSourcePolicy;
ParameterDescription
overrides: Partial<ImageSourcePolicyProps>Properties merged over. Defaults to {}.

createPlaybackPolicy() ImageSourcePolicy ​

Creates a loading policy tuned for playing through timepoints.

Prefetches twenty timepoints ahead, buffering at the current LOD for smooth playback without reduced quality.

ts
function createPlaybackPolicy(overrides?): ImageSourcePolicy;
ParameterDescription
overrides: Partial<ImageSourcePolicyProps>Properties merged over. Defaults to {}.

createNoPrefetchPolicy() ImageSourcePolicy ​

Creates a loading policy with spatial and temporal prefetching disabled.

No spatial or temporal prefetching happens, which minimizes memory use and network traffic for static scenes.

ts
function createNoPrefetchPolicy(overrides?): ImageSourcePolicy;
ParameterDescription
overrides: Partial<ImageSourcePolicyProps>Properties merged over. Defaults to {}.

createImageSourcePolicy() ImageSourcePolicy ​

Creates a loading policy from explicit properties, validating and freezing them. Prefer the profile factories for common cases and use this to build a policy from scratch.

ts
function createImageSourcePolicy(config): ImageSourcePolicy;
ParameterDescription
config: ImageSourcePolicyPropsInitialization properties.

Released under the MIT License