ThreeJS Scene To VR

Hi, I want to transform my scene into a VR scene, is the renderer.XR.enabled = true enough?

1 Like

There are several things that I do when converting to a VR scene.

  1. import three/examples/jsm/webxr/VRButton
  2. renderer.xr.enabled = true
  3. document.body.appendChild(VRButton.createButton(renderer))
  4. Use the renderer.setAnimationLoop() function instead of requestAnimationFrame

See simple example and source code here

https://sbcode.net/threejs/random-puncher/

2 Likes

Thanks you, it worked :slight_smile:

Hey, on changing to renderer.setAnimationLoop() worked for me.
I’m wondering why this is not mentioned in the official documentation. And if I could find some better documentation, thanks.

It’s here,

Look at official examples to see how things are used. : three.js examples

2 Likes

And also here:

image

1 Like

oh understood, thank you.

Thank you!

1 Like