acdream/src/AcDream.App/Rendering/OrbitCamera.cs
Erik 5640c153f3 feat(app): extract ICamera interface from OrbitCamera
Introduce ICamera (View, Projection, Aspect) and make OrbitCamera implement
it. TerrainRenderer.Draw and StaticMeshRenderer.Draw now accept ICamera,
widening the call-site contract while leaving all runtime behavior unchanged.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-10 20:24:29 +02:00

28 lines
918 B
C#

using System.Numerics;
namespace AcDream.App.Rendering;
public sealed class OrbitCamera : ICamera
{
public Vector3 Target { get; set; } = new(96, 96, 0); // center of a 192x192 landblock
public float Distance { get; set; } = 300f;
public float Yaw { get; set; } = MathF.PI / 4f;
public float Pitch { get; set; } = MathF.PI / 6f;
public float FovY { get; set; } = MathF.PI / 3f;
public float Aspect { get; set; } = 16f / 9f;
public Matrix4x4 View
{
get
{
var eye = Target + new Vector3(
Distance * MathF.Cos(Pitch) * MathF.Cos(Yaw),
Distance * MathF.Cos(Pitch) * MathF.Sin(Yaw),
Distance * MathF.Sin(Pitch));
return Matrix4x4.CreateLookAt(eye, Target, Vector3.UnitZ);
}
}
public Matrix4x4 Projection
=> Matrix4x4.CreatePerspectiveFieldOfView(FovY, Aspect, 1f, 5000f);
}