@kognifai/cogsengine
    Preparing search index...

    Class ControlXR

    Hierarchy

    • EventTarget
      • ControlXR
    Index

    Constructors

    • Parameters

      • control: Control

        Owning Cogs.js Control

      Returns ControlXR

    Properties

    _logger: Logger
    _virtualHeading: number = 0
    control: Control
    deltaEnd: number
    deltaTime: number
    foveationAmount: number
    frameBufferScale: number
    options: any
    originCube?: any = undefined
    physicalReferenceSpace?: XRReferenceSpace
    projectionLayer: any
    runtimeXR: RuntimeXR
    sessionMode: number
    squareMatInstance: MaterialInstance = null
    stashedFOV: number = 0
    teleportType: TeleportTypeXR
    testedRayMode: boolean = false
    useLayers: boolean = false
    visionProLongPinchTimestamp: number = 0
    webxrAssetsPath: any
    xrActiveSession: { options: SessionOptionsXR; xrSession: XRSession }
    xrGLFactory: any

    Accessors

    • get viewerOrientation(): number

      Current viewer orientation in virtual space. NOTE: not yet implemented.

      Returns number

    • set virtualHeading(heading: number): void

      Set viewing direction/heading for the viewer programmatically. The client application should keep track of this.

      Parameters

      • heading: number

      Returns void

    • get virtualPosition(): dvec3

      Current position of the viewer in virtual space.

      Returns dvec3

    • set virtualPosition(position: dvec3): void

      Setter for programmatically moving the viewer around. Typically used for teleporting and thumbstick navigation.

      Parameters

      Returns void

    Methods

    • Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.

      The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.

      When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.

      When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.

      When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.

      If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.

      The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject
      • Optionaloptions: boolean | AddEventListenerOptions

      Returns void

    • Attach to an XR session and begin rendering to that session.

      In theory, the control can be attached to multiple sessions at the same time.

      Control will automatically detach from the session when the session ends.

      The following options are supported:

      • forceOpaque: Sets the alpha to 1 (=opaque) for the whole framebuffer after rendering a frame. It has a cost, so it is better to set proper alpha value, but can be used as a quick-fix.
      • layerMask: Can be used to adjust what is visible in the XR view. The effective XR layermask is the main camera's layermask AND'ed with the provided layermask.
      • frameTimeTarget: Will enable automatic adjustment of tolerances if time spent in the rendering function exceeds the target. A target of zero disables any adjustment.

      Parameters

      • xrSession: XRSession

        The session to attach to.

      • options: any = {}

        Object with options.

      Returns void

    • Parameters

      • fadingSpeed: number

      Returns void

    • Returns void

    • Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.

      MDN Reference

      Parameters

      • event: Event

      Returns boolean

    • Returns ControlXREventMap

    • Parameters

      Returns number[]

    • Returns InputXR

    • Returns RuntimeXR

    • Returns SessionOptionsXR

    • Returns XRSession

    • Parameters

      • session: XRSession
      • controller: any

      Returns void

    • Parameters

      • devices: any

      Returns boolean

    • Returns true if no WebXR sessions are active

      Returns boolean

    • Returns boolean

    • Detects if the main squeeze of an existing motion controller was released this frame.

      Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Detects if the main squeeze of an existing motion controller was pressed this frame.

      Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Attach InputSourcesChange Event to the default XRSession.

      The inputsourceschange event is also fired once when the session's creation callback first completes execution, so you can use it to fetch the input source list as soon as it's available at startup time.

      The event is delivered as an XRInputSourceChangeEvent, which includes three properties of interest: session: The XRSession for which the input source have changed added: An array of zero or more XRInputSource objects indicating the newly added objects removed: An array of zero or more XRInputSource objects indicating any removed object from the XRSystem.

      Parameters

      • event: XRInputSourcesChangeEvent

        that gets raised.

      Returns Promise<void>

    • Detects if the user has stopped the pinching gesture and relaxed their hand.

      Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Detects if the user has started a pinching gesture.

      Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Detects if the main trigger of an existing motion controller was released this frame.

      This event will determine what happens to any picked entity (if any) when the trigger is released.

      • Primary controller: Changes the color of the picked entity.
      • Secondary controller: Applies some operations around the picked entity and region. if the region is deemed valid, then the client will teleport to the picked location.

      Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Detects if the main trigger of an existing motion controller was pressed this frame.

      Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Set up the already created session XR Aware session will want to manage some reference spaces in order to enable features such as teleport and picking. This method handles the creation and storage of the spaces.

      Broadcasts a session started event for self managed client programs, forwarding a reference to the xrSession as soon as it is created. This can be captured outside of update cycles, removing unnecessary checks and overhead in client programs..

      Parameters

      • xrSession: XRSession

        session that was successfully created and will be added to the map

      • options: any

        group of session specific parameters.

      • mode: XRSessionMode

      Returns Promise<void>

    • Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      Returns void

    • Thumbstick movement.

      Parameters

      • event: CustomInputSourceEventXR

        that gets raised.

      • speedMultiplier: number = 1

        Amount to multiply the base movement speed with.

      Returns void

    • Returns void

    • Removes the event listener in target's event listener list with the same type, callback, and options.

      MDN Reference

      Parameters

      • type: string
      • callback: EventListenerOrEventListenerObject
      • Optionaloptions: boolean | EventListenerOptions

      Returns void

    • Parameters

      • amount: number

      Returns void

    • Sets the teleporting behaviour.

      Parameters

      Returns void

    • Returns boolean

    • Returns boolean

    • Tries to request a new XRSession Attempts to request the navigator for a new xr session of the given mode

      Parameters

      • mode: XRSessionMode

        one of the valid web_xr session modes.

      • options: any

        Object with options for the xr Session.

      Returns Promise<XRSession>

    • Parameters

      • session: XRSession
      • controller: any

      Returns void

    • Move programatically to given position, given in Cogs coordinates.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns void

    • Move the viewer around in relative, virtual coordinates.

      Parameters

      • x: number
      • y: number
      • z: number

      Returns void

    • Transform given position in physical space to virtual position, using virtual heading.

      Parameters

      • physicalPosition: DOMPointReadOnly

        Position in physical space, absolute or relative to viewer pose.

      Returns dvec3

      Position in virtual space.

    • Compute rotation in virtual space from physical orientation and virtual heading.

      Parameters

      • physicalOrientation: DOMPointReadOnly

        Orientation in physical space

      Returns quat

      Orientation/rotation in virtual space