melonjs 10.2.3 → 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/dist/melonjs.js +1741 -1558
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +1256 -1758
- package/dist/melonjs.module.js +1734 -1582
- package/package.json +12 -12
- package/src/audio/audio.js +3 -3
- package/src/camera/camera2d.js +26 -27
- package/src/entity/draggable.js +10 -19
- package/src/entity/droptarget.js +12 -20
- package/src/entity/entity.js +13 -13
- package/src/game.js +6 -6
- package/src/{shapes → geometries}/ellipse.js +19 -20
- package/src/{shapes → geometries}/line.js +6 -7
- package/src/{shapes → geometries}/poly.js +70 -23
- package/src/{shapes → geometries}/rectangle.js +23 -24
- package/src/index.js +8 -9
- package/src/input/gamepad.js +7 -7
- package/src/input/input.js +2 -2
- package/src/input/keyboard.js +108 -108
- package/src/input/pointer.js +61 -28
- package/src/input/pointerevent.js +79 -16
- package/src/lang/deprecated.js +26 -15
- package/src/level/level.js +10 -10
- package/src/level/tiled/TMXGroup.js +6 -7
- package/src/level/tiled/TMXLayer.js +10 -11
- package/src/level/tiled/TMXObject.js +57 -51
- package/src/level/tiled/TMXTile.js +2 -3
- package/src/level/tiled/TMXTileMap.js +3 -4
- package/src/level/tiled/TMXTileset.js +1 -2
- package/src/level/tiled/TMXTilesetGroup.js +1 -2
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +1 -2
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +17 -15
- package/src/loader/loadingscreen.js +1 -2
- package/src/math/color.js +23 -24
- package/src/math/math.js +16 -16
- package/src/math/matrix2.js +24 -25
- package/src/math/matrix3.js +26 -27
- package/src/math/observable_vector2.js +46 -35
- package/src/math/observable_vector3.js +54 -36
- package/src/math/vector2.js +58 -47
- package/src/math/vector3.js +66 -48
- package/src/particles/emitter.js +64 -72
- package/src/particles/particle.js +3 -4
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +38 -39
- package/src/physics/bounds.js +30 -32
- package/src/physics/collision.js +6 -6
- package/src/physics/detector.js +3 -3
- package/src/physics/quadtree.js +8 -9
- package/src/physics/sat.js +4 -4
- package/src/physics/world.js +11 -12
- package/src/plugin/plugin.js +6 -7
- package/src/renderable/GUI.js +7 -8
- package/src/renderable/collectable.js +3 -4
- package/src/renderable/colorlayer.js +7 -8
- package/src/renderable/container.js +36 -37
- package/src/renderable/imagelayer.js +4 -5
- package/src/renderable/nineslicesprite.js +2 -3
- package/src/renderable/renderable.js +45 -46
- package/src/renderable/sprite.js +16 -17
- package/src/renderable/trigger.js +4 -5
- package/src/state/stage.js +8 -9
- package/src/state/state.js +24 -24
- package/src/system/device.js +41 -97
- package/src/system/event.js +45 -33
- package/src/system/pooling.js +1 -1
- package/src/system/save.js +3 -3
- package/src/system/timer.js +13 -13
- package/src/text/bitmaptext.js +12 -13
- package/src/text/bitmaptextdata.js +5 -6
- package/src/text/text.js +16 -17
- package/src/tweens/easing.js +1 -1
- package/src/tweens/interpolation.js +1 -1
- package/src/tweens/tween.js +14 -15
- package/src/utils/agent.js +3 -3
- package/src/utils/array.js +4 -4
- package/src/utils/file.js +3 -3
- package/src/utils/function.js +3 -3
- package/src/utils/string.js +7 -7
- package/src/utils/utils.js +4 -4
- package/src/video/canvas/canvas_renderer.js +39 -40
- package/src/video/renderer.js +29 -30
- package/src/video/texture.js +8 -9
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +7 -7
- package/src/video/webgl/buffer/vertex.js +2 -2
- package/src/video/webgl/glshader.js +11 -12
- package/src/video/webgl/webgl_compositor.js +118 -90
- package/src/video/webgl/webgl_renderer.js +95 -74
package/src/math/matrix3.js
CHANGED
|
@@ -5,8 +5,7 @@ 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
10
|
* @param {number[]} [arguments...] Matrix elements. See {@link me.Matrix3d.setTransform}
|
|
12
11
|
*/
|
|
@@ -42,7 +41,7 @@ class Matrix3d {
|
|
|
42
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];
|
|
@@ -54,7 +53,7 @@ class Matrix3d {
|
|
|
54
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];
|
|
@@ -66,7 +65,7 @@ class Matrix3d {
|
|
|
66
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,7 +76,7 @@ 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
|
*/
|
|
@@ -93,7 +92,7 @@ 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
97
|
* @param {number} m00
|
|
99
98
|
* @param {number} m01
|
|
@@ -139,7 +138,7 @@ 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
|
|
@@ -152,7 +151,7 @@ class Matrix3d {
|
|
|
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
|
|
@@ -171,7 +170,7 @@ 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
|
|
@@ -227,7 +226,7 @@ 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
|
*/
|
|
@@ -259,7 +258,7 @@ 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
|
*/
|
|
@@ -319,7 +318,7 @@ 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
323
|
* @param {me.Vector2d|me.Vector3d} v the vector object to be transformed
|
|
325
324
|
* @returns {me.Vector2d|me.Vector3d} result vector object.
|
|
@@ -345,7 +344,7 @@ 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
349
|
* @param {me.Vector2d|me.Vector3d} v the vector object to be transformed
|
|
351
350
|
* @returns {me.Vector2d|me.Vector3d} result vector object.
|
|
@@ -366,7 +365,7 @@ 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
370
|
* @param {number} left farthest left on the x-axis
|
|
372
371
|
* @param {number} right farthest right on the x-axis
|
|
@@ -405,7 +404,7 @@ class Matrix3d {
|
|
|
405
404
|
/**
|
|
406
405
|
* scale the matrix
|
|
407
406
|
* @name scale
|
|
408
|
-
* @
|
|
407
|
+
* @memberof me.Matrix3d
|
|
409
408
|
* @function
|
|
410
409
|
* @param {number} x a number representing the abscissa of the scaling vector.
|
|
411
410
|
* @param {number} [y=x] a number representing the ordinate of the scaling vector.
|
|
@@ -439,7 +438,7 @@ class Matrix3d {
|
|
|
439
438
|
/**
|
|
440
439
|
* adds a 2D scaling transformation.
|
|
441
440
|
* @name scaleV
|
|
442
|
-
* @
|
|
441
|
+
* @memberof me.Matrix3d
|
|
443
442
|
* @function
|
|
444
443
|
* @param {me.Vector2d|me.Vector3d} v scaling vector
|
|
445
444
|
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
@@ -451,7 +450,7 @@ 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
455
|
* @param {number} x x scaling vector
|
|
457
456
|
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
@@ -463,7 +462,7 @@ 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
467
|
* @param {number} y y scaling vector
|
|
469
468
|
* @returns {me.Matrix3d} Reference to this object for method chaining
|
|
@@ -475,7 +474,7 @@ 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
479
|
* @param {number} angle Rotation angle in radians.
|
|
481
480
|
* @param {me.Vector3d} v the axis to rotate around
|
|
@@ -554,7 +553,7 @@ 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
558
|
* @param {number} x a number representing the abscissa of the vector.
|
|
560
559
|
* @param {number} [y=x] a number representing the ordinate of the vector.
|
|
@@ -564,7 +563,7 @@ class Matrix3d {
|
|
|
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
|
|
@@ -596,7 +595,7 @@ 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
600
|
* @returns {boolean}
|
|
602
601
|
*/
|
|
@@ -626,7 +625,7 @@ 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
|
|
@@ -658,7 +657,7 @@ 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
|
*/
|
|
@@ -669,7 +668,7 @@ 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
|
*/
|
|
@@ -680,7 +679,7 @@ 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
|
*/
|
|
@@ -6,9 +6,8 @@ import {clamp} from "./math.js";
|
|
|
6
6
|
* @classdesc
|
|
7
7
|
* A Vector2d object that provide notification by executing the given callback when the vector is changed.
|
|
8
8
|
* @class ObservableVector2d
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @constructor
|
|
9
|
+
* @augments me.Vector2d
|
|
10
|
+
* @memberof me
|
|
12
11
|
* @param {number} [x=0] x value of the vector
|
|
13
12
|
* @param {number} [y=0] y value of the vector
|
|
14
13
|
* @param {object} settings additional required parameters
|
|
@@ -44,7 +43,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
44
43
|
* @public
|
|
45
44
|
* @type {number}
|
|
46
45
|
* @name x
|
|
47
|
-
* @
|
|
46
|
+
* @memberof me.ObservableVector2d
|
|
48
47
|
*/
|
|
49
48
|
|
|
50
49
|
get x() {
|
|
@@ -66,7 +65,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
66
65
|
* @public
|
|
67
66
|
* @type {number}
|
|
68
67
|
* @name y
|
|
69
|
-
* @
|
|
68
|
+
* @memberof me.ObservableVector2d
|
|
70
69
|
*/
|
|
71
70
|
|
|
72
71
|
get y() {
|
|
@@ -98,7 +97,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
98
97
|
/**
|
|
99
98
|
* set the vector value without triggering the callback
|
|
100
99
|
* @name setMuted
|
|
101
|
-
* @
|
|
100
|
+
* @memberof me.ObservableVector2d
|
|
102
101
|
* @function
|
|
103
102
|
* @param {number} x x value of the vector
|
|
104
103
|
* @param {number} y y value of the vector
|
|
@@ -113,7 +112,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
113
112
|
/**
|
|
114
113
|
* set the callback to be executed when the vector is changed
|
|
115
114
|
* @name setCallback
|
|
116
|
-
* @
|
|
115
|
+
* @memberof me.ObservableVector2d
|
|
117
116
|
* @function
|
|
118
117
|
* @param {Function} fn callback
|
|
119
118
|
* @param {Function} [scope=null] scope
|
|
@@ -133,7 +132,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
133
132
|
/**
|
|
134
133
|
* Add the passed vector to this vector
|
|
135
134
|
* @name add
|
|
136
|
-
* @
|
|
135
|
+
* @memberof me.ObservableVector2d
|
|
137
136
|
* @function
|
|
138
137
|
* @param {me.ObservableVector2d} v
|
|
139
138
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
@@ -145,7 +144,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
145
144
|
/**
|
|
146
145
|
* Substract the passed vector to this vector
|
|
147
146
|
* @name sub
|
|
148
|
-
* @
|
|
147
|
+
* @memberof me.ObservableVector2d
|
|
149
148
|
* @function
|
|
150
149
|
* @param {me.ObservableVector2d} v
|
|
151
150
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
@@ -157,7 +156,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
157
156
|
/**
|
|
158
157
|
* Multiply this vector values by the given scalar
|
|
159
158
|
* @name scale
|
|
160
|
-
* @
|
|
159
|
+
* @memberof me.ObservableVector2d
|
|
161
160
|
* @function
|
|
162
161
|
* @param {number} x
|
|
163
162
|
* @param {number} [y=x]
|
|
@@ -170,7 +169,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
170
169
|
/**
|
|
171
170
|
* Multiply this vector values by the passed vector
|
|
172
171
|
* @name scaleV
|
|
173
|
-
* @
|
|
172
|
+
* @memberof me.ObservableVector2d
|
|
174
173
|
* @function
|
|
175
174
|
* @param {me.ObservableVector2d} v
|
|
176
175
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
@@ -182,7 +181,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
182
181
|
/**
|
|
183
182
|
* Divide this vector values by the passed value
|
|
184
183
|
* @name div
|
|
185
|
-
* @
|
|
184
|
+
* @memberof me.ObservableVector2d
|
|
186
185
|
* @function
|
|
187
186
|
* @param {number} n the value to divide the vector by
|
|
188
187
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
@@ -194,7 +193,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
194
193
|
/**
|
|
195
194
|
* Update this vector values to absolute values
|
|
196
195
|
* @name abs
|
|
197
|
-
* @
|
|
196
|
+
* @memberof me.ObservableVector2d
|
|
198
197
|
* @function
|
|
199
198
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
200
199
|
*/
|
|
@@ -205,7 +204,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
205
204
|
/**
|
|
206
205
|
* Clamp the vector value within the specified value range
|
|
207
206
|
* @name clamp
|
|
208
|
-
* @
|
|
207
|
+
* @memberof me.ObservableVector2d
|
|
209
208
|
* @function
|
|
210
209
|
* @param {number} low
|
|
211
210
|
* @param {number} high
|
|
@@ -218,7 +217,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
218
217
|
/**
|
|
219
218
|
* Clamp this vector value within the specified value range
|
|
220
219
|
* @name clampSelf
|
|
221
|
-
* @
|
|
220
|
+
* @memberof me.ObservableVector2d
|
|
222
221
|
* @function
|
|
223
222
|
* @param {number} low
|
|
224
223
|
* @param {number} high
|
|
@@ -231,7 +230,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
231
230
|
/**
|
|
232
231
|
* Update this vector with the minimum value between this and the passed vector
|
|
233
232
|
* @name minV
|
|
234
|
-
* @
|
|
233
|
+
* @memberof me.ObservableVector2d
|
|
235
234
|
* @function
|
|
236
235
|
* @param {me.ObservableVector2d} v
|
|
237
236
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
@@ -243,7 +242,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
243
242
|
/**
|
|
244
243
|
* Update this vector with the maximum value between this and the passed vector
|
|
245
244
|
* @name maxV
|
|
246
|
-
* @
|
|
245
|
+
* @memberof me.ObservableVector2d
|
|
247
246
|
* @function
|
|
248
247
|
* @param {me.ObservableVector2d} v
|
|
249
248
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
@@ -255,7 +254,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
255
254
|
/**
|
|
256
255
|
* Floor the vector values
|
|
257
256
|
* @name floor
|
|
258
|
-
* @
|
|
257
|
+
* @memberof me.ObservableVector2d
|
|
259
258
|
* @function
|
|
260
259
|
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
261
260
|
*/
|
|
@@ -266,7 +265,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
266
265
|
/**
|
|
267
266
|
* Floor this vector values
|
|
268
267
|
* @name floorSelf
|
|
269
|
-
* @
|
|
268
|
+
* @memberof me.ObservableVector2d
|
|
270
269
|
* @function
|
|
271
270
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
272
271
|
*/
|
|
@@ -277,7 +276,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
277
276
|
/**
|
|
278
277
|
* Ceil the vector values
|
|
279
278
|
* @name ceil
|
|
280
|
-
* @
|
|
279
|
+
* @memberof me.ObservableVector2d
|
|
281
280
|
* @function
|
|
282
281
|
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
283
282
|
*/
|
|
@@ -288,7 +287,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
288
287
|
/**
|
|
289
288
|
* Ceil this vector values
|
|
290
289
|
* @name ceilSelf
|
|
291
|
-
* @
|
|
290
|
+
* @memberof me.ObservableVector2d
|
|
292
291
|
* @function
|
|
293
292
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
294
293
|
*/
|
|
@@ -299,7 +298,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
299
298
|
/**
|
|
300
299
|
* Negate the vector values
|
|
301
300
|
* @name negate
|
|
302
|
-
* @
|
|
301
|
+
* @memberof me.ObservableVector2d
|
|
303
302
|
* @function
|
|
304
303
|
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
305
304
|
*/
|
|
@@ -310,7 +309,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
310
309
|
/**
|
|
311
310
|
* Negate this vector values
|
|
312
311
|
* @name negateSelf
|
|
313
|
-
* @
|
|
312
|
+
* @memberof me.ObservableVector2d
|
|
314
313
|
* @function
|
|
315
314
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
316
315
|
*/
|
|
@@ -321,7 +320,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
321
320
|
/**
|
|
322
321
|
* Copy the x,y values of the passed vector to this one
|
|
323
322
|
* @name copy
|
|
324
|
-
* @
|
|
323
|
+
* @memberof me.ObservableVector2d
|
|
325
324
|
* @function
|
|
326
325
|
* @param {me.ObservableVector2d} v
|
|
327
326
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
@@ -333,7 +332,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
333
332
|
/**
|
|
334
333
|
* return true if the two vectors are the same
|
|
335
334
|
* @name equals
|
|
336
|
-
* @
|
|
335
|
+
* @memberof me.ObservableVector2d
|
|
337
336
|
* @function
|
|
338
337
|
* @param {me.ObservableVector2d} v
|
|
339
338
|
* @returns {boolean}
|
|
@@ -346,7 +345,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
346
345
|
* change this vector to be perpendicular to what it was before.<br>
|
|
347
346
|
* (Effectively rotates it 90 degrees in a clockwise direction)
|
|
348
347
|
* @name perp
|
|
349
|
-
* @
|
|
348
|
+
* @memberof me.ObservableVector2d
|
|
350
349
|
* @function
|
|
351
350
|
* @returns {me.ObservableVector2d} Reference to this object for method chaining
|
|
352
351
|
*/
|
|
@@ -357,7 +356,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
357
356
|
/**
|
|
358
357
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians).
|
|
359
358
|
* @name rotate
|
|
360
|
-
* @
|
|
359
|
+
* @memberof me.ObservableVector2d
|
|
361
360
|
* @function
|
|
362
361
|
* @param {number} angle The angle to rotate (in radians)
|
|
363
362
|
* @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around
|
|
@@ -383,20 +382,32 @@ class ObservableVector2d extends Vector2d {
|
|
|
383
382
|
|
|
384
383
|
/**
|
|
385
384
|
* return the dot product of this vector and the passed one
|
|
386
|
-
* @name
|
|
387
|
-
* @
|
|
385
|
+
* @name dot
|
|
386
|
+
* @memberof me.ObservableVector2d
|
|
388
387
|
* @function
|
|
389
388
|
* @param {me.Vector2d|me.ObservableVector2d} v
|
|
390
389
|
* @returns {number} The dot product.
|
|
391
390
|
*/
|
|
392
|
-
|
|
391
|
+
dot(v) {
|
|
393
392
|
return this._x * v.x + this._y * v.y;
|
|
394
393
|
}
|
|
395
394
|
|
|
395
|
+
/**
|
|
396
|
+
* return the cross product of this vector and the passed one
|
|
397
|
+
* @name cross
|
|
398
|
+
* @memberof me.ObservableVector2d
|
|
399
|
+
* @function
|
|
400
|
+
* @param {me.Vector2d|me.ObservableVector2d} v
|
|
401
|
+
* @returns {number} The cross product.
|
|
402
|
+
*/
|
|
403
|
+
cross(v) {
|
|
404
|
+
return this._x * v.y - this._y * v.x;
|
|
405
|
+
}
|
|
406
|
+
|
|
396
407
|
/**
|
|
397
408
|
* Linearly interpolate between this vector and the given one.
|
|
398
409
|
* @name lerp
|
|
399
|
-
* @
|
|
410
|
+
* @memberof me.ObservableVector2d
|
|
400
411
|
* @function
|
|
401
412
|
* @param {me.Vector2d|me.ObservableVector2d} v
|
|
402
413
|
* @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
@@ -411,7 +422,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
411
422
|
/**
|
|
412
423
|
* return the distance between this vector and the passed one
|
|
413
424
|
* @name distance
|
|
414
|
-
* @
|
|
425
|
+
* @memberof me.ObservableVector2d
|
|
415
426
|
* @function
|
|
416
427
|
* @param {me.ObservableVector2d} v
|
|
417
428
|
* @returns {number}
|
|
@@ -423,7 +434,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
423
434
|
/**
|
|
424
435
|
* return a clone copy of this vector
|
|
425
436
|
* @name clone
|
|
426
|
-
* @
|
|
437
|
+
* @memberof me.ObservableVector2d
|
|
427
438
|
* @function
|
|
428
439
|
* @returns {me.ObservableVector2d} new me.ObservableVector2d
|
|
429
440
|
*/
|
|
@@ -434,7 +445,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
434
445
|
/**
|
|
435
446
|
* return a `me.Vector2d` copy of this `me.ObservableVector2d` object
|
|
436
447
|
* @name toVector2d
|
|
437
|
-
* @
|
|
448
|
+
* @memberof me.ObservableVector2d
|
|
438
449
|
* @function
|
|
439
450
|
* @returns {me.Vector2d} new me.Vector2d
|
|
440
451
|
*/
|
|
@@ -445,7 +456,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
445
456
|
/**
|
|
446
457
|
* convert the object to a string representation
|
|
447
458
|
* @name toString
|
|
448
|
-
* @
|
|
459
|
+
* @memberof me.ObservableVector2d
|
|
449
460
|
* @function
|
|
450
461
|
* @returns {string}
|
|
451
462
|
*/
|