puckey / dance-tonite

An ever-changing VR collaboration by LCD Soundsystem and their fans.

Home Page:https://tonite.dance

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Javascript errors & black screen when Enter, then exit, then re-enter VR

leweaver opened this issue · comments

System
OS: Windows 10 Fall Creators Update
Browser: Edge
Headset: Windows Mixed Reality with Motion Controllers

Repo steps:

  1. Ensure controllers are powered on and connected
  2. Navigate to site, and Enter VR
  3. Press the Windows Key on the controller to Exit VR
  4. Press the Enter VR button to re-enter VR

Observed issue
JavaScript errors flood the console and nothing is rendered to the headset. I traced the javascript error to this line, which fails as pose.orientation is null:

this.armModel.setControllerOrientation(( new THREE.Quaternion() ).fromArray( pose.orientation ));

I believe this issue appears because you are caching the gamepad object between frames; but VRController does not get a chance to emit the 'on gamepad disconnected' event, since you do not update the controls when not presenting:

if (vrEffect.isPresenting) {

This causes the gamepad object to become stale and invalid when requestPresent is called a second time.