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/math/matrix2.js
CHANGED
|
@@ -6,14 +6,11 @@ import Matrix3d from "./matrix3.js";
|
|
|
6
6
|
* a Matrix2d Object.<br>
|
|
7
7
|
* the identity matrix and parameters position : <br>
|
|
8
8
|
* <img src="images/identity-matrix_2x.png"/>
|
|
9
|
-
* @class Matrix2d
|
|
10
|
-
* @memberof me
|
|
11
|
-
* @param {me.Matrix2d} [mat2d] An instance of me.Matrix2d to copy from
|
|
12
|
-
* @param {number[]} [arguments...] Matrix elements. See {@link me.Matrix2d.setTransform}
|
|
13
9
|
*/
|
|
14
|
-
|
|
15
10
|
class Matrix2d {
|
|
16
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @param {(Matrix2d|Matrix3d|...number)} args an instance of me.Matrix2d or me.Matrix3d to copy from, or individual matrix components (See {@link Matrix2d.setTransform}). If not arguments are given, the matrix will be set to Identity.
|
|
13
|
+
*/
|
|
17
14
|
constructor(...args) {
|
|
18
15
|
this.onResetEvent(...args);
|
|
19
16
|
}
|
|
@@ -45,10 +42,9 @@ class Matrix2d {
|
|
|
45
42
|
* tx component of the matrix
|
|
46
43
|
* @public
|
|
47
44
|
* @type {number}
|
|
48
|
-
* @
|
|
49
|
-
* @see me.Matrix2d.translate
|
|
45
|
+
* @see Matrix2d.translate
|
|
50
46
|
* @name tx
|
|
51
|
-
* @memberof
|
|
47
|
+
* @memberof Matrix2d
|
|
52
48
|
*/
|
|
53
49
|
get tx() {
|
|
54
50
|
return this.val[6];
|
|
@@ -58,10 +54,9 @@ class Matrix2d {
|
|
|
58
54
|
* ty component of the matrix
|
|
59
55
|
* @public
|
|
60
56
|
* @type {number}
|
|
61
|
-
* @
|
|
62
|
-
* @see me.Matrix2d.translate
|
|
57
|
+
* @see Matrix2d.translate
|
|
63
58
|
* @name ty
|
|
64
|
-
* @memberof
|
|
59
|
+
* @memberof Matrix2d
|
|
65
60
|
*/
|
|
66
61
|
get ty() {
|
|
67
62
|
return this.val[7];
|
|
@@ -72,9 +67,9 @@ class Matrix2d {
|
|
|
72
67
|
* the identity matrix and parameters position : <br>
|
|
73
68
|
* <img src="images/identity-matrix_2x.png"/>
|
|
74
69
|
* @name identity
|
|
75
|
-
* @memberof
|
|
70
|
+
* @memberof Matrix2d
|
|
76
71
|
* @function
|
|
77
|
-
* @returns {
|
|
72
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
78
73
|
*/
|
|
79
74
|
identity() {
|
|
80
75
|
this.setTransform(
|
|
@@ -88,7 +83,7 @@ class Matrix2d {
|
|
|
88
83
|
/**
|
|
89
84
|
* set the matrix to the specified value
|
|
90
85
|
* @name setTransform
|
|
91
|
-
* @memberof
|
|
86
|
+
* @memberof Matrix2d
|
|
92
87
|
* @function
|
|
93
88
|
* @param {number} a
|
|
94
89
|
* @param {number} b
|
|
@@ -99,7 +94,7 @@ class Matrix2d {
|
|
|
99
94
|
* @param {number} [g=0]
|
|
100
95
|
* @param {number} [h=0]
|
|
101
96
|
* @param {number} [i=1]
|
|
102
|
-
* @returns {
|
|
97
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
103
98
|
*/
|
|
104
99
|
setTransform() {
|
|
105
100
|
var a = this.val;
|
|
@@ -132,10 +127,10 @@ class Matrix2d {
|
|
|
132
127
|
/**
|
|
133
128
|
* Copies over the values from another me.Matrix2d.
|
|
134
129
|
* @name copy
|
|
135
|
-
* @memberof
|
|
130
|
+
* @memberof Matrix2d
|
|
136
131
|
* @function
|
|
137
|
-
* @param {
|
|
138
|
-
* @returns {
|
|
132
|
+
* @param {Matrix2d} m the matrix object to copy from
|
|
133
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
139
134
|
*/
|
|
140
135
|
copy(m) {
|
|
141
136
|
this.val.set(m.val);
|
|
@@ -145,10 +140,10 @@ class Matrix2d {
|
|
|
145
140
|
/**
|
|
146
141
|
* Copies over the upper-left 3x3 values from the given me.Matrix3d
|
|
147
142
|
* @name fromMat3d
|
|
148
|
-
* @memberof
|
|
143
|
+
* @memberof Matrix2d
|
|
149
144
|
* @function
|
|
150
|
-
* @param {
|
|
151
|
-
* @returns {
|
|
145
|
+
* @param {Matrix3d} m the matrix object to copy from
|
|
146
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
152
147
|
*/
|
|
153
148
|
fromMat3d(m) {
|
|
154
149
|
var b = m.val;
|
|
@@ -170,10 +165,10 @@ class Matrix2d {
|
|
|
170
165
|
/**
|
|
171
166
|
* multiply both matrix
|
|
172
167
|
* @name multiply
|
|
173
|
-
* @memberof
|
|
168
|
+
* @memberof Matrix2d
|
|
174
169
|
* @function
|
|
175
|
-
* @param {
|
|
176
|
-
* @returns {
|
|
170
|
+
* @param {Matrix2d} m the other matrix
|
|
171
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
177
172
|
*/
|
|
178
173
|
multiply(m) {
|
|
179
174
|
var b = m.val;
|
|
@@ -202,9 +197,9 @@ class Matrix2d {
|
|
|
202
197
|
/**
|
|
203
198
|
* Transpose the value of this matrix.
|
|
204
199
|
* @name transpose
|
|
205
|
-
* @memberof
|
|
200
|
+
* @memberof Matrix2d
|
|
206
201
|
* @function
|
|
207
|
-
* @returns {
|
|
202
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
208
203
|
*/
|
|
209
204
|
transpose() {
|
|
210
205
|
var a = this.val,
|
|
@@ -225,9 +220,9 @@ class Matrix2d {
|
|
|
225
220
|
/**
|
|
226
221
|
* invert this matrix, causing it to apply the opposite transformation.
|
|
227
222
|
* @name invert
|
|
228
|
-
* @memberof
|
|
223
|
+
* @memberof Matrix2d
|
|
229
224
|
* @function
|
|
230
|
-
* @returns {
|
|
225
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
231
226
|
*/
|
|
232
227
|
invert() {
|
|
233
228
|
var val = this.val;
|
|
@@ -260,10 +255,10 @@ class Matrix2d {
|
|
|
260
255
|
/**
|
|
261
256
|
* apply the current transform to the given 2d vector
|
|
262
257
|
* @name apply
|
|
263
|
-
* @memberof
|
|
258
|
+
* @memberof Matrix2d
|
|
264
259
|
* @function
|
|
265
|
-
* @param {
|
|
266
|
-
* @returns {
|
|
260
|
+
* @param {Vector2d} v the vector object to be transformed
|
|
261
|
+
* @returns {Vector2d} result vector object.
|
|
267
262
|
*/
|
|
268
263
|
apply(v) {
|
|
269
264
|
var a = this.val,
|
|
@@ -279,10 +274,10 @@ class Matrix2d {
|
|
|
279
274
|
/**
|
|
280
275
|
* apply the inverted current transform to the given 2d vector
|
|
281
276
|
* @name applyInverse
|
|
282
|
-
* @memberof
|
|
277
|
+
* @memberof Matrix2d
|
|
283
278
|
* @function
|
|
284
|
-
* @param {
|
|
285
|
-
* @returns {
|
|
279
|
+
* @param {Vector2d} v the vector object to be transformed
|
|
280
|
+
* @returns {Vector2d} result vector object.
|
|
286
281
|
*/
|
|
287
282
|
applyInverse(v) {
|
|
288
283
|
var a = this.val,
|
|
@@ -300,11 +295,11 @@ class Matrix2d {
|
|
|
300
295
|
/**
|
|
301
296
|
* scale the matrix
|
|
302
297
|
* @name scale
|
|
303
|
-
* @memberof
|
|
298
|
+
* @memberof Matrix2d
|
|
304
299
|
* @function
|
|
305
300
|
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
306
301
|
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
307
|
-
* @returns {
|
|
302
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
308
303
|
*/
|
|
309
304
|
scale(x, y) {
|
|
310
305
|
var a = this.val,
|
|
@@ -322,10 +317,10 @@ class Matrix2d {
|
|
|
322
317
|
/**
|
|
323
318
|
* adds a 2D scaling transformation.
|
|
324
319
|
* @name scaleV
|
|
325
|
-
* @memberof
|
|
320
|
+
* @memberof Matrix2d
|
|
326
321
|
* @function
|
|
327
|
-
* @param {
|
|
328
|
-
* @returns {
|
|
322
|
+
* @param {Vector2d} v scaling vector
|
|
323
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
329
324
|
*/
|
|
330
325
|
scaleV(v) {
|
|
331
326
|
return this.scale(v.x, v.y);
|
|
@@ -334,10 +329,10 @@ class Matrix2d {
|
|
|
334
329
|
/**
|
|
335
330
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
336
331
|
* @name scaleX
|
|
337
|
-
* @memberof
|
|
332
|
+
* @memberof Matrix2d
|
|
338
333
|
* @function
|
|
339
334
|
* @param {number} x x scaling vector
|
|
340
|
-
* @returns {
|
|
335
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
341
336
|
*/
|
|
342
337
|
scaleX(x) {
|
|
343
338
|
return this.scale(x, 1);
|
|
@@ -346,10 +341,10 @@ class Matrix2d {
|
|
|
346
341
|
/**
|
|
347
342
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
348
343
|
* @name scaleY
|
|
349
|
-
* @memberof
|
|
344
|
+
* @memberof Matrix2d
|
|
350
345
|
* @function
|
|
351
346
|
* @param {number} y y scaling vector
|
|
352
|
-
* @returns {
|
|
347
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
353
348
|
*/
|
|
354
349
|
scaleY(y) {
|
|
355
350
|
return this.scale(1, y);
|
|
@@ -358,10 +353,10 @@ class Matrix2d {
|
|
|
358
353
|
/**
|
|
359
354
|
* rotate the matrix (counter-clockwise) by the specified angle (in radians).
|
|
360
355
|
* @name rotate
|
|
361
|
-
* @memberof
|
|
356
|
+
* @memberof Matrix2d
|
|
362
357
|
* @function
|
|
363
358
|
* @param {number} angle Rotation angle in radians.
|
|
364
|
-
* @returns {
|
|
359
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
365
360
|
*/
|
|
366
361
|
rotate(angle) {
|
|
367
362
|
if (angle !== 0) {
|
|
@@ -389,19 +384,19 @@ class Matrix2d {
|
|
|
389
384
|
/**
|
|
390
385
|
* translate the matrix position on the horizontal and vertical axis
|
|
391
386
|
* @name translate
|
|
392
|
-
* @memberof
|
|
387
|
+
* @memberof Matrix2d
|
|
393
388
|
* @function
|
|
394
389
|
* @param {number} x the x coordindates to translate the matrix by
|
|
395
390
|
* @param {number} y the y coordindates to translate the matrix by
|
|
396
|
-
* @returns {
|
|
391
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
397
392
|
*/
|
|
398
393
|
/**
|
|
399
394
|
* translate the matrix by a vector on the horizontal and vertical axis
|
|
400
395
|
* @name translateV
|
|
401
|
-
* @memberof
|
|
396
|
+
* @memberof Matrix2d
|
|
402
397
|
* @function
|
|
403
|
-
* @param {
|
|
404
|
-
* @returns {
|
|
398
|
+
* @param {Vector2d} v the vector to translate the matrix by
|
|
399
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
405
400
|
*/
|
|
406
401
|
translate() {
|
|
407
402
|
var a = this.val;
|
|
@@ -426,7 +421,7 @@ class Matrix2d {
|
|
|
426
421
|
/**
|
|
427
422
|
* returns true if the matrix is an identity matrix.
|
|
428
423
|
* @name isIdentity
|
|
429
|
-
* @memberof
|
|
424
|
+
* @memberof Matrix2d
|
|
430
425
|
* @function
|
|
431
426
|
* @returns {boolean}
|
|
432
427
|
*/
|
|
@@ -449,9 +444,9 @@ class Matrix2d {
|
|
|
449
444
|
/**
|
|
450
445
|
* return true if the two matrices are identical
|
|
451
446
|
* @name equals
|
|
452
|
-
* @memberof
|
|
447
|
+
* @memberof Matrix2d
|
|
453
448
|
* @function
|
|
454
|
-
* @param {
|
|
449
|
+
* @param {Matrix2d} m the other matrix
|
|
455
450
|
* @returns {boolean} true if both are equals
|
|
456
451
|
*/
|
|
457
452
|
equals(m) {
|
|
@@ -474,9 +469,9 @@ class Matrix2d {
|
|
|
474
469
|
/**
|
|
475
470
|
* Clone the Matrix
|
|
476
471
|
* @name clone
|
|
477
|
-
* @memberof
|
|
472
|
+
* @memberof Matrix2d
|
|
478
473
|
* @function
|
|
479
|
-
* @returns {
|
|
474
|
+
* @returns {Matrix2d}
|
|
480
475
|
*/
|
|
481
476
|
clone() {
|
|
482
477
|
return pool.pull("Matrix2d", this);
|
|
@@ -485,7 +480,7 @@ class Matrix2d {
|
|
|
485
480
|
/**
|
|
486
481
|
* return an array representation of this Matrix
|
|
487
482
|
* @name toArray
|
|
488
|
-
* @memberof
|
|
483
|
+
* @memberof Matrix2d
|
|
489
484
|
* @function
|
|
490
485
|
* @returns {Float32Array}
|
|
491
486
|
*/
|
|
@@ -496,7 +491,7 @@ class Matrix2d {
|
|
|
496
491
|
/**
|
|
497
492
|
* convert the object to a string representation
|
|
498
493
|
* @name toString
|
|
499
|
-
* @memberof
|
|
494
|
+
* @memberof Matrix2d
|
|
500
495
|
* @function
|
|
501
496
|
* @returns {string}
|
|
502
497
|
*/
|
package/src/math/matrix3.js
CHANGED
|
@@ -3,15 +3,12 @@ import { EPSILON } from "./math.js";
|
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc
|
|
6
|
-
* a 4x4 Matrix3d Object
|
|
7
|
-
* @class Matrix3d
|
|
8
|
-
* @memberof me
|
|
9
|
-
* @param {me.Matrix3d} [mat3d] An instance of me.Matrix3d to copy from
|
|
10
|
-
* @param {number[]} [arguments...] Matrix elements. See {@link me.Matrix3d.setTransform}
|
|
6
|
+
* a 4x4 Matrix3d Object
|
|
11
7
|
*/
|
|
12
|
-
|
|
13
8
|
class Matrix3d {
|
|
14
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param {(Matrix3d|...number)} args An instance of me.Matrix3d to copy from, or individual Matrix components (See {@link Matrix3d.setTransform}). If not arguments are given, the matrix will be set to Identity.
|
|
11
|
+
*/
|
|
15
12
|
constructor(...args) {
|
|
16
13
|
this.onResetEvent(...args);
|
|
17
14
|
}
|
|
@@ -39,9 +36,8 @@ class Matrix3d {
|
|
|
39
36
|
* tx component of the matrix
|
|
40
37
|
* @public
|
|
41
38
|
* @type {number}
|
|
42
|
-
* @readonly
|
|
43
39
|
* @name tx
|
|
44
|
-
* @memberof
|
|
40
|
+
* @memberof Matrix3d
|
|
45
41
|
*/
|
|
46
42
|
get tx() {
|
|
47
43
|
return this.val[12];
|
|
@@ -51,9 +47,8 @@ class Matrix3d {
|
|
|
51
47
|
* ty component of the matrix
|
|
52
48
|
* @public
|
|
53
49
|
* @type {number}
|
|
54
|
-
* @readonly
|
|
55
50
|
* @name ty
|
|
56
|
-
* @memberof
|
|
51
|
+
* @memberof Matrix3d
|
|
57
52
|
*/
|
|
58
53
|
get ty() {
|
|
59
54
|
return this.val[13];
|
|
@@ -63,9 +58,8 @@ class Matrix3d {
|
|
|
63
58
|
* ty component of the matrix
|
|
64
59
|
* @public
|
|
65
60
|
* @type {number}
|
|
66
|
-
* @readonly
|
|
67
61
|
* @name tz
|
|
68
|
-
* @memberof
|
|
62
|
+
* @memberof Matrix3d
|
|
69
63
|
*/
|
|
70
64
|
get tz() {
|
|
71
65
|
return this.val[14];
|
|
@@ -76,9 +70,9 @@ class Matrix3d {
|
|
|
76
70
|
* the identity matrix and parameters position : <br>
|
|
77
71
|
* <img src="images/identity-matrix_2x.png"/>
|
|
78
72
|
* @name identity
|
|
79
|
-
* @memberof
|
|
73
|
+
* @memberof Matrix3d
|
|
80
74
|
* @function
|
|
81
|
-
* @returns {
|
|
75
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
82
76
|
*/
|
|
83
77
|
identity() {
|
|
84
78
|
return this.setTransform(
|
|
@@ -92,7 +86,7 @@ class Matrix3d {
|
|
|
92
86
|
/**
|
|
93
87
|
* set the matrix to the specified value
|
|
94
88
|
* @name setTransform
|
|
95
|
-
* @memberof
|
|
89
|
+
* @memberof Matrix3d
|
|
96
90
|
* @function
|
|
97
91
|
* @param {number} m00
|
|
98
92
|
* @param {number} m01
|
|
@@ -110,7 +104,7 @@ class Matrix3d {
|
|
|
110
104
|
* @param {number} m31
|
|
111
105
|
* @param {number} m32
|
|
112
106
|
* @param {number} m33
|
|
113
|
-
* @returns {
|
|
107
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
114
108
|
*/
|
|
115
109
|
setTransform(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
116
110
|
var a = this.val;
|
|
@@ -138,10 +132,10 @@ class Matrix3d {
|
|
|
138
132
|
/**
|
|
139
133
|
* Copies over the values from another me.Matrix3d.
|
|
140
134
|
* @name copy
|
|
141
|
-
* @memberof
|
|
135
|
+
* @memberof Matrix3d
|
|
142
136
|
* @function
|
|
143
|
-
* @param {
|
|
144
|
-
* @returns {
|
|
137
|
+
* @param {Matrix3d} m the matrix object to copy from
|
|
138
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
145
139
|
*/
|
|
146
140
|
copy(m) {
|
|
147
141
|
this.val.set(m.val);
|
|
@@ -151,10 +145,10 @@ class Matrix3d {
|
|
|
151
145
|
/**
|
|
152
146
|
* Copies over the upper-left 2x2 values from the given me.Matrix2d
|
|
153
147
|
* @name fromMat2d
|
|
154
|
-
* @memberof
|
|
148
|
+
* @memberof Matrix3d
|
|
155
149
|
* @function
|
|
156
|
-
* @param {
|
|
157
|
-
* @returns {
|
|
150
|
+
* @param {Matrix2d} m the matrix object to copy from
|
|
151
|
+
* @returns {Matrix2d} Reference to this object for method chaining
|
|
158
152
|
*/
|
|
159
153
|
fromMat2d(m) {
|
|
160
154
|
var b = m.val;
|
|
@@ -170,10 +164,10 @@ class Matrix3d {
|
|
|
170
164
|
/**
|
|
171
165
|
* multiply both matrix
|
|
172
166
|
* @name multiply
|
|
173
|
-
* @memberof
|
|
167
|
+
* @memberof Matrix3d
|
|
174
168
|
* @function
|
|
175
|
-
* @param {
|
|
176
|
-
* @returns {
|
|
169
|
+
* @param {Matrix3d} m Other matrix
|
|
170
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
177
171
|
*/
|
|
178
172
|
multiply(m) {
|
|
179
173
|
var a = this.val;
|
|
@@ -226,9 +220,9 @@ class Matrix3d {
|
|
|
226
220
|
/**
|
|
227
221
|
* Transpose the value of this matrix.
|
|
228
222
|
* @name transpose
|
|
229
|
-
* @memberof
|
|
223
|
+
* @memberof Matrix3d
|
|
230
224
|
* @function
|
|
231
|
-
* @returns {
|
|
225
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
232
226
|
*/
|
|
233
227
|
transpose() {
|
|
234
228
|
var a = this.val,
|
|
@@ -258,9 +252,9 @@ class Matrix3d {
|
|
|
258
252
|
/**
|
|
259
253
|
* invert this matrix, causing it to apply the opposite transformation.
|
|
260
254
|
* @name invert
|
|
261
|
-
* @memberof
|
|
255
|
+
* @memberof Matrix3d
|
|
262
256
|
* @function
|
|
263
|
-
* @returns {
|
|
257
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
264
258
|
*/
|
|
265
259
|
invert() {
|
|
266
260
|
var a = this.val;
|
|
@@ -318,10 +312,10 @@ class Matrix3d {
|
|
|
318
312
|
/**
|
|
319
313
|
* apply the current transform to the given 2d or 3d vector
|
|
320
314
|
* @name apply
|
|
321
|
-
* @memberof
|
|
315
|
+
* @memberof Matrix3d
|
|
322
316
|
* @function
|
|
323
|
-
* @param {
|
|
324
|
-
* @returns {
|
|
317
|
+
* @param {Vector2d|Vector3d} v the vector object to be transformed
|
|
318
|
+
* @returns {Vector2d|Vector3d} result vector object.
|
|
325
319
|
*/
|
|
326
320
|
apply(v) {
|
|
327
321
|
var a = this.val,
|
|
@@ -344,10 +338,10 @@ class Matrix3d {
|
|
|
344
338
|
/**
|
|
345
339
|
* apply the inverted current transform to the given 2d or 3d vector
|
|
346
340
|
* @name applyInverse
|
|
347
|
-
* @memberof
|
|
341
|
+
* @memberof Matrix3d
|
|
348
342
|
* @function
|
|
349
|
-
* @param {
|
|
350
|
-
* @returns {
|
|
343
|
+
* @param {Vector2d|Vector3d} v the vector object to be transformed
|
|
344
|
+
* @returns {Vector2d|Vector3d} result vector object.
|
|
351
345
|
*/
|
|
352
346
|
applyInverse(v) {
|
|
353
347
|
// invert the current matrix
|
|
@@ -365,7 +359,7 @@ class Matrix3d {
|
|
|
365
359
|
* generate an orthogonal projection matrix, with the result replacing the current matrix
|
|
366
360
|
* <img src="images/glOrtho.gif"/><br>
|
|
367
361
|
* @name ortho
|
|
368
|
-
* @memberof
|
|
362
|
+
* @memberof Matrix3d
|
|
369
363
|
* @function
|
|
370
364
|
* @param {number} left farthest left on the x-axis
|
|
371
365
|
* @param {number} right farthest right on the x-axis
|
|
@@ -373,7 +367,7 @@ class Matrix3d {
|
|
|
373
367
|
* @param {number} top farthest up on the y-axis
|
|
374
368
|
* @param {number} near distance to the near clipping plane along the -Z axis
|
|
375
369
|
* @param {number} far distance to the far clipping plane along the -Z axis
|
|
376
|
-
* @returns {
|
|
370
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
377
371
|
*/
|
|
378
372
|
ortho(left, right, bottom, top, near, far) {
|
|
379
373
|
var a = this.val;
|
|
@@ -404,12 +398,12 @@ class Matrix3d {
|
|
|
404
398
|
/**
|
|
405
399
|
* scale the matrix
|
|
406
400
|
* @name scale
|
|
407
|
-
* @memberof
|
|
401
|
+
* @memberof Matrix3d
|
|
408
402
|
* @function
|
|
409
403
|
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
410
404
|
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
411
405
|
* @param {number} [z=0] a number representing the depth vector
|
|
412
|
-
* @returns {
|
|
406
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
413
407
|
*/
|
|
414
408
|
scale(x, y, z) {
|
|
415
409
|
var a = this.val,
|
|
@@ -438,10 +432,10 @@ class Matrix3d {
|
|
|
438
432
|
/**
|
|
439
433
|
* adds a 2D scaling transformation.
|
|
440
434
|
* @name scaleV
|
|
441
|
-
* @memberof
|
|
435
|
+
* @memberof Matrix3d
|
|
442
436
|
* @function
|
|
443
|
-
* @param {
|
|
444
|
-
* @returns {
|
|
437
|
+
* @param {Vector2d|Vector3d} v scaling vector
|
|
438
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
445
439
|
*/
|
|
446
440
|
scaleV(v) {
|
|
447
441
|
return this.scale(v.x, v.y, v.z);
|
|
@@ -450,10 +444,10 @@ class Matrix3d {
|
|
|
450
444
|
/**
|
|
451
445
|
* specifies a 2D scale operation using the [sx, 1] scaling vector
|
|
452
446
|
* @name scaleX
|
|
453
|
-
* @memberof
|
|
447
|
+
* @memberof Matrix3d
|
|
454
448
|
* @function
|
|
455
449
|
* @param {number} x x scaling vector
|
|
456
|
-
* @returns {
|
|
450
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
457
451
|
*/
|
|
458
452
|
scaleX(x) {
|
|
459
453
|
return this.scale(x, 1);
|
|
@@ -462,10 +456,10 @@ class Matrix3d {
|
|
|
462
456
|
/**
|
|
463
457
|
* specifies a 2D scale operation using the [1,sy] scaling vector
|
|
464
458
|
* @name scaleY
|
|
465
|
-
* @memberof
|
|
459
|
+
* @memberof Matrix3d
|
|
466
460
|
* @function
|
|
467
461
|
* @param {number} y y scaling vector
|
|
468
|
-
* @returns {
|
|
462
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
469
463
|
*/
|
|
470
464
|
scaleY(y) {
|
|
471
465
|
return this.scale(1, y);
|
|
@@ -474,11 +468,11 @@ class Matrix3d {
|
|
|
474
468
|
/**
|
|
475
469
|
* rotate this matrix (counter-clockwise) by the specified angle (in radians).
|
|
476
470
|
* @name rotate
|
|
477
|
-
* @memberof
|
|
471
|
+
* @memberof Matrix3d
|
|
478
472
|
* @function
|
|
479
473
|
* @param {number} angle Rotation angle in radians.
|
|
480
|
-
* @param {
|
|
481
|
-
* @returns {
|
|
474
|
+
* @param {Vector3d} v the axis to rotate around
|
|
475
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
482
476
|
*/
|
|
483
477
|
rotate(angle, v) {
|
|
484
478
|
var a = this.val,
|
|
@@ -553,20 +547,20 @@ class Matrix3d {
|
|
|
553
547
|
/**
|
|
554
548
|
* translate the matrix position using the given vector
|
|
555
549
|
* @name translate
|
|
556
|
-
* @memberof
|
|
550
|
+
* @memberof Matrix3d
|
|
557
551
|
* @function
|
|
558
552
|
* @param {number} x a number representing the abscissa of the vector.
|
|
559
553
|
* @param {number} [y=x] a number representing the ordinate of the vector.
|
|
560
554
|
* @param {number} [z=0] a number representing the depth of the vector
|
|
561
|
-
* @returns {
|
|
555
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
562
556
|
*/
|
|
563
557
|
/**
|
|
564
558
|
* translate the matrix by a vector on the horizontal and vertical axis
|
|
565
559
|
* @name translateV
|
|
566
|
-
* @memberof
|
|
560
|
+
* @memberof Matrix3d
|
|
567
561
|
* @function
|
|
568
|
-
* @param {
|
|
569
|
-
* @returns {
|
|
562
|
+
* @param {Vector2d|Vector3d} v the vector to translate the matrix by
|
|
563
|
+
* @returns {Matrix3d} Reference to this object for method chaining
|
|
570
564
|
*/
|
|
571
565
|
translate() {
|
|
572
566
|
var a = this.val;
|
|
@@ -595,7 +589,7 @@ class Matrix3d {
|
|
|
595
589
|
/**
|
|
596
590
|
* returns true if the matrix is an identity matrix.
|
|
597
591
|
* @name isIdentity
|
|
598
|
-
* @memberof
|
|
592
|
+
* @memberof Matrix3d
|
|
599
593
|
* @function
|
|
600
594
|
* @returns {boolean}
|
|
601
595
|
*/
|
|
@@ -625,9 +619,9 @@ class Matrix3d {
|
|
|
625
619
|
/**
|
|
626
620
|
* return true if the two matrices are identical
|
|
627
621
|
* @name equals
|
|
628
|
-
* @memberof
|
|
622
|
+
* @memberof Matrix3d
|
|
629
623
|
* @function
|
|
630
|
-
* @param {
|
|
624
|
+
* @param {Matrix3d} m the other matrix
|
|
631
625
|
* @returns {boolean} true if both are equals
|
|
632
626
|
*/
|
|
633
627
|
equals(m) {
|
|
@@ -657,9 +651,9 @@ class Matrix3d {
|
|
|
657
651
|
/**
|
|
658
652
|
* Clone the Matrix
|
|
659
653
|
* @name clone
|
|
660
|
-
* @memberof
|
|
654
|
+
* @memberof Matrix3d
|
|
661
655
|
* @function
|
|
662
|
-
* @returns {
|
|
656
|
+
* @returns {Matrix3d}
|
|
663
657
|
*/
|
|
664
658
|
clone() {
|
|
665
659
|
return pool.pull("Matrix3d", this);
|
|
@@ -668,7 +662,7 @@ class Matrix3d {
|
|
|
668
662
|
/**
|
|
669
663
|
* return an array representation of this Matrix
|
|
670
664
|
* @name toArray
|
|
671
|
-
* @memberof
|
|
665
|
+
* @memberof Matrix3d
|
|
672
666
|
* @function
|
|
673
667
|
* @returns {Float32Array}
|
|
674
668
|
*/
|
|
@@ -679,7 +673,7 @@ class Matrix3d {
|
|
|
679
673
|
/**
|
|
680
674
|
* convert the object to a string representation
|
|
681
675
|
* @name toString
|
|
682
|
-
* @memberof
|
|
676
|
+
* @memberof Matrix3d
|
|
683
677
|
* @function
|
|
684
678
|
* @returns {string}
|
|
685
679
|
*/
|