Просмотр исходного кода

Introduce Trackable.tracker

customisations
alemart 8 месяцев назад
Родитель
Сommit
cbf1d1120a

+ 11
- 1
docs/api/trackable.md Просмотреть файл

@@ -1,3 +1,13 @@
1 1
 # Trackable
2 2
 
3
-A Trackable is an interface that represents something that is tracked by a [Tracker](tracker.md).
3
+A Trackable is an interface that represents something that is tracked by a [Tracker](tracker.md).
4
+
5
+## Properties
6
+
7
+### tracker
8
+
9
+`trackable.tracker: Tracker, read-only`
10
+
11
+A reference to the [Tracker](tracker.md) that generated this trackable.
12
+
13
+*Since:* 0.4.0

+ 2
- 1
src/trackers/image-tracker/states/tracking.ts Просмотреть файл

@@ -376,7 +376,8 @@ export class ImageTrackerTrackingState extends ImageTrackerState
376 376
             // the trackable object
377 377
             const trackable: TrackableImage = {
378 378
                 pose: pose,
379
-                referenceImage: referenceImage
379
+                referenceImage: referenceImage,
380
+                tracker: this._imageTracker
380 381
             };
381 382
 
382 383
             // the result generated by the image tracker

+ 8
- 1
src/trackers/pointer-tracker/pointer-tracker.ts Просмотреть файл

@@ -394,7 +394,14 @@ export class PointerTracker implements Tracker
394 394
 
395 395
             // we create new trackable instances on each frame;
396 396
             // these will be exported and consumed by the user
397
-            this._newPointers.set(id, { id, phase, position, deltaPosition, initialPosition, velocity, duration, movementDuration, movementLength, isPrimary, kind });
397
+            this._newPointers.set(id, {
398
+                id, phase,
399
+                position, deltaPosition, initialPosition,
400
+                velocity, duration,
401
+                movementDuration, movementLength,
402
+                isPrimary, kind,
403
+                tracker: this
404
+            });
398 405
 
399 406
         }
400 407
 

+ 2
- 0
src/trackers/tracker.ts Просмотреть файл

@@ -29,6 +29,8 @@ import { SpeedyMedia } from 'speedy-vision/types/core/speedy-media';
29 29
  */
30 30
 export interface Trackable
31 31
 {
32
+    /** the tracker that generated this trackable */
33
+    readonly tracker: Tracker;
32 34
 }
33 35
 
34 36
 /**

Загрузка…
Отмена
Сохранить