melonjs 10.10.0 → 10.11.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 (91) hide show
  1. package/README.md +4 -3
  2. package/dist/melonjs.js +817 -1922
  3. package/dist/melonjs.min.js +4 -4
  4. package/dist/melonjs.module.d.ts +339 -1183
  5. package/dist/melonjs.module.js +745 -1846
  6. package/package.json +12 -15
  7. package/src/audio/audio.js +0 -1
  8. package/src/camera/camera2d.js +1 -16
  9. package/src/entity/entity.js +1 -4
  10. package/src/geometries/ellipse.js +2 -11
  11. package/src/geometries/line.js +1 -4
  12. package/src/geometries/path2d.js +0 -10
  13. package/src/geometries/poly.js +5 -22
  14. package/src/geometries/rectangle.js +2 -14
  15. package/src/geometries/roundrect.js +2 -6
  16. package/src/index.js +0 -1
  17. package/src/input/gamepad.js +3 -14
  18. package/src/input/keyboard.js +1 -9
  19. package/src/input/pointer.js +0 -1
  20. package/src/input/pointerevent.js +14 -23
  21. package/src/lang/deprecated.js +4 -3
  22. package/src/level/level.js +0 -9
  23. package/src/level/tiled/TMXGroup.js +0 -4
  24. package/src/level/tiled/TMXLayer.js +0 -8
  25. package/src/level/tiled/TMXObject.js +0 -3
  26. package/src/level/tiled/TMXTile.js +4 -5
  27. package/src/level/tiled/TMXTileMap.js +1 -7
  28. package/src/level/tiled/TMXTileset.js +0 -5
  29. package/src/level/tiled/TMXTilesetGroup.js +1 -4
  30. package/src/level/tiled/TMXUtils.js +0 -3
  31. package/src/level/tiled/renderer/TMXHexagonalRenderer.js +2 -3
  32. package/src/level/tiled/renderer/TMXIsometricRenderer.js +0 -1
  33. package/src/level/tiled/renderer/TMXRenderer.js +1 -7
  34. package/src/loader/loader.js +0 -11
  35. package/src/loader/loadingscreen.js +1 -1
  36. package/src/math/color.js +5 -26
  37. package/src/math/math.js +0 -10
  38. package/src/math/matrix2.js +12 -27
  39. package/src/math/matrix3.js +1 -22
  40. package/src/math/observable_vector2.js +0 -29
  41. package/src/math/observable_vector3.js +0 -29
  42. package/src/math/vector2.js +3 -40
  43. package/src/math/vector3.js +4 -41
  44. package/src/particles/emitter.js +1 -1
  45. package/src/physics/body.js +1 -1
  46. package/src/physics/bounds.js +5 -19
  47. package/src/physics/collision.js +0 -1
  48. package/src/physics/detector.js +0 -4
  49. package/src/physics/quadtree.js +0 -7
  50. package/src/physics/sat.js +3 -3
  51. package/src/physics/world.js +0 -4
  52. package/src/plugin/plugin.js +0 -2
  53. package/src/polyfill/roundrect.js +4 -2
  54. package/src/renderable/GUI.js +0 -5
  55. package/src/renderable/collectable.js +1 -0
  56. package/src/renderable/container.js +0 -28
  57. package/src/renderable/dragndrop.js +0 -9
  58. package/src/renderable/imagelayer.js +1 -5
  59. package/src/renderable/light2d.js +1 -2
  60. package/src/renderable/renderable.js +0 -22
  61. package/src/renderable/sprite.js +0 -12
  62. package/src/renderable/trigger.js +1 -1
  63. package/src/state/stage.js +0 -4
  64. package/src/state/state.js +3 -20
  65. package/src/system/device.js +14 -53
  66. package/src/system/event.js +11 -0
  67. package/src/system/pooling.js +19 -8
  68. package/src/system/save.js +9 -11
  69. package/src/system/timer.js +239 -218
  70. package/src/text/bitmaptextdata.js +1 -4
  71. package/src/text/glyph.js +2 -2
  72. package/src/text/text.js +7 -5
  73. package/src/text/textmetrics.js +0 -2
  74. package/src/tweens/easing.js +1 -1
  75. package/src/tweens/interpolation.js +2 -2
  76. package/src/tweens/tween.js +1 -13
  77. package/src/utils/agent.js +1 -3
  78. package/src/utils/array.js +0 -3
  79. package/src/utils/file.js +0 -2
  80. package/src/utils/function.js +0 -2
  81. package/src/utils/string.js +0 -6
  82. package/src/utils/utils.js +0 -3
  83. package/src/video/canvas/canvas_renderer.js +4 -39
  84. package/src/video/renderer.js +1 -23
  85. package/src/video/texture/cache.js +0 -1
  86. package/src/video/texture/canvas_texture.js +16 -4
  87. package/src/video/video.js +3 -3
  88. package/src/video/webgl/glshader.js +0 -5
  89. package/src/video/webgl/utils/uniforms.js +3 -6
  90. package/src/video/webgl/webgl_compositor.js +0 -14
  91. package/src/video/webgl/webgl_renderer.js +0 -42
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "melonjs",
3
- "version": "10.10.0",
3
+ "version": "10.11.0",
4
4
  "description": "melonJS Game Engine",
5
5
  "homepage": "http://www.melonjs.org/",
6
6
  "keywords": [
@@ -55,36 +55,32 @@
55
55
  ],
56
56
  "dependencies": {
57
57
  "@teppeis/multimaps": "^2.0.0",
58
- "core-js": "^3.22.8",
58
+ "core-js": "^3.23.0",
59
59
  "earcut": "2.2.3",
60
60
  "eventemitter3": "^4.0.7",
61
61
  "howler": "2.2.3"
62
62
  },
63
63
  "devDependencies": {
64
- "@melonjs/jsdoc-template": "^2.0.2",
64
+ "@melonjs/webdoc-theme": "^1.1.0",
65
65
  "@rollup/plugin-buble": "^0.21.3",
66
66
  "@rollup/plugin-commonjs": "^22.0.0",
67
67
  "@rollup/plugin-node-resolve": "^13.3.0",
68
68
  "@rollup/plugin-replace": "^4.0.0",
69
69
  "@types/offscreencanvas": "^2019.7.0",
70
- "@webdoc/cli": "^1.6.0",
71
- "cheerio": "^1.0.0-rc.11",
70
+ "@webdoc/cli": "^1.6.6",
72
71
  "del-cli": "^4.0.1",
73
72
  "eslint": "^8.17.0",
74
- "eslint-plugin-jsdoc": "^39.3.2",
75
- "jasmine-core": "^4.1.1",
76
- "jsdoc": "^3.6.10",
73
+ "jasmine-core": "^4.2.0",
77
74
  "karma": "^6.3.20",
78
75
  "karma-chrome-launcher": "^3.1.1",
79
76
  "karma-coverage": "^2.2.0",
80
77
  "karma-html-detailed-reporter": "^2.1.0",
81
78
  "karma-jasmine": "^5.0.1",
82
79
  "karma-nyan-reporter": "0.2.5",
83
- "qs": "^6.10.5",
84
- "rollup": "^2.75.5",
80
+ "rollup": "^2.75.6",
85
81
  "rollup-plugin-bundle-size": "^1.0.3",
86
82
  "rollup-plugin-string": "^3.0.0",
87
- "terser": "^5.14.0",
83
+ "terser": "^5.14.1",
88
84
  "typescript": "^4.7.3"
89
85
  },
90
86
  "scripts": {
@@ -92,10 +88,11 @@
92
88
  "dist": " npm run build && npm run minify && mkdirp dist && cp -f build/*.js dist/ && npm run types",
93
89
  "minify": "terser build/melonjs.js --compress --mangle --comments '/(?:^!|@(?:license|preserve|cc_on))/' --output build/melonjs.min.js",
94
90
  "lint": "eslint src rollup.config.js",
95
- "test": "npm run build && karma start tests/karma.conf.cjs",
96
- "doc": "mkdirp docs && jsdoc -c jsdoc_conf.json",
97
- "webdoc": "mkdirp dist && webdoc --quiet -R README.md",
98
- "release": "npm run dist && npm publish --access public",
91
+ "test": "npm run test-node && karma start tests/karma.conf.cjs",
92
+ "test-node": "node build/melonjs.module.js",
93
+ "doc": "mkdirp docs && webdoc --quiet --site-root docs -R README.md",
94
+ "serve": "python3 -m http.server",
95
+ "prepublishOnly": "npm run dist && npm run test",
99
96
  "clean": "del-cli --force build/*.js dist/*.js dist/*.d.ts docs src/**/*.d.ts",
100
97
  "types": "tsc dist/melonjs.module.js --declaration --allowJs --emitDeclarationOnly"
101
98
  }
@@ -517,7 +517,6 @@ export function unload(sound_name) {
517
517
  /**
518
518
  * unload all audio to free memory
519
519
  * @function audio.unloadAll
520
- * @function
521
520
  * @example
522
521
  * me.audio.unloadAll();
523
522
  */
@@ -14,7 +14,7 @@ import { world } from "./../game.js";
14
14
 
15
15
 
16
16
  // some ref shortcut
17
- var MIN = Math.min, MAX = Math.max;
17
+ const MIN = Math.min, MAX = Math.max;
18
18
 
19
19
  var targetV = new Vector2d();
20
20
 
@@ -207,7 +207,6 @@ class Camera2d extends Renderable {
207
207
  * reset the camera position to specified coordinates
208
208
  * @name reset
209
209
  * @memberof Camera2d
210
- * @function
211
210
  * @param {number} [x=0]
212
211
  * @param {number} [y=0]
213
212
  */
@@ -238,7 +237,6 @@ class Camera2d extends Renderable {
238
237
  * @name setDeadzone
239
238
  * @see Camera2d.follow
240
239
  * @memberof Camera2d
241
- * @function
242
240
  * @param {number} w deadzone width
243
241
  * @param {number} h deadzone height
244
242
  */
@@ -266,7 +264,6 @@ class Camera2d extends Renderable {
266
264
  * resize the camera
267
265
  * @name resize
268
266
  * @memberof Camera2d
269
- * @function
270
267
  * @param {number} w new width of the camera
271
268
  * @param {number} h new height of the camera
272
269
  * @returns {Camera2d} this camera
@@ -298,7 +295,6 @@ class Camera2d extends Renderable {
298
295
  * the camera is bound to the given coordinates and cannot move/be scrolled outside of it.
299
296
  * @name setBounds
300
297
  * @memberof Camera2d
301
- * @function
302
298
  * @param {number} x world left limit
303
299
  * @param {number} y world top limit
304
300
  * @param {number} w world width limit
@@ -317,7 +313,6 @@ class Camera2d extends Renderable {
317
313
  * (this will put the camera center around the given target)
318
314
  * @name follow
319
315
  * @memberof Camera2d
320
- * @function
321
316
  * @param {Renderable|Vector2d} target renderable or position vector to follow
322
317
  * @param {number} [axis=me.game.viewport.AXIS.BOTH] Which axis to follow (see {@link Camera2d.AXIS})
323
318
  * @param {number} [damping=1] default damping value
@@ -359,7 +354,6 @@ class Camera2d extends Renderable {
359
354
  * unfollow the current target
360
355
  * @name unfollow
361
356
  * @memberof Camera2d
362
- * @function
363
357
  */
364
358
  unfollow() {
365
359
  this.target = null;
@@ -371,7 +365,6 @@ class Camera2d extends Renderable {
371
365
  * @name move
372
366
  * @memberof Camera2d
373
367
  * @see Camera2d.focusOn
374
- * @function
375
368
  * @param {number} x
376
369
  * @param {number} y
377
370
  * @example
@@ -387,7 +380,6 @@ class Camera2d extends Renderable {
387
380
  * @name moveTo
388
381
  * @memberof Camera2d
389
382
  * @see Camera2d.focusOn
390
- * @function
391
383
  * @param {number} x
392
384
  * @param {number} y
393
385
  */
@@ -511,7 +503,6 @@ class Camera2d extends Renderable {
511
503
  * shake the camera
512
504
  * @name shake
513
505
  * @memberof Camera2d
514
- * @function
515
506
  * @param {number} intensity maximum offset that the screen can be moved
516
507
  * while shaking
517
508
  * @param {number} duration expressed in milliseconds
@@ -536,7 +527,6 @@ class Camera2d extends Renderable {
536
527
  * screen is filled with the specified color and slowly goes back to normal
537
528
  * @name fadeOut
538
529
  * @memberof Camera2d
539
- * @function
540
530
  * @param {Color|string} color a CSS color value
541
531
  * @param {number} [duration=1000] expressed in milliseconds
542
532
  * @param {Function} [onComplete] callback once effect is over
@@ -562,7 +552,6 @@ class Camera2d extends Renderable {
562
552
  * fade to the specified color
563
553
  * @name fadeIn
564
554
  * @memberof Camera2d
565
- * @function
566
555
  * @param {Color|string} color a CSS color value
567
556
  * @param {number} [duration=1000] expressed in milliseconds
568
557
  * @param {Function} [onComplete] callback once effect is over
@@ -585,7 +574,6 @@ class Camera2d extends Renderable {
585
574
  * set the camera position around the specified object
586
575
  * @name focusOn
587
576
  * @memberof Camera2d
588
- * @function
589
577
  * @param {Renderable} target the renderable to focus the camera on
590
578
  */
591
579
  focusOn(target) {
@@ -600,7 +588,6 @@ class Camera2d extends Renderable {
600
588
  * check if the specified renderable is in the camera
601
589
  * @name isVisible
602
590
  * @memberof Camera2d
603
- * @function
604
591
  * @param {Renderable} obj to be checked against
605
592
  * @param {boolean} [floating = obj.floating] if visibility check should be done against screen coordinates
606
593
  * @returns {boolean}
@@ -619,7 +606,6 @@ class Camera2d extends Renderable {
619
606
  * convert the given "local" (screen) coordinates into world coordinates
620
607
  * @name localToWorld
621
608
  * @memberof Camera2d
622
- * @function
623
609
  * @param {number} x
624
610
  * @param {number} y
625
611
  * @param {number} [v] an optional vector object where to set the
@@ -640,7 +626,6 @@ class Camera2d extends Renderable {
640
626
  * convert the given world coordinates into "local" (screen) coordinates
641
627
  * @name worldToLocal
642
628
  * @memberof Camera2d
643
- * @function
644
629
  * @param {number} x
645
630
  * @param {number} y
646
631
  * @param {number} [v] an optional vector object where to set the
@@ -95,7 +95,7 @@ class Entity extends Renderable {
95
95
  /**
96
96
  * the entity body object
97
97
  * @public
98
- * @type {Body}
98
+ * @member {Body}
99
99
  * @name body
100
100
  * @memberof Entity
101
101
  */
@@ -158,7 +158,6 @@ class Entity extends Renderable {
158
158
  * @ignore
159
159
  * @name onBodyUpdate
160
160
  * @memberof Entity
161
- * @function
162
161
  * @param {Body} body the body whose bounds to update
163
162
  */
164
163
  onBodyUpdate(body) {
@@ -194,7 +193,6 @@ class Entity extends Renderable {
194
193
  * called by the game manager on each game loop
195
194
  * @name draw
196
195
  * @memberof Entity
197
- * @function
198
196
  * @protected
199
197
  * @param {CanvasRenderer|WebGLRenderer} renderer a renderer object
200
198
  * @param {Rect} rect region to draw
@@ -233,7 +231,6 @@ class Entity extends Renderable {
233
231
  * Called by engine before deleting the object
234
232
  * @name onDeactivateEvent
235
233
  * @memberof Entity
236
- * @function
237
234
  */
238
235
  onDeactivateEvent() {
239
236
  if (this.renderable && this.renderable.onDeactivateEvent) {
@@ -77,7 +77,6 @@ class Ellipse {
77
77
  * set new value to the Ellipse shape
78
78
  * @name setShape
79
79
  * @memberof Ellipse
80
- * @function
81
80
  * @param {number} x the center x coordinate of the ellipse
82
81
  * @param {number} y the center y coordinate of the ellipse
83
82
  * @param {number} w width (diameter) of the ellipse
@@ -107,7 +106,6 @@ class Ellipse {
107
106
  * Rotate this Ellipse (counter-clockwise) by the specified angle (in radians).
108
107
  * @name rotate
109
108
  * @memberof Ellipse
110
- * @function
111
109
  * @param {number} angle The angle to rotate (in radians)
112
110
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
113
111
  * @returns {Ellipse} Reference to this object for method chaining
@@ -124,7 +122,6 @@ class Ellipse {
124
122
  * Scale this Ellipse by the specified scalar.
125
123
  * @name scale
126
124
  * @memberof Ellipse
127
- * @function
128
125
  * @param {number} x
129
126
  * @param {number} [y=x]
130
127
  * @returns {Ellipse} Reference to this object for method chaining
@@ -143,7 +140,6 @@ class Ellipse {
143
140
  * Scale this Ellipse by the specified vector.
144
141
  * @name scale
145
142
  * @memberof Ellipse
146
- * @function
147
143
  * @param {Vector2d} v
148
144
  * @returns {Ellipse} Reference to this object for method chaining
149
145
  */
@@ -155,7 +151,6 @@ class Ellipse {
155
151
  * apply the given transformation matrix to this ellipse
156
152
  * @name transform
157
153
  * @memberof Ellipse
158
- * @function
159
154
  * @param {Matrix2d} matrix the transformation matrix
160
155
  * @returns {Polygon} Reference to this object for method chaining
161
156
  */
@@ -168,7 +163,7 @@ class Ellipse {
168
163
  * translate the circle/ellipse by the specified offset
169
164
  * @name translate
170
165
  * @memberof Ellipse
171
- * @function
166
+ * @method
172
167
  * @param {number} x x offset
173
168
  * @param {number} y y offset
174
169
  * @returns {Ellipse} this ellipse
@@ -177,7 +172,6 @@ class Ellipse {
177
172
  * translate the circle/ellipse by the specified vector
178
173
  * @name translate
179
174
  * @memberof Ellipse
180
- * @function
181
175
  * @param {Vector2d} v vector offset
182
176
  * @returns {Ellipse} this ellipse
183
177
  */
@@ -204,8 +198,8 @@ class Ellipse {
204
198
  /**
205
199
  * check if this circle/ellipse contains the specified point
206
200
  * @name contains
201
+ * @method
207
202
  * @memberof Ellipse
208
- * @function
209
203
  * @param {Vector2d} point
210
204
  * @returns {boolean} true if contains
211
205
  */
@@ -214,7 +208,6 @@ class Ellipse {
214
208
  * check if this circle/ellipse contains the specified point
215
209
  * @name contains
216
210
  * @memberof Ellipse
217
- * @function
218
211
  * @param {number} x x coordinate
219
212
  * @param {number} y y coordinate
220
213
  * @returns {boolean} true if contains
@@ -246,7 +239,6 @@ class Ellipse {
246
239
  * returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
247
240
  * @name getBounds
248
241
  * @memberof Ellipse
249
- * @function
250
242
  * @returns {Bounds} this shape bounding box Rectangle object
251
243
  */
252
244
  getBounds() {
@@ -260,7 +252,6 @@ class Ellipse {
260
252
  * clone this Ellipse
261
253
  * @name clone
262
254
  * @memberof Ellipse
263
- * @function
264
255
  * @returns {Ellipse} new Ellipse
265
256
  */
266
257
  clone() {
@@ -16,7 +16,7 @@ class Line extends Polygon {
16
16
  * Returns true if the Line contains the given point
17
17
  * @name contains
18
18
  * @memberof Line
19
- * @function
19
+ * @method
20
20
  * @param {Vector2d} point
21
21
  * @returns {boolean} true if contains
22
22
  */
@@ -25,7 +25,6 @@ class Line extends Polygon {
25
25
  * Returns true if the Line contains the given point
26
26
  * @name contains
27
27
  * @memberof Line
28
- * @function
29
28
  * @param {number} x x coordinate
30
29
  * @param {number} y y coordinate
31
30
  * @returns {boolean} true if contains
@@ -59,7 +58,6 @@ class Line extends Polygon {
59
58
  * This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
60
59
  * @name recalc
61
60
  * @memberof Line
62
- * @function
63
61
  * @returns {Line} this instance for objecf chaining
64
62
  */
65
63
  recalc() {
@@ -95,7 +93,6 @@ class Line extends Polygon {
95
93
  * clone this line segment
96
94
  * @name clone
97
95
  * @memberof Line
98
- * @function
99
96
  * @returns {Line} new Line
100
97
  */
101
98
  clone() {
@@ -35,7 +35,6 @@ class Path2D {
35
35
  * begin a new path
36
36
  * @name beginPath
37
37
  * @memberof Path2D
38
- * @function
39
38
  */
40
39
  beginPath() {
41
40
  // empty the cache and recycle all vectors
@@ -51,7 +50,6 @@ class Path2D {
51
50
  * If the shape has already been closed or has only one point, this function does nothing.
52
51
  * @name closePath
53
52
  * @memberof Path2D
54
- * @function
55
53
  */
56
54
  closePath() {
57
55
  var points = this.points;
@@ -64,7 +62,6 @@ class Path2D {
64
62
  * triangulate the shape defined by this path into an array of triangles
65
63
  * @name triangulatePath
66
64
  * @memberof Path2D
67
- * @function
68
65
  * @returns {Vector2d[]}
69
66
  */
70
67
  triangulatePath() {
@@ -95,7 +92,6 @@ class Path2D {
95
92
  * moves the starting point of the current path to the (x, y) coordinates.
96
93
  * @name moveTo
97
94
  * @memberof Path2D
98
- * @function
99
95
  * @param {number} x the x-axis (horizontal) coordinate of the point.
100
96
  * @param {number} y the y-axis (vertical) coordinate of the point.
101
97
  */
@@ -107,7 +103,6 @@ class Path2D {
107
103
  * connects the last point in the current patch to the (x, y) coordinates with a straight line.
108
104
  * @name lineTo
109
105
  * @memberof Path2D
110
- * @function
111
106
  * @param {number} x the x-axis coordinate of the line's end point.
112
107
  * @param {number} y the y-axis coordinate of the line's end point.
113
108
  */
@@ -120,7 +115,6 @@ class Path2D {
120
115
  * starting at startAngle and ending at endAngle going in the given direction by counterclockwise (defaulting to clockwise).
121
116
  * @name arc
122
117
  * @memberof Path2D
123
- * @function
124
118
  * @param {number} x the horizontal coordinate of the arc's center.
125
119
  * @param {number} y the vertical coordinate of the arc's center.
126
120
  * @param {number} radius the arc's radius. Must be positive.
@@ -170,7 +164,6 @@ class Path2D {
170
164
  * adds a circular arc to the path with the given control points and radius, connected to the previous point by a straight line.
171
165
  * @name arcTo
172
166
  * @memberof Path2D
173
- * @function
174
167
  * @param {number} x the x-axis coordinate of the first control point.
175
168
  * @param {number} y the y-axis coordinate of the first control point.
176
169
  * @param {number} x the x-axis coordinate of the second control point.
@@ -219,7 +212,6 @@ class Path2D {
219
212
  * starting at startAngle and ending at endAngle going in the given direction by counterclockwise.
220
213
  * @name ellipse
221
214
  * @memberof Path2D
222
- * @function
223
215
  * @param {number} x the x-axis (horizontal) coordinate of the ellipse's center.
224
216
  * @param {number} y the y-axis (vertical) coordinate of the ellipse's center.
225
217
  * @param {number} radiusX the ellipse's major-axis radius. Must be non-negative.
@@ -279,7 +271,6 @@ class Path2D {
279
271
  * creates a path for a rectangle at position (x, y) with a size that is determined by width and height.
280
272
  * @name rect
281
273
  * @memberof Path2D
282
- * @function
283
274
  * @param {number} x the x-axis coordinate of the rectangle's starting point.
284
275
  * @param {number} y the y-axis coordinate of the rectangle's starting point.
285
276
  * @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
@@ -297,7 +288,6 @@ class Path2D {
297
288
  * adds an rounded rectangle to the current path.
298
289
  * @name roundRect
299
290
  * @memberof Path2D
300
- * @function
301
291
  * @param {number} x the x-axis coordinate of the rectangle's starting point.
302
292
  * @param {number} y the y-axis coordinate of the rectangle's starting point.
303
293
  * @param {number} width the rectangle's width. Positive values are to the right, and negative to the left.
@@ -9,9 +9,9 @@ import pool from "./../system/pooling.js";
9
9
  * A polygon is convex when all line segments connecting two points in the interior do not cross any edge of the polygon
10
10
  * (which means that all angles are less than 180 degrees), as described here below : <br>
11
11
  * <center><img src="images/convex_polygon.png"/></center><br>
12
+ *
12
13
  * A polygon's `winding` is clockwise iff its vertices (points) are declared turning to the right. The image above shows COUNTERCLOCKWISE winding.
13
14
  */
14
-
15
15
  class Polygon {
16
16
 
17
17
  /**
@@ -32,7 +32,7 @@ class Polygon {
32
32
  /**
33
33
  * The bounding rectangle for this shape
34
34
  * @ignore
35
- * @type {Bounds}
35
+ * @member {Bounds}
36
36
  * @name _bounds
37
37
  * @memberof Polygon
38
38
  */
@@ -84,7 +84,6 @@ class Polygon {
84
84
  * set new value to the Polygon
85
85
  * @name setShape
86
86
  * @memberof Polygon
87
- * @function
88
87
  * @param {number} x position of the Polygon
89
88
  * @param {number} y position of the Polygon
90
89
  * @param {Vector2d[]|number[]} points array of vector or vertice defining the Polygon
@@ -100,7 +99,6 @@ class Polygon {
100
99
  * set the vertices defining this Polygon
101
100
  * @name setVertices
102
101
  * @memberof Polygon
103
- * @function
104
102
  * @param {Vector2d[]} vertices array of vector or vertice defining the Polygon
105
103
  * @returns {Polygon} this instance for objecf chaining
106
104
  */
@@ -140,7 +138,6 @@ class Polygon {
140
138
  * apply the given transformation matrix to this Polygon
141
139
  * @name transform
142
140
  * @memberof Polygon
143
- * @function
144
141
  * @param {Matrix2d} m the transformation matrix
145
142
  * @returns {Polygon} Reference to this object for method chaining
146
143
  */
@@ -159,7 +156,6 @@ class Polygon {
159
156
  * apply an isometric projection to this shape
160
157
  * @name toIso
161
158
  * @memberof Polygon
162
- * @function
163
159
  * @returns {Polygon} Reference to this object for method chaining
164
160
  */
165
161
  toIso() {
@@ -170,7 +166,6 @@ class Polygon {
170
166
  * apply a 2d projection to this shape
171
167
  * @name to2d
172
168
  * @memberof Polygon
173
- * @function
174
169
  * @returns {Polygon} Reference to this object for method chaining
175
170
  */
176
171
  to2d() {
@@ -181,7 +176,6 @@ class Polygon {
181
176
  * Rotate this Polygon (counter-clockwise) by the specified angle (in radians).
182
177
  * @name rotate
183
178
  * @memberof Polygon
184
- * @function
185
179
  * @param {number} angle The angle to rotate (in radians)
186
180
  * @param {Vector2d|ObservableVector2d} [v] an optional point to rotate around
187
181
  * @returns {Polygon} Reference to this object for method chaining
@@ -203,7 +197,6 @@ class Polygon {
203
197
  * Scale this Polygon by the given scalar.
204
198
  * @name scale
205
199
  * @memberof Polygon
206
- * @function
207
200
  * @param {number} x
208
201
  * @param {number} [y=x]
209
202
  * @returns {Polygon} Reference to this object for method chaining
@@ -225,7 +218,6 @@ class Polygon {
225
218
  * Scale this Polygon by the given vector
226
219
  * @name scaleV
227
220
  * @memberof Polygon
228
- * @function
229
221
  * @param {Vector2d} v
230
222
  * @returns {Polygon} Reference to this object for method chaining
231
223
  */
@@ -238,7 +230,6 @@ class Polygon {
238
230
  * This **must** be called if the `points` array, `angle`, or `offset` is modified manually.
239
231
  * @name recalc
240
232
  * @memberof Polygon
241
- * @function
242
233
  * @returns {Polygon} Reference to this object for method chaining
243
234
  */
244
235
  recalc() {
@@ -282,7 +273,6 @@ class Polygon {
282
273
  * returns a list of indices for all triangles defined in this polygon
283
274
  * @name getIndices
284
275
  * @memberof Polygon
285
- * @function
286
276
  * @returns {Array} an array of vertex indices for all triangles forming this polygon.
287
277
  */
288
278
  getIndices() {
@@ -296,7 +286,6 @@ class Polygon {
296
286
  * Returns true if the vertices composing this polygon form a convex shape (vertices must be in clockwise order).
297
287
  * @name isConvex
298
288
  * @memberof Polygon
299
- * @function
300
289
  * @returns {boolean} true if the vertices are convex, false if not, null if not computable
301
290
  */
302
291
  isConvex() {
@@ -343,7 +332,7 @@ class Polygon {
343
332
  * translate the Polygon by the specified offset
344
333
  * @name translate
345
334
  * @memberof Polygon
346
- * @function
335
+ * @method
347
336
  * @param {number} x x offset
348
337
  * @param {number} y y offset
349
338
  * @returns {Polygon} this Polygon
@@ -352,7 +341,6 @@ class Polygon {
352
341
  * translate the Polygon by the specified vector
353
342
  * @name translate
354
343
  * @memberof Polygon
355
- * @function
356
344
  * @param {Vector2d} v vector offset
357
345
  * @returns {Polygon} Reference to this object for method chaining
358
346
  */
@@ -380,14 +368,13 @@ class Polygon {
380
368
  * Shifts the Polygon to the given position vector.
381
369
  * @name shift
382
370
  * @memberof Polygon
383
- * @function
371
+ * @method
384
372
  * @param {Vector2d} position
385
373
  */
386
374
  /**
387
375
  * Shifts the Polygon to the given x, y position.
388
376
  * @name shift
389
377
  * @memberof Polygon
390
- * @function
391
378
  * @param {number} x
392
379
  * @param {number} y
393
380
  */
@@ -413,7 +400,7 @@ class Polygon {
413
400
  * bounding rect, as the function can be highly consuming with complex shapes)
414
401
  * @name contains
415
402
  * @memberof Polygon
416
- * @function
403
+ * @method
417
404
  * @param {Vector2d} point
418
405
  * @returns {boolean} true if contains
419
406
  */
@@ -424,7 +411,6 @@ class Polygon {
424
411
  * bounding rect, as the function can be highly consuming with complex shapes)
425
412
  * @name contains
426
413
  * @memberof Polygon
427
- * @function
428
414
  * @param {number} x x coordinate
429
415
  * @param {number} y y coordinate
430
416
  * @returns {boolean} true if contains
@@ -462,7 +448,6 @@ class Polygon {
462
448
  * returns the bounding box for this shape, the smallest Rectangle object completely containing this shape.
463
449
  * @name getBounds
464
450
  * @memberof Polygon
465
- * @function
466
451
  * @returns {Bounds} this shape bounding box Rectangle object
467
452
  */
468
453
  getBounds() {
@@ -477,7 +462,6 @@ class Polygon {
477
462
  * @ignore
478
463
  * @name updateBounds
479
464
  * @memberof Polygon
480
- * @function
481
465
  * @returns {Bounds} this shape bounding box Rectangle object
482
466
  */
483
467
  updateBounds() {
@@ -493,7 +477,6 @@ class Polygon {
493
477
  * clone this Polygon
494
478
  * @name clone
495
479
  * @memberof Polygon
496
- * @function
497
480
  * @returns {Polygon} new Polygon
498
481
  */
499
482
  clone() {