Class XRSession
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
NOTE
ExperimentalXRSession interface of the WebXR Device API represents an ongoing XR session, providing methods and properties used to interact with and control the session. To open a WebXR session, use the XRSystem interface's RequestSession(XRSessionMode, XRSessionInit) method.
[Value("XRSession")]
public class XRSession : EventTarget
- Inheritance
-
XRSession
- Inherited Members
Remarks
With XRSession methods, you can poll the viewer's position and orientation (the XRViewerPose), gather information about the user's environment, and present imagery to the user. XRSession supports both inline and immersive virtual and augmented reality modes.
Constructors
XRSession()
public XRSession()
Properties
DepthDataFormat
NOTE
ExperimentaldepthDataFormat property of an immersive-arXRSession describes which depth sensing data format is used.
[Value("depthDataFormat")]
public XRDepthDataFormat DepthDataFormat { get; }
Property Value
- XRDepthDataFormat
This property can return the following values:
Remarks
DepthUsage
NOTE
ExperimentaldepthUsage property of an immersive-arXRSession describes which depth-sensing usage is used.
[Value("depthUsage")]
public XRDepthUsage DepthUsage { get; }
Property Value
- XRDepthUsage
This property can return the following values:
Remarks
DomOverlayState
NOTE
ExperimentaldomOverlayState property of an immersive-arXRSession provides information about the DOM overlay, if the feature is enabled.
[Value("domOverlayState")]
public XRDOMOverlayState? DomOverlayState { get; }
Property Value
- XRDOMOverlayState
Returns
nullif the DOM overlay feature is not supported or not enabled or an object containing information about the DOM overlay state with the following properties:
Remarks
-Element.Beforexrselect
EnabledFeatures
NOTE
ExperimentalenabledFeatures property returns an array of features enabled (granted) for an XRSession. This contains all requiredFeatures and a subset of optionalFeatures that have been requested with RequestSession(XRSessionMode, XRSessionInit).
[Value("enabledFeatures")]
public string[] EnabledFeatures { get; }
Property Value
Remarks
EnvironmentBlendMode
NOTE
ExperimentalenvironmentBlendModeproperty identifies if, and to what degree, the computer-generated imagery is overlaid atop the real world.
[Value("environmentBlendMode")]
public XREnvironmentBlendMode EnvironmentBlendMode { get; }
Property Value
- XREnvironmentBlendMode
A string defining if and how virtual, rendered content is overlaid atop the image of the real world.Possible values are:
Remarks
This is used to differentiate between fully-immersive VR sessions and AR sessions which render
over a pass-through image of the real world, possibly partially transparently.
FrameRate
[Value("frameRate")]
public Number? FrameRate { get; }
Property Value
InputSources
NOTE
ExperimentalinputSources property of theXRSession interface returns an XRInputSourceArray object
which lists all controllers and input devices which are expressly associated with the
XR device and are currently available. These controllers may include handheld
controllers, XR-equipped gloves, optically tracked hands, and gaze-based input methods.
Keyboards, gamepads, and mice are not considered WebXR input sources.
[Value("inputSources")]
public XRInputSourceArray InputSources { get; }
Property Value
- XRInputSourceArray
An XRInputSourceArray object listing all of the currently-connected
input controllers which are linked specifically to the XR device currently in use. The
returned object is live; as devices are connected to and removed from
the user's system, the list's contents update to reflect the changes.
Remarks
NOTE
Traditional gamepad controllers are supported using the Gamepad API.
-XRInputSource
-The XRSession.Inputsourceschange event
-Gamepad API
InteractionMode
NOTE
ExperimentalinteractionMode propertydescribes the best space (according to the user agent) for the application to draw an interactive UI for the current session.
[Value("interactionMode")]
public XRInteractionMode InteractionMode { get; }
Property Value
- XRInteractionMode
A string describing the best space (according to the user agent) for the application to draw an interactive UI
for the current session.Possible values are:
Remarks
IsSystemKeyboardSupported
[Value("isSystemKeyboardSupported")]
public bool IsSystemKeyboardSupported { get; }
Property Value
Onend
[Value("onend")]
public EventHandlerNonNull Onend { get; set; }
Property Value
Onframeratechange
[Value("onframeratechange")]
public EventHandlerNonNull Onframeratechange { get; set; }
Property Value
Oninputsourceschange
[Value("oninputsourceschange")]
public EventHandlerNonNull Oninputsourceschange { get; set; }
Property Value
Onselect
[Value("onselect")]
public EventHandlerNonNull Onselect { get; set; }
Property Value
Onselectend
[Value("onselectend")]
public EventHandlerNonNull Onselectend { get; set; }
Property Value
Onselectstart
[Value("onselectstart")]
public EventHandlerNonNull Onselectstart { get; set; }
Property Value
Onsqueeze
[Value("onsqueeze")]
public EventHandlerNonNull Onsqueeze { get; set; }
Property Value
Onsqueezeend
[Value("onsqueezeend")]
public EventHandlerNonNull Onsqueezeend { get; set; }
Property Value
Onsqueezestart
[Value("onsqueezestart")]
public EventHandlerNonNull Onsqueezestart { get; set; }
Property Value
Onvisibilitychange
[Value("onvisibilitychange")]
public EventHandlerNonNull Onvisibilitychange { get; set; }
Property Value
PersistentAnchors
[Value("persistentAnchors")]
public string[] PersistentAnchors { get; }
Property Value
- string[]
PreferredReflectionFormat
NOTE
ExperimentalpreferredReflectionFormat property of the XRSession interface returns this session's preferred reflection format used for lighting estimation texture data.
[Value("preferredReflectionFormat")]
public XRReflectionFormat PreferredReflectionFormat { get; }
Property Value
- XRReflectionFormat
A string representing the reflection format. Possible values:
XRReflectionFormat WebGL Format WebGL Internal Format WebGPU Format HDR "srgba8" RGBA SRGB8_ALPHA8 "rgba8unorm-srgb" "rgba16f" RGBA RGBA16F "rgba16float" ✓
Remarks
RenderState
NOTE
Experimentalread-only
renderState property of anXRSession object indicates the returns a XRRenderState
object describing how the user's environment which should be rendered. The
information provided covers the minimum and maximum distance at which to render objects,
the vertical field of view to use when rendering the in the
inline sessionmode, and the XRWebGLLayer to render into for inline composition.
[Value("renderState")]
public XRRenderState RenderState { get; }
Property Value
- XRRenderState
An XRRenderState object describing how to render the scene.
Remarks
While this property is read only, you can call the XRSession method
UpdateRenderState(XRRenderStateInit) to make changes.
SupportedFrameRates
[Value("supportedFrameRates")]
public Float32Array? SupportedFrameRates { get; }
Property Value
TrackedSources
[Value("trackedSources")]
public XRInputSourceArray TrackedSources { get; }
Property Value
VisibilityState
NOTE
ExperimentalvisibilityState property of theXRSession interface is a string indicating whether the WebXR content is
currently visible to the user, and if it is, whether it's the primary focus.
[Value("visibilityState")]
public XRVisibilityState VisibilityState { get; }
Property Value
- XRVisibilityState
A string indicating whether or not the XR content is
visible to the user and if it is, whether or not it's currently the primary focus.The possible values ofvisibilityStateare:
Remarks
Every time the visibility state changes, a
XRSession.Visibilitychange event is fired on the
XRSession object.
-XRSession.Visibilitychange event
Methods
CancelAnimationFrame(ulong)
NOTE
ExperimentalcancelAnimationFrame() method ofthe XRSession interface cancels an animation frame which was previously
requested by calling RequestAnimationFrame(XRFrameRequestCallback).
[Value("cancelAnimationFrame")]
public GlobalObject.Undefined CancelAnimationFrame(ulong handle)
Parameters
handleulong
Returns
Remarks
-Window.CancelAnimationFrame
-RequestAnimationFrame(XRFrameRequestCallback)
DeletePersistentAnchor(string)
[Value("deletePersistentAnchor")]
public Task<GlobalObject.Undefined> DeletePersistentAnchor(string uuid)
Parameters
uuidstring
Returns
End()
NOTE
Experimentalend() method shuts down theXRSession on which it's called, returning a promise which resolves once
the session has fully shut down.
[Value("end")]
public Task<GlobalObject.Undefined> End()
Returns
- Task<GlobalObject.Undefined>
A Promise that resolves without a value after any platform-specific steps
related to shutting down the session have completed. You can use the promise to do
things like update UI elements to reflect the shut down connection, trigger application
shut down, or whatever else you might need to do.
Remarks
InitiateRoomCapture()
[Value("initiateRoomCapture")]
public Task<GlobalObject.Undefined> InitiateRoomCapture()
Returns
RequestAnimationFrame(XRFrameRequestCallback)
NOTE
Experimentalmethod
requestAnimationFrame(), much like theWindow method of the same name, schedules a callback to be executed the
next time the browser is ready to paint the session's virtual environment to the XR
display. The specified callback is executed once before the next repaint; if
you wish for it to be executed for the following repaint, you must
call
requestAnimationFrame() again. This can be done from within thecallback itself.
[Value("requestAnimationFrame")]
public ulong RequestAnimationFrame(XRFrameRequestCallback callback)
Parameters
callbackXRFrameRequestCallback
Returns
- ulong
An integer value which serves as a unique, non-zero ID or handle you may pass to
CancelAnimationFrame(ulong) if you need to
remove the pending animation frame request.
Remarks
The callback takes two parameters as inputs: an XRFrame describing the
state of all tracked objects for the session, and a timestamp you can use to compute
any animation updates needed.
You can cancel a previously scheduled animation by calling
CancelAnimationFrame(ulong).
NOTE
Despite the obvious similarities between these methods and the
global Window.RequestAnimationFrame function
provided by theWindowinterface, you must not treat these as
interchangeable. There is no guarantee that the latter will work at all while
an immersive XR session is underway.
-Window.RequestAnimationFrame
-CancelAnimationFrame(ulong)
RequestHitTestSource(XRHitTestOptionsInit)
NOTE
ExperimentalrequestHitTestSource() method of theXRSession interface returns a {{jsxref("Promise")}} that resolves with an XRHitTestSource object that can be passed to GetHitTestResults(XRHitTestSource).
[Value("requestHitTestSource")]
public Task<XRHitTestSource> RequestHitTestSource(XRHitTestOptionsInit options)
Parameters
optionsXRHitTestOptionsInit
Returns
- Task<XRHitTestSource>
A {{jsxref("Promise")}} that resolves with an XRHitTestSource object.
Remarks
RequestHitTestSourceForTransientInput(XRTransientInputHitTestOptionsInit)
NOTE
ExperimentalrequestHitTestSourceForTransientInput() method of theXRSession interface returns a {{jsxref("Promise")}} that resolves with an XRTransientInputHitTestSource object that can be passed to GetHitTestResultsForTransientInput(XRTransientInputHitTestSource).
[Value("requestHitTestSourceForTransientInput")]
public Task<XRTransientInputHitTestSource> RequestHitTestSourceForTransientInput(XRTransientInputHitTestOptionsInit options)
Parameters
Returns
- Task<XRTransientInputHitTestSource>
A {{jsxref("Promise")}} that resolves with an XRTransientInputHitTestSource object.
Remarks
RequestLightProbe(XRLightProbeInit)
NOTE
ExperimentalrequestLightProbe() method of theXRSession interface returns a {{jsxref("Promise")}} that resolves with an XRLightProbe object that estimates lighting information at a given point in the user's environment.
[Value("requestLightProbe")]
public Task<XRLightProbe> RequestLightProbe(XRLightProbeInit options = null)
Parameters
optionsXRLightProbeInit
Returns
- Task<XRLightProbe>
A {{jsxref("Promise")}} that resolves with an XRLightProbe object.
Remarks
RequestReferenceSpace(XRReferenceSpaceType)
NOTE
ExperimentalrequestReferenceSpace() method of theXRSession interface returns a {{JSxRef("promise")}} that resolves with
an instance of either XRReferenceSpace
or XRBoundedReferenceSpace as appropriate given the type of reference
space requested.
[Value("requestReferenceSpace")]
public Task<XRReferenceSpace> RequestReferenceSpace(XRReferenceSpaceType type)
Parameters
typeXRReferenceSpaceType
Returns
- Task<XRReferenceSpace>
A {{JSxRef("Promise")}} that resolves with an XRReferenceSpace object.The types of reference space are listed below, with brief information about their use cases and which interface is used to implement them.
Remarks
RestorePersistentAnchor(string)
[Value("restorePersistentAnchor")]
public Task<XRAnchor> RestorePersistentAnchor(string uuid)
Parameters
uuidstring
Returns
UpdateRenderState(XRRenderStateInit)
NOTE
ExperimentalupdateRenderState() method of the XRSession interface of the WebXR API schedules changes to be applied to the active render state (XRRenderState) prior to rendering of the next frame.
[Value("updateRenderState")]
public GlobalObject.Undefined UpdateRenderState(XRRenderStateInit state = null)
Parameters
stateXRRenderStateInit
Returns
Remarks
UpdateTargetFrameRate(Number)
[Value("updateTargetFrameRate")]
public Task<GlobalObject.Undefined> UpdateTargetFrameRate(Number rate)
Parameters
rateNumber