camera_set_view

Aims the camera by exactly one of: view (a canonical view, fitting the visible scene unless fit: false), direction (keeping the target and focus distance), or eye with target. Two of them, or eye without target, is invalid_params. up is a hint: it sets the heading only when looking along ±Z (top and bottom views included), and the camera never rolls. With view or direction, projection switches the kind with the framing kept; with eye and target it is applied as given, so a get_camera_state result comes back exactly. tight frames the box corners instead when fitting; tight without a fit is invalid_params.

Command

Usage

TypeScript
surface.execute('camera_set_view', { view?, direction?, eye?, target?, up?, projection?, fit?, tight?, animate?, durationMs?, easing?, from?, viewport? })

Parameters

  • view"front" | "back" | "left" | "right" | "top" | "bottom" | "iso"

    Optional

  • directionobject

    f64 world-space point or direction

    Optional

  • eyeobject

    f64 world-space point or direction

    Optional

  • targetobject

    f64 world-space point or direction

    Optional

  • upobject

    f64 world-space point or direction

    Optional

  • projectionobject

    Optional

  • fitboolean

    Optional

  • tightboolean

    Optional

  • animateboolean

    Optional

  • durationMsnumber

    Optional

  • easing"linear" | "cubic-in" | "cubic-out" | "cubic-in-out"

    Optional

  • from"goal" | "live"

    Optional

  • viewportstring

    the slot (viewport id); the first by default

    Optional

Returns

object with eye, target, up, projection, transition, in the ok: true envelope.

JSON
{
  "type": "object",
  "properties": {
    "eye": {
      "type": "object",
      "description": "f64 world-space point or direction",
      "properties": {
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "z": {
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ]
    },
    "target": {
      "type": "object",
      "description": "f64 world-space point or direction",
      "properties": {
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "z": {
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ]
    },
    "up": {
      "type": "object",
      "description": "f64 world-space point or direction",
      "properties": {
        "x": {
          "type": "number"
        },
        "y": {
          "type": "number"
        },
        "z": {
          "type": "number"
        }
      },
      "required": [
        "x",
        "y",
        "z"
      ]
    },
    "projection": {
      "type": "object",
      "properties": {
        "kind": {
          "type": "string",
          "enum": [
            "perspective",
            "orthographic"
          ]
        },
        "fovYDeg": {
          "type": "number"
        },
        "height": {
          "type": "number"
        }
      },
      "required": [
        "kind"
      ]
    },
    "transition": {
      "type": "integer",
      "minimum": 1
    }
  },
  "required": [
    "eye",
    "target",
    "up",
    "projection"
  ]
}

See also