Linkmkb commited on
Commit
769b0fc
·
verified ·
1 Parent(s): 8d27363

Add 3 files

Browse files
Files changed (3) hide show
  1. README.md +7 -5
  2. index.html +267 -19
  3. prompts.txt +1 -0
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Earth3d
3
- emoji: 🐠
4
- colorFrom: green
5
- colorTo: yellow
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: earth3d
3
+ emoji: 🐳
4
+ colorFrom: blue
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,267 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta name="viewport" content="width=device-width" />
6
- <title>My static Space</title>
7
- <link rel="stylesheet" href="style.css" />
8
- </head>
9
- <body>
10
- <div class="card">
11
- <h1>Welcome to your static Space!</h1>
12
- <p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p>
13
- <p>
14
- Also don't forget to check the
15
- <a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.
16
- </p>
17
- </div>
18
- </body>
19
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 with Country Labels</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
+ .country-label {
12
+ position: absolute;
13
+ color: white;
14
+ background: rgba(0, 0, 0, 0.6);
15
+ padding: 2px 6px;
16
+ border-radius: 4px;
17
+ font-size: 12px;
18
+ pointer-events: none;
19
+ transform: translate(-50%, -50%);
20
+ white-space: nowrap;
21
+ transition: all 0.2s ease;
22
+ }
23
+
24
+ .country-label:hover {
25
+ background: rgba(0, 0, 0, 0.9);
26
+ font-size: 14px;
27
+ z-index: 100;
28
+ }
29
+
30
+ #earth-container {
31
+ position: relative;
32
+ width: 100%;
33
+ height: 100vh;
34
+ overflow: hidden;
35
+ }
36
+
37
+ .info-panel {
38
+ position: absolute;
39
+ bottom: 20px;
40
+ left: 20px;
41
+ background: rgba(0, 0, 0, 0.7);
42
+ color: white;
43
+ padding: 15px;
44
+ border-radius: 8px;
45
+ max-width: 300px;
46
+ z-index: 10;
47
+ }
48
+
49
+ .controls-info {
50
+ position: absolute;
51
+ top: 20px;
52
+ right: 20px;
53
+ background: rgba(0, 0, 0, 0.7);
54
+ color: white;
55
+ padding: 10px;
56
+ border-radius: 8px;
57
+ font-size: 12px;
58
+ z-index: 10;
59
+ }
60
+ </style>
61
+ </head>
62
+ <body class="bg-gray-900">
63
+ <div id="earth-container">
64
+ <div class="controls-info">
65
+ <div>Left click + drag: Rotate</div>
66
+ <div>Right click + drag: Pan</div>
67
+ <div>Scroll: Zoom</div>
68
+ </div>
69
+
70
+ <div class="info-panel">
71
+ <h2 class="text-xl font-bold mb-2">Interactive 3D Earth</h2>
72
+ <p class="mb-3">Explore our planet with labeled countries. Hover over labels for more information.</p>
73
+ <div class="flex items-center mb-2">
74
+ <div class="w-4 h-4 bg-blue-500 rounded-full mr-2"></div>
75
+ <span>Water</span>
76
+ </div>
77
+ <div class="flex items-center mb-2">
78
+ <div class="w-4 h-4 bg-green-600 rounded-full mr-2"></div>
79
+ <span>Land</span>
80
+ </div>
81
+ <div class="flex items-center">
82
+ <div class="w-4 h-4 bg-yellow-400 rounded-full mr-2"></div>
83
+ <span>Highlighted Countries</span>
84
+ </div>
85
+ </div>
86
+ </div>
87
+
88
+ <script>
89
+ // Initialize Three.js scene
90
+ const container = document.getElementById('earth-container');
91
+ const width = container.clientWidth;
92
+ const height = container.clientHeight;
93
+
94
+ // Create scene
95
+ const scene = new THREE.Scene();
96
+ scene.background = new THREE.Color(0x000000);
97
+
98
+ // Create camera
99
+ const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000);
100
+ camera.position.z = 2;
101
+
102
+ // Create renderer
103
+ const renderer = new THREE.WebGLRenderer({ antialias: true });
104
+ renderer.setSize(width, height);
105
+ container.appendChild(renderer.domElement);
106
+
107
+ // Add orbit controls
108
+ const controls = new THREE.OrbitControls(camera, renderer.domElement);
109
+ controls.enableDamping = true;
110
+ controls.dampingFactor = 0.05;
111
+
112
+ // Add ambient light
113
+ const ambientLight = new THREE.AmbientLight(0x404040);
114
+ scene.add(ambientLight);
115
+
116
+ // Add directional light
117
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
118
+ directionalLight.position.set(5, 3, 5);
119
+ scene.add(directionalLight);
120
+
121
+ // Create Earth sphere
122
+ const earthGeometry = new THREE.SphereGeometry(1, 64, 64);
123
+
124
+ // Load Earth texture
125
+ const textureLoader = new THREE.TextureLoader();
126
+ const earthTexture = textureLoader.load('https://threejs.org/examples/textures/planets/earth_atmos_2048.jpg');
127
+ const bumpMap = textureLoader.load('https://threejs.org/examples/textures/planets/earth_normal_2048.jpg');
128
+ const specularMap = textureLoader.load('https://threejs.org/examples/textures/planets/earth_specular_2048.jpg');
129
+
130
+ const earthMaterial = new THREE.MeshPhongMaterial({
131
+ map: earthTexture,
132
+ bumpMap: bumpMap,
133
+ bumpScale: 0.05,
134
+ specularMap: specularMap,
135
+ specular: new THREE.Color('grey'),
136
+ shininess: 5
137
+ });
138
+
139
+ const earth = new THREE.Mesh(earthGeometry, earthMaterial);
140
+ scene.add(earth);
141
+
142
+ // Add clouds
143
+ const cloudGeometry = new THREE.SphereGeometry(1.01, 64, 64);
144
+ const cloudTexture = textureLoader.load('https://threejs.org/examples/textures/planets/earth_clouds_1024.png');
145
+ const cloudMaterial = new THREE.MeshPhongMaterial({
146
+ map: cloudTexture,
147
+ transparent: true,
148
+ opacity: 0.4
149
+ });
150
+
151
+ const clouds = new THREE.Mesh(cloudGeometry, cloudMaterial);
152
+ scene.add(clouds);
153
+
154
+ // Add stars
155
+ const starGeometry = new THREE.BufferGeometry();
156
+ const starMaterial = new THREE.PointsMaterial({
157
+ color: 0xffffff,
158
+ size: 0.05,
159
+ transparent: true,
160
+ opacity: 0.8
161
+ });
162
+
163
+ const starVertices = [];
164
+ for (let i = 0; i < 5000; i++) {
165
+ const x = (Math.random() - 0.5) * 2000;
166
+ const y = (Math.random() - 0.5) * 2000;
167
+ const z = (Math.random() - 0.5) * 2000;
168
+ starVertices.push(x, y, z);
169
+ }
170
+
171
+ starGeometry.setAttribute('position', new THREE.Float32BufferAttribute(starVertices, 3));
172
+ const stars = new THREE.Points(starGeometry, starMaterial);
173
+ scene.add(stars);
174
+
175
+ // Country data with coordinates and information
176
+ const countries = [
177
+ { name: "United States", lat: 37.0902, lng: -95.7129, capital: "Washington, D.C.", population: "331 million" },
178
+ { name: "Canada", lat: 56.1304, lng: -106.3468, capital: "Ottawa", population: "38 million" },
179
+ { name: "Brazil", lat: -14.2350, lng: -51.9253, capital: "Brasília", population: "213 million" },
180
+ { name: "United Kingdom", lat: 55.3781, lng: -3.4360, capital: "London", population: "67 million" },
181
+ { name: "France", lat: 46.6035, lng: 1.8883, capital: "Paris", population: "67 million" },
182
+ { name: "Germany", lat: 51.1657, lng: 10.4515, capital: "Berlin", population: "83 million" },
183
+ { name: "China", lat: 35.8617, lng: 104.1954, capital: "Beijing", population: "1.4 billion" },
184
+ { name: "India", lat: 20.5937, lng: 78.9629, capital: "New Delhi", population: "1.38 billion" },
185
+ { name: "Japan", lat: 36.2048, lng: 138.2529, capital: "Tokyo", population: "126 million" },
186
+ { name: "Australia", lat: -25.2744, lng: 133.7751, capital: "Canberra", population: "25 million" },
187
+ { name: "Russia", lat: 61.5240, lng: 105.3188, capital: "Moscow", population: "146 million" },
188
+ { name: "South Africa", lat: -30.5595, lng: 22.9375, capital: "Pretoria", population: "60 million" },
189
+ { name: "Egypt", lat: 26.8206, lng: 30.8025, capital: "Cairo", population: "102 million" },
190
+ { name: "Nigeria", lat: 9.0820, lng: 8.6753, capital: "Abuja", population: "206 million" },
191
+ { name: "Mexico", lat: 23.6345, lng: -102.5528, capital: "Mexico City", population: "128 million" }
192
+ ];
193
+
194
+ // Create country labels
195
+ const labels = [];
196
+
197
+ countries.forEach(country => {
198
+ const phi = (90 - country.lat) * (Math.PI / 180);
199
+ const theta = (country.lng + 180) * (Math.PI / 180);
200
+
201
+ const x = -Math.sin(phi) * Math.cos(theta);
202
+ const y = Math.cos(phi);
203
+ const z = Math.sin(phi) * Math.sin(theta);
204
+
205
+ const label = document.createElement('div');
206
+ label.className = 'country-label';
207
+ label.textContent = country.name;
208
+ label.dataset.capital = country.capital;
209
+ label.dataset.population = country.population;
210
+
211
+ container.appendChild(label);
212
+ labels.push({
213
+ element: label,
214
+ position: new THREE.Vector3(x, y, z)
215
+ });
216
+
217
+ // Add hover effect
218
+ label.addEventListener('mouseover', () => {
219
+ label.innerHTML = `
220
+ <div class="font-bold">${country.name}</div>
221
+ <div>Capital: ${country.capital}</div>
222
+ <div>Population: ${country.population}</div>
223
+ `;
224
+ });
225
+
226
+ label.addEventListener('mouseout', () => {
227
+ label.textContent = country.name;
228
+ });
229
+ });
230
+
231
+ // Handle window resize
232
+ window.addEventListener('resize', () => {
233
+ camera.aspect = container.clientWidth / container.clientHeight;
234
+ camera.updateProjectionMatrix();
235
+ renderer.setSize(container.clientWidth, container.clientHeight);
236
+ });
237
+
238
+ // Animation loop
239
+ function animate() {
240
+ requestAnimationFrame(animate);
241
+
242
+ // Rotate Earth and clouds
243
+ earth.rotation.y += 0.001;
244
+ clouds.rotation.y += 0.0015;
245
+
246
+ controls.update();
247
+
248
+ // Update label positions
249
+ labels.forEach(label => {
250
+ const screenPosition = label.position.clone().project(camera);
251
+
252
+ const x = (screenPosition.x * 0.5 + 0.5) * container.clientWidth;
253
+ const y = (-(screenPosition.y * 0.5) + 0.5) * container.clientHeight;
254
+
255
+ label.element.style.transform = `translate(-50%, -50%) translate(${x}px, ${y}px)`;
256
+
257
+ // Hide labels on the back side of the Earth
258
+ label.element.style.display = screenPosition.z > 1 ? 'none' : 'block';
259
+ });
260
+
261
+ renderer.render(scene, camera);
262
+ }
263
+
264
+ animate();
265
+ </script>
266
+ <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=Linkmkb/earth3d" style="color: #fff;text-decoration: underline;" target="_blank" >Remix</a></p></body>
267
+ </html>
prompts.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ a 3d model of earth with labelled countries