|
|
|
|
|
|
|
|
document.addEventListener('DOMContentLoaded', function() { |
|
|
|
|
|
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(); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
document.querySelectorAll('a[href^="#"]').forEach(anchor => { |
|
|
anchor.addEventListener('click', function(e) { |
|
|
e.preventDefault(); |
|
|
document.querySelector(this.getAttribute('href')).scrollIntoView({ |
|
|
behavior: 'smooth' |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|
|
|
window.toggleMobileMenu = function() { |
|
|
const menu = document.getElementById('mobile-menu'); |
|
|
menu.classList.toggle('hidden'); |
|
|
}; |
|
|
}); |
|
|
|
|
|
function load3DModel(containerId, modelConfig) { |
|
|
const container = document.getElementById(containerId); |
|
|
if (!container) return; |
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
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); |
|
|
|
|
|
|
|
|
const controls = new THREE.OrbitControls(camera, renderer.domElement); |
|
|
controls.enableDamping = true; |
|
|
controls.dampingFactor = 0.05; |
|
|
|
|
|
|
|
|
if (modelConfig.type === 'muscle') { |
|
|
|
|
|
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') { |
|
|
|
|
|
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); |
|
|
} |
|
|
|
|
|
camera.position.z = modelConfig.cameraDistance || 5; |
|
|
|
|
|
function animate() { |
|
|
requestAnimationFrame(animate); |
|
|
controls.update(); |
|
|
renderer.render(scene, camera); |
|
|
} |
|
|
|
|
|
window.addEventListener('resize', function() { |
|
|
camera.aspect = container.clientWidth / container.clientHeight; |
|
|
camera.updateProjectionMatrix(); |
|
|
renderer.setSize(container.clientWidth, container.clientHeight); |
|
|
}); |
|
|
|
|
|
animate(); |
|
|
} |