Looking-Glass / HoloPlayJS_Issues

A repository for feature requests and bug reports for the HoloPlay.js library. This repository doesn't contain source code. You can download the HoloPlay.js library at http://look.glass/threejs
0 stars 0 forks source link

Depth is reversed when first loading page #14

Closed lakmeer closed 4 years ago

lakmeer commented 4 years ago

I have a simple threejs scene with a single cube and some moving lights. However, this issue is also apparent when viewing the tutorial scene.

When I first load the page, the depth effect is reversed. That is, near objects seem far, and far objects seem near, as if I was looking at a stereograpic image with the eyes swapped over. Further, if I lean left, I see the part of the quilt showing right-hand side of my cube, and vice-versa.

Strangely, if I use the Holoplay fullscreen button, or F11 to fullscreen the browser itself, or change the window size in any way, it corrects itself. Even if I return the window size to what it was before, it remains correct. However, if I refresh the page, it becomes wrong again. It is very confusing :sweat_smile:

System:

lakmeer commented 4 years ago

I've got a workaround for myself that might be useful; I added the following function to Holoplay.js:

    function fixShaderValues (backoff) {
      if (typeof backoff === 'undefined') backoff = 1;

      // Exponential backoff
      if (!jsonObj) {
        console.log("HoloPlay::fixShaderValues - calibration not ready, retrying in " + backoff + "ms.");
        setTimeout(function () { fixShaderValues(backoff * 10) }, backoff);
      } else {
        setShaderValues(
          jsonObj.DPI.value, 
          jsonObj.pitch.value, 
          jsonObj.slope.value, 
          jsonObj.screenH.value, 
          jsonObj.screenW.value, 
          jsonObj.center.value, 
          jsonObj.flipImageX.value, 
          jsonObj.flipImageY.value, 
          jsonObj.invView.value);
        console.log("HoloPlay::fixShaderValues - calibration reapplied");
      }
    }

I made this function available on the HoloPlay prototype, so I can call it from my threejs setup code. This works well, so perhaps this code will be helpful in making a more robust solution to the problem :)

alxdncn commented 4 years ago

Hi, thanks for delving into this! This will be fixed in an upcoming release, v1.0.0. It will be live later this month.