melonjs 10.2.1 → 10.2.2
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 +2735 -2760
- package/dist/melonjs.min.js +3 -3
- package/dist/melonjs.module.d.ts +2186 -2162
- package/dist/melonjs.module.js +2323 -2362
- package/package.json +8 -9
- package/src/audio/audio.js +43 -43
- package/src/camera/camera2d.js +52 -74
- package/src/entity/draggable.js +18 -17
- package/src/entity/droptarget.js +19 -18
- package/src/entity/entity.js +22 -26
- package/src/game.js +2 -2
- package/src/index.js +11 -11
- package/src/input/gamepad.js +13 -13
- package/src/input/input.js +1 -1
- package/src/input/keyboard.js +14 -16
- package/src/input/pointer.js +42 -35
- package/src/input/pointerevent.js +18 -26
- package/src/lang/deprecated.js +3 -3
- package/src/level/level.js +24 -16
- package/src/level/tiled/TMXGroup.js +6 -6
- package/src/level/tiled/TMXLayer.js +31 -31
- package/src/level/tiled/TMXObject.js +19 -19
- package/src/level/tiled/TMXTile.js +11 -12
- package/src/level/tiled/TMXTileMap.js +23 -21
- package/src/level/tiled/TMXTileset.js +13 -13
- package/src/level/tiled/TMXTilesetGroup.js +4 -4
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
- package/src/level/tiled/renderer/TMXRenderer.js +17 -17
- package/src/loader/loader.js +29 -25
- package/src/math/color.js +45 -64
- package/src/math/math.js +17 -17
- package/src/math/matrix2.js +46 -46
- package/src/math/matrix3.js +64 -64
- package/src/math/observable_vector2.js +45 -57
- package/src/math/observable_vector3.js +56 -70
- package/src/math/vector2.js +60 -59
- package/src/math/vector3.js +65 -64
- package/src/particles/emitter.js +53 -55
- package/src/particles/particle.js +1 -1
- package/src/physics/body.js +44 -44
- package/src/physics/bounds.js +34 -34
- package/src/physics/collision.js +15 -16
- package/src/physics/detector.js +10 -10
- package/src/physics/quadtree.js +19 -17
- package/src/physics/sat.js +17 -17
- package/src/physics/world.js +12 -10
- package/src/plugin/plugin.js +6 -6
- package/src/renderable/GUI.js +13 -18
- package/src/renderable/collectable.js +3 -3
- package/src/renderable/colorlayer.js +4 -4
- package/src/renderable/container.js +64 -46
- package/src/renderable/imagelayer.js +30 -31
- package/src/renderable/nineslicesprite.js +13 -13
- package/src/renderable/renderable.js +68 -66
- package/src/renderable/sprite.js +57 -43
- package/src/renderable/trigger.js +14 -15
- package/src/shapes/ellipse.js +27 -26
- package/src/shapes/line.js +8 -7
- package/src/shapes/poly.js +33 -31
- package/src/shapes/rectangle.js +50 -96
- package/src/state/stage.js +6 -6
- package/src/state/state.js +54 -54
- package/src/system/device.js +97 -84
- package/src/system/event.js +72 -72
- package/src/system/pooling.js +14 -14
- package/src/system/save.js +6 -3
- package/src/system/timer.js +20 -20
- package/src/text/bitmaptext.js +27 -33
- package/src/text/bitmaptextdata.js +9 -9
- package/src/text/text.js +39 -41
- package/src/tweens/easing.js +4 -4
- package/src/tweens/interpolation.js +4 -4
- package/src/tweens/tween.js +37 -27
- package/src/utils/agent.js +9 -8
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +4 -4
- package/src/utils/function.js +5 -5
- package/src/utils/string.js +12 -12
- package/src/utils/utils.js +19 -19
- package/src/video/canvas/canvas_renderer.js +90 -90
- package/src/video/renderer.js +40 -39
- package/src/video/texture.js +74 -75
- package/src/video/video.js +30 -30
- package/src/video/webgl/buffer/vertex.js +9 -1
- package/src/video/webgl/glshader.js +20 -20
- package/src/video/webgl/webgl_compositor.js +33 -34
- package/src/video/webgl/webgl_renderer.js +104 -104
package/src/math/matrix3.js
CHANGED
|
@@ -8,7 +8,7 @@ import { EPSILON } from "./math.js";
|
|
|
8
8
|
* @memberOf me
|
|
9
9
|
* @constructor
|
|
10
10
|
* @param {me.Matrix3d} [mat3d] An instance of me.Matrix3d to copy from
|
|
11
|
-
* @param {
|
|
11
|
+
* @param {number[]} [arguments...] Matrix elements. See {@link me.Matrix3d.setTransform}
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
14
|
class Matrix3d {
|
|
@@ -39,7 +39,7 @@ class Matrix3d {
|
|
|
39
39
|
/**
|
|
40
40
|
* tx component of the matrix
|
|
41
41
|
* @public
|
|
42
|
-
* @type {
|
|
42
|
+
* @type {number}
|
|
43
43
|
* @readonly
|
|
44
44
|
* @name tx
|
|
45
45
|
* @memberOf me.Matrix3d
|
|
@@ -51,7 +51,7 @@ class Matrix3d {
|
|
|
51
51
|
/**
|
|
52
52
|
* ty component of the matrix
|
|
53
53
|
* @public
|
|
54
|
-
* @type {
|
|
54
|
+
* @type {number}
|
|
55
55
|
* @readonly
|
|
56
56
|
* @name ty
|
|
57
57
|
* @memberOf me.Matrix3d
|
|
@@ -63,7 +63,7 @@ class Matrix3d {
|
|
|
63
63
|
/**
|
|
64
64
|
* ty component of the matrix
|
|
65
65
|
* @public
|
|
66
|
-
* @type {
|
|
66
|
+
* @type {number}
|
|
67
67
|
* @readonly
|
|
68
68
|
* @name tz
|
|
69
69
|
* @memberOf me.Matrix3d
|
|
@@ -79,7 +79,7 @@ class Matrix3d {
|
|
|
79
79
|
* @name identity
|
|
80
80
|
* @memberOf me.Matrix3d
|
|
81
81
|
* @function
|
|
82
|
-
* @
|
|
82
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
83
83
|
*/
|
|
84
84
|
identity() {
|
|
85
85
|
return this.setTransform(
|
|
@@ -95,23 +95,23 @@ class Matrix3d {
|
|
|
95
95
|
* @name setTransform
|
|
96
96
|
* @memberOf me.Matrix3d
|
|
97
97
|
* @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
|
-
* @
|
|
98
|
+
* @param {number} m00
|
|
99
|
+
* @param {number} m01
|
|
100
|
+
* @param {number} m02
|
|
101
|
+
* @param {number} m03
|
|
102
|
+
* @param {number} m10
|
|
103
|
+
* @param {number} m11
|
|
104
|
+
* @param {number} m12
|
|
105
|
+
* @param {number} m13
|
|
106
|
+
* @param {number} m20
|
|
107
|
+
* @param {number} m21
|
|
108
|
+
* @param {number} m22
|
|
109
|
+
* @param {number} m23
|
|
110
|
+
* @param {number} m30
|
|
111
|
+
* @param {number} m31
|
|
112
|
+
* @param {number} m32
|
|
113
|
+
* @param {number} m33
|
|
114
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
115
115
|
*/
|
|
116
116
|
setTransform(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) {
|
|
117
117
|
var a = this.val;
|
|
@@ -142,10 +142,10 @@ class Matrix3d {
|
|
|
142
142
|
* @memberOf me.Matrix3d
|
|
143
143
|
* @function
|
|
144
144
|
* @param {me.Matrix3d} m the matrix object to copy from
|
|
145
|
-
* @
|
|
145
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
146
146
|
*/
|
|
147
|
-
copy(
|
|
148
|
-
this.val.set(
|
|
147
|
+
copy(m) {
|
|
148
|
+
this.val.set(m.val);
|
|
149
149
|
return this;
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -155,7 +155,7 @@ class Matrix3d {
|
|
|
155
155
|
* @memberOf me.Matrix3d
|
|
156
156
|
* @function
|
|
157
157
|
* @param {me.Matrix2d} m the matrix object to copy from
|
|
158
|
-
* @
|
|
158
|
+
* @returns {me.Matrix2d} Reference to this object for method chaining
|
|
159
159
|
*/
|
|
160
160
|
fromMat2d(m) {
|
|
161
161
|
var b = m.val;
|
|
@@ -174,7 +174,7 @@ class Matrix3d {
|
|
|
174
174
|
* @memberOf me.Matrix3d
|
|
175
175
|
* @function
|
|
176
176
|
* @param {me.Matrix3d} m Other matrix
|
|
177
|
-
* @
|
|
177
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
178
178
|
*/
|
|
179
179
|
multiply(m) {
|
|
180
180
|
var a = this.val;
|
|
@@ -229,7 +229,7 @@ class Matrix3d {
|
|
|
229
229
|
* @name transpose
|
|
230
230
|
* @memberOf me.Matrix3d
|
|
231
231
|
* @function
|
|
232
|
-
* @
|
|
232
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
233
233
|
*/
|
|
234
234
|
transpose() {
|
|
235
235
|
var a = this.val,
|
|
@@ -261,7 +261,7 @@ class Matrix3d {
|
|
|
261
261
|
* @name invert
|
|
262
262
|
* @memberOf me.Matrix3d
|
|
263
263
|
* @function
|
|
264
|
-
* @
|
|
264
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
265
265
|
*/
|
|
266
266
|
invert() {
|
|
267
267
|
var a = this.val;
|
|
@@ -321,8 +321,8 @@ class Matrix3d {
|
|
|
321
321
|
* @name apply
|
|
322
322
|
* @memberOf me.Matrix3d
|
|
323
323
|
* @function
|
|
324
|
-
* @param {me.Vector2d|me.Vector3d}
|
|
325
|
-
* @
|
|
324
|
+
* @param {me.Vector2d|me.Vector3d} v the vector object to be transformed
|
|
325
|
+
* @returns {me.Vector2d|me.Vector3d} result vector object.
|
|
326
326
|
*/
|
|
327
327
|
apply(v) {
|
|
328
328
|
var a = this.val,
|
|
@@ -347,8 +347,8 @@ class Matrix3d {
|
|
|
347
347
|
* @name applyInverse
|
|
348
348
|
* @memberOf me.Matrix3d
|
|
349
349
|
* @function
|
|
350
|
-
* @param {me.Vector2d|me.Vector3d}
|
|
351
|
-
* @
|
|
350
|
+
* @param {me.Vector2d|me.Vector3d} v the vector object to be transformed
|
|
351
|
+
* @returns {me.Vector2d|me.Vector3d} result vector object.
|
|
352
352
|
*/
|
|
353
353
|
applyInverse(v) {
|
|
354
354
|
// invert the current matrix
|
|
@@ -368,13 +368,13 @@ class Matrix3d {
|
|
|
368
368
|
* @name ortho
|
|
369
369
|
* @memberOf me.Matrix3d
|
|
370
370
|
* @function
|
|
371
|
-
* @param {
|
|
372
|
-
* @param {
|
|
373
|
-
* @param {
|
|
374
|
-
* @param {
|
|
375
|
-
* @param {
|
|
376
|
-
* @param {
|
|
377
|
-
* @
|
|
371
|
+
* @param {number} left farthest left on the x-axis
|
|
372
|
+
* @param {number} right farthest right on the x-axis
|
|
373
|
+
* @param {number} bottom farthest down on the y-axis
|
|
374
|
+
* @param {number} top farthest up on the y-axis
|
|
375
|
+
* @param {number} near distance to the near clipping plane along the -Z axis
|
|
376
|
+
* @param {number} far distance to the far clipping plane along the -Z axis
|
|
377
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
378
378
|
*/
|
|
379
379
|
ortho(left, right, bottom, top, near, far) {
|
|
380
380
|
var a = this.val;
|
|
@@ -407,10 +407,10 @@ class Matrix3d {
|
|
|
407
407
|
* @name scale
|
|
408
408
|
* @memberOf me.Matrix3d
|
|
409
409
|
* @function
|
|
410
|
-
* @param {
|
|
411
|
-
* @param {
|
|
412
|
-
* @param {
|
|
413
|
-
* @
|
|
410
|
+
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
411
|
+
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
412
|
+
* @param {number} [z=0] a number representing the depth vector
|
|
413
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
414
414
|
*/
|
|
415
415
|
scale(x, y, z) {
|
|
416
416
|
var a = this.val,
|
|
@@ -441,8 +441,8 @@ class Matrix3d {
|
|
|
441
441
|
* @name scaleV
|
|
442
442
|
* @memberOf me.Matrix3d
|
|
443
443
|
* @function
|
|
444
|
-
* @param {me.Vector2d|me.Vector3d}
|
|
445
|
-
* @
|
|
444
|
+
* @param {me.Vector2d|me.Vector3d} v scaling vector
|
|
445
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
446
446
|
*/
|
|
447
447
|
scaleV(v) {
|
|
448
448
|
return this.scale(v.x, v.y, v.z);
|
|
@@ -453,8 +453,8 @@ class Matrix3d {
|
|
|
453
453
|
* @name scaleX
|
|
454
454
|
* @memberOf me.Matrix3d
|
|
455
455
|
* @function
|
|
456
|
-
* @param {
|
|
457
|
-
* @
|
|
456
|
+
* @param {number} x x scaling vector
|
|
457
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
458
458
|
*/
|
|
459
459
|
scaleX(x) {
|
|
460
460
|
return this.scale(x, 1);
|
|
@@ -465,8 +465,8 @@ class Matrix3d {
|
|
|
465
465
|
* @name scaleY
|
|
466
466
|
* @memberOf me.Matrix3d
|
|
467
467
|
* @function
|
|
468
|
-
* @param {
|
|
469
|
-
* @
|
|
468
|
+
* @param {number} y y scaling vector
|
|
469
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
470
470
|
*/
|
|
471
471
|
scaleY(y) {
|
|
472
472
|
return this.scale(1, y);
|
|
@@ -477,9 +477,9 @@ class Matrix3d {
|
|
|
477
477
|
* @name rotate
|
|
478
478
|
* @memberOf me.Matrix3d
|
|
479
479
|
* @function
|
|
480
|
-
* @param {
|
|
481
|
-
* @param {me.Vector3d}
|
|
482
|
-
* @
|
|
480
|
+
* @param {number} angle Rotation angle in radians.
|
|
481
|
+
* @param {me.Vector3d} v the axis to rotate around
|
|
482
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
483
483
|
*/
|
|
484
484
|
rotate(angle, v) {
|
|
485
485
|
var a = this.val,
|
|
@@ -556,10 +556,10 @@ class Matrix3d {
|
|
|
556
556
|
* @name translate
|
|
557
557
|
* @memberOf me.Matrix3d
|
|
558
558
|
* @function
|
|
559
|
-
* @param {
|
|
560
|
-
* @param {
|
|
561
|
-
* @param {
|
|
562
|
-
* @
|
|
559
|
+
* @param {number} x a number representing the abscissa of the vector.
|
|
560
|
+
* @param {number} [y=x] a number representing the ordinate of the vector.
|
|
561
|
+
* @param {number} [z=0] a number representing the depth of the vector
|
|
562
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
563
563
|
*/
|
|
564
564
|
/**
|
|
565
565
|
* translate the matrix by a vector on the horizontal and vertical axis
|
|
@@ -567,7 +567,7 @@ class Matrix3d {
|
|
|
567
567
|
* @memberOf me.Matrix3d
|
|
568
568
|
* @function
|
|
569
569
|
* @param {me.Vector2d|me.Vector3d} v the vector to translate the matrix by
|
|
570
|
-
* @
|
|
570
|
+
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
571
571
|
*/
|
|
572
572
|
translate() {
|
|
573
573
|
var a = this.val;
|
|
@@ -598,8 +598,8 @@ class Matrix3d {
|
|
|
598
598
|
* @name isIdentity
|
|
599
599
|
* @memberOf me.Matrix3d
|
|
600
600
|
* @function
|
|
601
|
-
* @
|
|
602
|
-
|
|
601
|
+
* @returns {boolean}
|
|
602
|
+
*/
|
|
603
603
|
isIdentity() {
|
|
604
604
|
var a = this.val;
|
|
605
605
|
|
|
@@ -629,7 +629,7 @@ class Matrix3d {
|
|
|
629
629
|
* @memberOf me.Matrix3d
|
|
630
630
|
* @function
|
|
631
631
|
* @param {me.Matrix3d} m the other matrix
|
|
632
|
-
* @
|
|
632
|
+
* @returns {boolean} true if both are equals
|
|
633
633
|
*/
|
|
634
634
|
equals(m) {
|
|
635
635
|
var b = m.val;
|
|
@@ -660,7 +660,7 @@ class Matrix3d {
|
|
|
660
660
|
* @name clone
|
|
661
661
|
* @memberOf me.Matrix3d
|
|
662
662
|
* @function
|
|
663
|
-
* @
|
|
663
|
+
* @returns {me.Matrix3d}
|
|
664
664
|
*/
|
|
665
665
|
clone() {
|
|
666
666
|
return pool.pull("Matrix3d", this);
|
|
@@ -671,7 +671,7 @@ class Matrix3d {
|
|
|
671
671
|
* @name toArray
|
|
672
672
|
* @memberOf me.Matrix3d
|
|
673
673
|
* @function
|
|
674
|
-
* @
|
|
674
|
+
* @returns {Float32Array}
|
|
675
675
|
*/
|
|
676
676
|
toArray() {
|
|
677
677
|
return this.val;
|
|
@@ -682,7 +682,7 @@ class Matrix3d {
|
|
|
682
682
|
* @name toString
|
|
683
683
|
* @memberOf me.Matrix3d
|
|
684
684
|
* @function
|
|
685
|
-
* @
|
|
685
|
+
* @returns {string}
|
|
686
686
|
*/
|
|
687
687
|
toString() {
|
|
688
688
|
var a = this.val;
|
|
@@ -9,9 +9,9 @@ import {clamp} from "./math.js";
|
|
|
9
9
|
* @extends me.Vector2d
|
|
10
10
|
* @memberOf me
|
|
11
11
|
* @constructor
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
12
|
+
* @param {number} [x=0] x value of the vector
|
|
13
|
+
* @param {number} [y=0] y value of the vector
|
|
14
|
+
* @param {object} settings additional required parameters
|
|
15
15
|
* @param {Function} settings.onUpdate the callback to be executed when the vector is changed
|
|
16
16
|
* @param {Function} [settings.scope] the value to use as this when calling onUpdate
|
|
17
17
|
*/
|
|
@@ -42,21 +42,15 @@ class ObservableVector2d extends Vector2d {
|
|
|
42
42
|
/**
|
|
43
43
|
* x value of the vector
|
|
44
44
|
* @public
|
|
45
|
-
* @type
|
|
45
|
+
* @type {number}
|
|
46
46
|
* @name x
|
|
47
47
|
* @memberOf me.ObservableVector2d
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
-
/**
|
|
51
|
-
* @ignore
|
|
52
|
-
*/
|
|
53
50
|
get x() {
|
|
54
51
|
return this._x;
|
|
55
52
|
}
|
|
56
53
|
|
|
57
|
-
/**
|
|
58
|
-
* @ignore
|
|
59
|
-
*/
|
|
60
54
|
set x(value) {
|
|
61
55
|
var ret = this.onUpdate.call(this.scope, value, this._y, this._x, this._y);
|
|
62
56
|
if (ret && "x" in ret) {
|
|
@@ -70,21 +64,15 @@ class ObservableVector2d extends Vector2d {
|
|
|
70
64
|
/**
|
|
71
65
|
* y value of the vector
|
|
72
66
|
* @public
|
|
73
|
-
* @type
|
|
67
|
+
* @type {number}
|
|
74
68
|
* @name y
|
|
75
69
|
* @memberOf me.ObservableVector2d
|
|
76
70
|
*/
|
|
77
71
|
|
|
78
|
-
/**
|
|
79
|
-
* @ignore
|
|
80
|
-
*/
|
|
81
72
|
get y() {
|
|
82
73
|
return this._y;
|
|
83
74
|
}
|
|
84
75
|
|
|
85
|
-
/**
|
|
86
|
-
* @ignore
|
|
87
|
-
*/
|
|
88
76
|
set y(value) {
|
|
89
77
|
var ret = this.onUpdate.call(this.scope, this._x, value, this._x, this._y);
|
|
90
78
|
if (ret && "y" in ret) {
|
|
@@ -112,9 +100,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
112
100
|
* @name setMuted
|
|
113
101
|
* @memberOf me.ObservableVector2d
|
|
114
102
|
* @function
|
|
115
|
-
* @param {
|
|
116
|
-
* @param {
|
|
117
|
-
* @
|
|
103
|
+
* @param {number} x x value of the vector
|
|
104
|
+
* @param {number} y y value of the vector
|
|
105
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
118
106
|
*/
|
|
119
107
|
setMuted(x, y) {
|
|
120
108
|
this._x = x;
|
|
@@ -127,9 +115,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
127
115
|
* @name setCallback
|
|
128
116
|
* @memberOf me.ObservableVector2d
|
|
129
117
|
* @function
|
|
130
|
-
* @param {
|
|
131
|
-
* @param {
|
|
132
|
-
* @
|
|
118
|
+
* @param {Function} fn callback
|
|
119
|
+
* @param {Function} [scope=null] scope
|
|
120
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
133
121
|
*/
|
|
134
122
|
setCallback(fn, scope = null) {
|
|
135
123
|
if (typeof(fn) !== "function") {
|
|
@@ -148,7 +136,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
148
136
|
* @memberOf me.ObservableVector2d
|
|
149
137
|
* @function
|
|
150
138
|
* @param {me.ObservableVector2d} v
|
|
151
|
-
* @
|
|
139
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
152
140
|
*/
|
|
153
141
|
add(v) {
|
|
154
142
|
return this._set(this._x + v.x, this._y + v.y);
|
|
@@ -160,7 +148,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
160
148
|
* @memberOf me.ObservableVector2d
|
|
161
149
|
* @function
|
|
162
150
|
* @param {me.ObservableVector2d} v
|
|
163
|
-
* @
|
|
151
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
164
152
|
*/
|
|
165
153
|
sub(v) {
|
|
166
154
|
return this._set(this._x - v.x, this._y - v.y);
|
|
@@ -171,9 +159,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
171
159
|
* @name scale
|
|
172
160
|
* @memberOf me.ObservableVector2d
|
|
173
161
|
* @function
|
|
174
|
-
* @param {
|
|
175
|
-
* @param {
|
|
176
|
-
* @
|
|
162
|
+
* @param {number} x
|
|
163
|
+
* @param {number} [y=x]
|
|
164
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
177
165
|
*/
|
|
178
166
|
scale(x, y) {
|
|
179
167
|
return this._set(this._x * x, this._y * (typeof (y) !== "undefined" ? y : x));
|
|
@@ -185,7 +173,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
185
173
|
* @memberOf me.ObservableVector2d
|
|
186
174
|
* @function
|
|
187
175
|
* @param {me.ObservableVector2d} v
|
|
188
|
-
* @
|
|
176
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
189
177
|
*/
|
|
190
178
|
scaleV(v) {
|
|
191
179
|
return this._set(this._x * v.x, this._y * v.y);
|
|
@@ -196,8 +184,8 @@ class ObservableVector2d extends Vector2d {
|
|
|
196
184
|
* @name div
|
|
197
185
|
* @memberOf me.ObservableVector2d
|
|
198
186
|
* @function
|
|
199
|
-
* @param {
|
|
200
|
-
* @
|
|
187
|
+
* @param {number} n the value to divide the vector by
|
|
188
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
201
189
|
*/
|
|
202
190
|
div(n) {
|
|
203
191
|
return this._set(this._x / n, this._y / n);
|
|
@@ -208,7 +196,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
208
196
|
* @name abs
|
|
209
197
|
* @memberOf me.ObservableVector2d
|
|
210
198
|
* @function
|
|
211
|
-
* @
|
|
199
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
212
200
|
*/
|
|
213
201
|
abs() {
|
|
214
202
|
return this._set((this._x < 0) ? -this._x : this._x, (this._y < 0) ? -this._y : this._y);
|
|
@@ -219,9 +207,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
219
207
|
* @name clamp
|
|
220
208
|
* @memberOf me.ObservableVector2d
|
|
221
209
|
* @function
|
|
222
|
-
* @param {
|
|
223
|
-
* @param {
|
|
224
|
-
* @
|
|
210
|
+
* @param {number} low
|
|
211
|
+
* @param {number} high
|
|
212
|
+
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
225
213
|
*/
|
|
226
214
|
clamp(low, high) {
|
|
227
215
|
return new ObservableVector2d(clamp(this.x, low, high), clamp(this.y, low, high), {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -232,9 +220,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
232
220
|
* @name clampSelf
|
|
233
221
|
* @memberOf me.ObservableVector2d
|
|
234
222
|
* @function
|
|
235
|
-
* @param {
|
|
236
|
-
* @param {
|
|
237
|
-
* @
|
|
223
|
+
* @param {number} low
|
|
224
|
+
* @param {number} high
|
|
225
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
238
226
|
*/
|
|
239
227
|
clampSelf(low, high) {
|
|
240
228
|
return this._set(clamp(this._x, low, high), clamp(this._y, low, high));
|
|
@@ -246,7 +234,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
246
234
|
* @memberOf me.ObservableVector2d
|
|
247
235
|
* @function
|
|
248
236
|
* @param {me.ObservableVector2d} v
|
|
249
|
-
* @
|
|
237
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
250
238
|
*/
|
|
251
239
|
minV(v) {
|
|
252
240
|
return this._set((this._x < v.x) ? this._x : v.x, (this._y < v.y) ? this._y : v.y);
|
|
@@ -258,7 +246,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
258
246
|
* @memberOf me.ObservableVector2d
|
|
259
247
|
* @function
|
|
260
248
|
* @param {me.ObservableVector2d} v
|
|
261
|
-
* @
|
|
249
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
262
250
|
*/
|
|
263
251
|
maxV(v) {
|
|
264
252
|
return this._set((this._x > v.x) ? this._x : v.x, (this._y > v.y) ? this._y : v.y);
|
|
@@ -269,7 +257,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
269
257
|
* @name floor
|
|
270
258
|
* @memberOf me.ObservableVector2d
|
|
271
259
|
* @function
|
|
272
|
-
* @
|
|
260
|
+
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
273
261
|
*/
|
|
274
262
|
floor() {
|
|
275
263
|
return new ObservableVector2d(Math.floor(this._x), Math.floor(this._y), {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -280,7 +268,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
280
268
|
* @name floorSelf
|
|
281
269
|
* @memberOf me.ObservableVector2d
|
|
282
270
|
* @function
|
|
283
|
-
* @
|
|
271
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
284
272
|
*/
|
|
285
273
|
floorSelf() {
|
|
286
274
|
return this._set(Math.floor(this._x), Math.floor(this._y));
|
|
@@ -291,7 +279,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
291
279
|
* @name ceil
|
|
292
280
|
* @memberOf me.ObservableVector2d
|
|
293
281
|
* @function
|
|
294
|
-
* @
|
|
282
|
+
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
295
283
|
*/
|
|
296
284
|
ceil() {
|
|
297
285
|
return new ObservableVector2d(Math.ceil(this._x), Math.ceil(this._y), {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -302,7 +290,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
302
290
|
* @name ceilSelf
|
|
303
291
|
* @memberOf me.ObservableVector2d
|
|
304
292
|
* @function
|
|
305
|
-
* @
|
|
293
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
306
294
|
*/
|
|
307
295
|
ceilSelf() {
|
|
308
296
|
return this._set(Math.ceil(this._x), Math.ceil(this._y));
|
|
@@ -313,7 +301,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
313
301
|
* @name negate
|
|
314
302
|
* @memberOf me.ObservableVector2d
|
|
315
303
|
* @function
|
|
316
|
-
* @
|
|
304
|
+
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
317
305
|
*/
|
|
318
306
|
negate() {
|
|
319
307
|
return new ObservableVector2d(-this._x, -this._y, {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -324,7 +312,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
324
312
|
* @name negateSelf
|
|
325
313
|
* @memberOf me.ObservableVector2d
|
|
326
314
|
* @function
|
|
327
|
-
* @
|
|
315
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
328
316
|
*/
|
|
329
317
|
negateSelf() {
|
|
330
318
|
return this._set(-this._x, -this._y);
|
|
@@ -336,7 +324,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
336
324
|
* @memberOf me.ObservableVector2d
|
|
337
325
|
* @function
|
|
338
326
|
* @param {me.ObservableVector2d} v
|
|
339
|
-
* @
|
|
327
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
340
328
|
*/
|
|
341
329
|
copy(v) {
|
|
342
330
|
return this._set(v.x, v.y);
|
|
@@ -348,7 +336,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
348
336
|
* @memberOf me.ObservableVector2d
|
|
349
337
|
* @function
|
|
350
338
|
* @param {me.ObservableVector2d} v
|
|
351
|
-
* @
|
|
339
|
+
* @returns {boolean}
|
|
352
340
|
*/
|
|
353
341
|
equals(v) {
|
|
354
342
|
return ((this._x === v.x) && (this._y === v.y));
|
|
@@ -360,7 +348,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
360
348
|
* @name perp
|
|
361
349
|
* @memberOf me.ObservableVector2d
|
|
362
350
|
* @function
|
|
363
|
-
* @
|
|
351
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
364
352
|
*/
|
|
365
353
|
perp() {
|
|
366
354
|
return this._set(this._y, -this._x);
|
|
@@ -373,7 +361,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
373
361
|
* @function
|
|
374
362
|
* @param {number} angle The angle to rotate (in radians)
|
|
375
363
|
* @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around
|
|
376
|
-
* @
|
|
364
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
377
365
|
*/
|
|
378
366
|
rotate(angle, v) {
|
|
379
367
|
var cx = 0;
|
|
@@ -399,7 +387,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
399
387
|
* @memberOf me.ObservableVector2d
|
|
400
388
|
* @function
|
|
401
389
|
* @param {me.Vector2d|me.ObservableVector2d} v
|
|
402
|
-
* @
|
|
390
|
+
* @returns {number} The dot product.
|
|
403
391
|
*/
|
|
404
392
|
dotProduct(v) {
|
|
405
393
|
return this._x * v.x + this._y * v.y;
|
|
@@ -411,8 +399,8 @@ class ObservableVector2d extends Vector2d {
|
|
|
411
399
|
* @memberOf me.ObservableVector2d
|
|
412
400
|
* @function
|
|
413
401
|
* @param {me.Vector2d|me.ObservableVector2d} v
|
|
414
|
-
* @param {
|
|
415
|
-
* @
|
|
402
|
+
* @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
403
|
+
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
416
404
|
*/
|
|
417
405
|
lerp(v, alpha) {
|
|
418
406
|
this._x += ( v.x - this._x ) * alpha;
|
|
@@ -426,7 +414,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
426
414
|
* @memberOf me.ObservableVector2d
|
|
427
415
|
* @function
|
|
428
416
|
* @param {me.ObservableVector2d} v
|
|
429
|
-
* @
|
|
417
|
+
* @returns {number}
|
|
430
418
|
*/
|
|
431
419
|
distance(v) {
|
|
432
420
|
return Math.sqrt((this._x - v.x) * (this._x - v.x) + (this._y - v.y) * (this._y - v.y));
|
|
@@ -437,7 +425,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
437
425
|
* @name clone
|
|
438
426
|
* @memberOf me.ObservableVector2d
|
|
439
427
|
* @function
|
|
440
|
-
* @
|
|
428
|
+
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
441
429
|
*/
|
|
442
430
|
clone() {
|
|
443
431
|
return pool.pull("ObservableVector2d", this._x, this._y, {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -448,7 +436,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
448
436
|
* @name toVector2d
|
|
449
437
|
* @memberOf me.ObservableVector2d
|
|
450
438
|
* @function
|
|
451
|
-
* @
|
|
439
|
+
* @returns {me.Vector2d} new me.Vector2d
|
|
452
440
|
*/
|
|
453
441
|
toVector2d() {
|
|
454
442
|
return pool.pull("Vector2d", this._x, this._y);
|
|
@@ -459,7 +447,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
459
447
|
* @name toString
|
|
460
448
|
* @memberOf me.ObservableVector2d
|
|
461
449
|
* @function
|
|
462
|
-
* @
|
|
450
|
+
* @returns {string}
|
|
463
451
|
*/
|
|
464
452
|
toString() {
|
|
465
453
|
return "x:" + this._x + ",y:" + this._y;
|