Absolutely! Here's a captivating, interactive web experience that visualizes the invisible forces of polar magnetic fields, blending science with art. This project will combine HTML, CSS, and JavaScript (with WebGL via Three.js) to create an immersive and visually stunning simulation.
🌌 Project Name: "Aurora Nexus"
🎯 Objective:
Create an interactive, browser-based experience where users can explore the invisible dynamics of polar magnetic fields through beautiful visualizations inspired by auroras, magnetospheres, and solar winds.
✨ Key Features:
- Animated magnetic field lines around Earth
- Dynamic auroral lights responding to solar wind
- User interaction: drag to rotate view, scroll to intensify solar wind
- Real-time magnetic distortion based on simulated solar activity
- Ambient sound design for immersion
🧠 Scientific Inspiration:
- Magnetic field lines guide charged particles from the sun toward the poles.
- These particles collide with atmospheric gases, causing auroras.
- The magnetosphere protects Earth from solar storms.
We’ll simulate this using physics-inspired visuals without full scientific modeling—focusing on beauty and interactivity.
🛠 Tech Stack:
- Three.js: For 3D rendering in the browser
- GLSL shaders: For dynamic visual effects like glowing auroras and magnetic distortions
- Tone.js (optional): For ambient audio feedback
- GSAP / Tween.js: For smooth animations
📁 Folder Structure:
aurora-nexus/
├── index.html
├── style.css
├── main.js
├── shaders/
│ ├── vertex.glsl
│ └── fragment.glsl
└── assets/
└── background-sound.mp3 (optional)
🖼️ Preview Description (in your mind):
Imagine opening the page and seeing a glowing blue sphere (Earth) suspended in space. Delicate arcs of light spiral around it—these are the magnetic field lines. As time passes, waves of color pulse along these lines, simulating solar wind. When you scroll, the intensity increases—the auroras flare up near the poles, and the magnetic field visibly warps as if reacting to pressure. You can rotate the camera to see the entire structure from all angles.
🔧 Code Implementation
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Aurora Nexus</title>
<link rel="stylesheet" href="style.css" />
<style>
body { margin: 0; overflow: hidden; }
canvas { display: block; }
</style>
</head>
<body>
<script src="https://cdn.jsdelivr.net/npm/three@0.157.0/build/three.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three@0.157.0/examples/js/controls/OrbitControls.js"></script>
<script src="main.js"></script>
</body>
</html>
style.css
body {
margin: 0;
background-color: #000;
}
main.js
let scene, camera, renderer, controls;
let earth, fieldLines, aurora;
let solarWindIntensity = 0.0;
let clock = new THREE.Clock();
init();
animate();
function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(60, window.innerWidth/window.innerHeight, 0.1, 1000);
camera.position.set(0, 5, 10);
renderer = new THREE.WebGLRenderer({ antialias: true });
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);
controls = new THREE.OrbitControls(camera, renderer.domElement);
// Add ambient light
scene.add(new THREE.AmbientLight(0x222244));
// Create Earth sphere
const earthGeometry = new THREE.SphereGeometry(1.5, 64, 64);
const earthMaterial = new THREE.MeshStandardMaterial({
map: new THREE.TextureLoader().load('https://threejs.org/examples/textures/earth_atmos_2048.jpg'),
emissive: 0x111122,
metalness: 0.3,
roughness: 0.7
});
earth = new THREE.Mesh(earthGeometry, earthMaterial);
scene.add(earth);
// Simulated magnetic field lines
createMagneticField();
// Aurora effect (glowing ring near pole)
createAurora();
window.addEventListener('resize', onWindowResize, false);
window.addEventListener('wheel', onScroll, false);
}
function createMagneticField() {
const curveCount = 60;
const pointsPerLine = 100;
const fieldMaterial = new THREE.LineBasicMaterial({ color: 0x66aaff });
fieldLines = new THREE.Group();
for (let i = 0; i < curveCount; i++) {
const curve = new THREE.EllipseCurve(
0, 0,
2 + Math.random(), 2 + Math.random(),
0, Math.PI,
false,
Math.random() * Math.PI * 2
);
const points = curve.getPoints(pointsPerLine);
const geometry = new THREE.BufferGeometry().setFromPoints(points.map(p => new THREE.Vector3(p.x, p.y, 0)));
const line = new THREE.Line(geometry, fieldMaterial);
fieldLines.add(line);
}
scene.add(fieldLines);
}
function createAurora() {
const geometry = new THREE.RingGeometry(1.6, 1.9, 64);
const material = new THREE.MeshBasicMaterial({ color: 0x00ffcc, opacity: 0.3, transparent: true });
aurora = new THREE.Mesh(geometry, material);
aurora.rotation.x = Math.PI / 2;
aurora.position.y = 1.4;
scene.add(aurora);
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function onScroll(event) {
solarWindIntensity += event.deltaY * -0.001;
solarWindIntensity = THREE.MathUtils.clamp(solarWindIntensity, 0, 1);
}
function animate() {
requestAnimationFrame(animate);
const elapsed = clock.getElapsedTime();
// Rotate Earth
earth.rotation.y += 0.001;
// Aurora pulsing
aurora.material.opacity = 0.2 + solarWindIntensity * 0.5;
aurora.scale.setScalar(1 + solarWindIntensity * 0.2);
// Distort magnetic field lines
fieldLines.children.forEach((line, idx) => {
const geo = line.geometry;
const pos = geo.attributes.position;
for (let i = 0; i < pos.count; i++) {
const x = pos.getX(i);
const y = pos.getY(i);
const z = pos.getZ(i);
const noise = Math.sin(elapsed + idx + i * 0.5) * solarWindIntensity * 0.3;
pos.setXYZ(i, x + noise * Math.cos(i), y + noise * Math.sin(i), z);
}
pos.needsUpdate = true;
});
controls.update();
renderer.render(scene, camera);
}
🌟 Bonus Ideas to Surprise You:
-
Sound Reactive Auroras
Use Tone.js or Web Audio API to make the auroras react to ambient music or microphone input.
-
Real-Time Solar Wind Data
Fetch live data from NOAA or NASA APIs to drive the intensity of the simulation.
-
VR Mode
Enable WebXR for VR headsets so users can "fly through" magnetic field lines.
-
Particles Along Field Lines
Animate tiny glowing particles moving along magnetic field lines like real charged particles.
-
Polar Night Toggle
Let users toggle between day/night sides of Earth, revealing auroras only at night.
🚀 Deployment Tip:
Host it on Vercel or Netlify for free. Or export as a standalone HTML file and share it anywhere.
Would you like me to turn this into a downloadable ZIP template or add more advanced features like shader-based auroras or VR support?