melonjs 10.2.0 → 10.3.0

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 (95) hide show
  1. package/README.md +1 -1
  2. package/dist/melonjs.js +4435 -4283
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +3348 -3833
  5. package/dist/melonjs.module.js +4025 -3920
  6. package/package.json +13 -14
  7. package/src/audio/audio.js +45 -45
  8. package/src/camera/camera2d.js +78 -101
  9. package/src/entity/draggable.js +21 -29
  10. package/src/entity/droptarget.js +24 -31
  11. package/src/entity/entity.js +34 -38
  12. package/src/game.js +8 -8
  13. package/src/{shapes → geometries}/ellipse.js +46 -46
  14. package/src/{shapes → geometries}/line.js +14 -14
  15. package/src/{shapes → geometries}/poly.js +103 -54
  16. package/src/{shapes → geometries}/rectangle.js +73 -120
  17. package/src/index.js +18 -19
  18. package/src/input/gamepad.js +20 -20
  19. package/src/input/input.js +3 -3
  20. package/src/input/keyboard.js +122 -124
  21. package/src/input/pointer.js +102 -62
  22. package/src/input/pointerevent.js +97 -42
  23. package/src/lang/deprecated.js +29 -18
  24. package/src/level/level.js +34 -26
  25. package/src/level/tiled/TMXGroup.js +12 -13
  26. package/src/level/tiled/TMXLayer.js +41 -42
  27. package/src/level/tiled/TMXObject.js +76 -70
  28. package/src/level/tiled/TMXTile.js +13 -15
  29. package/src/level/tiled/TMXTileMap.js +26 -25
  30. package/src/level/tiled/TMXTileset.js +14 -15
  31. package/src/level/tiled/TMXTilesetGroup.js +5 -6
  32. package/src/level/tiled/TMXUtils.js +13 -11
  33. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
  34. package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
  35. package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
  36. package/src/level/tiled/renderer/TMXRenderer.js +18 -19
  37. package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
  38. package/src/loader/loader.js +46 -40
  39. package/src/loader/loadingscreen.js +7 -7
  40. package/src/math/color.js +68 -88
  41. package/src/math/math.js +33 -33
  42. package/src/math/matrix2.js +70 -71
  43. package/src/math/matrix3.js +90 -91
  44. package/src/math/observable_vector2.js +91 -92
  45. package/src/math/observable_vector3.js +110 -106
  46. package/src/math/vector2.js +116 -104
  47. package/src/math/vector3.js +129 -110
  48. package/src/particles/emitter.js +116 -126
  49. package/src/particles/particle.js +4 -5
  50. package/src/particles/particlecontainer.js +2 -3
  51. package/src/physics/body.js +82 -83
  52. package/src/physics/bounds.js +64 -66
  53. package/src/physics/collision.js +21 -22
  54. package/src/physics/detector.js +13 -13
  55. package/src/physics/quadtree.js +26 -25
  56. package/src/physics/sat.js +21 -21
  57. package/src/physics/world.js +23 -22
  58. package/src/plugin/plugin.js +12 -13
  59. package/src/renderable/GUI.js +20 -26
  60. package/src/renderable/collectable.js +6 -7
  61. package/src/renderable/colorlayer.js +11 -12
  62. package/src/renderable/container.js +98 -81
  63. package/src/renderable/imagelayer.js +33 -35
  64. package/src/renderable/nineslicesprite.js +15 -16
  65. package/src/renderable/renderable.js +112 -111
  66. package/src/renderable/sprite.js +71 -58
  67. package/src/renderable/trigger.js +17 -19
  68. package/src/state/stage.js +14 -15
  69. package/src/state/state.js +78 -78
  70. package/src/system/device.js +137 -180
  71. package/src/system/event.js +116 -104
  72. package/src/system/pooling.js +15 -15
  73. package/src/system/save.js +9 -6
  74. package/src/system/timer.js +33 -33
  75. package/src/text/bitmaptext.js +39 -46
  76. package/src/text/bitmaptextdata.js +14 -15
  77. package/src/text/text.js +55 -58
  78. package/src/tweens/easing.js +5 -5
  79. package/src/tweens/interpolation.js +5 -5
  80. package/src/tweens/tween.js +49 -40
  81. package/src/utils/agent.js +12 -11
  82. package/src/utils/array.js +8 -8
  83. package/src/utils/file.js +7 -7
  84. package/src/utils/function.js +8 -8
  85. package/src/utils/string.js +19 -19
  86. package/src/utils/utils.js +23 -23
  87. package/src/video/canvas/canvas_renderer.js +127 -128
  88. package/src/video/renderer.js +69 -69
  89. package/src/video/texture.js +80 -82
  90. package/src/video/texture_cache.js +2 -4
  91. package/src/video/video.js +38 -38
  92. package/src/video/webgl/buffer/vertex.js +11 -3
  93. package/src/video/webgl/glshader.js +31 -32
  94. package/src/video/webgl/webgl_compositor.js +145 -127
  95. package/src/video/webgl/webgl_renderer.js +196 -175
@@ -8,7 +8,7 @@ import * as event from "./../system/event.js";
8
8
  /**
9
9
  * The device capabilities and specific events
10
10
  * @namespace me.device
11
- * @memberOf me
11
+ * @memberof me
12
12
  */
13
13
 
14
14
  // private properties
@@ -17,6 +17,10 @@ let deviceOrientationInitialized = false;
17
17
 
18
18
  // swipe utility fn & flag
19
19
  let swipeEnabled = true;
20
+
21
+ /**
22
+ * @ignore
23
+ */
20
24
  function _disableSwipeFn(e) {
21
25
  e.preventDefault();
22
26
  if (typeof window.scroll === "function") {
@@ -28,7 +32,10 @@ function _disableSwipeFn(e) {
28
32
  // DOM loading stuff
29
33
  let readyBound = false, isReady = false, readyList = [];
30
34
 
31
- // called to check if the device is ready
35
+ /**
36
+ * // called to check if the device is ready
37
+ * @ignore
38
+ */
32
39
  function _domReady() {
33
40
  // Make sure that the DOM is not already loaded
34
41
  if (!isReady) {
@@ -61,8 +68,10 @@ function _domReady() {
61
68
  // a cache DOMRect object
62
69
  let _domRect = {left: 0, top: 0, x: 0, y: 0, width: 0, height: 0, right: 0, bottom: 0};
63
70
 
64
-
65
- // detect the device type
71
+ /**
72
+ * detect the device type
73
+ * @ignore
74
+ */
66
75
  function _detectDevice() {
67
76
  // iOS Device ?
68
77
  device.iOS = /iPhone|iPad|iPod/i.test(device.ua);
@@ -92,7 +101,10 @@ function _detectDevice() {
92
101
  device.isWeixin = /MicroMessenger/i.test(device.ua);
93
102
  };
94
103
 
95
- // check the device capapbilities
104
+ /**
105
+ * check the device capapbilities
106
+ * @ignore
107
+ */
96
108
  function _checkCapabilities() {
97
109
 
98
110
  // detect device type/platform
@@ -119,12 +131,8 @@ function _checkCapabilities() {
119
131
  // Modern browsers support "wheel", Webkit and IE support at least "mousewheel
120
132
  device.wheel = ("onwheel" in document.createElement("div"));
121
133
 
122
- // pointerlock detection
123
- device.hasPointerLockSupport = prefixed("pointerLockElement", document);
124
-
125
- if (device.hasPointerLockSupport) {
126
- document.exitPointerLock = prefixed("exitPointerLock", document);
127
- }
134
+ // pointerlock detection (pointerLockElement can be null when the feature is supported)
135
+ device.hasPointerLockSupport = typeof document.pointerLockElement !== "undefined";
128
136
 
129
137
  // device orientation and motion detection
130
138
  device.hasDeviceOrientation = !!window.DeviceOrientationEvent;
@@ -242,93 +250,93 @@ let device = {
242
250
 
243
251
  /**
244
252
  * the `ua` read-only property returns the user agent string for the current browser.
245
- * @type String
253
+ * @type {string}
246
254
  * @readonly
247
255
  * @name ua
248
- * @memberOf me.device
256
+ * @memberof me.device
249
257
  */
250
258
  ua : navigator.userAgent,
251
259
 
252
260
  /**
253
261
  * Browser Local Storage capabilities <br>
254
262
  * (this flag will be set to false if cookies are blocked)
255
- * @type Boolean
263
+ * @type {boolean}
256
264
  * @readonly
257
265
  * @name localStorage
258
- * @memberOf me.device
266
+ * @memberof me.device
259
267
  */
260
268
  localStorage : false,
261
269
 
262
270
  /**
263
271
  * Browser accelerometer capabilities
264
- * @type Boolean
272
+ * @type {boolean}
265
273
  * @readonly
266
274
  * @name hasAccelerometer
267
- * @memberOf me.device
275
+ * @memberof me.device
268
276
  */
269
277
  hasAccelerometer : false,
270
278
 
271
279
  /**
272
280
  * Browser device orientation
273
- * @type Boolean
281
+ * @type {boolean}
274
282
  * @readonly
275
283
  * @name hasDeviceOrientation
276
- * @memberOf me.device
284
+ * @memberof me.device
277
285
  */
278
286
  hasDeviceOrientation : false,
279
287
 
280
288
  /**
281
289
  * Supports the ScreenOrientation API
282
290
  * @see https://developer.mozilla.org/en-US/docs/Web/API/ScreenOrientation/onchange
283
- * @type Boolean
291
+ * @type {boolean}
284
292
  * @readonly
285
293
  * @name ScreenOrientation
286
- * @memberOf me.device
294
+ * @memberof me.device
287
295
  */
288
296
  ScreenOrientation : false,
289
297
 
290
298
  /**
291
299
  * Browser full screen support
292
- * @type Boolean
300
+ * @type {boolean}
293
301
  * @readonly
294
302
  * @name hasFullscreenSupport
295
- * @memberOf me.device
303
+ * @memberof me.device
296
304
  */
297
305
  hasFullscreenSupport : false,
298
306
 
299
- /**
307
+ /**
300
308
  * Browser pointerlock api support
301
- * @type Boolean
309
+ * @type {boolean}
302
310
  * @readonly
303
311
  * @name hasPointerLockSupport
304
- * @memberOf me.device
312
+ * @memberof me.device
305
313
  */
306
314
  hasPointerLockSupport : false,
307
315
 
308
316
  /**
309
- * Device WebAudio Support
310
- * @type Boolean
311
- * @readonly
312
- * @name hasWebAudio
313
- * @memberOf me.device
314
- */
315
- hasWebAudio : false,
317
+ * Device WebAudio Support
318
+ * @type {boolean}
319
+ * @readonly
320
+ * @name hasWebAudio
321
+ * @memberof me.device
322
+ */
323
+ hasWebAudio : false,
316
324
 
317
325
  /**
318
326
  * Browser Base64 decoding capability
319
- * @type Boolean
327
+ * @type {boolean}
320
328
  * @readonly
321
329
  * @name nativeBase64
322
- * @memberOf me.device
330
+ * @memberof me.device
323
331
  */
324
332
  nativeBase64 : (typeof(window.atob) === "function"),
325
333
 
326
334
  /**
327
335
  * Return the maximum number of simultaneous touch contact points are supported by the current device.
328
- * @type Number
336
+ * @type {number}
329
337
  * @readonly
330
338
  * @name maxTouchPoints
331
- * @memberOf me.device
339
+ * @memberof me.device
332
340
  * @example
333
341
  * if (me.device.maxTouchPoints > 1) {
334
342
  * // device supports multi-touch
@@ -338,175 +346,175 @@ let device = {
338
346
 
339
347
  /**
340
348
  * Touch capabilities
341
- * @type Boolean
349
+ * @type {boolean}
342
350
  * @readonly
343
351
  * @name touch
344
- * @memberOf me.device
352
+ * @memberof me.device
345
353
  */
346
354
  touch : false,
347
355
 
348
356
  /**
349
357
  * W3C standard wheel events
350
- * @type Boolean
358
+ * @type {boolean}
351
359
  * @readonly
352
360
  * @name wheel
353
- * @memberOf me.device
361
+ * @memberof me.device
354
362
  */
355
363
  wheel : false,
356
364
 
357
365
  /**
358
366
  * equals to true if a mobile device <br>
359
367
  * (Android | iPhone | iPad | iPod | BlackBerry | Windows Phone | Kindle)
360
- * @type Boolean
368
+ * @type {boolean}
361
369
  * @readonly
362
370
  * @name isMobile
363
- * @memberOf me.device
371
+ * @memberof me.device
364
372
  */
365
373
  isMobile : false,
366
374
 
367
375
  /**
368
376
  * equals to true if the device is an iOS platform.
369
- * @type Boolean
377
+ * @type {boolean}
370
378
  * @readonly
371
379
  * @name iOS
372
- * @memberOf me.device
380
+ * @memberof me.device
373
381
  */
374
382
  iOS : false,
375
383
 
376
384
  /**
377
385
  * equals to true if the device is an Android platform.
378
- * @type Boolean
386
+ * @type {boolean}
379
387
  * @readonly
380
388
  * @name android
381
- * @memberOf me.device
389
+ * @memberof me.device
382
390
  */
383
391
  android : false,
384
392
 
385
393
  /**
386
394
  * equals to true if the device is an Android 2.x platform.
387
- * @type Boolean
395
+ * @type {boolean}
388
396
  * @readonly
389
397
  * @name android2
390
- * @memberOf me.device
398
+ * @memberof me.device
391
399
  */
392
400
  android2 : false,
393
401
 
394
402
  /**
395
403
  * equals to true if the device is a Linux platform.
396
- * @type Boolean
404
+ * @type {boolean}
397
405
  * @readonly
398
406
  * @name linux
399
- * @memberOf me.device
407
+ * @memberof me.device
400
408
  */
401
409
  linux : false,
402
410
 
403
411
  /**
404
412
  * equals to true if the game is running under Ejecta.
405
- * @type Boolean
413
+ * @type {boolean}
406
414
  * @readonly
407
415
  * @see http://impactjs.com/ejecta
408
416
  * @name ejecta
409
- * @memberOf me.device
417
+ * @memberof me.device
410
418
  */
411
419
  ejecta : false,
412
420
 
413
421
  /**
414
422
  * equals to true if the game is running under Wechat.
415
- * @type Boolean
423
+ * @type {boolean}
416
424
  * @readonly
417
425
  * @name isWeixin
418
- * @memberOf me.device
426
+ * @memberof me.device
419
427
  */
420
428
  isWeixin : false,
421
429
 
422
430
  /**
423
431
  * equals to true if the device is running on ChromeOS.
424
- * @type Boolean
432
+ * @type {boolean}
425
433
  * @readonly
426
434
  * @name chromeOS
427
- * @memberOf me.device
435
+ * @memberof me.device
428
436
  */
429
437
  chromeOS : false,
430
438
 
431
- /**
439
+ /**
432
440
  * equals to true if the device is a Windows Phone platform.
433
- * @type Boolean
441
+ * @type {boolean}
434
442
  * @readonly
435
443
  * @name wp
436
- * @memberOf me.device
444
+ * @memberof me.device
437
445
  */
438
446
  wp : false,
439
447
 
440
448
  /**
441
449
  * equals to true if the device is a BlackBerry platform.
442
- * @type Boolean
450
+ * @type {boolean}
443
451
  * @readonly
444
452
  * @name BlackBerry
445
- * @memberOf me.device
453
+ * @memberof me.device
446
454
  */
447
455
  BlackBerry : false,
448
456
 
449
457
  /**
450
458
  * equals to true if the device is a Kindle platform.
451
- * @type Boolean
459
+ * @type {boolean}
452
460
  * @readonly
453
461
  * @name Kindle
454
- * @memberOf me.device
462
+ * @memberof me.device
455
463
  */
456
464
  Kindle : false,
457
465
 
458
466
  /**
459
467
  * contains the g-force acceleration along the x-axis.
460
468
  * @public
461
- * @type Number
469
+ * @type {number}
462
470
  * @readonly
463
471
  * @name accelerationX
464
472
  * @see me.device.watchAccelerometer
465
- * @memberOf me.device
473
+ * @memberof me.device
466
474
  */
467
475
  accelerationX : 0,
468
476
 
469
477
  /**
470
478
  * contains the g-force acceleration along the y-axis.
471
479
  * @public
472
- * @type Number
480
+ * @type {number}
473
481
  * @readonly
474
482
  * @name accelerationY
475
483
  * @see me.device.watchAccelerometer
476
- * @memberOf me.device
484
+ * @memberof me.device
477
485
  */
478
486
  accelerationY : 0,
479
487
 
480
488
  /**
481
489
  * contains the g-force acceleration along the z-axis.
482
490
  * @public
483
- * @type Number
491
+ * @type {number}
484
492
  * @readonly
485
493
  * @name accelerationZ
486
494
  * @see me.device.watchAccelerometer
487
- * @memberOf me.device
495
+ * @memberof me.device
488
496
  */
489
497
  accelerationZ : 0,
490
498
 
491
499
  /**
492
500
  * Device orientation Gamma property. Gives angle on tilting a portrait held phone left or right
493
501
  * @public
494
- * @type Number
502
+ * @type {number}
495
503
  * @readonly
496
504
  * @name gamma
497
505
  * @see me.device.watchDeviceOrientation
498
- * @memberOf me.device
506
+ * @memberof me.device
499
507
  */
500
508
  gamma : 0,
501
509
 
502
510
  /**
503
511
  * Device orientation Beta property. Gives angle on tilting a portrait held phone forward or backward
504
512
  * @public
505
- * @type Number
513
+ * @type {number}
506
514
  * @readonly
507
515
  * @name beta
508
516
  * @see me.device.watchDeviceOrientation
509
- * @memberOf me.device
517
+ * @memberof me.device
510
518
  */
511
519
  beta: 0,
512
520
 
@@ -514,11 +522,11 @@ let device = {
514
522
  * Device orientation Alpha property. Gives angle based on the rotation of the phone around its z axis.
515
523
  * The z-axis is perpendicular to the phone, facing out from the center of the screen.
516
524
  * @public
517
- * @type Number
525
+ * @type {number}
518
526
  * @readonly
519
527
  * @name alpha
520
528
  * @see me.device.watchDeviceOrientation
521
- * @memberOf me.device
529
+ * @memberof me.device
522
530
  */
523
531
  alpha : 0,
524
532
 
@@ -526,53 +534,53 @@ let device = {
526
534
  * a string representing the preferred language of the user, usually the language of the browser UI.
527
535
  * (will default to "en" if the information is not available)
528
536
  * @public
529
- * @type String
537
+ * @type {string}
530
538
  * @readonly
531
539
  * @see http://www.w3schools.com/tags/ref_language_codes.asp
532
540
  * @name language
533
- * @memberOf me.device
541
+ * @memberof me.device
534
542
  */
535
543
  language : navigator.language || navigator.browserLanguage || navigator.userLanguage || "en",
536
544
 
537
545
  /**
538
546
  * Specify whether to pause the game when losing focus
539
- * @type {Boolean}
547
+ * @type {boolean}
540
548
  * @default true
541
- * @memberOf me.device
549
+ * @memberof me.device
542
550
  */
543
551
  pauseOnBlur : true,
544
552
 
545
553
  /**
546
554
  * Specify whether to unpause the game when gaining focus
547
- * @type {Boolean}
555
+ * @type {boolean}
548
556
  * @default true
549
- * @memberOf me.device
557
+ * @memberof me.device
550
558
  */
551
559
  resumeOnFocus : true,
552
560
 
553
561
  /**
554
562
  * Specify whether to automatically bring the window to the front
555
- * @type {Boolean}
563
+ * @type {boolean}
556
564
  * @default true
557
- * @memberOf me.device
565
+ * @memberof me.device
558
566
  */
559
567
  autoFocus : true,
560
568
 
561
569
  /**
562
570
  * Specify whether to stop the game when losing focus or not.
563
571
  * The engine restarts on focus if this is enabled.
564
- * @type {Boolean}
572
+ * @type {boolean}
565
573
  * @default false
566
- * @memberOf me.device
574
+ * @memberof me.device
567
575
  */
568
576
  stopOnBlur : false,
569
577
 
570
578
  /**
571
579
  * equals to true if the device browser supports OffScreenCanvas.
572
- * @type Boolean
580
+ * @type {boolean}
573
581
  * @readonly
574
582
  * @name OffScreenCanvas
575
- * @memberOf me.device
583
+ * @memberof me.device
576
584
  */
577
585
  OffscreenCanvas : false,
578
586
 
@@ -653,7 +661,7 @@ let device = {
653
661
  /**
654
662
  * enable/disable swipe on WebView.
655
663
  * @function me.device.enableSwipe
656
- * @param {Boolean} [enable=true] enable or disable swipe.
664
+ * @param {boolean} [enable=true] enable or disable swipe.
657
665
  */
658
666
  enableSwipe(enable) {
659
667
  if (enable !== false) {
@@ -670,7 +678,7 @@ let device = {
670
678
  /**
671
679
  * Triggers a fullscreen request. Requires fullscreen support from the browser/device.
672
680
  * @function me.device.requestFullscreen
673
- * @param {Object} [element=default canvas object] the element to be set in full-screen mode.
681
+ * @param {object} [element=default canvas object] the element to be set in full-screen mode.
674
682
  * @example
675
683
  * // add a keyboard shortcut to toggle Fullscreen mode on/off
676
684
  * me.input.bindKey(me.input.KEY.F, "toggleFullscreen");
@@ -710,7 +718,7 @@ let device = {
710
718
  * It can be "any", "natural", "landscape", "portrait", "portrait-primary", "portrait-secondary", "landscape-primary", "landscape-secondary"
711
719
  * @function me.device.getScreenOrientation
712
720
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation
713
- * @return {String} the screen orientation
721
+ * @returns {string} the screen orientation
714
722
  */
715
723
  getScreenOrientation() {
716
724
  var PORTRAIT = "portrait";
@@ -744,14 +752,15 @@ let device = {
744
752
  * This method only works for installed Web apps or for Web pages in full-screen mode.
745
753
  * @function me.device.lockOrientation
746
754
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation
747
- * @return {Boolean} true if the orientation was unsuccessfully locked
755
+ * @param {string|string[]} orientation The orientation into which to lock the screen.
756
+ * @returns {boolean} true if the orientation was unsuccessfully locked
748
757
  */
749
758
  lockOrientation(orientation) {
750
759
  var screen = window.screen;
751
760
  if (typeof screen !== "undefined") {
752
- var lockOrientation = prefixed("lockOrientation", screen);
753
- if (typeof lockOrientation !== "undefined") {
754
- return lockOrientation(orientation);
761
+ var _lockOrientation = prefixed("lockOrientation", screen);
762
+ if (typeof _lockOrientation !== "undefined") {
763
+ return _lockOrientation(orientation);
755
764
  }
756
765
  }
757
766
  return false;
@@ -762,14 +771,14 @@ let device = {
762
771
  * This method only works for installed Web apps or for Web pages in full-screen mode.
763
772
  * @function me.device.unlockOrientation
764
773
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation
765
- * @return {Boolean} true if the orientation was unsuccessfully unlocked
774
+ * @returns {boolean} true if the orientation was unsuccessfully unlocked
766
775
  */
767
- unlockOrientation(orientation) {
776
+ unlockOrientation() {
768
777
  var screen = window.screen;
769
778
  if (typeof screen !== "undefined") {
770
- var unlockOrientation = prefixed("unlockOrientation", screen);
771
- if (typeof unlockOrientation !== "undefined") {
772
- return unlockOrientation(orientation);
779
+ var _unlockOrientation = prefixed("unlockOrientation", screen);
780
+ if (typeof _unlockOrientation !== "undefined") {
781
+ return _unlockOrientation();
773
782
  }
774
783
  }
775
784
  return false;
@@ -778,7 +787,7 @@ let device = {
778
787
  /**
779
788
  * return true if the device screen orientation is in Portrait mode
780
789
  * @function me.device.isPortrait
781
- * @return {Boolean}
790
+ * @returns {boolean}
782
791
  */
783
792
  isPortrait() {
784
793
  return this.getScreenOrientation().includes("portrait");
@@ -787,7 +796,7 @@ let device = {
787
796
  /**
788
797
  * return true if the device screen orientation is in Portrait mode
789
798
  * @function me.device.isLandscape
790
- * @return {Boolean}
799
+ * @returns {boolean}
791
800
  */
792
801
  isLandscape() {
793
802
  return this.getScreenOrientation().includes("landscape");
@@ -797,8 +806,8 @@ let device = {
797
806
  * return the device storage
798
807
  * @function me.device.getStorage
799
808
  * @see me.save
800
- * @param {String} [type="local"]
801
- * @return {Object} a reference to the device storage
809
+ * @param {string} [type="local"]
810
+ * @returns {object} a reference to the device storage
802
811
  */
803
812
  getStorage(type = "local") {
804
813
  switch (type) {
@@ -813,8 +822,8 @@ let device = {
813
822
  /**
814
823
  * return the parent DOM element for the given parent name or HTMLElement object
815
824
  * @function me.device.getParentElement
816
- * @param {String|HTMLElement} element the parent element name or a HTMLElement object
817
- * @return {HTMLElement} the parent Element
825
+ * @param {string|HTMLElement} element the parent element name or a HTMLElement object
826
+ * @returns {HTMLElement} the parent Element
818
827
  */
819
828
  getParentElement(element) {
820
829
  var target = this.getElement(element);
@@ -829,8 +838,8 @@ let device = {
829
838
  /**
830
839
  * return the DOM element for the given element name or HTMLElement object
831
840
  * @function me.device.getElement
832
- * @param {String|HTMLElement} element the parent element name or a HTMLElement object
833
- * @return {HTMLElement} the corresponding DOM Element or null if not existing
841
+ * @param {string|HTMLElement} element the parent element name or a HTMLElement object
842
+ * @returns {HTMLElement} the corresponding DOM Element or null if not existing
834
843
  */
835
844
  getElement(element) {
836
845
  var target = null;
@@ -857,8 +866,8 @@ let device = {
857
866
  * <br><img src="images/element-box-diagram.png"/>
858
867
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
859
868
  * @function me.device.getElementBounds
860
- * @param {String|HTMLElement} element an HTMLElement object
861
- * @return {DOMRect} the size and position of the element relatively to the viewport
869
+ * @param {string|HTMLElement} element an HTMLElement object
870
+ * @returns {DOMRect} the size and position of the element relatively to the viewport
862
871
  */
863
872
  getElementBounds(element) {
864
873
  if (typeof element === "object" && element !== document.body && typeof element.getBoundingClientRect !== "undefined") {
@@ -875,8 +884,8 @@ let device = {
875
884
  * <br><img src="images/element-box-diagram.png"/>
876
885
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
877
886
  * @function me.device.getParentBounds
878
- * @param {String|HTMLElement} element an HTMLElement object
879
- * @return {DOMRect} the size and position of the given element parent relative to the viewport
887
+ * @param {string|HTMLElement} element an HTMLElement object
888
+ * @returns {DOMRect} the size and position of the given element parent relative to the viewport
880
889
  */
881
890
  getParentBounds(element) {
882
891
  return this.getElementBounds(this.getParentElement(element));
@@ -885,9 +894,9 @@ let device = {
885
894
  /**
886
895
  * returns true if the device supports WebGL
887
896
  * @function me.device.isWebGLSupported
888
- * @param {Object} [options] context creation options
889
- * @param {Boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
890
- * @return {Boolean} true if WebGL is supported
897
+ * @param {object} [options] context creation options
898
+ * @param {boolean} [options.failIfMajorPerformanceCaveat=true] If true, the renderer will switch to CANVAS mode if the performances of a WebGL context would be dramatically lower than that of a native application making equivalent OpenGL calls.
899
+ * @returns {boolean} true if WebGL is supported
891
900
  */
892
901
  isWebGLSupported(options) {
893
902
  var _supported = false;
@@ -909,7 +918,7 @@ let device = {
909
918
  * return the highest precision format supported by this device for GL Shaders
910
919
  * @function me.device.getMaxShaderPrecision
911
920
  * @param {WebGLRenderingContext} gl
912
- * @return {Boolean} "lowp", "mediump", or "highp"
921
+ * @returns {boolean} "lowp", "mediump", or "highp"
913
922
  */
914
923
  getMaxShaderPrecision(gl) {
915
924
  if (gl.getShaderPrecisionFormat(gl.VERTEX_SHADER, gl.HIGH_FLOAT ).precision > 0 &&
@@ -961,58 +970,6 @@ let device = {
961
970
  this.alpha = e.alpha;
962
971
  },
963
972
 
964
- /**
965
- * Enters pointer lock, requesting it from the user first. Works on supported devices & browsers
966
- * Must be called in a click event or an event that requires user interaction.
967
- * If you need to run handle events for errors or change of the pointer lock, see below.
968
- * @function me.device.turnOnPointerLock
969
- * @example
970
- * document.addEventListener("pointerlockchange", pointerlockchange, false);
971
- * document.addEventListener("mozpointerlockchange", pointerlockchange, false);
972
- * document.addEventListener("webkitpointerlockchange", pointerlockchange, false);
973
- *
974
- * document.addEventListener("pointerlockerror", pointerlockerror, false);
975
- * document.addEventListener("mozpointerlockerror", pointerlockerror, false);
976
- * document.addEventListener("webkitpointerlockerror", pointerlockerror, false);
977
- */
978
- turnOnPointerLock() {
979
- if (this.hasPointerLockSupport) {
980
- var element = getParent();
981
- if (this.ua.match(/Firefox/i)) {
982
- var fullscreenchange = function() {
983
- if ((prefixed("fullscreenElement", document) ||
984
- document.mozFullScreenElement) === element) {
985
-
986
- document.removeEventListener("fullscreenchange", fullscreenchange);
987
- document.removeEventListener("mozfullscreenchange", fullscreenchange);
988
- element.requestPointerLock = prefixed("requestPointerLock", element);
989
- element.requestPointerLock();
990
- }
991
- };
992
-
993
- document.addEventListener("fullscreenchange", fullscreenchange, false);
994
- document.addEventListener("mozfullscreenchange", fullscreenchange, false);
995
-
996
- this.requestFullscreen();
997
-
998
- }
999
- else {
1000
- element.requestPointerLock();
1001
- }
1002
- }
1003
- },
1004
-
1005
- /**
1006
- * Exits pointer lock. Works on supported devices & browsers
1007
- * @function me.device.turnOffPointerLock
1008
- * @function
1009
- */
1010
- turnOffPointerLock() {
1011
- if (this.hasPointerLockSupport) {
1012
- document.exitPointerLock();
1013
- }
1014
- },
1015
-
1016
973
  /**
1017
974
  * Enable monitor of the device accelerator to detect the amount of physical force of acceleration the device is receiving.
1018
975
  * (one some device a first user gesture will be required before calling this function)
@@ -1020,7 +977,7 @@ let device = {
1020
977
  * @see me.device.accelerationX
1021
978
  * @see me.device.accelerationY
1022
979
  * @see me.device.accelerationZ
1023
- * @return {Boolean} false if not supported or permission not granted by the user
980
+ * @returns {boolean} false if not supported or permission not granted by the user
1024
981
  * @example
1025
982
  * // try to enable device accelerometer event on user gesture
1026
983
  * me.input.registerPointerEvent("pointerleave", me.game.viewport, function() {
@@ -1071,7 +1028,7 @@ let device = {
1071
1028
  * @see me.device.alpha
1072
1029
  * @see me.device.beta
1073
1030
  * @see me.device.gamma
1074
- * @return {Boolean} false if not supported or permission not granted by the user
1031
+ * @returns {boolean} false if not supported or permission not granted by the user
1075
1032
  * @example
1076
1033
  * // try to enable device orientation event on user gesture
1077
1034
  * me.input.registerPointerEvent("pointerleave", me.game.viewport, function() {
@@ -1118,7 +1075,7 @@ let device = {
1118
1075
  * If a vibration pattern is already in progress when this method is called,
1119
1076
  * the previous pattern is halted and the new one begins instead.
1120
1077
  * @function me.device.vibrate
1121
- * @param {Number|Number[]} pattern pattern of vibration and pause intervals
1078
+ * @param {number|number[]} pattern pattern of vibration and pause intervals
1122
1079
  * @example
1123
1080
  * // vibrate for 1000 ms
1124
1081
  * me.device.vibrate(1000);
@@ -1140,11 +1097,11 @@ let device = {
1140
1097
  /**
1141
1098
  * Ratio of the resolution in physical pixels to the resolution in CSS pixels for the current display device.
1142
1099
  * @name devicePixelRatio
1143
- * @memberOf me.device
1100
+ * @memberof me.device
1144
1101
  * @public
1145
- * @type {Number}
1102
+ * @type {number}
1146
1103
  * @readonly
1147
- * @return {Number}
1104
+ * @returns {number}
1148
1105
  */
1149
1106
  Object.defineProperty(device, "devicePixelRatio", {
1150
1107
  /**
@@ -1158,11 +1115,11 @@ Object.defineProperty(device, "devicePixelRatio", {
1158
1115
  /**
1159
1116
  * Returns true if the browser/device is in full screen mode.
1160
1117
  * @name isFullscreen
1161
- * @memberOf me.device
1118
+ * @memberof me.device
1162
1119
  * @public
1163
- * @type {Boolean}
1120
+ * @type {boolean}
1164
1121
  * @readonly
1165
- * @return {Boolean}
1122
+ * @returns {boolean}
1166
1123
  */
1167
1124
  Object.defineProperty(device, "isFullscreen", {
1168
1125
  /**
@@ -1181,11 +1138,11 @@ Object.defineProperty(device, "isFullscreen", {
1181
1138
  /**
1182
1139
  * Returns true if the browser/device has audio capabilities.
1183
1140
  * @name sound
1184
- * @memberOf me.device
1141
+ * @memberof me.device
1185
1142
  * @public
1186
- * @type {Boolean}
1143
+ * @type {boolean}
1187
1144
  * @readonly
1188
- * @return {Boolean}
1145
+ * @returns {boolean}
1189
1146
  */
1190
1147
  Object.defineProperty(device, "sound", {
1191
1148
  /**