-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patherror.js
104 lines (86 loc) · 2.85 KB
/
error.js
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
const scene = new THREE.Scene();
const camera = new THREE.PerspectiveCamera(
75,
window.innerWidth / window.innerHeight,
0.1,
1000
);
const renderer = new THREE.WebGLRenderer();
renderer.setSize(window.innerWidth, window.innerHeight);
document.getElementById("errorScene").appendChild(renderer.domElement);
const starGeometry = new THREE.BufferGeometry();
const starMaterial = new THREE.PointsMaterial({ color: 0xffffff });
const starVertices = [];
for (let i = 0; i < 10000; i++) {
const x = THREE.MathUtils.randFloatSpread(2000);
const y = THREE.MathUtils.randFloatSpread(2000);
const z = THREE.MathUtils.randFloatSpread(2000);
starVertices.push(x, y, z);
}
starGeometry.setAttribute(
"position",
new THREE.Float32BufferAttribute(starVertices, 3)
);
const stars = new THREE.Points(starGeometry, starMaterial);
scene.add(stars);
camera.position.z = 100;
function generateBinaryCode() {
const binaryCode = document.createElement("div");
binaryCode.textContent = Math.random() < 0.5 ? "0" : "1";
binaryCode.className = "binaryCode";
binaryCode.style.left = `${Math.random() * 100}%`;
binaryCode.style.top = `${Math.random() * 100}%`;
binaryCode.style.color = Math.random() < 0.5 ? "purple" : "cyan";
binaryCode.style.fontSize = `${Math.random() * 20 + 10}px`;
binaryCode.style.position = "fixed";
binaryCode.style.zIndex = "999";
document.body.appendChild(binaryCode);
setTimeout(() => {
document.body.removeChild(binaryCode);
}, Math.random() * 500 + 500);
}
setInterval(generateBinaryCode, 700);
function createShootingStar() {
const geometry = new THREE.BoxGeometry(0.1, 0.1, 5);
const material = new THREE.MeshBasicMaterial({ color: 0xffffff });
const star = new THREE.Mesh(geometry, material);
star.position.set(
THREE.MathUtils.randFloatSpread(2000),
THREE.MathUtils.randFloatSpread(2000),
THREE.MathUtils.randFloatSpread(2000)
);
star.velocity = new THREE.Vector3(
-1 - Math.random() * 2,
-1 - Math.random(),
0
);
scene.add(star);
return star;
}
const shootingStars = [];
for (let i = 0; i < 20; i++) {
shootingStars.push(createShootingStar());
}
function animate() {
requestAnimationFrame(animate);
shootingStars.forEach((star) => {
star.position.add(star.velocity);
if (star.position.x < -1000 || star.position.y < -1000) {
star.position.set(
THREE.MathUtils.randFloatSpread(2000),
THREE.MathUtils.randFloatSpread(2000),
THREE.MathUtils.randFloatSpread(2000)
);
star.velocity.set(-1 - Math.random() * 2, -1 - Math.random(), 0);
}
});
stars.rotation.x += 0.0005;
stars.rotation.y += 0.0005;
renderer.render(scene, camera);
}
animate();
window.addEventListener("resize", () => {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
});