# @ferret/inspector: API

Developer commands over the world: entity tree, component values, physics view, stats.

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

## Functions

### exportStep

*function* · `packages/inspector/src/step.ts:207`

```ts
function exportStep(scene: BABYLON.Scene, o: StepOptions = {}): StepResult
```

The scene (or `root` and its children) as the text of a STEP file. Throws when there is nothing to write or too much.

### installInspector

*function* · `packages/inspector/src/commands.ts:64`

```ts
function installInspector(ctx: InspectorContext): () => void
```

The command set behind the model viewer and the inspector. Everything is JSON in, JSON out, so a person's panel, a test and an
AI agent (over MCP) use the same calls. Register once per world: `installInspector(ctx)`. Returns a function that removes the
debug overlays and the helper objects.

### stepReal

*function* · `packages/inspector/src/step.ts:47`

```ts
function stepReal(v: number): string
```

a REAL: always with a decimal point ("1.", "0.5", "1.E-07")

### stepString

*function* · `packages/inspector/src/step.ts:57`

```ts
function stepString(s: string): string
```

a STRING: quotes and backslashes doubled, everything outside printable ASCII as \X2\hhhh\X0\ (UTF-16)

## Interfaces

### InspectorContext

*interface* · `packages/inspector/src/commands.ts:11`

```ts
interface InspectorContext
```

What the command set works on. Everything but the scene and the world is optional.

- `scene: BABYLON.Scene`
- `world: World`
- `engine?: BABYLON.AbstractEngine`
- `assets?: AssetCache`
- `physics?: PhysicsService`
- `host?: { advance(dt: number): void; render(): void }` — what advances and draws a frame when there are several worlds (the game's host); default: this world and its scene

### StepOptions

*interface* · `packages/inspector/src/step.ts:13`

```ts
interface StepOptions
```

STEP export (ISO 10303-21, schema AP214 `automotive_design`): the meshes of a scene as a file that CAD programs open (FreeCAD, Fusion, SolidWorks,
Inventor, KOMPAS, Onshape ...). A STEP file has no triangles of its own, so every triangle becomes a planar face (the faceted form of ISO 10303-42):
a closed piece of a mesh becomes a solid (`FACETED_BREP`), an open one a surface (`SHELL_BASED_SURFACE_MODEL`). The file is an assembly: one part per
mesh, named after it, coloured by its material's base colour, in world coordinates. Axes: CAD is right-handed and Z up, so Babylon's (x, y, z) is
written as (x, z, y) (a right-handed scene: (x, -z, y)). Units: a scene unit is a metre; the file is in millimetres (or metres, `units: 'm'`).
Not written: textures, UVs, vertex colours, lights, cameras, animation (a skinned or morphed mesh is written in its current pose).

  const r = exportStep(scene, { name: 'yard' });        // r.text is the file

- `name?: string` — the product's name, also the root of the assembly in the CAD tree (default 'scene')
- `root?: BABYLON.Node` — only this node and its children
- `units?: 'mm' | 'm'` — 'mm' (default) or 'm'
- `includeHidden?: boolean` — also disabled and invisible meshes (default false)
- `maxTriangles?: number` — refuse a scene with more triangles than this (default 2 000 000; a triangle is about 300 bytes of STEP)
- `time?: Date` — the time written in the header (default now, local time)

### StepResult

*interface* · `packages/inspector/src/step.ts:28`

```ts
interface StepResult
```

- `file: string` — a file name for it: the name, `.step`
- `text: string` — the file, ASCII
- `parts: number` — parts in the assembly (a mesh, or one thin instance of it)
- `solids: number` — closed pieces written as solids
- `surfaces: number` — open pieces written as surfaces
- `triangles: number`
- `skipped: { name: string; reason: string }[]` — meshes left out and why

