interface IGameObject {
    activeSelf: boolean;
    guid: undefined | string;
    hideFlags: HideFlags;
    raycastAllowed: boolean;
    raycastPreference?: "lod" | "bounds" | "full";
    get worldForward(): Vector3;
    get worldPosition(): Vector3;
    set worldPosition(val: Vector3): void;
    get worldQuaternion(): Quaternion;
    set worldQuaternion(val: Quaternion): void;
    get worldRight(): Vector3;
    get worldRotation(): Vector3;
    set worldRotation(val: Vector3): void;
    get worldScale(): Vector3;
    set worldScale(val: Vector3): void;
    get worldUp(): Vector3;
    addComponent<T extends IComponent>(
        comp: T | ConstructorConcrete<T>,
        init?: Partial<
            NoInternalNeedleEngineState<
                FilterStartingWith<FilterTypes<T, undefined | null | Function>, "_">,
            >,
        >,
    ): T;
    addNewComponent<T extends IComponent>(
        type: Constructor<T>,
        init?: Partial<
            NoInternalNeedleEngineState<
                FilterStartingWith<FilterTypes<T, undefined | null | Function>, "_">,
            >,
        >,
    ): T;
    contains(object: undefined | null | Object3D<Object3DEventMap>): boolean;
    destroy(): void;
    getComponent<T>(type: Constructor<T>): null | T;
    getComponentInChildren<T>(type: Constructor<T>): null | T;
    getComponentInParent<T>(type: Constructor<T>): null | T;
    getComponents<T>(type: Constructor<T>, arr?: T[]): T[];
    getComponentsInChildren<T>(type: Constructor<T>, arr?: T[]): T[];
    getComponentsInParent<T>(type: Constructor<T>, arr?: T[]): T[];
    getOrAddComponent<T>(typeName: null | Constructor<T>): T;
    removeComponent<T extends IComponent>(comp: T): T;
}

Hierarchy

Implemented by

Properties

activeSelf: boolean

if the object is enabled in the hierarchy (usually equivalent to visible)

guid: undefined | string

the object's unique identifier

hideFlags: HideFlags

Allows to control e.g. if an object should be exported

raycastAllowed: boolean

If false the object will be ignored for raycasting (e.g. pointer events). Default is true.

true
raycastPreference?: "lod" | "bounds" | "full"

Set a raycast preference for the object:

  • lod will use the raycast mesh lod if available (default). This is usually a simplified mesh for raycasting.
  • bounds will use the bounding box of the object for raycasting. This is very fast but not very accurate.
  • full will use the full mesh for raycasting. This is the most accurate but also the slowest option.

NOTE: Needle Engine's Raycast system will use Mesh BVH by default - so event 'full' is usually faster than default three.js raycasting.

Accessors

  • get worldForward(): Vector3

    Get the world forward vector of the Object3D.
    Added by Needle Engine.

    Returns Vector3

  • get worldPosition(): Vector3

    Get or set the world position of the Object3D.
    Added by Needle Engine.

    Returns Vector3

  • set worldPosition(val: Vector3): void

    Get or set the world position of the Object3D.
    Added by Needle Engine.

    Parameters

    Returns void

  • get worldQuaternion(): Quaternion

    Get or set the world quaternion of the Object3D.
    Added by Needle Engine.

    Returns Quaternion

  • set worldQuaternion(val: Quaternion): void

    Get or set the world quaternion of the Object3D.
    Added by Needle Engine.

    Parameters

    Returns void

  • get worldRight(): Vector3

    Get the world right vector of the Object3D.
    Added by Needle Engine.

    Returns Vector3

  • get worldRotation(): Vector3

    Get or set the world rotation of the Object3D.
    Added by Needle Engine.

    Returns Vector3

  • set worldRotation(val: Vector3): void

    Get or set the world rotation of the Object3D.
    Added by Needle Engine.

    Parameters

    Returns void

  • get worldScale(): Vector3

    Get or set the world scale of the Object3D.
    Added by Needle Engine.

    Returns Vector3

  • set worldScale(val: Vector3): void

    Get or set the world scale of the Object3D.
    Added by Needle Engine.

    Parameters

    Returns void

  • get worldUp(): Vector3

    Get the world up vector of the Object3D.
    Added by Needle Engine.

    Returns Vector3

Methods

  • Remove a component from this object. Expected a component instance

    Type Parameters

    Parameters

    • comp: T | ConstructorConcrete<T>
    • Optionalinit: Partial<
          NoInternalNeedleEngineState<
              FilterStartingWith<FilterTypes<T, undefined | null | Function>, "_">,
          >,
      >

    Returns T

    the removed component (equal to the passed in component)

  • Add a new component to this object. Expects a component type (e.g. addNewComponent(Animator))

    Type Parameters

    Parameters

    • type: Constructor<T>
    • Optionalinit: Partial<
          NoInternalNeedleEngineState<
              FilterStartingWith<FilterTypes<T, undefined | null | Function>, "_">,
          >,
      >

    Returns T

  • Check if the given object is contained in the hierarchy of this object or if it's the same object.

    Parameters

    • object: undefined | null | Object3D<Object3DEventMap>

      The object to check.

    Returns boolean

    True if the object is contained in the hierarchy, false otherwise.

  • call to destroy this object including all components that are attached to it. Will destroy all children recursively

    Returns void

  • Tries to find a component of a type on this object.

    Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns null | T

    the first instance of a component on this object that matches the passed in type or null if no component of this type (or a subtype) exists

  • Finds a component of a certain type on this object OR a child object if any exists

    Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns null | T

  • Finds a component of a certain type on this object OR a parent object if any exists

    Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns null | T

  • Type Parameters

    • T

    Parameters

    • type: Constructor<T>
    • Optionalarr: T[]

    Returns T[]

    all components of a certain type on this object

  • Finds all components of a certain type on this object AND all children (recursively)

    Type Parameters

    • T

    Parameters

    • type: Constructor<T>
    • Optionalarr: T[]

    Returns T[]

  • Finds all components of a certain type on this object AND all parents (recursively)

    Type Parameters

    • T

    Parameters

    • type: Constructor<T>
    • Optionalarr: T[]

    Returns T[]

  • Searches for a component type on this object. If no component of the searched type exists yet a new instance will be created and returned

    Type Parameters

    • T

    Parameters

    • typeName: null | Constructor<T>

    Returns T

  • Remove a Needle Engine component from the Object3D.

    Type Parameters

    Parameters

    • comp: T

    Returns T