Java基础、中级、高级、架构面试资料

WebVR API和接口大全

HTML5 herman 2281浏览 0评论
公告:“业余草”微信公众号提供免费CSDN下载服务(只下Java资源),关注业余草微信公众号,添加作者微信:xttblog2,发送下载链接帮助你免费下载!
本博客日IP超过2000,PV 3000 左右,急需赞助商。
极客时间所有课程通过我的二维码购买后返现24元微信红包,请加博主新的微信号:xttblog2,之前的微信号好友位已满,备注:返现
受密码保护的文章请关注“业余草”公众号,回复关键字“0”获得密码
所有面试题(java、前端、数据库、springboot等)一网打尽,请关注文末小程序
视频教程免费领
腾讯云】1核2G5M轻量应用服务器50元首年,高性价比,助您轻松上云

前面一篇我大概说了一下WebVR的内容。本文我将介绍一些谷歌和火狐提供的WebVR相关的api接口的用法。目前这些WebVR的相关API并没有形成一定的标准,后续可能会存在改动。另外个浏览器也都没有对WebVR进行支持。如果你需要测试WebVR相关api内容,可以下载对应的谷歌浏览器进行测试。

WebVR

在这份WebVR api中,连接到电脑的所有VR设备都将由 Navigator.getVRDevices() 方法返回。 这个方法将返回一个包含了所有已连接设备的对象数组,每个设备对应一个对象, 该对象继承自 VRDevice  — 通常一个头显将包含两个设备 — 头显自身由 HMDVRDevice 表示, 和一个跟踪头部位置的位置捕捉传感器,由 PositionSensorVRDevice 表示。

PositionSensorVRDevice 对象有一个 getState() 方法, 该方法返回一个VRPositionState 对象 — 这个对象代表位置传感器在指定时刻的状态,包含了一些十分有用的信息,例如速度、加速度以及运动方向,可用于根据头部运动刷新画面显示。

HMDVRDevice.getEyeParameters() 方法返回一个 VREyeParameters 对象, 可用于获取显示区域的信息 — 头显可以看到多少画面。 VREyeParameters.currentFieldOfView 返回一个 VRFieldOfView 对象 ,该对象包含了4个角度信息来描述当前的显示区域. 你可以用 HMDVRDevice.setFieldOfView() 来改变当前的显示区域。

WebVR Interfaces 接口

  • Navigator.getVRDevices:Returns a promise that resolves to an array of objects representing the VR devices attached to the computer.返回一个Promise对象,并通过resolve方式返回参数,参数为链接到电脑的VR设备数组。
  • VRDevice:A generic VR device, includes information such as device IDs and descriptions. Inherited by HMDVRDevice and PositionSensorVRDevice.返回一个包括了VR设备IDs,描述等信息的类。HMDVRDevice 和 PositionSensorVRDevice 继承了 VRDevice。
  • HMDVRDevice:Represents a head mounted display, providing access to information about each eye, and the current field of view.头戴设备。提供设备双眼、当前FOV(field of view)信息。
  • PositionSensorVRDevice:Represents the position sensor for the VR hardware, allowing access to information such as position and orientation.VR设备的位置传感器。获取位置、方向信息。
  • VRPose:Represents the position state at a given timestamp (which includes orientation, position, velocity, and acceleration.)根据一个时间戳返回包括(方向、位置、速度、加速度)的状态。
  • VREyeParameters:Provides access to all the information required to correctly render a scene for each given eye, including field of view information.给双眼提供正确渲染场景的所有信息,包括FOV。
  • VRFieldOfView:Represents a field of view defined by 4 different degree values describing the view from a center point.返回以视窗的中心点为基点的,表示FOV的4个角度值(downDegrees, leftDegrees, rightDegrees, upDegrees)。
  • VRFieldOfViewReadOnly:Contains the raw definition for the degree value properties required to define a field of view. Inherited by VRFieldOfView.定义一个FOV必须的角度属性。VRFieldOfView 继承了 VRFieldOfViewReadOnly。

参考资料

业余草公众号

最后,欢迎关注我的个人微信公众号:业余草(yyucao)!可加作者微信号:xttblog2。备注:“1”,添加博主微信拉你进微信群。备注错误不会同意好友申请。再次感谢您的关注!后续有精彩内容会第一时间发给您!原创文章投稿请发送至532009913@qq.com邮箱。商务合作也可添加作者微信进行联系!

本文原文出处:业余草: » WebVR API和接口大全