All {@type Object3D} types that are loaded in Needle Engine do automatically receive the GameObject extensions like addComponent etc.
Many of the GameObject methods can be imported directly via @needle-tools/engine as well:

import { addComponent } from "@needle-tools/engine";

Hierarchy

Implements

Constructors

Properties

activeSelf: boolean

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

guid: undefined | string

the object's unique identifier

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): 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): 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): 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): 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

  • creates a new component on this gameObject

    Type Parameters

    Parameters

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

    Returns T

  • Type Parameters

    Parameters

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

    Returns T

    use addComponent

  • Destroys the Object3D and all its Needle Engine components.

    Returns any

  • Get a Needle Engine component from the Object3D.

    Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns null | T

    The component instance or null if not found.

  • Get a Needle Engine component from the Object3D or its children. This will search on the current Object and all its children.

    Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns null | T

    The component instance or null if not found.

  • Get a Needle Engine component from the Object3D or its parents. This will search on the current Object and all its parents.

    Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns null | T

    The component instance or null if not found.

  • Get all components of a specific type from the Object3D.

    Type Parameters

    • T

    Parameters

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

      Optional array to fill with the found components.

    Returns T[]

    An array of components.

  • Get all components of a specific type from the Object3D or its children. This will search on the current Object and all its children.

    Type Parameters

    • T

    Parameters

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

      Optional array to fill with the found components.

    Returns T[]

    An array of components.

  • Get all Needle Engine components of a specific type from the Object3D or its parents. This will search on the current Object and all its parents.

    Type Parameters

    • T

    Parameters

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

      Optional array to fill with the found components.

    Returns T[]

    An array of components.

  • Get or add a Needle Engine component to the Object3D. If the component already exists, it will be returned. Otherwise, a new component will be added.

    Type Parameters

    • T

    Parameters

    • typeName: null | ConstructorConcrete<T>

      The component constructor to get or add.

    Returns T

    The component instance.

  • Remove a Needle Engine component from the Object3D.

    Type Parameters

    Parameters

    • comp: T

    Returns T

  • Add an object to parent and also ensure all components are being registered

    Parameters

    Returns void

  • Add a new component (or move an existing component) to the provided object

    Type Parameters

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject

      object to add the component to

    • instanceOrType: T | ConstructorConcrete<T>

      if an instance is provided it will be moved to the new object, if a type is provided a new instance will be created and moved to the new object

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

      optional init object to initialize the component with

    • Optionalopts: {
          callAwake: boolean;
      }
      • callAwake: boolean

    Returns T

  • Type Parameters

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject
    • type: T | ConstructorConcrete<T>
    • Optionalinit: Partial<NoInternalNeedleEngineState<FilterStartingWith<FilterTypes<T, undefined | null | Function>, "_">>>
    • callAwake: boolean = true

    Returns T

    Use addComponent

  • Destroys a object

    Parameters

    • instance: Object3D<Object3DEventMap> | Behaviour

      object to destroy

    • recursive: boolean = true

      if true, all children will be destroyed as well. true by default

    Returns void

  • Destroys a object on all connected clients (if you are in a networked session)

    Parameters

    Returns void

  • Parameters

    • guid: string
    • hierarchy: Object3D<Object3DEventMap>

    Returns
        | undefined
        | null
        | Behaviour
        | GameObject

  • Type Parameters

    Parameters

    • typeName: Constructor<T>
    • Optionalcontext: Object3D<Object3DEventMap> | Context
    • includeInactive: boolean = true

    Returns null | T

  • Type Parameters

    Parameters

    Returns T[]

  • Run a callback for all components of the provided type on the provided object and its children (if recursive is true)

    Parameters

    • instance: Object3D<Object3DEventMap>

      object to run the method on

    • cb: ((comp: Behaviour) => any)

      callback to run on each component, "return undefined;" to continue and "return ;" to break the loop

        • (comp): any
        • Parameters

          Returns any

    • recursive: boolean = true

      if true, the method will be run on all children as well

    Returns any

    the last return value of the callback

  • Gets a component on the provided object

    Type Parameters

    Parameters

    Returns null | T

  • Type Parameters

    Parameters

    Returns null | T

  • Type Parameters

    Parameters

    Returns null | T

  • Type Parameters

    Parameters

    Returns T[]

  • Type Parameters

    Parameters

    Returns T[]

  • Type Parameters

    Parameters

    Returns T[]

  • Type Parameters

    Parameters

    Returns T

  • Creates a new instance of the provided object (like cloning it including all components and children)

    Parameters

    • instance: Object3D<Object3DEventMap> | GameObject

      object to instantiate

    • opts: null | IInstantiateOptions = null

      options for the instantiation (e.g. with what parent, position, etc.)

    Returns GameObject

  • Creates a new instance of the provided object. The new instance will be created on all connected clients

    Parameters

    • instance: null | Object3D<Object3DEventMap> | GameObject

      object to instantiate

    • opts: IInstantiateOptions

      options for the instantiation

    Returns null | GameObject

  • Invokes a method on all components that have a method matching the provided name

    Parameters

    • go: undefined | null | Object3D<Object3DEventMap>

      object to invoke the method on all components

    • functionName: string

      name of the method to invoke

    • children: boolean = false
    • Rest...args: any

    Returns void

  • Invokes a method on all components including children (if a method with that name exists)

    Parameters

    • go: undefined | null | Object3D<Object3DEventMap>
    • functionName: string
    • Rest...args: any

    Returns void

  • If the object is active in the hierarchy (e.g. if any parent is invisible or not in the scene it will be false)

    Parameters

    • go: Object3D<Object3DEventMap>

      object to check

    Returns boolean

  • If the object is active (same as go.visible)

    Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    • go: Object3D<Object3DEventMap>
    • instanced: boolean

    Returns void

  • Moves a component to a new object

    Type Parameters

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject

      component to move the component to

    • instance: T | ConstructorConcrete<T>

      component to move to the GO

    Returns T

  • Removes the object from its parent and deactivates all of its components

    Parameters

    • instance: undefined | null | Object3D<Object3DEventMap>

    Returns void

  • Removes a component from its object

    Type Parameters

    Parameters

    • instance: T

      component to remove

    Returns T

  • Parameters

    • go: Object3D<Object3DEventMap>
    • active: boolean
    • processStart: boolean = true

    Returns void