FERRETGame engine over Babylon.js
Ferret

@ferret/inspector

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

7 exports · source in packages/inspector/src

Functions

exportStep function

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.

packages/inspector/src/step.ts:207

installInspector function

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.

packages/inspector/src/commands.ts:64

stepReal function

function stepReal(v: number): string

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

packages/inspector/src/step.ts:47

stepString function

function stepString(s: string): string

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

packages/inspector/src/step.ts:57

Interfaces

InspectorContext interface

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

packages/inspector/src/commands.ts:11

StepOptions interface

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?: stringthe product's name, also the root of the assembly in the CAD tree (default 'scene')
root?: BABYLON.Nodeonly this node and its children
units?: 'mm' | 'm''mm' (default) or 'm'
includeHidden?: booleanalso disabled and invisible meshes (default false)
maxTriangles?: numberrefuse a scene with more triangles than this (default 2 000 000; a triangle is about 300 bytes of STEP)
time?: Datethe time written in the header (default now, local time)

packages/inspector/src/step.ts:13

StepResult interface

interface StepResult
file: stringa file name for it: the name, .step
text: stringthe file, ASCII
parts: numberparts in the assembly (a mesh, or one thin instance of it)
solids: numberclosed pieces written as solids
surfaces: numberopen pieces written as surfaces
triangles: number
skipped: { name: string; reason: string }[]meshes left out and why

packages/inspector/src/step.ts:28