OrbitCameraBehavior() private static method

private static OrbitCameraBehavior ( SceneView view ) : void
view SceneView
return void
示例#1
0
        private static void HandleMouseDrag(SceneView view, int id)
        {
            SceneViewMotion.s_CurrentState = SceneViewMotion.MotionState.kDragging;
            if (GUIUtility.hotControl == id)
            {
                Event current = Event.current;
                switch (Tools.s_LockedViewTool)
                {
                case ViewTool.Orbit:
                    if (!view.in2DMode && !view.isRotationLocked)
                    {
                        SceneViewMotion.OrbitCameraBehavior(view);
                        view.svRot.UpdateGizmoLabel(view, view.rotation * Vector3.forward, view.m_Ortho.target);
                    }
                    break;

                case ViewTool.Pan:
                {
                    view.viewIsLockedToObject = false;
                    view.FixNegativeSize();
                    Camera  camera = view.camera;
                    Vector3 vector = camera.WorldToScreenPoint(view.pivot);
                    vector += new Vector3(-Event.current.delta.x, Event.current.delta.y, 0f);
                    Vector3 vector2 = Camera.current.ScreenToWorldPoint(vector) - view.pivot;
                    vector2 *= EditorGUIUtility.pixelsPerPoint;
                    if (current.shift)
                    {
                        vector2 *= 4f;
                    }
                    view.pivot += vector2;
                    break;
                }

                case ViewTool.Zoom:
                {
                    float num = HandleUtility.niceMouseDeltaZoom * (float)((!current.shift) ? 3 : 9);
                    if (view.orthographic)
                    {
                        view.size = Mathf.Max(0.0001f, view.size * (1f + num * 0.001f));
                    }
                    else
                    {
                        SceneViewMotion.s_TotalMotion += num;
                        if (SceneViewMotion.s_TotalMotion < 0f)
                        {
                            view.size = SceneViewMotion.s_StartZoom * (1f + SceneViewMotion.s_TotalMotion * 0.001f);
                        }
                        else
                        {
                            view.size += num * SceneViewMotion.s_ZoomSpeed * 0.003f;
                        }
                    }
                    break;
                }

                case ViewTool.FPS:
                    if (!view.in2DMode && !view.isRotationLocked)
                    {
                        if (!view.orthographic)
                        {
                            view.viewIsLockedToObject = false;
                            Vector3    a          = view.pivot - view.rotation * Vector3.forward * view.cameraDistance;
                            Quaternion quaternion = view.rotation;
                            quaternion    = Quaternion.AngleAxis(current.delta.y * 0.003f * 57.29578f, quaternion * Vector3.right) * quaternion;
                            quaternion    = Quaternion.AngleAxis(current.delta.x * 0.003f * 57.29578f, Vector3.up) * quaternion;
                            view.rotation = quaternion;
                            view.pivot    = a + quaternion * Vector3.forward * view.cameraDistance;
                        }
                        else
                        {
                            SceneViewMotion.OrbitCameraBehavior(view);
                        }
                        view.svRot.UpdateGizmoLabel(view, view.rotation * Vector3.forward, view.m_Ortho.target);
                    }
                    break;

                default:
                    Debug.Log("Enum value Tools.s_LockViewTool not handled");
                    break;
                }
                current.Use();
            }
        }
        private static void HandleMouseDrag(SceneView view, int id)
        {
            SceneViewMotion.s_Dragged = true;
            if (GUIUtility.hotControl != id)
            {
                return;
            }
            Event current = Event.current;

            switch (Tools.s_LockedViewTool)
            {
            case ViewTool.Orbit:
                if (!view.in2DMode)
                {
                    SceneViewMotion.OrbitCameraBehavior(view);
                    view.svRot.UpdateGizmoLabel(view, view.rotation * Vector3.forward, view.m_Ortho.target);
                    break;
                }
                break;

            case ViewTool.Pan:
                view.viewIsLockedToObject = false;
                view.FixNegativeSize();
                Vector3 vector3_1 = Camera.current.ScreenToWorldPoint(view.camera.WorldToScreenPoint(view.pivot) + new Vector3(-Event.current.delta.x, Event.current.delta.y, 0.0f)) - view.pivot;
                if (current.shift)
                {
                    vector3_1 *= 4f;
                }
                view.pivot += vector3_1;
                break;

            case ViewTool.Zoom:
                float num = HandleUtility.niceMouseDeltaZoom * (!current.shift ? 3f : 9f);
                if (view.orthographic)
                {
                    view.size = Mathf.Max(0.0001f, view.size * (float)(1.0 + (double)num * (1.0 / 1000.0)));
                    break;
                }
                SceneViewMotion.s_TotalMotion += num;
                view.size = (double)SceneViewMotion.s_TotalMotion >= 0.0 ? view.size + (float)((double)num * (double)SceneViewMotion.s_ZoomSpeed * (3.0 / 1000.0)) : SceneViewMotion.s_StartZoom * (float)(1.0 + (double)SceneViewMotion.s_TotalMotion * (1.0 / 1000.0));
                break;

            case ViewTool.FPS:
                if (!view.in2DMode)
                {
                    if (!view.orthographic)
                    {
                        view.viewIsLockedToObject = false;
                        Vector3    vector3_2   = view.pivot - view.rotation * Vector3.forward * view.cameraDistance;
                        Quaternion rotation    = view.rotation;
                        Quaternion quaternion1 = Quaternion.AngleAxis((float)((double)current.delta.y * (3.0 / 1000.0) * 57.2957801818848), rotation * Vector3.right) * rotation;
                        Quaternion quaternion2 = Quaternion.AngleAxis((float)((double)current.delta.x * (3.0 / 1000.0) * 57.2957801818848), Vector3.up) * quaternion1;
                        view.rotation = quaternion2;
                        view.pivot    = vector3_2 + quaternion2 * Vector3.forward * view.cameraDistance;
                    }
                    else
                    {
                        SceneViewMotion.OrbitCameraBehavior(view);
                    }
                    view.svRot.UpdateGizmoLabel(view, view.rotation * Vector3.forward, view.m_Ortho.target);
                    break;
                }
                break;

            default:
                Debug.Log((object)"Enum value Tools.s_LockViewTool not handled");
                break;
            }
            current.Use();
        }