Spaces:
Running
Running
Add 2 files
Browse filesFiles changed (2)
- README.md+7-5
- index.html+481-19
12345678910---title: Simulatoremoji: 🏃colorFrom: yellowcolorTo: pinksdk: staticpinned: false---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference123456789101112---title: simulatoremoji: 🐳colorFrom: bluecolorTo: purplesdk: staticpinned: falsetags:- deepsite---Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
12345678910111213141516171819<!doctype html><html><head><meta charset="utf-8" /><meta name="viewport" content="width=device-width" /><title>My static Space</title><link rel="stylesheet" href="style.css" /></head><body><div class="card"><h1>Welcome to your static Space!</h1><p>You can modify this app directly by editing <i>index.html</i> in the Files and versions tab.</p><p>Also don't forget to check the<a href="https://huggingface.co/docs/hub/spaces" target="_blank">Spaces documentation</a>.</p></div></body></html>123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481<!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>3D Wormhole Simulator</title><script src="https://cdn.tailwindcss.com"></script><script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script><script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/controls/OrbitControls.min.js"></script><script src="https://cdn.jsdelivr.net/npm/three@0.128.0/examples/js/loaders/GLTFLoader.min.js"></script><style>body {margin: 0;overflow: hidden;font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;}#canvas {display: block;}#ui {position: absolute;top: 0;left: 0;width: 100%;height: 100%;pointer-events: none;}#controls {position: absolute;bottom: 20px;left: 50%;transform: translateX(-50%);background: rgba(0, 0, 0, 0.5);padding: 10px 20px;border-radius: 20px;display: flex;gap: 10px;pointer-events: all;}button {background: rgba(255, 255, 255, 0.2);color: white;border: 1px solid rgba(255, 255, 255, 0.3);padding: 8px 16px;border-radius: 20px;cursor: pointer;transition: all 0.3s;}button:hover {background: rgba(255, 255, 255, 0.3);}#info {position: absolute;top: 20px;left: 20px;color: white;background: rgba(0, 0, 0, 0.5);padding: 10px;border-radius: 10px;max-width: 300px;}.particle {position: absolute;width: 2px;height: 2px;background: white;border-radius: 50%;pointer-events: none;}@keyframes pulse {0% { opacity: 0.2; }50% { opacity: 1; }100% { opacity: 0.2; }}.pulse {animation: pulse 2s infinite;}</style></head><body><div id="canvas"></div><div id="ui"><div id="info"><h1 class="text-xl font-bold mb-2">Wormhole Simulator</h1><p class="text-sm">Experience a journey through a cosmic wormhole with dynamic effects.</p><div class="mt-2 text-xs"><div class="flex items-center"><div class="w-3 h-3 bg-blue-500 rounded-full mr-2"></div> Stars</div><div class="flex items-center"><div class="w-3 h-3 bg-yellow-500 rounded-full mr-2"></div> Sparks</div><div class="flex items-center"><div class="w-3 h-3 bg-red-500 rounded-full mr-2"></div> Explosions</div><div class="flex items-center"><div class="w-3 h-3 bg-gray-400 rounded-full mr-2"></div> Debris</div></div></div><div id="controls"><button id="startBtn">Start Journey</button><button id="resetBtn">Reset</button><button id="autoPilot">Auto Pilot</button></div></div><script>// Main Three.js variableslet scene, camera, renderer, controls;let wormhole, ship, particles = [];let isAnimating = false;let autoPilot = false;let journeyProgress = 0;let journeySpeed = 0.001;let explosionParticles = [];let debrisParticles = [];let sparkParticles = [];let starParticles = [];// Initialize the scenefunction init() {// Create scenescene = new THREE.Scene();scene.background = new THREE.Color(0x000000);scene.fog = new THREE.FogExp2(0x000000, 0.002);// Create cameracamera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 10000);camera.position.set(0, 0, 50);// Create rendererrenderer = new THREE.WebGLRenderer({ antialias: true });renderer.setSize(window.innerWidth, window.innerHeight);renderer.shadowMap.enabled = true;document.getElementById('canvas').appendChild(renderer.domElement);// Add orbit controlscontrols = new THREE.OrbitControls(camera, renderer.domElement);controls.enableDamping = true;controls.dampingFactor = 0.05;// Create lightsconst ambientLight = new THREE.AmbientLight(0x404040);scene.add(ambientLight);const directionalLight = new THREE.DirectionalLight(0xffffff, 1);directionalLight.position.set(1, 1, 1);directionalLight.castShadow = true;scene.add(directionalLight);// Create wormholecreateWormhole();// Create spaceshipcreateSpaceship();// Create particlescreateParticles();// Add event listenerswindow.addEventListener('resize', onWindowResize);document.getElementById('startBtn').addEventListener('click', startJourney);document.getElementById('resetBtn').addEventListener('click', resetScene);document.getElementById('autoPilot').addEventListener('click', toggleAutoPilot);// Start animation loopanimate();}// Create wormhole geometryfunction createWormhole() {const geometry = new THREE.TorusGeometry(15, 3, 32, 100);const material = new THREE.MeshPhongMaterial({color: 0x00aaff,emissive: 0x0066ff,emissiveIntensity: 0.5,transparent: true,opacity: 0.8,wireframe: true});wormhole = new THREE.Mesh(geometry, material);wormhole.rotation.x = Math.PI / 2;scene.add(wormhole);// Add inner glowconst innerGlowGeometry = new THREE.SphereGeometry(12, 32, 32);const innerGlowMaterial = new THREE.MeshBasicMaterial({color: 0x00aaff,transparent: true,opacity: 0.2});const innerGlow = new THREE.Mesh(innerGlowGeometry, innerGlowMaterial);wormhole.add(innerGlow);}// Create spaceshipfunction createSpaceship() {const geometry = new THREE.ConeGeometry(1, 3, 8);const material = new THREE.MeshPhongMaterial({color: 0xffffff,emissive: 0xaaaaaa,emissiveIntensity: 0.2,specular: 0x111111,shininess: 30});ship = new THREE.Mesh(geometry, material);ship.position.set(0, 0, -50);ship.rotation.x = Math.PI / 2;scene.add(ship);// Add engine glowconst engineGlowGeometry = new THREE.SphereGeometry(0.5, 16, 16);const engineGlowMaterial = new THREE.MeshBasicMaterial({color: 0x00ffff,transparent: true,opacity: 0.8});const engineGlow = new THREE.Mesh(engineGlowGeometry, engineGlowMaterial);engineGlow.position.set(0, -1.5, 0);ship.add(engineGlow);}// Create various particlesfunction createParticles() {// Stars backgroundfor (let i = 0; i < 1000; i++) {const star = new THREE.Mesh(new THREE.SphereGeometry(0.05 + Math.random() * 0.2, 8, 8),new THREE.MeshBasicMaterial({ color: 0xffffff }));star.position.set(Math.random() * 2000 - 1000,Math.random() * 2000 - 1000,Math.random() * 2000 - 1000);scene.add(star);starParticles.push(star);}// Debrisfor (let i = 0; i < 100; i++) {const size = 0.2 + Math.random() * 1;const debris = new THREE.Mesh(new THREE.BoxGeometry(size, size, size),new THREE.MeshPhongMaterial({ color: 0x888888 }));debris.position.set(Math.random() * 100 - 50,Math.random() * 100 - 50,Math.random() * 100 - 50);debris.rotation.set(Math.random() * Math.PI,Math.random() * Math.PI,Math.random() * Math.PI);debris.userData = {velocity: new THREE.Vector3(Math.random() * 0.2 - 0.1,Math.random() * 0.2 - 0.1,Math.random() * 0.2 - 0.1)};scene.add(debris);debrisParticles.push(debris);}}// Create explosion effectfunction createExplosion(position) {for (let i = 0; i < 50; i++) {const size = 0.1 + Math.random() * 0.3;const particle = new THREE.Mesh(new THREE.SphereGeometry(size, 8, 8),new THREE.MeshBasicMaterial({color: new THREE.Color(0.8 + Math.random() * 0.2,0.3 + Math.random() * 0.3,Math.random() * 0.2),transparent: true,opacity: 0.8}));particle.position.copy(position);particle.userData = {velocity: new THREE.Vector3(Math.random() * 2 - 1,Math.random() * 2 - 1,Math.random() * 2 - 1),lifetime: 100 + Math.random() * 50,age: 0};scene.add(particle);explosionParticles.push(particle);}}// Create spark effectfunction createSparks(position) {for (let i = 0; i < 20; i++) {const spark = new THREE.Mesh(new THREE.SphereGeometry(0.05 + Math.random() * 0.1, 4, 4),new THREE.MeshBasicMaterial({color: 0xffff00,transparent: true,opacity: 0.8}));spark.position.copy(position);spark.userData = {velocity: new THREE.Vector3(Math.random() * 0.5 - 0.25,Math.random() * 0.5 - 0.25,Math.random() * 0.5 - 0.25),lifetime: 50 + Math.random() * 30,age: 0};scene.add(spark);sparkParticles.push(spark);}}// Bezier curve for smooth flight pathfunction getBezierPoint(t) {// Control points for the bezier curveconst p0 = new THREE.Vector3(0, 0, -50);const p1 = new THREE.Vector3(20, 30, -20);const p2 = new THREE.Vector3(-10, 0, 10);const p3 = new THREE.Vector3(0, 0, 50);// Cubic bezier formulaconst point = new THREE.Vector3();point.x = Math.pow(1 - t, 3) * p0.x +3 * Math.pow(1 - t, 2) * t * p1.x +3 * (1 - t) * Math.pow(t, 2) * p2.x +Math.pow(t, 3) * p3.x;point.y = Math.pow(1 - t, 3) * p0.y +3 * Math.pow(1 - t, 2) * t * p1.y +3 * (1 - t) * Math.pow(t, 2) * p2.y +Math.pow(t, 3) * p3.y;point.z = Math.pow(1 - t, 3) * p0.z +3 * Math.pow(1 - t, 2) * t * p1.z +3 * (1 - t) * Math.pow(t, 2) * p2.z +Math.pow(t, 3) * p3.z;return point;}// Start the journey through the wormholefunction startJourney() {if (!isAnimating) {isAnimating = true;journeyProgress = 0;}}// Reset the scenefunction resetScene() {isAnimating = false;autoPilot = false;journeyProgress = 0;ship.position.set(0, 0, -50);camera.position.set(0, 0, 50);controls.reset();}// Toggle autopilot modefunction toggleAutoPilot() {autoPilot = !autoPilot;document.getElementById('autoPilot').textContent = autoPilot ? 'Manual Control' : 'Auto Pilot';}// Handle window resizefunction onWindowResize() {camera.aspect = window.innerWidth / window.innerHeight;camera.updateProjectionMatrix();renderer.setSize(window.innerWidth, window.innerHeight);}// Animation loopfunction animate() {requestAnimationFrame(animate);// Update controlscontrols.update();// Rotate wormholewormhole.rotation.z += 0.005;// Update debris particlesdebrisParticles.forEach(debris => {debris.position.add(debris.userData.velocity);debris.rotation.x += 0.01;debris.rotation.y += 0.01;// Wrap around if out of boundsif (Math.abs(debris.position.x) > 100) debris.position.x = -debris.position.x;if (Math.abs(debris.position.y) > 100) debris.position.y = -debris.position.y;if (Math.abs(debris.position.z) > 100) debris.position.z = -debris.position.z;});// Update explosion particlesfor (let i = explosionParticles.length - 1; i >= 0; i--) {const particle = explosionParticles[i];particle.position.add(particle.userData.velocity);particle.userData.age++;particle.userData.velocity.multiplyScalar(0.98);particle.material.opacity = 0.8 * (1 - particle.userData.age / particle.userData.lifetime);if (particle.userData.age >= particle.userData.lifetime) {scene.remove(particle);explosionParticles.splice(i, 1);}}// Update spark particlesfor (let i = sparkParticles.length - 1; i >= 0; i--) {const spark = sparkParticles[i];spark.position.add(spark.userData.velocity);spark.userData.age++;spark.userData.velocity.multiplyScalar(0.95);spark.material.opacity = 0.8 * (1 - spark.userData.age / spark.userData.lifetime);if (spark.userData.age >= spark.userData.lifetime) {scene.remove(spark);sparkParticles.splice(i, 1);}}// Randomly create explosions and sparksif (Math.random() < 0.02) {createExplosion(new THREE.Vector3(Math.random() * 40 - 20,Math.random() * 40 - 20,Math.random() * 40 - 20));}if (Math.random() < 0.05) {createSparks(new THREE.Vector3(Math.random() * 30 - 15,Math.random() * 30 - 15,Math.random() * 30 - 15));}// Animate ship through wormholeif (isAnimating) {journeyProgress += journeySpeed;if (journeyProgress >= 1) {journeyProgress = 1;isAnimating = false;}const shipPos = getBezierPoint(journeyProgress);ship.position.copy(shipPos);// Calculate direction for ship orientationconst nextPos = getBezierPoint(Math.min(journeyProgress + 0.01, 1));const direction = new THREE.Vector3().subVectors(nextPos, shipPos).normalize();ship.lookAt(nextPos);// Randomly adjust speed for more organic feeljourneySpeed = 0.001 + Math.sin(Date.now() * 0.001) * 0.0005;// Auto camera follow in autopilot modeif (autoPilot) {const cameraOffset = new THREE.Vector3(0, 5, -10);cameraOffset.applyQuaternion(ship.quaternion);camera.position.copy(ship.position).add(cameraOffset);camera.lookAt(ship.position);}}renderer.render(scene, camera);}// Initialize the sceneinit();</script><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></html>
README.md+7-5
index.html+481-19