feat: neural network hero with 3D parallax
- Replace profit cluster with neural network visualization - 4 liquid-glass nodes: กำไร (center), Marketing, AI, Business Knowledge - 3D perspective with CSS preserve-3d - Mouse parallax: scene rotates ±15deg following cursor - Unequal distances: nodes at z: -100, -150, -200 - Floating animations for each outer node - SVG dashed connector lines with pulse animation - Device orientation support for mobile - Responsive: flat column layout on mobile (≤620px) - Smooth easing with requestAnimationFrame
This commit is contained in:
@@ -179,3 +179,55 @@ form?.addEventListener('submit', async (event) => {
|
||||
setStatus('ส่งไม่สำเร็จ กรุณาลองใหม่อีกครั้ง', 'error');
|
||||
}
|
||||
});
|
||||
|
||||
// Neural Network Hero - Mouse Parallax
|
||||
const neuralScene = document.querySelector('.neural-scene');
|
||||
const heroNeural = document.querySelector('.hero-neural');
|
||||
|
||||
if (neuralScene && heroNeural) {
|
||||
let targetRotateX = 0;
|
||||
let targetRotateY = 0;
|
||||
let currentRotateX = 0;
|
||||
let currentRotateY = 0;
|
||||
|
||||
// Mouse move handler
|
||||
heroNeural.addEventListener('mousemove', (e) => {
|
||||
const rect = heroNeural.getBoundingClientRect();
|
||||
const x = (e.clientX - rect.left) / rect.width;
|
||||
const y = (e.clientY - rect.top) / rect.height;
|
||||
|
||||
// Convert to rotation angles (±15 degrees)
|
||||
targetRotateY = (x - 0.5) * 30; // -15 to +15
|
||||
targetRotateX = (y - 0.5) * -30; // -15 to +15 (inverted)
|
||||
});
|
||||
|
||||
// Reset on mouse leave
|
||||
heroNeural.addEventListener('mouseleave', () => {
|
||||
targetRotateX = 0;
|
||||
targetRotateY = 0;
|
||||
});
|
||||
|
||||
// Smooth animation loop
|
||||
function animate() {
|
||||
// Ease towards target
|
||||
currentRotateX += (targetRotateX - currentRotateX) * 0.08;
|
||||
currentRotateY += (targetRotateY - currentRotateY) * 0.08;
|
||||
|
||||
neuralScene.style.transform =
|
||||
`rotateX(${currentRotateX}deg) rotateY(${currentRotateY}deg)`;
|
||||
|
||||
requestAnimationFrame(animate);
|
||||
}
|
||||
|
||||
animate();
|
||||
|
||||
// Mobile: Device orientation (if available)
|
||||
if (window.DeviceOrientationEvent && 'ontouchstart' in window) {
|
||||
window.addEventListener('deviceorientation', (e) => {
|
||||
if (e.gamma !== null && e.beta !== null) {
|
||||
targetRotateY = e.gamma * 0.3; // -30 to +30 scaled down
|
||||
targetRotateX = (e.beta - 45) * 0.3; // Assume holding at 45deg
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user