Skip to content

Commit

Permalink
Assigns default sitStand when when no room transform available, fixes M…
Browse files Browse the repository at this point in the history
  • Loading branch information
caseyyee committed Sep 19, 2018
1 parent 2ce0b6d commit 70bcc07
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion Assets/WebVR/Scripts/WebVRManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class WebVRManager : MonoBehaviour

public delegate void VRCapabilitiesUpdate(WebVRDisplayCapabilities capabilities);
public event VRCapabilitiesUpdate OnVRCapabilitiesUpdate;

public delegate void VRChange(WebVRState state);
public event VRChange OnVRChange;

Expand Down Expand Up @@ -66,6 +66,8 @@ public delegate void ControllerUpdate(string id,
// Array stores 5 matrices, each 16 values, stored linearly.
float[] sharedArray = new float[5 * 16];

private WebVRDisplayCapabilities capabilities;

public static WebVRManager Instance {
get
{
Expand Down Expand Up @@ -148,6 +150,7 @@ public void OnVRCapabilities(string json) {

public void OnVRCapabilities(WebVRDisplayCapabilities capabilities) {
#if !UNITY_EDITOR && UNITY_WEBGL
this.capabilities = capabilities;
if (!capabilities.canPresent)
WebVRUI.displayElementId("novr");
#endif
Expand Down Expand Up @@ -211,13 +214,20 @@ void Update()
if (quickToggleEnabled && Input.GetKeyUp(toggleVRKeyName))
toggleVrState();
#endif
}

void LateUpdate()
{
if (OnHeadsetUpdate != null && this.vrState == WebVRState.ENABLED) {
Matrix4x4 leftProjectionMatrix = WebVRMatrixUtil.NumbersToMatrix(GetFromSharedArray(0));
Matrix4x4 rightProjectionMatrix = WebVRMatrixUtil.NumbersToMatrix(GetFromSharedArray(1));
Matrix4x4 leftViewMatrix = WebVRMatrixUtil.NumbersToMatrix(GetFromSharedArray(2));
Matrix4x4 rightViewMatrix = WebVRMatrixUtil.NumbersToMatrix(GetFromSharedArray(3));
Matrix4x4 sitStandMatrix = WebVRMatrixUtil.NumbersToMatrix(GetFromSharedArray(4));
if (!this.capabilities.hasPosition)
{
sitStandMatrix = Matrix4x4.Translate(new Vector3(0, this.DefaultHeight, 0));
}

OnHeadsetUpdate(
leftProjectionMatrix,
Expand Down

0 comments on commit 70bcc07

Please sign in to comment.