# @ferret/view: API

Presentation views of a scene: section (cutaway) planes cut meshes on the GPU, with hatched caps on the cut faces.

6 exports. Generated from the source (`packages/view/src`), so it matches the code.

## Classes

### SectionView

*class* · `packages/view/src/section.ts:113`

```ts
class SectionView
```

A section (cutaway) view: meshes are cut by up to six planes in the material, on the GPU, and the cut faces are filled with a
flat, hatched colour (the inside faces of a closed solid show through the cut, and they are drawn as the cap). Works with
standard and PBR materials, instances and skinned meshes. The cut materials are copies, so a material shared with meshes that
are not cut stays as it was; `dispose()` gives every mesh its own material back. Shadows and picking still see the whole mesh.

- `mode: 'any' | 'all'`
- `capColor: [number, number, number] | null`
- `hatch: number`
- `worldPlanes: [number, number, number, number][]` — the current plane equations in world space (refreshed every frame when the planes follow a frame)
- `constructor(readonly scene: BABYLON.Scene, private readonly o: SectionOptions)`
- `get active()`
- `set active(on: boolean)`
- `get meshes(): BABYLON.AbstractMesh[]` — The meshes now cut.
- `setPlanes(planes: SectionPlane[], mode?: 'any' | 'all')`
- `isCut(p: V3): boolean` — Whether a world point is cut away now (for picking, labels, or placing things in the open part).
- `add(targets: (BABYLON.AbstractMesh | BABYLON.TransformNode)[])` — Cut more meshes (or every mesh under a node).
- `remove(meshes: BABYLON.AbstractMesh[])` — Stop cutting these meshes: they get their own material back.
- `dispose()`

## Functions

### isCut

*function* · `packages/view/src/section.ts:44`

```ts
function isCut(planes: [number, number, number, number][], mode: 'any' | 'all', p: V3): boolean
```

Whether a world point is cut away by these plane equations in this mode (the same test as the shader).

### planeEquation

*function* · `packages/view/src/section.ts:34`

```ts
function planeEquation(p: SectionPlane, frame?: BABYLON.Matrix): [number, number, number, number]
```

The plane equation (a, b, c, d) with a x + b y + c z + d > 0 on the side that is cut away.

## Interfaces

### SectionOptions

*interface* · `packages/view/src/section.ts:9`

```ts
interface SectionOptions
```

- `targets: (BABYLON.AbstractMesh | BABYLON.TransformNode)[]` — what is cut: these meshes, or every mesh under these nodes (a model's root)
- `exclude?: (mesh: BABYLON.AbstractMesh) => boolean` — meshes under the targets that stay whole (a part shown in full inside a cut housing)
- `planes: SectionPlane[]` — 1 to 6 planes
- `mode?: 'any' | 'all'` — `any`: cut away what is beyond any plane (a slice, a box); `all`: cut away only what is beyond every plane (one plane is a half cut; two planes take out a quarter, the classic cutaway). Default `all`.
- `frame?: BABYLON.TransformNode` — the planes are in this node's frame and move with it (default: world space)
- `capColor?: [number, number, number] | null` — colour of the cut faces, linear RGB 0..1 (default a light grey); null leaves the inside faces as they are
- `hatch?: number` — hatch of the cut faces: line spacing in pixels, 0 for none (default 8)
- `active?: boolean` — start cutting at once (default true)

### SectionPlane

*interface* · `packages/view/src/section.ts:4`

```ts
interface SectionPlane
```

A cutting plane: through `point`, `normal` pointing to the side that is cut away.

- `point: V3`
- `normal: V3`

## Types

### V3

*type* · `packages/view/src/section.ts:1`

```ts
type V3 = [number, number, number] | BABYLON.Vector3
```

