awacke1 commited on
Commit
bc9487e
·
1 Parent(s): 3aa6634

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +14 -8
index.html CHANGED
@@ -8,11 +8,11 @@
8
  <!-- Camera -->
9
  <a-entity camera look-controls position="0 2 6"></a-entity>
10
 
11
- <!-- Field -->
12
- <a-box color="green" position="0 -0.5 -10" width="16" height="0.5" depth="26"></a-box>
13
 
14
  <!-- Ball -->
15
- <a-sphere id="ball" color="white" radius="0.2" position="0 0.2 0"></a-sphere>
16
 
17
  <!-- Particle Systems -->
18
  <!-- Team 1 -->
@@ -29,6 +29,9 @@
29
 
30
  <!-- Script to move the ball -->
31
  <script>
 
 
 
32
  // Get the ball entity
33
  var ball = document.querySelector("#ball");
34
 
@@ -36,9 +39,9 @@
36
  var ballVelocity = new THREE.Vector3(0, 0, 0);
37
 
38
  // Set the ball's mass
39
- var ballMass = 1;
40
 
41
- // Set the ball's friction coefficient
42
  var ballFriction = 0.01;
43
 
44
  // Set the ball's restitution coefficient
@@ -48,7 +51,7 @@
48
  var ballInterval = 20; // milliseconds
49
 
50
  // Set the ball's initial position
51
- var ballPosition = new THREE.Vector3(0, 0.2, 0);
52
 
53
  // Set the ball's size
54
  var ballSize = 0.2;
@@ -64,7 +67,7 @@
64
  var ballMaxVelocity = 10;
65
 
66
  // Set the ball's reset position
67
- var resetPosition = new THREE.Vector3(0, 0.2, 0);
68
 
69
  // Set the ball's collision radius
70
  var ballRadius = 0.4;
@@ -114,6 +117,9 @@
114
  // Apply the ball's velocity to its position
115
  ballPosition.add(ballVelocity);
116
 
 
 
 
117
  // Apply the ball's position to the ball entity
118
  ball.setAttribute("position", ballPosition);
119
 
@@ -144,6 +150,7 @@
144
 
145
  // Loop through each particle system entity
146
  for (var i = 0; i < particleSystems.length; i++) {
 
147
  // Get the particle system's position
148
  var particleSystemPosition = particleSystems[i].getAttribute("position");
149
 
@@ -197,6 +204,5 @@
197
  detectCollisions();
198
  </script>
199
  </a-scene>
200
-
201
  </body>
202
  </html>
 
8
  <!-- Camera -->
9
  <a-entity camera look-controls position="0 2 6"></a-entity>
10
 
11
+ <!-- Ground -->
12
+ <a-box id="ground" color="green" position="0 -0.5 -10" width="16" height="0.5" depth="26"></a-box>
13
 
14
  <!-- Ball -->
15
+ <a-sphere id="ball" color="white" radius="0.2" position="0 2 0"></a-sphere>
16
 
17
  <!-- Particle Systems -->
18
  <!-- Team 1 -->
 
29
 
30
  <!-- Script to move the ball -->
31
  <script>
32
+ // Get the ground object
33
+ var ground = document.querySelector("#ground");
34
+
35
  // Get the ball entity
36
  var ball = document.querySelector("#ball");
37
 
 
39
  var ballVelocity = new THREE.Vector3(0, 0, 0);
40
 
41
  // Set the ball's mass
42
+ var ballMass = 1;
43
 
44
+ // Set the ball's friction coefficient
45
  var ballFriction = 0.01;
46
 
47
  // Set the ball's restitution coefficient
 
51
  var ballInterval = 20; // milliseconds
52
 
53
  // Set the ball's initial position
54
+ var ballPosition = new THREE.Vector3(0, 2, 0);
55
 
56
  // Set the ball's size
57
  var ballSize = 0.2;
 
67
  var ballMaxVelocity = 10;
68
 
69
  // Set the ball's reset position
70
+ var resetPosition = new THREE.Vector3(0, 2, 0);
71
 
72
  // Set the ball's collision radius
73
  var ballRadius = 0.4;
 
117
  // Apply the ball's velocity to its position
118
  ballPosition.add(ballVelocity);
119
 
120
+ // Apply the ground object's position to the ball's position
121
+ ballPosition.setY(Math.max(ballPosition.y, ground.object3D.position.y + ballRadius));
122
+
123
  // Apply the ball's position to the ball entity
124
  ball.setAttribute("position", ballPosition);
125
 
 
150
 
151
  // Loop through each particle system entity
152
  for (var i = 0; i < particleSystems.length; i++) {
153
+ // Get the
154
  // Get the particle system's position
155
  var particleSystemPosition = particleSystems[i].getAttribute("position");
156
 
 
204
  detectCollisions();
205
  </script>
206
  </a-scene>
 
207
  </body>
208
  </html>