Exemplo n.º 1
0
        void Update()
        {
            // Camera angle adjustment by right mouse drag
            var mp   = float3(Input.mousePosition).xy;
            var d_mp = (float2)(mp - _prevMousePos);

            if (Input.GetMouseButton(1))
            {
                var d_angle = d_mp.yx * float2(-1, 1) * 0.002f;
                _cameraAngles.xy = clamp(_cameraAngles.xy + d_angle, -1, 1);
            }

            _prevMousePos = mp;

            // Camera pivot rotation
            var pivot  = transform.parent;
            var target = EulerZXY(_cameraAngles);

            pivot.localRotation = ExpTween.Step(pivot.localRotation, target, 12);

            // Mouse wheel (camera distance)
            var d_dist = Input.mouseScrollDelta.y * -0.8f;

            _cameraDistance = Mathf.Max(1, _cameraDistance + d_dist);

            var z = transform.localPosition.z;

            z = ExpTween.Step(z, -_cameraDistance, 12);

            transform.localPosition = new Vector3(0, 0, z);
        }
Exemplo n.º 2
0
        void Update()
        {
            if (_dragFrom == null || _dragTo == null)
            {
                return;
            }

            var delta  = RotationBetween((float3)_dragFrom, (float3)_dragTo);
            var target = mul(delta, _rotateFrom);

            transform.localRotation = ExpTween.Step(transform.localRotation, target, 12);
        }
Exemplo n.º 3
0
        void Update()
        {
            // Camera pivot rotation
            var pivot  = transform.parent;
            var target = EulerZXY(_cameraAngles);

            pivot.localRotation = ExpTween.Step(pivot.localRotation, target, 12);

            // Mouse wheel (camera distance)
            var d_dist = Input.mouseScrollDelta.y * -0.8f;

            _cameraDistance = Mathf.Max(1, _cameraDistance + d_dist);

            var z = transform.localPosition.z;

            z = ExpTween.Step(z, -_cameraDistance, 12);

            transform.localPosition = new Vector3(0, 0, z);
        }
Exemplo n.º 4
0
        void Update()
        {
            // Update the drag-to point while pressing the left button down.
            if (Input.GetMouseButton(0))
            {
                _dragTo = MouseRayCast() ?? _dragTo;
            }

            // Update the drag-from point on a left button down.
            if (Input.GetMouseButtonDown(0))
            {
                _dragFrom   = _dragTo;
                _rotateFrom = transform.localRotation;
            }

            // Globe pivot rotation
            if (_dragFrom != null && _dragTo != null)
            {
                var delta  = RotationBetween((float3)_dragFrom, (float3)_dragTo);
                var target = mul(delta, _rotateFrom);
                transform.localRotation = ExpTween.Step(transform.localRotation, target, 12);
            }
        }