Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Actor

An actor represents an object instantiated on the host.

Hierarchy

  • Actor

Implements

Index

Accessors

children

  • get children(): Actor[]
  • Returns Actor[]

collider

  • Returns Collider

context

  • Returns Context

id

  • get id(): string
  • Returns string

light

  • Returns Light

material

  • Returns Material

    A shared reference to this actor's material, or null if this actor has no material

  • Parameters

    Returns void

    A shared reference to this actor's material, or null if this actor has no material

materialId

  • get materialId(): string
  • set materialId(value: string): void
  • Returns string

  • Parameters

    • value: string

    Returns void

name

  • get name(): string
  • Returns string

parent

  • Returns Actor

parentId

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

  • Parameters

    • value: string

    Returns void

rigidBody

  • Returns RigidBody

subscriptions

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

tag

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

  • Parameters

    • value: string

    Returns void

text

  • Returns Text

transform

  • Returns Transform

Methods

animateTo

  • animateTo(value: Partial<ActorLike>, duration: number, curve: number[]): Promise<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 Promise<void>

    Returns a Promise that is resolves after the animation completes.

copy

  • Parameters

    Returns this

createAnimation

  • Creates an animation on the actor.

    Parameters

    • animationName: string

      The name of the animation.

    • options: CreateAnimationOptions

      The animation keyframes, events, and other characteristics.

    Returns Promise<void>

created

  • created(): Promise<void>
  • Provides an awaitable object that resolves once the actor has been created on the host.

    Returns Promise<void>

destroy

  • destroy(): void
  • Destroys the actor.

    Returns 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
  • Adds a light component to the actor.

    Parameters

    • Optional light: Partial<LightLike>

      Light characteristics.

    Returns void

enableRigidBody

  • Adds a rigid body component to the actor.

    Parameters

    • Optional rigidBody: Partial<RigidBodyLike>

      Rigid body characteristics.

    Returns void

enableText

  • enableText(text?: Partial<TextLike>): void
  • Adds a text component to the actor.

    Parameters

    • Optional text: Partial<TextLike>

      Text characteristics

    Returns 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[]

lookAt

  • Instruct the actor to face another object, or stop facing an object.

    Parameters

    • targetOrId: Actor | User | string

      The actor, user, or id of the object to face.

    • lookAtMode: LookAtMode

      How to face the target. @see LookUpMode.

    Returns void

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

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

  • (Advanced) Sets the time, speed, and enabled state of an animation.

    Parameters

    Returns void

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

subscribe

  • Subscribe to updates from this actor.

    Parameters

    Returns void

toJSON

  • Returns ActorLike

unsubscribe

  • Unsubscribe from updates from this actor.

    Parameters

    Returns void

Static CreateEmpty

  • Creates a new, empty actor without geometry.

    Parameters

    • context: Context

      The SDK context object.

    • Optional options: object

    Returns ForwardPromise<Actor>

Static CreateFromGLTF

  • deprecated

    Use CreateFromGltf instead.

    Parameters

    Returns ForwardPromise<Actor>

Static CreateFromGltf

  • Creates a new actor from a glTF resource.

    Parameters

    • context: Context

      The SDK context object.

    • options: object

    Returns ForwardPromise<Actor>

Static CreateFromLibrary

Static CreateFromPrefab

  • Creates a new actor hierarchy from the provided prefab.

    Parameters

    • context: Context

      The SDK context object.

    • options: object

    Returns ForwardPromise<Actor>

Static CreatePrimitive

  • Creates a new actor with a primitive shape.

    Parameters

    • context: Context

      The SDK context object.

    • options: object

    Returns ForwardPromise<Actor>