// Create the scene, camera, and renderer const scene = new THREE.Scene(); const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000); const renderer = new THREE.WebGLRenderer(); renderer.setSize(window.innerWidth, window.innerHeight); document.body.appendChild(renderer.domElement); // Resize the canvas when the window size changes window.addEventListener('resize', function () { const width = window.innerWidth; const height = window.innerHeight; renderer.setSize(width, height); camera.aspect = width / height; camera.updateProjectionMatrix(); }); // Generate a random color const color = new THREE.Color(Math.random() * 0xffffff); // Create the geometry and material for the sphere const sphereGeometry = new THREE.SphereGeometry(2, 90, 90); // Increased sphere size const sphereMaterial = new THREE.MeshLambertMaterial({ color: color, wireframe: true }); // Create the sphere and add it to the scene const sphere = new THREE.Mesh(sphereGeometry, sphereMaterial); scene.add(sphere); // Create the geometry and material for the prisms const prismGeometry = new THREE.BoxGeometry(0.1, 0.1, 0.1); const prismMaterial = new THREE.MeshBasicMaterial({color: 0xffffff, wireframe: true}); // Create a grid of prisms const prismGridSize = 9; for (let x = -prismGridSize; x <= prismGridSize; x += 0.88) { for (let y = -prismGridSize; y <= prismGridSize; y += 0.88) { for (let z = -prismGridSize; z <= prismGridSize; z += 0.43) { const prism = new THREE.Mesh(prismGeometry, prismMaterial); prism.position.set(x, y, z); scene.add(prism); } } } // Set the camera's position camera.position.z = 5; // The animation loop function animate() { requestAnimationFrame(animate); // Rotate the sphere sphere.rotation.x += 0.0025; sphere.rotation.y += 0.0025; // Render the scene renderer.render(scene, camera); } // Add ambient light var ambientLight = new THREE.AmbientLight(0xcccccc, 1.4); scene.add(ambientLight); // Add point light var pointLight = new THREE.PointLight(0xffffff, 0.9); camera.add(pointLight); scene.add(camera); animate();