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

Accessors

  • get worldForward(): Vector3
  • Returns Vector3

  • get worldPosition(): Vector3
  • Returns Vector3

  • set worldPosition(val): void
  • Parameters

    Returns void

  • get worldQuaternion(): Quaternion
  • Returns Quaternion

  • set worldQuaternion(val): void
  • Parameters

    Returns void

  • get worldRight(): Vector3
  • Returns Vector3

  • get worldRotation(): Vector3
  • Returns Vector3

  • set worldRotation(val): void
  • Parameters

    Returns void

  • get worldScale(): Vector3
  • Returns Vector3

  • set worldScale(val): void
  • Parameters

    Returns void

  • get worldUp(): Vector3
  • Returns Vector3

Methods

  • creates a new component on this gameObject

    Type Parameters

    • T extends IComponent

    Parameters

    • comp: T | ConstructorConcrete<T>
    • Optional init: Partial<NoInternalNeedleEngineState<FilterStartingWith<FilterTypes<T, Function>, "_">>>

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

    • type: ConstructorConcrete<T>
    • Optional init: Partial<NoInternalNeedleEngineState<FilterStartingWith<FilterTypes<T, Function>, "_">>>

    Returns T

    Deprecated

    use addComponent

  • Returns any

  • Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns T

  • Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns T

  • Type Parameters

    • T

    Parameters

    • type: Constructor<T>

    Returns T

  • Type Parameters

    • T

    Parameters

    • type: Constructor<T>
    • Optional arr: T[]

    Returns T[]

  • Type Parameters

    • T

    Parameters

    • type: Constructor<T>
    • Optional arr: T[]

    Returns T[]

  • Type Parameters

    • T

    Parameters

    • type: Constructor<T>
    • Optional arr: T[]

    Returns T[]

  • Type Parameters

    • T

    Parameters

    • typeName: ConstructorConcrete<T>

    Returns T

  • Type Parameters

    • T extends IComponent

    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

    • T extends IComponent

    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

    • Optional init: Partial<NoInternalNeedleEngineState<FilterStartingWith<FilterTypes<T, Function>, "_">>>

      optional init object to initialize the component with

    • Optional opts: {
          callAwake: boolean;
      }
      • callAwake: boolean

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

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

    Returns T

    Deprecated

    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

  • Type Parameters

    • T extends IComponent

    Parameters

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

    Returns T

  • Type Parameters

    • T extends IComponent

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

    • T extends IComponent

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject
    • typeName: Constructor<T>

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject
    • typeName: Constructor<T>

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject
    • typeName: Constructor<T>

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject
    • typeName: Constructor<T>
    • arr: T[] = null

    Returns T[]

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject
    • typeName: Constructor<T>
    • arr: T[] = null

    Returns T[]

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject
    • typeName: Constructor<T>
    • arr: T[] = null

    Returns T[]

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: Object3D<Object3DEventMap> | IGameObject
    • typeName: ConstructorConcrete<T>

    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: 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: Object3D<Object3DEventMap> | GameObject

      object to instantiate

    • opts: IInstantiateOptions

      options for the instantiation

    Returns GameObject

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

    Parameters

    • go: 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: 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> | IGameObject

    Returns Generator<any, void, unknown>

  • Parameters

    • go: Object3D<Object3DEventMap>
    • instanced: boolean

    Returns void

  • Moves a component to a new object

    Type Parameters

    • T extends IComponent

    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

    Returns void

  • Removes a component from its object

    Type Parameters

    • T extends IComponent

    Parameters

    • instance: T

      component to remove

    Returns T

  • Parameters

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

    Returns void

Generated using TypeDoc