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)); } Matrix4x4 trs = WebVRMatrixUtil.TransformViewMatrixToTRS(leftViewMatrix); headRotation = WebVRMatrixUtil.GetRotationFromMatrix(trs); headPosition = WebVRMatrixUtil.GetTranslationFromMatrix(trs); sitStand = sitStandMatrix; if (cameraAttachment) { cameraAttachment.VRCamera.localRotation = headRotation; cameraAttachment.VRCamera.localPosition = headPosition; } OnHeadsetUpdate( leftProjectionMatrix, rightProjectionMatrix, leftViewMatrix, rightViewMatrix, sitStandMatrix); } }
private void onHeadsetUpdate(Matrix4x4 leftProjectionMatrix, Matrix4x4 rightProjectionMatrix, Matrix4x4 leftViewMatrix, Matrix4x4 rightViewMatrix, Matrix4x4 sitStandMatrix) { Matrix4x4 trs = WebVRMatrixUtil.TransformViewMatrixToTRS(leftViewMatrix); this.headRotation = WebVRMatrixUtil.GetRotationFromMatrix(trs); this.headPosition = WebVRMatrixUtil.GetTranslationFromMatrix(trs); }