From 8ef8e46d422b62ba05f4d46151f2beeedbea6372 Mon Sep 17 00:00:00 2001 From: KaiSD Date: Wed, 26 Feb 2025 10:53:45 +0100 Subject: [PATCH] =?UTF-8?q?=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B8=D1=82?= =?UTF-8?q?=D1=8C=20'wbld/orbits.html'?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- wbld/orbits.html | 431 +++++++++++++++++++++++++++-------------------- 1 file changed, 251 insertions(+), 180 deletions(-) diff --git a/wbld/orbits.html b/wbld/orbits.html index 9456071..543d7d6 100644 --- a/wbld/orbits.html +++ b/wbld/orbits.html @@ -1,215 +1,286 @@ - - Senthara Orbit, Rotation & Day/Night Visualization - - + + Senthara Orbit, Rotation & Day/Night Visualization + + - + // Clear global graphics. + globalGraphics.clear(); + + // Draw the central star. + globalGraphics.fillStyle(0xFFFF00, 1); + globalGraphics.fillCircle(centerX, centerY, 20); + + // Draw Senthara's orbital path (around the star). + globalGraphics.lineStyle(1, 0x555555, 1); + globalGraphics.strokeCircle(centerX, centerY, planetOrbitRadius); + + // Calculate Senthara's (the planet's) position along its orbit. + const planetOrbitAngle = Phaser.Math.DegToRad((360 * (simulationTime % planetPeriod)) / planetPeriod - 90); + const planetX = centerX + planetOrbitRadius * Math.cos(planetOrbitAngle); + const planetY = centerY + planetOrbitRadius * Math.sin(planetOrbitAngle); + + // Update the planet container's position. + planetContainer.x = planetX; + planetContainer.y = planetY; + // Set the planet's self-rotation (day/night cycle) with a 1-day period. + const planetRotationAngle = Phaser.Math.DegToRad((360 * (simulationTime % planetRotationPeriod)) / planetRotationPeriod); + planetContainer.rotation = planetRotationAngle; + + // Update the night overlay so that the dark half covers the side away from the star. + const subsolarAngle = Phaser.Math.Angle.Between(planetX, planetY, centerX, centerY); + // The night overlay's rotation is adjusted relative to the planet's rotation. + planetContainer.nightOverlay.rotation = subsolarAngle + Math.PI / 2 - planetContainer.rotation; + + // Calculate and update moon positions (relative to Senthara). + // Keriel: + const kerielOrbitAngle = Phaser.Math.DegToRad((360 * (simulationTime % kerielPeriod)) / kerielPeriod - 90); + const kerielX = planetX + kerielOrbitRadius * Math.cos(kerielOrbitAngle); + const kerielY = planetY + kerielOrbitRadius * Math.sin(kerielOrbitAngle); + kerielContainer.x = kerielX; + kerielContainer.y = kerielY; + // Ensure tidal locking: set Keriel's rotation so its marker points toward Senthara. + kerielContainer.rotation = Phaser.Math.Angle.Between(kerielX, kerielY, planetX, planetY); + + // Arkaen: + const arkaenOrbitAngle = Phaser.Math.DegToRad((360 * (simulationTime % arkaenPeriod)) / arkaenPeriod - 90); + const arkaenX = planetX + arkaenOrbitRadius * Math.cos(arkaenOrbitAngle); + const arkaenY = planetY + arkaenOrbitRadius * Math.sin(arkaenOrbitAngle); + arkaenContainer.x = arkaenX; + arkaenContainer.y = arkaenY; + arkaenContainer.rotation = Phaser.Math.Angle.Between(arkaenX, arkaenY, planetX, planetY); + + // Minian: + const minianOrbitAngle = Phaser.Math.DegToRad((360 * (simulationTime % minianPeriod)) / minianPeriod - 90); + const minianX = planetX + minianOrbitRadius * Math.cos(minianOrbitAngle); + const minianY = planetY + minianOrbitRadius * Math.sin(minianOrbitAngle); + minianContainer.x = minianX; + minianContainer.y = minianY; + minianContainer.rotation = Phaser.Math.Angle.Between(minianX, minianY, planetX, planetY); + + // Optionally, redraw the moons' orbital paths (around Senthara). + globalGraphics.lineStyle(1, 0x888888, 1); + globalGraphics.strokeCircle(planetX, planetY, kerielOrbitRadius); + globalGraphics.strokeCircle(planetX, planetY, arkaenOrbitRadius); + globalGraphics.strokeCircle(planetX, planetY, minianOrbitRadius); + + // Update the Senthara calendar date text. + dateText.setText(getSentharaDate(simulationTime)); + } + - + \ No newline at end of file