melonjs 10.2.0 → 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/README.md +1 -1
- package/dist/melonjs.js +4435 -4283
- package/dist/melonjs.min.js +4 -4
- package/dist/melonjs.module.d.ts +3348 -3833
- package/dist/melonjs.module.js +4025 -3920
- package/package.json +13 -14
- package/src/audio/audio.js +45 -45
- package/src/camera/camera2d.js +78 -101
- package/src/entity/draggable.js +21 -29
- package/src/entity/droptarget.js +24 -31
- package/src/entity/entity.js +34 -38
- package/src/game.js +8 -8
- package/src/{shapes → geometries}/ellipse.js +46 -46
- package/src/{shapes → geometries}/line.js +14 -14
- package/src/{shapes → geometries}/poly.js +103 -54
- package/src/{shapes → geometries}/rectangle.js +73 -120
- package/src/index.js +18 -19
- package/src/input/gamepad.js +20 -20
- package/src/input/input.js +3 -3
- package/src/input/keyboard.js +122 -124
- package/src/input/pointer.js +102 -62
- package/src/input/pointerevent.js +97 -42
- package/src/lang/deprecated.js +29 -18
- package/src/level/level.js +34 -26
- package/src/level/tiled/TMXGroup.js +12 -13
- package/src/level/tiled/TMXLayer.js +41 -42
- package/src/level/tiled/TMXObject.js +76 -70
- package/src/level/tiled/TMXTile.js +13 -15
- package/src/level/tiled/TMXTileMap.js +26 -25
- package/src/level/tiled/TMXTileset.js +14 -15
- package/src/level/tiled/TMXTilesetGroup.js +5 -6
- package/src/level/tiled/TMXUtils.js +13 -11
- package/src/level/tiled/renderer/TMXHexagonalRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXIsometricRenderer.js +3 -4
- package/src/level/tiled/renderer/TMXOrthogonalRenderer.js +2 -3
- package/src/level/tiled/renderer/TMXRenderer.js +18 -19
- package/src/level/tiled/renderer/TMXStaggeredRenderer.js +2 -3
- package/src/loader/loader.js +46 -40
- package/src/loader/loadingscreen.js +7 -7
- package/src/math/color.js +68 -88
- package/src/math/math.js +33 -33
- package/src/math/matrix2.js +70 -71
- package/src/math/matrix3.js +90 -91
- package/src/math/observable_vector2.js +91 -92
- package/src/math/observable_vector3.js +110 -106
- package/src/math/vector2.js +116 -104
- package/src/math/vector3.js +129 -110
- package/src/particles/emitter.js +116 -126
- package/src/particles/particle.js +4 -5
- package/src/particles/particlecontainer.js +2 -3
- package/src/physics/body.js +82 -83
- package/src/physics/bounds.js +64 -66
- package/src/physics/collision.js +21 -22
- package/src/physics/detector.js +13 -13
- package/src/physics/quadtree.js +26 -25
- package/src/physics/sat.js +21 -21
- package/src/physics/world.js +23 -22
- package/src/plugin/plugin.js +12 -13
- package/src/renderable/GUI.js +20 -26
- package/src/renderable/collectable.js +6 -7
- package/src/renderable/colorlayer.js +11 -12
- package/src/renderable/container.js +98 -81
- package/src/renderable/imagelayer.js +33 -35
- package/src/renderable/nineslicesprite.js +15 -16
- package/src/renderable/renderable.js +112 -111
- package/src/renderable/sprite.js +71 -58
- package/src/renderable/trigger.js +17 -19
- package/src/state/stage.js +14 -15
- package/src/state/state.js +78 -78
- package/src/system/device.js +137 -180
- package/src/system/event.js +116 -104
- package/src/system/pooling.js +15 -15
- package/src/system/save.js +9 -6
- package/src/system/timer.js +33 -33
- package/src/text/bitmaptext.js +39 -46
- package/src/text/bitmaptextdata.js +14 -15
- package/src/text/text.js +55 -58
- package/src/tweens/easing.js +5 -5
- package/src/tweens/interpolation.js +5 -5
- package/src/tweens/tween.js +49 -40
- package/src/utils/agent.js +12 -11
- package/src/utils/array.js +8 -8
- package/src/utils/file.js +7 -7
- package/src/utils/function.js +8 -8
- package/src/utils/string.js +19 -19
- package/src/utils/utils.js +23 -23
- package/src/video/canvas/canvas_renderer.js +127 -128
- package/src/video/renderer.js +69 -69
- package/src/video/texture.js +80 -82
- package/src/video/texture_cache.js +2 -4
- package/src/video/video.js +38 -38
- package/src/video/webgl/buffer/vertex.js +11 -3
- package/src/video/webgl/glshader.js +31 -32
- package/src/video/webgl/webgl_compositor.js +145 -127
- package/src/video/webgl/webgl_renderer.js +196 -175
|
@@ -6,15 +6,14 @@ import pool from "./../system/pooling.js";
|
|
|
6
6
|
* A Vector3d object that provide notification by executing the given callback when the vector is changed.
|
|
7
7
|
* @classdesc
|
|
8
8
|
* @class ObservableVector3d
|
|
9
|
-
* @
|
|
10
|
-
* @
|
|
11
|
-
* @
|
|
12
|
-
* @param {
|
|
13
|
-
* @param {
|
|
14
|
-
* @param {
|
|
15
|
-
* @param {Object} settings additional required parameters
|
|
9
|
+
* @augments me.Vector3d
|
|
10
|
+
* @memberof me
|
|
11
|
+
* @param {number} [x=0] x value of the vector
|
|
12
|
+
* @param {number} [y=0] y value of the vector
|
|
13
|
+
* @param {number} [z=0] z value of the vector
|
|
14
|
+
* @param {object} settings additional required parameters
|
|
16
15
|
* @param {Function} settings.onUpdate the callback to be executed when the vector is changed
|
|
17
|
-
* @param {
|
|
16
|
+
* @param {object} [settings.scope] the value to use as this when calling onUpdate
|
|
18
17
|
*/
|
|
19
18
|
class ObservableVector3d extends Vector3d {
|
|
20
19
|
|
|
@@ -43,20 +42,15 @@ class ObservableVector3d extends Vector3d {
|
|
|
43
42
|
/**
|
|
44
43
|
* x value of the vector
|
|
45
44
|
* @public
|
|
46
|
-
* @type
|
|
45
|
+
* @type {number}
|
|
47
46
|
* @name x
|
|
48
|
-
* @
|
|
47
|
+
* @memberof me.ObservableVector3d
|
|
49
48
|
*/
|
|
50
49
|
|
|
51
|
-
/**
|
|
52
|
-
* @ignore
|
|
53
|
-
*/
|
|
54
50
|
get x() {
|
|
55
51
|
return this._x;
|
|
56
52
|
}
|
|
57
|
-
|
|
58
|
-
* @ignore
|
|
59
|
-
*/
|
|
53
|
+
|
|
60
54
|
set x(value) {
|
|
61
55
|
var ret = this.onUpdate.call(this.scope, value, this._y, this._z, this._x, this._y, this._z);
|
|
62
56
|
if (ret && "x" in ret) {
|
|
@@ -69,20 +63,15 @@ class ObservableVector3d extends Vector3d {
|
|
|
69
63
|
/**
|
|
70
64
|
* y value of the vector
|
|
71
65
|
* @public
|
|
72
|
-
* @type
|
|
66
|
+
* @type {number}
|
|
73
67
|
* @name y
|
|
74
|
-
* @
|
|
68
|
+
* @memberof me.ObservableVector3d
|
|
75
69
|
*/
|
|
76
70
|
|
|
77
|
-
/**
|
|
78
|
-
* @ignore
|
|
79
|
-
*/
|
|
80
71
|
get y() {
|
|
81
72
|
return this._y;
|
|
82
73
|
}
|
|
83
|
-
|
|
84
|
-
* @ignore
|
|
85
|
-
*/
|
|
74
|
+
|
|
86
75
|
set y(value) {
|
|
87
76
|
var ret = this.onUpdate.call(this.scope, this._x, value, this._z, this._x, this._y, this._z);
|
|
88
77
|
if (ret && "y" in ret) {
|
|
@@ -96,20 +85,16 @@ class ObservableVector3d extends Vector3d {
|
|
|
96
85
|
/**
|
|
97
86
|
* z value of the vector
|
|
98
87
|
* @public
|
|
99
|
-
* @type
|
|
88
|
+
* @type {number}
|
|
100
89
|
* @name z
|
|
101
|
-
* @
|
|
90
|
+
* @memberof me.ObservableVector3d
|
|
102
91
|
*/
|
|
103
92
|
|
|
104
|
-
|
|
105
|
-
* @ignore
|
|
106
|
-
*/
|
|
93
|
+
|
|
107
94
|
get z() {
|
|
108
95
|
return this._z;
|
|
109
96
|
}
|
|
110
|
-
|
|
111
|
-
* @ignore
|
|
112
|
-
*/
|
|
97
|
+
|
|
113
98
|
set z(value) {
|
|
114
99
|
var ret = this.onUpdate.call(this.scope, this._x, this._y, value, this._x, this._y, this._z);
|
|
115
100
|
if (ret && "z" in ret) {
|
|
@@ -119,9 +104,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
119
104
|
}
|
|
120
105
|
}
|
|
121
106
|
|
|
122
|
-
|
|
123
107
|
/**
|
|
124
|
-
* @ignore
|
|
108
|
+
* @ignore
|
|
109
|
+
*/
|
|
125
110
|
_set(x, y, z) {
|
|
126
111
|
var ret = this.onUpdate.call(this.scope, x, y, z, this._x, this._y, this._z);
|
|
127
112
|
if (ret && "x" in ret && "y" in ret && "z" in ret) {
|
|
@@ -139,12 +124,12 @@ class ObservableVector3d extends Vector3d {
|
|
|
139
124
|
/**
|
|
140
125
|
* set the vector value without triggering the callback
|
|
141
126
|
* @name setMuted
|
|
142
|
-
* @
|
|
127
|
+
* @memberof me.ObservableVector3d
|
|
143
128
|
* @function
|
|
144
|
-
* @param {
|
|
145
|
-
* @param {
|
|
146
|
-
* @param {
|
|
147
|
-
* @
|
|
129
|
+
* @param {number} x x value of the vector
|
|
130
|
+
* @param {number} y y value of the vector
|
|
131
|
+
* @param {number} [z=0] z value of the vector
|
|
132
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
148
133
|
*/
|
|
149
134
|
setMuted(x, y, z) {
|
|
150
135
|
this._x = x;
|
|
@@ -156,11 +141,11 @@ class ObservableVector3d extends Vector3d {
|
|
|
156
141
|
/**
|
|
157
142
|
* set the callback to be executed when the vector is changed
|
|
158
143
|
* @name setCallback
|
|
159
|
-
* @
|
|
144
|
+
* @memberof me.ObservableVector3d
|
|
160
145
|
* @function
|
|
161
|
-
* @param {
|
|
162
|
-
* @param {
|
|
163
|
-
* @
|
|
146
|
+
* @param {Function} fn callback
|
|
147
|
+
* @param {Function} [scope=null] scope
|
|
148
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
164
149
|
*/
|
|
165
150
|
setCallback(fn, scope = null) {
|
|
166
151
|
if (typeof(fn) !== "function") {
|
|
@@ -176,10 +161,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
176
161
|
/**
|
|
177
162
|
* Add the passed vector to this vector
|
|
178
163
|
* @name add
|
|
179
|
-
* @
|
|
164
|
+
* @memberof me.ObservableVector3d
|
|
180
165
|
* @function
|
|
181
166
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
182
|
-
* @
|
|
167
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
183
168
|
*/
|
|
184
169
|
add(v) {
|
|
185
170
|
return this._set(this._x + v.x, this._y + v.y, this._z + (v.z || 0));
|
|
@@ -188,10 +173,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
188
173
|
/**
|
|
189
174
|
* Substract the passed vector to this vector
|
|
190
175
|
* @name sub
|
|
191
|
-
* @
|
|
176
|
+
* @memberof me.ObservableVector3d
|
|
192
177
|
* @function
|
|
193
178
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
194
|
-
* @
|
|
179
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
195
180
|
*/
|
|
196
181
|
sub(v) {
|
|
197
182
|
return this._set(this._x - v.x, this._y - v.y, this._z - (v.z || 0));
|
|
@@ -200,12 +185,12 @@ class ObservableVector3d extends Vector3d {
|
|
|
200
185
|
/**
|
|
201
186
|
* Multiply this vector values by the given scalar
|
|
202
187
|
* @name scale
|
|
203
|
-
* @
|
|
188
|
+
* @memberof me.ObservableVector3d
|
|
204
189
|
* @function
|
|
205
|
-
* @param {
|
|
206
|
-
* @param {
|
|
207
|
-
* @param {
|
|
208
|
-
* @
|
|
190
|
+
* @param {number} x
|
|
191
|
+
* @param {number} [y=x]
|
|
192
|
+
* @param {number} [z=1]
|
|
193
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
209
194
|
*/
|
|
210
195
|
scale(x, y, z) {
|
|
211
196
|
y = (typeof (y) !== "undefined" ? y : x);
|
|
@@ -215,10 +200,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
215
200
|
/**
|
|
216
201
|
* Multiply this vector values by the passed vector
|
|
217
202
|
* @name scaleV
|
|
218
|
-
* @
|
|
203
|
+
* @memberof me.ObservableVector3d
|
|
219
204
|
* @function
|
|
220
205
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
221
|
-
* @
|
|
206
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
222
207
|
*/
|
|
223
208
|
scaleV(v) {
|
|
224
209
|
return this._set(this._x * v.x, this._y * v.y, this._z * (v.z || 1));
|
|
@@ -227,10 +212,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
227
212
|
/**
|
|
228
213
|
* Divide this vector values by the passed value
|
|
229
214
|
* @name div
|
|
230
|
-
* @
|
|
215
|
+
* @memberof me.ObservableVector3d
|
|
231
216
|
* @function
|
|
232
|
-
* @param {
|
|
233
|
-
* @
|
|
217
|
+
* @param {number} n the value to divide the vector by
|
|
218
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
234
219
|
*/
|
|
235
220
|
div(n) {
|
|
236
221
|
return this._set(this._x / n, this._y / n, this._z / n);
|
|
@@ -239,9 +224,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
239
224
|
/**
|
|
240
225
|
* Update this vector values to absolute values
|
|
241
226
|
* @name abs
|
|
242
|
-
* @
|
|
227
|
+
* @memberof me.ObservableVector3d
|
|
243
228
|
* @function
|
|
244
|
-
* @
|
|
229
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
245
230
|
*/
|
|
246
231
|
abs() {
|
|
247
232
|
return this._set(
|
|
@@ -254,11 +239,11 @@ class ObservableVector3d extends Vector3d {
|
|
|
254
239
|
/**
|
|
255
240
|
* Clamp the vector value within the specified value range
|
|
256
241
|
* @name clamp
|
|
257
|
-
* @
|
|
242
|
+
* @memberof me.ObservableVector3d
|
|
258
243
|
* @function
|
|
259
|
-
* @param {
|
|
260
|
-
* @param {
|
|
261
|
-
* @
|
|
244
|
+
* @param {number} low
|
|
245
|
+
* @param {number} high
|
|
246
|
+
* @returns {me.ObservableVector3d} new me.ObservableVector3d
|
|
262
247
|
*/
|
|
263
248
|
clamp(low, high) {
|
|
264
249
|
return new ObservableVector3d(
|
|
@@ -272,11 +257,11 @@ class ObservableVector3d extends Vector3d {
|
|
|
272
257
|
/**
|
|
273
258
|
* Clamp this vector value within the specified value range
|
|
274
259
|
* @name clampSelf
|
|
275
|
-
* @
|
|
260
|
+
* @memberof me.ObservableVector3d
|
|
276
261
|
* @function
|
|
277
|
-
* @param {
|
|
278
|
-
* @param {
|
|
279
|
-
* @
|
|
262
|
+
* @param {number} low
|
|
263
|
+
* @param {number} high
|
|
264
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
280
265
|
*/
|
|
281
266
|
clampSelf(low, high) {
|
|
282
267
|
return this._set(
|
|
@@ -289,10 +274,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
289
274
|
/**
|
|
290
275
|
* Update this vector with the minimum value between this and the passed vector
|
|
291
276
|
* @name minV
|
|
292
|
-
* @
|
|
277
|
+
* @memberof me.ObservableVector3d
|
|
293
278
|
* @function
|
|
294
279
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
295
|
-
* @
|
|
280
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
296
281
|
*/
|
|
297
282
|
minV(v) {
|
|
298
283
|
var _vz = v.z || 0;
|
|
@@ -306,10 +291,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
306
291
|
/**
|
|
307
292
|
* Update this vector with the maximum value between this and the passed vector
|
|
308
293
|
* @name maxV
|
|
309
|
-
* @
|
|
294
|
+
* @memberof me.ObservableVector3d
|
|
310
295
|
* @function
|
|
311
296
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
312
|
-
* @
|
|
297
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
313
298
|
*/
|
|
314
299
|
maxV(v) {
|
|
315
300
|
var _vz = v.z || 0;
|
|
@@ -323,9 +308,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
323
308
|
/**
|
|
324
309
|
* Floor the vector values
|
|
325
310
|
* @name floor
|
|
326
|
-
* @
|
|
311
|
+
* @memberof me.ObservableVector3d
|
|
327
312
|
* @function
|
|
328
|
-
* @
|
|
313
|
+
* @returns {me.ObservableVector3d} new me.ObservableVector3d
|
|
329
314
|
*/
|
|
330
315
|
floor() {
|
|
331
316
|
return new ObservableVector3d(
|
|
@@ -339,9 +324,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
339
324
|
/**
|
|
340
325
|
* Floor this vector values
|
|
341
326
|
* @name floorSelf
|
|
342
|
-
* @
|
|
327
|
+
* @memberof me.ObservableVector3d
|
|
343
328
|
* @function
|
|
344
|
-
* @
|
|
329
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
345
330
|
*/
|
|
346
331
|
floorSelf() {
|
|
347
332
|
return this._set(Math.floor(this._x), Math.floor(this._y), Math.floor(this._z));
|
|
@@ -350,9 +335,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
350
335
|
/**
|
|
351
336
|
* Ceil the vector values
|
|
352
337
|
* @name ceil
|
|
353
|
-
* @
|
|
338
|
+
* @memberof me.ObservableVector3d
|
|
354
339
|
* @function
|
|
355
|
-
* @
|
|
340
|
+
* @returns {me.ObservableVector3d} new me.ObservableVector3d
|
|
356
341
|
*/
|
|
357
342
|
ceil() {
|
|
358
343
|
return new ObservableVector3d(
|
|
@@ -366,9 +351,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
366
351
|
/**
|
|
367
352
|
* Ceil this vector values
|
|
368
353
|
* @name ceilSelf
|
|
369
|
-
* @
|
|
354
|
+
* @memberof me.ObservableVector3d
|
|
370
355
|
* @function
|
|
371
|
-
* @
|
|
356
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
372
357
|
*/
|
|
373
358
|
ceilSelf() {
|
|
374
359
|
return this._set(Math.ceil(this._x), Math.ceil(this._y), Math.ceil(this._z));
|
|
@@ -377,9 +362,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
377
362
|
/**
|
|
378
363
|
* Negate the vector values
|
|
379
364
|
* @name negate
|
|
380
|
-
* @
|
|
365
|
+
* @memberof me.ObservableVector3d
|
|
381
366
|
* @function
|
|
382
|
-
* @
|
|
367
|
+
* @returns {me.ObservableVector3d} new me.ObservableVector3d
|
|
383
368
|
*/
|
|
384
369
|
negate() {
|
|
385
370
|
return new ObservableVector3d(
|
|
@@ -393,9 +378,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
393
378
|
/**
|
|
394
379
|
* Negate this vector values
|
|
395
380
|
* @name negateSelf
|
|
396
|
-
* @
|
|
381
|
+
* @memberof me.ObservableVector3d
|
|
397
382
|
* @function
|
|
398
|
-
* @
|
|
383
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
399
384
|
*/
|
|
400
385
|
negateSelf() {
|
|
401
386
|
return this._set(-this._x, -this._y, -this._z);
|
|
@@ -404,10 +389,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
404
389
|
/**
|
|
405
390
|
* Copy the components of the given vector into this one
|
|
406
391
|
* @name copy
|
|
407
|
-
* @
|
|
392
|
+
* @memberof me.ObservableVector3d
|
|
408
393
|
* @function
|
|
409
394
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
410
|
-
* @
|
|
395
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
411
396
|
*/
|
|
412
397
|
copy(v) {
|
|
413
398
|
return this._set(v.x, v.y, v.z || 0);
|
|
@@ -416,10 +401,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
416
401
|
/**
|
|
417
402
|
* return true if the two vectors are the same
|
|
418
403
|
* @name equals
|
|
419
|
-
* @
|
|
404
|
+
* @memberof me.ObservableVector3d
|
|
420
405
|
* @function
|
|
421
406
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
422
|
-
* @
|
|
407
|
+
* @returns {boolean}
|
|
423
408
|
*/
|
|
424
409
|
equals(v) {
|
|
425
410
|
return ((this._x === v.x) && (this._y === v.y) && (this._z === (v.z || this._z)));
|
|
@@ -429,9 +414,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
429
414
|
* change this vector to be perpendicular to what it was before.<br>
|
|
430
415
|
* (Effectively rotates it 90 degrees in a clockwise direction)
|
|
431
416
|
* @name perp
|
|
432
|
-
* @
|
|
417
|
+
* @memberof me.ObservableVector3d
|
|
433
418
|
* @function
|
|
434
|
-
* @
|
|
419
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
435
420
|
*/
|
|
436
421
|
perp() {
|
|
437
422
|
return this._set(this._y, -this._x, this._z);
|
|
@@ -440,11 +425,11 @@ class ObservableVector3d extends Vector3d {
|
|
|
440
425
|
/**
|
|
441
426
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians).
|
|
442
427
|
* @name rotate
|
|
443
|
-
* @
|
|
428
|
+
* @memberof me.ObservableVector3d
|
|
444
429
|
* @function
|
|
445
430
|
* @param {number} angle The angle to rotate (in radians)
|
|
446
431
|
* @param {me.Vector2d|me.ObservableVector2d} [v] an optional point to rotate around (on the same z axis)
|
|
447
|
-
* @
|
|
432
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
448
433
|
*/
|
|
449
434
|
rotate(angle, v) {
|
|
450
435
|
var cx = 0;
|
|
@@ -467,24 +452,43 @@ class ObservableVector3d extends Vector3d {
|
|
|
467
452
|
|
|
468
453
|
/**
|
|
469
454
|
* return the dot product of this vector and the passed one
|
|
470
|
-
* @name
|
|
471
|
-
* @
|
|
455
|
+
* @name dot
|
|
456
|
+
* @memberof me.ObservableVector3d
|
|
472
457
|
* @function
|
|
473
458
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
474
|
-
* @
|
|
459
|
+
* @returns {number} The dot product.
|
|
475
460
|
*/
|
|
476
|
-
|
|
461
|
+
dot(v) {
|
|
477
462
|
return this._x * v.x + this._y * v.y + this._z * (v.z || 1);
|
|
478
463
|
}
|
|
479
464
|
|
|
465
|
+
/**
|
|
466
|
+
* calculate the cross product of this vector and the passed one
|
|
467
|
+
* @name cross
|
|
468
|
+
* @memberof me.ObservableVector3d
|
|
469
|
+
* @function
|
|
470
|
+
* @param {me.Vector3d|me.ObservableVector3d} v
|
|
471
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
472
|
+
*/
|
|
473
|
+
cross(v) {
|
|
474
|
+
var ax = this._x, ay = this._y, az = this._z;
|
|
475
|
+
var bx = v.x, by = v.y, bz = v.z;
|
|
476
|
+
|
|
477
|
+
return this._set(
|
|
478
|
+
ay * bz - az * by,
|
|
479
|
+
az * bx - ax * bz,
|
|
480
|
+
ax * by - ay * bx
|
|
481
|
+
);
|
|
482
|
+
}
|
|
483
|
+
|
|
480
484
|
/**
|
|
481
485
|
* Linearly interpolate between this vector and the given one.
|
|
482
486
|
* @name lerp
|
|
483
|
-
* @
|
|
487
|
+
* @memberof me.ObservableVector3d
|
|
484
488
|
* @function
|
|
485
489
|
* @param {me.Vector3d|me.ObservableVector3d} v
|
|
486
|
-
* @param {
|
|
487
|
-
* @
|
|
490
|
+
* @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
491
|
+
* @returns {me.ObservableVector3d} Reference to this object for method chaining
|
|
488
492
|
*/
|
|
489
493
|
lerp(v, alpha) {
|
|
490
494
|
this._x += ( v.x - this._x ) * alpha;
|
|
@@ -496,10 +500,10 @@ class ObservableVector3d extends Vector3d {
|
|
|
496
500
|
/**
|
|
497
501
|
* return the distance between this vector and the passed one
|
|
498
502
|
* @name distance
|
|
499
|
-
* @
|
|
503
|
+
* @memberof me.ObservableVector3d
|
|
500
504
|
* @function
|
|
501
505
|
* @param {me.Vector2d|me.Vector3d|me.ObservableVector2d|me.ObservableVector3d} v
|
|
502
|
-
* @
|
|
506
|
+
* @returns {number}
|
|
503
507
|
*/
|
|
504
508
|
distance(v) {
|
|
505
509
|
var dx = this._x - v.x;
|
|
@@ -511,9 +515,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
511
515
|
/**
|
|
512
516
|
* return a clone copy of this vector
|
|
513
517
|
* @name clone
|
|
514
|
-
* @
|
|
518
|
+
* @memberof me.ObservableVector3d
|
|
515
519
|
* @function
|
|
516
|
-
* @
|
|
520
|
+
* @returns {me.ObservableVector3d} new me.ObservableVector3d
|
|
517
521
|
*/
|
|
518
522
|
clone() {
|
|
519
523
|
return pool.pull("ObservableVector3d",
|
|
@@ -527,9 +531,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
527
531
|
/**
|
|
528
532
|
* return a `me.Vector3d` copy of this `me.ObservableVector3d` object
|
|
529
533
|
* @name toVector3d
|
|
530
|
-
* @
|
|
534
|
+
* @memberof me.ObservableVector3d
|
|
531
535
|
* @function
|
|
532
|
-
* @
|
|
536
|
+
* @returns {me.Vector3d} new me.Vector3d
|
|
533
537
|
*/
|
|
534
538
|
toVector3d() {
|
|
535
539
|
return pool.pull("Vector3d", this._x, this._y, this._z);
|
|
@@ -538,9 +542,9 @@ class ObservableVector3d extends Vector3d {
|
|
|
538
542
|
/**
|
|
539
543
|
* convert the object to a string representation
|
|
540
544
|
* @name toString
|
|
541
|
-
* @
|
|
545
|
+
* @memberof me.ObservableVector3d
|
|
542
546
|
* @function
|
|
543
|
-
* @
|
|
547
|
+
* @returns {string}
|
|
544
548
|
*/
|
|
545
549
|
toString() {
|
|
546
550
|
return "x:" + this._x + ",y:" + this._y + ",z:" + this._z;
|