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

exclusiveToUser

  • get exclusiveToUser(): Guid
  • When supplied, this actor will be unsynchronized, and only exist on the client of the User with the given ID. This value can only be set at actor creation. Any actors parented to this actor will also be exclusive to the given user.

    inheritdoc

    Returns Guid

grabbable

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

id

light

lookAt

name

  • get name(): string

owner

  • get owner(): Guid
  • set owner(value: Guid): void

parent

  • get parent(): Actor
  • set parent(value: Actor): void

parentId

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

rigidBody

subscriptions

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

tag

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

targetingAnimations

targetingAnimationsByName

text

transform

Methods

animateTo

  • animateTo(value: Partial<ActorLike>, duration: number, curve: number[]): Promise<void>
  • deprecated

    Use Animation.AnimateTo instead.

    Parameters

    • value: Partial<ActorLike>

      The desired final state of the actor.

    • duration: number

      The length of the interpolation (in seconds).

    • curve: number[]

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

    Returns Promise<void>

attach

  • Attach to the user at the given attach point.

    Parameters

    • userOrUserId: User | Guid

      The User or id of user to attach to.

    • attachPoint: AttachPoint

      Where on the user to attach.

    Returns void

created

  • created(): Promise<void>
  • Creates a Promise that will resolve once the actor is created on the host.

    Returns Promise<void>

    Promise

destroy

  • destroy(): void

detach

  • detach(): void

enableLight

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

enableLookAt

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

    Parameters

    • actorOrActorId: Actor | Guid

      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

findAnimationInChildrenByName

  • findAnimationInChildrenByName(name: string): Animation

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

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

setBehavior

  • setBehavior<BehaviorT>(behavior: { constructor: any }): BehaviorT
  • Sets the behavior on this actor.

    Type parameters

    Parameters

    • behavior: { constructor: any }

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

    Returns BehaviorT

setCollider

  • setCollider(colliderType: Sphere, isTrigger: boolean, radius?: number, center?: Vector3Like): void
  • setCollider(colliderType: Box, isTrigger: boolean, size?: Vector3Like, center?: Vector3Like): void
  • setCollider(colliderType: Capsule, isTrigger: boolean, size?: Vector3Like, center?: Vector3Like): void
  • setCollider(colliderType: Auto, isTrigger: boolean): void
  • Adds a collider of the given type and parameters on the actor.

    Parameters

    • colliderType: Sphere

      Type of the collider to enable.

    • isTrigger: boolean

      Whether the collider is a trigger volume or not.

    • Optional radius: number

      The radius of the collider. If omitted, a best-guess radius is chosen based on the size of the currently assigned mesh (loading meshes are not considered). If no mesh is assigned, defaults to 0.5.

    • Optional center: Vector3Like

      The center of the collider, or default of the object if none is provided.

    Returns void

  • Adds a collider of the given type and parameters on the actor.

    Parameters

    • colliderType: Box

      Type of the collider to enable.

    • isTrigger: boolean

      Whether the collider is a trigger volume or not.

    • Optional size: Vector3Like

      The dimensions of the collider. If omitted, a best-guess size is chosen based on the currently assigned mesh (loading meshes are not considered). If no mesh is assigned, defaults to (1,1,1).

    • Optional center: Vector3Like

      The center of the collider, or default of the object if none is provided.

    Returns void

  • Adds a collider of the give type and parameters on the actor.

    Parameters

    • colliderType: Capsule

      Type of the collider to enable.

    • isTrigger: boolean

      Whether the collider is a trigger volume or not.

    • Optional size: Vector3Like

      The dimensions of the collider, with the largest component of the vector being the primary axis and height of the capsule (including end caps), and the smallest the diameter. If omitted, a best-guess size is chosen based on the currently assigned mesh (loading meshes are not considered). If no mesh is assigned, defaults to (1, 1, 1).

    • Optional center: Vector3Like

      The center of the collider, or default of the object if none is provided.

    Returns void

  • Adds a collider whose shape is determined by the current mesh.

    Parameters

    • colliderType: Auto

      Type of the collider to enable.

    • isTrigger: boolean

      Whether the collider is a trigger volume or not.

    Returns void

startSound

startVideoStream

subscribe

unsubscribe

Static Create

  • Creates a new, empty actor without geometry.

    Parameters

    • context: Context

      The SDK context object.

    • Optional options: { actor?: Partial<ActorLike> }
      • Optional actor?: Partial<ActorLike>

        The initial state of the actor.

    Returns Actor

Static CreateEmpty

Static CreateFromGltf

  • Load a glTF model, and spawn the first prefab in the resulting assets. Equivalent to using AssetContainer.loadGltf and Actor.CreateFromPrefab.

    Parameters

    • container: AssetContainer

      The asset container to load the glTF assets into

    • options: { actor?: Partial<ActorLike>; colliderType?: "box" | "mesh"; uri: string }
      • Optional actor?: Partial<ActorLike>

        The initial state of the actor

      • Optional colliderType?: "box" | "mesh"

        The type of collider to add to each mesh actor

      • uri: string

        A URI to a .gltf or .glb file

    Returns Actor

Static CreateFromLibrary

  • CreateFromLibrary(context: Context, options: { actor?: Partial<ActorLike>; resourceId: string }): Actor
  • Creates a new actor from a library resource, which is host-dependent. For AltspaceVR, the available resource ID formats are:

    • teleporter:event/<event_id>[?label=true], with an Altspace event ID, which you can get from the URL of an event's page on https://account.altvr.com.
    • teleporter:space/<space_id>[?label=true]
    • teleporter:<event_or_space_id>[?label=true]
    • artifact:<artifact_id>, with an Altspace artifact ID from https://account.altvr.com/kits.

    Parameters

    • context: Context

      The SDK context object.

    • options: { actor?: Partial<ActorLike>; resourceId: string }
      • Optional actor?: Partial<ActorLike>

        The initial state of the root actor.

      • resourceId: string

        The id of the library resource to instantiate.

    Returns Actor

Static CreateFromPrefab

  • Creates a new actor hierarchy from the provided prefab.

    Parameters

    • context: Context

      The SDK context object.

    • options: { actor?: Partial<ActorLike>; collisionLayer?: CollisionLayer; prefabId: Guid }
      • Optional actor?: Partial<ActorLike>

        The initial state of the root actor.

      • Optional collisionLayer?: CollisionLayer

        If the prefab contains colliders, put them on this layer.

      • prefabId: Guid

        The ID of a prefab asset to spawn.

    Returns Actor

  • Creates a new actor hierarchy from the provided prefab.

    Parameters

    • context: Context

      The SDK context object.

    • options: { actor?: Partial<ActorLike>; collisionLayer?: CollisionLayer; prefab: Prefab }
      • Optional actor?: Partial<ActorLike>

        The initial state of the root actor.

      • Optional collisionLayer?: CollisionLayer

        If the prefab contains colliders, put them on this layer.

      • prefab: Prefab

        The prefab asset to spawn.

    Returns Actor

  • Creates a new actor hierarchy from the provided prefab.

    Parameters

    • context: Context

      The SDK context object.

    • options: { actor?: Partial<ActorLike>; collisionLayer?: CollisionLayer; firstPrefabFrom: Asset[] }
      • Optional actor?: Partial<ActorLike>

        The initial state of the root actor.

      • Optional collisionLayer?: CollisionLayer

        If the prefab contains colliders, put them on this layer.

      • firstPrefabFrom: Asset[]

        An asset array containing at least one prefab.

    Returns Actor

Static CreatePrimitive

Static sanitize