Sonnensystem verbessert
This commit is contained in:
+45
-6
@@ -2194,6 +2194,35 @@ function getMinorPlanetHelioPosition(minorPlanet, date) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getMinorPlanetHelioPositionFromEccentricAnomaly(minorPlanet, eccentricAnomaly) {
|
||||||
|
if (!minorPlanet) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const eccentricity = Math.max(0, Math.min(0.999999, minorPlanet.eccentricity));
|
||||||
|
const semimajorAxisAu = minorPlanet.semimajorAxisAu;
|
||||||
|
const inclination = minorPlanet.inclinationDeg * Math.PI / 180;
|
||||||
|
const ascendingNode = minorPlanet.ascendingNodeDeg * Math.PI / 180;
|
||||||
|
const argPerihelion = minorPlanet.argPerihelionDeg * Math.PI / 180;
|
||||||
|
const orbitalX = semimajorAxisAu * (Math.cos(eccentricAnomaly) - eccentricity);
|
||||||
|
const orbitalY = semimajorAxisAu * Math.sqrt(1 - eccentricity ** 2) * Math.sin(eccentricAnomaly);
|
||||||
|
const cosArg = Math.cos(argPerihelion);
|
||||||
|
const sinArg = Math.sin(argPerihelion);
|
||||||
|
const cosNode = Math.cos(ascendingNode);
|
||||||
|
const sinNode = Math.sin(ascendingNode);
|
||||||
|
const cosInc = Math.cos(inclination);
|
||||||
|
const sinInc = Math.sin(inclination);
|
||||||
|
const perifocalX = (cosArg * orbitalX) - (sinArg * orbitalY);
|
||||||
|
const perifocalY = (sinArg * orbitalX) + (cosArg * orbitalY);
|
||||||
|
|
||||||
|
return {
|
||||||
|
x: (cosNode * perifocalX) - (sinNode * perifocalY * cosInc),
|
||||||
|
y: (sinNode * perifocalX) + (cosNode * perifocalY * cosInc),
|
||||||
|
z: perifocalY * sinInc,
|
||||||
|
r: semimajorAxisAu * (1 - eccentricity * Math.cos(eccentricAnomaly)),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
function ensureCometObjects() {
|
function ensureCometObjects() {
|
||||||
if (!cometObjects) {
|
if (!cometObjects) {
|
||||||
cometObjects = new Map();
|
cometObjects = new Map();
|
||||||
@@ -2383,12 +2412,22 @@ function rebuildMinorPlanetOrbit(id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const periodDays = minorPlanet.meanMotionDegPerDay > 0 ? 360 / minorPlanet.meanMotionDegPerDay : 365;
|
const periodDays = minorPlanet.meanMotionDegPerDay > 0 ? 360 / minorPlanet.meanMotionDegPerDay : 365;
|
||||||
const steps = Math.max(180, Math.min(520, Math.round(periodDays / 8)));
|
const steps = Math.max(
|
||||||
|
360,
|
||||||
|
Math.min(
|
||||||
|
1440,
|
||||||
|
Math.round(
|
||||||
|
360
|
||||||
|
+ (minorPlanet.eccentricity * 720)
|
||||||
|
+ (Math.log10(Math.max(periodDays, 365) / 365) * 220)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
);
|
||||||
const positions = [];
|
const positions = [];
|
||||||
|
|
||||||
for (let step = 0; step <= steps; step += 1) {
|
for (let step = 0; step <= steps; step += 1) {
|
||||||
const orbitDate = new Date(Date.parse(`${minorPlanet.epochDateIso}T00:00:00Z`) + ((periodDays * step) / steps) * 86400000);
|
const eccentricAnomaly = (step / steps) * Math.PI * 2;
|
||||||
const heliocentric = getMinorPlanetHelioPosition(minorPlanet, orbitDate);
|
const heliocentric = getMinorPlanetHelioPositionFromEccentricAnomaly(minorPlanet, eccentricAnomaly);
|
||||||
if (!heliocentric) {
|
if (!heliocentric) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -3087,7 +3126,7 @@ function attachPointerControls() {
|
|||||||
|
|
||||||
canvas.addEventListener('wheel', (event) => {
|
canvas.addEventListener('wheel', (event) => {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
camRadiusTarget = Math.max(12, Math.min(900, camRadiusTarget * (1 + event.deltaY * 0.001)));
|
camRadiusTarget = Math.max(12, Math.min(2600, camRadiusTarget * (1 + event.deltaY * 0.001)));
|
||||||
camRadius = camRadiusTarget;
|
camRadius = camRadiusTarget;
|
||||||
updateCamera();
|
updateCamera();
|
||||||
}, { passive: false });
|
}, { passive: false });
|
||||||
@@ -3365,7 +3404,7 @@ async function initSolarSystem() {
|
|||||||
|
|
||||||
scene = new THREE.Scene();
|
scene = new THREE.Scene();
|
||||||
|
|
||||||
camera = new THREE.PerspectiveCamera(45, 1, 0.1, 2000);
|
camera = new THREE.PerspectiveCamera(45, 1, 0.1, 6000);
|
||||||
planetMeshes = new Map();
|
planetMeshes = new Map();
|
||||||
orbitLines = new Map();
|
orbitLines = new Map();
|
||||||
labelElements = new Map();
|
labelElements = new Map();
|
||||||
@@ -3413,7 +3452,7 @@ async function initSolarSystem() {
|
|||||||
for (let i = 0; i < starCount; i++) {
|
for (let i = 0; i < starCount; i++) {
|
||||||
const theta = Math.random() * Math.PI * 2;
|
const theta = Math.random() * Math.PI * 2;
|
||||||
const phi = Math.acos(2 * Math.random() - 1);
|
const phi = Math.acos(2 * Math.random() - 1);
|
||||||
const r = 860 + Math.random() * 80;
|
const r = 2600 + Math.random() * 200;
|
||||||
positions[i * 3] = r * Math.sin(phi) * Math.cos(theta);
|
positions[i * 3] = r * Math.sin(phi) * Math.cos(theta);
|
||||||
positions[i * 3 + 1] = r * Math.sin(phi) * Math.sin(theta);
|
positions[i * 3 + 1] = r * Math.sin(phi) * Math.sin(theta);
|
||||||
positions[i * 3 + 2] = r * Math.cos(phi);
|
positions[i * 3 + 2] = r * Math.cos(phi);
|
||||||
|
|||||||
Reference in New Issue
Block a user