feat: migrate simulation to physically-based unit system
Replace arbitrary game units with real-world measurements throughout the simulation and viewer: planet orbits in AU, sizes in km, galaxy positions in light-years. Add SimulationUnits helpers for conversions, separate WarpSpeed from FtlSpeed for ships, fix FTL transit progress to use galaxy-space distances, overhaul Lagrange point placement with Hill sphere approximation, and update the viewer to scale and format all distances correctly. Ships in FTL transit now render in galaxy view. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -2,6 +2,7 @@ import * as THREE from "three";
|
||||
import {
|
||||
completeMarqueeSelection,
|
||||
hideMarqueeBox,
|
||||
pickSelectableHitAtClientPosition,
|
||||
pickSelectableAtClientPosition,
|
||||
updateHoverLabel,
|
||||
updateMarqueeBox,
|
||||
@@ -17,6 +18,7 @@ import type {
|
||||
DragMode,
|
||||
Selectable,
|
||||
WorldState,
|
||||
ZoomLevel,
|
||||
} from "./viewerTypes";
|
||||
|
||||
export interface ViewerInteractionContext {
|
||||
@@ -30,6 +32,7 @@ export interface ViewerInteractionContext {
|
||||
keyState: Set<string>;
|
||||
getWorld: () => WorldState | undefined;
|
||||
getActiveSystemId: () => string | undefined;
|
||||
getZoomLevel: () => ZoomLevel;
|
||||
getSelectedItems: () => Selectable[];
|
||||
setSelectedItems: (items: Selectable[]) => void;
|
||||
getDragMode: () => DragMode | undefined;
|
||||
@@ -247,10 +250,12 @@ export class ViewerInteractionController {
|
||||
updateHoverLabel({
|
||||
dragMode: this.context.getDragMode(),
|
||||
hoverLabelEl: this.context.hoverLabelEl,
|
||||
selection: this.pickSelectableAtClientPosition(event.clientX, event.clientY),
|
||||
hoverPick: this.pickSelectableHitAtClientPosition(event.clientX, event.clientY),
|
||||
activeSystemId: this.context.getActiveSystemId(),
|
||||
zoomLevel: this.context.getZoomLevel(),
|
||||
world: this.context.getWorld(),
|
||||
point: this.context.screenPointFromClient(event.clientX, event.clientY),
|
||||
camera: this.context.camera,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -285,6 +290,18 @@ export class ViewerInteractionController {
|
||||
);
|
||||
}
|
||||
|
||||
private pickSelectableHitAtClientPosition(clientX: number, clientY: number) {
|
||||
return pickSelectableHitAtClientPosition(
|
||||
this.context.renderer,
|
||||
this.context.raycaster,
|
||||
this.context.mouse,
|
||||
this.context.camera,
|
||||
this.context.selectableTargets,
|
||||
clientX,
|
||||
clientY,
|
||||
);
|
||||
}
|
||||
|
||||
private completeMarqueeSelection() {
|
||||
const selection = completeMarqueeSelection({
|
||||
renderer: this.context.renderer,
|
||||
|
||||
Reference in New Issue
Block a user