Spaces:
Running
Running
Update index.html
Browse files- index.html +48 -16
index.html
CHANGED
@@ -1,19 +1,51 @@
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
-
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
</html>
|
|
|
1 |
<!DOCTYPE html>
|
2 |
<html>
|
3 |
+
<head>
|
4 |
+
<title>Three.js Scene and Animation Example</title>
|
5 |
+
<style>
|
6 |
+
body {
|
7 |
+
margin: 0;
|
8 |
+
padding: 0;
|
9 |
+
}
|
10 |
+
canvas {
|
11 |
+
display: block;
|
12 |
+
}
|
13 |
+
</style>
|
14 |
+
</head>
|
15 |
+
<body>
|
16 |
+
<script src="https://threejs.org/build/three.min.js"></script>
|
17 |
+
<script>
|
18 |
+
// Set up the scene, camera, and renderer
|
19 |
+
const scene = new THREE.Scene();
|
20 |
+
const camera = new THREE.PerspectiveCamera(75, window.innerWidth / window.innerHeight, 0.1, 1000);
|
21 |
+
const renderer = new THREE.WebGLRenderer();
|
22 |
+
renderer.setSize(window.innerWidth, window.innerHeight);
|
23 |
+
document.body.appendChild(renderer.domElement);
|
24 |
+
|
25 |
+
// Create a cube geometry and material
|
26 |
+
const geometry = new THREE.BoxGeometry();
|
27 |
+
const material = new THREE.MeshBasicMaterial({ color: 0xffffff });
|
28 |
+
|
29 |
+
// Create a cube mesh and add it to the scene
|
30 |
+
const cube = new THREE.Mesh(geometry, material);
|
31 |
+
scene.add(cube);
|
32 |
+
|
33 |
+
// Set up animation loop
|
34 |
+
const animate = function () {
|
35 |
+
requestAnimationFrame(animate);
|
36 |
+
|
37 |
+
// Rotate the cube
|
38 |
+
cube.rotation.x += 0.01;
|
39 |
+
cube.rotation.y += 0.01;
|
40 |
+
|
41 |
+
renderer.render(scene, camera);
|
42 |
+
};
|
43 |
+
|
44 |
+
// Start the animation loop
|
45 |
+
animate();
|
46 |
+
|
47 |
+
// Adjust camera position
|
48 |
+
camera.position.z = 5;
|
49 |
+
</script>
|
50 |
+
</body>
|
51 |
</html>
|