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