Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ContextService

Provides a means of querying the current state of reality.

This class adds the following message handlers to any sessions managed by the session service:

  • ar.context.subscribe - Subscribes the session to updates from an entity with the provided id.
    • Parameters:
      • id: string - The id of an entity the session wishes to recieve updates on.

This service sends the following messages to managed sessions

  • ar.context.update - Indicates to this context that the session wants to be focused on.

Hierarchy

  • ContextService

Index

Constructors

constructor

Properties

Private _defaultReferenceFrame

_defaultReferenceFrame: unknown = this.localOriginEastNorthUp

Private _entityPoseCache

_entityPoseCache: SerializedEntityPoseMap

Private _entityPoseMap

_entityPoseMap: unknown = new Map<string, EntityPose | undefined>()

Private _knownEntities

_knownEntities: unknown = new Set<string>()

Private Optional _serializedState

_serializedState: SerializedFrameState

Private _subscribedEntities

_subscribedEntities: unknown = new WeakMap<SessionPort, Set<string> | undefined>()

Private _updatingEntities

_updatingEntities: unknown = new Set<string>()

entities

entities: unknown = new CompositeEntityCollection()

The set of entities that this session is aware of.

localOriginChangeEvent

localOriginChangeEvent: Event<void> = new Event<void>()

An event that fires when the local origin changes.

localOriginEastNorthUp

localOriginEastNorthUp: Entity = new Entity({id: 'ar.localENU',name: 'localOriginENU',position: new ConstantPositionProperty(undefined, ReferenceFrame.FIXED),orientation: new ConstantProperty(Quaternion.IDENTITY)})

An entity positioned near the user, aligned with the local East-North-Up coordinate system.

localOriginEastUpSouth

localOriginEastUpSouth: Entity = new Entity({id: 'ar.localEUS',name: 'localOriginEUS',position: new ConstantPositionProperty(Cartesian3.ZERO, this.localOriginEastNorthUp),orientation: new ConstantProperty(Quaternion.fromAxisAngle(Cartesian3.UNIT_X, Math.PI / 2))})

An entity positioned near the user, aligned with the East-Up-South coordinate system. This useful for converting to the Y-Up convention used in some libraries, such as three.js.

maxDeltaTime

maxDeltaTime: number = 1 / 3 * 1000

This value caps the deltaTime for each frame

Private realityService

realityService: RealityService

renderEvent

renderEvent: Event<Frame> = new Event<Frame>()

An event that is raised when it is an approriate time to render graphics. This event fires after the update event.

Private sessionService

sessionService: SessionService

subscribedEntities

subscribedEntities: unknown = new EntityCollection()

The set of subscribed entities.

updateEvent

updateEvent: Event<Frame> = new Event<Frame>()

An event that is raised when all remotely managed entities are are up-to-date for the current frame. It is suggested that all modifications to locally managed entities should occur within this event.

user

user: Entity = new Entity({id: 'ar.user',name: 'user',position: new ConstantPositionProperty(undefined, ReferenceFrame.FIXED),orientation: new ConstantProperty(Quaternion.IDENTITY)})

An entity representing the location and orientation of the user.

wellKnownReferenceFrames

wellKnownReferenceFrames: unknown = new EntityCollection()

The set of entities representing well-known reference frames. These are assumed to be readily available to applications.

Accessors

frame

serializedFrameState

Methods

Private _addEntityAndAncestorsToPoseMap

Private _sendUpdateForSession

Private _update

Private _updateLocalOrigin

getCurrentEntityState

  • getCurrentEntityState(entity: Entity, referenceFrame: any): EntityPose

getDefaultReferenceFrame

  • getDefaultReferenceFrame(): Entity
  • Get the default reference frame to use when calling getEntityPose. By default, this is the localOriginEastNorthUp reference frame.

    Returns Entity

getEntityPose

  • getEntityPose(entity: Entity, referenceFrame?: ReferenceFrame | Entity): EntityPose
  • Gets the current pose of an entity, relative to a given reference frame.

    Parameters

    • entity: Entity

      The entity whose state is to be queried.

    • Default value referenceFrame: ReferenceFrame | Entity = this._defaultReferenceFrame

      The intended reference frame. Defaults to this.defaultReferenceFrame.

    Returns EntityPose

    If the position and orientation exist for the given entity, an object with the fields position and orientation, both of type Cartesian3. Otherwise undefined.

getTime

  • getTime(): JulianDate

publishEntityState

  • publishEntityState(entity: Entity, referenceFrame: ReferenceFrame | Entity): void
  • Parameters

    • entity: Entity
    • referenceFrame: ReferenceFrame | Entity

    Returns void

setDefaultReferenceFrame

  • setDefaultReferenceFrame(origin: Entity): void
  • Set the default reference frame for getCurrentEntityState.

    Parameters

    • origin: Entity

    Returns void

subscribeToEntityById

  • subscribeToEntityById(id: string): Entity
  • Adds an entity to this session's set of tracked entities.

    Parameters

    • id: string

      The unique identifier of an entity.

    Returns Entity

    The entity that was subscribed to.

updateEntityFromFrameState

Object literals

Private _frame

_frame: object

deltaTime

deltaTime: number = 0

systemTime

systemTime: number = 0

time

time: unknown = new JulianDate(0, 0)

Generated using TypeDoc