melonjs 14.4.0 → 14.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (207) hide show
  1. package/README.md +11 -55
  2. package/dist/melonjs.mjs/_virtual/_commonjsHelpers.js +1 -1
  3. package/dist/melonjs.mjs/_virtual/arraymultimap.js +1 -1
  4. package/dist/melonjs.mjs/_virtual/earcut.js +1 -1
  5. package/dist/melonjs.mjs/_virtual/howler.js +1 -1
  6. package/dist/melonjs.mjs/_virtual/index.js +1 -1
  7. package/dist/melonjs.mjs/_virtual/index2.js +1 -1
  8. package/dist/melonjs.mjs/_virtual/multimap.js +1 -1
  9. package/dist/melonjs.mjs/_virtual/setmultimap.js +1 -1
  10. package/dist/melonjs.mjs/application/application.js +1 -1
  11. package/dist/melonjs.mjs/application/header.js +1 -1
  12. package/dist/melonjs.mjs/application/resize.js +1 -1
  13. package/dist/melonjs.mjs/application/settings.js +1 -1
  14. package/dist/melonjs.mjs/audio/audio.js +4 -4
  15. package/dist/melonjs.mjs/camera/camera2d.js +1 -1
  16. package/dist/melonjs.mjs/const.js +1 -1
  17. package/dist/melonjs.mjs/entity/entity.js +43 -9
  18. package/dist/melonjs.mjs/geometries/ellipse.js +2 -3
  19. package/dist/melonjs.mjs/geometries/line.js +1 -1
  20. package/dist/melonjs.mjs/geometries/path2d.js +18 -42
  21. package/dist/melonjs.mjs/geometries/point.js +1 -6
  22. package/dist/melonjs.mjs/geometries/poly.js +2 -5
  23. package/dist/melonjs.mjs/geometries/rectangle.js +13 -9
  24. package/dist/melonjs.mjs/geometries/roundrect.js +1 -1
  25. package/dist/melonjs.mjs/index.js +8 -6
  26. package/dist/melonjs.mjs/input/gamepad.js +10 -16
  27. package/dist/melonjs.mjs/input/input.js +1 -1
  28. package/dist/melonjs.mjs/input/keyboard.js +1 -1
  29. package/dist/melonjs.mjs/input/pointer.js +1 -1
  30. package/dist/melonjs.mjs/input/pointerevent.js +2 -16
  31. package/dist/melonjs.mjs/lang/console.js +1 -1
  32. package/dist/melonjs.mjs/lang/deprecated.js +1 -1
  33. package/dist/melonjs.mjs/level/level.js +3 -3
  34. package/dist/melonjs.mjs/level/tiled/TMXGroup.js +1 -1
  35. package/dist/melonjs.mjs/level/tiled/TMXLayer.js +1 -8
  36. package/dist/melonjs.mjs/level/tiled/TMXObject.js +1 -1
  37. package/dist/melonjs.mjs/level/tiled/TMXTile.js +1 -1
  38. package/dist/melonjs.mjs/level/tiled/TMXTileMap.js +8 -4
  39. package/dist/melonjs.mjs/level/tiled/TMXTileset.js +5 -5
  40. package/dist/melonjs.mjs/level/tiled/TMXTilesetGroup.js +1 -1
  41. package/dist/melonjs.mjs/level/tiled/TMXUtils.js +1 -1
  42. package/dist/melonjs.mjs/level/tiled/constants.js +1 -1
  43. package/dist/melonjs.mjs/level/tiled/renderer/TMXHexagonalRenderer.js +1 -1
  44. package/dist/melonjs.mjs/level/tiled/renderer/TMXIsometricRenderer.js +1 -1
  45. package/dist/melonjs.mjs/level/tiled/renderer/TMXOrthogonalRenderer.js +1 -1
  46. package/dist/melonjs.mjs/level/tiled/renderer/TMXRenderer.js +1 -1
  47. package/dist/melonjs.mjs/level/tiled/renderer/TMXStaggeredRenderer.js +1 -1
  48. package/dist/melonjs.mjs/level/tiled/renderer/autodetect.js +1 -1
  49. package/dist/melonjs.mjs/loader/cache.js +24 -0
  50. package/dist/melonjs.mjs/loader/loader.js +331 -716
  51. package/dist/melonjs.mjs/loader/loadingscreen.js +4 -4
  52. package/dist/melonjs.mjs/loader/melonjs_logo.png.js +1 -1
  53. package/dist/melonjs.mjs/loader/parser.js +281 -0
  54. package/dist/melonjs.mjs/loader/settings.js +91 -0
  55. package/dist/melonjs.mjs/math/color.js +1 -1
  56. package/dist/melonjs.mjs/math/math.js +1 -1
  57. package/dist/melonjs.mjs/math/matrix2.js +7 -9
  58. package/dist/melonjs.mjs/math/matrix3.js +18 -21
  59. package/dist/melonjs.mjs/math/observable_vector2.js +3 -3
  60. package/dist/melonjs.mjs/math/observable_vector3.js +3 -4
  61. package/dist/melonjs.mjs/math/vector2.js +3 -3
  62. package/dist/melonjs.mjs/math/vector3.js +3 -4
  63. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/arraymultimap.js +1 -1
  64. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/index.js +1 -1
  65. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/multimap.js +1 -1
  66. package/dist/melonjs.mjs/node_modules/@teppeis/multimaps/dist/src/setmultimap.js +1 -1
  67. package/dist/melonjs.mjs/node_modules/earcut/src/earcut.js +1 -1
  68. package/dist/melonjs.mjs/node_modules/eventemitter3/index.js +1 -1
  69. package/dist/melonjs.mjs/node_modules/eventemitter3/index2.js +1 -1
  70. package/dist/melonjs.mjs/node_modules/howler/dist/howler.js +1 -1
  71. package/dist/melonjs.mjs/particles/emitter.js +3 -3
  72. package/dist/melonjs.mjs/particles/particle.js +1 -1
  73. package/dist/melonjs.mjs/particles/settings.js +1 -1
  74. package/dist/melonjs.mjs/physics/body.js +18 -14
  75. package/dist/melonjs.mjs/physics/bounds.js +18 -70
  76. package/dist/melonjs.mjs/physics/collision.js +1 -1
  77. package/dist/melonjs.mjs/physics/detector.js +1 -1
  78. package/dist/melonjs.mjs/physics/quadtree.js +1 -1
  79. package/dist/melonjs.mjs/physics/response.js +1 -1
  80. package/dist/melonjs.mjs/physics/sat.js +1 -1
  81. package/dist/melonjs.mjs/physics/world.js +1 -1
  82. package/dist/melonjs.mjs/plugin/plugin.js +3 -3
  83. package/dist/melonjs.mjs/renderable/collectable.js +1 -1
  84. package/dist/melonjs.mjs/renderable/colorlayer.js +1 -1
  85. package/dist/melonjs.mjs/renderable/container.js +25 -19
  86. package/dist/melonjs.mjs/renderable/dragndrop.js +1 -1
  87. package/dist/melonjs.mjs/renderable/imagelayer.js +7 -1
  88. package/dist/melonjs.mjs/renderable/light2d.js +1 -1
  89. package/dist/melonjs.mjs/renderable/nineslicesprite.js +1 -1
  90. package/dist/melonjs.mjs/renderable/renderable.js +126 -105
  91. package/dist/melonjs.mjs/renderable/sprite.js +33 -54
  92. package/dist/melonjs.mjs/renderable/trigger.js +1 -1
  93. package/dist/melonjs.mjs/renderable/ui/uibaseelement.js +1 -1
  94. package/dist/melonjs.mjs/renderable/ui/uispriteelement.js +1 -1
  95. package/dist/melonjs.mjs/renderable/ui/uitextbutton.js +1 -1
  96. package/dist/melonjs.mjs/state/stage.js +1 -1
  97. package/dist/melonjs.mjs/state/state.js +2 -2
  98. package/dist/melonjs.mjs/system/device.js +1 -1
  99. package/dist/melonjs.mjs/system/dom.js +1 -1
  100. package/dist/melonjs.mjs/system/event.js +1 -1
  101. package/dist/melonjs.mjs/system/platform.js +1 -1
  102. package/dist/melonjs.mjs/system/pooling.js +8 -18
  103. package/dist/melonjs.mjs/system/save.js +1 -1
  104. package/dist/melonjs.mjs/system/timer.js +1 -1
  105. package/dist/melonjs.mjs/text/bitmaptext.js +66 -8
  106. package/dist/melonjs.mjs/text/bitmaptextdata.js +1 -1
  107. package/dist/melonjs.mjs/text/glyph.js +1 -1
  108. package/dist/melonjs.mjs/text/text.js +1 -1
  109. package/dist/melonjs.mjs/text/textmetrics.js +1 -1
  110. package/dist/melonjs.mjs/text/textstyle.js +1 -1
  111. package/dist/melonjs.mjs/tweens/easing.js +1 -1
  112. package/dist/melonjs.mjs/tweens/interpolation.js +1 -1
  113. package/dist/melonjs.mjs/tweens/tween.js +1 -1
  114. package/dist/melonjs.mjs/utils/agent.js +1 -1
  115. package/dist/melonjs.mjs/utils/array.js +1 -1
  116. package/dist/melonjs.mjs/utils/file.js +1 -1
  117. package/dist/melonjs.mjs/utils/function.js +1 -1
  118. package/dist/melonjs.mjs/utils/string.js +2 -2
  119. package/dist/melonjs.mjs/utils/utils.js +2 -4
  120. package/dist/melonjs.mjs/video/canvas/canvas_renderer.js +1 -1
  121. package/dist/melonjs.mjs/video/renderer.js +1 -1
  122. package/dist/melonjs.mjs/video/texture/atlas.js +10 -9
  123. package/dist/melonjs.mjs/video/texture/cache.js +3 -3
  124. package/dist/melonjs.mjs/video/texture/canvas_texture.js +1 -1
  125. package/dist/melonjs.mjs/video/utils/autodetect.js +1 -1
  126. package/dist/melonjs.mjs/video/video.js +2 -2
  127. package/dist/melonjs.mjs/video/webgl/buffer/vertex.js +1 -1
  128. package/dist/melonjs.mjs/video/webgl/compositors/compositor.js +235 -0
  129. package/{src/video/webgl → dist/melonjs.mjs/video/webgl/compositors}/webgl_compositor.js +28 -205
  130. package/dist/melonjs.mjs/video/webgl/glshader.js +1 -1
  131. package/dist/melonjs.mjs/video/webgl/shaders/primitive.frag.js +1 -1
  132. package/dist/melonjs.mjs/video/webgl/shaders/primitive.vert.js +1 -1
  133. package/dist/melonjs.mjs/video/webgl/shaders/quad.frag.js +1 -1
  134. package/dist/melonjs.mjs/video/webgl/shaders/quad.vert.js +1 -1
  135. package/dist/melonjs.mjs/video/webgl/utils/attributes.js +1 -1
  136. package/dist/melonjs.mjs/video/webgl/utils/precision.js +1 -1
  137. package/dist/melonjs.mjs/video/webgl/utils/program.js +1 -1
  138. package/dist/melonjs.mjs/video/webgl/utils/string.js +1 -1
  139. package/dist/melonjs.mjs/video/webgl/utils/uniforms.js +1 -1
  140. package/dist/melonjs.mjs/video/webgl/webgl_compositor.js +2 -2
  141. package/dist/melonjs.mjs/video/webgl/webgl_renderer.js +2 -2
  142. package/dist/melonjs.module.js +17844 -17809
  143. package/dist/types/entity/entity.d.ts +2 -2
  144. package/dist/types/geometries/path2d.d.ts +5 -31
  145. package/dist/types/geometries/point.d.ts +2 -7
  146. package/dist/types/geometries/poly.d.ts +0 -1
  147. package/dist/types/index.d.ts +2 -2
  148. package/dist/types/loader/cache.d.ts +7 -0
  149. package/dist/types/loader/loader.d.ts +166 -181
  150. package/dist/types/loader/parser.d.ts +41 -0
  151. package/dist/types/loader/settings.d.ts +57 -0
  152. package/dist/types/particles/emitter.d.ts +4 -4
  153. package/dist/types/physics/bounds.d.ts +29 -84
  154. package/dist/types/renderable/container.d.ts +0 -11
  155. package/dist/types/renderable/renderable.d.ts +37 -31
  156. package/dist/types/renderable/sprite.d.ts +3 -3
  157. package/dist/types/state/state.d.ts +1 -1
  158. package/dist/types/system/pooling.d.ts +2 -2
  159. package/dist/types/video/renderer.d.ts +1 -1
  160. package/dist/types/video/webgl/compositors/compositor.d.ts +101 -0
  161. package/dist/types/video/webgl/compositors/webgl_compositor.d.ts +86 -0
  162. package/dist/types/video/webgl/webgl_compositor.d.ts +2 -3
  163. package/dist/types/video/webgl/webgl_renderer.d.ts +1 -1
  164. package/package.json +16 -15
  165. package/src/audio/audio.js +3 -3
  166. package/src/entity/entity.js +42 -8
  167. package/src/geometries/ellipse.js +1 -2
  168. package/src/geometries/path2d.js +17 -41
  169. package/src/geometries/point.js +0 -5
  170. package/src/geometries/poly.js +1 -4
  171. package/src/geometries/rectangle.js +12 -8
  172. package/src/index.js +2 -2
  173. package/src/input/gamepad.js +9 -15
  174. package/src/input/pointerevent.js +1 -15
  175. package/src/level/level.js +2 -2
  176. package/src/level/tiled/TMXLayer.js +0 -7
  177. package/src/level/tiled/TMXTileMap.js +7 -3
  178. package/src/level/tiled/TMXTileset.js +4 -4
  179. package/src/loader/cache.js +16 -0
  180. package/src/loader/loader.js +339 -711
  181. package/src/loader/loadingscreen.js +3 -3
  182. package/src/loader/parser.js +279 -0
  183. package/src/loader/settings.js +85 -0
  184. package/src/math/matrix2.js +6 -8
  185. package/src/math/matrix3.js +17 -20
  186. package/src/math/observable_vector2.js +2 -2
  187. package/src/math/observable_vector3.js +2 -3
  188. package/src/math/vector2.js +2 -2
  189. package/src/math/vector3.js +2 -3
  190. package/src/particles/emitter.js +2 -2
  191. package/src/physics/body.js +17 -13
  192. package/src/physics/bounds.js +17 -69
  193. package/src/renderable/container.js +24 -18
  194. package/src/renderable/imagelayer.js +6 -0
  195. package/src/renderable/renderable.js +125 -104
  196. package/src/renderable/sprite.js +32 -53
  197. package/src/state/state.js +1 -1
  198. package/src/system/pooling.js +7 -17
  199. package/src/text/bitmaptext.js +65 -7
  200. package/src/utils/string.js +1 -1
  201. package/src/utils/utils.js +1 -3
  202. package/src/video/texture/atlas.js +9 -8
  203. package/src/video/texture/cache.js +2 -2
  204. package/src/video/video.js +1 -1
  205. package/src/video/webgl/compositors/compositor.js +227 -0
  206. package/src/video/webgl/compositors/webgl_compositor.js +300 -0
  207. package/src/video/webgl/webgl_renderer.js +1 -1
@@ -0,0 +1,57 @@
1
+ /**
2
+ * enable the nocache mechanism
3
+ * @ignore
4
+ */
5
+ export function setNocache(enable?: boolean): void;
6
+ /**
7
+ * change the default baseURL for the given asset type.<br>
8
+ * (this will prepend the asset URL and must finish with a '/')
9
+ * @name setBaseURL
10
+ * @memberof loader
11
+ * @public
12
+ * @param {string} type - "*", "audio", binary", "image", "json", "js", "tmx", "tsx"
13
+ * @param {string} [url="./"] - default base URL
14
+ * @example
15
+ * // change the base URL relative address for audio assets
16
+ * me.loader.setBaseURL("audio", "data/audio/");
17
+ * // change the base URL absolute address for all object types
18
+ * me.loader.setBaseURL("*", "http://myurl.com/")
19
+ */
20
+ export function setBaseURL(type: string, url?: string | undefined): void;
21
+ export let nocache: string;
22
+ export let baseURL: {};
23
+ /**
24
+ * crossOrigin attribute to configure the CORS requests for Image data element.
25
+ * By default (that is, when the attribute is not specified), CORS is not used at all.
26
+ * The "anonymous" keyword means that there will be no exchange of user credentials via cookies,
27
+ * client-side SSL certificates or HTTP authentication as described in the Terminology section of the CORS specification.<br>
28
+ * @type {string}
29
+ * @name crossOrigin
30
+ * @default undefined
31
+ * @memberof loader
32
+ * @see https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_settings_attributes
33
+ * @example
34
+ * // allow for cross-origin texture loading in WebGL
35
+ * me.loader.crossOrigin = "anonymous";
36
+ *
37
+ * // set all ressources to be loaded
38
+ * me.loader.preload(game.resources, this.loaded.bind(this));
39
+ */
40
+ export let crossOrigin: string;
41
+ /**
42
+ * indicates whether or not cross-site Access-Control requests should be made using credentials such as cookies,
43
+ * authorization headers or TLS client certificates. Setting withCredentials has no effect on same-site requests.
44
+ * @public
45
+ * @type {boolean}
46
+ * @name withCredentials
47
+ * @default false
48
+ * @memberof loader
49
+ * @see https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest/withCredentials
50
+ * @example
51
+ * // enable withCredentials
52
+ * me.loader.withCredentials = true;
53
+ *
54
+ * // set all ressources to be loaded
55
+ * me.loader.preload(game.resources, this.loaded.bind(this));
56
+ */
57
+ export let withCredentials: boolean;
@@ -168,18 +168,18 @@ export default class ParticleEmitter extends Container {
168
168
  isRunning(): boolean;
169
169
  /**
170
170
  * Launch particles from emitter constantly (e.g. for stream)
171
- * @param {number} duration - [optional] time that the emitter releases particles in ms
171
+ * @param {number} [duration] - time that the emitter releases particles in ms
172
172
  */
173
- streamParticles(duration: number): void;
173
+ streamParticles(duration?: number | undefined): void;
174
174
  /**
175
175
  * Stop the emitter from generating new particles (used only if emitter is Stream)
176
176
  */
177
177
  stopStream(): void;
178
178
  /**
179
179
  * Launch all particles from emitter and stop (e.g. for explosion)
180
- * @param {number} total - [optional] number of particles to launch
180
+ * @param {number} [total] - number of particles to launch
181
181
  */
182
- burstParticles(total: number): void;
182
+ burstParticles(total?: number | undefined): void;
183
183
  /**
184
184
  * @ignore
185
185
  */
@@ -4,9 +4,9 @@
4
4
  */
5
5
  export default class Bounds {
6
6
  /**
7
- * @param {Vector2d[]} [vertices] - an array of me.Vector2d points
7
+ * @param {Vector2d[]|Point[]} [vertices] - an array of Vector2d or Point
8
8
  */
9
- constructor(vertices?: Vector2d[] | undefined);
9
+ constructor(vertices?: Vector2d[] | Point[] | undefined);
10
10
  _center: Vector2d;
11
11
  /**
12
12
  * @ignore
@@ -22,147 +22,106 @@ export default class Bounds {
22
22
  } | undefined;
23
23
  /**
24
24
  * reset the bound
25
- * @name clear
26
- * @memberof Bounds
27
25
  */
28
26
  clear(): void;
29
27
  /**
30
28
  * sets the bounds to the given min and max value
31
- * @name setMinMax
32
- * @memberof Bounds
33
29
  * @param {number} minX
34
30
  * @param {number} minY
35
31
  * @param {number} maxX
36
32
  * @param {number} maxY
37
33
  */
38
34
  setMinMax(minX: number, minY: number, maxX: number, maxY: number): void;
39
- public set x(arg: number);
35
+ set x(arg: number);
40
36
  /**
41
37
  * x position of the bound
42
- * @public
43
38
  * @type {number}
44
- * @name x
45
- * @memberof Bounds
46
39
  */
47
- public get x(): number;
48
- public set y(arg: number);
40
+ get x(): number;
41
+ set y(arg: number);
49
42
  /**
50
43
  * y position of the bounds
51
- * @public
52
44
  * @type {number}
53
- * @name y
54
- * @memberof Bounds
55
45
  */
56
- public get y(): number;
57
- public set width(arg: number);
46
+ get y(): number;
47
+ set width(arg: number);
58
48
  /**
59
49
  * width of the bounds
60
- * @public
61
50
  * @type {number}
62
- * @name width
63
- * @memberof Bounds
64
51
  */
65
- public get width(): number;
66
- public set height(arg: number);
52
+ get width(): number;
53
+ set height(arg: number);
67
54
  /**
68
55
  * width of the bounds
69
- * @public
70
56
  * @type {number}
71
- * @name width
72
- * @memberof Bounds
73
57
  */
74
- public get height(): number;
58
+ get height(): number;
75
59
  /**
76
60
  * left coordinate of the bound
77
- * @public
78
61
  * @type {number}
79
- * @name left
80
- * @memberof Bounds
81
62
  */
82
- public get left(): number;
63
+ get left(): number;
83
64
  /**
84
65
  * right coordinate of the bound
85
- * @public
86
66
  * @type {number}
87
- * @name right
88
- * @memberof Bounds
89
67
  */
90
- public get right(): number;
68
+ get right(): number;
91
69
  /**
92
70
  * top coordinate of the bound
93
- * @public
94
71
  * @type {number}
95
- * @name top
96
- * @memberof Bounds
97
72
  */
98
- public get top(): number;
73
+ get top(): number;
99
74
  /**
100
75
  * bottom coordinate of the bound
101
- * @public
102
76
  * @type {number}
103
- * @name bottom
104
- * @memberof Bounds
105
77
  */
106
- public get bottom(): number;
78
+ get bottom(): number;
107
79
  /**
108
80
  * center position of the bound on the x axis
109
- * @public
110
81
  * @type {number}
111
- * @name centerX
112
- * @memberof Bounds
113
82
  */
114
- public get centerX(): number;
83
+ get centerX(): number;
115
84
  /**
116
85
  * center position of the bound on the y axis
117
- * @public
118
86
  * @type {number}
119
- * @name centerY
120
- * @memberof Bounds
121
87
  */
122
- public get centerY(): number;
88
+ get centerY(): number;
123
89
  /**
124
90
  * return the center position of the bound
125
- * @public
126
91
  * @type {Vector2d}
127
- * @name center
128
- * @memberof Bounds
129
92
  */
130
- public get center(): Vector2d;
93
+ get center(): Vector2d;
94
+ /**
95
+ * center the bounds position around the given coordinates
96
+ * @param {number} x - the x coordinate around which to center this bounds
97
+ * @param {number} y - the y coordinate around which to center this bounds
98
+ */
99
+ centerOn(x: number, y: number): Bounds;
131
100
  /**
132
101
  * Updates bounds using the given vertices
133
- * @name update
134
- * @memberof Bounds
135
- * @param {Vector2d[]} vertices - an array of me.Vector2d points
102
+ * @param {Vector2d[]|Point[]} vertices - an array of Vector2d or Point
136
103
  */
137
- update(vertices: Vector2d[]): void;
104
+ update(vertices: Vector2d[] | Point[]): void;
138
105
  /**
139
106
  * add the given vertices to the bounds definition.
140
- * @name add
141
- * @memberof Bounds
142
- * @param {Vector2d[]} vertices - an array of me.Vector2d points
107
+ * @param {Vector2d[]|Point[]} vertices - an array of Vector2d or Point
143
108
  * @param {boolean} [clear=false] - either to reset the bounds before adding the new vertices
144
109
  */
145
- add(vertices: Vector2d[], clear?: boolean | undefined): void;
110
+ add(vertices: Vector2d[] | Point[], clear?: boolean | undefined): void;
146
111
  /**
147
112
  * add the given bounds to the bounds definition.
148
- * @name addBounds
149
- * @memberof Bounds
150
113
  * @param {Bounds} bounds
151
114
  * @param {boolean} [clear=false] - either to reset the bounds before adding the new vertices
152
115
  */
153
116
  addBounds(bounds: Bounds, clear?: boolean | undefined): void;
154
117
  /**
155
118
  * add the given point to the bounds definition.
156
- * @name addPoint
157
- * @memberof Bounds
158
- * @param {Vector2d|Point} point - the point to be added to the bounds
159
- * @param {Matrix2d} [m] - an optional transform to apply to the given point (only if the given point is a vector)
119
+ * @param {Vector2d|Point} point - the vector or point to be added to the bounds
120
+ * @param {Matrix2d} [m] - an optional transform to apply to the given point (if the given point is a Vector2d)
160
121
  */
161
122
  addPoint(point: Vector2d | Point, m?: any): void;
162
123
  /**
163
124
  * add the given quad coordinates to this bound definition, multiplied by the given matrix
164
- * @name addFrame
165
- * @memberof Bounds
166
125
  * @param {number} x0 - left X coordinates of the quad
167
126
  * @param {number} y0 - top Y coordinates of the quad
168
127
  * @param {number} x1 - right X coordinates of the quad
@@ -180,8 +139,6 @@ export default class Bounds {
180
139
  */
181
140
  /**
182
141
  * Returns true if the bounds contains the given point.
183
- * @name contains
184
- * @memberof Bounds
185
142
  * @param {number} x
186
143
  * @param {number} y
187
144
  * @returns {boolean} True if the bounds contain the point, otherwise false
@@ -189,16 +146,12 @@ export default class Bounds {
189
146
  contains(...args: any[]): boolean;
190
147
  /**
191
148
  * Returns true if the two bounds intersect.
192
- * @name overlaps
193
- * @memberof Bounds
194
149
  * @param {Bounds|Rect} bounds
195
150
  * @returns {boolean} True if the bounds overlap, otherwise false
196
151
  */
197
152
  overlaps(bounds: Bounds | Rect): boolean;
198
153
  /**
199
154
  * determines whether all coordinates of this bounds are finite numbers.
200
- * @name isFinite
201
- * @memberof Bounds
202
155
  * @returns {boolean} false if all coordinates are positive or negative Infinity or NaN; otherwise, true.
203
156
  */
204
157
  isFinite(): boolean;
@@ -211,8 +164,6 @@ export default class Bounds {
211
164
  */
212
165
  /**
213
166
  * Translates the bounds by x on the x axis, and y on the y axis
214
- * @name translate
215
- * @memberof Bounds
216
167
  * @param {number} x
217
168
  * @param {number} y
218
169
  */
@@ -226,23 +177,17 @@ export default class Bounds {
226
177
  */
227
178
  /**
228
179
  * Shifts the bounds to the given x, y position.
229
- * @name shift
230
- * @memberof Bounds
231
180
  * @param {number} x
232
181
  * @param {number} y
233
182
  */
234
183
  shift(...args: any[]): void;
235
184
  /**
236
185
  * clone this bounds
237
- * @name clone
238
- * @memberof Bounds
239
186
  * @returns {Bounds}
240
187
  */
241
188
  clone(): Bounds;
242
189
  /**
243
190
  * Returns a polygon whose edges are the same as this bounds.
244
- * @name toPolygon
245
- * @memberof Bounds
246
191
  * @returns {Polygon} a new Polygon that represents this bounds.
247
192
  */
248
193
  toPolygon(): Polygon;
@@ -206,23 +206,12 @@ export default class Container extends Renderable {
206
206
  * @returns {Renderable[]} an array of renderable object
207
207
  */
208
208
  getChildren(): Renderable[];
209
- /**
210
- * update the bounding box for this shape.
211
- * @ignore
212
- * @returns {Bounds} this shape bounding box Rectangle object
213
- */
214
- updateBounds(forceUpdateChildBounds?: boolean): Bounds;
215
209
  /**
216
210
  * Checks if this container is root or if it's attached to the root container.
217
211
  * @private
218
212
  * @returns {boolean}
219
213
  */
220
214
  private isAttachedToRoot;
221
- /**
222
- * update the cointainer's bounding rect (private)
223
- * @ignore
224
- */
225
- updateBoundsPos(newX: any, newY: any): Bounds;
226
215
  /**
227
216
  * @ignore
228
217
  */
@@ -5,16 +5,28 @@
5
5
  */
6
6
  export default class Renderable extends Rect {
7
7
  /**
8
- * to identify the object as a renderable object
9
- * @ignore
8
+ * Position of the Renderable relative to its parent container
9
+ * @public
10
+ * @type {ObservableVector3d}
10
11
  */
11
- isRenderable: boolean;
12
+ public pos: ObservableVector3d;
12
13
  /**
13
- * If true then physic collision and input events will not impact this renderable
14
- * @type {boolean}
15
- * @default true
14
+ * The anchor point is used for attachment behavior, and/or when applying transformations.<br>
15
+ * The coordinate system places the origin at the top left corner of the frame (0, 0) and (1, 1) means the bottom-right corner<br>
16
+ * <img src="images/anchor_point.png"/><br>
17
+ * a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.<br>
18
+ * <br>
19
+ * <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
20
+ * To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
21
+ * @type {ObservableVector2d}
22
+ * @default <0.5,0.5>
16
23
  */
17
- isKinematic: boolean;
24
+ anchorPoint: ObservableVector2d;
25
+ /**
26
+ * the renderable default transformation matrix
27
+ * @type {Matrix2d}
28
+ */
29
+ currentTransform: Matrix2d;
18
30
  /**
19
31
  * the renderable physic body
20
32
  * @type {Body}
@@ -51,11 +63,6 @@ export default class Renderable extends Rect {
51
63
  * }
52
64
  */
53
65
  body: Body;
54
- /**
55
- * the renderable default transformation matrix
56
- * @type {Matrix2d}
57
- */
58
- currentTransform: Matrix2d;
59
66
  /**
60
67
  * (G)ame (U)nique (Id)entifier" <br>
61
68
  * a GUID will be allocated for any renderable object added <br>
@@ -100,18 +107,6 @@ export default class Renderable extends Rect {
100
107
  * @default false
101
108
  */
102
109
  floating: boolean;
103
- /**
104
- * The anchor point is used for attachment behavior, and/or when applying transformations.<br>
105
- * The coordinate system places the origin at the top left corner of the frame (0, 0) and (1, 1) means the bottom-right corner<br>
106
- * <img src="images/anchor_point.png"/><br>
107
- * a Renderable's anchor point defaults to (0.5,0.5), which corresponds to the center position.<br>
108
- * <br>
109
- * <i><b>Note:</b> Object created through Tiled will have their anchorPoint set to (0, 0) to match Tiled Level editor implementation.
110
- * To specify a value through Tiled, use a json expression like `json:{"x":0.5,"y":0.5}`. </i>
111
- * @type {ObservableVector2d}
112
- * @default <0.5,0.5>
113
- */
114
- anchorPoint: ObservableVector2d;
115
110
  /**
116
111
  * When enabled, an object container will automatically apply
117
112
  * any defined transformation before calling the child draw method.
@@ -182,15 +177,20 @@ export default class Renderable extends Rect {
182
177
  */
183
178
  name: string;
184
179
  /**
185
- * Position of the Renderable relative to its parent container
186
- * @public
187
- * @type {ObservableVector3d}
180
+ * to identify the object as a renderable object
181
+ * @ignore
188
182
  */
189
- public pos: ObservableVector3d;
183
+ isRenderable: boolean;
184
+ /**
185
+ * If true then physic collision and input events will not impact this renderable
186
+ * @type {boolean}
187
+ * @default true
188
+ */
189
+ isKinematic: boolean;
190
190
  /**
191
191
  * when true the renderable will be redrawn during the next update cycle
192
192
  * @type {boolean}
193
- * @default false
193
+ * @default true
194
194
  */
195
195
  isDirty: boolean;
196
196
  _flip: {
@@ -317,11 +317,17 @@ export default class Renderable extends Rect {
317
317
  * @returns {boolean} true if the renderable is dirty
318
318
  */
319
319
  update(dt: number): boolean;
320
+ /**
321
+ * update the bounding box for this shape.
322
+ * @param {boolean} [absolute=true] - update the bounds size and position in (world) absolute coordinates
323
+ * @returns {Bounds} this shape bounding box Rectangle object
324
+ */
325
+ updateBounds(absolute?: boolean | undefined): Bounds;
320
326
  /**
321
327
  * update the renderable's bounding rect (private)
322
328
  * @ignore
323
329
  */
324
- updateBoundsPos(newX: any, newY: any): void;
330
+ updateBoundsPos(newX?: number, newY?: number): void;
325
331
  /**
326
332
  * return the renderable absolute position in the game world
327
333
  * @returns {Vector2d}
@@ -397,6 +403,6 @@ export default class Renderable extends Rect {
397
403
  onDestroyEvent(): void;
398
404
  }
399
405
  import Rect from "./../geometries/rectangle.js";
400
- import ObservableVector2d from "./../math/observable_vector2.js";
401
406
  import ObservableVector3d from "./../math/observable_vector3.js";
407
+ import ObservableVector2d from "./../math/observable_vector2.js";
402
408
  import Color from "./../math/color.js";
@@ -83,7 +83,7 @@ export default class Sprite extends Renderable {
83
83
  anim: {};
84
84
  resetAnim: Function | (() => Sprite) | undefined;
85
85
  current: {
86
- name: string;
86
+ name: undefined;
87
87
  length: number;
88
88
  offset: object;
89
89
  width: number;
@@ -234,13 +234,13 @@ export default class Sprite extends Renderable {
234
234
  * force the current animation frame index.
235
235
  * @name setAnimationFrame
236
236
  * @memberof Sprite
237
- * @param {number} [idx=0] - animation frame index
237
+ * @param {number} [index=0] - animation frame index
238
238
  * @returns {Sprite} Reference to this object for method chaining
239
239
  * @example
240
240
  * // reset the current animation to the first frame
241
241
  * this.setAnimationFrame();
242
242
  */
243
- setAnimationFrame(idx?: number | undefined): Sprite;
243
+ setAnimationFrame(index?: number | undefined): Sprite;
244
244
  /**
245
245
  * return the current animation frame index.
246
246
  * @name getCurrentAnimationFrame
@@ -135,7 +135,7 @@ declare namespace state {
135
135
  */
136
136
  function transition(effect: string, color: any, duration?: number | undefined): void;
137
137
  /**
138
- * enable/disable transition for a specific state (by default enabled for all)
138
+ * enable/disable the transition to a particular state (by default enabled for all)
139
139
  * @name setTransition
140
140
  * @memberof state
141
141
  * @public
@@ -26,14 +26,14 @@ declare class ObjectPool {
26
26
  * @param {boolean} [recycling=false] - enables object recycling for the specified class
27
27
  * @example
28
28
  * // implement CherryEntity
29
- * class CherryEntity extends Spritesheet {
29
+ * class Cherry extends Sprite {
30
30
  * onResetEvent() {
31
31
  * // reset object mutable properties
32
32
  * this.lifeBar = 100;
33
33
  * }
34
34
  * };
35
35
  * // add our users defined entities in the object pool and enable object recycling
36
- * me.pool.register("cherryentity", CherryEntity, true);
36
+ * me.pool.register("cherrysprite", Cherry, true);
37
37
  */
38
38
  register(className: string, classObj: object, recycling?: boolean | undefined): void;
39
39
  /**
@@ -188,7 +188,7 @@ export default class Renderer {
188
188
  * @param {Rect|RoundRect|Polygon|Line|Ellipse} [mask] - the shape defining the mask to be applied
189
189
  * @param {boolean} [invert=false] - either the given shape should define what is visible (default) or the opposite
190
190
  */
191
- setMask(mask?: Rect | Polygon | Ellipse | RoundRect | Line | undefined): void;
191
+ setMask(mask?: Polygon | Rect | Ellipse | RoundRect | Line | undefined): void;
192
192
  /**
193
193
  * disable (remove) the rendering mask set through setMask.
194
194
  * @see Renderer#setMask
@@ -0,0 +1,101 @@
1
+ /**
2
+ * @classdesc
3
+ * A base Compositor object.
4
+ */
5
+ export default class Compositor {
6
+ /**
7
+ * @param {WebGLRenderer} renderer - the current WebGL renderer session
8
+ */
9
+ constructor(renderer: WebGLRenderer);
10
+ /**
11
+ * Initialize the compositor
12
+ * @ignore
13
+ */
14
+ init(renderer: any): void;
15
+ renderer: any;
16
+ gl: any;
17
+ color: any;
18
+ viewMatrix: any;
19
+ /**
20
+ * a reference to the active WebGL shader
21
+ * @type {GLShader}
22
+ */
23
+ activeShader: any;
24
+ /**
25
+ * primitive type to render (gl.POINTS, gl.LINE_STRIP, gl.LINE_LOOP, gl.LINES, gl.TRIANGLE_STRIP, gl.TRIANGLE_FAN, gl.TRIANGLES)
26
+ * @type {number}
27
+ * @default gl.TRIANGLES
28
+ */
29
+ mode: number | undefined;
30
+ /**
31
+ * an array of vertex attribute properties
32
+ * @see WebGLCompositor.addAttribute
33
+ * @type {Array}
34
+ */
35
+ attributes: any[] | undefined;
36
+ /**
37
+ * the size of a single vertex in bytes
38
+ * (will automatically be calculated as attributes definitions are added)
39
+ * @see WebGLCompositor.addAttribute
40
+ * @type {number}
41
+ */
42
+ vertexByteSize: number | undefined;
43
+ /**
44
+ * the size of a single vertex in floats
45
+ * (will automatically be calculated as attributes definitions are added)
46
+ * @see WebGLCompositor.addAttribute
47
+ * @type {number}
48
+ */
49
+ vertexSize: number | undefined;
50
+ /**
51
+ * Reset compositor internal state
52
+ * @ignore
53
+ */
54
+ reset(): void;
55
+ /**
56
+ * add vertex attribute property definition to the compositor
57
+ * @param {string} name - name of the attribute in the vertex shader
58
+ * @param {number} size - number of components per vertex attribute. Must be 1, 2, 3, or 4.
59
+ * @param {GLenum} type - data type of each component in the array
60
+ * @param {boolean} normalized - whether integer data values should be normalized into a certain range when being cast to a float
61
+ * @param {number} offset - offset in bytes of the first component in the vertex attribute array
62
+ */
63
+ addAttribute(name: string, size: number, type: GLenum, normalized: boolean, offset: number): void;
64
+ /**
65
+ * Sets the viewport
66
+ * @param {number} x - x position of viewport
67
+ * @param {number} y - y position of viewport
68
+ * @param {number} w - width of viewport
69
+ * @param {number} h - height of viewport
70
+ */
71
+ setViewport(x: number, y: number, w: number, h: number): void;
72
+ /**
73
+ * set/change the current projection matrix
74
+ * @param {Matrix3d} matrix
75
+ */
76
+ setProjection(matrix: Matrix3d): void;
77
+ /**
78
+ * Select the shader to use for compositing
79
+ * @see GLShader
80
+ * @param {GLShader} shader - a reference to a GLShader instance
81
+ */
82
+ useShader(shader: GLShader): void;
83
+ /**
84
+ * Flush batched texture operations to the GPU
85
+ * @param {number} [mode=gl.TRIANGLES] - the GL drawing mode
86
+ */
87
+ flush(mode?: number | undefined): void;
88
+ /**
89
+ * Clear the frame buffer
90
+ * @param {number} [alpha = 0.0] - the alpha value used when clearing the framebuffer
91
+ */
92
+ clear(alpha?: number | undefined): void;
93
+ /**
94
+ * Specify the color values used when clearing color buffers. The values are clamped between 0 and 1.
95
+ * @param {number} [r = 0] - the red color value used when the color buffers are cleared
96
+ * @param {number} [g = 0] - the green color value used when the color buffers are cleared
97
+ * @param {number} [b = 0] - the blue color value used when the color buffers are cleared
98
+ * @param {number} [a = 0] - the alpha color value used when the color buffers are cleared
99
+ */
100
+ clearColor(r?: number | undefined, g?: number | undefined, b?: number | undefined, a?: number | undefined): void;
101
+ }