You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
81 lines
2.1 KiB
81 lines
2.1 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<base href="../../../" />
|
|
<script src="page.js"></script>
|
|
<link type="text/css" rel="stylesheet" href="page.css" />
|
|
</head>
|
|
|
|
<body>
|
|
<h1>[name]</h1>
|
|
|
|
<p>
|
|
This guide provides a brief overview of the basic components of a web-based VR application
|
|
made with three.js.
|
|
</p>
|
|
|
|
<h2>Workflow</h2>
|
|
|
|
<p>
|
|
First, you have to include [link:https://github.com/mrdoob/three.js/blob/master/examples/jsm/webxr/VRButton.js VRButton.js]
|
|
into your project.
|
|
</p>
|
|
|
|
<code>
|
|
import { VRButton } from 'three/addons/webxr/VRButton.js';
|
|
</code>
|
|
|
|
<p>
|
|
*VRButton.createButton()* does two important things: It creates a button which indicates
|
|
VR compatibility. Besides, it initiates a VR session if the user activates the button. The only thing you have
|
|
to do is to add the following line of code to your app.
|
|
</p>
|
|
|
|
<code>
|
|
document.body.appendChild( VRButton.createButton( renderer ) );
|
|
</code>
|
|
|
|
<p>
|
|
Next, you have to tell your instance of `WebGLRenderer` to enable XR rendering.
|
|
</p>
|
|
|
|
<code>
|
|
renderer.xr.enabled = true;
|
|
</code>
|
|
|
|
<p>
|
|
Finally, you have to adjust your animation loop since we can't use our well known
|
|
*window.requestAnimationFrame()* function. For VR projects we use [page:WebGLRenderer.setAnimationLoop setAnimationLoop].
|
|
The minimal code looks like this:
|
|
</p>
|
|
|
|
<code>
|
|
renderer.setAnimationLoop( function () {
|
|
|
|
renderer.render( scene, camera );
|
|
|
|
} );
|
|
</code>
|
|
|
|
<h2>Next Steps</h2>
|
|
|
|
<p>
|
|
Have a look at one of the official WebVR examples to see this workflow in action.<br /><br />
|
|
|
|
[example:webxr_vr_ballshooter WebXR / VR / ballshooter]<br />
|
|
[example:webxr_vr_cubes WebXR / VR / cubes]<br />
|
|
[example:webxr_vr_dragging WebXR / VR / dragging]<br />
|
|
[example:webxr_vr_paint WebXR / VR / paint]<br />
|
|
[example:webxr_vr_panorama_depth WebXR / VR / panorama_depth]<br />
|
|
[example:webxr_vr_panorama WebXR / VR / panorama]<br />
|
|
[example:webxr_vr_rollercoaster WebXR / VR / rollercoaster]<br />
|
|
[example:webxr_vr_sandbox WebXR / VR / sandbox]<br />
|
|
[example:webxr_vr_sculpt WebXR / VR / sculpt]<br />
|
|
[example:webxr_vr_video WebXR / VR / video]
|
|
</p>
|
|
|
|
</body>
|
|
|
|
</html>
|
|
|