Taos API Reference
    Preparing search index...

    Class GameObject

    Container for transform, children, and components.

    Forms a parent/child scene graph: each GameObject has its own local TRS (position/rotation/scale) and inherits its parent's world transform via GameObject.localToWorld. Behavior is added by attaching Component instances; per-frame updates flow recursively through GameObject.update.

    Index

    Constructors

    Properties

    id: string

    Stable identity for this object, unique within a session. Auto-generated for runtime-created objects; the editor overwrites it with a persistent id when projecting a saved document so references, selection, and prefab links survive save / load / undo.

    enabled: boolean = true

    Whether this GameObject is active and should be updated and rendered.

    name: string

    Display/lookup name (not unique).

    transform: Transform

    This object's transform: local TRS plus the lazily-cached world matrix. The GameObject.position, GameObject.rotation, and GameObject.scale accessors forward to it.

    children: GameObject[] = []

    Child GameObjects whose transforms are relative to this one.

    parent: GameObject | null = null

    Parent GameObject, or null if this is a root.

    scene: Scene | null = null

    Scene this GameObject currently belongs to, or null when detached. Set by Scene.add and propagated down to descendants by addChild; cleared by Scene.remove. Used by the scene to maintain typed component caches without a per-frame hierarchy walk. Do not assign directly — use the scene/parent APIs.

    Accessors

    Methods

    • Sets the local position in place. Shorthand for position.set(x, y, z).

      Parameters

      • x: number
      • y: number
      • z: number

      Returns this

      This GameObject, for chaining.

    • Sets the local scale in place. Shorthand for scale.set(x, y, z).

      Parameters

      • x: number
      • y: number
      • z: number

      Returns this

      This GameObject, for chaining.

    • Sets the local rotation from intrinsic XYZ Euler angles (radians) in place. Shorthand for rotation.setEuler(x, y, z).

      Parameters

      • x: number
      • y: number
      • z: number

      Returns this

      This GameObject, for chaining.

    • Sets the local rotation to rad radians around axis in place. Shorthand for rotation.setAxisAngle(axis, rad).

      Parameters

      • axis: Vec3
      • rad: number

      Returns this

      This GameObject, for chaining.

    • Returns the first attached component matching the given constructor, or null.

      Type Parameters

      Parameters

      • ctor: new (...args: never[]) => T

        Component subclass constructor used as a type filter.

      Returns T | null

    • Returns all attached components matching the given constructor.

      Type Parameters

      Parameters

      • ctor: new (...args: never[]) => T

        Component subclass constructor used as a type filter.

      Returns T[]

    • Detaches a component (calling its onDetach) if it is attached to this GameObject.

      Parameters

      • component: Component

        The component instance to remove.

      Returns void

    • Reparents another GameObject under this one.

      Note: this does not remove the child from any previous parent's children list.

      Parameters

      Returns void

    • Depth-first search this subtree for the first GameObject named name. Convenience for wiring up references inside behaviors; for hot paths cache the result rather than searching every frame.

      Parameters

      • name: string

        Exact Function.name to match.

      • includeSelf: boolean = false

        When true, this object is considered before its descendants. Defaults to false (searches descendants only).

      Returns GameObject | null

      The first matching GameObject, or null.

    • Appends every GameObject named name in this subtree to out, in depth-first order.

      Parameters

      • name: string

        Exact Function.name to match.

      • out: GameObject[] = []

        Array the matches are pushed onto.

      • includeSelf: boolean = false

        When true, this object is considered before its descendants. Defaults to false (searches descendants only).

      Returns GameObject[]

      out, for chaining.

    • Returns true iff this GameObject and every ancestor up to the root is enabled. Used by the scene's cached component lookups to skip components whose owning subtree is currently disabled.

      Returns boolean

    • Sets the scene this GameObject (and all descendants) belongs to, registering/unregistering their components with the scene's caches. Called by Scene.add / Scene.remove and propagated by addChild. Internal — do not call directly.

      Parameters

      Returns void

    • Allocation-free variant of localToWorld: copies the cached world matrix into out and returns it. The cache is refreshed on read, so this reflects any transform changes made this frame. The caller owns out.

      Use this in per-frame loops (engine bucketing, light update, etc.).

      Parameters

      Returns Mat4

    • Updates every attached component, then recursively updates each child.

      Parameters

      • dt: number

        Frame delta time in seconds.

      Returns void

    • Refreshes per-frame render state on every attached component, then recursively on each child. Called after update and any controller input that mutates the transform, so cached values (e.g. camera view / projection matrices) reflect the final transform for the frame.

      Parameters

      Returns void