Complete universe model migration
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import * as THREE from "three";
|
||||
import { scaleGalaxyVector, toThreeVector } from "./viewerMath";
|
||||
import {
|
||||
determineActiveSystemId,
|
||||
focusOnSelection,
|
||||
@@ -62,6 +63,22 @@ export interface ViewerNavigationContext {
|
||||
export class ViewerNavigationController {
|
||||
constructor(private readonly context: ViewerNavigationContext) {}
|
||||
|
||||
syncGalaxyAnchorToActiveSystem() {
|
||||
const world = this.context.getWorld();
|
||||
const activeSystemId = this.context.getActiveSystemId();
|
||||
const povLevel = this.context.getPovLevel();
|
||||
if (!world || !activeSystemId || povLevel === "galaxy") {
|
||||
return;
|
||||
}
|
||||
|
||||
const system = world.systems.get(activeSystemId);
|
||||
if (!system) {
|
||||
return;
|
||||
}
|
||||
|
||||
this.context.galaxyAnchor.copy(scaleGalaxyVector(toThreeVector(system.galaxyPosition)));
|
||||
}
|
||||
|
||||
focusOnSelection(selection: Selectable) {
|
||||
focusOnSelection({
|
||||
world: this.context.getWorld(),
|
||||
@@ -70,7 +87,7 @@ export class ViewerNavigationController {
|
||||
nodeVisuals: this.context.nodeVisuals,
|
||||
planetVisuals: this.context.planetVisuals,
|
||||
computeNodeLocalPosition: (node, timeSeconds) => computeNodeLocalPosition(this.context.createWorldPresentationContext(), node, timeSeconds),
|
||||
resolvePointPosition: (systemId, celestialId) => resolvePointPosition(this.context.createWorldPresentationContext(), systemId, celestialId),
|
||||
resolvePointPosition: (systemId, celestialId, anchorId) => resolvePointPosition(this.context.createWorldPresentationContext(), systemId, celestialId, anchorId),
|
||||
activeSystemId: this.context.getActiveSystemId(),
|
||||
galaxyAnchor: this.context.galaxyAnchor,
|
||||
systemAnchor: this.context.systemAnchor,
|
||||
@@ -85,7 +102,7 @@ export class ViewerNavigationController {
|
||||
nodeVisuals: this.context.nodeVisuals,
|
||||
planetVisuals: this.context.planetVisuals,
|
||||
computeNodeLocalPosition: (node, timeSeconds) => computeNodeLocalPosition(this.context.createWorldPresentationContext(), node, timeSeconds),
|
||||
resolvePointPosition: (systemId, celestialId) => resolvePointPosition(this.context.createWorldPresentationContext(), systemId, celestialId),
|
||||
resolvePointPosition: (systemId, celestialId, anchorId) => resolvePointPosition(this.context.createWorldPresentationContext(), systemId, celestialId, anchorId),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -171,7 +188,7 @@ export class ViewerNavigationController {
|
||||
nodeVisuals: this.context.nodeVisuals,
|
||||
planetVisuals: this.context.planetVisuals,
|
||||
computeNodeLocalPosition: (node, timeSeconds) => computeNodeLocalPosition(this.context.createWorldPresentationContext(), node, timeSeconds),
|
||||
resolvePointPosition: (systemIdValue, celestialId) => resolvePointPosition(this.context.createWorldPresentationContext(), systemIdValue, celestialId),
|
||||
resolvePointPosition: (systemIdValue, celestialId, anchorId) => resolvePointPosition(this.context.createWorldPresentationContext(), systemIdValue, celestialId, anchorId),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user