diff --git a/assets/js/main.js b/assets/js/main.js index ecf744f..a75a685 100644 --- a/assets/js/main.js +++ b/assets/js/main.js @@ -9,57 +9,77 @@ document.querySelectorAll('a[href^="#"]').forEach(anchor => { }); }); -// Three.js 3D Visual -document.addEventListener('DOMContentLoaded', () => { - const container = document.getElementById('3d-canvas-container'); - if (container) { - let scene, camera, renderer, cube; +// 3D Logo +function init3DLogo() { + const canvas = document.getElementById('3d-logo-canvas'); + if (canvas && typeof THREE !== 'undefined') { + let scene, camera, renderer, plane; function init() { // Scene scene = new THREE.Scene(); // Camera - camera = new THREE.PerspectiveCamera(75, container.clientWidth / container.clientHeight, 0.1, 1000); + camera = new THREE.PerspectiveCamera(75, canvas.clientWidth / canvas.clientHeight, 0.1, 1000); camera.position.z = 5; // Renderer - renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true }); - renderer.setSize(container.clientWidth, container.clientHeight); - container.appendChild(renderer.domElement); + renderer = new THREE.WebGLRenderer({ antialias: true, alpha: true, canvas: canvas }); + renderer.setSize(canvas.clientWidth, canvas.clientHeight); - // Cube - const geometry = new THREE.BoxGeometry(2, 2, 2); - const material = new THREE.MeshStandardMaterial({ color: 0x8B5CF6, roughness: 0.5, metalness: 0.5 }); - cube = new THREE.Mesh(geometry, material); - scene.add(cube); + // Texture + const textureLoader = new THREE.TextureLoader(); + textureLoader.load('assets/pasted-20251022-215019-f7191fbf.png', function(texture) { + // Plane + const geometry = new THREE.PlaneGeometry(5, 1.5); + const material = new THREE.MeshStandardMaterial({ map: texture, transparent: true, roughness: 0.4, metalness: 0.2 }); + plane = new THREE.Mesh(geometry, material); + scene.add(plane); + }); // Lights - const ambientLight = new THREE.AmbientLight(0xffffff, 0.5); + const ambientLight = new THREE.AmbientLight(0xffffff, 0.7); scene.add(ambientLight); const pointLight = new THREE.PointLight(0xffffff, 0.8); - pointLight.position.set(5, 5, 5); + pointLight.position.set(0, 0, 5); scene.add(pointLight); // Animation animate(); } + let mouseX = 0, mouseY = 0; + let targetX = 0, targetY = 0; + const windowHalfX = window.innerWidth / 2; + const windowHalfY = window.innerHeight / 2; + + function onDocumentMouseMove(event) { + mouseX = (event.clientX - windowHalfX) / 2; + mouseY = (event.clientY - windowHalfY) / 2; + } + document.addEventListener('mousemove', onDocumentMouseMove); + + function animate() { requestAnimationFrame(animate); + + targetX = mouseX * .001; + targetY = mouseY * .001; - cube.rotation.x += 0.005; - cube.rotation.y += 0.005; + if (plane) { + plane.rotation.y += .05 * (targetX - plane.rotation.y); + plane.rotation.x += .05 * (targetY - plane.rotation.x); + } renderer.render(scene, camera); } function onWindowResize() { - if (container.clientWidth > 0 && container.clientHeight > 0) { - camera.aspect = container.clientWidth / container.clientHeight; + if (canvas.clientWidth > 0 && canvas.clientHeight > 0) { + camera.aspect = canvas.clientWidth / canvas.clientHeight; camera.updateProjectionMatrix(); - renderer.setSize(container.clientWidth, container.clientHeight); + renderer.setSize(canvas.clientWidth, canvas.clientHeight); } } @@ -67,4 +87,6 @@ document.addEventListener('DOMContentLoaded', () => { init(); } -}); \ No newline at end of file +} + +window.addEventListener('load', init3DLogo); \ No newline at end of file diff --git a/index.php b/index.php index b36bc05..6fc3c4c 100644 --- a/index.php +++ b/index.php @@ -26,7 +26,7 @@