}, // Error callback function (error) { console.error('An error occurred while loading the model:', error); loadingElement.textContent = 'Error loading 3D model'; loadingElement.style.color = 'red'; } ); // Handle window resize window.addEventListener('resize', function() { camera.aspect = window.innerWidth / window.innerHeight; camera.updateProjectionMatrix(); renderer.setSize(window.innerWidth, window.innerHeight); }); // Animation loop function animate() { requestAnimationFrame(animate); // Update controls controls.update(); // Update shader uniforms volumeShaderMaterial.uniforms.uTime.value = performance.now() * 0.001; // Optional: gentle rotation if you want the model to move if (model) { // model.rotation.y += 0.002; // Uncomment this line for auto-rotation } // Render the scene renderer.render(scene, camera); } animate(); }