Options
All
  • Public
  • Public/Protected
  • All
Menu

Class ContextService

Provides a means of querying the current state of reality.

Hierarchy

  • ContextService

Index

Constructors

constructor

Properties

Private _entityPoseMap

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

Private _frameIndex

_frameIndex: number = -1

Private _getEntityOrientationInReferenceFrame

_getEntityOrientationInReferenceFrame: getEntityOrientationInReferenceFrame = getEntityOrientationInReferenceFrame

Private _getEntityPositionInReferenceFrame

_getEntityPositionInReferenceFrame: getEntityPositionInReferenceFrame = getEntityPositionInReferenceFrame

Private _getSerializedEntityState

_getSerializedEntityState: getSerializedEntityState = getSerializedEntityState

Private _knownEntities

_knownEntities: Set<string> = new Set<string>()

Private _localOrigin

_localOrigin: Entity = this.entities.add(new Entity({id: 'ar.localOrigin',name: 'Local Origin',position: new ConstantPositionProperty(Cartesian3.ZERO, this.origin),orientation: new ConstantProperty(Quaternion.IDENTITY)}))

Private _localOriginEastNorthUp

_localOriginEastNorthUp: Entity = this.entities.add(new Entity({id: 'ar.localOriginENU',name: 'Local Origin (ENU)',position: new ConstantPositionProperty(Cartesian3.ZERO, this.localOriginEastNorthUp),orientation: new ConstantProperty(Quaternion.fromAxisAngle(Cartesian3.UNIT_X, -Math.PI / 2))}))

Private _originChanged

_originChanged: boolean = false

Private _scratchCartesian

_scratchCartesian: Cartesian3 = new Cartesian3

Private _scratchFrustum

_scratchFrustum: PerspectiveFrustum = new PerspectiveFrustum()

Private _scratchMatrix3

_scratchMatrix3: Matrix3 = new Matrix3

Private _scratchMatrix4

_scratchMatrix4: Matrix4 = new Matrix4

Private _scratchQuaternion

_scratchQuaternion: Quaternion = new Quaternion

Private _serializedFrameState

_serializedFrameState: ContextFrameState

Private _stringIdentifierFromReferenceFrame

_stringIdentifierFromReferenceFrame: stringIdentifierFromReferenceFrame = stringIdentifierFromReferenceFrame

Private _updatingEntities

_updatingEntities: Set<string> = new Set<string>()

defaultReferenceFrame

defaultReferenceFrame: Entity = this.origin

The default reference frame to use when calling getEntityPose. By default, this is the origin reference frame.

deltaTime

deltaTime: number = 0

The time in milliseconds since the previous timestamp, capped to ContextService.maxDeltaTime

Protected deviceService

deviceService: DeviceService

Protected entityService

entityService: EntityService

floor

floor: Entity = this.entities.add(new Entity({id: 'ar.floor',name: 'Floor',position: new ConstantPositionProperty(Cartesian3.ZERO, this.stage),orientation: new ConstantProperty(Quaternion.IDENTITY)}))

A coordinate system representing the floor. While the stage always represents a physical surface, the floor entity may represent a virtual floor.

maxDeltaTime

maxDeltaTime: number = 1 / 3 * 1000

This value caps the deltaTime for each frame. By default, the value is 1/3s (333.3ms)

origin

origin: Entity = this.entities.add(new Entity({id: 'ar.origin',name: 'Origin',position: new ConstantPositionProperty(undefined, ReferenceFrame.FIXED),orientation: new ConstantProperty(undefined)}))

An entity representing the local origin, which is oriented with +Y up. The local origin changes infrequently, is platform dependent, and is the suggested origin for a rendering scenegraph.

Any time the local origin changes, the localOriginChange event is raised.

originChangeEvent

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

An event that fires when the origin changes.

postRenderEvent

postRenderEvent: Event<ContextService> = new Event<ContextService>()

An event that is raised after the render event

renderEvent

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

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

Protected sessionService

sessionService: SessionService

stage

stage: Entity = this.entities.add(new Entity({id: 'ar.stage',name: 'Stage',position: new ConstantPositionProperty(undefined, ReferenceFrame.FIXED),orientation: new ConstantProperty(undefined)}))

A coordinate system representing the physical space in which the user is free to move around, positioned on the surface the user is standing on, where +X is east, +Y is up, and +Z is south (East-Up-South), if geolocation is known. If the stage is not geolocated, then the +X and +Z directions are arbitrary.

subscribe

subscribe: any = this.entityService.subscribe.bind(this.entityService)

Subscribe to pose updates for the given entity id

returns

A Promise that resolves to a new or existing entity instance matching the given id, if the subscription is successful

time

time: JulianDate = new JulianDate(0,0)

The current (absolute) time according to the current reality. This value is arbitrary until the first ContextService.updateEvent.

timestamp

timestamp: number = -1

A monotonically increasing value (in milliseconds) for the current frame state. This value is useful only for doing accurate timing, not for determining the absolute time. Use ContextService.time for absolute time. This value is -1 until the first ContextService.updateEvent.

unsubscribe

unsubscribe: any = this.entityService.unsubscribe.bind(this.entityService)

Unsubscribe to pose updates for the given entity id

updateEvent

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

An event that is raised after managed entities have been updated for the current frame.

user

user: Entity = this.entities.add(new Entity({id: 'ar.user',name: 'User',position: new ConstantPositionProperty(undefined, this.stage),orientation: new ConstantProperty(undefined)}))

An coordinate system representing the user, where +X is right, +Y is up, and -Z is the direction the user is facing

view

view: Entity = this.entities.add(new Entity({id: 'ar.view',name: 'View',position: new ConstantPositionProperty(Cartesian3.ZERO, this.user),orientation: new ConstantProperty(Quaternion.IDENTITY)}))

An coordinate system representing the rendering view, where +X is right, +Y is up, and -Z is the direction of the view.

Protected viewService

viewService: ViewService

Accessors

entities

  • get entities(): EntityCollection

geoHeadingAccuracy

  • get geoHeadingAccuracy(): number | undefined

geoHorizontalAccuracy

  • get geoHorizontalAccuracy(): number | undefined

geoVerticalAccuracy

  • get geoVerticalAccuracy(): number | undefined

geoposeHeadingAccuracy

  • get geoposeHeadingAccuracy(): number | undefined
  • If geopose is available, this is the accuracy of the user's heading

    Returns number | undefined

geoposeHorizontalAccuracy

  • get geoposeHorizontalAccuracy(): number | undefined
  • If geopose is available, this is the accuracy of the user's cartographic location

    Returns number | undefined

geoposeVerticalAccuracy

  • get geoposeVerticalAccuracy(): number | undefined
  • If geopose is available, this is the accuracy of the user's elevation

    Returns number | undefined

localOrigin

  • get localOrigin(): Entity

localOriginChangeEvent

  • get localOriginChangeEvent(): Event<void>

localOriginEastNorthUp

  • get localOriginEastNorthUp(): Entity

localOriginEastUpSouth

  • get localOriginEastUpSouth(): Entity

serializedFrameState

Private systemTime

  • get systemTime(): number

Methods

Private _update

Private _updateBackwardsCompatability

createEntityPose

  • createEntityPose(entityOrId: Entity | string, referenceFrameOrId?: string | ReferenceFrame | Entity): EntityPose
  • Create a new EntityPose instance to represent the pose of an entity relative to a given reference frame. If no reference frame is specified, then the pose is based on the context's defaultReferenceFrame.

    Parameters

    • entityOrId: Entity | string

      the entity to track

    • Default value referenceFrameOrId: string | ReferenceFrame | Entity = this.defaultReferenceFrame

      The intended reference frame. Defaults to this.defaultReferenceFrame.

    Returns EntityPose

createFrameState

createGeoEntity

  • createGeoEntity(cartographic: Cartographic, localToFixed: eastNorthUpToFixedFrame): Entity
  • Deprecated. Use EntityService.createFixed (app.entity.createFixed);

    Parameters

    • cartographic: Cartographic
    • localToFixed: eastNorthUpToFixedFrame

    Returns Entity

Private getDefaultReferenceFrame

  • getDefaultReferenceFrame(): Entity
  • Deprecated. To be removed. Use the defaultReferenceFrame property.

    Returns Entity

getEntityCartographic

  • getEntityCartographic(entity: Entity, result?: Cartographic): Cartographic | undefined
  • Get the cartographic position of an Entity for the current context time

    Parameters

    • entity: Entity
    • Optional result: Cartographic

    Returns Cartographic | undefined

getEntityPose

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

    deprecated

    Parameters

    • entityOrId: Entity | string

      The entity whose state is to be queried.

    • Default value referenceFrameOrId: string | ReferenceFrame | Entity = this.defaultReferenceFrame

      The intended reference frame. Defaults to this.defaultReferenceFrame.

    Returns EntityPose

getSubviewEntity

  • getSubviewEntity(index: number): Entity

Private getTime

  • getTime(): JulianDate

Private setDefaultReferenceFrame

  • setDefaultReferenceFrame(origin: Entity): void
  • Deprecated. To be removed. Use the defaultReferenceFrame property if necessary.

    Parameters

    • origin: Entity

    Returns void

submitFrameState

subscribeGeolocation

subscribeToEntityById

  • subscribeToEntityById(id: string): Entity
  • Subscribe to pose updates for an entity specified by the given id

    deprecated

    Use [[ContextService#subscribe]]

    Parameters

    • id: string

      the id of the desired entity

    Returns Entity

    A new or existing entity instance matching the given id

unsubscribeGeolocation

  • unsubscribeGeolocation(): void

Object literals

Private _scratchFrameState

_scratchFrameState: object

entities

entities: object

Type declaration

subviews

subviews: Array<undefined> = []

time

time: any = <any>{}

viewport

viewport: any = <any>{}

Generated using TypeDoc