XRCylinderLayer:aspectRatio 属性
XRCylinderLayer 接口的 aspectRatio 属性表示可见圆柱部分的比例。它是可见圆柱部分宽度除以其高度的比例。宽度通过将 radius 与 centralAngle 相乘来计算。
值
一个表示可见圆柱部分比例的数字。
示例
获取图层的纵横比
XRWebGLBinding.createCylinderLayer() 方法创建一个圆柱图层,并允许指定 aspectRatio。在图层创建后,可以使用 XRCylinder.aspectRatio 属性来获取使用的 纵横比,或将其设置为新的值。
js
const cylinderLayer = xrGlBinding.createCylinderLayer({
space: xrReferenceSpace,
viewPixelWidth: 1200,
viewPixelHeight: 600,
centralAngle: (60 * Math.PI) / 180,
aspectRatio: 2,
radius: 2,
transform: new XRRigidTransform(/* … */),
});
cylinderLayer.aspectRatio; // 2
规范
| 规范 |
|---|
| WebXR Layers API Level 1 # dom-xrcylinderlayer-aspectratio |
浏览器兼容性
加载中…