Changed around line 1
+ // Initialize Three.js
+ let scene, camera, renderer, brain, isRotating = true;
+
+ function init() {
+ // Create scene
+ scene = new THREE.Scene();
+ scene.background = new THREE.Color(0xffffff);
+
+ // Setup camera
+ camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
+ camera.position.z = 5;
+
+ // Setup renderer
+ renderer = new THREE.WebGLRenderer({ antialias: true });
+ renderer.setSize(document.getElementById('brain-container').offsetWidth,
+ document.getElementById('brain-container').offsetHeight);
+ document.getElementById('brain-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);
+
+ // Create brain geometry (simplified for example)
+ const geometry = new THREE.SphereGeometry(2, 32, 32);
+ const material = new THREE.MeshPhongMaterial({
+ color: 0xff69b4,
+ shininess: 100,
+ transparent: true,
+ opacity: 0.9
+ });
+
+ brain = new THREE.Mesh(geometry, material);
+ scene.add(brain);
+
+ // Add controls
+ const controls = new THREE.OrbitControls(camera, renderer.domElement);
+ controls.enableDamping = true;
+ controls.dampingFactor = 0.05;
+
+ // Event listeners
+ window.addEventListener('resize', onWindowResize, false);
+ document.getElementById('rotate').addEventListener('click', toggleRotation);
+ document.getElementById('wireframe').addEventListener('click', toggleWireframe);
+ document.getElementById('zoom').addEventListener('input', handleZoom);
+
+ animate();
+ }
+
+ function animate() {
+ requestAnimationFrame(animate);
+
+ if (isRotating) {
+ brain.rotation.y += 0.005;
+ }
+
+ renderer.render(scene, camera);
+ }
+
+ function onWindowResize() {
+ const container = document.getElementById('brain-container');
+ camera.aspect = container.offsetWidth / container.offsetHeight;
+ camera.updateProjectionMatrix();
+ renderer.setSize(container.offsetWidth, container.offsetHeight);
+ }
+
+ function toggleRotation() {
+ isRotating = !isRotating;
+ }
+
+ function toggleWireframe() {
+ brain.material.wireframe = !brain.material.wireframe;
+ }
+
+ function handleZoom(e) {
+ camera.position.z = 10 - (e.target.value - 50) / 20;
+ }
+
+ // Initialize when DOM is loaded
+ document.addEventListener('DOMContentLoaded', init);