Skip to content

Class: ClipPlane

Defined in: src/utils/ClipPlane.ts:40

ClipPlane manages a single clipping plane for surface visualization.

Clipping removes parts of the surface on one side of the plane, useful for revealing internal structures (e.g., medial wall) or focusing on specific regions.

Example

typescript
// Clip at x=0 (midline sagittal cut)
const clipX = new ClipPlane();
clipX.setFromAxisDistance('x', 0);

// Clip using three points
const clipCustom = new ClipPlane();
clipCustom.setFromPoints(p1, p2, p3);

Constructors

Constructor

ts
new ClipPlane(config?): ClipPlane;

Defined in: src/utils/ClipPlane.ts:56

Parameters

config?

ClipPlaneConfig = {}

Returns

ClipPlane

Properties

normal

ts
normal: Vector3;

Defined in: src/utils/ClipPlane.ts:42

Plane normal (unit vector pointing toward kept region)


point

ts
point: Vector3;

Defined in: src/utils/ClipPlane.ts:45

A point on the plane


enabled

ts
enabled: boolean;

Defined in: src/utils/ClipPlane.ts:48

Whether this clip plane is active

Methods

setFromAxisDistance()

ts
setFromAxisDistance(
   axis, 
   distance, 
   flip?): this;

Defined in: src/utils/ClipPlane.ts:72

Set clip plane from axis and distance from origin.

Parameters

axis

ClipAxis

Which axis the plane is perpendicular to ('x', 'y', or 'z')

distance

number

Distance from origin along the axis

flip?

boolean = false

If true, flip which side is clipped (default: false)

Returns

this


setFromPoints()

ts
setFromPoints(
   a, 
   b, 
   c): this;

Defined in: src/utils/ClipPlane.ts:106

Set clip plane from three points. The plane normal is computed using the right-hand rule.

Parameters

a

Vector3

First point

b

Vector3

Second point

c

Vector3

Third point

Returns

this


setFromNormalAndPoint()

ts
setFromNormalAndPoint(normal, point): this;

Defined in: src/utils/ClipPlane.ts:131

Set clip plane from normal and point directly.

Parameters

normal

Vector3

Plane normal (will be normalized)

point

Vector3

Point on the plane

Returns

this


setDistance()

ts
setDistance(distance): this;

Defined in: src/utils/ClipPlane.ts:149

Set the distance along the current normal direction. Useful for slider-based interaction.

Parameters

distance

number

Distance from origin along normal

Returns

this


getDistance()

ts
getDistance(): number;

Defined in: src/utils/ClipPlane.ts:159

Get the current distance from origin.

Returns

number


setEnabled()

ts
setEnabled(enabled): this;

Defined in: src/utils/ClipPlane.ts:166

Enable or disable the clip plane.

Parameters

enabled

boolean

Returns

this


toggle()

ts
toggle(): this;

Defined in: src/utils/ClipPlane.ts:174

Toggle the enabled state.

Returns

this


flip()

ts
flip(): this;

Defined in: src/utils/ClipPlane.ts:182

Flip the clipping direction (swap which side is kept/clipped).

Returns

this


getThreePlane()

ts
getThreePlane(): Plane;

Defined in: src/utils/ClipPlane.ts:192

Get the Three.js Plane object for use with material clipping.

Returns

Plane


getShaderUniforms()

ts
getShaderUniforms(): object;

Defined in: src/utils/ClipPlane.ts:199

Get shader uniform values for GPU clipping.

Returns

object

normal
ts
normal: Vector3;
point
ts
point: Vector3;
enabled
ts
enabled: boolean;

toStateJSON()

ts
toStateJSON(): object;

Defined in: src/utils/ClipPlane.ts:207

Returns

object

axis
ts
axis: string;
normal
ts
normal: [number, number, number];
distance
ts
distance: number;
enabled
ts
enabled: boolean;
flip
ts
flip: boolean;

clone()

ts
clone(): ClipPlane;

Defined in: src/utils/ClipPlane.ts:226

Clone this clip plane.

Returns

ClipPlane

Released under the MIT License.