Appearance
Camera
Camera controls. Position the viewport camera, snap it to a standard orthographic/isometric view, toggle between the 2D (plan) and 3D modelling modes, switch the 3D projection, and frame the view onto the scene or the selection — mirrors the canvas view menu, the 2D/3D toggle, the View Settings panel's Perspective/Orthographic control, and the zoom menu. These are transient view-state changes: they are not model edits, so they are not write-gated and are not undoable. Accessed via snaptrude.core.camera.
zoomExtents / zoomSelection are the canonical home of the framing actions — they replace the deprecated core.zoom namespace (core.zoom.extents / core.zoom.selection).
Functions
lookFrom(eye, target)
Point the camera: place its eye at eye looking toward target (world coordinates, internal babylon units).
eye:Vec3Handle— camera position.target:Vec3Handle— the point the camera looks at.- Returns:
boolean—trueonce the camera has been positioned.
ts
const { vec3 } = snaptrude.core.math;
await snaptrude.core.camera.lookFrom(vec3.new(50, 30, 50), vec3.new(0, 0, 0));setStandardView(view)
Snap the camera to a standard view — the five orthographic elevations (top / front / back / left / right) or the 3D iso (isometric perspective) view. The orthographic presets exit 2D mode first if needed.
view:"top" | "front" | "back" | "left" | "right" | "iso".- Returns:
boolean—trueonce the view has been applied.
ts
await snaptrude.core.camera.setStandardView("top");getMode()
Read the current modelling mode: "2d" (plan) or "3d". Paired with setMode. Read off the live engine flag the 2D/3D toggle writes, so it always agrees with getProjection — in "2d" the projection is always "orthographic".
- Returns:
"2d" | "3d".
ts
if ((await snaptrude.core.camera.getMode()) === "2d") {
await snaptrude.core.camera.setMode("3d");
}setMode(mode)
Toggle the modelling mode between 2d (plan) and 3d. 3d enters the isometric perspective view; 2d drops to the orthographic plan of the active storey.
mode:"2d" | "3d".- Returns:
boolean—trueonce the mode switch has been requested.
ts
await snaptrude.core.camera.setMode("3d");getProjection()
Read the camera's current projection: "perspective" (the default 3D view) or "orthographic". In 2D (plan) mode this always reports "orthographic" — a plan is an orthographic projection. The 2D test is the same live flag getMode reads, so the two can never contradict each other.
- Returns:
"perspective" | "orthographic".
ts
const projection = await snaptrude.core.camera.getProjection();
console.log(projection); // "perspective" | "orthographic"setProjection(projection)
Switch the 3D camera between "perspective" and "orthographic" projection — the Perspective/Orthographic control in the Design tab's View Settings panel (the same toggle, and it keeps that panel's radio in sync). Like setMode, a transient view-state change: not write-gated, not undoable. Setting the projection it already has is a no-op.
In 2D (plan) mode the canvas is always an orthographic plan: "orthographic" is accepted as a no-op, while "perspective" rejects with PRECONDITION_FAILED — switch to 3D first via setMode("3d").
projection:"perspective" | "orthographic".- Returns:
boolean—trueonce the projection has been applied.
ts
await snaptrude.core.camera.setProjection("orthographic");
const projection = await snaptrude.core.camera.getProjection(); // "orthographic"zoomExtents()
Zoom (fit) the camera to all geometry in the scene — the "zoom extents" action. Canonical home of the deprecated core.zoom.extents.
- Returns:
boolean—trueonce the camera has been framed to the scene.
ts
await snaptrude.core.camera.zoomExtents();zoomSelection()
Zoom (fit) the camera to the current selection. Canonical home of the deprecated core.zoom.selection.
- Returns:
boolean—trueif there was a selection to frame;falseif nothing is selected (no-op).
ts
await snaptrude.core.camera.zoomSelection();Errors
Failed calls reject with a typed PluginError — see Error Handling. lookFrom rejects with PRECONDITION_FAILED if there is no active camera, and with HANDLE_INVALID if a vector handle is gone or forged. setStandardView / setMode / setProjection reject with VALIDATION on an unrecognized view/mode/projection. getProjection / setProjection reject with PRECONDITION_FAILED when there is no active camera, and setProjection("perspective") rejects with PRECONDITION_FAILED while in 2D mode; otherwise the methods are total.