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>[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/jsm/webxr/VRButton.js VRButton.js]
  19. into your project.
  20. </p>
  21. <code>
  22. import { VRButton } from 'three/examples/jsm/webxr/VRButton.js';
  23. </code>
  24. <p>
  25. *VRButton.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( VRButton.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:webxr_vr_ballshooter WebXR / VR / ballshoter]<br />
  52. [example:webxr_vr_cubes WebXR / VR / cubes]<br />
  53. [example:webxr_vr_dragging WebXR / VR / dragging]<br />
  54. [example:webxr_vr_lorenzattractor WebXR / VR / lorenzattractor]<br />
  55. [example:webxr_vr_multiview WebXR / VR / multiview]<br />
  56. [example:webxr_vr_paint WebXR / VR / paint]<br />
  57. [example:webxr_vr_panorama_depth WebXR / VR / panorama_depth]<br />
  58. [example:webxr_vr_panorama WebXR / VR / panorama]<br />
  59. [example:webxr_vr_rollercoaster WebXR / VR / rollercoaster]<br />
  60. [example:webxr_vr_sandbox WebXR / VR / sandbox]<br />
  61. [example:webxr_vr_sculpt WebXR / VR / sculpt]<br />
  62. [example:webxr_vr_video WebXR / VR / video]
  63. </p>
  64. </body>
  65. </html>