Documentation
    Preparing search index...

    Class TrackballRig

    A virtual-sphere trackball (§44, §47) — see the module documentation for the mapping, the placement decision, and why this is not a component.

    The rig holds an orientation and, optionally, a pivot and a distance. Used for its TrackballRig.rotation alone it is a pure "spin this object" control; given a target and a distance it is a camera rig, and TrackballRig.applyTo places and aims a camera in one call.

    Index
    degenerateDrags: number

    Drags whose two points mapped to the same sphere point, so nothing was rotated.

    distance: number

    Distance from TrackballRig.target, in world units.

    dragCount: number

    Drags that produced a rotation.

    height: number

    Viewport height in pixels.

    origin: ScreenOrigin

    How TrackballRig.drag's coordinates are measured.

    radius: number

    Virtual sphere radius as a fraction of half the shorter side. Immutable — retuning is a new rig.

    rotation: Quaternion

    The accumulated orientation, as a unit quaternion. Live and mutable — read it, or write into it to snap the trackball somewhere; the instance is never replaced, so a caller that captured it keeps a valid view.

    target: Vector3

    The point TrackballRig.applyTo places a node around, in that node's parent space. Live and mutable, like rotation.

    Parent space rather than world space, deliberately: a trackball camera is authored as a top-level node or under a single rig parent, and writing the local transform keeps this rig free of world-matrix inversion — the machinery @fourjs/motion's placeAtWorldPosition exists for, which a rig driven from a pointer event does not need. A trackball under a moving parent orbits the parent's frame, which is the useful reading of it.

    width: number

    Viewport width in pixels. Assign a new one on resize (validated on use).

    • Writes the rig's orientation onto node, and — when TrackballRig.distance places it — its position: target plus the rotated +Z offset, so the node looks down its own −Z at the target (§7a, the convention Node.lookAt and Camera.updateViewMatrix share).

      The write is the application's, under §42's default "manual" authority, because no system drives this rig (see the module documentation). A node owned by any other authority is refused and warned about once, like every other refused write in §42.

      Parameters

      Returns boolean

      true when the node was written; false when §42 refused it.

    • Turns a drag from one viewport point to another into a rotation and composes it onto TrackballRig.rotation.

      Call it per pointer-move with the previous and current positions; a whole gesture is the composition of its moves, and composing per move is what makes the response continuous rather than snapping from the gesture's origin.

      Parameters

      • fromX: number
      • fromY: number
      • toX: number
      • toY: number

      Returns boolean

      true when the rig rotated. false — and a bumped TrackballRig.degenerateDrags — when the two points map to the same sphere point (a drag of zero length, or two points diametrically related by the sheet), which has no defined axis.

      RangeError if any coordinate is not finite, or the viewport size is not positive (§85). Nothing is written when it throws.

    • Maps a viewport point to a point on the virtual sphere, into out (§7b's out convention).

      Public because it is the whole mapping, and a caller who wants to draw the trackball's silhouette, unit-test a gesture, or build a different gesture on the same sphere should not have to re-derive it.

      Parameters

      Returns Vector3

      RangeError if either coordinate is not finite, or if the viewport size is not positive (§85).

    • Returns the rig to the identity orientation. Counters are left alone.

      Returns void

    • Records a new viewport size (§45/§48). Both numbers are validated (§85).

      Parameters

      • width: number
      • height: number

      Returns this

      this rig, for chaining

      RangeError on a non-finite or non-positive size. Nothing is written.