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.
- package/README.md +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
package/src/math/matrix3.js
CHANGED
|
@@ -5,10 +5,9 @@ import { EPSILON } from "./math.js";
|
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a 4x4 Matrix3d Object<br>
|
|
7
7
|
* @class Matrix3d
|
|
8
|
-
* @
|
|
9
|
-
* @constructor
|
|
8
|
+
* @memberof me
|
|
10
9
|
* @param {me.Matrix3d} [mat3d] An instance of me.Matrix3d to copy from
|
|
11
|
-
* @param {
|
|
10
|
+
* @param {number[]} [arguments...] Matrix elements. See {@link me.Matrix3d.setTransform}
|
|
12
11
|
*/
|
|
13
12
|
|
|
14
13
|
class Matrix3d {
|
|
@@ -39,10 +38,10 @@ class Matrix3d {
|
|
|
39
38
|
/**
|
|
40
39
|
* tx component of the matrix
|
|
41
40
|
* @public
|
|
42
|
-
* @type {
|
|
41
|
+
* @type {number}
|
|
43
42
|
* @readonly
|
|
44
43
|
* @name tx
|
|
45
|
-
* @
|
|
44
|
+
* @memberof me.Matrix3d
|
|
46
45
|
*/
|
|
47
46
|
get tx() {
|
|
48
47
|
return this.val[12];
|
|
@@ -51,10 +50,10 @@ class Matrix3d {
|
|
|
51
50
|
/**
|
|
52
51
|
* ty component of the matrix
|
|
53
52
|
* @public
|
|
54
|
-
* @type {
|
|
53
|
+
* @type {number}
|
|
55
54
|
* @readonly
|
|
56
55
|
* @name ty
|
|
57
|
-
* @
|
|
56
|
+
* @memberof me.Matrix3d
|
|
58
57
|
*/
|
|
59
58
|
get ty() {
|
|
60
59
|
return this.val[13];
|
|
@@ -63,10 +62,10 @@ class Matrix3d {
|
|
|
63
62
|
/**
|
|
64
63
|
* ty component of the matrix
|
|
65
64
|
* @public
|
|
66
|
-
* @type {
|
|
65
|
+
* @type {number}
|
|
67
66
|
* @readonly
|
|
68
67
|
* @name tz
|
|
69
|
-
* @
|
|
68
|
+
* @memberof me.Matrix3d
|
|
70
69
|
*/
|
|
71
70
|
get tz() {
|
|
72
71
|
return this.val[14];
|
|
@@ -77,9 +76,9 @@ class Matrix3d {
|
|
|
77
76
|
* the identity matrix and parameters position : <br>
|
|
78
77
|
* <img src="images/identity-matrix_2x.png"/>
|
|
79
78
|
* @name identity
|
|
80
|
-
* @
|
|
79
|
+
* @memberof me.Matrix3d
|
|
81
80
|
* @function
|
|
82
|
-
* @
|
|
81
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
83
82
|
*/
|
|
84
83
|
identity() {
|
|
85
84
|
return this.setTransform(
|
|
@@ -93,25 +92,25 @@ class Matrix3d {
|
|
|
93
92
|
/**
|
|
94
93
|
* set the matrix to the specified value
|
|
95
94
|
* @name setTransform
|
|
96
|
-
* @
|
|
95
|
+
* @memberof me.Matrix3d
|
|
97
96
|
* @function
|
|
98
|
-
* @param {
|
|
99
|
-
* @param {
|
|
100
|
-
* @param {
|
|
101
|
-
* @param {
|
|
102
|
-
* @param {
|
|
103
|
-
* @param {
|
|
104
|
-
* @param {
|
|
105
|
-
* @param {
|
|
106
|
-
* @param {
|
|
107
|
-
* @param {
|
|
108
|
-
* @param {
|
|
109
|
-
* @param {
|
|
110
|
-
* @param {
|
|
111
|
-
* @param {
|
|
112
|
-
* @param {
|
|
113
|
-
* @param {
|
|
114
|
-
* @
|
|
97
|
+
* @param {number} m00
|
|
98
|
+
* @param {number} m01
|
|
99
|
+
* @param {number} m02
|
|
100
|
+
* @param {number} m03
|
|
101
|
+
* @param {number} m10
|
|
102
|
+
* @param {number} m11
|
|
103
|
+
* @param {number} m12
|
|
104
|
+
* @param {number} m13
|
|
105
|
+
* @param {number} m20
|
|
106
|
+
* @param {number} m21
|
|
107
|
+
* @param {number} m22
|
|
108
|
+
* @param {number} m23
|
|
109
|
+
* @param {number} m30
|
|
110
|
+
* @param {number} m31
|
|
111
|
+
* @param {number} m32
|
|
112
|
+
* @param {number} m33
|
|
113
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
115
114
|
*/
|
|
116
115
|
setTransform(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
117
116
|
var a = this.val;
|
|
@@ -139,23 +138,23 @@ class Matrix3d {
|
|
|
139
138
|
/**
|
|
140
139
|
* Copies over the values from another me.Matrix3d.
|
|
141
140
|
* @name copy
|
|
142
|
-
* @
|
|
141
|
+
* @memberof me.Matrix3d
|
|
143
142
|
* @function
|
|
144
143
|
* @param {me.Matrix3d} m the matrix object to copy from
|
|
145
|
-
* @
|
|
144
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
146
145
|
*/
|
|
147
|
-
copy(
|
|
148
|
-
this.val.set(
|
|
146
|
+
copy(m) {
|
|
147
|
+
this.val.set(m.val);
|
|
149
148
|
return this;
|
|
150
149
|
}
|
|
151
150
|
|
|
152
151
|
/**
|
|
153
152
|
* Copies over the upper-left 2x2 values from the given me.Matrix2d
|
|
154
153
|
* @name fromMat2d
|
|
155
|
-
* @
|
|
154
|
+
* @memberof me.Matrix3d
|
|
156
155
|
* @function
|
|
157
156
|
* @param {me.Matrix2d} m the matrix object to copy from
|
|
158
|
-
* @
|
|
157
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
159
158
|
*/
|
|
160
159
|
fromMat2d(m) {
|
|
161
160
|
var b = m.val;
|
|
@@ -171,10 +170,10 @@ class Matrix3d {
|
|
|
171
170
|
/**
|
|
172
171
|
* multiply both matrix
|
|
173
172
|
* @name multiply
|
|
174
|
-
* @
|
|
173
|
+
* @memberof me.Matrix3d
|
|
175
174
|
* @function
|
|
176
175
|
* @param {me.Matrix3d} m Other matrix
|
|
177
|
-
* @
|
|
176
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
178
177
|
*/
|
|
179
178
|
multiply(m) {
|
|
180
179
|
var a = this.val;
|
|
@@ -227,9 +226,9 @@ class Matrix3d {
|
|
|
227
226
|
/**
|
|
228
227
|
* Transpose the value of this matrix.
|
|
229
228
|
* @name transpose
|
|
230
|
-
* @
|
|
229
|
+
* @memberof me.Matrix3d
|
|
231
230
|
* @function
|
|
232
|
-
* @
|
|
231
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
233
232
|
*/
|
|
234
233
|
transpose() {
|
|
235
234
|
var a = this.val,
|
|
@@ -259,9 +258,9 @@ class Matrix3d {
|
|
|
259
258
|
/**
|
|
260
259
|
* invert this matrix, causing it to apply the opposite transformation.
|
|
261
260
|
* @name invert
|
|
262
|
-
* @
|
|
261
|
+
* @memberof me.Matrix3d
|
|
263
262
|
* @function
|
|
264
|
-
* @
|
|
263
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
265
264
|
*/
|
|
266
265
|
invert() {
|
|
267
266
|
var a = this.val;
|
|
@@ -319,10 +318,10 @@ class Matrix3d {
|
|
|
319
318
|
/**
|
|
320
319
|
* apply the current transform to the given 2d or 3d vector
|
|
321
320
|
* @name apply
|
|
322
|
-
* @
|
|
321
|
+
* @memberof me.Matrix3d
|
|
323
322
|
* @function
|
|
324
|
-
* @param {me.Vector2d|me.Vector3d}
|
|
325
|
-
* @
|
|
323
|
+
* @param {me.Vector2d|me.Vector3d} v the vector object to be transformed
|
|
324
|
+
* @returns {me.Vector2d|me.Vector3d} result vector object.
|
|
326
325
|
*/
|
|
327
326
|
apply(v) {
|
|
328
327
|
var a = this.val,
|
|
@@ -345,10 +344,10 @@ class Matrix3d {
|
|
|
345
344
|
/**
|
|
346
345
|
* apply the inverted current transform to the given 2d or 3d vector
|
|
347
346
|
* @name applyInverse
|
|
348
|
-
* @
|
|
347
|
+
* @memberof me.Matrix3d
|
|
349
348
|
* @function
|
|
350
|
-
* @param {me.Vector2d|me.Vector3d}
|
|
351
|
-
* @
|
|
349
|
+
* @param {me.Vector2d|me.Vector3d} v the vector object to be transformed
|
|
350
|
+
* @returns {me.Vector2d|me.Vector3d} result vector object.
|
|
352
351
|
*/
|
|
353
352
|
applyInverse(v) {
|
|
354
353
|
// invert the current matrix
|
|
@@ -366,15 +365,15 @@ class Matrix3d {
|
|
|
366
365
|
* generate an orthogonal projection matrix, with the result replacing the current matrix
|
|
367
366
|
* <img src="images/glOrtho.gif"/><br>
|
|
368
367
|
* @name ortho
|
|
369
|
-
* @
|
|
368
|
+
* @memberof me.Matrix3d
|
|
370
369
|
* @function
|
|
371
|
-
* @param {
|
|
372
|
-
* @param {
|
|
373
|
-
* @param {
|
|
374
|
-
* @param {
|
|
375
|
-
* @param {
|
|
376
|
-
* @param {
|
|
377
|
-
* @
|
|
370
|
+
* @param {number} left farthest left on the x-axis
|
|
371
|
+
* @param {number} right farthest right on the x-axis
|
|
372
|
+
* @param {number} bottom farthest down on the y-axis
|
|
373
|
+
* @param {number} top farthest up on the y-axis
|
|
374
|
+
* @param {number} near distance to the near clipping plane along the -Z axis
|
|
375
|
+
* @param {number} far distance to the far clipping plane along the -Z axis
|
|
376
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
378
377
|
*/
|
|
379
378
|
ortho(left, right, bottom, top, near, far) {
|
|
380
379
|
var a = this.val;
|
|
@@ -405,12 +404,12 @@ class Matrix3d {
|
|
|
405
404
|
/**
|
|
406
405
|
* scale the matrix
|
|
407
406
|
* @name scale
|
|
408
|
-
* @
|
|
407
|
+
* @memberof me.Matrix3d
|
|
409
408
|
* @function
|
|
410
|
-
* @param {
|
|
411
|
-
* @param {
|
|
412
|
-
* @param {
|
|
413
|
-
* @
|
|
409
|
+
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
410
|
+
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
411
|
+
* @param {number} [z=0] a number representing the depth vector
|
|
412
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
414
413
|
*/
|
|
415
414
|
scale(x, y, z) {
|
|
416
415
|
var a = this.val,
|
|
@@ -439,10 +438,10 @@ class Matrix3d {
|
|
|
439
438
|
/**
|
|
440
439
|
* adds a 2D scaling transformation.
|
|
441
440
|
* @name scaleV
|
|
442
|
-
* @
|
|
441
|
+
* @memberof me.Matrix3d
|
|
443
442
|
* @function
|
|
444
|
-
* @param {me.Vector2d|me.Vector3d}
|
|
445
|
-
* @
|
|
443
|
+
* @param {me.Vector2d|me.Vector3d} v scaling vector
|
|
444
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
446
445
|
*/
|
|
447
446
|
scaleV(v) {
|
|
448
447
|
return this.scale(v.x, v.y, v.z);
|
|
@@ -451,10 +450,10 @@ class Matrix3d {
|
|
|
451
450
|
/**
|
|
452
451
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
453
452
|
* @name scaleX
|
|
454
|
-
* @
|
|
453
|
+
* @memberof me.Matrix3d
|
|
455
454
|
* @function
|
|
456
|
-
* @param {
|
|
457
|
-
* @
|
|
455
|
+
* @param {number} x x scaling vector
|
|
456
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
458
457
|
*/
|
|
459
458
|
scaleX(x) {
|
|
460
459
|
return this.scale(x, 1);
|
|
@@ -463,10 +462,10 @@ class Matrix3d {
|
|
|
463
462
|
/**
|
|
464
463
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
465
464
|
* @name scaleY
|
|
466
|
-
* @
|
|
465
|
+
* @memberof me.Matrix3d
|
|
467
466
|
* @function
|
|
468
|
-
* @param {
|
|
469
|
-
* @
|
|
467
|
+
* @param {number} y y scaling vector
|
|
468
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
470
469
|
*/
|
|
471
470
|
scaleY(y) {
|
|
472
471
|
return this.scale(1, y);
|
|
@@ -475,11 +474,11 @@ class Matrix3d {
|
|
|
475
474
|
/**
|
|
476
475
|
* rotate this matrix (counter-clockwise) by the specified angle (in radians).
|
|
477
476
|
* @name rotate
|
|
478
|
-
* @
|
|
477
|
+
* @memberof me.Matrix3d
|
|
479
478
|
* @function
|
|
480
|
-
* @param {
|
|
481
|
-
* @param {me.Vector3d}
|
|
482
|
-
* @
|
|
479
|
+
* @param {number} angle Rotation angle in radians.
|
|
480
|
+
* @param {me.Vector3d} v the axis to rotate around
|
|
481
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
483
482
|
*/
|
|
484
483
|
rotate(angle, v) {
|
|
485
484
|
var a = this.val,
|
|
@@ -554,20 +553,20 @@ class Matrix3d {
|
|
|
554
553
|
/**
|
|
555
554
|
* translate the matrix position using the given vector
|
|
556
555
|
* @name translate
|
|
557
|
-
* @
|
|
556
|
+
* @memberof me.Matrix3d
|
|
558
557
|
* @function
|
|
559
|
-
* @param {
|
|
560
|
-
* @param {
|
|
561
|
-
* @param {
|
|
562
|
-
* @
|
|
558
|
+
* @param {number} x a number representing the abscissa of the vector.
|
|
559
|
+
* @param {number} [y=x] a number representing the ordinate of the vector.
|
|
560
|
+
* @param {number} [z=0] a number representing the depth of the vector
|
|
561
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
563
562
|
*/
|
|
564
563
|
/**
|
|
565
564
|
* translate the matrix by a vector on the horizontal and vertical axis
|
|
566
565
|
* @name translateV
|
|
567
|
-
* @
|
|
566
|
+
* @memberof me.Matrix3d
|
|
568
567
|
* @function
|
|
569
568
|
* @param {me.Vector2d|me.Vector3d} v the vector to translate the matrix by
|
|
570
|
-
* @
|
|
569
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
571
570
|
*/
|
|
572
571
|
translate() {
|
|
573
572
|
var a = this.val;
|
|
@@ -596,10 +595,10 @@ class Matrix3d {
|
|
|
596
595
|
/**
|
|
597
596
|
* returns true if the matrix is an identity matrix.
|
|
598
597
|
* @name isIdentity
|
|
599
|
-
* @
|
|
598
|
+
* @memberof me.Matrix3d
|
|
600
599
|
* @function
|
|
601
|
-
* @
|
|
602
|
-
|
|
600
|
+
* @returns {boolean}
|
|
601
|
+
*/
|
|
603
602
|
isIdentity() {
|
|
604
603
|
var a = this.val;
|
|
605
604
|
|
|
@@ -626,10 +625,10 @@ class Matrix3d {
|
|
|
626
625
|
/**
|
|
627
626
|
* return true if the two matrices are identical
|
|
628
627
|
* @name equals
|
|
629
|
-
* @
|
|
628
|
+
* @memberof me.Matrix3d
|
|
630
629
|
* @function
|
|
631
630
|
* @param {me.Matrix3d} m the other matrix
|
|
632
|
-
* @
|
|
631
|
+
* @returns {boolean} true if both are equals
|
|
633
632
|
*/
|
|
634
633
|
equals(m) {
|
|
635
634
|
var b = m.val;
|
|
@@ -658,9 +657,9 @@ class Matrix3d {
|
|
|
658
657
|
/**
|
|
659
658
|
* Clone the Matrix
|
|
660
659
|
* @name clone
|
|
661
|
-
* @
|
|
660
|
+
* @memberof me.Matrix3d
|
|
662
661
|
* @function
|
|
663
|
-
* @
|
|
662
|
+
* @returns {me.Matrix3d}
|
|
664
663
|
*/
|
|
665
664
|
clone() {
|
|
666
665
|
return pool.pull("Matrix3d", this);
|
|
@@ -669,9 +668,9 @@ class Matrix3d {
|
|
|
669
668
|
/**
|
|
670
669
|
* return an array representation of this Matrix
|
|
671
670
|
* @name toArray
|
|
672
|
-
* @
|
|
671
|
+
* @memberof me.Matrix3d
|
|
673
672
|
* @function
|
|
674
|
-
* @
|
|
673
|
+
* @returns {Float32Array}
|
|
675
674
|
*/
|
|
676
675
|
toArray() {
|
|
677
676
|
return this.val;
|
|
@@ -680,9 +679,9 @@ class Matrix3d {
|
|
|
680
679
|
/**
|
|
681
680
|
* convert the object to a string representation
|
|
682
681
|
* @name toString
|
|
683
|
-
* @
|
|
682
|
+
* @memberof me.Matrix3d
|
|
684
683
|
* @function
|
|
685
|
-
* @
|
|
684
|
+
* @returns {string}
|
|
686
685
|
*/
|
|
687
686
|
toString() {
|
|
688
687
|
var a = this.val;
|