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

  • unknown
    • GameObject

Implements

  • unknown
  • IGameObject

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

      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: any
    • 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: any

      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

    • instance: any

      object to destroy

    • Optional context: Context
    • recursive: boolean = true

    Returns void

  • Type Parameters

    • T extends IComponent

    Parameters

    • typeName: Constructor<T>
    • Optional context: any
    • includeInactive: boolean = true

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

    • typeName: Constructor<T>
    • Optional context: any

    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

      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: any
    • typeName: Constructor<T>

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: any
    • typeName: Constructor<T>

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: any
    • typeName: Constructor<T>

    Returns T

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: any
    • typeName: Constructor<T>
    • arr: T[] = null

    Returns T[]

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: any
    • typeName: Constructor<T>
    • arr: T[] = null

    Returns T[]

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: any
    • typeName: Constructor<T>
    • arr: T[] = null

    Returns T[]

  • Type Parameters

    • T extends IComponent

    Parameters

    • go: any
    • typeName: ConstructorConcrete<T>

    Returns T

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

    Parameters

    • instance: any

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

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

      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: any
    • 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

    Returns boolean

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

    Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    Returns boolean

  • Parameters

    • go: any

    Returns Generator<any, void, unknown>

  • Parameters

    Returns void

  • Moves a component to a new object

    Type Parameters

    • T extends IComponent

    Parameters

    • go: any

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

    Returns void

  • Removes a component from its object

    Type Parameters

    • T extends IComponent

    Parameters

    • instance: T

      component to remove

    Returns T

  • Parameters

    • go: Object3D
    • active: boolean
    • processStart: boolean = true

    Returns void

Generated using TypeDoc