getOffsetReferenceSpace method
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.
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.
Implementation
external XRReferenceSpace getOffsetReferenceSpace(
XRRigidTransform originOffset);