How-to-create-VR-content.html 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <base href="../../../" />
  6. <script src="list.js"></script>
  7. <script src="page.js"></script>
  8. <link type="text/css" rel="stylesheet" href="page.css" />
  9. </head>
  10. <body>
  11. <h1>如何创建VR内容([name])</h1>
  12. <br />
  13. <p>
  14. 本指南简要介绍了使用three.js来制作的基于Web的VR应用程序的基本组件。
  15. </p>
  16. <h2>工作流程</h2>
  17. <p>
  18. 首先,你需要将[link:https://github.com/mrdoob/three.js/blob/master/examples/js/vr/WebVR.js WebVR.js]
  19. 包含到你的项目中。
  20. </p>
  21. <code>
  22. &lt;script src="/path/to/WebVR.js"&gt;&lt;/script&gt;
  23. </code>
  24. <p>*WEBVR.createButton()*做了两件重要的事情:首先,它创建了一个按钮,指示了VR的兼容性;
  25. 此外,若用户激活了这个按钮,则它将开启一个VR会话。
  26. 你所要做的唯一一件事情,便是把下面的这一行代码加入到你的应用程序里。
  27. </p>
  28. <code>
  29. document.body.appendChild( WEBVR.createButton( renderer ) );
  30. </code>
  31. <p>
  32. 接下来,你需要告诉你的*WebGLRenderer*实例来启用VR渲染。
  33. </p>
  34. <code>
  35. renderer.vr.enabled = true;
  36. </code>
  37. <p>
  38. 最后,你需要调整你的动画循环,因为在这里我们不能使用我们所熟知的
  39. *window.requestAnimationFrame()*函数来更新场景。对于VR项目来说,我们使用的是[page:WebGLRenderer.setAnimationLoop setAnimationLoop]。
  40. 简短的示例代码如下:
  41. </p>
  42. <code>
  43. renderer.setAnimationLoop( function () {
  44. renderer.render( scene, camera );
  45. } );
  46. </code>
  47. <h2>接下来的步骤</h2>
  48. <p>
  49. 请查看官方示例中与WebVR相关的示例,了解这一工作流程的实际使用、运行情况。
  50. <br /><br />
  51. [example:webvr_ballshooter WebVR / ballshoter]<br />
  52. [example:webvr_cubes WebVR / cubes]<br />
  53. [example:webvr_dragging WebVR / dragging]<br />
  54. [example:webvr_lorenzattractor WebVR / lorenzattractor]<br />
  55. [example:webvr_panorama WebVR / panorama]<br />
  56. [example:webvr_paint WebVR / paint]<br />
  57. [example:webvr_rollercoaster WebVR / rollercoaster]<br />
  58. [example:webvr_sandbox WebVR / sandbox]<br />
  59. [example:webvr_sculpt WebVR / sculpt]<br />
  60. [example:webvr_vive_paint WebVR / vive / paint]<br />
  61. [example:webvr_vive_sculpt WebVR / vive / sculpt]<br />
  62. </p>
  63. </body>
  64. </html>