XRRigidTransform
是
WebXR API
interface that represents the 3D geometric transform described by a position and orientation.
XRRigidTransform
is used to specify transforms throughout the WebXR APIs, including:
getOffsetReferenceSpace()
.
transform
of an
XRView
.
transform
of an
XRPose
.
XRReferenceSpaceEvent
event's
transform
property, as found in the
reset
event received by an
XRReferenceSpace
.
The advantage to using
XRRigidTransform
in these places rather than bare arrays that providing the matrix data is that the
XRRigidTransform
automatically does things like computing the inverse of the transform. Even better, once it's been computed, it's cached so that subsequent requests are significantly faster.
new XRRigidTransform()
XRRigidTransform
object which represents a transform that applies a specified position and/or orientation.
XRRigidTransform.position
只读
DOMPointReadOnly
specifying a 3-dimensional point, expressed in meters, describing the translation component of the transform. The
w
attribute is always
1.0
.
XRRigidTransform.orientation
只读
DOMPointReadOnly
which contains a unit quaternion describing the rotational component of the transform. As a unit quaternion, its length is always normalized to
1.0
.
XRRigidTransform.matrix
只读
Float32Array
. See the section
Matrix format
for how the array is used to represent a matrix.
XRRigidTransform.inverse
只读
XRRigidTransform
which is the inverse of this transform. That is, if applied to an object that had been previously transformed by the original transform, it will undo the transform and return the original object.
当
XRRigidTransform
is interpreted, the orientation is always applied to the affected object before the position is applied.
This code snippet creates an
XRRigidTransform
to specify the offset and orientation in relation to the current reference space to use when creating a new reference space. It then requests the first animation frame callback by calling the session's
requestAnimationFrame()
方法。
xrSession.requestReferenceSpace(refSpaceType)
.then((refSpace) => {
xrReferenceSpace = refSpace;
xrReferenceSpace = xrReferenceSpace.getOffsetReferenceSpace(
new XRRigidTransform(viewerStartPosition, cubeOrientation));
animationFrameRequestID = xrSession.requestAnimationFrame(drawFrame);
| 规范 | 状态 | 注释 |
|---|---|---|
|
WebXR 设备 API
The definition of 'XRRigidTransform' in that specification. |
工作草案 | 初始定义。 |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
XRRigidTransform
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
XRRigidTransform()
构造函数
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
inverse
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
matrix
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
orientation
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
位置
|
Chrome 79 | Edge 79 | Firefox 不支持 No | IE 不支持 No | Opera 不支持 No | Safari 不支持 No | WebView Android 不支持 No | Chrome Android 79 | Firefox Android 不支持 No | Opera Android 不支持 No | Safari iOS 不支持 No | Samsung Internet Android 11.2 |
完整支持
不支持
XRRigidTransform
Navigator.xr
WebGLRenderingContext.makeXRCompatible()
XR
XRBoundedReferenceSpace
XRFrame
XRInputSource
XRInputSourceArray
XRInputSourceEvent
XRInputSourcesChangeEvent
XRPose
XRReferenceSpace
XRReferenceSpaceEvent
XRRenderState
XRSession
XRSessionEvent
XRSpace
XRView
XRViewerPose
XRViewport
XRWebGLLayer