-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.js
More file actions
54 lines (48 loc) · 1.57 KB
/
script.js
File metadata and controls
54 lines (48 loc) · 1.57 KB
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
// THREE.JS 3D BACKGROUND
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(70, window.innerWidth/window.innerHeight, 0.1, 1000);
camera.position.z = 4;
const renderer = new THREE.WebGLRenderer({
canvas: document.getElementById('webgl'),
alpha: true
});
renderer.setSize(window.innerWidth, window.innerHeight);
renderer.setPixelRatio(window.devicePixelRatio);
// Sphere or Placeholder Logo
const geometry = new THREE.IcosahedronGeometry(1.5, 1);
const material = new THREE.MeshStandardMaterial({
color: 0x00ffd1,
metalness: 0.6,
roughness: 0.3
});
const mesh = new THREE.Mesh(geometry, material);
scene.add(mesh);
// Lights
const ambient = new THREE.AmbientLight(0xffffff, 0.6);
const point = new THREE.PointLight(0x00ffd1, 1);
point.position.set(5, 5, 5);
scene.add(ambient, point);
// Animation
function animate() {
requestAnimationFrame(animate);
mesh.rotation.y += 0.005;
mesh.rotation.x += 0.002;
renderer.render(scene, camera);
}
animate();
// Responsive
window.addEventListener('resize', () => {
camera.aspect = window.innerWidth/window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});
// WALLET CONNECT (SIMULATED)
document.getElementById('connectBtn').addEventListener('click', () => {
if (typeof window.ethereum !== 'undefined') {
window.ethereum.request({ method: 'eth_requestAccounts' })
.then(accounts => alert("Connected: " + accounts[0]))
.catch(() => alert("Connection rejected."));
} else {
alert("Please install MetaMask to connect your wallet.");
}
});