31 lines
719 B
C#
31 lines
719 B
C#
// src/AcDream.App/Rendering/CameraController.cs
|
|
namespace AcDream.App.Rendering;
|
|
|
|
public sealed class CameraController
|
|
{
|
|
public OrbitCamera Orbit { get; }
|
|
public FlyCamera Fly { get; }
|
|
public ICamera Active { get; private set; }
|
|
public bool IsFlyMode => Active == Fly;
|
|
|
|
public event Action<bool>? ModeChanged;
|
|
|
|
public CameraController(OrbitCamera orbit, FlyCamera fly)
|
|
{
|
|
Orbit = orbit;
|
|
Fly = fly;
|
|
Active = orbit;
|
|
}
|
|
|
|
public void ToggleFly()
|
|
{
|
|
Active = IsFlyMode ? (ICamera)Orbit : Fly;
|
|
ModeChanged?.Invoke(IsFlyMode);
|
|
}
|
|
|
|
public void SetAspect(float aspect)
|
|
{
|
|
Orbit.Aspect = aspect;
|
|
Fly.Aspect = aspect;
|
|
}
|
|
}
|