Ejemplo n.º 1
0
    void Update()
    {
        #if UNITY_EDITOR || !UNITY_WEBGL
        bool quickToggleEnabled = toggleVRKeyName != null && toggleVRKeyName != "";
        if (quickToggleEnabled && Input.GetKeyUp(toggleVRKeyName))
        {
            toggleVrState();
        }
        #endif

        if (OnHeadsetUpdate != null)
        {
            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));

            sitStand = sitStandMatrix;

            OnHeadsetUpdate(
                leftProjectionMatrix,
                rightProjectionMatrix,
                leftViewMatrix,
                rightViewMatrix,
                sitStand);
        }
    }
Ejemplo n.º 2
0
    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);
        }
    }
    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,
                rightProjectionMatrix,
                leftViewMatrix,
                rightViewMatrix,
                sitStandMatrix);
        }
    }