melonjs 9.1.0 → 10.0.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 (78) hide show
  1. package/{LICENSE → LICENSE.md} +0 -0
  2. package/README.md +93 -57
  3. package/dist/melonjs.js +10334 -11179
  4. package/dist/melonjs.min.js +4 -10
  5. package/dist/melonjs.module.d.ts +13206 -0
  6. package/dist/melonjs.module.js +9913 -10872
  7. package/package.json +19 -14
  8. package/src/audio/audio.js +477 -553
  9. package/src/camera/camera2d.js +67 -65
  10. package/src/entity/draggable.js +26 -35
  11. package/src/entity/droptarget.js +17 -14
  12. package/src/entity/entity.js +59 -79
  13. package/src/game.js +194 -204
  14. package/src/index.js +12 -30
  15. package/src/input/gamepad.js +8 -19
  16. package/src/input/keyboard.js +4 -4
  17. package/src/input/pointer.js +14 -12
  18. package/src/input/pointerevent.js +15 -13
  19. package/src/lang/deprecated.js +2 -887
  20. package/src/level/level.js +3 -3
  21. package/src/level/tiled/TMXGroup.js +7 -11
  22. package/src/level/tiled/TMXLayer.js +33 -32
  23. package/src/level/tiled/TMXTileMap.js +15 -19
  24. package/src/level/tiled/TMXTileset.js +5 -5
  25. package/src/level/tiled/TMXUtils.js +3 -3
  26. package/src/level/tiled/renderer/TMXRenderer.js +4 -0
  27. package/src/loader/loader.js +8 -23
  28. package/src/loader/loadingscreen.js +51 -60
  29. package/src/math/matrix3.js +1 -1
  30. package/src/particles/emitter.js +36 -39
  31. package/src/particles/particle.js +27 -12
  32. package/src/particles/particlecontainer.js +17 -16
  33. package/src/physics/body.js +80 -118
  34. package/src/physics/collision.js +5 -235
  35. package/src/physics/detector.js +235 -0
  36. package/src/physics/quadtree.js +14 -14
  37. package/src/physics/world.js +84 -18
  38. package/src/plugin/plugin.js +26 -24
  39. package/src/polyfill/console.js +9 -14
  40. package/src/renderable/GUI.js +48 -62
  41. package/src/renderable/collectable.js +11 -4
  42. package/src/renderable/colorlayer.js +28 -26
  43. package/src/renderable/container.js +120 -96
  44. package/src/renderable/imagelayer.js +94 -93
  45. package/src/renderable/renderable.js +164 -138
  46. package/src/renderable/sprite.js +42 -44
  47. package/src/renderable/trigger.js +24 -17
  48. package/src/shapes/ellipse.js +27 -27
  49. package/src/shapes/line.js +12 -8
  50. package/src/shapes/poly.js +77 -49
  51. package/src/shapes/rectangle.js +193 -268
  52. package/src/state/stage.js +23 -25
  53. package/src/state/state.js +35 -86
  54. package/src/system/device.js +233 -285
  55. package/src/system/event.js +485 -432
  56. package/src/system/pooling.js +61 -54
  57. package/src/system/save.js +17 -16
  58. package/src/system/timer.js +34 -38
  59. package/src/text/bitmaptext.js +44 -46
  60. package/src/text/text.js +39 -34
  61. package/src/tweens/easing.js +0 -2
  62. package/src/tweens/interpolation.js +3 -8
  63. package/src/tweens/tween.js +332 -351
  64. package/src/utils/function.js +6 -8
  65. package/src/utils/utils.js +34 -30
  66. package/src/video/canvas/canvas_renderer.js +13 -8
  67. package/src/video/renderer.js +8 -7
  68. package/src/video/texture.js +8 -8
  69. package/src/video/texture_cache.js +5 -5
  70. package/src/video/video.js +373 -403
  71. package/src/video/webgl/glshader.js +2 -2
  72. package/src/video/webgl/webgl_compositor.js +14 -8
  73. package/src/video/webgl/webgl_renderer.js +21 -19
  74. package/plugins/debug/debugPanel.js +0 -770
  75. package/plugins/debug/font/PressStart2P.fnt +0 -100
  76. package/plugins/debug/font/PressStart2P.ltr +0 -1
  77. package/plugins/debug/font/PressStart2P.png +0 -0
  78. package/plugins/debug/particleDebugPanel.js +0 -303
@@ -1,8 +1,15 @@
1
- import audio from "./../audio/audio.js";
2
- import video from "./../video/video.js";
1
+ import { hasAudio } from "./../audio/audio.js";
2
+ import { getParent } from "./../video/video.js";
3
3
  import save from "./../system/save.js";
4
4
  import { prefixed } from "./../utils/agent.js";
5
5
  import state from "./../state/state.js";
6
+ import * as event from "./../system/event.js";
7
+
8
+ /**
9
+ * The device capabilities and specific events
10
+ * @namespace me.device
11
+ * @memberOf me
12
+ */
6
13
 
7
14
  // private properties
8
15
  let accelInitialized = false;
@@ -10,7 +17,7 @@ let deviceOrientationInitialized = false;
10
17
 
11
18
  // swipe utility fn & flag
12
19
  let swipeEnabled = true;
13
- function disableSwipeFn(e) {
20
+ function _disableSwipeFn(e) {
14
21
  e.preventDefault();
15
22
  if (typeof window.scroll === "function") {
16
23
  window.scroll(0, 0);
@@ -21,224 +28,213 @@ function disableSwipeFn(e) {
21
28
  // DOM loading stuff
22
29
  let readyBound = false, isReady = false, readyList = [];
23
30
 
24
- // a cache DOMRect object
25
- let _domRect = {left: 0, top: 0, x: 0, y: 0, width: 0, height: 0, right: 0, bottom: 0};
31
+ // called to check if the device is ready
32
+ function _domReady() {
33
+ // Make sure that the DOM is not already loaded
34
+ if (!isReady) {
35
+ // be sure document.body is there
36
+ if (!document.body) {
37
+ return setTimeout(_domReady, 13);
38
+ }
26
39
 
27
- /**
28
- * The device capabilities and specific events
29
- * @namespace me.device
30
- * @memberOf me
31
- */
32
- let device = {
40
+ // clean up loading event
41
+ if (document.removeEventListener) {
42
+ document.removeEventListener(
43
+ "DOMContentLoaded",
44
+ this._domReady,
45
+ false
46
+ );
47
+ }
48
+ // remove the event on window.onload (always added in `onReady`)
49
+ window.removeEventListener("load", _domReady, false);
33
50
 
34
- /**
35
- * called to check if the device is ready
36
- * @ignore
37
- */
38
- _domReady(fn) {
39
- // Make sure that the DOM is not already loaded
40
- if (!isReady) {
41
- // be sure document.body is there
42
- if (!document.body) {
43
- return setTimeout(this._domReady, 13);
44
- }
51
+ // execute all callbacks
52
+ while (readyList.length) {
53
+ readyList.shift().call(window, []);
54
+ }
45
55
 
46
- // clean up loading event
47
- if (document.removeEventListener) {
48
- document.removeEventListener(
49
- "DOMContentLoaded",
50
- this._domReady,
51
- false
52
- );
53
- }
54
- // remove the event on window.onload (always added in `onReady`)
55
- window.removeEventListener("load", this._domReady, false);
56
+ // Remember that the DOM is ready
57
+ isReady = true;
58
+ }
59
+ };
56
60
 
57
- // execute all callbacks
58
- while (readyList.length) {
59
- readyList.shift().call(window, []);
60
- }
61
+ // a cache DOMRect object
62
+ let _domRect = {left: 0, top: 0, x: 0, y: 0, width: 0, height: 0, right: 0, bottom: 0};
61
63
 
62
- // Remember that the DOM is ready
63
- isReady = true;
64
- }
65
- },
66
64
 
65
+ // detect the device type
66
+ function _detectDevice() {
67
+ // iOS Device ?
68
+ device.iOS = /iPhone|iPad|iPod/i.test(device.ua);
69
+ // Android Device ?
70
+ device.android = /Android/i.test(device.ua);
71
+ device.android2 = /Android 2/i.test(device.ua);
72
+ // Linux platform
73
+ device.linux = /Linux/i.test(device.ua);
74
+ // Chrome OS ?
75
+ device.chromeOS = /CrOS/.test(device.ua);
76
+ // Windows Device ?
77
+ device.wp = /Windows Phone/i.test(device.ua);
78
+ // Blackberry device ?
79
+ device.BlackBerry = /BlackBerry/i.test(device.ua);
80
+ // Kindle device ?
81
+ device.Kindle = /Kindle|Silk.*Mobile Safari/i.test(device.ua);
82
+ // Mobile platform
83
+ device.isMobile = /Mobi/i.test(device.ua) ||
84
+ device.iOS ||
85
+ device.android ||
86
+ device.wp ||
87
+ device.BlackBerry ||
88
+ device.Kindle || false;
89
+ // ejecta
90
+ device.ejecta = (typeof window.ejecta !== "undefined");
91
+ // Wechat
92
+ device.isWeixin = /MicroMessenger/i.test(device.ua);
93
+ };
67
94
 
95
+ // check the device capapbilities
96
+ function _checkCapabilities() {
68
97
 
69
- /**
70
- * check the device capapbilities
71
- * @ignore
72
- */
73
- _check() {
98
+ // detect device type/platform
99
+ _detectDevice();
74
100
 
75
- // detect device type/platform
76
- this._detectDevice();
101
+ // Mobile browser hacks
102
+ if (device.isMobile) {
103
+ // Prevent the webview from moving on a swipe
104
+ device.enableSwipe(false);
105
+ }
77
106
 
78
- // Mobile browser hacks
79
- if (this.isMobile) {
80
- // Prevent the webview from moving on a swipe
81
- this.enableSwipe(false);
82
- }
107
+ // Touch/Gesture Event feature detection
108
+ device.TouchEvent = !!("ontouchstart" in window);
109
+ device.PointerEvent = !!window.PointerEvent;
110
+ window.gesture = prefixed("gesture");
83
111
 
84
- // Touch/Gesture Event feature detection
85
- this.TouchEvent = !!("ontouchstart" in window);
86
- this.PointerEvent = !!window.PointerEvent;
87
- window.gesture = prefixed("gesture");
112
+ // detect touch capabilities
113
+ device.touch = device.TouchEvent || device.PointerEvent;
88
114
 
89
- // detect touch capabilities
90
- this.touch = this.TouchEvent || this.PointerEvent;
115
+ // max amount of touch points ; always at least return 1 (e.g. headless chrome will return 0)
116
+ device.maxTouchPoints = device.touch ? (device.PointerEvent ? navigator.maxTouchPoints || 1 : 10) : 1;
91
117
 
92
- // max amount of touch points ; always at least return 1 (e.g. headless chrome will return 0)
93
- this.maxTouchPoints = this.touch ? (this.PointerEvent ? navigator.maxTouchPoints || 1 : 10) : 1;
118
+ // detect wheel event support
119
+ // Modern browsers support "wheel", Webkit and IE support at least "mousewheel
120
+ device.wheel = ("onwheel" in document.createElement("div"));
94
121
 
95
- // detect wheel event support
96
- // Modern browsers support "wheel", Webkit and IE support at least "mousewheel
97
- this.wheel = ("onwheel" in document.createElement("div"));
122
+ // pointerlock detection
123
+ device.hasPointerLockSupport = prefixed("pointerLockElement", document);
98
124
 
99
- // pointerlock detection
100
- this.hasPointerLockSupport = prefixed("pointerLockElement", document);
125
+ if (device.hasPointerLockSupport) {
126
+ document.exitPointerLock = prefixed("exitPointerLock", document);
127
+ }
101
128
 
102
- if (this.hasPointerLockSupport) {
103
- document.exitPointerLock = prefixed("exitPointerLock", document);
104
- }
129
+ // device orientation and motion detection
130
+ device.hasDeviceOrientation = !!window.DeviceOrientationEvent;
131
+ device.hasAccelerometer = !!window.DeviceMotionEvent;
105
132
 
106
- // device orientation and motion detection
107
- if (window.DeviceOrientationEvent) {
133
+ // fullscreen api detection & polyfill when possible
134
+ device.hasFullscreenSupport = prefixed("fullscreenEnabled", document) ||
135
+ document.mozFullScreenEnabled;
108
136
 
109
- }
110
- // device accelerometer and orientation detection
111
- this.hasDeviceOrientation = !!window.DeviceOrientationEvent;
112
- this.hasAccelerometer = !!window.DeviceMotionEvent;
137
+ document.exitFullscreen = prefixed("cancelFullScreen", document) ||
138
+ prefixed("exitFullscreen", document);
113
139
 
114
- // fullscreen api detection & polyfill when possible
115
- this.hasFullscreenSupport = prefixed("fullscreenEnabled", document) ||
116
- document.mozFullScreenEnabled;
140
+ // vibration API poyfill
141
+ navigator.vibrate = prefixed("vibrate", navigator);
117
142
 
118
- document.exitFullscreen = prefixed("cancelFullScreen", document) ||
119
- prefixed("exitFullscreen", document);
143
+ // web Audio detection
144
+ device.hasWebAudio = !!(window.AudioContext || window.webkitAudioContext);
120
145
 
121
- // vibration API poyfill
122
- navigator.vibrate = prefixed("vibrate", navigator);
146
+ try {
147
+ device.localStorage = !!window.localStorage;
148
+ } catch (e) {
149
+ // the above generates an exception when cookies are blocked
150
+ device.localStorage = false;
151
+ }
123
152
 
124
- // web Audio detection
125
- this.hasWebAudio = !!(window.AudioContext || window.webkitAudioContext);
153
+ try {
154
+ // some browser (e.g. Safari) implements WebGL1 and WebGL2 contexts only
155
+ // https://bugzilla.mozilla.org/show_bug.cgi?id=801176
156
+ device.OffscreenCanvas =
157
+ (typeof window.OffscreenCanvas !== "undefined") &&
158
+ ((new OffscreenCanvas(0, 0).getContext( "2d" )) !== null);
159
+ } catch (e) {
160
+ device.OffscreenCanvas = false;
161
+ }
126
162
 
127
- try {
128
- this.localStorage = !!window.localStorage;
129
- } catch (e) {
130
- // the above generates an exception when cookies are blocked
131
- this.localStorage = false;
163
+ // set pause/stop action on losing focus
164
+ window.addEventListener("blur", function () {
165
+ if (device.stopOnBlur) {
166
+ state.stop(true);
132
167
  }
133
-
134
- try {
135
- // some browser (e.g. Safari) implements WebGL1 and WebGL2 contexts only
136
- // https://bugzilla.mozilla.org/show_bug.cgi?id=801176
137
- this.OffscreenCanvas =
138
- (typeof window.OffscreenCanvas !== "undefined") &&
139
- ((new OffscreenCanvas(0, 0).getContext( "2d" )) !== null);
140
- } catch (e) {
141
- this.OffscreenCanvas = false;
168
+ if (device.pauseOnBlur) {
169
+ state.pause(true);
142
170
  }
143
-
144
- // set pause/stop action on losing focus
145
- window.addEventListener("blur", function () {
146
- if (this.stopOnBlur) {
147
- state.stop(true);
148
- }
149
- if (this.pauseOnBlur) {
150
- state.pause(true);
151
- }
152
- }, false);
153
- // set restart/resume action on gaining focus
154
- window.addEventListener("focus", function () {
155
- if (this.stopOnBlur) {
156
- state.restart(true);
157
- }
158
- if (this.resumeOnFocus) {
159
- state.resume(true);
160
- }
161
- // force focus if autofocus is on
162
- if (this.autoFocus) {
163
- this.focus();
164
- }
165
- }, false);
166
-
167
-
168
- // Set the name of the hidden property and the change event for visibility
169
- var hidden, visibilityChange;
170
- if (typeof document.hidden !== "undefined") {
171
- // Opera 12.10 and Firefox 18 and later support
172
- hidden = "hidden";
173
- visibilityChange = "visibilitychange";
174
- } else if (typeof document.mozHidden !== "undefined") {
175
- hidden = "mozHidden";
176
- visibilityChange = "mozvisibilitychange";
177
- } else if (typeof document.msHidden !== "undefined") {
178
- hidden = "msHidden";
179
- visibilityChange = "msvisibilitychange";
180
- } else if (typeof document.webkitHidden !== "undefined") {
181
- hidden = "webkitHidden";
182
- visibilityChange = "webkitvisibilitychange";
171
+ }, false);
172
+ // set restart/resume action on gaining focus
173
+ window.addEventListener("focus", function () {
174
+ if (device.stopOnBlur) {
175
+ state.restart(true);
176
+ }
177
+ if (device.resumeOnFocus) {
178
+ state.resume(true);
183
179
  }
180
+ // force focus if autofocus is on
181
+ if (device.autoFocus) {
182
+ device.focus();
183
+ }
184
+ }, false);
185
+
186
+
187
+ // Set the name of the hidden property and the change event for visibility
188
+ var hidden, visibilityChange;
189
+ if (typeof document.hidden !== "undefined") {
190
+ // Opera 12.10 and Firefox 18 and later support
191
+ hidden = "hidden";
192
+ visibilityChange = "visibilitychange";
193
+ } else if (typeof document.mozHidden !== "undefined") {
194
+ hidden = "mozHidden";
195
+ visibilityChange = "mozvisibilitychange";
196
+ } else if (typeof document.msHidden !== "undefined") {
197
+ hidden = "msHidden";
198
+ visibilityChange = "msvisibilitychange";
199
+ } else if (typeof document.webkitHidden !== "undefined") {
200
+ hidden = "webkitHidden";
201
+ visibilityChange = "webkitvisibilitychange";
202
+ }
184
203
 
185
- // register on the event if supported
186
- if (typeof (visibilityChange) === "string") {
187
- // add the corresponding event listener
188
- document.addEventListener(visibilityChange,
189
- function () {
190
- if (document[hidden]) {
191
- if (this.stopOnBlur) {
192
- state.stop(true);
193
- }
194
- if (this.pauseOnBlur) {
195
- state.pause(true);
196
- }
197
- } else {
198
- if (this.stopOnBlur) {
199
- state.restart(true);
200
- }
201
- if (this.resumeOnFocus) {
202
- state.resume(true);
203
- }
204
+ // register on the event if supported
205
+ if (typeof (visibilityChange) === "string") {
206
+ // add the corresponding event listener
207
+ document.addEventListener(visibilityChange,
208
+ function () {
209
+ if (document[hidden]) {
210
+ if (device.stopOnBlur) {
211
+ state.stop(true);
204
212
  }
205
- }, false
206
- );
207
- }
208
- },
213
+ if (device.pauseOnBlur) {
214
+ state.pause(true);
215
+ }
216
+ } else {
217
+ if (device.stopOnBlur) {
218
+ state.restart(true);
219
+ }
220
+ if (device.resumeOnFocus) {
221
+ state.resume(true);
222
+ }
223
+ }
224
+ }, false
225
+ );
226
+ }
227
+ };
209
228
 
210
- /**
211
- * detect the device type
212
- * @ignore
213
- */
214
- _detectDevice() {
215
- // iOS Device ?
216
- this.iOS = /iPhone|iPad|iPod/i.test(this.ua);
217
- // Android Device ?
218
- this.android = /Android/i.test(this.ua);
219
- this.android2 = /Android 2/i.test(this.ua);
220
- // Linux platform
221
- this.linux = /Linux/i.test(this.ua);
222
- // Chrome OS ?
223
- this.chromeOS = /CrOS/.test(this.ua);
224
- // Windows Device ?
225
- this.wp = /Windows Phone/i.test(this.ua);
226
- // Blackberry device ?
227
- this.BlackBerry = /BlackBerry/i.test(this.ua);
228
- // Kindle device ?
229
- this.Kindle = /Kindle|Silk.*Mobile Safari/i.test(this.ua);
230
- // Mobile platform
231
- this.isMobile = /Mobi/i.test(this.ua) ||
232
- this.iOS ||
233
- this.android ||
234
- this.wp ||
235
- this.BlackBerry ||
236
- this.Kindle || false;
237
- // ejecta
238
- this.ejecta = (typeof window.ejecta !== "undefined");
239
- // Wechat
240
- this.isWeixin = /MicroMessenger/i.test(this.ua);
241
- },
229
+
230
+ // Initialize me.timer on Boot event
231
+ event.on(event.BOOT, () => {
232
+ _checkCapabilities();
233
+ });
234
+
235
+
236
+ // public export
237
+ let device = {
242
238
 
243
239
  /**
244
240
  * the `ua` read-only property returns the user agent string for the current browser.
@@ -551,7 +547,7 @@ let device = {
551
547
  /**
552
548
  * Specify whether to stop the game when losing focus or not.
553
549
  * The engine restarts on focus if this is enabled.
554
- * @type {boolean}
550
+ * @type {Boolean}
555
551
  * @default false
556
552
  * @memberOf me.device
557
553
  */
@@ -569,9 +565,7 @@ let device = {
569
565
 
570
566
  /**
571
567
  * specify a function to execute when the Device is fully loaded and ready
572
- * @name onReady
573
- * @memberOf me.device
574
- * @function
568
+ * @function me.device.onReady
575
569
  * @param {Function} fn the function to be executed
576
570
  * @example
577
571
  * // small game skeleton
@@ -627,15 +621,15 @@ let device = {
627
621
  // directly call domReady if document is already "ready"
628
622
  if (document.readyState === "complete") {
629
623
  // defer the fn call to ensure our script is fully loaded
630
- window.setTimeout(this._domReady, 0);
624
+ window.setTimeout(_domReady, 0);
631
625
  }
632
626
  else {
633
627
  if (document.addEventListener) {
634
628
  // Use the handy event callback
635
- document.addEventListener("DOMContentLoaded", this._domReady, false);
629
+ document.addEventListener("DOMContentLoaded", _domReady, false);
636
630
  }
637
631
  // A fallback to window.onload, that will always work
638
- window.addEventListener("load", this._domReady, false);
632
+ window.addEventListener("load", _domReady, false);
639
633
  }
640
634
  readyBound = true;
641
635
  }
@@ -644,33 +638,29 @@ let device = {
644
638
 
645
639
  /**
646
640
  * enable/disable swipe on WebView.
647
- * @name enableSwipe
648
- * @memberOf me.device
649
- * @function
650
- * @param {boolean} [enable=true] enable or disable swipe.
641
+ * @function me.device.enableSwipe
642
+ * @param {Boolean} [enable=true] enable or disable swipe.
651
643
  */
652
644
  enableSwipe(enable) {
653
645
  if (enable !== false) {
654
646
  if (swipeEnabled === false) {
655
- window.document.removeEventListener("touchmove", disableSwipeFn, false);
647
+ window.document.removeEventListener("touchmove", _disableSwipeFn, false);
656
648
  swipeEnabled = true;
657
649
  }
658
650
  } else if (swipeEnabled === true) {
659
- window.document.addEventListener("touchmove", disableSwipeFn, false);
651
+ window.document.addEventListener("touchmove", _disableSwipeFn, false);
660
652
  swipeEnabled = false;
661
653
  }
662
654
  },
663
655
 
664
656
  /**
665
657
  * Triggers a fullscreen request. Requires fullscreen support from the browser/device.
666
- * @name requestFullscreen
667
- * @memberOf me.device
668
- * @function
658
+ * @function me.device.requestFullscreen
669
659
  * @param {Object} [element=default canvas object] the element to be set in full-screen mode.
670
660
  * @example
671
661
  * // add a keyboard shortcut to toggle Fullscreen mode on/off
672
662
  * me.input.bindKey(me.input.KEY.F, "toggleFullscreen");
673
- * me.event.subscribe(me.event.KEYDOWN, function (action, keyCode, edge) {
663
+ * me.event.on(me.event.KEYDOWN, function (action, keyCode, edge) {
674
664
  * // toggle fullscreen on/off
675
665
  * if (action === "toggleFullscreen") {
676
666
  * if (!me.device.isFullscreen) {
@@ -683,7 +673,7 @@ let device = {
683
673
  */
684
674
  requestFullscreen(element) {
685
675
  if (this.hasFullscreenSupport) {
686
- element = element || video.getParent();
676
+ element = element || getParent();
687
677
  element.requestFullscreen = prefixed("requestFullscreen", element) ||
688
678
  element.mozRequestFullScreen;
689
679
 
@@ -693,9 +683,7 @@ let device = {
693
683
 
694
684
  /**
695
685
  * Exit fullscreen mode. Requires fullscreen support from the browser/device.
696
- * @name exitFullscreen
697
- * @memberOf me.device
698
- * @function
686
+ * @function me.device.exitFullscreen
699
687
  */
700
688
  exitFullscreen() {
701
689
  if (this.hasFullscreenSupport) {
@@ -706,10 +694,8 @@ let device = {
706
694
  /**
707
695
  * Return a string representing the orientation of the device screen.
708
696
  * It can be "any", "natural", "landscape", "portrait", "portrait-primary", "portrait-secondary", "landscape-primary", "landscape-secondary"
709
- * @name getScreenOrientation
710
- * @memberOf me.device
697
+ * @function me.device.getScreenOrientation
711
698
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation
712
- * @function
713
699
  * @return {String} the screen orientation
714
700
  */
715
701
  getScreenOrientation() {
@@ -742,10 +728,8 @@ let device = {
742
728
  /**
743
729
  * locks the device screen into the specified orientation.<br>
744
730
  * This method only works for installed Web apps or for Web pages in full-screen mode.
745
- * @name lockOrientation
746
- * @memberOf me.device
731
+ * @function me.device.lockOrientation
747
732
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation
748
- * @function
749
733
  * @return {Boolean} true if the orientation was unsuccessfully locked
750
734
  */
751
735
  lockOrientation(orientation) {
@@ -762,10 +746,8 @@ let device = {
762
746
  /**
763
747
  * unlocks the device screen into the specified orientation.<br>
764
748
  * This method only works for installed Web apps or for Web pages in full-screen mode.
765
- * @name unlockOrientation
766
- * @memberOf me.device
749
+ * @function me.device.unlockOrientation
767
750
  * @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation
768
- * @function
769
751
  * @return {Boolean} true if the orientation was unsuccessfully unlocked
770
752
  */
771
753
  unlockOrientation(orientation) {
@@ -781,9 +763,7 @@ let device = {
781
763
 
782
764
  /**
783
765
  * return true if the device screen orientation is in Portrait mode
784
- * @name isPortrait
785
- * @memberOf me.device
786
- * @function
766
+ * @function me.device.isPortrait
787
767
  * @return {Boolean}
788
768
  */
789
769
  isPortrait() {
@@ -792,9 +772,7 @@ let device = {
792
772
 
793
773
  /**
794
774
  * return true if the device screen orientation is in Portrait mode
795
- * @name isLandscape
796
- * @memberOf me.device
797
- * @function
775
+ * @function me.device.isLandscape
798
776
  * @return {Boolean}
799
777
  */
800
778
  isLandscape() {
@@ -803,11 +781,9 @@ let device = {
803
781
 
804
782
  /**
805
783
  * return the device storage
806
- * @name getStorage
807
- * @memberOf me.device
808
- * @function
809
- * @param {String} [type="local"]
784
+ * @function me.device.getStorage
810
785
  * @see me.save
786
+ * @param {String} [type="local"]
811
787
  * @return {Object} a reference to the device storage
812
788
  */
813
789
  getStorage(type = "local") {
@@ -822,9 +798,7 @@ let device = {
822
798
 
823
799
  /**
824
800
  * return the parent DOM element for the given parent name or HTMLElement object
825
- * @name getParentElement
826
- * @memberOf me.device
827
- * @function
801
+ * @function me.device.getParentElement
828
802
  * @param {String|HTMLElement} element the parent element name or a HTMLElement object
829
803
  * @return {HTMLElement} the parent Element
830
804
  */
@@ -840,9 +814,7 @@ let device = {
840
814
 
841
815
  /**
842
816
  * return the DOM element for the given element name or HTMLElement object
843
- * @name getElement
844
- * @memberOf me.device
845
- * @function
817
+ * @function me.device.getElement
846
818
  * @param {String|HTMLElement} element the parent element name or a HTMLElement object
847
819
  * @return {HTMLElement} the corresponding DOM Element or null if not existing
848
820
  */
@@ -869,10 +841,8 @@ let device = {
869
841
  /**
870
842
  * returns the size of the given HTMLElement and its position relative to the viewport
871
843
  * <br><img src="images/element-box-diagram.png"/>
872
- * @name getElementBounds
873
844
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
874
- * @memberOf me.device
875
- * @function
845
+ * @function me.device.getElementBounds
876
846
  * @param {String|HTMLElement} element an HTMLElement object
877
847
  * @return {DOMRect} the size and position of the element relatively to the viewport
878
848
  */
@@ -889,10 +859,8 @@ let device = {
889
859
  /**
890
860
  * returns the size of the given HTMLElement Parent and its position relative to the viewport
891
861
  * <br><img src="images/element-box-diagram.png"/>
892
- * @name getParentBounds
893
862
  * @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
894
- * @memberOf me.device
895
- * @function
863
+ * @function me.device.getParentBounds
896
864
  * @param {String|HTMLElement} element an HTMLElement object
897
865
  * @return {DOMRect} the size and position of the given element parent relative to the viewport
898
866
  */
@@ -902,9 +870,7 @@ let device = {
902
870
 
903
871
  /**
904
872
  * returns true if the device supports WebGL
905
- * @name isWebGLSupported
906
- * @memberOf me.device
907
- * @function
873
+ * @function me.device.isWebGLSupported
908
874
  * @param {Object} [options] context creation options
909
875
  * @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.
910
876
  * @return {Boolean} true if WebGL is supported
@@ -927,9 +893,7 @@ let device = {
927
893
 
928
894
  /**
929
895
  * return the highest precision format supported by this device for GL Shaders
930
- * @name getMaxShaderPrecision
931
- * @memberOf me.device
932
- * @function
896
+ * @function me.device.getMaxShaderPrecision
933
897
  * @param {WebGLRenderingContext} gl
934
898
  * @return {Boolean} "lowp", "mediump", or "highp"
935
899
  */
@@ -947,9 +911,7 @@ let device = {
947
911
 
948
912
  /**
949
913
  * Makes a request to bring this device window to the front.
950
- * @name focus
951
- * @memberOf me.device
952
- * @function
914
+ * @function me.device.focus
953
915
  * @example
954
916
  * if (clicked) {
955
917
  * me.device.focus();
@@ -975,6 +937,10 @@ let device = {
975
937
  this.accelerationZ = e.accelerationIncludingGravity.z;
976
938
  },
977
939
 
940
+ /**
941
+ * event management (Accelerometer)
942
+ * @ignore
943
+ */
978
944
  onDeviceRotate(e) {
979
945
  this.gamma = e.gamma;
980
946
  this.beta = e.beta;
@@ -985,9 +951,7 @@ let device = {
985
951
  * Enters pointer lock, requesting it from the user first. Works on supported devices & browsers
986
952
  * Must be called in a click event or an event that requires user interaction.
987
953
  * If you need to run handle events for errors or change of the pointer lock, see below.
988
- * @name turnOnPointerLock
989
- * @memberOf me.device
990
- * @function
954
+ * @function me.device.turnOnPointerLock
991
955
  * @example
992
956
  * document.addEventListener("pointerlockchange", pointerlockchange, false);
993
957
  * document.addEventListener("mozpointerlockchange", pointerlockchange, false);
@@ -999,7 +963,7 @@ let device = {
999
963
  */
1000
964
  turnOnPointerLock() {
1001
965
  if (this.hasPointerLockSupport) {
1002
- var element = video.getParent();
966
+ var element = getParent();
1003
967
  if (this.ua.match(/Firefox/i)) {
1004
968
  var fullscreenchange = function() {
1005
969
  if ((prefixed("fullscreenElement", document) ||
@@ -1026,8 +990,7 @@ let device = {
1026
990
 
1027
991
  /**
1028
992
  * Exits pointer lock. Works on supported devices & browsers
1029
- * @name turnOffPointerLock
1030
- * @memberOf me.device
993
+ * @function me.device.turnOffPointerLock
1031
994
  * @function
1032
995
  */
1033
996
  turnOffPointerLock() {
@@ -1039,10 +1002,7 @@ let device = {
1039
1002
  /**
1040
1003
  * Enable monitor of the device accelerator to detect the amount of physical force of acceleration the device is receiving.
1041
1004
  * (one some device a first user gesture will be required before calling this function)
1042
- * @name watchAccelerometer
1043
- * @memberOf me.device
1044
- * @public
1045
- * @function
1005
+ * @function me.device.watchAccelerometer
1046
1006
  * @see me.device.accelerationX
1047
1007
  * @see me.device.accelerationY
1048
1008
  * @see me.device.accelerationZ
@@ -1080,10 +1040,7 @@ let device = {
1080
1040
 
1081
1041
  /**
1082
1042
  * unwatch Accelerometor event
1083
- * @name unwatchAccelerometer
1084
- * @memberOf me.device
1085
- * @public
1086
- * @function
1043
+ * @function me.device.unwatchAccelerometer
1087
1044
  */
1088
1045
  unwatchAccelerometer() {
1089
1046
  if (accelInitialized) {
@@ -1096,10 +1053,7 @@ let device = {
1096
1053
  /**
1097
1054
  * Enable monitor of the device orientation to detect the current orientation of the device as compared to the Earth coordinate frame.
1098
1055
  * (one some device a first user gesture will be required before calling this function)
1099
- * @name watchDeviceOrientation
1100
- * @memberOf me.device
1101
- * @public
1102
- * @function
1056
+ * @function me.device.watchDeviceOrientation
1103
1057
  * @see me.device.alpha
1104
1058
  * @see me.device.beta
1105
1059
  * @see me.device.gamma
@@ -1135,10 +1089,7 @@ let device = {
1135
1089
 
1136
1090
  /**
1137
1091
  * unwatch Device orientation event
1138
- * @name unwatchDeviceOrientation
1139
- * @memberOf me.device
1140
- * @public
1141
- * @function
1092
+ * @function me.device.unwatchDeviceOrientation
1142
1093
  */
1143
1094
  unwatchDeviceOrientation() {
1144
1095
  if (deviceOrientationInitialized) {
@@ -1152,10 +1103,7 @@ let device = {
1152
1103
  * If the device doesn't support vibration, this method has no effect. <br>
1153
1104
  * If a vibration pattern is already in progress when this method is called,
1154
1105
  * the previous pattern is halted and the new one begins instead.
1155
- * @name vibrate
1156
- * @memberOf me.device
1157
- * @public
1158
- * @function
1106
+ * @function me.device.vibrate
1159
1107
  * @param {Number|Number[]} pattern pattern of vibration and pause intervals
1160
1108
  * @example
1161
1109
  * // vibrate for 1000 ms
@@ -1180,7 +1128,7 @@ let device = {
1180
1128
  * @name devicePixelRatio
1181
1129
  * @memberOf me.device
1182
1130
  * @public
1183
- * @type Number
1131
+ * @type {Number}
1184
1132
  * @readonly
1185
1133
  * @return {Number}
1186
1134
  */
@@ -1198,9 +1146,9 @@ Object.defineProperty(device, "devicePixelRatio", {
1198
1146
  * @name isFullscreen
1199
1147
  * @memberOf me.device
1200
1148
  * @public
1201
- * @type Boolean
1149
+ * @type {Boolean}
1202
1150
  * @readonly
1203
- * @return {boolean}
1151
+ * @return {Boolean}
1204
1152
  */
1205
1153
  Object.defineProperty(device, "isFullscreen", {
1206
1154
  /**
@@ -1221,16 +1169,16 @@ Object.defineProperty(device, "isFullscreen", {
1221
1169
  * @name sound
1222
1170
  * @memberOf me.device
1223
1171
  * @public
1224
- * @type Boolean
1172
+ * @type {Boolean}
1225
1173
  * @readonly
1226
- * @return {boolean}
1174
+ * @return {Boolean}
1227
1175
  */
1228
1176
  Object.defineProperty(device, "sound", {
1229
1177
  /**
1230
1178
  * @ignore
1231
1179
  */
1232
1180
  get: function () {
1233
- return audio.hasAudio();
1181
+ return hasAudio();
1234
1182
  }
1235
1183
  });
1236
1184