2
0

How-to-create-VR-content.html 2.1 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>[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. For VR projects we use [page:WebGLRenderer.setAnimationLoop setAnimationLoop].
  42. The minimal code looks like this:
  43. </p>
  44. <code>
  45. renderer.setAnimationLoop( function () {
  46. renderer.render( scene, camera );
  47. } );
  48. </code>
  49. <h2>Next Steps</h2>
  50. <p>
  51. Have a look at one of the official WebVR examples to see this workflow in action.<br /><br />
  52. [example:webvr_ballshooter WebVR / ballshoter]<br />
  53. [example:webvr_cubes WebVR / cubes]<br />
  54. [example:webvr_dragging WebVR / dragging]<br />
  55. [example:webvr_lorenzattractor WebVR / lorenzattractor]<br />
  56. [example:webvr_panorama WebVR / panorama]<br />
  57. [example:webvr_paint WebVR / paint]<br />
  58. [example:webvr_rollercoaster WebVR / rollercoaster]<br />
  59. [example:webvr_sandbox WebVR / sandbox]<br />
  60. [example:webvr_sculpt WebVR / sculpt]<br />
  61. [example:webvr_vive_paint WebVR / vive / paint]<br />
  62. [example:webvr_vive_sculpt WebVR / vive / sculpt]<br />
  63. </p>
  64. </body>
  65. </html>