forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LeapMotionTS.d.ts
298 lines (279 loc) · 10.1 KB
/
LeapMotionTS.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
// Type definitions for Leap Motion TS 0.7.9
// Project: https://github.com/logotype/LeapMotionTS
// Definitions by: Victor Norgren <https://github.com/logotype/>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
export declare class EventDispatcher {
private _listeners;
constructor();
public hasEventListener(type: string, listener: Function): boolean;
public addEventListener(typeStr: string, listenerFunc: Function): void;
public removeEventListener(typeStr: string, listenerFunc: Function): void;
public dispatchEvent(evt: LeapEvent): void;
}
export interface Listener {
onConnect(controller: Controller): void;
onDisconnect(controller: Controller): void;
onExit(controller: Controller): void;
onFrame(controller: Controller, frame: Frame): void;
onInit(controller: Controller): void;
}
export declare class DefaultListener extends EventDispatcher implements Listener {
constructor();
public onConnect(controller: Controller): void;
public onDisconnect(controller: Controller): void;
public onExit(controller: Controller): void;
public onFrame(controller: Controller, frame: Frame): void;
public onInit(controller: Controller): void;
}
export declare class LeapEvent {
static LEAPMOTION_INIT: string;
static LEAPMOTION_CONNECTED: string;
static LEAPMOTION_DISCONNECTED: string;
static LEAPMOTION_EXIT: string;
static LEAPMOTION_FRAME: string;
private _type;
private _target;
public frame: Frame;
constructor(type: string, targetListener: Listener, frame?: Frame);
public getTarget(): any;
public getType(): string;
}
export declare class LeapUtil {
static PI: number;
static DEG_TO_RAD: number;
static RAD_TO_DEG: number;
static TWO_PI: number;
static HALF_PI: number;
static EPSILON: number;
constructor();
static toDegrees(radians: number): number;
static isNearZero(value: number): boolean;
static vectorIsNearZero(inVector: Vector3): boolean;
static extractRotation(mtxTransform: Matrix): Matrix;
static rotationInverse(mtxRot: Matrix): Matrix;
static rigidInverse(mtxTransform: Matrix): Matrix;
static componentWiseMin(vLHS: Vector3, vRHS: Vector3): Vector3;
static componentWiseMax(vLHS: Vector3, vRHS: Vector3): Vector3;
static componentWiseScale(vLHS: Vector3, vRHS: Vector3): Vector3;
static componentWiseReciprocal(inVector: Vector3): Vector3;
static minComponent(inVector: Vector3): number;
static maxComponent(inVector: Vector3): number;
static heading(inVector: Vector3): number;
static elevation(inVector: Vector3): number;
static normalizeSpherical(vSpherical: Vector3): Vector3;
static cartesianToSpherical(vCartesian: Vector3): Vector3;
static sphericalToCartesian(vSpherical: Vector3): Vector3;
static clamp(inVal: number, minVal: number, maxVal: number): number;
static lerp(a: number, b: number, coefficient: number): number;
static lerpVector(vec1: Vector3, vec2: Vector3, coefficient: number): Vector3;
}
export declare class Controller extends EventDispatcher {
private listener;
public frameHistory: Frame[];
private latestFrame;
public connection: WebSocket;
public _isConnected: boolean;
public _isGesturesEnabled: boolean;
constructor(host?: string);
private static getHandByID(frame, id);
private static getPointableByID(frame, id);
public frame(history?: number): Frame;
public setListener(listener: Listener): void;
public enableGesture(type: number, enable?: boolean): void;
public isGestureEnabled(type: number): boolean;
public isConnected(): boolean;
}
export declare class Pointable {
public direction: Vector3;
public frame: Frame;
public hand: Hand;
public id: number;
public length: number;
public width: number;
public tipPosition: Vector3;
public tipVelocity: Vector3;
public isFinger: boolean;
public isTool: boolean;
constructor();
public isValid(): boolean;
public isEqualTo(other: Pointable): boolean;
static invalid(): Pointable;
public toString(): string;
}
export declare class Gesture {
static STATE_INVALID: number;
static STATE_START: number;
static STATE_UPDATE: number;
static STATE_STOP: number;
static TYPE_INVALID: number;
static TYPE_SWIPE: number;
static TYPE_CIRCLE: number;
static TYPE_SCREEN_TAP: number;
static TYPE_KEY_TAP: number;
public duration: number;
public durationSeconds: number;
public frame: Frame;
public hands: Hand[];
public id: number;
public pointables: Pointable[];
public state: number;
public type: number;
constructor();
public isEqualTo(other: Gesture): boolean;
public isValid(): boolean;
static invalid(): Gesture;
public toString(): string;
}
export declare class Finger extends Pointable {
constructor();
static invalid(): Finger;
}
export declare class Tool extends Pointable {
constructor();
static invalid(): Tool;
}
export declare class Hand {
public direction: Vector3;
public fingers: Finger[];
public frame: Frame;
public id: number;
public palmNormal: Vector3;
public palmPosition: Vector3;
public palmVelocity: Vector3;
public pointables: Pointable[];
public sphereCenter: Vector3;
public sphereRadius: number;
public tools: Tool[];
public rotation: Matrix;
public scaleFactorNumber: number;
public translationVector: Vector3;
constructor();
public isValid(): boolean;
public isEqualTo(other: Hand): boolean;
public finger(id: number): Finger;
public tool(id: number): Tool;
public pointable(id: number): Pointable;
public rotationAxis(sinceFrame: Frame): Vector3;
public rotationAngle(sinceFrame: Frame, axis?: Vector3): number;
public rotationMatrix(sinceFrame: Frame): Matrix;
public scaleFactor(sinceFrame: Frame): number;
public translation(sinceFrame: Frame): Vector3;
static invalid(): Hand;
}
export declare class Frame {
public fingers: Finger[];
public hands: Hand[];
public pointables: Pointable[];
public _gestures: Gesture[];
public id: number;
public timestamp: number;
public tools: Tool[];
public rotation: Matrix;
public scaleFactorNumber: number;
public translationVector: Vector3;
public controller: Controller;
constructor();
public hand(id: number): Hand;
public finger(id: number): Finger;
public tool(id: number): Tool;
public pointable(id: number): Pointable;
public gesture(id: number): Gesture;
public gestures(sinceFrame?: Frame): Gesture[];
public rotationAxis(sinceFrame: Frame): Vector3;
public rotationAngle(sinceFrame: Frame, axis?: Vector3): number;
public rotationMatrix(sinceFrame: Frame): Matrix;
public scaleFactor(sinceFrame: Frame): number;
public translation(sinceFrame: Frame): Vector3;
public isEqualTo(other: Frame): boolean;
public isValid(): boolean;
static invalid(): Frame;
}
export declare class Matrix {
public origin: Vector3;
public xBasis: Vector3;
public yBasis: Vector3;
public zBasis: Vector3;
constructor(x: Vector3, y: Vector3, z: Vector3, _origin?: Vector3);
public setRotation(_axis: Vector3, angleRadians: number): void;
public transformPoint(inVector: Vector3): Vector3;
public transformDirection(inVector: Vector3): Vector3;
public rigidInverse(): Matrix;
public multiply(other: Matrix): Matrix;
public multiplyAssign(other: Matrix): Matrix;
public isEqualTo(other: Matrix): boolean;
static identity(): Matrix;
public toString(): string;
}
export declare class CircleGesture extends Gesture {
static classType: number;
public center: Vector3;
public normal: Vector3;
public pointable: Pointable;
public progress: number;
public radius: number;
constructor();
}
export declare class KeyTapGesture extends Gesture {
static classType: number;
public direction: Vector3;
public pointable: Pointable;
public position: Vector3;
public progress: number;
constructor();
}
export declare class ScreenTapGesture extends Gesture {
static classType: number;
public direction: Vector3;
public pointable: Pointable;
public position: Vector3;
public progress: number;
constructor();
}
export declare class SwipeGesture extends Gesture {
static classType: number;
public direction: Vector3;
public pointable: Pointable;
public position: Vector3;
public speed: number;
public startPosition: Vector3;
constructor();
}
export declare class Vector3 {
public x: number;
public y: number;
public z: number;
constructor(x: number, y: number, z: number);
public opposite(): Vector3;
public plus(other: Vector3): Vector3;
public plusAssign(other: Vector3): Vector3;
public minus(other: Vector3): Vector3;
public minusAssign(other: Vector3): Vector3;
public multiply(scalar: number): Vector3;
public multiplyAssign(scalar: number): Vector3;
public divide(scalar: number): Vector3;
public divideAssign(scalar: number): Vector3;
public isEqualTo(other: Vector3): boolean;
public angleTo(other: Vector3): number;
public cross(other: Vector3): Vector3;
public distanceTo(other: Vector3): number;
public dot(other: Vector3): number;
public isValid(): boolean;
static invalid(): Vector3;
public magnitude(): number;
public magnitudeSquared(): number;
public normalized(): Vector3;
public pitch : number;
public yaw : number;
public roll : number;
static zero(): Vector3;
static xAxis(): Vector3;
static yAxis(): Vector3;
static zAxis(): Vector3;
static left(): Vector3;
static right(): Vector3;
static down(): Vector3;
static up(): Vector3;
static forward(): Vector3;
static backward(): Vector3;
public toString(): string;
}