瀏覽代碼

Rename TrackablePointer.elapsedTime to TrackablePointer.duration

customisations
alemart 9 月之前
父節點
當前提交
03afca3961

+ 1
- 1
demos/pointer-demo/demo.js 查看文件

81
         ctx.fillText('x: ' + pointer.position.x.toFixed(5), position.x, position.y + 2 * TEXT_LINE_HEIGHT);
81
         ctx.fillText('x: ' + pointer.position.x.toFixed(5), position.x, position.y + 2 * TEXT_LINE_HEIGHT);
82
         ctx.fillText('y: ' + pointer.position.y.toFixed(5), position.x, position.y + 3 * TEXT_LINE_HEIGHT);
82
         ctx.fillText('y: ' + pointer.position.y.toFixed(5), position.x, position.y + 3 * TEXT_LINE_HEIGHT);
83
         ctx.fillText('speed: ' + pointer.velocity.length().toFixed(5), position.x, position.y + 4 * TEXT_LINE_HEIGHT);
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 查看文件

52
 
52
 
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.
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
 The elapsed time, in seconds, since the tracking of this pointer began.
59
 The elapsed time, in seconds, since the tracking of this pointer began.
60
 
60
 
62
 
62
 
63
 `pointer.totalDistance: number, read-only`
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
 ### isPrimary
67
 ### isPrimary
68
 
68
 

+ 4
- 4
src/trackers/pointer-tracker/pointer-tracker.ts 查看文件

378
             const velocity = deltaPosition._clone()._scale(inverseDeltaTime);
378
             const velocity = deltaPosition._clone()._scale(inverseDeltaTime);
379
 
379
 
380
             // determine the elapsed time since the tracking began
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
             // determine how much this pointer has moved since its tracking began
383
             // determine how much this pointer has moved since its tracking began
384
             const totalDistance = previous ? previous.totalDistance + deltaPosition.length() : 0;
384
             const totalDistance = previous ? previous.totalDistance + deltaPosition.length() : 0;
391
 
391
 
392
             // we create new trackable instances on each frame;
392
             // we create new trackable instances on each frame;
393
             // these will be exported and consumed by the user
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
     {
480
     {
481
         this._activePointers.forEach((trackable, id) => {
481
         this._activePointers.forEach((trackable, id) => {
482
             if(trackable.phase == 'stationary') {
482
             if(trackable.phase == 'stationary') {
483
-                (trackable as any).elapsedTime += deltaTime;
483
+                (trackable as any).duration += deltaTime;
484
                 /*
484
                 /*
485
                 this._activePointers.set(id, Object.assign({}, trackable, {
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 查看文件

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

Loading…
取消
儲存