Skip to content

Class: MultiLayerNeuroSurface

Defined in: src/MultiLayerNeuroSurface.ts:136

Multi-layer brain surface with flexible layer compositing

Extends

Extended by

Constructors

Constructor

ts
new MultiLayerNeuroSurface(geometry, config?): MultiLayerNeuroSurface;

Defined in: src/MultiLayerNeuroSurface.ts:149

Parameters

geometry

SurfaceGeometry

config?

MultiLayerSurfaceConfig = {}

Returns

MultiLayerNeuroSurface

Overrides

NeuroSurface.constructor

Properties

layerStack

ts
layerStack: LayerStack;

Defined in: src/MultiLayerNeuroSurface.ts:137


compositeBuffer

ts
compositeBuffer: Float32Array;

Defined in: src/MultiLayerNeuroSurface.ts:138


vertexCount

ts
vertexCount: number;

Defined in: src/MultiLayerNeuroSurface.ts:139


clipPlanes

ts
readonly clipPlanes: ClipPlaneSet;

Defined in: src/MultiLayerNeuroSurface.ts:147

Clip plane set for surface clipping


geometry

ts
geometry: SurfaceGeometry;

Defined in: src/classes.ts:263

Inherited from

NeuroSurface.geometry


indices

ts
indices: Uint32Array;

Defined in: src/classes.ts:264

Inherited from

NeuroSurface.indices


data

ts
data: Float32Array;

Defined in: src/classes.ts:265

Inherited from

NeuroSurface.data


vertexCurv

ts
vertexCurv: Float32Array<ArrayBufferLike> | null;

Defined in: src/classes.ts:266

Inherited from

NeuroSurface.vertexCurv


mesh

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

Defined in: src/classes.ts:267

Inherited from

NeuroSurface.mesh


threshold

ts
threshold: [number, number];

Defined in: src/classes.ts:268

Inherited from

NeuroSurface.threshold


irange

ts
irange: [number, number];

Defined in: src/classes.ts:269

Inherited from

NeuroSurface.irange


hemisphere

ts
hemisphere: string;

Defined in: src/classes.ts:270

Inherited from

NeuroSurface.hemisphere


config

ts
config: Required<SurfaceConfig>;

Defined in: src/classes.ts:271

Inherited from

NeuroSurface.config


viewer?

ts
optional viewer?: any;

Defined in: src/classes.ts:272

Inherited from

NeuroSurface.viewer

Methods

on()

ts
on(event, listener): UnsubscribeFn;

Defined in: src/EventEmitter.ts:12

Parameters

event

string

listener

EventListener

Returns

UnsubscribeFn

Inherited from

NeuroSurface.on


once()

ts
once(event, listener): UnsubscribeFn;

Defined in: src/EventEmitter.ts:23

Parameters

event

string

listener

EventListener

Returns

UnsubscribeFn

Inherited from

NeuroSurface.once


emit()

ts
emit(event, ...args): void;

Defined in: src/EventEmitter.ts:34

Parameters

event

string

args

...any[]

Returns

void

Inherited from

NeuroSurface.emit


removeListener()

ts
removeListener(event, listenerToRemove): void;

Defined in: src/EventEmitter.ts:41

Parameters

event

string

listenerToRemove

EventListener

Returns

void

Inherited from

NeuroSurface.removeListener


removeAllListeners()

ts
removeAllListeners(event?): void;

Defined in: src/EventEmitter.ts:52

Parameters

event?

string

Returns

void

Inherited from

NeuroSurface.removeAllListeners


off()

ts
off(event, listener): void;

Defined in: src/EventEmitter.ts:61

Parameters

event

string

listener

EventListener

Returns

void

Inherited from

NeuroSurface.off


toggleWireframe()

ts
toggleWireframe(enabled): void;

Defined in: src/MultiLayerNeuroSurface.ts:216

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

Parameters

enabled

boolean

Returns

void


updateOutlineResolution()

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

Defined in: src/MultiLayerNeuroSurface.ts:430

Parameters

width

number

height

number

dpr?

number = 1

Returns

void


requestColorUpdate()

ts
requestColorUpdate(): void;

Defined in: src/MultiLayerNeuroSurface.ts:447

Request a color update (throttled)

Returns

void


addLayer()

ts
addLayer(layer): void;

Defined in: src/MultiLayerNeuroSurface.ts:462

Add a layer to the surface

Parameters

layer

Layer

Returns

void


addTwoDataLayer()

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

Defined in: src/MultiLayerNeuroSurface.ts:512

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?

ColorMap2D | ColorMap2DPreset

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
  }
);

addParcelValueLayer()

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

Defined in: src/MultiLayerNeuroSurface.ts:530

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

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

colorMap?

string = 'viridis'

config?

ParcelValueLayerConfig = {}

Returns

ParcelValueLayer


getTwoDataLayer()

ts
getTwoDataLayer(id): TwoDataLayer | undefined;

Defined in: src/MultiLayerNeuroSurface.ts:545

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

Parameters

id

string

Returns

TwoDataLayer | undefined


removeLayer()

ts
removeLayer(id): boolean;

Defined in: src/MultiLayerNeuroSurface.ts:553

Remove a layer by ID

Parameters

id

string

Returns

boolean


clearLayers()

ts
clearLayers(options?): void;

Defined in: src/MultiLayerNeuroSurface.ts:581

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

Parameters

options?

ClearLayersOptions = {}

Returns

void


updateLayer()

ts
updateLayer(id, updates): void;

Defined in: src/MultiLayerNeuroSurface.ts:596

Update a layer's properties

Parameters

id

string

updates

Record<string, any>

Returns

void


updateLayerData()

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

Defined in: src/MultiLayerNeuroSurface.ts:607

Parameters

id

string

data

Float32Array<ArrayBufferLike> | number[]

indices?

Uint32Array<ArrayBufferLike> | number[] | null

Returns

void


updateLayerVisibility()

ts
updateLayerVisibility(id, visible): void;

Defined in: src/MultiLayerNeuroSurface.ts:611

Parameters

id

string

visible

boolean

Returns

void


getLayer()

ts
getLayer(id): Layer | undefined;

Defined in: src/MultiLayerNeuroSurface.ts:618

Get a layer by ID

Parameters

id

string

Returns

Layer | undefined


setCurvature()

ts
setCurvature(curvature, options?): void;

Defined in: src/MultiLayerNeuroSurface.ts:629

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)

brightness?

number

contrast?

number

smoothness?

number

Returns

void


getCurvatureLayer()

ts
getCurvatureLayer(): CurvatureLayer | undefined;

Defined in: src/MultiLayerNeuroSurface.ts:654

Get the curvature layer if it exists

Returns

CurvatureLayer | undefined


showCurvature()

ts
showCurvature(visible): void;

Defined in: src/MultiLayerNeuroSurface.ts:664

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


setClipPlane()

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

Defined in: src/MultiLayerNeuroSurface.ts:700

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);

enableClipPlane()

ts
enableClipPlane(axis): void;

Defined in: src/MultiLayerNeuroSurface.ts:714

Enable a clip plane.

Parameters

axis

ClipAxis

Returns

void


disableClipPlane()

ts
disableClipPlane(axis): void;

Defined in: src/MultiLayerNeuroSurface.ts:723

Disable a clip plane.

Parameters

axis

ClipAxis

Returns

void


clearClipPlanes()

ts
clearClipPlanes(): void;

Defined in: src/MultiLayerNeuroSurface.ts:732

Clear all clip planes (disable all).

Returns

void


getClipPlane()

ts
getClipPlane(axis): ClipPlane;

Defined in: src/MultiLayerNeuroSurface.ts:741

Get a clip plane by axis.

Parameters

axis

ClipAxis

Returns

ClipPlane


setLayerOrder()

ts
setLayerOrder(ids): void;

Defined in: src/MultiLayerNeuroSurface.ts:781

Set the order of layers (bottom to top)

Parameters

ids

string[]

Returns

void


updateLayers()

ts
updateLayers(updates): void;

Defined in: src/MultiLayerNeuroSurface.ts:789

Batch update multiple layers

Parameters

updates

LayerUpdate[]

Returns

void


updateColors()

ts
updateColors(): void;

Defined in: src/MultiLayerNeuroSurface.ts:965

Composite all layers and update mesh colors

Returns

void

Overrides

NeuroSurface.updateColors


createMesh()

ts
createMesh(): Mesh;

Defined in: src/MultiLayerNeuroSurface.ts:1233

Create mesh with proper material settings

Returns

Mesh

Overrides

NeuroSurface.createMesh


setCompositingMode()

ts
setCompositingMode(useGPU): void;

Defined in: src/MultiLayerNeuroSurface.ts:1280

Switch compositing mode between CPU and GPU

Parameters

useGPU

boolean

Returns

void


setWideLines()

ts
setWideLines(useWide): void;

Defined in: src/MultiLayerNeuroSurface.ts:1338

Parameters

useWide

boolean

Returns

void


getCompositingMode()

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

Defined in: src/MultiLayerNeuroSurface.ts:1355

Get current compositing mode

Returns

"CPU" | "GPU"


dispose()

ts
dispose(): void;

Defined in: src/MultiLayerNeuroSurface.ts:1367

Dispose of all resources

Returns

void

Overrides

NeuroSurface.dispose


update()

ts
update(property, value): void;

Defined in: src/classes.ts:317

Parameters

property

string

value

any

Returns

void

Inherited from

NeuroSurface.update


updateConfig()

ts
updateConfig(newConfig): void;

Defined in: src/classes.ts:342

Update surface material properties dynamically

Parameters

newConfig

Partial<SurfaceConfig>

Partial configuration object with properties to update

Returns

void

Example

javascript
// Make surface shiny and semi-transparent
surface.updateConfig({
  shininess: 150,
  specularColor: 0xffffff,
  alpha: 0.7
});

// Switch to flat shading for faceted look
surface.updateConfig({ flatShading: true });

Inherited from

NeuroSurface.updateConfig


getPickMetadata()

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

Defined in: src/classes.ts:438

Parameters

_vertexIndex

number

Returns

Record<string, unknown> | null

Inherited from

NeuroSurface.getPickMetadata


setVisible()

ts
setVisible(visible): void;

Defined in: src/classes.ts:445

Parameters

visible

boolean

Returns

void

Inherited from

NeuroSurface.setVisible


setOpacity()

ts
setOpacity(opacity): void;

Defined in: src/classes.ts:453

Parameters

opacity

number

Returns

void

Inherited from

NeuroSurface.setOpacity


setSmoothShading()

ts
setSmoothShading(smooth, smoothingAngle?): void;

Defined in: src/classes.ts:473

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

NeuroSurface.setSmoothShading


applyLaplacianSmoothing()

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

Defined in: src/classes.ts:509

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

NeuroSurface.applyLaplacianSmoothing


createSmoothedCopy()

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

Defined in: src/classes.ts:559

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

NeuroSurface.createSmoothedCopy


updateMesh()

ts
updateMesh(): Mesh;

Defined in: src/classes.ts:584

Returns

Mesh

Inherited from

NeuroSurface.updateMesh

Released under the MIT License.