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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. You have to include [link:https://github.com/mrdoob/three.js/blob/master/examples/js/vr/WebVR.js WebVR.js]
  20. into your project. *WEBVR.createButton()* does two important things: First, it creates a button which indicates
  21. VR compatibility. Second, it initiates a VR session if the user activates the button. The only thing you have
  22. to do is to add the following line of code to your app.
  23. </p>
  24. <code>
  25. document.body.appendChild( WEBVR.createButton( renderer ) );
  26. </code>
  27. <p>
  28. Next, you have to tell your instance of *WebGLRenderer* to enable VR rendering:
  29. </p>
  30. <code>
  31. renderer.vr.enabled = true;
  32. </code>
  33. <p>
  34. Finally, you have to adjust your animation loop since we can't use our well known
  35. *window.requestAnimationFrame()* function. The minimal code looks like this:
  36. </p>
  37. <code>
  38. function animate() {
  39. renderer.setAnimationLoop( render );
  40. }
  41. </code>
  42. <h2>Next Steps</h2>
  43. <p>
  44. Have a look at one of the official WebVR examples to see this workflow in action.<br /><br />
  45. [example:webvr_ballshooter WebVR / ballshoter]<br />
  46. [example:webvr_cubes WebVR / cubes]<br />
  47. [example:webvr_dragging WebVR / dragging]<br />
  48. [example:webvr_lorenzattractor WebVR / lorenzattractor]<br />
  49. [example:webvr_panorama WebVR / panorama]<br />
  50. [example:webvr_paint WebVR / paint]<br />
  51. [example:webvr_rollercoaster WebVR / rollercoaster]<br />
  52. [example:webvr_sandbox WebVR / sandbox]<br />
  53. [example:webvr_sculpt WebVR / sculpt]<br />
  54. [example:webvr_vive_paint WebVR / vive / paint]<br />
  55. [example:webvr_vive_sculpt WebVR / vive / sculpt]<br />
  56. </p>
  57. </body>
  58. </html>