awacke1 commited on
Commit
c026d73
1 Parent(s): a1db9ef

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +34 -2
index.html CHANGED
@@ -49,7 +49,6 @@
49
  this.resetPosition();
50
  setTimeout(resetAndStartAgain, Math.random() * this.data.meltTime + 15000);
51
  };
52
-
53
  setTimeout(resetAndStartAgain, Math.random() * this.data.meltTime + 15000);
54
  },
55
  resetPosition: function() {
@@ -58,7 +57,6 @@
58
  5 + Math.random() * 5,
59
  Math.random() * 20 - 10
60
  );
61
-
62
  this.velocity = new THREE.Vector3(
63
  (Math.random() - 0.5) * 0.01, // Random wind effect
64
  -0.02, // Falling speed
@@ -74,6 +72,40 @@
74
  }
75
  });
76
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
77
  function createSnowflakeCloud(x, y, z, numParticles) {
78
  let cloud = document.createElement('a-entity');
79
  cloud.object3D.position.set(x, y, z);
 
49
  this.resetPosition();
50
  setTimeout(resetAndStartAgain, Math.random() * this.data.meltTime + 15000);
51
  };
 
52
  setTimeout(resetAndStartAgain, Math.random() * this.data.meltTime + 15000);
53
  },
54
  resetPosition: function() {
 
57
  5 + Math.random() * 5,
58
  Math.random() * 20 - 10
59
  );
 
60
  this.velocity = new THREE.Vector3(
61
  (Math.random() - 0.5) * 0.01, // Random wind effect
62
  -0.02, // Falling speed
 
72
  }
73
  });
74
 
75
+ AFRAME.registerComponent('custom-controls', {
76
+ init: function () {
77
+ this.velocityY = 0;
78
+ this.isMovingUp = false;
79
+ window.addEventListener('keydown', (e) => {
80
+ if (e.key === 'q' || e.key === 'Q') {
81
+ this.isMovingUp = true;
82
+ }
83
+ if (e.key === 'e' || e.key === 'E') {
84
+ this.velocityY = 0; // Stop upward movement
85
+ }
86
+ });
87
+ window.addEventListener('keyup', (e) => {
88
+ if (e.key === 'q' || e.key === 'Q') {
89
+ this.isMovingUp = false;
90
+ }
91
+ });
92
+ },
93
+ tick: function () {
94
+ let position = this.el.getAttribute('position');
95
+ if (this.isMovingUp) {
96
+ this.velocityY = 0.05; // Upward velocity
97
+ } else {
98
+ this.velocityY -= 0.01; // Gravity
99
+ }
100
+ position.y += this.velocityY;
101
+ if (position.y < 1.6) { // Ground level
102
+ position.y = 1.6;
103
+ this.velocityY = 0;
104
+ }
105
+ this.el.setAttribute('position', position);
106
+ }
107
+ });
108
+
109
  function createSnowflakeCloud(x, y, z, numParticles) {
110
  let cloud = document.createElement('a-entity');
111
  cloud.object3D.position.set(x, y, z);