Improve close-up ship cameras and marine rendering

This commit is contained in:
josh
2026-11-28 00:16:51 -05:00
parent 4722db6456
commit 384f140b92
15 changed files with 875 additions and 230 deletions

View File

@@ -395,7 +395,7 @@ namespace Soundings
GameIcon(plan, "chart");
commands.Add(plan);
var camera = Add(commands, "camera-legend");
AddText(camera, "Drag to orbit / Scroll to zoom", "camera-copy");
AddText(camera, "Drag to orbit / Scroll to zoom / Middle-drag to pan", "camera-copy");
Button reset = Action("Reset", () => harbor.ResetView(), "camera-reset", "reset-camera");
reset.tooltip = "Reset harbor camera (Home)";
camera.Add(reset);
@@ -469,15 +469,16 @@ namespace Soundings
private void AttachCamera(VisualElement world)
{
int pointerId = -1;
bool freeLook = false;
bool freeLook = false, pan = false;
Vector2 start = Vector2.zero, last = Vector2.zero;
bool dragging = false;
world.RegisterCallback<PointerDownEvent>(evt =>
{
if (paused || pointerId >= 0 || (evt.button != 0 && evt.button != 1))
if (paused || pointerId >= 0 || evt.button < 0 || evt.button > 2)
return;
pointerId = evt.pointerId;
freeLook = underway != null && evt.button == 1 && (passageBridge || passageExploring);
pan = evt.button == 2;
SetPassageFreeLook(freeLook);
start = last = evt.localPosition;
dragging = false;
@@ -492,7 +493,12 @@ namespace Soundings
if (dragging || (position - start).sqrMagnitude > 16)
{
dragging = true;
if (!freeLook)
if (pan)
{
Vector2 delta = position - last;
harbor.Pan(new Vector2(delta.x / world.layout.width, -delta.y / world.layout.height));
}
else if (!freeLook)
harbor.Orbit(position - last);
else if (!passageCursorLocked)
harbor.Look(position - last);
@@ -531,7 +537,8 @@ namespace Soundings
{
if (paused)
return;
harbor.Zoom(evt.delta.y);
Vector2 point = world.WorldToLocal(evt.mousePosition);
harbor.Zoom(evt.delta.y, new Vector2(point.x / world.layout.width, 1f - point.y / world.layout.height));
evt.StopPropagation();
});
}