@openglobus/og 0.13.10 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +1 -4
  2. package/css/og.css +1 -1
  3. package/dist/@openglobus/og.css +1 -1
  4. package/dist/@openglobus/og.esm.js +2 -2
  5. package/dist/@openglobus/og.esm.js.map +1 -1
  6. package/dist/@openglobus/og.umd.js +2 -2
  7. package/dist/@openglobus/og.umd.js.map +1 -1
  8. package/package.json +2 -2
  9. package/src/og/Globe.js +14 -4
  10. package/src/og/camera/Camera.js +7 -7
  11. package/src/og/camera/PlanetCamera.js +1 -1
  12. package/src/og/control/LayerSwitcher.js +48 -31
  13. package/src/og/control/MouseNavigation.js +2 -2
  14. package/src/og/control/ScaleControl.js +30 -10
  15. package/src/og/control/SimpleSkyBackground.js +184 -0
  16. package/src/og/control/Sun.js +3 -2
  17. package/src/og/ellipsoid/Ellipsoid.js +119 -92
  18. package/src/og/ellipsoid/wgs84.js +13 -13
  19. package/src/og/entity/Entity.js +3 -3
  20. package/src/og/entity/GeometryHandler.js +1341 -1337
  21. package/src/og/entity/LabelHandler.js +1 -4
  22. package/src/og/entity/LabelWorker.js +10 -13
  23. package/src/og/entity/Polyline.js +0 -16
  24. package/src/og/entity/Ray.js +0 -10
  25. package/src/og/entity/RayHandler.js +3 -44
  26. package/src/og/entity/Strip.js +1 -6
  27. package/src/og/index.js +106 -95
  28. package/src/og/layer/GeoVideo.js +1 -0
  29. package/src/og/layer/Layer.js +62 -3
  30. package/src/og/layer/XYZ.js +4 -3
  31. package/src/og/math/Line3.js +140 -139
  32. package/src/og/math/Plane.js +118 -117
  33. package/src/og/math/Ray.js +242 -239
  34. package/src/og/math/Vec3.js +56 -37
  35. package/src/og/math/Vec4.js +3 -4
  36. package/src/og/math.js +21 -21
  37. package/src/og/quadTree/EarthQuadTreeStrategy.js +29 -0
  38. package/src/og/quadTree/MarsQuadTreeStrategy.js +27 -0
  39. package/src/og/quadTree/Node.js +55 -218
  40. package/src/og/quadTree/QuadTreeStrategy.js +93 -0
  41. package/src/og/quadTree/Wgs84QuadTreeStrategy.js +26 -0
  42. package/src/og/renderer/Renderer.js +13 -12
  43. package/src/og/renderer/RendererEvents.js +1065 -1065
  44. package/src/og/scene/Planet.js +84 -273
  45. package/src/og/segment/Segment.js +18 -25
  46. package/src/og/segment/SegmentLonLat.js +34 -31
  47. package/src/og/segment/SegmentLonLatWgs84.js +41 -0
  48. package/src/og/shaders/ray.js +13 -6
  49. package/src/og/shaders/toneMapping.js +5 -5
  50. package/src/og/terrain/GlobusTerrain.js +3 -2
  51. package/src/og/terrain/MapboxTerrain.js +231 -52
  52. package/src/og/utils/quadTreeType.js +11 -0
  53. package/src/og/utils/shared.js +942 -942
  54. package/src/og/webgl/Handler.js +22 -9
  55. package/types/Globe.d.ts +7 -0
  56. package/types/camera/Camera.d.ts +3 -3
  57. package/types/camera/PlanetCamera.d.ts +1 -1
  58. package/types/control/LayerSwitcher.d.ts +1 -1
  59. package/types/control/ScaleControl.d.ts +2 -1
  60. package/types/control/SimpleSkyBackground.d.ts +11 -0
  61. package/types/control/Sun.d.ts +2 -1
  62. package/types/ellipsoid/Ellipsoid.d.ts +3 -2
  63. package/types/entity/LabelWorker.d.ts +1 -1
  64. package/types/entity/Ray.d.ts +0 -3
  65. package/types/entity/RayHandler.d.ts +0 -4
  66. package/types/index.d.ts +6 -1
  67. package/types/layer/Layer.d.ts +8 -0
  68. package/types/math/Vec3.d.ts +19 -16
  69. package/types/math/Vec4.d.ts +2 -3
  70. package/types/math.d.ts +20 -20
  71. package/types/quadTree/EarthQuadTreeStrategy.d.ts +3 -0
  72. package/types/quadTree/MarsQuadTreeStrategy.d.ts +3 -0
  73. package/types/quadTree/Node.d.ts +0 -1
  74. package/types/quadTree/QuadTreeStrategy.d.ts +21 -0
  75. package/types/quadTree/Wgs84QuadTreeStrategy.d.ts +3 -0
  76. package/types/renderer/Renderer.d.ts +1 -1
  77. package/types/scene/Planet.d.ts +6 -24
  78. package/types/segment/Segment.d.ts +4 -4
  79. package/types/segment/SegmentLonLat.d.ts +6 -2
  80. package/types/segment/SegmentLonLatWgs84.d.ts +4 -0
  81. package/types/terrain/MapboxTerrain.d.ts +2 -1
  82. package/types/utils/quadTreeType.d.ts +8 -0
  83. package/types/webgl/Handler.d.ts +4 -1
@@ -1,1065 +1,1065 @@
1
- /**
2
- * @module og/renderer/RendererEvents
3
- */
4
-
5
- "use strict";
6
-
7
- import { Events } from "../Events.js";
8
- import { input } from "../input/input.js";
9
- import { KeyboardHandler } from "../input/KeyboardHandler.js";
10
- import { MouseHandler } from "../input/MouseHandler.js";
11
- import { TouchHandler } from "../input/TouchHandler.js";
12
- import { Vec2 } from "../math/Vec2.js";
13
- import { Vec3 } from "../math/Vec3.js";
14
-
15
- const LB_M = 0b0001;
16
- const RB_M = 0b0010;
17
- const MB_M = 0b0100;
18
-
19
- /**
20
- * Renderer events handler.
21
- * @class
22
- * @param {Renderer} renderer - Renderer object, events that works for.
23
- */
24
- class RendererEvents extends Events {
25
- constructor(renderer) {
26
- super(EVENT_NAMES);
27
-
28
- /**
29
- * Assigned renderer.
30
- * @public
31
- * @type {Renderer}
32
- */
33
- this.renderer = renderer;
34
-
35
- /**
36
- * Low level touch events handler.
37
- * @private
38
- * @type {input.TouchHandler}
39
- */
40
- this._touchHandler = new TouchHandler(renderer.handler.canvas);
41
-
42
- /**
43
- * Low level mouse events handler.
44
- * @private
45
- * @type {input.MouseHandler}
46
- */
47
- this._mouseHandler = new MouseHandler(renderer.handler.canvas);
48
-
49
- /**
50
- * Low level keyboard events handler.
51
- * @private
52
- * @type {input.KeyboardHandler}
53
- */
54
- this._keyboardHandler = new KeyboardHandler();
55
-
56
- this._active = true;
57
-
58
- this.clickRadius = 15;
59
-
60
- /**
61
- * Current mouse state.
62
- * @public
63
- * @enum {Object}
64
- */
65
- this.mouseState = {
66
- /** Current screen mouse X position. */
67
- clientX: 0,
68
- /** Current screen mouse Y position. */
69
- clientY: 0,
70
- /** Current viewport mouse X position. */
71
- x: 0,
72
- /** Current viewport mouse Y position. */
73
- y: 0,
74
- /** Current mouse X position from 0 to 1 */
75
- nx: 0,
76
- /** Current mouse Y position from 0 to 1 */
77
- ny: 0,
78
- /** Previous mouse X position. */
79
- prev_x: 0,
80
- /** Previous mouse Y position. */
81
- prev_y: 0,
82
- /** Screen mouse position world direction. */
83
- direction: new Vec3(),
84
- /** Left mouse button has stopped pushing down right now.*/
85
- leftButtonUp: false,
86
- /** Right mouse button has stopped pushing down right now.*/
87
- rightButtonUp: false,
88
- /** Middle mouse button has stopped pushing down right now.*/
89
- middleButtonUp: false,
90
- /** Left mouse button has pushed now.*/
91
- leftButtonDown: false,
92
- /** Right mouse button has pushed now.*/
93
- rightButtonDown: false,
94
- /** Middle mouse button has pushed now.*/
95
- middleButtonDown: false,
96
- /** Left mouse button is pushing.*/
97
- leftButtonHold: false,
98
- /** Right mouse button is pushing.*/
99
- rightButtonHold: false,
100
- /** Middle mouse button is pushing.*/
101
- middleButtonHold: false,
102
- /** Left mouse button has clicked twice now.*/
103
- leftButtonDoubleClick: false,
104
- /** Right mouse button has clicked twice now.*/
105
- rightButtonDoubleClick: false,
106
- /** Middle mouse button has clicked twice now.*/
107
- middleButtonDoubleClick: false,
108
- /** Left mouse button has clicked now. */
109
- leftButtonClick: false,
110
- /** Right mouse button has clicked now. */
111
- rightButtonClick: false,
112
- /** Middle mouse button has clicked now. */
113
- middleButtonClick: false,
114
- /** Mouse is moving now. */
115
- moving: false,
116
- /** Mouse has just stopped now. */
117
- justStopped: false,
118
- /** Mose double click delay response time.*/
119
- doubleClickDelay: 500,
120
- /** Mose click delay response time.*/
121
- clickDelay: 200,
122
- /** Mouse wheel. */
123
- wheelDelta: 0,
124
- /** JavaScript mouse system event message. */
125
- sys: null,
126
- /** Current picking object. */
127
- pickingObject: null,
128
- /** Renderer instanve. */
129
- renderer: renderer
130
- };
131
-
132
- /**
133
- * Current touch state.
134
- * @public
135
- * @enum {Object}
136
- */
137
- this.touchState = {
138
- /** Touching is moving now. */
139
- moving: false,
140
- /** Touch has ended right now.*/
141
- touchEnd: false,
142
- /** Touch has started right now.*/
143
- touchStart: false,
144
- /** Touch canceled.*/
145
- touchCancel: false,
146
- /** Touched twice.*/
147
- doubleTouch: false,
148
- /** Double touching responce delay.*/
149
- doubleTouchDelay: 550,
150
- /** Double touching responce radius in screen pixels.*/
151
- doubleTouchRadius: 10,
152
- /** Current touch X - coordinate. */
153
- x: 0,
154
- /** Current touch Y - coordinate. */
155
- y: 0,
156
- /** Current touch X - coordinate from 0 to 1 */
157
- nx: 0,
158
- /** Current touch Y - coordinate from 0 to 1 */
159
- ny: 0,
160
- /** Previous touch X coordinate. */
161
- prev_x: 0,
162
- /** Previous touch Y coordinate. */
163
- prev_y: 0,
164
- /** Screen touch position world direction. */
165
- direction: new Vec3(),
166
- /** JavaScript touching system event message. */
167
- sys: null,
168
- /** Current touched(picking) object. */
169
- pickingObject: null,
170
- /** Renderer instanve. */
171
- renderer: renderer
172
- };
173
-
174
- this._dblTchCoords = new Vec2();
175
- this._oneTouchStart = false;
176
- this._dblTchBegins = 0;
177
- /**
178
- * @type {number}
179
- */
180
- this._mousestopThread = null;
181
- this._ldblClkBegins = 0;
182
- this._rdblClkBegins = 0;
183
- this._mdblClkBegins = 0;
184
- this._lClkBegins = 0;
185
- this._rClkBegins = 0;
186
- this._mClkBegins = 0;
187
- this._lclickX = 0;
188
- this._lclickY = 0;
189
- this._rclickX = 0;
190
- this._rclickY = 0;
191
- this._mclickX = 0;
192
- this._mclickY = 0;
193
- }
194
-
195
- pointerEvent() {
196
- let ms = this.mouseState,
197
- ts = this.touchState;
198
- return (
199
- ms.moving ||
200
- ms.justStopped ||
201
- ms.wheelDelta ||
202
- ts.moving ||
203
- ts.touchStart ||
204
- ts.touchEnd
205
- )
206
- }
207
-
208
- get active() {
209
- return this._active;
210
- }
211
-
212
- set active(act) {
213
- this._active = act;
214
- this._keyboardHandler.setActivity(act);
215
- }
216
-
217
- /**
218
- * Used in render node frame.
219
- * @public
220
- */
221
- handleEvents() {
222
- if (this._active) {
223
- this.mouseState.direction = this.renderer.activeCamera.unproject(
224
- this.mouseState.x,
225
- this.mouseState.y
226
- );
227
- //
228
- // TODO: Replace in some other place with a thought that we do
229
- // not need to make unproject when we do not make touching
230
- this.touchState.direction = this.renderer.activeCamera.unproject(
231
- this.touchState.x,
232
- this.touchState.y
233
- );
234
- this.entityPickingEvents();
235
- this._keyboardHandler.handleEvents();
236
- this.handleMouseEvents();
237
- this.handleTouchEvents();
238
- }
239
- }
240
-
241
- /**
242
- * Set render event callback.
243
- * @public
244
- * @param {string} name - Event name
245
- * @param {eventCallback} callback - Callback function
246
- * @param {number} [key] - Key code from og.input
247
- * @param {*} sender - Callback context
248
- * @param {number} [priority] - Event callback priority
249
- */
250
- on(name, p0, p1, p2, p3) {
251
- if (name === "keypress" || name === "charkeypress" || name === "keyfree") {
252
- this._keyboardHandler.addEvent(name, p2, p1, p0, p3);
253
- } else {
254
- super.on(name, p0, p1, p2);
255
- }
256
- }
257
-
258
- /**
259
- * TODO: DOESNT WORK!!!
260
- * @param {any} name
261
- * @param {any} callback
262
- */
263
- off(name, callback) {
264
- if (name === "keypress" || name === "charkeypress" || name === "keyfree") {
265
- this._keyboardHandler.removeEvent(name, callback);
266
- } else {
267
- super.off(name, callback);
268
- }
269
- }
270
-
271
- /**
272
- * Check key is pressed.
273
- * @public
274
- * @param {number} keyCode - Key code
275
- * @return {boolean}
276
- */
277
- isKeyPressed(keyCode) {
278
- return this._keyboardHandler.isKeyPressed(keyCode);
279
- }
280
-
281
- releaseKeys() {
282
- this._keyboardHandler.releaseKeys();
283
- }
284
-
285
- /**
286
- * Renderer events initialization.
287
- * @public
288
- */
289
- initialize() {
290
- this._mouseHandler.setEvent("mouseup", this, this.onMouseUp);
291
- this._mouseHandler.setEvent("mousemove", this, this.onMouseMove);
292
- this._mouseHandler.setEvent("mousedown", this, this.onMouseDown);
293
- this._mouseHandler.setEvent("mousewheel", this, this.onMouseWheel);
294
- this._mouseHandler.setEvent("mouseleave", this, this.onMouseLeave);
295
- this._mouseHandler.setEvent("mouseenter", this, this.onMouseEnter);
296
-
297
- this._touchHandler.setEvent("touchstart", this, this.onTouchStart);
298
- this._touchHandler.setEvent("touchend", this, this.onTouchEnd);
299
- this._touchHandler.setEvent("touchcancel", this, this.onTouchCancel);
300
- this._touchHandler.setEvent("touchmove", this, this.onTouchMove);
301
- }
302
-
303
- /**
304
- * @private
305
- */
306
- onMouseWheel(event) {
307
- this.mouseState.wheelDelta = event.wheelDelta;
308
- }
309
-
310
- /**
311
- * @protected
312
- */
313
- updateButtonsStates(buttons) {
314
- var ms = this.mouseState;
315
- if (buttons & LB_M) {
316
- ms.leftButtonDown = true;
317
- } else {
318
- ms.leftButtonHold = false;
319
- ms.leftButtonDown = false;
320
- }
321
-
322
- if (buttons & RB_M) {
323
- ms.rightButtonDown = true;
324
- } else {
325
- ms.rightButtonHold = false;
326
- ms.rightButtonDown = false;
327
- }
328
-
329
- if (buttons & MB_M) {
330
- ms.middleButtonDown = true;
331
- } else {
332
- ms.middleButtonHold = false;
333
- ms.middleButtonDown = false;
334
- }
335
- }
336
-
337
- /**
338
- * @private
339
- */
340
- onMouseMove(event, sys) {
341
- var ms = this.mouseState;
342
- this.updateButtonsStates(sys.buttons);
343
- ms.sys = event;
344
-
345
- let ex = event.clientX,
346
- ey = event.clientY,
347
- r = this.clickRadius;
348
-
349
- if (Math.abs(this._lclickX - ex) >= r && Math.abs(this._lclickY - ey) >= r) {
350
- this._ldblClkBegins = 0;
351
- this._lClkBegins = 0;
352
- }
353
-
354
- if (Math.abs(this._rclickX - ex) >= r && Math.abs(this._rclickY - ey) >= r) {
355
- this._rdblClkBegins = 0;
356
- this._rClkBegins = 0;
357
- }
358
-
359
- if (Math.abs(this._mclickX - ex) >= r && Math.abs(this._mclickY - ey) >= r) {
360
- this._mdblClkBegins = 0;
361
- this._mClkBegins = 0;
362
- }
363
-
364
- if (ms.clientX === event.clientX && ms.clientY === event.clientY) {
365
- return;
366
- }
367
-
368
- ms.clientX = event.clientX;
369
- ms.clientY = event.clientY;
370
-
371
- let h = this.renderer.handler;
372
-
373
- ms.x = event.clientX * h.pixelRatio;
374
- ms.y = event.clientY * h.pixelRatio;
375
-
376
- ms.nx = ms.x / h.canvas.width;
377
- ms.ny = ms.y / h.canvas.height;
378
-
379
- ms.moving = true;
380
-
381
- //dispatch stop mouse event
382
- clearTimeout(this._mousestopThread);
383
- this._mousestopThread = setTimeout(function () {
384
- ms.justStopped = true;
385
- }, 100);
386
- }
387
-
388
- onMouseLeave(event) {
389
- this.dispatch(this.mouseleave, event);
390
- }
391
-
392
- onMouseEnter(event) {
393
- this.dispatch(this.mouseenter, event);
394
- }
395
-
396
- /**
397
- * @private
398
- */
399
- onMouseDown(event) {
400
- if (event.button === input.MB_LEFT) {
401
- this._lClkBegins = window.performance.now();
402
- this._lclickX = event.clientX;
403
- this._lclickY = event.clientY;
404
- this.mouseState.sys = event;
405
- this.mouseState.leftButtonDown = true;
406
- } else if (event.button === input.MB_RIGHT) {
407
- this._rClkBegins = window.performance.now();
408
- this._rclickX = event.clientX;
409
- this._rclickY = event.clientY;
410
- this.mouseState.sys = event;
411
- this.mouseState.rightButtonDown = true;
412
- } else if (event.button === input.MB_MIDDLE) {
413
- this._mClkBegins = window.performance.now();
414
- this._mclickX = event.clientX;
415
- this._mclickY = event.clientY;
416
- this.mouseState.sys = event;
417
- this.mouseState.middleButtonDown = true;
418
- }
419
- }
420
-
421
- /**
422
- * @private
423
- */
424
- onMouseUp(event) {
425
- var ms = this.mouseState;
426
- ms.sys = event;
427
- var t = window.performance.now();
428
-
429
- if (event.button === input.MB_LEFT) {
430
- ms.leftButtonDown = false;
431
- ms.leftButtonUp = true;
432
-
433
- if (
434
- Math.abs(this._lclickX - event.clientX) < this.clickRadius &&
435
- Math.abs(this._lclickY - event.clientY) < this.clickRadius &&
436
- t - this._lClkBegins <= ms.clickDelay
437
- ) {
438
- if (this._ldblClkBegins) {
439
- let deltatime = window.performance.now() - this._ldblClkBegins;
440
- if (deltatime <= ms.doubleClickDelay) {
441
- ms.leftButtonDoubleClick = true;
442
- }
443
- this._ldblClkBegins = 0;
444
- } else {
445
- this._ldblClkBegins = window.performance.now();
446
- }
447
-
448
- ms.leftButtonClick = true;
449
- this._lClkBegins = 0;
450
- }
451
- } else if (event.button === input.MB_RIGHT) {
452
- ms.rightButtonDown = false;
453
- ms.rightButtonUp = true;
454
-
455
- if (
456
- Math.abs(this._rclickX - event.clientX) < this.clickRadius &&
457
- Math.abs(this._rclickY - event.clientY) < this.clickRadius &&
458
- t - this._rClkBegins <= ms.clickDelay
459
- ) {
460
- if (this._rdblClkBegins) {
461
- let deltatime = window.performance.now() - this._rdblClkBegins;
462
- if (deltatime <= ms.doubleClickDelay) {
463
- ms.rightButtonDoubleClick = true;
464
- }
465
- this._rdblClkBegins = 0;
466
- } else {
467
- this._rdblClkBegins = window.performance.now();
468
- }
469
-
470
- ms.rightButtonClick = true;
471
- this._rClkBegins = 0;
472
- }
473
- } else if (event.button === input.MB_MIDDLE) {
474
- ms.middleButtonDown = false;
475
- ms.middleButtonUp = true;
476
-
477
- if (
478
- Math.abs(this._mclickX - event.clientX) < this.clickRadius &&
479
- Math.abs(this._mclickY - event.clientY) < this.clickRadius &&
480
- t - this._mClkBegins <= ms.clickDelay
481
- ) {
482
- if (this._mdblClkBegins) {
483
- var deltatime = window.performance.now() - this._mdblClkBegins;
484
- if (deltatime <= ms.doubleClickDelay) {
485
- ms.middleButtonDoubleClick = true;
486
- }
487
- this._mdblClkBegins = 0;
488
- } else {
489
- this._mdblClkBegins = window.performance.now();
490
- }
491
-
492
- ms.middleButtonClick = true;
493
- this._mClkBegins = 0;
494
- }
495
- }
496
- }
497
-
498
- /**
499
- * @private
500
- */
501
- onTouchStart(event) {
502
- var ts = this.touchState;
503
- ts.sys = event;
504
-
505
- ts.clientX = event.touches.item(0).clientX - event.offsetLeft;
506
- ts.clientY = event.touches.item(0).clientY - event.offsetTop;
507
-
508
- let h = this.renderer.handler;
509
-
510
- ts.x = ts.clientX * h.pixelRatio;
511
- ts.y = ts.clientY * h.pixelRatio;
512
-
513
- ts.nx = ts.x / h.canvas.width;
514
- ts.ny = ts.y / h.canvas.height;
515
- ts.prev_x = ts.x;
516
- ts.prev_y = ts.y;
517
- ts.touchStart = true;
518
-
519
- if (event.touches.length === 1) {
520
- this._dblTchCoords.x = ts.x;
521
- this._dblTchCoords.y = ts.y;
522
- this._oneTouchStart = true;
523
- } else {
524
- this._oneTouchStart = false;
525
- }
526
- }
527
-
528
- /**
529
- * @private
530
- */
531
- onTouchEnd(event) {
532
- var ts = this.touchState;
533
- ts.sys = event;
534
- ts.touchEnd = true;
535
-
536
- if (event.touches.length === 0) {
537
- ts.prev_x = ts.x;
538
- ts.prev_y = ts.y;
539
-
540
- if (this._oneTouchStart) {
541
- if (this._dblTchBegins) {
542
- var deltatime = window.performance.now() - this._dblTchBegins;
543
- if (deltatime <= ts.doubleTouchDelay) {
544
- ts.doubleTouch = true;
545
- }
546
- this._dblTchBegins = 0;
547
- }
548
- this._dblTchBegins = window.performance.now();
549
- this._oneTouchStart = false;
550
- }
551
- }
552
- }
553
-
554
- /**
555
- * @private
556
- */
557
- onTouchCancel(event) {
558
- var ts = this.touchState;
559
- ts.sys = event;
560
- ts.touchCancel = true;
561
- }
562
-
563
- /**
564
- * @private
565
- */
566
- onTouchMove(event) {
567
- var ts = this.touchState;
568
- ts.clientX = event.touches.item(0).clientX - event.offsetLeft;
569
- ts.clientY = event.touches.item(0).clientY - event.offsetTop;
570
-
571
- var h = this.renderer.handler;
572
-
573
- ts.x = ts.clientX * h.pixelRatio;
574
- ts.y = ts.clientY * h.pixelRatio;
575
-
576
- ts.nx = ts.x / h.canvas.width;
577
- ts.ny = ts.y / h.canvas.height;
578
-
579
- ts.sys = event;
580
- ts.moving = true;
581
-
582
- var dX = ts.x - ts.prev_x
583
- var dY = ts.y - ts.prev_y
584
- if (Math.abs(dX) > 9 || Math.abs(dY) > 9) {
585
- this._dblTchBegins = 0;
586
- this._oneTouchStart = false;
587
- }
588
- }
589
-
590
- /**
591
- * @private
592
- */
593
- entityPickingEvents() {
594
- var ts = this.touchState,
595
- ms = this.mouseState;
596
-
597
- if (!(ms.leftButtonHold || ms.rightButtonHold || ms.middleButtonHold)) {
598
- var r = this.renderer;
599
-
600
- var o = r.colorObjects;
601
-
602
- var c = r._currPickingColor,
603
- p = r._prevPickingColor;
604
-
605
- ms.pickingObject = null;
606
- ts.pickingObject = null;
607
-
608
- var co = o && o[c[0] + "_" + c[1] + "_" + c[2]];
609
-
610
- ms.pickingObject = co;
611
- ts.pickingObject = co;
612
-
613
- //object changed
614
- if (c[0] != p[0] || c[1] != p[1] || c[2] != p[2]) {
615
- //current black
616
- if (!(c[0] || c[1] || c[2])) {
617
- let po = o[p[0] + "_" + p[1] + "_" + p[2]];
618
- if (po) {
619
- let pe = po.rendererEvents;
620
- ms.pickingObject = po;
621
- pe && pe.dispatch(pe.mouseleave, ms);
622
- ts.pickingObject = po;
623
- pe && pe.dispatch(pe.touchleave, ts);
624
- }
625
- } else {
626
- //current not black
627
-
628
- //previous not black
629
- if (p[0] || p[1] || p[2]) {
630
- let po = o[p[0] + "_" + p[1] + "_" + p[2]];
631
- if (po) {
632
- let pe = po.rendererEvents;
633
- ms.pickingObject = po;
634
- pe && pe.dispatch(pe.mouseleave, ms);
635
- ts.pickingObject = po;
636
- pe && pe.dispatch(pe.touchleave, ts);
637
- }
638
- }
639
-
640
- if (co) {
641
- var ce = co.rendererEvents;
642
- ms.pickingObject = co;
643
- ce && ce.dispatch(ce.mouseenter, ms);
644
- ts.pickingObject = co;
645
- ce && ce.dispatch(ce.touchenter, ts);
646
- }
647
- }
648
- }
649
- }
650
- }
651
-
652
- /**
653
- * @private
654
- */
655
- handleMouseEvents() {
656
- let ms = this.mouseState;
657
- let po = ms.pickingObject,
658
- pe = null;
659
-
660
- if (ms.leftButtonClick) {
661
- if (po) {
662
- pe = po.rendererEvents;
663
- pe && pe.dispatch(pe.lclick, ms);
664
- }
665
- this.dispatch(this.lclick, ms);
666
- ms.leftButtonClick = false;
667
- }
668
-
669
- if (ms.rightButtonClick) {
670
- if (po) {
671
- pe = po.rendererEvents;
672
- pe && pe.dispatch(pe.rclick, ms);
673
- }
674
- this.dispatch(this.rclick, ms);
675
- ms.rightButtonClick = false;
676
- }
677
-
678
- if (ms.middleButtonClick) {
679
- if (po) {
680
- pe = po.rendererEvents;
681
- pe && pe.dispatch(pe.mclick, ms);
682
- }
683
- this.dispatch(this.mclick, ms);
684
- ms.middleButtonClick = false;
685
- }
686
-
687
- if (ms.leftButtonDown) {
688
- if (ms.leftButtonHold) {
689
- if (po) {
690
- pe = po.rendererEvents;
691
- pe && pe.dispatch(pe.lhold, ms);
692
- }
693
- this.dispatch(this.lhold, ms);
694
- } else {
695
- ms.leftButtonHold = true;
696
- if (po) {
697
- pe = po.rendererEvents;
698
- pe && pe.dispatch(pe.ldown, ms);
699
- }
700
- this.dispatch(this.ldown, ms);
701
- }
702
- }
703
-
704
- if (ms.rightButtonDown) {
705
- if (ms.rightButtonHold) {
706
- if (po) {
707
- pe = po.rendererEvents;
708
- pe && pe.dispatch(pe.rhold, ms);
709
- }
710
- this.dispatch(this.rhold, ms);
711
- } else {
712
- ms.rightButtonHold = true;
713
- if (po) {
714
- pe = po.rendererEvents;
715
- pe && pe.dispatch(pe.rdown, ms);
716
- }
717
- this.dispatch(this.rdown, ms);
718
- }
719
- }
720
-
721
- if (ms.middleButtonDown) {
722
- if (ms.middleButtonHold) {
723
- if (po) {
724
- pe = po.rendererEvents;
725
- pe && pe.dispatch(pe.mhold, ms);
726
- }
727
- this.dispatch(this.mhold, ms);
728
- } else {
729
- ms.middleButtonHold = true;
730
- if (po) {
731
- pe = po.rendererEvents;
732
- pe && pe.dispatch(pe.mdown, ms);
733
- }
734
- this.dispatch(this.mdown, ms);
735
- }
736
- }
737
-
738
- if (ms.leftButtonUp) {
739
- if (po) {
740
- pe = po.rendererEvents;
741
- pe && pe.dispatch(pe.lup, ms);
742
- }
743
- this.dispatch(this.lup, ms);
744
- ms.leftButtonUp = false;
745
- ms.leftButtonHold = false;
746
- }
747
-
748
- if (ms.rightButtonUp) {
749
- if (po) {
750
- pe = po.rendererEvents;
751
- pe && pe.dispatch(pe.rup, ms);
752
- }
753
- this.dispatch(this.rup, ms);
754
- ms.rightButtonUp = false;
755
- ms.rightButtonHold = false;
756
- }
757
-
758
- if (ms.middleButtonUp) {
759
- if (po) {
760
- pe = po.rendererEvents;
761
- pe && pe.dispatch(pe.mup, ms);
762
- }
763
- this.dispatch(this.mup, ms);
764
- ms.middleButtonUp = false;
765
- ms.middleButtonHold = false;
766
- }
767
-
768
- if (ms.leftButtonDoubleClick) {
769
- if (po) {
770
- pe = po.rendererEvents;
771
- pe && pe.dispatch(pe.ldblclick, ms);
772
- }
773
- this.dispatch(this.ldblclick, ms);
774
- ms.leftButtonDoubleClick = false;
775
- }
776
-
777
- if (ms.rightButtonDoubleClick) {
778
- if (po) {
779
- pe = po.rendererEvents;
780
- pe && pe.dispatch(pe.rdblclick, ms);
781
- }
782
- this.dispatch(this.rdblclick, ms);
783
- ms.rightButtonDoubleClick = false;
784
- }
785
-
786
- if (ms.middleButtonDoubleClick) {
787
- if (po) {
788
- pe = po.rendererEvents;
789
- pe && pe.dispatch(pe.mdblclick, ms);
790
- }
791
- this.dispatch(this.mdblclick, ms);
792
- ms.middleButtonDoubleClick = false;
793
- }
794
-
795
- if (ms.wheelDelta) {
796
- if (po) {
797
- pe = po.rendererEvents;
798
- pe && pe.dispatch(pe.mousewheel, ms);
799
- }
800
- this.dispatch(this.mousewheel, ms);
801
- }
802
-
803
- if (ms.moving) {
804
- if (po) {
805
- pe = po.rendererEvents;
806
- pe && pe.dispatch(pe.mousemove, ms);
807
- }
808
- this.dispatch(this.mousemove, ms);
809
- ms.prev_x = ms.x;
810
- ms.prev_y = ms.y;
811
- }
812
-
813
- if (ms.justStopped) {
814
- this.dispatch(this.mousestop, ms);
815
- }
816
- }
817
-
818
- /**
819
- * @private
820
- */
821
- handleTouchEvents() {
822
- var ts = this.touchState;
823
-
824
- var tpo = ts.pickingObject,
825
- tpe = null;
826
-
827
- if (ts.touchCancel) {
828
- this.dispatch(this.touchcancel, ts);
829
- ts.touchCancel = false;
830
- }
831
-
832
- if (ts.touchStart) {
833
- var r = this.renderer;
834
-
835
- r.pickingFramebuffer.activate();
836
- r.pickingFramebuffer.readPixels(r._currPickingColor, ts.nx, 1.0 - ts.ny, 1);
837
- r.pickingFramebuffer.deactivate();
838
-
839
- var o = r.colorObjects;
840
- var c = r._currPickingColor;
841
- var co = o[c[0] + "_" + c[1] + "_" + c[2]];
842
- tpo = ts.pickingObject = co;
843
- if (tpo) {
844
- tpe = tpo.rendererEvents;
845
- tpe && tpe.dispatch(tpe.touchstart, ts);
846
- }
847
- this.dispatch(this.touchstart, ts);
848
- ts.touchStart = false;
849
- }
850
-
851
- if (ts.doubleTouch) {
852
- if (tpo) {
853
- tpe = tpo.rendererEvents;
854
- tpe && tpe.dispatch(tpe.doubletouch, ts);
855
- }
856
- this.dispatch(this.doubletouch, ts);
857
- ts.doubleTouch = false;
858
- }
859
-
860
- if (ts.touchEnd) {
861
- if (tpo) {
862
- tpe = tpo.rendererEvents;
863
- tpe && tpe.dispatch(tpe.touchend, ts);
864
- }
865
- this.dispatch(this.touchend, ts);
866
- ts.x = 0;
867
- ts.y = 0;
868
- ts.touchEnd = false;
869
- }
870
-
871
- if (ts.moving) {
872
- if (tpo) {
873
- tpe = tpo.rendererEvents;
874
- tpe && tpe.dispatch(tpe.touchmove, ts);
875
- }
876
- this.dispatch(this.touchmove, ts);
877
- ts.prev_x = ts.x;
878
- ts.prev_y = ts.y;
879
- }
880
- }
881
- }
882
-
883
- const EVENT_NAMES = [
884
- /**
885
- * Triggered before scene frame is rendered(before render nodes).
886
- * @event og.RendererEvents#draw
887
- */
888
- "draw",
889
-
890
- /**
891
- * Triggered after scene frame is rendered(after render nodes).
892
- * @event og.RendererEvents#postdraw
893
- */
894
- "postdraw",
895
-
896
- /**
897
- * Triggered when screen is resized.
898
- * @event og.RendererEvents#resize
899
- */
900
- "resize",
901
-
902
- /**
903
- * Mouse enters the work screen
904
- * @event og.RendererEvents#mouseenter
905
- */
906
- "mouseenter",
907
-
908
- /**
909
- * Mouse leaves the work screen
910
- * @event og.RendererEvents#mouseleave
911
- */
912
- "mouseleave",
913
-
914
- /**
915
- * Mouse is moving.
916
- * @event og.RendererEvents#mousemove
917
- */
918
- "mousemove",
919
-
920
- /**
921
- * Mouse is just stopped.
922
- * @event og.RendererEvents#mousestop
923
- */
924
- "mousestop",
925
-
926
- /**
927
- * Mouse left button clicked.
928
- * @event og.RendererEvents#lclick
929
- */
930
- "lclick",
931
-
932
- /**
933
- * Mouse right button clicked.
934
- * @event og.RendererEvents#rclick
935
- */
936
- "rclick",
937
-
938
- /**
939
- * Mouse middle button clicked.
940
- * @event og.RendererEvents#mclick
941
- */
942
- "mclick",
943
-
944
- /**
945
- * Mouse left button double click.
946
- * @event og.RendererEvents#ldblclick
947
- */
948
- "ldblclick",
949
-
950
- /**
951
- * Mouse right button double click.
952
- * @event og.RendererEvents#rdblclick
953
- */
954
- "rdblclick",
955
-
956
- /**
957
- * Mouse middle button double click.
958
- * @event og.RendererEvents#mdblclick
959
- */
960
- "mdblclick",
961
-
962
- /**
963
- * Mouse left button up(stop pressing).
964
- * @event og.RendererEvents#lup
965
- */
966
- "lup",
967
-
968
- /**
969
- * Mouse right button up(stop pressing).
970
- * @event og.RendererEvents#rup
971
- */
972
- "rup",
973
-
974
- /**
975
- * Mouse middle button up(stop pressing).
976
- * @event og.RendererEvents#mup
977
- */
978
- "mup",
979
-
980
- /**
981
- * Mouse left button is just pressed down(start pressing).
982
- * @event og.RendererEvents#ldown
983
- */
984
- "ldown",
985
-
986
- /**
987
- * Mouse right button is just pressed down(start pressing).
988
- * @event og.RendererEvents#rdown
989
- */
990
- "rdown",
991
-
992
- /**
993
- * Mouse middle button is just pressed down(start pressing).
994
- * @event og.RendererEvents#mdown
995
- */
996
- "mdown",
997
-
998
- /**
999
- * Mouse left button is pressing.
1000
- * @event og.RendererEvents#lhold
1001
- */
1002
- "lhold",
1003
-
1004
- /**
1005
- * Mouse right button is pressing.
1006
- * @event og.RendererEvents#rhold
1007
- */
1008
- "rhold",
1009
-
1010
- /**
1011
- * Mouse middle button is pressing.
1012
- * @event og.RendererEvents#mhold
1013
- */
1014
- "mhold",
1015
-
1016
- /**
1017
- * Mouse wheel is rotated.
1018
- * @event og.RendererEvents#mousewheel
1019
- */
1020
- "mousewheel",
1021
-
1022
- /**
1023
- * Triggered when touching starts.
1024
- * @event og.RendererEvents#touchstart
1025
- */
1026
- "touchstart",
1027
-
1028
- /**
1029
- * Triggered when touching ends.
1030
- * @event og.RendererEvents#touchend
1031
- */
1032
- "touchend",
1033
-
1034
- /**
1035
- * Triggered when touching cancel.
1036
- * @event og.RendererEvents#touchcancel
1037
- */
1038
- "touchcancel",
1039
-
1040
- /**
1041
- * Triggered when touch is move.
1042
- * @event og.RendererEvents#touchmove
1043
- */
1044
- "touchmove",
1045
-
1046
- /**
1047
- * Triggered when double touch.
1048
- * @event og.RendererEvents#doubletouch
1049
- */
1050
- "doubletouch",
1051
-
1052
- /**
1053
- * Triggered when touch leaves picked object.
1054
- * @event og.RendererEvents#touchleave
1055
- */
1056
- "touchleave",
1057
-
1058
- /**
1059
- * Triggered when touch enter picking object.
1060
- * @event og.RendererEvents#touchenter
1061
- */
1062
- "touchenter"
1063
- ];
1064
-
1065
- export { RendererEvents };
1
+ /**
2
+ * @module og/renderer/RendererEvents
3
+ */
4
+
5
+ "use strict";
6
+
7
+ import { Events } from "../Events.js";
8
+ import { input } from "../input/input.js";
9
+ import { KeyboardHandler } from "../input/KeyboardHandler.js";
10
+ import { MouseHandler } from "../input/MouseHandler.js";
11
+ import { TouchHandler } from "../input/TouchHandler.js";
12
+ import { Vec2 } from "../math/Vec2.js";
13
+ import { Vec3 } from "../math/Vec3.js";
14
+
15
+ const LB_M = 0b0001;
16
+ const RB_M = 0b0010;
17
+ const MB_M = 0b0100;
18
+
19
+ /**
20
+ * Renderer events handler.
21
+ * @class
22
+ * @param {Renderer} renderer - Renderer object, events that works for.
23
+ */
24
+ class RendererEvents extends Events {
25
+ constructor(renderer) {
26
+ super(EVENT_NAMES);
27
+
28
+ /**
29
+ * Assigned renderer.
30
+ * @public
31
+ * @type {Renderer}
32
+ */
33
+ this.renderer = renderer;
34
+
35
+ /**
36
+ * Low level touch events handler.
37
+ * @private
38
+ * @type {input.TouchHandler}
39
+ */
40
+ this._touchHandler = new TouchHandler(renderer.handler.canvas);
41
+
42
+ /**
43
+ * Low level mouse events handler.
44
+ * @private
45
+ * @type {input.MouseHandler}
46
+ */
47
+ this._mouseHandler = new MouseHandler(renderer.handler.canvas);
48
+
49
+ /**
50
+ * Low level keyboard events handler.
51
+ * @private
52
+ * @type {input.KeyboardHandler}
53
+ */
54
+ this._keyboardHandler = new KeyboardHandler();
55
+
56
+ this._active = true;
57
+
58
+ this.clickRadius = 15;
59
+
60
+ /**
61
+ * Current mouse state.
62
+ * @public
63
+ * @enum {Object}
64
+ */
65
+ this.mouseState = {
66
+ /** Current screen mouse X position. */
67
+ clientX: 0,
68
+ /** Current screen mouse Y position. */
69
+ clientY: 0,
70
+ /** Current viewport mouse X position. */
71
+ x: 0,
72
+ /** Current viewport mouse Y position. */
73
+ y: 0,
74
+ /** Current mouse X position from 0 to 1 */
75
+ nx: 0,
76
+ /** Current mouse Y position from 0 to 1 */
77
+ ny: 0,
78
+ /** Previous mouse X position. */
79
+ prev_x: 0,
80
+ /** Previous mouse Y position. */
81
+ prev_y: 0,
82
+ /** Screen mouse position world direction. */
83
+ direction: new Vec3(),
84
+ /** Left mouse button has stopped pushing down right now.*/
85
+ leftButtonUp: false,
86
+ /** Right mouse button has stopped pushing down right now.*/
87
+ rightButtonUp: false,
88
+ /** Middle mouse button has stopped pushing down right now.*/
89
+ middleButtonUp: false,
90
+ /** Left mouse button has pushed now.*/
91
+ leftButtonDown: false,
92
+ /** Right mouse button has pushed now.*/
93
+ rightButtonDown: false,
94
+ /** Middle mouse button has pushed now.*/
95
+ middleButtonDown: false,
96
+ /** Left mouse button is pushing.*/
97
+ leftButtonHold: false,
98
+ /** Right mouse button is pushing.*/
99
+ rightButtonHold: false,
100
+ /** Middle mouse button is pushing.*/
101
+ middleButtonHold: false,
102
+ /** Left mouse button has clicked twice now.*/
103
+ leftButtonDoubleClick: false,
104
+ /** Right mouse button has clicked twice now.*/
105
+ rightButtonDoubleClick: false,
106
+ /** Middle mouse button has clicked twice now.*/
107
+ middleButtonDoubleClick: false,
108
+ /** Left mouse button has clicked now. */
109
+ leftButtonClick: false,
110
+ /** Right mouse button has clicked now. */
111
+ rightButtonClick: false,
112
+ /** Middle mouse button has clicked now. */
113
+ middleButtonClick: false,
114
+ /** Mouse is moving now. */
115
+ moving: false,
116
+ /** Mouse has just stopped now. */
117
+ justStopped: false,
118
+ /** Mose double click delay response time.*/
119
+ doubleClickDelay: 500,
120
+ /** Mose click delay response time.*/
121
+ clickDelay: 200,
122
+ /** Mouse wheel. */
123
+ wheelDelta: 0,
124
+ /** JavaScript mouse system event message. */
125
+ sys: null,
126
+ /** Current picking object. */
127
+ pickingObject: null,
128
+ /** Renderer instanve. */
129
+ renderer: renderer
130
+ };
131
+
132
+ /**
133
+ * Current touch state.
134
+ * @public
135
+ * @enum {Object}
136
+ */
137
+ this.touchState = {
138
+ /** Touching is moving now. */
139
+ moving: false,
140
+ /** Touch has ended right now.*/
141
+ touchEnd: false,
142
+ /** Touch has started right now.*/
143
+ touchStart: false,
144
+ /** Touch canceled.*/
145
+ touchCancel: false,
146
+ /** Touched twice.*/
147
+ doubleTouch: false,
148
+ /** Double touching responce delay.*/
149
+ doubleTouchDelay: 550,
150
+ /** Double touching responce radius in screen pixels.*/
151
+ doubleTouchRadius: 10,
152
+ /** Current touch X - coordinate. */
153
+ x: 0,
154
+ /** Current touch Y - coordinate. */
155
+ y: 0,
156
+ /** Current touch X - coordinate from 0 to 1 */
157
+ nx: 0,
158
+ /** Current touch Y - coordinate from 0 to 1 */
159
+ ny: 0,
160
+ /** Previous touch X coordinate. */
161
+ prev_x: 0,
162
+ /** Previous touch Y coordinate. */
163
+ prev_y: 0,
164
+ /** Screen touch position world direction. */
165
+ direction: new Vec3(),
166
+ /** JavaScript touching system event message. */
167
+ sys: null,
168
+ /** Current touched(picking) object. */
169
+ pickingObject: null,
170
+ /** Renderer instanve. */
171
+ renderer: renderer
172
+ };
173
+
174
+ this._dblTchCoords = new Vec2();
175
+ this._oneTouchStart = false;
176
+ this._dblTchBegins = 0;
177
+ /**
178
+ * @type {number}
179
+ */
180
+ this._mousestopThread = null;
181
+ this._ldblClkBegins = 0;
182
+ this._rdblClkBegins = 0;
183
+ this._mdblClkBegins = 0;
184
+ this._lClkBegins = 0;
185
+ this._rClkBegins = 0;
186
+ this._mClkBegins = 0;
187
+ this._lclickX = 0;
188
+ this._lclickY = 0;
189
+ this._rclickX = 0;
190
+ this._rclickY = 0;
191
+ this._mclickX = 0;
192
+ this._mclickY = 0;
193
+ }
194
+
195
+ pointerEvent() {
196
+ let ms = this.mouseState,
197
+ ts = this.touchState;
198
+ return (
199
+ ms.moving ||
200
+ ms.justStopped ||
201
+ ms.wheelDelta ||
202
+ ts.moving ||
203
+ ts.touchStart ||
204
+ ts.touchEnd
205
+ )
206
+ }
207
+
208
+ get active() {
209
+ return this._active;
210
+ }
211
+
212
+ set active(act) {
213
+ this._active = act;
214
+ this._keyboardHandler.setActivity(act);
215
+ }
216
+
217
+ /**
218
+ * Used in render node frame.
219
+ * @public
220
+ */
221
+ handleEvents() {
222
+ if (this._active) {
223
+ this.mouseState.direction = this.renderer.activeCamera.unproject(
224
+ this.mouseState.x,
225
+ this.mouseState.y
226
+ );
227
+ //
228
+ // TODO: Replace in some other place with a thought that we do
229
+ // not need to make unproject when we do not make touching
230
+ this.touchState.direction = this.renderer.activeCamera.unproject(
231
+ this.touchState.x,
232
+ this.touchState.y
233
+ );
234
+ this.entityPickingEvents();
235
+ this._keyboardHandler.handleEvents();
236
+ this.handleMouseEvents();
237
+ this.handleTouchEvents();
238
+ }
239
+ }
240
+
241
+ /**
242
+ * Set render event callback.
243
+ * @public
244
+ * @param {string} name - Event name
245
+ * @param {eventCallback} callback - Callback function
246
+ * @param {number} [key] - Key code from og.input
247
+ * @param {*} sender - Callback context
248
+ * @param {number} [priority] - Event callback priority
249
+ */
250
+ on(name, p0, p1, p2, p3) {
251
+ if (name === "keypress" || name === "charkeypress" || name === "keyfree") {
252
+ this._keyboardHandler.addEvent(name, p2, p1, p0, p3);
253
+ } else {
254
+ super.on(name, p0, p1, p2);
255
+ }
256
+ }
257
+
258
+ /**
259
+ * TODO: DOESNT WORK!!!
260
+ * @param {any} name
261
+ * @param {any} callback
262
+ */
263
+ off(name, callback) {
264
+ if (name === "keypress" || name === "charkeypress" || name === "keyfree") {
265
+ this._keyboardHandler.removeEvent(name, callback);
266
+ } else {
267
+ super.off(name, callback);
268
+ }
269
+ }
270
+
271
+ /**
272
+ * Check key is pressed.
273
+ * @public
274
+ * @param {number} keyCode - Key code
275
+ * @return {boolean}
276
+ */
277
+ isKeyPressed(keyCode) {
278
+ return this._keyboardHandler.isKeyPressed(keyCode);
279
+ }
280
+
281
+ releaseKeys() {
282
+ this._keyboardHandler.releaseKeys();
283
+ }
284
+
285
+ /**
286
+ * Renderer events initialization.
287
+ * @public
288
+ */
289
+ initialize() {
290
+ this._mouseHandler.setEvent("mouseup", this, this.onMouseUp);
291
+ this._mouseHandler.setEvent("mousemove", this, this.onMouseMove);
292
+ this._mouseHandler.setEvent("mousedown", this, this.onMouseDown);
293
+ this._mouseHandler.setEvent("mousewheel", this, this.onMouseWheel);
294
+ this._mouseHandler.setEvent("mouseleave", this, this.onMouseLeave);
295
+ this._mouseHandler.setEvent("mouseenter", this, this.onMouseEnter);
296
+
297
+ this._touchHandler.setEvent("touchstart", this, this.onTouchStart);
298
+ this._touchHandler.setEvent("touchend", this, this.onTouchEnd);
299
+ this._touchHandler.setEvent("touchcancel", this, this.onTouchCancel);
300
+ this._touchHandler.setEvent("touchmove", this, this.onTouchMove);
301
+ }
302
+
303
+ /**
304
+ * @private
305
+ */
306
+ onMouseWheel(event) {
307
+ this.mouseState.wheelDelta = event.wheelDelta;
308
+ }
309
+
310
+ /**
311
+ * @protected
312
+ */
313
+ updateButtonsStates(buttons) {
314
+ var ms = this.mouseState;
315
+ if (buttons & LB_M) {
316
+ ms.leftButtonDown = true;
317
+ } else {
318
+ ms.leftButtonHold = false;
319
+ ms.leftButtonDown = false;
320
+ }
321
+
322
+ if (buttons & RB_M) {
323
+ ms.rightButtonDown = true;
324
+ } else {
325
+ ms.rightButtonHold = false;
326
+ ms.rightButtonDown = false;
327
+ }
328
+
329
+ if (buttons & MB_M) {
330
+ ms.middleButtonDown = true;
331
+ } else {
332
+ ms.middleButtonHold = false;
333
+ ms.middleButtonDown = false;
334
+ }
335
+ }
336
+
337
+ /**
338
+ * @private
339
+ */
340
+ onMouseMove(event, sys) {
341
+ var ms = this.mouseState;
342
+ this.updateButtonsStates(sys.buttons);
343
+ ms.sys = event;
344
+
345
+ let ex = event.clientX,
346
+ ey = event.clientY,
347
+ r = this.clickRadius;
348
+
349
+ if (Math.abs(this._lclickX - ex) >= r && Math.abs(this._lclickY - ey) >= r) {
350
+ this._ldblClkBegins = 0;
351
+ this._lClkBegins = 0;
352
+ }
353
+
354
+ if (Math.abs(this._rclickX - ex) >= r && Math.abs(this._rclickY - ey) >= r) {
355
+ this._rdblClkBegins = 0;
356
+ this._rClkBegins = 0;
357
+ }
358
+
359
+ if (Math.abs(this._mclickX - ex) >= r && Math.abs(this._mclickY - ey) >= r) {
360
+ this._mdblClkBegins = 0;
361
+ this._mClkBegins = 0;
362
+ }
363
+
364
+ if (ms.clientX === event.clientX && ms.clientY === event.clientY) {
365
+ return;
366
+ }
367
+
368
+ ms.clientX = event.clientX;
369
+ ms.clientY = event.clientY;
370
+
371
+ let h = this.renderer.handler;
372
+
373
+ ms.x = event.clientX * h.pixelRatio;
374
+ ms.y = event.clientY * h.pixelRatio;
375
+
376
+ ms.nx = ms.x / h.canvas.width;
377
+ ms.ny = ms.y / h.canvas.height;
378
+
379
+ ms.moving = true;
380
+
381
+ //dispatch stop mouse event
382
+ clearTimeout(this._mousestopThread);
383
+ this._mousestopThread = setTimeout(function () {
384
+ ms.justStopped = true;
385
+ }, 100);
386
+ }
387
+
388
+ onMouseLeave(event) {
389
+ this.dispatch(this.mouseleave, event);
390
+ }
391
+
392
+ onMouseEnter(event) {
393
+ this.dispatch(this.mouseenter, event);
394
+ }
395
+
396
+ /**
397
+ * @private
398
+ */
399
+ onMouseDown(event) {
400
+ if (event.button === input.MB_LEFT) {
401
+ this._lClkBegins = window.performance.now();
402
+ this._lclickX = event.clientX;
403
+ this._lclickY = event.clientY;
404
+ this.mouseState.sys = event;
405
+ this.mouseState.leftButtonDown = true;
406
+ } else if (event.button === input.MB_RIGHT) {
407
+ this._rClkBegins = window.performance.now();
408
+ this._rclickX = event.clientX;
409
+ this._rclickY = event.clientY;
410
+ this.mouseState.sys = event;
411
+ this.mouseState.rightButtonDown = true;
412
+ } else if (event.button === input.MB_MIDDLE) {
413
+ this._mClkBegins = window.performance.now();
414
+ this._mclickX = event.clientX;
415
+ this._mclickY = event.clientY;
416
+ this.mouseState.sys = event;
417
+ this.mouseState.middleButtonDown = true;
418
+ }
419
+ }
420
+
421
+ /**
422
+ * @private
423
+ */
424
+ onMouseUp(event) {
425
+ var ms = this.mouseState;
426
+ ms.sys = event;
427
+ var t = window.performance.now();
428
+
429
+ if (event.button === input.MB_LEFT) {
430
+ ms.leftButtonDown = false;
431
+ ms.leftButtonUp = true;
432
+
433
+ if (
434
+ Math.abs(this._lclickX - event.clientX) < this.clickRadius &&
435
+ Math.abs(this._lclickY - event.clientY) < this.clickRadius &&
436
+ t - this._lClkBegins <= ms.clickDelay
437
+ ) {
438
+ if (this._ldblClkBegins) {
439
+ let deltatime = window.performance.now() - this._ldblClkBegins;
440
+ if (deltatime <= ms.doubleClickDelay) {
441
+ ms.leftButtonDoubleClick = true;
442
+ }
443
+ this._ldblClkBegins = 0;
444
+ } else {
445
+ this._ldblClkBegins = window.performance.now();
446
+ }
447
+
448
+ ms.leftButtonClick = true;
449
+ this._lClkBegins = 0;
450
+ }
451
+ } else if (event.button === input.MB_RIGHT) {
452
+ ms.rightButtonDown = false;
453
+ ms.rightButtonUp = true;
454
+
455
+ if (
456
+ Math.abs(this._rclickX - event.clientX) < this.clickRadius &&
457
+ Math.abs(this._rclickY - event.clientY) < this.clickRadius &&
458
+ t - this._rClkBegins <= ms.clickDelay
459
+ ) {
460
+ if (this._rdblClkBegins) {
461
+ let deltatime = window.performance.now() - this._rdblClkBegins;
462
+ if (deltatime <= ms.doubleClickDelay) {
463
+ ms.rightButtonDoubleClick = true;
464
+ }
465
+ this._rdblClkBegins = 0;
466
+ } else {
467
+ this._rdblClkBegins = window.performance.now();
468
+ }
469
+
470
+ ms.rightButtonClick = true;
471
+ this._rClkBegins = 0;
472
+ }
473
+ } else if (event.button === input.MB_MIDDLE) {
474
+ ms.middleButtonDown = false;
475
+ ms.middleButtonUp = true;
476
+
477
+ if (
478
+ Math.abs(this._mclickX - event.clientX) < this.clickRadius &&
479
+ Math.abs(this._mclickY - event.clientY) < this.clickRadius &&
480
+ t - this._mClkBegins <= ms.clickDelay
481
+ ) {
482
+ if (this._mdblClkBegins) {
483
+ var deltatime = window.performance.now() - this._mdblClkBegins;
484
+ if (deltatime <= ms.doubleClickDelay) {
485
+ ms.middleButtonDoubleClick = true;
486
+ }
487
+ this._mdblClkBegins = 0;
488
+ } else {
489
+ this._mdblClkBegins = window.performance.now();
490
+ }
491
+
492
+ ms.middleButtonClick = true;
493
+ this._mClkBegins = 0;
494
+ }
495
+ }
496
+ }
497
+
498
+ /**
499
+ * @private
500
+ */
501
+ onTouchStart(event) {
502
+ var ts = this.touchState;
503
+ ts.sys = event;
504
+
505
+ ts.clientX = event.touches.item(0).clientX - event.offsetLeft;
506
+ ts.clientY = event.touches.item(0).clientY - event.offsetTop;
507
+
508
+ let h = this.renderer.handler;
509
+
510
+ ts.x = ts.clientX * h.pixelRatio;
511
+ ts.y = ts.clientY * h.pixelRatio;
512
+
513
+ ts.nx = ts.x / h.canvas.width;
514
+ ts.ny = ts.y / h.canvas.height;
515
+ ts.prev_x = ts.x;
516
+ ts.prev_y = ts.y;
517
+ ts.touchStart = true;
518
+
519
+ if (event.touches.length === 1) {
520
+ this._dblTchCoords.x = ts.x;
521
+ this._dblTchCoords.y = ts.y;
522
+ this._oneTouchStart = true;
523
+ } else {
524
+ this._oneTouchStart = false;
525
+ }
526
+ }
527
+
528
+ /**
529
+ * @private
530
+ */
531
+ onTouchEnd(event) {
532
+ var ts = this.touchState;
533
+ ts.sys = event;
534
+ ts.touchEnd = true;
535
+
536
+ if (event.touches.length === 0) {
537
+ ts.prev_x = ts.x;
538
+ ts.prev_y = ts.y;
539
+
540
+ if (this._oneTouchStart) {
541
+ if (this._dblTchBegins) {
542
+ var deltatime = window.performance.now() - this._dblTchBegins;
543
+ if (deltatime <= ts.doubleTouchDelay) {
544
+ ts.doubleTouch = true;
545
+ }
546
+ this._dblTchBegins = 0;
547
+ }
548
+ this._dblTchBegins = window.performance.now();
549
+ this._oneTouchStart = false;
550
+ }
551
+ }
552
+ }
553
+
554
+ /**
555
+ * @private
556
+ */
557
+ onTouchCancel(event) {
558
+ var ts = this.touchState;
559
+ ts.sys = event;
560
+ ts.touchCancel = true;
561
+ }
562
+
563
+ /**
564
+ * @private
565
+ */
566
+ onTouchMove(event) {
567
+ var ts = this.touchState;
568
+ ts.clientX = event.touches.item(0).clientX - event.offsetLeft;
569
+ ts.clientY = event.touches.item(0).clientY - event.offsetTop;
570
+
571
+ var h = this.renderer.handler;
572
+
573
+ ts.x = ts.clientX * h.pixelRatio;
574
+ ts.y = ts.clientY * h.pixelRatio;
575
+
576
+ ts.nx = ts.x / h.canvas.width;
577
+ ts.ny = ts.y / h.canvas.height;
578
+
579
+ ts.sys = event;
580
+ ts.moving = true;
581
+
582
+ var dX = ts.x - ts.prev_x
583
+ var dY = ts.y - ts.prev_y
584
+ if (Math.abs(dX) > 9 || Math.abs(dY) > 9) {
585
+ this._dblTchBegins = 0;
586
+ this._oneTouchStart = false;
587
+ }
588
+ }
589
+
590
+ /**
591
+ * @private
592
+ */
593
+ entityPickingEvents() {
594
+ var ts = this.touchState,
595
+ ms = this.mouseState;
596
+
597
+ if (!(ms.leftButtonHold || ms.rightButtonHold || ms.middleButtonHold)) {
598
+ var r = this.renderer;
599
+
600
+ var o = r.colorObjects;
601
+
602
+ var c = r._currPickingColor,
603
+ p = r._prevPickingColor;
604
+
605
+ ms.pickingObject = null;
606
+ ts.pickingObject = null;
607
+
608
+ var co = o && o[c[0] + "_" + c[1] + "_" + c[2]];
609
+
610
+ ms.pickingObject = co;
611
+ ts.pickingObject = co;
612
+
613
+ //object changed
614
+ if (c[0] != p[0] || c[1] != p[1] || c[2] != p[2]) {
615
+ //current black
616
+ if (!(c[0] || c[1] || c[2])) {
617
+ let po = o[p[0] + "_" + p[1] + "_" + p[2]];
618
+ if (po) {
619
+ let pe = po.rendererEvents;
620
+ ms.pickingObject = po;
621
+ pe && pe.dispatch(pe.mouseleave, ms);
622
+ ts.pickingObject = po;
623
+ pe && pe.dispatch(pe.touchleave, ts);
624
+ }
625
+ } else {
626
+ //current not black
627
+
628
+ //previous not black
629
+ if (p[0] || p[1] || p[2]) {
630
+ let po = o[p[0] + "_" + p[1] + "_" + p[2]];
631
+ if (po) {
632
+ let pe = po.rendererEvents;
633
+ ms.pickingObject = po;
634
+ pe && pe.dispatch(pe.mouseleave, ms);
635
+ ts.pickingObject = po;
636
+ pe && pe.dispatch(pe.touchleave, ts);
637
+ }
638
+ }
639
+
640
+ if (co) {
641
+ var ce = co.rendererEvents;
642
+ ms.pickingObject = co;
643
+ ce && ce.dispatch(ce.mouseenter, ms);
644
+ ts.pickingObject = co;
645
+ ce && ce.dispatch(ce.touchenter, ts);
646
+ }
647
+ }
648
+ }
649
+ }
650
+ }
651
+
652
+ /**
653
+ * @private
654
+ */
655
+ handleMouseEvents() {
656
+ let ms = this.mouseState;
657
+ let po = ms.pickingObject,
658
+ pe = null;
659
+
660
+ if (ms.leftButtonClick) {
661
+ if (po) {
662
+ pe = po.rendererEvents;
663
+ pe && pe.dispatch(pe.lclick, ms);
664
+ }
665
+ this.dispatch(this.lclick, ms);
666
+ ms.leftButtonClick = false;
667
+ }
668
+
669
+ if (ms.rightButtonClick) {
670
+ if (po) {
671
+ pe = po.rendererEvents;
672
+ pe && pe.dispatch(pe.rclick, ms);
673
+ }
674
+ this.dispatch(this.rclick, ms);
675
+ ms.rightButtonClick = false;
676
+ }
677
+
678
+ if (ms.middleButtonClick) {
679
+ if (po) {
680
+ pe = po.rendererEvents;
681
+ pe && pe.dispatch(pe.mclick, ms);
682
+ }
683
+ this.dispatch(this.mclick, ms);
684
+ ms.middleButtonClick = false;
685
+ }
686
+
687
+ if (ms.leftButtonDown) {
688
+ if (ms.leftButtonHold) {
689
+ if (po) {
690
+ pe = po.rendererEvents;
691
+ pe && pe.dispatch(pe.lhold, ms);
692
+ }
693
+ this.dispatch(this.lhold, ms);
694
+ } else {
695
+ ms.leftButtonHold = true;
696
+ if (po) {
697
+ pe = po.rendererEvents;
698
+ pe && pe.dispatch(pe.ldown, ms);
699
+ }
700
+ this.dispatch(this.ldown, ms);
701
+ }
702
+ }
703
+
704
+ if (ms.rightButtonDown) {
705
+ if (ms.rightButtonHold) {
706
+ if (po) {
707
+ pe = po.rendererEvents;
708
+ pe && pe.dispatch(pe.rhold, ms);
709
+ }
710
+ this.dispatch(this.rhold, ms);
711
+ } else {
712
+ ms.rightButtonHold = true;
713
+ if (po) {
714
+ pe = po.rendererEvents;
715
+ pe && pe.dispatch(pe.rdown, ms);
716
+ }
717
+ this.dispatch(this.rdown, ms);
718
+ }
719
+ }
720
+
721
+ if (ms.middleButtonDown) {
722
+ if (ms.middleButtonHold) {
723
+ if (po) {
724
+ pe = po.rendererEvents;
725
+ pe && pe.dispatch(pe.mhold, ms);
726
+ }
727
+ this.dispatch(this.mhold, ms);
728
+ } else {
729
+ ms.middleButtonHold = true;
730
+ if (po) {
731
+ pe = po.rendererEvents;
732
+ pe && pe.dispatch(pe.mdown, ms);
733
+ }
734
+ this.dispatch(this.mdown, ms);
735
+ }
736
+ }
737
+
738
+ if (ms.leftButtonUp) {
739
+ if (po) {
740
+ pe = po.rendererEvents;
741
+ pe && pe.dispatch(pe.lup, ms);
742
+ }
743
+ this.dispatch(this.lup, ms);
744
+ ms.leftButtonUp = false;
745
+ ms.leftButtonHold = false;
746
+ }
747
+
748
+ if (ms.rightButtonUp) {
749
+ if (po) {
750
+ pe = po.rendererEvents;
751
+ pe && pe.dispatch(pe.rup, ms);
752
+ }
753
+ this.dispatch(this.rup, ms);
754
+ ms.rightButtonUp = false;
755
+ ms.rightButtonHold = false;
756
+ }
757
+
758
+ if (ms.middleButtonUp) {
759
+ if (po) {
760
+ pe = po.rendererEvents;
761
+ pe && pe.dispatch(pe.mup, ms);
762
+ }
763
+ this.dispatch(this.mup, ms);
764
+ ms.middleButtonUp = false;
765
+ ms.middleButtonHold = false;
766
+ }
767
+
768
+ if (ms.leftButtonDoubleClick) {
769
+ if (po) {
770
+ pe = po.rendererEvents;
771
+ pe && pe.dispatch(pe.ldblclick, ms);
772
+ }
773
+ this.dispatch(this.ldblclick, ms);
774
+ ms.leftButtonDoubleClick = false;
775
+ }
776
+
777
+ if (ms.rightButtonDoubleClick) {
778
+ if (po) {
779
+ pe = po.rendererEvents;
780
+ pe && pe.dispatch(pe.rdblclick, ms);
781
+ }
782
+ this.dispatch(this.rdblclick, ms);
783
+ ms.rightButtonDoubleClick = false;
784
+ }
785
+
786
+ if (ms.middleButtonDoubleClick) {
787
+ if (po) {
788
+ pe = po.rendererEvents;
789
+ pe && pe.dispatch(pe.mdblclick, ms);
790
+ }
791
+ this.dispatch(this.mdblclick, ms);
792
+ ms.middleButtonDoubleClick = false;
793
+ }
794
+
795
+ if (ms.wheelDelta) {
796
+ if (po) {
797
+ pe = po.rendererEvents;
798
+ pe && pe.dispatch(pe.mousewheel, ms);
799
+ }
800
+ this.dispatch(this.mousewheel, ms);
801
+ }
802
+
803
+ if (ms.moving) {
804
+ if (po) {
805
+ pe = po.rendererEvents;
806
+ pe && pe.dispatch(pe.mousemove, ms);
807
+ }
808
+ this.dispatch(this.mousemove, ms);
809
+ ms.prev_x = ms.x;
810
+ ms.prev_y = ms.y;
811
+ }
812
+
813
+ if (ms.justStopped) {
814
+ this.dispatch(this.mousestop, ms);
815
+ }
816
+ }
817
+
818
+ /**
819
+ * @private
820
+ */
821
+ handleTouchEvents() {
822
+ var ts = this.touchState;
823
+
824
+ var tpo = ts.pickingObject,
825
+ tpe = null;
826
+
827
+ if (ts.touchCancel) {
828
+ this.dispatch(this.touchcancel, ts);
829
+ ts.touchCancel = false;
830
+ }
831
+
832
+ if (ts.touchStart) {
833
+ var r = this.renderer;
834
+
835
+ r.pickingFramebuffer.activate();
836
+ r.pickingFramebuffer.readPixels(r._currPickingColor, ts.nx, 1.0 - ts.ny, 1);
837
+ r.pickingFramebuffer.deactivate();
838
+
839
+ var o = r.colorObjects;
840
+ var c = r._currPickingColor;
841
+ var co = o[c[0] + "_" + c[1] + "_" + c[2]];
842
+ tpo = ts.pickingObject = co;
843
+ if (tpo) {
844
+ tpe = tpo.rendererEvents;
845
+ tpe && tpe.dispatch(tpe.touchstart, ts);
846
+ }
847
+ this.dispatch(this.touchstart, ts);
848
+ ts.touchStart = false;
849
+ }
850
+
851
+ if (ts.doubleTouch) {
852
+ if (tpo) {
853
+ tpe = tpo.rendererEvents;
854
+ tpe && tpe.dispatch(tpe.doubletouch, ts);
855
+ }
856
+ this.dispatch(this.doubletouch, ts);
857
+ ts.doubleTouch = false;
858
+ }
859
+
860
+ if (ts.touchEnd) {
861
+ if (tpo) {
862
+ tpe = tpo.rendererEvents;
863
+ tpe && tpe.dispatch(tpe.touchend, ts);
864
+ }
865
+ this.dispatch(this.touchend, ts);
866
+ ts.x = 0;
867
+ ts.y = 0;
868
+ ts.touchEnd = false;
869
+ }
870
+
871
+ if (ts.moving) {
872
+ if (tpo) {
873
+ tpe = tpo.rendererEvents;
874
+ tpe && tpe.dispatch(tpe.touchmove, ts);
875
+ }
876
+ this.dispatch(this.touchmove, ts);
877
+ ts.prev_x = ts.x;
878
+ ts.prev_y = ts.y;
879
+ }
880
+ }
881
+ }
882
+
883
+ const EVENT_NAMES = [
884
+ /**
885
+ * Triggered before scene frame is rendered(before render nodes).
886
+ * @event og.RendererEvents#draw
887
+ */
888
+ "draw",
889
+
890
+ /**
891
+ * Triggered after scene frame is rendered(after render nodes).
892
+ * @event og.RendererEvents#postdraw
893
+ */
894
+ "postdraw",
895
+
896
+ /**
897
+ * Triggered when screen is resized.
898
+ * @event og.RendererEvents#resize
899
+ */
900
+ "resize",
901
+
902
+ /**
903
+ * Mouse enters the work screen
904
+ * @event og.RendererEvents#mouseenter
905
+ */
906
+ "mouseenter",
907
+
908
+ /**
909
+ * Mouse leaves the work screen
910
+ * @event og.RendererEvents#mouseleave
911
+ */
912
+ "mouseleave",
913
+
914
+ /**
915
+ * Mouse is moving.
916
+ * @event og.RendererEvents#mousemove
917
+ */
918
+ "mousemove",
919
+
920
+ /**
921
+ * Mouse is just stopped.
922
+ * @event og.RendererEvents#mousestop
923
+ */
924
+ "mousestop",
925
+
926
+ /**
927
+ * Mouse left button clicked.
928
+ * @event og.RendererEvents#lclick
929
+ */
930
+ "lclick",
931
+
932
+ /**
933
+ * Mouse right button clicked.
934
+ * @event og.RendererEvents#rclick
935
+ */
936
+ "rclick",
937
+
938
+ /**
939
+ * Mouse middle button clicked.
940
+ * @event og.RendererEvents#mclick
941
+ */
942
+ "mclick",
943
+
944
+ /**
945
+ * Mouse left button double click.
946
+ * @event og.RendererEvents#ldblclick
947
+ */
948
+ "ldblclick",
949
+
950
+ /**
951
+ * Mouse right button double click.
952
+ * @event og.RendererEvents#rdblclick
953
+ */
954
+ "rdblclick",
955
+
956
+ /**
957
+ * Mouse middle button double click.
958
+ * @event og.RendererEvents#mdblclick
959
+ */
960
+ "mdblclick",
961
+
962
+ /**
963
+ * Mouse left button up(stop pressing).
964
+ * @event og.RendererEvents#lup
965
+ */
966
+ "lup",
967
+
968
+ /**
969
+ * Mouse right button up(stop pressing).
970
+ * @event og.RendererEvents#rup
971
+ */
972
+ "rup",
973
+
974
+ /**
975
+ * Mouse middle button up(stop pressing).
976
+ * @event og.RendererEvents#mup
977
+ */
978
+ "mup",
979
+
980
+ /**
981
+ * Mouse left button is just pressed down(start pressing).
982
+ * @event og.RendererEvents#ldown
983
+ */
984
+ "ldown",
985
+
986
+ /**
987
+ * Mouse right button is just pressed down(start pressing).
988
+ * @event og.RendererEvents#rdown
989
+ */
990
+ "rdown",
991
+
992
+ /**
993
+ * Mouse middle button is just pressed down(start pressing).
994
+ * @event og.RendererEvents#mdown
995
+ */
996
+ "mdown",
997
+
998
+ /**
999
+ * Mouse left button is pressing.
1000
+ * @event og.RendererEvents#lhold
1001
+ */
1002
+ "lhold",
1003
+
1004
+ /**
1005
+ * Mouse right button is pressing.
1006
+ * @event og.RendererEvents#rhold
1007
+ */
1008
+ "rhold",
1009
+
1010
+ /**
1011
+ * Mouse middle button is pressing.
1012
+ * @event og.RendererEvents#mhold
1013
+ */
1014
+ "mhold",
1015
+
1016
+ /**
1017
+ * Mouse wheel is rotated.
1018
+ * @event og.RendererEvents#mousewheel
1019
+ */
1020
+ "mousewheel",
1021
+
1022
+ /**
1023
+ * Triggered when touching starts.
1024
+ * @event og.RendererEvents#touchstart
1025
+ */
1026
+ "touchstart",
1027
+
1028
+ /**
1029
+ * Triggered when touching ends.
1030
+ * @event og.RendererEvents#touchend
1031
+ */
1032
+ "touchend",
1033
+
1034
+ /**
1035
+ * Triggered when touching cancel.
1036
+ * @event og.RendererEvents#touchcancel
1037
+ */
1038
+ "touchcancel",
1039
+
1040
+ /**
1041
+ * Triggered when touch is move.
1042
+ * @event og.RendererEvents#touchmove
1043
+ */
1044
+ "touchmove",
1045
+
1046
+ /**
1047
+ * Triggered when double touch.
1048
+ * @event og.RendererEvents#doubletouch
1049
+ */
1050
+ "doubletouch",
1051
+
1052
+ /**
1053
+ * Triggered when touch leaves picked object.
1054
+ * @event og.RendererEvents#touchleave
1055
+ */
1056
+ "touchleave",
1057
+
1058
+ /**
1059
+ * Triggered when touch enter picking object.
1060
+ * @event og.RendererEvents#touchenter
1061
+ */
1062
+ "touchenter"
1063
+ ];
1064
+
1065
+ export { RendererEvents };