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