LukasBe commited on
Commit
89f819b
·
verified ·
1 Parent(s): eab14e9

Add 2 files

Browse files
Files changed (2) hide show
  1. README.md +7 -5
  2. index.html +481 -19
README.md CHANGED
@@ -1,10 +1,12 @@
1
  ---
2
- title: Simulator
3
- emoji: 🏃
4
- colorFrom: yellow
5
- colorTo: pink
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: simulator
3
+ emoji: 🐳
4
+ colorFrom: blue
5
+ colorTo: purple
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,481 @@
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 Wormhole Simulator</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
+ <script src="https://cdn.jsdelivr.net/npm/[email protected]/examples/js/loaders/GLTFLoader.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 {
18
+ display: block;
19
+ }
20
+ #ui {
21
+ position: absolute;
22
+ top: 0;
23
+ left: 0;
24
+ width: 100%;
25
+ height: 100%;
26
+ pointer-events: none;
27
+ }
28
+ #controls {
29
+ position: absolute;
30
+ bottom: 20px;
31
+ left: 50%;
32
+ transform: translateX(-50%);
33
+ background: rgba(0, 0, 0, 0.5);
34
+ padding: 10px 20px;
35
+ border-radius: 20px;
36
+ display: flex;
37
+ gap: 10px;
38
+ pointer-events: all;
39
+ }
40
+ button {
41
+ background: rgba(255, 255, 255, 0.2);
42
+ color: white;
43
+ border: 1px solid rgba(255, 255, 255, 0.3);
44
+ padding: 8px 16px;
45
+ border-radius: 20px;
46
+ cursor: pointer;
47
+ transition: all 0.3s;
48
+ }
49
+ button:hover {
50
+ background: rgba(255, 255, 255, 0.3);
51
+ }
52
+ #info {
53
+ position: absolute;
54
+ top: 20px;
55
+ left: 20px;
56
+ color: white;
57
+ background: rgba(0, 0, 0, 0.5);
58
+ padding: 10px;
59
+ border-radius: 10px;
60
+ max-width: 300px;
61
+ }
62
+ .particle {
63
+ position: absolute;
64
+ width: 2px;
65
+ height: 2px;
66
+ background: white;
67
+ border-radius: 50%;
68
+ pointer-events: none;
69
+ }
70
+ @keyframes pulse {
71
+ 0% { opacity: 0.2; }
72
+ 50% { opacity: 1; }
73
+ 100% { opacity: 0.2; }
74
+ }
75
+ .pulse {
76
+ animation: pulse 2s infinite;
77
+ }
78
+ </style>
79
+ </head>
80
+ <body>
81
+ <div id="canvas"></div>
82
+ <div id="ui">
83
+ <div id="info">
84
+ <h1 class="text-xl font-bold mb-2">Wormhole Simulator</h1>
85
+ <p class="text-sm">Experience a journey through a cosmic wormhole with dynamic effects.</p>
86
+ <div class="mt-2 text-xs">
87
+ <div class="flex items-center"><div class="w-3 h-3 bg-blue-500 rounded-full mr-2"></div> Stars</div>
88
+ <div class="flex items-center"><div class="w-3 h-3 bg-yellow-500 rounded-full mr-2"></div> Sparks</div>
89
+ <div class="flex items-center"><div class="w-3 h-3 bg-red-500 rounded-full mr-2"></div> Explosions</div>
90
+ <div class="flex items-center"><div class="w-3 h-3 bg-gray-400 rounded-full mr-2"></div> Debris</div>
91
+ </div>
92
+ </div>
93
+ <div id="controls">
94
+ <button id="startBtn">Start Journey</button>
95
+ <button id="resetBtn">Reset</button>
96
+ <button id="autoPilot">Auto Pilot</button>
97
+ </div>
98
+ </div>
99
+
100
+ <script>
101
+ // Main Three.js variables
102
+ let scene, camera, renderer, controls;
103
+ let wormhole, ship, particles = [];
104
+ let isAnimating = false;
105
+ let autoPilot = false;
106
+ let journeyProgress = 0;
107
+ let journeySpeed = 0.001;
108
+ let explosionParticles = [];
109
+ let debrisParticles = [];
110
+ let sparkParticles = [];
111
+ let starParticles = [];
112
+
113
+ // Initialize the scene
114
+ function init() {
115
+ // Create scene
116
+ scene = new THREE.Scene();
117
+ scene.background = new THREE.Color(0x000000);
118
+ scene.fog = new THREE.FogExp2(0x000000, 0.002);
119
+
120
+ // Create camera
121
+ camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 10000);
122
+ camera.position.set(0, 0, 50);
123
+
124
+ // Create renderer
125
+ renderer = new THREE.WebGLRenderer({ antialias: true });
126
+ renderer.setSize(window.innerWidth, window.innerHeight);
127
+ renderer.shadowMap.enabled = true;
128
+ document.getElementById('canvas').appendChild(renderer.domElement);
129
+
130
+ // Add orbit controls
131
+ controls = new THREE.OrbitControls(camera, renderer.domElement);
132
+ controls.enableDamping = true;
133
+ controls.dampingFactor = 0.05;
134
+
135
+ // Create lights
136
+ const ambientLight = new THREE.AmbientLight(0x404040);
137
+ scene.add(ambientLight);
138
+
139
+ const directionalLight = new THREE.DirectionalLight(0xffffff, 1);
140
+ directionalLight.position.set(1, 1, 1);
141
+ directionalLight.castShadow = true;
142
+ scene.add(directionalLight);
143
+
144
+ // Create wormhole
145
+ createWormhole();
146
+
147
+ // Create spaceship
148
+ createSpaceship();
149
+
150
+ // Create particles
151
+ createParticles();
152
+
153
+ // Add event listeners
154
+ window.addEventListener('resize', onWindowResize);
155
+ document.getElementById('startBtn').addEventListener('click', startJourney);
156
+ document.getElementById('resetBtn').addEventListener('click', resetScene);
157
+ document.getElementById('autoPilot').addEventListener('click', toggleAutoPilot);
158
+
159
+ // Start animation loop
160
+ animate();
161
+ }
162
+
163
+ // Create wormhole geometry
164
+ function createWormhole() {
165
+ const geometry = new THREE.TorusGeometry(15, 3, 32, 100);
166
+ const material = new THREE.MeshPhongMaterial({
167
+ color: 0x00aaff,
168
+ emissive: 0x0066ff,
169
+ emissiveIntensity: 0.5,
170
+ transparent: true,
171
+ opacity: 0.8,
172
+ wireframe: true
173
+ });
174
+
175
+ wormhole = new THREE.Mesh(geometry, material);
176
+ wormhole.rotation.x = Math.PI / 2;
177
+ scene.add(wormhole);
178
+
179
+ // Add inner glow
180
+ const innerGlowGeometry = new THREE.SphereGeometry(12, 32, 32);
181
+ const innerGlowMaterial = new THREE.MeshBasicMaterial({
182
+ color: 0x00aaff,
183
+ transparent: true,
184
+ opacity: 0.2
185
+ });
186
+ const innerGlow = new THREE.Mesh(innerGlowGeometry, innerGlowMaterial);
187
+ wormhole.add(innerGlow);
188
+ }
189
+
190
+ // Create spaceship
191
+ function createSpaceship() {
192
+ const geometry = new THREE.ConeGeometry(1, 3, 8);
193
+ const material = new THREE.MeshPhongMaterial({
194
+ color: 0xffffff,
195
+ emissive: 0xaaaaaa,
196
+ emissiveIntensity: 0.2,
197
+ specular: 0x111111,
198
+ shininess: 30
199
+ });
200
+
201
+ ship = new THREE.Mesh(geometry, material);
202
+ ship.position.set(0, 0, -50);
203
+ ship.rotation.x = Math.PI / 2;
204
+ scene.add(ship);
205
+
206
+ // Add engine glow
207
+ const engineGlowGeometry = new THREE.SphereGeometry(0.5, 16, 16);
208
+ const engineGlowMaterial = new THREE.MeshBasicMaterial({
209
+ color: 0x00ffff,
210
+ transparent: true,
211
+ opacity: 0.8
212
+ });
213
+ const engineGlow = new THREE.Mesh(engineGlowGeometry, engineGlowMaterial);
214
+ engineGlow.position.set(0, -1.5, 0);
215
+ ship.add(engineGlow);
216
+ }
217
+
218
+ // Create various particles
219
+ function createParticles() {
220
+ // Stars background
221
+ for (let i = 0; i < 1000; i++) {
222
+ const star = new THREE.Mesh(
223
+ new THREE.SphereGeometry(0.05 + Math.random() * 0.2, 8, 8),
224
+ new THREE.MeshBasicMaterial({ color: 0xffffff })
225
+ );
226
+ star.position.set(
227
+ Math.random() * 2000 - 1000,
228
+ Math.random() * 2000 - 1000,
229
+ Math.random() * 2000 - 1000
230
+ );
231
+ scene.add(star);
232
+ starParticles.push(star);
233
+ }
234
+
235
+ // Debris
236
+ for (let i = 0; i < 100; i++) {
237
+ const size = 0.2 + Math.random() * 1;
238
+ const debris = new THREE.Mesh(
239
+ new THREE.BoxGeometry(size, size, size),
240
+ new THREE.MeshPhongMaterial({ color: 0x888888 })
241
+ );
242
+ debris.position.set(
243
+ Math.random() * 100 - 50,
244
+ Math.random() * 100 - 50,
245
+ Math.random() * 100 - 50
246
+ );
247
+ debris.rotation.set(
248
+ Math.random() * Math.PI,
249
+ Math.random() * Math.PI,
250
+ Math.random() * Math.PI
251
+ );
252
+ debris.userData = {
253
+ velocity: new THREE.Vector3(
254
+ Math.random() * 0.2 - 0.1,
255
+ Math.random() * 0.2 - 0.1,
256
+ Math.random() * 0.2 - 0.1
257
+ )
258
+ };
259
+ scene.add(debris);
260
+ debrisParticles.push(debris);
261
+ }
262
+ }
263
+
264
+ // Create explosion effect
265
+ function createExplosion(position) {
266
+ for (let i = 0; i < 50; i++) {
267
+ const size = 0.1 + Math.random() * 0.3;
268
+ const particle = new THREE.Mesh(
269
+ new THREE.SphereGeometry(size, 8, 8),
270
+ new THREE.MeshBasicMaterial({
271
+ color: new THREE.Color(
272
+ 0.8 + Math.random() * 0.2,
273
+ 0.3 + Math.random() * 0.3,
274
+ Math.random() * 0.2
275
+ ),
276
+ transparent: true,
277
+ opacity: 0.8
278
+ })
279
+ );
280
+ particle.position.copy(position);
281
+ particle.userData = {
282
+ velocity: new THREE.Vector3(
283
+ Math.random() * 2 - 1,
284
+ Math.random() * 2 - 1,
285
+ Math.random() * 2 - 1
286
+ ),
287
+ lifetime: 100 + Math.random() * 50,
288
+ age: 0
289
+ };
290
+ scene.add(particle);
291
+ explosionParticles.push(particle);
292
+ }
293
+ }
294
+
295
+ // Create spark effect
296
+ function createSparks(position) {
297
+ for (let i = 0; i < 20; i++) {
298
+ const spark = new THREE.Mesh(
299
+ new THREE.SphereGeometry(0.05 + Math.random() * 0.1, 4, 4),
300
+ new THREE.MeshBasicMaterial({
301
+ color: 0xffff00,
302
+ transparent: true,
303
+ opacity: 0.8
304
+ })
305
+ );
306
+ spark.position.copy(position);
307
+ spark.userData = {
308
+ velocity: new THREE.Vector3(
309
+ Math.random() * 0.5 - 0.25,
310
+ Math.random() * 0.5 - 0.25,
311
+ Math.random() * 0.5 - 0.25
312
+ ),
313
+ lifetime: 50 + Math.random() * 30,
314
+ age: 0
315
+ };
316
+ scene.add(spark);
317
+ sparkParticles.push(spark);
318
+ }
319
+ }
320
+
321
+ // Bezier curve for smooth flight path
322
+ function getBezierPoint(t) {
323
+ // Control points for the bezier curve
324
+ const p0 = new THREE.Vector3(0, 0, -50);
325
+ const p1 = new THREE.Vector3(20, 30, -20);
326
+ const p2 = new THREE.Vector3(-10, 0, 10);
327
+ const p3 = new THREE.Vector3(0, 0, 50);
328
+
329
+ // Cubic bezier formula
330
+ const point = new THREE.Vector3();
331
+ point.x = Math.pow(1 - t, 3) * p0.x +
332
+ 3 * Math.pow(1 - t, 2) * t * p1.x +
333
+ 3 * (1 - t) * Math.pow(t, 2) * p2.x +
334
+ Math.pow(t, 3) * p3.x;
335
+ point.y = Math.pow(1 - t, 3) * p0.y +
336
+ 3 * Math.pow(1 - t, 2) * t * p1.y +
337
+ 3 * (1 - t) * Math.pow(t, 2) * p2.y +
338
+ Math.pow(t, 3) * p3.y;
339
+ point.z = Math.pow(1 - t, 3) * p0.z +
340
+ 3 * Math.pow(1 - t, 2) * t * p1.z +
341
+ 3 * (1 - t) * Math.pow(t, 2) * p2.z +
342
+ Math.pow(t, 3) * p3.z;
343
+
344
+ return point;
345
+ }
346
+
347
+ // Start the journey through the wormhole
348
+ function startJourney() {
349
+ if (!isAnimating) {
350
+ isAnimating = true;
351
+ journeyProgress = 0;
352
+ }
353
+ }
354
+
355
+ // Reset the scene
356
+ function resetScene() {
357
+ isAnimating = false;
358
+ autoPilot = false;
359
+ journeyProgress = 0;
360
+ ship.position.set(0, 0, -50);
361
+ camera.position.set(0, 0, 50);
362
+ controls.reset();
363
+ }
364
+
365
+ // Toggle autopilot mode
366
+ function toggleAutoPilot() {
367
+ autoPilot = !autoPilot;
368
+ document.getElementById('autoPilot').textContent = autoPilot ? 'Manual Control' : 'Auto Pilot';
369
+ }
370
+
371
+ // Handle window resize
372
+ function onWindowResize() {
373
+ camera.aspect = window.innerWidth / window.innerHeight;
374
+ camera.updateProjectionMatrix();
375
+ renderer.setSize(window.innerWidth, window.innerHeight);
376
+ }
377
+
378
+ // Animation loop
379
+ function animate() {
380
+ requestAnimationFrame(animate);
381
+
382
+ // Update controls
383
+ controls.update();
384
+
385
+ // Rotate wormhole
386
+ wormhole.rotation.z += 0.005;
387
+
388
+ // Update debris particles
389
+ debrisParticles.forEach(debris => {
390
+ debris.position.add(debris.userData.velocity);
391
+ debris.rotation.x += 0.01;
392
+ debris.rotation.y += 0.01;
393
+
394
+ // Wrap around if out of bounds
395
+ if (Math.abs(debris.position.x) > 100) debris.position.x = -debris.position.x;
396
+ if (Math.abs(debris.position.y) > 100) debris.position.y = -debris.position.y;
397
+ if (Math.abs(debris.position.z) > 100) debris.position.z = -debris.position.z;
398
+ });
399
+
400
+ // Update explosion particles
401
+ for (let i = explosionParticles.length - 1; i >= 0; i--) {
402
+ const particle = explosionParticles[i];
403
+ particle.position.add(particle.userData.velocity);
404
+ particle.userData.age++;
405
+ particle.userData.velocity.multiplyScalar(0.98);
406
+ particle.material.opacity = 0.8 * (1 - particle.userData.age / particle.userData.lifetime);
407
+
408
+ if (particle.userData.age >= particle.userData.lifetime) {
409
+ scene.remove(particle);
410
+ explosionParticles.splice(i, 1);
411
+ }
412
+ }
413
+
414
+ // Update spark particles
415
+ for (let i = sparkParticles.length - 1; i >= 0; i--) {
416
+ const spark = sparkParticles[i];
417
+ spark.position.add(spark.userData.velocity);
418
+ spark.userData.age++;
419
+ spark.userData.velocity.multiplyScalar(0.95);
420
+ spark.material.opacity = 0.8 * (1 - spark.userData.age / spark.userData.lifetime);
421
+
422
+ if (spark.userData.age >= spark.userData.lifetime) {
423
+ scene.remove(spark);
424
+ sparkParticles.splice(i, 1);
425
+ }
426
+ }
427
+
428
+ // Randomly create explosions and sparks
429
+ if (Math.random() < 0.02) {
430
+ createExplosion(new THREE.Vector3(
431
+ Math.random() * 40 - 20,
432
+ Math.random() * 40 - 20,
433
+ Math.random() * 40 - 20
434
+ ));
435
+ }
436
+
437
+ if (Math.random() < 0.05) {
438
+ createSparks(new THREE.Vector3(
439
+ Math.random() * 30 - 15,
440
+ Math.random() * 30 - 15,
441
+ Math.random() * 30 - 15
442
+ ));
443
+ }
444
+
445
+ // Animate ship through wormhole
446
+ if (isAnimating) {
447
+ journeyProgress += journeySpeed;
448
+
449
+ if (journeyProgress >= 1) {
450
+ journeyProgress = 1;
451
+ isAnimating = false;
452
+ }
453
+
454
+ const shipPos = getBezierPoint(journeyProgress);
455
+ ship.position.copy(shipPos);
456
+
457
+ // Calculate direction for ship orientation
458
+ const nextPos = getBezierPoint(Math.min(journeyProgress + 0.01, 1));
459
+ const direction = new THREE.Vector3().subVectors(nextPos, shipPos).normalize();
460
+ ship.lookAt(nextPos);
461
+
462
+ // Randomly adjust speed for more organic feel
463
+ journeySpeed = 0.001 + Math.sin(Date.now() * 0.001) * 0.0005;
464
+
465
+ // Auto camera follow in autopilot mode
466
+ if (autoPilot) {
467
+ const cameraOffset = new THREE.Vector3(0, 5, -10);
468
+ cameraOffset.applyQuaternion(ship.quaternion);
469
+ camera.position.copy(ship.position).add(cameraOffset);
470
+ camera.lookAt(ship.position);
471
+ }
472
+ }
473
+
474
+ renderer.render(scene, camera);
475
+ }
476
+
477
+ // Initialize the scene
478
+ init();
479
+ </script>
480
+ <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=LukasBe/simulator" style="color: #fff;text-decoration: underline;" target="_blank" >🧬 Remix</a></p></body>
481
+ </html>