magic-pixels
    Preparing search index...

    Class Object3D

    Base class of everything in the scene graph. An object has a transform relative to its parent (position, quaternion or rotation, scale, composed into localMatrix) and a list of children. worldMatrix is the transform relative to the scene root, parent.worldMatrix × localMatrix, computed by updateWorldMatrix() in a tree walk before each render.

    The rotation is stored twice, as a Quaternion and as Euler angles, and either can be written to. updateLocalMatrix() compares both against their values at the last update and converts whichever changed into the other (the quaternion wins if both changed).

    A child inherits its parent's transform, so planet.add(moon) and moon.position.set(2, 0, 0) make the moon orbit when planet.rotation.y changes. To orbit without spinning the parent, put an empty Object3D in between as a pivot.

    Hierarchy (View Summary)

    Index
    children: Object3D[] = []
    localMatrix: Mat4 = ...

    transform relative to the parent

    matrixAutoUpdate: boolean = true

    When true (the default), updateWorldMatrix() recomposes localMatrix from position, rotation and scale. Set to false to write localMatrix yourself; flag changes with worldMatrixNeedsUpdate.

    parent: Object3D | null = null
    position: Vector = ...

    translation relative to the parent

    quaternion: Quaternion = ...

    rotation relative to the parent, as a unit quaternion

    rotation: Vector = ...

    rotation relative to the parent, as Euler angles in radians applied in XYZ order; kept in sync with quaternion

    scale: Vector = ...

    scale factors per axis

    visible: boolean = true

    invisible objects and their children are not rendered

    worldMatrix: Mat4 = ...

    transform relative to the scene root

    worldMatrixNeedsUpdate: boolean = false

    set to true after changing localMatrix manually

    • Add children. An object that already has a parent is moved.

      Parameters

      Returns this

      this instance

    • Rotate so that the object's +Z axis points at target. Cameras override this and point their -Z axis (the viewing direction) instead.

      Parameters

      • target: Vector

        a point in the parent's coordinate system

      • up: Vector = DEFAULT_UP

        the up direction, +Y by default

      Returns this

    • Called after worldMatrix was recomputed

      Returns void

    • Remove children. Objects that are not children are ignored.

      Parameters

      Returns this

      this instance

    • Detach from the parent, if any

      Returns this

    • Set quaternion (and with it rotation) from the rotation part of a matrix. The matrix must not contain scaling.

      Parameters

      Returns this

    • Call callback for this object and all its descendants, depth-first

      Parameters

      Returns void

    • Recompose localMatrix from position, quaternion and scale, after bringing quaternion and rotation in sync (see the class description).

      Returns this

    • Update the world matrices of this object and its descendants.

      Parameters

      • force: boolean = false

        recompute even if nothing was flagged as changed

      Returns void