private void UpdateXRCameras()
        {
            if (OnHeadsetUpdate != null && this.xrState != WebXRState.NORMAL)
            {
                GetMatrixFromSharedArray(0, ref leftProjectionMatrix);
                GetMatrixFromSharedArray(16, ref rightProjectionMatrix);
                GetQuaternionFromSharedArray(32, ref leftRotation);
                GetQuaternionFromSharedArray(36, ref rightRotation);
                GetVector3FromSharedArray(40, ref leftPosition);
                GetVector3FromSharedArray(43, ref rightPosition);

                OnHeadsetUpdate?.Invoke(
                    leftProjectionMatrix,
                    rightProjectionMatrix,
                    leftRotation,
                    rightRotation,
                    leftPosition,
                    rightPosition);
            }
        }
Пример #2
0
        internal void OnLateUpdate()
        {
            if (OnHeadsetUpdate != null && this.xrState != WebXRState.NORMAL)
            {
                Matrix4x4 leftProjectionMatrix  = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(0));
                Matrix4x4 rightProjectionMatrix = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(1));
                Matrix4x4 leftViewMatrix        = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(2));
                Matrix4x4 rightViewMatrix       = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(3));
                Matrix4x4 sitStandMatrix        = WebXRMatrixUtil.NumbersToMatrix(GetMatrixFromSharedArray(4));
                if (!this.capabilities.hasPosition)
                {
                    const float defaultHeight = 1;
                    sitStandMatrix = Matrix4x4.Translate(new Vector3(0, defaultHeight, 0));
                }

                OnHeadsetUpdate?.Invoke(
                    leftProjectionMatrix,
                    rightProjectionMatrix,
                    leftViewMatrix,
                    rightViewMatrix,
                    sitStandMatrix);
            }
        }