Add 2 files
Browse files- README.md +7 -5
- index.html +283 -19
README.md
CHANGED
@@ -1,10 +1,12 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
-
colorFrom:
|
5 |
-
colorTo:
|
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: my-beautiful-earth
|
3 |
+
emoji: 🐳
|
4 |
+
colorFrom: blue
|
5 |
+
colorTo: blue
|
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,283 @@
|
|
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>3D Earth Visualization</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/[email protected]/examples/js/controls/OrbitControls.min.js"></script>
|
10 |
+
<style>
|
11 |
+
body {
|
12 |
+
margin: 0;
|
13 |
+
overflow: hidden;
|
14 |
+
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
|
15 |
+
}
|
16 |
+
#earth-container {
|
17 |
+
position: relative;
|
18 |
+
width: 100vw;
|
19 |
+
height: 100vh;
|
20 |
+
}
|
21 |
+
#info-panel {
|
22 |
+
position: absolute;
|
23 |
+
bottom: 20px;
|
24 |
+
left: 20px;
|
25 |
+
background: rgba(0, 0, 0, 0.7);
|
26 |
+
color: white;
|
27 |
+
padding: 15px;
|
28 |
+
border-radius: 10px;
|
29 |
+
max-width: 300px;
|
30 |
+
backdrop-filter: blur(5px);
|
31 |
+
z-index: 100;
|
32 |
+
}
|
33 |
+
#loading {
|
34 |
+
position: absolute;
|
35 |
+
top: 50%;
|
36 |
+
left: 50%;
|
37 |
+
transform: translate(-50%, -50%);
|
38 |
+
color: white;
|
39 |
+
font-size: 1.5rem;
|
40 |
+
z-index: 100;
|
41 |
+
}
|
42 |
+
.glow {
|
43 |
+
position: absolute;
|
44 |
+
width: 100%;
|
45 |
+
height: 100%;
|
46 |
+
background: radial-gradient(circle at center, rgba(64, 158, 255, 0.3) 0%, transparent 70%);
|
47 |
+
pointer-events: none;
|
48 |
+
z-index: 1;
|
49 |
+
}
|
50 |
+
#controls {
|
51 |
+
position: absolute;
|
52 |
+
top: 20px;
|
53 |
+
right: 20px;
|
54 |
+
display: flex;
|
55 |
+
flex-direction: column;
|
56 |
+
gap: 10px;
|
57 |
+
z-index: 100;
|
58 |
+
}
|
59 |
+
.control-btn {
|
60 |
+
background: rgba(0, 0, 0, 0.7);
|
61 |
+
color: white;
|
62 |
+
border: none;
|
63 |
+
border-radius: 50%;
|
64 |
+
width: 50px;
|
65 |
+
height: 50px;
|
66 |
+
font-size: 1.2rem;
|
67 |
+
cursor: pointer;
|
68 |
+
transition: all 0.3s;
|
69 |
+
backdrop-filter: blur(5px);
|
70 |
+
}
|
71 |
+
.control-btn:hover {
|
72 |
+
background: rgba(30, 144, 255, 0.8);
|
73 |
+
transform: scale(1.1);
|
74 |
+
}
|
75 |
+
</style>
|
76 |
+
</head>
|
77 |
+
<body class="bg-gray-900">
|
78 |
+
<div id="earth-container">
|
79 |
+
<div class="glow"></div>
|
80 |
+
<div id="loading">Loading Earth...</div>
|
81 |
+
<div id="info-panel">
|
82 |
+
<h2 class="text-xl font-bold mb-2">Planet Earth</h2>
|
83 |
+
<p class="text-sm mb-2">Our beautiful blue planet, the third from the Sun and the only known astronomical object to harbor life.</p>
|
84 |
+
<div class="flex justify-between text-xs">
|
85 |
+
<div>
|
86 |
+
<p><span class="font-semibold">Diameter:</span> 12,742 km</p>
|
87 |
+
<p><span class="font-semibold">Mass:</span> 5.97 × 10²⁴ kg</p>
|
88 |
+
</div>
|
89 |
+
<div>
|
90 |
+
<p><span class="font-semibold">Moons:</span> 1 (The Moon)</p>
|
91 |
+
<p><span class="font-semibold">Distance from Sun:</span> 149.6M km</p>
|
92 |
+
</div>
|
93 |
+
</div>
|
94 |
+
</div>
|
95 |
+
<div id="controls">
|
96 |
+
<button id="rotate-toggle" class="control-btn" title="Toggle Rotation">↻</button>
|
97 |
+
<button id="reset-view" class="control-btn" title="Reset View">⌂</button>
|
98 |
+
<button id="night-toggle" class="control-btn" title="Toggle Night View">🌙</button>
|
99 |
+
</div>
|
100 |
+
</div>
|
101 |
+
|
102 |
+
<script>
|
103 |
+
// Wait for DOM to load
|
104 |
+
document.addEventListener('DOMContentLoaded', () => {
|
105 |
+
// Scene setup
|
106 |
+
const scene = new THREE.Scene();
|
107 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
108 |
+
const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
|
109 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
110 |
+
renderer.setPixelRatio(window.devicePixelRatio);
|
111 |
+
document.getElementById('earth-container').appendChild(renderer.domElement);
|
112 |
+
|
113 |
+
// Controls
|
114 |
+
const controls = new THREE.OrbitControls(camera, renderer.domElement);
|
115 |
+
controls.enableDamping = true;
|
116 |
+
controls.dampingFactor = 0.05;
|
117 |
+
controls.minDistance = 1.5;
|
118 |
+
controls.maxDistance = 5;
|
119 |
+
controls.autoRotate = true;
|
120 |
+
controls.autoRotateSpeed = 0.5;
|
121 |
+
|
122 |
+
// Camera position
|
123 |
+
camera.position.z = 3;
|
124 |
+
|
125 |
+
// Lighting
|
126 |
+
const ambientLight = new THREE.AmbientLight(0x404040);
|
127 |
+
scene.add(ambientLight);
|
128 |
+
|
129 |
+
const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
|
130 |
+
directionalLight.position.set(5, 3, 5);
|
131 |
+
scene.add(directionalLight);
|
132 |
+
|
133 |
+
// Earth geometry
|
134 |
+
const earthGeometry = new THREE.SphereGeometry(1, 64, 64);
|
135 |
+
|
136 |
+
// Textures
|
137 |
+
const textureLoader = new THREE.TextureLoader();
|
138 |
+
let earthTexture, bumpMap, specularMap, cloudTexture;
|
139 |
+
|
140 |
+
// Load textures
|
141 |
+
Promise.all([
|
142 |
+
new Promise(resolve => textureLoader.load('https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/textures/planets/earth_atmos_2048.jpg', resolve)),
|
143 |
+
new Promise(resolve => textureLoader.load('https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/textures/planets/earth_normal_2048.jpg', resolve)),
|
144 |
+
new Promise(resolve => textureLoader.load('https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/textures/planets/earth_specular_2048.jpg', resolve)),
|
145 |
+
new Promise(resolve => textureLoader.load('https://raw.githubusercontent.com/mrdoob/three.js/dev/examples/textures/planets/earth_clouds_1024.png', resolve))
|
146 |
+
]).then(([earthTex, bump, specular, clouds]) => {
|
147 |
+
earthTexture = earthTex;
|
148 |
+
bumpMap = bump;
|
149 |
+
specularMap = specular;
|
150 |
+
cloudTexture = clouds;
|
151 |
+
|
152 |
+
// Create earth material
|
153 |
+
const earthMaterial = new THREE.MeshPhongMaterial({
|
154 |
+
map: earthTexture,
|
155 |
+
bumpMap: bumpMap,
|
156 |
+
bumpScale: 0.05,
|
157 |
+
specularMap: specularMap,
|
158 |
+
specular: new THREE.Color('grey'),
|
159 |
+
shininess: 5
|
160 |
+
});
|
161 |
+
|
162 |
+
// Create earth mesh
|
163 |
+
const earthMesh = new THREE.Mesh(earthGeometry, earthMaterial);
|
164 |
+
scene.add(earthMesh);
|
165 |
+
|
166 |
+
// Create clouds
|
167 |
+
const cloudGeometry = new THREE.SphereGeometry(1.01, 64, 64);
|
168 |
+
const cloudMaterial = new THREE.MeshPhongMaterial({
|
169 |
+
map: cloudTexture,
|
170 |
+
transparent: true,
|
171 |
+
opacity: 0.4,
|
172 |
+
depthWrite: false
|
173 |
+
});
|
174 |
+
const cloudMesh = new THREE.Mesh(cloudGeometry, cloudMaterial);
|
175 |
+
scene.add(cloudMesh);
|
176 |
+
|
177 |
+
// Create atmosphere glow
|
178 |
+
const atmosphereGeometry = new THREE.SphereGeometry(1.1, 64, 64);
|
179 |
+
const atmosphereMaterial = new THREE.ShaderMaterial({
|
180 |
+
uniforms: {
|
181 |
+
glowColor: { type: "c", value: new THREE.Color(0x00b3ff) },
|
182 |
+
viewVector: { type: "v3", value: camera.position }
|
183 |
+
},
|
184 |
+
vertexShader: `
|
185 |
+
uniform vec3 viewVector;
|
186 |
+
varying float intensity;
|
187 |
+
void main() {
|
188 |
+
gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);
|
189 |
+
vec3 actual_normal = normalize(normalMatrix * normal);
|
190 |
+
intensity = pow(0.7 - dot(actual_normal, normalize(viewVector)), 2.0);
|
191 |
+
}
|
192 |
+
`,
|
193 |
+
fragmentShader: `
|
194 |
+
uniform vec3 glowColor;
|
195 |
+
varying float intensity;
|
196 |
+
void main() {
|
197 |
+
vec3 glow = glowColor * intensity;
|
198 |
+
gl_FragColor = vec4(glow, 0.3);
|
199 |
+
}
|
200 |
+
`,
|
201 |
+
side: THREE.BackSide,
|
202 |
+
blending: THREE.AdditiveBlending,
|
203 |
+
transparent: true
|
204 |
+
});
|
205 |
+
const atmosphereMesh = new THREE.Mesh(atmosphereGeometry, atmosphereMaterial);
|
206 |
+
scene.add(atmosphereMesh);
|
207 |
+
|
208 |
+
// Hide loading
|
209 |
+
document.getElementById('loading').style.display = 'none';
|
210 |
+
|
211 |
+
// Animation loop
|
212 |
+
const animate = () => {
|
213 |
+
requestAnimationFrame(animate);
|
214 |
+
|
215 |
+
// Rotate earth and clouds
|
216 |
+
if (controls.autoRotate) {
|
217 |
+
earthMesh.rotation.y += 0.001;
|
218 |
+
cloudMesh.rotation.y += 0.0015; // Clouds rotate slightly faster
|
219 |
+
}
|
220 |
+
|
221 |
+
// Update atmosphere shader
|
222 |
+
atmosphereMaterial.uniforms.viewVector.value =
|
223 |
+
new THREE.Vector3().subVectors(camera.position, atmosphereMesh.position);
|
224 |
+
|
225 |
+
controls.update();
|
226 |
+
renderer.render(scene, camera);
|
227 |
+
};
|
228 |
+
animate();
|
229 |
+
|
230 |
+
// UI Controls
|
231 |
+
document.getElementById('rotate-toggle').addEventListener('click', () => {
|
232 |
+
controls.autoRotate = !controls.autoRotate;
|
233 |
+
document.getElementById('rotate-toggle').style.backgroundColor =
|
234 |
+
controls.autoRotate ? 'rgba(30, 144, 255, 0.8)' : 'rgba(0, 0, 0, 0.7)';
|
235 |
+
});
|
236 |
+
|
237 |
+
document.getElementById('reset-view').addEventListener('click', () => {
|
238 |
+
controls.reset();
|
239 |
+
camera.position.z = 3;
|
240 |
+
});
|
241 |
+
|
242 |
+
document.getElementById('night-toggle').addEventListener('click', function() {
|
243 |
+
const isNight = earthMaterial.specular.getHex() === 0x000000;
|
244 |
+
earthMaterial.specular.setHex(isNight ? 0x111111 : 0x000000);
|
245 |
+
earthMaterial.shininess = isNight ? 5 : 0;
|
246 |
+
this.style.backgroundColor = isNight ? 'rgba(0, 0, 0, 0.7)' : 'rgba(30, 144, 255, 0.8)';
|
247 |
+
});
|
248 |
+
|
249 |
+
// Handle window resize
|
250 |
+
window.addEventListener('resize', () => {
|
251 |
+
camera.aspect = window.innerWidth / window.innerHeight;
|
252 |
+
camera.updateProjectionMatrix();
|
253 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
254 |
+
});
|
255 |
+
|
256 |
+
}).catch(error => {
|
257 |
+
console.error('Error loading textures:', error);
|
258 |
+
document.getElementById('loading').textContent = 'Error loading Earth textures. Please check your connection.';
|
259 |
+
});
|
260 |
+
|
261 |
+
// Add stars background
|
262 |
+
const starGeometry = new THREE.BufferGeometry();
|
263 |
+
const starMaterial = new THREE.PointsMaterial({
|
264 |
+
color: 0xffffff,
|
265 |
+
size: 0.05,
|
266 |
+
transparent: true
|
267 |
+
});
|
268 |
+
|
269 |
+
const starVertices = [];
|
270 |
+
for (let i = 0; i < 5000; i++) {
|
271 |
+
const x = (Math.random() - 0.5) * 2000;
|
272 |
+
const y = (Math.random() - 0.5) * 2000;
|
273 |
+
const z = (Math.random() - 0.5) * 2000;
|
274 |
+
starVertices.push(x, y, z);
|
275 |
+
}
|
276 |
+
|
277 |
+
starGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starVertices, 3));
|
278 |
+
const stars = new THREE.Points(starGeometry, starMaterial);
|
279 |
+
scene.add(stars);
|
280 |
+
});
|
281 |
+
</script>
|
282 |
+
<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=suongbipun1234/my-beautiful-earth" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
|
283 |
+
</html>
|