|
@@ -0,0 +1,65 @@
|
|
1
|
+# TrackablePointer
|
|
2
|
+
|
|
3
|
+A [trackable](trackable.md) that represents a pointer tracked by a [PointerTracker](pointer-tracker.md).
|
|
4
|
+
|
|
5
|
+A pointer is an abstraction that represents an instance of user input that targets one or more coordinates on a screen. For example, each point of contact between fingers and a multitouch screen generate a pointer. Devices such as a mouse and a pen/stylus also generate pointers.
|
|
6
|
+
|
|
7
|
+Pointers are positioned in the [viewport](viewport.md), and their positions are given in normalized coordinates. Normalized coordinates range from -1 to +1. The center of the viewport is at (0,0). The top-right corner is at (1,1). The bottom-left corner is at (-1,-1).
|
|
8
|
+
|
|
9
|
+*Since:* 0.4.0
|
|
10
|
+
|
|
11
|
+## Properties
|
|
12
|
+
|
|
13
|
+### id
|
|
14
|
+
|
|
15
|
+`pointer.id: number, read-only`
|
|
16
|
+
|
|
17
|
+A unique identifier assigned to this pointer.
|
|
18
|
+
|
|
19
|
+### phase
|
|
20
|
+
|
|
21
|
+`pointer.phase: string, read-only`
|
|
22
|
+
|
|
23
|
+The phase of the pointer. It's one of the following strings:
|
|
24
|
+
|
|
25
|
+* `"began"`: the tracking began in this frame (e.g., a finger has just touched the screen)
|
|
26
|
+* `"stationary"`: the user did not move the pointer in this frame
|
|
27
|
+* `"moved"`: the user moved the pointer in this frame
|
|
28
|
+* `"ended"`: the tracking ended in this frame (e.g., a finger has just been lifted from the screen)
|
|
29
|
+* `"canceled"`: the tracking was canceled in this frame (e.g., the screen orientation of the device has just been changed)
|
|
30
|
+
|
|
31
|
+### position
|
|
32
|
+
|
|
33
|
+`pointer.position: Vector2, read-only`
|
|
34
|
+
|
|
35
|
+The current position of the pointer, given in normalized coordinates.
|
|
36
|
+
|
|
37
|
+### initialPosition
|
|
38
|
+
|
|
39
|
+`pointer.initialPosition: Vector2, read-only`
|
|
40
|
+
|
|
41
|
+The position of the pointer when its tracking began.
|
|
42
|
+
|
|
43
|
+### deltaPosition
|
|
44
|
+
|
|
45
|
+`pointer.deltaPosition: Vector2, read-only`
|
|
46
|
+
|
|
47
|
+The difference between the position of the pointer in this and in the previous frame.
|
|
48
|
+
|
|
49
|
+### velocity
|
|
50
|
+
|
|
51
|
+`pointer.velocity: Vector2, read-only`
|
|
52
|
+
|
|
53
|
+The current velocity of the pointer, given in normalized coordinates per second. You can get the speed of motion by calculating the [magnitude](vector2.md#length) of this vector.
|
|
54
|
+
|
|
55
|
+### isPrimary
|
|
56
|
+
|
|
57
|
+`pointer.isPrimary: boolean, read-only`
|
|
58
|
+
|
|
59
|
+Whether or not this is the primary pointer among all pointers of this [type](#type). A typical primary pointer is that of a finger that touches the screen when no other fingers are touching it.
|
|
60
|
+
|
|
61
|
+### type
|
|
62
|
+
|
|
63
|
+`pointer.type: string, read-only`
|
|
64
|
+
|
|
65
|
+The type of device that originated this pointer. Typically `"touch"`, `"mouse"` or `"pen"`.
|