Skip to content

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).

getPose / setPose read and set the full camera pose, and move / rotate walk and turn it the way the arrow keys do. Positions are world coordinates in Snaptrude units (1 unit = 0.254 m, Y up; see snaptrude.core.units); yaw is degrees clockwise from +z seen from above, pitch is degrees above level. These moves leave 2D plan view for 3D, stop a playing walkthrough and any standard-view change still animating, and resolve once the new view has been drawn — so a capture right after sees it without a fixed wait. getNavigationSettings / updateNavigationSettings read and change the arrow-key navigation settings.

Types ​

PluginCameraPose ​

Result of getPose, setPose, move and rotate.

PropertyTypeDescription
eye{ x, y, z }Camera position, in Snaptrude units
target{ x, y, z }The point the camera looks at
yawInDegreesnumberView direction, degrees clockwise from +z seen from above (−180 to 180)
pitchInDegreesnumberView direction, degrees above level (negative looks down)
fieldOfViewInDegreesnumberVertical field of view
projection"perspective" | "orthographic"The camera projection
mode"2d" | "3d"The modelling mode

PluginCameraPoseInput ​

Where setPose puts the camera — exactly one of:

ShapeMeaning
{ eye, target }Stand at eye looking at target
{ eye, yawInDegrees, pitchInDegrees }Stand at eye looking along a direction (pitch within ±89°)
{ standAt, yawInDegrees? }Stand at eye height on the floor, stair, terrain or ground at or below standAt, facing yawInDegrees (default: the current yaw)

PluginCameraNavigationSettings ​

Result of getNavigationSettings and updateNavigationSettings.

PropertyTypeDescription
isKeyboardNavigationEnabledbooleanWhether the arrow keys walk the camera (Project Settings)
eyeHeightnumberEye height above the floor, in Snaptrude units
walkSpeed"slow" | "normal" | "fast"Arrow-key walking speed
isCollisionEnabledbooleanWhether walking stops at walls

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 — true once 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 — true once 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 — true once 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 — true once 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 — true once 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 — true if there was a selection to frame; false if nothing is selected (no-op).
ts
await snaptrude.core.camera.zoomSelection();

getPose() ​

Read where the camera is and where it looks: eye, target, yaw, pitch, field of view, projection and mode. Paired with setPose.

ts
const pose = await snaptrude.core.camera.getPose();
console.log(pose.eye, pose.yawInDegrees, pose.pitchInDegrees);

setPose(pose, options?) ​

Place the camera, optionally easing there, and resolve once the new view has been drawn. pose is one of the PluginCameraPoseInput shapes; { eye, target } does what lookFrom does with handles. { standAt } stands at the user's eye height above the floor there, like the I key.

  • pose: PluginCameraPoseInput.
  • options.durationInSeconds: number — ease to the pose over this long, 0 to 10 (default 0 jumps).
  • Returns: PluginCameraPose — the pose once the camera has arrived.
ts
const { camera } = snaptrude.core;
await camera.setPose({ standAt: { x: 20, y: 0, z: 35 }, yawInDegrees: 90 });
await camera.setPose(
  { eye: { x: 60, y: 25, z: 60 }, target: { x: 0, y: 5, z: 0 } },
  { durationInSeconds: 1.5 }
);

move(displacement, options?) ​

Walk or fly the camera by a displacement in its own frame: forward along the level view direction, right to its side and up vertically, in Snaptrude units. The view direction does not change. With options.followsFloor the camera keeps its height above the floor, climbing and descending stairs and ramps as the arrow keys do; a change bigger than a step (a balcony edge, a raised stage) keeps the height.

  • displacement: { forward?, right?, up? } — omitted components are 0.
  • options.followsFloor: boolean — keep the height above the floor (default false).
  • options.durationInSeconds: number — walk over this long, 0 to 10 (default 0).
  • Returns: PluginCameraPose after the move.
ts
const metre = 1 / 0.254;
await snaptrude.core.camera.move(
  { forward: 3 * metre },
  { followsFloor: true, durationInSeconds: 2 }
);

rotate(yawInDegrees, pitchInDegrees?, options?) ​

Turn the camera in place by signed angles: yawInDegrees to the right (clockwise seen from above) and pitchInDegrees up. The eye does not move; the resulting pitch is kept within ±89°.

  • yawInDegrees: number — turn right by this much (negative turns left).
  • pitchInDegrees: number — tilt up by this much (negative tilts down; default 0).
  • options.durationInSeconds: number — turn over this long, 0 to 10 (default 0).
  • Returns: PluginCameraPose after turning.
ts
await snaptrude.core.camera.rotate(180, 0, { durationInSeconds: 1 });

getNavigationSettings() ​

Read the arrow-key navigation settings. Paired with updateNavigationSettings.

ts
const { isKeyboardNavigationEnabled } = await snaptrude.core.camera.getNavigationSettings();

updateNavigationSettings(patch) ​

Change arrow-key navigation settings; only the fields given change. isKeyboardNavigationEnabled is the user's Project Settings switch and is saved on this device; the others last for the session. Write-gated — it changes the user's preferences.

  • patch: { isKeyboardNavigationEnabled?, eyeHeight?, walkSpeed?, isCollisionEnabled? } — eyeHeight in Snaptrude units, 0.8 m to 2.5 m (3.15 to 9.84 units).
  • Returns: PluginCameraNavigationSettings after the change.
ts
await snaptrude.core.camera.updateNavigationSettings({
  eyeHeight: 1.6 / 0.254,
  isCollisionEnabled: true
});

Errors ​

Failed calls reject with a typed PluginError — see Error Handling. getPose / setPose / move / rotate reject with PRECONDITION_FAILED when there is no active camera, and setPose / move / rotate also while a walkthrough is being exported (moving the camera would spoil the recording). setPose rejects with VALIDATION when eye and target coincide, and with PRECONDITION_FAILED when standAt is below the ground with nothing under it. updateNavigationSettings rejects with METHOD_NOT_PERMITTED when plugin writes are disabled, and with VALIDATION for an eye height outside 0.8–2.5 m. 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.