Table of Contents

Class XRView

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll
NOTE
Experimental
The WebXR Device API's XRView interface describes a single view into the XR scene for a specific frame, providing orientation and position information for the viewpoint. You can think of it as a description of a specific eye or camera and how it views the world. A 3D frame will involve two views, one for each eye, separated by an appropriate distance which approximates the distance between the viewer's eyes. This allows the two views, when projected in isolation into the appropriate eyes, to simulate a 3D world.
[Value("XRView")]
public class XRView
Inheritance
XRView
Inherited Members

Remarks

Constructors

XRView()

public XRView()

Properties

Camera

[Value("camera")]
public XRCamera? Camera { get; }

Property Value

XRCamera

Eye

NOTE
Experimental
The XRView interface's read-only eye
property is a string indicating which eye's viewpoint the XRView represents: left or
right. For views which represent neither eye, such as monoscopic views,
this property's value is none.
[Value("eye")]
public XREye Eye { get; }

Property Value

XREye

A string that can be one of the following values:

Remarks

IsFirstPersonObserver

NOTE
Experimental
The XRView interface's read-only isFirstPersonObserver property is a boolean indicating if the XRView is a first-person observer view.
[Value("isFirstPersonObserver")]
public bool IsFirstPersonObserver { get; }

Property Value

bool

Remarks

To create video recordings of AR device cameras, you can't simply use one of the rendered eyes, as there often will be a physical offset. Some devices expose a secondary view, the first-person observer view, which has an eye of none.

To receive a first-person observer view, you need to enable the "secondary-views" feature descriptor explicitly (typically as an optional feature). See RequestSession(XRSessionMode, XRSessionInit) for details.

The isFirstPersonObserver property then allows you to check which secondary view is a first-person observer view.

See also on MDN

ProjectionMatrix

NOTE
Experimental
The XRView interface's read-only
projectionMatrix property specifies the projection matrix
to apply to the underlying view. This should be used to integrate perspective to
everything in the scene, in order to ensure the result is consistent with what the eye
expects to see.
[Value("projectionMatrix")]
public Float32Array ProjectionMatrix { get; }

Property Value

Float32Array

A Float32Array object representing the projection matrix for the view.
The projection matrix for each eye's view is used to ensure that the correct area of the
scene is presented to each eye in order to create a believable 3D scene without
introducing discomfort for the user.

Remarks

NOTE

Failure to apply proper perspective, or inconsistencies
in perspective, may result in possibly serious user discomfort or distress.

See also on MDN

RecommendedViewportScale

NOTE
Experimental
The read-only recommendedViewportScale property of the XRView interface is the recommended viewport scale value that you can use for RequestViewportScale(Number?) if the user agent has such a recommendation; null otherwise.
[Value("recommendedViewportScale")]
public Number? RecommendedViewportScale { get; }

Property Value

Number

A number greater than 0.0 and less than or equal to 1.0; or null if the user agent does not provide a recommended scale.

Remarks

Transform

NOTE
Experimental
The read-only transform property of the
XRView interface is an XRRigidTransform object which
provides the position and orientation of the viewpoint relative to the
XRReferenceSpace specified when the
GetViewerPose(XRReferenceSpace) method was called to obtain the view object.
[Value("transform")]
public XRRigidTransform Transform { get; }

Property Value

XRRigidTransform

A XRRigidTransform object specifying the position and orientation of the
viewpoint represented by the XRView.

Remarks

With the transform, you can then position the view as a camera within the
3D scene. If you instead need the more traditional view matrix, you can get using
view.transform.inverse.matrix; this gets the underlying
Matrix of the transform's
Inverse.

See also on MDN

Methods

RequestViewportScale(Number?)

NOTE
Experimental
The requestViewportScale() method of the XRView interface requests that the user agent sets the requested viewport scale for this viewport to the given value. This is used for dynamic viewport scaling which allows rendering to a subset of the WebXR viewport using a scale factor that can be changed every animation frame.
[Value("requestViewportScale")]
public GlobalObject.Undefined RequestViewportScale(Number? scale)

Parameters

scale Number

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks