Skip to content

Commit

Permalink
Update scripts.js
Browse files Browse the repository at this point in the history
  • Loading branch information
Techiral authored Jul 4, 2024
1 parent f1d928b commit 6706812
Showing 1 changed file with 52 additions and 6 deletions.
58 changes: 52 additions & 6 deletions scripts.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,54 @@
document.addEventListener('DOMContentLoaded', () => {
const ctaButton = document.querySelector('.cta-button');
// Cursor tracker
document.addEventListener('mousemove', (e) => {
const cursor = document.querySelector('.cursor');
const cursor2 = document.querySelector('.cursor2');
cursor.style.left = `${e.pageX}px`;
cursor.style.top = `${e.pageY}px`;
cursor2.style.left = `${e.pageX}px`;
cursor2.style.top = `${e.pageY}px`;
});

document.addEventListener('mousedown', () => {
const cursor = document.querySelector('.cursor');
const cursor2 = document.querySelector('.cursor2');
cursor.style.transform = 'scale(0.8)';
cursor2.style.transform = 'scale(1.2)';
});

ctaButton.addEventListener('mouseover', () => {
const audio = new Audio('hover-sound.mp3');
audio.play();
});
document.addEventListener('mouseup', () => {
const cursor = document.querySelector('.cursor');
const cursor2 = document.querySelector('.cursor2');
cursor.style.transform = 'scale(1)';
cursor2.style.transform = 'scale(1)';
});

// Three.js Scene
let scene, camera, renderer, cube;

function init() {
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.body.appendChild(renderer.domElement);

const geometry = new THREE.BoxGeometry();
const material = new THREE.MeshBasicMaterial({ color: 0x00e5ff });
cube = new THREE.Mesh(geometry, material);
scene.add(cube);

camera.position.z = 5;

animate();
}

function animate() {
requestAnimationFrame(animate);

cube.rotation.x += 0.01;
cube.rotation.y += 0.01;

renderer.render(scene, camera);
}

init();

0 comments on commit 6706812

Please sign in to comment.