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/vector2.js
CHANGED
|
@@ -4,15 +4,14 @@ import pool from "./../system/pooling.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a generic 2D Vector Object
|
|
7
|
-
* @class Vector2d
|
|
8
|
-
* @memberof me
|
|
9
|
-
* @param {number} [x=0] x value of the vector
|
|
10
|
-
* @param {number} [y=0] y value of the vector
|
|
11
7
|
*/
|
|
12
8
|
class Vector2d {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param {number} [x=0] x value of the vector
|
|
11
|
+
* @param {number} [y=0] y value of the vector
|
|
12
|
+
*/
|
|
13
|
+
constructor(x = 0, y = 0) {
|
|
14
|
+
this.onResetEvent(x, y);
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
/**
|
|
@@ -37,11 +36,11 @@ class Vector2d {
|
|
|
37
36
|
/**
|
|
38
37
|
* set the Vector x and y properties to the given values<br>
|
|
39
38
|
* @name set
|
|
40
|
-
* @memberof
|
|
39
|
+
* @memberof Vector2d
|
|
41
40
|
* @function
|
|
42
41
|
* @param {number} x
|
|
43
42
|
* @param {number} y
|
|
44
|
-
* @returns {
|
|
43
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
45
44
|
*/
|
|
46
45
|
set(x, y) {
|
|
47
46
|
if (x !== +x || y !== +y) {
|
|
@@ -55,7 +54,7 @@ class Vector2d {
|
|
|
55
54
|
* @public
|
|
56
55
|
* @type {number}
|
|
57
56
|
* @name x
|
|
58
|
-
* @memberof
|
|
57
|
+
* @memberof Vector2d
|
|
59
58
|
*/
|
|
60
59
|
//this.x = x;
|
|
61
60
|
|
|
@@ -64,7 +63,7 @@ class Vector2d {
|
|
|
64
63
|
* @public
|
|
65
64
|
* @type {number}
|
|
66
65
|
* @name y
|
|
67
|
-
* @memberof
|
|
66
|
+
* @memberof Vector2d
|
|
68
67
|
*/
|
|
69
68
|
//this.y = y;
|
|
70
69
|
|
|
@@ -74,9 +73,9 @@ class Vector2d {
|
|
|
74
73
|
/**
|
|
75
74
|
* set the Vector x and y properties to 0
|
|
76
75
|
* @name setZero
|
|
77
|
-
* @memberof
|
|
76
|
+
* @memberof Vector2d
|
|
78
77
|
* @function
|
|
79
|
-
* @returns {
|
|
78
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
80
79
|
*/
|
|
81
80
|
setZero() {
|
|
82
81
|
return this.set(0, 0);
|
|
@@ -85,10 +84,10 @@ class Vector2d {
|
|
|
85
84
|
/**
|
|
86
85
|
* set the Vector x and y properties using the passed vector
|
|
87
86
|
* @name setV
|
|
88
|
-
* @memberof
|
|
87
|
+
* @memberof Vector2d
|
|
89
88
|
* @function
|
|
90
|
-
* @param {
|
|
91
|
-
* @returns {
|
|
89
|
+
* @param {Vector2d} v
|
|
90
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
92
91
|
*/
|
|
93
92
|
setV(v) {
|
|
94
93
|
return this._set(v.x, v.y);
|
|
@@ -97,10 +96,10 @@ class Vector2d {
|
|
|
97
96
|
/**
|
|
98
97
|
* Add the passed vector to this vector
|
|
99
98
|
* @name add
|
|
100
|
-
* @memberof
|
|
99
|
+
* @memberof Vector2d
|
|
101
100
|
* @function
|
|
102
|
-
* @param {
|
|
103
|
-
* @returns {
|
|
101
|
+
* @param {Vector2d} v
|
|
102
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
104
103
|
*/
|
|
105
104
|
add(v) {
|
|
106
105
|
return this._set(this.x + v.x, this.y + v.y);
|
|
@@ -109,10 +108,10 @@ class Vector2d {
|
|
|
109
108
|
/**
|
|
110
109
|
* Substract the passed vector to this vector
|
|
111
110
|
* @name sub
|
|
112
|
-
* @memberof
|
|
111
|
+
* @memberof Vector2d
|
|
113
112
|
* @function
|
|
114
|
-
* @param {
|
|
115
|
-
* @returns {
|
|
113
|
+
* @param {Vector2d} v
|
|
114
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
116
115
|
*/
|
|
117
116
|
sub(v) {
|
|
118
117
|
return this._set(this.x - v.x, this.y - v.y);
|
|
@@ -121,11 +120,11 @@ class Vector2d {
|
|
|
121
120
|
/**
|
|
122
121
|
* Multiply this vector values by the given scalar
|
|
123
122
|
* @name scale
|
|
124
|
-
* @memberof
|
|
123
|
+
* @memberof Vector2d
|
|
125
124
|
* @function
|
|
126
125
|
* @param {number} x
|
|
127
126
|
* @param {number} [y=x]
|
|
128
|
-
* @returns {
|
|
127
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
129
128
|
*/
|
|
130
129
|
scale(x, y) {
|
|
131
130
|
return this._set(this.x * x, this.y * (typeof (y) !== "undefined" ? y : x));
|
|
@@ -134,9 +133,9 @@ class Vector2d {
|
|
|
134
133
|
/**
|
|
135
134
|
* Convert this vector into isometric coordinate space
|
|
136
135
|
* @name toIso
|
|
137
|
-
* @memberof
|
|
136
|
+
* @memberof Vector2d
|
|
138
137
|
* @function
|
|
139
|
-
* @returns {
|
|
138
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
140
139
|
*/
|
|
141
140
|
toIso() {
|
|
142
141
|
return this._set(this.x - this.y, (this.x + this.y) * 0.5);
|
|
@@ -145,9 +144,9 @@ class Vector2d {
|
|
|
145
144
|
/**
|
|
146
145
|
* Convert this vector into 2d coordinate space
|
|
147
146
|
* @name to2d
|
|
148
|
-
* @memberof
|
|
147
|
+
* @memberof Vector2d
|
|
149
148
|
* @function
|
|
150
|
-
* @returns {
|
|
149
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
151
150
|
*/
|
|
152
151
|
to2d() {
|
|
153
152
|
return this._set(this.y + this.x / 2, this.y - this.x / 2);
|
|
@@ -156,10 +155,10 @@ class Vector2d {
|
|
|
156
155
|
/**
|
|
157
156
|
* Multiply this vector values by the passed vector
|
|
158
157
|
* @name scaleV
|
|
159
|
-
* @memberof
|
|
158
|
+
* @memberof Vector2d
|
|
160
159
|
* @function
|
|
161
|
-
* @param {
|
|
162
|
-
* @returns {
|
|
160
|
+
* @param {Vector2d} v
|
|
161
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
163
162
|
*/
|
|
164
163
|
scaleV(v) {
|
|
165
164
|
return this._set(this.x * v.x, this.y * v.y);
|
|
@@ -168,10 +167,10 @@ class Vector2d {
|
|
|
168
167
|
/**
|
|
169
168
|
* Divide this vector values by the passed value
|
|
170
169
|
* @name div
|
|
171
|
-
* @memberof
|
|
170
|
+
* @memberof Vector2d
|
|
172
171
|
* @function
|
|
173
172
|
* @param {number} n the value to divide the vector by
|
|
174
|
-
* @returns {
|
|
173
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
175
174
|
*/
|
|
176
175
|
div(n) {
|
|
177
176
|
return this._set(this.x / n, this.y / n);
|
|
@@ -180,9 +179,9 @@ class Vector2d {
|
|
|
180
179
|
/**
|
|
181
180
|
* Update this vector values to absolute values
|
|
182
181
|
* @name abs
|
|
183
|
-
* @memberof
|
|
182
|
+
* @memberof Vector2d
|
|
184
183
|
* @function
|
|
185
|
-
* @returns {
|
|
184
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
186
185
|
*/
|
|
187
186
|
abs() {
|
|
188
187
|
return this._set((this.x < 0) ? -this.x : this.x, (this.y < 0) ? -this.y : this.y);
|
|
@@ -191,11 +190,11 @@ class Vector2d {
|
|
|
191
190
|
/**
|
|
192
191
|
* Clamp the vector value within the specified value range
|
|
193
192
|
* @name clamp
|
|
194
|
-
* @memberof
|
|
193
|
+
* @memberof Vector2d
|
|
195
194
|
* @function
|
|
196
195
|
* @param {number} low
|
|
197
196
|
* @param {number} high
|
|
198
|
-
* @returns {
|
|
197
|
+
* @returns {Vector2d} new me.Vector2d
|
|
199
198
|
*/
|
|
200
199
|
clamp(low, high) {
|
|
201
200
|
return new Vector2d(clamp(this.x, low, high), clamp(this.y, low, high));
|
|
@@ -204,11 +203,11 @@ class Vector2d {
|
|
|
204
203
|
/**
|
|
205
204
|
* Clamp this vector value within the specified value range
|
|
206
205
|
* @name clampSelf
|
|
207
|
-
* @memberof
|
|
206
|
+
* @memberof Vector2d
|
|
208
207
|
* @function
|
|
209
208
|
* @param {number} low
|
|
210
209
|
* @param {number} high
|
|
211
|
-
* @returns {
|
|
210
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
212
211
|
*/
|
|
213
212
|
clampSelf(low, high) {
|
|
214
213
|
return this._set(clamp(this.x, low, high), clamp(this.y, low, high));
|
|
@@ -217,10 +216,10 @@ class Vector2d {
|
|
|
217
216
|
/**
|
|
218
217
|
* Update this vector with the minimum value between this and the passed vector
|
|
219
218
|
* @name minV
|
|
220
|
-
* @memberof
|
|
219
|
+
* @memberof Vector2d
|
|
221
220
|
* @function
|
|
222
|
-
* @param {
|
|
223
|
-
* @returns {
|
|
221
|
+
* @param {Vector2d} v
|
|
222
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
224
223
|
*/
|
|
225
224
|
minV(v) {
|
|
226
225
|
return this._set((this.x < v.x) ? this.x : v.x, (this.y < v.y) ? this.y : v.y);
|
|
@@ -229,10 +228,10 @@ class Vector2d {
|
|
|
229
228
|
/**
|
|
230
229
|
* Update this vector with the maximum value between this and the passed vector
|
|
231
230
|
* @name maxV
|
|
232
|
-
* @memberof
|
|
231
|
+
* @memberof Vector2d
|
|
233
232
|
* @function
|
|
234
|
-
* @param {
|
|
235
|
-
* @returns {
|
|
233
|
+
* @param {Vector2d} v
|
|
234
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
236
235
|
*/
|
|
237
236
|
maxV(v) {
|
|
238
237
|
return this._set((this.x > v.x) ? this.x : v.x, (this.y > v.y) ? this.y : v.y);
|
|
@@ -241,9 +240,9 @@ class Vector2d {
|
|
|
241
240
|
/**
|
|
242
241
|
* Floor the vector values
|
|
243
242
|
* @name floor
|
|
244
|
-
* @memberof
|
|
243
|
+
* @memberof Vector2d
|
|
245
244
|
* @function
|
|
246
|
-
* @returns {
|
|
245
|
+
* @returns {Vector2d} new me.Vector2d
|
|
247
246
|
*/
|
|
248
247
|
floor() {
|
|
249
248
|
return new Vector2d(Math.floor(this.x), Math.floor(this.y));
|
|
@@ -252,9 +251,9 @@ class Vector2d {
|
|
|
252
251
|
/**
|
|
253
252
|
* Floor this vector values
|
|
254
253
|
* @name floorSelf
|
|
255
|
-
* @memberof
|
|
254
|
+
* @memberof Vector2d
|
|
256
255
|
* @function
|
|
257
|
-
* @returns {
|
|
256
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
258
257
|
*/
|
|
259
258
|
floorSelf() {
|
|
260
259
|
return this._set(Math.floor(this.x), Math.floor(this.y));
|
|
@@ -263,9 +262,9 @@ class Vector2d {
|
|
|
263
262
|
/**
|
|
264
263
|
* Ceil the vector values
|
|
265
264
|
* @name ceil
|
|
266
|
-
* @memberof
|
|
265
|
+
* @memberof Vector2d
|
|
267
266
|
* @function
|
|
268
|
-
* @returns {
|
|
267
|
+
* @returns {Vector2d} new me.Vector2d
|
|
269
268
|
*/
|
|
270
269
|
ceil() {
|
|
271
270
|
return new Vector2d(Math.ceil(this.x), Math.ceil(this.y));
|
|
@@ -274,9 +273,9 @@ class Vector2d {
|
|
|
274
273
|
/**
|
|
275
274
|
* Ceil this vector values
|
|
276
275
|
* @name ceilSelf
|
|
277
|
-
* @memberof
|
|
276
|
+
* @memberof Vector2d
|
|
278
277
|
* @function
|
|
279
|
-
* @returns {
|
|
278
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
280
279
|
*/
|
|
281
280
|
ceilSelf() {
|
|
282
281
|
return this._set(Math.ceil(this.x), Math.ceil(this.y));
|
|
@@ -285,9 +284,9 @@ class Vector2d {
|
|
|
285
284
|
/**
|
|
286
285
|
* Negate the vector values
|
|
287
286
|
* @name negate
|
|
288
|
-
* @memberof
|
|
287
|
+
* @memberof Vector2d
|
|
289
288
|
* @function
|
|
290
|
-
* @returns {
|
|
289
|
+
* @returns {Vector2d} new me.Vector2d
|
|
291
290
|
*/
|
|
292
291
|
negate() {
|
|
293
292
|
return new Vector2d(-this.x, -this.y);
|
|
@@ -296,9 +295,9 @@ class Vector2d {
|
|
|
296
295
|
/**
|
|
297
296
|
* Negate this vector values
|
|
298
297
|
* @name negateSelf
|
|
299
|
-
* @memberof
|
|
298
|
+
* @memberof Vector2d
|
|
300
299
|
* @function
|
|
301
|
-
* @returns {
|
|
300
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
302
301
|
*/
|
|
303
302
|
negateSelf() {
|
|
304
303
|
return this._set(-this.x, -this.y);
|
|
@@ -307,10 +306,10 @@ class Vector2d {
|
|
|
307
306
|
/**
|
|
308
307
|
* Copy the x,y values of the passed vector to this one
|
|
309
308
|
* @name copy
|
|
310
|
-
* @memberof
|
|
309
|
+
* @memberof Vector2d
|
|
311
310
|
* @function
|
|
312
|
-
* @param {
|
|
313
|
-
* @returns {
|
|
311
|
+
* @param {Vector2d} v
|
|
312
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
314
313
|
*/
|
|
315
314
|
copy(v) {
|
|
316
315
|
return this._set(v.x, v.y);
|
|
@@ -319,15 +318,15 @@ class Vector2d {
|
|
|
319
318
|
/**
|
|
320
319
|
* return true if the two vectors are the same
|
|
321
320
|
* @name equals
|
|
322
|
-
* @memberof
|
|
321
|
+
* @memberof Vector2d
|
|
323
322
|
* @function
|
|
324
|
-
* @param {
|
|
323
|
+
* @param {Vector2d} v
|
|
325
324
|
* @returns {boolean}
|
|
326
325
|
*/
|
|
327
326
|
/**
|
|
328
327
|
* return true if this vector is equal to the given values
|
|
329
328
|
* @name equals
|
|
330
|
-
* @memberof
|
|
329
|
+
* @memberof Vector2d
|
|
331
330
|
* @function
|
|
332
331
|
* @param {number} x
|
|
333
332
|
* @param {number} y
|
|
@@ -350,9 +349,9 @@ class Vector2d {
|
|
|
350
349
|
/**
|
|
351
350
|
* normalize this vector (scale the vector so that its magnitude is 1)
|
|
352
351
|
* @name normalize
|
|
353
|
-
* @memberof
|
|
352
|
+
* @memberof Vector2d
|
|
354
353
|
* @function
|
|
355
|
-
* @returns {
|
|
354
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
356
355
|
*/
|
|
357
356
|
normalize() {
|
|
358
357
|
return this.div(this.length() || 1);
|
|
@@ -362,9 +361,9 @@ class Vector2d {
|
|
|
362
361
|
* change this vector to be perpendicular to what it was before.<br>
|
|
363
362
|
* (Effectively rotates it 90 degrees in a clockwise direction)
|
|
364
363
|
* @name perp
|
|
365
|
-
* @memberof
|
|
364
|
+
* @memberof Vector2d
|
|
366
365
|
* @function
|
|
367
|
-
* @returns {
|
|
366
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
368
367
|
*/
|
|
369
368
|
perp() {
|
|
370
369
|
return this._set(this.y, -this.x);
|
|
@@ -373,11 +372,11 @@ class Vector2d {
|
|
|
373
372
|
/**
|
|
374
373
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians).
|
|
375
374
|
* @name rotate
|
|
376
|
-
* @memberof
|
|
375
|
+
* @memberof Vector2d
|
|
377
376
|
* @function
|
|
378
377
|
* @param {number} angle The angle to rotate (in radians)
|
|
379
|
-
* @param {
|
|
380
|
-
* @returns {
|
|
378
|
+
* @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
|
|
379
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
381
380
|
*/
|
|
382
381
|
rotate(angle, v) {
|
|
383
382
|
var cx = 0;
|
|
@@ -400,9 +399,9 @@ class Vector2d {
|
|
|
400
399
|
/**
|
|
401
400
|
* return the dot product of this vector and the passed one
|
|
402
401
|
* @name dot
|
|
403
|
-
* @memberof
|
|
402
|
+
* @memberof Vector2d
|
|
404
403
|
* @function
|
|
405
|
-
* @param {
|
|
404
|
+
* @param {Vector2d} v
|
|
406
405
|
* @returns {number} The dot product.
|
|
407
406
|
*/
|
|
408
407
|
dot(v) {
|
|
@@ -412,9 +411,9 @@ class Vector2d {
|
|
|
412
411
|
/**
|
|
413
412
|
* return the cross product of this vector and the passed one
|
|
414
413
|
* @name cross
|
|
415
|
-
* @memberof
|
|
414
|
+
* @memberof Vector2d
|
|
416
415
|
* @function
|
|
417
|
-
* @param {
|
|
416
|
+
* @param {Vector2d} v
|
|
418
417
|
* @returns {number} The cross product.
|
|
419
418
|
*/
|
|
420
419
|
cross(v) {
|
|
@@ -424,7 +423,7 @@ class Vector2d {
|
|
|
424
423
|
/**
|
|
425
424
|
* return the square length of this vector
|
|
426
425
|
* @name length2
|
|
427
|
-
* @memberof
|
|
426
|
+
* @memberof Vector2d
|
|
428
427
|
* @function
|
|
429
428
|
* @returns {number} The length^2 of this vector.
|
|
430
429
|
*/
|
|
@@ -435,7 +434,7 @@ class Vector2d {
|
|
|
435
434
|
/**
|
|
436
435
|
* return the length (magnitude) of this vector
|
|
437
436
|
* @name length
|
|
438
|
-
* @memberof
|
|
437
|
+
* @memberof Vector2d
|
|
439
438
|
* @function
|
|
440
439
|
* @returns {number} the length of this vector
|
|
441
440
|
*/
|
|
@@ -446,11 +445,11 @@ class Vector2d {
|
|
|
446
445
|
/**
|
|
447
446
|
* Linearly interpolate between this vector and the given one.
|
|
448
447
|
* @name lerp
|
|
449
|
-
* @memberof
|
|
448
|
+
* @memberof Vector2d
|
|
450
449
|
* @function
|
|
451
|
-
* @param {
|
|
450
|
+
* @param {Vector2d} v
|
|
452
451
|
* @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
453
|
-
* @returns {
|
|
452
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
454
453
|
*/
|
|
455
454
|
lerp(v, alpha) {
|
|
456
455
|
this.x += ( v.x - this.x ) * alpha;
|
|
@@ -461,9 +460,9 @@ class Vector2d {
|
|
|
461
460
|
/**
|
|
462
461
|
* return the distance between this vector and the passed one
|
|
463
462
|
* @name distance
|
|
464
|
-
* @memberof
|
|
463
|
+
* @memberof Vector2d
|
|
465
464
|
* @function
|
|
466
|
-
* @param {
|
|
465
|
+
* @param {Vector2d} v
|
|
467
466
|
* @returns {number}
|
|
468
467
|
*/
|
|
469
468
|
distance(v) {
|
|
@@ -474,9 +473,9 @@ class Vector2d {
|
|
|
474
473
|
/**
|
|
475
474
|
* return the angle between this vector and the passed one
|
|
476
475
|
* @name angle
|
|
477
|
-
* @memberof
|
|
476
|
+
* @memberof Vector2d
|
|
478
477
|
* @function
|
|
479
|
-
* @param {
|
|
478
|
+
* @param {Vector2d} v
|
|
480
479
|
* @returns {number} angle in radians
|
|
481
480
|
*/
|
|
482
481
|
angle(v) {
|
|
@@ -486,10 +485,10 @@ class Vector2d {
|
|
|
486
485
|
/**
|
|
487
486
|
* project this vector on to another vector.
|
|
488
487
|
* @name project
|
|
489
|
-
* @memberof
|
|
488
|
+
* @memberof Vector2d
|
|
490
489
|
* @function
|
|
491
|
-
* @param {
|
|
492
|
-
* @returns {
|
|
490
|
+
* @param {Vector2d} v The vector to project onto.
|
|
491
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
493
492
|
*/
|
|
494
493
|
project(v) {
|
|
495
494
|
return this.scale(this.dot(v) / v.length2());
|
|
@@ -499,10 +498,10 @@ class Vector2d {
|
|
|
499
498
|
* Project this vector onto a vector of unit length.<br>
|
|
500
499
|
* This is slightly more efficient than `project` when dealing with unit vectors.
|
|
501
500
|
* @name projectN
|
|
502
|
-
* @memberof
|
|
501
|
+
* @memberof Vector2d
|
|
503
502
|
* @function
|
|
504
|
-
* @param {
|
|
505
|
-
* @returns {
|
|
503
|
+
* @param {Vector2d} v The unit vector to project onto.
|
|
504
|
+
* @returns {Vector2d} Reference to this object for method chaining
|
|
506
505
|
*/
|
|
507
506
|
projectN(v) {
|
|
508
507
|
return this.scale(this.dot(v));
|
|
@@ -511,9 +510,9 @@ class Vector2d {
|
|
|
511
510
|
/**
|
|
512
511
|
* return a clone copy of this vector
|
|
513
512
|
* @name clone
|
|
514
|
-
* @memberof
|
|
513
|
+
* @memberof Vector2d
|
|
515
514
|
* @function
|
|
516
|
-
* @returns {
|
|
515
|
+
* @returns {Vector2d} new me.Vector2d
|
|
517
516
|
*/
|
|
518
517
|
clone() {
|
|
519
518
|
return pool.pull("Vector2d", this.x, this.y);
|
|
@@ -522,7 +521,7 @@ class Vector2d {
|
|
|
522
521
|
/**
|
|
523
522
|
* convert the object to a string representation
|
|
524
523
|
* @name toString
|
|
525
|
-
* @memberof
|
|
524
|
+
* @memberof Vector2d
|
|
526
525
|
* @function
|
|
527
526
|
* @returns {string}
|
|
528
527
|
*/
|