XRRigidTransform.inverse - Web APIs 编辑

The read-only inverse property of the XRRigidTransform interface returns another XRRigidTransform object which is the inverse of its owning transform. That is, you can always get the inverse of any XRRigidTransform using its inverse property, instead of having to explicitly generate it.

Syntax

let transformInverse = xrRigidTransform.inverse;

Value

An XRRigidTransform which contains the inverse of the XRRigidTransform on which it's accessed.

Applying the inverse of a transform to any object previously transformed by the parent XRRigidTransform always undoes the transformation, resulting in the object returning to its previous pose. In other words, its position and orientation both return to their prior configurations.

Examples

In this example, the model view matrix for an object is computed by taking the view matrix and multiplying it by the object's pose matrix.

let modelViewMatrix = mat4.create();

for (let view of pose.view) {
  let viewport = glLayer.getViewport(view);
  gl.viewport(viewport.x, viewport.y, viewport.width, viewport.height);

  /* ... */

  mat4.multiply(modelViewMatrix, view.transform.inverse.matrix, objectMatrix);
  gl.uniformMatrix4fv(programInfo.uniformLocations.modelViewMatrix,
                      false, modelViewMatrix);

  /* ... */
}

This outline of a renderer's core code shows how the pose's view gets represented by taking its transform's inverse's matrix as the model view matrix used to transform objects based on the viewer's position and orientation. The inverse's matrix is multiplied by the object's matrix to get the model view matrix, which is then passed into the shader program by setting a uniform to contain that information.

Specifications

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

Browser compatibility

BCD tables only load in the browser

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

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

发布评论

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

词条统计

浏览:78 次

字数:3170

最后编辑:6 年前

编辑次数:0 次

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