awacke1 commited on
Commit
9346d4c
·
1 Parent(s): eafcff0

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +32 -10
index.html CHANGED
@@ -22,21 +22,43 @@
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
  };
@@ -45,7 +67,7 @@
45
  animate();
46
 
47
  // Adjust camera position
48
- camera.position.z = 5;
49
  </script>
50
  </body>
51
  </html>
 
22
  renderer.setSize(window.innerWidth, window.innerHeight);
23
  document.body.appendChild(renderer.domElement);
24
 
25
+ // Add lighting to the scene
26
+ const ambientLight = new THREE.AmbientLight(0xffffff, 0.5);
27
+ scene.add(ambientLight);
28
+ const pointLight = new THREE.PointLight(0xffffff, 1);
29
+ pointLight.position.set(5, 5, 5);
30
+ scene.add(pointLight);
31
 
32
+ // Create a complex shaded shape geometry and material
33
+ const geometry = new THREE.TorusKnotGeometry(1, 0.4, 256, 32, 2, 3, 1);
34
+ const material = new THREE.MeshPhongMaterial({
35
+ color: 0xffaaff,
36
+ specular: 0x999999,
37
+ shininess: 50,
38
+ flatShading: false,
39
+ });
40
+
41
+ // Create a shape mesh and add it to the scene
42
+ const shape = new THREE.Mesh(geometry, material);
43
+ scene.add(shape);
44
 
45
  // Set up animation loop
46
  const animate = function () {
47
  requestAnimationFrame(animate);
48
 
49
+ // Rotate the shape
50
+ shape.rotation.x += 0.01;
51
+ shape.rotation.y += 0.01;
52
+
53
+ // Move the camera in a circle around the shape
54
+ const time = Date.now() * 0.001;
55
+ const radius = 10;
56
+ camera.position.x = Math.sin(time) * radius;
57
+ camera.position.z = Math.cos(time) * radius;
58
+ camera.lookAt(new THREE.Vector3());
59
+
60
+ // Update the lighting position to follow the camera
61
+ pointLight.position.copy(camera.position);
62
 
63
  renderer.render(scene, camera);
64
  };
 
67
  animate();
68
 
69
  // Adjust camera position
70
+ camera.position.z = 10;
71
  </script>
72
  </body>
73
  </html>