示例#1
0
        private static CameraTransform UpdateCameraTransform(CameraInput input, Vector3 targetPosition)
        {
            var dir           = new Vector3(0, 0, -input.Distance);
            var orbitRotation = Quaternion.Euler(input.Y, input.X, 0);
            var position      = targetPosition + TargetOffset + orbitRotation * dir;
            var rotation      = Quaternion.LookRotation(targetPosition + TargetOffset - position);

            return(new CameraTransform
            {
                Position = position,
                Rotation = rotation
            });
        }
示例#2
0
        private static CameraInput UpdateCameraInput(CameraInput input)
        {
            var x        = input.X + Input.GetAxis("Mouse X");
            var y        = input.Y - Input.GetAxis("Mouse Y");
            var distance = input.Distance + Input.GetAxis("Mouse ScrollWheel") * ZoomScale;

            x       %= 360;
            y        = Mathf.Clamp(y, MinYAngle, MaxYAngle);
            distance = Mathf.Clamp(distance, MinCameraDistance, MaxCameraDistance);

            return(new CameraInput
            {
                X = x,
                Y = y,
                Distance = distance
            });
        }