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/vector3.js
CHANGED
|
@@ -4,17 +4,15 @@ import pool from "./../system/pooling.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* @classdesc
|
|
6
6
|
* a generic 3D Vector Object
|
|
7
|
-
* @class Vector3d
|
|
8
|
-
* @memberof me
|
|
9
|
-
* @param {number} [x=0] x value of the vector
|
|
10
|
-
* @param {number} [y=0] y value of the vector
|
|
11
|
-
* @param {number} [z=0] z value of the vector
|
|
12
7
|
*/
|
|
13
|
-
|
|
14
8
|
class Vector3d {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
9
|
+
/**
|
|
10
|
+
* @param {number} [x=0] x value of the vector
|
|
11
|
+
* @param {number} [y=0] y value of the vector
|
|
12
|
+
* @param {number} [z=0] z value of the vector
|
|
13
|
+
*/
|
|
14
|
+
constructor(x = 0, y = 0, z = 0) {
|
|
15
|
+
this.onResetEvent(x, y, z);
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
/**
|
|
@@ -41,12 +39,12 @@ class Vector3d {
|
|
|
41
39
|
/**
|
|
42
40
|
* set the Vector x and y properties to the given values<br>
|
|
43
41
|
* @name set
|
|
44
|
-
* @memberof
|
|
42
|
+
* @memberof Vector3d
|
|
45
43
|
* @function
|
|
46
44
|
* @param {number} x
|
|
47
45
|
* @param {number} y
|
|
48
46
|
* @param {number} [z=0]
|
|
49
|
-
* @returns {
|
|
47
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
50
48
|
*/
|
|
51
49
|
set(x, y, z) {
|
|
52
50
|
if (x !== +x || y !== +y || (typeof z !== "undefined" && z !== +z)) {
|
|
@@ -60,7 +58,7 @@ class Vector3d {
|
|
|
60
58
|
* @public
|
|
61
59
|
* @type {number}
|
|
62
60
|
* @name x
|
|
63
|
-
* @memberof
|
|
61
|
+
* @memberof Vector3d
|
|
64
62
|
*/
|
|
65
63
|
//this.x = x;
|
|
66
64
|
|
|
@@ -69,7 +67,7 @@ class Vector3d {
|
|
|
69
67
|
* @public
|
|
70
68
|
* @type {number}
|
|
71
69
|
* @name y
|
|
72
|
-
* @memberof
|
|
70
|
+
* @memberof Vector3d
|
|
73
71
|
*/
|
|
74
72
|
//this.y = y;
|
|
75
73
|
|
|
@@ -78,7 +76,7 @@ class Vector3d {
|
|
|
78
76
|
* @public
|
|
79
77
|
* @type {number}
|
|
80
78
|
* @name z
|
|
81
|
-
* @memberof
|
|
79
|
+
* @memberof Vector3d
|
|
82
80
|
*/
|
|
83
81
|
//this.z = z;
|
|
84
82
|
|
|
@@ -88,9 +86,9 @@ class Vector3d {
|
|
|
88
86
|
/**
|
|
89
87
|
* set the Vector x and y properties to 0
|
|
90
88
|
* @name setZero
|
|
91
|
-
* @memberof
|
|
89
|
+
* @memberof Vector3d
|
|
92
90
|
* @function
|
|
93
|
-
* @returns {
|
|
91
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
94
92
|
*/
|
|
95
93
|
setZero() {
|
|
96
94
|
return this.set(0, 0, 0);
|
|
@@ -99,10 +97,10 @@ class Vector3d {
|
|
|
99
97
|
/**
|
|
100
98
|
* set the Vector x and y properties using the passed vector
|
|
101
99
|
* @name setV
|
|
102
|
-
* @memberof
|
|
100
|
+
* @memberof Vector3d
|
|
103
101
|
* @function
|
|
104
|
-
* @param {
|
|
105
|
-
* @returns {
|
|
102
|
+
* @param {Vector2d|Vector3d} v
|
|
103
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
106
104
|
*/
|
|
107
105
|
setV(v) {
|
|
108
106
|
return this._set(v.x, v.y, v.z);
|
|
@@ -111,10 +109,10 @@ class Vector3d {
|
|
|
111
109
|
/**
|
|
112
110
|
* Add the passed vector to this vector
|
|
113
111
|
* @name add
|
|
114
|
-
* @memberof
|
|
112
|
+
* @memberof Vector3d
|
|
115
113
|
* @function
|
|
116
|
-
* @param {
|
|
117
|
-
* @returns {
|
|
114
|
+
* @param {Vector2d|Vector3d} v
|
|
115
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
118
116
|
*/
|
|
119
117
|
add(v) {
|
|
120
118
|
return this._set(this.x + v.x, this.y + v.y, this.z + (v.z || 0));
|
|
@@ -123,10 +121,10 @@ class Vector3d {
|
|
|
123
121
|
/**
|
|
124
122
|
* Substract the passed vector to this vector
|
|
125
123
|
* @name sub
|
|
126
|
-
* @memberof
|
|
124
|
+
* @memberof Vector3d
|
|
127
125
|
* @function
|
|
128
|
-
* @param {
|
|
129
|
-
* @returns {
|
|
126
|
+
* @param {Vector2d|Vector3d} v
|
|
127
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
130
128
|
*/
|
|
131
129
|
sub(v) {
|
|
132
130
|
return this._set(this.x - v.x, this.y - v.y, this.z - (v.z || 0));
|
|
@@ -135,12 +133,12 @@ class Vector3d {
|
|
|
135
133
|
/**
|
|
136
134
|
* Multiply this vector values by the given scalar
|
|
137
135
|
* @name scale
|
|
138
|
-
* @memberof
|
|
136
|
+
* @memberof Vector3d
|
|
139
137
|
* @function
|
|
140
138
|
* @param {number} x
|
|
141
139
|
* @param {number} [y=x]
|
|
142
140
|
* @param {number} [z=1]
|
|
143
|
-
* @returns {
|
|
141
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
144
142
|
*/
|
|
145
143
|
scale(x, y, z) {
|
|
146
144
|
y = (typeof (y) !== "undefined" ? y : x);
|
|
@@ -150,10 +148,10 @@ class Vector3d {
|
|
|
150
148
|
/**
|
|
151
149
|
* Multiply this vector values by the passed vector
|
|
152
150
|
* @name scaleV
|
|
153
|
-
* @memberof
|
|
151
|
+
* @memberof Vector3d
|
|
154
152
|
* @function
|
|
155
|
-
* @param {
|
|
156
|
-
* @returns {
|
|
153
|
+
* @param {Vector2d|Vector3d} v
|
|
154
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
157
155
|
*/
|
|
158
156
|
scaleV(v) {
|
|
159
157
|
return this.scale(v.x, v.y, v.z);
|
|
@@ -162,9 +160,9 @@ class Vector3d {
|
|
|
162
160
|
/**
|
|
163
161
|
* Convert this vector into isometric coordinate space
|
|
164
162
|
* @name toIso
|
|
165
|
-
* @memberof
|
|
163
|
+
* @memberof Vector3d
|
|
166
164
|
* @function
|
|
167
|
-
* @returns {
|
|
165
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
168
166
|
*/
|
|
169
167
|
toIso() {
|
|
170
168
|
return this._set(this.x - this.y, (this.x + this.y) * 0.5, this.z);
|
|
@@ -173,9 +171,9 @@ class Vector3d {
|
|
|
173
171
|
/**
|
|
174
172
|
* Convert this vector into 2d coordinate space
|
|
175
173
|
* @name to2d
|
|
176
|
-
* @memberof
|
|
174
|
+
* @memberof Vector3d
|
|
177
175
|
* @function
|
|
178
|
-
* @returns {
|
|
176
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
179
177
|
*/
|
|
180
178
|
to2d() {
|
|
181
179
|
return this._set(this.y + this.x / 2, this.y - this.x / 2, this.z);
|
|
@@ -184,10 +182,10 @@ class Vector3d {
|
|
|
184
182
|
/**
|
|
185
183
|
* Divide this vector values by the passed value
|
|
186
184
|
* @name div
|
|
187
|
-
* @memberof
|
|
185
|
+
* @memberof Vector3d
|
|
188
186
|
* @function
|
|
189
187
|
* @param {number} n the value to divide the vector by
|
|
190
|
-
* @returns {
|
|
188
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
191
189
|
*/
|
|
192
190
|
div(n) {
|
|
193
191
|
return this._set(this.x / n, this.y / n, this.z / n);
|
|
@@ -196,9 +194,9 @@ class Vector3d {
|
|
|
196
194
|
/**
|
|
197
195
|
* Update this vector values to absolute values
|
|
198
196
|
* @name abs
|
|
199
|
-
* @memberof
|
|
197
|
+
* @memberof Vector3d
|
|
200
198
|
* @function
|
|
201
|
-
* @returns {
|
|
199
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
202
200
|
*/
|
|
203
201
|
abs() {
|
|
204
202
|
return this._set((this.x < 0) ? -this.x : this.x, (this.y < 0) ? -this.y : this.y, (this.z < 0) ? -this.z : this.z);
|
|
@@ -207,11 +205,11 @@ class Vector3d {
|
|
|
207
205
|
/**
|
|
208
206
|
* Clamp the vector value within the specified value range
|
|
209
207
|
* @name clamp
|
|
210
|
-
* @memberof
|
|
208
|
+
* @memberof Vector3d
|
|
211
209
|
* @function
|
|
212
210
|
* @param {number} low
|
|
213
211
|
* @param {number} high
|
|
214
|
-
* @returns {
|
|
212
|
+
* @returns {Vector3d} new me.Vector3d
|
|
215
213
|
*/
|
|
216
214
|
clamp(low, high) {
|
|
217
215
|
return new Vector3d(clamp(this.x, low, high), clamp(this.y, low, high), clamp(this.z, low, high));
|
|
@@ -220,11 +218,11 @@ class Vector3d {
|
|
|
220
218
|
/**
|
|
221
219
|
* Clamp this vector value within the specified value range
|
|
222
220
|
* @name clampSelf
|
|
223
|
-
* @memberof
|
|
221
|
+
* @memberof Vector3d
|
|
224
222
|
* @function
|
|
225
223
|
* @param {number} low
|
|
226
224
|
* @param {number} high
|
|
227
|
-
* @returns {
|
|
225
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
228
226
|
*/
|
|
229
227
|
clampSelf(low, high) {
|
|
230
228
|
return this._set(clamp(this.x, low, high), clamp(this.y, low, high), clamp(this.z, low, high));
|
|
@@ -233,10 +231,10 @@ class Vector3d {
|
|
|
233
231
|
/**
|
|
234
232
|
* Update this vector with the minimum value between this and the passed vector
|
|
235
233
|
* @name minV
|
|
236
|
-
* @memberof
|
|
234
|
+
* @memberof Vector3d
|
|
237
235
|
* @function
|
|
238
|
-
* @param {
|
|
239
|
-
* @returns {
|
|
236
|
+
* @param {Vector2d|Vector3d} v
|
|
237
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
240
238
|
*/
|
|
241
239
|
minV(v) {
|
|
242
240
|
var _vz = v.z || 0;
|
|
@@ -246,10 +244,10 @@ class Vector3d {
|
|
|
246
244
|
/**
|
|
247
245
|
* Update this vector with the maximum value between this and the passed vector
|
|
248
246
|
* @name maxV
|
|
249
|
-
* @memberof
|
|
247
|
+
* @memberof Vector3d
|
|
250
248
|
* @function
|
|
251
|
-
* @param {
|
|
252
|
-
* @returns {
|
|
249
|
+
* @param {Vector2d|Vector3d} v
|
|
250
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
253
251
|
*/
|
|
254
252
|
maxV(v) {
|
|
255
253
|
var _vz = v.z || 0;
|
|
@@ -259,9 +257,9 @@ class Vector3d {
|
|
|
259
257
|
/**
|
|
260
258
|
* Floor the vector values
|
|
261
259
|
* @name floor
|
|
262
|
-
* @memberof
|
|
260
|
+
* @memberof Vector3d
|
|
263
261
|
* @function
|
|
264
|
-
* @returns {
|
|
262
|
+
* @returns {Vector3d} new me.Vector3d
|
|
265
263
|
*/
|
|
266
264
|
floor() {
|
|
267
265
|
return new Vector3d(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
|
|
@@ -270,9 +268,9 @@ class Vector3d {
|
|
|
270
268
|
/**
|
|
271
269
|
* Floor this vector values
|
|
272
270
|
* @name floorSelf
|
|
273
|
-
* @memberof
|
|
271
|
+
* @memberof Vector3d
|
|
274
272
|
* @function
|
|
275
|
-
* @returns {
|
|
273
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
276
274
|
*/
|
|
277
275
|
floorSelf() {
|
|
278
276
|
return this._set(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
|
|
@@ -281,9 +279,9 @@ class Vector3d {
|
|
|
281
279
|
/**
|
|
282
280
|
* Ceil the vector values
|
|
283
281
|
* @name ceil
|
|
284
|
-
* @memberof
|
|
282
|
+
* @memberof Vector3d
|
|
285
283
|
* @function
|
|
286
|
-
* @returns {
|
|
284
|
+
* @returns {Vector3d} new me.Vector3d
|
|
287
285
|
*/
|
|
288
286
|
ceil() {
|
|
289
287
|
return new Vector3d(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z));
|
|
@@ -292,9 +290,9 @@ class Vector3d {
|
|
|
292
290
|
/**
|
|
293
291
|
* Ceil this vector values
|
|
294
292
|
* @name ceilSelf
|
|
295
|
-
* @memberof
|
|
293
|
+
* @memberof Vector3d
|
|
296
294
|
* @function
|
|
297
|
-
* @returns {
|
|
295
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
298
296
|
*/
|
|
299
297
|
ceilSelf() {
|
|
300
298
|
return this._set(Math.ceil(this.x), Math.ceil(this.y), Math.ceil(this.z));
|
|
@@ -303,9 +301,9 @@ class Vector3d {
|
|
|
303
301
|
/**
|
|
304
302
|
* Negate the vector values
|
|
305
303
|
* @name negate
|
|
306
|
-
* @memberof
|
|
304
|
+
* @memberof Vector3d
|
|
307
305
|
* @function
|
|
308
|
-
* @returns {
|
|
306
|
+
* @returns {Vector3d} new me.Vector3d
|
|
309
307
|
*/
|
|
310
308
|
negate() {
|
|
311
309
|
return new Vector3d(-this.x, -this.y, -this.z);
|
|
@@ -314,9 +312,9 @@ class Vector3d {
|
|
|
314
312
|
/**
|
|
315
313
|
* Negate this vector values
|
|
316
314
|
* @name negateSelf
|
|
317
|
-
* @memberof
|
|
315
|
+
* @memberof Vector3d
|
|
318
316
|
* @function
|
|
319
|
-
* @returns {
|
|
317
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
320
318
|
*/
|
|
321
319
|
negateSelf() {
|
|
322
320
|
return this._set(-this.x, -this.y, -this.z);
|
|
@@ -325,10 +323,10 @@ class Vector3d {
|
|
|
325
323
|
/**
|
|
326
324
|
* Copy the components of the given vector into this one
|
|
327
325
|
* @name copy
|
|
328
|
-
* @memberof
|
|
326
|
+
* @memberof Vector3d
|
|
329
327
|
* @function
|
|
330
|
-
* @param {
|
|
331
|
-
* @returns {
|
|
328
|
+
* @param {Vector2d|Vector3d} v
|
|
329
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
332
330
|
*/
|
|
333
331
|
copy(v) {
|
|
334
332
|
return this._set(v.x, v.y, v.z || 0);
|
|
@@ -337,15 +335,15 @@ class Vector3d {
|
|
|
337
335
|
/**
|
|
338
336
|
* return true if the two vectors are the same
|
|
339
337
|
* @name equals
|
|
340
|
-
* @memberof
|
|
338
|
+
* @memberof Vector3d
|
|
341
339
|
* @function
|
|
342
|
-
* @param {
|
|
340
|
+
* @param {Vector2d|Vector3d} v
|
|
343
341
|
* @returns {boolean}
|
|
344
342
|
*/
|
|
345
343
|
/**
|
|
346
344
|
* return true if this vector is equal to the given values
|
|
347
345
|
* @name equals
|
|
348
|
-
* @memberof
|
|
346
|
+
* @memberof Vector3d
|
|
349
347
|
* @function
|
|
350
348
|
* @param {number} x
|
|
351
349
|
* @param {number} y
|
|
@@ -376,9 +374,9 @@ class Vector3d {
|
|
|
376
374
|
/**
|
|
377
375
|
* normalize this vector (scale the vector so that its magnitude is 1)
|
|
378
376
|
* @name normalize
|
|
379
|
-
* @memberof
|
|
377
|
+
* @memberof Vector3d
|
|
380
378
|
* @function
|
|
381
|
-
* @returns {
|
|
379
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
382
380
|
*/
|
|
383
381
|
normalize() {
|
|
384
382
|
return this.div(this.length() || 1);
|
|
@@ -388,9 +386,9 @@ class Vector3d {
|
|
|
388
386
|
* change this vector to be perpendicular to what it was before.<br>
|
|
389
387
|
* (Effectively rotates it 90 degrees in a clockwise direction around the z axis)
|
|
390
388
|
* @name perp
|
|
391
|
-
* @memberof
|
|
389
|
+
* @memberof Vector3d
|
|
392
390
|
* @function
|
|
393
|
-
* @returns {
|
|
391
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
394
392
|
*/
|
|
395
393
|
perp() {
|
|
396
394
|
return this._set(this.y, -this.x, this.z);
|
|
@@ -399,11 +397,11 @@ class Vector3d {
|
|
|
399
397
|
/**
|
|
400
398
|
* Rotate this vector (counter-clockwise) by the specified angle (in radians) around the z axis
|
|
401
399
|
* @name rotate
|
|
402
|
-
* @memberof
|
|
400
|
+
* @memberof Vector3d
|
|
403
401
|
* @function
|
|
404
402
|
* @param {number} angle The angle to rotate (in radians)
|
|
405
|
-
* @param {
|
|
406
|
-
* @returns {
|
|
403
|
+
* @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around (on the same z axis)
|
|
404
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
407
405
|
*/
|
|
408
406
|
rotate(angle, v) {
|
|
409
407
|
var cx = 0;
|
|
@@ -427,9 +425,9 @@ class Vector3d {
|
|
|
427
425
|
/**
|
|
428
426
|
* return the dot product of this vector and the passed one
|
|
429
427
|
* @name dot
|
|
430
|
-
* @memberof
|
|
428
|
+
* @memberof Vector3d
|
|
431
429
|
* @function
|
|
432
|
-
* @param {
|
|
430
|
+
* @param {Vector2d|Vector3d} v
|
|
433
431
|
* @returns {number} The dot product.
|
|
434
432
|
*/
|
|
435
433
|
dot(v) {
|
|
@@ -439,10 +437,10 @@ class Vector3d {
|
|
|
439
437
|
/**
|
|
440
438
|
* calculate the cross product of this vector and the passed one
|
|
441
439
|
* @name cross
|
|
442
|
-
* @memberof
|
|
440
|
+
* @memberof Vector3d
|
|
443
441
|
* @function
|
|
444
|
-
* @param {
|
|
445
|
-
* @returns {
|
|
442
|
+
* @param {Vector3d} v
|
|
443
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
446
444
|
*/
|
|
447
445
|
cross(v) {
|
|
448
446
|
var ax = this.x, ay = this.y, az = this.z;
|
|
@@ -458,7 +456,7 @@ class Vector3d {
|
|
|
458
456
|
/**
|
|
459
457
|
* return the square length of this vector
|
|
460
458
|
* @name length2
|
|
461
|
-
* @memberof
|
|
459
|
+
* @memberof Vector3d
|
|
462
460
|
* @function
|
|
463
461
|
* @returns {number} The length^2 of this vector.
|
|
464
462
|
*/
|
|
@@ -469,7 +467,7 @@ class Vector3d {
|
|
|
469
467
|
/**
|
|
470
468
|
* return the length (magnitude) of this vector
|
|
471
469
|
* @name length
|
|
472
|
-
* @memberof
|
|
470
|
+
* @memberof Vector3d
|
|
473
471
|
* @function
|
|
474
472
|
* @returns {number} the length of this vector
|
|
475
473
|
*/
|
|
@@ -480,11 +478,11 @@ class Vector3d {
|
|
|
480
478
|
/**
|
|
481
479
|
* Linearly interpolate between this vector and the given one.
|
|
482
480
|
* @name lerp
|
|
483
|
-
* @memberof
|
|
481
|
+
* @memberof Vector3d
|
|
484
482
|
* @function
|
|
485
|
-
* @param {
|
|
483
|
+
* @param {Vector3d} v
|
|
486
484
|
* @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
|
|
487
|
-
* @returns {
|
|
485
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
488
486
|
*/
|
|
489
487
|
lerp(v, alpha) {
|
|
490
488
|
this.x += ( v.x - this.x ) * alpha;
|
|
@@ -496,9 +494,9 @@ class Vector3d {
|
|
|
496
494
|
/**
|
|
497
495
|
* return the distance between this vector and the passed one
|
|
498
496
|
* @name distance
|
|
499
|
-
* @memberof
|
|
497
|
+
* @memberof Vector3d
|
|
500
498
|
* @function
|
|
501
|
-
* @param {
|
|
499
|
+
* @param {Vector2d|Vector3d} v
|
|
502
500
|
* @returns {number}
|
|
503
501
|
*/
|
|
504
502
|
distance(v) {
|
|
@@ -511,9 +509,9 @@ class Vector3d {
|
|
|
511
509
|
/**
|
|
512
510
|
* return the angle between this vector and the passed one
|
|
513
511
|
* @name angle
|
|
514
|
-
* @memberof
|
|
512
|
+
* @memberof Vector3d
|
|
515
513
|
* @function
|
|
516
|
-
* @param {
|
|
514
|
+
* @param {Vector2d|Vector3d} v
|
|
517
515
|
* @returns {number} angle in radians
|
|
518
516
|
*/
|
|
519
517
|
angle(v) {
|
|
@@ -523,10 +521,10 @@ class Vector3d {
|
|
|
523
521
|
/**
|
|
524
522
|
* project this vector on to another vector.
|
|
525
523
|
* @name project
|
|
526
|
-
* @memberof
|
|
524
|
+
* @memberof Vector3d
|
|
527
525
|
* @function
|
|
528
|
-
* @param {
|
|
529
|
-
* @returns {
|
|
526
|
+
* @param {Vector2d|Vector3d} v The vector to project onto.
|
|
527
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
530
528
|
*/
|
|
531
529
|
project(v) {
|
|
532
530
|
var ratio = this.dot(v) / v.length2();
|
|
@@ -537,10 +535,10 @@ class Vector3d {
|
|
|
537
535
|
* Project this vector onto a vector of unit length.<br>
|
|
538
536
|
* This is slightly more efficient than `project` when dealing with unit vectors.
|
|
539
537
|
* @name projectN
|
|
540
|
-
* @memberof
|
|
538
|
+
* @memberof Vector3d
|
|
541
539
|
* @function
|
|
542
|
-
* @param {
|
|
543
|
-
* @returns {
|
|
540
|
+
* @param {Vector2d|Vector3d} v The unit vector to project onto.
|
|
541
|
+
* @returns {Vector3d} Reference to this object for method chaining
|
|
544
542
|
*/
|
|
545
543
|
projectN(v) {
|
|
546
544
|
var ratio = this.dot(v) / v.length2();
|
|
@@ -550,9 +548,9 @@ class Vector3d {
|
|
|
550
548
|
/**
|
|
551
549
|
* return a clone copy of this vector
|
|
552
550
|
* @name clone
|
|
553
|
-
* @memberof
|
|
551
|
+
* @memberof Vector3d
|
|
554
552
|
* @function
|
|
555
|
-
* @returns {
|
|
553
|
+
* @returns {Vector3d} new me.Vector3d
|
|
556
554
|
*/
|
|
557
555
|
clone() {
|
|
558
556
|
return pool.pull("Vector3d", this.x, this.y, this.z);
|
|
@@ -561,7 +559,7 @@ class Vector3d {
|
|
|
561
559
|
/**
|
|
562
560
|
* convert the object to a string representation
|
|
563
561
|
* @name toString
|
|
564
|
-
* @memberof
|
|
562
|
+
* @memberof Vector3d
|
|
565
563
|
* @function
|
|
566
564
|
* @returns {string}
|
|
567
565
|
*/
|