melonjs 10.2.3 → 10.5.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 +3620 -3582
- package/dist/melonjs.min.js +5 -5
- package/dist/melonjs.module.d.ts +3646 -4545
- package/dist/melonjs.module.js +3912 -3521
- package/package.json +21 -20
- package/src/audio/audio.js +30 -31
- package/src/camera/camera2d.js +47 -58
- 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 +14 -32
- 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 +83 -13
- 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 +40 -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 +2 -5
- 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 +49 -147
- package/src/physics/bounds.js +48 -50
- package/src/physics/collision.js +13 -14
- package/src/physics/detector.js +18 -17
- package/src/physics/quadtree.js +17 -20
- 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/dragndrop.js +224 -0
- 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 +26 -10
- package/src/video/video.js +15 -16
- 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 -101
- package/src/video/webgl/webgl_renderer.js +126 -106
- package/src/entity/draggable.js +0 -139
- package/src/entity/droptarget.js +0 -109
|
@@ -5,18 +5,16 @@ import {clamp} from "./math.js";
|
|
|
5
5
|
/**
|
|
6
6
|
* @classdesc
|
|
7
7
|
* A Vector2d object that provide notification by executing the given callback when the vector is changed.
|
|
8
|
-
* @
|
|
9
|
-
* @extends me.Vector2d
|
|
10
|
-
* @memberOf me
|
|
11
|
-
* @constructor
|
|
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
|
-
* @param {Function} settings.onUpdate the callback to be executed when the vector is changed
|
|
16
|
-
* @param {Function} [settings.scope] the value to use as this when calling onUpdate
|
|
8
|
+
* @augments Vector2d
|
|
17
9
|
*/
|
|
18
10
|
class ObservableVector2d extends Vector2d {
|
|
19
|
-
|
|
11
|
+
/**
|
|
12
|
+
* @param {number} x x value of the vector
|
|
13
|
+
* @param {number} y y value of the vector
|
|
14
|
+
* @param {object} settings additional required parameters
|
|
15
|
+
* @param {Function} settings.onUpdate the callback to be executed when the vector is changed
|
|
16
|
+
* @param {Function} [settings.scope] the value to use as this when calling onUpdate
|
|
17
|
+
*/
|
|
20
18
|
constructor(x = 0, y = 0, settings) {
|
|
21
19
|
super(x, y);
|
|
22
20
|
if (typeof(settings) === "undefined") {
|
|
@@ -44,7 +42,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
44
42
|
* @public
|
|
45
43
|
* @type {number}
|
|
46
44
|
* @name x
|
|
47
|
-
* @
|
|
45
|
+
* @memberof ObservableVector2d
|
|
48
46
|
*/
|
|
49
47
|
|
|
50
48
|
get x() {
|
|
@@ -66,7 +64,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
66
64
|
* @public
|
|
67
65
|
* @type {number}
|
|
68
66
|
* @name y
|
|
69
|
-
* @
|
|
67
|
+
* @memberof ObservableVector2d
|
|
70
68
|
*/
|
|
71
69
|
|
|
72
70
|
get y() {
|
|
@@ -98,11 +96,11 @@ class ObservableVector2d extends Vector2d {
|
|
|
98
96
|
/**
|
|
99
97
|
* set the vector value without triggering the callback
|
|
100
98
|
* @name setMuted
|
|
101
|
-
* @
|
|
99
|
+
* @memberof ObservableVector2d
|
|
102
100
|
* @function
|
|
103
101
|
* @param {number} x x value of the vector
|
|
104
102
|
* @param {number} y y value of the vector
|
|
105
|
-
* @returns {
|
|
103
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
106
104
|
*/
|
|
107
105
|
setMuted(x, y) {
|
|
108
106
|
this._x = x;
|
|
@@ -113,11 +111,11 @@ class ObservableVector2d extends Vector2d {
|
|
|
113
111
|
/**
|
|
114
112
|
* set the callback to be executed when the vector is changed
|
|
115
113
|
* @name setCallback
|
|
116
|
-
* @
|
|
114
|
+
* @memberof ObservableVector2d
|
|
117
115
|
* @function
|
|
118
116
|
* @param {Function} fn callback
|
|
119
117
|
* @param {Function} [scope=null] scope
|
|
120
|
-
* @returns {
|
|
118
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
121
119
|
*/
|
|
122
120
|
setCallback(fn, scope = null) {
|
|
123
121
|
if (typeof(fn) !== "function") {
|
|
@@ -133,10 +131,10 @@ class ObservableVector2d extends Vector2d {
|
|
|
133
131
|
/**
|
|
134
132
|
* Add the passed vector to this vector
|
|
135
133
|
* @name add
|
|
136
|
-
* @
|
|
134
|
+
* @memberof ObservableVector2d
|
|
137
135
|
* @function
|
|
138
|
-
* @param {
|
|
139
|
-
* @returns {
|
|
136
|
+
* @param {ObservableVector2d} v
|
|
137
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
140
138
|
*/
|
|
141
139
|
add(v) {
|
|
142
140
|
return this._set(this._x + v.x, this._y + v.y);
|
|
@@ -145,10 +143,10 @@ class ObservableVector2d extends Vector2d {
|
|
|
145
143
|
/**
|
|
146
144
|
* Substract the passed vector to this vector
|
|
147
145
|
* @name sub
|
|
148
|
-
* @
|
|
146
|
+
* @memberof ObservableVector2d
|
|
149
147
|
* @function
|
|
150
|
-
* @param {
|
|
151
|
-
* @returns {
|
|
148
|
+
* @param {ObservableVector2d} v
|
|
149
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
152
150
|
*/
|
|
153
151
|
sub(v) {
|
|
154
152
|
return this._set(this._x - v.x, this._y - v.y);
|
|
@@ -157,11 +155,11 @@ class ObservableVector2d extends Vector2d {
|
|
|
157
155
|
/**
|
|
158
156
|
* Multiply this vector values by the given scalar
|
|
159
157
|
* @name scale
|
|
160
|
-
* @
|
|
158
|
+
* @memberof ObservableVector2d
|
|
161
159
|
* @function
|
|
162
160
|
* @param {number} x
|
|
163
161
|
* @param {number} [y=x]
|
|
164
|
-
* @returns {
|
|
162
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
165
163
|
*/
|
|
166
164
|
scale(x, y) {
|
|
167
165
|
return this._set(this._x * x, this._y * (typeof (y) !== "undefined" ? y : x));
|
|
@@ -170,10 +168,10 @@ class ObservableVector2d extends Vector2d {
|
|
|
170
168
|
/**
|
|
171
169
|
* Multiply this vector values by the passed vector
|
|
172
170
|
* @name scaleV
|
|
173
|
-
* @
|
|
171
|
+
* @memberof ObservableVector2d
|
|
174
172
|
* @function
|
|
175
|
-
* @param {
|
|
176
|
-
* @returns {
|
|
173
|
+
* @param {ObservableVector2d} v
|
|
174
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
177
175
|
*/
|
|
178
176
|
scaleV(v) {
|
|
179
177
|
return this._set(this._x * v.x, this._y * v.y);
|
|
@@ -182,10 +180,10 @@ class ObservableVector2d extends Vector2d {
|
|
|
182
180
|
/**
|
|
183
181
|
* Divide this vector values by the passed value
|
|
184
182
|
* @name div
|
|
185
|
-
* @
|
|
183
|
+
* @memberof ObservableVector2d
|
|
186
184
|
* @function
|
|
187
185
|
* @param {number} n the value to divide the vector by
|
|
188
|
-
* @returns {
|
|
186
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
189
187
|
*/
|
|
190
188
|
div(n) {
|
|
191
189
|
return this._set(this._x / n, this._y / n);
|
|
@@ -194,9 +192,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
194
192
|
/**
|
|
195
193
|
* Update this vector values to absolute values
|
|
196
194
|
* @name abs
|
|
197
|
-
* @
|
|
195
|
+
* @memberof ObservableVector2d
|
|
198
196
|
* @function
|
|
199
|
-
* @returns {
|
|
197
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
200
198
|
*/
|
|
201
199
|
abs() {
|
|
202
200
|
return this._set((this._x < 0) ? -this._x : this._x, (this._y < 0) ? -this._y : this._y);
|
|
@@ -205,11 +203,11 @@ class ObservableVector2d extends Vector2d {
|
|
|
205
203
|
/**
|
|
206
204
|
* Clamp the vector value within the specified value range
|
|
207
205
|
* @name clamp
|
|
208
|
-
* @
|
|
206
|
+
* @memberof ObservableVector2d
|
|
209
207
|
* @function
|
|
210
208
|
* @param {number} low
|
|
211
209
|
* @param {number} high
|
|
212
|
-
* @returns {
|
|
210
|
+
* @returns {ObservableVector2d} new me.ObservableVector2d
|
|
213
211
|
*/
|
|
214
212
|
clamp(low, high) {
|
|
215
213
|
return new ObservableVector2d(clamp(this.x, low, high), clamp(this.y, low, high), {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -218,11 +216,11 @@ class ObservableVector2d extends Vector2d {
|
|
|
218
216
|
/**
|
|
219
217
|
* Clamp this vector value within the specified value range
|
|
220
218
|
* @name clampSelf
|
|
221
|
-
* @
|
|
219
|
+
* @memberof ObservableVector2d
|
|
222
220
|
* @function
|
|
223
221
|
* @param {number} low
|
|
224
222
|
* @param {number} high
|
|
225
|
-
* @returns {
|
|
223
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
226
224
|
*/
|
|
227
225
|
clampSelf(low, high) {
|
|
228
226
|
return this._set(clamp(this._x, low, high), clamp(this._y, low, high));
|
|
@@ -231,10 +229,10 @@ class ObservableVector2d extends Vector2d {
|
|
|
231
229
|
/**
|
|
232
230
|
* Update this vector with the minimum value between this and the passed vector
|
|
233
231
|
* @name minV
|
|
234
|
-
* @
|
|
232
|
+
* @memberof ObservableVector2d
|
|
235
233
|
* @function
|
|
236
|
-
* @param {
|
|
237
|
-
* @returns {
|
|
234
|
+
* @param {ObservableVector2d} v
|
|
235
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
238
236
|
*/
|
|
239
237
|
minV(v) {
|
|
240
238
|
return this._set((this._x < v.x) ? this._x : v.x, (this._y < v.y) ? this._y : v.y);
|
|
@@ -243,10 +241,10 @@ class ObservableVector2d extends Vector2d {
|
|
|
243
241
|
/**
|
|
244
242
|
* Update this vector with the maximum value between this and the passed vector
|
|
245
243
|
* @name maxV
|
|
246
|
-
* @
|
|
244
|
+
* @memberof ObservableVector2d
|
|
247
245
|
* @function
|
|
248
|
-
* @param {
|
|
249
|
-
* @returns {
|
|
246
|
+
* @param {ObservableVector2d} v
|
|
247
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
250
248
|
*/
|
|
251
249
|
maxV(v) {
|
|
252
250
|
return this._set((this._x > v.x) ? this._x : v.x, (this._y > v.y) ? this._y : v.y);
|
|
@@ -255,9 +253,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
255
253
|
/**
|
|
256
254
|
* Floor the vector values
|
|
257
255
|
* @name floor
|
|
258
|
-
* @
|
|
256
|
+
* @memberof ObservableVector2d
|
|
259
257
|
* @function
|
|
260
|
-
* @returns {
|
|
258
|
+
* @returns {ObservableVector2d} new me.ObservableVector2d
|
|
261
259
|
*/
|
|
262
260
|
floor() {
|
|
263
261
|
return new ObservableVector2d(Math.floor(this._x), Math.floor(this._y), {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -266,9 +264,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
266
264
|
/**
|
|
267
265
|
* Floor this vector values
|
|
268
266
|
* @name floorSelf
|
|
269
|
-
* @
|
|
267
|
+
* @memberof ObservableVector2d
|
|
270
268
|
* @function
|
|
271
|
-
* @returns {
|
|
269
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
272
270
|
*/
|
|
273
271
|
floorSelf() {
|
|
274
272
|
return this._set(Math.floor(this._x), Math.floor(this._y));
|
|
@@ -277,9 +275,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
277
275
|
/**
|
|
278
276
|
* Ceil the vector values
|
|
279
277
|
* @name ceil
|
|
280
|
-
* @
|
|
278
|
+
* @memberof ObservableVector2d
|
|
281
279
|
* @function
|
|
282
|
-
* @returns {
|
|
280
|
+
* @returns {ObservableVector2d} new me.ObservableVector2d
|
|
283
281
|
*/
|
|
284
282
|
ceil() {
|
|
285
283
|
return new ObservableVector2d(Math.ceil(this._x), Math.ceil(this._y), {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -288,9 +286,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
288
286
|
/**
|
|
289
287
|
* Ceil this vector values
|
|
290
288
|
* @name ceilSelf
|
|
291
|
-
* @
|
|
289
|
+
* @memberof ObservableVector2d
|
|
292
290
|
* @function
|
|
293
|
-
* @returns {
|
|
291
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
294
292
|
*/
|
|
295
293
|
ceilSelf() {
|
|
296
294
|
return this._set(Math.ceil(this._x), Math.ceil(this._y));
|
|
@@ -299,9 +297,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
299
297
|
/**
|
|
300
298
|
* Negate the vector values
|
|
301
299
|
* @name negate
|
|
302
|
-
* @
|
|
300
|
+
* @memberof ObservableVector2d
|
|
303
301
|
* @function
|
|
304
|
-
* @returns {
|
|
302
|
+
* @returns {ObservableVector2d} new me.ObservableVector2d
|
|
305
303
|
*/
|
|
306
304
|
negate() {
|
|
307
305
|
return new ObservableVector2d(-this._x, -this._y, {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -310,9 +308,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
310
308
|
/**
|
|
311
309
|
* Negate this vector values
|
|
312
310
|
* @name negateSelf
|
|
313
|
-
* @
|
|
311
|
+
* @memberof ObservableVector2d
|
|
314
312
|
* @function
|
|
315
|
-
* @returns {
|
|
313
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
316
314
|
*/
|
|
317
315
|
negateSelf() {
|
|
318
316
|
return this._set(-this._x, -this._y);
|
|
@@ -321,10 +319,10 @@ class ObservableVector2d extends Vector2d {
|
|
|
321
319
|
/**
|
|
322
320
|
* Copy the x,y values of the passed vector to this one
|
|
323
321
|
* @name copy
|
|
324
|
-
* @
|
|
322
|
+
* @memberof ObservableVector2d
|
|
325
323
|
* @function
|
|
326
|
-
* @param {
|
|
327
|
-
* @returns {
|
|
324
|
+
* @param {ObservableVector2d} v
|
|
325
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
328
326
|
*/
|
|
329
327
|
copy(v) {
|
|
330
328
|
return this._set(v.x, v.y);
|
|
@@ -333,9 +331,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
333
331
|
/**
|
|
334
332
|
* return true if the two vectors are the same
|
|
335
333
|
* @name equals
|
|
336
|
-
* @
|
|
334
|
+
* @memberof ObservableVector2d
|
|
337
335
|
* @function
|
|
338
|
-
* @param {
|
|
336
|
+
* @param {ObservableVector2d} v
|
|
339
337
|
* @returns {boolean}
|
|
340
338
|
*/
|
|
341
339
|
equals(v) {
|
|
@@ -346,9 +344,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
346
344
|
* change this vector to be perpendicular to what it was before.<br>
|
|
347
345
|
* (Effectively rotates it 90 degrees in a clockwise direction)
|
|
348
346
|
* @name perp
|
|
349
|
-
* @
|
|
347
|
+
* @memberof ObservableVector2d
|
|
350
348
|
* @function
|
|
351
|
-
* @returns {
|
|
349
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
352
350
|
*/
|
|
353
351
|
perp() {
|
|
354
352
|
return this._set(this._y, -this._x);
|
|
@@ -357,11 +355,11 @@ class ObservableVector2d extends Vector2d {
|
|
|
357
355
|
/**
|
|
358
356
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians).
|
|
359
357
|
* @name rotate
|
|
360
|
-
* @
|
|
358
|
+
* @memberof ObservableVector2d
|
|
361
359
|
* @function
|
|
362
360
|
* @param {number} angle The angle to rotate (in radians)
|
|
363
|
-
* @param {
|
|
364
|
-
* @returns {
|
|
361
|
+
* @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
|
|
362
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
365
363
|
*/
|
|
366
364
|
rotate(angle, v) {
|
|
367
365
|
var cx = 0;
|
|
@@ -383,24 +381,36 @@ class ObservableVector2d extends Vector2d {
|
|
|
383
381
|
|
|
384
382
|
/**
|
|
385
383
|
* return the dot product of this vector and the passed one
|
|
386
|
-
* @name
|
|
387
|
-
* @
|
|
384
|
+
* @name dot
|
|
385
|
+
* @memberof ObservableVector2d
|
|
388
386
|
* @function
|
|
389
|
-
* @param {
|
|
387
|
+
* @param {Vector2d|ObservableVector2d} v
|
|
390
388
|
* @returns {number} The dot product.
|
|
391
389
|
*/
|
|
392
|
-
|
|
390
|
+
dot(v) {
|
|
393
391
|
return this._x * v.x + this._y * v.y;
|
|
394
392
|
}
|
|
395
393
|
|
|
394
|
+
/**
|
|
395
|
+
* return the cross product of this vector and the passed one
|
|
396
|
+
* @name cross
|
|
397
|
+
* @memberof ObservableVector2d
|
|
398
|
+
* @function
|
|
399
|
+
* @param {Vector2d|ObservableVector2d} v
|
|
400
|
+
* @returns {number} The cross product.
|
|
401
|
+
*/
|
|
402
|
+
cross(v) {
|
|
403
|
+
return this._x * v.y - this._y * v.x;
|
|
404
|
+
}
|
|
405
|
+
|
|
396
406
|
/**
|
|
397
407
|
* Linearly interpolate between this vector and the given one.
|
|
398
408
|
* @name lerp
|
|
399
|
-
* @
|
|
409
|
+
* @memberof ObservableVector2d
|
|
400
410
|
* @function
|
|
401
|
-
* @param {
|
|
411
|
+
* @param {Vector2d|ObservableVector2d} v
|
|
402
412
|
* @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
403
|
-
* @returns {
|
|
413
|
+
* @returns {ObservableVector2d} Reference to this object for method chaining
|
|
404
414
|
*/
|
|
405
415
|
lerp(v, alpha) {
|
|
406
416
|
this._x += ( v.x - this._x ) * alpha;
|
|
@@ -411,9 +421,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
411
421
|
/**
|
|
412
422
|
* return the distance between this vector and the passed one
|
|
413
423
|
* @name distance
|
|
414
|
-
* @
|
|
424
|
+
* @memberof ObservableVector2d
|
|
415
425
|
* @function
|
|
416
|
-
* @param {
|
|
426
|
+
* @param {ObservableVector2d} v
|
|
417
427
|
* @returns {number}
|
|
418
428
|
*/
|
|
419
429
|
distance(v) {
|
|
@@ -423,9 +433,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
423
433
|
/**
|
|
424
434
|
* return a clone copy of this vector
|
|
425
435
|
* @name clone
|
|
426
|
-
* @
|
|
436
|
+
* @memberof ObservableVector2d
|
|
427
437
|
* @function
|
|
428
|
-
* @returns {
|
|
438
|
+
* @returns {ObservableVector2d} new me.ObservableVector2d
|
|
429
439
|
*/
|
|
430
440
|
clone() {
|
|
431
441
|
return pool.pull("ObservableVector2d", this._x, this._y, {onUpdate: this.onUpdate, scope: this.scope});
|
|
@@ -434,9 +444,9 @@ class ObservableVector2d extends Vector2d {
|
|
|
434
444
|
/**
|
|
435
445
|
* return a `me.Vector2d` copy of this `me.ObservableVector2d` object
|
|
436
446
|
* @name toVector2d
|
|
437
|
-
* @
|
|
447
|
+
* @memberof ObservableVector2d
|
|
438
448
|
* @function
|
|
439
|
-
* @returns {
|
|
449
|
+
* @returns {Vector2d} new me.Vector2d
|
|
440
450
|
*/
|
|
441
451
|
toVector2d() {
|
|
442
452
|
return pool.pull("Vector2d", this._x, this._y);
|
|
@@ -445,7 +455,7 @@ class ObservableVector2d extends Vector2d {
|
|
|
445
455
|
/**
|
|
446
456
|
* convert the object to a string representation
|
|
447
457
|
* @name toString
|
|
448
|
-
* @
|
|
458
|
+
* @memberof ObservableVector2d
|
|
449
459
|
* @function
|
|
450
460
|
* @returns {string}
|
|
451
461
|
*/
|