← Back to Docs
  • index.html
  • Clayground
  • Clayground.Canvas3D
  • OrbitCamera3D
  • Clayground 2026.2
  • OrbitCamera3D QML Type

    An orbit camera on a leash: circles a pivot, never dives through the floor. More...

    Import Statement: import Clayground.Canvas3D

    Properties

    Methods

    Detailed Description

    The camera every 3D lab and demo ends up hand-rolling. It looks at pivot from a yaw/pitch/distance rig, clamps itself so the viewer cannot get lost, and can frame a set of world points so a scene arrives properly composed.

    The anti-clip rule is a minimum height above the pivot plane, not a minimum distance: a distance sphere wrongly blocks zooming onto a small focused object, while a height floor pushes the rig outward as the angle flattens and can never end up under the ground.

    Example usage:

    import Clayground.Canvas3D
    
    View3D {
        camera: rig.camera
        OrbitCamera3D {
            id: rig
            pivot: Qt.vector3d(0, 0, 0)
            distance: 60
        }
    }
    MouseArea {
        anchors.fill: parent
        property point last
        onPressed: (m) => last = Qt.point(m.x, m.y)
        onPositionChanged: (m) => {
            rig.orbitBy((m.x - last.x) * 0.4, (m.y - last.y) * 0.3)
            last = Qt.point(m.x, m.y)
        }
        onWheel: (w) => rig.zoomBy(w.angleDelta.y > 0 ? 0.9 : 1.1)
    }

    See also Label3D.

    Property Documentation

    camera : alias [read-only]


    camera \readonly : PerspectiveCamera [read-only]


    distance : real


    distance \brief Distance to the pivot. : real


    fieldOfView : real


    fieldOfView \brief Vertical FOV of the camera. : real


    maxDistance : real


    maxDistance \brief Furthest allowed retreat. : real


    maxPitch : real


    maxPitch \brief Steepest allowed angle (< 90). : real


    minDistance : real


    minDistance \brief Closest allowed approach. : real


    minHeight : real

    Lowest the camera may sit above the pivot plane.

    The leash: flattening the angle backs the rig off instead of letting it sink through the ground.


    minPitch : real


    minPitch \brief Flattest allowed angle. : real


    pitch : real


    pitch \brief Angle above the pivot plane, degrees. : real


    pivot : vector3d


    pivot \brief The point the camera looks at. : vector3d


    yaw : real


    yaw \brief Angle around the pivot, degrees. : real


    Method Documentation

    void applyState(var s)

    Restores a pose produced by state().


    void clamp()

    Applies the pitch/distance limits and the minimum-height rule.


    void frame(var points, real pad)

    Centres on the given world points and backs off until they fit.

    points is an array of vector3d (or {x, y, z}); pad is a headroom factor (1.0 = tight, 1.3 = comfortable). Keeps the current yaw/pitch, so framing never disorients the viewer.


    void orbitBy(real dYaw, real dPitch)

    Turns the rig, then re-applies the leash.


    var state()

    Pose as a JSON-serializable object, for the viewState convention.


    void zoomBy(real factor)

    Multiplies the distance (0.9 zooms in, 1.1 out).