File size: 3,623 Bytes
51dd040
 
d73c5f1
51dd040
 
d73c5f1
 
 
 
 
 
 
 
 
 
 
 
 
51dd040
 
d73c5f1
 
 
 
 
 
 
51dd040
 
d73c5f1
 
 
 
51dd040
d73c5f1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
51dd040
 
d73c5f1
 
 
 
 
 
 
 
51dd040
 
d73c5f1
 
 
 
 
 
 
51dd040
 
 
 
d73c5f1
 
 
 
51dd040
 
d73c5f1
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96

// Funzioni condivise tra le pagine
document.addEventListener('DOMContentLoaded', function() {
// Inizializza i tooltip
const tooltips = document.querySelectorAll('[data-tooltip]');
    tooltips.forEach(tooltip => {
        tooltip.addEventListener('mouseenter', function() {
            const tooltipText = this.getAttribute('data-tooltip');
            const tooltipElement = document.createElement('div');
            tooltipElement.className = 'absolute z-50 bg-black text-white text-sm px-3 py-1 rounded-md';
            tooltipElement.textContent = tooltipText;
            this.appendChild(tooltipElement);
            
            this.addEventListener('mouseleave', function() {
                tooltipElement.remove();
            });
        });
    });
// Scorrimento fluido per i link interni
document.querySelectorAll('a[href^="#"]').forEach(anchor => {
        anchor.addEventListener('click', function(e) {
            e.preventDefault();
            document.querySelector(this.getAttribute('href')).scrollIntoView({
                behavior: 'smooth'
            });
        });
    });
// Toggle menu mobile (usato dal componente navbar)
window.toggleMobileMenu = function() {
        const menu = document.getElementById('mobile-menu');
        menu.classList.toggle('hidden');
    };
});
// Funzione per caricare modelli 3D (usata in più pagine)
function load3DModel(containerId, modelConfig) {
    const container = document.getElementById(containerId);
    if (!container) return;

    // Basic Three.js setup
    const scene = new THREE.Scene();
    const camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000);
    const renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true });
    renderer.setSize(container.clientWidth, container.clientHeight);
    container.innerHTML = '';
    container.appendChild(renderer.domElement);

    // Add lights
    const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
    scene.add(ambientLight);
    const directionalLight = new THREE.DirectionalLight(0xffffff, 0.8);
    directionalLight.position.set(1, 1, 1);
    scene.add(directionalLight);

    // Controls
    const controls = new THREE.OrbitControls(camera, renderer.domElement);
    controls.enableDamping = true;
    controls.dampingFactor = 0.05;

    // Add model based on config
    if (modelConfig.type === 'muscle') {
// Modello muscolare semplificato
const geometry = new THREE.SphereGeometry(1, 32, 32);
        const material = new THREE.MeshPhongMaterial({ 
            color: 0xff6b6b,
            transparent: true,
            opacity: 0.8
        });
        const sphere = new THREE.Mesh(geometry, material);
        scene.add(sphere);
    } else if (modelConfig.type === 'skeleton') {
// Modello scheletrico semplificato
const geometry = new THREE.BoxGeometry(1, 2, 1);
        const material = new THREE.MeshPhongMaterial({ 
            color: 0xf5f5f5,
            wireframe: false
        });
        const bone = new THREE.Mesh(geometry, material);
        scene.add(bone);
    }
// Posiziona la camera
camera.position.z = modelConfig.cameraDistance || 5;
// Ciclo di animazione
function animate() {
        requestAnimationFrame(animate);
        controls.update();
        renderer.render(scene, camera);
    }
// Gestisce il ridimensionamento della finestra
window.addEventListener('resize', function() {
        camera.aspect = container.clientWidth / container.clientHeight;
        camera.updateProjectionMatrix();
        renderer.setSize(container.clientWidth, container.clientHeight);
    });

    animate();
}