Spaces:
Running
Running
Add 2 files
Browse files- README.md +6 -4
- index.html +589 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
colorTo: gray
|
6 |
sdk: static
|
7 |
pinned: false
|
|
|
|
|
8 |
---
|
9 |
|
10 |
-
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
|
|
1 |
---
|
2 |
+
title: solar-system
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: gray
|
5 |
colorTo: gray
|
6 |
sdk: static
|
7 |
pinned: false
|
8 |
+
tags:
|
9 |
+
- deepsite
|
10 |
---
|
11 |
|
12 |
+
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
|
index.html
CHANGED
@@ -1,19 +1,589 @@
|
|
1 |
-
<!
|
2 |
-
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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>Interactive 3D Solar System</title>
|
7 |
+
<script src="https://cdn.tailwindcss.com"></script>
|
8 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/animejs/3.2.1/anime.min.js"></script>
|
9 |
+
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
|
10 |
+
<script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/controls/OrbitControls.min.js"></script>
|
11 |
+
<style>
|
12 |
+
body {
|
13 |
+
margin: 0;
|
14 |
+
overflow: hidden;
|
15 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
16 |
+
}
|
17 |
+
#canvas-container {
|
18 |
+
position: absolute;
|
19 |
+
width: 100%;
|
20 |
+
height: 100%;
|
21 |
+
}
|
22 |
+
.planet-info {
|
23 |
+
transition: all 0.3s ease;
|
24 |
+
transform: translateY(20px);
|
25 |
+
opacity: 0;
|
26 |
+
}
|
27 |
+
.planet-info.active {
|
28 |
+
transform: translateY(0);
|
29 |
+
opacity: 1;
|
30 |
+
}
|
31 |
+
.tooltip {
|
32 |
+
position: absolute;
|
33 |
+
background: rgba(0, 0, 0, 0.7);
|
34 |
+
color: white;
|
35 |
+
padding: 8px 12px;
|
36 |
+
border-radius: 4px;
|
37 |
+
pointer-events: none;
|
38 |
+
font-size: 14px;
|
39 |
+
z-index: 100;
|
40 |
+
transition: all 0.1s ease;
|
41 |
+
max-width: 200px;
|
42 |
+
}
|
43 |
+
.orbit {
|
44 |
+
position: absolute;
|
45 |
+
border: 1px solid rgba(255, 255, 255, 0.1);
|
46 |
+
border-radius: 50%;
|
47 |
+
transform-origin: center;
|
48 |
+
}
|
49 |
+
.star {
|
50 |
+
position: absolute;
|
51 |
+
background: white;
|
52 |
+
border-radius: 50%;
|
53 |
+
box-shadow: 0 0 5px white;
|
54 |
+
}
|
55 |
+
</style>
|
56 |
+
</head>
|
57 |
+
<body class="bg-gray-900 text-white">
|
58 |
+
<div id="canvas-container"></div>
|
59 |
+
|
60 |
+
<!-- Main UI -->
|
61 |
+
<div class="fixed top-0 left-0 right-0 p-4 bg-black bg-opacity-50 z-10">
|
62 |
+
<div class="flex justify-between items-center">
|
63 |
+
<h1 class="text-2xl font-bold">Interactive Solar System</h1>
|
64 |
+
<div class="flex space-x-4">
|
65 |
+
<button id="reset-view" class="px-4 py-2 bg-blue-600 rounded hover:bg-blue-700 transition">Reset View</button>
|
66 |
+
<button id="toggle-constellations" class="px-4 py-2 bg-purple-600 rounded hover:bg-purple-700 transition">Toggle Constellations</button>
|
67 |
+
<button id="toggle-orbits" class="px-4 py-2 bg-green-600 rounded hover:bg-green-700 transition">Toggle Orbits</button>
|
68 |
+
</div>
|
69 |
+
</div>
|
70 |
+
</div>
|
71 |
+
|
72 |
+
<!-- Planet Selector -->
|
73 |
+
<div class="fixed bottom-4 left-0 right-0 flex justify-center space-x-2 z-10">
|
74 |
+
<button data-planet="sun" class="planet-btn w-10 h-10 rounded-full bg-yellow-500 hover:bg-yellow-400 transition"></button>
|
75 |
+
<button data-planet="mercury" class="planet-btn w-6 h-6 rounded-full bg-gray-400 hover:bg-gray-300 transition"></button>
|
76 |
+
<button data-planet="venus" class="planet-btn w-7 h-7 rounded-full bg-yellow-200 hover:bg-yellow-100 transition"></button>
|
77 |
+
<button data-planet="earth" class="planet-btn w-7 h-7 rounded-full bg-blue-500 hover:bg-blue-400 transition"></button>
|
78 |
+
<button data-planet="mars" class="planet-btn w-6 h-6 rounded-full bg-red-500 hover:bg-red-400 transition"></button>
|
79 |
+
<button data-planet="jupiter" class="planet-btn w-9 h-9 rounded-full bg-yellow-600 hover:bg-yellow-500 transition"></button>
|
80 |
+
<button data-planet="saturn" class="planet-btn w-8 h-8 rounded-full bg-yellow-300 hover:bg-yellow-200 transition"></button>
|
81 |
+
<button data-planet="uranus" class="planet-btn w-7 h-7 rounded-full bg-teal-300 hover:bg-teal-200 transition"></button>
|
82 |
+
<button data-planet="neptune" class="planet-btn w-7 h-7 rounded-full bg-blue-400 hover:bg-blue-300 transition"></button>
|
83 |
+
</div>
|
84 |
+
|
85 |
+
<!-- Planet Info Panel -->
|
86 |
+
<div class="fixed top-20 right-4 w-64 bg-black bg-opacity-70 rounded-lg p-4 z-10 planet-info">
|
87 |
+
<h2 id="planet-name" class="text-xl font-bold mb-2">Solar System</h2>
|
88 |
+
<div id="planet-desc" class="text-sm">
|
89 |
+
Click on a planet to view information about it.
|
90 |
+
</div>
|
91 |
+
<div class="mt-4 grid grid-cols-2 gap-2 text-xs">
|
92 |
+
<div>Diameter: <span id="planet-diameter" class="font-bold">-</span></div>
|
93 |
+
<div>Distance from Sun: <span id="planet-distance" class="font-bold">-</span></div>
|
94 |
+
<div>Orbital Period: <span id="planet-orbit" class="font-bold">-</span></div>
|
95 |
+
<div>Rotation Period: <span id="planet-rotation" class="font-bold">-</span></div>
|
96 |
+
<div>Moons: <span id="planet-moons" class="font-bold">-</span></div>
|
97 |
+
<div>Surface Temp: <span id="planet-temp" class="font-bold">-</span></div>
|
98 |
+
</div>
|
99 |
+
</div>
|
100 |
+
|
101 |
+
<!-- Tooltip -->
|
102 |
+
<div id="tooltip" class="tooltip" style="display: none;"></div>
|
103 |
+
|
104 |
+
<script>
|
105 |
+
// Solar system data
|
106 |
+
const planets = {
|
107 |
+
sun: {
|
108 |
+
name: "Sun",
|
109 |
+
diameter: "1,392,700 km",
|
110 |
+
distance: "0 km",
|
111 |
+
orbit: "N/A",
|
112 |
+
rotation: "27 days",
|
113 |
+
moons: "0",
|
114 |
+
temp: "5,500°C",
|
115 |
+
desc: "The Sun is the star at the center of our solar system. It accounts for about 99.86% of the total mass of the Solar System.",
|
116 |
+
color: 0xFDB813,
|
117 |
+
radius: 10,
|
118 |
+
orbitRadius: 0,
|
119 |
+
rotationSpeed: 0.002,
|
120 |
+
orbitSpeed: 0
|
121 |
+
},
|
122 |
+
mercury: {
|
123 |
+
name: "Mercury",
|
124 |
+
diameter: "4,880 km",
|
125 |
+
distance: "57.9 million km",
|
126 |
+
orbit: "88 days",
|
127 |
+
rotation: "59 days",
|
128 |
+
moons: "0",
|
129 |
+
temp: "167°C",
|
130 |
+
desc: "Mercury is the smallest and innermost planet in the Solar System. It has no natural satellites and its surface is heavily cratered.",
|
131 |
+
color: 0xAAAAAA,
|
132 |
+
radius: 1.5,
|
133 |
+
orbitRadius: 30,
|
134 |
+
rotationSpeed: 0.004,
|
135 |
+
orbitSpeed: 0.04
|
136 |
+
},
|
137 |
+
venus: {
|
138 |
+
name: "Venus",
|
139 |
+
diameter: "12,104 km",
|
140 |
+
distance: "108.2 million km",
|
141 |
+
orbit: "225 days",
|
142 |
+
rotation: "243 days",
|
143 |
+
moons: "0",
|
144 |
+
temp: "464°C",
|
145 |
+
desc: "Venus is the second planet from the Sun and Earth's closest planetary neighbor. It has the densest atmosphere of the four terrestrial planets.",
|
146 |
+
color: 0xE6E6FA,
|
147 |
+
radius: 2.5,
|
148 |
+
orbitRadius: 50,
|
149 |
+
rotationSpeed: 0.002,
|
150 |
+
orbitSpeed: 0.015
|
151 |
+
},
|
152 |
+
earth: {
|
153 |
+
name: "Earth",
|
154 |
+
diameter: "12,742 km",
|
155 |
+
distance: "149.6 million km",
|
156 |
+
orbit: "365.25 days",
|
157 |
+
rotation: "1 day",
|
158 |
+
moons: "1",
|
159 |
+
temp: "15°C",
|
160 |
+
desc: "Earth is the third planet from the Sun and the only astronomical object known to harbor life. About 29% of Earth's surface is land consisting of continents and islands.",
|
161 |
+
color: 0x1E90FF,
|
162 |
+
radius: 2.6,
|
163 |
+
orbitRadius: 70,
|
164 |
+
rotationSpeed: 0.02,
|
165 |
+
orbitSpeed: 0.01
|
166 |
+
},
|
167 |
+
mars: {
|
168 |
+
name: "Mars",
|
169 |
+
diameter: "6,779 km",
|
170 |
+
distance: "227.9 million km",
|
171 |
+
orbit: "687 days",
|
172 |
+
rotation: "1.03 days",
|
173 |
+
moons: "2",
|
174 |
+
temp: "-65°C",
|
175 |
+
desc: "Mars is the fourth planet from the Sun and the second-smallest planet in the Solar System. It has a thin atmosphere and surface features reminiscent of impact craters.",
|
176 |
+
color: 0xFF4500,
|
177 |
+
radius: 1.8,
|
178 |
+
orbitRadius: 90,
|
179 |
+
rotationSpeed: 0.018,
|
180 |
+
orbitSpeed: 0.008
|
181 |
+
},
|
182 |
+
jupiter: {
|
183 |
+
name: "Jupiter",
|
184 |
+
diameter: "139,820 km",
|
185 |
+
distance: "778.3 million km",
|
186 |
+
orbit: "12 years",
|
187 |
+
rotation: "9.9 hours",
|
188 |
+
moons: "79",
|
189 |
+
temp: "-110°C",
|
190 |
+
desc: "Jupiter is the fifth planet from the Sun and the largest in the Solar System. It is a gas giant with a mass one-thousandth that of the Sun.",
|
191 |
+
color: 0xF5DEB3,
|
192 |
+
radius: 6,
|
193 |
+
orbitRadius: 120,
|
194 |
+
rotationSpeed: 0.04,
|
195 |
+
orbitSpeed: 0.002
|
196 |
+
},
|
197 |
+
saturn: {
|
198 |
+
name: "Saturn",
|
199 |
+
diameter: "116,460 km",
|
200 |
+
distance: "1.4 billion km",
|
201 |
+
orbit: "29.5 years",
|
202 |
+
rotation: "10.7 hours",
|
203 |
+
moons: "82",
|
204 |
+
temp: "-140°C",
|
205 |
+
desc: "Saturn is the sixth planet from the Sun and the second-largest in the Solar System, after Jupiter. It is a gas giant with an average radius about nine times that of Earth.",
|
206 |
+
color: 0xE5D9B6,
|
207 |
+
radius: 5,
|
208 |
+
orbitRadius: 150,
|
209 |
+
rotationSpeed: 0.038,
|
210 |
+
orbitSpeed: 0.0009
|
211 |
+
},
|
212 |
+
uranus: {
|
213 |
+
name: "Uranus",
|
214 |
+
diameter: "50,724 km",
|
215 |
+
distance: "2.9 billion km",
|
216 |
+
orbit: "84 years",
|
217 |
+
rotation: "17.2 hours",
|
218 |
+
moons: "27",
|
219 |
+
temp: "-195°C",
|
220 |
+
desc: "Uranus is the seventh planet from the Sun. It has the third-largest planetary radius and fourth-largest planetary mass in the Solar System.",
|
221 |
+
color: 0xAFEEEE,
|
222 |
+
radius: 3.5,
|
223 |
+
orbitRadius: 180,
|
224 |
+
rotationSpeed: 0.03,
|
225 |
+
orbitSpeed: 0.0004
|
226 |
+
},
|
227 |
+
neptune: {
|
228 |
+
name: "Neptune",
|
229 |
+
diameter: "49,244 km",
|
230 |
+
distance: "4.5 billion km",
|
231 |
+
orbit: "165 years",
|
232 |
+
rotation: "16.1 hours",
|
233 |
+
moons: "14",
|
234 |
+
temp: "-200°C",
|
235 |
+
desc: "Neptune is the eighth and farthest-known Solar planet from the Sun. It is the fourth-largest planet by diameter and the third-most-massive planet.",
|
236 |
+
color: 0x4682B4,
|
237 |
+
radius: 3.4,
|
238 |
+
orbitRadius: 210,
|
239 |
+
rotationSpeed: 0.032,
|
240 |
+
orbitSpeed: 0.0001
|
241 |
+
}
|
242 |
+
};
|
243 |
+
|
244 |
+
// Initialize Three.js scene
|
245 |
+
const container = document.getElementById('canvas-container');
|
246 |
+
const scene = new THREE.Scene();
|
247 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
248 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true });
|
249 |
+
|
250 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
251 |
+
renderer.setPixelRatio(window.devicePixelRatio);
|
252 |
+
renderer.shadowMap.enabled = true;
|
253 |
+
container.appendChild(renderer.domElement);
|
254 |
+
|
255 |
+
// Add controls
|
256 |
+
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
257 |
+
controls.enableDamping = true;
|
258 |
+
controls.dampingFactor = 0.05;
|
259 |
+
controls.minDistance = 5;
|
260 |
+
controls.maxDistance = 500;
|
261 |
+
|
262 |
+
// Set camera position
|
263 |
+
camera.position.set(0, 50, 100);
|
264 |
+
controls.update();
|
265 |
+
|
266 |
+
// Add ambient light
|
267 |
+
const ambientLight = new THREE.AmbientLight(0x404040);
|
268 |
+
scene.add(ambientLight);
|
269 |
+
|
270 |
+
// Add directional light (sun)
|
271 |
+
const sunLight = new THREE.PointLight(0xffffff, 2, 500);
|
272 |
+
sunLight.castShadow = true;
|
273 |
+
sunLight.shadow.mapSize.width = 2048;
|
274 |
+
sunLight.shadow.mapSize.height = 2048;
|
275 |
+
scene.add(sunLight);
|
276 |
+
|
277 |
+
// Create solar system objects
|
278 |
+
const solarSystem = new THREE.Group();
|
279 |
+
scene.add(solarSystem);
|
280 |
+
|
281 |
+
// Create sun
|
282 |
+
const sunGeometry = new THREE.SphereGeometry(planets.sun.radius, 32, 32);
|
283 |
+
const sunMaterial = new THREE.MeshPhongMaterial({
|
284 |
+
color: planets.sun.color,
|
285 |
+
emissive: 0xFDB813,
|
286 |
+
emissiveIntensity: 1,
|
287 |
+
shininess: 10
|
288 |
+
});
|
289 |
+
const sun = new THREE.Mesh(sunGeometry, sunMaterial);
|
290 |
+
sun.castShadow = true;
|
291 |
+
sun.receiveShadow = true;
|
292 |
+
sun.name = "sun";
|
293 |
+
solarSystem.add(sun);
|
294 |
+
sunLight.position.copy(sun.position);
|
295 |
+
|
296 |
+
// Create planets
|
297 |
+
const planetMeshes = {};
|
298 |
+
const orbitLines = {};
|
299 |
+
|
300 |
+
Object.keys(planets).forEach(planetKey => {
|
301 |
+
if (planetKey === "sun") return;
|
302 |
+
|
303 |
+
const planet = planets[planetKey];
|
304 |
+
|
305 |
+
// Create orbit line
|
306 |
+
const orbitGeometry = new THREE.TorusGeometry(planet.orbitRadius, 0.05, 16, 100);
|
307 |
+
const orbitMaterial = new THREE.MeshBasicMaterial({
|
308 |
+
color: 0x666666,
|
309 |
+
transparent: true,
|
310 |
+
opacity: 0.3
|
311 |
+
});
|
312 |
+
const orbit = new THREE.Mesh(orbitGeometry, orbitMaterial);
|
313 |
+
orbit.rotation.x = Math.PI / 2;
|
314 |
+
orbit.name = `${planetKey}-orbit`;
|
315 |
+
solarSystem.add(orbit);
|
316 |
+
orbitLines[planetKey] = orbit;
|
317 |
+
|
318 |
+
// Create planet
|
319 |
+
const planetGeometry = new THREE.SphereGeometry(planet.radius, 32, 32);
|
320 |
+
const planetMaterial = new THREE.MeshPhongMaterial({
|
321 |
+
color: planet.color,
|
322 |
+
shininess: 10
|
323 |
+
});
|
324 |
+
const planetMesh = new THREE.Mesh(planetGeometry, planetMaterial);
|
325 |
+
planetMesh.castShadow = true;
|
326 |
+
planetMesh.receiveShadow = true;
|
327 |
+
planetMesh.position.x = planet.orbitRadius;
|
328 |
+
planetMesh.name = planetKey;
|
329 |
+
|
330 |
+
// Add ring for Saturn
|
331 |
+
if (planetKey === "saturn") {
|
332 |
+
const ringGeometry = new THREE.RingGeometry(planet.radius * 1.5, planet.radius * 2, 32);
|
333 |
+
const ringMaterial = new THREE.MeshPhongMaterial({
|
334 |
+
color: 0xDAA520,
|
335 |
+
side: THREE.DoubleSide,
|
336 |
+
transparent: true,
|
337 |
+
opacity: 0.8
|
338 |
+
});
|
339 |
+
const ring = new THREE.Mesh(ringGeometry, ringMaterial);
|
340 |
+
ring.rotation.x = Math.PI / 2;
|
341 |
+
planetMesh.add(ring);
|
342 |
+
}
|
343 |
+
|
344 |
+
solarSystem.add(planetMesh);
|
345 |
+
planetMeshes[planetKey] = planetMesh;
|
346 |
+
});
|
347 |
+
|
348 |
+
// Create stars background
|
349 |
+
const starsGeometry = new THREE.BufferGeometry();
|
350 |
+
const starsMaterial = new THREE.PointsMaterial({
|
351 |
+
color: 0xFFFFFF,
|
352 |
+
size: 0.1,
|
353 |
+
transparent: true
|
354 |
+
});
|
355 |
+
|
356 |
+
const starsVertices = [];
|
357 |
+
for (let i = 0; i < 10000; i++) {
|
358 |
+
const x = (Math.random() - 0.5) * 2000;
|
359 |
+
const y = (Math.random() - 0.5) * 2000;
|
360 |
+
const z = (Math.random() - 0.5) * 2000;
|
361 |
+
starsVertices.push(x, y, z);
|
362 |
+
}
|
363 |
+
|
364 |
+
starsGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starsVertices, 3));
|
365 |
+
const stars = new THREE.Points(starsGeometry, starsMaterial);
|
366 |
+
scene.add(stars);
|
367 |
+
|
368 |
+
// Create constellations (simplified)
|
369 |
+
const constellations = new THREE.Group();
|
370 |
+
scene.add(constellations);
|
371 |
+
|
372 |
+
// Add some simple constellation lines
|
373 |
+
const createConstellation = (points, name) => {
|
374 |
+
const lineGeometry = new THREE.BufferGeometry();
|
375 |
+
lineGeometry.setFromPoints(points);
|
376 |
+
const lineMaterial = new THREE.LineBasicMaterial({
|
377 |
+
color: 0x8888FF,
|
378 |
+
transparent: true,
|
379 |
+
opacity: 0.5
|
380 |
+
});
|
381 |
+
const line = new THREE.Line(lineGeometry, lineMaterial);
|
382 |
+
line.name = name;
|
383 |
+
constellations.add(line);
|
384 |
+
};
|
385 |
+
|
386 |
+
// Example constellations (positions are arbitrary)
|
387 |
+
createConstellation([
|
388 |
+
new THREE.Vector3(-100, 80, -50),
|
389 |
+
new THREE.Vector3(-90, 90, -40),
|
390 |
+
new THREE.Vector3(-80, 85, -30)
|
391 |
+
], "constellation-1");
|
392 |
+
|
393 |
+
createConstellation([
|
394 |
+
new THREE.Vector3(120, 70, -60),
|
395 |
+
new THREE.Vector3(130, 60, -70),
|
396 |
+
new THREE.Vector3(140, 80, -50)
|
397 |
+
], "constellation-2");
|
398 |
+
|
399 |
+
createConstellation([
|
400 |
+
new THREE.Vector3(-50, -30, 100),
|
401 |
+
new THREE.Vector3(-60, -20, 110),
|
402 |
+
new THREE.Vector3(-40, -10, 120)
|
403 |
+
], "constellation-3");
|
404 |
+
|
405 |
+
// Animation variables
|
406 |
+
let showConstellations = true;
|
407 |
+
let showOrbits = true;
|
408 |
+
|
409 |
+
// Raycaster for planet selection
|
410 |
+
const raycaster = new THREE.Raycaster();
|
411 |
+
const mouse = new THREE.Vector2();
|
412 |
+
|
413 |
+
// UI Elements
|
414 |
+
const planetInfo = document.querySelector('.planet-info');
|
415 |
+
const planetName = document.getElementById('planet-name');
|
416 |
+
const planetDesc = document.getElementById('planet-desc');
|
417 |
+
const planetDiameter = document.getElementById('planet-diameter');
|
418 |
+
const planetDistance = document.getElementById('planet-distance');
|
419 |
+
const planetOrbit = document.getElementById('planet-orbit');
|
420 |
+
const planetRotation = document.getElementById('planet-rotation');
|
421 |
+
const planetMoons = document.getElementById('planet-moons');
|
422 |
+
const planetTemp = document.getElementById('planet-temp');
|
423 |
+
const tooltip = document.getElementById('tooltip');
|
424 |
+
|
425 |
+
// Event Listeners
|
426 |
+
document.addEventListener('mousemove', onMouseMove);
|
427 |
+
document.addEventListener('click', onClick);
|
428 |
+
window.addEventListener('resize', onWindowResize);
|
429 |
+
|
430 |
+
// Planet buttons
|
431 |
+
document.querySelectorAll('.planet-btn').forEach(btn => {
|
432 |
+
btn.addEventListener('click', () => {
|
433 |
+
const planet = btn.dataset.planet;
|
434 |
+
focusOnPlanet(planet);
|
435 |
+
});
|
436 |
+
});
|
437 |
+
|
438 |
+
// UI buttons
|
439 |
+
document.getElementById('reset-view').addEventListener('click', () => {
|
440 |
+
camera.position.set(0, 50, 100);
|
441 |
+
controls.target.set(0, 0, 0);
|
442 |
+
updatePlanetInfo(null);
|
443 |
+
});
|
444 |
+
|
445 |
+
document.getElementById('toggle-constellations').addEventListener('click', () => {
|
446 |
+
showConstellations = !showConstellations;
|
447 |
+
constellations.visible = showConstellations;
|
448 |
+
});
|
449 |
+
|
450 |
+
document.getElementById('toggle-orbits').addEventListener('click', () => {
|
451 |
+
showOrbits = !showOrbits;
|
452 |
+
Object.values(orbitLines).forEach(orbit => {
|
453 |
+
orbit.visible = showOrbits;
|
454 |
+
});
|
455 |
+
});
|
456 |
+
|
457 |
+
// Functions
|
458 |
+
function onMouseMove(event) {
|
459 |
+
// Calculate mouse position in normalized device coordinates
|
460 |
+
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
|
461 |
+
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
462 |
+
|
463 |
+
// Update the raycaster
|
464 |
+
raycaster.setFromCamera(mouse, camera);
|
465 |
+
|
466 |
+
// Calculate objects intersecting the ray
|
467 |
+
const intersects = raycaster.intersectObjects(Object.values(planetMeshes));
|
468 |
+
|
469 |
+
if (intersects.length > 0) {
|
470 |
+
const planet = intersects[0].object;
|
471 |
+
tooltip.style.display = 'block';
|
472 |
+
tooltip.style.left = `${event.clientX + 10}px`;
|
473 |
+
tooltip.style.top = `${event.clientY + 10}px`;
|
474 |
+
tooltip.textContent = planets[planet.name].name;
|
475 |
+
} else {
|
476 |
+
tooltip.style.display = 'none';
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
function onClick(event) {
|
481 |
+
// Calculate mouse position in normalized device coordinates
|
482 |
+
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
|
483 |
+
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
|
484 |
+
|
485 |
+
// Update the raycaster
|
486 |
+
raycaster.setFromCamera(mouse, camera);
|
487 |
+
|
488 |
+
// Calculate objects intersecting the ray
|
489 |
+
const intersects = raycaster.intersectObjects(Object.values(planetMeshes));
|
490 |
+
|
491 |
+
if (intersects.length > 0) {
|
492 |
+
const planet = intersects[0].object;
|
493 |
+
focusOnPlanet(planet.name);
|
494 |
+
updatePlanetInfo(planet.name);
|
495 |
+
}
|
496 |
+
}
|
497 |
+
|
498 |
+
function focusOnPlanet(planetName) {
|
499 |
+
if (planetName === 'sun') {
|
500 |
+
controls.target.copy(sun.position);
|
501 |
+
anime({
|
502 |
+
targets: camera.position,
|
503 |
+
x: 0,
|
504 |
+
y: 20,
|
505 |
+
z: 50,
|
506 |
+
duration: 1000,
|
507 |
+
easing: 'easeInOutQuad'
|
508 |
+
});
|
509 |
+
} else {
|
510 |
+
const planet = planetMeshes[planetName];
|
511 |
+
controls.target.copy(planet.position);
|
512 |
+
|
513 |
+
// Calculate position to view the planet from a slight angle
|
514 |
+
const distance = planets[planetName].orbitRadius * 0.5;
|
515 |
+
const angle = Math.atan2(planet.position.z, planet.position.x);
|
516 |
+
|
517 |
+
anime({
|
518 |
+
targets: camera.position,
|
519 |
+
x: planet.position.x + Math.cos(angle) * distance,
|
520 |
+
y: planet.position.y + distance * 0.3,
|
521 |
+
z: planet.position.z + Math.sin(angle) * distance,
|
522 |
+
duration: 1000,
|
523 |
+
easing: 'easeInOutQuad'
|
524 |
+
});
|
525 |
+
}
|
526 |
+
}
|
527 |
+
|
528 |
+
function updatePlanetInfo(planetKey) {
|
529 |
+
if (!planetKey) {
|
530 |
+
planetName.textContent = "Solar System";
|
531 |
+
planetDesc.textContent = "Click on a planet to view information about it.";
|
532 |
+
planetDiameter.textContent = "-";
|
533 |
+
planetDistance.textContent = "-";
|
534 |
+
planetOrbit.textContent = "-";
|
535 |
+
planetRotation.textContent = "-";
|
536 |
+
planetMoons.textContent = "-";
|
537 |
+
planetTemp.textContent = "-";
|
538 |
+
planetInfo.classList.remove('active');
|
539 |
+
return;
|
540 |
+
}
|
541 |
+
|
542 |
+
const planet = planets[planetKey];
|
543 |
+
planetName.textContent = planet.name;
|
544 |
+
planetDesc.textContent = planet.desc;
|
545 |
+
planetDiameter.textContent = planet.diameter;
|
546 |
+
planetDistance.textContent = planet.distance;
|
547 |
+
planetOrbit.textContent = planet.orbit;
|
548 |
+
planetRotation.textContent = planet.rotation;
|
549 |
+
planetMoons.textContent = planet.moons;
|
550 |
+
planetTemp.textContent = planet.temp;
|
551 |
+
planetInfo.classList.add('active');
|
552 |
+
}
|
553 |
+
|
554 |
+
function onWindowResize() {
|
555 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
556 |
+
camera.updateProjectionMatrix();
|
557 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
558 |
+
}
|
559 |
+
|
560 |
+
// Animation loop
|
561 |
+
function animate() {
|
562 |
+
requestAnimationFrame(animate);
|
563 |
+
|
564 |
+
// Rotate sun
|
565 |
+
sun.rotation.y += planets.sun.rotationSpeed;
|
566 |
+
|
567 |
+
// Rotate and orbit planets
|
568 |
+
Object.keys(planetMeshes).forEach(planetKey => {
|
569 |
+
const planet = planetMeshes[planetKey];
|
570 |
+
const planetData = planets[planetKey];
|
571 |
+
|
572 |
+
// Rotate planet
|
573 |
+
planet.rotation.y += planetData.rotationSpeed;
|
574 |
+
|
575 |
+
// Orbit planet around sun
|
576 |
+
if (planetData.orbitSpeed > 0) {
|
577 |
+
planet.position.x = Math.cos(Date.now() * 0.001 * planetData.orbitSpeed) * planetData.orbitRadius;
|
578 |
+
planet.position.z = Math.sin(Date.now() * 0.001 * planetData.orbitSpeed) * planetData.orbitRadius;
|
579 |
+
}
|
580 |
+
});
|
581 |
+
|
582 |
+
controls.update();
|
583 |
+
renderer.render(scene, camera);
|
584 |
+
}
|
585 |
+
|
586 |
+
animate();
|
587 |
+
</script>
|
588 |
+
<p style="border-radius: 8px; text-align: center; font-size: 12px; color: #fff; margin-top: 16px;position: fixed; left: 8px; bottom: 8px; z-index: 10; background: rgba(0, 0, 0, 0.8); padding: 4px 8px;">Made with <img src="https://enzostvs-deepsite.hf.space/logo.svg" alt="DeepSite Logo" style="width: 16px; height: 16px; vertical-align: middle;display:inline-block;margin-right:3px;filter:brightness(0) invert(1);"><a href="https://enzostvs-deepsite.hf.space" style="color: #fff;text-decoration: underline;" target="_blank" >DeepSite</a> - 🧬 <a href="https://enzostvs-deepsite.hf.space?remix=youjunhyeok/solar-system" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
|
589 |
+
</html>
|