Quellcode durchsuchen

Rename TrackablePointer.elapsedTime to TrackablePointer.duration

customisations
alemart vor 8 Monaten
Ursprung
Commit
03afca3961

+ 1
- 1
demos/pointer-demo/demo.js Datei anzeigen

@@ -81,7 +81,7 @@ function render(pointers, viewport)
81 81
         ctx.fillText('x: ' + pointer.position.x.toFixed(5), position.x, position.y + 2 * TEXT_LINE_HEIGHT);
82 82
         ctx.fillText('y: ' + pointer.position.y.toFixed(5), position.x, position.y + 3 * TEXT_LINE_HEIGHT);
83 83
         ctx.fillText('speed: ' + pointer.velocity.length().toFixed(5), position.x, position.y + 4 * TEXT_LINE_HEIGHT);
84
-        ctx.fillText('time: ' + pointer.elapsedTime.toFixed(5), position.x, position.y + 5 * TEXT_LINE_HEIGHT);
84
+        ctx.fillText('time: ' + pointer.duration.toFixed(5), position.x, position.y + 5 * TEXT_LINE_HEIGHT);
85 85
     }
86 86
 }
87 87
 

+ 3
- 3
docs/api/trackable-pointer.md Datei anzeigen

@@ -52,9 +52,9 @@ The difference between the position of the pointer in this and in the previous f
52 52
 
53 53
 The current velocity of the pointer, given in space units per second. You can get the current speed of motion by calculating the [magnitude](vector2.md#length) of this vector.
54 54
 
55
-### elapsedTime
55
+### duration
56 56
 
57
-`pointer.elapsedTime: number, read-only`
57
+`pointer.duration: number, read-only`
58 58
 
59 59
 The elapsed time, in seconds, since the tracking of this pointer began.
60 60
 
@@ -62,7 +62,7 @@ The elapsed time, in seconds, since the tracking of this pointer began.
62 62
 
63 63
 `pointer.totalDistance: number, read-only`
64 64
 
65
-How much this pointer has moved, in space units, since its tracking began. You can get the average speed of motion by calculating the ratio `totalDistance / elapsedTime`.
65
+How much this pointer has moved, in space units, since its tracking began. You can get the average speed of motion by calculating the ratio `totalDistance / duration`.
66 66
 
67 67
 ### isPrimary
68 68
 

+ 4
- 4
src/trackers/pointer-tracker/pointer-tracker.ts Datei anzeigen

@@ -378,7 +378,7 @@ export class PointerTracker implements Tracker
378 378
             const velocity = deltaPosition._clone()._scale(inverseDeltaTime);
379 379
 
380 380
             // determine the elapsed time since the tracking began
381
-            const elapsedTime = previous ? previous.elapsedTime + deltaTime : 0;
381
+            const duration = previous ? previous.duration + deltaTime : 0;
382 382
 
383 383
             // determine how much this pointer has moved since its tracking began
384 384
             const totalDistance = previous ? previous.totalDistance + deltaPosition.length() : 0;
@@ -391,7 +391,7 @@ export class PointerTracker implements Tracker
391 391
 
392 392
             // we create new trackable instances on each frame;
393 393
             // these will be exported and consumed by the user
394
-            this._newPointers.set(id, { id, phase, position, deltaPosition, initialPosition, velocity, elapsedTime, totalDistance, isPrimary, kind });
394
+            this._newPointers.set(id, { id, phase, position, deltaPosition, initialPosition, velocity, duration, totalDistance, isPrimary, kind });
395 395
 
396 396
         }
397 397
 
@@ -480,10 +480,10 @@ export class PointerTracker implements Tracker
480 480
     {
481 481
         this._activePointers.forEach((trackable, id) => {
482 482
             if(trackable.phase == 'stationary') {
483
-                (trackable as any).elapsedTime += deltaTime;
483
+                (trackable as any).duration += deltaTime;
484 484
                 /*
485 485
                 this._activePointers.set(id, Object.assign({}, trackable, {
486
-                    elapsedTime: trackable.elapsedTime + deltaTime
486
+                    duration: trackable.duration + deltaTime
487 487
                 }));
488 488
                 */
489 489
             }

+ 1
- 1
src/trackers/pointer-tracker/trackable-pointer.ts Datei anzeigen

@@ -57,7 +57,7 @@ export interface TrackablePointer extends Trackable
57 57
     readonly velocity: Vector2;
58 58
 
59 59
     /** elapsed time, in seconds, since the tracking of this pointer began */
60
-    readonly elapsedTime: number;
60
+    readonly duration: number;
61 61
 
62 62
     /** how much this pointer has moved, in space units, since its tracking began */
63 63
     readonly totalDistance: number;

Laden…
Abbrechen
Speichern