Download script.js from ineshdev/cosmic-3d-explorer-voyage: direct link, hf CLI and curl.
- Browser
- Download file 2.85 kB
-
https://huggingface.co/spaces/ineshdev/cosmic-3d-explorer-voyage/resolve/main/script.js
- Command line
-
hf download hf://spaces/ineshdev/cosmic-3d-explorer-voyage/script.js
-
curl -L -o script.js https://huggingface.co/spaces/ineshdev/cosmic-3d-explorer-voyage/resolve/main/script.js
2.85 kB
| document.addEventListener('DOMContentLoaded', () => { | |
| // Initialize Vanta.js background | |
| VANTA.NET({ | |
| el: "#vanta-bg", | |
| color: 0x7e22ce, | |
| backgroundColor: 0x0, | |
| points: 12.00, | |
| maxDistance: 22.00, | |
| spacing: 18.00 | |
| }); | |
| // Initialize Three.js scene | |
| const initThreeJS = () => { | |
| const container = document.getElementById('threejs-container'); | |
| const width = container.clientWidth; | |
| const height = container.clientHeight; | |
| const scene = new THREE.Scene(); | |
| const camera = new THREE.PerspectiveCamera(75, width / height, 0.1, 1000); | |
| const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); | |
| renderer.setSize(width, height); | |
| renderer.setPixelRatio(window.devicePixelRatio); | |
| container.appendChild(renderer.domElement); | |
| // Add lights | |
| const ambientLight = new THREE.AmbientLight(0x404040); | |
| scene.add(ambientLight); | |
| const directionalLight = new THREE.DirectionalLight(0xffffff, 1); | |
| directionalLight.position.set(1, 1, 1); | |
| scene.add(directionalLight); | |
| // Add objects | |
| const geometry = new THREE.IcosahedronGeometry(2, 1); | |
| const material = new THREE.MeshPhongMaterial({ | |
| color: 0x7e22ce, | |
| emissive: 0x3b0764, | |
| emissiveIntensity: 0.5, | |
| specular: 0x7b34dd, | |
| shininess: 50, | |
| wireframe: false | |
| }); | |
| const mesh = new THREE.Mesh(geometry, material); | |
| scene.add(mesh); | |
| camera.position.z = 5; | |
| // Animation loop | |
| const animate = () => { | |
| requestAnimationFrame(animate); | |
| mesh.rotation.x += 0.005; | |
| mesh.rotation.y += 0.01; | |
| renderer.render(scene, camera); | |
| }; | |
| animate(); | |
| // Handle window resize | |
| window.addEventListener('resize', () => { | |
| camera.aspect = container.clientWidth / container.clientHeight; | |
| camera.updateProjectionMatrix(); | |
| renderer.setSize(container.clientWidth, container.clientHeight); | |
| }); | |
| // VR button functionality | |
| document.getElementById('enter-vr').addEventListener('click', () => { | |
| alert('VR functionality would be implemented here with WebXR'); | |
| }); | |
| }; | |
| initThreeJS(); | |
| // Intersection Observer for scroll animations | |
| const observer = new IntersectionObserver((entries) => { | |
| entries.forEach(entry => { | |
| if (entry.isIntersecting) { | |
| entry.target.classList.add('animate-fadeIn'); | |
| } | |
| }); | |
| }, { threshold: 0.1 }); | |
| document.querySelectorAll('.animate-on-scroll').forEach(el => { | |
| observer.observe(el); | |
| }); | |
| }); | |
| // Web Components could be added here or in separate files |