只读 inverse 特性为 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.

句法

let transformInverse = xrRigidTransform.inverse;
					

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.

范例

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.

规范

规范 状态 注释
WebXR 设备 API
The definition of 'XRRigidTransform.inverse' in that specification.
工作草案 初始定义。

浏览器兼容性

更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
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

图例

完整支持

完整支持

不支持

不支持

元数据

  • 最后修改: