awacke1 commited on
Commit
579e500
1 Parent(s): 070f7ee

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +32 -16
index.html CHANGED
@@ -19,8 +19,8 @@
19
  <!-- Existing Recursive Polygon Component -->
20
  <!-- ... Your existing entities ... -->
21
 
22
- <!-- Snowflakes Component -->
23
- <a-entity id="snowflakes"></a-entity>
24
 
25
  <a-entity camera position="0 1.6 0" look-controls wasd-controls></a-entity>
26
  </a-scene>
@@ -34,11 +34,11 @@
34
  });
35
  this.el.setAttribute('material', { color: '#FFF' });
36
 
37
- // Set initial position
38
  this.el.object3D.position.set(
39
- (Math.random() - 0.5) * 20,
40
- 5 + Math.random() * 5,
41
- (Math.random() - 0.5) * 20
42
  );
43
 
44
  // Set velocity
@@ -46,19 +46,35 @@
46
  },
47
  tick: function() {
48
  this.el.object3D.position.add(this.velocity);
49
- if (this.el.object3D.position.y <= 0) {
50
- this.el.parentNode.removeChild(this.el); // Remove snowflake when it hits the ground
51
  }
52
  }
53
  });
54
 
55
- // Generate snowflakes
56
- setInterval(() => {
57
- let sceneEl = document.querySelector('a-scene');
58
- let snowflakeEl = document.createElement('a-entity');
59
- snowflakeEl.setAttribute('snowflake', '');
60
- sceneEl.appendChild(snowflakeEl);
61
- }, 100);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
62
  </script>
63
  </body>
64
- </html>
 
19
  <!-- Existing Recursive Polygon Component -->
20
  <!-- ... Your existing entities ... -->
21
 
22
+ <!-- Snowflakes Components -->
23
+ <!-- Clouds will be added dynamically -->
24
 
25
  <a-entity camera position="0 1.6 0" look-controls wasd-controls></a-entity>
26
  </a-scene>
 
34
  });
35
  this.el.setAttribute('material', { color: '#FFF' });
36
 
37
+ // Randomly position within a unit cube centered at the origin
38
  this.el.object3D.position.set(
39
+ Math.random() - 0.5,
40
+ Math.random() - 0.5,
41
+ Math.random() - 0.5
42
  );
43
 
44
  // Set velocity
 
46
  },
47
  tick: function() {
48
  this.el.object3D.position.add(this.velocity);
49
+ if (this.el.object3D.position.y <= -0.5) {
50
+ this.el.parentNode.removeChild(this.el); // Remove snowflake when it falls out of the cloud
51
  }
52
  }
53
  });
54
 
55
+ function createSnowflakeCloud(x, y, z) {
56
+ let cloud = document.createElement('a-entity');
57
+ cloud.object3D.position.set(x, y, z);
58
+
59
+ setInterval(() => {
60
+ let snowflakeEl = document.createElement('a-entity');
61
+ snowflakeEl.setAttribute('snowflake', '');
62
+ cloud.appendChild(snowflakeEl);
63
+ }, 100);
64
+
65
+ document.querySelector('a-scene').appendChild(cloud);
66
+ }
67
+
68
+ // Create a grid of 9 snowflake clouds
69
+ for (let x = -10; x <= 10; x += 10) {
70
+ for (let z = -10; z <= 10; z += 10) {
71
+ createSnowflakeCloud(x, 5, z);
72
+ }
73
+ }
74
+
75
+ // Create a larger central cloud
76
+ createSnowflakeCloud(0, 8, 0);
77
+
78
  </script>
79
  </body>
80
+ </html>