melonjs 10.3.0 → 10.5.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.
- package/README.md +6 -6
- package/dist/melonjs.js +3147 -3293
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3411 -3852
- package/dist/melonjs.module.js +3448 -3210
- package/package.json +18 -17
- package/src/audio/audio.js +29 -30
- package/src/camera/camera2d.js +46 -56
- package/src/entity/entity.js +30 -36
- package/src/game.js +21 -22
- package/src/geometries/ellipse.js +40 -46
- package/src/geometries/line.js +9 -11
- package/src/geometries/poly.js +53 -53
- package/src/geometries/rectangle.js +42 -44
- package/src/index.js +9 -26
- package/src/input/gamepad.js +11 -10
- package/src/input/input.js +2 -3
- package/src/input/keyboard.js +113 -113
- package/src/input/pointer.js +30 -31
- package/src/input/pointerevent.js +26 -26
- package/src/lang/deprecated.js +65 -6
- package/src/level/level.js +23 -24
- package/src/level/tiled/TMXGroup.js +7 -8
- package/src/level/tiled/TMXLayer.js +30 -32
- package/src/level/tiled/TMXObject.js +21 -21
- package/src/level/tiled/TMXTile.js +18 -18
- package/src/level/tiled/TMXTileMap.js +39 -44
- package/src/level/tiled/TMXTileset.js +12 -15
- package/src/level/tiled/TMXTilesetGroup.js +9 -9
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +7 -8
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +4 -5
- package/src/level/tiled/renderer/TMXRenderer.js +24 -25
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +1 -4
- package/src/loader/loader.js +14 -15
- package/src/loader/loadingscreen.js +2 -4
- package/src/math/color.js +47 -66
- package/src/math/math.js +15 -16
- package/src/math/matrix2.js +53 -58
- package/src/math/matrix3.js +56 -62
- package/src/math/observable_vector2.js +75 -76
- package/src/math/observable_vector3.js +79 -80
- package/src/math/vector2.js +91 -92
- package/src/math/vector3.js +94 -96
- package/src/particles/emitter.js +38 -40
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +46 -143
- package/src/physics/bounds.js +47 -47
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +18 -17
- package/src/physics/quadtree.js +17 -19
- package/src/physics/sat.js +26 -26
- package/src/physics/world.js +24 -28
- package/src/plugin/plugin.js +11 -14
- package/src/renderable/GUI.js +41 -46
- package/src/renderable/collectable.js +4 -8
- package/src/renderable/colorlayer.js +6 -10
- package/src/renderable/container.js +87 -72
- package/src/renderable/dragndrop.js +224 -0
- package/src/renderable/imagelayer.js +25 -31
- package/src/renderable/nineslicesprite.js +41 -41
- package/src/renderable/renderable.js +114 -125
- package/src/renderable/sprite.js +62 -68
- package/src/renderable/trigger.js +25 -30
- package/src/state/stage.js +13 -17
- package/src/state/state.js +26 -27
- package/src/system/device.js +74 -75
- package/src/system/event.js +71 -72
- package/src/system/pooling.js +11 -12
- package/src/system/save.js +3 -4
- package/src/system/timer.js +19 -20
- package/src/text/bitmaptext.js +57 -54
- package/src/text/bitmaptextdata.js +10 -10
- package/src/text/glyph.js +3 -0
- package/src/text/text.js +44 -49
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +43 -44
- package/src/utils/agent.js +3 -4
- package/src/utils/array.js +4 -5
- package/src/utils/file.js +3 -4
- package/src/utils/function.js +4 -5
- package/src/utils/string.js +7 -9
- package/src/utils/utils.js +4 -5
- package/src/video/canvas/canvas_renderer.js +58 -59
- package/src/video/renderer.js +49 -53
- package/src/video/texture.js +98 -111
- package/src/video/texture_cache.js +24 -6
- package/src/video/video.js +16 -17
- package/src/video/webgl/glshader.js +37 -38
- package/src/video/webgl/webgl_compositor.js +31 -32
- package/src/video/webgl/webgl_renderer.js +79 -80
- package/src/entity/draggable.js +0 -130
- package/src/entity/droptarget.js +0 -101
package/src/system/device.js
CHANGED
|
@@ -7,8 +7,7 @@ import * as event from "./../system/event.js";
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* The device capabilities and specific events
|
|
10
|
-
* @namespace
|
|
11
|
-
* @memberof me
|
|
10
|
+
* @namespace device
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
// private properties
|
|
@@ -253,7 +252,7 @@ let device = {
|
|
|
253
252
|
* @type {string}
|
|
254
253
|
* @readonly
|
|
255
254
|
* @name ua
|
|
256
|
-
* @memberof
|
|
255
|
+
* @memberof device
|
|
257
256
|
*/
|
|
258
257
|
ua : navigator.userAgent,
|
|
259
258
|
|
|
@@ -263,7 +262,7 @@ let device = {
|
|
|
263
262
|
* @type {boolean}
|
|
264
263
|
* @readonly
|
|
265
264
|
* @name localStorage
|
|
266
|
-
* @memberof
|
|
265
|
+
* @memberof device
|
|
267
266
|
*/
|
|
268
267
|
localStorage : false,
|
|
269
268
|
|
|
@@ -272,7 +271,7 @@ let device = {
|
|
|
272
271
|
* @type {boolean}
|
|
273
272
|
* @readonly
|
|
274
273
|
* @name hasAccelerometer
|
|
275
|
-
* @memberof
|
|
274
|
+
* @memberof device
|
|
276
275
|
*/
|
|
277
276
|
hasAccelerometer : false,
|
|
278
277
|
|
|
@@ -281,7 +280,7 @@ let device = {
|
|
|
281
280
|
* @type {boolean}
|
|
282
281
|
* @readonly
|
|
283
282
|
* @name hasDeviceOrientation
|
|
284
|
-
* @memberof
|
|
283
|
+
* @memberof device
|
|
285
284
|
*/
|
|
286
285
|
hasDeviceOrientation : false,
|
|
287
286
|
|
|
@@ -291,7 +290,7 @@ let device = {
|
|
|
291
290
|
* @type {boolean}
|
|
292
291
|
* @readonly
|
|
293
292
|
* @name ScreenOrientation
|
|
294
|
-
* @memberof
|
|
293
|
+
* @memberof device
|
|
295
294
|
*/
|
|
296
295
|
ScreenOrientation : false,
|
|
297
296
|
|
|
@@ -300,7 +299,7 @@ let device = {
|
|
|
300
299
|
* @type {boolean}
|
|
301
300
|
* @readonly
|
|
302
301
|
* @name hasFullscreenSupport
|
|
303
|
-
* @memberof
|
|
302
|
+
* @memberof device
|
|
304
303
|
*/
|
|
305
304
|
hasFullscreenSupport : false,
|
|
306
305
|
|
|
@@ -309,7 +308,7 @@ let device = {
|
|
|
309
308
|
* @type {boolean}
|
|
310
309
|
* @readonly
|
|
311
310
|
* @name hasPointerLockSupport
|
|
312
|
-
* @memberof
|
|
311
|
+
* @memberof device
|
|
313
312
|
*/
|
|
314
313
|
hasPointerLockSupport : false,
|
|
315
314
|
|
|
@@ -318,7 +317,7 @@ let device = {
|
|
|
318
317
|
* @type {boolean}
|
|
319
318
|
* @readonly
|
|
320
319
|
* @name hasWebAudio
|
|
321
|
-
* @memberof
|
|
320
|
+
* @memberof device
|
|
322
321
|
*/
|
|
323
322
|
hasWebAudio : false,
|
|
324
323
|
|
|
@@ -327,7 +326,7 @@ let device = {
|
|
|
327
326
|
* @type {boolean}
|
|
328
327
|
* @readonly
|
|
329
328
|
* @name nativeBase64
|
|
330
|
-
* @memberof
|
|
329
|
+
* @memberof device
|
|
331
330
|
*/
|
|
332
331
|
nativeBase64 : (typeof(window.atob) === "function"),
|
|
333
332
|
|
|
@@ -336,7 +335,7 @@ let device = {
|
|
|
336
335
|
* @type {number}
|
|
337
336
|
* @readonly
|
|
338
337
|
* @name maxTouchPoints
|
|
339
|
-
* @memberof
|
|
338
|
+
* @memberof device
|
|
340
339
|
* @example
|
|
341
340
|
* if (me.device.maxTouchPoints > 1) {
|
|
342
341
|
* // device supports multi-touch
|
|
@@ -349,7 +348,7 @@ let device = {
|
|
|
349
348
|
* @type {boolean}
|
|
350
349
|
* @readonly
|
|
351
350
|
* @name touch
|
|
352
|
-
* @memberof
|
|
351
|
+
* @memberof device
|
|
353
352
|
*/
|
|
354
353
|
touch : false,
|
|
355
354
|
|
|
@@ -358,7 +357,7 @@ let device = {
|
|
|
358
357
|
* @type {boolean}
|
|
359
358
|
* @readonly
|
|
360
359
|
* @name wheel
|
|
361
|
-
* @memberof
|
|
360
|
+
* @memberof device
|
|
362
361
|
*/
|
|
363
362
|
wheel : false,
|
|
364
363
|
|
|
@@ -368,7 +367,7 @@ let device = {
|
|
|
368
367
|
* @type {boolean}
|
|
369
368
|
* @readonly
|
|
370
369
|
* @name isMobile
|
|
371
|
-
* @memberof
|
|
370
|
+
* @memberof device
|
|
372
371
|
*/
|
|
373
372
|
isMobile : false,
|
|
374
373
|
|
|
@@ -377,7 +376,7 @@ let device = {
|
|
|
377
376
|
* @type {boolean}
|
|
378
377
|
* @readonly
|
|
379
378
|
* @name iOS
|
|
380
|
-
* @memberof
|
|
379
|
+
* @memberof device
|
|
381
380
|
*/
|
|
382
381
|
iOS : false,
|
|
383
382
|
|
|
@@ -386,7 +385,7 @@ let device = {
|
|
|
386
385
|
* @type {boolean}
|
|
387
386
|
* @readonly
|
|
388
387
|
* @name android
|
|
389
|
-
* @memberof
|
|
388
|
+
* @memberof device
|
|
390
389
|
*/
|
|
391
390
|
android : false,
|
|
392
391
|
|
|
@@ -395,7 +394,7 @@ let device = {
|
|
|
395
394
|
* @type {boolean}
|
|
396
395
|
* @readonly
|
|
397
396
|
* @name android2
|
|
398
|
-
* @memberof
|
|
397
|
+
* @memberof device
|
|
399
398
|
*/
|
|
400
399
|
android2 : false,
|
|
401
400
|
|
|
@@ -404,7 +403,7 @@ let device = {
|
|
|
404
403
|
* @type {boolean}
|
|
405
404
|
* @readonly
|
|
406
405
|
* @name linux
|
|
407
|
-
* @memberof
|
|
406
|
+
* @memberof device
|
|
408
407
|
*/
|
|
409
408
|
linux : false,
|
|
410
409
|
|
|
@@ -414,7 +413,7 @@ let device = {
|
|
|
414
413
|
* @readonly
|
|
415
414
|
* @see http://impactjs.com/ejecta
|
|
416
415
|
* @name ejecta
|
|
417
|
-
* @memberof
|
|
416
|
+
* @memberof device
|
|
418
417
|
*/
|
|
419
418
|
ejecta : false,
|
|
420
419
|
|
|
@@ -423,7 +422,7 @@ let device = {
|
|
|
423
422
|
* @type {boolean}
|
|
424
423
|
* @readonly
|
|
425
424
|
* @name isWeixin
|
|
426
|
-
* @memberof
|
|
425
|
+
* @memberof device
|
|
427
426
|
*/
|
|
428
427
|
isWeixin : false,
|
|
429
428
|
|
|
@@ -432,7 +431,7 @@ let device = {
|
|
|
432
431
|
* @type {boolean}
|
|
433
432
|
* @readonly
|
|
434
433
|
* @name chromeOS
|
|
435
|
-
* @memberof
|
|
434
|
+
* @memberof device
|
|
436
435
|
*/
|
|
437
436
|
chromeOS : false,
|
|
438
437
|
|
|
@@ -441,7 +440,7 @@ let device = {
|
|
|
441
440
|
* @type {boolean}
|
|
442
441
|
* @readonly
|
|
443
442
|
* @name wp
|
|
444
|
-
* @memberof
|
|
443
|
+
* @memberof device
|
|
445
444
|
*/
|
|
446
445
|
wp : false,
|
|
447
446
|
|
|
@@ -450,7 +449,7 @@ let device = {
|
|
|
450
449
|
* @type {boolean}
|
|
451
450
|
* @readonly
|
|
452
451
|
* @name BlackBerry
|
|
453
|
-
* @memberof
|
|
452
|
+
* @memberof device
|
|
454
453
|
*/
|
|
455
454
|
BlackBerry : false,
|
|
456
455
|
|
|
@@ -459,7 +458,7 @@ let device = {
|
|
|
459
458
|
* @type {boolean}
|
|
460
459
|
* @readonly
|
|
461
460
|
* @name Kindle
|
|
462
|
-
* @memberof
|
|
461
|
+
* @memberof device
|
|
463
462
|
*/
|
|
464
463
|
Kindle : false,
|
|
465
464
|
|
|
@@ -469,8 +468,8 @@ let device = {
|
|
|
469
468
|
* @type {number}
|
|
470
469
|
* @readonly
|
|
471
470
|
* @name accelerationX
|
|
472
|
-
* @see
|
|
473
|
-
* @memberof
|
|
471
|
+
* @see device.watchAccelerometer
|
|
472
|
+
* @memberof device
|
|
474
473
|
*/
|
|
475
474
|
accelerationX : 0,
|
|
476
475
|
|
|
@@ -480,8 +479,8 @@ let device = {
|
|
|
480
479
|
* @type {number}
|
|
481
480
|
* @readonly
|
|
482
481
|
* @name accelerationY
|
|
483
|
-
* @see
|
|
484
|
-
* @memberof
|
|
482
|
+
* @see device.watchAccelerometer
|
|
483
|
+
* @memberof device
|
|
485
484
|
*/
|
|
486
485
|
accelerationY : 0,
|
|
487
486
|
|
|
@@ -491,8 +490,8 @@ let device = {
|
|
|
491
490
|
* @type {number}
|
|
492
491
|
* @readonly
|
|
493
492
|
* @name accelerationZ
|
|
494
|
-
* @see
|
|
495
|
-
* @memberof
|
|
493
|
+
* @see device.watchAccelerometer
|
|
494
|
+
* @memberof device
|
|
496
495
|
*/
|
|
497
496
|
accelerationZ : 0,
|
|
498
497
|
|
|
@@ -502,8 +501,8 @@ let device = {
|
|
|
502
501
|
* @type {number}
|
|
503
502
|
* @readonly
|
|
504
503
|
* @name gamma
|
|
505
|
-
* @see
|
|
506
|
-
* @memberof
|
|
504
|
+
* @see device.watchDeviceOrientation
|
|
505
|
+
* @memberof device
|
|
507
506
|
*/
|
|
508
507
|
gamma : 0,
|
|
509
508
|
|
|
@@ -513,8 +512,8 @@ let device = {
|
|
|
513
512
|
* @type {number}
|
|
514
513
|
* @readonly
|
|
515
514
|
* @name beta
|
|
516
|
-
* @see
|
|
517
|
-
* @memberof
|
|
515
|
+
* @see device.watchDeviceOrientation
|
|
516
|
+
* @memberof device
|
|
518
517
|
*/
|
|
519
518
|
beta: 0,
|
|
520
519
|
|
|
@@ -525,8 +524,8 @@ let device = {
|
|
|
525
524
|
* @type {number}
|
|
526
525
|
* @readonly
|
|
527
526
|
* @name alpha
|
|
528
|
-
* @see
|
|
529
|
-
* @memberof
|
|
527
|
+
* @see device.watchDeviceOrientation
|
|
528
|
+
* @memberof device
|
|
530
529
|
*/
|
|
531
530
|
alpha : 0,
|
|
532
531
|
|
|
@@ -538,7 +537,7 @@ let device = {
|
|
|
538
537
|
* @readonly
|
|
539
538
|
* @see http://www.w3schools.com/tags/ref_language_codes.asp
|
|
540
539
|
* @name language
|
|
541
|
-
* @memberof
|
|
540
|
+
* @memberof device
|
|
542
541
|
*/
|
|
543
542
|
language : navigator.language || navigator.browserLanguage || navigator.userLanguage || "en",
|
|
544
543
|
|
|
@@ -546,7 +545,7 @@ let device = {
|
|
|
546
545
|
* Specify whether to pause the game when losing focus
|
|
547
546
|
* @type {boolean}
|
|
548
547
|
* @default true
|
|
549
|
-
* @memberof
|
|
548
|
+
* @memberof device
|
|
550
549
|
*/
|
|
551
550
|
pauseOnBlur : true,
|
|
552
551
|
|
|
@@ -554,7 +553,7 @@ let device = {
|
|
|
554
553
|
* Specify whether to unpause the game when gaining focus
|
|
555
554
|
* @type {boolean}
|
|
556
555
|
* @default true
|
|
557
|
-
* @memberof
|
|
556
|
+
* @memberof device
|
|
558
557
|
*/
|
|
559
558
|
resumeOnFocus : true,
|
|
560
559
|
|
|
@@ -562,7 +561,7 @@ let device = {
|
|
|
562
561
|
* Specify whether to automatically bring the window to the front
|
|
563
562
|
* @type {boolean}
|
|
564
563
|
* @default true
|
|
565
|
-
* @memberof
|
|
564
|
+
* @memberof device
|
|
566
565
|
*/
|
|
567
566
|
autoFocus : true,
|
|
568
567
|
|
|
@@ -571,7 +570,7 @@ let device = {
|
|
|
571
570
|
* The engine restarts on focus if this is enabled.
|
|
572
571
|
* @type {boolean}
|
|
573
572
|
* @default false
|
|
574
|
-
* @memberof
|
|
573
|
+
* @memberof device
|
|
575
574
|
*/
|
|
576
575
|
stopOnBlur : false,
|
|
577
576
|
|
|
@@ -580,14 +579,14 @@ let device = {
|
|
|
580
579
|
* @type {boolean}
|
|
581
580
|
* @readonly
|
|
582
581
|
* @name OffScreenCanvas
|
|
583
|
-
* @memberof
|
|
582
|
+
* @memberof device
|
|
584
583
|
*/
|
|
585
584
|
OffscreenCanvas : false,
|
|
586
585
|
|
|
587
586
|
|
|
588
587
|
/**
|
|
589
588
|
* specify a function to execute when the Device is fully loaded and ready
|
|
590
|
-
* @function
|
|
589
|
+
* @function device.onReady
|
|
591
590
|
* @param {Function} fn the function to be executed
|
|
592
591
|
* @example
|
|
593
592
|
* // small game skeleton
|
|
@@ -660,7 +659,7 @@ let device = {
|
|
|
660
659
|
|
|
661
660
|
/**
|
|
662
661
|
* enable/disable swipe on WebView.
|
|
663
|
-
* @function
|
|
662
|
+
* @function device.enableSwipe
|
|
664
663
|
* @param {boolean} [enable=true] enable or disable swipe.
|
|
665
664
|
*/
|
|
666
665
|
enableSwipe(enable) {
|
|
@@ -677,7 +676,7 @@ let device = {
|
|
|
677
676
|
|
|
678
677
|
/**
|
|
679
678
|
* Triggers a fullscreen request. Requires fullscreen support from the browser/device.
|
|
680
|
-
* @function
|
|
679
|
+
* @function device.requestFullscreen
|
|
681
680
|
* @param {object} [element=default canvas object] the element to be set in full-screen mode.
|
|
682
681
|
* @example
|
|
683
682
|
* // add a keyboard shortcut to toggle Fullscreen mode on/off
|
|
@@ -705,7 +704,7 @@ let device = {
|
|
|
705
704
|
|
|
706
705
|
/**
|
|
707
706
|
* Exit fullscreen mode. Requires fullscreen support from the browser/device.
|
|
708
|
-
* @function
|
|
707
|
+
* @function device.exitFullscreen
|
|
709
708
|
*/
|
|
710
709
|
exitFullscreen() {
|
|
711
710
|
if (this.hasFullscreenSupport) {
|
|
@@ -716,7 +715,7 @@ let device = {
|
|
|
716
715
|
/**
|
|
717
716
|
* Return a string representing the orientation of the device screen.
|
|
718
717
|
* It can be "any", "natural", "landscape", "portrait", "portrait-primary", "portrait-secondary", "landscape-primary", "landscape-secondary"
|
|
719
|
-
* @function
|
|
718
|
+
* @function device.getScreenOrientation
|
|
720
719
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/orientation
|
|
721
720
|
* @returns {string} the screen orientation
|
|
722
721
|
*/
|
|
@@ -750,7 +749,7 @@ let device = {
|
|
|
750
749
|
/**
|
|
751
750
|
* locks the device screen into the specified orientation.<br>
|
|
752
751
|
* This method only works for installed Web apps or for Web pages in full-screen mode.
|
|
753
|
-
* @function
|
|
752
|
+
* @function device.lockOrientation
|
|
754
753
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation
|
|
755
754
|
* @param {string|string[]} orientation The orientation into which to lock the screen.
|
|
756
755
|
* @returns {boolean} true if the orientation was unsuccessfully locked
|
|
@@ -769,7 +768,7 @@ let device = {
|
|
|
769
768
|
/**
|
|
770
769
|
* unlocks the device screen into the specified orientation.<br>
|
|
771
770
|
* This method only works for installed Web apps or for Web pages in full-screen mode.
|
|
772
|
-
* @function
|
|
771
|
+
* @function device.unlockOrientation
|
|
773
772
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/Screen/lockOrientation
|
|
774
773
|
* @returns {boolean} true if the orientation was unsuccessfully unlocked
|
|
775
774
|
*/
|
|
@@ -786,7 +785,7 @@ let device = {
|
|
|
786
785
|
|
|
787
786
|
/**
|
|
788
787
|
* return true if the device screen orientation is in Portrait mode
|
|
789
|
-
* @function
|
|
788
|
+
* @function device.isPortrait
|
|
790
789
|
* @returns {boolean}
|
|
791
790
|
*/
|
|
792
791
|
isPortrait() {
|
|
@@ -795,7 +794,7 @@ let device = {
|
|
|
795
794
|
|
|
796
795
|
/**
|
|
797
796
|
* return true if the device screen orientation is in Portrait mode
|
|
798
|
-
* @function
|
|
797
|
+
* @function device.isLandscape
|
|
799
798
|
* @returns {boolean}
|
|
800
799
|
*/
|
|
801
800
|
isLandscape() {
|
|
@@ -804,8 +803,8 @@ let device = {
|
|
|
804
803
|
|
|
805
804
|
/**
|
|
806
805
|
* return the device storage
|
|
807
|
-
* @function
|
|
808
|
-
* @see
|
|
806
|
+
* @function device.getStorage
|
|
807
|
+
* @see save
|
|
809
808
|
* @param {string} [type="local"]
|
|
810
809
|
* @returns {object} a reference to the device storage
|
|
811
810
|
*/
|
|
@@ -821,7 +820,7 @@ let device = {
|
|
|
821
820
|
|
|
822
821
|
/**
|
|
823
822
|
* return the parent DOM element for the given parent name or HTMLElement object
|
|
824
|
-
* @function
|
|
823
|
+
* @function device.getParentElement
|
|
825
824
|
* @param {string|HTMLElement} element the parent element name or a HTMLElement object
|
|
826
825
|
* @returns {HTMLElement} the parent Element
|
|
827
826
|
*/
|
|
@@ -837,7 +836,7 @@ let device = {
|
|
|
837
836
|
|
|
838
837
|
/**
|
|
839
838
|
* return the DOM element for the given element name or HTMLElement object
|
|
840
|
-
* @function
|
|
839
|
+
* @function device.getElement
|
|
841
840
|
* @param {string|HTMLElement} element the parent element name or a HTMLElement object
|
|
842
841
|
* @returns {HTMLElement} the corresponding DOM Element or null if not existing
|
|
843
842
|
*/
|
|
@@ -865,7 +864,7 @@ let device = {
|
|
|
865
864
|
* returns the size of the given HTMLElement and its position relative to the viewport
|
|
866
865
|
* <br><img src="images/element-box-diagram.png"/>
|
|
867
866
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
|
|
868
|
-
* @function
|
|
867
|
+
* @function device.getElementBounds
|
|
869
868
|
* @param {string|HTMLElement} element an HTMLElement object
|
|
870
869
|
* @returns {DOMRect} the size and position of the element relatively to the viewport
|
|
871
870
|
*/
|
|
@@ -883,7 +882,7 @@ let device = {
|
|
|
883
882
|
* returns the size of the given HTMLElement Parent and its position relative to the viewport
|
|
884
883
|
* <br><img src="images/element-box-diagram.png"/>
|
|
885
884
|
* @see https://developer.mozilla.org/en-US/docs/Web/API/DOMRect
|
|
886
|
-
* @function
|
|
885
|
+
* @function device.getParentBounds
|
|
887
886
|
* @param {string|HTMLElement} element an HTMLElement object
|
|
888
887
|
* @returns {DOMRect} the size and position of the given element parent relative to the viewport
|
|
889
888
|
*/
|
|
@@ -893,7 +892,7 @@ let device = {
|
|
|
893
892
|
|
|
894
893
|
/**
|
|
895
894
|
* returns true if the device supports WebGL
|
|
896
|
-
* @function
|
|
895
|
+
* @function device.isWebGLSupported
|
|
897
896
|
* @param {object} [options] context creation options
|
|
898
897
|
* @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
898
|
* @returns {boolean} true if WebGL is supported
|
|
@@ -916,7 +915,7 @@ let device = {
|
|
|
916
915
|
|
|
917
916
|
/**
|
|
918
917
|
* return the highest precision format supported by this device for GL Shaders
|
|
919
|
-
* @function
|
|
918
|
+
* @function device.getMaxShaderPrecision
|
|
920
919
|
* @param {WebGLRenderingContext} gl
|
|
921
920
|
* @returns {boolean} "lowp", "mediump", or "highp"
|
|
922
921
|
*/
|
|
@@ -934,7 +933,7 @@ let device = {
|
|
|
934
933
|
|
|
935
934
|
/**
|
|
936
935
|
* Makes a request to bring this device window to the front.
|
|
937
|
-
* @function
|
|
936
|
+
* @function device.focus
|
|
938
937
|
* @example
|
|
939
938
|
* if (clicked) {
|
|
940
939
|
* me.device.focus();
|
|
@@ -973,10 +972,10 @@ let device = {
|
|
|
973
972
|
/**
|
|
974
973
|
* Enable monitor of the device accelerator to detect the amount of physical force of acceleration the device is receiving.
|
|
975
974
|
* (one some device a first user gesture will be required before calling this function)
|
|
976
|
-
* @function
|
|
977
|
-
* @see
|
|
978
|
-
* @see
|
|
979
|
-
* @see
|
|
975
|
+
* @function device.watchAccelerometer
|
|
976
|
+
* @see device.accelerationX
|
|
977
|
+
* @see device.accelerationY
|
|
978
|
+
* @see device.accelerationZ
|
|
980
979
|
* @returns {boolean} false if not supported or permission not granted by the user
|
|
981
980
|
* @example
|
|
982
981
|
* // try to enable device accelerometer event on user gesture
|
|
@@ -1011,7 +1010,7 @@ let device = {
|
|
|
1011
1010
|
|
|
1012
1011
|
/**
|
|
1013
1012
|
* unwatch Accelerometor event
|
|
1014
|
-
* @function
|
|
1013
|
+
* @function device.unwatchAccelerometer
|
|
1015
1014
|
*/
|
|
1016
1015
|
unwatchAccelerometer() {
|
|
1017
1016
|
if (accelInitialized) {
|
|
@@ -1024,10 +1023,10 @@ let device = {
|
|
|
1024
1023
|
/**
|
|
1025
1024
|
* Enable monitor of the device orientation to detect the current orientation of the device as compared to the Earth coordinate frame.
|
|
1026
1025
|
* (one some device a first user gesture will be required before calling this function)
|
|
1027
|
-
* @function
|
|
1028
|
-
* @see
|
|
1029
|
-
* @see
|
|
1030
|
-
* @see
|
|
1026
|
+
* @function device.watchDeviceOrientation
|
|
1027
|
+
* @see device.alpha
|
|
1028
|
+
* @see device.beta
|
|
1029
|
+
* @see device.gamma
|
|
1031
1030
|
* @returns {boolean} false if not supported or permission not granted by the user
|
|
1032
1031
|
* @example
|
|
1033
1032
|
* // try to enable device orientation event on user gesture
|
|
@@ -1060,7 +1059,7 @@ let device = {
|
|
|
1060
1059
|
|
|
1061
1060
|
/**
|
|
1062
1061
|
* unwatch Device orientation event
|
|
1063
|
-
* @function
|
|
1062
|
+
* @function device.unwatchDeviceOrientation
|
|
1064
1063
|
*/
|
|
1065
1064
|
unwatchDeviceOrientation() {
|
|
1066
1065
|
if (deviceOrientationInitialized) {
|
|
@@ -1074,7 +1073,7 @@ let device = {
|
|
|
1074
1073
|
* If the device doesn't support vibration, this method has no effect. <br>
|
|
1075
1074
|
* If a vibration pattern is already in progress when this method is called,
|
|
1076
1075
|
* the previous pattern is halted and the new one begins instead.
|
|
1077
|
-
* @function
|
|
1076
|
+
* @function device.vibrate
|
|
1078
1077
|
* @param {number|number[]} pattern pattern of vibration and pause intervals
|
|
1079
1078
|
* @example
|
|
1080
1079
|
* // vibrate for 1000 ms
|
|
@@ -1097,7 +1096,7 @@ let device = {
|
|
|
1097
1096
|
/**
|
|
1098
1097
|
* Ratio of the resolution in physical pixels to the resolution in CSS pixels for the current display device.
|
|
1099
1098
|
* @name devicePixelRatio
|
|
1100
|
-
* @memberof
|
|
1099
|
+
* @memberof device
|
|
1101
1100
|
* @public
|
|
1102
1101
|
* @type {number}
|
|
1103
1102
|
* @readonly
|
|
@@ -1115,7 +1114,7 @@ Object.defineProperty(device, "devicePixelRatio", {
|
|
|
1115
1114
|
/**
|
|
1116
1115
|
* Returns true if the browser/device is in full screen mode.
|
|
1117
1116
|
* @name isFullscreen
|
|
1118
|
-
* @memberof
|
|
1117
|
+
* @memberof device
|
|
1119
1118
|
* @public
|
|
1120
1119
|
* @type {boolean}
|
|
1121
1120
|
* @readonly
|
|
@@ -1138,7 +1137,7 @@ Object.defineProperty(device, "isFullscreen", {
|
|
|
1138
1137
|
/**
|
|
1139
1138
|
* Returns true if the browser/device has audio capabilities.
|
|
1140
1139
|
* @name sound
|
|
1141
|
-
* @memberof
|
|
1140
|
+
* @memberof device
|
|
1142
1141
|
* @public
|
|
1143
1142
|
* @type {boolean}
|
|
1144
1143
|
* @readonly
|