Browse Source

Add TrackablePointer.isPrimary flag

customisations
alemart 10 months ago
parent
commit
ab17a40297
1 changed files with 7 additions and 1 deletions
  1. 7
    1
      src/trackers/pointer-tracker/pointer-tracker.ts

+ 7
- 1
src/trackers/pointer-tracker/pointer-tracker.ts View File

53
     /** the first position, given in normalized coordinates */
53
     /** the first position, given in normalized coordinates */
54
     readonly initialPosition: Vector2;
54
     readonly initialPosition: Vector2;
55
 
55
 
56
+    /** whether or not this is the primary pointer for this type */
57
+    readonly isPrimary: boolean;
58
+
56
     /** the type of the originating device; typically "mouse", "touch" or "pen" */
59
     /** the type of the originating device; typically "mouse", "touch" or "pen" */
57
     readonly type: string;
60
     readonly type: string;
58
 }
61
 }
283
             // determine the type of the originating device
286
             // determine the type of the originating device
284
             const type = event.pointerType;
287
             const type = event.pointerType;
285
 
288
 
289
+            // determine whether or not this is the primary pointer for this type
290
+            const isPrimary = event.isPrimary;
291
+
286
             // we create new trackable instances on each frame;
292
             // we create new trackable instances on each frame;
287
             // these will be exported and consumed by the user
293
             // these will be exported and consumed by the user
288
-            this._newPointers.set(id, { id, phase, position, initialPosition, type });
294
+            this._newPointers.set(id, { id, phase, position, initialPosition, isPrimary, type });
289
 
295
 
290
         }
296
         }
291
 
297
 

Loading…
Cancel
Save