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|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
<!DOCTYPE html>
|
| 2 |
+
<html lang="en">
|
| 3 |
+
<head>
|
| 4 |
+
<meta charset="UTF-8">
|
| 5 |
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
| 6 |
+
<title>Rahu & Ketu: The Lunar Nodes</title>
|
| 7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
| 8 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
| 9 |
+
<script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.js"></script>
|
| 10 |
+
<style>
|
| 11 |
+
body { margin: 0; overflow: hidden; background-color: #030308; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; color: white; }
|
| 12 |
+
#canvas-container { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 1; }
|
| 13 |
+
#ui-layer { position: absolute; top: 0; left: 0; width: 100%; height: 100%; z-index: 10; pointer-events: none; }
|
| 14 |
+
.pointer-events-auto { pointer-events: auto; }
|
| 15 |
+
|
| 16 |
+
/* Glassmorphism panel */
|
| 17 |
+
.glass-panel {
|
| 18 |
+
background: rgba(15, 20, 35, 0.7);
|
| 19 |
+
backdrop-filter: blur(12px);
|
| 20 |
+
-webkit-backdrop-filter: blur(12px);
|
| 21 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
| 22 |
+
box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.5);
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
/* Custom Scrollbar for text panel */
|
| 26 |
+
::-webkit-scrollbar { width: 6px; }
|
| 27 |
+
::-webkit-scrollbar-track { background: rgba(0,0,0,0.1); }
|
| 28 |
+
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 10px; }
|
| 29 |
+
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.4); }
|
| 30 |
+
|
| 31 |
+
input[type=range] {
|
| 32 |
+
-webkit-appearance: none; background: transparent;
|
| 33 |
+
}
|
| 34 |
+
input[type=range]::-webkit-slider-thumb {
|
| 35 |
+
-webkit-appearance: none; height: 16px; width: 16px; border-radius: 50%;
|
| 36 |
+
background: #4ade80; cursor: pointer; margin-top: -6px;
|
| 37 |
+
}
|
| 38 |
+
input[type=range]::-webkit-slider-runnable-track {
|
| 39 |
+
width: 100%; height: 4px; cursor: pointer; background: rgba(255,255,255,0.2); border-radius: 2px;
|
| 40 |
+
}
|
| 41 |
+
</style>
|
| 42 |
+
</head>
|
| 43 |
+
<body>
|
| 44 |
+
|
| 45 |
+
<!-- 3D Canvas -->
|
| 46 |
+
<div id="canvas-container"></div>
|
| 47 |
+
|
| 48 |
+
<!-- UI Overlay -->
|
| 49 |
+
<div id="ui-layer" class="flex flex-col md:flex-row justify-between p-4 md:p-6 h-screen relative">
|
| 50 |
+
|
| 51 |
+
<!-- Left Info Panel -->
|
| 52 |
+
<div class="glass-panel w-full md:w-96 rounded-2xl p-6 flex flex-col pointer-events-auto h-auto max-h-[45vh] md:max-h-full overflow-y-auto mb-4 md:mb-0">
|
| 53 |
+
<h1 class="text-3xl font-bold bg-clip-text text-transparent bg-gradient-to-r from-orange-400 to-yellow-200 mb-2">Rahu & Ketu</h1>
|
| 54 |
+
<h2 class="text-sm text-gray-300 uppercase tracking-widest mb-6 border-b border-gray-600 pb-2">The Lunar Nodes</h2>
|
| 55 |
+
|
| 56 |
+
<div class="space-y-4 text-sm leading-relaxed text-gray-200">
|
| 57 |
+
<p>
|
| 58 |
+
<strong class="text-white text-base">What are they?</strong><br>
|
| 59 |
+
In astronomy, Rahu and Ketu are not physical planets. They are mathematical intersection points known as the <strong>Lunar Nodes</strong>.
|
| 60 |
+
</p>
|
| 61 |
+
<p>
|
| 62 |
+
The Earth orbits the Sun on a flat plane called the <em>Ecliptic</em>. However, the Moon's orbit around the Earth is tilted by about 5 degrees relative to this plane.
|
| 63 |
+
</p>
|
| 64 |
+
<p>
|
| 65 |
+
Because of this tilt, the Moon's orbit crosses the Earth's Ecliptic plane at exactly two points.
|
| 66 |
+
</p>
|
| 67 |
+
|
| 68 |
+
<div class="bg-orange-500/10 border border-orange-500/30 p-3 rounded-lg mt-2">
|
| 69 |
+
<h3 class="text-orange-400 font-bold mb-1">Rahu (North Node) ☊</h3>
|
| 70 |
+
<p class="text-xs">The <em>Ascending Node</em>. This is the exact point where the Moon crosses the ecliptic going from South to North.</p>
|
| 71 |
+
</div>
|
| 72 |
+
|
| 73 |
+
<div class="bg-gray-500/10 border border-gray-500/30 p-3 rounded-lg mt-2">
|
| 74 |
+
<h3 class="text-gray-300 font-bold mb-1">Ketu (South Node) ☋</h3>
|
| 75 |
+
<p class="text-xs">The <em>Descending Node</em>. This is the exact point where the Moon crosses the ecliptic going from North to South.</p>
|
| 76 |
+
</div>
|
| 77 |
+
|
| 78 |
+
<div class="bg-purple-500/10 border border-purple-500/30 p-3 rounded-lg mt-2">
|
| 79 |
+
<h3 class="text-purple-400 font-bold mb-1">The 18.6 Year Cycle</h3>
|
| 80 |
+
<p class="text-xs">The nodes are not stationary! The Moon's orbital plane slowly wobbles, causing the nodes to drift backwards (retrograde). It takes exactly <strong>18.6 years</strong> for Rahu and Ketu to complete one full cycle around the Zodiac. This is called <em>Nodal Precession</em>.</p>
|
| 81 |
+
</div>
|
| 82 |
+
|
| 83 |
+
<p class="mt-4 border-t border-gray-600 pt-4">
|
| 84 |
+
<strong class="text-yellow-300">Eclipses:</strong> A Solar or Lunar eclipse can <em>only</em> happen when the New Moon or Full Moon aligns closely with either Rahu or Ketu. In ancient mythology, these nodes were personified as shadow demons that "swallowed" the Sun and Moon.
|
| 85 |
+
</p>
|
| 86 |
+
</div>
|
| 87 |
+
</div>
|
| 88 |
+
|
| 89 |
+
<!-- Right / Bottom Controls -->
|
| 90 |
+
<div class="flex flex-col justify-end pointer-events-auto w-full md:w-auto">
|
| 91 |
+
<div class="glass-panel rounded-2xl p-5 w-full md:w-80 space-y-5">
|
| 92 |
+
|
| 93 |
+
<div class="flex items-center justify-between mb-2">
|
| 94 |
+
<h3 class="font-semibold text-white">Controls</h3>
|
| 95 |
+
<button id="btn-pause" class="bg-white/10 hover:bg-white/20 text-white px-3 py-1 rounded text-sm transition">Pause</button>
|
| 96 |
+
</div>
|
| 97 |
+
|
| 98 |
+
<!-- Time Speed -->
|
| 99 |
+
<div>
|
| 100 |
+
<label class="flex justify-between text-xs text-gray-400 mb-2">
|
| 101 |
+
<span>Time Speed</span>
|
| 102 |
+
<span id="speed-val">1x</span>
|
| 103 |
+
</label>
|
| 104 |
+
<input type="range" id="time-speed" min="0" max="5" step="0.1" value="1" class="w-full">
|
| 105 |
+
</div>
|
| 106 |
+
|
| 107 |
+
<!-- Camera Focus -->
|
| 108 |
+
<div>
|
| 109 |
+
<label class="block text-xs text-gray-400 mb-2">Camera Focus</label>
|
| 110 |
+
<div class="flex bg-black/40 rounded-lg p-1">
|
| 111 |
+
<button id="focus-sun" class="flex-1 py-1.5 text-sm rounded-md transition text-gray-400 hover:text-white">Sun</button>
|
| 112 |
+
<button id="focus-earth" class="flex-1 py-1.5 text-sm rounded-md transition bg-blue-500/30 text-blue-200 border border-blue-500/50">Earth</button>
|
| 113 |
+
</div>
|
| 114 |
+
</div>
|
| 115 |
+
|
| 116 |
+
<!-- Visibility Toggles -->
|
| 117 |
+
<div class="pt-2 border-t border-gray-700/50 space-y-2">
|
| 118 |
+
<label class="flex items-center space-x-2 text-sm cursor-pointer">
|
| 119 |
+
<input type="checkbox" id="toggle-ecliptic" checked class="rounded bg-gray-800 border-gray-600 text-blue-500 focus:ring-blue-500">
|
| 120 |
+
<span class="text-gray-300">Show Earth's Plane (Ecliptic)</span>
|
| 121 |
+
</label>
|
| 122 |
+
<label class="flex items-center space-x-2 text-sm cursor-pointer">
|
| 123 |
+
<input type="checkbox" id="toggle-lunar" checked class="rounded bg-gray-800 border-gray-600 text-blue-500 focus:ring-blue-500">
|
| 124 |
+
<span class="text-gray-300">Show Moon's Tilted Plane</span>
|
| 125 |
+
</label>
|
| 126 |
+
</div>
|
| 127 |
+
|
| 128 |
+
<!-- Wobble Controls -->
|
| 129 |
+
<div class="pt-2 border-t border-gray-700/50 space-y-3">
|
| 130 |
+
<h4 class="text-xs font-semibold text-purple-400 uppercase tracking-wider">Lunar Wobble Controls</h4>
|
| 131 |
+
|
| 132 |
+
<div>
|
| 133 |
+
<label class="flex justify-between text-xs text-gray-400 mb-1">
|
| 134 |
+
<span>Wobble (Precession) Speed</span>
|
| 135 |
+
<span id="wobble-speed-val">1x</span>
|
| 136 |
+
</label>
|
| 137 |
+
<input type="range" id="wobble-speed" min="0" max="100" step="1" value="1" class="w-full">
|
| 138 |
+
</div>
|
| 139 |
+
|
| 140 |
+
<div>
|
| 141 |
+
<label class="flex justify-between text-xs text-gray-400 mb-1">
|
| 142 |
+
<span>Tilt Angle</span>
|
| 143 |
+
<span id="tilt-val">15°</span>
|
| 144 |
+
</label>
|
| 145 |
+
<input type="range" id="tilt-angle" min="0" max="45" step="1" value="15" class="w-full">
|
| 146 |
+
</div>
|
| 147 |
+
|
| 148 |
+
<label class="flex items-center space-x-2 text-sm cursor-pointer">
|
| 149 |
+
<input type="checkbox" id="toggle-axis" checked class="rounded bg-gray-800 border-gray-600 text-purple-500 focus:ring-purple-500">
|
| 150 |
+
<span class="text-gray-300">Show Orbital Axis</span>
|
| 151 |
+
</label>
|
| 152 |
+
</div>
|
| 153 |
+
|
| 154 |
+
</div>
|
| 155 |
+
</div>
|
| 156 |
+
</div>
|
| 157 |
+
|
| 158 |
+
<script>
|
| 159 |
+
// --- THREE.JS SETUP ---
|
| 160 |
+
const canvasContainer = document.getElementById('canvas-container');
|
| 161 |
+
const scene = new THREE.Scene();
|
| 162 |
+
|
| 163 |
+
// Camera setup
|
| 164 |
+
const camera = new THREE.PerspectiveCamera(45, window.innerWidth / window.innerHeight, 0.1, 2000);
|
| 165 |
+
camera.position.set(0, 80, 150);
|
| 166 |
+
|
| 167 |
+
// Renderer setup
|
| 168 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
|
| 169 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 170 |
+
renderer.setPixelRatio(window.devicePixelRatio);
|
| 171 |
+
canvasContainer.appendChild(renderer.domElement);
|
| 172 |
+
|
| 173 |
+
// OrbitControls
|
| 174 |
+
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
| 175 |
+
controls.enableDamping = true;
|
| 176 |
+
controls.dampingFactor = 0.05;
|
| 177 |
+
controls.maxDistance = 600;
|
| 178 |
+
controls.minDistance = 20;
|
| 179 |
+
|
| 180 |
+
// --- ENVIRONMENT ---
|
| 181 |
+
// Starfield
|
| 182 |
+
const starsGeometry = new THREE.BufferGeometry();
|
| 183 |
+
const starsCount = 3000;
|
| 184 |
+
const posArray = new Float32Array(starsCount * 3);
|
| 185 |
+
for(let i = 0; i < starsCount * 3; i++) {
|
| 186 |
+
posArray[i] = (Math.random() - 0.5) * 1500;
|
| 187 |
+
}
|
| 188 |
+
starsGeometry.setAttribute('position', new THREE.BufferAttribute(posArray, 3));
|
| 189 |
+
const starsMaterial = new THREE.PointsMaterial({ size: 1.5, color: 0xffffff, transparent: true, opacity: 0.8 });
|
| 190 |
+
const starMesh = new THREE.Points(starsGeometry, starsMaterial);
|
| 191 |
+
scene.add(starMesh);
|
| 192 |
+
|
| 193 |
+
// Ambient Light
|
| 194 |
+
scene.add(new THREE.AmbientLight(0x333344));
|
| 195 |
+
|
| 196 |
+
// --- CELESTIAL BODIES ---
|
| 197 |
+
|
| 198 |
+
// 1. SUN SYSTEM
|
| 199 |
+
const sunSystem = new THREE.Group();
|
| 200 |
+
scene.add(sunSystem);
|
| 201 |
+
|
| 202 |
+
// Sun Mesh
|
| 203 |
+
const sunGeo = new THREE.SphereGeometry(15, 32, 32);
|
| 204 |
+
const sunMat = new THREE.MeshBasicMaterial({ color: 0xffaa00 });
|
| 205 |
+
const sun = new THREE.Mesh(sunGeo, sunMat);
|
| 206 |
+
sunSystem.add(sun);
|
| 207 |
+
|
| 208 |
+
// Sun Light
|
| 209 |
+
const sunLight = new THREE.PointLight(0xffffff, 2.5, 1000);
|
| 210 |
+
sunSystem.add(sunLight);
|
| 211 |
+
|
| 212 |
+
// Sun Glow (Sprite)
|
| 213 |
+
const glowCanvas = document.createElement('canvas');
|
| 214 |
+
glowCanvas.width = 128; glowCanvas.height = 128;
|
| 215 |
+
const ctx = glowCanvas.getContext('2d');
|
| 216 |
+
const gradient = ctx.createRadialGradient(64,64,0, 64,64,64);
|
| 217 |
+
gradient.addColorStop(0, 'rgba(255, 170, 0, 0.6)');
|
| 218 |
+
gradient.addColorStop(1, 'rgba(255, 170, 0, 0)');
|
| 219 |
+
ctx.fillStyle = gradient;
|
| 220 |
+
ctx.fillRect(0,0, 128,128);
|
| 221 |
+
const glowTexture = new THREE.CanvasTexture(glowCanvas);
|
| 222 |
+
const glowMaterial = new THREE.SpriteMaterial({ map: glowTexture, blending: THREE.AdditiveBlending, transparent: true });
|
| 223 |
+
const sunGlow = new THREE.Sprite(glowMaterial);
|
| 224 |
+
sunGlow.scale.set(60, 60, 1);
|
| 225 |
+
sun.add(sunGlow);
|
| 226 |
+
|
| 227 |
+
// 2. EARTH SYSTEM
|
| 228 |
+
const earthOrbitRadius = 120;
|
| 229 |
+
const earthSystem = new THREE.Group();
|
| 230 |
+
scene.add(earthSystem);
|
| 231 |
+
|
| 232 |
+
// Earth Orbit Line
|
| 233 |
+
const earthOrbitGeo = new THREE.RingGeometry(earthOrbitRadius - 0.2, earthOrbitRadius + 0.2, 128);
|
| 234 |
+
const earthOrbitMat = new THREE.MeshBasicMaterial({ color: 0x445566, side: THREE.DoubleSide, transparent: true, opacity: 0.5 });
|
| 235 |
+
const earthOrbitLine = new THREE.Mesh(earthOrbitGeo, earthOrbitMat);
|
| 236 |
+
earthOrbitLine.rotation.x = Math.PI / 2;
|
| 237 |
+
scene.add(earthOrbitLine);
|
| 238 |
+
|
| 239 |
+
// Earth Mesh
|
| 240 |
+
const earthGeo = new THREE.SphereGeometry(4, 32, 32);
|
| 241 |
+
const earthMat = new THREE.MeshStandardMaterial({ color: 0x2288ff, roughness: 0.6 });
|
| 242 |
+
const earth = new THREE.Mesh(earthGeo, earthMat);
|
| 243 |
+
earthSystem.add(earth);
|
| 244 |
+
|
| 245 |
+
// Ecliptic Plane (Local to Earth)
|
| 246 |
+
const eclipticGeo = new THREE.PlaneGeometry(60, 60);
|
| 247 |
+
const eclipticMat = new THREE.MeshBasicMaterial({ color: 0x22ff44, transparent: true, opacity: 0.1, side: THREE.DoubleSide });
|
| 248 |
+
const eclipticPlane = new THREE.Mesh(eclipticGeo, eclipticMat);
|
| 249 |
+
eclipticPlane.rotation.x = Math.PI / 2;
|
| 250 |
+
earthSystem.add(eclipticPlane);
|
| 251 |
+
|
| 252 |
+
// Ecliptic Grid Helper to make it clearer
|
| 253 |
+
const eclipticGrid = new THREE.GridHelper(60, 10, 0x22ff44, 0x22ff44);
|
| 254 |
+
eclipticGrid.material.opacity = 0.2;
|
| 255 |
+
eclipticGrid.material.transparent = true;
|
| 256 |
+
earthSystem.add(eclipticGrid);
|
| 257 |
+
|
| 258 |
+
// 3. MOON SYSTEM & NODAL PRECESSION
|
| 259 |
+
const nodalPrecessionGroup = new THREE.Group();
|
| 260 |
+
earthSystem.add(nodalPrecessionGroup);
|
| 261 |
+
|
| 262 |
+
const moonOrbitRadius = 22;
|
| 263 |
+
const moonSystem = new THREE.Group();
|
| 264 |
+
|
| 265 |
+
// TILT THE LUNAR ORBIT (Exaggerated to 15 degrees for visual clarity, real is ~5 degrees)
|
| 266 |
+
let lunarTilt = 15 * (Math.PI / 180);
|
| 267 |
+
moonSystem.rotation.x = lunarTilt;
|
| 268 |
+
nodalPrecessionGroup.add(moonSystem);
|
| 269 |
+
|
| 270 |
+
// Moon Orbit Axis (To visualize the wobble)
|
| 271 |
+
const axisGeo = new THREE.BufferGeometry().setFromPoints([
|
| 272 |
+
new THREE.Vector3(0, -30, 0),
|
| 273 |
+
new THREE.Vector3(0, 30, 0)
|
| 274 |
+
]);
|
| 275 |
+
const axisMat = new THREE.LineBasicMaterial({ color: 0xdd44ff, transparent: true, opacity: 0.8, linewidth: 2 });
|
| 276 |
+
const moonOrbitAxis = new THREE.Line(axisGeo, axisMat);
|
| 277 |
+
moonSystem.add(moonOrbitAxis);
|
| 278 |
+
|
| 279 |
+
// Moon Plane
|
| 280 |
+
const lunarPlaneGeo = new THREE.PlaneGeometry(50, 50);
|
| 281 |
+
const lunarPlaneMat = new THREE.MeshBasicMaterial({ color: 0x44aaff, transparent: true, opacity: 0.15, side: THREE.DoubleSide });
|
| 282 |
+
const lunarPlane = new THREE.Mesh(lunarPlaneGeo, lunarPlaneMat);
|
| 283 |
+
lunarPlane.rotation.x = Math.PI / 2;
|
| 284 |
+
moonSystem.add(lunarPlane);
|
| 285 |
+
|
| 286 |
+
// Moon Orbit Line
|
| 287 |
+
const moonOrbitLineGeo = new THREE.RingGeometry(moonOrbitRadius - 0.2, moonOrbitRadius + 0.2, 64);
|
| 288 |
+
const moonOrbitLineMat = new THREE.MeshBasicMaterial({ color: 0xaaaaff, side: THREE.DoubleSide, transparent: true, opacity: 0.8 });
|
| 289 |
+
const moonOrbitLine = new THREE.Mesh(moonOrbitLineGeo, moonOrbitLineMat);
|
| 290 |
+
moonOrbitLine.rotation.x = Math.PI / 2;
|
| 291 |
+
moonSystem.add(moonOrbitLine);
|
| 292 |
+
|
| 293 |
+
// Moon Mesh
|
| 294 |
+
const moonGeo = new THREE.SphereGeometry(1.2, 16, 16);
|
| 295 |
+
const moonMat = new THREE.MeshStandardMaterial({ color: 0xdddddd, roughness: 0.8 });
|
| 296 |
+
const moon = new THREE.Mesh(moonGeo, moonMat);
|
| 297 |
+
moonSystem.add(moon);
|
| 298 |
+
|
| 299 |
+
// --- RAHU & KETU NODES ---
|
| 300 |
+
// Create Sprite Text Labels
|
| 301 |
+
function createTextLabel(text, color) {
|
| 302 |
+
const canvas = document.createElement('canvas');
|
| 303 |
+
canvas.width = 512; canvas.height = 128;
|
| 304 |
+
const ctx = canvas.getContext('2d');
|
| 305 |
+
ctx.fillStyle = color;
|
| 306 |
+
ctx.font = 'bold 36px sans-serif';
|
| 307 |
+
ctx.textAlign = 'center';
|
| 308 |
+
ctx.textBaseline = 'middle';
|
| 309 |
+
|
| 310 |
+
// Background capsule
|
| 311 |
+
ctx.fillStyle = 'rgba(0, 0, 0, 0.6)';
|
| 312 |
+
ctx.beginPath();
|
| 313 |
+
ctx.roundRect(64, 20, 384, 88, 44);
|
| 314 |
+
ctx.fill();
|
| 315 |
+
ctx.strokeStyle = color;
|
| 316 |
+
ctx.lineWidth = 3;
|
| 317 |
+
ctx.stroke();
|
| 318 |
+
|
| 319 |
+
// Text
|
| 320 |
+
ctx.fillStyle = color;
|
| 321 |
+
ctx.fillText(text, 256, 64);
|
| 322 |
+
|
| 323 |
+
const texture = new THREE.CanvasTexture(canvas);
|
| 324 |
+
const material = new THREE.SpriteMaterial({ map: texture, depthTest: false });
|
| 325 |
+
const sprite = new THREE.Sprite(material);
|
| 326 |
+
sprite.scale.set(16, 4, 1);
|
| 327 |
+
return sprite;
|
| 328 |
+
}
|
| 329 |
+
|
| 330 |
+
function createNodeMarker(color) {
|
| 331 |
+
const geo = new THREE.SphereGeometry(1.5, 16, 16);
|
| 332 |
+
const mat = new THREE.MeshBasicMaterial({ color: color });
|
| 333 |
+
return new THREE.Mesh(geo, mat);
|
| 334 |
+
}
|
| 335 |
+
|
| 336 |
+
// The intersection of the tilted Moon system with the Ecliptic (Earth's XZ plane) happens along the local X-axis.
|
| 337 |
+
// Because we rotated the moonSystem around X, the X-axis remains unchanged and perfectly lies on the Ecliptic.
|
| 338 |
+
// Rahu (Ascending Node) - Going South to North. Due to rotation rules, this occurs at -X.
|
| 339 |
+
const rahuLabel = createTextLabel("Rahu ☊", "#ff8800");
|
| 340 |
+
rahuLabel.position.set(-moonOrbitRadius, 5, 0);
|
| 341 |
+
const rahuMarker = createNodeMarker(0xff8800);
|
| 342 |
+
rahuMarker.position.set(-moonOrbitRadius, 0, 0);
|
| 343 |
+
moonSystem.add(rahuLabel);
|
| 344 |
+
moonSystem.add(rahuMarker);
|
| 345 |
+
|
| 346 |
+
// Ketu (Descending Node) - Going North to South. This occurs at +X.
|
| 347 |
+
const ketuLabel = createTextLabel("Ketu ☋", "#a0a0a0");
|
| 348 |
+
ketuLabel.position.set(moonOrbitRadius, 5, 0);
|
| 349 |
+
const ketuMarker = createNodeMarker(0xa0a0a0);
|
| 350 |
+
ketuMarker.position.set(moonOrbitRadius, 0, 0);
|
| 351 |
+
moonSystem.add(ketuLabel);
|
| 352 |
+
moonSystem.add(ketuMarker);
|
| 353 |
+
|
| 354 |
+
// Line of Nodes
|
| 355 |
+
const lineOfNodesGeo = new THREE.BufferGeometry().setFromPoints([
|
| 356 |
+
new THREE.Vector3(-moonOrbitRadius - 5, 0, 0),
|
| 357 |
+
new THREE.Vector3(moonOrbitRadius + 5, 0, 0)
|
| 358 |
+
]);
|
| 359 |
+
const lineOfNodesMat = new THREE.LineBasicMaterial({ color: 0xffffff, transparent: true, opacity: 0.7 });
|
| 360 |
+
const lineOfNodes = new THREE.Line(lineOfNodesGeo, lineOfNodesMat);
|
| 361 |
+
moonSystem.add(lineOfNodes);
|
| 362 |
+
|
| 363 |
+
|
| 364 |
+
// --- ANIMATION LOGIC ---
|
| 365 |
+
let time = 0;
|
| 366 |
+
let wobbleTime = 0; // Separate time tracker for wobble
|
| 367 |
+
let isPaused = false;
|
| 368 |
+
let speedMultiplier = 1;
|
| 369 |
+
let wobbleSpeedMultiplier = 1; // Default independent wobble speed
|
| 370 |
+
let currentTilt = 15; // Default tilt in degrees
|
| 371 |
+
let cameraFocus = 'earth'; // 'earth' or 'sun'
|
| 372 |
+
const earthWorldPos = new THREE.Vector3();
|
| 373 |
+
|
| 374 |
+
// Set initial camera to Earth
|
| 375 |
+
camera.position.set(170, 40, 60);
|
| 376 |
+
|
| 377 |
+
function animate() {
|
| 378 |
+
requestAnimationFrame(animate);
|
| 379 |
+
|
| 380 |
+
if (!isPaused) {
|
| 381 |
+
time += 0.005 * speedMultiplier;
|
| 382 |
+
wobbleTime += 0.005 * speedMultiplier * wobbleSpeedMultiplier;
|
| 383 |
+
|
| 384 |
+
// Earth revolution around Sun (1 Earth Year)
|
| 385 |
+
earthSystem.position.x = Math.cos(time) * earthOrbitRadius;
|
| 386 |
+
earthSystem.position.z = Math.sin(time) * earthOrbitRadius;
|
| 387 |
+
|
| 388 |
+
// Earth rotation
|
| 389 |
+
earth.rotation.y += 0.05 * speedMultiplier;
|
| 390 |
+
|
| 391 |
+
// Nodal Precession (Takes 18.6 Earth Years, moves Retrograde/Backwards)
|
| 392 |
+
// We divide time by 18.6 so it takes exactly 18.6 Earth revolutions to do 1 Node revolution
|
| 393 |
+
nodalPrecessionGroup.rotation.y = -(wobbleTime / 18.6);
|
| 394 |
+
|
| 395 |
+
// Update Lunar Tilt Dynamically
|
| 396 |
+
moonSystem.rotation.x = currentTilt * (Math.PI / 180);
|
| 397 |
+
|
| 398 |
+
// Moon revolution around Earth
|
| 399 |
+
// Inside moonSystem, rotation around Y moves it along the tilted orbit!
|
| 400 |
+
const moonSpeed = time * 13.36; // Moon revolves ~13.36 times a year
|
| 401 |
+
moon.position.x = Math.cos(moonSpeed) * moonOrbitRadius;
|
| 402 |
+
moon.position.z = Math.sin(moonSpeed) * moonOrbitRadius;
|
| 403 |
+
moon.rotation.y += 0.02 * speedMultiplier;
|
| 404 |
+
|
| 405 |
+
// Make text sprites always face camera
|
| 406 |
+
rahuLabel.material.rotation = 0;
|
| 407 |
+
ketuLabel.material.rotation = 0;
|
| 408 |
+
}
|
| 409 |
+
|
| 410 |
+
// Camera Tracking
|
| 411 |
+
earthSystem.getWorldPosition(earthWorldPos);
|
| 412 |
+
|
| 413 |
+
if (cameraFocus === 'earth') {
|
| 414 |
+
controls.target.copy(earthWorldPos);
|
| 415 |
+
} else {
|
| 416 |
+
controls.target.set(0, 0, 0);
|
| 417 |
+
}
|
| 418 |
+
|
| 419 |
+
controls.update();
|
| 420 |
+
renderer.render(scene, camera);
|
| 421 |
+
}
|
| 422 |
+
|
| 423 |
+
// --- UI INTERACTIONS ---
|
| 424 |
+
|
| 425 |
+
// Pause Button
|
| 426 |
+
const btnPause = document.getElementById('btn-pause');
|
| 427 |
+
btnPause.addEventListener('click', () => {
|
| 428 |
+
isPaused = !isPaused;
|
| 429 |
+
btnPause.innerText = isPaused ? "Play" : "Pause";
|
| 430 |
+
btnPause.className = isPaused
|
| 431 |
+
? "bg-green-500 hover:bg-green-600 text-white px-3 py-1 rounded text-sm transition"
|
| 432 |
+
: "bg-white/10 hover:bg-white/20 text-white px-3 py-1 rounded text-sm transition";
|
| 433 |
+
});
|
| 434 |
+
|
| 435 |
+
// Speed Slider
|
| 436 |
+
const speedSlider = document.getElementById('time-speed');
|
| 437 |
+
const speedVal = document.getElementById('speed-val');
|
| 438 |
+
speedSlider.addEventListener('input', (e) => {
|
| 439 |
+
speedMultiplier = parseFloat(e.target.value);
|
| 440 |
+
speedVal.innerText = speedMultiplier.toFixed(1) + "x";
|
| 441 |
+
});
|
| 442 |
+
|
| 443 |
+
// Camera Focus Toggles
|
| 444 |
+
const btnFocusSun = document.getElementById('focus-sun');
|
| 445 |
+
const btnFocusEarth = document.getElementById('focus-earth');
|
| 446 |
+
|
| 447 |
+
btnFocusSun.addEventListener('click', () => {
|
| 448 |
+
cameraFocus = 'sun';
|
| 449 |
+
btnFocusSun.className = "flex-1 py-1.5 text-sm rounded-md transition bg-blue-500/30 text-blue-200 border border-blue-500/50";
|
| 450 |
+
btnFocusEarth.className = "flex-1 py-1.5 text-sm rounded-md transition text-gray-400 hover:text-white border border-transparent";
|
| 451 |
+
|
| 452 |
+
// Move camera to see whole system
|
| 453 |
+
const targetPos = new THREE.Vector3(0, 200, 300);
|
| 454 |
+
camera.position.lerp(targetPos, 1);
|
| 455 |
+
});
|
| 456 |
+
|
| 457 |
+
btnFocusEarth.addEventListener('click', () => {
|
| 458 |
+
cameraFocus = 'earth';
|
| 459 |
+
btnFocusEarth.className = "flex-1 py-1.5 text-sm rounded-md transition bg-blue-500/30 text-blue-200 border border-blue-500/50";
|
| 460 |
+
btnFocusSun.className = "flex-1 py-1.5 text-sm rounded-md transition text-gray-400 hover:text-white border border-transparent";
|
| 461 |
+
|
| 462 |
+
// Move camera closer to earth
|
| 463 |
+
earthSystem.getWorldPosition(earthWorldPos);
|
| 464 |
+
camera.position.set(earthWorldPos.x, earthWorldPos.y + 40, earthWorldPos.z + 60);
|
| 465 |
+
});
|
| 466 |
+
|
| 467 |
+
// Visibility Toggles
|
| 468 |
+
document.getElementById('toggle-ecliptic').addEventListener('change', (e) => {
|
| 469 |
+
eclipticPlane.visible = e.target.checked;
|
| 470 |
+
eclipticGrid.visible = e.target.checked;
|
| 471 |
+
});
|
| 472 |
+
|
| 473 |
+
document.getElementById('toggle-lunar').addEventListener('change', (e) => {
|
| 474 |
+
lunarPlane.visible = e.target.checked;
|
| 475 |
+
});
|
| 476 |
+
|
| 477 |
+
// Wobble Control Listeners
|
| 478 |
+
const wobbleSpeedSlider = document.getElementById('wobble-speed');
|
| 479 |
+
const wobbleSpeedVal = document.getElementById('wobble-speed-val');
|
| 480 |
+
wobbleSpeedSlider.addEventListener('input', (e) => {
|
| 481 |
+
wobbleSpeedMultiplier = parseFloat(e.target.value);
|
| 482 |
+
wobbleSpeedVal.innerText = wobbleSpeedMultiplier + "x";
|
| 483 |
+
});
|
| 484 |
+
|
| 485 |
+
const tiltSlider = document.getElementById('tilt-angle');
|
| 486 |
+
const tiltVal = document.getElementById('tilt-val');
|
| 487 |
+
tiltSlider.addEventListener('input', (e) => {
|
| 488 |
+
currentTilt = parseFloat(e.target.value);
|
| 489 |
+
tiltVal.innerText = currentTilt + "°";
|
| 490 |
+
});
|
| 491 |
+
|
| 492 |
+
document.getElementById('toggle-axis').addEventListener('change', (e) => {
|
| 493 |
+
moonOrbitAxis.visible = e.target.checked;
|
| 494 |
+
});
|
| 495 |
+
|
| 496 |
+
// Handle Window Resize
|
| 497 |
+
window.addEventListener('resize', () => {
|
| 498 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
| 499 |
+
camera.updateProjectionMatrix();
|
| 500 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
| 501 |
+
});
|
| 502 |
+
|
| 503 |
+
// Start animation loop
|
| 504 |
+
animate();
|
| 505 |
+
|
| 506 |
+
</script>
|
| 507 |
+
</body>
|
| 508 |
+
</html>
|