Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Actor

An actor represents an object instantiated on the host.

Hierarchy

  • Actor

Implements

Index

Accessors

appearance

attachment

children

  • get children(): Actor[]

collider

context

grabbable

  • get grabbable(): boolean
  • set grabbable(value: boolean): void

id

  • get id(): string

light

lookAt

name

  • get name(): string

parent

parentId

  • get parentId(): string
  • set parentId(value: string): void

rigidBody

subscriptions

  • get subscriptions(): ("transform" | "rigidbody" | "collider")[]

tag

  • get tag(): string
  • set tag(value: string): void

text

transform

Methods

animateTo

  • animateTo(value: Partial<ActorLike>, duration: number, curve: number[]): void
  • Animate actor properties to the given value, following the specified animation curve. Actor transform is the only animatable property at the moment. Other properties such as light color may become animatable in the future.

    Parameters

    • value: Partial<ActorLike>

      The desired final state of the animation.

    • duration: number

      The length of the interpolation (in seconds).

    • curve: number[]

      The cubic-bezier curve parameters. @see AnimationEaseCurves for predefined values.

    Returns void

attach

  • Attach to the user at the given attach point.

    Parameters

    • userOrUserId: User | string

      The User or id of user to attach to.

    • attachPoint: AttachPoint

      Where on the user to attach.

    Returns void

copy

createAnimation

destroy

  • destroy(): void

detach

  • detach(): void

disableAnimation

  • disableAnimation(animationName: string): void
  • Disables the animation on the actor. Animation will stop playing immediately. When an animation is disabled, it is also paused (its time does not move forward).

    Parameters

    • animationName: string

      The name of the animation.

    Returns void

enableAnimation

  • enableAnimation(animationName: string): void
  • Enables the animation on the actor. Animation will start playing immediately.

    Parameters

    • animationName: string

      The name of the animation.

    Returns void

enableLight

  • enableLight(light?: Partial<LightLike>): void

enableLookAt

  • enableLookAt(actorOrActorId: Actor | string, mode?: LookAtMode, backward?: boolean): void
  • Instruct the actor to face another object, or stop facing an object.

    Parameters

    • actorOrActorId: Actor | string

      The Actor or id of the actor to face.

    • Optional mode: LookAtMode
    • Optional backward: boolean

      (Optional) If true, actor faces away from target rather than toward.

    Returns void

enableRigidBody

enableText

  • enableText(text?: Partial<TextLike>): void

findChildrenByName

  • findChildrenByName(name: string, recurse: boolean): Actor[]
  • Finds child actors matching name.

    Parameters

    • name: string

      The name of the actors to find.

    • recurse: boolean

      Whether or not to search recursively.

    Returns Actor[]

onAnimationDisabled

  • onAnimationDisabled(handler: function): this
  • Set an event handler for the animation-disabled event.

    Parameters

    • handler: function

      The handler to call when an animation reaches the end or is otherwise disabled.

        • (animationName: string): any
        • Parameters

          • animationName: string

          Returns any

    Returns this

onAnimationEnabled

  • onAnimationEnabled(handler: function): this
  • Set an event handler for the animation-enabled event.

    Parameters

    • handler: function

      The handler to call when an animation moves from the disabled to enabled state.

        • (animationName: string): any
        • Parameters

          • animationName: string

          Returns any

    Returns this

onCollisionEnter

  • onCollisionEnter(handler: function): this
  • Add an event handler for the collision enter event.

    Parameters

    • handler: function

      The handler to call when the collision event is raised.

    Returns this

onCollisionExit

  • onCollisionExit(handler: function): this
  • Add an event handler for the collision exit event.

    Parameters

    • handler: function

      The handler to call when the collision event is raised.

    Returns this

onGrab

  • onGrab(grabState: "begin" | "end", handler: ActionHandler): void
  • Add a grad handler to be called when the given action state has changed.

    Parameters

    • grabState: "begin" | "end"

      The grab state to fire the handler on.

    • handler: ActionHandler

      The handler to call when the grab state has changed.

    Returns void

onTriggerEnter

  • onTriggerEnter(handler: function): this
  • Add an event handler for the trigger enter event.

    Parameters

    • handler: function

      The handler to call when the collision event is raised.

    Returns this

onTriggerExit

  • onTriggerExit(handler: function): this
  • Add an event handler for the trigger exit event.

    Parameters

    • handler: function

      The handler to call when the collision event is raised.

    Returns this

pauseAnimation

  • pauseAnimation(animationName: string): void
  • Stops the animation (sets animation speed to zero).

    Parameters

    • animationName: string

      The name of the animation.

    Returns void

resumeAnimation

  • resumeAnimation(animationName: string): void
  • Starts the animation (sets animation speed to 1).

    Parameters

    • animationName: string

      The name of the animation.

    Returns void

setAnimationState

setAnimationTime

  • setAnimationTime(animationName: string, time: number): void
  • Sets the animation time (units are in seconds).

    Parameters

    • animationName: string

      The name of the animation.

    • time: number

      The desired animation time. A negative value seeks to the end of the animation.

    Returns void

setBehavior

  • setBehavior<BehaviorT>(behavior: object): BehaviorT
  • Sets the behavior on this actor.

    Type parameters

    Parameters

    • behavior: object

      The type of behavior to set. Pass null to clear the behavior.

    Returns BehaviorT

startSound

subscribe

toJSON

unsubscribe

Static CreateEmpty

Static CreateFromGLTF

Static CreateFromGltf

Static CreateFromLibrary

Static CreateFromPrefab

Static CreatePrimitive