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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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>[name]</h1>
  12. <p>
  13. This guide provides a brief overview of the basic components of a web-based VR application
  14. made with three.js.
  15. </p>
  16. <h2>Workflow</h2>
  17. <p>
  18. First, you have to include [link:https://github.com/mrdoob/three.js/blob/master/examples/js/vr/WebVR.js WebVR.js]
  19. into your project.
  20. </p>
  21. <code>
  22. &lt;script src="/path/to/WebVR.js"&gt;&lt;/script&gt;
  23. </code>
  24. <p>
  25. *WEBVR.createButton()* does two important things: It creates a button which indicates
  26. VR compatibility. Besides, it initiates a VR session if the user activates the button. The only thing you have
  27. to do is to add the following line of code to your app.
  28. </p>
  29. <code>
  30. document.body.appendChild( WEBVR.createButton( renderer ) );
  31. </code>
  32. <p>
  33. Next, you have to tell your instance of *WebGLRenderer* to enable VR rendering.
  34. </p>
  35. <code>
  36. renderer.vr.enabled = true;
  37. </code>
  38. <p>
  39. Finally, you have to adjust your animation loop since we can't use our well known
  40. *window.requestAnimationFrame()* function. For VR projects we use [page:WebGLRenderer.setAnimationLoop setAnimationLoop].
  41. The minimal code looks like this:
  42. </p>
  43. <code>
  44. renderer.setAnimationLoop( function () {
  45. renderer.render( scene, camera );
  46. } );
  47. </code>
  48. <h2>Next Steps</h2>
  49. <p>
  50. Have a look at one of the official WebVR examples to see this workflow in action.<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>