Bladeren bron

Basketball game: more adjustments

customisations
alemart 8 maanden geleden
bovenliggende
commit
56a18c9b2e
1 gewijzigde bestanden met toevoegingen van 7 en 6 verwijderingen
  1. 7
    6
      demos/basketball/src/entities/ball.js

+ 7
- 6
demos/basketball/src/entities/ball.js Bestand weergeven

34
 /** Maximum distance from the camera to the ball, so that the ball is considered "lost" in the thrown state */
34
 /** Maximum distance from the camera to the ball, so that the ball is considered "lost" in the thrown state */
35
 const MAX_DISTANCE = 15;
35
 const MAX_DISTANCE = 15;
36
 
36
 
37
-/** Maximum distance in the y-axis from the camera to the ball, so that the ball is considered "lost" in the thrown state */
37
+/** Maximum distance in the y-axis from ar.root to the ball, so that the ball is considered "lost" in the thrown state */
38
 const MAX_Y_DISTANCE = 5;
38
 const MAX_Y_DISTANCE = 5;
39
 
39
 
40
 /** Frequency of the shining effect, in Hz */
40
 /** Frequency of the shining effect, in Hz */
412
             return 0;
412
             return 0;
413
         }
413
         }
414
 
414
 
415
-        const time = this.ar.session.time;
416
-        const dt = time.delta;
415
+        const ar = this.ar;
416
+        const dt = ar.session.time.delta;
417
         const rate = 1.0 / SHINE_FADE_DURATION;
417
         const rate = 1.0 / SHINE_FADE_DURATION;
418
         const distance = this._calculateDistanceToHoop(this._mesh.absolutePosition);
418
         const distance = this._calculateDistanceToHoop(this._mesh.absolutePosition);
419
 
419
 
420
+        // shine if long distance
420
         if(distance >= THREE_POINT_THRESHOLD) {
421
         if(distance >= THREE_POINT_THRESHOLD) {
421
             this._shineFactor = 1;
422
             this._shineFactor = 1;
422
             this._shineTimer += dt;
423
             this._shineTimer += dt;
423
         }
424
         }
424
         else {
425
         else {
425
-            this._shineFactor = Math.max(0, this._shineFactor - rate * dt);
426
-            if(this._shineFactor == 0)
427
-                this._shineTimer = 0;
426
+            this._shineFactor -= rate * dt;
427
+            if(this._shineFactor <= 0)
428
+                this._shineFactor = this._shineTimer = 0;
428
         }
429
         }
429
 
430
 
430
         const t = this._shineTimer;
431
         const t = this._shineTimer;

Laden…
Annuleren
Opslaan