Repository navigation
Expand file tree
/
Copy pathmain.html
More file actions
98 lines (84 loc) · 3.15 KB
/
Copy pathmain.html
File metadata and controls
98 lines (84 loc) · 3.15 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
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>3D Анимация</title>
<link rel="stylesheet" type="text/css" href="Other_Pages/styles_common.css">
<style>
body, html {
height: 100%;
margin: 0;
overflow: hidden;
font-family: Arial, Helvetica, sans-serif;
}
#background {
position: absolute;
width: 100%;
height: 100%;
overflow: hidden;
}
.content {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: white;
text-align: center;
z-index: 10;
}
</style>
<script src="https://cdnjs.cloudflare.com/ajax/libs/three.js/r128/three.min.js"></script>
</head>
<body>
<div id="background"></div>
<div>
<span class="next_page">
<a href="Other_Pages/animatedCircles.html" style="color: yellow">Следующая страница</a>
</span>
</div>
<div class="content">
<h1>Добро пожаловать в 3D Мир!</h1>
<p>Движение кубика зависит от перемещения курсора мыши</p>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
let scene, camera, renderer, cube, light;
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.MeshPhongMaterial({color: 0x00ff00});
cube = new THREE.Mesh(geometry, material);
scene.add(cube);
light = new THREE.PointLight(0xffffff, 1, 100);
light.position.set(10, 10, 10);
scene.add(light);
camera.position.z = 5;
document.addEventListener('mousemove', onDocumentMouseMove, false);
window.addEventListener('resize', onWindowResize, false);
}
function onWindowResize() {
camera.aspect = window.innerWidth / window.innerHeight;
camera.updateProjectionMatrix();
renderer.setSize(window.innerWidth, window.innerHeight);
}
function onDocumentMouseMove() {
cube.rotation.x = event.clientY * 0.005;
cube.rotation.y = event.clientX * 0.005;
}
function animate() {
requestAnimationFrame(animate);
cube.rotation.x += 0.01;
cube.rotation.y += 0.01;
renderer.render(scene, camera);
}
init();
animate();
})
</script>
</body>
</html>