--- title: WebVR concepts slug: Web/API/WebVR_API/Concepts tags: - Apps - FOV - Guide - VR - WebVR - 位置 - 加速度 - 概念 - 立体 - 速度 translation_of: Web/API/WebVR_API/Concepts ---
{{draft("The WebVR API documentation is currently being updated to cover the v1.0 spec, therefore some of this information will be out of date. Contact ~~chrisdavidmills if you have any questions about this work.")}}
This article discusses some of the concepts and theory behind virtual reality (VR). If you are a newcomer to the area, it is worthwhile getting an understanding of these topics before you start diving into code.
这篇文章探讨了一些关于虚拟现实(VR)的概念及其背后的理论基础。如果你是一个进入这个领域的新手,在你深入学习相关代码知识前,非常有必要对于以下的话题做一定的了解。【K】
Virtual reality is nothing new — the concept goes way further back than the Oculus Rift Kickstarter campaign of 2012. People have been experimenting with it for decades.
虚拟现实(VR)并不是一件新生的事物:这个概念甚至能追溯到,比2012年Oculus Rift在Kickstarter campaig上发起众筹,还要更早的时候。人们已经持续研发这种技术长达数十年。
In 1939 the View-Master device was created, allowing people to see 3D pictures. The device displayed images stored on cardboard disks containing stereoscopic 3D pairs of small color photographs. After years of development the military got interested in using such technology, and Project Headsight was born in 1961 — this involved a helmet incorporating a video screen with a head-tracking system.
1939年View-Master device问世,它允许人们通过它观看3D成像的照片。这款设备播放的是,存储在圆盘硬纸板上的,成对的立体3D的彩色小照片。经过了许多年的研发,军方开始对使用这项技术产生了浓厚的兴趣,终于在1961年,名为HEADSIGHT的项目诞生了:它包含了一个连接头部追踪系统的显示屏的头盔。
There were various experiments conducted over the next few decades, but it wasn't resricted to science labs and battlefields anymore. Eventually pop culture took over with movie directors showing their visions of virtual reality. Movies like Tron (1982) and The Matrix (1999) were created, where people could transfer themselves into a whole new cyber world or were trapped in one without even knowing, accepting it as the real world.
在接下来的数十年中,出现了许多具有指导性作用的实验,但是它不再像从前那样只对科学实验室和战场开放。最终大众文化通过电影导演展现他们的视角,从而接过了虚拟现实的大旗。像【创:战纪 TRON: Legacy(1982)】 和【黑客帝国The Matrix (1999)】那样的电影被拍摄出来,在那里人们能够轻易的将自己置身于一个完全由信息构成的世界,又或者,接受让自己进入一个从未认识过的新世界,并且将它当做一个真实的存在。【K】
The first VR gaming attempts were big and expensive — in 1991 Virtuality Group created a VR-ready arcade machine with goggles and ported popular titles like Pac-Man to virtual reality. Sega introduced their VR glasses at the Consumer Electronics Show in 1993. Companies were experimenting, but the market and consumers weren't convinced — we had to wait until 2012 to see real example of a successful VR project.
世界上第一次VR游戏的尝试是既大又昂贵的:1991年Virtuality Group制造了一款名为VR-ready的商业街机,其中装有护目镜,并且美其名曰 Pac-Man to virtual reality。随后,世嘉株式会社(SEGA)在1993的 Consumer Electronics Show上引进了他们的VR眼睛设备。当时的公司都在努力尝试,但是市场和消费者并不关注和买账:之后,我们再见到真正成功的VR项目,就要等到最近的2012年了。【K】
So what's new? Virtual Reality hardware needs to deliver high-precision, low-latency data to deliver an acceptable user experience; computers running VR applications need to be powerful enough to handle all this information. It has not been until recently that such accuracy and power has been available at an afforable cost, if at all. Early VR prototypes cost tens of thousands of dollars, whereas the latest Oculus Rift developer kit is available for $350, and cheaper solutions are available, such as mobile device-based solutions like Google Cardboard.
那么有什么值得我们期待的呢?VR硬件需要传输高精度的信息,在保证低延迟的情况下传递可接受的用户的体感信息;运行VR设备和程序的电脑,必需强大到足以维持这些庞大的信息。直到最近的这几年,如此高精度并且能量强大的设备,才能通过大众可以接受的价格被购买到。早期的VR原型设备,需要花费数万美元,然而最近出现的Oculus Rift developer kit却仅售350$, 并且还有更加便宜的解决方案,比如基于手机的VR设备像是Google Cardboard.【K】
By 2015, such VRDevices gained commercial support for VR technology. Sony are developing a VR hardware kit for the PS4 (codename Project Morpheus), Facebook bought Oculus Rift for $2 billion, Valve has created SteamVR software that works with HTC's Vive VR headset, and Google has launched a 2.0 version of its Cardboard that supports up to 6 inch phones (it is also fully compatible with iOS devices because it has a piece of conductive foam that works as a tap over the screen.)
到了2015年,类似的VR设备吸引了大量的商业投资,进入到VR科技的研发中。SONY正在PS4中开发一项针对VR的硬件工具(编程代号 Project Morpheus), FACRBOOK花费20亿美元买下了 Oculus Rift, Valve开发了 SteamVR 软件系统,能够应用于HTC的Vive VR headset, 随后,谷歌发布了能够最多支持6英寸手机屏幕的CARDBOARD的2.0版本(它同时完全兼容了IOS的设备,因为在它屏幕的背后有一块传感海绵凸起作为触碰点。)
Samsung also launched a headset associated with Oculus called GearVR, which works by connecting its Note 4 and 6S devices. This however only works with native apps, so it is not very interesting for the specific area of WebVR.
三星公司同Oculus 合作,也推出了它的头戴设备GearVR, 这款设备可以连接旗下的NOTE4以及6S等手机。然而这款设备仅仅能够运行几款纯粹的APP应用,因而相对于WEBVR的特效领域而言,显得不是那么的有意思。【K】
The technology itself is here, and the more expensive headsets will only get cheaper over time so more people can experience virtual reality on their own in the future.
科技已经发展到了今天,随着时间的推移,只会有更多的昂贵的头显设备变得越来越便宜,从而另更多的人在将来能够亲自体验虚拟现实的乐趣。【K】
Handling input for virtual reality applications is an interesting topic — it's a totally new experience for which dedicated user interfaces have to be designed. There are various approaches right now from classic keyboard and mouse, to new ones like Leap Motion. It's a matter of trial and error to see what works in given situations and what inputs fit best for your type of game.
针对虚拟显示应用的手持传入设备,是一个非常有意思的话题:这是一种全新的体验,从而必须要设计出沉浸式的用户界面来适应它。目前为止,在这方面,从传统的键盘鼠标,一直到LEAP MOTION这样的新兴设备,有多种多样的途径来实现它。只有通过【试错法】最终才能窥见,哪种方式最有利于创造情景以及哪种输入设备最适合于你所玩的游戏的类型。【K】
There are two main types of setup, mobile or computer-connected. Their minimum hardware set ups are as follows:
主要有两种创建VR环境的类型,手机或者是PC。以下是实现这两种环境所需要的最少的硬件支持:
Note: Computer-connected systems sometimes don't include a position sensor, but they usually do.
注释:通过电脑连接的系统有时候不会包含定位传感装置,但是通常情况下都会有。【K】
Other hardware that complements the VR experience includes:
其余的帮助补充完整的VR体验的硬件包括:【K】
As mentioned above, the position sensor detects information concerning the HMD and constantly outputs it, allowing you to continually update a scene according to head movement, rotation, etc. But what exactly is the information?
正如上文所提到的,那个位置传感器通过检测与HMD相关的信息并且实时的输出这些数据,从而允许你持续的通过改变你的头部移动,更新你身处的虚拟场景,包括旋转等动作。但是我们所说的这些信息包括些什么呢?【K】
The output information falls into four categories:
通过HMD输出的信息包含一下四种类别:【K】
The field of view (FOV) is the area that each of the user's eyes can reasonably be expected to see. It roughly takes the form of a pyramid shape, laid down on one side, with the apex inside the user's head, and the rest of the pyramid eminating from the user's eye. Each eye has it's own FOV, one slightly overlapping the other.
VR的视野(FOV)就是我们的双眼理论上预期能看到的区域。这个区域大致上呈现一个倒置的金字塔形状,金字塔的中轴线穿过使用者的头部,金字塔剩余的部分从使用者的双眼部位发散出去。每只眼睛都有自己的FOV,同时其中的一个稍微同另一个重叠。
The FOV is defined by the following values:
FOV是通过下列的值来定义的:
The default values for these properties will differ slightly by VR hardware, although they tend to be around 53° up and down, and 47° left and right, with zNear and zFar coming in at around 0.1m and 10000m respectively.
更具VR硬件的不同,这些特性的值会略有不同,然而他们基本上分别都趋向于上下53°,左右47°,zNear和zFar两个值可以在0.1m到10000m之间变换。
Different users will also require slightly different values for optimal viewing. It therefore makes sense to be able to calibrate these when a user starts using an app. You can detect the current value of these using the methods of the {{domxref("VREyeParameters")}} interface, and set new values using the {{domxref("HMDVRDevice.setFieldOfView()")}} method.
不同的使用者将会为了达成尽量完美的视觉体验,而要求略有不同的特性数值。因此,我们有理由在使用者开始使用一个APP之前,对这些特性进行测算。你可以使用{{domxref("VREyeParameters")}} interface, and set new values using the {{domxref("HMDVRDevice.setFieldOfView()")}} method.这个方法来侦测现行的特性值。
Note: The user can potentially see all the way around them, which is a brand new concept for apps and games. Try to give people a reason to look around and see what's behind them — make them reach out and find things that are not visible at the very beginning. Describe what's behind their backs.
注释:使用者潜在的可以看到所有他们身边的事物,这是一个APP和游戏中出现的全新的概念。那就是,试着传达给人们一个发现他们身后事物的理由--引导他们去发现那些在一开始并没有出现在他们视野中的事物。描述他们身后的世界。【K】
【可以说这一点是VR概念中同其他3D技术区别开,非常重要的特性,就是创建和引导使用者去发现他们视野中看不见的部分】
This section discusses concepts to be aware of when developing VR apps that you've probably not had to consider before when developing regular apps for mobile or desktop.
这个部分讨论的是,从前在我们开发普通的APP和手机或者PC应用时,不必考虑的,但是在我们开发VR APP的时候必须被意识到的概念。
立体视觉
Stereoscopic vision is the normal vision humans and (most) animals have — the perception of two slightly differing images (one from each eye) as a single image. This results in depth perception, helping us to see the world in glorious 3D. To recreate this in VR apps, you need to render two very slightly different views side by side, which will be taken in by the left and right eyes when the user is using the HMD.
立体视觉是大多数的动物以及人类拥有的正常的视觉效果--也就是将来自每只眼睛的略有差别的图像,通过大脑的处理,感知为一张立体的图片。这种对深度的感知结果,帮助我们通过一种神奇的3D的视角看世界。为了在APP中重现这种视觉效果,你需要渲染两幅略有不同的场景,当使用者在通过使用HMD观看时能分别被左右眼所调用。
The primary technology used to make you feel present in a 360º scene, thanks to the gyroscope, accelerometer, and magnetometer (compass) included in the HMD.
首要的使我们能够感到置身于360°场景中的科技,要感谢包括在HMD设备中的陀螺仪、加速剂、磁力计等装置。
It has primary relevance because it makes our eyes believe we are in front of a spherical screen, giving users realistic immersion inside the app canvas.
这种技术对于VR有非常重要的关联性,因为它让我们的眼睛相信我们置身于一个球形的屏幕前,它提供给使用者一种在APP画布中沉浸式的体验。
A term commonly used in VR because it is a major handicap of using an HMD — we are constantly fooling the eye with what we are showing in the app canvas, and this leads to the eyes doing a lot more work than they normally would, so using VR apps for any extended period of time can lead to eye strain.
这是一个通常使用在VR中的术语,因为这也是使用HMD设备的一个副作用--我们的视线历来会追踪我们在APP画布中被展示的内容,然而这将导致我们的眼睛超负荷的工作,因此假如我们使用VR APP时,有任何超时的行为,都有可能导致眼部的拉伤。
To minimize this unwanted effect, we need to:
为了将这些可能的影响最小化,我们可以:
In general, the path of least visual effort will give the user a less tiring experience.
If developers do not take utmost care, VR apps can actually cause their users to feel sick. This effect is produced when the stimuli their eyes are receiving is not what the body expects to receive.
如果开发者没有非常注意的话,VR APP将会很有可能引起它的使用者的反感。这种反应的产生是因为我们的眼睛受到了,我们的身体并不准备接收的刺激。
To avoid bringing on motion sickness in our users (or at least minimize the effects), we need to:
为了避免带来晕动效果给我们的使用者(或者说最大限度的减小这种反应),我们可以:
Latency is the time between the physical head movement and the visual display reaching the user's eyes from the screen of an HMD being updated. This is one of the most critical factors in providing a realistic experience. Humans can detect very small delays — we need to keep the latency below 20 milliseconds if they are to be imperceptible (for example a 60Hz monitor has a 16 ms response.)
延迟指的是,头部的物理转动动作,显示设备在接收了HMD的信息更新后,这两者之间的时间间隔。这是一个在提供虚拟现实体验的过程中非常关键的因素。人体能感知到非常细微的延迟--如果我们要让人体感知不到这种延迟,我们需要将延迟保持在20微妙以下(例如一个60HZ的显示器拥有16ms的返回速度。)
The Oculus Rift headset has a letency of 20 ms or less, but woth mobile device-based setups it will depend heavily on the smartphone CPU power and other capabilities.
Oculus Rift headset的延迟在20ms甚至比这更低,但是目前这都非常依赖于智能手机的CPU性能和其他性能。
Based on the Wikipedia definition, framerate is the frequency at which an imaging device produces unique consecutive images, called frames. A rate of 60fps is an acceptable rate for a smooth user experience, but depending on the performance of the machine the app is running on, or the complexity of the content you want to show, it can drastically lower. Less than 30fps is generally considered juddery, and annoying to the user.、
根据维基百科的定义,帧率指的是一个设备产生单一连贯的图像的速率,叫做框架。60FPS的帧率足够提供给使用者一个平稳的体验,但是更加要取决于APP运行的设备的表现,或者是你想要体验的VR内容,也有可能大大的降低。假如帧率小于了30FPS,通常会发生严重的颤抖,并且使使用者产生厌恶感。
One of the most difficult tasks is to maintain a constant and high framerate value, so we must optimize our code to make it as efficient as possible. It is preferable to have a decent framerate that doesn't constantly or suddenly change; for this you need to as few necessary objects moving into the scene as possible and (in the case of WebGL) try to reduce draw calls.
最困难的任务之一就是保持一个稳定的和高帧率的值,所以我们必须优化代码从而使它发挥最大的功效。假如能够有一个合适的帧率并且不会规律的或者突然的改变,那将会是非常好的体验;因此你需要在一个场景中设置尽量少的物体(例如在WEBGL中)并且减小DRAW CALLS的值。
Based on the Wikipedia definition, IPD is the distance between the centers of the pupils of the two eyes. IPD is critical for the design of binocular viewing systems, where both eye pupils need to be positioned within the exit pupils of the viewing system.
根据维基百科的定义,IPD是指两眼瞳孔之间的距离。IPD对于双目视觉系统是非常重要的,因为双眼的瞳孔都必须对准这套视觉系统的瞳孔出口。
Interpupillary distace ( IPD ) is represented by {{domxref("VREyeParameters.eyeTranslation")}} in WebVR.
瞳孔间距(IPD)可用 {{domxref("VREyeParameters.eyeTranslation")}} 来表示.
This value is returned by the HMD and its value may be around 60 to 70 mm; in the case of some HMDs like Oculus Rift's, you can set your own IPD. Normally we don't change this value but you can play with it to change the scale of the entire scene. For example, if your IPD is set to 6000 mm, the user would view the scene like a giant looking at a Lilliputian world.
这个值是通过HMD来返回的并且它的值一般在60-70mm之间;在像是Oculus Rift这样的HMD设备中,你可以设置你自己的IPD。一般我们不会去改变这个值,但是你可以通过有意的改变它从而改变你所身处的整个场景。例如,如果你将IPD调整到6000mm,使用者将会看到一个好像巨人身处小人国中一样的世界。
DoF refers to the movement of a rigid body inside space. There is no uniformity in creating acronyms for this term — we can find references to 3DoF in the context of sensors that detect only rotational head tracking, and 6DoF when an input allows us to control position and orientation simultaneously. We even sometimes find 9DoF references when the hardware contains three sensors like gyroscope, accelerometer and magnetometer, but the results of the 3 x 3DoF values will actually return a 6 degrees of freedom tracking.
DOF指向的是空间中固态物体移动的自由度。并没有一个统一的对这个专业术语的缩写--我们可以找到,在关于侦测头部转动的传感器的那篇文章中的3DOF的参考,还有当一个传入设备允许我们同时控制位置和方位信息时的6DOF。我们有时候甚至会看到9DOF的案例,那就是当硬件中包含了三个感应装置时,如陀螺仪、加速计和磁力计,但是3 x 3DoF的值的接过实际上返回的,还是一个6纬的自由度跟踪结果。
DoF is directly related to the tracking of the user's head movement.
DOF直接和使用者的头部运动追踪相关联。
Although our field of view is much larger (approximately 180º), we need to be aware that only in a small portion of that field can you perceive symbols (the center 60º) or read text (the center 10º). If you do not have an eye tracking sensor we assume that the center of the screen is where the user is focusing their eyes.
虽然我们的视野非常的旷阔(最大可以达到180°),但是我们必须要意识到只有在一个小范围内,你才可以察觉到一些标识的存在(中心向外60°)或者读取文本(中心向外10°)。如果你没有一个眼部追踪器,那么我们建议你将使用者的视角尽量控制在屏幕中心点附近。
This limitation is important to consider when deciding where place visuals on the app canvas — too far towards the edge of the cone of focus can lead to eye strain much ore quickly. There is a very interesting post about this (amongst other things) at MozVR.com — see Quick VR Mockups with Illustrator.
这样的限制对于在考虑如何在APP画布上设置视角的时候,是非常重要的--假如太过于远离锥形焦点的边缘,就可能更快更容易的导致眼部的拉伤。想要阅读MozVR.com 上的关于这个问题的有意思的文章(还包含其他内容)--请点击Quick VR Mockups with Illustrator.
3D positional audio refers to a group of effects that manipulate audio to simulate how it would sound in a three dimensional space.
3D定位音效,指的是一组控制声音去实现怎样模拟它在一个三维空间中播放的效果。,
This directly related to the Web Audio API, which allows us to place sounds on objects we have in the canvas or launch audio depending on the part of the scene the user is traveling towards or looking at.
这项技术直接关系到Web Audio API,它可以让我们将一段声音附加到,一个我们在VANVAS中或者launch audio中的物体上,并且基于一个用户在其中可以移动或者观看的场景的一部分。