feat: 3 scene rendering setup

This commit is contained in:
2026-03-18 08:49:51 -04:00
parent 933c6afd08
commit 358122a74a
33 changed files with 1094 additions and 1132 deletions

View File

@@ -5,7 +5,7 @@ import {
formatSystemDistance,
inventoryAmount,
} from "./viewerMath";
import { describeOrbitalParent, describeSelectable, describeShipCurrentAction, describeShipObjective, describeShipState, describeSpatialNodePathWithinSystem, getSelectionGroup, renderSystemDetails } from "./viewerSelection";
import { describeCelestialPathWithinSystem, describeOrbitalParent, describeSelectable, describeShipCurrentAction, describeShipObjective, describeShipState, getSelectionGroup, renderSystemDetails } from "./viewerSelection";
import type {
CameraMode,
HistoryWindowState,
@@ -20,7 +20,7 @@ import type {
interface DetailPanelParams {
world: WorldState;
selectedItems: Selectable[];
zoomLevel: string;
povLevel: string;
cameraMode: CameraMode;
cameraTargetShipId?: string;
worldLabel: string;
@@ -156,7 +156,7 @@ export function updateDetailPanel(
const {
world,
selectedItems,
zoomLevel,
povLevel,
cameraMode,
cameraTargetShipId,
worldLabel,
@@ -166,10 +166,9 @@ export function updateDetailPanel(
if (selectedItems.length === 0) {
detailTitleEl.textContent = worldLabel;
detailBodyEl.innerHTML = `
Zoom ${zoomLevel}<br>
Zoom ${povLevel}<br>
Systems ${world.systems.size}<br>
Spatial nodes ${world.spatialNodes.size}<br>
Bubbles ${world.localBubbles.size}<br>
Celestials ${world.celestials.size}<br>
Stations ${world.stations.size}<br>
Claims ${world.claims.size}<br>
Construction ${world.constructionSites.size}<br>
@@ -294,34 +293,17 @@ export function updateDetailPanel(
return;
}
if (selected.kind === "spatial-node") {
const node = world.spatialNodes.get(selected.id);
if (!node) {
if (selected.kind === "celestial") {
const celestial = world.celestials.get(selected.id);
if (!celestial) {
return;
}
const bubble = world.localBubbles.get(node.bubbleId);
detailTitleEl.textContent = `${node.kind} node`;
detailTitleEl.textContent = `${celestial.kind} celestial`;
detailBodyEl.innerHTML = `
<p>${node.systemId}</p>
<p>Bubble ${node.bubbleId}</p>
<p>Parent ${node.parentNodeId ?? "none"}<br>Orbit ref ${node.orbitReferenceId ?? "none"}</p>
<p>Occupying structure ${node.occupyingStructureId ?? "none"}</p>
<p>Bubble occupants ${bubble ? bubble.occupantShipIds.length + bubble.occupantStationIds.length : 0}</p>
`;
return;
}
if (selected.kind === "bubble") {
const bubble = world.localBubbles.get(selected.id);
if (!bubble) {
return;
}
detailTitleEl.textContent = `Bubble ${bubble.id}`;
detailBodyEl.innerHTML = `
<p>${bubble.systemId}</p>
<p>Anchor node ${bubble.nodeId}<br>Radius ${formatLocalDistance(bubble.radius)}</p>
<p>Ships ${bubble.occupantShipIds.length}<br>Stations ${bubble.occupantStationIds.length}</p>
<p>Claims ${bubble.occupantClaimIds.length}<br>Construction sites ${bubble.occupantConstructionSiteIds.length}</p>
<p>${celestial.systemId}</p>
<p>Parent ${celestial.parentNodeId ?? "none"}<br>Orbit ref ${celestial.orbitReferenceId ?? "none"}</p>
<p>Occupying structure ${celestial.occupyingStructureId ?? "none"}</p>
<p>Local space radius ${celestial.localSpaceRadius.toFixed(0)} km</p>
`;
return;
}
@@ -334,7 +316,7 @@ export function updateDetailPanel(
detailTitleEl.textContent = `Claim ${claim.id}`;
detailBodyEl.innerHTML = `
<p>${claim.systemId}</p>
<p>Node ${claim.nodeId}<br>Bubble ${claim.bubbleId}</p>
<p>Celestial ${claim.celestialId}</p>
<p>State ${claim.state}<br>Health ${claim.health.toFixed(0)}</p>
<p>Activates ${new Date(claim.activatesAtUtc).toLocaleTimeString()}</p>
`;
@@ -350,7 +332,7 @@ export function updateDetailPanel(
detailTitleEl.textContent = `Construction ${site.id}`;
detailBodyEl.innerHTML = `
<p>${site.systemId}</p>
<p>Node ${site.nodeId}<br>Bubble ${site.bubbleId}</p>
<p>Celestial ${site.celestialId}</p>
<p>${site.targetKind} ${site.targetDefinitionId}</p>
<p>State ${site.state}<br>Progress ${(site.progress * 100).toFixed(0)}%</p>
<p>Orders ${orderCount}<br>Assigned constructors ${site.assignedConstructorShipIds.length}</p>
@@ -445,8 +427,8 @@ export function describeSelectionParent(
return "unknown";
}
return station.anchorNodeId
? describeSpatialNodePathWithinSystem(world, station.systemId, station.anchorNodeId) ?? `${station.systemId} network`
return station.celestialId
? describeCelestialPathWithinSystem(world, station.systemId, station.celestialId) ?? `${station.systemId} network`
: "unknown";
}
if (selection.kind === "node") {
@@ -454,18 +436,15 @@ export function describeSelectionParent(
const visual = node ? nodeVisuals.get(selection.id) : undefined;
return describeOrbitalParent(world, node?.systemId, visual?.anchor);
}
if (selection.kind === "spatial-node") {
const node = world.spatialNodes.get(selection.id);
return node?.parentNodeId ?? `${node?.systemId ?? "unknown"} network`;
}
if (selection.kind === "bubble") {
return `${world.localBubbles.get(selection.id)?.nodeId ?? "unknown"} node`;
if (selection.kind === "celestial") {
const celestial = world.celestials.get(selection.id);
return celestial?.parentNodeId ?? `${celestial?.systemId ?? "unknown"} network`;
}
if (selection.kind === "claim") {
return world.claims.get(selection.id)?.nodeId ?? "unknown";
return world.claims.get(selection.id)?.celestialId ?? "unknown";
}
if (selection.kind === "construction-site") {
return world.constructionSites.get(selection.id)?.nodeId ?? "unknown";
return world.constructionSites.get(selection.id)?.celestialId ?? "unknown";
}
return "unknown";