| 495 | |
| 496 | // Animation loop |
| 497 | const animate = () => { |
| 498 | requestAnimationFrame(animate); |
| 499 | material.uniforms.u_time.value += 0.01; // Update time for animation |
| 500 | material.uniforms.u_viewVector.value = camera.position; |
| 501 | sphere.rotation.y += 0.002; // Slow down rotation for better visibility |
| 502 | |
| 503 | // Update mouse position in the shader |
| 504 | raycaster.setFromCamera(mouse, camera); |
| 505 | const intersects = raycaster.intersectObject(sphere); |
| 506 | if (intersects.length > 0) { |
| 507 | material.uniforms.u_mouse.value = intersects[0].point; |
| 508 | } |
| 509 | |
| 510 | renderer.render(scene, camera); |
| 511 | }; |
| 512 | |
| 513 | animate(); |
| 514 | |