XRRigidTransform - Web APIs 编辑

The XRRigidTransform is a 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:

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.

Constructor

new XRRigidTransform()
Creates a new XRRigidTransform object which represents a transform that applies a specified position and/or orientation.

Properties

XRRigidTransform.position Read only This is an experimental API that should not be used in production code.
A DOMPointReadOnly specifying a 3-dimensional point, expressed in meters, describing the translation component of the transform. The w property is always 1.0.
XRRigidTransform.orientation Read only  This is an experimental API that should not be used in production code.
A 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 Read only  This is an experimental API that should not be used in production code.
Returns the transform matrix in the form of a 16-member Float32Array. See the section Matrix format for how the array is used to represent a matrix.
XRRigidTransform.inverse Read only  This is an experimental API that should not be used in production code.
Returns a 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.

Usage notes

When an XRRigidTransform is interpreted, the orientation is always applied to the affected object before the position is applied.

Example

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() method.

xrSession.requestReferenceSpace(refSpaceType)
.then((refSpace) => {
  xrReferenceSpace = refSpace;
  xrReferenceSpace = xrReferenceSpace.getOffsetReferenceSpace(
        new XRRigidTransform(viewerStartPosition, cubeOrientation));
  animationFrameRequestID = xrSession.requestAnimationFrame(drawFrame);

Specifications

SpecificationStatusComment
WebXR Device API
The definition of 'XRRigidTransform' in that specification.
Working DraftInitial definition.

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:147 次

字数:7479

最后编辑:6 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文