Skip to content

Commit

Permalink
Merge pull request #163 from BarthPaleologue/SpaceElevators
Browse files Browse the repository at this point in the history
Space elevators
  • Loading branch information
BarthPaleologue authored Nov 3, 2024
2 parents 44409e4 + 18e5b50 commit b04b773
Show file tree
Hide file tree
Showing 74 changed files with 1,876 additions and 1,082 deletions.
1,289 changes: 614 additions & 675 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions src/locales/en-US/objectTypes.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"telluricPlanet": "Telluric Planet",
"telluricMoon": "Telluric Moon",
"spaceStation": "Space Station",
"spaceElevator": "Space Elevator",
"spaceElevatorClimber": "Space Elevator Climber",
"anomaly": "Anomaly",
"landingPad": "Landing Pad"
}
22 changes: 12 additions & 10 deletions src/locales/fr-FR/objectTypes.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{
"starSystem": "Système Solaire",
"star": "Étoile de type {{stellarType}}",
"neutronStar": "Étoile à Neutrons",
"blackHole": "Trou Noir",
"gasPlanet": "Planète Gazeuse",
"telluricPlanet": "Planète Tellurique",
"telluricMoon": "Lune Tellurique",
"spaceStation": "Station Spatiale",
"anomaly": "Anomalie",
"landingPad": "Plateforme d'Atterrissage"
"starSystem": "Système Solaire",
"star": "Étoile de type {{stellarType}}",
"neutronStar": "Étoile à Neutrons",
"blackHole": "Trou Noir",
"gasPlanet": "Planète Gazeuse",
"telluricPlanet": "Planète Tellurique",
"telluricMoon": "Lune Tellurique",
"spaceStation": "Station Spatiale",
"spaceElevator": "Ascenseur Spatial",
"spaceElevatorClimber": "Nacelle de l'Ascenseur Spatial",
"anomaly": "Anomalie",
"landingPad": "Plateforme d'Atterrissage"
}
31 changes: 16 additions & 15 deletions src/ts/alphaTestis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ import "../styles/index.scss";
import { Settings } from "./settings";
import { positionNearObjectBrightSide } from "./utils/positionNearObject";
import { CosmosJourneyer } from "./cosmosJourneyer";
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
import { newSeededGasPlanetModel } from "./planets/gasPlanet/gasPlanetModel";
import { SpaceShipControlsInputs } from "./spaceship/spaceShipControlsInputs";

import { newSeededStarModel } from "./stellarObjects/star/starModel";
import { newSeededSpaceStationModel } from "./spacestation/spacestationModel";
import { StarSystemModel } from "./starSystem/starSystemModel";
import { StarSystemCoordinates } from "./utils/coordinates/universeCoordinates";
import { CustomSystemRegistry } from "./starSystem/customSystemRegistry";
import { newSeededTelluricSatelliteModel } from "./planets/telluricPlanet/telluricSatelliteModel";
import { newSeededTelluricPlanetModel } from "./planets/telluricPlanet/telluricPlanetModel";
import { newSeededSpaceElevatorModel } from "./spacestation/spaceElevatorModel";
import { getOrbitRadiusFromPeriod } from "./utils/physics";
import { Quaternion } from "@babylonjs/core/Maths/math";

const engine = await CosmosJourneyer.CreateAsync();

Expand Down Expand Up @@ -69,11 +70,13 @@ const hecateModel = newSeededTelluricPlanetModel(253, "Hécate", [sunModel]);
hecateModel.physics.minTemperature = -40;
hecateModel.physics.maxTemperature = 30;

hecateModel.physics.siderealDayDuration = 6 * 60 * 60;

hecateModel.orbit.period = 60 * 60 * 24 * 365.25;
hecateModel.orbit.radius = 25000 * hecateModel.radius;
hecateModel.orbit.normalToPlane = Vector3.Up();
hecateModel.orbit.orientation = Quaternion.Identity();

const spaceStationModel = newSeededSpaceStationModel(0, [sunModel], systemCoordinates, [hecateModel]);
const spaceStationModel = newSeededSpaceElevatorModel(0, [sunModel], systemCoordinates, hecateModel);

//physicsViewer.showBody(spaceStation.aggregate.body);
/*for(const landingpad of spaceStation.landingPads) {
Expand All @@ -82,19 +85,18 @@ const spaceStationModel = newSeededSpaceStationModel(0, [sunModel], systemCoordi

const moonModel = newSeededTelluricSatelliteModel(23, "Manaleth", [hecateModel]);
moonModel.physics.mass = 2;
moonModel.physics.rotationPeriod = 7 * 60 * 60;
moonModel.physics.siderealDayDuration = 28 * 60 * 60;
moonModel.physics.minTemperature = -180;
moonModel.physics.maxTemperature = 200;
moonModel.physics.waterAmount = 0.9;

moonModel.orbit.period = moonModel.physics.rotationPeriod;
moonModel.orbit.radius = 8 * hecateModel.radius;
moonModel.orbit.normalToPlane = Vector3.Up();
moonModel.orbit.period = moonModel.physics.siderealDayDuration;
moonModel.orbit.radius = getOrbitRadiusFromPeriod(moonModel.orbit.period, hecateModel.physics.mass);

const aresModel = newSeededTelluricPlanetModel(0.3725, "Ares", [sunModel]);
if (aresModel.clouds !== null) aresModel.clouds.coverage = 1;
aresModel.physics.mass = 7;
aresModel.physics.rotationPeriod = (24 * 60 * 60) / 30;
aresModel.physics.siderealDayDuration = (24 * 60 * 60) / 30;
aresModel.physics.minTemperature = -30;
aresModel.physics.maxTemperature = 20;
aresModel.physics.pressure = 0.5;
Expand All @@ -103,7 +105,6 @@ aresModel.physics.oceanLevel = 0;

aresModel.orbit.period = 60 * 60 * 24 * 365.24;
aresModel.orbit.radius = 25020 * hecateModel.radius;
aresModel.orbit.normalToPlane = Vector3.Up();

//aresModel.terrainSettings.continents_fragmentation = 0.0;
//aresModel.terrainSettings.continent_base_height = 10e3;
Expand All @@ -112,7 +113,7 @@ aresModel.orbit.normalToPlane = Vector3.Up();
const andromaqueModel = newSeededGasPlanetModel(0.28711440474126226, "Andromaque", [sunModel]);
andromaqueModel.orbit.period = 60 * 60 * 24 * 365.25;
andromaqueModel.orbit.radius = 25300 * hecateModel.radius;
andromaqueModel.orbit.normalToPlane = Vector3.Up();
andromaqueModel.orbit.orientation = Quaternion.Identity();

const starSystemModel: StarSystemModel = {
name: systemName,
Expand All @@ -121,12 +122,12 @@ const starSystemModel: StarSystemModel = {
{
stellarObjects: [sunModel],
planetarySystems: [
{ planets: [hecateModel], satellites: [moonModel], spaceStations: [spaceStationModel] },
{ planets: [aresModel], satellites: [], spaceStations: [] },
{ planets: [andromaqueModel], satellites: [], spaceStations: [] }
{ planets: [hecateModel], satellites: [moonModel], orbitalFacilities: [spaceStationModel] },
{ planets: [aresModel], satellites: [], orbitalFacilities: [] },
{ planets: [andromaqueModel], satellites: [], orbitalFacilities: [] }
],
anomalies: [],
spaceStations: []
orbitalFacilities: []
}
]
};
Expand Down
9 changes: 7 additions & 2 deletions src/ts/anomalies/julia/juliaSet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@
import { Camera } from "@babylonjs/core/Cameras/camera";
import { JuliaSetModel } from "./juliaSetModel";
import { PostProcessType } from "../../postProcesses/postProcessTypes";
import { Axis } from "@babylonjs/core/Maths/math.axis";
import { TransformNode } from "@babylonjs/core/Meshes";
import { Scene } from "@babylonjs/core/scene";
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
import { Cullable } from "../../utils/cullable";
import { CelestialBody } from "../../architecture/celestialBody";
import { orbitalObjectTypeToDisplay } from "../../utils/strings/orbitalObjectTypeToDisplay";
import { defaultTargetInfoCelestialBody, TargetInfo } from "../../architecture/targetable";
import { setRotationQuaternion } from "../../uberCore/transforms/basicTransform";

export class JuliaSet implements CelestialBody, Cullable {
readonly model: JuliaSetModel;
Expand All @@ -36,6 +37,8 @@ export class JuliaSet implements CelestialBody, Cullable {
readonly ringsUniforms = null;
readonly asteroidField = null;

readonly targetInfo: TargetInfo;

/**
* New Gas Planet
* @param model The model to create the planet from or a seed for the planet in [-1, 1]
Expand All @@ -48,7 +51,9 @@ export class JuliaSet implements CelestialBody, Cullable {

this.postProcesses.push(PostProcessType.JULIA_SET);

this.getTransform().rotate(Axis.X, this.model.physics.axialTilt);
setRotationQuaternion(this.getTransform(), this.model.physics.axialTilt);

this.targetInfo = defaultTargetInfoCelestialBody(this.getBoundingRadius());
}

getTransform(): TransformNode {
Expand Down
10 changes: 5 additions & 5 deletions src/ts/anomalies/julia/juliaSetModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@
import { normalRandom } from "extended-random";
import { clamp } from "../../utils/math";
import { getOrbitalPeriod, getPeriapsis, Orbit } from "../../orbit/orbit";
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
import { OrbitalObjectPhysicsInfo } from "../../architecture/physicsInfo";
import { CelestialBodyModel } from "../../architecture/celestialBody";
import { GenerationSteps } from "../../utils/generationSteps";
import { Color3 } from "@babylonjs/core/Maths/math.color";
import { AnomalyModel } from "../anomaly";

import { getRngFromSeed } from "../../utils/getRngFromSeed";
import { OrbitalObjectType } from "../../architecture/orbitalObject";
import { Quaternion } from "@babylonjs/core/Maths/math";
import { Axis } from "@babylonjs/core/Maths/math.axis";

export type JuliaSetModel = AnomalyModel & {
readonly type: OrbitalObjectType.JULIA_SET;
Expand All @@ -51,13 +51,13 @@ export function newSeededJuliaSetModel(seed: number, name: string, parentBodies:
radius: orbitRadius,
p: orbitalP,
period: getOrbitalPeriod(orbitRadius, parentMassSum),
normalToPlane: Vector3.Up()
orientation: Quaternion.Identity()
};

const physicalProperties: OrbitalObjectPhysicsInfo = {
mass: 10,
rotationPeriod: 0,
axialTilt: normalRandom(0, 0.4, rng, GenerationSteps.AXIAL_TILT)
siderealDayDuration: 0,
axialTilt: Quaternion.RotationAxis(Axis.X, normalRandom(0, 0.4, rng, GenerationSteps.AXIAL_TILT))
};

return {
Expand Down
10 changes: 8 additions & 2 deletions src/ts/anomalies/mandelbulb/mandelbulb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,16 @@
import { Camera } from "@babylonjs/core/Cameras/camera";
import { MandelbulbModel } from "./mandelbulbModel";
import { PostProcessType } from "../../postProcesses/postProcessTypes";
import { Axis } from "@babylonjs/core/Maths/math.axis";
import { TransformNode } from "@babylonjs/core/Meshes";
import { Scene } from "@babylonjs/core/scene";
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
import { Cullable } from "../../utils/cullable";
import { CelestialBody } from "../../architecture/celestialBody";
import { orbitalObjectTypeToDisplay } from "../../utils/strings/orbitalObjectTypeToDisplay";

import { defaultTargetInfoCelestialBody, TargetInfo } from "../../architecture/targetable";
import { setRotationQuaternion } from "../../uberCore/transforms/basicTransform";

export class Mandelbulb implements CelestialBody, Cullable {
readonly model: MandelbulbModel;

Expand All @@ -36,6 +38,8 @@ export class Mandelbulb implements CelestialBody, Cullable {
readonly asteroidField = null;
readonly ringsUniforms = null;

readonly targetInfo: TargetInfo;

/**
* New Gas Planet
* @param model The model to create the planet from or a seed for the planet in [-1, 1]
Expand All @@ -48,7 +52,9 @@ export class Mandelbulb implements CelestialBody, Cullable {

this.postProcesses.push(PostProcessType.MANDELBULB);

this.getTransform().rotate(Axis.X, this.model.physics.axialTilt);
setRotationQuaternion(this.getTransform(), this.model.physics.axialTilt);

this.targetInfo = defaultTargetInfoCelestialBody(this.getBoundingRadius());
}

getTransform(): TransformNode {
Expand Down
9 changes: 5 additions & 4 deletions src/ts/anomalies/mandelbulb/mandelbulbModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,15 @@ import { Color3 } from "@babylonjs/core/Maths/math.color";
import { normalRandom, randRange } from "extended-random";
import { clamp } from "../../utils/math";
import { getOrbitalPeriod, getPeriapsis, Orbit } from "../../orbit/orbit";
import { Vector3 } from "@babylonjs/core/Maths/math.vector";
import { CelestialBodyModel } from "../../architecture/celestialBody";
import { GenerationSteps } from "../../utils/generationSteps";
import { OrbitalObjectPhysicsInfo } from "../../architecture/physicsInfo";
import { AnomalyModel } from "../anomaly";

import { getRngFromSeed } from "../../utils/getRngFromSeed";
import { OrbitalObjectType } from "../../architecture/orbitalObject";
import { Quaternion } from "@babylonjs/core/Maths/math";
import { Axis } from "@babylonjs/core/Maths/math.axis";

export type MandelbulbModel = AnomalyModel & {
readonly type: OrbitalObjectType.MANDELBULB;
Expand All @@ -53,13 +54,13 @@ export function newSeededMandelbulbModel(seed: number, name: string, parentBodie
radius: orbitRadius,
p: orbitalP,
period: getOrbitalPeriod(orbitRadius, parentMassSum),
normalToPlane: Vector3.Up()
orientation: Quaternion.Identity()
};

const physicalProperties: OrbitalObjectPhysicsInfo = {
mass: 10,
rotationPeriod: 0,
axialTilt: normalRandom(0, 0.4, rng, GenerationSteps.AXIAL_TILT)
siderealDayDuration: 0,
axialTilt: Quaternion.RotationAxis(Axis.X, normalRandom(0, 0.4, rng, GenerationSteps.AXIAL_TILT))
};

return {
Expand Down
3 changes: 2 additions & 1 deletion src/ts/architecture/celestialBody.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
import { OrbitalObject, OrbitalObjectModel } from "./orbitalObject";
import { HasPostProcesses } from "./hasPostProcesses";
import { CanHaveRings, CanHaveRingsModel } from "./canHaveRings";
import { Targetable } from "./targetable";

/**
* Describes all celestial bodies (a combination of OrbitalObject, CanHaveRings and HasPostProcesses)
*/
export interface CelestialBody extends OrbitalObject, CanHaveRings, HasPostProcesses {
export interface CelestialBody extends OrbitalObject, CanHaveRings, HasPostProcesses, Targetable {
/**
* The underlying model describing the data of the celestial body
*/
Expand Down
7 changes: 4 additions & 3 deletions src/ts/architecture/orbitalObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ export class OrbitalObjectUtils {
* @constructor
*/
static GetRotationAngle(object: OrbitalObject, deltaTime: number): number {
if (object.model.physics.rotationPeriod === 0) return 0;
return (2 * Math.PI * deltaTime) / object.model.physics.rotationPeriod;
if (object.model.physics.siderealDayDuration === 0) return 0;
return (2 * Math.PI * deltaTime) / object.model.physics.siderealDayDuration;
}

/**
Expand Down Expand Up @@ -142,7 +142,8 @@ export const enum OrbitalObjectType {
GAS_PLANET = 1002,
MANDELBULB = 2000,
JULIA_SET = 2001,
SPACE_STATION = 3000
SPACE_STATION = 3000,
SPACE_ELEVATOR = 3001
}

export const SatelliteTypes = [OrbitalObjectType.TELLURIC_SATELLITE, OrbitalObjectType.SPACE_STATION];
Expand Down
10 changes: 7 additions & 3 deletions src/ts/architecture/physicsInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,17 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

import { Quaternion } from "@babylonjs/core/Maths/math";

export type OrbitalObjectPhysicsInfo = {
mass: number;
/**
* Time needed for the object to rotate on its axis in seconds
* Time needed for the object to rotate 360° on its axis in seconds.
* It is slightly different from the duration of solar day which is the time it takes for the sun to be at the same position in the sky.
* @see https://en.wikipedia.org/wiki/Sidereal_time
*/
rotationPeriod: number;
axialTilt: number;
siderealDayDuration: number;
axialTilt: Quaternion;
};

export type StellarObjectPhysicsInfo = OrbitalObjectPhysicsInfo & {
Expand Down
2 changes: 1 addition & 1 deletion src/ts/architecture/planetaryMassObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@ export interface PlanetaryMassObject extends CelestialBody {

export type PlanetaryMassObjectModel = CelestialBodyModel & {
readonly physics: PlanetaryMassObjectPhysicsInfo;
};
};
3 changes: 3 additions & 0 deletions src/ts/architecture/stellarObject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import { PointLight } from "@babylonjs/core/Lights/pointLight";
import { CelestialBody, CelestialBodyModel } from "./celestialBody";
import { StellarObjectPhysicsInfo } from "./physicsInfo";
import { OrbitalObjectType } from "./orbitalObject";

export interface StellarObject extends CelestialBody {
model: StellarObjectModel;
Expand All @@ -27,4 +28,6 @@ export interface StellarObject extends CelestialBody {

export type StellarObjectModel = CelestialBodyModel & {
physics: StellarObjectPhysicsInfo;

type: OrbitalObjectType.STAR | OrbitalObjectType.NEUTRON_STAR | OrbitalObjectType.BLACK_HOLE;
};
29 changes: 29 additions & 0 deletions src/ts/architecture/targetable.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Transformable } from "./transformable";
import { HasBoundingSphere } from "./hasBoundingSphere";
import { TypedObject } from "./typedObject";

export const enum ObjectTargetCursorType {
CELESTIAL_BODY,
FACILITY,
ANOMALY,
LANDING_PAD,
STAR_SYSTEM
}

export type TargetInfo = {
type: ObjectTargetCursorType;
minDistance: number;
maxDistance: number;
};

export interface Targetable extends Transformable, HasBoundingSphere, TypedObject {
readonly targetInfo: TargetInfo;
}

export function defaultTargetInfoCelestialBody(boundingRadius: number): TargetInfo {
return {
type: ObjectTargetCursorType.CELESTIAL_BODY,
minDistance: boundingRadius * 10.0,
maxDistance: 0.0
};
}
Loading

0 comments on commit b04b773

Please sign in to comment.