Skip to content

Class: VariantSurface ​

Defined in: VariantSurface.ts:17

A multi-layer surface that can switch between multiple geometric embeddings (e.g., pial, white, inflated) that share the same topology and data indices.

Extends ​

Constructors ​

Constructor ​

ts
new VariantSurface(surfaceSet, config?): VariantSurface;

Defined in: VariantSurface.ts:22

Parameters ​

surfaceSet ​

SurfaceSet

config? ​

MultiLayerSurfaceConfig = {}

Returns ​

VariantSurface

Overrides ​

MultiLayerNeuroSurface.constructor

Properties ​

layerStack ​

ts
layerStack: LayerStack;

Defined in: MultiLayerNeuroSurface.ts:183

Inherited from ​

MultiLayerNeuroSurface.layerStack


compositeBuffer ​

ts
compositeBuffer: Float32Array;

Defined in: MultiLayerNeuroSurface.ts:184

Inherited from ​

MultiLayerNeuroSurface.compositeBuffer


vertexCount ​

ts
vertexCount: number;

Defined in: MultiLayerNeuroSurface.ts:185

Inherited from ​

MultiLayerNeuroSurface.vertexCount


clipPlanes ​

ts
readonly clipPlanes: ClipPlaneSet;

Defined in: MultiLayerNeuroSurface.ts:205

Clip plane set for surface clipping

Inherited from ​

MultiLayerNeuroSurface.clipPlanes


surfaceSet ​

ts
surfaceSet: SurfaceSet;

Defined in: VariantSurface.ts:18


geometry ​

ts
geometry: SurfaceGeometry;

Defined in: classes.ts:458

Inherited from ​

MultiLayerNeuroSurface.geometry


indices ​

ts
indices: Uint32Array;

Defined in: classes.ts:459

Inherited from ​

MultiLayerNeuroSurface.indices


data ​

ts
data: Float32Array;

Defined in: classes.ts:460

Inherited from ​

MultiLayerNeuroSurface.data


vertexCurv ​

ts
vertexCurv: Float32Array<ArrayBufferLike> | null;

Defined in: classes.ts:461

Inherited from ​

MultiLayerNeuroSurface.vertexCurv


mesh ​

ts
mesh: 
  | Mesh<BufferGeometry<NormalBufferAttributes, BufferGeometryEventMap>, 
  | Material<MaterialEventMap>
  | Material<MaterialEventMap>[], Object3DEventMap>
  | null;

Defined in: classes.ts:462

Inherited from ​

MultiLayerNeuroSurface.mesh


threshold ​

ts
threshold: [number, number];

Defined in: classes.ts:463

Inherited from ​

MultiLayerNeuroSurface.threshold


irange ​

ts
irange: [number, number];

Defined in: classes.ts:464

Inherited from ​

MultiLayerNeuroSurface.irange


hemisphere ​

ts
hemisphere: string;

Defined in: classes.ts:465

Inherited from ​

MultiLayerNeuroSurface.hemisphere


config ​

ts
config: ResolvedSurfaceConfig;

Defined in: classes.ts:466

Inherited from ​

MultiLayerNeuroSurface.config


viewer? ​

ts
optional viewer?: any;

Defined in: classes.ts:467

Inherited from ​

MultiLayerNeuroSurface.viewer

Methods ​

on() ​

ts
on<K>(event, listener): UnsubscribeFn;

Defined in: EventEmitter.ts:18

Type Parameters ​

K ​

K extends keyof SurfaceEventMap

Parameters ​

event ​

K

listener ​

TypedEventListener<SurfaceEventMap[K]>

Returns ​

UnsubscribeFn

Inherited from ​

MultiLayerNeuroSurface.on


once() ​

ts
once<K>(event, listener): UnsubscribeFn;

Defined in: EventEmitter.ts:30

Type Parameters ​

K ​

K extends keyof SurfaceEventMap

Parameters ​

event ​

K

listener ​

TypedEventListener<SurfaceEventMap[K]>

Returns ​

UnsubscribeFn

Inherited from ​

MultiLayerNeuroSurface.once


emit() ​

ts
emit<K>(event, ...args): void;

Defined in: EventEmitter.ts:41

Type Parameters ​

K ​

K extends keyof SurfaceEventMap

Parameters ​

event ​

K

args ​

...EventPayloadArgs<SurfaceEventMap[K]>

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.emit


removeListener() ​

ts
removeListener<K>(event, listenerToRemove): void;

Defined in: EventEmitter.ts:60

Type Parameters ​

K ​

K extends keyof SurfaceEventMap

Parameters ​

event ​

K

listenerToRemove ​

TypedEventListener<SurfaceEventMap[K]>

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.removeListener


removeAllListeners() ​

ts
removeAllListeners(event?): void;

Defined in: EventEmitter.ts:75

Parameters ​

event? ​

keyof SurfaceEventMap

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.removeAllListeners


off() ​

ts
off<K>(event, listener): void;

Defined in: EventEmitter.ts:84

Type Parameters ​

K ​

K extends keyof SurfaceEventMap

Parameters ​

event ​

K

listener ​

TypedEventListener<SurfaceEventMap[K]>

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.off


toggleWireframe() ​

ts
toggleWireframe(enabled): void;

Defined in: MultiLayerNeuroSurface.ts:267

Toggle a simple edge wireframe for debugging/presentation. Creates if missing.

Parameters ​

enabled ​

boolean

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.toggleWireframe


updateOutlineResolution() ​

ts
updateOutlineResolution(
   width, 
   height, 
   dpr?
): void;

Defined in: MultiLayerNeuroSurface.ts:489

Parameters ​

width ​

number

height ​

number

dpr? ​

number = 1

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.updateOutlineResolution


requestColorUpdate() ​

ts
requestColorUpdate(): void;

Defined in: MultiLayerNeuroSurface.ts:509

Request a color update (throttled)

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.requestColorUpdate


flushPendingColorUpdate() ​

ts
flushPendingColorUpdate(): boolean;

Defined in: MultiLayerNeuroSurface.ts:520

Composite a queued layer change immediately before a viewer paint.

The viewer calls this at the start of render() so its already-scheduled animation frame cannot paint stale vertex colors ahead of this surface's independently queued compositing callback.

Returns ​

boolean

Inherited from ​

MultiLayerNeuroSurface.flushPendingColorUpdate


addLayer() ​

ts
addLayer(layer): void;

Defined in: MultiLayerNeuroSurface.ts:540

Add a layer to the surface

Parameters ​

layer ​

Layer

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.addLayer


addTwoDataLayer() ​

ts
addTwoDataLayer(
   id, 
   dataX, 
   dataY, 
   colorMap?, 
   config?
): TwoDataLayer;

Defined in: MultiLayerNeuroSurface.ts:601

Add a 2D data layer that maps two scalar fields to a 2D colormap.

This is a convenience method for creating TwoDataLayer instances.

Parameters ​

id ​

string

Layer identifier

dataX ​

Float32Array<ArrayBufferLike> | number[]

First scalar field (X axis of colormap)

dataY ​

Float32Array<ArrayBufferLike> | number[]

Second scalar field (Y axis of colormap)

colorMap? ​

| ColorMap2DPreset | ColorMap2D

2D colormap preset name or ColorMap2D instance

config? ​

TwoDataLayerConfig = {}

Layer configuration options

Returns ​

TwoDataLayer

Example ​

typescript
// Visualize effect size vs. confidence
surface.addTwoDataLayer(
  'effect-confidence',
  effectSizeData,
  confidenceData,
  'confidence',
  {
    rangeX: [-2, 2],
    rangeY: [0, 1],
    thresholdY: [0, 0.05]  // Hide low-confidence values
  }
);

Inherited from ​

MultiLayerNeuroSurface.addTwoDataLayer


addParcelValueLayer() ​

ts
addParcelValueLayer(
   id, 
   parcelData, 
   vertexLabels, 
   colorMap?, 
   config?
): ParcelValueLayer;

Defined in: MultiLayerNeuroSurface.ts:619

Add a parcel-native value layer.

Parcel values are expanded to vertices using the provided per-vertex parcel labels.

Parameters ​

id ​

string

parcelData ​

ParcelData

vertexLabels ​

| number[] | Int32Array<ArrayBufferLike> | Uint32Array<ArrayBufferLike>

colorMap? ​

string = 'viridis'

config? ​

ParcelValueLayerConfig = {}

Returns ​

ParcelValueLayer

Inherited from ​

MultiLayerNeuroSurface.addParcelValueLayer


getTwoDataLayer() ​

ts
getTwoDataLayer(id): TwoDataLayer | undefined;

Defined in: MultiLayerNeuroSurface.ts:634

Get a TwoDataLayer by ID (type-safe convenience method)

Parameters ​

id ​

string

Returns ​

TwoDataLayer | undefined

Inherited from ​

MultiLayerNeuroSurface.getTwoDataLayer


removeLayer() ​

ts
removeLayer(id): boolean;

Defined in: MultiLayerNeuroSurface.ts:642

Remove a layer by ID

Parameters ​

id ​

string

Returns ​

boolean

Inherited from ​

MultiLayerNeuroSurface.removeLayer


clearLayers() ​

ts
clearLayers(options?): void;

Defined in: MultiLayerNeuroSurface.ts:671

Remove all non-base layers (optionally including base).

Parameters ​

options? ​

ClearLayersOptions = {}

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.clearLayers


updateLayer() ​

ts
updateLayer(id, updates): void;

Defined in: MultiLayerNeuroSurface.ts:686

Update a layer's properties

Parameters ​

id ​

string

updates ​

Record<string, any>

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.updateLayer


updateLayerData() ​

ts
updateLayerData(
   id, 
   data, 
   indices?
): void;

Defined in: MultiLayerNeuroSurface.ts:697

Parameters ​

id ​

string

data ​

Float32Array<ArrayBufferLike> | number[]

indices? ​

number[] | Uint32Array<ArrayBufferLike> | null

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.updateLayerData


updateLayerVisibility() ​

ts
updateLayerVisibility(id, visible): void;

Defined in: MultiLayerNeuroSurface.ts:701

Parameters ​

id ​

string

visible ​

boolean

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.updateLayerVisibility


getLayer() ​

ts
getLayer(id): Layer | undefined;

Defined in: MultiLayerNeuroSurface.ts:708

Get a layer by ID

Parameters ​

id ​

string

Returns ​

Layer | undefined

Inherited from ​

MultiLayerNeuroSurface.getLayer


setCurvature() ​

ts
setCurvature(curvature, options?): void;

Defined in: MultiLayerNeuroSurface.ts:719

Set curvature data for display as underlay. Creates curvature layer if it doesn't exist.

Parameters ​

curvature ​

Float32Array<ArrayBufferLike> | number[]

Curvature values per vertex

options? ​

Display options (brightness, contrast, smoothness, invert)

brightness? ​

number

contrast? ​

number

smoothness? ​

number

invert? ​

boolean

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.setCurvature


applyStyleBaseColor() ​

ts
applyStyleBaseColor(color): boolean;

Defined in: MultiLayerNeuroSurface.ts:752

Apply a style preset's base colour. The base is recoloured only while it still shows the colour the default or the previous preset gave it; a colour chosen any other way is kept. (Choosing exactly that colour yourself is indistinguishable from not choosing one.) The preset colour is remembered either way, for resetBaseColor. Returns whether the base colour changed.

Parameters ​

color ​

ColorRepresentation

Returns ​

boolean

Inherited from ​

MultiLayerNeuroSurface.applyStyleBaseColor


resetBaseColor() ​

ts
resetBaseColor(): void;

Defined in: MultiLayerNeuroSurface.ts:764

Return the base layer to the colour of the current style preset (or the library default), so later presets recolour it again.

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.resetBaseColor


getCurvatureLayer() ​

ts
getCurvatureLayer(): CurvatureLayer | undefined;

Defined in: MultiLayerNeuroSurface.ts:778

Get the curvature layer if it exists

Returns ​

CurvatureLayer | undefined

Inherited from ​

MultiLayerNeuroSurface.getCurvatureLayer


showCurvature() ​

ts
showCurvature(visible): void;

Defined in: MultiLayerNeuroSurface.ts:788

Toggle curvature visibility. When curvature is shown, the base layer is hidden (curvature acts as the underlay). When curvature is hidden, the base layer is shown.

Parameters ​

visible ​

boolean

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.showCurvature


setClipPlane() ​

ts
setClipPlane(
   axis, 
   distance, 
   enabled?, 
   flip?
): void;

Defined in: MultiLayerNeuroSurface.ts:824

Set a clip plane by axis.

Parameters ​

axis ​

ClipAxis

Which axis to clip ('x', 'y', or 'z')

distance ​

number

Distance from origin along axis

enabled? ​

boolean = true

Whether to enable (default: true)

flip? ​

boolean = false

Flip clipping direction (default: false)

Returns ​

void

Example ​

ts
// Clip at x=0 (midline sagittal cut)
surface.setClipPlane('x', 0);

// Clip right hemisphere only
surface.setClipPlane('x', 0, true, true);

Inherited from ​

MultiLayerNeuroSurface.setClipPlane


enableClipPlane() ​

ts
enableClipPlane(axis): void;

Defined in: MultiLayerNeuroSurface.ts:839

Enable a clip plane.

Parameters ​

axis ​

ClipAxis

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.enableClipPlane


disableClipPlane() ​

ts
disableClipPlane(axis): void;

Defined in: MultiLayerNeuroSurface.ts:849

Disable a clip plane.

Parameters ​

axis ​

ClipAxis

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.disableClipPlane


clearClipPlanes() ​

ts
clearClipPlanes(): void;

Defined in: MultiLayerNeuroSurface.ts:859

Clear all clip planes (disable all).

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.clearClipPlanes


getClipPlane() ​

ts
getClipPlane(axis): ClipPlane;

Defined in: MultiLayerNeuroSurface.ts:869

Get a clip plane by axis.

Parameters ​

axis ​

ClipAxis

Returns ​

ClipPlane

Inherited from ​

MultiLayerNeuroSurface.getClipPlane


getOrderedLayers() ​

ts
getOrderedLayers(): readonly Layer[];

Defined in: MultiLayerNeuroSurface.ts:909

Return the exact bottom-to-top layer order used by compositing.

Returns ​

readonly Layer[]

Inherited from ​

MultiLayerNeuroSurface.getOrderedLayers


getLayerOrderDescriptors() ​

ts
getLayerOrderDescriptors(): readonly LayerOrderDescriptor[];

Defined in: MultiLayerNeuroSurface.ts:913

Returns ​

readonly LayerOrderDescriptor[]

Inherited from ​

MultiLayerNeuroSurface.getLayerOrderDescriptors


validateLayerOrder() ​

ts
validateLayerOrder(ids): LayerOrderResult;

Defined in: MultiLayerNeuroSurface.ts:918

Validate a complete bottom-to-top order without mutating the surface.

Parameters ​

ids ​

readonly string[]

Returns ​

LayerOrderResult

Inherited from ​

MultiLayerNeuroSurface.validateLayerOrder


setLayerOrder() ​

ts
setLayerOrder(ids): LayerOrderResult;

Defined in: MultiLayerNeuroSurface.ts:925

Atomically set the complete bottom-to-top layer order.

Parameters ​

ids ​

readonly string[]

Returns ​

LayerOrderResult

Inherited from ​

MultiLayerNeuroSurface.setLayerOrder


moveLayer() ​

ts
moveLayer(layerId, destinationIndex): LayerOrderResult;

Defined in: MultiLayerNeuroSurface.ts:939

Parameters ​

layerId ​

string

destinationIndex ​

number

Returns ​

LayerOrderResult

Inherited from ​

MultiLayerNeuroSurface.moveLayer


updateLayers() ​

ts
updateLayers(updates): void;

Defined in: MultiLayerNeuroSurface.ts:957

Batch update multiple layers

Parameters ​

updates ​

LayerUpdate[]

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.updateLayers


updateColors() ​

ts
updateColors(): void;

Defined in: MultiLayerNeuroSurface.ts:1142

Composite all layers and update mesh colors

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.updateColors


setShading() ​

ts
setShading(options): void;

Defined in: MultiLayerNeuroSurface.ts:1341

Update fragment-level shading (threshold edges, outline, silhouette).

Parameters ​

options ​

SurfaceShadingOptions

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.setShading


updateConfig() ​

ts
updateConfig(newConfig): void;

Defined in: MultiLayerNeuroSurface.ts:1490

Update material settings. On the GPU path the compositor's Phong-based shader receives the same Phong properties a CPU material would.

Parameters ​

newConfig ​

Partial<SurfaceConfig>

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.updateConfig


createMesh() ​

ts
createMesh(): Mesh;

Defined in: MultiLayerNeuroSurface.ts:1515

Create mesh with proper material settings

Returns ​

Mesh

Inherited from ​

MultiLayerNeuroSurface.createMesh


setCompositingMode() ​

ts
setCompositingMode(useGPU): void;

Defined in: MultiLayerNeuroSurface.ts:1575

Switch compositing mode between CPU and GPU

Parameters ​

useGPU ​

boolean

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.setCompositingMode


activateConfiguredCompositor() ​

ts
activateConfiguredCompositor(): void;

Defined in: MultiLayerNeuroSurface.ts:1640

Activate the constructor-requested GPU path once a viewer renderer exists.

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.activateConfiguredCompositor


setWideLines() ​

ts
setWideLines(useWide): void;

Defined in: MultiLayerNeuroSurface.ts:1646

Parameters ​

useWide ​

boolean

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.setWideLines


getCompositingMode() ​

ts
getCompositingMode(): "CPU" | "GPU";

Defined in: MultiLayerNeuroSurface.ts:1664

Get current compositing mode

Returns ​

"CPU" | "GPU"

Inherited from ​

MultiLayerNeuroSurface.getCompositingMode


currentVariant() ​

ts
currentVariant(): string;

Defined in: VariantSurface.ts:33

Returns ​

string


variantNames() ​

ts
variantNames(): string[];

Defined in: VariantSurface.ts:37

Returns ​

string[]


setVariant() ​

ts
setVariant(name, options?): void;

Defined in: VariantSurface.ts:41

Parameters ​

name ​

string

options? ​

VariantTransitionOptions = {}

Returns ​

void


dispose() ​

ts
dispose(): void;

Defined in: VariantSurface.ts:106

Dispose of all resources

Returns ​

void

Overrides ​

MultiLayerNeuroSurface.dispose


update() ​

ts
update(property, value): void;

Defined in: classes.ts:517

Parameters ​

property ​

string

value ​

any

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.update


getPickMetadata() ​

ts
getPickMetadata(_vertexIndex): Record<string, unknown> | null;

Defined in: classes.ts:647

Parameters ​

_vertexIndex ​

number

Returns ​

Record<string, unknown> | null

Inherited from ​

MultiLayerNeuroSurface.getPickMetadata


setVisible() ​

ts
setVisible(visible): void;

Defined in: classes.ts:654

Parameters ​

visible ​

boolean

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.setVisible


setOpacity() ​

ts
setOpacity(opacity): void;

Defined in: classes.ts:662

Parameters ​

opacity ​

number

Returns ​

void

Inherited from ​

MultiLayerNeuroSurface.setOpacity


setSmoothShading() ​

ts
setSmoothShading(smooth, smoothingAngle?): void;

Defined in: classes.ts:682

Control surface shading style (visual only, doesn't modify geometry)

Parameters ​

smooth ​

boolean

If true, uses smooth shading (interpolated normals). If false, uses flat shading (face normals)

smoothingAngle? ​

number

Optional angle threshold in degrees (0-180). Edges above this angle remain sharp

Returns ​

void

Example ​

javascript
// Enable smooth shading for organic surfaces
surface.setSmoothShading(true);

// Smooth shading with 30° threshold (sharp edges preserved)
surface.setSmoothShading(true, 30);

// Flat shading for faceted/crystalline look
surface.setSmoothShading(false);

Inherited from ​

MultiLayerNeuroSurface.setSmoothShading


applyLaplacianSmoothing() ​

ts
applyLaplacianSmoothing(
   iterations?, 
   lambda?, 
   method?, 
   preserveBoundaries?
): void;

Defined in: classes.ts:718

Apply Laplacian smoothing to the surface vertices (modifies geometry)

Parameters ​

iterations? ​

number = 1

Number of smoothing iterations (1-10). More iterations = smoother surface

lambda? ​

number = 0.5

Smoothing strength (0-1). 0 = no effect, 1 = maximum smoothing per iteration

method? ​

"laplacian" | "taubin"

Smoothing algorithm:

  • 'laplacian': Standard smoothing, may shrink surface
  • 'taubin': Alternates shrink/expand to preserve volume
preserveBoundaries? ​

boolean = true

If true, boundary edges remain fixed

Returns ​

void

Example ​

javascript
// Gentle smoothing to reduce noise
surface.applyLaplacianSmoothing(2, 0.3, 'laplacian', true);

// Aggressive smoothing while preserving volume
surface.applyLaplacianSmoothing(5, 0.5, 'taubin', true);

// Smooth including boundaries (may distort edges)
surface.applyLaplacianSmoothing(3, 0.4, 'laplacian', false);

Inherited from ​

MultiLayerNeuroSurface.applyLaplacianSmoothing


createSmoothedCopy() ​

ts
createSmoothedCopy(
   iterations?, 
   lambda?, 
   method?
): SurfaceGeometry;

Defined in: classes.ts:768

Create a smoothed copy of this surface

Parameters ​

iterations? ​

number = 1

Number of smoothing iterations

lambda? ​

number = 0.5

Smoothing factor 0-1

method? ​

"laplacian" | "taubin"

'laplacian' or 'taubin'

Returns ​

SurfaceGeometry

A new smoothed surface geometry

Inherited from ​

MultiLayerNeuroSurface.createSmoothedCopy


updateMesh() ​

ts
updateMesh(): Mesh;

Defined in: classes.ts:793

Returns ​

Mesh

Inherited from ​

MultiLayerNeuroSurface.updateMesh

Released under the MIT License.