XRCylinderLayer: aspectRatio property

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Thuộc tính aspectRatio của giao diện XRCylinderLayer đại diện cho tỷ lệ của phần hình trụ hiển thị. Đây là tỷ lệ giữa chiều rộng của phần hình trụ hiển thị chia cho chiều cao của nó. Chiều rộng được tính bằng cách nhân radius với centralAngle.

Giá trị

Số đại diện cho tỷ lệ của phần hình trụ hiển thị.

Ví dụ

Lấy tỷ lệ khung hình của lớp

Phương thức XRWebGLBinding.createCylinderLayer() tạo lớp hình trụ và cho phép chỉ định aspectRatio. Thuộc tính XRCylinder.aspectRatio có thể được dùng sau khi tạo lớp để lấy tỷ lệ khung hình được dùng hoặc đặt thành tỷ lệ mới.

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

Thông số kỹ thuật

Specification
WebXR Layers API Level 1
# dom-xrcylinderlayer-aspectratio

Tương thích trình duyệt

Xem thêm