awacke1 commited on
Commit
770c9ed
1 Parent(s): c11beb7

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +17 -7
index.html CHANGED
@@ -29,7 +29,8 @@
29
  <script>
30
  AFRAME.registerComponent('snowflake', {
31
  schema: {
32
- size: { type: 'number', default: 0.1 }
 
33
  },
34
  init: function() {
35
  let size = this.data.size;
@@ -40,17 +41,25 @@
40
  });
41
  this.el.setAttribute('material', { color: '#FFF' });
42
 
43
- this.el.object3D.position.set(
44
- Math.random() - 0.5,
45
- 0,
46
- Math.random() - 0.5
47
- );
48
 
49
  this.velocity = new THREE.Vector3(
50
  (Math.random() - 0.5) * 0.01, // Random wind effect
51
  -0.01, // Falling speed
52
  (Math.random() - 0.5) * 0.01 // Random wind effect
53
  );
 
 
 
 
 
 
 
 
 
 
 
 
54
  },
55
  tick: function() {
56
  this.el.object3D.position.add(this.velocity);
@@ -67,9 +76,10 @@
67
 
68
  for (let i = 0; i < numParticles; i++) {
69
  let size = Math.random() * 0.1 + 0.05; // Random size between 0.05 and 0.15
 
70
  setTimeout(() => {
71
  let snowflakeEl = document.createElement('a-entity');
72
- snowflakeEl.setAttribute('snowflake', 'size', size);
73
  cloud.appendChild(snowflakeEl);
74
  }, i * 100);
75
  }
 
29
  <script>
30
  AFRAME.registerComponent('snowflake', {
31
  schema: {
32
+ size: { type: 'number', default: 0.1 },
33
+ meltTime: { type: 'number', default: 10000 }
34
  },
35
  init: function() {
36
  let size = this.data.size;
 
41
  });
42
  this.el.setAttribute('material', { color: '#FFF' });
43
 
44
+ this.resetPosition();
 
 
 
 
45
 
46
  this.velocity = new THREE.Vector3(
47
  (Math.random() - 0.5) * 0.01, // Random wind effect
48
  -0.01, // Falling speed
49
  (Math.random() - 0.5) * 0.01 // Random wind effect
50
  );
51
+
52
+ // Set timer for melting or landing
53
+ setTimeout(() => {
54
+ this.resetPosition();
55
+ }, Math.random() * this.data.meltTime);
56
+ },
57
+ resetPosition: function() {
58
+ this.el.object3D.position.set(
59
+ Math.random() * 20 - 10,
60
+ 5 + Math.random() * 5,
61
+ Math.random() * 20 - 10
62
+ );
63
  },
64
  tick: function() {
65
  this.el.object3D.position.add(this.velocity);
 
76
 
77
  for (let i = 0; i < numParticles; i++) {
78
  let size = Math.random() * 0.1 + 0.05; // Random size between 0.05 and 0.15
79
+ let meltTime = Math.random() * 20000 + 5000; // Random time between 5 and 25 seconds
80
  setTimeout(() => {
81
  let snowflakeEl = document.createElement('a-entity');
82
+ snowflakeEl.setAttribute('snowflake', {size: size, meltTime: meltTime});
83
  cloud.appendChild(snowflakeEl);
84
  }, i * 100);
85
  }