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 |
瀏覽器相容性
載入中…