melonjs 10.9.0 → 10.12.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.
Files changed (96) hide show
  1. package/LICENSE.md +1 -1
  2. package/README.md +32 -25
  3. package/dist/melonjs.js +1635 -2383
  4. package/dist/melonjs.min.js +4 -4
  5. package/dist/melonjs.module.d.ts +929 -1504
  6. package/dist/melonjs.module.js +1581 -2344
  7. package/package.json +18 -18
  8. package/src/audio/audio.js +0 -1
  9. package/src/camera/camera2d.js +1 -16
  10. package/src/entity/entity.js +6 -11
  11. package/src/game.js +2 -2
  12. package/src/geometries/ellipse.js +19 -28
  13. package/src/geometries/line.js +5 -8
  14. package/src/geometries/path2d.js +14 -24
  15. package/src/geometries/poly.js +29 -47
  16. package/src/geometries/rectangle.js +25 -37
  17. package/src/geometries/roundrect.js +8 -12
  18. package/src/index.js +7 -2
  19. package/src/input/gamepad.js +3 -14
  20. package/src/input/keyboard.js +1 -9
  21. package/src/input/pointer.js +0 -1
  22. package/src/input/pointerevent.js +14 -23
  23. package/src/lang/deprecated.js +9 -6
  24. package/src/level/level.js +0 -9
  25. package/src/level/tiled/TMXGroup.js +0 -4
  26. package/src/level/tiled/TMXLayer.js +0 -8
  27. package/src/level/tiled/TMXObject.js +0 -3
  28. package/src/level/tiled/TMXTile.js +4 -5
  29. package/src/level/tiled/TMXTileMap.js +1 -7
  30. package/src/level/tiled/TMXTileset.js +0 -5
  31. package/src/level/tiled/TMXTilesetGroup.js +1 -4
  32. package/src/level/tiled/TMXUtils.js +1 -4
  33. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
  34. package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -1
  35. package/src/level/tiled/renderer/TMXRenderer.js +1 -7
  36. package/src/loader/loader.js +0 -11
  37. package/src/loader/loadingscreen.js +16 -5
  38. package/src/math/color.js +10 -30
  39. package/src/math/math.js +0 -10
  40. package/src/math/matrix2.js +12 -27
  41. package/src/math/matrix3.js +1 -22
  42. package/src/math/observable_vector2.js +0 -29
  43. package/src/math/observable_vector3.js +0 -29
  44. package/src/math/vector2.js +3 -40
  45. package/src/math/vector3.js +4 -41
  46. package/src/particles/emitter.js +11 -12
  47. package/src/physics/body.js +4 -5
  48. package/src/physics/bounds.js +5 -19
  49. package/src/physics/collision.js +1 -13
  50. package/src/physics/detector.js +6 -56
  51. package/src/physics/quadtree.js +0 -7
  52. package/src/physics/response.js +48 -0
  53. package/src/physics/sat.js +4 -4
  54. package/src/physics/world.js +0 -4
  55. package/src/plugin/plugin.js +0 -2
  56. package/src/polyfill/roundrect.js +4 -2
  57. package/src/renderable/GUI.js +11 -14
  58. package/src/renderable/collectable.js +1 -0
  59. package/src/renderable/colorlayer.js +9 -7
  60. package/src/renderable/container.js +38 -64
  61. package/src/renderable/dragndrop.js +1 -10
  62. package/src/renderable/imagelayer.js +8 -12
  63. package/src/renderable/light2d.js +118 -0
  64. package/src/renderable/renderable.js +27 -48
  65. package/src/renderable/sprite.js +17 -29
  66. package/src/renderable/trigger.js +10 -3
  67. package/src/state/stage.js +72 -6
  68. package/src/state/state.js +22 -23
  69. package/src/system/device.js +14 -53
  70. package/src/system/event.js +11 -0
  71. package/src/system/pooling.js +20 -9
  72. package/src/system/save.js +9 -11
  73. package/src/system/timer.js +239 -218
  74. package/src/text/bitmaptextdata.js +1 -4
  75. package/src/text/glyph.js +2 -2
  76. package/src/text/text.js +25 -24
  77. package/src/text/textmetrics.js +0 -2
  78. package/src/tweens/easing.js +1 -1
  79. package/src/tweens/interpolation.js +2 -2
  80. package/src/tweens/tween.js +1 -13
  81. package/src/utils/agent.js +1 -3
  82. package/src/utils/array.js +0 -3
  83. package/src/utils/file.js +0 -2
  84. package/src/utils/function.js +0 -2
  85. package/src/utils/string.js +0 -6
  86. package/src/utils/utils.js +0 -3
  87. package/src/video/canvas/canvas_renderer.js +73 -90
  88. package/src/video/renderer.js +34 -49
  89. package/src/video/{texture.js → texture/atlas.js} +10 -8
  90. package/src/video/{texture_cache.js → texture/cache.js} +4 -5
  91. package/src/video/texture/canvas_texture.js +99 -0
  92. package/src/video/video.js +3 -3
  93. package/src/video/webgl/glshader.js +0 -5
  94. package/src/video/webgl/utils/uniforms.js +3 -6
  95. package/src/video/webgl/webgl_compositor.js +0 -14
  96. package/src/video/webgl/webgl_renderer.js +73 -97
@@ -37,7 +37,6 @@ class Vector2d {
37
37
  * set the Vector x and y properties to the given values<br>
38
38
  * @name set
39
39
  * @memberof Vector2d
40
- * @function
41
40
  * @param {number} x
42
41
  * @param {number} y
43
42
  * @returns {Vector2d} Reference to this object for method chaining
@@ -52,7 +51,7 @@ class Vector2d {
52
51
  /**
53
52
  * x value of the vector
54
53
  * @public
55
- * @type {number}
54
+ * @member {number}
56
55
  * @name x
57
56
  * @memberof Vector2d
58
57
  */
@@ -61,7 +60,7 @@ class Vector2d {
61
60
  /**
62
61
  * y value of the vector
63
62
  * @public
64
- * @type {number}
63
+ * @member {number}
65
64
  * @name y
66
65
  * @memberof Vector2d
67
66
  */
@@ -74,7 +73,6 @@ class Vector2d {
74
73
  * set the Vector x and y properties to 0
75
74
  * @name setZero
76
75
  * @memberof Vector2d
77
- * @function
78
76
  * @returns {Vector2d} Reference to this object for method chaining
79
77
  */
80
78
  setZero() {
@@ -85,7 +83,6 @@ class Vector2d {
85
83
  * set the Vector x and y properties using the passed vector
86
84
  * @name setV
87
85
  * @memberof Vector2d
88
- * @function
89
86
  * @param {Vector2d} v
90
87
  * @returns {Vector2d} Reference to this object for method chaining
91
88
  */
@@ -97,7 +94,6 @@ class Vector2d {
97
94
  * Add the passed vector to this vector
98
95
  * @name add
99
96
  * @memberof Vector2d
100
- * @function
101
97
  * @param {Vector2d} v
102
98
  * @returns {Vector2d} Reference to this object for method chaining
103
99
  */
@@ -109,7 +105,6 @@ class Vector2d {
109
105
  * Substract the passed vector to this vector
110
106
  * @name sub
111
107
  * @memberof Vector2d
112
- * @function
113
108
  * @param {Vector2d} v
114
109
  * @returns {Vector2d} Reference to this object for method chaining
115
110
  */
@@ -121,7 +116,6 @@ class Vector2d {
121
116
  * Multiply this vector values by the given scalar
122
117
  * @name scale
123
118
  * @memberof Vector2d
124
- * @function
125
119
  * @param {number} x
126
120
  * @param {number} [y=x]
127
121
  * @returns {Vector2d} Reference to this object for method chaining
@@ -134,7 +128,6 @@ class Vector2d {
134
128
  * Convert this vector into isometric coordinate space
135
129
  * @name toIso
136
130
  * @memberof Vector2d
137
- * @function
138
131
  * @returns {Vector2d} Reference to this object for method chaining
139
132
  */
140
133
  toIso() {
@@ -145,7 +138,6 @@ class Vector2d {
145
138
  * Convert this vector into 2d coordinate space
146
139
  * @name to2d
147
140
  * @memberof Vector2d
148
- * @function
149
141
  * @returns {Vector2d} Reference to this object for method chaining
150
142
  */
151
143
  to2d() {
@@ -156,7 +148,6 @@ class Vector2d {
156
148
  * Multiply this vector values by the passed vector
157
149
  * @name scaleV
158
150
  * @memberof Vector2d
159
- * @function
160
151
  * @param {Vector2d} v
161
152
  * @returns {Vector2d} Reference to this object for method chaining
162
153
  */
@@ -168,7 +159,6 @@ class Vector2d {
168
159
  * Divide this vector values by the passed value
169
160
  * @name div
170
161
  * @memberof Vector2d
171
- * @function
172
162
  * @param {number} n the value to divide the vector by
173
163
  * @returns {Vector2d} Reference to this object for method chaining
174
164
  */
@@ -180,7 +170,6 @@ class Vector2d {
180
170
  * Update this vector values to absolute values
181
171
  * @name abs
182
172
  * @memberof Vector2d
183
- * @function
184
173
  * @returns {Vector2d} Reference to this object for method chaining
185
174
  */
186
175
  abs() {
@@ -191,7 +180,6 @@ class Vector2d {
191
180
  * Clamp the vector value within the specified value range
192
181
  * @name clamp
193
182
  * @memberof Vector2d
194
- * @function
195
183
  * @param {number} low
196
184
  * @param {number} high
197
185
  * @returns {Vector2d} new me.Vector2d
@@ -204,7 +192,6 @@ class Vector2d {
204
192
  * Clamp this vector value within the specified value range
205
193
  * @name clampSelf
206
194
  * @memberof Vector2d
207
- * @function
208
195
  * @param {number} low
209
196
  * @param {number} high
210
197
  * @returns {Vector2d} Reference to this object for method chaining
@@ -217,7 +204,6 @@ class Vector2d {
217
204
  * Update this vector with the minimum value between this and the passed vector
218
205
  * @name minV
219
206
  * @memberof Vector2d
220
- * @function
221
207
  * @param {Vector2d} v
222
208
  * @returns {Vector2d} Reference to this object for method chaining
223
209
  */
@@ -229,7 +215,6 @@ class Vector2d {
229
215
  * Update this vector with the maximum value between this and the passed vector
230
216
  * @name maxV
231
217
  * @memberof Vector2d
232
- * @function
233
218
  * @param {Vector2d} v
234
219
  * @returns {Vector2d} Reference to this object for method chaining
235
220
  */
@@ -241,7 +226,6 @@ class Vector2d {
241
226
  * Floor the vector values
242
227
  * @name floor
243
228
  * @memberof Vector2d
244
- * @function
245
229
  * @returns {Vector2d} new me.Vector2d
246
230
  */
247
231
  floor() {
@@ -252,7 +236,6 @@ class Vector2d {
252
236
  * Floor this vector values
253
237
  * @name floorSelf
254
238
  * @memberof Vector2d
255
- * @function
256
239
  * @returns {Vector2d} Reference to this object for method chaining
257
240
  */
258
241
  floorSelf() {
@@ -263,7 +246,6 @@ class Vector2d {
263
246
  * Ceil the vector values
264
247
  * @name ceil
265
248
  * @memberof Vector2d
266
- * @function
267
249
  * @returns {Vector2d} new me.Vector2d
268
250
  */
269
251
  ceil() {
@@ -274,7 +256,6 @@ class Vector2d {
274
256
  * Ceil this vector values
275
257
  * @name ceilSelf
276
258
  * @memberof Vector2d
277
- * @function
278
259
  * @returns {Vector2d} Reference to this object for method chaining
279
260
  */
280
261
  ceilSelf() {
@@ -285,7 +266,6 @@ class Vector2d {
285
266
  * Negate the vector values
286
267
  * @name negate
287
268
  * @memberof Vector2d
288
- * @function
289
269
  * @returns {Vector2d} new me.Vector2d
290
270
  */
291
271
  negate() {
@@ -296,7 +276,6 @@ class Vector2d {
296
276
  * Negate this vector values
297
277
  * @name negateSelf
298
278
  * @memberof Vector2d
299
- * @function
300
279
  * @returns {Vector2d} Reference to this object for method chaining
301
280
  */
302
281
  negateSelf() {
@@ -307,7 +286,6 @@ class Vector2d {
307
286
  * Copy the x,y values of the passed vector to this one
308
287
  * @name copy
309
288
  * @memberof Vector2d
310
- * @function
311
289
  * @param {Vector2d} v
312
290
  * @returns {Vector2d} Reference to this object for method chaining
313
291
  */
@@ -319,7 +297,7 @@ class Vector2d {
319
297
  * return true if the two vectors are the same
320
298
  * @name equals
321
299
  * @memberof Vector2d
322
- * @function
300
+ * @method
323
301
  * @param {Vector2d} v
324
302
  * @returns {boolean}
325
303
  */
@@ -327,7 +305,6 @@ class Vector2d {
327
305
  * return true if this vector is equal to the given values
328
306
  * @name equals
329
307
  * @memberof Vector2d
330
- * @function
331
308
  * @param {number} x
332
309
  * @param {number} y
333
310
  * @returns {boolean}
@@ -350,7 +327,6 @@ class Vector2d {
350
327
  * normalize this vector (scale the vector so that its magnitude is 1)
351
328
  * @name normalize
352
329
  * @memberof Vector2d
353
- * @function
354
330
  * @returns {Vector2d} Reference to this object for method chaining
355
331
  */
356
332
  normalize() {
@@ -362,7 +338,6 @@ class Vector2d {
362
338
  * (Effectively rotates it 90 degrees in a clockwise direction)
363
339
  * @name perp
364
340
  * @memberof Vector2d
365
- * @function
366
341
  * @returns {Vector2d} Reference to this object for method chaining
367
342
  */
368
343
  perp() {
@@ -373,7 +348,6 @@ class Vector2d {
373
348
  * Rotate this vector (counter-clockwise) by the specified angle (in radians).
374
349
  * @name rotate
375
350
  * @memberof Vector2d
376
- * @function
377
351
  * @param {number} angle The angle to rotate (in radians)
378
352
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
379
353
  * @returns {Vector2d} Reference to this object for method chaining
@@ -400,7 +374,6 @@ class Vector2d {
400
374
  * return the dot product of this vector and the passed one
401
375
  * @name dot
402
376
  * @memberof Vector2d
403
- * @function
404
377
  * @param {Vector2d} v
405
378
  * @returns {number} The dot product.
406
379
  */
@@ -412,7 +385,6 @@ class Vector2d {
412
385
  * return the cross product of this vector and the passed one
413
386
  * @name cross
414
387
  * @memberof Vector2d
415
- * @function
416
388
  * @param {Vector2d} v
417
389
  * @returns {number} The cross product.
418
390
  */
@@ -424,7 +396,6 @@ class Vector2d {
424
396
  * return the square length of this vector
425
397
  * @name length2
426
398
  * @memberof Vector2d
427
- * @function
428
399
  * @returns {number} The length^2 of this vector.
429
400
  */
430
401
  length2() {
@@ -435,7 +406,6 @@ class Vector2d {
435
406
  * return the length (magnitude) of this vector
436
407
  * @name length
437
408
  * @memberof Vector2d
438
- * @function
439
409
  * @returns {number} the length of this vector
440
410
  */
441
411
  length() {
@@ -446,7 +416,6 @@ class Vector2d {
446
416
  * Linearly interpolate between this vector and the given one.
447
417
  * @name lerp
448
418
  * @memberof Vector2d
449
- * @function
450
419
  * @param {Vector2d} v
451
420
  * @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
452
421
  * @returns {Vector2d} Reference to this object for method chaining
@@ -461,7 +430,6 @@ class Vector2d {
461
430
  * return the distance between this vector and the passed one
462
431
  * @name distance
463
432
  * @memberof Vector2d
464
- * @function
465
433
  * @param {Vector2d} v
466
434
  * @returns {number}
467
435
  */
@@ -474,7 +442,6 @@ class Vector2d {
474
442
  * return the angle between this vector and the passed one
475
443
  * @name angle
476
444
  * @memberof Vector2d
477
- * @function
478
445
  * @param {Vector2d} v
479
446
  * @returns {number} angle in radians
480
447
  */
@@ -486,7 +453,6 @@ class Vector2d {
486
453
  * project this vector on to another vector.
487
454
  * @name project
488
455
  * @memberof Vector2d
489
- * @function
490
456
  * @param {Vector2d} v The vector to project onto.
491
457
  * @returns {Vector2d} Reference to this object for method chaining
492
458
  */
@@ -499,7 +465,6 @@ class Vector2d {
499
465
  * This is slightly more efficient than `project` when dealing with unit vectors.
500
466
  * @name projectN
501
467
  * @memberof Vector2d
502
- * @function
503
468
  * @param {Vector2d} v The unit vector to project onto.
504
469
  * @returns {Vector2d} Reference to this object for method chaining
505
470
  */
@@ -511,7 +476,6 @@ class Vector2d {
511
476
  * return a clone copy of this vector
512
477
  * @name clone
513
478
  * @memberof Vector2d
514
- * @function
515
479
  * @returns {Vector2d} new me.Vector2d
516
480
  */
517
481
  clone() {
@@ -522,7 +486,6 @@ class Vector2d {
522
486
  * convert the object to a string representation
523
487
  * @name toString
524
488
  * @memberof Vector2d
525
- * @function
526
489
  * @returns {string}
527
490
  */
528
491
  toString() {
@@ -40,7 +40,6 @@ class Vector3d {
40
40
  * set the Vector x and y properties to the given values<br>
41
41
  * @name set
42
42
  * @memberof Vector3d
43
- * @function
44
43
  * @param {number} x
45
44
  * @param {number} y
46
45
  * @param {number} [z=0]
@@ -56,7 +55,7 @@ class Vector3d {
56
55
  /**
57
56
  * x value of the vector
58
57
  * @public
59
- * @type {number}
58
+ * @member {number}
60
59
  * @name x
61
60
  * @memberof Vector3d
62
61
  */
@@ -65,7 +64,7 @@ class Vector3d {
65
64
  /**
66
65
  * y value of the vector
67
66
  * @public
68
- * @type {number}
67
+ * @member {number}
69
68
  * @name y
70
69
  * @memberof Vector3d
71
70
  */
@@ -74,7 +73,7 @@ class Vector3d {
74
73
  /**
75
74
  * z value of the vector
76
75
  * @public
77
- * @type {number}
76
+ * @member {number}
78
77
  * @name z
79
78
  * @memberof Vector3d
80
79
  */
@@ -87,7 +86,6 @@ class Vector3d {
87
86
  * set the Vector x and y properties to 0
88
87
  * @name setZero
89
88
  * @memberof Vector3d
90
- * @function
91
89
  * @returns {Vector3d} Reference to this object for method chaining
92
90
  */
93
91
  setZero() {
@@ -98,7 +96,6 @@ class Vector3d {
98
96
  * set the Vector x and y properties using the passed vector
99
97
  * @name setV
100
98
  * @memberof Vector3d
101
- * @function
102
99
  * @param {Vector2d|Vector3d} v
103
100
  * @returns {Vector3d} Reference to this object for method chaining
104
101
  */
@@ -110,7 +107,6 @@ class Vector3d {
110
107
  * Add the passed vector to this vector
111
108
  * @name add
112
109
  * @memberof Vector3d
113
- * @function
114
110
  * @param {Vector2d|Vector3d} v
115
111
  * @returns {Vector3d} Reference to this object for method chaining
116
112
  */
@@ -122,7 +118,6 @@ class Vector3d {
122
118
  * Substract the passed vector to this vector
123
119
  * @name sub
124
120
  * @memberof Vector3d
125
- * @function
126
121
  * @param {Vector2d|Vector3d} v
127
122
  * @returns {Vector3d} Reference to this object for method chaining
128
123
  */
@@ -134,7 +129,6 @@ class Vector3d {
134
129
  * Multiply this vector values by the given scalar
135
130
  * @name scale
136
131
  * @memberof Vector3d
137
- * @function
138
132
  * @param {number} x
139
133
  * @param {number} [y=x]
140
134
  * @param {number} [z=1]
@@ -149,7 +143,6 @@ class Vector3d {
149
143
  * Multiply this vector values by the passed vector
150
144
  * @name scaleV
151
145
  * @memberof Vector3d
152
- * @function
153
146
  * @param {Vector2d|Vector3d} v
154
147
  * @returns {Vector3d} Reference to this object for method chaining
155
148
  */
@@ -161,7 +154,6 @@ class Vector3d {
161
154
  * Convert this vector into isometric coordinate space
162
155
  * @name toIso
163
156
  * @memberof Vector3d
164
- * @function
165
157
  * @returns {Vector3d} Reference to this object for method chaining
166
158
  */
167
159
  toIso() {
@@ -172,7 +164,6 @@ class Vector3d {
172
164
  * Convert this vector into 2d coordinate space
173
165
  * @name to2d
174
166
  * @memberof Vector3d
175
- * @function
176
167
  * @returns {Vector3d} Reference to this object for method chaining
177
168
  */
178
169
  to2d() {
@@ -183,7 +174,6 @@ class Vector3d {
183
174
  * Divide this vector values by the passed value
184
175
  * @name div
185
176
  * @memberof Vector3d
186
- * @function
187
177
  * @param {number} n the value to divide the vector by
188
178
  * @returns {Vector3d} Reference to this object for method chaining
189
179
  */
@@ -195,7 +185,6 @@ class Vector3d {
195
185
  * Update this vector values to absolute values
196
186
  * @name abs
197
187
  * @memberof Vector3d
198
- * @function
199
188
  * @returns {Vector3d} Reference to this object for method chaining
200
189
  */
201
190
  abs() {
@@ -206,7 +195,6 @@ class Vector3d {
206
195
  * Clamp the vector value within the specified value range
207
196
  * @name clamp
208
197
  * @memberof Vector3d
209
- * @function
210
198
  * @param {number} low
211
199
  * @param {number} high
212
200
  * @returns {Vector3d} new me.Vector3d
@@ -219,7 +207,6 @@ class Vector3d {
219
207
  * Clamp this vector value within the specified value range
220
208
  * @name clampSelf
221
209
  * @memberof Vector3d
222
- * @function
223
210
  * @param {number} low
224
211
  * @param {number} high
225
212
  * @returns {Vector3d} Reference to this object for method chaining
@@ -232,7 +219,6 @@ class Vector3d {
232
219
  * Update this vector with the minimum value between this and the passed vector
233
220
  * @name minV
234
221
  * @memberof Vector3d
235
- * @function
236
222
  * @param {Vector2d|Vector3d} v
237
223
  * @returns {Vector3d} Reference to this object for method chaining
238
224
  */
@@ -245,7 +231,6 @@ class Vector3d {
245
231
  * Update this vector with the maximum value between this and the passed vector
246
232
  * @name maxV
247
233
  * @memberof Vector3d
248
- * @function
249
234
  * @param {Vector2d|Vector3d} v
250
235
  * @returns {Vector3d} Reference to this object for method chaining
251
236
  */
@@ -258,7 +243,6 @@ class Vector3d {
258
243
  * Floor the vector values
259
244
  * @name floor
260
245
  * @memberof Vector3d
261
- * @function
262
246
  * @returns {Vector3d} new me.Vector3d
263
247
  */
264
248
  floor() {
@@ -269,7 +253,6 @@ class Vector3d {
269
253
  * Floor this vector values
270
254
  * @name floorSelf
271
255
  * @memberof Vector3d
272
- * @function
273
256
  * @returns {Vector3d} Reference to this object for method chaining
274
257
  */
275
258
  floorSelf() {
@@ -280,7 +263,6 @@ class Vector3d {
280
263
  * Ceil the vector values
281
264
  * @name ceil
282
265
  * @memberof Vector3d
283
- * @function
284
266
  * @returns {Vector3d} new me.Vector3d
285
267
  */
286
268
  ceil() {
@@ -291,7 +273,6 @@ class Vector3d {
291
273
  * Ceil this vector values
292
274
  * @name ceilSelf
293
275
  * @memberof Vector3d
294
- * @function
295
276
  * @returns {Vector3d} Reference to this object for method chaining
296
277
  */
297
278
  ceilSelf() {
@@ -302,7 +283,6 @@ class Vector3d {
302
283
  * Negate the vector values
303
284
  * @name negate
304
285
  * @memberof Vector3d
305
- * @function
306
286
  * @returns {Vector3d} new me.Vector3d
307
287
  */
308
288
  negate() {
@@ -313,7 +293,6 @@ class Vector3d {
313
293
  * Negate this vector values
314
294
  * @name negateSelf
315
295
  * @memberof Vector3d
316
- * @function
317
296
  * @returns {Vector3d} Reference to this object for method chaining
318
297
  */
319
298
  negateSelf() {
@@ -324,7 +303,6 @@ class Vector3d {
324
303
  * Copy the components of the given vector into this one
325
304
  * @name copy
326
305
  * @memberof Vector3d
327
- * @function
328
306
  * @param {Vector2d|Vector3d} v
329
307
  * @returns {Vector3d} Reference to this object for method chaining
330
308
  */
@@ -336,7 +314,7 @@ class Vector3d {
336
314
  * return true if the two vectors are the same
337
315
  * @name equals
338
316
  * @memberof Vector3d
339
- * @function
317
+ * @method
340
318
  * @param {Vector2d|Vector3d} v
341
319
  * @returns {boolean}
342
320
  */
@@ -344,7 +322,6 @@ class Vector3d {
344
322
  * return true if this vector is equal to the given values
345
323
  * @name equals
346
324
  * @memberof Vector3d
347
- * @function
348
325
  * @param {number} x
349
326
  * @param {number} y
350
327
  * @param {number} [z]
@@ -375,7 +352,6 @@ class Vector3d {
375
352
  * normalize this vector (scale the vector so that its magnitude is 1)
376
353
  * @name normalize
377
354
  * @memberof Vector3d
378
- * @function
379
355
  * @returns {Vector3d} Reference to this object for method chaining
380
356
  */
381
357
  normalize() {
@@ -387,7 +363,6 @@ class Vector3d {
387
363
  * (Effectively rotates it 90 degrees in a clockwise direction around the z axis)
388
364
  * @name perp
389
365
  * @memberof Vector3d
390
- * @function
391
366
  * @returns {Vector3d} Reference to this object for method chaining
392
367
  */
393
368
  perp() {
@@ -398,7 +373,6 @@ class Vector3d {
398
373
  * Rotate this vector (counter-clockwise) by the specified angle (in radians) around the z axis
399
374
  * @name rotate
400
375
  * @memberof Vector3d
401
- * @function
402
376
  * @param {number} angle The angle to rotate (in radians)
403
377
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around (on the same z axis)
404
378
  * @returns {Vector3d} Reference to this object for method chaining
@@ -426,7 +400,6 @@ class Vector3d {
426
400
  * return the dot product of this vector and the passed one
427
401
  * @name dot
428
402
  * @memberof Vector3d
429
- * @function
430
403
  * @param {Vector2d|Vector3d} v
431
404
  * @returns {number} The dot product.
432
405
  */
@@ -438,7 +411,6 @@ class Vector3d {
438
411
  * calculate the cross product of this vector and the passed one
439
412
  * @name cross
440
413
  * @memberof Vector3d
441
- * @function
442
414
  * @param {Vector3d} v
443
415
  * @returns {Vector3d} Reference to this object for method chaining
444
416
  */
@@ -457,7 +429,6 @@ class Vector3d {
457
429
  * return the square length of this vector
458
430
  * @name length2
459
431
  * @memberof Vector3d
460
- * @function
461
432
  * @returns {number} The length^2 of this vector.
462
433
  */
463
434
  length2() {
@@ -468,7 +439,6 @@ class Vector3d {
468
439
  * return the length (magnitude) of this vector
469
440
  * @name length
470
441
  * @memberof Vector3d
471
- * @function
472
442
  * @returns {number} the length of this vector
473
443
  */
474
444
  length() {
@@ -479,7 +449,6 @@ class Vector3d {
479
449
  * Linearly interpolate between this vector and the given one.
480
450
  * @name lerp
481
451
  * @memberof Vector3d
482
- * @function
483
452
  * @param {Vector3d} v
484
453
  * @param {number} alpha distance along the line (alpha = 0 will be this vector, and alpha = 1 will be the given one).
485
454
  * @returns {Vector3d} Reference to this object for method chaining
@@ -495,7 +464,6 @@ class Vector3d {
495
464
  * return the distance between this vector and the passed one
496
465
  * @name distance
497
466
  * @memberof Vector3d
498
- * @function
499
467
  * @param {Vector2d|Vector3d} v
500
468
  * @returns {number}
501
469
  */
@@ -510,7 +478,6 @@ class Vector3d {
510
478
  * return the angle between this vector and the passed one
511
479
  * @name angle
512
480
  * @memberof Vector3d
513
- * @function
514
481
  * @param {Vector2d|Vector3d} v
515
482
  * @returns {number} angle in radians
516
483
  */
@@ -522,7 +489,6 @@ class Vector3d {
522
489
  * project this vector on to another vector.
523
490
  * @name project
524
491
  * @memberof Vector3d
525
- * @function
526
492
  * @param {Vector2d|Vector3d} v The vector to project onto.
527
493
  * @returns {Vector3d} Reference to this object for method chaining
528
494
  */
@@ -536,7 +502,6 @@ class Vector3d {
536
502
  * This is slightly more efficient than `project` when dealing with unit vectors.
537
503
  * @name projectN
538
504
  * @memberof Vector3d
539
- * @function
540
505
  * @param {Vector2d|Vector3d} v The unit vector to project onto.
541
506
  * @returns {Vector3d} Reference to this object for method chaining
542
507
  */
@@ -549,7 +514,6 @@ class Vector3d {
549
514
  * return a clone copy of this vector
550
515
  * @name clone
551
516
  * @memberof Vector3d
552
- * @function
553
517
  * @returns {Vector3d} new me.Vector3d
554
518
  */
555
519
  clone() {
@@ -560,7 +524,6 @@ class Vector3d {
560
524
  * convert the object to a string representation
561
525
  * @name toString
562
526
  * @memberof Vector3d
563
- * @function
564
527
  * @returns {string}
565
528
  */
566
529
  toString() {
@@ -1,23 +1,18 @@
1
- import { createCanvas } from "./../video/video.js";
2
1
  import pool from "./../system/pooling.js";
3
2
  import ParticleEmitterSettings from "./settings.js";
4
3
  import { randomFloat } from "./../math/math.js";
5
4
  import Container from "./../renderable/container.js";
6
5
 
7
6
 
8
- // default texture used when no sprite is defined
9
- let defaultParticleTexture;
10
-
11
7
  /**
12
8
  * @ignore
13
9
  */
14
10
  function createDefaultParticleTexture(w = 8, h = 8) {
15
- if (typeof defaultParticleTexture === "undefined") {
16
- defaultParticleTexture = createCanvas(w, h, true);
17
- var context = defaultParticleTexture.getContext("2d");
18
- context.fillStyle = "#fff";
19
- context.fillRect(0, 0, w, h);
20
- }
11
+ var defaultParticleTexture = pool.pull("CanvasTexture", w, h, { offscreenCanvas: true });
12
+
13
+ defaultParticleTexture.context.fillStyle = "#fff";
14
+ defaultParticleTexture.context.fillRect(0, 0, w, h);
15
+
21
16
  return defaultParticleTexture;
22
17
  };
23
18
 
@@ -120,9 +115,9 @@ class ParticleEmitter extends Container {
120
115
  reset(settings = {}) {
121
116
  Object.assign(this.settings, ParticleEmitterSettings, settings);
122
117
 
123
- // Cache the image reference
124
118
  if (typeof this.settings.image === "undefined") {
125
- this.settings.image = createDefaultParticleTexture(settings.textureSize, settings.textureSize);
119
+ this._defaultParticle = createDefaultParticleTexture(settings.textureSize, settings.textureSize);
120
+ this.settings.image = this._defaultParticle.canvas;
126
121
  }
127
122
 
128
123
  this.floating = this.settings.floating;
@@ -252,6 +247,10 @@ class ParticleEmitter extends Container {
252
247
  // call the parent destroy method
253
248
  super.destroy(arguments);
254
249
  // clean emitter specific Properties
250
+ if (typeof this._defaultParticle !== "undefined") {
251
+ pool.push(this._defaultParticle);
252
+ this._defaultParticle = undefined;
253
+ }
255
254
  this.settings.image = undefined;
256
255
  this.settings = undefined;
257
256
  }