Class XRReferenceSpace
- Namespace
- CSharpToJavaScript.APIs.JS
- Assembly
- CSharpToJavaScript.dll
The WebXR Device API's XRReferenceSpace interface describes the coordinate system for a specific tracked entity or object within the virtual world using a specified tracking behavior. The tracking behavior is defined by the selected reference space type. It expands upon the base class, XRSpace, by adding support for several different tracking behaviors as well as to request a new reference space which describes the offset transform between the tracked object and another location in the world.
[Value("XRReferenceSpace")]
public class XRReferenceSpace : XRSpace
- Inheritance
-
XRReferenceSpace
- Derived
- Inherited Members
Remarks
All reference spaces—with the sole exception being bounded reference spaces—are described using the XRReferenceSpace type. Bounded spaces are implemented as XRBoundedReferenceSpace objects. These are special spaces which let you establish a perimeter within which it's "safe" for the viewer to move. For XR systems that allow the user to physically move around, such as those that track movement with a real-world camera, this boundary establishes the edges of the area the user is able to move around in, whether due to physical obstacles or due to limitations of the XR hardware. See the article Using bounded reference spaces to protect the viewer for more on using boundaries to keep the user from colliding with obstacles both physical and virtual.
-Fundamentals of WebXR
-Geometry and reference spaces in WebXR
-Viewpoints and viewers: Simulating cameras in WebXR
-Matrix math for the web
-Movement, orientation, and motion
-Using bounded reference spaces to protect the user
Constructors
XRReferenceSpace()
public XRReferenceSpace()
Properties
Onreset
[Value("onreset")]
public EventHandlerNonNull Onreset { get; set; }
Property Value
Methods
GetOffsetReferenceSpace(XRRigidTransform)
The XRReferenceSpace
interface's getOffsetReferenceSpace() method returns a
new reference space object which describes the relative difference in position between
the object on which the method is called and a given point in 3D space. The
object returned by getOffsetReferenceSpace() is an
XRReferenceSpace if called on an XRReferenceSpace, or an
XRBoundedReferenceSpace if called on an object of that type.
[Value("getOffsetReferenceSpace")]
public XRReferenceSpace GetOffsetReferenceSpace(XRRigidTransform originOffset)
Parameters
originOffsetXRRigidTransform
Returns
- XRReferenceSpace
A new XRReferenceSpace object describing a reference space with the same
native origin as the reference space on which the method was called, but with an origin
offset indicating the distance from the object to the point given
byoriginOffset.If the object on which you call this method is an
XRBoundedReferenceSpace, the returned object is one as well. The
BoundsGeometry of the new
reference space is set to the original object'sboundsGeometrywith each of
its points multiplied by the inverse oforiginOffset.
Remarks
In other words, when you have an object in 3D space and need to position another object
relative to that one, you can call getOffsetReferenceSpace(), passing into
it the position and orientation you want the second object to have
relative to the position and orientation of the object on which you call getOffsetReferenceSpace().
Then, when drawing the scene, you can use the offset reference space to not only
position objects relative to one another, but to apply the needed transforms to render
objects properly based upon the viewer's position. This is demonstrated in the example
Implementing rotation based on non-XR inputs, which demonstrates a way to
use this method to let the user use their mouse to pitch and yaw their viewing angle.